@georgedong32/ccs 7.67.0 → 7.67.1
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/.claude/settings.local.json +5 -1
- package/dist/commands/command-catalog.d.ts +1 -1
- package/dist/commands/command-catalog.d.ts.map +1 -1
- package/dist/commands/cursor-command-display.d.ts.map +1 -1
- package/dist/commands/cursor-command-display.js +1 -0
- package/dist/commands/cursor-command-display.js.map +1 -1
- package/dist/commands/cursor-command.d.ts.map +1 -1
- package/dist/commands/cursor-command.js +41 -0
- package/dist/commands/cursor-command.js.map +1 -1
- package/dist/commands/cursor-usage-display.d.ts +29 -0
- package/dist/commands/cursor-usage-display.d.ts.map +1 -0
- package/dist/commands/cursor-usage-display.js +107 -0
- package/dist/commands/cursor-usage-display.js.map +1 -0
- package/dist/cursor/constants.d.ts +1 -1
- package/dist/cursor/constants.d.ts.map +1 -1
- package/dist/cursor/constants.js +1 -0
- package/dist/cursor/constants.js.map +1 -1
- package/dist/ui/assets/accounts-DhtktAIG.js +1 -0
- package/dist/ui/assets/{alert-dialog-DudTubF8.js → alert-dialog-DQK2Jxfk.js} +1 -1
- package/dist/ui/assets/api-Den1YY2d.js +4 -0
- package/dist/ui/assets/{auth-section-CHSm0Pb6.js → auth-section-BQitOLMK.js} +1 -1
- package/dist/ui/assets/{backups-section-wajt9dzX.js → backups-section-BLGK5re-.js} +1 -1
- package/dist/ui/assets/{channels-CHran6QE.js → channels-Dop1axTi.js} +1 -1
- package/dist/ui/assets/{checkbox-DvR--eRI.js → checkbox-DDrDuGxi.js} +1 -1
- package/dist/ui/assets/claude-extension-6WjTc0o8.js +1 -0
- package/dist/ui/assets/cliproxy-Ch7RdSMG.js +3 -0
- package/dist/ui/assets/{cliproxy-ai-providers-CjKicdzR.js → cliproxy-ai-providers-DjybBlb5.js} +7 -7
- package/dist/ui/assets/{cliproxy-control-panel-Dw9Q1OoX.js → cliproxy-control-panel-DDif_QAT.js} +1 -1
- package/dist/ui/assets/{codex-D3mdE9ZJ.js → codex-DFAV50Ee.js} +4 -4
- package/dist/ui/assets/{confirm-dialog-C5COcZYh.js → confirm-dialog-CP26_Zko.js} +1 -1
- package/dist/ui/assets/copilot-uZuyhqwv.js +3 -0
- package/dist/ui/assets/cursor-CuaM2FmN.js +1 -0
- package/dist/ui/assets/{droid-BRV6w--c.js → droid-DdjXJ2lF.js} +1 -1
- package/dist/ui/assets/{globalenv-section-D3NP1kLr.js → globalenv-section-D5_-EIlf.js} +1 -1
- package/dist/ui/assets/{health-D9LnJ4lp.js → health-BHhVKLNR.js} +1 -1
- package/dist/ui/assets/{icons-DhBsHU-U.js → icons-CQ3MLSan.js} +1 -1
- package/dist/ui/assets/{index-BCpf7__M.js → index-B8bAYHAs.js} +1 -1
- package/dist/ui/assets/{index-BYrPCHr6.js → index-Ba-43jCS.js} +1 -1
- package/dist/ui/assets/{index-A9ZK234F.js → index-Bm09kGOw.js} +1 -1
- package/dist/ui/assets/{index-DtD1WuHr.js → index-DHY37v8a.js} +1 -1
- package/dist/ui/assets/index-DLCFe4s3.js +1 -0
- package/dist/ui/assets/{index-CKNvmYLR.js → index-TSYtCr3K.js} +20 -20
- package/dist/ui/assets/{masked-input-CcbDAxug.js → masked-input-CTkIqCMg.js} +1 -1
- package/dist/ui/assets/{proxy-status-widget-DhIJtL48.js → proxy-status-widget-DPhKjJFl.js} +1 -1
- package/dist/ui/assets/{radix-ui-Zb8sVEtn.js → radix-ui-BlliRfHq.js} +1 -1
- package/dist/ui/assets/{raw-json-settings-editor-panel-BJetiLxV.js → raw-json-settings-editor-panel-DQr_y0E4.js} +1 -1
- package/dist/ui/assets/{searchable-select-DNmazsgI.js → searchable-select-C2sP7JW5.js} +1 -1
- package/dist/ui/assets/{separator-vdIGU0ab.js → separator-2lt47Sla.js} +1 -1
- package/dist/ui/assets/{shared-IFLNQqyt.js → shared-DPKtsiFQ.js} +1 -1
- package/dist/ui/assets/{table-C8wlucHc.js → table-DbsFACgT.js} +1 -1
- package/dist/ui/assets/{tanstack-DWm6aJ-G.js → tanstack-BjiH4QZq.js} +1 -1
- package/dist/ui/assets/updates-C5iL4KNn.js +1 -0
- package/dist/ui/index.html +4 -4
- package/dist/web-server/model-pricing.d.ts.map +1 -1
- package/dist/web-server/model-pricing.js +18 -0
- package/dist/web-server/model-pricing.js.map +1 -1
- package/dist/web-server/usage/aggregator.d.ts.map +1 -1
- package/dist/web-server/usage/aggregator.js +98 -0
- package/dist/web-server/usage/aggregator.js.map +1 -1
- package/dist/web-server/usage/cursor-csv-parser.d.ts +68 -0
- package/dist/web-server/usage/cursor-csv-parser.d.ts.map +1 -0
- package/dist/web-server/usage/cursor-csv-parser.js +238 -0
- package/dist/web-server/usage/cursor-csv-parser.js.map +1 -0
- package/dist/web-server/usage/cursor-data-store.d.ts +55 -0
- package/dist/web-server/usage/cursor-data-store.d.ts.map +1 -0
- package/dist/web-server/usage/cursor-data-store.js +240 -0
- package/dist/web-server/usage/cursor-data-store.js.map +1 -0
- package/dist/web-server/usage/handlers.d.ts +13 -0
- package/dist/web-server/usage/handlers.d.ts.map +1 -1
- package/dist/web-server/usage/handlers.js +105 -1
- package/dist/web-server/usage/handlers.js.map +1 -1
- package/dist/web-server/usage/routes.d.ts.map +1 -1
- package/dist/web-server/usage/routes.js +13 -0
- package/dist/web-server/usage/routes.js.map +1 -1
- package/package.json +3 -1
- package/dist/ui/assets/accounts-Cvu7FuLd.js +0 -1
- package/dist/ui/assets/api-B_SQnrmH.js +0 -4
- package/dist/ui/assets/claude-extension-EUfubgK-.js +0 -1
- package/dist/ui/assets/cliproxy-CMcQRlMQ.js +0 -3
- package/dist/ui/assets/copilot-C_bkjtNE.js +0 -3
- package/dist/ui/assets/cursor-CwFdpjUZ.js +0 -1
- package/dist/ui/assets/index-B8R9vAE9.js +0 -1
- package/dist/ui/assets/updates-BtnxoQcx.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-DWm6aJ-G.js";import{T as Pe,a as Ae,b as te,c as De,d as _e,e as Te}from"./table-C8wlucHc.js";import{l as O,a as z,ad as de,ae as ue,af as xe,ag as me,ah as he,L as T,I as X,w as D,av as Se,d as b,B as P,C as M,b as R,e as Ge,f as Me,g as Re,v as Oe,j as I,k as q,Y as Q}from"./index-CKNvmYLR.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-DudTubF8.js";import{t as k}from"./notifications-B2HqRBj7.js";import{aT as W,aU as U,aV as pe,ay as ge,Q as fe,aW as Ue,aX as Ee,k as J,am as Be,J as Qe,at as E,T as Y,v as Ze,V as Ve,m as ae,U as Xe,a5 as se,Z as ne}from"./icons-DhBsHU-U.js";import{C as re}from"./checkbox-DvR--eRI.js";import"./utils-CzKF5WmX.js";import"./form-utils-Bcoyqxpq.js";import"./code-highlight-BRUf_pqB.js";function Z(s){return Array.from(s).sort((r,t)=>r.localeCompare(t))}function We(s){const r=new Map;for(const n of s){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=s.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}}),a=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:a,sharedStandardCount:Math.max(a-i,0),deeperSharedCount:i,isolatedCount:u.length-a,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 Je(){return Ce({queryKey:["accounts"],queryFn:()=>O.accounts.list(),select:s=>{const r=s.accounts.filter(i=>i.type!=="cliproxy"),t=We(r),u=s.accounts.length-r.length,a=t.accounts.some(i=>i.name===s.default)?s.default:null;return{accounts:t.accounts,default:a,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:s.plain_ccs_lane??null}}})}function Ye(){const s=$();return F({mutationFn:r=>O.accounts.setDefault(r),onSuccess:(r,t)=>{s.invalidateQueries({queryKey:["accounts"]}),k.success(`Default account set to "${t}"`)},onError:r=>{k.error(r.message)}})}function et(){const s=$();return F({mutationFn:()=>O.accounts.resetDefault(),onSuccess:()=>{s.invalidateQueries({queryKey:["accounts"]}),k.success("Default account reset to CCS")},onError:r=>{k.error(r.message)}})}function tt(){const s=$();return F({mutationFn:r=>O.accounts.delete(r),onSuccess:(r,t)=>{s.invalidateQueries({queryKey:["accounts"]}),k.success(`Account "${t}" deleted`)},onError:r=>{k.error(r.message)}})}function be(){const s=$();return F({mutationFn:({name:r,context_mode:t,context_group:u,continuity_mode:a})=>O.accounts.updateContext(r,{context_mode:t,context_group:u,continuity_mode:a}),onSuccess:(r,t)=>{s.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 at(){const s=$();return F({mutationFn:async r=>{const t=r.filter(i=>i.context_inferred||i.continuity_inferred),a=(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-a,failedCount:a}},onSuccess:({updatedCount:r,failedCount:t})=>{if(s.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=>{s.invalidateQueries({queryKey:["accounts"]}),k.error(r.message)}})}const oe=64,st=/^[a-zA-Z][a-zA-Z0-9_-]*$/;function nt({account:s,groupSummaries:r,plainCcsLane:t,onClose:u}){const{t:a}=z(),i=be(),[c,p]=C.useState(s.context_mode==="shared"?"shared":"isolated"),[n,h]=C.useState(s.context_group||"default"),[m,y]=C.useState(s.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&&st.test(x),o=c==="isolated"||N,d=c==="shared"?Math.max((l?.sharedCount??0)-(s.context_mode==="shared"&&s.context_group===x?1:0),0):0,f=c==="shared"?Math.max((l?.deeperCount??0)-(s.continuity_mode==="deeper"&&s.context_group===x?1:0),0):0,v=t?.account_name===s.name,j=!!t&&!v,S=`ccs auth default ${s.name}`,_=`ccs auth backup ${s.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"?a("continuityOverview.lane.native"):t.kind==="account-default"?a("continuityOverview.lane.accountDefault",{name:t.account_name||""}):t.kind==="account-inherited"?a("continuityOverview.lane.accountInherited",{name:t.account_name||""}):t.kind==="profile-default"?a("continuityOverview.lane.profileDefault",{name:t.profile_name||"default"}):t.label:"",A=()=>{o&&i.mutate({name:s.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:a("editAccountContext.title")}),e.jsx(he,{children:a("editAccountContext.description",{name:s.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:a("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":a("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:a("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(U,{className:"h-4 w-4 shrink-0"}),e.jsx("span",{className:"truncate",children:a("editAccountContext.sharedOption")})]})]}),e.jsx("p",{className:"text-xs text-muted-foreground pt-1 px-1",children:a(c==="isolated"?"editAccountContext.isolatedModeHint":"editAccountContext.sharedModeHint")})]}),c==="shared"&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(T,{htmlFor:"context-group",children:a("editAccountContext.historySyncGroup")}),e.jsx(X,{id:"context-group",value:n,onChange:g=>h(g.target.value),placeholder:a("editAccountContext.groupPlaceholder"),autoComplete:"off"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:a("editAccountContext.groupHint",{max:oe})}),!N&&e.jsx("p",{className:"text-xs text-destructive",children:a("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:a("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":a("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(U,{className:"h-4 w-4 shrink-0"}),e.jsx("span",{className:"truncate",children:a("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:a("editAccountContext.deeperOption")})]})]}),e.jsx("p",{className:"text-xs text-muted-foreground pt-1 px-1",children:a(m==="standard"?"editAccountContext.standardHint":"editAccountContext.deeperHint")})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:a("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:a("continuityOverview.plainLaneTitle")}),e.jsx("p",{className:"text-muted-foreground leading-relaxed",children:a("continuityOverview.plainLaneDescription",{lane:L||"plain ccs",name:s.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:a("editAccountContext.isolatedImplication")}):e.jsxs(e.Fragment,{children:[e.jsxs("p",{children:[e.jsx("span",{className:"text-foreground font-medium",children:a("editAccountContext.sameGroupRule",{group:x})})," ",d>0?a("editAccountContext.sameGroupPeerCount",{count:d}):a("editAccountContext.noSameGroupPeer")]}),m==="deeper"&&e.jsx("p",{children:f>0?a("editAccountContext.deeperReady",{count:f}):e.jsx("span",{className:"text-amber-600 dark:text-amber-500",children:a("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:a("editAccountContext.resumeOriginalWarning")})]})]})})]}),e.jsxs(Se,{children:[e.jsx(b,{variant:"outline",onClick:u,disabled:i.isPending,children:a("editAccountContext.cancel")}),e.jsx(b,{onClick:A,disabled:!o||i.isPending,children:i.isPending?a("editAccountContext.saving"):a("editAccountContext.save")})]})]})})}function ce({data:s,defaultAccount:r,groupSummaries:t,plainCcsLane:u}){const{t:a}=z(),i=Ye(),c=tt(),p=et(),n=be(),[h,m]=C.useState(null),[y,x]=C.useState(null),l=[{accessorKey:"name",header:a("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:a("accountsTable.defaultBadge")})]})},{accessorKey:"type",header:a("accountsTable.type"),size:100,cell:({row:o})=>e.jsx("span",{className:"capitalize text-muted-foreground",children:o.original.type||"oauth"})},{accessorKey:"created",header:a("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:a("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:a("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:a(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?a("accountsTable.sameGroupPeerCount",{count:o.original.sameGroupPeerCount}):a("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:a("accountsTable.badges.legacy")}),e.jsx("p",{className:"text-[10px] text-amber-700/80 dark:text-amber-400/80 whitespace-nowrap",children:a("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:a("accountsTable.badges.isolated")})})}},{id:"actions",header:a("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:a("accountsTable.syncTitle"),children:[e.jsx(Ue,{className:"w-3.5 h-3.5 mr-1"}),a("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:a("accountsTable.confirmLegacyTitle"),children:[e.jsx(Ee,{className:"w-3 h-3 mr-1"}),a("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(J,{className:`w-3 h-3 mr-1 ${d?"opacity-50":""}`}),a(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:a(d?"accountsTable.cannotDeleteDefault":"accountsTable.deleteAccount"),children:e.jsx(Be,{className:"w-4 h-4"})})]})}}],N=ke({data:s,columns:l,getCoreRowModel:we()});return s.length===0?e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:a("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"}),a("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:a("accountsTable.deleteDialogTitle")}),e.jsx(Ke,{children:a("accountsTable.deleteDialogDesc",{name:h??""})})]}),e.jsxs(He,{children:[e.jsx(Ie,{children:a("accountsTable.cancel")}),e.jsx(qe,{className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",onClick:()=>{h&&(c.mutate(h),m(null))},children:a("accountsTable.delete")})]})]})})]})}const V=({titleKey:s,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(s),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(s)}),e.jsx("p",{className:"mt-1.5 text-muted-foreground leading-relaxed",children:t(r)})]})]})};function ie({totalAccounts:s,primaryAccountName:r,isolatedCount:t,sharedStandardCount:u,deeperSharedCount:a,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=s<2?"single":n.length===0?t===s?"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(U,{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(Y,{className:"h-6 w-6 text-amber-600 dark:text-amber-400"}),partial:e.jsx(Y,{className:"h-6 w-6 text-amber-600 dark:text-amber-400"})}[o],S=!!r&&x?.account_name===r,_=s>0&&!!x&&(!r||!S),w=s>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(V,{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(E,{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(U,{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(V,{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(E,{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(V,{titleKey:"accountsPage.sharedDeeper",descKey:"accountsPage.sharedDeeperDesc"})]}),e.jsx("span",{className:"text-lg font-mono font-bold text-indigo-900 dark:text-indigo-200",children:a})]})]})]})}const le=64;function rt({open:s,onClose:r}){const{t}=z(),[u,a]=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=()=>{a(""),c(!1),n(""),m(!1),x(!1),r()};return e.jsx(de,{open:s,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(X,{id:"profile-name",value:u,onChange:j=>a(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(X,{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(Ve,{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(J,{className:"w-4 h-4 text-green-500"}):e.jsx(ae,{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(J,{className:"w-4 h-4 mr-2"}),t("createAuthProfileDialog.copied")]}):e.jsxs(e.Fragment,{children:[e.jsx(ae,{className:"w-4 h-4 mr-2"}),t("createAuthProfileDialog.copyCommand")]})})]})]})]})})}function bt(){const{t:s}=z(),r=ve(),{data:t,isLoading:u}=Je(),a=at(),[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=()=>a.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(Xe,{className:"h-5 w-5 text-primary"}),e.jsx("h1",{className:"font-semibold",children:s("accountsPage.title")})]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[s("accountsPage.managePrefix"),e.jsx("code",{className:"mx-1 rounded bg-muted px-1 py-0.5",children:"ccs auth"}),s("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:s("accountsPage.primaryActions")}),e.jsxs(b,{size:"sm",className:"w-full justify-start",onClick:()=>c(!0),children:[e.jsx(se,{className:"w-4 h-4 mr-2"}),s("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"}),s("accountsPage.authClaudeInPool")]}),e.jsxs(b,{variant:"outline",size:"sm",className:"w-full justify-start",onClick:g,children:[s("accountsPage.openClaudePoolSettings"),e.jsx(E,{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:s("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(Y,{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:s("accountsPage.legacyContextPending",{count:h})}),m>0&&e.jsx("p",{className:"text-amber-800 dark:text-amber-300",children:s("accountsPage.legacyContinuityPending",{count:m})})]})]}),e.jsx(b,{variant:"secondary",size:"sm",className:"w-full justify-start",onClick:G,disabled:a.isPending||A===0,children:a.isPending?s("accountsPage.confirmingLegacy"):s("accountsPage.confirmLegacy",{count:A})})]})]}):e.jsx("div",{className:"rounded-md border bg-background px-3 py-2 text-xs text-muted-foreground",children:s("accountsPage.noLegacyFollowup")}),e.jsxs(M,{children:[e.jsxs(I,{className:"pb-2",children:[e.jsx(q,{className:"text-sm",children:s("accountsPage.quickCommands")}),e.jsx(Q,{children:s("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:s("accountsPage.workspaceBadge")}),e.jsx(P,{variant:"secondary",children:s("accountsPage.historySyncBadge")})]}),e.jsx("h2",{className:"mt-2 text-xl font-semibold tracking-tight",children:s("accountsPage.authAccounts")}),e.jsxs("p",{className:"mt-1 text-sm text-muted-foreground",children:[s("accountsPage.tableScopePrefix"),e.jsx("code",{className:"mx-1 rounded bg-muted px-1 py-0.5",children:"ccs auth"}),s("accountsPage.tableScopeMiddle"),e.jsx("code",{className:"mx-1 rounded bg-muted px-1 py-0.5",children:s("accountsTable.sync")}),s("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:s("accountsPage.accountMatrix")}),e.jsx(Q,{children:s("accountsPage.sharedTotalDesc",{count:y})})]}),e.jsx(R,{children:u?e.jsx("div",{className:"text-muted-foreground",children:s("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:s("accountsPage.title")}),e.jsxs(Q,{children:[s("accountsPage.managePrefix"),e.jsx("code",{className:"mx-1 rounded bg-muted px-1 py-0.5",children:"ccs auth"}),s("accountsPage.mobileManageSuffix")]})]}),e.jsxs(R,{className:"space-y-2",children:[e.jsxs(b,{className:"w-full",onClick:()=>c(!0),children:[e.jsx(se,{className:"w-4 h-4 mr-2"}),s("accountsPage.createAccount")]}),e.jsxs(b,{variant:"outline",className:"w-full",onClick:g,children:[s("accountsPage.openCliProxyClaudePool"),e.jsx(E,{className:"w-4 h-4 ml-2"})]}),e.jsxs(b,{variant:"outline",className:"w-full",onClick:K,children:[s("accountsPage.authClaudeInPool"),e.jsx(ne,{className:"w-4 h-4 ml-2"})]}),e.jsx(b,{variant:"outline",className:"w-full",onClick:G,disabled:a.isPending||A===0,children:a.isPending?s("accountsPage.confirmingLegacy"):s("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:s("accountsPage.accountMatrix")})}),e.jsx(R,{children:u?e.jsx("div",{className:"text-muted-foreground",children:s("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 Ke}from"./react-vendor-CNOkPC89.js";import{B as L,c as D,T as Je,n as Be,o as qe,p as Ye,q as Ve,r as We,s as Ge,t as me,d as v,a as B,v as ae,L as R,I as U,w as J,x as Oe,y as Xe,z as Ze,A as es,D as ss,S as je,E as Z,F as xe,G as Te,H as ts,J as as,K as Ee,M as Ae,N as _e,O as rs,Q as ns,R as Ne,U as ve,V as ee,W as is,l as ls,X as ge,C as Re,b as Me,j as os,k as cs,Y as ds,Z as ms,_ as us,$ as xs,a0 as hs,a1 as ps,a2 as gs,a3 as fs,a4 as js,a5 as Ns}from"./index-CKNvmYLR.js";import{a as vs,u as be,b as we}from"./tanstack-DWm6aJ-G.js";import{C as he}from"./confirm-dialog-C5COcZYh.js";import{t as T}from"./notifications-B2HqRBj7.js";import{L as se,R as G,am as De,an as bs,a5 as te,Q as ws,ao as Le,a6 as fe,C as Ie,ap as Cs,a3 as ys,aq as Ps,n as pe,X as ks,Z as Fe,ar as Ce,l as ye,as as Ue,at as Ss,a9 as Os,au as Ts,u as He,av as Es,v as Qe,m as As,aw as _s}from"./icons-DhBsHU-U.js";import{M as $e}from"./masked-input-CcbDAxug.js";import"./utils-CzKF5WmX.js";import"./form-utils-Bcoyqxpq.js";import"./code-highlight-BRUf_pqB.js";import"./alert-dialog-DudTubF8.js";function Rs({className:s,showTooltip:r=!0}){const n=e.jsxs(L,{variant:"outline",className:D("bg-accent/10 border-accent/30 text-accent","dark:bg-accent/20 dark:border-accent/40 dark:text-accent-foreground",s),children:[e.jsx("img",{src:"/icons/openrouter.svg",alt:"OpenRouter",className:"mr-1 h-3 w-3"}),"OpenRouter"]});return r?e.jsxs(Je,{children:[e.jsx(Be,{asChild:!0,children:n}),e.jsx(qe,{children:e.jsx("p",{children:"Access 349+ models via OpenRouter"})})]}):n}function Pe(s){return[/^ANTHROPIC_AUTH_TOKEN$/,/_API_KEY$/,/_AUTH_TOKEN$/,/^API_KEY$/,/^AUTH_TOKEN$/,/_SECRET$/,/^SECRET$/].some(n=>n.test(s))}function ze(s){return s?.env?(s.env.ANTHROPIC_BASE_URL||"").toLowerCase().includes("openrouter.ai"):!1}function Ms(s){return{opus:s.ANTHROPIC_DEFAULT_OPUS_MODEL||void 0,sonnet:s.ANTHROPIC_DEFAULT_SONNET_MODEL||void 0,haiku:s.ANTHROPIC_DEFAULT_HAIKU_MODEL||void 0}}function Ds(s,r){const n={...s};return r.opus?n.ANTHROPIC_DEFAULT_OPUS_MODEL=r.opus:delete n.ANTHROPIC_DEFAULT_OPUS_MODEL,r.sonnet?n.ANTHROPIC_DEFAULT_SONNET_MODEL=r.sonnet:delete n.ANTHROPIC_DEFAULT_SONNET_MODEL,r.haiku?n.ANTHROPIC_DEFAULT_HAIKU_MODEL=r.haiku:delete n.ANTHROPIC_DEFAULT_HAIKU_MODEL,n}function Ls({profileName:s,target:r,data:n,settings:m,isLoading:c,isSaving:g,isTargetSaving:a,hasChanges:f,isRawJsonValid:t,onTargetChange:p,onRefresh:h,onDelete:b,onSave:w}){const k=g||a,j=c||k;return e.jsxs("div",{className:"px-6 py-4 border-b bg-background flex items-center justify-between shrink-0",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h2",{className:"text-lg font-semibold",children:s}),n?.path&&e.jsx(L,{variant:"outline",className:"text-xs",children:n.path.replace(/^.*\//,"")}),ze(m)&&e.jsx(Rs,{className:"ml-1"})]}),n&&e.jsxs("p",{className:"text-xs text-muted-foreground mt-0.5",children:["Last modified: ",new Date(n.mtime).toLocaleString()]}),e.jsxs("div",{className:"mt-2 flex items-center gap-2",children:[e.jsx("span",{className:"text-xs text-muted-foreground",children:"Default target:"}),e.jsxs(Ye,{value:r,onValueChange:S=>{j||p(S)},disabled:j,children:[e.jsx(Ve,{className:"h-7 w-[170px] text-xs",disabled:j,children:e.jsx(We,{})}),e.jsxs(Ge,{children:[e.jsx(me,{value:"claude",children:"Claude Code"}),e.jsx(me,{value:"droid",children:"Factory Droid"}),e.jsx(me,{value:"codex",children:"Codex CLI"})]})]}),a&&e.jsx(se,{className:"w-3.5 h-3.5 animate-spin text-muted-foreground"})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(v,{variant:"ghost",size:"sm",onClick:h,disabled:j,children:e.jsx(G,{className:`w-4 h-4 ${c?"animate-spin":""}`})}),b&&e.jsx(v,{variant:"ghost",size:"sm",onClick:b,disabled:k,children:e.jsx(De,{className:"w-4 h-4 text-destructive"})}),e.jsx(v,{size:"sm",onClick:w,disabled:k||!f||!t,children:g?e.jsxs(e.Fragment,{children:[e.jsx(se,{className:"w-4 h-4 mr-1 animate-spin"}),"Saving..."]}):e.jsxs(e.Fragment,{children:[e.jsx(bs,{className:"w-4 h-4 mr-1"}),"Save"]})})]})]})}function Is({currentSettings:s,newEnvKey:r,newEnvValue:n,onNewEnvKeyChange:m,onNewEnvValueChange:c,onEnvValueChange:g,onAddEnvVar:a}){const{t:f}=B();return e.jsxs(e.Fragment,{children:[e.jsx(ae,{className:"flex-1",children:e.jsx("div",{className:"p-4 space-y-4",children:s?.env&&Object.keys(s.env).length>0?e.jsx(e.Fragment,{children:Object.entries(s.env).map(([t,p])=>e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs(R,{className:"text-xs font-medium flex items-center gap-2 text-muted-foreground",children:[t,Pe(t)&&e.jsx(L,{variant:"secondary",className:"text-[10px] px-1 py-0 h-4",children:f("envEditor.sensitive")})]}),Pe(t)?e.jsx($e,{value:p,onChange:h=>g(t,h.target.value),className:"font-mono text-sm h-8"}):e.jsx(U,{value:p,onChange:h=>g(t,h.target.value),className:"font-mono text-sm h-8"})]},t))}):e.jsxs("div",{className:"py-8 text-center text-muted-foreground bg-muted/30 rounded-lg border border-dashed text-sm",children:[e.jsx("p",{children:f("envEditor.none")}),e.jsx("p",{className:"text-xs mt-1 opacity-70",children:f("envEditor.noneHint")})]})})}),e.jsxs("div",{className:"p-4 border-t bg-background shrink-0",children:[e.jsx(R,{className:"text-xs font-medium text-muted-foreground",children:f("envEditor.addVariable")}),e.jsxs("div",{className:"flex gap-2 mt-2",children:[e.jsx(U,{placeholder:f("envEditor.keyPlaceholder"),value:r,onChange:t=>m(t.target.value.toUpperCase()),className:"font-mono text-sm h-8 w-2/5",onKeyDown:t=>t.key==="Enter"&&r.trim()&&a()}),e.jsx(U,{placeholder:f("envEditor.valuePlaceholder"),value:n,onChange:t=>c(t.target.value),className:"font-mono text-sm h-8 flex-1",onKeyDown:t=>t.key==="Enter"&&r.trim()&&a()}),e.jsx(v,{variant:"outline",size:"sm",className:"h-8",onClick:a,disabled:!r.trim(),children:e.jsx(te,{className:"w-4 h-4"})})]})]})]})}function Fs({profileName:s,target:r,data:n}){const{t:m}=B(),c=r==="droid";return e.jsx(ae,{className:"h-full",children:e.jsxs("div",{className:"p-4 space-y-6",children:[e.jsxs("div",{children:[e.jsxs("h3",{className:"text-sm font-medium flex items-center gap-2 mb-3",children:[e.jsx(ws,{className:"w-4 h-4"}),m("profileEditor.profileInfo")]}),e.jsx("div",{className:"space-y-3 bg-card rounded-lg border p-4 shadow-sm",children:n&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid grid-cols-[100px_1fr] gap-2 text-sm items-center",children:[e.jsx("span",{className:"font-medium text-muted-foreground",children:m("profileEditor.profileName")}),e.jsx("span",{className:"font-mono",children:n.profile})]}),e.jsxs("div",{className:"grid grid-cols-[100px_1fr] gap-2 text-sm items-center",children:[e.jsx("span",{className:"font-medium text-muted-foreground",children:m("profileEditor.filePath")}),e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsx("code",{className:"bg-muted px-1.5 py-0.5 rounded text-xs break-all",children:n.path}),e.jsx(J,{value:n.path,size:"icon",className:"h-5 w-5"})]})]}),e.jsxs("div",{className:"grid grid-cols-[100px_1fr] gap-2 text-sm items-center",children:[e.jsx("span",{className:"font-medium text-muted-foreground",children:m("profileEditor.lastModified")}),e.jsx("span",{className:"text-xs",children:new Date(n.mtime).toLocaleString()})]}),e.jsxs("div",{className:"grid grid-cols-[100px_1fr] gap-2 text-sm items-center",children:[e.jsx("span",{className:"font-medium text-muted-foreground",children:m("profileEditor.defaultTarget")}),e.jsx("span",{className:"font-mono",children:r})]})]})})]}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-medium mb-3",children:m("profileEditor.quickUsage")}),e.jsxs("div",{className:"space-y-3 bg-card rounded-lg border p-4 shadow-sm",children:[e.jsxs("div",{children:[e.jsx(R,{className:"text-xs text-muted-foreground",children:m("profileEditor.runWithProfile")}),e.jsxs("div",{className:"mt-1 flex gap-2",children:[e.jsxs("code",{className:"flex-1 px-2 py-1.5 bg-muted rounded text-xs font-mono truncate",children:["ccs ",s,' "prompt"']}),e.jsx(J,{value:`ccs ${s} "prompt"`,size:"icon",className:"h-6 w-6"})]})]}),e.jsxs("div",{children:[e.jsx(R,{className:"text-xs text-muted-foreground",children:m(c?"profileEditor.droidAliasExplicit":"profileEditor.runOnDroid")}),e.jsxs("div",{className:"mt-1 flex gap-2",children:[e.jsx("code",{className:"flex-1 px-2 py-1.5 bg-muted rounded text-xs font-mono truncate",children:`ccs-droid ${s} "prompt"`}),e.jsx(J,{value:`ccs-droid ${s} "prompt"`,size:"icon",className:"h-6 w-6"})]})]}),e.jsxs("div",{children:[e.jsx(R,{className:"text-xs text-muted-foreground",children:m(c?"profileEditor.overrideToClaude":"profileEditor.runOnDroidWithFlag")}),e.jsxs("div",{className:"mt-1 flex gap-2",children:[e.jsxs("code",{className:"flex-1 px-2 py-1.5 bg-muted rounded text-xs font-mono truncate",children:["ccs ",s," --target ",c?"claude":"droid",' "prompt"']}),e.jsx(J,{value:`ccs ${s} --target ${c?"claude":"droid"} "prompt"`,size:"icon",className:"h-6 w-6"})]})]}),e.jsxs("div",{children:[e.jsx(R,{className:"text-xs text-muted-foreground",children:m("profileEditor.setAsDefault")}),e.jsxs("div",{className:"mt-1 flex gap-2",children:[e.jsxs("code",{className:"flex-1 px-2 py-1.5 bg-muted rounded text-xs font-mono truncate",children:["ccs default ",s]}),e.jsx(J,{value:`ccs default ${s}`,size:"icon",className:"h-6 w-6"})]})]})]})]})]})})}function Us({value:s,onChange:r,placeholder:n="Search models...",className:m}){const[c,g]=u.useState(""),[a,f]=u.useState(null),{models:t,isLoading:p,isError:h,isFetching:b}=Oe(),w=Xe(),k=u.useMemo(()=>Ze(t,c,{category:a??void 0}),[t,c,a]),j=u.useMemo(()=>es(t,2),[t]),S=!c.trim()&&!a,H=u.useMemo(()=>{const d={anthropic:[],openai:[],google:[],meta:[],mistral:[],opensource:[],other:[]};k.forEach(x=>{d[x.category].push(x)});for(const x of Object.keys(d))d[x]=ss(d[x]);return d},[k]),C=u.useCallback(()=>{w()},[w]),M=t.find(d=>d.id===s);return p&&t.length===0?e.jsxs("div",{className:D("space-y-2",m),children:[e.jsx(je,{className:"h-10 w-full"}),e.jsx(je,{className:"h-32 w-full"})]}):e.jsxs("div",{className:D("space-y-2 w-full min-w-0 overflow-hidden",m),children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(Le,{className:"text-muted-foreground absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2"}),e.jsx(U,{value:c,onChange:d=>g(d.target.value),placeholder:n,className:"pl-9"})]}),e.jsx(v,{variant:"outline",size:"icon",onClick:C,disabled:b,title:"Refresh models",children:b?e.jsx(se,{className:"h-4 w-4 animate-spin"}):e.jsx(G,{className:"h-4 w-4"})})]}),e.jsxs("div",{className:"flex flex-wrap gap-1",children:[e.jsxs(L,{variant:a===null?"default":"outline",className:"cursor-pointer",onClick:()=>f(null),children:["All (",t.length,")"]}),Object.keys(Z).map(d=>{const x=H[d].length;return x===0?null:e.jsxs(L,{variant:a===d?"default":"outline",className:"cursor-pointer",onClick:()=>f(d),children:[Z[d]," (",x,")"]},d)})]}),M&&e.jsxs("div",{className:"bg-muted rounded-md p-2 text-sm",children:[e.jsx("span",{className:"font-medium",children:M.name}),e.jsxs("span",{className:"text-muted-foreground ml-2",children:[xe(M.pricing)," |"," ",Te(M.context_length)]})]}),e.jsx(ae,{className:"h-72 w-full rounded-md border",children:h?e.jsxs("div",{className:"text-destructive p-4 text-center",children:["Failed to load models."," ",e.jsx(v,{variant:"link",onClick:C,children:"Retry"})]}):k.length===0?e.jsxs("div",{className:"text-muted-foreground p-4 text-center",children:['No models found matching "',c,'"']}):e.jsxs("div",{className:"space-y-6 p-3",children:[S&&j.length>0&&e.jsxs("div",{children:[e.jsxs("div",{className:"text-muted-foreground bg-background sticky top-0 mb-2 flex items-center gap-1.5 py-1.5 text-xs font-semibold border-b pb-2",children:[e.jsx(fe,{className:"h-3 w-3 text-accent"}),e.jsx("span",{children:"Newest Models"})]}),e.jsx("div",{className:"space-y-1",children:j.map(d=>e.jsx(ke,{model:d,isSelected:d.id===s,onClick:()=>r(d.id),showAge:!0},d.id))})]}),Object.keys(Z).map(d=>{const x=H[d];return x.length===0?null:e.jsxs("div",{children:[e.jsx("div",{className:"text-muted-foreground bg-background sticky top-0 mb-2 py-1.5 text-xs font-semibold border-b pb-2",children:Z[d]}),e.jsx("div",{className:"space-y-1",children:x.map(o=>e.jsx(ke,{model:o,isSelected:o.id===s,onClick:()=>r(o.id)},o.id))})]},d)})]})})]})}function ke({model:s,isSelected:r,onClick:n,showAge:m=!1}){return e.jsxs("button",{type:"button",onClick:n,className:D("group flex w-full items-center gap-2 rounded-md px-3 py-2 text-left text-sm transition-colors","hover:bg-accent hover:text-accent-foreground",r&&"bg-accent text-accent-foreground"),children:[e.jsx("span",{className:"flex-1 min-w-0 truncate font-medium",children:s.name}),e.jsxs("span",{className:D("flex shrink-0 items-center gap-1 text-xs whitespace-nowrap",r?"text-accent-foreground/80":"text-muted-foreground group-hover:text-accent-foreground/80"),children:[m&&s.created&&e.jsx(L,{variant:"outline",className:D("text-[10px] px-1",r?"border-accent-foreground/30 text-accent-foreground/80":"text-accent border-accent/30 group-hover:text-accent-foreground/80 group-hover:border-accent-foreground/30"),children:ts(s.created)}),s.isFree?e.jsx(L,{variant:"secondary",className:D("text-[10px] px-1",r?"bg-accent-foreground/20 text-accent-foreground":"group-hover:bg-accent-foreground/20 group-hover:text-accent-foreground"),children:"Free"}):s.isExacto?e.jsxs(e.Fragment,{children:[e.jsx(L,{variant:"outline",className:D("text-[10px] px-1 border-emerald-500/50 text-emerald-600",r?"border-accent-foreground/30 text-accent-foreground/80":"group-hover:border-accent-foreground/30 group-hover:text-accent-foreground/80"),children:"Exacto"}),e.jsx("span",{className:"tabular-nums",children:xe(s.pricing)})]}):e.jsx("span",{className:"tabular-nums",children:xe(s.pricing)}),e.jsx("span",{className:"tabular-nums",children:Te(s.context_length)})]})]})}function Hs({selectedModel:s,value:r,onChange:n,className:m}){const{t:c}=B(),{models:g}=Oe(),a=u.useMemo(()=>s?as(s,g):{},[s,g]),f=()=>{n(a)},t=(h,b)=>{n({...r,[h]:b||void 0})},p=s&&Object.keys(a).length>0;return e.jsxs(Ee,{className:D("group",m),children:[e.jsxs(Ae,{className:"flex items-center gap-2 text-sm font-medium hover:underline",children:[e.jsx(Ie,{className:"h-4 w-4 transition-transform group-data-[state=open]:rotate-90"}),c("modelTierMapping.title"),e.jsxs("span",{className:"text-muted-foreground font-normal",children:["(",c("modelTierMapping.advanced"),")"]})]}),e.jsxs(_e,{className:"space-y-3 pt-3",children:[e.jsx("p",{className:"text-muted-foreground text-sm",children:c("modelTierMapping.description")}),p&&e.jsxs(v,{type:"button",variant:"outline",size:"sm",onClick:f,children:[e.jsx(Cs,{className:"mr-1 h-4 w-4"}),c("modelTierMapping.autoSuggest",{provider:s?.split("/")[0]})]}),e.jsxs("div",{className:"grid gap-3",children:[e.jsxs("div",{className:"grid grid-cols-[80px_1fr] items-center gap-2",children:[e.jsx(R,{htmlFor:"tier-opus",className:"text-right",children:"Opus"}),e.jsx(U,{id:"tier-opus",value:r.opus??"",onChange:h=>t("opus",h.target.value),placeholder:c("modelTierMapping.opusPlaceholder")})]}),e.jsxs("div",{className:"grid grid-cols-[80px_1fr] items-center gap-2",children:[e.jsx(R,{htmlFor:"tier-sonnet",className:"text-right",children:"Sonnet"}),e.jsx(U,{id:"tier-sonnet",value:r.sonnet??"",onChange:h=>t("sonnet",h.target.value),placeholder:c("modelTierMapping.sonnetPlaceholder")})]}),e.jsxs("div",{className:"grid grid-cols-[80px_1fr] items-center gap-2",children:[e.jsx(R,{htmlFor:"tier-haiku",className:"text-right",children:"Haiku"}),e.jsx(U,{id:"tier-haiku",value:r.haiku??"",onChange:h=>t("haiku",h.target.value),placeholder:c("modelTierMapping.haikuPlaceholder")})]})]}),e.jsx("p",{className:"text-muted-foreground text-xs",children:c("modelTierMapping.footer")})]})]})}function Qs({profileName:s,target:r,data:n,currentSettings:m,newEnvKey:c,newEnvValue:g,onNewEnvKeyChange:a,onNewEnvValueChange:f,onEnvValueChange:t,onAddEnvVar:p,onEnvBulkChange:h}){const b=ze(m),w=m?.env,k=u.useMemo(()=>Ms(w??{}),[w]),j=w??{},S=o=>{if(h){const Q={...j,ANTHROPIC_MODEL:o,ANTHROPIC_DEFAULT_OPUS_MODEL:o,ANTHROPIC_DEFAULT_SONNET_MODEL:o,ANTHROPIC_DEFAULT_HAIKU_MODEL:o};h(Q)}else t("ANTHROPIC_MODEL",o),t("ANTHROPIC_DEFAULT_OPUS_MODEL",o),t("ANTHROPIC_DEFAULT_SONNET_MODEL",o),t("ANTHROPIC_DEFAULT_HAIKU_MODEL",o);T.success(ee.t("commonToast.appliedModelAllTiers"),{duration:2e3})},H=o=>{if(h){const Q=Ds(j,o);h(Q)}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||"")},[C,M]=u.useState(!1),d=new Set(["ANTHROPIC_AUTH_TOKEN"]),x=Object.entries(j).filter(([o])=>!d.has(o));return e.jsx("div",{className:"h-full w-full min-w-0 flex flex-col",children:e.jsxs(rs,{defaultValue:"env",className:"h-full w-full min-w-0 flex flex-col",children:[e.jsx("div",{className:"px-4 pt-4 shrink-0",children:e.jsxs(ns,{className:"w-full",children:[e.jsx(Ne,{value:"env",className:"flex-1",children:b?"Configuration":"Environment Variables"}),e.jsx(Ne,{value:"info",className:"flex-1",children:"Info & Usage"})]})}),e.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col min-w-0",children:[e.jsx(ve,{value:"env",className:"flex-1 mt-0 border-0 p-0 data-[state=inactive]:hidden flex flex-col overflow-hidden min-w-0",children:b?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"flex-1 overflow-hidden",children:e.jsxs("div",{className:"h-full overflow-y-auto overflow-x-hidden p-4 space-y-6",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsx(R,{className:"text-sm font-medium",children:"Model Selection"}),e.jsx(Us,{value:j.ANTHROPIC_MODEL,onChange:S,placeholder:"Search OpenRouter models..."})]}),e.jsx(Hs,{selectedModel:j.ANTHROPIC_MODEL,value:k,onChange:H}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(R,{className:"text-sm font-medium",children:"API Key"}),e.jsx($e,{value:j.ANTHROPIC_AUTH_TOKEN||"",onChange: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"})]})]}),x.length>0&&e.jsxs(Ee,{open:C,onOpenChange:M,children:[e.jsxs(Ae,{className:"flex items-center gap-2 text-sm font-medium text-muted-foreground hover:text-foreground transition-colors group",children:[e.jsx(Ie,{className:D("h-4 w-4 transition-transform",C&&"rotate-90")}),e.jsx(ys,{className:"h-4 w-4"}),e.jsx("span",{children:"Additional Variables"}),e.jsxs("span",{className:"text-xs font-normal opacity-70",children:["(",x.length,")"]})]}),e.jsx(_e,{className:"pt-4",children:e.jsx("div",{className:"space-y-3 border rounded-lg p-3 bg-muted/30",children:x.map(([o,Q])=>e.jsxs("div",{className:"space-y-1",children:[e.jsx(R,{className:"text-xs text-muted-foreground",children:o}),e.jsx(U,{value:Q,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(R,{className:"text-xs font-medium text-muted-foreground",children:"Add Environment Variable"}),e.jsxs("div",{className:"flex gap-2 mt-2",children:[e.jsx(U,{placeholder:"VARIABLE_NAME",value:c,onChange:o=>a(o.target.value.toUpperCase()),className:"font-mono text-sm h-8 w-2/5",onKeyDown:o=>o.key==="Enter"&&c.trim()&&p()}),e.jsx(U,{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(v,{variant:"outline",size:"sm",className:"h-8",onClick:p,disabled:!c.trim(),children:e.jsx(te,{className:"w-4 h-4"})})]})]})]}):e.jsx(Is,{currentSettings:m,newEnvKey:c,newEnvValue:g,onNewEnvKeyChange:a,onNewEnvValueChange:f,onEnvValueChange:t,onAddEnvVar:p})}),e.jsx(ve,{value:"info",className:"h-full mt-0 border-0 p-0 data-[state=inactive]:hidden",children:e.jsx(Fs,{profileName:s,target:r,data:n})})]})]})})}function $s({profileName:s,profileTarget:r,onDelete:n,onHasChangesUpdate:m}){const[c,g]=u.useState({}),[a,f]=u.useState(!1),[t,p]=u.useState(null),[h,b]=u.useState(""),[w,k]=u.useState(""),j=vs(),{data:S,isLoading:H,isError:C,refetch:M}=be({queryKey:["settings",s],queryFn:async()=>{const l=await fetch(`/api/settings/${s}/raw`);if(!l.ok)throw new Error(`Failed to load settings: ${l.status}`);return l.json()}}),d=S?.settings,x=u.useMemo(()=>{if(t!==null)try{return JSON.parse(t)}catch{}if(d)return{...d,env:{...d.env,...c}}},[d,c,t]),o=u.useMemo(()=>t!==null?t:d?JSON.stringify(d,null,2):"",[t,d]),Q=u.useCallback(l=>{p(l)},[]),$=u.useCallback(l=>{const N={...x??{}},A=N.ccs_image&&typeof N.ccs_image=="object"?{...N.ccs_image}:{};l?A.native_read=!0:delete A.native_read,Object.keys(A).length>0?N.ccs_image=A:delete N.ccs_image,p(JSON.stringify(N,null,2))},[x]),q=(l,N)=>{const A={...x?.env||{},[l]:N};g(W=>({...W,[l]:N})),p(JSON.stringify({...x,env:A},null,2))},K=l=>{const N={...x?.env||{},...l};g(A=>({...A,...l})),p(JSON.stringify({...x,env:N},null,2))},X=()=>{if(!h.trim())return;const l=h.trim(),N=w,A={...x?.env||{},[l]:N};g(W=>({...W,[l]:N})),p(JSON.stringify({...x,env:A},null,2)),b(""),k("")},y=u.useMemo(()=>{try{return JSON.parse(o),!0}catch{return!1}},[o]),I=u.useMemo(()=>t!==null?t!==JSON.stringify(d,null,2):Object.keys(c).length>0,[t,c,d]),O=u.useDeferredValue(o),z=u.useMemo(()=>{if(!I||!y)return null;try{return JSON.parse(O)}catch{return null}},[I,y,O]),{data:Y,isFetching:re,isError:V,isPlaceholderData:ne}=be({queryKey:["settings",s,"image-analysis-status-preview",O],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()}}),ie=I&&y&&!V?Y?.imageAnalysisStatus??S?.imageAnalysisStatus:S?.imageAnalysisStatus,le=I&&y&&!V&&Y?.imageAnalysisStatus?"editor":"saved",oe=I?y?V?"saved":re&&(!Y?.imageAnalysisStatus||ne)?"refreshing":"preview":"invalid":"saved",ce=x?.ccs_image?.native_read===!0,de=u.useMemo(()=>{const l=["ANTHROPIC_BASE_URL","ANTHROPIC_AUTH_TOKEN"],N=x?.env||{};return l.filter(A=>!N[A]?.trim())},[x]);u.useEffect(()=>{m?.(I)},[I,m]);const i=we({mutationFn:async()=>{let l;try{l=JSON.parse(o)}catch{l={...S?.settings,env:{...S?.settings?.env,...c}}}const N=await fetch(`/api/settings/${s}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({settings:l,expectedMtime:S?.mtime})});if(N.status===409)throw new Error("CONFLICT");if(!N.ok)throw new Error("Failed to save");return N.json()},onSuccess:()=>{j.invalidateQueries({queryKey:["settings",s]}),j.invalidateQueries({queryKey:["profiles"]}),g({}),p(null),T.success(ee.t("commonToast.settingsSaved"))},onError:l=>{l.message==="CONFLICT"?f(!0):T.error(l.message)}}),E=we({mutationFn:async l=>(await ls.profiles.update(s,{target:l}),l),onSuccess:()=>{j.invalidateQueries({queryKey:["profiles"]}),T.success(ee.t("commonToast.defaultTargetUpdated"))},onError:(l,N)=>{const A=N==="droid"?"Factory Droid":N==="codex"?"Codex CLI":"Claude Code",W=l.message.trim()?`: ${l.message}`:"";T.error(ee.t("commonToast.failedUpdateDefaultTarget",{target:A,suffix:W}))}}),P=r||"claude",F=i.isPending||E.isPending,_=async l=>{f(!1),l?(await M(),i.mutate()):(g({}),p(null))};return e.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden",children:[e.jsx(Ls,{profileName:s,target:P,data:S,settings:x,isLoading:H,isSaving:i.isPending,isTargetSaving:E.isPending,hasChanges:I,isRawJsonValid:y,onTargetChange:l=>{F||l!==P&&E.mutate(l)},onRefresh:()=>{F||M()},onDelete:n,onSave:()=>{F||i.mutate()}}),H?e.jsxs("div",{className:"flex-1 flex items-center justify-center",children:[e.jsx(se,{className:"w-8 h-8 animate-spin text-muted-foreground"}),e.jsx("span",{className:"ml-3 text-muted-foreground",children:"Loading settings..."})]}):C?e.jsx("div",{className:"flex-1 flex items-center justify-center",children:e.jsxs("div",{className:"text-center space-y-3",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Failed to load settings."}),e.jsxs(v,{variant:"outline",size:"sm",onClick:()=>M(),children:[e.jsx(G,{className:"w-4 h-4 mr-1"}),"Retry"]})]})}):e.jsxs("div",{className:"min-h-0 flex-1 grid grid-cols-[40%_60%] divide-x overflow-hidden",children:[e.jsx("div",{className:"flex min-h-0 min-w-0 flex-col overflow-hidden bg-muted/5",children:e.jsx(Qs,{profileName:s,target:P,data:S,currentSettings:x,newEnvKey:h,newEnvValue:w,onNewEnvKeyChange:b,onNewEnvValueChange:k,onEnvValueChange:q,onEnvBulkChange:K,onAddEnvVar:X})}),e.jsxs("div",{className:"flex min-h-0 min-w-0 flex-col overflow-hidden",children:[e.jsxs("div",{className:"px-6 py-2 bg-muted/30 border-b flex items-center gap-2 shrink-0 h-[45px]",children:[e.jsx(Ps,{className:"w-4 h-4 text-muted-foreground"}),e.jsx("span",{className:"text-sm font-medium text-muted-foreground",children:"Raw Configuration (JSON)"})]}),e.jsx(is,{rawJsonContent:o,isRawJsonValid:y,rawJsonEdits:t,settings:d,profileTarget:P,imageAnalysisStatus:ie,imageAnalysisStatusSource:le,imageAnalysisStatusPreviewState:oe,nativeReadPreferenceOverride:ce,onToggleNativeRead:$,onChange:Q,missingRequiredFields:de})]})]}),e.jsx(he,{open:a,title:"File Modified Externally",description:"Overwrite with your changes or discard?",confirmText:"Overwrite",variant:"destructive",onConfirm:()=>_(!0),onCancel:()=>_(!1)})]},s)}const Se="ccs:openrouter-banner-dismissed";function zs({onCreateClick:s}){const[r,n]=u.useState(!0),{modelCount:m,isLoading:c}=ge();u.useEffect(()=>{const a=localStorage.getItem(Se)==="true";n(a)},[]);const g=()=>{localStorage.setItem(Se,"true"),n(!0)};return r?null:e.jsx("div",{className:"bg-gradient-to-r from-accent to-accent/90 text-white px-4 py-3 relative shrink-0",children:e.jsxs("div",{className:"flex items-center justify-between gap-4 max-w-screen-xl mx-auto",children:[e.jsxs("div",{className:"flex items-center gap-3 flex-1 min-w-0",children:[e.jsx("div",{className:"p-1.5 bg-white/20 rounded-md shrink-0",children:e.jsx(fe,{className:"w-4 h-4"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-medium text-sm",children:"NEW: OpenRouter Integration"}),e.jsxs("p",{className:"text-xs text-white/80 truncate",children:["Browse ",c?"300+":`${m}+`," models from OpenAI, Anthropic, Google, Meta and more."]})]})]}),e.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[s&&e.jsx(v,{size:"sm",variant:"secondary",onClick:s,className:"bg-white text-accent hover:bg-white/90 h-8",children:"Try it now"}),e.jsxs("a",{href:"https://openrouter.ai",target:"_blank",rel:"noopener noreferrer",className:"text-xs text-white/80 hover:text-white hidden sm:flex items-center gap-1",children:["Learn more",e.jsx(pe,{className:"w-3 h-3"})]}),e.jsxs(v,{size:"icon",variant:"ghost",onClick:g,className:"h-7 w-7 text-white/70 hover:text-white hover:bg-white/20",children:[e.jsx(ks,{className:"w-4 h-4"}),e.jsx("span",{className:"sr-only",children:"Dismiss"})]})]})]})})}function ue({badge:s,badgeClassName:r,className:n,title:m,description:c,visual:g,highlights:a,actionLabel:f,actionClassName:t,onAction:p,footer:h}){return e.jsxs(Re,{className:D("flex h-full flex-col border shadow-sm",n),children:[e.jsxs(os,{className:"space-y-3 pb-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[g,e.jsx(L,{variant:"secondary",className:r,children:s})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(cs,{className:"text-base",children:m}),e.jsx(ds,{className:"text-sm leading-6",children:c})]})]}),e.jsxs(Me,{className:"mt-auto flex flex-1 flex-col gap-4 pt-0",children:[e.jsx("div",{className:"space-y-2 text-xs text-muted-foreground",children:a.map(b=>e.jsxs("div",{className:"flex items-center gap-2",children:[b.icon,e.jsx("span",{children:b.label})]},b.label))}),e.jsxs(v,{onClick:p,className:t,children:[f,e.jsx(Ss,{className:"ml-2 h-4 w-4"})]}),h?e.jsx("div",{className:"text-xs text-muted-foreground",children:h}):null]})]})}function Ks({hasProfiles:s,profileCount:r,onOpenRouterClick:n,onAlibabaCodingPlanClick:m,onCliproxyClick:c,onCustomClick:g}){const{t:a}=B(),{modelCount:f,isLoading:t}=ge(),p=t?"300+":`${f}+`,h=s?a("openrouterQuickStart.profileCount",{count:r}):a("openrouterQuickStart.recommended"),b=a(s?"openrouterQuickStart.selectProfileTitle":"apiProfiles.noProfilesYet"),w=s?a("openrouterQuickStart.summaryDescriptionWithProfiles",{count:r}):a("openrouterQuickStart.summaryDescriptionNoProfiles");return e.jsx("div",{className:"flex h-full min-h-0 flex-col overflow-auto bg-muted/20 p-4 sm:p-6",children:e.jsxs("div",{className:"mx-auto flex w-full max-w-7xl flex-col gap-4",children:[e.jsx(Re,{className:"border-dashed bg-background/90 shadow-sm",children:e.jsxs(Me,{className:"flex flex-col gap-4 p-5 lg:flex-row lg:items-center lg:justify-between",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(L,{variant:"secondary",children:h}),e.jsx(L,{variant:"outline",children:a("openrouterQuickStart.openrouterModelsBadge",{modelCountLabel:p})})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("h2",{className:"text-xl font-semibold",children:b}),e.jsx("p",{className:"max-w-3xl text-sm leading-6 text-muted-foreground",children:w})]})]}),e.jsx(v,{variant:"outline",onClick:g,className:"shrink-0",children:a("openrouterQuickStart.createCustomProfile")})]})}),e.jsxs("div",{className:"grid gap-4 lg:grid-cols-2",children:[e.jsx(ue,{badge:a("openrouterQuickStart.recommended"),title:a("openrouterQuickStart.title"),description:a("openrouterQuickStart.description",{modelCountLabel:p}),visual:e.jsx("div",{className:"rounded-lg bg-accent/10 p-2",children:e.jsx("img",{src:"/icons/openrouter.svg",alt:"OpenRouter",className:"h-5 w-5"})}),highlights:[{icon:e.jsx(Fe,{className:"h-3.5 w-3.5 text-accent"}),label:a("openrouterQuickStart.featureOneApi")},{icon:e.jsx(fe,{className:"h-3.5 w-3.5 text-accent"}),label:a("openrouterQuickStart.featureTierMapping")}],actionLabel:a("openrouterQuickStart.createOpenRouterProfile"),actionClassName:"w-full bg-accent text-white hover:bg-accent/90",onAction:n,footer:e.jsxs(e.Fragment,{children:[a("openrouterQuickStart.getApiKeyAt")," ",e.jsxs("a",{href:"https://openrouter.ai/keys",target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 text-accent hover:underline",children:["openrouter.ai/keys",e.jsx(pe,{className:"h-3 w-3"})]})]})}),e.jsx(ue,{badge:a("openrouterQuickStart.runtimeProviderBadge"),badgeClassName:"bg-emerald-500/10 text-emerald-700 dark:bg-emerald-500/20 dark:text-emerald-200",title:a("openrouterQuickStart.runtimeProviderTitle"),description:a("openrouterQuickStart.runtimeProviderDescription"),visual:e.jsx("div",{className:"rounded-lg bg-emerald-500/10 p-2",children:e.jsx(Ce,{className:"h-5 w-5 text-emerald-700 dark:text-emerald-300"})}),highlights:[{icon:e.jsx(Ce,{className:"h-3.5 w-3.5 text-emerald-600"}),label:a("openrouterQuickStart.runtimeProviderFeatureConnectors")},{icon:e.jsx(ye,{className:"h-3.5 w-3.5 text-emerald-600"}),label:a("openrouterQuickStart.runtimeProviderFeatureSecrets")}],actionLabel:a("openrouterQuickStart.runtimeProviderTitle"),actionClassName:"w-full bg-emerald-600 text-white hover:bg-emerald-600/90",onAction:c,footer:e.jsx("span",{children:a("openrouterQuickStart.runtimeProviderFooter")})}),e.jsx(ue,{badge:a("alibabaCodingPlanQuickStart.recommended"),badgeClassName:"bg-orange-500/10 text-orange-700 dark:bg-orange-500/20 dark:text-orange-200",className:"lg:col-span-2",title:a("alibabaCodingPlanQuickStart.title"),description:a("alibabaCodingPlanQuickStart.description"),visual:e.jsx("div",{className:"rounded-lg bg-orange-500/10 p-2",children:e.jsx("img",{src:"/assets/providers/alibabacloud-color.svg",alt:"Alibaba Coding Plan",className:"h-5 w-5"})}),highlights:[{icon:e.jsx(Ue,{className:"h-3.5 w-3.5 text-orange-600"}),label:a("alibabaCodingPlanQuickStart.featureEndpoint")},{icon:e.jsx(ye,{className:"h-3.5 w-3.5 text-orange-600"}),label:a("alibabaCodingPlanQuickStart.featureKeyFormat")}],actionLabel:a("alibabaCodingPlanQuickStart.createAlibabaProfile"),actionClassName:"w-full bg-orange-600 text-white hover:bg-orange-600/90",onAction:m,footer:e.jsxs(e.Fragment,{children:[a("alibabaCodingPlanQuickStart.readGuideAt")," ",e.jsxs("a",{href:"https://www.alibabacloud.com/help/en/model-studio/coding-plan",target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 text-orange-700 hover:underline dark:text-orange-400",children:["Alibaba Cloud Model Studio",e.jsx(pe,{className:"h-3 w-3"})]})]})})]})]})})}function Js({onCreateClick:s}){const{modelCount:r,isLoading:n}=ge();return e.jsx("div",{className:"p-3 border-t bg-gradient-to-r from-accent/5 to-accent/10 dark:from-accent/10 dark:to-accent/15",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"p-1.5 bg-accent/10 dark:bg-accent/20 rounded shrink-0",children:e.jsx("img",{src:"/icons/openrouter.svg",alt:"",className:"w-4 h-4"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-xs font-medium text-accent dark:text-accent-foreground",children:"OpenRouter"}),e.jsxs("p",{className:"text-[10px] text-muted-foreground truncate",children:[n?"300+":`${r}+`," models available"]})]}),e.jsxs(v,{size:"sm",variant:"ghost",onClick:s,className:"h-7 px-2 text-accent hover:text-accent hover:bg-accent/10 dark:hover:bg-accent/20",children:[e.jsx(Fe,{className:"w-3 h-3 mr-1"}),e.jsx("span",{className:"text-xs",children:"Add"})]})]})})}function Bs({onCreateClick:s}){const{t:r}=B();return e.jsx("div",{className:"p-3 border-t bg-gradient-to-r from-orange-500/5 to-orange-500/10 dark:from-orange-500/10 dark:to-orange-500/15",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"p-1.5 bg-orange-500/10 dark:bg-orange-500/20 rounded shrink-0",children:e.jsx("img",{src:"/assets/providers/alibabacloud-color.svg",alt:"",className:"w-4 h-4"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-xs font-medium text-orange-700 dark:text-orange-300",children:r("alibabaCodingPlanPromo.title")}),e.jsx("p",{className:"text-[10px] text-muted-foreground truncate",children:r("alibabaCodingPlanPromo.subtitle")})]}),e.jsxs(v,{size:"sm",variant:"ghost",onClick:s,className:"h-7 px-2 text-orange-700 dark:text-orange-300 hover:text-orange-700 hover:bg-orange-500/10 dark:hover:bg-orange-500/20",children:[e.jsx(Ue,{className:"w-3 h-3 mr-1"}),e.jsx("span",{className:"text-xs",children:r("alibabaCodingPlanPromo.add")})]})]})})}function it(){const{t:s}=B(),r=Ke(),{data:n,isLoading:m,isError:c,refetch:g}=ms(),a=us(),f=xs(),t=hs(),p=ps(),h=gs(),b=fs(),[w,k]=u.useState(null),[j,S]=u.useState(""),[H,C]=u.useState(!1),[M,d]=u.useState("normal"),[x,o]=u.useState(null),[Q,$]=u.useState(!1),[q,K]=u.useState(null),X=u.useRef(null);js();const y=u.useMemo(()=>n?.profiles||[],[n?.profiles]),I=u.useMemo(()=>y.filter(i=>i.name.toLowerCase().includes(j.toLowerCase())),[y,j]),O=w?y.find(i=>i.name===w):null,z=i=>{Q&&w!==i?K(i):k(i)},Y=i=>{a.mutate(i,{onSuccess:()=>{w===i&&(k(null),$(!1),K(null)),o(null)}})},re=i=>{C(!1),z(i)},V=i=>{z(i)},ne=(i,E)=>{const P=JSON.stringify(E,null,2)+`
|
|
2
|
-
`,F=new Blob([P],{type:"application/json"}),_=URL.createObjectURL(F),l=document.createElement("a");l.href=_,l.download=i,document.body.appendChild(l),l.click(),l.remove(),URL.revokeObjectURL(_)},ie=async()=>{try{const i=await f.mutateAsync();if(i.orphans.length===0){T.success("No orphan profile settings found");return}const E=i.orphans.filter(l=>l.validation.valid).length;if(!window.confirm(`Found ${i.orphans.length} orphan settings file(s). Register ${E} valid profile(s) now?`))return;const F=await t.mutateAsync({}),_=F.skipped.length>0?`, skipped ${F.skipped.length}`:"";T.success(`Registered ${F.registered.length} profile(s)${_}`)}catch(i){T.error(i.message)}},le=async()=>{if(!O)return;const i=window.prompt(`Copy profile "${O.name}" to new profile name:`,`${O.name}-copy`);if(!i)return;const E=i.trim();if(!E){T.error("Destination profile name cannot be empty");return}try{const P=await p.mutateAsync({name:O.name,data:{destination:E}});z(E),P.warnings&&P.warnings.length>0&&T.info(P.warnings.join(`
|
|
3
|
-
`))}catch(P){T.error(P.message)}},oe=async()=>{if(O)try{const i=await h.mutateAsync({name:O.name});ne(`${O.name}.ccs-profile.json`,i.bundle),i.redacted?T.info("Export created with redacted token. Use include-secrets flow in CLI if needed."):T.success("Profile export downloaded")}catch(i){T.error(i.message)}},ce=()=>{X.current?.click()},de=async i=>{const E=i.target.files?.[0];if(i.target.value="",!!E)try{const P=await E.text(),F=JSON.parse(P),_=await b.mutateAsync({bundle:F});_.name&&z(_.name),_.warnings&&_.warnings.length>0&&T.info(_.warnings.join(`
|
|
4
|
-
`))}catch(P){T.error(P.message||"Failed to import profile bundle")}};return e.jsxs("div",{className:"flex h-full min-h-0 flex-col overflow-hidden",children:[e.jsx(zs,{onCreateClick:()=>C(!0)}),e.jsxs("div",{className:"flex-1 flex min-h-0 overflow-hidden",children:[e.jsxs("div",{className:"w-80 border-r flex flex-col bg-muted/30",children:[e.jsxs("div",{className:"p-4 border-b bg-background",children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Os,{className:"w-5 h-5 text-primary"}),e.jsx("h1",{className:"font-semibold",children:s("apiProfiles.title")})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(v,{size:"sm",variant:"outline",onClick:()=>void ie(),disabled:f.isPending||t.isPending,"aria-label":"Discover orphan profiles",title:"Discover orphan profiles",children:e.jsx(G,{className:`w-4 h-4 ${f.isPending?"animate-spin":""}`})}),e.jsx(v,{size:"sm",variant:"outline",onClick:ce,disabled:b.isPending,"aria-label":"Import profile bundle",title:"Import profile bundle",children:e.jsx(Ts,{className:"w-4 h-4"})}),e.jsxs(v,{size:"sm",onClick:()=>{C(!0)},children:[e.jsx(te,{className:"w-4 h-4 mr-1"}),s("apiProfiles.new")]})]})]}),e.jsxs("div",{className:"relative",children:[e.jsx(Le,{className:"absolute left-2.5 top-2.5 h-4 w-4 text-muted-foreground"}),e.jsx(U,{placeholder:s("apiProfiles.searchPlaceholder"),className:"pl-8 h-9",value:j,onChange:i=>S(i.target.value)})]})]}),e.jsx(ae,{className:"flex-1 min-h-0",children:m?e.jsx("div",{className:"p-4 text-sm text-muted-foreground",children:s("apiProfiles.loadingProfiles")}):c?e.jsx("div",{className:"p-4 text-center",children:e.jsxs("div",{className:"space-y-3 py-8",children:[e.jsx(He,{className:"w-12 h-12 mx-auto text-destructive/50"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:s("apiProfiles.failedLoadTitle")}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:s("apiProfiles.failedLoadDesc")})]}),e.jsxs(v,{size:"sm",variant:"outline",onClick:()=>g(),children:[e.jsx(G,{className:"w-4 h-4 mr-1"}),s("apiProfiles.retry")]})]})}):I.length===0?e.jsx("div",{className:"p-4 text-center",children:y.length===0?e.jsxs("div",{className:"space-y-3 py-8",children:[e.jsx(Es,{className:"w-12 h-12 mx-auto text-muted-foreground/50"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:s("apiProfiles.noProfilesYet")}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:s("apiProfiles.noProfilesDesc")})]}),e.jsxs(v,{size:"sm",variant:"outline",onClick:()=>{C(!0)},children:[e.jsx(te,{className:"w-4 h-4 mr-1"}),s("apiProfiles.createProfile")]})]}):e.jsx("p",{className:"text-sm text-muted-foreground py-4",children:s("apiProfiles.noProfileMatch",{query:j})})}):e.jsx("div",{className:"p-2 space-y-1",children:I.map(i=>e.jsx(qs,{profile:i,isSelected:w===i.name,onSelect:()=>V(i.name),onDelete:()=>o(i.name)},i.name))})}),y.length>0&&e.jsx("div",{className:"p-3 border-t bg-background text-xs text-muted-foreground",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{children:s("apiProfiles.profileCount",{count:y.length})}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Qe,{className:"w-3 h-3 text-green-600"}),s("apiProfiles.configuredCount",{count:y.filter(i=>i.configured).length})]})]})}),e.jsx(Js,{onCreateClick:()=>{d("openrouter"),C(!0)}}),e.jsx(Bs,{onCreateClick:()=>{d("alibaba-coding-plan"),C(!0)}})]}),e.jsx("div",{className:"flex min-h-0 flex-1 flex-col min-w-0 overflow-hidden",children:O?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"px-4 py-2 border-b bg-background flex items-center justify-end gap-2",children:[e.jsxs(v,{size:"sm",variant:"outline",onClick:()=>void le(),disabled:p.isPending,children:[e.jsx(As,{className:"w-4 h-4 mr-1"}),"Copy"]}),e.jsxs(v,{size:"sm",variant:"outline",onClick:()=>void oe(),disabled:h.isPending,children:[e.jsx(_s,{className:"w-4 h-4 mr-1"}),"Export"]})]}),e.jsx($s,{profileName:O.name,profileTarget:O.target,onDelete:()=>o(O.name),onHasChangesUpdate:$},O.name)]}):e.jsx(Ks,{hasProfiles:y.length>0,profileCount:y.length,onCliproxyClick:()=>{r("/cliproxy/ai-providers")},onOpenRouterClick:()=>{d("openrouter"),C(!0)},onAlibabaCodingPlanClick:()=>{d("alibaba-coding-plan"),C(!0)},onCustomClick:()=>{d("normal"),C(!0)}})})]}),e.jsx("input",{ref:X,type:"file",accept:".json,application/json",className:"hidden",onChange:i=>void de(i)}),e.jsx(Ns,{open:H,onOpenChange:C,onSuccess:re,initialMode:M}),e.jsx(he,{open:!!x,title:s("apiProfiles.deleteProfileTitle"),description:s("apiProfiles.deleteProfileDesc",{name:x??""}),confirmText:s("apiProfiles.delete"),variant:"destructive",onConfirm:()=>x&&Y(x),onCancel:()=>o(null)}),e.jsx(he,{open:!!q,title:s("apiProfiles.unsavedChangesTitle"),description:s("apiProfiles.unsavedChangesDesc",{current:w??"",next:q??""}),confirmText:s("apiProfiles.discardSwitch"),variant:"destructive",onConfirm:()=>{$(!1),k(q),K(null)},onCancel:()=>K(null)})]})}function qs({profile:s,isSelected:r,onSelect:n,onDelete:m}){return e.jsxs("div",{className:D("group flex items-center gap-2 px-3 py-2.5 rounded-md cursor-pointer transition-colors",r?"bg-primary/10 border border-primary/20":"hover:bg-muted border border-transparent"),onClick:n,children:[s.configured?e.jsx(Qe,{className:"w-4 h-4 text-green-600 shrink-0"}):e.jsx(He,{className:"w-4 h-4 text-yellow-600 shrink-0"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsx("div",{className:"font-medium text-sm truncate",children:s.name}),e.jsx(L,{variant:"outline",className:"text-[10px] h-4 px-1.5 uppercase",children:s.target||"claude"})]}),e.jsxs("div",{className:"flex items-center gap-1.5 min-w-0",children:[e.jsx("div",{className:"text-xs text-muted-foreground truncate flex-1",children:s.settingsPath}),e.jsx(J,{value:s.settingsPath,size:"icon",className:"h-5 w-5 opacity-0 group-hover:opacity-100 transition-opacity"})]})]}),e.jsx(v,{variant:"ghost",size:"icon",className:"h-7 w-7 opacity-0 group-hover:opacity-100 transition-opacity",onClick:c=>{c.stopPropagation(),m()},children:e.jsx(De,{className:"w-3.5 h-3.5 text-destructive"})})]})}export{it as ApiPage};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{j as e}from"./radix-ui-Zb8sVEtn.js";import{r as W}from"./react-vendor-CNOkPC89.js";import{b1 as Ce,B as p,d as y,v as se,C as u,j as f,k as j,Y as v,b as h,I as G,p as te,q as ae,r as ne,s as ie,t as re,w as F,O as we,Q as Ee,R as le,U as de,c as xe}from"./index-CKNvmYLR.js";import{u as K,a as J,b as M}from"./tanstack-DWm6aJ-G.js";import{t as E}from"./notifications-B2HqRBj7.js";import{a6 as Pe,a5 as ke,L as U,an as De,am as Be,R as Ie,T as oe,aG as Te,a3 as Re}from"./icons-DhBsHU-U.js";import"./utils-CzKF5WmX.js";import"./form-utils-Bcoyqxpq.js";import"./code-highlight-BRUf_pqB.js";const $=["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 Oe(){return K({queryKey:$,queryFn:()=>P("/claude-extension/bindings")})}function $e(s){return K({queryKey:["claude-extension-binding-status",s],enabled:!!s,queryFn:()=>P(`/claude-extension/bindings/${encodeURIComponent(s||"")}/verify`)})}function Le(){const s=J();return M({mutationFn:a=>P("/claude-extension/bindings",{method:"POST",body:JSON.stringify(a)}),onSuccess:()=>{s.invalidateQueries({queryKey:$}),E.success("Binding created")},onError:a=>E.error(a.message)})}function Qe(){const s=J();return M({mutationFn:({id:a,binding:n})=>P(`/claude-extension/bindings/${encodeURIComponent(a)}`,{method:"PUT",body:JSON.stringify(n)}),onSuccess:(a,n)=>{s.invalidateQueries({queryKey:$}),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 M({mutationFn:a=>P(`/claude-extension/bindings/${encodeURIComponent(a)}`,{method:"DELETE"}),onSuccess:()=>{s.invalidateQueries({queryKey:$}),E.success("Binding deleted")},onError:a=>E.error(a.message)})}function ge(s,a){const n=J();return M({mutationFn:({id:l,target:S})=>P(`/claude-extension/bindings/${encodeURIComponent(l)}/${s}`,{method:"POST",body:JSON.stringify({target:S})}),onSuccess:l=>{n.invalidateQueries({queryKey:$}),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 Me(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 Ve({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 ze(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:ze(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(Ve,{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 _e({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=Oe(),n=Le(),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),[L,T]=W.useState(null),[H,k]=W.useState(()=>ce("default")),c=fe||w.length===0,b=!c&&w.length>0?w.find(t=>t.id===L)??(L?null:w[0]):null,g=b?.id??null,r=c||!b||L?H:q(b),Y=Ae(r.profile,r.host),A=$e(c?void 0:g||void 0),d=B.find(t=>t.id===r.host),V=D.find(t=>t.name===r.profile),z=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 _(){I(!0),T(null),k(ce(pe))}async function ye(){if(!Z)return;const t=Me(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]))):_()}function O(t,N){if(!c&&b&&!L){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:_,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(G,{value:r.name,onChange:t=>O("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=>O("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:V?.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=>O("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(G,{value:r.ideSettingsPath,onChange:t=>O("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(G,{value:r.notes,onChange:t=>O("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:_,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(_e,{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:[V?e.jsx(p,{variant:"outline",children:V.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]})]}),z?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:z.message})]})}):null,z?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,3 +0,0 @@
|
|
|
1
|
-
import{j as e}from"./radix-ui-Zb8sVEtn.js";import{r as c}from"./react-vendor-CNOkPC89.js";import{a as Ve,u as hs,b as Qs}from"./tanstack-DWm6aJ-G.js";import{a6 as Js,d as I,C as gs,b as fs,a7 as vs,c as B,P as Be,B as G,a as se,a8 as ee,L as Y,I as de,p as js,q as Ns,r as bs,s as ys,t as Le,a9 as ws,aa as Ws,ab as Xs,ac as Ys,u as Cs,ad as ze,ae as $e,af as Qe,ag as Je,ah as ks,ai as ns,aj as Zs,ak as et,V as As,al as _e,am as Ss,l as ke,an as st,ao as is,ap as tt,aq as at,ar as nt,as as it,at as rt,au as rs,av as ot,w as Ps,v as We,aw as Xe,ax as os,ay as Ms,az as lt,aA as ct,aB as dt,aC as ut,aD as Fe,T as Ue,n as qe,o as Ke,aE as mt,aF as pt,aG as xt,aH as ls,aI as ht,aJ as gt,aK as ft,aL as vt,aM as jt,aN as Nt,O as bt,Q as yt,R as cs,U as ds,aO as wt,aP as Ct,aQ as kt,aR as At,aS as St,aT as Pt,aU as Mt,aV as Dt,aW as Tt,aX as Et,aY as Ot,aZ as Rt,S as It}from"./index-CKNvmYLR.js";import{C as He}from"./default-ports-1QQSffYX.js";import{t as U}from"./notifications-B2HqRBj7.js";import{C as Ds,L as Z,n as me,V as Lt,k as ue,m as Ts,ax as Ye,R as Ze,o as fe,a6 as je,T as es,a3 as _t,ay as Es,aw as Ft,x as ss,Z as Ne,Q as Os,h as Ut,s as Rs,az as qt,an as Kt,X as ts,a5 as Is,D as Ls,y as _s,aA as Ht,am as Fs,aB as Gt,aq as Vt,aC as Us}from"./icons-DhBsHU-U.js";import{R as Ae,A as us,D as Oe,i as Bt,a as zt}from"./antigravity-responsibility-constants-Bvh4Ybz0.js";import{C as Se}from"./checkbox-DvR--eRI.js";import{C as $t}from"./confirm-dialog-C5COcZYh.js";import{S as as}from"./separator-vdIGU0ab.js";import{S as Qt}from"./searchable-select-DNmazsgI.js";import{P as Jt}from"./proxy-status-widget-DhIJtL48.js";import"./utils-CzKF5WmX.js";import"./form-utils-Bcoyqxpq.js";import"./code-highlight-BRUf_pqB.js";import"./alert-dialog-DudTubF8.js";const qs=Object.freeze({"gemini-3-pro-preview":"gemini-3.1-pro-preview","gemini-3.1-pro-preview":"gemini-3-pro-preview","gemini-3-flash-preview":"gemini-3.1-flash-preview","gemini-3.1-flash-preview":"gemini-3-flash-preview"}),Wt=/^gemini-(\d+(?:[.-]\d+)*)-(pro|flash)-preview(-customtools)?$/i;function ve(s){return Js(s).toLowerCase()}function Pe(s){const t=ve(s),a=t.match(Wt);if(!a)return null;const[,n,i,d]=a;return{normalizedId:t,version:n.split(/[.-]/).map(u=>Number(u)),family:i,customtools:!!d,dottedVersion:n.includes(".")}}function Ks(s,t){const a=Math.max(s.length,t.length);for(let n=0;n<a;n+=1){const i=s[n]??0,d=t[n]??0;if(i!==d)return i>d?1:-1}return 0}function Xt(s,t,a){if(s.customtools!==t.customtools)return s.customtools?1:-1;const n=Ks(s.version,t.version);if(n!==0)return n>0?-1:1;const i=+(s.dottedVersion===a.dottedVersion),d=+(t.dottedVersion===a.dottedVersion);return i!==d?d-i:s.normalizedId.localeCompare(t.normalizedId)}function ms(s,t){const a=ve(t);return s.find(n=>ve(n.id)===a)?.id}function Yt(s,t){const a=Pe(s);return!a||t.length===0?void 0:t.map(i=>{const d=Pe(i.id);return!d||d.family!==a.family?null:{id:i.id,info:d}}).filter(i=>!!i).sort((i,d)=>Xt(i.info,d.info,a))[0]?.id}const pe={agy:{provider:"agy",displayName:"Antigravity",defaultModel:"claude-opus-4-6-thinking",models:[{id:"claude-opus-4-6-thinking",name:"Claude Opus 4.6 Thinking",description:"Latest flagship, extended thinking",extendedContext:!1,presetMapping:{default:"claude-opus-4-6-thinking",opus:"claude-opus-4-6-thinking",sonnet:"claude-sonnet-4-6",haiku:"claude-sonnet-4-6"}},{id:"claude-sonnet-4-6",name:"Claude Sonnet 4.6",description:"Latest Sonnet with thinking budget support",presetMapping:{default:"claude-sonnet-4-6",opus:"claude-opus-4-6-thinking",sonnet:"claude-sonnet-4-6",haiku:"claude-sonnet-4-6"}},{id:"gemini-3.1-pro-preview",name:"Gemini Pro",description:"Resolves to the best advertised Gemini Pro preview via Antigravity",extendedContext:!0,presetMapping:{default:"gemini-3.1-pro-preview",opus:"gemini-3.1-pro-preview",sonnet:"gemini-3.1-pro-preview",haiku:"gemini-3-1-flash-preview"}},{id:"gemini-3-1-flash-preview",name:"Gemini Flash",description:"Resolves to the best advertised Gemini Flash preview via Antigravity",extendedContext:!0,presetMapping:{default:"gemini-3-1-flash-preview",opus:"gemini-3.1-pro-preview",sonnet:"gemini-3.1-pro-preview",haiku:"gemini-3-1-flash-preview"}}]},gemini:{provider:"gemini",displayName:"Gemini",defaultModel:"gemini-2.5-pro",models:[{id:"gemini-3.1-pro-preview",name:"Gemini Pro",tier:"paid",description:"Uses the best advertised Gemini Pro preview when Google exposes one",extendedContext:!0,presetMapping:{default:"gemini-3.1-pro-preview",opus:"gemini-3.1-pro-preview",sonnet:"gemini-3.1-pro-preview",haiku:"gemini-3-flash-preview"}},{id:"gemini-3-flash-preview",name:"Gemini Flash",tier:"paid",description:"Uses the best advertised Gemini Flash preview when Google exposes one",extendedContext:!0,presetMapping:{default:"gemini-3-flash-preview",opus:"gemini-3.1-pro-preview",sonnet:"gemini-3.1-pro-preview",haiku:"gemini-3-flash-preview"}},{id:"gemini-2.5-pro",name:"Gemini 2.5 Pro",description:"Stable, works with free Google account",extendedContext:!0,presetMapping:{default:"gemini-2.5-pro",opus:"gemini-2.5-pro",sonnet:"gemini-2.5-pro",haiku:"gemini-2.5-flash"}}]},codex:{provider:"codex",displayName:"Codex",defaultModel:"gpt-5-codex",models:[{id:"gpt-5-codex",name:"GPT-5 Codex",description:"Cross-plan safe Codex default",presetMapping:{default:"gpt-5-codex",opus:"gpt-5-codex",sonnet:"gpt-5-codex",haiku:"gpt-5-codex-mini"}},{id:"gpt-5-codex-mini",name:"GPT-5 Codex Mini",description:"Faster and cheaper Codex option",presetMapping:{default:"gpt-5-codex-mini",opus:"gpt-5-codex",sonnet:"gpt-5-codex",haiku:"gpt-5-codex-mini"}},{id:"gpt-5-mini",name:"GPT-5 Mini",description:"Legacy mini model ID kept for backwards compatibility",presetMapping:{default:"gpt-5-mini",opus:"gpt-5-codex",sonnet:"gpt-5-mini",haiku:"gpt-5-mini"}},{id:"gpt-5.1-codex-mini",name:"GPT-5.1 Codex Mini",description:"Legacy fast Codex mini model",presetMapping:{default:"gpt-5.1-codex-mini",opus:"gpt-5.1-codex-max",sonnet:"gpt-5.1-codex-max",haiku:"gpt-5.1-codex-mini"}},{id:"gpt-5.1-codex-max",name:"GPT-5.1 Codex Max",description:"Higher-effort Codex model with xhigh support",presetMapping:{default:"gpt-5.1-codex-max",opus:"gpt-5.1-codex-max",sonnet:"gpt-5.1-codex-max",haiku:"gpt-5.1-codex-mini"}},{id:"gpt-5.2-codex",name:"GPT-5.2 Codex",description:"Cross-plan Codex model with xhigh support",presetMapping:{default:"gpt-5.2-codex",opus:"gpt-5.2-codex",sonnet:"gpt-5.2-codex",haiku:"gpt-5-codex-mini"}},{id:"gpt-5.3-codex",name:"GPT-5.3 Codex",tier:"paid",description:"Paid Codex plans only",presetMapping:{default:"gpt-5.3-codex",opus:"gpt-5.3-codex",sonnet:"gpt-5.3-codex",haiku:"gpt-5-codex-mini"}},{id:"gpt-5.3-codex-spark",name:"GPT-5.3 Codex Spark",tier:"paid",description:"Paid Codex plans only, ultra-fast coding model",presetMapping:{default:"gpt-5.3-codex-spark",opus:"gpt-5.3-codex",sonnet:"gpt-5.3-codex",haiku:"gpt-5-codex-mini"}},{id:"gpt-5.4",name:"GPT-5.4",tier:"paid",description:"Paid Codex plans only, latest GPT-5 family model",presetMapping:{default:"gpt-5.4",opus:"gpt-5.4",sonnet:"gpt-5.4",haiku:"gpt-5-codex-mini"}}]},qwen:{provider:"qwen",displayName:"Qwen",defaultModel:"qwen3-coder-plus",models:[{id:"qwen3-coder-plus",name:"Qwen3 Coder Plus",description:"Code-focused model (1M context)",presetMapping:{default:"qwen3-coder-plus",opus:"qwen3-max",sonnet:"qwen3-coder-plus",haiku:"qwen3-coder-flash"}},{id:"qwen3-max",name:"Qwen3 Max",description:"Flagship model (256K context)",presetMapping:{default:"qwen3-max",opus:"qwen3-max",sonnet:"qwen3-coder-plus",haiku:"qwen3-coder-flash"}},{id:"qwen3-max-preview",name:"Qwen3 Max Preview",description:"Preview with thinking support (256K)",presetMapping:{default:"qwen3-max-preview",opus:"qwen3-max-preview",sonnet:"qwen3-max",haiku:"qwen3-coder-flash"}},{id:"qwen3-235b",name:"Qwen3 235B",description:"Large 235B A22B model",presetMapping:{default:"qwen3-235b",opus:"qwen3-max",sonnet:"qwen3-235b",haiku:"qwen3-coder-flash"}},{id:"qwen3-vl-plus",name:"Qwen3 VL Plus",description:"Vision-language multimodal"},{id:"qwen3-coder-flash",name:"Qwen3 Coder Flash",description:"Fast code generation"},{id:"qwen3-32b",name:"Qwen3 32B",description:"Qwen3 32B model"}]},iflow:{provider:"iflow",displayName:"iFlow",defaultModel:"qwen3-coder-plus",models:[{id:"qwen3-coder-plus",name:"Qwen3 Coder Plus",description:"Recommended default for iFlow accounts",presetMapping:{default:"qwen3-coder-plus",opus:"qwen3-coder-plus",sonnet:"qwen3-coder-plus",haiku:"qwen3-coder-plus"}},{id:"qwen3-max",name:"Qwen3 Max",description:"Flagship Qwen model via iFlow"},{id:"kimi-k2",name:"Kimi K2",description:"Kimi model currently available via iFlow"},{id:"deepseek-v3.2",name:"DeepSeek V3.2",description:"Current DeepSeek V3.2 model via iFlow"},{id:"deepseek-r1",name:"DeepSeek R1",description:"Reasoning-focused DeepSeek model"},{id:"glm-4.6",name:"GLM 4.6",description:"Zhipu GLM 4.6 via iFlow"},{id:"qwen3-vl-plus",name:"Qwen3 VL Plus",description:"Vision-language model"}]},kimi:{provider:"kimi",displayName:"Kimi (Moonshot)",defaultModel:"kimi-k2.5",models:[{id:"kimi-k2.5",name:"Kimi K2.5",description:"Latest multimodal model (262K context)",presetMapping:{default:"kimi-k2.5",opus:"kimi-k2.5",sonnet:"kimi-k2-thinking",haiku:"kimi-k2"}},{id:"kimi-k2-thinking",name:"Kimi K2 Thinking",description:"Extended reasoning model",presetMapping:{default:"kimi-k2-thinking",opus:"kimi-k2.5",sonnet:"kimi-k2-thinking",haiku:"kimi-k2"}},{id:"kimi-k2",name:"Kimi K2",description:"Flagship coding model"}]},kiro:{provider:"kiro",displayName:"Kiro (AWS)",defaultModel:"kiro-claude-sonnet-4-6",models:[{id:"kiro-claude-opus-4-6",name:"Kiro Claude Opus 4.6",description:"Claude Opus 4.6 via Kiro (2.2x credit)",presetMapping:{default:"kiro-claude-opus-4-6",opus:"kiro-claude-opus-4-6",sonnet:"kiro-claude-sonnet-4-6",haiku:"kiro-claude-haiku-4-5"}},{id:"kiro-claude-sonnet-4-6",name:"Kiro Claude Sonnet 4.6",description:"Claude Sonnet 4.6 via Kiro (1.3x credit)",presetMapping:{default:"kiro-claude-sonnet-4-6",opus:"kiro-claude-opus-4-6",sonnet:"kiro-claude-sonnet-4-6",haiku:"kiro-claude-haiku-4-5"}},{id:"kiro-claude-opus-4-5",name:"Kiro Claude Opus 4.5",description:"Claude Opus 4.5 via Kiro (2.2x credit)",presetMapping:{default:"kiro-claude-opus-4-5",opus:"kiro-claude-opus-4-5",sonnet:"kiro-claude-sonnet-4-5",haiku:"kiro-claude-haiku-4-5"}},{id:"kiro-claude-sonnet-4-5",name:"Kiro Claude Sonnet 4.5",description:"Claude Sonnet 4.5 via Kiro (1.3x credit)",presetMapping:{default:"kiro-claude-sonnet-4-5",opus:"kiro-claude-opus-4-5",sonnet:"kiro-claude-sonnet-4-5",haiku:"kiro-claude-haiku-4-5"}},{id:"kiro-claude-sonnet-4",name:"Kiro Claude Sonnet 4",description:"Claude Sonnet 4 via Kiro (1.3x credit)",presetMapping:{default:"kiro-claude-sonnet-4",opus:"kiro-claude-opus-4-5",sonnet:"kiro-claude-sonnet-4",haiku:"kiro-claude-haiku-4-5"}},{id:"kiro-claude-haiku-4-5",name:"Kiro Claude Haiku 4.5",description:"Claude Haiku 4.5 via Kiro (0.4x credit)"}]},ghcp:{provider:"ghcp",displayName:"GitHub Copilot (OAuth)",defaultModel:"claude-sonnet-4.5",models:[{id:"claude-opus-4.5",name:"Claude Opus 4.5",description:"Anthropic Claude Opus 4.5 via GitHub Copilot",presetMapping:{default:"claude-opus-4.5",opus:"claude-opus-4.5",sonnet:"claude-sonnet-4.5",haiku:"claude-haiku-4.5"}},{id:"claude-sonnet-4.5",name:"Claude Sonnet 4.5",description:"Anthropic Claude Sonnet 4.5 via GitHub Copilot",presetMapping:{default:"claude-sonnet-4.5",opus:"claude-opus-4.5",sonnet:"claude-sonnet-4.5",haiku:"claude-haiku-4.5"}},{id:"claude-sonnet-4",name:"Claude Sonnet 4",description:"Anthropic Claude Sonnet 4 via GitHub Copilot"},{id:"claude-haiku-4.5",name:"Claude Haiku 4.5",description:"Anthropic Claude Haiku 4.5 via GitHub Copilot"},{id:"gpt-5.2",name:"GPT-5.2",description:"OpenAI GPT-5.2 via GitHub Copilot",presetMapping:{default:"gpt-5.2",opus:"gpt-5.2",sonnet:"gpt-5.1",haiku:"gpt-5-mini"}},{id:"gpt-5.1",name:"GPT-5.1",description:"OpenAI GPT-5.1 via GitHub Copilot"},{id:"gpt-5",name:"GPT-5",description:"OpenAI GPT-5 via GitHub Copilot"},{id:"gpt-5-mini",name:"GPT-5 Mini",description:"OpenAI GPT-5 Mini via GitHub Copilot"},{id:"gemini-3-pro",name:"Gemini 3 Pro",description:"Google Gemini 3 Pro via GitHub Copilot"}]},claude:{provider:"claude",displayName:"Claude (Anthropic)",defaultModel:"claude-sonnet-4-6",models:[{id:"claude-opus-4-6",name:"Claude Opus 4.6",description:"Latest flagship model",extendedContext:!0,presetMapping:{default:"claude-opus-4-6",opus:"claude-opus-4-6",sonnet:"claude-sonnet-4-6",haiku:"claude-haiku-4-5-20251001"}},{id:"claude-sonnet-4-6",name:"Claude Sonnet 4.6",description:"Balanced performance and speed",extendedContext:!0,presetMapping:{default:"claude-sonnet-4-6",opus:"claude-opus-4-6",sonnet:"claude-sonnet-4-6",haiku:"claude-haiku-4-5-20251001"}},{id:"claude-opus-4-5-20251101",name:"Claude Opus 4.5",description:"Most capable Claude model",extendedContext:!0,presetMapping:{default:"claude-opus-4-5-20251101",opus:"claude-opus-4-5-20251101",sonnet:"claude-sonnet-4-5-20250929",haiku:"claude-haiku-4-5-20251001"}},{id:"claude-sonnet-4-5-20250929",name:"Claude Sonnet 4.5",description:"Balanced performance and speed",extendedContext:!0,presetMapping:{default:"claude-sonnet-4-5-20250929",opus:"claude-opus-4-5-20251101",sonnet:"claude-sonnet-4-5-20250929",haiku:"claude-haiku-4-5-20251001"}},{id:"claude-sonnet-4-20250514",name:"Claude Sonnet 4",description:"Previous generation Sonnet",extendedContext:!0,presetMapping:{default:"claude-sonnet-4-20250514",opus:"claude-opus-4-5-20251101",sonnet:"claude-sonnet-4-20250514",haiku:"claude-haiku-4-5-20251001"}},{id:"claude-haiku-4-5-20251001",name:"Claude Haiku 4.5",description:"Fast and efficient"}]}};function Hs(s,t){const a=pe[s.toLowerCase()];if(!a)return;const n=ve(t),i=qs[n.toLowerCase()],d=a.models.find(r=>r.id===n||r.id===i);if(d)return d;const u=Pe(n);if(u)return a.models.map(r=>({model:r,info:Pe(r.id)})).filter(r=>!!(r.info&&r.info.family===u.family)).sort((r,o)=>Ks(o.info.version,r.info.version))[0]?.model}function ge(s,t=[]){const a=ve(s),n=Yt(a,t);if(n)return n;const i=ms(t,a);if(i)return i;const d=qs[a];return(d?ms(t,d):void 0)??a}function Zt(s,t=[]){return{default:ge(s.default,t),opus:ge(s.opus,t),sonnet:ge(s.sonnet,t),haiku:ge(s.haiku,t)}}function Gs(s,t=[]){if(!s)return[];const a=new Set;return s.models.map(n=>{const i=ge(n.id,t),d=n.presetMapping?Zt(n.presetMapping,t):void 0;return{...n,id:i,presetMapping:d}}).filter(n=>a.has(n.id)?!1:(a.add(n.id),!0))}function ea(s,t){return Hs(s,t)?.extendedContext===!0}const Re="ccs-internal-managed";async function sa(){try{const s=await fetch("/api/settings/auth/tokens/raw");return s.ok?(await s.json())?.apiKey?.value??Re:Re}catch{return Re}}async function Ge(s,t){const a=pe[s];if(!a)return{success:!1};const n=a.models.find(o=>o.id===a.defaultModel)||a.models[0],i=n?.presetMapping||{default:a.defaultModel,opus:a.defaultModel,sonnet:a.defaultModel,haiku:a.defaultModel},d=await sa(),r={env:{ANTHROPIC_BASE_URL:`http://127.0.0.1:${He}/api/provider/${s}`,ANTHROPIC_AUTH_TOKEN:d,ANTHROPIC_MODEL:i.default,ANTHROPIC_DEFAULT_OPUS_MODEL:i.opus,ANTHROPIC_DEFAULT_SONNET_MODEL:i.sonnet,ANTHROPIC_DEFAULT_HAIKU_MODEL:i.haiku}};try{return{success:(await fetch(`/api/settings/${s}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({settings:r})})).ok,presetName:n?.name||a.defaultModel}}catch{return{success:!1}}}function ta({currentProgress:s,allSteps:t}){return e.jsx("div",{className:"flex justify-center gap-1 pt-2",children:t.map((a,n)=>e.jsx("div",{className:`w-2 h-2 rounded-full transition-colors ${s>=n?"bg-primary":"bg-muted"}`},a))})}function aa({providers:s,onSelect:t}){return e.jsx("div",{className:"grid gap-2",children:s.map(a=>e.jsxs("button",{onClick:()=>t(a.id),className:"flex items-center justify-between p-3 border rounded-lg hover:bg-muted/50 transition-colors text-left",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:a.name}),e.jsx("div",{className:"text-xs text-muted-foreground",children:a.description})]}),e.jsx(Ds,{className:"w-4 h-4 text-muted-foreground"})]},a.id))})}function na({selectedProvider:s,providers:t,authCommand:a,isRefreshing:n,isPending:i,onBack:d,onStartAuth:u,onRefresh:r}){const[o,p]=c.useState(!1),f=async v=>{await navigator.clipboard.writeText(v),p(!0),setTimeout(()=>p(!1),2e3)};return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"text-center space-y-3",children:[e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Authenticate with ",t.find(v=>v.id===s)?.name," to add an account"]}),e.jsx(I,{onClick:u,disabled:i,className:"w-full gap-2",size:"lg",children:i?e.jsxs(e.Fragment,{children:[e.jsx(Z,{className:"w-4 h-4 animate-spin"}),"Authenticating..."]}):e.jsxs(e.Fragment,{children:[e.jsx(me,{className:"w-4 h-4"}),"Authenticate in Browser"]})}),i&&e.jsx("p",{className:"text-xs text-muted-foreground",children:"Complete the OAuth flow in your browser..."})]}),e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"absolute inset-0 flex items-center",children:e.jsx("span",{className:"w-full border-t"})}),e.jsx("div",{className:"relative flex justify-center text-xs uppercase",children:e.jsx("span",{className:"bg-background px-2 text-muted-foreground",children:"Or use terminal"})})]}),e.jsx(gs,{children:e.jsxs(fs,{className:"p-4 space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(Lt,{className:"w-4 h-4"}),"Run this command in your terminal:"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("code",{className:"flex-1 px-3 py-2 bg-muted rounded-md font-mono text-sm",children:a}),e.jsx(I,{variant:"outline",size:"icon",onClick:()=>f(a),children:o?e.jsx(ue,{className:"w-4 h-4 text-green-500"}):e.jsx(Ts,{className:"w-4 h-4"})})]})]})}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(I,{variant:"ghost",onClick:d,disabled:i,children:[e.jsx(Ye,{className:"w-4 h-4 mr-2"}),"Back"]}),e.jsxs(I,{variant:"outline",onClick:r,disabled:n||i,children:[e.jsx(Ze,{className:`w-4 h-4 mr-2 ${n?"animate-spin":""}`}),n?"Checking...":"Refresh Status"]})]})]})}function ia({accounts:s,privacyMode:t,onSelect:a,onAddNew:n,onBack:i}){return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:["Select an account (",s.length,")"]}),e.jsx("div",{className:"grid gap-2 max-h-[320px] overflow-y-auto pr-1",children:s.map(d=>{const u=vs(d.id,d.email,d.tokenFile);return e.jsxs("button",{type:"button",onClick:()=>a(d),className:"flex items-center justify-between p-3 border rounded-lg hover:bg-muted/50 transition-colors text-left",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-8 h-8 rounded-full bg-muted flex items-center justify-center",children:e.jsx(fe,{className:"w-4 h-4 text-muted-foreground"})}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("div",{className:B("font-medium",t&&Be),children:u.email}),e.jsxs("div",{className:"flex items-center gap-1.5 flex-wrap",children:[u.audienceLabel&&e.jsx(G,{variant:"outline",className:B("text-[10px] h-4 px-1.5 border-transparent",u.audience==="business"?"bg-sky-500/12 text-sky-700 dark:text-sky-300":"bg-emerald-500/12 text-emerald-700 dark:text-emerald-300"),children:u.audienceLabel}),u.detailLabel&&e.jsx(G,{variant:"outline",className:"text-[10px] h-4 px-1.5",children:u.detailLabel}),d.isDefault&&e.jsx("span",{className:"text-xs text-muted-foreground",children:"Default account"})]})]})]}),e.jsx(Ds,{className:"w-4 h-4 text-muted-foreground"})]},d.id)})}),e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"absolute inset-0 flex items-center",children:e.jsx("span",{className:"w-full border-t"})}),e.jsx("div",{className:"relative flex justify-center text-xs uppercase",children:e.jsx("span",{className:"bg-background px-2 text-muted-foreground",children:"Or"})})]}),e.jsxs("button",{type:"button",className:"w-full flex items-center gap-3 p-3 border-2 border-dashed border-primary/50 rounded-lg hover:border-primary hover:bg-primary/5 transition-colors text-left",onClick:n,children:[e.jsx("div",{className:"w-8 h-8 rounded-full bg-primary/10 flex items-center justify-center shrink-0",children:e.jsx(me,{className:"w-4 h-4 text-primary"})}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-primary",children:"Add new account"}),e.jsx("div",{className:"text-xs text-muted-foreground",children:"Authenticate with a different account"})]})]}),e.jsx("div",{className:"flex items-center justify-between pt-2",children:e.jsxs(I,{variant:"ghost",onClick:i,children:[e.jsx(Ye,{className:"w-4 h-4 mr-2"}),"Back"]})})]})}const ps="__custom__";function ra({selectedProvider:s,selectedAccount:t,variantName:a,modelName:n,isPending:i,privacyMode:d,onVariantNameChange:u,onModelChange:r,onBack:o,onSkip:p,onCreate:f}){const{t:v}=se(),g=pe[s]?.models||[],L=n&&!g.some(l=>l.id===n),[j,w]=c.useState(L),D=s==="agy"&&n.trim().length>0?ee(n):!1,b=t?vs(t.id,t.email,t.tokenFile):null,N=l=>{l===ps?(w(!0),r("")):(w(!1),r(l))};return e.jsxs("div",{className:"space-y-4",children:[t&&e.jsxs("div",{className:"flex items-start gap-2 p-2 bg-muted/50 rounded-md text-sm",children:[e.jsx(fe,{className:"w-4 h-4"}),e.jsxs("div",{className:"space-y-1",children:[e.jsxs("span",{children:[v("setupVariant.using")," ",e.jsx("span",{className:B(d&&Be),children:b?.email})]}),(b?.audienceLabel||b?.detailLabel)&&e.jsxs("div",{className:"flex items-center gap-1.5 flex-wrap",children:[b?.audienceLabel&&e.jsx(G,{variant:"outline",className:B("text-[10px] h-4 px-1.5 border-transparent",b.audience==="business"?"bg-sky-500/12 text-sky-700 dark:text-sky-300":"bg-emerald-500/12 text-emerald-700 dark:text-emerald-300"),children:b.audienceLabel}),b?.detailLabel&&e.jsx(G,{variant:"outline",className:"text-[10px] h-4 px-1.5",children:b.detailLabel})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Y,{htmlFor:"variant-name",children:v("setupVariant.variantNameRequired")}),e.jsx(de,{id:"variant-name",value:a,onChange:l=>u(l.target.value),placeholder:v("setupVariant.variantNamePlaceholder")}),e.jsxs("div",{className:"text-xs text-muted-foreground",children:[v("setupVariant.invokeHintPrefix")," ccs ",a||"<name>",' "prompt"']})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Y,{children:v("setupVariant.model")}),j?e.jsxs("div",{className:"space-y-2",children:[e.jsx(de,{value:n,onChange:l=>r(l.target.value),placeholder:v("setupVariant.modelPlaceholder")}),D&&e.jsx("p",{className:"text-xs text-destructive",children:"Antigravity denylist: Claude Opus 4.5 and Claude Sonnet 4.5 are deprecated."}),e.jsx("button",{type:"button",className:"text-xs text-primary hover:underline",onClick:()=>{w(!1),s==="agy"&&ee(n)&&r("")},children:v("setupVariant.choosePresetInstead")})]}):e.jsxs(js,{value:g.some(l=>l.id===n)?n:"",onValueChange:N,children:[e.jsx(Ns,{children:e.jsx(bs,{placeholder:v("setupVariant.selectModel")})}),e.jsxs(ys,{children:[g.map(l=>e.jsx(Le,{value:l.id,children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{children:l.name}),l.description&&e.jsxs("span",{className:"text-xs text-muted-foreground",children:["- ",l.description]})]})},l.id)),e.jsx(Le,{value:ps,children:e.jsx("span",{className:"text-primary",children:v("setupVariant.customModelName")})})]})]}),e.jsx("div",{className:"text-xs text-muted-foreground",children:j?v("setupVariant.enterAnyModel"):v("setupVariant.defaultModel",{model:pe[s]?.defaultModel||v("setupVariant.providerDefault")})})]}),e.jsxs("div",{className:"flex items-center justify-between pt-2",children:[e.jsxs(I,{variant:"ghost",onClick:o,children:[e.jsx(Ye,{className:"w-4 h-4 mr-2"}),v("setupVariant.back")]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(I,{variant:"ghost",onClick:p,children:v("setupVariant.skip")}),e.jsx(I,{onClick:f,disabled:!a||i||D,children:v(i?"setupVariant.creating":"setupVariant.createVariant")})]})]}),e.jsx("p",{className:"text-xs text-center text-muted-foreground",children:v("setupVariant.skipHint")})]})}function oa({variantName:s,onClose:t}){return e.jsxs("div",{className:"space-y-4 text-center",children:[e.jsx("div",{className:"flex justify-center",children:e.jsx("div",{className:"w-16 h-16 bg-green-100 dark:bg-green-900/30 rounded-full flex items-center justify-center",children:e.jsx(ue,{className:"w-8 h-8 text-green-600 dark:text-green-400"})})}),e.jsxs("div",{children:[e.jsx("div",{className:"font-semibold text-lg",children:"Variant Created!"}),e.jsx("div",{className:"text-sm text-muted-foreground",children:"Your custom variant is ready to use"})]}),e.jsx(gs,{children:e.jsxs(fs,{className:"p-4 space-y-2",children:[e.jsx("div",{className:"text-sm text-muted-foreground",children:"Usage:"}),e.jsxs("code",{className:"block px-3 py-2 bg-muted rounded-md font-mono text-sm",children:["ccs ",s,' "your prompt here"']})]})}),e.jsx(I,{onClick:t,className:"w-full",children:"Done"})]})}function la({open:s,onClose:t}){const[a,n]=c.useState("provider"),[i,d]=c.useState(""),[u,r]=c.useState(null),[o,p]=c.useState(""),[f,v]=c.useState(""),[g,L]=c.useState(!1),[j,w]=c.useState(!1),{data:D,refetch:b}=ws(),N=Ws(),l=Xs(),A=Ys(),{privacyMode:C}=Cs(),M=D?.authStatus.find(T=>T.provider===i),m=c.useMemo(()=>M?.accounts||[],[M?.accounts]);c.useEffect(()=>{if(!s){const T=setTimeout(()=>{n("provider"),d(""),r(null),p(""),v(""),w(!1)},0);return()=>clearTimeout(T)}},[s]),c.useEffect(()=>{if(a==="auth"&&m.length>0&&!j){const T=setTimeout(()=>{n("account")},0);return()=>clearTimeout(T)}},[a,m,j]);const S=async()=>{L(!0),await b(),L(!1)},O=()=>{const T=(M?.accounts?.length||0)===0;l.mutate({provider:i},{onSuccess:async R=>{if(T){const K=await Ge(i);K.success&&K.presetName?U.success(`Applied "${K.presetName}" preset`):K.success||U.warning(As.t("commonToast.accountAddedPresetFailed"))}R.account&&(r(R.account),n("variant")),b()}})},q=T=>{d(T),(D?.authStatus.find(V=>V.provider===T)?.accounts||[]).length===0?n("auth"):n("account")},h=T=>{r(T),n("variant")},k=async()=>{if(!(!o||!i))try{await N.mutateAsync({name:o,provider:i,model:f||void 0,account:u?.id}),n("success")}catch(T){console.error("Failed to create variant:",T)}},y=`ccs ${i} --auth --add`,F=et(a),H=T=>{if(!T&&(l.isPending&&i&&A.mutate(i),a==="success"||a==="provider")){t();return}};return e.jsx(ze,{open:s,onOpenChange:H,children:e.jsxs($e,{className:"sm:max-w-lg",onPointerDownOutside:T=>{a!=="success"&&a!=="provider"&&T.preventDefault()},onEscapeKeyDown:T=>{(l.isPending||N.isPending)&&T.preventDefault()},children:[e.jsxs(Qe,{children:[e.jsxs(Je,{className:"flex items-center gap-2",children:[e.jsx(je,{className:"w-5 h-5 text-primary"}),"Quick Setup Wizard"]}),e.jsxs(ks,{children:[a==="provider"&&"Select a provider to get started",a==="auth"&&"Authenticate with your provider",a==="account"&&"Select which account to use",a==="variant"&&"Create your custom variant",a==="success"&&"Setup complete!"]})]}),e.jsxs("div",{className:"space-y-4 py-4",children:[a==="provider"&&e.jsx(aa,{providers:ns,onSelect:q}),a==="auth"&&e.jsx(na,{selectedProvider:i,providers:ns,authCommand:y,isRefreshing:g,isPending:l.isPending,onBack:()=>n("provider"),onStartAuth:O,onRefresh:S}),a==="account"&&e.jsx(ia,{accounts:m,privacyMode:C,onSelect:h,onAddNew:()=>{w(!0),n("auth")},onBack:()=>n("provider")}),a==="variant"&&e.jsx(ra,{selectedProvider:i,selectedAccount:u,variantName:o,modelName:f,isPending:N.isPending,privacyMode:C,onVariantNameChange:p,onModelChange:v,onBack:()=>m.length>0?n("account"):n("provider"),onSkip:t,onCreate:k}),a==="success"&&e.jsx(oa,{variantName:o,onClose:t})]}),e.jsx(ta,{currentProgress:F,allSteps:Zs})]})})}const ca=3e3,da=300*1e3,ua=3;async function Ie(s){const t=await s.text();if(!t)return{};try{return JSON.parse(t)}catch{const a=s.status>=400?`Request failed with status ${s.status}`:void 0;return a?{error:a}:{}}}const ce={provider:null,isAuthenticating:!1,error:null,authUrl:null,oauthState:null,isSubmittingCallback:!1,isDeviceCodeFlow:!1};function ma(){const[s,t]=c.useState(ce),a=c.useRef(0),n=c.useRef(null),i=c.useRef(null),d=c.useRef(0),u=c.useRef(0),r=c.useRef(!1),o=Ve(),p=c.useCallback(w=>w===a.current,[]),f=c.useCallback(()=>{i.current&&(clearInterval(i.current),i.current=null),u.current=0},[]);c.useEffect(()=>()=>{n.current?.abort(),f(),r.current=!1},[f]);const v=c.useCallback(async(w,D,b)=>{if(p(b)){if(Date.now()-d.current>da){f(),p(b)&&t(N=>({...N,isAuthenticating:!1,error:"Authentication timed out. Please try again."}));return}try{const N=await fetch(`/api/cliproxy/auth/${w}/status?state=${encodeURIComponent(D)}`);if(!p(b))return;const l=await N.json();if(u.current=0,l.status==="ok"){if(!(typeof l.account=="object"&&l.account!==null)){f();const C="Authenticated account could not be registered";U.error(C),t(M=>({...M,isAuthenticating:!1,error:C}));return}f(),o.invalidateQueries({queryKey:["cliproxy-auth"]}),o.invalidateQueries({queryKey:["cliproxy-accounts"]}),o.invalidateQueries({queryKey:["account-quota"]}),U.success(`${w} authentication successful`),r.current=!1,t(ce)}else if(l.status==="auth_url"){const A=l.url||l.auth_url;A&&(t(C=>({...C,authUrl:A})),r.current||(r.current=!0,window.open(A,"_blank")))}else if(l.status==="device_code"){f();const A=l.user_code&&l.verification_url?`Open ${l.verification_url} and enter code: ${l.user_code}`:"Switch to Device Code method and try again.";U.error("Provider returned Device Code flow in callback mode"),t(C=>({...C,isAuthenticating:!1,error:A}))}else if(l.status==="error"){f();const A=l.error||"Authentication failed";U.error(A),t(C=>({...C,isAuthenticating:!1,error:A}))}}catch(N){if(!p(b)||(u.current+=1,u.current<ua))return;f();const l=N instanceof Error&&N.message.trim().length>0?N.message:"Lost contact with the auth status endpoint";U.error(l),t(A=>({...A,isAuthenticating:!1,error:l}))}}},[p,o,f]),g=c.useCallback(async(w,D)=>{if(!_e(w)){t({...ce,error:`Unknown provider: ${w}`});return}n.current?.abort(),f(),r.current=!1,u.current=0;const b=new AbortController,N=a.current+1;a.current=N,n.current=b;const A=(D?.flowType||(Ss(w)?"device_code":"authorization_code"))==="device_code",C=D?.startEndpoint||(A?"start":"start-url"),M={nickname:D?.nickname,kiroMethod:D?.kiroMethod,riskAcknowledgement:D?.riskAcknowledgement};t({provider:w,isAuthenticating:!0,error:null,authUrl:null,oauthState:null,isSubmittingCallback:!1,isDeviceCodeFlow:A});try{if(C==="start")fetch(`/api/cliproxy/auth/${w}/start`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(M),signal:b.signal}).then(async m=>{if(!p(N))return;const S=await Ie(m);if(!p(N))return;const O=S.success===!0,q=typeof S.account=="object"&&S.account!==null;if(m.ok&&O&&q)o.invalidateQueries({queryKey:["cliproxy-auth"]}),o.invalidateQueries({queryKey:["cliproxy-accounts"]}),o.invalidateQueries({queryKey:["account-quota"]}),r.current=!1,t(ce);else{const h=typeof S.error=="string"?S.error:O?"Authenticated account could not be registered":"Authentication failed";U.error(h),t(k=>({...k,isAuthenticating:!1,error:h}))}}).catch(m=>{if(!p(N)||m instanceof Error&&m.name==="AbortError")return;const S=m instanceof Error?m.message:"Authentication failed";U.error(S),t(O=>({...O,isAuthenticating:!1,error:S}))});else{const m=await fetch(`/api/cliproxy/auth/${w}/start-url`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(M),signal:b.signal});if(!p(N))return;const S=await Ie(m);if(!p(N))return;const O=S.success===!0;if(!m.ok||!O){const k=typeof S.error=="string"?S.error:"Failed to start OAuth";throw new Error(k)}const q=typeof S.authUrl=="string"?S.authUrl:null,h=typeof S.state=="string"?S.state:null;t(k=>({...k,authUrl:q,oauthState:h})),q&&(r.current=!0,window.open(q,"_blank")),h&&(d.current=Date.now(),i.current=setInterval(()=>{v(w,h,N)},ca))}}catch(m){if(!p(N))return;if(m instanceof Error&&m.name==="AbortError"){r.current=!1,t(ce);return}const S=m instanceof Error?m.message:"Authentication failed";U.error(S),t(O=>({...O,isAuthenticating:!1,error:S}))}},[p,v,f,o]),L=c.useCallback(()=>{const w=s.provider;a.current+=1,n.current?.abort(),f(),r.current=!1,t(ce),w&&ke.cliproxy.auth.cancel(w).catch(()=>{})},[s.provider,f]),j=c.useCallback(async w=>{if(!s.provider)return;const D=a.current,b=s.provider;t(N=>({...N,isSubmittingCallback:!0,error:null}));try{const N=await fetch(`/api/cliproxy/auth/${b}/submit-callback`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({redirectUrl:w})});if(!p(D))return;const l=await Ie(N);if(!p(D))return;const A=l.success===!0,C=l.status==="wait",M=typeof l.account=="object"&&l.account!==null;if(N.ok&&C)t(m=>({...m,isSubmittingCallback:!1,error:null}));else if(N.ok&&A&&M)f(),o.invalidateQueries({queryKey:["cliproxy-auth"]}),o.invalidateQueries({queryKey:["cliproxy-accounts"]}),o.invalidateQueries({queryKey:["account-quota"]}),U.success(`${b} authentication successful`),t(ce);else{const m=typeof l.error=="string"?l.error:A?"Authenticated account could not be registered":"Callback submission failed";throw new Error(m)}}catch(N){if(!p(D))return;const l=N instanceof Error?N.message:"Failed to submit callback";U.error(l),t(A=>({...A,isSubmittingCallback:!1,error:l}))}},[p,s.provider,o,f]);return c.useMemo(()=>({...s,startAuth:g,cancelAuth:L,submitCallback:j}),[s,g,L,j])}function Vs({className:s,showAcknowledgement:t=!1,acknowledgementPhrase:a=Ae,acknowledgementText:n="",onAcknowledgementTextChange:i,disabled:d=!1,showProxySettingsLink:u=!1}){const{t:r}=se(),o=r("accountSafetyWarning.title"),p=r("accountSafetyWarning.subtitle"),f=r("accountSafetyWarning.firstLine"),v=r("accountSafetyWarning.secondLine"),g="https://github.com/kaitranntt/ccs/issues/509",L=r("accountSafetyWarning.issueLabel"),j=r("accountSafetyWarning.proxySettingsLabel");return e.jsxs("section",{role:"alert",className:B("relative overflow-hidden rounded-xl border border-amber-500/30 bg-gradient-to-br from-amber-50 via-background to-rose-50/70 shadow-sm dark:from-amber-950/20 dark:to-rose-950/20",s),children:[e.jsx("div",{className:"absolute inset-x-0 top-0 h-0.5 bg-gradient-to-r from-amber-500 via-orange-500 to-rose-500"}),e.jsxs("div",{className:"space-y-3 p-4",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"flex items-start gap-2.5",children:[e.jsx("div",{className:"mt-0.5 inline-flex h-7 w-7 items-center justify-center rounded-md bg-amber-500/15 text-amber-700 dark:text-amber-400",children:e.jsx(es,{className:"h-4 w-4"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-semibold leading-5",children:o}),e.jsx("p",{className:"text-xs text-muted-foreground",children:p})]})]}),e.jsx(G,{variant:"outline",className:"border-amber-500/40 text-amber-700 dark:text-amber-300",children:"High Risk"})]}),e.jsxs("div",{className:"space-y-2 text-sm leading-relaxed",children:[e.jsx("p",{children:f}),e.jsx("p",{className:"font-medium text-amber-900 dark:text-amber-200",children:v}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"CCS is provided as-is and does not take responsibility for suspension, bans, or access loss from upstream providers."})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs("a",{href:g,target:"_blank",rel:"noreferrer",className:"inline-flex items-center gap-1.5 rounded-md border border-amber-500/30 bg-amber-500/10 px-2.5 py-1 text-xs font-medium text-amber-800 transition-colors hover:bg-amber-500/15 dark:text-amber-200",children:[L,e.jsx(me,{className:"h-3.5 w-3.5"})]}),u&&e.jsxs("a",{href:"/settings?tab=proxy",className:"inline-flex items-center gap-1.5 rounded-md border border-amber-500/30 bg-amber-500/10 px-2.5 py-1 text-xs font-medium text-amber-800 transition-colors hover:bg-amber-500/15 dark:text-amber-200",children:[e.jsx(_t,{className:"h-3.5 w-3.5"}),j]}),e.jsx("span",{className:"rounded-md border border-border/70 bg-muted/60 px-2.5 py-1 text-xs text-muted-foreground",children:"Applies to CLI and dashboard auth"})]}),t&&i&&e.jsxs("div",{className:"rounded-lg border border-amber-500/25 bg-amber-500/5 p-2.5",children:[e.jsxs(Y,{htmlFor:"account-risk-ack-text",className:"text-xs leading-5",children:["Type exact phrase to continue:"," ",e.jsx("code",{className:"rounded bg-muted px-1 py-0.5 font-mono",children:a})]}),e.jsx(de,{id:"account-risk-ack-text",value:n,onChange:w=>i(w.target.value),placeholder:a,disabled:d,className:"mt-2 font-mono text-xs"})]})]})]})}function pa({className:s,value:t,onChange:a,disabled:n=!1}){const{t:i}=se(),d=[t.reviewedIssue509,t.understandsBanRisk,t.acceptsFullResponsibility,t.typedPhrase.trim().replace(/\s+/g," ").toUpperCase()===us].filter(Boolean).length,u=d/4*100,r=o=>{a({...t,...o})};return e.jsxs("section",{role:"alert",className:B("relative overflow-hidden rounded-xl border border-rose-500/35 bg-gradient-to-br from-rose-50 via-background to-amber-50/70 p-4 shadow-sm dark:from-rose-950/20 dark:to-amber-950/20",s),children:[e.jsx("div",{className:"absolute inset-x-0 top-0 h-0.5 bg-gradient-to-r from-rose-500 via-orange-500 to-amber-500"}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"flex items-start gap-2.5",children:[e.jsx("div",{className:"mt-0.5 inline-flex h-7 w-7 items-center justify-center rounded-md bg-rose-500/15 text-rose-700 dark:text-rose-300",children:e.jsx(es,{className:"h-4 w-4"})}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-sm font-semibold leading-5",children:i("antigravityChecklist.title")}),e.jsx("p",{className:"text-xs text-muted-foreground",children:i("antigravityChecklist.subtitle")})]})]}),e.jsx(G,{variant:"outline",className:"border-rose-500/40 text-rose-700 dark:text-rose-300",children:i("antigravityChecklist.mandatory")})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{className:"flex items-center justify-between text-xs text-muted-foreground",children:[e.jsx("span",{children:i("antigravityChecklist.completion")}),e.jsx("span",{children:i("antigravityChecklist.stepsCount",{current:d})})]}),e.jsx(st,{value:u,className:"h-2"})]}),e.jsxs("div",{className:"space-y-3 rounded-lg border border-rose-500/20 bg-rose-500/5 p-3",children:[e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(Se,{id:"agy-step-reviewed-issue",checked:t.reviewedIssue509,onCheckedChange:o=>r({reviewedIssue509:!!o}),disabled:n}),e.jsx(Y,{htmlFor:"agy-step-reviewed-issue",className:"text-xs leading-5",children:"Step 1: I reviewed issue #509 and understand AGY OAuth can trigger account bans/suspensions."})]}),e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(Se,{id:"agy-step-understands-risk",checked:t.understandsBanRisk,onCheckedChange:o=>r({understandsBanRisk:!!o}),disabled:n}),e.jsx(Y,{htmlFor:"agy-step-understands-risk",className:"text-xs leading-5",children:"Step 2: I understand this OAuth action is my own decision and I accept the upstream risk."})]}),e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(Se,{id:"agy-step-accept-responsibility",checked:t.acceptsFullResponsibility,onCheckedChange:o=>r({acceptsFullResponsibility:!!o}),disabled:n}),e.jsx(Y,{htmlFor:"agy-step-accept-responsibility",className:"text-xs leading-5",children:"Step 3: I accept full responsibility. CCS is not liable for suspension, bans, or access loss."})]})]}),e.jsxs("div",{className:"space-y-2 rounded-lg border border-amber-500/25 bg-amber-500/5 p-3",children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-xs font-medium text-amber-800 dark:text-amber-200",children:[e.jsx(Es,{className:"h-3.5 w-3.5"}),"Step 4: Type exact phrase to continue"]}),e.jsx(de,{value:t.typedPhrase,onChange:o=>r({typedPhrase:o.target.value}),placeholder:us,disabled:n,className:"font-mono text-xs"})]}),e.jsx("div",{className:"flex flex-wrap items-center gap-2 text-xs",children:e.jsxs("a",{href:"https://github.com/kaitranntt/ccs/issues/509",target:"_blank",rel:"noreferrer",className:"inline-flex items-center gap-1.5 rounded-md border border-rose-500/30 bg-rose-500/10 px-2.5 py-1 font-medium text-rose-800 transition-colors hover:bg-rose-500/15 dark:text-rose-200",children:["Read issue #509",e.jsx(me,{className:"h-3.5 w-3.5"})]})})]})]})}function xa(s){return s.trim().replace(/\s+/g," ").toUpperCase()}function ha({open:s,onClose:t,provider:a,displayName:n,isFirstAccount:i=!1}){const[d,u]=c.useState(""),[r,o]=c.useState(""),[p,f]=c.useState(!1),[v,g]=c.useState(null),[L,j]=c.useState(""),[w,D]=c.useState(Oe),[b,N]=c.useState(!1),[l,A]=c.useState(!1),[C,M]=c.useState(is),{t:m}=se(),S=c.useRef(!1),O=c.useRef(0),q=c.useRef(!1),h=ma(),k=tt(),y=a==="kiro",F=a==="agy"||a==="gemini",H=a==="gemini"&&!b,T=a==="agy"&&!b,R=F&&l,K=Bt(w),V=xa(L)===Ae,te=Ss(a),W=at(C),ae=y?W.flowType==="device_code":te,Q=h.isAuthenticating||k.isPending,x=d.trim(),E=v||h.error,z=c.useCallback(async()=>{const P=await fetch("/api/settings/auth/antigravity-risk");if(!P.ok)throw new Error("Failed to load power user mode setting");return(await P.json()).antigravityAckBypass===!0},[]),ne=c.useCallback(async({pendingMessage:P=null,disabledMessage:X=null}={})=>{const he=++O.current;A(!0),P!==null&&g(P);try{const le=await z();return O.current!==he||(N(le),X?g(le?null:X):P!==null&&g(null)),le}catch{return O.current!==he||(N(!1),g(X??m("addAccountDialog.powerUserLoadFailed")),q.current||(q.current=!0,U.error(m("addAccountDialog.powerUserLoadFailed")))),!1}finally{O.current===he&&A(!1)}},[z,m]),xe=()=>{u(""),o(""),f(!1),g(null),j(""),D(Oe),N(!1),A(!1),M(is),O.current+=1,q.current=!1,S.current=!1,t()};c.useEffect(()=>{s&&(j(""),D(Oe),g(null))},[a,s]),c.useEffect(()=>()=>{O.current+=1},[]),c.useEffect(()=>{if(!s||!F){O.current+=1,N(!1),A(!1);return}ne()},[s,a,F,ne]),c.useEffect(()=>{if(!s||a!=="agy"||!h.error||!b)return;const P=h.error.toLowerCase();(P.includes("agy_risk_ack_required")||P.includes("responsibility acknowledgement")||P.includes("responsibility checklist"))&&ne({pendingMessage:m("addAccountDialog.powerUserLoading"),disabledMessage:m("addAccountDialog.powerUserUnavailableRetry")})},[h.error,s,b,a,ne,m]),c.useEffect(()=>{!h.isAuthenticating&&!h.error&&h.provider===null&&s&&S.current&&(S.current=!1,(async()=>{try{const X=await Ge(a);X.success&&X.presetName&&i&&U.success(`Applied "${X.presetName}" preset`)}catch{}xe()})())},[h.isAuthenticating,h.error,h.provider]);const be=()=>{h.cancelAuth(),xe()},Me=async()=>{h.authUrl&&(await navigator.clipboard.writeText(h.authUrl),f(!0),setTimeout(()=>f(!1),2e3))},De=()=>{r.trim()&&h.submitCallback(r.trim())},ye=()=>{if(R){g(m("addAccountDialog.powerUserLoading"));return}if(T&&!K){g("Complete all Antigravity responsibility steps before authenticating this provider.");return}if(H&&!V){g(`Type "${Ae}" to acknowledge the account safety warning before authenticating this provider.`);return}g(null),S.current=!0,h.startAuth(a,{nickname:x||void 0,kiroMethod:y?C:void 0,flowType:y?W.flowType:void 0,startEndpoint:y?W.startEndpoint:void 0,riskAcknowledgement:T?{version:zt,reviewedIssue509:w.reviewedIssue509,understandsBanRisk:w.understandsBanRisk,acceptsFullResponsibility:w.acceptsFullResponsibility,typedPhrase:w.typedPhrase}:void 0})},we=()=>{S.current=!0,k.mutate(void 0,{onSuccess:async()=>{const P=await Ge("kiro");P.success&&P.presetName&&i&&U.success(`Applied "${P.presetName}" preset`),xe()}})},Te=P=>{P||be()},J=h.isAuthenticating;return e.jsx(ze,{open:s,onOpenChange:Te,children:e.jsxs($e,{className:"sm:max-w-md",onInteractOutside:P=>{J&&P.preventDefault()},children:[e.jsxs(Qe,{children:[e.jsx(Je,{children:m("addAccountDialog.title",{displayName:n})}),e.jsx(ks,{children:m(y?"addAccountDialog.descKiro":ae?"addAccountDialog.descDeviceCode":"addAccountDialog.descOauth")})]}),e.jsxs("div",{className:"space-y-4 py-4",children:[T&&!J&&e.jsx(pa,{value:w,onChange:P=>{D(P),g(null)},disabled:Q}),F&&b&&!J&&e.jsxs("div",{className:"rounded-lg border border-amber-400/35 bg-amber-50/70 p-3 text-xs text-amber-900 dark:border-amber-800/60 dark:bg-amber-950/25 dark:text-amber-100",children:[e.jsxs("div",{className:"mb-1.5 flex items-center gap-1.5 font-semibold",children:[e.jsx(Es,{className:"h-3.5 w-3.5"}),m("addAccountDialog.powerUserEnabled")]}),m("addAccountDialog.powerUserSkipped")]}),H&&!J&&e.jsx(Vs,{showAcknowledgement:!0,acknowledgementPhrase:Ae,acknowledgementText:L,onAcknowledgementTextChange:P=>{j(P),g(null)},disabled:Q}),y&&!J&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(Y,{htmlFor:"kiro-auth-method",children:m("addAccountDialog.authMethod")}),e.jsxs(js,{value:C,onValueChange:P=>{M(P),g(null)},children:[e.jsx(Ns,{id:"kiro-auth-method",children:e.jsx(bs,{placeholder:m("addAccountDialog.selectKiroAuthMethod")})}),e.jsx(ys,{children:nt.map(P=>e.jsx(Le,{value:P.id,children:P.label},P.id))})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:W.description})]}),!J&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(Y,{htmlFor:"nickname",children:m("addAccountDialog.nicknameOptional")}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(fe,{className:"w-4 h-4 text-muted-foreground"}),e.jsx(de,{id:"nickname",value:d,onChange:P=>{u(P.target.value),g(null)},placeholder:m("addAccountDialog.nicknamePlaceholder"),disabled:Q,className:"flex-1"})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:m("addAccountDialog.nicknameOptionalHint")})]}),J&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"text-center",children:[e.jsxs("p",{className:"text-sm text-muted-foreground",children:[e.jsx(Z,{className:"w-4 h-4 inline mr-2 animate-spin"}),m("addAccountDialog.waitingForAuth")]}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:h.isDeviceCodeFlow?m("addAccountDialog.deviceCodeHint"):m("addAccountDialog.browserHint")})]}),h.authUrl&&!h.isDeviceCodeFlow&&e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(Y,{className:"text-xs",children:m("addAccountDialog.openUrlLabel")}),e.jsxs("div",{className:"p-3 bg-muted rounded-md",children:[e.jsx("p",{className:"text-xs text-muted-foreground break-all font-mono line-clamp-3",children:h.authUrl}),e.jsxs("div",{className:"flex gap-2 mt-2",children:[e.jsx(I,{variant:"outline",size:"sm",onClick:Me,children:p?e.jsxs(e.Fragment,{children:[e.jsx(ue,{className:"w-3 h-3 mr-1"}),m("addAccountDialog.copied")]}):e.jsxs(e.Fragment,{children:[e.jsx(Ts,{className:"w-3 h-3 mr-1"}),m("addAccountDialog.copy")]})}),e.jsxs(I,{variant:"outline",size:"sm",onClick:()=>{if(!h.authUrl)return;const P=window.open(h.authUrl,"_blank");(!P||P.closed||typeof P.closed>"u")&&U.warning(m("addAccountDialog.popupBlocked"),{duration:5e3})},children:[e.jsx(me,{className:"w-3 h-3 mr-1"}),m("addAccountDialog.open")]})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Y,{htmlFor:"callback-url",className:"text-xs",children:m("addAccountDialog.redirectPasteLabel")}),e.jsx(de,{id:"callback-url",value:r,onChange:P=>o(P.target.value),placeholder:m("addAccountDialog.callbackPlaceholder"),className:"font-mono text-xs"}),e.jsx(I,{variant:"secondary",size:"sm",onClick:De,disabled:!r.trim()||h.isSubmittingCallback,children:h.isSubmittingCallback?e.jsxs(e.Fragment,{children:[e.jsx(Z,{className:"w-3 h-3 mr-1 animate-spin"}),m("addAccountDialog.submitting")]}):m("addAccountDialog.submitCallback")})]})]}),!h.authUrl&&!h.isDeviceCodeFlow&&e.jsx("p",{className:"text-xs text-center text-muted-foreground",children:m("addAccountDialog.preparingUrl")})]}),E&&e.jsx("p",{className:"text-xs text-center text-destructive",children:E}),k.isPending&&e.jsxs("p",{className:"text-sm text-center text-muted-foreground",children:[e.jsx(Z,{className:"w-4 h-4 inline mr-2 animate-spin"}),m("addAccountDialog.importingToken")]}),e.jsxs("div",{className:"flex items-center justify-end gap-2 pt-2",children:[e.jsx(I,{variant:"ghost",onClick:be,children:m("addAccountDialog.cancel")}),y&&!J&&e.jsx(I,{variant:"outline",onClick:we,disabled:Q,children:k.isPending?e.jsxs(e.Fragment,{children:[e.jsx(Z,{className:"w-4 h-4 mr-2 animate-spin"}),m("addAccountDialog.importing")]}):e.jsxs(e.Fragment,{children:[e.jsx(Ft,{className:"w-4 h-4 mr-2"}),m("addAccountDialog.importFromIde")]})}),!J&&e.jsxs(I,{onClick:ye,disabled:Q||R||T&&!K||H&&!V,children:[e.jsx(me,{className:"w-4 h-4 mr-2"}),m("addAccountDialog.authenticate")]})]})]})]})})}const ga=["ANTHROPIC_BASE_URL","ANTHROPIC_AUTH_TOKEN"];function fa(s){const t=s?.env||{};return ga.filter(a=>!t[a]?.trim())}function va(s){const[t,a]=c.useState(null),[n,i]=c.useState(!1),d=Ve(),{data:u,isLoading:r,refetch:o}=hs({queryKey:["settings",s],queryFn:async()=>{const h=await fetch(`/api/settings/${s}/raw`);return h.ok?h.json():{profile:s,settings:{env:{}},mtime:Date.now(),path:`~/.ccs/profiles/${s}/settings.json`}}}),p=u?.settings,f=c.useMemo(()=>t!==null?t:p?JSON.stringify(p,null,2):`{
|
|
2
|
-
"env": {}
|
|
3
|
-
}`,[t,p]),v=c.useCallback(h=>{a(h)},[]),g=c.useMemo(()=>{try{return JSON.parse(f)}catch{return p||{env:{}}}},[f,p]),L=g?.env?.ANTHROPIC_MODEL,j=g?.env?.ANTHROPIC_DEFAULT_OPUS_MODEL,w=g?.env?.ANTHROPIC_DEFAULT_SONNET_MODEL,D=g?.env?.ANTHROPIC_DEFAULT_HAIKU_MODEL,b=c.useMemo(()=>it(g?.env||{}),[g]),N=c.useCallback((h,k)=>rt(h,k,{supportsExtendedContext:y=>ea(s,y)}),[s]),l=c.useCallback((h,k)=>{const y={...g?.env||{},[h]:k},F=rs(h)?N(y,b):y;delete F.CCS_EXTENDED_CONTEXT;const H={...g,env:F};a(JSON.stringify(H,null,2))},[N,g,b]),A=c.useCallback(h=>{const k=g?.env||{},y=N(k,h);delete y.CCS_EXTENDED_CONTEXT;const F={...g,env:y};a(JSON.stringify(F,null,2))},[N,g]),C=c.useCallback(h=>{const k={...g?.env||{},...h},F=Object.keys(h).some(rs)?N(k,b):k;delete F.CCS_EXTENDED_CONTEXT;const H={...g,env:F};a(JSON.stringify(H,null,2))},[N,g,b]),M=c.useMemo(()=>{try{return JSON.parse(f),!0}catch{return!1}},[f]),m=c.useMemo(()=>t===null?!1:t!==JSON.stringify(p,null,2),[t,p]),S=c.useMemo(()=>fa(g),[g]),O=Qs({mutationFn:async()=>{const h=JSON.parse(f),k=await fetch(`/api/settings/${s}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({settings:h,expectedMtime:u?.mtime})});if(k.status===409)throw new Error("CONFLICT");if(!k.ok)throw new Error("Failed to save");return k.json()},onSuccess:h=>{d.invalidateQueries({queryKey:["settings",s]}),a(null),h?.warning?U.success("Settings saved",{description:h.warning}):U.success("Settings saved")},onError:h=>{h.message==="CONFLICT"?i(!0):U.error(h.message)}}),q=async h=>{i(!1),h?(await o(),O.mutate()):a(null)};return{data:u,isLoading:r,refetch:o,rawJsonContent:f,rawJsonEdits:t,isRawJsonValid:M,hasChanges:m,currentSettings:g,currentModel:L,opusModel:j,sonnetModel:w,haikuModel:D,extendedContextEnabled:b,toggleExtendedContext:A,handleRawJsonChange:v,updateEnvValue:l,updateEnvValues:C,saveMutation:{mutate:()=>O.mutate(),isPending:O.isPending},conflictDialog:n,setConflictDialog:i,handleConflictResolve:q,missingRequiredFields:S}}const ja=/-(medium|high|xhigh)$/i;function Na(s){if(!s)return;const t=s.trim().match(ja);if(t?.[1])return t[1].toLowerCase()}function ba(s){if(!s)return null;const t=Na(s);return t?{label:`Pinned ${t}`,explicit:!0}:{label:"Auto effort",explicit:!1}}function ya({label:s}){return e.jsx(G,{variant:"outline",className:"text-[9px] h-4 px-1",children:s})}function Ce({modelId:s}){const t=ba(s);return t?e.jsx(G,{variant:t.explicit?"secondary":"outline",className:"text-[9px] h-4 px-1 uppercase",children:t.label}):null}function oe({label:s,description:t,value:a,onChange:n,catalog:i,allModels:d,disabled:u}){const{t:r}=se(),o=i?.provider==="codex",p=c.useMemo(()=>Gs(i,d),[d,i]),f=new Set(p.map(j=>j.id)),v=p.map(j=>({value:j.id,groupKey:"recommended",searchText:`${j.id} ${j.name}`,keywords:[j.tier??"",i?.provider??""],triggerContent:e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("span",{className:"truncate font-mono text-xs",children:j.id}),o&&e.jsx(Ce,{modelId:j.id})]}),itemContent:e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("span",{className:"truncate font-mono text-xs",children:j.id}),j.tier==="paid"&&e.jsx(ya,{label:r("providerModelSelector.paid")}),o&&e.jsx(Ce,{modelId:j.id})]})})),g=d.filter(j=>!f.has(j.id)).map(j=>({value:j.id,groupKey:"all",searchText:j.id,keywords:[j.owned_by],triggerContent:e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("span",{className:"truncate font-mono text-xs",children:j.id}),o&&e.jsx(Ce,{modelId:j.id})]}),itemContent:e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("span",{className:"truncate font-mono text-xs",children:j.id}),o&&e.jsx(Ce,{modelId:j.id})]})})),L=v.length+g.length>0;return e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-medium",children:s}),t&&e.jsx("p",{className:"text-[10px] text-muted-foreground",children:t})]}),e.jsx(Qt,{value:a||void 0,onChange:n,disabled:u,placeholder:r("providerModelSelector.selectModel"),searchPlaceholder:r("searchableSelect.searchModels"),emptyText:r(L?"searchableSelect.noResults":"providerModelSelector.noModelsAvailable"),triggerClassName:"h-9",groups:[{key:"recommended",label:e.jsx("span",{className:"text-xs text-primary",children:r("providerModelSelector.recommended")})},{key:"all",label:e.jsx("span",{className:"text-xs text-muted-foreground",children:r("providerModelSelector.allModelsCount",{count:d.length})})}],options:[...v,...g]})]})}function wa({open:s,onClose:t,currentValues:a,onApply:n,onSave:i,isSaving:d,catalog:u,allModels:r}){const{t:o}=se(),[p,f]=c.useState(a),[v,g]=c.useState(""),L=j=>{j?(f(a),g("")):t()};return e.jsx(ze,{open:s,onOpenChange:L,children:e.jsxs($e,{className:"sm:max-w-md",children:[e.jsx(Qe,{children:e.jsxs(Je,{className:"flex items-center gap-2",children:[e.jsx(je,{className:"w-4 h-4"}),o("customPresetDialog.title")]})}),e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(Y,{htmlFor:"preset-name",children:o("customPresetDialog.presetNameOptional")}),e.jsx(de,{id:"preset-name",value:v,onChange:j=>g(j.target.value),placeholder:o("customPresetDialog.presetNamePlaceholder"),className:"text-sm"})]}),e.jsx(as,{}),u?.provider==="codex"&&e.jsxs("p",{className:"text-[11px] text-muted-foreground rounded-md border bg-muted/30 px-2.5 py-2",children:[o("customPresetDialog.codexTipPrefix")," ",e.jsx("code",{children:"-medium"}),", ",e.jsx("code",{children:"-high"}),", and"," ",e.jsx("code",{children:"-xhigh"})," ",o("customPresetDialog.codexTipSuffix")]}),e.jsx(oe,{label:o("customPresetDialog.defaultModel"),description:o("customPresetDialog.defaultModelDesc"),value:p.default,onChange:j=>f({...p,default:j}),catalog:u,allModels:r}),e.jsx(oe,{label:o("customPresetDialog.opusModel"),description:o("customPresetDialog.opusModelDesc"),value:p.opus,onChange:j=>f({...p,opus:j}),catalog:u,allModels:r}),e.jsx(oe,{label:o("customPresetDialog.sonnetModel"),description:o("customPresetDialog.sonnetModelDesc"),value:p.sonnet,onChange:j=>f({...p,sonnet:j}),catalog:u,allModels:r}),e.jsx(oe,{label:o("customPresetDialog.haikuModel"),description:o("customPresetDialog.haikuModelDesc"),value:p.haiku,onChange:j=>f({...p,haiku:j}),catalog:u,allModels:r})]}),e.jsxs(ot,{className:"gap-2 sm:gap-0",children:[e.jsx(I,{variant:"outline",onClick:t,children:o("customPresetDialog.cancel")}),i&&e.jsxs(I,{variant:"secondary",onClick:()=>i(p,v||void 0),disabled:d||!v.trim(),children:[d?e.jsx(Z,{className:"w-4 h-4 mr-1 animate-spin"}):e.jsx(ss,{className:"w-4 h-4 mr-1"}),o("customPresetDialog.savePreset")]}),e.jsxs(I,{onClick:()=>n(p,v||void 0),children:[e.jsx(Ne,{className:"w-4 h-4 mr-1"}),o("customPresetDialog.applyPreset")]})]})]})})}function re({label:s,command:t}){return e.jsxs("div",{children:[e.jsx("label",{className:"text-xs text-muted-foreground",children:s}),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:t}),e.jsx(Ps,{value:t,size:"icon",className:"h-6 w-6"})]})]})}function Ca({provider:s,displayName:t,defaultTarget:a,data:n,authStatus:i,supportsModelConfig:d=!1}){const u=a||"claude",r=u==="droid",o=s==="codex",p=u==="claude"?`ccs ${s}`:`ccs ${s} --target claude`,f=`${p} --config`,v=`${p} --auth --add`,g=`${p} --accounts`;return e.jsx(We,{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(Os,{className:"w-4 h-4"}),"Provider Information"]}),e.jsxs("div",{className:"space-y-3 bg-card rounded-lg border p-4 shadow-sm",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:"Provider"}),e.jsx("span",{className:"font-mono",children:t})]}),n&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid grid-cols-[100px_1fr] gap-2 text-sm items-center",children:[e.jsx("span",{className:"font-medium text-muted-foreground",children:"File Path"}),e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsx("code",{className:"bg-muted px-1.5 py-0.5 rounded text-xs break-all",children:n.path}),e.jsx(Ps,{value:n.path,size:"icon",className:"h-5 w-5"})]})]}),e.jsxs("div",{className:"grid grid-cols-[100px_1fr] gap-2 text-sm items-center",children:[e.jsx("span",{className:"font-medium text-muted-foreground",children:"Last Modified"}),e.jsx("span",{className:"text-xs",children:new Date(n.mtime).toLocaleString()})]})]}),e.jsxs("div",{className:"grid grid-cols-[100px_1fr] gap-2 text-sm items-center",children:[e.jsx("span",{className:"font-medium text-muted-foreground",children:"Status"}),i.authenticated?e.jsxs(G,{variant:"outline",className:"w-fit text-green-600 border-green-200 bg-green-50",children:[e.jsx(Ut,{className:"w-3 h-3 mr-1"}),"Authenticated"]}):e.jsx(G,{variant:"outline",className:"w-fit text-muted-foreground",children:"Not connected"})]}),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:"Default Target"}),e.jsx("span",{className:"font-mono",children:u})]})]})]}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-medium mb-3",children:"Quick Usage"}),e.jsxs("div",{className:"space-y-3 bg-card rounded-lg border p-4 shadow-sm",children:[e.jsx(re,{label:"Run with prompt",command:`ccs ${s} "your prompt"`}),o&&e.jsxs(e.Fragment,{children:[e.jsx(re,{label:"Run on native Codex (shortcut)",command:'ccsxp "your prompt"'}),e.jsx(re,{label:"Run on native Codex (--target)",command:`ccs ${s} --target codex "your prompt"`})]}),e.jsx(re,{label:r?"Droid alias (explicit)":"Run on Droid",command:`ccs-droid ${s} "your prompt"`}),e.jsx(re,{label:r?"Override to Claude":"Run on Droid (--target)",command:`ccs ${s} --target ${r?"claude":"droid"} "your prompt"`}),d&&e.jsx(re,{label:u==="claude"?"Change model":"Change model (Claude target)",command:f}),e.jsx(re,{label:u==="claude"?"Add account":"Add account (Claude target)",command:v}),e.jsx(re,{label:u==="claude"?"List accounts":"List accounts (Claude target)",command:g}),u!=="claude"&&e.jsx("p",{className:"text-xs text-muted-foreground",children:"Account and model-management flags stay on Claude target. Codex and Droid runtime launches reject those CLIProxy management commands."})]})]})]})})}function ka({displayName:s,logoProvider:t,provider:a,data:n,isLoading:i,hasChanges:d,isRawJsonValid:u,isSaving:r,isRemoteMode:o,port:p,onRefetch:f,onSave:v}){return e.jsxs("div",{className:"px-6 py-4 border-b bg-background flex items-center justify-between shrink-0",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(Xe,{provider:t||a,size:"lg"}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h2",{className:"text-lg font-semibold",children:s}),o&&e.jsxs(G,{variant:"secondary",className:"text-xs gap-1 bg-blue-100 text-blue-700 dark:bg-blue-900/30 dark:text-blue-400",children:[e.jsx(Rs,{className:"w-3 h-3"}),"Remote"]}),p&&e.jsxs(G,{variant:"outline",className:"text-xs gap-1 font-mono",children:[e.jsx(qt,{className:"w-3 h-3"}),":",p]}),!o&&n?.path&&e.jsx(G,{variant:"outline",className:"text-xs",children:n.path.replace(/^.*[\\/]/,"")})]}),o?e.jsx("p",{className:"text-xs text-blue-600 dark:text-blue-400 mt-0.5",children:"Traffic auto-routed to remote server"}):n&&e.jsxs("p",{className:"text-xs text-muted-foreground mt-0.5",children:["Last modified: ",new Date(n.mtime).toLocaleString()]})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(I,{variant:"ghost",size:"sm",onClick:f,disabled:i,children:e.jsx(Ze,{className:`w-4 h-4 ${i?"animate-spin":""}`})}),e.jsx(I,{size:"sm",onClick:v,disabled:r||!d||!u,children:r?e.jsxs(e.Fragment,{children:[e.jsx(Z,{className:"w-4 h-4 mr-1 animate-spin"}),"Saving..."]}):e.jsxs(e.Fragment,{children:[e.jsx(Kt,{className:"w-4 h-4 mr-1"}),"Save"]})})]})]})}function Aa({models:s,provider:t,enabled:a,onToggle:n,disabled:i,className:d}){if(s.length===0)return null;const u=s.some(p=>os(p.id)),r=s.some(p=>!os(p.id));let o="Compatible mappings stay on standard context unless you turn this on.";return u&&r?o="Gemini-compatible mappings can use 1M automatically. Claude mappings stay plain unless you turn this on.":u&&(o="Gemini-compatible mappings can use 1M by default. Turn this off to keep standard context."),e.jsxs("div",{className:B("rounded-lg border p-3 space-y-2",a?"border-primary/50 bg-primary/5":"border-border bg-muted/30",d),children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ne,{className:B("w-4 h-4",a?"text-primary":"text-muted-foreground")}),e.jsx("span",{className:"text-sm font-medium",children:"Extended Context"}),e.jsx(G,{variant:a?"default":"secondary",className:"text-[10px] h-5 px-1.5",children:"1M tokens"})]}),e.jsx(Ms,{checked:a,onCheckedChange:n,disabled:i})]}),e.jsxs("div",{className:"flex items-start gap-2 text-xs text-muted-foreground",children:[e.jsx(Os,{className:"w-3.5 h-3.5 mt-0.5 shrink-0"}),e.jsxs("div",{className:"space-y-1",children:[e.jsxs("p",{children:["Applies the explicit ",e.jsx("code",{children:"[1m]"})," long-context suffix to compatible saved mappings."]}),e.jsx("p",{className:"text-[10px]",children:o}),e.jsxs("p",{className:"text-amber-600 dark:text-amber-500",children:["CCS only saves ",e.jsx("code",{children:"[1m]"}),". Provider pricing and entitlement are separate, and some accounts can still return 429 extra-usage errors for long-context requests."]})]})]})]})}function Sa(s){const t=s.presetMapping||{default:s.id,opus:s.id,sonnet:s.id,haiku:s.id};return{ANTHROPIC_MODEL:t.default,ANTHROPIC_DEFAULT_OPUS_MODEL:t.opus,ANTHROPIC_DEFAULT_SONNET_MODEL:t.sonnet,ANTHROPIC_DEFAULT_HAIKU_MODEL:t.haiku}}function Pa({catalog:s,savedPresets:t,currentModel:a,opusModel:n,sonnetModel:i,haikuModel:d,providerModels:u,provider:r,extendedContextEnabled:o,onExtendedContextToggle:p,onApplyPreset:f,onUpdateEnvValue:v,onOpenCustomPreset:g,onDeletePreset:L,isDeletePending:j}){const w=c.useMemo(()=>{if(!s)return[];const l=[a,n,i,d].filter(C=>!!C).map(C=>lt(C));return[...new Set(l)].map(C=>Hs(s.provider,C)).filter(C=>!!C?.extendedContext)},[s,a,n,i,d]),D=c.useMemo(()=>Gs(s,u),[s,u]),b=c.useMemo(()=>{const l=D.filter(C=>C.presetMapping);return l.length===0?[]:l.some(C=>C.tier==="paid")?[{key:"free",label:"Free Tier",description:"Available on free or paid plans",badgeClassName:"text-[10px] bg-green-100 text-green-700 border-green-200",iconClassName:"text-green-600",models:l.filter(C=>C.tier!=="paid")},{key:"paid",label:"Paid Tier",description:"Requires paid access",badgeClassName:"text-[10px] bg-amber-100 text-amber-700 border-amber-200",iconClassName:"text-amber-700",models:l.filter(C=>C.tier==="paid")}].filter(C=>C.models.length>0):[{key:"default",models:l.slice(0,4)}]},[D]),N=b.length>0||t.length>0;return e.jsxs(e.Fragment,{children:[N&&e.jsxs("div",{children:[e.jsxs("h3",{className:"text-sm font-medium mb-2 flex items-center gap-2",children:[e.jsx(je,{className:"w-4 h-4"}),"Presets"]}),e.jsx("p",{className:"text-xs text-muted-foreground mb-3",children:"Apply pre-configured model mappings"}),e.jsxs("div",{className:"space-y-4",children:[b.map(l=>e.jsxs("div",{children:["label"in l&&l.label&&e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(G,{variant:"outline",className:l.badgeClassName,children:l.label}),e.jsx("span",{className:"text-[10px] text-muted-foreground",children:l.description})]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:l.models.map(A=>e.jsxs(I,{variant:"outline",size:"sm",className:"text-xs h-7 gap-1",onClick:()=>f(Sa(A)),children:[e.jsx(Ne,{className:`w-3 h-3 ${"iconClassName"in l?l.iconClassName:""}`}),A.name]},A.id))})]},l.key)),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[t.map(l=>e.jsxs("div",{className:"group relative",children:[e.jsxs(I,{variant:"secondary",size:"sm",className:"text-xs h-7 gap-1 pr-6",onClick:()=>{f({ANTHROPIC_MODEL:l.default,ANTHROPIC_DEFAULT_OPUS_MODEL:l.opus,ANTHROPIC_DEFAULT_SONNET_MODEL:l.sonnet,ANTHROPIC_DEFAULT_HAIKU_MODEL:l.haiku})},children:[e.jsx(ss,{className:"w-3 h-3 fill-current"}),l.name]}),e.jsx(I,{variant:"ghost",size:"icon",className:"absolute right-0 top-0 h-7 w-5 opacity-0 group-hover:opacity-100 hover:text-destructive",onClick:A=>{A.stopPropagation(),L(l.name)},disabled:j,children:e.jsx(ts,{className:"w-3 h-3"})})]},l.name)),e.jsxs(I,{variant:"outline",size:"sm",className:"text-xs h-7 gap-1 border-primary/50 text-primary hover:bg-primary/10 hover:border-primary",onClick:g,children:[e.jsx(Is,{className:"w-3 h-3"}),"Custom"]})]})]})]}),e.jsx(as,{}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-medium mb-2",children:"Model Mapping"}),e.jsx("p",{className:"text-xs text-muted-foreground mb-4",children:"Configure which models to use for each tier"}),r==="codex"&&e.jsxs("p",{className:"text-[11px] text-muted-foreground mb-3 rounded-md border bg-muted/30 px-2.5 py-2",children:["Codex tip: suffixes ",e.jsx("code",{children:"-medium"}),", ",e.jsx("code",{children:"-high"}),", and ",e.jsx("code",{children:"-xhigh"})," ","pin reasoning effort. Unsuffixed models use Thinking settings."]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx(oe,{label:"Default Model",description:"Used when no specific tier is requested",value:a,onChange:l=>v("ANTHROPIC_MODEL",l),catalog:s,allModels:u}),w.length>0&&p&&e.jsx(Aa,{models:w,provider:r,enabled:o??!1,onToggle:p}),e.jsx(oe,{label:"Opus (Most capable)",description:"For complex reasoning tasks",value:n,onChange:l=>v("ANTHROPIC_DEFAULT_OPUS_MODEL",l),catalog:s,allModels:u}),e.jsx(oe,{label:"Sonnet (Balanced)",description:"Balance of speed and capability",value:i,onChange:l=>v("ANTHROPIC_DEFAULT_SONNET_MODEL",l),catalog:s,allModels:u}),e.jsx(oe,{label:"Haiku (Fast)",description:"Quick responses for simple tasks",value:d,onChange:l=>v("ANTHROPIC_DEFAULT_HAIKU_MODEL",l),catalog:s,allModels:u})]})]})]})}function Ma(s,t){return s?e.jsx(Fe,{children:e.jsxs(Ue,{children:[e.jsx(qe,{asChild:!0,children:e.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[e.jsx(Gt,{className:"w-3 h-3","aria-hidden":"true"}),e.jsx("span",{className:B("font-mono max-w-[180px] truncate",t&&Be),title:s,children:s})]})}),e.jsx(Ke,{side:"bottom",children:e.jsx("p",{className:"text-xs",children:"GCP Project ID (read-only)"})})]})}):e.jsx(Fe,{children:e.jsxs(Ue,{children:[e.jsx(qe,{asChild:!0,children:e.jsxs("div",{className:"flex items-center gap-1 text-xs text-amber-600 dark:text-amber-500",children:[e.jsx(es,{className:"w-3 h-3","aria-label":"Warning"}),e.jsx("span",{children:"Project ID: N/A"})]})}),e.jsx(Ke,{side:"bottom",className:"max-w-[250px]",children:e.jsxs("div",{className:"text-xs space-y-1",children:[e.jsx("p",{className:"font-medium text-amber-600",children:"Missing Project ID"}),e.jsx("p",{children:"This may cause errors. Remove the account and re-add it to fetch the project ID."})]})})]})})}function Da({account:s,onSetDefault:t,onRemove:a,onPauseToggle:n,isRemoving:i,isPausingAccount:d,privacyMode:u,showQuota:r,selectable:o,selected:p,onSelectChange:f}){const v=s.provider.toLowerCase(),{data:g}=ct(r),{data:L,isLoading:j}=dt(v,s.id,r),w=ut(g,s)?.lastUsedAt,D=o||n?e.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[o&&e.jsx("button",{type:"button",onClick:()=>f?.(!p),className:B("flex items-center justify-center w-5 h-5 rounded border-2 transition-colors shrink-0",p?"bg-primary border-primary text-primary-foreground":"border-muted-foreground/30 hover:border-primary/50"),"aria-label":p?"Deselect account":"Select account",children:p&&e.jsx(ue,{className:"w-3 h-3"})}),n&&e.jsx(Fe,{children:e.jsxs(Ue,{children:[e.jsx(qe,{asChild:!0,children:e.jsx(I,{variant:"ghost",size:"icon",className:"h-7 w-7 shrink-0",onClick:()=>n(!s.paused),disabled:d,children:d?e.jsx(Z,{className:"w-4 h-4 animate-spin"}):s.paused?e.jsx(Ls,{className:"w-4 h-4 text-emerald-500"}):e.jsx(_s,{className:"w-4 h-4 text-muted-foreground hover:text-foreground"})})}),e.jsx(Ke,{side:"top",children:s.paused?"Resume account":"Pause account"})]})})]}):void 0,b=e.jsxs(mt,{children:[e.jsx(pt,{asChild:!0,children:e.jsx(I,{variant:"ghost",size:"icon",className:"h-7 w-7 shrink-0",children:e.jsx(Ht,{className:"w-4 h-4"})})}),e.jsxs(xt,{align:"end",children:[!s.isDefault&&e.jsxs(ls,{onClick:t,children:[e.jsx(ss,{className:"w-4 h-4 mr-2"}),"Set as default"]}),e.jsxs(ls,{className:"text-destructive focus:text-destructive",onClick:a,disabled:i,children:[e.jsx(Fs,{className:"w-4 h-4 mr-2"}),i?"Removing...":"Remove account"]})]})]});return e.jsx("div",{className:B("rounded-lg border p-3 transition-colors overflow-hidden",s.isDefault?"border-primary/30 bg-primary/5":"border-border hover:bg-muted/30",s.paused&&"opacity-75",p&&"ring-2 ring-primary/50 bg-primary/5"),children:e.jsx(ht,{mode:"detailed",provider:s.provider,accountId:s.id,email:s.email,displayEmail:s.email||s.id,tokenFile:s.tokenFile,tier:s.tier,isDefault:s.isDefault,paused:s.paused,privacyMode:u,showQuota:r,quota:L,quotaLoading:j,runtimeLastUsed:w,beforeIdentity:D,headerEnd:b,bodySlot:s.provider==="agy"?Ma(s.projectId,u):null,quotaInsetClassName:"pl-11"})})}function Ta({selectedCount:s,onPauseSelected:t,onResumeSelected:a,onClearSelection:n,isPausing:i,isResuming:d}){if(s<1)return null;const u=i||d;return e.jsxs("div",{className:"flex items-center gap-3 p-2 bg-muted/50 rounded-lg border mt-2",children:[e.jsxs("span",{className:"text-sm text-muted-foreground",children:[s," selected"]}),e.jsx(I,{variant:"ghost",size:"sm",className:"text-xs h-6 px-2",onClick:n,disabled:u,children:"Clear"}),e.jsxs("div",{className:"flex gap-2 ml-auto",children:[e.jsxs(I,{size:"sm",variant:"outline",className:"h-7 text-xs gap-1",onClick:t,disabled:u,children:[i?e.jsx(Z,{className:"w-3 h-3 animate-spin"}):e.jsx(_s,{className:"w-3 h-3"}),"Pause Selected"]}),e.jsxs(I,{size:"sm",variant:"outline",className:"h-7 text-xs gap-1",onClick:a,disabled:u,children:[d?e.jsx(Z,{className:"w-3 h-3 animate-spin"}):e.jsx(Ls,{className:"w-3 h-3"}),"Resume Selected"]})]})]})}function Ea({accounts:s,onAddAccount:t,onSetDefault:a,onRemoveAccount:n,onPauseToggle:i,onSoloMode:d,onBulkPause:u,onBulkResume:r,isRemovingAccount:o,isPausingAccount:p,isSoloingAccount:f,isBulkPausing:v,isBulkResuming:g,privacyMode:L,showQuota:j,isKiro:w,kiroNoIncognito:D,onKiroNoIncognitoChange:b,kiroSettingsLoading:N}){const[l,A]=c.useState(new Set),C=c.useMemo(()=>new Set(s.map(R=>R.id)),[s]),M=c.useMemo(()=>new Set([...l].filter(R=>C.has(R))),[l,C]),m=!!(u&&r),S=M.size,O=s.length>0&&M.size===s.length,q=M.size>0&&M.size<s.length,h=c.useCallback(R=>{A(K=>{const V=new Set(K);return V.has(R)?V.delete(R):V.add(R),V})},[]),k=c.useCallback(()=>{A(new Set(s.map(R=>R.id)))},[s]),y=c.useCallback(()=>{A(new Set)},[]),F=c.useCallback(()=>{O?y():k()},[O,k,y]),H=c.useCallback(()=>{u&&M.size>0&&(u(Array.from(M)),A(new Set))},[u,M]),T=c.useCallback(()=>{r&&M.size>0&&(r(Array.from(M)),A(new Set))},[r,M]);return e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsxs("h3",{className:"text-sm font-medium flex items-center gap-2",children:[m&&s.length>0&&e.jsx(Se,{checked:O,onCheckedChange:F,"aria-label":"Select all accounts",className:q?"data-[state=checked]:bg-primary/50":"",...q?{"data-state":"indeterminate"}:{}}),e.jsx(fe,{className:"w-4 h-4"}),"Accounts",s.length>0&&e.jsx(G,{variant:"secondary",className:"text-xs",children:s.length})]}),e.jsxs(I,{variant:"default",size:"sm",className:"h-7 text-xs gap-1",onClick:t,children:[e.jsx(Is,{className:"w-3 h-3"}),"Add"]})]}),m&&S>0&&e.jsx(Ta,{selectedCount:S,onPauseSelected:H,onResumeSelected:T,onClearSelection:y,isPausing:!!v,isResuming:!!g}),s.length>0?e.jsx("div",{className:"space-y-2",children:s.map(R=>e.jsx(Da,{account:R,onSetDefault:()=>a(R.id),onRemove:()=>n(R.id),onPauseToggle:i?K=>i(R.id,K):void 0,onSoloMode:d?()=>d(R.id):void 0,isRemoving:o,isPausingAccount:p,isSoloingAccount:f,privacyMode:L,showQuota:j,selectable:m,selected:M.has(R.id),onSelectChange:()=>h(R.id)},R.id))}):e.jsxs("div",{className:"py-6 text-center text-muted-foreground bg-muted/30 rounded-lg border border-dashed",children:[e.jsx(fe,{className:"w-8 h-8 mx-auto mb-2 opacity-50"}),e.jsx("p",{className:"text-sm",children:"No accounts connected"}),e.jsx("p",{className:"text-xs opacity-70",children:"Add an account to get started"})]}),w&&b&&e.jsx("div",{className:"mt-3 pt-3 border-t border-dashed",children:e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(Rs,{className:"w-3.5 h-3.5"}),e.jsx("span",{children:"Use incognito"})]}),e.jsx(Ms,{checked:!D,onCheckedChange:R=>b(!R),disabled:N,className:"scale-90"})]})})]})}function Oa({provider:s,catalog:t,savedPresets:a,currentModel:n,opusModel:i,sonnetModel:d,haikuModel:u,providerModels:r,extendedContextEnabled:o,onExtendedContextToggle:p,onApplyPreset:f,onUpdateEnvValue:v,onOpenCustomPreset:g,onDeletePreset:L,isDeletePending:j,accounts:w,onAddAccount:D,onSetDefault:b,onRemoveAccount:N,onPauseToggle:l,onSoloMode:A,onBulkPause:C,onBulkResume:M,isRemovingAccount:m,isPausingAccount:S,isSoloingAccount:O,isBulkPausing:q,isBulkResuming:h,privacyMode:k,isRemoteMode:y}){const F=s.toLowerCase(),H=(gt.includes(F)||["anthropic","antigravity","gemini-cli","copilot","github-copilot"].includes(F))&&!y,T=s==="kiro",[R,K]=c.useState(!0),[V,te]=c.useState(!0),[W,ae]=c.useState(!1),Q=c.useCallback(async()=>{if(T)try{te(!0);const z=(await ke.config.get()).cliproxy;K(z?.kiro_no_incognito??!0)}catch{K(!0)}finally{te(!1)}},[T]),x=c.useCallback(async E=>{K(E),ae(!0);try{const z=await ke.config.get(),ne=z.cliproxy??{};await ke.config.update({...z,cliproxy:{...ne,kiro_no_incognito:E}})}catch{K(!E)}finally{ae(!1)}},[]);return c.useEffect(()=>{Q()},[Q]),e.jsx(We,{className:"flex-1",children:e.jsxs("div",{className:"p-4 space-y-6",children:[e.jsx(Pa,{catalog:t,savedPresets:a,currentModel:n,opusModel:i,sonnetModel:d,haikuModel:u,providerModels:r,provider:s,extendedContextEnabled:o,onExtendedContextToggle:p,onApplyPreset:f,onUpdateEnvValue:v,onOpenCustomPreset:g,onDeletePreset:L,isDeletePending:j}),e.jsx(as,{}),e.jsx(Ea,{accounts:w,onAddAccount:D,onSetDefault:b,onRemoveAccount:N,onPauseToggle:l,onSoloMode:A,onBulkPause:C,onBulkResume:M,isRemovingAccount:m,isPausingAccount:S,isSoloingAccount:O,isBulkPausing:q,isBulkResuming:h,privacyMode:k,showQuota:H,isKiro:T,kiroNoIncognito:R,onKiroNoIncognitoChange:x,kiroSettingsLoading:V||W})]})})}function xs({provider:s,displayName:t,authStatus:a,catalog:n,logoProvider:i,baseProvider:d,isRemoteMode:u,port:r,defaultTarget:o,onAddAccount:p,onSetDefault:f,onRemoveAccount:v,onPauseToggle:g,onSoloMode:L,onBulkPause:j,onBulkResume:w,isRemovingAccount:D,isPausingAccount:b,isSoloingAccount:N,isBulkPausing:l,isBulkResuming:A}){const[C,M]=c.useState(!1),{privacyMode:m}=Cs(),{data:S}=ft(),{data:O}=vt(s),q=jt(),h=Nt(),k=d||s,y=k.toLowerCase()==="agy",F=c.useMemo(()=>{const _=O?.presets||[];return y?_.filter($=>!ee($.default)&&!ee($.opus)&&!ee($.sonnet)&&!ee($.haiku)):_},[y,O?.presets]),H=c.useMemo(()=>{if(!S?.models)return[];const $={gemini:["google"],agy:["antigravity"],codex:["openai"],qwen:["alibaba","qwen"],iflow:["iflow"],kiro:["kiro","aws"],ghcp:["github","copilot"],kimi:["kimi","moonshot"]}[k.toLowerCase()]||[k.toLowerCase()];return S.models.filter(ie=>$.some(Ee=>ie.owned_by.toLowerCase().includes(Ee))?y?!ee(ie.id):!0:!1)},[y,S,k]),T=(d||s).toLowerCase(),{data:R,isLoading:K,refetch:V,rawJsonContent:te,rawJsonEdits:W,isRawJsonValid:ae,hasChanges:Q,currentModel:x,opusModel:E,sonnetModel:z,haikuModel:ne,extendedContextEnabled:xe,toggleExtendedContext:be,handleRawJsonChange:Me,updateEnvValue:De,updateEnvValues:ye,saveMutation:we,conflictDialog:Te,handleConflictResolve:J,missingRequiredFields:P}=va(s),X=c.useMemo(()=>(a.accounts||[]).map(_=>({..._,provider:_.provider||d||s})),[a.accounts,d,s]),{data:he}=hs({queryKey:["auth-tokens-raw"],queryFn:async()=>{const _=await fetch("/api/settings/auth/tokens/raw");return _.ok?_.json():{apiKey:{value:"ccs-internal-managed"}}},staleTime:6e4}),le=he?.apiKey?.value??"ccs-internal-managed",Bs=_=>{if(y&&[_.ANTHROPIC_MODEL,_.ANTHROPIC_DEFAULT_OPUS_MODEL,_.ANTHROPIC_DEFAULT_SONNET_MODEL,_.ANTHROPIC_DEFAULT_HAIKU_MODEL].some(ie=>typeof ie=="string"&&ee(ie))){U.error("Antigravity denylist: Claude Opus 4.5 and Claude Sonnet 4.5 are deprecated.");return}ye({ANTHROPIC_BASE_URL:`http://127.0.0.1:${r??He}/api/provider/${T}`,ANTHROPIC_AUTH_TOKEN:le,..._}),U.success(`Applied "${_.ANTHROPIC_MODEL?.split("/").pop()||"preset"}" preset`)},zs=(_,$)=>{if(y&&[_.default,_.opus,_.sonnet,_.haiku].some(Ee=>ee(Ee))){U.error("Antigravity denylist: Claude Opus 4.5 and Claude Sonnet 4.5 are deprecated.");return}ye({ANTHROPIC_BASE_URL:`http://127.0.0.1:${r??He}/api/provider/${T}`,ANTHROPIC_AUTH_TOKEN:le,ANTHROPIC_MODEL:_.default,ANTHROPIC_DEFAULT_OPUS_MODEL:_.opus,ANTHROPIC_DEFAULT_SONNET_MODEL:_.sonnet,ANTHROPIC_DEFAULT_HAIKU_MODEL:_.haiku}),U.success(`Applied ${$?`"${$}"`:"custom"} preset`),M(!1)},$s=(_,$)=>{if(!$){U.error(As.t("commonToast.enterPresetName"));return}if(y&&[_.default,_.opus,_.sonnet,_.haiku].some(ie=>ee(ie))){U.error("Antigravity denylist: Claude Opus 4.5 and Claude Sonnet 4.5 are deprecated.");return}q.mutate({profile:s,data:{name:$,..._}}),M(!1)};return e.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden",children:[e.jsx(ka,{provider:s,displayName:t,logoProvider:i,data:R,isLoading:K,hasChanges:Q,isRawJsonValid:ae,isSaving:we.isPending,isRemoteMode:u,port:r,onRefetch:V,onSave:()=>we.mutate()}),K?e.jsxs("div",{className:"flex-1 flex items-center justify-center",children:[e.jsx(Z,{className:"w-8 h-8 animate-spin text-muted-foreground"}),e.jsx("span",{className:"ml-3 text-muted-foreground",children:"Loading settings..."})]}):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.jsxs(bt,{defaultValue:"config",className:"h-full flex flex-col",children:[e.jsx("div",{className:"px-4 pt-4 shrink-0",children:e.jsxs(yt,{className:"w-full",children:[e.jsx(cs,{value:"config",className:"flex-1",children:"Model Config"}),e.jsx(cs,{value:"info",className:"flex-1",children:"Info & Usage"})]})}),e.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col",children:[e.jsx(ds,{value:"config",className:"flex-1 mt-0 border-0 p-0 data-[state=inactive]:hidden flex flex-col overflow-hidden",children:e.jsx(Oa,{provider:s,catalog:n,savedPresets:F,currentModel:x,opusModel:E,sonnetModel:z,haikuModel:ne,providerModels:H,extendedContextEnabled:xe,onExtendedContextToggle:be,onApplyPreset:Bs,onUpdateEnvValue:De,onOpenCustomPreset:()=>M(!0),onDeletePreset:_=>h.mutate({profile:s,name:_}),isDeletePending:h.isPending,accounts:X,onAddAccount:p,onSetDefault:f,onRemoveAccount:v,onPauseToggle:g,onSoloMode:L,onBulkPause:j,onBulkResume:w,isRemovingAccount:D,isPausingAccount:b,isSoloingAccount:N,isBulkPausing:l,isBulkResuming:A,privacyMode:m,isRemoteMode:u})}),e.jsx(ds,{value:"info",className:"h-full mt-0 border-0 p-0 data-[state=inactive]:hidden",children:e.jsx(Ca,{provider:s,displayName:t,defaultTarget:o,data:R,authStatus:a,supportsModelConfig:!!n})})]})]})}),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(Vt,{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(wt,{rawJsonContent:te,isRawJsonValid:ae,rawJsonEdits:W,onRawJsonChange:Me,profileEnv:R?.settings?.env,missingRequiredFields:P})]})]}),e.jsx($t,{open:Te,title:"File Modified Externally",description:"This settings file was modified by another process. Overwrite with your changes or discard?",confirmText:"Overwrite",variant:"destructive",onConfirm:()=>J(!0),onCancel:()=>J(!1)}),e.jsx(wa,{open:C,onClose:()=>M(!1),currentValues:{default:x||"",opus:E||"",sonnet:z||"",haiku:ne||""},onApply:zs,onSave:$s,isSaving:q.isPending,catalog:n,allModels:H})]})}function Ra({status:s,isSelected:t,onSelect:a}){const{t:n}=se(),i=s.accounts?.length||0;return e.jsxs("button",{className:B("w-full flex items-center gap-3 px-3 py-2.5 rounded-lg transition-colors cursor-pointer text-left",t?"bg-primary/10 border border-primary/20":"hover:bg-muted border border-transparent"),onClick:a,children:[e.jsx(Xe,{provider:s.provider,size:"md"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"font-medium text-sm truncate",children:s.displayName}),i>0&&e.jsx(G,{variant:"secondary",className:"text-[10px] h-4 px-1",children:i})]}),e.jsx("div",{className:"flex items-center gap-1.5 mt-0.5",children:s.authenticated?e.jsxs(e.Fragment,{children:[e.jsx(ue,{className:"w-3 h-3 text-green-600"}),e.jsx("span",{className:"text-xs text-green-600",children:n("cliproxyPage.connected")})]}):e.jsxs(e.Fragment,{children:[e.jsx(ts,{className:"w-3 h-3 text-muted-foreground"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:n("cliproxyPage.notConnected")})]})})]})]})}function Ia({variant:s,parentAuth:t,isSelected:a,onSelect:n,onDelete:i,isDeleting:d}){const{t:u}=se(),r=()=>{n()};return e.jsxs("div",{role:"button",tabIndex:0,className:B("group w-full flex items-center gap-3 px-3 py-2 rounded-lg transition-colors cursor-pointer text-left pl-6",a?"bg-primary/10 border border-primary/20":"hover:bg-muted border border-transparent"),onClick:r,onKeyDown:o=>{(o.key==="Enter"||o.key===" ")&&(o.preventDefault(),r())},children:[e.jsxs("div",{className:"relative",children:[e.jsx(Xe,{provider:s.provider,size:"sm"}),e.jsx(Us,{className:"w-2.5 h-2.5 absolute -bottom-0.5 -right-0.5 text-muted-foreground"})]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"font-medium text-sm truncate",children:s.name}),e.jsx(G,{variant:"outline",className:"text-[9px] h-4 px-1",children:u("cliproxyPage.variant")}),e.jsx(G,{variant:"outline",className:"text-[9px] h-4 px-1 uppercase",children:s.target||"claude"})]}),e.jsx("div",{className:"flex items-center gap-1.5 mt-0.5",children:t?.authenticated?e.jsxs(e.Fragment,{children:[e.jsx(ue,{className:"w-3 h-3 text-green-600"}),e.jsx("span",{className:"text-xs text-muted-foreground truncate",children:u("cliproxyPage.viaProvider",{provider:s.provider})})]}):e.jsxs(e.Fragment,{children:[e.jsx(ts,{className:"w-3 h-3 text-muted-foreground"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:u("cliproxyPage.parentNotConnected")})]})})]}),e.jsx(I,{variant:"ghost",size:"icon",className:"h-6 w-6 opacity-0 group-hover:opacity-100 hover:text-destructive",onClick:o=>{o.stopPropagation(),i()},disabled:d,children:e.jsx(Fs,{className:"w-3 h-3"})})]})}function La({onSetup:s}){const{t}=se();return 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-muted flex items-center justify-center mx-auto mb-6",children:e.jsx(Ne,{className:"w-8 h-8 text-muted-foreground"})}),e.jsx("h2",{className:"text-xl font-semibold mb-2",children:t("cliproxyPage.emptyTitle")}),e.jsx("p",{className:"text-muted-foreground mb-4",children:t("cliproxyPage.emptyDesc")}),e.jsxs("p",{className:"text-xs text-muted-foreground mb-6",children:[t("cliproxyPage.emptyControlPanelPrefix")," ",e.jsx("a",{href:"/cliproxy/control-panel",className:"text-primary hover:underline",children:t("cliproxyPage.controlPanel")}),"."]}),e.jsxs(I,{onClick:s,className:"gap-2",children:[e.jsx(je,{className:"w-4 h-4"}),t("cliproxyPage.quickSetup")]})]})})}function en(){const{t:s}=se(),t=Ve(),{data:a,isLoading:n}=ws(),{data:i,isFetching:d}=Ct(),{data:u}=kt(),r=At(),o=St(),p=Pt(),f=Mt(),v=Dt(),g=Tt(),L=Et(),j=Ot(),[w,D]=c.useState(()=>{if(typeof window<"u"){const E=new URLSearchParams(window.location.search).get("provider")?.trim().toLowerCase();return E&&_e(E)?E:localStorage.getItem("cliproxy-selected-provider")}return null}),[b,N]=c.useState(null),[l,A]=c.useState(!1),[C,M]=c.useState(()=>{if(typeof window>"u")return null;const x=new URLSearchParams(window.location.search),E=x.get("provider")?.trim().toLowerCase();return x.get("action")!=="auth"||!E||!_e(E)?null:{provider:E,displayName:Rt(E),isFirstAccount:!1}}),m=c.useMemo(()=>a?.authStatus||[],[a?.authStatus]),S=a?.source==="remote",O=c.useMemo(()=>i?.variants||[],[i?.variants]),q=x=>{D(x),x&&localStorage.setItem("cliproxy-selected-provider",x)},h=c.useMemo(()=>b?null:w&&m.some(x=>x.provider===w)?w:m.length>0&&(m.find(E=>(E.accounts?.length||0)>0)?.provider||m[0]?.provider)||null,[w,b,m]),k=m.find(x=>x.provider===h),y=O.find(x=>x.name===b),F=y?m.find(x=>x.provider===y.provider):void 0,H=(y?.provider||k?.provider||"").toLowerCase().trim(),T=H==="gemini"||H==="agy",R=()=>{t.invalidateQueries({queryKey:["cliproxy"]}),t.invalidateQueries({queryKey:["cliproxy-auth"]})},K=(x,E,z)=>{p.isPending||f.isPending||(z?p.mutate({provider:x,accountId:E}):f.mutate({provider:x,accountId:E}))},V=(x,E)=>{v.isPending||v.mutate({provider:x,accountId:E})},te=(x,E)=>{g.isPending||g.mutate({provider:x,accountIds:E})},W=(x,E)=>{L.isPending||L.mutate({provider:x,accountIds:E})},ae=x=>{q(x),N(null)},Q=x=>{N(x),q(null)};return e.jsxs("div",{className:"flex h-full min-h-0 overflow-hidden",children:[e.jsxs("div",{className:"w-80 border-r flex flex-col bg-muted/30",children:[e.jsxs("div",{className:"p-4 border-b bg-background",children:[e.jsxs("div",{className:"flex items-center justify-between mb-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ne,{className:"w-5 h-5 text-primary"}),e.jsx("h1",{className:"font-semibold",children:u?.backendLabel??"CLIProxy"})]}),e.jsx(I,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:R,disabled:d,children:e.jsx(Ze,{className:B("w-4 h-4",d&&"animate-spin")})})]}),e.jsx("p",{className:"text-xs text-muted-foreground mb-3",children:s("cliproxyPage.accountManagement")}),e.jsxs(I,{variant:"default",size:"sm",className:"w-full gap-2",onClick:()=>A(!0),children:[e.jsx(je,{className:"w-4 h-4"}),s("cliproxyPage.quickSetup")]})]}),e.jsx(We,{className:"flex-1",children:e.jsxs("div",{className:"p-2",children:[e.jsx("div",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide px-3 py-2",children:s("cliproxyPage.providers")}),n?e.jsx("div",{className:"space-y-2 px-2",children:[1,2,3,4].map(x=>e.jsx(It,{className:"h-14 w-full rounded-lg"},x))}):e.jsx("div",{className:"space-y-1",children:m.map(x=>e.jsx(Ra,{status:x,isSelected:h===x.provider,onSelect:()=>ae(x.provider)},x.provider))}),O.length>0&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide px-3 py-2 mt-4 flex items-center gap-1.5",children:[e.jsx(Us,{className:"w-3 h-3"}),s("cliproxyPage.variants")]}),e.jsx("div",{className:"space-y-1",children:O.map(x=>e.jsx(Ia,{variant:x,parentAuth:m.find(E=>E.provider===x.provider),isSelected:b===x.name,onSelect:()=>Q(x.name),onDelete:()=>j.mutate(x.name),isDeleting:j.isPending},x.name))})]})]})}),e.jsx("div",{className:"p-3 border-t",children:e.jsx(Jt,{})}),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("cliproxyPage.providerCount",{count:m.length})}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(ue,{className:"w-3 h-3 text-green-600"}),s("cliproxyPage.connectedCount",{count:m.filter(x=>x.authenticated).length})]})]})})]}),e.jsxs("div",{className:"flex-1 flex flex-col min-w-0 bg-background",children:[T&&e.jsx(Vs,{showProxySettingsLink:!0,className:"mx-4 mt-4"}),y&&F?e.jsx(e.Fragment,{children:e.jsx(xs,{provider:y.name,displayName:s("cliproxyPage.variantDisplay",{name:y.name,provider:y.provider}),authStatus:F,catalog:pe[y.provider],logoProvider:y.provider,baseProvider:y.provider,defaultTarget:y.target,isRemoteMode:S,port:y.port,onAddAccount:()=>M({provider:y.provider,displayName:F.displayName,isFirstAccount:(F.accounts?.length||0)===0}),onSetDefault:x=>r.mutate({provider:y.provider,accountId:x}),onRemoveAccount:x=>o.mutate({provider:y.provider,accountId:x}),onPauseToggle:(x,E)=>K(y.provider,x,E),onSoloMode:x=>V(y.provider,x),onBulkPause:x=>te(y.provider,x),onBulkResume:x=>W(y.provider,x),isRemovingAccount:o.isPending,isPausingAccount:p.isPending||f.isPending,isSoloingAccount:v.isPending,isBulkPausing:g.isPending,isBulkResuming:L.isPending})}):k?e.jsx(e.Fragment,{children:e.jsx(xs,{provider:k.provider,displayName:k.displayName,authStatus:k,catalog:pe[k.provider],isRemoteMode:S,onAddAccount:()=>M({provider:k.provider,displayName:k.displayName,isFirstAccount:(k.accounts?.length||0)===0}),onSetDefault:x=>r.mutate({provider:k.provider,accountId:x}),onRemoveAccount:x=>o.mutate({provider:k.provider,accountId:x}),onPauseToggle:(x,E)=>K(k.provider,x,E),onSoloMode:x=>V(k.provider,x),onBulkPause:x=>te(k.provider,x),onBulkResume:x=>W(k.provider,x),isRemovingAccount:o.isPending,isPausingAccount:p.isPending||f.isPending,isSoloingAccount:v.isPending,isBulkPausing:g.isPending,isBulkResuming:L.isPending})}):e.jsx(La,{onSetup:()=>A(!0)})]}),e.jsx(la,{open:l,onClose:()=>A(!1)}),e.jsx(ha,{open:C!==null,onClose:()=>M(null),provider:C?.provider||"",displayName:C?.displayName||"",isFirstAccount:C?.isFirstAccount||!1})]})}export{en as CliproxyPage};
|