@kaitranntt/ccs 7.26.2-dev.3 → 7.26.3-dev.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/dist/cliproxy/account-manager.d.ts +28 -0
- package/dist/cliproxy/account-manager.d.ts.map +1 -1
- package/dist/cliproxy/account-manager.js +79 -1
- package/dist/cliproxy/account-manager.js.map +1 -1
- package/dist/cliproxy/quota-fetcher.d.ts.map +1 -1
- package/dist/cliproxy/quota-fetcher.js +57 -59
- package/dist/cliproxy/quota-fetcher.js.map +1 -1
- package/dist/ui/assets/{accounts-ClRO9xRe.js → accounts-BOzNq5ee.js} +1 -1
- package/dist/ui/assets/{alert-dialog-DFi20Kyu.js → alert-dialog-Cb5PMEBl.js} +1 -1
- package/dist/ui/assets/api-Dve5qAOP.js +1 -0
- package/dist/ui/assets/auth-section-Cpc5CmnT.js +1 -0
- package/dist/ui/assets/backups-section-DUZ2HR46.js +1 -0
- package/dist/ui/assets/cliproxy-DaYarYV8.js +3 -0
- package/dist/ui/assets/cliproxy-control-panel-D8brA7Zn.js +1 -0
- package/dist/ui/assets/confirm-dialog-0Zy9TN_K.js +1 -0
- package/dist/ui/assets/{copilot-CxS7F-wF.js → copilot-C2Q9oafS.js} +3 -3
- package/dist/ui/assets/globalenv-section-g_Bh1_Vi.js +1 -0
- package/dist/ui/assets/{health-DtEewGXR.js → health-BfdjLTeV.js} +1 -1
- package/dist/ui/assets/{icons-MT_USDDP.js → icons-C6UNjkCT.js} +1 -1
- package/dist/ui/assets/index-326cTntS.js +1 -0
- package/dist/ui/assets/index-B9LdCgpr.js +1 -0
- package/dist/ui/assets/index-C-e4p8-0.js +1 -0
- package/dist/ui/assets/index-CErLyTsQ.js +47 -0
- package/dist/ui/assets/index-DWVSWP6e.css +1 -0
- package/dist/ui/assets/{index-CWHCl8iV.js → index-DX32Yp2A.js} +1 -1
- package/dist/ui/assets/proxy-status-widget-BBhLPlDp.js +1 -0
- package/dist/ui/assets/radix-ui-qEZD5MMp.js +51 -0
- package/dist/ui/assets/{shared-Axa1XCh5.js → shared-ogUMuADx.js} +1 -1
- package/dist/ui/assets/{switch-D7uSKm8B.js → switch-DVMOWp74.js} +1 -1
- package/dist/ui/assets/{tanstack-ChZysrI1.js → tanstack-De4wvi8X.js} +1 -1
- package/dist/ui/index.html +5 -5
- package/dist/web-server/routes/account-routes.d.ts.map +1 -1
- package/dist/web-server/routes/account-routes.js +104 -2
- package/dist/web-server/routes/account-routes.js.map +1 -1
- package/package.json +1 -1
- package/dist/ui/assets/api-BpnXG9Bg.js +0 -1
- package/dist/ui/assets/auth-section-Dvxm2fKF.js +0 -1
- package/dist/ui/assets/backups-section-DRZ3sdMb.js +0 -1
- package/dist/ui/assets/cliproxy-DfCPAvnX.js +0 -3
- package/dist/ui/assets/cliproxy-control-panel-TVrFXe7F.js +0 -1
- package/dist/ui/assets/confirm-dialog-DRaXid8b.js +0 -1
- package/dist/ui/assets/globalenv-section-BAdk876f.js +0 -1
- package/dist/ui/assets/index-9iuiv2P7.js +0 -1
- package/dist/ui/assets/index-Bqpm7XFW.js +0 -47
- package/dist/ui/assets/index-BxW8t4Z6.js +0 -1
- package/dist/ui/assets/index-CRayOc33.css +0 -1
- package/dist/ui/assets/index-CtbouR3A.js +0 -1
- package/dist/ui/assets/proxy-status-widget-DNGPVCQ7.js +0 -1
- package/dist/ui/assets/radix-ui-DP8--cuX.js +0 -51
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{j as e}from"./radix-ui-DP8--cuX.js";import{r as t}from"./react-vendor-CNOkPC89.js";import{aK as J,aF as _,aH as Q,m as V,I as b,b as i}from"./index-Bqpm7XFW.js";import{a5 as K,$ as W,p as X,k as Y,E,d as A,j as T,l as I,aI as Z,_ as ee,R as se,ag as ae}from"./icons-MT_USDDP.js";import"./tanstack-ChZysrI1.js";import"./notifications-B2HqRBj7.js";import"./utils-CzKF5WmX.js";import"./form-utils-C-pVd1--.js";import"./code-highlight-BRUf_pqB.js";function ue(){const{fetchRawConfig:o}=J(),[a,P]=t.useState(null),[g,v]=t.useState(!0),[n,c]=t.useState(!1),[x,r]=t.useState(null),[p,f]=t.useState(null),[y,R]=t.useState(!1),[j,z]=t.useState(!1),[d,w]=t.useState(null),[m,N]=t.useState(null),[L,C]=t.useState(!1),[U,k]=t.useState(!1),u=t.useCallback(async()=>{try{v(!0),r(null);const s=await fetch("/api/settings/auth/tokens/raw");if(!s.ok)throw new Error("Failed to fetch auth tokens");const l=await s.json();P(l)}catch(s){r(s instanceof Error?s.message:"Unknown error")}finally{v(!1)}},[]);t.useEffect(()=>{u(),o()},[u,o]),t.useEffect(()=>{if(p){const s=setTimeout(()=>f(null),3e3);return()=>clearTimeout(s)}},[p]),t.useEffect(()=>{if(x){const s=setTimeout(()=>r(null),5e3);return()=>clearTimeout(s)}},[x]);const F=async()=>{const s=d!==null&&d!==a?.apiKey.value,l=m!==null&&m!==a?.managementSecret.value;if(!(!s&&!l))try{c(!0),r(null);const h={};s&&(h.apiKey=d),l&&(h.managementSecret=m);const S=await fetch("/api/settings/auth/tokens",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(h)});if(!S.ok){const H=await S.json();throw new Error(H.error||"Failed to save tokens")}f("Tokens updated. Restart CLIProxy to apply."),w(null),N(null),await u(),await o()}catch(h){r(h instanceof Error?h.message:"Unknown error")}finally{c(!1)}},O=async()=>{try{c(!0),r(null);const s=await fetch("/api/settings/auth/tokens/regenerate-secret",{method:"POST"});if(!s.ok){const l=await s.json();throw new Error(l.error||"Failed to regenerate secret")}f("New management secret generated. Restart CLIProxy to apply."),await u(),await o()}catch(s){r(s instanceof Error?s.message:"Unknown error")}finally{c(!1)}},$=async()=>{try{c(!0),r(null);const s=await fetch("/api/settings/auth/tokens/reset",{method:"POST"});if(!s.ok){const l=await s.json();throw new Error(l.error||"Failed to reset tokens")}f("Tokens reset to defaults. Restart CLIProxy to apply."),w(null),N(null),await u(),await o()}catch(s){r(s instanceof Error?s.message:"Unknown error")}finally{c(!1)}},D=async()=>{a&&(await navigator.clipboard.writeText(a.apiKey.value),C(!0),setTimeout(()=>C(!1),2e3))},M=async()=>{a&&(await navigator.clipboard.writeText(a.managementSecret.value),k(!0),setTimeout(()=>k(!1),2e3))};if(g||!a)return e.jsx("div",{className:"flex-1 flex items-center justify-center",children:e.jsxs("div",{className:"flex items-center gap-3 text-muted-foreground",children:[e.jsx(K,{className:"w-5 h-5 animate-spin"}),e.jsx("span",{children:"Loading..."})]})});const q=d??a.apiKey.value,B=m??a.managementSecret.value,G=d!==null&&d!==a.apiKey.value||m!==null&&m!==a.managementSecret.value;return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:`absolute left-5 right-5 top-20 z-10 transition-all duration-200 ease-out ${x||p?"opacity-100 translate-y-0":"opacity-0 -translate-y-2 pointer-events-none"}`,children:[x&&e.jsxs(_,{variant:"destructive",className:"py-2 shadow-lg",children:[e.jsx(W,{className:"h-4 w-4"}),e.jsx(Q,{children:x})]}),p&&e.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 rounded-md border border-green-200 bg-green-50 text-green-700 shadow-lg dark:border-green-900/50 dark:bg-green-900/90 dark:text-green-300",children:[e.jsx(X,{className:"h-4 w-4 shrink-0"}),e.jsx("span",{className:"text-sm font-medium",children:p})]})]}),e.jsx(V,{className:"flex-1",children:e.jsxs("div",{className:"p-5 space-y-6",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Configure CLIProxy authentication tokens. Changes require CLIProxy restart."}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Y,{className:"w-4 h-4 text-primary"}),e.jsx("h3",{className:"text-base font-medium",children:"API Key"}),a.apiKey.isCustom&&e.jsx("span",{className:"text-xs px-2 py-0.5 rounded bg-amber-100 text-amber-700 dark:bg-amber-900/50 dark:text-amber-300",children:"Custom"})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Used by Claude Code to authenticate with CLIProxy"}),e.jsx("div",{className:"flex gap-2",children:e.jsxs("div",{className:"relative flex-1",children:[e.jsx(b,{type:y?"text":"password",value:q,onChange:s=>w(s.target.value),placeholder:"API key",disabled:n,className:"pr-20 font-mono text-sm"}),e.jsxs("div",{className:"absolute right-2 top-1/2 -translate-y-1/2 flex gap-1",children:[e.jsx(i,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0",onClick:()=>R(!y),children:y?e.jsx(E,{className:"w-4 h-4"}):e.jsx(A,{className:"w-4 h-4"})}),e.jsx(i,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0",onClick:D,disabled:!a.apiKey.value,children:L?e.jsx(T,{className:"w-4 h-4 text-green-600"}):e.jsx(I,{className:"w-4 h-4"})})]})]})})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Z,{className:"w-4 h-4 text-primary"}),e.jsx("h3",{className:"text-base font-medium",children:"Management Secret"}),a.managementSecret.isCustom&&e.jsx("span",{className:"text-xs px-2 py-0.5 rounded bg-amber-100 text-amber-700 dark:bg-amber-900/50 dark:text-amber-300",children:"Custom"})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Used by CCS dashboard to access CLIProxy management APIs"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(b,{type:j?"text":"password",value:B,onChange:s=>N(s.target.value),placeholder:"Management secret",disabled:n,className:"pr-20 font-mono text-sm"}),e.jsxs("div",{className:"absolute right-2 top-1/2 -translate-y-1/2 flex gap-1",children:[e.jsx(i,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0",onClick:()=>z(!j),children:j?e.jsx(E,{className:"w-4 h-4"}):e.jsx(A,{className:"w-4 h-4"})}),e.jsx(i,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0",onClick:M,disabled:!a.managementSecret.value,children:U?e.jsx(T,{className:"w-4 h-4 text-green-600"}):e.jsx(I,{className:"w-4 h-4"})})]})]}),e.jsx(i,{variant:"outline",size:"sm",onClick:O,disabled:n,title:"Generate new secure secret",children:e.jsx(ee,{className:"w-4 h-4"})})]})]}),e.jsxs("div",{className:"pt-4 border-t",children:[e.jsxs(i,{variant:"outline",size:"sm",onClick:$,disabled:n||!a.apiKey.isCustom&&!a.managementSecret.isCustom,className:"gap-2",children:[e.jsx(se,{className:"w-4 h-4"}),"Reset to Defaults"]}),e.jsx("p",{className:"text-xs text-muted-foreground mt-2",children:"Resets both API key and management secret to their default values."})]})]})}),e.jsxs("div",{className:"p-4 border-t bg-background flex gap-2",children:[e.jsxs(i,{variant:"outline",size:"sm",onClick:()=>{u(),o()},disabled:g||n,className:"flex-1",children:[e.jsx(K,{className:`w-4 h-4 mr-2 ${g?"animate-spin":""}`}),"Refresh"]}),e.jsxs(i,{variant:"default",size:"sm",onClick:F,disabled:!G||n,className:"flex-1",children:[e.jsx(ae,{className:`w-4 h-4 mr-2 ${n?"animate-pulse":""}`}),n?"Saving...":"Save"]})]})]})}export{ue as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{j as e}from"./radix-ui-DP8--cuX.js";import{r as t}from"./react-vendor-CNOkPC89.js";import{aK as R,m as b,S as a,C as f,aF as S,aH as E,B as D,b as y}from"./index-Bqpm7XFW.js";import{A as B,a as T,b as F,c as O,d as _,e as U,f as I,g as L}from"./alert-dialog-DFi20Kyu.js";import{$,p as z,a3 as k,s as P,R as H,a5 as M}from"./icons-MT_USDDP.js";import"./tanstack-ChZysrI1.js";import"./notifications-B2HqRBj7.js";import"./utils-CzKF5WmX.js";import"./form-utils-C-pVd1--.js";import"./code-highlight-BRUf_pqB.js";const Y=3e3,J=5e3;function te(){const{fetchRawConfig:x}=R(),c=t.useRef(null),m=t.useRef(null),[j,v]=t.useState([]),[h,g]=t.useState(!0),[d,N]=t.useState(null),[n,l]=t.useState(null),[i,w]=t.useState(null),[u,p]=t.useState(null),o=t.useCallback(async()=>{c.current?.abort(),c.current=new AbortController;try{g(!0),l(null);const s=await fetch("/api/persist/backups",{signal:c.current.signal});if(!s.ok)throw new Error("Failed to fetch backups");const r=await s.json();v(r.backups||[])}catch(s){if(s instanceof Error&&s.name==="AbortError")return;l(s instanceof Error?s.message:"Unknown error")}finally{g(!1)}},[]),C=t.useCallback(async s=>{m.current?.abort(),m.current=new AbortController;try{N(s),l(null);const r=await fetch("/api/persist/restore",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({timestamp:s}),signal:m.current.signal});if(!r.ok){const A=await r.json();throw new Error(A.error||"Failed to restore backup")}w("Backup restored successfully"),await o(),await x()}catch(r){if(r instanceof Error&&r.name==="AbortError")return;l(r instanceof Error?r.message:"Unknown error")}finally{N(null)}},[o,x]);return t.useEffect(()=>{o()},[o]),t.useEffect(()=>()=>{c.current?.abort(),m.current?.abort()},[]),t.useEffect(()=>{if(i){const s=setTimeout(()=>w(null),Y);return()=>clearTimeout(s)}},[i]),t.useEffect(()=>{if(n){const s=setTimeout(()=>l(null),J);return()=>clearTimeout(s)}},[n]),h?e.jsxs(e.Fragment,{children:[e.jsx(b,{className:"flex-1",children:e.jsxs("div",{className:"p-5 space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(a,{className:"h-6 w-40"}),e.jsx(a,{className:"h-4 w-full"})]}),[1,2,3].map(s=>e.jsx(f,{className:"p-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-2 flex-1",children:[e.jsx(a,{className:"h-4 w-32"}),e.jsx(a,{className:"h-3 w-48"})]}),e.jsx(a,{className:"h-8 w-20"})]})},s))]})}),e.jsx("div",{className:"p-4 border-t bg-background",children:e.jsx(a,{className:"h-9 w-full"})})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:`absolute left-5 right-5 top-20 z-10 transition-all duration-200 ease-out ${n||i?"opacity-100 translate-y-0":"opacity-0 -translate-y-2 pointer-events-none"}`,children:[n&&e.jsxs(S,{variant:"destructive",className:"py-2 shadow-lg",children:[e.jsx($,{className:"h-4 w-4"}),e.jsx(E,{children:n})]}),i&&e.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 rounded-md border border-green-200 bg-green-50 text-green-700 shadow-lg dark:border-green-900/50 dark:bg-green-900/90 dark:text-green-300",children:[e.jsx(z,{className:"h-4 w-4 shrink-0"}),e.jsx("span",{className:"text-sm font-medium",children:i})]})]}),e.jsx(b,{className:"flex-1",children:e.jsxs("div",{className:"p-5 space-y-4",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(k,{className:"w-5 h-5 text-primary"}),e.jsx("h2",{className:"text-lg font-semibold",children:"Settings Backups"})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Restore previous versions of your settings.json file. Backups are created automatically when settings are modified."})]}),j.length===0?e.jsx(f,{className:"p-8",children:e.jsxs("div",{className:"text-center",children:[e.jsx(k,{className:"w-12 h-12 mx-auto mb-3 opacity-30 text-muted-foreground"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"No backups available"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Backups will appear here when you modify settings"})]})}):e.jsx("div",{className:"space-y-2",children:j.map((s,r)=>e.jsx(f,{className:"p-4 hover:bg-muted/50 transition-colors",children:e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsxs("div",{className:"flex items-start gap-3 flex-1 min-w-0",children:[e.jsx(P,{className:"w-4 h-4 text-muted-foreground mt-0.5 shrink-0"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("p",{className:"text-sm font-medium font-mono",children:s.timestamp}),r===0&&e.jsx(D,{variant:"secondary",className:"text-xs",children:"Latest"})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:s.date})]})]}),e.jsxs(y,{variant:"outline",size:"sm",onClick:()=>p(s.timestamp),disabled:d!==null,className:"gap-2 shrink-0",children:[e.jsx(H,{className:`w-4 h-4 ${d===s.timestamp?"animate-spin":""}`}),d===s.timestamp?"Restoring...":"Restore"]})]})},s.timestamp))})]})}),e.jsx("div",{className:"p-4 border-t bg-background",children:e.jsxs(y,{variant:"outline",size:"sm",onClick:()=>{o(),x()},disabled:h||d!==null,className:"w-full",children:[e.jsx(M,{className:`w-4 h-4 mr-2 ${h?"animate-spin":""}`}),"Refresh"]})}),e.jsx(B,{open:!!u,onOpenChange:()=>p(null),children:e.jsxs(T,{children:[e.jsxs(F,{children:[e.jsx(O,{children:"Restore Backup?"}),e.jsxs(_,{children:["This will replace your current settings with backup from"," ",e.jsx("code",{className:"font-mono bg-muted px-1.5 py-0.5 rounded text-foreground",children:u}),". This action cannot be undone."]})]}),e.jsxs(U,{children:[e.jsx(I,{children:"Cancel"}),e.jsx(L,{onClick:()=>{u&&C(u),p(null)},children:"Restore"})]})]})})]})}export{te as default};
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import{j as e}from"./radix-ui-DP8--cuX.js";import{r as h}from"./react-vendor-CNOkPC89.js";import{a as Re,u as Fe,b as us}from"./tanstack-ChZysrI1.js";import{b as v,C as He,a as Ue,c as O,P as ee,L as se,I as ue,X as Ge,Y as Ke,Z as qe,_ as $e,$ as ce,a0 as Ve,a1 as xs,a2 as Qe,a3 as ze,u as Be,a4 as xe,a5 as pe,a6 as he,a7 as ge,a8 as Je,a9 as ps,aa as Me,ab as Te,B as D,ac as hs,q as We,m as fe,l as gs,ad as fs,ae as js,af as vs,ag as J,T as W,o as Y,p as X,ah as Ns,ai as ws,aj as ys,ak as ie,al as Cs,am as bs,an as ks,ao as re,ap as As,aq as Ss,ar as Ps,as as Ms,H as Ts,J as Os,K as Oe,M as De,at as Ds,au as _s,av as Es,aw as Is,ax as Ls,ay as Rs,az as Fs,aA as Hs,S as Us}from"./index-Bqpm7XFW.js";import{t as L}from"./notifications-B2HqRBj7.js";import{b as Ye,L as $,m as je,w as Gs,j as V,l as Ks,am as ve,a5 as Ne,n as Q,_ as B,an as qs,ao as te,Z as ae,I as $s,f as Vs,a0 as Xe,ap as Qs,ag as zs,X as we,Y as Ze,t as _e,aq as Bs,T as Js,s as oe,ar as Ws,as as Ys,af as es,p as Xs,at as Zs,$ as et,aj as st,au as ss}from"./icons-MT_USDDP.js";import{S as ye,C as tt}from"./confirm-dialog-DRaXid8b.js";import{S as at}from"./switch-D7uSKm8B.js";import{P as nt}from"./proxy-status-widget-DNGPVCQ7.js";import"./utils-CzKF5WmX.js";import"./form-utils-C-pVd1--.js";import"./code-highlight-BRUf_pqB.js";import"./alert-dialog-DFi20Kyu.js";const z={agy:{provider:"agy",displayName:"Antigravity",defaultModel:"gemini-claude-opus-4-5-thinking",models:[{id:"gemini-claude-opus-4-5-thinking",name:"Claude Opus 4.5 Thinking",description:"Most capable, extended thinking",presetMapping:{default:"gemini-claude-opus-4-5-thinking",opus:"gemini-claude-opus-4-5-thinking",sonnet:"gemini-claude-sonnet-4-5-thinking",haiku:"gemini-claude-sonnet-4-5"}},{id:"gemini-claude-sonnet-4-5-thinking",name:"Claude Sonnet 4.5 Thinking",description:"Balanced with extended thinking",presetMapping:{default:"gemini-claude-sonnet-4-5-thinking",opus:"gemini-claude-opus-4-5-thinking",sonnet:"gemini-claude-sonnet-4-5-thinking",haiku:"gemini-claude-sonnet-4-5"}},{id:"gemini-claude-sonnet-4-5",name:"Claude Sonnet 4.5",description:"Fast and capable",presetMapping:{default:"gemini-claude-sonnet-4-5",opus:"gemini-claude-opus-4-5-thinking",sonnet:"gemini-claude-sonnet-4-5",haiku:"gemini-claude-sonnet-4-5"}},{id:"gemini-3-pro-preview",name:"Gemini 3 Pro",description:"Google latest model via Antigravity",presetMapping:{default:"gemini-3-pro-preview",opus:"gemini-3-pro-preview",sonnet:"gemini-3-pro-preview",haiku:"gemini-3-flash-preview"}},{id:"gemini-3-flash-preview",name:"Gemini 3 Flash",description:"Fast Gemini model via Antigravity",presetMapping:{default:"gemini-3-flash-preview",opus:"gemini-3-pro-preview",sonnet:"gemini-3-pro-preview",haiku:"gemini-3-flash-preview"}}]},gemini:{provider:"gemini",displayName:"Gemini",defaultModel:"gemini-2.5-pro",models:[{id:"gemini-3-pro-preview",name:"Gemini 3 Pro",tier:"paid",description:"Latest model, requires paid Google account",presetMapping:{default:"gemini-3-pro-preview",opus:"gemini-3-pro-preview",sonnet:"gemini-3-pro-preview",haiku:"gemini-3-flash-preview"}},{id:"gemini-3-flash-preview",name:"Gemini 3 Flash",tier:"paid",description:"Fast Gemini 3 model, requires paid Google account",presetMapping:{default:"gemini-3-flash-preview",opus:"gemini-3-pro-preview",sonnet:"gemini-3-pro-preview",haiku:"gemini-3-flash-preview"}},{id:"gemini-2.5-pro",name:"Gemini 2.5 Pro",description:"Stable, works with free Google account",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.2-codex",models:[{id:"gpt-5.2-codex",name:"GPT-5.2 Codex",description:"Full reasoning support (xhigh)",presetMapping:{default:"gpt-5.2-codex",opus:"gpt-5.2-codex",sonnet:"gpt-5.2-codex",haiku:"gpt-5-mini"}},{id:"gpt-5-mini",name:"GPT-5 Mini",description:"Fast, capped at high reasoning (no xhigh)",presetMapping:{default:"gpt-5-mini",opus:"gpt-5.2-codex",sonnet:"gpt-5-mini",haiku:"gpt-5-mini"}},{id:"gpt-5.1-codex-max",name:"Codex Max (5.1)",description:"Legacy most capable Codex model",presetMapping:{default:"gpt-5.1-codex-max",opus:"gpt-5.1-codex-max-high",sonnet:"gpt-5.1-codex-max",haiku:"gpt-5.1-codex-mini-high"}},{id:"gpt-5.2",name:"GPT 5.2",description:"Latest GPT model",presetMapping:{default:"gpt-5.2",opus:"gpt-5.2",sonnet:"gpt-5.2",haiku:"gpt-5.2"}},{id:"gpt-5.1-codex-mini",name:"Codex Mini",description:"Fast and efficient Codex model"}]},qwen:{provider:"qwen",displayName:"Qwen",defaultModel:"qwen-coder-plus",models:[{id:"qwen-coder-plus",name:"Qwen Coder Plus",description:"Alibaba code-focused model"},{id:"qwen-max",name:"Qwen Max",description:"Most capable Qwen model"}]},iflow:{provider:"iflow",displayName:"iFlow",defaultModel:"iflow-default",models:[{id:"iflow-default",name:"iFlow Default",description:"Default iFlow model"}]},kiro:{provider:"kiro",displayName:"Kiro (AWS)",defaultModel:"kiro-claude-sonnet-4-5",models:[{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"}]}},de=8317,le="ccs-internal-managed";async function it(){try{const s=await fetch("/api/settings/auth/tokens/raw");return s.ok?(await s.json())?.apiKey?.value??le:le}catch{return le}}async function me(s,a){const t=z[s];if(!t)return{success:!1};const n=t.models[0],i=n?.presetMapping||{default:t.defaultModel,opus:t.defaultModel,sonnet:t.defaultModel,haiku:t.defaultModel},l=await it(),u={env:{ANTHROPIC_BASE_URL:`http://127.0.0.1:${de}/api/provider/${s}`,ANTHROPIC_AUTH_TOKEN:l,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:u})})).ok,presetName:n?.name||t.defaultModel}}catch{return{success:!1}}}const Ee=[{id:"gemini",name:"Google Gemini",description:"Gemini Pro/Flash models"},{id:"codex",name:"OpenAI Codex",description:"GPT-4 and codex models"},{id:"agy",name:"Antigravity",description:"Antigravity AI models"},{id:"qwen",name:"Alibaba Qwen",description:"Qwen Code models"},{id:"iflow",name:"iFlow",description:"iFlow AI models"},{id:"kiro",name:"Kiro (AWS)",description:"AWS CodeWhisperer models"},{id:"ghcp",name:"GitHub Copilot (OAuth)",description:"GitHub Copilot via OAuth"}],ts=["provider","auth","variant","success"];function rt(s){return s==="account"?1:ts.indexOf(s)}function ot({currentProgress:s,allSteps:a}){return e.jsx("div",{className:"flex justify-center gap-1 pt-2",children:a.map((t,n)=>e.jsx("div",{className:`w-2 h-2 rounded-full transition-colors ${s>=n?"bg-primary":"bg-muted"}`},t))})}function lt({providers:s,onSelect:a}){return e.jsx("div",{className:"grid gap-2",children:s.map(t=>e.jsxs("button",{onClick:()=>a(t.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:t.name}),e.jsx("div",{className:"text-xs text-muted-foreground",children:t.description})]}),e.jsx(Ye,{className:"w-4 h-4 text-muted-foreground"})]},t.id))})}function ct({selectedProvider:s,providers:a,authCommand:t,isRefreshing:n,isPending:i,onBack:l,onStartAuth:c,onRefresh:u}){const[r,d]=h.useState(!1),g=async x=>{await navigator.clipboard.writeText(x),d(!0),setTimeout(()=>d(!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 ",a.find(x=>x.id===s)?.name," to add an account"]}),e.jsx(v,{onClick:c,disabled:i,className:"w-full gap-2",size:"lg",children:i?e.jsxs(e.Fragment,{children:[e.jsx($,{className:"w-4 h-4 animate-spin"}),"Authenticating..."]}):e.jsxs(e.Fragment,{children:[e.jsx(je,{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(He,{children:e.jsxs(Ue,{className:"p-4 space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(Gs,{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:t}),e.jsx(v,{variant:"outline",size:"icon",onClick:()=>g(t),children:r?e.jsx(V,{className:"w-4 h-4 text-green-500"}):e.jsx(Ks,{className:"w-4 h-4"})})]})]})}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(v,{variant:"ghost",onClick:l,disabled:i,children:[e.jsx(ve,{className:"w-4 h-4 mr-2"}),"Back"]}),e.jsxs(v,{variant:"outline",onClick:u,disabled:n||i,children:[e.jsx(Ne,{className:`w-4 h-4 mr-2 ${n?"animate-spin":""}`}),n?"Checking...":"Refresh Status"]})]})]})}function dt({accounts:s,privacyMode:a,onSelect:t,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",children:s.map(l=>e.jsxs("button",{type:"button",onClick:()=>t(l),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(Q,{className:"w-4 h-4 text-muted-foreground"})}),e.jsxs("div",{children:[e.jsx("div",{className:O("font-medium",a&&ee),children:l.email||l.id}),l.isDefault&&e.jsx("div",{className:"text-xs text-muted-foreground",children:"Default account"})]})]}),e.jsx(Ye,{className:"w-4 h-4 text-muted-foreground"})]},l.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(je,{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(v,{variant:"ghost",onClick:i,children:[e.jsx(ve,{className:"w-4 h-4 mr-2"}),"Back"]})})]})}function mt({selectedProvider:s,selectedAccount:a,variantName:t,modelName:n,isPending:i,privacyMode:l,onVariantNameChange:c,onModelChange:u,onBack:r,onSkip:d,onCreate:g}){return e.jsxs("div",{className:"space-y-4",children:[a&&e.jsxs("div",{className:"flex items-center gap-2 p-2 bg-muted/50 rounded-md text-sm",children:[e.jsx(Q,{className:"w-4 h-4"}),e.jsxs("span",{children:["Using:"," ",e.jsx("span",{className:O(l&&ee),children:a.email||a.id})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(se,{htmlFor:"variant-name",children:"Variant Name *"}),e.jsx(ue,{id:"variant-name",value:t,onChange:x=>c(x.target.value),placeholder:"e.g., my-gemini, g3, flash"}),e.jsxs("div",{className:"text-xs text-muted-foreground",children:["Use this name to invoke: ccs ",t||"<name>",' "prompt"']})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(se,{children:"Model"}),e.jsxs(Ge,{value:n,onValueChange:u,children:[e.jsx(Ke,{children:e.jsx(qe,{placeholder:"Select a model"})}),e.jsx($e,{children:z[s]?.models.map(x=>e.jsx(ce,{value:x.id,children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{children:x.name}),x.description&&e.jsxs("span",{className:"text-xs text-muted-foreground",children:["- ",x.description]})]})},x.id))})]}),e.jsxs("div",{className:"text-xs text-muted-foreground",children:["Default: ",z[s]?.defaultModel||"provider default"]})]}),e.jsxs("div",{className:"flex items-center justify-between pt-2",children:[e.jsxs(v,{variant:"ghost",onClick:r,children:[e.jsx(ve,{className:"w-4 h-4 mr-2"}),"Back"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(v,{variant:"ghost",onClick:d,children:"Skip"}),e.jsx(v,{onClick:g,disabled:!t||i,children:i?"Creating...":"Create Variant"})]})]}),e.jsx("p",{className:"text-xs text-center text-muted-foreground",children:"Skip if you just wanted to add an account without creating a variant"})]})}function ut({variantName:s,onClose:a}){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(V,{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(He,{children:e.jsxs(Ue,{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(v,{onClick:a,className:"w-full",children:"Done"})]})}function xt({open:s,onClose:a}){const[t,n]=h.useState("provider"),[i,l]=h.useState(""),[c,u]=h.useState(null),[r,d]=h.useState(""),[g,x]=h.useState(""),[f,o]=h.useState(!1),[N,b]=h.useState(!1),{data:w,refetch:P}=Ve(),T=xs(),y=Qe(),I=ze(),{privacyMode:_}=Be(),A=w?.authStatus.find(j=>j.provider===i),C=h.useMemo(()=>A?.accounts||[],[A?.accounts]);h.useEffect(()=>{if(!s){const j=setTimeout(()=>{n("provider"),l(""),u(null),d(""),x(""),b(!1)},0);return()=>clearTimeout(j)}},[s]),h.useEffect(()=>{if(t==="auth"&&C.length>0&&!N){const j=setTimeout(()=>{n("account")},0);return()=>clearTimeout(j)}},[t,C,N]);const p=async()=>{o(!0),await P(),o(!1)},k=()=>{const j=(A?.accounts?.length||0)===0;y.mutate({provider:i},{onSuccess:async U=>{if(j){const G=await me(i);G.success&&G.presetName?L.success(`Applied "${G.presetName}" preset`):G.success||L.warning("Account added, but failed to apply default preset")}U.account&&(u(U.account),n("variant")),P()}})},E=j=>{l(j),(w?.authStatus.find(ne=>ne.provider===j)?.accounts||[]).length===0?n("auth"):n("account")},R=j=>{u(j),n("variant")},H=async()=>{if(!(!r||!i))try{await T.mutateAsync({name:r,provider:i,model:g||void 0,account:c?.id}),n("success")}catch(j){console.error("Failed to create variant:",j)}},F=`ccs ${i} --auth --add`,m=rt(t),S=j=>{if(!j&&(y.isPending&&i&&I.mutate(i),t==="success"||t==="provider")){a();return}};return e.jsx(xe,{open:s,onOpenChange:S,children:e.jsxs(pe,{className:"sm:max-w-lg",onPointerDownOutside:j=>{t!=="success"&&t!=="provider"&&j.preventDefault()},onEscapeKeyDown:j=>{(y.isPending||T.isPending)&&j.preventDefault()},children:[e.jsxs(he,{children:[e.jsxs(ge,{className:"flex items-center gap-2",children:[e.jsx(B,{className:"w-5 h-5 text-primary"}),"Quick Setup Wizard"]}),e.jsxs(Je,{children:[t==="provider"&&"Select a provider to get started",t==="auth"&&"Authenticate with your provider",t==="account"&&"Select which account to use",t==="variant"&&"Create your custom variant",t==="success"&&"Setup complete!"]})]}),e.jsxs("div",{className:"space-y-4 py-4",children:[t==="provider"&&e.jsx(lt,{providers:Ee,onSelect:E}),t==="auth"&&e.jsx(ct,{selectedProvider:i,providers:Ee,authCommand:F,isRefreshing:f,isPending:y.isPending,onBack:()=>n("provider"),onStartAuth:k,onRefresh:p}),t==="account"&&e.jsx(dt,{accounts:C,privacyMode:_,onSelect:R,onAddNew:()=>{b(!0),n("auth")},onBack:()=>n("provider")}),t==="variant"&&e.jsx(mt,{selectedProvider:i,selectedAccount:c,variantName:r,modelName:g,isPending:T.isPending,privacyMode:_,onVariantNameChange:d,onModelChange:x,onBack:()=>C.length>0?n("account"):n("provider"),onSkip:a,onCreate:H}),t==="success"&&e.jsx(ut,{variantName:r,onClose:a})]}),e.jsx(ot,{currentProgress:m,allSteps:ts})]})})}function pt({open:s,onClose:a,provider:t,displayName:n,isFirstAccount:i=!1}){const[l,c]=h.useState(""),u=Qe(),r=ps(),d=ze(),g=t==="kiro",x=u.isPending||r.isPending,f=()=>{x&&d.mutate(t),c(""),a()},o=()=>{u.mutate({provider:t,nickname:l.trim()||void 0},{onSuccess:async()=>{const w=await me(t);w.success&&w.presetName?i&&L.success(`Applied "${w.presetName}" preset`):w.success||L.warning("Account added, but failed to apply default preset. You may need to configure settings manually."),c(""),a()}})},N=()=>{r.mutate(void 0,{onSuccess:async()=>{const w=await me("kiro");w.success&&w.presetName&&i&&L.success(`Applied "${w.presetName}" preset`),c(""),a()}})},b=w=>{w||f()};return e.jsx(xe,{open:s,onOpenChange:b,children:e.jsxs(pe,{className:"sm:max-w-md",children:[e.jsxs(he,{children:[e.jsxs(ge,{children:["Add ",n," Account"]}),e.jsx(Je,{children:g?"Authenticate via browser or import an existing token from Kiro IDE.":"Click the button below to authenticate a new account. A browser window will open for OAuth."})]}),e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(se,{htmlFor:"nickname",children:"Nickname (optional)"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Q,{className:"w-4 h-4 text-muted-foreground"}),e.jsx(ue,{id:"nickname",value:l,onChange:w=>c(w.target.value),placeholder:"e.g., work, personal",disabled:x,className:"flex-1"})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"A friendly name to identify this account. Auto-generated from email if left empty."})]}),e.jsxs("div",{className:"flex items-center justify-end gap-2 pt-2",children:[e.jsx(v,{variant:"ghost",onClick:f,children:"Cancel"}),g&&e.jsx(v,{variant:"outline",onClick:N,disabled:x,children:r.isPending?e.jsxs(e.Fragment,{children:[e.jsx($,{className:"w-4 h-4 mr-2 animate-spin"}),"Importing..."]}):e.jsxs(e.Fragment,{children:[e.jsx(qs,{className:"w-4 h-4 mr-2"}),"Import from IDE"]})}),e.jsx(v,{onClick:o,disabled:x,children:u.isPending?e.jsxs(e.Fragment,{children:[e.jsx($,{className:"w-4 h-4 mr-2 animate-spin"}),"Authenticating..."]}):e.jsxs(e.Fragment,{children:[e.jsx(je,{className:"w-4 h-4 mr-2"}),"Authenticate"]})})]}),u.isPending&&e.jsx("p",{className:"text-sm text-center text-muted-foreground",children:"Complete the OAuth flow in your browser..."}),r.isPending&&e.jsx("p",{className:"text-sm text-center text-muted-foreground",children:"Importing token from Kiro IDE..."})]})]})})}const ht=["ANTHROPIC_BASE_URL","ANTHROPIC_AUTH_TOKEN"];function gt(s){const a=s?.env||{};return ht.filter(t=>!a[t]?.trim())}function ft(s){const[a,t]=h.useState(null),[n,i]=h.useState(!1),l=Re(),{data:c,isLoading:u,refetch:r}=Fe({queryKey:["settings",s],queryFn:async()=>{const p=await fetch(`/api/settings/${s}/raw`);return p.ok?p.json():{profile:s,settings:{env:{}},mtime:Date.now(),path:`~/.ccs/profiles/${s}/settings.json`}}}),d=c?.settings,g=h.useMemo(()=>a!==null?a:d?JSON.stringify(d,null,2):`{
|
|
2
|
-
"env": {}
|
|
3
|
-
}`,[a,d]),x=h.useCallback(p=>{t(p)},[]),f=h.useMemo(()=>{try{return JSON.parse(g)}catch{return d||{env:{}}}},[g,d]),o=f?.env?.ANTHROPIC_MODEL,N=f?.env?.ANTHROPIC_DEFAULT_OPUS_MODEL,b=f?.env?.ANTHROPIC_DEFAULT_SONNET_MODEL,w=f?.env?.ANTHROPIC_DEFAULT_HAIKU_MODEL,P=h.useCallback((p,k)=>{const E={...f?.env||{},[p]:k},R={...f,env:E};t(JSON.stringify(R,null,2))},[f]),T=h.useCallback(p=>{const k={...f?.env||{},...p},E={...f,env:k};t(JSON.stringify(E,null,2))},[f]),y=h.useMemo(()=>{try{return JSON.parse(g),!0}catch{return!1}},[g]),I=h.useMemo(()=>a===null?!1:a!==JSON.stringify(d,null,2),[a,d]),_=h.useMemo(()=>gt(f),[f]),A=us({mutationFn:async()=>{const p=JSON.parse(g),k=await fetch(`/api/settings/${s}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({settings:p,expectedMtime:c?.mtime})});if(k.status===409)throw new Error("CONFLICT");if(!k.ok)throw new Error("Failed to save");return k.json()},onSuccess:p=>{l.invalidateQueries({queryKey:["settings",s]}),t(null),p?.warning?L.success("Settings saved",{description:p.warning}):L.success("Settings saved")},onError:p=>{p.message==="CONFLICT"?i(!0):L.error(p.message)}}),C=async p=>{i(!1),p?(await r(),A.mutate()):t(null)};return{data:c,isLoading:u,refetch:r,rawJsonContent:g,rawJsonEdits:a,isRawJsonValid:y,hasChanges:I,currentSettings:f,currentModel:o,opusModel:N,sonnetModel:b,haikuModel:w,handleRawJsonChange:x,updateEnvValue:P,updateEnvValues:T,saveMutation:{mutate:()=>A.mutate(),isPending:A.isPending},conflictDialog:n,setConflictDialog:i,handleConflictResolve:C,missingRequiredFields:_}}function q({label:s,description:a,value:t,onChange:n,catalog:i,allModels:l,disabled:c}){const u=new Set(i?.models.map(r=>r.id)||[]);return e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-medium",children:s}),a&&e.jsx("p",{className:"text-[10px] text-muted-foreground",children:a})]}),e.jsxs(Ge,{value:t||"",onValueChange:n,disabled:c,children:[e.jsx(Ke,{className:"h-9",children:e.jsx(qe,{placeholder:"Select model",children:t&&e.jsx("span",{className:"truncate font-mono text-xs",children:t})})}),e.jsxs($e,{className:"max-h-[300px]",children:[i&&i.models.length>0&&e.jsxs(Me,{children:[e.jsx(Te,{className:"text-xs text-primary",children:"Recommended"}),i.models.map(r=>e.jsx(ce,{value:r.id,children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"truncate font-mono text-xs",children:r.id}),r.tier==="paid"&&e.jsx(D,{variant:"outline",className:"text-[9px] h-4 px-1",children:"PAID"}),t===r.id&&e.jsx(V,{className:"w-3 h-3 text-primary ml-auto"})]})},r.id))]}),l.length>0&&e.jsxs(Me,{children:[e.jsxs(Te,{className:"text-xs text-muted-foreground",children:["All Models (",l.length,")"]}),l.filter(r=>!u.has(r.id)).map(r=>e.jsx(ce,{value:r.id,children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"truncate font-mono text-xs",children:r.id}),t===r.id&&e.jsx(V,{className:"w-3 h-3 text-primary ml-auto"})]})},r.id))]}),(!i||i.models.length===0)&&l.length===0&&e.jsx("div",{className:"py-2 px-3 text-xs text-muted-foreground",children:"No models available"})]})]})]})}function jt({open:s,onClose:a,currentValues:t,onApply:n,onSave:i,isSaving:l,catalog:c,allModels:u}){const[r,d]=h.useState(t),[g,x]=h.useState(""),f=o=>{o?(d(t),x("")):a()};return e.jsx(xe,{open:s,onOpenChange:f,children:e.jsxs(pe,{className:"sm:max-w-md",children:[e.jsx(he,{children:e.jsxs(ge,{className:"flex items-center gap-2",children:[e.jsx(B,{className:"w-4 h-4"}),"Custom Preset"]})}),e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(se,{htmlFor:"preset-name",children:"Preset Name (optional)"}),e.jsx(ue,{id:"preset-name",value:g,onChange:o=>x(o.target.value),placeholder:"e.g., My Custom Config",className:"text-sm"})]}),e.jsx(ye,{}),e.jsx(q,{label:"Default Model",description:"Used when no specific tier is requested",value:r.default,onChange:o=>d({...r,default:o}),catalog:c,allModels:u}),e.jsx(q,{label:"Opus (Most capable)",description:"For complex reasoning tasks",value:r.opus,onChange:o=>d({...r,opus:o}),catalog:c,allModels:u}),e.jsx(q,{label:"Sonnet (Balanced)",description:"Balance of speed and capability",value:r.sonnet,onChange:o=>d({...r,sonnet:o}),catalog:c,allModels:u}),e.jsx(q,{label:"Haiku (Fast)",description:"Quick responses for simple tasks",value:r.haiku,onChange:o=>d({...r,haiku:o}),catalog:c,allModels:u})]}),e.jsxs(hs,{className:"gap-2 sm:gap-0",children:[e.jsx(v,{variant:"outline",onClick:a,children:"Cancel"}),i&&e.jsxs(v,{variant:"secondary",onClick:()=>i(r,g||void 0),disabled:l||!g.trim(),children:[l?e.jsx($,{className:"w-4 h-4 mr-1 animate-spin"}):e.jsx(te,{className:"w-4 h-4 mr-1"}),"Save Preset"]}),e.jsxs(v,{onClick:()=>n(r,g||void 0),children:[e.jsx(ae,{className:"w-4 h-4 mr-1"}),"Apply Preset"]})]})]})})}function Z({label:s,command:a}){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:a}),e.jsx(We,{value:a,size:"icon",className:"h-6 w-6"})]})]})}function vt({provider:s,displayName:a,data:t,authStatus:n}){return e.jsx(fe,{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($s,{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:a})]}),t&&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:t.path}),e.jsx(We,{value:t.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(t.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"}),n.authenticated?e.jsxs(D,{variant:"outline",className:"w-fit text-green-600 border-green-200 bg-green-50",children:[e.jsx(Vs,{className:"w-3 h-3 mr-1"}),"Authenticated"]}):e.jsx(D,{variant:"outline",className:"w-fit text-muted-foreground",children:"Not connected"})]})]})]}),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(Z,{label:"Run with prompt",command:`ccs ${s} "your prompt"`}),e.jsx(Z,{label:"Change model",command:`ccs ${s} --config`}),e.jsx(Z,{label:"Add account",command:`ccs ${s} --add`}),e.jsx(Z,{label:"List accounts",command:`ccs ${s} --accounts`})]})]})]})})}const Nt={gemini:"/assets/providers/gemini-color.svg",codex:"/assets/providers/openai.svg",agy:"/assets/providers/agy.png",qwen:"/assets/providers/qwen-color.svg",iflow:"/assets/providers/iflow.png",kiro:"/assets/providers/kiro.png",ghcp:"/assets/providers/copilot.svg"},wt={gemini:{text:"text-blue-600",letter:"G"},claude:{text:"text-orange-600",letter:"C"},codex:{text:"text-emerald-600",letter:"X"},agy:{text:"text-violet-600",letter:"A"},qwen:{text:"text-cyan-600",letter:"Q"},iflow:{text:"text-indigo-600",letter:"i"},kiro:{text:"text-teal-600",letter:"K"},ghcp:{text:"text-green-600",letter:"C"}},yt={sm:{container:"w-6 h-6",icon:"w-4 h-4",text:"text-xs"},md:{container:"w-8 h-8",icon:"w-5 h-5",text:"text-sm"},lg:{container:"w-12 h-12",icon:"w-8 h-8",text:"text-lg"}};function Ce({provider:s,className:a,size:t="md"}){const n=s.toLowerCase(),i=wt[n]||{text:"text-gray-600",letter:s[0]?.toUpperCase()||"?"},l=yt[t],c=Nt[n];return e.jsx("div",{className:O("flex items-center justify-center rounded-md",c&&"bg-white p-1",l.container,a),children:c?e.jsx("img",{src:c,alt:`${s} logo`,className:O(l.icon,"object-contain")}):e.jsx("span",{className:O("font-semibold",i.text,l.text),children:i.letter})})}function Ct({displayName:s,logoProvider:a,provider:t,data:n,isLoading:i,hasChanges:l,isRawJsonValid:c,isSaving:u,isRemoteMode:r,port:d,onRefetch:g,onSave:x}){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(Ce,{provider:a||t,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}),r&&e.jsxs(D,{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(Xe,{className:"w-3 h-3"}),"Remote"]}),d&&e.jsxs(D,{variant:"outline",className:"text-xs gap-1 font-mono",children:[e.jsx(Qs,{className:"w-3 h-3"}),":",d]}),!r&&n?.path&&e.jsx(D,{variant:"outline",className:"text-xs",children:n.path.replace(/^.*[\\/]/,"")})]}),r?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(v,{variant:"ghost",size:"sm",onClick:g,disabled:i,children:e.jsx(Ne,{className:`w-4 h-4 ${i?"animate-spin":""}`})}),e.jsx(v,{size:"sm",onClick:x,disabled:u||!l||!c,children:u?e.jsxs(e.Fragment,{children:[e.jsx($,{className:"w-4 h-4 mr-1 animate-spin"}),"Saving..."]}):e.jsxs(e.Fragment,{children:[e.jsx(zs,{className:"w-4 h-4 mr-1"}),"Save"]})})]})]})}function bt({catalog:s,savedPresets:a,currentModel:t,opusModel:n,sonnetModel:i,haikuModel:l,providerModels:c,onApplyPreset:u,onUpdateEnvValue:r,onOpenCustomPreset:d,onDeletePreset:g,isDeletePending:x}){const f=s&&s.models.length>0||a.length>0;return e.jsxs(e.Fragment,{children:[f&&e.jsxs("div",{children:[e.jsxs("h3",{className:"text-sm font-medium mb-2 flex items-center gap-2",children:[e.jsx(B,{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:"flex flex-wrap gap-2",children:[s?.models.slice(0,4).map(o=>e.jsxs(v,{variant:"outline",size:"sm",className:"text-xs h-7 gap-1",onClick:()=>{const N=o.presetMapping||{default:o.id,opus:o.id,sonnet:o.id,haiku:o.id};u({ANTHROPIC_MODEL:N.default,ANTHROPIC_DEFAULT_OPUS_MODEL:N.opus,ANTHROPIC_DEFAULT_SONNET_MODEL:N.sonnet,ANTHROPIC_DEFAULT_HAIKU_MODEL:N.haiku})},children:[e.jsx(ae,{className:"w-3 h-3"}),o.name]},o.id)),a.map(o=>e.jsxs("div",{className:"group relative",children:[e.jsxs(v,{variant:"secondary",size:"sm",className:"text-xs h-7 gap-1 pr-6",onClick:()=>{u({ANTHROPIC_MODEL:o.default,ANTHROPIC_DEFAULT_OPUS_MODEL:o.opus,ANTHROPIC_DEFAULT_SONNET_MODEL:o.sonnet,ANTHROPIC_DEFAULT_HAIKU_MODEL:o.haiku})},children:[e.jsx(te,{className:"w-3 h-3 fill-current"}),o.name]}),e.jsx(v,{variant:"ghost",size:"icon",className:"absolute right-0 top-0 h-7 w-5 opacity-0 group-hover:opacity-100 hover:text-destructive",onClick:N=>{N.stopPropagation(),g(o.name)},disabled:x,children:e.jsx(we,{className:"w-3 h-3"})})]},o.name)),e.jsxs(v,{variant:"outline",size:"sm",className:"text-xs h-7 gap-1 border-primary/50 text-primary hover:bg-primary/10 hover:border-primary",onClick:d,children:[e.jsx(Ze,{className:"w-3 h-3"}),"Custom"]})]})]}),e.jsx(ye,{}),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"}),e.jsxs("div",{className:"space-y-4",children:[e.jsx(q,{label:"Default Model",description:"Used when no specific tier is requested",value:t,onChange:o=>r("ANTHROPIC_MODEL",o),catalog:s,allModels:c}),e.jsx(q,{label:"Opus (Most capable)",description:"For complex reasoning tasks",value:n,onChange:o=>r("ANTHROPIC_DEFAULT_OPUS_MODEL",o),catalog:s,allModels:c}),e.jsx(q,{label:"Sonnet (Balanced)",description:"Balance of speed and capability",value:i,onChange:o=>r("ANTHROPIC_DEFAULT_SONNET_MODEL",o),catalog:s,allModels:c}),e.jsx(q,{label:"Haiku (Fast)",description:"Quick responses for simple tasks",value:l,onChange:o=>r("ANTHROPIC_DEFAULT_HAIKU_MODEL",o),catalog:s,allModels:c})]})]})]})}function kt(s){const a=Math.max(0,Math.min(100,s));return a<=20?"bg-destructive":a<=50?"bg-yellow-500":"bg-green-500"}function Ie(s){if(!s)return"";try{const a=new Date(s),n=new Date().getTime()-a.getTime();if(n<0)return"just now";const i=Math.floor(n/(1e3*60)),l=Math.floor(n/(1e3*60*60)),c=Math.floor(n/(1e3*60*60*24));return c>0?`${c}d ago`:l>0?`${l}h ago`:i>0?`${i}m ago`:"just now"}catch{return""}}function At(s){if(!s)return!1;try{const a=new Date(s);return new Date().getTime()-a.getTime()<3600*1e3}catch{return!1}}function St({account:s,onSetDefault:a,onRemove:t,onPauseToggle:n,isRemoving:i,isPausingAccount:l,privacyMode:c,showQuota:u}){const{data:r}=gs(u),{data:d,isLoading:g}=fs(s.provider,s.id,u),x=r?.accountStats?.[s.email||s.id]?.lastUsedAt,f=At(x),o=d?.success?js(d.models):null,N=d?.success&&d.models.length>0?vs(d.models):null;return e.jsxs("div",{className:O("flex flex-col gap-2 p-3 rounded-lg border transition-colors",s.isDefault?"border-primary/30 bg-primary/5":"border-border hover:bg-muted/30"),children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:O("flex items-center justify-center w-8 h-8 rounded-full",s.isDefault?"bg-primary/10":"bg-muted"),children:e.jsx(Q,{className:"w-4 h-4"})}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:O("font-medium text-sm",c&&ee),children:s.email||s.id}),s.isDefault&&e.jsxs(D,{variant:"secondary",className:"text-[10px] h-4 px-1.5 gap-0.5",children:[e.jsx(te,{className:"w-2.5 h-2.5 fill-current"}),"Default"]}),s.tier&&s.tier!=="unknown"&&e.jsx(D,{variant:"outline",className:O("text-[10px] h-4 px-1.5 uppercase",s.tier==="paid"&&"border-blue-500 text-blue-600",s.tier==="free"&&"border-gray-400 text-gray-500"),children:s.tier}),s.paused&&e.jsxs(D,{variant:"outline",className:"text-[10px] h-4 px-1.5 border-yellow-500 text-yellow-600",children:[e.jsx(_e,{className:"w-2 h-2 mr-0.5"}),"Paused"]})]}),s.provider==="agy"&&e.jsx("div",{className:"flex items-center gap-1.5 mt-1",children:s.projectId?e.jsx(J,{children:e.jsxs(W,{children:[e.jsx(Y,{asChild:!0,children:e.jsxs("div",{className:"flex items-center gap-1 text-xs text-muted-foreground",children:[e.jsx(Bs,{className:"w-3 h-3","aria-hidden":"true"}),e.jsx("span",{className:O("font-mono max-w-[180px] truncate",c&&ee),title:s.projectId,children:s.projectId})]})}),e.jsx(X,{side:"bottom",children:e.jsx("p",{className:"text-xs",children:"GCP Project ID (read-only)"})})]})}):e.jsx(J,{children:e.jsxs(W,{children:[e.jsx(Y,{asChild:!0,children:e.jsxs("div",{className:"flex items-center gap-1 text-xs text-amber-600 dark:text-amber-500",children:[e.jsx(Js,{className:"w-3 h-3","aria-label":"Warning"}),e.jsx("span",{children:"Project ID: N/A"})]})}),e.jsx(X,{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."})]})})]})})}),s.lastUsedAt&&e.jsxs("div",{className:"flex items-center gap-1 text-xs text-muted-foreground mt-0.5",children:[e.jsx(oe,{className:"w-3 h-3"}),"Last used: ",new Date(s.lastUsedAt).toLocaleDateString()]})]})]}),e.jsxs(Ns,{children:[e.jsx(ws,{asChild:!0,children:e.jsx(v,{variant:"ghost",size:"icon",className:"h-7 w-7",children:e.jsx(Ws,{className:"w-4 h-4"})})}),e.jsxs(ys,{align:"end",children:[!s.isDefault&&e.jsxs(ie,{onClick:a,children:[e.jsx(te,{className:"w-4 h-4 mr-2"}),"Set as default"]}),n&&e.jsx(ie,{onClick:()=>n(!s.paused),disabled:l,children:s.paused?e.jsxs(e.Fragment,{children:[e.jsx(Ys,{className:"w-4 h-4 mr-2"}),l?"Resuming...":"Resume account"]}):e.jsxs(e.Fragment,{children:[e.jsx(_e,{className:"w-4 h-4 mr-2"}),l?"Pausing...":"Pause account"]})}),e.jsxs(ie,{className:"text-destructive focus:text-destructive",onClick:t,disabled:i,children:[e.jsx(es,{className:"w-4 h-4 mr-2"}),i?"Removing...":"Remove account"]})]})]})]}),u&&e.jsx("div",{className:"pl-11",children:g?e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[e.jsx($,{className:"w-3 h-3 animate-spin"}),e.jsx("span",{children:"Loading quota..."})]}):o!==null?e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("div",{className:"flex items-center gap-1.5 text-xs",children:f?e.jsxs(e.Fragment,{children:[e.jsx(Xs,{className:"w-3 h-3 text-emerald-500"}),e.jsxs("span",{className:"text-emerald-600 dark:text-emerald-400",children:["Active · ",Ie(x)]})]}):x?e.jsxs(e.Fragment,{children:[e.jsx(oe,{className:"w-3 h-3 text-muted-foreground"}),e.jsxs("span",{className:"text-muted-foreground",children:["Last used ",Ie(x)]})]}):e.jsxs(e.Fragment,{children:[e.jsx(Zs,{className:"w-3 h-3 text-muted-foreground"}),e.jsx("span",{className:"text-muted-foreground",children:"Not used yet"})]})}),e.jsx(J,{children:e.jsxs(W,{children:[e.jsx(Y,{asChild:!0,children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Cs,{value:Math.max(0,Math.min(100,o)),className:"h-2 flex-1",indicatorClassName:kt(o)}),e.jsxs("span",{className:"text-xs font-medium w-10 text-right",children:[o,"%"]})]})}),e.jsx(X,{side:"bottom",className:"max-w-xs",children:e.jsxs("div",{className:"text-xs space-y-1",children:[e.jsx("p",{className:"font-medium",children:"Model Quotas:"}),bs(d?.models||[]).map(b=>e.jsxs("div",{className:"flex justify-between gap-4",children:[e.jsx("span",{className:"truncate",children:b.displayName||b.name}),e.jsxs("span",{className:"font-mono",children:[b.percentage,"%"]})]},b.name)),N&&e.jsxs("div",{className:"flex items-center gap-1.5 mt-2 pt-2 border-t border-border/50",children:[e.jsx(oe,{className:"w-3 h-3 text-blue-400"}),e.jsxs("span",{className:"text-blue-400 font-medium",children:["Resets ",ks(N)]})]})]})})]})})]}):d?.error||d&&!d.success?e.jsx(J,{children:e.jsxs(W,{children:[e.jsx(Y,{asChild:!0,children:e.jsx("div",{className:"flex items-center gap-1.5",children:e.jsxs(D,{variant:"outline",className:"text-[10px] h-5 px-2 gap-1 border-muted-foreground/50 text-muted-foreground",children:[e.jsx(et,{className:"w-3 h-3"}),"N/A"]})})}),e.jsx(X,{side:"bottom",children:e.jsx("p",{className:"text-xs",children:d?.error||"Quota information unavailable"})})]})}):null})]})}function Pt({accounts:s,onAddAccount:a,onSetDefault:t,onRemoveAccount:n,onPauseToggle:i,isRemovingAccount:l,isPausingAccount:c,privacyMode:u,showQuota:r,isKiro:d,kiroNoIncognito:g,onKiroNoIncognitoChange:x,kiroSettingsLoading:f}){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:[e.jsx(Q,{className:"w-4 h-4"}),"Accounts",s.length>0&&e.jsx(D,{variant:"secondary",className:"text-xs",children:s.length})]}),e.jsxs(v,{variant:"default",size:"sm",className:"h-7 text-xs gap-1",onClick:a,children:[e.jsx(Ze,{className:"w-3 h-3"}),"Add"]})]}),s.length>0?e.jsx("div",{className:"space-y-2",children:s.map(o=>e.jsx(St,{account:o,onSetDefault:()=>t(o.id),onRemove:()=>n(o.id),onPauseToggle:i?N=>i(o.id,N):void 0,isRemoving:l,isPausingAccount:c,privacyMode:u,showQuota:r},o.id))}):e.jsxs("div",{className:"py-6 text-center text-muted-foreground bg-muted/30 rounded-lg border border-dashed",children:[e.jsx(Q,{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"})]}),d&&x&&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(Xe,{className:"w-3.5 h-3.5"}),e.jsx("span",{children:"Use incognito"})]}),e.jsx(at,{checked:!g,onCheckedChange:o=>x(!o),disabled:f,className:"scale-90"})]})})]})}function Mt({provider:s,catalog:a,savedPresets:t,currentModel:n,opusModel:i,sonnetModel:l,haikuModel:c,providerModels:u,onApplyPreset:r,onUpdateEnvValue:d,onOpenCustomPreset:g,onDeletePreset:x,isDeletePending:f,accounts:o,onAddAccount:N,onSetDefault:b,onRemoveAccount:w,onPauseToggle:P,isRemovingAccount:T,isPausingAccount:y,privacyMode:I,isRemoteMode:_}){const A=s==="kiro",[C,p]=h.useState(!0),[k,E]=h.useState(!0),[R,H]=h.useState(!1),F=h.useCallback(async()=>{if(A)try{E(!0);const j=(await re.config.get()).cliproxy;p(j?.kiro_no_incognito??!0)}catch{p(!0)}finally{E(!1)}},[A]),m=h.useCallback(async S=>{p(S),H(!0);try{const j=await re.config.get(),U=j.cliproxy??{};await re.config.update({...j,cliproxy:{...U,kiro_no_incognito:S}})}catch{p(!S)}finally{H(!1)}},[]);return h.useEffect(()=>{F()},[F]),e.jsx(fe,{className:"flex-1",children:e.jsxs("div",{className:"p-4 space-y-6",children:[e.jsx(bt,{catalog:a,savedPresets:t,currentModel:n,opusModel:i,sonnetModel:l,haikuModel:c,providerModels:u,onApplyPreset:r,onUpdateEnvValue:d,onOpenCustomPreset:g,onDeletePreset:x,isDeletePending:f}),e.jsx(ye,{}),e.jsx(Pt,{accounts:o,onAddAccount:N,onSetDefault:b,onRemoveAccount:w,onPauseToggle:P,isRemovingAccount:T,isPausingAccount:y,privacyMode:I,showQuota:s==="agy"&&!_,isKiro:A,kiroNoIncognito:C,onKiroNoIncognitoChange:m,kiroSettingsLoading:k||R})]})})}function Le({provider:s,displayName:a,authStatus:t,catalog:n,logoProvider:i,baseProvider:l,isRemoteMode:c,port:u,onAddAccount:r,onSetDefault:d,onRemoveAccount:g,onPauseToggle:x,isRemovingAccount:f,isPausingAccount:o}){const[N,b]=h.useState(!1),{privacyMode:w}=Be(),{data:P}=As(),{data:T}=Ss(s),y=Ps(),I=Ms(),_=T?.presets||[],A=l||s,C=h.useMemo(()=>{if(!P?.models)return[];const K={gemini:["google"],agy:["antigravity"],codex:["openai"],qwen:["alibaba","qwen"],iflow:["iflow"],kiro:["kiro","aws"],ghcp:["github","copilot"]}[A.toLowerCase()]||[A.toLowerCase()];return P.models.filter(Pe=>K.some(ms=>Pe.owned_by.toLowerCase().includes(ms)))},[P,A]),{data:p,isLoading:k,refetch:E,rawJsonContent:R,rawJsonEdits:H,isRawJsonValid:F,hasChanges:m,currentModel:S,opusModel:j,sonnetModel:U,haikuModel:G,handleRawJsonChange:ne,updateEnvValue:as,updateEnvValues:be,saveMutation:ke,conflictDialog:ns,handleConflictResolve:Ae,missingRequiredFields:is}=ft(s),rs=t.accounts||[],{data:os}=Fe({queryKey:["auth-tokens-raw"],queryFn:async()=>{const M=await fetch("/api/settings/auth/tokens/raw");return M.ok?M.json():{apiKey:{value:"ccs-internal-managed"}}},staleTime:6e4}),Se=os?.apiKey?.value??"ccs-internal-managed",ls=M=>{be({ANTHROPIC_BASE_URL:`http://127.0.0.1:${u??de}/api/provider/${s}`,ANTHROPIC_AUTH_TOKEN:Se,...M}),L.success(`Applied "${M.ANTHROPIC_MODEL?.split("/").pop()||"preset"}" preset`)},cs=(M,K)=>{be({ANTHROPIC_BASE_URL:`http://127.0.0.1:${u??de}/api/provider/${s}`,ANTHROPIC_AUTH_TOKEN:Se,ANTHROPIC_MODEL:M.default,ANTHROPIC_DEFAULT_OPUS_MODEL:M.opus,ANTHROPIC_DEFAULT_SONNET_MODEL:M.sonnet,ANTHROPIC_DEFAULT_HAIKU_MODEL:M.haiku}),L.success(`Applied ${K?`"${K}"`:"custom"} preset`),b(!1)},ds=(M,K)=>{if(!K){L.error("Please enter a preset name to save");return}y.mutate({profile:s,data:{name:K,...M}}),b(!1)};return e.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden",children:[e.jsx(Ct,{provider:s,displayName:a,logoProvider:i,data:p,isLoading:k,hasChanges:m,isRawJsonValid:F,isSaving:ke.isPending,isRemoteMode:c,port:u,onRefetch:E,onSave:()=>ke.mutate()}),k?e.jsxs("div",{className:"flex-1 flex items-center justify-center",children:[e.jsx($,{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:"flex-1 grid grid-cols-[40%_60%] divide-x overflow-hidden",children:[e.jsx("div",{className:"flex flex-col overflow-hidden bg-muted/5",children:e.jsxs(Ts,{defaultValue:"config",className:"h-full flex flex-col",children:[e.jsx("div",{className:"px-4 pt-4 shrink-0",children:e.jsxs(Os,{className:"w-full",children:[e.jsx(Oe,{value:"config",className:"flex-1",children:"Model Config"}),e.jsx(Oe,{value:"info",className:"flex-1",children:"Info & Usage"})]})}),e.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col",children:[e.jsx(De,{value:"config",className:"flex-1 mt-0 border-0 p-0 data-[state=inactive]:hidden flex flex-col overflow-hidden",children:e.jsx(Mt,{provider:s,catalog:n,savedPresets:_,currentModel:S,opusModel:j,sonnetModel:U,haikuModel:G,providerModels:C,onApplyPreset:ls,onUpdateEnvValue:as,onOpenCustomPreset:()=>b(!0),onDeletePreset:M=>I.mutate({profile:s,name:M}),isDeletePending:I.isPending,accounts:rs,onAddAccount:r,onSetDefault:d,onRemoveAccount:g,onPauseToggle:x,isRemovingAccount:f,isPausingAccount:o,privacyMode:w,isRemoteMode:c})}),e.jsx(De,{value:"info",className:"h-full mt-0 border-0 p-0 data-[state=inactive]:hidden",children:e.jsx(vt,{provider:s,displayName:a,data:p,authStatus:t})})]})]})}),e.jsxs("div",{className:"flex 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(st,{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(Ds,{rawJsonContent:R,isRawJsonValid:F,rawJsonEdits:H,onRawJsonChange:ne,profileEnv:p?.settings?.env,missingRequiredFields:is})]})]}),e.jsx(tt,{open:ns,title:"File Modified Externally",description:"This settings file was modified by another process. Overwrite with your changes or discard?",confirmText:"Overwrite",variant:"destructive",onConfirm:()=>Ae(!0),onCancel:()=>Ae(!1)}),e.jsx(jt,{open:N,onClose:()=>b(!1),currentValues:{default:S||"",opus:j||"",sonnet:U||"",haiku:G||""},onApply:cs,onSave:ds,isSaving:y.isPending,catalog:n,allModels:C})]})}function Tt({status:s,isSelected:a,onSelect:t}){const n=s.accounts?.length||0;return e.jsxs("button",{className:O("w-full flex items-center gap-3 px-3 py-2.5 rounded-lg transition-colors cursor-pointer text-left",a?"bg-primary/10 border border-primary/20":"hover:bg-muted border border-transparent"),onClick:t,children:[e.jsx(Ce,{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}),n>0&&e.jsx(D,{variant:"secondary",className:"text-[10px] h-4 px-1",children:n})]}),e.jsx("div",{className:"flex items-center gap-1.5 mt-0.5",children:s.authenticated?e.jsxs(e.Fragment,{children:[e.jsx(V,{className:"w-3 h-3 text-green-600"}),e.jsx("span",{className:"text-xs text-green-600",children:"Connected"})]}):e.jsxs(e.Fragment,{children:[e.jsx(we,{className:"w-3 h-3 text-muted-foreground"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:"Not connected"})]})})]})]})}function Ot({variant:s,parentAuth:a,isSelected:t,onSelect:n,onDelete:i,isDeleting:l}){return e.jsxs("button",{className:O("group w-full flex items-center gap-3 px-3 py-2 rounded-lg transition-colors cursor-pointer text-left pl-6",t?"bg-primary/10 border border-primary/20":"hover:bg-muted border border-transparent"),onClick:n,children:[e.jsxs("div",{className:"relative",children:[e.jsx(Ce,{provider:s.provider,size:"sm"}),e.jsx(ss,{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(D,{variant:"outline",className:"text-[9px] h-4 px-1",children:"variant"})]}),e.jsx("div",{className:"flex items-center gap-1.5 mt-0.5",children:a?.authenticated?e.jsxs(e.Fragment,{children:[e.jsx(V,{className:"w-3 h-3 text-green-600"}),e.jsxs("span",{className:"text-xs text-muted-foreground truncate",children:["via ",s.provider]})]}):e.jsxs(e.Fragment,{children:[e.jsx(we,{className:"w-3 h-3 text-muted-foreground"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:"Parent not connected"})]})})]}),e.jsx(v,{variant:"ghost",size:"icon",className:"h-6 w-6 opacity-0 group-hover:opacity-100 hover:text-destructive",onClick:c=>{c.stopPropagation(),i()},disabled:l,children:e.jsx(es,{className:"w-3 h-3"})})]})}function Dt({onSetup:s}){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(ae,{className:"w-8 h-8 text-muted-foreground"})}),e.jsx("h2",{className:"text-xl font-semibold mb-2",children:"CCS Profile Manager"}),e.jsx("p",{className:"text-muted-foreground mb-4",children:"Manage OAuth authentication, account preferences, and model selection for CLIProxy providers. Configure how CCS routes requests to different AI backends."}),e.jsxs("p",{className:"text-xs text-muted-foreground mb-6",children:["For live usage stats and real-time monitoring, visit the"," ",e.jsx("a",{href:"/cliproxy/control-panel",className:"text-primary hover:underline",children:"Control Panel"}),"."]}),e.jsxs(v,{onClick:s,className:"gap-2",children:[e.jsx(B,{className:"w-4 h-4"}),"Quick Setup"]})]})})}function Qt(){const s=Re(),{data:a,isLoading:t}=Ve(),{data:n,isFetching:i}=_s(),{data:l}=Es(),c=Is(),u=Ls(),r=Rs(),d=Fs(),g=Hs(),[x,f]=h.useState(null),[o,N]=h.useState(null),[b,w]=h.useState(!1),[P,T]=h.useState(null),y=h.useMemo(()=>a?.authStatus||[],[a?.authStatus]),I=a?.source==="remote",_=h.useMemo(()=>n?.variants||[],[n?.variants]),A=h.useMemo(()=>o?null:x&&y.some(m=>m.provider===x)?x:y.length>0?y[0].provider:null,[x,o,y]),C=y.find(m=>m.provider===A),p=_.find(m=>m.name===o),k=p?y.find(m=>m.provider===p.provider):void 0,E=()=>{s.invalidateQueries({queryKey:["cliproxy"]}),s.invalidateQueries({queryKey:["cliproxy-auth"]})},R=(m,S,j)=>{r.isPending||d.isPending||(j?r.mutate({provider:m,accountId:S}):d.mutate({provider:m,accountId:S}))},H=m=>{f(m),N(null)},F=m=>{N(m),f(null)};return e.jsxs("div",{className:"h-[calc(100vh-100px)] flex",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(ae,{className:"w-5 h-5 text-primary"}),e.jsx("h1",{className:"font-semibold",children:l?.backendLabel??"CLIProxy"})]}),e.jsx(v,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:E,disabled:i,children:e.jsx(Ne,{className:O("w-4 h-4",i&&"animate-spin")})})]}),e.jsx("p",{className:"text-xs text-muted-foreground mb-3",children:"CCS-level account management"}),e.jsxs(v,{variant:"default",size:"sm",className:"w-full gap-2",onClick:()=>w(!0),children:[e.jsx(B,{className:"w-4 h-4"}),"Quick Setup"]})]}),e.jsx(fe,{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:"Providers"}),t?e.jsx("div",{className:"space-y-2 px-2",children:[1,2,3,4].map(m=>e.jsx(Us,{className:"h-14 w-full rounded-lg"},m))}):e.jsx("div",{className:"space-y-1",children:y.map(m=>e.jsx(Tt,{status:m,isSelected:A===m.provider,onSelect:()=>H(m.provider)},m.provider))}),_.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(ss,{className:"w-3 h-3"}),"Variants"]}),e.jsx("div",{className:"space-y-1",children:_.map(m=>e.jsx(Ot,{variant:m,parentAuth:y.find(S=>S.provider===m.provider),isSelected:o===m.name,onSelect:()=>F(m.name),onDelete:()=>g.mutate(m.name),isDeleting:g.isPending},m.name))})]})]})}),e.jsx("div",{className:"p-3 border-t",children:e.jsx(nt,{})}),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.jsxs("span",{children:[y.length," provider",y.length!==1?"s":""]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(V,{className:"w-3 h-3 text-green-600"}),y.filter(m=>m.authenticated).length," connected"]})]})})]}),e.jsx("div",{className:"flex-1 flex flex-col min-w-0 bg-background",children:p&&k?e.jsx(Le,{provider:p.name,displayName:`${p.name} (${p.provider} variant)`,authStatus:k,catalog:z[p.provider],logoProvider:p.provider,baseProvider:p.provider,isRemoteMode:I,port:p.port,onAddAccount:()=>T({provider:p.provider,displayName:k.displayName,isFirstAccount:(k.accounts?.length||0)===0}),onSetDefault:m=>c.mutate({provider:p.provider,accountId:m}),onRemoveAccount:m=>u.mutate({provider:p.provider,accountId:m}),onPauseToggle:(m,S)=>R(p.provider,m,S),isRemovingAccount:u.isPending,isPausingAccount:r.isPending||d.isPending}):C?e.jsx(Le,{provider:C.provider,displayName:C.displayName,authStatus:C,catalog:z[C.provider],isRemoteMode:I,onAddAccount:()=>T({provider:C.provider,displayName:C.displayName,isFirstAccount:(C.accounts?.length||0)===0}),onSetDefault:m=>c.mutate({provider:C.provider,accountId:m}),onRemoveAccount:m=>u.mutate({provider:C.provider,accountId:m}),onPauseToggle:(m,S)=>R(C.provider,m,S),isRemovingAccount:u.isPending,isPausingAccount:r.isPending||d.isPending}):e.jsx(Dt,{onSetup:()=>w(!0)})}),e.jsx(xt,{open:b,onClose:()=>w(!1)}),e.jsx(pt,{open:P!==null,onClose:()=>T(null),provider:P?.provider||"",displayName:P?.displayName||"",isFirstAccount:P?.isFirstAccount||!1})]})}export{Qt as CliproxyPage};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{j as e}from"./radix-ui-DP8--cuX.js";import{r as s}from"./react-vendor-CNOkPC89.js";import{u as w}from"./tanstack-ChZysrI1.js";import{ao as I}from"./index-Bqpm7XFW.js";import{G as R,a5 as v,$ as S,a0 as T,K as U,S as K,X as M}from"./icons-MT_USDDP.js";import"./notifications-B2HqRBj7.js";import"./utils-CzKF5WmX.js";import"./form-utils-C-pVd1--.js";import"./code-highlight-BRUf_pqB.js";const A=8317;function F({port:c=A}){const n=s.useRef(null),[f,p]=s.useState(!0),[b,i]=s.useState(null),[k,m]=s.useState(!1),[P,L]=s.useState(!0),{data:g,error:h}=w({queryKey:["cliproxy-server-config"],queryFn:()=>I.cliproxyServer.get(),staleTime:3e4}),{data:j}=w({queryKey:["auth-tokens-raw"],queryFn:async()=>{const t=await fetch("/api/settings/auth/tokens/raw");if(!t.ok)throw new Error("Failed to fetch auth tokens");return t.json()},staleTime:3e4});s.useEffect(()=>{h&&console.warn("[ControlPanelEmbed] Config fetch failed, using local mode:",h)},[h]);const{managementUrl:y,checkUrl:d,authToken:r,isRemote:l,displayHost:u}=s.useMemo(()=>{const t=g?.remote;if(t?.enabled&&t?.host){const o=t.protocol||"http",a=t.port||(o==="https"?443:80),N=o==="https"&&a===443||o==="http"&&a===80?"":`:${a}`,C=`${o}://${t.host}${N}`;return{managementUrl:`${C}/management.html`,checkUrl:`${C}/`,authToken:t.auth_token||void 0,isRemote:!0,displayHost:`${t.host}${N}`}}const x=j?.managementSecret?.value||"ccs";return{managementUrl:`http://localhost:${c}/management.html`,checkUrl:`http://localhost:${c}/`,authToken:x,isRemote:!1,displayHost:`localhost:${c}`}},[g,j,c]);s.useEffect(()=>{const t=new AbortController,x=async()=>{try{(await fetch(d,{signal:t.signal})).ok?(m(!0),i(null)):(m(!1),i(l?`Remote CLIProxy at ${u} returned an error`:"CLIProxy returned an error"))}catch(a){if(a instanceof Error&&a.name==="AbortError")return;m(!1),i(l?`Remote CLIProxy at ${u} is not reachable`:"CLIProxy is not running")}},o=setTimeout(()=>t.abort(),2e3);return x().finally(()=>clearTimeout(o)),()=>t.abort()},[d,l,u]);const $=s.useCallback(()=>{if(p(!1),n.current?.contentWindow&&r)try{const t=d.replace(/\/$/,"");if(!n.current.src.startsWith(t)){console.warn("[ControlPanelEmbed] Iframe origin mismatch, skipping postMessage");return}n.current.contentWindow.postMessage({type:"ccs-auto-login",apiBase:t,managementKey:r},t)}catch(t){console.debug("[ControlPanelEmbed] postMessage failed - cross-origin:",t)}},[d,r]),E=()=>{p(!0),i(null),m(!1),n.current&&(n.current.src=y)};return!k&&b?e.jsxs("div",{className:"flex-1 flex flex-col",children:[e.jsxs("div",{className:"flex items-center justify-between p-4 border-b",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(R,{className:"w-5 h-5 text-primary"}),e.jsx("h2",{className:"font-semibold",children:"CLIProxy Control Panel"})]}),e.jsxs("button",{className:"inline-flex items-center gap-2 px-3 py-1.5 text-sm border rounded-md hover:bg-muted",onClick:E,children:[e.jsx(v,{className:"w-4 h-4"}),"Retry"]})]}),e.jsx("div",{className:"flex-1 flex items-center justify-center bg-muted/20",children:e.jsxs("div",{className:"text-center max-w-md px-8",children:[e.jsx("div",{className:"w-16 h-16 rounded-full bg-destructive/10 flex items-center justify-center mx-auto mb-6",children:e.jsx(S,{className:"w-8 h-8 text-destructive"})}),e.jsx("h3",{className:"text-lg font-semibold mb-2",children:"CLIProxy Not Available"}),e.jsx("p",{className:"text-muted-foreground mb-4",children:b}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Start a CLIProxy session with"," ",e.jsx("code",{className:"bg-muted px-1 rounded",children:"ccs gemini"})," or run"," ",e.jsx("code",{className:"bg-muted px-1 rounded",children:"ccs config"})," which auto-starts it."]})]})})]}):e.jsxs("div",{className:"flex-1 flex flex-col relative",children:[P&&!f&&e.jsx("div",{className:"absolute top-2 left-1/2 -translate-x-1/2 z-20",children:e.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5 bg-blue-50 dark:bg-blue-950 border border-blue-200 dark:border-blue-800 rounded-md text-sm",children:[l&&e.jsxs(e.Fragment,{children:[e.jsx(T,{className:"h-3.5 w-3.5 text-green-600"}),e.jsx("span",{className:"text-green-600 font-medium",children:"Remote"}),e.jsx("span",{className:"text-blue-300 dark:text-blue-700",children:"|"})]}),e.jsx(U,{className:"h-3.5 w-3.5 text-blue-600"}),e.jsxs("span",{children:["Key:"," ",e.jsx("code",{className:"bg-blue-100 dark:bg-blue-900 px-1 rounded font-mono font-semibold",children:r&&r.length>4?`***${r.slice(-4)}`:r||"ccs"})]}),e.jsx("a",{href:"/settings?tab=auth",className:"text-blue-600 hover:text-blue-800 dark:hover:text-blue-400",title:"Manage auth tokens",children:e.jsx(K,{className:"h-3.5 w-3.5"})}),e.jsx("button",{className:"text-blue-600 hover:text-blue-800 dark:hover:text-blue-400",onClick:()=>L(!1),children:e.jsx(M,{className:"h-3.5 w-3.5"})})]})}),f&&e.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-background/80 z-10",children:e.jsxs("div",{className:"text-center",children:[e.jsx(v,{className:"w-8 h-8 animate-spin text-primary mx-auto mb-2"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:l?`Loading Control Panel from ${u}...`:"Loading Control Panel..."})]})}),e.jsx("iframe",{ref:n,src:y,className:"flex-1 w-full border-0",title:"CLIProxy Management Panel",onLoad:$})]})}function D(){return e.jsx("div",{className:"h-[calc(100vh-100px)] flex flex-col",children:e.jsx(F,{})})}export{D as CliproxyControlPanelPage};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{j as r,$ as c}from"./radix-ui-DP8--cuX.js";import"./react-vendor-CNOkPC89.js";import{c as d}from"./index-Bqpm7XFW.js";import{A as h,a as x,b as g,c as m,d as p,e as f,f as j,g as u}from"./alert-dialog-DFi20Kyu.js";function v({className:t,orientation:e="horizontal",decorative:a=!0,...o}){return r.jsx(c,{"data-slot":"separator",decorative:a,orientation:e,className:d("bg-border shrink-0 data-[orientation=horizontal]:h-px data-[orientation=horizontal]:w-full data-[orientation=vertical]:h-full data-[orientation=vertical]:w-px",t),...o})}function k({open:t,onConfirm:e,onCancel:a,title:o,description:i,confirmText:l="Confirm",variant:n="default"}){return r.jsx(h,{open:t,onOpenChange:s=>!s&&a(),children:r.jsxs(x,{children:[r.jsxs(g,{children:[r.jsx(m,{children:o}),r.jsx(p,{children:i})]}),r.jsxs(f,{children:[r.jsx(j,{onClick:a,children:"Cancel"}),r.jsx(u,{onClick:e,className:n==="destructive"?"bg-red-600 hover:bg-red-700 text-white":"",children:l})]})]})})}export{k as C,v as S};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{j as e}from"./radix-ui-DP8--cuX.js";import{r as c}from"./react-vendor-CNOkPC89.js";import{aI as N,aJ as C,aK as w,aF as y,aH as G,m as S,b,I as p}from"./index-Bqpm7XFW.js";import{S as k}from"./switch-D7uSKm8B.js";import{a5 as j,$ as A,p as R,af as L,Y as I}from"./icons-MT_USDDP.js";import"./tanstack-ChZysrI1.js";import"./notifications-B2HqRBj7.js";import"./utils-CzKF5WmX.js";import"./form-utils-C-pVd1--.js";import"./code-highlight-BRUf_pqB.js";function V(){const{state:s}=N(),a=C(),[l,d]=c.useState(""),[m,v]=c.useState(""),u=c.useCallback(async()=>{try{a.setGlobalEnvLoading(!0),a.setGlobalEnvError(null);const t=await fetch("/api/global-env");if(!t.ok)throw new Error("Failed to load Global Env config");const o=await t.json();a.setGlobalEnvConfig(o)}catch(t){a.setGlobalEnvError(t.message)}finally{a.setGlobalEnvLoading(!1)}},[a]),i=c.useCallback(async t=>{const o=s.globalEnvConfig;if(!o)return;const x={...o,...t};a.setGlobalEnvConfig(x);try{a.setGlobalEnvSaving(!0),a.setGlobalEnvError(null);const r=await fetch("/api/global-env",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(x)});if(!r.ok){const n=await r.json();throw new Error(n.error||"Failed to save")}const h=await r.json();a.setGlobalEnvConfig(h.config),a.setGlobalEnvSuccess(!0),setTimeout(()=>a.setGlobalEnvSuccess(!1),1500)}catch(r){a.setGlobalEnvConfig(o),a.setGlobalEnvError(r.message)}finally{a.setGlobalEnvSaving(!1)}},[s.globalEnvConfig,a]),f=c.useCallback(()=>{if(!l.trim()||!s.globalEnvConfig)return;const t={...s.globalEnvConfig.env,[l.trim()]:m};i({env:t}),d(""),v("")},[l,m,s.globalEnvConfig,i]),g=c.useCallback(t=>{if(!s.globalEnvConfig)return;const o={...s.globalEnvConfig.env};delete o[t],i({env:o})},[s.globalEnvConfig,i]);return{config:s.globalEnvConfig,loading:s.globalEnvLoading,saving:s.globalEnvSaving,error:s.globalEnvError,success:s.globalEnvSuccess,newEnvKey:l,setNewEnvKey:d,newEnvValue:m,setNewEnvValue:v,fetchConfig:u,saveConfig:i,addEnvVar:f,removeEnvVar:g}}function U(){const{config:s,loading:a,saving:l,error:d,success:m,newEnvKey:v,setNewEnvKey:u,newEnvValue:i,setNewEnvValue:f,fetchConfig:g,saveConfig:t,addEnvVar:o,removeEnvVar:x}=V(),{fetchRawConfig:r}=w();c.useEffect(()=>{g(),r()},[g,r]);const h=()=>{t({enabled:!s?.enabled})};return a?e.jsx("div",{className:"flex-1 flex items-center justify-center",children:e.jsxs("div",{className:"flex items-center gap-3 text-muted-foreground",children:[e.jsx(j,{className:"w-5 h-5 animate-spin"}),e.jsx("span",{children:"Loading..."})]})}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:`absolute left-5 right-5 top-20 z-10 transition-all duration-200 ease-out ${d||m?"opacity-100 translate-y-0":"opacity-0 -translate-y-2 pointer-events-none"}`,children:[d&&e.jsxs(y,{variant:"destructive",className:"py-2 shadow-lg",children:[e.jsx(A,{className:"h-4 w-4"}),e.jsx(G,{children:d})]}),m&&e.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 rounded-md border border-green-200 bg-green-50 text-green-700 shadow-lg dark:border-green-900/50 dark:bg-green-900/90 dark:text-green-300",children:[e.jsx(R,{className:"h-4 w-4 shrink-0"}),e.jsx("span",{className:"text-sm font-medium",children:"Saved"})]})]}),e.jsx(S,{className:"flex-1",children:e.jsxs("div",{className:"p-5 space-y-6",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Environment variables injected into all non-Claude subscription profiles (gemini, codex, agy, ghcp, etc.)"}),e.jsxs("div",{className:"flex items-center justify-between p-4 rounded-lg bg-muted/50",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:s?.enabled?"Global Env enabled":"Global Env disabled"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s?.enabled?"Env vars will be injected into third-party profiles":"Env vars will not be injected"})]}),e.jsx(k,{checked:s?.enabled??!0,onCheckedChange:h})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx("h3",{className:"text-base font-medium",children:"Environment Variables"}),s?.env&&Object.keys(s.env).length>0?e.jsx("div",{className:"space-y-2",children:Object.entries(s.env).map(([n,E])=>e.jsxs("div",{className:"flex items-center gap-2 p-3 rounded-lg border bg-background",children:[e.jsx("code",{className:"flex-1 font-mono text-sm truncate",children:n}),e.jsx("span",{className:"text-muted-foreground",children:"="}),e.jsx("code",{className:"font-mono text-sm px-2 py-1 bg-muted rounded",children:E}),e.jsx(b,{variant:"ghost",size:"sm",onClick:()=>x(n),disabled:l,className:"h-8 w-8 p-0 text-destructive hover:text-destructive hover:bg-destructive/10",children:e.jsx(L,{className:"w-4 h-4"})})]},n))}):e.jsx("div",{className:"p-4 rounded-lg border border-dashed text-center text-muted-foreground",children:e.jsx("p",{children:"No environment variables configured"})}),e.jsxs("div",{className:"p-4 rounded-lg border bg-muted/30",children:[e.jsx("h4",{className:"text-sm font-medium mb-3",children:"Add New Variable"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(p,{value:v,onChange:n=>u(n.target.value.toUpperCase()),placeholder:"KEY_NAME",className:"flex-1 font-mono text-sm h-9",disabled:l}),e.jsx("span",{className:"flex items-center text-muted-foreground",children:"="}),e.jsx(p,{value:i,onChange:n=>f(n.target.value),placeholder:"value",className:"flex-1 font-mono text-sm h-9",disabled:l}),e.jsxs(b,{size:"sm",onClick:o,disabled:l||!v.trim(),className:"h-9",children:[e.jsx(I,{className:"w-4 h-4 mr-1"}),"Add"]})]})]}),e.jsxs("div",{className:"p-4 rounded-lg border bg-muted/30",children:[e.jsx("h4",{className:"text-sm font-medium mb-3",children:"Quick Add Common Variables"}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[[{key:"DISABLE_BUG_COMMAND",value:"1"},{key:"DISABLE_ERROR_REPORTING",value:"1"},{key:"DISABLE_TELEMETRY",value:"1"}].map(({key:n,value:E})=>!s?.env?.[n]&&e.jsxs(b,{variant:"outline",size:"sm",onClick:()=>{u(n),f(E)},className:"text-xs font-mono",children:["+ ",n]},n)),s?.env&&["DISABLE_BUG_COMMAND","DISABLE_ERROR_REPORTING","DISABLE_TELEMETRY"].every(n=>s.env[n])&&e.jsx("span",{className:"text-sm text-muted-foreground",children:"All common variables are configured"})]})]})]})]})}),e.jsx("div",{className:"p-4 border-t bg-background",children:e.jsxs(b,{variant:"outline",size:"sm",onClick:()=>{g(),r()},disabled:a||l,className:"w-full",children:[e.jsx(j,{className:`w-4 h-4 mr-2 ${a?"animate-spin":""}`}),"Refresh"]})})]})}export{U as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{j as e}from"./radix-ui-DP8--cuX.js";import{r as c}from"./react-vendor-CNOkPC89.js";import{aI as ge,aJ as fe,ao as L,I as A,X as ye,Y as be,Z as je,_ as ve,$ as Y,b as X,aK as Ne,aL as ke,aM as Ce,aF as V,aH as O,m as Pe}from"./index-Bqpm7XFW.js";import{S as M}from"./switch-D7uSKm8B.js";import{aA as Z,a5 as U,e as Se,p as Q,W as we,$ as Ie,aB as Ee,aC as Te,T as q,aD as Ae}from"./icons-MT_USDDP.js";import{P as Le}from"./proxy-status-widget-DNGPVCQ7.js";import"./tanstack-ChZysrI1.js";import"./notifications-B2HqRBj7.js";import"./utils-CzKF5WmX.js";import"./form-utils-C-pVd1--.js";import"./code-highlight-BRUf_pqB.js";import"./alert-dialog-DFi20Kyu.js";function _e(){const{state:t}=ge(),s=fe(),[n,d]=c.useState(null),[u,f]=c.useState(null),[p,m]=c.useState(null),[b,j]=c.useState(null),[v,N]=c.useState(null),k=c.useCallback(async()=>{try{s.setProxyLoading(!0),s.setProxyError(null);const l=await L.cliproxyServer.get();s.setProxyConfig(l)}catch(l){s.setProxyError(l.message)}finally{s.setProxyLoading(!1)}},[s]),C=c.useCallback(async l=>{const i=t.proxyConfig;if(!i)return;const x={remote:{...i.remote,...l.remote},fallback:{...i.fallback,...l.fallback},local:{...i.local,...l.local}};s.setProxyConfig(x),s.setProxyTestResult(null);try{s.setProxySaving(!0),s.setProxyError(null);const r=await L.cliproxyServer.update(l);s.setProxyConfig(r),s.setProxySuccess(!0),setTimeout(()=>s.setProxySuccess(!1),1500)}catch(r){s.setProxyConfig(i),s.setProxyError(r.message)}finally{s.setProxySaving(!1)}},[t.proxyConfig,s]),P=c.useCallback(async l=>{const{host:i,port:x,protocol:r,authToken:S}=l;if(!i){s.setProxyError("Host is required");return}try{s.setProxyTesting(!0),s.setProxyError(null),s.setProxyTestResult(null);const o=x?parseInt(x,10):void 0,w=await L.cliproxyServer.test({host:i,port:o||void 0,protocol:r,authToken:S||void 0});s.setProxyTestResult(w)}catch(o){s.setProxyError(o.message)}finally{s.setProxyTesting(!1)}},[s]);return{config:t.proxyConfig,loading:t.proxyLoading,saving:t.proxySaving,error:t.proxyError,success:t.proxySuccess,testResult:t.proxyTestResult,testing:t.proxyTesting,editedHost:n,setEditedHost:d,editedPort:u,setEditedPort:f,editedAuthToken:p,setEditedAuthToken:m,editedManagementKey:b,setEditedManagementKey:j,editedLocalPort:v,setEditedLocalPort:N,fetchConfig:k,saveConfig:C,testConnection:P}}function Me({config:t,saving:s,displayLocalPort:n,setEditedLocalPort:d,onSaveLocalPort:u,onSaveConfig:f}){const p=t.local;return e.jsxs("div",{className:"space-y-3",children:[e.jsx("h3",{className:"text-base font-medium",children:"Local Proxy"}),e.jsxs("div",{className:"space-y-3 p-4 rounded-lg border bg-muted/30",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("label",{className:"text-sm text-muted-foreground",children:"Port"}),e.jsx(A,{type:"number",value:n,onChange:m=>d(m.target.value),onBlur:u,placeholder:"8317",className:"font-mono max-w-32",disabled:s})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-sm",children:"Auto-start"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Start local proxy automatically when needed"})]}),e.jsx(M,{checked:p.auto_start??!0,onCheckedChange:m=>f({local:{...p,auto_start:m}}),disabled:s})]})]})]})}function Be({config:t,saving:s,testing:n,testResult:d,displayHost:u,displayPort:f,displayAuthToken:p,displayManagementKey:m,setEditedHost:b,setEditedPort:j,setEditedAuthToken:v,setEditedManagementKey:N,onSaveHost:k,onSavePort:C,onSaveAuthToken:P,onSaveManagementKey:l,onSaveConfig:i,onTestConnection:x}){const r=t.remote,S=o=>o==="https"?443:8317;return e.jsxs("div",{className:"space-y-4 p-4 rounded-lg border bg-muted/30",children:[e.jsxs("h4",{className:"text-sm font-medium flex items-center gap-2",children:[e.jsx(Z,{className:"w-4 h-4"}),"Remote Server Configuration"]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:"text-sm text-muted-foreground",children:"Host"}),e.jsx(A,{value:u,onChange:o=>b(o.target.value),onBlur:k,placeholder:"192.168.1.100 or proxy.example.com",className:"font-mono",disabled:s})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs("label",{className:"text-sm text-muted-foreground",children:["Port"," ",e.jsxs("span",{className:"text-xs opacity-70",children:["(default: ",S(t.remote.protocol||"http"),")"]})]}),e.jsx(A,{type:"text",inputMode:"numeric",value:f,onChange:o=>j(o.target.value.replace(/\D/g,"")),onBlur:C,placeholder:`Leave empty for ${S(t.remote.protocol||"http")}`,className:"font-mono",disabled:s})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:"text-sm text-muted-foreground",children:"Protocol"}),e.jsxs(ye,{value:t.remote.protocol||"http",onValueChange:o=>i({remote:{...r,protocol:o}}),disabled:s,children:[e.jsx(be,{children:e.jsx(je,{})}),e.jsxs(ve,{children:[e.jsx(Y,{value:"http",children:"HTTP"}),e.jsx(Y,{value:"https",children:"HTTPS"})]})]})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:"text-sm text-muted-foreground",children:"API Key (optional)"}),e.jsx(A,{type:"password",value:p,onChange:o=>v(o.target.value),onBlur:P,placeholder:"For /v1/* API endpoints",className:"font-mono",disabled:s}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Used for API requests to /v1/chat/completions"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:"text-sm text-muted-foreground",children:"Management Key (optional)"}),e.jsx(A,{type:"password",value:m,onChange:o=>N(o.target.value),onBlur:l,placeholder:"For /v0/management/* endpoints",className:"font-mono",disabled:s}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Used for dashboard management APIs. Falls back to API Key if not set."})]}),e.jsxs("div",{className:"space-y-3 pt-2",children:[e.jsx(X,{onClick:x,disabled:n||!u,variant:"outline",className:"w-full",children:n?e.jsxs(e.Fragment,{children:[e.jsx(U,{className:"w-4 h-4 mr-2 animate-spin"}),"Testing..."]}):e.jsxs(e.Fragment,{children:[e.jsx(Se,{className:"w-4 h-4 mr-2"}),"Test Connection"]})}),d&&e.jsx("div",{className:`p-3 rounded-md ${d.reachable?"bg-green-50 border border-green-200 dark:bg-green-900/20 dark:border-green-900/50":"bg-red-50 border border-red-200 dark:bg-red-900/20 dark:border-red-900/50"}`,children:e.jsx("div",{className:"flex items-center gap-2",children:d.reachable?e.jsxs(e.Fragment,{children:[e.jsx(Q,{className:"w-4 h-4 text-green-600 dark:text-green-400"}),e.jsxs("span",{className:"text-sm font-medium text-green-700 dark:text-green-300",children:["Connected (",d.latencyMs,"ms)"]})]}):e.jsxs(e.Fragment,{children:[e.jsx(we,{className:"w-4 h-4 text-red-600 dark:text-red-400"}),e.jsx("span",{className:"text-sm font-medium text-red-700 dark:text-red-300",children:d.error||"Connection failed"})]})})})]})]})}const J="ccs_debug_mode",De=["kiro","ghcp"];function qe(){const{config:t,loading:s,saving:n,error:d,success:u,testResult:f,testing:p,editedHost:m,setEditedHost:b,editedPort:j,setEditedPort:v,editedAuthToken:N,setEditedAuthToken:k,editedManagementKey:C,setEditedManagementKey:P,editedLocalPort:l,setEditedLocalPort:i,fetchConfig:x,saveConfig:r,testConnection:S}=_e(),{fetchRawConfig:o}=Ne(),[w,ee]=c.useState(()=>{try{return localStorage.getItem(J)==="true"}catch{return!1}}),te=a=>{ee(a);try{localStorage.setItem(J,String(a))}catch{}},[y,B]=c.useState("plus"),[se,ae]=c.useState(!1),D=ke(),{data:re}=Ce(),E=re?.running??!1,K=c.useCallback(async()=>{try{const a=await L.cliproxyServer.getBackend();B(a.backend)}catch(a){console.error("[Proxy] Failed to fetch backend:",a)}},[]),R=c.useCallback(async()=>{try{const g=(await L.cliproxy.list()).variants.some(_=>De.includes(_.provider));ae(g)}catch(a){console.error("[Proxy] Failed to check variants:",a)}},[]),G=a=>{const g=y;B(a),D.mutate({backend:a},{onError:()=>{B(g)}})};if(c.useEffect(()=>{if(w&&t){const a={...t,remote:{...t.remote,auth_token:t.remote.auth_token?"[REDACTED]":void 0,management_key:t.remote.management_key?"[REDACTED]":void 0}};console.log("[CCS Debug] Debug mode enabled - proxy config:",a)}},[w,t]),c.useEffect(()=>{x(),o(),K(),R()},[x,o,K,R]),s||!t)return e.jsx("div",{className:"flex-1 flex items-center justify-center",children:e.jsxs("div",{className:"flex items-center gap-3 text-muted-foreground",children:[e.jsx(U,{className:"w-5 h-5 animate-spin"}),e.jsx("span",{children:"Loading..."})]})});const h=t.remote.enabled??!1,I=t.remote,T=t.fallback,oe=t.remote.host??"",ne=t.remote.port!==void 0?t.remote.port.toString():"",le=t.remote.auth_token??"",ce=t.remote.management_key??"",de=(t.local.port??8317).toString(),$=m??oe,F=j??ne,H=N??le,W=C??ce,z=l??de,ie=()=>{const a=m??$;a!==t.remote.host&&r({remote:{...I,host:a}}),b(null)},me=()=>{const a=j??F,g=a===""?void 0:parseInt(a,10),_=g&&!isNaN(g)&&g>0?g:void 0;_!==t.remote.port&&r({remote:{...I,port:_}}),v(null)},xe=()=>{const a=N??H;a!==t.remote.auth_token&&r({remote:{...I,auth_token:a}}),k(null)},ue=()=>{const a=C??W;a!==t.remote.management_key&&r({remote:{...I,management_key:a||void 0}}),P(null)},he=()=>{const a=parseInt(l??z,10);!isNaN(a)&&a!==t.local.port&&r({local:{...t.local,port:a}}),i(null)},pe=()=>{S({host:$,port:F,protocol:t.remote.protocol||"http",authToken:H})};return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:`absolute left-5 right-5 top-20 z-10 transition-all duration-200 ease-out ${d||u?"opacity-100 translate-y-0":"opacity-0 -translate-y-2 pointer-events-none"}`,children:[d&&e.jsxs(V,{variant:"destructive",className:"py-2 shadow-lg",children:[e.jsx(Ie,{className:"h-4 w-4"}),e.jsx(O,{children:d})]}),u&&e.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 rounded-md border border-green-200 bg-green-50 text-green-700 shadow-lg dark:border-green-900/50 dark:bg-green-900/90 dark:text-green-300",children:[e.jsx(Q,{className:"h-4 w-4 shrink-0"}),e.jsx("span",{className:"text-sm font-medium",children:"Saved"})]})]}),e.jsx(Pe,{className:"flex-1",children:e.jsxs("div",{className:"p-5 space-y-6",children:[e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Configure local or remote ",y==="plus"?"CLIProxy Plus":"CLIProxy"," connection for proxy-based profiles"]}),!h&&e.jsxs("div",{className:"space-y-3",children:[e.jsx("h3",{className:"text-base font-medium",children:"Instance Status"}),e.jsx(Le,{})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx("h3",{className:"text-base font-medium",children:"Connection Mode"}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("button",{onClick:()=>r({remote:{...I,enabled:!1}}),disabled:n,className:`p-4 rounded-lg border-2 text-left transition-all ${h?"border-border hover:border-muted-foreground/50":"border-primary bg-primary/5"}`,children:[e.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[e.jsx(Ee,{className:`w-5 h-5 ${h?"text-muted-foreground":"text-primary"}`}),e.jsx("span",{className:"font-medium",children:"Local"})]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Run ",y==="plus"?"CLIProxy Plus":"CLIProxy"," binary on this machine"]})]}),e.jsxs("button",{onClick:()=>r({remote:{...I,enabled:!0}}),disabled:n,className:`p-4 rounded-lg border-2 text-left transition-all ${h?"border-primary bg-primary/5":"border-border hover:border-muted-foreground/50"}`,children:[e.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[e.jsx(Z,{className:`w-5 h-5 ${h?"text-primary":"text-muted-foreground"}`}),e.jsx("span",{className:"font-medium",children:"Remote"})]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Connect to a remote ",y==="plus"?"CLIProxy Plus":"CLIProxy"," server"]})]})]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("h3",{className:"text-base font-medium flex items-center gap-2",children:[e.jsx(Te,{className:"w-4 h-4"}),"Backend Binary"]}),E&&e.jsxs(V,{className:"py-2 border-amber-200 bg-amber-50 dark:border-amber-900/50 dark:bg-amber-900/20 [&>svg]:top-2.5",children:[e.jsx(q,{className:"h-4 w-4 text-amber-600"}),e.jsx(O,{className:"text-amber-700 dark:text-amber-400",children:"Stop the running proxy in Instance Status to switch backend."})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("button",{onClick:()=>G("plus"),disabled:D.isPending||E,className:`p-4 rounded-lg border-2 text-left transition-all ${y==="plus"?"border-primary bg-primary/5":"border-border hover:border-muted-foreground/50"} ${E?"opacity-60 cursor-not-allowed":""}`,children:[e.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[e.jsx("span",{className:"font-medium",children:"CLIProxyAPIPlus"}),e.jsx("span",{className:"text-xs px-1.5 py-0.5 rounded bg-green-100 text-green-700 dark:bg-green-900/50 dark:text-green-400",children:"Default"})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Full provider support including Kiro and GitHub Copilot"})]}),e.jsxs("button",{onClick:()=>G("original"),disabled:D.isPending||E,className:`p-4 rounded-lg border-2 text-left transition-all ${y==="original"?"border-primary bg-primary/5":"border-border hover:border-muted-foreground/50"} ${E?"opacity-60 cursor-not-allowed":""}`,children:[e.jsx("div",{className:"flex items-center gap-3 mb-2",children:e.jsx("span",{className:"font-medium",children:"CLIProxyAPI"})}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Original binary (Gemini, Codex, Antigravity only)"})]})]}),y==="original"&&se&&e.jsxs(V,{variant:"destructive",className:"py-2",children:[e.jsx(q,{className:"h-4 w-4"}),e.jsx(O,{children:"Existing Kiro/Copilot variants will not work with CLIProxyAPI. Switch to CLIProxyAPIPlus or remove those variants."})]})]}),h&&e.jsx(Be,{config:t,saving:n,testing:p,testResult:f,displayHost:$,displayPort:F,displayAuthToken:H,displayManagementKey:W,setEditedHost:b,setEditedPort:v,setEditedAuthToken:k,setEditedManagementKey:P,onSaveHost:ie,onSavePort:me,onSaveAuthToken:xe,onSaveManagementKey:ue,onSaveConfig:r,onTestConnection:pe}),e.jsxs("div",{className:"space-y-3",children:[e.jsx("h3",{className:"text-base font-medium",children:"Fallback Settings"}),e.jsxs("div",{className:"space-y-3 p-4 rounded-lg border bg-muted/30",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-sm",children:"Enable fallback to local"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Use local proxy if remote is unreachable"})]}),e.jsx(M,{checked:T.enabled??!0,onCheckedChange:a=>r({fallback:{...T,enabled:a}}),disabled:n||!h})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-sm",children:"Auto-start local proxy"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Automatically start local proxy on fallback"})]}),e.jsx(M,{checked:T.auto_start??!1,onCheckedChange:a=>r({fallback:{...T,auto_start:a}}),disabled:n||!h||!T.enabled})]})]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("h3",{className:"text-base font-medium flex items-center gap-2",children:[e.jsx(Ae,{className:"w-4 h-4"}),"Advanced"]}),e.jsxs("div",{className:"space-y-3 p-4 rounded-lg border bg-muted/30",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-sm",children:"Debug Mode"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Enable developer diagnostics in browser console"})]}),e.jsx(M,{checked:w,onCheckedChange:te,disabled:n})]}),w&&e.jsx("p",{className:"text-xs text-amber-600 dark:text-amber-400 pl-0.5",children:"Debug mode enabled. Check browser console for detailed logs."})]})]}),!h&&e.jsx(Me,{config:t,saving:n,displayLocalPort:z,setEditedLocalPort:i,onSaveLocalPort:he,onSaveConfig:r})]})}),e.jsx("div",{className:"p-4 border-t bg-background",children:e.jsxs(X,{variant:"outline",size:"sm",onClick:()=>{x(),o(),K(),R()},disabled:s||n,className:"w-full",children:[e.jsx(U,{className:`w-4 h-4 mr-2 ${s?"animate-spin":""}`}),"Refresh"]})})]})}export{qe as default};
|