@kaitranntt/ccs 7.65.3 → 7.66.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 (245) hide show
  1. package/README.md +88 -750
  2. package/dist/api/services/profile-lifecycle-service.d.ts.map +1 -1
  3. package/dist/api/services/profile-lifecycle-service.js +4 -0
  4. package/dist/api/services/profile-lifecycle-service.js.map +1 -1
  5. package/dist/api/services/profile-writer.d.ts.map +1 -1
  6. package/dist/api/services/profile-writer.js +3 -0
  7. package/dist/api/services/profile-writer.js.map +1 -1
  8. package/dist/auth/auth-commands.d.ts +1 -0
  9. package/dist/auth/auth-commands.d.ts.map +1 -1
  10. package/dist/auth/auth-commands.js +11 -0
  11. package/dist/auth/auth-commands.js.map +1 -1
  12. package/dist/auth/commands/backup-command.d.ts +3 -0
  13. package/dist/auth/commands/backup-command.d.ts.map +1 -0
  14. package/dist/auth/commands/backup-command.js +126 -0
  15. package/dist/auth/commands/backup-command.js.map +1 -0
  16. package/dist/auth/commands/index.d.ts +1 -0
  17. package/dist/auth/commands/index.d.ts.map +1 -1
  18. package/dist/auth/commands/index.js +3 -1
  19. package/dist/auth/commands/index.js.map +1 -1
  20. package/dist/auth/profile-continuity-inheritance.d.ts +1 -0
  21. package/dist/auth/profile-continuity-inheritance.d.ts.map +1 -1
  22. package/dist/auth/profile-continuity-inheritance.js +10 -6
  23. package/dist/auth/profile-continuity-inheritance.js.map +1 -1
  24. package/dist/auth/profile-detector.d.ts +9 -1
  25. package/dist/auth/profile-detector.d.ts.map +1 -1
  26. package/dist/auth/profile-detector.js +35 -0
  27. package/dist/auth/profile-detector.js.map +1 -1
  28. package/dist/auth/resume-lane-diagnostics.d.ts +21 -0
  29. package/dist/auth/resume-lane-diagnostics.d.ts.map +1 -0
  30. package/dist/auth/resume-lane-diagnostics.js +146 -0
  31. package/dist/auth/resume-lane-diagnostics.js.map +1 -0
  32. package/dist/auth/resume-lane-warning.d.ts +9 -0
  33. package/dist/auth/resume-lane-warning.d.ts.map +1 -0
  34. package/dist/auth/resume-lane-warning.js +60 -0
  35. package/dist/auth/resume-lane-warning.js.map +1 -0
  36. package/dist/ccs.js +82 -7
  37. package/dist/ccs.js.map +1 -1
  38. package/dist/cliproxy/auth/auth-types.d.ts +29 -6
  39. package/dist/cliproxy/auth/auth-types.d.ts.map +1 -1
  40. package/dist/cliproxy/auth/auth-types.js +58 -10
  41. package/dist/cliproxy/auth/auth-types.js.map +1 -1
  42. package/dist/cliproxy/auth/oauth-handler.d.ts +9 -1
  43. package/dist/cliproxy/auth/oauth-handler.d.ts.map +1 -1
  44. package/dist/cliproxy/auth/oauth-handler.js +196 -45
  45. package/dist/cliproxy/auth/oauth-handler.js.map +1 -1
  46. package/dist/cliproxy/auth/oauth-process.d.ts +13 -1
  47. package/dist/cliproxy/auth/oauth-process.d.ts.map +1 -1
  48. package/dist/cliproxy/auth/oauth-process.js +262 -17
  49. package/dist/cliproxy/auth/oauth-process.js.map +1 -1
  50. package/dist/cliproxy/executor/env-resolver.d.ts +3 -0
  51. package/dist/cliproxy/executor/env-resolver.d.ts.map +1 -1
  52. package/dist/cliproxy/executor/env-resolver.js +19 -1
  53. package/dist/cliproxy/executor/env-resolver.js.map +1 -1
  54. package/dist/cliproxy/executor/index.d.ts +5 -0
  55. package/dist/cliproxy/executor/index.d.ts.map +1 -1
  56. package/dist/cliproxy/executor/index.js +138 -12
  57. package/dist/cliproxy/executor/index.js.map +1 -1
  58. package/dist/cliproxy/gemini-cli-quota-normalizer.d.ts +10 -0
  59. package/dist/cliproxy/gemini-cli-quota-normalizer.d.ts.map +1 -0
  60. package/dist/cliproxy/gemini-cli-quota-normalizer.js +122 -0
  61. package/dist/cliproxy/gemini-cli-quota-normalizer.js.map +1 -0
  62. package/dist/cliproxy/quota-fetcher-gemini-cli.d.ts.map +1 -1
  63. package/dist/cliproxy/quota-fetcher-gemini-cli.js +133 -92
  64. package/dist/cliproxy/quota-fetcher-gemini-cli.js.map +1 -1
  65. package/dist/cliproxy/quota-types.d.ts +8 -0
  66. package/dist/cliproxy/quota-types.d.ts.map +1 -1
  67. package/dist/cliproxy/services/variant-settings.d.ts.map +1 -1
  68. package/dist/cliproxy/services/variant-settings.js +11 -0
  69. package/dist/cliproxy/services/variant-settings.js.map +1 -1
  70. package/dist/commands/cliproxy/quota-subcommand.d.ts.map +1 -1
  71. package/dist/commands/cliproxy/quota-subcommand.js +10 -1
  72. package/dist/commands/cliproxy/quota-subcommand.js.map +1 -1
  73. package/dist/commands/command-catalog.d.ts +39 -0
  74. package/dist/commands/command-catalog.d.ts.map +1 -0
  75. package/dist/commands/command-catalog.js +299 -0
  76. package/dist/commands/command-catalog.js.map +1 -0
  77. package/dist/commands/completion-backend.d.ts +14 -0
  78. package/dist/commands/completion-backend.d.ts.map +1 -0
  79. package/dist/commands/completion-backend.js +216 -0
  80. package/dist/commands/completion-backend.js.map +1 -0
  81. package/dist/commands/cursor-command-display.d.ts.map +1 -1
  82. package/dist/commands/cursor-command-display.js +25 -5
  83. package/dist/commands/cursor-command-display.js.map +1 -1
  84. package/dist/commands/cursor-command.d.ts +1 -3
  85. package/dist/commands/cursor-command.d.ts.map +1 -1
  86. package/dist/commands/cursor-command.js +3 -15
  87. package/dist/commands/cursor-command.js.map +1 -1
  88. package/dist/commands/help-command.d.ts +4 -3
  89. package/dist/commands/help-command.d.ts.map +1 -1
  90. package/dist/commands/help-command.js +209 -503
  91. package/dist/commands/help-command.js.map +1 -1
  92. package/dist/commands/install-command.d.ts.map +1 -1
  93. package/dist/commands/install-command.js +16 -3
  94. package/dist/commands/install-command.js.map +1 -1
  95. package/dist/commands/root-command-router.d.ts +2 -0
  96. package/dist/commands/root-command-router.d.ts.map +1 -1
  97. package/dist/commands/root-command-router.js +13 -13
  98. package/dist/commands/root-command-router.js.map +1 -1
  99. package/dist/commands/shell-completion-command.d.ts +1 -0
  100. package/dist/commands/shell-completion-command.d.ts.map +1 -1
  101. package/dist/commands/shell-completion-command.js +27 -11
  102. package/dist/commands/shell-completion-command.js.map +1 -1
  103. package/dist/copilot/copilot-executor.d.ts +2 -0
  104. package/dist/copilot/copilot-executor.d.ts.map +1 -1
  105. package/dist/copilot/copilot-executor.js +36 -4
  106. package/dist/copilot/copilot-executor.js.map +1 -1
  107. package/dist/cursor/constants.d.ts +3 -0
  108. package/dist/cursor/constants.d.ts.map +1 -0
  109. package/dist/cursor/constants.js +20 -0
  110. package/dist/cursor/constants.js.map +1 -0
  111. package/dist/cursor/cursor-models.d.ts.map +1 -1
  112. package/dist/cursor/cursor-models.js +2 -0
  113. package/dist/cursor/cursor-models.js.map +1 -1
  114. package/dist/cursor/cursor-profile-executor.d.ts +10 -0
  115. package/dist/cursor/cursor-profile-executor.d.ts.map +1 -0
  116. package/dist/cursor/cursor-profile-executor.js +158 -0
  117. package/dist/cursor/cursor-profile-executor.js.map +1 -0
  118. package/dist/cursor/cursor-translator.d.ts +22 -11
  119. package/dist/cursor/cursor-translator.d.ts.map +1 -1
  120. package/dist/cursor/cursor-translator.js +254 -75
  121. package/dist/cursor/cursor-translator.js.map +1 -1
  122. package/dist/cursor/index.d.ts +1 -0
  123. package/dist/cursor/index.d.ts.map +1 -1
  124. package/dist/cursor/index.js +4 -1
  125. package/dist/cursor/index.js.map +1 -1
  126. package/dist/delegation/headless-executor.d.ts.map +1 -1
  127. package/dist/delegation/headless-executor.js +79 -2
  128. package/dist/delegation/headless-executor.js.map +1 -1
  129. package/dist/management/checks/image-analysis-check.d.ts.map +1 -1
  130. package/dist/management/checks/image-analysis-check.js +4 -5
  131. package/dist/management/checks/image-analysis-check.js.map +1 -1
  132. package/dist/management/instance-manager.js +1 -1
  133. package/dist/management/instance-manager.js.map +1 -1
  134. package/dist/shared/claude-extension-setup.d.ts.map +1 -1
  135. package/dist/shared/claude-extension-setup.js +36 -16
  136. package/dist/shared/claude-extension-setup.js.map +1 -1
  137. package/dist/targets/target-runtime-compatibility.d.ts.map +1 -1
  138. package/dist/targets/target-runtime-compatibility.js +6 -0
  139. package/dist/targets/target-runtime-compatibility.js.map +1 -1
  140. package/dist/types/profile.d.ts +1 -1
  141. package/dist/types/profile.d.ts.map +1 -1
  142. package/dist/ui/assets/accounts-l__hcQUq.js +1 -0
  143. package/dist/ui/assets/{alert-dialog-D0EFRcfB.js → alert-dialog-BtM3eP43.js} +1 -1
  144. package/dist/ui/assets/{api-DhM3BYXr.js → api-Ddwn7EXC.js} +1 -1
  145. package/dist/ui/assets/{auth-section-DVp8FQGm.js → auth-section-BnYn1EA3.js} +1 -1
  146. package/dist/ui/assets/{backups-section-CRo0NZkA.js → backups-section-M4jx3HzK.js} +1 -1
  147. package/dist/ui/assets/{channels-uZ_9CBqO.js → channels-D9ywyAj3.js} +1 -1
  148. package/dist/ui/assets/{checkbox-32DNqW_Q.js → checkbox-Df-yoPbe.js} +1 -1
  149. package/dist/ui/assets/{claude-extension-BfXlz5gV.js → claude-extension-Cxg0a-Ee.js} +1 -1
  150. package/dist/ui/assets/cliproxy-DPFdpIHy.js +3 -0
  151. package/dist/ui/assets/{cliproxy-ai-providers-5SHLMHiy.js → cliproxy-ai-providers-DtW-6cPc.js} +6 -6
  152. package/dist/ui/assets/cliproxy-control-panel-0TyLDMf7.js +1 -0
  153. package/dist/ui/assets/{codex-CRUSpjsu.js → codex-BtPojOrJ.js} +3 -3
  154. package/dist/ui/assets/{confirm-dialog-DVf5ZmCZ.js → confirm-dialog-BMwFBq5G.js} +1 -1
  155. package/dist/ui/assets/{copilot-BZrihl_Z.js → copilot-BG3BnHxa.js} +2 -2
  156. package/dist/ui/assets/{cursor-BP4nbEk_.js → cursor-BfDO73Lu.js} +1 -1
  157. package/dist/ui/assets/{droid-BG92rdM2.js → droid-iW-Vtuhy.js} +2 -2
  158. package/dist/ui/assets/{globalenv-section-Cf6dKgSf.js → globalenv-section-d9h23hIf.js} +1 -1
  159. package/dist/ui/assets/{health-BTy1UZs3.js → health-BPPMFQMR.js} +1 -1
  160. package/dist/ui/assets/icons-BxSzn11s.js +1 -0
  161. package/dist/ui/assets/index-B6Y8wFQ0.css +1 -0
  162. package/dist/ui/assets/{index-wg7UtkFv.js → index-BPyp9RJE.js} +1 -1
  163. package/dist/ui/assets/{index-DHrTq-0n.js → index-CctYE17X.js} +1 -1
  164. package/dist/ui/assets/{index-BVeN0dIB.js → index-CeP2Pr2w.js} +1 -1
  165. package/dist/ui/assets/{index-DuRYaONg.js → index-DYY3wcwk.js} +1 -1
  166. package/dist/ui/assets/{index-N2ZSJurX.js → index-DusmDwkD.js} +1 -1
  167. package/dist/ui/assets/index-wIy8qzU9.js +69 -0
  168. package/dist/ui/assets/{masked-input-DX9bedLy.js → masked-input-DWNtAEKs.js} +1 -1
  169. package/dist/ui/assets/{proxy-status-widget-DVDMuZK5.js → proxy-status-widget-GS3qroms.js} +1 -1
  170. package/dist/ui/assets/{radix-ui-C98W0NRG.js → radix-ui-Zb8sVEtn.js} +1 -1
  171. package/dist/ui/assets/{raw-json-settings-editor-panel-Dkt5E6Z_.js → raw-json-settings-editor-panel-e3Ziu5B1.js} +1 -1
  172. package/dist/ui/assets/{searchable-select-BP3Q1-Yn.js → searchable-select-D2G6gg3h.js} +1 -1
  173. package/dist/ui/assets/{separator-BLGGUlh9.js → separator-CR1SGLxF.js} +1 -1
  174. package/dist/ui/assets/{shared-G0XRyLig.js → shared-BpB5GiWS.js} +1 -1
  175. package/dist/ui/assets/{table-B4lRrWC-.js → table-BMbwptG_.js} +1 -1
  176. package/dist/ui/assets/{tanstack-CfKik0yL.js → tanstack-DWm6aJ-G.js} +1 -1
  177. package/dist/ui/assets/{updates--A2Sdo7N.js → updates-iC3kvbKP.js} +1 -1
  178. package/dist/ui/index.html +5 -5
  179. package/dist/utils/config-manager.d.ts +5 -0
  180. package/dist/utils/config-manager.d.ts.map +1 -1
  181. package/dist/utils/config-manager.js +10 -1
  182. package/dist/utils/config-manager.js.map +1 -1
  183. package/dist/utils/hooks/get-image-analysis-hook-env.d.ts +26 -0
  184. package/dist/utils/hooks/get-image-analysis-hook-env.d.ts.map +1 -1
  185. package/dist/utils/hooks/get-image-analysis-hook-env.js +79 -1
  186. package/dist/utils/hooks/get-image-analysis-hook-env.js.map +1 -1
  187. package/dist/utils/hooks/image-analysis-backend-resolver.d.ts.map +1 -1
  188. package/dist/utils/hooks/image-analysis-backend-resolver.js +13 -5
  189. package/dist/utils/hooks/image-analysis-backend-resolver.js.map +1 -1
  190. package/dist/utils/hooks/image-analysis-runtime-status.d.ts +2 -0
  191. package/dist/utils/hooks/image-analysis-runtime-status.d.ts.map +1 -1
  192. package/dist/utils/hooks/image-analysis-runtime-status.js +15 -11
  193. package/dist/utils/hooks/image-analysis-runtime-status.js.map +1 -1
  194. package/dist/utils/hooks/image-analyzer-hook-installer.d.ts.map +1 -1
  195. package/dist/utils/hooks/image-analyzer-hook-installer.js +60 -27
  196. package/dist/utils/hooks/image-analyzer-hook-installer.js.map +1 -1
  197. package/dist/utils/hooks/image-analyzer-profile-hook-injector.d.ts.map +1 -1
  198. package/dist/utils/hooks/image-analyzer-profile-hook-injector.js +3 -0
  199. package/dist/utils/hooks/image-analyzer-profile-hook-injector.js.map +1 -1
  200. package/dist/utils/hooks/index.d.ts +2 -1
  201. package/dist/utils/hooks/index.d.ts.map +1 -1
  202. package/dist/utils/hooks/index.js +14 -7
  203. package/dist/utils/hooks/index.js.map +1 -1
  204. package/dist/utils/image-analysis/claude-tool-args.d.ts +6 -0
  205. package/dist/utils/image-analysis/claude-tool-args.d.ts.map +1 -0
  206. package/dist/utils/image-analysis/claude-tool-args.js +65 -0
  207. package/dist/utils/image-analysis/claude-tool-args.js.map +1 -0
  208. package/dist/utils/image-analysis/index.d.ts +4 -0
  209. package/dist/utils/image-analysis/index.d.ts.map +1 -1
  210. package/dist/utils/image-analysis/index.js +20 -1
  211. package/dist/utils/image-analysis/index.js.map +1 -1
  212. package/dist/utils/image-analysis/mcp-installer.d.ts +18 -0
  213. package/dist/utils/image-analysis/mcp-installer.d.ts.map +1 -0
  214. package/dist/utils/image-analysis/mcp-installer.js +447 -0
  215. package/dist/utils/image-analysis/mcp-installer.js.map +1 -0
  216. package/dist/web-server/routes/account-routes.d.ts.map +1 -1
  217. package/dist/web-server/routes/account-routes.js +14 -2
  218. package/dist/web-server/routes/account-routes.js.map +1 -1
  219. package/dist/web-server/routes/auth-routes.d.ts +10 -0
  220. package/dist/web-server/routes/auth-routes.d.ts.map +1 -1
  221. package/dist/web-server/routes/auth-routes.js +33 -6
  222. package/dist/web-server/routes/auth-routes.js.map +1 -1
  223. package/dist/web-server/routes/cliproxy-auth-routes.d.ts +8 -0
  224. package/dist/web-server/routes/cliproxy-auth-routes.d.ts.map +1 -1
  225. package/dist/web-server/routes/cliproxy-auth-routes.js +141 -11
  226. package/dist/web-server/routes/cliproxy-auth-routes.js.map +1 -1
  227. package/dist/web-server/routes/image-analysis-routes.d.ts.map +1 -1
  228. package/dist/web-server/routes/image-analysis-routes.js +30 -5
  229. package/dist/web-server/routes/image-analysis-routes.js.map +1 -1
  230. package/lib/hooks/image-analysis-runtime.cjs +469 -0
  231. package/lib/hooks/image-analyzer-transformer.cjs +27 -418
  232. package/lib/hooks/websearch-transformer.cjs +37 -2
  233. package/lib/mcp/ccs-image-analysis-server.cjs +440 -0
  234. package/package.json +1 -1
  235. package/scripts/completion/README.md +55 -131
  236. package/scripts/completion/ccs.bash +22 -190
  237. package/scripts/completion/ccs.fish +19 -245
  238. package/scripts/completion/ccs.ps1 +37 -427
  239. package/scripts/completion/ccs.zsh +27 -305
  240. package/dist/ui/assets/accounts-BHEYnq6b.js +0 -1
  241. package/dist/ui/assets/cliproxy-DjNY9H-U.js +0 -3
  242. package/dist/ui/assets/cliproxy-control-panel-Zax_m1AC.js +0 -1
  243. package/dist/ui/assets/icons-CeH5899d.js +0 -1
  244. package/dist/ui/assets/index-B6SrL1O-.css +0 -1
  245. package/dist/ui/assets/index-Corv1lSo.js +0 -69
@@ -1 +1 @@
1
- import{j as e}from"./radix-ui-C98W0NRG.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 G,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-Corv1lSo.js";import{u as K,a as J,b as V}from"./tanstack-CfKik0yL.js";import{t as E}from"./notifications-B2HqRBj7.js";import{a7 as Pe,a6 as ke,L as U,an as De,am as Be,R as Ie,T as oe,aG as Te,a4 as Re}from"./icons-CeH5899d.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 ce(s){return{name:"",profile:s,host:"vscode",ideSettingsPath:"",notes:""}}function q(s){return{name:s.name,profile:s.profile,host:s.host,ideSettingsPath:s.ideSettingsPath||"",notes:s.notes||""}}function 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 o({label:s,value:a,mono:n=!1,copyValue:l}){const S=typeof l=="string"&&l.trim().length>0;return e.jsxs("div",{className:"grid gap-2 text-sm sm:grid-cols-[112px_minmax(0,1fr)] sm:items-start",children:[e.jsx("span",{className:"text-muted-foreground",children:s}),S?e.jsxs("div",{className:"flex min-w-0 items-start gap-2",children:[e.jsx("div",{className:"min-w-0 flex-1 rounded-md border bg-muted/25 px-3 py-2",children:e.jsx("span",{className:"block text-left font-mono text-xs leading-5 [overflow-wrap:anywhere]",children:_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(o,{label:"Path",value:n?.path||"Save a binding first",mono:!0,copyValue:n?.path}),e.jsx(o,{label:"File",value:n?n.exists?"Present":"Not created yet":"Unavailable"})]}),e.jsx("div",{className:"rounded-lg border bg-muted/25 p-3 text-sm text-muted-foreground",children:n?.message||"Verify the binding after saving to inspect the current file state."}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(y,{size:"sm",className:"flex-1",onClick: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),[H,k]=W.useState(()=>ce("default")),c=fe||w.length===0,b=!c&&w.length>0?w.find(t=>t.id===O)??(O?null:w[0]):null,g=b?.id??null,r=c||!b||O?H:q(b),Y=Ae(r.profile,r.host),A=Le(c?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(ce(pe))}async function ye(){if(!Z)return;const t=Ve(r);if(!c&&g){const Q=await l.mutateAsync({id:g,binding:t});I(!1),T(Q.binding.id),k(q(Q.binding));return}const N=await n.mutateAsync(t);I(!1),T(N.binding.id),k(q(N.binding))}async function Se(){if(!g||!b||!window.confirm(`Delete binding "${b.name}"?`))return;await S.mutateAsync(g);const t=w.filter(N=>N.id!==g);t.length>0?(T(t[0].id),I(!1),k(q(t[0]))):z()}function $(t,N){if(!c&&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-full min-h-0 overflow-hidden",children:[e.jsxs("div",{className:"flex w-[348px] shrink-0 flex-col border-r bg-muted/30 xl:w-[372px]",children:[e.jsx("div",{className:"border-b bg-background p-4",children:e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"rounded-lg border bg-muted/40 p-2",children:e.jsx(Pe,{className:"h-5 w-5 text-primary"})}),e.jsxs("div",{children:[e.jsx("h1",{className:"font-semibold",children:"Claude Extension"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Saved IDE bindings for CCS profiles"})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(p,{variant:"secondary",children:je}),d?e.jsx(p,{variant:"outline",children:d.label}):null]})]}),e.jsxs(y,{size:"sm",onClick: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:c?"Create binding":"Binding editor"}),e.jsx(v,{children:"Save a profile + IDE path once, then apply or reset it from the dashboard."})]}),e.jsxs(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(G,{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(G,{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(G,{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"}),c?"Create":"Save"]}),e.jsx(y,{variant:"outline",onClick:z,children:"Reset form"})]}),c?null:e.jsxs(y,{variant:"outline",className:"w-full gap-1.5 text-destructive hover:text-destructive",onClick:()=>void Se(),disabled:S.isPending,children:[e.jsx(Be,{className:"h-3.5 w-3.5"}),"Delete binding"]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"px-1 text-xs font-medium uppercase tracking-wide text-muted-foreground",children:"Saved bindings"}),e.jsx("div",{className:"space-y-2",children:w.length>0?w.map(t=>e.jsx(ze,{binding:t,isSelected:t.id===g&&!c,onSelect:()=>{I(!1),T(t.id),k(q(t))}},t.id)):e.jsx(u,{className:"border-dashed border-border/60 bg-card/60",children:e.jsx(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,c?e.jsx(p,{variant:"secondary",children:"Draft"}):null,m?.sharedSettings&&me(m.sharedSettings)&&me(m.ideSettings)?e.jsx(p,{className:"bg-emerald-600 hover:bg-emerald-600",children:"In sync"}):null]}),e.jsxs("div",{className:"max-w-5xl",children:[e.jsx("h2",{className:"text-2xl font-semibold tracking-tight",children:b?.name||"Claude extension binding"}),e.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:"Manage the shared Claude settings file and the IDE-local settings file as two scoped targets."})]})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(y,{variant:"outline",onClick:()=>void A.refetch(),disabled:c||A.isFetching,children:[A.isFetching?e.jsx(U,{className:"mr-1.5 h-3.5 w-3.5 animate-spin"}):e.jsx(Ie,{className:"mr-1.5 h-3.5 w-3.5"}),"Verify"]}),i?e.jsx(F,{value:i.sharedSettings.command,label:"Copy persist command"}):null]})]}),_?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(oe,{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:c,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:c,busy:be})]}),e.jsxs("div",{className:"grid gap-6 xl:grid-cols-[minmax(0,1.15fr)_minmax(320px,0.85fr)]",children:[e.jsxs(u,{className:"border-border/60 bg-card/80",children:[e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:"Resolved binding"}),e.jsx(v,{children:"The binding uses the same profile resolution as `ccs persist` and `ccs env`."})]}),e.jsxs(x,{className:"space-y-3",children:[e.jsx(o,{label:"Profile",value:i?.profile.label||r.profile||"Not selected"}),e.jsx(o,{label:"Profile type",value:i?.profile.profileType||"Unknown"}),e.jsx(o,{label:"IDE host",value:d?.label||"Not selected"}),e.jsx(o,{label:"IDE path mode",value:r.ideSettingsPath.trim()?"Custom path":"Default user path"}),e.jsx(o,{label:"Effective IDE path",value:m?.ideSettings.path||r.ideSettingsPath.trim()||d?.defaultSettingsPath||"Unavailable",mono:!0,copyValue:m?.ideSettings.path||r.ideSettingsPath.trim()||d?.defaultSettingsPath}),e.jsx(o,{label:"Persist command",value:i?.sharedSettings.command||"Save a valid binding first",mono:!0}),r.notes.trim()?e.jsx(o,{label:"Notes",value:r.notes.trim()}):null]})]}),e.jsxs(u,{className:"border-border/60 bg-card/80",children:[e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:"Managed payload"}),e.jsx(v,{children:"Keep the main view short. The full JSON stays in the Advanced tab."})]}),e.jsxs(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."})}),c?e.jsx("div",{className:"rounded-lg border border-dashed bg-muted/15 p-4 text-sm text-muted-foreground",children:"Save this draft to unlock apply, reset, and verify actions."}):e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(y,{className:"flex-1",onClick:()=>R("all","apply"),disabled: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(oe,{className:"mt-0.5 h-4 w-4 shrink-0 text-amber-600"}),e.jsx("span",{children:t})]},t)):e.jsx("div",{className:"rounded-lg border bg-muted/20 p-3 text-sm text-muted-foreground",children:"No runtime warnings for this binding."})})]}),e.jsxs(u,{className:"border-border/60 bg-card/80",children:[e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:"Notes"}),e.jsx(v,{children:"Short context from CCS about account continuity and host-specific behavior."})]}),e.jsx(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(o,{label:"Target path",value:m?.sharedSettings.path||i.sharedSettings.path,mono:!0,copyValue:m?.sharedSettings.path||i.sharedSettings.path}),e.jsx(o,{label:"Command",value:i.sharedSettings.command,mono:!0}),e.jsx(o,{label:"Current state",value:m?.sharedSettings.state||"Not verified"})]})]}),e.jsxs(u,{className:"border-border/60 bg-card/80",children:[e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:"IDE target metadata"}),e.jsx(v,{children:"Current file path plus the extension setting key used for this host."})]}),e.jsxs(x,{className:"space-y-3",children:[e.jsx(o,{label:"Target path",value:m?.ideSettings.path||r.ideSettingsPath.trim()||d?.defaultSettingsPath||i.ideSettings.path,mono:!0,copyValue:m?.ideSettings.path||r.ideSettingsPath.trim()||d?.defaultSettingsPath||i.ideSettings.path}),e.jsx(o,{label:"Settings key",value:d?.settingsKey||"Unknown",mono:!0}),e.jsx(o,{label:"Current state",value:m?.ideSettings.state||"Not verified"})]})]})]})]}):e.jsx(u,{className:"border-border/60 bg-card/80",children:e.jsxs(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-Zb8sVEtn.js";import{r as W}from"./react-vendor-CNOkPC89.js";import{b6 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-wIy8qzU9.js";import{u as K,a as J,b as V}from"./tanstack-DWm6aJ-G.js";import{t as E}from"./notifications-B2HqRBj7.js";import{a7 as Pe,a6 as ke,L as U,aq as De,ap as Be,R as Ie,T as oe,ae as Te,a4 as Re}from"./icons-BxSzn11s.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 ce(s){return{name:"",profile:s,host:"vscode",ideSettingsPath:"",notes:""}}function q(s){return{name:s.name,profile:s.profile,host:s.host,ideSettingsPath:s.ideSettingsPath||"",notes:s.notes||""}}function 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 o({label:s,value:a,mono:n=!1,copyValue:l}){const S=typeof l=="string"&&l.trim().length>0;return e.jsxs("div",{className:"grid gap-2 text-sm sm:grid-cols-[112px_minmax(0,1fr)] sm:items-start",children:[e.jsx("span",{className:"text-muted-foreground",children:s}),S?e.jsxs("div",{className:"flex min-w-0 items-start gap-2",children:[e.jsx("div",{className:"min-w-0 flex-1 rounded-md border bg-muted/25 px-3 py-2",children:e.jsx("span",{className:"block text-left font-mono text-xs leading-5 [overflow-wrap:anywhere]",children:_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(o,{label:"Path",value:n?.path||"Save a binding first",mono:!0,copyValue:n?.path}),e.jsx(o,{label:"File",value:n?n.exists?"Present":"Not created yet":"Unavailable"})]}),e.jsx("div",{className:"rounded-lg border bg-muted/25 p-3 text-sm text-muted-foreground",children:n?.message||"Verify the binding after saving to inspect the current file state."}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(y,{size:"sm",className:"flex-1",onClick: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(()=>ce("default")),c=fe||w.length===0,b=!c&&w.length>0?w.find(t=>t.id===O)??(O?null:w[0]):null,g=b?.id??null,r=c||!b||O?G:q(b),Y=Ae(r.profile,r.host),A=Le(c?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(ce(pe))}async function ye(){if(!Z)return;const t=Ve(r);if(!c&&g){const Q=await l.mutateAsync({id:g,binding:t});I(!1),T(Q.binding.id),k(q(Q.binding));return}const N=await n.mutateAsync(t);I(!1),T(N.binding.id),k(q(N.binding))}async function Se(){if(!g||!b||!window.confirm(`Delete binding "${b.name}"?`))return;await S.mutateAsync(g);const t=w.filter(N=>N.id!==g);t.length>0?(T(t[0].id),I(!1),k(q(t[0]))):z()}function $(t,N){if(!c&&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-full min-h-0 overflow-hidden",children:[e.jsxs("div",{className:"flex w-[348px] shrink-0 flex-col border-r bg-muted/30 xl:w-[372px]",children:[e.jsx("div",{className:"border-b bg-background p-4",children:e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"rounded-lg border bg-muted/40 p-2",children:e.jsx(Pe,{className:"h-5 w-5 text-primary"})}),e.jsxs("div",{children:[e.jsx("h1",{className:"font-semibold",children:"Claude Extension"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Saved IDE bindings for CCS profiles"})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(p,{variant:"secondary",children:je}),d?e.jsx(p,{variant:"outline",children:d.label}):null]})]}),e.jsxs(y,{size:"sm",onClick: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:c?"Create binding":"Binding editor"}),e.jsx(v,{children:"Save a profile + IDE path once, then apply or reset it from the dashboard."})]}),e.jsxs(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"}),c?"Create":"Save"]}),e.jsx(y,{variant:"outline",onClick:z,children:"Reset form"})]}),c?null:e.jsxs(y,{variant:"outline",className:"w-full gap-1.5 text-destructive hover:text-destructive",onClick:()=>void Se(),disabled:S.isPending,children:[e.jsx(Be,{className:"h-3.5 w-3.5"}),"Delete binding"]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"px-1 text-xs font-medium uppercase tracking-wide text-muted-foreground",children:"Saved bindings"}),e.jsx("div",{className:"space-y-2",children:w.length>0?w.map(t=>e.jsx(ze,{binding:t,isSelected:t.id===g&&!c,onSelect:()=>{I(!1),T(t.id),k(q(t))}},t.id)):e.jsx(u,{className:"border-dashed border-border/60 bg-card/60",children:e.jsx(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,c?e.jsx(p,{variant:"secondary",children:"Draft"}):null,m?.sharedSettings&&me(m.sharedSettings)&&me(m.ideSettings)?e.jsx(p,{className:"bg-emerald-600 hover:bg-emerald-600",children:"In sync"}):null]}),e.jsxs("div",{className:"max-w-5xl",children:[e.jsx("h2",{className:"text-2xl font-semibold tracking-tight",children:b?.name||"Claude extension binding"}),e.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:"Manage the shared Claude settings file and the IDE-local settings file as two scoped targets."})]})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(y,{variant:"outline",onClick:()=>void A.refetch(),disabled:c||A.isFetching,children:[A.isFetching?e.jsx(U,{className:"mr-1.5 h-3.5 w-3.5 animate-spin"}):e.jsx(Ie,{className:"mr-1.5 h-3.5 w-3.5"}),"Verify"]}),i?e.jsx(F,{value:i.sharedSettings.command,label:"Copy persist command"}):null]})]}),_?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(oe,{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:c,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:c,busy:be})]}),e.jsxs("div",{className:"grid gap-6 xl:grid-cols-[minmax(0,1.15fr)_minmax(320px,0.85fr)]",children:[e.jsxs(u,{className:"border-border/60 bg-card/80",children:[e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:"Resolved binding"}),e.jsx(v,{children:"The binding uses the same profile resolution as `ccs persist` and `ccs env`."})]}),e.jsxs(x,{className:"space-y-3",children:[e.jsx(o,{label:"Profile",value:i?.profile.label||r.profile||"Not selected"}),e.jsx(o,{label:"Profile type",value:i?.profile.profileType||"Unknown"}),e.jsx(o,{label:"IDE host",value:d?.label||"Not selected"}),e.jsx(o,{label:"IDE path mode",value:r.ideSettingsPath.trim()?"Custom path":"Default user path"}),e.jsx(o,{label:"Effective IDE path",value:m?.ideSettings.path||r.ideSettingsPath.trim()||d?.defaultSettingsPath||"Unavailable",mono:!0,copyValue:m?.ideSettings.path||r.ideSettingsPath.trim()||d?.defaultSettingsPath}),e.jsx(o,{label:"Persist command",value:i?.sharedSettings.command||"Save a valid binding first",mono:!0}),r.notes.trim()?e.jsx(o,{label:"Notes",value:r.notes.trim()}):null]})]}),e.jsxs(u,{className:"border-border/60 bg-card/80",children:[e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:"Managed payload"}),e.jsx(v,{children:"Keep the main view short. The full JSON stays in the Advanced tab."})]}),e.jsxs(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."})}),c?e.jsx("div",{className:"rounded-lg border border-dashed bg-muted/15 p-4 text-sm text-muted-foreground",children:"Save this draft to unlock apply, reset, and verify actions."}):e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(y,{className:"flex-1",onClick:()=>R("all","apply"),disabled: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(oe,{className:"mt-0.5 h-4 w-4 shrink-0 text-amber-600"}),e.jsx("span",{children:t})]},t)):e.jsx("div",{className:"rounded-lg border bg-muted/20 p-3 text-sm text-muted-foreground",children:"No runtime warnings for this binding."})})]}),e.jsxs(u,{className:"border-border/60 bg-card/80",children:[e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:"Notes"}),e.jsx(v,{children:"Short context from CCS about account continuity and host-specific behavior."})]}),e.jsx(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(o,{label:"Target path",value:m?.sharedSettings.path||i.sharedSettings.path,mono:!0,copyValue:m?.sharedSettings.path||i.sharedSettings.path}),e.jsx(o,{label:"Command",value:i.sharedSettings.command,mono:!0}),e.jsx(o,{label:"Current state",value:m?.sharedSettings.state||"Not verified"})]})]}),e.jsxs(u,{className:"border-border/60 bg-card/80",children:[e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:"IDE target metadata"}),e.jsx(v,{children:"Current file path plus the extension setting key used for this host."})]}),e.jsxs(x,{className:"space-y-3",children:[e.jsx(o,{label:"Target path",value:m?.ideSettings.path||r.ideSettingsPath.trim()||d?.defaultSettingsPath||i.ideSettings.path,mono:!0,copyValue:m?.ideSettings.path||r.ideSettingsPath.trim()||d?.defaultSettingsPath||i.ideSettings.path}),e.jsx(o,{label:"Settings key",value:d?.settingsKey||"Unknown",mono:!0}),e.jsx(o,{label:"Current state",value:m?.ideSettings.state||"Not verified"})]})]})]})]}):e.jsx(u,{className:"border-border/60 bg-card/80",children:e.jsxs(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-Zb8sVEtn.js";import{r as o}from"./react-vendor-CNOkPC89.js";import{a as st,u as Pt,b as es}from"./tanstack-DWm6aJ-G.js";import{a8 as ts,d as L,C as Mt,b as Dt,a9 as Tt,c as $,P as at,B as G,a as ae,aa as se,L as z,I as re,r as Be,s as ze,t as $e,v as Qe,w as be,ab as It,ac as ss,ad as as,ae as ns,u as Et,af as nt,ag as it,ah as rt,ai as ot,aj as Rt,ak as gt,al as is,am as rs,W as Ot,an as Je,ao as Lt,Y as Re,ap as os,aq as ft,ar as vt,as as ls,at as cs,au as ds,av as us,aw as ms,ax as ps,ay as xs,az as hs,aA as jt,aB as gs,x as _t,n as lt,aC as ct,aD as Nt,aE as Ft,aF as fs,m as vs,aG as js,aH as Ns,aI as We,T as Xe,p as Ye,q as Ze,aJ as bs,aK as ys,aL as ws,aM as bt,aN as Cs,aO as ks,aP as As,aQ as Ss,aR as Ps,aS as Ms,Q as Ds,R as Ts,U as yt,V as wt,aT as Is,aU as Es,aV as Rs,aW as Os,aX as Ls,aY as _s,aZ as Fs,a_ as Us,a$ as Ks,b0 as qs,b1 as Hs,b2 as Vs,S as Gs}from"./index-wIy8qzU9.js";import{C as et}from"./default-ports-1QQSffYX.js";import{t as H}from"./notifications-B2HqRBj7.js";import{C as Ut,L as X,o as he,Y as Bs,l as pe,n as Kt,aA as dt,R as ut,p as ye,a7 as Ce,T as mt,a4 as zs,aB as qt,az as $s,y as pt,Z as ke,V as Ht,h as Qs,t as Vt,aC as Js,aq as Ws,X as xt,a6 as Gt,I as Bt,z as zt,aD as Xs,ap as $t,aE as Ys,at as Zs,aF as Qt}from"./icons-BxSzn11s.js";import{R as Oe,A as Ct,D as He,i as ea,a as ta}from"./antigravity-responsibility-constants-Bvh4Ybz0.js";import{C as Le}from"./checkbox-Df-yoPbe.js";import{C as sa}from"./confirm-dialog-BMwFBq5G.js";import{S as ht}from"./separator-CR1SGLxF.js";import{S as aa}from"./searchable-select-D2G6gg3h.js";import{P as na}from"./proxy-status-widget-GS3qroms.js";import"./utils-CzKF5WmX.js";import"./form-utils-Bcoyqxpq.js";import"./code-highlight-BRUf_pqB.js";import"./alert-dialog-BtM3eP43.js";const Jt=Object.freeze({"gemini-3-pro-preview":"gemini-3.1-pro-preview","gemini-3.1-pro-preview":"gemini-3-pro-preview","gemini-3-flash-preview":"gemini-3.1-flash-preview","gemini-3.1-flash-preview":"gemini-3-flash-preview"}),ia=/^gemini-(\d+(?:[.-]\d+)*)-(pro|flash)-preview(-customtools)?$/i;function we(t){return ts(t).toLowerCase()}function _e(t){const s=we(t),a=s.match(ia);if(!a)return null;const[,n,i,d]=a;return{normalizedId:s,version:n.split(/[.-]/).map(m=>Number(m)),family:i,customtools:!!d,dottedVersion:n.includes(".")}}function Wt(t,s){const a=Math.max(t.length,s.length);for(let n=0;n<a;n+=1){const i=t[n]??0,d=s[n]??0;if(i!==d)return i>d?1:-1}return 0}function ra(t,s,a){if(t.customtools!==s.customtools)return t.customtools?1:-1;const n=Wt(t.version,s.version);if(n!==0)return n>0?-1:1;const i=+(t.dottedVersion===a.dottedVersion),d=+(s.dottedVersion===a.dottedVersion);return i!==d?d-i:t.normalizedId.localeCompare(s.normalizedId)}function kt(t,s){const a=we(s);return t.find(n=>we(n.id)===a)?.id}function oa(t,s){const a=_e(t);return!a||s.length===0?void 0:s.map(i=>{const d=_e(i.id);return!d||d.family!==a.family?null:{id:i.id,info:d}}).filter(i=>!!i).sort((i,d)=>ra(i.info,d.info,a))[0]?.id}const ge={agy:{provider:"agy",displayName:"Antigravity",defaultModel:"claude-opus-4-6-thinking",models:[{id:"claude-opus-4-6-thinking",name:"Claude Opus 4.6 Thinking",description:"Latest flagship, extended thinking",extendedContext:!1,presetMapping:{default:"claude-opus-4-6-thinking",opus:"claude-opus-4-6-thinking",sonnet:"claude-sonnet-4-6",haiku:"claude-sonnet-4-6"}},{id:"claude-sonnet-4-6",name:"Claude Sonnet 4.6",description:"Latest Sonnet with thinking budget support",presetMapping:{default:"claude-sonnet-4-6",opus:"claude-opus-4-6-thinking",sonnet:"claude-sonnet-4-6",haiku:"claude-sonnet-4-6"}},{id:"gemini-3.1-pro-preview",name:"Gemini Pro",description:"Resolves to the best advertised Gemini Pro preview via Antigravity",extendedContext:!0,presetMapping:{default:"gemini-3.1-pro-preview",opus:"gemini-3.1-pro-preview",sonnet:"gemini-3.1-pro-preview",haiku:"gemini-3-1-flash-preview"}},{id:"gemini-3-1-flash-preview",name:"Gemini Flash",description:"Resolves to the best advertised Gemini Flash preview via Antigravity",extendedContext:!0,presetMapping:{default:"gemini-3-1-flash-preview",opus:"gemini-3.1-pro-preview",sonnet:"gemini-3.1-pro-preview",haiku:"gemini-3-1-flash-preview"}}]},gemini:{provider:"gemini",displayName:"Gemini",defaultModel:"gemini-2.5-pro",models:[{id:"gemini-3.1-pro-preview",name:"Gemini Pro",tier:"paid",description:"Uses the best advertised Gemini Pro preview when Google exposes one",extendedContext:!0,presetMapping:{default:"gemini-3.1-pro-preview",opus:"gemini-3.1-pro-preview",sonnet:"gemini-3.1-pro-preview",haiku:"gemini-3-flash-preview"}},{id:"gemini-3-flash-preview",name:"Gemini Flash",tier:"paid",description:"Uses the best advertised Gemini Flash preview when Google exposes one",extendedContext:!0,presetMapping:{default:"gemini-3-flash-preview",opus:"gemini-3.1-pro-preview",sonnet:"gemini-3.1-pro-preview",haiku:"gemini-3-flash-preview"}},{id:"gemini-2.5-pro",name:"Gemini 2.5 Pro",description:"Stable, works with free Google account",extendedContext:!0,presetMapping:{default:"gemini-2.5-pro",opus:"gemini-2.5-pro",sonnet:"gemini-2.5-pro",haiku:"gemini-2.5-flash"}}]},codex:{provider:"codex",displayName:"Codex",defaultModel:"gpt-5-codex",models:[{id:"gpt-5-codex",name:"GPT-5 Codex",description:"Cross-plan safe Codex default",presetMapping:{default:"gpt-5-codex",opus:"gpt-5-codex",sonnet:"gpt-5-codex",haiku:"gpt-5-codex-mini"}},{id:"gpt-5-codex-mini",name:"GPT-5 Codex Mini",description:"Faster and cheaper Codex option",presetMapping:{default:"gpt-5-codex-mini",opus:"gpt-5-codex",sonnet:"gpt-5-codex",haiku:"gpt-5-codex-mini"}},{id:"gpt-5-mini",name:"GPT-5 Mini",description:"Legacy mini model ID kept for backwards compatibility",presetMapping:{default:"gpt-5-mini",opus:"gpt-5-codex",sonnet:"gpt-5-mini",haiku:"gpt-5-mini"}},{id:"gpt-5.1-codex-mini",name:"GPT-5.1 Codex Mini",description:"Legacy fast Codex mini model",presetMapping:{default:"gpt-5.1-codex-mini",opus:"gpt-5.1-codex-max",sonnet:"gpt-5.1-codex-max",haiku:"gpt-5.1-codex-mini"}},{id:"gpt-5.1-codex-max",name:"GPT-5.1 Codex Max",description:"Higher-effort Codex model with xhigh support",presetMapping:{default:"gpt-5.1-codex-max",opus:"gpt-5.1-codex-max",sonnet:"gpt-5.1-codex-max",haiku:"gpt-5.1-codex-mini"}},{id:"gpt-5.2-codex",name:"GPT-5.2 Codex",description:"Cross-plan Codex model with xhigh support",presetMapping:{default:"gpt-5.2-codex",opus:"gpt-5.2-codex",sonnet:"gpt-5.2-codex",haiku:"gpt-5-codex-mini"}},{id:"gpt-5.3-codex",name:"GPT-5.3 Codex",tier:"paid",description:"Paid Codex plans only",presetMapping:{default:"gpt-5.3-codex",opus:"gpt-5.3-codex",sonnet:"gpt-5.3-codex",haiku:"gpt-5-codex-mini"}},{id:"gpt-5.3-codex-spark",name:"GPT-5.3 Codex Spark",tier:"paid",description:"Paid Codex plans only, ultra-fast coding model",presetMapping:{default:"gpt-5.3-codex-spark",opus:"gpt-5.3-codex",sonnet:"gpt-5.3-codex",haiku:"gpt-5-codex-mini"}},{id:"gpt-5.4",name:"GPT-5.4",tier:"paid",description:"Paid Codex plans only, latest GPT-5 family model",presetMapping:{default:"gpt-5.4",opus:"gpt-5.4",sonnet:"gpt-5.4",haiku:"gpt-5-codex-mini"}}]},qwen:{provider:"qwen",displayName:"Qwen",defaultModel:"qwen3-coder-plus",models:[{id:"qwen3-coder-plus",name:"Qwen3 Coder Plus",description:"Code-focused model (1M context)",presetMapping:{default:"qwen3-coder-plus",opus:"qwen3-max",sonnet:"qwen3-coder-plus",haiku:"qwen3-coder-flash"}},{id:"qwen3-max",name:"Qwen3 Max",description:"Flagship model (256K context)",presetMapping:{default:"qwen3-max",opus:"qwen3-max",sonnet:"qwen3-coder-plus",haiku:"qwen3-coder-flash"}},{id:"qwen3-max-preview",name:"Qwen3 Max Preview",description:"Preview with thinking support (256K)",presetMapping:{default:"qwen3-max-preview",opus:"qwen3-max-preview",sonnet:"qwen3-max",haiku:"qwen3-coder-flash"}},{id:"qwen3-235b",name:"Qwen3 235B",description:"Large 235B A22B model",presetMapping:{default:"qwen3-235b",opus:"qwen3-max",sonnet:"qwen3-235b",haiku:"qwen3-coder-flash"}},{id:"qwen3-vl-plus",name:"Qwen3 VL Plus",description:"Vision-language multimodal"},{id:"qwen3-coder-flash",name:"Qwen3 Coder Flash",description:"Fast code generation"},{id:"qwen3-32b",name:"Qwen3 32B",description:"Qwen3 32B model"}]},iflow:{provider:"iflow",displayName:"iFlow",defaultModel:"qwen3-coder-plus",models:[{id:"qwen3-coder-plus",name:"Qwen3 Coder Plus",description:"Recommended default for iFlow accounts",presetMapping:{default:"qwen3-coder-plus",opus:"qwen3-coder-plus",sonnet:"qwen3-coder-plus",haiku:"qwen3-coder-plus"}},{id:"qwen3-max",name:"Qwen3 Max",description:"Flagship Qwen model via iFlow"},{id:"kimi-k2",name:"Kimi K2",description:"Kimi model currently available via iFlow"},{id:"deepseek-v3.2",name:"DeepSeek V3.2",description:"Current DeepSeek V3.2 model via iFlow"},{id:"deepseek-r1",name:"DeepSeek R1",description:"Reasoning-focused DeepSeek model"},{id:"glm-4.6",name:"GLM 4.6",description:"Zhipu GLM 4.6 via iFlow"},{id:"qwen3-vl-plus",name:"Qwen3 VL Plus",description:"Vision-language model"}]},kimi:{provider:"kimi",displayName:"Kimi (Moonshot)",defaultModel:"kimi-k2.5",models:[{id:"kimi-k2.5",name:"Kimi K2.5",description:"Latest multimodal model (262K context)",presetMapping:{default:"kimi-k2.5",opus:"kimi-k2.5",sonnet:"kimi-k2-thinking",haiku:"kimi-k2"}},{id:"kimi-k2-thinking",name:"Kimi K2 Thinking",description:"Extended reasoning model",presetMapping:{default:"kimi-k2-thinking",opus:"kimi-k2.5",sonnet:"kimi-k2-thinking",haiku:"kimi-k2"}},{id:"kimi-k2",name:"Kimi K2",description:"Flagship coding model"}]},kiro:{provider:"kiro",displayName:"Kiro (AWS)",defaultModel:"kiro-claude-sonnet-4-6",models:[{id:"kiro-claude-opus-4-6",name:"Kiro Claude Opus 4.6",description:"Claude Opus 4.6 via Kiro (2.2x credit)",presetMapping:{default:"kiro-claude-opus-4-6",opus:"kiro-claude-opus-4-6",sonnet:"kiro-claude-sonnet-4-6",haiku:"kiro-claude-haiku-4-5"}},{id:"kiro-claude-sonnet-4-6",name:"Kiro Claude Sonnet 4.6",description:"Claude Sonnet 4.6 via Kiro (1.3x credit)",presetMapping:{default:"kiro-claude-sonnet-4-6",opus:"kiro-claude-opus-4-6",sonnet:"kiro-claude-sonnet-4-6",haiku:"kiro-claude-haiku-4-5"}},{id:"kiro-claude-opus-4-5",name:"Kiro Claude Opus 4.5",description:"Claude Opus 4.5 via Kiro (2.2x credit)",presetMapping:{default:"kiro-claude-opus-4-5",opus:"kiro-claude-opus-4-5",sonnet:"kiro-claude-sonnet-4-5",haiku:"kiro-claude-haiku-4-5"}},{id:"kiro-claude-sonnet-4-5",name:"Kiro Claude Sonnet 4.5",description:"Claude Sonnet 4.5 via Kiro (1.3x credit)",presetMapping:{default:"kiro-claude-sonnet-4-5",opus:"kiro-claude-opus-4-5",sonnet:"kiro-claude-sonnet-4-5",haiku:"kiro-claude-haiku-4-5"}},{id:"kiro-claude-sonnet-4",name:"Kiro Claude Sonnet 4",description:"Claude Sonnet 4 via Kiro (1.3x credit)",presetMapping:{default:"kiro-claude-sonnet-4",opus:"kiro-claude-opus-4-5",sonnet:"kiro-claude-sonnet-4",haiku:"kiro-claude-haiku-4-5"}},{id:"kiro-claude-haiku-4-5",name:"Kiro Claude Haiku 4.5",description:"Claude Haiku 4.5 via Kiro (0.4x credit)"}]},ghcp:{provider:"ghcp",displayName:"GitHub Copilot (OAuth)",defaultModel:"claude-sonnet-4.5",models:[{id:"claude-opus-4.5",name:"Claude Opus 4.5",description:"Anthropic Claude Opus 4.5 via GitHub Copilot",presetMapping:{default:"claude-opus-4.5",opus:"claude-opus-4.5",sonnet:"claude-sonnet-4.5",haiku:"claude-haiku-4.5"}},{id:"claude-sonnet-4.5",name:"Claude Sonnet 4.5",description:"Anthropic Claude Sonnet 4.5 via GitHub Copilot",presetMapping:{default:"claude-sonnet-4.5",opus:"claude-opus-4.5",sonnet:"claude-sonnet-4.5",haiku:"claude-haiku-4.5"}},{id:"claude-sonnet-4",name:"Claude Sonnet 4",description:"Anthropic Claude Sonnet 4 via GitHub Copilot"},{id:"claude-haiku-4.5",name:"Claude Haiku 4.5",description:"Anthropic Claude Haiku 4.5 via GitHub Copilot"},{id:"gpt-5.2",name:"GPT-5.2",description:"OpenAI GPT-5.2 via GitHub Copilot",presetMapping:{default:"gpt-5.2",opus:"gpt-5.2",sonnet:"gpt-5.1",haiku:"gpt-5-mini"}},{id:"gpt-5.1",name:"GPT-5.1",description:"OpenAI GPT-5.1 via GitHub Copilot"},{id:"gpt-5",name:"GPT-5",description:"OpenAI GPT-5 via GitHub Copilot"},{id:"gpt-5-mini",name:"GPT-5 Mini",description:"OpenAI GPT-5 Mini via GitHub Copilot"},{id:"gemini-3-pro",name:"Gemini 3 Pro",description:"Google Gemini 3 Pro via GitHub Copilot"}]},claude:{provider:"claude",displayName:"Claude (Anthropic)",defaultModel:"claude-sonnet-4-6",models:[{id:"claude-opus-4-6",name:"Claude Opus 4.6",description:"Latest flagship model",extendedContext:!0,presetMapping:{default:"claude-opus-4-6",opus:"claude-opus-4-6",sonnet:"claude-sonnet-4-6",haiku:"claude-haiku-4-5-20251001"}},{id:"claude-sonnet-4-6",name:"Claude Sonnet 4.6",description:"Balanced performance and speed",extendedContext:!0,presetMapping:{default:"claude-sonnet-4-6",opus:"claude-opus-4-6",sonnet:"claude-sonnet-4-6",haiku:"claude-haiku-4-5-20251001"}},{id:"claude-opus-4-5-20251101",name:"Claude Opus 4.5",description:"Most capable Claude model",extendedContext:!0,presetMapping:{default:"claude-opus-4-5-20251101",opus:"claude-opus-4-5-20251101",sonnet:"claude-sonnet-4-5-20250929",haiku:"claude-haiku-4-5-20251001"}},{id:"claude-sonnet-4-5-20250929",name:"Claude Sonnet 4.5",description:"Balanced performance and speed",extendedContext:!0,presetMapping:{default:"claude-sonnet-4-5-20250929",opus:"claude-opus-4-5-20251101",sonnet:"claude-sonnet-4-5-20250929",haiku:"claude-haiku-4-5-20251001"}},{id:"claude-sonnet-4-20250514",name:"Claude Sonnet 4",description:"Previous generation Sonnet",extendedContext:!0,presetMapping:{default:"claude-sonnet-4-20250514",opus:"claude-opus-4-5-20251101",sonnet:"claude-sonnet-4-20250514",haiku:"claude-haiku-4-5-20251001"}},{id:"claude-haiku-4-5-20251001",name:"Claude Haiku 4.5",description:"Fast and efficient"}]}};function Xt(t,s){const a=ge[t.toLowerCase()];if(!a)return;const n=we(s),i=Jt[n.toLowerCase()],d=a.models.find(c=>c.id===n||c.id===i);if(d)return d;const m=_e(n);if(m)return a.models.map(c=>({model:c,info:_e(c.id)})).filter(c=>!!(c.info&&c.info.family===m.family)).sort((c,l)=>Wt(l.info.version,c.info.version))[0]?.model}function Ne(t,s=[]){const a=we(t),n=oa(a,s);if(n)return n;const i=kt(s,a);if(i)return i;const d=Jt[a];return(d?kt(s,d):void 0)??a}function la(t,s=[]){return{default:Ne(t.default,s),opus:Ne(t.opus,s),sonnet:Ne(t.sonnet,s),haiku:Ne(t.haiku,s)}}function Yt(t,s=[]){if(!t)return[];const a=new Set;return t.models.map(n=>{const i=Ne(n.id,s),d=n.presetMapping?la(n.presetMapping,s):void 0;return{...n,id:i,presetMapping:d}}).filter(n=>a.has(n.id)?!1:(a.add(n.id),!0))}function ca(t,s){return Xt(t,s)?.extendedContext===!0}const Ve="ccs-internal-managed";async function da(){try{const t=await fetch("/api/settings/auth/tokens/raw");return t.ok?(await t.json())?.apiKey?.value??Ve:Ve}catch{return Ve}}async function tt(t,s){const a=ge[t];if(!a)return{success:!1};const n=a.models.find(l=>l.id===a.defaultModel)||a.models[0],i=n?.presetMapping||{default:a.defaultModel,opus:a.defaultModel,sonnet:a.defaultModel,haiku:a.defaultModel},d=await da(),c={env:{ANTHROPIC_BASE_URL:`http://127.0.0.1:${et}/api/provider/${t}`,ANTHROPIC_AUTH_TOKEN:d,ANTHROPIC_MODEL:i.default,ANTHROPIC_DEFAULT_OPUS_MODEL:i.opus,ANTHROPIC_DEFAULT_SONNET_MODEL:i.sonnet,ANTHROPIC_DEFAULT_HAIKU_MODEL:i.haiku}};try{return{success:(await fetch(`/api/settings/${t}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({settings:c})})).ok,presetName:n?.name||a.defaultModel}}catch{return{success:!1}}}function ua({currentProgress:t,allSteps:s}){return e.jsx("div",{className:"flex justify-center gap-1 pt-2",children:s.map((a,n)=>e.jsx("div",{className:`w-2 h-2 rounded-full transition-colors ${t>=n?"bg-primary":"bg-muted"}`},a))})}function ma({providers:t,onSelect:s}){return e.jsx("div",{className:"grid gap-2",children:t.map(a=>e.jsxs("button",{onClick:()=>s(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(Ut,{className:"w-4 h-4 text-muted-foreground"})]},a.id))})}function pa({selectedProvider:t,providers:s,authCommand:a,isRefreshing:n,isPending:i,onBack:d,onStartAuth:m,onRefresh:c}){const[l,p]=o.useState(!1),f=async h=>{await navigator.clipboard.writeText(h),p(!0),setTimeout(()=>p(!1),2e3)};return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"text-center space-y-3",children:[e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Authenticate with ",s.find(h=>h.id===t)?.name," to add an account"]}),e.jsx(L,{onClick:m,disabled:i,className:"w-full gap-2",size:"lg",children:i?e.jsxs(e.Fragment,{children:[e.jsx(X,{className:"w-4 h-4 animate-spin"}),"Authenticating..."]}):e.jsxs(e.Fragment,{children:[e.jsx(he,{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(Mt,{children:e.jsxs(Dt,{className:"p-4 space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(Bs,{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(L,{variant:"outline",size:"icon",onClick:()=>f(a),children:l?e.jsx(pe,{className:"w-4 h-4 text-green-500"}):e.jsx(Kt,{className:"w-4 h-4"})})]})]})}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(L,{variant:"ghost",onClick:d,disabled:i,children:[e.jsx(dt,{className:"w-4 h-4 mr-2"}),"Back"]}),e.jsxs(L,{variant:"outline",onClick:c,disabled:n||i,children:[e.jsx(ut,{className:`w-4 h-4 mr-2 ${n?"animate-spin":""}`}),n?"Checking...":"Refresh Status"]})]})]})}function xa({accounts:t,privacyMode:s,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 (",t.length,")"]}),e.jsx("div",{className:"grid gap-2 max-h-[320px] overflow-y-auto pr-1",children:t.map(d=>{const m=Tt(d.id,d.email,d.tokenFile);return e.jsxs("button",{type:"button",onClick:()=>a(d),className:"flex items-center justify-between p-3 border rounded-lg hover:bg-muted/50 transition-colors text-left",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-8 h-8 rounded-full bg-muted flex items-center justify-center",children:e.jsx(ye,{className:"w-4 h-4 text-muted-foreground"})}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("div",{className:$("font-medium",s&&at),children:m.email}),e.jsxs("div",{className:"flex items-center gap-1.5 flex-wrap",children:[m.audienceLabel&&e.jsx(G,{variant:"outline",className:$("text-[10px] h-4 px-1.5 border-transparent",m.audience==="business"?"bg-sky-500/12 text-sky-700 dark:text-sky-300":"bg-emerald-500/12 text-emerald-700 dark:text-emerald-300"),children:m.audienceLabel}),m.detailLabel&&e.jsx(G,{variant:"outline",className:"text-[10px] h-4 px-1.5",children:m.detailLabel}),d.isDefault&&e.jsx("span",{className:"text-xs text-muted-foreground",children:"Default account"})]})]})]}),e.jsx(Ut,{className:"w-4 h-4 text-muted-foreground"})]},d.id)})}),e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"absolute inset-0 flex items-center",children:e.jsx("span",{className:"w-full border-t"})}),e.jsx("div",{className:"relative flex justify-center text-xs uppercase",children:e.jsx("span",{className:"bg-background px-2 text-muted-foreground",children:"Or"})})]}),e.jsxs("button",{type:"button",className:"w-full flex items-center gap-3 p-3 border-2 border-dashed border-primary/50 rounded-lg hover:border-primary hover:bg-primary/5 transition-colors text-left",onClick:n,children:[e.jsx("div",{className:"w-8 h-8 rounded-full bg-primary/10 flex items-center justify-center shrink-0",children:e.jsx(he,{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(L,{variant:"ghost",onClick:i,children:[e.jsx(dt,{className:"w-4 h-4 mr-2"}),"Back"]})})]})}const At="__custom__";function ha({selectedProvider:t,selectedAccount:s,variantName:a,modelName:n,isPending:i,privacyMode:d,onVariantNameChange:m,onModelChange:c,onBack:l,onSkip:p,onCreate:f}){const{t:h}=ae(),g=ge[t]?.models||[],_=n&&!g.some(r=>r.id===n),[v,T]=o.useState(_),k=t==="agy"&&n.trim().length>0?se(n):!1,y=s?Tt(s.id,s.email,s.tokenFile):null,M=r=>{r===At?(T(!0),c("")):(T(!1),c(r))};return e.jsxs("div",{className:"space-y-4",children:[s&&e.jsxs("div",{className:"flex items-start gap-2 p-2 bg-muted/50 rounded-md text-sm",children:[e.jsx(ye,{className:"w-4 h-4"}),e.jsxs("div",{className:"space-y-1",children:[e.jsxs("span",{children:[h("setupVariant.using")," ",e.jsx("span",{className:$(d&&at),children:y?.email})]}),(y?.audienceLabel||y?.detailLabel)&&e.jsxs("div",{className:"flex items-center gap-1.5 flex-wrap",children:[y?.audienceLabel&&e.jsx(G,{variant:"outline",className:$("text-[10px] h-4 px-1.5 border-transparent",y.audience==="business"?"bg-sky-500/12 text-sky-700 dark:text-sky-300":"bg-emerald-500/12 text-emerald-700 dark:text-emerald-300"),children:y.audienceLabel}),y?.detailLabel&&e.jsx(G,{variant:"outline",className:"text-[10px] h-4 px-1.5",children:y.detailLabel})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(z,{htmlFor:"variant-name",children:h("setupVariant.variantNameRequired")}),e.jsx(re,{id:"variant-name",value:a,onChange:r=>m(r.target.value),placeholder:h("setupVariant.variantNamePlaceholder")}),e.jsxs("div",{className:"text-xs text-muted-foreground",children:[h("setupVariant.invokeHintPrefix")," ccs ",a||"<name>",' "prompt"']})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(z,{children:h("setupVariant.model")}),v?e.jsxs("div",{className:"space-y-2",children:[e.jsx(re,{value:n,onChange:r=>c(r.target.value),placeholder:h("setupVariant.modelPlaceholder")}),k&&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:()=>{T(!1),t==="agy"&&se(n)&&c("")},children:h("setupVariant.choosePresetInstead")})]}):e.jsxs(Be,{value:g.some(r=>r.id===n)?n:"",onValueChange:M,children:[e.jsx(ze,{children:e.jsx($e,{placeholder:h("setupVariant.selectModel")})}),e.jsxs(Qe,{children:[g.map(r=>e.jsx(be,{value:r.id,children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{children:r.name}),r.description&&e.jsxs("span",{className:"text-xs text-muted-foreground",children:["- ",r.description]})]})},r.id)),e.jsx(be,{value:At,children:e.jsx("span",{className:"text-primary",children:h("setupVariant.customModelName")})})]})]}),e.jsx("div",{className:"text-xs text-muted-foreground",children:v?h("setupVariant.enterAnyModel"):h("setupVariant.defaultModel",{model:ge[t]?.defaultModel||h("setupVariant.providerDefault")})})]}),e.jsxs("div",{className:"flex items-center justify-between pt-2",children:[e.jsxs(L,{variant:"ghost",onClick:l,children:[e.jsx(dt,{className:"w-4 h-4 mr-2"}),h("setupVariant.back")]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(L,{variant:"ghost",onClick:p,children:h("setupVariant.skip")}),e.jsx(L,{onClick:f,disabled:!a||i||k,children:h(i?"setupVariant.creating":"setupVariant.createVariant")})]})]}),e.jsx("p",{className:"text-xs text-center text-muted-foreground",children:h("setupVariant.skipHint")})]})}function ga({variantName:t,onClose:s}){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(pe,{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(Mt,{children:e.jsxs(Dt,{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 ",t,' "your prompt here"']})]})}),e.jsx(L,{onClick:s,className:"w-full",children:"Done"})]})}function fa({open:t,onClose:s}){const[a,n]=o.useState("provider"),[i,d]=o.useState(""),[m,c]=o.useState(null),[l,p]=o.useState(""),[f,h]=o.useState(""),[g,_]=o.useState(!1),[v,T]=o.useState(!1),{data:k,refetch:y}=It(),M=ss(),r=as(),b=ns(),{privacyMode:j}=Et(),A=k?.authStatus.find(R=>R.provider===i),I=o.useMemo(()=>A?.accounts||[],[A?.accounts]);o.useEffect(()=>{if(!t){const R=setTimeout(()=>{n("provider"),d(""),c(null),p(""),h(""),T(!1)},0);return()=>clearTimeout(R)}},[t]),o.useEffect(()=>{if(a==="auth"&&I.length>0&&!v){const R=setTimeout(()=>{n("account")},0);return()=>clearTimeout(R)}},[a,I,v]);const D=async()=>{_(!0),await y(),_(!1)},P=()=>{const R=(A?.accounts?.length||0)===0;r.mutate({provider:i},{onSuccess:async N=>{if(R){const K=await tt(i);K.success&&K.presetName?H.success(`Applied "${K.presetName}" preset`):K.success||H.warning(Ot.t("commonToast.accountAddedPresetFailed"))}N.account&&(c(N.account),n("variant")),y()}})},U=R=>{d(R),(k?.authStatus.find(q=>q.provider===R)?.accounts||[]).length===0?n("auth"):n("account")},C=R=>{c(R),n("variant")},w=async()=>{if(!(!l||!i))try{await M.mutateAsync({name:l,provider:i,model:f||void 0,account:m?.id}),n("success")}catch(R){console.error("Failed to create variant:",R)}},u=`ccs ${i} --auth --add`,F=rs(a),V=R=>{if(!R&&(r.isPending&&i&&b.mutate(i),a==="success"||a==="provider")){s();return}};return e.jsx(nt,{open:t,onOpenChange:V,children:e.jsxs(it,{className:"sm:max-w-lg",onPointerDownOutside:R=>{a!=="success"&&a!=="provider"&&R.preventDefault()},onEscapeKeyDown:R=>{(r.isPending||M.isPending)&&R.preventDefault()},children:[e.jsxs(rt,{children:[e.jsxs(ot,{className:"flex items-center gap-2",children:[e.jsx(Ce,{className:"w-5 h-5 text-primary"}),"Quick Setup Wizard"]}),e.jsxs(Rt,{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(ma,{providers:gt,onSelect:U}),a==="auth"&&e.jsx(pa,{selectedProvider:i,providers:gt,authCommand:u,isRefreshing:g,isPending:r.isPending,onBack:()=>n("provider"),onStartAuth:P,onRefresh:D}),a==="account"&&e.jsx(xa,{accounts:I,privacyMode:j,onSelect:C,onAddNew:()=>{T(!0),n("auth")},onBack:()=>n("provider")}),a==="variant"&&e.jsx(ha,{selectedProvider:i,selectedAccount:m,variantName:l,modelName:f,isPending:M.isPending,privacyMode:j,onVariantNameChange:p,onModelChange:h,onBack:()=>I.length>0?n("account"):n("provider"),onSkip:s,onCreate:w}),a==="success"&&e.jsx(ga,{variantName:l,onClose:s})]}),e.jsx(ua,{currentProgress:F,allSteps:is})]})})}const va=3e3,ja=300*1e3,Na=3;async function Ge(t){const s=await t.text();if(!s)return{};try{return JSON.parse(s)}catch{const a=t.status>=400?`Request failed with status ${t.status}`:void 0;return a?{error:a}:{}}}const oe={provider:null,isAuthenticating:!1,error:null,authUrl:null,oauthState:null,isSubmittingCallback:!1,isDeviceCodeFlow:!1};function ba(){const[t,s]=o.useState(oe),a=o.useRef(oe),n=o.useRef(0),i=o.useRef(null),d=o.useRef(null),m=o.useRef(0),c=o.useRef(0),l=o.useRef(!1),p=st(),f=o.useCallback(k=>k===n.current,[]),h=o.useCallback(()=>{d.current&&(clearInterval(d.current),d.current=null),c.current=0},[]);o.useEffect(()=>()=>{i.current?.abort(),h(),l.current=!1},[h]),o.useEffect(()=>{a.current=t},[t]);const g=o.useCallback(async(k,y,M)=>{if(f(M)){if(Date.now()-m.current>ja){h(),f(M)&&s(r=>({...r,isAuthenticating:!1,error:"Authentication timed out. Please try again."}));return}try{const r=await fetch(`/api/cliproxy/auth/${k}/status?state=${encodeURIComponent(y)}`);if(!f(M))return;const b=await r.json();if(c.current=0,b.status==="ok"){if(!(typeof b.account=="object"&&b.account!==null)){h();const A="Authenticated account could not be registered";H.error(A),s(I=>({...I,isAuthenticating:!1,error:A}));return}h(),p.invalidateQueries({queryKey:["cliproxy-auth"]}),p.invalidateQueries({queryKey:["cliproxy-accounts"]}),p.invalidateQueries({queryKey:["account-quota"]}),H.success(`${k} authentication successful`),l.current=!1,s(oe)}else if(b.status==="auth_url"){const j=b.url||b.auth_url;j&&(s(A=>({...A,authUrl:j})),l.current||(l.current=!0,window.open(j,"_blank")))}else if(b.status==="device_code"){h();const j=b.user_code&&b.verification_url?`Open ${b.verification_url} and enter code: ${b.user_code}`:"Switch to Device Code method and try again.";H.error("Provider returned Device Code flow in callback mode"),s(A=>({...A,isAuthenticating:!1,error:j}))}else if(b.status==="error"){h();const j=b.error||"Authentication failed";H.error(j),s(A=>({...A,isAuthenticating:!1,error:j}))}}catch(r){if(!f(M)||(c.current+=1,c.current<Na))return;h();const b=r instanceof Error&&r.message.trim().length>0?r.message:"Lost contact with the auth status endpoint";H.error(b),s(j=>({...j,isAuthenticating:!1,error:b}))}}},[f,p,h]),_=o.useCallback(async(k,y)=>{if(!Je(k)){s({...oe,error:`Unknown provider: ${k}`});return}i.current?.abort(),h(),l.current=!1,c.current=0;const M=new AbortController,r=n.current+1;n.current=r,i.current=M;const j=(y?.flowType||(Lt(k)?"device_code":"authorization_code"))==="device_code",A=y?.startEndpoint||(j?"start":"start-url"),I={nickname:y?.nickname,kiroMethod:y?.kiroMethod,kiroIDCStartUrl:y?.kiroIDCStartUrl,kiroIDCRegion:y?.kiroIDCRegion,kiroIDCFlow:y?.kiroIDCFlow,riskAcknowledgement:y?.riskAcknowledgement};s({provider:k,isAuthenticating:!0,error:null,authUrl:null,oauthState:null,isSubmittingCallback:!1,isDeviceCodeFlow:j});try{if(A==="start")fetch(`/api/cliproxy/auth/${k}/start`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(I),signal:M.signal}).then(async D=>{if(!f(r))return;const P=await Ge(D);if(!f(r))return;const U=P.success===!0,C=typeof P.account=="object"&&P.account!==null;if(D.ok&&U&&C)p.invalidateQueries({queryKey:["cliproxy-auth"]}),p.invalidateQueries({queryKey:["cliproxy-accounts"]}),p.invalidateQueries({queryKey:["account-quota"]}),l.current=!1,s(oe);else{const w=typeof P.error=="string"?P.error:U?"Authenticated account could not be registered":"Authentication failed";H.error(w),s(u=>({...u,isAuthenticating:!1,error:w}))}}).catch(D=>{if(!f(r)||D instanceof Error&&D.name==="AbortError")return;const P=D instanceof Error?D.message:"Authentication failed";H.error(P),s(U=>({...U,isAuthenticating:!1,error:P}))});else{const D=await fetch(`/api/cliproxy/auth/${k}/start-url`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(I),signal:M.signal});if(!f(r))return;const P=await Ge(D);if(!f(r))return;const U=P.success===!0;if(!D.ok||!U){const u=typeof P.error=="string"?P.error:"Failed to start OAuth";throw new Error(u)}const C=typeof P.authUrl=="string"?P.authUrl:null,w=typeof P.state=="string"?P.state:null;if(s(u=>({...u,authUrl:C,oauthState:w})),C&&(l.current=!0,window.open(C,"_blank")),w){if(m.current=Date.now(),!C){if(await g(k,w,r),!f(r))return;const u=a.current;if(!u.isAuthenticating||u.provider!==k)return}d.current=setInterval(()=>{g(k,w,r)},va)}}}catch(D){if(!f(r))return;if(D instanceof Error&&D.name==="AbortError"){l.current=!1,s(oe);return}const P=D instanceof Error?D.message:"Authentication failed";H.error(P),s(U=>({...U,isAuthenticating:!1,error:P}))}},[f,g,h,p]),v=o.useCallback(()=>{const k=t.provider;n.current+=1,i.current?.abort(),h(),l.current=!1,s(oe),k&&Re.cliproxy.auth.cancel(k).catch(()=>{})},[t.provider,h]),T=o.useCallback(async k=>{if(!t.provider)return;const y=n.current,M=t.provider;s(r=>({...r,isSubmittingCallback:!0,error:null}));try{const r=await fetch(`/api/cliproxy/auth/${M}/submit-callback`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({redirectUrl:k})});if(!f(y))return;const b=await Ge(r);if(!f(y))return;const j=b.success===!0,A=b.status==="wait",I=typeof b.account=="object"&&b.account!==null;if(r.ok&&A)s(D=>({...D,isSubmittingCallback:!1,error:null}));else if(r.ok&&j&&I)h(),p.invalidateQueries({queryKey:["cliproxy-auth"]}),p.invalidateQueries({queryKey:["cliproxy-accounts"]}),p.invalidateQueries({queryKey:["account-quota"]}),H.success(`${M} authentication successful`),s(oe);else{const D=typeof b.error=="string"?b.error:j?"Authenticated account could not be registered":"Callback submission failed";throw new Error(D)}}catch(r){if(!f(y))return;const b=r instanceof Error?r.message:"Failed to submit callback";H.error(b),s(j=>({...j,isSubmittingCallback:!1,error:b}))}},[f,t.provider,p,h]);return o.useMemo(()=>({...t,startAuth:_,cancelAuth:v,submitCallback:T}),[t,_,v,T])}function Zt({className:t,showAcknowledgement:s=!1,acknowledgementPhrase:a=Oe,acknowledgementText:n="",onAcknowledgementTextChange:i,disabled:d=!1,showProxySettingsLink:m=!1}){const{t:c}=ae(),l=c("accountSafetyWarning.title"),p=c("accountSafetyWarning.subtitle"),f=c("accountSafetyWarning.firstLine"),h=c("accountSafetyWarning.secondLine"),g="https://github.com/kaitranntt/ccs/issues/509",_=c("accountSafetyWarning.issueLabel"),v=c("accountSafetyWarning.proxySettingsLabel");return e.jsxs("section",{role:"alert",className:$("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",t),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(mt,{className:"h-4 w-4"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-semibold leading-5",children:l}),e.jsx("p",{className:"text-xs text-muted-foreground",children:p})]})]}),e.jsx(G,{variant:"outline",className:"border-amber-500/40 text-amber-700 dark:text-amber-300",children:"High Risk"})]}),e.jsxs("div",{className:"space-y-2 text-sm leading-relaxed",children:[e.jsx("p",{children:f}),e.jsx("p",{className:"font-medium text-amber-900 dark:text-amber-200",children:h}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"CCS is provided as-is and does not take responsibility for suspension, bans, or access loss from upstream providers."})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs("a",{href:g,target:"_blank",rel:"noreferrer",className:"inline-flex items-center gap-1.5 rounded-md border border-amber-500/30 bg-amber-500/10 px-2.5 py-1 text-xs font-medium text-amber-800 transition-colors hover:bg-amber-500/15 dark:text-amber-200",children:[_,e.jsx(he,{className:"h-3.5 w-3.5"})]}),m&&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(zs,{className:"h-3.5 w-3.5"}),v]}),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"})]}),s&&i&&e.jsxs("div",{className:"rounded-lg border border-amber-500/25 bg-amber-500/5 p-2.5",children:[e.jsxs(z,{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(re,{id:"account-risk-ack-text",value:n,onChange:T=>i(T.target.value),placeholder:a,disabled:d,className:"mt-2 font-mono text-xs"})]})]})]})}function ya({className:t,value:s,onChange:a,disabled:n=!1}){const{t:i}=ae(),d=[s.reviewedIssue509,s.understandsBanRisk,s.acceptsFullResponsibility,s.typedPhrase.trim().replace(/\s+/g," ").toUpperCase()===Ct].filter(Boolean).length,m=d/4*100,c=l=>{a({...s,...l})};return e.jsxs("section",{role:"alert",className:$("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",t),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(mt,{className:"h-4 w-4"})}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-sm font-semibold leading-5",children:i("antigravityChecklist.title")}),e.jsx("p",{className:"text-xs text-muted-foreground",children:i("antigravityChecklist.subtitle")})]})]}),e.jsx(G,{variant:"outline",className:"border-rose-500/40 text-rose-700 dark:text-rose-300",children:i("antigravityChecklist.mandatory")})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{className:"flex items-center justify-between text-xs text-muted-foreground",children:[e.jsx("span",{children:i("antigravityChecklist.completion")}),e.jsx("span",{children:i("antigravityChecklist.stepsCount",{current:d})})]}),e.jsx(os,{value:m,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(Le,{id:"agy-step-reviewed-issue",checked:s.reviewedIssue509,onCheckedChange:l=>c({reviewedIssue509:!!l}),disabled:n}),e.jsx(z,{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(Le,{id:"agy-step-understands-risk",checked:s.understandsBanRisk,onCheckedChange:l=>c({understandsBanRisk:!!l}),disabled:n}),e.jsx(z,{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(Le,{id:"agy-step-accept-responsibility",checked:s.acceptsFullResponsibility,onCheckedChange:l=>c({acceptsFullResponsibility:!!l}),disabled:n}),e.jsx(z,{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(qt,{className:"h-3.5 w-3.5"}),"Step 4: Type exact phrase to continue"]}),e.jsx(re,{value:s.typedPhrase,onChange:l=>c({typedPhrase:l.target.value}),placeholder:Ct,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(he,{className:"h-3.5 w-3.5"})]})})]})]})}function wa(t){return t.trim().replace(/\s+/g," ").toUpperCase()}function Ca({open:t,onClose:s,provider:a,displayName:n,isFirstAccount:i=!1}){const[d,m]=o.useState(""),[c,l]=o.useState(""),[p,f]=o.useState(!1),[h,g]=o.useState(null),[_,v]=o.useState(""),[T,k]=o.useState(He),[y,M]=o.useState(!1),[r,b]=o.useState(!1),[j,A]=o.useState(ft),[I,D]=o.useState(""),[P,U]=o.useState(""),[C,w]=o.useState(vt),{t:u}=ae(),F=o.useRef(!1),V=o.useRef(0),R=o.useRef(!1),N=ba(),K=ls(),q=a==="kiro",Q=a==="agy"||a==="gemini",Y=a==="gemini"&&!y,J=a==="agy"&&!y,ne=Q&&r,x=ea(T),E=wa(_)===Oe,W=Lt(a),xe=cs(j),de=q&&j==="idc",ue=q&&us(j),Ae=q?ds(j,C):void 0,Fe=q?ps(j):void 0,Se=q?Ae==="device_code":W,Z=N.isAuthenticating||K.isPending,Ue=d.trim(),fe=I.trim(),Pe=P.trim(),Me=h||N.error,De=o.useCallback(async()=>{const S=await fetch("/api/settings/auth/antigravity-risk");if(!S.ok)throw new Error("Failed to load power user mode setting");return(await S.json()).antigravityAckBypass===!0},[]),me=o.useCallback(async({pendingMessage:S=null,disabledMessage:ie=null}={})=>{const qe=++V.current;b(!0),S!==null&&g(S);try{const Ie=await De();return V.current!==qe||(M(Ie),ie?g(Ie?null:ie):S!==null&&g(null)),Ie}catch{return V.current!==qe||(M(!1),g(ie??u("addAccountDialog.powerUserLoadFailed")),R.current||(R.current=!0,H.error(u("addAccountDialog.powerUserLoadFailed")))),!1}finally{V.current===qe&&b(!1)}},[De,u]),ve=()=>{m(""),l(""),f(!1),g(null),v(""),k(He),M(!1),b(!1),A(ft),D(""),U(""),w(vt),V.current+=1,R.current=!1,F.current=!1,s()};o.useEffect(()=>{t&&(v(""),k(He),g(null))},[a,t]),o.useEffect(()=>()=>{V.current+=1},[]),o.useEffect(()=>{if(!t||!Q){V.current+=1,M(!1),b(!1);return}me()},[t,a,Q,me]),o.useEffect(()=>{if(!t||a!=="agy"||!N.error||!y)return;const S=N.error.toLowerCase();(S.includes("agy_risk_ack_required")||S.includes("responsibility acknowledgement")||S.includes("responsibility checklist"))&&me({pendingMessage:u("addAccountDialog.powerUserLoading"),disabledMessage:u("addAccountDialog.powerUserUnavailableRetry")})},[N.error,t,y,a,me,u]),o.useEffect(()=>{!N.isAuthenticating&&!N.error&&N.provider===null&&t&&F.current&&(F.current=!1,(async()=>{try{const ie=await tt(a);ie.success&&ie.presetName&&i&&H.success(`Applied "${ie.presetName}" preset`)}catch{}ve()})())},[N.isAuthenticating,N.error,N.provider]);const Te=()=>{N.cancelAuth(),ve()},Ke=async()=>{N.authUrl&&(await navigator.clipboard.writeText(N.authUrl),f(!0),setTimeout(()=>f(!1),2e3))},O=()=>{c.trim()&&N.submitCallback(c.trim())},B=()=>{if(ne){g(u("addAccountDialog.powerUserLoading"));return}if(J&&!x){g("Complete all Antigravity responsibility steps before authenticating this provider.");return}if(Y&&!E){g(`Type "${Oe}" to acknowledge the account safety warning before authenticating this provider.`);return}if(g(null),de&&!fe){g("IDC Start URL is required for Kiro IAM Identity Center login.");return}F.current=!0,N.startAuth(a,{nickname:Ue||void 0,kiroMethod:q?j:void 0,kiroIDCStartUrl:de?fe:void 0,kiroIDCRegion:de&&Pe?Pe:void 0,kiroIDCFlow:de?C:void 0,flowType:q?Ae:void 0,startEndpoint:q?Fe:void 0,riskAcknowledgement:J?{version:ta,reviewedIssue509:T.reviewedIssue509,understandsBanRisk:T.understandsBanRisk,acceptsFullResponsibility:T.acceptsFullResponsibility,typedPhrase:T.typedPhrase}:void 0})},ee=()=>{F.current=!0,K.mutate(void 0,{onSuccess:async()=>{const S=await tt("kiro");S.success&&S.presetName&&i&&H.success(`Applied "${S.presetName}" preset`),ve()}})},je=S=>{S||Te()},te=N.isAuthenticating;return e.jsx(nt,{open:t,onOpenChange:je,children:e.jsxs(it,{className:"sm:max-w-md",onInteractOutside:S=>{te&&S.preventDefault()},children:[e.jsxs(rt,{children:[e.jsx(ot,{children:u("addAccountDialog.title",{displayName:n})}),e.jsx(Rt,{children:u(q?"addAccountDialog.descKiro":Se?"addAccountDialog.descDeviceCode":"addAccountDialog.descOauth")})]}),e.jsxs("div",{className:"space-y-4 py-4",children:[J&&!te&&e.jsx(ya,{value:T,onChange:S=>{k(S),g(null)},disabled:Z}),Q&&y&&!te&&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(qt,{className:"h-3.5 w-3.5"}),u("addAccountDialog.powerUserEnabled")]}),u("addAccountDialog.powerUserSkipped")]}),Y&&!te&&e.jsx(Zt,{showAcknowledgement:!0,acknowledgementPhrase:Oe,acknowledgementText:_,onAcknowledgementTextChange:S=>{v(S),g(null)},disabled:Z}),q&&!te&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(z,{htmlFor:"kiro-auth-method",children:u("addAccountDialog.authMethod")}),e.jsxs(Be,{value:j,onValueChange:S=>{A(S),g(null)},children:[e.jsx(ze,{id:"kiro-auth-method",children:e.jsx($e,{placeholder:u("addAccountDialog.selectKiroAuthMethod")})}),e.jsx(Qe,{children:ms.map(S=>e.jsx(be,{value:S.id,children:S.label},S.id))})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:xe.description}),ue&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:["If your browser does not return automatically after login, CCS can accept the final",e.jsx("span",{className:"mx-1 rounded bg-muted px-1.5 py-0.5 font-mono text-[11px]",children:"kiro://..."}),"callback URL in the next step."]})]}),de&&!te&&e.jsxs("div",{className:"space-y-4 rounded-lg border border-border/60 bg-muted/20 p-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(z,{htmlFor:"kiro-idc-start-url",children:"IDC Start URL"}),e.jsx(re,{id:"kiro-idc-start-url",value:I,onChange:S=>{D(S.target.value),g(null)},placeholder:"https://d-xxx.awsapps.com/start",disabled:Z}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Required for organization IAM Identity Center login."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(z,{htmlFor:"kiro-idc-region",children:"IDC Region"}),e.jsx(re,{id:"kiro-idc-region",value:P,onChange:S=>{U(S.target.value),g(null)},placeholder:"us-east-1",disabled:Z}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Optional. Leave blank to use the upstream default region."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(z,{htmlFor:"kiro-idc-flow",children:"IDC Flow"}),e.jsxs(Be,{value:C,onValueChange:S=>{w(S),g(null)},children:[e.jsx(ze,{id:"kiro-idc-flow",children:e.jsx($e,{placeholder:"Select IDC flow"})}),e.jsxs(Qe,{children:[e.jsx(be,{value:"authcode",children:"Authorization Code"}),e.jsx(be,{value:"device",children:"Device Code"})]})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Auth Code opens a browser and may need the final callback URL pasted back. Device Code shows a verification code instead."})]})]}),!te&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(z,{htmlFor:"nickname",children:u("addAccountDialog.nicknameOptional")}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ye,{className:"w-4 h-4 text-muted-foreground"}),e.jsx(re,{id:"nickname",value:d,onChange:S=>{m(S.target.value),g(null)},placeholder:u("addAccountDialog.nicknamePlaceholder"),disabled:Z,className:"flex-1"})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:u("addAccountDialog.nicknameOptionalHint")})]}),te&&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(X,{className:"w-4 h-4 inline mr-2 animate-spin"}),u("addAccountDialog.waitingForAuth")]}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:N.isDeviceCodeFlow?u("addAccountDialog.deviceCodeHint"):ue?"Complete sign-in in your browser. If it does not return automatically, paste the final kiro:// callback URL below.":u("addAccountDialog.browserHint")})]}),N.authUrl&&!N.isDeviceCodeFlow&&e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(z,{className:"text-xs",children:u("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:N.authUrl}),e.jsxs("div",{className:"flex gap-2 mt-2",children:[e.jsx(L,{variant:"outline",size:"sm",onClick:Ke,children:p?e.jsxs(e.Fragment,{children:[e.jsx(pe,{className:"w-3 h-3 mr-1"}),u("addAccountDialog.copied")]}):e.jsxs(e.Fragment,{children:[e.jsx(Kt,{className:"w-3 h-3 mr-1"}),u("addAccountDialog.copy")]})}),e.jsxs(L,{variant:"outline",size:"sm",onClick:()=>{if(!N.authUrl)return;const S=window.open(N.authUrl,"_blank");(!S||S.closed||typeof S.closed>"u")&&H.warning(u("addAccountDialog.popupBlocked"),{duration:5e3})},children:[e.jsx(he,{className:"w-3 h-3 mr-1"}),u("addAccountDialog.open")]})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(z,{htmlFor:"callback-url",className:"text-xs",children:ue?"Browser did not return? Paste the final kiro:// callback URL:":u("addAccountDialog.redirectPasteLabel")}),e.jsx(re,{id:"callback-url",value:c,onChange:S=>l(S.target.value),placeholder:ue?"kiro://kiro.kiroAgent/authenticate-success?code=...&state=...":u("addAccountDialog.callbackPlaceholder"),className:"font-mono text-xs"}),e.jsx(L,{variant:"secondary",size:"sm",onClick:O,disabled:!c.trim()||N.isSubmittingCallback,children:N.isSubmittingCallback?e.jsxs(e.Fragment,{children:[e.jsx(X,{className:"w-3 h-3 mr-1 animate-spin"}),u("addAccountDialog.submitting")]}):u("addAccountDialog.submitCallback")})]})]}),!N.authUrl&&!N.isDeviceCodeFlow&&e.jsx("p",{className:"text-xs text-center text-muted-foreground",children:ue?"Preparing the Kiro sign-in URL. If it does not open automatically, it will appear here shortly.":u("addAccountDialog.preparingUrl")})]}),Me&&e.jsx("p",{className:"text-xs text-center text-destructive",children:Me}),K.isPending&&e.jsxs("p",{className:"text-sm text-center text-muted-foreground",children:[e.jsx(X,{className:"w-4 h-4 inline mr-2 animate-spin"}),u("addAccountDialog.importingToken")]}),e.jsxs("div",{className:"flex items-center justify-end gap-2 pt-2",children:[e.jsx(L,{variant:"ghost",onClick:Te,children:u("addAccountDialog.cancel")}),q&&!te&&e.jsx(L,{variant:"outline",onClick:ee,disabled:Z,children:K.isPending?e.jsxs(e.Fragment,{children:[e.jsx(X,{className:"w-4 h-4 mr-2 animate-spin"}),u("addAccountDialog.importing")]}):e.jsxs(e.Fragment,{children:[e.jsx($s,{className:"w-4 h-4 mr-2"}),u("addAccountDialog.importFromIde")]})}),!te&&e.jsxs(L,{onClick:B,disabled:Z||ne||J&&!x||Y&&!E,children:[e.jsx(he,{className:"w-4 h-4 mr-2"}),u("addAccountDialog.authenticate")]})]})]})]})})}const ka=["ANTHROPIC_BASE_URL","ANTHROPIC_AUTH_TOKEN"];function Aa(t){const s=t?.env||{};return ka.filter(a=>!s[a]?.trim())}function Sa(t){const[s,a]=o.useState(null),[n,i]=o.useState(!1),d=st(),{data:m,isLoading:c,refetch:l}=Pt({queryKey:["settings",t],queryFn:async()=>{const C=await fetch(`/api/settings/${t}/raw`);return C.ok?C.json():{profile:t,settings:{env:{}},mtime:Date.now(),path:`~/.ccs/profiles/${t}/settings.json`}}}),p=m?.settings,f=o.useMemo(()=>s!==null?s:p?JSON.stringify(p,null,2):`{
2
+ "env": {}
3
+ }`,[s,p]),h=o.useCallback(C=>{a(C)},[]),g=o.useMemo(()=>{try{return JSON.parse(f)}catch{return p||{env:{}}}},[f,p]),_=g?.env?.ANTHROPIC_MODEL,v=g?.env?.ANTHROPIC_DEFAULT_OPUS_MODEL,T=g?.env?.ANTHROPIC_DEFAULT_SONNET_MODEL,k=g?.env?.ANTHROPIC_DEFAULT_HAIKU_MODEL,y=o.useMemo(()=>xs(g?.env||{}),[g]),M=o.useCallback((C,w)=>hs(C,w,{supportsExtendedContext:u=>ca(t,u)}),[t]),r=o.useCallback((C,w)=>{const u={...g?.env||{},[C]:w},F=jt(C)?M(u,y):u;delete F.CCS_EXTENDED_CONTEXT;const V={...g,env:F};a(JSON.stringify(V,null,2))},[M,g,y]),b=o.useCallback(C=>{const w=g?.env||{},u=M(w,C);delete u.CCS_EXTENDED_CONTEXT;const F={...g,env:u};a(JSON.stringify(F,null,2))},[M,g]),j=o.useCallback(C=>{const w={...g?.env||{},...C},F=Object.keys(C).some(jt)?M(w,y):w;delete F.CCS_EXTENDED_CONTEXT;const V={...g,env:F};a(JSON.stringify(V,null,2))},[M,g,y]),A=o.useMemo(()=>{try{return JSON.parse(f),!0}catch{return!1}},[f]),I=o.useMemo(()=>s===null?!1:s!==JSON.stringify(p,null,2),[s,p]),D=o.useMemo(()=>Aa(g),[g]),P=es({mutationFn:async()=>{const C=JSON.parse(f),w=await fetch(`/api/settings/${t}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({settings:C,expectedMtime:m?.mtime})});if(w.status===409)throw new Error("CONFLICT");if(!w.ok)throw new Error("Failed to save");return w.json()},onSuccess:C=>{d.invalidateQueries({queryKey:["settings",t]}),a(null),C?.warning?H.success("Settings saved",{description:C.warning}):H.success("Settings saved")},onError:C=>{C.message==="CONFLICT"?i(!0):H.error(C.message)}}),U=async C=>{i(!1),C?(await l(),P.mutate()):a(null)};return{data:m,isLoading:c,refetch:l,rawJsonContent:f,rawJsonEdits:s,isRawJsonValid:A,hasChanges:I,currentSettings:g,currentModel:_,opusModel:v,sonnetModel:T,haikuModel:k,extendedContextEnabled:y,toggleExtendedContext:b,handleRawJsonChange:h,updateEnvValue:r,updateEnvValues:j,saveMutation:{mutate:()=>P.mutate(),isPending:P.isPending},conflictDialog:n,setConflictDialog:i,handleConflictResolve:U,missingRequiredFields:D}}const Pa=/-(medium|high|xhigh)$/i;function Ma(t){if(!t)return;const s=t.trim().match(Pa);if(s?.[1])return s[1].toLowerCase()}function Da(t){if(!t)return null;const s=Ma(t);return s?{label:`Pinned ${s}`,explicit:!0}:{label:"Auto effort",explicit:!1}}function Ta({label:t}){return e.jsx(G,{variant:"outline",className:"text-[9px] h-4 px-1",children:t})}function Ee({modelId:t}){const s=Da(t);return s?e.jsx(G,{variant:s.explicit?"secondary":"outline",className:"text-[9px] h-4 px-1 uppercase",children:s.label}):null}function ce({label:t,description:s,value:a,onChange:n,catalog:i,allModels:d,disabled:m}){const{t:c}=ae(),l=i?.provider==="codex",p=o.useMemo(()=>Yt(i,d),[d,i]),f=new Set(p.map(v=>v.id)),h=p.map(v=>({value:v.id,groupKey:"recommended",searchText:`${v.id} ${v.name}`,keywords:[v.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:v.id}),l&&e.jsx(Ee,{modelId:v.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:v.id}),v.tier==="paid"&&e.jsx(Ta,{label:c("providerModelSelector.paid")}),l&&e.jsx(Ee,{modelId:v.id})]})})),g=d.filter(v=>!f.has(v.id)).map(v=>({value:v.id,groupKey:"all",searchText:v.id,keywords:[v.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:v.id}),l&&e.jsx(Ee,{modelId:v.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:v.id}),l&&e.jsx(Ee,{modelId:v.id})]})})),_=h.length+g.length>0;return e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-medium",children:t}),s&&e.jsx("p",{className:"text-[10px] text-muted-foreground",children:s})]}),e.jsx(aa,{value:a||void 0,onChange:n,disabled:m,placeholder:c("providerModelSelector.selectModel"),searchPlaceholder:c("searchableSelect.searchModels"),emptyText:c(_?"searchableSelect.noResults":"providerModelSelector.noModelsAvailable"),triggerClassName:"h-9",groups:[{key:"recommended",label:e.jsx("span",{className:"text-xs text-primary",children:c("providerModelSelector.recommended")})},{key:"all",label:e.jsx("span",{className:"text-xs text-muted-foreground",children:c("providerModelSelector.allModelsCount",{count:d.length})})}],options:[...h,...g]})]})}function Ia({open:t,onClose:s,currentValues:a,onApply:n,onSave:i,isSaving:d,catalog:m,allModels:c}){const{t:l}=ae(),[p,f]=o.useState(a),[h,g]=o.useState(""),_=v=>{v?(f(a),g("")):s()};return e.jsx(nt,{open:t,onOpenChange:_,children:e.jsxs(it,{className:"sm:max-w-md",children:[e.jsx(rt,{children:e.jsxs(ot,{className:"flex items-center gap-2",children:[e.jsx(Ce,{className:"w-4 h-4"}),l("customPresetDialog.title")]})}),e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(z,{htmlFor:"preset-name",children:l("customPresetDialog.presetNameOptional")}),e.jsx(re,{id:"preset-name",value:h,onChange:v=>g(v.target.value),placeholder:l("customPresetDialog.presetNamePlaceholder"),className:"text-sm"})]}),e.jsx(ht,{}),m?.provider==="codex"&&e.jsxs("p",{className:"text-[11px] text-muted-foreground rounded-md border bg-muted/30 px-2.5 py-2",children:[l("customPresetDialog.codexTipPrefix")," ",e.jsx("code",{children:"-medium"}),", ",e.jsx("code",{children:"-high"}),", and"," ",e.jsx("code",{children:"-xhigh"})," ",l("customPresetDialog.codexTipSuffix")]}),e.jsx(ce,{label:l("customPresetDialog.defaultModel"),description:l("customPresetDialog.defaultModelDesc"),value:p.default,onChange:v=>f({...p,default:v}),catalog:m,allModels:c}),e.jsx(ce,{label:l("customPresetDialog.opusModel"),description:l("customPresetDialog.opusModelDesc"),value:p.opus,onChange:v=>f({...p,opus:v}),catalog:m,allModels:c}),e.jsx(ce,{label:l("customPresetDialog.sonnetModel"),description:l("customPresetDialog.sonnetModelDesc"),value:p.sonnet,onChange:v=>f({...p,sonnet:v}),catalog:m,allModels:c}),e.jsx(ce,{label:l("customPresetDialog.haikuModel"),description:l("customPresetDialog.haikuModelDesc"),value:p.haiku,onChange:v=>f({...p,haiku:v}),catalog:m,allModels:c})]}),e.jsxs(gs,{className:"gap-2 sm:gap-0",children:[e.jsx(L,{variant:"outline",onClick:s,children:l("customPresetDialog.cancel")}),i&&e.jsxs(L,{variant:"secondary",onClick:()=>i(p,h||void 0),disabled:d||!h.trim(),children:[d?e.jsx(X,{className:"w-4 h-4 mr-1 animate-spin"}):e.jsx(pt,{className:"w-4 h-4 mr-1"}),l("customPresetDialog.savePreset")]}),e.jsxs(L,{onClick:()=>n(p,h||void 0),children:[e.jsx(ke,{className:"w-4 h-4 mr-1"}),l("customPresetDialog.applyPreset")]})]})]})})}function le({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(_t,{value:s,size:"icon",className:"h-6 w-6"})]})]})}function Ea({provider:t,displayName:s,defaultTarget:a,data:n,authStatus:i,supportsModelConfig:d=!1}){const m=a||"claude",c=m==="droid",l=t==="codex",p=m==="claude"?`ccs ${t}`:`ccs ${t} --target claude`,f=`${p} --config`,h=`${p} --auth --add`,g=`${p} --accounts`;return e.jsx(lt,{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(Ht,{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:s})]}),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(_t,{value:n.path,size:"icon",className:"h-5 w-5"})]})]}),e.jsxs("div",{className:"grid grid-cols-[100px_1fr] gap-2 text-sm items-center",children:[e.jsx("span",{className:"font-medium text-muted-foreground",children:"Last Modified"}),e.jsx("span",{className:"text-xs",children:new Date(n.mtime).toLocaleString()})]})]}),e.jsxs("div",{className:"grid grid-cols-[100px_1fr] gap-2 text-sm items-center",children:[e.jsx("span",{className:"font-medium text-muted-foreground",children:"Status"}),i.authenticated?e.jsxs(G,{variant:"outline",className:"w-fit text-green-600 border-green-200 bg-green-50",children:[e.jsx(Qs,{className:"w-3 h-3 mr-1"}),"Authenticated"]}):e.jsx(G,{variant:"outline",className:"w-fit text-muted-foreground",children:"Not connected"})]}),e.jsxs("div",{className:"grid grid-cols-[100px_1fr] gap-2 text-sm items-center",children:[e.jsx("span",{className:"font-medium text-muted-foreground",children:"Default Target"}),e.jsx("span",{className:"font-mono",children: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(le,{label:"Run with prompt",command:`ccs ${t} "your prompt"`}),l&&e.jsxs(e.Fragment,{children:[e.jsx(le,{label:"Run on native Codex (shortcut)",command:'ccsxp "your prompt"'}),e.jsx(le,{label:"Run on native Codex (--target)",command:`ccs ${t} --target codex "your prompt"`})]}),e.jsx(le,{label:c?"Droid alias (explicit)":"Run on Droid",command:`ccs-droid ${t} "your prompt"`}),e.jsx(le,{label:c?"Override to Claude":"Run on Droid (--target)",command:`ccs ${t} --target ${c?"claude":"droid"} "your prompt"`}),d&&e.jsx(le,{label:m==="claude"?"Change model":"Change model (Claude target)",command:f}),e.jsx(le,{label:m==="claude"?"Add account":"Add account (Claude target)",command:h}),e.jsx(le,{label:m==="claude"?"List accounts":"List accounts (Claude target)",command:g}),m!=="claude"&&e.jsx("p",{className:"text-xs text-muted-foreground",children:"Account and model-management flags stay on Claude target. Codex and Droid runtime launches reject those CLIProxy management commands."})]})]})]})})}function Ra({displayName:t,logoProvider:s,provider:a,data:n,isLoading:i,hasChanges:d,isRawJsonValid:m,isSaving:c,isRemoteMode:l,port:p,onRefetch:f,onSave:h}){return e.jsxs("div",{className:"px-6 py-4 border-b bg-background flex items-center justify-between shrink-0",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(ct,{provider:s||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:t}),l&&e.jsxs(G,{variant:"secondary",className:"text-xs gap-1 bg-blue-100 text-blue-700 dark:bg-blue-900/30 dark:text-blue-400",children:[e.jsx(Vt,{className:"w-3 h-3"}),"Remote"]}),p&&e.jsxs(G,{variant:"outline",className:"text-xs gap-1 font-mono",children:[e.jsx(Js,{className:"w-3 h-3"}),":",p]}),!l&&n?.path&&e.jsx(G,{variant:"outline",className:"text-xs",children:n.path.replace(/^.*[\\/]/,"")})]}),l?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(L,{variant:"ghost",size:"sm",onClick:f,disabled:i,children:e.jsx(ut,{className:`w-4 h-4 ${i?"animate-spin":""}`})}),e.jsx(L,{size:"sm",onClick:h,disabled:c||!d||!m,children:c?e.jsxs(e.Fragment,{children:[e.jsx(X,{className:"w-4 h-4 mr-1 animate-spin"}),"Saving..."]}):e.jsxs(e.Fragment,{children:[e.jsx(Ws,{className:"w-4 h-4 mr-1"}),"Save"]})})]})]})}function Oa({models:t,provider:s,enabled:a,onToggle:n,disabled:i,className:d}){if(t.length===0)return null;const m=t.some(p=>Nt(p.id)),c=t.some(p=>!Nt(p.id));let l="Compatible mappings stay on standard context unless you turn this on.";return m&&c?l="Gemini-compatible mappings can use 1M automatically. Claude mappings stay plain unless you turn this on.":m&&(l="Gemini-compatible mappings can use 1M by default. Turn this off to keep standard context."),e.jsxs("div",{className:$("rounded-lg border p-3 space-y-2",a?"border-primary/50 bg-primary/5":"border-border bg-muted/30",d),children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ke,{className:$("w-4 h-4",a?"text-primary":"text-muted-foreground")}),e.jsx("span",{className:"text-sm font-medium",children:"Extended Context"}),e.jsx(G,{variant:a?"default":"secondary",className:"text-[10px] h-5 px-1.5",children:"1M tokens"})]}),e.jsx(Ft,{checked:a,onCheckedChange:n,disabled:i})]}),e.jsxs("div",{className:"flex items-start gap-2 text-xs text-muted-foreground",children:[e.jsx(Ht,{className:"w-3.5 h-3.5 mt-0.5 shrink-0"}),e.jsxs("div",{className:"space-y-1",children:[e.jsxs("p",{children:["Applies the explicit ",e.jsx("code",{children:"[1m]"})," long-context suffix to compatible saved mappings."]}),e.jsx("p",{className:"text-[10px]",children:l}),e.jsxs("p",{className:"text-amber-600 dark:text-amber-500",children:["CCS only saves ",e.jsx("code",{children:"[1m]"}),". Provider pricing and entitlement are separate, and some accounts can still return 429 extra-usage errors for long-context requests."]})]})]})]})}function La(t){const s=t.presetMapping||{default:t.id,opus:t.id,sonnet:t.id,haiku:t.id};return{ANTHROPIC_MODEL:s.default,ANTHROPIC_DEFAULT_OPUS_MODEL:s.opus,ANTHROPIC_DEFAULT_SONNET_MODEL:s.sonnet,ANTHROPIC_DEFAULT_HAIKU_MODEL:s.haiku}}function _a({catalog:t,savedPresets:s,currentModel:a,opusModel:n,sonnetModel:i,haikuModel:d,providerModels:m,provider:c,extendedContextEnabled:l,onExtendedContextToggle:p,onApplyPreset:f,onUpdateEnvValue:h,onOpenCustomPreset:g,onDeletePreset:_,isDeletePending:v}){const T=o.useMemo(()=>{if(!t)return[];const r=[a,n,i,d].filter(j=>!!j).map(j=>fs(j));return[...new Set(r)].map(j=>Xt(t.provider,j)).filter(j=>!!j?.extendedContext)},[t,a,n,i,d]),k=o.useMemo(()=>Yt(t,m),[t,m]),y=o.useMemo(()=>{const r=k.filter(j=>j.presetMapping);return r.length===0?[]:r.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:r.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:r.filter(j=>j.tier==="paid")}].filter(j=>j.models.length>0):[{key:"default",models:r.slice(0,4)}]},[k]),M=y.length>0||s.length>0;return e.jsxs(e.Fragment,{children:[M&&e.jsxs("div",{children:[e.jsxs("h3",{className:"text-sm font-medium mb-2 flex items-center gap-2",children:[e.jsx(Ce,{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(r=>e.jsxs("div",{children:["label"in r&&r.label&&e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(G,{variant:"outline",className:r.badgeClassName,children:r.label}),e.jsx("span",{className:"text-[10px] text-muted-foreground",children:r.description})]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:r.models.map(b=>e.jsxs(L,{variant:"outline",size:"sm",className:"text-xs h-7 gap-1",onClick:()=>f(La(b)),children:[e.jsx(ke,{className:`w-3 h-3 ${"iconClassName"in r?r.iconClassName:""}`}),b.name]},b.id))})]},r.key)),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[s.map(r=>e.jsxs("div",{className:"group relative",children:[e.jsxs(L,{variant:"secondary",size:"sm",className:"text-xs h-7 gap-1 pr-6",onClick:()=>{f({ANTHROPIC_MODEL:r.default,ANTHROPIC_DEFAULT_OPUS_MODEL:r.opus,ANTHROPIC_DEFAULT_SONNET_MODEL:r.sonnet,ANTHROPIC_DEFAULT_HAIKU_MODEL:r.haiku})},children:[e.jsx(pt,{className:"w-3 h-3 fill-current"}),r.name]}),e.jsx(L,{variant:"ghost",size:"icon",className:"absolute right-0 top-0 h-7 w-5 opacity-0 group-hover:opacity-100 hover:text-destructive",onClick:b=>{b.stopPropagation(),_(r.name)},disabled:v,children:e.jsx(xt,{className:"w-3 h-3"})})]},r.name)),e.jsxs(L,{variant:"outline",size:"sm",className:"text-xs h-7 gap-1 border-primary/50 text-primary hover:bg-primary/10 hover:border-primary",onClick:g,children:[e.jsx(Gt,{className:"w-3 h-3"}),"Custom"]})]})]})]}),e.jsx(ht,{}),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"}),c==="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(ce,{label:"Default Model",description:"Used when no specific tier is requested",value:a,onChange:r=>h("ANTHROPIC_MODEL",r),catalog:t,allModels:m}),T.length>0&&p&&e.jsx(Oa,{models:T,provider:c,enabled:l??!1,onToggle:p}),e.jsx(ce,{label:"Opus (Most capable)",description:"For complex reasoning tasks",value:n,onChange:r=>h("ANTHROPIC_DEFAULT_OPUS_MODEL",r),catalog:t,allModels:m}),e.jsx(ce,{label:"Sonnet (Balanced)",description:"Balance of speed and capability",value:i,onChange:r=>h("ANTHROPIC_DEFAULT_SONNET_MODEL",r),catalog:t,allModels:m}),e.jsx(ce,{label:"Haiku (Fast)",description:"Quick responses for simple tasks",value:d,onChange:r=>h("ANTHROPIC_DEFAULT_HAIKU_MODEL",r),catalog:t,allModels:m})]})]})]})}function Fa(t,s){return t?e.jsx(We,{children:e.jsxs(Xe,{children:[e.jsx(Ye,{asChild:!0,children:e.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[e.jsx(Ys,{className:"w-3 h-3","aria-hidden":"true"}),e.jsx("span",{className:$("font-mono max-w-[180px] truncate",s&&at),title:t,children:t})]})}),e.jsx(Ze,{side:"bottom",children:e.jsx("p",{className:"text-xs",children:"GCP Project ID (read-only)"})})]})}):e.jsx(We,{children:e.jsxs(Xe,{children:[e.jsx(Ye,{asChild:!0,children:e.jsxs("div",{className:"flex items-center gap-1 text-xs text-amber-600 dark:text-amber-500",children:[e.jsx(mt,{className:"w-3 h-3","aria-label":"Warning"}),e.jsx("span",{children:"Project ID: N/A"})]})}),e.jsx(Ze,{side:"bottom",className:"max-w-[250px]",children:e.jsxs("div",{className:"text-xs space-y-1",children:[e.jsx("p",{className:"font-medium text-amber-600",children:"Missing Project ID"}),e.jsx("p",{children:"This may cause errors. Remove the account and re-add it to fetch the project ID."})]})})]})})}function Ua({account:t,onSetDefault:s,onRemove:a,onPauseToggle:n,isRemoving:i,isPausingAccount:d,privacyMode:m,showQuota:c,selectable:l,selected:p,onSelectChange:f}){const h=t.provider.toLowerCase(),{data:g}=vs(c),{data:_,isLoading:v}=js(h,t.id,c),T=Ns(g,t)?.lastUsedAt,k=l||n?e.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[l&&e.jsx("button",{type:"button",onClick:()=>f?.(!p),className:$("flex items-center justify-center w-5 h-5 rounded border-2 transition-colors shrink-0",p?"bg-primary border-primary text-primary-foreground":"border-muted-foreground/30 hover:border-primary/50"),"aria-label":p?"Deselect account":"Select account",children:p&&e.jsx(pe,{className:"w-3 h-3"})}),n&&e.jsx(We,{children:e.jsxs(Xe,{children:[e.jsx(Ye,{asChild:!0,children:e.jsx(L,{variant:"ghost",size:"icon",className:"h-7 w-7 shrink-0",onClick:()=>n(!t.paused),disabled:d,children:d?e.jsx(X,{className:"w-4 h-4 animate-spin"}):t.paused?e.jsx(Bt,{className:"w-4 h-4 text-emerald-500"}):e.jsx(zt,{className:"w-4 h-4 text-muted-foreground hover:text-foreground"})})}),e.jsx(Ze,{side:"top",children:t.paused?"Resume account":"Pause account"})]})})]}):void 0,y=e.jsxs(bs,{children:[e.jsx(ys,{asChild:!0,children:e.jsx(L,{variant:"ghost",size:"icon",className:"h-7 w-7 shrink-0",children:e.jsx(Xs,{className:"w-4 h-4"})})}),e.jsxs(ws,{align:"end",children:[!t.isDefault&&e.jsxs(bt,{onClick:s,children:[e.jsx(pt,{className:"w-4 h-4 mr-2"}),"Set as default"]}),e.jsxs(bt,{className:"text-destructive focus:text-destructive",onClick:a,disabled:i,children:[e.jsx($t,{className:"w-4 h-4 mr-2"}),i?"Removing...":"Remove account"]})]})]});return e.jsx("div",{className:$("rounded-lg border p-3 transition-colors overflow-hidden",t.isDefault?"border-primary/30 bg-primary/5":"border-border hover:bg-muted/30",t.paused&&"opacity-75",p&&"ring-2 ring-primary/50 bg-primary/5"),children:e.jsx(Cs,{mode:"detailed",provider:t.provider,accountId:t.id,email:t.email,displayEmail:t.email||t.id,tokenFile:t.tokenFile,tier:t.tier,isDefault:t.isDefault,paused:t.paused,privacyMode:m,showQuota:c,quota:_,quotaLoading:v,runtimeLastUsed:T,beforeIdentity:k,headerEnd:y,bodySlot:t.provider==="agy"?Fa(t.projectId,m):null,quotaInsetClassName:"pl-11"})})}function Ka({selectedCount:t,onPauseSelected:s,onResumeSelected:a,onClearSelection:n,isPausing:i,isResuming:d}){if(t<1)return null;const m=i||d;return e.jsxs("div",{className:"flex items-center gap-3 p-2 bg-muted/50 rounded-lg border mt-2",children:[e.jsxs("span",{className:"text-sm text-muted-foreground",children:[t," selected"]}),e.jsx(L,{variant:"ghost",size:"sm",className:"text-xs h-6 px-2",onClick:n,disabled:m,children:"Clear"}),e.jsxs("div",{className:"flex gap-2 ml-auto",children:[e.jsxs(L,{size:"sm",variant:"outline",className:"h-7 text-xs gap-1",onClick:s,disabled:m,children:[i?e.jsx(X,{className:"w-3 h-3 animate-spin"}):e.jsx(zt,{className:"w-3 h-3"}),"Pause Selected"]}),e.jsxs(L,{size:"sm",variant:"outline",className:"h-7 text-xs gap-1",onClick:a,disabled:m,children:[d?e.jsx(X,{className:"w-3 h-3 animate-spin"}):e.jsx(Bt,{className:"w-3 h-3"}),"Resume Selected"]})]})]})}function qa({accounts:t,onAddAccount:s,onSetDefault:a,onRemoveAccount:n,onPauseToggle:i,onSoloMode:d,onBulkPause:m,onBulkResume:c,isRemovingAccount:l,isPausingAccount:p,isSoloingAccount:f,isBulkPausing:h,isBulkResuming:g,privacyMode:_,showQuota:v,isKiro:T,kiroNoIncognito:k,onKiroNoIncognitoChange:y,kiroSettingsLoading:M}){const[r,b]=o.useState(new Set),j=o.useMemo(()=>new Set(t.map(N=>N.id)),[t]),A=o.useMemo(()=>new Set([...r].filter(N=>j.has(N))),[r,j]),I=!!(m&&c),D=A.size,P=t.length>0&&A.size===t.length,U=A.size>0&&A.size<t.length,C=o.useCallback(N=>{b(K=>{const q=new Set(K);return q.has(N)?q.delete(N):q.add(N),q})},[]),w=o.useCallback(()=>{b(new Set(t.map(N=>N.id)))},[t]),u=o.useCallback(()=>{b(new Set)},[]),F=o.useCallback(()=>{P?u():w()},[P,w,u]),V=o.useCallback(()=>{m&&A.size>0&&(m(Array.from(A)),b(new Set))},[m,A]),R=o.useCallback(()=>{c&&A.size>0&&(c(Array.from(A)),b(new Set))},[c,A]);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:[I&&t.length>0&&e.jsx(Le,{checked:P,onCheckedChange:F,"aria-label":"Select all accounts",className:U?"data-[state=checked]:bg-primary/50":"",...U?{"data-state":"indeterminate"}:{}}),e.jsx(ye,{className:"w-4 h-4"}),"Accounts",t.length>0&&e.jsx(G,{variant:"secondary",className:"text-xs",children:t.length})]}),e.jsxs(L,{variant:"default",size:"sm",className:"h-7 text-xs gap-1",onClick:s,children:[e.jsx(Gt,{className:"w-3 h-3"}),"Add"]})]}),I&&D>0&&e.jsx(Ka,{selectedCount:D,onPauseSelected:V,onResumeSelected:R,onClearSelection:u,isPausing:!!h,isResuming:!!g}),t.length>0?e.jsx("div",{className:"space-y-2",children:t.map(N=>e.jsx(Ua,{account:N,onSetDefault:()=>a(N.id),onRemove:()=>n(N.id),onPauseToggle:i?K=>i(N.id,K):void 0,onSoloMode:d?()=>d(N.id):void 0,isRemoving:l,isPausingAccount:p,isSoloingAccount:f,privacyMode:_,showQuota:v,selectable:I,selected:A.has(N.id),onSelectChange:()=>C(N.id)},N.id))}):e.jsxs("div",{className:"py-6 text-center text-muted-foreground bg-muted/30 rounded-lg border border-dashed",children:[e.jsx(ye,{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"})]}),T&&y&&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(Vt,{className:"w-3.5 h-3.5"}),e.jsx("span",{children:"Use incognito"})]}),e.jsx(Ft,{checked:!k,onCheckedChange:N=>y(!N),disabled:M,className:"scale-90"})]})})]})}function Ha({provider:t,catalog:s,savedPresets:a,currentModel:n,opusModel:i,sonnetModel:d,haikuModel:m,providerModels:c,extendedContextEnabled:l,onExtendedContextToggle:p,onApplyPreset:f,onUpdateEnvValue:h,onOpenCustomPreset:g,onDeletePreset:_,isDeletePending:v,accounts:T,onAddAccount:k,onSetDefault:y,onRemoveAccount:M,onPauseToggle:r,onSoloMode:b,onBulkPause:j,onBulkResume:A,isRemovingAccount:I,isPausingAccount:D,isSoloingAccount:P,isBulkPausing:U,isBulkResuming:C,privacyMode:w,isRemoteMode:u}){const F=t.toLowerCase(),V=(ks.includes(F)||["anthropic","antigravity","gemini-cli","copilot","github-copilot"].includes(F))&&!u,R=t==="kiro",[N,K]=o.useState(!0),[q,Q]=o.useState(!0),[Y,J]=o.useState(!1),ne=o.useCallback(async()=>{if(R)try{Q(!0);const W=(await Re.config.get()).cliproxy;K(W?.kiro_no_incognito??!0)}catch{K(!0)}finally{Q(!1)}},[R]),x=o.useCallback(async E=>{K(E),J(!0);try{const W=await Re.config.get(),xe=W.cliproxy??{};await Re.config.update({...W,cliproxy:{...xe,kiro_no_incognito:E}})}catch{K(!E)}finally{J(!1)}},[]);return o.useEffect(()=>{ne()},[ne]),e.jsx(lt,{className:"flex-1",children:e.jsxs("div",{className:"p-4 space-y-6",children:[e.jsx(_a,{catalog:s,savedPresets:a,currentModel:n,opusModel:i,sonnetModel:d,haikuModel:m,providerModels:c,provider:t,extendedContextEnabled:l,onExtendedContextToggle:p,onApplyPreset:f,onUpdateEnvValue:h,onOpenCustomPreset:g,onDeletePreset:_,isDeletePending:v}),e.jsx(ht,{}),e.jsx(qa,{accounts:T,onAddAccount:k,onSetDefault:y,onRemoveAccount:M,onPauseToggle:r,onSoloMode:b,onBulkPause:j,onBulkResume:A,isRemovingAccount:I,isPausingAccount:D,isSoloingAccount:P,isBulkPausing:U,isBulkResuming:C,privacyMode:w,showQuota:V,isKiro:R,kiroNoIncognito:N,onKiroNoIncognitoChange:x,kiroSettingsLoading:q||Y})]})})}function St({provider:t,displayName:s,authStatus:a,catalog:n,logoProvider:i,baseProvider:d,isRemoteMode:m,port:c,defaultTarget:l,onAddAccount:p,onSetDefault:f,onRemoveAccount:h,onPauseToggle:g,onSoloMode:_,onBulkPause:v,onBulkResume:T,isRemovingAccount:k,isPausingAccount:y,isSoloingAccount:M,isBulkPausing:r,isBulkResuming:b}){const[j,A]=o.useState(!1),{privacyMode:I}=Et(),{data:D}=As(),{data:P}=Ss(t),U=Ps(),C=Ms(),w=d||t,u=w.toLowerCase()==="agy",F=o.useMemo(()=>{const O=P?.presets||[];return u?O.filter(B=>!se(B.default)&&!se(B.opus)&&!se(B.sonnet)&&!se(B.haiku)):O},[u,P?.presets]),V=o.useMemo(()=>{if(!D?.models)return[];const B={gemini:["google"],agy:["antigravity"],codex:["openai"],qwen:["alibaba","qwen"],iflow:["iflow"],kiro:["kiro","aws"],ghcp:["github","copilot"],kimi:["kimi","moonshot"]}[w.toLowerCase()]||[w.toLowerCase()];return D.models.filter(ee=>B.some(je=>ee.owned_by.toLowerCase().includes(je))?u?!se(ee.id):!0:!1)},[u,D,w]),R=(d||t).toLowerCase(),{data:N,isLoading:K,refetch:q,rawJsonContent:Q,rawJsonEdits:Y,isRawJsonValid:J,hasChanges:ne,currentModel:x,opusModel:E,sonnetModel:W,haikuModel:xe,extendedContextEnabled:de,toggleExtendedContext:ue,handleRawJsonChange:Ae,updateEnvValue:Fe,updateEnvValues:Se,saveMutation:Z,conflictDialog:Ue,handleConflictResolve:fe,missingRequiredFields:Pe}=Sa(t),Me=o.useMemo(()=>(a.accounts||[]).map(O=>({...O,provider:O.provider||d||t})),[a.accounts,d,t]),{data:De}=Pt({queryKey:["auth-tokens-raw"],queryFn:async()=>{const O=await fetch("/api/settings/auth/tokens/raw");return O.ok?O.json():{apiKey:{value:"ccs-internal-managed"}}},staleTime:6e4}),me=De?.apiKey?.value??"ccs-internal-managed",ve=O=>{if(u&&[O.ANTHROPIC_MODEL,O.ANTHROPIC_DEFAULT_OPUS_MODEL,O.ANTHROPIC_DEFAULT_SONNET_MODEL,O.ANTHROPIC_DEFAULT_HAIKU_MODEL].some(ee=>typeof ee=="string"&&se(ee))){H.error("Antigravity denylist: Claude Opus 4.5 and Claude Sonnet 4.5 are deprecated.");return}Se({ANTHROPIC_BASE_URL:`http://127.0.0.1:${c??et}/api/provider/${R}`,ANTHROPIC_AUTH_TOKEN:me,...O}),H.success(`Applied "${O.ANTHROPIC_MODEL?.split("/").pop()||"preset"}" preset`)},Te=(O,B)=>{if(u&&[O.default,O.opus,O.sonnet,O.haiku].some(je=>se(je))){H.error("Antigravity denylist: Claude Opus 4.5 and Claude Sonnet 4.5 are deprecated.");return}Se({ANTHROPIC_BASE_URL:`http://127.0.0.1:${c??et}/api/provider/${R}`,ANTHROPIC_AUTH_TOKEN:me,ANTHROPIC_MODEL:O.default,ANTHROPIC_DEFAULT_OPUS_MODEL:O.opus,ANTHROPIC_DEFAULT_SONNET_MODEL:O.sonnet,ANTHROPIC_DEFAULT_HAIKU_MODEL:O.haiku}),H.success(`Applied ${B?`"${B}"`:"custom"} preset`),A(!1)},Ke=(O,B)=>{if(!B){H.error(Ot.t("commonToast.enterPresetName"));return}if(u&&[O.default,O.opus,O.sonnet,O.haiku].some(ee=>se(ee))){H.error("Antigravity denylist: Claude Opus 4.5 and Claude Sonnet 4.5 are deprecated.");return}U.mutate({profile:t,data:{name:B,...O}}),A(!1)};return e.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden",children:[e.jsx(Ra,{provider:t,displayName:s,logoProvider:i,data:N,isLoading:K,hasChanges:ne,isRawJsonValid:J,isSaving:Z.isPending,isRemoteMode:m,port:c,onRefetch:q,onSave:()=>Z.mutate()}),K?e.jsxs("div",{className:"flex-1 flex items-center justify-center",children:[e.jsx(X,{className:"w-8 h-8 animate-spin text-muted-foreground"}),e.jsx("span",{className:"ml-3 text-muted-foreground",children:"Loading settings..."})]}):e.jsxs("div",{className:"min-h-0 flex-1 grid grid-cols-[40%_60%] divide-x overflow-hidden",children:[e.jsx("div",{className:"flex min-h-0 min-w-0 flex-col overflow-hidden bg-muted/5",children:e.jsxs(Ds,{defaultValue:"config",className:"h-full flex flex-col",children:[e.jsx("div",{className:"px-4 pt-4 shrink-0",children:e.jsxs(Ts,{className:"w-full",children:[e.jsx(yt,{value:"config",className:"flex-1",children:"Model Config"}),e.jsx(yt,{value:"info",className:"flex-1",children:"Info & Usage"})]})}),e.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col",children:[e.jsx(wt,{value:"config",className:"flex-1 mt-0 border-0 p-0 data-[state=inactive]:hidden flex flex-col overflow-hidden",children:e.jsx(Ha,{provider:t,catalog:n,savedPresets:F,currentModel:x,opusModel:E,sonnetModel:W,haikuModel:xe,providerModels:V,extendedContextEnabled:de,onExtendedContextToggle:ue,onApplyPreset:ve,onUpdateEnvValue:Fe,onOpenCustomPreset:()=>A(!0),onDeletePreset:O=>C.mutate({profile:t,name:O}),isDeletePending:C.isPending,accounts:Me,onAddAccount:p,onSetDefault:f,onRemoveAccount:h,onPauseToggle:g,onSoloMode:_,onBulkPause:v,onBulkResume:T,isRemovingAccount:k,isPausingAccount:y,isSoloingAccount:M,isBulkPausing:r,isBulkResuming:b,privacyMode:I,isRemoteMode:m})}),e.jsx(wt,{value:"info",className:"h-full mt-0 border-0 p-0 data-[state=inactive]:hidden",children:e.jsx(Ea,{provider:t,displayName:s,defaultTarget:l,data:N,authStatus:a,supportsModelConfig:!!n})})]})]})}),e.jsxs("div",{className:"flex min-h-0 min-w-0 flex-col overflow-hidden",children:[e.jsxs("div",{className:"px-6 py-2 bg-muted/30 border-b flex items-center gap-2 shrink-0 h-[45px]",children:[e.jsx(Zs,{className:"w-4 h-4 text-muted-foreground"}),e.jsx("span",{className:"text-sm font-medium text-muted-foreground",children:"Raw Configuration (JSON)"})]}),e.jsx(Is,{rawJsonContent:Q,isRawJsonValid:J,rawJsonEdits:Y,onRawJsonChange:Ae,profileEnv:N?.settings?.env,missingRequiredFields:Pe})]})]}),e.jsx(sa,{open:Ue,title:"File Modified Externally",description:"This settings file was modified by another process. Overwrite with your changes or discard?",confirmText:"Overwrite",variant:"destructive",onConfirm:()=>fe(!0),onCancel:()=>fe(!1)}),e.jsx(Ia,{open:j,onClose:()=>A(!1),currentValues:{default:x||"",opus:E||"",sonnet:W||"",haiku:xe||""},onApply:Te,onSave:Ke,isSaving:U.isPending,catalog:n,allModels:V})]})}function Va({status:t,isSelected:s,onSelect:a}){const{t:n}=ae(),i=t.accounts?.length||0;return e.jsxs("button",{className:$("w-full flex items-center gap-3 px-3 py-2.5 rounded-lg transition-colors cursor-pointer text-left",s?"bg-primary/10 border border-primary/20":"hover:bg-muted border border-transparent"),onClick:a,children:[e.jsx(ct,{provider:t.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:t.displayName}),i>0&&e.jsx(G,{variant:"secondary",className:"text-[10px] h-4 px-1",children:i})]}),e.jsx("div",{className:"flex items-center gap-1.5 mt-0.5",children:t.authenticated?e.jsxs(e.Fragment,{children:[e.jsx(pe,{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(xt,{className:"w-3 h-3 text-muted-foreground"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:n("cliproxyPage.notConnected")})]})})]})]})}function Ga({variant:t,parentAuth:s,isSelected:a,onSelect:n,onDelete:i,isDeleting:d}){const{t:m}=ae(),c=()=>{n()};return e.jsxs("div",{role:"button",tabIndex:0,className:$("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:c,onKeyDown:l=>{(l.key==="Enter"||l.key===" ")&&(l.preventDefault(),c())},children:[e.jsxs("div",{className:"relative",children:[e.jsx(ct,{provider:t.provider,size:"sm"}),e.jsx(Qt,{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:t.name}),e.jsx(G,{variant:"outline",className:"text-[9px] h-4 px-1",children:m("cliproxyPage.variant")}),e.jsx(G,{variant:"outline",className:"text-[9px] h-4 px-1 uppercase",children:t.target||"claude"})]}),e.jsx("div",{className:"flex items-center gap-1.5 mt-0.5",children:s?.authenticated?e.jsxs(e.Fragment,{children:[e.jsx(pe,{className:"w-3 h-3 text-green-600"}),e.jsx("span",{className:"text-xs text-muted-foreground truncate",children:m("cliproxyPage.viaProvider",{provider:t.provider})})]}):e.jsxs(e.Fragment,{children:[e.jsx(xt,{className:"w-3 h-3 text-muted-foreground"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:m("cliproxyPage.parentNotConnected")})]})})]}),e.jsx(L,{variant:"ghost",size:"icon",className:"h-6 w-6 opacity-0 group-hover:opacity-100 hover:text-destructive",onClick:l=>{l.stopPropagation(),i()},disabled:d,children:e.jsx($t,{className:"w-3 h-3"})})]})}function Ba({onSetup:t}){const{t:s}=ae();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(ke,{className:"w-8 h-8 text-muted-foreground"})}),e.jsx("h2",{className:"text-xl font-semibold mb-2",children:s("cliproxyPage.emptyTitle")}),e.jsx("p",{className:"text-muted-foreground mb-4",children:s("cliproxyPage.emptyDesc")}),e.jsxs("p",{className:"text-xs text-muted-foreground mb-6",children:[s("cliproxyPage.emptyControlPanelPrefix")," ",e.jsx("a",{href:"/cliproxy/control-panel",className:"text-primary hover:underline",children:s("cliproxyPage.controlPanel")}),"."]}),e.jsxs(L,{onClick:t,className:"gap-2",children:[e.jsx(Ce,{className:"w-4 h-4"}),s("cliproxyPage.quickSetup")]})]})})}function dn(){const{t}=ae(),s=st(),{data:a,isLoading:n}=It(),{data:i,isFetching:d}=Es(),{data:m}=Rs(),c=Os(),l=Ls(),p=_s(),f=Fs(),h=Us(),g=Ks(),_=qs(),v=Hs(),[T,k]=o.useState(()=>{if(typeof window<"u"){const E=new URLSearchParams(window.location.search).get("provider")?.trim().toLowerCase();return E&&Je(E)?E:localStorage.getItem("cliproxy-selected-provider")}return null}),[y,M]=o.useState(null),[r,b]=o.useState(!1),[j,A]=o.useState(()=>{if(typeof window>"u")return null;const x=new URLSearchParams(window.location.search),E=x.get("provider")?.trim().toLowerCase();return x.get("action")!=="auth"||!E||!Je(E)?null:{provider:E,displayName:Vs(E),isFirstAccount:!1}}),I=o.useMemo(()=>a?.authStatus||[],[a?.authStatus]),D=a?.source==="remote",P=o.useMemo(()=>i?.variants||[],[i?.variants]),U=x=>{k(x),x&&localStorage.setItem("cliproxy-selected-provider",x)},C=o.useMemo(()=>y?null:T&&I.some(x=>x.provider===T)?T:I.length>0&&(I.find(E=>(E.accounts?.length||0)>0)?.provider||I[0]?.provider)||null,[T,y,I]),w=I.find(x=>x.provider===C),u=P.find(x=>x.name===y),F=u?I.find(x=>x.provider===u.provider):void 0,V=(u?.provider||w?.provider||"").toLowerCase().trim(),R=V==="gemini"||V==="agy",N=()=>{s.invalidateQueries({queryKey:["cliproxy"]}),s.invalidateQueries({queryKey:["cliproxy-auth"]})},K=(x,E,W)=>{p.isPending||f.isPending||(W?p.mutate({provider:x,accountId:E}):f.mutate({provider:x,accountId:E}))},q=(x,E)=>{h.isPending||h.mutate({provider:x,accountId:E})},Q=(x,E)=>{g.isPending||g.mutate({provider:x,accountIds:E})},Y=(x,E)=>{_.isPending||_.mutate({provider:x,accountIds:E})},J=x=>{U(x),M(null)},ne=x=>{M(x),U(null)};return e.jsxs("div",{className:"flex h-full min-h-0 overflow-hidden",children:[e.jsxs("div",{className:"w-80 border-r flex flex-col bg-muted/30",children:[e.jsxs("div",{className:"p-4 border-b bg-background",children:[e.jsxs("div",{className:"flex items-center justify-between mb-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ke,{className:"w-5 h-5 text-primary"}),e.jsx("h1",{className:"font-semibold",children:m?.backendLabel??"CLIProxy"})]}),e.jsx(L,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:N,disabled:d,children:e.jsx(ut,{className:$("w-4 h-4",d&&"animate-spin")})})]}),e.jsx("p",{className:"text-xs text-muted-foreground mb-3",children:t("cliproxyPage.accountManagement")}),e.jsxs(L,{variant:"default",size:"sm",className:"w-full gap-2",onClick:()=>b(!0),children:[e.jsx(Ce,{className:"w-4 h-4"}),t("cliproxyPage.quickSetup")]})]}),e.jsx(lt,{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:t("cliproxyPage.providers")}),n?e.jsx("div",{className:"space-y-2 px-2",children:[1,2,3,4].map(x=>e.jsx(Gs,{className:"h-14 w-full rounded-lg"},x))}):e.jsx("div",{className:"space-y-1",children:I.map(x=>e.jsx(Va,{status:x,isSelected:C===x.provider,onSelect:()=>J(x.provider)},x.provider))}),P.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(Qt,{className:"w-3 h-3"}),t("cliproxyPage.variants")]}),e.jsx("div",{className:"space-y-1",children:P.map(x=>e.jsx(Ga,{variant:x,parentAuth:I.find(E=>E.provider===x.provider),isSelected:y===x.name,onSelect:()=>ne(x.name),onDelete:()=>v.mutate(x.name),isDeleting:v.isPending},x.name))})]})]})}),e.jsx("div",{className:"p-3 border-t",children:e.jsx(na,{})}),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("cliproxyPage.providerCount",{count:I.length})}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(pe,{className:"w-3 h-3 text-green-600"}),t("cliproxyPage.connectedCount",{count:I.filter(x=>x.authenticated).length})]})]})})]}),e.jsxs("div",{className:"flex-1 flex flex-col min-w-0 bg-background",children:[R&&e.jsx(Zt,{showProxySettingsLink:!0,className:"mx-4 mt-4"}),u&&F?e.jsx(e.Fragment,{children:e.jsx(St,{provider:u.name,displayName:t("cliproxyPage.variantDisplay",{name:u.name,provider:u.provider}),authStatus:F,catalog:ge[u.provider],logoProvider:u.provider,baseProvider:u.provider,defaultTarget:u.target,isRemoteMode:D,port:u.port,onAddAccount:()=>A({provider:u.provider,displayName:F.displayName,isFirstAccount:(F.accounts?.length||0)===0}),onSetDefault:x=>c.mutate({provider:u.provider,accountId:x}),onRemoveAccount:x=>l.mutate({provider:u.provider,accountId:x}),onPauseToggle:(x,E)=>K(u.provider,x,E),onSoloMode:x=>q(u.provider,x),onBulkPause:x=>Q(u.provider,x),onBulkResume:x=>Y(u.provider,x),isRemovingAccount:l.isPending,isPausingAccount:p.isPending||f.isPending,isSoloingAccount:h.isPending,isBulkPausing:g.isPending,isBulkResuming:_.isPending})}):w?e.jsx(e.Fragment,{children:e.jsx(St,{provider:w.provider,displayName:w.displayName,authStatus:w,catalog:ge[w.provider],isRemoteMode:D,onAddAccount:()=>A({provider:w.provider,displayName:w.displayName,isFirstAccount:(w.accounts?.length||0)===0}),onSetDefault:x=>c.mutate({provider:w.provider,accountId:x}),onRemoveAccount:x=>l.mutate({provider:w.provider,accountId:x}),onPauseToggle:(x,E)=>K(w.provider,x,E),onSoloMode:x=>q(w.provider,x),onBulkPause:x=>Q(w.provider,x),onBulkResume:x=>Y(w.provider,x),isRemovingAccount:l.isPending,isPausingAccount:p.isPending||f.isPending,isSoloingAccount:h.isPending,isBulkPausing:g.isPending,isBulkResuming:_.isPending})}):e.jsx(Ba,{onSetup:()=>b(!0)})]}),e.jsx(fa,{open:r,onClose:()=>b(!1)}),e.jsx(Ca,{open:j!==null,onClose:()=>A(null),provider:j?.provider||"",displayName:j?.displayName||"",isFirstAccount:j?.isFirstAccount||!1})]})}export{dn as CliproxyPage};