@kaitranntt/ccs 7.76.0 → 7.77.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 (559) hide show
  1. package/README.md +2 -1
  2. package/dist/api/services/cliproxy-profile-bridge.d.ts.map +1 -1
  3. package/dist/api/services/cliproxy-profile-bridge.js +5 -6
  4. package/dist/api/services/cliproxy-profile-bridge.js.map +1 -1
  5. package/dist/api/services/openrouter-catalog.js +2 -2
  6. package/dist/api/services/openrouter-catalog.js.map +1 -1
  7. package/dist/api/services/profile-lifecycle-service.d.ts.map +1 -1
  8. package/dist/api/services/profile-lifecycle-service.js +6 -6
  9. package/dist/api/services/profile-lifecycle-service.js.map +1 -1
  10. package/dist/api/services/profile-reader.d.ts.map +1 -1
  11. package/dist/api/services/profile-reader.js +14 -15
  12. package/dist/api/services/profile-reader.js.map +1 -1
  13. package/dist/api/services/profile-writer.d.ts.map +1 -1
  14. package/dist/api/services/profile-writer.js +13 -13
  15. package/dist/api/services/profile-writer.js.map +1 -1
  16. package/dist/auth/commands/create-command.d.ts.map +1 -1
  17. package/dist/auth/commands/create-command.js +2 -2
  18. package/dist/auth/commands/create-command.js.map +1 -1
  19. package/dist/auth/commands/default-command.d.ts.map +1 -1
  20. package/dist/auth/commands/default-command.js +3 -3
  21. package/dist/auth/commands/default-command.js.map +1 -1
  22. package/dist/auth/commands/remove-command.d.ts.map +1 -1
  23. package/dist/auth/commands/remove-command.js +2 -2
  24. package/dist/auth/commands/remove-command.js.map +1 -1
  25. package/dist/auth/profile-continuity-inheritance.d.ts.map +1 -1
  26. package/dist/auth/profile-continuity-inheritance.js +4 -4
  27. package/dist/auth/profile-continuity-inheritance.js.map +1 -1
  28. package/dist/auth/profile-detector.d.ts.map +1 -1
  29. package/dist/auth/profile-detector.js +5 -6
  30. package/dist/auth/profile-detector.js.map +1 -1
  31. package/dist/auth/profile-registry.d.ts.map +1 -1
  32. package/dist/auth/profile-registry.js +14 -15
  33. package/dist/auth/profile-registry.js.map +1 -1
  34. package/dist/auth/resume-lane-diagnostics.d.ts.map +1 -1
  35. package/dist/auth/resume-lane-diagnostics.js +2 -2
  36. package/dist/auth/resume-lane-diagnostics.js.map +1 -1
  37. package/dist/ccs.js +30 -1257
  38. package/dist/ccs.js.map +1 -1
  39. package/dist/channels/official-channels-ids.d.ts +21 -0
  40. package/dist/channels/official-channels-ids.d.ts.map +1 -0
  41. package/dist/channels/official-channels-ids.js +46 -0
  42. package/dist/channels/official-channels-ids.js.map +1 -0
  43. package/dist/channels/official-channels-runtime.d.ts +2 -5
  44. package/dist/channels/official-channels-runtime.d.ts.map +1 -1
  45. package/dist/channels/official-channels-runtime.js +14 -29
  46. package/dist/channels/official-channels-runtime.js.map +1 -1
  47. package/dist/channels/official-channels-store.d.ts.map +1 -1
  48. package/dist/channels/official-channels-store.js +2 -2
  49. package/dist/channels/official-channels-store.js.map +1 -1
  50. package/dist/cliproxy/accounts/account-safety.js +4 -4
  51. package/dist/cliproxy/accounts/account-safety.js.map +1 -1
  52. package/dist/cliproxy/auth/antigravity-responsibility.js +2 -2
  53. package/dist/cliproxy/auth/antigravity-responsibility.js.map +1 -1
  54. package/dist/cliproxy/auth/auth-token-manager.d.ts.map +1 -1
  55. package/dist/cliproxy/auth/auth-token-manager.js +8 -8
  56. package/dist/cliproxy/auth/auth-token-manager.js.map +1 -1
  57. package/dist/cliproxy/auth/token-refresh-config.d.ts.map +1 -1
  58. package/dist/cliproxy/auth/token-refresh-config.js +2 -2
  59. package/dist/cliproxy/auth/token-refresh-config.js.map +1 -1
  60. package/dist/cliproxy/binary/lifecycle.js +2 -2
  61. package/dist/cliproxy/binary/lifecycle.js.map +1 -1
  62. package/dist/cliproxy/binary/platform-detector.d.ts +7 -6
  63. package/dist/cliproxy/binary/platform-detector.d.ts.map +1 -1
  64. package/dist/cliproxy/binary/platform-detector.js +22 -11
  65. package/dist/cliproxy/binary/platform-detector.js.map +1 -1
  66. package/dist/cliproxy/binary-manager.d.ts.map +1 -1
  67. package/dist/cliproxy/binary-manager.js +5 -3
  68. package/dist/cliproxy/binary-manager.js.map +1 -1
  69. package/dist/cliproxy/config/env-builder.d.ts.map +1 -1
  70. package/dist/cliproxy/config/env-builder.js +2 -2
  71. package/dist/cliproxy/config/env-builder.js.map +1 -1
  72. package/dist/cliproxy/config/generator.d.ts +6 -2
  73. package/dist/cliproxy/config/generator.d.ts.map +1 -1
  74. package/dist/cliproxy/config/generator.js +43 -10
  75. package/dist/cliproxy/config/generator.js.map +1 -1
  76. package/dist/cliproxy/config/model-config.d.ts.map +1 -1
  77. package/dist/cliproxy/config/model-config.js +2 -2
  78. package/dist/cliproxy/config/model-config.js.map +1 -1
  79. package/dist/cliproxy/config/path-resolver.d.ts.map +1 -1
  80. package/dist/cliproxy/config/path-resolver.js +4 -4
  81. package/dist/cliproxy/config/path-resolver.js.map +1 -1
  82. package/dist/cliproxy/config/port-manager.d.ts +6 -0
  83. package/dist/cliproxy/config/port-manager.d.ts.map +1 -1
  84. package/dist/cliproxy/config/port-manager.js +19 -1
  85. package/dist/cliproxy/config/port-manager.js.map +1 -1
  86. package/dist/cliproxy/config/thinking-config.d.ts.map +1 -1
  87. package/dist/cliproxy/config/thinking-config.js +2 -2
  88. package/dist/cliproxy/config/thinking-config.js.map +1 -1
  89. package/dist/cliproxy/executor/account-resolution.d.ts +52 -0
  90. package/dist/cliproxy/executor/account-resolution.d.ts.map +1 -0
  91. package/dist/cliproxy/executor/account-resolution.js +154 -0
  92. package/dist/cliproxy/executor/account-resolution.js.map +1 -0
  93. package/dist/cliproxy/executor/arg-parser.d.ts +96 -0
  94. package/dist/cliproxy/executor/arg-parser.d.ts.map +1 -0
  95. package/dist/cliproxy/executor/arg-parser.js +529 -0
  96. package/dist/cliproxy/executor/arg-parser.js.map +1 -0
  97. package/dist/cliproxy/executor/auth-coordinator.d.ts +96 -0
  98. package/dist/cliproxy/executor/auth-coordinator.d.ts.map +1 -0
  99. package/dist/cliproxy/executor/auth-coordinator.js +342 -0
  100. package/dist/cliproxy/executor/auth-coordinator.js.map +1 -0
  101. package/dist/cliproxy/executor/browser-launch-setup.d.ts +36 -0
  102. package/dist/cliproxy/executor/browser-launch-setup.d.ts.map +1 -0
  103. package/dist/cliproxy/executor/browser-launch-setup.js +80 -0
  104. package/dist/cliproxy/executor/browser-launch-setup.js.map +1 -0
  105. package/dist/cliproxy/executor/claude-launcher.d.ts +55 -0
  106. package/dist/cliproxy/executor/claude-launcher.d.ts.map +1 -0
  107. package/dist/cliproxy/executor/claude-launcher.js +112 -0
  108. package/dist/cliproxy/executor/claude-launcher.js.map +1 -0
  109. package/dist/cliproxy/executor/index.d.ts +4 -9
  110. package/dist/cliproxy/executor/index.d.ts.map +1 -1
  111. package/dist/cliproxy/executor/index.js +110 -866
  112. package/dist/cliproxy/executor/index.js.map +1 -1
  113. package/dist/cliproxy/executor/model-warnings.d.ts +22 -0
  114. package/dist/cliproxy/executor/model-warnings.d.ts.map +1 -0
  115. package/dist/cliproxy/executor/model-warnings.js +67 -0
  116. package/dist/cliproxy/executor/model-warnings.js.map +1 -0
  117. package/dist/cliproxy/executor/proxy-chain-builder.d.ts +71 -0
  118. package/dist/cliproxy/executor/proxy-chain-builder.d.ts.map +1 -0
  119. package/dist/cliproxy/executor/proxy-chain-builder.js +143 -0
  120. package/dist/cliproxy/executor/proxy-chain-builder.js.map +1 -0
  121. package/dist/cliproxy/executor/proxy-resolver.d.ts +44 -0
  122. package/dist/cliproxy/executor/proxy-resolver.d.ts.map +1 -0
  123. package/dist/cliproxy/executor/proxy-resolver.js +173 -0
  124. package/dist/cliproxy/executor/proxy-resolver.js.map +1 -0
  125. package/dist/cliproxy/proxy/proxy-target-resolver.d.ts.map +1 -1
  126. package/dist/cliproxy/proxy/proxy-target-resolver.js +3 -3
  127. package/dist/cliproxy/proxy/proxy-target-resolver.js.map +1 -1
  128. package/dist/cliproxy/proxy/tool-sanitization-proxy.d.ts.map +1 -1
  129. package/dist/cliproxy/proxy/tool-sanitization-proxy.js +2 -2
  130. package/dist/cliproxy/proxy/tool-sanitization-proxy.js.map +1 -1
  131. package/dist/cliproxy/quota/quota-fetcher.d.ts.map +1 -1
  132. package/dist/cliproxy/quota/quota-fetcher.js +28 -9
  133. package/dist/cliproxy/quota/quota-fetcher.js.map +1 -1
  134. package/dist/cliproxy/quota/quota-manager.d.ts.map +1 -1
  135. package/dist/cliproxy/quota/quota-manager.js +4 -4
  136. package/dist/cliproxy/quota/quota-manager.js.map +1 -1
  137. package/dist/cliproxy/routing/routing-strategy.d.ts.map +1 -1
  138. package/dist/cliproxy/routing/routing-strategy.js +5 -5
  139. package/dist/cliproxy/routing/routing-strategy.js.map +1 -1
  140. package/dist/cliproxy/service-manager.js +2 -2
  141. package/dist/cliproxy/service-manager.js.map +1 -1
  142. package/dist/cliproxy/services/binary-service.js +8 -8
  143. package/dist/cliproxy/services/binary-service.js.map +1 -1
  144. package/dist/cliproxy/services/catalog-cache.d.ts.map +1 -1
  145. package/dist/cliproxy/services/catalog-cache.js +2 -2
  146. package/dist/cliproxy/services/catalog-cache.js.map +1 -1
  147. package/dist/cliproxy/services/proxy-lifecycle-service.d.ts +1 -0
  148. package/dist/cliproxy/services/proxy-lifecycle-service.d.ts.map +1 -1
  149. package/dist/cliproxy/services/proxy-lifecycle-service.js +6 -6
  150. package/dist/cliproxy/services/proxy-lifecycle-service.js.map +1 -1
  151. package/dist/cliproxy/services/variant-config-adapter.d.ts.map +1 -1
  152. package/dist/cliproxy/services/variant-config-adapter.js +10 -10
  153. package/dist/cliproxy/services/variant-config-adapter.js.map +1 -1
  154. package/dist/cliproxy/services/variant-service.d.ts.map +1 -1
  155. package/dist/cliproxy/services/variant-service.js +7 -8
  156. package/dist/cliproxy/services/variant-service.js.map +1 -1
  157. package/dist/cliproxy/services/variant-settings.d.ts.map +1 -1
  158. package/dist/cliproxy/services/variant-settings.js +5 -5
  159. package/dist/cliproxy/services/variant-settings.js.map +1 -1
  160. package/dist/cliproxy/session-tracker.d.ts +1 -0
  161. package/dist/cliproxy/session-tracker.d.ts.map +1 -1
  162. package/dist/cliproxy/session-tracker.js +14 -8
  163. package/dist/cliproxy/session-tracker.js.map +1 -1
  164. package/dist/cliproxy/sync/auto-sync-watcher.js +3 -4
  165. package/dist/cliproxy/sync/auto-sync-watcher.js.map +1 -1
  166. package/dist/cliproxy/sync/profile-mapper.d.ts.map +1 -1
  167. package/dist/cliproxy/sync/profile-mapper.js +2 -2
  168. package/dist/cliproxy/sync/profile-mapper.js.map +1 -1
  169. package/dist/cliproxy/types/platform-types.d.ts +2 -2
  170. package/dist/cliproxy/types/platform-types.d.ts.map +1 -1
  171. package/dist/commands/browser-command.d.ts.map +1 -1
  172. package/dist/commands/browser-command.js +7 -7
  173. package/dist/commands/browser-command.js.map +1 -1
  174. package/dist/commands/cliproxy/proxy-lifecycle-subcommand.js +5 -5
  175. package/dist/commands/cliproxy/proxy-lifecycle-subcommand.js.map +1 -1
  176. package/dist/commands/cliproxy/variant-subcommand.d.ts.map +1 -1
  177. package/dist/commands/cliproxy/variant-subcommand.js +4 -4
  178. package/dist/commands/cliproxy/variant-subcommand.js.map +1 -1
  179. package/dist/commands/config-auth/disable-command.d.ts.map +1 -1
  180. package/dist/commands/config-auth/disable-command.js +3 -3
  181. package/dist/commands/config-auth/disable-command.js.map +1 -1
  182. package/dist/commands/config-auth/setup-command.d.ts.map +1 -1
  183. package/dist/commands/config-auth/setup-command.js +2 -2
  184. package/dist/commands/config-auth/setup-command.js.map +1 -1
  185. package/dist/commands/config-auth/show-command.js +2 -2
  186. package/dist/commands/config-auth/show-command.js.map +1 -1
  187. package/dist/commands/config-channels-command.d.ts.map +1 -1
  188. package/dist/commands/config-channels-command.js +4 -4
  189. package/dist/commands/config-channels-command.js.map +1 -1
  190. package/dist/commands/config-command.d.ts +1 -1
  191. package/dist/commands/config-command.d.ts.map +1 -1
  192. package/dist/commands/config-command.js +4 -4
  193. package/dist/commands/config-command.js.map +1 -1
  194. package/dist/commands/config-image-analysis-command.d.ts.map +1 -1
  195. package/dist/commands/config-image-analysis-command.js +4 -4
  196. package/dist/commands/config-image-analysis-command.js.map +1 -1
  197. package/dist/commands/config-thinking-command.d.ts.map +1 -1
  198. package/dist/commands/config-thinking-command.js +4 -4
  199. package/dist/commands/config-thinking-command.js.map +1 -1
  200. package/dist/commands/copilot-command.d.ts.map +1 -1
  201. package/dist/commands/copilot-command.js +4 -4
  202. package/dist/commands/copilot-command.js.map +1 -1
  203. package/dist/commands/cursor-command.d.ts.map +1 -1
  204. package/dist/commands/cursor-command.js +7 -7
  205. package/dist/commands/cursor-command.js.map +1 -1
  206. package/dist/commands/env-command.d.ts.map +1 -1
  207. package/dist/commands/env-command.js +2 -2
  208. package/dist/commands/env-command.js.map +1 -1
  209. package/dist/commands/migrate-command.d.ts.map +1 -1
  210. package/dist/commands/migrate-command.js +2 -2
  211. package/dist/commands/migrate-command.js.map +1 -1
  212. package/dist/commands/proxy-command.d.ts.map +1 -1
  213. package/dist/commands/proxy-command.js +2 -1
  214. package/dist/commands/proxy-command.js.map +1 -1
  215. package/dist/commands/setup-command.d.ts.map +1 -1
  216. package/dist/commands/setup-command.js +6 -7
  217. package/dist/commands/setup-command.js.map +1 -1
  218. package/dist/commands/version-command.d.ts.map +1 -1
  219. package/dist/commands/version-command.js +2 -1
  220. package/dist/commands/version-command.js.map +1 -1
  221. package/dist/config/loader/config-getters.d.ts +121 -0
  222. package/dist/config/loader/config-getters.d.ts.map +1 -0
  223. package/dist/config/loader/config-getters.js +260 -0
  224. package/dist/config/loader/config-getters.js.map +1 -0
  225. package/dist/config/loader/defaults-merger.d.ts +21 -0
  226. package/dist/config/loader/defaults-merger.d.ts.map +1 -0
  227. package/dist/config/loader/defaults-merger.js +278 -0
  228. package/dist/config/loader/defaults-merger.js.map +1 -0
  229. package/dist/config/loader/io-locks.d.ts +76 -0
  230. package/dist/config/loader/io-locks.d.ts.map +1 -0
  231. package/dist/config/loader/io-locks.js +297 -0
  232. package/dist/config/loader/io-locks.js.map +1 -0
  233. package/dist/config/loader/normalizers.d.ts +40 -0
  234. package/dist/config/loader/normalizers.d.ts.map +1 -0
  235. package/dist/config/loader/normalizers.js +172 -0
  236. package/dist/config/loader/normalizers.js.map +1 -0
  237. package/dist/config/loader/yaml-serializer.d.ts +19 -0
  238. package/dist/config/loader/yaml-serializer.d.ts.map +1 -0
  239. package/dist/config/loader/yaml-serializer.js +300 -0
  240. package/dist/config/loader/yaml-serializer.js.map +1 -0
  241. package/dist/config/schemas/cliproxy.d.ts +2 -0
  242. package/dist/config/schemas/cliproxy.d.ts.map +1 -1
  243. package/dist/config/unified-config-loader.d.ts +21 -124
  244. package/dist/config/unified-config-loader.d.ts.map +1 -1
  245. package/dist/config/unified-config-loader.js +100 -1098
  246. package/dist/config/unified-config-loader.js.map +1 -1
  247. package/dist/copilot/copilot-daemon.d.ts.map +1 -1
  248. package/dist/copilot/copilot-daemon.js +2 -2
  249. package/dist/copilot/copilot-daemon.js.map +1 -1
  250. package/dist/copilot/copilot-executor.d.ts.map +1 -1
  251. package/dist/copilot/copilot-executor.js +3 -3
  252. package/dist/copilot/copilot-executor.js.map +1 -1
  253. package/dist/copilot/copilot-package-manager.js +2 -2
  254. package/dist/copilot/copilot-package-manager.js.map +1 -1
  255. package/dist/cursor/cursor-auth.js +2 -2
  256. package/dist/cursor/cursor-auth.js.map +1 -1
  257. package/dist/cursor/cursor-daemon-pid.js +2 -2
  258. package/dist/cursor/cursor-daemon-pid.js.map +1 -1
  259. package/dist/cursor/cursor-models.d.ts.map +1 -1
  260. package/dist/cursor/cursor-models.js +26 -4
  261. package/dist/cursor/cursor-models.js.map +1 -1
  262. package/dist/cursor/cursor-profile-executor.d.ts +10 -1
  263. package/dist/cursor/cursor-profile-executor.d.ts.map +1 -1
  264. package/dist/cursor/cursor-profile-executor.js +10 -6
  265. package/dist/cursor/cursor-profile-executor.js.map +1 -1
  266. package/dist/delegation/delegation-handler.js +2 -2
  267. package/dist/delegation/delegation-handler.js.map +1 -1
  268. package/dist/delegation/headless-executor.d.ts.map +1 -1
  269. package/dist/delegation/headless-executor.js +5 -5
  270. package/dist/delegation/headless-executor.js.map +1 -1
  271. package/dist/delegation/session-manager.js +2 -2
  272. package/dist/delegation/session-manager.js.map +1 -1
  273. package/dist/dispatcher/cli-argument-parser.d.ts +70 -0
  274. package/dist/dispatcher/cli-argument-parser.d.ts.map +1 -0
  275. package/dist/dispatcher/cli-argument-parser.js +285 -0
  276. package/dist/dispatcher/cli-argument-parser.js.map +1 -0
  277. package/dist/dispatcher/dispatcher-context.d.ts +24 -0
  278. package/dist/dispatcher/dispatcher-context.d.ts.map +1 -0
  279. package/dist/dispatcher/dispatcher-context.js +11 -0
  280. package/dist/dispatcher/dispatcher-context.js.map +1 -0
  281. package/dist/dispatcher/environment-builder.d.ts +20 -0
  282. package/dist/dispatcher/environment-builder.d.ts.map +1 -0
  283. package/dist/dispatcher/environment-builder.js +95 -0
  284. package/dist/dispatcher/environment-builder.js.map +1 -0
  285. package/dist/dispatcher/flows/account-flow.d.ts +9 -0
  286. package/dist/dispatcher/flows/account-flow.d.ts.map +1 -0
  287. package/dist/dispatcher/flows/account-flow.js +49 -0
  288. package/dist/dispatcher/flows/account-flow.js.map +1 -0
  289. package/dist/dispatcher/flows/cliproxy-flow.d.ts +8 -0
  290. package/dist/dispatcher/flows/cliproxy-flow.d.ts.map +1 -0
  291. package/dist/dispatcher/flows/cliproxy-flow.js +165 -0
  292. package/dist/dispatcher/flows/cliproxy-flow.js.map +1 -0
  293. package/dist/dispatcher/flows/copilot-flow.d.ts +8 -0
  294. package/dist/dispatcher/flows/copilot-flow.d.ts.map +1 -0
  295. package/dist/dispatcher/flows/copilot-flow.js +72 -0
  296. package/dist/dispatcher/flows/copilot-flow.js.map +1 -0
  297. package/dist/dispatcher/flows/cursor-flow.d.ts +8 -0
  298. package/dist/dispatcher/flows/cursor-flow.d.ts.map +1 -0
  299. package/dist/dispatcher/flows/cursor-flow.js +62 -0
  300. package/dist/dispatcher/flows/cursor-flow.js.map +1 -0
  301. package/dist/dispatcher/flows/default-flow.d.ts +10 -0
  302. package/dist/dispatcher/flows/default-flow.d.ts.map +1 -0
  303. package/dist/dispatcher/flows/default-flow.js +99 -0
  304. package/dist/dispatcher/flows/default-flow.js.map +1 -0
  305. package/dist/dispatcher/flows/settings-flow.d.ts +9 -0
  306. package/dist/dispatcher/flows/settings-flow.d.ts.map +1 -0
  307. package/dist/dispatcher/flows/settings-flow.js +318 -0
  308. package/dist/dispatcher/flows/settings-flow.js.map +1 -0
  309. package/dist/dispatcher/flows/settings-image-analysis-prep.d.ts +28 -0
  310. package/dist/dispatcher/flows/settings-image-analysis-prep.d.ts.map +1 -0
  311. package/dist/dispatcher/flows/settings-image-analysis-prep.js +81 -0
  312. package/dist/dispatcher/flows/settings-image-analysis-prep.js.map +1 -0
  313. package/dist/dispatcher/pre-dispatch.d.ts +23 -0
  314. package/dist/dispatcher/pre-dispatch.d.ts.map +1 -0
  315. package/dist/dispatcher/pre-dispatch.js +156 -0
  316. package/dist/dispatcher/pre-dispatch.js.map +1 -0
  317. package/dist/dispatcher/profile-resolver.d.ts +65 -0
  318. package/dist/dispatcher/profile-resolver.d.ts.map +1 -0
  319. package/dist/dispatcher/profile-resolver.js +290 -0
  320. package/dist/dispatcher/profile-resolver.js.map +1 -0
  321. package/dist/dispatcher/target-executor.d.ts +26 -0
  322. package/dist/dispatcher/target-executor.d.ts.map +1 -0
  323. package/dist/dispatcher/target-executor.js +81 -0
  324. package/dist/dispatcher/target-executor.js.map +1 -0
  325. package/dist/docker/docker-assets.d.ts.map +1 -1
  326. package/dist/docker/docker-assets.js +2 -2
  327. package/dist/docker/docker-assets.js.map +1 -1
  328. package/dist/glmt/glmt-transformer.d.ts.map +1 -1
  329. package/dist/glmt/glmt-transformer.js +2 -2
  330. package/dist/glmt/glmt-transformer.js.map +1 -1
  331. package/dist/management/checks/config-check.d.ts.map +1 -1
  332. package/dist/management/checks/config-check.js +2 -2
  333. package/dist/management/checks/config-check.js.map +1 -1
  334. package/dist/management/checks/env-check.d.ts.map +1 -1
  335. package/dist/management/checks/env-check.js +2 -1
  336. package/dist/management/checks/env-check.js.map +1 -1
  337. package/dist/management/checks/image-analysis-check.d.ts.map +1 -1
  338. package/dist/management/checks/image-analysis-check.js +4 -4
  339. package/dist/management/checks/image-analysis-check.js.map +1 -1
  340. package/dist/management/checks/profile-check.js +4 -4
  341. package/dist/management/checks/profile-check.js.map +1 -1
  342. package/dist/management/checks/symlink-check.js +2 -2
  343. package/dist/management/checks/symlink-check.js.map +1 -1
  344. package/dist/management/checks/system-check.js +2 -2
  345. package/dist/management/checks/system-check.js.map +1 -1
  346. package/dist/management/instance-manager.d.ts.map +1 -1
  347. package/dist/management/instance-manager.js +2 -1
  348. package/dist/management/instance-manager.js.map +1 -1
  349. package/dist/management/recovery-manager.d.ts.map +1 -1
  350. package/dist/management/recovery-manager.js +5 -5
  351. package/dist/management/recovery-manager.js.map +1 -1
  352. package/dist/management/repair/auto-repair.d.ts.map +1 -1
  353. package/dist/management/repair/auto-repair.js +2 -2
  354. package/dist/management/repair/auto-repair.js.map +1 -1
  355. package/dist/management/shared-manager.d.ts.map +1 -1
  356. package/dist/management/shared-manager.js +2 -2
  357. package/dist/management/shared-manager.js.map +1 -1
  358. package/dist/proxy/proxy-daemon-entry.js +2 -2
  359. package/dist/proxy/proxy-daemon-entry.js.map +1 -1
  360. package/dist/proxy/proxy-daemon-paths.js +2 -2
  361. package/dist/proxy/proxy-daemon-paths.js.map +1 -1
  362. package/dist/proxy/proxy-port-resolver.js +2 -2
  363. package/dist/proxy/proxy-port-resolver.js.map +1 -1
  364. package/dist/proxy/request-router.d.ts.map +1 -1
  365. package/dist/proxy/request-router.js +3 -3
  366. package/dist/proxy/request-router.js.map +1 -1
  367. package/dist/services/logging/log-config.d.ts.map +1 -1
  368. package/dist/services/logging/log-config.js +3 -3
  369. package/dist/services/logging/log-config.js.map +1 -1
  370. package/dist/services/logging/log-paths.js +3 -3
  371. package/dist/services/logging/log-paths.js.map +1 -1
  372. package/dist/targets/droid-provider.d.ts.map +1 -1
  373. package/dist/targets/droid-provider.js +9 -6
  374. package/dist/targets/droid-provider.js.map +1 -1
  375. package/dist/ui/assets/{accounts-CDgKt-GZ.js → accounts-CybVGDsm.js} +1 -1
  376. package/dist/ui/assets/{alert-dialog-CRqbTpjm.js → alert-dialog-C6npAhT0.js} +1 -1
  377. package/dist/ui/assets/{api-C7W2ibtd.js → api-DZosWVkR.js} +1 -1
  378. package/dist/ui/assets/{auth-section-RBgQQrdk.js → auth-section-D4MZkgcP.js} +1 -1
  379. package/dist/ui/assets/{backups-section-DptarTls.js → backups-section-DvMJrmHH.js} +1 -1
  380. package/dist/ui/assets/{channels-BMQs4wmY.js → channels-BVftYfOn.js} +1 -1
  381. package/dist/ui/assets/{checkbox-BrRyK0T3.js → checkbox-BLRznRTO.js} +1 -1
  382. package/dist/ui/assets/{claude-extension-DrSuOyf4.js → claude-extension-C6OeBQ73.js} +1 -1
  383. package/dist/ui/assets/cliproxy-B3Jyu3r9.js +3 -0
  384. package/dist/ui/assets/{cliproxy-ai-providers-B8aZTWIe.js → cliproxy-ai-providers-BAJ78pUc.js} +1 -1
  385. package/dist/ui/assets/{cliproxy-control-panel-BpXgvmht.js → cliproxy-control-panel-XEvUMVJe.js} +1 -1
  386. package/dist/ui/assets/{codex-CYoq5g4z.js → codex-CY2vikqX.js} +1 -1
  387. package/dist/ui/assets/{confirm-dialog-CP-4T1Wp.js → confirm-dialog-DjLHh1qX.js} +1 -1
  388. package/dist/ui/assets/{copilot-aEdlrY3S.js → copilot-afee2lL9.js} +1 -1
  389. package/dist/ui/assets/{cursor-CSJ0aqxS.js → cursor-DuWy60wp.js} +1 -1
  390. package/dist/ui/assets/{droid-DTdvqOvV.js → droid-FlceoQ6k.js} +1 -1
  391. package/dist/ui/assets/{globalenv-section-DXbRVgOM.js → globalenv-section-DpJ7unxC.js} +1 -1
  392. package/dist/ui/assets/{health-CDce37cB.js → health-BEMgcKD3.js} +1 -1
  393. package/dist/ui/assets/{index-vN-yw8kw.js → index-0GkznW41.js} +1 -1
  394. package/dist/ui/assets/{index-DjxqZO4B.js → index-0n_43sCZ.js} +1 -1
  395. package/dist/ui/assets/{index-Fd17BSGq.js → index-BRtgic66.js} +2 -2
  396. package/dist/ui/assets/{index-dnIWLkjb.js → index-Ba4ysocb.js} +1 -1
  397. package/dist/ui/assets/{index-Bm9k7s_T.js → index-Cj7EjEq6.js} +1 -1
  398. package/dist/ui/assets/{index-KK76yIJk.js → index-Cq9VySs6.js} +1 -1
  399. package/dist/ui/assets/{index-D_FmvtnX.js → index-DOC7_hun.js} +1 -1
  400. package/dist/ui/assets/{logs-C_MtpQIE.js → logs-Dth4naJl.js} +1 -1
  401. package/dist/ui/assets/{masked-input-BAWBYIqo.js → masked-input-DL6pJ8pE.js} +1 -1
  402. package/dist/ui/assets/{proxy-status-widget-DUqasX3c.js → proxy-status-widget-DW4cPFeD.js} +1 -1
  403. package/dist/ui/assets/{raw-json-settings-editor-panel-DuVlOXFi.js → raw-json-settings-editor-panel-Dcumu3Qi.js} +1 -1
  404. package/dist/ui/assets/{searchable-select-BCxZHr8N.js → searchable-select-CWL2D5Ft.js} +1 -1
  405. package/dist/ui/assets/{separator-BV4BKMsB.js → separator-Do_vqTQD.js} +1 -1
  406. package/dist/ui/assets/{shared-D-Cu_o1h.js → shared-CwWuZx24.js} +1 -1
  407. package/dist/ui/assets/{table-DW66THR9.js → table-BP6nBZzg.js} +1 -1
  408. package/dist/ui/assets/{updates-V0D_Q8n4.js → updates-BTHJZ7Rk.js} +1 -1
  409. package/dist/ui/index.html +1 -1
  410. package/dist/utils/browser/browser-setup.d.ts +2 -2
  411. package/dist/utils/browser/browser-setup.d.ts.map +1 -1
  412. package/dist/utils/browser/browser-setup.js +4 -4
  413. package/dist/utils/browser/browser-setup.js.map +1 -1
  414. package/dist/utils/browser/browser-status.d.ts.map +1 -1
  415. package/dist/utils/browser/browser-status.js +3 -3
  416. package/dist/utils/browser/browser-status.js.map +1 -1
  417. package/dist/utils/hooks/get-image-analysis-hook-env.d.ts.map +1 -1
  418. package/dist/utils/hooks/get-image-analysis-hook-env.js +2 -2
  419. package/dist/utils/hooks/get-image-analysis-hook-env.js.map +1 -1
  420. package/dist/utils/hooks/image-analyzer-hook-configuration.d.ts.map +1 -1
  421. package/dist/utils/hooks/image-analyzer-hook-configuration.js +2 -2
  422. package/dist/utils/hooks/image-analyzer-hook-configuration.js.map +1 -1
  423. package/dist/utils/hooks/image-analyzer-hook-installer.d.ts.map +1 -1
  424. package/dist/utils/hooks/image-analyzer-hook-installer.js +2 -2
  425. package/dist/utils/hooks/image-analyzer-hook-installer.js.map +1 -1
  426. package/dist/utils/hooks/image-analyzer-profile-hook-injector.d.ts.map +1 -1
  427. package/dist/utils/hooks/image-analyzer-profile-hook-injector.js +2 -2
  428. package/dist/utils/hooks/image-analyzer-profile-hook-injector.js.map +1 -1
  429. package/dist/utils/image-analysis/mcp-installer.d.ts.map +1 -1
  430. package/dist/utils/image-analysis/mcp-installer.js +5 -5
  431. package/dist/utils/image-analysis/mcp-installer.js.map +1 -1
  432. package/dist/utils/shell-executor.d.ts.map +1 -1
  433. package/dist/utils/shell-executor.js +2 -2
  434. package/dist/utils/shell-executor.js.map +1 -1
  435. package/dist/utils/websearch/hook-config.d.ts.map +1 -1
  436. package/dist/utils/websearch/hook-config.js +3 -3
  437. package/dist/utils/websearch/hook-config.js.map +1 -1
  438. package/dist/utils/websearch/hook-env.js +2 -2
  439. package/dist/utils/websearch/hook-env.js.map +1 -1
  440. package/dist/utils/websearch/hook-installer.d.ts.map +1 -1
  441. package/dist/utils/websearch/hook-installer.js +2 -2
  442. package/dist/utils/websearch/hook-installer.js.map +1 -1
  443. package/dist/utils/websearch/mcp-installer.d.ts.map +1 -1
  444. package/dist/utils/websearch/mcp-installer.js +5 -5
  445. package/dist/utils/websearch/mcp-installer.js.map +1 -1
  446. package/dist/utils/websearch/profile-hook-injector.d.ts.map +1 -1
  447. package/dist/utils/websearch/profile-hook-injector.js +3 -3
  448. package/dist/utils/websearch/profile-hook-injector.js.map +1 -1
  449. package/dist/utils/websearch/provider-secrets.js +2 -2
  450. package/dist/utils/websearch/provider-secrets.js.map +1 -1
  451. package/dist/utils/websearch/status.d.ts.map +1 -1
  452. package/dist/utils/websearch/status.js +4 -4
  453. package/dist/utils/websearch/status.js.map +1 -1
  454. package/dist/web-server/file-watcher.js +2 -2
  455. package/dist/web-server/file-watcher.js.map +1 -1
  456. package/dist/web-server/health/config-checks.d.ts.map +1 -1
  457. package/dist/web-server/health/config-checks.js +3 -3
  458. package/dist/web-server/health/config-checks.js.map +1 -1
  459. package/dist/web-server/health/profile-checks.d.ts.map +1 -1
  460. package/dist/web-server/health/profile-checks.js +3 -3
  461. package/dist/web-server/health/profile-checks.js.map +1 -1
  462. package/dist/web-server/health-service.d.ts.map +1 -1
  463. package/dist/web-server/health-service.js +7 -6
  464. package/dist/web-server/health-service.js.map +1 -1
  465. package/dist/web-server/middleware/auth-middleware.d.ts.map +1 -1
  466. package/dist/web-server/middleware/auth-middleware.js +6 -7
  467. package/dist/web-server/middleware/auth-middleware.js.map +1 -1
  468. package/dist/web-server/models-dev/registry-cache.d.ts.map +1 -1
  469. package/dist/web-server/models-dev/registry-cache.js +2 -2
  470. package/dist/web-server/models-dev/registry-cache.js.map +1 -1
  471. package/dist/web-server/overview-routes.d.ts.map +1 -1
  472. package/dist/web-server/overview-routes.js +2 -2
  473. package/dist/web-server/overview-routes.js.map +1 -1
  474. package/dist/web-server/routes/account-routes.d.ts.map +1 -1
  475. package/dist/web-server/routes/account-routes.js +7 -7
  476. package/dist/web-server/routes/account-routes.js.map +1 -1
  477. package/dist/web-server/routes/auth-routes.d.ts.map +1 -1
  478. package/dist/web-server/routes/auth-routes.js +4 -4
  479. package/dist/web-server/routes/auth-routes.js.map +1 -1
  480. package/dist/web-server/routes/browser-routes.d.ts.map +1 -1
  481. package/dist/web-server/routes/browser-routes.js +2 -2
  482. package/dist/web-server/routes/browser-routes.js.map +1 -1
  483. package/dist/web-server/routes/channels-routes.d.ts.map +1 -1
  484. package/dist/web-server/routes/channels-routes.js +4 -4
  485. package/dist/web-server/routes/channels-routes.js.map +1 -1
  486. package/dist/web-server/routes/cliproxy-auth-routes.d.ts.map +1 -1
  487. package/dist/web-server/routes/cliproxy-auth-routes.js +2 -2
  488. package/dist/web-server/routes/cliproxy-auth-routes.js.map +1 -1
  489. package/dist/web-server/routes/cliproxy-local-proxy.d.ts.map +1 -1
  490. package/dist/web-server/routes/cliproxy-local-proxy.js +1 -11
  491. package/dist/web-server/routes/cliproxy-local-proxy.js.map +1 -1
  492. package/dist/web-server/routes/cliproxy-stats-routes.d.ts.map +1 -1
  493. package/dist/web-server/routes/cliproxy-stats-routes.js +10 -8
  494. package/dist/web-server/routes/cliproxy-stats-routes.js.map +1 -1
  495. package/dist/web-server/routes/cliproxy-sync-routes.d.ts.map +1 -1
  496. package/dist/web-server/routes/cliproxy-sync-routes.js +2 -2
  497. package/dist/web-server/routes/cliproxy-sync-routes.js.map +1 -1
  498. package/dist/web-server/routes/config-routes.d.ts.map +1 -1
  499. package/dist/web-server/routes/config-routes.js +6 -6
  500. package/dist/web-server/routes/config-routes.js.map +1 -1
  501. package/dist/web-server/routes/copilot-routes.d.ts.map +1 -1
  502. package/dist/web-server/routes/copilot-routes.js +3 -3
  503. package/dist/web-server/routes/copilot-routes.js.map +1 -1
  504. package/dist/web-server/routes/copilot-settings-routes.d.ts.map +1 -1
  505. package/dist/web-server/routes/copilot-settings-routes.js +6 -7
  506. package/dist/web-server/routes/copilot-settings-routes.js.map +1 -1
  507. package/dist/web-server/routes/cursor-routes.d.ts.map +1 -1
  508. package/dist/web-server/routes/cursor-routes.js +5 -5
  509. package/dist/web-server/routes/cursor-routes.js.map +1 -1
  510. package/dist/web-server/routes/cursor-settings-routes.d.ts.map +1 -1
  511. package/dist/web-server/routes/cursor-settings-routes.js +8 -9
  512. package/dist/web-server/routes/cursor-settings-routes.js.map +1 -1
  513. package/dist/web-server/routes/image-analysis-routes.d.ts.map +1 -1
  514. package/dist/web-server/routes/image-analysis-routes.js +5 -6
  515. package/dist/web-server/routes/image-analysis-routes.js.map +1 -1
  516. package/dist/web-server/routes/misc-routes.d.ts.map +1 -1
  517. package/dist/web-server/routes/misc-routes.js +10 -11
  518. package/dist/web-server/routes/misc-routes.js.map +1 -1
  519. package/dist/web-server/routes/proxy-routes.d.ts.map +1 -1
  520. package/dist/web-server/routes/proxy-routes.js +40 -10
  521. package/dist/web-server/routes/proxy-routes.js.map +1 -1
  522. package/dist/web-server/routes/route-helpers.d.ts.map +1 -1
  523. package/dist/web-server/routes/route-helpers.js +7 -6
  524. package/dist/web-server/routes/route-helpers.js.map +1 -1
  525. package/dist/web-server/routes/settings-routes.d.ts.map +1 -1
  526. package/dist/web-server/routes/settings-routes.js +8 -9
  527. package/dist/web-server/routes/settings-routes.js.map +1 -1
  528. package/dist/web-server/routes/websearch-routes.d.ts.map +1 -1
  529. package/dist/web-server/routes/websearch-routes.js +4 -4
  530. package/dist/web-server/routes/websearch-routes.js.map +1 -1
  531. package/dist/web-server/services/claude-extension-binding-service.js +2 -2
  532. package/dist/web-server/services/claude-extension-binding-service.js.map +1 -1
  533. package/dist/web-server/services/cliproxy-dashboard-install-service.d.ts.map +1 -1
  534. package/dist/web-server/services/cliproxy-dashboard-install-service.js +4 -3
  535. package/dist/web-server/services/cliproxy-dashboard-install-service.js.map +1 -1
  536. package/dist/web-server/services/logs-dashboard-service.d.ts.map +1 -1
  537. package/dist/web-server/services/logs-dashboard-service.js +2 -2
  538. package/dist/web-server/services/logs-dashboard-service.js.map +1 -1
  539. package/dist/web-server/shared-routes.d.ts.map +1 -1
  540. package/dist/web-server/shared-routes.js +4 -4
  541. package/dist/web-server/shared-routes.js.map +1 -1
  542. package/dist/web-server/usage/aggregator.d.ts.map +1 -1
  543. package/dist/web-server/usage/aggregator.js +2 -2
  544. package/dist/web-server/usage/aggregator.js.map +1 -1
  545. package/dist/web-server/usage/cliproxy-usage-syncer.d.ts.map +1 -1
  546. package/dist/web-server/usage/cliproxy-usage-syncer.js +2 -2
  547. package/dist/web-server/usage/cliproxy-usage-syncer.js.map +1 -1
  548. package/dist/web-server/usage/codex-native-usage-collector.d.ts +2 -0
  549. package/dist/web-server/usage/codex-native-usage-collector.d.ts.map +1 -1
  550. package/dist/web-server/usage/codex-native-usage-collector.js +99 -1
  551. package/dist/web-server/usage/codex-native-usage-collector.js.map +1 -1
  552. package/dist/web-server/usage/disk-cache.js +2 -2
  553. package/dist/web-server/usage/disk-cache.js.map +1 -1
  554. package/package.json +1 -1
  555. package/dist/commands/cliproxy/resolve-lifecycle-port.d.ts +0 -9
  556. package/dist/commands/cliproxy/resolve-lifecycle-port.d.ts.map +0 -1
  557. package/dist/commands/cliproxy/resolve-lifecycle-port.js +0 -14
  558. package/dist/commands/cliproxy/resolve-lifecycle-port.js.map +0 -1
  559. package/dist/ui/assets/cliproxy-CdqYwRJH.js +0 -3
@@ -1,3 +0,0 @@
1
- import{j as e}from"./radix-ui-nu4wz29m.js";import{r as d}from"./react-vendor-Bjx91N7w.js";import{a as ht,u as $t,b as Ss}from"./tanstack-bhJxV1h8.js";import{a8 as Ms,a as W,d as K,C as Wt,b as Qt,a9 as Jt,aa as Xt,c as X,P as gt,B as H,ab as ue,L as Y,I as de,r as qe,s as ze,t as Ge,v as Be,w as ye,ac as Yt,ad as Zt,ae as Ps,af as Ds,ag as Is,u as es,ah as ft,ai as vt,aj as jt,ak as bt,W as me,al as ts,am as It,an as Es,ao as Ts,ap as Qe,aq as ss,Y as Ve,ar as Rs,as as Et,at as Tt,au as Ls,av as Os,aw as _s,ax as Fs,ay as Us,az as Ks,aA as Hs,aB as qs,aC as Rt,aD as zs,x as as,aE as Gs,n as Nt,aF as Bs,aG as yt,aH as Lt,aI as ns,aJ as Vs,m as $s,aK as Ws,aL as Qs,aM as lt,T as dt,p as ct,q as ut,aN as Js,aO as Xs,aP as Ys,aQ as Ot,aR as Zs,aS as ea,aT as ta,aU as sa,aV as aa,aW as na,Q as ia,R as ra,U as _t,V as Ft,aX as oa,aY as la,aZ as da,a_ as ca,a$ as ua,b0 as ma,b1 as pa,b2 as xa,b3 as ha,b4 as ga,b5 as fa,b6 as va,b7 as ja,S as ba}from"./index-Fd17BSGq.js";import{C as mt}from"./default-ports-1QQSffYX.js";import{t as B}from"./notifications-B4_o8bcr.js";import{C as is,L as ce,p as ke,$ as Na,m as we,o as rs,aG as kt,R as wt,q as Pe,aa as De,T as Je,a7 as Ut,aH as os,aF as ya,z as Ct,Z as Ie,_ as ls,i as ka,u as ds,aI as wa,au as Ca,X as At,a9 as cs,J as us,D as ms,aJ as Aa,at as ps,aK as Sa,ax as Ma,aL as xs}from"./icons-DQFHtVq5.js";import{R as $e,A as Kt,D as at,i as Pa,a as Da}from"./antigravity-responsibility-constants-Bvh4Ybz0.js";import{C as We}from"./checkbox-BrRyK0T3.js";import{C as Ia}from"./confirm-dialog-CP-4T1Wp.js";import{S as St}from"./separator-BV4BKMsB.js";import{S as Ea}from"./searchable-select-BCxZHr8N.js";import{P as Ta}from"./proxy-status-widget-DUqasX3c.js";import"./utils-CzKF5WmX.js";import"./form-utils-CuHzLhJZ.js";import"./code-highlight-D4E79GKQ.js";import"./alert-dialog-CRqbTpjm.js";const se="gemini-3.1-pro-high",Ce="gemini-3.1-pro-low",Ra=Object.freeze({"gemini-3-pro-high":se,"gemini-3.1-pro-high":se,"gemini-3-pro-low":Ce,"gemini-3.1-pro-low":Ce,"gemini-3-pro-preview":se,"gemini-3-pro-preview-customtools":se,"gemini-3.1-pro-preview":se,"gemini-3.1-pro-preview-customtools":se,"gemini-3-1-pro-preview":se,"gemini-3-1-pro-preview-customtools":se}),hs=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"}),La=/^gemini-(\d+(?:[.-]\d+)*)-(pro|flash)-preview(-customtools)?$/i,Oa=["agy/","gcli/"];function J(t){return Ms(t).toLowerCase()}function _a(t){const a=t.trim(),s=a.toLowerCase();for(const i of Oa)if(s.startsWith(i))return a.slice(i.length);return a}function Fa(t){return t.replace(/-customtools$/i,"")}function Ua(t){return Ra[J(t)]}function Xe(t){const a=J(t),s=a.match(La);if(!s)return null;const[,i,n,c]=s;return{normalizedId:a,version:i.split(/[.-]/).map(l=>Number(l)),family:n,customtools:!!c,dottedVersion:i.includes(".")}}function gs(t,a){const s=Math.max(t.length,a.length);for(let i=0;i<s;i+=1){const n=t[i]??0,c=a[i]??0;if(n!==c)return n>c?1:-1}return 0}function Ka(t,a,s){if(t.customtools!==a.customtools)return t.customtools?1:-1;const i=gs(t.version,a.version);if(i!==0)return i>0?-1:1;const n=+(t.dottedVersion===s.dottedVersion),c=+(a.dottedVersion===s.dottedVersion);return n!==c?c-n:t.normalizedId.localeCompare(a.normalizedId)}function Ht(t,a){const s=J(a);return t.find(i=>J(i.id)===s)?.id}function Ha(t,a){const s=Xe(t);return!s||a.length===0?void 0:a.map(n=>{const c=Xe(n.id);return!c||c.family!==s.family?null:{id:n.id,info:c}}).filter(n=>!!n).sort((n,c)=>Ka(n.info,c.info,s))[0]?.id}const xe={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:se,name:"Gemini Pro High",description:"Current Antigravity Gemini Pro route with higher reasoning budget",extendedContext:!0,presetMapping:{default:se,opus:se,sonnet:se,haiku:"gemini-3-1-flash-preview"}},{id:Ce,name:"Gemini Pro Low",description:"Current Antigravity Gemini Pro route with the lighter quota tier",extendedContext:!0,presetMapping:{default:Ce,opus:Ce,sonnet:Ce,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:se,sonnet:se,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.5",name:"GPT-5.5",tier:"paid",description:"Newest Codex-only GPT-5 family model",codexMaxEffort:"xhigh",presetMapping:{default:"gpt-5.5",opus:"gpt-5.5",sonnet:"gpt-5.5",haiku:"gpt-5-codex-mini"}},{id:"gpt-5-codex",name:"GPT-5 Codex",description:"Cross-plan safe Codex default",codexMaxEffort:"xhigh",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",codexMaxEffort:"high",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",codexMaxEffort:"high",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",codexMaxEffort:"high",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",codexMaxEffort:"xhigh",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",codexMaxEffort:"xhigh",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",codexMaxEffort:"xhigh",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",codexMaxEffort:"xhigh",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",codexMaxEffort:"xhigh",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 Se(t,a){if(!t)return;const s=J(a);if(t.provider==="agy"){const l=Ua(s);if(l){const o=t.models.find(r=>r.id===l);if(o)return o}}const i=hs[s.toLowerCase()],n=t.models.find(l=>l.id===s||l.id===i);if(n)return n;const c=Xe(s);if(c)return t.models.map(l=>({model:l,info:Xe(l.id)})).filter(l=>!!(l.info&&l.info.family===c.family)).sort((l,o)=>gs(o.info.version,l.info.version))[0]?.model}function qa(t){if(t==="free")return"free";if(typeof t=="string"&&t.trim().length>0)return"paid"}function za(t,a){const s=xe[t.toLowerCase()];if(!a||a.models.length===0)return s;const i=a.models.map(o=>({id:o.id,owned_by:a.provider})),n=a.models.map(o=>{const r=Se(s,o.id);return{...o,name:o.name||r?.name||o.id,tier:r?.tier??qa(o.tier),description:o.description??r?.description,broken:r?.broken,issueUrl:r?.issueUrl,deprecated:r?.deprecated,deprecationReason:r?.deprecationReason,extendedContext:o.extendedContext??r?.extendedContext,presetMapping:r?.presetMapping}}),c=s?.defaultModel?Ae(s.defaultModel,i):void 0,l=typeof c=="string"&&i.some(o=>J(o.id)===J(c));return{provider:a.provider,displayName:a.displayName||s?.displayName||t,defaultModel:l?c:a.defaultModel,models:n}}function Mt(t){const a={},s=new Set([...Object.keys(xe),...Object.keys(t??{})]);for(const i of s){const n=za(i,t?.[i]);n&&(a[i]=n)}return a}function fs(t,a,s){const i=Se(s,a);return i||Se(xe[t.toLowerCase()],a)}function Ae(t,a=[]){const s=J(t),i=Ha(s,a);if(i)return i;const n=Ht(a,s);if(n)return n;const c=hs[s];return(c?Ht(a,c):void 0)??s}function Ga(t,a=[]){return{default:Ae(t.default,a),opus:Ae(t.opus,a),sonnet:Ae(t.sonnet,a),haiku:Ae(t.haiku,a)}}function Pt(t,a=[]){if(!t)return[];const s=xe[t.provider.toLowerCase()]??t,i=new Set;return s.models.map(n=>{const c=Ae(n.id,a),l=n.presetMapping?Ga(n.presetMapping,a):void 0,o=t.models.find(r=>J(r.id)===J(c));return{...n,id:c,name:o?.name||n.name,description:o?.description??n.description,presetMapping:l}}).filter(n=>i.has(n.id)?!1:(i.add(n.id),!0))}function Ba(t,a,s=[]){const i=t.trim().toLowerCase();if(!a||!i)return[];const n=xe[i]??a,c=Pt(a,s),l=new Set(c.map(m=>J(m.id))),o=new Set(c.map(m=>Se(n,m.id)?.id).filter(m=>!!m).map(m=>J(m))),r=new Set,p=new Set(s.map(m=>J(m.id)));return s.filter(m=>{const j=J(m.id),g=_a(m.id),x=Fa(g),T=Se(n,g)??Se(n,x);if(l.has(J(g))||j!==J(g)&&p.has(J(g)))return!1;const k=J(x);if(k!==J(g)&&p.has(k))return!1;const D=T?J(T.id):k;return T&&o.has(D)||r.has(D)||!T&&i==="agy"?!1:(r.add(D),!0)})}function Va(t,a,s){return fs(t,a,s)?.extendedContext===!0}const nt="ccs-internal-managed";async function $a(){try{const t=await fetch("/api/settings/auth/tokens/raw");return t.ok?(await t.json())?.apiKey?.value??nt:nt}catch{return nt}}async function Wa(t,a){if(a)return a;try{const s=await fetch("/api/cliproxy/catalog");if(!s.ok)return xe[t];const i=await s.json();return Mt(i.catalogs)[t]??xe[t]}catch{return xe[t]}}async function pt(t,a,s){const i=await Wa(t,s);if(!i)return{success:!1};const n=i.models.find(p=>p.id===i.defaultModel)||i.models[0],c=n?.presetMapping||{default:i.defaultModel,opus:i.defaultModel,sonnet:i.defaultModel,haiku:i.defaultModel},l=await $a(),r={env:{ANTHROPIC_BASE_URL:`http://127.0.0.1:${mt}/api/provider/${t}`,ANTHROPIC_AUTH_TOKEN:l,ANTHROPIC_MODEL:c.default,ANTHROPIC_DEFAULT_OPUS_MODEL:c.opus,ANTHROPIC_DEFAULT_SONNET_MODEL:c.sonnet,ANTHROPIC_DEFAULT_HAIKU_MODEL:c.haiku}};try{return{success:(await fetch(`/api/settings/${t}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({settings:r})})).ok,presetName:n?.name||i.defaultModel}}catch{return{success:!1}}}function Qa({currentProgress:t,allSteps:a}){return e.jsx("div",{className:"flex justify-center gap-1 pt-2",children:a.map((s,i)=>e.jsx("div",{className:`w-2 h-2 rounded-full transition-colors ${t>=i?"bg-primary":"bg-muted"}`},s))})}function Ja({providers:t,onSelect:a}){return e.jsx("div",{className:"grid gap-2",children:t.map(s=>e.jsxs("button",{onClick:()=>a(s.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:s.name}),e.jsx("div",{className:"text-xs text-muted-foreground",children:s.description})]}),e.jsx(is,{className:"w-4 h-4 text-muted-foreground"})]},s.id))})}function Xa({selectedProvider:t,providers:a,authCommand:s,isRefreshing:i,isPending:n,onBack:c,onStartAuth:l,onRefresh:o}){const{t:r}=W(),[p,m]=d.useState(!1),j=async g=>{await navigator.clipboard.writeText(g),m(!0),setTimeout(()=>m(!1),2e3)};return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"text-center space-y-3",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:r("setupWizard.authStep.authenticateWith",{provider:a.find(g=>g.id===t)?.name})}),e.jsx(K,{onClick:l,disabled:n,className:"w-full gap-2",size:"lg",children:n?e.jsxs(e.Fragment,{children:[e.jsx(ce,{className:"w-4 h-4 animate-spin"}),r("setupWizard.authStep.authenticating")]}):e.jsxs(e.Fragment,{children:[e.jsx(ke,{className:"w-4 h-4"}),r("setupWizard.authStep.authenticateInBrowser")]})}),n&&e.jsx("p",{className:"text-xs text-muted-foreground",children:r("setupWizard.authStep.completeOAuth")})]}),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:r("setupWizard.authStep.orUseTerminal")})})]}),e.jsx(Wt,{children:e.jsxs(Qt,{className:"p-4 space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(Na,{className:"w-4 h-4"}),r("setupWizard.authStep.runCommandHint")]}),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:s}),e.jsx(K,{variant:"outline",size:"icon",onClick:()=>j(s),children:p?e.jsx(we,{className:"w-4 h-4 text-green-500"}):e.jsx(rs,{className:"w-4 h-4"})})]})]})}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(K,{variant:"ghost",onClick:c,disabled:n,children:[e.jsx(kt,{className:"w-4 h-4 mr-2"}),r("setupWizard.authStep.back")]}),e.jsxs(K,{variant:"outline",onClick:o,disabled:i||n,children:[e.jsx(wt,{className:`w-4 h-4 mr-2 ${i?"animate-spin":""}`}),r(i?"setupWizard.authStep.checking":"setupWizard.authStep.refreshStatus")]})]})]})}function Ya({accounts:t,privacyMode:a,onSelect:s,onAddNew:i,onBack:n}){const{t:c}=W();return e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:c("setupWizard.accountStep.selectAccount",{count:t.length})}),e.jsx("div",{className:"grid gap-2 max-h-[320px] overflow-y-auto pr-1",children:t.map(l=>{const o=Jt(l.id,l.email,l.tokenFile),r=l.provider?.toLowerCase()==="codex"?Xt(o):null;return e.jsxs("button",{type:"button",onClick:()=>s(l),className:"flex items-center justify-between p-3 border rounded-lg hover:bg-muted/50 transition-colors text-left",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-8 h-8 rounded-full bg-muted flex items-center justify-center",children:e.jsx(Pe,{className:"w-4 h-4 text-muted-foreground"})}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("div",{className:X("font-medium",a&&gt),children:o.email}),e.jsxs("div",{className:"flex items-center gap-1.5 flex-wrap",children:[r?.label?e.jsx(H,{variant:"outline",className:X("text-[10px] h-4 px-1.5 border-transparent",r.audience==="business"?"bg-sky-500/12 text-sky-700 dark:text-sky-300":r.audience==="free"?"bg-slate-200/70 text-slate-700 dark:bg-slate-700/40 dark:text-slate-200":"bg-emerald-500/12 text-emerald-700 dark:text-emerald-300"),children:r.label}):o.audienceLabel?e.jsx(H,{variant:"outline",className:X("text-[10px] h-4 px-1.5 border-transparent",o.audience==="business"?"bg-sky-500/12 text-sky-700 dark:text-sky-300":o.audience==="free"?"bg-slate-200/70 text-slate-700 dark:bg-slate-700/40 dark:text-slate-200":"bg-emerald-500/12 text-emerald-700 dark:text-emerald-300"),children:o.audienceLabel}):null,!r?.label&&o.detailLabel&&e.jsx(H,{variant:"outline",className:"text-[10px] h-4 px-1.5",children:o.detailLabel}),l.isDefault&&e.jsx("span",{className:"text-xs text-muted-foreground",children:c("setupWizard.accountStep.defaultAccount")})]})]})]}),e.jsx(is,{className:"w-4 h-4 text-muted-foreground"})]},l.id)})}),e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"absolute inset-0 flex items-center",children:e.jsx("span",{className:"w-full border-t"})}),e.jsx("div",{className:"relative flex justify-center text-xs uppercase",children:e.jsx("span",{className:"bg-background px-2 text-muted-foreground",children:c("setupWizard.accountStep.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:i,children:[e.jsx("div",{className:"w-8 h-8 rounded-full bg-primary/10 flex items-center justify-center shrink-0",children:e.jsx(ke,{className:"w-4 h-4 text-primary"})}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-primary",children:c("setupWizard.accountStep.addNewAccount")}),e.jsx("div",{className:"text-xs text-muted-foreground",children:c("setupWizard.accountStep.addNewAccountDesc")})]})]}),e.jsx("div",{className:"flex items-center justify-between pt-2",children:e.jsxs(K,{variant:"ghost",onClick:n,children:[e.jsx(kt,{className:"w-4 h-4 mr-2"}),c("setupWizard.accountStep.back")]})})]})}const qt="__custom__";function Za({selectedProvider:t,catalog:a,selectedAccount:s,variantName:i,modelName:n,isPending:c,privacyMode:l,onVariantNameChange:o,onModelChange:r,onBack:p,onSkip:m,onCreate:j}){const{t:g}=W(),x=a||xe[t],T=x?.models||[],k=n&&!T.some(f=>f.id===n),[D,A]=d.useState(k),C=t==="agy"&&n.trim().length>0?ue(n):!1,y=s?Jt(s.id,s.email,s.tokenFile):null,w=t==="codex"&&y?Xt(y):null,h=f=>{f===qt?(A(!0),r("")):(A(!1),r(f))};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(Pe,{className:"w-4 h-4"}),e.jsxs("div",{className:"space-y-1",children:[e.jsxs("span",{children:[g("setupVariant.using")," ",e.jsx("span",{className:X(l&&gt),children:y?.email})]}),(y?.audienceLabel||y?.detailLabel)&&e.jsxs("div",{className:"flex items-center gap-1.5 flex-wrap",children:[w?.label?e.jsx(H,{variant:"outline",className:X("text-[10px] h-4 px-1.5 border-transparent",w.audience==="business"?"bg-sky-500/12 text-sky-700 dark:text-sky-300":w.audience==="free"?"bg-slate-200/70 text-slate-700 dark:bg-slate-700/40 dark:text-slate-200":"bg-emerald-500/12 text-emerald-700 dark:text-emerald-300"),children:w.label}):y?.audienceLabel?e.jsx(H,{variant:"outline",className:X("text-[10px] h-4 px-1.5 border-transparent",y.audience==="business"?"bg-sky-500/12 text-sky-700 dark:text-sky-300":y.audience==="free"?"bg-slate-200/70 text-slate-700 dark:bg-slate-700/40 dark:text-slate-200":"bg-emerald-500/12 text-emerald-700 dark:text-emerald-300"),children:y.audienceLabel}):null,!w?.label&&y?.detailLabel&&e.jsx(H,{variant:"outline",className:"text-[10px] h-4 px-1.5",children:y.detailLabel})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Y,{htmlFor:"variant-name",children:g("setupVariant.variantNameRequired")}),e.jsx(de,{id:"variant-name",value:i,onChange:f=>o(f.target.value),placeholder:g("setupVariant.variantNamePlaceholder")}),e.jsxs("div",{className:"text-xs text-muted-foreground",children:[g("setupVariant.invokeHintPrefix")," ccs ",i||"<name>",' "prompt"']})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Y,{children:g("setupVariant.model")}),D?e.jsxs("div",{className:"space-y-2",children:[e.jsx(de,{value:n,onChange:f=>r(f.target.value),placeholder:g("setupVariant.modelPlaceholder")}),C&&e.jsx("p",{className:"text-xs text-destructive",children:g("providerEditor.agyDenylist")}),e.jsx("button",{type:"button",className:"text-xs text-primary hover:underline",onClick:()=>{A(!1),t==="agy"&&ue(n)&&r("")},children:g("setupVariant.choosePresetInstead")})]}):e.jsxs(qe,{value:T.some(f=>f.id===n)?n:"",onValueChange:h,children:[e.jsx(ze,{children:e.jsx(Ge,{placeholder:g("setupVariant.selectModel")})}),e.jsxs(Be,{children:[T.map(f=>e.jsx(ye,{value:f.id,children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{children:f.name}),f.description&&e.jsxs("span",{className:"text-xs text-muted-foreground",children:["- ",f.description]})]})},f.id)),e.jsx(ye,{value:qt,children:e.jsx("span",{className:"text-primary",children:g("setupVariant.customModelName")})})]})]}),e.jsx("div",{className:"text-xs text-muted-foreground",children:D?g("setupVariant.enterAnyModel"):g("setupVariant.defaultModel",{model:x?.defaultModel||g("setupVariant.providerDefault")})})]}),e.jsxs("div",{className:"flex items-center justify-between pt-2",children:[e.jsxs(K,{variant:"ghost",onClick:p,children:[e.jsx(kt,{className:"w-4 h-4 mr-2"}),g("setupVariant.back")]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(K,{variant:"ghost",onClick:m,children:g("setupVariant.skip")}),e.jsx(K,{onClick:j,disabled:!i||c||C,children:g(c?"setupVariant.creating":"setupVariant.createVariant")})]})]}),e.jsx("p",{className:"text-xs text-center text-muted-foreground",children:g("setupVariant.skipHint")})]})}function en({variantName:t,onClose:a}){const{t:s}=W();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(we,{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:s("setupWizard.successStep.title")}),e.jsx("div",{className:"text-sm text-muted-foreground",children:s("setupWizard.successStep.subtitle")})]}),e.jsx(Wt,{children:e.jsxs(Qt,{className:"p-4 space-y-2",children:[e.jsx("div",{className:"text-sm text-muted-foreground",children:s("setupWizard.successStep.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(K,{onClick:a,className:"w-full",children:s("setupWizard.successStep.done")})]})}function tn({open:t,onClose:a}){const[s,i]=d.useState("provider"),[n,c]=d.useState(""),[l,o]=d.useState(null),[r,p]=d.useState(""),[m,j]=d.useState(""),[g,x]=d.useState(!1),[T,k]=d.useState(!1),{data:D,refetch:A}=Yt(),{data:C}=Zt(),y=Ps(),w=Ds(),h=Is(),{privacyMode:f}=es(),I=D?.authStatus.find(R=>R.provider===n),u=d.useMemo(()=>I?.accounts||[],[I?.accounts]),E=d.useMemo(()=>Mt(C?.catalogs),[C?.catalogs]),N=!!C;d.useEffect(()=>{if(!t){const R=setTimeout(()=>{i("provider"),c(""),o(null),p(""),j(""),k(!1)},0);return()=>clearTimeout(R)}},[t]),d.useEffect(()=>{if(s==="auth"&&u.length>0&&!T){const R=setTimeout(()=>{i("account")},0);return()=>clearTimeout(R)}},[s,u,T]);const z=async()=>{x(!0),await A(),x(!1)},P=()=>{const R=(I?.accounts?.length||0)===0;w.mutate({provider:n},{onSuccess:async b=>{if(R){const Q=await pt(n,void 0,N?E[n]:void 0);Q.success&&Q.presetName?B.success(`Applied "${Q.presetName}" preset`):Q.success||B.warning(me.t("commonToast.accountAddedPresetFailed"))}b.account&&(o(b.account),i("variant")),A()}})},L=R=>{c(R),(D?.authStatus.find(te=>te.provider===R)?.accounts||[]).length===0?i("auth"):i("account")},_=R=>{o(R),i("variant")},G=async()=>{if(!(!r||!n))try{await y.mutateAsync({name:r,provider:n,model:m||void 0,account:l?.id}),i("success")}catch(R){console.error("Failed to create variant:",R)}},V=`ccs ${n} --auth --add`,q=Ts(s),S=R=>{if(!R&&(w.isPending&&n&&h.mutate(n),s==="success"||s==="provider")){a();return}};return e.jsx(ft,{open:t,onOpenChange:S,children:e.jsxs(vt,{className:"sm:max-w-lg",onPointerDownOutside:R=>{s!=="success"&&s!=="provider"&&R.preventDefault()},onEscapeKeyDown:R=>{(w.isPending||y.isPending)&&R.preventDefault()},children:[e.jsxs(jt,{children:[e.jsxs(bt,{className:"flex items-center gap-2",children:[e.jsx(De,{className:"w-5 h-5 text-primary"}),me.t("setupWizard.title")]}),e.jsxs(ts,{children:[s==="provider"&&me.t("setupWizard.stepProviderDesc"),s==="auth"&&me.t("setupWizard.stepAuthDesc"),s==="account"&&me.t("setupWizard.stepAccountDesc"),s==="variant"&&me.t("setupWizard.stepVariantDesc"),s==="success"&&me.t("setupWizard.stepSuccessDesc")]})]}),e.jsxs("div",{className:"space-y-4 py-4",children:[s==="provider"&&e.jsx(Ja,{providers:It,onSelect:L}),s==="auth"&&e.jsx(Xa,{selectedProvider:n,providers:It,authCommand:V,isRefreshing:g,isPending:w.isPending,onBack:()=>i("provider"),onStartAuth:P,onRefresh:z}),s==="account"&&e.jsx(Ya,{accounts:u,privacyMode:f,onSelect:_,onAddNew:()=>{k(!0),i("auth")},onBack:()=>i("provider")}),s==="variant"&&e.jsx(Za,{selectedProvider:n,catalog:E[n],selectedAccount:l,variantName:r,modelName:m,isPending:y.isPending,privacyMode:f,onVariantNameChange:p,onModelChange:j,onBack:()=>u.length>0?i("account"):i("provider"),onSkip:a,onCreate:G}),s==="success"&&e.jsx(en,{variantName:r,onClose:a})]}),e.jsx(Qa,{currentProgress:q,allSteps:Es})]})})}const sn=3e3,an=300*1e3,nn=3;function it(t){t.invalidateQueries({queryKey:["cliproxy-catalog"]}),t.invalidateQueries({queryKey:["cliproxy-models"]})}async function rt(t){const a=await t.text();if(!a)return{};try{return JSON.parse(a)}catch{const s=t.status>=400?`Request failed with status ${t.status}`:void 0;return s?{error:s}:{}}}const fe={provider:null,isAuthenticating:!1,error:null,authUrl:null,oauthState:null,isSubmittingCallback:!1,isDeviceCodeFlow:!1};function rn(){const{t}=W(),[a,s]=d.useState(fe),i=d.useRef(fe),n=d.useRef(0),c=d.useRef(null),l=d.useRef(null),o=d.useRef(0),r=d.useRef(0),p=d.useRef(!1),m=ht(),j=d.useCallback(A=>A===n.current,[]),g=d.useCallback(()=>{l.current&&(clearInterval(l.current),l.current=null),r.current=0},[]);d.useEffect(()=>()=>{c.current?.abort(),g(),p.current=!1},[g]),d.useEffect(()=>{i.current=a},[a]);const x=d.useCallback(async(A,C,y)=>{if(j(y)){if(Date.now()-o.current>an){g(),j(y)&&s(w=>({...w,isAuthenticating:!1,error:t("toasts.providerAuthTimeout")}));return}try{const w=await fetch(`/api/cliproxy/auth/${A}/status?state=${encodeURIComponent(C)}`);if(!j(y))return;const h=await w.json();if(r.current=0,h.status==="ok"){if(!(typeof h.account=="object"&&h.account!==null)){g();const I=t("toasts.providerAccountRegistrationFailed");B.error(I),s(u=>({...u,isAuthenticating:!1,error:I}));return}g(),m.invalidateQueries({queryKey:["cliproxy-auth"]}),m.invalidateQueries({queryKey:["cliproxy-accounts"]}),m.invalidateQueries({queryKey:["account-quota"]}),it(m),B.success(t("toasts.providerAuthSuccess",{provider:A})),p.current=!1,s(fe)}else if(h.status==="auth_url"){const f=h.url||h.auth_url;f&&(s(I=>({...I,authUrl:f})),p.current||(p.current=!0,window.open(f,"_blank")))}else if(h.status==="device_code"){g();const f=h.user_code&&h.verification_url?`Open ${h.verification_url} and enter code: ${h.user_code}`:"Switch to Device Code method and try again.";B.error(t("toasts.providerDeviceCodeInCallback")),s(I=>({...I,isAuthenticating:!1,error:f}))}else if(h.status==="error"){g();const f=h.error||"Authentication failed";B.error(f),s(I=>({...I,isAuthenticating:!1,error:f}))}}catch(w){if(!j(y)||(r.current+=1,r.current<nn))return;g();const h=w instanceof Error&&w.message.trim().length>0?w.message:t("toasts.providerLostStatusEndpoint");B.error(h),s(f=>({...f,isAuthenticating:!1,error:h}))}}},[j,m,g,t]),T=d.useCallback(async(A,C)=>{if(!Qe(A)){s({...fe,error:t("toasts.providerUnknown",{provider:A})});return}c.current?.abort(),g(),p.current=!1,r.current=0;const y=new AbortController,w=n.current+1;n.current=w,c.current=y;const f=(C?.flowType||(ss(A)?"device_code":"authorization_code"))==="device_code",I=C?.startEndpoint||(f?"start":"start-url"),u={nickname:C?.nickname,kiroMethod:C?.kiroMethod,kiroIDCStartUrl:C?.kiroIDCStartUrl,kiroIDCRegion:C?.kiroIDCRegion,kiroIDCFlow:C?.kiroIDCFlow,gitlabAuthMode:C?.gitlabAuthMode,gitlabBaseUrl:C?.gitlabBaseUrl,gitlabPersonalAccessToken:C?.gitlabPersonalAccessToken,riskAcknowledgement:C?.riskAcknowledgement};s({provider:A,isAuthenticating:!0,error:null,authUrl:null,oauthState:null,isSubmittingCallback:!1,isDeviceCodeFlow:f});try{if(I==="start")fetch(`/api/cliproxy/auth/${A}/start`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(u),signal:y.signal}).then(async E=>{if(!j(w))return;const N=await rt(E);if(!j(w))return;const z=N.success===!0,P=typeof N.account=="object"&&N.account!==null;if(E.ok&&z&&P)m.invalidateQueries({queryKey:["cliproxy-auth"]}),m.invalidateQueries({queryKey:["cliproxy-accounts"]}),m.invalidateQueries({queryKey:["account-quota"]}),it(m),p.current=!1,s(fe);else{const L=typeof N.error=="string"?N.error:t(z?"toasts.providerAccountRegistrationFailed":"auth.loginFailed");B.error(L),s(_=>({..._,isAuthenticating:!1,error:L}))}}).catch(E=>{if(!j(w)||E instanceof Error&&E.name==="AbortError")return;const N=E instanceof Error?E.message:"Authentication failed";B.error(N),s(z=>({...z,isAuthenticating:!1,error:N}))});else{const E=await fetch(`/api/cliproxy/auth/${A}/start-url`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(u),signal:y.signal});if(!j(w))return;const N=await rt(E);if(!j(w))return;const z=N.success===!0;if(!E.ok||!z){const _=typeof N.error=="string"?N.error:t("toasts.providerStartOAuthFailed");throw new Error(_)}const P=typeof N.authUrl=="string"?N.authUrl:null,L=typeof N.state=="string"?N.state:null;if(s(_=>({..._,authUrl:P,oauthState:L})),P&&(p.current=!0,window.open(P,"_blank")),L){if(o.current=Date.now(),!P){if(await x(A,L,w),!j(w))return;const _=i.current;if(!_.isAuthenticating||_.provider!==A)return}l.current=setInterval(()=>{x(A,L,w)},sn)}}}catch(E){if(!j(w))return;if(E instanceof Error&&E.name==="AbortError"){p.current=!1,s(fe);return}const N=E instanceof Error?E.message:t("auth.loginFailed");B.error(N),s(z=>({...z,isAuthenticating:!1,error:N}))}},[j,x,g,m,t]),k=d.useCallback(()=>{const A=a.provider;n.current+=1,c.current?.abort(),g(),p.current=!1,s(fe),A&&Ve.cliproxy.auth.cancel(A).catch(()=>{})},[a.provider,g]),D=d.useCallback(async A=>{if(!a.provider)return;const C=n.current,y=a.provider;s(w=>({...w,isSubmittingCallback:!0,error:null}));try{const w=await fetch(`/api/cliproxy/auth/${y}/submit-callback`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({redirectUrl:A})});if(!j(C))return;const h=await rt(w);if(!j(C))return;const f=h.success===!0,I=h.status==="wait",u=typeof h.account=="object"&&h.account!==null;if(w.ok&&I)s(E=>({...E,isSubmittingCallback:!1,error:null}));else if(w.ok&&f&&u)g(),m.invalidateQueries({queryKey:["cliproxy-auth"]}),m.invalidateQueries({queryKey:["cliproxy-accounts"]}),m.invalidateQueries({queryKey:["account-quota"]}),it(m),B.success(t("toasts.providerAuthSuccess",{provider:y})),s(fe);else{const E=typeof h.error=="string"?h.error:t(f?"toasts.providerAccountRegistrationFailed":"toasts.providerCallbackFailed");throw new Error(E)}}catch(w){if(!j(C))return;const h=w instanceof Error?w.message:t("toasts.providerSubmitCallbackFailed");B.error(h),s(f=>({...f,isSubmittingCallback:!1,error:h}))}},[j,a.provider,m,g,t]);return d.useMemo(()=>({...a,startAuth:T,cancelAuth:k,submitCallback:D}),[a,T,k,D])}function xt({className:t,compact:a=!1,showAcknowledgement:s=!1,acknowledgementPhrase:i=$e,acknowledgementText:n="",onAcknowledgementTextChange:c,disabled:l=!1,showProxySettingsLink:o=!1}){const{t:r}=W(),p=r("accountSafetyWarning.title"),m=r("accountSafetyWarning.subtitle"),j=r("accountSafetyWarning.firstLine"),g=r("accountSafetyWarning.secondLine"),x="https://github.com/kaitranntt/ccs/issues/509",T=r("accountSafetyWarning.issueLabel"),k=r("accountSafetyWarning.proxySettingsLabel");return a?e.jsx("section",{role:"alert",className:X("border-b border-amber-200/70 bg-amber-50/45 dark:bg-amber-950/5",t),children:e.jsxs("div",{className:"flex flex-col gap-3 px-6 py-3 lg:flex-row lg:items-start lg:justify-between",children:[e.jsxs("div",{className:"min-w-0 flex items-start gap-3",children:[e.jsx("div",{className:"mt-0.5 inline-flex h-6 w-6 items-center justify-center rounded-md bg-amber-500/12 text-amber-700 dark:text-amber-300",children:e.jsx(Je,{className:"h-3.5 w-3.5"})}),e.jsxs("div",{className:"min-w-0 space-y-1",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("p",{className:"text-xs font-semibold leading-5",children:p}),e.jsx("p",{className:"text-[11px] text-muted-foreground",children:m})]}),e.jsx("p",{className:"text-xs leading-5 text-muted-foreground",children:j}),e.jsx("p",{className:"text-xs font-medium leading-5 text-amber-900 dark:text-amber-200",children:g})]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2 lg:justify-end",children:[e.jsxs("a",{href:x,target:"_blank",rel:"noreferrer",className:"inline-flex items-center gap-1 rounded-md border border-amber-500/25 bg-background/90 px-2 py-1 text-[11px] font-medium text-amber-800 transition-colors hover:bg-amber-500/10 dark:text-amber-200",children:[T,e.jsx(ke,{className:"h-3 w-3"})]}),o?e.jsxs("a",{href:"/settings?tab=proxy",className:"inline-flex items-center gap-1 rounded-md border border-amber-500/25 bg-background/90 px-2 py-1 text-[11px] font-medium text-amber-800 transition-colors hover:bg-amber-500/10 dark:text-amber-200",children:[e.jsx(Ut,{className:"h-3 w-3"}),k]}):null,e.jsx(H,{variant:"outline",className:"border-amber-500/40 text-[10px] text-amber-700 dark:text-amber-300",children:"High Risk"})]})]})}):e.jsxs("section",{role:"alert",className:X("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(Je,{className:"h-4 w-4"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-semibold leading-5",children:p}),e.jsx("p",{className:"text-xs text-muted-foreground",children:m})]})]}),e.jsx(H,{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:j}),e.jsx("p",{className:"font-medium text-amber-900 dark:text-amber-200",children:g}),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:x,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:[T,e.jsx(ke,{className:"h-3.5 w-3.5"})]}),o&&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(Ut,{className:"h-3.5 w-3.5"}),k]}),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&&c&&e.jsxs("div",{className:"rounded-lg border border-amber-500/25 bg-amber-500/5 p-2.5",children:[e.jsxs(Y,{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:i})]}),e.jsx(de,{id:"account-risk-ack-text",value:n,onChange:D=>c(D.target.value),placeholder:i,disabled:l,className:"mt-2 font-mono text-xs"})]})]})]})}function on({className:t,value:a,onChange:s,disabled:i=!1}){const{t:n}=W(),c=[a.reviewedIssue509,a.understandsBanRisk,a.acceptsFullResponsibility,a.typedPhrase.trim().replace(/\s+/g," ").toUpperCase()===Kt].filter(Boolean).length,l=c/4*100,o=r=>{s({...a,...r})};return e.jsxs("section",{role:"alert",className:X("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(Je,{className:"h-4 w-4"})}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-sm font-semibold leading-5",children:n("antigravityChecklist.title")}),e.jsx("p",{className:"text-xs text-muted-foreground",children:n("antigravityChecklist.subtitle")})]})]}),e.jsx(H,{variant:"outline",className:"border-rose-500/40 text-rose-700 dark:text-rose-300",children:n("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:n("antigravityChecklist.completion")}),e.jsx("span",{children:n("antigravityChecklist.stepsCount",{current:c})})]}),e.jsx(Rs,{value:l,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(We,{id:"agy-step-reviewed-issue",checked:a.reviewedIssue509,onCheckedChange:r=>o({reviewedIssue509:!!r}),disabled:i}),e.jsx(Y,{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(We,{id:"agy-step-understands-risk",checked:a.understandsBanRisk,onCheckedChange:r=>o({understandsBanRisk:!!r}),disabled:i}),e.jsx(Y,{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(We,{id:"agy-step-accept-responsibility",checked:a.acceptsFullResponsibility,onCheckedChange:r=>o({acceptsFullResponsibility:!!r}),disabled:i}),e.jsx(Y,{htmlFor:"agy-step-accept-responsibility",className:"text-xs leading-5",children:"Step 3: I accept full responsibility. CCS is not liable for suspension, bans, or access loss."})]})]}),e.jsxs("div",{className:"space-y-2 rounded-lg border border-amber-500/25 bg-amber-500/5 p-3",children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-xs font-medium text-amber-800 dark:text-amber-200",children:[e.jsx(os,{className:"h-3.5 w-3.5"}),"Step 4: Type exact phrase to continue"]}),e.jsx(de,{value:a.typedPhrase,onChange:r=>o({typedPhrase:r.target.value}),placeholder:Kt,disabled:i,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(ke,{className:"h-3.5 w-3.5"})]})})]})]})}function ln(t){return t.trim().replace(/\s+/g," ").toUpperCase()}function dn({open:t,onClose:a,provider:s,displayName:i,catalog:n,isFirstAccount:c=!1}){const[l,o]=d.useState(""),[r,p]=d.useState(""),[m,j]=d.useState(!1),[g,x]=d.useState(null),[T,k]=d.useState(""),[D,A]=d.useState(at),[C,y]=d.useState(!1),[w,h]=d.useState(!1),[f,I]=d.useState(Et),[u,E]=d.useState(""),[N,z]=d.useState(""),[P,L]=d.useState(Tt),[_,G]=d.useState("oauth"),[V,q]=d.useState(""),[S,R]=d.useState(""),{t:b}=W(),Q=d.useRef(!1),te=d.useRef(0),ne=d.useRef(!1),U=rn(),ae=Ls(),$=s==="kiro",Z=s==="gitlab",ie=s==="agy"||s==="gemini",v=s==="gemini"&&!C,O=s==="agy"&&!C,be=ie&&w,Ee=Pa(D),Te=ln(T)===$e,Ye=ss(s),Re=Os(f),he=$&&f==="idc",Ne=$&&Fs(f),Me=$?_s(f,P):void 0,Ze=$?Ks(f):void 0,et=$?Me==="device_code":Ye,re=U.isAuthenticating||ae.isPending,Le=l.trim(),Oe=u.trim(),_e=N.trim(),Fe=V.trim(),F=S.trim(),ee=g||U.error,oe=d.useCallback(async()=>{const M=await fetch("/api/settings/auth/antigravity-risk");if(!M.ok)throw new Error("Failed to load power user mode setting");return(await M.json()).antigravityAckBypass===!0},[]),ge=d.useCallback(async({pendingMessage:M=null,disabledMessage:pe=null}={})=>{const st=++te.current;h(!0),M!==null&&x(M);try{const Ue=await oe();return te.current!==st||(y(Ue),pe?x(Ue?null:pe):M!==null&&x(null)),Ue}catch{return te.current!==st||(y(!1),x(pe??b("addAccountDialog.powerUserLoadFailed")),ne.current||(ne.current=!0,B.error(b("addAccountDialog.powerUserLoadFailed")))),!1}finally{te.current===st&&h(!1)}},[oe,b]),tt=()=>{o(""),p(""),j(!1),x(null),k(""),A(at),y(!1),h(!1),I(Et),E(""),z(""),L(Tt),G("oauth"),q(""),R(""),te.current+=1,ne.current=!1,Q.current=!1,a()};d.useEffect(()=>{t&&(k(""),A(at),x(null))},[s,t]),d.useEffect(()=>()=>{te.current+=1},[]),d.useEffect(()=>{if(!t||!ie){te.current+=1,y(!1),h(!1);return}ge()},[t,s,ie,ge]),d.useEffect(()=>{if(!t||s!=="agy"||!U.error||!C)return;const M=U.error.toLowerCase();(M.includes("agy_risk_ack_required")||M.includes("responsibility acknowledgement")||M.includes("responsibility checklist"))&&ge({pendingMessage:b("addAccountDialog.powerUserLoading"),disabledMessage:b("addAccountDialog.powerUserUnavailableRetry")})},[U.error,t,C,s,ge,b]),d.useEffect(()=>{!U.isAuthenticating&&!U.error&&U.provider===null&&t&&Q.current&&(Q.current=!1,(async()=>{try{const pe=await pt(s,void 0,n);pe.success&&pe.presetName&&c&&B.success(`Applied "${pe.presetName}" preset`)}catch{}tt()})())},[U.isAuthenticating,U.error,U.provider]);const Dt=()=>{U.cancelAuth(),tt()},ys=async()=>{U.authUrl&&(await navigator.clipboard.writeText(U.authUrl),j(!0),setTimeout(()=>j(!1),2e3))},ks=()=>{r.trim()&&U.submitCallback(r.trim())},ws=()=>{if(be){x(b("addAccountDialog.powerUserLoading"));return}if(O&&!Ee){x("Complete all Antigravity responsibility steps before authenticating this provider.");return}if(v&&!Te){x(`Type "${$e}" to acknowledge the account safety warning before authenticating this provider.`);return}if(x(null),he&&!Oe){x("IDC Start URL is required for Kiro IAM Identity Center login.");return}if(Z&&_==="pat"&&!F){x(b("addAccountDialog.gitlabPatRequired"));return}Q.current=!0,U.startAuth(s,{nickname:Le||void 0,kiroMethod:$?f:void 0,kiroIDCStartUrl:he?Oe:void 0,kiroIDCRegion:he&&_e?_e:void 0,kiroIDCFlow:he?P:void 0,gitlabAuthMode:Z?_:void 0,gitlabBaseUrl:Z&&Fe?Fe:void 0,gitlabPersonalAccessToken:Z&&_==="pat"&&F?F:void 0,flowType:$?Me:void 0,startEndpoint:$?Ze:Z&&_==="pat"?"start":void 0,riskAcknowledgement:O?{version:Da,reviewedIssue509:D.reviewedIssue509,understandsBanRisk:D.understandsBanRisk,acceptsFullResponsibility:D.acceptsFullResponsibility,typedPhrase:D.typedPhrase}:void 0})},Cs=()=>{Q.current=!0,ae.mutate(void 0,{onSuccess:async()=>{const M=await pt("kiro",void 0,n);M.success&&M.presetName&&c&&B.success(`Applied "${M.presetName}" preset`),tt()}})},As=M=>{M||Dt()},le=U.isAuthenticating;return e.jsx(ft,{open:t,onOpenChange:As,children:e.jsxs(vt,{className:"sm:max-w-md",onInteractOutside:M=>{le&&M.preventDefault()},children:[e.jsxs(jt,{children:[e.jsx(bt,{children:b("addAccountDialog.title",{displayName:i})}),e.jsx(ts,{children:b($?"addAccountDialog.descKiro":et?"addAccountDialog.descDeviceCode":"addAccountDialog.descOauth")})]}),e.jsxs("div",{className:"space-y-4 py-4",children:[O&&!le&&e.jsx(on,{value:D,onChange:M=>{A(M),x(null)},disabled:re}),ie&&C&&!le&&e.jsxs("div",{className:"rounded-lg border border-amber-400/35 bg-amber-50/70 p-3 text-xs text-amber-900 dark:border-amber-800/60 dark:bg-amber-950/25 dark:text-amber-100",children:[e.jsxs("div",{className:"mb-1.5 flex items-center gap-1.5 font-semibold",children:[e.jsx(os,{className:"h-3.5 w-3.5"}),b("addAccountDialog.powerUserEnabled")]}),b("addAccountDialog.powerUserSkipped")]}),v&&!le&&e.jsx(xt,{showAcknowledgement:!0,acknowledgementPhrase:$e,acknowledgementText:T,onAcknowledgementTextChange:M=>{k(M),x(null)},disabled:re}),$&&!le&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(Y,{htmlFor:"kiro-auth-method",children:b("addAccountDialog.authMethod")}),e.jsxs(qe,{value:f,onValueChange:M=>{I(M),x(null)},children:[e.jsx(ze,{id:"kiro-auth-method",children:e.jsx(Ge,{placeholder:b("addAccountDialog.selectKiroAuthMethod")})}),e.jsx(Be,{children:Us.map(M=>e.jsx(ye,{value:M.id,children:M.label},M.id))})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:Re.description}),Ne&&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."]})]}),he&&!le&&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(Y,{htmlFor:"kiro-idc-start-url",children:"IDC Start URL"}),e.jsx(de,{id:"kiro-idc-start-url",value:u,onChange:M=>{E(M.target.value),x(null)},placeholder:"https://d-xxx.awsapps.com/start",disabled:re}),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(Y,{htmlFor:"kiro-idc-region",children:"IDC Region"}),e.jsx(de,{id:"kiro-idc-region",value:N,onChange:M=>{z(M.target.value),x(null)},placeholder:"us-east-1",disabled:re}),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(Y,{htmlFor:"kiro-idc-flow",children:"IDC Flow"}),e.jsxs(qe,{value:P,onValueChange:M=>{L(M),x(null)},children:[e.jsx(ze,{id:"kiro-idc-flow",children:e.jsx(Ge,{placeholder:"{/* TODO i18n: missing key */}Select IDC flow"})}),e.jsxs(Be,{children:[e.jsx(ye,{value:"authcode",children:"Authorization Code"}),e.jsx(ye,{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."})]})]}),Z&&!le&&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(Y,{htmlFor:"gitlab-auth-mode",children:b("addAccountDialog.gitlabAuthMethod")}),e.jsxs(qe,{value:_,onValueChange:M=>{G(M),x(null)},children:[e.jsx(ze,{id:"gitlab-auth-mode",children:e.jsx(Ge,{placeholder:b("addAccountDialog.selectGitlabAuthMethod")})}),e.jsxs(Be,{children:[e.jsx(ye,{value:"oauth",children:b("addAccountDialog.gitlabAuthOAuth")}),e.jsx(ye,{value:"pat",children:b("addAccountDialog.gitlabAuthPat")})]})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:b("addAccountDialog.gitlabAuthHint")})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Y,{htmlFor:"gitlab-base-url",children:b("addAccountDialog.gitlabUrl")}),e.jsx(de,{id:"gitlab-base-url",value:V,onChange:M=>{q(M.target.value),x(null)},placeholder:b("addAccountDialog.gitlabUrlPlaceholder"),disabled:re}),e.jsx("p",{className:"text-xs text-muted-foreground",children:b("addAccountDialog.gitlabUrlHint")})]}),_==="pat"&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(Y,{htmlFor:"gitlab-pat",children:b("addAccountDialog.gitlabPat")}),e.jsx(de,{id:"gitlab-pat",type:"password",value:S,onChange:M=>{R(M.target.value),x(null)},placeholder:b("addAccountDialog.gitlabPatPlaceholder"),disabled:re}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[b("addAccountDialog.gitlabPatHint")," ",e.jsx("span",{className:"font-mono",children:"api"})," and"," ",e.jsx("span",{className:"font-mono",children:"read_user"})," scopes."]})]})]}),!le&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(Y,{htmlFor:"nickname",children:b("addAccountDialog.nicknameOptional")}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Pe,{className:"w-4 h-4 text-muted-foreground"}),e.jsx(de,{id:"nickname",value:l,onChange:M=>{o(M.target.value),x(null)},placeholder:b("addAccountDialog.nicknamePlaceholder"),disabled:re,className:"flex-1"})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:b("addAccountDialog.nicknameOptionalHint")})]}),le&&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(ce,{className:"w-4 h-4 inline mr-2 animate-spin"}),b("addAccountDialog.waitingForAuth")]}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:U.isDeviceCodeFlow?b("addAccountDialog.deviceCodeHint"):Ne?"Complete sign-in in your browser. If it does not return automatically, paste the final kiro:// callback URL below.":b("addAccountDialog.browserHint")})]}),U.authUrl&&!U.isDeviceCodeFlow&&e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(Y,{className:"text-xs",children:b("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:U.authUrl}),e.jsxs("div",{className:"flex gap-2 mt-2",children:[e.jsx(K,{variant:"outline",size:"sm",onClick:ys,children:m?e.jsxs(e.Fragment,{children:[e.jsx(we,{className:"w-3 h-3 mr-1"}),b("addAccountDialog.copied")]}):e.jsxs(e.Fragment,{children:[e.jsx(rs,{className:"w-3 h-3 mr-1"}),b("addAccountDialog.copy")]})}),e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>{if(!U.authUrl)return;const M=window.open(U.authUrl,"_blank");(!M||M.closed||typeof M.closed>"u")&&B.warning(b("addAccountDialog.popupBlocked"),{duration:5e3})},children:[e.jsx(ke,{className:"w-3 h-3 mr-1"}),b("addAccountDialog.open")]})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Y,{htmlFor:"callback-url",className:"text-xs",children:Ne?"Browser did not return? Paste the final kiro:// callback URL:":b("addAccountDialog.redirectPasteLabel")}),e.jsx(de,{id:"callback-url",value:r,onChange:M=>p(M.target.value),placeholder:Ne?"kiro://kiro.kiroAgent/authenticate-success?code=...&state=...":b("addAccountDialog.callbackPlaceholder"),className:"font-mono text-xs"}),e.jsx(K,{variant:"secondary",size:"sm",onClick:ks,disabled:!r.trim()||U.isSubmittingCallback,children:U.isSubmittingCallback?e.jsxs(e.Fragment,{children:[e.jsx(ce,{className:"w-3 h-3 mr-1 animate-spin"}),b("addAccountDialog.submitting")]}):b("addAccountDialog.submitCallback")})]})]}),!U.authUrl&&!U.isDeviceCodeFlow&&e.jsx("p",{className:"text-xs text-center text-muted-foreground",children:Ne?"Preparing the Kiro sign-in URL. If it does not open automatically, it will appear here shortly.":b("addAccountDialog.preparingUrl")})]}),ee&&e.jsx("p",{className:"text-xs text-center text-destructive",children:ee}),ae.isPending&&e.jsxs("p",{className:"text-sm text-center text-muted-foreground",children:[e.jsx(ce,{className:"w-4 h-4 inline mr-2 animate-spin"}),b("addAccountDialog.importingToken")]}),e.jsxs("div",{className:"flex items-center justify-end gap-2 pt-2",children:[e.jsx(K,{variant:"ghost",onClick:Dt,children:b("addAccountDialog.cancel")}),$&&!le&&e.jsx(K,{variant:"outline",onClick:Cs,disabled:re,children:ae.isPending?e.jsxs(e.Fragment,{children:[e.jsx(ce,{className:"w-4 h-4 mr-2 animate-spin"}),b("addAccountDialog.importing")]}):e.jsxs(e.Fragment,{children:[e.jsx(ya,{className:"w-4 h-4 mr-2"}),b("addAccountDialog.importFromIde")]})}),!le&&e.jsxs(K,{onClick:ws,disabled:re||be||O&&!Ee||v&&!Te,children:[e.jsx(ke,{className:"w-4 h-4 mr-2"}),b("addAccountDialog.authenticate")]})]})]})]})})}const cn=["ANTHROPIC_BASE_URL","ANTHROPIC_AUTH_TOKEN"];function un(t){const a=t?.env||{};return cn.filter(s=>!a[s]?.trim())}function mn(t,a){const[s,i]=d.useState(null),[n,c]=d.useState(!1),l=ht(),{data:o,isLoading:r,refetch:p}=$t({queryKey:["settings",t],queryFn:async()=>{const P=await fetch(`/api/settings/${t}/raw`);if(!P.ok){const L=t==="cursor"?`~/.ccs/cliproxy/providers/${t}.settings.json`:Qe(t)?`~/.ccs/${t}.settings.json`:`~/.ccs/profiles/${t}/settings.json`;return{profile:t,settings:{env:{}},mtime:Date.now(),path:L}}return P.json()}}),m=o?.settings,j=d.useMemo(()=>s!==null?s:m?JSON.stringify(m,null,2):`{
2
- "env": {}
3
- }`,[s,m]),g=d.useCallback(P=>{i(P)},[]),x=d.useMemo(()=>{try{return JSON.parse(j)}catch{return m||{env:{}}}},[j,m]),T=x?.env?.ANTHROPIC_MODEL,k=x?.env?.ANTHROPIC_DEFAULT_OPUS_MODEL,D=x?.env?.ANTHROPIC_DEFAULT_SONNET_MODEL,A=x?.env?.ANTHROPIC_DEFAULT_HAIKU_MODEL,C=d.useMemo(()=>Hs(x?.env||{}),[x]),y=d.useCallback((P,L)=>qs(P,L,{supportsExtendedContext:_=>Va(t,_,a)}),[a,t]),w=d.useCallback((P,L)=>{const _={...x?.env||{},[P]:L},G=Rt(P)?y(_,C):_;delete G.CCS_EXTENDED_CONTEXT;const V={...x,env:G};i(JSON.stringify(V,null,2))},[y,x,C]),h=d.useCallback(P=>{const L=x?.env||{},_=y(L,P);delete _.CCS_EXTENDED_CONTEXT;const G={...x,env:_};i(JSON.stringify(G,null,2))},[y,x]),f=d.useCallback(P=>{const L={...x?.env||{},...P},G=Object.keys(P).some(Rt)?y(L,C):L;delete G.CCS_EXTENDED_CONTEXT;const V={...x,env:G};i(JSON.stringify(V,null,2))},[y,x,C]),I=d.useMemo(()=>{try{return JSON.parse(j),!0}catch{return!1}},[j]),u=d.useMemo(()=>s===null?!1:s!==JSON.stringify(m,null,2),[s,m]),E=d.useMemo(()=>un(x),[x]),N=Ss({mutationFn:async()=>{const P=JSON.parse(j),L=await fetch(`/api/settings/${t}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({settings:P,expectedMtime:o?.mtime})});if(L.status===409)throw new Error("CONFLICT");if(!L.ok)throw new Error("Failed to save");return L.json()},onSuccess:P=>{l.invalidateQueries({queryKey:["settings",t]}),i(null),P?.warning?B.success(me.t("settings.saved"),{description:P.warning}):B.success(me.t("settings.saved"))},onError:P=>{P.message==="CONFLICT"?c(!0):B.error(P.message)}}),z=async P=>{c(!1),P?(await p(),N.mutate()):i(null)};return{data:o,isLoading:r,refetch:p,rawJsonContent:j,rawJsonEdits:s,isRawJsonValid:I,hasChanges:u,currentSettings:x,currentModel:T,opusModel:k,sonnetModel:D,haikuModel:A,extendedContextEnabled:C,toggleExtendedContext:h,handleRawJsonChange:g,updateEnvValue:w,updateEnvValues:f,saveMutation:{mutate:()=>N.mutate(),isPending:N.isPending},conflictDialog:n,setConflictDialog:c,handleConflictResolve:z,missingRequiredFields:E}}const vs=/-(medium|high|xhigh)$/i,pn=["medium","high","xhigh"];function js(t){return t?.trim()??""}function bs(t){if(!t)return;const a=js(t).match(vs);if(a?.[1])return a[1].toLowerCase()}function Ns(t){return js(t).replace(vs,"")}function zt(t,a){const s=Ns(t);return!s||!a?s:`${s}-${a}`}function xn(t,a){if(!a){const n=bs(t);return[zt(t,n)]}const s=Ns(t),i=[s];for(const n of pn)if(i.push(zt(s,n)),n===a)break;return i}function hn(t,a){if(!t)return null;const s=bs(t);return s?{label:`Pinned ${s}`,explicit:!0}:{label:"Auto effort",explicit:!1}}function gn({label:t}){return e.jsx(H,{variant:"outline",className:"text-[9px] h-4 px-1",children:t})}function Ke({modelId:t}){const a=hn(t);return a?e.jsx(H,{variant:a.explicit?"secondary":"outline",className:"text-[9px] h-4 px-1 uppercase",children:a.label}):null}function Gt(t,a){if(!t)return"";if(!a?.prefix)return t;const s=`${a.prefix}/`;return t.startsWith(s)?t.slice(s.length):t}function He(t,a){return a?.recommendedModelId??t}function ot(t,a,s){return s?xn(a,t):[a]}function je({label:t,description:a,value:s,onChange:i,catalog:n,allModels:c,routing:l,disabled:o}){const{t:r}=W(),p=n?.provider==="codex",m=d.useMemo(()=>Pt(n,c),[c,n]),j=d.useMemo(()=>Ba(n?.provider??"",n,c),[c,n]),g=new Set(m.map(h=>h.id)),x=d.useMemo(()=>new Map((l?.models??[]).map(h=>[h.modelId.toLowerCase(),h])),[l]),T=d.useMemo(()=>new Set(m.flatMap(h=>ot(h.codexMaxEffort,He(h.id,x.get(h.id.toLowerCase())),p))),[p,m,x]),k=d.useMemo(()=>x.get(Gt(s,l).toLowerCase()),[l,x,s]),D=m.flatMap(h=>{const f=x.get(h.id.toLowerCase());return ot(h.codexMaxEffort,He(h.id,f),p).map(u=>({value:u,groupKey:"recommended",searchText:`${u} ${h.id} ${h.name} ${f?.recommendedModelId??""}`,keywords:[h.tier??"",n?.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:u}),f?.pinnedAvailable?e.jsx(H,{variant:"secondary",className:"text-[9px] h-4 px-1 uppercase",children:f.prefix}):null,p&&e.jsx(Ke,{modelId:u})]}),itemContent:e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("span",{className:"truncate font-mono text-xs",children:u}),h.tier==="paid"&&e.jsx(gn,{label:r("providerModelSelector.paid")}),f?.unprefixedStatus==="shadowed"?e.jsx(H,{variant:"outline",className:"text-[9px] h-4 px-1",children:r("providerModelSelector.shadowed")}):null,f?.unprefixedStatus==="prefix-only"?e.jsx(H,{variant:"outline",className:"text-[9px] h-4 px-1",children:r("providerModelSelector.prefixOnly")}):null,p&&e.jsx(Ke,{modelId:u})]})}))}),A=j.filter(h=>!g.has(h.id)).filter(h=>!T.has(He(h.id,x.get(h.id.toLowerCase())))).flatMap(h=>{const f=x.get(h.id.toLowerCase());return ot(void 0,He(h.id,f),p).map(u=>({value:u,groupKey:"all",searchText:`${u} ${h.id} ${f?.recommendedModelId??""}`,keywords:[h.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:u}),f?.pinnedAvailable?e.jsx(H,{variant:"secondary",className:"text-[9px] h-4 px-1 uppercase",children:f.prefix}):null,p&&e.jsx(Ke,{modelId:u})]}),itemContent:e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("span",{className:"truncate font-mono text-xs",children:u}),f?.unprefixedStatus==="shadowed"?e.jsx(H,{variant:"outline",className:"text-[9px] h-4 px-1",children:r("providerModelSelector.shadowed")}):null,f?.unprefixedStatus==="prefix-only"?e.jsx(H,{variant:"outline",className:"text-[9px] h-4 px-1",children:r("providerModelSelector.prefixOnly")}):null,p&&e.jsx(Ke,{modelId:u})]})}))}),C=!!s&&!D.some(h=>h.value===s)&&!A.some(h=>h.value===s),y=s?{value:s,groupKey:"current",searchText:s,triggerContent:e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("span",{className:"truncate font-mono text-xs",children:s}),e.jsx(H,{variant:"outline",className:"text-[9px] h-4 px-1",children:r("providerModelSelector.current")})]}),itemContent:e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("span",{className:"truncate font-mono text-xs",children:s}),e.jsx(H,{variant:"outline",className:"text-[9px] h-4 px-1",children:r("providerModelSelector.current")})]})}:null,w=D.length+A.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}),a&&e.jsx("p",{className:"text-[10px] text-muted-foreground",children:a})]}),e.jsx(Ea,{value:s||void 0,onChange:i,disabled:o,placeholder:r("providerModelSelector.selectModel"),searchPlaceholder:r("searchableSelect.searchModels"),emptyText:r(w?"searchableSelect.noResults":"providerModelSelector.noModelsAvailable"),triggerClassName:"h-9",groups:[...C&&y?[{key:"current",label:e.jsx("span",{className:"text-xs text-muted-foreground",children:r("providerModelSelector.currentValue")})}]:[],{key:"recommended",label:e.jsx("span",{className:"text-xs text-primary",children:r("providerModelSelector.recommended")})},...A.length>0?[{key:"all",label:e.jsx("span",{className:"text-xs text-muted-foreground",children:r("providerModelSelector.allModelsCount",{count:A.length})})}]:[]],options:[...C&&y?[y]:[],...D,...A]}),k?e.jsxs("div",{className:X("rounded-md border px-2.5 py-2 text-[11px]",k.unprefixedStatus==="safe"?"border-border/70 bg-muted/25 text-muted-foreground":"border-amber-300/60 bg-amber-50 text-amber-900 dark:border-amber-500/30 dark:bg-amber-950/25 dark:text-amber-100"),children:[e.jsxs("div",{className:"font-medium",children:[k.pinnedAvailable?r("providerModelSelector.preferredPinnedModel"):r("providerModelSelector.pinnedRouteStatus")," ",e.jsx("code",{children:k.pinnedAvailable?k.recommendedModelId:k.pinnedModelId})]}),e.jsx("p",{className:"mt-1 leading-5",children:k.summary})]}):null,s&&!k&&Gt(s,l)!==s?e.jsx("div",{className:"rounded-md border border-amber-300/60 bg-amber-50 px-2.5 py-2 text-[11px] text-amber-900 dark:border-amber-500/30 dark:bg-amber-950/25 dark:text-amber-100",children:r("providerModelSelector.pinnedModelNotAdvertised",{model:s})}):null]})}function Bt(t,a){const s=i=>a?.models.find(c=>c.modelId.toLowerCase()===i.toLowerCase())?.recommendedModelId??i;return{default:s(t.default),opus:s(t.opus),sonnet:s(t.sonnet),haiku:s(t.haiku)}}function fn({open:t,onClose:a,currentValues:s,onApply:i,onSave:n,isSaving:c,catalog:l,allModels:o,routing:r}){const{t:p}=W(),[m,j]=d.useState(Bt(s,r)),[g,x]=d.useState(""),T=k=>{k?(j(Bt(s,r)),x("")):a()};return e.jsx(ft,{open:t,onOpenChange:T,children:e.jsxs(vt,{className:"sm:max-w-md",children:[e.jsx(jt,{children:e.jsxs(bt,{className:"flex items-center gap-2",children:[e.jsx(De,{className:"w-4 h-4"}),p("customPresetDialog.title")]})}),e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(Y,{htmlFor:"preset-name",children:p("customPresetDialog.presetNameOptional")}),e.jsx(de,{id:"preset-name",value:g,onChange:k=>x(k.target.value),placeholder:p("customPresetDialog.presetNamePlaceholder"),className:"text-sm"})]}),e.jsx(St,{}),l?.provider==="codex"&&e.jsxs("p",{className:"text-[11px] text-muted-foreground rounded-md border bg-muted/30 px-2.5 py-2",children:[p("customPresetDialog.codexTipPrefix")," ",e.jsx("code",{children:"-medium"}),", ",e.jsx("code",{children:"-high"}),", and"," ",e.jsx("code",{children:"-xhigh"})," ",p("customPresetDialog.codexTipSuffix")]}),e.jsx(je,{label:p("customPresetDialog.defaultModel"),description:p("customPresetDialog.defaultModelDesc"),value:m.default,onChange:k=>j({...m,default:k}),catalog:l,allModels:o,routing:r}),e.jsx(je,{label:p("customPresetDialog.opusModel"),description:p("customPresetDialog.opusModelDesc"),value:m.opus,onChange:k=>j({...m,opus:k}),catalog:l,allModels:o,routing:r}),e.jsx(je,{label:p("customPresetDialog.sonnetModel"),description:p("customPresetDialog.sonnetModelDesc"),value:m.sonnet,onChange:k=>j({...m,sonnet:k}),catalog:l,allModels:o,routing:r}),e.jsx(je,{label:p("customPresetDialog.haikuModel"),description:p("customPresetDialog.haikuModelDesc"),value:m.haiku,onChange:k=>j({...m,haiku:k}),catalog:l,allModels:o,routing:r})]}),e.jsxs(zs,{className:"gap-2 sm:gap-0",children:[e.jsx(K,{variant:"outline",onClick:a,children:p("customPresetDialog.cancel")}),n&&e.jsxs(K,{variant:"secondary",onClick:()=>n(m,g||void 0),disabled:c||!g.trim(),children:[c?e.jsx(ce,{className:"w-4 h-4 mr-1 animate-spin"}):e.jsx(Ct,{className:"w-4 h-4 mr-1"}),p("customPresetDialog.savePreset")]}),e.jsxs(K,{onClick:()=>i(m,g||void 0),children:[e.jsx(Ie,{className:"w-4 h-4 mr-1"}),p("customPresetDialog.applyPreset")]})]})]})})}function ve({label:t,command:a}){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:a}),e.jsx(as,{value:a,size:"icon",className:"h-6 w-6"})]})]})}function vn({provider:t,displayName:a,baseProvider:s,defaultTarget:i,data:n,authStatus:c,supportsModelConfig:l=!1}){const{t:o}=W(),r=i||"claude",p=r==="droid",m=t==="codex",j=s||c.provider||t,g=Gs(j),x=r==="claude"?`ccs ${t}`:`ccs ${t} --target claude`,T=`${x} --config`,k=`${x} --auth --add`,D=`${x} --accounts`;return e.jsx(Nt,{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(ls,{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:o("providerEditor.provider")}),e.jsx("span",{className:"font-mono",children:a})]}),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:o("providerEditor.filePath")}),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(as,{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:o("providerEditor.lastModified")}),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:o("providerEditor.status")}),c.authenticated?e.jsxs(H,{variant:"outline",className:"w-fit text-green-600 border-green-200 bg-green-50",children:[e.jsx(ka,{className:"w-3 h-3 mr-1"}),"Authenticated"]}):e.jsx(H,{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:o("providerEditor.defaultTarget")}),e.jsx("span",{className:"font-mono",children:r})]}),g&&e.jsxs("div",{className:"grid grid-cols-[100px_1fr] gap-2 text-sm items-start",children:[e.jsx("span",{className:"font-medium text-muted-foreground",children:o("providerConfig.trackLabel")}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("span",{className:"font-mono",children:o(g.labelKey)}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[o(g.hintKey),Bs(j)?` ${o("providerConfig.plusTrackNote")}`:""]})]})]})]})]}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-medium mb-3",children:o("providerEditor.quickUsage")}),e.jsxs("div",{className:"space-y-3 bg-card rounded-lg border p-4 shadow-sm",children:[e.jsx(ve,{label:"Run with prompt",command:`ccs ${t} "your prompt"`}),m&&e.jsxs(e.Fragment,{children:[e.jsx(ve,{label:"Run on native Codex (shortcut)",command:'ccsxp "your prompt"'}),e.jsx(ve,{label:"Run on native Codex (--target)",command:`ccs ${t} --target codex "your prompt"`})]}),e.jsx(ve,{label:p?"Droid alias (explicit)":"Run on Droid",command:`ccs-droid ${t} "your prompt"`}),e.jsx(ve,{label:p?"Override to Claude":"Run on Droid (--target)",command:`ccs ${t} --target ${p?"claude":"droid"} "your prompt"`}),l&&e.jsx(ve,{label:r==="claude"?"Change model":"Change model (Claude target)",command:T}),e.jsx(ve,{label:r==="claude"?"Add account":"Add account (Claude target)",command:k}),e.jsx(ve,{label:r==="claude"?"List accounts":"List accounts (Claude target)",command:D}),r!=="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 jn(t){const a=t.replace(/\\/g,"/"),i=a.lastIndexOf("/cliproxy/providers/");return i!==-1?a.slice(i+1):a.replace(/^.*\//,"")}function bn({displayName:t,logoProvider:a,provider:s,data:i,isLoading:n,hasChanges:c,isRawJsonValid:l,isSaving:o,isRemoteMode:r,port:p,onRefetch:m,onSave:j}){const{t:g}=W();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(yt,{provider:a||s,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}),r&&e.jsxs(H,{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(ds,{className:"w-3 h-3"}),"Remote"]}),p&&e.jsxs(H,{variant:"outline",className:"text-xs gap-1 font-mono",children:[e.jsx(wa,{className:"w-3 h-3"}),":",p]}),!r&&i?.path&&e.jsx(H,{variant:"outline",className:"text-xs",children:jn(i.path)})]}),r?e.jsx("p",{className:"text-xs text-blue-600 dark:text-blue-400 mt-0.5",children:"Traffic auto-routed to remote server"}):i&&e.jsxs("p",{className:"text-xs text-muted-foreground mt-0.5",children:[g("providerEditor.lastModified"),": ",new Date(i.mtime).toLocaleString()]})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(K,{variant:"ghost",size:"sm",onClick:m,disabled:n,children:e.jsx(wt,{className:`w-4 h-4 ${n?"animate-spin":""}`})}),e.jsx(K,{size:"sm",onClick:j,disabled:o||!c||!l,children:o?e.jsxs(e.Fragment,{children:[e.jsx(ce,{className:"w-4 h-4 mr-1 animate-spin"}),"Saving..."]}):e.jsxs(e.Fragment,{children:[e.jsx(Ca,{className:"w-4 h-4 mr-1"}),"Save"]})})]})]})}function Nn({models:t,provider:a,enabled:s,onToggle:i,disabled:n,className:c}){const{t:l}=W();if(t.length===0)return null;const o=t.some(m=>Lt(m.id)),r=t.some(m=>!Lt(m.id));let p="Compatible mappings stay on standard context unless you turn this on.";return o&&r?p="Gemini-compatible mappings can use 1M automatically. Claude mappings stay plain unless you turn this on.":o&&(p="Gemini-compatible mappings can use 1M by default. Turn this off to keep standard context."),e.jsxs("div",{className:X("rounded-lg border p-3 space-y-2",s?"border-primary/50 bg-primary/5":"border-border bg-muted/30",c),children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ie,{className:X("w-4 h-4",s?"text-primary":"text-muted-foreground")}),e.jsx("span",{className:"text-sm font-medium",children:l("extendedContext.extendedContext")}),e.jsx(H,{variant:s?"default":"secondary",className:"text-[10px] h-5 px-1.5",children:"1M tokens"})]}),e.jsx(ns,{checked:s,onCheckedChange:i,disabled:n})]}),e.jsxs("div",{className:"flex items-start gap-2 text-xs text-muted-foreground",children:[e.jsx(ls,{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:p}),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 yn(t,a){const s=t.presetMapping||{default:t.id,opus:t.id,sonnet:t.id,haiku:t.id};return{ANTHROPIC_MODEL:a(s.default),ANTHROPIC_DEFAULT_OPUS_MODEL:a(s.opus),ANTHROPIC_DEFAULT_SONNET_MODEL:a(s.sonnet),ANTHROPIC_DEFAULT_HAIKU_MODEL:a(s.haiku)}}function kn({catalog:t,savedPresets:a,currentModel:s,opusModel:i,sonnetModel:n,haikuModel:c,providerModels:l,routing:o,provider:r,extendedContextEnabled:p,onExtendedContextToggle:m,onApplyPreset:j,onUpdateEnvValue:g,onOpenCustomPreset:x,onDeletePreset:T,isDeletePending:k}){const{t:D}=W(),A=(o?.models??[]).some(u=>u.pinnedAvailable),C=d.useMemo(()=>new Map((o?.models??[]).map(u=>[u.modelId.toLowerCase(),u])),[o]),y=u=>C.get(u.toLowerCase())?.recommendedModelId??u,w=d.useMemo(()=>{if(!t)return[];const u=[s,i,n,c].filter(N=>!!N).map(N=>Vs(N));return[...new Set(u)].map(N=>fs(t.provider,N,t)).filter(N=>!!N?.extendedContext)},[t,s,i,n,c]),h=d.useMemo(()=>Pt(t,l),[t,l]),f=d.useMemo(()=>{const u=h.filter(N=>N.presetMapping);return u.length===0?[]:u.some(N=>N.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:u.filter(N=>N.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:u.filter(N=>N.tier==="paid")}].filter(N=>N.models.length>0):[{key:"default",models:u.slice(0,4)}]},[h]),I=f.length>0||a.length>0;return e.jsxs(e.Fragment,{children:[I&&e.jsxs("div",{children:[e.jsxs("h3",{className:"text-sm font-medium mb-2 flex items-center gap-2",children:[e.jsx(De,{className:"w-4 h-4"}),"Presets"]}),e.jsx("p",{className:"text-xs text-muted-foreground mb-3",children:D("providerEditor.presets")}),e.jsxs("div",{className:"space-y-4",children:[f.map(u=>e.jsxs("div",{children:["label"in u&&u.label&&e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(H,{variant:"outline",className:u.badgeClassName,children:u.label}),e.jsx("span",{className:"text-[10px] text-muted-foreground",children:u.description})]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:u.models.map(E=>e.jsxs(K,{variant:"outline",size:"sm",className:"text-xs h-7 gap-1",onClick:()=>j(yn(E,y)),children:[e.jsx(Ie,{className:`w-3 h-3 ${"iconClassName"in u?u.iconClassName:""}`}),E.name]},E.id))})]},u.key)),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[a.map(u=>e.jsxs("div",{className:"group relative",children:[e.jsxs(K,{variant:"secondary",size:"sm",className:"text-xs h-7 gap-1 pr-6",onClick:()=>{j({ANTHROPIC_MODEL:y(u.default),ANTHROPIC_DEFAULT_OPUS_MODEL:y(u.opus),ANTHROPIC_DEFAULT_SONNET_MODEL:y(u.sonnet),ANTHROPIC_DEFAULT_HAIKU_MODEL:y(u.haiku)})},children:[e.jsx(Ct,{className:"w-3 h-3 fill-current"}),u.name]}),e.jsx(K,{variant:"ghost",size:"icon",className:"absolute right-0 top-0 h-7 w-5 opacity-0 group-hover:opacity-100 hover:text-destructive",onClick:E=>{E.stopPropagation(),T(u.name)},disabled:k,children:e.jsx(At,{className:"w-3 h-3"})})]},u.name)),e.jsxs(K,{variant:"outline",size:"sm",className:"text-xs h-7 gap-1 border-primary/50 text-primary hover:bg-primary/10 hover:border-primary",onClick:x,children:[e.jsx(cs,{className:"w-3 h-3"}),"Custom"]})]})]})]}),e.jsx(St,{}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-medium mb-2",children:D("providerEditor.modelMapping")}),e.jsx("p",{className:"text-xs text-muted-foreground mb-4",children:"Configure which models to use for each tier"}),o?e.jsx("p",{className:"text-[11px] text-muted-foreground mb-3 rounded-md border bg-muted/30 px-2.5 py-2",children:A?e.jsxs(e.Fragment,{children:["Preferred pinned model names use the ",e.jsxs("code",{children:[o.prefix,"/"]})," prefix. Unprefixed names can still resolve to a different backend when providers overlap."]}):e.jsxs(e.Fragment,{children:["Managed pinning for ",e.jsxs("code",{children:[o.prefix,"/"]})," is not currently advertised by the proxy. Unprefixed names may still be ambiguous until prefix repair completes."]})}):null,r==="codex"&&e.jsxs("p",{className:"text-[11px] text-muted-foreground mb-3 rounded-md border bg-muted/30 px-2.5 py-2",children:["Codex tip: suffixes ",e.jsx("code",{children:"-medium"}),", ",e.jsx("code",{children:"-high"}),", and ",e.jsx("code",{children:"-xhigh"})," ","pin reasoning effort. Select a suffixed model to pin effort; unsuffixed models use Thinking settings."]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx(je,{label:"Default Model",description:"Used when no specific tier is requested",value:s,onChange:u=>g("ANTHROPIC_MODEL",u),catalog:t,allModels:l,routing:o}),w.length>0&&m&&e.jsx(Nn,{models:w,provider:r,enabled:p??!1,onToggle:m}),e.jsx(je,{label:"Opus (Most capable)",description:"For complex reasoning tasks",value:i,onChange:u=>g("ANTHROPIC_DEFAULT_OPUS_MODEL",u),catalog:t,allModels:l,routing:o}),e.jsx(je,{label:"Sonnet (Balanced)",description:"Balance of speed and capability",value:n,onChange:u=>g("ANTHROPIC_DEFAULT_SONNET_MODEL",u),catalog:t,allModels:l,routing:o}),e.jsx(je,{label:"Haiku (Fast)",description:"Quick responses for simple tasks",value:c,onChange:u=>g("ANTHROPIC_DEFAULT_HAIKU_MODEL",u),catalog:t,allModels:l,routing:o})]})]})]})}function wn(t,a,s){return t?e.jsx(lt,{children:e.jsxs(dt,{children:[e.jsx(ct,{asChild:!0,children:e.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[e.jsx(Sa,{className:"w-3 h-3","aria-hidden":"true"}),e.jsx("span",{className:X("font-mono max-w-[180px] truncate",a&&gt),title:t,children:t})]})}),e.jsx(ut,{side:"bottom",children:e.jsx("p",{className:"text-xs",children:s("providerEditor.gcpProjectIdReadonly")})})]})}):e.jsx(lt,{children:e.jsxs(dt,{children:[e.jsx(ct,{asChild:!0,children:e.jsxs("div",{className:"flex items-center gap-1 text-xs text-amber-600 dark:text-amber-500",children:[e.jsx(Je,{className:"w-3 h-3","aria-label":"Warning"}),e.jsx("span",{children:s("providerEditor.projectIdNA")})]})}),e.jsx(ut,{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:s("providerEditor.missingProjectId")}),e.jsx("p",{children:s("providerEditor.missingProjectIdHint")})]})})]})})}function Cn({account:t,onSetDefault:a,onRemove:s,onPauseToggle:i,isRemoving:n,isPausingAccount:c,privacyMode:l,showQuota:o,selectable:r,selected:p,onSelectChange:m}){const{t:j}=W(),g=t.provider.toLowerCase(),{data:x}=$s(o),{data:T,isLoading:k}=Ws(g,t.id,o),D=Qs(x,t)?.lastUsedAt,A=r||i?e.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[r&&e.jsx("button",{type:"button",onClick:()=>m?.(!p),className:X("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(we,{className:"w-3 h-3"})}),i&&e.jsx(lt,{children:e.jsxs(dt,{children:[e.jsx(ct,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",className:"h-7 w-7 shrink-0",onClick:()=>i(!t.paused),disabled:c,children:c?e.jsx(ce,{className:"w-4 h-4 animate-spin"}):t.paused?e.jsx(us,{className:"w-4 h-4 text-emerald-500"}):e.jsx(ms,{className:"w-4 h-4 text-muted-foreground hover:text-foreground"})})}),e.jsx(ut,{side:"top",children:t.paused?"Resume account":"Pause account"})]})})]}):void 0,C=e.jsxs(Js,{children:[e.jsx(Xs,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",className:"h-7 w-7 shrink-0",children:e.jsx(Aa,{className:"w-4 h-4"})})}),e.jsxs(Ys,{align:"end",children:[!t.isDefault&&e.jsxs(Ot,{onClick:a,children:[e.jsx(Ct,{className:"w-4 h-4 mr-2"}),"Set as default"]}),e.jsxs(Ot,{className:"text-destructive focus:text-destructive",onClick:s,disabled:n,children:[e.jsx(ps,{className:"w-4 h-4 mr-2"}),n?"Removing...":"Remove account"]})]})]});return e.jsx("div",{className:X("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(Zs,{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:l,showQuota:o,quota:T,quotaLoading:k,runtimeLastUsed:D,beforeIdentity:A,headerEnd:C,bodySlot:t.provider==="agy"?wn(t.projectId,l,j):null,quotaInsetClassName:"pl-11"})})}function An({selectedCount:t,onPauseSelected:a,onResumeSelected:s,onClearSelection:i,isPausing:n,isResuming:c}){if(t<1)return null;const l=n||c;return e.jsxs("div",{className:"flex items-center gap-3 p-2 bg-muted/50 rounded-lg border mt-2",children:[e.jsxs("span",{className:"text-sm text-muted-foreground",children:[t," selected"]}),e.jsx(K,{variant:"ghost",size:"sm",className:"text-xs h-6 px-2",onClick:i,disabled:l,children:"Clear"}),e.jsxs("div",{className:"flex gap-2 ml-auto",children:[e.jsxs(K,{size:"sm",variant:"outline",className:"h-7 text-xs gap-1",onClick:a,disabled:l,children:[n?e.jsx(ce,{className:"w-3 h-3 animate-spin"}):e.jsx(ms,{className:"w-3 h-3"}),"Pause Selected"]}),e.jsxs(K,{size:"sm",variant:"outline",className:"h-7 text-xs gap-1",onClick:s,disabled:l,children:[c?e.jsx(ce,{className:"w-3 h-3 animate-spin"}):e.jsx(us,{className:"w-3 h-3"}),"Resume Selected"]})]})]})}function Sn({accounts:t,onAddAccount:a,onSetDefault:s,onRemoveAccount:i,onPauseToggle:n,onSoloMode:c,onBulkPause:l,onBulkResume:o,isRemovingAccount:r,isPausingAccount:p,isSoloingAccount:m,isBulkPausing:j,isBulkResuming:g,privacyMode:x,showQuota:T,isKiro:k,kiroNoIncognito:D,onKiroNoIncognitoChange:A,kiroSettingsLoading:C}){const{t:y}=W(),[w,h]=d.useState(new Set),f=d.useMemo(()=>new Set(t.map(S=>S.id)),[t]),I=d.useMemo(()=>new Set([...w].filter(S=>f.has(S))),[w,f]),u=!!(l&&o),E=I.size,N=t.length>0&&I.size===t.length,z=I.size>0&&I.size<t.length,P=d.useCallback(S=>{h(R=>{const b=new Set(R);return b.has(S)?b.delete(S):b.add(S),b})},[]),L=d.useCallback(()=>{h(new Set(t.map(S=>S.id)))},[t]),_=d.useCallback(()=>{h(new Set)},[]),G=d.useCallback(()=>{N?_():L()},[N,L,_]),V=d.useCallback(()=>{l&&I.size>0&&(l(Array.from(I)),h(new Set))},[l,I]),q=d.useCallback(()=>{o&&I.size>0&&(o(Array.from(I)),h(new Set))},[o,I]);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:[u&&t.length>0&&e.jsx(We,{checked:N,onCheckedChange:G,"aria-label":"Select all accounts",className:z?"data-[state=checked]:bg-primary/50":"",...z?{"data-state":"indeterminate"}:{}}),e.jsx(Pe,{className:"w-4 h-4"}),"Accounts",t.length>0&&e.jsx(H,{variant:"secondary",className:"text-xs",children:t.length})]}),e.jsxs(K,{variant:"default",size:"sm",className:"h-7 text-xs gap-1",onClick:a,children:[e.jsx(cs,{className:"w-3 h-3"}),"Add"]})]}),u&&E>0&&e.jsx(An,{selectedCount:E,onPauseSelected:V,onResumeSelected:q,onClearSelection:_,isPausing:!!j,isResuming:!!g}),t.length>0?e.jsx("div",{className:"space-y-2",children:t.map(S=>e.jsx(Cn,{account:S,onSetDefault:()=>s(S.id),onRemove:()=>i(S.id),onPauseToggle:n?R=>n(S.id,R):void 0,onSoloMode:c?()=>c(S.id):void 0,isRemoving:r,isPausingAccount:p,isSoloingAccount:m,privacyMode:x,showQuota:T,selectable:u,selected:I.has(S.id),onSelectChange:()=>P(S.id)},S.id))}):e.jsxs("div",{className:"py-6 text-center text-muted-foreground bg-muted/30 rounded-lg border border-dashed",children:[e.jsx(Pe,{className:"w-8 h-8 mx-auto mb-2 opacity-50"}),e.jsx("p",{className:"text-sm",children:y("providerEditor.noAccountsConnected")}),e.jsx("p",{className:"text-xs opacity-70",children:y("providerEditor.addAccountToStart")})]}),k&&A&&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(ds,{className:"w-3.5 h-3.5"}),e.jsx("span",{children:y("providerEditor.useIncognito")})]}),e.jsx(ns,{checked:!D,onCheckedChange:S=>A(!S),disabled:C,className:"scale-90"})]})})]})}function Mn({provider:t,catalog:a,savedPresets:s,currentModel:i,opusModel:n,sonnetModel:c,haikuModel:l,providerModels:o,routing:r,extendedContextEnabled:p,onExtendedContextToggle:m,onApplyPreset:j,onUpdateEnvValue:g,onOpenCustomPreset:x,onDeletePreset:T,isDeletePending:k,accounts:D,onAddAccount:A,onSetDefault:C,onRemoveAccount:y,onPauseToggle:w,onSoloMode:h,onBulkPause:f,onBulkResume:I,isRemovingAccount:u,isPausingAccount:E,isSoloingAccount:N,isBulkPausing:z,isBulkResuming:P,privacyMode:L,isRemoteMode:_}){const G=t.toLowerCase(),V=(ea.includes(G)||["anthropic","antigravity","gemini-cli","copilot","github-copilot"].includes(G))&&!_,q=t==="kiro",[S,R]=d.useState(!0),[b,Q]=d.useState(!0),[te,ne]=d.useState(!1),U=d.useCallback(async()=>{if(q)try{Q(!0);const Z=(await Ve.config.get()).cliproxy;R(Z?.kiro_no_incognito??!0)}catch{R(!0)}finally{Q(!1)}},[q]),ae=d.useCallback(async $=>{R($),ne(!0);try{const Z=await Ve.config.get(),ie=Z.cliproxy??{};await Ve.config.update({...Z,cliproxy:{...ie,kiro_no_incognito:$}})}catch{R(!$)}finally{ne(!1)}},[]);return d.useEffect(()=>{U()},[U]),e.jsx(Nt,{className:"flex-1",children:e.jsxs("div",{className:"p-4 space-y-6",children:[e.jsx(kn,{catalog:a,savedPresets:s,currentModel:i,opusModel:n,sonnetModel:c,haikuModel:l,providerModels:o,routing:r,provider:t,extendedContextEnabled:p,onExtendedContextToggle:m,onApplyPreset:j,onUpdateEnvValue:g,onOpenCustomPreset:x,onDeletePreset:T,isDeletePending:k}),e.jsx(St,{}),e.jsx(Sn,{accounts:D,onAddAccount:A,onSetDefault:C,onRemoveAccount:y,onPauseToggle:w,onSoloMode:h,onBulkPause:f,onBulkResume:I,isRemovingAccount:u,isPausingAccount:E,isSoloingAccount:N,isBulkPausing:z,isBulkResuming:P,privacyMode:L,showQuota:V,isKiro:q,kiroNoIncognito:S,onKiroNoIncognitoChange:ae,kiroSettingsLoading:b||te})]})})}function Vt({provider:t,displayName:a,authStatus:s,catalog:i,routing:n,logoProvider:c,baseProvider:l,isRemoteMode:o,port:r,defaultTarget:p,topNotice:m,onAddAccount:j,onSetDefault:g,onRemoveAccount:x,onPauseToggle:T,onSoloMode:k,onBulkPause:D,onBulkResume:A,isRemovingAccount:C,isPausingAccount:y,isSoloingAccount:w,isBulkPausing:h,isBulkResuming:f}){const[I,u]=d.useState(!1),{privacyMode:E}=es(),{t:N}=W(),{data:z}=ta(),{data:P}=sa(t),L=aa(),_=na(),G=l||t,V=G.toLowerCase()==="agy",q=d.useMemo(()=>{const F=P?.presets||[];return V?F.filter(ee=>!ue(ee.default)&&!ue(ee.opus)&&!ue(ee.sonnet)&&!ue(ee.haiku)):F},[V,P?.presets]),S=d.useMemo(()=>{if(!z?.models)return[];const ee={gemini:["google"],agy:["antigravity"],codex:["openai"],cursor:["cursor"],gitlab:["gitlab","duo"],codebuddy:["codebuddy"],qwen:["alibaba","qwen"],iflow:["iflow"],kilo:["kilo"],kiro:["kiro","aws"],ghcp:["github","copilot"],kimi:["kimi","moonshot"]}[G.toLowerCase()]||[G.toLowerCase()];return z.models.filter(oe=>ee.some(ge=>oe.owned_by.toLowerCase().includes(ge))?V?!ue(oe.id):!0:!1)},[V,z,G]),R=(l||t).toLowerCase(),{data:b,isLoading:Q,refetch:te,rawJsonContent:ne,rawJsonEdits:U,isRawJsonValid:ae,hasChanges:$,currentModel:Z,opusModel:ie,sonnetModel:v,haikuModel:O,extendedContextEnabled:be,toggleExtendedContext:Ee,handleRawJsonChange:Te,updateEnvValue:Ye,updateEnvValues:Re,saveMutation:he,conflictDialog:Ne,handleConflictResolve:Me,missingRequiredFields:Ze}=mn(t,i),et=d.useMemo(()=>(s.accounts||[]).map(F=>({...F,provider:F.provider||l||t})),[s.accounts,l,t]),{data:re}=$t({queryKey:["auth-tokens-raw"],queryFn:async()=>{const F=await fetch("/api/settings/auth/tokens/raw");return F.ok?F.json():{apiKey:{value:"ccs-internal-managed"}}},staleTime:6e4}),Le=re?.apiKey?.value??"ccs-internal-managed",Oe=F=>{if(V&&[F.ANTHROPIC_MODEL,F.ANTHROPIC_DEFAULT_OPUS_MODEL,F.ANTHROPIC_DEFAULT_SONNET_MODEL,F.ANTHROPIC_DEFAULT_HAIKU_MODEL].some(oe=>typeof oe=="string"&&ue(oe))){B.error(N("providerEditor.agyDenylist"));return}Re({ANTHROPIC_BASE_URL:`http://127.0.0.1:${r??mt}/api/provider/${R}`,ANTHROPIC_AUTH_TOKEN:Le,...F}),B.success(`Applied "${F.ANTHROPIC_MODEL?.split("/").pop()||"preset"}" preset`)},_e=(F,ee)=>{if(V&&[F.default,F.opus,F.sonnet,F.haiku].some(ge=>ue(ge))){B.error(N("providerEditor.agyDenylist"));return}Re({ANTHROPIC_BASE_URL:`http://127.0.0.1:${r??mt}/api/provider/${R}`,ANTHROPIC_AUTH_TOKEN:Le,ANTHROPIC_MODEL:F.default,ANTHROPIC_DEFAULT_OPUS_MODEL:F.opus,ANTHROPIC_DEFAULT_SONNET_MODEL:F.sonnet,ANTHROPIC_DEFAULT_HAIKU_MODEL:F.haiku}),B.success(`Applied ${ee?`"${ee}"`:"custom"} preset`),u(!1)},Fe=(F,ee)=>{if(!ee){B.error(me.t("commonToast.enterPresetName"));return}if(V&&[F.default,F.opus,F.sonnet,F.haiku].some(oe=>ue(oe))){B.error(N("providerEditor.agyDenylist"));return}L.mutate({profile:t,data:{name:ee,...F}}),u(!1)};return e.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden",children:[e.jsx(bn,{provider:t,displayName:a,logoProvider:c,data:b,isLoading:Q,hasChanges:$,isRawJsonValid:ae,isSaving:he.isPending,isRemoteMode:o,port:r,onRefetch:te,onSave:()=>he.mutate()}),m?e.jsx("div",{className:"border-b bg-muted/10 px-4 py-3",children:m}):null,Q?e.jsxs("div",{className:"flex-1 flex items-center justify-center",children:[e.jsx(ce,{className:"w-8 h-8 animate-spin text-muted-foreground"}),e.jsx("span",{className:"ml-3 text-muted-foreground",children:N("providerEditor.loadingSettings")})]}):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(ia,{defaultValue:"config",className:"h-full flex flex-col",children:[e.jsx("div",{className:"px-4 pt-4 shrink-0",children:e.jsxs(ra,{className:"w-full",children:[e.jsx(_t,{value:"config",className:"flex-1",children:"Model Config"}),e.jsx(_t,{value:"info",className:"flex-1",children:"Info & Usage"})]})}),e.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col",children:[e.jsx(Ft,{value:"config",className:"flex-1 mt-0 border-0 p-0 data-[state=inactive]:hidden flex flex-col overflow-hidden",children:e.jsx(Mn,{provider:t,catalog:i,savedPresets:q,currentModel:Z,opusModel:ie,sonnetModel:v,haikuModel:O,providerModels:S,routing:n,extendedContextEnabled:be,onExtendedContextToggle:Ee,onApplyPreset:Oe,onUpdateEnvValue:Ye,onOpenCustomPreset:()=>u(!0),onDeletePreset:F=>_.mutate({profile:t,name:F}),isDeletePending:_.isPending,accounts:et,onAddAccount:j,onSetDefault:g,onRemoveAccount:x,onPauseToggle:T,onSoloMode:k,onBulkPause:D,onBulkResume:A,isRemovingAccount:C,isPausingAccount:y,isSoloingAccount:w,isBulkPausing:h,isBulkResuming:f,privacyMode:E,isRemoteMode:o})}),e.jsx(Ft,{value:"info",className:"h-full mt-0 border-0 p-0 data-[state=inactive]:hidden",children:e.jsx(vn,{provider:t,displayName:a,baseProvider:l,defaultTarget:p,data:b,authStatus:s,supportsModelConfig:!!i})})]})]})}),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(Ma,{className:"w-4 h-4 text-muted-foreground"}),e.jsxs("span",{className:"text-sm font-medium text-muted-foreground",children:[N("rawEditorSection.rawConfig")," (JSON)"]})]}),e.jsx(oa,{rawJsonContent:ne,isRawJsonValid:ae,rawJsonEdits:U,onRawJsonChange:Te,profileEnv:b?.settings?.env,missingRequiredFields:Ze})]})]}),e.jsx(Ia,{open:Ne,title:"File Modified Externally",description:"This settings file was modified by another process. Overwrite with your changes or discard?",confirmText:"Overwrite",variant:"destructive",onConfirm:()=>Me(!0),onCancel:()=>Me(!1)}),e.jsx(fn,{open:I,onClose:()=>u(!1),currentValues:{default:Z||"",opus:ie||"",sonnet:v||"",haiku:O||""},onApply:_e,onSave:Fe,isSaving:L.isPending,catalog:i,allModels:S,routing:n})]})}function Pn({status:t,isSelected:a,onSelect:s}){const{t:i}=W(),n=t.accounts?.length||0;return e.jsxs("button",{className:X("w-full flex items-center gap-3 px-3 py-2.5 rounded-lg transition-colors cursor-pointer text-left",a?"bg-primary/10 border border-primary/20":"hover:bg-muted border border-transparent"),onClick:s,children:[e.jsx(yt,{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}),n>0&&e.jsx(H,{variant:"secondary",className:"text-[10px] h-4 px-1",children:n})]}),e.jsx("div",{className:"flex items-center gap-1.5 mt-0.5",children:t.authenticated?e.jsxs(e.Fragment,{children:[e.jsx(we,{className:"w-3 h-3 text-green-600"}),e.jsx("span",{className:"text-xs text-green-600",children:i("cliproxyPage.connected")})]}):e.jsxs(e.Fragment,{children:[e.jsx(At,{className:"w-3 h-3 text-muted-foreground"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:i("cliproxyPage.notConnected")})]})})]})]})}function Dn({variant:t,parentAuth:a,isSelected:s,onSelect:i,onDelete:n,isDeleting:c}){const{t:l}=W(),o=()=>{i()};return e.jsxs("div",{role:"button",tabIndex:0,className:X("group w-full flex items-center gap-3 px-3 py-2 rounded-lg transition-colors cursor-pointer text-left pl-6",s?"bg-primary/10 border border-primary/20":"hover:bg-muted border border-transparent"),onClick:o,onKeyDown:r=>{(r.key==="Enter"||r.key===" ")&&(r.preventDefault(),o())},children:[e.jsxs("div",{className:"relative",children:[e.jsx(yt,{provider:t.provider,size:"sm"}),e.jsx(xs,{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(H,{variant:"outline",className:"text-[9px] h-4 px-1",children:l("cliproxyPage.variant")}),e.jsx(H,{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:a?.authenticated?e.jsxs(e.Fragment,{children:[e.jsx(we,{className:"w-3 h-3 text-green-600"}),e.jsx("span",{className:"text-xs text-muted-foreground truncate",children:l("cliproxyPage.viaProvider",{provider:t.provider})})]}):e.jsxs(e.Fragment,{children:[e.jsx(At,{className:"w-3 h-3 text-muted-foreground"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:l("cliproxyPage.parentNotConnected")})]})})]}),e.jsx(K,{variant:"ghost",size:"icon",className:"h-6 w-6 opacity-0 group-hover:opacity-100 hover:text-destructive",onClick:r=>{r.stopPropagation(),n()},disabled:c,children:e.jsx(ps,{className:"w-3 h-3"})})]})}function In({onSetup:t}){const{t:a}=W();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(Ie,{className:"w-8 h-8 text-muted-foreground"})}),e.jsx("h2",{className:"text-xl font-semibold mb-2",children:a("cliproxyPage.emptyTitle")}),e.jsx("p",{className:"text-muted-foreground mb-4",children:a("cliproxyPage.emptyDesc")}),e.jsxs("p",{className:"text-xs text-muted-foreground mb-6",children:[a("cliproxyPage.emptyControlPanelPrefix")," ",e.jsx("a",{href:"/cliproxy/control-panel",className:"text-primary hover:underline",children:a("cliproxyPage.controlPanel")}),"."]}),e.jsxs(K,{onClick:t,className:"gap-2",children:[e.jsx(De,{className:"w-4 h-4"}),a("cliproxyPage.quickSetup")]})]})})}function Qn(){const{t}=W(),a=ht(),{data:s,isLoading:i}=Yt(),{data:n,isFetching:c}=la(),{data:l}=Zt(),{data:o}=da(),r=ca(),p=ua(),m=ma(),j=pa(),g=xa(),x=ha(),T=ga(),k=fa(),[D,A]=d.useState(()=>{if(typeof window<"u"){const O=new URLSearchParams(window.location.search).get("provider")?.trim().toLowerCase();return O&&Qe(O)?O:localStorage.getItem("cliproxy-selected-provider")}return null}),[C,y]=d.useState(null),[w,h]=d.useState(!1),[f,I]=d.useState(()=>{if(typeof window>"u")return null;const v=new URLSearchParams(window.location.search),O=v.get("provider")?.trim().toLowerCase();return v.get("action")!=="auth"||!O||!Qe(O)?null:{provider:O,displayName:va(O),isFirstAccount:!1}}),u=d.useMemo(()=>s?.authStatus||[],[s?.authStatus]),E=d.useMemo(()=>ja(u,v=>v.provider),[u]),N=s?.source==="remote",z=d.useMemo(()=>n?.variants||[],[n?.variants]),P=d.useMemo(()=>Mt(l?.catalogs),[l?.catalogs]),L=l?.routing??{},_=!!l,G=v=>{A(v),v&&localStorage.setItem("cliproxy-selected-provider",v)},V=d.useMemo(()=>C?null:D&&u.some(v=>v.provider===D)?D:u.length>0&&(u.find(O=>(O.accounts?.length||0)>0)?.provider||u[0]?.provider)||null,[D,C,u]),q=u.find(v=>v.provider===V),S=z.find(v=>v.name===C),R=S?u.find(v=>v.provider===S.provider):void 0,b=(S?.provider||q?.provider||"").toLowerCase().trim(),Q=b==="gemini"||b==="agy",te=()=>{a.invalidateQueries({queryKey:["cliproxy"]}),a.invalidateQueries({queryKey:["cliproxy-auth"]}),a.invalidateQueries({queryKey:["cliproxy-catalog"]}),a.invalidateQueries({queryKey:["cliproxy-models"]})},ne=(v,O,be)=>{m.isPending||j.isPending||(be?m.mutate({provider:v,accountId:O}):j.mutate({provider:v,accountId:O}))},U=(v,O)=>{g.isPending||g.mutate({provider:v,accountId:O})},ae=(v,O)=>{x.isPending||x.mutate({provider:v,accountIds:O})},$=(v,O)=>{T.isPending||T.mutate({provider:v,accountIds:O})},Z=v=>{G(v),y(null)},ie=v=>{y(v),G(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(Ie,{className:"w-5 h-5 text-primary"}),e.jsx("h1",{className:"font-semibold",children:o?.backendLabel??"CLIProxy"})]}),e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:te,disabled:c,children:e.jsx(wt,{className:X("w-4 h-4",c&&"animate-spin")})})]}),e.jsx("p",{className:"text-xs text-muted-foreground mb-3",children:t("cliproxyPage.accountManagement")}),e.jsxs(K,{variant:"default",size:"sm",className:"w-full gap-2",onClick:()=>h(!0),children:[e.jsx(De,{className:"w-4 h-4"}),t("cliproxyPage.quickSetup")]})]}),e.jsx(Nt,{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")}),i?e.jsx("div",{className:"space-y-2 px-2",children:[1,2,3,4].map(v=>e.jsx(ba,{className:"h-14 w-full rounded-lg"},v))}):e.jsx("div",{className:"space-y-4",children:E.map(v=>e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"px-3",children:[e.jsx("div",{className:"text-[11px] font-medium uppercase tracking-wide text-muted-foreground",children:t(v.labelKey)}),e.jsx("p",{className:"mt-1 text-[11px] leading-relaxed text-muted-foreground",children:t(v.hintKey)})]}),e.jsx("div",{className:"space-y-1",children:v.items.map(O=>e.jsx(Pn,{status:O,isSelected:V===O.provider,onSelect:()=>Z(O.provider)},O.provider))})]},v.id))}),z.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(xs,{className:"w-3 h-3"}),t("cliproxyPage.variants")]}),e.jsx("div",{className:"space-y-1",children:z.map(v=>e.jsx(Dn,{variant:v,parentAuth:u.find(O=>O.provider===v.provider),isSelected:C===v.name,onSelect:()=>ie(v.name),onDelete:()=>k.mutate(v.name),isDeleting:k.isPending},v.name))})]})]})}),e.jsx("div",{className:"p-3 border-t",children:e.jsx(Ta,{})}),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:u.length})}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(we,{className:"w-3 h-3 text-green-600"}),t("cliproxyPage.connectedCount",{count:u.filter(v=>v.authenticated).length})]})]})})]}),e.jsx("div",{className:"flex-1 flex min-w-0 flex-col overflow-hidden bg-background",children:S&&R?e.jsx(e.Fragment,{children:e.jsx(Vt,{provider:S.name,displayName:t("cliproxyPage.variantDisplay",{name:S.name,provider:S.provider}),authStatus:R,catalog:P[S.provider],routing:L[S.provider],logoProvider:S.provider,baseProvider:S.provider,defaultTarget:S.target,isRemoteMode:N,port:S.port,topNotice:Q?e.jsx(xt,{compact:!0,showProxySettingsLink:!0}):void 0,onAddAccount:()=>I({provider:S.provider,displayName:R.displayName,isFirstAccount:(R.accounts?.length||0)===0}),onSetDefault:v=>r.mutate({provider:S.provider,accountId:v}),onRemoveAccount:v=>p.mutate({provider:S.provider,accountId:v}),onPauseToggle:(v,O)=>ne(S.provider,v,O),onSoloMode:v=>U(S.provider,v),onBulkPause:v=>ae(S.provider,v),onBulkResume:v=>$(S.provider,v),isRemovingAccount:p.isPending,isPausingAccount:m.isPending||j.isPending,isSoloingAccount:g.isPending,isBulkPausing:x.isPending,isBulkResuming:T.isPending})}):q?e.jsx(e.Fragment,{children:e.jsx(Vt,{provider:q.provider,displayName:q.displayName,authStatus:q,catalog:P[q.provider],routing:L[q.provider],isRemoteMode:N,topNotice:Q?e.jsx(xt,{compact:!0,showProxySettingsLink:!0}):void 0,onAddAccount:()=>I({provider:q.provider,displayName:q.displayName,isFirstAccount:(q.accounts?.length||0)===0}),onSetDefault:v=>r.mutate({provider:q.provider,accountId:v}),onRemoveAccount:v=>p.mutate({provider:q.provider,accountId:v}),onPauseToggle:(v,O)=>ne(q.provider,v,O),onSoloMode:v=>U(q.provider,v),onBulkPause:v=>ae(q.provider,v),onBulkResume:v=>$(q.provider,v),isRemovingAccount:p.isPending,isPausingAccount:m.isPending||j.isPending,isSoloingAccount:g.isPending,isBulkPausing:x.isPending,isBulkResuming:T.isPending})}):e.jsx(In,{onSetup:()=>h(!0)})}),e.jsx(tn,{open:w,onClose:()=>h(!1)}),e.jsx(dn,{open:f!==null,onClose:()=>I(null),provider:f?.provider||"",displayName:f?.displayName||"",catalog:_&&f?.provider?P[f.provider]:void 0,isFirstAccount:f?.isFirstAccount||!1})]})}export{Qn as CliproxyPage};