@kaitranntt/ccs 8.4.0 → 8.5.0

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 (672) hide show
  1. package/README.md +5 -2
  2. package/config/base-claude.settings.json +1 -1
  3. package/config/base-glm.settings.json +4 -4
  4. package/config/base-glmt.settings.json +4 -4
  5. package/config/base-km.settings.json +4 -4
  6. package/config/base-mm.settings.json +4 -4
  7. package/dist/api/services/cliproxy-profile-bridge.d.ts.map +1 -1
  8. package/dist/api/services/cliproxy-profile-bridge.js +20 -9
  9. package/dist/api/services/cliproxy-profile-bridge.js.map +1 -1
  10. package/dist/auth/profile-registry.d.ts.map +1 -1
  11. package/dist/auth/profile-registry.js +13 -12
  12. package/dist/auth/profile-registry.js.map +1 -1
  13. package/dist/cliproxy/accounts/account-safety.d.ts.map +1 -1
  14. package/dist/cliproxy/accounts/account-safety.js +56 -56
  15. package/dist/cliproxy/accounts/account-safety.js.map +1 -1
  16. package/dist/cliproxy/auth/antigravity-responsibility.d.ts.map +1 -1
  17. package/dist/cliproxy/auth/antigravity-responsibility.js +15 -15
  18. package/dist/cliproxy/auth/antigravity-responsibility.js.map +1 -1
  19. package/dist/cliproxy/auth/auth-token-manager.d.ts.map +1 -1
  20. package/dist/cliproxy/auth/auth-token-manager.js +2 -1
  21. package/dist/cliproxy/auth/auth-token-manager.js.map +1 -1
  22. package/dist/cliproxy/auth/auth-types.d.ts.map +1 -1
  23. package/dist/cliproxy/auth/auth-types.js +3 -2
  24. package/dist/cliproxy/auth/auth-types.js.map +1 -1
  25. package/dist/cliproxy/auth/oauth-handler.d.ts.map +1 -1
  26. package/dist/cliproxy/auth/oauth-handler.js +16 -5
  27. package/dist/cliproxy/auth/oauth-handler.js.map +1 -1
  28. package/dist/cliproxy/auth/provider-refreshers/index.d.ts +2 -1
  29. package/dist/cliproxy/auth/provider-refreshers/index.d.ts.map +1 -1
  30. package/dist/cliproxy/auth/provider-refreshers/index.js +4 -2
  31. package/dist/cliproxy/auth/provider-refreshers/index.js.map +1 -1
  32. package/dist/cliproxy/auth/token-manager.d.ts +2 -1
  33. package/dist/cliproxy/auth/token-manager.d.ts.map +1 -1
  34. package/dist/cliproxy/auth/token-manager.js +2 -1
  35. package/dist/cliproxy/auth/token-manager.js.map +1 -1
  36. package/dist/cliproxy/config/env-builder.d.ts +19 -2
  37. package/dist/cliproxy/config/env-builder.d.ts.map +1 -1
  38. package/dist/cliproxy/config/env-builder.js +58 -9
  39. package/dist/cliproxy/config/env-builder.js.map +1 -1
  40. package/dist/cliproxy/config/model-config.d.ts.map +1 -1
  41. package/dist/cliproxy/config/model-config.js +32 -32
  42. package/dist/cliproxy/config/model-config.js.map +1 -1
  43. package/dist/cliproxy/executor/arg-parser.d.ts.map +1 -1
  44. package/dist/cliproxy/executor/arg-parser.js +26 -26
  45. package/dist/cliproxy/executor/arg-parser.js.map +1 -1
  46. package/dist/cliproxy/executor/auth-coordinator.d.ts.map +1 -1
  47. package/dist/cliproxy/executor/auth-coordinator.js +15 -14
  48. package/dist/cliproxy/executor/auth-coordinator.js.map +1 -1
  49. package/dist/cliproxy/executor/browser-launch-setup.d.ts.map +1 -1
  50. package/dist/cliproxy/executor/browser-launch-setup.js +6 -2
  51. package/dist/cliproxy/executor/browser-launch-setup.js.map +1 -1
  52. package/dist/cliproxy/executor/index.d.ts.map +1 -1
  53. package/dist/cliproxy/executor/index.js +27 -17
  54. package/dist/cliproxy/executor/index.js.map +1 -1
  55. package/dist/cliproxy/executor/lifecycle-manager.d.ts.map +1 -1
  56. package/dist/cliproxy/executor/lifecycle-manager.js +18 -16
  57. package/dist/cliproxy/executor/lifecycle-manager.js.map +1 -1
  58. package/dist/cliproxy/executor/model-warnings.d.ts.map +1 -1
  59. package/dist/cliproxy/executor/model-warnings.js +24 -13
  60. package/dist/cliproxy/executor/model-warnings.js.map +1 -1
  61. package/dist/cliproxy/executor/retry-handler.d.ts.map +1 -1
  62. package/dist/cliproxy/executor/retry-handler.js +13 -11
  63. package/dist/cliproxy/executor/retry-handler.js.map +1 -1
  64. package/dist/cliproxy/executor/session-bridge.d.ts.map +1 -1
  65. package/dist/cliproxy/executor/session-bridge.js +18 -10
  66. package/dist/cliproxy/executor/session-bridge.js.map +1 -1
  67. package/dist/cliproxy/management/remote-token-uploader.d.ts.map +1 -1
  68. package/dist/cliproxy/management/remote-token-uploader.js +11 -11
  69. package/dist/cliproxy/management/remote-token-uploader.js.map +1 -1
  70. package/dist/cliproxy/provider-capabilities.d.ts +6 -0
  71. package/dist/cliproxy/provider-capabilities.d.ts.map +1 -1
  72. package/dist/cliproxy/provider-capabilities.js +28 -3
  73. package/dist/cliproxy/provider-capabilities.js.map +1 -1
  74. package/dist/cliproxy/proxy/https-tunnel-proxy.d.ts +5 -1
  75. package/dist/cliproxy/proxy/https-tunnel-proxy.d.ts.map +1 -1
  76. package/dist/cliproxy/proxy/https-tunnel-proxy.js +22 -10
  77. package/dist/cliproxy/proxy/https-tunnel-proxy.js.map +1 -1
  78. package/dist/cliproxy/proxy/tool-sanitization-proxy.d.ts +0 -12
  79. package/dist/cliproxy/proxy/tool-sanitization-proxy.d.ts.map +1 -1
  80. package/dist/cliproxy/proxy/tool-sanitization-proxy.js +42 -72
  81. package/dist/cliproxy/proxy/tool-sanitization-proxy.js.map +1 -1
  82. package/dist/cliproxy/quota/quota-fetcher/account-quota-fetcher.d.ts +21 -0
  83. package/dist/cliproxy/quota/quota-fetcher/account-quota-fetcher.d.ts.map +1 -0
  84. package/dist/cliproxy/quota/quota-fetcher/account-quota-fetcher.js +154 -0
  85. package/dist/cliproxy/quota/quota-fetcher/account-quota-fetcher.js.map +1 -0
  86. package/dist/cliproxy/quota/quota-fetcher/all-accounts-fetcher.d.ts +35 -0
  87. package/dist/cliproxy/quota/quota-fetcher/all-accounts-fetcher.d.ts.map +1 -0
  88. package/dist/cliproxy/quota/quota-fetcher/all-accounts-fetcher.js +98 -0
  89. package/dist/cliproxy/quota/quota-fetcher/all-accounts-fetcher.js.map +1 -0
  90. package/dist/cliproxy/quota/quota-fetcher/auth-file-reader.d.ts +22 -0
  91. package/dist/cliproxy/quota/quota-fetcher/auth-file-reader.d.ts.map +1 -0
  92. package/dist/cliproxy/quota/quota-fetcher/auth-file-reader.js +111 -0
  93. package/dist/cliproxy/quota/quota-fetcher/auth-file-reader.js.map +1 -0
  94. package/dist/cliproxy/quota/quota-fetcher/available-models-fetcher.d.ts +17 -0
  95. package/dist/cliproxy/quota/quota-fetcher/available-models-fetcher.d.ts.map +1 -0
  96. package/dist/cliproxy/quota/quota-fetcher/available-models-fetcher.js +85 -0
  97. package/dist/cliproxy/quota/quota-fetcher/available-models-fetcher.js.map +1 -0
  98. package/dist/cliproxy/quota/quota-fetcher/constants.d.ts +25 -0
  99. package/dist/cliproxy/quota/quota-fetcher/constants.d.ts.map +1 -0
  100. package/dist/cliproxy/quota/quota-fetcher/constants.js +31 -0
  101. package/dist/cliproxy/quota/quota-fetcher/constants.js.map +1 -0
  102. package/dist/cliproxy/quota/quota-fetcher/http-client.d.ts +29 -0
  103. package/dist/cliproxy/quota/quota-fetcher/http-client.d.ts.map +1 -0
  104. package/dist/cliproxy/quota/quota-fetcher/http-client.js +199 -0
  105. package/dist/cliproxy/quota/quota-fetcher/http-client.js.map +1 -0
  106. package/dist/cliproxy/quota/quota-fetcher/project-lookup.d.ts +16 -0
  107. package/dist/cliproxy/quota/quota-fetcher/project-lookup.d.ts.map +1 -0
  108. package/dist/cliproxy/quota/quota-fetcher/project-lookup.js +89 -0
  109. package/dist/cliproxy/quota/quota-fetcher/project-lookup.js.map +1 -0
  110. package/dist/cliproxy/quota/quota-fetcher/status-classifier.d.ts +29 -0
  111. package/dist/cliproxy/quota/quota-fetcher/status-classifier.d.ts.map +1 -0
  112. package/dist/cliproxy/quota/quota-fetcher/status-classifier.js +168 -0
  113. package/dist/cliproxy/quota/quota-fetcher/status-classifier.js.map +1 -0
  114. package/dist/cliproxy/quota/quota-fetcher/types.d.ts +165 -0
  115. package/dist/cliproxy/quota/quota-fetcher/types.d.ts.map +1 -0
  116. package/dist/cliproxy/quota/quota-fetcher/types.js +9 -0
  117. package/dist/cliproxy/quota/quota-fetcher/types.js.map +1 -0
  118. package/dist/cliproxy/quota/quota-fetcher-claude.d.ts.map +1 -1
  119. package/dist/cliproxy/quota/quota-fetcher-claude.js +14 -3
  120. package/dist/cliproxy/quota/quota-fetcher-claude.js.map +1 -1
  121. package/dist/cliproxy/quota/quota-fetcher-codex.d.ts.map +1 -1
  122. package/dist/cliproxy/quota/quota-fetcher-codex.js +36 -9
  123. package/dist/cliproxy/quota/quota-fetcher-codex.js.map +1 -1
  124. package/dist/cliproxy/quota/quota-fetcher-gemini-cli/auth-file-discovery.d.ts +26 -0
  125. package/dist/cliproxy/quota/quota-fetcher-gemini-cli/auth-file-discovery.d.ts.map +1 -0
  126. package/dist/cliproxy/quota/quota-fetcher-gemini-cli/auth-file-discovery.js +132 -0
  127. package/dist/cliproxy/quota/quota-fetcher-gemini-cli/auth-file-discovery.js.map +1 -0
  128. package/dist/cliproxy/quota/quota-fetcher-gemini-cli/bucket-building.d.ts +23 -0
  129. package/dist/cliproxy/quota/quota-fetcher-gemini-cli/bucket-building.d.ts.map +1 -0
  130. package/dist/cliproxy/quota/quota-fetcher-gemini-cli/bucket-building.js +54 -0
  131. package/dist/cliproxy/quota/quota-fetcher-gemini-cli/bucket-building.js.map +1 -0
  132. package/dist/cliproxy/quota/quota-fetcher-gemini-cli/constants.d.ts +26 -0
  133. package/dist/cliproxy/quota/quota-fetcher-gemini-cli/constants.d.ts.map +1 -0
  134. package/dist/cliproxy/quota/quota-fetcher-gemini-cli/constants.js +29 -0
  135. package/dist/cliproxy/quota/quota-fetcher-gemini-cli/constants.js.map +1 -0
  136. package/dist/cliproxy/quota/quota-fetcher-gemini-cli/error-parsing.d.ts +61 -0
  137. package/dist/cliproxy/quota/quota-fetcher-gemini-cli/error-parsing.d.ts.map +1 -0
  138. package/dist/cliproxy/quota/quota-fetcher-gemini-cli/error-parsing.js +259 -0
  139. package/dist/cliproxy/quota/quota-fetcher-gemini-cli/error-parsing.js.map +1 -0
  140. package/dist/cliproxy/quota/quota-fetcher-gemini-cli/index.d.ts +20 -0
  141. package/dist/cliproxy/quota/quota-fetcher-gemini-cli/index.d.ts.map +1 -0
  142. package/dist/cliproxy/quota/quota-fetcher-gemini-cli/index.js +38 -0
  143. package/dist/cliproxy/quota/quota-fetcher-gemini-cli/index.js.map +1 -0
  144. package/dist/cliproxy/quota/quota-fetcher-gemini-cli/managed-request.d.ts +82 -0
  145. package/dist/cliproxy/quota/quota-fetcher-gemini-cli/managed-request.d.ts.map +1 -0
  146. package/dist/cliproxy/quota/quota-fetcher-gemini-cli/managed-request.js +263 -0
  147. package/dist/cliproxy/quota/quota-fetcher-gemini-cli/managed-request.js.map +1 -0
  148. package/dist/cliproxy/quota/quota-fetcher-gemini-cli/quota-fetcher.d.ts +46 -0
  149. package/dist/cliproxy/quota/quota-fetcher-gemini-cli/quota-fetcher.d.ts.map +1 -0
  150. package/dist/cliproxy/quota/quota-fetcher-gemini-cli/quota-fetcher.js +188 -0
  151. package/dist/cliproxy/quota/quota-fetcher-gemini-cli/quota-fetcher.js.map +1 -0
  152. package/dist/cliproxy/quota/quota-fetcher-gemini-cli/shared-utils.d.ts +35 -0
  153. package/dist/cliproxy/quota/quota-fetcher-gemini-cli/shared-utils.d.ts.map +1 -0
  154. package/dist/cliproxy/quota/quota-fetcher-gemini-cli/shared-utils.js +65 -0
  155. package/dist/cliproxy/quota/quota-fetcher-gemini-cli/shared-utils.js.map +1 -0
  156. package/dist/cliproxy/quota/quota-fetcher-gemini-cli/supplementary-metadata.d.ts +37 -0
  157. package/dist/cliproxy/quota/quota-fetcher-gemini-cli/supplementary-metadata.d.ts.map +1 -0
  158. package/dist/cliproxy/quota/quota-fetcher-gemini-cli/supplementary-metadata.js +117 -0
  159. package/dist/cliproxy/quota/quota-fetcher-gemini-cli/supplementary-metadata.js.map +1 -0
  160. package/dist/cliproxy/quota/quota-fetcher-gemini-cli/token-parsing.d.ts +31 -0
  161. package/dist/cliproxy/quota/quota-fetcher-gemini-cli/token-parsing.d.ts.map +1 -0
  162. package/dist/cliproxy/quota/quota-fetcher-gemini-cli/token-parsing.js +77 -0
  163. package/dist/cliproxy/quota/quota-fetcher-gemini-cli/token-parsing.js.map +1 -0
  164. package/dist/cliproxy/quota/quota-fetcher-gemini-cli/types.d.ts +114 -0
  165. package/dist/cliproxy/quota/quota-fetcher-gemini-cli/types.d.ts.map +1 -0
  166. package/dist/cliproxy/quota/quota-fetcher-gemini-cli/types.js +10 -0
  167. package/dist/cliproxy/quota/quota-fetcher-gemini-cli/types.js.map +1 -0
  168. package/dist/cliproxy/quota/quota-fetcher-gemini-cli.d.ts +13 -58
  169. package/dist/cliproxy/quota/quota-fetcher-gemini-cli.d.ts.map +1 -1
  170. package/dist/cliproxy/quota/quota-fetcher-gemini-cli.js +20 -819
  171. package/dist/cliproxy/quota/quota-fetcher-gemini-cli.js.map +1 -1
  172. package/dist/cliproxy/quota/quota-fetcher-ghcp.d.ts.map +1 -1
  173. package/dist/cliproxy/quota/quota-fetcher-ghcp.js +19 -4
  174. package/dist/cliproxy/quota/quota-fetcher-ghcp.js.map +1 -1
  175. package/dist/cliproxy/quota/quota-fetcher.d.ts +12 -108
  176. package/dist/cliproxy/quota/quota-fetcher.d.ts.map +1 -1
  177. package/dist/cliproxy/quota/quota-fetcher.js +23 -766
  178. package/dist/cliproxy/quota/quota-fetcher.js.map +1 -1
  179. package/dist/cliproxy/quota/quota-manager.d.ts.map +1 -1
  180. package/dist/cliproxy/quota/quota-manager.js +7 -3
  181. package/dist/cliproxy/quota/quota-manager.js.map +1 -1
  182. package/dist/cliproxy/routing/routing-strategy.d.ts.map +1 -1
  183. package/dist/cliproxy/routing/routing-strategy.js +11 -3
  184. package/dist/cliproxy/routing/routing-strategy.js.map +1 -1
  185. package/dist/commands/bar/bar-server-probe.d.ts +16 -3
  186. package/dist/commands/bar/bar-server-probe.d.ts.map +1 -1
  187. package/dist/commands/bar/bar-server-probe.js +83 -18
  188. package/dist/commands/bar/bar-server-probe.js.map +1 -1
  189. package/dist/commands/bar/help-subcommand.d.ts.map +1 -1
  190. package/dist/commands/bar/help-subcommand.js +2 -2
  191. package/dist/commands/bar/help-subcommand.js.map +1 -1
  192. package/dist/commands/bar/install-subcommand.d.ts +4 -10
  193. package/dist/commands/bar/install-subcommand.d.ts.map +1 -1
  194. package/dist/commands/bar/install-subcommand.js +44 -53
  195. package/dist/commands/bar/install-subcommand.js.map +1 -1
  196. package/dist/commands/bar/launch-subcommand.d.ts +11 -1
  197. package/dist/commands/bar/launch-subcommand.d.ts.map +1 -1
  198. package/dist/commands/bar/launch-subcommand.js +82 -15
  199. package/dist/commands/bar/launch-subcommand.js.map +1 -1
  200. package/dist/commands/cliproxy/quota-subcommand/claude-window-helpers.d.ts +26 -0
  201. package/dist/commands/cliproxy/quota-subcommand/claude-window-helpers.d.ts.map +1 -0
  202. package/dist/commands/cliproxy/quota-subcommand/claude-window-helpers.js +82 -0
  203. package/dist/commands/cliproxy/quota-subcommand/claude-window-helpers.js.map +1 -0
  204. package/dist/commands/cliproxy/quota-subcommand/codex-window-helpers.d.ts +41 -0
  205. package/dist/commands/cliproxy/quota-subcommand/codex-window-helpers.d.ts.map +1 -0
  206. package/dist/commands/cliproxy/quota-subcommand/codex-window-helpers.js +202 -0
  207. package/dist/commands/cliproxy/quota-subcommand/codex-window-helpers.js.map +1 -0
  208. package/dist/commands/cliproxy/quota-subcommand/format-helpers.d.ts +32 -0
  209. package/dist/commands/cliproxy/quota-subcommand/format-helpers.d.ts.map +1 -0
  210. package/dist/commands/cliproxy/quota-subcommand/format-helpers.js +90 -0
  211. package/dist/commands/cliproxy/quota-subcommand/format-helpers.js.map +1 -0
  212. package/dist/commands/cliproxy/quota-subcommand/handlers.d.ts +25 -0
  213. package/dist/commands/cliproxy/quota-subcommand/handlers.d.ts.map +1 -0
  214. package/dist/commands/cliproxy/quota-subcommand/handlers.js +245 -0
  215. package/dist/commands/cliproxy/quota-subcommand/handlers.js.map +1 -0
  216. package/dist/commands/cliproxy/quota-subcommand/profile-args.d.ts +10 -0
  217. package/dist/commands/cliproxy/quota-subcommand/profile-args.d.ts.map +1 -0
  218. package/dist/commands/cliproxy/quota-subcommand/profile-args.js +37 -0
  219. package/dist/commands/cliproxy/quota-subcommand/profile-args.js.map +1 -0
  220. package/dist/commands/cliproxy/quota-subcommand/provider-runtime.d.ts +12 -0
  221. package/dist/commands/cliproxy/quota-subcommand/provider-runtime.d.ts.map +1 -0
  222. package/dist/commands/cliproxy/quota-subcommand/provider-runtime.js +64 -0
  223. package/dist/commands/cliproxy/quota-subcommand/provider-runtime.js.map +1 -0
  224. package/dist/commands/cliproxy/quota-subcommand/quota-failure-display.d.ts +27 -0
  225. package/dist/commands/cliproxy/quota-subcommand/quota-failure-display.d.ts.map +1 -0
  226. package/dist/commands/cliproxy/quota-subcommand/quota-failure-display.js +74 -0
  227. package/dist/commands/cliproxy/quota-subcommand/quota-failure-display.js.map +1 -0
  228. package/dist/commands/cliproxy/quota-subcommand/sections/antigravity.d.ts +10 -0
  229. package/dist/commands/cliproxy/quota-subcommand/sections/antigravity.d.ts.map +1 -0
  230. package/dist/commands/cliproxy/quota-subcommand/sections/antigravity.js +46 -0
  231. package/dist/commands/cliproxy/quota-subcommand/sections/antigravity.js.map +1 -0
  232. package/dist/commands/cliproxy/quota-subcommand/sections/claude.d.ts +14 -0
  233. package/dist/commands/cliproxy/quota-subcommand/sections/claude.d.ts.map +1 -0
  234. package/dist/commands/cliproxy/quota-subcommand/sections/claude.js +68 -0
  235. package/dist/commands/cliproxy/quota-subcommand/sections/claude.js.map +1 -0
  236. package/dist/commands/cliproxy/quota-subcommand/sections/codex.d.ts +14 -0
  237. package/dist/commands/cliproxy/quota-subcommand/sections/codex.d.ts.map +1 -0
  238. package/dist/commands/cliproxy/quota-subcommand/sections/codex.js +82 -0
  239. package/dist/commands/cliproxy/quota-subcommand/sections/codex.js.map +1 -0
  240. package/dist/commands/cliproxy/quota-subcommand/sections/gemini-cli.d.ts +14 -0
  241. package/dist/commands/cliproxy/quota-subcommand/sections/gemini-cli.d.ts.map +1 -0
  242. package/dist/commands/cliproxy/quota-subcommand/sections/gemini-cli.js +61 -0
  243. package/dist/commands/cliproxy/quota-subcommand/sections/gemini-cli.js.map +1 -0
  244. package/dist/commands/cliproxy/quota-subcommand/sections/ghcp.d.ts +13 -0
  245. package/dist/commands/cliproxy/quota-subcommand/sections/ghcp.d.ts.map +1 -0
  246. package/dist/commands/cliproxy/quota-subcommand/sections/ghcp.js +63 -0
  247. package/dist/commands/cliproxy/quota-subcommand/sections/ghcp.js.map +1 -0
  248. package/dist/commands/cliproxy/quota-subcommand/test-exports.d.ts +19 -0
  249. package/dist/commands/cliproxy/quota-subcommand/test-exports.d.ts.map +1 -0
  250. package/dist/commands/cliproxy/quota-subcommand/test-exports.js +22 -0
  251. package/dist/commands/cliproxy/quota-subcommand/test-exports.js.map +1 -0
  252. package/dist/commands/cliproxy/quota-subcommand/types.d.ts +42 -0
  253. package/dist/commands/cliproxy/quota-subcommand/types.d.ts.map +1 -0
  254. package/dist/commands/cliproxy/quota-subcommand/types.js +9 -0
  255. package/dist/commands/cliproxy/quota-subcommand/types.js.map +1 -0
  256. package/dist/commands/cliproxy/quota-subcommand.d.ts +14 -36
  257. package/dist/commands/cliproxy/quota-subcommand.d.ts.map +1 -1
  258. package/dist/commands/cliproxy/quota-subcommand.js +21 -872
  259. package/dist/commands/cliproxy/quota-subcommand.js.map +1 -1
  260. package/dist/commands/command-catalog.js +1 -1
  261. package/dist/commands/command-catalog.js.map +1 -1
  262. package/dist/commands/config-channels-command.d.ts +1 -1
  263. package/dist/commands/config-channels-command.d.ts.map +1 -1
  264. package/dist/commands/config-channels-command.js +3 -3
  265. package/dist/commands/config-channels-command.js.map +1 -1
  266. package/dist/commands/config-command-options.d.ts.map +1 -1
  267. package/dist/commands/config-command-options.js +11 -2
  268. package/dist/commands/config-command-options.js.map +1 -1
  269. package/dist/commands/persist-command/arg-parsing.d.ts +14 -0
  270. package/dist/commands/persist-command/arg-parsing.d.ts.map +1 -0
  271. package/dist/commands/persist-command/arg-parsing.js +84 -0
  272. package/dist/commands/persist-command/arg-parsing.js.map +1 -0
  273. package/dist/commands/persist-command/backup-rotation.d.ts +23 -0
  274. package/dist/commands/persist-command/backup-rotation.d.ts.map +1 -0
  275. package/dist/commands/persist-command/backup-rotation.js +260 -0
  276. package/dist/commands/persist-command/backup-rotation.js.map +1 -0
  277. package/dist/commands/persist-command/handler.d.ts +10 -0
  278. package/dist/commands/persist-command/handler.d.ts.map +1 -0
  279. package/dist/commands/persist-command/handler.js +267 -0
  280. package/dist/commands/persist-command/handler.js.map +1 -0
  281. package/dist/commands/persist-command/help.d.ts +9 -0
  282. package/dist/commands/persist-command/help.d.ts.map +1 -0
  283. package/dist/commands/persist-command/help.js +86 -0
  284. package/dist/commands/persist-command/help.js.map +1 -0
  285. package/dist/commands/persist-command/receipt.d.ts +13 -0
  286. package/dist/commands/persist-command/receipt.d.ts.map +1 -0
  287. package/dist/commands/persist-command/receipt.js +102 -0
  288. package/dist/commands/persist-command/receipt.js.map +1 -0
  289. package/dist/commands/persist-command/secret-detection.d.ts +11 -0
  290. package/dist/commands/persist-command/secret-detection.d.ts.map +1 -0
  291. package/dist/commands/persist-command/secret-detection.js +54 -0
  292. package/dist/commands/persist-command/secret-detection.js.map +1 -0
  293. package/dist/commands/persist-command/secure-file.d.ts +21 -0
  294. package/dist/commands/persist-command/secure-file.d.ts.map +1 -0
  295. package/dist/commands/persist-command/secure-file.js +231 -0
  296. package/dist/commands/persist-command/secure-file.js.map +1 -0
  297. package/dist/commands/persist-command/types.d.ts +42 -0
  298. package/dist/commands/persist-command/types.d.ts.map +1 -0
  299. package/dist/commands/persist-command/types.js +34 -0
  300. package/dist/commands/persist-command/types.js.map +1 -0
  301. package/dist/commands/persist-command.d.ts +7 -2
  302. package/dist/commands/persist-command.d.ts.map +1 -1
  303. package/dist/commands/persist-command.js +17 -933
  304. package/dist/commands/persist-command.js.map +1 -1
  305. package/dist/config/config-loader-facade.d.ts +1 -1
  306. package/dist/config/config-loader-facade.d.ts.map +1 -1
  307. package/dist/config/config-loader-facade.js +3 -1
  308. package/dist/config/config-loader-facade.js.map +1 -1
  309. package/dist/config/loader/config-getters.d.ts +16 -0
  310. package/dist/config/loader/config-getters.d.ts.map +1 -1
  311. package/dist/config/loader/config-getters.js +33 -1
  312. package/dist/config/loader/config-getters.js.map +1 -1
  313. package/dist/config/loader/defaults-merger.d.ts.map +1 -1
  314. package/dist/config/loader/defaults-merger.js +4 -0
  315. package/dist/config/loader/defaults-merger.js.map +1 -1
  316. package/dist/config/loader/yaml-serializer.d.ts.map +1 -1
  317. package/dist/config/loader/yaml-serializer.js +13 -0
  318. package/dist/config/loader/yaml-serializer.js.map +1 -1
  319. package/dist/config/schemas/index.d.ts +2 -0
  320. package/dist/config/schemas/index.d.ts.map +1 -1
  321. package/dist/config/schemas/index.js +5 -1
  322. package/dist/config/schemas/index.js.map +1 -1
  323. package/dist/config/schemas/runtime.d.ts +57 -0
  324. package/dist/config/schemas/runtime.d.ts.map +1 -0
  325. package/dist/config/schemas/runtime.js +51 -0
  326. package/dist/config/schemas/runtime.js.map +1 -0
  327. package/dist/config/schemas/unified-config.d.ts +3 -0
  328. package/dist/config/schemas/unified-config.d.ts.map +1 -1
  329. package/dist/config/schemas/unified-config.js.map +1 -1
  330. package/dist/config/unified-config-loader.d.ts +1 -1
  331. package/dist/config/unified-config-loader.d.ts.map +1 -1
  332. package/dist/config/unified-config-loader.js +3 -1
  333. package/dist/config/unified-config-loader.js.map +1 -1
  334. package/dist/copilot/copilot-executor.js +25 -25
  335. package/dist/copilot/copilot-executor.js.map +1 -1
  336. package/dist/cursor/cursor-daemon-entry.d.ts.map +1 -1
  337. package/dist/cursor/cursor-daemon-entry.js +34 -9
  338. package/dist/cursor/cursor-daemon-entry.js.map +1 -1
  339. package/dist/cursor/cursor-daemon.d.ts.map +1 -1
  340. package/dist/cursor/cursor-daemon.js +1 -0
  341. package/dist/cursor/cursor-daemon.js.map +1 -1
  342. package/dist/cursor/cursor-profile-executor.d.ts.map +1 -1
  343. package/dist/cursor/cursor-profile-executor.js +18 -17
  344. package/dist/cursor/cursor-profile-executor.js.map +1 -1
  345. package/dist/delegation/delegation-handler.d.ts.map +1 -1
  346. package/dist/delegation/delegation-handler.js +29 -23
  347. package/dist/delegation/delegation-handler.js.map +1 -1
  348. package/dist/delegation/headless-executor.d.ts +1 -0
  349. package/dist/delegation/headless-executor.d.ts.map +1 -1
  350. package/dist/delegation/headless-executor.js +36 -15
  351. package/dist/delegation/headless-executor.js.map +1 -1
  352. package/dist/delegation/session-manager.d.ts.map +1 -1
  353. package/dist/delegation/session-manager.js +12 -4
  354. package/dist/delegation/session-manager.js.map +1 -1
  355. package/dist/dispatcher/cli-argument-parser.d.ts +1 -1
  356. package/dist/dispatcher/cli-argument-parser.d.ts.map +1 -1
  357. package/dist/dispatcher/cli-argument-parser.js +24 -23
  358. package/dist/dispatcher/cli-argument-parser.js.map +1 -1
  359. package/dist/dispatcher/flows/cliproxy-flow.d.ts.map +1 -1
  360. package/dist/dispatcher/flows/cliproxy-flow.js +12 -15
  361. package/dist/dispatcher/flows/cliproxy-flow.js.map +1 -1
  362. package/dist/dispatcher/flows/copilot-flow.js +1 -1
  363. package/dist/dispatcher/flows/copilot-flow.js.map +1 -1
  364. package/dist/dispatcher/flows/cursor-flow.js +1 -1
  365. package/dist/dispatcher/flows/cursor-flow.js.map +1 -1
  366. package/dist/dispatcher/flows/settings-flow.d.ts.map +1 -1
  367. package/dist/dispatcher/flows/settings-flow.js +32 -29
  368. package/dist/dispatcher/flows/settings-flow.js.map +1 -1
  369. package/dist/dispatcher/profile-resolver.d.ts +1 -1
  370. package/dist/dispatcher/profile-resolver.d.ts.map +1 -1
  371. package/dist/dispatcher/profile-resolver.js +36 -23
  372. package/dist/dispatcher/profile-resolver.js.map +1 -1
  373. package/dist/docker/supervisord-lifecycle.d.ts.map +1 -1
  374. package/dist/docker/supervisord-lifecycle.js +5 -1
  375. package/dist/docker/supervisord-lifecycle.js.map +1 -1
  376. package/dist/errors/error-types.d.ts +26 -22
  377. package/dist/errors/error-types.d.ts.map +1 -1
  378. package/dist/errors/error-types.js +15 -12
  379. package/dist/errors/error-types.js.map +1 -1
  380. package/dist/errors/exit-codes.d.ts +20 -13
  381. package/dist/errors/exit-codes.d.ts.map +1 -1
  382. package/dist/errors/exit-codes.js +32 -28
  383. package/dist/errors/exit-codes.js.map +1 -1
  384. package/dist/glmt/delta-accumulator.d.ts +1 -0
  385. package/dist/glmt/delta-accumulator.d.ts.map +1 -1
  386. package/dist/glmt/delta-accumulator.js +12 -4
  387. package/dist/glmt/delta-accumulator.js.map +1 -1
  388. package/dist/glmt/glmt-proxy.d.ts.map +1 -1
  389. package/dist/glmt/glmt-proxy.js +39 -10
  390. package/dist/glmt/glmt-proxy.js.map +1 -1
  391. package/dist/glmt/glmt-transformer.d.ts.map +1 -1
  392. package/dist/glmt/glmt-transformer.js +1 -4
  393. package/dist/glmt/glmt-transformer.js.map +1 -1
  394. package/dist/glmt/pipeline/request-transformer.d.ts.map +1 -1
  395. package/dist/glmt/pipeline/request-transformer.js +5 -1
  396. package/dist/glmt/pipeline/request-transformer.js.map +1 -1
  397. package/dist/glmt/pipeline/response-builder.d.ts.map +1 -1
  398. package/dist/glmt/pipeline/response-builder.js +7 -3
  399. package/dist/glmt/pipeline/response-builder.js.map +1 -1
  400. package/dist/glmt/pipeline/stream-parser.d.ts.map +1 -1
  401. package/dist/glmt/pipeline/stream-parser.js +11 -5
  402. package/dist/glmt/pipeline/stream-parser.js.map +1 -1
  403. package/dist/glmt/pipeline/tool-call-handler.d.ts.map +1 -1
  404. package/dist/glmt/pipeline/tool-call-handler.js +7 -1
  405. package/dist/glmt/pipeline/tool-call-handler.js.map +1 -1
  406. package/dist/glmt/sse-parser.d.ts +1 -0
  407. package/dist/glmt/sse-parser.d.ts.map +1 -1
  408. package/dist/glmt/sse-parser.js +7 -3
  409. package/dist/glmt/sse-parser.js.map +1 -1
  410. package/dist/management/shared-manager/fs-helpers.d.ts +69 -0
  411. package/dist/management/shared-manager/fs-helpers.d.ts.map +1 -0
  412. package/dist/management/shared-manager/fs-helpers.js +241 -0
  413. package/dist/management/shared-manager/fs-helpers.js.map +1 -0
  414. package/dist/management/shared-manager/migrations.d.ts +21 -0
  415. package/dist/management/shared-manager/migrations.d.ts.map +1 -0
  416. package/dist/management/shared-manager/migrations.js +187 -0
  417. package/dist/management/shared-manager/migrations.js.map +1 -0
  418. package/dist/management/shared-manager/orchestrator.d.ts +87 -0
  419. package/dist/management/shared-manager/orchestrator.d.ts.map +1 -0
  420. package/dist/management/shared-manager/orchestrator.js +161 -0
  421. package/dist/management/shared-manager/orchestrator.js.map +1 -0
  422. package/dist/management/shared-manager/plugin-layout-internals.d.ts +42 -0
  423. package/dist/management/shared-manager/plugin-layout-internals.d.ts.map +1 -0
  424. package/dist/management/shared-manager/plugin-layout-internals.js +192 -0
  425. package/dist/management/shared-manager/plugin-layout-internals.js.map +1 -0
  426. package/dist/management/shared-manager/plugin-metadata-normalizer.d.ts +53 -0
  427. package/dist/management/shared-manager/plugin-metadata-normalizer.d.ts.map +1 -0
  428. package/dist/management/shared-manager/plugin-metadata-normalizer.js +253 -0
  429. package/dist/management/shared-manager/plugin-metadata-normalizer.js.map +1 -0
  430. package/dist/management/shared-manager/project-context-sync.d.ts +36 -0
  431. package/dist/management/shared-manager/project-context-sync.d.ts.map +1 -0
  432. package/dist/management/shared-manager/project-context-sync.js +204 -0
  433. package/dist/management/shared-manager/project-context-sync.js.map +1 -0
  434. package/dist/management/shared-manager/project-memory-sync.d.ts +21 -0
  435. package/dist/management/shared-manager/project-memory-sync.d.ts.map +1 -0
  436. package/dist/management/shared-manager/project-memory-sync.js +113 -0
  437. package/dist/management/shared-manager/project-memory-sync.js.map +1 -0
  438. package/dist/management/shared-manager/shared-dir-linker.d.ts +41 -0
  439. package/dist/management/shared-manager/shared-dir-linker.d.ts.map +1 -0
  440. package/dist/management/shared-manager/shared-dir-linker.js +227 -0
  441. package/dist/management/shared-manager/shared-dir-linker.js.map +1 -0
  442. package/dist/management/shared-manager/symlink-helpers.d.ts +61 -0
  443. package/dist/management/shared-manager/symlink-helpers.d.ts.map +1 -0
  444. package/dist/management/shared-manager/symlink-helpers.js +243 -0
  445. package/dist/management/shared-manager/symlink-helpers.js.map +1 -0
  446. package/dist/management/shared-manager/types.d.ts +45 -0
  447. package/dist/management/shared-manager/types.d.ts.map +1 -0
  448. package/dist/management/shared-manager/types.js +57 -0
  449. package/dist/management/shared-manager/types.js.map +1 -0
  450. package/dist/management/shared-manager.d.ts +13 -160
  451. package/dist/management/shared-manager.d.ts.map +1 -1
  452. package/dist/management/shared-manager.js +18 -1294
  453. package/dist/management/shared-manager.js.map +1 -1
  454. package/dist/proxy/proxy-daemon-entry.js +1 -1
  455. package/dist/proxy/proxy-daemon-entry.js.map +1 -1
  456. package/dist/proxy/server/messages-route.d.ts +10 -0
  457. package/dist/proxy/server/messages-route.d.ts.map +1 -1
  458. package/dist/proxy/server/messages-route.js +34 -7
  459. package/dist/proxy/server/messages-route.js.map +1 -1
  460. package/dist/proxy/server/proxy-server.d.ts.map +1 -1
  461. package/dist/proxy/server/proxy-server.js +1 -1
  462. package/dist/proxy/server/proxy-server.js.map +1 -1
  463. package/dist/proxy/transformers/sse-stream-transformer.d.ts.map +1 -1
  464. package/dist/proxy/transformers/sse-stream-transformer.js +12 -17
  465. package/dist/proxy/transformers/sse-stream-transformer.js.map +1 -1
  466. package/dist/services/logging/index.d.ts +1 -1
  467. package/dist/services/logging/index.d.ts.map +1 -1
  468. package/dist/services/logging/index.js +6 -1
  469. package/dist/services/logging/index.js.map +1 -1
  470. package/dist/services/logging/log-context.d.ts +27 -2
  471. package/dist/services/logging/log-context.d.ts.map +1 -1
  472. package/dist/services/logging/log-context.js +43 -4
  473. package/dist/services/logging/log-context.js.map +1 -1
  474. package/dist/services/logging/log-redaction.d.ts +9 -0
  475. package/dist/services/logging/log-redaction.d.ts.map +1 -1
  476. package/dist/services/logging/log-redaction.js +31 -3
  477. package/dist/services/logging/log-redaction.js.map +1 -1
  478. package/dist/services/logging/logger.js +2 -2
  479. package/dist/services/logging/logger.js.map +1 -1
  480. package/dist/shared/provider-preset-catalog.d.ts +1 -1
  481. package/dist/shared/provider-preset-catalog.d.ts.map +1 -1
  482. package/dist/shared/provider-preset-catalog.js +21 -7
  483. package/dist/shared/provider-preset-catalog.js.map +1 -1
  484. package/dist/targets/claude-adapter.d.ts.map +1 -1
  485. package/dist/targets/claude-adapter.js +5 -0
  486. package/dist/targets/claude-adapter.js.map +1 -1
  487. package/dist/targets/codex-adapter.d.ts.map +1 -1
  488. package/dist/targets/codex-adapter.js +11 -10
  489. package/dist/targets/codex-adapter.js.map +1 -1
  490. package/dist/targets/codex-detector.d.ts.map +1 -1
  491. package/dist/targets/codex-detector.js +14 -0
  492. package/dist/targets/codex-detector.js.map +1 -1
  493. package/dist/targets/droid-adapter.d.ts.map +1 -1
  494. package/dist/targets/droid-adapter.js +12 -12
  495. package/dist/targets/droid-adapter.js.map +1 -1
  496. package/dist/ui/assets/{Trans-RG_sMDEu.js → Trans-GYzYLs2D.js} +1 -1
  497. package/dist/ui/assets/{accounts-yTXURc-q.js → accounts-DC1QuyI9.js} +1 -1
  498. package/dist/ui/assets/{alert-dialog-DjvPgzFs.js → alert-dialog-6SiedqmE.js} +1 -1
  499. package/dist/ui/assets/{api-Ck1dtNEM.js → api-3s21dbNJ.js} +1 -1
  500. package/dist/ui/assets/{auth-section-DBnY_LPz.js → auth-section-XBfNgVN4.js} +1 -1
  501. package/dist/ui/assets/{backups-section-Ci-uL4Of.js → backups-section-BidiiVlq.js} +1 -1
  502. package/dist/ui/assets/{channels-BeS9O5q0.js → channels-pfgPUDGt.js} +1 -1
  503. package/dist/ui/assets/{checkbox-DFeFDZBp.js → checkbox-CJw_-nvC.js} +1 -1
  504. package/dist/ui/assets/{claude-extension-DS5qN19Z.js → claude-extension-BIIUOvTJ.js} +1 -1
  505. package/dist/ui/assets/{cliproxy-D7HJH4mZ.js → cliproxy-Cq8OX0Pu.js} +1 -1
  506. package/dist/ui/assets/{cliproxy-ai-providers-oJQZXrtc.js → cliproxy-ai-providers-DI760ZF0.js} +1 -1
  507. package/dist/ui/assets/{cliproxy-control-panel-2mRPEcRj.js → cliproxy-control-panel-CBqvpOqj.js} +1 -1
  508. package/dist/ui/assets/{codex-D0AUQ6jA.js → codex-DL4OLBUu.js} +1 -1
  509. package/dist/ui/assets/{confirm-dialog-B37-CVuq.js → confirm-dialog-CC_Cc3EO.js} +1 -1
  510. package/dist/ui/assets/{copilot-KaaW-mko.js → copilot-D2kEhTXR.js} +1 -1
  511. package/dist/ui/assets/{cursor-BKiTgYi5.js → cursor-BashLrYk.js} +1 -1
  512. package/dist/ui/assets/{droid-DHdqGnFw.js → droid-DaKTINFL.js} +1 -1
  513. package/dist/ui/assets/{globalenv-section-SfZO97nU.js → globalenv-section-BQicL8L0.js} +1 -1
  514. package/dist/ui/assets/{health-CSRS9O0D.js → health-bRbE_ADg.js} +1 -1
  515. package/dist/ui/assets/{index-CGgavq2X.js → index-B2JEyN3d.js} +36 -36
  516. package/dist/ui/assets/{index-Cu_F55_O.js → index-BwZdl1HU.js} +1 -1
  517. package/dist/ui/assets/{index-DWUuSBUe.js → index-CgeAb1-K.js} +1 -1
  518. package/dist/ui/assets/{index-iQuEEGbH.js → index-DAQ0qIQ_.js} +1 -1
  519. package/dist/ui/assets/{index-ChTYEBCZ.js → index-O2x1grGh.js} +1 -1
  520. package/dist/ui/assets/{index-DycwEe96.js → index-WA7tK6np.js} +1 -1
  521. package/dist/ui/assets/{index-DJ66NrBH.js → index-mf2X1GwS.js} +1 -1
  522. package/dist/ui/assets/{logs-tiZ_51mo.js → logs-qrBHUJ0H.js} +1 -1
  523. package/dist/ui/assets/{masked-input-D9FVoeMA.js → masked-input-CXwQ4E-g.js} +1 -1
  524. package/dist/ui/assets/{proxy-status-widget-2k26d8pS.js → proxy-status-widget-DPz4nCzR.js} +1 -1
  525. package/dist/ui/assets/{raw-json-settings-editor-panel-CguBh93H.js → raw-json-settings-editor-panel-CcvsWVh1.js} +1 -1
  526. package/dist/ui/assets/{searchable-select-C4wShshD.js → searchable-select-EXSjNCRu.js} +1 -1
  527. package/dist/ui/assets/{separator-mvGlDdEW.js → separator-D2CTfWBQ.js} +1 -1
  528. package/dist/ui/assets/{shared-Ck0yAwbs.js → shared-DpgzhFqe.js} +1 -1
  529. package/dist/ui/assets/{table-DrUJOxKL.js → table-DwbiGRYk.js} +1 -1
  530. package/dist/ui/assets/{updates-BVHBFcq8.js → updates-D8jfIb2y.js} +1 -1
  531. package/dist/ui/assets/{use-accounts-DLtuaniS.js → use-accounts-Bwtpnx-x.js} +1 -1
  532. package/dist/ui/index.html +1 -1
  533. package/dist/utils/bar-auth-token.d.ts +4 -0
  534. package/dist/utils/bar-auth-token.d.ts.map +1 -0
  535. package/dist/utils/bar-auth-token.js +60 -0
  536. package/dist/utils/bar-auth-token.js.map +1 -0
  537. package/dist/utils/browser/browser-settings.d.ts +3 -1
  538. package/dist/utils/browser/browser-settings.d.ts.map +1 -1
  539. package/dist/utils/browser/browser-settings.js +2 -2
  540. package/dist/utils/browser/browser-settings.js.map +1 -1
  541. package/dist/utils/browser/browser-setup.d.ts.map +1 -1
  542. package/dist/utils/browser/browser-setup.js +3 -1
  543. package/dist/utils/browser/browser-setup.js.map +1 -1
  544. package/dist/utils/browser/browser-status.d.ts.map +1 -1
  545. package/dist/utils/browser/browser-status.js +4 -2
  546. package/dist/utils/browser/browser-status.js.map +1 -1
  547. package/dist/utils/fetch-proxy-setup.d.ts +3 -2
  548. package/dist/utils/fetch-proxy-setup.d.ts.map +1 -1
  549. package/dist/utils/fetch-proxy-setup.js +10 -6
  550. package/dist/utils/fetch-proxy-setup.js.map +1 -1
  551. package/dist/utils/image-analysis/mcp-installer.d.ts.map +1 -1
  552. package/dist/utils/image-analysis/mcp-installer.js +16 -13
  553. package/dist/utils/image-analysis/mcp-installer.js.map +1 -1
  554. package/dist/utils/websearch/index.d.ts +1 -1
  555. package/dist/utils/websearch/index.d.ts.map +1 -1
  556. package/dist/utils/websearch/index.js +2 -1
  557. package/dist/utils/websearch/index.js.map +1 -1
  558. package/dist/utils/websearch/mcp-installer.d.ts +8 -0
  559. package/dist/utils/websearch/mcp-installer.d.ts.map +1 -1
  560. package/dist/utils/websearch/mcp-installer.js +34 -13
  561. package/dist/utils/websearch/mcp-installer.js.map +1 -1
  562. package/dist/utils/websearch-manager.d.ts +1 -1
  563. package/dist/utils/websearch-manager.d.ts.map +1 -1
  564. package/dist/utils/websearch-manager.js +2 -1
  565. package/dist/utils/websearch-manager.js.map +1 -1
  566. package/dist/web-server/middleware/request-logging-middleware.d.ts.map +1 -1
  567. package/dist/web-server/middleware/request-logging-middleware.js +14 -9
  568. package/dist/web-server/middleware/request-logging-middleware.js.map +1 -1
  569. package/dist/web-server/model-pricing.d.ts.map +1 -1
  570. package/dist/web-server/model-pricing.js +22 -2
  571. package/dist/web-server/model-pricing.js.map +1 -1
  572. package/dist/web-server/routes/bar-routes.d.ts +12 -1
  573. package/dist/web-server/routes/bar-routes.d.ts.map +1 -1
  574. package/dist/web-server/routes/bar-routes.js +22 -6
  575. package/dist/web-server/routes/bar-routes.js.map +1 -1
  576. package/dist/web-server/routes/claude-extension-routes.d.ts.map +1 -1
  577. package/dist/web-server/routes/claude-extension-routes.js +3 -2
  578. package/dist/web-server/routes/claude-extension-routes.js.map +1 -1
  579. package/dist/web-server/routes/cliproxy-auth-routes.d.ts +1 -0
  580. package/dist/web-server/routes/cliproxy-auth-routes.d.ts.map +1 -1
  581. package/dist/web-server/routes/cliproxy-auth-routes.js +20 -5
  582. package/dist/web-server/routes/cliproxy-auth-routes.js.map +1 -1
  583. package/dist/web-server/routes/cliproxy-stats-routes/config-routes.d.ts +16 -0
  584. package/dist/web-server/routes/cliproxy-stats-routes/config-routes.d.ts.map +1 -0
  585. package/dist/web-server/routes/cliproxy-stats-routes/config-routes.js +219 -0
  586. package/dist/web-server/routes/cliproxy-stats-routes/config-routes.js.map +1 -0
  587. package/dist/web-server/routes/cliproxy-stats-routes/error-log-routes.d.ts +12 -0
  588. package/dist/web-server/routes/cliproxy-stats-routes/error-log-routes.d.ts.map +1 -0
  589. package/dist/web-server/routes/cliproxy-stats-routes/error-log-routes.js +153 -0
  590. package/dist/web-server/routes/cliproxy-stats-routes/error-log-routes.js.map +1 -0
  591. package/dist/web-server/routes/cliproxy-stats-routes/quota-helpers.d.ts +19 -0
  592. package/dist/web-server/routes/cliproxy-stats-routes/quota-helpers.d.ts.map +1 -0
  593. package/dist/web-server/routes/cliproxy-stats-routes/quota-helpers.js +38 -0
  594. package/dist/web-server/routes/cliproxy-stats-routes/quota-helpers.js.map +1 -0
  595. package/dist/web-server/routes/cliproxy-stats-routes/quota-routes.d.ts +13 -0
  596. package/dist/web-server/routes/cliproxy-stats-routes/quota-routes.d.ts.map +1 -0
  597. package/dist/web-server/routes/cliproxy-stats-routes/quota-routes.js +195 -0
  598. package/dist/web-server/routes/cliproxy-stats-routes/quota-routes.js.map +1 -0
  599. package/dist/web-server/routes/cliproxy-stats-routes/restart-route.d.ts +17 -0
  600. package/dist/web-server/routes/cliproxy-stats-routes/restart-route.d.ts.map +1 -0
  601. package/dist/web-server/routes/cliproxy-stats-routes/restart-route.js +34 -0
  602. package/dist/web-server/routes/cliproxy-stats-routes/restart-route.js.map +1 -0
  603. package/dist/web-server/routes/cliproxy-stats-routes/router.d.ts +10 -0
  604. package/dist/web-server/routes/cliproxy-stats-routes/router.d.ts.map +1 -0
  605. package/dist/web-server/routes/cliproxy-stats-routes/router.js +245 -0
  606. package/dist/web-server/routes/cliproxy-stats-routes/router.js.map +1 -0
  607. package/dist/web-server/routes/cliproxy-stats-routes/shared.d.ts +35 -0
  608. package/dist/web-server/routes/cliproxy-stats-routes/shared.d.ts.map +1 -0
  609. package/dist/web-server/routes/cliproxy-stats-routes/shared.js +59 -0
  610. package/dist/web-server/routes/cliproxy-stats-routes/shared.js.map +1 -0
  611. package/dist/web-server/routes/cliproxy-stats-routes/version-helpers.d.ts +44 -0
  612. package/dist/web-server/routes/cliproxy-stats-routes/version-helpers.d.ts.map +1 -0
  613. package/dist/web-server/routes/cliproxy-stats-routes/version-helpers.js +66 -0
  614. package/dist/web-server/routes/cliproxy-stats-routes/version-helpers.js.map +1 -0
  615. package/dist/web-server/routes/cliproxy-stats-routes.d.ts +16 -57
  616. package/dist/web-server/routes/cliproxy-stats-routes.d.ts.map +1 -1
  617. package/dist/web-server/routes/cliproxy-stats-routes.js +25 -926
  618. package/dist/web-server/routes/cliproxy-stats-routes.js.map +1 -1
  619. package/dist/web-server/routes/cliproxy-sync-routes.d.ts.map +1 -1
  620. package/dist/web-server/routes/cliproxy-sync-routes.js +9 -2
  621. package/dist/web-server/routes/cliproxy-sync-routes.js.map +1 -1
  622. package/dist/web-server/routes/copilot-settings-routes.d.ts.map +1 -1
  623. package/dist/web-server/routes/copilot-settings-routes.js +2 -1
  624. package/dist/web-server/routes/copilot-settings-routes.js.map +1 -1
  625. package/dist/web-server/routes/cursor-routes.d.ts.map +1 -1
  626. package/dist/web-server/routes/cursor-routes.js +3 -1
  627. package/dist/web-server/routes/cursor-routes.js.map +1 -1
  628. package/dist/web-server/routes/image-analysis-routes.d.ts.map +1 -1
  629. package/dist/web-server/routes/image-analysis-routes.js +2 -1
  630. package/dist/web-server/routes/image-analysis-routes.js.map +1 -1
  631. package/dist/web-server/routes/index.d.ts.map +1 -1
  632. package/dist/web-server/routes/index.js +6 -0
  633. package/dist/web-server/routes/index.js.map +1 -1
  634. package/dist/web-server/routes/persist-routes.d.ts.map +1 -1
  635. package/dist/web-server/routes/persist-routes.js +8 -1
  636. package/dist/web-server/routes/persist-routes.js.map +1 -1
  637. package/dist/web-server/routes/proxy-routes.d.ts.map +1 -1
  638. package/dist/web-server/routes/proxy-routes.js +33 -5
  639. package/dist/web-server/routes/proxy-routes.js.map +1 -1
  640. package/dist/web-server/routes/route-helpers.d.ts.map +1 -1
  641. package/dist/web-server/routes/route-helpers.js +18 -6
  642. package/dist/web-server/routes/route-helpers.js.map +1 -1
  643. package/dist/web-server/routes/settings-routes.d.ts.map +1 -1
  644. package/dist/web-server/routes/settings-routes.js +7 -6
  645. package/dist/web-server/routes/settings-routes.js.map +1 -1
  646. package/dist/web-server/usage/aggregator.d.ts.map +1 -1
  647. package/dist/web-server/usage/aggregator.js +8 -8
  648. package/dist/web-server/usage/aggregator.js.map +1 -1
  649. package/dist/web-server/usage/bar-analytics.d.ts +21 -0
  650. package/dist/web-server/usage/bar-analytics.d.ts.map +1 -1
  651. package/dist/web-server/usage/bar-analytics.js +78 -9
  652. package/dist/web-server/usage/bar-analytics.js.map +1 -1
  653. package/dist/web-server/usage/cliproxy-usage-transformer.d.ts.map +1 -1
  654. package/dist/web-server/usage/cliproxy-usage-transformer.js +9 -4
  655. package/dist/web-server/usage/cliproxy-usage-transformer.js.map +1 -1
  656. package/dist/web-server/usage/codex-local-quota-collector.d.ts +2 -2
  657. package/dist/web-server/usage/codex-local-quota-collector.d.ts.map +1 -1
  658. package/dist/web-server/usage/codex-local-quota-collector.js +39 -11
  659. package/dist/web-server/usage/codex-local-quota-collector.js.map +1 -1
  660. package/dist/web-server/usage/handlers.d.ts.map +1 -1
  661. package/dist/web-server/usage/handlers.js +1 -1
  662. package/dist/web-server/usage/handlers.js.map +1 -1
  663. package/dist/web-server/usage/native-quota-collector.d.ts +37 -9
  664. package/dist/web-server/usage/native-quota-collector.d.ts.map +1 -1
  665. package/dist/web-server/usage/native-quota-collector.js +226 -23
  666. package/dist/web-server/usage/native-quota-collector.js.map +1 -1
  667. package/package.json +1 -1
  668. package/scripts/ci-parity-gate.sh +31 -0
  669. package/scripts/generate-throw-error-baseline.js +103 -0
  670. package/scripts/github/stable-release-issue-cleanup-lib.mjs +51 -11
  671. package/scripts/hardening-inventory.js +62 -4
  672. package/scripts/maintainability-metrics.js +356 -0
@@ -1 +1 @@
1
- import{j as e}from"./radix-ui-nu4wz29m.js";import{r as o}from"./react-vendor-Bjx91N7w.js";import{by as ie,bz as ne,_ as E,a as X,bA as oe,bi as O,bk as R,e as h,x as le,c as w,L as f,I as T,j as $,k as H,l as F,m as U,n as V,aJ as G,O as ce,Q as ue,R as xe}from"./index-CGgavq2X.js";import{m as g,A as me}from"./proxy-C4-M_9kB.js";import{R as N,J as B,y as k,ac as ge,$ as be,bd as pe,x as Y,a0 as he,a7 as fe,e as we,t as je}from"./icons-DSLG1YsC.js";import"./tanstack-bhJxV1h8.js";import"./notifications-B4_o8bcr.js";import"./utils-CzKF5WmX.js";import"./form-utils-CuHzLhJZ.js";import"./charts-eIPy2oG6.js";function ve(r,s){return{claude:{...r.claude,...s.claude},codex:{...r.codex,...s.codex}}}function Ne(){const{state:r}=ie(),s=ne(),i=o.useCallback(async()=>{try{s.setBrowserLoading(!0),s.setBrowserError(null);const d=await E.browser.get();s.setBrowserConfig(d.config),s.setBrowserStatus(d.status)}catch(d){s.setBrowserError(d.message)}finally{s.setBrowserLoading(!1),s.setBrowserStatusLoading(!1)}},[s]),a=o.useCallback(async()=>{try{s.setBrowserStatusLoading(!0),s.setBrowserError(null);const d=await E.browser.getStatus();return s.setBrowserStatus(d),d}catch(d){return s.setBrowserError(d.message),null}finally{s.setBrowserStatusLoading(!1)}},[s]),c=o.useCallback(async d=>{const l=r.browserConfig;if(!l)return!1;const b=ve(l,d);s.setBrowserConfig(b);try{s.setBrowserSaving(!0),s.setBrowserError(null);const x=await E.browser.update(d);return s.setBrowserConfig(x.browser.config),s.setBrowserStatus(x.browser.status),s.setBrowserSuccess(!0),window.setTimeout(()=>s.setBrowserSuccess(!1),1500),!0}catch(x){return s.setBrowserConfig(l),s.setBrowserError(x.message),!1}finally{s.setBrowserSaving(!1)}},[s,r.browserConfig]);return{config:r.browserConfig,status:r.browserStatus,loading:r.browserLoading,statusLoading:r.browserStatusLoading,saving:r.browserSaving,error:r.browserError,success:r.browserSuccess,fetchConfig:i,fetchStatus:a,saveConfig:c}}function ke(r){const s=r.toLowerCase();return s.includes("mac")?"darwin":s.includes("win")?"win32":"linux"}function ye(r=navigator){const s=typeof r.userAgentData?.platform=="string"?r.userAgentData.platform:"",i=typeof r.platform=="string"&&r.platform.trim()?r.platform:r.userAgent;return ke(s||i||"")}function Se(r){if(!/^\d+$/.test(r.trim()))return null;const s=Number.parseInt(r.trim(),10);return s<1||s>65535?null:s}const J=["disabled","readonly","readwrite"];function D(r,s){return r(`settingsPage.browserSection.evalMode.options.${s}`)}function Ce(r,s,i){const a=JSON.stringify(r);return i==="darwin"?`open -na "Google Chrome" --args --remote-debugging-port=${s} --user-data-dir=${a}`:i==="win32"?`chrome.exe --remote-debugging-port=${s} --user-data-dir=${a}`:`google-chrome --remote-debugging-port=${s} --user-data-dir=${a}`}function q({children:r,className:s,title:i,description:a,badge:c,action:d}){return e.jsx("div",{className:w("group relative overflow-hidden rounded-[2.5rem] border border-border/60 bg-muted/20 p-1.5 transition-all duration-700 ease-[cubic-bezier(0.32,0.72,0,1)] dark:border-white/[0.08] dark:bg-zinc-900/35",s),children:e.jsxs("div",{className:"relative overflow-hidden rounded-[calc(2.5rem-0.375rem)] border border-border/70 bg-card/90 shadow-[0_12px_36px_-18px_rgba(15,23,42,0.18)] dark:border-white/[0.08] dark:bg-zinc-900/70 dark:shadow-[0_18px_44px_-24px_rgba(0,0,0,0.55)]",children:[e.jsx("div",{className:"pointer-events-none absolute inset-0 shadow-[inset_0_1px_0_rgba(255,255,255,0.28)] dark:shadow-[inset_0_1px_0_rgba(255,255,255,0.04)]"}),(i||d)&&e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-4 border-b border-border/60 px-8 py-6 dark:border-white/[0.06]",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("h3",{className:"text-xl font-semibold tracking-tight",children:i}),c]}),a&&e.jsx("p",{className:"text-sm text-muted-foreground",children:a})]}),d&&e.jsx("div",{className:"flex items-center gap-2",children:d})]}),e.jsx("div",{className:"px-8 py-8",children:r})]})})}function K({state:r,title:s,detail:i,nextStep:a}){const{t:c}=X(),d=r==="ready"||r==="enabled",l=!d&&r!=="disabled";return e.jsx("div",{className:w("relative overflow-hidden rounded-2xl border p-4 transition-all duration-500",d?"border-emerald-500/20 bg-emerald-500/[0.03] dark:bg-emerald-500/[0.02]":l?"border-amber-500/20 bg-amber-500/[0.03] dark:bg-amber-500/[0.02]":"border-border/60 bg-muted/30 dark:border-white/[0.06] dark:bg-zinc-900/45"),children:e.jsxs("div",{className:"flex items-start gap-4",children:[e.jsx("div",{className:w("flex h-10 w-10 shrink-0 items-center justify-center rounded-xl transition-transform duration-500 group-hover:scale-110",d?"bg-emerald-500/10 text-emerald-600":l?"bg-amber-500/10 text-amber-600":"bg-slate-500/10 text-slate-500"),children:d?e.jsx(k,{size:24}):l?e.jsx(Y,{size:24}):e.jsx(B,{size:24})}),e.jsxs("div",{className:"min-w-0 flex-1 space-y-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-sm font-semibold uppercase tracking-wider text-muted-foreground/60",children:c("settingsPage.browserSection.readiness")}),d&&e.jsx(g.span,{animate:{opacity:[.4,1,.4]},transition:{duration:2,repeat:1/0},className:"h-1.5 w-1.5 rounded-full bg-emerald-500"})]}),e.jsx("h4",{className:"font-medium text-foreground",children:s}),e.jsx("p",{className:"text-sm leading-relaxed text-muted-foreground",children:i}),a&&e.jsxs("div",{className:"mt-3 flex items-start gap-2 rounded-lg border border-border/50 bg-muted/35 p-3 dark:border-white/[0.05] dark:bg-zinc-900/45",children:[e.jsx(fe,{size:14,className:"mt-0.5 shrink-0 text-primary"}),e.jsxs("p",{className:"text-xs leading-normal",children:[e.jsxs("span",{className:"font-semibold text-primary",children:[c("settingsPage.browserSection.nextStep"),":"]})," ",a]})]})]})]})})}function Q({title:r,children:s,defaultOpen:i=!1}){const[a,c]=o.useState(i);return e.jsxs(ce,{open:a,onOpenChange:c,className:"overflow-hidden rounded-2xl border border-border/60 bg-muted/20 dark:border-white/[0.06] dark:bg-zinc-900/30",children:[e.jsx(ue,{asChild:!0,children:e.jsxs("button",{className:"flex w-full items-center justify-between px-6 py-4 text-sm font-medium transition-colors hover:bg-muted/40 dark:hover:bg-zinc-900/50",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(we,{size:16,className:"text-muted-foreground"}),r]}),e.jsx(je,{size:16,className:w("transition-transform duration-300",a&&"rotate-180")})]})}),e.jsx(xe,{children:e.jsx("div",{className:"border-t border-border/60 px-6 py-6 dark:border-white/[0.06]",children:s})})]})}function Oe(){const{t:r}=X(),{fetchRawConfig:s}=oe(),{config:i,status:a,loading:c,statusLoading:d,saving:l,error:b,success:x,fetchConfig:y,fetchStatus:L,saveConfig:S}=Ne(),[Z,m]=o.useState(null),[ee,C]=o.useState(null),[P,p]=o.useState(null);o.useEffect(()=>{y()},[y]),o.useEffect(()=>{if(!P&&!x)return;const n=window.setTimeout(()=>p(null),2500);return()=>window.clearTimeout(n)},[P,x]);const t=Z??i,j=o.useMemo(()=>t?Ce(t.claude.userDataDir,t.claude.devtoolsPort,ye()):"",[t]),M=ee??String(t?.claude.devtoolsPort??9222),v=Se(M),z=M.trim().length>0&&v===null,_=i!==null&&t!==null&&(i.claude.enabled!==t.claude.enabled||i.claude.userDataDir!==t.claude.userDataDir||i.claude.devtoolsPort!==v||i.claude.evalMode!==t.claude.evalMode),re=i!==null&&t!==null&&(i.codex.enabled!==t.codex.enabled||i.codex.evalMode!==t.codex.evalMode),I=o.useCallback(async()=>{p(null),m(null),C(null),await Promise.all([y(),s()])},[y,s]),se=o.useCallback(async()=>{await L()&&p(r("settingsPage.browserSection.messages.statusRefreshed"))},[L,r]),ae=o.useCallback(async()=>{if(!t||v===null)return;await S({claude:{enabled:t.claude.enabled,userDataDir:t.claude.userDataDir.trim(),devtoolsPort:v,evalMode:t.claude.evalMode}})&&(await s(),p(null),m(null),C(null))},[v,t,s,S]),te=o.useCallback(async()=>{if(!t)return;await S({codex:{enabled:t.codex.enabled,evalMode:t.codex.evalMode}})&&(await s(),p(null),m(null),C(null))},[t,s,S]),de=o.useCallback(async()=>{j&&(await navigator.clipboard.writeText(j),p(r("settingsPage.browserSection.messages.launchCommandCopied")))},[j,r]);return c?e.jsx("div",{className:"flex flex-1 items-center justify-center",children:e.jsxs("div",{className:"flex flex-col items-center gap-4 text-muted-foreground",children:[e.jsx(g.div,{animate:{rotate:360},transition:{duration:1.5,repeat:1/0,ease:"linear"},children:e.jsx(N,{size:32})}),e.jsx("span",{className:"text-sm font-medium uppercase tracking-widest opacity-60",children:r("settings.loading")})]})}):!i||!a||!t?e.jsx("div",{className:"p-8",children:e.jsxs(O,{variant:"destructive",className:"rounded-[2rem] p-8 shadow-xl",children:[e.jsx(B,{size:24}),e.jsx(R,{className:"mt-2 text-md leading-relaxed",children:b??r("settingsPage.browserSection.description")}),e.jsx("div",{className:"mt-6",children:e.jsxs(h,{variant:"outline",className:"rounded-full px-6 transition-transform active:scale-95",onClick:I,children:[e.jsx(N,{className:"mr-2 h-4 w-4"}),r("sharedPage.retry")]})})]})}):e.jsxs("div",{className:"relative flex min-h-0 flex-1 flex-col overflow-hidden bg-background",children:[e.jsx(me,{children:(b||x||P)&&e.jsx(g.div,{initial:{opacity:0,y:-20,scale:.95},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:-20,scale:.95},className:"absolute left-1/2 top-6 z-50 -translate-x-1/2",children:b?e.jsxs("div",{className:"flex items-center gap-3 rounded-full border border-rose-500/20 bg-card/95 px-6 py-2.5 text-sm font-medium text-rose-600 shadow-2xl dark:bg-zinc-900/85",children:[e.jsx(B,{size:18}),b]}):e.jsxs("div",{className:"flex items-center gap-3 rounded-full border border-emerald-500/20 bg-card/95 px-6 py-2.5 text-sm font-medium text-emerald-600 shadow-2xl dark:bg-zinc-900/85",children:[e.jsx(k,{size:18}),P??r("commonToast.settingsSaved")]})})}),e.jsx(le,{className:"flex-1",children:e.jsxs("div",{className:"mx-auto max-w-[1240px] space-y-12 p-8 py-16",children:[e.jsxs(g.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},className:"flex flex-wrap items-end justify-between gap-6",children:[e.jsx("div",{className:"space-y-4",children:e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:"flex h-12 w-12 items-center justify-center rounded-2xl bg-primary/10 text-primary",children:e.jsx(ge,{size:28})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-3xl font-bold tracking-tight",children:r("settingsPage.browserSection.title")}),e.jsx("p",{className:"mt-1 text-muted-foreground",children:r("settingsPage.browserSection.description")})]})]})}),e.jsxs(h,{variant:"outline",className:"rounded-full border-border/70 bg-background/85 shadow-sm transition-all hover:bg-muted/50 active:scale-95 dark:border-white/[0.08] dark:bg-zinc-900/70 dark:hover:bg-zinc-900",onClick:I,disabled:l||c,children:[e.jsx(N,{className:w("mr-2 h-4 w-4",d&&"animate-spin")}),r("settings.refresh")]})]}),e.jsx(g.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{delay:.1},children:e.jsxs(O,{className:"items-center rounded-3xl border-primary/10 bg-primary/[0.04] p-6 py-4 dark:border-primary/15 dark:bg-primary/[0.05]",children:[e.jsx(be,{className:"h-5 w-5 text-primary"}),e.jsxs(R,{className:"ml-2 text-sm",children:[e.jsx("span",{className:"font-semibold text-primary/80",children:r("settingsPage.browserSection.primaryTitle")})," ",r("settingsPage.browserSection.primaryDescription")]})]})}),e.jsx(g.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{delay:.2},children:e.jsx(q,{title:r("settingsPage.browserSection.claude.title"),description:r("settingsPage.browserSection.claude.description"),action:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("div",{className:"flex items-center gap-2 rounded-full border border-border/60 bg-muted/30 px-4 py-2 dark:border-white/[0.06] dark:bg-zinc-900/45",children:[e.jsx(f,{htmlFor:"browser-claude-enabled",className:"cursor-pointer text-xs font-semibold leading-none",children:t.claude.enabled?"ENABLED":"DISABLED"}),e.jsx(G,{id:"browser-claude-enabled",checked:t.claude.enabled,onCheckedChange:n=>m(u=>A(u??t,{enabled:n}))})]}),e.jsxs(h,{onClick:ae,disabled:l||z||!_,className:"rounded-full px-6 shadow-md transition-transform active:scale-95",children:[l?e.jsx(N,{className:"mr-2 h-4 w-4 animate-spin"}):e.jsx(k,{size:16,className:"mr-2"}),r("settingsPage.browserSection.actions.saveClaude")]}),e.jsxs(h,{variant:"outline",className:"rounded-full border-border/70 bg-background/85 shadow-sm transition-all hover:bg-muted/50 active:scale-95 dark:border-white/[0.08] dark:bg-zinc-900/70 dark:hover:bg-zinc-900",onClick:se,disabled:l||d||_||z,children:[e.jsx(he,{size:16,className:"mr-2"}),r("settingsPage.browserSection.actions.testConnection")]})]}),children:e.jsxs("div",{className:"grid gap-12",children:[e.jsx(K,{state:a.claude.state,title:a.claude.title,detail:a.claude.detail,nextStep:a.claude.nextStep}),e.jsxs("div",{className:"grid gap-8 lg:grid-cols-2",children:[e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsx(f,{htmlFor:"browser-claude-user-data-dir",className:"text-sm font-semibold tracking-wide text-muted-foreground/80",children:r("settingsPage.browserSection.claude.userDataDir")}),e.jsx(T,{id:"browser-claude-user-data-dir",value:t.claude.userDataDir,onChange:n=>m(u=>A(u??t,{userDataDir:n.target.value})),className:"rounded-xl border-border/70 bg-background/85 dark:border-white/[0.08] dark:bg-zinc-900/70",placeholder:a.claude.recommendedUserDataDir}),e.jsx("p",{className:"text-[11px] leading-relaxed text-muted-foreground/70",children:r("settingsPage.browserSection.claude.userDataDirHint")})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx(f,{htmlFor:"browser-claude-devtools-port",className:"text-sm font-semibold tracking-wide text-muted-foreground/80",children:r("settingsPage.browserSection.claude.devtoolsPort")}),e.jsx(T,{id:"browser-claude-devtools-port",value:M,onChange:n=>C(n.target.value),inputMode:"numeric",className:"max-w-[120px] rounded-xl border-border/70 bg-background/85 dark:border-white/[0.08] dark:bg-zinc-900/70"}),e.jsx("p",{className:w("text-[11px] leading-relaxed text-muted-foreground/70",z&&"text-rose-500"),children:r(z?"settingsPage.browserSection.claude.devtoolsPortInvalid":"settingsPage.browserSection.claude.devtoolsPortHint")})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx(f,{className:"text-sm font-semibold tracking-wide text-muted-foreground/80",children:r("settingsPage.browserSection.evalMode.label")}),e.jsxs($,{value:t.claude.evalMode,onValueChange:n=>m(u=>A(u??t,{evalMode:n})),children:[e.jsx(H,{className:"rounded-xl border-border/70 bg-background/85 dark:border-white/[0.08] dark:bg-zinc-900/70",children:e.jsx(F,{})}),e.jsx(U,{children:J.map(n=>e.jsx(V,{value:n,children:D(r,n)},n))})]}),e.jsx("p",{className:"text-[11px] leading-relaxed text-muted-foreground/70",children:r("settingsPage.browserSection.claude.evalModeHint")})]})]}),e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"group/launch relative overflow-hidden rounded-2xl border border-border/60 bg-muted/20 p-5 transition-all hover:bg-muted/35 dark:border-white/[0.06] dark:bg-zinc-900/35 dark:hover:bg-zinc-900/50",children:[e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-[11px] font-bold uppercase tracking-[0.15em] text-primary/70",children:r("settingsPage.browserSection.claude.launchGuidance")}),e.jsx("p",{className:"text-xs text-muted-foreground",children:r("settingsPage.browserSection.claude.launchGuidanceHint")})]}),e.jsx(h,{variant:"ghost",size:"sm",className:"h-8 w-8 rounded-full p-0 transition-transform active:scale-90",onClick:de,disabled:!j,children:e.jsx(pe,{size:18})})]}),e.jsx("code",{className:"mt-4 block break-all rounded-lg border border-border/50 bg-background/80 p-3 font-mono text-[10px] leading-relaxed dark:border-white/[0.05] dark:bg-zinc-900/60",children:j})]}),a.claude.overrideActive&&e.jsxs("div",{className:"flex items-center gap-3 rounded-2xl border border-amber-500/10 bg-amber-500/[0.05] p-4 text-xs font-medium text-amber-700 dark:text-amber-300",children:[e.jsx(Y,{size:18}),r("settingsPage.browserSection.claude.overrideMessage",{source:a.claude.source})]})]})]}),e.jsx(Q,{title:r("settingsPage.browserSection.technicalDetails"),defaultOpen:a.claude.state!=="ready",children:e.jsxs("div",{className:"grid gap-6 sm:grid-cols-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-[10px] font-bold uppercase tracking-widest text-muted-foreground/50",children:r("settingsPage.browserSection.claude.effectivePath")}),e.jsx("div",{className:"rounded-lg border border-border/50 bg-muted/25 p-3 dark:border-white/[0.05] dark:bg-zinc-900/45",children:e.jsx("p",{className:"break-all font-mono text-[11px] leading-relaxed",children:a.claude.effectiveUserDataDir})}),e.jsxs("p",{className:"text-[10px] font-medium text-muted-foreground/60",children:[e.jsxs("span",{className:"font-bold",children:[r("settingsPage.browserSection.claude.recommendedPath"),":"]})," ",a.claude.recommendedUserDataDir]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-[10px] font-bold uppercase tracking-widest text-muted-foreground/50",children:r("settingsPage.browserSection.claude.managedRuntime")}),e.jsxs("div",{className:"rounded-lg border border-border/50 bg-muted/25 p-3 dark:border-white/[0.05] dark:bg-zinc-900/45",children:[e.jsx("p",{className:"font-semibold text-primary/80",children:a.claude.managedMcpServerName}),e.jsx("p",{className:"mt-1 break-all font-mono text-[11px] leading-relaxed text-muted-foreground/80",children:a.claude.managedMcpServerPath})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-[10px] font-bold uppercase tracking-widest text-muted-foreground/50",children:r("settingsPage.browserSection.evalMode.label")}),e.jsx("div",{className:"rounded-lg border border-border/50 bg-muted/25 p-3 dark:border-white/[0.05] dark:bg-zinc-900/45",children:e.jsx("p",{className:"font-mono text-[11px] font-semibold",children:D(r,a.claude.evalMode)})})]})]})})]})})}),e.jsx(g.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{delay:.3},children:e.jsx(q,{title:r("settingsPage.browserSection.codex.title"),description:r("settingsPage.browserSection.codex.description"),action:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("div",{className:"flex items-center gap-2 rounded-full border border-border/60 bg-muted/30 px-4 py-2 dark:border-white/[0.06] dark:bg-zinc-900/45",children:[e.jsx(f,{htmlFor:"browser-codex-enabled",className:"cursor-pointer text-xs font-semibold leading-none",children:t.codex.enabled?"ENABLED":"DISABLED"}),e.jsx(G,{id:"browser-codex-enabled",checked:t.codex.enabled,onCheckedChange:n=>m(u=>W(u??t,{enabled:n}))})]}),e.jsxs(h,{onClick:te,disabled:l||!re,className:"rounded-full px-6 shadow-md transition-transform active:scale-95",children:[l?e.jsx(N,{className:"mr-2 h-4 w-4 animate-spin"}):e.jsx(k,{size:16,className:"mr-2"}),r("settingsPage.browserSection.actions.saveCodex")]})]}),children:e.jsxs("div",{className:"grid gap-12",children:[e.jsx(K,{state:a.codex.state,title:a.codex.title,detail:a.codex.detail,nextStep:a.codex.nextStep}),e.jsxs("div",{className:"max-w-md space-y-3",children:[e.jsx(f,{className:"text-sm font-semibold tracking-wide text-muted-foreground/80",children:r("settingsPage.browserSection.evalMode.label")}),e.jsxs($,{value:t.codex.evalMode,onValueChange:n=>m(u=>W(u??t,{evalMode:n})),children:[e.jsx(H,{className:"rounded-xl border-border/70 bg-background/85 dark:border-white/[0.08] dark:bg-zinc-900/70",children:e.jsx(F,{})}),e.jsx(U,{children:J.map(n=>e.jsx(V,{value:n,children:D(r,n)},n))})]}),e.jsx("p",{className:"text-[11px] leading-relaxed text-muted-foreground/70",children:r("settingsPage.browserSection.codex.evalModeHint")})]}),e.jsx(Q,{title:r("settingsPage.browserSection.technicalDetails"),defaultOpen:a.codex.state==="unsupported_build",children:e.jsxs("div",{className:"grid gap-6 sm:grid-cols-3",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-[10px] font-bold uppercase tracking-widest text-muted-foreground/50",children:r("settingsPage.browserSection.codex.serverName")}),e.jsx("div",{className:"rounded-lg border border-border/50 bg-muted/25 p-3 dark:border-white/[0.05] dark:bg-zinc-900/45",children:e.jsx("p",{className:"font-mono text-[11px] font-semibold",children:a.codex.serverName})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-[10px] font-bold uppercase tracking-widest text-muted-foreground/50",children:r("settingsPage.browserSection.codex.overrideSupport")}),e.jsxs("div",{className:"flex items-center gap-2 rounded-lg border border-border/50 bg-muted/25 p-3 font-medium text-xs dark:border-white/[0.05] dark:bg-zinc-900/45",children:[a.codex.supportsConfigOverrides?e.jsx(k,{className:"text-emerald-500",size:16}):e.jsx(B,{className:"text-rose-500",size:16}),a.codex.supportsConfigOverrides?r("settingsPage.browserSection.codex.overrideSupported"):r("settingsPage.browserSection.codex.overrideUnsupported")]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-[10px] font-bold uppercase tracking-widest text-muted-foreground/50",children:r("settingsPage.browserSection.codex.binary")}),e.jsxs("div",{className:"rounded-lg border border-border/50 bg-muted/25 p-3 dark:border-white/[0.05] dark:bg-zinc-900/45",children:[e.jsx("p",{className:"break-all font-mono text-[11px] leading-relaxed",children:a.codex.binaryPath??r("settingsPage.browserSection.codex.notDetected")}),a.codex.version&&e.jsx("div",{className:"mt-2 inline-flex rounded-full bg-primary/10 px-2 py-0.5 text-[10px] font-bold text-primary",children:a.codex.version})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-[10px] font-bold uppercase tracking-widest text-muted-foreground/50",children:r("settingsPage.browserSection.evalMode.label")}),e.jsx("div",{className:"rounded-lg border border-border/50 bg-muted/25 p-3 dark:border-white/[0.05] dark:bg-zinc-900/45",children:e.jsx("p",{className:"font-mono text-[11px] font-semibold",children:D(r,a.codex.evalMode)})})]})]})})]})})})]})})]})}function A(r,s){return{...r,claude:{...r.claude,...s}}}function W(r,s){return{...r,codex:{...r.codex,...s}}}export{Oe as default};
1
+ import{j as e}from"./radix-ui-nu4wz29m.js";import{r as o}from"./react-vendor-Bjx91N7w.js";import{by as ie,bz as ne,_ as E,a as X,bA as oe,bi as O,bk as R,e as h,x as le,c as w,L as f,I as T,j as $,k as H,l as F,m as U,n as V,aJ as G,O as ce,Q as ue,R as xe}from"./index-B2JEyN3d.js";import{m as g,A as me}from"./proxy-C4-M_9kB.js";import{R as N,J as B,y as k,ac as ge,$ as be,bd as pe,x as Y,a0 as he,a7 as fe,e as we,t as je}from"./icons-DSLG1YsC.js";import"./tanstack-bhJxV1h8.js";import"./notifications-B4_o8bcr.js";import"./utils-CzKF5WmX.js";import"./form-utils-CuHzLhJZ.js";import"./charts-eIPy2oG6.js";function ve(r,s){return{claude:{...r.claude,...s.claude},codex:{...r.codex,...s.codex}}}function Ne(){const{state:r}=ie(),s=ne(),i=o.useCallback(async()=>{try{s.setBrowserLoading(!0),s.setBrowserError(null);const d=await E.browser.get();s.setBrowserConfig(d.config),s.setBrowserStatus(d.status)}catch(d){s.setBrowserError(d.message)}finally{s.setBrowserLoading(!1),s.setBrowserStatusLoading(!1)}},[s]),a=o.useCallback(async()=>{try{s.setBrowserStatusLoading(!0),s.setBrowserError(null);const d=await E.browser.getStatus();return s.setBrowserStatus(d),d}catch(d){return s.setBrowserError(d.message),null}finally{s.setBrowserStatusLoading(!1)}},[s]),c=o.useCallback(async d=>{const l=r.browserConfig;if(!l)return!1;const b=ve(l,d);s.setBrowserConfig(b);try{s.setBrowserSaving(!0),s.setBrowserError(null);const x=await E.browser.update(d);return s.setBrowserConfig(x.browser.config),s.setBrowserStatus(x.browser.status),s.setBrowserSuccess(!0),window.setTimeout(()=>s.setBrowserSuccess(!1),1500),!0}catch(x){return s.setBrowserConfig(l),s.setBrowserError(x.message),!1}finally{s.setBrowserSaving(!1)}},[s,r.browserConfig]);return{config:r.browserConfig,status:r.browserStatus,loading:r.browserLoading,statusLoading:r.browserStatusLoading,saving:r.browserSaving,error:r.browserError,success:r.browserSuccess,fetchConfig:i,fetchStatus:a,saveConfig:c}}function ke(r){const s=r.toLowerCase();return s.includes("mac")?"darwin":s.includes("win")?"win32":"linux"}function ye(r=navigator){const s=typeof r.userAgentData?.platform=="string"?r.userAgentData.platform:"",i=typeof r.platform=="string"&&r.platform.trim()?r.platform:r.userAgent;return ke(s||i||"")}function Se(r){if(!/^\d+$/.test(r.trim()))return null;const s=Number.parseInt(r.trim(),10);return s<1||s>65535?null:s}const J=["disabled","readonly","readwrite"];function D(r,s){return r(`settingsPage.browserSection.evalMode.options.${s}`)}function Ce(r,s,i){const a=JSON.stringify(r);return i==="darwin"?`open -na "Google Chrome" --args --remote-debugging-port=${s} --user-data-dir=${a}`:i==="win32"?`chrome.exe --remote-debugging-port=${s} --user-data-dir=${a}`:`google-chrome --remote-debugging-port=${s} --user-data-dir=${a}`}function q({children:r,className:s,title:i,description:a,badge:c,action:d}){return e.jsx("div",{className:w("group relative overflow-hidden rounded-[2.5rem] border border-border/60 bg-muted/20 p-1.5 transition-all duration-700 ease-[cubic-bezier(0.32,0.72,0,1)] dark:border-white/[0.08] dark:bg-zinc-900/35",s),children:e.jsxs("div",{className:"relative overflow-hidden rounded-[calc(2.5rem-0.375rem)] border border-border/70 bg-card/90 shadow-[0_12px_36px_-18px_rgba(15,23,42,0.18)] dark:border-white/[0.08] dark:bg-zinc-900/70 dark:shadow-[0_18px_44px_-24px_rgba(0,0,0,0.55)]",children:[e.jsx("div",{className:"pointer-events-none absolute inset-0 shadow-[inset_0_1px_0_rgba(255,255,255,0.28)] dark:shadow-[inset_0_1px_0_rgba(255,255,255,0.04)]"}),(i||d)&&e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-4 border-b border-border/60 px-8 py-6 dark:border-white/[0.06]",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("h3",{className:"text-xl font-semibold tracking-tight",children:i}),c]}),a&&e.jsx("p",{className:"text-sm text-muted-foreground",children:a})]}),d&&e.jsx("div",{className:"flex items-center gap-2",children:d})]}),e.jsx("div",{className:"px-8 py-8",children:r})]})})}function K({state:r,title:s,detail:i,nextStep:a}){const{t:c}=X(),d=r==="ready"||r==="enabled",l=!d&&r!=="disabled";return e.jsx("div",{className:w("relative overflow-hidden rounded-2xl border p-4 transition-all duration-500",d?"border-emerald-500/20 bg-emerald-500/[0.03] dark:bg-emerald-500/[0.02]":l?"border-amber-500/20 bg-amber-500/[0.03] dark:bg-amber-500/[0.02]":"border-border/60 bg-muted/30 dark:border-white/[0.06] dark:bg-zinc-900/45"),children:e.jsxs("div",{className:"flex items-start gap-4",children:[e.jsx("div",{className:w("flex h-10 w-10 shrink-0 items-center justify-center rounded-xl transition-transform duration-500 group-hover:scale-110",d?"bg-emerald-500/10 text-emerald-600":l?"bg-amber-500/10 text-amber-600":"bg-slate-500/10 text-slate-500"),children:d?e.jsx(k,{size:24}):l?e.jsx(Y,{size:24}):e.jsx(B,{size:24})}),e.jsxs("div",{className:"min-w-0 flex-1 space-y-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-sm font-semibold uppercase tracking-wider text-muted-foreground/60",children:c("settingsPage.browserSection.readiness")}),d&&e.jsx(g.span,{animate:{opacity:[.4,1,.4]},transition:{duration:2,repeat:1/0},className:"h-1.5 w-1.5 rounded-full bg-emerald-500"})]}),e.jsx("h4",{className:"font-medium text-foreground",children:s}),e.jsx("p",{className:"text-sm leading-relaxed text-muted-foreground",children:i}),a&&e.jsxs("div",{className:"mt-3 flex items-start gap-2 rounded-lg border border-border/50 bg-muted/35 p-3 dark:border-white/[0.05] dark:bg-zinc-900/45",children:[e.jsx(fe,{size:14,className:"mt-0.5 shrink-0 text-primary"}),e.jsxs("p",{className:"text-xs leading-normal",children:[e.jsxs("span",{className:"font-semibold text-primary",children:[c("settingsPage.browserSection.nextStep"),":"]})," ",a]})]})]})]})})}function Q({title:r,children:s,defaultOpen:i=!1}){const[a,c]=o.useState(i);return e.jsxs(ce,{open:a,onOpenChange:c,className:"overflow-hidden rounded-2xl border border-border/60 bg-muted/20 dark:border-white/[0.06] dark:bg-zinc-900/30",children:[e.jsx(ue,{asChild:!0,children:e.jsxs("button",{className:"flex w-full items-center justify-between px-6 py-4 text-sm font-medium transition-colors hover:bg-muted/40 dark:hover:bg-zinc-900/50",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(we,{size:16,className:"text-muted-foreground"}),r]}),e.jsx(je,{size:16,className:w("transition-transform duration-300",a&&"rotate-180")})]})}),e.jsx(xe,{children:e.jsx("div",{className:"border-t border-border/60 px-6 py-6 dark:border-white/[0.06]",children:s})})]})}function Oe(){const{t:r}=X(),{fetchRawConfig:s}=oe(),{config:i,status:a,loading:c,statusLoading:d,saving:l,error:b,success:x,fetchConfig:y,fetchStatus:L,saveConfig:S}=Ne(),[Z,m]=o.useState(null),[ee,C]=o.useState(null),[P,p]=o.useState(null);o.useEffect(()=>{y()},[y]),o.useEffect(()=>{if(!P&&!x)return;const n=window.setTimeout(()=>p(null),2500);return()=>window.clearTimeout(n)},[P,x]);const t=Z??i,j=o.useMemo(()=>t?Ce(t.claude.userDataDir,t.claude.devtoolsPort,ye()):"",[t]),M=ee??String(t?.claude.devtoolsPort??9222),v=Se(M),z=M.trim().length>0&&v===null,_=i!==null&&t!==null&&(i.claude.enabled!==t.claude.enabled||i.claude.userDataDir!==t.claude.userDataDir||i.claude.devtoolsPort!==v||i.claude.evalMode!==t.claude.evalMode),re=i!==null&&t!==null&&(i.codex.enabled!==t.codex.enabled||i.codex.evalMode!==t.codex.evalMode),I=o.useCallback(async()=>{p(null),m(null),C(null),await Promise.all([y(),s()])},[y,s]),se=o.useCallback(async()=>{await L()&&p(r("settingsPage.browserSection.messages.statusRefreshed"))},[L,r]),ae=o.useCallback(async()=>{if(!t||v===null)return;await S({claude:{enabled:t.claude.enabled,userDataDir:t.claude.userDataDir.trim(),devtoolsPort:v,evalMode:t.claude.evalMode}})&&(await s(),p(null),m(null),C(null))},[v,t,s,S]),te=o.useCallback(async()=>{if(!t)return;await S({codex:{enabled:t.codex.enabled,evalMode:t.codex.evalMode}})&&(await s(),p(null),m(null),C(null))},[t,s,S]),de=o.useCallback(async()=>{j&&(await navigator.clipboard.writeText(j),p(r("settingsPage.browserSection.messages.launchCommandCopied")))},[j,r]);return c?e.jsx("div",{className:"flex flex-1 items-center justify-center",children:e.jsxs("div",{className:"flex flex-col items-center gap-4 text-muted-foreground",children:[e.jsx(g.div,{animate:{rotate:360},transition:{duration:1.5,repeat:1/0,ease:"linear"},children:e.jsx(N,{size:32})}),e.jsx("span",{className:"text-sm font-medium uppercase tracking-widest opacity-60",children:r("settings.loading")})]})}):!i||!a||!t?e.jsx("div",{className:"p-8",children:e.jsxs(O,{variant:"destructive",className:"rounded-[2rem] p-8 shadow-xl",children:[e.jsx(B,{size:24}),e.jsx(R,{className:"mt-2 text-md leading-relaxed",children:b??r("settingsPage.browserSection.description")}),e.jsx("div",{className:"mt-6",children:e.jsxs(h,{variant:"outline",className:"rounded-full px-6 transition-transform active:scale-95",onClick:I,children:[e.jsx(N,{className:"mr-2 h-4 w-4"}),r("sharedPage.retry")]})})]})}):e.jsxs("div",{className:"relative flex min-h-0 flex-1 flex-col overflow-hidden bg-background",children:[e.jsx(me,{children:(b||x||P)&&e.jsx(g.div,{initial:{opacity:0,y:-20,scale:.95},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:-20,scale:.95},className:"absolute left-1/2 top-6 z-50 -translate-x-1/2",children:b?e.jsxs("div",{className:"flex items-center gap-3 rounded-full border border-rose-500/20 bg-card/95 px-6 py-2.5 text-sm font-medium text-rose-600 shadow-2xl dark:bg-zinc-900/85",children:[e.jsx(B,{size:18}),b]}):e.jsxs("div",{className:"flex items-center gap-3 rounded-full border border-emerald-500/20 bg-card/95 px-6 py-2.5 text-sm font-medium text-emerald-600 shadow-2xl dark:bg-zinc-900/85",children:[e.jsx(k,{size:18}),P??r("commonToast.settingsSaved")]})})}),e.jsx(le,{className:"flex-1",children:e.jsxs("div",{className:"mx-auto max-w-[1240px] space-y-12 p-8 py-16",children:[e.jsxs(g.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},className:"flex flex-wrap items-end justify-between gap-6",children:[e.jsx("div",{className:"space-y-4",children:e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:"flex h-12 w-12 items-center justify-center rounded-2xl bg-primary/10 text-primary",children:e.jsx(ge,{size:28})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-3xl font-bold tracking-tight",children:r("settingsPage.browserSection.title")}),e.jsx("p",{className:"mt-1 text-muted-foreground",children:r("settingsPage.browserSection.description")})]})]})}),e.jsxs(h,{variant:"outline",className:"rounded-full border-border/70 bg-background/85 shadow-sm transition-all hover:bg-muted/50 active:scale-95 dark:border-white/[0.08] dark:bg-zinc-900/70 dark:hover:bg-zinc-900",onClick:I,disabled:l||c,children:[e.jsx(N,{className:w("mr-2 h-4 w-4",d&&"animate-spin")}),r("settings.refresh")]})]}),e.jsx(g.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{delay:.1},children:e.jsxs(O,{className:"items-center rounded-3xl border-primary/10 bg-primary/[0.04] p-6 py-4 dark:border-primary/15 dark:bg-primary/[0.05]",children:[e.jsx(be,{className:"h-5 w-5 text-primary"}),e.jsxs(R,{className:"ml-2 text-sm",children:[e.jsx("span",{className:"font-semibold text-primary/80",children:r("settingsPage.browserSection.primaryTitle")})," ",r("settingsPage.browserSection.primaryDescription")]})]})}),e.jsx(g.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{delay:.2},children:e.jsx(q,{title:r("settingsPage.browserSection.claude.title"),description:r("settingsPage.browserSection.claude.description"),action:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("div",{className:"flex items-center gap-2 rounded-full border border-border/60 bg-muted/30 px-4 py-2 dark:border-white/[0.06] dark:bg-zinc-900/45",children:[e.jsx(f,{htmlFor:"browser-claude-enabled",className:"cursor-pointer text-xs font-semibold leading-none",children:t.claude.enabled?"ENABLED":"DISABLED"}),e.jsx(G,{id:"browser-claude-enabled",checked:t.claude.enabled,onCheckedChange:n=>m(u=>A(u??t,{enabled:n}))})]}),e.jsxs(h,{onClick:ae,disabled:l||z||!_,className:"rounded-full px-6 shadow-md transition-transform active:scale-95",children:[l?e.jsx(N,{className:"mr-2 h-4 w-4 animate-spin"}):e.jsx(k,{size:16,className:"mr-2"}),r("settingsPage.browserSection.actions.saveClaude")]}),e.jsxs(h,{variant:"outline",className:"rounded-full border-border/70 bg-background/85 shadow-sm transition-all hover:bg-muted/50 active:scale-95 dark:border-white/[0.08] dark:bg-zinc-900/70 dark:hover:bg-zinc-900",onClick:se,disabled:l||d||_||z,children:[e.jsx(he,{size:16,className:"mr-2"}),r("settingsPage.browserSection.actions.testConnection")]})]}),children:e.jsxs("div",{className:"grid gap-12",children:[e.jsx(K,{state:a.claude.state,title:a.claude.title,detail:a.claude.detail,nextStep:a.claude.nextStep}),e.jsxs("div",{className:"grid gap-8 lg:grid-cols-2",children:[e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsx(f,{htmlFor:"browser-claude-user-data-dir",className:"text-sm font-semibold tracking-wide text-muted-foreground/80",children:r("settingsPage.browserSection.claude.userDataDir")}),e.jsx(T,{id:"browser-claude-user-data-dir",value:t.claude.userDataDir,onChange:n=>m(u=>A(u??t,{userDataDir:n.target.value})),className:"rounded-xl border-border/70 bg-background/85 dark:border-white/[0.08] dark:bg-zinc-900/70",placeholder:a.claude.recommendedUserDataDir}),e.jsx("p",{className:"text-[11px] leading-relaxed text-muted-foreground/70",children:r("settingsPage.browserSection.claude.userDataDirHint")})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx(f,{htmlFor:"browser-claude-devtools-port",className:"text-sm font-semibold tracking-wide text-muted-foreground/80",children:r("settingsPage.browserSection.claude.devtoolsPort")}),e.jsx(T,{id:"browser-claude-devtools-port",value:M,onChange:n=>C(n.target.value),inputMode:"numeric",className:"max-w-[120px] rounded-xl border-border/70 bg-background/85 dark:border-white/[0.08] dark:bg-zinc-900/70"}),e.jsx("p",{className:w("text-[11px] leading-relaxed text-muted-foreground/70",z&&"text-rose-500"),children:r(z?"settingsPage.browserSection.claude.devtoolsPortInvalid":"settingsPage.browserSection.claude.devtoolsPortHint")})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx(f,{className:"text-sm font-semibold tracking-wide text-muted-foreground/80",children:r("settingsPage.browserSection.evalMode.label")}),e.jsxs($,{value:t.claude.evalMode,onValueChange:n=>m(u=>A(u??t,{evalMode:n})),children:[e.jsx(H,{className:"rounded-xl border-border/70 bg-background/85 dark:border-white/[0.08] dark:bg-zinc-900/70",children:e.jsx(F,{})}),e.jsx(U,{children:J.map(n=>e.jsx(V,{value:n,children:D(r,n)},n))})]}),e.jsx("p",{className:"text-[11px] leading-relaxed text-muted-foreground/70",children:r("settingsPage.browserSection.claude.evalModeHint")})]})]}),e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"group/launch relative overflow-hidden rounded-2xl border border-border/60 bg-muted/20 p-5 transition-all hover:bg-muted/35 dark:border-white/[0.06] dark:bg-zinc-900/35 dark:hover:bg-zinc-900/50",children:[e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-[11px] font-bold uppercase tracking-[0.15em] text-primary/70",children:r("settingsPage.browserSection.claude.launchGuidance")}),e.jsx("p",{className:"text-xs text-muted-foreground",children:r("settingsPage.browserSection.claude.launchGuidanceHint")})]}),e.jsx(h,{variant:"ghost",size:"sm",className:"h-8 w-8 rounded-full p-0 transition-transform active:scale-90",onClick:de,disabled:!j,children:e.jsx(pe,{size:18})})]}),e.jsx("code",{className:"mt-4 block break-all rounded-lg border border-border/50 bg-background/80 p-3 font-mono text-[10px] leading-relaxed dark:border-white/[0.05] dark:bg-zinc-900/60",children:j})]}),a.claude.overrideActive&&e.jsxs("div",{className:"flex items-center gap-3 rounded-2xl border border-amber-500/10 bg-amber-500/[0.05] p-4 text-xs font-medium text-amber-700 dark:text-amber-300",children:[e.jsx(Y,{size:18}),r("settingsPage.browserSection.claude.overrideMessage",{source:a.claude.source})]})]})]}),e.jsx(Q,{title:r("settingsPage.browserSection.technicalDetails"),defaultOpen:a.claude.state!=="ready",children:e.jsxs("div",{className:"grid gap-6 sm:grid-cols-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-[10px] font-bold uppercase tracking-widest text-muted-foreground/50",children:r("settingsPage.browserSection.claude.effectivePath")}),e.jsx("div",{className:"rounded-lg border border-border/50 bg-muted/25 p-3 dark:border-white/[0.05] dark:bg-zinc-900/45",children:e.jsx("p",{className:"break-all font-mono text-[11px] leading-relaxed",children:a.claude.effectiveUserDataDir})}),e.jsxs("p",{className:"text-[10px] font-medium text-muted-foreground/60",children:[e.jsxs("span",{className:"font-bold",children:[r("settingsPage.browserSection.claude.recommendedPath"),":"]})," ",a.claude.recommendedUserDataDir]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-[10px] font-bold uppercase tracking-widest text-muted-foreground/50",children:r("settingsPage.browserSection.claude.managedRuntime")}),e.jsxs("div",{className:"rounded-lg border border-border/50 bg-muted/25 p-3 dark:border-white/[0.05] dark:bg-zinc-900/45",children:[e.jsx("p",{className:"font-semibold text-primary/80",children:a.claude.managedMcpServerName}),e.jsx("p",{className:"mt-1 break-all font-mono text-[11px] leading-relaxed text-muted-foreground/80",children:a.claude.managedMcpServerPath})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-[10px] font-bold uppercase tracking-widest text-muted-foreground/50",children:r("settingsPage.browserSection.evalMode.label")}),e.jsx("div",{className:"rounded-lg border border-border/50 bg-muted/25 p-3 dark:border-white/[0.05] dark:bg-zinc-900/45",children:e.jsx("p",{className:"font-mono text-[11px] font-semibold",children:D(r,a.claude.evalMode)})})]})]})})]})})}),e.jsx(g.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{delay:.3},children:e.jsx(q,{title:r("settingsPage.browserSection.codex.title"),description:r("settingsPage.browserSection.codex.description"),action:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("div",{className:"flex items-center gap-2 rounded-full border border-border/60 bg-muted/30 px-4 py-2 dark:border-white/[0.06] dark:bg-zinc-900/45",children:[e.jsx(f,{htmlFor:"browser-codex-enabled",className:"cursor-pointer text-xs font-semibold leading-none",children:t.codex.enabled?"ENABLED":"DISABLED"}),e.jsx(G,{id:"browser-codex-enabled",checked:t.codex.enabled,onCheckedChange:n=>m(u=>W(u??t,{enabled:n}))})]}),e.jsxs(h,{onClick:te,disabled:l||!re,className:"rounded-full px-6 shadow-md transition-transform active:scale-95",children:[l?e.jsx(N,{className:"mr-2 h-4 w-4 animate-spin"}):e.jsx(k,{size:16,className:"mr-2"}),r("settingsPage.browserSection.actions.saveCodex")]})]}),children:e.jsxs("div",{className:"grid gap-12",children:[e.jsx(K,{state:a.codex.state,title:a.codex.title,detail:a.codex.detail,nextStep:a.codex.nextStep}),e.jsxs("div",{className:"max-w-md space-y-3",children:[e.jsx(f,{className:"text-sm font-semibold tracking-wide text-muted-foreground/80",children:r("settingsPage.browserSection.evalMode.label")}),e.jsxs($,{value:t.codex.evalMode,onValueChange:n=>m(u=>W(u??t,{evalMode:n})),children:[e.jsx(H,{className:"rounded-xl border-border/70 bg-background/85 dark:border-white/[0.08] dark:bg-zinc-900/70",children:e.jsx(F,{})}),e.jsx(U,{children:J.map(n=>e.jsx(V,{value:n,children:D(r,n)},n))})]}),e.jsx("p",{className:"text-[11px] leading-relaxed text-muted-foreground/70",children:r("settingsPage.browserSection.codex.evalModeHint")})]}),e.jsx(Q,{title:r("settingsPage.browserSection.technicalDetails"),defaultOpen:a.codex.state==="unsupported_build",children:e.jsxs("div",{className:"grid gap-6 sm:grid-cols-3",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-[10px] font-bold uppercase tracking-widest text-muted-foreground/50",children:r("settingsPage.browserSection.codex.serverName")}),e.jsx("div",{className:"rounded-lg border border-border/50 bg-muted/25 p-3 dark:border-white/[0.05] dark:bg-zinc-900/45",children:e.jsx("p",{className:"font-mono text-[11px] font-semibold",children:a.codex.serverName})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-[10px] font-bold uppercase tracking-widest text-muted-foreground/50",children:r("settingsPage.browserSection.codex.overrideSupport")}),e.jsxs("div",{className:"flex items-center gap-2 rounded-lg border border-border/50 bg-muted/25 p-3 font-medium text-xs dark:border-white/[0.05] dark:bg-zinc-900/45",children:[a.codex.supportsConfigOverrides?e.jsx(k,{className:"text-emerald-500",size:16}):e.jsx(B,{className:"text-rose-500",size:16}),a.codex.supportsConfigOverrides?r("settingsPage.browserSection.codex.overrideSupported"):r("settingsPage.browserSection.codex.overrideUnsupported")]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-[10px] font-bold uppercase tracking-widest text-muted-foreground/50",children:r("settingsPage.browserSection.codex.binary")}),e.jsxs("div",{className:"rounded-lg border border-border/50 bg-muted/25 p-3 dark:border-white/[0.05] dark:bg-zinc-900/45",children:[e.jsx("p",{className:"break-all font-mono text-[11px] leading-relaxed",children:a.codex.binaryPath??r("settingsPage.browserSection.codex.notDetected")}),a.codex.version&&e.jsx("div",{className:"mt-2 inline-flex rounded-full bg-primary/10 px-2 py-0.5 text-[10px] font-bold text-primary",children:a.codex.version})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-[10px] font-bold uppercase tracking-widest text-muted-foreground/50",children:r("settingsPage.browserSection.evalMode.label")}),e.jsx("div",{className:"rounded-lg border border-border/50 bg-muted/25 p-3 dark:border-white/[0.05] dark:bg-zinc-900/45",children:e.jsx("p",{className:"font-mono text-[11px] font-semibold",children:D(r,a.codex.evalMode)})})]})]})})]})})})]})})]})}function A(r,s){return{...r,claude:{...r.claude,...s}}}function W(r,s){return{...r,codex:{...r.codex,...s}}}export{Oe as default};
@@ -1 +1 @@
1
- import{j as e}from"./radix-ui-nu4wz29m.js";import{r as f,E as Te}from"./react-vendor-Bjx91N7w.js";import{u as U,a as P,C as N,b,S as p,c as x,P as k,B as _,d as Le,e as X,f as de,g as $e,h as ue,i as Re,j as Pe,k as Fe,l as Me,m as De,n as Ae,T as Be,o as Ie,p as Oe,q as Ue,r as xe,s as v,t as R,v as qe,w as Ee,x as Ke,y as _e}from"./index-CGgavq2X.js";import{a4 as We,an as me,ao as se,ap as he,a2 as fe,ab as Ge,G as He,aq as ze,$ as Ve,R as Ye,a0 as ne,U as Qe,Z as pe,w as Ze,af as Q,ar as Xe,_ as Je,C as es,as as ss,at as ts}from"./icons-DSLG1YsC.js";import{a as as,u as q}from"./tanstack-bhJxV1h8.js";import{u as ns}from"./use-accounts-DLtuaniS.js";import{K as B,f as L,H as rs,L as ls}from"./utils-CzKF5WmX.js";import{R as ge,A as os,C as is,X as cs,Y as re,T as je,b as le,P as ds,c as us,d as xs}from"./charts-eIPy2oG6.js";import"./notifications-B4_o8bcr.js";import"./form-utils-CuHzLhJZ.js";function ms({data:s,isLoading:t}){const{privacyMode:a}=U(),{t:n}=P(),i=s?.totalTokens??0,r=s?.totalInputTokens??0,o=s?.totalOutputTokens??0,u=s?.totalCacheTokens??0,l=r+o;if(t)return e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-3 lg:grid-cols-5 gap-4",children:[1,2,3,4,5].map(h=>e.jsx(N,{children:e.jsx(b,{className:"p-6",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(p,{className:"h-4 w-[100px]"}),e.jsx(p,{className:"h-8 w-[80px]"})]}),e.jsx(p,{className:"h-8 w-8 rounded-lg"})]})})},h))});const c=(s?.tokenBreakdown?.cacheCreation?.cost??0)+(s?.tokenBreakdown?.cacheRead?.cost??0),m=s?.totalCost?Math.round(c/s.totalCost*100):0,d=u>0&&i>l,g=u>0&&!d?"Total Tokens (I/O)":n("analyticsSummary.totalTokens"),S=d?`${$(r)} in / ${$(o)} out / ${$(u)} cache`:n("analyticsSummary.totalTokensSubtitle",{input:$(r),output:$(o)}),C=[{title:g,value:i,icon:We,format:h=>$(h),color:"text-blue-600",bgColor:"bg-blue-100 dark:bg-blue-900/20",subtitle:S},{title:n("analyticsSummary.totalCost"),value:s?.totalCost??0,icon:me,format:h=>`$${h.toFixed(2)}`,color:"text-green-600",bgColor:"bg-green-100 dark:bg-green-900/20",subtitle:n("analyticsSummary.totalCostSubtitle",{value:s?.averageCostPerDay?.toFixed(2)??"0.00"})},{title:n("analyticsSummary.cacheTokens"),value:s?.totalCacheTokens??0,icon:se,format:h=>$(h),color:"text-cyan-600",bgColor:"bg-cyan-100 dark:bg-cyan-900/20",subtitle:n("analyticsSummary.cacheTokensSubtitle",{cost:c.toFixed(2),percent:m})},{title:n("analyticsSummary.inputCost"),value:s?.tokenBreakdown?.input?.cost??0,icon:he,format:h=>`$${h.toFixed(2)}`,color:"text-purple-600",bgColor:"bg-purple-100 dark:bg-purple-900/20",subtitle:n("analyticsSummary.tokensSubtitle",{value:$(s?.tokenBreakdown?.input?.tokens??0)})},{title:n("analyticsSummary.outputCost"),value:s?.tokenBreakdown?.output?.cost??0,icon:fe,format:h=>`$${h.toFixed(2)}`,color:"text-orange-600",bgColor:"bg-orange-100 dark:bg-orange-900/20",subtitle:n("analyticsSummary.tokensSubtitle",{value:$(s?.tokenBreakdown?.output?.tokens??0)})}];return e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-3 lg:grid-cols-5 gap-4",children:C.map((h,y)=>{const T=h.icon;return e.jsx(N,{className:"hover:shadow-md transition-shadow",children:e.jsx(b,{className:"p-4",children:e.jsxs("div",{className:"flex items-center justify-between space-x-2",children:[e.jsxs("div",{className:"space-y-1 min-w-0",children:[e.jsx("p",{className:"text-xs font-medium text-muted-foreground truncate",children:h.title}),e.jsx("p",{className:x("text-xl font-bold truncate",a&&k),children:h.format(h.value)}),h.subtitle&&e.jsx("p",{className:x("text-[10px] text-muted-foreground truncate",a&&k),children:h.subtitle})]}),e.jsx("div",{className:x("p-2 rounded-lg shrink-0",h.bgColor),children:e.jsx(T,{className:x("h-4 w-4",h.color)})})]})})},y)})})}function $(s){return s>=1e6?`${(s/1e6).toFixed(1)}M`:s>=1e3?`${(s/1e3).toFixed(1)}K`:s.toLocaleString()}function hs({model:s}){const{privacyMode:t}=U(),{t:a}=P(),n=fs(s.ioRatio),r=s.cacheCreationTokens+s.cacheReadTokens>0?"All Tokens":a("analyticsCards.totalTokens");return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ge,{className:"h-4 w-4 text-primary shrink-0"}),e.jsx("h4",{className:"font-semibold leading-none truncate",title:s.model,children:s.model})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsxs(_,{variant:"secondary",className:"text-[10px] h-5 px-1.5",children:[s.percentage.toFixed(1),"% usage"]}),e.jsxs(_,{variant:n.variant,className:"text-[10px] h-5 px-1.5",children:[s.ioRatio.toFixed(0),":1 I/O"]})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{className:"p-2 rounded-md bg-muted/50 border text-center",children:[e.jsxs("p",{className:x("text-lg font-bold",t&&k),children:["$",s.cost.toFixed(2)]}),e.jsx("p",{className:"text-[10px] text-muted-foreground uppercase tracking-wider",children:a("analyticsCards.totalCost")})]}),e.jsxs("div",{className:"p-2 rounded-md bg-muted/50 border text-center",children:[e.jsx("p",{className:x("text-lg font-bold",t&&k),children:gs(s.tokens)}),e.jsx("p",{className:"text-[10px] text-muted-foreground uppercase tracking-wider",children:r})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("h5",{className:"text-[11px] font-medium text-muted-foreground uppercase tracking-wider",children:"Token Breakdown"}),e.jsxs("div",{className:x("space-y-1",t&&k),children:[e.jsx(Z,{label:"Input",tokens:s.inputTokens,cost:s.costBreakdown.input.cost,color:"#335c67",icon:he}),e.jsx(Z,{label:"Output",tokens:s.outputTokens,cost:s.costBreakdown.output.cost,color:"#fff3b0",icon:fe}),e.jsx(Z,{label:"Cache Write",tokens:s.cacheCreationTokens,cost:s.costBreakdown.cacheCreation.cost,color:"#e09f3e",icon:se}),e.jsx(Z,{label:"Cache Read",tokens:s.cacheReadTokens,cost:s.costBreakdown.cacheRead.cost,color:"#9e2a2b",icon:se})]})]}),e.jsxs("div",{className:"p-2.5 rounded-md border bg-muted/20 space-y-1.5",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(He,{className:"h-3.5 w-3.5 text-muted-foreground"}),e.jsx("span",{className:"text-xs font-medium",children:a("analyticsCards.inputOutputRatio")})]}),e.jsx("p",{className:"text-[11px] text-muted-foreground leading-snug",children:n.description})]})]})}function Z({label:s,tokens:t,cost:a,color:n,icon:i}){return t===0?null:e.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[e.jsx("div",{className:"w-1 h-6 rounded-full shrink-0",style:{backgroundColor:n}}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"font-medium truncate",children:s}),e.jsxs("span",{className:"font-mono text-muted-foreground",children:["$",a.toFixed(3)]})]}),e.jsxs("div",{className:"flex items-center gap-1.5 text-muted-foreground",children:[e.jsx(i,{className:"h-3 w-3 shrink-0"}),e.jsx("span",{children:ps(t)})]})]})]})}function fs(s){return s>=200?{variant:"destructive",description:"Extended thinking or large context loading. Expected for reasoning models."}:s>=50?{variant:"secondary",description:"More input than output. Typical for analysis tasks."}:s>=5?{variant:"outline",description:"Balanced input/output ratio for typical coding tasks."}:{variant:"default",description:"More output than input. Generation-heavy workload."}}function ps(s){return s.toLocaleString()}function gs(s){return s>=1e9?`${(s/1e9).toFixed(1)}B`:s>=1e6?`${(s/1e6).toFixed(1)}M`:s>=1e3?`${(s/1e3).toFixed(1)}K`:s.toString()}const js="/api";function oe(s){const t=s.getFullYear(),a=String(s.getMonth()+1).padStart(2,"0"),n=String(s.getDate()).padStart(2,"0");return`${t}${a}${n}`}function M(s,t){const a=t.toString();return a?`${s}?${a}`:s}function D(s,t){t?.startDate&&s.append("since",oe(t.startDate)),t?.endDate&&s.append("until",oe(t.endDate))}function A(s,t){t?.profile&&s.append("profile",t.profile)}const I={summary:s=>{const t=new URLSearchParams;return D(t,s),A(t,s),F(M("/usage/summary",t))},trends:s=>{const t=new URLSearchParams;return D(t,s),A(t,s),F(M("/usage/daily",t))},hourly:s=>{const t=new URLSearchParams;return D(t,s),A(t,s),F(M("/usage/hourly",t))},models:s=>{const t=new URLSearchParams;return D(t,s),A(t,s),F(M("/usage/models",t))},sessions:s=>{const t=new URLSearchParams;return D(t,s),s?.limit&&t.append("limit",s.limit.toString()),s?.offset&&t.append("offset",s.offset.toString()),A(t,s),F(M("/usage/sessions",t))},monthly:s=>{const t=new URLSearchParams;return D(t,s),A(t,s),F(M("/usage/monthly",t))},refresh:async()=>{if(!(await fetch(`${js}/usage/refresh`,{method:"POST",headers:{"Content-Type":"application/json"}})).ok)throw new Error("Failed to refresh usage cache")},status:()=>F("/usage/status"),insights:s=>{const t=new URLSearchParams;return D(t,s),A(t,s),F(M("/usage/insights",t))}};async function F(s){const a=await fetch(`/api${s}`,{headers:{"Content-Type":"application/json"}});if(!a.ok){const i=await a.json().catch(()=>({error:"Unknown error"}));throw new Error(i.error||a.statusText)}const n=await a.json();return n.data||n}function ys(s){return q({queryKey:["usage","summary",s],queryFn:()=>I.summary(s),staleTime:60*1e3})}function Ns(s){return q({queryKey:["usage","trends",s],queryFn:()=>I.trends(s),staleTime:60*1e3})}function bs(s){return q({queryKey:["usage","hourly",s],queryFn:()=>I.hourly(s),staleTime:60*1e3})}function ws(s){return q({queryKey:["usage","models",s],queryFn:()=>I.models(s),staleTime:60*1e3})}function vs(){const s=as();return f.useCallback(async()=>{await I.refresh(),await s.invalidateQueries({queryKey:["usage"]})},[s])}function ks(){return q({queryKey:["usage","status"],queryFn:()=>I.status(),staleTime:10*1e3,refetchInterval:30*1e3})}function Cs(s){return q({queryKey:["usage","sessions",s],queryFn:()=>I.sessions(s),staleTime:60*1e3})}function Ss(s){const t=Math.max(1,Math.floor((Date.now()-s.getTime())/1e3));if(t<60)return`${t}s ago`;const a=Math.floor(t/60);if(a<60)return`${a}m ago`;const n=Math.floor(a/60);return n<24?`${n}h ago`:`${Math.floor(n/24)}d ago`}const Ts=50,te="ccs.analytics.selectedProfile",W="all";function Ls(){if(typeof globalThis.localStorage>"u")return W;const s=globalThis.localStorage.getItem(te);return!s||s.startsWith("unsupported:")?W:s}function $s(s){if(!(typeof globalThis.localStorage>"u")){if(s===W){globalThis.localStorage.removeItem(te);return}globalThis.localStorage.setItem(te,s)}}function Rs(){const[s,t]=f.useState({from:B(new Date,30),to:new Date}),[a,n]=f.useState(!1),[i,r]=f.useState(null),[o,u]=f.useState(Ls),[l,c]=f.useState(null),[m,d]=f.useState("daily"),{data:g}=ns(),{data:S}=Le(),C=vs(),h=f.useCallback(async()=>{n(!0);try{await C()}finally{n(!1)}},[C]),y=f.useMemo(()=>({startDate:s?.from,endDate:s?.to,profile:o===W?void 0:o}),[s?.from,s?.to,o]),T=f.useMemo(()=>{const w=new Set(g?.accounts.map(j=>j.name)??[]),Y=[{value:W,label:"All profiles",description:"Includes all analytics sources.",supported:!0},{value:"default",label:"Default Claude",description:"Profile-scoped Claude JSONL data.",supported:!0},...Array.from(w).sort((j,Se)=>j.localeCompare(Se)).map(j=>({value:j,label:j,description:"Profile-scoped account data.",supported:!0}))];for(const j of S?.profiles??[])w.has(j.name)||j.name==="default"||Y.push({value:`unsupported:${j.name}`,label:j.name,description:"API profile usage is not yet attributed by stable profile.",supported:!1});return Y},[g?.accounts,S?.profiles]),{data:E,isLoading:O}=ys(y),{data:J,isLoading:G}=Ns(y),{data:K,isLoading:H}=bs(y),{data:ee,isLoading:z}=ws(y),{data:ye,isLoading:ae}=Cs({...y,limit:Ts}),{data:V}=ks(),Ne=f.useCallback(()=>{const w=new Date;t({from:B(w,1),to:w}),d("hourly")},[]),be=f.useCallback(w=>{t(w),d("daily")},[]),we=f.useCallback(w=>{w.startsWith("unsupported:")||(u(w),$s(w))},[]),ve=f.useMemo(()=>V?.lastFetch?Ss(new Date(V.lastFetch)):null,[V?.lastFetch]),ke=f.useCallback((w,Y)=>{const j=Y.currentTarget.getBoundingClientRect();c({x:j.left+j.width/2,y:j.top+j.height/2}),r(w)},[]),Ce=f.useCallback(()=>{r(null),c(null)},[]);return{dateRange:s,isRefreshing:a,viewMode:m,selectedProfile:o,profileOptions:T,selectedModel:i,popoverPosition:l,summary:E,trends:J,hourlyData:K,models:ee,sessions:ye,status:V,isSummaryLoading:O,isTrendsLoading:G,isHourlyLoading:H,isModelsLoading:z,isSessionsLoading:ae,isLoading:O||G||z||ae,handleRefresh:h,handleTodayClick:Ne,handleDateRangeChange:be,handleProfileChange:we,handleModelClick:ke,handlePopoverClose:Ce,lastUpdatedText:ve}}function Ps({value:s,onChange:t,presets:a=[{label:"Last 7 days",range:{from:B(new Date,7),to:new Date}},{label:"Last 30 days",range:{from:B(new Date,30),to:new Date}},{label:"Last 90 days",range:{from:B(new Date,90),to:new Date}}],className:n}){const[i,r]=Te.useState(!1),{t:o}=P(),u=l=>!s||!s.from||!s.to||!l.from||!l.to?!1:L(s.from,"yyyy-MM-dd")===L(l.from,"yyyy-MM-dd")&&L(s.to,"yyyy-MM-dd")===L(l.to,"yyyy-MM-dd");return e.jsxs("div",{className:x("flex flex-wrap items-center gap-2",n),children:[a.map(l=>e.jsx(X,{variant:u(l.range)?"default":"outline",size:"sm",onClick:()=>t(l.range),children:l.label},l.label)),e.jsxs(de,{open:i,onOpenChange:r,children:[e.jsx($e,{asChild:!0,children:e.jsxs(X,{id:"date",variant:"outline",className:x("w-auto min-w-[200px] sm:min-w-[240px] justify-start text-left font-normal",!s&&"text-muted-foreground"),children:[e.jsx(ze,{className:"mr-2 h-4 w-4"}),s?.from?s.to?e.jsxs(e.Fragment,{children:[L(s.from,"LLL dd, y")," - ",L(s.to,"LLL dd, y")]}):L(s.from,"LLL dd, y"):e.jsx("span",{children:o("dateRangeFilter.pickADate")})]})}),e.jsx(ue,{className:"w-auto p-0",align:"end",children:e.jsx(Re,{initialFocus:!0,mode:"range",defaultMonth:s?.from,selected:s,onSelect:t,numberOfMonths:2})})]})]})}function Fs({dateRange:s,onDateRangeChange:t,onTodayClick:a,onRefresh:n,isRefreshing:i,lastUpdatedText:r,viewMode:o,selectedProfile:u,profileOptions:l,onProfileChange:c}){const{t:m}=P();return e.jsxs("div",{className:"flex flex-col gap-3 shrink-0 xl:flex-row xl:items-center xl:justify-between",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-xl font-semibold",children:m("analytics.title")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:m("analytics.subtitle")})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2 xl:justify-end",children:[e.jsxs("div",{className:"inline-flex items-center gap-1 shrink-0",children:[e.jsxs(Pe,{value:u,onValueChange:c,children:[e.jsx(Fe,{className:"h-8 w-[170px]","aria-label":"Analytics profile",children:e.jsx(Me,{placeholder:"All profiles",children:l.find(d=>d.value===u)?.label??"All profiles"})}),e.jsx(De,{children:l.map(d=>e.jsx(Ae,{value:d.value,disabled:!d.supported,children:e.jsxs("span",{className:"flex flex-col",children:[e.jsx("span",{children:d.label}),e.jsx("span",{className:"text-xs text-muted-foreground",children:d.description})]})},d.value))})]}),u!=="all"&&e.jsx(Be,{delayDuration:150,children:e.jsxs(Ie,{children:[e.jsx(Oe,{asChild:!0,children:e.jsx("button",{type:"button","aria-label":"Selected-profile analytics scope",className:"inline-flex size-7 items-center justify-center rounded-md text-muted-foreground hover:bg-accent hover:text-foreground",children:e.jsx(Ve,{className:"size-4","aria-hidden":"true"})})}),e.jsx(Ue,{side:"bottom",align:"start",className:"max-w-xs text-xs",children:"Selected-profile analytics include only default/account data with stable profile attribution. CLIProxy and native runtime snapshots remain in All profiles."})]})})]}),e.jsx(X,{variant:o==="hourly"?"default":"outline",size:"sm",className:"h-8",onClick:a,children:"24H"}),e.jsx(Ps,{className:"flex-wrap",value:s,onChange:t,presets:[{label:"7D",range:{from:B(new Date,7),to:new Date}},{label:"30D",range:{from:B(new Date,30),to:new Date}},{label:m("analytics.month"),range:{from:rs(new Date),to:new Date}},{label:m("analytics.allTime"),range:{from:void 0,to:new Date}}]}),r&&e.jsx("span",{className:"text-xs text-muted-foreground whitespace-nowrap font-mono",title:m("analytics.updated",{value:r}),children:r}),e.jsx(X,{variant:"outline",size:"sm",className:"gap-2 h-8",onClick:n,disabled:i,children:e.jsx(Ye,{className:`w-3.5 h-3.5 ${i?"animate-spin":""}`})})]})]})}function Ms({data:s,isLoading:t,granularity:a="daily",className:n}){const{privacyMode:i}=U(),{t:r}=P(),o=f.useMemo(()=>!s||s.length===0?[]:s.map(c=>{const m="hour"in c?c.hour:c.date;return{...c,dateFormatted:Ds(m,a),costRounded:Number(c.cost.toFixed(4))}}),[s,a]);if(t)return e.jsx(p,{className:x("h-full w-full",n)});if(!s||s.length===0)return e.jsx("div",{className:x("h-full flex items-center justify-center",n),children:e.jsx("p",{className:"text-muted-foreground",children:r(a==="hourly"?"analytics.noDailyUsage":"analytics.noUsageData")})});const u=({x:l,y:c,payload:m,isRight:d})=>{const g=d?`$${m.value}`:ie(Number(m.value));return e.jsx("text",{x:l,y:c,dy:4,textAnchor:d?"start":"end",fontSize:12,fill:"currentColor",className:x("fill-muted-foreground",i&&"blur-[4px]"),children:g})};return e.jsx("div",{className:x("w-full h-full",n),children:e.jsx(ge,{width:"100%",height:"100%",children:e.jsxs(os,{data:o,margin:{top:5,right:30,left:20,bottom:5},children:[e.jsxs("defs",{children:[e.jsxs("linearGradient",{id:"tokenGradient",x1:"0",y1:"0",x2:"0",y2:"1",children:[e.jsx("stop",{offset:"5%",stopColor:"#0080FF",stopOpacity:.8}),e.jsx("stop",{offset:"95%",stopColor:"#0080FF",stopOpacity:.1})]}),e.jsxs("linearGradient",{id:"costGradient",x1:"0",y1:"0",x2:"0",y2:"1",children:[e.jsx("stop",{offset:"5%",stopColor:"#00C49F",stopOpacity:.8}),e.jsx("stop",{offset:"95%",stopColor:"#00C49F",stopOpacity:.1})]})]}),e.jsx(is,{strokeDasharray:"3 3",className:"stroke-muted"}),e.jsx(cs,{dataKey:"dateFormatted",tick:{fontSize:12},tickLine:!1,axisLine:{className:"stroke-muted"}}),e.jsx(re,{yAxisId:"left",orientation:"left",tick:l=>e.jsx(u,{...l,isRight:!1}),tickLine:!1,axisLine:{className:"stroke-muted"}}),e.jsx(re,{yAxisId:"right",orientation:"right",tick:l=>e.jsx(u,{...l,isRight:!0}),tickLine:!1,axisLine:{className:"stroke-muted"}}),e.jsx(je,{content:({active:l,payload:c,label:m})=>!l||!c||!c.length?null:e.jsxs("div",{className:"rounded-lg border bg-background p-3 shadow-lg",children:[e.jsx("p",{className:"font-medium mb-2",children:m}),c.map((d,g)=>e.jsxs("p",{className:x("text-sm",i&&k),style:{color:d.color},children:[d.name,":"," ",d.name==="Tokens"?ie(Number(d.value)||0):`$${d.value}`]},g))]})}),e.jsx(le,{yAxisId:"left",type:"monotone",dataKey:"tokens",stroke:"#0080FF",strokeWidth:2,fillOpacity:1,fill:"url(#tokenGradient)",name:"Tokens"}),e.jsx(le,{yAxisId:"right",type:"monotone",dataKey:"costRounded",stroke:"#00C49F",strokeWidth:2,fillOpacity:1,fill:"url(#costGradient)",name:"Cost"})]})})})}function Ds(s,t){if(t==="hourly"){const[n,i]=s.split(" ");if(n&&i){const r=new Date(`${n}T${i}:00Z`);return L(r,"HH:mm")}return s}const a=new Date(s);return t==="monthly"?L(a,"MMM yyyy"):L(a,"MMM dd")}function ie(s){return s>=1e6?`${(s/1e6).toFixed(1)}M`:s>=1e3?`${(s/1e3).toFixed(1)}K`:s.toLocaleString()}function As({data:s,isLoading:t,className:a}){const{privacyMode:n}=U(),{t:i}=P(),r=f.useMemo(()=>!s||s.length===0?[]:s.map(l=>({name:l.model,value:l.tokens,cost:l.cost,percentage:l.percentage,fill:xe(l.model)})),[s]);if(t)return e.jsx(p,{className:x("h-full min-h-[100px] w-full",a)});if(!s||s.length===0)return e.jsx("div",{className:x("h-full min-h-[100px] flex items-center justify-center",a),children:e.jsx("p",{className:"text-muted-foreground",children:i("analyticsCards.noModelData")})});const o=({active:l,payload:c})=>{if(!l||!c)return null;const m=c;if(!m.length)return null;const d=m[0].payload;return e.jsxs("div",{className:"rounded-lg border bg-background p-2 shadow-lg text-xs",children:[e.jsx("p",{className:"font-medium mb-1",children:d.name}),e.jsxs("p",{className:x("text-muted-foreground",n&&k),children:[Bs(d.value)," (",d.percentage.toFixed(1),"%)"]}),e.jsxs("p",{className:x("text-muted-foreground",n&&k),children:["$",d.cost.toFixed(4)]})]})},u=l=>l.percentage>5?`${l.percentage.toFixed(1)}%`:"";return e.jsx("div",{className:x("w-full h-full min-h-[100px]",a),children:e.jsx(ge,{width:"100%",height:"100%",children:e.jsxs(ds,{children:[e.jsx(us,{data:r,cx:"50%",cy:"50%",labelLine:!1,label:u,innerRadius:50,outerRadius:70,paddingAngle:2,dataKey:"value",children:r.map((l,c)=>e.jsx(xs,{fill:l.fill,strokeWidth:1},`cell-${c}`))}),e.jsx(je,{content:o})]})})})}function Bs(s){return s>=1e6?`${(s/1e6).toFixed(1)}M`:s>=1e3?`${(s/1e3).toFixed(1)}K`:s.toLocaleString()}function Is(s){if(!s)return"";const a=s.replace(/^\/|\/$/g,"").split("/").filter(n=>n.length>0);return a[a.length-1]||""}function Os({data:s,isLoading:t,className:a}){const{privacyMode:n}=U(),{t:i}=P(),r=f.useMemo(()=>{if(!s?.sessions||s.sessions.length===0)return null;const o=s.sessions,u=s.total,l=o.length,c=s.hasMore||s.offset>0,d=o.reduce((g,S)=>g+S.cost,0)/o.length;return{displayedSessions:c?l:u,totalSessions:u,avgCost:d,hasPartialSample:c,recentSessions:o.slice(0,3)}},[s]);return t?e.jsxs(N,{className:x("flex flex-col h-full min-h-0 overflow-hidden gap-0 py-0",a),children:[e.jsx(v,{className:"px-3 py-2",children:e.jsx(p,{className:"h-5 w-32"})}),e.jsx(b,{className:"px-3 pb-3 pt-0 flex-1",children:e.jsx(p,{className:"h-full w-full"})})]}):r?e.jsxs(N,{className:x("flex flex-col h-full min-h-0 overflow-hidden gap-0 py-0 shadow-sm",a),children:[e.jsx(v,{className:"px-3 py-2",children:e.jsxs(R,{className:"text-base font-semibold flex items-center gap-2",children:[e.jsx(ne,{className:"w-4 h-4"}),"Session Stats"]})}),e.jsxs(b,{className:"px-3 pb-3 pt-0 flex-1 min-h-0 flex flex-col gap-3",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{className:"p-2 rounded-md bg-muted/50 border text-center",children:[e.jsxs("div",{className:"flex items-center justify-center gap-1.5 text-blue-600 dark:text-blue-400",children:[e.jsx(Qe,{className:"w-4 h-4"}),e.jsx("span",{className:"text-xl font-bold",children:r.displayedSessions})]}),e.jsx("p",{className:"text-[10px] text-muted-foreground uppercase tracking-wider mt-0.5",children:r.hasPartialSample?"Sampled Sessions":"Total Sessions"}),r.hasPartialSample&&e.jsxs("p",{className:"text-[10px] text-muted-foreground mt-0.5",children:[r.totalSessions," total"]})]}),e.jsxs("div",{className:"p-2 rounded-md bg-muted/50 border text-center",children:[e.jsxs("div",{className:"flex items-center justify-center gap-1.5 text-green-600 dark:text-green-400",children:[e.jsx(pe,{className:"w-4 h-4"}),e.jsxs("span",{className:x("text-xl font-bold",n&&k),children:["$",r.avgCost.toFixed(2)]})]}),e.jsx("p",{className:"text-[10px] text-muted-foreground uppercase tracking-wider mt-0.5",children:r.hasPartialSample?"Recent Avg Cost":"Avg Cost/Session"})]})]}),e.jsxs("div",{className:"flex-1 min-h-0 space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-1 text-xs text-muted-foreground font-medium mb-1",children:[e.jsx(Ze,{className:"w-3 h-3"}),"Recent Activity"]}),e.jsx("div",{className:"space-y-1.5 max-h-full overflow-y-auto pr-1",children:r.recentSessions.map(o=>e.jsxs("div",{className:"flex items-center justify-between text-xs p-1.5 rounded bg-muted/30 hover:bg-muted/50 transition-colors",children:[e.jsxs("div",{className:"flex flex-col min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("span",{className:"font-medium truncate",title:o.projectPath,children:Is(o.projectPath)}),(o.target??"claude")!=="claude"&&e.jsx("span",{className:"shrink-0 px-1 py-0 text-[9px] font-medium rounded bg-purple-100 text-purple-700 dark:bg-purple-900/30 dark:text-purple-300 uppercase",children:o.target})]}),e.jsx("span",{className:"text-[10px] text-muted-foreground",children:ls(new Date(o.lastActivity),{addSuffix:!0})})]}),e.jsxs("div",{className:x("text-right shrink-0 ml-2",n&&k),children:[e.jsxs("div",{className:"font-mono",children:["$",o.cost.toFixed(2)]}),e.jsxs("div",{className:"text-[10px] text-muted-foreground",children:[Us(o.tokens??o.inputTokens+o.outputTokens)," ","toks"]})]})]},o.sessionId))})]})]})]}):e.jsxs(N,{className:x("flex flex-col h-full min-h-0 overflow-hidden gap-0 py-0",a),children:[e.jsx(v,{className:"px-3 py-2",children:e.jsxs(R,{className:"text-base font-semibold flex items-center gap-2",children:[e.jsx(ne,{className:"w-4 h-4"}),"Session Stats"]})}),e.jsx(b,{className:"px-3 pb-3 pt-0 flex-1 flex items-center justify-center",children:e.jsx("p",{className:"text-sm text-muted-foreground text-center",children:i("analyticsCards.noSessionData")})})]})}function Us(s){return s>=1e9?`${(s/1e9).toFixed(1)}B`:s>=1e6?`${(s/1e6).toFixed(1)}M`:s>=1e3?`${(s/1e3).toFixed(1)}K`:s.toString()}function qs({className:s,isLoading:t}){const{data:a,isLoading:n}=qe(),{data:i,isLoading:r,error:o}=Ee(a?.running),{t:u}=P();if(t||n||a?.running&&r)return e.jsxs(N,{className:x("flex flex-col h-full min-h-0 overflow-hidden gap-0 py-0",s),children:[e.jsx(v,{className:"px-3 py-2",children:e.jsxs(R,{className:"text-base font-semibold flex items-center gap-2",children:[e.jsx(Q,{className:"h-4 w-4"}),"CLIProxy Stats"]})}),e.jsx(b,{className:"px-3 pb-3 pt-0 flex-1",children:e.jsxs("div",{className:"space-y-3",children:[e.jsx(p,{className:"h-4 w-[100px]"}),e.jsx(p,{className:"h-16 w-full"})]})})]});if(!a?.running)return e.jsxs(N,{className:x("flex flex-col h-full min-h-0 overflow-hidden gap-0 py-0 border-dashed",s),children:[e.jsx(v,{className:"px-3 py-2",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(R,{className:"text-base font-semibold flex items-center gap-2",children:[e.jsx(Q,{className:"h-4 w-4 text-muted-foreground"}),"CLIProxy Stats"]}),e.jsx(_,{variant:"secondary",className:"text-[10px] h-5",children:u("cliproxyStatsOverview.offline")})]})}),e.jsx(b,{className:"px-3 pb-3 pt-0 flex-1 flex items-center justify-center",children:e.jsx("p",{className:"text-xs text-muted-foreground text-center",children:u("cliproxyStatsOverview.noActiveSessionHint")})})]});if(o)return e.jsxs(N,{className:x("flex flex-col h-full min-h-0 overflow-hidden gap-0 py-0 border-destructive/50",s),children:[e.jsx(v,{className:"px-3 py-2",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(R,{className:"text-base font-semibold flex items-center gap-2",children:[e.jsx(Q,{className:"h-4 w-4"}),"CLIProxy Stats"]}),e.jsx(_,{variant:"destructive",className:"text-[10px] h-5",children:"Error"})]})}),e.jsx(b,{className:"px-3 pb-3 pt-0 flex-1",children:e.jsx("p",{className:"text-xs text-destructive",children:o.message})})]});const c=i?.totalRequests??0,m=i?.quotaExceededCount??0,d=c-m,g=c>0?Math.round(d/c*100):100,S=i?.tokens?.total??0,C=Object.entries(i?.requestsByModel??{}).sort((y,T)=>T[1]-y[1]).slice(0,4),h=C.length>0?C[0][1]:1;return e.jsxs(N,{className:x("flex flex-col h-full min-h-0 overflow-hidden gap-0 py-0",s),children:[e.jsx(v,{className:"px-3 py-2 border-b bg-muted/5",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(R,{className:"text-base font-semibold flex items-center gap-2",children:[e.jsx(Q,{className:"h-4 w-4"}),"CLIProxy Stats"]}),e.jsxs(_,{variant:"outline",className:"text-[10px] h-5 text-green-600 border-green-200 bg-green-50 dark:bg-green-900/10 dark:border-green-800",children:[e.jsx(pe,{className:"h-3 w-3 mr-0.5"}),u("cliproxyStatsOverview.running")]})]})}),e.jsx(b,{className:"p-0 flex-1 min-h-0",children:e.jsx(Ke,{className:"h-full",children:e.jsxs("div",{className:"p-3 space-y-3",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{className:"flex items-center gap-2 p-2 rounded-lg bg-muted/30",children:[e.jsxs("div",{className:"relative",children:[e.jsxs("svg",{className:"w-10 h-10 -rotate-90",viewBox:"0 0 36 36",children:[e.jsx("circle",{cx:"18",cy:"18",r:"14",fill:"none",stroke:"currentColor",strokeWidth:"3",className:"text-muted/30"}),e.jsx("circle",{cx:"18",cy:"18",r:"14",fill:"none",stroke:"currentColor",strokeWidth:"3",strokeDasharray:`${g*.88} 88`,strokeLinecap:"round",className:g>=90?"text-green-500":"text-amber-500"})]}),e.jsxs("span",{className:"absolute inset-0 flex items-center justify-center text-[8px] font-bold",children:[g,"%"]})]}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-lg font-bold leading-none",children:ce(c)}),e.jsx("div",{className:"text-[9px] text-muted-foreground mt-0.5",children:m>0?`${m} failed`:"All success"})]})]}),e.jsxs("div",{className:"flex items-center gap-2 p-2 rounded-lg bg-muted/30",children:[e.jsx("div",{className:"p-1.5 rounded-md bg-purple-100 dark:bg-purple-900/20",children:e.jsx(Xe,{className:"h-4 w-4 text-purple-600"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-lg font-bold leading-none",children:ce(S)}),e.jsx("div",{className:"text-[9px] text-muted-foreground mt-0.5",children:u("cliproxyStatsOverview.totalTokens")})]})]})]}),C.length>0&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-[10px] font-medium text-muted-foreground",children:[e.jsx(Je,{className:"h-3 w-3"}),u("cliproxyStatsOverview.modelsUsed")]}),e.jsx("div",{className:"space-y-1",children:C.map(([y,T])=>{const E=Math.round(T/h*100),O=Es(y);return e.jsxs("div",{className:"group",children:[e.jsxs("div",{className:"flex items-center justify-between text-[10px] mb-0.5",children:[e.jsx("span",{className:"truncate font-medium",title:y,children:O}),e.jsx("span",{className:"text-muted-foreground shrink-0 ml-2",children:T})]}),e.jsx("div",{className:"h-1 bg-muted/50 rounded-full overflow-hidden",children:e.jsx("div",{className:"h-full bg-accent/70 rounded-full transition-all",style:{width:`${E}%`}})})]},y)})})]})]})})})]})}function ce(s){return s>=1e6?`${(s/1e6).toFixed(1)}M`:s>=1e3?`${(s/1e3).toFixed(1)}K`:s.toLocaleString()}function Es(s){let t=s.replace(/^gemini-claude-/,"").replace(/^gemini-/,"").replace(/^claude-/,"").replace(/^anthropic\./,"").replace(/-thinking$/," Thinking");return t=t.split(/[-_]/).map(a=>a.charAt(0).toUpperCase()+a.slice(1)).join(" "),t.length>20&&(t=t.slice(0,18)+"..."),t}function Ks(s){return s>=1e9?`${(s/1e9).toFixed(1)}B`:s>=1e6?`${(s/1e6).toFixed(1)}M`:s>=1e3?`${(s/1e3).toFixed(0)}K`:s.toString()}function _s({models:s,isLoading:t,onModelClick:a,privacyMode:n}){const{t:i}=P();return e.jsxs(N,{className:"flex flex-col h-full min-h-0 overflow-hidden gap-0 py-0 shadow-sm lg:col-span-4",children:[e.jsx(v,{className:"px-3 py-2",children:e.jsxs(R,{className:"text-base font-semibold flex items-center gap-2",children:[e.jsx(me,{className:"w-4 h-4"}),i("analyticsPages.costByModel")]})}),e.jsx(b,{className:"px-2 pb-2 pt-0 flex-1 min-h-0 overflow-y-auto",children:t?e.jsx(p,{className:"h-full w-full"}):e.jsxs("div",{className:"space-y-0.5",children:[[...s||[]].sort((r,o)=>o.cost-r.cost).map(r=>e.jsxs("button",{className:"group flex items-center text-xs w-full hover:bg-muted/50 rounded px-2 py-1.5 transition-colors cursor-pointer gap-3",onClick:o=>a(r,o),title:"Click for details",children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0 w-[180px] shrink-0",children:[e.jsx("div",{className:"w-2 h-2 rounded-full shrink-0",style:{backgroundColor:xe(r.model)}}),e.jsx("span",{className:"font-medium truncate group-hover:underline underline-offset-2",children:r.model})]}),e.jsx(Ws,{model:r}),e.jsx("span",{className:x("text-[10px] text-muted-foreground w-14 text-right shrink-0",n&&k),children:Ks(r.tokens)}),e.jsxs("span",{className:x("font-mono font-medium w-16 text-right shrink-0",n&&k),children:["$",r.cost.toFixed(2)]}),e.jsx(es,{className:"w-3 h-3 opacity-0 group-hover:opacity-50 transition-opacity shrink-0"})]},r.model)),e.jsx(Gs,{})]})})]})}function Ws({model:s}){const t={input:"#335c67",output:"#fff3b0",cacheWrite:"#e09f3e",cacheRead:"#9e2a2b"},a=n=>s.cost>0?n/s.cost*100:0;return e.jsx("div",{className:"flex-1 flex items-center gap-1 min-w-0",children:e.jsxs("div",{className:"flex-1 h-2 bg-muted rounded-full overflow-hidden flex",children:[e.jsx("div",{className:"h-full",style:{backgroundColor:t.input,width:`${a(s.costBreakdown.input.cost)}%`},title:`Input: $${s.costBreakdown.input.cost.toFixed(2)}`}),e.jsx("div",{className:"h-full",style:{backgroundColor:t.output,width:`${a(s.costBreakdown.output.cost)}%`},title:`Output: $${s.costBreakdown.output.cost.toFixed(2)}`}),e.jsx("div",{className:"h-full",style:{backgroundColor:t.cacheWrite,width:`${a(s.costBreakdown.cacheCreation.cost)}%`},title:`Cache Write: $${s.costBreakdown.cacheCreation.cost.toFixed(2)}`}),e.jsx("div",{className:"h-full",style:{backgroundColor:t.cacheRead,width:`${a(s.costBreakdown.cacheRead.cost)}%`},title:`Cache Read: $${s.costBreakdown.cacheRead.cost.toFixed(2)}`})]})})}function Gs(){const s=[{color:"#335c67",label:"Input"},{color:"#fff3b0",label:"Output",hasBorder:!0},{color:"#e09f3e",label:"Cache Write"},{color:"#9e2a2b",label:"Cache Read"}];return e.jsx("div",{className:"flex items-center gap-3 pt-2 px-2 text-[10px] text-muted-foreground border-t mt-2",children:s.map(({color:t,label:a,hasBorder:n})=>e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx("div",{className:x("w-2 h-2 rounded-full",n&&"border border-muted-foreground/30"),style:{backgroundColor:t}}),a]},a))})}function Hs({viewMode:s,trends:t,hourlyData:a,models:n,sessions:i,isTrendsLoading:r,isHourlyLoading:o,isModelsLoading:u,isSessionsLoading:l,isSummaryLoading:c,onModelClick:m}){const{privacyMode:d}=U();return e.jsxs("div",{className:"min-h-0 grid gap-4 lg:grid-rows-[minmax(260px,1.2fr)_minmax(220px,0.9fr)]",children:[e.jsxs(N,{className:"flex flex-col h-full min-h-[220px] lg:min-h-[240px] overflow-hidden gap-0 py-0 shadow-sm",children:[e.jsx(v,{className:"px-3 py-2 shrink-0",children:e.jsxs(R,{className:"text-base font-semibold flex items-center gap-2",children:[e.jsx(ss,{className:"w-4 h-4"}),s==="hourly"?"Last 24 Hours":"Usage Trends"]})}),e.jsx(b,{className:"px-3 pb-3 pt-0 flex-1 min-h-0",children:e.jsx(Ms,{data:s==="hourly"?a||[]:t||[],isLoading:s==="hourly"?o:r,granularity:s==="hourly"?"hourly":"daily"})})]}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-10 gap-4 h-auto min-h-[220px] lg:h-full lg:min-h-[220px] lg:grid-rows-[minmax(0,1fr)] lg:[&>*]:min-h-0",children:[e.jsx(_s,{models:n,isLoading:u,onModelClick:m,privacyMode:d}),e.jsxs(N,{className:"flex flex-col h-full min-h-0 overflow-hidden gap-0 py-0 shadow-sm lg:col-span-2",children:[e.jsx(v,{className:"px-3 py-2",children:e.jsxs(R,{className:"text-base font-semibold flex items-center gap-2",children:[e.jsx(ts,{className:"w-4 h-4"}),"Model Usage"]})}),e.jsx(b,{className:"px-2 pb-2 pt-0 flex-1 min-h-0 flex items-center justify-center",children:e.jsx(As,{data:n||[],isLoading:u,className:"h-full w-full"})})]}),e.jsx(Os,{data:i,isLoading:l,className:"lg:col-span-2"}),e.jsx(qs,{isLoading:c,className:"lg:col-span-2"})]})]})}function at(){return e.jsxs("div",{className:"space-y-4 h-full overflow-hidden",children:[e.jsxs(N,{className:"flex flex-col min-h-[300px]",children:[e.jsx(v,{className:"p-4 pb-2",children:e.jsx(p,{className:"h-4 w-32"})}),e.jsx(b,{className:"p-4 pt-0 flex-1",children:e.jsx(p,{className:"h-full w-full"})})]}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-4",children:[e.jsxs(N,{className:"flex flex-col min-h-[250px]",children:[e.jsx(v,{className:"p-4 pb-2",children:e.jsx(p,{className:"h-4 w-28"})}),e.jsx(b,{className:"p-4 pt-2",children:e.jsx("div",{className:"space-y-3",children:[1,2,3,4,5].map(s=>e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(p,{className:"w-2.5 h-2.5 rounded-full"}),e.jsx(p,{className:"h-3 w-24"})]}),e.jsx(p,{className:"h-3 w-16"})]},s))})})]}),e.jsxs(N,{className:"flex flex-col min-h-[250px]",children:[e.jsx(v,{className:"p-4 pb-2",children:e.jsx(p,{className:"h-4 w-28"})}),e.jsx(b,{className:"p-4 pt-0 flex-1",children:e.jsxs("div",{className:"flex w-full h-full items-center",children:[e.jsx("div",{className:"flex-1 flex justify-center",children:e.jsx(p,{className:"h-[180px] w-[180px] rounded-full"})}),e.jsx("div",{className:"w-[140px] shrink-0 pl-2 space-y-2",children:[1,2,3,4].map(s=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(p,{className:"w-2 h-2 rounded-full"}),e.jsx(p,{className:"h-3 w-20"})]},s))})]})})]})]})]})}function nt(){const s=f.useRef(null),{dateRange:t,handleDateRangeChange:a,handleTodayClick:n,handleRefresh:i,isRefreshing:r,lastUpdatedText:o,viewMode:u,selectedProfile:l,profileOptions:c,summary:m,isSummaryLoading:d,trends:g,hourlyData:S,models:C,sessions:h,isTrendsLoading:y,isHourlyLoading:T,isModelsLoading:E,isSessionsLoading:O,handleModelClick:J,handleProfileChange:G,selectedModel:K,popoverPosition:H,handlePopoverClose:ee}=Rs();return e.jsxs("div",{className:"grid h-full min-h-0 grid-rows-[auto_auto_minmax(0,1fr)] gap-4 overflow-y-auto px-4 py-4",children:[e.jsx(Fs,{dateRange:t,onDateRangeChange:a,onTodayClick:n,onRefresh:i,isRefreshing:r,lastUpdatedText:o,viewMode:u,selectedProfile:l,profileOptions:c,onProfileChange:G}),e.jsx(ms,{data:m,isLoading:d}),e.jsx(Hs,{viewMode:u,trends:g,hourlyData:S,models:C,sessions:h,isTrendsLoading:y,isHourlyLoading:T,isModelsLoading:E,isSessionsLoading:O,isSummaryLoading:d,onModelClick:J}),e.jsxs(de,{open:!!K,onOpenChange:z=>!z&&ee(),children:[e.jsx(_e,{asChild:!0,children:e.jsx("div",{ref:s,className:"fixed pointer-events-none",style:{left:H?.x??0,top:H?.y??0,width:1,height:1}})}),e.jsx(ue,{className:"w-80 p-3",side:"top",align:"center",children:K&&e.jsx(hs,{model:K})})]})]})}export{nt as AnalyticsPage,at as AnalyticsSkeleton};
1
+ import{j as e}from"./radix-ui-nu4wz29m.js";import{r as f,E as Te}from"./react-vendor-Bjx91N7w.js";import{u as U,a as P,C as N,b,S as p,c as x,P as k,B as _,d as Le,e as X,f as de,g as $e,h as ue,i as Re,j as Pe,k as Fe,l as Me,m as De,n as Ae,T as Be,o as Ie,p as Oe,q as Ue,r as xe,s as v,t as R,v as qe,w as Ee,x as Ke,y as _e}from"./index-B2JEyN3d.js";import{a4 as We,an as me,ao as se,ap as he,a2 as fe,ab as Ge,G as He,aq as ze,$ as Ve,R as Ye,a0 as ne,U as Qe,Z as pe,w as Ze,af as Q,ar as Xe,_ as Je,C as es,as as ss,at as ts}from"./icons-DSLG1YsC.js";import{a as as,u as q}from"./tanstack-bhJxV1h8.js";import{u as ns}from"./use-accounts-Bwtpnx-x.js";import{K as B,f as L,H as rs,L as ls}from"./utils-CzKF5WmX.js";import{R as ge,A as os,C as is,X as cs,Y as re,T as je,b as le,P as ds,c as us,d as xs}from"./charts-eIPy2oG6.js";import"./notifications-B4_o8bcr.js";import"./form-utils-CuHzLhJZ.js";function ms({data:s,isLoading:t}){const{privacyMode:a}=U(),{t:n}=P(),i=s?.totalTokens??0,r=s?.totalInputTokens??0,o=s?.totalOutputTokens??0,u=s?.totalCacheTokens??0,l=r+o;if(t)return e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-3 lg:grid-cols-5 gap-4",children:[1,2,3,4,5].map(h=>e.jsx(N,{children:e.jsx(b,{className:"p-6",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(p,{className:"h-4 w-[100px]"}),e.jsx(p,{className:"h-8 w-[80px]"})]}),e.jsx(p,{className:"h-8 w-8 rounded-lg"})]})})},h))});const c=(s?.tokenBreakdown?.cacheCreation?.cost??0)+(s?.tokenBreakdown?.cacheRead?.cost??0),m=s?.totalCost?Math.round(c/s.totalCost*100):0,d=u>0&&i>l,g=u>0&&!d?"Total Tokens (I/O)":n("analyticsSummary.totalTokens"),S=d?`${$(r)} in / ${$(o)} out / ${$(u)} cache`:n("analyticsSummary.totalTokensSubtitle",{input:$(r),output:$(o)}),C=[{title:g,value:i,icon:We,format:h=>$(h),color:"text-blue-600",bgColor:"bg-blue-100 dark:bg-blue-900/20",subtitle:S},{title:n("analyticsSummary.totalCost"),value:s?.totalCost??0,icon:me,format:h=>`$${h.toFixed(2)}`,color:"text-green-600",bgColor:"bg-green-100 dark:bg-green-900/20",subtitle:n("analyticsSummary.totalCostSubtitle",{value:s?.averageCostPerDay?.toFixed(2)??"0.00"})},{title:n("analyticsSummary.cacheTokens"),value:s?.totalCacheTokens??0,icon:se,format:h=>$(h),color:"text-cyan-600",bgColor:"bg-cyan-100 dark:bg-cyan-900/20",subtitle:n("analyticsSummary.cacheTokensSubtitle",{cost:c.toFixed(2),percent:m})},{title:n("analyticsSummary.inputCost"),value:s?.tokenBreakdown?.input?.cost??0,icon:he,format:h=>`$${h.toFixed(2)}`,color:"text-purple-600",bgColor:"bg-purple-100 dark:bg-purple-900/20",subtitle:n("analyticsSummary.tokensSubtitle",{value:$(s?.tokenBreakdown?.input?.tokens??0)})},{title:n("analyticsSummary.outputCost"),value:s?.tokenBreakdown?.output?.cost??0,icon:fe,format:h=>`$${h.toFixed(2)}`,color:"text-orange-600",bgColor:"bg-orange-100 dark:bg-orange-900/20",subtitle:n("analyticsSummary.tokensSubtitle",{value:$(s?.tokenBreakdown?.output?.tokens??0)})}];return e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-3 lg:grid-cols-5 gap-4",children:C.map((h,y)=>{const T=h.icon;return e.jsx(N,{className:"hover:shadow-md transition-shadow",children:e.jsx(b,{className:"p-4",children:e.jsxs("div",{className:"flex items-center justify-between space-x-2",children:[e.jsxs("div",{className:"space-y-1 min-w-0",children:[e.jsx("p",{className:"text-xs font-medium text-muted-foreground truncate",children:h.title}),e.jsx("p",{className:x("text-xl font-bold truncate",a&&k),children:h.format(h.value)}),h.subtitle&&e.jsx("p",{className:x("text-[10px] text-muted-foreground truncate",a&&k),children:h.subtitle})]}),e.jsx("div",{className:x("p-2 rounded-lg shrink-0",h.bgColor),children:e.jsx(T,{className:x("h-4 w-4",h.color)})})]})})},y)})})}function $(s){return s>=1e6?`${(s/1e6).toFixed(1)}M`:s>=1e3?`${(s/1e3).toFixed(1)}K`:s.toLocaleString()}function hs({model:s}){const{privacyMode:t}=U(),{t:a}=P(),n=fs(s.ioRatio),r=s.cacheCreationTokens+s.cacheReadTokens>0?"All Tokens":a("analyticsCards.totalTokens");return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ge,{className:"h-4 w-4 text-primary shrink-0"}),e.jsx("h4",{className:"font-semibold leading-none truncate",title:s.model,children:s.model})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsxs(_,{variant:"secondary",className:"text-[10px] h-5 px-1.5",children:[s.percentage.toFixed(1),"% usage"]}),e.jsxs(_,{variant:n.variant,className:"text-[10px] h-5 px-1.5",children:[s.ioRatio.toFixed(0),":1 I/O"]})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{className:"p-2 rounded-md bg-muted/50 border text-center",children:[e.jsxs("p",{className:x("text-lg font-bold",t&&k),children:["$",s.cost.toFixed(2)]}),e.jsx("p",{className:"text-[10px] text-muted-foreground uppercase tracking-wider",children:a("analyticsCards.totalCost")})]}),e.jsxs("div",{className:"p-2 rounded-md bg-muted/50 border text-center",children:[e.jsx("p",{className:x("text-lg font-bold",t&&k),children:gs(s.tokens)}),e.jsx("p",{className:"text-[10px] text-muted-foreground uppercase tracking-wider",children:r})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("h5",{className:"text-[11px] font-medium text-muted-foreground uppercase tracking-wider",children:"Token Breakdown"}),e.jsxs("div",{className:x("space-y-1",t&&k),children:[e.jsx(Z,{label:"Input",tokens:s.inputTokens,cost:s.costBreakdown.input.cost,color:"#335c67",icon:he}),e.jsx(Z,{label:"Output",tokens:s.outputTokens,cost:s.costBreakdown.output.cost,color:"#fff3b0",icon:fe}),e.jsx(Z,{label:"Cache Write",tokens:s.cacheCreationTokens,cost:s.costBreakdown.cacheCreation.cost,color:"#e09f3e",icon:se}),e.jsx(Z,{label:"Cache Read",tokens:s.cacheReadTokens,cost:s.costBreakdown.cacheRead.cost,color:"#9e2a2b",icon:se})]})]}),e.jsxs("div",{className:"p-2.5 rounded-md border bg-muted/20 space-y-1.5",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(He,{className:"h-3.5 w-3.5 text-muted-foreground"}),e.jsx("span",{className:"text-xs font-medium",children:a("analyticsCards.inputOutputRatio")})]}),e.jsx("p",{className:"text-[11px] text-muted-foreground leading-snug",children:n.description})]})]})}function Z({label:s,tokens:t,cost:a,color:n,icon:i}){return t===0?null:e.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[e.jsx("div",{className:"w-1 h-6 rounded-full shrink-0",style:{backgroundColor:n}}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"font-medium truncate",children:s}),e.jsxs("span",{className:"font-mono text-muted-foreground",children:["$",a.toFixed(3)]})]}),e.jsxs("div",{className:"flex items-center gap-1.5 text-muted-foreground",children:[e.jsx(i,{className:"h-3 w-3 shrink-0"}),e.jsx("span",{children:ps(t)})]})]})]})}function fs(s){return s>=200?{variant:"destructive",description:"Extended thinking or large context loading. Expected for reasoning models."}:s>=50?{variant:"secondary",description:"More input than output. Typical for analysis tasks."}:s>=5?{variant:"outline",description:"Balanced input/output ratio for typical coding tasks."}:{variant:"default",description:"More output than input. Generation-heavy workload."}}function ps(s){return s.toLocaleString()}function gs(s){return s>=1e9?`${(s/1e9).toFixed(1)}B`:s>=1e6?`${(s/1e6).toFixed(1)}M`:s>=1e3?`${(s/1e3).toFixed(1)}K`:s.toString()}const js="/api";function oe(s){const t=s.getFullYear(),a=String(s.getMonth()+1).padStart(2,"0"),n=String(s.getDate()).padStart(2,"0");return`${t}${a}${n}`}function M(s,t){const a=t.toString();return a?`${s}?${a}`:s}function D(s,t){t?.startDate&&s.append("since",oe(t.startDate)),t?.endDate&&s.append("until",oe(t.endDate))}function A(s,t){t?.profile&&s.append("profile",t.profile)}const I={summary:s=>{const t=new URLSearchParams;return D(t,s),A(t,s),F(M("/usage/summary",t))},trends:s=>{const t=new URLSearchParams;return D(t,s),A(t,s),F(M("/usage/daily",t))},hourly:s=>{const t=new URLSearchParams;return D(t,s),A(t,s),F(M("/usage/hourly",t))},models:s=>{const t=new URLSearchParams;return D(t,s),A(t,s),F(M("/usage/models",t))},sessions:s=>{const t=new URLSearchParams;return D(t,s),s?.limit&&t.append("limit",s.limit.toString()),s?.offset&&t.append("offset",s.offset.toString()),A(t,s),F(M("/usage/sessions",t))},monthly:s=>{const t=new URLSearchParams;return D(t,s),A(t,s),F(M("/usage/monthly",t))},refresh:async()=>{if(!(await fetch(`${js}/usage/refresh`,{method:"POST",headers:{"Content-Type":"application/json"}})).ok)throw new Error("Failed to refresh usage cache")},status:()=>F("/usage/status"),insights:s=>{const t=new URLSearchParams;return D(t,s),A(t,s),F(M("/usage/insights",t))}};async function F(s){const a=await fetch(`/api${s}`,{headers:{"Content-Type":"application/json"}});if(!a.ok){const i=await a.json().catch(()=>({error:"Unknown error"}));throw new Error(i.error||a.statusText)}const n=await a.json();return n.data||n}function ys(s){return q({queryKey:["usage","summary",s],queryFn:()=>I.summary(s),staleTime:60*1e3})}function Ns(s){return q({queryKey:["usage","trends",s],queryFn:()=>I.trends(s),staleTime:60*1e3})}function bs(s){return q({queryKey:["usage","hourly",s],queryFn:()=>I.hourly(s),staleTime:60*1e3})}function ws(s){return q({queryKey:["usage","models",s],queryFn:()=>I.models(s),staleTime:60*1e3})}function vs(){const s=as();return f.useCallback(async()=>{await I.refresh(),await s.invalidateQueries({queryKey:["usage"]})},[s])}function ks(){return q({queryKey:["usage","status"],queryFn:()=>I.status(),staleTime:10*1e3,refetchInterval:30*1e3})}function Cs(s){return q({queryKey:["usage","sessions",s],queryFn:()=>I.sessions(s),staleTime:60*1e3})}function Ss(s){const t=Math.max(1,Math.floor((Date.now()-s.getTime())/1e3));if(t<60)return`${t}s ago`;const a=Math.floor(t/60);if(a<60)return`${a}m ago`;const n=Math.floor(a/60);return n<24?`${n}h ago`:`${Math.floor(n/24)}d ago`}const Ts=50,te="ccs.analytics.selectedProfile",W="all";function Ls(){if(typeof globalThis.localStorage>"u")return W;const s=globalThis.localStorage.getItem(te);return!s||s.startsWith("unsupported:")?W:s}function $s(s){if(!(typeof globalThis.localStorage>"u")){if(s===W){globalThis.localStorage.removeItem(te);return}globalThis.localStorage.setItem(te,s)}}function Rs(){const[s,t]=f.useState({from:B(new Date,30),to:new Date}),[a,n]=f.useState(!1),[i,r]=f.useState(null),[o,u]=f.useState(Ls),[l,c]=f.useState(null),[m,d]=f.useState("daily"),{data:g}=ns(),{data:S}=Le(),C=vs(),h=f.useCallback(async()=>{n(!0);try{await C()}finally{n(!1)}},[C]),y=f.useMemo(()=>({startDate:s?.from,endDate:s?.to,profile:o===W?void 0:o}),[s?.from,s?.to,o]),T=f.useMemo(()=>{const w=new Set(g?.accounts.map(j=>j.name)??[]),Y=[{value:W,label:"All profiles",description:"Includes all analytics sources.",supported:!0},{value:"default",label:"Default Claude",description:"Profile-scoped Claude JSONL data.",supported:!0},...Array.from(w).sort((j,Se)=>j.localeCompare(Se)).map(j=>({value:j,label:j,description:"Profile-scoped account data.",supported:!0}))];for(const j of S?.profiles??[])w.has(j.name)||j.name==="default"||Y.push({value:`unsupported:${j.name}`,label:j.name,description:"API profile usage is not yet attributed by stable profile.",supported:!1});return Y},[g?.accounts,S?.profiles]),{data:E,isLoading:O}=ys(y),{data:J,isLoading:G}=Ns(y),{data:K,isLoading:H}=bs(y),{data:ee,isLoading:z}=ws(y),{data:ye,isLoading:ae}=Cs({...y,limit:Ts}),{data:V}=ks(),Ne=f.useCallback(()=>{const w=new Date;t({from:B(w,1),to:w}),d("hourly")},[]),be=f.useCallback(w=>{t(w),d("daily")},[]),we=f.useCallback(w=>{w.startsWith("unsupported:")||(u(w),$s(w))},[]),ve=f.useMemo(()=>V?.lastFetch?Ss(new Date(V.lastFetch)):null,[V?.lastFetch]),ke=f.useCallback((w,Y)=>{const j=Y.currentTarget.getBoundingClientRect();c({x:j.left+j.width/2,y:j.top+j.height/2}),r(w)},[]),Ce=f.useCallback(()=>{r(null),c(null)},[]);return{dateRange:s,isRefreshing:a,viewMode:m,selectedProfile:o,profileOptions:T,selectedModel:i,popoverPosition:l,summary:E,trends:J,hourlyData:K,models:ee,sessions:ye,status:V,isSummaryLoading:O,isTrendsLoading:G,isHourlyLoading:H,isModelsLoading:z,isSessionsLoading:ae,isLoading:O||G||z||ae,handleRefresh:h,handleTodayClick:Ne,handleDateRangeChange:be,handleProfileChange:we,handleModelClick:ke,handlePopoverClose:Ce,lastUpdatedText:ve}}function Ps({value:s,onChange:t,presets:a=[{label:"Last 7 days",range:{from:B(new Date,7),to:new Date}},{label:"Last 30 days",range:{from:B(new Date,30),to:new Date}},{label:"Last 90 days",range:{from:B(new Date,90),to:new Date}}],className:n}){const[i,r]=Te.useState(!1),{t:o}=P(),u=l=>!s||!s.from||!s.to||!l.from||!l.to?!1:L(s.from,"yyyy-MM-dd")===L(l.from,"yyyy-MM-dd")&&L(s.to,"yyyy-MM-dd")===L(l.to,"yyyy-MM-dd");return e.jsxs("div",{className:x("flex flex-wrap items-center gap-2",n),children:[a.map(l=>e.jsx(X,{variant:u(l.range)?"default":"outline",size:"sm",onClick:()=>t(l.range),children:l.label},l.label)),e.jsxs(de,{open:i,onOpenChange:r,children:[e.jsx($e,{asChild:!0,children:e.jsxs(X,{id:"date",variant:"outline",className:x("w-auto min-w-[200px] sm:min-w-[240px] justify-start text-left font-normal",!s&&"text-muted-foreground"),children:[e.jsx(ze,{className:"mr-2 h-4 w-4"}),s?.from?s.to?e.jsxs(e.Fragment,{children:[L(s.from,"LLL dd, y")," - ",L(s.to,"LLL dd, y")]}):L(s.from,"LLL dd, y"):e.jsx("span",{children:o("dateRangeFilter.pickADate")})]})}),e.jsx(ue,{className:"w-auto p-0",align:"end",children:e.jsx(Re,{initialFocus:!0,mode:"range",defaultMonth:s?.from,selected:s,onSelect:t,numberOfMonths:2})})]})]})}function Fs({dateRange:s,onDateRangeChange:t,onTodayClick:a,onRefresh:n,isRefreshing:i,lastUpdatedText:r,viewMode:o,selectedProfile:u,profileOptions:l,onProfileChange:c}){const{t:m}=P();return e.jsxs("div",{className:"flex flex-col gap-3 shrink-0 xl:flex-row xl:items-center xl:justify-between",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-xl font-semibold",children:m("analytics.title")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:m("analytics.subtitle")})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2 xl:justify-end",children:[e.jsxs("div",{className:"inline-flex items-center gap-1 shrink-0",children:[e.jsxs(Pe,{value:u,onValueChange:c,children:[e.jsx(Fe,{className:"h-8 w-[170px]","aria-label":"Analytics profile",children:e.jsx(Me,{placeholder:"All profiles",children:l.find(d=>d.value===u)?.label??"All profiles"})}),e.jsx(De,{children:l.map(d=>e.jsx(Ae,{value:d.value,disabled:!d.supported,children:e.jsxs("span",{className:"flex flex-col",children:[e.jsx("span",{children:d.label}),e.jsx("span",{className:"text-xs text-muted-foreground",children:d.description})]})},d.value))})]}),u!=="all"&&e.jsx(Be,{delayDuration:150,children:e.jsxs(Ie,{children:[e.jsx(Oe,{asChild:!0,children:e.jsx("button",{type:"button","aria-label":"Selected-profile analytics scope",className:"inline-flex size-7 items-center justify-center rounded-md text-muted-foreground hover:bg-accent hover:text-foreground",children:e.jsx(Ve,{className:"size-4","aria-hidden":"true"})})}),e.jsx(Ue,{side:"bottom",align:"start",className:"max-w-xs text-xs",children:"Selected-profile analytics include only default/account data with stable profile attribution. CLIProxy and native runtime snapshots remain in All profiles."})]})})]}),e.jsx(X,{variant:o==="hourly"?"default":"outline",size:"sm",className:"h-8",onClick:a,children:"24H"}),e.jsx(Ps,{className:"flex-wrap",value:s,onChange:t,presets:[{label:"7D",range:{from:B(new Date,7),to:new Date}},{label:"30D",range:{from:B(new Date,30),to:new Date}},{label:m("analytics.month"),range:{from:rs(new Date),to:new Date}},{label:m("analytics.allTime"),range:{from:void 0,to:new Date}}]}),r&&e.jsx("span",{className:"text-xs text-muted-foreground whitespace-nowrap font-mono",title:m("analytics.updated",{value:r}),children:r}),e.jsx(X,{variant:"outline",size:"sm",className:"gap-2 h-8",onClick:n,disabled:i,children:e.jsx(Ye,{className:`w-3.5 h-3.5 ${i?"animate-spin":""}`})})]})]})}function Ms({data:s,isLoading:t,granularity:a="daily",className:n}){const{privacyMode:i}=U(),{t:r}=P(),o=f.useMemo(()=>!s||s.length===0?[]:s.map(c=>{const m="hour"in c?c.hour:c.date;return{...c,dateFormatted:Ds(m,a),costRounded:Number(c.cost.toFixed(4))}}),[s,a]);if(t)return e.jsx(p,{className:x("h-full w-full",n)});if(!s||s.length===0)return e.jsx("div",{className:x("h-full flex items-center justify-center",n),children:e.jsx("p",{className:"text-muted-foreground",children:r(a==="hourly"?"analytics.noDailyUsage":"analytics.noUsageData")})});const u=({x:l,y:c,payload:m,isRight:d})=>{const g=d?`$${m.value}`:ie(Number(m.value));return e.jsx("text",{x:l,y:c,dy:4,textAnchor:d?"start":"end",fontSize:12,fill:"currentColor",className:x("fill-muted-foreground",i&&"blur-[4px]"),children:g})};return e.jsx("div",{className:x("w-full h-full",n),children:e.jsx(ge,{width:"100%",height:"100%",children:e.jsxs(os,{data:o,margin:{top:5,right:30,left:20,bottom:5},children:[e.jsxs("defs",{children:[e.jsxs("linearGradient",{id:"tokenGradient",x1:"0",y1:"0",x2:"0",y2:"1",children:[e.jsx("stop",{offset:"5%",stopColor:"#0080FF",stopOpacity:.8}),e.jsx("stop",{offset:"95%",stopColor:"#0080FF",stopOpacity:.1})]}),e.jsxs("linearGradient",{id:"costGradient",x1:"0",y1:"0",x2:"0",y2:"1",children:[e.jsx("stop",{offset:"5%",stopColor:"#00C49F",stopOpacity:.8}),e.jsx("stop",{offset:"95%",stopColor:"#00C49F",stopOpacity:.1})]})]}),e.jsx(is,{strokeDasharray:"3 3",className:"stroke-muted"}),e.jsx(cs,{dataKey:"dateFormatted",tick:{fontSize:12},tickLine:!1,axisLine:{className:"stroke-muted"}}),e.jsx(re,{yAxisId:"left",orientation:"left",tick:l=>e.jsx(u,{...l,isRight:!1}),tickLine:!1,axisLine:{className:"stroke-muted"}}),e.jsx(re,{yAxisId:"right",orientation:"right",tick:l=>e.jsx(u,{...l,isRight:!0}),tickLine:!1,axisLine:{className:"stroke-muted"}}),e.jsx(je,{content:({active:l,payload:c,label:m})=>!l||!c||!c.length?null:e.jsxs("div",{className:"rounded-lg border bg-background p-3 shadow-lg",children:[e.jsx("p",{className:"font-medium mb-2",children:m}),c.map((d,g)=>e.jsxs("p",{className:x("text-sm",i&&k),style:{color:d.color},children:[d.name,":"," ",d.name==="Tokens"?ie(Number(d.value)||0):`$${d.value}`]},g))]})}),e.jsx(le,{yAxisId:"left",type:"monotone",dataKey:"tokens",stroke:"#0080FF",strokeWidth:2,fillOpacity:1,fill:"url(#tokenGradient)",name:"Tokens"}),e.jsx(le,{yAxisId:"right",type:"monotone",dataKey:"costRounded",stroke:"#00C49F",strokeWidth:2,fillOpacity:1,fill:"url(#costGradient)",name:"Cost"})]})})})}function Ds(s,t){if(t==="hourly"){const[n,i]=s.split(" ");if(n&&i){const r=new Date(`${n}T${i}:00Z`);return L(r,"HH:mm")}return s}const a=new Date(s);return t==="monthly"?L(a,"MMM yyyy"):L(a,"MMM dd")}function ie(s){return s>=1e6?`${(s/1e6).toFixed(1)}M`:s>=1e3?`${(s/1e3).toFixed(1)}K`:s.toLocaleString()}function As({data:s,isLoading:t,className:a}){const{privacyMode:n}=U(),{t:i}=P(),r=f.useMemo(()=>!s||s.length===0?[]:s.map(l=>({name:l.model,value:l.tokens,cost:l.cost,percentage:l.percentage,fill:xe(l.model)})),[s]);if(t)return e.jsx(p,{className:x("h-full min-h-[100px] w-full",a)});if(!s||s.length===0)return e.jsx("div",{className:x("h-full min-h-[100px] flex items-center justify-center",a),children:e.jsx("p",{className:"text-muted-foreground",children:i("analyticsCards.noModelData")})});const o=({active:l,payload:c})=>{if(!l||!c)return null;const m=c;if(!m.length)return null;const d=m[0].payload;return e.jsxs("div",{className:"rounded-lg border bg-background p-2 shadow-lg text-xs",children:[e.jsx("p",{className:"font-medium mb-1",children:d.name}),e.jsxs("p",{className:x("text-muted-foreground",n&&k),children:[Bs(d.value)," (",d.percentage.toFixed(1),"%)"]}),e.jsxs("p",{className:x("text-muted-foreground",n&&k),children:["$",d.cost.toFixed(4)]})]})},u=l=>l.percentage>5?`${l.percentage.toFixed(1)}%`:"";return e.jsx("div",{className:x("w-full h-full min-h-[100px]",a),children:e.jsx(ge,{width:"100%",height:"100%",children:e.jsxs(ds,{children:[e.jsx(us,{data:r,cx:"50%",cy:"50%",labelLine:!1,label:u,innerRadius:50,outerRadius:70,paddingAngle:2,dataKey:"value",children:r.map((l,c)=>e.jsx(xs,{fill:l.fill,strokeWidth:1},`cell-${c}`))}),e.jsx(je,{content:o})]})})})}function Bs(s){return s>=1e6?`${(s/1e6).toFixed(1)}M`:s>=1e3?`${(s/1e3).toFixed(1)}K`:s.toLocaleString()}function Is(s){if(!s)return"";const a=s.replace(/^\/|\/$/g,"").split("/").filter(n=>n.length>0);return a[a.length-1]||""}function Os({data:s,isLoading:t,className:a}){const{privacyMode:n}=U(),{t:i}=P(),r=f.useMemo(()=>{if(!s?.sessions||s.sessions.length===0)return null;const o=s.sessions,u=s.total,l=o.length,c=s.hasMore||s.offset>0,d=o.reduce((g,S)=>g+S.cost,0)/o.length;return{displayedSessions:c?l:u,totalSessions:u,avgCost:d,hasPartialSample:c,recentSessions:o.slice(0,3)}},[s]);return t?e.jsxs(N,{className:x("flex flex-col h-full min-h-0 overflow-hidden gap-0 py-0",a),children:[e.jsx(v,{className:"px-3 py-2",children:e.jsx(p,{className:"h-5 w-32"})}),e.jsx(b,{className:"px-3 pb-3 pt-0 flex-1",children:e.jsx(p,{className:"h-full w-full"})})]}):r?e.jsxs(N,{className:x("flex flex-col h-full min-h-0 overflow-hidden gap-0 py-0 shadow-sm",a),children:[e.jsx(v,{className:"px-3 py-2",children:e.jsxs(R,{className:"text-base font-semibold flex items-center gap-2",children:[e.jsx(ne,{className:"w-4 h-4"}),"Session Stats"]})}),e.jsxs(b,{className:"px-3 pb-3 pt-0 flex-1 min-h-0 flex flex-col gap-3",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{className:"p-2 rounded-md bg-muted/50 border text-center",children:[e.jsxs("div",{className:"flex items-center justify-center gap-1.5 text-blue-600 dark:text-blue-400",children:[e.jsx(Qe,{className:"w-4 h-4"}),e.jsx("span",{className:"text-xl font-bold",children:r.displayedSessions})]}),e.jsx("p",{className:"text-[10px] text-muted-foreground uppercase tracking-wider mt-0.5",children:r.hasPartialSample?"Sampled Sessions":"Total Sessions"}),r.hasPartialSample&&e.jsxs("p",{className:"text-[10px] text-muted-foreground mt-0.5",children:[r.totalSessions," total"]})]}),e.jsxs("div",{className:"p-2 rounded-md bg-muted/50 border text-center",children:[e.jsxs("div",{className:"flex items-center justify-center gap-1.5 text-green-600 dark:text-green-400",children:[e.jsx(pe,{className:"w-4 h-4"}),e.jsxs("span",{className:x("text-xl font-bold",n&&k),children:["$",r.avgCost.toFixed(2)]})]}),e.jsx("p",{className:"text-[10px] text-muted-foreground uppercase tracking-wider mt-0.5",children:r.hasPartialSample?"Recent Avg Cost":"Avg Cost/Session"})]})]}),e.jsxs("div",{className:"flex-1 min-h-0 space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-1 text-xs text-muted-foreground font-medium mb-1",children:[e.jsx(Ze,{className:"w-3 h-3"}),"Recent Activity"]}),e.jsx("div",{className:"space-y-1.5 max-h-full overflow-y-auto pr-1",children:r.recentSessions.map(o=>e.jsxs("div",{className:"flex items-center justify-between text-xs p-1.5 rounded bg-muted/30 hover:bg-muted/50 transition-colors",children:[e.jsxs("div",{className:"flex flex-col min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("span",{className:"font-medium truncate",title:o.projectPath,children:Is(o.projectPath)}),(o.target??"claude")!=="claude"&&e.jsx("span",{className:"shrink-0 px-1 py-0 text-[9px] font-medium rounded bg-purple-100 text-purple-700 dark:bg-purple-900/30 dark:text-purple-300 uppercase",children:o.target})]}),e.jsx("span",{className:"text-[10px] text-muted-foreground",children:ls(new Date(o.lastActivity),{addSuffix:!0})})]}),e.jsxs("div",{className:x("text-right shrink-0 ml-2",n&&k),children:[e.jsxs("div",{className:"font-mono",children:["$",o.cost.toFixed(2)]}),e.jsxs("div",{className:"text-[10px] text-muted-foreground",children:[Us(o.tokens??o.inputTokens+o.outputTokens)," ","toks"]})]})]},o.sessionId))})]})]})]}):e.jsxs(N,{className:x("flex flex-col h-full min-h-0 overflow-hidden gap-0 py-0",a),children:[e.jsx(v,{className:"px-3 py-2",children:e.jsxs(R,{className:"text-base font-semibold flex items-center gap-2",children:[e.jsx(ne,{className:"w-4 h-4"}),"Session Stats"]})}),e.jsx(b,{className:"px-3 pb-3 pt-0 flex-1 flex items-center justify-center",children:e.jsx("p",{className:"text-sm text-muted-foreground text-center",children:i("analyticsCards.noSessionData")})})]})}function Us(s){return s>=1e9?`${(s/1e9).toFixed(1)}B`:s>=1e6?`${(s/1e6).toFixed(1)}M`:s>=1e3?`${(s/1e3).toFixed(1)}K`:s.toString()}function qs({className:s,isLoading:t}){const{data:a,isLoading:n}=qe(),{data:i,isLoading:r,error:o}=Ee(a?.running),{t:u}=P();if(t||n||a?.running&&r)return e.jsxs(N,{className:x("flex flex-col h-full min-h-0 overflow-hidden gap-0 py-0",s),children:[e.jsx(v,{className:"px-3 py-2",children:e.jsxs(R,{className:"text-base font-semibold flex items-center gap-2",children:[e.jsx(Q,{className:"h-4 w-4"}),"CLIProxy Stats"]})}),e.jsx(b,{className:"px-3 pb-3 pt-0 flex-1",children:e.jsxs("div",{className:"space-y-3",children:[e.jsx(p,{className:"h-4 w-[100px]"}),e.jsx(p,{className:"h-16 w-full"})]})})]});if(!a?.running)return e.jsxs(N,{className:x("flex flex-col h-full min-h-0 overflow-hidden gap-0 py-0 border-dashed",s),children:[e.jsx(v,{className:"px-3 py-2",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(R,{className:"text-base font-semibold flex items-center gap-2",children:[e.jsx(Q,{className:"h-4 w-4 text-muted-foreground"}),"CLIProxy Stats"]}),e.jsx(_,{variant:"secondary",className:"text-[10px] h-5",children:u("cliproxyStatsOverview.offline")})]})}),e.jsx(b,{className:"px-3 pb-3 pt-0 flex-1 flex items-center justify-center",children:e.jsx("p",{className:"text-xs text-muted-foreground text-center",children:u("cliproxyStatsOverview.noActiveSessionHint")})})]});if(o)return e.jsxs(N,{className:x("flex flex-col h-full min-h-0 overflow-hidden gap-0 py-0 border-destructive/50",s),children:[e.jsx(v,{className:"px-3 py-2",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(R,{className:"text-base font-semibold flex items-center gap-2",children:[e.jsx(Q,{className:"h-4 w-4"}),"CLIProxy Stats"]}),e.jsx(_,{variant:"destructive",className:"text-[10px] h-5",children:"Error"})]})}),e.jsx(b,{className:"px-3 pb-3 pt-0 flex-1",children:e.jsx("p",{className:"text-xs text-destructive",children:o.message})})]});const c=i?.totalRequests??0,m=i?.quotaExceededCount??0,d=c-m,g=c>0?Math.round(d/c*100):100,S=i?.tokens?.total??0,C=Object.entries(i?.requestsByModel??{}).sort((y,T)=>T[1]-y[1]).slice(0,4),h=C.length>0?C[0][1]:1;return e.jsxs(N,{className:x("flex flex-col h-full min-h-0 overflow-hidden gap-0 py-0",s),children:[e.jsx(v,{className:"px-3 py-2 border-b bg-muted/5",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(R,{className:"text-base font-semibold flex items-center gap-2",children:[e.jsx(Q,{className:"h-4 w-4"}),"CLIProxy Stats"]}),e.jsxs(_,{variant:"outline",className:"text-[10px] h-5 text-green-600 border-green-200 bg-green-50 dark:bg-green-900/10 dark:border-green-800",children:[e.jsx(pe,{className:"h-3 w-3 mr-0.5"}),u("cliproxyStatsOverview.running")]})]})}),e.jsx(b,{className:"p-0 flex-1 min-h-0",children:e.jsx(Ke,{className:"h-full",children:e.jsxs("div",{className:"p-3 space-y-3",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{className:"flex items-center gap-2 p-2 rounded-lg bg-muted/30",children:[e.jsxs("div",{className:"relative",children:[e.jsxs("svg",{className:"w-10 h-10 -rotate-90",viewBox:"0 0 36 36",children:[e.jsx("circle",{cx:"18",cy:"18",r:"14",fill:"none",stroke:"currentColor",strokeWidth:"3",className:"text-muted/30"}),e.jsx("circle",{cx:"18",cy:"18",r:"14",fill:"none",stroke:"currentColor",strokeWidth:"3",strokeDasharray:`${g*.88} 88`,strokeLinecap:"round",className:g>=90?"text-green-500":"text-amber-500"})]}),e.jsxs("span",{className:"absolute inset-0 flex items-center justify-center text-[8px] font-bold",children:[g,"%"]})]}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-lg font-bold leading-none",children:ce(c)}),e.jsx("div",{className:"text-[9px] text-muted-foreground mt-0.5",children:m>0?`${m} failed`:"All success"})]})]}),e.jsxs("div",{className:"flex items-center gap-2 p-2 rounded-lg bg-muted/30",children:[e.jsx("div",{className:"p-1.5 rounded-md bg-purple-100 dark:bg-purple-900/20",children:e.jsx(Xe,{className:"h-4 w-4 text-purple-600"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-lg font-bold leading-none",children:ce(S)}),e.jsx("div",{className:"text-[9px] text-muted-foreground mt-0.5",children:u("cliproxyStatsOverview.totalTokens")})]})]})]}),C.length>0&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-[10px] font-medium text-muted-foreground",children:[e.jsx(Je,{className:"h-3 w-3"}),u("cliproxyStatsOverview.modelsUsed")]}),e.jsx("div",{className:"space-y-1",children:C.map(([y,T])=>{const E=Math.round(T/h*100),O=Es(y);return e.jsxs("div",{className:"group",children:[e.jsxs("div",{className:"flex items-center justify-between text-[10px] mb-0.5",children:[e.jsx("span",{className:"truncate font-medium",title:y,children:O}),e.jsx("span",{className:"text-muted-foreground shrink-0 ml-2",children:T})]}),e.jsx("div",{className:"h-1 bg-muted/50 rounded-full overflow-hidden",children:e.jsx("div",{className:"h-full bg-accent/70 rounded-full transition-all",style:{width:`${E}%`}})})]},y)})})]})]})})})]})}function ce(s){return s>=1e6?`${(s/1e6).toFixed(1)}M`:s>=1e3?`${(s/1e3).toFixed(1)}K`:s.toLocaleString()}function Es(s){let t=s.replace(/^gemini-claude-/,"").replace(/^gemini-/,"").replace(/^claude-/,"").replace(/^anthropic\./,"").replace(/-thinking$/," Thinking");return t=t.split(/[-_]/).map(a=>a.charAt(0).toUpperCase()+a.slice(1)).join(" "),t.length>20&&(t=t.slice(0,18)+"..."),t}function Ks(s){return s>=1e9?`${(s/1e9).toFixed(1)}B`:s>=1e6?`${(s/1e6).toFixed(1)}M`:s>=1e3?`${(s/1e3).toFixed(0)}K`:s.toString()}function _s({models:s,isLoading:t,onModelClick:a,privacyMode:n}){const{t:i}=P();return e.jsxs(N,{className:"flex flex-col h-full min-h-0 overflow-hidden gap-0 py-0 shadow-sm lg:col-span-4",children:[e.jsx(v,{className:"px-3 py-2",children:e.jsxs(R,{className:"text-base font-semibold flex items-center gap-2",children:[e.jsx(me,{className:"w-4 h-4"}),i("analyticsPages.costByModel")]})}),e.jsx(b,{className:"px-2 pb-2 pt-0 flex-1 min-h-0 overflow-y-auto",children:t?e.jsx(p,{className:"h-full w-full"}):e.jsxs("div",{className:"space-y-0.5",children:[[...s||[]].sort((r,o)=>o.cost-r.cost).map(r=>e.jsxs("button",{className:"group flex items-center text-xs w-full hover:bg-muted/50 rounded px-2 py-1.5 transition-colors cursor-pointer gap-3",onClick:o=>a(r,o),title:"Click for details",children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0 w-[180px] shrink-0",children:[e.jsx("div",{className:"w-2 h-2 rounded-full shrink-0",style:{backgroundColor:xe(r.model)}}),e.jsx("span",{className:"font-medium truncate group-hover:underline underline-offset-2",children:r.model})]}),e.jsx(Ws,{model:r}),e.jsx("span",{className:x("text-[10px] text-muted-foreground w-14 text-right shrink-0",n&&k),children:Ks(r.tokens)}),e.jsxs("span",{className:x("font-mono font-medium w-16 text-right shrink-0",n&&k),children:["$",r.cost.toFixed(2)]}),e.jsx(es,{className:"w-3 h-3 opacity-0 group-hover:opacity-50 transition-opacity shrink-0"})]},r.model)),e.jsx(Gs,{})]})})]})}function Ws({model:s}){const t={input:"#335c67",output:"#fff3b0",cacheWrite:"#e09f3e",cacheRead:"#9e2a2b"},a=n=>s.cost>0?n/s.cost*100:0;return e.jsx("div",{className:"flex-1 flex items-center gap-1 min-w-0",children:e.jsxs("div",{className:"flex-1 h-2 bg-muted rounded-full overflow-hidden flex",children:[e.jsx("div",{className:"h-full",style:{backgroundColor:t.input,width:`${a(s.costBreakdown.input.cost)}%`},title:`Input: $${s.costBreakdown.input.cost.toFixed(2)}`}),e.jsx("div",{className:"h-full",style:{backgroundColor:t.output,width:`${a(s.costBreakdown.output.cost)}%`},title:`Output: $${s.costBreakdown.output.cost.toFixed(2)}`}),e.jsx("div",{className:"h-full",style:{backgroundColor:t.cacheWrite,width:`${a(s.costBreakdown.cacheCreation.cost)}%`},title:`Cache Write: $${s.costBreakdown.cacheCreation.cost.toFixed(2)}`}),e.jsx("div",{className:"h-full",style:{backgroundColor:t.cacheRead,width:`${a(s.costBreakdown.cacheRead.cost)}%`},title:`Cache Read: $${s.costBreakdown.cacheRead.cost.toFixed(2)}`})]})})}function Gs(){const s=[{color:"#335c67",label:"Input"},{color:"#fff3b0",label:"Output",hasBorder:!0},{color:"#e09f3e",label:"Cache Write"},{color:"#9e2a2b",label:"Cache Read"}];return e.jsx("div",{className:"flex items-center gap-3 pt-2 px-2 text-[10px] text-muted-foreground border-t mt-2",children:s.map(({color:t,label:a,hasBorder:n})=>e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx("div",{className:x("w-2 h-2 rounded-full",n&&"border border-muted-foreground/30"),style:{backgroundColor:t}}),a]},a))})}function Hs({viewMode:s,trends:t,hourlyData:a,models:n,sessions:i,isTrendsLoading:r,isHourlyLoading:o,isModelsLoading:u,isSessionsLoading:l,isSummaryLoading:c,onModelClick:m}){const{privacyMode:d}=U();return e.jsxs("div",{className:"min-h-0 grid gap-4 lg:grid-rows-[minmax(260px,1.2fr)_minmax(220px,0.9fr)]",children:[e.jsxs(N,{className:"flex flex-col h-full min-h-[220px] lg:min-h-[240px] overflow-hidden gap-0 py-0 shadow-sm",children:[e.jsx(v,{className:"px-3 py-2 shrink-0",children:e.jsxs(R,{className:"text-base font-semibold flex items-center gap-2",children:[e.jsx(ss,{className:"w-4 h-4"}),s==="hourly"?"Last 24 Hours":"Usage Trends"]})}),e.jsx(b,{className:"px-3 pb-3 pt-0 flex-1 min-h-0",children:e.jsx(Ms,{data:s==="hourly"?a||[]:t||[],isLoading:s==="hourly"?o:r,granularity:s==="hourly"?"hourly":"daily"})})]}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-10 gap-4 h-auto min-h-[220px] lg:h-full lg:min-h-[220px] lg:grid-rows-[minmax(0,1fr)] lg:[&>*]:min-h-0",children:[e.jsx(_s,{models:n,isLoading:u,onModelClick:m,privacyMode:d}),e.jsxs(N,{className:"flex flex-col h-full min-h-0 overflow-hidden gap-0 py-0 shadow-sm lg:col-span-2",children:[e.jsx(v,{className:"px-3 py-2",children:e.jsxs(R,{className:"text-base font-semibold flex items-center gap-2",children:[e.jsx(ts,{className:"w-4 h-4"}),"Model Usage"]})}),e.jsx(b,{className:"px-2 pb-2 pt-0 flex-1 min-h-0 flex items-center justify-center",children:e.jsx(As,{data:n||[],isLoading:u,className:"h-full w-full"})})]}),e.jsx(Os,{data:i,isLoading:l,className:"lg:col-span-2"}),e.jsx(qs,{isLoading:c,className:"lg:col-span-2"})]})]})}function at(){return e.jsxs("div",{className:"space-y-4 h-full overflow-hidden",children:[e.jsxs(N,{className:"flex flex-col min-h-[300px]",children:[e.jsx(v,{className:"p-4 pb-2",children:e.jsx(p,{className:"h-4 w-32"})}),e.jsx(b,{className:"p-4 pt-0 flex-1",children:e.jsx(p,{className:"h-full w-full"})})]}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-4",children:[e.jsxs(N,{className:"flex flex-col min-h-[250px]",children:[e.jsx(v,{className:"p-4 pb-2",children:e.jsx(p,{className:"h-4 w-28"})}),e.jsx(b,{className:"p-4 pt-2",children:e.jsx("div",{className:"space-y-3",children:[1,2,3,4,5].map(s=>e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(p,{className:"w-2.5 h-2.5 rounded-full"}),e.jsx(p,{className:"h-3 w-24"})]}),e.jsx(p,{className:"h-3 w-16"})]},s))})})]}),e.jsxs(N,{className:"flex flex-col min-h-[250px]",children:[e.jsx(v,{className:"p-4 pb-2",children:e.jsx(p,{className:"h-4 w-28"})}),e.jsx(b,{className:"p-4 pt-0 flex-1",children:e.jsxs("div",{className:"flex w-full h-full items-center",children:[e.jsx("div",{className:"flex-1 flex justify-center",children:e.jsx(p,{className:"h-[180px] w-[180px] rounded-full"})}),e.jsx("div",{className:"w-[140px] shrink-0 pl-2 space-y-2",children:[1,2,3,4].map(s=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(p,{className:"w-2 h-2 rounded-full"}),e.jsx(p,{className:"h-3 w-20"})]},s))})]})})]})]})]})}function nt(){const s=f.useRef(null),{dateRange:t,handleDateRangeChange:a,handleTodayClick:n,handleRefresh:i,isRefreshing:r,lastUpdatedText:o,viewMode:u,selectedProfile:l,profileOptions:c,summary:m,isSummaryLoading:d,trends:g,hourlyData:S,models:C,sessions:h,isTrendsLoading:y,isHourlyLoading:T,isModelsLoading:E,isSessionsLoading:O,handleModelClick:J,handleProfileChange:G,selectedModel:K,popoverPosition:H,handlePopoverClose:ee}=Rs();return e.jsxs("div",{className:"grid h-full min-h-0 grid-rows-[auto_auto_minmax(0,1fr)] gap-4 overflow-y-auto px-4 py-4",children:[e.jsx(Fs,{dateRange:t,onDateRangeChange:a,onTodayClick:n,onRefresh:i,isRefreshing:r,lastUpdatedText:o,viewMode:u,selectedProfile:l,profileOptions:c,onProfileChange:G}),e.jsx(ms,{data:m,isLoading:d}),e.jsx(Hs,{viewMode:u,trends:g,hourlyData:S,models:C,sessions:h,isTrendsLoading:y,isHourlyLoading:T,isModelsLoading:E,isSessionsLoading:O,isSummaryLoading:d,onModelClick:J}),e.jsxs(de,{open:!!K,onOpenChange:z=>!z&&ee(),children:[e.jsx(_e,{asChild:!0,children:e.jsx("div",{ref:s,className:"fixed pointer-events-none",style:{left:H?.x??0,top:H?.y??0,width:1,height:1}})}),e.jsx(ue,{className:"w-80 p-3",side:"top",align:"center",children:K&&e.jsx(hs,{model:K})})]})]})}export{nt as AnalyticsPage,at as AnalyticsSkeleton};
@@ -1 +1 @@
1
- import{j as e}from"./radix-ui-nu4wz29m.js";import{r as n}from"./react-vendor-Bjx91N7w.js";import{by as Ue,bz as ze,_ as R,a as oe,I as B,aJ as M,j as We,k as Xe,l as Ye,m as Ge,n as ye,e as z,bA as qe,bB as Je,bC as Qe,bD as Ze,b6 as he,bE as es,bF as ss,bi as V,bk as H,x as ts}from"./index-CGgavq2X.js";import{C as W}from"./default-ports-1QQSffYX.js";import{be as fe,R as ae,h as rs,y as je,W as as,x as os,aB as ns,b5 as is,T as re,aI as ls,q as cs,bf as ds}from"./icons-DSLG1YsC.js";import{P as xs}from"./proxy-status-widget-2k26d8pS.js";import{R as U}from"./antigravity-responsibility-constants-Bvh4Ybz0.js";import{t as T}from"./notifications-B4_o8bcr.js";import"./tanstack-bhJxV1h8.js";import"./utils-CzKF5WmX.js";import"./form-utils-CuHzLhJZ.js";import"./charts-eIPy2oG6.js";import"./alert-dialog-DjvPgzFs.js";import"./Trans-RG_sMDEu.js";function ms(){const{state:s}=Ue(),t=ze(),[g,o]=n.useState(null),[u,f]=n.useState(null),[p,j]=n.useState(null),[y,C]=n.useState(null),[S,P]=n.useState(null),w=n.useCallback(async()=>{try{t.setProxyLoading(!0),t.setProxyError(null);const d=await R.cliproxyServer.get();t.setProxyConfig(d)}catch(d){t.setProxyError(d.message)}finally{t.setProxyLoading(!1)}},[t]),A=n.useCallback(async d=>{const x=s.proxyConfig;if(!x)return;const h={remote:{...x.remote,...d.remote},fallback:{...x.fallback,...d.fallback},local:{...x.local,...d.local}};t.setProxyConfig(h),t.setProxyTestResult(null);try{t.setProxySaving(!0),t.setProxyError(null);const a=await R.cliproxyServer.update(d);t.setProxyConfig(a),t.setProxySuccess(!0),setTimeout(()=>t.setProxySuccess(!1),1500)}catch(a){t.setProxyConfig(x),t.setProxyError(a.message)}finally{t.setProxySaving(!1)}},[s.proxyConfig,t]),E=n.useCallback(async d=>{const{host:x,port:h,protocol:a,authToken:c}=d;if(!x){t.setProxyError("Host is required");return}try{t.setProxyTesting(!0),t.setProxyError(null),t.setProxyTestResult(null);const k=h?parseInt(h,10):void 0,l=await R.cliproxyServer.test({host:x,port:k||void 0,protocol:a,authToken:c||void 0});t.setProxyTestResult(l)}catch(k){t.setProxyError(k.message)}finally{t.setProxyTesting(!1)}},[t]);return{config:s.proxyConfig,loading:s.proxyLoading,saving:s.proxySaving,error:s.proxyError,success:s.proxySuccess,testResult:s.proxyTestResult,testing:s.proxyTesting,editedHost:g,setEditedHost:o,editedPort:u,setEditedPort:f,editedAuthToken:p,setEditedAuthToken:j,editedManagementKey:y,setEditedManagementKey:C,editedLocalPort:S,setEditedLocalPort:P,fetchConfig:w,saveConfig:A,testConnection:E}}function gs({config:s,saving:t,displayLocalPort:g,setEditedLocalPort:o,onSaveLocalPort:u,onSaveConfig:f}){const{t:p}=oe(),j=s.local;return e.jsxs("div",{className:"space-y-3",children:[e.jsx("h3",{className:"text-base font-medium",children:p("settingsProxy.localProxy")}),e.jsxs("div",{className:"space-y-3 p-4 rounded-lg border bg-muted/30",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("label",{className:"text-sm text-muted-foreground",children:p("settingsProxy.port")}),e.jsx(B,{type:"text",inputMode:"numeric",value:g,onChange:y=>o(y.target.value.replace(/\D/g,"")),onBlur:u,placeholder:`${W}`,className:"font-mono max-w-32",disabled:t})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-sm",children:p("settingsProxy.autoStart")}),e.jsx("p",{className:"text-xs text-muted-foreground",children:p("settingsProxy.localAutoStartDesc")})]}),e.jsx(M,{checked:j.auto_start??!0,onCheckedChange:y=>f({local:{...j,auto_start:y}}),disabled:t})]})]})]})}function us({config:s,saving:t,testing:g,testResult:o,displayHost:u,displayPort:f,displayAuthToken:p,displayManagementKey:j,setEditedHost:y,setEditedPort:C,setEditedAuthToken:S,setEditedManagementKey:P,onSaveHost:w,onSavePort:A,onSaveAuthToken:E,onSaveManagementKey:d,onSaveConfig:x,onTestConnection:h}){const{t:a}=oe(),c=s.remote,k=l=>l==="https"?443:W;return e.jsxs("div",{className:"space-y-4 p-4 rounded-lg border bg-muted/30",children:[e.jsxs("h4",{className:"text-sm font-medium flex items-center gap-2",children:[e.jsx(fe,{className:"w-4 h-4"}),a("settingsProxy.remoteConfigTitle")]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:"text-sm text-muted-foreground",children:a("settingsProxy.host")}),e.jsx(B,{value:u,onChange:l=>y(l.target.value),onBlur:w,placeholder:a("settingsProxy.hostPlaceholder"),className:"font-mono",disabled:t})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs("label",{className:"text-sm text-muted-foreground",children:[a("settingsProxy.port")," ",e.jsxs("span",{className:"text-xs opacity-70",children:["(",a("settingsProxy.defaultPort",{value:k(s.remote.protocol||"http")}),")"]})]}),e.jsx(B,{type:"text",inputMode:"numeric",value:f,onChange:l=>C(l.target.value.replace(/\D/g,"")),onBlur:A,placeholder:a("settingsProxy.portPlaceholder",{value:k(s.remote.protocol||"http")}),className:"font-mono",disabled:t})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:"text-sm text-muted-foreground",children:a("settingsProxy.protocol")}),e.jsxs(We,{value:s.remote.protocol||"http",onValueChange:l=>x({remote:{...c,protocol:l}}),disabled:t,children:[e.jsx(Xe,{children:e.jsx(Ye,{})}),e.jsxs(Ge,{children:[e.jsx(ye,{value:"http",children:a("settingsProxy.http")}),e.jsx(ye,{value:"https",children:a("settingsProxy.https")})]})]})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:"text-sm text-muted-foreground",children:a("settingsProxy.apiKeyOptional")}),e.jsx(B,{type:"password",value:p,onChange:l=>S(l.target.value),onBlur:E,placeholder:a("settingsProxy.apiKeyPlaceholder"),className:"font-mono",disabled:t}),e.jsx("p",{className:"text-xs text-muted-foreground",children:a("settingsProxy.apiKeyDesc")})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:"text-sm text-muted-foreground",children:a("settingsProxy.managementKeyOptional")}),e.jsx(B,{type:"password",value:j,onChange:l=>P(l.target.value),onBlur:d,placeholder:a("settingsProxy.managementKeyPlaceholder"),className:"font-mono",disabled:t}),e.jsx("p",{className:"text-xs text-muted-foreground",children:a("settingsProxy.managementKeyDesc")})]}),e.jsxs("div",{className:"space-y-3 pt-2",children:[e.jsx(z,{onClick:h,disabled:g||!u,variant:"outline",className:"w-full",children:g?e.jsxs(e.Fragment,{children:[e.jsx(ae,{className:"w-4 h-4 mr-2 animate-spin"}),a("settingsProxy.testing")]}):e.jsxs(e.Fragment,{children:[e.jsx(rs,{className:"w-4 h-4 mr-2"}),a("settingsProxy.testConnection")]})}),o&&e.jsx("div",{className:`p-3 rounded-md ${o.reachable?"bg-green-50 border border-green-200 dark:bg-green-900/20 dark:border-green-900/50":"bg-red-50 border border-red-200 dark:bg-red-900/20 dark:border-red-900/50"}`,children:e.jsx("div",{className:"flex items-center gap-2",children:o.reachable?e.jsxs(e.Fragment,{children:[e.jsx(je,{className:"w-4 h-4 text-green-600 dark:text-green-400"}),e.jsx("span",{className:"text-sm font-medium text-green-700 dark:text-green-300",children:a("settingsProxy.connectedLatency",{value:o.latencyMs})})]}):e.jsxs(e.Fragment,{children:[e.jsx(as,{className:"w-4 h-4 text-red-600 dark:text-red-400"}),e.jsx("span",{className:"text-sm font-medium text-red-700 dark:text-red-300",children:o.error||a("settingsProxy.connectionFailed")})]})})})]})]})}const be="ccs_debug_mode";function ps(s){return s.trim().replace(/\s+/g," ").toUpperCase()}function Bs(){const{t:s}=oe(),{config:t,loading:g,saving:o,error:u,success:f,testResult:p,testing:j,editedHost:y,setEditedHost:C,editedPort:S,setEditedPort:P,editedAuthToken:w,setEditedAuthToken:A,editedManagementKey:E,setEditedManagementKey:d,editedLocalPort:x,setEditedLocalPort:h,fetchConfig:a,saveConfig:c,testConnection:k}=ms(),{fetchRawConfig:l}=qe(),[_,Pe]=n.useState(()=>{try{return localStorage.getItem(be)==="true"}catch{return!1}}),[ke,X]=n.useState(!1),[ve,ne]=n.useState(!0),[b,ie]=n.useState(!1),[Ne,L]=n.useState(!1),[le,I]=n.useState(""),K=n.useRef(!1),Y=ps(le)===U,Ce=r=>{Pe(r);try{localStorage.setItem(be,String(r))}catch{}},G=n.useCallback(async()=>{try{ne(!0);const r=await fetch("/api/settings/auth/antigravity-risk");if(!r.ok)throw new Error(s("settingsProxy.failedLoadAgyMode"));const i=await r.json();X(i.antigravityAckBypass===!0)}catch(r){T.error(r instanceof Error?r.message:s("settingsProxy.failedLoadAgyMode")),X(!1)}finally{ne(!1)}},[s]),O=n.useCallback(async r=>{if(!(K.current||b||o))try{K.current=!0,ie(!0);const i=await fetch("/api/settings/auth/antigravity-risk",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({antigravityAckBypass:r})}),$=await i.json();if(!i.ok)throw new Error($.error||s("settingsProxy.failedUpdateAgyMode"));const He=$.antigravityAckBypass===!0,ue=await fetch("/api/settings/auth/antigravity-risk",{cache:"no-store"});if(!ue.ok)throw new Error(s("settingsProxy.failedVerifyAgyMode"));const pe=(await ue.json()).antigravityAckBypass===!0;if(pe!==r)throw new Error(s("settingsProxy.notPersistedAgyMode"));X(pe&&He),L(!1),I(""),T.success(s(r?"settingsProxy.agyModeEnabled":"settingsProxy.agyModeDisabled")),await l()}catch(i){T.error(i instanceof Error?i.message:s("settingsProxy.failedUpdateAgyMode"))}finally{K.current=!1,ie(!1)}},[b,l,o,s]),Se=n.useCallback(r=>{if(!(K.current||b||o)){if(r){L(!0);return}L(!1),I(""),O(!1)}},[b,O,o]),we=n.useCallback(()=>{if(!Y){T.error(s("settingsProxy.typePhraseToContinue",{value:U}));return}O(!0)},[Y,O,s]),[v,q]=n.useState("original"),[Ae,Ee]=n.useState(!1),J=Je(),{data:Te}=Qe(),ce=Te?.running??!1,Be=Ze.map(he).join(", "),de=es.map(he).join(", "),Q=n.useCallback(async()=>{try{const r=await R.cliproxyServer.getBackend();q(r.backend)}catch(r){console.error("[Proxy] Failed to fetch backend:",r)}},[]),Z=n.useCallback(async()=>{try{const i=(await R.cliproxy.list()).variants.some($=>ss($));Ee(i)}catch(r){console.error("[Proxy] Failed to check variants:",r)}},[]),xe=r=>{const i=v;q(r),J.mutate({backend:r},{onError:()=>{q(i)}})};if(n.useEffect(()=>{if(_&&t){const r={...t,remote:{...t.remote,auth_token:t.remote.auth_token?"[REDACTED]":void 0,management_key:t.remote.management_key?"[REDACTED]":void 0}};console.log("[CCS Debug] Debug mode enabled - proxy config:",r)}},[_,t]),n.useEffect(()=>{a(),G(),l(),Q(),Z()},[a,G,l,Q,Z]),g||!t)return e.jsx("div",{className:"flex-1 flex items-center justify-center",children:e.jsxs("div",{className:"flex items-center gap-3 text-muted-foreground",children:[e.jsx(ae,{className:"w-5 h-5 animate-spin"}),e.jsx("span",{children:s("settings.loading")})]})});const m=t.remote.enabled??!1,F=!m&&ce,N=t.remote,D=t.fallback,De=t.remote.host??"",Me=t.remote.port!==void 0?t.remote.port.toString():"",Re=t.remote.auth_token??"",_e=t.remote.management_key??"",Le=(t.local.port??W).toString(),ee=y??De,se=S??Me,te=w??Re,me=E??_e,ge=x??Le,Ie=()=>{const r=y??ee;r!==t.remote.host&&c({remote:{...N,host:r}}),C(null)},Ke=()=>{const r=(S??se).trim();if(r===""){t.remote.port!==void 0&&c({remote:{...N,port:void 0}}),P(null);return}const i=Number(r);if(!Number.isInteger(i)||i<1||i>65535){T.error(s("settingsProxy.invalidPortOrEmpty")),P(null);return}i!==t.remote.port&&c({remote:{...N,port:i}}),P(null)},Oe=()=>{const r=w??te;r!==t.remote.auth_token&&c({remote:{...N,auth_token:r}}),A(null)},Fe=()=>{const r=E??me;r!==t.remote.management_key&&c({remote:{...N,management_key:r||void 0}}),d(null)},$e=()=>{const r=(x??ge).trim(),i=r===""?W:Number(r);if(!Number.isInteger(i)||i<1||i>65535){T.error(s("settingsProxy.invalidLocalPort")),h(null);return}i!==t.local.port&&c({local:{...t.local,port:i}}),h(null)},Ve=()=>{k({host:ee,port:se,protocol:t.remote.protocol||"http",authToken:te})};return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:`absolute left-5 right-5 top-20 z-10 transition-all duration-200 ease-out ${u||f?"opacity-100 translate-y-0":"opacity-0 -translate-y-2 pointer-events-none"}`,children:[u&&e.jsxs(V,{variant:"destructive",className:"py-2 shadow-lg",children:[e.jsx(os,{className:"h-4 w-4"}),e.jsx(H,{children:u})]}),f&&e.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 rounded-md border border-green-200 bg-green-50 text-green-700 shadow-lg dark:border-green-900/50 dark:bg-green-900/90 dark:text-green-300",children:[e.jsx(je,{className:"h-4 w-4 shrink-0"}),e.jsx("span",{className:"text-sm font-medium",children:s("settings.saved")})]})]}),e.jsx(ts,{className:"flex-1",children:e.jsxs("div",{className:"p-5 space-y-6",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:s("settingsProxy.description",{backend:s(v==="plus"?"settingsProxy.backendPlus":"settingsProxy.backend")})}),!m&&e.jsxs("div",{className:"space-y-3",children:[e.jsx("h3",{className:"text-base font-medium",children:s("settingsProxy.instanceStatus")}),e.jsx(xs,{})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx("h3",{className:"text-base font-medium",children:s("settingsProxy.connectionMode")}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("button",{onClick:()=>c({remote:{...N,enabled:!1}}),disabled:o,className:`p-4 rounded-lg border-2 text-left transition-all ${m?"border-border hover:border-muted-foreground/50":"border-primary bg-primary/5"}`,children:[e.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[e.jsx(ns,{className:`w-5 h-5 ${m?"text-muted-foreground":"text-primary"}`}),e.jsx("span",{className:"font-medium",children:s("settingsProxy.local")})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:s("settingsProxy.localDesc",{backend:s(v==="plus"?"settingsProxy.backendPlus":"settingsProxy.backend")})})]}),e.jsxs("button",{onClick:()=>c({remote:{...N,enabled:!0}}),disabled:o,className:`p-4 rounded-lg border-2 text-left transition-all ${m?"border-primary bg-primary/5":"border-border hover:border-muted-foreground/50"}`,children:[e.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[e.jsx(fe,{className:`w-5 h-5 ${m?"text-primary":"text-muted-foreground"}`}),e.jsx("span",{className:"font-medium",children:s("settingsProxy.remote")})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:s("settingsProxy.remoteDesc",{backend:s(v==="plus"?"settingsProxy.backendPlus":"settingsProxy.backend")})})]})]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("h3",{className:"text-base font-medium flex items-center gap-2",children:[e.jsx(is,{className:"w-4 h-4"}),s("settingsProxy.backendBinary")]}),!m&&ce&&e.jsxs(V,{className:"py-2 border-amber-200 bg-amber-50 dark:border-amber-900/50 dark:bg-amber-900/20 [&>svg]:top-2.5",children:[e.jsx(re,{className:"h-4 w-4 text-amber-600"}),e.jsx(H,{className:"text-amber-700 dark:text-amber-400",children:s("settingsProxy.stopProxyToSwitch")})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("button",{onClick:()=>xe("plus"),disabled:J.isPending||F,className:`p-4 rounded-lg border-2 text-left transition-all ${v==="plus"?"border-primary bg-primary/5":"border-border hover:border-muted-foreground/50"} ${F?"opacity-60 cursor-not-allowed":""}`,children:[e.jsx("div",{className:"flex items-center gap-3 mb-2",children:e.jsx("span",{className:"font-medium",children:s("settingsProxy.backendPlusApi")})}),e.jsx("p",{className:"text-xs text-muted-foreground",children:s("settingsProxy.plusDesc")}),e.jsx("p",{className:"mt-2 text-[11px] leading-relaxed text-muted-foreground",children:de})]}),e.jsxs("button",{onClick:()=>xe("original"),disabled:J.isPending||F,className:`p-4 rounded-lg border-2 text-left transition-all ${v==="original"?"border-primary bg-primary/5":"border-border hover:border-muted-foreground/50"} ${F?"opacity-60 cursor-not-allowed":""}`,children:[e.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[e.jsx("span",{className:"font-medium",children:s("settingsProxy.backendApi")}),e.jsx("span",{className:"text-xs px-1.5 py-0.5 rounded bg-green-100 text-green-700 dark:bg-green-900/50 dark:text-green-400",children:s("settingsProxy.default")})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:s("settingsProxy.originalDesc")}),e.jsx("p",{className:"mt-2 text-[11px] leading-relaxed text-muted-foreground",children:Be})]})]}),v==="plus"&&e.jsxs(V,{className:"py-2 border-amber-200 bg-amber-50 dark:border-amber-900/50 dark:bg-amber-900/20 [&>svg]:top-2.5",children:[e.jsx(re,{className:"h-4 w-4 text-amber-600"}),e.jsx(H,{className:"text-amber-700 dark:text-amber-400",children:s("settingsProxy.plusFallbackNotice")})]}),v==="original"&&Ae&&e.jsxs(V,{variant:"destructive",className:"py-2",children:[e.jsx(re,{className:"h-4 w-4"}),e.jsx(H,{children:s("settingsProxy.variantsIncompatible",{providers:de})})]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("h3",{className:"text-base font-medium flex items-center gap-2",children:[e.jsx(ls,{className:"w-4 h-4 text-amber-700 dark:text-amber-300"}),s("settingsProxy.safety")]}),e.jsxs("div",{className:"space-y-3 rounded-lg border border-amber-400/35 bg-amber-50/70 p-4 dark:border-amber-800/60 dark:bg-amber-950/25",children:[e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"font-medium text-sm",children:s("settingsProxy.agyModeTitle")}),e.jsx("p",{className:"text-xs text-muted-foreground",children:s("settingsProxy.agyModeDesc")})]}),e.jsx(M,{"aria-labelledby":"agy-power-user-mode-label","aria-describedby":"agy-power-user-mode-description",checked:ke,disabled:ve||b||o,onCheckedChange:Se})]}),e.jsx("p",{id:"agy-power-user-mode-description",className:"text-xs text-amber-800/90 dark:text-amber-200/90",children:s("settingsProxy.agyWarning")}),Ne&&e.jsxs("div",{className:"space-y-3 rounded-lg border border-rose-500/40 bg-rose-500/[0.08] p-3.5",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("p",{className:"text-xs font-semibold tracking-wide text-rose-900 dark:text-rose-200",children:s("settingsProxy.finalConfirm")}),e.jsx("p",{className:"text-xs leading-relaxed text-rose-800/95 dark:text-rose-200/90",children:s("settingsProxy.finalConfirmDesc")})]}),e.jsxs("div",{className:"grid gap-2 md:grid-cols-2",children:[e.jsxs("div",{className:"rounded-md border border-rose-400/30 bg-rose-500/10 p-2.5",children:[e.jsx("p",{className:"text-[11px] font-semibold uppercase tracking-wide text-rose-900 dark:text-rose-200",children:s("settingsProxy.step1")}),e.jsxs("a",{href:"https://github.com/kaitranntt/ccs/issues/509",target:"_blank",rel:"noreferrer",className:"mt-1 inline-flex items-center gap-1.5 text-xs font-medium text-rose-800 underline decoration-rose-500/60 underline-offset-2 transition-colors hover:text-rose-700 dark:text-rose-200",children:[s("settingsProxy.readIssue"),e.jsx(cs,{className:"h-3.5 w-3.5"})]})]}),e.jsxs("div",{className:"rounded-md border border-rose-400/30 bg-rose-500/10 p-2.5",children:[e.jsx("p",{className:"text-[11px] font-semibold uppercase tracking-wide text-rose-900 dark:text-rose-200",children:s("settingsProxy.step2")}),e.jsxs("p",{className:"mt-1 text-xs text-rose-800/95 dark:text-rose-200/90",children:[s("settingsProxy.typePrefix")," ",e.jsx("code",{className:"rounded bg-background/80 px-1 py-0.5 font-mono",children:U})," ",s("settingsProxy.typeSuffix")]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(B,{value:le,onChange:r=>I(r.target.value),placeholder:U,disabled:b||o,className:"font-mono text-xs","aria-label":s("settingsProxy.typePhraseAria")}),e.jsx("p",{className:"text-[11px] text-rose-800/90 dark:text-rose-200/80",children:s("settingsProxy.exactPhrase")})]}),e.jsxs("div",{className:"flex items-center justify-end gap-2",children:[e.jsx(z,{variant:"outline",size:"sm",onClick:()=>{L(!1),I("")},disabled:b||o,children:s("settingsBackups.cancel")}),e.jsx(z,{size:"sm",variant:"destructive",onClick:we,disabled:!Y||b||o,children:s("settingsProxy.enableAgyMode")})]})]}),e.jsx("span",{id:"agy-power-user-mode-label",className:"sr-only",children:s("settingsProxy.toggleAgyMode")})]})]}),m&&e.jsx(us,{config:t,saving:o,testing:j,testResult:p,displayHost:ee,displayPort:se,displayAuthToken:te,displayManagementKey:me,setEditedHost:C,setEditedPort:P,setEditedAuthToken:A,setEditedManagementKey:d,onSaveHost:Ie,onSavePort:Ke,onSaveAuthToken:Oe,onSaveManagementKey:Fe,onSaveConfig:c,onTestConnection:Ve}),e.jsxs("div",{className:"space-y-3",children:[e.jsx("h3",{className:"text-base font-medium",children:s("settingsProxy.fallbackSettings")}),e.jsxs("div",{className:"space-y-3 p-4 rounded-lg border bg-muted/30",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-sm",children:s("settingsProxy.enableFallback")}),e.jsx("p",{className:"text-xs text-muted-foreground",children:s("settingsProxy.enableFallbackDesc")})]}),e.jsx(M,{checked:D.enabled??!0,onCheckedChange:r=>c({fallback:{...D,enabled:r}}),disabled:o||!m})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-sm",children:s("settingsProxy.autoStartLocal")}),e.jsx("p",{className:"text-xs text-muted-foreground",children:s("settingsProxy.autoStartLocalDesc")})]}),e.jsx(M,{checked:D.auto_start??!1,onCheckedChange:r=>c({fallback:{...D,auto_start:r}}),disabled:o||!m||!D.enabled})]})]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("h3",{className:"text-base font-medium flex items-center gap-2",children:[e.jsx(ds,{className:"w-4 h-4"}),s("settingsProxy.advanced")]}),e.jsxs("div",{className:"space-y-3 p-4 rounded-lg border bg-muted/30",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-sm",children:s("settingsProxy.debugMode")}),e.jsx("p",{className:"text-xs text-muted-foreground",children:s("settingsProxy.debugModeDesc")})]}),e.jsx(M,{checked:_,onCheckedChange:Ce,disabled:o})]}),_&&e.jsx("p",{className:"text-xs text-amber-600 dark:text-amber-400 pl-0.5",children:s("settingsProxy.debugModeEnabled")})]})]}),!m&&e.jsx(gs,{config:t,saving:o,displayLocalPort:ge,setEditedLocalPort:h,onSaveLocalPort:$e,onSaveConfig:c})]})}),e.jsx("div",{className:"p-4 border-t bg-background",children:e.jsxs(z,{variant:"outline",size:"sm",onClick:()=>{a(),G(),l(),Q(),Z()},disabled:g||o||b,className:"w-full",children:[e.jsx(ae,{className:`w-4 h-4 mr-2 ${g?"animate-spin":""}`}),s("settings.refresh")]})})]})}export{Bs as default};
1
+ import{j as e}from"./radix-ui-nu4wz29m.js";import{r as n}from"./react-vendor-Bjx91N7w.js";import{by as Ue,bz as ze,_ as R,a as oe,I as B,aJ as M,j as We,k as Xe,l as Ye,m as Ge,n as ye,e as z,bA as qe,bB as Je,bC as Qe,bD as Ze,b6 as he,bE as es,bF as ss,bi as V,bk as H,x as ts}from"./index-B2JEyN3d.js";import{C as W}from"./default-ports-1QQSffYX.js";import{be as fe,R as ae,h as rs,y as je,W as as,x as os,aB as ns,b5 as is,T as re,aI as ls,q as cs,bf as ds}from"./icons-DSLG1YsC.js";import{P as xs}from"./proxy-status-widget-DPz4nCzR.js";import{R as U}from"./antigravity-responsibility-constants-Bvh4Ybz0.js";import{t as T}from"./notifications-B4_o8bcr.js";import"./tanstack-bhJxV1h8.js";import"./utils-CzKF5WmX.js";import"./form-utils-CuHzLhJZ.js";import"./charts-eIPy2oG6.js";import"./alert-dialog-6SiedqmE.js";import"./Trans-GYzYLs2D.js";function ms(){const{state:s}=Ue(),t=ze(),[g,o]=n.useState(null),[u,f]=n.useState(null),[p,j]=n.useState(null),[y,C]=n.useState(null),[S,P]=n.useState(null),w=n.useCallback(async()=>{try{t.setProxyLoading(!0),t.setProxyError(null);const d=await R.cliproxyServer.get();t.setProxyConfig(d)}catch(d){t.setProxyError(d.message)}finally{t.setProxyLoading(!1)}},[t]),A=n.useCallback(async d=>{const x=s.proxyConfig;if(!x)return;const h={remote:{...x.remote,...d.remote},fallback:{...x.fallback,...d.fallback},local:{...x.local,...d.local}};t.setProxyConfig(h),t.setProxyTestResult(null);try{t.setProxySaving(!0),t.setProxyError(null);const a=await R.cliproxyServer.update(d);t.setProxyConfig(a),t.setProxySuccess(!0),setTimeout(()=>t.setProxySuccess(!1),1500)}catch(a){t.setProxyConfig(x),t.setProxyError(a.message)}finally{t.setProxySaving(!1)}},[s.proxyConfig,t]),E=n.useCallback(async d=>{const{host:x,port:h,protocol:a,authToken:c}=d;if(!x){t.setProxyError("Host is required");return}try{t.setProxyTesting(!0),t.setProxyError(null),t.setProxyTestResult(null);const k=h?parseInt(h,10):void 0,l=await R.cliproxyServer.test({host:x,port:k||void 0,protocol:a,authToken:c||void 0});t.setProxyTestResult(l)}catch(k){t.setProxyError(k.message)}finally{t.setProxyTesting(!1)}},[t]);return{config:s.proxyConfig,loading:s.proxyLoading,saving:s.proxySaving,error:s.proxyError,success:s.proxySuccess,testResult:s.proxyTestResult,testing:s.proxyTesting,editedHost:g,setEditedHost:o,editedPort:u,setEditedPort:f,editedAuthToken:p,setEditedAuthToken:j,editedManagementKey:y,setEditedManagementKey:C,editedLocalPort:S,setEditedLocalPort:P,fetchConfig:w,saveConfig:A,testConnection:E}}function gs({config:s,saving:t,displayLocalPort:g,setEditedLocalPort:o,onSaveLocalPort:u,onSaveConfig:f}){const{t:p}=oe(),j=s.local;return e.jsxs("div",{className:"space-y-3",children:[e.jsx("h3",{className:"text-base font-medium",children:p("settingsProxy.localProxy")}),e.jsxs("div",{className:"space-y-3 p-4 rounded-lg border bg-muted/30",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("label",{className:"text-sm text-muted-foreground",children:p("settingsProxy.port")}),e.jsx(B,{type:"text",inputMode:"numeric",value:g,onChange:y=>o(y.target.value.replace(/\D/g,"")),onBlur:u,placeholder:`${W}`,className:"font-mono max-w-32",disabled:t})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-sm",children:p("settingsProxy.autoStart")}),e.jsx("p",{className:"text-xs text-muted-foreground",children:p("settingsProxy.localAutoStartDesc")})]}),e.jsx(M,{checked:j.auto_start??!0,onCheckedChange:y=>f({local:{...j,auto_start:y}}),disabled:t})]})]})]})}function us({config:s,saving:t,testing:g,testResult:o,displayHost:u,displayPort:f,displayAuthToken:p,displayManagementKey:j,setEditedHost:y,setEditedPort:C,setEditedAuthToken:S,setEditedManagementKey:P,onSaveHost:w,onSavePort:A,onSaveAuthToken:E,onSaveManagementKey:d,onSaveConfig:x,onTestConnection:h}){const{t:a}=oe(),c=s.remote,k=l=>l==="https"?443:W;return e.jsxs("div",{className:"space-y-4 p-4 rounded-lg border bg-muted/30",children:[e.jsxs("h4",{className:"text-sm font-medium flex items-center gap-2",children:[e.jsx(fe,{className:"w-4 h-4"}),a("settingsProxy.remoteConfigTitle")]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:"text-sm text-muted-foreground",children:a("settingsProxy.host")}),e.jsx(B,{value:u,onChange:l=>y(l.target.value),onBlur:w,placeholder:a("settingsProxy.hostPlaceholder"),className:"font-mono",disabled:t})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs("label",{className:"text-sm text-muted-foreground",children:[a("settingsProxy.port")," ",e.jsxs("span",{className:"text-xs opacity-70",children:["(",a("settingsProxy.defaultPort",{value:k(s.remote.protocol||"http")}),")"]})]}),e.jsx(B,{type:"text",inputMode:"numeric",value:f,onChange:l=>C(l.target.value.replace(/\D/g,"")),onBlur:A,placeholder:a("settingsProxy.portPlaceholder",{value:k(s.remote.protocol||"http")}),className:"font-mono",disabled:t})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:"text-sm text-muted-foreground",children:a("settingsProxy.protocol")}),e.jsxs(We,{value:s.remote.protocol||"http",onValueChange:l=>x({remote:{...c,protocol:l}}),disabled:t,children:[e.jsx(Xe,{children:e.jsx(Ye,{})}),e.jsxs(Ge,{children:[e.jsx(ye,{value:"http",children:a("settingsProxy.http")}),e.jsx(ye,{value:"https",children:a("settingsProxy.https")})]})]})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:"text-sm text-muted-foreground",children:a("settingsProxy.apiKeyOptional")}),e.jsx(B,{type:"password",value:p,onChange:l=>S(l.target.value),onBlur:E,placeholder:a("settingsProxy.apiKeyPlaceholder"),className:"font-mono",disabled:t}),e.jsx("p",{className:"text-xs text-muted-foreground",children:a("settingsProxy.apiKeyDesc")})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:"text-sm text-muted-foreground",children:a("settingsProxy.managementKeyOptional")}),e.jsx(B,{type:"password",value:j,onChange:l=>P(l.target.value),onBlur:d,placeholder:a("settingsProxy.managementKeyPlaceholder"),className:"font-mono",disabled:t}),e.jsx("p",{className:"text-xs text-muted-foreground",children:a("settingsProxy.managementKeyDesc")})]}),e.jsxs("div",{className:"space-y-3 pt-2",children:[e.jsx(z,{onClick:h,disabled:g||!u,variant:"outline",className:"w-full",children:g?e.jsxs(e.Fragment,{children:[e.jsx(ae,{className:"w-4 h-4 mr-2 animate-spin"}),a("settingsProxy.testing")]}):e.jsxs(e.Fragment,{children:[e.jsx(rs,{className:"w-4 h-4 mr-2"}),a("settingsProxy.testConnection")]})}),o&&e.jsx("div",{className:`p-3 rounded-md ${o.reachable?"bg-green-50 border border-green-200 dark:bg-green-900/20 dark:border-green-900/50":"bg-red-50 border border-red-200 dark:bg-red-900/20 dark:border-red-900/50"}`,children:e.jsx("div",{className:"flex items-center gap-2",children:o.reachable?e.jsxs(e.Fragment,{children:[e.jsx(je,{className:"w-4 h-4 text-green-600 dark:text-green-400"}),e.jsx("span",{className:"text-sm font-medium text-green-700 dark:text-green-300",children:a("settingsProxy.connectedLatency",{value:o.latencyMs})})]}):e.jsxs(e.Fragment,{children:[e.jsx(as,{className:"w-4 h-4 text-red-600 dark:text-red-400"}),e.jsx("span",{className:"text-sm font-medium text-red-700 dark:text-red-300",children:o.error||a("settingsProxy.connectionFailed")})]})})})]})]})}const be="ccs_debug_mode";function ps(s){return s.trim().replace(/\s+/g," ").toUpperCase()}function Bs(){const{t:s}=oe(),{config:t,loading:g,saving:o,error:u,success:f,testResult:p,testing:j,editedHost:y,setEditedHost:C,editedPort:S,setEditedPort:P,editedAuthToken:w,setEditedAuthToken:A,editedManagementKey:E,setEditedManagementKey:d,editedLocalPort:x,setEditedLocalPort:h,fetchConfig:a,saveConfig:c,testConnection:k}=ms(),{fetchRawConfig:l}=qe(),[_,Pe]=n.useState(()=>{try{return localStorage.getItem(be)==="true"}catch{return!1}}),[ke,X]=n.useState(!1),[ve,ne]=n.useState(!0),[b,ie]=n.useState(!1),[Ne,L]=n.useState(!1),[le,I]=n.useState(""),K=n.useRef(!1),Y=ps(le)===U,Ce=r=>{Pe(r);try{localStorage.setItem(be,String(r))}catch{}},G=n.useCallback(async()=>{try{ne(!0);const r=await fetch("/api/settings/auth/antigravity-risk");if(!r.ok)throw new Error(s("settingsProxy.failedLoadAgyMode"));const i=await r.json();X(i.antigravityAckBypass===!0)}catch(r){T.error(r instanceof Error?r.message:s("settingsProxy.failedLoadAgyMode")),X(!1)}finally{ne(!1)}},[s]),O=n.useCallback(async r=>{if(!(K.current||b||o))try{K.current=!0,ie(!0);const i=await fetch("/api/settings/auth/antigravity-risk",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({antigravityAckBypass:r})}),$=await i.json();if(!i.ok)throw new Error($.error||s("settingsProxy.failedUpdateAgyMode"));const He=$.antigravityAckBypass===!0,ue=await fetch("/api/settings/auth/antigravity-risk",{cache:"no-store"});if(!ue.ok)throw new Error(s("settingsProxy.failedVerifyAgyMode"));const pe=(await ue.json()).antigravityAckBypass===!0;if(pe!==r)throw new Error(s("settingsProxy.notPersistedAgyMode"));X(pe&&He),L(!1),I(""),T.success(s(r?"settingsProxy.agyModeEnabled":"settingsProxy.agyModeDisabled")),await l()}catch(i){T.error(i instanceof Error?i.message:s("settingsProxy.failedUpdateAgyMode"))}finally{K.current=!1,ie(!1)}},[b,l,o,s]),Se=n.useCallback(r=>{if(!(K.current||b||o)){if(r){L(!0);return}L(!1),I(""),O(!1)}},[b,O,o]),we=n.useCallback(()=>{if(!Y){T.error(s("settingsProxy.typePhraseToContinue",{value:U}));return}O(!0)},[Y,O,s]),[v,q]=n.useState("original"),[Ae,Ee]=n.useState(!1),J=Je(),{data:Te}=Qe(),ce=Te?.running??!1,Be=Ze.map(he).join(", "),de=es.map(he).join(", "),Q=n.useCallback(async()=>{try{const r=await R.cliproxyServer.getBackend();q(r.backend)}catch(r){console.error("[Proxy] Failed to fetch backend:",r)}},[]),Z=n.useCallback(async()=>{try{const i=(await R.cliproxy.list()).variants.some($=>ss($));Ee(i)}catch(r){console.error("[Proxy] Failed to check variants:",r)}},[]),xe=r=>{const i=v;q(r),J.mutate({backend:r},{onError:()=>{q(i)}})};if(n.useEffect(()=>{if(_&&t){const r={...t,remote:{...t.remote,auth_token:t.remote.auth_token?"[REDACTED]":void 0,management_key:t.remote.management_key?"[REDACTED]":void 0}};console.log("[CCS Debug] Debug mode enabled - proxy config:",r)}},[_,t]),n.useEffect(()=>{a(),G(),l(),Q(),Z()},[a,G,l,Q,Z]),g||!t)return e.jsx("div",{className:"flex-1 flex items-center justify-center",children:e.jsxs("div",{className:"flex items-center gap-3 text-muted-foreground",children:[e.jsx(ae,{className:"w-5 h-5 animate-spin"}),e.jsx("span",{children:s("settings.loading")})]})});const m=t.remote.enabled??!1,F=!m&&ce,N=t.remote,D=t.fallback,De=t.remote.host??"",Me=t.remote.port!==void 0?t.remote.port.toString():"",Re=t.remote.auth_token??"",_e=t.remote.management_key??"",Le=(t.local.port??W).toString(),ee=y??De,se=S??Me,te=w??Re,me=E??_e,ge=x??Le,Ie=()=>{const r=y??ee;r!==t.remote.host&&c({remote:{...N,host:r}}),C(null)},Ke=()=>{const r=(S??se).trim();if(r===""){t.remote.port!==void 0&&c({remote:{...N,port:void 0}}),P(null);return}const i=Number(r);if(!Number.isInteger(i)||i<1||i>65535){T.error(s("settingsProxy.invalidPortOrEmpty")),P(null);return}i!==t.remote.port&&c({remote:{...N,port:i}}),P(null)},Oe=()=>{const r=w??te;r!==t.remote.auth_token&&c({remote:{...N,auth_token:r}}),A(null)},Fe=()=>{const r=E??me;r!==t.remote.management_key&&c({remote:{...N,management_key:r||void 0}}),d(null)},$e=()=>{const r=(x??ge).trim(),i=r===""?W:Number(r);if(!Number.isInteger(i)||i<1||i>65535){T.error(s("settingsProxy.invalidLocalPort")),h(null);return}i!==t.local.port&&c({local:{...t.local,port:i}}),h(null)},Ve=()=>{k({host:ee,port:se,protocol:t.remote.protocol||"http",authToken:te})};return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:`absolute left-5 right-5 top-20 z-10 transition-all duration-200 ease-out ${u||f?"opacity-100 translate-y-0":"opacity-0 -translate-y-2 pointer-events-none"}`,children:[u&&e.jsxs(V,{variant:"destructive",className:"py-2 shadow-lg",children:[e.jsx(os,{className:"h-4 w-4"}),e.jsx(H,{children:u})]}),f&&e.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 rounded-md border border-green-200 bg-green-50 text-green-700 shadow-lg dark:border-green-900/50 dark:bg-green-900/90 dark:text-green-300",children:[e.jsx(je,{className:"h-4 w-4 shrink-0"}),e.jsx("span",{className:"text-sm font-medium",children:s("settings.saved")})]})]}),e.jsx(ts,{className:"flex-1",children:e.jsxs("div",{className:"p-5 space-y-6",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:s("settingsProxy.description",{backend:s(v==="plus"?"settingsProxy.backendPlus":"settingsProxy.backend")})}),!m&&e.jsxs("div",{className:"space-y-3",children:[e.jsx("h3",{className:"text-base font-medium",children:s("settingsProxy.instanceStatus")}),e.jsx(xs,{})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx("h3",{className:"text-base font-medium",children:s("settingsProxy.connectionMode")}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("button",{onClick:()=>c({remote:{...N,enabled:!1}}),disabled:o,className:`p-4 rounded-lg border-2 text-left transition-all ${m?"border-border hover:border-muted-foreground/50":"border-primary bg-primary/5"}`,children:[e.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[e.jsx(ns,{className:`w-5 h-5 ${m?"text-muted-foreground":"text-primary"}`}),e.jsx("span",{className:"font-medium",children:s("settingsProxy.local")})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:s("settingsProxy.localDesc",{backend:s(v==="plus"?"settingsProxy.backendPlus":"settingsProxy.backend")})})]}),e.jsxs("button",{onClick:()=>c({remote:{...N,enabled:!0}}),disabled:o,className:`p-4 rounded-lg border-2 text-left transition-all ${m?"border-primary bg-primary/5":"border-border hover:border-muted-foreground/50"}`,children:[e.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[e.jsx(fe,{className:`w-5 h-5 ${m?"text-primary":"text-muted-foreground"}`}),e.jsx("span",{className:"font-medium",children:s("settingsProxy.remote")})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:s("settingsProxy.remoteDesc",{backend:s(v==="plus"?"settingsProxy.backendPlus":"settingsProxy.backend")})})]})]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("h3",{className:"text-base font-medium flex items-center gap-2",children:[e.jsx(is,{className:"w-4 h-4"}),s("settingsProxy.backendBinary")]}),!m&&ce&&e.jsxs(V,{className:"py-2 border-amber-200 bg-amber-50 dark:border-amber-900/50 dark:bg-amber-900/20 [&>svg]:top-2.5",children:[e.jsx(re,{className:"h-4 w-4 text-amber-600"}),e.jsx(H,{className:"text-amber-700 dark:text-amber-400",children:s("settingsProxy.stopProxyToSwitch")})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("button",{onClick:()=>xe("plus"),disabled:J.isPending||F,className:`p-4 rounded-lg border-2 text-left transition-all ${v==="plus"?"border-primary bg-primary/5":"border-border hover:border-muted-foreground/50"} ${F?"opacity-60 cursor-not-allowed":""}`,children:[e.jsx("div",{className:"flex items-center gap-3 mb-2",children:e.jsx("span",{className:"font-medium",children:s("settingsProxy.backendPlusApi")})}),e.jsx("p",{className:"text-xs text-muted-foreground",children:s("settingsProxy.plusDesc")}),e.jsx("p",{className:"mt-2 text-[11px] leading-relaxed text-muted-foreground",children:de})]}),e.jsxs("button",{onClick:()=>xe("original"),disabled:J.isPending||F,className:`p-4 rounded-lg border-2 text-left transition-all ${v==="original"?"border-primary bg-primary/5":"border-border hover:border-muted-foreground/50"} ${F?"opacity-60 cursor-not-allowed":""}`,children:[e.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[e.jsx("span",{className:"font-medium",children:s("settingsProxy.backendApi")}),e.jsx("span",{className:"text-xs px-1.5 py-0.5 rounded bg-green-100 text-green-700 dark:bg-green-900/50 dark:text-green-400",children:s("settingsProxy.default")})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:s("settingsProxy.originalDesc")}),e.jsx("p",{className:"mt-2 text-[11px] leading-relaxed text-muted-foreground",children:Be})]})]}),v==="plus"&&e.jsxs(V,{className:"py-2 border-amber-200 bg-amber-50 dark:border-amber-900/50 dark:bg-amber-900/20 [&>svg]:top-2.5",children:[e.jsx(re,{className:"h-4 w-4 text-amber-600"}),e.jsx(H,{className:"text-amber-700 dark:text-amber-400",children:s("settingsProxy.plusFallbackNotice")})]}),v==="original"&&Ae&&e.jsxs(V,{variant:"destructive",className:"py-2",children:[e.jsx(re,{className:"h-4 w-4"}),e.jsx(H,{children:s("settingsProxy.variantsIncompatible",{providers:de})})]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("h3",{className:"text-base font-medium flex items-center gap-2",children:[e.jsx(ls,{className:"w-4 h-4 text-amber-700 dark:text-amber-300"}),s("settingsProxy.safety")]}),e.jsxs("div",{className:"space-y-3 rounded-lg border border-amber-400/35 bg-amber-50/70 p-4 dark:border-amber-800/60 dark:bg-amber-950/25",children:[e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"font-medium text-sm",children:s("settingsProxy.agyModeTitle")}),e.jsx("p",{className:"text-xs text-muted-foreground",children:s("settingsProxy.agyModeDesc")})]}),e.jsx(M,{"aria-labelledby":"agy-power-user-mode-label","aria-describedby":"agy-power-user-mode-description",checked:ke,disabled:ve||b||o,onCheckedChange:Se})]}),e.jsx("p",{id:"agy-power-user-mode-description",className:"text-xs text-amber-800/90 dark:text-amber-200/90",children:s("settingsProxy.agyWarning")}),Ne&&e.jsxs("div",{className:"space-y-3 rounded-lg border border-rose-500/40 bg-rose-500/[0.08] p-3.5",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("p",{className:"text-xs font-semibold tracking-wide text-rose-900 dark:text-rose-200",children:s("settingsProxy.finalConfirm")}),e.jsx("p",{className:"text-xs leading-relaxed text-rose-800/95 dark:text-rose-200/90",children:s("settingsProxy.finalConfirmDesc")})]}),e.jsxs("div",{className:"grid gap-2 md:grid-cols-2",children:[e.jsxs("div",{className:"rounded-md border border-rose-400/30 bg-rose-500/10 p-2.5",children:[e.jsx("p",{className:"text-[11px] font-semibold uppercase tracking-wide text-rose-900 dark:text-rose-200",children:s("settingsProxy.step1")}),e.jsxs("a",{href:"https://github.com/kaitranntt/ccs/issues/509",target:"_blank",rel:"noreferrer",className:"mt-1 inline-flex items-center gap-1.5 text-xs font-medium text-rose-800 underline decoration-rose-500/60 underline-offset-2 transition-colors hover:text-rose-700 dark:text-rose-200",children:[s("settingsProxy.readIssue"),e.jsx(cs,{className:"h-3.5 w-3.5"})]})]}),e.jsxs("div",{className:"rounded-md border border-rose-400/30 bg-rose-500/10 p-2.5",children:[e.jsx("p",{className:"text-[11px] font-semibold uppercase tracking-wide text-rose-900 dark:text-rose-200",children:s("settingsProxy.step2")}),e.jsxs("p",{className:"mt-1 text-xs text-rose-800/95 dark:text-rose-200/90",children:[s("settingsProxy.typePrefix")," ",e.jsx("code",{className:"rounded bg-background/80 px-1 py-0.5 font-mono",children:U})," ",s("settingsProxy.typeSuffix")]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(B,{value:le,onChange:r=>I(r.target.value),placeholder:U,disabled:b||o,className:"font-mono text-xs","aria-label":s("settingsProxy.typePhraseAria")}),e.jsx("p",{className:"text-[11px] text-rose-800/90 dark:text-rose-200/80",children:s("settingsProxy.exactPhrase")})]}),e.jsxs("div",{className:"flex items-center justify-end gap-2",children:[e.jsx(z,{variant:"outline",size:"sm",onClick:()=>{L(!1),I("")},disabled:b||o,children:s("settingsBackups.cancel")}),e.jsx(z,{size:"sm",variant:"destructive",onClick:we,disabled:!Y||b||o,children:s("settingsProxy.enableAgyMode")})]})]}),e.jsx("span",{id:"agy-power-user-mode-label",className:"sr-only",children:s("settingsProxy.toggleAgyMode")})]})]}),m&&e.jsx(us,{config:t,saving:o,testing:j,testResult:p,displayHost:ee,displayPort:se,displayAuthToken:te,displayManagementKey:me,setEditedHost:C,setEditedPort:P,setEditedAuthToken:A,setEditedManagementKey:d,onSaveHost:Ie,onSavePort:Ke,onSaveAuthToken:Oe,onSaveManagementKey:Fe,onSaveConfig:c,onTestConnection:Ve}),e.jsxs("div",{className:"space-y-3",children:[e.jsx("h3",{className:"text-base font-medium",children:s("settingsProxy.fallbackSettings")}),e.jsxs("div",{className:"space-y-3 p-4 rounded-lg border bg-muted/30",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-sm",children:s("settingsProxy.enableFallback")}),e.jsx("p",{className:"text-xs text-muted-foreground",children:s("settingsProxy.enableFallbackDesc")})]}),e.jsx(M,{checked:D.enabled??!0,onCheckedChange:r=>c({fallback:{...D,enabled:r}}),disabled:o||!m})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-sm",children:s("settingsProxy.autoStartLocal")}),e.jsx("p",{className:"text-xs text-muted-foreground",children:s("settingsProxy.autoStartLocalDesc")})]}),e.jsx(M,{checked:D.auto_start??!1,onCheckedChange:r=>c({fallback:{...D,auto_start:r}}),disabled:o||!m||!D.enabled})]})]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("h3",{className:"text-base font-medium flex items-center gap-2",children:[e.jsx(ds,{className:"w-4 h-4"}),s("settingsProxy.advanced")]}),e.jsxs("div",{className:"space-y-3 p-4 rounded-lg border bg-muted/30",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-sm",children:s("settingsProxy.debugMode")}),e.jsx("p",{className:"text-xs text-muted-foreground",children:s("settingsProxy.debugModeDesc")})]}),e.jsx(M,{checked:_,onCheckedChange:Ce,disabled:o})]}),_&&e.jsx("p",{className:"text-xs text-amber-600 dark:text-amber-400 pl-0.5",children:s("settingsProxy.debugModeEnabled")})]})]}),!m&&e.jsx(gs,{config:t,saving:o,displayLocalPort:ge,setEditedLocalPort:h,onSaveLocalPort:$e,onSaveConfig:c})]})}),e.jsx("div",{className:"p-4 border-t bg-background",children:e.jsxs(z,{variant:"outline",size:"sm",onClick:()=>{a(),G(),l(),Q(),Z()},disabled:g||o||b,className:"w-full",children:[e.jsx(ae,{className:`w-4 h-4 mr-2 ${g?"animate-spin":""}`}),s("settings.refresh")]})})]})}export{Bs as default};