omniroute 3.7.2 → 3.7.3

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 (362) hide show
  1. package/app/.next/BUILD_ID +1 -1
  2. package/app/.next/app-path-routes-manifest.json +15 -15
  3. package/app/.next/build-manifest.json +3 -3
  4. package/app/.next/prerender-manifest.json +3 -3
  5. package/app/.next/react-loadable-manifest.json +3 -3
  6. package/app/.next/server/app/(dashboard)/dashboard/agents/page_client-reference-manifest.js +1 -1
  7. package/app/.next/server/app/(dashboard)/dashboard/analytics/page_client-reference-manifest.js +1 -1
  8. package/app/.next/server/app/(dashboard)/dashboard/api-manager/page_client-reference-manifest.js +1 -1
  9. package/app/.next/server/app/(dashboard)/dashboard/audit/page_client-reference-manifest.js +1 -1
  10. package/app/.next/server/app/(dashboard)/dashboard/auto-combo/page_client-reference-manifest.js +1 -1
  11. package/app/.next/server/app/(dashboard)/dashboard/batch/page_client-reference-manifest.js +1 -1
  12. package/app/.next/server/app/(dashboard)/dashboard/cache/media/page.js +1 -1
  13. package/app/.next/server/app/(dashboard)/dashboard/cache/media/page_client-reference-manifest.js +1 -1
  14. package/app/.next/server/app/(dashboard)/dashboard/cache/page_client-reference-manifest.js +1 -1
  15. package/app/.next/server/app/(dashboard)/dashboard/cli-tools/page_client-reference-manifest.js +1 -1
  16. package/app/.next/server/app/(dashboard)/dashboard/combos/page_client-reference-manifest.js +1 -1
  17. package/app/.next/server/app/(dashboard)/dashboard/costs/page_client-reference-manifest.js +1 -1
  18. package/app/.next/server/app/(dashboard)/dashboard/endpoint/page_client-reference-manifest.js +1 -1
  19. package/app/.next/server/app/(dashboard)/dashboard/health/page_client-reference-manifest.js +1 -1
  20. package/app/.next/server/app/(dashboard)/dashboard/limits/page_client-reference-manifest.js +1 -1
  21. package/app/.next/server/app/(dashboard)/dashboard/logs/page.js +1 -1
  22. package/app/.next/server/app/(dashboard)/dashboard/logs/page_client-reference-manifest.js +1 -1
  23. package/app/.next/server/app/(dashboard)/dashboard/memory/page_client-reference-manifest.js +1 -1
  24. package/app/.next/server/app/(dashboard)/dashboard/onboarding/page_client-reference-manifest.js +1 -1
  25. package/app/.next/server/app/(dashboard)/dashboard/page.js.nft.json +1 -1
  26. package/app/.next/server/app/(dashboard)/dashboard/page_client-reference-manifest.js +1 -1
  27. package/app/.next/server/app/(dashboard)/dashboard/playground/page_client-reference-manifest.js +1 -1
  28. package/app/.next/server/app/(dashboard)/dashboard/providers/[id]/page_client-reference-manifest.js +1 -1
  29. package/app/.next/server/app/(dashboard)/dashboard/providers/new/page_client-reference-manifest.js +1 -1
  30. package/app/.next/server/app/(dashboard)/dashboard/providers/page_client-reference-manifest.js +1 -1
  31. package/app/.next/server/app/(dashboard)/dashboard/search-tools/page_client-reference-manifest.js +1 -1
  32. package/app/.next/server/app/(dashboard)/dashboard/settings/page_client-reference-manifest.js +1 -1
  33. package/app/.next/server/app/(dashboard)/dashboard/settings/pricing/page_client-reference-manifest.js +1 -1
  34. package/app/.next/server/app/(dashboard)/dashboard/skills/page_client-reference-manifest.js +1 -1
  35. package/app/.next/server/app/(dashboard)/dashboard/translator/page_client-reference-manifest.js +1 -1
  36. package/app/.next/server/app/(dashboard)/dashboard/usage/page_client-reference-manifest.js +1 -1
  37. package/app/.next/server/app/400/page_client-reference-manifest.js +1 -1
  38. package/app/.next/server/app/401/page_client-reference-manifest.js +1 -1
  39. package/app/.next/server/app/403/page_client-reference-manifest.js +1 -1
  40. package/app/.next/server/app/408/page_client-reference-manifest.js +1 -1
  41. package/app/.next/server/app/429/page_client-reference-manifest.js +1 -1
  42. package/app/.next/server/app/500/page_client-reference-manifest.js +1 -1
  43. package/app/.next/server/app/502/page_client-reference-manifest.js +1 -1
  44. package/app/.next/server/app/503/page_client-reference-manifest.js +1 -1
  45. package/app/.next/server/app/_global-error/page_client-reference-manifest.js +1 -1
  46. package/app/.next/server/app/_global-error.html +1 -1
  47. package/app/.next/server/app/_global-error.rsc +1 -1
  48. package/app/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
  49. package/app/.next/server/app/_global-error.segments/_global-error/__PAGE__.segment.rsc +1 -1
  50. package/app/.next/server/app/_global-error.segments/_global-error.segment.rsc +1 -1
  51. package/app/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
  52. package/app/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
  53. package/app/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  54. package/app/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
  55. package/app/.next/server/app/api/acp/agents/route.js.nft.json +1 -1
  56. package/app/.next/server/app/api/auth/login/route.js.nft.json +1 -1
  57. package/app/.next/server/app/api/auth/logout/route.js.nft.json +1 -1
  58. package/app/.next/server/app/api/batches/route.js.nft.json +1 -1
  59. package/app/.next/server/app/api/cache/entries/route.js.nft.json +1 -1
  60. package/app/.next/server/app/api/cache/reasoning/route.js.nft.json +1 -1
  61. package/app/.next/server/app/api/cache/route.js.nft.json +1 -1
  62. package/app/.next/server/app/api/cache/stats/route.js.nft.json +1 -1
  63. package/app/.next/server/app/api/cli-tools/antigravity-mitm/alias/route.js +2 -2
  64. package/app/.next/server/app/api/cli-tools/antigravity-mitm/alias/route.js.nft.json +1 -1
  65. package/app/.next/server/app/api/cli-tools/antigravity-mitm/route.js.nft.json +1 -1
  66. package/app/.next/server/app/api/cli-tools/backups/route.js +2 -2
  67. package/app/.next/server/app/api/cli-tools/backups/route.js.nft.json +1 -1
  68. package/app/.next/server/app/api/cli-tools/claude-settings/route.js +2 -2
  69. package/app/.next/server/app/api/cli-tools/claude-settings/route.js.nft.json +1 -1
  70. package/app/.next/server/app/api/cli-tools/cline-settings/route.js +1 -1
  71. package/app/.next/server/app/api/cli-tools/cline-settings/route.js.nft.json +1 -1
  72. package/app/.next/server/app/api/cli-tools/codex-profiles/route.js +1 -1
  73. package/app/.next/server/app/api/cli-tools/codex-profiles/route.js.nft.json +1 -1
  74. package/app/.next/server/app/api/cli-tools/codex-settings/route.js +2 -2
  75. package/app/.next/server/app/api/cli-tools/codex-settings/route.js.nft.json +1 -1
  76. package/app/.next/server/app/api/cli-tools/droid-settings/route.js +1 -1
  77. package/app/.next/server/app/api/cli-tools/droid-settings/route.js.nft.json +1 -1
  78. package/app/.next/server/app/api/cli-tools/guide-settings/[toolId]/route.js.nft.json +1 -1
  79. package/app/.next/server/app/api/cli-tools/keys/route.js.nft.json +1 -1
  80. package/app/.next/server/app/api/cli-tools/kilo-settings/route.js +1 -1
  81. package/app/.next/server/app/api/cli-tools/kilo-settings/route.js.nft.json +1 -1
  82. package/app/.next/server/app/api/cli-tools/openclaw/auto-order/route.js.nft.json +1 -1
  83. package/app/.next/server/app/api/cli-tools/openclaw-settings/route.js +1 -1
  84. package/app/.next/server/app/api/cli-tools/openclaw-settings/route.js.nft.json +1 -1
  85. package/app/.next/server/app/api/cli-tools/qwen-settings/route.js +1 -1
  86. package/app/.next/server/app/api/cli-tools/qwen-settings/route.js.nft.json +1 -1
  87. package/app/.next/server/app/api/cli-tools/runtime/[toolId]/route.js +2 -2
  88. package/app/.next/server/app/api/cli-tools/runtime/[toolId]/route.js.nft.json +1 -1
  89. package/app/.next/server/app/api/cli-tools/status/route.js +1 -1
  90. package/app/.next/server/app/api/cli-tools/status/route.js.nft.json +1 -1
  91. package/app/.next/server/app/api/cloud/auth/route.js.nft.json +1 -1
  92. package/app/.next/server/app/api/cloud/credentials/update/route.js.nft.json +1 -1
  93. package/app/.next/server/app/api/cloud/model/resolve/route.js.nft.json +1 -1
  94. package/app/.next/server/app/api/cloud/models/alias/route.js.nft.json +1 -1
  95. package/app/.next/server/app/api/combos/[id]/route.js +1 -1
  96. package/app/.next/server/app/api/combos/[id]/route.js.nft.json +1 -1
  97. package/app/.next/server/app/api/combos/builder/options/route.js.nft.json +1 -1
  98. package/app/.next/server/app/api/combos/metrics/route.js.nft.json +1 -1
  99. package/app/.next/server/app/api/combos/reorder/route.js.nft.json +1 -1
  100. package/app/.next/server/app/api/combos/route.js +1 -1
  101. package/app/.next/server/app/api/combos/route.js.nft.json +1 -1
  102. package/app/.next/server/app/api/combos/test/route.js +1 -1
  103. package/app/.next/server/app/api/combos/test/route.js.nft.json +1 -1
  104. package/app/.next/server/app/api/compliance/audit-log/route.js.nft.json +1 -1
  105. package/app/.next/server/app/api/db-backups/export/route.js.nft.json +1 -1
  106. package/app/.next/server/app/api/db-backups/exportAll/route.js.nft.json +1 -1
  107. package/app/.next/server/app/api/db-backups/import/route.js.nft.json +1 -1
  108. package/app/.next/server/app/api/db-backups/route.js.nft.json +1 -1
  109. package/app/.next/server/app/api/evals/[suiteId]/route.js.nft.json +1 -1
  110. package/app/.next/server/app/api/evals/route.js.nft.json +1 -1
  111. package/app/.next/server/app/api/evals/scorecard/route.js.nft.json +1 -1
  112. package/app/.next/server/app/api/evals/suites/[suiteId]/route.js.nft.json +1 -1
  113. package/app/.next/server/app/api/evals/suites/route.js.nft.json +1 -1
  114. package/app/.next/server/app/api/fallback/chains/route.js.nft.json +1 -1
  115. package/app/.next/server/app/api/files/[id]/content/route.js.nft.json +1 -1
  116. package/app/.next/server/app/api/files/route.js.nft.json +1 -1
  117. package/app/.next/server/app/api/init/route.js.nft.json +1 -1
  118. package/app/.next/server/app/api/internal/codex-responses-ws/route.js.nft.json +1 -1
  119. package/app/.next/server/app/api/keys/[id]/reveal/route.js.nft.json +1 -1
  120. package/app/.next/server/app/api/keys/[id]/route.js.nft.json +1 -1
  121. package/app/.next/server/app/api/keys/route.js.nft.json +1 -1
  122. package/app/.next/server/app/api/logs/active/route.js.nft.json +1 -1
  123. package/app/.next/server/app/api/logs/console/route.js.nft.json +1 -1
  124. package/app/.next/server/app/api/logs/detail/route.js.nft.json +1 -1
  125. package/app/.next/server/app/api/logs/export/route.js.nft.json +1 -1
  126. package/app/.next/server/app/api/mcp/sse/route.js.nft.json +1 -1
  127. package/app/.next/server/app/api/mcp/status/route.js.nft.json +1 -1
  128. package/app/.next/server/app/api/mcp/stream/route.js.nft.json +1 -1
  129. package/app/.next/server/app/api/memory/[id]/route.js.nft.json +1 -1
  130. package/app/.next/server/app/api/memory/health/route.js.nft.json +1 -1
  131. package/app/.next/server/app/api/memory/route.js.nft.json +1 -1
  132. package/app/.next/server/app/api/model-combo-mappings/[id]/route.js.nft.json +1 -1
  133. package/app/.next/server/app/api/model-combo-mappings/route.js.nft.json +1 -1
  134. package/app/.next/server/app/api/models/alias/route.js.nft.json +1 -1
  135. package/app/.next/server/app/api/models/catalog/route.js.nft.json +1 -1
  136. package/app/.next/server/app/api/models/openrouter-catalog/route.js.nft.json +1 -1
  137. package/app/.next/server/app/api/models/route.js.nft.json +1 -1
  138. package/app/.next/server/app/api/models/test/route.js.nft.json +1 -1
  139. package/app/.next/server/app/api/monitoring/health/route.js +1 -1
  140. package/app/.next/server/app/api/monitoring/health/route.js.nft.json +1 -1
  141. package/app/.next/server/app/api/oauth/[provider]/[action]/route.js.nft.json +1 -1
  142. package/app/.next/server/app/api/oauth/cursor/auto-import/route.js.nft.json +1 -1
  143. package/app/.next/server/app/api/oauth/cursor/import/route.js.nft.json +1 -1
  144. package/app/.next/server/app/api/oauth/kiro/auto-import/route.js.nft.json +1 -1
  145. package/app/.next/server/app/api/oauth/kiro/import/route.js.nft.json +1 -1
  146. package/app/.next/server/app/api/oauth/kiro/social-exchange/route.js.nft.json +1 -1
  147. package/app/.next/server/app/api/openapi/try/route.js.nft.json +1 -1
  148. package/app/.next/server/app/api/policies/route.js.nft.json +1 -1
  149. package/app/.next/server/app/api/pricing/models/route.js.nft.json +1 -1
  150. package/app/.next/server/app/api/pricing/route.js.nft.json +1 -1
  151. package/app/.next/server/app/api/pricing/sync/route.js.nft.json +1 -1
  152. package/app/.next/server/app/api/provider-metrics/route.js.nft.json +1 -1
  153. package/app/.next/server/app/api/provider-models/route.js.nft.json +1 -1
  154. package/app/.next/server/app/api/provider-nodes/[id]/route.js.nft.json +1 -1
  155. package/app/.next/server/app/api/provider-nodes/route.js.nft.json +1 -1
  156. package/app/.next/server/app/api/provider-nodes/validate/route.js.nft.json +1 -1
  157. package/app/.next/server/app/api/providers/[id]/codex-auth/apply-local/route.js.nft.json +1 -1
  158. package/app/.next/server/app/api/providers/[id]/codex-auth/export/route.js.nft.json +1 -1
  159. package/app/.next/server/app/api/providers/[id]/models/route.js.nft.json +1 -1
  160. package/app/.next/server/app/api/providers/[id]/refresh/route.js.nft.json +1 -1
  161. package/app/.next/server/app/api/providers/[id]/route.js.nft.json +1 -1
  162. package/app/.next/server/app/api/providers/[id]/sync-models/route.js.nft.json +1 -1
  163. package/app/.next/server/app/api/providers/[id]/test/route.js.nft.json +1 -1
  164. package/app/.next/server/app/api/providers/client/route.js.nft.json +1 -1
  165. package/app/.next/server/app/api/providers/route.js.nft.json +1 -1
  166. package/app/.next/server/app/api/providers/test-batch/route.js +1 -1
  167. package/app/.next/server/app/api/providers/test-batch/route.js.nft.json +1 -1
  168. package/app/.next/server/app/api/providers/validate/route.js.nft.json +1 -1
  169. package/app/.next/server/app/api/providers/zed/import/route.js.nft.json +1 -1
  170. package/app/.next/server/app/api/rate-limits/route.js.nft.json +1 -1
  171. package/app/.next/server/app/api/resilience/reset/route.js.nft.json +1 -1
  172. package/app/.next/server/app/api/resilience/route.js.nft.json +1 -1
  173. package/app/.next/server/app/api/restart/route.js.nft.json +1 -1
  174. package/app/.next/server/app/api/search/providers/route.js.nft.json +1 -1
  175. package/app/.next/server/app/api/search/stats/route.js.nft.json +1 -1
  176. package/app/.next/server/app/api/settings/auto-disable-accounts/route.js.nft.json +1 -1
  177. package/app/.next/server/app/api/settings/background-degradation/route.js.nft.json +1 -1
  178. package/app/.next/server/app/api/settings/cache-config/route.js.nft.json +1 -1
  179. package/app/.next/server/app/api/settings/cache-metrics/route.js.nft.json +1 -1
  180. package/app/.next/server/app/api/settings/combo-defaults/route.js.nft.json +1 -1
  181. package/app/.next/server/app/api/settings/export-json/route.js.nft.json +1 -1
  182. package/app/.next/server/app/api/settings/favicon/route.js.nft.json +1 -1
  183. package/app/.next/server/app/api/settings/import-json/route.js.nft.json +1 -1
  184. package/app/.next/server/app/api/settings/ip-filter/route.js.nft.json +1 -1
  185. package/app/.next/server/app/api/settings/lkgp-cache/route.js.nft.json +1 -1
  186. package/app/.next/server/app/api/settings/memory/route.js.nft.json +1 -1
  187. package/app/.next/server/app/api/settings/model-aliases/route.js.nft.json +1 -1
  188. package/app/.next/server/app/api/settings/models-dev/route.js.nft.json +1 -1
  189. package/app/.next/server/app/api/settings/payload-rules/route.js.nft.json +1 -1
  190. package/app/.next/server/app/api/settings/proxies/assignments/route.js.nft.json +1 -1
  191. package/app/.next/server/app/api/settings/proxies/bulk-assign/route.js.nft.json +1 -1
  192. package/app/.next/server/app/api/settings/proxies/health/route.js.nft.json +1 -1
  193. package/app/.next/server/app/api/settings/proxies/migrate/route.js.nft.json +1 -1
  194. package/app/.next/server/app/api/settings/proxies/route.js.nft.json +1 -1
  195. package/app/.next/server/app/api/settings/proxy/route.js.nft.json +1 -1
  196. package/app/.next/server/app/api/settings/proxy/test/route.js.nft.json +1 -1
  197. package/app/.next/server/app/api/settings/purge-logs/route.js.nft.json +1 -1
  198. package/app/.next/server/app/api/settings/require-login/route.js.nft.json +1 -1
  199. package/app/.next/server/app/api/settings/route.js.nft.json +1 -1
  200. package/app/.next/server/app/api/settings/system-prompt/route.js.nft.json +1 -1
  201. package/app/.next/server/app/api/settings/task-routing/route.js.nft.json +1 -1
  202. package/app/.next/server/app/api/settings/thinking-budget/route.js.nft.json +1 -1
  203. package/app/.next/server/app/api/shutdown/route.js.nft.json +1 -1
  204. package/app/.next/server/app/api/skills/[id]/route.js.nft.json +1 -1
  205. package/app/.next/server/app/api/skills/executions/route.js.nft.json +1 -1
  206. package/app/.next/server/app/api/skills/install/route.js.nft.json +1 -1
  207. package/app/.next/server/app/api/skills/marketplace/install/route.js.nft.json +1 -1
  208. package/app/.next/server/app/api/skills/marketplace/route.js.nft.json +1 -1
  209. package/app/.next/server/app/api/skills/route.js.nft.json +1 -1
  210. package/app/.next/server/app/api/skills/skillssh/install/route.js.nft.json +1 -1
  211. package/app/.next/server/app/api/skills/skillssh/route.js.nft.json +1 -1
  212. package/app/.next/server/app/api/storage/health/route.js.nft.json +1 -1
  213. package/app/.next/server/app/api/sync/bundle/route.js.nft.json +1 -1
  214. package/app/.next/server/app/api/sync/cloud/route.js.nft.json +1 -1
  215. package/app/.next/server/app/api/sync/initialize/route.js.nft.json +1 -1
  216. package/app/.next/server/app/api/sync/tokens/[id]/route.js.nft.json +1 -1
  217. package/app/.next/server/app/api/sync/tokens/route.js.nft.json +1 -1
  218. package/app/.next/server/app/api/synced-available-models/route.js.nft.json +1 -1
  219. package/app/.next/server/app/api/system/env/repair/route.js.nft.json +1 -1
  220. package/app/.next/server/app/api/system/version/route.js +1 -1
  221. package/app/.next/server/app/api/system/version/route.js.nft.json +1 -1
  222. package/app/.next/server/app/api/token-health/route.js.nft.json +1 -1
  223. package/app/.next/server/app/api/translator/save/route.js.nft.json +1 -1
  224. package/app/.next/server/app/api/translator/send/route.js.nft.json +1 -1
  225. package/app/.next/server/app/api/translator/translate/route.js.nft.json +1 -1
  226. package/app/.next/server/app/api/tunnels/cloudflared/route.js.nft.json +1 -1
  227. package/app/.next/server/app/api/tunnels/tailscale/check/route.js.nft.json +1 -1
  228. package/app/.next/server/app/api/tunnels/tailscale/disable/route.js.nft.json +1 -1
  229. package/app/.next/server/app/api/tunnels/tailscale/enable/route.js.nft.json +1 -1
  230. package/app/.next/server/app/api/tunnels/tailscale/install/route.js.nft.json +1 -1
  231. package/app/.next/server/app/api/tunnels/tailscale/login/route.js.nft.json +1 -1
  232. package/app/.next/server/app/api/tunnels/tailscale/route.js.nft.json +1 -1
  233. package/app/.next/server/app/api/tunnels/tailscale/start-daemon/route.js.nft.json +1 -1
  234. package/app/.next/server/app/api/upstream-proxy/[providerId]/route.js.nft.json +1 -1
  235. package/app/.next/server/app/api/usage/[connectionId]/route.js.nft.json +1 -1
  236. package/app/.next/server/app/api/usage/analytics/route.js.nft.json +1 -1
  237. package/app/.next/server/app/api/usage/budget/route.js.nft.json +1 -1
  238. package/app/.next/server/app/api/usage/call-logs/[id]/route.js.nft.json +1 -1
  239. package/app/.next/server/app/api/usage/call-logs/route.js.nft.json +1 -1
  240. package/app/.next/server/app/api/usage/combo-health/route.js +1 -1
  241. package/app/.next/server/app/api/usage/combo-health/route.js.nft.json +1 -1
  242. package/app/.next/server/app/api/usage/history/route.js.nft.json +1 -1
  243. package/app/.next/server/app/api/usage/logs/route.js.nft.json +1 -1
  244. package/app/.next/server/app/api/usage/provider-limits/route.js.nft.json +1 -1
  245. package/app/.next/server/app/api/usage/proxy-logs/route.js.nft.json +1 -1
  246. package/app/.next/server/app/api/usage/quota/route.js.nft.json +1 -1
  247. package/app/.next/server/app/api/usage/request-logs/route.js.nft.json +1 -1
  248. package/app/.next/server/app/api/usage/utilization/route.js.nft.json +1 -1
  249. package/app/.next/server/app/api/v1/accounts/[id]/limits/route.js.nft.json +1 -1
  250. package/app/.next/server/app/api/v1/api/chat/route.js.nft.json +1 -1
  251. package/app/.next/server/app/api/v1/audio/speech/route.js.nft.json +1 -1
  252. package/app/.next/server/app/api/v1/audio/transcriptions/route.js.nft.json +1 -1
  253. package/app/.next/server/app/api/v1/batches/[id]/cancel/route.js.nft.json +1 -1
  254. package/app/.next/server/app/api/v1/batches/[id]/route.js.nft.json +1 -1
  255. package/app/.next/server/app/api/v1/batches/route.js.nft.json +1 -1
  256. package/app/.next/server/app/api/v1/chat/completions/route.js.nft.json +1 -1
  257. package/app/.next/server/app/api/v1/completions/route.js.nft.json +1 -1
  258. package/app/.next/server/app/api/v1/db/health/route.js.nft.json +1 -1
  259. package/app/.next/server/app/api/v1/embeddings/route.js.nft.json +1 -1
  260. package/app/.next/server/app/api/v1/files/[id]/content/route.js.nft.json +1 -1
  261. package/app/.next/server/app/api/v1/files/[id]/route.js.nft.json +1 -1
  262. package/app/.next/server/app/api/v1/files/route.js.nft.json +1 -1
  263. package/app/.next/server/app/api/v1/images/edits/route.js.nft.json +1 -1
  264. package/app/.next/server/app/api/v1/images/generations/route.js.nft.json +1 -1
  265. package/app/.next/server/app/api/v1/issues/report/route.js.nft.json +1 -1
  266. package/app/.next/server/app/api/v1/management/proxies/assignments/route.js.nft.json +1 -1
  267. package/app/.next/server/app/api/v1/management/proxies/bulk-assign/route.js.nft.json +1 -1
  268. package/app/.next/server/app/api/v1/management/proxies/health/route.js.nft.json +1 -1
  269. package/app/.next/server/app/api/v1/management/proxies/route.js.nft.json +1 -1
  270. package/app/.next/server/app/api/v1/messages/count_tokens/route.js.nft.json +1 -1
  271. package/app/.next/server/app/api/v1/messages/route.js.nft.json +1 -1
  272. package/app/.next/server/app/api/v1/models/route.js.nft.json +1 -1
  273. package/app/.next/server/app/api/v1/moderations/route.js.nft.json +1 -1
  274. package/app/.next/server/app/api/v1/music/generations/route.js.nft.json +1 -1
  275. package/app/.next/server/app/api/v1/providers/[provider]/chat/completions/route.js.nft.json +1 -1
  276. package/app/.next/server/app/api/v1/providers/[provider]/embeddings/route.js.nft.json +1 -1
  277. package/app/.next/server/app/api/v1/providers/[provider]/images/generations/route.js.nft.json +1 -1
  278. package/app/.next/server/app/api/v1/providers/[provider]/limits/route.js.nft.json +1 -1
  279. package/app/.next/server/app/api/v1/quotas/check/route.js.nft.json +1 -1
  280. package/app/.next/server/app/api/v1/registered-keys/[id]/revoke/route.js.nft.json +1 -1
  281. package/app/.next/server/app/api/v1/registered-keys/[id]/route.js.nft.json +1 -1
  282. package/app/.next/server/app/api/v1/registered-keys/route.js.nft.json +1 -1
  283. package/app/.next/server/app/api/v1/rerank/route.js.nft.json +1 -1
  284. package/app/.next/server/app/api/v1/responses/[...path]/route.js.nft.json +1 -1
  285. package/app/.next/server/app/api/v1/responses/route.js.nft.json +1 -1
  286. package/app/.next/server/app/api/v1/route.js.nft.json +1 -1
  287. package/app/.next/server/app/api/v1/search/analytics/route.js.nft.json +1 -1
  288. package/app/.next/server/app/api/v1/search/route.js.nft.json +1 -1
  289. package/app/.next/server/app/api/v1/videos/generations/route.js.nft.json +1 -1
  290. package/app/.next/server/app/api/v1/ws/route.js.nft.json +1 -1
  291. package/app/.next/server/app/api/v1beta/models/[...path]/route.js.nft.json +1 -1
  292. package/app/.next/server/app/api/v1beta/models/route.js.nft.json +1 -1
  293. package/app/.next/server/app/api/version-manager/check-update/route.js +1 -1
  294. package/app/.next/server/app/api/version-manager/check-update/route.js.nft.json +1 -1
  295. package/app/.next/server/app/api/version-manager/install/route.js +1 -1
  296. package/app/.next/server/app/api/version-manager/install/route.js.nft.json +1 -1
  297. package/app/.next/server/app/api/version-manager/restart/route.js +1 -1
  298. package/app/.next/server/app/api/version-manager/restart/route.js.nft.json +1 -1
  299. package/app/.next/server/app/api/version-manager/start/route.js +1 -1
  300. package/app/.next/server/app/api/version-manager/start/route.js.nft.json +1 -1
  301. package/app/.next/server/app/api/version-manager/status/route.js +1 -1
  302. package/app/.next/server/app/api/version-manager/status/route.js.nft.json +1 -1
  303. package/app/.next/server/app/api/version-manager/stop/route.js +1 -1
  304. package/app/.next/server/app/api/version-manager/stop/route.js.nft.json +1 -1
  305. package/app/.next/server/app/api/webhooks/[id]/route.js.nft.json +1 -1
  306. package/app/.next/server/app/api/webhooks/[id]/test/route.js.nft.json +1 -1
  307. package/app/.next/server/app/api/webhooks/route.js.nft.json +1 -1
  308. package/app/.next/server/app/callback/page_client-reference-manifest.js +1 -1
  309. package/app/.next/server/app/docs/page.js +1 -1
  310. package/app/.next/server/app/docs/page_client-reference-manifest.js +1 -1
  311. package/app/.next/server/app/forbidden/page_client-reference-manifest.js +1 -1
  312. package/app/.next/server/app/forgot-password/page_client-reference-manifest.js +1 -1
  313. package/app/.next/server/app/landing/page_client-reference-manifest.js +1 -1
  314. package/app/.next/server/app/login/page_client-reference-manifest.js +1 -1
  315. package/app/.next/server/app/maintenance/page_client-reference-manifest.js +1 -1
  316. package/app/.next/server/app/offline/page_client-reference-manifest.js +1 -1
  317. package/app/.next/server/app/page_client-reference-manifest.js +1 -1
  318. package/app/.next/server/app/privacy/page_client-reference-manifest.js +1 -1
  319. package/app/.next/server/app/status/page_client-reference-manifest.js +1 -1
  320. package/app/.next/server/app/terms/page_client-reference-manifest.js +1 -1
  321. package/app/.next/server/app-paths-manifest.json +15 -15
  322. package/app/.next/server/chunks/12767.js +1 -1
  323. package/app/.next/server/chunks/19849.js +1 -1
  324. package/app/.next/server/chunks/20236.js +1 -1
  325. package/app/.next/server/chunks/36040.js +4 -4
  326. package/app/.next/server/chunks/3832.js +1 -1
  327. package/app/.next/server/chunks/39548.js +1 -1
  328. package/app/.next/server/chunks/39859.js +1 -1
  329. package/app/.next/server/chunks/44088.js +1 -1
  330. package/app/.next/server/chunks/45415.js +1 -1
  331. package/app/.next/server/chunks/55672.js +1 -0
  332. package/app/.next/server/chunks/59092.js +2 -2
  333. package/app/.next/server/chunks/66094.js +1 -1
  334. package/app/.next/server/chunks/69105.js +1 -1
  335. package/app/.next/server/chunks/75225.js +1 -1
  336. package/app/.next/server/chunks/77044.js +1 -1
  337. package/app/.next/server/chunks/83648.js +1 -1
  338. package/app/.next/server/chunks/93831.js +4 -4
  339. package/app/.next/server/chunks/9679.js +3 -3
  340. package/app/.next/server/chunks/99168.js +2 -2
  341. package/app/.next/server/middleware-build-manifest.js +1 -1
  342. package/app/.next/server/middleware-react-loadable-manifest.js +1 -1
  343. package/app/.next/server/middleware.js +2 -2
  344. package/app/.next/server/pages/500.html +1 -1
  345. package/app/.next/server/server-reference-manifest.js +1 -1
  346. package/app/.next/server/server-reference-manifest.json +1 -1
  347. package/app/.next/static/chunks/{1999-fefe90c60eaa3b23.js → 1999-8cf58c233346f980.js} +1 -1
  348. package/app/.next/static/chunks/app/(dashboard)/dashboard/cache/media/page-ad8091c5b7536b7a.js +1 -0
  349. package/app/.next/static/chunks/app/(dashboard)/dashboard/logs/page-ccc65d29bbb19d51.js +1 -0
  350. package/app/.next/static/chunks/app/{layout-3e3b043f9b52bb80.js → layout-fbebdd84c4996160.js} +1 -1
  351. package/app/.next/static/chunks/{webpack-117eac5998a94c69.js → webpack-ea5983ad4b51e934.js} +1 -1
  352. package/app/.next/static/css/7caa8a6802c65def.css +1 -0
  353. package/app/docs/openapi.yaml +1 -1
  354. package/app/open-sse/mcp-server/server.js +15 -1
  355. package/app/package.json +1 -1
  356. package/package.json +1 -1
  357. package/app/.next/server/chunks/80812.js +0 -1
  358. package/app/.next/static/chunks/app/(dashboard)/dashboard/cache/media/page-f0289617f824bbf2.js +0 -1
  359. package/app/.next/static/chunks/app/(dashboard)/dashboard/logs/page-f24fde8a3f731108.js +0 -1
  360. package/app/.next/static/css/8d36e4e21725013b.css +0 -1
  361. /package/app/.next/static/{yvJ6rPtn4eb7sOBUCBGrF → qmeYzerLcoUXZ06JXgit3}/_buildManifest.js +0 -0
  362. /package/app/.next/static/{yvJ6rPtn4eb7sOBUCBGrF → qmeYzerLcoUXZ06JXgit3}/_ssgManifest.js +0 -0
@@ -1,4 +1,4 @@
1
- "use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[1999],{1652:(e,t,r)=>{r.d(t,{default:()=>d});var s=r(95155),a=r(12115),l=r(14051),o=r.n(l),n=r(71361),i=r(35806),c=r(34422);function d({isOpen:e,providerId:t="kiro",providerLabel:r="Kiro",onMethodSelect:l,onClose:o}){let[x,m]=(0,a.useState)(null),[u,p]=(0,a.useState)(""),[h,b]=(0,a.useState)("us-east-1"),[f,g]=(0,a.useState)(""),[y,j]=(0,a.useState)(null),[v,N]=(0,a.useState)(!1),[k,w]=(0,a.useState)(!1),[C,S]=(0,a.useState)(!1);(0,a.useEffect)(()=>{"import"===x&&e&&(async()=>{w(!0),j(null),S(!1);try{let e=await fetch(`/api/oauth/kiro/auto-import?targetProvider=${encodeURIComponent(t)}`),r=await e.json();r.found?(g(r.refreshToken),S(!0)):j(r.error||"Could not auto-detect token")}catch(e){j("Failed to auto-detect token")}finally{w(!1)}})()},[t,x,e]);let A=e=>{m(e),j(null)},T=()=>{m(null),j(null)},I=async()=>{if(!f.trim())return void j("Please enter a refresh token");N(!0),j(null);try{let e=await fetch(`/api/oauth/kiro/import?targetProvider=${encodeURIComponent(t)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({refreshToken:f.trim()})}),r=await e.json();if(!e.ok)throw Error(r.error||"Import failed");o()}catch(e){j(e.message)}finally{N(!1)}},M=e=>{l("social",{provider:e})};return(0,s.jsx)(n.default,{isOpen:e,title:`Connect ${r}`,onClose:o,size:"lg",children:(0,s.jsxs)("div",{className:"flex flex-col gap-4",children:[!x&&(0,s.jsxs)("div",{className:"space-y-3",children:[(0,s.jsx)("p",{className:"text-sm text-text-muted mb-4",children:"Choose your authentication method:"}),(0,s.jsx)("button",{onClick:()=>l("builder-id"),className:"w-full p-4 text-left border border-border rounded-lg hover:bg-sidebar transition-colors",children:(0,s.jsxs)("div",{className:"flex items-start gap-3",children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-primary mt-0.5",children:"shield"}),(0,s.jsxs)("div",{className:"flex-1",children:[(0,s.jsx)("h3",{className:"font-semibold mb-1",children:"AWS Builder ID"}),(0,s.jsxs)("p",{className:"text-sm text-text-muted",children:["Recommended for most users. Sign in with the AWS account linked to"," ",r,"."]})]})]})}),(0,s.jsx)("button",{onClick:()=>A("idc"),className:"hidden w-full p-4 text-left border border-border rounded-lg hover:bg-sidebar transition-colors",children:(0,s.jsxs)("div",{className:"flex items-start gap-3",children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-primary mt-0.5",children:"business"}),(0,s.jsxs)("div",{className:"flex-1",children:[(0,s.jsx)("h3",{className:"font-semibold mb-1",children:"AWS IAM Identity Center"}),(0,s.jsx)("p",{className:"text-sm text-text-muted",children:"For enterprise users with custom AWS IAM Identity Center."})]})]})}),(0,s.jsx)("button",{onClick:()=>A("social-google"),className:"hidden w-full p-4 text-left border border-border rounded-lg hover:bg-sidebar transition-colors",children:(0,s.jsxs)("div",{className:"flex items-start gap-3",children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-primary mt-0.5",children:"account_circle"}),(0,s.jsxs)("div",{className:"flex-1",children:[(0,s.jsx)("h3",{className:"font-semibold mb-1",children:"Google Account"}),(0,s.jsx)("p",{className:"text-sm text-text-muted",children:"Login with your Google account (manual callback)."})]})]})}),(0,s.jsx)("button",{onClick:()=>A("social-github"),className:"hidden w-full p-4 text-left border border-border rounded-lg hover:bg-sidebar transition-colors",children:(0,s.jsxs)("div",{className:"flex items-start gap-3",children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-primary mt-0.5",children:"code"}),(0,s.jsxs)("div",{className:"flex-1",children:[(0,s.jsx)("h3",{className:"font-semibold mb-1",children:"GitHub Account"}),(0,s.jsx)("p",{className:"text-sm text-text-muted",children:"Login with your GitHub account (manual callback)."})]})]})}),(0,s.jsx)("button",{onClick:()=>A("import"),className:"w-full p-4 text-left border border-border rounded-lg hover:bg-sidebar transition-colors",children:(0,s.jsxs)("div",{className:"flex items-start gap-3",children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-primary mt-0.5",children:"file_upload"}),(0,s.jsxs)("div",{className:"flex-1",children:[(0,s.jsx)("h3",{className:"font-semibold mb-1",children:"Import Token"}),(0,s.jsxs)("p",{className:"text-sm text-text-muted",children:["Paste a refresh token exported from ",r,"."]})]})]})})]}),"idc"===x&&(0,s.jsxs)("div",{className:"space-y-4",children:[(0,s.jsxs)("div",{children:[(0,s.jsxs)("label",{className:"block text-sm font-medium mb-2",children:["IDC Start URL ",(0,s.jsx)("span",{className:"text-red-500",children:"*"})]}),(0,s.jsx)(c.default,{value:u,onChange:e=>p(e.target.value),placeholder:"https://your-org.awsapps.com/start",className:"font-mono text-sm"}),(0,s.jsx)("p",{className:"text-xs text-text-muted mt-1",children:"Your organization's AWS IAM Identity Center URL"})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{className:"block text-sm font-medium mb-2",children:"AWS Region"}),(0,s.jsx)(c.default,{value:h,onChange:e=>b(e.target.value),placeholder:"us-east-1",className:"font-mono text-sm"}),(0,s.jsx)("p",{className:"text-xs text-text-muted mt-1",children:"AWS region for your Identity Center (default: us-east-1)"})]}),y&&(0,s.jsx)("p",{className:"text-sm text-red-600",children:y}),(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsx)(i.default,{onClick:()=>{u.trim()?l("idc",{startUrl:u.trim(),region:h}):j("Please enter your IDC start URL")},fullWidth:!0,children:"Continue"}),(0,s.jsx)(i.default,{onClick:T,variant:"ghost",fullWidth:!0,children:"Back"})]})]}),"social-google"===x&&(0,s.jsxs)("div",{className:"space-y-4",children:[(0,s.jsx)("div",{className:"bg-amber-50 dark:bg-amber-900/20 p-4 rounded-lg border border-amber-200 dark:border-amber-800",children:(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-amber-600 dark:text-amber-400",children:"info"}),(0,s.jsxs)("div",{className:"flex-1 text-sm",children:[(0,s.jsx)("p",{className:"font-medium text-amber-900 dark:text-amber-100 mb-1",children:"Manual Callback Required"}),(0,s.jsx)("p",{className:"text-amber-800 dark:text-amber-200",children:"After login, you'll need to copy the callback URL from your browser and paste it back here."})]})]})}),(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsx)(i.default,{onClick:()=>M("google"),fullWidth:!0,children:"Continue with Google"}),(0,s.jsx)(i.default,{onClick:T,variant:"ghost",fullWidth:!0,children:"Back"})]})]}),"social-github"===x&&(0,s.jsxs)("div",{className:"space-y-4",children:[(0,s.jsx)("div",{className:"bg-amber-50 dark:bg-amber-900/20 p-4 rounded-lg border border-amber-200 dark:border-amber-800",children:(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-amber-600 dark:text-amber-400",children:"info"}),(0,s.jsxs)("div",{className:"flex-1 text-sm",children:[(0,s.jsx)("p",{className:"font-medium text-amber-900 dark:text-amber-100 mb-1",children:"Manual Callback Required"}),(0,s.jsx)("p",{className:"text-amber-800 dark:text-amber-200",children:"After login, you'll need to copy the callback URL from your browser and paste it back here."})]})]})}),(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsx)(i.default,{onClick:()=>M("github"),fullWidth:!0,children:"Continue with GitHub"}),(0,s.jsx)(i.default,{onClick:T,variant:"ghost",fullWidth:!0,children:"Back"})]})]}),"import"===x&&(0,s.jsxs)("div",{className:"space-y-4",children:[k&&(0,s.jsxs)("div",{className:"text-center py-6",children:[(0,s.jsx)("div",{className:"size-16 mx-auto mb-4 rounded-full bg-primary/10 flex items-center justify-center",children:(0,s.jsx)("span",{className:"material-symbols-outlined text-3xl text-primary animate-spin",children:"progress_activity"})}),(0,s.jsx)("h3",{className:"text-lg font-semibold mb-2",children:"Auto-detecting token..."}),(0,s.jsxs)("p",{className:"text-sm text-text-muted",children:["Reading ",r," credentials from AWS SSO cache"]})]}),!k&&(0,s.jsxs)(s.Fragment,{children:[C&&(0,s.jsx)("div",{className:"bg-green-50 dark:bg-green-900/20 p-3 rounded-lg border border-green-200 dark:border-green-800",children:(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-green-600 dark:text-green-400",children:"check_circle"}),(0,s.jsxs)("p",{className:"text-sm text-green-800 dark:text-green-200",children:["Token auto-detected from ",r," successfully!"]})]})}),!C&&!y&&(0,s.jsx)("div",{className:"bg-blue-50 dark:bg-blue-900/20 p-3 rounded-lg border border-blue-200 dark:border-blue-800",children:(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-blue-600 dark:text-blue-400",children:"info"}),(0,s.jsxs)("p",{className:"text-sm text-blue-800 dark:text-blue-200",children:[r," token was not auto-detected. Please paste your refresh token manually."]})]})}),(0,s.jsxs)("div",{children:[(0,s.jsxs)("label",{className:"block text-sm font-medium mb-2",children:["Refresh Token ",(0,s.jsx)("span",{className:"text-red-500",children:"*"})]}),(0,s.jsx)(c.default,{value:f,onChange:e=>g(e.target.value),placeholder:"Token will be auto-filled...",className:"font-mono text-sm"})]}),y&&(0,s.jsx)("div",{className:"bg-red-50 dark:bg-red-900/20 p-3 rounded-lg border border-red-200 dark:border-red-800",children:(0,s.jsx)("p",{className:"text-sm text-red-600 dark:text-red-400",children:y})}),(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsx)(i.default,{onClick:I,fullWidth:!0,disabled:v||!f.trim(),children:v?"Importing...":"Import Token"}),(0,s.jsx)(i.default,{onClick:T,variant:"ghost",fullWidth:!0,children:"Back"})]})]})]})]})})}d.propTypes={isOpen:o().bool.isRequired,providerId:o().string,providerLabel:o().string,onMethodSelect:o().func.isRequired,onClose:o().func.isRequired}},6261:(e,t,r)=>{r.d(t,{default:()=>o});var s=r(95155),a=r(97550),l=r(67040);function o({className:e,variant:t="default"}){let{theme:r,toggleTheme:n,isDark:i}=(0,a.D)(),c={default:(0,l.cn)("flex items-center justify-center size-10 rounded-full","text-text-muted","hover:bg-black/5","hover:text-text-main","transition-colors"),card:(0,l.cn)("flex items-center justify-center size-11 rounded-full","bg-surface/60","hover:bg-surface","border border-border","backdrop-blur-md shadow-sm hover:shadow-md","text-text-muted-light hover:text-primary","hover:text-primary","transition-all group")};return(0,s.jsx)("button",{onClick:n,className:(0,l.cn)(c[t],e),"aria-label":`Switch to ${i?"light":"dark"} mode`,title:`Switch to ${i?"light":"dark"} mode`,children:(0,s.jsx)("span",{className:(0,l.cn)("material-symbols-outlined text-[22px]","card"===t&&"transition-transform duration-300 group-hover:rotate-12"),children:i?"light_mode":"dark_mode"})})}},8287:(e,t,r)=>{r.d(t,{default:()=>m});var s=r(95155),a=r(12115),l=r(81060),o=r(99333),n=r(8898);function i({log:e,onClose:t}){(0,a.useEffect)(()=>{let e=e=>{"Escape"===e.key&&t()};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[t]);let r=(0,o.Yh)(e.status),l=o.Gp[e.proxy?.type]||{bg:"#6B7280",text:"#fff",label:e.proxy?.type||"-"},c=o.Ie[e.level]||o.Ie.direct,d=o.RY[e.provider]||{bg:"#374151",text:"#fff",label:(e.provider||"-").toUpperCase()};return(0,s.jsxs)("div",{className:"fixed inset-0 z-50 flex items-start justify-center pt-[5vh]",onClick:t,role:"dialog","aria-modal":"true","aria-label":"Proxy log detail",children:[(0,s.jsx)("div",{className:"absolute inset-0 bg-black/60 backdrop-blur-sm"}),(0,s.jsxs)("div",{className:"relative bg-bg-primary border border-border rounded-xl w-full max-w-[700px] max-h-[90vh] overflow-y-auto shadow-2xl",onClick:e=>e.stopPropagation(),children:[(0,s.jsxs)("div",{className:"sticky top-0 z-10 flex items-center justify-between px-6 py-4 border-b border-border bg-bg-primary/95 backdrop-blur-sm rounded-t-xl",children:[(0,s.jsxs)("div",{className:"flex items-center gap-3",children:[(0,s.jsx)("span",{className:"inline-block px-2.5 py-1 rounded text-xs font-bold uppercase",style:{backgroundColor:r.bg,color:r.text},children:e.status}),(0,s.jsx)("span",{className:"font-bold text-lg",children:"Proxy Event"})]}),(0,s.jsx)("button",{onClick:t,className:"p-1.5 rounded-lg hover:bg-bg-subtle text-text-muted hover:text-text-primary transition-colors","aria-label":"Close proxy detail modal",children:(0,s.jsx)("span",{className:"material-symbols-outlined",children:"close"})})]}),(0,s.jsxs)("div",{className:"p-6 flex flex-col gap-6",children:[(0,s.jsxs)("div",{className:"grid grid-cols-2 md:grid-cols-3 gap-4 p-4 bg-bg-subtle rounded-xl border border-border",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("div",{className:"text-[10px] text-text-muted uppercase tracking-wider mb-1",children:"Time"}),(0,s.jsx)("div",{className:"text-sm font-medium",children:(e=>{try{let t=new Date(e);return t.toLocaleDateString("pt-BR")+", "+t.toLocaleTimeString("en-US",{hour12:!1})}catch{return e}})(e.timestamp)})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("div",{className:"text-[10px] text-text-muted uppercase tracking-wider mb-1",children:"Latency"}),(0,s.jsx)("div",{className:"text-sm font-medium",children:(0,n.a3)(e.latencyMs)})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("div",{className:"text-[10px] text-text-muted uppercase tracking-wider mb-1",children:"Public IP"}),(0,s.jsx)("div",{className:"text-sm font-medium font-mono text-emerald-400",children:e.publicIp||"—"})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("div",{className:"text-[10px] text-text-muted uppercase tracking-wider mb-1",children:"Proxy"}),(0,s.jsx)("div",{className:"text-sm font-medium font-mono text-primary",children:e.proxy?`${e.proxy.type}://${e.proxy.host}:${e.proxy.port}`:"Direct"})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("div",{className:"text-[10px] text-text-muted uppercase tracking-wider mb-1",children:"Type"}),(0,s.jsx)("span",{className:"inline-block px-2.5 py-1 rounded text-[10px] font-bold uppercase",style:{backgroundColor:l.bg,color:l.text},children:l.label})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("div",{className:"text-[10px] text-text-muted uppercase tracking-wider mb-1",children:"Level"}),(0,s.jsx)("span",{className:"inline-block px-2.5 py-1 rounded text-[10px] font-bold uppercase",style:{backgroundColor:c.bg,color:c.text},children:c.label})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("div",{className:"text-[10px] text-text-muted uppercase tracking-wider mb-1",children:"Provider"}),e.provider?(0,s.jsx)("span",{className:"inline-block px-2.5 py-1 rounded text-[10px] font-bold uppercase",style:{backgroundColor:d.bg,color:d.text},children:d.label}):(0,s.jsx)("div",{className:"text-sm text-text-muted",children:"—"})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("div",{className:"text-[10px] text-text-muted uppercase tracking-wider mb-1",children:"TLS Fingerprint"}),e.tlsFingerprint?(0,s.jsxs)("span",{className:"inline-flex items-center gap-1 px-2.5 py-1 rounded text-[10px] font-bold uppercase",style:{backgroundColor:"rgba(6, 182, 212, 0.15)",color:"#22d3ee"},children:[(0,s.jsx)("span",{style:{fontSize:"12px"},children:"\uD83D\uDD12"})," Chrome 124"]}):(0,s.jsx)("div",{className:"text-sm text-text-muted",children:"Direct (native)"})]}),(0,s.jsxs)("div",{className:"col-span-2",children:[(0,s.jsx)("div",{className:"text-[10px] text-text-muted uppercase tracking-wider mb-1",children:"Target URL"}),(0,s.jsx)("div",{className:"text-sm font-medium font-mono text-text-muted break-all",children:e.targetUrl||"—"})]})]}),e.error&&(0,s.jsxs)("div",{className:"p-4 rounded-xl bg-red-500/10 border border-red-500/30",children:[(0,s.jsx)("div",{className:"text-[10px] text-red-400 uppercase tracking-wider mb-1 font-bold",children:"Error"}),(0,s.jsx)("div",{className:"text-sm text-red-300 font-mono",children:e.error})]}),e.proxy&&(0,s.jsxs)("div",{className:"p-4 rounded-xl bg-bg-subtle border border-border",children:[(0,s.jsx)("div",{className:"text-[10px] text-text-muted uppercase tracking-wider mb-2 font-bold",children:"Proxy Configuration"}),(0,s.jsx)("pre",{className:"text-xs font-mono text-text-primary bg-black/20 rounded-lg p-3 overflow-x-auto",children:JSON.stringify(e.proxy,null,2)})]})]})]})]})}let c=[{key:"all",label:"All"},{key:"error",label:"Errors",icon:"error"},{key:"ok",label:"Success",icon:"check_circle"},{key:"timeout",label:"Timeout",icon:"timer_off"}],d=[{key:"status",label:"Status"},{key:"proxy",label:"Proxy"},{key:"tls",label:"TLS"},{key:"type",label:"Type"},{key:"level",label:"Level"},{key:"provider",label:"Provider"},{key:"target",label:"Target"},{key:"latency",label:"Latency"},{key:"ip",label:"Public IP"},{key:"time",label:"Time"}],x=Object.fromEntries(d.map(e=>[e.key,!0]));function m(){let[e,t]=(0,a.useState)([]),[r,m]=(0,a.useState)(!0),[u,p]=(0,a.useState)(!0),[h,b]=(0,a.useState)(""),[f,g]=(0,a.useState)("all"),[y,j]=(0,a.useState)(""),[v,N]=(0,a.useState)(""),[k,w]=(0,a.useState)(""),[C,S]=(0,a.useState)("newest"),[A,T]=(0,a.useState)(null),I=(0,a.useRef)(null),M=(0,a.useRef)(!1),O=(0,a.useRef)(""),[R,L]=(0,a.useState)(()=>{try{let e=localStorage.getItem("proxyLoggerVisibleColumns");return e?{...x,...JSON.parse(e)}:x}catch{return x}}),E=(0,a.useCallback)(e=>{L(t=>{let r={...t,[e]:!t[e]};try{localStorage.setItem("proxyLoggerVisibleColumns",JSON.stringify(r))}catch{}return r})},[]),_=(0,a.useCallback)(async(e=!1)=>{e&&m(!0);try{let e=new URLSearchParams;h&&e.set("search",h),"error"===f&&e.set("status","error"),"ok"===f&&e.set("status","ok"),"timeout"===f&&e.set("status","timeout"),y&&e.set("type",y),v&&e.set("provider",v),k&&e.set("level",k),e.set("limit","300");let r=await fetch(`/api/usage/proxy-logs?${e}`);if(r.ok){let e=await r.json(),s=JSON.stringify(e.map?.(e=>e.id)??[]);s!==O.current&&(O.current=s,t(e))}}catch(e){console.error("Failed to fetch proxy logs:",e)}finally{e&&m(!1)}},[h,f,y,v,k]);(0,a.useEffect)(()=>{let e=!M.current;M.current=!0,_(e)},[_]),(0,a.useEffect)(()=>(I.current&&clearInterval(I.current),u&&(I.current=setInterval(()=>_(!1),3e3)),()=>{I.current&&clearInterval(I.current)}),[u,_]);let F=(0,a.useMemo)(()=>{let t=[...e];return t.sort((e,t)=>{switch(C){case"oldest":return new Date(e.timestamp).getTime()-new Date(t.timestamp).getTime();case"latency_desc":return(t.latencyMs||0)-(e.latencyMs||0);case"latency_asc":return(e.latencyMs||0)-(t.latencyMs||0);default:return new Date(t.timestamp).getTime()-new Date(e.timestamp).getTime()}}),t},[e,C]),$=[...new Set(e.map(e=>e.provider).filter(Boolean))].sort(),D=[...new Set(e.map(e=>e.proxy?.type).filter(Boolean))].sort(),P=[...new Set(e.map(e=>e.level).filter(Boolean))].sort(),K=e.length,z=e.filter(e=>"success"===e.status).length,q=e.filter(e=>"error"===e.status).length,B=e.filter(e=>"timeout"===e.status).length,U=e.filter(e=>"direct"===e.level).length,W=e.filter(e=>e.tlsFingerprint).length;return(0,s.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,s.jsxs)("div",{className:"flex flex-wrap items-center gap-3",children:[(0,s.jsxs)("button",{onClick:()=>p(!u),className:`flex items-center gap-2 px-3 py-1.5 rounded-full text-sm font-medium border transition-colors ${u?"bg-red-500/10 border-red-500/30 text-red-400":"bg-bg-subtle border-border text-text-muted"}`,children:[(0,s.jsx)("span",{className:`w-2 h-2 rounded-full ${u?"bg-red-500 animate-pulse":"bg-text-muted"}`}),u?"Recording":"Paused"]}),(0,s.jsxs)("div",{className:"flex-1 min-w-[200px] relative",children:[(0,s.jsx)("span",{className:"material-symbols-outlined absolute left-3 top-1/2 -translate-y-1/2 text-text-muted text-[18px]",children:"search"}),(0,s.jsx)("input",{type:"text",placeholder:"Search host, provider, target, IP...",value:h,onChange:e=>b(e.target.value),className:"w-full pl-10 pr-4 py-2 rounded-lg bg-bg-subtle border border-border text-sm text-text-primary placeholder:text-text-muted focus:outline-none focus:border-primary"})]}),(0,s.jsxs)("select",{value:y,onChange:e=>j(e.target.value),className:"px-3 py-2 rounded-lg bg-bg-subtle border border-border text-sm text-text-primary focus:outline-none focus:border-primary appearance-none cursor-pointer min-w-[120px]",children:[(0,s.jsx)("option",{value:"",children:"All Types"}),D.map(e=>(0,s.jsx)("option",{value:e,children:(o.Gp[e]?.label||e).toUpperCase()},e))]}),(0,s.jsxs)("select",{value:k,onChange:e=>w(e.target.value),className:"px-3 py-2 rounded-lg bg-bg-subtle border border-border text-sm text-text-primary focus:outline-none focus:border-primary appearance-none cursor-pointer min-w-[120px]",children:[(0,s.jsx)("option",{value:"",children:"All Levels"}),P.map(e=>(0,s.jsx)("option",{value:e,children:o.Ie[e]?.label||e},e))]}),(0,s.jsxs)("select",{value:v,onChange:e=>N(e.target.value),className:"px-3 py-2 rounded-lg bg-bg-subtle border border-border text-sm text-text-primary focus:outline-none focus:border-primary appearance-none cursor-pointer min-w-[140px]",children:[(0,s.jsx)("option",{value:"",children:"All Providers"}),$.map(e=>{let t=o.RY[e];return(0,s.jsx)("option",{value:e,children:t?.label||e.toUpperCase()},e)})]}),(0,s.jsxs)("div",{className:"flex items-center gap-2 text-xs text-text-muted",children:[(0,s.jsxs)("span",{className:"px-2 py-1 rounded bg-bg-subtle border border-border font-mono",children:[K," total"]}),(0,s.jsxs)("span",{className:"px-2 py-1 rounded bg-emerald-500/10 text-emerald-400 font-mono",children:[z," OK"]}),q>0&&(0,s.jsxs)("span",{className:"px-2 py-1 rounded bg-red-500/10 text-red-400 font-mono",children:[q," ERR"]}),B>0&&(0,s.jsxs)("span",{className:"px-2 py-1 rounded bg-amber-500/10 text-amber-400 font-mono",children:[B," TMO"]}),U>0&&(0,s.jsxs)("span",{className:"px-2 py-1 rounded bg-gray-500/10 text-gray-400 font-mono",children:[U," direct"]}),W>0&&(0,s.jsxs)("span",{className:"px-2 py-1 rounded bg-cyan-500/10 text-cyan-400 font-mono",children:["\uD83D\uDD12 ",W," TLS"]})]}),(0,s.jsxs)("select",{value:C,onChange:e=>S(e.target.value),className:"px-3 py-2 rounded-lg bg-bg-subtle border border-border text-sm text-text-primary focus:outline-none focus:border-primary appearance-none cursor-pointer min-w-[140px]",children:[(0,s.jsx)("option",{value:"newest",children:"Newest"}),(0,s.jsx)("option",{value:"oldest",children:"Oldest"}),(0,s.jsx)("option",{value:"latency_desc",children:"Latency ↓"}),(0,s.jsx)("option",{value:"latency_asc",children:"Latency ↑"})]}),(0,s.jsx)("button",{onClick:()=>_(!1),className:"p-2 rounded-lg hover:bg-bg-subtle text-text-muted hover:text-text-primary transition-colors",title:"Refresh",children:(0,s.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:"refresh"})})]}),(0,s.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[c.map(e=>(0,s.jsxs)("button",{onClick:()=>g(f===e.key?"all":e.key),className:`flex items-center gap-1.5 px-3 py-1 rounded-full text-xs font-medium border transition-all ${f===e.key?"error"===e.key?"bg-red-500/20 text-red-400 border-red-500/40":"ok"===e.key?"bg-emerald-500/20 text-emerald-400 border-emerald-500/40":"timeout"===e.key?"bg-amber-500/20 text-amber-400 border-amber-500/40":"bg-primary text-white border-primary":"bg-bg-subtle border-border text-text-muted hover:border-text-muted"}`,children:[e.icon&&(0,s.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:e.icon}),e.label]},e.key)),$.length>0&&(0,s.jsx)("span",{className:"w-px h-5 bg-border mx-1"}),$.map(e=>{let t=o.RY[e]||{bg:"#374151",text:"#fff",label:e.toUpperCase()},r=v===e;return(0,s.jsx)("button",{onClick:()=>N(r?"":e),className:`px-3 py-1 rounded-full text-xs font-bold uppercase border transition-all ${r?"border-white/40 ring-1 ring-white/20":"border-transparent opacity-70 hover:opacity-100"}`,style:{backgroundColor:r?t.bg:`${t.bg}33`,color:r?t.text:t.bg},children:t.label},e)})]}),(0,s.jsxs)("div",{className:"flex flex-wrap items-center gap-1.5",children:[(0,s.jsx)("span",{className:"text-[10px] text-text-muted uppercase tracking-wider mr-1",children:"Columns"}),d.map(e=>(0,s.jsx)("button",{onClick:()=>E(e.key),className:`px-2 py-0.5 rounded text-[10px] font-medium border transition-all ${R[e.key]?"bg-primary/15 text-primary border-primary/30":"bg-bg-subtle text-text-muted border-border opacity-50 hover:opacity-80"}`,children:e.label},e.key))]}),(0,s.jsx)(l.default,{className:"overflow-hidden bg-black/5 dark:bg-black/20",children:(0,s.jsx)("div",{className:"p-0 overflow-x-auto max-h-[calc(100vh-320px)] overflow-y-auto",children:r&&0===e.length?(0,s.jsx)("div",{className:"p-8 text-center text-text-muted",children:"Loading proxy logs..."}):0===e.length?(0,s.jsxs)("div",{className:"p-8 text-center text-text-muted",children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-[48px] mb-2 block opacity-40",children:"vpn_lock"}),"No proxy logs yet. Configure proxies and make API calls to see them here."]}):0===F.length?(0,s.jsx)("div",{className:"p-8 text-center text-text-muted",children:"No logs match the current filters."}):(0,s.jsxs)("table",{className:"w-full text-left border-collapse text-xs",children:[(0,s.jsx)("thead",{className:"sticky top-0 z-10",style:{backgroundColor:"var(--bg-primary, #0f1117)"},children:(0,s.jsxs)("tr",{className:"border-b border-border",style:{backgroundColor:"var(--bg-primary, #0f1117)"},children:[R.status&&(0,s.jsx)("th",{className:"px-3 py-2.5 font-semibold text-text-muted uppercase tracking-wider text-[10px]",children:"Status"}),R.proxy&&(0,s.jsx)("th",{className:"px-3 py-2.5 font-semibold text-text-muted uppercase tracking-wider text-[10px]",children:"Proxy"}),R.tls&&(0,s.jsx)("th",{className:"px-3 py-2.5 font-semibold text-text-muted uppercase tracking-wider text-[10px]",children:"TLS"}),R.type&&(0,s.jsx)("th",{className:"px-3 py-2.5 font-semibold text-text-muted uppercase tracking-wider text-[10px]",children:"Type"}),R.level&&(0,s.jsx)("th",{className:"px-3 py-2.5 font-semibold text-text-muted uppercase tracking-wider text-[10px]",children:"Level"}),R.provider&&(0,s.jsx)("th",{className:"px-3 py-2.5 font-semibold text-text-muted uppercase tracking-wider text-[10px]",children:"Provider"}),R.target&&(0,s.jsx)("th",{className:"px-3 py-2.5 font-semibold text-text-muted uppercase tracking-wider text-[10px]",children:"Target"}),R.latency&&(0,s.jsx)("th",{className:"px-3 py-2.5 font-semibold text-text-muted uppercase tracking-wider text-[10px] text-right",children:"Latency"}),R.ip&&(0,s.jsx)("th",{className:"px-3 py-2.5 font-semibold text-text-muted uppercase tracking-wider text-[10px]",children:"Public IP"}),R.time&&(0,s.jsx)("th",{className:"px-3 py-2.5 font-semibold text-text-muted uppercase tracking-wider text-[10px] text-right",children:"Time"})]})}),(0,s.jsx)("tbody",{className:"divide-y divide-border/30",children:F.map(e=>{let t=(0,o.Yh)(e.status),r=o.Gp[e.proxy?.type]||{bg:"#6B7280",text:"#fff",label:e.proxy?.type||"-"},a=o.Ie[e.level]||o.Ie.direct,l=o.RY[e.provider]||{bg:"#374151",text:"#fff",label:(e.provider||"-").toUpperCase()},i="error"===e.status||"timeout"===e.status;return(0,s.jsxs)("tr",{onClick:()=>T(A?.id===e.id?null:e),className:`cursor-pointer hover:bg-primary/5 transition-colors ${i?"bg-red-500/5":""}`,children:[R.status&&(0,s.jsx)("td",{className:"px-3 py-2",children:(0,s.jsx)("span",{className:"inline-block px-2 py-0.5 rounded text-[10px] font-bold min-w-[50px] text-center uppercase",style:{backgroundColor:t.bg,color:t.text},children:e.status})}),R.proxy&&(0,s.jsx)("td",{className:"px-3 py-2 font-mono text-[11px] text-primary",children:e.proxy?`${e.proxy.host}:${e.proxy.port}`:"—"}),R.tls&&(0,s.jsx)("td",{className:"px-3 py-2",children:e.tlsFingerprint?(0,s.jsxs)("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 rounded text-[9px] font-bold uppercase",style:{backgroundColor:"rgba(6, 182, 212, 0.15)",color:"#22d3ee"},title:"Chrome 124 TLS Fingerprint",children:[(0,s.jsx)("span",{style:{fontSize:"10px"},children:"\uD83D\uDD12"})," TLS"]}):(0,s.jsx)("span",{className:"text-text-muted text-[10px]",children:"—"})}),R.type&&(0,s.jsx)("td",{className:"px-3 py-2",children:(0,s.jsx)("span",{className:"inline-block px-2 py-0.5 rounded text-[9px] font-bold uppercase",style:{backgroundColor:r.bg,color:r.text},children:r.label})}),R.level&&(0,s.jsx)("td",{className:"px-3 py-2",children:(0,s.jsx)("span",{className:"inline-block px-2 py-0.5 rounded text-[9px] font-bold uppercase",style:{backgroundColor:a.bg,color:a.text},children:a.label})}),R.provider&&(0,s.jsx)("td",{className:"px-3 py-2",children:e.provider?(0,s.jsx)("span",{className:"inline-block px-2 py-0.5 rounded text-[9px] font-bold uppercase",style:{backgroundColor:l.bg,color:l.text},children:l.label}):(0,s.jsx)("span",{className:"text-text-muted text-[10px]",children:"—"})}),R.target&&(0,s.jsx)("td",{className:"px-3 py-2 text-text-muted truncate max-w-[200px] font-mono text-[10px]",title:e.targetUrl,children:(0,n.Y1)(e.targetUrl)}),R.latency&&(0,s.jsx)("td",{className:"px-3 py-2 text-right text-text-muted font-mono",children:(0,n.a3)(e.latencyMs)}),R.ip&&(0,s.jsx)("td",{className:"px-3 py-2 font-mono text-[11px] text-emerald-400",children:e.publicIp||"—"}),R.time&&(0,s.jsx)("td",{className:"px-3 py-2 text-right text-text-muted",children:(0,n.fU)(e.timestamp)})]},e.id)})})]})})}),A&&(0,s.jsx)(i,{log:A,onClose:()=>T(null)})]})}},8898:(e,t,r)=>{function s(e){try{return new Date(e).toLocaleTimeString("en-US",{hour12:!1,hour:"2-digit",minute:"2-digit",second:"2-digit"})}catch{return"-"}}function a(e){return e?e<1e3?`${e}ms`:`${(e/1e3).toFixed(1)}s`:"-"}function l(e,t){if(!e||"-"===e)return"-";let r=e.indexOf("@");return r>3?t?e:e.slice(0,3)+"***"+e.slice(r):e.length>8?e.slice(0,5)+"***":e}function o(e,t){if(!e&&!t)return"—";let r=e||"key";return t?`${r} (${function(e,t=2,r=2){return e?e.length<=t+r?`${e.slice(0,1)}***`:`${e.slice(0,t)}***${e.slice(-r)}`:""}(t,4,4)})`:r}function n(e){return e>=1e9?`${(e/1e9).toFixed(1)}B`:e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}K`:new Intl.NumberFormat().format(e||0)}function i(e){return new Intl.NumberFormat().format(e||0)}function c(e){return`$${(e||0).toFixed(2)}`}function d(e,t=50){if(!e)return"-";try{let r=new URL(e),s=r.hostname+r.pathname;return s.length>t?s.slice(0,t)+"…":s}catch{return e.length>t?e.slice(0,t)+"…":e}}function x(e){return"number"==typeof e&&isFinite(e)?e:void 0}r.d(t,{F0:()=>c,Ib:()=>l,Q1:()=>x,VK:()=>n,VO:()=>o,Y1:()=>d,a3:()=>a,fU:()=>s,xW:()=>i})},11567:(e,t,r)=>{r.d(t,{yX:()=>n});var s=r(12115);function a(){return window.electronAPI?.isElectron===!0}function l(){return!1}let o=()=>()=>{};function n(){return(0,s.useSyncExternalStore)(o,a,l)}},15559:(e,t,r)=>{r.d(t,{Ke:()=>a,ad:()=>l,ii:()=>n,uj:()=>o});let s=["home","endpoints","api-manager","providers","combos","batch","costs","analytics","cache","limits","cli-tools","agents","memory","skills","translator","playground","media","search-tools","logs","health","settings","docs","issues"],a=[{id:"primary",titleKey:"primarySection",titleFallback:"Main",items:[{id:"home",href:"/dashboard",i18nKey:"home",icon:"home",exact:!0},{id:"endpoints",href:"/dashboard/endpoint",i18nKey:"endpoints",icon:"api"},{id:"api-manager",href:"/dashboard/api-manager",i18nKey:"apiManager",icon:"vpn_key"},{id:"providers",href:"/dashboard/providers",i18nKey:"providers",icon:"dns"},{id:"combos",href:"/dashboard/combos",i18nKey:"combos",icon:"layers"},{id:"batch",href:"/dashboard/batch",i18nKey:"batch",icon:"view_list"},{id:"costs",href:"/dashboard/costs",i18nKey:"costs",icon:"account_balance_wallet"},{id:"analytics",href:"/dashboard/analytics",i18nKey:"analytics",icon:"analytics"},{id:"cache",href:"/dashboard/cache",i18nKey:"cache",icon:"cached"},{id:"limits",href:"/dashboard/limits",i18nKey:"limits",icon:"tune"},{id:"media",href:"/dashboard/cache/media",i18nKey:"media",icon:"perm_media"}],showTitleInSidebar:!1},{id:"cli",titleKey:"cliSection",titleFallback:"CLI",items:[{id:"cli-tools",href:"/dashboard/cli-tools",i18nKey:"cliToolsShort",icon:"terminal"},{id:"agents",href:"/dashboard/agents",i18nKey:"agents",icon:"smart_toy"},{id:"memory",href:"/dashboard/memory",i18nKey:"memory",icon:"psychology"},{id:"skills",href:"/dashboard/skills",i18nKey:"skills",icon:"auto_fix_high"}]},{id:"debug",titleKey:"debugSection",titleFallback:"Debug",items:[{id:"translator",href:"/dashboard/translator",i18nKey:"translator",icon:"translate"},{id:"playground",href:"/dashboard/playground",i18nKey:"playground",icon:"science"},{id:"search-tools",href:"/dashboard/search-tools",i18nKey:"searchTools",icon:"manage_search"}],visibility:"debug"},{id:"system",titleKey:"systemSection",titleFallback:"System",items:[{id:"logs",href:"/dashboard/logs",i18nKey:"logs",icon:"description"},{id:"health",href:"/dashboard/health",i18nKey:"health",icon:"health_and_safety"},{id:"settings",href:"/dashboard/settings",i18nKey:"settings",icon:"settings"}]},{id:"help",titleKey:"helpSection",titleFallback:"Help",items:[{id:"docs",href:"/docs",i18nKey:"docs",icon:"menu_book",external:!0},{id:"issues",href:"https://github.com/diegosouzapw/OmniRoute/issues",i18nKey:"issues",icon:"bug_report",external:!0}]}],l="hiddenSidebarItems",o="omniroute:settings-updated";function n(e){if(!Array.isArray(e))return[];let t=new Set;for(let r of e)"string"==typeof r&&s.includes(r)&&t.add(r);return s.filter(e=>t.has(e))}},17705:(e,t,r)=>{r.d(t,{default:()=>l});var s=r(95155),a=r(67040);function l({src:e,alt:t="Avatar",name:r,size:o="md",className:n}){let i={xs:"size-6 text-xs",sm:"size-8 text-sm",md:"size-10 text-base",lg:"size-12 text-lg",xl:"size-16 text-xl"};return e?(0,s.jsx)("div",{className:(0,a.cn)("rounded-full bg-cover bg-center bg-no-repeat","ring-2 ring-white dark:ring-surface-dark shadow-sm",i[o],n),style:{backgroundImage:`url(${e})`},role:"img","aria-label":t}):(0,s.jsx)("div",{className:(0,a.cn)("rounded-full flex items-center justify-center font-semibold text-white","ring-2 ring-white dark:ring-surface-dark shadow-sm",i[o],(e=>{if(!e)return"bg-primary";let t=["bg-red-500","bg-orange-500","bg-amber-500","bg-yellow-500","bg-lime-500","bg-green-500","bg-emerald-500","bg-teal-500","bg-cyan-500","bg-sky-500","bg-blue-500","bg-indigo-500","bg-violet-500","bg-purple-500","bg-fuchsia-500","bg-pink-500","bg-rose-500"],r=e.charCodeAt(0)%t.length;return t[r]})(r),n),role:"img","aria-label":t,children:(e=>{if(!e)return"?";let t=e.split(" ");return t.length>=2?`${t[0][0]}${t[1][0]}`.toUpperCase():e.substring(0,2).toUpperCase()})(r)})}},18150:(e,t,r)=>{r.d(t,{default:()=>x});var s=r(95155),a=r(12115),l=r(14051),o=r.n(l),n=r(71361),i=r(35806),c=r(34422),d=r(30949);function x({isOpen:e,provider:t,providerLabel:r="Kiro",onSuccess:l,onClose:o}){let[m,u]=(0,a.useState)("loading"),[p,h]=(0,a.useState)(""),[b,f]=(0,a.useState)(null),[g,y]=(0,a.useState)(""),[j,v]=(0,a.useState)(null),{copied:N,copy:k}=(0,d.C)();(0,a.useEffect)(()=>{e&&t&&(async()=>{try{v(null),u("loading");let e=await fetch(`/api/oauth/kiro/social-authorize?provider=${t}`),r=await e.json();if(!e.ok)throw Error(r.error);f(r),h(r.authUrl),u("input"),window.open(r.authUrl,"kiro_social_auth")}catch(e){v(e.message),u("error")}})()},[e,t]);let w=async()=>{try{let e;v(null);try{e=new URL(g)}catch(e){throw Error("Invalid callback URL format")}let r=e.searchParams.get("code");e.searchParams.get("state");let s=e.searchParams.get("error");if(s)throw Error(e.searchParams.get("error_description")||s);if(!r)throw Error("No authorization code found in URL");let a=await fetch("/api/oauth/kiro/social-exchange",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({code:r,codeVerifier:b.codeVerifier,provider:t})}),o=await a.json();if(!a.ok)throw Error(o.error);u("success"),l?.()}catch(e){v(e.message),u("error")}},C="google"===t?"Google":"GitHub";return(0,s.jsx)(n.default,{isOpen:e,title:`Connect ${r} via ${C}`,onClose:o,size:"lg",children:(0,s.jsxs)("div",{className:"flex flex-col gap-4",children:["loading"===m&&(0,s.jsxs)("div",{className:"text-center py-6",children:[(0,s.jsx)("div",{className:"size-16 mx-auto mb-4 rounded-full bg-primary/10 flex items-center justify-center",children:(0,s.jsx)("span",{className:"material-symbols-outlined text-3xl text-primary animate-spin",children:"progress_activity"})}),(0,s.jsx)("h3",{className:"text-lg font-semibold mb-2",children:"Initializing..."}),(0,s.jsxs)("p",{className:"text-sm text-text-muted",children:["Setting up ",C," authentication"]})]}),"input"===m&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("div",{className:"space-y-4",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:"text-sm font-medium mb-2",children:"Step 1: Open this URL in your browser"}),(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsx)(c.default,{value:p,readOnly:!0,className:"flex-1 font-mono text-xs"}),(0,s.jsx)(i.default,{variant:"secondary",icon:"auth_url"===N?"check":"content_copy",onClick:()=>k(p,"auth_url"),children:"Copy"})]})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:"text-sm font-medium mb-2",children:"Step 2: Paste the callback URL here"}),(0,s.jsx)("p",{className:"text-xs text-text-muted mb-2",children:"After authorization, copy the full URL from your browser address bar."}),(0,s.jsx)(c.default,{value:g,onChange:e=>y(e.target.value),placeholder:"kiro://kiro.kiroAgent/authenticate-success?code=...",className:"font-mono text-xs"})]})]}),(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsx)(i.default,{onClick:w,fullWidth:!0,disabled:!g,children:"Connect"}),(0,s.jsx)(i.default,{onClick:o,variant:"ghost",fullWidth:!0,children:"Cancel"})]})]}),"success"===m&&(0,s.jsxs)("div",{className:"text-center py-6",children:[(0,s.jsx)("div",{className:"size-16 mx-auto mb-4 rounded-full bg-green-100 dark:bg-green-900/30 flex items-center justify-center",children:(0,s.jsx)("span",{className:"material-symbols-outlined text-3xl text-green-600",children:"check_circle"})}),(0,s.jsx)("h3",{className:"text-lg font-semibold mb-2",children:"Connected Successfully!"}),(0,s.jsxs)("p",{className:"text-sm text-text-muted mb-4",children:["Your ",r," account via ",C," has been connected."]}),(0,s.jsx)(i.default,{onClick:o,fullWidth:!0,children:"Done"})]}),"error"===m&&(0,s.jsxs)("div",{className:"text-center py-6",children:[(0,s.jsx)("div",{className:"size-16 mx-auto mb-4 rounded-full bg-red-100 dark:bg-red-900/30 flex items-center justify-center",children:(0,s.jsx)("span",{className:"material-symbols-outlined text-3xl text-red-600",children:"error"})}),(0,s.jsx)("h3",{className:"text-lg font-semibold mb-2",children:"Connection Failed"}),(0,s.jsx)("p",{className:"text-sm text-red-600 mb-4",children:j}),(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsx)(i.default,{onClick:()=>u("input"),variant:"secondary",fullWidth:!0,children:"Try Again"}),(0,s.jsx)(i.default,{onClick:o,variant:"ghost",fullWidth:!0,children:"Cancel"})]})]})]})})}x.propTypes={isOpen:o().bool.isRequired,provider:o().oneOf(["google","github"]).isRequired,providerLabel:o().string,onSuccess:o().func,onClose:o().func.isRequired}},21720:(e,t,r)=>{r.d(t,{default:()=>h});var s=r(95155),a=r(12115),l=r(42912),o=r(87806),n=r(76332),i=r(61580),c=r(50910);function d(){let[e,t]=(0,a.useState)(!1),[r,l]=(0,a.useState)(""),o=(0,a.useRef)(0),n=(0,a.useRef)(!1),i=(0,c.c)("common");return((0,a.useEffect)(()=>{let e=async()=>{let e=new AbortController,r=setTimeout(()=>e.abort("Health check timeout"),8e3);try{(await fetch("/api/monitoring/health",{signal:e.signal,cache:"no-store"})).ok?(o.current=0,n.current=!1,t(!1),l("")):(o.current+=1,o.current>=2&&!n.current&&(t(!0),l(i("maintenanceServerIssues"))))}catch{o.current+=1,o.current>=2&&!n.current&&(t(!0),l(i("maintenanceServerUnreachable")))}finally{clearTimeout(r)}};e();let r=setInterval(e,1e4);return()=>clearInterval(r)},[i]),e)?(0,s.jsxs)("div",{className:"bg-amber-500/10 border-b border-amber-500/20 px-4 py-2.5 flex items-center justify-between gap-3 animate-in slide-in-from-top",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2.5",children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-amber-500 text-[18px] animate-pulse",children:"warning"}),(0,s.jsx)("span",{className:"text-sm text-amber-200",children:r})]}),(0,s.jsx)("button",{onClick:()=>{n.current=!0,t(!1)},className:"p-1 rounded hover:bg-white/5 text-text-muted hover:text-text-main transition-colors","aria-label":i("close"),children:(0,s.jsx)("span",{className:"material-symbols-outlined text-[16px]",children:"close"})})]}):null}var x=r(11567),m=r(41463);let u="sidebar-collapsed",p="1"===m.env.NEXT_PUBLIC_OMNIROUTE_E2E_MODE;function h({children:e}){let[t,r]=(0,a.useState)(!1),c=(0,x.yX)(),[m,b]=(0,a.useState)(()=>{try{return"true"===localStorage.getItem(u)}catch{return!1}}),f=c&&window.electronAPI?.platform==="darwin";return(0,a.useEffect)(()=>{if("u">typeof document)return document.body.classList.toggle("electron-macos",f),()=>{document.body.classList.remove("electron-macos")}},[f]),(0,s.jsxs)("div",{className:"flex h-dvh min-h-0 w-full overflow-hidden bg-bg",children:[t&&(0,s.jsx)("div",{className:"fixed inset-0 z-40 bg-black/20 lg:hidden",onClick:()=>r(!1)}),(0,s.jsx)("div",{className:"hidden min-h-0 lg:flex",children:(0,s.jsx)(l.default,{collapsed:m,onToggleCollapse:()=>{let e=!m;b(e),localStorage.setItem(u,String(e))},isMacElectron:f})}),(0,s.jsx)("div",{className:`fixed inset-y-0 left-0 z-50 transform lg:hidden transition-transform duration-300 ease-in-out h-dvh overflow-y-auto ${t?"translate-x-0":"-translate-x-full"}`,children:(0,s.jsx)(l.default,{onClose:()=>r(!1),isMacElectron:f})}),(0,s.jsxs)("main",{id:"main-content",className:"relative flex min-h-0 flex-1 min-w-0 flex-col transition-colors duration-300",children:[(0,s.jsx)(o.default,{onMenuClick:()=>r(!0)}),!p&&(0,s.jsx)(d,{}),(0,s.jsx)("div",{className:"flex-1 min-h-0 overflow-y-auto overflow-x-hidden custom-scrollbar p-4 sm:p-6 lg:p-10",children:(0,s.jsxs)("div",{className:"max-w-7xl mx-auto w-full",children:[(0,s.jsx)(n.default,{}),e]})})]}),(0,s.jsx)(i.default,{})]})}},25112:(e,t,r)=>{r.d(t,{default:()=>h});var s=r(95155),a=r(50910),l=r(12115),o=r(14051),n=r.n(o),i=r(73321),c=r(81060),d=r(80927),x=r(92542),m=r(8898);function u({field:e,currentSort:t,currentOrder:r}){return t!==e?(0,s.jsx)("span",{className:"ml-1 opacity-20",children:"↕"}):(0,s.jsx)("span",{className:"ml-1",children:"asc"===r?"↑":"↓"})}function p({data:e,colorClass:t="bg-primary"}){let r=Math.max(...e,1);return(0,s.jsx)("div",{className:"flex items-end gap-1 h-8 w-24",children:e.slice(-9).map((e,a)=>(0,s.jsx)("div",{className:`flex-1 rounded-t-sm transition-all duration-500 ${t}`,style:{height:`${Math.max(e/r*100,5)}%`},title:String(e)},`bar-${a}-${e}`))})}function h(){let e=(0,a.c)("stats"),t=(0,i.useRouter)(),r=(0,i.useSearchParams)(),o=r.get("sortBy")||"rawModel",n=r.get("sortOrder")||"asc",[h,b]=(0,l.useState)(null),[f,g]=(0,l.useState)(!0),[y,j]=(0,l.useState)(!0),[v,N]=(0,l.useState)("tokens"),[k,w]=(0,l.useState)(5e3),C=(0,l.useRef)(0),S=e=>{let s=new URLSearchParams(r.toString());o===e?s.set("sortOrder","asc"===n?"desc":"asc"):(s.set("sortBy",e),s.set("sortOrder","asc")),t.replace(`?${s.toString()}`,{scroll:!1})},A=(0,l.useCallback)((e,t={})=>Object.entries(e||{}).map(([e,r])=>{let s=(r.promptTokens||0)+(r.completionTokens||0),a=r.cost||0,l=s>0?(r.promptTokens||0)*(a/s):0,o=s>0?(r.completionTokens||0)*(a/s):0;return{...r,key:e,totalTokens:s,totalCost:a,inputCost:l,outputCost:o,pending:t[e]||0}}).sort((e,t)=>{let r=e[o],s=t[o];return("string"==typeof r&&(r=r.toLowerCase()),"string"==typeof s&&(s=s.toLowerCase()),r<s)?"asc"===n?-1:1:r>s?"asc"===n?1:-1:0}),[o,n]),T=(0,l.useMemo)(()=>A(h?.byModel,h?.pending?.byModel),[h?.byModel,h?.pending?.byModel,A]),I=(0,l.useMemo)(()=>{let e={};return h?.pending?.byAccount&&Object.entries(h.byAccount||{}).forEach(([t,r])=>{let s=h.pending.byAccount[r.connectionId];if(s){let a=r.provider?`${r.rawModel} (${r.provider})`:r.rawModel;e[t]=s[a]||0}}),A(h?.byAccount,e)},[h?.byAccount,h?.pending?.byAccount,A]),M=(0,l.useCallback)(async(e=!0)=>{e&&g(!0);try{let e=await fetch("/api/usage/history");if(e.ok){let t=await e.json();b(t);let r=t.totalRequests||0;r>C.current?w(5e3):w(e=>Math.min(2*e,6e4)),C.current=r}}catch(e){console.error("Failed to fetch usage stats:",e)}finally{e&&g(!1)}},[]);if((0,l.useEffect)(()=>{M()},[M]),(0,l.useEffect)(()=>{let e,t=!0,r=()=>{(t=!document.hidden)&&y&&M(!1)};return document.addEventListener("visibilitychange",r),y&&(e&&clearInterval(e),e=setInterval(()=>{t&&M(!1)},k)),()=>{e&&clearInterval(e),document.removeEventListener("visibilitychange",r)}},[y,k,M]),f)return(0,s.jsx)(x.CardSkeleton,{});if(!h)return(0,s.jsx)("div",{className:"text-text-muted",children:e("failedToLoad")});let O=e=>(0,m.xW)(e),R=e=>{if(!e)return"Never";let t=new Date(e),r=Math.floor((new Date().getTime()-t.getTime())/6e4);return r<1?"Just now":r<60?`${r}m ago`:r<1440?`${Math.floor(r/60)}h ago`:t.toLocaleDateString()};return(0,s.jsxs)("div",{className:"flex flex-col gap-6",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between",children:[(0,s.jsx)("h2",{className:"text-xl font-semibold",children:e("usageOverview")}),(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsxs)("div",{className:"flex items-center gap-1 bg-bg-subtle rounded-lg p-1 border border-border",children:[(0,s.jsx)("button",{onClick:()=>N("tokens"),className:`px-3 py-1 rounded-md text-sm font-medium transition-colors ${"tokens"===v?"bg-primary text-white shadow-sm":"text-text-muted hover:text-text hover:bg-bg-hover"}`,children:"Tokens"}),(0,s.jsx)("button",{onClick:()=>N("costs"),className:`px-3 py-1 rounded-md text-sm font-medium transition-colors ${"costs"===v?"bg-primary text-white shadow-sm":"text-text-muted hover:text-text hover:bg-bg-hover"}`,children:"Costs"})]}),(0,s.jsxs)("div",{className:"text-sm font-medium text-text-muted flex items-center gap-2",children:[(0,s.jsxs)("span",{children:["Auto Refresh (",k/1e3,"s)"]}),(0,s.jsx)("button",{type:"button",onClick:()=>j(!y),role:"switch","aria-checked":y,"aria-label":"Toggle auto refresh",className:`relative inline-flex h-5 w-9 items-center rounded-full transition-colors focus:outline-none focus:ring-2 focus:ring-primary/50 ${y?"bg-primary":"bg-bg-subtle border border-border"}`,children:(0,s.jsx)("span",{className:`inline-block h-3 w-3 transform rounded-full bg-white transition-transform ${y?"translate-x-5":"translate-x-1"}`})})]})]})]}),(h.activeRequests||[]).length>0&&(0,s.jsx)(c.default,{className:"p-3 border-primary/20 bg-primary/5",children:(0,s.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2 text-primary font-semibold text-sm uppercase tracking-wider",children:[(0,s.jsxs)("span",{className:"relative flex h-2 w-2",children:[(0,s.jsx)("span",{className:"animate-ping absolute inline-flex h-full w-full rounded-full bg-primary opacity-75"}),(0,s.jsx)("span",{className:"relative inline-flex rounded-full h-2 w-2 bg-primary"})]}),"Active Requests"]}),(0,s.jsx)("div",{className:"flex flex-wrap gap-3",children:h.activeRequests.map(e=>(0,s.jsxs)("div",{className:"px-3 py-1.5 rounded-md bg-bg-subtle border border-primary/20 text-xs font-mono shadow-sm",children:[(0,s.jsx)("span",{className:"text-primary font-bold",children:e.model}),(0,s.jsx)("span",{className:"mx-1 text-text-muted",children:"|"}),(0,s.jsx)("span",{className:"text-text",children:e.provider}),(0,s.jsx)("span",{className:"mx-1 text-text-muted",children:"|"}),(0,s.jsx)("span",{className:"text-text font-medium",children:e.account}),e.count>1&&(0,s.jsxs)("span",{className:"ml-2 px-1.5 py-0.5 rounded bg-primary text-white font-bold",children:["x",e.count]})]},`${e.model}-${e.provider}-${e.account}`))})]})}),(0,s.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[(0,s.jsx)(c.default,{className:"px-4 py-3 flex flex-col gap-1",children:(0,s.jsxs)("div",{className:"flex justify-between items-start",children:[(0,s.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,s.jsx)("span",{className:"text-text-muted text-sm uppercase font-semibold",children:"Total Requests"}),(0,s.jsx)("span",{className:"text-2xl font-bold",children:O(h.totalRequests)})]}),(0,s.jsx)(p,{data:(h.last10Minutes||[]).map(e=>e.requests),colorClass:"bg-text-muted/30"})]})}),(0,s.jsx)(c.default,{className:"px-4 py-3 flex flex-col gap-1",children:(0,s.jsxs)("div",{className:"flex justify-between items-start",children:[(0,s.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,s.jsx)("span",{className:"text-text-muted text-sm uppercase font-semibold",children:"Total Input Tokens"}),(0,s.jsx)("span",{className:"text-2xl font-bold text-primary",children:O(h.totalPromptTokens)})]}),(0,s.jsx)(p,{data:(h.last10Minutes||[]).map(e=>e.promptTokens),colorClass:"bg-primary/50"})]})}),(0,s.jsx)(c.default,{className:"px-4 py-2 flex flex-col gap-1",children:(0,s.jsxs)("div",{className:"flex justify-between items-start gap-4",children:[(0,s.jsxs)("div",{className:"flex flex-col gap-1 flex-1",children:[(0,s.jsx)("span",{className:"text-text-muted text-sm uppercase font-semibold",children:e("outputTokens")}),(0,s.jsx)("span",{className:"text-2xl font-bold text-success",children:O(h.totalCompletionTokens)})]}),(0,s.jsx)("div",{className:"w-px bg-border self-stretch mx-2"}),(0,s.jsxs)("div",{className:"flex flex-col gap-1 flex-1",children:[(0,s.jsx)("span",{className:"text-text-muted text-sm uppercase font-semibold",children:e("totalCost")}),(0,s.jsx)("span",{className:"text-2xl font-bold text-warning",children:(0,m.F0)(h.totalCost)})]})]})})]}),(0,s.jsxs)(c.default,{className:"overflow-hidden",children:[(0,s.jsx)("div",{className:"p-4 border-b border-border bg-bg-subtle/50",children:(0,s.jsx)("h3",{className:"font-semibold",children:"Usage by Model"})}),(0,s.jsx)("div",{className:"overflow-x-auto",children:(0,s.jsxs)("table",{className:"w-full text-sm text-left",children:[(0,s.jsx)("thead",{className:"bg-bg-subtle/30 text-text-muted uppercase text-xs",children:(0,s.jsxs)("tr",{children:[(0,s.jsxs)("th",{className:"px-6 py-3 cursor-pointer hover:bg-bg-subtle/50",onClick:()=>S("rawModel"),children:["Model ",(0,s.jsx)(u,{field:"rawModel",currentSort:o,currentOrder:n})]}),(0,s.jsxs)("th",{className:"px-6 py-3 cursor-pointer hover:bg-bg-subtle/50",onClick:()=>S("provider"),children:["Provider"," ",(0,s.jsx)(u,{field:"provider",currentSort:o,currentOrder:n})]}),(0,s.jsxs)("th",{className:"px-6 py-3 text-right cursor-pointer hover:bg-bg-subtle/50",onClick:()=>S("requests"),children:["Requests"," ",(0,s.jsx)(u,{field:"requests",currentSort:o,currentOrder:n})]}),(0,s.jsxs)("th",{className:"px-6 py-3 text-right cursor-pointer hover:bg-bg-subtle/50",onClick:()=>S("lastUsed"),children:["Last Used"," ",(0,s.jsx)(u,{field:"lastUsed",currentSort:o,currentOrder:n})]}),"tokens"===v?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("th",{className:"px-6 py-3 text-right cursor-pointer hover:bg-bg-subtle/50",onClick:()=>S("promptTokens"),children:["Input Tokens"," ",(0,s.jsx)(u,{field:"promptTokens",currentSort:o,currentOrder:n})]}),(0,s.jsxs)("th",{className:"px-6 py-3 text-right cursor-pointer hover:bg-bg-subtle/50",onClick:()=>S("completionTokens"),children:["Output Tokens"," ",(0,s.jsx)(u,{field:"completionTokens",currentSort:o,currentOrder:n})]}),(0,s.jsxs)("th",{className:"px-6 py-3 text-right cursor-pointer hover:bg-bg-subtle/50",onClick:()=>S("totalTokens"),children:["Total Tokens"," ",(0,s.jsx)(u,{field:"totalTokens",currentSort:o,currentOrder:n})]})]}):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("th",{className:"px-6 py-3 text-right cursor-pointer hover:bg-bg-subtle/50",onClick:()=>S("promptTokens"),children:["Input Cost"," ",(0,s.jsx)(u,{field:"promptTokens",currentSort:o,currentOrder:n})]}),(0,s.jsxs)("th",{className:"px-6 py-3 text-right cursor-pointer hover:bg-bg-subtle/50",onClick:()=>S("completionTokens"),children:["Output Cost"," ",(0,s.jsx)(u,{field:"completionTokens",currentSort:o,currentOrder:n})]}),(0,s.jsxs)("th",{className:"px-6 py-3 text-right cursor-pointer hover:bg-bg-subtle/50",onClick:()=>S("cost"),children:["Total Cost"," ",(0,s.jsx)(u,{field:"cost",currentSort:o,currentOrder:n})]})]})]})}),(0,s.jsxs)("tbody",{className:"divide-y divide-border",children:[T.map(e=>(0,s.jsxs)("tr",{className:"hover:bg-bg-subtle/20",children:[(0,s.jsx)("td",{className:`px-6 py-3 font-medium transition-colors ${e.pending>0?"text-primary":""}`,children:e.rawModel}),(0,s.jsx)("td",{className:"px-6 py-3",children:(0,s.jsx)(d.default,{variant:e.pending>0?"primary":"default",size:"sm",children:e.provider})}),(0,s.jsx)("td",{className:"px-6 py-3 text-right",children:O(e.requests)}),(0,s.jsx)("td",{className:"px-6 py-3 text-right text-text-muted whitespace-nowrap",children:R(e.lastUsed)}),"tokens"===v?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("td",{className:"px-6 py-3 text-right text-text-muted",children:O(e.promptTokens)}),(0,s.jsx)("td",{className:"px-6 py-3 text-right text-text-muted",children:O(e.completionTokens)}),(0,s.jsx)("td",{className:"px-6 py-3 text-right font-medium",children:O(e.totalTokens)})]}):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("td",{className:"px-6 py-3 text-right text-text-muted",children:(0,m.F0)(e.inputCost)}),(0,s.jsx)("td",{className:"px-6 py-3 text-right text-text-muted",children:(0,m.F0)(e.outputCost)}),(0,s.jsx)("td",{className:"px-6 py-3 text-right font-medium text-warning",children:(0,m.F0)(e.totalCost)})]})]},e.key)),0===T.length&&(0,s.jsx)("tr",{children:(0,s.jsx)("td",{colSpan:8,className:"px-6 py-8 text-center text-text-muted",children:"No usage recorded yet. Make some requests to see data here."})})]})]})})]}),(0,s.jsxs)(c.default,{className:"overflow-hidden",children:[(0,s.jsx)("div",{className:"p-4 border-b border-border bg-bg-subtle/50",children:(0,s.jsx)("h3",{className:"font-semibold",children:"Usage by Account"})}),(0,s.jsx)("div",{className:"overflow-x-auto",children:(0,s.jsxs)("table",{className:"w-full text-sm text-left",children:[(0,s.jsx)("thead",{className:"bg-bg-subtle/30 text-text-muted uppercase text-xs",children:(0,s.jsxs)("tr",{children:[(0,s.jsxs)("th",{className:"px-6 py-3 cursor-pointer hover:bg-bg-subtle/50",onClick:()=>S("rawModel"),children:["Model ",(0,s.jsx)(u,{field:"rawModel",currentSort:o,currentOrder:n})]}),(0,s.jsxs)("th",{className:"px-6 py-3 cursor-pointer hover:bg-bg-subtle/50",onClick:()=>S("provider"),children:["Provider"," ",(0,s.jsx)(u,{field:"provider",currentSort:o,currentOrder:n})]}),(0,s.jsxs)("th",{className:"px-6 py-3 cursor-pointer hover:bg-bg-subtle/50",onClick:()=>S("accountName"),children:["Account"," ",(0,s.jsx)(u,{field:"accountName",currentSort:o,currentOrder:n})]}),(0,s.jsxs)("th",{className:"px-6 py-3 text-right cursor-pointer hover:bg-bg-subtle/50",onClick:()=>S("requests"),children:["Requests"," ",(0,s.jsx)(u,{field:"requests",currentSort:o,currentOrder:n})]}),(0,s.jsxs)("th",{className:"px-6 py-3 text-right cursor-pointer hover:bg-bg-subtle/50",onClick:()=>S("lastUsed"),children:["Last Used"," ",(0,s.jsx)(u,{field:"lastUsed",currentSort:o,currentOrder:n})]}),"tokens"===v?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("th",{className:"px-6 py-3 text-right cursor-pointer hover:bg-bg-subtle/50",onClick:()=>S("promptTokens"),children:["Input Tokens"," ",(0,s.jsx)(u,{field:"promptTokens",currentSort:o,currentOrder:n})]}),(0,s.jsxs)("th",{className:"px-6 py-3 text-right cursor-pointer hover:bg-bg-subtle/50",onClick:()=>S("completionTokens"),children:["Output Tokens"," ",(0,s.jsx)(u,{field:"completionTokens",currentSort:o,currentOrder:n})]}),(0,s.jsxs)("th",{className:"px-6 py-3 text-right cursor-pointer hover:bg-bg-subtle/50",onClick:()=>S("totalTokens"),children:["Total Tokens"," ",(0,s.jsx)(u,{field:"totalTokens",currentSort:o,currentOrder:n})]})]}):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("th",{className:"px-6 py-3 text-right cursor-pointer hover:bg-bg-subtle/50",onClick:()=>S("promptTokens"),children:["Input Cost"," ",(0,s.jsx)(u,{field:"promptTokens",currentSort:o,currentOrder:n})]}),(0,s.jsxs)("th",{className:"px-6 py-3 text-right cursor-pointer hover:bg-bg-subtle/50",onClick:()=>S("completionTokens"),children:["Output Cost"," ",(0,s.jsx)(u,{field:"completionTokens",currentSort:o,currentOrder:n})]}),(0,s.jsxs)("th",{className:"px-6 py-3 text-right cursor-pointer hover:bg-bg-subtle/50",onClick:()=>S("cost"),children:["Total Cost"," ",(0,s.jsx)(u,{field:"cost",currentSort:o,currentOrder:n})]})]})]})}),(0,s.jsxs)("tbody",{className:"divide-y divide-border",children:[I.map(e=>(0,s.jsxs)("tr",{className:"hover:bg-bg-subtle/20",children:[(0,s.jsx)("td",{className:`px-6 py-3 font-medium transition-colors ${e.pending>0?"text-primary":""}`,children:e.rawModel}),(0,s.jsx)("td",{className:"px-6 py-3",children:(0,s.jsx)(d.default,{variant:e.pending>0?"primary":"default",size:"sm",children:e.provider})}),(0,s.jsx)("td",{className:"px-6 py-3",children:(0,s.jsx)("span",{className:`font-medium transition-colors ${e.pending>0?"text-primary":""}`,children:e.accountName||`Account ${e.connectionId?.slice(0,8)}...`})}),(0,s.jsx)("td",{className:"px-6 py-3 text-right",children:O(e.requests)}),(0,s.jsx)("td",{className:"px-6 py-3 text-right text-text-muted whitespace-nowrap",children:R(e.lastUsed)}),"tokens"===v?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("td",{className:"px-6 py-3 text-right text-text-muted",children:O(e.promptTokens)}),(0,s.jsx)("td",{className:"px-6 py-3 text-right text-text-muted",children:O(e.completionTokens)}),(0,s.jsx)("td",{className:"px-6 py-3 text-right font-medium",children:O(e.totalTokens)})]}):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("td",{className:"px-6 py-3 text-right text-text-muted",children:(0,m.F0)(e.inputCost)}),(0,s.jsx)("td",{className:"px-6 py-3 text-right text-text-muted",children:(0,m.F0)(e.outputCost)}),(0,s.jsx)("td",{className:"px-6 py-3 text-right font-medium text-warning",children:(0,m.F0)(e.totalCost)})]})]},e.key)),0===I.length&&(0,s.jsx)("tr",{children:(0,s.jsx)("td",{colSpan:9,className:"px-6 py-8 text-center text-text-muted",children:"No account-specific usage recorded yet. Make requests using OAuth accounts to see data here."})})]})]})})]})]})}u.propTypes={field:n().string.isRequired,currentSort:n().string.isRequired,currentOrder:n().string.isRequired},p.propTypes={data:n().arrayOf(n().number).isRequired,colorClass:n().string}},29862:(e,t,r)=>{r.d(t,{A:()=>tz});var s=r(95155),a=r(12115),l=r(5772),o=r(89358),n=r(10760),i=r(6334),c=r(67381),d=r(14574),x=r(17044),m=r(69512),u=r(47198),p=r(75425),h=r(29345),b=r(60403),f=r(99059),g=r(94301),y=r(94669),j=r(83003),v=r(32251),N=r(41573),k=r(92501),w=r(38632),C=r(12958),S=r(2965),A=r(74418),T=r(30248),I=r(74897),M=r(3321),O=r(33017),R=r(45955),L=r(44067),E=r(90288),_=r(69399),F=r(63367),$=r(43433),D=r(53513),P=r(46522),K=r(90544),z=r(75990),q=r(82044),B=r(86929),U=r(67966),W=r(29220),V=r(66988),G=r(90562),H=r(52520),J=r(16062),Y=r(58808),X=r(15172),Z=r(37722),Q=r(52957),ee=r(72237),et=r(9490),er=r(7880),es=r(44610),ea=r(86456),el=r(2618),eo=r(29775),en=r(73375),ei=r(49857),ec=r(69441),ed=r(57794),ex=r(10839),em=r(80935),eu=r(34166),ep=r(9312),eh=r(87638),eb=r(86108),ef=r(56655),eg=r(29599),ey=r(72319),ej=r(92104),ev=r(215),eN=r(52823),ek=r(27576),ew=r(28078),eC=r(12678),eS=r(41356),eA=r(87609),eT=r(27577),eI=r(11799),eM=r(49447),eO=r(95541),eR=r(44293),eL=r(27056),eE=r(19398),e_=r(22008),eF=r(23886),e$=r(94292),eD=r(82311),eP=r(80599),eK=r(42339),ez=r(38073),eq=r(27109),eB=r(61173),eU=r(79191),eW=r(73799),eV=r(45293),eG=r(64433),eH=r(77583),eJ=r(44351),eY=r(74068),eX=r(19872),eZ=r(12804),eQ=r(20858),e0=r(53300),e1=r(22922),e2=r(71809),e5=r(44225),e3=r(5711),e4=r(26751),e6=r(662),e8=r(69140),e9=r(36239),e7=r(4376),te=r(2478),tt=r(60249),tr=r(11008),ts=r(2102),ta=r(81352),tl=r(35870),to=r(24701),tn=r(25389),ti=r(68385),tc=r(11489),td=r(10632),tx=r(75326),tm=r(53945),tu=r(78075),tp=r(87931),th=r(24869),tb=r(47478),tf=r(39484),tg=r(48238),ty=r(93326),tj=r(36020),tv=r(21081),tN=r(67321),tk=r(36730),tw=r(8784),tC=r(16237),tS=r(5309),tA=r(40431),tT=r(99839),tI=r(7751),tM=r(83546),tO=r(4635),tR=r(79675),tL=r(83709),tE=r(30814),t_=r(25604);let tF={Ai21:{mono:o.A},Alibaba:{mono:i.A,color:n.A},Anthropic:{mono:c.A},Antigravity:{mono:x.A,color:d.A},AssemblyAI:{mono:u.A,color:m.A},Automatic:{mono:h.A,color:p.A},Aws:{mono:f.A,color:b.A},Azure:{mono:y.A,color:g.A},AzureAI:{mono:v.A,color:j.A},Baidu:{mono:k.A,color:N.A},Bailian:{mono:C.A,color:w.A},Baseten:{mono:S.A},Bedrock:{mono:T.A,color:A.A},Bfl:{mono:I.A},Cerebras:{mono:O.A,color:M.A},ClaudeCode:{mono:L.A,color:R.A},Cline:{mono:E.A},Cloudflare:{mono:F.A,color:_.A},Codex:{mono:D.A,color:$.A},Cohere:{mono:K.A,color:P.A},ComfyUI:{mono:q.A,color:z.A},Cursor:{mono:B.A},Dbrx:{mono:W.A,color:U.A},DeepInfra:{mono:G.A,color:V.A},DeepSeek:{mono:J.A,color:H.A},ElevenLabs:{mono:Y.A},Exa:{mono:Z.A,color:X.A},Fal:{mono:ee.A,color:Q.A},Featherless:{mono:er.A,color:et.A},Fireworks:{mono:ea.A,color:es.A},Friendli:{mono:el.A},Gemini:{mono:en.A,color:eo.A},GeminiCLI:{mono:ec.A,color:ei.A},GithubCopilot:{mono:ed.A},Google:{mono:em.A,color:ex.A},Grok:{mono:eu.A},Groq:{mono:ep.A},HuggingFace:{mono:eb.A,color:eh.A},Hyperbolic:{mono:eg.A,color:ef.A},IBM:{mono:ey.A},Inference:{mono:ej.A},Jina:{mono:ev.A},KiloCode:{mono:eN.A},Kimi:{mono:ew.A,color:ek.A},Lambda:{mono:eC.A},LmStudio:{mono:eS.A},Meta:{mono:eT.A,color:eA.A},MetaAI:{mono:eM.A,color:eI.A},Minimax:{mono:eR.A,color:eO.A},Mistral:{mono:eE.A,color:eL.A},Moonshot:{mono:e_.A},Morph:{mono:e$.A,color:eF.A},NanoBanana:{mono:eP.A,color:eD.A},Nebius:{mono:eK.A},NousResearch:{mono:ez.A},Novita:{mono:eB.A,color:eq.A},Nvidia:{mono:eW.A,color:eU.A},Ollama:{mono:eV.A},OpenAI:{mono:eG.A},OpenClaw:{mono:eJ.A,color:eH.A},OpenCode:{mono:eY.A},OpenRouter:{mono:eX.A},Perplexity:{mono:eQ.A,color:eZ.A},Poe:{mono:e1.A,color:e0.A},Qoder:{mono:e5.A,color:e2.A},Qwen:{mono:e4.A,color:e3.A},Recraft:{mono:e6.A},Replicate:{mono:e8.A},Runway:{mono:e9.A},SambaNova:{mono:te.A,color:e7.A},SearchApi:{mono:tt.A},SiliconCloud:{mono:ts.A,color:tr.A},Snowflake:{mono:tl.A,color:ta.A},Stability:{mono:tn.A,color:to.A},Tavily:{mono:tc.A,color:ti.A},Together:{mono:tx.A,color:td.A},TopazLabs:{mono:tm.A},Upstage:{mono:tp.A,color:tu.A},V0:{mono:th.A},Venice:{mono:tf.A,color:tb.A},Vercel:{mono:tg.A},VertexAI:{mono:tj.A,color:ty.A},Vllm:{mono:tN.A,color:tv.A},Volcengine:{mono:tw.A,color:tk.A},Voyage:{mono:tS.A,color:tC.A},WorkersAI:{mono:tT.A,color:tA.A},XAI:{mono:tI.A},XiaomiMiMo:{mono:tM.A},Xinference:{mono:tR.A,color:tO.A},ZAI:{mono:tL.A},Zhipu:{mono:t_.A,color:tE.A}},t$={ai21:"Ai21",alibaba:"Alibaba",alicode:"Alibaba","alicode-intl":"Alibaba","amazon-q":"Aws",anthropic:"Anthropic",antigravity:"Antigravity",assemblyai:"AssemblyAI","aws-polly":"Aws",azure:"Azure","azure-ai":"AzureAI","azure-openai":"AzureAI",baidu:"Baidu","bailian-coding-plan":"Bailian",baseten:"Baseten",bedrock:"Bedrock",bfl:"Bfl","black-forest-labs":"Bfl",cerebras:"Cerebras",claude:"ClaudeCode",cline:"Cline",cloudflare:"Cloudflare","cloudflare-ai":"WorkersAI",codestral:"Mistral",codex:"Codex",cohere:"Cohere",comfyui:"ComfyUI",copilot:"GithubCopilot",cursor:"Cursor",databricks:"Dbrx",deepinfra:"DeepInfra",deepseek:"DeepSeek",elevenlabs:"ElevenLabs",exa:"Exa","exa-search":"Exa",fal:"Fal","fal-ai":"Fal",featherless:"Featherless","featherless-ai":"Featherless",fireworks:"Fireworks","fireworks-ai":"Fireworks",friendli:"Friendli",friendliai:"Friendli",gemini:"Gemini","gemini-cli":"GeminiCLI",github:"GithubCopilot","github-copilot":"GithubCopilot",glm:"Zhipu","glm-cn":"Zhipu",glmt:"Zhipu","google-pse-search":"Google",grok:"Grok","grok-web":"Grok",groq:"Groq","hugging-face":"HuggingFace",huggingface:"HuggingFace",hyperbolic:"Hyperbolic",ibm:"IBM","inference-net":"Inference",jina:"Jina","jina-ai":"Jina",kilocode:"KiloCode",kimi:"Kimi","kimi-coding":"Kimi","kimi-coding-apikey":"Kimi",lambda:"Lambda","lambda-ai":"Lambda","lm-studio":"LmStudio",lmstudio:"LmStudio","meta-llama":"Meta",minimax:"Minimax","minimax-cn":"Minimax",mistral:"Mistral",mistralai:"Mistral",moonshot:"Moonshot",morph:"Morph","muse-spark-web":"MetaAI",nanobanana:"NanoBanana",nebius:"Nebius","nous-research":"NousResearch",nousresearch:"NousResearch",novita:"Novita",nvidia:"Nvidia",ollama:"Ollama","ollama-cloud":"Ollama",openai:"OpenAI",openclaw:"OpenClaw",opencode:"OpenCode","opencode-go":"OpenCode","opencode-zen":"OpenCode","open-router":"OpenRouter",openrouter:"OpenRouter",perplexity:"Perplexity","perplexity-search":"Perplexity","perplexity-web":"Perplexity",poe:"Poe",qoder:"Qoder",qwen:"Qwen",recraft:"Recraft",replicate:"Replicate",runwayml:"Runway",sambanova:"SambaNova",sdwebui:"Automatic",searchapi:"SearchApi","searchapi-search":"SearchApi",siliconflow:"SiliconCloud",snowflake:"Snowflake",stability:"Stability","stability-ai":"Stability",tavily:"Tavily","tavily-search":"Tavily",together:"Together",topaz:"TopazLabs",upstage:"Upstage",v0:"V0","v0-vercel":"V0",venice:"Venice","vercel-ai-gateway":"Vercel",vertex:"VertexAI","vertex-partner":"VertexAI",vertexai:"VertexAI",vllm:"Vllm",volcengine:"Volcengine",voyage:"Voyage","voyage-ai":"Voyage",watsonx:"IBM","workers-ai":"WorkersAI",workersai:"WorkersAI",xai:"XAI","xiaomi-mimo":"XiaomiMiMo",xiaomimimo:"XiaomiMiMo",xinference:"Xinference",zai:"ZAI",zhipu:"Zhipu"};function tD({size:e}){return(0,s.jsxs)("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",style:{flex:"none"},children:[(0,s.jsx)("circle",{cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"1.5",opacity:"0.4"}),(0,s.jsx)("path",{d:"M8 12h8M12 8v8",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})]})}let tP=new Set(["aimlapi","alibaba","alicode-intl","alicode","anthropic-m","anthropic","antigravity","bailian-coding-plan","blackbox","brave-search","brave","cerebras","claude","cline","codex","cohere","continue","copilot","cursor","deepgram","deepseek","droid","exa-search","fireworks","gemini-cli","gemini","github","glm","glmt","groq","ironclaw","kilo-gateway","kilocode","kimi-coding-apikey","kimi-coding","kimi","kiro","longcat","minimax-cn","minimax","mistral","nanobot","nebius","nvidia","oai-cc","oai-r","ollama-cloud","openai","openclaw","openrouter","perplexity-search","perplexity","pollinations","qwen","roo","serper-search","serper","siliconflow","tavily-search","tavily","together","xai","zeroclaw","aws-polly","blackbox-web","cliproxyapi","databricks","empower","gigachat","gitlab-duo","gitlab","heroku","linkup-search","llamagate","maritalk","modal","nanogpt","nscale","oci","ovhcloud","piapi","poe","predibase","qoder","recraft","reka","runwayml","triton","venice","voyage-ai","wandb","youcom-search"]),tK=new Set(["apikey","assemblyai","brave","cartesia","cloudflare-ai","comfyui","elevenlabs","exa-search","exa","huggingface","hyperbolic","inworld","nanobanana","oauth","opencode-go","opencode-zen","opencode","playht","puter","qianfan","scaleway","sdwebui","synthetic","vertex","windsurf","zai"]),tz=(0,a.memo)(function({providerId:e,size:t=24,type:r="color",className:o,style:n}){let i=e.toLowerCase(),c=function(e,t="color"){let r=t$[e.toLowerCase()];if(!r)return null;let s=tF[r];return"color"===t&&s.color?s.color:s.mono}(i,r),d=tP.has(i),x=tK.has(i),[m,u]=(0,a.useState)({}),p=`${i}:png`,h=`${i}:svg`,b=!c&&d&&!m[p],f=!c&&x&&!m[h]&&(!d||m[p]);return c?(0,s.jsx)("span",{className:o,style:{display:"inline-flex",alignItems:"center",...n},children:(0,a.createElement)(c,{"aria-label":e,size:t,style:{flex:"none"}})}):b?(0,s.jsx)("span",{className:o,style:{display:"inline-flex",alignItems:"center",...n},children:(0,s.jsx)(l.default,{src:`/providers/${i}.png`,alt:e,width:t,height:t,style:{objectFit:"contain"},onError:()=>{u(e=>({...e,[p]:!0}))},unoptimized:!0})}):f?(0,s.jsx)("span",{className:o,style:{display:"inline-flex",alignItems:"center",...n},children:(0,s.jsx)(l.default,{src:`/providers/${i}.svg`,alt:e,width:t,height:t,style:{objectFit:"contain"},onError:()=>u(e=>({...e,[h]:!0})),unoptimized:!0})}):(0,s.jsx)("span",{className:o,style:{display:"inline-flex",alignItems:"center",...n},children:(0,s.jsx)(tD,{size:t})})})},33637:(e,t,r)=>{r.d(t,{A:()=>o});var s=r(95155),a=r(14051),l=r.n(a);function o({size:e=20,className:t=""}){return(0,s.jsxs)("svg",{width:e,height:e,viewBox:"0 0 32 32",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:t,children:[(0,s.jsx)("circle",{cx:"16",cy:"16",r:"3",fill:"currentColor"}),(0,s.jsx)("circle",{cx:"8",cy:"8",r:"2",fill:"currentColor"}),(0,s.jsx)("circle",{cx:"24",cy:"8",r:"2",fill:"currentColor"}),(0,s.jsx)("circle",{cx:"8",cy:"24",r:"2",fill:"currentColor"}),(0,s.jsx)("circle",{cx:"24",cy:"24",r:"2",fill:"currentColor"}),(0,s.jsx)("circle",{cx:"16",cy:"5",r:"1.5",fill:"currentColor"}),(0,s.jsx)("circle",{cx:"16",cy:"27",r:"1.5",fill:"currentColor"}),(0,s.jsx)("line",{x1:"16",y1:"13",x2:"8",y2:"8",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round"}),(0,s.jsx)("line",{x1:"16",y1:"13",x2:"24",y2:"8",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round"}),(0,s.jsx)("line",{x1:"16",y1:"19",x2:"8",y2:"24",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round"}),(0,s.jsx)("line",{x1:"16",y1:"19",x2:"24",y2:"24",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round"}),(0,s.jsx)("line",{x1:"16",y1:"13",x2:"16",y2:"5",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round"}),(0,s.jsx)("line",{x1:"16",y1:"19",x2:"16",y2:"27",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round"})]})}o.propTypes={size:l().number,className:l().string}},33709:(e,t,r)=>{r.d(t,{default:()=>l});var s=r(95155),a=r(67040);function l({options:e=[],value:t,onChange:r,size:o="md",className:n,"aria-label":i}){let c={sm:"h-7 text-xs",md:"h-9 text-sm",lg:"h-11 text-base"};return(0,s.jsx)("div",{role:"tablist","aria-label":i,className:(0,a.cn)("inline-flex items-center p-1 rounded-lg","bg-black/5 dark:bg-white/5",n),children:e.map(e=>(0,s.jsxs)("button",{role:"tab","aria-selected":t===e.value,tabIndex:t===e.value?0:-1,onClick:()=>r(e.value),className:(0,a.cn)("px-4 rounded-md font-medium transition-all",c[o],t===e.value?"bg-white dark:bg-white/10 text-text-main shadow-sm":"text-text-muted hover:text-text-main"),children:[e.icon&&(0,s.jsx)("span",{className:"material-symbols-outlined text-[16px] mr-1.5","aria-hidden":"true",children:e.icon}),e.label]},e.value))})}},37415:(e,t,r)=>{r.d(t,{default:()=>b});var s=r(95155),a=r(12115),l=r(50910),o=r(81060),n=r(99333),i=r(8898);function c({title:e,json:t,onCopy:r}){let[l,o]=(0,a.useState)(!1),n=async()=>{!1!==await r()&&(o(!0),setTimeout(()=>o(!1),2e3))};return(0,s.jsxs)("div",{children:[(0,s.jsxs)("div",{className:"flex items-center justify-between mb-2",children:[(0,s.jsx)("h3",{className:"text-[11px] text-text-muted uppercase tracking-wider font-bold",children:e}),(0,s.jsxs)("button",{onClick:n,className:"flex items-center gap-1 px-2 py-1 text-xs text-text-muted hover:text-text-primary transition-colors","aria-label":`Copy ${e}`,children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:l?"check":"content_copy"}),l?"Copied!":"Copy"]})]}),(0,s.jsx)("pre",{className:"p-4 rounded-xl bg-black/5 dark:bg-black/30 border border-border overflow-x-auto text-xs font-mono text-text-main max-h-[600px] overflow-y-auto leading-relaxed whitespace-pre-wrap break-words",children:t})]})}function d({log:e,detail:t,loading:r,onClose:l,onCopy:o}){(0,a.useEffect)(()=>{let e=e=>{"Escape"===e.key&&l()};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[l]);let x=(0,n._Z)(e.status),m=e.sourceFormat||e.provider,u=(0,n.sE)(m,e.provider),p=n.RY[e.provider]||{bg:"#374151",text:"#fff",label:(e.provider||"-").toUpperCase()},h=e=>{if(null==e)return null;try{return JSON.stringify(e,null,2)}catch{return String(e)}},b=t?.pipelinePayloads||null,f=b?[["clientRawRequest","Client Raw Request"],["clientRequest","Client Request"],["openaiRequest","OpenAI Request"],["providerRequest","Provider Request"],["providerResponse","Provider Response"],["clientResponse","Client Response"],["error","Pipeline Error"]].map(([e,t])=>({key:e,title:t,json:h(b[e])})).filter(e=>e.json):[],g=t?.requestBody?h(t.requestBody):null,y=t?.responseBody?h(t.responseBody):null,j=t?.detailState==="missing"?"Detailed payload artifact is no longer available for this log entry.":t?.detailState==="corrupt"?"Detailed payload artifact could not be parsed.":null,v={totalIn:t?.tokens?.in??e.tokens?.in??0,totalOut:t?.tokens?.out??e.tokens?.out??0,cacheRead:t?.tokens?.cacheRead??e.tokens?.cacheRead,cacheWrite:t?.tokens?.cacheWrite??e.tokens?.cacheWrite,reasoning:t?.tokens?.reasoning??e.tokens?.reasoning},N=e=>null!=e?e.toLocaleString():"N/A",k=t?.cacheSource||e.cacheSource||"upstream";return(0,s.jsxs)("div",{className:"fixed inset-0 z-50 flex items-start justify-center pt-[5vh]",onClick:l,role:"dialog","aria-modal":"true","aria-label":"Request log detail",children:[(0,s.jsx)("div",{className:"absolute inset-0 bg-black/60 backdrop-blur-sm"}),(0,s.jsxs)("div",{className:"relative bg-bg-primary border border-border rounded-xl w-full max-w-[900px] max-h-[90vh] overflow-y-auto shadow-2xl",onClick:e=>e.stopPropagation(),children:[(0,s.jsxs)("div",{className:"sticky top-0 z-10 flex items-center justify-between px-6 py-4 border-b border-border bg-bg-primary/95 backdrop-blur-sm rounded-t-xl",children:[(0,s.jsxs)("div",{className:"flex items-center gap-3",children:[(0,s.jsx)("span",{className:"inline-block px-2.5 py-1 rounded text-xs font-bold",style:{backgroundColor:x.bg,color:x.text},children:e.status}),(0,s.jsx)("span",{className:"font-bold text-lg",children:e.method}),(0,s.jsx)("span",{className:"text-text-muted font-mono text-sm",children:e.path})]}),(0,s.jsx)("button",{onClick:l,className:"p-1.5 rounded-lg hover:bg-bg-subtle text-text-muted hover:text-text-primary transition-colors","aria-label":"Close detail modal",children:(0,s.jsx)("span",{className:"material-symbols-outlined",children:"close"})})]}),(0,s.jsxs)("div",{className:"p-6 flex flex-col gap-6",children:[(0,s.jsxs)("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4 p-4 bg-bg-subtle rounded-xl border border-border","data-testid":"request-log-metadata-grid",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("div",{className:"text-[10px] text-text-muted uppercase tracking-wider mb-1",children:"Completed Time"}),(0,s.jsx)("div",{className:"text-sm font-medium",children:(e=>{try{let t=new Date(e);return t.toLocaleDateString("pt-BR")+", "+t.toLocaleTimeString("en-US",{hour12:!1})}catch{return e}})(e.timestamp)})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("div",{className:"text-[10px] text-text-muted uppercase tracking-wider mb-1",children:"Duration"}),(0,s.jsx)("div",{className:"text-sm font-medium",children:(0,i.a3)(e.duration)})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("div",{className:"text-[10px] text-text-muted uppercase tracking-wider mb-1",children:"Input"}),(0,s.jsxs)("div",{className:"flex flex-wrap items-center gap-1.5","data-testid":"token-group-input",children:[(0,s.jsxs)("span",{className:"px-2 py-0.5 rounded bg-primary/20 text-primary text-xs font-bold",children:["Total In: ",v.totalIn.toLocaleString()]}),(0,s.jsxs)("span",{className:"px-2 py-0.5 rounded bg-sky-500/20 text-sky-700 dark:text-sky-400 text-xs font-bold",children:["Cache Read: ",N(v.cacheRead)]}),(0,s.jsxs)("span",{className:"px-2 py-0.5 rounded bg-amber-500/20 text-amber-700 dark:text-amber-400 text-xs font-bold",children:["Cache Write: ",N(v.cacheWrite)]})]})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("div",{className:"text-[10px] text-text-muted uppercase tracking-wider mb-1",children:"Output"}),(0,s.jsxs)("div",{className:"flex flex-wrap items-center gap-1.5","data-testid":"token-group-output",children:[(0,s.jsxs)("span",{className:"px-2 py-0.5 rounded bg-emerald-500/20 text-emerald-700 dark:text-emerald-400 text-xs font-bold",children:["Total Out: ",v.totalOut.toLocaleString()]}),(0,s.jsxs)("span",{className:"px-2 py-0.5 rounded bg-violet-500/20 text-violet-700 dark:text-violet-400 text-xs font-bold",children:["Reasoning: ",N(v.reasoning)]})]})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("div",{className:"text-[10px] text-text-muted uppercase tracking-wider mb-1",children:"Model"}),(0,s.jsx)("div",{className:"text-sm font-medium text-primary font-mono",children:e.model})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("div",{className:"text-[10px] text-text-muted uppercase tracking-wider mb-1",children:"Requested Model"}),(0,s.jsx)("div",{className:`text-sm font-medium font-mono ${(t?.requestedModel||e.requestedModel)&&(t?.requestedModel||e.requestedModel)!==e.model?"text-amber-600 dark:text-amber-400":"text-text-muted"}`,children:t?.requestedModel||e.requestedModel||"—"})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("div",{className:"text-[10px] text-text-muted uppercase tracking-wider mb-1",children:"Provider"}),(0,s.jsx)("span",{className:"inline-block px-2.5 py-1 rounded text-[10px] font-bold uppercase",style:{backgroundColor:p.bg,color:p.text},children:p.label})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("div",{className:"text-[10px] text-text-muted uppercase tracking-wider mb-1",children:"Req Protocol"}),(0,s.jsx)("span",{className:"inline-block px-2.5 py-1 rounded text-[10px] font-bold uppercase",style:{backgroundColor:u.bg,color:u.text},children:u.label})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("div",{className:"text-[10px] text-text-muted uppercase tracking-wider mb-1",children:"Cache Source"}),(0,s.jsx)("span",{className:`inline-block px-2.5 py-1 rounded text-[10px] font-bold border ${"semantic"===k?"bg-emerald-500/20 text-emerald-700 dark:text-emerald-300 border-emerald-500/30":"bg-sky-500/20 text-sky-700 dark:text-sky-300 border-sky-500/30"}`,children:"semantic"===k?"Semantic (OmniRoute)":"Upstream (Provider)"})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("div",{className:"text-[10px] text-text-muted uppercase tracking-wider mb-1",children:"Account"}),(0,s.jsx)("div",{className:"text-sm font-medium",children:t?.account||e.account||"-"})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("div",{className:"text-[10px] text-text-muted uppercase tracking-wider mb-1",children:"API Key"}),(0,s.jsx)("div",{className:"text-sm font-medium",title:t?.apiKeyName||t?.apiKeyId||e.apiKeyName||e.apiKeyId||"No API key",children:(0,i.VO)(t?.apiKeyName||e.apiKeyName,t?.apiKeyId||e.apiKeyId)})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("div",{className:"text-[10px] text-text-muted uppercase tracking-wider mb-1",children:"Combo"}),t?.comboName||e.comboName?(0,s.jsx)("span",{className:"inline-block px-2.5 py-1 rounded-full text-[10px] font-bold bg-violet-500/20 text-violet-700 dark:text-violet-300 border border-violet-500/30",children:t?.comboName||e.comboName}):(0,s.jsx)("div",{className:"text-sm text-text-muted",children:"—"})]})]}),(t?.error||e.error)&&(0,s.jsxs)("div",{className:"p-4 rounded-xl bg-red-500/10 border border-red-500/30",children:[(0,s.jsx)("div",{className:"text-[10px] text-red-600 dark:text-red-400 uppercase tracking-wider mb-1 font-bold",children:"Error"}),(0,s.jsx)("div",{className:"text-sm text-red-600 dark:text-red-300 font-mono",children:t?.error||e.error})]}),j&&(0,s.jsxs)("div",{className:"p-4 rounded-xl bg-amber-500/10 border border-amber-500/30",children:[(0,s.jsx)("div",{className:"text-[10px] text-amber-700 dark:text-amber-400 uppercase tracking-wider mb-1 font-bold",children:"Detail Status"}),(0,s.jsx)("div",{className:"text-sm text-amber-700 dark:text-amber-200",children:j})]}),r?(0,s.jsx)("div",{className:"p-8 text-center text-text-muted animate-pulse",children:"Loading request details..."}):(0,s.jsxs)(s.Fragment,{children:[f.length>0&&f.map(e=>(0,s.jsx)(c,{title:e.title,json:e.json,onCopy:()=>o(e.json)},e.key)),0===f.length&&y&&(0,s.jsx)(c,{title:"Response Payload (Legacy)",json:y,onCopy:()=>o(y)}),0===f.length&&g&&(0,s.jsx)(c,{title:"Request Payload (Legacy)",json:g,onCopy:()=>o(g)}),0===f.length&&!g&&!y&&!r&&(0,s.jsxs)("div",{className:"p-6 text-center text-text-muted",children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-[32px] mb-2 block opacity-40",children:"info"}),(0,s.jsx)("p",{className:"text-sm",children:"No payload data available for this log entry."}),(0,s.jsx)("p",{className:"text-xs mt-1",children:"Enable detailed logging first if you want the four-stage client/provider payload view for new requests."})]})]})]})]})]})}var x=r(32661),m=r(96914);function u(e,t){if(!e)return"-";if(e.startsWith("openai-compatible-")||e.startsWith("anthropic-compatible-")){if(t?.length){let r=t.find(t=>t.id===e||t.prefix===e);if(r?.name)return r.name}if(e.startsWith("openai-compatible-")){let t=e.replace("openai-compatible-",""),r=t.split("-");return r.length>1&&r[1]?.length>=8?"OAI-COMPAT":`OAI: ${t.slice(0,16).toUpperCase()}`}if(e.startsWith("anthropic-compatible-")){let t=e.replace("anthropic-compatible-",""),r=t.split("-");return r.length>1&&r[1]?.length>=8?"ANT-COMPAT":`ANT: ${t.slice(0,16).toUpperCase()}`}}return null}function p(e){return(e?.tokens?.in||0)+(e?.tokens?.out||0)}function h(e){let t=e?.tokens?.out||0,r=e?.duration||0;return t<=0||r<=0?0:t/(r/1e3)}function b(){let e=(0,l.c)("requestLogger"),{emailsVisible:t}=(0,m.A)(),r=(0,a.useMemo)(()=>[{key:"all",label:e("statusFilters.all"),icon:""},{key:"error",label:e("statusFilters.error"),icon:"error"},{key:"ok",label:e("statusFilters.success"),icon:"check_circle"},{key:"combo",label:e("statusFilters.combo"),icon:"hub"}],[e]),c=(0,a.useMemo)(()=>[{key:"status",label:e("columns.status")},{key:"cacheSource",label:e("columns.cacheSource")},{key:"model",label:e("columns.model")},{key:"requestedModel",label:e("columns.requested")},{key:"provider",label:e("columns.provider")},{key:"protocol",label:e("columns.protocol")},{key:"account",label:e("columns.account")},{key:"apiKey",label:e("columns.apiKey")},{key:"combo",label:e("columns.combo")},{key:"tokens",label:e("columns.tokens")},{key:"tps",label:e("columns.tps")},{key:"duration",label:e("columns.duration")},{key:"time",label:e("columns.time")}],[e]),[b,f]=(0,a.useState)([]),[g,y]=(0,a.useState)(!0),[j,v]=(0,a.useState)(!0),[N,k]=(0,a.useState)(""),[w,C]=(0,a.useState)("all"),[S,A]=(0,a.useState)(""),[T,I]=(0,a.useState)(""),[M,O]=(0,a.useState)(""),[R,L]=(0,a.useState)(""),[E,_]=(0,a.useState)("newest"),[F,$]=(0,a.useState)(null),[D,P]=(0,a.useState)(!1),[K,z]=(0,a.useState)(null),[q,B]=(0,a.useState)(!1),[U,W]=(0,a.useState)(!1),V=(0,a.useRef)(null),G=(0,a.useRef)(!1),H=(0,a.useRef)(""),[J,Y]=(0,a.useState)([]),[X,Z]=(0,a.useState)(()=>{let e=Object.fromEntries(c.map(e=>[e.key,!0]));try{let t=localStorage.getItem("loggerVisibleColumns");return t?{...e,...JSON.parse(t)}:e}catch{return e}}),Q=(0,a.useCallback)(e=>{Z(t=>{let r={...t,[e]:!t[e]};try{localStorage.setItem("loggerVisibleColumns",JSON.stringify(r))}catch{}return r})},[]),ee=(0,a.useCallback)(async(e=!1)=>{e&&y(!0);try{let e=new URLSearchParams;N&&e.set("search",N),"error"===w&&e.set("status","error"),"ok"===w&&e.set("status","ok"),"combo"===w&&e.set("combo","1"),S&&e.set("model",S),M&&e.set("provider",M),T&&e.set("account",T),R&&e.set("apiKey",R),e.set("limit","300");let t=await fetch(`/api/usage/call-logs?${e}`);if(t.ok){let e=await t.json(),r=JSON.stringify(e.map?.(e=>e.id)??[]);r!==H.current&&(H.current=r,f(e))}}catch(e){console.error("Failed to fetch call logs:",e)}finally{e&&y(!1)}},[N,w,S,T,M,R]);(0,a.useEffect)(()=>{let e=!G.current;G.current=!0,ee(e)},[ee]),(0,a.useEffect)(()=>{fetch("/api/provider-nodes").then(e=>e.ok?e.json():{nodes:[]}).then(e=>Y(e.nodes||[])).catch(()=>{})},[]),(0,a.useEffect)(()=>{fetch("/api/logs/detail?limit=1").then(async e=>e.ok?await e.json():null).then(e=>{e&&B(!0===e.enabled)}).catch(()=>{})},[]),(0,a.useEffect)(()=>(V.current&&clearInterval(V.current),j&&(V.current=setInterval(()=>ee(!1),3e3)),()=>{V.current&&clearInterval(V.current)}),[j,ee]);let et=(0,a.useMemo)(()=>"combo"===w?b.filter(e=>e.comboName):b,[w,b]),er=(0,a.useMemo)(()=>{let e=[...et];return e.sort((e,t)=>{switch(E){case"oldest":return new Date(e.timestamp).getTime()-new Date(t.timestamp).getTime();case"tokens_desc":return p(t)-p(e);case"tokens_asc":return p(e)-p(t);case"duration_desc":return(t.duration||0)-(e.duration||0);case"duration_asc":return(e.duration||0)-(t.duration||0);case"tps_desc":return h(t)-h(e);case"tps_asc":return h(e)-h(t);case"status_desc":return(t.status||0)-(e.status||0);case"status_asc":return(e.status||0)-(t.status||0);case"model_asc":return(e.model||"").localeCompare(t.model||"");case"model_desc":return(t.model||"").localeCompare(e.model||"");default:return new Date(t.timestamp).getTime()-new Date(e.timestamp).getTime()}}),e},[et,E]),es=async e=>{$(e),P(!0),z(null);try{let t=await fetch(`/api/usage/call-logs/${e.id}`);if(t.ok){let e=await t.json();z(e)}}catch(e){console.error("Failed to fetch log detail:",e)}finally{P(!1)}},ea=async()=>{W(!0);try{let e=!q;if(!(await fetch("/api/logs/detail",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({enabled:e})})).ok)throw Error("Failed to update pipeline logging");B(e)}catch(e){console.error("Failed to toggle pipeline logging:",e)}finally{W(!1)}},el=[...new Set(b.map(e=>e.account).filter(e=>e&&"-"!==e))],eo=[...new Set(b.flatMap(e=>[e.model,e.requestedModel]).filter(e=>!!e))].sort(),en=[...new Set(b.map(e=>e.provider).filter(e=>e&&"-"!==e))].sort(),ei=[...new Set(b.map(e=>e.apiKeyId||e.apiKeyName).filter(Boolean))].sort(),ec=et.length,ed=et.filter(e=>e.status>=200&&e.status<300).length,ex=et.filter(e=>e.status>=400).length,em=b.filter(e=>e.comboName).length,eu=ei.length;return(0,s.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,s.jsxs)("div",{className:"flex flex-wrap items-center gap-3",children:[(0,s.jsxs)("button",{onClick:()=>v(!j),className:`flex items-center gap-2 px-3 py-1.5 rounded-full text-sm font-medium border transition-colors ${j?"bg-red-500/10 border-red-500/30 text-red-700 dark:text-red-400":"bg-bg-subtle border-border text-text-muted"}`,children:[(0,s.jsx)("span",{className:`w-2 h-2 rounded-full ${j?"bg-red-500 animate-pulse":"bg-text-muted"}`}),j?e("recording"):e("paused")]}),(0,s.jsxs)("button",{onClick:ea,disabled:U,className:`flex items-center gap-2 px-3 py-1.5 rounded-full text-sm font-medium border transition-colors disabled:opacity-60 ${q?"bg-amber-500/10 border-amber-500/30 text-amber-700 dark:text-amber-300":"bg-bg-subtle border-border text-text-muted"}`,title:"Capture pipeline payloads for new requests",children:[(0,s.jsx)("span",{className:`w-2 h-2 rounded-full ${q?"bg-amber-500":"bg-text-muted"}`}),U?e("updatingPipelineLogs"):q?e("pipelineLogsOn"):e("pipelineLogsOff")]}),(0,s.jsxs)("div",{className:"flex-1 min-w-[200px] relative",children:[(0,s.jsx)("span",{className:"material-symbols-outlined absolute left-3 top-1/2 -translate-y-1/2 text-text-muted text-[18px]",children:"search"}),(0,s.jsx)("input",{type:"text",placeholder:e("searchPlaceholder"),value:N,onChange:e=>k(e.target.value),className:"w-full pl-10 pr-4 py-2 rounded-lg bg-bg-subtle border border-border text-sm text-text-primary placeholder:text-text-muted focus:outline-none focus:border-primary"})]}),(0,s.jsxs)("select",{value:M,onChange:e=>O(e.target.value),className:"px-3 py-2 rounded-lg bg-bg-subtle border border-border text-sm text-text-primary focus:outline-none focus:border-primary appearance-none cursor-pointer min-w-[140px]",children:[(0,s.jsx)("option",{value:"",children:e("allProviders")}),en.map(e=>{let t=u(e,J),r=n.RY[e];return(0,s.jsx)("option",{value:e,children:t||r?.label||e.toUpperCase()},e)})]}),(0,s.jsxs)("select",{value:S,onChange:e=>A(e.target.value),className:"px-3 py-2 rounded-lg bg-bg-subtle border border-border text-sm text-text-primary focus:outline-none focus:border-primary appearance-none cursor-pointer min-w-[180px]",children:[(0,s.jsx)("option",{value:"",children:e("allModels")}),eo.map(e=>(0,s.jsx)("option",{value:e,children:e},e))]}),(0,s.jsxs)("select",{value:T,onChange:e=>I(e.target.value),className:"px-3 py-2 rounded-lg bg-bg-subtle border border-border text-sm text-text-primary focus:outline-none focus:border-primary appearance-none cursor-pointer min-w-[140px]",children:[(0,s.jsx)("option",{value:"",children:e("allAccounts")}),el.map(e=>(0,s.jsx)("option",{value:e,children:e},e))]}),(0,s.jsxs)("select",{value:R,onChange:e=>L(e.target.value),className:"px-3 py-2 rounded-lg bg-bg-subtle border border-border text-sm text-text-primary focus:outline-none focus:border-primary appearance-none cursor-pointer min-w-[160px]",children:[(0,s.jsx)("option",{value:"",children:e("allApiKeys")}),ei.map(e=>{let t=b.find(t=>(t.apiKeyId||t.apiKeyName)===e),r=(0,i.VO)(t?.apiKeyName,t?.apiKeyId);return(0,s.jsx)("option",{value:e,children:r},e)})]}),(0,s.jsxs)("div",{className:"flex items-center gap-2 text-xs text-text-muted",children:[(0,s.jsxs)("span",{className:"px-2 py-1 rounded bg-bg-subtle border border-border font-mono",children:[ec," ",e("total")]}),(0,s.jsxs)("span",{className:"px-2 py-1 rounded bg-emerald-500/10 text-emerald-700 dark:text-emerald-400 font-mono",children:[ed," ",e("ok")]}),ex>0&&(0,s.jsxs)("span",{className:"px-2 py-1 rounded bg-red-500/10 text-red-700 dark:text-red-400 font-mono",children:[ex," ",e("err")]}),em>0&&(0,s.jsxs)("span",{className:"px-2 py-1 rounded bg-violet-500/10 text-violet-700 dark:text-violet-400 font-mono",children:[em," ",e("combo")]}),eu>0&&(0,s.jsxs)("span",{className:"px-2 py-1 rounded bg-primary/10 text-primary font-mono",children:[eu," ",e("keys")]}),(0,s.jsxs)("span",{className:"px-2 py-1 rounded bg-bg-subtle border border-border font-mono",children:[er.length," ",e("shown")]})]}),(0,s.jsxs)("select",{value:E,onChange:e=>_(e.target.value),className:"px-3 py-2 rounded-lg bg-bg-subtle border border-border text-sm text-text-primary focus:outline-none focus:border-primary appearance-none cursor-pointer min-w-[150px]",title:"Sort logs",children:[(0,s.jsx)("option",{value:"newest",children:e("sortNewest")}),(0,s.jsx)("option",{value:"oldest",children:e("sortOldest")}),(0,s.jsx)("option",{value:"tokens_desc",children:e("sortTokensDesc")}),(0,s.jsx)("option",{value:"tokens_asc",children:e("sortTokensAsc")}),(0,s.jsx)("option",{value:"duration_desc",children:e("sortDurationDesc")}),(0,s.jsx)("option",{value:"duration_asc",children:e("sortDurationAsc")}),(0,s.jsx)("option",{value:"status_desc",children:e("sortStatusDesc")}),(0,s.jsx)("option",{value:"status_asc",children:e("sortStatusAsc")}),(0,s.jsx)("option",{value:"model_asc",children:e("sortModelAsc")}),(0,s.jsx)("option",{value:"model_desc",children:e("sortModelDesc")})]}),(0,s.jsx)("button",{onClick:()=>ee(!1),className:"p-2 rounded-lg hover:bg-bg-subtle text-text-muted hover:text-text-primary transition-colors",title:"Refresh",children:(0,s.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:"refresh"})})]}),(0,s.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[r.map(e=>(0,s.jsxs)("button",{onClick:()=>C(w===e.key?"all":e.key),className:`flex items-center gap-1.5 px-3 py-1 rounded-full text-xs font-medium border transition-all ${w===e.key?"error"===e.key?"bg-red-500/20 text-red-700 dark:text-red-400 border-red-500/40":"ok"===e.key?"bg-emerald-500/20 text-emerald-700 dark:text-emerald-400 border-emerald-500/40":"combo"===e.key?"bg-violet-500/20 text-violet-700 dark:text-violet-300 border-violet-500/40":"bg-primary text-white border-primary":"bg-bg-subtle border-border text-text-muted hover:border-text-muted"}`,children:[e.icon&&(0,s.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:e.icon}),e.label]},e.key)),en.length>0&&(0,s.jsx)("span",{className:"w-px h-5 bg-border mx-1"}),en.map(e=>{let t=u(e,J),r=n.RY[e]||{bg:"#374151",text:"#fff",label:t||e.toUpperCase()},a=t||r.label,l=M===e;return(0,s.jsx)("button",{onClick:()=>O(l?"":e),className:`px-3 py-1 rounded-full text-xs font-bold uppercase border transition-all ${l?"border-white/40 ring-1 ring-white/20":"border-transparent opacity-70 hover:opacity-100"}`,style:{backgroundColor:l?r.bg:`${r.bg}33`,color:l?r.text:r.bg},children:a},e)})]}),(0,s.jsxs)("div",{className:"flex flex-wrap items-center gap-1.5",children:[(0,s.jsx)("span",{className:"text-[10px] text-text-muted uppercase tracking-wider mr-1",children:"Columns"}),c.map(e=>(0,s.jsx)("button",{onClick:()=>Q(e.key),className:`px-2 py-0.5 rounded text-[10px] font-medium border transition-all ${X[e.key]?"bg-primary/15 text-primary border-primary/30":"bg-bg-subtle text-text-muted border-border opacity-50 hover:opacity-80"}`,children:e.label},e.key))]}),(0,s.jsx)(o.default,{className:"overflow-hidden bg-black/5 dark:bg-black/20",children:(0,s.jsx)("div",{className:"p-0 overflow-x-auto max-h-[calc(100vh-320px)] overflow-y-auto",children:g&&0===b.length?(0,s.jsx)("div",{className:"p-8 text-center text-text-muted",children:e("loadingLogs")}):0===b.length?(0,s.jsxs)("div",{className:"p-8 text-center text-text-muted",children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-[48px] mb-2 block opacity-40",children:"receipt_long"}),e("noLogs")]}):0===er.length?(0,s.jsx)("div",{className:"p-8 text-center text-text-muted",children:e("noMatchingLogs")}):(0,s.jsxs)("table",{className:"w-full text-left border-collapse text-xs",children:[(0,s.jsx)("thead",{className:"sticky top-0 z-10",style:{backgroundColor:"var(--color-bg, #fff)"},children:(0,s.jsxs)("tr",{className:"border-b border-border",style:{backgroundColor:"var(--color-bg, #fff)"},children:[X.status&&(0,s.jsx)("th",{className:"px-3 py-2.5 font-semibold text-text-muted uppercase tracking-wider text-[10px]",children:e("columns.status")}),X.cacheSource&&(0,s.jsx)("th",{className:"px-3 py-2.5 font-semibold text-text-muted uppercase tracking-wider text-[10px]",children:e("columns.cacheSource")}),X.model&&(0,s.jsx)("th",{className:"px-3 py-2.5 font-semibold text-text-muted uppercase tracking-wider text-[10px]",children:e("columns.model")}),X.requestedModel&&(0,s.jsx)("th",{className:"px-3 py-2.5 font-semibold text-text-muted uppercase tracking-wider text-[10px]",children:e("columns.requested")}),X.provider&&(0,s.jsx)("th",{className:"px-3 py-2.5 font-semibold text-text-muted uppercase tracking-wider text-[10px]",children:e("columns.provider")}),X.protocol&&(0,s.jsx)("th",{className:"px-3 py-2.5 font-semibold text-text-muted uppercase tracking-wider text-[10px]",children:e("columns.protocol")}),X.account&&(0,s.jsx)("th",{className:"px-3 py-2.5 font-semibold text-text-muted uppercase tracking-wider text-[10px]",children:e("columns.account")}),X.apiKey&&(0,s.jsx)("th",{className:"px-3 py-2.5 font-semibold text-text-muted uppercase tracking-wider text-[10px]",children:e("columns.apiKey")}),X.combo&&(0,s.jsx)("th",{className:"px-3 py-2.5 font-semibold text-text-muted uppercase tracking-wider text-[10px]",children:e("columns.combo")}),X.tokens&&(0,s.jsx)("th",{className:"px-3 py-2.5 font-semibold text-text-muted uppercase tracking-wider text-[10px] text-right",children:e("columns.tokens")}),X.tps&&(0,s.jsx)("th",{className:"px-3 py-2.5 font-semibold text-text-muted uppercase tracking-wider text-[10px] text-right",children:e("columns.tps")}),X.duration&&(0,s.jsx)("th",{className:"px-3 py-2.5 font-semibold text-text-muted uppercase tracking-wider text-[10px] text-right",children:e("columns.duration")}),X.time&&(0,s.jsx)("th",{className:"px-3 py-2.5 font-semibold text-text-muted uppercase tracking-wider text-[10px] text-right",children:e("columns.time")})]})}),(0,s.jsx)("tbody",{className:"divide-y divide-border/30",children:er.map(e=>{let r,a,l=(0,n._Z)(e.status),o=e.sourceFormat||e.provider,c=(0,n.sE)(o,e.provider),d=u(e.provider,J),x=n.RY[e.provider]||{bg:"#374151",text:"#fff",label:d||(e.provider||"-").toUpperCase()},m=d||x.label,p=e.status>=400,b="semantic"===e.cacheSource?{label:"SEM",title:"Semantic cache hit (served by OmniRoute)",className:"bg-emerald-500/15 text-emerald-700 dark:text-emerald-300 border border-emerald-500/30"}:{label:"UP",title:"Upstream provider response",className:"bg-sky-500/15 text-sky-700 dark:text-sky-300 border border-sky-500/30"};return(0,s.jsxs)("tr",{onClick:()=>es(e),className:`cursor-pointer hover:bg-primary/5 transition-colors ${p?"bg-red-500/5":""}`,children:[X.status&&(0,s.jsx)("td",{className:"px-3 py-2",children:(0,s.jsx)("span",{className:"inline-block px-2 py-0.5 rounded text-[10px] font-bold min-w-[36px] text-center",style:{backgroundColor:l.bg,color:l.text},children:e.status||"..."})}),X.cacheSource&&(0,s.jsx)("td",{className:"px-3 py-2",children:(0,s.jsx)("span",{className:`inline-block px-2 py-0.5 rounded text-[9px] font-bold uppercase ${b.className}`,title:b.title,children:"SEM"===b.label?"Semantic":"Upstream"})}),X.model&&(0,s.jsx)("td",{className:"px-3 py-2 font-medium text-primary font-mono text-[11px]",children:e.model}),X.requestedModel&&(0,s.jsx)("td",{className:"px-3 py-2 font-mono text-[11px]",children:e.requestedModel?(0,s.jsx)("span",{className:e.requestedModel!==e.model?"text-amber-600 dark:text-amber-400":"text-text-muted",title:e.requestedModel!==e.model?`Requested ${e.requestedModel}, routed as ${e.model}`:e.requestedModel,children:e.requestedModel}):(0,s.jsx)("span",{className:"text-text-muted text-[10px]",children:"—"})}),X.provider&&(0,s.jsx)("td",{className:"px-3 py-2",children:(0,s.jsx)("span",{className:"inline-block px-2 py-0.5 rounded text-[9px] font-bold uppercase",style:{backgroundColor:x.bg,color:x.text},children:m})}),X.protocol&&(0,s.jsx)("td",{className:"px-3 py-2",children:(0,s.jsx)("span",{className:"inline-block px-2 py-0.5 rounded text-[9px] font-bold uppercase",style:{backgroundColor:c.bg,color:c.text},children:c.label})}),X.account&&(0,s.jsx)("td",{className:"px-3 py-2 text-text-muted truncate max-w-[120px]",title:e.account,children:(0,i.Ib)(e.account,t)}),X.apiKey&&(0,s.jsx)("td",{className:"px-3 py-2 text-text-muted truncate max-w-[140px]",title:e.apiKeyName||e.apiKeyId||"No API key",children:(0,i.VO)(e.apiKeyName,e.apiKeyId)}),X.combo&&(0,s.jsx)("td",{className:"px-3 py-2",children:e.comboName?(0,s.jsx)("span",{className:"inline-block px-2 py-0.5 rounded-full text-[9px] font-bold bg-violet-500/20 text-violet-800 dark:text-violet-300 border border-violet-500/40",children:e.comboName}):(0,s.jsx)("span",{className:"text-text-muted text-[10px]",children:"—"})}),X.tokens&&(0,s.jsxs)("td",{className:"px-3 py-2 text-right whitespace-nowrap",children:[(0,s.jsx)("span",{className:"text-text-muted",children:"TI:"})," ",(0,s.jsx)("span",{className:"text-primary",children:e.tokens?.in?.toLocaleString()||0}),(0,s.jsx)("span",{className:"mx-1 text-border",children:"|"}),(0,s.jsx)("span",{className:"text-text-muted",children:"TO:"})," ",(0,s.jsx)("span",{className:"text-emerald-700 dark:text-emerald-400",children:e.tokens?.out?.toLocaleString()||0})]}),X.tps&&(0,s.jsx)("td",{className:"px-3 py-2 text-right whitespace-nowrap font-mono",children:(a=(r=h(e))<=0?"text-text-muted":r>=80?"text-emerald-600 dark:text-emerald-400":r>=30?"text-sky-600 dark:text-sky-400":"text-amber-600 dark:text-amber-400",(0,s.jsx)("span",{className:a,title:`${r.toFixed(2)} tokens/sec`,children:r<=0?"—":r>=100?Math.round(r).toLocaleString():r.toFixed(1)}))}),X.duration&&(0,s.jsx)("td",{className:"px-3 py-2 text-right text-text-muted font-mono",children:(0,i.a3)(e.duration)}),X.time&&(0,s.jsx)("td",{className:"px-3 py-2 text-right text-text-muted",children:(0,i.fU)(e.timestamp)})]},e.id)})})]})})}),(0,s.jsx)("div",{className:"text-[10px] text-text-muted italic",children:e("callLogsInfo",{dataDir:"{DATA_DIR}/call_logs/",retentionDays:"CALL_LOG_RETENTION_DAYS",maxEntries:"CALL_LOG_MAX_ENTRIES"})}),F&&(0,s.jsx)(d,{log:F,detail:K,loading:D,onClose:()=>{$(null),z(null)},onCopy:x.l})]})}},42912:(e,t,r)=>{r.d(t,{default:()=>j});var s=r(95155),a=r(12115),l=r(14051),o=r.n(l),n=r(98500),i=r.n(n),c=r(73321),d=r(67040),x=r(49007),m=r(33637),u=r(35806),p=r(71361);let h={connected:{icon:"cloud_done",color:"text-green-500",label:"Cloud"},syncing:{icon:"cloud_sync",color:"text-blue-400 animate-pulse",label:"Syncing..."},disconnected:{icon:"cloud_off",color:"text-amber-500",label:"Cloud Off"},error:{icon:"cloud_off",color:"text-red-400",label:"Cloud Error"},disabled:{icon:"cloud_off",color:"text-text-muted/50",label:"Disabled"}};function b({collapsed:e=!1}){let[t,r]=(0,a.useState)("disabled"),[l,o]=(0,a.useState)(null),n=(0,a.useRef)(!0),i=(0,c.useRouter)(),d=(0,a.useCallback)(async()=>{try{let e=await fetch("/api/sync/cloud");if(!n.current)return;if(!e.ok)return void r("disconnected");let t=await e.json();if(!n.current)return;t.enabled?t.syncing?r("syncing"):t.connected?(r("connected"),t.lastSync&&o(new Date(t.lastSync))):r("disconnected"):r("disabled")}catch{n.current&&r("disconnected")}},[]);if((0,a.useEffect)(()=>{n.current=!0,queueMicrotask(d);let e=setInterval(d,3e4),t=()=>{setTimeout(d,500)};return globalThis.addEventListener("cloud-status-changed",t),()=>{n.current=!1,clearInterval(e),globalThis.removeEventListener("cloud-status-changed",t)}},[d]),"disabled"===t)return null;let x=h[t];return(0,s.jsxs)("button",{onClick:()=>i.push("/dashboard/endpoint"),className:"flex items-center gap-2 px-3 py-1.5 text-xs rounded-lg hover:bg-white/5 transition-colors cursor-pointer w-full",title:l?`Cloud ${"connected"===t?"connected":"disconnected"} — Last sync: ${l.toLocaleTimeString()}`:x.label,"aria-label":`Cloud sync status: ${x.label}`,children:[(0,s.jsx)("span",{className:`material-symbols-outlined text-[16px] ${x.color}`,"aria-hidden":"true",children:x.icon}),!e&&(0,s.jsx)("span",{className:`truncate ${"connected"===t?"text-green-500":"text-text-muted"}`,children:x.label})]})}var f=r(50910),g=r(15559);let y="1"===r(41463).env.NEXT_PUBLIC_OMNIROUTE_E2E_MODE;function j({onClose:e,collapsed:t=!1,onToggleCollapse:r,isMacElectron:l=!1}){let o=(0,c.usePathname)(),n=(0,f.c)("sidebar"),h=(0,f.c)("common"),[v,N]=(0,a.useState)(!1),[k,w]=(0,a.useState)(!1),[C,S]=(0,a.useState)(!1),[A,T]=(0,a.useState)(!1),[I,M]=(0,a.useState)(!1),[O,R]=(0,a.useState)(!1),[L,E]=(0,a.useState)([]),[_,F]=(0,a.useState)(null),[$,D]=(0,a.useState)(null);(0,a.useEffect)(()=>{fetch("/api/settings").then(e=>e.json()).then(e=>{R(e?.debugMode===!0),E((0,g.ii)(e?.[g.ad])),F(e?.instanceName||null),D(e?.customLogoBase64||e?.customLogoUrl||null)}).catch(()=>{});let e=e=>{let t=e.detail||{};"debugMode"in t&&R(!0===t.debugMode),g.ad in t&&E((0,g.ii)(t[g.ad])),"instanceName"in t&&F(t.instanceName||null),"customLogoBase64"in t?D(t.customLogoBase64||null):"customLogoUrl"in t&&D(t.customLogoUrl||null)};return window.addEventListener(g.uj,e),()=>{window.removeEventListener(g.uj,e)}},[]);let P=async()=>{S(!0);try{await fetch("/api/shutdown",{method:"POST"})}catch(e){}S(!1),N(!1),M(!0)},K=async()=>{T(!0);try{await fetch("/api/restart",{method:"POST"})}catch(e){}T(!1),w(!1),M(!0),setTimeout(()=>{globalThis.location.reload()},3e3)},z=new Set(L),q=g.Ke.filter(e=>"debug"!==e.visibility||O).map(e=>{let t,r;return{...e,title:(t=e.titleKey,r=e.titleFallback,"function"==typeof n.has&&n.has(t)?n(t):r),items:e.items.map(e=>({...e,label:n(e.i18nKey)})).filter(e=>!z.has(e.id))}}).filter(e=>e.items.length>0),B=function(e,t){let r=null;for(let s of t)if(!s.external&&function(e,t,r=!1){return!!e&&(r?e===t:e===t||e.startsWith(`${t}/`))}(e,s.href,!0===s.exact)){if(!r||s.href.length>r.href.length){r=s;continue}s.href.length===r.href.length&&s.exact&&!r.exact&&(r=s)}return r?.href||null}(o,q.flatMap(e=>e.items)),U=r=>{let a=!r.external&&B===r.href,l=(0,d.cn)("flex items-center gap-3 rounded-lg transition-all group",t?"justify-center px-2 py-2.5":"px-4 py-2",a?"bg-primary/10 text-primary":"text-text-muted hover:bg-surface/50 hover:text-text-main"),o=(0,d.cn)("material-symbols-outlined text-[18px]",a?"fill-1":"group-hover:text-primary transition-colors"),n=(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("span",{className:o,children:r.icon}),!t&&(0,s.jsx)("span",{className:"text-sm font-medium",children:r.label})]});return r.external?(0,s.jsx)("a",{href:r.href,target:"_blank",rel:"noopener noreferrer",onClick:e,title:t?r.label:void 0,className:l,children:n},r.href):(0,s.jsx)(i(),{href:r.href,onClick:e,title:t?r.label:void 0,className:l,children:n},r.href)};return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("aside",{className:(0,d.cn)("flex h-full min-h-0 flex-col border-r border-black/5 bg-sidebar transition-all duration-300 ease-in-out dark:border-white/5",t?"w-16":"w-80"),style:{paddingTop:l?"var(--desktop-safe-top)":void 0},children:[(0,s.jsx)("a",{href:"#main-content",className:"sr-only focus:not-sr-only focus:absolute focus:z-50 focus:p-3 focus:bg-primary focus:text-white focus:rounded-md focus:m-2",children:"Skip to content"}),(r||!l)&&(0,s.jsxs)("div",{className:(0,d.cn)("flex items-center gap-2 pb-2",l?"pt-3":"pt-5",t?"px-3 justify-center":"px-6"),"aria-hidden":"true",children:[!l&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("div",{className:"w-3 h-3 rounded-full bg-[#FF5F56]"}),(0,s.jsx)("div",{className:"w-3 h-3 rounded-full bg-[#FFBD2E]"}),(0,s.jsx)("div",{className:"w-3 h-3 rounded-full bg-[#27C93F]"})]}),!t&&(0,s.jsx)("div",{className:"flex-1"}),r&&(0,s.jsx)("button",{onClick:r,title:t?"Expand sidebar":"Collapse sidebar","aria-expanded":!t,"aria-label":t?"Expand sidebar":"Collapse sidebar",className:(0,d.cn)("rounded-md p-1 text-text-muted/50 transition-colors hover:bg-black/5 hover:text-text-muted dark:hover:bg-white/5",t&&!l&&"mt-2",l&&"ml-auto"),children:(0,s.jsx)("span",{className:"material-symbols-outlined text-[16px]","aria-hidden":"true",children:t?"chevron_right":"chevron_left"})})]}),(0,s.jsx)("div",{className:(0,d.cn)("py-4",t?"px-2":"px-6"),children:(0,s.jsxs)(i(),{href:"/dashboard",className:(0,d.cn)("flex items-center",t?"justify-center":"gap-3"),children:[(0,s.jsx)("div",{className:"flex items-center justify-center size-9 rounded bg-linear-to-br from-[#E54D5E] to-[#C93D4E] shrink-0",children:$?(0,s.jsx)("img",{src:$,alt:_||x.v.name,className:"size-5 object-contain"}):(0,s.jsx)(m.A,{size:20,className:"text-white"})}),!t&&(0,s.jsxs)("div",{className:"flex flex-col",children:[(0,s.jsx)("h1",{className:"text-lg font-semibold tracking-tight text-text-main",children:_||x.v.name}),(0,s.jsxs)("span",{className:"text-xs text-text-muted",children:["v",x.v.version]})]})]})}),(0,s.jsx)("nav",{"aria-label":"Main navigation",className:(0,d.cn)("min-h-0 flex-1 space-y-1 overflow-y-auto py-2 custom-scrollbar",t?"px-2":"px-4"),children:q.map(e=>{let r=!1!==e.showTitleInSidebar;return(0,s.jsxs)("div",{className:r?"pt-4 mt-2":void 0,children:[!t&&r&&(0,s.jsx)("p",{className:"px-4 text-xs font-semibold text-text-muted/60 uppercase tracking-wider mb-2",children:e.title}),t&&r&&(0,s.jsx)("div",{className:"border-t border-black/5 dark:border-white/5 mb-2"}),e.items.map(U)]},e.id)})}),!y&&(0,s.jsx)(b,{collapsed:t}),(0,s.jsxs)("div",{className:(0,d.cn)("shrink-0 border-t border-black/5 dark:border-white/5",t?"p-2 flex flex-col gap-1":"p-3 flex gap-2"),style:{paddingBottom:l?"calc(0.75rem + var(--desktop-safe-bottom))":void 0},children:[(0,s.jsxs)("button",{onClick:()=>w(!0),title:n("restart"),className:(0,d.cn)("flex items-center justify-center gap-2 rounded-lg font-medium transition-all","text-amber-500 hover:bg-amber-500/10 border border-amber-500/20 hover:border-amber-500/40",t?"p-2":"flex-1 min-w-0 px-3 py-2 text-xs"),children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:"restart_alt"}),!t&&n("restart")]}),(0,s.jsxs)("button",{onClick:()=>N(!0),title:n("shutdown"),className:(0,d.cn)("flex items-center justify-center gap-2 rounded-lg font-medium transition-all","text-red-500 hover:bg-red-500/10 border border-red-500/20 hover:border-red-500/40",t?"p-2":"flex-1 min-w-0 px-3 py-2 text-xs"),children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:"power_settings_new"}),!t&&n("shutdown")]})]})]}),(0,s.jsx)(p.ConfirmModal,{isOpen:v,onClose:()=>N(!1),onConfirm:P,title:n("shutdown"),message:n("shutdownConfirm"),confirmText:n("shutdown"),cancelText:h("cancel"),variant:"danger",loading:C}),(0,s.jsx)(p.ConfirmModal,{isOpen:k,onClose:()=>w(!1),onConfirm:K,title:n("restart"),message:n("restartConfirm"),confirmText:n("restart"),cancelText:h("cancel"),variant:"warning",loading:A}),I&&(0,s.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/80 backdrop-blur-sm",children:(0,s.jsxs)("div",{className:"text-center p-8",children:[(0,s.jsx)("div",{className:"flex items-center justify-center size-16 rounded-full bg-red-500/20 text-red-500 mx-auto mb-4",children:(0,s.jsx)("span",{className:"material-symbols-outlined text-[32px]",children:"power_off"})}),(0,s.jsx)("h2",{className:"text-xl font-semibold text-white mb-2",children:"Server Disconnected"}),(0,s.jsx)("p",{className:"text-text-muted mb-6",children:"The proxy server has been stopped or is restarting."}),(0,s.jsx)(u.default,{variant:"secondary",onClick:()=>globalThis.location.reload(),children:"Reload Page"})]})})]})}j.propTypes={onClose:o().func,collapsed:o().bool,onToggleCollapse:o().func,isMacElectron:o().bool}},42994:(e,t,r)=>{r.d(t,{default:()=>o});var s=r(95155),a=r(12115),l=r(67040);function o({label:e,options:t=[],value:r,onChange:n,placeholder:i="Select an option",error:c,hint:d,disabled:x=!1,required:m=!1,className:u,selectClassName:p,id:h,...b}){let f=(0,a.useId)(),g=h||f,y=c?`${g}-error`:void 0,j=d&&!c?`${g}-hint`:void 0,v=[y,j].filter(Boolean).join(" ")||void 0;return(0,s.jsxs)("div",{className:(0,l.cn)("flex flex-col gap-1.5",u),children:[e&&(0,s.jsxs)("label",{htmlFor:g,className:"text-sm font-medium text-text-main",children:[e,m&&(0,s.jsx)("span",{className:"text-red-500 ml-1","aria-hidden":"true",children:"*"})]}),(0,s.jsxs)("div",{className:"relative",children:[(0,s.jsxs)("select",{id:g,value:r,onChange:n,disabled:x,required:m,"aria-required":m||void 0,"aria-invalid":!!c||void 0,"aria-describedby":v,className:(0,l.cn)("w-full py-2 px-3 pr-10 text-sm text-text-main","bg-surface border border-black/10 dark:border-white/10 rounded-md appearance-none","focus:ring-1 focus:ring-primary/30 focus:border-primary/50 focus:outline-none","transition-all disabled:opacity-50 disabled:cursor-not-allowed","text-[16px] sm:text-sm",c?"border-red-500 focus:border-red-500 focus:ring-red-500/20":"",p),...b,children:[(0,s.jsx)("option",{value:"",disabled:!0,className:"bg-surface text-text-muted",children:i}),t.map(e=>(0,s.jsx)("option",{value:e.value,className:"bg-surface text-text-main",children:e.label},e.value))]}),(0,s.jsx)("div",{className:"absolute inset-y-0 right-0 flex items-center pr-3 pointer-events-none text-text-muted","aria-hidden":"true",children:(0,s.jsx)("span",{className:"material-symbols-outlined text-[20px]",children:"expand_more"})})]}),c&&(0,s.jsxs)("p",{id:y,className:"text-xs text-red-500 flex items-center gap-1",role:"alert",children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-[14px]","aria-hidden":"true",children:"error"}),c]}),d&&!c&&(0,s.jsx)("p",{id:j,className:"text-xs text-text-muted",children:d})]})}},44638:(e,t,r)=>{r.d(t,{default:()=>l});var s=r(95155),a=r(50910);function l({columns:e=[],data:t=[],renderCell:r,renderHeader:o,onRowClick:n,selectedId:i,loading:c=!1,maxHeight:d="calc(100vh - 320px)",emptyIcon:x="\uD83D\uDCED",emptyMessage:m}){let u=(0,a.c)("common"),p=m??u("noData");return c?(0,s.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",padding:"48px 24px",color:"var(--text-secondary, #888)",fontSize:"14px"},children:[(0,s.jsx)("span",{style:{animation:"spin 1s linear infinite",marginRight:"8px"},children:"⏳"}),u("loading"),(0,s.jsx)("style",{children:"@keyframes spin { to { transform: rotate(360deg); } }"})]}):0===t.length?(0,s.jsxs)("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",padding:"48px 24px",color:"var(--text-secondary, #888)",fontSize:"14px"},children:[(0,s.jsx)("span",{style:{fontSize:"32px",marginBottom:"8px",opacity:.6},children:x}),p]}):(0,s.jsx)("div",{style:{overflow:"auto",maxHeight:d,borderRadius:"8px"},children:(0,s.jsxs)("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:"12px",tableLayout:"auto"},children:[(0,s.jsx)("thead",{children:(0,s.jsx)("tr",{children:e.map(e=>(0,s.jsx)("th",{style:{padding:"8px 10px",textAlign:"left",fontWeight:600,color:"var(--text-secondary, #888)",borderBottom:"1px solid rgba(255,255,255,0.08)",position:"sticky",top:0,background:"var(--bg-table-header, rgba(15,15,25,0.95))",zIndex:1,whiteSpace:"nowrap",fontSize:"11px",textTransform:"uppercase",letterSpacing:"0.5px"},children:o?o(e):e.label},e.key))})}),(0,s.jsx)("tbody",{children:t.map((t,a)=>(0,s.jsx)("tr",{onClick:()=>n?.(t),style:{cursor:n?"pointer":"default",background:t.id===i?"rgba(99,102,241,0.1)":a%2==0?"transparent":"rgba(255,255,255,0.02)",transition:"background 0.15s"},onMouseEnter:e=>{t.id!==i&&(e.currentTarget.style.background="rgba(255,255,255,0.04)")},onMouseLeave:e=>{t.id!==i&&(e.currentTarget.style.background=a%2==0?"transparent":"rgba(255,255,255,0.02)")},children:e.map(e=>(0,s.jsx)("td",{style:{padding:"6px 10px",borderBottom:"1px solid rgba(255,255,255,0.04)",whiteSpace:"nowrap",maxWidth:e.maxWidth||"200px",overflow:"hidden",textOverflow:"ellipsis"},children:r(t,e)},e.key))},t.id||a))})]})})}},45624:(e,t,r)=>{r.d(t,{default:()=>K});var s=r(95155),a=r(12115),l=r(81060),o=r(92542),n=r(8898),i=r(55510),c=r(99333),d=r(1728),x=r(68444),m=r(32539),u=r(59656),p=r(65671),h=r(54945),b=r(75319),f=r(80865),g=r(53201),y=r(67389),j=r(90639),v=r(53459);function N(e,t){try{return new Intl.DateTimeFormat(e,t)}catch{return new Intl.DateTimeFormat(void 0,t)}}function k({active:e,payload:t,label:r,formatter:a}){return e&&t?.length?(0,s.jsxs)("div",{className:"rounded-lg border border-white/10 bg-surface px-3 py-2 text-xs shadow-lg",children:[r&&(0,s.jsx)("div",{className:"font-semibold text-text-main mb-1",children:r}),t.map((e,t)=>(0,s.jsxs)("div",{className:"flex items-center gap-1.5 text-text-muted",children:[(0,s.jsx)("span",{className:"w-2 h-2 rounded-full shrink-0",style:{backgroundColor:e.color}}),(0,s.jsxs)("span",{children:[e.name,":"]}),(0,s.jsx)("span",{className:"font-mono font-medium text-text-main",children:a?a(e.value):e.value})]},t))]}):null}function w({active:e,sortOrder:t}){return e?(0,s.jsx)("span",{className:"material-symbols-outlined text-[12px] text-primary",children:"asc"===t?"expand_less":"expand_more"}):(0,s.jsx)("span",{className:"material-symbols-outlined text-[12px] opacity-0 group-hover:opacity-30",children:"unfold_more"})}function C({icon:e,label:t,value:r,subValue:a,color:o="text-text-main"}){return(0,s.jsxs)(l.default,{className:"px-4 py-3 flex flex-col gap-1 min-w-0",children:[(0,s.jsxs)("div",{className:"flex items-center gap-1.5 text-text-muted text-[11px] uppercase font-semibold tracking-wide min-w-0",children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-[14px] shrink-0",children:e}),(0,s.jsx)("span",{className:"truncate",children:t})]}),(0,s.jsx)("span",{className:`text-2xl font-bold ${o} truncate`,title:String(r),children:r}),a&&(0,s.jsx)("span",{className:"text-xs text-text-muted truncate",children:a})]})}function S({sections:e}){return(0,s.jsx)(l.default,{className:"px-5 py-4",children:(0,s.jsx)("div",{className:"flex flex-col gap-3",children:e.map((e,t)=>(0,s.jsxs)("div",{children:[t>0&&(0,s.jsx)("div",{className:"border-t border-black/[0.06] dark:border-white/[0.06] mb-3"}),(0,s.jsx)("div",{className:"text-[10px] uppercase font-semibold tracking-widest text-text-muted/50 mb-2",children:e.title}),(0,s.jsx)("div",{className:e.wideValues?"grid grid-cols-1 sm:grid-cols-2 md:grid-cols-4 gap-x-5 gap-y-2":"grid grid-cols-2 md:grid-cols-4 gap-x-5 gap-y-2",children:e.items.map((t,r)=>(0,s.jsxs)("div",{className:"flex items-center justify-between gap-2 min-w-0 py-0.5",children:[(0,s.jsxs)("div",{className:`flex items-center gap-1.5 ${e.wideValues?"shrink-0":"min-w-0"}`,children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-[14px] text-text-muted shrink-0",children:t.icon}),(0,s.jsx)("span",{className:`text-[11px] uppercase font-semibold tracking-wide text-text-muted ${e.wideValues?"whitespace-nowrap":"truncate"}`,children:t.label})]}),(0,s.jsx)("span",{className:`text-sm font-bold text-right ${e.wideValues?"truncate min-w-0":"shrink-0"} ${t.color||"text-text-main"}`,title:String(t.value),children:t.value})]},r))})]},t))})})}function A({activityMap:e}){let t=(0,a.useRef)(null),r=(0,a.useMemo)(()=>{let t=new Date,r=[],s=0;for(let a=364;a>=0;a--){let l=new Date(t);l.setDate(l.getDate()-a);let o=`${l.getFullYear()}-${String(l.getMonth()+1).padStart(2,"0")}-${String(l.getDate()).padStart(2,"0")}`,n=e?.[o]||0;n>s&&(s=n),r.push({date:o,value:n,dayOfWeek:l.getDay()})}return{days:r,maxVal:s}},[e]),o=(0,a.useMemo)(()=>{let e=[],t=[],s=r.days[0]?.dayOfWeek||0;for(let e=0;e<s;e++)t.push(null);for(let s of r.days)t.push(s),7===t.length&&(e.push(t),t=[]);return t.length>0&&e.push(t),e},[r]);(0,a.useEffect)(()=>{t.current&&(t.current.scrollLeft=t.current.scrollWidth)},[o]);let i=(0,a.useMemo)(()=>{let e=[],t=-1;return o.forEach((r,s)=>{let a=r.find(e=>null!==e);if(a){let r=new Date(a.date).getMonth();r!==t&&(e.push({weekIdx:s,label:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"][r]}),t=r)}}),e},[o]);return(0,s.jsxs)(l.default,{className:"p-4 h-full min-w-0 overflow-hidden",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between mb-3",children:[(0,s.jsx)("h3",{className:"text-sm font-semibold text-text-muted uppercase tracking-wider",children:"Activity"}),(0,s.jsxs)("span",{className:"text-xs text-text-muted",children:[Object.keys(e||{}).length," active days \xb7"," ",(0,n.VK)(Object.values(e||{}).reduce((e,t)=>e+t,0))," tokens \xb7 365 days"]})]}),(0,s.jsx)("div",{ref:t,className:"overflow-x-auto",children:(0,s.jsxs)("div",{className:"w-max",children:[(0,s.jsx)("div",{className:"flex gap-[3px] mb-1 ml-6",style:{fontSize:"10px"},children:i.map((e,t)=>(0,s.jsx)("span",{className:"text-text-muted",style:{position:"relative",left:`${13*e.weekIdx}px`,marginLeft:0===t?0:"-20px"},children:e.label},t))}),(0,s.jsxs)("div",{className:"flex gap-[3px]",children:[(0,s.jsxs)("div",{className:"flex flex-col gap-[3px] shrink-0 text-[10px] text-text-muted pr-1 sticky left-0 z-10 bg-surface",children:[(0,s.jsx)("span",{className:"h-[10px]"}),(0,s.jsx)("span",{className:"h-[10px] leading-[10px]",children:"Mon"}),(0,s.jsx)("span",{className:"h-[10px]"}),(0,s.jsx)("span",{className:"h-[10px] leading-[10px]",children:"Wed"}),(0,s.jsx)("span",{className:"h-[10px]"}),(0,s.jsx)("span",{className:"h-[10px] leading-[10px]",children:"Fri"}),(0,s.jsx)("span",{className:"h-[10px]"})]}),o.map((e,t)=>(0,s.jsx)("div",{className:"flex flex-col gap-[3px]",children:e.map((e,t)=>(0,s.jsx)("div",{title:e?`${e.date}: ${(0,n.xW)(e.value)} tokens`:"",className:`w-[10px] h-[10px] rounded-[2px] ${e?function(e){if(!e||0===e)return"bg-white/[0.04]";let t=Math.min(e/(r.maxVal||1),1);return t<.25?"bg-primary/20":t<.5?"bg-primary/40":t<.75?"bg-primary/60":"bg-primary/90"}(e.value):"bg-transparent"}`},t))},t))]})]})}),(0,s.jsxs)("div",{className:"flex items-center gap-1 mt-2 ml-6 text-[10px] text-text-muted",children:[(0,s.jsx)("span",{children:"Less"}),(0,s.jsx)("div",{className:"w-[10px] h-[10px] rounded-[2px] bg-white/[0.04]"}),(0,s.jsx)("div",{className:"w-[10px] h-[10px] rounded-[2px] bg-primary/20"}),(0,s.jsx)("div",{className:"w-[10px] h-[10px] rounded-[2px] bg-primary/40"}),(0,s.jsx)("div",{className:"w-[10px] h-[10px] rounded-[2px] bg-primary/60"}),(0,s.jsx)("div",{className:"w-[10px] h-[10px] rounded-[2px] bg-primary/90"}),(0,s.jsx)("span",{children:"More"})]})]})}function T({dailyTrend:e}){let t=(0,a.useMemo)(()=>(e||[]).map(e=>({date:e.date.slice(5),Input:e.promptTokens,Output:e.completionTokens,Cost:e.cost||0})),[e]),r=(0,a.useMemo)(()=>t.some(e=>e.Cost>0),[t]);return t.length?(0,s.jsxs)(l.default,{className:"p-4 flex-1",children:[(0,s.jsx)("h3",{className:"text-sm font-semibold text-text-muted uppercase tracking-wider mb-3",children:"Token & Cost Trend"}),(0,s.jsx)(d.u,{width:"100%",height:140,children:(0,s.jsxs)(x.X,{data:t,margin:{top:0,right:40*!!r,left:0,bottom:0},children:[(0,s.jsx)(m.W,{dataKey:"date",tick:{fontSize:9,fill:"var(--text-muted)"},axisLine:!1,tickLine:!1,interval:Math.max(Math.floor(t.length/6),0)}),r&&(0,s.jsx)(u.h,{yAxisId:"cost",orientation:"right",tick:{fontSize:8,fill:"#f59e0b"},axisLine:!1,tickLine:!1,tickFormatter:e=>`$${e.toFixed(2)}`,width:36}),(0,s.jsx)(p.m,{content:(0,s.jsx)(I,{}),cursor:{fill:"rgba(255,255,255,0.04)"}}),(0,s.jsx)(h.yP,{dataKey:"Input",stackId:"a",fill:"var(--primary)",opacity:.7,radius:[0,0,0,0],animationDuration:600}),(0,s.jsx)(h.yP,{dataKey:"Output",stackId:"a",fill:"#10b981",opacity:.7,radius:[3,3,0,0],animationDuration:600}),r&&(0,s.jsx)(b.N1,{yAxisId:"cost",type:"monotone",dataKey:"Cost",stroke:"#f59e0b",strokeWidth:2,dot:!1,animationDuration:600})]})}),(0,s.jsxs)("div",{className:"flex items-center gap-4 mt-2 text-[10px] text-text-muted",children:[(0,s.jsxs)("span",{className:"flex items-center gap-1",children:[(0,s.jsx)("span",{className:"w-2 h-2 rounded-full bg-primary/70"})," Input"]}),(0,s.jsxs)("span",{className:"flex items-center gap-1",children:[(0,s.jsx)("span",{className:"w-2 h-2 rounded-full bg-emerald-500/70"})," Output"]}),r&&(0,s.jsxs)("span",{className:"flex items-center gap-1",children:[(0,s.jsx)("span",{className:"w-2 h-2 rounded-full bg-amber-500/70"})," Cost ($)"]})]})]}):(0,s.jsxs)(l.default,{className:"p-4",children:[(0,s.jsx)("h3",{className:"text-sm font-semibold text-text-muted uppercase tracking-wider mb-3",children:"Token Trend"}),(0,s.jsx)("div",{className:"text-center text-text-muted text-sm py-8",children:"No data"})]})}function I({active:e,payload:t,label:r}){return e&&t?.length?(0,s.jsxs)("div",{className:"rounded-lg border border-white/10 bg-surface px-3 py-2 text-xs shadow-lg",children:[r&&(0,s.jsx)("div",{className:"font-semibold text-text-main mb-1",children:r}),t.map((e,t)=>(0,s.jsxs)("div",{className:"flex items-center gap-1.5 text-text-muted",children:[(0,s.jsx)("span",{className:"w-2 h-2 rounded-full shrink-0",style:{backgroundColor:e.color}}),(0,s.jsxs)("span",{children:[e.name,":"]}),(0,s.jsx)("span",{className:"font-mono font-medium text-text-main",children:"Cost"===e.name?(0,n.F0)(e.value):(0,n.VK)(e.value)})]},t))]}):null}function M({byAccount:e}){let t=(0,a.useMemo)(()=>e||[],[e]),r=t.length>0,o=(0,a.useMemo)(()=>t.slice(0,8).map((e,t)=>({name:e.account,value:e.totalTokens,fill:(0,c.ng)(t)})),[t]);return r?(0,s.jsxs)(l.default,{className:"p-4 flex-1",children:[(0,s.jsx)("h3",{className:"text-sm font-semibold text-text-muted uppercase tracking-wider mb-3",children:"By Account"}),(0,s.jsxs)("div",{className:"flex items-center gap-4",children:[(0,s.jsx)(d.u,{width:120,height:120,children:(0,s.jsxs)(f.r,{children:[(0,s.jsx)(g.Fq,{data:o,dataKey:"value",nameKey:"name",cx:"50%",cy:"50%",innerRadius:28,outerRadius:55,paddingAngle:1,animationDuration:600,children:o.map((e,t)=>(0,s.jsx)(y.f,{fill:e.fill,stroke:"none"},t))}),(0,s.jsx)(p.m,{content:(0,s.jsx)(k,{formatter:n.VK})})]})}),(0,s.jsx)("div",{className:"flex flex-col gap-1 min-w-0 flex-1",children:o.map((e,t)=>(0,s.jsxs)("div",{className:"flex items-center justify-between gap-2 text-xs",children:[(0,s.jsxs)("div",{className:"flex items-center gap-1.5 min-w-0",children:[(0,s.jsx)("span",{className:"w-2 h-2 rounded-full shrink-0",style:{backgroundColor:e.fill}}),(0,s.jsx)("span",{className:"truncate text-text-main",children:e.name})]}),(0,s.jsx)("span",{className:"font-mono font-medium text-text-muted shrink-0",children:(0,n.VK)(e.value)})]},t))})]})]}):(0,s.jsxs)(l.default,{className:"p-4 flex-1",children:[(0,s.jsx)("h3",{className:"text-sm font-semibold text-text-muted uppercase tracking-wider mb-3",children:"By Account"}),(0,s.jsx)("div",{className:"text-center text-text-muted text-sm py-8",children:"No data"})]})}function O({byApiKey:e}){let t=(0,a.useMemo)(()=>e||[],[e]),r=t.length>0,o=(0,a.useMemo)(()=>t.slice(0,8).map((e,t)=>({name:(0,n.VO)(e.apiKeyName,e.apiKeyId),fullName:e.apiKeyName||e.apiKeyId||"unknown",value:e.totalTokens,fill:(0,c.ng)(t)})),[t]);return r?(0,s.jsxs)(l.default,{className:"p-4 flex-1",children:[(0,s.jsx)("h3",{className:"text-sm font-semibold text-text-muted uppercase tracking-wider mb-3",children:"By API Key"}),(0,s.jsxs)("div",{className:"flex items-center gap-4",children:[(0,s.jsx)(d.u,{width:120,height:120,children:(0,s.jsxs)(f.r,{children:[(0,s.jsx)(g.Fq,{data:o,dataKey:"value",nameKey:"name",cx:"50%",cy:"50%",innerRadius:28,outerRadius:55,paddingAngle:1,animationDuration:600,children:o.map((e,t)=>(0,s.jsx)(y.f,{fill:e.fill,stroke:"none"},t))}),(0,s.jsx)(p.m,{content:(0,s.jsx)(k,{formatter:n.VK})})]})}),(0,s.jsx)("div",{className:"flex flex-col gap-1 min-w-0 flex-1",children:o.map((e,t)=>(0,s.jsxs)("div",{className:"flex items-center justify-between gap-2 text-xs",children:[(0,s.jsxs)("div",{className:"flex items-center gap-1.5 min-w-0",children:[(0,s.jsx)("span",{className:"w-2 h-2 rounded-full shrink-0",style:{backgroundColor:e.fill}}),(0,s.jsx)("span",{className:"truncate text-text-main",title:e.fullName,children:e.name})]}),(0,s.jsx)("span",{className:"font-mono font-medium text-text-muted shrink-0",children:(0,n.VK)(e.value)})]},`${e.fullName}-${t}`))})]})]}):(0,s.jsxs)(l.default,{className:"p-4 flex-1",children:[(0,s.jsx)("h3",{className:"text-sm font-semibold text-text-muted uppercase tracking-wider mb-3",children:"By API Key"}),(0,s.jsx)("div",{className:"text-center text-text-muted text-sm py-8",children:"No data"})]})}function R({byApiKey:e}){let[t,r]=(0,a.useState)(""),[o,i]=(0,a.useState)("totalTokens"),[c,d]=(0,a.useState)("desc"),x=(0,a.useMemo)(()=>e||[],[e]),m=(0,a.useMemo)(()=>{let e=t.trim().toLowerCase();return e?x.filter(t=>(t.apiKeyName||"").toLowerCase().includes(e)||(t.apiKeyId||"").toLowerCase().includes(e)):x},[x,t]),u=(0,a.useMemo)(()=>{let e=[...m];return e.sort((e,t)=>{let r=e[o]??0,s=t[o]??0;return"string"==typeof r?"asc"===c?r.localeCompare(s):s.localeCompare(r):"asc"===c?r-s:s-r}),e},[m,o,c]),p=(0,a.useCallback)(e=>{o===e?d(e=>"asc"===e?"desc":"asc"):(i(e),d("desc"))},[o]);return x.length>0?(0,s.jsxs)(l.default,{className:"overflow-hidden",children:[(0,s.jsxs)("div",{className:"p-4 border-b border-border flex items-center justify-between gap-3",children:[(0,s.jsx)("h3",{className:"text-sm font-semibold text-text-muted uppercase tracking-wider",children:"API Key Breakdown"}),(0,s.jsx)("input",{type:"text",value:t,onChange:e=>r(e.target.value),placeholder:"Filter API key...",className:"w-full max-w-[220px] px-3 py-1.5 rounded-lg bg-bg-subtle border border-border text-xs text-text-primary placeholder:text-text-muted focus:outline-none focus:border-primary"})]}),(0,s.jsx)("div",{className:"overflow-x-auto",children:(0,s.jsxs)("table",{className:"w-full text-sm",children:[(0,s.jsx)("thead",{className:"text-xs text-text-muted uppercase bg-black/[0.02] dark:bg-white/[0.02]",children:(0,s.jsxs)("tr",{children:[(0,s.jsxs)("th",{className:"px-4 py-2.5 text-left cursor-pointer group",onClick:()=>p("apiKeyName"),children:["API Key ",(0,s.jsx)(w,{active:"apiKeyName"===o,sortOrder:c})]}),(0,s.jsxs)("th",{className:"px-4 py-2.5 text-right cursor-pointer group",onClick:()=>p("requests"),children:["Requests ",(0,s.jsx)(w,{active:"requests"===o,sortOrder:c})]}),(0,s.jsxs)("th",{className:"px-4 py-2.5 text-right cursor-pointer group",onClick:()=>p("promptTokens"),children:["Input ",(0,s.jsx)(w,{active:"promptTokens"===o,sortOrder:c})]}),(0,s.jsxs)("th",{className:"px-4 py-2.5 text-right cursor-pointer group",onClick:()=>p("completionTokens"),children:["Output"," ",(0,s.jsx)(w,{active:"completionTokens"===o,sortOrder:c})]}),(0,s.jsxs)("th",{className:"px-4 py-2.5 text-right cursor-pointer group",onClick:()=>p("totalTokens"),children:["Total Tokens"," ",(0,s.jsx)(w,{active:"totalTokens"===o,sortOrder:c})]}),(0,s.jsxs)("th",{className:"px-4 py-2.5 text-right cursor-pointer group",onClick:()=>p("cost"),children:["Cost ",(0,s.jsx)(w,{active:"cost"===o,sortOrder:c})]})]})}),(0,s.jsxs)("tbody",{className:"divide-y divide-border",children:[u.map((e,t)=>(0,s.jsxs)("tr",{className:"hover:bg-black/[0.02] dark:hover:bg-white/[0.02] transition-colors",children:[(0,s.jsx)("td",{className:"px-4 py-2.5",children:(0,s.jsx)("span",{className:"font-medium",title:e.apiKeyName||e.apiKeyId||"unknown",children:(0,n.VO)(e.apiKeyName,e.apiKeyId)})}),(0,s.jsx)("td",{className:"px-4 py-2.5 text-right font-mono text-text-muted",children:(0,n.xW)(e.requests)}),(0,s.jsx)("td",{className:"px-4 py-2.5 text-right font-mono text-primary",children:(0,n.VK)(e.promptTokens)}),(0,s.jsx)("td",{className:"px-4 py-2.5 text-right font-mono text-emerald-500",children:(0,n.VK)(e.completionTokens)}),(0,s.jsx)("td",{className:"px-4 py-2.5 text-right font-mono font-semibold",children:(0,n.VK)(e.totalTokens)}),(0,s.jsx)("td",{className:"px-4 py-2.5 text-right font-mono text-amber-500",children:(0,n.F0)(e.cost)})]},`${e.apiKeyId||e.apiKeyName||"key"}-${t}`)),0===u.length&&(0,s.jsx)("tr",{children:(0,s.jsx)("td",{colSpan:6,className:"px-4 py-8 text-center text-text-muted",children:"No API key matches this filter."})})]})]})})]}):(0,s.jsxs)(l.default,{className:"p-4 flex-1",children:[(0,s.jsx)("h3",{className:"text-sm font-semibold text-text-muted uppercase tracking-wider mb-3",children:"API Key Breakdown"}),(0,s.jsx)("div",{className:"text-center text-text-muted text-sm py-8",children:"No data"})]})}function L({activityMap:e}){let t=(0,i.Ym)(),r=(0,a.useMemo)(()=>N(t,{weekday:"long"}),[t]),o=(0,a.useMemo)(()=>N(t,{month:"short",day:"numeric"}),[t]),c=(0,a.useMemo)(()=>{if(!e)return null;let t=new Date,s=null,a=0;for(let r=0;r<7;r++){let l=new Date(t);l.setDate(l.getDate()-r);let o=`${l.getFullYear()}-${String(l.getMonth()+1).padStart(2,"0")}-${String(l.getDate()).padStart(2,"0")}`,n=e[o]||0;n>a&&(a=n,s=o)}if(!s||0===a)return null;let l=new Date(s+"T12:00:00");return{weekday:r.format(l),label:o.format(l),tokens:a}},[e,o,r]);return(0,s.jsxs)(l.default,{className:"p-4 flex flex-col justify-center",style:{flex:1,minHeight:0},children:[(0,s.jsx)("h3",{className:"text-xs font-semibold uppercase tracking-wider mb-2",style:{color:"var(--text-muted)"},children:"Most Active Day"}),c?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("span",{className:"text-xl font-bold capitalize",style:{lineHeight:1.2},children:c.weekday}),(0,s.jsxs)("span",{className:"text-xs mt-1",style:{color:"var(--text-muted)"},children:[c.label," \xb7 ",(0,n.VK)(c.tokens)," tokens"]})]}):(0,s.jsx)("span",{className:"text-xs",style:{color:"var(--text-muted)"},children:"No data in the last 7 days"})]})}function E({activityMap:e}){let t=(0,i.Ym)(),r=(0,a.useMemo)(()=>N(t,{weekday:"short"}),[t]),o=(0,a.useMemo)(()=>N(t,{month:"short",day:"numeric"}),[t]),c=(0,a.useMemo)(()=>{if(!e)return[];let t=new Date,s=[],a=0;for(let l=6;l>=0;l--){let n=new Date(t);n.setDate(n.getDate()-l);let i=`${n.getFullYear()}-${String(n.getMonth()+1).padStart(2,"0")}-${String(n.getDate()).padStart(2,"0")}`,c=e[i]||0;c>a&&(a=c),s.push({key:i,val:c,label:r.format(n),dateLabel:o.format(n)})}return s.map(e=>({...e,intensity:a>0?e.val/a:0}))},[e,o,r]);return(0,s.jsxs)(l.default,{className:"p-4 flex flex-col justify-center",style:{flex:1,minHeight:0},children:[(0,s.jsx)("h3",{className:"text-xs font-semibold uppercase tracking-wider mb-3",style:{color:"var(--text-muted)"},children:"Weekly"}),(0,s.jsx)("div",{style:{display:"flex",alignItems:"flex-end",gap:6,justifyContent:"center"},children:c.map((e,t)=>{var r;return(0,s.jsxs)("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",gap:4},children:[(0,s.jsx)("div",{title:`${e.dateLabel}: ${(0,n.xW)(e.val)} tokens`,style:{width:36,height:36,borderRadius:8,...0===(r=e.intensity)?{background:"rgba(255,255,255,0.04)"}:{background:`rgba(229, 77, 94, ${(.15+.75*r).toFixed(2)})`},transition:"all 0.2s",cursor:"default"}}),(0,s.jsx)("span",{style:{fontSize:9,fontWeight:600,color:"var(--text-muted)",letterSpacing:"0.03em"},children:e.label})]},e.key)})})]})}function _({byModel:e,summary:t}){let[r,o]=(0,a.useState)("totalTokens"),[i,d]=(0,a.useState)("desc"),x=(0,a.useCallback)(e=>{r===e?d(e=>"asc"===e?"desc":"asc"):(o(e),d("desc"))},[r]),m=(0,a.useMemo)(()=>{let t=[...e||[]];return t.sort((e,t)=>{let s=e[r]??0,a=t[r]??0;return"string"==typeof s?"asc"===i?s.localeCompare(a):a.localeCompare(s):"asc"===i?s-a:a-s}),t},[e,r,i]);return(0,s.jsxs)(l.default,{className:"overflow-hidden",children:[(0,s.jsx)("div",{className:"p-4 border-b border-border",children:(0,s.jsx)("h3",{className:"text-sm font-semibold text-text-muted uppercase tracking-wider",children:"Model Breakdown"})}),(0,s.jsx)("div",{className:"overflow-x-auto",children:(0,s.jsxs)("table",{className:"w-full text-sm",children:[(0,s.jsx)("thead",{className:"text-xs text-text-muted uppercase bg-black/[0.02] dark:bg-white/[0.02]",children:(0,s.jsxs)("tr",{children:[(0,s.jsxs)("th",{className:"px-4 py-2.5 text-left cursor-pointer group",onClick:()=>x("model"),children:["Model ",(0,s.jsx)(w,{active:"model"===r,sortOrder:i})]}),(0,s.jsxs)("th",{className:"px-4 py-2.5 text-right cursor-pointer group",onClick:()=>x("requests"),children:["Requests ",(0,s.jsx)(w,{active:"requests"===r,sortOrder:i})]}),(0,s.jsxs)("th",{className:"px-4 py-2.5 text-right cursor-pointer group",onClick:()=>x("promptTokens"),children:["Input ",(0,s.jsx)(w,{active:"promptTokens"===r,sortOrder:i})]}),(0,s.jsxs)("th",{className:"px-4 py-2.5 text-right cursor-pointer group",onClick:()=>x("completionTokens"),children:["Output"," ",(0,s.jsx)(w,{active:"completionTokens"===r,sortOrder:i})]}),(0,s.jsxs)("th",{className:"px-4 py-2.5 text-right cursor-pointer group",onClick:()=>x("totalTokens"),children:["Total ",(0,s.jsx)(w,{active:"totalTokens"===r,sortOrder:i})]}),(0,s.jsxs)("th",{className:"px-4 py-2.5 text-right cursor-pointer group",onClick:()=>x("cost"),children:["Cost ",(0,s.jsx)(w,{active:"cost"===r,sortOrder:i})]}),(0,s.jsx)("th",{className:"px-4 py-2.5 text-right w-36",children:"Share"})]})}),(0,s.jsx)("tbody",{className:"divide-y divide-border",children:m.map((e,t)=>(0,s.jsxs)("tr",{className:"hover:bg-black/[0.02] dark:hover:bg-white/[0.02] transition-colors",children:[(0,s.jsx)("td",{className:"px-4 py-2.5",children:(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)("span",{className:"w-2 h-2 rounded-full shrink-0",style:{backgroundColor:(0,c.ng)(t)}}),(0,s.jsx)("span",{className:"font-medium",children:e.model})]})}),(0,s.jsx)("td",{className:"px-4 py-2.5 text-right font-mono text-text-muted",children:(0,n.xW)(e.requests)}),(0,s.jsx)("td",{className:"px-4 py-2.5 text-right font-mono text-primary",children:(0,n.VK)(e.promptTokens)}),(0,s.jsx)("td",{className:"px-4 py-2.5 text-right font-mono text-emerald-500",children:(0,n.VK)(e.completionTokens)}),(0,s.jsx)("td",{className:"px-4 py-2.5 text-right font-mono font-semibold",children:(0,n.VK)(e.totalTokens)}),(0,s.jsx)("td",{className:"px-4 py-2.5 text-right font-mono text-amber-500",children:(0,n.F0)(e.cost)}),(0,s.jsx)("td",{className:"px-4 py-2.5 text-right",children:(0,s.jsxs)("div",{className:"flex items-center gap-2 justify-end",children:[(0,s.jsx)("div",{className:"w-16 h-1.5 rounded-full bg-white/[0.06] overflow-hidden",children:(0,s.jsx)("div",{className:"h-full rounded-full transition-all",style:{width:`${e.pct}%`,backgroundColor:(0,c.ng)(t)}})}),(0,s.jsxs)("span",{className:"text-xs font-mono text-text-muted w-10 text-right",children:[e.pct,"%"]})]})})]},e.model))})]})})]})}let F=["#f59e0b","#ef4444","#8b5cf6","#10b981","#06b6d4","#ec4899","#f97316","#6366f1","#14b8a6","#a855f7"];function $({byProvider:e}){let t=(0,a.useMemo)(()=>e||[],[e]),r=t.length>0&&t.some(e=>e.cost>0),o=(0,a.useMemo)(()=>t.filter(e=>e.cost>0).sort((e,t)=>t.cost-e.cost).slice(0,8).map((e,t)=>({name:e.provider,value:e.cost,fill:F[t%F.length]})),[t]);return r?(0,s.jsxs)(l.default,{className:"p-4 flex-1",children:[(0,s.jsx)("h3",{className:"text-sm font-semibold text-text-muted uppercase tracking-wider mb-3",children:"Cost by Provider"}),(0,s.jsxs)("div",{className:"flex items-center gap-4",children:[(0,s.jsx)(d.u,{width:120,height:120,children:(0,s.jsxs)(f.r,{children:[(0,s.jsx)(g.Fq,{data:o,dataKey:"value",nameKey:"name",cx:"50%",cy:"50%",innerRadius:28,outerRadius:55,paddingAngle:1,animationDuration:600,children:o.map((e,t)=>(0,s.jsx)(y.f,{fill:e.fill,stroke:"none"},t))}),(0,s.jsx)(p.m,{content:(0,s.jsx)(k,{formatter:n.F0})})]})}),(0,s.jsx)("div",{className:"flex flex-col gap-1 min-w-0 flex-1",children:o.map((e,t)=>(0,s.jsxs)("div",{className:"flex items-center justify-between gap-2 text-xs",children:[(0,s.jsxs)("div",{className:"flex items-center gap-1.5 min-w-0",children:[(0,s.jsx)("span",{className:"w-2 h-2 rounded-full shrink-0",style:{backgroundColor:e.fill}}),(0,s.jsx)("span",{className:"truncate text-text-main capitalize",children:e.name})]}),(0,s.jsx)("span",{className:"font-mono font-medium text-amber-500 shrink-0",children:(0,n.F0)(e.value)})]},t))})]})]}):(0,s.jsxs)(l.default,{className:"p-4 flex-1",children:[(0,s.jsx)("h3",{className:"text-sm font-semibold text-text-muted uppercase tracking-wider mb-3",children:"Cost by Provider"}),(0,s.jsx)("div",{className:"text-center text-text-muted text-sm py-8",children:"No cost data"})]})}function D({dailyByModel:e,modelNames:t}){let r=(0,a.useMemo)(()=>e||[],[e]),o=(0,a.useMemo)(()=>t||[],[t]),i=(0,a.useMemo)(()=>r.map(e=>{let t={...e};if(e.date){let r=e.date.split("-");t.dateLabel=`${r[1]}/${r[2]}`}return t}),[r]);return r.length&&o.length?(0,s.jsxs)(l.default,{className:"p-4",children:[(0,s.jsx)("h3",{className:"text-sm font-semibold text-text-muted uppercase tracking-wider mb-3",children:"Model Usage Over Time"}),(0,s.jsx)(d.u,{width:"100%",height:240,children:(0,s.jsxs)(j.Q,{data:i,margin:{top:4,right:4,left:0,bottom:0},children:[(0,s.jsx)(m.W,{dataKey:"dateLabel",tick:{fontSize:10,fill:"var(--text-muted)"},axisLine:!1,tickLine:!1,interval:"preserveStartEnd"}),(0,s.jsx)(u.h,{tick:{fontSize:10,fill:"var(--text-muted)"},tickFormatter:e=>(0,n.VK)(e),axisLine:!1,tickLine:!1,width:50}),(0,s.jsx)(p.m,{content:(0,s.jsx)(k,{formatter:n.VK})}),o.map((e,t)=>(0,s.jsx)(v.Gk,{type:"monotone",dataKey:e,stackId:"1",stroke:(0,c.ng)(t),fill:(0,c.ng)(t),fillOpacity:.4,strokeWidth:1.5,animationDuration:600},e))]})}),(0,s.jsx)("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1 mt-2 text-[10px] text-text-muted",children:o.map((e,t)=>(0,s.jsxs)("span",{className:"flex items-center gap-1",children:[(0,s.jsx)("span",{className:"w-2 h-2 rounded-full shrink-0",style:{backgroundColor:(0,c.ng)(t)}}),e]},e))})]}):(0,s.jsxs)(l.default,{className:"p-4",children:[(0,s.jsx)("h3",{className:"text-sm font-semibold text-text-muted uppercase tracking-wider mb-3",children:"Model Usage Over Time"}),(0,s.jsx)("div",{className:"text-center text-text-muted text-sm py-8",children:"No data"})]})}function P({byProvider:e}){let[t,r]=(0,a.useState)("totalTokens"),[o,i]=(0,a.useState)("desc"),c=(0,a.useMemo)(()=>e||[],[e]),d=(0,a.useMemo)(()=>c.reduce((e,t)=>e+t.totalTokens,0),[c]),x=(0,a.useCallback)(e=>{t===e?i(e=>"asc"===e?"desc":"asc"):(r(e),i("desc"))},[t]),m=(0,a.useMemo)(()=>{let e=[...c];return e.sort((e,r)=>{let s=e[t]??0,a=r[t]??0;return"string"==typeof s?"asc"===o?s.localeCompare(a):a.localeCompare(s):"asc"===o?s-a:a-s}),e},[c,t,o]);return c.length?(0,s.jsxs)(l.default,{className:"overflow-hidden",children:[(0,s.jsx)("div",{className:"p-4 border-b border-border",children:(0,s.jsx)("h3",{className:"text-sm font-semibold text-text-muted uppercase tracking-wider",children:"Provider Breakdown"})}),(0,s.jsx)("div",{className:"overflow-x-auto",children:(0,s.jsxs)("table",{className:"w-full text-sm",children:[(0,s.jsx)("thead",{className:"text-xs text-text-muted uppercase bg-black/[0.02] dark:bg-white/[0.02]",children:(0,s.jsxs)("tr",{children:[(0,s.jsxs)("th",{className:"px-4 py-2.5 text-left cursor-pointer group",onClick:()=>x("provider"),children:["Provider ",(0,s.jsx)(w,{active:"provider"===t,sortOrder:o})]}),(0,s.jsxs)("th",{className:"px-4 py-2.5 text-right cursor-pointer group",onClick:()=>x("requests"),children:["Requests ",(0,s.jsx)(w,{active:"requests"===t,sortOrder:o})]}),(0,s.jsxs)("th",{className:"px-4 py-2.5 text-right cursor-pointer group",onClick:()=>x("promptTokens"),children:["Input ",(0,s.jsx)(w,{active:"promptTokens"===t,sortOrder:o})]}),(0,s.jsxs)("th",{className:"px-4 py-2.5 text-right cursor-pointer group",onClick:()=>x("completionTokens"),children:["Output"," ",(0,s.jsx)(w,{active:"completionTokens"===t,sortOrder:o})]}),(0,s.jsxs)("th",{className:"px-4 py-2.5 text-right cursor-pointer group",onClick:()=>x("totalTokens"),children:["Total ",(0,s.jsx)(w,{active:"totalTokens"===t,sortOrder:o})]}),(0,s.jsxs)("th",{className:"px-4 py-2.5 text-right cursor-pointer group",onClick:()=>x("cost"),children:["Cost ",(0,s.jsx)(w,{active:"cost"===t,sortOrder:o})]}),(0,s.jsx)("th",{className:"px-4 py-2.5 text-right w-36",children:"Share"})]})}),(0,s.jsx)("tbody",{className:"divide-y divide-border",children:m.map((e,t)=>{let r=d>0?(e.totalTokens/d*100).toFixed(1):"0";return(0,s.jsxs)("tr",{className:"hover:bg-black/[0.02] dark:hover:bg-white/[0.02] transition-colors",children:[(0,s.jsx)("td",{className:"px-4 py-2.5",children:(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)("span",{className:"w-2 h-2 rounded-full shrink-0",style:{backgroundColor:F[t%F.length]}}),(0,s.jsx)("span",{className:"font-medium capitalize",children:e.provider})]})}),(0,s.jsx)("td",{className:"px-4 py-2.5 text-right font-mono text-text-muted",children:(0,n.xW)(e.requests)}),(0,s.jsx)("td",{className:"px-4 py-2.5 text-right font-mono text-primary",children:(0,n.VK)(e.promptTokens)}),(0,s.jsx)("td",{className:"px-4 py-2.5 text-right font-mono text-emerald-500",children:(0,n.VK)(e.completionTokens)}),(0,s.jsx)("td",{className:"px-4 py-2.5 text-right font-mono font-semibold",children:(0,n.VK)(e.totalTokens)}),(0,s.jsx)("td",{className:"px-4 py-2.5 text-right font-mono text-amber-500",children:(0,n.F0)(e.cost)}),(0,s.jsx)("td",{className:"px-4 py-2.5 text-right",children:(0,s.jsxs)("div",{className:"flex items-center gap-2 justify-end",children:[(0,s.jsx)("div",{className:"w-16 h-1.5 rounded-full bg-white/[0.06] overflow-hidden",children:(0,s.jsx)("div",{className:"h-full rounded-full transition-all",style:{width:`${r}%`,backgroundColor:F[t%F.length]}})}),(0,s.jsxs)("span",{className:"text-xs font-mono text-text-muted w-10 text-right",children:[r,"%"]})]})})]},e.provider)})})]})})]}):(0,s.jsxs)(l.default,{className:"p-4",children:[(0,s.jsx)("h3",{className:"text-sm font-semibold text-text-muted uppercase tracking-wider mb-3",children:"Provider Breakdown"}),(0,s.jsx)("div",{className:"text-center text-text-muted text-sm py-8",children:"No data"})]})}function K(){let[e,t]=(0,a.useState)("30d"),[r,i]=(0,a.useState)(null),[c,d]=(0,a.useState)(!0),[x,m]=(0,a.useState)(null),u=(0,a.useCallback)(async()=>{try{d(!0);let t=await fetch(`/api/usage/analytics?range=${e}`);if(!t.ok)throw Error("Failed to fetch");let r=await t.json();i(r),m(null)}catch(e){m(e.message)}finally{d(!1)}},[e]);(0,a.useEffect)(()=>{u()},[u]);let p=(0,a.useMemo)(()=>{let e=r?.byModel||[];return e.length>0?e[0].model:"—"},[r]),h=(0,a.useMemo)(()=>{let e=r?.byProvider||[];return e.length>0?e[0].provider:"—"},[r]),b=(0,a.useMemo)(()=>{let e=r?.weeklyPattern||[];if(!e.length)return"—";let t=e.reduce((e,t)=>e.avgTokens>t.avgTokens?e:t,e[0]);return t.avgTokens>0?t.day:"—"},[r]),f=(0,a.useMemo)(()=>(r?.byProvider||[]).length,[r]),g=(0,a.useMemo)(()=>{let e=r?.byProvider||[];if(e.length<=1)return 0;let t=0;for(let r of e)t+=r.totalRequests||r.apiCalls||0;if(0===t)return 0;let s=0;for(let r of e){let e=(r.totalRequests||r.apiCalls||0)/t;e>0&&(s-=e*Math.log2(e))}let a=Math.log2(e.length);return a>0?s/a*100:0},[r]);if(c&&!r)return(0,s.jsx)(o.CardSkeleton,{});if(x)return(0,s.jsxs)(l.default,{className:"p-6 text-center text-red-500",children:["Error: ",x]});let y=r?.summary||{},j=y.totalRequests>0?Math.round(y.totalTokens/y.totalRequests):0,v=y.totalRequests>0?y.totalCost/y.totalRequests:0,N=y.completionTokens>0?(y.promptTokens/y.completionTokens).toFixed(1):"—";return(0,s.jsxs)("div",{className:"flex flex-col gap-5 min-w-0",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between",children:[(0,s.jsxs)("h2",{className:"text-xl font-semibold flex items-center gap-2",children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-primary text-[22px]",children:"analytics"}),"Usage Analytics"]}),(0,s.jsx)("div",{className:"flex items-center gap-1 bg-black/[0.03] dark:bg-white/[0.03] rounded-lg p-1 border border-black/5 dark:border-white/5",children:[{value:"1d",label:"1D"},{value:"7d",label:"7D"},{value:"30d",label:"30D"},{value:"90d",label:"90D"},{value:"ytd",label:"YTD"},{value:"all",label:"All"}].map(r=>(0,s.jsx)("button",{onClick:()=>t(r.value),className:`px-3 py-1 rounded-md text-xs font-semibold transition-all ${e===r.value?"bg-primary text-white shadow-sm":"text-text-muted hover:text-text-main hover:bg-black/5 dark:hover:bg-white/5"}`,children:r.label},r.value))})]}),(0,s.jsxs)("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-3",children:[(0,s.jsx)(C,{icon:"generating_tokens",label:"Total Tokens",value:(0,n.VK)(y.totalTokens),subValue:`${(0,n.xW)(y.totalRequests)} requests`}),(0,s.jsx)(C,{icon:"input",label:"Input Tokens",value:(0,n.VK)(y.promptTokens),color:"text-primary"}),(0,s.jsx)(C,{icon:"output",label:"Output Tokens",value:(0,n.VK)(y.completionTokens),color:"text-emerald-500"}),(0,s.jsx)(C,{icon:"payments",label:"Est. Cost",value:(0,n.F0)(y.totalCost),color:"text-amber-500"})]}),(0,s.jsx)(S,{sections:[{title:"Infrastructure",items:[{icon:"group",label:"Accounts",value:y.uniqueAccounts||0},{icon:"dns",label:"Providers",value:f,color:"text-indigo-500"},{icon:"vpn_key",label:"API Keys",value:y.uniqueApiKeys||0},{icon:"model_training",label:"Models",value:y.uniqueModels||0}]},{title:"Performance",items:[{icon:"speed",label:"Avg Tokens/Req",value:(0,n.VK)(j),color:"text-cyan-500"},{icon:"request_quote",label:"Cost/Req",value:(0,n.F0)(v),color:"text-orange-500"},{icon:"compare_arrows",label:"I/O Ratio",value:`${N}x`,color:"text-violet-500"},{icon:"swap_horiz",label:"Fallback Rate",value:`${Number(y.fallbackRatePct||0).toFixed(1)}%`,color:"text-amber-500"}]},{title:"Highlights",wideValues:!0,items:[{icon:"star",label:"Top Model",value:p,color:"text-pink-500"},{icon:"cloud",label:"Top Provider",value:h,color:"text-teal-500"},{icon:"today",label:"Busiest Day",value:b,color:"text-rose-500"},{icon:"network_node",label:"Diversity",value:`${g.toFixed(1)}%`,color:"text-sky-500"}]}]}),(0,s.jsxs)("div",{className:"grid grid-cols-1 lg:grid-cols-[2fr_1fr] gap-4 items-stretch",children:[(0,s.jsx)(A,{activityMap:r?.activityMap}),(0,s.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,s.jsx)(L,{activityMap:r?.activityMap}),(0,s.jsx)(E,{activityMap:r?.activityMap})]})]}),(0,s.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[(0,s.jsx)(T,{dailyTrend:r?.dailyTrend}),(0,s.jsx)($,{byProvider:r?.byProvider})]}),(0,s.jsx)(D,{dailyByModel:r?.dailyByModel,modelNames:r?.modelNames}),(0,s.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[(0,s.jsx)(M,{byAccount:r?.byAccount}),(0,s.jsx)(O,{byApiKey:r?.byApiKey})]}),(0,s.jsx)(P,{byProvider:r?.byProvider}),(0,s.jsx)(R,{byApiKey:r?.byApiKey}),(0,s.jsx)(_,{byModel:r?.byModel,summary:y})]})}},49007:(e,t,r)=>{r.d(t,{v:()=>s,B:()=>a});let s={name:"OmniRoute",description:"AI Gateway for Multi-Provider LLMs",version:"3.7.2"},a={storageKey:"theme",defaultTheme:"system"}},51503:(e,t,r)=>{r.d(t,{default:()=>l});var s=r(95155),a=r(12115);function l({searchValue:e="",onSearchChange:t,placeholder:r="Search...",filters:o=[],activeFilters:n={},onFilterChange:i,children:c}){let[d,x]=(0,a.useState)(null),m=(0,a.useCallback)(()=>{t(""),o.forEach(e=>i(e.key,"")),x(null)},[t,o,i]),u=e||Object.values(n).some(e=>e&&""!==e);return(0,s.jsxs)("div",{style:{display:"flex",flexWrap:"wrap",gap:"8px",alignItems:"center",padding:"8px 0"},children:[(0,s.jsxs)("div",{style:{position:"relative",flex:"1 1 200px",minWidth:"200px"},children:[(0,s.jsx)("input",{type:"text",value:e,onChange:e=>t(e.target.value),placeholder:r,style:{width:"100%",padding:"8px 12px 8px 32px",borderRadius:"6px",border:"1px solid rgba(255,255,255,0.1)",background:"rgba(255,255,255,0.05)",color:"var(--text-primary, #e0e0e0)",fontSize:"13px",outline:"none"}}),(0,s.jsx)("span",{style:{position:"absolute",left:"10px",top:"50%",transform:"translateY(-50%)",opacity:.4,fontSize:"14px",pointerEvents:"none"},children:"\uD83D\uDD0D"})]}),o.map(e=>(0,s.jsxs)("div",{style:{position:"relative"},children:[(0,s.jsxs)("button",{onClick:()=>x(d===e.key?null:e.key),style:{padding:"6px 12px",borderRadius:"6px",border:`1px solid ${n[e.key]?"rgba(99,102,241,0.5)":"rgba(255,255,255,0.1)"}`,background:n[e.key]?"rgba(99,102,241,0.15)":"rgba(255,255,255,0.05)",color:n[e.key]?"#818cf8":"var(--text-secondary, #888)",fontSize:"12px",cursor:"pointer",whiteSpace:"nowrap"},children:[e.label,n[e.key]?` \xb7 ${n[e.key]}`:""]}),d===e.key&&(0,s.jsxs)("div",{style:{position:"absolute",top:"100%",left:0,marginTop:"4px",background:"rgba(20,20,30,0.95)",border:"1px solid rgba(255,255,255,0.1)",borderRadius:"8px",padding:"4px",zIndex:50,minWidth:"120px",backdropFilter:"blur(12px)"},children:[(0,s.jsx)("button",{onClick:()=>{i(e.key,""),x(null)},style:{display:"block",width:"100%",padding:"6px 12px",textAlign:"left",background:"none",border:"none",color:"#888",fontSize:"12px",cursor:"pointer",borderRadius:"4px"},children:"All"}),(e.options||[]).map(t=>(0,s.jsx)("button",{onClick:()=>{i(e.key,t),x(null)},style:{display:"block",width:"100%",padding:"6px 12px",textAlign:"left",background:n[e.key]===t?"rgba(99,102,241,0.2)":"none",border:"none",color:n[e.key]===t?"#818cf8":"var(--text-primary, #e0e0e0)",fontSize:"12px",cursor:"pointer",borderRadius:"4px"},children:t},t))]})]},e.key)),u&&(0,s.jsx)("button",{onClick:m,style:{padding:"6px 12px",borderRadius:"6px",border:"1px solid rgba(239,68,68,0.3)",background:"rgba(239,68,68,0.1)",color:"#ef4444",fontSize:"12px",cursor:"pointer"},children:"Clear"}),c]})}},54128:(e,t,r)=>{r.d(t,{default:()=>l});var s=r(95155),a=r(12115);function l({columns:e=[],visible:t={},onToggle:r}){let[o,n]=(0,a.useState)(!1),i=(0,a.useRef)(null);return(0,a.useEffect)(()=>{if(!o)return;let e=e=>{i.current&&!i.current.contains(e.target)&&n(!1)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[o]),(0,s.jsxs)("div",{ref:i,style:{position:"relative"},children:[(0,s.jsxs)("button",{onClick:()=>n(!o),title:"Toggle columns",style:{padding:"6px 10px",borderRadius:"6px",border:"1px solid rgba(255,255,255,0.1)",background:"rgba(255,255,255,0.05)",color:"var(--text-secondary, #888)",fontSize:"13px",cursor:"pointer",display:"flex",alignItems:"center",gap:"4px"},children:[(0,s.jsx)("span",{style:{fontSize:"14px"},children:"⚙️"}),"Columns"]}),o&&(0,s.jsx)("div",{style:{position:"absolute",top:"100%",right:0,marginTop:"4px",background:"rgba(20,20,30,0.95)",border:"1px solid rgba(255,255,255,0.1)",borderRadius:"8px",padding:"8px",zIndex:50,minWidth:"160px",backdropFilter:"blur(12px)"},children:e.map(e=>(0,s.jsxs)("label",{style:{display:"flex",alignItems:"center",gap:"8px",padding:"4px 8px",cursor:"pointer",fontSize:"12px",color:t[e.key]?"var(--text-primary, #e0e0e0)":"var(--text-secondary, #888)",borderRadius:"4px"},children:[(0,s.jsx)("input",{type:"checkbox",checked:t[e.key]??!0,onChange:()=>r(e.key),style:{accentColor:"#6366f1"}}),e.label]},e.key))})]})}},55846:(e,t,r)=>{r.d(t,{ThemeProvider:()=>o});var s=r(95155),a=r(12115),l=r(76851);function o({children:e}){let{initTheme:t}=(0,l.A)();return(0,a.useEffect)(()=>{t()},[t]),(0,s.jsx)(s.Fragment,{children:e})}},61580:(e,t,r)=>{r.d(t,{default:()=>c});var s=r(95155),a=r(67671),l=r(12115);let o={success:"✓",error:"✕",warning:"⚠",info:"ℹ"},n={success:{bg:"rgba(16, 185, 129, 0.15)",border:"rgba(16, 185, 129, 0.4)",icon:"#10b981"},error:{bg:"rgba(239, 68, 68, 0.15)",border:"rgba(239, 68, 68, 0.4)",icon:"#ef4444"},warning:{bg:"rgba(245, 158, 11, 0.15)",border:"rgba(245, 158, 11, 0.4)",icon:"#f59e0b"},info:{bg:"rgba(59, 130, 246, 0.15)",border:"rgba(59, 130, 246, 0.4)",icon:"#3b82f6"}};function i({notification:e,onDismiss:t}){let[r,a]=(0,l.useState)(!1),c=n[e.type]||n.info;return(0,s.jsxs)("div",{role:"alert","aria-live":"polite",style:{display:"flex",alignItems:"flex-start",gap:"12px",padding:"14px 16px",borderRadius:"10px",backgroundColor:c.bg,border:`1px solid ${c.border}`,backdropFilter:"blur(12px)",boxShadow:"0 8px 32px rgba(0,0,0,0.2)",minWidth:"320px",maxWidth:"420px",animation:r?"toastOut 0.2s ease-in forwards":"toastIn 0.3s ease-out forwards",transition:"all 0.2s ease"},children:[(0,s.jsx)("span",{style:{fontSize:"18px",color:c.icon,fontWeight:"bold",lineHeight:1,marginTop:"2px"},children:o[e.type]}),(0,s.jsxs)("div",{style:{flex:1,minWidth:0},children:[e.title&&(0,s.jsx)("div",{style:{fontWeight:600,fontSize:"14px",color:"var(--text-primary, #fff)",marginBottom:"2px"},children:e.title}),(0,s.jsx)("div",{style:{fontSize:"13px",color:"var(--text-secondary, #ccc)",lineHeight:1.4},children:e.message})]}),e.dismissible&&(0,s.jsx)("button",{onClick:()=>{a(!0),setTimeout(()=>t(e.id),200)},"aria-label":"Dismiss notification",style:{background:"none",border:"none",cursor:"pointer",color:"var(--text-secondary, #999)",fontSize:"16px",padding:"0 2px",lineHeight:1,opacity:.6,transition:"opacity 0.15s"},onMouseEnter:e=>e.currentTarget.style.opacity="1",onMouseLeave:e=>e.currentTarget.style.opacity="0.6",children:"\xd7"})]})}function c(){let{notifications:e,removeNotification:t}=(0,a.i)();return 0===e.length?null:(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("style",{children:`
1
+ "use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[1999],{1652:(e,t,r)=>{r.d(t,{default:()=>d});var s=r(95155),a=r(12115),l=r(14051),o=r.n(l),n=r(71361),i=r(35806),c=r(34422);function d({isOpen:e,providerId:t="kiro",providerLabel:r="Kiro",onMethodSelect:l,onClose:o}){let[x,m]=(0,a.useState)(null),[u,p]=(0,a.useState)(""),[h,b]=(0,a.useState)("us-east-1"),[f,g]=(0,a.useState)(""),[y,j]=(0,a.useState)(null),[v,N]=(0,a.useState)(!1),[k,w]=(0,a.useState)(!1),[C,S]=(0,a.useState)(!1);(0,a.useEffect)(()=>{"import"===x&&e&&(async()=>{w(!0),j(null),S(!1);try{let e=await fetch(`/api/oauth/kiro/auto-import?targetProvider=${encodeURIComponent(t)}`),r=await e.json();r.found?(g(r.refreshToken),S(!0)):j(r.error||"Could not auto-detect token")}catch(e){j("Failed to auto-detect token")}finally{w(!1)}})()},[t,x,e]);let A=e=>{m(e),j(null)},T=()=>{m(null),j(null)},I=async()=>{if(!f.trim())return void j("Please enter a refresh token");N(!0),j(null);try{let e=await fetch(`/api/oauth/kiro/import?targetProvider=${encodeURIComponent(t)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({refreshToken:f.trim()})}),r=await e.json();if(!e.ok)throw Error(r.error||"Import failed");o()}catch(e){j(e.message)}finally{N(!1)}},M=e=>{l("social",{provider:e})};return(0,s.jsx)(n.default,{isOpen:e,title:`Connect ${r}`,onClose:o,size:"lg",children:(0,s.jsxs)("div",{className:"flex flex-col gap-4",children:[!x&&(0,s.jsxs)("div",{className:"space-y-3",children:[(0,s.jsx)("p",{className:"text-sm text-text-muted mb-4",children:"Choose your authentication method:"}),(0,s.jsx)("button",{onClick:()=>l("builder-id"),className:"w-full p-4 text-left border border-border rounded-lg hover:bg-sidebar transition-colors",children:(0,s.jsxs)("div",{className:"flex items-start gap-3",children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-primary mt-0.5",children:"shield"}),(0,s.jsxs)("div",{className:"flex-1",children:[(0,s.jsx)("h3",{className:"font-semibold mb-1",children:"AWS Builder ID"}),(0,s.jsxs)("p",{className:"text-sm text-text-muted",children:["Recommended for most users. Sign in with the AWS account linked to"," ",r,"."]})]})]})}),(0,s.jsx)("button",{onClick:()=>A("idc"),className:"hidden w-full p-4 text-left border border-border rounded-lg hover:bg-sidebar transition-colors",children:(0,s.jsxs)("div",{className:"flex items-start gap-3",children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-primary mt-0.5",children:"business"}),(0,s.jsxs)("div",{className:"flex-1",children:[(0,s.jsx)("h3",{className:"font-semibold mb-1",children:"AWS IAM Identity Center"}),(0,s.jsx)("p",{className:"text-sm text-text-muted",children:"For enterprise users with custom AWS IAM Identity Center."})]})]})}),(0,s.jsx)("button",{onClick:()=>A("social-google"),className:"hidden w-full p-4 text-left border border-border rounded-lg hover:bg-sidebar transition-colors",children:(0,s.jsxs)("div",{className:"flex items-start gap-3",children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-primary mt-0.5",children:"account_circle"}),(0,s.jsxs)("div",{className:"flex-1",children:[(0,s.jsx)("h3",{className:"font-semibold mb-1",children:"Google Account"}),(0,s.jsx)("p",{className:"text-sm text-text-muted",children:"Login with your Google account (manual callback)."})]})]})}),(0,s.jsx)("button",{onClick:()=>A("social-github"),className:"hidden w-full p-4 text-left border border-border rounded-lg hover:bg-sidebar transition-colors",children:(0,s.jsxs)("div",{className:"flex items-start gap-3",children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-primary mt-0.5",children:"code"}),(0,s.jsxs)("div",{className:"flex-1",children:[(0,s.jsx)("h3",{className:"font-semibold mb-1",children:"GitHub Account"}),(0,s.jsx)("p",{className:"text-sm text-text-muted",children:"Login with your GitHub account (manual callback)."})]})]})}),(0,s.jsx)("button",{onClick:()=>A("import"),className:"w-full p-4 text-left border border-border rounded-lg hover:bg-sidebar transition-colors",children:(0,s.jsxs)("div",{className:"flex items-start gap-3",children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-primary mt-0.5",children:"file_upload"}),(0,s.jsxs)("div",{className:"flex-1",children:[(0,s.jsx)("h3",{className:"font-semibold mb-1",children:"Import Token"}),(0,s.jsxs)("p",{className:"text-sm text-text-muted",children:["Paste a refresh token exported from ",r,"."]})]})]})})]}),"idc"===x&&(0,s.jsxs)("div",{className:"space-y-4",children:[(0,s.jsxs)("div",{children:[(0,s.jsxs)("label",{className:"block text-sm font-medium mb-2",children:["IDC Start URL ",(0,s.jsx)("span",{className:"text-red-500",children:"*"})]}),(0,s.jsx)(c.default,{value:u,onChange:e=>p(e.target.value),placeholder:"https://your-org.awsapps.com/start",className:"font-mono text-sm"}),(0,s.jsx)("p",{className:"text-xs text-text-muted mt-1",children:"Your organization's AWS IAM Identity Center URL"})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{className:"block text-sm font-medium mb-2",children:"AWS Region"}),(0,s.jsx)(c.default,{value:h,onChange:e=>b(e.target.value),placeholder:"us-east-1",className:"font-mono text-sm"}),(0,s.jsx)("p",{className:"text-xs text-text-muted mt-1",children:"AWS region for your Identity Center (default: us-east-1)"})]}),y&&(0,s.jsx)("p",{className:"text-sm text-red-600",children:y}),(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsx)(i.default,{onClick:()=>{u.trim()?l("idc",{startUrl:u.trim(),region:h}):j("Please enter your IDC start URL")},fullWidth:!0,children:"Continue"}),(0,s.jsx)(i.default,{onClick:T,variant:"ghost",fullWidth:!0,children:"Back"})]})]}),"social-google"===x&&(0,s.jsxs)("div",{className:"space-y-4",children:[(0,s.jsx)("div",{className:"bg-amber-50 dark:bg-amber-900/20 p-4 rounded-lg border border-amber-200 dark:border-amber-800",children:(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-amber-600 dark:text-amber-400",children:"info"}),(0,s.jsxs)("div",{className:"flex-1 text-sm",children:[(0,s.jsx)("p",{className:"font-medium text-amber-900 dark:text-amber-100 mb-1",children:"Manual Callback Required"}),(0,s.jsx)("p",{className:"text-amber-800 dark:text-amber-200",children:"After login, you'll need to copy the callback URL from your browser and paste it back here."})]})]})}),(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsx)(i.default,{onClick:()=>M("google"),fullWidth:!0,children:"Continue with Google"}),(0,s.jsx)(i.default,{onClick:T,variant:"ghost",fullWidth:!0,children:"Back"})]})]}),"social-github"===x&&(0,s.jsxs)("div",{className:"space-y-4",children:[(0,s.jsx)("div",{className:"bg-amber-50 dark:bg-amber-900/20 p-4 rounded-lg border border-amber-200 dark:border-amber-800",children:(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-amber-600 dark:text-amber-400",children:"info"}),(0,s.jsxs)("div",{className:"flex-1 text-sm",children:[(0,s.jsx)("p",{className:"font-medium text-amber-900 dark:text-amber-100 mb-1",children:"Manual Callback Required"}),(0,s.jsx)("p",{className:"text-amber-800 dark:text-amber-200",children:"After login, you'll need to copy the callback URL from your browser and paste it back here."})]})]})}),(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsx)(i.default,{onClick:()=>M("github"),fullWidth:!0,children:"Continue with GitHub"}),(0,s.jsx)(i.default,{onClick:T,variant:"ghost",fullWidth:!0,children:"Back"})]})]}),"import"===x&&(0,s.jsxs)("div",{className:"space-y-4",children:[k&&(0,s.jsxs)("div",{className:"text-center py-6",children:[(0,s.jsx)("div",{className:"size-16 mx-auto mb-4 rounded-full bg-primary/10 flex items-center justify-center",children:(0,s.jsx)("span",{className:"material-symbols-outlined text-3xl text-primary animate-spin",children:"progress_activity"})}),(0,s.jsx)("h3",{className:"text-lg font-semibold mb-2",children:"Auto-detecting token..."}),(0,s.jsxs)("p",{className:"text-sm text-text-muted",children:["Reading ",r," credentials from AWS SSO cache"]})]}),!k&&(0,s.jsxs)(s.Fragment,{children:[C&&(0,s.jsx)("div",{className:"bg-green-50 dark:bg-green-900/20 p-3 rounded-lg border border-green-200 dark:border-green-800",children:(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-green-600 dark:text-green-400",children:"check_circle"}),(0,s.jsxs)("p",{className:"text-sm text-green-800 dark:text-green-200",children:["Token auto-detected from ",r," successfully!"]})]})}),!C&&!y&&(0,s.jsx)("div",{className:"bg-blue-50 dark:bg-blue-900/20 p-3 rounded-lg border border-blue-200 dark:border-blue-800",children:(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-blue-600 dark:text-blue-400",children:"info"}),(0,s.jsxs)("p",{className:"text-sm text-blue-800 dark:text-blue-200",children:[r," token was not auto-detected. Please paste your refresh token manually."]})]})}),(0,s.jsxs)("div",{children:[(0,s.jsxs)("label",{className:"block text-sm font-medium mb-2",children:["Refresh Token ",(0,s.jsx)("span",{className:"text-red-500",children:"*"})]}),(0,s.jsx)(c.default,{value:f,onChange:e=>g(e.target.value),placeholder:"Token will be auto-filled...",className:"font-mono text-sm"})]}),y&&(0,s.jsx)("div",{className:"bg-red-50 dark:bg-red-900/20 p-3 rounded-lg border border-red-200 dark:border-red-800",children:(0,s.jsx)("p",{className:"text-sm text-red-600 dark:text-red-400",children:y})}),(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsx)(i.default,{onClick:I,fullWidth:!0,disabled:v||!f.trim(),children:v?"Importing...":"Import Token"}),(0,s.jsx)(i.default,{onClick:T,variant:"ghost",fullWidth:!0,children:"Back"})]})]})]})]})})}d.propTypes={isOpen:o().bool.isRequired,providerId:o().string,providerLabel:o().string,onMethodSelect:o().func.isRequired,onClose:o().func.isRequired}},6261:(e,t,r)=>{r.d(t,{default:()=>o});var s=r(95155),a=r(97550),l=r(67040);function o({className:e,variant:t="default"}){let{theme:r,toggleTheme:n,isDark:i}=(0,a.D)(),c={default:(0,l.cn)("flex items-center justify-center size-10 rounded-full","text-text-muted","hover:bg-black/5","hover:text-text-main","transition-colors"),card:(0,l.cn)("flex items-center justify-center size-11 rounded-full","bg-surface/60","hover:bg-surface","border border-border","backdrop-blur-md shadow-sm hover:shadow-md","text-text-muted-light hover:text-primary","hover:text-primary","transition-all group")};return(0,s.jsx)("button",{onClick:n,className:(0,l.cn)(c[t],e),"aria-label":`Switch to ${i?"light":"dark"} mode`,title:`Switch to ${i?"light":"dark"} mode`,children:(0,s.jsx)("span",{className:(0,l.cn)("material-symbols-outlined text-[22px]","card"===t&&"transition-transform duration-300 group-hover:rotate-12"),children:i?"light_mode":"dark_mode"})})}},8287:(e,t,r)=>{r.d(t,{default:()=>m});var s=r(95155),a=r(12115),l=r(81060),o=r(99333),n=r(8898);function i({log:e,onClose:t}){(0,a.useEffect)(()=>{let e=e=>{"Escape"===e.key&&t()};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[t]);let r=(0,o.Yh)(e.status),l=o.Gp[e.proxy?.type]||{bg:"#6B7280",text:"#fff",label:e.proxy?.type||"-"},c=o.Ie[e.level]||o.Ie.direct,d=o.RY[e.provider]||{bg:"#374151",text:"#fff",label:(e.provider||"-").toUpperCase()};return(0,s.jsxs)("div",{className:"fixed inset-0 z-50 flex items-start justify-center pt-[5vh]",onClick:t,role:"dialog","aria-modal":"true","aria-label":"Proxy log detail",children:[(0,s.jsx)("div",{className:"absolute inset-0 bg-black/60 backdrop-blur-sm"}),(0,s.jsxs)("div",{className:"relative bg-bg-primary border border-border rounded-xl w-full max-w-[700px] max-h-[90vh] overflow-y-auto shadow-2xl",onClick:e=>e.stopPropagation(),children:[(0,s.jsxs)("div",{className:"sticky top-0 z-10 flex items-center justify-between px-6 py-4 border-b border-border bg-bg-primary/95 backdrop-blur-sm rounded-t-xl",children:[(0,s.jsxs)("div",{className:"flex items-center gap-3",children:[(0,s.jsx)("span",{className:"inline-block px-2.5 py-1 rounded text-xs font-bold uppercase",style:{backgroundColor:r.bg,color:r.text},children:e.status}),(0,s.jsx)("span",{className:"font-bold text-lg",children:"Proxy Event"})]}),(0,s.jsx)("button",{onClick:t,className:"p-1.5 rounded-lg hover:bg-bg-subtle text-text-muted hover:text-text-primary transition-colors","aria-label":"Close proxy detail modal",children:(0,s.jsx)("span",{className:"material-symbols-outlined",children:"close"})})]}),(0,s.jsxs)("div",{className:"p-6 flex flex-col gap-6",children:[(0,s.jsxs)("div",{className:"grid grid-cols-2 md:grid-cols-3 gap-4 p-4 bg-bg-subtle rounded-xl border border-border",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("div",{className:"text-[10px] text-text-muted uppercase tracking-wider mb-1",children:"Time"}),(0,s.jsx)("div",{className:"text-sm font-medium",children:(e=>{try{let t=new Date(e);return t.toLocaleDateString("pt-BR")+", "+t.toLocaleTimeString("en-US",{hour12:!1})}catch{return e}})(e.timestamp)})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("div",{className:"text-[10px] text-text-muted uppercase tracking-wider mb-1",children:"Latency"}),(0,s.jsx)("div",{className:"text-sm font-medium",children:(0,n.a3)(e.latencyMs)})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("div",{className:"text-[10px] text-text-muted uppercase tracking-wider mb-1",children:"Public IP"}),(0,s.jsx)("div",{className:"text-sm font-medium font-mono text-emerald-400",children:e.publicIp||"—"})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("div",{className:"text-[10px] text-text-muted uppercase tracking-wider mb-1",children:"Proxy"}),(0,s.jsx)("div",{className:"text-sm font-medium font-mono text-primary",children:e.proxy?`${e.proxy.type}://${e.proxy.host}:${e.proxy.port}`:"Direct"})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("div",{className:"text-[10px] text-text-muted uppercase tracking-wider mb-1",children:"Type"}),(0,s.jsx)("span",{className:"inline-block px-2.5 py-1 rounded text-[10px] font-bold uppercase",style:{backgroundColor:l.bg,color:l.text},children:l.label})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("div",{className:"text-[10px] text-text-muted uppercase tracking-wider mb-1",children:"Level"}),(0,s.jsx)("span",{className:"inline-block px-2.5 py-1 rounded text-[10px] font-bold uppercase",style:{backgroundColor:c.bg,color:c.text},children:c.label})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("div",{className:"text-[10px] text-text-muted uppercase tracking-wider mb-1",children:"Provider"}),e.provider?(0,s.jsx)("span",{className:"inline-block px-2.5 py-1 rounded text-[10px] font-bold uppercase",style:{backgroundColor:d.bg,color:d.text},children:d.label}):(0,s.jsx)("div",{className:"text-sm text-text-muted",children:"—"})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("div",{className:"text-[10px] text-text-muted uppercase tracking-wider mb-1",children:"TLS Fingerprint"}),e.tlsFingerprint?(0,s.jsxs)("span",{className:"inline-flex items-center gap-1 px-2.5 py-1 rounded text-[10px] font-bold uppercase",style:{backgroundColor:"rgba(6, 182, 212, 0.15)",color:"#22d3ee"},children:[(0,s.jsx)("span",{style:{fontSize:"12px"},children:"\uD83D\uDD12"})," Chrome 124"]}):(0,s.jsx)("div",{className:"text-sm text-text-muted",children:"Direct (native)"})]}),(0,s.jsxs)("div",{className:"col-span-2",children:[(0,s.jsx)("div",{className:"text-[10px] text-text-muted uppercase tracking-wider mb-1",children:"Target URL"}),(0,s.jsx)("div",{className:"text-sm font-medium font-mono text-text-muted break-all",children:e.targetUrl||"—"})]})]}),e.error&&(0,s.jsxs)("div",{className:"p-4 rounded-xl bg-red-500/10 border border-red-500/30",children:[(0,s.jsx)("div",{className:"text-[10px] text-red-400 uppercase tracking-wider mb-1 font-bold",children:"Error"}),(0,s.jsx)("div",{className:"text-sm text-red-300 font-mono",children:e.error})]}),e.proxy&&(0,s.jsxs)("div",{className:"p-4 rounded-xl bg-bg-subtle border border-border",children:[(0,s.jsx)("div",{className:"text-[10px] text-text-muted uppercase tracking-wider mb-2 font-bold",children:"Proxy Configuration"}),(0,s.jsx)("pre",{className:"text-xs font-mono text-text-primary bg-black/20 rounded-lg p-3 overflow-x-auto",children:JSON.stringify(e.proxy,null,2)})]})]})]})]})}let c=[{key:"all",label:"All"},{key:"error",label:"Errors",icon:"error"},{key:"ok",label:"Success",icon:"check_circle"},{key:"timeout",label:"Timeout",icon:"timer_off"}],d=[{key:"status",label:"Status"},{key:"proxy",label:"Proxy"},{key:"tls",label:"TLS"},{key:"type",label:"Type"},{key:"level",label:"Level"},{key:"provider",label:"Provider"},{key:"target",label:"Target"},{key:"latency",label:"Latency"},{key:"ip",label:"Public IP"},{key:"time",label:"Time"}],x=Object.fromEntries(d.map(e=>[e.key,!0]));function m(){let[e,t]=(0,a.useState)([]),[r,m]=(0,a.useState)(!0),[u,p]=(0,a.useState)(!0),[h,b]=(0,a.useState)(""),[f,g]=(0,a.useState)("all"),[y,j]=(0,a.useState)(""),[v,N]=(0,a.useState)(""),[k,w]=(0,a.useState)(""),[C,S]=(0,a.useState)("newest"),[A,T]=(0,a.useState)(null),I=(0,a.useRef)(null),M=(0,a.useRef)(!1),O=(0,a.useRef)(""),[R,L]=(0,a.useState)(()=>{try{let e=localStorage.getItem("proxyLoggerVisibleColumns");return e?{...x,...JSON.parse(e)}:x}catch{return x}}),E=(0,a.useCallback)(e=>{L(t=>{let r={...t,[e]:!t[e]};try{localStorage.setItem("proxyLoggerVisibleColumns",JSON.stringify(r))}catch{}return r})},[]),_=(0,a.useCallback)(async(e=!1)=>{e&&m(!0);try{let e=new URLSearchParams;h&&e.set("search",h),"error"===f&&e.set("status","error"),"ok"===f&&e.set("status","ok"),"timeout"===f&&e.set("status","timeout"),y&&e.set("type",y),v&&e.set("provider",v),k&&e.set("level",k),e.set("limit","300");let r=await fetch(`/api/usage/proxy-logs?${e}`);if(r.ok){let e=await r.json(),s=JSON.stringify(e.map?.(e=>e.id)??[]);s!==O.current&&(O.current=s,t(e))}}catch(e){console.error("Failed to fetch proxy logs:",e)}finally{e&&m(!1)}},[h,f,y,v,k]);(0,a.useEffect)(()=>{let e=!M.current;M.current=!0,_(e)},[_]),(0,a.useEffect)(()=>(I.current&&clearInterval(I.current),u&&(I.current=setInterval(()=>_(!1),3e3)),()=>{I.current&&clearInterval(I.current)}),[u,_]);let F=(0,a.useMemo)(()=>{let t=[...e];return t.sort((e,t)=>{switch(C){case"oldest":return new Date(e.timestamp).getTime()-new Date(t.timestamp).getTime();case"latency_desc":return(t.latencyMs||0)-(e.latencyMs||0);case"latency_asc":return(e.latencyMs||0)-(t.latencyMs||0);default:return new Date(t.timestamp).getTime()-new Date(e.timestamp).getTime()}}),t},[e,C]),$=[...new Set(e.map(e=>e.provider).filter(Boolean))].sort(),D=[...new Set(e.map(e=>e.proxy?.type).filter(Boolean))].sort(),P=[...new Set(e.map(e=>e.level).filter(Boolean))].sort(),K=e.length,z=e.filter(e=>"success"===e.status).length,q=e.filter(e=>"error"===e.status).length,B=e.filter(e=>"timeout"===e.status).length,U=e.filter(e=>"direct"===e.level).length,W=e.filter(e=>e.tlsFingerprint).length;return(0,s.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,s.jsxs)("div",{className:"flex flex-wrap items-center gap-3",children:[(0,s.jsxs)("button",{onClick:()=>p(!u),className:`flex items-center gap-2 px-3 py-1.5 rounded-full text-sm font-medium border transition-colors ${u?"bg-red-500/10 border-red-500/30 text-red-400":"bg-bg-subtle border-border text-text-muted"}`,children:[(0,s.jsx)("span",{className:`w-2 h-2 rounded-full ${u?"bg-red-500 animate-pulse":"bg-text-muted"}`}),u?"Recording":"Paused"]}),(0,s.jsxs)("div",{className:"flex-1 min-w-[200px] relative",children:[(0,s.jsx)("span",{className:"material-symbols-outlined absolute left-3 top-1/2 -translate-y-1/2 text-text-muted text-[18px]",children:"search"}),(0,s.jsx)("input",{type:"text",placeholder:"Search host, provider, target, IP...",value:h,onChange:e=>b(e.target.value),className:"w-full pl-10 pr-4 py-2 rounded-lg bg-bg-subtle border border-border text-sm text-text-primary placeholder:text-text-muted focus:outline-none focus:border-primary"})]}),(0,s.jsxs)("select",{value:y,onChange:e=>j(e.target.value),className:"px-3 py-2 rounded-lg bg-bg-subtle border border-border text-sm text-text-primary focus:outline-none focus:border-primary appearance-none cursor-pointer min-w-[120px]",children:[(0,s.jsx)("option",{value:"",children:"All Types"}),D.map(e=>(0,s.jsx)("option",{value:e,children:(o.Gp[e]?.label||e).toUpperCase()},e))]}),(0,s.jsxs)("select",{value:k,onChange:e=>w(e.target.value),className:"px-3 py-2 rounded-lg bg-bg-subtle border border-border text-sm text-text-primary focus:outline-none focus:border-primary appearance-none cursor-pointer min-w-[120px]",children:[(0,s.jsx)("option",{value:"",children:"All Levels"}),P.map(e=>(0,s.jsx)("option",{value:e,children:o.Ie[e]?.label||e},e))]}),(0,s.jsxs)("select",{value:v,onChange:e=>N(e.target.value),className:"px-3 py-2 rounded-lg bg-bg-subtle border border-border text-sm text-text-primary focus:outline-none focus:border-primary appearance-none cursor-pointer min-w-[140px]",children:[(0,s.jsx)("option",{value:"",children:"All Providers"}),$.map(e=>{let t=o.RY[e];return(0,s.jsx)("option",{value:e,children:t?.label||e.toUpperCase()},e)})]}),(0,s.jsxs)("div",{className:"flex items-center gap-2 text-xs text-text-muted",children:[(0,s.jsxs)("span",{className:"px-2 py-1 rounded bg-bg-subtle border border-border font-mono",children:[K," total"]}),(0,s.jsxs)("span",{className:"px-2 py-1 rounded bg-emerald-500/10 text-emerald-400 font-mono",children:[z," OK"]}),q>0&&(0,s.jsxs)("span",{className:"px-2 py-1 rounded bg-red-500/10 text-red-400 font-mono",children:[q," ERR"]}),B>0&&(0,s.jsxs)("span",{className:"px-2 py-1 rounded bg-amber-500/10 text-amber-400 font-mono",children:[B," TMO"]}),U>0&&(0,s.jsxs)("span",{className:"px-2 py-1 rounded bg-gray-500/10 text-gray-400 font-mono",children:[U," direct"]}),W>0&&(0,s.jsxs)("span",{className:"px-2 py-1 rounded bg-cyan-500/10 text-cyan-400 font-mono",children:["\uD83D\uDD12 ",W," TLS"]})]}),(0,s.jsxs)("select",{value:C,onChange:e=>S(e.target.value),className:"px-3 py-2 rounded-lg bg-bg-subtle border border-border text-sm text-text-primary focus:outline-none focus:border-primary appearance-none cursor-pointer min-w-[140px]",children:[(0,s.jsx)("option",{value:"newest",children:"Newest"}),(0,s.jsx)("option",{value:"oldest",children:"Oldest"}),(0,s.jsx)("option",{value:"latency_desc",children:"Latency ↓"}),(0,s.jsx)("option",{value:"latency_asc",children:"Latency ↑"})]}),(0,s.jsx)("button",{onClick:()=>_(!1),className:"p-2 rounded-lg hover:bg-bg-subtle text-text-muted hover:text-text-primary transition-colors",title:"Refresh",children:(0,s.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:"refresh"})})]}),(0,s.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[c.map(e=>(0,s.jsxs)("button",{onClick:()=>g(f===e.key?"all":e.key),className:`flex items-center gap-1.5 px-3 py-1 rounded-full text-xs font-medium border transition-all ${f===e.key?"error"===e.key?"bg-red-500/20 text-red-400 border-red-500/40":"ok"===e.key?"bg-emerald-500/20 text-emerald-400 border-emerald-500/40":"timeout"===e.key?"bg-amber-500/20 text-amber-400 border-amber-500/40":"bg-primary text-white border-primary":"bg-bg-subtle border-border text-text-muted hover:border-text-muted"}`,children:[e.icon&&(0,s.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:e.icon}),e.label]},e.key)),$.length>0&&(0,s.jsx)("span",{className:"w-px h-5 bg-border mx-1"}),$.map(e=>{let t=o.RY[e]||{bg:"#374151",text:"#fff",label:e.toUpperCase()},r=v===e;return(0,s.jsx)("button",{onClick:()=>N(r?"":e),className:`px-3 py-1 rounded-full text-xs font-bold uppercase border transition-all ${r?"border-white/40 ring-1 ring-white/20":"border-transparent opacity-70 hover:opacity-100"}`,style:{backgroundColor:r?t.bg:`${t.bg}33`,color:r?t.text:t.bg},children:t.label},e)})]}),(0,s.jsxs)("div",{className:"flex flex-wrap items-center gap-1.5",children:[(0,s.jsx)("span",{className:"text-[10px] text-text-muted uppercase tracking-wider mr-1",children:"Columns"}),d.map(e=>(0,s.jsx)("button",{onClick:()=>E(e.key),className:`px-2 py-0.5 rounded text-[10px] font-medium border transition-all ${R[e.key]?"bg-primary/15 text-primary border-primary/30":"bg-bg-subtle text-text-muted border-border opacity-50 hover:opacity-80"}`,children:e.label},e.key))]}),(0,s.jsx)(l.default,{className:"overflow-hidden bg-black/5 dark:bg-black/20",children:(0,s.jsx)("div",{className:"p-0 overflow-x-auto max-h-[calc(100vh-320px)] overflow-y-auto",children:r&&0===e.length?(0,s.jsx)("div",{className:"p-8 text-center text-text-muted",children:"Loading proxy logs..."}):0===e.length?(0,s.jsxs)("div",{className:"p-8 text-center text-text-muted",children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-[48px] mb-2 block opacity-40",children:"vpn_lock"}),"No proxy logs yet. Configure proxies and make API calls to see them here."]}):0===F.length?(0,s.jsx)("div",{className:"p-8 text-center text-text-muted",children:"No logs match the current filters."}):(0,s.jsxs)("table",{className:"w-full text-left border-collapse text-xs",children:[(0,s.jsx)("thead",{className:"sticky top-0 z-10",style:{backgroundColor:"var(--bg-primary, #0f1117)"},children:(0,s.jsxs)("tr",{className:"border-b border-border",style:{backgroundColor:"var(--bg-primary, #0f1117)"},children:[R.status&&(0,s.jsx)("th",{className:"px-3 py-2.5 font-semibold text-text-muted uppercase tracking-wider text-[10px]",children:"Status"}),R.proxy&&(0,s.jsx)("th",{className:"px-3 py-2.5 font-semibold text-text-muted uppercase tracking-wider text-[10px]",children:"Proxy"}),R.tls&&(0,s.jsx)("th",{className:"px-3 py-2.5 font-semibold text-text-muted uppercase tracking-wider text-[10px]",children:"TLS"}),R.type&&(0,s.jsx)("th",{className:"px-3 py-2.5 font-semibold text-text-muted uppercase tracking-wider text-[10px]",children:"Type"}),R.level&&(0,s.jsx)("th",{className:"px-3 py-2.5 font-semibold text-text-muted uppercase tracking-wider text-[10px]",children:"Level"}),R.provider&&(0,s.jsx)("th",{className:"px-3 py-2.5 font-semibold text-text-muted uppercase tracking-wider text-[10px]",children:"Provider"}),R.target&&(0,s.jsx)("th",{className:"px-3 py-2.5 font-semibold text-text-muted uppercase tracking-wider text-[10px]",children:"Target"}),R.latency&&(0,s.jsx)("th",{className:"px-3 py-2.5 font-semibold text-text-muted uppercase tracking-wider text-[10px] text-right",children:"Latency"}),R.ip&&(0,s.jsx)("th",{className:"px-3 py-2.5 font-semibold text-text-muted uppercase tracking-wider text-[10px]",children:"Public IP"}),R.time&&(0,s.jsx)("th",{className:"px-3 py-2.5 font-semibold text-text-muted uppercase tracking-wider text-[10px] text-right",children:"Time"})]})}),(0,s.jsx)("tbody",{className:"divide-y divide-border/30",children:F.map(e=>{let t=(0,o.Yh)(e.status),r=o.Gp[e.proxy?.type]||{bg:"#6B7280",text:"#fff",label:e.proxy?.type||"-"},a=o.Ie[e.level]||o.Ie.direct,l=o.RY[e.provider]||{bg:"#374151",text:"#fff",label:(e.provider||"-").toUpperCase()},i="error"===e.status||"timeout"===e.status;return(0,s.jsxs)("tr",{onClick:()=>T(A?.id===e.id?null:e),className:`cursor-pointer hover:bg-primary/5 transition-colors ${i?"bg-red-500/5":""}`,children:[R.status&&(0,s.jsx)("td",{className:"px-3 py-2",children:(0,s.jsx)("span",{className:"inline-block px-2 py-0.5 rounded text-[10px] font-bold min-w-[50px] text-center uppercase",style:{backgroundColor:t.bg,color:t.text},children:e.status})}),R.proxy&&(0,s.jsx)("td",{className:"px-3 py-2 font-mono text-[11px] text-primary",children:e.proxy?`${e.proxy.host}:${e.proxy.port}`:"—"}),R.tls&&(0,s.jsx)("td",{className:"px-3 py-2",children:e.tlsFingerprint?(0,s.jsxs)("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 rounded text-[9px] font-bold uppercase",style:{backgroundColor:"rgba(6, 182, 212, 0.15)",color:"#22d3ee"},title:"Chrome 124 TLS Fingerprint",children:[(0,s.jsx)("span",{style:{fontSize:"10px"},children:"\uD83D\uDD12"})," TLS"]}):(0,s.jsx)("span",{className:"text-text-muted text-[10px]",children:"—"})}),R.type&&(0,s.jsx)("td",{className:"px-3 py-2",children:(0,s.jsx)("span",{className:"inline-block px-2 py-0.5 rounded text-[9px] font-bold uppercase",style:{backgroundColor:r.bg,color:r.text},children:r.label})}),R.level&&(0,s.jsx)("td",{className:"px-3 py-2",children:(0,s.jsx)("span",{className:"inline-block px-2 py-0.5 rounded text-[9px] font-bold uppercase",style:{backgroundColor:a.bg,color:a.text},children:a.label})}),R.provider&&(0,s.jsx)("td",{className:"px-3 py-2",children:e.provider?(0,s.jsx)("span",{className:"inline-block px-2 py-0.5 rounded text-[9px] font-bold uppercase",style:{backgroundColor:l.bg,color:l.text},children:l.label}):(0,s.jsx)("span",{className:"text-text-muted text-[10px]",children:"—"})}),R.target&&(0,s.jsx)("td",{className:"px-3 py-2 text-text-muted truncate max-w-[200px] font-mono text-[10px]",title:e.targetUrl,children:(0,n.Y1)(e.targetUrl)}),R.latency&&(0,s.jsx)("td",{className:"px-3 py-2 text-right text-text-muted font-mono",children:(0,n.a3)(e.latencyMs)}),R.ip&&(0,s.jsx)("td",{className:"px-3 py-2 font-mono text-[11px] text-emerald-400",children:e.publicIp||"—"}),R.time&&(0,s.jsx)("td",{className:"px-3 py-2 text-right text-text-muted",children:(0,n.fU)(e.timestamp)})]},e.id)})})]})})}),A&&(0,s.jsx)(i,{log:A,onClose:()=>T(null)})]})}},8898:(e,t,r)=>{function s(e){try{return new Date(e).toLocaleTimeString("en-US",{hour12:!1,hour:"2-digit",minute:"2-digit",second:"2-digit"})}catch{return"-"}}function a(e){return e?e<1e3?`${e}ms`:`${(e/1e3).toFixed(1)}s`:"-"}function l(e,t){if(!e||"-"===e)return"-";let r=e.indexOf("@");return r>3?t?e:e.slice(0,3)+"***"+e.slice(r):e.length>8?e.slice(0,5)+"***":e}function o(e,t){if(!e&&!t)return"—";let r=e||"key";return t?`${r} (${function(e,t=2,r=2){return e?e.length<=t+r?`${e.slice(0,1)}***`:`${e.slice(0,t)}***${e.slice(-r)}`:""}(t,4,4)})`:r}function n(e){return e>=1e9?`${(e/1e9).toFixed(1)}B`:e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}K`:new Intl.NumberFormat().format(e||0)}function i(e){return new Intl.NumberFormat().format(e||0)}function c(e){return`$${(e||0).toFixed(2)}`}function d(e,t=50){if(!e)return"-";try{let r=new URL(e),s=r.hostname+r.pathname;return s.length>t?s.slice(0,t)+"…":s}catch{return e.length>t?e.slice(0,t)+"…":e}}function x(e){return"number"==typeof e&&isFinite(e)?e:void 0}r.d(t,{F0:()=>c,Ib:()=>l,Q1:()=>x,VK:()=>n,VO:()=>o,Y1:()=>d,a3:()=>a,fU:()=>s,xW:()=>i})},11567:(e,t,r)=>{r.d(t,{yX:()=>n});var s=r(12115);function a(){return window.electronAPI?.isElectron===!0}function l(){return!1}let o=()=>()=>{};function n(){return(0,s.useSyncExternalStore)(o,a,l)}},15559:(e,t,r)=>{r.d(t,{Ke:()=>a,ad:()=>l,ii:()=>n,uj:()=>o});let s=["home","endpoints","api-manager","providers","combos","batch","costs","analytics","cache","limits","cli-tools","agents","memory","skills","translator","playground","media","search-tools","logs","health","settings","docs","issues"],a=[{id:"primary",titleKey:"primarySection",titleFallback:"Main",items:[{id:"home",href:"/dashboard",i18nKey:"home",icon:"home",exact:!0},{id:"endpoints",href:"/dashboard/endpoint",i18nKey:"endpoints",icon:"api"},{id:"api-manager",href:"/dashboard/api-manager",i18nKey:"apiManager",icon:"vpn_key"},{id:"providers",href:"/dashboard/providers",i18nKey:"providers",icon:"dns"},{id:"combos",href:"/dashboard/combos",i18nKey:"combos",icon:"layers"},{id:"batch",href:"/dashboard/batch",i18nKey:"batch",icon:"view_list"},{id:"costs",href:"/dashboard/costs",i18nKey:"costs",icon:"account_balance_wallet"},{id:"analytics",href:"/dashboard/analytics",i18nKey:"analytics",icon:"analytics"},{id:"cache",href:"/dashboard/cache",i18nKey:"cache",icon:"cached"},{id:"limits",href:"/dashboard/limits",i18nKey:"limits",icon:"tune"},{id:"media",href:"/dashboard/cache/media",i18nKey:"media",icon:"perm_media"}],showTitleInSidebar:!1},{id:"cli",titleKey:"cliSection",titleFallback:"CLI",items:[{id:"cli-tools",href:"/dashboard/cli-tools",i18nKey:"cliToolsShort",icon:"terminal"},{id:"agents",href:"/dashboard/agents",i18nKey:"agents",icon:"smart_toy"},{id:"memory",href:"/dashboard/memory",i18nKey:"memory",icon:"psychology"},{id:"skills",href:"/dashboard/skills",i18nKey:"skills",icon:"auto_fix_high"}]},{id:"debug",titleKey:"debugSection",titleFallback:"Debug",items:[{id:"translator",href:"/dashboard/translator",i18nKey:"translator",icon:"translate"},{id:"playground",href:"/dashboard/playground",i18nKey:"playground",icon:"science"},{id:"search-tools",href:"/dashboard/search-tools",i18nKey:"searchTools",icon:"manage_search"}],visibility:"debug"},{id:"system",titleKey:"systemSection",titleFallback:"System",items:[{id:"logs",href:"/dashboard/logs",i18nKey:"logs",icon:"description"},{id:"health",href:"/dashboard/health",i18nKey:"health",icon:"health_and_safety"},{id:"settings",href:"/dashboard/settings",i18nKey:"settings",icon:"settings"}]},{id:"help",titleKey:"helpSection",titleFallback:"Help",items:[{id:"docs",href:"/docs",i18nKey:"docs",icon:"menu_book",external:!0},{id:"issues",href:"https://github.com/diegosouzapw/OmniRoute/issues",i18nKey:"issues",icon:"bug_report",external:!0}]}],l="hiddenSidebarItems",o="omniroute:settings-updated";function n(e){if(!Array.isArray(e))return[];let t=new Set;for(let r of e)"string"==typeof r&&s.includes(r)&&t.add(r);return s.filter(e=>t.has(e))}},17705:(e,t,r)=>{r.d(t,{default:()=>l});var s=r(95155),a=r(67040);function l({src:e,alt:t="Avatar",name:r,size:o="md",className:n}){let i={xs:"size-6 text-xs",sm:"size-8 text-sm",md:"size-10 text-base",lg:"size-12 text-lg",xl:"size-16 text-xl"};return e?(0,s.jsx)("div",{className:(0,a.cn)("rounded-full bg-cover bg-center bg-no-repeat","ring-2 ring-white dark:ring-surface-dark shadow-sm",i[o],n),style:{backgroundImage:`url(${e})`},role:"img","aria-label":t}):(0,s.jsx)("div",{className:(0,a.cn)("rounded-full flex items-center justify-center font-semibold text-white","ring-2 ring-white dark:ring-surface-dark shadow-sm",i[o],(e=>{if(!e)return"bg-primary";let t=["bg-red-500","bg-orange-500","bg-amber-500","bg-yellow-500","bg-lime-500","bg-green-500","bg-emerald-500","bg-teal-500","bg-cyan-500","bg-sky-500","bg-blue-500","bg-indigo-500","bg-violet-500","bg-purple-500","bg-fuchsia-500","bg-pink-500","bg-rose-500"],r=e.charCodeAt(0)%t.length;return t[r]})(r),n),role:"img","aria-label":t,children:(e=>{if(!e)return"?";let t=e.split(" ");return t.length>=2?`${t[0][0]}${t[1][0]}`.toUpperCase():e.substring(0,2).toUpperCase()})(r)})}},18150:(e,t,r)=>{r.d(t,{default:()=>x});var s=r(95155),a=r(12115),l=r(14051),o=r.n(l),n=r(71361),i=r(35806),c=r(34422),d=r(30949);function x({isOpen:e,provider:t,providerLabel:r="Kiro",onSuccess:l,onClose:o}){let[m,u]=(0,a.useState)("loading"),[p,h]=(0,a.useState)(""),[b,f]=(0,a.useState)(null),[g,y]=(0,a.useState)(""),[j,v]=(0,a.useState)(null),{copied:N,copy:k}=(0,d.C)();(0,a.useEffect)(()=>{e&&t&&(async()=>{try{v(null),u("loading");let e=await fetch(`/api/oauth/kiro/social-authorize?provider=${t}`),r=await e.json();if(!e.ok)throw Error(r.error);f(r),h(r.authUrl),u("input"),window.open(r.authUrl,"kiro_social_auth")}catch(e){v(e.message),u("error")}})()},[e,t]);let w=async()=>{try{let e;v(null);try{e=new URL(g)}catch(e){throw Error("Invalid callback URL format")}let r=e.searchParams.get("code");e.searchParams.get("state");let s=e.searchParams.get("error");if(s)throw Error(e.searchParams.get("error_description")||s);if(!r)throw Error("No authorization code found in URL");let a=await fetch("/api/oauth/kiro/social-exchange",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({code:r,codeVerifier:b.codeVerifier,provider:t})}),o=await a.json();if(!a.ok)throw Error(o.error);u("success"),l?.()}catch(e){v(e.message),u("error")}},C="google"===t?"Google":"GitHub";return(0,s.jsx)(n.default,{isOpen:e,title:`Connect ${r} via ${C}`,onClose:o,size:"lg",children:(0,s.jsxs)("div",{className:"flex flex-col gap-4",children:["loading"===m&&(0,s.jsxs)("div",{className:"text-center py-6",children:[(0,s.jsx)("div",{className:"size-16 mx-auto mb-4 rounded-full bg-primary/10 flex items-center justify-center",children:(0,s.jsx)("span",{className:"material-symbols-outlined text-3xl text-primary animate-spin",children:"progress_activity"})}),(0,s.jsx)("h3",{className:"text-lg font-semibold mb-2",children:"Initializing..."}),(0,s.jsxs)("p",{className:"text-sm text-text-muted",children:["Setting up ",C," authentication"]})]}),"input"===m&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("div",{className:"space-y-4",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:"text-sm font-medium mb-2",children:"Step 1: Open this URL in your browser"}),(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsx)(c.default,{value:p,readOnly:!0,className:"flex-1 font-mono text-xs"}),(0,s.jsx)(i.default,{variant:"secondary",icon:"auth_url"===N?"check":"content_copy",onClick:()=>k(p,"auth_url"),children:"Copy"})]})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:"text-sm font-medium mb-2",children:"Step 2: Paste the callback URL here"}),(0,s.jsx)("p",{className:"text-xs text-text-muted mb-2",children:"After authorization, copy the full URL from your browser address bar."}),(0,s.jsx)(c.default,{value:g,onChange:e=>y(e.target.value),placeholder:"kiro://kiro.kiroAgent/authenticate-success?code=...",className:"font-mono text-xs"})]})]}),(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsx)(i.default,{onClick:w,fullWidth:!0,disabled:!g,children:"Connect"}),(0,s.jsx)(i.default,{onClick:o,variant:"ghost",fullWidth:!0,children:"Cancel"})]})]}),"success"===m&&(0,s.jsxs)("div",{className:"text-center py-6",children:[(0,s.jsx)("div",{className:"size-16 mx-auto mb-4 rounded-full bg-green-100 dark:bg-green-900/30 flex items-center justify-center",children:(0,s.jsx)("span",{className:"material-symbols-outlined text-3xl text-green-600",children:"check_circle"})}),(0,s.jsx)("h3",{className:"text-lg font-semibold mb-2",children:"Connected Successfully!"}),(0,s.jsxs)("p",{className:"text-sm text-text-muted mb-4",children:["Your ",r," account via ",C," has been connected."]}),(0,s.jsx)(i.default,{onClick:o,fullWidth:!0,children:"Done"})]}),"error"===m&&(0,s.jsxs)("div",{className:"text-center py-6",children:[(0,s.jsx)("div",{className:"size-16 mx-auto mb-4 rounded-full bg-red-100 dark:bg-red-900/30 flex items-center justify-center",children:(0,s.jsx)("span",{className:"material-symbols-outlined text-3xl text-red-600",children:"error"})}),(0,s.jsx)("h3",{className:"text-lg font-semibold mb-2",children:"Connection Failed"}),(0,s.jsx)("p",{className:"text-sm text-red-600 mb-4",children:j}),(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsx)(i.default,{onClick:()=>u("input"),variant:"secondary",fullWidth:!0,children:"Try Again"}),(0,s.jsx)(i.default,{onClick:o,variant:"ghost",fullWidth:!0,children:"Cancel"})]})]})]})})}x.propTypes={isOpen:o().bool.isRequired,provider:o().oneOf(["google","github"]).isRequired,providerLabel:o().string,onSuccess:o().func,onClose:o().func.isRequired}},21720:(e,t,r)=>{r.d(t,{default:()=>h});var s=r(95155),a=r(12115),l=r(42912),o=r(87806),n=r(76332),i=r(61580),c=r(50910);function d(){let[e,t]=(0,a.useState)(!1),[r,l]=(0,a.useState)(""),o=(0,a.useRef)(0),n=(0,a.useRef)(!1),i=(0,c.c)("common");return((0,a.useEffect)(()=>{let e=async()=>{let e=new AbortController,r=setTimeout(()=>e.abort("Health check timeout"),8e3);try{(await fetch("/api/monitoring/health",{signal:e.signal,cache:"no-store"})).ok?(o.current=0,n.current=!1,t(!1),l("")):(o.current+=1,o.current>=2&&!n.current&&(t(!0),l(i("maintenanceServerIssues"))))}catch{o.current+=1,o.current>=2&&!n.current&&(t(!0),l(i("maintenanceServerUnreachable")))}finally{clearTimeout(r)}};e();let r=setInterval(e,1e4);return()=>clearInterval(r)},[i]),e)?(0,s.jsxs)("div",{className:"bg-amber-500/10 border-b border-amber-500/20 px-4 py-2.5 flex items-center justify-between gap-3 animate-in slide-in-from-top",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2.5",children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-amber-500 text-[18px] animate-pulse",children:"warning"}),(0,s.jsx)("span",{className:"text-sm text-amber-200",children:r})]}),(0,s.jsx)("button",{onClick:()=>{n.current=!0,t(!1)},className:"p-1 rounded hover:bg-white/5 text-text-muted hover:text-text-main transition-colors","aria-label":i("close"),children:(0,s.jsx)("span",{className:"material-symbols-outlined text-[16px]",children:"close"})})]}):null}var x=r(11567),m=r(41463);let u="sidebar-collapsed",p="1"===m.env.NEXT_PUBLIC_OMNIROUTE_E2E_MODE;function h({children:e}){let[t,r]=(0,a.useState)(!1),c=(0,x.yX)(),[m,b]=(0,a.useState)(()=>{try{return"true"===localStorage.getItem(u)}catch{return!1}}),f=c&&window.electronAPI?.platform==="darwin";return(0,a.useEffect)(()=>{if("u">typeof document)return document.body.classList.toggle("electron-macos",f),()=>{document.body.classList.remove("electron-macos")}},[f]),(0,s.jsxs)("div",{className:"flex h-dvh min-h-0 w-full overflow-hidden bg-bg",children:[t&&(0,s.jsx)("div",{className:"fixed inset-0 z-40 bg-black/20 lg:hidden",onClick:()=>r(!1)}),(0,s.jsx)("div",{className:"hidden min-h-0 lg:flex",children:(0,s.jsx)(l.default,{collapsed:m,onToggleCollapse:()=>{let e=!m;b(e),localStorage.setItem(u,String(e))},isMacElectron:f})}),(0,s.jsx)("div",{className:`fixed inset-y-0 left-0 z-50 transform lg:hidden transition-transform duration-300 ease-in-out h-dvh overflow-y-auto ${t?"translate-x-0":"-translate-x-full"}`,children:(0,s.jsx)(l.default,{onClose:()=>r(!1),isMacElectron:f})}),(0,s.jsxs)("main",{id:"main-content",className:"relative flex min-h-0 flex-1 min-w-0 flex-col transition-colors duration-300",children:[(0,s.jsx)(o.default,{onMenuClick:()=>r(!0)}),!p&&(0,s.jsx)(d,{}),(0,s.jsx)("div",{className:"flex-1 min-h-0 overflow-y-auto overflow-x-hidden custom-scrollbar p-4 sm:p-6 lg:p-10",children:(0,s.jsxs)("div",{className:"max-w-7xl mx-auto w-full",children:[(0,s.jsx)(n.default,{}),e]})})]}),(0,s.jsx)(i.default,{})]})}},25112:(e,t,r)=>{r.d(t,{default:()=>h});var s=r(95155),a=r(50910),l=r(12115),o=r(14051),n=r.n(o),i=r(73321),c=r(81060),d=r(80927),x=r(92542),m=r(8898);function u({field:e,currentSort:t,currentOrder:r}){return t!==e?(0,s.jsx)("span",{className:"ml-1 opacity-20",children:"↕"}):(0,s.jsx)("span",{className:"ml-1",children:"asc"===r?"↑":"↓"})}function p({data:e,colorClass:t="bg-primary"}){let r=Math.max(...e,1);return(0,s.jsx)("div",{className:"flex items-end gap-1 h-8 w-24",children:e.slice(-9).map((e,a)=>(0,s.jsx)("div",{className:`flex-1 rounded-t-sm transition-all duration-500 ${t}`,style:{height:`${Math.max(e/r*100,5)}%`},title:String(e)},`bar-${a}-${e}`))})}function h(){let e=(0,a.c)("stats"),t=(0,i.useRouter)(),r=(0,i.useSearchParams)(),o=r.get("sortBy")||"rawModel",n=r.get("sortOrder")||"asc",[h,b]=(0,l.useState)(null),[f,g]=(0,l.useState)(!0),[y,j]=(0,l.useState)(!0),[v,N]=(0,l.useState)("tokens"),[k,w]=(0,l.useState)(5e3),C=(0,l.useRef)(0),S=e=>{let s=new URLSearchParams(r.toString());o===e?s.set("sortOrder","asc"===n?"desc":"asc"):(s.set("sortBy",e),s.set("sortOrder","asc")),t.replace(`?${s.toString()}`,{scroll:!1})},A=(0,l.useCallback)((e,t={})=>Object.entries(e||{}).map(([e,r])=>{let s=(r.promptTokens||0)+(r.completionTokens||0),a=r.cost||0,l=s>0?(r.promptTokens||0)*(a/s):0,o=s>0?(r.completionTokens||0)*(a/s):0;return{...r,key:e,totalTokens:s,totalCost:a,inputCost:l,outputCost:o,pending:t[e]||0}}).sort((e,t)=>{let r=e[o],s=t[o];return("string"==typeof r&&(r=r.toLowerCase()),"string"==typeof s&&(s=s.toLowerCase()),r<s)?"asc"===n?-1:1:r>s?"asc"===n?1:-1:0}),[o,n]),T=(0,l.useMemo)(()=>A(h?.byModel,h?.pending?.byModel),[h?.byModel,h?.pending?.byModel,A]),I=(0,l.useMemo)(()=>{let e={};return h?.pending?.byAccount&&Object.entries(h.byAccount||{}).forEach(([t,r])=>{let s=h.pending.byAccount[r.connectionId];if(s){let a=r.provider?`${r.rawModel} (${r.provider})`:r.rawModel;e[t]=s[a]||0}}),A(h?.byAccount,e)},[h?.byAccount,h?.pending?.byAccount,A]),M=(0,l.useCallback)(async(e=!0)=>{e&&g(!0);try{let e=await fetch("/api/usage/history");if(e.ok){let t=await e.json();b(t);let r=t.totalRequests||0;r>C.current?w(5e3):w(e=>Math.min(2*e,6e4)),C.current=r}}catch(e){console.error("Failed to fetch usage stats:",e)}finally{e&&g(!1)}},[]);if((0,l.useEffect)(()=>{M()},[M]),(0,l.useEffect)(()=>{let e,t=!0,r=()=>{(t=!document.hidden)&&y&&M(!1)};return document.addEventListener("visibilitychange",r),y&&(e&&clearInterval(e),e=setInterval(()=>{t&&M(!1)},k)),()=>{e&&clearInterval(e),document.removeEventListener("visibilitychange",r)}},[y,k,M]),f)return(0,s.jsx)(x.CardSkeleton,{});if(!h)return(0,s.jsx)("div",{className:"text-text-muted",children:e("failedToLoad")});let O=e=>(0,m.xW)(e),R=e=>{if(!e)return"Never";let t=new Date(e),r=Math.floor((new Date().getTime()-t.getTime())/6e4);return r<1?"Just now":r<60?`${r}m ago`:r<1440?`${Math.floor(r/60)}h ago`:t.toLocaleDateString()};return(0,s.jsxs)("div",{className:"flex flex-col gap-6",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between",children:[(0,s.jsx)("h2",{className:"text-xl font-semibold",children:e("usageOverview")}),(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsxs)("div",{className:"flex items-center gap-1 bg-bg-subtle rounded-lg p-1 border border-border",children:[(0,s.jsx)("button",{onClick:()=>N("tokens"),className:`px-3 py-1 rounded-md text-sm font-medium transition-colors ${"tokens"===v?"bg-primary text-white shadow-sm":"text-text-muted hover:text-text hover:bg-bg-hover"}`,children:"Tokens"}),(0,s.jsx)("button",{onClick:()=>N("costs"),className:`px-3 py-1 rounded-md text-sm font-medium transition-colors ${"costs"===v?"bg-primary text-white shadow-sm":"text-text-muted hover:text-text hover:bg-bg-hover"}`,children:"Costs"})]}),(0,s.jsxs)("div",{className:"text-sm font-medium text-text-muted flex items-center gap-2",children:[(0,s.jsxs)("span",{children:["Auto Refresh (",k/1e3,"s)"]}),(0,s.jsx)("button",{type:"button",onClick:()=>j(!y),role:"switch","aria-checked":y,"aria-label":"Toggle auto refresh",className:`relative inline-flex h-5 w-9 items-center rounded-full transition-colors focus:outline-none focus:ring-2 focus:ring-primary/50 ${y?"bg-primary":"bg-bg-subtle border border-border"}`,children:(0,s.jsx)("span",{className:`inline-block h-3 w-3 transform rounded-full bg-white transition-transform ${y?"translate-x-5":"translate-x-1"}`})})]})]})]}),(h.activeRequests||[]).length>0&&(0,s.jsx)(c.default,{className:"p-3 border-primary/20 bg-primary/5",children:(0,s.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2 text-primary font-semibold text-sm uppercase tracking-wider",children:[(0,s.jsxs)("span",{className:"relative flex h-2 w-2",children:[(0,s.jsx)("span",{className:"animate-ping absolute inline-flex h-full w-full rounded-full bg-primary opacity-75"}),(0,s.jsx)("span",{className:"relative inline-flex rounded-full h-2 w-2 bg-primary"})]}),"Active Requests"]}),(0,s.jsx)("div",{className:"flex flex-wrap gap-3",children:h.activeRequests.map(e=>(0,s.jsxs)("div",{className:"px-3 py-1.5 rounded-md bg-bg-subtle border border-primary/20 text-xs font-mono shadow-sm",children:[(0,s.jsx)("span",{className:"text-primary font-bold",children:e.model}),(0,s.jsx)("span",{className:"mx-1 text-text-muted",children:"|"}),(0,s.jsx)("span",{className:"text-text",children:e.provider}),(0,s.jsx)("span",{className:"mx-1 text-text-muted",children:"|"}),(0,s.jsx)("span",{className:"text-text font-medium",children:e.account}),e.count>1&&(0,s.jsxs)("span",{className:"ml-2 px-1.5 py-0.5 rounded bg-primary text-white font-bold",children:["x",e.count]})]},`${e.model}-${e.provider}-${e.account}`))})]})}),(0,s.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[(0,s.jsx)(c.default,{className:"px-4 py-3 flex flex-col gap-1",children:(0,s.jsxs)("div",{className:"flex justify-between items-start",children:[(0,s.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,s.jsx)("span",{className:"text-text-muted text-sm uppercase font-semibold",children:"Total Requests"}),(0,s.jsx)("span",{className:"text-2xl font-bold",children:O(h.totalRequests)})]}),(0,s.jsx)(p,{data:(h.last10Minutes||[]).map(e=>e.requests),colorClass:"bg-text-muted/30"})]})}),(0,s.jsx)(c.default,{className:"px-4 py-3 flex flex-col gap-1",children:(0,s.jsxs)("div",{className:"flex justify-between items-start",children:[(0,s.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,s.jsx)("span",{className:"text-text-muted text-sm uppercase font-semibold",children:"Total Input Tokens"}),(0,s.jsx)("span",{className:"text-2xl font-bold text-primary",children:O(h.totalPromptTokens)})]}),(0,s.jsx)(p,{data:(h.last10Minutes||[]).map(e=>e.promptTokens),colorClass:"bg-primary/50"})]})}),(0,s.jsx)(c.default,{className:"px-4 py-2 flex flex-col gap-1",children:(0,s.jsxs)("div",{className:"flex justify-between items-start gap-4",children:[(0,s.jsxs)("div",{className:"flex flex-col gap-1 flex-1",children:[(0,s.jsx)("span",{className:"text-text-muted text-sm uppercase font-semibold",children:e("outputTokens")}),(0,s.jsx)("span",{className:"text-2xl font-bold text-success",children:O(h.totalCompletionTokens)})]}),(0,s.jsx)("div",{className:"w-px bg-border self-stretch mx-2"}),(0,s.jsxs)("div",{className:"flex flex-col gap-1 flex-1",children:[(0,s.jsx)("span",{className:"text-text-muted text-sm uppercase font-semibold",children:e("totalCost")}),(0,s.jsx)("span",{className:"text-2xl font-bold text-warning",children:(0,m.F0)(h.totalCost)})]})]})})]}),(0,s.jsxs)(c.default,{className:"overflow-hidden",children:[(0,s.jsx)("div",{className:"p-4 border-b border-border bg-bg-subtle/50",children:(0,s.jsx)("h3",{className:"font-semibold",children:"Usage by Model"})}),(0,s.jsx)("div",{className:"overflow-x-auto",children:(0,s.jsxs)("table",{className:"w-full text-sm text-left",children:[(0,s.jsx)("thead",{className:"bg-bg-subtle/30 text-text-muted uppercase text-xs",children:(0,s.jsxs)("tr",{children:[(0,s.jsxs)("th",{className:"px-6 py-3 cursor-pointer hover:bg-bg-subtle/50",onClick:()=>S("rawModel"),children:["Model ",(0,s.jsx)(u,{field:"rawModel",currentSort:o,currentOrder:n})]}),(0,s.jsxs)("th",{className:"px-6 py-3 cursor-pointer hover:bg-bg-subtle/50",onClick:()=>S("provider"),children:["Provider"," ",(0,s.jsx)(u,{field:"provider",currentSort:o,currentOrder:n})]}),(0,s.jsxs)("th",{className:"px-6 py-3 text-right cursor-pointer hover:bg-bg-subtle/50",onClick:()=>S("requests"),children:["Requests"," ",(0,s.jsx)(u,{field:"requests",currentSort:o,currentOrder:n})]}),(0,s.jsxs)("th",{className:"px-6 py-3 text-right cursor-pointer hover:bg-bg-subtle/50",onClick:()=>S("lastUsed"),children:["Last Used"," ",(0,s.jsx)(u,{field:"lastUsed",currentSort:o,currentOrder:n})]}),"tokens"===v?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("th",{className:"px-6 py-3 text-right cursor-pointer hover:bg-bg-subtle/50",onClick:()=>S("promptTokens"),children:["Input Tokens"," ",(0,s.jsx)(u,{field:"promptTokens",currentSort:o,currentOrder:n})]}),(0,s.jsxs)("th",{className:"px-6 py-3 text-right cursor-pointer hover:bg-bg-subtle/50",onClick:()=>S("completionTokens"),children:["Output Tokens"," ",(0,s.jsx)(u,{field:"completionTokens",currentSort:o,currentOrder:n})]}),(0,s.jsxs)("th",{className:"px-6 py-3 text-right cursor-pointer hover:bg-bg-subtle/50",onClick:()=>S("totalTokens"),children:["Total Tokens"," ",(0,s.jsx)(u,{field:"totalTokens",currentSort:o,currentOrder:n})]})]}):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("th",{className:"px-6 py-3 text-right cursor-pointer hover:bg-bg-subtle/50",onClick:()=>S("promptTokens"),children:["Input Cost"," ",(0,s.jsx)(u,{field:"promptTokens",currentSort:o,currentOrder:n})]}),(0,s.jsxs)("th",{className:"px-6 py-3 text-right cursor-pointer hover:bg-bg-subtle/50",onClick:()=>S("completionTokens"),children:["Output Cost"," ",(0,s.jsx)(u,{field:"completionTokens",currentSort:o,currentOrder:n})]}),(0,s.jsxs)("th",{className:"px-6 py-3 text-right cursor-pointer hover:bg-bg-subtle/50",onClick:()=>S("cost"),children:["Total Cost"," ",(0,s.jsx)(u,{field:"cost",currentSort:o,currentOrder:n})]})]})]})}),(0,s.jsxs)("tbody",{className:"divide-y divide-border",children:[T.map(e=>(0,s.jsxs)("tr",{className:"hover:bg-bg-subtle/20",children:[(0,s.jsx)("td",{className:`px-6 py-3 font-medium transition-colors ${e.pending>0?"text-primary":""}`,children:e.rawModel}),(0,s.jsx)("td",{className:"px-6 py-3",children:(0,s.jsx)(d.default,{variant:e.pending>0?"primary":"default",size:"sm",children:e.provider})}),(0,s.jsx)("td",{className:"px-6 py-3 text-right",children:O(e.requests)}),(0,s.jsx)("td",{className:"px-6 py-3 text-right text-text-muted whitespace-nowrap",children:R(e.lastUsed)}),"tokens"===v?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("td",{className:"px-6 py-3 text-right text-text-muted",children:O(e.promptTokens)}),(0,s.jsx)("td",{className:"px-6 py-3 text-right text-text-muted",children:O(e.completionTokens)}),(0,s.jsx)("td",{className:"px-6 py-3 text-right font-medium",children:O(e.totalTokens)})]}):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("td",{className:"px-6 py-3 text-right text-text-muted",children:(0,m.F0)(e.inputCost)}),(0,s.jsx)("td",{className:"px-6 py-3 text-right text-text-muted",children:(0,m.F0)(e.outputCost)}),(0,s.jsx)("td",{className:"px-6 py-3 text-right font-medium text-warning",children:(0,m.F0)(e.totalCost)})]})]},e.key)),0===T.length&&(0,s.jsx)("tr",{children:(0,s.jsx)("td",{colSpan:8,className:"px-6 py-8 text-center text-text-muted",children:"No usage recorded yet. Make some requests to see data here."})})]})]})})]}),(0,s.jsxs)(c.default,{className:"overflow-hidden",children:[(0,s.jsx)("div",{className:"p-4 border-b border-border bg-bg-subtle/50",children:(0,s.jsx)("h3",{className:"font-semibold",children:"Usage by Account"})}),(0,s.jsx)("div",{className:"overflow-x-auto",children:(0,s.jsxs)("table",{className:"w-full text-sm text-left",children:[(0,s.jsx)("thead",{className:"bg-bg-subtle/30 text-text-muted uppercase text-xs",children:(0,s.jsxs)("tr",{children:[(0,s.jsxs)("th",{className:"px-6 py-3 cursor-pointer hover:bg-bg-subtle/50",onClick:()=>S("rawModel"),children:["Model ",(0,s.jsx)(u,{field:"rawModel",currentSort:o,currentOrder:n})]}),(0,s.jsxs)("th",{className:"px-6 py-3 cursor-pointer hover:bg-bg-subtle/50",onClick:()=>S("provider"),children:["Provider"," ",(0,s.jsx)(u,{field:"provider",currentSort:o,currentOrder:n})]}),(0,s.jsxs)("th",{className:"px-6 py-3 cursor-pointer hover:bg-bg-subtle/50",onClick:()=>S("accountName"),children:["Account"," ",(0,s.jsx)(u,{field:"accountName",currentSort:o,currentOrder:n})]}),(0,s.jsxs)("th",{className:"px-6 py-3 text-right cursor-pointer hover:bg-bg-subtle/50",onClick:()=>S("requests"),children:["Requests"," ",(0,s.jsx)(u,{field:"requests",currentSort:o,currentOrder:n})]}),(0,s.jsxs)("th",{className:"px-6 py-3 text-right cursor-pointer hover:bg-bg-subtle/50",onClick:()=>S("lastUsed"),children:["Last Used"," ",(0,s.jsx)(u,{field:"lastUsed",currentSort:o,currentOrder:n})]}),"tokens"===v?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("th",{className:"px-6 py-3 text-right cursor-pointer hover:bg-bg-subtle/50",onClick:()=>S("promptTokens"),children:["Input Tokens"," ",(0,s.jsx)(u,{field:"promptTokens",currentSort:o,currentOrder:n})]}),(0,s.jsxs)("th",{className:"px-6 py-3 text-right cursor-pointer hover:bg-bg-subtle/50",onClick:()=>S("completionTokens"),children:["Output Tokens"," ",(0,s.jsx)(u,{field:"completionTokens",currentSort:o,currentOrder:n})]}),(0,s.jsxs)("th",{className:"px-6 py-3 text-right cursor-pointer hover:bg-bg-subtle/50",onClick:()=>S("totalTokens"),children:["Total Tokens"," ",(0,s.jsx)(u,{field:"totalTokens",currentSort:o,currentOrder:n})]})]}):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("th",{className:"px-6 py-3 text-right cursor-pointer hover:bg-bg-subtle/50",onClick:()=>S("promptTokens"),children:["Input Cost"," ",(0,s.jsx)(u,{field:"promptTokens",currentSort:o,currentOrder:n})]}),(0,s.jsxs)("th",{className:"px-6 py-3 text-right cursor-pointer hover:bg-bg-subtle/50",onClick:()=>S("completionTokens"),children:["Output Cost"," ",(0,s.jsx)(u,{field:"completionTokens",currentSort:o,currentOrder:n})]}),(0,s.jsxs)("th",{className:"px-6 py-3 text-right cursor-pointer hover:bg-bg-subtle/50",onClick:()=>S("cost"),children:["Total Cost"," ",(0,s.jsx)(u,{field:"cost",currentSort:o,currentOrder:n})]})]})]})}),(0,s.jsxs)("tbody",{className:"divide-y divide-border",children:[I.map(e=>(0,s.jsxs)("tr",{className:"hover:bg-bg-subtle/20",children:[(0,s.jsx)("td",{className:`px-6 py-3 font-medium transition-colors ${e.pending>0?"text-primary":""}`,children:e.rawModel}),(0,s.jsx)("td",{className:"px-6 py-3",children:(0,s.jsx)(d.default,{variant:e.pending>0?"primary":"default",size:"sm",children:e.provider})}),(0,s.jsx)("td",{className:"px-6 py-3",children:(0,s.jsx)("span",{className:`font-medium transition-colors ${e.pending>0?"text-primary":""}`,children:e.accountName||`Account ${e.connectionId?.slice(0,8)}...`})}),(0,s.jsx)("td",{className:"px-6 py-3 text-right",children:O(e.requests)}),(0,s.jsx)("td",{className:"px-6 py-3 text-right text-text-muted whitespace-nowrap",children:R(e.lastUsed)}),"tokens"===v?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("td",{className:"px-6 py-3 text-right text-text-muted",children:O(e.promptTokens)}),(0,s.jsx)("td",{className:"px-6 py-3 text-right text-text-muted",children:O(e.completionTokens)}),(0,s.jsx)("td",{className:"px-6 py-3 text-right font-medium",children:O(e.totalTokens)})]}):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("td",{className:"px-6 py-3 text-right text-text-muted",children:(0,m.F0)(e.inputCost)}),(0,s.jsx)("td",{className:"px-6 py-3 text-right text-text-muted",children:(0,m.F0)(e.outputCost)}),(0,s.jsx)("td",{className:"px-6 py-3 text-right font-medium text-warning",children:(0,m.F0)(e.totalCost)})]})]},e.key)),0===I.length&&(0,s.jsx)("tr",{children:(0,s.jsx)("td",{colSpan:9,className:"px-6 py-8 text-center text-text-muted",children:"No account-specific usage recorded yet. Make requests using OAuth accounts to see data here."})})]})]})})]})]})}u.propTypes={field:n().string.isRequired,currentSort:n().string.isRequired,currentOrder:n().string.isRequired},p.propTypes={data:n().arrayOf(n().number).isRequired,colorClass:n().string}},29862:(e,t,r)=>{r.d(t,{A:()=>tz});var s=r(95155),a=r(12115),l=r(5772),o=r(89358),n=r(10760),i=r(6334),c=r(67381),d=r(14574),x=r(17044),m=r(69512),u=r(47198),p=r(75425),h=r(29345),b=r(60403),f=r(99059),g=r(94301),y=r(94669),j=r(83003),v=r(32251),N=r(41573),k=r(92501),w=r(38632),C=r(12958),S=r(2965),A=r(74418),T=r(30248),I=r(74897),M=r(3321),O=r(33017),R=r(45955),L=r(44067),E=r(90288),_=r(69399),F=r(63367),$=r(43433),D=r(53513),P=r(46522),K=r(90544),z=r(75990),q=r(82044),B=r(86929),U=r(67966),W=r(29220),V=r(66988),G=r(90562),H=r(52520),J=r(16062),Y=r(58808),X=r(15172),Z=r(37722),Q=r(52957),ee=r(72237),et=r(9490),er=r(7880),es=r(44610),ea=r(86456),el=r(2618),eo=r(29775),en=r(73375),ei=r(49857),ec=r(69441),ed=r(57794),ex=r(10839),em=r(80935),eu=r(34166),ep=r(9312),eh=r(87638),eb=r(86108),ef=r(56655),eg=r(29599),ey=r(72319),ej=r(92104),ev=r(215),eN=r(52823),ek=r(27576),ew=r(28078),eC=r(12678),eS=r(41356),eA=r(87609),eT=r(27577),eI=r(11799),eM=r(49447),eO=r(95541),eR=r(44293),eL=r(27056),eE=r(19398),e_=r(22008),eF=r(23886),e$=r(94292),eD=r(82311),eP=r(80599),eK=r(42339),ez=r(38073),eq=r(27109),eB=r(61173),eU=r(79191),eW=r(73799),eV=r(45293),eG=r(64433),eH=r(77583),eJ=r(44351),eY=r(74068),eX=r(19872),eZ=r(12804),eQ=r(20858),e0=r(53300),e1=r(22922),e2=r(71809),e5=r(44225),e3=r(5711),e4=r(26751),e6=r(662),e8=r(69140),e9=r(36239),e7=r(4376),te=r(2478),tt=r(60249),tr=r(11008),ts=r(2102),ta=r(81352),tl=r(35870),to=r(24701),tn=r(25389),ti=r(68385),tc=r(11489),td=r(10632),tx=r(75326),tm=r(53945),tu=r(78075),tp=r(87931),th=r(24869),tb=r(47478),tf=r(39484),tg=r(48238),ty=r(93326),tj=r(36020),tv=r(21081),tN=r(67321),tk=r(36730),tw=r(8784),tC=r(16237),tS=r(5309),tA=r(40431),tT=r(99839),tI=r(7751),tM=r(83546),tO=r(4635),tR=r(79675),tL=r(83709),tE=r(30814),t_=r(25604);let tF={Ai21:{mono:o.A},Alibaba:{mono:i.A,color:n.A},Anthropic:{mono:c.A},Antigravity:{mono:x.A,color:d.A},AssemblyAI:{mono:u.A,color:m.A},Automatic:{mono:h.A,color:p.A},Aws:{mono:f.A,color:b.A},Azure:{mono:y.A,color:g.A},AzureAI:{mono:v.A,color:j.A},Baidu:{mono:k.A,color:N.A},Bailian:{mono:C.A,color:w.A},Baseten:{mono:S.A},Bedrock:{mono:T.A,color:A.A},Bfl:{mono:I.A},Cerebras:{mono:O.A,color:M.A},ClaudeCode:{mono:L.A,color:R.A},Cline:{mono:E.A},Cloudflare:{mono:F.A,color:_.A},Codex:{mono:D.A,color:$.A},Cohere:{mono:K.A,color:P.A},ComfyUI:{mono:q.A,color:z.A},Cursor:{mono:B.A},Dbrx:{mono:W.A,color:U.A},DeepInfra:{mono:G.A,color:V.A},DeepSeek:{mono:J.A,color:H.A},ElevenLabs:{mono:Y.A},Exa:{mono:Z.A,color:X.A},Fal:{mono:ee.A,color:Q.A},Featherless:{mono:er.A,color:et.A},Fireworks:{mono:ea.A,color:es.A},Friendli:{mono:el.A},Gemini:{mono:en.A,color:eo.A},GeminiCLI:{mono:ec.A,color:ei.A},GithubCopilot:{mono:ed.A},Google:{mono:em.A,color:ex.A},Grok:{mono:eu.A},Groq:{mono:ep.A},HuggingFace:{mono:eb.A,color:eh.A},Hyperbolic:{mono:eg.A,color:ef.A},IBM:{mono:ey.A},Inference:{mono:ej.A},Jina:{mono:ev.A},KiloCode:{mono:eN.A},Kimi:{mono:ew.A,color:ek.A},Lambda:{mono:eC.A},LmStudio:{mono:eS.A},Meta:{mono:eT.A,color:eA.A},MetaAI:{mono:eM.A,color:eI.A},Minimax:{mono:eR.A,color:eO.A},Mistral:{mono:eE.A,color:eL.A},Moonshot:{mono:e_.A},Morph:{mono:e$.A,color:eF.A},NanoBanana:{mono:eP.A,color:eD.A},Nebius:{mono:eK.A},NousResearch:{mono:ez.A},Novita:{mono:eB.A,color:eq.A},Nvidia:{mono:eW.A,color:eU.A},Ollama:{mono:eV.A},OpenAI:{mono:eG.A},OpenClaw:{mono:eJ.A,color:eH.A},OpenCode:{mono:eY.A},OpenRouter:{mono:eX.A},Perplexity:{mono:eQ.A,color:eZ.A},Poe:{mono:e1.A,color:e0.A},Qoder:{mono:e5.A,color:e2.A},Qwen:{mono:e4.A,color:e3.A},Recraft:{mono:e6.A},Replicate:{mono:e8.A},Runway:{mono:e9.A},SambaNova:{mono:te.A,color:e7.A},SearchApi:{mono:tt.A},SiliconCloud:{mono:ts.A,color:tr.A},Snowflake:{mono:tl.A,color:ta.A},Stability:{mono:tn.A,color:to.A},Tavily:{mono:tc.A,color:ti.A},Together:{mono:tx.A,color:td.A},TopazLabs:{mono:tm.A},Upstage:{mono:tp.A,color:tu.A},V0:{mono:th.A},Venice:{mono:tf.A,color:tb.A},Vercel:{mono:tg.A},VertexAI:{mono:tj.A,color:ty.A},Vllm:{mono:tN.A,color:tv.A},Volcengine:{mono:tw.A,color:tk.A},Voyage:{mono:tS.A,color:tC.A},WorkersAI:{mono:tT.A,color:tA.A},XAI:{mono:tI.A},XiaomiMiMo:{mono:tM.A},Xinference:{mono:tR.A,color:tO.A},ZAI:{mono:tL.A},Zhipu:{mono:t_.A,color:tE.A}},t$={ai21:"Ai21",alibaba:"Alibaba",alicode:"Alibaba","alicode-intl":"Alibaba","amazon-q":"Aws",anthropic:"Anthropic",antigravity:"Antigravity",assemblyai:"AssemblyAI","aws-polly":"Aws",azure:"Azure","azure-ai":"AzureAI","azure-openai":"AzureAI",baidu:"Baidu","bailian-coding-plan":"Bailian",baseten:"Baseten",bedrock:"Bedrock",bfl:"Bfl","black-forest-labs":"Bfl",cerebras:"Cerebras",claude:"ClaudeCode",cline:"Cline",cloudflare:"Cloudflare","cloudflare-ai":"WorkersAI",codestral:"Mistral",codex:"Codex",cohere:"Cohere",comfyui:"ComfyUI",copilot:"GithubCopilot",cursor:"Cursor",databricks:"Dbrx",deepinfra:"DeepInfra",deepseek:"DeepSeek",elevenlabs:"ElevenLabs",exa:"Exa","exa-search":"Exa",fal:"Fal","fal-ai":"Fal",featherless:"Featherless","featherless-ai":"Featherless",fireworks:"Fireworks","fireworks-ai":"Fireworks",friendli:"Friendli",friendliai:"Friendli",gemini:"Gemini","gemini-cli":"GeminiCLI",github:"GithubCopilot","github-copilot":"GithubCopilot",glm:"Zhipu","glm-cn":"Zhipu",glmt:"Zhipu","google-pse-search":"Google",grok:"Grok","grok-web":"Grok",groq:"Groq","hugging-face":"HuggingFace",huggingface:"HuggingFace",hyperbolic:"Hyperbolic",ibm:"IBM","inference-net":"Inference",jina:"Jina","jina-ai":"Jina",kilocode:"KiloCode",kimi:"Kimi","kimi-coding":"Kimi","kimi-coding-apikey":"Kimi",lambda:"Lambda","lambda-ai":"Lambda","lm-studio":"LmStudio",lmstudio:"LmStudio","meta-llama":"Meta",minimax:"Minimax","minimax-cn":"Minimax",mistral:"Mistral",mistralai:"Mistral",moonshot:"Moonshot",morph:"Morph","muse-spark-web":"MetaAI",nanobanana:"NanoBanana",nebius:"Nebius","nous-research":"NousResearch",nousresearch:"NousResearch",novita:"Novita",nvidia:"Nvidia",ollama:"Ollama","ollama-cloud":"Ollama",openai:"OpenAI",openclaw:"OpenClaw",opencode:"OpenCode","opencode-go":"OpenCode","opencode-zen":"OpenCode","open-router":"OpenRouter",openrouter:"OpenRouter",perplexity:"Perplexity","perplexity-search":"Perplexity","perplexity-web":"Perplexity",poe:"Poe",qoder:"Qoder",qwen:"Qwen",recraft:"Recraft",replicate:"Replicate",runwayml:"Runway",sambanova:"SambaNova",sdwebui:"Automatic",searchapi:"SearchApi","searchapi-search":"SearchApi",siliconflow:"SiliconCloud",snowflake:"Snowflake",stability:"Stability","stability-ai":"Stability",tavily:"Tavily","tavily-search":"Tavily",together:"Together",topaz:"TopazLabs",upstage:"Upstage",v0:"V0","v0-vercel":"V0",venice:"Venice","vercel-ai-gateway":"Vercel",vertex:"VertexAI","vertex-partner":"VertexAI",vertexai:"VertexAI",vllm:"Vllm",volcengine:"Volcengine",voyage:"Voyage","voyage-ai":"Voyage",watsonx:"IBM","workers-ai":"WorkersAI",workersai:"WorkersAI",xai:"XAI","xiaomi-mimo":"XiaomiMiMo",xiaomimimo:"XiaomiMiMo",xinference:"Xinference",zai:"ZAI",zhipu:"Zhipu"};function tD({size:e}){return(0,s.jsxs)("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",style:{flex:"none"},children:[(0,s.jsx)("circle",{cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"1.5",opacity:"0.4"}),(0,s.jsx)("path",{d:"M8 12h8M12 8v8",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})]})}let tP=new Set(["aimlapi","alibaba","alicode-intl","alicode","anthropic-m","anthropic","antigravity","bailian-coding-plan","blackbox","brave-search","brave","cerebras","claude","cline","codex","cohere","continue","copilot","cursor","deepgram","deepseek","droid","exa-search","fireworks","gemini-cli","gemini","github","glm","glmt","groq","ironclaw","kilo-gateway","kilocode","kimi-coding-apikey","kimi-coding","kimi","kiro","longcat","minimax-cn","minimax","mistral","nanobot","nebius","nvidia","oai-cc","oai-r","ollama-cloud","openai","openclaw","openrouter","perplexity-search","perplexity","pollinations","qwen","roo","serper-search","serper","siliconflow","tavily-search","tavily","together","xai","zeroclaw","aws-polly","blackbox-web","cliproxyapi","databricks","empower","gigachat","gitlab-duo","gitlab","heroku","linkup-search","llamagate","maritalk","modal","nanogpt","nscale","oci","ovhcloud","piapi","poe","predibase","qoder","recraft","reka","runwayml","triton","venice","voyage-ai","wandb","youcom-search"]),tK=new Set(["apikey","assemblyai","brave","cartesia","cloudflare-ai","comfyui","elevenlabs","exa-search","exa","huggingface","hyperbolic","inworld","nanobanana","oauth","opencode-go","opencode-zen","opencode","playht","puter","qianfan","scaleway","sdwebui","synthetic","vertex","windsurf","zai"]),tz=(0,a.memo)(function({providerId:e,size:t=24,type:r="color",className:o,style:n}){let i=e.toLowerCase(),c=function(e,t="color"){let r=t$[e.toLowerCase()];if(!r)return null;let s=tF[r];return"color"===t&&s.color?s.color:s.mono}(i,r),d=tP.has(i),x=tK.has(i),[m,u]=(0,a.useState)({}),p=`${i}:png`,h=`${i}:svg`,b=!c&&d&&!m[p],f=!c&&x&&!m[h]&&(!d||m[p]);return c?(0,s.jsx)("span",{className:o,style:{display:"inline-flex",alignItems:"center",...n},children:(0,a.createElement)(c,{"aria-label":e,size:t,style:{flex:"none"}})}):b?(0,s.jsx)("span",{className:o,style:{display:"inline-flex",alignItems:"center",...n},children:(0,s.jsx)(l.default,{src:`/providers/${i}.png`,alt:e,width:t,height:t,style:{objectFit:"contain"},onError:()=>{u(e=>({...e,[p]:!0}))},unoptimized:!0})}):f?(0,s.jsx)("span",{className:o,style:{display:"inline-flex",alignItems:"center",...n},children:(0,s.jsx)(l.default,{src:`/providers/${i}.svg`,alt:e,width:t,height:t,style:{objectFit:"contain"},onError:()=>u(e=>({...e,[h]:!0})),unoptimized:!0})}):(0,s.jsx)("span",{className:o,style:{display:"inline-flex",alignItems:"center",...n},children:(0,s.jsx)(tD,{size:t})})})},33637:(e,t,r)=>{r.d(t,{A:()=>o});var s=r(95155),a=r(14051),l=r.n(a);function o({size:e=20,className:t=""}){return(0,s.jsxs)("svg",{width:e,height:e,viewBox:"0 0 32 32",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:t,children:[(0,s.jsx)("circle",{cx:"16",cy:"16",r:"3",fill:"currentColor"}),(0,s.jsx)("circle",{cx:"8",cy:"8",r:"2",fill:"currentColor"}),(0,s.jsx)("circle",{cx:"24",cy:"8",r:"2",fill:"currentColor"}),(0,s.jsx)("circle",{cx:"8",cy:"24",r:"2",fill:"currentColor"}),(0,s.jsx)("circle",{cx:"24",cy:"24",r:"2",fill:"currentColor"}),(0,s.jsx)("circle",{cx:"16",cy:"5",r:"1.5",fill:"currentColor"}),(0,s.jsx)("circle",{cx:"16",cy:"27",r:"1.5",fill:"currentColor"}),(0,s.jsx)("line",{x1:"16",y1:"13",x2:"8",y2:"8",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round"}),(0,s.jsx)("line",{x1:"16",y1:"13",x2:"24",y2:"8",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round"}),(0,s.jsx)("line",{x1:"16",y1:"19",x2:"8",y2:"24",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round"}),(0,s.jsx)("line",{x1:"16",y1:"19",x2:"24",y2:"24",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round"}),(0,s.jsx)("line",{x1:"16",y1:"13",x2:"16",y2:"5",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round"}),(0,s.jsx)("line",{x1:"16",y1:"19",x2:"16",y2:"27",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round"})]})}o.propTypes={size:l().number,className:l().string}},33709:(e,t,r)=>{r.d(t,{default:()=>l});var s=r(95155),a=r(67040);function l({options:e=[],value:t,onChange:r,size:o="md",className:n,"aria-label":i}){let c={sm:"h-7 text-xs",md:"h-9 text-sm",lg:"h-11 text-base"};return(0,s.jsx)("div",{role:"tablist","aria-label":i,className:(0,a.cn)("inline-flex items-center p-1 rounded-lg","bg-black/5 dark:bg-white/5",n),children:e.map(e=>(0,s.jsxs)("button",{role:"tab","aria-selected":t===e.value,tabIndex:t===e.value?0:-1,onClick:()=>r(e.value),className:(0,a.cn)("px-4 rounded-md font-medium transition-all",c[o],t===e.value?"bg-white dark:bg-white/10 text-text-main shadow-sm":"text-text-muted hover:text-text-main"),children:[e.icon&&(0,s.jsx)("span",{className:"material-symbols-outlined text-[16px] mr-1.5","aria-hidden":"true",children:e.icon}),e.label]},e.value))})}},37415:(e,t,r)=>{r.d(t,{default:()=>b});var s=r(95155),a=r(12115),l=r(50910),o=r(81060),n=r(99333),i=r(8898);function c({title:e,json:t,onCopy:r}){let[l,o]=(0,a.useState)(!1),n=async()=>{!1!==await r()&&(o(!0),setTimeout(()=>o(!1),2e3))};return(0,s.jsxs)("div",{children:[(0,s.jsxs)("div",{className:"flex items-center justify-between mb-2",children:[(0,s.jsx)("h3",{className:"text-[11px] text-text-muted uppercase tracking-wider font-bold",children:e}),(0,s.jsxs)("button",{onClick:n,className:"flex items-center gap-1 px-2 py-1 text-xs text-text-muted hover:text-text-primary transition-colors","aria-label":`Copy ${e}`,children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:l?"check":"content_copy"}),l?"Copied!":"Copy"]})]}),(0,s.jsx)("pre",{className:"p-4 rounded-xl bg-black/5 dark:bg-black/30 border border-border overflow-x-auto text-xs font-mono text-text-main max-h-[600px] overflow-y-auto leading-relaxed whitespace-pre-wrap break-words",children:t})]})}function d({log:e,detail:t,loading:r,onClose:l,onCopy:o}){(0,a.useEffect)(()=>{let e=e=>{"Escape"===e.key&&l()};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[l]);let x=(0,n._Z)(e.status),m=e.sourceFormat||e.provider,u=(0,n.sE)(m,e.provider),p=n.RY[e.provider]||{bg:"#374151",text:"#fff",label:(e.provider||"-").toUpperCase()},h=e=>{if(null==e)return null;try{return JSON.stringify(e,null,2)}catch{return String(e)}},b=t?.pipelinePayloads||null,f=b?[["clientRawRequest","Client Raw Request"],["clientRequest","Client Request"],["openaiRequest","OpenAI Request"],["providerRequest","Provider Request"],["providerResponse","Provider Response"],["clientResponse","Client Response"],["error","Pipeline Error"]].map(([e,t])=>({key:e,title:t,json:h(b[e])})).filter(e=>e.json):[],g=t?.requestBody?h(t.requestBody):null,y=t?.responseBody?h(t.responseBody):null,j=t?.detailState==="missing"?"Detailed payload artifact is no longer available for this log entry.":t?.detailState==="corrupt"?"Detailed payload artifact could not be parsed.":null,v={totalIn:t?.tokens?.in??e.tokens?.in??0,totalOut:t?.tokens?.out??e.tokens?.out??0,cacheRead:t?.tokens?.cacheRead??e.tokens?.cacheRead,cacheWrite:t?.tokens?.cacheWrite??e.tokens?.cacheWrite,reasoning:t?.tokens?.reasoning??e.tokens?.reasoning},N=e=>null!=e?e.toLocaleString():"N/A",k=t?.cacheSource||e.cacheSource||"upstream";return(0,s.jsxs)("div",{className:"fixed inset-0 z-50 flex items-start justify-center pt-[5vh]",onClick:l,role:"dialog","aria-modal":"true","aria-label":"Request log detail",children:[(0,s.jsx)("div",{className:"absolute inset-0 bg-black/60 backdrop-blur-sm"}),(0,s.jsxs)("div",{className:"relative bg-bg-primary border border-border rounded-xl w-full max-w-[900px] max-h-[90vh] overflow-y-auto shadow-2xl",onClick:e=>e.stopPropagation(),children:[(0,s.jsxs)("div",{className:"sticky top-0 z-10 flex items-center justify-between px-6 py-4 border-b border-border bg-bg-primary/95 backdrop-blur-sm rounded-t-xl",children:[(0,s.jsxs)("div",{className:"flex items-center gap-3",children:[(0,s.jsx)("span",{className:"inline-block px-2.5 py-1 rounded text-xs font-bold",style:{backgroundColor:x.bg,color:x.text},children:e.status}),(0,s.jsx)("span",{className:"font-bold text-lg",children:e.method}),(0,s.jsx)("span",{className:"text-text-muted font-mono text-sm",children:e.path})]}),(0,s.jsx)("button",{onClick:l,className:"p-1.5 rounded-lg hover:bg-bg-subtle text-text-muted hover:text-text-primary transition-colors","aria-label":"Close detail modal",children:(0,s.jsx)("span",{className:"material-symbols-outlined",children:"close"})})]}),(0,s.jsxs)("div",{className:"p-6 flex flex-col gap-6",children:[(0,s.jsxs)("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4 p-4 bg-bg-subtle rounded-xl border border-border","data-testid":"request-log-metadata-grid",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("div",{className:"text-[10px] text-text-muted uppercase tracking-wider mb-1",children:"Completed Time"}),(0,s.jsx)("div",{className:"text-sm font-medium",children:(e=>{try{let t=new Date(e);return t.toLocaleDateString("pt-BR")+", "+t.toLocaleTimeString("en-US",{hour12:!1})}catch{return e}})(e.timestamp)})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("div",{className:"text-[10px] text-text-muted uppercase tracking-wider mb-1",children:"Duration"}),(0,s.jsx)("div",{className:"text-sm font-medium",children:(0,i.a3)(e.duration)})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("div",{className:"text-[10px] text-text-muted uppercase tracking-wider mb-1",children:"Input"}),(0,s.jsxs)("div",{className:"flex flex-wrap items-center gap-1.5","data-testid":"token-group-input",children:[(0,s.jsxs)("span",{className:"px-2 py-0.5 rounded bg-primary/20 text-primary text-xs font-bold",children:["Total In: ",v.totalIn.toLocaleString()]}),(0,s.jsxs)("span",{className:"px-2 py-0.5 rounded bg-sky-500/20 text-sky-700 dark:text-sky-400 text-xs font-bold",children:["Cache Read: ",N(v.cacheRead)]}),(0,s.jsxs)("span",{className:"px-2 py-0.5 rounded bg-amber-500/20 text-amber-700 dark:text-amber-400 text-xs font-bold",children:["Cache Write: ",N(v.cacheWrite)]})]})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("div",{className:"text-[10px] text-text-muted uppercase tracking-wider mb-1",children:"Output"}),(0,s.jsxs)("div",{className:"flex flex-wrap items-center gap-1.5","data-testid":"token-group-output",children:[(0,s.jsxs)("span",{className:"px-2 py-0.5 rounded bg-emerald-500/20 text-emerald-700 dark:text-emerald-400 text-xs font-bold",children:["Total Out: ",v.totalOut.toLocaleString()]}),(0,s.jsxs)("span",{className:"px-2 py-0.5 rounded bg-violet-500/20 text-violet-700 dark:text-violet-400 text-xs font-bold",children:["Reasoning: ",N(v.reasoning)]})]})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("div",{className:"text-[10px] text-text-muted uppercase tracking-wider mb-1",children:"Model"}),(0,s.jsx)("div",{className:"text-sm font-medium text-primary font-mono",children:e.model})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("div",{className:"text-[10px] text-text-muted uppercase tracking-wider mb-1",children:"Requested Model"}),(0,s.jsx)("div",{className:`text-sm font-medium font-mono ${(t?.requestedModel||e.requestedModel)&&(t?.requestedModel||e.requestedModel)!==e.model?"text-amber-600 dark:text-amber-400":"text-text-muted"}`,children:t?.requestedModel||e.requestedModel||"—"})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("div",{className:"text-[10px] text-text-muted uppercase tracking-wider mb-1",children:"Provider"}),(0,s.jsx)("span",{className:"inline-block px-2.5 py-1 rounded text-[10px] font-bold uppercase",style:{backgroundColor:p.bg,color:p.text},children:p.label})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("div",{className:"text-[10px] text-text-muted uppercase tracking-wider mb-1",children:"Req Protocol"}),(0,s.jsx)("span",{className:"inline-block px-2.5 py-1 rounded text-[10px] font-bold uppercase",style:{backgroundColor:u.bg,color:u.text},children:u.label})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("div",{className:"text-[10px] text-text-muted uppercase tracking-wider mb-1",children:"Cache Source"}),(0,s.jsx)("span",{className:`inline-block px-2.5 py-1 rounded text-[10px] font-bold border ${"semantic"===k?"bg-emerald-500/20 text-emerald-700 dark:text-emerald-300 border-emerald-500/30":"bg-sky-500/20 text-sky-700 dark:text-sky-300 border-sky-500/30"}`,children:"semantic"===k?"Semantic (OmniRoute)":"Upstream (Provider)"})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("div",{className:"text-[10px] text-text-muted uppercase tracking-wider mb-1",children:"Account"}),(0,s.jsx)("div",{className:"text-sm font-medium",children:t?.account||e.account||"-"})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("div",{className:"text-[10px] text-text-muted uppercase tracking-wider mb-1",children:"API Key"}),(0,s.jsx)("div",{className:"text-sm font-medium",title:t?.apiKeyName||t?.apiKeyId||e.apiKeyName||e.apiKeyId||"No API key",children:(0,i.VO)(t?.apiKeyName||e.apiKeyName,t?.apiKeyId||e.apiKeyId)})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("div",{className:"text-[10px] text-text-muted uppercase tracking-wider mb-1",children:"Combo"}),t?.comboName||e.comboName?(0,s.jsx)("span",{className:"inline-block px-2.5 py-1 rounded-full text-[10px] font-bold bg-violet-500/20 text-violet-700 dark:text-violet-300 border border-violet-500/30",children:t?.comboName||e.comboName}):(0,s.jsx)("div",{className:"text-sm text-text-muted",children:"—"})]})]}),(t?.error||e.error)&&(0,s.jsxs)("div",{className:"p-4 rounded-xl bg-red-500/10 border border-red-500/30",children:[(0,s.jsx)("div",{className:"text-[10px] text-red-600 dark:text-red-400 uppercase tracking-wider mb-1 font-bold",children:"Error"}),(0,s.jsx)("div",{className:"text-sm text-red-600 dark:text-red-300 font-mono",children:t?.error||e.error})]}),j&&(0,s.jsxs)("div",{className:"p-4 rounded-xl bg-amber-500/10 border border-amber-500/30",children:[(0,s.jsx)("div",{className:"text-[10px] text-amber-700 dark:text-amber-400 uppercase tracking-wider mb-1 font-bold",children:"Detail Status"}),(0,s.jsx)("div",{className:"text-sm text-amber-700 dark:text-amber-200",children:j})]}),r?(0,s.jsx)("div",{className:"p-8 text-center text-text-muted animate-pulse",children:"Loading request details..."}):(0,s.jsxs)(s.Fragment,{children:[f.length>0&&f.map(e=>(0,s.jsx)(c,{title:e.title,json:e.json,onCopy:()=>o(e.json)},e.key)),0===f.length&&y&&(0,s.jsx)(c,{title:"Response Payload (Legacy)",json:y,onCopy:()=>o(y)}),0===f.length&&g&&(0,s.jsx)(c,{title:"Request Payload (Legacy)",json:g,onCopy:()=>o(g)}),0===f.length&&!g&&!y&&!r&&(0,s.jsxs)("div",{className:"p-6 text-center text-text-muted",children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-[32px] mb-2 block opacity-40",children:"info"}),(0,s.jsx)("p",{className:"text-sm",children:"No payload data available for this log entry."}),(0,s.jsx)("p",{className:"text-xs mt-1",children:"Enable detailed logging first if you want the four-stage client/provider payload view for new requests."})]})]})]})]})]})}var x=r(32661),m=r(96914);function u(e,t){if(!e)return"-";if(e.startsWith("openai-compatible-")||e.startsWith("anthropic-compatible-")){if(t?.length){let r=t.find(t=>t.id===e||t.prefix===e);if(r?.name)return r.name}if(e.startsWith("openai-compatible-")){let t=e.replace("openai-compatible-",""),r=t.split("-");return r.length>1&&r[1]?.length>=8?"OAI-COMPAT":`OAI: ${t.slice(0,16).toUpperCase()}`}if(e.startsWith("anthropic-compatible-")){let t=e.replace("anthropic-compatible-",""),r=t.split("-");return r.length>1&&r[1]?.length>=8?"ANT-COMPAT":`ANT: ${t.slice(0,16).toUpperCase()}`}}return null}function p(e){return(e?.tokens?.in||0)+(e?.tokens?.out||0)}function h(e){let t=e?.tokens?.out||0,r=e?.duration||0;return t<=0||r<=0?0:t/(r/1e3)}function b(){let e=(0,l.c)("requestLogger"),{emailsVisible:t}=(0,m.A)(),r=(0,a.useMemo)(()=>[{key:"all",label:e("statusFilters.all"),icon:""},{key:"error",label:e("statusFilters.error"),icon:"error"},{key:"ok",label:e("statusFilters.success"),icon:"check_circle"},{key:"combo",label:e("statusFilters.combo"),icon:"hub"}],[e]),c=(0,a.useMemo)(()=>[{key:"status",label:e("columns.status")},{key:"cacheSource",label:e("columns.cacheSource")},{key:"model",label:e("columns.model")},{key:"requestedModel",label:e("columns.requested")},{key:"provider",label:e("columns.provider")},{key:"protocol",label:e("columns.protocol")},{key:"account",label:e("columns.account")},{key:"apiKey",label:e("columns.apiKey")},{key:"combo",label:e("columns.combo")},{key:"tokens",label:e("columns.tokens")},{key:"tps",label:e("columns.tps")},{key:"duration",label:e("columns.duration")},{key:"time",label:e("columns.time")}],[e]),[b,f]=(0,a.useState)([]),[g,y]=(0,a.useState)(!0),[j,v]=(0,a.useState)(!0),[N,k]=(0,a.useState)(""),[w,C]=(0,a.useState)("all"),[S,A]=(0,a.useState)(""),[T,I]=(0,a.useState)(""),[M,O]=(0,a.useState)(""),[R,L]=(0,a.useState)(""),[E,_]=(0,a.useState)("newest"),[F,$]=(0,a.useState)(null),[D,P]=(0,a.useState)(!1),[K,z]=(0,a.useState)(null),[q,B]=(0,a.useState)(!1),[U,W]=(0,a.useState)(!1),V=(0,a.useRef)(null),G=(0,a.useRef)(!1),H=(0,a.useRef)(""),[J,Y]=(0,a.useState)([]),[X,Z]=(0,a.useState)(()=>{let e=Object.fromEntries(c.map(e=>[e.key,!0]));try{let t=localStorage.getItem("loggerVisibleColumns");return t?{...e,...JSON.parse(t)}:e}catch{return e}}),Q=(0,a.useCallback)(e=>{Z(t=>{let r={...t,[e]:!t[e]};try{localStorage.setItem("loggerVisibleColumns",JSON.stringify(r))}catch{}return r})},[]),ee=(0,a.useCallback)(async(e=!1)=>{e&&y(!0);try{let e=new URLSearchParams;N&&e.set("search",N),"error"===w&&e.set("status","error"),"ok"===w&&e.set("status","ok"),"combo"===w&&e.set("combo","1"),S&&e.set("model",S),M&&e.set("provider",M),T&&e.set("account",T),R&&e.set("apiKey",R),e.set("limit","300");let t=await fetch(`/api/usage/call-logs?${e}`);if(t.ok){let e=await t.json(),r=JSON.stringify(e.map?.(e=>e.id)??[]);r!==H.current&&(H.current=r,f(e))}}catch(e){console.error("Failed to fetch call logs:",e)}finally{e&&y(!1)}},[N,w,S,T,M,R]);(0,a.useEffect)(()=>{let e=!G.current;G.current=!0,ee(e)},[ee]),(0,a.useEffect)(()=>{fetch("/api/provider-nodes").then(e=>e.ok?e.json():{nodes:[]}).then(e=>Y(e.nodes||[])).catch(()=>{})},[]),(0,a.useEffect)(()=>{fetch("/api/logs/detail?limit=1").then(async e=>e.ok?await e.json():null).then(e=>{e&&B(!0===e.enabled)}).catch(()=>{})},[]),(0,a.useEffect)(()=>(V.current&&clearInterval(V.current),j&&(V.current=setInterval(()=>ee(!1),3e3)),()=>{V.current&&clearInterval(V.current)}),[j,ee]);let et=(0,a.useMemo)(()=>"combo"===w?b.filter(e=>e.comboName):b,[w,b]),er=(0,a.useMemo)(()=>{let e=[...et];return e.sort((e,t)=>{switch(E){case"oldest":return new Date(e.timestamp).getTime()-new Date(t.timestamp).getTime();case"tokens_desc":return p(t)-p(e);case"tokens_asc":return p(e)-p(t);case"duration_desc":return(t.duration||0)-(e.duration||0);case"duration_asc":return(e.duration||0)-(t.duration||0);case"tps_desc":return h(t)-h(e);case"tps_asc":return h(e)-h(t);case"status_desc":return(t.status||0)-(e.status||0);case"status_asc":return(e.status||0)-(t.status||0);case"model_asc":return(e.model||"").localeCompare(t.model||"");case"model_desc":return(t.model||"").localeCompare(e.model||"");default:return new Date(t.timestamp).getTime()-new Date(e.timestamp).getTime()}}),e},[et,E]),es=async e=>{$(e),P(!0),z(null);try{let t=await fetch(`/api/usage/call-logs/${e.id}`);if(t.ok){let e=await t.json();z(e)}}catch(e){console.error("Failed to fetch log detail:",e)}finally{P(!1)}},ea=async()=>{W(!0);try{let e=!q;if(!(await fetch("/api/logs/detail",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({enabled:e})})).ok)throw Error("Failed to update pipeline logging");B(e)}catch(e){console.error("Failed to toggle pipeline logging:",e)}finally{W(!1)}},el=[...new Set(b.map(e=>e.account).filter(e=>e&&"-"!==e))],eo=[...new Set(b.flatMap(e=>[e.model,e.requestedModel]).filter(e=>!!e))].sort(),en=[...new Set(b.map(e=>e.provider).filter(e=>e&&"-"!==e))].sort(),ei=[...new Set(b.map(e=>e.apiKeyId||e.apiKeyName).filter(Boolean))].sort(),ec=et.length,ed=et.filter(e=>e.status>=200&&e.status<300).length,ex=et.filter(e=>e.status>=400).length,em=b.filter(e=>e.comboName).length,eu=ei.length;return(0,s.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,s.jsxs)("div",{className:"flex flex-wrap items-center gap-3",children:[(0,s.jsxs)("button",{onClick:()=>v(!j),className:`flex items-center gap-2 px-3 py-1.5 rounded-full text-sm font-medium border transition-colors ${j?"bg-red-500/10 border-red-500/30 text-red-700 dark:text-red-400":"bg-bg-subtle border-border text-text-muted"}`,children:[(0,s.jsx)("span",{className:`w-2 h-2 rounded-full ${j?"bg-red-500 animate-pulse":"bg-text-muted"}`}),j?e("recording"):e("paused")]}),(0,s.jsxs)("button",{onClick:ea,disabled:U,className:`flex items-center gap-2 px-3 py-1.5 rounded-full text-sm font-medium border transition-colors disabled:opacity-60 ${q?"bg-amber-500/10 border-amber-500/30 text-amber-700 dark:text-amber-300":"bg-bg-subtle border-border text-text-muted"}`,title:"Capture pipeline payloads for new requests",children:[(0,s.jsx)("span",{className:`w-2 h-2 rounded-full ${q?"bg-amber-500":"bg-text-muted"}`}),U?e("updatingPipelineLogs"):q?e("pipelineLogsOn"):e("pipelineLogsOff")]}),(0,s.jsxs)("div",{className:"flex-1 min-w-[200px] relative",children:[(0,s.jsx)("span",{className:"material-symbols-outlined absolute left-3 top-1/2 -translate-y-1/2 text-text-muted text-[18px]",children:"search"}),(0,s.jsx)("input",{type:"text",placeholder:e("searchPlaceholder"),value:N,onChange:e=>k(e.target.value),className:"w-full pl-10 pr-4 py-2 rounded-lg bg-bg-subtle border border-border text-sm text-text-primary placeholder:text-text-muted focus:outline-none focus:border-primary"})]}),(0,s.jsxs)("select",{value:M,onChange:e=>O(e.target.value),className:"px-3 py-2 rounded-lg bg-bg-subtle border border-border text-sm text-text-primary focus:outline-none focus:border-primary appearance-none cursor-pointer min-w-[140px]",children:[(0,s.jsx)("option",{value:"",children:e("allProviders")}),en.map(e=>{let t=u(e,J),r=n.RY[e];return(0,s.jsx)("option",{value:e,children:t||r?.label||e.toUpperCase()},e)})]}),(0,s.jsxs)("select",{value:S,onChange:e=>A(e.target.value),className:"px-3 py-2 rounded-lg bg-bg-subtle border border-border text-sm text-text-primary focus:outline-none focus:border-primary appearance-none cursor-pointer min-w-[180px]",children:[(0,s.jsx)("option",{value:"",children:e("allModels")}),eo.map(e=>(0,s.jsx)("option",{value:e,children:e},e))]}),(0,s.jsxs)("select",{value:T,onChange:e=>I(e.target.value),className:"px-3 py-2 rounded-lg bg-bg-subtle border border-border text-sm text-text-primary focus:outline-none focus:border-primary appearance-none cursor-pointer min-w-[140px]",children:[(0,s.jsx)("option",{value:"",children:e("allAccounts")}),el.map(e=>(0,s.jsx)("option",{value:e,children:e},e))]}),(0,s.jsxs)("select",{value:R,onChange:e=>L(e.target.value),className:"px-3 py-2 rounded-lg bg-bg-subtle border border-border text-sm text-text-primary focus:outline-none focus:border-primary appearance-none cursor-pointer min-w-[160px]",children:[(0,s.jsx)("option",{value:"",children:e("allApiKeys")}),ei.map(e=>{let t=b.find(t=>(t.apiKeyId||t.apiKeyName)===e),r=(0,i.VO)(t?.apiKeyName,t?.apiKeyId);return(0,s.jsx)("option",{value:e,children:r},e)})]}),(0,s.jsxs)("div",{className:"flex items-center gap-2 text-xs text-text-muted",children:[(0,s.jsxs)("span",{className:"px-2 py-1 rounded bg-bg-subtle border border-border font-mono",children:[ec," ",e("total")]}),(0,s.jsxs)("span",{className:"px-2 py-1 rounded bg-emerald-500/10 text-emerald-700 dark:text-emerald-400 font-mono",children:[ed," ",e("ok")]}),ex>0&&(0,s.jsxs)("span",{className:"px-2 py-1 rounded bg-red-500/10 text-red-700 dark:text-red-400 font-mono",children:[ex," ",e("err")]}),em>0&&(0,s.jsxs)("span",{className:"px-2 py-1 rounded bg-violet-500/10 text-violet-700 dark:text-violet-400 font-mono",children:[em," ",e("combo")]}),eu>0&&(0,s.jsxs)("span",{className:"px-2 py-1 rounded bg-primary/10 text-primary font-mono",children:[eu," ",e("keys")]}),(0,s.jsxs)("span",{className:"px-2 py-1 rounded bg-bg-subtle border border-border font-mono",children:[er.length," ",e("shown")]})]}),(0,s.jsxs)("select",{value:E,onChange:e=>_(e.target.value),className:"px-3 py-2 rounded-lg bg-bg-subtle border border-border text-sm text-text-primary focus:outline-none focus:border-primary appearance-none cursor-pointer min-w-[150px]",title:"Sort logs",children:[(0,s.jsx)("option",{value:"newest",children:e("sortNewest")}),(0,s.jsx)("option",{value:"oldest",children:e("sortOldest")}),(0,s.jsx)("option",{value:"tokens_desc",children:e("sortTokensDesc")}),(0,s.jsx)("option",{value:"tokens_asc",children:e("sortTokensAsc")}),(0,s.jsx)("option",{value:"duration_desc",children:e("sortDurationDesc")}),(0,s.jsx)("option",{value:"duration_asc",children:e("sortDurationAsc")}),(0,s.jsx)("option",{value:"status_desc",children:e("sortStatusDesc")}),(0,s.jsx)("option",{value:"status_asc",children:e("sortStatusAsc")}),(0,s.jsx)("option",{value:"model_asc",children:e("sortModelAsc")}),(0,s.jsx)("option",{value:"model_desc",children:e("sortModelDesc")})]}),(0,s.jsx)("button",{onClick:()=>ee(!1),className:"p-2 rounded-lg hover:bg-bg-subtle text-text-muted hover:text-text-primary transition-colors",title:"Refresh",children:(0,s.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:"refresh"})})]}),(0,s.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[r.map(e=>(0,s.jsxs)("button",{onClick:()=>C(w===e.key?"all":e.key),className:`flex items-center gap-1.5 px-3 py-1 rounded-full text-xs font-medium border transition-all ${w===e.key?"error"===e.key?"bg-red-500/20 text-red-700 dark:text-red-400 border-red-500/40":"ok"===e.key?"bg-emerald-500/20 text-emerald-700 dark:text-emerald-400 border-emerald-500/40":"combo"===e.key?"bg-violet-500/20 text-violet-700 dark:text-violet-300 border-violet-500/40":"bg-primary text-white border-primary":"bg-bg-subtle border-border text-text-muted hover:border-text-muted"}`,children:[e.icon&&(0,s.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:e.icon}),e.label]},e.key)),en.length>0&&(0,s.jsx)("span",{className:"w-px h-5 bg-border mx-1"}),en.map(e=>{let t=u(e,J),r=n.RY[e]||{bg:"#374151",text:"#fff",label:t||e.toUpperCase()},a=t||r.label,l=M===e;return(0,s.jsx)("button",{onClick:()=>O(l?"":e),className:`px-3 py-1 rounded-full text-xs font-bold uppercase border transition-all ${l?"border-white/40 ring-1 ring-white/20":"border-transparent opacity-70 hover:opacity-100"}`,style:{backgroundColor:l?r.bg:`${r.bg}33`,color:l?r.text:r.bg},children:a},e)})]}),(0,s.jsxs)("div",{className:"flex flex-wrap items-center gap-1.5",children:[(0,s.jsx)("span",{className:"text-[10px] text-text-muted uppercase tracking-wider mr-1",children:"Columns"}),c.map(e=>(0,s.jsx)("button",{onClick:()=>Q(e.key),className:`px-2 py-0.5 rounded text-[10px] font-medium border transition-all ${X[e.key]?"bg-primary/15 text-primary border-primary/30":"bg-bg-subtle text-text-muted border-border opacity-50 hover:opacity-80"}`,children:e.label},e.key))]}),(0,s.jsx)(o.default,{className:"overflow-hidden bg-black/5 dark:bg-black/20",children:(0,s.jsx)("div",{className:"p-0 overflow-x-auto max-h-[calc(100vh-320px)] overflow-y-auto",children:g&&0===b.length?(0,s.jsx)("div",{className:"p-8 text-center text-text-muted",children:e("loadingLogs")}):0===b.length?(0,s.jsxs)("div",{className:"p-8 text-center text-text-muted",children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-[48px] mb-2 block opacity-40",children:"receipt_long"}),e("noLogs")]}):0===er.length?(0,s.jsx)("div",{className:"p-8 text-center text-text-muted",children:e("noMatchingLogs")}):(0,s.jsxs)("table",{className:"w-full text-left border-collapse text-xs",children:[(0,s.jsx)("thead",{className:"sticky top-0 z-10",style:{backgroundColor:"var(--color-bg, #fff)"},children:(0,s.jsxs)("tr",{className:"border-b border-border",style:{backgroundColor:"var(--color-bg, #fff)"},children:[X.status&&(0,s.jsx)("th",{className:"px-3 py-2.5 font-semibold text-text-muted uppercase tracking-wider text-[10px]",children:e("columns.status")}),X.cacheSource&&(0,s.jsx)("th",{className:"px-3 py-2.5 font-semibold text-text-muted uppercase tracking-wider text-[10px]",children:e("columns.cacheSource")}),X.model&&(0,s.jsx)("th",{className:"px-3 py-2.5 font-semibold text-text-muted uppercase tracking-wider text-[10px]",children:e("columns.model")}),X.requestedModel&&(0,s.jsx)("th",{className:"px-3 py-2.5 font-semibold text-text-muted uppercase tracking-wider text-[10px]",children:e("columns.requested")}),X.provider&&(0,s.jsx)("th",{className:"px-3 py-2.5 font-semibold text-text-muted uppercase tracking-wider text-[10px]",children:e("columns.provider")}),X.protocol&&(0,s.jsx)("th",{className:"px-3 py-2.5 font-semibold text-text-muted uppercase tracking-wider text-[10px]",children:e("columns.protocol")}),X.account&&(0,s.jsx)("th",{className:"px-3 py-2.5 font-semibold text-text-muted uppercase tracking-wider text-[10px]",children:e("columns.account")}),X.apiKey&&(0,s.jsx)("th",{className:"px-3 py-2.5 font-semibold text-text-muted uppercase tracking-wider text-[10px]",children:e("columns.apiKey")}),X.combo&&(0,s.jsx)("th",{className:"px-3 py-2.5 font-semibold text-text-muted uppercase tracking-wider text-[10px]",children:e("columns.combo")}),X.tokens&&(0,s.jsx)("th",{className:"px-3 py-2.5 font-semibold text-text-muted uppercase tracking-wider text-[10px] text-right",children:e("columns.tokens")}),X.tps&&(0,s.jsx)("th",{className:"px-3 py-2.5 font-semibold text-text-muted uppercase tracking-wider text-[10px] text-right",children:e("columns.tps")}),X.duration&&(0,s.jsx)("th",{className:"px-3 py-2.5 font-semibold text-text-muted uppercase tracking-wider text-[10px] text-right",children:e("columns.duration")}),X.time&&(0,s.jsx)("th",{className:"px-3 py-2.5 font-semibold text-text-muted uppercase tracking-wider text-[10px] text-right",children:e("columns.time")})]})}),(0,s.jsx)("tbody",{className:"divide-y divide-border/30",children:er.map(e=>{let r,a,l=(0,n._Z)(e.status),o=e.sourceFormat||e.provider,c=(0,n.sE)(o,e.provider),d=u(e.provider,J),x=n.RY[e.provider]||{bg:"#374151",text:"#fff",label:d||(e.provider||"-").toUpperCase()},m=d||x.label,p=e.status>=400,b="semantic"===e.cacheSource?{label:"SEM",title:"Semantic cache hit (served by OmniRoute)",className:"bg-emerald-500/15 text-emerald-700 dark:text-emerald-300 border border-emerald-500/30"}:{label:"UP",title:"Upstream provider response",className:"bg-sky-500/15 text-sky-700 dark:text-sky-300 border border-sky-500/30"};return(0,s.jsxs)("tr",{onClick:()=>es(e),className:`cursor-pointer hover:bg-primary/5 transition-colors ${p?"bg-red-500/5":""}`,children:[X.status&&(0,s.jsx)("td",{className:"px-3 py-2",children:(0,s.jsx)("span",{className:"inline-block px-2 py-0.5 rounded text-[10px] font-bold min-w-[36px] text-center",style:{backgroundColor:l.bg,color:l.text},children:e.status||"..."})}),X.cacheSource&&(0,s.jsx)("td",{className:"px-3 py-2",children:(0,s.jsx)("span",{className:`inline-block px-2 py-0.5 rounded text-[9px] font-bold uppercase ${b.className}`,title:b.title,children:"SEM"===b.label?"Semantic":"Upstream"})}),X.model&&(0,s.jsx)("td",{className:"px-3 py-2 font-medium text-primary font-mono text-[11px]",children:e.model}),X.requestedModel&&(0,s.jsx)("td",{className:"px-3 py-2 font-mono text-[11px]",children:e.requestedModel?(0,s.jsx)("span",{className:e.requestedModel!==e.model?"text-amber-600 dark:text-amber-400":"text-text-muted",title:e.requestedModel!==e.model?`Requested ${e.requestedModel}, routed as ${e.model}`:e.requestedModel,children:e.requestedModel}):(0,s.jsx)("span",{className:"text-text-muted text-[10px]",children:"—"})}),X.provider&&(0,s.jsx)("td",{className:"px-3 py-2",children:(0,s.jsx)("span",{className:"inline-block px-2 py-0.5 rounded text-[9px] font-bold uppercase",style:{backgroundColor:x.bg,color:x.text},children:m})}),X.protocol&&(0,s.jsx)("td",{className:"px-3 py-2",children:(0,s.jsx)("span",{className:"inline-block px-2 py-0.5 rounded text-[9px] font-bold uppercase",style:{backgroundColor:c.bg,color:c.text},children:c.label})}),X.account&&(0,s.jsx)("td",{className:"px-3 py-2 text-text-muted truncate max-w-[120px]",title:e.account,children:(0,i.Ib)(e.account,t)}),X.apiKey&&(0,s.jsx)("td",{className:"px-3 py-2 text-text-muted truncate max-w-[140px]",title:e.apiKeyName||e.apiKeyId||"No API key",children:(0,i.VO)(e.apiKeyName,e.apiKeyId)}),X.combo&&(0,s.jsx)("td",{className:"px-3 py-2",children:e.comboName?(0,s.jsx)("span",{className:"inline-block px-2 py-0.5 rounded-full text-[9px] font-bold bg-violet-500/20 text-violet-800 dark:text-violet-300 border border-violet-500/40",children:e.comboName}):(0,s.jsx)("span",{className:"text-text-muted text-[10px]",children:"—"})}),X.tokens&&(0,s.jsxs)("td",{className:"px-3 py-2 text-right whitespace-nowrap",children:[(0,s.jsx)("span",{className:"text-text-muted",children:"TI:"})," ",(0,s.jsx)("span",{className:"text-primary",children:e.tokens?.in?.toLocaleString()||0}),(0,s.jsx)("span",{className:"mx-1 text-border",children:"|"}),(0,s.jsx)("span",{className:"text-text-muted",children:"TO:"})," ",(0,s.jsx)("span",{className:"text-emerald-700 dark:text-emerald-400",children:e.tokens?.out?.toLocaleString()||0})]}),X.tps&&(0,s.jsx)("td",{className:"px-3 py-2 text-right whitespace-nowrap font-mono",children:(a=(r=h(e))<=0?"text-text-muted":r>=80?"text-emerald-600 dark:text-emerald-400":r>=30?"text-sky-600 dark:text-sky-400":"text-amber-600 dark:text-amber-400",(0,s.jsx)("span",{className:a,title:`${r.toFixed(2)} tokens/sec`,children:r<=0?"—":r>=100?Math.round(r).toLocaleString():r.toFixed(1)}))}),X.duration&&(0,s.jsx)("td",{className:"px-3 py-2 text-right text-text-muted font-mono",children:(0,i.a3)(e.duration)}),X.time&&(0,s.jsx)("td",{className:"px-3 py-2 text-right text-text-muted",children:(0,i.fU)(e.timestamp)})]},e.id)})})]})})}),(0,s.jsx)("div",{className:"text-[10px] text-text-muted italic",children:e("callLogsInfo",{dataDir:"{DATA_DIR}/call_logs/",retentionDays:"CALL_LOG_RETENTION_DAYS",maxEntries:"CALL_LOG_MAX_ENTRIES"})}),F&&(0,s.jsx)(d,{log:F,detail:K,loading:D,onClose:()=>{$(null),z(null)},onCopy:x.l})]})}},42912:(e,t,r)=>{r.d(t,{default:()=>j});var s=r(95155),a=r(12115),l=r(14051),o=r.n(l),n=r(98500),i=r.n(n),c=r(73321),d=r(67040),x=r(49007),m=r(33637),u=r(35806),p=r(71361);let h={connected:{icon:"cloud_done",color:"text-green-500",label:"Cloud"},syncing:{icon:"cloud_sync",color:"text-blue-400 animate-pulse",label:"Syncing..."},disconnected:{icon:"cloud_off",color:"text-amber-500",label:"Cloud Off"},error:{icon:"cloud_off",color:"text-red-400",label:"Cloud Error"},disabled:{icon:"cloud_off",color:"text-text-muted/50",label:"Disabled"}};function b({collapsed:e=!1}){let[t,r]=(0,a.useState)("disabled"),[l,o]=(0,a.useState)(null),n=(0,a.useRef)(!0),i=(0,c.useRouter)(),d=(0,a.useCallback)(async()=>{try{let e=await fetch("/api/sync/cloud");if(!n.current)return;if(!e.ok)return void r("disconnected");let t=await e.json();if(!n.current)return;t.enabled?t.syncing?r("syncing"):t.connected?(r("connected"),t.lastSync&&o(new Date(t.lastSync))):r("disconnected"):r("disabled")}catch{n.current&&r("disconnected")}},[]);if((0,a.useEffect)(()=>{n.current=!0,queueMicrotask(d);let e=setInterval(d,3e4),t=()=>{setTimeout(d,500)};return globalThis.addEventListener("cloud-status-changed",t),()=>{n.current=!1,clearInterval(e),globalThis.removeEventListener("cloud-status-changed",t)}},[d]),"disabled"===t)return null;let x=h[t];return(0,s.jsxs)("button",{onClick:()=>i.push("/dashboard/endpoint"),className:"flex items-center gap-2 px-3 py-1.5 text-xs rounded-lg hover:bg-white/5 transition-colors cursor-pointer w-full",title:l?`Cloud ${"connected"===t?"connected":"disconnected"} — Last sync: ${l.toLocaleTimeString()}`:x.label,"aria-label":`Cloud sync status: ${x.label}`,children:[(0,s.jsx)("span",{className:`material-symbols-outlined text-[16px] ${x.color}`,"aria-hidden":"true",children:x.icon}),!e&&(0,s.jsx)("span",{className:`truncate ${"connected"===t?"text-green-500":"text-text-muted"}`,children:x.label})]})}var f=r(50910),g=r(15559);let y="1"===r(41463).env.NEXT_PUBLIC_OMNIROUTE_E2E_MODE;function j({onClose:e,collapsed:t=!1,onToggleCollapse:r,isMacElectron:l=!1}){let o=(0,c.usePathname)(),n=(0,f.c)("sidebar"),h=(0,f.c)("common"),[v,N]=(0,a.useState)(!1),[k,w]=(0,a.useState)(!1),[C,S]=(0,a.useState)(!1),[A,T]=(0,a.useState)(!1),[I,M]=(0,a.useState)(!1),[O,R]=(0,a.useState)(!1),[L,E]=(0,a.useState)([]),[_,F]=(0,a.useState)(null),[$,D]=(0,a.useState)(null);(0,a.useEffect)(()=>{fetch("/api/settings").then(e=>e.json()).then(e=>{R(e?.debugMode===!0),E((0,g.ii)(e?.[g.ad])),F(e?.instanceName||null),D(e?.customLogoBase64||e?.customLogoUrl||null)}).catch(()=>{});let e=e=>{let t=e.detail||{};"debugMode"in t&&R(!0===t.debugMode),g.ad in t&&E((0,g.ii)(t[g.ad])),"instanceName"in t&&F(t.instanceName||null),"customLogoBase64"in t?D(t.customLogoBase64||null):"customLogoUrl"in t&&D(t.customLogoUrl||null)};return window.addEventListener(g.uj,e),()=>{window.removeEventListener(g.uj,e)}},[]);let P=async()=>{S(!0);try{await fetch("/api/shutdown",{method:"POST"})}catch(e){}S(!1),N(!1),M(!0)},K=async()=>{T(!0);try{await fetch("/api/restart",{method:"POST"})}catch(e){}T(!1),w(!1),M(!0),setTimeout(()=>{globalThis.location.reload()},3e3)},z=new Set(L),q=g.Ke.filter(e=>"debug"!==e.visibility||O).map(e=>{let t,r;return{...e,title:(t=e.titleKey,r=e.titleFallback,"function"==typeof n.has&&n.has(t)?n(t):r),items:e.items.map(e=>({...e,label:n(e.i18nKey)})).filter(e=>!z.has(e.id))}}).filter(e=>e.items.length>0),B=function(e,t){let r=null;for(let s of t)if(!s.external&&function(e,t,r=!1){return!!e&&(r?e===t:e===t||e.startsWith(`${t}/`))}(e,s.href,!0===s.exact)){if(!r||s.href.length>r.href.length){r=s;continue}s.href.length===r.href.length&&s.exact&&!r.exact&&(r=s)}return r?.href||null}(o,q.flatMap(e=>e.items)),U=r=>{let a=!r.external&&B===r.href,l=(0,d.cn)("flex items-center gap-3 rounded-lg transition-all group",t?"justify-center px-2 py-2.5":"px-4 py-2",a?"bg-primary/10 text-primary":"text-text-muted hover:bg-surface/50 hover:text-text-main"),o=(0,d.cn)("material-symbols-outlined text-[18px]",a?"fill-1":"group-hover:text-primary transition-colors"),n=(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("span",{className:o,children:r.icon}),!t&&(0,s.jsx)("span",{className:"text-sm font-medium",children:r.label})]});return r.external?(0,s.jsx)("a",{href:r.href,target:"_blank",rel:"noopener noreferrer",onClick:e,title:t?r.label:void 0,className:l,children:n},r.href):(0,s.jsx)(i(),{href:r.href,onClick:e,title:t?r.label:void 0,className:l,children:n},r.href)};return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("aside",{className:(0,d.cn)("flex h-full min-h-0 flex-col border-r border-black/5 bg-sidebar transition-all duration-300 ease-in-out dark:border-white/5",t?"w-16":"w-80"),style:{paddingTop:l?"var(--desktop-safe-top)":void 0},children:[(0,s.jsx)("a",{href:"#main-content",className:"sr-only focus:not-sr-only focus:absolute focus:z-50 focus:p-3 focus:bg-primary focus:text-white focus:rounded-md focus:m-2",children:"Skip to content"}),(r||!l)&&(0,s.jsxs)("div",{className:(0,d.cn)("flex items-center gap-2 pb-2",l?"pt-3":"pt-5",t?"px-3 justify-center":"px-6"),"aria-hidden":"true",children:[!l&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("div",{className:"w-3 h-3 rounded-full bg-[#FF5F56]"}),(0,s.jsx)("div",{className:"w-3 h-3 rounded-full bg-[#FFBD2E]"}),(0,s.jsx)("div",{className:"w-3 h-3 rounded-full bg-[#27C93F]"})]}),!t&&(0,s.jsx)("div",{className:"flex-1"}),r&&(0,s.jsx)("button",{onClick:r,title:t?"Expand sidebar":"Collapse sidebar","aria-expanded":!t,"aria-label":t?"Expand sidebar":"Collapse sidebar",className:(0,d.cn)("rounded-md p-1 text-text-muted/50 transition-colors hover:bg-black/5 hover:text-text-muted dark:hover:bg-white/5",t&&!l&&"mt-2",l&&"ml-auto"),children:(0,s.jsx)("span",{className:"material-symbols-outlined text-[16px]","aria-hidden":"true",children:t?"chevron_right":"chevron_left"})})]}),(0,s.jsx)("div",{className:(0,d.cn)("py-4",t?"px-2":"px-6"),children:(0,s.jsxs)(i(),{href:"/dashboard",className:(0,d.cn)("flex items-center",t?"justify-center":"gap-3"),children:[(0,s.jsx)("div",{className:"flex items-center justify-center size-9 rounded bg-linear-to-br from-[#E54D5E] to-[#C93D4E] shrink-0",children:$?(0,s.jsx)("img",{src:$,alt:_||x.v.name,className:"size-5 object-contain"}):(0,s.jsx)(m.A,{size:20,className:"text-white"})}),!t&&(0,s.jsxs)("div",{className:"flex flex-col",children:[(0,s.jsx)("h1",{className:"text-lg font-semibold tracking-tight text-text-main",children:_||x.v.name}),(0,s.jsxs)("span",{className:"text-xs text-text-muted",children:["v",x.v.version]})]})]})}),(0,s.jsx)("nav",{"aria-label":"Main navigation",className:(0,d.cn)("min-h-0 flex-1 space-y-1 overflow-y-auto py-2 custom-scrollbar",t?"px-2":"px-4"),children:q.map(e=>{let r=!1!==e.showTitleInSidebar;return(0,s.jsxs)("div",{className:r?"pt-4 mt-2":void 0,children:[!t&&r&&(0,s.jsx)("p",{className:"px-4 text-xs font-semibold text-text-muted/60 uppercase tracking-wider mb-2",children:e.title}),t&&r&&(0,s.jsx)("div",{className:"border-t border-black/5 dark:border-white/5 mb-2"}),e.items.map(U)]},e.id)})}),!y&&(0,s.jsx)(b,{collapsed:t}),(0,s.jsxs)("div",{className:(0,d.cn)("shrink-0 border-t border-black/5 dark:border-white/5",t?"p-2 flex flex-col gap-1":"p-3 flex gap-2"),style:{paddingBottom:l?"calc(0.75rem + var(--desktop-safe-bottom))":void 0},children:[(0,s.jsxs)("button",{onClick:()=>w(!0),title:n("restart"),className:(0,d.cn)("flex items-center justify-center gap-2 rounded-lg font-medium transition-all","text-amber-500 hover:bg-amber-500/10 border border-amber-500/20 hover:border-amber-500/40",t?"p-2":"flex-1 min-w-0 px-3 py-2 text-xs"),children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:"restart_alt"}),!t&&n("restart")]}),(0,s.jsxs)("button",{onClick:()=>N(!0),title:n("shutdown"),className:(0,d.cn)("flex items-center justify-center gap-2 rounded-lg font-medium transition-all","text-red-500 hover:bg-red-500/10 border border-red-500/20 hover:border-red-500/40",t?"p-2":"flex-1 min-w-0 px-3 py-2 text-xs"),children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:"power_settings_new"}),!t&&n("shutdown")]})]})]}),(0,s.jsx)(p.ConfirmModal,{isOpen:v,onClose:()=>N(!1),onConfirm:P,title:n("shutdown"),message:n("shutdownConfirm"),confirmText:n("shutdown"),cancelText:h("cancel"),variant:"danger",loading:C}),(0,s.jsx)(p.ConfirmModal,{isOpen:k,onClose:()=>w(!1),onConfirm:K,title:n("restart"),message:n("restartConfirm"),confirmText:n("restart"),cancelText:h("cancel"),variant:"warning",loading:A}),I&&(0,s.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/80 backdrop-blur-sm",children:(0,s.jsxs)("div",{className:"text-center p-8",children:[(0,s.jsx)("div",{className:"flex items-center justify-center size-16 rounded-full bg-red-500/20 text-red-500 mx-auto mb-4",children:(0,s.jsx)("span",{className:"material-symbols-outlined text-[32px]",children:"power_off"})}),(0,s.jsx)("h2",{className:"text-xl font-semibold text-white mb-2",children:"Server Disconnected"}),(0,s.jsx)("p",{className:"text-text-muted mb-6",children:"The proxy server has been stopped or is restarting."}),(0,s.jsx)(u.default,{variant:"secondary",onClick:()=>globalThis.location.reload(),children:"Reload Page"})]})})]})}j.propTypes={onClose:o().func,collapsed:o().bool,onToggleCollapse:o().func,isMacElectron:o().bool}},42994:(e,t,r)=>{r.d(t,{default:()=>o});var s=r(95155),a=r(12115),l=r(67040);function o({label:e,options:t=[],value:r,onChange:n,placeholder:i="Select an option",error:c,hint:d,disabled:x=!1,required:m=!1,className:u,selectClassName:p,id:h,...b}){let f=(0,a.useId)(),g=h||f,y=c?`${g}-error`:void 0,j=d&&!c?`${g}-hint`:void 0,v=[y,j].filter(Boolean).join(" ")||void 0;return(0,s.jsxs)("div",{className:(0,l.cn)("flex flex-col gap-1.5",u),children:[e&&(0,s.jsxs)("label",{htmlFor:g,className:"text-sm font-medium text-text-main",children:[e,m&&(0,s.jsx)("span",{className:"text-red-500 ml-1","aria-hidden":"true",children:"*"})]}),(0,s.jsxs)("div",{className:"relative",children:[(0,s.jsxs)("select",{id:g,value:r,onChange:n,disabled:x,required:m,"aria-required":m||void 0,"aria-invalid":!!c||void 0,"aria-describedby":v,className:(0,l.cn)("w-full py-2 px-3 pr-10 text-sm text-text-main","bg-surface border border-black/10 dark:border-white/10 rounded-md appearance-none","focus:ring-1 focus:ring-primary/30 focus:border-primary/50 focus:outline-none","transition-all disabled:opacity-50 disabled:cursor-not-allowed","text-[16px] sm:text-sm",c?"border-red-500 focus:border-red-500 focus:ring-red-500/20":"",p),...b,children:[(0,s.jsx)("option",{value:"",disabled:!0,className:"bg-surface text-text-muted",children:i}),t.map(e=>(0,s.jsx)("option",{value:e.value,className:"bg-surface text-text-main",children:e.label},e.value))]}),(0,s.jsx)("div",{className:"absolute inset-y-0 right-0 flex items-center pr-3 pointer-events-none text-text-muted","aria-hidden":"true",children:(0,s.jsx)("span",{className:"material-symbols-outlined text-[20px]",children:"expand_more"})})]}),c&&(0,s.jsxs)("p",{id:y,className:"text-xs text-red-500 flex items-center gap-1",role:"alert",children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-[14px]","aria-hidden":"true",children:"error"}),c]}),d&&!c&&(0,s.jsx)("p",{id:j,className:"text-xs text-text-muted",children:d})]})}},44638:(e,t,r)=>{r.d(t,{default:()=>l});var s=r(95155),a=r(50910);function l({columns:e=[],data:t=[],renderCell:r,renderHeader:o,onRowClick:n,selectedId:i,loading:c=!1,maxHeight:d="calc(100vh - 320px)",emptyIcon:x="\uD83D\uDCED",emptyMessage:m}){let u=(0,a.c)("common"),p=m??u("noData");return c?(0,s.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",padding:"48px 24px",color:"var(--text-secondary, #888)",fontSize:"14px"},children:[(0,s.jsx)("span",{style:{animation:"spin 1s linear infinite",marginRight:"8px"},children:"⏳"}),u("loading"),(0,s.jsx)("style",{children:"@keyframes spin { to { transform: rotate(360deg); } }"})]}):0===t.length?(0,s.jsxs)("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",padding:"48px 24px",color:"var(--text-secondary, #888)",fontSize:"14px"},children:[(0,s.jsx)("span",{style:{fontSize:"32px",marginBottom:"8px",opacity:.6},children:x}),p]}):(0,s.jsx)("div",{style:{overflow:"auto",maxHeight:d,borderRadius:"8px"},children:(0,s.jsxs)("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:"12px",tableLayout:"auto"},children:[(0,s.jsx)("thead",{children:(0,s.jsx)("tr",{children:e.map(e=>(0,s.jsx)("th",{style:{padding:"8px 10px",textAlign:"left",fontWeight:600,color:"var(--text-secondary, #888)",borderBottom:"1px solid rgba(255,255,255,0.08)",position:"sticky",top:0,background:"var(--bg-table-header, rgba(15,15,25,0.95))",zIndex:1,whiteSpace:"nowrap",fontSize:"11px",textTransform:"uppercase",letterSpacing:"0.5px"},children:o?o(e):e.label},e.key))})}),(0,s.jsx)("tbody",{children:t.map((t,a)=>(0,s.jsx)("tr",{onClick:()=>n?.(t),style:{cursor:n?"pointer":"default",background:t.id===i?"rgba(99,102,241,0.1)":a%2==0?"transparent":"rgba(255,255,255,0.02)",transition:"background 0.15s"},onMouseEnter:e=>{t.id!==i&&(e.currentTarget.style.background="rgba(255,255,255,0.04)")},onMouseLeave:e=>{t.id!==i&&(e.currentTarget.style.background=a%2==0?"transparent":"rgba(255,255,255,0.02)")},children:e.map(e=>(0,s.jsx)("td",{style:{padding:"6px 10px",borderBottom:"1px solid rgba(255,255,255,0.04)",whiteSpace:"nowrap",maxWidth:e.maxWidth||"200px",overflow:"hidden",textOverflow:"ellipsis"},children:r(t,e)},e.key))},t.id||a))})]})})}},45624:(e,t,r)=>{r.d(t,{default:()=>K});var s=r(95155),a=r(12115),l=r(81060),o=r(92542),n=r(8898),i=r(55510),c=r(99333),d=r(1728),x=r(68444),m=r(32539),u=r(59656),p=r(65671),h=r(54945),b=r(75319),f=r(80865),g=r(53201),y=r(67389),j=r(90639),v=r(53459);function N(e,t){try{return new Intl.DateTimeFormat(e,t)}catch{return new Intl.DateTimeFormat(void 0,t)}}function k({active:e,payload:t,label:r,formatter:a}){return e&&t?.length?(0,s.jsxs)("div",{className:"rounded-lg border border-white/10 bg-surface px-3 py-2 text-xs shadow-lg",children:[r&&(0,s.jsx)("div",{className:"font-semibold text-text-main mb-1",children:r}),t.map((e,t)=>(0,s.jsxs)("div",{className:"flex items-center gap-1.5 text-text-muted",children:[(0,s.jsx)("span",{className:"w-2 h-2 rounded-full shrink-0",style:{backgroundColor:e.color}}),(0,s.jsxs)("span",{children:[e.name,":"]}),(0,s.jsx)("span",{className:"font-mono font-medium text-text-main",children:a?a(e.value):e.value})]},t))]}):null}function w({active:e,sortOrder:t}){return e?(0,s.jsx)("span",{className:"material-symbols-outlined text-[12px] text-primary",children:"asc"===t?"expand_less":"expand_more"}):(0,s.jsx)("span",{className:"material-symbols-outlined text-[12px] opacity-0 group-hover:opacity-30",children:"unfold_more"})}function C({icon:e,label:t,value:r,subValue:a,color:o="text-text-main"}){return(0,s.jsxs)(l.default,{className:"px-4 py-3 flex flex-col gap-1 min-w-0",children:[(0,s.jsxs)("div",{className:"flex items-center gap-1.5 text-text-muted text-[11px] uppercase font-semibold tracking-wide min-w-0",children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-[14px] shrink-0",children:e}),(0,s.jsx)("span",{className:"truncate",children:t})]}),(0,s.jsx)("span",{className:`text-2xl font-bold ${o} truncate`,title:String(r),children:r}),a&&(0,s.jsx)("span",{className:"text-xs text-text-muted truncate",children:a})]})}function S({sections:e}){return(0,s.jsx)(l.default,{className:"px-5 py-4",children:(0,s.jsx)("div",{className:"flex flex-col gap-3",children:e.map((e,t)=>(0,s.jsxs)("div",{children:[t>0&&(0,s.jsx)("div",{className:"border-t border-black/[0.06] dark:border-white/[0.06] mb-3"}),(0,s.jsx)("div",{className:"text-[10px] uppercase font-semibold tracking-widest text-text-muted/50 mb-2",children:e.title}),(0,s.jsx)("div",{className:e.wideValues?"grid grid-cols-1 sm:grid-cols-2 md:grid-cols-4 gap-x-5 gap-y-2":"grid grid-cols-2 md:grid-cols-4 gap-x-5 gap-y-2",children:e.items.map((t,r)=>(0,s.jsxs)("div",{className:"flex items-center justify-between gap-2 min-w-0 py-0.5",children:[(0,s.jsxs)("div",{className:`flex items-center gap-1.5 ${e.wideValues?"shrink-0":"min-w-0"}`,children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-[14px] text-text-muted shrink-0",children:t.icon}),(0,s.jsx)("span",{className:`text-[11px] uppercase font-semibold tracking-wide text-text-muted ${e.wideValues?"whitespace-nowrap":"truncate"}`,children:t.label})]}),(0,s.jsx)("span",{className:`text-sm font-bold text-right ${e.wideValues?"truncate min-w-0":"shrink-0"} ${t.color||"text-text-main"}`,title:String(t.value),children:t.value})]},r))})]},t))})})}function A({activityMap:e}){let t=(0,a.useRef)(null),r=(0,a.useMemo)(()=>{let t=new Date,r=[],s=0;for(let a=364;a>=0;a--){let l=new Date(t);l.setDate(l.getDate()-a);let o=`${l.getFullYear()}-${String(l.getMonth()+1).padStart(2,"0")}-${String(l.getDate()).padStart(2,"0")}`,n=e?.[o]||0;n>s&&(s=n),r.push({date:o,value:n,dayOfWeek:l.getDay()})}return{days:r,maxVal:s}},[e]),o=(0,a.useMemo)(()=>{let e=[],t=[],s=r.days[0]?.dayOfWeek||0;for(let e=0;e<s;e++)t.push(null);for(let s of r.days)t.push(s),7===t.length&&(e.push(t),t=[]);return t.length>0&&e.push(t),e},[r]);(0,a.useEffect)(()=>{t.current&&(t.current.scrollLeft=t.current.scrollWidth)},[o]);let i=(0,a.useMemo)(()=>{let e=[],t=-1;return o.forEach((r,s)=>{let a=r.find(e=>null!==e);if(a){let r=new Date(a.date).getMonth();r!==t&&(e.push({weekIdx:s,label:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"][r]}),t=r)}}),e},[o]);return(0,s.jsxs)(l.default,{className:"p-4 h-full min-w-0 overflow-hidden",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between mb-3",children:[(0,s.jsx)("h3",{className:"text-sm font-semibold text-text-muted uppercase tracking-wider",children:"Activity"}),(0,s.jsxs)("span",{className:"text-xs text-text-muted",children:[Object.keys(e||{}).length," active days \xb7"," ",(0,n.VK)(Object.values(e||{}).reduce((e,t)=>e+t,0))," tokens \xb7 365 days"]})]}),(0,s.jsx)("div",{ref:t,className:"overflow-x-auto",children:(0,s.jsxs)("div",{className:"w-max",children:[(0,s.jsx)("div",{className:"flex gap-[3px] mb-1 ml-6",style:{fontSize:"10px"},children:i.map((e,t)=>(0,s.jsx)("span",{className:"text-text-muted",style:{position:"relative",left:`${13*e.weekIdx}px`,marginLeft:0===t?0:"-20px"},children:e.label},t))}),(0,s.jsxs)("div",{className:"flex gap-[3px]",children:[(0,s.jsxs)("div",{className:"flex flex-col gap-[3px] shrink-0 text-[10px] text-text-muted pr-1 sticky left-0 z-10 bg-surface",children:[(0,s.jsx)("span",{className:"h-[10px]"}),(0,s.jsx)("span",{className:"h-[10px] leading-[10px]",children:"Mon"}),(0,s.jsx)("span",{className:"h-[10px]"}),(0,s.jsx)("span",{className:"h-[10px] leading-[10px]",children:"Wed"}),(0,s.jsx)("span",{className:"h-[10px]"}),(0,s.jsx)("span",{className:"h-[10px] leading-[10px]",children:"Fri"}),(0,s.jsx)("span",{className:"h-[10px]"})]}),o.map((e,t)=>(0,s.jsx)("div",{className:"flex flex-col gap-[3px]",children:e.map((e,t)=>(0,s.jsx)("div",{title:e?`${e.date}: ${(0,n.xW)(e.value)} tokens`:"",className:`w-[10px] h-[10px] rounded-[2px] ${e?function(e){if(!e||0===e)return"bg-white/[0.04]";let t=Math.min(e/(r.maxVal||1),1);return t<.25?"bg-primary/20":t<.5?"bg-primary/40":t<.75?"bg-primary/60":"bg-primary/90"}(e.value):"bg-transparent"}`},t))},t))]})]})}),(0,s.jsxs)("div",{className:"flex items-center gap-1 mt-2 ml-6 text-[10px] text-text-muted",children:[(0,s.jsx)("span",{children:"Less"}),(0,s.jsx)("div",{className:"w-[10px] h-[10px] rounded-[2px] bg-white/[0.04]"}),(0,s.jsx)("div",{className:"w-[10px] h-[10px] rounded-[2px] bg-primary/20"}),(0,s.jsx)("div",{className:"w-[10px] h-[10px] rounded-[2px] bg-primary/40"}),(0,s.jsx)("div",{className:"w-[10px] h-[10px] rounded-[2px] bg-primary/60"}),(0,s.jsx)("div",{className:"w-[10px] h-[10px] rounded-[2px] bg-primary/90"}),(0,s.jsx)("span",{children:"More"})]})]})}function T({dailyTrend:e}){let t=(0,a.useMemo)(()=>(e||[]).map(e=>({date:e.date.slice(5),Input:e.promptTokens,Output:e.completionTokens,Cost:e.cost||0})),[e]),r=(0,a.useMemo)(()=>t.some(e=>e.Cost>0),[t]);return t.length?(0,s.jsxs)(l.default,{className:"p-4 flex-1",children:[(0,s.jsx)("h3",{className:"text-sm font-semibold text-text-muted uppercase tracking-wider mb-3",children:"Token & Cost Trend"}),(0,s.jsx)(d.u,{width:"100%",height:140,children:(0,s.jsxs)(x.X,{data:t,margin:{top:0,right:40*!!r,left:0,bottom:0},children:[(0,s.jsx)(m.W,{dataKey:"date",tick:{fontSize:9,fill:"var(--text-muted)"},axisLine:!1,tickLine:!1,interval:Math.max(Math.floor(t.length/6),0)}),r&&(0,s.jsx)(u.h,{yAxisId:"cost",orientation:"right",tick:{fontSize:8,fill:"#f59e0b"},axisLine:!1,tickLine:!1,tickFormatter:e=>`$${e.toFixed(2)}`,width:36}),(0,s.jsx)(p.m,{content:(0,s.jsx)(I,{}),cursor:{fill:"rgba(255,255,255,0.04)"}}),(0,s.jsx)(h.yP,{dataKey:"Input",stackId:"a",fill:"var(--primary)",opacity:.7,radius:[0,0,0,0],animationDuration:600}),(0,s.jsx)(h.yP,{dataKey:"Output",stackId:"a",fill:"#10b981",opacity:.7,radius:[3,3,0,0],animationDuration:600}),r&&(0,s.jsx)(b.N1,{yAxisId:"cost",type:"monotone",dataKey:"Cost",stroke:"#f59e0b",strokeWidth:2,dot:!1,animationDuration:600})]})}),(0,s.jsxs)("div",{className:"flex items-center gap-4 mt-2 text-[10px] text-text-muted",children:[(0,s.jsxs)("span",{className:"flex items-center gap-1",children:[(0,s.jsx)("span",{className:"w-2 h-2 rounded-full bg-primary/70"})," Input"]}),(0,s.jsxs)("span",{className:"flex items-center gap-1",children:[(0,s.jsx)("span",{className:"w-2 h-2 rounded-full bg-emerald-500/70"})," Output"]}),r&&(0,s.jsxs)("span",{className:"flex items-center gap-1",children:[(0,s.jsx)("span",{className:"w-2 h-2 rounded-full bg-amber-500/70"})," Cost ($)"]})]})]}):(0,s.jsxs)(l.default,{className:"p-4",children:[(0,s.jsx)("h3",{className:"text-sm font-semibold text-text-muted uppercase tracking-wider mb-3",children:"Token Trend"}),(0,s.jsx)("div",{className:"text-center text-text-muted text-sm py-8",children:"No data"})]})}function I({active:e,payload:t,label:r}){return e&&t?.length?(0,s.jsxs)("div",{className:"rounded-lg border border-white/10 bg-surface px-3 py-2 text-xs shadow-lg",children:[r&&(0,s.jsx)("div",{className:"font-semibold text-text-main mb-1",children:r}),t.map((e,t)=>(0,s.jsxs)("div",{className:"flex items-center gap-1.5 text-text-muted",children:[(0,s.jsx)("span",{className:"w-2 h-2 rounded-full shrink-0",style:{backgroundColor:e.color}}),(0,s.jsxs)("span",{children:[e.name,":"]}),(0,s.jsx)("span",{className:"font-mono font-medium text-text-main",children:"Cost"===e.name?(0,n.F0)(e.value):(0,n.VK)(e.value)})]},t))]}):null}function M({byAccount:e}){let t=(0,a.useMemo)(()=>e||[],[e]),r=t.length>0,o=(0,a.useMemo)(()=>t.slice(0,8).map((e,t)=>({name:e.account,value:e.totalTokens,fill:(0,c.ng)(t)})),[t]);return r?(0,s.jsxs)(l.default,{className:"p-4 flex-1",children:[(0,s.jsx)("h3",{className:"text-sm font-semibold text-text-muted uppercase tracking-wider mb-3",children:"By Account"}),(0,s.jsxs)("div",{className:"flex items-center gap-4",children:[(0,s.jsx)(d.u,{width:120,height:120,children:(0,s.jsxs)(f.r,{children:[(0,s.jsx)(g.Fq,{data:o,dataKey:"value",nameKey:"name",cx:"50%",cy:"50%",innerRadius:28,outerRadius:55,paddingAngle:1,animationDuration:600,children:o.map((e,t)=>(0,s.jsx)(y.f,{fill:e.fill,stroke:"none"},t))}),(0,s.jsx)(p.m,{content:(0,s.jsx)(k,{formatter:n.VK})})]})}),(0,s.jsx)("div",{className:"flex flex-col gap-1 min-w-0 flex-1",children:o.map((e,t)=>(0,s.jsxs)("div",{className:"flex items-center justify-between gap-2 text-xs",children:[(0,s.jsxs)("div",{className:"flex items-center gap-1.5 min-w-0",children:[(0,s.jsx)("span",{className:"w-2 h-2 rounded-full shrink-0",style:{backgroundColor:e.fill}}),(0,s.jsx)("span",{className:"truncate text-text-main",children:e.name})]}),(0,s.jsx)("span",{className:"font-mono font-medium text-text-muted shrink-0",children:(0,n.VK)(e.value)})]},t))})]})]}):(0,s.jsxs)(l.default,{className:"p-4 flex-1",children:[(0,s.jsx)("h3",{className:"text-sm font-semibold text-text-muted uppercase tracking-wider mb-3",children:"By Account"}),(0,s.jsx)("div",{className:"text-center text-text-muted text-sm py-8",children:"No data"})]})}function O({byApiKey:e}){let t=(0,a.useMemo)(()=>e||[],[e]),r=t.length>0,o=(0,a.useMemo)(()=>t.slice(0,8).map((e,t)=>({name:(0,n.VO)(e.apiKeyName,e.apiKeyId),fullName:e.apiKeyName||e.apiKeyId||"unknown",value:e.totalTokens,fill:(0,c.ng)(t)})),[t]);return r?(0,s.jsxs)(l.default,{className:"p-4 flex-1",children:[(0,s.jsx)("h3",{className:"text-sm font-semibold text-text-muted uppercase tracking-wider mb-3",children:"By API Key"}),(0,s.jsxs)("div",{className:"flex items-center gap-4",children:[(0,s.jsx)(d.u,{width:120,height:120,children:(0,s.jsxs)(f.r,{children:[(0,s.jsx)(g.Fq,{data:o,dataKey:"value",nameKey:"name",cx:"50%",cy:"50%",innerRadius:28,outerRadius:55,paddingAngle:1,animationDuration:600,children:o.map((e,t)=>(0,s.jsx)(y.f,{fill:e.fill,stroke:"none"},t))}),(0,s.jsx)(p.m,{content:(0,s.jsx)(k,{formatter:n.VK})})]})}),(0,s.jsx)("div",{className:"flex flex-col gap-1 min-w-0 flex-1",children:o.map((e,t)=>(0,s.jsxs)("div",{className:"flex items-center justify-between gap-2 text-xs",children:[(0,s.jsxs)("div",{className:"flex items-center gap-1.5 min-w-0",children:[(0,s.jsx)("span",{className:"w-2 h-2 rounded-full shrink-0",style:{backgroundColor:e.fill}}),(0,s.jsx)("span",{className:"truncate text-text-main",title:e.fullName,children:e.name})]}),(0,s.jsx)("span",{className:"font-mono font-medium text-text-muted shrink-0",children:(0,n.VK)(e.value)})]},`${e.fullName}-${t}`))})]})]}):(0,s.jsxs)(l.default,{className:"p-4 flex-1",children:[(0,s.jsx)("h3",{className:"text-sm font-semibold text-text-muted uppercase tracking-wider mb-3",children:"By API Key"}),(0,s.jsx)("div",{className:"text-center text-text-muted text-sm py-8",children:"No data"})]})}function R({byApiKey:e}){let[t,r]=(0,a.useState)(""),[o,i]=(0,a.useState)("totalTokens"),[c,d]=(0,a.useState)("desc"),x=(0,a.useMemo)(()=>e||[],[e]),m=(0,a.useMemo)(()=>{let e=t.trim().toLowerCase();return e?x.filter(t=>(t.apiKeyName||"").toLowerCase().includes(e)||(t.apiKeyId||"").toLowerCase().includes(e)):x},[x,t]),u=(0,a.useMemo)(()=>{let e=[...m];return e.sort((e,t)=>{let r=e[o]??0,s=t[o]??0;return"string"==typeof r?"asc"===c?r.localeCompare(s):s.localeCompare(r):"asc"===c?r-s:s-r}),e},[m,o,c]),p=(0,a.useCallback)(e=>{o===e?d(e=>"asc"===e?"desc":"asc"):(i(e),d("desc"))},[o]);return x.length>0?(0,s.jsxs)(l.default,{className:"overflow-hidden",children:[(0,s.jsxs)("div",{className:"p-4 border-b border-border flex items-center justify-between gap-3",children:[(0,s.jsx)("h3",{className:"text-sm font-semibold text-text-muted uppercase tracking-wider",children:"API Key Breakdown"}),(0,s.jsx)("input",{type:"text",value:t,onChange:e=>r(e.target.value),placeholder:"Filter API key...",className:"w-full max-w-[220px] px-3 py-1.5 rounded-lg bg-bg-subtle border border-border text-xs text-text-primary placeholder:text-text-muted focus:outline-none focus:border-primary"})]}),(0,s.jsx)("div",{className:"overflow-x-auto",children:(0,s.jsxs)("table",{className:"w-full text-sm",children:[(0,s.jsx)("thead",{className:"text-xs text-text-muted uppercase bg-black/[0.02] dark:bg-white/[0.02]",children:(0,s.jsxs)("tr",{children:[(0,s.jsxs)("th",{className:"px-4 py-2.5 text-left cursor-pointer group",onClick:()=>p("apiKeyName"),children:["API Key ",(0,s.jsx)(w,{active:"apiKeyName"===o,sortOrder:c})]}),(0,s.jsxs)("th",{className:"px-4 py-2.5 text-right cursor-pointer group",onClick:()=>p("requests"),children:["Requests ",(0,s.jsx)(w,{active:"requests"===o,sortOrder:c})]}),(0,s.jsxs)("th",{className:"px-4 py-2.5 text-right cursor-pointer group",onClick:()=>p("promptTokens"),children:["Input ",(0,s.jsx)(w,{active:"promptTokens"===o,sortOrder:c})]}),(0,s.jsxs)("th",{className:"px-4 py-2.5 text-right cursor-pointer group",onClick:()=>p("completionTokens"),children:["Output"," ",(0,s.jsx)(w,{active:"completionTokens"===o,sortOrder:c})]}),(0,s.jsxs)("th",{className:"px-4 py-2.5 text-right cursor-pointer group",onClick:()=>p("totalTokens"),children:["Total Tokens"," ",(0,s.jsx)(w,{active:"totalTokens"===o,sortOrder:c})]}),(0,s.jsxs)("th",{className:"px-4 py-2.5 text-right cursor-pointer group",onClick:()=>p("cost"),children:["Cost ",(0,s.jsx)(w,{active:"cost"===o,sortOrder:c})]})]})}),(0,s.jsxs)("tbody",{className:"divide-y divide-border",children:[u.map((e,t)=>(0,s.jsxs)("tr",{className:"hover:bg-black/[0.02] dark:hover:bg-white/[0.02] transition-colors",children:[(0,s.jsx)("td",{className:"px-4 py-2.5",children:(0,s.jsx)("span",{className:"font-medium",title:e.apiKeyName||e.apiKeyId||"unknown",children:(0,n.VO)(e.apiKeyName,e.apiKeyId)})}),(0,s.jsx)("td",{className:"px-4 py-2.5 text-right font-mono text-text-muted",children:(0,n.xW)(e.requests)}),(0,s.jsx)("td",{className:"px-4 py-2.5 text-right font-mono text-primary",children:(0,n.VK)(e.promptTokens)}),(0,s.jsx)("td",{className:"px-4 py-2.5 text-right font-mono text-emerald-500",children:(0,n.VK)(e.completionTokens)}),(0,s.jsx)("td",{className:"px-4 py-2.5 text-right font-mono font-semibold",children:(0,n.VK)(e.totalTokens)}),(0,s.jsx)("td",{className:"px-4 py-2.5 text-right font-mono text-amber-500",children:(0,n.F0)(e.cost)})]},`${e.apiKeyId||e.apiKeyName||"key"}-${t}`)),0===u.length&&(0,s.jsx)("tr",{children:(0,s.jsx)("td",{colSpan:6,className:"px-4 py-8 text-center text-text-muted",children:"No API key matches this filter."})})]})]})})]}):(0,s.jsxs)(l.default,{className:"p-4 flex-1",children:[(0,s.jsx)("h3",{className:"text-sm font-semibold text-text-muted uppercase tracking-wider mb-3",children:"API Key Breakdown"}),(0,s.jsx)("div",{className:"text-center text-text-muted text-sm py-8",children:"No data"})]})}function L({activityMap:e}){let t=(0,i.Ym)(),r=(0,a.useMemo)(()=>N(t,{weekday:"long"}),[t]),o=(0,a.useMemo)(()=>N(t,{month:"short",day:"numeric"}),[t]),c=(0,a.useMemo)(()=>{if(!e)return null;let t=new Date,s=null,a=0;for(let r=0;r<7;r++){let l=new Date(t);l.setDate(l.getDate()-r);let o=`${l.getFullYear()}-${String(l.getMonth()+1).padStart(2,"0")}-${String(l.getDate()).padStart(2,"0")}`,n=e[o]||0;n>a&&(a=n,s=o)}if(!s||0===a)return null;let l=new Date(s+"T12:00:00");return{weekday:r.format(l),label:o.format(l),tokens:a}},[e,o,r]);return(0,s.jsxs)(l.default,{className:"p-4 flex flex-col justify-center",style:{flex:1,minHeight:0},children:[(0,s.jsx)("h3",{className:"text-xs font-semibold uppercase tracking-wider mb-2",style:{color:"var(--text-muted)"},children:"Most Active Day"}),c?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("span",{className:"text-xl font-bold capitalize",style:{lineHeight:1.2},children:c.weekday}),(0,s.jsxs)("span",{className:"text-xs mt-1",style:{color:"var(--text-muted)"},children:[c.label," \xb7 ",(0,n.VK)(c.tokens)," tokens"]})]}):(0,s.jsx)("span",{className:"text-xs",style:{color:"var(--text-muted)"},children:"No data in the last 7 days"})]})}function E({activityMap:e}){let t=(0,i.Ym)(),r=(0,a.useMemo)(()=>N(t,{weekday:"short"}),[t]),o=(0,a.useMemo)(()=>N(t,{month:"short",day:"numeric"}),[t]),c=(0,a.useMemo)(()=>{if(!e)return[];let t=new Date,s=[],a=0;for(let l=6;l>=0;l--){let n=new Date(t);n.setDate(n.getDate()-l);let i=`${n.getFullYear()}-${String(n.getMonth()+1).padStart(2,"0")}-${String(n.getDate()).padStart(2,"0")}`,c=e[i]||0;c>a&&(a=c),s.push({key:i,val:c,label:r.format(n),dateLabel:o.format(n)})}return s.map(e=>({...e,intensity:a>0?e.val/a:0}))},[e,o,r]);return(0,s.jsxs)(l.default,{className:"p-4 flex flex-col justify-center",style:{flex:1,minHeight:0},children:[(0,s.jsx)("h3",{className:"text-xs font-semibold uppercase tracking-wider mb-3",style:{color:"var(--text-muted)"},children:"Weekly"}),(0,s.jsx)("div",{style:{display:"flex",alignItems:"flex-end",gap:6,justifyContent:"center"},children:c.map((e,t)=>{var r;return(0,s.jsxs)("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",gap:4},children:[(0,s.jsx)("div",{title:`${e.dateLabel}: ${(0,n.xW)(e.val)} tokens`,style:{width:36,height:36,borderRadius:8,...0===(r=e.intensity)?{background:"rgba(255,255,255,0.04)"}:{background:`rgba(229, 77, 94, ${(.15+.75*r).toFixed(2)})`},transition:"all 0.2s",cursor:"default"}}),(0,s.jsx)("span",{style:{fontSize:9,fontWeight:600,color:"var(--text-muted)",letterSpacing:"0.03em"},children:e.label})]},e.key)})})]})}function _({byModel:e,summary:t}){let[r,o]=(0,a.useState)("totalTokens"),[i,d]=(0,a.useState)("desc"),x=(0,a.useCallback)(e=>{r===e?d(e=>"asc"===e?"desc":"asc"):(o(e),d("desc"))},[r]),m=(0,a.useMemo)(()=>{let t=[...e||[]];return t.sort((e,t)=>{let s=e[r]??0,a=t[r]??0;return"string"==typeof s?"asc"===i?s.localeCompare(a):a.localeCompare(s):"asc"===i?s-a:a-s}),t},[e,r,i]);return(0,s.jsxs)(l.default,{className:"overflow-hidden",children:[(0,s.jsx)("div",{className:"p-4 border-b border-border",children:(0,s.jsx)("h3",{className:"text-sm font-semibold text-text-muted uppercase tracking-wider",children:"Model Breakdown"})}),(0,s.jsx)("div",{className:"overflow-x-auto",children:(0,s.jsxs)("table",{className:"w-full text-sm",children:[(0,s.jsx)("thead",{className:"text-xs text-text-muted uppercase bg-black/[0.02] dark:bg-white/[0.02]",children:(0,s.jsxs)("tr",{children:[(0,s.jsxs)("th",{className:"px-4 py-2.5 text-left cursor-pointer group",onClick:()=>x("model"),children:["Model ",(0,s.jsx)(w,{active:"model"===r,sortOrder:i})]}),(0,s.jsxs)("th",{className:"px-4 py-2.5 text-right cursor-pointer group",onClick:()=>x("requests"),children:["Requests ",(0,s.jsx)(w,{active:"requests"===r,sortOrder:i})]}),(0,s.jsxs)("th",{className:"px-4 py-2.5 text-right cursor-pointer group",onClick:()=>x("promptTokens"),children:["Input ",(0,s.jsx)(w,{active:"promptTokens"===r,sortOrder:i})]}),(0,s.jsxs)("th",{className:"px-4 py-2.5 text-right cursor-pointer group",onClick:()=>x("completionTokens"),children:["Output"," ",(0,s.jsx)(w,{active:"completionTokens"===r,sortOrder:i})]}),(0,s.jsxs)("th",{className:"px-4 py-2.5 text-right cursor-pointer group",onClick:()=>x("totalTokens"),children:["Total ",(0,s.jsx)(w,{active:"totalTokens"===r,sortOrder:i})]}),(0,s.jsxs)("th",{className:"px-4 py-2.5 text-right cursor-pointer group",onClick:()=>x("cost"),children:["Cost ",(0,s.jsx)(w,{active:"cost"===r,sortOrder:i})]}),(0,s.jsx)("th",{className:"px-4 py-2.5 text-right w-36",children:"Share"})]})}),(0,s.jsx)("tbody",{className:"divide-y divide-border",children:m.map((e,t)=>(0,s.jsxs)("tr",{className:"hover:bg-black/[0.02] dark:hover:bg-white/[0.02] transition-colors",children:[(0,s.jsx)("td",{className:"px-4 py-2.5",children:(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)("span",{className:"w-2 h-2 rounded-full shrink-0",style:{backgroundColor:(0,c.ng)(t)}}),(0,s.jsx)("span",{className:"font-medium",children:e.model})]})}),(0,s.jsx)("td",{className:"px-4 py-2.5 text-right font-mono text-text-muted",children:(0,n.xW)(e.requests)}),(0,s.jsx)("td",{className:"px-4 py-2.5 text-right font-mono text-primary",children:(0,n.VK)(e.promptTokens)}),(0,s.jsx)("td",{className:"px-4 py-2.5 text-right font-mono text-emerald-500",children:(0,n.VK)(e.completionTokens)}),(0,s.jsx)("td",{className:"px-4 py-2.5 text-right font-mono font-semibold",children:(0,n.VK)(e.totalTokens)}),(0,s.jsx)("td",{className:"px-4 py-2.5 text-right font-mono text-amber-500",children:(0,n.F0)(e.cost)}),(0,s.jsx)("td",{className:"px-4 py-2.5 text-right",children:(0,s.jsxs)("div",{className:"flex items-center gap-2 justify-end",children:[(0,s.jsx)("div",{className:"w-16 h-1.5 rounded-full bg-white/[0.06] overflow-hidden",children:(0,s.jsx)("div",{className:"h-full rounded-full transition-all",style:{width:`${e.pct}%`,backgroundColor:(0,c.ng)(t)}})}),(0,s.jsxs)("span",{className:"text-xs font-mono text-text-muted w-10 text-right",children:[e.pct,"%"]})]})})]},e.model))})]})})]})}let F=["#f59e0b","#ef4444","#8b5cf6","#10b981","#06b6d4","#ec4899","#f97316","#6366f1","#14b8a6","#a855f7"];function $({byProvider:e}){let t=(0,a.useMemo)(()=>e||[],[e]),r=t.length>0&&t.some(e=>e.cost>0),o=(0,a.useMemo)(()=>t.filter(e=>e.cost>0).sort((e,t)=>t.cost-e.cost).slice(0,8).map((e,t)=>({name:e.provider,value:e.cost,fill:F[t%F.length]})),[t]);return r?(0,s.jsxs)(l.default,{className:"p-4 flex-1",children:[(0,s.jsx)("h3",{className:"text-sm font-semibold text-text-muted uppercase tracking-wider mb-3",children:"Cost by Provider"}),(0,s.jsxs)("div",{className:"flex items-center gap-4",children:[(0,s.jsx)(d.u,{width:120,height:120,children:(0,s.jsxs)(f.r,{children:[(0,s.jsx)(g.Fq,{data:o,dataKey:"value",nameKey:"name",cx:"50%",cy:"50%",innerRadius:28,outerRadius:55,paddingAngle:1,animationDuration:600,children:o.map((e,t)=>(0,s.jsx)(y.f,{fill:e.fill,stroke:"none"},t))}),(0,s.jsx)(p.m,{content:(0,s.jsx)(k,{formatter:n.F0})})]})}),(0,s.jsx)("div",{className:"flex flex-col gap-1 min-w-0 flex-1",children:o.map((e,t)=>(0,s.jsxs)("div",{className:"flex items-center justify-between gap-2 text-xs",children:[(0,s.jsxs)("div",{className:"flex items-center gap-1.5 min-w-0",children:[(0,s.jsx)("span",{className:"w-2 h-2 rounded-full shrink-0",style:{backgroundColor:e.fill}}),(0,s.jsx)("span",{className:"truncate text-text-main capitalize",children:e.name})]}),(0,s.jsx)("span",{className:"font-mono font-medium text-amber-500 shrink-0",children:(0,n.F0)(e.value)})]},t))})]})]}):(0,s.jsxs)(l.default,{className:"p-4 flex-1",children:[(0,s.jsx)("h3",{className:"text-sm font-semibold text-text-muted uppercase tracking-wider mb-3",children:"Cost by Provider"}),(0,s.jsx)("div",{className:"text-center text-text-muted text-sm py-8",children:"No cost data"})]})}function D({dailyByModel:e,modelNames:t}){let r=(0,a.useMemo)(()=>e||[],[e]),o=(0,a.useMemo)(()=>t||[],[t]),i=(0,a.useMemo)(()=>r.map(e=>{let t={...e};if(e.date){let r=e.date.split("-");t.dateLabel=`${r[1]}/${r[2]}`}return t}),[r]);return r.length&&o.length?(0,s.jsxs)(l.default,{className:"p-4",children:[(0,s.jsx)("h3",{className:"text-sm font-semibold text-text-muted uppercase tracking-wider mb-3",children:"Model Usage Over Time"}),(0,s.jsx)(d.u,{width:"100%",height:240,children:(0,s.jsxs)(j.Q,{data:i,margin:{top:4,right:4,left:0,bottom:0},children:[(0,s.jsx)(m.W,{dataKey:"dateLabel",tick:{fontSize:10,fill:"var(--text-muted)"},axisLine:!1,tickLine:!1,interval:"preserveStartEnd"}),(0,s.jsx)(u.h,{tick:{fontSize:10,fill:"var(--text-muted)"},tickFormatter:e=>(0,n.VK)(e),axisLine:!1,tickLine:!1,width:50}),(0,s.jsx)(p.m,{content:(0,s.jsx)(k,{formatter:n.VK})}),o.map((e,t)=>(0,s.jsx)(v.Gk,{type:"monotone",dataKey:e,stackId:"1",stroke:(0,c.ng)(t),fill:(0,c.ng)(t),fillOpacity:.4,strokeWidth:1.5,animationDuration:600},e))]})}),(0,s.jsx)("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1 mt-2 text-[10px] text-text-muted",children:o.map((e,t)=>(0,s.jsxs)("span",{className:"flex items-center gap-1",children:[(0,s.jsx)("span",{className:"w-2 h-2 rounded-full shrink-0",style:{backgroundColor:(0,c.ng)(t)}}),e]},e))})]}):(0,s.jsxs)(l.default,{className:"p-4",children:[(0,s.jsx)("h3",{className:"text-sm font-semibold text-text-muted uppercase tracking-wider mb-3",children:"Model Usage Over Time"}),(0,s.jsx)("div",{className:"text-center text-text-muted text-sm py-8",children:"No data"})]})}function P({byProvider:e}){let[t,r]=(0,a.useState)("totalTokens"),[o,i]=(0,a.useState)("desc"),c=(0,a.useMemo)(()=>e||[],[e]),d=(0,a.useMemo)(()=>c.reduce((e,t)=>e+t.totalTokens,0),[c]),x=(0,a.useCallback)(e=>{t===e?i(e=>"asc"===e?"desc":"asc"):(r(e),i("desc"))},[t]),m=(0,a.useMemo)(()=>{let e=[...c];return e.sort((e,r)=>{let s=e[t]??0,a=r[t]??0;return"string"==typeof s?"asc"===o?s.localeCompare(a):a.localeCompare(s):"asc"===o?s-a:a-s}),e},[c,t,o]);return c.length?(0,s.jsxs)(l.default,{className:"overflow-hidden",children:[(0,s.jsx)("div",{className:"p-4 border-b border-border",children:(0,s.jsx)("h3",{className:"text-sm font-semibold text-text-muted uppercase tracking-wider",children:"Provider Breakdown"})}),(0,s.jsx)("div",{className:"overflow-x-auto",children:(0,s.jsxs)("table",{className:"w-full text-sm",children:[(0,s.jsx)("thead",{className:"text-xs text-text-muted uppercase bg-black/[0.02] dark:bg-white/[0.02]",children:(0,s.jsxs)("tr",{children:[(0,s.jsxs)("th",{className:"px-4 py-2.5 text-left cursor-pointer group",onClick:()=>x("provider"),children:["Provider ",(0,s.jsx)(w,{active:"provider"===t,sortOrder:o})]}),(0,s.jsxs)("th",{className:"px-4 py-2.5 text-right cursor-pointer group",onClick:()=>x("requests"),children:["Requests ",(0,s.jsx)(w,{active:"requests"===t,sortOrder:o})]}),(0,s.jsxs)("th",{className:"px-4 py-2.5 text-right cursor-pointer group",onClick:()=>x("promptTokens"),children:["Input ",(0,s.jsx)(w,{active:"promptTokens"===t,sortOrder:o})]}),(0,s.jsxs)("th",{className:"px-4 py-2.5 text-right cursor-pointer group",onClick:()=>x("completionTokens"),children:["Output"," ",(0,s.jsx)(w,{active:"completionTokens"===t,sortOrder:o})]}),(0,s.jsxs)("th",{className:"px-4 py-2.5 text-right cursor-pointer group",onClick:()=>x("totalTokens"),children:["Total ",(0,s.jsx)(w,{active:"totalTokens"===t,sortOrder:o})]}),(0,s.jsxs)("th",{className:"px-4 py-2.5 text-right cursor-pointer group",onClick:()=>x("cost"),children:["Cost ",(0,s.jsx)(w,{active:"cost"===t,sortOrder:o})]}),(0,s.jsx)("th",{className:"px-4 py-2.5 text-right w-36",children:"Share"})]})}),(0,s.jsx)("tbody",{className:"divide-y divide-border",children:m.map((e,t)=>{let r=d>0?(e.totalTokens/d*100).toFixed(1):"0";return(0,s.jsxs)("tr",{className:"hover:bg-black/[0.02] dark:hover:bg-white/[0.02] transition-colors",children:[(0,s.jsx)("td",{className:"px-4 py-2.5",children:(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)("span",{className:"w-2 h-2 rounded-full shrink-0",style:{backgroundColor:F[t%F.length]}}),(0,s.jsx)("span",{className:"font-medium capitalize",children:e.provider})]})}),(0,s.jsx)("td",{className:"px-4 py-2.5 text-right font-mono text-text-muted",children:(0,n.xW)(e.requests)}),(0,s.jsx)("td",{className:"px-4 py-2.5 text-right font-mono text-primary",children:(0,n.VK)(e.promptTokens)}),(0,s.jsx)("td",{className:"px-4 py-2.5 text-right font-mono text-emerald-500",children:(0,n.VK)(e.completionTokens)}),(0,s.jsx)("td",{className:"px-4 py-2.5 text-right font-mono font-semibold",children:(0,n.VK)(e.totalTokens)}),(0,s.jsx)("td",{className:"px-4 py-2.5 text-right font-mono text-amber-500",children:(0,n.F0)(e.cost)}),(0,s.jsx)("td",{className:"px-4 py-2.5 text-right",children:(0,s.jsxs)("div",{className:"flex items-center gap-2 justify-end",children:[(0,s.jsx)("div",{className:"w-16 h-1.5 rounded-full bg-white/[0.06] overflow-hidden",children:(0,s.jsx)("div",{className:"h-full rounded-full transition-all",style:{width:`${r}%`,backgroundColor:F[t%F.length]}})}),(0,s.jsxs)("span",{className:"text-xs font-mono text-text-muted w-10 text-right",children:[r,"%"]})]})})]},e.provider)})})]})})]}):(0,s.jsxs)(l.default,{className:"p-4",children:[(0,s.jsx)("h3",{className:"text-sm font-semibold text-text-muted uppercase tracking-wider mb-3",children:"Provider Breakdown"}),(0,s.jsx)("div",{className:"text-center text-text-muted text-sm py-8",children:"No data"})]})}function K(){let[e,t]=(0,a.useState)("30d"),[r,i]=(0,a.useState)(null),[c,d]=(0,a.useState)(!0),[x,m]=(0,a.useState)(null),u=(0,a.useCallback)(async()=>{try{d(!0);let t=await fetch(`/api/usage/analytics?range=${e}`);if(!t.ok)throw Error("Failed to fetch");let r=await t.json();i(r),m(null)}catch(e){m(e.message)}finally{d(!1)}},[e]);(0,a.useEffect)(()=>{u()},[u]);let p=(0,a.useMemo)(()=>{let e=r?.byModel||[];return e.length>0?e[0].model:"—"},[r]),h=(0,a.useMemo)(()=>{let e=r?.byProvider||[];return e.length>0?e[0].provider:"—"},[r]),b=(0,a.useMemo)(()=>{let e=r?.weeklyPattern||[];if(!e.length)return"—";let t=e.reduce((e,t)=>e.avgTokens>t.avgTokens?e:t,e[0]);return t.avgTokens>0?t.day:"—"},[r]),f=(0,a.useMemo)(()=>(r?.byProvider||[]).length,[r]),g=(0,a.useMemo)(()=>{let e=r?.byProvider||[];if(e.length<=1)return 0;let t=0;for(let r of e)t+=r.totalRequests||r.apiCalls||0;if(0===t)return 0;let s=0;for(let r of e){let e=(r.totalRequests||r.apiCalls||0)/t;e>0&&(s-=e*Math.log2(e))}let a=Math.log2(e.length);return a>0?s/a*100:0},[r]);if(c&&!r)return(0,s.jsx)(o.CardSkeleton,{});if(x)return(0,s.jsxs)(l.default,{className:"p-6 text-center text-red-500",children:["Error: ",x]});let y=r?.summary||{},j=y.totalRequests>0?Math.round(y.totalTokens/y.totalRequests):0,v=y.totalRequests>0?y.totalCost/y.totalRequests:0,N=y.completionTokens>0?(y.promptTokens/y.completionTokens).toFixed(1):"—";return(0,s.jsxs)("div",{className:"flex flex-col gap-5 min-w-0",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between",children:[(0,s.jsxs)("h2",{className:"text-xl font-semibold flex items-center gap-2",children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-primary text-[22px]",children:"analytics"}),"Usage Analytics"]}),(0,s.jsx)("div",{className:"flex items-center gap-1 bg-black/[0.03] dark:bg-white/[0.03] rounded-lg p-1 border border-black/5 dark:border-white/5",children:[{value:"1d",label:"1D"},{value:"7d",label:"7D"},{value:"30d",label:"30D"},{value:"90d",label:"90D"},{value:"ytd",label:"YTD"},{value:"all",label:"All"}].map(r=>(0,s.jsx)("button",{onClick:()=>t(r.value),className:`px-3 py-1 rounded-md text-xs font-semibold transition-all ${e===r.value?"bg-primary text-white shadow-sm":"text-text-muted hover:text-text-main hover:bg-black/5 dark:hover:bg-white/5"}`,children:r.label},r.value))})]}),(0,s.jsxs)("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-3",children:[(0,s.jsx)(C,{icon:"generating_tokens",label:"Total Tokens",value:(0,n.VK)(y.totalTokens),subValue:`${(0,n.xW)(y.totalRequests)} requests`}),(0,s.jsx)(C,{icon:"input",label:"Input Tokens",value:(0,n.VK)(y.promptTokens),color:"text-primary"}),(0,s.jsx)(C,{icon:"output",label:"Output Tokens",value:(0,n.VK)(y.completionTokens),color:"text-emerald-500"}),(0,s.jsx)(C,{icon:"payments",label:"Est. Cost",value:(0,n.F0)(y.totalCost),color:"text-amber-500"})]}),(0,s.jsx)(S,{sections:[{title:"Infrastructure",items:[{icon:"group",label:"Accounts",value:y.uniqueAccounts||0},{icon:"dns",label:"Providers",value:f,color:"text-indigo-500"},{icon:"vpn_key",label:"API Keys",value:y.uniqueApiKeys||0},{icon:"model_training",label:"Models",value:y.uniqueModels||0}]},{title:"Performance",items:[{icon:"speed",label:"Avg Tokens/Req",value:(0,n.VK)(j),color:"text-cyan-500"},{icon:"request_quote",label:"Cost/Req",value:(0,n.F0)(v),color:"text-orange-500"},{icon:"compare_arrows",label:"I/O Ratio",value:`${N}x`,color:"text-violet-500"},{icon:"swap_horiz",label:"Fallback Rate",value:`${Number(y.fallbackRatePct||0).toFixed(1)}%`,color:"text-amber-500"}]},{title:"Highlights",wideValues:!0,items:[{icon:"star",label:"Top Model",value:p,color:"text-pink-500"},{icon:"cloud",label:"Top Provider",value:h,color:"text-teal-500"},{icon:"today",label:"Busiest Day",value:b,color:"text-rose-500"},{icon:"network_node",label:"Diversity",value:`${g.toFixed(1)}%`,color:"text-sky-500"}]}]}),(0,s.jsxs)("div",{className:"grid grid-cols-1 lg:grid-cols-[2fr_1fr] gap-4 items-stretch",children:[(0,s.jsx)(A,{activityMap:r?.activityMap}),(0,s.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,s.jsx)(L,{activityMap:r?.activityMap}),(0,s.jsx)(E,{activityMap:r?.activityMap})]})]}),(0,s.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[(0,s.jsx)(T,{dailyTrend:r?.dailyTrend}),(0,s.jsx)($,{byProvider:r?.byProvider})]}),(0,s.jsx)(D,{dailyByModel:r?.dailyByModel,modelNames:r?.modelNames}),(0,s.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[(0,s.jsx)(M,{byAccount:r?.byAccount}),(0,s.jsx)(O,{byApiKey:r?.byApiKey})]}),(0,s.jsx)(P,{byProvider:r?.byProvider}),(0,s.jsx)(R,{byApiKey:r?.byApiKey}),(0,s.jsx)(_,{byModel:r?.byModel,summary:y})]})}},49007:(e,t,r)=>{r.d(t,{v:()=>s,B:()=>a});let s={name:"OmniRoute",description:"AI Gateway for Multi-Provider LLMs",version:"3.7.3"},a={storageKey:"theme",defaultTheme:"system"}},51503:(e,t,r)=>{r.d(t,{default:()=>l});var s=r(95155),a=r(12115);function l({searchValue:e="",onSearchChange:t,placeholder:r="Search...",filters:o=[],activeFilters:n={},onFilterChange:i,children:c}){let[d,x]=(0,a.useState)(null),m=(0,a.useCallback)(()=>{t(""),o.forEach(e=>i(e.key,"")),x(null)},[t,o,i]),u=e||Object.values(n).some(e=>e&&""!==e);return(0,s.jsxs)("div",{style:{display:"flex",flexWrap:"wrap",gap:"8px",alignItems:"center",padding:"8px 0"},children:[(0,s.jsxs)("div",{style:{position:"relative",flex:"1 1 200px",minWidth:"200px"},children:[(0,s.jsx)("input",{type:"text",value:e,onChange:e=>t(e.target.value),placeholder:r,style:{width:"100%",padding:"8px 12px 8px 32px",borderRadius:"6px",border:"1px solid rgba(255,255,255,0.1)",background:"rgba(255,255,255,0.05)",color:"var(--text-primary, #e0e0e0)",fontSize:"13px",outline:"none"}}),(0,s.jsx)("span",{style:{position:"absolute",left:"10px",top:"50%",transform:"translateY(-50%)",opacity:.4,fontSize:"14px",pointerEvents:"none"},children:"\uD83D\uDD0D"})]}),o.map(e=>(0,s.jsxs)("div",{style:{position:"relative"},children:[(0,s.jsxs)("button",{onClick:()=>x(d===e.key?null:e.key),style:{padding:"6px 12px",borderRadius:"6px",border:`1px solid ${n[e.key]?"rgba(99,102,241,0.5)":"rgba(255,255,255,0.1)"}`,background:n[e.key]?"rgba(99,102,241,0.15)":"rgba(255,255,255,0.05)",color:n[e.key]?"#818cf8":"var(--text-secondary, #888)",fontSize:"12px",cursor:"pointer",whiteSpace:"nowrap"},children:[e.label,n[e.key]?` \xb7 ${n[e.key]}`:""]}),d===e.key&&(0,s.jsxs)("div",{style:{position:"absolute",top:"100%",left:0,marginTop:"4px",background:"rgba(20,20,30,0.95)",border:"1px solid rgba(255,255,255,0.1)",borderRadius:"8px",padding:"4px",zIndex:50,minWidth:"120px",backdropFilter:"blur(12px)"},children:[(0,s.jsx)("button",{onClick:()=>{i(e.key,""),x(null)},style:{display:"block",width:"100%",padding:"6px 12px",textAlign:"left",background:"none",border:"none",color:"#888",fontSize:"12px",cursor:"pointer",borderRadius:"4px"},children:"All"}),(e.options||[]).map(t=>(0,s.jsx)("button",{onClick:()=>{i(e.key,t),x(null)},style:{display:"block",width:"100%",padding:"6px 12px",textAlign:"left",background:n[e.key]===t?"rgba(99,102,241,0.2)":"none",border:"none",color:n[e.key]===t?"#818cf8":"var(--text-primary, #e0e0e0)",fontSize:"12px",cursor:"pointer",borderRadius:"4px"},children:t},t))]})]},e.key)),u&&(0,s.jsx)("button",{onClick:m,style:{padding:"6px 12px",borderRadius:"6px",border:"1px solid rgba(239,68,68,0.3)",background:"rgba(239,68,68,0.1)",color:"#ef4444",fontSize:"12px",cursor:"pointer"},children:"Clear"}),c]})}},54128:(e,t,r)=>{r.d(t,{default:()=>l});var s=r(95155),a=r(12115);function l({columns:e=[],visible:t={},onToggle:r}){let[o,n]=(0,a.useState)(!1),i=(0,a.useRef)(null);return(0,a.useEffect)(()=>{if(!o)return;let e=e=>{i.current&&!i.current.contains(e.target)&&n(!1)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[o]),(0,s.jsxs)("div",{ref:i,style:{position:"relative"},children:[(0,s.jsxs)("button",{onClick:()=>n(!o),title:"Toggle columns",style:{padding:"6px 10px",borderRadius:"6px",border:"1px solid rgba(255,255,255,0.1)",background:"rgba(255,255,255,0.05)",color:"var(--text-secondary, #888)",fontSize:"13px",cursor:"pointer",display:"flex",alignItems:"center",gap:"4px"},children:[(0,s.jsx)("span",{style:{fontSize:"14px"},children:"⚙️"}),"Columns"]}),o&&(0,s.jsx)("div",{style:{position:"absolute",top:"100%",right:0,marginTop:"4px",background:"rgba(20,20,30,0.95)",border:"1px solid rgba(255,255,255,0.1)",borderRadius:"8px",padding:"8px",zIndex:50,minWidth:"160px",backdropFilter:"blur(12px)"},children:e.map(e=>(0,s.jsxs)("label",{style:{display:"flex",alignItems:"center",gap:"8px",padding:"4px 8px",cursor:"pointer",fontSize:"12px",color:t[e.key]?"var(--text-primary, #e0e0e0)":"var(--text-secondary, #888)",borderRadius:"4px"},children:[(0,s.jsx)("input",{type:"checkbox",checked:t[e.key]??!0,onChange:()=>r(e.key),style:{accentColor:"#6366f1"}}),e.label]},e.key))})]})}},55846:(e,t,r)=>{r.d(t,{ThemeProvider:()=>o});var s=r(95155),a=r(12115),l=r(76851);function o({children:e}){let{initTheme:t}=(0,l.A)();return(0,a.useEffect)(()=>{t()},[t]),(0,s.jsx)(s.Fragment,{children:e})}},61580:(e,t,r)=>{r.d(t,{default:()=>c});var s=r(95155),a=r(67671),l=r(12115);let o={success:"✓",error:"✕",warning:"⚠",info:"ℹ"},n={success:{bg:"rgba(16, 185, 129, 0.15)",border:"rgba(16, 185, 129, 0.4)",icon:"#10b981"},error:{bg:"rgba(239, 68, 68, 0.15)",border:"rgba(239, 68, 68, 0.4)",icon:"#ef4444"},warning:{bg:"rgba(245, 158, 11, 0.15)",border:"rgba(245, 158, 11, 0.4)",icon:"#f59e0b"},info:{bg:"rgba(59, 130, 246, 0.15)",border:"rgba(59, 130, 246, 0.4)",icon:"#3b82f6"}};function i({notification:e,onDismiss:t}){let[r,a]=(0,l.useState)(!1),c=n[e.type]||n.info;return(0,s.jsxs)("div",{role:"alert","aria-live":"polite",style:{display:"flex",alignItems:"flex-start",gap:"12px",padding:"14px 16px",borderRadius:"10px",backgroundColor:c.bg,border:`1px solid ${c.border}`,backdropFilter:"blur(12px)",boxShadow:"0 8px 32px rgba(0,0,0,0.2)",minWidth:"320px",maxWidth:"420px",animation:r?"toastOut 0.2s ease-in forwards":"toastIn 0.3s ease-out forwards",transition:"all 0.2s ease"},children:[(0,s.jsx)("span",{style:{fontSize:"18px",color:c.icon,fontWeight:"bold",lineHeight:1,marginTop:"2px"},children:o[e.type]}),(0,s.jsxs)("div",{style:{flex:1,minWidth:0},children:[e.title&&(0,s.jsx)("div",{style:{fontWeight:600,fontSize:"14px",color:"var(--text-primary, #fff)",marginBottom:"2px"},children:e.title}),(0,s.jsx)("div",{style:{fontSize:"13px",color:"var(--text-secondary, #ccc)",lineHeight:1.4},children:e.message})]}),e.dismissible&&(0,s.jsx)("button",{onClick:()=>{a(!0),setTimeout(()=>t(e.id),200)},"aria-label":"Dismiss notification",style:{background:"none",border:"none",cursor:"pointer",color:"var(--text-secondary, #999)",fontSize:"16px",padding:"0 2px",lineHeight:1,opacity:.6,transition:"opacity 0.15s"},onMouseEnter:e=>e.currentTarget.style.opacity="1",onMouseLeave:e=>e.currentTarget.style.opacity="0.6",children:"\xd7"})]})}function c(){let{notifications:e,removeNotification:t}=(0,a.i)();return 0===e.length?null:(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("style",{children:`
2
2
  @keyframes toastIn {
3
3
  from { opacity: 0; transform: translateX(100%) scale(0.95); }
4
4
  to { opacity: 1; transform: translateX(0) scale(1); }