@kaitranntt/ccs 7.51.0-dev.12 → 7.51.0-dev.13

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 (44) hide show
  1. package/README.md +7 -1
  2. package/dist/commands/api-command.d.ts.map +1 -1
  3. package/dist/commands/api-command.js +2 -0
  4. package/dist/commands/api-command.js.map +1 -1
  5. package/dist/commands/help-command.d.ts.map +1 -1
  6. package/dist/commands/help-command.js +5 -1
  7. package/dist/commands/help-command.js.map +1 -1
  8. package/dist/shared/provider-preset-catalog.d.ts +1 -1
  9. package/dist/shared/provider-preset-catalog.d.ts.map +1 -1
  10. package/dist/shared/provider-preset-catalog.js +19 -1
  11. package/dist/shared/provider-preset-catalog.js.map +1 -1
  12. package/dist/ui/assets/{accounts-C461-bYH.js → accounts-szAllF_0.js} +1 -1
  13. package/dist/ui/assets/{alert-dialog-DpjPV6hi.js → alert-dialog-DPdKlUG9.js} +1 -1
  14. package/dist/ui/assets/api-Bq7TnM0v.js +1 -0
  15. package/dist/ui/assets/{auth-section-a4QIr8Cu.js → auth-section-DYPWbNRj.js} +1 -1
  16. package/dist/ui/assets/{backups-section-JcABaxvV.js → backups-section-gIWfCGmR.js} +1 -1
  17. package/dist/ui/assets/{checkbox-DCwR0qqq.js → checkbox-CcX8-GfD.js} +1 -1
  18. package/dist/ui/assets/{cliproxy-CvT_CrEG.js → cliproxy-SS8eRAX0.js} +1 -1
  19. package/dist/ui/assets/{cliproxy-control-panel-DwnkIgNd.js → cliproxy-control-panel-Bu0TtDft.js} +1 -1
  20. package/dist/ui/assets/{confirm-dialog-DY2Ziz3R.js → confirm-dialog-BZj0PYFs.js} +1 -1
  21. package/dist/ui/assets/{copilot-4Z8LP3vC.js → copilot-DnJj3frU.js} +2 -2
  22. package/dist/ui/assets/{cursor-DGcuUa4B.js → cursor-rS1S0i_y.js} +1 -1
  23. package/dist/ui/assets/{droid-C5Rebf4T.js → droid-Dfc2QwbE.js} +2 -2
  24. package/dist/ui/assets/{globalenv-section-C8zXrVbd.js → globalenv-section-BrHb5lRq.js} +1 -1
  25. package/dist/ui/assets/{health-B82MeRXO.js → health-B0WQPDXb.js} +1 -1
  26. package/dist/ui/assets/icons-BYZM_9Gm.js +1 -0
  27. package/dist/ui/assets/{index-BIAXf19X.js → index-BFTIN2qO.js} +1 -1
  28. package/dist/ui/assets/{index-z8fzygJg.js → index-BVBXszJi.js} +1 -1
  29. package/dist/ui/assets/index-DCQkhmoo.js +47 -0
  30. package/dist/ui/assets/{index-D09dhWOP.js → index-DxKsP0Ke.js} +1 -1
  31. package/dist/ui/assets/{index-vh-9Yvr6.js → index-LHbr_5SB.js} +1 -1
  32. package/dist/ui/assets/index-WBo504Wu.css +1 -0
  33. package/dist/ui/assets/providers/alibabacloud-color.svg +1 -0
  34. package/dist/ui/assets/{proxy-status-widget-K1IwJ8u6.js → proxy-status-widget-DPXgRGkB.js} +1 -1
  35. package/dist/ui/assets/{separator-BBQkLglZ.js → separator-DtcqgZIS.js} +1 -1
  36. package/dist/ui/assets/{shared-bTrmCnMf.js → shared-DPJ_z23p.js} +1 -1
  37. package/dist/ui/assets/{switch-D9kCIDCe.js → switch-BL5xZtnr.js} +1 -1
  38. package/dist/ui/assets/{updates-CIkkbMYB.js → updates-B3HKUp7y.js} +1 -1
  39. package/dist/ui/index.html +3 -3
  40. package/package.json +1 -1
  41. package/dist/ui/assets/api-DjGF8-45.js +0 -1
  42. package/dist/ui/assets/icons-kPbuhVdj.js +0 -1
  43. package/dist/ui/assets/index-Ck953xpy.css +0 -1
  44. package/dist/ui/assets/index-CsbQfRnG.js +0 -47
@@ -1 +1 @@
1
- import{j as e}from"./radix-ui-BR1vy4kf.js";import{r as s}from"./react-vendor-CNOkPC89.js";import{u as k}from"./tanstack-e99Cjjy2.js";import{Y as K,aY as M}from"./index-CsbQfRnG.js";import{C as P}from"./default-ports-1QQSffYX.js";import{G as F,R as L,a3 as H,s as q,K as G,c as W,X as Y}from"./icons-kPbuhVdj.js";import"./notifications-B2HqRBj7.js";import"./utils-CzKF5WmX.js";import"./form-utils-Cn_Uld6y.js";import"./code-highlight-BRUf_pqB.js";function _({port:c=P}){const i=s.useRef(null),[$,b]=s.useState(null),[R,E]=s.useState(0),[g,m]=s.useState(null),[I,d]=s.useState(!1),[S,T]=s.useState(!0),{data:j,error:f}=k({queryKey:["cliproxy-server-config"],queryFn:()=>K.cliproxyServer.get(),staleTime:3e4}),{data:y}=k({queryKey:["auth-tokens-raw"],queryFn:async()=>{const t=await fetch(M("/settings/auth/tokens/raw"));if(!t.ok)throw new Error("Failed to fetch auth tokens");return t.json()},staleTime:3e4});s.useEffect(()=>{f&&console.warn("[ControlPanelEmbed] Config fetch failed, using local mode:",f)},[f]);const{managementUrl:n,checkUrl:u,authToken:r,isRemote:l,displayHost:x}=s.useMemo(()=>{const t=j?.remote;if(t?.enabled&&t?.host){const o=t.protocol||"http",a=t.port||(o==="https"?443:P),v=o==="https"&&a===443||o==="http"&&a===80?"":`:${a}`,w=`${o}://${t.host}${v}`;return{managementUrl:`${w}/management.html`,checkUrl:`${w}/`,authToken:t.auth_token||void 0,isRemote:!0,displayHost:`${t.host}${v}`}}const h=y?.managementSecret?.value||"ccs";return{managementUrl:`http://localhost:${c}/management.html`,checkUrl:`http://localhost:${c}/`,authToken:h,isRemote:!1,displayHost:`localhost:${c}`}},[j,y,c]),p=$===n,N=!p;s.useEffect(()=>{const t=new AbortController,h=async()=>{try{(await fetch(u,{signal:t.signal})).ok?(d(!0),m(null)):(d(!1),m(l?`Remote CLIProxy at ${x} returned an error`:"CLIProxy returned an error"))}catch(a){if(a instanceof Error&&a.name==="AbortError")return;d(!1),m(l?`Remote CLIProxy at ${x} is not reachable`:"CLIProxy is not running")}},o=setTimeout(()=>t.abort(),2e3);return h().finally(()=>clearTimeout(o)),()=>t.abort()},[u,l,x]);const C=s.useCallback(()=>{if(!(!p||!i.current?.contentWindow||!r))try{const t=u.replace(/\/$/,"");if(!i.current.src.startsWith(t)){console.warn("[ControlPanelEmbed] Iframe origin mismatch, skipping postMessage");return}i.current.contentWindow.postMessage({type:"ccs-auto-login",apiBase:t,managementKey:r},t)}catch(t){console.debug("[ControlPanelEmbed] postMessage failed - cross-origin:",t)}},[r,u,p]);s.useEffect(()=>{C()},[C]);const U=s.useCallback(()=>{b(n)},[n]),A=()=>{b(null),E(t=>t+1),m(null),d(!1)};return!I&&g?e.jsxs("div",{className:"flex-1 flex flex-col",children:[e.jsxs("div",{className:"flex items-center justify-between p-4 border-b",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(F,{className:"w-5 h-5 text-primary"}),e.jsx("h2",{className:"font-semibold",children:"CLIProxy Control Panel"})]}),e.jsxs("button",{className:"inline-flex items-center gap-2 px-3 py-1.5 text-sm border rounded-md hover:bg-muted",onClick:A,children:[e.jsx(L,{className:"w-4 h-4"}),"Retry"]})]}),e.jsx("div",{className:"flex-1 flex items-center justify-center bg-muted/20",children:e.jsxs("div",{className:"text-center max-w-md px-8",children:[e.jsx("div",{className:"w-16 h-16 rounded-full bg-destructive/10 flex items-center justify-center mx-auto mb-6",children:e.jsx(H,{className:"w-8 h-8 text-destructive"})}),e.jsx("h3",{className:"text-lg font-semibold mb-2",children:"CLIProxy Not Available"}),e.jsx("p",{className:"text-muted-foreground mb-4",children:g}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Start a CLIProxy session with"," ",e.jsx("code",{className:"bg-muted px-1 rounded",children:"ccs gemini"})," or run"," ",e.jsx("code",{className:"bg-muted px-1 rounded",children:"ccs config"})," which auto-starts it."]})]})})]}):e.jsxs("div",{className:"flex-1 flex flex-col relative",children:[S&&!N&&e.jsx("div",{className:"absolute top-2 left-1/2 -translate-x-1/2 z-20",children:e.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5 bg-blue-50 dark:bg-blue-950 border border-blue-200 dark:border-blue-800 rounded-md text-sm",children:[l&&e.jsxs(e.Fragment,{children:[e.jsx(q,{className:"h-3.5 w-3.5 text-green-600"}),e.jsx("span",{className:"text-green-600 font-medium",children:"Remote"}),e.jsx("span",{className:"text-blue-300 dark:text-blue-700",children:"|"})]}),e.jsx(G,{className:"h-3.5 w-3.5 text-blue-600"}),e.jsxs("span",{children:["Key:"," ",e.jsx("code",{className:"bg-blue-100 dark:bg-blue-900 px-1 rounded font-mono font-semibold",children:r&&r.length>4?`***${r.slice(-4)}`:r||"ccs"})]}),e.jsx("a",{href:"/settings?tab=auth",className:"text-blue-600 hover:text-blue-800 dark:hover:text-blue-400",title:"Manage auth tokens",children:e.jsx(W,{className:"h-3.5 w-3.5"})}),e.jsx("button",{className:"text-blue-600 hover:text-blue-800 dark:hover:text-blue-400",onClick:()=>T(!1),children:e.jsx(Y,{className:"h-3.5 w-3.5"})})]})}),N&&e.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-background/80 z-10",children:e.jsxs("div",{className:"text-center",children:[e.jsx(L,{className:"w-8 h-8 animate-spin text-primary mx-auto mb-2"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:l?`Loading Control Panel from ${x}...`:"Loading Control Panel..."})]})}),e.jsx("iframe",{ref:i,src:n,className:"flex-1 w-full border-0",title:"CLIProxy Management Panel",onLoad:U},`${n}:${R}`)]})}function te(){return e.jsx("div",{className:"h-[calc(100vh-100px)] flex flex-col",children:e.jsx(_,{})})}export{te as CliproxyControlPanelPage};
1
+ import{j as e}from"./radix-ui-BR1vy4kf.js";import{r as s}from"./react-vendor-CNOkPC89.js";import{u as k}from"./tanstack-e99Cjjy2.js";import{Y as K,aY as M}from"./index-DCQkhmoo.js";import{C as P}from"./default-ports-1QQSffYX.js";import{G as F,R as L,a3 as H,s as q,K as G,c as W,X as Y}from"./icons-BYZM_9Gm.js";import"./notifications-B2HqRBj7.js";import"./utils-CzKF5WmX.js";import"./form-utils-Cn_Uld6y.js";import"./code-highlight-BRUf_pqB.js";function _({port:c=P}){const i=s.useRef(null),[$,b]=s.useState(null),[R,E]=s.useState(0),[g,m]=s.useState(null),[I,d]=s.useState(!1),[S,T]=s.useState(!0),{data:j,error:f}=k({queryKey:["cliproxy-server-config"],queryFn:()=>K.cliproxyServer.get(),staleTime:3e4}),{data:y}=k({queryKey:["auth-tokens-raw"],queryFn:async()=>{const t=await fetch(M("/settings/auth/tokens/raw"));if(!t.ok)throw new Error("Failed to fetch auth tokens");return t.json()},staleTime:3e4});s.useEffect(()=>{f&&console.warn("[ControlPanelEmbed] Config fetch failed, using local mode:",f)},[f]);const{managementUrl:n,checkUrl:u,authToken:r,isRemote:l,displayHost:x}=s.useMemo(()=>{const t=j?.remote;if(t?.enabled&&t?.host){const o=t.protocol||"http",a=t.port||(o==="https"?443:P),v=o==="https"&&a===443||o==="http"&&a===80?"":`:${a}`,w=`${o}://${t.host}${v}`;return{managementUrl:`${w}/management.html`,checkUrl:`${w}/`,authToken:t.auth_token||void 0,isRemote:!0,displayHost:`${t.host}${v}`}}const h=y?.managementSecret?.value||"ccs";return{managementUrl:`http://localhost:${c}/management.html`,checkUrl:`http://localhost:${c}/`,authToken:h,isRemote:!1,displayHost:`localhost:${c}`}},[j,y,c]),p=$===n,N=!p;s.useEffect(()=>{const t=new AbortController,h=async()=>{try{(await fetch(u,{signal:t.signal})).ok?(d(!0),m(null)):(d(!1),m(l?`Remote CLIProxy at ${x} returned an error`:"CLIProxy returned an error"))}catch(a){if(a instanceof Error&&a.name==="AbortError")return;d(!1),m(l?`Remote CLIProxy at ${x} is not reachable`:"CLIProxy is not running")}},o=setTimeout(()=>t.abort(),2e3);return h().finally(()=>clearTimeout(o)),()=>t.abort()},[u,l,x]);const C=s.useCallback(()=>{if(!(!p||!i.current?.contentWindow||!r))try{const t=u.replace(/\/$/,"");if(!i.current.src.startsWith(t)){console.warn("[ControlPanelEmbed] Iframe origin mismatch, skipping postMessage");return}i.current.contentWindow.postMessage({type:"ccs-auto-login",apiBase:t,managementKey:r},t)}catch(t){console.debug("[ControlPanelEmbed] postMessage failed - cross-origin:",t)}},[r,u,p]);s.useEffect(()=>{C()},[C]);const U=s.useCallback(()=>{b(n)},[n]),A=()=>{b(null),E(t=>t+1),m(null),d(!1)};return!I&&g?e.jsxs("div",{className:"flex-1 flex flex-col",children:[e.jsxs("div",{className:"flex items-center justify-between p-4 border-b",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(F,{className:"w-5 h-5 text-primary"}),e.jsx("h2",{className:"font-semibold",children:"CLIProxy Control Panel"})]}),e.jsxs("button",{className:"inline-flex items-center gap-2 px-3 py-1.5 text-sm border rounded-md hover:bg-muted",onClick:A,children:[e.jsx(L,{className:"w-4 h-4"}),"Retry"]})]}),e.jsx("div",{className:"flex-1 flex items-center justify-center bg-muted/20",children:e.jsxs("div",{className:"text-center max-w-md px-8",children:[e.jsx("div",{className:"w-16 h-16 rounded-full bg-destructive/10 flex items-center justify-center mx-auto mb-6",children:e.jsx(H,{className:"w-8 h-8 text-destructive"})}),e.jsx("h3",{className:"text-lg font-semibold mb-2",children:"CLIProxy Not Available"}),e.jsx("p",{className:"text-muted-foreground mb-4",children:g}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Start a CLIProxy session with"," ",e.jsx("code",{className:"bg-muted px-1 rounded",children:"ccs gemini"})," or run"," ",e.jsx("code",{className:"bg-muted px-1 rounded",children:"ccs config"})," which auto-starts it."]})]})})]}):e.jsxs("div",{className:"flex-1 flex flex-col relative",children:[S&&!N&&e.jsx("div",{className:"absolute top-2 left-1/2 -translate-x-1/2 z-20",children:e.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5 bg-blue-50 dark:bg-blue-950 border border-blue-200 dark:border-blue-800 rounded-md text-sm",children:[l&&e.jsxs(e.Fragment,{children:[e.jsx(q,{className:"h-3.5 w-3.5 text-green-600"}),e.jsx("span",{className:"text-green-600 font-medium",children:"Remote"}),e.jsx("span",{className:"text-blue-300 dark:text-blue-700",children:"|"})]}),e.jsx(G,{className:"h-3.5 w-3.5 text-blue-600"}),e.jsxs("span",{children:["Key:"," ",e.jsx("code",{className:"bg-blue-100 dark:bg-blue-900 px-1 rounded font-mono font-semibold",children:r&&r.length>4?`***${r.slice(-4)}`:r||"ccs"})]}),e.jsx("a",{href:"/settings?tab=auth",className:"text-blue-600 hover:text-blue-800 dark:hover:text-blue-400",title:"Manage auth tokens",children:e.jsx(W,{className:"h-3.5 w-3.5"})}),e.jsx("button",{className:"text-blue-600 hover:text-blue-800 dark:hover:text-blue-400",onClick:()=>T(!1),children:e.jsx(Y,{className:"h-3.5 w-3.5"})})]})}),N&&e.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-background/80 z-10",children:e.jsxs("div",{className:"text-center",children:[e.jsx(L,{className:"w-8 h-8 animate-spin text-primary mx-auto mb-2"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:l?`Loading Control Panel from ${x}...`:"Loading Control Panel..."})]})}),e.jsx("iframe",{ref:i,src:n,className:"flex-1 w-full border-0",title:"CLIProxy Management Panel",onLoad:U},`${n}:${R}`)]})}function te(){return e.jsx("div",{className:"h-[calc(100vh-100px)] flex flex-col",children:e.jsx(_,{})})}export{te as CliproxyControlPanelPage};
@@ -1 +1 @@
1
- import{j as e}from"./radix-ui-BR1vy4kf.js";import{A as c,a as d,b as g,c as x,d as h,e as j,f as A,g as D}from"./alert-dialog-DpjPV6hi.js";function f({open:i,onConfirm:l,onCancel:r,title:s,description:t,confirmText:a="Confirm",variant:o="default"}){return e.jsx(c,{open:i,onOpenChange:n=>!n&&r(),children:e.jsxs(d,{children:[e.jsxs(g,{children:[e.jsx(x,{children:s}),e.jsx(h,{children:t})]}),e.jsxs(j,{children:[e.jsx(A,{onClick:r,children:"Cancel"}),e.jsx(D,{onClick:l,className:o==="destructive"?"bg-red-600 hover:bg-red-700 text-white":"",children:a})]})]})})}export{f as C};
1
+ import{j as e}from"./radix-ui-BR1vy4kf.js";import{A as c,a as d,b as g,c as x,d as h,e as j,f as A,g as D}from"./alert-dialog-DPdKlUG9.js";function f({open:i,onConfirm:l,onCancel:r,title:s,description:t,confirmText:a="Confirm",variant:o="default"}){return e.jsx(c,{open:i,onOpenChange:n=>!n&&r(),children:e.jsxs(d,{children:[e.jsxs(g,{children:[e.jsx(x,{children:s}),e.jsx(h,{children:t})]}),e.jsxs(j,{children:[e.jsx(A,{onClick:r,children:"Cancel"}),e.jsx(D,{onClick:l,className:o==="destructive"?"bg-red-600 hover:bg-red-700 text-white":"",children:a})]})]})})}export{f as C};
@@ -1,3 +1,3 @@
1
- import{j as e}from"./radix-ui-BR1vy4kf.js";import{aY as j,aZ as ye,B as b,d as v,a as X,r as ce,s as re,t as de,v as ue,ao as be,ap as Se,w as J,V as W,n as K,L as S,I as ae,x as me,a_ as Ce,S as y,Q as Pe,R as ke,U as V,a$ as Fe,c as Y}from"./index-CsbQfRnG.js";import{r as N}from"./react-vendor-CNOkPC89.js";import{a as Me,u as M,b as C}from"./tanstack-e99Cjjy2.js";import{C as Te}from"./confirm-dialog-DY2Ziz3R.js";import{R as xe,L as pe,ai as Le,k as Re,a2 as Ae,Z as ne,J as Ee,al as Oe,b as _e,T as qe,a5 as De,aq as Ie,ax as ie,K as Ue,I as Qe,ay as Je,u as he,v as ge}from"./icons-kPbuhVdj.js";import{S as Z}from"./separator-BBQkLglZ.js";import{S as $}from"./switch-D9kCIDCe.js";import{t as T}from"./notifications-B2HqRBj7.js";import"./utils-CzKF5WmX.js";import"./form-utils-Cn_Uld6y.js";import"./code-highlight-BRUf_pqB.js";import"./alert-dialog-DpjPV6hi.js";async function Ke(){const t=await fetch(j("/copilot/status"));if(!t.ok)throw new Error("Failed to fetch copilot status");return t.json()}async function Be(){const t=await fetch(j("/copilot/config"));if(!t.ok)throw new Error("Failed to fetch copilot config");return t.json()}async function ze(){const t=await fetch(j("/copilot/models"));if(!t.ok)throw new Error("Failed to fetch copilot models");return t.json()}async function Ge(){const t=await fetch(j("/copilot/settings/raw"));if(!t.ok)throw new Error("Failed to fetch copilot raw settings");return t.json()}async function Ve(t){const s=await fetch(j("/copilot/config"),{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!s.ok)throw new Error("Failed to update copilot config");return s.json()}async function $e(t){const s=await fetch(j("/copilot/settings/raw"),{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(s.status===409)throw new ye("Copilot raw settings changed externally");if(!s.ok)throw new Error("Failed to save copilot raw settings");return s.json()}async function He(){const t=await fetch(j("/copilot/auth/start"),{method:"POST"});if(!t.ok)throw new Error("Failed to start auth");return t.json()}async function Ye(){const t=await fetch(j("/copilot/daemon/start"),{method:"POST"});if(!t.ok)throw new Error("Failed to start daemon");return t.json()}async function Ze(){const t=await fetch(j("/copilot/daemon/stop"),{method:"POST"});if(!t.ok)throw new Error("Failed to stop daemon");return t.json()}async function Xe(){const t=await fetch(j("/copilot/info"));if(!t.ok)throw new Error("Failed to fetch copilot info");return t.json()}async function We(t){const s=await fetch(j("/copilot/install"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t?{version:t}:{})});if(!s.ok)throw new Error("Failed to install copilot-api");return s.json()}function fe(){const t=Me(),s=M({queryKey:["copilot-status"],queryFn:Ke,refetchInterval:5e3}),o=M({queryKey:["copilot-config"],queryFn:Be}),d=M({queryKey:["copilot-models"],queryFn:ze}),a=M({queryKey:["copilot-raw-settings"],queryFn:Ge}),c=M({queryKey:["copilot-info"],queryFn:Xe}),l=C({mutationFn:Ve,onSuccess:()=>{t.invalidateQueries({queryKey:["copilot-status"]}),t.invalidateQueries({queryKey:["copilot-config"]}),t.invalidateQueries({queryKey:["copilot-raw-settings"]})}}),u=C({mutationFn:$e,onSuccess:()=>{t.invalidateQueries({queryKey:["copilot-status"]}),t.invalidateQueries({queryKey:["copilot-config"]}),t.invalidateQueries({queryKey:["copilot-raw-settings"]})}}),i=C({mutationFn:He,onSuccess:()=>{t.invalidateQueries({queryKey:["copilot-status"]})}}),h=C({mutationFn:Ye,onSuccess:()=>{t.invalidateQueries({queryKey:["copilot-status"]})}}),g=C({mutationFn:Ze,onSuccess:()=>{t.invalidateQueries({queryKey:["copilot-status"]})}}),n=C({mutationFn:We,onSuccess:()=>{t.invalidateQueries({queryKey:["copilot-status"]}),t.invalidateQueries({queryKey:["copilot-info"]})}});return N.useMemo(()=>({status:s.data,statusLoading:s.isLoading,statusError:s.error,refetchStatus:s.refetch,config:o.data,configLoading:o.isLoading,models:d.data?.models??[],currentModel:d.data?.current,modelsLoading:d.isLoading,rawSettings:a.data,rawSettingsLoading:a.isLoading,refetchRawSettings:a.refetch,updateConfig:l.mutate,updateConfigAsync:l.mutateAsync,isUpdating:l.isPending,saveRawSettings:u.mutate,saveRawSettingsAsync:u.mutateAsync,isSavingRawSettings:u.isPending,startAuth:i.mutate,startAuthAsync:i.mutateAsync,isAuthenticating:i.isPending,authResult:i.data,startDaemon:h.mutate,isStartingDaemon:h.isPending,stopDaemon:g.mutate,isStoppingDaemon:g.isPending,info:c.data,infoLoading:c.isLoading,refetchInfo:c.refetch,install:n.mutate,installAsync:n.mutateAsync,isInstalling:n.isPending}),[s.data,s.isLoading,s.error,s.refetch,o.data,o.isLoading,d.data,d.isLoading,a.data,a.isLoading,a.refetch,l.mutate,l.mutateAsync,l.isPending,u.mutate,u.mutateAsync,u.isPending,i.mutate,i.mutateAsync,i.isPending,i.data,h.mutate,h.isPending,g.mutate,g.isPending,c.data,c.isLoading,c.refetch,n.mutate,n.mutateAsync,n.isPending])}function et({rawSettings:t,rawSettingsLoading:s,isUpdating:o,isSavingRawSettings:d,hasChanges:a,isRawJsonValid:c,onRefresh:l,onSave:u}){return e.jsxs("div",{className:"px-6 py-4 border-b bg-background flex items-center justify-between shrink-0",children:[e.jsx("div",{className:"flex items-center gap-3",children:e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h2",{className:"text-lg font-semibold",children:"Copilot Configuration"}),t&&e.jsx(b,{variant:"outline",className:"text-xs",children:"copilot.settings.json"})]}),t&&e.jsxs("p",{className:"text-xs text-muted-foreground mt-0.5",children:["Last modified:"," ",t.exists?new Date(t.mtime).toLocaleString():"Never saved"]})]})}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(v,{variant:"ghost",size:"sm",onClick:l,disabled:s,children:e.jsx(xe,{className:`w-4 h-4 ${s?"animate-spin":""}`})}),e.jsx(v,{size:"sm",onClick:u,disabled:o||d||!a||!c,children:o||d?e.jsxs(e.Fragment,{children:[e.jsx(pe,{className:"w-4 h-4 mr-1 animate-spin"}),"Saving..."]}):e.jsxs(e.Fragment,{children:[e.jsx(Le,{className:"w-4 h-4 mr-1"}),"Save"]})})]})]})}const tt=[{name:"GPT-4.1 (Free)",description:"Free tier - no premium usage",default:"gpt-4.1",opus:"gpt-4.1",sonnet:"gpt-4.1",haiku:"gpt-4.1"},{name:"GPT-5 Mini (Free)",description:"Free tier - lightweight model",default:"gpt-5-mini",opus:"gpt-5-mini",sonnet:"gpt-5-mini",haiku:"gpt-5-mini"},{name:"Raptor Mini (Free)",description:"Free tier - fine-tuned for coding",default:"raptor-mini",opus:"raptor-mini",sonnet:"raptor-mini",haiku:"raptor-mini"}],st=[{name:"Claude Opus 4.5",description:"Pro+ (3x) - Most capable reasoning",default:"claude-opus-4.5",opus:"claude-opus-4.5",sonnet:"claude-sonnet-4.5",haiku:"claude-haiku-4.5"},{name:"Claude Sonnet 4.5",description:"Pro+ (1x) - Balanced performance",default:"claude-sonnet-4.5",opus:"claude-opus-4.5",sonnet:"claude-sonnet-4.5",haiku:"claude-haiku-4.5"},{name:"GPT-5.2",description:"Pro+ (1x) - Latest OpenAI (Preview)",default:"gpt-5.2",opus:"gpt-5.2",sonnet:"gpt-5.1",haiku:"gpt-5-mini"},{name:"GPT-5.1 Codex Max",description:"Pro+ (1x) - Best for coding",default:"gpt-5.1-codex-max",opus:"gpt-5.1-codex-max",sonnet:"gpt-5.1-codex",haiku:"gpt-5.1-codex-mini"},{name:"Gemini 2.5 Pro",description:"Pro+ (1x) - Google latest",default:"gemini-2.5-pro",opus:"gemini-2.5-pro",sonnet:"gemini-2.5-pro",haiku:"gemini-3-flash"}];function oe(t){switch(t){case"free":return"bg-green-100 text-green-700 border-green-200";case"pro":return"bg-blue-100 text-blue-700 border-blue-200";case"pro+":return"bg-purple-100 text-purple-700 border-purple-200";case"business":return"bg-orange-100 text-orange-700 border-orange-200";case"enterprise":return"bg-red-100 text-red-700 border-red-200";default:return"bg-muted text-muted-foreground"}}function at(t){return t==null?null:t===0?"Free":t<1?`${t}x`:t===1?"1x":`${t}x`}function I({label:t,description:s,value:o,onChange:d,models:a,disabled:c}){const{t:l}=X(),u=a.find(i=>i.id===o);return e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-medium",children:t}),s&&e.jsx("p",{className:"text-[10px] text-muted-foreground",children:s})]}),e.jsxs(ce,{value:o||"",onValueChange:d,disabled:c,children:[e.jsx(re,{className:"h-9",children:e.jsx(de,{placeholder:l("componentModelSelector.selectModel"),children:o&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"truncate font-mono text-xs",children:o}),u?.minPlan&&e.jsx(b,{variant:"outline",className:`text-[9px] px-1 py-0 h-4 ${oe(u.minPlan)}`,children:u.minPlan})]})})}),e.jsx(ue,{className:"max-h-[300px]",children:e.jsxs(be,{children:[e.jsx(Se,{className:"text-xs text-muted-foreground",children:l("componentModelSelector.availableModelsCount",{count:a.length})}),a.map(i=>e.jsx(J,{value:i.id,children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"truncate font-mono text-xs",children:i.name||i.id}),i.minPlan&&e.jsx(b,{variant:"outline",className:`text-[9px] px-1 py-0 h-4 ${oe(i.minPlan)}`,children:i.minPlan}),i.multiplier!==void 0&&e.jsx("span",{className:"text-[9px] text-muted-foreground",children:at(i.multiplier)}),i.preview&&e.jsx(b,{variant:"secondary",className:"text-[9px] px-1 py-0 h-4",children:l("componentModelSelector.preview")}),o===i.id&&e.jsx(Re,{className:"w-3 h-3 text-primary ml-auto"})]})},i.id))]})})]})]})}function nt({currentModel:t,opusModel:s,sonnetModel:o,haikuModel:d,models:a,modelsLoading:c,onApplyPreset:l,onUpdateModel:u,onUpdateOpusModel:i,onUpdateSonnetModel:h,onUpdateHaikuModel:g}){return e.jsx(W,{value:"config",className:"flex-1 mt-0 border-0 p-0 data-[state=inactive]:hidden flex flex-col overflow-hidden",children:e.jsx(K,{className:"flex-1",children:e.jsxs("div",{className:"p-4 space-y-6",children:[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:"mb-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(b,{variant:"outline",className:"text-[10px] bg-green-100 text-green-700 border-green-200",children:"Free Tier"}),e.jsx("span",{className:"text-[10px] text-muted-foreground",children:"No premium usage count"})]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:tt.map(n=>e.jsxs(v,{variant:"outline",size:"sm",className:"text-xs h-7 gap-1",onClick:()=>l(n),title:n.description,children:[e.jsx(ne,{className:"w-3 h-3 text-green-600"}),n.name]},n.name))})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(b,{variant:"outline",className:"text-[10px] bg-blue-100 text-blue-700 border-blue-200",children:"Pro+ Required"}),e.jsx("span",{className:"text-[10px] text-muted-foreground",children:"Uses premium request quota"})]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:st.map(n=>e.jsxs(v,{variant:"outline",size:"sm",className:"text-xs h-7 gap-1",onClick:()=>l(n),title:n.description,children:[e.jsx(ne,{className:"w-3 h-3"}),n.name]},n.name))})]})]}),e.jsx(Z,{}),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(I,{label:"Default Model",description:"Used when no specific tier is requested",value:t,onChange:u,models:a,disabled:c}),e.jsx(I,{label:"Opus (Most capable)",description:"For complex reasoning tasks",value:s||t,onChange:i,models:a,disabled:c}),e.jsx(I,{label:"Sonnet (Balanced)",description:"Balance of speed and capability",value:o||t,onChange:h,models:a,disabled:c}),e.jsx(I,{label:"Haiku (Fast)",description:"Quick responses for simple tasks",value:d||t,onChange:g,models:a,disabled:c})]})]})]})})})}function it({enabled:t,autoStart:s,port:o,accountType:d,rateLimit:a,waitOnLimit:c,onUpdateEnabled:l,onUpdateAutoStart:u,onUpdatePort:i,onUpdateAccountType:h,onUpdateRateLimit:g,onUpdateWaitOnLimit:n}){const{t:m}=X();return e.jsx(W,{value:"settings",className:"flex-1 mt-0 border-0 p-0 data-[state=inactive]:hidden flex flex-col overflow-hidden",children:e.jsx(K,{className:"flex-1",children:e.jsxs("div",{className:"p-4 space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between rounded-lg border p-4",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(S,{htmlFor:"enabled",className:"text-sm font-medium",children:m("copilotSettings.enableCopilot")}),e.jsx("p",{className:"text-xs text-muted-foreground",children:m("copilotSettings.enableCopilotDesc")})]}),e.jsx($,{id:"enabled",checked:t,onCheckedChange:l})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("h3",{className:"text-sm font-medium",children:m("copilotSettings.basicSettings")}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(S,{htmlFor:"port",className:"text-xs",children:m("copilotPage.port")}),e.jsx(ae,{id:"port",type:"number",value:o,onChange:p=>i(parseInt(p.target.value,10)),min:1024,max:65535,className:"max-w-[150px] h-8"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(S,{htmlFor:"account-type",className:"text-xs",children:m("copilotSettings.accountType")}),e.jsxs(ce,{value:d,onValueChange:h,children:[e.jsx(re,{id:"account-type",className:"max-w-[150px] h-8",children:e.jsx(de,{})}),e.jsxs(ue,{children:[e.jsx(J,{value:"individual",children:m("copilotSettings.accountTypeIndividual")}),e.jsx(J,{value:"business",children:m("copilotSettings.accountTypeBusiness")}),e.jsx(J,{value:"enterprise",children:m("copilotSettings.accountTypeEnterprise")})]})]})]})]}),e.jsx(Z,{}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("h3",{className:"text-sm font-medium",children:m("copilotSettings.rateLimiting")}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(S,{htmlFor:"rate-limit",className:"text-xs",children:m("copilotSettings.rateLimitSeconds")}),e.jsx(ae,{id:"rate-limit",type:"number",value:a,onChange:p=>g(p.target.value),placeholder:m("copilotSettings.noLimit"),min:0,className:"max-w-[150px] h-8"})]}),e.jsxs("div",{className:"flex items-center justify-between rounded-lg border p-3",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(S,{htmlFor:"wait-on-limit",className:"text-xs",children:m("copilotSettings.waitOnRateLimit")}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:m("copilotSettings.waitOnRateLimitDesc")})]}),e.jsx($,{id:"wait-on-limit",checked:c,onCheckedChange:n})]})]}),e.jsx(Z,{}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("h3",{className:"text-sm font-medium",children:m("copilotSettings.daemonSettings")}),e.jsxs("div",{className:"flex items-center justify-between rounded-lg border p-3",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(S,{htmlFor:"auto-start",className:"text-xs",children:m("copilotSettings.autoStartDaemon")}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:m("copilotSettings.autoStartDaemonDesc")})]}),e.jsx($,{id:"auto-start",checked:s,onCheckedChange:u})]})]})]})})})}function U({label:t,command:s}){return e.jsxs("div",{children:[e.jsx("label",{className:"text-xs text-muted-foreground",children:t}),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:s}),e.jsx(me,{value:s,size:"icon",className:"h-6 w-6"})]})]})}function ot({rawSettings:t}){return e.jsx(W,{value:"info",className:"h-full mt-0 border-0 p-0 data-[state=inactive]:hidden",children:e.jsx(K,{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(Ee,{className:"w-4 h-4"}),"Configuration Info"]}),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:"GitHub Copilot"})]}),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(me,{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:"Status"}),e.jsx(b,{variant:"outline",className:t.exists?"w-fit text-green-600 border-green-200 bg-green-50":"w-fit text-muted-foreground",children:t.exists?"File exists":"Using defaults"})]})]})]})]}),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(U,{label:"Run with Copilot",command:"ccs copilot"}),e.jsx(U,{label:"Authenticate",command:"ccs copilot auth"}),e.jsx(U,{label:"Start daemon",command:"ccs copilot --start"}),e.jsx(U,{label:"Stop daemon",command:"ccs copilot --stop"})]})]})]})})})}const lt=["ANTHROPIC_BASE_URL","ANTHROPIC_AUTH_TOKEN"];function le(t){const s=t?.env||{};return lt.filter(o=>!s[o]?.trim())}function ct(){const{config:t,configLoading:s,models:o,modelsLoading:d,rawSettings:a,rawSettingsLoading:c,updateConfigAsync:l,isUpdating:u,saveRawSettingsAsync:i,isSavingRawSettings:h,refetchRawSettings:g}=fe(),[n,m]=N.useState({}),[p,P]=N.useState(null),[B,L]=N.useState(!1),R=n.enabled??t?.enabled??!1,A=n.autoStart??t?.auto_start??!1,k=n.port??t?.port??4141,E=n.accountType??t?.account_type??"individual",O=n.model??t?.model??"claude-sonnet-4-5-20250929",f=n.rateLimit??t?.rate_limit?.toString()??"",_=n.waitOnLimit??t?.wait_on_limit??!0,q=n.opusModel??t?.opus_model??"",D=n.sonnetModel??t?.sonnet_model??"",F=n.haikuModel??t?.haiku_model??"",z=(x,w)=>{m(we=>({...we,[x]:w}))},G=x=>{m(w=>({...w,model:x.default,opusModel:x.opus,sonnetModel:x.sonnet,haikuModel:x.haiku})),T.success(`Applied "${x.name}" preset`)},r=N.useMemo(()=>p!==null?p:a?.settings?JSON.stringify(a.settings,null,2):`{
1
+ import{j as e}from"./radix-ui-BR1vy4kf.js";import{aY as j,aZ as ye,B as b,d as v,a as X,r as ce,s as re,t as de,v as ue,ao as be,ap as Se,w as J,V as W,n as K,L as S,I as ae,x as me,a_ as Ce,S as y,Q as Pe,R as ke,U as V,a$ as Fe,c as Y}from"./index-DCQkhmoo.js";import{r as N}from"./react-vendor-CNOkPC89.js";import{a as Me,u as M,b as C}from"./tanstack-e99Cjjy2.js";import{C as Te}from"./confirm-dialog-BZj0PYFs.js";import{R as xe,L as pe,ai as Le,k as Re,a2 as Ae,Z as ne,J as Ee,al as Oe,b as _e,T as qe,a5 as De,ar as Ie,ay as ie,K as Ue,I as Qe,az as Je,u as he,v as ge}from"./icons-BYZM_9Gm.js";import{S as Z}from"./separator-DtcqgZIS.js";import{S as $}from"./switch-BL5xZtnr.js";import{t as T}from"./notifications-B2HqRBj7.js";import"./utils-CzKF5WmX.js";import"./form-utils-Cn_Uld6y.js";import"./code-highlight-BRUf_pqB.js";import"./alert-dialog-DPdKlUG9.js";async function Ke(){const t=await fetch(j("/copilot/status"));if(!t.ok)throw new Error("Failed to fetch copilot status");return t.json()}async function ze(){const t=await fetch(j("/copilot/config"));if(!t.ok)throw new Error("Failed to fetch copilot config");return t.json()}async function Be(){const t=await fetch(j("/copilot/models"));if(!t.ok)throw new Error("Failed to fetch copilot models");return t.json()}async function Ge(){const t=await fetch(j("/copilot/settings/raw"));if(!t.ok)throw new Error("Failed to fetch copilot raw settings");return t.json()}async function Ve(t){const s=await fetch(j("/copilot/config"),{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!s.ok)throw new Error("Failed to update copilot config");return s.json()}async function $e(t){const s=await fetch(j("/copilot/settings/raw"),{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(s.status===409)throw new ye("Copilot raw settings changed externally");if(!s.ok)throw new Error("Failed to save copilot raw settings");return s.json()}async function He(){const t=await fetch(j("/copilot/auth/start"),{method:"POST"});if(!t.ok)throw new Error("Failed to start auth");return t.json()}async function Ye(){const t=await fetch(j("/copilot/daemon/start"),{method:"POST"});if(!t.ok)throw new Error("Failed to start daemon");return t.json()}async function Ze(){const t=await fetch(j("/copilot/daemon/stop"),{method:"POST"});if(!t.ok)throw new Error("Failed to stop daemon");return t.json()}async function Xe(){const t=await fetch(j("/copilot/info"));if(!t.ok)throw new Error("Failed to fetch copilot info");return t.json()}async function We(t){const s=await fetch(j("/copilot/install"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t?{version:t}:{})});if(!s.ok)throw new Error("Failed to install copilot-api");return s.json()}function fe(){const t=Me(),s=M({queryKey:["copilot-status"],queryFn:Ke,refetchInterval:5e3}),o=M({queryKey:["copilot-config"],queryFn:ze}),d=M({queryKey:["copilot-models"],queryFn:Be}),a=M({queryKey:["copilot-raw-settings"],queryFn:Ge}),c=M({queryKey:["copilot-info"],queryFn:Xe}),l=C({mutationFn:Ve,onSuccess:()=>{t.invalidateQueries({queryKey:["copilot-status"]}),t.invalidateQueries({queryKey:["copilot-config"]}),t.invalidateQueries({queryKey:["copilot-raw-settings"]})}}),u=C({mutationFn:$e,onSuccess:()=>{t.invalidateQueries({queryKey:["copilot-status"]}),t.invalidateQueries({queryKey:["copilot-config"]}),t.invalidateQueries({queryKey:["copilot-raw-settings"]})}}),i=C({mutationFn:He,onSuccess:()=>{t.invalidateQueries({queryKey:["copilot-status"]})}}),h=C({mutationFn:Ye,onSuccess:()=>{t.invalidateQueries({queryKey:["copilot-status"]})}}),g=C({mutationFn:Ze,onSuccess:()=>{t.invalidateQueries({queryKey:["copilot-status"]})}}),n=C({mutationFn:We,onSuccess:()=>{t.invalidateQueries({queryKey:["copilot-status"]}),t.invalidateQueries({queryKey:["copilot-info"]})}});return N.useMemo(()=>({status:s.data,statusLoading:s.isLoading,statusError:s.error,refetchStatus:s.refetch,config:o.data,configLoading:o.isLoading,models:d.data?.models??[],currentModel:d.data?.current,modelsLoading:d.isLoading,rawSettings:a.data,rawSettingsLoading:a.isLoading,refetchRawSettings:a.refetch,updateConfig:l.mutate,updateConfigAsync:l.mutateAsync,isUpdating:l.isPending,saveRawSettings:u.mutate,saveRawSettingsAsync:u.mutateAsync,isSavingRawSettings:u.isPending,startAuth:i.mutate,startAuthAsync:i.mutateAsync,isAuthenticating:i.isPending,authResult:i.data,startDaemon:h.mutate,isStartingDaemon:h.isPending,stopDaemon:g.mutate,isStoppingDaemon:g.isPending,info:c.data,infoLoading:c.isLoading,refetchInfo:c.refetch,install:n.mutate,installAsync:n.mutateAsync,isInstalling:n.isPending}),[s.data,s.isLoading,s.error,s.refetch,o.data,o.isLoading,d.data,d.isLoading,a.data,a.isLoading,a.refetch,l.mutate,l.mutateAsync,l.isPending,u.mutate,u.mutateAsync,u.isPending,i.mutate,i.mutateAsync,i.isPending,i.data,h.mutate,h.isPending,g.mutate,g.isPending,c.data,c.isLoading,c.refetch,n.mutate,n.mutateAsync,n.isPending])}function et({rawSettings:t,rawSettingsLoading:s,isUpdating:o,isSavingRawSettings:d,hasChanges:a,isRawJsonValid:c,onRefresh:l,onSave:u}){return e.jsxs("div",{className:"px-6 py-4 border-b bg-background flex items-center justify-between shrink-0",children:[e.jsx("div",{className:"flex items-center gap-3",children:e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h2",{className:"text-lg font-semibold",children:"Copilot Configuration"}),t&&e.jsx(b,{variant:"outline",className:"text-xs",children:"copilot.settings.json"})]}),t&&e.jsxs("p",{className:"text-xs text-muted-foreground mt-0.5",children:["Last modified:"," ",t.exists?new Date(t.mtime).toLocaleString():"Never saved"]})]})}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(v,{variant:"ghost",size:"sm",onClick:l,disabled:s,children:e.jsx(xe,{className:`w-4 h-4 ${s?"animate-spin":""}`})}),e.jsx(v,{size:"sm",onClick:u,disabled:o||d||!a||!c,children:o||d?e.jsxs(e.Fragment,{children:[e.jsx(pe,{className:"w-4 h-4 mr-1 animate-spin"}),"Saving..."]}):e.jsxs(e.Fragment,{children:[e.jsx(Le,{className:"w-4 h-4 mr-1"}),"Save"]})})]})]})}const tt=[{name:"GPT-4.1 (Free)",description:"Free tier - no premium usage",default:"gpt-4.1",opus:"gpt-4.1",sonnet:"gpt-4.1",haiku:"gpt-4.1"},{name:"GPT-5 Mini (Free)",description:"Free tier - lightweight model",default:"gpt-5-mini",opus:"gpt-5-mini",sonnet:"gpt-5-mini",haiku:"gpt-5-mini"},{name:"Raptor Mini (Free)",description:"Free tier - fine-tuned for coding",default:"raptor-mini",opus:"raptor-mini",sonnet:"raptor-mini",haiku:"raptor-mini"}],st=[{name:"Claude Opus 4.5",description:"Pro+ (3x) - Most capable reasoning",default:"claude-opus-4.5",opus:"claude-opus-4.5",sonnet:"claude-sonnet-4.5",haiku:"claude-haiku-4.5"},{name:"Claude Sonnet 4.5",description:"Pro+ (1x) - Balanced performance",default:"claude-sonnet-4.5",opus:"claude-opus-4.5",sonnet:"claude-sonnet-4.5",haiku:"claude-haiku-4.5"},{name:"GPT-5.2",description:"Pro+ (1x) - Latest OpenAI (Preview)",default:"gpt-5.2",opus:"gpt-5.2",sonnet:"gpt-5.1",haiku:"gpt-5-mini"},{name:"GPT-5.1 Codex Max",description:"Pro+ (1x) - Best for coding",default:"gpt-5.1-codex-max",opus:"gpt-5.1-codex-max",sonnet:"gpt-5.1-codex",haiku:"gpt-5.1-codex-mini"},{name:"Gemini 2.5 Pro",description:"Pro+ (1x) - Google latest",default:"gemini-2.5-pro",opus:"gemini-2.5-pro",sonnet:"gemini-2.5-pro",haiku:"gemini-3-flash"}];function oe(t){switch(t){case"free":return"bg-green-100 text-green-700 border-green-200";case"pro":return"bg-blue-100 text-blue-700 border-blue-200";case"pro+":return"bg-purple-100 text-purple-700 border-purple-200";case"business":return"bg-orange-100 text-orange-700 border-orange-200";case"enterprise":return"bg-red-100 text-red-700 border-red-200";default:return"bg-muted text-muted-foreground"}}function at(t){return t==null?null:t===0?"Free":t<1?`${t}x`:t===1?"1x":`${t}x`}function I({label:t,description:s,value:o,onChange:d,models:a,disabled:c}){const{t:l}=X(),u=a.find(i=>i.id===o);return e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-medium",children:t}),s&&e.jsx("p",{className:"text-[10px] text-muted-foreground",children:s})]}),e.jsxs(ce,{value:o||"",onValueChange:d,disabled:c,children:[e.jsx(re,{className:"h-9",children:e.jsx(de,{placeholder:l("componentModelSelector.selectModel"),children:o&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"truncate font-mono text-xs",children:o}),u?.minPlan&&e.jsx(b,{variant:"outline",className:`text-[9px] px-1 py-0 h-4 ${oe(u.minPlan)}`,children:u.minPlan})]})})}),e.jsx(ue,{className:"max-h-[300px]",children:e.jsxs(be,{children:[e.jsx(Se,{className:"text-xs text-muted-foreground",children:l("componentModelSelector.availableModelsCount",{count:a.length})}),a.map(i=>e.jsx(J,{value:i.id,children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"truncate font-mono text-xs",children:i.name||i.id}),i.minPlan&&e.jsx(b,{variant:"outline",className:`text-[9px] px-1 py-0 h-4 ${oe(i.minPlan)}`,children:i.minPlan}),i.multiplier!==void 0&&e.jsx("span",{className:"text-[9px] text-muted-foreground",children:at(i.multiplier)}),i.preview&&e.jsx(b,{variant:"secondary",className:"text-[9px] px-1 py-0 h-4",children:l("componentModelSelector.preview")}),o===i.id&&e.jsx(Re,{className:"w-3 h-3 text-primary ml-auto"})]})},i.id))]})})]})]})}function nt({currentModel:t,opusModel:s,sonnetModel:o,haikuModel:d,models:a,modelsLoading:c,onApplyPreset:l,onUpdateModel:u,onUpdateOpusModel:i,onUpdateSonnetModel:h,onUpdateHaikuModel:g}){return e.jsx(W,{value:"config",className:"flex-1 mt-0 border-0 p-0 data-[state=inactive]:hidden flex flex-col overflow-hidden",children:e.jsx(K,{className:"flex-1",children:e.jsxs("div",{className:"p-4 space-y-6",children:[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:"mb-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(b,{variant:"outline",className:"text-[10px] bg-green-100 text-green-700 border-green-200",children:"Free Tier"}),e.jsx("span",{className:"text-[10px] text-muted-foreground",children:"No premium usage count"})]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:tt.map(n=>e.jsxs(v,{variant:"outline",size:"sm",className:"text-xs h-7 gap-1",onClick:()=>l(n),title:n.description,children:[e.jsx(ne,{className:"w-3 h-3 text-green-600"}),n.name]},n.name))})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(b,{variant:"outline",className:"text-[10px] bg-blue-100 text-blue-700 border-blue-200",children:"Pro+ Required"}),e.jsx("span",{className:"text-[10px] text-muted-foreground",children:"Uses premium request quota"})]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:st.map(n=>e.jsxs(v,{variant:"outline",size:"sm",className:"text-xs h-7 gap-1",onClick:()=>l(n),title:n.description,children:[e.jsx(ne,{className:"w-3 h-3"}),n.name]},n.name))})]})]}),e.jsx(Z,{}),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(I,{label:"Default Model",description:"Used when no specific tier is requested",value:t,onChange:u,models:a,disabled:c}),e.jsx(I,{label:"Opus (Most capable)",description:"For complex reasoning tasks",value:s||t,onChange:i,models:a,disabled:c}),e.jsx(I,{label:"Sonnet (Balanced)",description:"Balance of speed and capability",value:o||t,onChange:h,models:a,disabled:c}),e.jsx(I,{label:"Haiku (Fast)",description:"Quick responses for simple tasks",value:d||t,onChange:g,models:a,disabled:c})]})]})]})})})}function it({enabled:t,autoStart:s,port:o,accountType:d,rateLimit:a,waitOnLimit:c,onUpdateEnabled:l,onUpdateAutoStart:u,onUpdatePort:i,onUpdateAccountType:h,onUpdateRateLimit:g,onUpdateWaitOnLimit:n}){const{t:m}=X();return e.jsx(W,{value:"settings",className:"flex-1 mt-0 border-0 p-0 data-[state=inactive]:hidden flex flex-col overflow-hidden",children:e.jsx(K,{className:"flex-1",children:e.jsxs("div",{className:"p-4 space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between rounded-lg border p-4",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(S,{htmlFor:"enabled",className:"text-sm font-medium",children:m("copilotSettings.enableCopilot")}),e.jsx("p",{className:"text-xs text-muted-foreground",children:m("copilotSettings.enableCopilotDesc")})]}),e.jsx($,{id:"enabled",checked:t,onCheckedChange:l})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("h3",{className:"text-sm font-medium",children:m("copilotSettings.basicSettings")}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(S,{htmlFor:"port",className:"text-xs",children:m("copilotPage.port")}),e.jsx(ae,{id:"port",type:"number",value:o,onChange:p=>i(parseInt(p.target.value,10)),min:1024,max:65535,className:"max-w-[150px] h-8"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(S,{htmlFor:"account-type",className:"text-xs",children:m("copilotSettings.accountType")}),e.jsxs(ce,{value:d,onValueChange:h,children:[e.jsx(re,{id:"account-type",className:"max-w-[150px] h-8",children:e.jsx(de,{})}),e.jsxs(ue,{children:[e.jsx(J,{value:"individual",children:m("copilotSettings.accountTypeIndividual")}),e.jsx(J,{value:"business",children:m("copilotSettings.accountTypeBusiness")}),e.jsx(J,{value:"enterprise",children:m("copilotSettings.accountTypeEnterprise")})]})]})]})]}),e.jsx(Z,{}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("h3",{className:"text-sm font-medium",children:m("copilotSettings.rateLimiting")}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(S,{htmlFor:"rate-limit",className:"text-xs",children:m("copilotSettings.rateLimitSeconds")}),e.jsx(ae,{id:"rate-limit",type:"number",value:a,onChange:p=>g(p.target.value),placeholder:m("copilotSettings.noLimit"),min:0,className:"max-w-[150px] h-8"})]}),e.jsxs("div",{className:"flex items-center justify-between rounded-lg border p-3",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(S,{htmlFor:"wait-on-limit",className:"text-xs",children:m("copilotSettings.waitOnRateLimit")}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:m("copilotSettings.waitOnRateLimitDesc")})]}),e.jsx($,{id:"wait-on-limit",checked:c,onCheckedChange:n})]})]}),e.jsx(Z,{}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("h3",{className:"text-sm font-medium",children:m("copilotSettings.daemonSettings")}),e.jsxs("div",{className:"flex items-center justify-between rounded-lg border p-3",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(S,{htmlFor:"auto-start",className:"text-xs",children:m("copilotSettings.autoStartDaemon")}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:m("copilotSettings.autoStartDaemonDesc")})]}),e.jsx($,{id:"auto-start",checked:s,onCheckedChange:u})]})]})]})})})}function U({label:t,command:s}){return e.jsxs("div",{children:[e.jsx("label",{className:"text-xs text-muted-foreground",children:t}),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:s}),e.jsx(me,{value:s,size:"icon",className:"h-6 w-6"})]})]})}function ot({rawSettings:t}){return e.jsx(W,{value:"info",className:"h-full mt-0 border-0 p-0 data-[state=inactive]:hidden",children:e.jsx(K,{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(Ee,{className:"w-4 h-4"}),"Configuration Info"]}),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:"GitHub Copilot"})]}),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(me,{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:"Status"}),e.jsx(b,{variant:"outline",className:t.exists?"w-fit text-green-600 border-green-200 bg-green-50":"w-fit text-muted-foreground",children:t.exists?"File exists":"Using defaults"})]})]})]})]}),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(U,{label:"Run with Copilot",command:"ccs copilot"}),e.jsx(U,{label:"Authenticate",command:"ccs copilot auth"}),e.jsx(U,{label:"Start daemon",command:"ccs copilot --start"}),e.jsx(U,{label:"Stop daemon",command:"ccs copilot --stop"})]})]})]})})})}const lt=["ANTHROPIC_BASE_URL","ANTHROPIC_AUTH_TOKEN"];function le(t){const s=t?.env||{};return lt.filter(o=>!s[o]?.trim())}function ct(){const{config:t,configLoading:s,models:o,modelsLoading:d,rawSettings:a,rawSettingsLoading:c,updateConfigAsync:l,isUpdating:u,saveRawSettingsAsync:i,isSavingRawSettings:h,refetchRawSettings:g}=fe(),[n,m]=N.useState({}),[p,P]=N.useState(null),[z,L]=N.useState(!1),R=n.enabled??t?.enabled??!1,A=n.autoStart??t?.auto_start??!1,k=n.port??t?.port??4141,E=n.accountType??t?.account_type??"individual",O=n.model??t?.model??"claude-sonnet-4-5-20250929",f=n.rateLimit??t?.rate_limit?.toString()??"",_=n.waitOnLimit??t?.wait_on_limit??!0,q=n.opusModel??t?.opus_model??"",D=n.sonnetModel??t?.sonnet_model??"",F=n.haikuModel??t?.haiku_model??"",B=(x,w)=>{m(we=>({...we,[x]:w}))},G=x=>{m(w=>({...w,model:x.default,opusModel:x.opus,sonnetModel:x.sonnet,haikuModel:x.haiku})),T.success(`Applied "${x.name}" preset`)},r=N.useMemo(()=>p!==null?p:a?.settings?JSON.stringify(a.settings,null,2):`{
2
2
  "env": {}
3
- }`,[p,a]),je=N.useCallback(x=>{P(x)},[]),ee=N.useMemo(()=>{try{return JSON.parse(r),!0}catch{return!1}},[r]),Ne=N.useMemo(()=>{const x=Object.keys(n).length>0,w=p!==null&&p!==JSON.stringify(a?.settings,null,2);return x||w},[n,p,a]),te=N.useMemo(()=>{if(p!==null)try{return JSON.parse(p)}catch{return a?.settings}return a?.settings},[p,a?.settings]),ve=N.useMemo(()=>le(te),[te]),se=async()=>{try{if(Object.keys(n).length>0&&await l({enabled:R,auto_start:A,port:k,account_type:E,model:O,rate_limit:f?parseInt(f,10):null,wait_on_limit:_,opus_model:q||void 0,sonnet_model:D||void 0,haiku_model:F||void 0}),p!==null&&ee){const x=JSON.parse(r),w=le(x);await i({settings:x,expectedMtime:a?.mtime}),w.length>0?T.success("Copilot configuration saved",{description:`Missing fields will use defaults: ${w.join(", ")}`}):T.success("Copilot configuration saved")}else T.success("Copilot configuration saved");m({}),P(null)}catch(x){Ce(x)?L(!0):T.error("Failed to save settings")}};return{configLoading:s,rawSettingsLoading:c,modelsLoading:d,isUpdating:u,isSavingRawSettings:h,models:o,rawSettings:a,rawJsonContent:r,rawJsonEdits:p,enabled:R,autoStart:A,port:k,accountType:E,currentModel:O,rateLimit:f,waitOnLimit:_,opusModel:q,sonnetModel:D,haikuModel:F,isRawJsonValid:ee,hasChanges:Ne,conflictDialog:B,updateField:z,applyPreset:G,handleRawJsonChange:je,handleSave:se,handleConflictResolve:async x=>{L(!1),x?(await g(),se()):P(null)},refetchRawSettings:g,missingRequiredFields:ve}}function rt(){const{configLoading:t,rawSettingsLoading:s,modelsLoading:o,isUpdating:d,isSavingRawSettings:a,models:c,rawSettings:l,rawJsonContent:u,rawJsonEdits:i,enabled:h,autoStart:g,port:n,accountType:m,currentModel:p,rateLimit:P,waitOnLimit:B,opusModel:L,sonnetModel:R,haikuModel:A,isRawJsonValid:k,hasChanges:E,conflictDialog:O,updateField:f,applyPreset:_,handleRawJsonChange:q,handleSave:D,handleConflictResolve:F,refetchRawSettings:z,missingRequiredFields:G}=ct();return t||s?e.jsxs("div",{className:"space-y-6",children:[e.jsx(y,{className:"h-10 w-full"}),e.jsx(y,{className:"h-10 w-full"}),e.jsx(y,{className:"h-10 w-full"}),e.jsx(y,{className:"h-10 w-full"})]}):e.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden",children:[e.jsx(et,{rawSettings:l,rawSettingsLoading:s,isUpdating:d,isSavingRawSettings:a,hasChanges:E,isRawJsonValid:k,onRefresh:()=>z(),onSave:D}),e.jsxs("div",{className:"flex-1 flex divide-x overflow-hidden",children:[e.jsx("div",{className:"w-[540px] shrink-0 flex flex-col overflow-hidden bg-muted/5",children:e.jsx("div",{className:"h-full flex flex-col",children:e.jsxs(Pe,{defaultValue:"config",className:"h-full flex flex-col",children:[e.jsx("div",{className:"px-4 pt-4 shrink-0",children:e.jsxs(ke,{className:"w-full",children:[e.jsx(V,{value:"config",className:"flex-1",children:"Model Config"}),e.jsx(V,{value:"settings",className:"flex-1",children:"Settings"}),e.jsx(V,{value:"info",className:"flex-1",children:"Info"})]})}),e.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col",children:[e.jsx(nt,{currentModel:p,opusModel:L,sonnetModel:R,haikuModel:A,models:c,modelsLoading:o,onApplyPreset:_,onUpdateModel:r=>f("model",r),onUpdateOpusModel:r=>f("opusModel",r),onUpdateSonnetModel:r=>f("sonnetModel",r),onUpdateHaikuModel:r=>f("haikuModel",r)}),e.jsx(it,{enabled:h,autoStart:g,port:n,accountType:m,rateLimit:P,waitOnLimit:B,onUpdateEnabled:r=>f("enabled",r),onUpdateAutoStart:r=>f("autoStart",r),onUpdatePort:r=>f("port",r),onUpdateAccountType:r=>f("accountType",r),onUpdateRateLimit:r=>f("rateLimit",r),onUpdateWaitOnLimit:r=>f("waitOnLimit",r)}),e.jsx(ot,{rawSettings:l})]})]})})}),e.jsxs("div",{className:"flex-1 min-w-0 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(Oe,{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(Fe,{rawJsonContent:u,isRawJsonValid:k,rawJsonEdits:i,rawSettingsEnv:l?.settings?.env,onChange:q,missingRequiredFields:G})]})]}),e.jsx(Te,{open:O,title:"File Modified Externally",description:"This settings file was modified by another process. Overwrite with your changes or discard?",confirmText:"Overwrite",variant:"destructive",onConfirm:()=>F(!0),onCancel:()=>F(!1)})]})}function H({title:t,children:s}){return e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide px-3",children:t}),e.jsx("div",{className:"space-y-1",children:s})]})}function Q({icon:t,label:s,status:o,statusText:d,variant:a="default"}){return e.jsxs("div",{className:"flex items-center gap-3 px-3 py-2 rounded-lg bg-muted/50",children:[e.jsx(t,{className:"w-4 h-4 text-muted-foreground shrink-0"}),e.jsx("div",{className:"flex-1 min-w-0",children:e.jsx("span",{className:"text-sm",children:s})}),e.jsx("div",{className:"flex items-center gap-1.5",children:o?e.jsxs(e.Fragment,{children:[e.jsx(he,{className:Y("w-4 h-4",a==="warning"?"text-yellow-500":"text-green-500")}),e.jsx("span",{className:Y("text-xs",a==="warning"?"text-yellow-500":"text-green-500"),children:d||"Yes"})]}):e.jsxs(e.Fragment,{children:[e.jsx(ge,{className:"w-4 h-4 text-muted-foreground"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:d||"No"})]})})]})}function dt(){return e.jsxs("div",{className:"space-y-4 p-4",children:[e.jsx(y,{className:"h-8 w-full"}),e.jsx(y,{className:"h-12 w-full"}),e.jsx(y,{className:"h-12 w-full"}),e.jsx(y,{className:"h-12 w-full"})]})}function Ct(){const{t}=X(),{status:s,statusLoading:o,refetchStatus:d,startAuth:a,isAuthenticating:c,startDaemon:l,isStartingDaemon:u,stopDaemon:i,isStoppingDaemon:h,install:g,isInstalling:n}=fe();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 shrink-0",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(_e,{className:"w-5 h-5 text-primary"}),e.jsx("h1",{className:"font-semibold",children:t("copilotPage.title")})]}),e.jsx(v,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>d(),disabled:o,children:e.jsx(xe,{className:Y("w-4 h-4",o&&"animate-spin")})})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:t("copilotPage.subtitle")})]}),e.jsx(K,{className:"flex-1",children:o?e.jsx(dt,{}):e.jsxs("div",{className:"p-3 space-y-4",children:[e.jsxs("div",{className:"rounded-md border border-yellow-500/50 bg-yellow-500/15 p-3 space-y-1.5",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(qe,{className:"h-4 w-4 text-yellow-600 dark:text-yellow-400 shrink-0"}),e.jsx("span",{className:"text-xs font-semibold text-yellow-800 dark:text-yellow-200",children:t("copilotPage.unofficialTitle")})]}),e.jsxs("ul",{className:"text-[11px] text-yellow-700 dark:text-yellow-300 space-y-0.5 pl-6 list-disc",children:[e.jsx("li",{children:t("copilotPage.unofficialItem1")}),e.jsx("li",{children:t("copilotPage.unofficialItem2")}),e.jsx("li",{children:t("copilotPage.unofficialItem3")})]})]}),e.jsxs(H,{title:t("copilotPage.setup"),children:[e.jsx(Q,{icon:De,label:"copilot-api",status:s?.installed??!1,statusText:s?.installed?s.version?`v${s.version}`:t("copilotPage.installed"):t("copilotPage.missing")}),!s?.installed&&e.jsx(v,{size:"sm",className:"w-full mt-2",onClick:()=>g(void 0),disabled:n,children:n?e.jsxs(e.Fragment,{children:[e.jsx(pe,{className:"w-3.5 h-3.5 mr-1.5 animate-spin"}),t("copilotPage.installing")]}):e.jsxs(e.Fragment,{children:[e.jsx(Ie,{className:"w-3.5 h-3.5 mr-1.5"}),t("copilotPage.installCopilotApi")]})}),s?.installed&&e.jsx(Q,{icon:ie,label:t("copilotPage.integration"),status:s?.enabled??!1,statusText:s?.enabled?t("copilotPage.enabled"):t("copilotPage.disabled")})]}),s?.installed&&e.jsxs(H,{title:t("copilotPage.auth"),children:[e.jsx(Q,{icon:Ue,label:t("copilotPage.github"),status:s?.authenticated??!1,statusText:s?.authenticated?t("copilotPage.connected"):t("copilotPage.notConnected")}),!s?.authenticated&&e.jsx(v,{size:"sm",className:"w-full mt-2",onClick:()=>a(),disabled:c,children:t(c?"copilotPage.authenticating":"copilotPage.authenticate")})]}),s?.authenticated&&e.jsxs(H,{title:t("copilotPage.daemon"),children:[e.jsx(Q,{icon:Qe,label:t("copilotPage.status"),status:s?.daemon_running??!1,statusText:s?.daemon_running?t("copilotPage.running"):t("copilotPage.stopped")}),e.jsxs("div",{className:"px-3 py-1 text-xs text-muted-foreground",children:[t("copilotPage.port"),": ",s?.port??4141]}),e.jsx("div",{className:"px-1",children:s?.daemon_running?e.jsxs(v,{size:"sm",variant:"outline",className:"w-full",onClick:()=>i(),disabled:h,children:[e.jsx(Je,{className:"w-3.5 h-3.5 mr-1.5"}),t(h?"copilotPage.stopping":"copilotPage.stop")]}):e.jsxs(v,{size:"sm",variant:"outline",className:"w-full",onClick:()=>l(),disabled:u,children:[e.jsx(ie,{className:"w-3.5 h-3.5 mr-1.5"}),t(u?"copilotPage.starting":"copilotPage.start")]})})]})]})}),e.jsx("div",{className:"p-3 border-t bg-background text-xs text-muted-foreground",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{children:t("copilotPage.proxy")}),s?.daemon_running?e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(he,{className:"w-3 h-3 text-green-500"}),t("copilotPage.active")]}):e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(ge,{className:"w-3 h-3 text-muted-foreground"}),t("copilotPage.inactive")]})]})})]}),e.jsx("div",{className:"flex-1 flex flex-col min-w-0 bg-background overflow-hidden",children:e.jsx(rt,{})})]})}export{Ct as CopilotPage};
3
+ }`,[p,a]),je=N.useCallback(x=>{P(x)},[]),ee=N.useMemo(()=>{try{return JSON.parse(r),!0}catch{return!1}},[r]),Ne=N.useMemo(()=>{const x=Object.keys(n).length>0,w=p!==null&&p!==JSON.stringify(a?.settings,null,2);return x||w},[n,p,a]),te=N.useMemo(()=>{if(p!==null)try{return JSON.parse(p)}catch{return a?.settings}return a?.settings},[p,a?.settings]),ve=N.useMemo(()=>le(te),[te]),se=async()=>{try{if(Object.keys(n).length>0&&await l({enabled:R,auto_start:A,port:k,account_type:E,model:O,rate_limit:f?parseInt(f,10):null,wait_on_limit:_,opus_model:q||void 0,sonnet_model:D||void 0,haiku_model:F||void 0}),p!==null&&ee){const x=JSON.parse(r),w=le(x);await i({settings:x,expectedMtime:a?.mtime}),w.length>0?T.success("Copilot configuration saved",{description:`Missing fields will use defaults: ${w.join(", ")}`}):T.success("Copilot configuration saved")}else T.success("Copilot configuration saved");m({}),P(null)}catch(x){Ce(x)?L(!0):T.error("Failed to save settings")}};return{configLoading:s,rawSettingsLoading:c,modelsLoading:d,isUpdating:u,isSavingRawSettings:h,models:o,rawSettings:a,rawJsonContent:r,rawJsonEdits:p,enabled:R,autoStart:A,port:k,accountType:E,currentModel:O,rateLimit:f,waitOnLimit:_,opusModel:q,sonnetModel:D,haikuModel:F,isRawJsonValid:ee,hasChanges:Ne,conflictDialog:z,updateField:B,applyPreset:G,handleRawJsonChange:je,handleSave:se,handleConflictResolve:async x=>{L(!1),x?(await g(),se()):P(null)},refetchRawSettings:g,missingRequiredFields:ve}}function rt(){const{configLoading:t,rawSettingsLoading:s,modelsLoading:o,isUpdating:d,isSavingRawSettings:a,models:c,rawSettings:l,rawJsonContent:u,rawJsonEdits:i,enabled:h,autoStart:g,port:n,accountType:m,currentModel:p,rateLimit:P,waitOnLimit:z,opusModel:L,sonnetModel:R,haikuModel:A,isRawJsonValid:k,hasChanges:E,conflictDialog:O,updateField:f,applyPreset:_,handleRawJsonChange:q,handleSave:D,handleConflictResolve:F,refetchRawSettings:B,missingRequiredFields:G}=ct();return t||s?e.jsxs("div",{className:"space-y-6",children:[e.jsx(y,{className:"h-10 w-full"}),e.jsx(y,{className:"h-10 w-full"}),e.jsx(y,{className:"h-10 w-full"}),e.jsx(y,{className:"h-10 w-full"})]}):e.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden",children:[e.jsx(et,{rawSettings:l,rawSettingsLoading:s,isUpdating:d,isSavingRawSettings:a,hasChanges:E,isRawJsonValid:k,onRefresh:()=>B(),onSave:D}),e.jsxs("div",{className:"flex-1 flex divide-x overflow-hidden",children:[e.jsx("div",{className:"w-[540px] shrink-0 flex flex-col overflow-hidden bg-muted/5",children:e.jsx("div",{className:"h-full flex flex-col",children:e.jsxs(Pe,{defaultValue:"config",className:"h-full flex flex-col",children:[e.jsx("div",{className:"px-4 pt-4 shrink-0",children:e.jsxs(ke,{className:"w-full",children:[e.jsx(V,{value:"config",className:"flex-1",children:"Model Config"}),e.jsx(V,{value:"settings",className:"flex-1",children:"Settings"}),e.jsx(V,{value:"info",className:"flex-1",children:"Info"})]})}),e.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col",children:[e.jsx(nt,{currentModel:p,opusModel:L,sonnetModel:R,haikuModel:A,models:c,modelsLoading:o,onApplyPreset:_,onUpdateModel:r=>f("model",r),onUpdateOpusModel:r=>f("opusModel",r),onUpdateSonnetModel:r=>f("sonnetModel",r),onUpdateHaikuModel:r=>f("haikuModel",r)}),e.jsx(it,{enabled:h,autoStart:g,port:n,accountType:m,rateLimit:P,waitOnLimit:z,onUpdateEnabled:r=>f("enabled",r),onUpdateAutoStart:r=>f("autoStart",r),onUpdatePort:r=>f("port",r),onUpdateAccountType:r=>f("accountType",r),onUpdateRateLimit:r=>f("rateLimit",r),onUpdateWaitOnLimit:r=>f("waitOnLimit",r)}),e.jsx(ot,{rawSettings:l})]})]})})}),e.jsxs("div",{className:"flex-1 min-w-0 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(Oe,{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(Fe,{rawJsonContent:u,isRawJsonValid:k,rawJsonEdits:i,rawSettingsEnv:l?.settings?.env,onChange:q,missingRequiredFields:G})]})]}),e.jsx(Te,{open:O,title:"File Modified Externally",description:"This settings file was modified by another process. Overwrite with your changes or discard?",confirmText:"Overwrite",variant:"destructive",onConfirm:()=>F(!0),onCancel:()=>F(!1)})]})}function H({title:t,children:s}){return e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide px-3",children:t}),e.jsx("div",{className:"space-y-1",children:s})]})}function Q({icon:t,label:s,status:o,statusText:d,variant:a="default"}){return e.jsxs("div",{className:"flex items-center gap-3 px-3 py-2 rounded-lg bg-muted/50",children:[e.jsx(t,{className:"w-4 h-4 text-muted-foreground shrink-0"}),e.jsx("div",{className:"flex-1 min-w-0",children:e.jsx("span",{className:"text-sm",children:s})}),e.jsx("div",{className:"flex items-center gap-1.5",children:o?e.jsxs(e.Fragment,{children:[e.jsx(he,{className:Y("w-4 h-4",a==="warning"?"text-yellow-500":"text-green-500")}),e.jsx("span",{className:Y("text-xs",a==="warning"?"text-yellow-500":"text-green-500"),children:d||"Yes"})]}):e.jsxs(e.Fragment,{children:[e.jsx(ge,{className:"w-4 h-4 text-muted-foreground"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:d||"No"})]})})]})}function dt(){return e.jsxs("div",{className:"space-y-4 p-4",children:[e.jsx(y,{className:"h-8 w-full"}),e.jsx(y,{className:"h-12 w-full"}),e.jsx(y,{className:"h-12 w-full"}),e.jsx(y,{className:"h-12 w-full"})]})}function Ct(){const{t}=X(),{status:s,statusLoading:o,refetchStatus:d,startAuth:a,isAuthenticating:c,startDaemon:l,isStartingDaemon:u,stopDaemon:i,isStoppingDaemon:h,install:g,isInstalling:n}=fe();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 shrink-0",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(_e,{className:"w-5 h-5 text-primary"}),e.jsx("h1",{className:"font-semibold",children:t("copilotPage.title")})]}),e.jsx(v,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>d(),disabled:o,children:e.jsx(xe,{className:Y("w-4 h-4",o&&"animate-spin")})})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:t("copilotPage.subtitle")})]}),e.jsx(K,{className:"flex-1",children:o?e.jsx(dt,{}):e.jsxs("div",{className:"p-3 space-y-4",children:[e.jsxs("div",{className:"rounded-md border border-yellow-500/50 bg-yellow-500/15 p-3 space-y-1.5",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(qe,{className:"h-4 w-4 text-yellow-600 dark:text-yellow-400 shrink-0"}),e.jsx("span",{className:"text-xs font-semibold text-yellow-800 dark:text-yellow-200",children:t("copilotPage.unofficialTitle")})]}),e.jsxs("ul",{className:"text-[11px] text-yellow-700 dark:text-yellow-300 space-y-0.5 pl-6 list-disc",children:[e.jsx("li",{children:t("copilotPage.unofficialItem1")}),e.jsx("li",{children:t("copilotPage.unofficialItem2")}),e.jsx("li",{children:t("copilotPage.unofficialItem3")})]})]}),e.jsxs(H,{title:t("copilotPage.setup"),children:[e.jsx(Q,{icon:De,label:"copilot-api",status:s?.installed??!1,statusText:s?.installed?s.version?`v${s.version}`:t("copilotPage.installed"):t("copilotPage.missing")}),!s?.installed&&e.jsx(v,{size:"sm",className:"w-full mt-2",onClick:()=>g(void 0),disabled:n,children:n?e.jsxs(e.Fragment,{children:[e.jsx(pe,{className:"w-3.5 h-3.5 mr-1.5 animate-spin"}),t("copilotPage.installing")]}):e.jsxs(e.Fragment,{children:[e.jsx(Ie,{className:"w-3.5 h-3.5 mr-1.5"}),t("copilotPage.installCopilotApi")]})}),s?.installed&&e.jsx(Q,{icon:ie,label:t("copilotPage.integration"),status:s?.enabled??!1,statusText:s?.enabled?t("copilotPage.enabled"):t("copilotPage.disabled")})]}),s?.installed&&e.jsxs(H,{title:t("copilotPage.auth"),children:[e.jsx(Q,{icon:Ue,label:t("copilotPage.github"),status:s?.authenticated??!1,statusText:s?.authenticated?t("copilotPage.connected"):t("copilotPage.notConnected")}),!s?.authenticated&&e.jsx(v,{size:"sm",className:"w-full mt-2",onClick:()=>a(),disabled:c,children:t(c?"copilotPage.authenticating":"copilotPage.authenticate")})]}),s?.authenticated&&e.jsxs(H,{title:t("copilotPage.daemon"),children:[e.jsx(Q,{icon:Qe,label:t("copilotPage.status"),status:s?.daemon_running??!1,statusText:s?.daemon_running?t("copilotPage.running"):t("copilotPage.stopped")}),e.jsxs("div",{className:"px-3 py-1 text-xs text-muted-foreground",children:[t("copilotPage.port"),": ",s?.port??4141]}),e.jsx("div",{className:"px-1",children:s?.daemon_running?e.jsxs(v,{size:"sm",variant:"outline",className:"w-full",onClick:()=>i(),disabled:h,children:[e.jsx(Je,{className:"w-3.5 h-3.5 mr-1.5"}),t(h?"copilotPage.stopping":"copilotPage.stop")]}):e.jsxs(v,{size:"sm",variant:"outline",className:"w-full",onClick:()=>l(),disabled:u,children:[e.jsx(ie,{className:"w-3.5 h-3.5 mr-1.5"}),t(u?"copilotPage.starting":"copilotPage.start")]})})]})]})}),e.jsx("div",{className:"p-3 border-t bg-background text-xs text-muted-foreground",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{children:t("copilotPage.proxy")}),s?.daemon_running?e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(he,{className:"w-3 h-3 text-green-500"}),t("copilotPage.active")]}):e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(ge,{className:"w-3 h-3 text-muted-foreground"}),t("copilotPage.inactive")]})]})})]}),e.jsx("div",{className:"flex-1 flex flex-col min-w-0 bg-background overflow-hidden",children:e.jsx(rt,{})})]})}export{Ct as CopilotPage};
@@ -1 +1 @@
1
- import{j as e}from"./radix-ui-BR1vy4kf.js";import{r as p}from"./react-vendor-CNOkPC89.js";import{t as o}from"./notifications-B2HqRBj7.js";import{aY as N,aZ as Ye,a as ke,B as D,d as f,c as oe,n as E,Q as $e,R as es,U as $,V as ee,L as M,I as se,a$ as ss,a8 as as,a9 as ts,aa as rs,ab as ns,ac as os,aq as is,r as cs,s as ls,t as ds,v as us,ao as ms,ap as hs,w as ye,a_ as xs}from"./index-CsbQfRnG.js";import{a as gs,u as z,b as A}from"./tanstack-e99Cjjy2.js";import{D as De}from"./default-ports-1QQSffYX.js";import{S as be}from"./switch-D9kCIDCe.js";import{S as fs}from"./separator-BBQkLglZ.js";import{R as Ce,T as ps,az as js,K as q,a5 as vs,ay as Se,ax as ws,L as _,w as Ns,ai as Ps,a2 as ys,Z as ae,al as bs,u as Cs,v as Ss}from"./icons-kPbuhVdj.js";import"./utils-CzKF5WmX.js";import"./form-utils-Cn_Uld6y.js";import"./code-highlight-BRUf_pqB.js";async function ks(){const s=await fetch(N("/cursor/status"));if(!s.ok)throw new Error("Failed to fetch cursor status");return s.json()}async function Ds(){const s=await fetch(N("/cursor/settings"));if(!s.ok)throw new Error("Failed to fetch cursor config");return s.json()}async function As(){const s=await fetch(N("/cursor/models"));if(!s.ok)throw new Error("Failed to fetch cursor models");return s.json()}async function _s(){const s=await fetch(N("/cursor/settings/raw"));if(!s.ok)throw new Error("Failed to fetch cursor raw settings");return s.json()}async function Ms(s){const t=await fetch(N("/cursor/settings"),{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)});if(!t.ok)throw new Error("Failed to update cursor config");return t.json()}async function Ts(s){const t=await fetch(N("/cursor/settings/raw"),{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)});if(t.status===409)throw new Ye("Cursor raw settings changed externally");if(!t.ok)throw new Error("Failed to save cursor raw settings");return t.json()}async function Fs(){const s=await fetch(N("/cursor/auth/auto-detect"),{method:"POST"});if(!s.ok){const t=await s.json().catch(()=>({error:"Auto-detect failed"}));throw new Error(t.error||"Auto-detect failed")}return s.json()}async function Rs(s){const t=await fetch(N("/cursor/auth/import"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)});if(!t.ok){const l=await t.json().catch(()=>({error:"Manual import failed"}));throw new Error(l.error||"Manual import failed")}return t.json()}async function Is(){const s=await fetch(N("/cursor/daemon/start"),{method:"POST"});if(!s.ok)throw new Error("Failed to start cursor daemon");return s.json()}async function Ls(){const s=await fetch(N("/cursor/daemon/stop"),{method:"POST"});if(!s.ok)throw new Error("Failed to stop cursor daemon");return s.json()}function Os(){const s=gs(),t=z({queryKey:["cursor-status"],queryFn:ks,refetchInterval:5e3}),l=z({queryKey:["cursor-config"],queryFn:Ds}),d=z({queryKey:["cursor-models"],queryFn:As}),h=z({queryKey:["cursor-raw-settings"],queryFn:_s}),u=()=>{s.invalidateQueries({queryKey:["cursor-status"]}),s.invalidateQueries({queryKey:["cursor-config"]}),s.invalidateQueries({queryKey:["cursor-models"]}),s.invalidateQueries({queryKey:["cursor-raw-settings"]})},m=A({mutationFn:Ms,onSuccess:u}),r=A({mutationFn:Ts,onSuccess:u}),c=A({mutationFn:Fs,onSuccess:u}),x=A({mutationFn:Rs,onSuccess:u}),i=A({mutationFn:Is,onSuccess:u}),P=A({mutationFn:Ls,onSuccess:u});return p.useMemo(()=>({status:t.data,statusLoading:t.isLoading,statusError:t.error,refetchStatus:t.refetch,config:l.data,configLoading:l.isLoading,models:d.data?.models??[],currentModel:d.data?.current??null,modelsLoading:d.isLoading,rawSettings:h.data,rawSettingsLoading:h.isLoading,refetchRawSettings:h.refetch,updateConfig:m.mutate,updateConfigAsync:m.mutateAsync,isUpdatingConfig:m.isPending,saveRawSettings:r.mutate,saveRawSettingsAsync:r.mutateAsync,isSavingRawSettings:r.isPending,autoDetectAuth:c.mutate,autoDetectAuthAsync:c.mutateAsync,isAutoDetectingAuth:c.isPending,autoDetectAuthResult:c.data,importManualAuth:x.mutate,importManualAuthAsync:x.mutateAsync,isImportingManualAuth:x.isPending,manualAuthResult:x.data,startDaemon:i.mutate,startDaemonAsync:i.mutateAsync,isStartingDaemon:i.isPending,stopDaemon:P.mutate,stopDaemonAsync:P.mutateAsync,isStoppingDaemon:P.isPending}),[t.data,t.isLoading,t.error,t.refetch,l.data,l.isLoading,d.data,d.isLoading,h.data,h.isLoading,h.refetch,m.mutate,m.mutateAsync,m.isPending,r.mutate,r.mutateAsync,r.isPending,c.mutate,c.mutateAsync,c.isPending,c.data,x.mutate,x.mutateAsync,x.isPending,x.data,i.mutate,i.mutateAsync,i.isPending,P.mutate,P.mutateAsync,P.isPending])}function te(s){return{port:String(s?.port??De),auto_start:s?.auto_start??!1,ghost_mode:s?.ghost_mode??!0,model:s?.model?.trim()||"gpt-5.3-codex",opus_model:s?.opus_model?.trim()||"",sonnet_model:s?.sonnet_model?.trim()||"",haiku_model:s?.haiku_model?.trim()||""}}function y(s,t,l){return s.find(h=>t.some(u=>u.test(h.id)))?.id??l}function re(s){return s.toLowerCase().replace(/[^a-z0-9]/g,"")}function b(s,t,l){const d=new Set(t.map(re)),h=s.find(m=>d.has(re(m.id)));if(h)return h.id;const u=s.find(m=>d.has(re(m.name)));return u?u.id:l}function Es(s){try{const t=JSON.parse(s||"{}");return!t||typeof t!="object"||Array.isArray(t)?{isValid:!1,error:"Raw settings must be a JSON object"}:{isValid:!0,settings:t}}catch(t){return{isValid:!1,error:t.message||"Invalid JSON"}}}function G({label:s,description:t,value:l,models:d,disabled:h,allowDefaultFallback:u=!1,onChange:m}){const{t:r}=ke(),c=l||(u?"__default":""),x=d.find(i=>i.id===l);return e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{children:[e.jsx(M,{className:"text-xs font-medium",children:s}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:t})]}),e.jsxs(cs,{value:c,onValueChange:i=>{if(u&&i==="__default"){m("");return}m(i)},disabled:h,children:[e.jsx(ls,{className:"h-9",children:e.jsx(ds,{placeholder:r("cursorPage.selectModel"),children:c&&e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsx("span",{className:"truncate font-mono text-xs",children:u&&c==="__default"?r("cursorPage.useDefaultModel"):x?.name||c}),x?.provider&&e.jsx(D,{variant:"outline",className:"text-[9px] h-4 px-1 capitalize",children:x.provider})]})})}),e.jsx(us,{className:"max-h-[300px]",children:e.jsxs(ms,{children:[e.jsx(hs,{className:"text-xs text-muted-foreground",children:r("cursorPage.availableModelCount",{count:d.length})}),u&&e.jsx(ye,{value:"__default",children:r("cursorPage.useDefaultModel")}),d.map(i=>e.jsx(ye,{value:i.id,children:e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsx("span",{className:"truncate text-xs font-mono",children:i.name||i.id}),e.jsx(D,{variant:"outline",className:"text-[9px] h-4 px-1 capitalize",children:i.provider})]})},i.id))]})})]})]})}function ne({icon:s,label:t,ok:l,detail:d}){return e.jsxs("div",{className:"flex items-center gap-3 rounded-lg bg-muted/50 px-3 py-2",children:[e.jsx(s,{className:"h-4 w-4 text-muted-foreground shrink-0"}),e.jsx("div",{className:"flex-1 min-w-0",children:e.jsx("p",{className:"text-sm",children:t})}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[l?e.jsx(Cs,{className:"h-4 w-4 text-green-500"}):e.jsx(Ss,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{className:oe("text-xs",l?"text-green-500":"text-muted-foreground"),title:d,children:d})]})]})}function Xs(){const{t:s}=ke(),{status:t,statusLoading:l,refetchStatus:d,config:h,updateConfigAsync:u,isUpdatingConfig:m,models:r,modelsLoading:c,currentModel:x,rawSettings:i,rawSettingsLoading:P,refetchRawSettings:Ae,saveRawSettingsAsync:_e,isSavingRawSettings:ie,autoDetectAuthAsync:Me,isAutoDetectingAuth:ce,importManualAuthAsync:Te,isImportingManualAuth:le,startDaemonAsync:Fe,isStartingDaemon:Re,stopDaemonAsync:Ie,isStoppingDaemon:de}=Os(),[k,ue]=p.useState(()=>te()),[j,me]=p.useState(!1),[he,Le]=p.useState("{}"),[T,U]=p.useState(!1),[Oe,I]=p.useState(!1),[B,xe]=p.useState(""),[K,ge]=p.useState(""),C=te(h),fe=j?k.port:C.port,Q=j?k.auto_start:C.auto_start,J=j?k.ghost_mode:C.ghost_mode,v=j?k.model:C.model,H=j?k.opus_model:C.opus_model,V=j?k.sonnet_model:C.sonnet_model,Z=j?k.haiku_model:C.haiku_model,W=T?he:JSON.stringify(i?.settings??{},null,2),pe=!!i,F=p.useMemo(()=>Es(W),[W]),je=F.isValid,ve=j||T,Ee=!T||pe&&je,L=p.useMemo(()=>{const a=new Set,n=[...r].sort((S,Y)=>S.name.localeCompare(Y.name)),g=n.filter(S=>a.has(S.id)?!1:(a.add(S.id),!0));return v&&!n.some(S=>S.id===v)?[{id:v,name:v,provider:"custom"},...g]:g},[r,v]),w=a=>{ue(n=>a(j?n:C)),me(!0)},ze=!!(t?.enabled&&t?.authenticated&&!t?.token_expired),qe=p.useMemo(()=>t?.enabled?e.jsx(D,{children:s("cursorPage.enabled")}):e.jsx(D,{variant:"secondary",children:s("cursorPage.disabled")}),[t?.enabled,s]),Ge=async({suppressSuccessToast:a=!1}={})=>{const n=Number(fe);if(!Number.isInteger(n)||n<1||n>65535)return o.error(s("cursorPage.invalidPort")),!1;if(!v.trim())return o.error(s("cursorPage.defaultModelRequired")),!1;try{return await u({port:n,auto_start:Q,ghost_mode:J,model:v,opus_model:H||void 0,sonnet_model:V||void 0,haiku_model:Z||void 0}),me(!1),ue(te({port:n,auto_start:Q,ghost_mode:J,model:v,opus_model:H||void 0,sonnet_model:V||void 0,haiku_model:Z||void 0})),a||o.success(s("cursorPage.savedConfig")),!0}catch(g){return o.error(g.message||s("cursorPage.failedSaveConfig")),!1}},X=a=>{if(c){o.error(s("cursorPage.modelsLoadingWait"));return}if(r.length===0){o.error(s("cursorPage.noModelsAvailable"));return}const n=v||x||r[0]?.id||"gpt-5.3-codex",g=b(r,["gpt-5.3-codex","gpt53codex","GPT-5.3 Codex"],y(r,[/gpt[-.]?5.*codex/i],n)),S=b(r,["gpt-5.1-codex-max","gpt51codexmax","GPT-5.1 Codex Max"],y(r,[/gpt[-.]?5.*codex.*max/i],g)),Y=b(r,["gpt-5-fast","gpt5fast","GPT-5 Fast"],y(r,[/gpt[-.]?5.*fast/i],g)),Ze=b(r,["gpt-5-mini","gpt5mini","GPT-5 Mini"],y(r,[/gpt[-.]?5.*mini/i],Y)),Ne=b(r,["claude-4.6-opus","claude46opus","Claude 4.6 Opus"],y(r,[/claude[-.]?4\.?6.*opus/i,/claude.*opus/i],g)),Pe=b(r,["claude-4.5-sonnet","claude45sonnet","Claude 4.5 Sonnet"],y(r,[/claude[-.]?4\.?5.*sonnet/i,/claude.*sonnet/i],g)),We=b(r,["claude-4.5-haiku","claude45haiku","Claude 4.5 Haiku"],y(r,[/claude[-.]?4\.?5.*haiku/i,/haiku/i],Pe)),O=b(r,["gemini-3-pro","gemini3pro","Gemini 3 Pro"],y(r,[/gemini[-.]?3.*pro/i],g)),Xe=b(r,["gemini-3-flash","gemini3flash","Gemini 3 Flash"],y(r,[/gemini[-.]?3.*flash/i,/gemini[-.]?2\.?5.*flash/i],O));if(a==="codex53"){w(R=>({...R,model:g,opus_model:S,sonnet_model:g,haiku_model:Ze})),o.success(s("cursorPage.appliedCodexPreset"));return}if(a==="claude46"){w(R=>({...R,model:Ne,opus_model:Ne,sonnet_model:Pe,haiku_model:We})),o.success(s("cursorPage.appliedClaudePreset"));return}w(R=>({...R,model:O,opus_model:O,sonnet_model:O,haiku_model:Xe})),o.success(s("cursorPage.appliedGeminiPreset"))},we=async a=>{try{await u({enabled:a}),o.success(s(a?"cursorPage.integrationEnabled":"cursorPage.integrationDisabled"))}catch(n){o.error(n.message||s("cursorPage.failedUpdateIntegration"))}},Ue=async()=>{try{await Me(),o.success(s("cursorPage.credentialsImported"))}catch(a){o.error(a.message||s("cursorPage.autoDetectFailed"))}},Be=async()=>{if(!B.trim()||!K.trim()){o.error(s("cursorPage.manualRequired"));return}try{await Te({accessToken:B.trim(),machineId:K.trim()}),o.success(s("cursorPage.credentialsImported")),I(!1),xe(""),ge("")}catch(a){o.error(a.message||s("cursorPage.manualImportFailed"))}},Ke=async()=>{try{const a=await Fe();if(!a.success){o.error(a.error||s("cursorPage.failedStartDaemon"));return}o.success(a.pid?s("cursorPage.daemonStartedWithPid",{pid:a.pid}):s("cursorPage.daemonStarted"))}catch(a){o.error(a.message||s("cursorPage.failedStartDaemon"))}},Qe=async()=>{try{const a=await Ie();if(!a.success){o.error(a.error||s("cursorPage.failedStopDaemon"));return}o.success(s("cursorPage.daemonStopped"))}catch(a){o.error(a.message||s("cursorPage.failedStopDaemon"))}},Je=async({suppressSuccessToast:a=!1}={})=>{if(!pe)return o.error(s("cursorPage.rawLoading")),!1;if(!F.isValid||!F.settings)return o.error(F.error||s("cursorPage.invalidJson")),!1;try{return await _e({settings:F.settings,expectedMtime:i?.mtime}),U(!1),a||o.success(s("cursorPage.rawSaved")),!0}catch(n){return xs(n)?o.error(s("cursorPage.rawChanged")):o.error(n.message||s("cursorPage.failedSaveRaw")),!1}},He=async()=>{if(!ve)return;const a=j,n=T;a&&!await Ge({suppressSuccessToast:n})||n&&!await Je({suppressSuccessToast:a})||a&&n&&o.success(s("cursorPage.savedAll"))},Ve=()=>{U(!1),d(),Ae()};return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"h-[calc(100vh-100px)] flex",children:[e.jsxs("div",{className:"w-80 border-r flex flex-col bg-muted/30 shrink-0",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("img",{src:"/assets/sidebar/cursor.svg",alt:"",className:"w-5 h-5 object-contain shrink-0"}),e.jsx("h1",{className:"font-semibold",children:s("cursorPage.title")}),e.jsx(D,{variant:"outline",className:"h-5 border-amber-500/60 bg-amber-500/10 px-1.5 text-[10px] font-semibold uppercase tracking-wide text-amber-800 dark:text-amber-300",children:s("cursorPage.beta")}),qe]}),e.jsx(f,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>d(),disabled:l,children:e.jsx(Ce,{className:oe("w-4 h-4",l&&"animate-spin")})})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:s("cursorPage.subtitle")})]}),e.jsx(E,{className:"flex-1",children:e.jsxs("div",{className:"p-3 space-y-4",children:[e.jsxs("div",{className:"rounded-md border border-yellow-500/50 bg-yellow-500/15 p-3 space-y-1.5",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ps,{className:"h-4 w-4 text-yellow-600 dark:text-yellow-400 shrink-0"}),e.jsx("span",{className:"text-xs font-semibold text-yellow-800 dark:text-yellow-200",children:s("cursorPage.unofficialTitle")})]}),e.jsxs("ul",{className:"text-[11px] text-yellow-700 dark:text-yellow-300 space-y-0.5 pl-6 list-disc",children:[e.jsx("li",{children:s("cursorPage.unofficialItem1")}),e.jsx("li",{children:s("cursorPage.unofficialItem2")}),e.jsx("li",{children:s("cursorPage.unofficialItem3")})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ne,{icon:js,label:s("cursorPage.integration"),ok:!!t?.enabled,detail:t?.enabled?s("cursorPage.enabled"):s("cursorPage.disabled")}),e.jsx(ne,{icon:q,label:s("cursorPage.authentication"),ok:!!(t?.authenticated&&!t?.token_expired),detail:t?.authenticated?t?.token_expired?s("cursorPage.expired"):t.auth_method??s("cursorPage.connected"):s("cursorPage.notConnected")}),e.jsx(ne,{icon:vs,label:s("cursorPage.daemon"),ok:!!t?.daemon_running,detail:t?.daemon_running?s("cursorPage.running"):s("cursorPage.stopped")})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:s("cursorPage.actions")}),t?.enabled?e.jsxs(f,{variant:"outline",size:"sm",className:"w-full",onClick:()=>we(!1),disabled:m,children:[e.jsx(Se,{className:"w-3.5 h-3.5 mr-1.5"}),s("cursorPage.disableIntegration")]}):e.jsxs(f,{size:"sm",className:"w-full",onClick:()=>we(!0),disabled:m,children:[e.jsx(ws,{className:"w-3.5 h-3.5 mr-1.5"}),s("cursorPage.enableIntegration")]}),e.jsxs(f,{variant:"outline",size:"sm",className:"w-full",onClick:Ue,disabled:ce,children:[ce?e.jsx(_,{className:"w-3.5 h-3.5 mr-1.5 animate-spin"}):e.jsx(q,{className:"w-3.5 h-3.5 mr-1.5"}),s("cursorPage.autoDetectAuth")]}),e.jsxs(f,{variant:"outline",size:"sm",className:"w-full",onClick:()=>I(!0),children:[e.jsx(q,{className:"w-3.5 h-3.5 mr-1.5"}),s("cursorPage.manualAuthImport")]}),t?.daemon_running?e.jsxs(f,{variant:"outline",size:"sm",className:"w-full",onClick:Qe,disabled:de,children:[de?e.jsx(_,{className:"w-3.5 h-3.5 mr-1.5 animate-spin"}):e.jsx(Se,{className:"w-3.5 h-3.5 mr-1.5"}),s("cursorPage.stopDaemon")]}):e.jsxs(f,{size:"sm",className:"w-full",onClick:Ke,disabled:!ze,children:[Re?e.jsx(_,{className:"w-3.5 h-3.5 mr-1.5 animate-spin"}):e.jsx(Ns,{className:"w-3.5 h-3.5 mr-1.5"}),s("cursorPage.startDaemon")]})]})]})}),e.jsx("div",{className:"p-3 border-t bg-background text-xs text-muted-foreground",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{children:s("cursorPage.port")}),e.jsx("span",{children:t?.port??h?.port??De})]})})]}),e.jsx("div",{className:"flex-1 flex flex-col min-w-0 bg-background overflow-hidden",children:e.jsxs("div",{className:"flex-1 min-h-0 flex flex-col overflow-hidden",children:[e.jsxs("div",{className:"px-6 py-4 border-b bg-background flex items-center justify-between shrink-0",children:[e.jsx("div",{className:"flex items-center gap-3",children:e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h2",{className:"text-lg font-semibold",children:s("cursorPage.configuration")}),i&&e.jsx(D,{variant:"outline",className:"text-xs",children:"cursor.settings.json"})]}),i&&e.jsxs("p",{className:"text-xs text-muted-foreground mt-0.5",children:[s("cursorPage.lastModified")," ",i.exists?new Date(i.mtime).toLocaleString():s("cursorPage.neverSaved")]})]})}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(f,{variant:"ghost",size:"sm",onClick:Ve,disabled:l||P,children:e.jsx(Ce,{className:oe("w-4 h-4",(l||P)&&"animate-spin")})}),e.jsx(f,{size:"sm",onClick:He,disabled:m||ie||!ve||!Ee,children:m||ie?e.jsxs(e.Fragment,{children:[e.jsx(_,{className:"w-4 h-4 mr-1 animate-spin"}),s("cursorPage.saving")]}):e.jsxs(e.Fragment,{children:[e.jsx(Ps,{className:"w-4 h-4 mr-1"}),s("cursorPage.save")]})})]})]}),e.jsxs("div",{className:"flex-1 min-h-0 flex divide-x overflow-hidden",children:[e.jsx("div",{className:"w-[540px] shrink-0 flex flex-col min-h-0 overflow-hidden bg-muted/5",children:e.jsxs($e,{defaultValue:"config",className:"h-full flex flex-col",children:[e.jsx("div",{className:"px-4 pt-4 shrink-0",children:e.jsxs(es,{className:"w-full",children:[e.jsx($,{value:"config",className:"flex-1",children:s("cursorPage.modelConfig")}),e.jsx($,{value:"settings",className:"flex-1",children:s("cursorPage.settings")}),e.jsx($,{value:"info",className:"flex-1",children:s("cursorPage.info")})]})}),e.jsxs("div",{className:"flex-1 min-h-0 overflow-hidden flex flex-col",children:[e.jsx(ee,{value:"config",className:"flex-1 mt-0 border-0 p-0 data-[state=inactive]:hidden flex flex-col overflow-hidden",children:e.jsx(E,{className:"flex-1",children:e.jsxs("div",{className:"p-4 space-y-6",children:[e.jsxs("div",{children:[e.jsxs("h3",{className:"text-sm font-medium mb-2 flex items-center gap-2",children:[e.jsx(ys,{className:"w-4 h-4"}),s("cursorPage.presets")]}),e.jsx("p",{className:"text-xs text-muted-foreground mb-3",children:s("cursorPage.presetsDesc")}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsxs(f,{variant:"outline",size:"sm",className:"text-xs h-7 gap-1",onClick:()=>X("codex53"),disabled:c||r.length===0,title:"OpenAI-only mapping: GPT-5.3 Codex / Codex Max / GPT-5 Mini",children:[e.jsx(ae,{className:"w-3 h-3"}),"GPT-5.3 Codex"]}),e.jsxs(f,{variant:"outline",size:"sm",className:"text-xs h-7 gap-1",onClick:()=>X("claude46"),disabled:c||r.length===0,title:"Claude-first mapping: Opus 4.6 / Sonnet 4.5 / Haiku 4.5",children:[e.jsx(ae,{className:"w-3 h-3"}),"Claude 4.6"]}),e.jsxs(f,{variant:"outline",size:"sm",className:"text-xs h-7 gap-1",onClick:()=>X("gemini3"),disabled:c||r.length===0,title:"Gemini-first mapping: Gemini 3 Pro + Gemini 3 Flash",children:[e.jsx(ae,{className:"w-3 h-3"}),"Gemini 3 Pro"]})]})]}),e.jsx(fs,{}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-medium mb-2",children:s("cursorPage.modelMapping")}),e.jsx("p",{className:"text-xs text-muted-foreground mb-4",children:s("cursorPage.modelMappingDesc")}),e.jsxs("div",{className:"space-y-4",children:[e.jsx(G,{label:s("cursorPage.defaultModel"),description:s("cursorPage.defaultModelDesc"),value:v,models:L,disabled:c,onChange:a=>{w(n=>({...n,model:a}))}}),e.jsx(G,{label:s("cursorPage.opusModel"),description:s("cursorPage.opusModelDesc"),value:H,models:L,disabled:c,allowDefaultFallback:!0,onChange:a=>{w(n=>({...n,opus_model:a}))}}),e.jsx(G,{label:s("cursorPage.sonnetModel"),description:s("cursorPage.sonnetModelDesc"),value:V,models:L,disabled:c,allowDefaultFallback:!0,onChange:a=>{w(n=>({...n,sonnet_model:a}))}}),e.jsx(G,{label:s("cursorPage.haikuModel"),description:s("cursorPage.haikuModelDesc"),value:Z,models:L,disabled:c,allowDefaultFallback:!0,onChange:a=>{w(n=>({...n,haiku_model:a}))}})]})]})]})})}),e.jsx(ee,{value:"settings",className:"flex-1 mt-0 border-0 p-0 data-[state=inactive]:hidden flex flex-col overflow-hidden",children:e.jsx(E,{className:"flex-1",children:e.jsx("div",{className:"p-4 space-y-6",children:e.jsxs("div",{className:"space-y-4",children:[e.jsx("h3",{className:"text-sm font-medium",children:s("cursorPage.runtimeSettings")}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(M,{htmlFor:"cursor-port",className:"text-xs",children:"Port"}),e.jsx(se,{id:"cursor-port",type:"number",min:1,max:65535,className:"max-w-[150px] h-8",value:fe,onChange:a=>{w(n=>({...n,port:a.target.value}))}})]}),e.jsxs("div",{className:"flex items-center justify-between rounded-lg border p-3",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(M,{htmlFor:"cursor-auto-start",className:"text-xs",children:s("cursorPage.autoStartDaemon")}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:s("cursorPage.autoStartDesc")})]}),e.jsx(be,{id:"cursor-auto-start",checked:Q,onCheckedChange:a=>{w(n=>({...n,auto_start:a}))}})]}),e.jsxs("div",{className:"flex items-center justify-between rounded-lg border p-3",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(M,{htmlFor:"cursor-ghost-mode",className:"text-xs",children:s("cursorPage.ghostMode")}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:s("cursorPage.ghostModeDesc")})]}),e.jsx(be,{id:"cursor-ghost-mode",checked:J,onCheckedChange:a=>{w(n=>({...n,ghost_mode:a}))}})]})]})})})}),e.jsx(ee,{value:"info",className:"flex-1 mt-0 border-0 p-0 data-[state=inactive]:hidden flex flex-col overflow-hidden",children:e.jsx(E,{className:"flex-1",children:e.jsxs("div",{className:"p-4 space-y-6",children:[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:s("cursorPage.provider")}),e.jsx("span",{className:"font-mono",children:"Cursor IDE"})]}),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:s("cursorPage.filePath")}),e.jsx("code",{className:"bg-muted px-1.5 py-0.5 rounded text-xs break-all",children:i?.path??"~/.ccs/cursor.settings.json"})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Model mapping writes `ANTHROPIC_MODEL`, `ANTHROPIC_DEFAULT_OPUS_MODEL`, `ANTHROPIC_DEFAULT_SONNET_MODEL`, and `ANTHROPIC_DEFAULT_HAIKU_MODEL` in `cursor.settings.json`."})]}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-medium mb-3",children:s("cursorPage.availableModels")}),c?e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[e.jsx(_,{className:"w-4 h-4 animate-spin"}),s("cursorPage.loadingModels")]}):r.length===0?e.jsx("p",{className:"text-sm text-muted-foreground",children:s("cursorPage.noModels")}):e.jsx("div",{className:"space-y-2",children:r.map(a=>e.jsxs("div",{className:"rounded-lg border px-3 py-2 flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:a.id}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[a.name," • ",a.provider]})]}),a.id===x&&e.jsx(D,{children:s("cursorPage.default")})]},a.id))})]})]})})})]})]})}),e.jsxs("div",{className:"flex-1 min-w-0 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(bs,{className:"w-4 h-4 text-muted-foreground"}),e.jsx("span",{className:"text-sm font-medium text-muted-foreground",children:s("cursorPage.rawConfiguration")})]}),e.jsx(ss,{rawJsonContent:W,isRawJsonValid:je,rawJsonEdits:T?he:null,rawSettingsEnv:i?.settings?.env,onChange:a=>{U(!0),Le(a)}})]})]})]})})]}),e.jsx(as,{open:Oe,onOpenChange:I,children:e.jsxs(ts,{children:[e.jsxs(rs,{children:[e.jsx(ns,{children:s("cursorPage.manualImportTitle")}),e.jsx(os,{children:s("cursorPage.manualImportDesc")})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(M,{htmlFor:"cursor-manual-token",children:s("cursorPage.accessToken")}),e.jsx(se,{id:"cursor-manual-token",value:B,onChange:a=>xe(a.target.value),placeholder:s("cursorPage.accessTokenPlaceholder")})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(M,{htmlFor:"cursor-manual-machine-id",children:s("cursorPage.machineId")}),e.jsx(se,{id:"cursor-manual-machine-id",value:K,onChange:a=>ge(a.target.value),placeholder:s("cursorPage.machineIdPlaceholder")})]})]}),e.jsxs(is,{children:[e.jsx(f,{variant:"outline",onClick:()=>I(!1),children:s("cursorPage.cancel")}),e.jsxs(f,{onClick:Be,disabled:le,children:[le?e.jsx(_,{className:"w-4 h-4 mr-2 animate-spin"}):e.jsx(q,{className:"w-4 h-4 mr-2"}),s("cursorPage.import")]})]})]})})]})}export{Xs as CursorPage};
1
+ import{j as e}from"./radix-ui-BR1vy4kf.js";import{r as p}from"./react-vendor-CNOkPC89.js";import{t as o}from"./notifications-B2HqRBj7.js";import{aY as N,aZ as Ye,a as ke,B as A,d as f,c as oe,n as E,Q as $e,R as es,U as $,V as ee,L as M,I as se,a$ as ss,a8 as as,a9 as ts,aa as rs,ab as ns,ac as os,aq as is,r as cs,s as ls,t as ds,v as us,ao as ms,ap as hs,w as ye,a_ as xs}from"./index-DCQkhmoo.js";import{a as gs,u as z,b as D}from"./tanstack-e99Cjjy2.js";import{D as Ae}from"./default-ports-1QQSffYX.js";import{S as be}from"./switch-BL5xZtnr.js";import{S as fs}from"./separator-DtcqgZIS.js";import{R as Ce,T as ps,aA as js,K as q,a5 as vs,az as Se,ay as ws,L as _,w as Ns,ai as Ps,a2 as ys,Z as ae,al as bs,u as Cs,v as Ss}from"./icons-BYZM_9Gm.js";import"./utils-CzKF5WmX.js";import"./form-utils-Cn_Uld6y.js";import"./code-highlight-BRUf_pqB.js";async function ks(){const s=await fetch(N("/cursor/status"));if(!s.ok)throw new Error("Failed to fetch cursor status");return s.json()}async function As(){const s=await fetch(N("/cursor/settings"));if(!s.ok)throw new Error("Failed to fetch cursor config");return s.json()}async function Ds(){const s=await fetch(N("/cursor/models"));if(!s.ok)throw new Error("Failed to fetch cursor models");return s.json()}async function _s(){const s=await fetch(N("/cursor/settings/raw"));if(!s.ok)throw new Error("Failed to fetch cursor raw settings");return s.json()}async function Ms(s){const t=await fetch(N("/cursor/settings"),{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)});if(!t.ok)throw new Error("Failed to update cursor config");return t.json()}async function Ts(s){const t=await fetch(N("/cursor/settings/raw"),{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)});if(t.status===409)throw new Ye("Cursor raw settings changed externally");if(!t.ok)throw new Error("Failed to save cursor raw settings");return t.json()}async function Fs(){const s=await fetch(N("/cursor/auth/auto-detect"),{method:"POST"});if(!s.ok){const t=await s.json().catch(()=>({error:"Auto-detect failed"}));throw new Error(t.error||"Auto-detect failed")}return s.json()}async function Rs(s){const t=await fetch(N("/cursor/auth/import"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)});if(!t.ok){const l=await t.json().catch(()=>({error:"Manual import failed"}));throw new Error(l.error||"Manual import failed")}return t.json()}async function Is(){const s=await fetch(N("/cursor/daemon/start"),{method:"POST"});if(!s.ok)throw new Error("Failed to start cursor daemon");return s.json()}async function Ls(){const s=await fetch(N("/cursor/daemon/stop"),{method:"POST"});if(!s.ok)throw new Error("Failed to stop cursor daemon");return s.json()}function Os(){const s=gs(),t=z({queryKey:["cursor-status"],queryFn:ks,refetchInterval:5e3}),l=z({queryKey:["cursor-config"],queryFn:As}),d=z({queryKey:["cursor-models"],queryFn:Ds}),h=z({queryKey:["cursor-raw-settings"],queryFn:_s}),u=()=>{s.invalidateQueries({queryKey:["cursor-status"]}),s.invalidateQueries({queryKey:["cursor-config"]}),s.invalidateQueries({queryKey:["cursor-models"]}),s.invalidateQueries({queryKey:["cursor-raw-settings"]})},m=D({mutationFn:Ms,onSuccess:u}),r=D({mutationFn:Ts,onSuccess:u}),c=D({mutationFn:Fs,onSuccess:u}),x=D({mutationFn:Rs,onSuccess:u}),i=D({mutationFn:Is,onSuccess:u}),P=D({mutationFn:Ls,onSuccess:u});return p.useMemo(()=>({status:t.data,statusLoading:t.isLoading,statusError:t.error,refetchStatus:t.refetch,config:l.data,configLoading:l.isLoading,models:d.data?.models??[],currentModel:d.data?.current??null,modelsLoading:d.isLoading,rawSettings:h.data,rawSettingsLoading:h.isLoading,refetchRawSettings:h.refetch,updateConfig:m.mutate,updateConfigAsync:m.mutateAsync,isUpdatingConfig:m.isPending,saveRawSettings:r.mutate,saveRawSettingsAsync:r.mutateAsync,isSavingRawSettings:r.isPending,autoDetectAuth:c.mutate,autoDetectAuthAsync:c.mutateAsync,isAutoDetectingAuth:c.isPending,autoDetectAuthResult:c.data,importManualAuth:x.mutate,importManualAuthAsync:x.mutateAsync,isImportingManualAuth:x.isPending,manualAuthResult:x.data,startDaemon:i.mutate,startDaemonAsync:i.mutateAsync,isStartingDaemon:i.isPending,stopDaemon:P.mutate,stopDaemonAsync:P.mutateAsync,isStoppingDaemon:P.isPending}),[t.data,t.isLoading,t.error,t.refetch,l.data,l.isLoading,d.data,d.isLoading,h.data,h.isLoading,h.refetch,m.mutate,m.mutateAsync,m.isPending,r.mutate,r.mutateAsync,r.isPending,c.mutate,c.mutateAsync,c.isPending,c.data,x.mutate,x.mutateAsync,x.isPending,x.data,i.mutate,i.mutateAsync,i.isPending,P.mutate,P.mutateAsync,P.isPending])}function te(s){return{port:String(s?.port??Ae),auto_start:s?.auto_start??!1,ghost_mode:s?.ghost_mode??!0,model:s?.model?.trim()||"gpt-5.3-codex",opus_model:s?.opus_model?.trim()||"",sonnet_model:s?.sonnet_model?.trim()||"",haiku_model:s?.haiku_model?.trim()||""}}function y(s,t,l){return s.find(h=>t.some(u=>u.test(h.id)))?.id??l}function re(s){return s.toLowerCase().replace(/[^a-z0-9]/g,"")}function b(s,t,l){const d=new Set(t.map(re)),h=s.find(m=>d.has(re(m.id)));if(h)return h.id;const u=s.find(m=>d.has(re(m.name)));return u?u.id:l}function Es(s){try{const t=JSON.parse(s||"{}");return!t||typeof t!="object"||Array.isArray(t)?{isValid:!1,error:"Raw settings must be a JSON object"}:{isValid:!0,settings:t}}catch(t){return{isValid:!1,error:t.message||"Invalid JSON"}}}function G({label:s,description:t,value:l,models:d,disabled:h,allowDefaultFallback:u=!1,onChange:m}){const{t:r}=ke(),c=l||(u?"__default":""),x=d.find(i=>i.id===l);return e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{children:[e.jsx(M,{className:"text-xs font-medium",children:s}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:t})]}),e.jsxs(cs,{value:c,onValueChange:i=>{if(u&&i==="__default"){m("");return}m(i)},disabled:h,children:[e.jsx(ls,{className:"h-9",children:e.jsx(ds,{placeholder:r("cursorPage.selectModel"),children:c&&e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsx("span",{className:"truncate font-mono text-xs",children:u&&c==="__default"?r("cursorPage.useDefaultModel"):x?.name||c}),x?.provider&&e.jsx(A,{variant:"outline",className:"text-[9px] h-4 px-1 capitalize",children:x.provider})]})})}),e.jsx(us,{className:"max-h-[300px]",children:e.jsxs(ms,{children:[e.jsx(hs,{className:"text-xs text-muted-foreground",children:r("cursorPage.availableModelCount",{count:d.length})}),u&&e.jsx(ye,{value:"__default",children:r("cursorPage.useDefaultModel")}),d.map(i=>e.jsx(ye,{value:i.id,children:e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsx("span",{className:"truncate text-xs font-mono",children:i.name||i.id}),e.jsx(A,{variant:"outline",className:"text-[9px] h-4 px-1 capitalize",children:i.provider})]})},i.id))]})})]})]})}function ne({icon:s,label:t,ok:l,detail:d}){return e.jsxs("div",{className:"flex items-center gap-3 rounded-lg bg-muted/50 px-3 py-2",children:[e.jsx(s,{className:"h-4 w-4 text-muted-foreground shrink-0"}),e.jsx("div",{className:"flex-1 min-w-0",children:e.jsx("p",{className:"text-sm",children:t})}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[l?e.jsx(Cs,{className:"h-4 w-4 text-green-500"}):e.jsx(Ss,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{className:oe("text-xs",l?"text-green-500":"text-muted-foreground"),title:d,children:d})]})]})}function Xs(){const{t:s}=ke(),{status:t,statusLoading:l,refetchStatus:d,config:h,updateConfigAsync:u,isUpdatingConfig:m,models:r,modelsLoading:c,currentModel:x,rawSettings:i,rawSettingsLoading:P,refetchRawSettings:De,saveRawSettingsAsync:_e,isSavingRawSettings:ie,autoDetectAuthAsync:Me,isAutoDetectingAuth:ce,importManualAuthAsync:Te,isImportingManualAuth:le,startDaemonAsync:Fe,isStartingDaemon:Re,stopDaemonAsync:Ie,isStoppingDaemon:de}=Os(),[k,ue]=p.useState(()=>te()),[j,me]=p.useState(!1),[he,Le]=p.useState("{}"),[T,U]=p.useState(!1),[Oe,I]=p.useState(!1),[B,xe]=p.useState(""),[K,ge]=p.useState(""),C=te(h),fe=j?k.port:C.port,Q=j?k.auto_start:C.auto_start,J=j?k.ghost_mode:C.ghost_mode,v=j?k.model:C.model,H=j?k.opus_model:C.opus_model,V=j?k.sonnet_model:C.sonnet_model,Z=j?k.haiku_model:C.haiku_model,W=T?he:JSON.stringify(i?.settings??{},null,2),pe=!!i,F=p.useMemo(()=>Es(W),[W]),je=F.isValid,ve=j||T,Ee=!T||pe&&je,L=p.useMemo(()=>{const a=new Set,n=[...r].sort((S,Y)=>S.name.localeCompare(Y.name)),g=n.filter(S=>a.has(S.id)?!1:(a.add(S.id),!0));return v&&!n.some(S=>S.id===v)?[{id:v,name:v,provider:"custom"},...g]:g},[r,v]),w=a=>{ue(n=>a(j?n:C)),me(!0)},ze=!!(t?.enabled&&t?.authenticated&&!t?.token_expired),qe=p.useMemo(()=>t?.enabled?e.jsx(A,{children:s("cursorPage.enabled")}):e.jsx(A,{variant:"secondary",children:s("cursorPage.disabled")}),[t?.enabled,s]),Ge=async({suppressSuccessToast:a=!1}={})=>{const n=Number(fe);if(!Number.isInteger(n)||n<1||n>65535)return o.error(s("cursorPage.invalidPort")),!1;if(!v.trim())return o.error(s("cursorPage.defaultModelRequired")),!1;try{return await u({port:n,auto_start:Q,ghost_mode:J,model:v,opus_model:H||void 0,sonnet_model:V||void 0,haiku_model:Z||void 0}),me(!1),ue(te({port:n,auto_start:Q,ghost_mode:J,model:v,opus_model:H||void 0,sonnet_model:V||void 0,haiku_model:Z||void 0})),a||o.success(s("cursorPage.savedConfig")),!0}catch(g){return o.error(g.message||s("cursorPage.failedSaveConfig")),!1}},X=a=>{if(c){o.error(s("cursorPage.modelsLoadingWait"));return}if(r.length===0){o.error(s("cursorPage.noModelsAvailable"));return}const n=v||x||r[0]?.id||"gpt-5.3-codex",g=b(r,["gpt-5.3-codex","gpt53codex","GPT-5.3 Codex"],y(r,[/gpt[-.]?5.*codex/i],n)),S=b(r,["gpt-5.1-codex-max","gpt51codexmax","GPT-5.1 Codex Max"],y(r,[/gpt[-.]?5.*codex.*max/i],g)),Y=b(r,["gpt-5-fast","gpt5fast","GPT-5 Fast"],y(r,[/gpt[-.]?5.*fast/i],g)),Ze=b(r,["gpt-5-mini","gpt5mini","GPT-5 Mini"],y(r,[/gpt[-.]?5.*mini/i],Y)),Ne=b(r,["claude-4.6-opus","claude46opus","Claude 4.6 Opus"],y(r,[/claude[-.]?4\.?6.*opus/i,/claude.*opus/i],g)),Pe=b(r,["claude-4.5-sonnet","claude45sonnet","Claude 4.5 Sonnet"],y(r,[/claude[-.]?4\.?5.*sonnet/i,/claude.*sonnet/i],g)),We=b(r,["claude-4.5-haiku","claude45haiku","Claude 4.5 Haiku"],y(r,[/claude[-.]?4\.?5.*haiku/i,/haiku/i],Pe)),O=b(r,["gemini-3-pro","gemini3pro","Gemini 3 Pro"],y(r,[/gemini[-.]?3.*pro/i],g)),Xe=b(r,["gemini-3-flash","gemini3flash","Gemini 3 Flash"],y(r,[/gemini[-.]?3.*flash/i,/gemini[-.]?2\.?5.*flash/i],O));if(a==="codex53"){w(R=>({...R,model:g,opus_model:S,sonnet_model:g,haiku_model:Ze})),o.success(s("cursorPage.appliedCodexPreset"));return}if(a==="claude46"){w(R=>({...R,model:Ne,opus_model:Ne,sonnet_model:Pe,haiku_model:We})),o.success(s("cursorPage.appliedClaudePreset"));return}w(R=>({...R,model:O,opus_model:O,sonnet_model:O,haiku_model:Xe})),o.success(s("cursorPage.appliedGeminiPreset"))},we=async a=>{try{await u({enabled:a}),o.success(s(a?"cursorPage.integrationEnabled":"cursorPage.integrationDisabled"))}catch(n){o.error(n.message||s("cursorPage.failedUpdateIntegration"))}},Ue=async()=>{try{await Me(),o.success(s("cursorPage.credentialsImported"))}catch(a){o.error(a.message||s("cursorPage.autoDetectFailed"))}},Be=async()=>{if(!B.trim()||!K.trim()){o.error(s("cursorPage.manualRequired"));return}try{await Te({accessToken:B.trim(),machineId:K.trim()}),o.success(s("cursorPage.credentialsImported")),I(!1),xe(""),ge("")}catch(a){o.error(a.message||s("cursorPage.manualImportFailed"))}},Ke=async()=>{try{const a=await Fe();if(!a.success){o.error(a.error||s("cursorPage.failedStartDaemon"));return}o.success(a.pid?s("cursorPage.daemonStartedWithPid",{pid:a.pid}):s("cursorPage.daemonStarted"))}catch(a){o.error(a.message||s("cursorPage.failedStartDaemon"))}},Qe=async()=>{try{const a=await Ie();if(!a.success){o.error(a.error||s("cursorPage.failedStopDaemon"));return}o.success(s("cursorPage.daemonStopped"))}catch(a){o.error(a.message||s("cursorPage.failedStopDaemon"))}},Je=async({suppressSuccessToast:a=!1}={})=>{if(!pe)return o.error(s("cursorPage.rawLoading")),!1;if(!F.isValid||!F.settings)return o.error(F.error||s("cursorPage.invalidJson")),!1;try{return await _e({settings:F.settings,expectedMtime:i?.mtime}),U(!1),a||o.success(s("cursorPage.rawSaved")),!0}catch(n){return xs(n)?o.error(s("cursorPage.rawChanged")):o.error(n.message||s("cursorPage.failedSaveRaw")),!1}},He=async()=>{if(!ve)return;const a=j,n=T;a&&!await Ge({suppressSuccessToast:n})||n&&!await Je({suppressSuccessToast:a})||a&&n&&o.success(s("cursorPage.savedAll"))},Ve=()=>{U(!1),d(),De()};return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"h-[calc(100vh-100px)] flex",children:[e.jsxs("div",{className:"w-80 border-r flex flex-col bg-muted/30 shrink-0",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("img",{src:"/assets/sidebar/cursor.svg",alt:"",className:"w-5 h-5 object-contain shrink-0"}),e.jsx("h1",{className:"font-semibold",children:s("cursorPage.title")}),e.jsx(A,{variant:"outline",className:"h-5 border-amber-500/60 bg-amber-500/10 px-1.5 text-[10px] font-semibold uppercase tracking-wide text-amber-800 dark:text-amber-300",children:s("cursorPage.beta")}),qe]}),e.jsx(f,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>d(),disabled:l,children:e.jsx(Ce,{className:oe("w-4 h-4",l&&"animate-spin")})})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:s("cursorPage.subtitle")})]}),e.jsx(E,{className:"flex-1",children:e.jsxs("div",{className:"p-3 space-y-4",children:[e.jsxs("div",{className:"rounded-md border border-yellow-500/50 bg-yellow-500/15 p-3 space-y-1.5",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ps,{className:"h-4 w-4 text-yellow-600 dark:text-yellow-400 shrink-0"}),e.jsx("span",{className:"text-xs font-semibold text-yellow-800 dark:text-yellow-200",children:s("cursorPage.unofficialTitle")})]}),e.jsxs("ul",{className:"text-[11px] text-yellow-700 dark:text-yellow-300 space-y-0.5 pl-6 list-disc",children:[e.jsx("li",{children:s("cursorPage.unofficialItem1")}),e.jsx("li",{children:s("cursorPage.unofficialItem2")}),e.jsx("li",{children:s("cursorPage.unofficialItem3")})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ne,{icon:js,label:s("cursorPage.integration"),ok:!!t?.enabled,detail:t?.enabled?s("cursorPage.enabled"):s("cursorPage.disabled")}),e.jsx(ne,{icon:q,label:s("cursorPage.authentication"),ok:!!(t?.authenticated&&!t?.token_expired),detail:t?.authenticated?t?.token_expired?s("cursorPage.expired"):t.auth_method??s("cursorPage.connected"):s("cursorPage.notConnected")}),e.jsx(ne,{icon:vs,label:s("cursorPage.daemon"),ok:!!t?.daemon_running,detail:t?.daemon_running?s("cursorPage.running"):s("cursorPage.stopped")})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:s("cursorPage.actions")}),t?.enabled?e.jsxs(f,{variant:"outline",size:"sm",className:"w-full",onClick:()=>we(!1),disabled:m,children:[e.jsx(Se,{className:"w-3.5 h-3.5 mr-1.5"}),s("cursorPage.disableIntegration")]}):e.jsxs(f,{size:"sm",className:"w-full",onClick:()=>we(!0),disabled:m,children:[e.jsx(ws,{className:"w-3.5 h-3.5 mr-1.5"}),s("cursorPage.enableIntegration")]}),e.jsxs(f,{variant:"outline",size:"sm",className:"w-full",onClick:Ue,disabled:ce,children:[ce?e.jsx(_,{className:"w-3.5 h-3.5 mr-1.5 animate-spin"}):e.jsx(q,{className:"w-3.5 h-3.5 mr-1.5"}),s("cursorPage.autoDetectAuth")]}),e.jsxs(f,{variant:"outline",size:"sm",className:"w-full",onClick:()=>I(!0),children:[e.jsx(q,{className:"w-3.5 h-3.5 mr-1.5"}),s("cursorPage.manualAuthImport")]}),t?.daemon_running?e.jsxs(f,{variant:"outline",size:"sm",className:"w-full",onClick:Qe,disabled:de,children:[de?e.jsx(_,{className:"w-3.5 h-3.5 mr-1.5 animate-spin"}):e.jsx(Se,{className:"w-3.5 h-3.5 mr-1.5"}),s("cursorPage.stopDaemon")]}):e.jsxs(f,{size:"sm",className:"w-full",onClick:Ke,disabled:!ze,children:[Re?e.jsx(_,{className:"w-3.5 h-3.5 mr-1.5 animate-spin"}):e.jsx(Ns,{className:"w-3.5 h-3.5 mr-1.5"}),s("cursorPage.startDaemon")]})]})]})}),e.jsx("div",{className:"p-3 border-t bg-background text-xs text-muted-foreground",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{children:s("cursorPage.port")}),e.jsx("span",{children:t?.port??h?.port??Ae})]})})]}),e.jsx("div",{className:"flex-1 flex flex-col min-w-0 bg-background overflow-hidden",children:e.jsxs("div",{className:"flex-1 min-h-0 flex flex-col overflow-hidden",children:[e.jsxs("div",{className:"px-6 py-4 border-b bg-background flex items-center justify-between shrink-0",children:[e.jsx("div",{className:"flex items-center gap-3",children:e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h2",{className:"text-lg font-semibold",children:s("cursorPage.configuration")}),i&&e.jsx(A,{variant:"outline",className:"text-xs",children:"cursor.settings.json"})]}),i&&e.jsxs("p",{className:"text-xs text-muted-foreground mt-0.5",children:[s("cursorPage.lastModified")," ",i.exists?new Date(i.mtime).toLocaleString():s("cursorPage.neverSaved")]})]})}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(f,{variant:"ghost",size:"sm",onClick:Ve,disabled:l||P,children:e.jsx(Ce,{className:oe("w-4 h-4",(l||P)&&"animate-spin")})}),e.jsx(f,{size:"sm",onClick:He,disabled:m||ie||!ve||!Ee,children:m||ie?e.jsxs(e.Fragment,{children:[e.jsx(_,{className:"w-4 h-4 mr-1 animate-spin"}),s("cursorPage.saving")]}):e.jsxs(e.Fragment,{children:[e.jsx(Ps,{className:"w-4 h-4 mr-1"}),s("cursorPage.save")]})})]})]}),e.jsxs("div",{className:"flex-1 min-h-0 flex divide-x overflow-hidden",children:[e.jsx("div",{className:"w-[540px] shrink-0 flex flex-col min-h-0 overflow-hidden bg-muted/5",children:e.jsxs($e,{defaultValue:"config",className:"h-full flex flex-col",children:[e.jsx("div",{className:"px-4 pt-4 shrink-0",children:e.jsxs(es,{className:"w-full",children:[e.jsx($,{value:"config",className:"flex-1",children:s("cursorPage.modelConfig")}),e.jsx($,{value:"settings",className:"flex-1",children:s("cursorPage.settings")}),e.jsx($,{value:"info",className:"flex-1",children:s("cursorPage.info")})]})}),e.jsxs("div",{className:"flex-1 min-h-0 overflow-hidden flex flex-col",children:[e.jsx(ee,{value:"config",className:"flex-1 mt-0 border-0 p-0 data-[state=inactive]:hidden flex flex-col overflow-hidden",children:e.jsx(E,{className:"flex-1",children:e.jsxs("div",{className:"p-4 space-y-6",children:[e.jsxs("div",{children:[e.jsxs("h3",{className:"text-sm font-medium mb-2 flex items-center gap-2",children:[e.jsx(ys,{className:"w-4 h-4"}),s("cursorPage.presets")]}),e.jsx("p",{className:"text-xs text-muted-foreground mb-3",children:s("cursorPage.presetsDesc")}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsxs(f,{variant:"outline",size:"sm",className:"text-xs h-7 gap-1",onClick:()=>X("codex53"),disabled:c||r.length===0,title:"OpenAI-only mapping: GPT-5.3 Codex / Codex Max / GPT-5 Mini",children:[e.jsx(ae,{className:"w-3 h-3"}),"GPT-5.3 Codex"]}),e.jsxs(f,{variant:"outline",size:"sm",className:"text-xs h-7 gap-1",onClick:()=>X("claude46"),disabled:c||r.length===0,title:"Claude-first mapping: Opus 4.6 / Sonnet 4.5 / Haiku 4.5",children:[e.jsx(ae,{className:"w-3 h-3"}),"Claude 4.6"]}),e.jsxs(f,{variant:"outline",size:"sm",className:"text-xs h-7 gap-1",onClick:()=>X("gemini3"),disabled:c||r.length===0,title:"Gemini-first mapping: Gemini 3 Pro + Gemini 3 Flash",children:[e.jsx(ae,{className:"w-3 h-3"}),"Gemini 3 Pro"]})]})]}),e.jsx(fs,{}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-medium mb-2",children:s("cursorPage.modelMapping")}),e.jsx("p",{className:"text-xs text-muted-foreground mb-4",children:s("cursorPage.modelMappingDesc")}),e.jsxs("div",{className:"space-y-4",children:[e.jsx(G,{label:s("cursorPage.defaultModel"),description:s("cursorPage.defaultModelDesc"),value:v,models:L,disabled:c,onChange:a=>{w(n=>({...n,model:a}))}}),e.jsx(G,{label:s("cursorPage.opusModel"),description:s("cursorPage.opusModelDesc"),value:H,models:L,disabled:c,allowDefaultFallback:!0,onChange:a=>{w(n=>({...n,opus_model:a}))}}),e.jsx(G,{label:s("cursorPage.sonnetModel"),description:s("cursorPage.sonnetModelDesc"),value:V,models:L,disabled:c,allowDefaultFallback:!0,onChange:a=>{w(n=>({...n,sonnet_model:a}))}}),e.jsx(G,{label:s("cursorPage.haikuModel"),description:s("cursorPage.haikuModelDesc"),value:Z,models:L,disabled:c,allowDefaultFallback:!0,onChange:a=>{w(n=>({...n,haiku_model:a}))}})]})]})]})})}),e.jsx(ee,{value:"settings",className:"flex-1 mt-0 border-0 p-0 data-[state=inactive]:hidden flex flex-col overflow-hidden",children:e.jsx(E,{className:"flex-1",children:e.jsx("div",{className:"p-4 space-y-6",children:e.jsxs("div",{className:"space-y-4",children:[e.jsx("h3",{className:"text-sm font-medium",children:s("cursorPage.runtimeSettings")}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(M,{htmlFor:"cursor-port",className:"text-xs",children:"Port"}),e.jsx(se,{id:"cursor-port",type:"number",min:1,max:65535,className:"max-w-[150px] h-8",value:fe,onChange:a=>{w(n=>({...n,port:a.target.value}))}})]}),e.jsxs("div",{className:"flex items-center justify-between rounded-lg border p-3",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(M,{htmlFor:"cursor-auto-start",className:"text-xs",children:s("cursorPage.autoStartDaemon")}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:s("cursorPage.autoStartDesc")})]}),e.jsx(be,{id:"cursor-auto-start",checked:Q,onCheckedChange:a=>{w(n=>({...n,auto_start:a}))}})]}),e.jsxs("div",{className:"flex items-center justify-between rounded-lg border p-3",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(M,{htmlFor:"cursor-ghost-mode",className:"text-xs",children:s("cursorPage.ghostMode")}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:s("cursorPage.ghostModeDesc")})]}),e.jsx(be,{id:"cursor-ghost-mode",checked:J,onCheckedChange:a=>{w(n=>({...n,ghost_mode:a}))}})]})]})})})}),e.jsx(ee,{value:"info",className:"flex-1 mt-0 border-0 p-0 data-[state=inactive]:hidden flex flex-col overflow-hidden",children:e.jsx(E,{className:"flex-1",children:e.jsxs("div",{className:"p-4 space-y-6",children:[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:s("cursorPage.provider")}),e.jsx("span",{className:"font-mono",children:"Cursor IDE"})]}),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:s("cursorPage.filePath")}),e.jsx("code",{className:"bg-muted px-1.5 py-0.5 rounded text-xs break-all",children:i?.path??"~/.ccs/cursor.settings.json"})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Model mapping writes `ANTHROPIC_MODEL`, `ANTHROPIC_DEFAULT_OPUS_MODEL`, `ANTHROPIC_DEFAULT_SONNET_MODEL`, and `ANTHROPIC_DEFAULT_HAIKU_MODEL` in `cursor.settings.json`."})]}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-medium mb-3",children:s("cursorPage.availableModels")}),c?e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[e.jsx(_,{className:"w-4 h-4 animate-spin"}),s("cursorPage.loadingModels")]}):r.length===0?e.jsx("p",{className:"text-sm text-muted-foreground",children:s("cursorPage.noModels")}):e.jsx("div",{className:"space-y-2",children:r.map(a=>e.jsxs("div",{className:"rounded-lg border px-3 py-2 flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:a.id}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[a.name," • ",a.provider]})]}),a.id===x&&e.jsx(A,{children:s("cursorPage.default")})]},a.id))})]})]})})})]})]})}),e.jsxs("div",{className:"flex-1 min-w-0 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(bs,{className:"w-4 h-4 text-muted-foreground"}),e.jsx("span",{className:"text-sm font-medium text-muted-foreground",children:s("cursorPage.rawConfiguration")})]}),e.jsx(ss,{rawJsonContent:W,isRawJsonValid:je,rawJsonEdits:T?he:null,rawSettingsEnv:i?.settings?.env,onChange:a=>{U(!0),Le(a)}})]})]})]})})]}),e.jsx(as,{open:Oe,onOpenChange:I,children:e.jsxs(ts,{children:[e.jsxs(rs,{children:[e.jsx(ns,{children:s("cursorPage.manualImportTitle")}),e.jsx(os,{children:s("cursorPage.manualImportDesc")})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(M,{htmlFor:"cursor-manual-token",children:s("cursorPage.accessToken")}),e.jsx(se,{id:"cursor-manual-token",value:B,onChange:a=>xe(a.target.value),placeholder:s("cursorPage.accessTokenPlaceholder")})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(M,{htmlFor:"cursor-manual-machine-id",children:s("cursorPage.machineId")}),e.jsx(se,{id:"cursor-manual-machine-id",value:K,onChange:a=>ge(a.target.value),placeholder:s("cursorPage.machineIdPlaceholder")})]})]}),e.jsxs(is,{children:[e.jsx(f,{variant:"outline",onClick:()=>I(!1),children:s("cursorPage.cancel")}),e.jsxs(f,{onClick:Be,disabled:le,children:[le?e.jsx(_,{className:"w-4 h-4 mr-2 animate-spin"}):e.jsx(q,{className:"w-4 h-4 mr-2"}),s("cursorPage.import")]})]})]})})]})}export{Xs as CursorPage};
@@ -1,2 +1,2 @@
1
- import{j as e}from"./radix-ui-BR1vy4kf.js";import{r as M}from"./react-vendor-CNOkPC89.js";import{t as p}from"./notifications-B2HqRBj7.js";import{aY as ee,aZ as ke,B as S,d as V,c as de,b0 as Se,W as Ce,C as b,j as v,k as y,b as N,r as q,s as Y,t as W,v as G,w as k,I as ce,a as Pe,b1 as Ee,b2 as ie,b3 as Te,Q as Ae,R as Re,U as z,V as $,n as D,a_ as _e}from"./index-CsbQfRnG.js";import{a as De,u as oe,b as Oe}from"./tanstack-e99Cjjy2.js";import{aA as Be,L as X,ai as Me,m as Fe,R as Le,aB as Ie,aC as Ke,y as Ue,S as Ve,aD as ze,u as $e,v as Je,T as Qe,a5 as He,az as qe,n as le}from"./icons-kPbuhVdj.js";import{S as O}from"./separator-BBQkLglZ.js";import"./utils-CzKF5WmX.js";import"./form-utils-Cn_Uld6y.js";import"./code-highlight-BRUf_pqB.js";function Ye(s){try{const r=JSON.parse(s);return!r||typeof r!="object"||Array.isArray(r)?{settings:null,parseError:"JSON root must be an object."}:{settings:r,parseError:null}}catch(r){return{settings:null,parseError:r.message}}}async function We(){const s=await fetch(ee("/droid/diagnostics"));if(!s.ok)throw new Error("Failed to fetch Droid diagnostics");return s.json()}async function Ge(){const s=await fetch(ee("/droid/settings/raw"));if(!s.ok)throw new Error("Failed to fetch Droid raw settings");return s.json()}async function Xe(s){const r=await fetch(ee("/droid/settings/raw"),{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)});if(r.status===409)throw new ke("Droid raw settings changed externally");if(!r.ok){const n=await r.json().catch(()=>null);throw new Error(n?.error||"Failed to save Droid raw settings")}return r.json()}function Ze(){const s=De(),r=oe({queryKey:["droid-diagnostics"],queryFn:We,refetchInterval:1e4}),n=oe({queryKey:["droid-raw-settings"],queryFn:Ge}),o=Oe({mutationFn:Xe,onSuccess:(l,d)=>{s.setQueryData(["droid-raw-settings"],t=>{const a=t?.path??"~/.factory/settings.json",u=t?.resolvedPath??a,x=Ye(d.rawText);return{path:a,resolvedPath:u,exists:!0,mtime:l.mtime,rawText:d.rawText,settings:x.settings,parseError:x.parseError}}),s.invalidateQueries({queryKey:["droid-diagnostics"]})}});return M.useMemo(()=>({diagnostics:r.data,diagnosticsLoading:r.isLoading,diagnosticsError:r.error,refetchDiagnostics:r.refetch,rawSettings:n.data,rawSettingsLoading:n.isLoading,rawSettingsError:n.error,refetchRawSettings:n.refetch,saveRawSettings:o.mutate,saveRawSettingsAsync:o.mutateAsync,isSavingRawSettings:o.isPending}),[r.data,r.isLoading,r.error,r.refetch,n.data,n.isLoading,n.error,n.refetch,o.mutate,o.mutateAsync,o.isPending])}function es({title:s,pathLabel:r,loading:n,parseWarning:o,value:l,dirty:d,saving:t,saveDisabled:a,onChange:u,onSave:x,onRefresh:E}){const[T,C]=M.useState(!1),A=async()=>{l&&(await navigator.clipboard.writeText(l),C(!0),p.success(Ce.t("commonToast.settingsCopied")),window.setTimeout(()=>C(!1),1500))};return e.jsxs("div",{className:"h-full flex flex-col",children:[e.jsxs("div",{className:"p-4 border-b bg-background flex items-center justify-between gap-2",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("h2",{className:"font-semibold flex items-center gap-2",children:[e.jsx(Be,{className:"h-4 w-4 text-primary"}),s,d&&e.jsx(S,{variant:"secondary",className:"text-[10px]",children:"Unsaved"})]}),e.jsx("p",{className:"text-xs text-muted-foreground font-mono truncate",children:r})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(V,{size:"sm",onClick:x,disabled:a,children:[t?e.jsx(X,{className:"h-4 w-4 mr-1 animate-spin"}):e.jsx(Me,{className:"h-4 w-4 mr-1"}),"Save"]}),e.jsxs(V,{variant:"outline",size:"sm",onClick:A,disabled:!l,children:[e.jsx(Fe,{className:"h-4 w-4 mr-1"}),T?"Copied":"Copy"]}),e.jsx(V,{variant:"outline",size:"sm",onClick:E,children:e.jsx(Le,{className:de("h-4 w-4",n?"animate-spin":"")})})]})]}),e.jsx("div",{className:"flex-1 overflow-auto",children:n?e.jsxs("div",{className:"h-full flex items-center justify-center text-muted-foreground",children:[e.jsx(X,{className:"h-5 w-5 animate-spin mr-2"}),"Loading settings.json..."]}):e.jsxs("div",{className:"h-full flex flex-col",children:[o&&e.jsxs("div",{className:"mx-4 mt-4 rounded-md border border-amber-300 bg-amber-50 px-3 py-2 text-sm text-amber-800 dark:bg-amber-950/20 dark:text-amber-300",children:["Parse warning: ",o]}),e.jsx("div",{className:"flex-1 p-4 pt-3",children:e.jsx("div",{className:"h-full rounded-md border overflow-hidden bg-background",children:e.jsx(Se,{value:l,onChange:u,language:"json",minHeight:"100%"})})})]})})]})}const ss=["customModels","custom_models"],rs={low:4e3,medium:12e3,high:3e4,max:5e4,xhigh:64e3},ts=["low","medium","high","max","xhigh"];function h(s){return typeof s=="object"&&s!==null&&!Array.isArray(s)}function j(s){return typeof s=="string"&&s.trim()?s.trim():null}function F(s){return typeof s=="number"&&Number.isFinite(s)?s:null}function Z(s){if(!s)return"unknown";const r=s.toLowerCase();return r==="anthropic"?"anthropic":r==="openai"?"openai":r==="generic-chat-completion-api"?"generic-chat-completion-api":"unknown"}function ns(s,r,n){return`${s}:${r}:${encodeURIComponent(String(n))}`}function as(s){const r=s.indexOf(":"),n=s.indexOf(":",r+1);if(r<=0||n<=r+1)return null;const o=s.slice(0,r),l=s.slice(r+1,n),d=s.slice(n+1);if(o!=="customModels"&&o!=="custom_models"||l!=="array"&&l!=="object")return null;const t=decodeURIComponent(d);if(l==="array"){const a=Number.parseInt(t,10);return!Number.isInteger(a)||a<0?null:{rootKey:o,locationType:l,locationKey:a}}return{rootKey:o,locationType:l,locationKey:t}}function is(s){return!s||s<=0?null:s<=4e3?"low":s<=12e3?"medium":s<=3e4?"high":s<=5e4?"max":"xhigh"}function os(s){return Object.prototype.hasOwnProperty.call(s,"extraArgs")?"extraArgs":Object.prototype.hasOwnProperty.call(s,"extra_args")?"extra_args":"extraArgs"}function ue(s){return JSON.parse(JSON.stringify(s))}function ls(s){const r=[];for(const n of ss){const o=s[n];if(Array.isArray(o)){o.forEach((l,d)=>{h(l)&&r.push({rootKey:n,locationType:"array",locationKey:d,entry:l})});continue}if(h(o))for(const[l,d]of Object.entries(o))h(d)&&r.push({rootKey:n,locationType:"object",locationKey:l,entry:d})}return r}function me(s,r){const n=as(r);if(!n)return null;const o=s[n.rootKey];if(n.locationType==="array"){if(!Array.isArray(o))return null;const t=o[n.locationKey];if(!h(t))return null;const a=j(t.provider);return{entry:t,providerKind:Z(a)}}if(!h(o))return null;const l=o[n.locationKey];if(!h(l))return null;const d=j(l.provider);return{entry:l,providerKind:Z(d)}}function ds(s,r){const n=r.extraArgs??r.extra_args,o=h(n)?n:null;if(!o)return{effort:null,anthropicBudgetTokens:null};const l=j(o.reasoning_effort)??j(o.reasoningEffort),d=h(o.reasoning)?o.reasoning:null,t=d?j(d.effort):null,a=h(o.thinking)?o.thinking:null,u=a?j(a.type):null,x=a?F(a.budget_tokens)??F(a.budgetTokens):null;return s==="openai"?{effort:t??l,anthropicBudgetTokens:null}:s==="anthropic"?u==="enabled"?{effort:is(x)??"high",anthropicBudgetTokens:x}:{effort:t??l,anthropicBudgetTokens:x}:{effort:l??t,anthropicBudgetTokens:null}}function cs(s){if(!s)return null;const r=s.trim().toLowerCase();return!r||r==="default"||r==="unset"||r==="off"||r==="none"||r==="disabled"?null:r}function xe(s){const r=os(s),n=s[r],o=h(n)?{...n}:{};return{extraArgsKey:r,extraArgs:o}}function ge(s,r,n){if(Object.keys(n).length===0){delete s[r];return}s[r]=n}function us(s){return ls(s).map(({rootKey:r,locationType:n,locationKey:o,entry:l})=>{const d=j(l.displayName)??j(l.model_display_name)??"Unnamed model",t=j(l.model)??"",a=j(l.provider)??"unknown",u=Z(a),x=ds(u,l);return{id:ns(r,n,o),rootKey:r,locationType:n,locationKey:o,displayName:d,model:t,provider:a,providerKind:u,effort:x.effort,anthropicBudgetTokens:x.anthropicBudgetTokens}})}function ms(s,r,n){const o=ue(s),l=me(o,r);if(!l)return null;const d=cs(n),{extraArgsKey:t,extraArgs:a}=xe(l.entry);if(l.providerKind==="openai")if(delete a.reasoning_effort,delete a.reasoningEffort,!d)delete a.reasoning;else{const u=h(a.reasoning)?a.reasoning:{};a.reasoning={...u,effort:d}}else if(l.providerKind==="anthropic")if(delete a.reasoning_effort,delete a.reasoningEffort,delete a.reasoning,!d)delete a.thinking;else{const u=h(a.thinking)?{...a.thinking}:{},x=F(u.budget_tokens)??F(u.budgetTokens);delete u.budgetTokens,a.thinking={...u,type:"enabled",budget_tokens:x??rs[d]??3e4}}else delete a.reasoning,delete a.reasoningEffort,d?a.reasoning_effort=d:delete a.reasoning_effort;return ge(l.entry,t,a),o}function xs(s,r,n){const o=ue(s),l=me(o,r);if(!l||l.providerKind!=="anthropic")return null;const{extraArgsKey:d,extraArgs:t}=xe(l.entry),a=h(t.thinking)?{...t.thinking}:{};if(a.type="enabled",n===null)delete a.budget_tokens,delete a.budgetTokens;else{const u=Math.max(1024,Math.floor(n));a.budget_tokens=u,delete a.budgetTokens}return t.thinking=a,ge(l.entry,d,t),o}const J="__unset__";function gs(s){return s.providerKind==="openai"?"Writes: extraArgs.reasoning.effort":s.providerKind==="anthropic"?"Writes: extraArgs.thinking.{type,budget_tokens}":"Writes: extraArgs.reasoning_effort"}function fs({models:s,disabled:r,disabledReason:n,onEffortChange:o,onAnthropicBudgetChange:l}){return e.jsxs(b,{children:[e.jsx(v,{className:"pb-2",children:e.jsxs(y,{className:"text-base flex items-center gap-2",children:[e.jsx(Ie,{className:"h-4 w-4"}),"BYOK Reasoning / Thinking",e.jsx(S,{variant:"outline",className:"text-[10px] font-normal",children:"customModels"})]})}),e.jsxs(N,{className:"space-y-3",children:[n&&e.jsx("p",{className:"text-xs text-amber-600",children:n}),s.length===0?e.jsx("p",{className:"text-xs text-muted-foreground",children:"No BYOK custom models found in settings.json (`customModels` or `custom_models`)."}):e.jsx("div",{className:"space-y-2",children:s.map(d=>e.jsxs("div",{className:"rounded-md border p-3 space-y-2",children:[e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-xs font-medium truncate",children:d.displayName}),e.jsx("p",{className:"text-[11px] font-mono text-muted-foreground truncate",children:d.model||"(missing model id)"})]}),e.jsx(S,{variant:"outline",className:"font-mono text-[10px] shrink-0",children:d.provider})]}),e.jsxs("div",{className:"grid gap-2 sm:grid-cols-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-[11px] font-medium",children:"Reasoning Effort"}),e.jsxs(q,{value:d.effort??J,onValueChange:t=>o(d.id,t===J?null:t),disabled:r,children:[e.jsx(Y,{className:"h-8 text-xs",children:e.jsx(W,{placeholder:"Use provider default"})}),e.jsxs(G,{children:[e.jsx(k,{value:J,children:"Use provider default"}),ts.map(t=>e.jsx(k,{value:t,children:t},t))]})]})]}),d.providerKind==="anthropic"&&e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-[11px] font-medium",children:"Thinking Budget Tokens"}),e.jsx(ce,{type:"number",min:1024,step:1024,value:d.anthropicBudgetTokens??"",placeholder:"auto",className:"h-8 text-xs",disabled:r,onChange:t=>{const a=t.target.value.trim();if(!a){l(d.id,null);return}const u=Number.parseInt(a,10);Number.isFinite(u)&&l(d.id,Math.max(1024,u))}})]})]}),e.jsx("p",{className:"text-[11px] text-muted-foreground",children:gs(d)})]},d.id))})]})]})}const _="__unset__",hs=[{key:"reasoningEffort",label:"Reasoning Effort",description:"none | medium | high | max",options:[{value:"none",label:"none"},{value:"medium",label:"medium"},{value:"high",label:"high"},{value:"max",label:"max"}]},{key:"autonomyLevel",label:"Autonomy Level",description:"suggest | aggressive | full",options:[{value:"suggest",label:"suggest"},{value:"aggressive",label:"aggressive"},{value:"full",label:"full"}]},{key:"diffMode",label:"Diff Mode",description:"auto | none | inline | split",options:[{value:"auto",label:"auto"},{value:"none",label:"none"},{value:"inline",label:"inline"},{value:"split",label:"split"}]}],ps=[{key:"todoEnabled",label:"Todo Enabled"},{key:"todoAutoRefresh",label:"Todo Auto Refresh"},{key:"autoCompactEnabled",label:"Auto Compact Enabled"},{key:"soundEnabled",label:"Sound Enabled"}],js=[{key:"maxTurns",label:"Max Turns",min:1,step:1},{key:"maxToolCalls",label:"Max Tool Calls",min:1,step:1},{key:"autoCompactThreshold",label:"Auto Compact Threshold",min:1e3,step:1e3}];function bs(s){return s===!0?"true":s===!1?"false":_}function vs(s){return s==="true"?!0:s==="false"?!1:null}function ys({values:s,disabled:r,disabledReason:n,onEnumSettingChange:o,onBooleanSettingChange:l,onNumberSettingChange:d}){return e.jsxs(b,{children:[e.jsx(v,{className:"pb-2",children:e.jsxs(y,{className:"text-base flex items-center gap-2",children:[e.jsx(Ke,{className:"h-4 w-4"}),"Quick Settings",e.jsx(S,{variant:"outline",className:"text-[10px] font-normal",children:"settings.json"})]})}),e.jsxs(N,{className:"space-y-4",children:[n&&e.jsx("p",{className:"text-xs text-amber-600",children:n}),e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[hs.map(t=>e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs font-medium",children:t.label}),e.jsxs(q,{value:s[t.key]??_,onValueChange:a=>o(t.key,a===_?null:a),disabled:r,children:[e.jsx(Y,{className:"h-8 text-xs",children:e.jsx(W,{placeholder:"Use default"})}),e.jsxs(G,{children:[e.jsx(k,{value:_,children:"Use default"}),t.options.map(a=>e.jsx(k,{value:a.value,children:a.label},a.value))]})]}),e.jsx("p",{className:"text-[11px] text-muted-foreground",children:t.description})]},t.key)),js.map(t=>e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs font-medium",children:t.label}),e.jsx(ce,{type:"number",min:t.min,step:t.step,value:s[t.key]??"",onChange:a=>{const u=a.target.value.trim();if(!u){d(t.key,null);return}const x=Number.parseInt(u,10);Number.isFinite(x)&&d(t.key,Math.max(t.min,x))},className:"h-8 text-xs",disabled:r})]},t.key)),ps.map(t=>e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs font-medium",children:t.label}),e.jsxs(q,{value:bs(s[t.key]),onValueChange:a=>l(t.key,vs(a)),disabled:r,children:[e.jsx(Y,{className:"h-8 text-xs",children:e.jsx(W,{placeholder:"Use default"})}),e.jsxs(G,{children:[e.jsx(k,{value:_,children:"Use default"}),e.jsx(k,{value:"true",children:"true"}),e.jsx(k,{value:"false",children:"false"})]})]})]},t.key))]})]})]})}const Ns=[{id:"droid-cli-overview",label:"Droid CLI Overview",url:"https://docs.factory.ai/cli/",description:"Primary entry docs for setup, auth, and core CLI usage."},{id:"droid-byok-overview",label:"BYOK Overview",url:"https://docs.factory.ai/cli/byok/overview/",description:"BYOK model/provider shape, provider values, and migration notes."},{id:"droid-settings-reference",label:"settings.json Reference",url:"https://docs.factory.ai/cli/configuration/settings/",description:"Supported settings keys, defaults, and allowed values."}],ws=[{provider:"anthropic",label:"Anthropic Messages API",apiFormat:"Messages API",url:"https://docs.anthropic.com/en/api/messages"},{provider:"openai",label:"OpenAI Responses API",apiFormat:"Responses API",url:"https://platform.openai.com/docs/api-reference/responses"},{provider:"generic-chat-completion-api",label:"OpenAI Chat Completions Spec",apiFormat:"Chat Completions API",url:"https://platform.openai.com/docs/api-reference/chat"}];function ks(s){const r=/https?:\/\/[^\s)]+/g,n=[];let o=0,l;for(;(l=r.exec(s))!==null;){const[d]=l,t=l.index;t>o&&n.push(s.slice(o,t)),n.push(e.jsx("a",{href:d,target:"_blank",rel:"noreferrer",className:"underline underline-offset-2 hover:text-foreground",children:d},`${d}-${t}`)),o=t+d.length}return o<s.length&&n.push(s.slice(o)),n.length>0?n:[s]}function Ss(s){return!s||!Number.isFinite(s)?"N/A":new Date(s).toLocaleString()}function Cs(s){return!s||s<=0?"0 B":s<1024?`${s} B`:s<1024*1024?`${(s/1024).toFixed(1)} KB`:`${(s/(1024*1024)).toFixed(2)} MB`}function Ps(s){try{const r=JSON.parse(s);return!r||typeof r!="object"||Array.isArray(r)?{valid:!1,error:"JSON root must be an object."}:{valid:!0,value:r}}catch(r){return{valid:!1,error:r.message}}}function Q(s){return typeof s=="string"?s:null}function H(s){return typeof s=="number"&&Number.isFinite(s)?s:null}function B(s){return typeof s=="boolean"?s:null}function g({label:s,value:r,mono:n=!1}){return e.jsxs("div",{className:"flex items-start justify-between gap-3 text-sm",children:[e.jsx("span",{className:"text-muted-foreground shrink-0",children:s}),e.jsx("span",{className:de("text-right break-all",n&&"font-mono text-xs"),children:r})]})}function Ls(){const{t:s}=Pe(),{diagnostics:r,diagnosticsLoading:n,diagnosticsError:o,refetchDiagnostics:l,rawSettings:d,rawSettingsLoading:t,refetchRawSettings:a,saveRawSettingsAsync:u,isSavingRawSettings:x}=Ze(),[E,T]=M.useState(null),C=d?.rawText??"{}",A=E??C,se=E!==null&&E!==C,c=Ps(A),L=c.valid?{valid:!0}:{valid:!1,error:c.error},re=m=>{if(m===C){T(null);return}T(m)},I=m=>{re(JSON.stringify(m,null,2)+`
2
- `)},K=(m,w)=>{if(!c.valid){p.error(s("droidPage.fixJsonBeforeQuickSettings"));return}const P={...c.value};w==null?delete P[m]:P[m]=w,I(P)},fe=c.valid?{reasoningEffort:Q(c.value.reasoningEffort),autonomyLevel:Q(c.value.autonomyLevel),diffMode:Q(c.value.diffMode),maxTurns:H(c.value.maxTurns),maxToolCalls:H(c.value.maxToolCalls),autoCompactThreshold:H(c.value.autoCompactThreshold),todoEnabled:B(c.value.todoEnabled),todoAutoRefresh:B(c.value.todoAutoRefresh),autoCompactEnabled:B(c.value.autoCompactEnabled),soundEnabled:B(c.value.soundEnabled)}:{reasoningEffort:null,autonomyLevel:null,diffMode:null,maxTurns:null,maxToolCalls:null,autoCompactThreshold:null,todoEnabled:null,todoAutoRefresh:null,autoCompactEnabled:null,soundEnabled:null},he=c.valid?us(c.value):[],pe=async()=>{await Promise.all([l(),a()])},je=async()=>{if(!L.valid){p.error(s("droidPage.invalidJson",{value:L.error}));return}try{await u({rawText:A,expectedMtime:d?.exists?d.mtime:void 0}),T(null),p.success(s("droidPage.saved"))}catch(m){_e(m)?p.error(s("droidPage.changedExternally")):p.error(m.message||s("droidPage.failedSave"))}},te=r?.byok.customModels??[],ne=M.useMemo(()=>Object.entries(r?.byok.providerBreakdown??{}).sort((m,w)=>w[1]-m[1]),[r?.byok.providerBreakdown]),be=()=>{if(n)return e.jsxs("div",{className:"flex h-full items-center justify-center text-muted-foreground",children:[e.jsx(X,{className:"h-5 w-5 animate-spin mr-2"}),s("droidPage.loadingDiagnostics")]});if(o||!r)return e.jsx("div",{className:"flex h-full items-center justify-center text-destructive px-6 text-center",children:s("droidPage.failedDiagnostics")});const m=r.docsReference??{notes:[],links:[],providerDocs:[],providerValues:[],settingsHierarchy:[]},w=m.notes??[],P=m.links??[],ae=m.providerDocs??[],ve=P.length>0?P:Ns,ye=ae.length>0?ae:ws,Ne=m.providerValues??[],we=m.settingsHierarchy??[],U="mt-0 h-full border-0 p-0 data-[state=inactive]:hidden";return e.jsxs(Ae,{defaultValue:"byok",className:"h-full flex flex-col",children:[e.jsx("div",{className:"px-4 pt-4 shrink-0",children:e.jsxs(Re,{className:"grid w-full grid-cols-3",children:[e.jsx(z,{value:"overview",children:s("droidPage.overview")}),e.jsx(z,{value:"byok",children:s("droidPage.byok")}),e.jsx(z,{value:"docs",children:s("droidPage.docs")})]})}),e.jsxs("div",{className:"flex-1 min-h-0 overflow-hidden px-4 pb-4 pt-3",children:[e.jsx($,{value:"overview",className:U,children:e.jsx(D,{className:"h-full",children:e.jsxs("div",{className:"space-y-4 pr-1",children:[e.jsxs(b,{children:[e.jsx(v,{className:"pb-2",children:e.jsxs(y,{className:"text-base flex items-center gap-2",children:[e.jsx(Ve,{className:"h-4 w-4"}),s("droidPage.runtimeInstall")]})}),e.jsxs(N,{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-sm text-muted-foreground",children:s("droidPage.status")}),e.jsx(S,{variant:r.binary.installed?"default":"secondary",children:r.binary.installed?s("droidPage.detected"):s("droidPage.notFound")})]}),e.jsx(g,{label:s("droidPage.detectionSource"),value:r.binary.source,mono:!0}),e.jsx(g,{label:s("droidPage.binaryPath"),value:r.binary.path||s("droidPage.notFound"),mono:!0}),e.jsx(g,{label:s("droidPage.installDirectory"),value:r.binary.installDir||"N/A",mono:!0}),e.jsx(g,{label:s("droidPage.version"),value:r.binary.version||"Unknown",mono:!0}),e.jsx(g,{label:s("droidPage.overridePath"),value:r.binary.overridePath||"Not set",mono:!0})]})]}),e.jsxs(b,{children:[e.jsx(v,{className:"pb-2",children:e.jsxs(y,{className:"text-base flex items-center gap-2",children:[e.jsx(ze,{className:"h-4 w-4"}),s("droidPage.configFiles")]})}),e.jsx(N,{className:"space-y-3",children:[r.files.settings,r.files.legacyConfig].map(i=>e.jsxs("div",{className:"rounded-md border p-3 space-y-1.5",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("span",{className:"font-medium text-sm",children:i.label}),i.exists?e.jsx($e,{className:"h-4 w-4 text-green-600"}):e.jsx(Je,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsx(g,{label:s("droidPage.path"),value:i.path,mono:!0}),e.jsx(g,{label:s("droidPage.resolved"),value:i.resolvedPath,mono:!0}),e.jsx(g,{label:s("droidPage.size"),value:Cs(i.sizeBytes)}),e.jsx(g,{label:s("droidPage.lastModified"),value:Ss(i.mtimeMs)}),i.parseError&&e.jsx("p",{className:"text-xs text-amber-600",children:s("droidPage.parseWarning",{value:i.parseError})}),i.readError&&e.jsx("p",{className:"text-xs text-destructive",children:s("droidPage.readWarning",{value:i.readError})})]},i.label))})]}),r.warnings.length>0&&e.jsxs(b,{className:"border-amber-200 bg-amber-50/50 dark:bg-amber-950/20",children:[e.jsx(v,{className:"pb-2",children:e.jsxs(y,{className:"text-base flex items-center gap-2",children:[e.jsx(Qe,{className:"h-4 w-4 text-amber-600"}),s("droidPage.warnings")]})}),e.jsx(N,{className:"space-y-1.5",children:r.warnings.map(i=>e.jsxs("p",{className:"text-sm text-amber-800 dark:text-amber-300",children:["- ",i]},i))})]})]})})}),e.jsx($,{value:"byok",className:U,children:e.jsx(D,{className:"h-full",children:e.jsxs("div",{className:"space-y-4 pr-1",children:[e.jsx(ys,{values:fe,disabled:t||!c.valid,disabledReason:c.valid?null:`Quick settings disabled: ${c.error}`,onEnumSettingChange:(i,f)=>{K(i,f)},onBooleanSettingChange:(i,f)=>{K(i,f)},onNumberSettingChange:(i,f)=>{K(i,f)}}),e.jsx(fs,{models:he,disabled:t||!c.valid,disabledReason:c.valid?null:`${s("droidPage.byok")}: ${c.error}`,onEffortChange:(i,f)=>{if(!c.valid){p.error(s("droidPage.fixJsonBeforeReasoning"));return}const R=ms(c.value,i,f);if(!R){p.error(s("droidPage.unableUpdateReasoning"));return}I(R)},onAnthropicBudgetChange:(i,f)=>{if(!c.valid){p.error(s("droidPage.fixJsonBeforeBudget"));return}const R=xs(c.value,i,f);if(!R){p.error(s("droidPage.anthropicOnlyBudget"));return}I(R)}}),e.jsxs(b,{children:[e.jsx(v,{className:"pb-2",children:e.jsxs(y,{className:"text-base flex items-center gap-2",children:[e.jsx(He,{className:"h-4 w-4"}),s("droidPage.byokSummary")]})}),e.jsxs(N,{className:"space-y-2",children:[e.jsx(g,{label:s("droidPage.activeModelSelector"),value:r.byok.activeModelSelector||"Not set",mono:!0}),e.jsx(g,{label:s("droidPage.customModels"),value:String(r.byok.customModelCount)}),e.jsx(g,{label:s("droidPage.ccsManaged"),value:String(r.byok.ccsManagedCount)}),e.jsx(g,{label:s("droidPage.userManaged"),value:String(r.byok.userManagedCount)}),e.jsx(g,{label:s("droidPage.malformedEntries"),value:String(r.byok.invalidModelEntryCount)}),e.jsx(O,{}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:s("droidPage.providers")}),e.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[ne.length===0&&e.jsx(S,{variant:"secondary",className:"font-mono",children:s("droidPage.none")}),ne.map(([i,f])=>e.jsxs(S,{variant:"outline",className:"font-mono text-xs",children:[i,": ",f]},i))]})]})]})]}),e.jsxs(b,{children:[e.jsx(v,{className:"pb-2",children:e.jsx(y,{className:"text-base",children:s("droidPage.customModelsTitle")})}),e.jsx(N,{children:e.jsxs("div",{className:"rounded-md border overflow-hidden",children:[e.jsxs("div",{className:"grid grid-cols-[2fr_1fr_2fr] bg-muted/40 px-3 py-2 text-xs font-medium",children:[e.jsx("span",{children:s("droidPage.modelName")}),e.jsx("span",{children:s("droidPage.provider")}),e.jsx("span",{children:s("droidPage.baseUrl")})]}),e.jsx(D,{className:"h-52",children:e.jsxs("div",{className:"divide-y",children:[te.length===0&&e.jsx("div",{className:"px-3 py-4 text-xs text-muted-foreground",children:s("droidPage.noCustomModels")}),te.map(i=>e.jsxs("div",{className:"grid grid-cols-[2fr_1fr_2fr] gap-2 px-3 py-2 text-xs",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"font-medium truncate",children:i.displayName}),e.jsx("p",{className:"text-muted-foreground font-mono truncate",children:i.model})]}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"truncate",children:i.provider}),e.jsx("p",{className:"text-muted-foreground",children:i.apiKeyPreview||"no-key"})]}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"truncate",title:i.baseUrl,children:i.host||i.baseUrl}),e.jsx("p",{className:"text-muted-foreground font-mono truncate",children:i.baseUrl})]})]},`${i.displayName}-${i.model}-${i.baseUrl}`))]})})]})})]})]})})}),e.jsx($,{value:"docs",className:U,children:e.jsx(D,{className:"h-full",children:e.jsx("div",{className:"space-y-4 pr-1",children:e.jsxs(b,{children:[e.jsx(v,{className:"pb-2",children:e.jsxs(y,{className:"text-base flex items-center gap-2",children:[e.jsx(qe,{className:"h-4 w-4"}),s("droidPage.docsAlignedNotes")]})}),e.jsxs(N,{className:"space-y-2 text-sm",children:[w.map((i,f)=>e.jsxs("p",{className:"text-muted-foreground",children:["- ",ks(i)]},`${f}-${i}`)),e.jsx(O,{}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-xs text-muted-foreground uppercase tracking-wide",children:s("droidPage.factoryDocs")}),e.jsx("div",{className:"space-y-1.5",children:ve.map(i=>e.jsxs("a",{href:i.url,target:"_blank",rel:"noreferrer",className:"block rounded-md border px-2.5 py-2 transition-colors hover:bg-muted/50",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("span",{className:"text-xs font-medium",children:i.label}),e.jsx(le,{className:"h-3.5 w-3.5 text-muted-foreground"})]}),e.jsx("p",{className:"mt-0.5 text-[11px] text-muted-foreground",children:i.description}),e.jsx("p",{className:"mt-1 break-all font-mono text-[11px] text-muted-foreground/90 underline underline-offset-2",children:i.url})]},i.id))})]}),e.jsx(O,{}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-xs text-muted-foreground uppercase tracking-wide",children:s("droidPage.providerFactCheckDocs")}),e.jsx("div",{className:"space-y-1.5",children:ye.map(i=>e.jsxs("a",{href:i.url,target:"_blank",rel:"noreferrer",className:"block rounded-md border px-2.5 py-2 transition-colors hover:bg-muted/50",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("span",{className:"text-xs font-medium",children:i.label}),e.jsx(le,{className:"h-3.5 w-3.5 text-muted-foreground"})]}),e.jsxs("p",{className:"mt-0.5 text-[11px] text-muted-foreground",children:["provider: ",i.provider," | format: ",i.apiFormat]}),e.jsx("p",{className:"mt-1 break-all font-mono text-[11px] text-muted-foreground/90 underline underline-offset-2",children:i.url})]},`${i.provider}-${i.url}`))})]}),e.jsx(O,{}),e.jsx("p",{className:"text-xs text-muted-foreground",children:s("droidPage.providerValues",{value:Ne.join(", ")})}),e.jsx("p",{className:"text-xs text-muted-foreground",children:s("droidPage.settingsHierarchy",{value:we.join(" -> ")})})]})]})})})})]})]})};return e.jsx("div",{className:"h-[calc(100vh-100px)] overflow-hidden",children:e.jsxs(Ee,{direction:"horizontal",className:"h-full",children:[e.jsx(ie,{defaultSize:45,minSize:35,children:e.jsx("div",{className:"h-full border-r bg-muted/20",children:be()})}),e.jsx(Te,{className:"w-2 bg-border hover:bg-primary/20 transition-colors cursor-col-resize flex items-center justify-center group",children:e.jsx(Ue,{className:"w-3 h-3 text-muted-foreground group-hover:text-primary"})}),e.jsx(ie,{defaultSize:55,minSize:35,children:e.jsx(es,{title:s("droidPage.settingsTitle"),pathLabel:d?.path||"~/.factory/settings.json",loading:t,parseWarning:d?.parseError,value:A,dirty:se,saving:x,saveDisabled:!se||x||t||!L.valid,onChange:m=>{re(m)},onSave:je,onRefresh:pe})})]})})}export{Ls as DroidPage};
1
+ import{j as e}from"./radix-ui-BR1vy4kf.js";import{r as M}from"./react-vendor-CNOkPC89.js";import{t as p}from"./notifications-B2HqRBj7.js";import{aY as ee,aZ as ke,B as S,d as V,c as de,b0 as Se,W as Ce,C as b,j as v,k as y,b as N,r as q,s as Y,t as W,v as G,w as k,I as ce,a as Ee,b1 as Pe,b2 as ie,b3 as Te,Q as Ae,R as Re,U as z,V as $,n as D,a_ as _e}from"./index-DCQkhmoo.js";import{a as De,u as oe,b as Oe}from"./tanstack-e99Cjjy2.js";import{aB as Be,L as X,ai as Me,m as Fe,R as Le,aC as Ie,aD as Ke,y as Ue,S as Ve,aE as ze,u as $e,v as Je,T as Qe,a5 as He,aA as qe,n as le}from"./icons-BYZM_9Gm.js";import{S as O}from"./separator-DtcqgZIS.js";import"./utils-CzKF5WmX.js";import"./form-utils-Cn_Uld6y.js";import"./code-highlight-BRUf_pqB.js";function Ye(s){try{const r=JSON.parse(s);return!r||typeof r!="object"||Array.isArray(r)?{settings:null,parseError:"JSON root must be an object."}:{settings:r,parseError:null}}catch(r){return{settings:null,parseError:r.message}}}async function We(){const s=await fetch(ee("/droid/diagnostics"));if(!s.ok)throw new Error("Failed to fetch Droid diagnostics");return s.json()}async function Ge(){const s=await fetch(ee("/droid/settings/raw"));if(!s.ok)throw new Error("Failed to fetch Droid raw settings");return s.json()}async function Xe(s){const r=await fetch(ee("/droid/settings/raw"),{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)});if(r.status===409)throw new ke("Droid raw settings changed externally");if(!r.ok){const n=await r.json().catch(()=>null);throw new Error(n?.error||"Failed to save Droid raw settings")}return r.json()}function Ze(){const s=De(),r=oe({queryKey:["droid-diagnostics"],queryFn:We,refetchInterval:1e4}),n=oe({queryKey:["droid-raw-settings"],queryFn:Ge}),o=Oe({mutationFn:Xe,onSuccess:(l,d)=>{s.setQueryData(["droid-raw-settings"],t=>{const a=t?.path??"~/.factory/settings.json",u=t?.resolvedPath??a,x=Ye(d.rawText);return{path:a,resolvedPath:u,exists:!0,mtime:l.mtime,rawText:d.rawText,settings:x.settings,parseError:x.parseError}}),s.invalidateQueries({queryKey:["droid-diagnostics"]})}});return M.useMemo(()=>({diagnostics:r.data,diagnosticsLoading:r.isLoading,diagnosticsError:r.error,refetchDiagnostics:r.refetch,rawSettings:n.data,rawSettingsLoading:n.isLoading,rawSettingsError:n.error,refetchRawSettings:n.refetch,saveRawSettings:o.mutate,saveRawSettingsAsync:o.mutateAsync,isSavingRawSettings:o.isPending}),[r.data,r.isLoading,r.error,r.refetch,n.data,n.isLoading,n.error,n.refetch,o.mutate,o.mutateAsync,o.isPending])}function es({title:s,pathLabel:r,loading:n,parseWarning:o,value:l,dirty:d,saving:t,saveDisabled:a,onChange:u,onSave:x,onRefresh:P}){const[T,C]=M.useState(!1),A=async()=>{l&&(await navigator.clipboard.writeText(l),C(!0),p.success(Ce.t("commonToast.settingsCopied")),window.setTimeout(()=>C(!1),1500))};return e.jsxs("div",{className:"h-full flex flex-col",children:[e.jsxs("div",{className:"p-4 border-b bg-background flex items-center justify-between gap-2",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("h2",{className:"font-semibold flex items-center gap-2",children:[e.jsx(Be,{className:"h-4 w-4 text-primary"}),s,d&&e.jsx(S,{variant:"secondary",className:"text-[10px]",children:"Unsaved"})]}),e.jsx("p",{className:"text-xs text-muted-foreground font-mono truncate",children:r})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(V,{size:"sm",onClick:x,disabled:a,children:[t?e.jsx(X,{className:"h-4 w-4 mr-1 animate-spin"}):e.jsx(Me,{className:"h-4 w-4 mr-1"}),"Save"]}),e.jsxs(V,{variant:"outline",size:"sm",onClick:A,disabled:!l,children:[e.jsx(Fe,{className:"h-4 w-4 mr-1"}),T?"Copied":"Copy"]}),e.jsx(V,{variant:"outline",size:"sm",onClick:P,children:e.jsx(Le,{className:de("h-4 w-4",n?"animate-spin":"")})})]})]}),e.jsx("div",{className:"flex-1 overflow-auto",children:n?e.jsxs("div",{className:"h-full flex items-center justify-center text-muted-foreground",children:[e.jsx(X,{className:"h-5 w-5 animate-spin mr-2"}),"Loading settings.json..."]}):e.jsxs("div",{className:"h-full flex flex-col",children:[o&&e.jsxs("div",{className:"mx-4 mt-4 rounded-md border border-amber-300 bg-amber-50 px-3 py-2 text-sm text-amber-800 dark:bg-amber-950/20 dark:text-amber-300",children:["Parse warning: ",o]}),e.jsx("div",{className:"flex-1 p-4 pt-3",children:e.jsx("div",{className:"h-full rounded-md border overflow-hidden bg-background",children:e.jsx(Se,{value:l,onChange:u,language:"json",minHeight:"100%"})})})]})})]})}const ss=["customModels","custom_models"],rs={low:4e3,medium:12e3,high:3e4,max:5e4,xhigh:64e3},ts=["low","medium","high","max","xhigh"];function h(s){return typeof s=="object"&&s!==null&&!Array.isArray(s)}function j(s){return typeof s=="string"&&s.trim()?s.trim():null}function F(s){return typeof s=="number"&&Number.isFinite(s)?s:null}function Z(s){if(!s)return"unknown";const r=s.toLowerCase();return r==="anthropic"?"anthropic":r==="openai"?"openai":r==="generic-chat-completion-api"?"generic-chat-completion-api":"unknown"}function ns(s,r,n){return`${s}:${r}:${encodeURIComponent(String(n))}`}function as(s){const r=s.indexOf(":"),n=s.indexOf(":",r+1);if(r<=0||n<=r+1)return null;const o=s.slice(0,r),l=s.slice(r+1,n),d=s.slice(n+1);if(o!=="customModels"&&o!=="custom_models"||l!=="array"&&l!=="object")return null;const t=decodeURIComponent(d);if(l==="array"){const a=Number.parseInt(t,10);return!Number.isInteger(a)||a<0?null:{rootKey:o,locationType:l,locationKey:a}}return{rootKey:o,locationType:l,locationKey:t}}function is(s){return!s||s<=0?null:s<=4e3?"low":s<=12e3?"medium":s<=3e4?"high":s<=5e4?"max":"xhigh"}function os(s){return Object.prototype.hasOwnProperty.call(s,"extraArgs")?"extraArgs":Object.prototype.hasOwnProperty.call(s,"extra_args")?"extra_args":"extraArgs"}function ue(s){return JSON.parse(JSON.stringify(s))}function ls(s){const r=[];for(const n of ss){const o=s[n];if(Array.isArray(o)){o.forEach((l,d)=>{h(l)&&r.push({rootKey:n,locationType:"array",locationKey:d,entry:l})});continue}if(h(o))for(const[l,d]of Object.entries(o))h(d)&&r.push({rootKey:n,locationType:"object",locationKey:l,entry:d})}return r}function me(s,r){const n=as(r);if(!n)return null;const o=s[n.rootKey];if(n.locationType==="array"){if(!Array.isArray(o))return null;const t=o[n.locationKey];if(!h(t))return null;const a=j(t.provider);return{entry:t,providerKind:Z(a)}}if(!h(o))return null;const l=o[n.locationKey];if(!h(l))return null;const d=j(l.provider);return{entry:l,providerKind:Z(d)}}function ds(s,r){const n=r.extraArgs??r.extra_args,o=h(n)?n:null;if(!o)return{effort:null,anthropicBudgetTokens:null};const l=j(o.reasoning_effort)??j(o.reasoningEffort),d=h(o.reasoning)?o.reasoning:null,t=d?j(d.effort):null,a=h(o.thinking)?o.thinking:null,u=a?j(a.type):null,x=a?F(a.budget_tokens)??F(a.budgetTokens):null;return s==="openai"?{effort:t??l,anthropicBudgetTokens:null}:s==="anthropic"?u==="enabled"?{effort:is(x)??"high",anthropicBudgetTokens:x}:{effort:t??l,anthropicBudgetTokens:x}:{effort:l??t,anthropicBudgetTokens:null}}function cs(s){if(!s)return null;const r=s.trim().toLowerCase();return!r||r==="default"||r==="unset"||r==="off"||r==="none"||r==="disabled"?null:r}function xe(s){const r=os(s),n=s[r],o=h(n)?{...n}:{};return{extraArgsKey:r,extraArgs:o}}function ge(s,r,n){if(Object.keys(n).length===0){delete s[r];return}s[r]=n}function us(s){return ls(s).map(({rootKey:r,locationType:n,locationKey:o,entry:l})=>{const d=j(l.displayName)??j(l.model_display_name)??"Unnamed model",t=j(l.model)??"",a=j(l.provider)??"unknown",u=Z(a),x=ds(u,l);return{id:ns(r,n,o),rootKey:r,locationType:n,locationKey:o,displayName:d,model:t,provider:a,providerKind:u,effort:x.effort,anthropicBudgetTokens:x.anthropicBudgetTokens}})}function ms(s,r,n){const o=ue(s),l=me(o,r);if(!l)return null;const d=cs(n),{extraArgsKey:t,extraArgs:a}=xe(l.entry);if(l.providerKind==="openai")if(delete a.reasoning_effort,delete a.reasoningEffort,!d)delete a.reasoning;else{const u=h(a.reasoning)?a.reasoning:{};a.reasoning={...u,effort:d}}else if(l.providerKind==="anthropic")if(delete a.reasoning_effort,delete a.reasoningEffort,delete a.reasoning,!d)delete a.thinking;else{const u=h(a.thinking)?{...a.thinking}:{},x=F(u.budget_tokens)??F(u.budgetTokens);delete u.budgetTokens,a.thinking={...u,type:"enabled",budget_tokens:x??rs[d]??3e4}}else delete a.reasoning,delete a.reasoningEffort,d?a.reasoning_effort=d:delete a.reasoning_effort;return ge(l.entry,t,a),o}function xs(s,r,n){const o=ue(s),l=me(o,r);if(!l||l.providerKind!=="anthropic")return null;const{extraArgsKey:d,extraArgs:t}=xe(l.entry),a=h(t.thinking)?{...t.thinking}:{};if(a.type="enabled",n===null)delete a.budget_tokens,delete a.budgetTokens;else{const u=Math.max(1024,Math.floor(n));a.budget_tokens=u,delete a.budgetTokens}return t.thinking=a,ge(l.entry,d,t),o}const J="__unset__";function gs(s){return s.providerKind==="openai"?"Writes: extraArgs.reasoning.effort":s.providerKind==="anthropic"?"Writes: extraArgs.thinking.{type,budget_tokens}":"Writes: extraArgs.reasoning_effort"}function fs({models:s,disabled:r,disabledReason:n,onEffortChange:o,onAnthropicBudgetChange:l}){return e.jsxs(b,{children:[e.jsx(v,{className:"pb-2",children:e.jsxs(y,{className:"text-base flex items-center gap-2",children:[e.jsx(Ie,{className:"h-4 w-4"}),"BYOK Reasoning / Thinking",e.jsx(S,{variant:"outline",className:"text-[10px] font-normal",children:"customModels"})]})}),e.jsxs(N,{className:"space-y-3",children:[n&&e.jsx("p",{className:"text-xs text-amber-600",children:n}),s.length===0?e.jsx("p",{className:"text-xs text-muted-foreground",children:"No BYOK custom models found in settings.json (`customModels` or `custom_models`)."}):e.jsx("div",{className:"space-y-2",children:s.map(d=>e.jsxs("div",{className:"rounded-md border p-3 space-y-2",children:[e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-xs font-medium truncate",children:d.displayName}),e.jsx("p",{className:"text-[11px] font-mono text-muted-foreground truncate",children:d.model||"(missing model id)"})]}),e.jsx(S,{variant:"outline",className:"font-mono text-[10px] shrink-0",children:d.provider})]}),e.jsxs("div",{className:"grid gap-2 sm:grid-cols-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-[11px] font-medium",children:"Reasoning Effort"}),e.jsxs(q,{value:d.effort??J,onValueChange:t=>o(d.id,t===J?null:t),disabled:r,children:[e.jsx(Y,{className:"h-8 text-xs",children:e.jsx(W,{placeholder:"Use provider default"})}),e.jsxs(G,{children:[e.jsx(k,{value:J,children:"Use provider default"}),ts.map(t=>e.jsx(k,{value:t,children:t},t))]})]})]}),d.providerKind==="anthropic"&&e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-[11px] font-medium",children:"Thinking Budget Tokens"}),e.jsx(ce,{type:"number",min:1024,step:1024,value:d.anthropicBudgetTokens??"",placeholder:"auto",className:"h-8 text-xs",disabled:r,onChange:t=>{const a=t.target.value.trim();if(!a){l(d.id,null);return}const u=Number.parseInt(a,10);Number.isFinite(u)&&l(d.id,Math.max(1024,u))}})]})]}),e.jsx("p",{className:"text-[11px] text-muted-foreground",children:gs(d)})]},d.id))})]})]})}const _="__unset__",hs=[{key:"reasoningEffort",label:"Reasoning Effort",description:"none | medium | high | max",options:[{value:"none",label:"none"},{value:"medium",label:"medium"},{value:"high",label:"high"},{value:"max",label:"max"}]},{key:"autonomyLevel",label:"Autonomy Level",description:"suggest | aggressive | full",options:[{value:"suggest",label:"suggest"},{value:"aggressive",label:"aggressive"},{value:"full",label:"full"}]},{key:"diffMode",label:"Diff Mode",description:"auto | none | inline | split",options:[{value:"auto",label:"auto"},{value:"none",label:"none"},{value:"inline",label:"inline"},{value:"split",label:"split"}]}],ps=[{key:"todoEnabled",label:"Todo Enabled"},{key:"todoAutoRefresh",label:"Todo Auto Refresh"},{key:"autoCompactEnabled",label:"Auto Compact Enabled"},{key:"soundEnabled",label:"Sound Enabled"}],js=[{key:"maxTurns",label:"Max Turns",min:1,step:1},{key:"maxToolCalls",label:"Max Tool Calls",min:1,step:1},{key:"autoCompactThreshold",label:"Auto Compact Threshold",min:1e3,step:1e3}];function bs(s){return s===!0?"true":s===!1?"false":_}function vs(s){return s==="true"?!0:s==="false"?!1:null}function ys({values:s,disabled:r,disabledReason:n,onEnumSettingChange:o,onBooleanSettingChange:l,onNumberSettingChange:d}){return e.jsxs(b,{children:[e.jsx(v,{className:"pb-2",children:e.jsxs(y,{className:"text-base flex items-center gap-2",children:[e.jsx(Ke,{className:"h-4 w-4"}),"Quick Settings",e.jsx(S,{variant:"outline",className:"text-[10px] font-normal",children:"settings.json"})]})}),e.jsxs(N,{className:"space-y-4",children:[n&&e.jsx("p",{className:"text-xs text-amber-600",children:n}),e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[hs.map(t=>e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs font-medium",children:t.label}),e.jsxs(q,{value:s[t.key]??_,onValueChange:a=>o(t.key,a===_?null:a),disabled:r,children:[e.jsx(Y,{className:"h-8 text-xs",children:e.jsx(W,{placeholder:"Use default"})}),e.jsxs(G,{children:[e.jsx(k,{value:_,children:"Use default"}),t.options.map(a=>e.jsx(k,{value:a.value,children:a.label},a.value))]})]}),e.jsx("p",{className:"text-[11px] text-muted-foreground",children:t.description})]},t.key)),js.map(t=>e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs font-medium",children:t.label}),e.jsx(ce,{type:"number",min:t.min,step:t.step,value:s[t.key]??"",onChange:a=>{const u=a.target.value.trim();if(!u){d(t.key,null);return}const x=Number.parseInt(u,10);Number.isFinite(x)&&d(t.key,Math.max(t.min,x))},className:"h-8 text-xs",disabled:r})]},t.key)),ps.map(t=>e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs font-medium",children:t.label}),e.jsxs(q,{value:bs(s[t.key]),onValueChange:a=>l(t.key,vs(a)),disabled:r,children:[e.jsx(Y,{className:"h-8 text-xs",children:e.jsx(W,{placeholder:"Use default"})}),e.jsxs(G,{children:[e.jsx(k,{value:_,children:"Use default"}),e.jsx(k,{value:"true",children:"true"}),e.jsx(k,{value:"false",children:"false"})]})]})]},t.key))]})]})]})}const Ns=[{id:"droid-cli-overview",label:"Droid CLI Overview",url:"https://docs.factory.ai/cli/",description:"Primary entry docs for setup, auth, and core CLI usage."},{id:"droid-byok-overview",label:"BYOK Overview",url:"https://docs.factory.ai/cli/byok/overview/",description:"BYOK model/provider shape, provider values, and migration notes."},{id:"droid-settings-reference",label:"settings.json Reference",url:"https://docs.factory.ai/cli/configuration/settings/",description:"Supported settings keys, defaults, and allowed values."}],ws=[{provider:"anthropic",label:"Anthropic Messages API",apiFormat:"Messages API",url:"https://docs.anthropic.com/en/api/messages"},{provider:"openai",label:"OpenAI Responses API",apiFormat:"Responses API",url:"https://platform.openai.com/docs/api-reference/responses"},{provider:"generic-chat-completion-api",label:"OpenAI Chat Completions Spec",apiFormat:"Chat Completions API",url:"https://platform.openai.com/docs/api-reference/chat"}];function ks(s){const r=/https?:\/\/[^\s)]+/g,n=[];let o=0,l;for(;(l=r.exec(s))!==null;){const[d]=l,t=l.index;t>o&&n.push(s.slice(o,t)),n.push(e.jsx("a",{href:d,target:"_blank",rel:"noreferrer",className:"underline underline-offset-2 hover:text-foreground",children:d},`${d}-${t}`)),o=t+d.length}return o<s.length&&n.push(s.slice(o)),n.length>0?n:[s]}function Ss(s){return!s||!Number.isFinite(s)?"N/A":new Date(s).toLocaleString()}function Cs(s){return!s||s<=0?"0 B":s<1024?`${s} B`:s<1024*1024?`${(s/1024).toFixed(1)} KB`:`${(s/(1024*1024)).toFixed(2)} MB`}function Es(s){try{const r=JSON.parse(s);return!r||typeof r!="object"||Array.isArray(r)?{valid:!1,error:"JSON root must be an object."}:{valid:!0,value:r}}catch(r){return{valid:!1,error:r.message}}}function Q(s){return typeof s=="string"?s:null}function H(s){return typeof s=="number"&&Number.isFinite(s)?s:null}function B(s){return typeof s=="boolean"?s:null}function g({label:s,value:r,mono:n=!1}){return e.jsxs("div",{className:"flex items-start justify-between gap-3 text-sm",children:[e.jsx("span",{className:"text-muted-foreground shrink-0",children:s}),e.jsx("span",{className:de("text-right break-all",n&&"font-mono text-xs"),children:r})]})}function Ls(){const{t:s}=Ee(),{diagnostics:r,diagnosticsLoading:n,diagnosticsError:o,refetchDiagnostics:l,rawSettings:d,rawSettingsLoading:t,refetchRawSettings:a,saveRawSettingsAsync:u,isSavingRawSettings:x}=Ze(),[P,T]=M.useState(null),C=d?.rawText??"{}",A=P??C,se=P!==null&&P!==C,c=Es(A),L=c.valid?{valid:!0}:{valid:!1,error:c.error},re=m=>{if(m===C){T(null);return}T(m)},I=m=>{re(JSON.stringify(m,null,2)+`
2
+ `)},K=(m,w)=>{if(!c.valid){p.error(s("droidPage.fixJsonBeforeQuickSettings"));return}const E={...c.value};w==null?delete E[m]:E[m]=w,I(E)},fe=c.valid?{reasoningEffort:Q(c.value.reasoningEffort),autonomyLevel:Q(c.value.autonomyLevel),diffMode:Q(c.value.diffMode),maxTurns:H(c.value.maxTurns),maxToolCalls:H(c.value.maxToolCalls),autoCompactThreshold:H(c.value.autoCompactThreshold),todoEnabled:B(c.value.todoEnabled),todoAutoRefresh:B(c.value.todoAutoRefresh),autoCompactEnabled:B(c.value.autoCompactEnabled),soundEnabled:B(c.value.soundEnabled)}:{reasoningEffort:null,autonomyLevel:null,diffMode:null,maxTurns:null,maxToolCalls:null,autoCompactThreshold:null,todoEnabled:null,todoAutoRefresh:null,autoCompactEnabled:null,soundEnabled:null},he=c.valid?us(c.value):[],pe=async()=>{await Promise.all([l(),a()])},je=async()=>{if(!L.valid){p.error(s("droidPage.invalidJson",{value:L.error}));return}try{await u({rawText:A,expectedMtime:d?.exists?d.mtime:void 0}),T(null),p.success(s("droidPage.saved"))}catch(m){_e(m)?p.error(s("droidPage.changedExternally")):p.error(m.message||s("droidPage.failedSave"))}},te=r?.byok.customModels??[],ne=M.useMemo(()=>Object.entries(r?.byok.providerBreakdown??{}).sort((m,w)=>w[1]-m[1]),[r?.byok.providerBreakdown]),be=()=>{if(n)return e.jsxs("div",{className:"flex h-full items-center justify-center text-muted-foreground",children:[e.jsx(X,{className:"h-5 w-5 animate-spin mr-2"}),s("droidPage.loadingDiagnostics")]});if(o||!r)return e.jsx("div",{className:"flex h-full items-center justify-center text-destructive px-6 text-center",children:s("droidPage.failedDiagnostics")});const m=r.docsReference??{notes:[],links:[],providerDocs:[],providerValues:[],settingsHierarchy:[]},w=m.notes??[],E=m.links??[],ae=m.providerDocs??[],ve=E.length>0?E:Ns,ye=ae.length>0?ae:ws,Ne=m.providerValues??[],we=m.settingsHierarchy??[],U="mt-0 h-full border-0 p-0 data-[state=inactive]:hidden";return e.jsxs(Ae,{defaultValue:"byok",className:"h-full flex flex-col",children:[e.jsx("div",{className:"px-4 pt-4 shrink-0",children:e.jsxs(Re,{className:"grid w-full grid-cols-3",children:[e.jsx(z,{value:"overview",children:s("droidPage.overview")}),e.jsx(z,{value:"byok",children:s("droidPage.byok")}),e.jsx(z,{value:"docs",children:s("droidPage.docs")})]})}),e.jsxs("div",{className:"flex-1 min-h-0 overflow-hidden px-4 pb-4 pt-3",children:[e.jsx($,{value:"overview",className:U,children:e.jsx(D,{className:"h-full",children:e.jsxs("div",{className:"space-y-4 pr-1",children:[e.jsxs(b,{children:[e.jsx(v,{className:"pb-2",children:e.jsxs(y,{className:"text-base flex items-center gap-2",children:[e.jsx(Ve,{className:"h-4 w-4"}),s("droidPage.runtimeInstall")]})}),e.jsxs(N,{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-sm text-muted-foreground",children:s("droidPage.status")}),e.jsx(S,{variant:r.binary.installed?"default":"secondary",children:r.binary.installed?s("droidPage.detected"):s("droidPage.notFound")})]}),e.jsx(g,{label:s("droidPage.detectionSource"),value:r.binary.source,mono:!0}),e.jsx(g,{label:s("droidPage.binaryPath"),value:r.binary.path||s("droidPage.notFound"),mono:!0}),e.jsx(g,{label:s("droidPage.installDirectory"),value:r.binary.installDir||"N/A",mono:!0}),e.jsx(g,{label:s("droidPage.version"),value:r.binary.version||"Unknown",mono:!0}),e.jsx(g,{label:s("droidPage.overridePath"),value:r.binary.overridePath||"Not set",mono:!0})]})]}),e.jsxs(b,{children:[e.jsx(v,{className:"pb-2",children:e.jsxs(y,{className:"text-base flex items-center gap-2",children:[e.jsx(ze,{className:"h-4 w-4"}),s("droidPage.configFiles")]})}),e.jsx(N,{className:"space-y-3",children:[r.files.settings,r.files.legacyConfig].map(i=>e.jsxs("div",{className:"rounded-md border p-3 space-y-1.5",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("span",{className:"font-medium text-sm",children:i.label}),i.exists?e.jsx($e,{className:"h-4 w-4 text-green-600"}):e.jsx(Je,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsx(g,{label:s("droidPage.path"),value:i.path,mono:!0}),e.jsx(g,{label:s("droidPage.resolved"),value:i.resolvedPath,mono:!0}),e.jsx(g,{label:s("droidPage.size"),value:Cs(i.sizeBytes)}),e.jsx(g,{label:s("droidPage.lastModified"),value:Ss(i.mtimeMs)}),i.parseError&&e.jsx("p",{className:"text-xs text-amber-600",children:s("droidPage.parseWarning",{value:i.parseError})}),i.readError&&e.jsx("p",{className:"text-xs text-destructive",children:s("droidPage.readWarning",{value:i.readError})})]},i.label))})]}),r.warnings.length>0&&e.jsxs(b,{className:"border-amber-200 bg-amber-50/50 dark:bg-amber-950/20",children:[e.jsx(v,{className:"pb-2",children:e.jsxs(y,{className:"text-base flex items-center gap-2",children:[e.jsx(Qe,{className:"h-4 w-4 text-amber-600"}),s("droidPage.warnings")]})}),e.jsx(N,{className:"space-y-1.5",children:r.warnings.map(i=>e.jsxs("p",{className:"text-sm text-amber-800 dark:text-amber-300",children:["- ",i]},i))})]})]})})}),e.jsx($,{value:"byok",className:U,children:e.jsx(D,{className:"h-full",children:e.jsxs("div",{className:"space-y-4 pr-1",children:[e.jsx(ys,{values:fe,disabled:t||!c.valid,disabledReason:c.valid?null:`Quick settings disabled: ${c.error}`,onEnumSettingChange:(i,f)=>{K(i,f)},onBooleanSettingChange:(i,f)=>{K(i,f)},onNumberSettingChange:(i,f)=>{K(i,f)}}),e.jsx(fs,{models:he,disabled:t||!c.valid,disabledReason:c.valid?null:`${s("droidPage.byok")}: ${c.error}`,onEffortChange:(i,f)=>{if(!c.valid){p.error(s("droidPage.fixJsonBeforeReasoning"));return}const R=ms(c.value,i,f);if(!R){p.error(s("droidPage.unableUpdateReasoning"));return}I(R)},onAnthropicBudgetChange:(i,f)=>{if(!c.valid){p.error(s("droidPage.fixJsonBeforeBudget"));return}const R=xs(c.value,i,f);if(!R){p.error(s("droidPage.anthropicOnlyBudget"));return}I(R)}}),e.jsxs(b,{children:[e.jsx(v,{className:"pb-2",children:e.jsxs(y,{className:"text-base flex items-center gap-2",children:[e.jsx(He,{className:"h-4 w-4"}),s("droidPage.byokSummary")]})}),e.jsxs(N,{className:"space-y-2",children:[e.jsx(g,{label:s("droidPage.activeModelSelector"),value:r.byok.activeModelSelector||"Not set",mono:!0}),e.jsx(g,{label:s("droidPage.customModels"),value:String(r.byok.customModelCount)}),e.jsx(g,{label:s("droidPage.ccsManaged"),value:String(r.byok.ccsManagedCount)}),e.jsx(g,{label:s("droidPage.userManaged"),value:String(r.byok.userManagedCount)}),e.jsx(g,{label:s("droidPage.malformedEntries"),value:String(r.byok.invalidModelEntryCount)}),e.jsx(O,{}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:s("droidPage.providers")}),e.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[ne.length===0&&e.jsx(S,{variant:"secondary",className:"font-mono",children:s("droidPage.none")}),ne.map(([i,f])=>e.jsxs(S,{variant:"outline",className:"font-mono text-xs",children:[i,": ",f]},i))]})]})]})]}),e.jsxs(b,{children:[e.jsx(v,{className:"pb-2",children:e.jsx(y,{className:"text-base",children:s("droidPage.customModelsTitle")})}),e.jsx(N,{children:e.jsxs("div",{className:"rounded-md border overflow-hidden",children:[e.jsxs("div",{className:"grid grid-cols-[2fr_1fr_2fr] bg-muted/40 px-3 py-2 text-xs font-medium",children:[e.jsx("span",{children:s("droidPage.modelName")}),e.jsx("span",{children:s("droidPage.provider")}),e.jsx("span",{children:s("droidPage.baseUrl")})]}),e.jsx(D,{className:"h-52",children:e.jsxs("div",{className:"divide-y",children:[te.length===0&&e.jsx("div",{className:"px-3 py-4 text-xs text-muted-foreground",children:s("droidPage.noCustomModels")}),te.map(i=>e.jsxs("div",{className:"grid grid-cols-[2fr_1fr_2fr] gap-2 px-3 py-2 text-xs",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"font-medium truncate",children:i.displayName}),e.jsx("p",{className:"text-muted-foreground font-mono truncate",children:i.model})]}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"truncate",children:i.provider}),e.jsx("p",{className:"text-muted-foreground",children:i.apiKeyPreview||"no-key"})]}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"truncate",title:i.baseUrl,children:i.host||i.baseUrl}),e.jsx("p",{className:"text-muted-foreground font-mono truncate",children:i.baseUrl})]})]},`${i.displayName}-${i.model}-${i.baseUrl}`))]})})]})})]})]})})}),e.jsx($,{value:"docs",className:U,children:e.jsx(D,{className:"h-full",children:e.jsx("div",{className:"space-y-4 pr-1",children:e.jsxs(b,{children:[e.jsx(v,{className:"pb-2",children:e.jsxs(y,{className:"text-base flex items-center gap-2",children:[e.jsx(qe,{className:"h-4 w-4"}),s("droidPage.docsAlignedNotes")]})}),e.jsxs(N,{className:"space-y-2 text-sm",children:[w.map((i,f)=>e.jsxs("p",{className:"text-muted-foreground",children:["- ",ks(i)]},`${f}-${i}`)),e.jsx(O,{}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-xs text-muted-foreground uppercase tracking-wide",children:s("droidPage.factoryDocs")}),e.jsx("div",{className:"space-y-1.5",children:ve.map(i=>e.jsxs("a",{href:i.url,target:"_blank",rel:"noreferrer",className:"block rounded-md border px-2.5 py-2 transition-colors hover:bg-muted/50",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("span",{className:"text-xs font-medium",children:i.label}),e.jsx(le,{className:"h-3.5 w-3.5 text-muted-foreground"})]}),e.jsx("p",{className:"mt-0.5 text-[11px] text-muted-foreground",children:i.description}),e.jsx("p",{className:"mt-1 break-all font-mono text-[11px] text-muted-foreground/90 underline underline-offset-2",children:i.url})]},i.id))})]}),e.jsx(O,{}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-xs text-muted-foreground uppercase tracking-wide",children:s("droidPage.providerFactCheckDocs")}),e.jsx("div",{className:"space-y-1.5",children:ye.map(i=>e.jsxs("a",{href:i.url,target:"_blank",rel:"noreferrer",className:"block rounded-md border px-2.5 py-2 transition-colors hover:bg-muted/50",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("span",{className:"text-xs font-medium",children:i.label}),e.jsx(le,{className:"h-3.5 w-3.5 text-muted-foreground"})]}),e.jsxs("p",{className:"mt-0.5 text-[11px] text-muted-foreground",children:["provider: ",i.provider," | format: ",i.apiFormat]}),e.jsx("p",{className:"mt-1 break-all font-mono text-[11px] text-muted-foreground/90 underline underline-offset-2",children:i.url})]},`${i.provider}-${i.url}`))})]}),e.jsx(O,{}),e.jsx("p",{className:"text-xs text-muted-foreground",children:s("droidPage.providerValues",{value:Ne.join(", ")})}),e.jsx("p",{className:"text-xs text-muted-foreground",children:s("droidPage.settingsHierarchy",{value:we.join(" -> ")})})]})]})})})})]})]})};return e.jsx("div",{className:"h-[calc(100vh-100px)] overflow-hidden",children:e.jsxs(Pe,{direction:"horizontal",className:"h-full",children:[e.jsx(ie,{defaultSize:45,minSize:35,children:e.jsx("div",{className:"h-full border-r bg-muted/20",children:be()})}),e.jsx(Te,{className:"w-2 bg-border hover:bg-primary/20 transition-colors cursor-col-resize flex items-center justify-center group",children:e.jsx(Ue,{className:"w-3 h-3 text-muted-foreground group-hover:text-primary"})}),e.jsx(ie,{defaultSize:55,minSize:35,children:e.jsx(es,{title:s("droidPage.settingsTitle"),pathLabel:d?.path||"~/.factory/settings.json",loading:t,parseWarning:d?.parseError,value:A,dirty:se,saving:x,saveDisabled:!se||x||t||!L.valid,onChange:m=>{re(m)},onSave:je,onRefresh:pe})})]})})}export{Ls as DroidPage};
@@ -1 +1 @@
1
- import{j as e}from"./radix-ui-BR1vy4kf.js";import{r as m}from"./react-vendor-CNOkPC89.js";import{be as C,bf as w,a as G,bg as y,b7 as S,b9 as k,n as R,d as x,I as j}from"./index-CsbQfRnG.js";import{S as A}from"./switch-D9kCIDCe.js";import{R as N,a3 as D,u as L,ah as T,a1 as I}from"./icons-kPbuhVdj.js";import"./tanstack-e99Cjjy2.js";import"./notifications-B2HqRBj7.js";import"./utils-CzKF5WmX.js";import"./form-utils-Cn_Uld6y.js";import"./code-highlight-BRUf_pqB.js";function _(){const{state:s}=C(),n=w(),[o,r]=m.useState(""),[c,g]=m.useState(""),u=m.useCallback(async()=>{try{n.setGlobalEnvLoading(!0),n.setGlobalEnvError(null);const a=await fetch("/api/global-env");if(!a.ok)throw new Error("Failed to load Global Env config");const l=await a.json();n.setGlobalEnvConfig(l)}catch(a){n.setGlobalEnvError(a.message)}finally{n.setGlobalEnvLoading(!1)}},[n]),i=m.useCallback(async a=>{const l=s.globalEnvConfig;if(!l)return;const f={...l,...a};n.setGlobalEnvConfig(f);try{n.setGlobalEnvSaving(!0),n.setGlobalEnvError(null);const d=await fetch("/api/global-env",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(f)});if(!d.ok){const E=await d.json();throw new Error(E.error||"Failed to save")}const v=await d.json();n.setGlobalEnvConfig(v.config),n.setGlobalEnvSuccess(!0),setTimeout(()=>n.setGlobalEnvSuccess(!1),1500)}catch(d){n.setGlobalEnvConfig(l),n.setGlobalEnvError(d.message)}finally{n.setGlobalEnvSaving(!1)}},[s.globalEnvConfig,n]),h=m.useCallback(()=>{if(!o.trim()||!s.globalEnvConfig)return;const a={...s.globalEnvConfig.env,[o.trim()]:c};i({env:a}),r(""),g("")},[o,c,s.globalEnvConfig,i]),b=m.useCallback(a=>{if(!s.globalEnvConfig)return;const l={...s.globalEnvConfig.env};delete l[a],i({env:l})},[s.globalEnvConfig,i]);return{config:s.globalEnvConfig,loading:s.globalEnvLoading,saving:s.globalEnvSaving,error:s.globalEnvError,success:s.globalEnvSuccess,newEnvKey:o,setNewEnvKey:r,newEnvValue:c,setNewEnvValue:g,fetchConfig:u,saveConfig:i,addEnvVar:h,removeEnvVar:b}}function $(){const{t:s}=G(),{config:n,loading:o,saving:r,error:c,success:g,newEnvKey:u,setNewEnvKey:i,newEnvValue:h,setNewEnvValue:b,fetchConfig:a,saveConfig:l,addEnvVar:f,removeEnvVar:d}=_(),{fetchRawConfig:v}=y();m.useEffect(()=>{a(),v()},[a,v]);const E=()=>{l({enabled:!n?.enabled})};return o?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(N,{className:"w-5 h-5 animate-spin"}),e.jsx("span",{children:s("settings.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 ${c||g?"opacity-100 translate-y-0":"opacity-0 -translate-y-2 pointer-events-none"}`,children:[c&&e.jsxs(S,{variant:"destructive",className:"py-2 shadow-lg",children:[e.jsx(D,{className:"h-4 w-4"}),e.jsx(k,{children:c})]}),g&&e.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 rounded-md border border-green-200 bg-green-50 text-green-700 shadow-lg dark:border-green-900/50 dark:bg-green-900/90 dark:text-green-300",children:[e.jsx(L,{className:"h-4 w-4 shrink-0"}),e.jsx("span",{className:"text-sm font-medium",children:s("settings.saved")})]})]}),e.jsx(R,{className:"flex-1",children:e.jsxs("div",{className:"p-5 space-y-6",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:s("settingsGlobalEnv.description")}),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?.enabled?s("settingsGlobalEnv.enabled"):s("settingsGlobalEnv.disabled")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:n?.enabled?s("settingsGlobalEnv.enabledDesc"):s("settingsGlobalEnv.disabledDesc")})]}),e.jsx(A,{checked:n?.enabled??!0,onCheckedChange:E})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx("h3",{className:"text-base font-medium",children:s("settingsGlobalEnv.envVars")}),n?.env&&Object.keys(n.env).length>0?e.jsx("div",{className:"space-y-2",children:Object.entries(n.env).map(([t,p])=>e.jsxs("div",{className:"flex items-center gap-2 p-3 rounded-lg border bg-background",children:[e.jsx("code",{className:"flex-1 font-mono text-sm truncate",children:t}),e.jsx("span",{className:"text-muted-foreground",children:"="}),e.jsx("code",{className:"font-mono text-sm px-2 py-1 bg-muted rounded",children:p}),e.jsx(x,{variant:"ghost",size:"sm",onClick:()=>d(t),disabled:r,className:"h-8 w-8 p-0 text-destructive hover:text-destructive hover:bg-destructive/10",children:e.jsx(T,{className:"w-4 h-4"})})]},t))}):e.jsx("div",{className:"p-4 rounded-lg border border-dashed text-center text-muted-foreground",children:e.jsx("p",{children:s("settingsGlobalEnv.noneConfigured")})}),e.jsxs("div",{className:"p-4 rounded-lg border bg-muted/30",children:[e.jsx("h4",{className:"text-sm font-medium mb-3",children:s("settingsGlobalEnv.addNew")}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(j,{value:u,onChange:t=>i(t.target.value.toUpperCase()),placeholder:s("settingsGlobalEnv.keyName"),className:"flex-1 font-mono text-sm h-9",disabled:r}),e.jsx("span",{className:"flex items-center text-muted-foreground",children:"="}),e.jsx(j,{value:h,onChange:t=>b(t.target.value),placeholder:s("settingsGlobalEnv.value"),className:"flex-1 font-mono text-sm h-9",disabled:r}),e.jsxs(x,{size:"sm",onClick:f,disabled:r||!u.trim(),className:"h-9",children:[e.jsx(I,{className:"w-4 h-4 mr-1"}),s("settingsGlobalEnv.add")]})]})]}),e.jsxs("div",{className:"p-4 rounded-lg border bg-muted/30",children:[e.jsx("h4",{className:"text-sm font-medium mb-3",children:s("settingsGlobalEnv.quickAdd")}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[[{key:"DISABLE_BUG_COMMAND",value:"1"},{key:"DISABLE_ERROR_REPORTING",value:"1"},{key:"DISABLE_TELEMETRY",value:"1"}].map(({key:t,value:p})=>!n?.env?.[t]&&e.jsxs(x,{variant:"outline",size:"sm",onClick:()=>{i(t),b(p)},className:"text-xs font-mono",children:["+ ",t]},t)),n?.env&&["DISABLE_BUG_COMMAND","DISABLE_ERROR_REPORTING","DISABLE_TELEMETRY"].every(t=>n.env[t])&&e.jsx("span",{className:"text-sm text-muted-foreground",children:s("settingsGlobalEnv.allConfigured")})]})]})]})]})}),e.jsx("div",{className:"p-4 border-t bg-background",children:e.jsxs(x,{variant:"outline",size:"sm",onClick:()=>{a(),v()},disabled:o||r,className:"w-full",children:[e.jsx(N,{className:`w-4 h-4 mr-2 ${o?"animate-spin":""}`}),s("settings.refresh")]})})]})}export{$ as default};
1
+ import{j as e}from"./radix-ui-BR1vy4kf.js";import{r as m}from"./react-vendor-CNOkPC89.js";import{be as C,bf as w,a as G,bg as y,b7 as S,b9 as k,n as R,d as x,I as j}from"./index-DCQkhmoo.js";import{S as A}from"./switch-BL5xZtnr.js";import{R as N,a3 as D,u as L,ah as T,a1 as I}from"./icons-BYZM_9Gm.js";import"./tanstack-e99Cjjy2.js";import"./notifications-B2HqRBj7.js";import"./utils-CzKF5WmX.js";import"./form-utils-Cn_Uld6y.js";import"./code-highlight-BRUf_pqB.js";function _(){const{state:s}=C(),n=w(),[o,r]=m.useState(""),[c,g]=m.useState(""),u=m.useCallback(async()=>{try{n.setGlobalEnvLoading(!0),n.setGlobalEnvError(null);const a=await fetch("/api/global-env");if(!a.ok)throw new Error("Failed to load Global Env config");const l=await a.json();n.setGlobalEnvConfig(l)}catch(a){n.setGlobalEnvError(a.message)}finally{n.setGlobalEnvLoading(!1)}},[n]),i=m.useCallback(async a=>{const l=s.globalEnvConfig;if(!l)return;const f={...l,...a};n.setGlobalEnvConfig(f);try{n.setGlobalEnvSaving(!0),n.setGlobalEnvError(null);const d=await fetch("/api/global-env",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(f)});if(!d.ok){const E=await d.json();throw new Error(E.error||"Failed to save")}const v=await d.json();n.setGlobalEnvConfig(v.config),n.setGlobalEnvSuccess(!0),setTimeout(()=>n.setGlobalEnvSuccess(!1),1500)}catch(d){n.setGlobalEnvConfig(l),n.setGlobalEnvError(d.message)}finally{n.setGlobalEnvSaving(!1)}},[s.globalEnvConfig,n]),h=m.useCallback(()=>{if(!o.trim()||!s.globalEnvConfig)return;const a={...s.globalEnvConfig.env,[o.trim()]:c};i({env:a}),r(""),g("")},[o,c,s.globalEnvConfig,i]),b=m.useCallback(a=>{if(!s.globalEnvConfig)return;const l={...s.globalEnvConfig.env};delete l[a],i({env:l})},[s.globalEnvConfig,i]);return{config:s.globalEnvConfig,loading:s.globalEnvLoading,saving:s.globalEnvSaving,error:s.globalEnvError,success:s.globalEnvSuccess,newEnvKey:o,setNewEnvKey:r,newEnvValue:c,setNewEnvValue:g,fetchConfig:u,saveConfig:i,addEnvVar:h,removeEnvVar:b}}function $(){const{t:s}=G(),{config:n,loading:o,saving:r,error:c,success:g,newEnvKey:u,setNewEnvKey:i,newEnvValue:h,setNewEnvValue:b,fetchConfig:a,saveConfig:l,addEnvVar:f,removeEnvVar:d}=_(),{fetchRawConfig:v}=y();m.useEffect(()=>{a(),v()},[a,v]);const E=()=>{l({enabled:!n?.enabled})};return o?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(N,{className:"w-5 h-5 animate-spin"}),e.jsx("span",{children:s("settings.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 ${c||g?"opacity-100 translate-y-0":"opacity-0 -translate-y-2 pointer-events-none"}`,children:[c&&e.jsxs(S,{variant:"destructive",className:"py-2 shadow-lg",children:[e.jsx(D,{className:"h-4 w-4"}),e.jsx(k,{children:c})]}),g&&e.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 rounded-md border border-green-200 bg-green-50 text-green-700 shadow-lg dark:border-green-900/50 dark:bg-green-900/90 dark:text-green-300",children:[e.jsx(L,{className:"h-4 w-4 shrink-0"}),e.jsx("span",{className:"text-sm font-medium",children:s("settings.saved")})]})]}),e.jsx(R,{className:"flex-1",children:e.jsxs("div",{className:"p-5 space-y-6",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:s("settingsGlobalEnv.description")}),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?.enabled?s("settingsGlobalEnv.enabled"):s("settingsGlobalEnv.disabled")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:n?.enabled?s("settingsGlobalEnv.enabledDesc"):s("settingsGlobalEnv.disabledDesc")})]}),e.jsx(A,{checked:n?.enabled??!0,onCheckedChange:E})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx("h3",{className:"text-base font-medium",children:s("settingsGlobalEnv.envVars")}),n?.env&&Object.keys(n.env).length>0?e.jsx("div",{className:"space-y-2",children:Object.entries(n.env).map(([t,p])=>e.jsxs("div",{className:"flex items-center gap-2 p-3 rounded-lg border bg-background",children:[e.jsx("code",{className:"flex-1 font-mono text-sm truncate",children:t}),e.jsx("span",{className:"text-muted-foreground",children:"="}),e.jsx("code",{className:"font-mono text-sm px-2 py-1 bg-muted rounded",children:p}),e.jsx(x,{variant:"ghost",size:"sm",onClick:()=>d(t),disabled:r,className:"h-8 w-8 p-0 text-destructive hover:text-destructive hover:bg-destructive/10",children:e.jsx(T,{className:"w-4 h-4"})})]},t))}):e.jsx("div",{className:"p-4 rounded-lg border border-dashed text-center text-muted-foreground",children:e.jsx("p",{children:s("settingsGlobalEnv.noneConfigured")})}),e.jsxs("div",{className:"p-4 rounded-lg border bg-muted/30",children:[e.jsx("h4",{className:"text-sm font-medium mb-3",children:s("settingsGlobalEnv.addNew")}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(j,{value:u,onChange:t=>i(t.target.value.toUpperCase()),placeholder:s("settingsGlobalEnv.keyName"),className:"flex-1 font-mono text-sm h-9",disabled:r}),e.jsx("span",{className:"flex items-center text-muted-foreground",children:"="}),e.jsx(j,{value:h,onChange:t=>b(t.target.value),placeholder:s("settingsGlobalEnv.value"),className:"flex-1 font-mono text-sm h-9",disabled:r}),e.jsxs(x,{size:"sm",onClick:f,disabled:r||!u.trim(),className:"h-9",children:[e.jsx(I,{className:"w-4 h-4 mr-1"}),s("settingsGlobalEnv.add")]})]})]}),e.jsxs("div",{className:"p-4 rounded-lg border bg-muted/30",children:[e.jsx("h4",{className:"text-sm font-medium mb-3",children:s("settingsGlobalEnv.quickAdd")}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[[{key:"DISABLE_BUG_COMMAND",value:"1"},{key:"DISABLE_ERROR_REPORTING",value:"1"},{key:"DISABLE_TELEMETRY",value:"1"}].map(({key:t,value:p})=>!n?.env?.[t]&&e.jsxs(x,{variant:"outline",size:"sm",onClick:()=>{i(t),b(p)},className:"text-xs font-mono",children:["+ ",t]},t)),n?.env&&["DISABLE_BUG_COMMAND","DISABLE_ERROR_REPORTING","DISABLE_TELEMETRY"].every(t=>n.env[t])&&e.jsx("span",{className:"text-sm text-muted-foreground",children:s("settingsGlobalEnv.allConfigured")})]})]})]})]})}),e.jsx("div",{className:"p-4 border-t bg-background",children:e.jsxs(x,{variant:"outline",size:"sm",onClick:()=>{a(),v()},disabled:o||r,className:"w-full",children:[e.jsx(N,{className:`w-4 h-4 mr-2 ${o?"animate-spin":""}`}),s("settings.refresh")]})})]})}export{$ as default};