@kaitranntt/ccs 7.54.0 → 7.55.0-dev.2

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 (230) hide show
  1. package/README.md +26 -4
  2. package/config/base-codex.settings.json +4 -4
  3. package/dist/auth/commands/create-command.js +1 -1
  4. package/dist/auth/commands/create-command.js.map +1 -1
  5. package/dist/auth/commands/remove-command.js +1 -1
  6. package/dist/auth/commands/remove-command.js.map +1 -1
  7. package/dist/ccs.js +70 -370
  8. package/dist/ccs.js.map +1 -1
  9. package/dist/cliproxy/codex-plan-compatibility.d.ts +29 -0
  10. package/dist/cliproxy/codex-plan-compatibility.d.ts.map +1 -0
  11. package/dist/cliproxy/codex-plan-compatibility.js +130 -0
  12. package/dist/cliproxy/codex-plan-compatibility.js.map +1 -0
  13. package/dist/cliproxy/codex-reasoning-proxy.d.ts +5 -0
  14. package/dist/cliproxy/codex-reasoning-proxy.d.ts.map +1 -1
  15. package/dist/cliproxy/codex-reasoning-proxy.js +103 -20
  16. package/dist/cliproxy/codex-reasoning-proxy.js.map +1 -1
  17. package/dist/cliproxy/executor/index.d.ts.map +1 -1
  18. package/dist/cliproxy/executor/index.js +8 -0
  19. package/dist/cliproxy/executor/index.js.map +1 -1
  20. package/dist/cliproxy/index.d.ts +1 -0
  21. package/dist/cliproxy/index.d.ts.map +1 -1
  22. package/dist/cliproxy/index.js +6 -2
  23. package/dist/cliproxy/index.js.map +1 -1
  24. package/dist/cliproxy/model-catalog.d.ts.map +1 -1
  25. package/dist/cliproxy/model-catalog.js +81 -12
  26. package/dist/cliproxy/model-catalog.js.map +1 -1
  27. package/dist/cliproxy/model-config.d.ts.map +1 -1
  28. package/dist/cliproxy/model-config.js +2 -2
  29. package/dist/cliproxy/model-config.js.map +1 -1
  30. package/dist/cliproxy/services/variant-settings.d.ts +3 -1
  31. package/dist/cliproxy/services/variant-settings.d.ts.map +1 -1
  32. package/dist/cliproxy/services/variant-settings.js +5 -2
  33. package/dist/cliproxy/services/variant-settings.js.map +1 -1
  34. package/dist/commands/api-command/copy-command.d.ts +2 -0
  35. package/dist/commands/api-command/copy-command.d.ts.map +1 -0
  36. package/dist/commands/api-command/copy-command.js +41 -0
  37. package/dist/commands/api-command/copy-command.js.map +1 -0
  38. package/dist/commands/api-command/create-command.d.ts +2 -0
  39. package/dist/commands/api-command/create-command.d.ts.map +1 -0
  40. package/dist/commands/api-command/create-command.js +249 -0
  41. package/dist/commands/api-command/create-command.js.map +1 -0
  42. package/dist/commands/api-command/discover-command.d.ts +2 -0
  43. package/dist/commands/api-command/discover-command.d.ts.map +1 -0
  44. package/dist/commands/api-command/discover-command.js +69 -0
  45. package/dist/commands/api-command/discover-command.js.map +1 -0
  46. package/dist/commands/api-command/export-command.d.ts +2 -0
  47. package/dist/commands/api-command/export-command.d.ts.map +1 -0
  48. package/dist/commands/api-command/export-command.js +73 -0
  49. package/dist/commands/api-command/export-command.js.map +1 -0
  50. package/dist/commands/api-command/help.d.ts +3 -0
  51. package/dist/commands/api-command/help.d.ts.map +1 -0
  52. package/dist/commands/api-command/help.js +100 -0
  53. package/dist/commands/api-command/help.js.map +1 -0
  54. package/dist/commands/api-command/import-command.d.ts +2 -0
  55. package/dist/commands/api-command/import-command.d.ts.map +1 -0
  56. package/dist/commands/api-command/import-command.js +111 -0
  57. package/dist/commands/api-command/import-command.js.map +1 -0
  58. package/dist/commands/api-command/index.d.ts +3 -0
  59. package/dist/commands/api-command/index.d.ts.map +1 -0
  60. package/dist/commands/api-command/index.js +34 -0
  61. package/dist/commands/api-command/index.js.map +1 -0
  62. package/dist/commands/api-command/list-command.d.ts +2 -0
  63. package/dist/commands/api-command/list-command.d.ts.map +1 -0
  64. package/dist/commands/api-command/list-command.js +53 -0
  65. package/dist/commands/api-command/list-command.js.map +1 -0
  66. package/dist/commands/api-command/remove-command.d.ts +2 -0
  67. package/dist/commands/api-command/remove-command.d.ts.map +1 -0
  68. package/dist/commands/api-command/remove-command.js +63 -0
  69. package/dist/commands/api-command/remove-command.js.map +1 -0
  70. package/dist/commands/api-command/shared.d.ts +36 -0
  71. package/dist/commands/api-command/shared.d.ts.map +1 -0
  72. package/dist/commands/api-command/shared.js +164 -0
  73. package/dist/commands/api-command/shared.js.map +1 -0
  74. package/dist/commands/api-command.d.ts +1 -26
  75. package/dist/commands/api-command.d.ts.map +1 -1
  76. package/dist/commands/api-command.js +3 -807
  77. package/dist/commands/api-command.js.map +1 -1
  78. package/dist/commands/arg-extractor.d.ts +15 -0
  79. package/dist/commands/arg-extractor.d.ts.map +1 -1
  80. package/dist/commands/arg-extractor.js +48 -2
  81. package/dist/commands/arg-extractor.js.map +1 -1
  82. package/dist/commands/config-auth/index.d.ts.map +1 -1
  83. package/dist/commands/config-auth/index.js +35 -19
  84. package/dist/commands/config-auth/index.js.map +1 -1
  85. package/dist/commands/config-command-options.d.ts +14 -0
  86. package/dist/commands/config-command-options.d.ts.map +1 -0
  87. package/dist/commands/config-command-options.js +108 -0
  88. package/dist/commands/config-command-options.js.map +1 -0
  89. package/dist/commands/config-command.d.ts +1 -1
  90. package/dist/commands/config-command.d.ts.map +1 -1
  91. package/dist/commands/config-command.js +91 -104
  92. package/dist/commands/config-command.js.map +1 -1
  93. package/dist/commands/config-dashboard-host.d.ts +17 -0
  94. package/dist/commands/config-dashboard-host.d.ts.map +1 -0
  95. package/dist/commands/config-dashboard-host.js +99 -0
  96. package/dist/commands/config-dashboard-host.js.map +1 -0
  97. package/dist/commands/env-command.d.ts.map +1 -1
  98. package/dist/commands/env-command.js +5 -0
  99. package/dist/commands/env-command.js.map +1 -1
  100. package/dist/commands/help-command.js +1 -1
  101. package/dist/commands/help-command.js.map +1 -1
  102. package/dist/commands/named-command-router.d.ts +17 -0
  103. package/dist/commands/named-command-router.d.ts.map +1 -0
  104. package/dist/commands/named-command-router.js +39 -0
  105. package/dist/commands/named-command-router.js.map +1 -0
  106. package/dist/commands/persist-command.js +1 -1
  107. package/dist/commands/persist-command.js.map +1 -1
  108. package/dist/commands/root-command-router.d.ts +2 -0
  109. package/dist/commands/root-command-router.d.ts.map +1 -0
  110. package/dist/commands/root-command-router.js +209 -0
  111. package/dist/commands/root-command-router.js.map +1 -0
  112. package/dist/config/unified-config-loader.js +1 -1
  113. package/dist/config/unified-config-loader.js.map +1 -1
  114. package/dist/cursor/cursor-anthropic-response.d.ts +6 -0
  115. package/dist/cursor/cursor-anthropic-response.d.ts.map +1 -0
  116. package/dist/cursor/cursor-anthropic-response.js +190 -0
  117. package/dist/cursor/cursor-anthropic-response.js.map +1 -0
  118. package/dist/cursor/cursor-anthropic-translator.d.ts +11 -0
  119. package/dist/cursor/cursor-anthropic-translator.d.ts.map +1 -0
  120. package/dist/cursor/cursor-anthropic-translator.js +167 -0
  121. package/dist/cursor/cursor-anthropic-translator.js.map +1 -0
  122. package/dist/cursor/cursor-anthropic-types.d.ts +46 -0
  123. package/dist/cursor/cursor-anthropic-types.d.ts.map +1 -0
  124. package/dist/cursor/cursor-anthropic-types.js +3 -0
  125. package/dist/cursor/cursor-anthropic-types.js.map +1 -0
  126. package/dist/cursor/cursor-daemon-entry.d.ts.map +1 -1
  127. package/dist/cursor/cursor-daemon-entry.js +53 -24
  128. package/dist/cursor/cursor-daemon-entry.js.map +1 -1
  129. package/dist/cursor/cursor-models.d.ts.map +1 -1
  130. package/dist/cursor/cursor-models.js +36 -2
  131. package/dist/cursor/cursor-models.js.map +1 -1
  132. package/dist/glmt/glmt-proxy.d.ts +4 -3
  133. package/dist/glmt/glmt-proxy.d.ts.map +1 -1
  134. package/dist/glmt/glmt-proxy.js +4 -3
  135. package/dist/glmt/glmt-proxy.js.map +1 -1
  136. package/dist/glmt/sse-parser.d.ts +2 -0
  137. package/dist/glmt/sse-parser.d.ts.map +1 -1
  138. package/dist/glmt/sse-parser.js +4 -0
  139. package/dist/glmt/sse-parser.js.map +1 -1
  140. package/dist/management/instance-manager.d.ts +2 -1
  141. package/dist/management/instance-manager.d.ts.map +1 -1
  142. package/dist/management/instance-manager.js +23 -8
  143. package/dist/management/instance-manager.js.map +1 -1
  144. package/dist/management/profile-context-sync-lock.d.ts +3 -0
  145. package/dist/management/profile-context-sync-lock.d.ts.map +1 -1
  146. package/dist/management/profile-context-sync-lock.js +75 -3
  147. package/dist/management/profile-context-sync-lock.js.map +1 -1
  148. package/dist/management/recovery-manager.d.ts +2 -2
  149. package/dist/management/recovery-manager.js +2 -2
  150. package/dist/management/shared-manager.d.ts +31 -1
  151. package/dist/management/shared-manager.d.ts.map +1 -1
  152. package/dist/management/shared-manager.js +420 -23
  153. package/dist/management/shared-manager.js.map +1 -1
  154. package/dist/shared/claude-extension-setup.d.ts.map +1 -1
  155. package/dist/shared/claude-extension-setup.js +16 -2
  156. package/dist/shared/claude-extension-setup.js.map +1 -1
  157. package/dist/shared/provider-preset-catalog.d.ts +1 -1
  158. package/dist/shared/provider-preset-catalog.d.ts.map +1 -1
  159. package/dist/shared/provider-preset-catalog.js +34 -40
  160. package/dist/shared/provider-preset-catalog.js.map +1 -1
  161. package/dist/ui/assets/{accounts-CZEg1_PX.js → accounts-CxIwtPW5.js} +1 -1
  162. package/dist/ui/assets/{alert-dialog-DhwS38kc.js → alert-dialog-D0M-j0xk.js} +1 -1
  163. package/dist/ui/assets/{api-sWNND4wP.js → api-D_GvXEjg.js} +1 -1
  164. package/dist/ui/assets/{auth-section-nJIpOcnm.js → auth-section-DtxR8sof.js} +1 -1
  165. package/dist/ui/assets/{backups-section-D3A6hmrU.js → backups-section-DAPwVCGp.js} +1 -1
  166. package/dist/ui/assets/checkbox-D470Q1y9.js +1 -0
  167. package/dist/ui/assets/{claude-extension-BjInaILv.js → claude-extension-vRIHOe5q.js} +1 -1
  168. package/dist/ui/assets/cliproxy-DGsWe0cf.js +3 -0
  169. package/dist/ui/assets/{cliproxy-control-panel-CKO2Sn9B.js → cliproxy-control-panel-BoKpt64d.js} +1 -1
  170. package/dist/ui/assets/{confirm-dialog-DTKxwrat.js → confirm-dialog-BnNUvB5u.js} +1 -1
  171. package/dist/ui/assets/copilot-DCkXk9mK.js +3 -0
  172. package/dist/ui/assets/cursor-9aQfYlGU.js +1 -0
  173. package/dist/ui/assets/{droid-Cl8QsJJL.js → droid-Bzp6uHqU.js} +2 -2
  174. package/dist/ui/assets/{globalenv-section-C3dxxoD9.js → globalenv-section-BM9oGUk_.js} +1 -1
  175. package/dist/ui/assets/{health-BUifaDU7.js → health-DLIgkfxF.js} +1 -1
  176. package/dist/ui/assets/icons-DtwH984l.js +1 -0
  177. package/dist/ui/assets/index-C-7tLTU2.js +47 -0
  178. package/dist/ui/assets/index-ClEn7Y7g.css +1 -0
  179. package/dist/ui/assets/{index-CPdceT1C.js → index-D9tmeP-H.js} +1 -1
  180. package/dist/ui/assets/{index-CYo-E5rU.js → index-DGQhzUIq.js} +1 -1
  181. package/dist/ui/assets/{index-BOsbrhaa.js → index-DimlYMhI.js} +1 -1
  182. package/dist/ui/assets/{index-xayyyR26.js → index-DykKl5b0.js} +1 -1
  183. package/dist/ui/assets/providers/llama-cpp.svg +5 -0
  184. package/dist/ui/assets/{proxy-status-widget-D94htBPb.js → proxy-status-widget-DloYg7yP.js} +1 -1
  185. package/dist/ui/assets/{radix-ui-BR1vy4kf.js → radix-ui-Dt3edmE5.js} +8 -8
  186. package/dist/ui/assets/searchable-select-CSREngvO.js +1 -0
  187. package/dist/ui/assets/{separator-3fBbTn-V.js → separator-DzrBeBn-.js} +1 -1
  188. package/dist/ui/assets/{shared-q_FNNbjD.js → shared-qRzQxB-N.js} +1 -1
  189. package/dist/ui/assets/{switch-5N8qBdBr.js → switch-BP9rnaI6.js} +1 -1
  190. package/dist/ui/assets/{tanstack-e99Cjjy2.js → tanstack-B8i0evp-.js} +1 -1
  191. package/dist/ui/assets/{updates-CubQ54J0.js → updates-BQvHbU9s.js} +1 -1
  192. package/dist/ui/icons/novita.svg +9 -0
  193. package/dist/ui/index.html +5 -5
  194. package/dist/utils/config-manager.d.ts +1 -1
  195. package/dist/utils/config-manager.js +1 -1
  196. package/dist/utils/fetch-proxy-setup.d.ts.map +1 -1
  197. package/dist/utils/fetch-proxy-setup.js.map +1 -1
  198. package/dist/utils/glmt-deprecation.d.ts +11 -0
  199. package/dist/utils/glmt-deprecation.d.ts.map +1 -0
  200. package/dist/utils/glmt-deprecation.js +64 -0
  201. package/dist/utils/glmt-deprecation.js.map +1 -0
  202. package/dist/utils/shell-executor.d.ts.map +1 -1
  203. package/dist/utils/shell-executor.js +12 -0
  204. package/dist/utils/shell-executor.js.map +1 -1
  205. package/dist/web-server/index.d.ts +1 -0
  206. package/dist/web-server/index.d.ts.map +1 -1
  207. package/dist/web-server/index.js +39 -3
  208. package/dist/web-server/index.js.map +1 -1
  209. package/dist/web-server/routes/account-routes.js +2 -2
  210. package/dist/web-server/routes/account-routes.js.map +1 -1
  211. package/dist/web-server/routes/profile-routes.d.ts +1 -0
  212. package/dist/web-server/routes/profile-routes.d.ts.map +1 -1
  213. package/dist/web-server/routes/profile-routes.js +3 -0
  214. package/dist/web-server/routes/profile-routes.js.map +1 -1
  215. package/dist/web-server/routes/variant-routes.d.ts +1 -0
  216. package/dist/web-server/routes/variant-routes.d.ts.map +1 -1
  217. package/dist/web-server/routes/variant-routes.js +3 -0
  218. package/dist/web-server/routes/variant-routes.js.map +1 -1
  219. package/package.json +3 -2
  220. package/scripts/completion/README.md +1 -1
  221. package/scripts/completion/ccs.fish +1 -2
  222. package/scripts/completion/ccs.zsh +1 -2
  223. package/scripts/postinstall.js +3 -3
  224. package/dist/ui/assets/checkbox-CZrxD1iS.js +0 -1
  225. package/dist/ui/assets/cliproxy-BGiSCGkl.js +0 -3
  226. package/dist/ui/assets/copilot-CuRngdBg.js +0 -3
  227. package/dist/ui/assets/cursor-Dxo0uIiU.js +0 -1
  228. package/dist/ui/assets/icons-DrEfTmfX.js +0 -1
  229. package/dist/ui/assets/index-Btf_ow2V.css +0 -1
  230. package/dist/ui/assets/index-Cw9Urr0S.js +0 -47
@@ -1 +1 @@
1
- import{j as e}from"./radix-ui-BR1vy4kf.js";import{r as W}from"./react-vendor-CNOkPC89.js";import{b2 as Ce,B as p,d as y,n as se,C as u,j as f,k as j,_ as v,b as x,I as H,r as te,s as ae,t as ne,v as ie,w as re,x as F,Q as we,R as Ee,U as le,V as de,c as he}from"./index-Cw9Urr0S.js";import{u as K,a as J,b as V}from"./tanstack-e99Cjjy2.js";import{t as E}from"./notifications-B2HqRBj7.js";import{a4 as Pe,a3 as ke,L as U,aj as De,ai as Be,R as Ie,T as ce,aC as Te,a2 as Re}from"./icons-DrEfTmfX.js";import"./utils-CzKF5WmX.js";import"./form-utils-Bcoyqxpq.js";import"./code-highlight-BRUf_pqB.js";const L=["claude-extension-bindings"];async function P(s,a){const n=await fetch(Ce(s),{headers:{"Content-Type":"application/json"},...a});if(!n.ok){const l=await n.json().catch(()=>null);throw new Error(l?.error||`Request failed (${n.status})`)}return n.status===204?void 0:await n.json()}function qe(){return K({queryKey:["claude-extension-options"],queryFn:()=>P("/claude-extension/profiles")})}function Ae(s,a="vscode"){return K({queryKey:["claude-extension-setup",s,a],enabled:!!s,queryFn:()=>P(`/claude-extension/setup?profile=${encodeURIComponent(s||"")}&host=${encodeURIComponent(a)}`)})}function $e(){return K({queryKey:L,queryFn:()=>P("/claude-extension/bindings")})}function Le(s){return K({queryKey:["claude-extension-binding-status",s],enabled:!!s,queryFn:()=>P(`/claude-extension/bindings/${encodeURIComponent(s||"")}/verify`)})}function Oe(){const s=J();return V({mutationFn:a=>P("/claude-extension/bindings",{method:"POST",body:JSON.stringify(a)}),onSuccess:()=>{s.invalidateQueries({queryKey:L}),E.success("Binding created")},onError:a=>E.error(a.message)})}function Qe(){const s=J();return V({mutationFn:({id:a,binding:n})=>P(`/claude-extension/bindings/${encodeURIComponent(a)}`,{method:"PUT",body:JSON.stringify(n)}),onSuccess:(a,n)=>{s.invalidateQueries({queryKey:L}),s.invalidateQueries({queryKey:["claude-extension-binding-status",n.id]}),E.success("Binding saved")},onError:a=>E.error(a.message)})}function Ue(){const s=J();return V({mutationFn:a=>P(`/claude-extension/bindings/${encodeURIComponent(a)}`,{method:"DELETE"}),onSuccess:()=>{s.invalidateQueries({queryKey:L}),E.success("Binding deleted")},onError:a=>E.error(a.message)})}function ge(s,a){const n=J();return V({mutationFn:({id:l,target:S})=>P(`/claude-extension/bindings/${encodeURIComponent(l)}/${s}`,{method:"POST",body:JSON.stringify({target:S})}),onSuccess:l=>{n.invalidateQueries({queryKey:L}),n.setQueryData(["claude-extension-binding-status",l.bindingId],l),E.success(a)},onError:l=>E.error(l.message)})}function Fe(){return ge("apply","Binding applied")}function Ke(){return ge("reset","Managed values removed")}const Je=[];function oe(s){return{name:"",profile:s,host:"vscode",ideSettingsPath:"",notes:""}}function q(s){return{name:s.name,profile:s.profile,host:s.host,ideSettingsPath:s.ideSettingsPath||"",notes:s.notes||""}}function Ve(s){return{name:s.name.trim(),profile:s.profile.trim(),host:s.host,ideSettingsPath:s.ideSettingsPath.trim()||void 0,notes:s.notes.trim()||void 0}}function me(s){return s?.state==="applied"}function Me({state:s}){const a=s==="applied"?"border-emerald-500/30 bg-emerald-500/10 text-emerald-700 dark:text-emerald-300":s==="drifted"?"border-amber-500/30 bg-amber-500/10 text-amber-700 dark:text-amber-300":s==="missing"?"border-destructive/30 bg-destructive/10 text-destructive":"border-border bg-muted text-muted-foreground";return e.jsx(p,{variant:"outline",className:a,children:s})}function _e(s){return s.replace(/[\\/]/g,"$&​")}function c({label:s,value:a,mono:n=!1,copyValue:l}){const S=typeof l=="string"&&l.trim().length>0;return e.jsxs("div",{className:"grid gap-2 text-sm sm:grid-cols-[112px_minmax(0,1fr)] sm:items-start",children:[e.jsx("span",{className:"text-muted-foreground",children:s}),S?e.jsxs("div",{className:"flex min-w-0 items-start gap-2",children:[e.jsx("div",{className:"min-w-0 flex-1 rounded-md border bg-muted/25 px-3 py-2",children:e.jsx("span",{className:"block text-left font-mono text-xs leading-5 [overflow-wrap:anywhere]",children:_e(a)})}),e.jsx(F,{value:l,label:`Copy ${s.toLowerCase()}`,className:"shrink-0"})]}):e.jsx("span",{className:he("text-left sm:text-right",n&&"font-mono text-xs leading-5 [overflow-wrap:anywhere]"),children:a})]})}function ue({title:s,description:a,value:n}){return e.jsxs(u,{className:"border-border/60 bg-card/80",children:[e.jsx(f,{className:"pb-3",children:e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx(j,{className:"text-base",children:s}),e.jsx(v,{className:"mt-1",children:a})]}),e.jsx(F,{value:n,label:`Copy ${s}`})]})}),e.jsx(x,{children:e.jsx("pre",{className:"max-h-[360px] overflow-auto rounded-lg border bg-muted/30 p-4 text-xs leading-6",children:n})})]})}function xe({title:s,description:a,status:n,applyLabel:l,resetLabel:S,onApply:h,onReset:C,disabled:D,busy:B}){return e.jsxs(u,{className:"border-border/60 bg-card/80",children:[e.jsx(f,{className:"pb-3",children:e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx(j,{className:"text-base",children:s}),e.jsx(v,{className:"mt-1",children:a})]}),n?e.jsx(Me,{state:n.state}):null]})}),e.jsxs(x,{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(c,{label:"Path",value:n?.path||"Save a binding first",mono:!0,copyValue:n?.path}),e.jsx(c,{label:"File",value:n?n.exists?"Present":"Not created yet":"Unavailable"})]}),e.jsx("div",{className:"rounded-lg border bg-muted/25 p-3 text-sm text-muted-foreground",children:n?.message||"Verify the binding after saving to inspect the current file state."}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(y,{size:"sm",className:"flex-1",onClick:h,disabled:D||B,children:[B?e.jsx(U,{className:"mr-1.5 h-3.5 w-3.5 animate-spin"}):null,l]}),e.jsx(y,{size:"sm",variant:"outline",className:"flex-1",onClick:C,disabled:D||B,children:S})]})]})]})}function ze({binding:s,isSelected:a,onSelect:n}){return e.jsx("button",{onClick:n,className:he("w-full rounded-lg border px-3 py-3 text-left transition-colors",a?"border-primary/40 bg-primary/10":"border-border/60 bg-card hover:bg-muted/40"),children:e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"truncate text-sm font-medium",children:s.name}),e.jsxs("div",{className:"mt-1 text-xs text-muted-foreground",children:[s.profile," · ",s.host]})]}),e.jsx(p,{variant:"outline",className:"shrink-0",children:s.usesDefaultIdeSettingsPath?"Default path":"Custom path"})]})})}function as(){const s=qe(),a=$e(),n=Oe(),l=Qe(),S=Ue(),h=Fe(),C=Ke(),D=s.data?.profiles??[],B=s.data?.hosts??[],w=a.data?.bindings??Je,pe=D[0]?.name??"default",[fe,I]=W.useState(!1),[O,T]=W.useState(null),[G,k]=W.useState(()=>oe("default")),o=fe||w.length===0,b=!o&&w.length>0?w.find(t=>t.id===O)??(O?null:w[0]):null,g=b?.id??null,r=o||!b||O?G:q(b),Y=Ae(r.profile,r.host),A=Le(o?void 0:g||void 0),d=B.find(t=>t.id===r.host),M=D.find(t=>t.name===r.profile),_=s.error||a.error||Y.error||A.error,je=`${w.length} saved`,X=n.isPending||l.isPending,ve=h.isPending&&h.variables?.target==="shared"||C.isPending&&C.variables?.target==="shared",be=h.isPending&&h.variables?.target==="ide"||C.isPending&&C.variables?.target==="ide",Z=r.name.trim().length>0&&r.profile.trim().length>0,i=Y.data,m=A.data,ee=Math.max((i?.env.length??0)-6,0),Ne=i?.env.slice(0,6)??[];function z(){I(!0),T(null),k(oe(pe))}async function ye(){if(!Z)return;const t=Ve(r);if(!o&&g){const Q=await l.mutateAsync({id:g,binding:t});I(!1),T(Q.binding.id),k(q(Q.binding));return}const N=await n.mutateAsync(t);I(!1),T(N.binding.id),k(q(N.binding))}async function Se(){if(!g||!b||!window.confirm(`Delete binding "${b.name}"?`))return;await S.mutateAsync(g);const t=w.filter(N=>N.id!==g);t.length>0?(T(t[0].id),I(!1),k(q(t[0]))):z()}function $(t,N){if(!o&&b&&!O){T(b.id),k({...q(b),[t]:N}),I(!1);return}k(Q=>({...Q,[t]:N}))}function R(t,N){if(g){if(N==="apply"){h.mutate({id:g,target:t});return}C.mutate({id:g,target:t})}}return e.jsxs("div",{className:"flex h-[calc(100vh-100px)] min-h-0",children:[e.jsxs("div",{className:"flex w-[348px] shrink-0 flex-col border-r bg-muted/30 xl:w-[372px]",children:[e.jsx("div",{className:"border-b bg-background p-4",children:e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"rounded-lg border bg-muted/40 p-2",children:e.jsx(Pe,{className:"h-5 w-5 text-primary"})}),e.jsxs("div",{children:[e.jsx("h1",{className:"font-semibold",children:"Claude Extension"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Saved IDE bindings for CCS profiles"})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(p,{variant:"secondary",children:je}),d?e.jsx(p,{variant:"outline",children:d.label}):null]})]}),e.jsxs(y,{size:"sm",onClick:z,className:"gap-1.5",children:[e.jsx(ke,{className:"h-3.5 w-3.5"}),"New"]})]})}),e.jsx(se,{className:"flex-1",children:e.jsxs("div",{className:"space-y-4 p-5",children:[e.jsxs(u,{className:"border-border/60 bg-card/80",children:[e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:o?"Create binding":"Binding editor"}),e.jsx(v,{children:"Save a profile + IDE path once, then apply or reset it from the dashboard."})]}),e.jsxs(x,{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"text-sm font-medium",children:"Binding name"}),e.jsx(H,{value:r.name,onChange:t=>$("name",t.target.value),placeholder:"VS Code · work profile"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"text-sm font-medium",children:"CCS profile"}),e.jsxs(te,{value:r.profile,onValueChange:t=>$("profile",t),children:[e.jsx(ae,{children:e.jsx(ne,{placeholder:"Select a profile"})}),e.jsx(ie,{children:D.map(t=>e.jsxs(re,{value:t.name,children:[t.label," (",t.profileType,")"]},t.name))})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:M?.description||"Choose which CCS profile the IDE should inherit."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"text-sm font-medium",children:"IDE host"}),e.jsxs(te,{value:r.host,onValueChange:t=>$("host",t),children:[e.jsx(ae,{children:e.jsx(ne,{placeholder:"Select a host"})}),e.jsx(ie,{children:B.map(t=>e.jsx(re,{value:t.id,children:t.label},t.id))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"text-sm font-medium",children:"IDE settings path"}),e.jsx(H,{value:r.ideSettingsPath,onChange:t=>$("ideSettingsPath",t.target.value),placeholder:d?.defaultSettingsPath||"Leave blank for the default user settings path"}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Leave blank to use the default user settings path for"," ",d?.label||"this IDE","."]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"text-sm font-medium",children:"Notes"}),e.jsx(H,{value:r.notes,onChange:t=>$("notes",t.target.value),placeholder:"Optional reminder for this machine or workspace"})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(y,{className:"flex-1 gap-1.5",onClick:()=>void ye(),disabled:!Z||X,children:[X?e.jsx(U,{className:"h-3.5 w-3.5 animate-spin"}):e.jsx(De,{className:"h-3.5 w-3.5"}),o?"Create":"Save"]}),e.jsx(y,{variant:"outline",onClick:z,children:"Reset form"})]}),o?null:e.jsxs(y,{variant:"outline",className:"w-full gap-1.5 text-destructive hover:text-destructive",onClick:()=>void Se(),disabled:S.isPending,children:[e.jsx(Be,{className:"h-3.5 w-3.5"}),"Delete binding"]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"px-1 text-xs font-medium uppercase tracking-wide text-muted-foreground",children:"Saved bindings"}),e.jsx("div",{className:"space-y-2",children:w.length>0?w.map(t=>e.jsx(ze,{binding:t,isSelected:t.id===g&&!o,onSelect:()=>{I(!1),T(t.id),k(q(t))}},t.id)):e.jsx(u,{className:"border-dashed border-border/60 bg-card/60",children:e.jsx(x,{className:"pt-6 text-sm text-muted-foreground",children:"No saved bindings yet. Create one to manage apply, reset, and drift checks from the dashboard."})})})]})]})})]}),e.jsx("div",{className:"min-w-0 flex-1",children:e.jsx(se,{className:"h-full",children:e.jsxs("div",{className:"w-full space-y-6 p-6 xl:p-7 2xl:p-8",children:[e.jsxs("div",{className:"flex flex-col gap-3 lg:flex-row lg:items-end lg:justify-between",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[M?e.jsx(p,{variant:"outline",children:M.label}):null,d?e.jsx(p,{variant:"outline",children:d.label}):null,o?e.jsx(p,{variant:"secondary",children:"Draft"}):null,m?.sharedSettings&&me(m.sharedSettings)&&me(m.ideSettings)?e.jsx(p,{className:"bg-emerald-600 hover:bg-emerald-600",children:"In sync"}):null]}),e.jsxs("div",{className:"max-w-5xl",children:[e.jsx("h2",{className:"text-2xl font-semibold tracking-tight",children:b?.name||"Claude extension binding"}),e.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:"Manage the shared Claude settings file and the IDE-local settings file as two scoped targets."})]})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(y,{variant:"outline",onClick:()=>void A.refetch(),disabled:o||A.isFetching,children:[A.isFetching?e.jsx(U,{className:"mr-1.5 h-3.5 w-3.5 animate-spin"}):e.jsx(Ie,{className:"mr-1.5 h-3.5 w-3.5"}),"Verify"]}),i?e.jsx(F,{value:i.sharedSettings.command,label:"Copy persist command"}):null]})]}),_?e.jsx(u,{className:"border-destructive/40 bg-destructive/5",children:e.jsxs(x,{className:"flex items-start gap-3 pt-6 text-sm text-destructive",children:[e.jsx(ce,{className:"mt-0.5 h-4 w-4 shrink-0"}),e.jsx("div",{children:_.message})]})}):null,_?null:e.jsxs(we,{defaultValue:"overview",className:"flex flex-col gap-6",children:[e.jsxs(Ee,{className:"w-full justify-start",children:[e.jsx(le,{value:"overview",children:"Overview"}),e.jsx(le,{value:"advanced",children:"Advanced"})]}),e.jsxs(de,{value:"overview",className:"mt-0 space-y-6",children:[e.jsxs("div",{className:"grid gap-6 xl:grid-cols-2",children:[e.jsx(xe,{title:"Shared Claude settings",description:"Writes the managed env block inside ~/.claude/settings.json so CLI and IDE behavior stay aligned.",status:m?.sharedSettings,applyLabel:"Apply shared",resetLabel:"Reset shared",onApply:()=>R("shared","apply"),onReset:()=>R("shared","reset"),disabled:o,busy:ve}),e.jsx(xe,{title:`${d?.label||"IDE"} settings.json`,description:"Writes only the Anthropic extension keys so unrelated editor preferences stay untouched.",status:m?.ideSettings,applyLabel:"Apply IDE",resetLabel:"Reset IDE",onApply:()=>R("ide","apply"),onReset:()=>R("ide","reset"),disabled:o,busy:be})]}),e.jsxs("div",{className:"grid gap-6 xl:grid-cols-[minmax(0,1.15fr)_minmax(320px,0.85fr)]",children:[e.jsxs(u,{className:"border-border/60 bg-card/80",children:[e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:"Resolved binding"}),e.jsx(v,{children:"The binding uses the same profile resolution as `ccs persist` and `ccs env`."})]}),e.jsxs(x,{className:"space-y-3",children:[e.jsx(c,{label:"Profile",value:i?.profile.label||r.profile||"Not selected"}),e.jsx(c,{label:"Profile type",value:i?.profile.profileType||"Unknown"}),e.jsx(c,{label:"IDE host",value:d?.label||"Not selected"}),e.jsx(c,{label:"IDE path mode",value:r.ideSettingsPath.trim()?"Custom path":"Default user path"}),e.jsx(c,{label:"Effective IDE path",value:m?.ideSettings.path||r.ideSettingsPath.trim()||d?.defaultSettingsPath||"Unavailable",mono:!0,copyValue:m?.ideSettings.path||r.ideSettingsPath.trim()||d?.defaultSettingsPath}),e.jsx(c,{label:"Persist command",value:i?.sharedSettings.command||"Save a valid binding first",mono:!0}),r.notes.trim()?e.jsx(c,{label:"Notes",value:r.notes.trim()}):null]})]}),e.jsxs(u,{className:"border-border/60 bg-card/80",children:[e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:"Managed payload"}),e.jsx(v,{children:"Keep the main view short. The full JSON stays in the Advanced tab."})]}),e.jsxs(x,{className:"space-y-4",children:[e.jsxs("div",{className:"flex flex-wrap gap-2",children:[Ne.map(t=>e.jsx(p,{variant:"secondary",className:"font-mono text-[10px]",children:t.name},t.name)),ee>0?e.jsxs(p,{variant:"outline",children:["+",ee," more"]}):null]}),e.jsx("div",{className:"rounded-lg border bg-muted/25 p-4 text-sm",children:i?.env.length?e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"font-medium",children:["CCS will inject ",i.env.length," environment values."]}),e.jsx("div",{className:"text-muted-foreground",children:"The IDE-local target receives the extension schema. The shared target receives the same env block through Claude settings."})]}):e.jsx("div",{className:"text-muted-foreground",children:"This profile resolves to native Claude defaults, so apply/reset mainly clears existing CCS-managed overrides."})}),o?e.jsx("div",{className:"rounded-lg border border-dashed bg-muted/15 p-4 text-sm text-muted-foreground",children:"Save this draft to unlock apply, reset, and verify actions."}):e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(y,{className:"flex-1",onClick:()=>R("all","apply"),disabled:h.isPending,children:[h.isPending&&h.variables?.target==="all"?e.jsx(U,{className:"mr-1.5 h-3.5 w-3.5 animate-spin"}):null,"Apply both targets"]}),e.jsx(y,{variant:"outline",className:"flex-1",onClick:()=>R("all","reset"),disabled:C.isPending,children:"Reset both targets"})]})]})]})]}),i&&(i.warnings.length>0||i.notes.length>0)?e.jsxs("div",{className:"grid gap-6 xl:grid-cols-2",children:[e.jsxs(u,{className:"border-border/60 bg-card/80",children:[e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:"Warnings"}),e.jsx(v,{children:"Operational details that can break the binding even when JSON is correct."})]}),e.jsx(x,{className:"space-y-3",children:i.warnings.length>0?i.warnings.map(t=>e.jsxs("div",{className:"flex items-start gap-3 rounded-lg border border-amber-400/40 bg-amber-50/60 p-3 text-sm dark:bg-amber-950/10",children:[e.jsx(ce,{className:"mt-0.5 h-4 w-4 shrink-0 text-amber-600"}),e.jsx("span",{children:t})]},t)):e.jsx("div",{className:"rounded-lg border bg-muted/20 p-3 text-sm text-muted-foreground",children:"No runtime warnings for this binding."})})]}),e.jsxs(u,{className:"border-border/60 bg-card/80",children:[e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:"Notes"}),e.jsx(v,{children:"Short context from CCS about account continuity and host-specific behavior."})]}),e.jsx(x,{className:"space-y-3",children:i.notes.length>0?i.notes.map(t=>e.jsxs("div",{className:"flex items-start gap-3 rounded-lg border bg-muted/30 p-3 text-sm",children:[e.jsx(Te,{className:"mt-0.5 h-4 w-4 shrink-0 text-muted-foreground"}),e.jsx("span",{children:t})]},t)):e.jsx("div",{className:"rounded-lg border bg-muted/20 p-3 text-sm text-muted-foreground",children:"No extra notes for this binding."})})]})]}):null]}),e.jsx(de,{value:"advanced",className:"mt-0 space-y-6",children:i?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid gap-6 xl:grid-cols-2",children:[e.jsx(ue,{title:"Shared Claude settings JSON",description:"Managed env block for ~/.claude/settings.json.",value:i.sharedSettings.json}),e.jsx(ue,{title:`${d?.label||"IDE"} settings JSON`,description:`Anthropic extension snippet for ${d?.settingsTargetLabel||"settings.json"}.`,value:i.ideSettings.json})]}),e.jsxs(u,{className:"border-border/60 bg-card/80",children:[e.jsx(f,{children:e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx(j,{className:"text-base",children:"Resolved environment payload"}),e.jsx(v,{children:"Exact environment values that the extension receives after CCS expands this profile."})]}),e.jsx(F,{value:JSON.stringify(i.env,null,2),label:"Copy environment payload"})]})}),e.jsx(x,{children:i.env.length>0?e.jsx("pre",{className:"max-h-[420px] overflow-auto rounded-lg border bg-muted/30 p-4 text-xs leading-6",children:JSON.stringify(i.env,null,2)}):e.jsx("div",{className:"rounded-lg border bg-muted/20 p-4 text-sm text-muted-foreground",children:"No env payload. This binding resolves to native Claude defaults."})})]}),e.jsxs("div",{className:"grid gap-6 xl:grid-cols-2",children:[e.jsxs(u,{className:"border-border/60 bg-card/80",children:[e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:"Shared target metadata"}),e.jsx(v,{children:"Useful when debugging drift or comparing with manual edits."})]}),e.jsxs(x,{className:"space-y-3",children:[e.jsx(c,{label:"Target path",value:m?.sharedSettings.path||i.sharedSettings.path,mono:!0,copyValue:m?.sharedSettings.path||i.sharedSettings.path}),e.jsx(c,{label:"Command",value:i.sharedSettings.command,mono:!0}),e.jsx(c,{label:"Current state",value:m?.sharedSettings.state||"Not verified"})]})]}),e.jsxs(u,{className:"border-border/60 bg-card/80",children:[e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:"IDE target metadata"}),e.jsx(v,{children:"Current file path plus the extension setting key used for this host."})]}),e.jsxs(x,{className:"space-y-3",children:[e.jsx(c,{label:"Target path",value:m?.ideSettings.path||r.ideSettingsPath.trim()||d?.defaultSettingsPath||i.ideSettings.path,mono:!0,copyValue:m?.ideSettings.path||r.ideSettingsPath.trim()||d?.defaultSettingsPath||i.ideSettings.path}),e.jsx(c,{label:"Settings key",value:d?.settingsKey||"Unknown",mono:!0}),e.jsx(c,{label:"Current state",value:m?.ideSettings.state||"Not verified"})]})]})]})]}):e.jsx(u,{className:"border-border/60 bg-card/80",children:e.jsxs(x,{className:"flex min-h-[240px] items-center justify-center gap-3 text-sm text-muted-foreground",children:[e.jsx(Re,{className:"h-5 w-5"}),"Choose a profile and IDE host to preview the generated payload."]})})})]})]})})})]})}export{as as ClaudeExtensionPage};
1
+ import{j as e}from"./radix-ui-Dt3edmE5.js";import{r as W}from"./react-vendor-CNOkPC89.js";import{a_ as Ce,B as p,d as y,n as se,C as u,j as f,k as j,_ as v,b as x,I as H,r as te,s as ae,t as ne,v as ie,w as re,x as F,Q as we,R as Ee,U as le,V as de,c as he}from"./index-C-7tLTU2.js";import{u as K,a as J,b as V}from"./tanstack-B8i0evp-.js";import{t as E}from"./notifications-B2HqRBj7.js";import{a4 as Pe,a3 as ke,L as U,aj as De,ai as Be,R as Ie,T as ce,aC as Te,a2 as Re}from"./icons-DtwH984l.js";import"./utils-CzKF5WmX.js";import"./form-utils-Bcoyqxpq.js";import"./code-highlight-BRUf_pqB.js";const L=["claude-extension-bindings"];async function P(s,a){const n=await fetch(Ce(s),{headers:{"Content-Type":"application/json"},...a});if(!n.ok){const l=await n.json().catch(()=>null);throw new Error(l?.error||`Request failed (${n.status})`)}return n.status===204?void 0:await n.json()}function qe(){return K({queryKey:["claude-extension-options"],queryFn:()=>P("/claude-extension/profiles")})}function Ae(s,a="vscode"){return K({queryKey:["claude-extension-setup",s,a],enabled:!!s,queryFn:()=>P(`/claude-extension/setup?profile=${encodeURIComponent(s||"")}&host=${encodeURIComponent(a)}`)})}function $e(){return K({queryKey:L,queryFn:()=>P("/claude-extension/bindings")})}function Le(s){return K({queryKey:["claude-extension-binding-status",s],enabled:!!s,queryFn:()=>P(`/claude-extension/bindings/${encodeURIComponent(s||"")}/verify`)})}function Oe(){const s=J();return V({mutationFn:a=>P("/claude-extension/bindings",{method:"POST",body:JSON.stringify(a)}),onSuccess:()=>{s.invalidateQueries({queryKey:L}),E.success("Binding created")},onError:a=>E.error(a.message)})}function Qe(){const s=J();return V({mutationFn:({id:a,binding:n})=>P(`/claude-extension/bindings/${encodeURIComponent(a)}`,{method:"PUT",body:JSON.stringify(n)}),onSuccess:(a,n)=>{s.invalidateQueries({queryKey:L}),s.invalidateQueries({queryKey:["claude-extension-binding-status",n.id]}),E.success("Binding saved")},onError:a=>E.error(a.message)})}function Ue(){const s=J();return V({mutationFn:a=>P(`/claude-extension/bindings/${encodeURIComponent(a)}`,{method:"DELETE"}),onSuccess:()=>{s.invalidateQueries({queryKey:L}),E.success("Binding deleted")},onError:a=>E.error(a.message)})}function ge(s,a){const n=J();return V({mutationFn:({id:l,target:S})=>P(`/claude-extension/bindings/${encodeURIComponent(l)}/${s}`,{method:"POST",body:JSON.stringify({target:S})}),onSuccess:l=>{n.invalidateQueries({queryKey:L}),n.setQueryData(["claude-extension-binding-status",l.bindingId],l),E.success(a)},onError:l=>E.error(l.message)})}function Fe(){return ge("apply","Binding applied")}function Ke(){return ge("reset","Managed values removed")}const Je=[];function oe(s){return{name:"",profile:s,host:"vscode",ideSettingsPath:"",notes:""}}function q(s){return{name:s.name,profile:s.profile,host:s.host,ideSettingsPath:s.ideSettingsPath||"",notes:s.notes||""}}function Ve(s){return{name:s.name.trim(),profile:s.profile.trim(),host:s.host,ideSettingsPath:s.ideSettingsPath.trim()||void 0,notes:s.notes.trim()||void 0}}function me(s){return s?.state==="applied"}function Me({state:s}){const a=s==="applied"?"border-emerald-500/30 bg-emerald-500/10 text-emerald-700 dark:text-emerald-300":s==="drifted"?"border-amber-500/30 bg-amber-500/10 text-amber-700 dark:text-amber-300":s==="missing"?"border-destructive/30 bg-destructive/10 text-destructive":"border-border bg-muted text-muted-foreground";return e.jsx(p,{variant:"outline",className:a,children:s})}function _e(s){return s.replace(/[\\/]/g,"$&​")}function c({label:s,value:a,mono:n=!1,copyValue:l}){const S=typeof l=="string"&&l.trim().length>0;return e.jsxs("div",{className:"grid gap-2 text-sm sm:grid-cols-[112px_minmax(0,1fr)] sm:items-start",children:[e.jsx("span",{className:"text-muted-foreground",children:s}),S?e.jsxs("div",{className:"flex min-w-0 items-start gap-2",children:[e.jsx("div",{className:"min-w-0 flex-1 rounded-md border bg-muted/25 px-3 py-2",children:e.jsx("span",{className:"block text-left font-mono text-xs leading-5 [overflow-wrap:anywhere]",children:_e(a)})}),e.jsx(F,{value:l,label:`Copy ${s.toLowerCase()}`,className:"shrink-0"})]}):e.jsx("span",{className:he("text-left sm:text-right",n&&"font-mono text-xs leading-5 [overflow-wrap:anywhere]"),children:a})]})}function ue({title:s,description:a,value:n}){return e.jsxs(u,{className:"border-border/60 bg-card/80",children:[e.jsx(f,{className:"pb-3",children:e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx(j,{className:"text-base",children:s}),e.jsx(v,{className:"mt-1",children:a})]}),e.jsx(F,{value:n,label:`Copy ${s}`})]})}),e.jsx(x,{children:e.jsx("pre",{className:"max-h-[360px] overflow-auto rounded-lg border bg-muted/30 p-4 text-xs leading-6",children:n})})]})}function xe({title:s,description:a,status:n,applyLabel:l,resetLabel:S,onApply:h,onReset:C,disabled:D,busy:B}){return e.jsxs(u,{className:"border-border/60 bg-card/80",children:[e.jsx(f,{className:"pb-3",children:e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx(j,{className:"text-base",children:s}),e.jsx(v,{className:"mt-1",children:a})]}),n?e.jsx(Me,{state:n.state}):null]})}),e.jsxs(x,{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(c,{label:"Path",value:n?.path||"Save a binding first",mono:!0,copyValue:n?.path}),e.jsx(c,{label:"File",value:n?n.exists?"Present":"Not created yet":"Unavailable"})]}),e.jsx("div",{className:"rounded-lg border bg-muted/25 p-3 text-sm text-muted-foreground",children:n?.message||"Verify the binding after saving to inspect the current file state."}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(y,{size:"sm",className:"flex-1",onClick:h,disabled:D||B,children:[B?e.jsx(U,{className:"mr-1.5 h-3.5 w-3.5 animate-spin"}):null,l]}),e.jsx(y,{size:"sm",variant:"outline",className:"flex-1",onClick:C,disabled:D||B,children:S})]})]})]})}function ze({binding:s,isSelected:a,onSelect:n}){return e.jsx("button",{onClick:n,className:he("w-full rounded-lg border px-3 py-3 text-left transition-colors",a?"border-primary/40 bg-primary/10":"border-border/60 bg-card hover:bg-muted/40"),children:e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"truncate text-sm font-medium",children:s.name}),e.jsxs("div",{className:"mt-1 text-xs text-muted-foreground",children:[s.profile," · ",s.host]})]}),e.jsx(p,{variant:"outline",className:"shrink-0",children:s.usesDefaultIdeSettingsPath?"Default path":"Custom path"})]})})}function as(){const s=qe(),a=$e(),n=Oe(),l=Qe(),S=Ue(),h=Fe(),C=Ke(),D=s.data?.profiles??[],B=s.data?.hosts??[],w=a.data?.bindings??Je,pe=D[0]?.name??"default",[fe,I]=W.useState(!1),[O,T]=W.useState(null),[G,k]=W.useState(()=>oe("default")),o=fe||w.length===0,b=!o&&w.length>0?w.find(t=>t.id===O)??(O?null:w[0]):null,g=b?.id??null,r=o||!b||O?G:q(b),Y=Ae(r.profile,r.host),A=Le(o?void 0:g||void 0),d=B.find(t=>t.id===r.host),M=D.find(t=>t.name===r.profile),_=s.error||a.error||Y.error||A.error,je=`${w.length} saved`,X=n.isPending||l.isPending,ve=h.isPending&&h.variables?.target==="shared"||C.isPending&&C.variables?.target==="shared",be=h.isPending&&h.variables?.target==="ide"||C.isPending&&C.variables?.target==="ide",Z=r.name.trim().length>0&&r.profile.trim().length>0,i=Y.data,m=A.data,ee=Math.max((i?.env.length??0)-6,0),Ne=i?.env.slice(0,6)??[];function z(){I(!0),T(null),k(oe(pe))}async function ye(){if(!Z)return;const t=Ve(r);if(!o&&g){const Q=await l.mutateAsync({id:g,binding:t});I(!1),T(Q.binding.id),k(q(Q.binding));return}const N=await n.mutateAsync(t);I(!1),T(N.binding.id),k(q(N.binding))}async function Se(){if(!g||!b||!window.confirm(`Delete binding "${b.name}"?`))return;await S.mutateAsync(g);const t=w.filter(N=>N.id!==g);t.length>0?(T(t[0].id),I(!1),k(q(t[0]))):z()}function $(t,N){if(!o&&b&&!O){T(b.id),k({...q(b),[t]:N}),I(!1);return}k(Q=>({...Q,[t]:N}))}function R(t,N){if(g){if(N==="apply"){h.mutate({id:g,target:t});return}C.mutate({id:g,target:t})}}return e.jsxs("div",{className:"flex h-[calc(100vh-100px)] min-h-0",children:[e.jsxs("div",{className:"flex w-[348px] shrink-0 flex-col border-r bg-muted/30 xl:w-[372px]",children:[e.jsx("div",{className:"border-b bg-background p-4",children:e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"rounded-lg border bg-muted/40 p-2",children:e.jsx(Pe,{className:"h-5 w-5 text-primary"})}),e.jsxs("div",{children:[e.jsx("h1",{className:"font-semibold",children:"Claude Extension"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Saved IDE bindings for CCS profiles"})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(p,{variant:"secondary",children:je}),d?e.jsx(p,{variant:"outline",children:d.label}):null]})]}),e.jsxs(y,{size:"sm",onClick:z,className:"gap-1.5",children:[e.jsx(ke,{className:"h-3.5 w-3.5"}),"New"]})]})}),e.jsx(se,{className:"flex-1",children:e.jsxs("div",{className:"space-y-4 p-5",children:[e.jsxs(u,{className:"border-border/60 bg-card/80",children:[e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:o?"Create binding":"Binding editor"}),e.jsx(v,{children:"Save a profile + IDE path once, then apply or reset it from the dashboard."})]}),e.jsxs(x,{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"text-sm font-medium",children:"Binding name"}),e.jsx(H,{value:r.name,onChange:t=>$("name",t.target.value),placeholder:"VS Code · work profile"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"text-sm font-medium",children:"CCS profile"}),e.jsxs(te,{value:r.profile,onValueChange:t=>$("profile",t),children:[e.jsx(ae,{children:e.jsx(ne,{placeholder:"Select a profile"})}),e.jsx(ie,{children:D.map(t=>e.jsxs(re,{value:t.name,children:[t.label," (",t.profileType,")"]},t.name))})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:M?.description||"Choose which CCS profile the IDE should inherit."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"text-sm font-medium",children:"IDE host"}),e.jsxs(te,{value:r.host,onValueChange:t=>$("host",t),children:[e.jsx(ae,{children:e.jsx(ne,{placeholder:"Select a host"})}),e.jsx(ie,{children:B.map(t=>e.jsx(re,{value:t.id,children:t.label},t.id))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"text-sm font-medium",children:"IDE settings path"}),e.jsx(H,{value:r.ideSettingsPath,onChange:t=>$("ideSettingsPath",t.target.value),placeholder:d?.defaultSettingsPath||"Leave blank for the default user settings path"}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Leave blank to use the default user settings path for"," ",d?.label||"this IDE","."]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"text-sm font-medium",children:"Notes"}),e.jsx(H,{value:r.notes,onChange:t=>$("notes",t.target.value),placeholder:"Optional reminder for this machine or workspace"})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(y,{className:"flex-1 gap-1.5",onClick:()=>void ye(),disabled:!Z||X,children:[X?e.jsx(U,{className:"h-3.5 w-3.5 animate-spin"}):e.jsx(De,{className:"h-3.5 w-3.5"}),o?"Create":"Save"]}),e.jsx(y,{variant:"outline",onClick:z,children:"Reset form"})]}),o?null:e.jsxs(y,{variant:"outline",className:"w-full gap-1.5 text-destructive hover:text-destructive",onClick:()=>void Se(),disabled:S.isPending,children:[e.jsx(Be,{className:"h-3.5 w-3.5"}),"Delete binding"]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"px-1 text-xs font-medium uppercase tracking-wide text-muted-foreground",children:"Saved bindings"}),e.jsx("div",{className:"space-y-2",children:w.length>0?w.map(t=>e.jsx(ze,{binding:t,isSelected:t.id===g&&!o,onSelect:()=>{I(!1),T(t.id),k(q(t))}},t.id)):e.jsx(u,{className:"border-dashed border-border/60 bg-card/60",children:e.jsx(x,{className:"pt-6 text-sm text-muted-foreground",children:"No saved bindings yet. Create one to manage apply, reset, and drift checks from the dashboard."})})})]})]})})]}),e.jsx("div",{className:"min-w-0 flex-1",children:e.jsx(se,{className:"h-full",children:e.jsxs("div",{className:"w-full space-y-6 p-6 xl:p-7 2xl:p-8",children:[e.jsxs("div",{className:"flex flex-col gap-3 lg:flex-row lg:items-end lg:justify-between",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[M?e.jsx(p,{variant:"outline",children:M.label}):null,d?e.jsx(p,{variant:"outline",children:d.label}):null,o?e.jsx(p,{variant:"secondary",children:"Draft"}):null,m?.sharedSettings&&me(m.sharedSettings)&&me(m.ideSettings)?e.jsx(p,{className:"bg-emerald-600 hover:bg-emerald-600",children:"In sync"}):null]}),e.jsxs("div",{className:"max-w-5xl",children:[e.jsx("h2",{className:"text-2xl font-semibold tracking-tight",children:b?.name||"Claude extension binding"}),e.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:"Manage the shared Claude settings file and the IDE-local settings file as two scoped targets."})]})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(y,{variant:"outline",onClick:()=>void A.refetch(),disabled:o||A.isFetching,children:[A.isFetching?e.jsx(U,{className:"mr-1.5 h-3.5 w-3.5 animate-spin"}):e.jsx(Ie,{className:"mr-1.5 h-3.5 w-3.5"}),"Verify"]}),i?e.jsx(F,{value:i.sharedSettings.command,label:"Copy persist command"}):null]})]}),_?e.jsx(u,{className:"border-destructive/40 bg-destructive/5",children:e.jsxs(x,{className:"flex items-start gap-3 pt-6 text-sm text-destructive",children:[e.jsx(ce,{className:"mt-0.5 h-4 w-4 shrink-0"}),e.jsx("div",{children:_.message})]})}):null,_?null:e.jsxs(we,{defaultValue:"overview",className:"flex flex-col gap-6",children:[e.jsxs(Ee,{className:"w-full justify-start",children:[e.jsx(le,{value:"overview",children:"Overview"}),e.jsx(le,{value:"advanced",children:"Advanced"})]}),e.jsxs(de,{value:"overview",className:"mt-0 space-y-6",children:[e.jsxs("div",{className:"grid gap-6 xl:grid-cols-2",children:[e.jsx(xe,{title:"Shared Claude settings",description:"Writes the managed env block inside ~/.claude/settings.json so CLI and IDE behavior stay aligned.",status:m?.sharedSettings,applyLabel:"Apply shared",resetLabel:"Reset shared",onApply:()=>R("shared","apply"),onReset:()=>R("shared","reset"),disabled:o,busy:ve}),e.jsx(xe,{title:`${d?.label||"IDE"} settings.json`,description:"Writes only the Anthropic extension keys so unrelated editor preferences stay untouched.",status:m?.ideSettings,applyLabel:"Apply IDE",resetLabel:"Reset IDE",onApply:()=>R("ide","apply"),onReset:()=>R("ide","reset"),disabled:o,busy:be})]}),e.jsxs("div",{className:"grid gap-6 xl:grid-cols-[minmax(0,1.15fr)_minmax(320px,0.85fr)]",children:[e.jsxs(u,{className:"border-border/60 bg-card/80",children:[e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:"Resolved binding"}),e.jsx(v,{children:"The binding uses the same profile resolution as `ccs persist` and `ccs env`."})]}),e.jsxs(x,{className:"space-y-3",children:[e.jsx(c,{label:"Profile",value:i?.profile.label||r.profile||"Not selected"}),e.jsx(c,{label:"Profile type",value:i?.profile.profileType||"Unknown"}),e.jsx(c,{label:"IDE host",value:d?.label||"Not selected"}),e.jsx(c,{label:"IDE path mode",value:r.ideSettingsPath.trim()?"Custom path":"Default user path"}),e.jsx(c,{label:"Effective IDE path",value:m?.ideSettings.path||r.ideSettingsPath.trim()||d?.defaultSettingsPath||"Unavailable",mono:!0,copyValue:m?.ideSettings.path||r.ideSettingsPath.trim()||d?.defaultSettingsPath}),e.jsx(c,{label:"Persist command",value:i?.sharedSettings.command||"Save a valid binding first",mono:!0}),r.notes.trim()?e.jsx(c,{label:"Notes",value:r.notes.trim()}):null]})]}),e.jsxs(u,{className:"border-border/60 bg-card/80",children:[e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:"Managed payload"}),e.jsx(v,{children:"Keep the main view short. The full JSON stays in the Advanced tab."})]}),e.jsxs(x,{className:"space-y-4",children:[e.jsxs("div",{className:"flex flex-wrap gap-2",children:[Ne.map(t=>e.jsx(p,{variant:"secondary",className:"font-mono text-[10px]",children:t.name},t.name)),ee>0?e.jsxs(p,{variant:"outline",children:["+",ee," more"]}):null]}),e.jsx("div",{className:"rounded-lg border bg-muted/25 p-4 text-sm",children:i?.env.length?e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"font-medium",children:["CCS will inject ",i.env.length," environment values."]}),e.jsx("div",{className:"text-muted-foreground",children:"The IDE-local target receives the extension schema. The shared target receives the same env block through Claude settings."})]}):e.jsx("div",{className:"text-muted-foreground",children:"This profile resolves to native Claude defaults, so apply/reset mainly clears existing CCS-managed overrides."})}),o?e.jsx("div",{className:"rounded-lg border border-dashed bg-muted/15 p-4 text-sm text-muted-foreground",children:"Save this draft to unlock apply, reset, and verify actions."}):e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(y,{className:"flex-1",onClick:()=>R("all","apply"),disabled:h.isPending,children:[h.isPending&&h.variables?.target==="all"?e.jsx(U,{className:"mr-1.5 h-3.5 w-3.5 animate-spin"}):null,"Apply both targets"]}),e.jsx(y,{variant:"outline",className:"flex-1",onClick:()=>R("all","reset"),disabled:C.isPending,children:"Reset both targets"})]})]})]})]}),i&&(i.warnings.length>0||i.notes.length>0)?e.jsxs("div",{className:"grid gap-6 xl:grid-cols-2",children:[e.jsxs(u,{className:"border-border/60 bg-card/80",children:[e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:"Warnings"}),e.jsx(v,{children:"Operational details that can break the binding even when JSON is correct."})]}),e.jsx(x,{className:"space-y-3",children:i.warnings.length>0?i.warnings.map(t=>e.jsxs("div",{className:"flex items-start gap-3 rounded-lg border border-amber-400/40 bg-amber-50/60 p-3 text-sm dark:bg-amber-950/10",children:[e.jsx(ce,{className:"mt-0.5 h-4 w-4 shrink-0 text-amber-600"}),e.jsx("span",{children:t})]},t)):e.jsx("div",{className:"rounded-lg border bg-muted/20 p-3 text-sm text-muted-foreground",children:"No runtime warnings for this binding."})})]}),e.jsxs(u,{className:"border-border/60 bg-card/80",children:[e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:"Notes"}),e.jsx(v,{children:"Short context from CCS about account continuity and host-specific behavior."})]}),e.jsx(x,{className:"space-y-3",children:i.notes.length>0?i.notes.map(t=>e.jsxs("div",{className:"flex items-start gap-3 rounded-lg border bg-muted/30 p-3 text-sm",children:[e.jsx(Te,{className:"mt-0.5 h-4 w-4 shrink-0 text-muted-foreground"}),e.jsx("span",{children:t})]},t)):e.jsx("div",{className:"rounded-lg border bg-muted/20 p-3 text-sm text-muted-foreground",children:"No extra notes for this binding."})})]})]}):null]}),e.jsx(de,{value:"advanced",className:"mt-0 space-y-6",children:i?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid gap-6 xl:grid-cols-2",children:[e.jsx(ue,{title:"Shared Claude settings JSON",description:"Managed env block for ~/.claude/settings.json.",value:i.sharedSettings.json}),e.jsx(ue,{title:`${d?.label||"IDE"} settings JSON`,description:`Anthropic extension snippet for ${d?.settingsTargetLabel||"settings.json"}.`,value:i.ideSettings.json})]}),e.jsxs(u,{className:"border-border/60 bg-card/80",children:[e.jsx(f,{children:e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx(j,{className:"text-base",children:"Resolved environment payload"}),e.jsx(v,{children:"Exact environment values that the extension receives after CCS expands this profile."})]}),e.jsx(F,{value:JSON.stringify(i.env,null,2),label:"Copy environment payload"})]})}),e.jsx(x,{children:i.env.length>0?e.jsx("pre",{className:"max-h-[420px] overflow-auto rounded-lg border bg-muted/30 p-4 text-xs leading-6",children:JSON.stringify(i.env,null,2)}):e.jsx("div",{className:"rounded-lg border bg-muted/20 p-4 text-sm text-muted-foreground",children:"No env payload. This binding resolves to native Claude defaults."})})]}),e.jsxs("div",{className:"grid gap-6 xl:grid-cols-2",children:[e.jsxs(u,{className:"border-border/60 bg-card/80",children:[e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:"Shared target metadata"}),e.jsx(v,{children:"Useful when debugging drift or comparing with manual edits."})]}),e.jsxs(x,{className:"space-y-3",children:[e.jsx(c,{label:"Target path",value:m?.sharedSettings.path||i.sharedSettings.path,mono:!0,copyValue:m?.sharedSettings.path||i.sharedSettings.path}),e.jsx(c,{label:"Command",value:i.sharedSettings.command,mono:!0}),e.jsx(c,{label:"Current state",value:m?.sharedSettings.state||"Not verified"})]})]}),e.jsxs(u,{className:"border-border/60 bg-card/80",children:[e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:"IDE target metadata"}),e.jsx(v,{children:"Current file path plus the extension setting key used for this host."})]}),e.jsxs(x,{className:"space-y-3",children:[e.jsx(c,{label:"Target path",value:m?.ideSettings.path||r.ideSettingsPath.trim()||d?.defaultSettingsPath||i.ideSettings.path,mono:!0,copyValue:m?.ideSettings.path||r.ideSettingsPath.trim()||d?.defaultSettingsPath||i.ideSettings.path}),e.jsx(c,{label:"Settings key",value:d?.settingsKey||"Unknown",mono:!0}),e.jsx(c,{label:"Current state",value:m?.ideSettings.state||"Not verified"})]})]})]})]}):e.jsx(u,{className:"border-border/60 bg-card/80",children:e.jsxs(x,{className:"flex min-h-[240px] items-center justify-center gap-3 text-sm text-muted-foreground",children:[e.jsx(Re,{className:"h-5 w-5"}),"Choose a profile and IDE host to preview the generated payload."]})})})]})]})})})]})}export{as as ClaudeExtensionPage};
@@ -0,0 +1,3 @@
1
+ import{j as e}from"./radix-ui-Dt3edmE5.js";import{r as o}from"./react-vendor-CNOkPC89.js";import{a as Be,u as fs,b as $s}from"./tanstack-B8i0evp-.js";import{d as R,C as js,b as vs,c as G,P as Ae,a as Z,a8 as ee,L as X,I as le,r as Ns,s as ys,t as bs,v as ws,w as Ie,a9 as ks,aa as Qs,ab as zs,ac as Js,u as Cs,ad as Ve,ae as Ge,af as $e,ag as Qe,ah as As,ai as ns,aj as Ws,ak as Ys,W as Ss,al as Fe,am as Ps,Y as we,B,an as Ue,ao as is,ap as Xs,aq as Zs,ar as et,as as st,at as tt,x as Ms,n as ze,au as Je,m as at,av as nt,aw as it,ax as rt,ay as ot,az as lt,aA as ct,aB as dt,aC as pe,T as he,p as ge,q as fe,aD as ut,aE as mt,aF as xt,aG as rs,aH as pt,aI as ht,aJ as gt,aK as ft,aL as jt,aM as vt,aN as Nt,Q as yt,R as bt,U as os,V as ls,aO as wt,aP as kt,aQ as Ct,aR as At,aS as St,aT as Pt,aU as Mt,aV as Tt,aW as Dt,aX as Ot,aY as Et,aZ as _t,S as Rt}from"./index-C-7tLTU2.js";import{C as He}from"./default-ports-1QQSffYX.js";import{t as q}from"./notifications-B2HqRBj7.js";import{C as Ts,L as W,o as me,Q as Lt,l as ce,n as Ds,as as We,R as Ye,p as xe,a4 as ve,T as Se,a2 as It,at as Os,ar as Ft,au as Pe,Z as Ne,O as Es,h as Ut,t as _s,av as Ht,aj as qt,X as Xe,a3 as Rs,m as Kt,x as Bt,y as Ls,z as qe,aw as Vt,u as cs,ax as Gt,ai as Is,v as $t,ay as ds,am as Qt,az as Fs}from"./icons-DtwH984l.js";import{R as ke,A as us,D as _e,i as zt,a as Jt,P as Wt}from"./proxy-status-widget-DloYg7yP.js";import{C as Ce}from"./checkbox-D470Q1y9.js";import{C as Yt}from"./confirm-dialog-BnNUvB5u.js";import{S as Ze}from"./separator-DzrBeBn-.js";import{S as Xt}from"./searchable-select-CSREngvO.js";import{S as Us}from"./switch-BP9rnaI6.js";import"./utils-CzKF5WmX.js";import"./form-utils-Bcoyqxpq.js";import"./code-highlight-BRUf_pqB.js";import"./alert-dialog-D0M-j0xk.js";const je={agy:{provider:"agy",displayName:"Antigravity",defaultModel:"claude-opus-4-6-thinking",models:[{id:"claude-opus-4-6-thinking",name:"Claude Opus 4.6 Thinking",description:"Latest flagship, extended thinking",extendedContext:!1,presetMapping:{default:"claude-opus-4-6-thinking",opus:"claude-opus-4-6-thinking",sonnet:"claude-sonnet-4-6",haiku:"claude-sonnet-4-6"}},{id:"claude-sonnet-4-6",name:"Claude Sonnet 4.6",description:"Latest Sonnet with thinking budget support",presetMapping:{default:"claude-sonnet-4-6",opus:"claude-opus-4-6-thinking",sonnet:"claude-sonnet-4-6",haiku:"claude-sonnet-4-6"}},{id:"gemini-3-pro-preview",name:"Gemini 3 Pro",description:"Google latest model via Antigravity",extendedContext:!0,presetMapping:{default:"gemini-3-pro-preview",opus:"gemini-3-pro-preview",sonnet:"gemini-3-pro-preview",haiku:"gemini-3-flash-preview"}},{id:"gemini-3-flash-preview",name:"Gemini 3 Flash",description:"Fast Gemini model via Antigravity",extendedContext:!0,presetMapping:{default:"gemini-3-flash-preview",opus:"gemini-3-pro-preview",sonnet:"gemini-3-pro-preview",haiku:"gemini-3-flash-preview"}}]},gemini:{provider:"gemini",displayName:"Gemini",defaultModel:"gemini-2.5-pro",models:[{id:"gemini-3-pro-preview",name:"Gemini 3 Pro",tier:"paid",description:"Latest model, requires paid Google account",extendedContext:!0,presetMapping:{default:"gemini-3-pro-preview",opus:"gemini-3-pro-preview",sonnet:"gemini-3-pro-preview",haiku:"gemini-3-flash-preview"}},{id:"gemini-3-flash-preview",name:"Gemini 3 Flash",tier:"paid",description:"Fast Gemini 3 model, requires paid Google account",extendedContext:!0,presetMapping:{default:"gemini-3-flash-preview",opus:"gemini-3-pro-preview",sonnet:"gemini-3-pro-preview",haiku:"gemini-3-flash-preview"}},{id:"gemini-2.5-pro",name:"Gemini 2.5 Pro",description:"Stable, works with free Google account",extendedContext:!0,presetMapping:{default:"gemini-2.5-pro",opus:"gemini-2.5-pro",sonnet:"gemini-2.5-pro",haiku:"gemini-2.5-flash"}}]},codex:{provider:"codex",displayName:"Codex",defaultModel:"gpt-5-codex",models:[{id:"gpt-5-codex",name:"GPT-5 Codex",description:"Cross-plan safe Codex default",presetMapping:{default:"gpt-5-codex",opus:"gpt-5-codex",sonnet:"gpt-5-codex",haiku:"gpt-5-codex-mini"}},{id:"gpt-5-codex-mini",name:"GPT-5 Codex Mini",description:"Faster and cheaper Codex option",presetMapping:{default:"gpt-5-codex-mini",opus:"gpt-5-codex",sonnet:"gpt-5-codex",haiku:"gpt-5-codex-mini"}},{id:"gpt-5-mini",name:"GPT-5 Mini",description:"Legacy mini model ID kept for backwards compatibility",presetMapping:{default:"gpt-5-mini",opus:"gpt-5-codex",sonnet:"gpt-5-mini",haiku:"gpt-5-mini"}},{id:"gpt-5.1-codex-mini",name:"GPT-5.1 Codex Mini",description:"Legacy fast Codex mini model",presetMapping:{default:"gpt-5.1-codex-mini",opus:"gpt-5.1-codex-max",sonnet:"gpt-5.1-codex-max",haiku:"gpt-5.1-codex-mini"}},{id:"gpt-5.1-codex-max",name:"GPT-5.1 Codex Max",description:"Higher-effort Codex model with xhigh support",presetMapping:{default:"gpt-5.1-codex-max",opus:"gpt-5.1-codex-max",sonnet:"gpt-5.1-codex-max",haiku:"gpt-5.1-codex-mini"}},{id:"gpt-5.2-codex",name:"GPT-5.2 Codex",description:"Cross-plan Codex model with xhigh support",presetMapping:{default:"gpt-5.2-codex",opus:"gpt-5.2-codex",sonnet:"gpt-5.2-codex",haiku:"gpt-5-codex-mini"}},{id:"gpt-5.3-codex",name:"GPT-5.3 Codex",tier:"paid",description:"Paid Codex plans only",presetMapping:{default:"gpt-5.3-codex",opus:"gpt-5.3-codex",sonnet:"gpt-5.3-codex",haiku:"gpt-5-codex-mini"}},{id:"gpt-5.3-codex-spark",name:"GPT-5.3 Codex Spark",tier:"paid",description:"Paid Codex plans only, ultra-fast coding model",presetMapping:{default:"gpt-5.3-codex-spark",opus:"gpt-5.3-codex",sonnet:"gpt-5.3-codex",haiku:"gpt-5-codex-mini"}},{id:"gpt-5.4",name:"GPT-5.4",tier:"paid",description:"Paid Codex plans only, latest GPT-5 family model",presetMapping:{default:"gpt-5.4",opus:"gpt-5.4",sonnet:"gpt-5.4",haiku:"gpt-5-codex-mini"}}]},qwen:{provider:"qwen",displayName:"Qwen",defaultModel:"qwen3-coder-plus",models:[{id:"qwen3-coder-plus",name:"Qwen3 Coder Plus",description:"Code-focused model (1M context)",presetMapping:{default:"qwen3-coder-plus",opus:"qwen3-max",sonnet:"qwen3-coder-plus",haiku:"qwen3-coder-flash"}},{id:"qwen3-max",name:"Qwen3 Max",description:"Flagship model (256K context)",presetMapping:{default:"qwen3-max",opus:"qwen3-max",sonnet:"qwen3-coder-plus",haiku:"qwen3-coder-flash"}},{id:"qwen3-max-preview",name:"Qwen3 Max Preview",description:"Preview with thinking support (256K)",presetMapping:{default:"qwen3-max-preview",opus:"qwen3-max-preview",sonnet:"qwen3-max",haiku:"qwen3-coder-flash"}},{id:"qwen3-235b",name:"Qwen3 235B",description:"Large 235B A22B model",presetMapping:{default:"qwen3-235b",opus:"qwen3-max",sonnet:"qwen3-235b",haiku:"qwen3-coder-flash"}},{id:"qwen3-vl-plus",name:"Qwen3 VL Plus",description:"Vision-language multimodal"},{id:"qwen3-coder-flash",name:"Qwen3 Coder Flash",description:"Fast code generation"},{id:"qwen3-32b",name:"Qwen3 32B",description:"Qwen3 32B model"}]},iflow:{provider:"iflow",displayName:"iFlow",defaultModel:"qwen3-coder-plus",models:[{id:"qwen3-coder-plus",name:"Qwen3 Coder Plus",description:"Recommended default for iFlow accounts",presetMapping:{default:"qwen3-coder-plus",opus:"qwen3-coder-plus",sonnet:"qwen3-coder-plus",haiku:"qwen3-coder-plus"}},{id:"qwen3-max",name:"Qwen3 Max",description:"Flagship Qwen model via iFlow"},{id:"kimi-k2",name:"Kimi K2",description:"Kimi model currently available via iFlow"},{id:"deepseek-v3.2",name:"DeepSeek V3.2",description:"Current DeepSeek V3.2 model via iFlow"},{id:"deepseek-r1",name:"DeepSeek R1",description:"Reasoning-focused DeepSeek model"},{id:"glm-4.6",name:"GLM 4.6",description:"Zhipu GLM 4.6 via iFlow"},{id:"qwen3-vl-plus",name:"Qwen3 VL Plus",description:"Vision-language model"}]},kimi:{provider:"kimi",displayName:"Kimi (Moonshot)",defaultModel:"kimi-k2.5",models:[{id:"kimi-k2.5",name:"Kimi K2.5",description:"Latest multimodal model (262K context)",presetMapping:{default:"kimi-k2.5",opus:"kimi-k2.5",sonnet:"kimi-k2-thinking",haiku:"kimi-k2"}},{id:"kimi-k2-thinking",name:"Kimi K2 Thinking",description:"Extended reasoning model",presetMapping:{default:"kimi-k2-thinking",opus:"kimi-k2.5",sonnet:"kimi-k2-thinking",haiku:"kimi-k2"}},{id:"kimi-k2",name:"Kimi K2",description:"Flagship coding model"}]},kiro:{provider:"kiro",displayName:"Kiro (AWS)",defaultModel:"kiro-claude-sonnet-4-5",models:[{id:"kiro-claude-opus-4-5",name:"Kiro Claude Opus 4.5",description:"Claude Opus 4.5 via Kiro (2.2x credit)",presetMapping:{default:"kiro-claude-opus-4-5",opus:"kiro-claude-opus-4-5",sonnet:"kiro-claude-sonnet-4-5",haiku:"kiro-claude-haiku-4-5"}},{id:"kiro-claude-sonnet-4-5",name:"Kiro Claude Sonnet 4.5",description:"Claude Sonnet 4.5 via Kiro (1.3x credit)",presetMapping:{default:"kiro-claude-sonnet-4-5",opus:"kiro-claude-opus-4-5",sonnet:"kiro-claude-sonnet-4-5",haiku:"kiro-claude-haiku-4-5"}},{id:"kiro-claude-sonnet-4",name:"Kiro Claude Sonnet 4",description:"Claude Sonnet 4 via Kiro (1.3x credit)",presetMapping:{default:"kiro-claude-sonnet-4",opus:"kiro-claude-opus-4-5",sonnet:"kiro-claude-sonnet-4",haiku:"kiro-claude-haiku-4-5"}},{id:"kiro-claude-haiku-4-5",name:"Kiro Claude Haiku 4.5",description:"Claude Haiku 4.5 via Kiro (0.4x credit)"}]},ghcp:{provider:"ghcp",displayName:"GitHub Copilot (OAuth)",defaultModel:"claude-sonnet-4.5",models:[{id:"claude-opus-4.5",name:"Claude Opus 4.5",description:"Anthropic Claude Opus 4.5 via GitHub Copilot",presetMapping:{default:"claude-opus-4.5",opus:"claude-opus-4.5",sonnet:"claude-sonnet-4.5",haiku:"claude-haiku-4.5"}},{id:"claude-sonnet-4.5",name:"Claude Sonnet 4.5",description:"Anthropic Claude Sonnet 4.5 via GitHub Copilot",presetMapping:{default:"claude-sonnet-4.5",opus:"claude-opus-4.5",sonnet:"claude-sonnet-4.5",haiku:"claude-haiku-4.5"}},{id:"claude-sonnet-4",name:"Claude Sonnet 4",description:"Anthropic Claude Sonnet 4 via GitHub Copilot"},{id:"claude-haiku-4.5",name:"Claude Haiku 4.5",description:"Anthropic Claude Haiku 4.5 via GitHub Copilot"},{id:"gpt-5.2",name:"GPT-5.2",description:"OpenAI GPT-5.2 via GitHub Copilot",presetMapping:{default:"gpt-5.2",opus:"gpt-5.2",sonnet:"gpt-5.1",haiku:"gpt-5-mini"}},{id:"gpt-5.1",name:"GPT-5.1",description:"OpenAI GPT-5.1 via GitHub Copilot"},{id:"gpt-5",name:"GPT-5",description:"OpenAI GPT-5 via GitHub Copilot"},{id:"gpt-5-mini",name:"GPT-5 Mini",description:"OpenAI GPT-5 Mini via GitHub Copilot"},{id:"gemini-3-pro",name:"Gemini 3 Pro",description:"Google Gemini 3 Pro via GitHub Copilot"}]},claude:{provider:"claude",displayName:"Claude (Anthropic)",defaultModel:"claude-sonnet-4-6",models:[{id:"claude-opus-4-6",name:"Claude Opus 4.6",description:"Latest flagship model",extendedContext:!0,presetMapping:{default:"claude-opus-4-6",opus:"claude-opus-4-6",sonnet:"claude-sonnet-4-6",haiku:"claude-haiku-4-5-20251001"}},{id:"claude-sonnet-4-6",name:"Claude Sonnet 4.6",description:"Balanced performance and speed",extendedContext:!0,presetMapping:{default:"claude-sonnet-4-6",opus:"claude-opus-4-6",sonnet:"claude-sonnet-4-6",haiku:"claude-haiku-4-5-20251001"}},{id:"claude-opus-4-5-20251101",name:"Claude Opus 4.5",description:"Most capable Claude model",extendedContext:!0,presetMapping:{default:"claude-opus-4-5-20251101",opus:"claude-opus-4-5-20251101",sonnet:"claude-sonnet-4-5-20250929",haiku:"claude-haiku-4-5-20251001"}},{id:"claude-sonnet-4-5-20250929",name:"Claude Sonnet 4.5",description:"Balanced performance and speed",extendedContext:!0,presetMapping:{default:"claude-sonnet-4-5-20250929",opus:"claude-opus-4-5-20251101",sonnet:"claude-sonnet-4-5-20250929",haiku:"claude-haiku-4-5-20251001"}},{id:"claude-sonnet-4-20250514",name:"Claude Sonnet 4",description:"Previous generation Sonnet",extendedContext:!0,presetMapping:{default:"claude-sonnet-4-20250514",opus:"claude-opus-4-5-20251101",sonnet:"claude-sonnet-4-20250514",haiku:"claude-haiku-4-5-20251001"}},{id:"claude-haiku-4-5-20251001",name:"Claude Haiku 4.5",description:"Fast and efficient"}]}},Re="ccs-internal-managed";async function Zt(){try{const s=await fetch("/api/settings/auth/tokens/raw");return s.ok?(await s.json())?.apiKey?.value??Re:Re}catch{return Re}}async function Ke(s,t){const a=je[s];if(!a)return{success:!1};const n=a.models.find(x=>x.id===a.defaultModel)||a.models[0],i=n?.presetMapping||{default:a.defaultModel,opus:a.defaultModel,sonnet:a.defaultModel,haiku:a.defaultModel},m=await Zt(),r={env:{ANTHROPIC_BASE_URL:`http://127.0.0.1:${He}/api/provider/${s}`,ANTHROPIC_AUTH_TOKEN:m,ANTHROPIC_MODEL:i.default,ANTHROPIC_DEFAULT_OPUS_MODEL:i.opus,ANTHROPIC_DEFAULT_SONNET_MODEL:i.sonnet,ANTHROPIC_DEFAULT_HAIKU_MODEL:i.haiku}};try{return{success:(await fetch(`/api/settings/${s}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({settings:r})})).ok,presetName:n?.name||a.defaultModel}}catch{return{success:!1}}}function ea({currentProgress:s,allSteps:t}){return e.jsx("div",{className:"flex justify-center gap-1 pt-2",children:t.map((a,n)=>e.jsx("div",{className:`w-2 h-2 rounded-full transition-colors ${s>=n?"bg-primary":"bg-muted"}`},a))})}function sa({providers:s,onSelect:t}){return e.jsx("div",{className:"grid gap-2",children:s.map(a=>e.jsxs("button",{onClick:()=>t(a.id),className:"flex items-center justify-between p-3 border rounded-lg hover:bg-muted/50 transition-colors text-left",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:a.name}),e.jsx("div",{className:"text-xs text-muted-foreground",children:a.description})]}),e.jsx(Ts,{className:"w-4 h-4 text-muted-foreground"})]},a.id))})}function ta({selectedProvider:s,providers:t,authCommand:a,isRefreshing:n,isPending:i,onBack:m,onStartAuth:u,onRefresh:r}){const[x,g]=o.useState(!1),w=async f=>{await navigator.clipboard.writeText(f),g(!0),setTimeout(()=>g(!1),2e3)};return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"text-center space-y-3",children:[e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Authenticate with ",t.find(f=>f.id===s)?.name," to add an account"]}),e.jsx(R,{onClick:u,disabled:i,className:"w-full gap-2",size:"lg",children:i?e.jsxs(e.Fragment,{children:[e.jsx(W,{className:"w-4 h-4 animate-spin"}),"Authenticating..."]}):e.jsxs(e.Fragment,{children:[e.jsx(me,{className:"w-4 h-4"}),"Authenticate in Browser"]})}),i&&e.jsx("p",{className:"text-xs text-muted-foreground",children:"Complete the OAuth flow in your browser..."})]}),e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"absolute inset-0 flex items-center",children:e.jsx("span",{className:"w-full border-t"})}),e.jsx("div",{className:"relative flex justify-center text-xs uppercase",children:e.jsx("span",{className:"bg-background px-2 text-muted-foreground",children:"Or use terminal"})})]}),e.jsx(js,{children:e.jsxs(vs,{className:"p-4 space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(Lt,{className:"w-4 h-4"}),"Run this command in your terminal:"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("code",{className:"flex-1 px-3 py-2 bg-muted rounded-md font-mono text-sm",children:a}),e.jsx(R,{variant:"outline",size:"icon",onClick:()=>w(a),children:x?e.jsx(ce,{className:"w-4 h-4 text-green-500"}):e.jsx(Ds,{className:"w-4 h-4"})})]})]})}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(R,{variant:"ghost",onClick:m,disabled:i,children:[e.jsx(We,{className:"w-4 h-4 mr-2"}),"Back"]}),e.jsxs(R,{variant:"outline",onClick:r,disabled:n||i,children:[e.jsx(Ye,{className:`w-4 h-4 mr-2 ${n?"animate-spin":""}`}),n?"Checking...":"Refresh Status"]})]})]})}function aa({accounts:s,privacyMode:t,onSelect:a,onAddNew:n,onBack:i}){return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:["Select an account (",s.length,")"]}),e.jsx("div",{className:"grid gap-2 max-h-[320px] overflow-y-auto pr-1",children:s.map(m=>e.jsxs("button",{type:"button",onClick:()=>a(m),className:"flex items-center justify-between p-3 border rounded-lg hover:bg-muted/50 transition-colors text-left",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-8 h-8 rounded-full bg-muted flex items-center justify-center",children:e.jsx(xe,{className:"w-4 h-4 text-muted-foreground"})}),e.jsxs("div",{children:[e.jsx("div",{className:G("font-medium",t&&Ae),children:m.email||m.id}),m.isDefault&&e.jsx("div",{className:"text-xs text-muted-foreground",children:"Default account"})]})]}),e.jsx(Ts,{className:"w-4 h-4 text-muted-foreground"})]},m.id))}),e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"absolute inset-0 flex items-center",children:e.jsx("span",{className:"w-full border-t"})}),e.jsx("div",{className:"relative flex justify-center text-xs uppercase",children:e.jsx("span",{className:"bg-background px-2 text-muted-foreground",children:"Or"})})]}),e.jsxs("button",{type:"button",className:"w-full flex items-center gap-3 p-3 border-2 border-dashed border-primary/50 rounded-lg hover:border-primary hover:bg-primary/5 transition-colors text-left",onClick:n,children:[e.jsx("div",{className:"w-8 h-8 rounded-full bg-primary/10 flex items-center justify-center shrink-0",children:e.jsx(me,{className:"w-4 h-4 text-primary"})}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-primary",children:"Add new account"}),e.jsx("div",{className:"text-xs text-muted-foreground",children:"Authenticate with a different account"})]})]}),e.jsx("div",{className:"flex items-center justify-between pt-2",children:e.jsxs(R,{variant:"ghost",onClick:i,children:[e.jsx(We,{className:"w-4 h-4 mr-2"}),"Back"]})})]})}const ms="__custom__";function na({selectedProvider:s,selectedAccount:t,variantName:a,modelName:n,isPending:i,privacyMode:m,onVariantNameChange:u,onModelChange:r,onBack:x,onSkip:g,onCreate:w}){const{t:f}=Z(),c=je[s]?.models||[],p=n&&!c.some(l=>l.id===n),[N,b]=o.useState(p),y=s==="agy"&&n.trim().length>0?ee(n):!1,E=l=>{l===ms?(b(!0),r("")):(b(!1),r(l))};return e.jsxs("div",{className:"space-y-4",children:[t&&e.jsxs("div",{className:"flex items-center gap-2 p-2 bg-muted/50 rounded-md text-sm",children:[e.jsx(xe,{className:"w-4 h-4"}),e.jsxs("span",{children:[f("setupVariant.using")," ",e.jsx("span",{className:G(m&&Ae),children:t.email||t.id})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(X,{htmlFor:"variant-name",children:f("setupVariant.variantNameRequired")}),e.jsx(le,{id:"variant-name",value:a,onChange:l=>u(l.target.value),placeholder:f("setupVariant.variantNamePlaceholder")}),e.jsxs("div",{className:"text-xs text-muted-foreground",children:[f("setupVariant.invokeHintPrefix")," ccs ",a||"<name>",' "prompt"']})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(X,{children:f("setupVariant.model")}),N?e.jsxs("div",{className:"space-y-2",children:[e.jsx(le,{value:n,onChange:l=>r(l.target.value),placeholder:f("setupVariant.modelPlaceholder")}),y&&e.jsx("p",{className:"text-xs text-destructive",children:"Antigravity denylist: Claude Opus 4.5 and Claude Sonnet 4.5 are deprecated."}),e.jsx("button",{type:"button",className:"text-xs text-primary hover:underline",onClick:()=>{b(!1),s==="agy"&&ee(n)&&r("")},children:f("setupVariant.choosePresetInstead")})]}):e.jsxs(Ns,{value:c.some(l=>l.id===n)?n:"",onValueChange:E,children:[e.jsx(ys,{children:e.jsx(bs,{placeholder:f("setupVariant.selectModel")})}),e.jsxs(ws,{children:[c.map(l=>e.jsx(Ie,{value:l.id,children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{children:l.name}),l.description&&e.jsxs("span",{className:"text-xs text-muted-foreground",children:["- ",l.description]})]})},l.id)),e.jsx(Ie,{value:ms,children:e.jsx("span",{className:"text-primary",children:f("setupVariant.customModelName")})})]})]}),e.jsx("div",{className:"text-xs text-muted-foreground",children:N?f("setupVariant.enterAnyModel"):f("setupVariant.defaultModel",{model:je[s]?.defaultModel||f("setupVariant.providerDefault")})})]}),e.jsxs("div",{className:"flex items-center justify-between pt-2",children:[e.jsxs(R,{variant:"ghost",onClick:x,children:[e.jsx(We,{className:"w-4 h-4 mr-2"}),f("setupVariant.back")]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(R,{variant:"ghost",onClick:g,children:f("setupVariant.skip")}),e.jsx(R,{onClick:w,disabled:!a||i||y,children:f(i?"setupVariant.creating":"setupVariant.createVariant")})]})]}),e.jsx("p",{className:"text-xs text-center text-muted-foreground",children:f("setupVariant.skipHint")})]})}function ia({variantName:s,onClose:t}){return e.jsxs("div",{className:"space-y-4 text-center",children:[e.jsx("div",{className:"flex justify-center",children:e.jsx("div",{className:"w-16 h-16 bg-green-100 dark:bg-green-900/30 rounded-full flex items-center justify-center",children:e.jsx(ce,{className:"w-8 h-8 text-green-600 dark:text-green-400"})})}),e.jsxs("div",{children:[e.jsx("div",{className:"font-semibold text-lg",children:"Variant Created!"}),e.jsx("div",{className:"text-sm text-muted-foreground",children:"Your custom variant is ready to use"})]}),e.jsx(js,{children:e.jsxs(vs,{className:"p-4 space-y-2",children:[e.jsx("div",{className:"text-sm text-muted-foreground",children:"Usage:"}),e.jsxs("code",{className:"block px-3 py-2 bg-muted rounded-md font-mono text-sm",children:["ccs ",s,' "your prompt here"']})]})}),e.jsx(R,{onClick:t,className:"w-full",children:"Done"})]})}function ra({open:s,onClose:t}){const[a,n]=o.useState("provider"),[i,m]=o.useState(""),[u,r]=o.useState(null),[x,g]=o.useState(""),[w,f]=o.useState(""),[c,p]=o.useState(!1),[N,b]=o.useState(!1),{data:y,refetch:E}=ks(),l=Qs(),A=zs(),j=Js(),{privacyMode:F}=Cs(),P=y?.authStatus.find(T=>T.provider===i),h=o.useMemo(()=>P?.accounts||[],[P?.accounts]);o.useEffect(()=>{if(!s){const T=setTimeout(()=>{n("provider"),m(""),r(null),g(""),f(""),b(!1)},0);return()=>clearTimeout(T)}},[s]),o.useEffect(()=>{if(a==="auth"&&h.length>0&&!N){const T=setTimeout(()=>{n("account")},0);return()=>clearTimeout(T)}},[a,h,N]);const U=async()=>{p(!0),await E(),p(!1)},k=()=>{const T=(P?.accounts?.length||0)===0;A.mutate({provider:i},{onSuccess:async _=>{if(T){const H=await Ke(i);H.success&&H.presetName?q.success(`Applied "${H.presetName}" preset`):H.success||q.warning(Ss.t("commonToast.accountAddedPresetFailed"))}_.account&&(r(_.account),n("variant")),E()}})},S=T=>{m(T),(y?.authStatus.find(V=>V.provider===T)?.accounts||[]).length===0?n("auth"):n("account")},O=T=>{r(T),n("variant")},v=async()=>{if(!(!x||!i))try{await l.mutateAsync({name:x,provider:i,model:w||void 0,account:u?.id}),n("success")}catch(T){console.error("Failed to create variant:",T)}},C=`ccs ${i} --auth --add`,K=Ys(a),I=T=>{if(!T&&(A.isPending&&i&&j.mutate(i),a==="success"||a==="provider")){t();return}};return e.jsx(Ve,{open:s,onOpenChange:I,children:e.jsxs(Ge,{className:"sm:max-w-lg",onPointerDownOutside:T=>{a!=="success"&&a!=="provider"&&T.preventDefault()},onEscapeKeyDown:T=>{(A.isPending||l.isPending)&&T.preventDefault()},children:[e.jsxs($e,{children:[e.jsxs(Qe,{className:"flex items-center gap-2",children:[e.jsx(ve,{className:"w-5 h-5 text-primary"}),"Quick Setup Wizard"]}),e.jsxs(As,{children:[a==="provider"&&"Select a provider to get started",a==="auth"&&"Authenticate with your provider",a==="account"&&"Select which account to use",a==="variant"&&"Create your custom variant",a==="success"&&"Setup complete!"]})]}),e.jsxs("div",{className:"space-y-4 py-4",children:[a==="provider"&&e.jsx(sa,{providers:ns,onSelect:S}),a==="auth"&&e.jsx(ta,{selectedProvider:i,providers:ns,authCommand:C,isRefreshing:c,isPending:A.isPending,onBack:()=>n("provider"),onStartAuth:k,onRefresh:U}),a==="account"&&e.jsx(aa,{accounts:h,privacyMode:F,onSelect:O,onAddNew:()=>{b(!0),n("auth")},onBack:()=>n("provider")}),a==="variant"&&e.jsx(na,{selectedProvider:i,selectedAccount:u,variantName:x,modelName:w,isPending:l.isPending,privacyMode:F,onVariantNameChange:g,onModelChange:f,onBack:()=>h.length>0?n("account"):n("provider"),onSkip:t,onCreate:v}),a==="success"&&e.jsx(ia,{variantName:x,onClose:t})]}),e.jsx(ea,{currentProgress:K,allSteps:Ws})]})})}const oa=3e3,la=300*1e3;async function Le(s){const t=await s.text();if(!t)return{};try{return JSON.parse(t)}catch{const a=s.status>=400?`Request failed with status ${s.status}`:void 0;return a?{error:a}:{}}}const oe={provider:null,isAuthenticating:!1,error:null,authUrl:null,oauthState:null,isSubmittingCallback:!1,isDeviceCodeFlow:!1};function ca(){const[s,t]=o.useState(oe),a=o.useRef(null),n=o.useRef(null),i=o.useRef(0),m=o.useRef(!1),u=Be(),r=o.useCallback(()=>{n.current&&(clearInterval(n.current),n.current=null)},[]);o.useEffect(()=>()=>{a.current?.abort(),r(),m.current=!1},[r]);const x=o.useCallback(async(c,p)=>{if(Date.now()-i.current>la){r(),t(N=>({...N,isAuthenticating:!1,error:"Authentication timed out. Please try again."}));return}try{const b=await(await fetch(`/api/cliproxy/auth/${c}/status?state=${encodeURIComponent(p)}`)).json();if(b.status==="ok")r(),u.invalidateQueries({queryKey:["cliproxy-auth"]}),u.invalidateQueries({queryKey:["account-quota"]}),q.success(`${c} authentication successful`),m.current=!1,t(oe);else if(b.status==="auth_url"){const y=b.url||b.auth_url;y&&(t(E=>({...E,authUrl:y})),m.current||(m.current=!0,window.open(y,"_blank")))}else if(b.status==="device_code"){r();const y=b.user_code&&b.verification_url?`Open ${b.verification_url} and enter code: ${b.user_code}`:"Switch to Device Code method and try again.";q.error("Provider returned Device Code flow in callback mode"),t(E=>({...E,isAuthenticating:!1,error:y}))}else if(b.status==="error"){r();const y=b.error||"Authentication failed";q.error(y),t(E=>({...E,isAuthenticating:!1,error:y}))}}catch{}},[u,r]),g=o.useCallback(async(c,p)=>{if(!Fe(c)){t({...oe,error:`Unknown provider: ${c}`});return}a.current?.abort(),r(),m.current=!1;const N=new AbortController;a.current=N;const y=(p?.flowType||(Ps(c)?"device_code":"authorization_code"))==="device_code",E=p?.startEndpoint||(y?"start":"start-url"),l={nickname:p?.nickname,kiroMethod:p?.kiroMethod,riskAcknowledgement:p?.riskAcknowledgement};t({provider:c,isAuthenticating:!0,error:null,authUrl:null,oauthState:null,isSubmittingCallback:!1,isDeviceCodeFlow:y});try{if(E==="start")fetch(`/api/cliproxy/auth/${c}/start`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(l),signal:N.signal}).then(async A=>{const j=await Le(A),F=j.success===!0;if(A.ok&&F)u.invalidateQueries({queryKey:["cliproxy-auth"]}),u.invalidateQueries({queryKey:["account-quota"]}),m.current=!1,t(oe);else{const P=typeof j.error=="string"?j.error:"Authentication failed";q.error(P),t(h=>({...h,isAuthenticating:!1,error:P}))}}).catch(A=>{if(A instanceof Error&&A.name==="AbortError")return;const j=A instanceof Error?A.message:"Authentication failed";q.error(j),t(F=>({...F,isAuthenticating:!1,error:j}))});else{const A=await fetch(`/api/cliproxy/auth/${c}/start-url`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(l),signal:N.signal}),j=await Le(A),F=j.success===!0;if(!A.ok||!F){const U=typeof j.error=="string"?j.error:"Failed to start OAuth";throw new Error(U)}const P=typeof j.authUrl=="string"?j.authUrl:null,h=typeof j.state=="string"?j.state:null;t(U=>({...U,authUrl:P,oauthState:h})),P&&(m.current=!0,window.open(P,"_blank")),h&&(i.current=Date.now(),n.current=setInterval(()=>{x(c,h)},oa))}}catch(A){if(A instanceof Error&&A.name==="AbortError"){m.current=!1,t(oe);return}const j=A instanceof Error?A.message:"Authentication failed";q.error(j),t(F=>({...F,isAuthenticating:!1,error:j}))}},[x,r,u]),w=o.useCallback(()=>{const c=s.provider;a.current?.abort(),r(),m.current=!1,t(oe),c&&we.cliproxy.auth.cancel(c).catch(()=>{})},[s.provider,r]),f=o.useCallback(async c=>{if(s.provider){t(p=>({...p,isSubmittingCallback:!0,error:null}));try{const p=await fetch(`/api/cliproxy/auth/${s.provider}/submit-callback`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({redirectUrl:c})}),N=await Le(p),b=N.success===!0;if(p.ok&&b)r(),u.invalidateQueries({queryKey:["cliproxy-auth"]}),u.invalidateQueries({queryKey:["account-quota"]}),q.success(`${s.provider} authentication successful`),t(oe);else{const y=typeof N.error=="string"?N.error:"Callback submission failed";throw new Error(y)}}catch(p){const N=p instanceof Error?p.message:"Failed to submit callback";q.error(N),t(b=>({...b,isSubmittingCallback:!1,error:N}))}}},[s.provider,u,r]);return o.useMemo(()=>({...s,startAuth:g,cancelAuth:w,submitCallback:f}),[s,g,w,f])}function Hs({className:s,showAcknowledgement:t=!1,acknowledgementPhrase:a=ke,acknowledgementText:n="",onAcknowledgementTextChange:i,disabled:m=!1,showProxySettingsLink:u=!1}){const{t:r}=Z(),x=r("accountSafetyWarning.title"),g=r("accountSafetyWarning.subtitle"),w=r("accountSafetyWarning.firstLine"),f=r("accountSafetyWarning.secondLine"),c="https://github.com/kaitranntt/ccs/issues/509",p=r("accountSafetyWarning.issueLabel"),N=r("accountSafetyWarning.proxySettingsLabel");return e.jsxs("section",{role:"alert",className:G("relative overflow-hidden rounded-xl border border-amber-500/30 bg-gradient-to-br from-amber-50 via-background to-rose-50/70 shadow-sm dark:from-amber-950/20 dark:to-rose-950/20",s),children:[e.jsx("div",{className:"absolute inset-x-0 top-0 h-0.5 bg-gradient-to-r from-amber-500 via-orange-500 to-rose-500"}),e.jsxs("div",{className:"space-y-3 p-4",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"flex items-start gap-2.5",children:[e.jsx("div",{className:"mt-0.5 inline-flex h-7 w-7 items-center justify-center rounded-md bg-amber-500/15 text-amber-700 dark:text-amber-400",children:e.jsx(Se,{className:"h-4 w-4"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-semibold leading-5",children:x}),e.jsx("p",{className:"text-xs text-muted-foreground",children:g})]})]}),e.jsx(B,{variant:"outline",className:"border-amber-500/40 text-amber-700 dark:text-amber-300",children:"High Risk"})]}),e.jsxs("div",{className:"space-y-2 text-sm leading-relaxed",children:[e.jsx("p",{children:w}),e.jsx("p",{className:"font-medium text-amber-900 dark:text-amber-200",children:f}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"CCS is provided as-is and does not take responsibility for suspension, bans, or access loss from upstream providers."})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs("a",{href:c,target:"_blank",rel:"noreferrer",className:"inline-flex items-center gap-1.5 rounded-md border border-amber-500/30 bg-amber-500/10 px-2.5 py-1 text-xs font-medium text-amber-800 transition-colors hover:bg-amber-500/15 dark:text-amber-200",children:[p,e.jsx(me,{className:"h-3.5 w-3.5"})]}),u&&e.jsxs("a",{href:"/settings?tab=proxy",className:"inline-flex items-center gap-1.5 rounded-md border border-amber-500/30 bg-amber-500/10 px-2.5 py-1 text-xs font-medium text-amber-800 transition-colors hover:bg-amber-500/15 dark:text-amber-200",children:[e.jsx(It,{className:"h-3.5 w-3.5"}),N]}),e.jsx("span",{className:"rounded-md border border-border/70 bg-muted/60 px-2.5 py-1 text-xs text-muted-foreground",children:"Applies to CLI and dashboard auth"})]}),t&&i&&e.jsxs("div",{className:"rounded-lg border border-amber-500/25 bg-amber-500/5 p-2.5",children:[e.jsxs(X,{htmlFor:"account-risk-ack-text",className:"text-xs leading-5",children:["Type exact phrase to continue:"," ",e.jsx("code",{className:"rounded bg-muted px-1 py-0.5 font-mono",children:a})]}),e.jsx(le,{id:"account-risk-ack-text",value:n,onChange:b=>i(b.target.value),placeholder:a,disabled:m,className:"mt-2 font-mono text-xs"})]})]})]})}function da({className:s,value:t,onChange:a,disabled:n=!1}){const{t:i}=Z(),m=[t.reviewedIssue509,t.understandsBanRisk,t.acceptsFullResponsibility,t.typedPhrase.trim().replace(/\s+/g," ").toUpperCase()===us].filter(Boolean).length,u=m/4*100,r=x=>{a({...t,...x})};return e.jsxs("section",{role:"alert",className:G("relative overflow-hidden rounded-xl border border-rose-500/35 bg-gradient-to-br from-rose-50 via-background to-amber-50/70 p-4 shadow-sm dark:from-rose-950/20 dark:to-amber-950/20",s),children:[e.jsx("div",{className:"absolute inset-x-0 top-0 h-0.5 bg-gradient-to-r from-rose-500 via-orange-500 to-amber-500"}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"flex items-start gap-2.5",children:[e.jsx("div",{className:"mt-0.5 inline-flex h-7 w-7 items-center justify-center rounded-md bg-rose-500/15 text-rose-700 dark:text-rose-300",children:e.jsx(Se,{className:"h-4 w-4"})}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-sm font-semibold leading-5",children:i("antigravityChecklist.title")}),e.jsx("p",{className:"text-xs text-muted-foreground",children:i("antigravityChecklist.subtitle")})]})]}),e.jsx(B,{variant:"outline",className:"border-rose-500/40 text-rose-700 dark:text-rose-300",children:i("antigravityChecklist.mandatory")})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{className:"flex items-center justify-between text-xs text-muted-foreground",children:[e.jsx("span",{children:i("antigravityChecklist.completion")}),e.jsx("span",{children:i("antigravityChecklist.stepsCount",{current:m})})]}),e.jsx(Ue,{value:u,className:"h-2"})]}),e.jsxs("div",{className:"space-y-3 rounded-lg border border-rose-500/20 bg-rose-500/5 p-3",children:[e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(Ce,{id:"agy-step-reviewed-issue",checked:t.reviewedIssue509,onCheckedChange:x=>r({reviewedIssue509:!!x}),disabled:n}),e.jsx(X,{htmlFor:"agy-step-reviewed-issue",className:"text-xs leading-5",children:"Step 1: I reviewed issue #509 and understand AGY OAuth can trigger account bans/suspensions."})]}),e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(Ce,{id:"agy-step-understands-risk",checked:t.understandsBanRisk,onCheckedChange:x=>r({understandsBanRisk:!!x}),disabled:n}),e.jsx(X,{htmlFor:"agy-step-understands-risk",className:"text-xs leading-5",children:"Step 2: I understand this OAuth action is my own decision and I accept the upstream risk."})]}),e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(Ce,{id:"agy-step-accept-responsibility",checked:t.acceptsFullResponsibility,onCheckedChange:x=>r({acceptsFullResponsibility:!!x}),disabled:n}),e.jsx(X,{htmlFor:"agy-step-accept-responsibility",className:"text-xs leading-5",children:"Step 3: I accept full responsibility. CCS is not liable for suspension, bans, or access loss."})]})]}),e.jsxs("div",{className:"space-y-2 rounded-lg border border-amber-500/25 bg-amber-500/5 p-3",children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-xs font-medium text-amber-800 dark:text-amber-200",children:[e.jsx(Os,{className:"h-3.5 w-3.5"}),"Step 4: Type exact phrase to continue"]}),e.jsx(le,{value:t.typedPhrase,onChange:x=>r({typedPhrase:x.target.value}),placeholder:us,disabled:n,className:"font-mono text-xs"})]}),e.jsx("div",{className:"flex flex-wrap items-center gap-2 text-xs",children:e.jsxs("a",{href:"https://github.com/kaitranntt/ccs/issues/509",target:"_blank",rel:"noreferrer",className:"inline-flex items-center gap-1.5 rounded-md border border-rose-500/30 bg-rose-500/10 px-2.5 py-1 font-medium text-rose-800 transition-colors hover:bg-rose-500/15 dark:text-rose-200",children:["Read issue #509",e.jsx(me,{className:"h-3.5 w-3.5"})]})})]})]})}function ua(s){return s.trim().replace(/\s+/g," ").toUpperCase()}function ma({open:s,onClose:t,provider:a,displayName:n,isFirstAccount:i=!1}){const[m,u]=o.useState(""),[r,x]=o.useState(""),[g,w]=o.useState(!1),[f,c]=o.useState(null),[p,N]=o.useState(""),[b,y]=o.useState(_e),[E,l]=o.useState(!1),[A,j]=o.useState(!1),[F,P]=o.useState(is),{t:h}=Z(),U=o.useRef(!1),k=ca(),S=Xs(),O=a==="kiro",v=a==="gemini",C=a==="agy"&&!E,K=a==="agy"&&A,I=zt(b),T=ua(p)===ke,_=Ps(a),H=Zs(a),V=et(F),se=O?V.flowType==="device_code":_,z=k.isAuthenticating||S.isPending,Y=m.trim(),te=f||k.error,d=o.useCallback(async()=>{const M=await fetch("/api/settings/auth/antigravity-risk");if(!M.ok)throw new Error("Failed to load Antigravity power user setting");return(await M.json()).antigravityAckBypass===!0},[]),D=()=>{u(""),x(""),w(!1),c(null),N(""),y(_e),l(!1),j(!1),P(is),U.current=!1,t()};o.useEffect(()=>{s&&(N(""),y(_e),c(null))},[a,s]),o.useEffect(()=>{let M=!1;if(!s||a!=="agy"){l(!1),j(!1);return}return(async()=>{try{j(!0);const ae=await d();M||l(ae)}catch{M||l(!1)}finally{M||j(!1)}})(),()=>{M=!0}},[d,s,a]),o.useEffect(()=>{if(!s||a!=="agy"||!k.error||!E)return;const M=k.error.toLowerCase();if(!(M.includes("agy_risk_ack_required")||M.includes("responsibility acknowledgement")||M.includes("responsibility checklist")))return;let ae=!1;return(async()=>{try{j(!0);const ye=await d();if(ae)return;l(ye),ye||c("Power user mode is off. Complete the AGY checklist and retry.")}catch{if(ae)return;l(!1),c("Power user mode is off. Complete the AGY checklist and retry.")}finally{ae||j(!1)}})(),()=>{ae=!0}},[E,k.error,d,s,a]),o.useEffect(()=>{!k.isAuthenticating&&!k.error&&k.provider===null&&s&&U.current&&(U.current=!1,(async()=>{try{const ne=await Ke(a);ne.success&&ne.presetName&&i&&q.success(`Applied "${ne.presetName}" preset`)}catch{}D()})())},[k.isAuthenticating,k.error,k.provider]);const $=()=>{k.cancelAuth(),D()},de=async()=>{k.authUrl&&(await navigator.clipboard.writeText(k.authUrl),w(!0),setTimeout(()=>w(!1),2e3))},Me=()=>{r.trim()&&k.submitCallback(r.trim())},Te=()=>{if(K){c("Loading Antigravity safety settings. Please wait a moment and retry.");return}if(C&&!I){c("Complete all Antigravity responsibility steps before authenticating this provider.");return}if(v&&!T){c(`Type "${ke}" to acknowledge the account safety warning before authenticating this provider.`);return}if(H&&!Y){c(`Nickname is required for ${n} accounts.`);return}c(null),U.current=!0,k.startAuth(a,{nickname:Y||void 0,kiroMethod:O?F:void 0,flowType:O?V.flowType:void 0,startEndpoint:O?V.startEndpoint:void 0,riskAcknowledgement:C?{version:Jt,reviewedIssue509:b.reviewedIssue509,understandsBanRisk:b.understandsBanRisk,acceptsFullResponsibility:b.acceptsFullResponsibility,typedPhrase:b.typedPhrase}:void 0})},De=()=>{U.current=!0,S.mutate(void 0,{onSuccess:async()=>{const M=await Ke("kiro");M.success&&M.presetName&&i&&q.success(`Applied "${M.presetName}" preset`),D()}})},Oe=M=>{M||$()},J=k.isAuthenticating;return e.jsx(Ve,{open:s,onOpenChange:Oe,children:e.jsxs(Ge,{className:"sm:max-w-md",onInteractOutside:M=>{J&&M.preventDefault()},children:[e.jsxs($e,{children:[e.jsx(Qe,{children:h("addAccountDialog.title",{displayName:n})}),e.jsx(As,{children:h(O?"addAccountDialog.descKiro":se?"addAccountDialog.descDeviceCode":"addAccountDialog.descOauth")})]}),e.jsxs("div",{className:"space-y-4 py-4",children:[C&&!J&&e.jsx(da,{value:b,onChange:M=>{y(M),c(null)},disabled:z}),a==="agy"&&E&&!J&&e.jsxs("div",{className:"rounded-lg border border-amber-400/35 bg-amber-50/70 p-3 text-xs text-amber-900 dark:border-amber-800/60 dark:bg-amber-950/25 dark:text-amber-100",children:[e.jsxs("div",{className:"mb-1.5 flex items-center gap-1.5 font-semibold",children:[e.jsx(Os,{className:"h-3.5 w-3.5"}),h("addAccountDialog.powerUserEnabled")]}),h("addAccountDialog.powerUserSkipped")]}),v&&!J&&e.jsx(Hs,{showAcknowledgement:!0,acknowledgementPhrase:ke,acknowledgementText:p,onAcknowledgementTextChange:M=>{N(M),c(null)},disabled:z}),O&&!J&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(X,{htmlFor:"kiro-auth-method",children:h("addAccountDialog.authMethod")}),e.jsxs(Ns,{value:F,onValueChange:M=>{P(M),c(null)},children:[e.jsx(ys,{id:"kiro-auth-method",children:e.jsx(bs,{placeholder:h("addAccountDialog.selectKiroAuthMethod")})}),e.jsx(ws,{children:st.map(M=>e.jsx(Ie,{value:M.id,children:M.label},M.id))})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:V.description})]}),!J&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(X,{htmlFor:"nickname",children:h(H?"addAccountDialog.nicknameRequired":"addAccountDialog.nicknameOptional")}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(xe,{className:"w-4 h-4 text-muted-foreground"}),e.jsx(le,{id:"nickname",value:m,onChange:M=>{u(M.target.value),c(null)},placeholder:h("addAccountDialog.nicknamePlaceholder"),disabled:z,className:"flex-1"})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:h(H?"addAccountDialog.nicknameRequiredHint":"addAccountDialog.nicknameOptionalHint")})]}),J&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"text-center",children:[e.jsxs("p",{className:"text-sm text-muted-foreground",children:[e.jsx(W,{className:"w-4 h-4 inline mr-2 animate-spin"}),h("addAccountDialog.waitingForAuth")]}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:k.isDeviceCodeFlow?h("addAccountDialog.deviceCodeHint"):h("addAccountDialog.browserHint")})]}),k.authUrl&&!k.isDeviceCodeFlow&&e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(X,{className:"text-xs",children:h("addAccountDialog.openUrlLabel")}),e.jsxs("div",{className:"p-3 bg-muted rounded-md",children:[e.jsx("p",{className:"text-xs text-muted-foreground break-all font-mono line-clamp-3",children:k.authUrl}),e.jsxs("div",{className:"flex gap-2 mt-2",children:[e.jsx(R,{variant:"outline",size:"sm",onClick:de,children:g?e.jsxs(e.Fragment,{children:[e.jsx(ce,{className:"w-3 h-3 mr-1"}),h("addAccountDialog.copied")]}):e.jsxs(e.Fragment,{children:[e.jsx(Ds,{className:"w-3 h-3 mr-1"}),h("addAccountDialog.copy")]})}),e.jsxs(R,{variant:"outline",size:"sm",onClick:()=>{if(!k.authUrl)return;const M=window.open(k.authUrl,"_blank");(!M||M.closed||typeof M.closed>"u")&&q.warning(h("addAccountDialog.popupBlocked"),{duration:5e3})},children:[e.jsx(me,{className:"w-3 h-3 mr-1"}),h("addAccountDialog.open")]})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(X,{htmlFor:"callback-url",className:"text-xs",children:h("addAccountDialog.redirectPasteLabel")}),e.jsx(le,{id:"callback-url",value:r,onChange:M=>x(M.target.value),placeholder:h("addAccountDialog.callbackPlaceholder"),className:"font-mono text-xs"}),e.jsx(R,{variant:"secondary",size:"sm",onClick:Me,disabled:!r.trim()||k.isSubmittingCallback,children:k.isSubmittingCallback?e.jsxs(e.Fragment,{children:[e.jsx(W,{className:"w-3 h-3 mr-1 animate-spin"}),h("addAccountDialog.submitting")]}):h("addAccountDialog.submitCallback")})]})]}),!k.authUrl&&!k.isDeviceCodeFlow&&e.jsx("p",{className:"text-xs text-center text-muted-foreground",children:h("addAccountDialog.preparingUrl")})]}),te&&e.jsx("p",{className:"text-xs text-center text-destructive",children:te}),S.isPending&&e.jsxs("p",{className:"text-sm text-center text-muted-foreground",children:[e.jsx(W,{className:"w-4 h-4 inline mr-2 animate-spin"}),h("addAccountDialog.importingToken")]}),e.jsxs("div",{className:"flex items-center justify-end gap-2 pt-2",children:[e.jsx(R,{variant:"ghost",onClick:$,children:h("addAccountDialog.cancel")}),O&&!J&&e.jsx(R,{variant:"outline",onClick:De,disabled:z,children:S.isPending?e.jsxs(e.Fragment,{children:[e.jsx(W,{className:"w-4 h-4 mr-2 animate-spin"}),h("addAccountDialog.importing")]}):e.jsxs(e.Fragment,{children:[e.jsx(Ft,{className:"w-4 h-4 mr-2"}),h("addAccountDialog.importFromIde")]})}),!J&&e.jsxs(R,{onClick:Te,disabled:z||K||H&&!Y||C&&!I||v&&!T,children:[e.jsx(me,{className:"w-4 h-4 mr-2"}),h("addAccountDialog.authenticate")]})]})]})]})})}const es="[1m]";function xa(s){return s.toLowerCase().startsWith("gemini-")}function ss(s){return s.toLowerCase().endsWith(es.toLowerCase())}function pa(s){return!s||ss(s)?s:`${s}${es}`}function qs(s){return s&&(ss(s)?s.slice(0,-es.length):s)}const xs=["ANTHROPIC_MODEL"],ha=["ANTHROPIC_BASE_URL","ANTHROPIC_AUTH_TOKEN"];function ga(s){const t=s?.env||{};return ha.filter(a=>!t[a]?.trim())}function fa(s){const[t,a]=o.useState(null),[n,i]=o.useState(!1),m=Be(),{data:u,isLoading:r,refetch:x}=fs({queryKey:["settings",s],queryFn:async()=>{const S=await fetch(`/api/settings/${s}/raw`);return S.ok?S.json():{profile:s,settings:{env:{}},mtime:Date.now(),path:`~/.ccs/profiles/${s}/settings.json`}}}),g=u?.settings,w=o.useMemo(()=>t!==null?t:g?JSON.stringify(g,null,2):`{
2
+ "env": {}
3
+ }`,[t,g]),f=o.useCallback(S=>{a(S)},[]),c=o.useMemo(()=>{try{return JSON.parse(w)}catch{return g||{env:{}}}},[w,g]),p=c?.env?.ANTHROPIC_MODEL,N=c?.env?.ANTHROPIC_DEFAULT_OPUS_MODEL,b=c?.env?.ANTHROPIC_DEFAULT_SONNET_MODEL,y=c?.env?.ANTHROPIC_DEFAULT_HAIKU_MODEL,E=o.useMemo(()=>{const S=c?.env||{};return xs.some(O=>{const v=S[O];return v&&ss(v)})},[c]),l=o.useCallback((S,O)=>{const v={...c?.env||{},[S]:O},C={...c,env:v};a(JSON.stringify(C,null,2))},[c]),A=o.useCallback(S=>{const O=c?.env||{},v={};for(const I of xs){const T=O[I];T&&(v[I]=S?pa(T):qs(T))}const C={...O,...v};delete C.CCS_EXTENDED_CONTEXT;const K={...c,env:C};a(JSON.stringify(K,null,2))},[c]),j=o.useCallback(S=>{const O={...c?.env||{},...S},v={...c,env:O};a(JSON.stringify(v,null,2))},[c]),F=o.useMemo(()=>{try{return JSON.parse(w),!0}catch{return!1}},[w]),P=o.useMemo(()=>t===null?!1:t!==JSON.stringify(g,null,2),[t,g]),h=o.useMemo(()=>ga(c),[c]),U=$s({mutationFn:async()=>{const S=JSON.parse(w),O=await fetch(`/api/settings/${s}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({settings:S,expectedMtime:u?.mtime})});if(O.status===409)throw new Error("CONFLICT");if(!O.ok)throw new Error("Failed to save");return O.json()},onSuccess:S=>{m.invalidateQueries({queryKey:["settings",s]}),a(null),S?.warning?q.success("Settings saved",{description:S.warning}):q.success("Settings saved")},onError:S=>{S.message==="CONFLICT"?i(!0):q.error(S.message)}}),k=async S=>{i(!1),S?(await x(),U.mutate()):a(null)};return{data:u,isLoading:r,refetch:x,rawJsonContent:w,rawJsonEdits:t,isRawJsonValid:F,hasChanges:P,currentSettings:c,currentModel:p,opusModel:N,sonnetModel:b,haikuModel:y,extendedContextEnabled:E,toggleExtendedContext:A,handleRawJsonChange:f,updateEnvValue:l,updateEnvValues:j,saveMutation:{mutate:()=>U.mutate(),isPending:U.isPending},conflictDialog:n,setConflictDialog:i,handleConflictResolve:k,missingRequiredFields:h}}const ja=/-(medium|high|xhigh)$/i;function va(s){if(!s)return;const t=s.trim().match(ja);if(t?.[1])return t[1].toLowerCase()}function Na(s){if(!s)return null;const t=va(s);return t?{label:`Pinned ${t}`,explicit:!0}:{label:"Auto effort",explicit:!1}}function ya({label:s}){return e.jsx(B,{variant:"outline",className:"text-[9px] h-4 px-1",children:s})}function be({modelId:s}){const t=Na(s);return t?e.jsx(B,{variant:t.explicit?"secondary":"outline",className:"text-[9px] h-4 px-1 uppercase",children:t.label}):null}function re({label:s,description:t,value:a,onChange:n,catalog:i,allModels:m,disabled:u}){const{t:r}=Z(),x=new Set(i?.models.map(p=>p.id)||[]),g=i?.provider==="codex",w=(i?.models??[]).map(p=>({value:p.id,groupKey:"recommended",searchText:`${p.id} ${p.name}`,keywords:[p.tier??"",i?.provider??""],triggerContent:e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("span",{className:"truncate font-mono text-xs",children:p.id}),g&&e.jsx(be,{modelId:p.id})]}),itemContent:e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("span",{className:"truncate font-mono text-xs",children:p.id}),p.tier==="paid"&&e.jsx(ya,{label:r("providerModelSelector.paid")}),g&&e.jsx(be,{modelId:p.id})]})})),f=m.filter(p=>!x.has(p.id)).map(p=>({value:p.id,groupKey:"all",searchText:p.id,keywords:[p.owned_by],triggerContent:e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("span",{className:"truncate font-mono text-xs",children:p.id}),g&&e.jsx(be,{modelId:p.id})]}),itemContent:e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("span",{className:"truncate font-mono text-xs",children:p.id}),g&&e.jsx(be,{modelId:p.id})]})})),c=w.length+f.length>0;return e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-medium",children:s}),t&&e.jsx("p",{className:"text-[10px] text-muted-foreground",children:t})]}),e.jsx(Xt,{value:a||void 0,onChange:n,disabled:u,placeholder:r("providerModelSelector.selectModel"),searchPlaceholder:r("searchableSelect.searchModels"),emptyText:r(c?"searchableSelect.noResults":"providerModelSelector.noModelsAvailable"),triggerClassName:"h-9",groups:[{key:"recommended",label:e.jsx("span",{className:"text-xs text-primary",children:r("providerModelSelector.recommended")})},{key:"all",label:e.jsx("span",{className:"text-xs text-muted-foreground",children:r("providerModelSelector.allModelsCount",{count:m.length})})}],options:[...w,...f]})]})}function ba({open:s,onClose:t,currentValues:a,onApply:n,onSave:i,isSaving:m,catalog:u,allModels:r}){const{t:x}=Z(),[g,w]=o.useState(a),[f,c]=o.useState(""),p=N=>{N?(w(a),c("")):t()};return e.jsx(Ve,{open:s,onOpenChange:p,children:e.jsxs(Ge,{className:"sm:max-w-md",children:[e.jsx($e,{children:e.jsxs(Qe,{className:"flex items-center gap-2",children:[e.jsx(ve,{className:"w-4 h-4"}),x("customPresetDialog.title")]})}),e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(X,{htmlFor:"preset-name",children:x("customPresetDialog.presetNameOptional")}),e.jsx(le,{id:"preset-name",value:f,onChange:N=>c(N.target.value),placeholder:x("customPresetDialog.presetNamePlaceholder"),className:"text-sm"})]}),e.jsx(Ze,{}),u?.provider==="codex"&&e.jsxs("p",{className:"text-[11px] text-muted-foreground rounded-md border bg-muted/30 px-2.5 py-2",children:[x("customPresetDialog.codexTipPrefix")," ",e.jsx("code",{children:"-medium"}),", ",e.jsx("code",{children:"-high"}),", and"," ",e.jsx("code",{children:"-xhigh"})," ",x("customPresetDialog.codexTipSuffix")]}),e.jsx(re,{label:x("customPresetDialog.defaultModel"),description:x("customPresetDialog.defaultModelDesc"),value:g.default,onChange:N=>w({...g,default:N}),catalog:u,allModels:r}),e.jsx(re,{label:x("customPresetDialog.opusModel"),description:x("customPresetDialog.opusModelDesc"),value:g.opus,onChange:N=>w({...g,opus:N}),catalog:u,allModels:r}),e.jsx(re,{label:x("customPresetDialog.sonnetModel"),description:x("customPresetDialog.sonnetModelDesc"),value:g.sonnet,onChange:N=>w({...g,sonnet:N}),catalog:u,allModels:r}),e.jsx(re,{label:x("customPresetDialog.haikuModel"),description:x("customPresetDialog.haikuModelDesc"),value:g.haiku,onChange:N=>w({...g,haiku:N}),catalog:u,allModels:r})]}),e.jsxs(tt,{className:"gap-2 sm:gap-0",children:[e.jsx(R,{variant:"outline",onClick:t,children:x("customPresetDialog.cancel")}),i&&e.jsxs(R,{variant:"secondary",onClick:()=>i(g,f||void 0),disabled:m||!f.trim(),children:[m?e.jsx(W,{className:"w-4 h-4 mr-1 animate-spin"}):e.jsx(Pe,{className:"w-4 h-4 mr-1"}),x("customPresetDialog.savePreset")]}),e.jsxs(R,{onClick:()=>n(g,f||void 0),children:[e.jsx(Ne,{className:"w-4 h-4 mr-1"}),x("customPresetDialog.applyPreset")]})]})]})})}function ue({label:s,command:t}){return e.jsxs("div",{children:[e.jsx("label",{className:"text-xs text-muted-foreground",children:s}),e.jsxs("div",{className:"mt-1 flex gap-2",children:[e.jsx("code",{className:"flex-1 px-2 py-1.5 bg-muted rounded text-xs font-mono truncate",children:t}),e.jsx(Ms,{value:t,size:"icon",className:"h-6 w-6"})]})]})}function wa({provider:s,displayName:t,defaultTarget:a,data:n,authStatus:i}){const m=a||"claude",u=m==="droid";return e.jsx(ze,{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(Es,{className:"w-4 h-4"}),"Provider Information"]}),e.jsxs("div",{className:"space-y-3 bg-card rounded-lg border p-4 shadow-sm",children:[e.jsxs("div",{className:"grid grid-cols-[100px_1fr] gap-2 text-sm items-center",children:[e.jsx("span",{className:"font-medium text-muted-foreground",children:"Provider"}),e.jsx("span",{className:"font-mono",children:t})]}),n&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid grid-cols-[100px_1fr] gap-2 text-sm items-center",children:[e.jsx("span",{className:"font-medium text-muted-foreground",children:"File Path"}),e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsx("code",{className:"bg-muted px-1.5 py-0.5 rounded text-xs break-all",children:n.path}),e.jsx(Ms,{value:n.path,size:"icon",className:"h-5 w-5"})]})]}),e.jsxs("div",{className:"grid grid-cols-[100px_1fr] gap-2 text-sm items-center",children:[e.jsx("span",{className:"font-medium text-muted-foreground",children:"Last Modified"}),e.jsx("span",{className:"text-xs",children:new Date(n.mtime).toLocaleString()})]})]}),e.jsxs("div",{className:"grid grid-cols-[100px_1fr] gap-2 text-sm items-center",children:[e.jsx("span",{className:"font-medium text-muted-foreground",children:"Status"}),i.authenticated?e.jsxs(B,{variant:"outline",className:"w-fit text-green-600 border-green-200 bg-green-50",children:[e.jsx(Ut,{className:"w-3 h-3 mr-1"}),"Authenticated"]}):e.jsx(B,{variant:"outline",className:"w-fit text-muted-foreground",children:"Not connected"})]}),e.jsxs("div",{className:"grid grid-cols-[100px_1fr] gap-2 text-sm items-center",children:[e.jsx("span",{className:"font-medium text-muted-foreground",children:"Default Target"}),e.jsx("span",{className:"font-mono",children:m})]})]})]}),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(ue,{label:"Run with prompt",command:`ccs ${s} "your prompt"`}),e.jsx(ue,{label:u?"Droid alias (explicit)":"Run on Droid",command:u?`ccsd ${s} "your prompt"`:`ccs ${s} --target droid "your prompt"`}),e.jsx(ue,{label:u?"Override to Claude":"Override target",command:`ccs ${s} --target claude "your prompt"`}),e.jsx(ue,{label:"Change model",command:`ccs ${s} --config`}),e.jsx(ue,{label:"Add account",command:`ccs ${s} --add`}),e.jsx(ue,{label:"List accounts",command:`ccs ${s} --accounts`})]})]})]})})}function ka({displayName:s,logoProvider:t,provider:a,data:n,isLoading:i,hasChanges:m,isRawJsonValid:u,isSaving:r,isRemoteMode:x,port:g,onRefetch:w,onSave:f}){return e.jsxs("div",{className:"px-6 py-4 border-b bg-background flex items-center justify-between shrink-0",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(Je,{provider:t||a,size:"lg"}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h2",{className:"text-lg font-semibold",children:s}),x&&e.jsxs(B,{variant:"secondary",className:"text-xs gap-1 bg-blue-100 text-blue-700 dark:bg-blue-900/30 dark:text-blue-400",children:[e.jsx(_s,{className:"w-3 h-3"}),"Remote"]}),g&&e.jsxs(B,{variant:"outline",className:"text-xs gap-1 font-mono",children:[e.jsx(Ht,{className:"w-3 h-3"}),":",g]}),!x&&n?.path&&e.jsx(B,{variant:"outline",className:"text-xs",children:n.path.replace(/^.*[\\/]/,"")})]}),x?e.jsx("p",{className:"text-xs text-blue-600 dark:text-blue-400 mt-0.5",children:"Traffic auto-routed to remote server"}):n&&e.jsxs("p",{className:"text-xs text-muted-foreground mt-0.5",children:["Last modified: ",new Date(n.mtime).toLocaleString()]})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(R,{variant:"ghost",size:"sm",onClick:w,disabled:i,children:e.jsx(Ye,{className:`w-4 h-4 ${i?"animate-spin":""}`})}),e.jsx(R,{size:"sm",onClick:f,disabled:r||!m||!u,children:r?e.jsxs(e.Fragment,{children:[e.jsx(W,{className:"w-4 h-4 mr-1 animate-spin"}),"Saving..."]}):e.jsxs(e.Fragment,{children:[e.jsx(qt,{className:"w-4 h-4 mr-1"}),"Save"]})})]})]})}function Ca({model:s,provider:t,enabled:a,onToggle:n,disabled:i,className:m}){if(!s?.extendedContext)return null;const u=xa(s.id);return e.jsxs("div",{className:G("rounded-lg border p-3 space-y-2",a?"border-primary/50 bg-primary/5":"border-border bg-muted/30",m),children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ne,{className:G("w-4 h-4",a?"text-primary":"text-muted-foreground")}),e.jsx("span",{className:"text-sm font-medium",children:"Extended Context"}),e.jsx(B,{variant:a?"default":"secondary",className:"text-[10px] h-5 px-1.5",children:"1M tokens"})]}),e.jsx(Us,{checked:a,onCheckedChange:n,disabled:i})]}),e.jsxs("div",{className:"flex items-start gap-2 text-xs text-muted-foreground",children:[e.jsx(Es,{className:"w-3.5 h-3.5 mt-0.5 shrink-0"}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{children:"Enables 1M token context window instead of default 200K."}),e.jsx("p",{className:"text-[10px]",children:u?e.jsxs("span",{className:"text-primary",children:["Auto-enabled for ",t," Gemini models"]}):e.jsxs("span",{children:["Opt-in for ",t," Claude models via --1m flag"]})}),a&&e.jsx("p",{className:"text-amber-600 dark:text-amber-500",children:"Note: 2x input pricing applies for tokens beyond 200K"})]})]})]})}function Aa(s){const t=s.presetMapping||{default:s.id,opus:s.id,sonnet:s.id,haiku:s.id};return{ANTHROPIC_MODEL:t.default,ANTHROPIC_DEFAULT_OPUS_MODEL:t.opus,ANTHROPIC_DEFAULT_SONNET_MODEL:t.sonnet,ANTHROPIC_DEFAULT_HAIKU_MODEL:t.haiku}}function Sa({catalog:s,savedPresets:t,currentModel:a,opusModel:n,sonnetModel:i,haikuModel:m,providerModels:u,provider:r,extendedContextEnabled:x,onExtendedContextToggle:g,onApplyPreset:w,onUpdateEnvValue:f,onOpenCustomPreset:c,onDeletePreset:p,isDeletePending:N}){const b=o.useMemo(()=>{if(!s||!a)return;const l=qs(a);return s.models.find(A=>A.id===l)},[s,a]),y=o.useMemo(()=>{const l=(s?.models??[]).filter(j=>j.presetMapping);return l.length===0?[]:l.some(j=>j.tier==="paid")?[{key:"free",label:"Free Tier",description:"Available on free or paid plans",badgeClassName:"text-[10px] bg-green-100 text-green-700 border-green-200",iconClassName:"text-green-600",models:l.filter(j=>j.tier!=="paid")},{key:"paid",label:"Paid Tier",description:"Requires paid access",badgeClassName:"text-[10px] bg-amber-100 text-amber-700 border-amber-200",iconClassName:"text-amber-700",models:l.filter(j=>j.tier==="paid")}].filter(j=>j.models.length>0):[{key:"default",models:l.slice(0,4)}]},[s]),E=y.length>0||t.length>0;return e.jsxs(e.Fragment,{children:[E&&e.jsxs("div",{children:[e.jsxs("h3",{className:"text-sm font-medium mb-2 flex items-center gap-2",children:[e.jsx(ve,{className:"w-4 h-4"}),"Presets"]}),e.jsx("p",{className:"text-xs text-muted-foreground mb-3",children:"Apply pre-configured model mappings"}),e.jsxs("div",{className:"space-y-4",children:[y.map(l=>e.jsxs("div",{children:["label"in l&&l.label&&e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(B,{variant:"outline",className:l.badgeClassName,children:l.label}),e.jsx("span",{className:"text-[10px] text-muted-foreground",children:l.description})]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:l.models.map(A=>e.jsxs(R,{variant:"outline",size:"sm",className:"text-xs h-7 gap-1",onClick:()=>w(Aa(A)),children:[e.jsx(Ne,{className:`w-3 h-3 ${"iconClassName"in l?l.iconClassName:""}`}),A.name]},A.id))})]},l.key)),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[t.map(l=>e.jsxs("div",{className:"group relative",children:[e.jsxs(R,{variant:"secondary",size:"sm",className:"text-xs h-7 gap-1 pr-6",onClick:()=>{w({ANTHROPIC_MODEL:l.default,ANTHROPIC_DEFAULT_OPUS_MODEL:l.opus,ANTHROPIC_DEFAULT_SONNET_MODEL:l.sonnet,ANTHROPIC_DEFAULT_HAIKU_MODEL:l.haiku})},children:[e.jsx(Pe,{className:"w-3 h-3 fill-current"}),l.name]}),e.jsx(R,{variant:"ghost",size:"icon",className:"absolute right-0 top-0 h-7 w-5 opacity-0 group-hover:opacity-100 hover:text-destructive",onClick:A=>{A.stopPropagation(),p(l.name)},disabled:N,children:e.jsx(Xe,{className:"w-3 h-3"})})]},l.name)),e.jsxs(R,{variant:"outline",size:"sm",className:"text-xs h-7 gap-1 border-primary/50 text-primary hover:bg-primary/10 hover:border-primary",onClick:c,children:[e.jsx(Rs,{className:"w-3 h-3"}),"Custom"]})]})]})]}),e.jsx(Ze,{}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-medium mb-2",children:"Model Mapping"}),e.jsx("p",{className:"text-xs text-muted-foreground mb-4",children:"Configure which models to use for each tier"}),r==="codex"&&e.jsxs("p",{className:"text-[11px] text-muted-foreground mb-3 rounded-md border bg-muted/30 px-2.5 py-2",children:["Codex tip: suffixes ",e.jsx("code",{children:"-medium"}),", ",e.jsx("code",{children:"-high"}),", and ",e.jsx("code",{children:"-xhigh"})," ","pin reasoning effort. Unsuffixed models use Thinking settings."]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx(re,{label:"Default Model",description:"Used when no specific tier is requested",value:a,onChange:l=>f("ANTHROPIC_MODEL",l),catalog:s,allModels:u}),b?.extendedContext&&g&&e.jsx(Ca,{model:b,provider:r,enabled:x??!1,onToggle:g}),e.jsx(re,{label:"Opus (Most capable)",description:"For complex reasoning tasks",value:n,onChange:l=>f("ANTHROPIC_DEFAULT_OPUS_MODEL",l),catalog:s,allModels:u}),e.jsx(re,{label:"Sonnet (Balanced)",description:"Balance of speed and capability",value:i,onChange:l=>f("ANTHROPIC_DEFAULT_SONNET_MODEL",l),catalog:s,allModels:u}),e.jsx(re,{label:"Haiku (Fast)",description:"Quick responses for simple tasks",value:m,onChange:l=>f("ANTHROPIC_DEFAULT_HAIKU_MODEL",l),catalog:s,allModels:u})]})]})]})}function ps(s){const t=Math.max(0,Math.min(100,s));return t<=20?"bg-destructive":t<=50?"bg-yellow-500":"bg-green-500"}function hs(s){if(!s)return"";try{const t=new Date(s),n=new Date().getTime()-t.getTime();if(n<0)return"just now";const i=Math.floor(n/(1e3*60)),m=Math.floor(n/(1e3*60*60)),u=Math.floor(n/(1e3*60*60*24));return u>0?`${u}d ago`:m>0?`${m}h ago`:i>0?`${i}m ago`:"just now"}catch{return""}}function Pa(s){if(!s)return!1;try{const t=new Date(s);return new Date().getTime()-t.getTime()<3600*1e3}catch{return!1}}function Ma({account:s,onSetDefault:t,onRemove:a,onPauseToggle:n,isRemoving:i,isPausingAccount:m,privacyMode:u,showQuota:r,selectable:x,selected:g,onSelectChange:w}){const{t:f}=Z(),c=s.provider.toLowerCase(),p=c==="codex",N=c==="claude"||c==="anthropic",{data:b}=at(r),{data:y,isLoading:E}=nt(c,s.id,r),l=b?.accountStats?.[s.email||s.id]?.lastUsedAt,A=Pa(l),j=it(s.provider,y),F=rt(s.provider,y),P=p&&y&&ot(y)?lt(y.windows):null,h=[{label:"5h",value:P?.fiveHourWindow?.remainingPercent??null},{label:"Weekly",value:P?.weeklyWindow?.remainingPercent??null}].filter(I=>I.value!==null),U=N&&y&&ct(y)?[{label:"5h",value:y.coreUsage?.fiveHour?.remainingPercent??y.windows.find(I=>I.rateLimitType==="five_hour")?.remainingPercent??null},{label:"Weekly",value:y.coreUsage?.weekly?.remainingPercent??y.windows.find(I=>["seven_day","seven_day_opus","seven_day_sonnet","seven_day_oauth_apps","seven_day_cowork"].includes(I.rateLimitType))?.remainingPercent??null}].filter(I=>I.value!==null):[],k=p?h:N?U:[],S=j!==null?pt(j):null,O=S!==null?Number(S):null,v=dt(y),C=v?.label==="Reauth"?Kt:v?.tone==="warning"?Se:Bt,K=v?.tone==="warning"?"border-amber-500/50 text-amber-600 dark:text-amber-400":v?.tone==="destructive"?"border-destructive/50 text-destructive":"border-muted-foreground/50 text-muted-foreground";return e.jsxs("div",{className:G("flex flex-col gap-2 p-3 rounded-lg border transition-colors overflow-hidden",s.isDefault?"border-primary/30 bg-primary/5":"border-border hover:bg-muted/30",s.paused&&"opacity-75",g&&"ring-2 ring-primary/50 bg-primary/5"),children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0 flex-1",children:[x&&e.jsx("button",{type:"button",onClick:()=>w?.(!g),className:G("flex items-center justify-center w-5 h-5 rounded border-2 transition-colors shrink-0",g?"bg-primary border-primary text-primary-foreground":"border-muted-foreground/30 hover:border-primary/50"),"aria-label":g?"Deselect account":"Select account",children:g&&e.jsx(ce,{className:"w-3 h-3"})}),n&&e.jsx(pe,{children:e.jsxs(he,{children:[e.jsx(ge,{asChild:!0,children:e.jsx(R,{variant:"ghost",size:"icon",className:"h-7 w-7 shrink-0",onClick:()=>n(!s.paused),disabled:m,children:m?e.jsx(W,{className:"w-4 h-4 animate-spin"}):s.paused?e.jsx(Ls,{className:"w-4 h-4 text-emerald-500"}):e.jsx(qe,{className:"w-4 h-4 text-muted-foreground hover:text-foreground"})})}),e.jsx(fe,{side:"top",children:s.paused?"Resume account":"Pause account"})]})}),e.jsxs("div",{className:"relative shrink-0",children:[e.jsx("div",{className:G("flex items-center justify-center w-8 h-8 rounded-full",s.isDefault?"bg-primary/10":"bg-muted"),children:e.jsx(xe,{className:"w-4 h-4"})}),s.tier&&s.tier!=="unknown"&&s.tier!=="free"&&e.jsx("span",{className:G("absolute -bottom-0.5 -right-0.5 text-[7px] font-bold uppercase px-1 py-px rounded","ring-1 ring-background",s.tier==="ultra"?"bg-violet-500/20 text-violet-600 dark:bg-violet-500/30 dark:text-violet-300":"bg-yellow-500/20 text-yellow-700 dark:bg-yellow-500/25 dark:text-yellow-400"),children:s.tier==="ultra"?"U":"P"})]}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:G("font-medium text-sm truncate",u&&Ae),children:s.email||s.id}),s.isDefault&&e.jsxs(B,{variant:"secondary",className:"text-[10px] h-4 px-1.5 gap-0.5",children:[e.jsx(Pe,{className:"w-2.5 h-2.5 fill-current"}),"Default"]}),s.paused&&e.jsxs(B,{variant:"outline",className:"text-[10px] h-4 px-1.5 border-yellow-500 text-yellow-600",children:[e.jsx(qe,{className:"w-2 h-2 mr-0.5"}),"Paused"]})]}),s.provider==="agy"&&e.jsx("div",{className:"flex items-center gap-1.5 mt-1",children:s.projectId?e.jsx(pe,{children:e.jsxs(he,{children:[e.jsx(ge,{asChild:!0,children:e.jsxs("div",{className:"flex items-center gap-1 text-xs text-muted-foreground",children:[e.jsx(Vt,{className:"w-3 h-3","aria-hidden":"true"}),e.jsx("span",{className:G("font-mono max-w-[180px] truncate",u&&Ae),title:s.projectId,children:s.projectId})]})}),e.jsx(fe,{side:"bottom",children:e.jsx("p",{className:"text-xs",children:"GCP Project ID (read-only)"})})]})}):e.jsx(pe,{children:e.jsxs(he,{children:[e.jsx(ge,{asChild:!0,children:e.jsxs("div",{className:"flex items-center gap-1 text-xs text-amber-600 dark:text-amber-500",children:[e.jsx(Se,{className:"w-3 h-3","aria-label":"Warning"}),e.jsx("span",{children:"Project ID: N/A"})]})}),e.jsx(fe,{side:"bottom",className:"max-w-[250px]",children:e.jsxs("div",{className:"text-xs space-y-1",children:[e.jsx("p",{className:"font-medium text-amber-600",children:"Missing Project ID"}),e.jsx("p",{children:"This may cause errors. Remove the account and re-add it to fetch the project ID."})]})})]})})}),s.lastUsedAt&&e.jsxs("div",{className:"flex items-center gap-1 text-xs text-muted-foreground mt-0.5",children:[e.jsx(cs,{className:"w-3 h-3"}),"Last used: ",new Date(s.lastUsedAt).toLocaleDateString()]})]})]}),e.jsxs(ut,{children:[e.jsx(mt,{asChild:!0,children:e.jsx(R,{variant:"ghost",size:"icon",className:"h-7 w-7 shrink-0",children:e.jsx(Gt,{className:"w-4 h-4"})})}),e.jsxs(xt,{align:"end",children:[!s.isDefault&&e.jsxs(rs,{onClick:t,children:[e.jsx(Pe,{className:"w-4 h-4 mr-2"}),"Set as default"]}),e.jsxs(rs,{className:"text-destructive focus:text-destructive",onClick:a,disabled:i,children:[e.jsx(Is,{className:"w-4 h-4 mr-2"}),i?"Removing...":"Remove account"]})]})]})]}),r&&e.jsx("div",{className:"pl-11",children:E?e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[e.jsx(W,{className:"w-3 h-3 animate-spin"}),e.jsx("span",{children:"Loading quota..."})]}):O!==null?e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("div",{className:"flex items-center gap-1.5 text-xs",children:A?e.jsxs(e.Fragment,{children:[e.jsx($t,{className:"w-3 h-3 text-emerald-500"}),e.jsxs("span",{className:"text-emerald-600 dark:text-emerald-400",children:["Active · ",hs(l)]})]}):l?e.jsxs(e.Fragment,{children:[e.jsx(cs,{className:"w-3 h-3 text-muted-foreground"}),e.jsxs("span",{className:"text-muted-foreground",children:["Last used ",hs(l)]})]}):e.jsxs(e.Fragment,{children:[e.jsx(ds,{className:"w-3 h-3 text-muted-foreground"}),e.jsx("span",{className:"text-muted-foreground",children:"Not used yet"})]})}),e.jsx(pe,{children:e.jsxs(he,{children:[e.jsx(ge,{asChild:!0,children:k.length>0?e.jsx("div",{className:"space-y-1.5",children:k.map(I=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"w-10 text-[10px] text-muted-foreground",children:I.label}),e.jsx(Ue,{value:Math.max(0,Math.min(100,I.value)),className:"h-2 flex-1",indicatorClassName:ps(I.value)}),e.jsxs("span",{className:"text-xs font-medium w-10 text-right",children:[I.value,"%"]})]},I.label))}):e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ue,{value:Math.max(0,Math.min(100,O)),className:"h-2 flex-1",indicatorClassName:ps(O)}),e.jsxs("span",{className:"text-xs font-medium w-10 text-right",children:[S,"%"]})]})}),e.jsx(fe,{side:"bottom",className:"max-w-xs",children:e.jsx(ht,{quota:y,resetTime:F})})]})})]}):y?.success?e.jsx("div",{className:"flex items-center gap-1.5",children:e.jsxs(B,{variant:"outline",className:"text-[10px] h-5 px-2 gap-1 border-muted-foreground/50 text-muted-foreground",children:[e.jsx(ds,{className:"w-3 h-3"}),f("accountCard.quotaUnavailable")]})}):v?e.jsx(pe,{children:e.jsxs(he,{children:[e.jsx(ge,{asChild:!0,children:e.jsx("div",{className:"flex items-center gap-1.5",children:e.jsxs(B,{variant:"outline",className:G("text-[10px] h-5 px-2 gap-1",K),children:[e.jsx(C,{className:"w-3 h-3"}),v.label]})})}),e.jsx(fe,{side:"bottom",className:"max-w-[260px]",children:e.jsxs("div",{className:"space-y-1 text-xs",children:[e.jsx("p",{children:v.summary}),v.actionHint&&e.jsx("p",{className:"text-muted-foreground",children:v.actionHint}),v.technicalDetail&&e.jsx("p",{className:"font-mono text-[11px] text-muted-foreground",children:v.technicalDetail}),v.rawDetail&&e.jsx("pre",{className:"whitespace-pre-wrap break-all rounded bg-muted/40 px-2 py-1 font-mono text-[10px] text-muted-foreground",children:v.rawDetail})]})})]})}):null})]})}function Ta({selectedCount:s,onPauseSelected:t,onResumeSelected:a,onClearSelection:n,isPausing:i,isResuming:m}){if(s<1)return null;const u=i||m;return e.jsxs("div",{className:"flex items-center gap-3 p-2 bg-muted/50 rounded-lg border mt-2",children:[e.jsxs("span",{className:"text-sm text-muted-foreground",children:[s," selected"]}),e.jsx(R,{variant:"ghost",size:"sm",className:"text-xs h-6 px-2",onClick:n,disabled:u,children:"Clear"}),e.jsxs("div",{className:"flex gap-2 ml-auto",children:[e.jsxs(R,{size:"sm",variant:"outline",className:"h-7 text-xs gap-1",onClick:t,disabled:u,children:[i?e.jsx(W,{className:"w-3 h-3 animate-spin"}):e.jsx(qe,{className:"w-3 h-3"}),"Pause Selected"]}),e.jsxs(R,{size:"sm",variant:"outline",className:"h-7 text-xs gap-1",onClick:a,disabled:u,children:[m?e.jsx(W,{className:"w-3 h-3 animate-spin"}):e.jsx(Ls,{className:"w-3 h-3"}),"Resume Selected"]})]})]})}function Da({accounts:s,onAddAccount:t,onSetDefault:a,onRemoveAccount:n,onPauseToggle:i,onSoloMode:m,onBulkPause:u,onBulkResume:r,isRemovingAccount:x,isPausingAccount:g,isSoloingAccount:w,isBulkPausing:f,isBulkResuming:c,privacyMode:p,showQuota:N,isKiro:b,kiroNoIncognito:y,onKiroNoIncognitoChange:E,kiroSettingsLoading:l}){const[A,j]=o.useState(new Set),F=o.useMemo(()=>new Set(s.map(_=>_.id)),[s]),P=o.useMemo(()=>new Set([...A].filter(_=>F.has(_))),[A,F]),h=!!(u&&r),U=P.size,k=s.length>0&&P.size===s.length,S=P.size>0&&P.size<s.length,O=o.useCallback(_=>{j(H=>{const V=new Set(H);return V.has(_)?V.delete(_):V.add(_),V})},[]),v=o.useCallback(()=>{j(new Set(s.map(_=>_.id)))},[s]),C=o.useCallback(()=>{j(new Set)},[]),K=o.useCallback(()=>{k?C():v()},[k,v,C]),I=o.useCallback(()=>{u&&P.size>0&&(u(Array.from(P)),j(new Set))},[u,P]),T=o.useCallback(()=>{r&&P.size>0&&(r(Array.from(P)),j(new Set))},[r,P]);return e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsxs("h3",{className:"text-sm font-medium flex items-center gap-2",children:[h&&s.length>0&&e.jsx(Ce,{checked:k,onCheckedChange:K,"aria-label":"Select all accounts",className:S?"data-[state=checked]:bg-primary/50":"",...S?{"data-state":"indeterminate"}:{}}),e.jsx(xe,{className:"w-4 h-4"}),"Accounts",s.length>0&&e.jsx(B,{variant:"secondary",className:"text-xs",children:s.length})]}),e.jsxs(R,{variant:"default",size:"sm",className:"h-7 text-xs gap-1",onClick:t,children:[e.jsx(Rs,{className:"w-3 h-3"}),"Add"]})]}),h&&U>0&&e.jsx(Ta,{selectedCount:U,onPauseSelected:I,onResumeSelected:T,onClearSelection:C,isPausing:!!f,isResuming:!!c}),s.length>0?e.jsx("div",{className:"space-y-2",children:s.map(_=>e.jsx(Ma,{account:_,onSetDefault:()=>a(_.id),onRemove:()=>n(_.id),onPauseToggle:i?H=>i(_.id,H):void 0,onSoloMode:m?()=>m(_.id):void 0,isRemoving:x,isPausingAccount:g,isSoloingAccount:w,privacyMode:p,showQuota:N,selectable:h,selected:P.has(_.id),onSelectChange:()=>O(_.id)},_.id))}):e.jsxs("div",{className:"py-6 text-center text-muted-foreground bg-muted/30 rounded-lg border border-dashed",children:[e.jsx(xe,{className:"w-8 h-8 mx-auto mb-2 opacity-50"}),e.jsx("p",{className:"text-sm",children:"No accounts connected"}),e.jsx("p",{className:"text-xs opacity-70",children:"Add an account to get started"})]}),b&&E&&e.jsx("div",{className:"mt-3 pt-3 border-t border-dashed",children:e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(_s,{className:"w-3.5 h-3.5"}),e.jsx("span",{children:"Use incognito"})]}),e.jsx(Us,{checked:!y,onCheckedChange:_=>E(!_),disabled:l,className:"scale-90"})]})})]})}function Oa({provider:s,catalog:t,savedPresets:a,currentModel:n,opusModel:i,sonnetModel:m,haikuModel:u,providerModels:r,extendedContextEnabled:x,onExtendedContextToggle:g,onApplyPreset:w,onUpdateEnvValue:f,onOpenCustomPreset:c,onDeletePreset:p,isDeletePending:N,accounts:b,onAddAccount:y,onSetDefault:E,onRemoveAccount:l,onPauseToggle:A,onSoloMode:j,onBulkPause:F,onBulkResume:P,isRemovingAccount:h,isPausingAccount:U,isSoloingAccount:k,isBulkPausing:S,isBulkResuming:O,privacyMode:v,isRemoteMode:C}){const K=s.toLowerCase(),I=(gt.includes(K)||["anthropic","antigravity","gemini-cli","copilot","github-copilot"].includes(K))&&!C,T=s==="kiro",[_,H]=o.useState(!0),[V,se]=o.useState(!0),[z,Y]=o.useState(!1),te=o.useCallback(async()=>{if(T)try{se(!0);const $=(await we.config.get()).cliproxy;H($?.kiro_no_incognito??!0)}catch{H(!0)}finally{se(!1)}},[T]),d=o.useCallback(async D=>{H(D),Y(!0);try{const $=await we.config.get(),de=$.cliproxy??{};await we.config.update({...$,cliproxy:{...de,kiro_no_incognito:D}})}catch{H(!D)}finally{Y(!1)}},[]);return o.useEffect(()=>{te()},[te]),e.jsx(ze,{className:"flex-1",children:e.jsxs("div",{className:"p-4 space-y-6",children:[e.jsx(Sa,{catalog:t,savedPresets:a,currentModel:n,opusModel:i,sonnetModel:m,haikuModel:u,providerModels:r,provider:s,extendedContextEnabled:x,onExtendedContextToggle:g,onApplyPreset:w,onUpdateEnvValue:f,onOpenCustomPreset:c,onDeletePreset:p,isDeletePending:N}),e.jsx(Ze,{}),e.jsx(Da,{accounts:b,onAddAccount:y,onSetDefault:E,onRemoveAccount:l,onPauseToggle:A,onSoloMode:j,onBulkPause:F,onBulkResume:P,isRemovingAccount:h,isPausingAccount:U,isSoloingAccount:k,isBulkPausing:S,isBulkResuming:O,privacyMode:v,showQuota:I,isKiro:T,kiroNoIncognito:_,onKiroNoIncognitoChange:d,kiroSettingsLoading:V||z})]})})}function gs({provider:s,displayName:t,authStatus:a,catalog:n,logoProvider:i,baseProvider:m,isRemoteMode:u,port:r,defaultTarget:x,onAddAccount:g,onSetDefault:w,onRemoveAccount:f,onPauseToggle:c,onSoloMode:p,onBulkPause:N,onBulkResume:b,isRemovingAccount:y,isPausingAccount:E,isSoloingAccount:l,isBulkPausing:A,isBulkResuming:j}){const[F,P]=o.useState(!1),{privacyMode:h}=Cs(),{data:U}=ft(),{data:k}=jt(s),S=vt(),O=Nt(),v=m||s,C=v.toLowerCase()==="agy",K=o.useMemo(()=>{const L=k?.presets||[];return C?L.filter(Q=>!ee(Q.default)&&!ee(Q.opus)&&!ee(Q.sonnet)&&!ee(Q.haiku)):L},[C,k?.presets]),I=o.useMemo(()=>{if(!U?.models)return[];const Q={gemini:["google"],agy:["antigravity"],codex:["openai"],qwen:["alibaba","qwen"],iflow:["iflow"],kiro:["kiro","aws"],ghcp:["github","copilot"],kimi:["kimi","moonshot"]}[v.toLowerCase()]||[v.toLowerCase()];return U.models.filter(ie=>Q.some(Ee=>ie.owned_by.toLowerCase().includes(Ee))?C?!ee(ie.id):!0:!1)},[C,U,v]),T=(m||s).toLowerCase(),{data:_,isLoading:H,refetch:V,rawJsonContent:se,rawJsonEdits:z,isRawJsonValid:Y,hasChanges:te,currentModel:d,opusModel:D,sonnetModel:$,haikuModel:de,extendedContextEnabled:Me,toggleExtendedContext:Te,handleRawJsonChange:De,updateEnvValue:Oe,updateEnvValues:J,saveMutation:M,conflictDialog:ne,handleConflictResolve:ae,missingRequiredFields:ts}=fa(s),ye=o.useMemo(()=>(a.accounts||[]).map(L=>({...L,provider:L.provider||m||s})),[a.accounts,m,s]),{data:Ks}=fs({queryKey:["auth-tokens-raw"],queryFn:async()=>{const L=await fetch("/api/settings/auth/tokens/raw");return L.ok?L.json():{apiKey:{value:"ccs-internal-managed"}}},staleTime:6e4}),as=Ks?.apiKey?.value??"ccs-internal-managed",Bs=L=>{if(C&&[L.ANTHROPIC_MODEL,L.ANTHROPIC_DEFAULT_OPUS_MODEL,L.ANTHROPIC_DEFAULT_SONNET_MODEL,L.ANTHROPIC_DEFAULT_HAIKU_MODEL].some(ie=>typeof ie=="string"&&ee(ie))){q.error("Antigravity denylist: Claude Opus 4.5 and Claude Sonnet 4.5 are deprecated.");return}J({ANTHROPIC_BASE_URL:`http://127.0.0.1:${r??He}/api/provider/${T}`,ANTHROPIC_AUTH_TOKEN:as,...L}),q.success(`Applied "${L.ANTHROPIC_MODEL?.split("/").pop()||"preset"}" preset`)},Vs=(L,Q)=>{if(C&&[L.default,L.opus,L.sonnet,L.haiku].some(Ee=>ee(Ee))){q.error("Antigravity denylist: Claude Opus 4.5 and Claude Sonnet 4.5 are deprecated.");return}J({ANTHROPIC_BASE_URL:`http://127.0.0.1:${r??He}/api/provider/${T}`,ANTHROPIC_AUTH_TOKEN:as,ANTHROPIC_MODEL:L.default,ANTHROPIC_DEFAULT_OPUS_MODEL:L.opus,ANTHROPIC_DEFAULT_SONNET_MODEL:L.sonnet,ANTHROPIC_DEFAULT_HAIKU_MODEL:L.haiku}),q.success(`Applied ${Q?`"${Q}"`:"custom"} preset`),P(!1)},Gs=(L,Q)=>{if(!Q){q.error(Ss.t("commonToast.enterPresetName"));return}if(C&&[L.default,L.opus,L.sonnet,L.haiku].some(ie=>ee(ie))){q.error("Antigravity denylist: Claude Opus 4.5 and Claude Sonnet 4.5 are deprecated.");return}S.mutate({profile:s,data:{name:Q,...L}}),P(!1)};return e.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden",children:[e.jsx(ka,{provider:s,displayName:t,logoProvider:i,data:_,isLoading:H,hasChanges:te,isRawJsonValid:Y,isSaving:M.isPending,isRemoteMode:u,port:r,onRefetch:V,onSave:()=>M.mutate()}),H?e.jsxs("div",{className:"flex-1 flex items-center justify-center",children:[e.jsx(W,{className:"w-8 h-8 animate-spin text-muted-foreground"}),e.jsx("span",{className:"ml-3 text-muted-foreground",children:"Loading settings..."})]}):e.jsxs("div",{className:"flex-1 grid grid-cols-[40%_60%] divide-x overflow-hidden",children:[e.jsx("div",{className:"flex flex-col overflow-hidden bg-muted/5",children:e.jsxs(yt,{defaultValue:"config",className:"h-full flex flex-col",children:[e.jsx("div",{className:"px-4 pt-4 shrink-0",children:e.jsxs(bt,{className:"w-full",children:[e.jsx(os,{value:"config",className:"flex-1",children:"Model Config"}),e.jsx(os,{value:"info",className:"flex-1",children:"Info & Usage"})]})}),e.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col",children:[e.jsx(ls,{value:"config",className:"flex-1 mt-0 border-0 p-0 data-[state=inactive]:hidden flex flex-col overflow-hidden",children:e.jsx(Oa,{provider:s,catalog:n,savedPresets:K,currentModel:d,opusModel:D,sonnetModel:$,haikuModel:de,providerModels:I,extendedContextEnabled:Me,onExtendedContextToggle:Te,onApplyPreset:Bs,onUpdateEnvValue:Oe,onOpenCustomPreset:()=>P(!0),onDeletePreset:L=>O.mutate({profile:s,name:L}),isDeletePending:O.isPending,accounts:ye,onAddAccount:g,onSetDefault:w,onRemoveAccount:f,onPauseToggle:c,onSoloMode:p,onBulkPause:N,onBulkResume:b,isRemovingAccount:y,isPausingAccount:E,isSoloingAccount:l,isBulkPausing:A,isBulkResuming:j,privacyMode:h,isRemoteMode:u})}),e.jsx(ls,{value:"info",className:"h-full mt-0 border-0 p-0 data-[state=inactive]:hidden",children:e.jsx(wa,{provider:s,displayName:t,defaultTarget:x,data:_,authStatus:a})})]})]})}),e.jsxs("div",{className:"flex flex-col overflow-hidden",children:[e.jsxs("div",{className:"px-6 py-2 bg-muted/30 border-b flex items-center gap-2 shrink-0 h-[45px]",children:[e.jsx(Qt,{className:"w-4 h-4 text-muted-foreground"}),e.jsx("span",{className:"text-sm font-medium text-muted-foreground",children:"Raw Configuration (JSON)"})]}),e.jsx(wt,{rawJsonContent:se,isRawJsonValid:Y,rawJsonEdits:z,onRawJsonChange:De,profileEnv:_?.settings?.env,missingRequiredFields:ts})]})]}),e.jsx(Yt,{open:ne,title:"File Modified Externally",description:"This settings file was modified by another process. Overwrite with your changes or discard?",confirmText:"Overwrite",variant:"destructive",onConfirm:()=>ae(!0),onCancel:()=>ae(!1)}),e.jsx(ba,{open:F,onClose:()=>P(!1),currentValues:{default:d||"",opus:D||"",sonnet:$||"",haiku:de||""},onApply:Vs,onSave:Gs,isSaving:S.isPending,catalog:n,allModels:I})]})}function Ea({status:s,isSelected:t,onSelect:a}){const{t:n}=Z(),i=s.accounts?.length||0;return e.jsxs("button",{className:G("w-full flex items-center gap-3 px-3 py-2.5 rounded-lg transition-colors cursor-pointer text-left",t?"bg-primary/10 border border-primary/20":"hover:bg-muted border border-transparent"),onClick:a,children:[e.jsx(Je,{provider:s.provider,size:"md"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"font-medium text-sm truncate",children:s.displayName}),i>0&&e.jsx(B,{variant:"secondary",className:"text-[10px] h-4 px-1",children:i})]}),e.jsx("div",{className:"flex items-center gap-1.5 mt-0.5",children:s.authenticated?e.jsxs(e.Fragment,{children:[e.jsx(ce,{className:"w-3 h-3 text-green-600"}),e.jsx("span",{className:"text-xs text-green-600",children:n("cliproxyPage.connected")})]}):e.jsxs(e.Fragment,{children:[e.jsx(Xe,{className:"w-3 h-3 text-muted-foreground"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:n("cliproxyPage.notConnected")})]})})]})]})}function _a({variant:s,parentAuth:t,isSelected:a,onSelect:n,onDelete:i,isDeleting:m}){const{t:u}=Z();return e.jsxs("button",{className:G("group w-full flex items-center gap-3 px-3 py-2 rounded-lg transition-colors cursor-pointer text-left pl-6",a?"bg-primary/10 border border-primary/20":"hover:bg-muted border border-transparent"),onClick:n,children:[e.jsxs("div",{className:"relative",children:[e.jsx(Je,{provider:s.provider,size:"sm"}),e.jsx(Fs,{className:"w-2.5 h-2.5 absolute -bottom-0.5 -right-0.5 text-muted-foreground"})]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"font-medium text-sm truncate",children:s.name}),e.jsx(B,{variant:"outline",className:"text-[9px] h-4 px-1",children:u("cliproxyPage.variant")}),e.jsx(B,{variant:"outline",className:"text-[9px] h-4 px-1 uppercase",children:s.target||"claude"})]}),e.jsx("div",{className:"flex items-center gap-1.5 mt-0.5",children:t?.authenticated?e.jsxs(e.Fragment,{children:[e.jsx(ce,{className:"w-3 h-3 text-green-600"}),e.jsx("span",{className:"text-xs text-muted-foreground truncate",children:u("cliproxyPage.viaProvider",{provider:s.provider})})]}):e.jsxs(e.Fragment,{children:[e.jsx(Xe,{className:"w-3 h-3 text-muted-foreground"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:u("cliproxyPage.parentNotConnected")})]})})]}),e.jsx(R,{variant:"ghost",size:"icon",className:"h-6 w-6 opacity-0 group-hover:opacity-100 hover:text-destructive",onClick:r=>{r.stopPropagation(),i()},disabled:m,children:e.jsx(Is,{className:"w-3 h-3"})})]})}function Ra({onSetup:s}){const{t}=Z();return e.jsx("div",{className:"flex-1 flex items-center justify-center bg-muted/20",children:e.jsxs("div",{className:"text-center max-w-md px-8",children:[e.jsx("div",{className:"w-16 h-16 rounded-full bg-muted flex items-center justify-center mx-auto mb-6",children:e.jsx(Ne,{className:"w-8 h-8 text-muted-foreground"})}),e.jsx("h2",{className:"text-xl font-semibold mb-2",children:t("cliproxyPage.emptyTitle")}),e.jsx("p",{className:"text-muted-foreground mb-4",children:t("cliproxyPage.emptyDesc")}),e.jsxs("p",{className:"text-xs text-muted-foreground mb-6",children:[t("cliproxyPage.emptyControlPanelPrefix")," ",e.jsx("a",{href:"/cliproxy/control-panel",className:"text-primary hover:underline",children:t("cliproxyPage.controlPanel")}),"."]}),e.jsxs(R,{onClick:s,className:"gap-2",children:[e.jsx(ve,{className:"w-4 h-4"}),t("cliproxyPage.quickSetup")]})]})})}function Za(){const{t:s}=Z(),t=Be(),{data:a,isLoading:n}=ks(),{data:i,isFetching:m}=kt(),{data:u}=Ct(),r=At(),x=St(),g=Pt(),w=Mt(),f=Tt(),c=Dt(),p=Ot(),N=Et(),[b,y]=o.useState(()=>{if(typeof window<"u"){const D=new URLSearchParams(window.location.search).get("provider")?.trim().toLowerCase();return D&&Fe(D)?D:localStorage.getItem("cliproxy-selected-provider")}return null}),[E,l]=o.useState(null),[A,j]=o.useState(!1),[F,P]=o.useState(()=>{if(typeof window>"u")return null;const d=new URLSearchParams(window.location.search),D=d.get("provider")?.trim().toLowerCase();return d.get("action")!=="auth"||!D||!Fe(D)?null:{provider:D,displayName:_t(D),isFirstAccount:!1}}),h=o.useMemo(()=>a?.authStatus||[],[a?.authStatus]),U=a?.source==="remote",k=o.useMemo(()=>i?.variants||[],[i?.variants]),S=d=>{y(d),d&&localStorage.setItem("cliproxy-selected-provider",d)},O=o.useMemo(()=>E?null:b&&h.some(d=>d.provider===b)?b:h.length>0&&(h.find(D=>(D.accounts?.length||0)>0)?.provider||h[0]?.provider)||null,[b,E,h]),v=h.find(d=>d.provider===O),C=k.find(d=>d.name===E),K=C?h.find(d=>d.provider===C.provider):void 0,I=(C?.provider||v?.provider||"").toLowerCase().trim(),T=I==="gemini"||I==="agy",_=()=>{t.invalidateQueries({queryKey:["cliproxy"]}),t.invalidateQueries({queryKey:["cliproxy-auth"]})},H=(d,D,$)=>{g.isPending||w.isPending||($?g.mutate({provider:d,accountId:D}):w.mutate({provider:d,accountId:D}))},V=(d,D)=>{f.isPending||f.mutate({provider:d,accountId:D})},se=(d,D)=>{c.isPending||c.mutate({provider:d,accountIds:D})},z=(d,D)=>{p.isPending||p.mutate({provider:d,accountIds:D})},Y=d=>{S(d),l(null)},te=d=>{l(d),S(null)};return e.jsxs("div",{className:"h-[calc(100vh-100px)] flex",children:[e.jsxs("div",{className:"w-80 border-r flex flex-col bg-muted/30",children:[e.jsxs("div",{className:"p-4 border-b bg-background",children:[e.jsxs("div",{className:"flex items-center justify-between mb-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ne,{className:"w-5 h-5 text-primary"}),e.jsx("h1",{className:"font-semibold",children:u?.backendLabel??"CLIProxy"})]}),e.jsx(R,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:_,disabled:m,children:e.jsx(Ye,{className:G("w-4 h-4",m&&"animate-spin")})})]}),e.jsx("p",{className:"text-xs text-muted-foreground mb-3",children:s("cliproxyPage.accountManagement")}),e.jsxs(R,{variant:"default",size:"sm",className:"w-full gap-2",onClick:()=>j(!0),children:[e.jsx(ve,{className:"w-4 h-4"}),s("cliproxyPage.quickSetup")]})]}),e.jsx(ze,{className:"flex-1",children:e.jsxs("div",{className:"p-2",children:[e.jsx("div",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide px-3 py-2",children:s("cliproxyPage.providers")}),n?e.jsx("div",{className:"space-y-2 px-2",children:[1,2,3,4].map(d=>e.jsx(Rt,{className:"h-14 w-full rounded-lg"},d))}):e.jsx("div",{className:"space-y-1",children:h.map(d=>e.jsx(Ea,{status:d,isSelected:O===d.provider,onSelect:()=>Y(d.provider)},d.provider))}),k.length>0&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide px-3 py-2 mt-4 flex items-center gap-1.5",children:[e.jsx(Fs,{className:"w-3 h-3"}),s("cliproxyPage.variants")]}),e.jsx("div",{className:"space-y-1",children:k.map(d=>e.jsx(_a,{variant:d,parentAuth:h.find(D=>D.provider===d.provider),isSelected:E===d.name,onSelect:()=>te(d.name),onDelete:()=>N.mutate(d.name),isDeleting:N.isPending},d.name))})]})]})}),e.jsx("div",{className:"p-3 border-t",children:e.jsx(Wt,{})}),e.jsx("div",{className:"p-3 border-t bg-background text-xs text-muted-foreground",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{children:s("cliproxyPage.providerCount",{count:h.length})}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(ce,{className:"w-3 h-3 text-green-600"}),s("cliproxyPage.connectedCount",{count:h.filter(d=>d.authenticated).length})]})]})})]}),e.jsxs("div",{className:"flex-1 flex flex-col min-w-0 bg-background",children:[T&&e.jsx(Hs,{showProxySettingsLink:!0,className:"mx-4 mt-4"}),C&&K?e.jsx(gs,{provider:C.name,displayName:s("cliproxyPage.variantDisplay",{name:C.name,provider:C.provider}),authStatus:K,catalog:je[C.provider],logoProvider:C.provider,baseProvider:C.provider,defaultTarget:C.target,isRemoteMode:U,port:C.port,onAddAccount:()=>P({provider:C.provider,displayName:K.displayName,isFirstAccount:(K.accounts?.length||0)===0}),onSetDefault:d=>r.mutate({provider:C.provider,accountId:d}),onRemoveAccount:d=>x.mutate({provider:C.provider,accountId:d}),onPauseToggle:(d,D)=>H(C.provider,d,D),onSoloMode:d=>V(C.provider,d),onBulkPause:d=>se(C.provider,d),onBulkResume:d=>z(C.provider,d),isRemovingAccount:x.isPending,isPausingAccount:g.isPending||w.isPending,isSoloingAccount:f.isPending,isBulkPausing:c.isPending,isBulkResuming:p.isPending}):v?e.jsx(gs,{provider:v.provider,displayName:v.displayName,authStatus:v,catalog:je[v.provider],isRemoteMode:U,onAddAccount:()=>P({provider:v.provider,displayName:v.displayName,isFirstAccount:(v.accounts?.length||0)===0}),onSetDefault:d=>r.mutate({provider:v.provider,accountId:d}),onRemoveAccount:d=>x.mutate({provider:v.provider,accountId:d}),onPauseToggle:(d,D)=>H(v.provider,d,D),onSoloMode:d=>V(v.provider,d),onBulkPause:d=>se(v.provider,d),onBulkResume:d=>z(v.provider,d),isRemovingAccount:x.isPending,isPausingAccount:g.isPending||w.isPending,isSoloingAccount:f.isPending,isBulkPausing:c.isPending,isBulkResuming:p.isPending}):e.jsx(Ra,{onSetup:()=>j(!0)})]}),e.jsx(ra,{open:A,onClose:()=>j(!1)}),e.jsx(ma,{open:F!==null,onClose:()=>P(null),provider:F?.provider||"",displayName:F?.displayName||"",isFirstAccount:F?.isFirstAccount||!1})]})}export{Za as CliproxyPage};
@@ -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,b2 as M}from"./index-Cw9Urr0S.js";import{C as P}from"./default-ports-1QQSffYX.js";import{G as F,R as L,x as H,t as q,K as G,d as W,X as _}from"./icons-DrEfTmfX.js";import"./notifications-B2HqRBj7.js";import"./utils-CzKF5WmX.js";import"./form-utils-Bcoyqxpq.js";import"./code-highlight-BRUf_pqB.js";function z({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 a=t.protocol||"http",o=t.port||(a==="https"?443:P),v=a==="https"&&o===443||a==="http"&&o===80?"":`:${o}`,w=`${a}://${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(o){if(o instanceof Error&&o.name==="AbortError")return;d(!1),m(l?`Remote CLIProxy at ${x} is not reachable`:"CLIProxy is not running")}},a=setTimeout(()=>t.abort(),2e3);return h().finally(()=>clearTimeout(a)),()=>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(_,{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(z,{})})}export{te as CliproxyControlPanelPage};
1
+ import{j as e}from"./radix-ui-Dt3edmE5.js";import{r as s}from"./react-vendor-CNOkPC89.js";import{u as k}from"./tanstack-B8i0evp-.js";import{Y as K,a_ as M}from"./index-C-7tLTU2.js";import{C as P}from"./default-ports-1QQSffYX.js";import{G as F,R as L,x as H,t as q,K as _,d as G,X as W}from"./icons-DtwH984l.js";import"./notifications-B2HqRBj7.js";import"./utils-CzKF5WmX.js";import"./form-utils-Bcoyqxpq.js";import"./code-highlight-BRUf_pqB.js";function z({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(_,{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(G,{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(W,{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(z,{})})}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-DhwS38kc.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-Dt3edmE5.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-D0M-j0xk.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};
@@ -0,0 +1,3 @@
1
+ import{j as e}from"./radix-ui-Dt3edmE5.js";import{a_ as w,a$ as Pe,B as S,d as N,a as ie,V as ne,n as H,L as T,I as ce,r as ke,s as Fe,t as Te,v as Me,w as X,x as he,b0 as Le,S as b,b1 as Re,b2 as Ae,b3 as Oe,Q as Ee,R as _e,U as Y,b4 as qe,c as se}from"./index-C-7tLTU2.js";import{r as v}from"./react-vendor-CNOkPC89.js";import{a as De,u as _,b as M}from"./tanstack-B8i0evp-.js";import{C as Ie}from"./confirm-dialog-BnNUvB5u.js";import{R as ge,L as fe,aj as Ke,a4 as Ue,Z as de,O as Qe,T as je,am as $e,b as Je,a6 as ze,ar as Be,aA as me,K as Ge,N as He,aB as Ve,v as ve,w as we}from"./icons-DtwH984l.js";import{S as ae}from"./separator-DzrBeBn-.js";import{S as We}from"./searchable-select-CSREngvO.js";import{S as Z}from"./switch-BP9rnaI6.js";import{t as q}from"./notifications-B2HqRBj7.js";import"./utils-CzKF5WmX.js";import"./form-utils-Bcoyqxpq.js";import"./code-highlight-BRUf_pqB.js";import"./alert-dialog-D0M-j0xk.js";async function Xe(){const t=await fetch(w("/copilot/status"));if(!t.ok)throw new Error("Failed to fetch copilot status");return t.json()}async function Ye(){const t=await fetch(w("/copilot/config"));if(!t.ok)throw new Error("Failed to fetch copilot config");return t.json()}async function Ze(){const t=await fetch(w("/copilot/models"));if(!t.ok)throw new Error("Failed to fetch copilot models");return t.json()}async function et(){const t=await fetch(w("/copilot/settings/raw"));if(!t.ok)throw new Error("Failed to fetch copilot raw settings");return t.json()}async function tt(t){const s=await fetch(w("/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 st(t){const s=await fetch(w("/copilot/settings/raw"),{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(s.status===409)throw new Pe("Copilot raw settings changed externally");if(!s.ok)throw new Error("Failed to save copilot raw settings");return s.json()}async function at(){const t=await fetch(w("/copilot/auth/start"),{method:"POST"});if(!t.ok)throw new Error("Failed to start auth");return t.json()}async function it(){const t=await fetch(w("/copilot/daemon/start"),{method:"POST"});if(!t.ok)throw new Error("Failed to start daemon");return t.json()}async function nt(){const t=await fetch(w("/copilot/daemon/stop"),{method:"POST"});if(!t.ok)throw new Error("Failed to stop daemon");return t.json()}async function ot(){const t=await fetch(w("/copilot/info"));if(!t.ok)throw new Error("Failed to fetch copilot info");return t.json()}async function lt(t){const s=await fetch(w("/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 Ne(){const t=De(),s=_({queryKey:["copilot-status"],queryFn:Xe,refetchInterval:5e3}),l=_({queryKey:["copilot-config"],queryFn:Ye}),c=_({queryKey:["copilot-models"],queryFn:Ze}),i=_({queryKey:["copilot-raw-settings"],queryFn:et}),d=_({queryKey:["copilot-info"],queryFn:ot}),r=M({mutationFn:tt,onSuccess:()=>{t.invalidateQueries({queryKey:["copilot-status"]}),t.invalidateQueries({queryKey:["copilot-config"]}),t.invalidateQueries({queryKey:["copilot-raw-settings"]})}}),n=M({mutationFn:st,onSuccess:()=>{t.invalidateQueries({queryKey:["copilot-status"]}),t.invalidateQueries({queryKey:["copilot-config"]}),t.invalidateQueries({queryKey:["copilot-raw-settings"]})}}),x=M({mutationFn:at,onSuccess:()=>{t.invalidateQueries({queryKey:["copilot-status"]})}}),p=M({mutationFn:it,onSuccess:()=>{t.invalidateQueries({queryKey:["copilot-status"]})}}),g=M({mutationFn:nt,onSuccess:()=>{t.invalidateQueries({queryKey:["copilot-status"]})}}),o=M({mutationFn:lt,onSuccess:()=>{t.invalidateQueries({queryKey:["copilot-status"]}),t.invalidateQueries({queryKey:["copilot-info"]})}});return v.useMemo(()=>({status:s.data,statusLoading:s.isLoading,statusError:s.error,refetchStatus:s.refetch,config:l.data,configLoading:l.isLoading,models:c.data?.models??[],currentModel:c.data?.current,modelsLoading:c.isLoading,rawSettings:i.data,rawSettingsLoading:i.isLoading,refetchRawSettings:i.refetch,updateConfig:r.mutate,updateConfigAsync:r.mutateAsync,isUpdating:r.isPending,saveRawSettings:n.mutate,saveRawSettingsAsync:n.mutateAsync,isSavingRawSettings:n.isPending,startAuth:x.mutate,startAuthAsync:x.mutateAsync,isAuthenticating:x.isPending,authResult:x.data,startDaemon:p.mutate,isStartingDaemon:p.isPending,stopDaemon:g.mutate,isStoppingDaemon:g.isPending,info:d.data,infoLoading:d.isLoading,refetchInfo:d.refetch,install:o.mutate,installAsync:o.mutateAsync,isInstalling:o.isPending}),[s.data,s.isLoading,s.error,s.refetch,l.data,l.isLoading,c.data,c.isLoading,i.data,i.isLoading,i.refetch,r.mutate,r.mutateAsync,r.isPending,n.mutate,n.mutateAsync,n.isPending,x.mutate,x.mutateAsync,x.isPending,x.data,p.mutate,p.isPending,g.mutate,g.isPending,d.data,d.isLoading,d.refetch,o.mutate,o.mutateAsync,o.isPending])}function rt({rawSettings:t,rawSettingsLoading:s,isUpdating:l,isSavingRawSettings:c,hasChanges:i,isRawJsonValid:d,onRefresh:r,onSave:n}){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(S,{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(N,{variant:"ghost",size:"sm",onClick:r,disabled:s,children:e.jsx(ge,{className:`w-4 h-4 ${s?"animate-spin":""}`})}),e.jsx(N,{size:"sm",onClick:n,disabled:l||c||!i||!d,children:l||c?e.jsxs(e.Fragment,{children:[e.jsx(fe,{className:"w-4 h-4 mr-1 animate-spin"}),"Saving..."]}):e.jsxs(e.Fragment,{children:[e.jsx(Ke,{className:"w-4 h-4 mr-1"}),"Save"]})})]})]})}const ct=[{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"}],dt=[{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 ue(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 mt(t){return t==null?null:t===0?"Free":t<1?`${t}x`:t===1?"1x":`${t}x`}function z({label:t,description:s,value:l,onChange:c,models:i,disabled:d}){const{t:r}=ie();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.jsx(We,{value:l||void 0,onChange:c,disabled:d,placeholder:r("componentModelSelector.selectModel"),searchPlaceholder:r("searchableSelect.searchModels"),emptyText:r("searchableSelect.noResults"),triggerClassName:"h-9",groups:[{key:"models",label:r("componentModelSelector.availableModelsCount",{count:i.length})}],options:i.map(n=>({value:n.id,groupKey:"models",searchText:`${n.name||n.id} ${n.id}`,keywords:[n.minPlan??"",n.preview?"preview":""],triggerContent:e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("span",{className:"truncate font-mono text-xs",children:n.id}),n.minPlan&&e.jsx(S,{variant:"outline",className:`text-[9px] px-1 py-0 h-4 ${ue(n.minPlan)}`,children:n.minPlan})]}),itemContent:e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("span",{className:"truncate font-mono text-xs",children:n.name||n.id}),n.minPlan&&e.jsx(S,{variant:"outline",className:`text-[9px] px-1 py-0 h-4 ${ue(n.minPlan)}`,children:n.minPlan}),n.multiplier!==void 0&&e.jsx("span",{className:"text-[9px] text-muted-foreground",children:mt(n.multiplier)}),n.preview&&e.jsx(S,{variant:"secondary",className:"text-[9px] px-1 py-0 h-4",children:r("componentModelSelector.preview")})]})}))})]})}function ee(t){if(t>=1e6){const s=t/1e6;return s%1===0?`${s}M`:`${s.toFixed(1)}M`}if(t>=1e3){const s=t/1e3;return s%1===0?`${s}K`:`${s.toFixed(1)}K`}return`${t}`}function ut(t){if(!t?.limits)return null;const s=[];return t.limits.maxPromptTokens&&s.push(`prompt ${ee(t.limits.maxPromptTokens)}`),t.limits.maxContextWindowTokens&&s.push(`context ${ee(t.limits.maxContextWindowTokens)}`),t.limits.maxOutputTokens&&s.push(`output ${ee(t.limits.maxOutputTokens)}`),s.length>0?s.join(" | "):null}function xt({currentModel:t,opusModel:s,sonnetModel:l,haikuModel:c,models:i,modelsLoading:d,onApplyPreset:r,onUpdateModel:n,onUpdateOpusModel:x,onUpdateSonnetModel:p,onUpdateHaikuModel:g}){const o=[{label:"Default",id:t},{label:"Opus",id:s||t},{label:"Sonnet",id:l||t},{label:"Haiku",id:c||t}].map(({label:a,id:u})=>{const y=i.find(P=>P.id===u),C=ut(y);return C?{label:a,id:u,limits:C}:null}).filter(a=>a!==null);return e.jsx(ne,{value:"config",className:"flex-1 mt-0 border-0 p-0 data-[state=inactive]:hidden flex flex-col overflow-hidden",children:e.jsx(H,{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(Ue,{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(S,{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:ct.map(a=>e.jsxs(N,{variant:"outline",size:"sm",className:"text-xs h-7 gap-1",onClick:()=>r(a),title:a.description,children:[e.jsx(de,{className:"w-3 h-3 text-green-600"}),a.name]},a.name))})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(S,{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:dt.map(a=>e.jsxs(N,{variant:"outline",size:"sm",className:"text-xs h-7 gap-1",onClick:()=>r(a),title:a.description,children:[e.jsx(de,{className:"w-3 h-3"}),a.name]},a.name))})]})]}),e.jsx(ae,{}),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:"mb-4 rounded-lg border border-amber-500/30 bg-amber-500/10 p-3 text-xs text-amber-900 dark:text-amber-200",children:[e.jsx("p",{className:"font-medium",children:"GitHub Copilot controls prompt/context limits upstream."}),e.jsx("p",{className:"mt-1",children:"CCS can switch Copilot models, but it cannot increase the provider's max prompt or context window."}),o.length>0?e.jsx("div",{className:"mt-2 space-y-1 text-[11px] font-mono",children:o.map(a=>e.jsxs("p",{children:[a.label,": ",a.id," (",a.limits,")"]},`${a.label}-${a.id}`))}):e.jsx("p",{className:"mt-2 text-[11px] font-mono",children:"Start the daemon to inspect live model limits from GitHub Copilot metadata."})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx(z,{label:"Default Model",description:"Used when no specific tier is requested",value:t,onChange:n,models:i,disabled:d}),e.jsx(z,{label:"Opus (Most capable)",description:"For complex reasoning tasks",value:s||t,onChange:x,models:i,disabled:d}),e.jsx(z,{label:"Sonnet (Balanced)",description:"Balance of speed and capability",value:l||t,onChange:p,models:i,disabled:d}),e.jsx(z,{label:"Haiku (Fast)",description:"Quick responses for simple tasks",value:c||t,onChange:g,models:i,disabled:d})]})]})]})})})}function pt({enabled:t,autoStart:s,port:l,accountType:c,rateLimit:i,waitOnLimit:d,onUpdateEnabled:r,onUpdateAutoStart:n,onUpdatePort:x,onUpdateAccountType:p,onUpdateRateLimit:g,onUpdateWaitOnLimit:o}){const{t:a}=ie();return e.jsx(ne,{value:"settings",className:"flex-1 mt-0 border-0 p-0 data-[state=inactive]:hidden flex flex-col overflow-hidden",children:e.jsx(H,{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(T,{htmlFor:"enabled",className:"text-sm font-medium",children:a("copilotSettings.enableCopilot")}),e.jsx("p",{className:"text-xs text-muted-foreground",children:a("copilotSettings.enableCopilotDesc")})]}),e.jsx(Z,{id:"enabled",checked:t,onCheckedChange:r})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("h3",{className:"text-sm font-medium",children:a("copilotSettings.basicSettings")}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(T,{htmlFor:"port",className:"text-xs",children:a("copilotPage.port")}),e.jsx(ce,{id:"port",type:"number",value:l,onChange:u=>x(parseInt(u.target.value,10)),min:1024,max:65535,className:"max-w-[150px] h-8"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(T,{htmlFor:"account-type",className:"text-xs",children:a("copilotSettings.accountType")}),e.jsxs(ke,{value:c,onValueChange:p,children:[e.jsx(Fe,{id:"account-type",className:"max-w-[150px] h-8",children:e.jsx(Te,{})}),e.jsxs(Me,{children:[e.jsx(X,{value:"individual",children:a("copilotSettings.accountTypeIndividual")}),e.jsx(X,{value:"business",children:a("copilotSettings.accountTypeBusiness")}),e.jsx(X,{value:"enterprise",children:a("copilotSettings.accountTypeEnterprise")})]})]})]})]}),e.jsx(ae,{}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("h3",{className:"text-sm font-medium",children:a("copilotSettings.rateLimiting")}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(T,{htmlFor:"rate-limit",className:"text-xs",children:a("copilotSettings.rateLimitSeconds")}),e.jsx(ce,{id:"rate-limit",type:"number",value:i,onChange:u=>g(u.target.value),placeholder:a("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(T,{htmlFor:"wait-on-limit",className:"text-xs",children:a("copilotSettings.waitOnRateLimit")}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:a("copilotSettings.waitOnRateLimitDesc")})]}),e.jsx(Z,{id:"wait-on-limit",checked:d,onCheckedChange:o})]})]}),e.jsx(ae,{}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("h3",{className:"text-sm font-medium",children:a("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(T,{htmlFor:"auto-start",className:"text-xs",children:a("copilotSettings.autoStartDaemon")}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:a("copilotSettings.autoStartDaemonDesc")})]}),e.jsx(Z,{id:"auto-start",checked:s,onCheckedChange:n})]})]})]})})})}function B({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(he,{value:s,size:"icon",className:"h-6 w-6"})]})]})}function ht({rawSettings:t}){return e.jsx(ne,{value:"info",className:"h-full mt-0 border-0 p-0 data-[state=inactive]:hidden",children:e.jsx(H,{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(Qe,{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(he,{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(S,{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(B,{label:"Run with Copilot",command:"ccs copilot"}),e.jsx(B,{label:"Authenticate",command:"ccs copilot auth"}),e.jsx(B,{label:"Start daemon",command:"ccs copilot --start"}),e.jsx(B,{label:"Stop daemon",command:"ccs copilot --stop"})]})]})]})})})}const gt=["ANTHROPIC_BASE_URL","ANTHROPIC_AUTH_TOKEN"];function xe(t){const s=t?.env||{};return gt.filter(l=>!s[l]?.trim())}function pe(t){if(!t||t.length===0)return[];const s=new Map;return t.forEach(l=>{s.set(l.message,l)}),[...s.values()]}function ft(){const{config:t,configLoading:s,models:l,modelsLoading:c,rawSettings:i,rawSettingsLoading:d,updateConfigAsync:r,isUpdating:n,saveRawSettingsAsync:x,isSavingRawSettings:p,refetchRawSettings:g}=Ne(),[o,a]=v.useState({}),[u,y]=v.useState(null),[C,P]=v.useState(!1),D=o.enabled??t?.enabled??!1,I=o.autoStart??t?.auto_start??!1,L=o.port??t?.port??4141,K=o.accountType??t?.account_type??"individual",R=o.model??t?.model??"claude-sonnet-4-6",A=o.rateLimit??t?.rate_limit?.toString()??"",f=o.waitOnLimit??t?.wait_on_limit??!0,U=o.opusModel??t?.opus_model??"",Q=o.sonnetModel??t?.sonnet_model??"",$=o.haikuModel??t?.haiku_model??"",J=(h,j)=>{a(O=>({...O,[h]:j}))},V=h=>{a(j=>({...j,model:h.default,opusModel:h.opus,sonnetModel:h.sonnet,haikuModel:h.haiku})),q.success(`Applied "${h.name}" preset`)},k=v.useMemo(()=>u!==null?u:i?.settings?JSON.stringify(i.settings,null,2):`{
2
+ "env": {}
3
+ }`,[u,i]),m=v.useCallback(h=>{y(h)},[]),oe=v.useMemo(()=>{try{return JSON.parse(k),!0}catch{return!1}},[k]),be=v.useMemo(()=>{const h=Object.keys(o).length>0,j=u!==null&&u!==JSON.stringify(i?.settings,null,2);return h||j},[o,u,i]),le=v.useMemo(()=>{if(u!==null)try{return JSON.parse(u)}catch{return i?.settings}return i?.settings},[u,i?.settings]),ye=v.useMemo(()=>xe(le),[le]),Se=v.useMemo(()=>pe([...t?.warnings??[],...i?.warnings??[]]),[t?.warnings,i?.warnings]),re=async({overwriteRawSettings:h=!1}={})=>{try{const j=[];if(Object.keys(o).length>0){const F=await r({enabled:D,auto_start:I,port:L,account_type:K,model:R,rate_limit:A?parseInt(A,10):null,wait_on_limit:f,opus_model:U||void 0,sonnet_model:Q||void 0,haiku_model:$||void 0});j.push(...F.warnings??[])}let O=[];if(u!==null&&oe){const F=JSON.parse(k);O=xe(F);const Ce=await x({settings:F,expectedMtime:h?void 0:i?.mtime});j.push(...Ce.warnings??[])}const W=pe(j),E=[];W.length>0&&E.push(W.map(F=>F.message).join(" ")),O.length>0&&E.push(`Missing fields will use defaults: ${O.join(", ")}`),W.length>0?q.warning("Copilot configuration saved with model adjustments",{description:E.join(" ")}):E.length>0?q.success("Copilot configuration saved",{description:E.join(" ")}):q.success("Copilot configuration saved"),a({}),y(null)}catch(j){Le(j)?P(!0):q.error("Failed to save settings")}};return{configLoading:s,rawSettingsLoading:d,modelsLoading:c,isUpdating:n,isSavingRawSettings:p,models:l,rawSettings:i,rawJsonContent:k,rawJsonEdits:u,enabled:D,autoStart:I,port:L,accountType:K,currentModel:R,rateLimit:A,waitOnLimit:f,opusModel:U,sonnetModel:Q,haikuModel:$,isRawJsonValid:oe,hasChanges:be,normalizationWarnings:Se,conflictDialog:C,updateField:J,applyPreset:V,handleRawJsonChange:m,handleSave:re,handleConflictResolve:async h=>{P(!1),h?await re({overwriteRawSettings:!0}):y(null)},refetchRawSettings:g,missingRequiredFields:ye}}function jt(){const{configLoading:t,rawSettingsLoading:s,modelsLoading:l,isUpdating:c,isSavingRawSettings:i,models:d,rawSettings:r,rawJsonContent:n,rawJsonEdits:x,enabled:p,autoStart:g,port:o,accountType:a,currentModel:u,rateLimit:y,waitOnLimit:C,opusModel:P,sonnetModel:D,haikuModel:I,isRawJsonValid:L,hasChanges:K,normalizationWarnings:R,conflictDialog:A,updateField:f,applyPreset:U,handleRawJsonChange:Q,handleSave:$,handleConflictResolve:J,refetchRawSettings:V,missingRequiredFields:k}=ft();return t||s?e.jsxs("div",{className:"space-y-6",children:[e.jsx(b,{className:"h-10 w-full"}),e.jsx(b,{className:"h-10 w-full"}),e.jsx(b,{className:"h-10 w-full"}),e.jsx(b,{className:"h-10 w-full"})]}):e.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden",children:[e.jsx(rt,{rawSettings:r,rawSettingsLoading:s,isUpdating:c,isSavingRawSettings:i,hasChanges:K,isRawJsonValid:L,onRefresh:()=>V(),onSave:$}),R.length>0&&e.jsx("div",{className:"px-6 pt-4 shrink-0",children:e.jsxs(Re,{variant:"warning",children:[e.jsx(je,{className:"h-4 w-4"}),e.jsx(Ae,{children:"Deprecated Copilot models detected"}),e.jsxs(Oe,{className:"space-y-2",children:[e.jsx("p",{children:"Loading this page did not rewrite your files. Save the Copilot configuration to persist these replacements."}),e.jsx("div",{className:"space-y-1",children:R.map(m=>e.jsx("p",{children:m.message},m.message))})]})]})}),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(Ee,{defaultValue:"config",className:"h-full flex flex-col",children:[e.jsx("div",{className:"px-4 pt-4 shrink-0",children:e.jsxs(_e,{className:"w-full",children:[e.jsx(Y,{value:"config",className:"flex-1",children:"Model Config"}),e.jsx(Y,{value:"settings",className:"flex-1",children:"Settings"}),e.jsx(Y,{value:"info",className:"flex-1",children:"Info"})]})}),e.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col",children:[e.jsx(xt,{currentModel:u,opusModel:P,sonnetModel:D,haikuModel:I,models:d,modelsLoading:l,onApplyPreset:U,onUpdateModel:m=>f("model",m),onUpdateOpusModel:m=>f("opusModel",m),onUpdateSonnetModel:m=>f("sonnetModel",m),onUpdateHaikuModel:m=>f("haikuModel",m)}),e.jsx(pt,{enabled:p,autoStart:g,port:o,accountType:a,rateLimit:y,waitOnLimit:C,onUpdateEnabled:m=>f("enabled",m),onUpdateAutoStart:m=>f("autoStart",m),onUpdatePort:m=>f("port",m),onUpdateAccountType:m=>f("accountType",m),onUpdateRateLimit:m=>f("rateLimit",m),onUpdateWaitOnLimit:m=>f("waitOnLimit",m)}),e.jsx(ht,{rawSettings:r})]})]})})}),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($e,{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(qe,{rawJsonContent:n,isRawJsonValid:L,rawJsonEdits:x,rawSettingsEnv:r?.settings?.env,onChange:Q,missingRequiredFields:k})]})]}),e.jsx(Ie,{open:A,title:"File Modified Externally",description:"This settings file was modified by another process. Overwrite with your changes or discard?",confirmText:"Overwrite",variant:"destructive",onConfirm:()=>J(!0),onCancel:()=>J(!1)})]})}function te({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 G({icon:t,label:s,status:l,statusText:c,variant:i="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:l?e.jsxs(e.Fragment,{children:[e.jsx(ve,{className:se("w-4 h-4",i==="warning"?"text-yellow-500":"text-green-500")}),e.jsx("span",{className:se("text-xs",i==="warning"?"text-yellow-500":"text-green-500"),children:c||"Yes"})]}):e.jsxs(e.Fragment,{children:[e.jsx(we,{className:"w-4 h-4 text-muted-foreground"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:c||"No"})]})})]})}function vt(){return e.jsxs("div",{className:"space-y-4 p-4",children:[e.jsx(b,{className:"h-8 w-full"}),e.jsx(b,{className:"h-12 w-full"}),e.jsx(b,{className:"h-12 w-full"}),e.jsx(b,{className:"h-12 w-full"})]})}function Et(){const{t}=ie(),{status:s,statusLoading:l,refetchStatus:c,startAuth:i,isAuthenticating:d,startDaemon:r,isStartingDaemon:n,stopDaemon:x,isStoppingDaemon:p,install:g,isInstalling:o}=Ne();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(Je,{className:"w-5 h-5 text-primary"}),e.jsx("h1",{className:"font-semibold",children:t("copilotPage.title")})]}),e.jsx(N,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>c(),disabled:l,children:e.jsx(ge,{className:se("w-4 h-4",l&&"animate-spin")})})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:t("copilotPage.subtitle")})]}),e.jsx(H,{className:"flex-1",children:l?e.jsx(vt,{}):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(je,{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(te,{title:t("copilotPage.setup"),children:[e.jsx(G,{icon:ze,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(N,{size:"sm",className:"w-full mt-2",onClick:()=>g(void 0),disabled:o,children:o?e.jsxs(e.Fragment,{children:[e.jsx(fe,{className:"w-3.5 h-3.5 mr-1.5 animate-spin"}),t("copilotPage.installing")]}):e.jsxs(e.Fragment,{children:[e.jsx(Be,{className:"w-3.5 h-3.5 mr-1.5"}),t("copilotPage.installCopilotApi")]})}),s?.installed&&e.jsx(G,{icon:me,label:t("copilotPage.integration"),status:s?.enabled??!1,statusText:s?.enabled?t("copilotPage.enabled"):t("copilotPage.disabled")})]}),s?.installed&&e.jsxs(te,{title:t("copilotPage.auth"),children:[e.jsx(G,{icon:Ge,label:t("copilotPage.github"),status:s?.authenticated??!1,statusText:s?.authenticated?t("copilotPage.connected"):t("copilotPage.notConnected")}),!s?.authenticated&&e.jsx(N,{size:"sm",className:"w-full mt-2",onClick:()=>i(),disabled:d,children:t(d?"copilotPage.authenticating":"copilotPage.authenticate")})]}),s?.authenticated&&e.jsxs(te,{title:t("copilotPage.daemon"),children:[e.jsx(G,{icon:He,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(N,{size:"sm",variant:"outline",className:"w-full",onClick:()=>x(),disabled:p,children:[e.jsx(Ve,{className:"w-3.5 h-3.5 mr-1.5"}),t(p?"copilotPage.stopping":"copilotPage.stop")]}):e.jsxs(N,{size:"sm",variant:"outline",className:"w-full",onClick:()=>r(),disabled:n,children:[e.jsx(me,{className:"w-3.5 h-3.5 mr-1.5"}),t(n?"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(ve,{className:"w-3 h-3 text-green-500"}),t("copilotPage.active")]}):e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(we,{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(jt,{})})]})}export{Et as CopilotPage};
@@ -0,0 +1 @@
1
+ import{j as e}from"./radix-ui-Dt3edmE5.js";import{r as j}from"./react-vendor-CNOkPC89.js";import{t as o}from"./notifications-B2HqRBj7.js";import{a_ as N,a$ as Xe,a as Se,B as M,d as f,c as oe,n as E,Q as Ze,R as Ye,U as Y,V as ee,L as _,I as se,b4 as es,ad as ss,ae as as,af as ts,ag as rs,ah as ns,at as os,b0 as is}from"./index-C-7tLTU2.js";import{a as cs,u as z,b as D}from"./tanstack-B8i0evp-.js";import{D as ke}from"./default-ports-1QQSffYX.js";import{S as ye}from"./switch-BP9rnaI6.js";import{S as ls}from"./separator-DzrBeBn-.js";import{S as ds}from"./searchable-select-CSREngvO.js";import{R as be,T as us,aC as ms,K as q,a6 as gs,aB as Ce,aA as hs,L as A,y as xs,aj as fs,a4 as ps,Z as ae,am as js,v as vs,w as ws}from"./icons-DtwH984l.js";import"./utils-CzKF5WmX.js";import"./form-utils-Bcoyqxpq.js";import"./code-highlight-BRUf_pqB.js";async function Ps(){const s=await fetch(N("/cursor/status"));if(!s.ok)throw new Error("Failed to fetch cursor status");return s.json()}async function Ns(){const s=await fetch(N("/cursor/settings"));if(!s.ok)throw new Error("Failed to fetch cursor config");return s.json()}async function ys(){const s=await fetch(N("/cursor/models"));if(!s.ok)throw new Error("Failed to fetch cursor models");return s.json()}async function bs(){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 Cs(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 Ss(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 Xe("Cursor raw settings changed externally");if(!t.ok)throw new Error("Failed to save cursor raw settings");return t.json()}async function ks(){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 Ms(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 Ds(){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 As(){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 _s(){const s=cs(),t=z({queryKey:["cursor-status"],queryFn:Ps,refetchInterval:5e3}),l=z({queryKey:["cursor-config"],queryFn:Ns}),u=z({queryKey:["cursor-models"],queryFn:ys}),h=z({queryKey:["cursor-raw-settings"],queryFn:bs}),m=()=>{s.invalidateQueries({queryKey:["cursor-status"]}),s.invalidateQueries({queryKey:["cursor-config"]}),s.invalidateQueries({queryKey:["cursor-models"]}),s.invalidateQueries({queryKey:["cursor-raw-settings"]})},g=D({mutationFn:Cs,onSuccess:m}),r=D({mutationFn:Ss,onSuccess:m}),d=D({mutationFn:ks,onSuccess:m}),p=D({mutationFn:Ms,onSuccess:m}),i=D({mutationFn:Ds,onSuccess:m}),c=D({mutationFn:As,onSuccess:m});return j.useMemo(()=>({status:t.data,statusLoading:t.isLoading,statusError:t.error,refetchStatus:t.refetch,config:l.data,configLoading:l.isLoading,models:u.data?.models??[],currentModel:u.data?.current??null,modelsLoading:u.isLoading,rawSettings:h.data,rawSettingsLoading:h.isLoading,refetchRawSettings:h.refetch,updateConfig:g.mutate,updateConfigAsync:g.mutateAsync,isUpdatingConfig:g.isPending,saveRawSettings:r.mutate,saveRawSettingsAsync:r.mutateAsync,isSavingRawSettings:r.isPending,autoDetectAuth:d.mutate,autoDetectAuthAsync:d.mutateAsync,isAutoDetectingAuth:d.isPending,autoDetectAuthResult:d.data,importManualAuth:p.mutate,importManualAuthAsync:p.mutateAsync,isImportingManualAuth:p.isPending,manualAuthResult:p.data,startDaemon:i.mutate,startDaemonAsync:i.mutateAsync,isStartingDaemon:i.isPending,stopDaemon:c.mutate,stopDaemonAsync:c.mutateAsync,isStoppingDaemon:c.isPending}),[t.data,t.isLoading,t.error,t.refetch,l.data,l.isLoading,u.data,u.isLoading,h.data,h.isLoading,h.refetch,g.mutate,g.mutateAsync,g.isPending,r.mutate,r.mutateAsync,r.isPending,d.mutate,d.mutateAsync,d.isPending,d.data,p.mutate,p.mutateAsync,p.isPending,p.data,i.mutate,i.mutateAsync,i.isPending,c.mutate,c.mutateAsync,c.isPending])}function te(s){return{port:String(s?.port??ke),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(m=>m.test(h.id)))?.id??l}function re(s){return s.toLowerCase().replace(/[^a-z0-9]/g,"")}function b(s,t,l){const u=new Set(t.map(re)),h=s.find(g=>u.has(re(g.id)));if(h)return h.id;const m=s.find(g=>u.has(re(g.name)));return m?m.id:l}function Ts(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:u,disabled:h,allowDefaultFallback:m=!1,onChange:g}){const{t:r}=Se(),d=l||(m?"__default":""),p=j.useMemo(()=>{const i=u.map(c=>({value:c.id,groupKey:"models",searchText:`${c.name||c.id} ${c.id}`,keywords:[c.provider],triggerContent:e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("span",{className:"truncate font-mono text-xs",children:c.name||c.id}),c.provider&&e.jsx(M,{variant:"outline",className:"text-[9px] h-4 px-1 capitalize",children:c.provider})]}),itemContent:e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("span",{className:"truncate text-xs font-mono",children:c.name||c.id}),e.jsx(M,{variant:"outline",className:"text-[9px] h-4 px-1 capitalize",children:c.provider})]})}));return m?[{value:"__default",groupKey:"models",searchText:r("cursorPage.useDefaultModel"),triggerContent:e.jsx("span",{className:"truncate font-mono text-xs",children:r("cursorPage.useDefaultModel")}),itemContent:e.jsx("span",{children:r("cursorPage.useDefaultModel")})},...i]:i},[m,u,r]);return e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{children:[e.jsx(_,{className:"text-xs font-medium",children:s}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:t})]}),e.jsx(ds,{value:d||void 0,onChange:i=>{if(m&&i==="__default"){g("");return}g(i)},disabled:h,placeholder:r("cursorPage.selectModel"),searchPlaceholder:r("searchableSelect.searchModels"),emptyText:r("searchableSelect.noResults"),triggerClassName:"h-9",groups:[{key:"models",label:r("cursorPage.availableModelCount",{count:u.length})}],options:p})]})}function ne({icon:s,label:t,ok:l,detail:u}){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(vs,{className:"h-4 w-4 text-green-500"}):e.jsx(ws,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{className:oe("text-xs",l?"text-green-500":"text-muted-foreground"),title:u,children:u})]})]})}function Js(){const{t:s}=Se(),{status:t,statusLoading:l,refetchStatus:u,config:h,updateConfigAsync:m,isUpdatingConfig:g,models:r,modelsLoading:d,currentModel:p,rawSettings:i,rawSettingsLoading:c,refetchRawSettings:Me,saveRawSettingsAsync:De,isSavingRawSettings:ie,autoDetectAuthAsync:Ae,isAutoDetectingAuth:ce,importManualAuthAsync:_e,isImportingManualAuth:le,startDaemonAsync:Te,isStartingDaemon:Re,stopDaemonAsync:Fe,isStoppingDaemon:de}=_s(),[k,ue]=j.useState(()=>te()),[v,me]=j.useState(!1),[ge,Ie]=j.useState("{}"),[T,K]=j.useState(!1),[Le,I]=j.useState(!1),[B,he]=j.useState(""),[U,xe]=j.useState(""),C=te(h),fe=v?k.port:C.port,Q=v?k.auto_start:C.auto_start,J=v?k.ghost_mode:C.ghost_mode,w=v?k.model:C.model,H=v?k.opus_model:C.opus_model,V=v?k.sonnet_model:C.sonnet_model,$=v?k.haiku_model:C.haiku_model,W=T?ge:JSON.stringify(i?.settings??{},null,2),pe=!!i,R=j.useMemo(()=>Ts(W),[W]),je=R.isValid,ve=v||T,Oe=!T||pe&&je,L=j.useMemo(()=>{const a=new Set,n=[...r].sort((S,Z)=>S.name.localeCompare(Z.name)),x=n.filter(S=>a.has(S.id)?!1:(a.add(S.id),!0));return w&&!n.some(S=>S.id===w)?[{id:w,name:w,provider:"custom"},...x]:x},[r,w]),P=a=>{ue(n=>a(v?n:C)),me(!0)},Ee=!!(t?.enabled&&t?.authenticated&&!t?.token_expired),ze=j.useMemo(()=>t?.enabled?e.jsx(M,{children:s("cursorPage.enabled")}):e.jsx(M,{variant:"secondary",children:s("cursorPage.disabled")}),[t?.enabled,s]),qe=async({suppressSuccessToast:a=!1}={})=>{const n=Number(fe);if(!Number.isInteger(n)||n<1||n>65535)return o.error(s("cursorPage.invalidPort")),!1;if(!w.trim())return o.error(s("cursorPage.defaultModelRequired")),!1;try{return await m({port:n,auto_start:Q,ghost_mode:J,model:w,opus_model:H||void 0,sonnet_model:V||void 0,haiku_model:$||void 0}),me(!1),ue(te({port:n,auto_start:Q,ghost_mode:J,model:w,opus_model:H||void 0,sonnet_model:V||void 0,haiku_model:$||void 0})),a||o.success(s("cursorPage.savedConfig")),!0}catch(x){return o.error(x.message||s("cursorPage.failedSaveConfig")),!1}},X=a=>{if(d){o.error(s("cursorPage.modelsLoadingWait"));return}if(r.length===0){o.error(s("cursorPage.noModelsAvailable"));return}const n=w||p||r[0]?.id||"gpt-5.3-codex",x=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],x)),Z=b(r,["gpt-5-fast","gpt5fast","GPT-5 Fast"],y(r,[/gpt[-.]?5.*fast/i],x)),Ve=b(r,["gpt-5-mini","gpt5mini","GPT-5 Mini"],y(r,[/gpt[-.]?5.*mini/i],Z)),Pe=b(r,["claude-4.6-opus","claude46opus","Claude 4.6 Opus"],y(r,[/claude[-.]?4\.?6.*opus/i,/claude.*opus/i],x)),Ne=b(r,["claude-4.5-sonnet","claude45sonnet","Claude 4.5 Sonnet"],y(r,[/claude[-.]?4\.?5.*sonnet/i,/claude.*sonnet/i],x)),$e=b(r,["claude-4.5-haiku","claude45haiku","Claude 4.5 Haiku"],y(r,[/claude[-.]?4\.?5.*haiku/i,/haiku/i],Ne)),O=b(r,["gemini-3-pro","gemini3pro","Gemini 3 Pro"],y(r,[/gemini[-.]?3.*pro/i],x)),We=b(r,["gemini-3-flash","gemini3flash","Gemini 3 Flash"],y(r,[/gemini[-.]?3.*flash/i,/gemini[-.]?2\.?5.*flash/i],O));if(a==="codex53"){P(F=>({...F,model:x,opus_model:S,sonnet_model:x,haiku_model:Ve})),o.success(s("cursorPage.appliedCodexPreset"));return}if(a==="claude46"){P(F=>({...F,model:Pe,opus_model:Pe,sonnet_model:Ne,haiku_model:$e})),o.success(s("cursorPage.appliedClaudePreset"));return}P(F=>({...F,model:O,opus_model:O,sonnet_model:O,haiku_model:We})),o.success(s("cursorPage.appliedGeminiPreset"))},we=async a=>{try{await m({enabled:a}),o.success(s(a?"cursorPage.integrationEnabled":"cursorPage.integrationDisabled"))}catch(n){o.error(n.message||s("cursorPage.failedUpdateIntegration"))}},Ge=async()=>{try{await Ae(),o.success(s("cursorPage.credentialsImported"))}catch(a){o.error(a.message||s("cursorPage.autoDetectFailed"))}},Ke=async()=>{if(!B.trim()||!U.trim()){o.error(s("cursorPage.manualRequired"));return}try{await _e({accessToken:B.trim(),machineId:U.trim()}),o.success(s("cursorPage.credentialsImported")),I(!1),he(""),xe("")}catch(a){o.error(a.message||s("cursorPage.manualImportFailed"))}},Be=async()=>{try{const a=await Te();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"))}},Ue=async()=>{try{const a=await Fe();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"))}},Qe=async({suppressSuccessToast:a=!1}={})=>{if(!pe)return o.error(s("cursorPage.rawLoading")),!1;if(!R.isValid||!R.settings)return o.error(R.error||s("cursorPage.invalidJson")),!1;try{return await De({settings:R.settings,expectedMtime:i?.mtime}),K(!1),a||o.success(s("cursorPage.rawSaved")),!0}catch(n){return is(n)?o.error(s("cursorPage.rawChanged")):o.error(n.message||s("cursorPage.failedSaveRaw")),!1}},Je=async()=>{if(!ve)return;const a=v,n=T;a&&!await qe({suppressSuccessToast:n})||n&&!await Qe({suppressSuccessToast:a})||a&&n&&o.success(s("cursorPage.savedAll"))},He=()=>{K(!1),u(),Me()};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(M,{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")}),ze]}),e.jsx(f,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>u(),disabled:l,children:e.jsx(be,{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(us,{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:ms,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:gs,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:g,children:[e.jsx(Ce,{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:g,children:[e.jsx(hs,{className:"w-3.5 h-3.5 mr-1.5"}),s("cursorPage.enableIntegration")]}),e.jsxs(f,{variant:"outline",size:"sm",className:"w-full",onClick:Ge,disabled:ce,children:[ce?e.jsx(A,{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:Ue,disabled:de,children:[de?e.jsx(A,{className:"w-3.5 h-3.5 mr-1.5 animate-spin"}):e.jsx(Ce,{className:"w-3.5 h-3.5 mr-1.5"}),s("cursorPage.stopDaemon")]}):e.jsxs(f,{size:"sm",className:"w-full",onClick:Be,disabled:!Ee,children:[Re?e.jsx(A,{className:"w-3.5 h-3.5 mr-1.5 animate-spin"}):e.jsx(xs,{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??ke})]})})]}),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(M,{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:He,disabled:l||c,children:e.jsx(be,{className:oe("w-4 h-4",(l||c)&&"animate-spin")})}),e.jsx(f,{size:"sm",onClick:Je,disabled:g||ie||!ve||!Oe,children:g||ie?e.jsxs(e.Fragment,{children:[e.jsx(A,{className:"w-4 h-4 mr-1 animate-spin"}),s("cursorPage.saving")]}):e.jsxs(e.Fragment,{children:[e.jsx(fs,{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(Ze,{defaultValue:"config",className:"h-full flex flex-col",children:[e.jsx("div",{className:"px-4 pt-4 shrink-0",children:e.jsxs(Ye,{className:"w-full",children:[e.jsx(Y,{value:"config",className:"flex-1",children:s("cursorPage.modelConfig")}),e.jsx(Y,{value:"settings",className:"flex-1",children:s("cursorPage.settings")}),e.jsx(Y,{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(ps,{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:d||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:d||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:d||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(ls,{}),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:w,models:L,disabled:d,onChange:a=>{P(n=>({...n,model:a}))}}),e.jsx(G,{label:s("cursorPage.opusModel"),description:s("cursorPage.opusModelDesc"),value:H,models:L,disabled:d,allowDefaultFallback:!0,onChange:a=>{P(n=>({...n,opus_model:a}))}}),e.jsx(G,{label:s("cursorPage.sonnetModel"),description:s("cursorPage.sonnetModelDesc"),value:V,models:L,disabled:d,allowDefaultFallback:!0,onChange:a=>{P(n=>({...n,sonnet_model:a}))}}),e.jsx(G,{label:s("cursorPage.haikuModel"),description:s("cursorPage.haikuModelDesc"),value:$,models:L,disabled:d,allowDefaultFallback:!0,onChange:a=>{P(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(_,{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=>{P(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(_,{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(ye,{id:"cursor-auto-start",checked:Q,onCheckedChange:a=>{P(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(_,{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(ye,{id:"cursor-ghost-mode",checked:J,onCheckedChange:a=>{P(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")}),d?e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[e.jsx(A,{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===p&&e.jsx(M,{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(js,{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(es,{rawJsonContent:W,isRawJsonValid:je,rawJsonEdits:T?ge:null,rawSettingsEnv:i?.settings?.env,onChange:a=>{K(!0),Ie(a)}})]})]})]})})]}),e.jsx(ss,{open:Le,onOpenChange:I,children:e.jsxs(as,{children:[e.jsxs(ts,{children:[e.jsx(rs,{children:s("cursorPage.manualImportTitle")}),e.jsx(ns,{children:s("cursorPage.manualImportDesc")})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(_,{htmlFor:"cursor-manual-token",children:s("cursorPage.accessToken")}),e.jsx(se,{id:"cursor-manual-token",value:B,onChange:a=>he(a.target.value),placeholder:s("cursorPage.accessTokenPlaceholder")})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(_,{htmlFor:"cursor-manual-machine-id",children:s("cursorPage.machineId")}),e.jsx(se,{id:"cursor-manual-machine-id",value:U,onChange:a=>xe(a.target.value),placeholder:s("cursorPage.machineIdPlaceholder")})]})]}),e.jsxs(os,{children:[e.jsx(f,{variant:"outline",onClick:()=>I(!1),children:s("cursorPage.cancel")}),e.jsxs(f,{onClick:Ke,disabled:le,children:[le?e.jsx(A,{className:"w-4 h-4 mr-2 animate-spin"}):e.jsx(q,{className:"w-4 h-4 mr-2"}),s("cursorPage.import")]})]})]})})]})}export{Js as CursorPage};