@kaitranntt/ccs 7.28.1-dev.1 → 7.28.2-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.
Files changed (52) hide show
  1. package/dist/auth/profile-detector.d.ts +1 -1
  2. package/dist/auth/profile-detector.d.ts.map +1 -1
  3. package/dist/auth/profile-detector.js +1 -0
  4. package/dist/auth/profile-detector.js.map +1 -1
  5. package/dist/cliproxy/auth/auth-types.d.ts.map +1 -1
  6. package/dist/cliproxy/auth/auth-types.js +10 -0
  7. package/dist/cliproxy/auth/auth-types.js.map +1 -1
  8. package/dist/cliproxy/auth/token-manager.d.ts.map +1 -1
  9. package/dist/cliproxy/auth/token-manager.js +10 -1
  10. package/dist/cliproxy/auth/token-manager.js.map +1 -1
  11. package/dist/cliproxy/config-generator.d.ts.map +1 -1
  12. package/dist/cliproxy/config-generator.js +1 -0
  13. package/dist/cliproxy/config-generator.js.map +1 -1
  14. package/dist/cliproxy/model-catalog.d.ts.map +1 -1
  15. package/dist/cliproxy/model-catalog.js +49 -0
  16. package/dist/cliproxy/model-catalog.js.map +1 -1
  17. package/dist/cliproxy/services/variant-config-adapter.js +1 -1
  18. package/dist/cliproxy/services/variant-config-adapter.js.map +1 -1
  19. package/dist/cliproxy/types.d.ts +2 -1
  20. package/dist/cliproxy/types.d.ts.map +1 -1
  21. package/dist/cliproxy/types.js.map +1 -1
  22. package/dist/config/unified-config-types.d.ts +1 -1
  23. package/dist/config/unified-config-types.d.ts.map +1 -1
  24. package/dist/management/oauth-port-diagnostics.d.ts.map +1 -1
  25. package/dist/management/oauth-port-diagnostics.js +13 -2
  26. package/dist/management/oauth-port-diagnostics.js.map +1 -1
  27. package/dist/types/config.d.ts +1 -1
  28. package/dist/types/config.d.ts.map +1 -1
  29. package/dist/ui/assets/{accounts-BOzNq5ee.js → accounts-Dx1GSmE5.js} +1 -1
  30. package/dist/ui/assets/{alert-dialog-Cb5PMEBl.js → alert-dialog-Bn6K2nsn.js} +1 -1
  31. package/dist/ui/assets/{api-Dve5qAOP.js → api-Cp9G3vp7.js} +1 -1
  32. package/dist/ui/assets/{auth-section-Cpc5CmnT.js → auth-section-DD7GA40Q.js} +1 -1
  33. package/dist/ui/assets/{backups-section-DUZ2HR46.js → backups-section-BhQu2E4b.js} +1 -1
  34. package/dist/ui/assets/cliproxy-DYjT8MVB.js +3 -0
  35. package/dist/ui/assets/{cliproxy-control-panel-D8brA7Zn.js → cliproxy-control-panel-CzEcwQpU.js} +1 -1
  36. package/dist/ui/assets/{confirm-dialog-0Zy9TN_K.js → confirm-dialog-DXOlh68I.js} +1 -1
  37. package/dist/ui/assets/{copilot-C2Q9oafS.js → copilot-B40z4Wb2.js} +2 -2
  38. package/dist/ui/assets/{globalenv-section-g_Bh1_Vi.js → globalenv-section-DM5NsLUS.js} +1 -1
  39. package/dist/ui/assets/{health-BfdjLTeV.js → health-BV9rZ_Ya.js} +1 -1
  40. package/dist/ui/assets/{index-DX32Yp2A.js → index-BKqrprbn.js} +1 -1
  41. package/dist/ui/assets/{index-326cTntS.js → index-BtaYToht.js} +1 -1
  42. package/dist/ui/assets/{index-CErLyTsQ.js → index-D7Pl56Ob.js} +3 -3
  43. package/dist/ui/assets/{index-B9LdCgpr.js → index-DANNDDO3.js} +1 -1
  44. package/dist/ui/assets/{index-C-e4p8-0.js → index-DRPh4nzV.js} +1 -1
  45. package/dist/ui/assets/providers/claude.svg +1 -0
  46. package/dist/ui/assets/{proxy-status-widget-BBhLPlDp.js → proxy-status-widget-P-1knrgv.js} +1 -1
  47. package/dist/ui/assets/{shared-ogUMuADx.js → shared-DG32MUkN.js} +1 -1
  48. package/dist/ui/assets/{switch-DVMOWp74.js → switch-D0G-SCdh.js} +1 -1
  49. package/dist/ui/index.html +1 -1
  50. package/lib/hooks/websearch-transformer.cjs +15 -1
  51. package/package.json +1 -1
  52. package/dist/ui/assets/cliproxy-DaYarYV8.js +0 -3
@@ -1 +1 @@
1
- import{j as e}from"./radix-ui-qEZD5MMp.js";import{r as c}from"./react-vendor-CNOkPC89.js";import{aM as ge,aN as fe,ap as L,I as A,X as ye,Y as be,Z as je,_ as ve,$ as Y,b as Q,aO as Ne,aP as ke,aQ as Ce,aJ as O,aL as V,m as Pe}from"./index-CErLyTsQ.js";import{S as M}from"./switch-DVMOWp74.js";import{aA as X,a6 as U,e as Se,p as Z,W as we,a0 as Ie,aB as Ee,aC as Te,T as q,aD as Ae}from"./icons-C6UNjkCT.js";import{P as Le}from"./proxy-status-widget-BBhLPlDp.js";import"./tanstack-De4wvi8X.js";import"./notifications-B2HqRBj7.js";import"./utils-CzKF5WmX.js";import"./form-utils-C-pVd1--.js";import"./code-highlight-BRUf_pqB.js";import"./alert-dialog-Cb5PMEBl.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(X,{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(Q,{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(Z,{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,R=c.useCallback(async()=>{try{const a=await L.cliproxyServer.getBackend();B(a.backend)}catch(a){console.error("[Proxy] Failed to fetch backend:",a)}},[]),K=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(),R(),K()},[x,o,R,K]),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(O,{variant:"destructive",className:"py-2 shadow-lg",children:[e.jsx(Ie,{className:"h-4 w-4"}),e.jsx(V,{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(Z,{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(X,{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(O,{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(V,{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(O,{variant:"destructive",className:"py-2",children:[e.jsx(q,{className:"h-4 w-4"}),e.jsx(V,{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(Q,{variant:"outline",size:"sm",onClick:()=>{x(),o(),R(),K()},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};
1
+ import{j as e}from"./radix-ui-qEZD5MMp.js";import{r as c}from"./react-vendor-CNOkPC89.js";import{aM as ge,aN as fe,ap as L,I as A,X as ye,Y as be,Z as je,_ as ve,$ as Y,b as Q,aO as Ne,aP as ke,aQ as Ce,aJ as O,aL as V,m as Pe}from"./index-D7Pl56Ob.js";import{S as M}from"./switch-D0G-SCdh.js";import{aA as X,a6 as U,e as Se,p as Z,W as we,a0 as Ie,aB as Ee,aC as Te,T as q,aD as Ae}from"./icons-C6UNjkCT.js";import{P as Le}from"./proxy-status-widget-P-1knrgv.js";import"./tanstack-De4wvi8X.js";import"./notifications-B2HqRBj7.js";import"./utils-CzKF5WmX.js";import"./form-utils-C-pVd1--.js";import"./code-highlight-BRUf_pqB.js";import"./alert-dialog-Bn6K2nsn.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(X,{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(Q,{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(Z,{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,R=c.useCallback(async()=>{try{const a=await L.cliproxyServer.getBackend();B(a.backend)}catch(a){console.error("[Proxy] Failed to fetch backend:",a)}},[]),K=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(),R(),K()},[x,o,R,K]),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(O,{variant:"destructive",className:"py-2 shadow-lg",children:[e.jsx(Ie,{className:"h-4 w-4"}),e.jsx(V,{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(Z,{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(X,{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(O,{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(V,{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(O,{variant:"destructive",className:"py-2",children:[e.jsx(q,{className:"h-4 w-4"}),e.jsx(V,{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(Q,{variant:"outline",size:"sm",onClick:()=>{x(),o(),R(),K()},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};
@@ -1 +1 @@
1
- import{j as e}from"./radix-ui-qEZD5MMp.js";import{r as i}from"./react-vendor-CNOkPC89.js";import{aM as $,aN as P,I as F,aO as U,aJ as _,aL as B,m as K,b as A}from"./index-CErLyTsQ.js";import{S as z}from"./switch-DVMOWp74.js";import{x as q,j as D,Q as J,V,m as Y,a6 as L,a0 as Q,p as X}from"./icons-C6UNjkCT.js";import"./tanstack-De4wvi8X.js";import"./notifications-B2HqRBj7.js";import"./utils-CzKF5WmX.js";import"./form-utils-C-pVd1--.js";import"./code-highlight-BRUf_pqB.js";function Z(){const{state:s}=$(),a=P(),[d,l]=i.useState(""),[o,m]=i.useState(""),[f,h]=i.useState(!1),[j,u]=i.useState(!1),S=i.useCallback(async()=>{try{a.setWebSearchLoading(!0),a.setWebSearchError(null);const t=await fetch("/api/websearch");if(!t.ok)throw new Error("Failed to load WebSearch config");const r=await t.json();a.setWebSearchConfig(r)}catch(t){a.setWebSearchError(t.message)}finally{a.setWebSearchLoading(!1)}},[a]),v=i.useCallback(async()=>{try{a.setWebSearchStatusLoading(!0);const t=await fetch("/api/websearch/status");if(!t.ok)throw new Error("Failed to load status");const r=await t.json();a.setWebSearchStatus(r)}catch{}finally{a.setWebSearchStatusLoading(!1)}},[a]),p=i.useCallback(async t=>{const r=s.webSearchConfig;if(!r)return;const w={...r,...t};a.setWebSearchConfig(w);try{a.setWebSearchSaving(!0),a.setWebSearchError(null);const n=await fetch("/api/websearch",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(w)});if(!n.ok){const k=await n.json();throw new Error(k.error||"Failed to save")}const C=await n.json();a.setWebSearchConfig(C.websearch),a.setWebSearchSuccess(!0),setTimeout(()=>a.setWebSearchSuccess(!1),1500)}catch(n){a.setWebSearchConfig(r),a.setWebSearchError(n.message)}finally{a.setWebSearchSaving(!1)}},[s.webSearchConfig,a]);i.useEffect(()=>{s.webSearchConfig&&(l(s.webSearchConfig.providers?.gemini?.model??"gemini-2.5-flash"),m(s.webSearchConfig.providers?.opencode?.model??"opencode/grok-code"))},[s.webSearchConfig]);const x=i.useCallback(async()=>{const t=s.webSearchConfig?.providers?.gemini?.model??"gemini-2.5-flash";if(d!==t){const r=s.webSearchConfig?.providers||{};await p({providers:{...r,gemini:{...r.gemini,model:d}}}),h(!0),setTimeout(()=>h(!1),2e3)}},[d,s.webSearchConfig,p]),g=i.useCallback(async()=>{const t=s.webSearchConfig?.providers?.opencode?.model??"opencode/grok-code";if(o!==t){const r=s.webSearchConfig?.providers||{};await p({providers:{...r,opencode:{...r.opencode,model:o}}}),u(!0),setTimeout(()=>u(!1),2e3)}},[o,s.webSearchConfig,p]);return{config:s.webSearchConfig,status:s.webSearchStatus,loading:s.webSearchLoading,statusLoading:s.webSearchStatusLoading,saving:s.webSearchSaving,error:s.webSearchError,success:s.webSearchSuccess,geminiModelInput:d,setGeminiModelInput:l,opencodeModelInput:o,setOpencodeModelInput:m,geminiModelSaved:f,opencodeModelSaved:j,fetchConfig:S,fetchStatus:v,saveConfig:p,saveGeminiModel:x,saveOpencodeModel:g}}function O({name:s,label:a,badge:d,badgeColor:l,enabled:o,installed:m,statusLoading:f,saving:h,onToggle:j,modelInput:u,setModelInput:S,onModelBlur:v,modelSaved:p,modelPlaceholder:x,showHint:g,setShowHint:t,installCmd:r,docsUrl:w,hintColor:n}){const C=l==="green"?"bg-green-500/10 text-green-600":l==="blue"?"bg-blue-500/10 text-blue-600":"bg-purple-500/10 text-purple-600",k=n==="amber"?"bg-amber-50 dark:bg-amber-900/20 text-amber-700 dark:text-amber-300":n==="blue"?"bg-blue-50 dark:bg-blue-900/20 text-blue-700 dark:text-blue-300":"bg-purple-50 dark:bg-purple-900/20 text-purple-700 dark:text-purple-300",y=n==="amber"?"bg-amber-100 dark:bg-amber-900/40":n==="blue"?"bg-blue-100 dark:bg-blue-900/40":"bg-purple-100 dark:bg-purple-900/40",E=n==="amber"?"text-amber-600 dark:text-amber-400":n==="blue"?"text-blue-600 dark:text-blue-400":"text-purple-600 dark:text-purple-400",M=s==="opencode"?"OpenCode":s.charAt(0).toUpperCase()+s.slice(1);return e.jsxs("div",{className:`rounded-lg border transition-colors ${o?"border-primary border-l-4":"border-border"}`,children:[e.jsxs("div",{className:"flex items-center justify-between p-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(q,{className:`w-5 h-5 ${o?"text-primary":"text-muted-foreground"}`}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("p",{className:"font-mono font-medium",children:s}),e.jsx("span",{className:`text-xs px-1.5 py-0.5 rounded font-medium ${C}`,children:d}),m?e.jsx("span",{className:"text-xs px-1.5 py-0.5 rounded bg-green-500/10 text-green-600 font-medium",children:"installed"}):e.jsx("span",{className:"text-xs px-1.5 py-0.5 rounded bg-amber-500/10 text-amber-600 font-medium",children:"not installed"})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:a})]})]}),e.jsx(z,{checked:o,onCheckedChange:j,disabled:h||!m})]}),o&&u!==void 0&&S&&v&&e.jsx("div",{className:"px-4 pb-4 pt-0",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("label",{className:"text-sm text-muted-foreground whitespace-nowrap",children:"Model:"}),e.jsx(F,{value:u,onChange:I=>S(I.target.value),onBlur:v,placeholder:x,className:"h-8 text-sm font-mono",disabled:h}),p&&e.jsxs("span",{className:"flex items-center gap-1 text-green-600 dark:text-green-400 text-xs animate-in fade-in duration-200",children:[e.jsx(D,{className:"w-3.5 h-3.5"}),"Saved"]})]})}),!m&&!f&&e.jsxs("div",{className:"px-4 pb-4 pt-0 border-t border-border/50",children:[e.jsxs("button",{onClick:()=>t(!g),className:`flex items-center gap-2 text-sm hover:underline w-full py-2 ${E}`,children:[g?e.jsx(J,{className:"w-4 h-4"}):e.jsx(V,{className:"w-4 h-4"}),"How to install ",M," CLI"]}),g&&e.jsxs("div",{className:`mt-2 p-3 rounded-md text-sm ${k}`,children:[e.jsxs("p",{className:"mb-2",children:["Install globally"," ",d==="GROK_API_KEY"?"(requires xAI API key)":"(FREE tier available)",":"]}),e.jsx("code",{className:`text-sm px-2 py-1 rounded font-mono block mb-2 ${y}`,children:r}),e.jsxs("a",{href:w,target:"_blank",rel:"noopener noreferrer",className:"hover:underline inline-flex items-center gap-1",children:[e.jsx(Y,{className:"w-3 h-3"}),"View documentation"]})]})]})]})}function ce(){const{config:s,status:a,loading:d,statusLoading:l,saving:o,error:m,success:f,geminiModelInput:h,setGeminiModelInput:j,opencodeModelInput:u,setOpencodeModelInput:S,geminiModelSaved:v,opencodeModelSaved:p,fetchConfig:x,fetchStatus:g,saveConfig:t,saveGeminiModel:r,saveOpencodeModel:w}=Z(),{fetchRawConfig:n}=U(),[C,k]=i.useState(!1),[y,E]=i.useState(!1),[M,I]=i.useState(!1);i.useEffect(()=>{x(),g(),n()},[x,g,n]);const N=s?.providers?.gemini?.enabled??!1,W=s?.providers?.grok?.enabled??!1,G=s?.providers?.opencode?.enabled??!1,H=()=>{const c=s?.providers||{},b=c.gemini?.enabled??!1;t({enabled:!b||W||G,providers:{...c,gemini:{...c.gemini,enabled:!b}}})},R=()=>{const c=s?.providers||{},b=c.grok?.enabled??!1;t({enabled:N||!b||G,providers:{...c,grok:{...c.grok,enabled:!b}}})},T=()=>{const c=s?.providers||{},b=c.opencode?.enabled??!1;t({enabled:N||W||!b,providers:{...c,opencode:{...c.opencode,enabled:!b}}})};return d?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(L,{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 ${m||f?"opacity-100 translate-y-0":"opacity-0 -translate-y-2 pointer-events-none"}`,children:[m&&e.jsxs(_,{variant:"destructive",className:"py-2 shadow-lg",children:[e.jsx(Q,{className:"h-4 w-4"}),e.jsx(B,{children:m})]}),f&&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:"Saved"})]})]}),e.jsx(K,{className:"flex-1",children:e.jsxs("div",{className:"p-5 space-y-6",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"CLI-based web search for third-party profiles (gemini, codex, agy, 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:N?"WebSearch enabled":"WebSearch disabled"}),l?e.jsx("p",{className:"text-sm text-muted-foreground",children:"Checking status..."}):a?.readiness?e.jsx("p",{className:"text-sm text-muted-foreground",children:a.readiness.message}):null]}),e.jsx(A,{variant:"ghost",size:"sm",onClick:g,disabled:l,children:e.jsx(L,{className:`w-4 h-4 ${l?"animate-spin":""}`})})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx("h3",{className:"text-base font-medium",children:"Providers"}),e.jsx(O,{name:"gemini",label:"Google Gemini CLI (1000 req/day free)",badge:"FREE",badgeColor:"green",enabled:N,installed:a?.geminiCli?.installed??!1,statusLoading:l,saving:o,onToggle:H,modelInput:h,setModelInput:j,onModelBlur:r,modelSaved:v,modelPlaceholder:"gemini-2.5-flash",showHint:C,setShowHint:k,installCmd:"npm install -g @google/gemini-cli",docsUrl:"https://github.com/google-gemini/gemini-cli",hintColor:"amber"}),e.jsx(O,{name:"opencode",label:"OpenCode (web search via Zen)",badge:"FREE",badgeColor:"green",enabled:G,installed:a?.opencodeCli?.installed??!1,statusLoading:l,saving:o,onToggle:T,modelInput:u,setModelInput:S,onModelBlur:w,modelSaved:p,modelPlaceholder:"opencode/grok-code",showHint:y,setShowHint:E,installCmd:"curl -fsSL https://opencode.ai/install | bash",docsUrl:"https://github.com/sst/opencode",hintColor:"purple"}),e.jsx(O,{name:"grok",label:"xAI Grok CLI (web + X search)",badge:"GROK_API_KEY",badgeColor:"blue",enabled:W,installed:a?.grokCli?.installed??!1,statusLoading:l,saving:o,onToggle:R,showHint:M,setShowHint:I,installCmd:"npm install -g @vibe-kit/grok-cli",docsUrl:"https://github.com/superagent-ai/grok-cli",hintColor:"blue"})]})]})}),e.jsx("div",{className:"p-4 border-t bg-background",children:e.jsxs(A,{variant:"outline",size:"sm",onClick:()=>{x(),n()},disabled:d||o,className:"w-full",children:[e.jsx(L,{className:`w-4 h-4 mr-2 ${d?"animate-spin":""}`}),"Refresh"]})})]})}export{ce as default};
1
+ import{j as e}from"./radix-ui-qEZD5MMp.js";import{r as i}from"./react-vendor-CNOkPC89.js";import{aM as $,aN as P,I as F,aO as U,aJ as _,aL as B,m as K,b as A}from"./index-D7Pl56Ob.js";import{S as z}from"./switch-D0G-SCdh.js";import{x as q,j as D,Q as J,V,m as Y,a6 as L,a0 as Q,p as X}from"./icons-C6UNjkCT.js";import"./tanstack-De4wvi8X.js";import"./notifications-B2HqRBj7.js";import"./utils-CzKF5WmX.js";import"./form-utils-C-pVd1--.js";import"./code-highlight-BRUf_pqB.js";function Z(){const{state:s}=$(),a=P(),[d,l]=i.useState(""),[o,m]=i.useState(""),[f,h]=i.useState(!1),[j,u]=i.useState(!1),S=i.useCallback(async()=>{try{a.setWebSearchLoading(!0),a.setWebSearchError(null);const t=await fetch("/api/websearch");if(!t.ok)throw new Error("Failed to load WebSearch config");const r=await t.json();a.setWebSearchConfig(r)}catch(t){a.setWebSearchError(t.message)}finally{a.setWebSearchLoading(!1)}},[a]),v=i.useCallback(async()=>{try{a.setWebSearchStatusLoading(!0);const t=await fetch("/api/websearch/status");if(!t.ok)throw new Error("Failed to load status");const r=await t.json();a.setWebSearchStatus(r)}catch{}finally{a.setWebSearchStatusLoading(!1)}},[a]),p=i.useCallback(async t=>{const r=s.webSearchConfig;if(!r)return;const w={...r,...t};a.setWebSearchConfig(w);try{a.setWebSearchSaving(!0),a.setWebSearchError(null);const n=await fetch("/api/websearch",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(w)});if(!n.ok){const k=await n.json();throw new Error(k.error||"Failed to save")}const C=await n.json();a.setWebSearchConfig(C.websearch),a.setWebSearchSuccess(!0),setTimeout(()=>a.setWebSearchSuccess(!1),1500)}catch(n){a.setWebSearchConfig(r),a.setWebSearchError(n.message)}finally{a.setWebSearchSaving(!1)}},[s.webSearchConfig,a]);i.useEffect(()=>{s.webSearchConfig&&(l(s.webSearchConfig.providers?.gemini?.model??"gemini-2.5-flash"),m(s.webSearchConfig.providers?.opencode?.model??"opencode/grok-code"))},[s.webSearchConfig]);const x=i.useCallback(async()=>{const t=s.webSearchConfig?.providers?.gemini?.model??"gemini-2.5-flash";if(d!==t){const r=s.webSearchConfig?.providers||{};await p({providers:{...r,gemini:{...r.gemini,model:d}}}),h(!0),setTimeout(()=>h(!1),2e3)}},[d,s.webSearchConfig,p]),g=i.useCallback(async()=>{const t=s.webSearchConfig?.providers?.opencode?.model??"opencode/grok-code";if(o!==t){const r=s.webSearchConfig?.providers||{};await p({providers:{...r,opencode:{...r.opencode,model:o}}}),u(!0),setTimeout(()=>u(!1),2e3)}},[o,s.webSearchConfig,p]);return{config:s.webSearchConfig,status:s.webSearchStatus,loading:s.webSearchLoading,statusLoading:s.webSearchStatusLoading,saving:s.webSearchSaving,error:s.webSearchError,success:s.webSearchSuccess,geminiModelInput:d,setGeminiModelInput:l,opencodeModelInput:o,setOpencodeModelInput:m,geminiModelSaved:f,opencodeModelSaved:j,fetchConfig:S,fetchStatus:v,saveConfig:p,saveGeminiModel:x,saveOpencodeModel:g}}function O({name:s,label:a,badge:d,badgeColor:l,enabled:o,installed:m,statusLoading:f,saving:h,onToggle:j,modelInput:u,setModelInput:S,onModelBlur:v,modelSaved:p,modelPlaceholder:x,showHint:g,setShowHint:t,installCmd:r,docsUrl:w,hintColor:n}){const C=l==="green"?"bg-green-500/10 text-green-600":l==="blue"?"bg-blue-500/10 text-blue-600":"bg-purple-500/10 text-purple-600",k=n==="amber"?"bg-amber-50 dark:bg-amber-900/20 text-amber-700 dark:text-amber-300":n==="blue"?"bg-blue-50 dark:bg-blue-900/20 text-blue-700 dark:text-blue-300":"bg-purple-50 dark:bg-purple-900/20 text-purple-700 dark:text-purple-300",y=n==="amber"?"bg-amber-100 dark:bg-amber-900/40":n==="blue"?"bg-blue-100 dark:bg-blue-900/40":"bg-purple-100 dark:bg-purple-900/40",E=n==="amber"?"text-amber-600 dark:text-amber-400":n==="blue"?"text-blue-600 dark:text-blue-400":"text-purple-600 dark:text-purple-400",M=s==="opencode"?"OpenCode":s.charAt(0).toUpperCase()+s.slice(1);return e.jsxs("div",{className:`rounded-lg border transition-colors ${o?"border-primary border-l-4":"border-border"}`,children:[e.jsxs("div",{className:"flex items-center justify-between p-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(q,{className:`w-5 h-5 ${o?"text-primary":"text-muted-foreground"}`}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("p",{className:"font-mono font-medium",children:s}),e.jsx("span",{className:`text-xs px-1.5 py-0.5 rounded font-medium ${C}`,children:d}),m?e.jsx("span",{className:"text-xs px-1.5 py-0.5 rounded bg-green-500/10 text-green-600 font-medium",children:"installed"}):e.jsx("span",{className:"text-xs px-1.5 py-0.5 rounded bg-amber-500/10 text-amber-600 font-medium",children:"not installed"})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:a})]})]}),e.jsx(z,{checked:o,onCheckedChange:j,disabled:h||!m})]}),o&&u!==void 0&&S&&v&&e.jsx("div",{className:"px-4 pb-4 pt-0",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("label",{className:"text-sm text-muted-foreground whitespace-nowrap",children:"Model:"}),e.jsx(F,{value:u,onChange:I=>S(I.target.value),onBlur:v,placeholder:x,className:"h-8 text-sm font-mono",disabled:h}),p&&e.jsxs("span",{className:"flex items-center gap-1 text-green-600 dark:text-green-400 text-xs animate-in fade-in duration-200",children:[e.jsx(D,{className:"w-3.5 h-3.5"}),"Saved"]})]})}),!m&&!f&&e.jsxs("div",{className:"px-4 pb-4 pt-0 border-t border-border/50",children:[e.jsxs("button",{onClick:()=>t(!g),className:`flex items-center gap-2 text-sm hover:underline w-full py-2 ${E}`,children:[g?e.jsx(J,{className:"w-4 h-4"}):e.jsx(V,{className:"w-4 h-4"}),"How to install ",M," CLI"]}),g&&e.jsxs("div",{className:`mt-2 p-3 rounded-md text-sm ${k}`,children:[e.jsxs("p",{className:"mb-2",children:["Install globally"," ",d==="GROK_API_KEY"?"(requires xAI API key)":"(FREE tier available)",":"]}),e.jsx("code",{className:`text-sm px-2 py-1 rounded font-mono block mb-2 ${y}`,children:r}),e.jsxs("a",{href:w,target:"_blank",rel:"noopener noreferrer",className:"hover:underline inline-flex items-center gap-1",children:[e.jsx(Y,{className:"w-3 h-3"}),"View documentation"]})]})]})]})}function ce(){const{config:s,status:a,loading:d,statusLoading:l,saving:o,error:m,success:f,geminiModelInput:h,setGeminiModelInput:j,opencodeModelInput:u,setOpencodeModelInput:S,geminiModelSaved:v,opencodeModelSaved:p,fetchConfig:x,fetchStatus:g,saveConfig:t,saveGeminiModel:r,saveOpencodeModel:w}=Z(),{fetchRawConfig:n}=U(),[C,k]=i.useState(!1),[y,E]=i.useState(!1),[M,I]=i.useState(!1);i.useEffect(()=>{x(),g(),n()},[x,g,n]);const N=s?.providers?.gemini?.enabled??!1,W=s?.providers?.grok?.enabled??!1,G=s?.providers?.opencode?.enabled??!1,H=()=>{const c=s?.providers||{},b=c.gemini?.enabled??!1;t({enabled:!b||W||G,providers:{...c,gemini:{...c.gemini,enabled:!b}}})},R=()=>{const c=s?.providers||{},b=c.grok?.enabled??!1;t({enabled:N||!b||G,providers:{...c,grok:{...c.grok,enabled:!b}}})},T=()=>{const c=s?.providers||{},b=c.opencode?.enabled??!1;t({enabled:N||W||!b,providers:{...c,opencode:{...c.opencode,enabled:!b}}})};return d?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(L,{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 ${m||f?"opacity-100 translate-y-0":"opacity-0 -translate-y-2 pointer-events-none"}`,children:[m&&e.jsxs(_,{variant:"destructive",className:"py-2 shadow-lg",children:[e.jsx(Q,{className:"h-4 w-4"}),e.jsx(B,{children:m})]}),f&&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:"Saved"})]})]}),e.jsx(K,{className:"flex-1",children:e.jsxs("div",{className:"p-5 space-y-6",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"CLI-based web search for third-party profiles (gemini, codex, agy, 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:N?"WebSearch enabled":"WebSearch disabled"}),l?e.jsx("p",{className:"text-sm text-muted-foreground",children:"Checking status..."}):a?.readiness?e.jsx("p",{className:"text-sm text-muted-foreground",children:a.readiness.message}):null]}),e.jsx(A,{variant:"ghost",size:"sm",onClick:g,disabled:l,children:e.jsx(L,{className:`w-4 h-4 ${l?"animate-spin":""}`})})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx("h3",{className:"text-base font-medium",children:"Providers"}),e.jsx(O,{name:"gemini",label:"Google Gemini CLI (1000 req/day free)",badge:"FREE",badgeColor:"green",enabled:N,installed:a?.geminiCli?.installed??!1,statusLoading:l,saving:o,onToggle:H,modelInput:h,setModelInput:j,onModelBlur:r,modelSaved:v,modelPlaceholder:"gemini-2.5-flash",showHint:C,setShowHint:k,installCmd:"npm install -g @google/gemini-cli",docsUrl:"https://github.com/google-gemini/gemini-cli",hintColor:"amber"}),e.jsx(O,{name:"opencode",label:"OpenCode (web search via Zen)",badge:"FREE",badgeColor:"green",enabled:G,installed:a?.opencodeCli?.installed??!1,statusLoading:l,saving:o,onToggle:T,modelInput:u,setModelInput:S,onModelBlur:w,modelSaved:p,modelPlaceholder:"opencode/grok-code",showHint:y,setShowHint:E,installCmd:"curl -fsSL https://opencode.ai/install | bash",docsUrl:"https://github.com/sst/opencode",hintColor:"purple"}),e.jsx(O,{name:"grok",label:"xAI Grok CLI (web + X search)",badge:"GROK_API_KEY",badgeColor:"blue",enabled:W,installed:a?.grokCli?.installed??!1,statusLoading:l,saving:o,onToggle:R,showHint:M,setShowHint:I,installCmd:"npm install -g @vibe-kit/grok-cli",docsUrl:"https://github.com/superagent-ai/grok-cli",hintColor:"blue"})]})]})}),e.jsx("div",{className:"p-4 border-t bg-background",children:e.jsxs(A,{variant:"outline",size:"sm",onClick:()=>{x(),n()},disabled:d||o,className:"w-full",children:[e.jsx(L,{className:`w-4 h-4 mr-2 ${d?"animate-spin":""}`}),"Refresh"]})})]})}export{ce as default};
@@ -0,0 +1 @@
1
+ <svg height="1em" style="flex:none;line-height:1" viewBox="0 0 24 24" width="1em" xmlns="http://www.w3.org/2000/svg"><title>Claude</title><path d="M4.709 15.955l4.72-2.647.08-.23-.08-.128H9.2l-.79-.048-2.698-.073-2.339-.097-2.266-.122-.571-.121L0 11.784l.055-.352.48-.321.686.06 1.52.103 2.278.158 1.652.097 2.449.255h.389l.055-.157-.134-.098-.103-.097-2.358-1.596-2.552-1.688-1.336-.972-.724-.491-.364-.462-.158-1.008.656-.722.881.06.225.061.893.686 1.908 1.476 2.491 1.833.365.304.145-.103.019-.073-.164-.274-1.355-2.446-1.446-2.49-.644-1.032-.17-.619a2.97 2.97 0 01-.104-.729L6.283.134 6.696 0l.996.134.42.364.62 1.414 1.002 2.229 1.555 3.03.456.898.243.832.091.255h.158V9.01l.128-1.706.237-2.095.23-2.695.08-.76.376-.91.747-.492.584.28.48.685-.067.444-.286 1.851-.559 2.903-.364 1.942h.212l.243-.242.985-1.306 1.652-2.064.73-.82.85-.904.547-.431h1.033l.76 1.129-.34 1.166-1.064 1.347-.881 1.142-1.264 1.7-.79 1.36.073.11.188-.02 2.856-.606 1.543-.28 1.841-.315.833.388.091.395-.328.807-1.969.486-2.309.462-3.439.813-.042.03.049.061 1.549.146.662.036h1.622l3.02.225.79.522.474.638-.079.485-1.215.62-1.64-.389-3.829-.91-1.312-.329h-.182v.11l1.093 1.068 2.006 1.81 2.509 2.33.127.578-.322.455-.34-.049-2.205-1.657-.851-.747-1.926-1.62h-.128v.17l.444.649 2.345 3.521.122 1.08-.17.353-.608.213-.668-.122-1.374-1.925-1.415-2.167-1.143-1.943-.14.08-.674 7.254-.316.37-.729.28-.607-.461-.322-.747.322-1.476.389-1.924.315-1.53.286-1.9.17-.632-.012-.042-.14.018-1.434 1.967-2.18 2.945-1.726 1.845-.414.164-.717-.37.067-.662.401-.589 2.388-3.036 1.44-1.882.93-1.086-.006-.158h-.055L4.132 18.56l-1.13.146-.487-.456.061-.746.231-.243 1.908-1.312-.006.006z" fill="#D97757" fill-rule="nonzero"></path></svg>
@@ -1 +1 @@
1
- import{j as e}from"./radix-ui-qEZD5MMp.js";import{r as f}from"./react-vendor-CNOkPC89.js";import{aQ as G,aw as H,aR as K,aS as O,aT as Q,aU as X,aV as Y,c as m,B as T,ag as W,E as Z,G as _,X as J,Y as ee,Z as se,_ as te,$ as ae,b as k,T as ne,o as re,p as ie,ap as oe}from"./index-CErLyTsQ.js";import{A as le,a as ce,b as de,c as xe,d as me,e as ue,f as he,g as ge}from"./alert-dialog-Cb5PMEBl.js";import{u as pe,e as be}from"./tanstack-De4wvi8X.js";import{a1 as fe,A as je,a6 as j,aE as Ne,aF as ve,X as we,S as Ce,aG as Se,aH as ye,U as ke,u as Pe,ao as Ve,T as I,av as Ae}from"./icons-C6UNjkCT.js";function S(t,i){const a=t.replace(/-\d+$/,"").split(".").map(Number),s=i.replace(/-\d+$/,"").split(".").map(Number);for(let r=0;r<3;r++){if((a[r]||0)>(s[r]||0))return!0;if((a[r]||0)<(s[r]||0))return!1}return!1}function De(t){if(!t)return"";const i=new Date(t).getTime(),s=Date.now()-i,r=Math.floor(s/(1e3*60*60)),o=Math.floor(s%(1e3*60*60)/(1e3*60));return r>0?`${r}h ${o}m`:`${o}m`}function Ue(t){if(!t)return"";const i=Date.now()-t,a=Math.floor(i/(1e3*60)),s=Math.floor(i/(1e3*60*60));return a<1?"just now":a<60?`${a}m ago`:`${s}h ago`}function y({icon:t,tooltip:i,onClick:a,disabled:s,isPending:r,className:o,variant:l="ghost"}){return e.jsxs(ne,{children:[e.jsx(re,{asChild:!0,children:e.jsx(k,{variant:l==="destructive-ghost"?"ghost":l,size:"sm",className:m("h-7 w-7 p-0",l==="destructive-ghost"&&"hover:bg-destructive/10 hover:text-destructive hover:border-destructive/30",o),onClick:a,disabled:s,children:r?e.jsx(j,{className:"w-3.5 h-3.5 animate-spin"}):e.jsx(t,{className:"w-3.5 h-3.5"})})}),e.jsx(ie,{side:"bottom",className:"text-xs",children:i})]})}function Le(){const{data:t,isLoading:i}=G(),{data:a}=H(),{data:s,isLoading:r}=K(),o=O(),l=Q(),N=X(),u=Y(),[h,P]=f.useState(!1),[g,$]=f.useState(""),[R,b]=f.useState(!1),[v,w]=f.useState(null),{data:M}=pe({queryKey:["cliproxy-server-config"],queryFn:()=>oe.cliproxyServer.get(),staleTime:3e4}),E=be({mutationKey:["update-backend"]})>0,d=M?.remote,V=d?.enabled&&d?.host,p=t?.running??!1,A=o.isPending||l.isPending||N.isPending||u.isPending||E,L=a?.hasUpdate??!1,x=a?.isStable===!1,D=a?.currentVersion,C=x?a?.maxStableVersion||s?.latestStable:a?.latestVersion,U=n=>{if(!n)return;const c=s?.maxStableVersion||"6.6.80";if(S(n,c)){w(n),b(!0);return}u.mutate({version:n})},B=()=>{v&&u.mutate({version:v,force:!0}),b(!1),w(null)},F=()=>{b(!1),w(null)},q=V?(()=>{const n=d.protocol||"http",c=d.port||(n==="https"?443:80);return n==="https"&&c===443||n==="http"&&c===80?d.host:`${d.host}:${c}`})():null;return V?e.jsxs("div",{className:m("rounded-lg border p-3 transition-colors","border-blue-500/30 bg-blue-500/5"),children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(fe,{className:"w-4 h-4 text-blue-500"}),e.jsx("span",{className:"text-sm font-medium",children:"Remote Proxy"}),e.jsx(T,{variant:"secondary",className:"text-[10px] h-4 px-1.5 bg-blue-100 text-blue-700 dark:bg-blue-900/30 dark:text-blue-400",children:"Active"})]}),e.jsx(je,{className:"w-3 h-3 text-blue-600"})]}),e.jsxs("div",{className:"mt-2 text-xs text-muted-foreground",children:[e.jsx("div",{className:"flex items-center gap-1 mb-1",children:e.jsx("span",{className:"font-mono",children:q})}),e.jsx("p",{className:"text-[10px] text-muted-foreground/70 leading-tight",children:"Traffic auto-routed to remote server"})]})]}):e.jsx(W,{delayDuration:300,children:e.jsxs("div",{className:m("rounded-lg border p-3 transition-colors",p?"border-green-500/30 bg-green-500/5":"border-muted bg-muted/30"),children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:m("w-2 h-2 rounded-full",p?"bg-green-500 animate-pulse":"bg-muted-foreground/30")}),e.jsx("span",{className:"text-sm font-medium",children:a?.backendLabel??"CLIProxy"})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[i?e.jsx(j,{className:"w-3 h-3 animate-spin text-muted-foreground"}):p?e.jsxs(e.Fragment,{children:[e.jsx(y,{icon:Ne,tooltip:"Restart",onClick:()=>N.mutate(),disabled:A,isPending:N.isPending}),e.jsx(y,{icon:ve,tooltip:"Stop",onClick:()=>l.mutate(),disabled:A,isPending:l.isPending,variant:"destructive-ghost"})]}):null,e.jsx(y,{icon:h?we:Ce,tooltip:h?"Close":"Version settings",onClick:()=>P(!h),className:h?"bg-muted":void 0})]})]}),D&&e.jsxs("div",{className:"mt-1.5 flex items-center gap-2",children:[e.jsxs("span",{className:m("text-xs font-mono text-muted-foreground",x&&"text-amber-600 dark:text-amber-400"),children:["v",D]}),(L||x)&&C&&e.jsxs(T,{variant:"secondary",className:m("text-[10px] h-4 px-1.5 gap-0.5 cursor-pointer transition-colors",x?"bg-amber-100 text-amber-700 hover:bg-amber-200 dark:bg-amber-900/30 dark:text-amber-400 dark:hover:bg-amber-900/50":"bg-green-100 text-green-700 hover:bg-green-200 dark:bg-green-900/30 dark:text-green-400 dark:hover:bg-green-900/50"),onClick:()=>U(C),title:`Click to ${x?"downgrade":"update"}`,children:[x?e.jsx(Se,{className:"w-2.5 h-2.5"}):e.jsx(ye,{className:"w-2.5 h-2.5"}),C]})]}),p&&t&&e.jsxs("div",{className:"mt-2 flex items-center gap-4 text-xs text-muted-foreground",children:[e.jsxs("span",{className:"flex items-center gap-1",children:["Port ",t.port]}),t.sessionCount!==void 0&&t.sessionCount>0&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(ke,{className:"w-3 h-3"}),t.sessionCount," session",t.sessionCount!==1?"s":""]}),t.startedAt&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Pe,{className:"w-3 h-3"}),De(t.startedAt)]})]}),e.jsx(Z,{open:h,onOpenChange:P,children:e.jsxs(_,{className:"mt-3 pt-3 border-t border-muted",children:[e.jsx("h4",{className:"text-xs font-medium text-muted-foreground mb-3",children:"Version Management"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(J,{value:g,onValueChange:$,disabled:r,children:[e.jsx(ee,{className:"h-8 text-xs flex-1",children:e.jsx(se,{placeholder:"Select version to install..."})}),e.jsx(te,{children:s?.versions.slice(0,20).map(n=>{const c=s?.maxStableVersion&&S(n,s.maxStableVersion);return e.jsx(ae,{value:n,className:"text-xs",children:e.jsxs("span",{className:"flex items-center gap-2",children:["v",n,n===s.latestStable&&e.jsx("span",{className:"text-green-600 dark:text-green-400",children:"(stable)"}),c&&e.jsx("span",{className:"text-amber-600 dark:text-amber-400",children:"⚠"})]})},n)})})]}),e.jsxs(k,{variant:"outline",size:"sm",className:"h-8 text-xs gap-1.5 px-3",onClick:()=>U(g),disabled:u.isPending||!g,children:[u.isPending?e.jsx(j,{className:"w-3.5 h-3.5 animate-spin"}):e.jsx(Ve,{className:"w-3.5 h-3.5"}),"Install"]})]}),g&&s?.maxStableVersion&&S(g,s.maxStableVersion)&&e.jsxs("div",{className:"mt-2 flex items-center gap-1.5 text-[11px] text-amber-600 dark:text-amber-400",children:[e.jsx(I,{className:"w-3.5 h-3.5 flex-shrink-0"}),e.jsxs("span",{children:["Versions above ",s.maxStableVersion," have known issues"]})]}),a?.checkedAt&&e.jsxs("div",{className:"mt-2 text-[10px] text-muted-foreground/60",children:["Last checked ",Ue(a.checkedAt)]})]})}),!p&&e.jsxs("div",{className:"mt-2 flex items-center justify-between",children:[e.jsx("span",{className:"text-xs text-muted-foreground",children:"Not running"}),e.jsxs(k,{variant:"outline",size:"sm",className:"h-7 text-xs gap-1",onClick:()=>o.mutate(),disabled:o.isPending,children:[o.isPending?e.jsx(j,{className:"w-3 h-3 animate-spin"}):e.jsx(Ae,{className:"w-3 h-3"}),"Start"]})]}),e.jsx(le,{open:R,onOpenChange:b,children:e.jsxs(ce,{children:[e.jsxs(de,{children:[e.jsxs(xe,{className:"flex items-center gap-2",children:[e.jsx(I,{className:"w-5 h-5 text-amber-500"}),"Install Unstable Version?"]}),e.jsxs(me,{className:"space-y-2",children:[e.jsxs("p",{children:["You are about to install ",e.jsxs("strong",{children:["v",v]}),", which is above the maximum stable version"," ",e.jsxs("strong",{children:["v",s?.maxStableVersion||"6.6.80"]}),"."]}),e.jsx("p",{className:"text-amber-600 dark:text-amber-400",children:"This version has known stability issues and may cause unexpected behavior."}),e.jsx("p",{children:"Are you sure you want to proceed?"})]})]}),e.jsxs(ue,{children:[e.jsx(he,{onClick:F,children:"Cancel"}),e.jsx(ge,{onClick:B,className:"bg-amber-500 hover:bg-amber-600 text-white",children:"Install Anyway"})]})]})})]})})}export{Le as P};
1
+ import{j as e}from"./radix-ui-qEZD5MMp.js";import{r as f}from"./react-vendor-CNOkPC89.js";import{aQ as G,aw as H,aR as K,aS as O,aT as Q,aU as X,aV as Y,c as m,B as T,ag as W,E as Z,G as _,X as J,Y as ee,Z as se,_ as te,$ as ae,b as k,T as ne,o as re,p as ie,ap as oe}from"./index-D7Pl56Ob.js";import{A as le,a as ce,b as de,c as xe,d as me,e as ue,f as he,g as ge}from"./alert-dialog-Bn6K2nsn.js";import{u as pe,e as be}from"./tanstack-De4wvi8X.js";import{a1 as fe,A as je,a6 as j,aE as Ne,aF as ve,X as we,S as Ce,aG as Se,aH as ye,U as ke,u as Pe,ao as Ve,T as I,av as Ae}from"./icons-C6UNjkCT.js";function S(t,i){const a=t.replace(/-\d+$/,"").split(".").map(Number),s=i.replace(/-\d+$/,"").split(".").map(Number);for(let r=0;r<3;r++){if((a[r]||0)>(s[r]||0))return!0;if((a[r]||0)<(s[r]||0))return!1}return!1}function De(t){if(!t)return"";const i=new Date(t).getTime(),s=Date.now()-i,r=Math.floor(s/(1e3*60*60)),o=Math.floor(s%(1e3*60*60)/(1e3*60));return r>0?`${r}h ${o}m`:`${o}m`}function Ue(t){if(!t)return"";const i=Date.now()-t,a=Math.floor(i/(1e3*60)),s=Math.floor(i/(1e3*60*60));return a<1?"just now":a<60?`${a}m ago`:`${s}h ago`}function y({icon:t,tooltip:i,onClick:a,disabled:s,isPending:r,className:o,variant:l="ghost"}){return e.jsxs(ne,{children:[e.jsx(re,{asChild:!0,children:e.jsx(k,{variant:l==="destructive-ghost"?"ghost":l,size:"sm",className:m("h-7 w-7 p-0",l==="destructive-ghost"&&"hover:bg-destructive/10 hover:text-destructive hover:border-destructive/30",o),onClick:a,disabled:s,children:r?e.jsx(j,{className:"w-3.5 h-3.5 animate-spin"}):e.jsx(t,{className:"w-3.5 h-3.5"})})}),e.jsx(ie,{side:"bottom",className:"text-xs",children:i})]})}function Le(){const{data:t,isLoading:i}=G(),{data:a}=H(),{data:s,isLoading:r}=K(),o=O(),l=Q(),N=X(),u=Y(),[h,P]=f.useState(!1),[g,$]=f.useState(""),[R,b]=f.useState(!1),[v,w]=f.useState(null),{data:M}=pe({queryKey:["cliproxy-server-config"],queryFn:()=>oe.cliproxyServer.get(),staleTime:3e4}),E=be({mutationKey:["update-backend"]})>0,d=M?.remote,V=d?.enabled&&d?.host,p=t?.running??!1,A=o.isPending||l.isPending||N.isPending||u.isPending||E,L=a?.hasUpdate??!1,x=a?.isStable===!1,D=a?.currentVersion,C=x?a?.maxStableVersion||s?.latestStable:a?.latestVersion,U=n=>{if(!n)return;const c=s?.maxStableVersion||"6.6.80";if(S(n,c)){w(n),b(!0);return}u.mutate({version:n})},B=()=>{v&&u.mutate({version:v,force:!0}),b(!1),w(null)},F=()=>{b(!1),w(null)},q=V?(()=>{const n=d.protocol||"http",c=d.port||(n==="https"?443:80);return n==="https"&&c===443||n==="http"&&c===80?d.host:`${d.host}:${c}`})():null;return V?e.jsxs("div",{className:m("rounded-lg border p-3 transition-colors","border-blue-500/30 bg-blue-500/5"),children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(fe,{className:"w-4 h-4 text-blue-500"}),e.jsx("span",{className:"text-sm font-medium",children:"Remote Proxy"}),e.jsx(T,{variant:"secondary",className:"text-[10px] h-4 px-1.5 bg-blue-100 text-blue-700 dark:bg-blue-900/30 dark:text-blue-400",children:"Active"})]}),e.jsx(je,{className:"w-3 h-3 text-blue-600"})]}),e.jsxs("div",{className:"mt-2 text-xs text-muted-foreground",children:[e.jsx("div",{className:"flex items-center gap-1 mb-1",children:e.jsx("span",{className:"font-mono",children:q})}),e.jsx("p",{className:"text-[10px] text-muted-foreground/70 leading-tight",children:"Traffic auto-routed to remote server"})]})]}):e.jsx(W,{delayDuration:300,children:e.jsxs("div",{className:m("rounded-lg border p-3 transition-colors",p?"border-green-500/30 bg-green-500/5":"border-muted bg-muted/30"),children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:m("w-2 h-2 rounded-full",p?"bg-green-500 animate-pulse":"bg-muted-foreground/30")}),e.jsx("span",{className:"text-sm font-medium",children:a?.backendLabel??"CLIProxy"})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[i?e.jsx(j,{className:"w-3 h-3 animate-spin text-muted-foreground"}):p?e.jsxs(e.Fragment,{children:[e.jsx(y,{icon:Ne,tooltip:"Restart",onClick:()=>N.mutate(),disabled:A,isPending:N.isPending}),e.jsx(y,{icon:ve,tooltip:"Stop",onClick:()=>l.mutate(),disabled:A,isPending:l.isPending,variant:"destructive-ghost"})]}):null,e.jsx(y,{icon:h?we:Ce,tooltip:h?"Close":"Version settings",onClick:()=>P(!h),className:h?"bg-muted":void 0})]})]}),D&&e.jsxs("div",{className:"mt-1.5 flex items-center gap-2",children:[e.jsxs("span",{className:m("text-xs font-mono text-muted-foreground",x&&"text-amber-600 dark:text-amber-400"),children:["v",D]}),(L||x)&&C&&e.jsxs(T,{variant:"secondary",className:m("text-[10px] h-4 px-1.5 gap-0.5 cursor-pointer transition-colors",x?"bg-amber-100 text-amber-700 hover:bg-amber-200 dark:bg-amber-900/30 dark:text-amber-400 dark:hover:bg-amber-900/50":"bg-green-100 text-green-700 hover:bg-green-200 dark:bg-green-900/30 dark:text-green-400 dark:hover:bg-green-900/50"),onClick:()=>U(C),title:`Click to ${x?"downgrade":"update"}`,children:[x?e.jsx(Se,{className:"w-2.5 h-2.5"}):e.jsx(ye,{className:"w-2.5 h-2.5"}),C]})]}),p&&t&&e.jsxs("div",{className:"mt-2 flex items-center gap-4 text-xs text-muted-foreground",children:[e.jsxs("span",{className:"flex items-center gap-1",children:["Port ",t.port]}),t.sessionCount!==void 0&&t.sessionCount>0&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(ke,{className:"w-3 h-3"}),t.sessionCount," session",t.sessionCount!==1?"s":""]}),t.startedAt&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Pe,{className:"w-3 h-3"}),De(t.startedAt)]})]}),e.jsx(Z,{open:h,onOpenChange:P,children:e.jsxs(_,{className:"mt-3 pt-3 border-t border-muted",children:[e.jsx("h4",{className:"text-xs font-medium text-muted-foreground mb-3",children:"Version Management"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(J,{value:g,onValueChange:$,disabled:r,children:[e.jsx(ee,{className:"h-8 text-xs flex-1",children:e.jsx(se,{placeholder:"Select version to install..."})}),e.jsx(te,{children:s?.versions.slice(0,20).map(n=>{const c=s?.maxStableVersion&&S(n,s.maxStableVersion);return e.jsx(ae,{value:n,className:"text-xs",children:e.jsxs("span",{className:"flex items-center gap-2",children:["v",n,n===s.latestStable&&e.jsx("span",{className:"text-green-600 dark:text-green-400",children:"(stable)"}),c&&e.jsx("span",{className:"text-amber-600 dark:text-amber-400",children:"⚠"})]})},n)})})]}),e.jsxs(k,{variant:"outline",size:"sm",className:"h-8 text-xs gap-1.5 px-3",onClick:()=>U(g),disabled:u.isPending||!g,children:[u.isPending?e.jsx(j,{className:"w-3.5 h-3.5 animate-spin"}):e.jsx(Ve,{className:"w-3.5 h-3.5"}),"Install"]})]}),g&&s?.maxStableVersion&&S(g,s.maxStableVersion)&&e.jsxs("div",{className:"mt-2 flex items-center gap-1.5 text-[11px] text-amber-600 dark:text-amber-400",children:[e.jsx(I,{className:"w-3.5 h-3.5 flex-shrink-0"}),e.jsxs("span",{children:["Versions above ",s.maxStableVersion," have known issues"]})]}),a?.checkedAt&&e.jsxs("div",{className:"mt-2 text-[10px] text-muted-foreground/60",children:["Last checked ",Ue(a.checkedAt)]})]})}),!p&&e.jsxs("div",{className:"mt-2 flex items-center justify-between",children:[e.jsx("span",{className:"text-xs text-muted-foreground",children:"Not running"}),e.jsxs(k,{variant:"outline",size:"sm",className:"h-7 text-xs gap-1",onClick:()=>o.mutate(),disabled:o.isPending,children:[o.isPending?e.jsx(j,{className:"w-3 h-3 animate-spin"}):e.jsx(Ae,{className:"w-3 h-3"}),"Start"]})]}),e.jsx(le,{open:R,onOpenChange:b,children:e.jsxs(ce,{children:[e.jsxs(de,{children:[e.jsxs(xe,{className:"flex items-center gap-2",children:[e.jsx(I,{className:"w-5 h-5 text-amber-500"}),"Install Unstable Version?"]}),e.jsxs(me,{className:"space-y-2",children:[e.jsxs("p",{children:["You are about to install ",e.jsxs("strong",{children:["v",v]}),", which is above the maximum stable version"," ",e.jsxs("strong",{children:["v",s?.maxStableVersion||"6.6.80"]}),"."]}),e.jsx("p",{className:"text-amber-600 dark:text-amber-400",children:"This version has known stability issues and may cause unexpected behavior."}),e.jsx("p",{children:"Are you sure you want to proceed?"})]})]}),e.jsxs(ue,{children:[e.jsx(he,{onClick:F,children:"Cancel"}),e.jsx(ge,{onClick:B,className:"bg-amber-500 hover:bg-amber-600 text-white",children:"Install Anyway"})]})]})})]})})}export{Le as P};
@@ -1 +1 @@
1
- import{j as s}from"./radix-ui-qEZD5MMp.js";import{r as l}from"./react-vendor-CNOkPC89.js";import{aH as o,aI as m,aJ as c,aK as x,aL as u,b as h,C as p,a as g}from"./index-CErLyTsQ.js";import{J as j,$ as f,az as N,T as b}from"./icons-C6UNjkCT.js";import"./tanstack-De4wvi8X.js";import"./notifications-B2HqRBj7.js";import"./utils-CzKF5WmX.js";import"./form-utils-C-pVd1--.js";import"./code-highlight-BRUf_pqB.js";function R(){const[t,i]=l.useState("commands"),{data:e}=o(),{data:n,isLoading:r}=m(t),d=[{id:"commands",label:"Commands",icon:j,count:e?.commands??0},{id:"skills",label:"Skills",icon:f,count:e?.skills??0},{id:"agents",label:"Agents",icon:N,count:e?.agents??0}];return s.jsxs("div",{className:"p-6 max-w-6xl mx-auto space-y-8",children:[s.jsxs("div",{children:[s.jsx("h1",{className:"text-2xl font-bold",children:"Shared Data"}),s.jsx("p",{className:"text-muted-foreground",children:"Commands, skills, and agents shared across Claude instances"})]}),e&&!e.symlinkStatus.valid&&s.jsxs(c,{variant:"warning",children:[s.jsx(b,{className:"h-4 w-4"}),s.jsx(x,{children:"Configuration Required"}),s.jsxs(u,{children:[e.symlinkStatus.message,". Run `ccs sync` to configure."]})]}),s.jsx("div",{className:"flex gap-2 border-b pb-2",children:d.map(a=>s.jsxs(h,{variant:t===a.id?"default":"ghost",size:"sm",onClick:()=>i(a.id),className:"flex items-center gap-2",children:[s.jsx(a.icon,{className:"w-4 h-4"}),a.label," (",a.count,")"]},a.id))}),s.jsx("div",{className:"mt-4",children:r?s.jsx("div",{className:"text-muted-foreground",children:"Loading..."}):n?.items.length===0?s.jsxs("div",{className:"text-muted-foreground",children:["No ",t," found"]}):s.jsx("div",{className:"grid gap-3",children:n?.items.map(a=>s.jsx(p,{children:s.jsxs(g,{children:[s.jsx("div",{className:"font-medium",children:a.name}),s.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:a.description}),s.jsx("p",{className:"text-xs text-muted-foreground mt-2 font-mono truncate",children:a.path})]})},a.name))})})]})}export{R as SharedPage};
1
+ import{j as s}from"./radix-ui-qEZD5MMp.js";import{r as l}from"./react-vendor-CNOkPC89.js";import{aH as o,aI as m,aJ as c,aK as x,aL as u,b as h,C as p,a as g}from"./index-D7Pl56Ob.js";import{J as j,$ as f,az as N,T as b}from"./icons-C6UNjkCT.js";import"./tanstack-De4wvi8X.js";import"./notifications-B2HqRBj7.js";import"./utils-CzKF5WmX.js";import"./form-utils-C-pVd1--.js";import"./code-highlight-BRUf_pqB.js";function R(){const[t,i]=l.useState("commands"),{data:e}=o(),{data:n,isLoading:r}=m(t),d=[{id:"commands",label:"Commands",icon:j,count:e?.commands??0},{id:"skills",label:"Skills",icon:f,count:e?.skills??0},{id:"agents",label:"Agents",icon:N,count:e?.agents??0}];return s.jsxs("div",{className:"p-6 max-w-6xl mx-auto space-y-8",children:[s.jsxs("div",{children:[s.jsx("h1",{className:"text-2xl font-bold",children:"Shared Data"}),s.jsx("p",{className:"text-muted-foreground",children:"Commands, skills, and agents shared across Claude instances"})]}),e&&!e.symlinkStatus.valid&&s.jsxs(c,{variant:"warning",children:[s.jsx(b,{className:"h-4 w-4"}),s.jsx(x,{children:"Configuration Required"}),s.jsxs(u,{children:[e.symlinkStatus.message,". Run `ccs sync` to configure."]})]}),s.jsx("div",{className:"flex gap-2 border-b pb-2",children:d.map(a=>s.jsxs(h,{variant:t===a.id?"default":"ghost",size:"sm",onClick:()=>i(a.id),className:"flex items-center gap-2",children:[s.jsx(a.icon,{className:"w-4 h-4"}),a.label," (",a.count,")"]},a.id))}),s.jsx("div",{className:"mt-4",children:r?s.jsx("div",{className:"text-muted-foreground",children:"Loading..."}):n?.items.length===0?s.jsxs("div",{className:"text-muted-foreground",children:["No ",t," found"]}):s.jsx("div",{className:"grid gap-3",children:n?.items.map(a=>s.jsx(p,{children:s.jsxs(g,{children:[s.jsx("div",{className:"font-medium",children:a.name}),s.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:a.description}),s.jsx("p",{className:"text-xs text-muted-foreground mt-2 font-mono truncate",children:a.path})]})},a.name))})})]})}export{R as SharedPage};
@@ -1 +1 @@
1
- import{j as a,a2 as s,a3 as n}from"./radix-ui-qEZD5MMp.js";import"./react-vendor-CNOkPC89.js";import{c as e}from"./index-CErLyTsQ.js";function c({className:t,...r}){return a.jsx(s,{"data-slot":"switch",className:e("peer data-[state=checked]:bg-primary data-[state=unchecked]:bg-input focus-visible:border-ring focus-visible:ring-ring/50 dark:data-[state=unchecked]:bg-input/80 inline-flex h-[1.15rem] w-8 shrink-0 items-center rounded-full border border-transparent shadow-xs transition-all outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50",t),...r,children:a.jsx(n,{"data-slot":"switch-thumb",className:e("bg-background dark:data-[state=unchecked]:bg-foreground dark:data-[state=checked]:bg-primary-foreground pointer-events-none block size-4 rounded-full ring-0 transition-transform data-[state=checked]:translate-x-[calc(100%-2px)] data-[state=unchecked]:translate-x-0")})})}export{c as S};
1
+ import{j as a,a2 as s,a3 as n}from"./radix-ui-qEZD5MMp.js";import"./react-vendor-CNOkPC89.js";import{c as e}from"./index-D7Pl56Ob.js";function c({className:t,...r}){return a.jsx(s,{"data-slot":"switch",className:e("peer data-[state=checked]:bg-primary data-[state=unchecked]:bg-input focus-visible:border-ring focus-visible:ring-ring/50 dark:data-[state=unchecked]:bg-input/80 inline-flex h-[1.15rem] w-8 shrink-0 items-center rounded-full border border-transparent shadow-xs transition-all outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50",t),...r,children:a.jsx(n,{"data-slot":"switch-thumb",className:e("bg-background dark:data-[state=unchecked]:bg-foreground dark:data-[state=checked]:bg-primary-foreground pointer-events-none block size-4 rounded-full ring-0 transition-transform data-[state=checked]:translate-x-[calc(100%-2px)] data-[state=unchecked]:translate-x-0")})})}export{c as S};
@@ -24,7 +24,7 @@
24
24
  href="https://fonts.googleapis.com/css2?family=IBM+Plex+Sans:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;500;600;700&display=swap"
25
25
  rel="stylesheet"
26
26
  />
27
- <script type="module" crossorigin src="/assets/index-CErLyTsQ.js"></script>
27
+ <script type="module" crossorigin src="/assets/index-D7Pl56Ob.js"></script>
28
28
  <link rel="modulepreload" crossorigin href="/assets/react-vendor-CNOkPC89.js">
29
29
  <link rel="modulepreload" crossorigin href="/assets/radix-ui-qEZD5MMp.js">
30
30
  <link rel="modulepreload" crossorigin href="/assets/tanstack-De4wvi8X.js">
@@ -26,6 +26,18 @@
26
26
 
27
27
  const { spawnSync } = require('child_process');
28
28
 
29
+ // ============================================================================
30
+ // PLATFORM DETECTION
31
+ // ============================================================================
32
+
33
+ /**
34
+ * Windows platform flag - used for shell option in spawnSync calls.
35
+ * On Windows, globally installed CLI tools via npm/pnpm are .cmd/.bat files,
36
+ * which require shell: true to execute properly.
37
+ * @see https://github.com/kaitranntt/ccs/issues/378
38
+ */
39
+ const isWindows = process.platform === 'win32';
40
+
29
41
  // ============================================================================
30
42
  // CONFIGURATION - Edit these for prompt engineering
31
43
  // ============================================================================
@@ -154,7 +166,6 @@ process.stdin.on('error', () => {
154
166
  */
155
167
  function isCliAvailable(cmd) {
156
168
  try {
157
- const isWindows = process.platform === 'win32';
158
169
  const whichCmd = isWindows ? 'where.exe' : 'which';
159
170
 
160
171
  const result = spawnSync(whichCmd, [cmd], {
@@ -292,6 +303,7 @@ function tryGeminiSearch(query, timeoutSec = DEFAULT_TIMEOUT_SEC) {
292
303
  timeout: timeoutMs,
293
304
  maxBuffer: 1024 * 1024 * 2,
294
305
  stdio: ['pipe', 'pipe', 'pipe'],
306
+ shell: isWindows,
295
307
  }
296
308
  );
297
309
 
@@ -358,6 +370,7 @@ function tryOpenCodeSearch(query, timeoutSec = DEFAULT_TIMEOUT_SEC) {
358
370
  timeout: timeoutMs,
359
371
  maxBuffer: 1024 * 1024 * 2,
360
372
  stdio: ['pipe', 'pipe', 'pipe'],
373
+ shell: isWindows,
361
374
  }
362
375
  );
363
376
 
@@ -417,6 +430,7 @@ function tryGrokSearch(query, timeoutSec = DEFAULT_TIMEOUT_SEC) {
417
430
  timeout: timeoutMs,
418
431
  maxBuffer: 1024 * 1024 * 2,
419
432
  stdio: ['pipe', 'pipe', 'pipe'],
433
+ shell: isWindows,
420
434
  });
421
435
 
422
436
  if (spawnResult.error) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kaitranntt/ccs",
3
- "version": "7.28.1-dev.1",
3
+ "version": "7.28.2-dev.1",
4
4
  "description": "Claude Code Switch - Instant profile switching between Claude Sonnet 4.5 and GLM 4.6",
5
5
  "keywords": [
6
6
  "cli",
@@ -1,3 +0,0 @@
1
- import{j as e,$ as vs,a0 as Ns}from"./radix-ui-qEZD5MMp.js";import{r as m}from"./react-vendor-CNOkPC89.js";import{a as Ke,u as ze,b as ws}from"./tanstack-De4wvi8X.js";import{b as w,C as Be,a as $e,c as _,P as ie,L as re,I as ge,X as qe,Y as Ve,Z as Qe,_ as Je,$ as me,a0 as We,a1 as bs,a2 as Ye,a3 as Xe,u as Ze,a4 as fe,a5 as je,a6 as ve,a7 as Ne,a8 as es,a9 as ys,aa as _e,ab as Ee,B as K,ac as Cs,q as ss,m as we,l as ks,ad as Ss,ae as As,af as Ps,ag as X,T as Z,o as ee,p as se,ah as Ms,ai as Ts,aj as Os,ak as Re,al as Ds,am as Is,an as _s,ao as Es,ap as ce,aq as Rs,ar as Ls,as as Fs,at as Hs,H as Us,J as Gs,K as Le,M as Fe,au as Ks,av as zs,aw as Bs,ax as $s,ay as qs,az as Vs,aA as Qs,aB as Js,aC as Ws,aD as Ys,aE as Xs,S as Zs}from"./index-CErLyTsQ.js";import{t as B}from"./notifications-B2HqRBj7.js";import{b as ts,L as $,m as be,x as et,j as q,l as st,an as ye,a6 as Ce,n as W,$ as ae,ao as tt,ap as oe,Z as le,I as at,f as nt,a1 as as,aq as it,ah as rt,X as ke,_ as ns,s as is,t as xe,ar as ot,T as lt,u as de,as as ct,ag as rs,p as dt,at as ut,a0 as mt,ak as xt,au as os}from"./icons-C6UNjkCT.js";import{S as Se,C as pt}from"./confirm-dialog-0Zy9TN_K.js";import{S as ht}from"./switch-DVMOWp74.js";import{P as gt}from"./proxy-status-widget-BBhLPlDp.js";import"./utils-CzKF5WmX.js";import"./form-utils-C-pVd1--.js";import"./code-highlight-BRUf_pqB.js";import"./alert-dialog-Cb5PMEBl.js";const te={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"}]}},pe=8317,ue="ccs-internal-managed";async function ft(){try{const s=await fetch("/api/settings/auth/tokens/raw");return s.ok?(await s.json())?.apiKey?.value??ue:ue}catch{return ue}}async function he(s,a){const t=te[s];if(!t)return{success:!1};const r=t.models[0],i=r?.presetMapping||{default:t.defaultModel,opus:t.defaultModel,sonnet:t.defaultModel,haiku:t.defaultModel},c=await ft(),u={env:{ANTHROPIC_BASE_URL:`http://127.0.0.1:${pe}/api/provider/${s}`,ANTHROPIC_AUTH_TOKEN:c,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:r?.name||t.defaultModel}}catch{return{success:!1}}}const He=[{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"}],ls=["provider","auth","variant","success"];function jt(s){return s==="account"?1:ls.indexOf(s)}function vt({currentProgress:s,allSteps:a}){return e.jsx("div",{className:"flex justify-center gap-1 pt-2",children:a.map((t,r)=>e.jsx("div",{className:`w-2 h-2 rounded-full transition-colors ${s>=r?"bg-primary":"bg-muted"}`},t))})}function Nt({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(ts,{className:"w-4 h-4 text-muted-foreground"})]},t.id))})}function wt({selectedProvider:s,providers:a,authCommand:t,isRefreshing:r,isPending:i,onBack:c,onStartAuth:l,onRefresh:u}){const[o,x]=m.useState(!1),g=async h=>{await navigator.clipboard.writeText(h),x(!0),setTimeout(()=>x(!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(h=>h.id===s)?.name," to add an account"]}),e.jsx(w,{onClick:l,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(be,{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(Be,{children:e.jsxs($e,{className:"p-4 space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(et,{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(w,{variant:"outline",size:"icon",onClick:()=>g(t),children:o?e.jsx(q,{className:"w-4 h-4 text-green-500"}):e.jsx(st,{className:"w-4 h-4"})})]})]})}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(w,{variant:"ghost",onClick:c,disabled:i,children:[e.jsx(ye,{className:"w-4 h-4 mr-2"}),"Back"]}),e.jsxs(w,{variant:"outline",onClick:u,disabled:r||i,children:[e.jsx(Ce,{className:`w-4 h-4 mr-2 ${r?"animate-spin":""}`}),r?"Checking...":"Refresh Status"]})]})]})}function bt({accounts:s,privacyMode:a,onSelect:t,onAddNew:r,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(c=>e.jsxs("button",{type:"button",onClick:()=>t(c),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(W,{className:"w-4 h-4 text-muted-foreground"})}),e.jsxs("div",{children:[e.jsx("div",{className:_("font-medium",a&&ie),children:c.email||c.id}),c.isDefault&&e.jsx("div",{className:"text-xs text-muted-foreground",children:"Default account"})]})]}),e.jsx(ts,{className:"w-4 h-4 text-muted-foreground"})]},c.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:r,children:[e.jsx("div",{className:"w-8 h-8 rounded-full bg-primary/10 flex items-center justify-center shrink-0",children:e.jsx(be,{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(w,{variant:"ghost",onClick:i,children:[e.jsx(ye,{className:"w-4 h-4 mr-2"}),"Back"]})})]})}function yt({selectedProvider:s,selectedAccount:a,variantName:t,modelName:r,isPending:i,privacyMode:c,onVariantNameChange:l,onModelChange:u,onBack:o,onSkip:x,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(W,{className:"w-4 h-4"}),e.jsxs("span",{children:["Using:"," ",e.jsx("span",{className:_(c&&ie),children:a.email||a.id})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(re,{htmlFor:"variant-name",children:"Variant Name *"}),e.jsx(ge,{id:"variant-name",value:t,onChange:h=>l(h.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(re,{children:"Model"}),e.jsxs(qe,{value:r,onValueChange:u,children:[e.jsx(Ve,{children:e.jsx(Qe,{placeholder:"Select a model"})}),e.jsx(Je,{children:te[s]?.models.map(h=>e.jsx(me,{value:h.id,children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{children:h.name}),h.description&&e.jsxs("span",{className:"text-xs text-muted-foreground",children:["- ",h.description]})]})},h.id))})]}),e.jsxs("div",{className:"text-xs text-muted-foreground",children:["Default: ",te[s]?.defaultModel||"provider default"]})]}),e.jsxs("div",{className:"flex items-center justify-between pt-2",children:[e.jsxs(w,{variant:"ghost",onClick:o,children:[e.jsx(ye,{className:"w-4 h-4 mr-2"}),"Back"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(w,{variant:"ghost",onClick:x,children:"Skip"}),e.jsx(w,{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 Ct({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(q,{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(Be,{children:e.jsxs($e,{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(w,{onClick:a,className:"w-full",children:"Done"})]})}function kt({open:s,onClose:a}){const[t,r]=m.useState("provider"),[i,c]=m.useState(""),[l,u]=m.useState(null),[o,x]=m.useState(""),[g,h]=m.useState(""),[p,d]=m.useState(!1),[C,E]=m.useState(!1),{data:j,refetch:D}=We(),L=bs(),O=Ye(),M=Xe(),{privacyMode:T}=Ze(),f=j?.authStatus.find(y=>y.provider===i),P=m.useMemo(()=>f?.accounts||[],[f?.accounts]);m.useEffect(()=>{if(!s){const y=setTimeout(()=>{r("provider"),c(""),u(null),x(""),h(""),E(!1)},0);return()=>clearTimeout(y)}},[s]),m.useEffect(()=>{if(t==="auth"&&P.length>0&&!C){const y=setTimeout(()=>{r("account")},0);return()=>clearTimeout(y)}},[t,P,C]);const v=async()=>{d(!0),await D(),d(!1)},k=()=>{const y=(f?.accounts?.length||0)===0;O.mutate({provider:i},{onSuccess:async N=>{if(y){const I=await he(i);I.success&&I.presetName?B.success(`Applied "${I.presetName}" preset`):I.success||B.warning("Account added, but failed to apply default preset")}N.account&&(u(N.account),r("variant")),D()}})},R=y=>{c(y),(j?.authStatus.find(G=>G.provider===y)?.accounts||[]).length===0?r("auth"):r("account")},S=y=>{u(y),r("variant")},b=async()=>{if(!(!o||!i))try{await L.mutateAsync({name:o,provider:i,model:g||void 0,account:l?.id}),r("success")}catch(y){console.error("Failed to create variant:",y)}},F=`ccs ${i} --auth --add`,U=jt(t),z=y=>{if(!y&&(O.isPending&&i&&M.mutate(i),t==="success"||t==="provider")){a();return}};return e.jsx(fe,{open:s,onOpenChange:z,children:e.jsxs(je,{className:"sm:max-w-lg",onPointerDownOutside:y=>{t!=="success"&&t!=="provider"&&y.preventDefault()},onEscapeKeyDown:y=>{(O.isPending||L.isPending)&&y.preventDefault()},children:[e.jsxs(ve,{children:[e.jsxs(Ne,{className:"flex items-center gap-2",children:[e.jsx(ae,{className:"w-5 h-5 text-primary"}),"Quick Setup Wizard"]}),e.jsxs(es,{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(Nt,{providers:He,onSelect:R}),t==="auth"&&e.jsx(wt,{selectedProvider:i,providers:He,authCommand:F,isRefreshing:p,isPending:O.isPending,onBack:()=>r("provider"),onStartAuth:k,onRefresh:v}),t==="account"&&e.jsx(bt,{accounts:P,privacyMode:T,onSelect:S,onAddNew:()=>{E(!0),r("auth")},onBack:()=>r("provider")}),t==="variant"&&e.jsx(yt,{selectedProvider:i,selectedAccount:l,variantName:o,modelName:g,isPending:L.isPending,privacyMode:T,onVariantNameChange:x,onModelChange:h,onBack:()=>P.length>0?r("account"):r("provider"),onSkip:a,onCreate:b}),t==="success"&&e.jsx(Ct,{variantName:o,onClose:a})]}),e.jsx(vt,{currentProgress:U,allSteps:ls})]})})}function St({open:s,onClose:a,provider:t,displayName:r,isFirstAccount:i=!1}){const[c,l]=m.useState(""),u=Ye(),o=ys(),x=Xe(),g=t==="kiro",h=u.isPending||o.isPending,p=()=>{h&&x.mutate(t),l(""),a()},d=()=>{u.mutate({provider:t,nickname:c.trim()||void 0},{onSuccess:async()=>{const j=await he(t);j.success&&j.presetName?i&&B.success(`Applied "${j.presetName}" preset`):j.success||B.warning("Account added, but failed to apply default preset. You may need to configure settings manually."),l(""),a()}})},C=()=>{o.mutate(void 0,{onSuccess:async()=>{const j=await he("kiro");j.success&&j.presetName&&i&&B.success(`Applied "${j.presetName}" preset`),l(""),a()}})},E=j=>{j||p()};return e.jsx(fe,{open:s,onOpenChange:E,children:e.jsxs(je,{className:"sm:max-w-md",children:[e.jsxs(ve,{children:[e.jsxs(Ne,{children:["Add ",r," Account"]}),e.jsx(es,{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(re,{htmlFor:"nickname",children:"Nickname (optional)"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(W,{className:"w-4 h-4 text-muted-foreground"}),e.jsx(ge,{id:"nickname",value:c,onChange:j=>l(j.target.value),placeholder:"e.g., work, personal",disabled:h,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(w,{variant:"ghost",onClick:p,children:"Cancel"}),g&&e.jsx(w,{variant:"outline",onClick:C,disabled:h,children:o.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(tt,{className:"w-4 h-4 mr-2"}),"Import from IDE"]})}),e.jsx(w,{onClick:d,disabled:h,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(be,{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..."}),o.isPending&&e.jsx("p",{className:"text-sm text-center text-muted-foreground",children:"Importing token from Kiro IDE..."})]})]})})}const At=["ANTHROPIC_BASE_URL","ANTHROPIC_AUTH_TOKEN"];function Pt(s){const a=s?.env||{};return At.filter(t=>!a[t]?.trim())}function Mt(s){const[a,t]=m.useState(null),[r,i]=m.useState(!1),c=Ke(),{data:l,isLoading:u,refetch:o}=ze({queryKey:["settings",s],queryFn:async()=>{const v=await fetch(`/api/settings/${s}/raw`);return v.ok?v.json():{profile:s,settings:{env:{}},mtime:Date.now(),path:`~/.ccs/profiles/${s}/settings.json`}}}),x=l?.settings,g=m.useMemo(()=>a!==null?a:x?JSON.stringify(x,null,2):`{
2
- "env": {}
3
- }`,[a,x]),h=m.useCallback(v=>{t(v)},[]),p=m.useMemo(()=>{try{return JSON.parse(g)}catch{return x||{env:{}}}},[g,x]),d=p?.env?.ANTHROPIC_MODEL,C=p?.env?.ANTHROPIC_DEFAULT_OPUS_MODEL,E=p?.env?.ANTHROPIC_DEFAULT_SONNET_MODEL,j=p?.env?.ANTHROPIC_DEFAULT_HAIKU_MODEL,D=m.useCallback((v,k)=>{const R={...p?.env||{},[v]:k},S={...p,env:R};t(JSON.stringify(S,null,2))},[p]),L=m.useCallback(v=>{const k={...p?.env||{},...v},R={...p,env:k};t(JSON.stringify(R,null,2))},[p]),O=m.useMemo(()=>{try{return JSON.parse(g),!0}catch{return!1}},[g]),M=m.useMemo(()=>a===null?!1:a!==JSON.stringify(x,null,2),[a,x]),T=m.useMemo(()=>Pt(p),[p]),f=ws({mutationFn:async()=>{const v=JSON.parse(g),k=await fetch(`/api/settings/${s}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({settings:v,expectedMtime:l?.mtime})});if(k.status===409)throw new Error("CONFLICT");if(!k.ok)throw new Error("Failed to save");return k.json()},onSuccess:v=>{c.invalidateQueries({queryKey:["settings",s]}),t(null),v?.warning?B.success("Settings saved",{description:v.warning}):B.success("Settings saved")},onError:v=>{v.message==="CONFLICT"?i(!0):B.error(v.message)}}),P=async v=>{i(!1),v?(await o(),f.mutate()):t(null)};return{data:l,isLoading:u,refetch:o,rawJsonContent:g,rawJsonEdits:a,isRawJsonValid:O,hasChanges:M,currentSettings:p,currentModel:d,opusModel:C,sonnetModel:E,haikuModel:j,handleRawJsonChange:h,updateEnvValue:D,updateEnvValues:L,saveMutation:{mutate:()=>f.mutate(),isPending:f.isPending},conflictDialog:r,setConflictDialog:i,handleConflictResolve:P,missingRequiredFields:T}}function Q({label:s,description:a,value:t,onChange:r,catalog:i,allModels:c,disabled:l}){const u=new Set(i?.models.map(o=>o.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(qe,{value:t||"",onValueChange:r,disabled:l,children:[e.jsx(Ve,{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(Je,{className:"max-h-[300px]",children:[i&&i.models.length>0&&e.jsxs(_e,{children:[e.jsx(Ee,{className:"text-xs text-primary",children:"Recommended"}),i.models.map(o=>e.jsx(me,{value:o.id,children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"truncate font-mono text-xs",children:o.id}),o.tier==="paid"&&e.jsx(K,{variant:"outline",className:"text-[9px] h-4 px-1",children:"PAID"}),t===o.id&&e.jsx(q,{className:"w-3 h-3 text-primary ml-auto"})]})},o.id))]}),c.length>0&&e.jsxs(_e,{children:[e.jsxs(Ee,{className:"text-xs text-muted-foreground",children:["All Models (",c.length,")"]}),c.filter(o=>!u.has(o.id)).map(o=>e.jsx(me,{value:o.id,children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"truncate font-mono text-xs",children:o.id}),t===o.id&&e.jsx(q,{className:"w-3 h-3 text-primary ml-auto"})]})},o.id))]}),(!i||i.models.length===0)&&c.length===0&&e.jsx("div",{className:"py-2 px-3 text-xs text-muted-foreground",children:"No models available"})]})]})]})}function Tt({open:s,onClose:a,currentValues:t,onApply:r,onSave:i,isSaving:c,catalog:l,allModels:u}){const[o,x]=m.useState(t),[g,h]=m.useState(""),p=d=>{d?(x(t),h("")):a()};return e.jsx(fe,{open:s,onOpenChange:p,children:e.jsxs(je,{className:"sm:max-w-md",children:[e.jsx(ve,{children:e.jsxs(Ne,{className:"flex items-center gap-2",children:[e.jsx(ae,{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(re,{htmlFor:"preset-name",children:"Preset Name (optional)"}),e.jsx(ge,{id:"preset-name",value:g,onChange:d=>h(d.target.value),placeholder:"e.g., My Custom Config",className:"text-sm"})]}),e.jsx(Se,{}),e.jsx(Q,{label:"Default Model",description:"Used when no specific tier is requested",value:o.default,onChange:d=>x({...o,default:d}),catalog:l,allModels:u}),e.jsx(Q,{label:"Opus (Most capable)",description:"For complex reasoning tasks",value:o.opus,onChange:d=>x({...o,opus:d}),catalog:l,allModels:u}),e.jsx(Q,{label:"Sonnet (Balanced)",description:"Balance of speed and capability",value:o.sonnet,onChange:d=>x({...o,sonnet:d}),catalog:l,allModels:u}),e.jsx(Q,{label:"Haiku (Fast)",description:"Quick responses for simple tasks",value:o.haiku,onChange:d=>x({...o,haiku:d}),catalog:l,allModels:u})]}),e.jsxs(Cs,{className:"gap-2 sm:gap-0",children:[e.jsx(w,{variant:"outline",onClick:a,children:"Cancel"}),i&&e.jsxs(w,{variant:"secondary",onClick:()=>i(o,g||void 0),disabled:c||!g.trim(),children:[c?e.jsx($,{className:"w-4 h-4 mr-1 animate-spin"}):e.jsx(oe,{className:"w-4 h-4 mr-1"}),"Save Preset"]}),e.jsxs(w,{onClick:()=>r(o,g||void 0),children:[e.jsx(le,{className:"w-4 h-4 mr-1"}),"Apply Preset"]})]})]})})}function ne({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(ss,{value:a,size:"icon",className:"h-6 w-6"})]})]})}function Ot({provider:s,displayName:a,data:t,authStatus:r}){return e.jsx(we,{className:"h-full",children:e.jsxs("div",{className:"p-4 space-y-6",children:[e.jsxs("div",{children:[e.jsxs("h3",{className:"text-sm font-medium flex items-center gap-2 mb-3",children:[e.jsx(at,{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(ss,{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"}),r.authenticated?e.jsxs(K,{variant:"outline",className:"w-fit text-green-600 border-green-200 bg-green-50",children:[e.jsx(nt,{className:"w-3 h-3 mr-1"}),"Authenticated"]}):e.jsx(K,{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(ne,{label:"Run with prompt",command:`ccs ${s} "your prompt"`}),e.jsx(ne,{label:"Change model",command:`ccs ${s} --config`}),e.jsx(ne,{label:"Add account",command:`ccs ${s} --add`}),e.jsx(ne,{label:"List accounts",command:`ccs ${s} --accounts`})]})]})]})})}const Dt={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"},It={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"}},_t={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 Ae({provider:s,className:a,size:t="md"}){const r=s.toLowerCase(),i=It[r]||{text:"text-gray-600",letter:s[0]?.toUpperCase()||"?"},c=_t[t],l=Dt[r];return e.jsx("div",{className:_("flex items-center justify-center rounded-md",l&&"bg-white p-1",c.container,a),children:l?e.jsx("img",{src:l,alt:`${s} logo`,className:_(c.icon,"object-contain")}):e.jsx("span",{className:_("font-semibold",i.text,c.text),children:i.letter})})}function Et({displayName:s,logoProvider:a,provider:t,data:r,isLoading:i,hasChanges:c,isRawJsonValid:l,isSaving:u,isRemoteMode:o,port:x,onRefetch:g,onSave:h}){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(Ae,{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}),o&&e.jsxs(K,{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(as,{className:"w-3 h-3"}),"Remote"]}),x&&e.jsxs(K,{variant:"outline",className:"text-xs gap-1 font-mono",children:[e.jsx(it,{className:"w-3 h-3"}),":",x]}),!o&&r?.path&&e.jsx(K,{variant:"outline",className:"text-xs",children:r.path.replace(/^.*[\\/]/,"")})]}),o?e.jsx("p",{className:"text-xs text-blue-600 dark:text-blue-400 mt-0.5",children:"Traffic auto-routed to remote server"}):r&&e.jsxs("p",{className:"text-xs text-muted-foreground mt-0.5",children:["Last modified: ",new Date(r.mtime).toLocaleString()]})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(w,{variant:"ghost",size:"sm",onClick:g,disabled:i,children:e.jsx(Ce,{className:`w-4 h-4 ${i?"animate-spin":""}`})}),e.jsx(w,{size:"sm",onClick:h,disabled:u||!c||!l,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(rt,{className:"w-4 h-4 mr-1"}),"Save"]})})]})]})}function Rt({catalog:s,savedPresets:a,currentModel:t,opusModel:r,sonnetModel:i,haikuModel:c,providerModels:l,onApplyPreset:u,onUpdateEnvValue:o,onOpenCustomPreset:x,onDeletePreset:g,isDeletePending:h}){const p=s&&s.models.length>0||a.length>0;return e.jsxs(e.Fragment,{children:[p&&e.jsxs("div",{children:[e.jsxs("h3",{className:"text-sm font-medium mb-2 flex items-center gap-2",children:[e.jsx(ae,{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(d=>e.jsxs(w,{variant:"outline",size:"sm",className:"text-xs h-7 gap-1",onClick:()=>{const C=d.presetMapping||{default:d.id,opus:d.id,sonnet:d.id,haiku:d.id};u({ANTHROPIC_MODEL:C.default,ANTHROPIC_DEFAULT_OPUS_MODEL:C.opus,ANTHROPIC_DEFAULT_SONNET_MODEL:C.sonnet,ANTHROPIC_DEFAULT_HAIKU_MODEL:C.haiku})},children:[e.jsx(le,{className:"w-3 h-3"}),d.name]},d.id)),a.map(d=>e.jsxs("div",{className:"group relative",children:[e.jsxs(w,{variant:"secondary",size:"sm",className:"text-xs h-7 gap-1 pr-6",onClick:()=>{u({ANTHROPIC_MODEL:d.default,ANTHROPIC_DEFAULT_OPUS_MODEL:d.opus,ANTHROPIC_DEFAULT_SONNET_MODEL:d.sonnet,ANTHROPIC_DEFAULT_HAIKU_MODEL:d.haiku})},children:[e.jsx(oe,{className:"w-3 h-3 fill-current"}),d.name]}),e.jsx(w,{variant:"ghost",size:"icon",className:"absolute right-0 top-0 h-7 w-5 opacity-0 group-hover:opacity-100 hover:text-destructive",onClick:C=>{C.stopPropagation(),g(d.name)},disabled:h,children:e.jsx(ke,{className:"w-3 h-3"})})]},d.name)),e.jsxs(w,{variant:"outline",size:"sm",className:"text-xs h-7 gap-1 border-primary/50 text-primary hover:bg-primary/10 hover:border-primary",onClick:x,children:[e.jsx(ns,{className:"w-3 h-3"}),"Custom"]})]})]}),e.jsx(Se,{}),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:d=>o("ANTHROPIC_MODEL",d),catalog:s,allModels:l}),e.jsx(Q,{label:"Opus (Most capable)",description:"For complex reasoning tasks",value:r,onChange:d=>o("ANTHROPIC_DEFAULT_OPUS_MODEL",d),catalog:s,allModels:l}),e.jsx(Q,{label:"Sonnet (Balanced)",description:"Balance of speed and capability",value:i,onChange:d=>o("ANTHROPIC_DEFAULT_SONNET_MODEL",d),catalog:s,allModels:l}),e.jsx(Q,{label:"Haiku (Fast)",description:"Quick responses for simple tasks",value:c,onChange:d=>o("ANTHROPIC_DEFAULT_HAIKU_MODEL",d),catalog:s,allModels:l})]})]})]})}function Lt({className:s,...a}){return e.jsx(vs,{"data-slot":"checkbox",className:_("peer border-input dark:bg-input/30 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground dark:data-[state=checked]:bg-primary data-[state=checked]:border-primary focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive size-4 shrink-0 rounded-[4px] border shadow-xs transition-shadow outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50",s),...a,children:e.jsx(Ns,{"data-slot":"checkbox-indicator",className:"grid place-content-center text-current transition-none",children:e.jsx(q,{className:"size-3.5"})})})}function Ft(s){const a=Math.max(0,Math.min(100,s));return a<=20?"bg-destructive":a<=50?"bg-yellow-500":"bg-green-500"}function Ue(s){if(!s)return"";try{const a=new Date(s),r=new Date().getTime()-a.getTime();if(r<0)return"just now";const i=Math.floor(r/(1e3*60)),c=Math.floor(r/(1e3*60*60)),l=Math.floor(r/(1e3*60*60*24));return l>0?`${l}d ago`:c>0?`${c}h ago`:i>0?`${i}m ago`:"just now"}catch{return""}}function Ht(s){if(!s)return!1;try{const a=new Date(s);return new Date().getTime()-a.getTime()<3600*1e3}catch{return!1}}function Ut({account:s,onSetDefault:a,onRemove:t,onPauseToggle:r,isRemoving:i,isPausingAccount:c,privacyMode:l,showQuota:u,selectable:o,selected:x,onSelectChange:g}){const{data:h}=ks(u),{data:p,isLoading:d}=Ss(s.provider,s.id,u),C=h?.accountStats?.[s.email||s.id]?.lastUsedAt,E=Ht(C),j=p?.success?As(p.models):null,D=p?.success&&p.models.length>0?Ps(p.models):null;return e.jsxs("div",{className:_("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",s.paused&&"opacity-75",x&&"ring-2 ring-primary/50 bg-primary/5"),children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[o&&e.jsx("button",{type:"button",onClick:()=>g?.(!x),className:_("flex items-center justify-center w-5 h-5 rounded border-2 transition-colors shrink-0",x?"bg-primary border-primary text-primary-foreground":"border-muted-foreground/30 hover:border-primary/50"),"aria-label":x?"Deselect account":"Select account",children:x&&e.jsx(q,{className:"w-3 h-3"})}),r&&e.jsx(X,{children:e.jsxs(Z,{children:[e.jsx(ee,{asChild:!0,children:e.jsx(w,{variant:"ghost",size:"icon",className:"h-7 w-7 shrink-0",onClick:()=>r(!s.paused),disabled:c,children:c?e.jsx($,{className:"w-4 h-4 animate-spin"}):s.paused?e.jsx(is,{className:"w-4 h-4 text-emerald-500"}):e.jsx(xe,{className:"w-4 h-4 text-muted-foreground hover:text-foreground"})})}),e.jsx(se,{side:"top",children:s.paused?"Resume account":"Pause account"})]})}),e.jsx("div",{className:_("flex items-center justify-center w-8 h-8 rounded-full",s.isDefault?"bg-primary/10":"bg-muted"),children:e.jsx(W,{className:"w-4 h-4"})}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:_("font-medium text-sm",l&&ie),children:s.email||s.id}),s.isDefault&&e.jsxs(K,{variant:"secondary",className:"text-[10px] h-4 px-1.5 gap-0.5",children:[e.jsx(oe,{className:"w-2.5 h-2.5 fill-current"}),"Default"]}),s.tier&&s.tier!=="unknown"&&e.jsx(K,{variant:"outline",className:_("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(K,{variant:"outline",className:"text-[10px] h-4 px-1.5 border-yellow-500 text-yellow-600",children:[e.jsx(xe,{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(X,{children:e.jsxs(Z,{children:[e.jsx(ee,{asChild:!0,children:e.jsxs("div",{className:"flex items-center gap-1 text-xs text-muted-foreground",children:[e.jsx(ot,{className:"w-3 h-3","aria-hidden":"true"}),e.jsx("span",{className:_("font-mono max-w-[180px] truncate",l&&ie),title:s.projectId,children:s.projectId})]})}),e.jsx(se,{side:"bottom",children:e.jsx("p",{className:"text-xs",children:"GCP Project ID (read-only)"})})]})}):e.jsx(X,{children:e.jsxs(Z,{children:[e.jsx(ee,{asChild:!0,children:e.jsxs("div",{className:"flex items-center gap-1 text-xs text-amber-600 dark:text-amber-500",children:[e.jsx(lt,{className:"w-3 h-3","aria-label":"Warning"}),e.jsx("span",{children:"Project ID: N/A"})]})}),e.jsx(se,{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(de,{className:"w-3 h-3"}),"Last used: ",new Date(s.lastUsedAt).toLocaleDateString()]})]})]}),e.jsxs(Ms,{children:[e.jsx(Ts,{asChild:!0,children:e.jsx(w,{variant:"ghost",size:"icon",className:"h-7 w-7",children:e.jsx(ct,{className:"w-4 h-4"})})}),e.jsxs(Os,{align:"end",children:[!s.isDefault&&e.jsxs(Re,{onClick:a,children:[e.jsx(oe,{className:"w-4 h-4 mr-2"}),"Set as default"]}),e.jsxs(Re,{className:"text-destructive focus:text-destructive",onClick:t,disabled:i,children:[e.jsx(rs,{className:"w-4 h-4 mr-2"}),i?"Removing...":"Remove account"]})]})]})]}),u&&e.jsx("div",{className:"pl-11",children:d?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..."})]}):j!==null?e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("div",{className:"flex items-center gap-1.5 text-xs",children:E?e.jsxs(e.Fragment,{children:[e.jsx(dt,{className:"w-3 h-3 text-emerald-500"}),e.jsxs("span",{className:"text-emerald-600 dark:text-emerald-400",children:["Active · ",Ue(C)]})]}):C?e.jsxs(e.Fragment,{children:[e.jsx(de,{className:"w-3 h-3 text-muted-foreground"}),e.jsxs("span",{className:"text-muted-foreground",children:["Last used ",Ue(C)]})]}):e.jsxs(e.Fragment,{children:[e.jsx(ut,{className:"w-3 h-3 text-muted-foreground"}),e.jsx("span",{className:"text-muted-foreground",children:"Not used yet"})]})}),e.jsx(X,{children:e.jsxs(Z,{children:[e.jsx(ee,{asChild:!0,children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ds,{value:Math.max(0,Math.min(100,j)),className:"h-2 flex-1",indicatorClassName:Ft(j)}),e.jsxs("span",{className:"text-xs font-medium w-10 text-right",children:[j,"%"]})]})}),e.jsx(se,{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:"}),(()=>{const L=Is(p?.models||[]),O=_s(L),M=["primary","gemini-3","gemini-2","other"];return M.map((T,f)=>{const P=O.get(T);if(!P||P.length===0)return null;const v=M.slice(0,f).every(k=>!O.get(k)?.length);return e.jsxs("div",{children:[!v&&e.jsx("div",{className:"border-t border-border/40 my-1"}),P.map(k=>e.jsxs("div",{className:"flex justify-between gap-4",children:[e.jsx("span",{className:_("truncate",k.exhausted&&"text-red-500"),children:k.displayName}),e.jsxs("span",{className:_("font-mono",k.exhausted&&"text-red-500"),children:[k.percentage,"%"]})]},k.name))]},T)})})(),D&&e.jsxs("div",{className:"flex items-center gap-1.5 pt-1 border-t border-border/50",children:[e.jsx(de,{className:"w-3 h-3 text-blue-400"}),e.jsxs("span",{className:"text-blue-400 font-medium",children:["Resets ",Es(D)]})]})]})})]})})]}):p?.error||p&&!p.success?e.jsx(X,{children:e.jsxs(Z,{children:[e.jsx(ee,{asChild:!0,children:e.jsx("div",{className:"flex items-center gap-1.5",children:e.jsxs(K,{variant:"outline",className:"text-[10px] h-5 px-2 gap-1 border-muted-foreground/50 text-muted-foreground",children:[e.jsx(mt,{className:"w-3 h-3"}),"N/A"]})})}),e.jsx(se,{side:"bottom",children:e.jsx("p",{className:"text-xs",children:p?.error||"Quota information unavailable"})})]})}):null})]})}function Gt({selectedCount:s,onPauseSelected:a,onResumeSelected:t,onClearSelection:r,isPausing:i,isResuming:c}){if(s<1)return null;const l=i||c;return e.jsxs("div",{className:"flex items-center gap-3 p-2 bg-muted/50 rounded-lg border mt-2",children:[e.jsxs("span",{className:"text-sm text-muted-foreground",children:[s," selected"]}),e.jsx(w,{variant:"ghost",size:"sm",className:"text-xs h-6 px-2",onClick:r,disabled:l,children:"Clear"}),e.jsxs("div",{className:"flex gap-2 ml-auto",children:[e.jsxs(w,{size:"sm",variant:"outline",className:"h-7 text-xs gap-1",onClick:a,disabled:l,children:[i?e.jsx($,{className:"w-3 h-3 animate-spin"}):e.jsx(xe,{className:"w-3 h-3"}),"Pause Selected"]}),e.jsxs(w,{size:"sm",variant:"outline",className:"h-7 text-xs gap-1",onClick:t,disabled:l,children:[c?e.jsx($,{className:"w-3 h-3 animate-spin"}):e.jsx(is,{className:"w-3 h-3"}),"Resume Selected"]})]})]})}function Kt({accounts:s,onAddAccount:a,onSetDefault:t,onRemoveAccount:r,onPauseToggle:i,onSoloMode:c,onBulkPause:l,onBulkResume:u,isRemovingAccount:o,isPausingAccount:x,isSoloingAccount:g,isBulkPausing:h,isBulkResuming:p,privacyMode:d,showQuota:C,isKiro:E,kiroNoIncognito:j,onKiroNoIncognitoChange:D,kiroSettingsLoading:L}){const[O,M]=m.useState(new Set),T=m.useMemo(()=>new Set(s.map(N=>N.id)),[s]),f=m.useMemo(()=>new Set([...O].filter(N=>T.has(N))),[O,T]),P=!!(l&&u),v=f.size,k=s.length>0&&f.size===s.length,R=f.size>0&&f.size<s.length,S=m.useCallback(N=>{M(I=>{const G=new Set(I);return G.has(N)?G.delete(N):G.add(N),G})},[]),b=m.useCallback(()=>{M(new Set(s.map(N=>N.id)))},[s]),F=m.useCallback(()=>{M(new Set)},[]),U=m.useCallback(()=>{k?F():b()},[k,b,F]),z=m.useCallback(()=>{l&&f.size>0&&(l(Array.from(f)),M(new Set))},[l,f]),y=m.useCallback(()=>{u&&f.size>0&&(u(Array.from(f)),M(new Set))},[u,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:[P&&s.length>0&&e.jsx(Lt,{checked:k,onCheckedChange:U,"aria-label":"Select all accounts",className:R?"data-[state=checked]:bg-primary/50":"",...R?{"data-state":"indeterminate"}:{}}),e.jsx(W,{className:"w-4 h-4"}),"Accounts",s.length>0&&e.jsx(K,{variant:"secondary",className:"text-xs",children:s.length})]}),e.jsxs(w,{variant:"default",size:"sm",className:"h-7 text-xs gap-1",onClick:a,children:[e.jsx(ns,{className:"w-3 h-3"}),"Add"]})]}),P&&v>0&&e.jsx(Gt,{selectedCount:v,onPauseSelected:z,onResumeSelected:y,onClearSelection:F,isPausing:!!h,isResuming:!!p}),s.length>0?e.jsx("div",{className:"space-y-2",children:s.map(N=>e.jsx(Ut,{account:N,onSetDefault:()=>t(N.id),onRemove:()=>r(N.id),onPauseToggle:i?I=>i(N.id,I):void 0,onSoloMode:c?()=>c(N.id):void 0,isRemoving:o,isPausingAccount:x,isSoloingAccount:g,privacyMode:d,showQuota:C,selectable:P,selected:f.has(N.id),onSelectChange:()=>S(N.id)},N.id))}):e.jsxs("div",{className:"py-6 text-center text-muted-foreground bg-muted/30 rounded-lg border border-dashed",children:[e.jsx(W,{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"})]}),E&&D&&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(as,{className:"w-3.5 h-3.5"}),e.jsx("span",{children:"Use incognito"})]}),e.jsx(ht,{checked:!j,onCheckedChange:N=>D(!N),disabled:L,className:"scale-90"})]})})]})}function zt({provider:s,catalog:a,savedPresets:t,currentModel:r,opusModel:i,sonnetModel:c,haikuModel:l,providerModels:u,onApplyPreset:o,onUpdateEnvValue:x,onOpenCustomPreset:g,onDeletePreset:h,isDeletePending:p,accounts:d,onAddAccount:C,onSetDefault:E,onRemoveAccount:j,onPauseToggle:D,onSoloMode:L,onBulkPause:O,onBulkResume:M,isRemovingAccount:T,isPausingAccount:f,isSoloingAccount:P,isBulkPausing:v,isBulkResuming:k,privacyMode:R,isRemoteMode:S}){const b=s==="kiro",[F,U]=m.useState(!0),[z,y]=m.useState(!0),[N,I]=m.useState(!1),G=m.useCallback(async()=>{if(b)try{y(!0);const A=(await ce.config.get()).cliproxy;U(A?.kiro_no_incognito??!0)}catch{U(!0)}finally{y(!1)}},[b]),Y=m.useCallback(async n=>{U(n),I(!0);try{const A=await ce.config.get(),J=A.cliproxy??{};await ce.config.update({...A,cliproxy:{...J,kiro_no_incognito:n}})}catch{U(!n)}finally{I(!1)}},[]);return m.useEffect(()=>{G()},[G]),e.jsx(we,{className:"flex-1",children:e.jsxs("div",{className:"p-4 space-y-6",children:[e.jsx(Rt,{catalog:a,savedPresets:t,currentModel:r,opusModel:i,sonnetModel:c,haikuModel:l,providerModels:u,onApplyPreset:o,onUpdateEnvValue:x,onOpenCustomPreset:g,onDeletePreset:h,isDeletePending:p}),e.jsx(Se,{}),e.jsx(Kt,{accounts:d,onAddAccount:C,onSetDefault:E,onRemoveAccount:j,onPauseToggle:D,onSoloMode:L,onBulkPause:O,onBulkResume:M,isRemovingAccount:T,isPausingAccount:f,isSoloingAccount:P,isBulkPausing:v,isBulkResuming:k,privacyMode:R,showQuota:s==="agy"&&!S,isKiro:b,kiroNoIncognito:F,onKiroNoIncognitoChange:Y,kiroSettingsLoading:z||N})]})})}function Ge({provider:s,displayName:a,authStatus:t,catalog:r,logoProvider:i,baseProvider:c,isRemoteMode:l,port:u,onAddAccount:o,onSetDefault:x,onRemoveAccount:g,onPauseToggle:h,onSoloMode:p,onBulkPause:d,onBulkResume:C,isRemovingAccount:E,isPausingAccount:j,isSoloingAccount:D,isBulkPausing:L,isBulkResuming:O}){const[M,T]=m.useState(!1),{privacyMode:f}=Ze(),{data:P}=Rs(),{data:v}=Ls(s),k=Fs(),R=Hs(),S=v?.presets||[],b=c||s,F=m.useMemo(()=>{if(!P?.models)return[];const V={gemini:["google"],agy:["antigravity"],codex:["openai"],qwen:["alibaba","qwen"],iflow:["iflow"],kiro:["kiro","aws"],ghcp:["github","copilot"]}[b.toLowerCase()]||[b.toLowerCase()];return P.models.filter(Ie=>V.some(js=>Ie.owned_by.toLowerCase().includes(js)))},[P,b]),{data:U,isLoading:z,refetch:y,rawJsonContent:N,rawJsonEdits:I,isRawJsonValid:G,hasChanges:Y,currentModel:n,opusModel:A,sonnetModel:J,haikuModel:Pe,handleRawJsonChange:cs,updateEnvValue:ds,updateEnvValues:Me,saveMutation:Te,conflictDialog:us,handleConflictResolve:Oe,missingRequiredFields:ms}=Mt(s),xs=t.accounts||[],{data:ps}=ze({queryKey:["auth-tokens-raw"],queryFn:async()=>{const H=await fetch("/api/settings/auth/tokens/raw");return H.ok?H.json():{apiKey:{value:"ccs-internal-managed"}}},staleTime:6e4}),De=ps?.apiKey?.value??"ccs-internal-managed",hs=H=>{Me({ANTHROPIC_BASE_URL:`http://127.0.0.1:${u??pe}/api/provider/${s}`,ANTHROPIC_AUTH_TOKEN:De,...H}),B.success(`Applied "${H.ANTHROPIC_MODEL?.split("/").pop()||"preset"}" preset`)},gs=(H,V)=>{Me({ANTHROPIC_BASE_URL:`http://127.0.0.1:${u??pe}/api/provider/${s}`,ANTHROPIC_AUTH_TOKEN:De,ANTHROPIC_MODEL:H.default,ANTHROPIC_DEFAULT_OPUS_MODEL:H.opus,ANTHROPIC_DEFAULT_SONNET_MODEL:H.sonnet,ANTHROPIC_DEFAULT_HAIKU_MODEL:H.haiku}),B.success(`Applied ${V?`"${V}"`:"custom"} preset`),T(!1)},fs=(H,V)=>{if(!V){B.error("Please enter a preset name to save");return}k.mutate({profile:s,data:{name:V,...H}}),T(!1)};return e.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden",children:[e.jsx(Et,{provider:s,displayName:a,logoProvider:i,data:U,isLoading:z,hasChanges:Y,isRawJsonValid:G,isSaving:Te.isPending,isRemoteMode:l,port:u,onRefetch:y,onSave:()=>Te.mutate()}),z?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(Us,{defaultValue:"config",className:"h-full flex flex-col",children:[e.jsx("div",{className:"px-4 pt-4 shrink-0",children:e.jsxs(Gs,{className:"w-full",children:[e.jsx(Le,{value:"config",className:"flex-1",children:"Model Config"}),e.jsx(Le,{value:"info",className:"flex-1",children:"Info & Usage"})]})}),e.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col",children:[e.jsx(Fe,{value:"config",className:"flex-1 mt-0 border-0 p-0 data-[state=inactive]:hidden flex flex-col overflow-hidden",children:e.jsx(zt,{provider:s,catalog:r,savedPresets:S,currentModel:n,opusModel:A,sonnetModel:J,haikuModel:Pe,providerModels:F,onApplyPreset:hs,onUpdateEnvValue:ds,onOpenCustomPreset:()=>T(!0),onDeletePreset:H=>R.mutate({profile:s,name:H}),isDeletePending:R.isPending,accounts:xs,onAddAccount:o,onSetDefault:x,onRemoveAccount:g,onPauseToggle:h,onSoloMode:p,onBulkPause:d,onBulkResume:C,isRemovingAccount:E,isPausingAccount:j,isSoloingAccount:D,isBulkPausing:L,isBulkResuming:O,privacyMode:f,isRemoteMode:l})}),e.jsx(Fe,{value:"info",className:"h-full mt-0 border-0 p-0 data-[state=inactive]:hidden",children:e.jsx(Ot,{provider:s,displayName:a,data:U,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(xt,{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(Ks,{rawJsonContent:N,isRawJsonValid:G,rawJsonEdits:I,onRawJsonChange:cs,profileEnv:U?.settings?.env,missingRequiredFields:ms})]})]}),e.jsx(pt,{open:us,title:"File Modified Externally",description:"This settings file was modified by another process. Overwrite with your changes or discard?",confirmText:"Overwrite",variant:"destructive",onConfirm:()=>Oe(!0),onCancel:()=>Oe(!1)}),e.jsx(Tt,{open:M,onClose:()=>T(!1),currentValues:{default:n||"",opus:A||"",sonnet:J||"",haiku:Pe||""},onApply:gs,onSave:fs,isSaving:k.isPending,catalog:r,allModels:F})]})}function Bt({status:s,isSelected:a,onSelect:t}){const r=s.accounts?.length||0;return e.jsxs("button",{className:_("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(Ae,{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}),r>0&&e.jsx(K,{variant:"secondary",className:"text-[10px] h-4 px-1",children:r})]}),e.jsx("div",{className:"flex items-center gap-1.5 mt-0.5",children:s.authenticated?e.jsxs(e.Fragment,{children:[e.jsx(q,{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(ke,{className:"w-3 h-3 text-muted-foreground"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:"Not connected"})]})})]})]})}function $t({variant:s,parentAuth:a,isSelected:t,onSelect:r,onDelete:i,isDeleting:c}){return e.jsxs("button",{className:_("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:r,children:[e.jsxs("div",{className:"relative",children:[e.jsx(Ae,{provider:s.provider,size:"sm"}),e.jsx(os,{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(K,{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(q,{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(ke,{className:"w-3 h-3 text-muted-foreground"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:"Parent not connected"})]})})]}),e.jsx(w,{variant:"ghost",size:"icon",className:"h-6 w-6 opacity-0 group-hover:opacity-100 hover:text-destructive",onClick:l=>{l.stopPropagation(),i()},disabled:c,children:e.jsx(rs,{className:"w-3 h-3"})})]})}function qt({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(le,{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(w,{onClick:s,className:"gap-2",children:[e.jsx(ae,{className:"w-4 h-4"}),"Quick Setup"]})]})})}function ra(){const s=Ke(),{data:a,isLoading:t}=We(),{data:r,isFetching:i}=zs(),{data:c}=Bs(),l=$s(),u=qs(),o=Vs(),x=Qs(),g=Js(),h=Ws(),p=Ys(),d=Xs(),[C,E]=m.useState(()=>typeof window<"u"?localStorage.getItem("cliproxy-selected-provider"):null),[j,D]=m.useState(null),[L,O]=m.useState(!1),[M,T]=m.useState(null),f=m.useMemo(()=>a?.authStatus||[],[a?.authStatus]),P=a?.source==="remote",v=m.useMemo(()=>r?.variants||[],[r?.variants]),k=n=>{E(n),n&&localStorage.setItem("cliproxy-selected-provider",n)},R=m.useMemo(()=>j?null:C&&f.some(n=>n.provider===C)?C:f.length>0&&(f.find(A=>(A.accounts?.length||0)>0)?.provider||f[0]?.provider)||null,[C,j,f]),S=f.find(n=>n.provider===R),b=v.find(n=>n.name===j),F=b?f.find(n=>n.provider===b.provider):void 0,U=()=>{s.invalidateQueries({queryKey:["cliproxy"]}),s.invalidateQueries({queryKey:["cliproxy-auth"]})},z=(n,A,J)=>{o.isPending||x.isPending||(J?o.mutate({provider:n,accountId:A}):x.mutate({provider:n,accountId:A}))},y=(n,A)=>{g.isPending||g.mutate({provider:n,accountId:A})},N=(n,A)=>{h.isPending||h.mutate({provider:n,accountIds:A})},I=(n,A)=>{p.isPending||p.mutate({provider:n,accountIds:A})},G=n=>{k(n),D(null)},Y=n=>{D(n),k(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(le,{className:"w-5 h-5 text-primary"}),e.jsx("h1",{className:"font-semibold",children:c?.backendLabel??"CLIProxy"})]}),e.jsx(w,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:U,disabled:i,children:e.jsx(Ce,{className:_("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(w,{variant:"default",size:"sm",className:"w-full gap-2",onClick:()=>O(!0),children:[e.jsx(ae,{className:"w-4 h-4"}),"Quick Setup"]})]}),e.jsx(we,{className:"flex-1",children:e.jsxs("div",{className:"p-2",children:[e.jsx("div",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide px-3 py-2",children:"Providers"}),t?e.jsx("div",{className:"space-y-2 px-2",children:[1,2,3,4].map(n=>e.jsx(Zs,{className:"h-14 w-full rounded-lg"},n))}):e.jsx("div",{className:"space-y-1",children:f.map(n=>e.jsx(Bt,{status:n,isSelected:R===n.provider,onSelect:()=>G(n.provider)},n.provider))}),v.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(os,{className:"w-3 h-3"}),"Variants"]}),e.jsx("div",{className:"space-y-1",children:v.map(n=>e.jsx($t,{variant:n,parentAuth:f.find(A=>A.provider===n.provider),isSelected:j===n.name,onSelect:()=>Y(n.name),onDelete:()=>d.mutate(n.name),isDeleting:d.isPending},n.name))})]})]})}),e.jsx("div",{className:"p-3 border-t",children:e.jsx(gt,{})}),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:[f.length," provider",f.length!==1?"s":""]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(q,{className:"w-3 h-3 text-green-600"}),f.filter(n=>n.authenticated).length," connected"]})]})})]}),e.jsx("div",{className:"flex-1 flex flex-col min-w-0 bg-background",children:b&&F?e.jsx(Ge,{provider:b.name,displayName:`${b.name} (${b.provider} variant)`,authStatus:F,catalog:te[b.provider],logoProvider:b.provider,baseProvider:b.provider,isRemoteMode:P,port:b.port,onAddAccount:()=>T({provider:b.provider,displayName:F.displayName,isFirstAccount:(F.accounts?.length||0)===0}),onSetDefault:n=>l.mutate({provider:b.provider,accountId:n}),onRemoveAccount:n=>u.mutate({provider:b.provider,accountId:n}),onPauseToggle:(n,A)=>z(b.provider,n,A),onSoloMode:n=>y(b.provider,n),onBulkPause:n=>N(b.provider,n),onBulkResume:n=>I(b.provider,n),isRemovingAccount:u.isPending,isPausingAccount:o.isPending||x.isPending,isSoloingAccount:g.isPending,isBulkPausing:h.isPending,isBulkResuming:p.isPending}):S?e.jsx(Ge,{provider:S.provider,displayName:S.displayName,authStatus:S,catalog:te[S.provider],isRemoteMode:P,onAddAccount:()=>T({provider:S.provider,displayName:S.displayName,isFirstAccount:(S.accounts?.length||0)===0}),onSetDefault:n=>l.mutate({provider:S.provider,accountId:n}),onRemoveAccount:n=>u.mutate({provider:S.provider,accountId:n}),onPauseToggle:(n,A)=>z(S.provider,n,A),onSoloMode:n=>y(S.provider,n),onBulkPause:n=>N(S.provider,n),onBulkResume:n=>I(S.provider,n),isRemovingAccount:u.isPending,isPausingAccount:o.isPending||x.isPending,isSoloingAccount:g.isPending,isBulkPausing:h.isPending,isBulkResuming:p.isPending}):e.jsx(qt,{onSetup:()=>O(!0)})}),e.jsx(kt,{open:L,onClose:()=>O(!1)}),e.jsx(St,{open:M!==null,onClose:()=>T(null),provider:M?.provider||"",displayName:M?.displayName||"",isFirstAccount:M?.isFirstAccount||!1})]})}export{ra as CliproxyPage};