@kaitranntt/ccs 7.71.0-dev.1 → 7.71.0-dev.10

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 (261) hide show
  1. package/README.md +34 -0
  2. package/config/base-codebuddy.settings.json +10 -0
  3. package/config/base-cursor.settings.json +10 -0
  4. package/config/base-gitlab.settings.json +10 -0
  5. package/config/base-kilo.settings.json +10 -0
  6. package/dist/auth/profile-detector.d.ts +2 -3
  7. package/dist/auth/profile-detector.d.ts.map +1 -1
  8. package/dist/auth/profile-detector.js +19 -19
  9. package/dist/auth/profile-detector.js.map +1 -1
  10. package/dist/ccs.js +66 -4
  11. package/dist/ccs.js.map +1 -1
  12. package/dist/cliproxy/accounts/email-account-identity.d.ts.map +1 -1
  13. package/dist/cliproxy/accounts/email-account-identity.js +22 -2
  14. package/dist/cliproxy/accounts/email-account-identity.js.map +1 -1
  15. package/dist/cliproxy/auth/auth-types.d.ts +10 -0
  16. package/dist/cliproxy/auth/auth-types.d.ts.map +1 -1
  17. package/dist/cliproxy/auth/auth-types.js +32 -0
  18. package/dist/cliproxy/auth/auth-types.js.map +1 -1
  19. package/dist/cliproxy/auth/gitlab-pat-response.d.ts +9 -0
  20. package/dist/cliproxy/auth/gitlab-pat-response.d.ts.map +1 -0
  21. package/dist/cliproxy/auth/gitlab-pat-response.js +64 -0
  22. package/dist/cliproxy/auth/gitlab-pat-response.js.map +1 -0
  23. package/dist/cliproxy/auth/kiro-import.js +1 -1
  24. package/dist/cliproxy/auth/kiro-import.js.map +1 -1
  25. package/dist/cliproxy/auth/oauth-handler.d.ts +3 -0
  26. package/dist/cliproxy/auth/oauth-handler.d.ts.map +1 -1
  27. package/dist/cliproxy/auth/oauth-handler.js +120 -4
  28. package/dist/cliproxy/auth/oauth-handler.js.map +1 -1
  29. package/dist/cliproxy/binary/lifecycle.d.ts.map +1 -1
  30. package/dist/cliproxy/binary/lifecycle.js +12 -1
  31. package/dist/cliproxy/binary/lifecycle.js.map +1 -1
  32. package/dist/cliproxy/binary-manager.d.ts +5 -1
  33. package/dist/cliproxy/binary-manager.d.ts.map +1 -1
  34. package/dist/cliproxy/binary-manager.js +10 -2
  35. package/dist/cliproxy/binary-manager.js.map +1 -1
  36. package/dist/cliproxy/config/env-builder.d.ts +5 -0
  37. package/dist/cliproxy/config/env-builder.d.ts.map +1 -1
  38. package/dist/cliproxy/config/env-builder.js +56 -4
  39. package/dist/cliproxy/config/env-builder.js.map +1 -1
  40. package/dist/cliproxy/config/path-resolver.d.ts +21 -0
  41. package/dist/cliproxy/config/path-resolver.d.ts.map +1 -1
  42. package/dist/cliproxy/config/path-resolver.js +42 -2
  43. package/dist/cliproxy/config/path-resolver.js.map +1 -1
  44. package/dist/cliproxy/executor/index.d.ts +1 -0
  45. package/dist/cliproxy/executor/index.d.ts.map +1 -1
  46. package/dist/cliproxy/executor/index.js +32 -2
  47. package/dist/cliproxy/executor/index.js.map +1 -1
  48. package/dist/cliproxy/model-config.js +4 -4
  49. package/dist/cliproxy/model-config.js.map +1 -1
  50. package/dist/cliproxy/provider-capabilities.d.ts.map +1 -1
  51. package/dist/cliproxy/provider-capabilities.js +48 -0
  52. package/dist/cliproxy/provider-capabilities.js.map +1 -1
  53. package/dist/cliproxy/quota-fetcher-claude-normalizer.d.ts +1 -5
  54. package/dist/cliproxy/quota-fetcher-claude-normalizer.d.ts.map +1 -1
  55. package/dist/cliproxy/quota-fetcher-claude-normalizer.js +33 -6
  56. package/dist/cliproxy/quota-fetcher-claude-normalizer.js.map +1 -1
  57. package/dist/cliproxy/quota-fetcher-claude.d.ts +2 -2
  58. package/dist/cliproxy/quota-fetcher-claude.d.ts.map +1 -1
  59. package/dist/cliproxy/quota-fetcher-claude.js +18 -32
  60. package/dist/cliproxy/quota-fetcher-claude.js.map +1 -1
  61. package/dist/cliproxy/quota-fetcher-codex.d.ts.map +1 -1
  62. package/dist/cliproxy/quota-fetcher-codex.js +2 -0
  63. package/dist/cliproxy/quota-fetcher-codex.js.map +1 -1
  64. package/dist/cliproxy/quota-types.d.ts +2 -2
  65. package/dist/cliproxy/quota-types.d.ts.map +1 -1
  66. package/dist/cliproxy/service-manager.d.ts.map +1 -1
  67. package/dist/cliproxy/service-manager.js +4 -1
  68. package/dist/cliproxy/service-manager.js.map +1 -1
  69. package/dist/cliproxy/types.d.ts +11 -3
  70. package/dist/cliproxy/types.d.ts.map +1 -1
  71. package/dist/cliproxy/types.js +8 -1
  72. package/dist/cliproxy/types.js.map +1 -1
  73. package/dist/commands/command-catalog.d.ts +2 -1
  74. package/dist/commands/command-catalog.d.ts.map +1 -1
  75. package/dist/commands/command-catalog.js +21 -4
  76. package/dist/commands/command-catalog.js.map +1 -1
  77. package/dist/commands/completion-backend.d.ts.map +1 -1
  78. package/dist/commands/completion-backend.js +4 -0
  79. package/dist/commands/completion-backend.js.map +1 -1
  80. package/dist/commands/cursor-command-display.d.ts.map +1 -1
  81. package/dist/commands/cursor-command-display.js +43 -30
  82. package/dist/commands/cursor-command-display.js.map +1 -1
  83. package/dist/commands/cursor-command.d.ts.map +1 -1
  84. package/dist/commands/cursor-command.js +30 -13
  85. package/dist/commands/cursor-command.js.map +1 -1
  86. package/dist/commands/help-command.d.ts +2 -0
  87. package/dist/commands/help-command.d.ts.map +1 -1
  88. package/dist/commands/help-command.js +55 -2
  89. package/dist/commands/help-command.js.map +1 -1
  90. package/dist/commands/index.d.ts +1 -0
  91. package/dist/commands/index.d.ts.map +1 -1
  92. package/dist/commands/index.js +3 -1
  93. package/dist/commands/index.js.map +1 -1
  94. package/dist/commands/proxy-command.d.ts +2 -0
  95. package/dist/commands/proxy-command.d.ts.map +1 -0
  96. package/dist/commands/proxy-command.js +156 -0
  97. package/dist/commands/proxy-command.js.map +1 -0
  98. package/dist/commands/root-command-router.d.ts.map +1 -1
  99. package/dist/commands/root-command-router.js +7 -0
  100. package/dist/commands/root-command-router.js.map +1 -1
  101. package/dist/config/reserved-names.d.ts +1 -1
  102. package/dist/config/reserved-names.d.ts.map +1 -1
  103. package/dist/config/reserved-names.js +10 -0
  104. package/dist/config/reserved-names.js.map +1 -1
  105. package/dist/config/unified-config-loader.d.ts.map +1 -1
  106. package/dist/config/unified-config-loader.js +19 -0
  107. package/dist/config/unified-config-loader.js.map +1 -1
  108. package/dist/config/unified-config-types.d.ts +14 -0
  109. package/dist/config/unified-config-types.d.ts.map +1 -1
  110. package/dist/config/unified-config-types.js +11 -1
  111. package/dist/config/unified-config-types.js.map +1 -1
  112. package/dist/cursor/constants.d.ts +3 -0
  113. package/dist/cursor/constants.d.ts.map +1 -1
  114. package/dist/cursor/constants.js +26 -1
  115. package/dist/cursor/constants.js.map +1 -1
  116. package/dist/cursor/cursor-anthropic-response.d.ts +1 -6
  117. package/dist/cursor/cursor-anthropic-response.d.ts.map +1 -1
  118. package/dist/cursor/cursor-anthropic-response.js +3 -186
  119. package/dist/cursor/cursor-anthropic-response.js.map +1 -1
  120. package/dist/cursor/cursor-daemon-entry.js +2 -2
  121. package/dist/cursor/cursor-daemon-entry.js.map +1 -1
  122. package/dist/cursor/cursor-profile-executor.js +4 -4
  123. package/dist/cursor/cursor-profile-executor.js.map +1 -1
  124. package/dist/cursor/cursor-runtime-probe.js +3 -3
  125. package/dist/cursor/cursor-runtime-probe.js.map +1 -1
  126. package/dist/glmt/sse-parser.d.ts.map +1 -1
  127. package/dist/glmt/sse-parser.js +46 -41
  128. package/dist/glmt/sse-parser.js.map +1 -1
  129. package/dist/management/shared-manager.d.ts +2 -0
  130. package/dist/management/shared-manager.d.ts.map +1 -1
  131. package/dist/management/shared-manager.js +25 -10
  132. package/dist/management/shared-manager.js.map +1 -1
  133. package/dist/proxy/index.d.ts +8 -0
  134. package/dist/proxy/index.d.ts.map +1 -0
  135. package/dist/proxy/index.js +24 -0
  136. package/dist/proxy/index.js.map +1 -0
  137. package/dist/proxy/profile-router.d.ts +28 -0
  138. package/dist/proxy/profile-router.d.ts.map +1 -0
  139. package/dist/proxy/profile-router.js +43 -0
  140. package/dist/proxy/profile-router.js.map +1 -0
  141. package/dist/proxy/proxy-daemon-entry.d.ts +2 -0
  142. package/dist/proxy/proxy-daemon-entry.d.ts.map +1 -0
  143. package/dist/proxy/proxy-daemon-entry.js +68 -0
  144. package/dist/proxy/proxy-daemon-entry.js.map +1 -0
  145. package/dist/proxy/proxy-daemon-paths.d.ts +6 -0
  146. package/dist/proxy/proxy-daemon-paths.d.ts.map +1 -0
  147. package/dist/proxy/proxy-daemon-paths.js +43 -0
  148. package/dist/proxy/proxy-daemon-paths.js.map +1 -0
  149. package/dist/proxy/proxy-daemon-state.d.ts +18 -0
  150. package/dist/proxy/proxy-daemon-state.d.ts.map +1 -0
  151. package/dist/proxy/proxy-daemon-state.js +92 -0
  152. package/dist/proxy/proxy-daemon-state.js.map +1 -0
  153. package/dist/proxy/proxy-daemon.d.ts +26 -0
  154. package/dist/proxy/proxy-daemon.d.ts.map +1 -0
  155. package/dist/proxy/proxy-daemon.js +350 -0
  156. package/dist/proxy/proxy-daemon.js.map +1 -0
  157. package/dist/proxy/proxy-env.d.ts +3 -0
  158. package/dist/proxy/proxy-env.d.ts.map +1 -0
  159. package/dist/proxy/proxy-env.js +26 -0
  160. package/dist/proxy/proxy-env.js.map +1 -0
  161. package/dist/proxy/request-router.d.ts +12 -0
  162. package/dist/proxy/request-router.d.ts.map +1 -0
  163. package/dist/proxy/request-router.js +163 -0
  164. package/dist/proxy/request-router.js.map +1 -0
  165. package/dist/proxy/routing-config.d.ts +10 -0
  166. package/dist/proxy/routing-config.d.ts.map +1 -0
  167. package/dist/proxy/routing-config.js +79 -0
  168. package/dist/proxy/routing-config.js.map +1 -0
  169. package/dist/proxy/server/http-helpers.d.ts +8 -0
  170. package/dist/proxy/server/http-helpers.d.ts.map +1 -0
  171. package/dist/proxy/server/http-helpers.js +73 -0
  172. package/dist/proxy/server/http-helpers.js.map +1 -0
  173. package/dist/proxy/server/messages-route.d.ts +12 -0
  174. package/dist/proxy/server/messages-route.d.ts.map +1 -0
  175. package/dist/proxy/server/messages-route.js +208 -0
  176. package/dist/proxy/server/messages-route.js.map +1 -0
  177. package/dist/proxy/server/proxy-server.d.ts +12 -0
  178. package/dist/proxy/server/proxy-server.d.ts.map +1 -0
  179. package/dist/proxy/server/proxy-server.js +110 -0
  180. package/dist/proxy/server/proxy-server.js.map +1 -0
  181. package/dist/proxy/transformers/request-transformer.d.ts +52 -0
  182. package/dist/proxy/transformers/request-transformer.d.ts.map +1 -0
  183. package/dist/proxy/transformers/request-transformer.js +254 -0
  184. package/dist/proxy/transformers/request-transformer.js.map +1 -0
  185. package/dist/proxy/transformers/sse-stream-transformer.d.ts +11 -0
  186. package/dist/proxy/transformers/sse-stream-transformer.d.ts.map +1 -0
  187. package/dist/proxy/transformers/sse-stream-transformer.js +199 -0
  188. package/dist/proxy/transformers/sse-stream-transformer.js.map +1 -0
  189. package/dist/proxy/upstream-url.d.ts +3 -0
  190. package/dist/proxy/upstream-url.d.ts.map +1 -0
  191. package/dist/proxy/upstream-url.js +35 -0
  192. package/dist/proxy/upstream-url.js.map +1 -0
  193. package/dist/shared/claude-extension-setup.js +1 -1
  194. package/dist/shared/claude-extension-setup.js.map +1 -1
  195. package/dist/targets/droid-provider.d.ts.map +1 -1
  196. package/dist/targets/droid-provider.js +2 -0
  197. package/dist/targets/droid-provider.js.map +1 -1
  198. package/dist/types/config.d.ts +13 -0
  199. package/dist/types/config.d.ts.map +1 -1
  200. package/dist/types/config.js.map +1 -1
  201. package/dist/types/index.d.ts +1 -1
  202. package/dist/types/index.d.ts.map +1 -1
  203. package/dist/types/index.js.map +1 -1
  204. package/dist/ui/assets/{accounts-B8EmUjf7.js → accounts-Cr7W1buT.js} +1 -1
  205. package/dist/ui/assets/{alert-dialog-zvnFuSZG.js → alert-dialog-C96SrxIc.js} +1 -1
  206. package/dist/ui/assets/{api-vTHvDFg5.js → api-DYkus27c.js} +1 -1
  207. package/dist/ui/assets/{auth-section-Dg3AdWQR.js → auth-section-CxMIfDdS.js} +1 -1
  208. package/dist/ui/assets/{backups-section-CuRlCk7U.js → backups-section-2mpHmgVy.js} +1 -1
  209. package/dist/ui/assets/{channels-ByIXpMal.js → channels-D525HeAb.js} +1 -1
  210. package/dist/ui/assets/{checkbox-DoV2JinM.js → checkbox-CQ1Ps6GL.js} +1 -1
  211. package/dist/ui/assets/{claude-extension-B-Ofp87Z.js → claude-extension-Etkm5mj8.js} +1 -1
  212. package/dist/ui/assets/cliproxy-CtGOikbg.js +3 -0
  213. package/dist/ui/assets/{cliproxy-ai-providers-BVOtMT7b.js → cliproxy-ai-providers-OsVlLpCW.js} +1 -1
  214. package/dist/ui/assets/{cliproxy-control-panel-qL0R878z.js → cliproxy-control-panel-Ds5WBaJL.js} +1 -1
  215. package/dist/ui/assets/{codex-BCHZ-0dx.js → codex-Cjj2T2eA.js} +1 -1
  216. package/dist/ui/assets/{confirm-dialog-BcfzKHj3.js → confirm-dialog-BWtF62KB.js} +1 -1
  217. package/dist/ui/assets/{copilot-Dti40Uv-.js → copilot-jL0eEQoq.js} +1 -1
  218. package/dist/ui/assets/cursor-CCc4tTX_.js +1 -0
  219. package/dist/ui/assets/{droid-BmuIeDFh.js → droid-DqCUCvdJ.js} +2 -2
  220. package/dist/ui/assets/{globalenv-section-CGbpkbpW.js → globalenv-section-psU6xwvx.js} +1 -1
  221. package/dist/ui/assets/{health-DryU1jzv.js → health-ChHRngKH.js} +1 -1
  222. package/dist/ui/assets/{index-Cu--MLG0.js → index-CIIjSQmj.js} +1 -1
  223. package/dist/ui/assets/{index-DUCkRc_D.js → index-CsS3wNix.js} +1 -1
  224. package/dist/ui/assets/index-CsgUrwXk.js +1 -0
  225. package/dist/ui/assets/index-DzJi9m-K.css +1 -0
  226. package/dist/ui/assets/{index-B_vdNMI1.js → index-SYCXM7Jq.js} +1 -1
  227. package/dist/ui/assets/{index-Dgu-LYP_.js → index-a2T7PPUI.js} +1 -1
  228. package/dist/ui/assets/index-lHI_E9S9.js +72 -0
  229. package/dist/ui/assets/{logs-CtIgaS7y.js → logs-DntALG8B.js} +1 -1
  230. package/dist/ui/assets/{masked-input-Dm8T-Vtr.js → masked-input-CYdjMOZg.js} +1 -1
  231. package/dist/ui/assets/providers/codebuddy.png +0 -0
  232. package/dist/ui/assets/providers/cursor.svg +5 -0
  233. package/dist/ui/assets/providers/gitlab.svg +22 -0
  234. package/dist/ui/assets/providers/kilo.png +0 -0
  235. package/dist/ui/assets/{proxy-status-widget-BXghaDz7.js → proxy-status-widget-CLsv7grw.js} +1 -1
  236. package/dist/ui/assets/{raw-json-settings-editor-panel-DhhcWn5Q.js → raw-json-settings-editor-panel-BZlH8urA.js} +1 -1
  237. package/dist/ui/assets/{searchable-select-DiGUiefs.js → searchable-select-D-ry9mQV.js} +1 -1
  238. package/dist/ui/assets/{separator-DnQqlaL0.js → separator-DKvhcyfD.js} +1 -1
  239. package/dist/ui/assets/{shared-BPuiJsYO.js → shared-Z5QeA443.js} +1 -1
  240. package/dist/ui/assets/{table-BDsTJlxT.js → table-DHcccdh4.js} +1 -1
  241. package/dist/ui/assets/{updates-DQxYQBCf.js → updates-B78utNho.js} +1 -1
  242. package/dist/ui/index.html +2 -2
  243. package/dist/utils/hooks/image-analysis-backend-resolver.js +1 -1
  244. package/dist/utils/hooks/image-analysis-backend-resolver.js.map +1 -1
  245. package/dist/web-server/routes/cliproxy-auth-routes.d.ts.map +1 -1
  246. package/dist/web-server/routes/cliproxy-auth-routes.js +124 -1
  247. package/dist/web-server/routes/cliproxy-auth-routes.js.map +1 -1
  248. package/dist/web-server/routes/config-routes.d.ts.map +1 -1
  249. package/dist/web-server/routes/config-routes.js +3 -0
  250. package/dist/web-server/routes/config-routes.js.map +1 -1
  251. package/dist/web-server/routes/index.js +1 -0
  252. package/dist/web-server/routes/index.js.map +1 -1
  253. package/dist/web-server/routes/settings-routes.d.ts.map +1 -1
  254. package/dist/web-server/routes/settings-routes.js +8 -0
  255. package/dist/web-server/routes/settings-routes.js.map +1 -1
  256. package/package.json +1 -1
  257. package/dist/ui/assets/cliproxy-Bhu0JvIb.js +0 -3
  258. package/dist/ui/assets/cursor-BG0Y8Z5F.js +0 -1
  259. package/dist/ui/assets/index-B1mN7ZR-.js +0 -72
  260. package/dist/ui/assets/index-BBVoDJnl.js +0 -1
  261. package/dist/ui/assets/index-BMC5Tudw.css +0 -1
@@ -1 +0,0 @@
1
- import{j as e}from"./radix-ui-Zb8sVEtn.js";import{r as f,c as pe}from"./react-vendor-CNOkPC89.js";import{u as A,a as L,C as g,b as j,S as h,c as d,P as w,B as I,d as _,e as se,f as ge,g as te,h as je,i as ae,j as N,k as S,l as ye,m as Ne,n as we,o as ve}from"./index-B1mN7ZR-.js";import{a3 as be,al as re,am as Y,an as ne,a1 as le,aa as ke,G as Ce,ao as Se,R as De,$ as V,U as $e,Z as ie,v as Le,ad as H,ap as Fe,Y as Re,C as Te,aq as Me,ar as Pe}from"./icons-KVCk4_U8.js";import{a as Be,u as U}from"./tanstack-CrmUhA7Z.js";import{K as T,L as Q,f as C,H as Ae}from"./utils-CzKF5WmX.js";import{R as oe,A as Ue,C as qe,X as Oe,Y as Z,T as ce,a as X,P as Ie,b as Ke,c as Ee}from"./charts-BBPXh0Ar.js";import"./notifications-B2HqRBj7.js";import"./form-utils-Bcoyqxpq.js";import"./code-highlight-BRUf_pqB.js";function Ge({data:s,isLoading:t}){const{privacyMode:a}=A(),{t:r}=L();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(n=>e.jsx(g,{children:e.jsx(j,{className:"p-6",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(h,{className:"h-4 w-[100px]"}),e.jsx(h,{className:"h-8 w-[80px]"})]}),e.jsx(h,{className:"h-8 w-8 rounded-lg"})]})})},n))});const c=(s?.tokenBreakdown?.cacheCreation?.cost??0)+(s?.tokenBreakdown?.cacheRead?.cost??0),o=s?.totalCost?Math.round(c/s.totalCost*100):0,i=[{title:r("analyticsSummary.totalTokens"),value:s?.totalTokens??0,icon:be,format:n=>B(n),color:"text-blue-600",bgColor:"bg-blue-100 dark:bg-blue-900/20",subtitle:r("analyticsSummary.totalTokensSubtitle",{input:B(s?.totalInputTokens??0),output:B(s?.totalOutputTokens??0)})},{title:r("analyticsSummary.totalCost"),value:s?.totalCost??0,icon:re,format:n=>`$${n.toFixed(2)}`,color:"text-green-600",bgColor:"bg-green-100 dark:bg-green-900/20",subtitle:r("analyticsSummary.totalCostSubtitle",{value:s?.averageCostPerDay?.toFixed(2)??"0.00"})},{title:r("analyticsSummary.cacheTokens"),value:s?.totalCacheTokens??0,icon:Y,format:n=>B(n),color:"text-cyan-600",bgColor:"bg-cyan-100 dark:bg-cyan-900/20",subtitle:r("analyticsSummary.cacheTokensSubtitle",{cost:c.toFixed(2),percent:o})},{title:r("analyticsSummary.inputCost"),value:s?.tokenBreakdown?.input?.cost??0,icon:ne,format:n=>`$${n.toFixed(2)}`,color:"text-purple-600",bgColor:"bg-purple-100 dark:bg-purple-900/20",subtitle:r("analyticsSummary.tokensSubtitle",{value:B(s?.tokenBreakdown?.input?.tokens??0)})},{title:r("analyticsSummary.outputCost"),value:s?.tokenBreakdown?.output?.cost??0,icon:le,format:n=>`$${n.toFixed(2)}`,color:"text-orange-600",bgColor:"bg-orange-100 dark:bg-orange-900/20",subtitle:r("analyticsSummary.tokensSubtitle",{value:B(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:i.map((n,l)=>{const x=n.icon;return e.jsx(g,{className:"hover:shadow-md transition-shadow",children:e.jsx(j,{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:n.title}),e.jsx("p",{className:d("text-xl font-bold truncate",a&&w),children:n.format(n.value)}),n.subtitle&&e.jsx("p",{className:d("text-[10px] text-muted-foreground truncate",a&&w),children:n.subtitle})]}),e.jsx("div",{className:d("p-2 rounded-lg shrink-0",n.bgColor),children:e.jsx(x,{className:d("h-4 w-4",n.color)})})]})})},l)})})}function B(s){return s>=1e6?`${(s/1e6).toFixed(1)}M`:s>=1e3?`${(s/1e3).toFixed(1)}K`:s.toLocaleString()}function He({model:s}){const{privacyMode:t}=A(),{t:a}=L(),r=We(s.ioRatio);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(ke,{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(I,{variant:"secondary",className:"text-[10px] h-5 px-1.5",children:[s.percentage.toFixed(1),"% usage"]}),e.jsxs(I,{variant:r.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:d("text-lg font-bold",t&&w),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:d("text-lg font-bold",t&&w),children:ze(s.tokens)}),e.jsx("p",{className:"text-[10px] text-muted-foreground uppercase tracking-wider",children:a("analyticsCards.totalTokens")})]})]}),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:d("space-y-1",t&&w),children:[e.jsx(W,{label:"Input",tokens:s.inputTokens,cost:s.costBreakdown.input.cost,color:"#335c67",icon:ne}),e.jsx(W,{label:"Output",tokens:s.outputTokens,cost:s.costBreakdown.output.cost,color:"#fff3b0",icon:le}),e.jsx(W,{label:"Cache Write",tokens:s.cacheCreationTokens,cost:s.costBreakdown.cacheCreation.cost,color:"#e09f3e",icon:Y}),e.jsx(W,{label:"Cache Read",tokens:s.cacheReadTokens,cost:s.costBreakdown.cacheRead.cost,color:"#9e2a2b",icon:Y})]})]}),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(Ce,{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:r.description})]})]})}function W({label:s,tokens:t,cost:a,color:r,icon:c}){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:r}}),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(c,{className:"h-3 w-3 shrink-0"}),e.jsx("span",{children:_e(t)})]})]})]})}function We(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 _e(s){return s.toLocaleString()}function ze(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 Ye="/api";function v(s){const t=s.getFullYear(),a=String(s.getMonth()+1).padStart(2,"0"),r=String(s.getDate()).padStart(2,"0");return`${t}${a}${r}`}const M={summary:s=>{const t=new URLSearchParams;return s?.startDate&&t.append("since",v(s.startDate)),s?.endDate&&t.append("until",v(s.endDate)),s?.profile&&t.append("profile",s.profile),$(`/usage/summary?${t}`)},trends:s=>{const t=new URLSearchParams;return s?.startDate&&t.append("since",v(s.startDate)),s?.endDate&&t.append("until",v(s.endDate)),s?.profile&&t.append("profile",s.profile),$(`/usage/daily?${t}`)},hourly:s=>{const t=new URLSearchParams;return s?.startDate&&t.append("since",v(s.startDate)),s?.endDate&&t.append("until",v(s.endDate)),$(`/usage/hourly?${t}`)},models:s=>{const t=new URLSearchParams;return s?.startDate&&t.append("since",v(s.startDate)),s?.endDate&&t.append("until",v(s.endDate)),s?.profile&&t.append("profile",s.profile),$(`/usage/models?${t}`)},sessions:s=>{const t=new URLSearchParams;return s?.startDate&&t.append("since",v(s.startDate)),s?.endDate&&t.append("until",v(s.endDate)),s?.profile&&t.append("profile",s.profile),s?.limit&&t.append("limit",s.limit.toString()),s?.offset&&t.append("offset",s.offset.toString()),$(`/usage/sessions?${t}`)},monthly:(s,t)=>{const a=new URLSearchParams;return s&&a.append("months",s.toString()),t&&a.append("profile",t),$(`/usage/monthly?${a}`)},refresh:async()=>{if(!(await fetch(`${Ye}/usage/refresh`,{method:"POST",headers:{"Content-Type":"application/json"}})).ok)throw new Error("Failed to refresh usage cache")},status:()=>$("/usage/status"),insights:s=>{const t=new URLSearchParams;return s?.startDate&&t.append("since",v(s.startDate)),s?.endDate&&t.append("until",v(s.endDate)),s?.profile&&t.append("profile",s.profile),$(`/usage/insights?${t}`)}};async function $(s){const a=await fetch(`/api${s}`,{headers:{"Content-Type":"application/json"}});if(!a.ok){const c=await a.json().catch(()=>({error:"Unknown error"}));throw new Error(c.error||a.statusText)}const r=await a.json();return r.data||r}function Qe(s){return U({queryKey:["usage","summary",s],queryFn:()=>M.summary(s),staleTime:60*1e3})}function Ve(s){return U({queryKey:["usage","trends",s],queryFn:()=>M.trends(s),staleTime:60*1e3})}function Ze(s){return U({queryKey:["usage","hourly",s],queryFn:()=>M.hourly(s),staleTime:60*1e3})}function Xe(s){return U({queryKey:["usage","models",s],queryFn:()=>M.models(s),staleTime:60*1e3})}function Je(){const s=Be();return f.useCallback(async()=>{await M.refresh(),await s.invalidateQueries({queryKey:["usage"]})},[s])}function es(){return U({queryKey:["usage","status"],queryFn:()=>M.status(),staleTime:10*1e3,refetchInterval:30*1e3})}function ss(s){return U({queryKey:["usage","sessions",s],queryFn:()=>M.sessions(s),staleTime:60*1e3})}function ts(){const[s,t]=f.useState({from:T(new Date,30),to:new Date}),[a,r]=f.useState(!1),[c,o]=f.useState(null),[i,n]=f.useState(null),[l,x]=f.useState("daily"),m=Je(),u=f.useCallback(async()=>{r(!0);try{await m()}finally{r(!1)}},[m]),p=f.useMemo(()=>({startDate:s?.from,endDate:s?.to}),[s?.from,s?.to]),{data:F,isLoading:y}=Qe(p),{data:b,isLoading:k}=Ve(p),{data:D,isLoading:q}=Ze(p),{data:R,isLoading:O}=Xe(p),{data:z,isLoading:K}=ss({...p,limit:3}),{data:E}=es(),de=f.useCallback(()=>{const P=new Date;t({from:T(P,1),to:P}),x("hourly")},[]),xe=f.useCallback(P=>{t(P),x("daily")},[]),ue=f.useMemo(()=>E?.lastFetch?Q(new Date(E.lastFetch),{addSuffix:!0}):null,[E?.lastFetch]),me=f.useCallback((P,fe)=>{const G=fe.currentTarget.getBoundingClientRect();n({x:G.left+G.width/2,y:G.top+G.height/2}),o(P)},[]),he=f.useCallback(()=>{o(null),n(null)},[]);return{dateRange:s,isRefreshing:a,viewMode:l,selectedModel:c,popoverPosition:i,summary:F,trends:b,hourlyData:D,models:R,sessions:z,status:E,isSummaryLoading:y,isTrendsLoading:k,isHourlyLoading:q,isModelsLoading:O,isSessionsLoading:K,isLoading:y||k||O||K,handleRefresh:u,handleTodayClick:de,handleDateRangeChange:xe,handleModelClick:me,handlePopoverClose:he,lastUpdatedText:ue}}function as({value:s,onChange:t,presets:a=[{label:"Last 7 days",range:{from:T(new Date,7),to:new Date}},{label:"Last 30 days",range:{from:T(new Date,30),to:new Date}},{label:"Last 90 days",range:{from:T(new Date,90),to:new Date}}],className:r}){const[c,o]=pe.useState(!1),{t:i}=L(),n=l=>!s||!s.from||!s.to||!l.from||!l.to?!1:C(s.from,"yyyy-MM-dd")===C(l.from,"yyyy-MM-dd")&&C(s.to,"yyyy-MM-dd")===C(l.to,"yyyy-MM-dd");return e.jsxs("div",{className:d("flex flex-wrap items-center gap-2",r),children:[a.map(l=>e.jsx(_,{variant:n(l.range)?"default":"outline",size:"sm",onClick:()=>t(l.range),children:l.label},l.label)),e.jsxs(se,{open:c,onOpenChange:o,children:[e.jsx(ge,{asChild:!0,children:e.jsxs(_,{id:"date",variant:"outline",className:d("w-auto min-w-[200px] sm:min-w-[240px] justify-start text-left font-normal",!s&&"text-muted-foreground"),children:[e.jsx(Se,{className:"mr-2 h-4 w-4"}),s?.from?s.to?e.jsxs(e.Fragment,{children:[C(s.from,"LLL dd, y")," - ",C(s.to,"LLL dd, y")]}):C(s.from,"LLL dd, y"):e.jsx("span",{children:i("dateRangeFilter.pickADate")})]})}),e.jsx(te,{className:"w-auto p-0",align:"end",children:e.jsx(je,{initialFocus:!0,mode:"range",defaultMonth:s?.from,selected:s,onSelect:t,numberOfMonths:2})})]})]})}function rs({dateRange:s,onDateRangeChange:t,onTodayClick:a,onRefresh:r,isRefreshing:c,lastUpdatedText:o,viewMode:i}){const{t:n}=L();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:n("analytics.title")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:n("analytics.subtitle")})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2 xl:justify-end",children:[e.jsx(_,{variant:i==="hourly"?"default":"outline",size:"sm",className:"h-8",onClick:a,children:"24H"}),e.jsx(as,{className:"flex-wrap",value:s,onChange:t,presets:[{label:"7D",range:{from:T(new Date,7),to:new Date}},{label:"30D",range:{from:T(new Date,30),to:new Date}},{label:n("analytics.month"),range:{from:Ae(new Date),to:new Date}},{label:n("analytics.allTime"),range:{from:void 0,to:new Date}}]}),o&&e.jsx("span",{className:"text-xs text-muted-foreground whitespace-nowrap",children:n("analytics.updated",{value:o})}),e.jsx(_,{variant:"outline",size:"sm",className:"gap-2 h-8",onClick:r,disabled:c,children:e.jsx(De,{className:`w-3.5 h-3.5 ${c?"animate-spin":""}`})})]})]})}function ns({data:s,isLoading:t,granularity:a="daily",className:r}){const{privacyMode:c}=A(),o=f.useMemo(()=>!s||s.length===0?[]:(a==="hourly"?s:[...s].reverse()).map(l=>{const x="hour"in l?l.hour:l.date;return{...l,dateFormatted:ls(x,a),costRounded:Number(l.cost.toFixed(4))}}),[s,a]);if(t)return e.jsx(h,{className:d("h-full w-full",r)});if(!s||s.length===0)return e.jsx("div",{className:d("h-full flex items-center justify-center",r),children:e.jsx("p",{className:"text-muted-foreground",children:a==="hourly"?"No usage data for today":"No usage data available"})});const i=({x:n,y:l,payload:x,isRight:m})=>{const u=m?`$${x.value}`:J(Number(x.value));return e.jsx("text",{x:n,y:l,dy:4,textAnchor:m?"start":"end",fontSize:12,fill:"currentColor",className:d("fill-muted-foreground",c&&"blur-[4px]"),children:u})};return e.jsx("div",{className:d("w-full h-full",r),children:e.jsx(oe,{width:"100%",height:"100%",children:e.jsxs(Ue,{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(qe,{strokeDasharray:"3 3",className:"stroke-muted"}),e.jsx(Oe,{dataKey:"dateFormatted",tick:{fontSize:12},tickLine:!1,axisLine:{className:"stroke-muted"}}),e.jsx(Z,{yAxisId:"left",orientation:"left",tick:n=>e.jsx(i,{...n,isRight:!1}),tickLine:!1,axisLine:{className:"stroke-muted"}}),e.jsx(Z,{yAxisId:"right",orientation:"right",tick:n=>e.jsx(i,{...n,isRight:!0}),tickLine:!1,axisLine:{className:"stroke-muted"}}),e.jsx(ce,{content:({active:n,payload:l,label:x})=>{if(!n||!l||!l.length)return null;const m=l[0].payload;return e.jsxs("div",{className:"rounded-lg border bg-background p-3 shadow-lg",children:[e.jsx("p",{className:"font-medium mb-2",children:x}),l.map((u,p)=>e.jsxs("p",{className:d("text-sm",c&&w),style:{color:u.color},children:[u.name,":"," ",u.name==="Tokens"?J(Number(u.value)||0):`$${u.value}`]},p)),"requests"in m&&e.jsxs("p",{className:d("text-sm text-muted-foreground mt-1",c&&w),children:["Requests: ",m.requests]})]})}}),e.jsx(X,{yAxisId:"left",type:"monotone",dataKey:"tokens",stroke:"#0080FF",strokeWidth:2,fillOpacity:1,fill:"url(#tokenGradient)",name:"Tokens"}),e.jsx(X,{yAxisId:"right",type:"monotone",dataKey:"costRounded",stroke:"#00C49F",strokeWidth:2,fillOpacity:1,fill:"url(#costGradient)",name:"Cost"})]})})})}function ls(s,t){if(t==="hourly"){const[r,c]=s.split(" ");if(r&&c){const o=new Date(`${r}T${c}:00Z`);return C(o,"HH:mm")}return s}const a=new Date(s);return t==="monthly"?C(a,"MMM yyyy"):C(a,"MMM dd")}function J(s){return s>=1e6?`${(s/1e6).toFixed(1)}M`:s>=1e3?`${(s/1e3).toFixed(1)}K`:s.toLocaleString()}function is({data:s,isLoading:t,className:a}){const{privacyMode:r}=A(),{t:c}=L(),o=f.useMemo(()=>!s||s.length===0?[]:s.map(l=>({name:l.model,value:l.tokens,cost:l.cost,percentage:l.percentage,fill:ae(l.model)})),[s]);if(t)return e.jsx(h,{className:d("h-full min-h-[100px] w-full",a)});if(!s||s.length===0)return e.jsx("div",{className:d("h-full min-h-[100px] flex items-center justify-center",a),children:e.jsx("p",{className:"text-muted-foreground",children:c("analyticsCards.noModelData")})});const i=({active:l,payload:x})=>{if(!l||!x)return null;const m=x;if(!m.length)return null;const u=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:u.name}),e.jsxs("p",{className:d("text-muted-foreground",r&&w),children:[os(u.value)," (",u.percentage.toFixed(1),"%)"]}),e.jsxs("p",{className:d("text-muted-foreground",r&&w),children:["$",u.cost.toFixed(4)]})]})},n=l=>l.percentage>5?`${l.percentage.toFixed(1)}%`:"";return e.jsx("div",{className:d("w-full h-full min-h-[100px]",a),children:e.jsx(oe,{width:"100%",height:"100%",children:e.jsxs(Ie,{children:[e.jsx(Ke,{data:o,cx:"50%",cy:"50%",labelLine:!1,label:n,innerRadius:50,outerRadius:70,paddingAngle:2,dataKey:"value",children:o.map((l,x)=>e.jsx(Ee,{fill:l.fill,strokeWidth:1},`cell-${x}`))}),e.jsx(ce,{content:i})]})})})}function os(s){return s>=1e6?`${(s/1e6).toFixed(1)}M`:s>=1e3?`${(s/1e3).toFixed(1)}K`:s.toLocaleString()}function cs(s){if(!s)return"";const a=s.replace(/^\/|\/$/g,"").split("/").filter(r=>r.length>0);return a[a.length-1]||""}function ds({data:s,isLoading:t,className:a}){const{privacyMode:r}=A(),{t:c}=L(),o=f.useMemo(()=>{if(!s?.sessions||s.sessions.length===0)return null;const i=s.sessions,n=s.total,l=i.reduce((y,b)=>y+(b.inputTokens+b.outputTokens),0),x=Math.round(l/i.length),u=i.reduce((y,b)=>y+b.cost,0)/i.length,p=i[0],F=p?Q(new Date(p.lastActivity),{addSuffix:!0}):"N/A";return{totalSessions:n,avgTokens:x,avgCost:u,lastActive:F,recentSessions:i.slice(0,3)}},[s]);return t?e.jsxs(g,{className:d("flex flex-col h-full min-h-0 overflow-hidden gap-0 py-0",a),children:[e.jsx(N,{className:"px-3 py-2",children:e.jsx(h,{className:"h-5 w-32"})}),e.jsx(j,{className:"px-3 pb-3 pt-0 flex-1",children:e.jsx(h,{className:"h-full w-full"})})]}):o?e.jsxs(g,{className:d("flex flex-col h-full min-h-0 overflow-hidden gap-0 py-0 shadow-sm",a),children:[e.jsx(N,{className:"px-3 py-2",children:e.jsxs(S,{className:"text-base font-semibold flex items-center gap-2",children:[e.jsx(V,{className:"w-4 h-4"}),"Session Stats"]})}),e.jsxs(j,{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($e,{className:"w-4 h-4"}),e.jsx("span",{className:"text-xl font-bold",children:o.totalSessions})]}),e.jsx("p",{className:"text-[10px] text-muted-foreground uppercase tracking-wider mt-0.5",children:"Total Sessions"})]}),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(ie,{className:"w-4 h-4"}),e.jsxs("span",{className:d("text-xl font-bold",r&&w),children:["$",o.avgCost.toFixed(2)]})]}),e.jsx("p",{className:"text-[10px] text-muted-foreground uppercase tracking-wider mt-0.5",children:"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(Le,{className:"w-3 h-3"}),"Recent Activity"]}),e.jsx("div",{className:"space-y-1.5 max-h-full overflow-y-auto pr-1",children:o.recentSessions.map(i=>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:i.projectPath,children:cs(i.projectPath)}),(i.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:i.target})]}),e.jsx("span",{className:"text-[10px] text-muted-foreground",children:Q(new Date(i.lastActivity),{addSuffix:!0})})]}),e.jsxs("div",{className:d("text-right shrink-0 ml-2",r&&w),children:[e.jsxs("div",{className:"font-mono",children:["$",i.cost.toFixed(2)]}),e.jsxs("div",{className:"text-[10px] text-muted-foreground",children:[xs(i.inputTokens+i.outputTokens)," toks"]})]})]},i.sessionId))})]})]})]}):e.jsxs(g,{className:d("flex flex-col h-full min-h-0 overflow-hidden gap-0 py-0",a),children:[e.jsx(N,{className:"px-3 py-2",children:e.jsxs(S,{className:"text-base font-semibold flex items-center gap-2",children:[e.jsx(V,{className:"w-4 h-4"}),"Session Stats"]})}),e.jsx(j,{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:c("analyticsCards.noSessionData")})})]})}function xs(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 us({className:s,isLoading:t}){const{data:a,isLoading:r}=ye(),{data:c,isLoading:o,error:i}=Ne(a?.running),{t:n}=L();if(t||r||a?.running&&o)return e.jsxs(g,{className:d("flex flex-col h-full min-h-0 overflow-hidden gap-0 py-0",s),children:[e.jsx(N,{className:"px-3 py-2",children:e.jsxs(S,{className:"text-base font-semibold flex items-center gap-2",children:[e.jsx(H,{className:"h-4 w-4"}),"CLIProxy Stats"]})}),e.jsx(j,{className:"px-3 pb-3 pt-0 flex-1",children:e.jsxs("div",{className:"space-y-3",children:[e.jsx(h,{className:"h-4 w-[100px]"}),e.jsx(h,{className:"h-16 w-full"})]})})]});if(!a?.running)return e.jsxs(g,{className:d("flex flex-col h-full min-h-0 overflow-hidden gap-0 py-0 border-dashed",s),children:[e.jsx(N,{className:"px-3 py-2",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(S,{className:"text-base font-semibold flex items-center gap-2",children:[e.jsx(H,{className:"h-4 w-4 text-muted-foreground"}),"CLIProxy Stats"]}),e.jsx(I,{variant:"secondary",className:"text-[10px] h-5",children:n("cliproxyStatsOverview.offline")})]})}),e.jsx(j,{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:n("cliproxyStatsOverview.noActiveSessionHint")})})]});if(i)return e.jsxs(g,{className:d("flex flex-col h-full min-h-0 overflow-hidden gap-0 py-0 border-destructive/50",s),children:[e.jsx(N,{className:"px-3 py-2",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(S,{className:"text-base font-semibold flex items-center gap-2",children:[e.jsx(H,{className:"h-4 w-4"}),"CLIProxy Stats"]}),e.jsx(I,{variant:"destructive",className:"text-[10px] h-5",children:"Error"})]})}),e.jsx(j,{className:"px-3 pb-3 pt-0 flex-1",children:e.jsx("p",{className:"text-xs text-destructive",children:i.message})})]});const x=c?.totalRequests??0,m=c?.quotaExceededCount??0,u=x-m,p=x>0?Math.round(u/x*100):100,F=c?.tokens?.total??0,y=Object.entries(c?.requestsByModel??{}).sort((k,D)=>D[1]-k[1]).slice(0,4),b=y.length>0?y[0][1]:1;return e.jsxs(g,{className:d("flex flex-col h-full min-h-0 overflow-hidden gap-0 py-0",s),children:[e.jsx(N,{className:"px-3 py-2 border-b bg-muted/5",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(S,{className:"text-base font-semibold flex items-center gap-2",children:[e.jsx(H,{className:"h-4 w-4"}),"CLIProxy Stats"]}),e.jsxs(I,{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(ie,{className:"h-3 w-3 mr-0.5"}),n("cliproxyStatsOverview.running")]})]})}),e.jsx(j,{className:"p-0 flex-1 min-h-0",children:e.jsx(we,{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:`${p*.88} 88`,strokeLinecap:"round",className:p>=90?"text-green-500":"text-amber-500"})]}),e.jsxs("span",{className:"absolute inset-0 flex items-center justify-center text-[8px] font-bold",children:[p,"%"]})]}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-lg font-bold leading-none",children:ee(x)}),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(Fe,{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:ee(F)}),e.jsx("div",{className:"text-[9px] text-muted-foreground mt-0.5",children:n("cliproxyStatsOverview.totalTokens")})]})]})]}),y.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(Re,{className:"h-3 w-3"}),n("cliproxyStatsOverview.modelsUsed")]}),e.jsx("div",{className:"space-y-1",children:y.map(([k,D])=>{const q=Math.round(D/b*100),R=ms(k);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:k,children:R}),e.jsx("span",{className:"text-muted-foreground shrink-0 ml-2",children:D})]}),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:`${q}%`}})})]},k)})})]})]})})})]})}function ee(s){return s>=1e6?`${(s/1e6).toFixed(1)}M`:s>=1e3?`${(s/1e3).toFixed(1)}K`:s.toLocaleString()}function ms(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 hs(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 fs({models:s,isLoading:t,onModelClick:a,privacyMode:r}){const{t:c}=L();return e.jsxs(g,{className:"flex flex-col h-full min-h-0 overflow-hidden gap-0 py-0 shadow-sm lg:col-span-4",children:[e.jsx(N,{className:"px-3 py-2",children:e.jsxs(S,{className:"text-base font-semibold flex items-center gap-2",children:[e.jsx(re,{className:"w-4 h-4"}),c("analyticsPages.costByModel")]})}),e.jsx(j,{className:"px-2 pb-2 pt-0 flex-1 min-h-0 overflow-y-auto",children:t?e.jsx(h,{className:"h-full w-full"}):e.jsxs("div",{className:"space-y-0.5",children:[[...s||[]].sort((o,i)=>i.cost-o.cost).map(o=>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:i=>a(o,i),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:ae(o.model)}}),e.jsx("span",{className:"font-medium truncate group-hover:underline underline-offset-2",children:o.model})]}),e.jsx(ps,{model:o}),e.jsx("span",{className:d("text-[10px] text-muted-foreground w-14 text-right shrink-0",r&&w),children:hs(o.tokens)}),e.jsxs("span",{className:d("font-mono font-medium w-16 text-right shrink-0",r&&w),children:["$",o.cost.toFixed(2)]}),e.jsx(Te,{className:"w-3 h-3 opacity-0 group-hover:opacity-50 transition-opacity shrink-0"})]},o.model)),e.jsx(gs,{})]})})]})}function ps({model:s}){const t={input:"#335c67",output:"#fff3b0",cacheWrite:"#e09f3e",cacheRead:"#9e2a2b"},a=r=>s.cost>0?r/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:r})=>e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx("div",{className:d("w-2 h-2 rounded-full",r&&"border border-muted-foreground/30"),style:{backgroundColor:t}}),a]},a))})}function js({viewMode:s,trends:t,hourlyData:a,models:r,sessions:c,isTrendsLoading:o,isHourlyLoading:i,isModelsLoading:n,isSessionsLoading:l,isSummaryLoading:x,onModelClick:m}){const{privacyMode:u}=A();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(g,{className:"flex flex-col h-full min-h-[220px] lg:min-h-[240px] overflow-hidden gap-0 py-0 shadow-sm",children:[e.jsx(N,{className:"px-3 py-2 shrink-0",children:e.jsxs(S,{className:"text-base font-semibold flex items-center gap-2",children:[e.jsx(Me,{className:"w-4 h-4"}),s==="hourly"?"Last 24 Hours":"Usage Trends"]})}),e.jsx(j,{className:"px-3 pb-3 pt-0 flex-1 min-h-0",children:e.jsx(ns,{data:s==="hourly"?a||[]:t||[],isLoading:s==="hourly"?i:o,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(fs,{models:r,isLoading:n,onModelClick:m,privacyMode:u}),e.jsxs(g,{className:"flex flex-col h-full min-h-0 overflow-hidden gap-0 py-0 shadow-sm lg:col-span-2",children:[e.jsx(N,{className:"px-3 py-2",children:e.jsxs(S,{className:"text-base font-semibold flex items-center gap-2",children:[e.jsx(Pe,{className:"w-4 h-4"}),"Model Usage"]})}),e.jsx(j,{className:"px-2 pb-2 pt-0 flex-1 min-h-0 flex items-center justify-center",children:e.jsx(is,{data:r||[],isLoading:n,className:"h-full w-full"})})]}),e.jsx(ds,{data:c,isLoading:l,className:"lg:col-span-2"}),e.jsx(us,{isLoading:x,className:"lg:col-span-2"})]})]})}function Ls(){return e.jsxs("div",{className:"space-y-4 h-full overflow-hidden",children:[e.jsxs(g,{className:"flex flex-col min-h-[300px]",children:[e.jsx(N,{className:"p-4 pb-2",children:e.jsx(h,{className:"h-4 w-32"})}),e.jsx(j,{className:"p-4 pt-0 flex-1",children:e.jsx(h,{className:"h-full w-full"})})]}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-4",children:[e.jsxs(g,{className:"flex flex-col min-h-[250px]",children:[e.jsx(N,{className:"p-4 pb-2",children:e.jsx(h,{className:"h-4 w-28"})}),e.jsx(j,{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(h,{className:"w-2.5 h-2.5 rounded-full"}),e.jsx(h,{className:"h-3 w-24"})]}),e.jsx(h,{className:"h-3 w-16"})]},s))})})]}),e.jsxs(g,{className:"flex flex-col min-h-[250px]",children:[e.jsx(N,{className:"p-4 pb-2",children:e.jsx(h,{className:"h-4 w-28"})}),e.jsx(j,{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(h,{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(h,{className:"w-2 h-2 rounded-full"}),e.jsx(h,{className:"h-3 w-20"})]},s))})]})})]})]})]})}function Fs(){const s=f.useRef(null),{dateRange:t,handleDateRangeChange:a,handleTodayClick:r,handleRefresh:c,isRefreshing:o,lastUpdatedText:i,viewMode:n,summary:l,isSummaryLoading:x,trends:m,hourlyData:u,models:p,sessions:F,isTrendsLoading:y,isHourlyLoading:b,isModelsLoading:k,isSessionsLoading:D,handleModelClick:q,selectedModel:R,popoverPosition:O,handlePopoverClose:z}=ts();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(rs,{dateRange:t,onDateRangeChange:a,onTodayClick:r,onRefresh:c,isRefreshing:o,lastUpdatedText:i,viewMode:n}),e.jsx(Ge,{data:l,isLoading:x}),e.jsx(js,{viewMode:n,trends:m,hourlyData:u,models:p,sessions:F,isTrendsLoading:y,isHourlyLoading:b,isModelsLoading:k,isSessionsLoading:D,isSummaryLoading:x,onModelClick:q}),e.jsxs(se,{open:!!R,onOpenChange:K=>!K&&z(),children:[e.jsx(ve,{asChild:!0,children:e.jsx("div",{ref:s,className:"fixed pointer-events-none",style:{left:O?.x??0,top:O?.y??0,width:1,height:1}})}),e.jsx(te,{className:"w-80 p-3",side:"top",align:"center",children:R&&e.jsx(He,{model:R})})]})]})}export{Fs as AnalyticsPage,Ls as AnalyticsSkeleton};