omniroute 1.4.9 → 1.4.11

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 (226) hide show
  1. package/app/.next/BUILD_ID +1 -1
  2. package/app/.next/app-path-routes-manifest.json +36 -36
  3. package/app/.next/build-manifest.json +2 -2
  4. package/app/.next/prerender-manifest.json +3 -3
  5. package/app/.next/server/app/(dashboard)/dashboard/analytics/page.js +1 -1
  6. package/app/.next/server/app/(dashboard)/dashboard/analytics/page_client-reference-manifest.js +1 -1
  7. package/app/.next/server/app/(dashboard)/dashboard/api-manager/page_client-reference-manifest.js +1 -1
  8. package/app/.next/server/app/(dashboard)/dashboard/audit-log/page_client-reference-manifest.js +1 -1
  9. package/app/.next/server/app/(dashboard)/dashboard/cli-tools/page_client-reference-manifest.js +1 -1
  10. package/app/.next/server/app/(dashboard)/dashboard/combos/page_client-reference-manifest.js +1 -1
  11. package/app/.next/server/app/(dashboard)/dashboard/costs/page.js +1 -1
  12. package/app/.next/server/app/(dashboard)/dashboard/costs/page_client-reference-manifest.js +1 -1
  13. package/app/.next/server/app/(dashboard)/dashboard/endpoint/page_client-reference-manifest.js +1 -1
  14. package/app/.next/server/app/(dashboard)/dashboard/health/page_client-reference-manifest.js +1 -1
  15. package/app/.next/server/app/(dashboard)/dashboard/limits/page.js +1 -1
  16. package/app/.next/server/app/(dashboard)/dashboard/limits/page_client-reference-manifest.js +1 -1
  17. package/app/.next/server/app/(dashboard)/dashboard/logs/page_client-reference-manifest.js +1 -1
  18. package/app/.next/server/app/(dashboard)/dashboard/onboarding/page_client-reference-manifest.js +1 -1
  19. package/app/.next/server/app/(dashboard)/dashboard/page_client-reference-manifest.js +1 -1
  20. package/app/.next/server/app/(dashboard)/dashboard/profile/page_client-reference-manifest.js +1 -1
  21. package/app/.next/server/app/(dashboard)/dashboard/providers/[id]/page.js +1 -1
  22. package/app/.next/server/app/(dashboard)/dashboard/providers/[id]/page_client-reference-manifest.js +1 -1
  23. package/app/.next/server/app/(dashboard)/dashboard/providers/new/page_client-reference-manifest.js +1 -1
  24. package/app/.next/server/app/(dashboard)/dashboard/providers/page_client-reference-manifest.js +1 -1
  25. package/app/.next/server/app/(dashboard)/dashboard/settings/page_client-reference-manifest.js +1 -1
  26. package/app/.next/server/app/(dashboard)/dashboard/settings/pricing/page_client-reference-manifest.js +1 -1
  27. package/app/.next/server/app/(dashboard)/dashboard/translator/page.js +4 -4
  28. package/app/.next/server/app/(dashboard)/dashboard/translator/page_client-reference-manifest.js +1 -1
  29. package/app/.next/server/app/(dashboard)/dashboard/usage/page_client-reference-manifest.js +1 -1
  30. package/app/.next/server/app/_global-error/page_client-reference-manifest.js +1 -1
  31. package/app/.next/server/app/_global-error.html +2 -2
  32. package/app/.next/server/app/_global-error.rsc +1 -1
  33. package/app/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
  34. package/app/.next/server/app/_global-error.segments/_global-error/__PAGE__.segment.rsc +1 -1
  35. package/app/.next/server/app/_global-error.segments/_global-error.segment.rsc +1 -1
  36. package/app/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
  37. package/app/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
  38. package/app/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  39. package/app/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
  40. package/app/.next/server/app/api/auth/login/route.js +1 -1
  41. package/app/.next/server/app/api/auth/login/route_client-reference-manifest.js +1 -1
  42. package/app/.next/server/app/api/auth/logout/route_client-reference-manifest.js +1 -1
  43. package/app/.next/server/app/api/auth/status/route_client-reference-manifest.js +1 -1
  44. package/app/.next/server/app/api/cache/route_client-reference-manifest.js +1 -1
  45. package/app/.next/server/app/api/cache/stats/route_client-reference-manifest.js +1 -1
  46. package/app/.next/server/app/api/cli-tools/antigravity-mitm/alias/route.js +2 -2
  47. package/app/.next/server/app/api/cli-tools/antigravity-mitm/alias/route_client-reference-manifest.js +1 -1
  48. package/app/.next/server/app/api/cli-tools/antigravity-mitm/route.js +2 -2
  49. package/app/.next/server/app/api/cli-tools/antigravity-mitm/route_client-reference-manifest.js +1 -1
  50. package/app/.next/server/app/api/cli-tools/backups/route.js +2 -2
  51. package/app/.next/server/app/api/cli-tools/backups/route_client-reference-manifest.js +1 -1
  52. package/app/.next/server/app/api/cli-tools/claude-settings/route.js +2 -2
  53. package/app/.next/server/app/api/cli-tools/claude-settings/route_client-reference-manifest.js +1 -1
  54. package/app/.next/server/app/api/cli-tools/cline-settings/route.js +1 -1
  55. package/app/.next/server/app/api/cli-tools/cline-settings/route_client-reference-manifest.js +1 -1
  56. package/app/.next/server/app/api/cli-tools/codex-profiles/route.js +1 -1
  57. package/app/.next/server/app/api/cli-tools/codex-profiles/route_client-reference-manifest.js +1 -1
  58. package/app/.next/server/app/api/cli-tools/codex-settings/route.js +2 -2
  59. package/app/.next/server/app/api/cli-tools/codex-settings/route_client-reference-manifest.js +1 -1
  60. package/app/.next/server/app/api/cli-tools/droid-settings/route.js +2 -2
  61. package/app/.next/server/app/api/cli-tools/droid-settings/route_client-reference-manifest.js +1 -1
  62. package/app/.next/server/app/api/cli-tools/guide-settings/[toolId]/route_client-reference-manifest.js +1 -1
  63. package/app/.next/server/app/api/cli-tools/kilo-settings/route.js +1 -1
  64. package/app/.next/server/app/api/cli-tools/kilo-settings/route_client-reference-manifest.js +1 -1
  65. package/app/.next/server/app/api/cli-tools/openclaw-settings/route.js +2 -2
  66. package/app/.next/server/app/api/cli-tools/openclaw-settings/route_client-reference-manifest.js +1 -1
  67. package/app/.next/server/app/api/cli-tools/runtime/[toolId]/route.js +2 -2
  68. package/app/.next/server/app/api/cli-tools/runtime/[toolId]/route_client-reference-manifest.js +1 -1
  69. package/app/.next/server/app/api/cli-tools/status/route.js +2 -2
  70. package/app/.next/server/app/api/cli-tools/status/route_client-reference-manifest.js +1 -1
  71. package/app/.next/server/app/api/cloud/auth/route_client-reference-manifest.js +1 -1
  72. package/app/.next/server/app/api/cloud/credentials/update/route_client-reference-manifest.js +1 -1
  73. package/app/.next/server/app/api/cloud/model/resolve/route_client-reference-manifest.js +1 -1
  74. package/app/.next/server/app/api/cloud/models/alias/route_client-reference-manifest.js +1 -1
  75. package/app/.next/server/app/api/combos/[id]/route_client-reference-manifest.js +1 -1
  76. package/app/.next/server/app/api/combos/metrics/route_client-reference-manifest.js +1 -1
  77. package/app/.next/server/app/api/combos/route.js +1 -1
  78. package/app/.next/server/app/api/combos/route_client-reference-manifest.js +1 -1
  79. package/app/.next/server/app/api/combos/test/route_client-reference-manifest.js +1 -1
  80. package/app/.next/server/app/api/compliance/audit-log/route_client-reference-manifest.js +1 -1
  81. package/app/.next/server/app/api/db-backups/export/route_client-reference-manifest.js +1 -1
  82. package/app/.next/server/app/api/db-backups/exportAll/route_client-reference-manifest.js +1 -1
  83. package/app/.next/server/app/api/db-backups/import/route_client-reference-manifest.js +1 -1
  84. package/app/.next/server/app/api/db-backups/route_client-reference-manifest.js +1 -1
  85. package/app/.next/server/app/api/evals/[suiteId]/route_client-reference-manifest.js +1 -1
  86. package/app/.next/server/app/api/evals/route_client-reference-manifest.js +1 -1
  87. package/app/.next/server/app/api/fallback/chains/route_client-reference-manifest.js +1 -1
  88. package/app/.next/server/app/api/init/route_client-reference-manifest.js +1 -1
  89. package/app/.next/server/app/api/keys/[id]/route_client-reference-manifest.js +1 -1
  90. package/app/.next/server/app/api/keys/route.js +1 -1
  91. package/app/.next/server/app/api/keys/route_client-reference-manifest.js +1 -1
  92. package/app/.next/server/app/api/logs/console/route_client-reference-manifest.js +1 -1
  93. package/app/.next/server/app/api/models/alias/route_client-reference-manifest.js +1 -1
  94. package/app/.next/server/app/api/models/availability/route_client-reference-manifest.js +1 -1
  95. package/app/.next/server/app/api/models/catalog/route_client-reference-manifest.js +1 -1
  96. package/app/.next/server/app/api/models/route.js +1 -1
  97. package/app/.next/server/app/api/models/route_client-reference-manifest.js +1 -1
  98. package/app/.next/server/app/api/monitoring/health/route.js +1 -1
  99. package/app/.next/server/app/api/monitoring/health/route_client-reference-manifest.js +1 -1
  100. package/app/.next/server/app/api/oauth/[provider]/[action]/route_client-reference-manifest.js +1 -1
  101. package/app/.next/server/app/api/oauth/cursor/auto-import/route_client-reference-manifest.js +1 -1
  102. package/app/.next/server/app/api/oauth/cursor/import/route_client-reference-manifest.js +1 -1
  103. package/app/.next/server/app/api/oauth/kiro/auto-import/route_client-reference-manifest.js +1 -1
  104. package/app/.next/server/app/api/oauth/kiro/import/route_client-reference-manifest.js +1 -1
  105. package/app/.next/server/app/api/oauth/kiro/social-authorize/route_client-reference-manifest.js +1 -1
  106. package/app/.next/server/app/api/oauth/kiro/social-exchange/route_client-reference-manifest.js +1 -1
  107. package/app/.next/server/app/api/policies/route_client-reference-manifest.js +1 -1
  108. package/app/.next/server/app/api/pricing/defaults/route_client-reference-manifest.js +1 -1
  109. package/app/.next/server/app/api/pricing/models/route_client-reference-manifest.js +1 -1
  110. package/app/.next/server/app/api/pricing/route_client-reference-manifest.js +1 -1
  111. package/app/.next/server/app/api/provider-metrics/route_client-reference-manifest.js +1 -1
  112. package/app/.next/server/app/api/provider-models/route_client-reference-manifest.js +1 -1
  113. package/app/.next/server/app/api/provider-nodes/[id]/route_client-reference-manifest.js +1 -1
  114. package/app/.next/server/app/api/provider-nodes/route_client-reference-manifest.js +1 -1
  115. package/app/.next/server/app/api/provider-nodes/validate/route_client-reference-manifest.js +1 -1
  116. package/app/.next/server/app/api/providers/[id]/models/route_client-reference-manifest.js +1 -1
  117. package/app/.next/server/app/api/providers/[id]/route_client-reference-manifest.js +1 -1
  118. package/app/.next/server/app/api/providers/[id]/test/route_client-reference-manifest.js +1 -1
  119. package/app/.next/server/app/api/providers/client/route_client-reference-manifest.js +1 -1
  120. package/app/.next/server/app/api/providers/route.js +1 -1
  121. package/app/.next/server/app/api/providers/route_client-reference-manifest.js +1 -1
  122. package/app/.next/server/app/api/providers/test-batch/route_client-reference-manifest.js +1 -1
  123. package/app/.next/server/app/api/providers/validate/route_client-reference-manifest.js +1 -1
  124. package/app/.next/server/app/api/rate-limit/route_client-reference-manifest.js +1 -1
  125. package/app/.next/server/app/api/rate-limits/route_client-reference-manifest.js +1 -1
  126. package/app/.next/server/app/api/resilience/reset/route_client-reference-manifest.js +1 -1
  127. package/app/.next/server/app/api/resilience/route_client-reference-manifest.js +1 -1
  128. package/app/.next/server/app/api/restart/route_client-reference-manifest.js +1 -1
  129. package/app/.next/server/app/api/sessions/route_client-reference-manifest.js +1 -1
  130. package/app/.next/server/app/api/settings/combo-defaults/route_client-reference-manifest.js +1 -1
  131. package/app/.next/server/app/api/settings/ip-filter/route_client-reference-manifest.js +1 -1
  132. package/app/.next/server/app/api/settings/proxy/route_client-reference-manifest.js +1 -1
  133. package/app/.next/server/app/api/settings/proxy/test/route_client-reference-manifest.js +1 -1
  134. package/app/.next/server/app/api/settings/require-login/route_client-reference-manifest.js +1 -1
  135. package/app/.next/server/app/api/settings/route.js +1 -1
  136. package/app/.next/server/app/api/settings/route_client-reference-manifest.js +1 -1
  137. package/app/.next/server/app/api/settings/system-prompt/route_client-reference-manifest.js +1 -1
  138. package/app/.next/server/app/api/settings/thinking-budget/route_client-reference-manifest.js +1 -1
  139. package/app/.next/server/app/api/shutdown/route_client-reference-manifest.js +1 -1
  140. package/app/.next/server/app/api/storage/health/route_client-reference-manifest.js +1 -1
  141. package/app/.next/server/app/api/sync/cloud/route_client-reference-manifest.js +1 -1
  142. package/app/.next/server/app/api/sync/initialize/route_client-reference-manifest.js +1 -1
  143. package/app/.next/server/app/api/tags/route_client-reference-manifest.js +1 -1
  144. package/app/.next/server/app/api/telemetry/summary/route_client-reference-manifest.js +1 -1
  145. package/app/.next/server/app/api/token-health/route_client-reference-manifest.js +1 -1
  146. package/app/.next/server/app/api/translator/detect/route_client-reference-manifest.js +1 -1
  147. package/app/.next/server/app/api/translator/history/route_client-reference-manifest.js +1 -1
  148. package/app/.next/server/app/api/translator/load/route_client-reference-manifest.js +1 -1
  149. package/app/.next/server/app/api/translator/save/route_client-reference-manifest.js +1 -1
  150. package/app/.next/server/app/api/translator/send/route_client-reference-manifest.js +1 -1
  151. package/app/.next/server/app/api/translator/translate/route_client-reference-manifest.js +1 -1
  152. package/app/.next/server/app/api/usage/[connectionId]/route_client-reference-manifest.js +1 -1
  153. package/app/.next/server/app/api/usage/analytics/route_client-reference-manifest.js +1 -1
  154. package/app/.next/server/app/api/usage/budget/route_client-reference-manifest.js +1 -1
  155. package/app/.next/server/app/api/usage/call-logs/[id]/route_client-reference-manifest.js +1 -1
  156. package/app/.next/server/app/api/usage/call-logs/route_client-reference-manifest.js +1 -1
  157. package/app/.next/server/app/api/usage/history/route_client-reference-manifest.js +1 -1
  158. package/app/.next/server/app/api/usage/logs/route_client-reference-manifest.js +1 -1
  159. package/app/.next/server/app/api/usage/proxy-logs/route_client-reference-manifest.js +1 -1
  160. package/app/.next/server/app/api/usage/request-logs/route_client-reference-manifest.js +1 -1
  161. package/app/.next/server/app/api/v1/api/chat/route_client-reference-manifest.js +1 -1
  162. package/app/.next/server/app/api/v1/audio/speech/route_client-reference-manifest.js +1 -1
  163. package/app/.next/server/app/api/v1/audio/transcriptions/route_client-reference-manifest.js +1 -1
  164. package/app/.next/server/app/api/v1/chat/completions/route_client-reference-manifest.js +1 -1
  165. package/app/.next/server/app/api/v1/embeddings/route_client-reference-manifest.js +1 -1
  166. package/app/.next/server/app/api/v1/images/generations/route_client-reference-manifest.js +1 -1
  167. package/app/.next/server/app/api/v1/messages/count_tokens/route_client-reference-manifest.js +1 -1
  168. package/app/.next/server/app/api/v1/messages/route_client-reference-manifest.js +1 -1
  169. package/app/.next/server/app/api/v1/models/route_client-reference-manifest.js +1 -1
  170. package/app/.next/server/app/api/v1/moderations/route_client-reference-manifest.js +1 -1
  171. package/app/.next/server/app/api/v1/providers/[provider]/chat/completions/route_client-reference-manifest.js +1 -1
  172. package/app/.next/server/app/api/v1/providers/[provider]/embeddings/route_client-reference-manifest.js +1 -1
  173. package/app/.next/server/app/api/v1/providers/[provider]/images/generations/route_client-reference-manifest.js +1 -1
  174. package/app/.next/server/app/api/v1/rerank/route_client-reference-manifest.js +1 -1
  175. package/app/.next/server/app/api/v1/responses/route_client-reference-manifest.js +1 -1
  176. package/app/.next/server/app/api/v1/route_client-reference-manifest.js +1 -1
  177. package/app/.next/server/app/api/v1beta/models/[...path]/route_client-reference-manifest.js +1 -1
  178. package/app/.next/server/app/api/v1beta/models/route_client-reference-manifest.js +1 -1
  179. package/app/.next/server/app/callback/page_client-reference-manifest.js +1 -1
  180. package/app/.next/server/app/docs/page.js +1 -1
  181. package/app/.next/server/app/docs/page_client-reference-manifest.js +1 -1
  182. package/app/.next/server/app/forbidden/page_client-reference-manifest.js +1 -1
  183. package/app/.next/server/app/forgot-password/page.js +1 -1
  184. package/app/.next/server/app/forgot-password/page_client-reference-manifest.js +1 -1
  185. package/app/.next/server/app/landing/page_client-reference-manifest.js +1 -1
  186. package/app/.next/server/app/login/page.js +1 -1
  187. package/app/.next/server/app/login/page_client-reference-manifest.js +1 -1
  188. package/app/.next/server/app/page_client-reference-manifest.js +1 -1
  189. package/app/.next/server/app/privacy/page_client-reference-manifest.js +1 -1
  190. package/app/.next/server/app/terms/page_client-reference-manifest.js +1 -1
  191. package/app/.next/server/app-paths-manifest.json +36 -36
  192. package/app/.next/server/chunks/1259.js +1 -1
  193. package/app/.next/server/chunks/1960.js +1 -1
  194. package/app/.next/server/chunks/1990.js +1 -1
  195. package/app/.next/server/chunks/2180.js +3 -1
  196. package/app/.next/server/chunks/2910.js +3 -1
  197. package/app/.next/server/chunks/3498.js +5 -3
  198. package/app/.next/server/chunks/4488.js +3 -1
  199. package/app/.next/server/chunks/9824.js +2 -2
  200. package/app/.next/server/middleware.js +3 -1
  201. package/app/.next/server/pages/500.html +2 -2
  202. package/app/.next/server/server-reference-manifest.js +1 -1
  203. package/app/.next/server/server-reference-manifest.json +1 -1
  204. package/app/.next/static/chunks/{5846-756d72eb0e01a60c.js → 5846-19c878280decbd16.js} +1 -1
  205. package/app/.next/static/chunks/{993-961f6e199b93539a.js → 993-e3050ebfd4f5032f.js} +1 -1
  206. package/app/.next/static/chunks/app/(dashboard)/dashboard/analytics/page-a50474b6ebdf468a.js +1 -0
  207. package/app/.next/static/chunks/app/(dashboard)/dashboard/cli-tools/{page-012be9f38cda4c4a.js → page-ad885fdf9806e9a6.js} +1 -1
  208. package/app/.next/static/chunks/app/(dashboard)/dashboard/costs/page-08f3ed204d01b6a0.js +1 -0
  209. package/app/.next/static/chunks/app/(dashboard)/dashboard/limits/page-fbe1442b61df950a.js +1 -0
  210. package/app/.next/static/chunks/app/(dashboard)/dashboard/providers/[id]/page-6b6d62c5872aee46.js +1 -0
  211. package/app/.next/static/chunks/app/(dashboard)/dashboard/translator/page-b351778975cb8622.js +4 -0
  212. package/app/.next/static/chunks/app/forgot-password/page-a440e0c1675842bf.js +1 -0
  213. package/app/.next/static/chunks/app/login/page-164f6b6b41167c5a.js +1 -0
  214. package/app/.next/static/css/{a0c29bb208bb9dfe.css → e90887a86e63903f.css} +1 -1
  215. package/app/node_modules/better-sqlite3/build/Release/better_sqlite3.node +0 -0
  216. package/app/package.json +1 -1
  217. package/package.json +1 -1
  218. package/app/.next/static/chunks/app/(dashboard)/dashboard/analytics/page-3fcbbdb2221f0b0c.js +0 -1
  219. package/app/.next/static/chunks/app/(dashboard)/dashboard/costs/page-f256689b8410bd74.js +0 -1
  220. package/app/.next/static/chunks/app/(dashboard)/dashboard/limits/page-a5a48afa8c125ada.js +0 -1
  221. package/app/.next/static/chunks/app/(dashboard)/dashboard/providers/[id]/page-62c6fceede3a5549.js +0 -1
  222. package/app/.next/static/chunks/app/(dashboard)/dashboard/translator/page-75c8b38a55e13042.js +0 -4
  223. package/app/.next/static/chunks/app/forgot-password/page-057ea91c6f140e0b.js +0 -1
  224. package/app/.next/static/chunks/app/login/page-c1d7bfab91a7877c.js +0 -1
  225. /package/app/.next/static/{oaQaCPrOo77oe3OAEMAe- → g7Mie-iq39oZ7ts610YtL}/_buildManifest.js +0 -0
  226. /package/app/.next/static/{oaQaCPrOo77oe3OAEMAe- → g7Mie-iq39oZ7ts610YtL}/_ssgManifest.js +0 -0
@@ -0,0 +1 @@
1
+ (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[3700],{14031:(e,t,s)=>{Promise.resolve().then(s.bind(s,70595))},70595:(e,t,s)=>{"use strict";s.r(t),s.d(t,{default:()=>h});var a=s(95155),l=s(12115),i=s(40993),r=s(50910),d=s(67671);function n({value:e,max:t,warningAt:s=.8}){let l=t>0?Math.min(e/t*100,100):0,i=t>0?e/t:0;return(0,a.jsxs)("div",{className:"w-full",children:[(0,a.jsxs)("div",{className:"flex justify-between text-xs mb-1",children:[(0,a.jsxs)("span",{className:"text-text-muted",children:["$",e.toFixed(2)]}),(0,a.jsxs)("span",{className:"text-text-muted",children:["$",t.toFixed(2)]})]}),(0,a.jsx)("div",{className:"w-full h-2 rounded-full bg-surface/50 overflow-hidden",children:(0,a.jsx)("div",{className:"h-full rounded-full transition-all duration-500",style:{width:`${l}%`,backgroundColor:i>=1?"#ef4444":i>=s?"#f59e0b":"#22c55e"}})})]})}function o(){let e=(0,r.c)("usage"),[t,s]=(0,l.useState)([]),[o,c]=(0,l.useState)(null),[m,x]=(0,l.useState)(null),[u,p]=(0,l.useState)(!0),[h,g]=(0,l.useState)(!1),[b,f]=(0,l.useState)({dailyLimitUsd:"",monthlyLimitUsd:"",warningThreshold:"80"}),j=(0,d.i)();(0,l.useEffect)(()=>{fetch("/api/keys").then(e=>e.json()).then(e=>{let t=Array.isArray(e)?e:e.keys||[];s(t),t.length>0&&c(t[0].id),p(!1)}).catch(()=>p(!1))},[]);let y=(0,l.useCallback)(async()=>{if(o)try{let e=await fetch(`/api/usage/budget?apiKeyId=${o}`);if(e.ok){let t=await e.json();x(t),t.dailyLimitUsd&&f(e=>({...e,dailyLimitUsd:String(t.dailyLimitUsd)})),t.monthlyLimitUsd&&f(e=>({...e,monthlyLimitUsd:String(t.monthlyLimitUsd)})),t.warningThreshold&&f(e=>({...e,warningThreshold:String(t.warningThreshold)}))}}catch{}},[o]);(0,l.useEffect)(()=>{y()},[y]);let v=async()=>{g(!0);try{(await fetch("/api/usage/budget",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({apiKeyId:o,dailyLimitUsd:b.dailyLimitUsd?parseFloat(b.dailyLimitUsd):null,monthlyLimitUsd:b.monthlyLimitUsd?parseFloat(b.monthlyLimitUsd):null,warningThreshold:parseInt(b.warningThreshold)||80})})).ok?(j.success("Budget limits saved"),await y()):j.error("Failed to save budget")}catch{j.error("Failed to save budget")}finally{g(!1)}};if(u)return(0,a.jsxs)("div",{className:"flex items-center gap-2 text-text-muted p-8 animate-pulse",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[20px]",children:"account_balance_wallet"}),"Loading budget data..."]});if(0===t.length)return(0,a.jsx)(i.pp,{icon:"vpn_key",title:"No API Keys",description:"Add API keys first to set up budget limits."});let N=m?.dailyLimitUsd||parseFloat(b.dailyLimitUsd)||0,w=m?.monthlyLimitUsd||parseFloat(b.monthlyLimitUsd)||0,C=m?.totalCostToday||0,k=m?.totalCostMonth||0,S=(parseInt(b.warningThreshold)||80)/100;return(0,a.jsxs)("div",{className:"flex flex-col gap-6",children:[(0,a.jsxs)(i.Zp,{className:"p-6",children:[(0,a.jsxs)("div",{className:"flex items-center gap-3 mb-4",children:[(0,a.jsx)("div",{className:"p-2 rounded-lg bg-emerald-500/10 text-emerald-500",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[20px]",children:"account_balance_wallet"})}),(0,a.jsx)("h3",{className:"text-lg font-semibold",children:e("budgetManagement")})]}),(0,a.jsxs)("div",{className:"mb-4",children:[(0,a.jsx)("label",{className:"text-sm text-text-muted mb-1 block",children:e("apiKey")}),(0,a.jsx)("select",{value:o||"",onChange:e=>c(e.target.value),className:"w-full md:w-auto px-3 py-2 rounded-lg border border-border/50 bg-surface/30 text-text-main text-sm focus:outline-none focus:ring-1 focus:ring-primary",children:t.map(e=>(0,a.jsxs)("option",{value:e.id,children:[e.name||e.id," ",e.provider?`(${e.provider})`:""]},e.id))})]}),(0,a.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4 mb-6",children:[(0,a.jsxs)("div",{className:"p-4 rounded-lg border border-border/30 bg-surface/20",children:[(0,a.jsx)("p",{className:"text-sm text-text-muted mb-2",children:"Today's Spend"}),(0,a.jsxs)("p",{className:"text-2xl font-bold text-text-main",children:["$",C.toFixed(2)]}),N>0&&(0,a.jsx)(n,{value:C,max:N,warningAt:S})]}),(0,a.jsxs)("div",{className:"p-4 rounded-lg border border-border/30 bg-surface/20",children:[(0,a.jsx)("p",{className:"text-sm text-text-muted mb-2",children:e("thisMonth")}),(0,a.jsxs)("p",{className:"text-2xl font-bold text-text-main",children:["$",k.toFixed(2)]}),w>0&&(0,a.jsx)(n,{value:k,max:w,warningAt:S})]})]}),(0,a.jsxs)("div",{className:"border-t border-border/30 pt-4",children:[(0,a.jsx)("p",{className:"text-sm font-medium mb-3",children:e("setLimits")}),(0,a.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4 mb-4",children:[(0,a.jsx)(i.pd,{label:"Daily Limit (USD)",type:"number",step:"0.01",min:"0",placeholder:"e.g. 5.00",value:b.dailyLimitUsd,onChange:e=>f({...b,dailyLimitUsd:e.target.value})}),(0,a.jsx)(i.pd,{label:"Monthly Limit (USD)",type:"number",step:"0.01",min:"0",placeholder:"e.g. 50.00",value:b.monthlyLimitUsd,onChange:e=>f({...b,monthlyLimitUsd:e.target.value})}),(0,a.jsx)(i.pd,{label:"Warning Threshold (%)",type:"number",min:"1",max:"100",placeholder:"80",value:b.warningThreshold,onChange:e=>f({...b,warningThreshold:e.target.value})})]}),(0,a.jsx)(i.$n,{variant:"primary",onClick:v,loading:h,children:"Save Limits"})]})]}),m?.budgetCheck&&(0,a.jsx)(i.Zp,{className:"p-4",children:(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[20px]",style:{color:m.budgetCheck.allowed?"#22c55e":"#ef4444"},children:m.budgetCheck.allowed?"check_circle":"block"}),(0,a.jsx)("span",{className:"text-sm",children:m.budgetCheck.allowed?`Budget OK — $${(m.budgetCheck.remaining||0).toFixed(2)} remaining`:"Budget exceeded — requests may be blocked"})]})})]})}let c=["input","output","cached","reasoning","cache_creation"],m={input:"Input",output:"Output",cached:"Cached",reasoning:"Reasoning",cache_creation:"Cache Write"};function x(){let[e,t]=(0,l.useState)({}),[s,d]=(0,l.useState)({}),[n,o]=(0,l.useState)(!0),[c,m]=(0,l.useState)(!1),[x,p]=(0,l.useState)(""),[h,g]=(0,l.useState)(null),[b,f]=(0,l.useState)(new Set),[j,y]=(0,l.useState)(""),[v,N]=(0,l.useState)(new Set),w=(0,r.c)("settings");(0,l.useEffect)(()=>{C()},[]);let C=async()=>{o(!0);try{let[e,s]=await Promise.all([fetch("/api/pricing/models"),fetch("/api/pricing")]);e.ok&&t(await e.json()),s.ok&&d(await s.json())}catch(e){console.error("Failed to load pricing data:",e)}finally{o(!1)}},k=(0,l.useMemo)(()=>Object.entries(e).map(([e,t])=>({alias:e,...t,pricedModels:s[e]?Object.keys(s[e]).length:0})).sort((e,t)=>t.modelCount-e.modelCount),[e,s]),S=(0,l.useMemo)(()=>{if(!j.trim())return k;let e=j.toLowerCase();return k.filter(t=>t.alias.toLowerCase().includes(e)||t.id.toLowerCase().includes(e)||t.models.some(t=>t.id.toLowerCase().includes(e)||t.name.toLowerCase().includes(e)))},[k,j]),L=(0,l.useMemo)(()=>{let e=k.reduce((e,t)=>e+t.modelCount,0),t=Object.values(s).reduce((e,t)=>e+Object.keys(t).length,0);return{providers:k.length,totalModels:e,pricedCount:t}},[k,s]),U=(0,l.useCallback)(e=>{f(t=>{let s=new Set(t);return s.has(e)?s.delete(e):s.add(e),s})},[]),T=(0,l.useCallback)((e,t,s,a)=>{let l=parseFloat(a);isNaN(l)||l<0||(d(a=>{let i={...a};return i[e]||(i[e]={}),i[e][t]||(i[e][t]={input:0,output:0,cached:0,reasoning:0,cache_creation:0}),i[e][t]={...i[e][t],[s]:l},i}),N(t=>new Set(t).add(e)))},[]),$=(0,l.useCallback)(async e=>{m(!0),p("");try{let t=s[e]||{},a=await fetch("/api/pricing",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({[e]:t})});if(a.ok)p(`✅ ${e.toUpperCase()} saved`),N(t=>{let s=new Set(t);return s.delete(e),s}),setTimeout(()=>p(""),3e3);else{let e=await a.json();p(`❌ Error: ${e.error}`)}}catch(e){p(`❌ Save failed: ${e.message}`)}finally{m(!1)}},[s]),P=(0,l.useCallback)(async e=>{if(confirm(w("resetPricingConfirm",{provider:e.toUpperCase()})))try{let t=await fetch(`/api/pricing?provider=${e}`,{method:"DELETE"});if(t.ok){let s=await t.json();d(s),p(`🔄 ${e.toUpperCase()} reset to defaults`),N(t=>{let s=new Set(t);return s.delete(e),s}),setTimeout(()=>p(""),3e3)}}catch(e){p(`❌ Reset failed: ${e.message}`)}},[]),_=(0,l.useCallback)(e=>{g(t=>t===e?null:e)},[]),O=(0,l.useMemo)(()=>h?S.filter(e=>e.alias===h):S,[S,h]);return n?(0,a.jsx)("div",{className:"flex items-center justify-center py-16",children:(0,a.jsx)("div",{className:"text-text-muted animate-pulse",children:w("loadingPricing")})}):(0,a.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,a.jsxs)("div",{className:"flex items-start justify-between flex-wrap gap-4",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("h2",{className:"text-xl font-bold",children:w("modelPricing")}),(0,a.jsx)("p",{className:"text-text-muted text-sm mt-1",children:w("modelPricingDesc")})]}),(0,a.jsxs)("div",{className:"flex gap-3 text-sm",children:[(0,a.jsxs)("div",{className:"bg-bg-subtle rounded-lg px-3 py-2 text-center",children:[(0,a.jsx)("div",{className:"text-text-muted text-xs font-semibold",children:w("providers")}),(0,a.jsx)("div",{className:"text-lg font-bold",children:L.providers})]}),(0,a.jsxs)("div",{className:"bg-bg-subtle rounded-lg px-3 py-2 text-center",children:[(0,a.jsx)("div",{className:"text-text-muted text-xs font-semibold",children:w("registry")}),(0,a.jsx)("div",{className:"text-lg font-bold",children:L.totalModels})]}),(0,a.jsxs)("div",{className:"bg-bg-subtle rounded-lg px-3 py-2 text-center",children:[(0,a.jsx)("div",{className:"text-text-muted text-xs font-semibold",children:w("priced")}),(0,a.jsx)("div",{className:"text-lg font-bold text-success",children:L.pricedCount})]})]})]}),x&&(0,a.jsx)("div",{className:"px-3 py-2 rounded-lg bg-bg-subtle border border-border text-sm",children:x}),(0,a.jsxs)("div",{className:"flex gap-3 items-center flex-wrap",children:[(0,a.jsxs)("div",{className:"relative flex-1 min-w-[200px]",children:[(0,a.jsx)("span",{className:"material-symbols-outlined absolute left-3 top-1/2 -translate-y-1/2 text-text-muted text-lg",children:"search"}),(0,a.jsx)("input",{type:"text",placeholder:w("searchProvidersModels"),value:j,onChange:e=>y(e.target.value),className:"w-full pl-10 pr-3 py-2 bg-bg-base border border-border rounded-lg focus:outline-none focus:border-primary text-sm"})]}),h&&(0,a.jsxs)("button",{onClick:()=>g(null),className:"px-3 py-2 text-xs bg-primary/10 text-primary border border-primary/20 rounded-lg hover:bg-primary/20 transition-colors flex items-center gap-1",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-sm",children:"close"}),h.toUpperCase()," — ",w("showAll")]})]}),(0,a.jsx)("div",{className:"flex flex-wrap gap-1.5",children:k.map(e=>(0,a.jsxs)("button",{onClick:()=>_(e.alias),className:`px-2.5 py-1 rounded-md text-xs font-medium transition-all ${h===e.alias?"bg-primary text-white shadow-sm":v.has(e.alias)?"bg-yellow-500/15 text-yellow-400 border border-yellow-500/30":"bg-bg-subtle text-text-muted hover:bg-bg-hover border border-transparent"}`,children:[e.alias.toUpperCase()," ",(0,a.jsxs)("span",{className:"opacity-60",children:["(",e.modelCount,")"]})]},e.alias))}),(0,a.jsxs)("div",{className:"flex flex-col gap-2",children:[O.map(e=>(0,a.jsx)(u,{provider:e,pricingData:s[e.alias]||{},isExpanded:b.has(e.alias),isEdited:v.has(e.alias),onToggle:()=>U(e.alias),onPricingChange:(t,s,a)=>T(e.alias,t,s,a),onSave:()=>$(e.alias),onReset:()=>P(e.alias),saving:c},e.alias)),0===O.length&&(0,a.jsx)("div",{className:"text-center py-12 text-text-muted",children:w("noProvidersMatch")})]}),(0,a.jsxs)(i.Zp,{className:"p-4 mt-2",children:[(0,a.jsxs)("h3",{className:"text-sm font-semibold mb-2",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-sm align-middle mr-1",children:"info"}),w("howPricingWorks")]}),(0,a.jsxs)("div",{className:"text-xs text-text-muted space-y-1",children:[(0,a.jsxs)("p",{children:[w("pricingDescInput")," • ",w("pricingDescOutput")," • ",w("pricingDescCached")," •"," ",w("pricingDescReasoning")," • ",w("pricingDescCacheWrite")]}),(0,a.jsx)("p",{children:w("pricingDescFormula")})]})]})]})}function u({provider:e,pricingData:t,isExpanded:s,isEdited:l,onToggle:i,onPricingChange:d,onSave:n,onReset:o,saving:x}){let u=(0,r.c)("settings"),h=Object.keys(t).length,g="oauth"===e.authType?"OAuth":"apikey"===e.authType?"API Key":e.authType;return(0,a.jsxs)("div",{className:`border rounded-lg overflow-hidden transition-colors ${l?"border-yellow-500/40 bg-yellow-500/5":"border-border"}`,children:[(0,a.jsxs)("button",{onClick:i,className:"w-full flex items-center justify-between px-4 py-3 hover:bg-bg-hover/50 transition-colors text-left",children:[(0,a.jsxs)("div",{className:"flex items-center gap-3",children:[(0,a.jsx)("span",{className:`material-symbols-outlined text-lg transition-transform ${s?"rotate-90":""}`,children:"chevron_right"}),(0,a.jsxs)("div",{children:[(0,a.jsx)("span",{className:"font-semibold text-sm",children:e.id.charAt(0).toUpperCase()+e.id.slice(1)}),(0,a.jsxs)("span",{className:"text-text-muted text-xs ml-2",children:["(",e.alias.toUpperCase(),")"]})]}),(0,a.jsx)("span",{className:"px-1.5 py-0.5 bg-bg-subtle text-text-muted text-[10px] rounded uppercase font-semibold",children:g}),(0,a.jsx)("span",{className:"px-1.5 py-0.5 bg-bg-subtle text-text-muted text-[10px] rounded uppercase font-semibold",children:e.format})]}),(0,a.jsxs)("div",{className:"flex items-center gap-3",children:[l&&(0,a.jsx)("span",{className:"text-yellow-500 text-xs font-medium",children:u("unsaved")}),(0,a.jsxs)("span",{className:"text-text-muted text-xs",children:[h,"/",e.modelCount," priced"]}),(0,a.jsx)("div",{className:"w-16 h-1.5 bg-bg-subtle rounded-full overflow-hidden",children:(0,a.jsx)("div",{className:"h-full bg-primary rounded-full transition-all",style:{width:`${e.modelCount>0?Math.round(h/e.modelCount*100):0}%`}})})]})]}),s&&(0,a.jsxs)("div",{className:"border-t border-border",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between px-4 py-2 bg-bg-subtle/50",children:[(0,a.jsxs)("span",{className:"text-xs text-text-muted",children:[e.modelCount," models • ",h," with pricing configured"]}),(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("button",{onClick:e=>{e.stopPropagation(),o()},className:"px-2.5 py-1 text-[11px] text-red-400 hover:bg-red-500/10 rounded border border-red-500/20 transition-colors",children:u("resetDefaults")}),(0,a.jsx)("button",{onClick:e=>{e.stopPropagation(),n()},disabled:x||!l,className:"px-2.5 py-1 text-[11px] bg-primary text-white rounded hover:bg-primary/90 transition-colors disabled:opacity-40",children:u(x?"saving":"saveProvider")})]})]}),(0,a.jsx)("div",{className:"overflow-x-auto",children:(0,a.jsxs)("table",{className:"w-full text-sm",children:[(0,a.jsx)("thead",{className:"text-[11px] text-text-muted uppercase bg-bg-subtle/30",children:(0,a.jsxs)("tr",{children:[(0,a.jsx)("th",{className:"px-4 py-2 text-left font-semibold",children:u("model")}),c.map(e=>(0,a.jsx)("th",{className:"px-2 py-2 text-right font-semibold w-24",children:m[e]},e))]})}),(0,a.jsx)("tbody",{className:"divide-y divide-border/50",children:e.models.map(e=>(0,a.jsx)(p,{model:e,pricing:t[e.id],onPricingChange:(t,s)=>d(e.id,t,s)},e.id))})]})})]})]})}function p({model:e,pricing:t,onPricingChange:s}){let l=t&&Object.values(t).some(e=>e>0);return(0,a.jsxs)("tr",{className:"hover:bg-bg-hover/30 group",children:[(0,a.jsx)("td",{className:"px-4 py-1.5",children:(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("span",{className:`w-1.5 h-1.5 rounded-full ${l?"bg-success":"bg-text-muted/30"}`}),(0,a.jsx)("span",{className:"font-medium text-xs",children:e.name}),e.custom&&(0,a.jsx)("span",{className:"px-1 py-0.5 text-[8px] font-bold bg-blue-500/15 text-blue-400 border border-blue-500/20 rounded uppercase",children:"custom"}),(0,a.jsx)("span",{className:"text-text-muted text-[10px] opacity-0 group-hover:opacity-100 transition-opacity",children:e.id})]})}),c.map(e=>(0,a.jsx)("td",{className:"px-2 py-1.5",children:(0,a.jsx)("input",{type:"number",step:"0.01",min:"0",value:t?.[e]||0,onChange:t=>s(e,t.target.value),className:"w-full px-2 py-1 text-right text-xs bg-transparent border border-transparent hover:border-border focus:border-primary focus:bg-bg-base rounded transition-colors outline-none tabular-nums"})},e))]})}function h(){let[e,t]=(0,l.useState)("budget"),s=(0,r.c)("costs"),d=(0,r.c)("settings");return(0,a.jsxs)("div",{className:"flex flex-col gap-6",children:[(0,a.jsx)(i.Iz,{options:[{value:"budget",label:s("budget")},{value:"pricing",label:d("pricing")}],value:e,onChange:t}),"budget"===e&&(0,a.jsx)(o,{}),"pricing"===e&&(0,a.jsx)(x,{})]})}}},e=>{e.O(0,[3418,8500,9751,782,6458,5846,993,8441,3794,7358],()=>e(e.s=14031)),_N_E=e.O()}]);
@@ -0,0 +1 @@
1
+ (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[1066],{39387:(e,t,s)=>{Promise.resolve().then(s.bind(s,73732))},73732:(e,t,s)=>{"use strict";s.r(t),s.d(t,{default:()=>j});var a=s(95155),l=s(12115),r=s(40993),n=s(50910),i=s(5772),c=s(35144);function o(e){let t="string"==typeof e?e.trim():"";if(!t)return{key:"unknown",label:"Unknown",variant:"default",rank:0,raw:null};let s=t.toUpperCase();return s.includes("ENTERPRISE")||s.includes("CORP")||s.includes("ORG")?{key:"enterprise",label:"Enterprise",variant:"info",rank:7,raw:t}:s.includes("TEAM")||s.includes("CHATGPTTEAM")?{key:"team",label:"Team",variant:"info",rank:6,raw:t}:s.includes("BUSINESS")||s.includes("STANDARD")||s.includes("BIZ")?{key:"business",label:"Business",variant:"warning",rank:5,raw:t}:s.includes("ULTRA")?{key:"ultra",label:"Ultra",variant:"success",rank:4,raw:t}:s.includes("PRO")||s.includes("PREMIUM")?{key:"pro",label:"Pro",variant:"primary",rank:3,raw:t}:s.includes("PLUS")||s.includes("PAID")?{key:"plus",label:"Plus",variant:"secondary",rank:2,raw:t}:s.includes("FREE")||s.includes("INDIVIDUAL")||s.includes("BASIC")||s.includes("TRIAL")||s.includes("LEGACY")?{key:"free",label:"Free",variant:"default",rank:1,raw:t}:{key:"unknown",label:t.toLowerCase().split(/[\s_-]+/).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(" ")||"Unknown",variant:"default",rank:0,raw:t}}var d=s(81060),x=s(80927),u=s(92542),m=s(20909);let p={antigravity:{label:"Antigravity",color:"#F59E0B"},github:{label:"GitHub Copilot",color:"#333"},kiro:{label:"Kiro AI",color:"#FF6B35"},codex:{label:"OpenAI Codex",color:"#10A37F"},claude:{label:"Claude Code",color:"#D97757"}},h=[{key:"all",label:"All"},{key:"enterprise",label:"Enterprise"},{key:"team",label:"Team"},{key:"business",label:"Business"},{key:"ultra",label:"Ultra"},{key:"pro",label:"Pro"},{key:"plus",label:"Plus"},{key:"free",label:"Free"},{key:"unknown",label:"Unknown"}];function f(){let e=(0,n.c)("usage"),[t,s]=(0,l.useState)([]),[r,f]=(0,l.useState)({}),[b,g]=(0,l.useState)({}),[j,y]=(0,l.useState)({}),[v,N]=(0,l.useState)(!0),[k,w]=(0,l.useState)(null),[A,E]=(0,l.useState)(!1),[C,I]=(0,l.useState)(120),[S,q]=(0,l.useState)(!0),[M,P]=(0,l.useState)("all"),T=(0,l.useRef)(null),$=(0,l.useRef)(null),_=(0,l.useRef)({}),R=(0,l.useCallback)(async()=>{try{let e=await fetch("/api/providers/client");if(!e.ok)throw Error("Failed");let t=(await e.json()).connections||[];return s(t),t}catch{return s([]),[]}},[]),L=(0,l.useCallback)(async(e,t)=>{let s=Date.now();if(!(s-(_.current[e]||0)<3e4)){_.current[e]=s,g(t=>({...t,[e]:!0})),y(t=>({...t,[e]:null}));try{let s=await fetch(`/api/usage/${e}`);if(!s.ok){let t=(await s.json().catch(()=>({}))).error||s.statusText;if(404===s.status)return;if(401===s.status)return void f(s=>({...s,[e]:{quotas:[],message:t}}));throw Error(`HTTP ${s.status}: ${t}`)}let a=await s.json(),l=function(e,t){if(!t||"object"!=typeof t)return[];let s=[];try{switch(e.toLowerCase()){case"github":default:t.quotas&&Object.entries(t.quotas).forEach(([e,t])=>{s.push({name:e,used:t.used||0,total:t.total||0,resetAt:t.resetAt||null})});break;case"antigravity":t.quotas&&Object.entries(t.quotas).forEach(([e,t])=>{s.push({name:t.displayName||e,modelKey:e,used:t.used||0,total:t.total||0,resetAt:t.resetAt||null,remainingPercentage:t.remainingPercentage})});break;case"codex":t.quotas&&Object.entries(t.quotas).forEach(([e,t])=>{s.push({name:e,used:t.used||0,total:t.total||0,resetAt:t.resetAt||null})});break;case"kiro":t.quotas&&Object.entries(t.quotas).forEach(([e,t])=>{s.push({name:e,used:t.used||0,total:t.total||0,resetAt:t.resetAt||null})});break;case"claude":t.message?s.push({name:"error",used:0,total:0,resetAt:null,message:t.message}):t.quotas&&Object.entries(t.quotas).forEach(([e,t])=>{s.push({name:e,used:t.used||0,total:t.total||0,resetAt:t.resetAt||null})})}}catch(t){return console.error(`Error parsing quota data for ${e}:`,t),[]}let a=(0,c.KC)(e);if(a.length>0){let e=new Map(a.map((e,t)=>[e.id,t]));s.sort((t,s)=>{let a=t.modelKey||t.name,l=s.modelKey||s.name;return(e.get(a)??999)-(e.get(l)??999)})}return s}(t,a);f(t=>({...t,[e]:{quotas:l,plan:a.plan||null,message:a.message||null,raw:a}}))}catch(t){y(s=>({...s,[e]:t.message||"Failed to fetch quota"}))}finally{g(t=>({...t,[e]:!1}))}}},[]),O=(0,l.useCallback)(async(e,t)=>{await L(e,t),w(new Date)},[L]),D=(0,l.useCallback)(async()=>{if(!A){E(!0),I(120);try{let e=(await R()).filter(e=>m.wb.includes(e.provider)&&"oauth"===e.authType);await Promise.all(e.map(e=>L(e.id,e.provider))),w(new Date)}catch(e){console.error("Error refreshing all:",e)}finally{E(!1)}}},[A,R,L]);(0,l.useEffect)(()=>{(async()=>{q(!0),await D(),q(!1)})()},[]),(0,l.useEffect)(()=>{if(!v){T.current&&clearInterval(T.current),$.current&&clearInterval($.current);return}return T.current=setInterval(D,12e4),$.current=setInterval(()=>{I(e=>e<=1?120:e-1)},1e3),()=>{T.current&&clearInterval(T.current),$.current&&clearInterval($.current)}},[v,D]),(0,l.useEffect)(()=>{let e=()=>{document.hidden?(T.current&&clearInterval(T.current),$.current&&clearInterval($.current)):v&&(T.current=setInterval(D,12e4),$.current=setInterval(()=>{I(e=>e<=1?120:e-1)},1e3))};return document.addEventListener("visibilitychange",e),()=>document.removeEventListener("visibilitychange",e)},[v,D]);let U=(0,l.useMemo)(()=>t.filter(e=>m.wb.includes(e.provider)&&"oauth"===e.authType),[t]),F=(0,l.useMemo)(()=>{let e={antigravity:1,github:2,codex:3,claude:4,kiro:5};return[...U].sort((t,s)=>(e[t.provider]||9)-(e[s.provider]||9))},[U]),B=(0,l.useMemo)(()=>{let e={};for(let t of F)e[t.id]=o(r[t.id]?.plan);return e},[F,r]),G=(0,l.useMemo)(()=>{let e={all:F.length,enterprise:0,team:0,business:0,ultra:0,pro:0,free:0,unknown:0};for(let t of F){let s=B[t.id]?.key||"unknown";e[s]=(e[s]||0)+1}return e},[F,B]),K=(0,l.useMemo)(()=>"all"===M?F:F.filter(e=>(B[e.id]?.key||"unknown")===M),[F,B,M]);return S?(0,a.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,a.jsx)(u.CardSkeleton,{}),(0,a.jsx)(u.CardSkeleton,{})]}):0===F.length?(0,a.jsx)(d.default,{padding:"lg",children:(0,a.jsxs)("div",{className:"text-center py-12",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[64px] opacity-15",children:"cloud_off"}),(0,a.jsx)("h3",{className:"mt-4 text-lg font-semibold text-text-main",children:e("noProviders")}),(0,a.jsx)("p",{className:"mt-2 text-sm text-text-muted max-w-[400px] mx-auto",children:"Connect to providers with OAuth to track your API quota limits and usage."})]})}):(0,a.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between flex-wrap gap-3",children:[(0,a.jsxs)("div",{className:"flex items-center gap-3",children:[(0,a.jsx)("h2",{className:"text-lg font-semibold text-text-main m-0",children:e("providerLimits")}),(0,a.jsxs)("span",{className:"text-[13px] text-text-muted",children:[K.length," account",1!==K.length?"s":"",K.length!==F.length?` (filtered from ${F.length})`:""]})]}),(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsxs)("button",{onClick:()=>N(e=>!e),className:"flex items-center gap-1.5 px-3 py-1.5 rounded-lg border border-white/[0.08] bg-transparent cursor-pointer text-text-main text-[13px]",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px]",style:{color:v?"#22c55e":"var(--text-muted)"},children:v?"toggle_on":"toggle_off"}),"Auto-refresh",v&&(0,a.jsxs)("span",{className:"text-xs text-text-muted",children:["(",C,"s)"]})]}),(0,a.jsxs)("button",{onClick:D,disabled:A,className:"flex items-center gap-1.5 px-3.5 py-1.5 rounded-lg bg-white/[0.06] border border-white/10 text-text-main text-[13px] disabled:opacity-50 disabled:cursor-not-allowed cursor-pointer",children:[(0,a.jsx)("span",{className:`material-symbols-outlined text-[16px] ${A?"animate-spin":""}`,children:"refresh"}),"Refresh All"]})]})]}),(0,a.jsx)("div",{className:"flex items-center gap-2 flex-wrap",children:h.map(e=>{if("all"!==e.key&&!G[e.key])return null;let t=M===e.key;return(0,a.jsxs)("button",{onClick:()=>P(e.key),className:"inline-flex items-center gap-1.5 px-2.5 py-1 rounded-full text-xs font-semibold cursor-pointer",style:{border:t?"1px solid var(--primary, #E54D5E)":"1px solid rgba(255,255,255,0.12)",background:t?"rgba(249,120,21,0.14)":"transparent",color:t?"var(--primary, #E54D5E)":"var(--text-muted)"},children:[(0,a.jsx)("span",{children:e.label}),(0,a.jsx)("span",{className:"opacity-85",children:G[e.key]||0})]},e.key)})}),(0,a.jsxs)("div",{className:"rounded-xl border border-white/[0.06] overflow-hidden bg-black/15",children:[(0,a.jsxs)("div",{className:"items-center px-4 py-2.5 border-b border-white/[0.06] text-[11px] font-semibold uppercase tracking-wider text-text-muted",style:{display:"grid",gridTemplateColumns:"280px 1fr 100px 48px"},children:[(0,a.jsx)("div",{children:e("account")}),(0,a.jsx)("div",{children:e("modelQuotas")}),(0,a.jsx)("div",{className:"text-center",children:e("lastUsed")}),(0,a.jsx)("div",{className:"text-center",children:e("actions")})]}),K.map((t,s)=>{let l=r[t.id],n=b[t.id],c=j[t.id],d=p[t.provider]||{label:t.provider,color:"#666"},u=B[t.id]||o(null);return(0,a.jsxs)("div",{className:"items-center px-4 py-3.5 transition-[background] duration-150 hover:bg-white/[0.02]",style:{display:"grid",gridTemplateColumns:"280px 1fr 100px 48px",borderBottom:s<K.length-1?"1px solid rgba(255,255,255,0.04)":"none"},children:[(0,a.jsxs)("div",{className:"flex items-center gap-2.5 min-w-0",children:[(0,a.jsx)("div",{className:"w-8 h-8 rounded-lg flex items-center justify-center overflow-hidden shrink-0",children:(0,a.jsx)(i.default,{src:`/providers/${t.provider}.png`,alt:t.provider,width:32,height:32,className:"object-contain",sizes:"32px"})}),(0,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsx)("div",{className:"text-[13px] font-semibold text-text-main truncate",children:t.name||d.label}),(0,a.jsxs)("div",{className:"flex items-center gap-1.5 mt-0.5",children:[(0,a.jsx)("span",{title:l?.plan?`Raw plan: ${l.plan}`:"No plan from provider",children:(0,a.jsx)(x.default,{variant:u.variant,size:"sm",dot:!0,children:u.label})}),(0,a.jsx)("span",{className:"text-[11px] text-text-muted",children:d.label})]})]})]}),(0,a.jsx)("div",{className:"flex flex-wrap gap-x-3 gap-y-1.5 pr-3",children:n?(0,a.jsxs)("div",{className:"flex items-center gap-1.5 text-text-muted text-xs",children:[(0,a.jsx)("span",{className:"material-symbols-outlined animate-spin text-[14px]",children:"progress_activity"}),"Loading..."]}):c?(0,a.jsxs)("div",{className:"flex items-center gap-1.5 text-xs text-red-500",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"error"}),(0,a.jsx)("span",{className:"overflow-hidden text-ellipsis whitespace-nowrap max-w-[300px]",children:c})]}):l?.message&&(!l.quotas||0===l.quotas.length)?(0,a.jsx)("div",{className:"text-xs text-text-muted italic",children:l.message}):l?.quotas?.length>0?l.quotas.map((e,t)=>{var s,l,r;let n=void 0!==e.remainingPercentage?Math.round(e.remainingPercentage):(s=e.used,(l=e.total)&&0!==l?!s||s<0?100:s>=l?0:Math.round((l-s)/l*100):0),i=n>70?{bar:"#22c55e",text:"#22c55e",bg:"rgba(34,197,94,0.12)"}:n>=30?{bar:"#eab308",text:"#eab308",bg:"rgba(234,179,8,0.12)"}:{bar:"#ef4444",text:"#ef4444",bg:"rgba(239,68,68,0.12)"},c=function(e){if(!e)return null;try{let t=new Date(e)-new Date;if(t<=0)return null;let s=Math.floor(t/36e5),a=Math.floor(t%36e5/6e4);if(s>=24){let e=Math.floor(s/24);return`${e}d ${s%24}h`}return`${s}h ${a}m`}catch{return null}}(e.resetAt),o={"gemini-3-pro-high":"G3 Pro","gemini-3-pro-low":"G3 Pro Low","gemini-3-flash":"G3 Flash","gemini-2.5-flash":"G2.5 Flash","claude-opus-4-6-thinking":"Opus 4.6 Tk","claude-opus-4-5-thinking":"Opus 4.5 Tk","claude-opus-4-5":"Opus 4.5","claude-sonnet-4-5-thinking":"Sonnet 4.5 Tk","claude-sonnet-4-5":"Sonnet 4.5",chat:"Chat",completions:"Completions",premium_interactions:"Premium",session:"Session",weekly:"Weekly",agentic_request:"Agentic",agentic_request_freetrial:"Agentic (Trial)"}[r=e.name]||r;return(0,a.jsxs)("div",{className:"flex items-center gap-1.5 min-w-[200px] shrink-0",children:[(0,a.jsx)("span",{className:"text-[11px] font-semibold py-0.5 px-2 rounded whitespace-nowrap min-w-[60px] text-center",style:{background:i.bg,color:i.text},children:o}),c&&(0,a.jsxs)("span",{className:"text-[10px] text-text-muted whitespace-nowrap",children:["⏱ ",c]}),(0,a.jsx)("div",{className:"flex-1 h-1.5 rounded-sm bg-white/[0.06] min-w-[60px] overflow-hidden",children:(0,a.jsx)("div",{className:"h-full rounded-sm transition-[width] duration-300 ease-out",style:{width:`${Math.min(n,100)}%`,background:i.bar}})}),(0,a.jsxs)("span",{className:"text-[11px] font-semibold min-w-[32px] text-right",style:{color:i.text},children:[n,"%"]})]},t)}):(0,a.jsx)("div",{className:"text-xs text-text-muted italic",children:e("noQuotaData")})}),(0,a.jsx)("div",{className:"text-center text-[11px] text-text-muted",children:k?(0,a.jsx)("span",{children:k.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}):"-"}),(0,a.jsx)("div",{className:"flex justify-center gap-0.5",children:(0,a.jsx)("button",{onClick:()=>O(t.id,t.provider),disabled:n,title:"Refresh quota",className:"p-1 rounded-md border-none bg-transparent cursor-pointer disabled:cursor-not-allowed disabled:opacity-30 opacity-60 hover:opacity-100 flex items-center justify-center transition-opacity duration-150",children:(0,a.jsx)("span",{className:`material-symbols-outlined text-[16px] text-text-muted ${n?"animate-spin":""}`,children:"refresh"})})})]},t.id)}),0===K.length&&(0,a.jsxs)("div",{className:"py-6 px-4 text-center text-text-muted text-[13px]",children:["No accounts found for tier filter"," ",(0,a.jsx)("strong",{children:h.find(e=>e.key===M)?.label||M}),"."]})]})]})}function b(){let e=(0,n.c)("usage"),[t,s]=(0,l.useState)({lockouts:[],cacheStats:null}),[i,c]=(0,l.useState)(!0),o=(0,l.useCallback)(async()=>{try{let e=await fetch("/api/rate-limits");e.ok&&s(await e.json())}catch{}finally{c(!1)}},[]);return(0,l.useEffect)(()=>{o();let e=setInterval(o,1e4);return()=>clearInterval(e)},[o]),(0,a.jsx)("div",{className:"flex flex-col gap-4",children:(0,a.jsxs)(r.Zp,{children:[(0,a.jsxs)("div",{className:"flex items-center gap-3 mb-4",children:[(0,a.jsx)("div",{className:"p-2 rounded-lg bg-orange-500/10 text-orange-500",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[20px]","aria-hidden":"true",children:"lock_clock"})}),(0,a.jsxs)("div",{className:"flex-1",children:[(0,a.jsx)("h3",{className:"text-lg font-semibold",children:"Model Lockouts"}),(0,a.jsx)("p",{className:"text-sm text-text-muted",children:"Per-model rate limit locks • Auto-refresh 10s"})]}),t.lockouts.length>0&&(0,a.jsxs)("span",{className:"px-2.5 py-1 rounded-full text-xs font-semibold bg-orange-500/10 text-orange-400 border border-orange-500/20",children:[t.lockouts.length," locked"]})]}),0===t.lockouts.length?(0,a.jsxs)("div",{className:"text-center py-6 text-text-muted",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[32px] mb-2 block opacity-40",children:"lock_open"}),(0,a.jsx)("p",{className:"text-sm",children:e("noLockouts")})]}):(0,a.jsx)("div",{className:"flex flex-col gap-2",children:t.lockouts.map((e,t)=>{var s;return(0,a.jsxs)("div",{className:"flex items-center justify-between px-3 py-2.5 rounded-lg bg-orange-500/5 border border-orange-500/15",children:[(0,a.jsxs)("div",{className:"flex items-center gap-3",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[16px] text-orange-400",children:"lock"}),(0,a.jsxs)("div",{children:[(0,a.jsx)("p",{className:"text-sm font-medium",children:e.model}),(0,a.jsxs)("p",{className:"text-xs text-text-muted",children:["Account:"," ",(0,a.jsx)("span",{className:"font-mono",children:e.accountId?.slice(0,12)||"N/A"}),e.reason&&(0,a.jsxs)(a.Fragment,{children:[" — ",e.reason]})]})]})]}),(0,a.jsxs)("span",{className:"text-xs font-mono tabular-nums text-orange-400",children:[(s=e.remainingMs)<1e3?`${s}ms`:s<6e4?`${Math.ceil(s/1e3)}s`:`${Math.ceil(s/6e4)}m`," left"]})]},t)})})]})})}function g(){let e=(0,n.c)("usage"),[t,s]=(0,l.useState)({count:0,sessions:[]}),[i,c]=(0,l.useState)(!0),o=(0,l.useCallback)(async()=>{try{let e=await fetch("/api/sessions");e.ok&&s(await e.json())}catch{}finally{c(!1)}},[]);return(0,l.useEffect)(()=>{o();let e=setInterval(o,5e3);return()=>clearInterval(e)},[o]),(0,a.jsxs)(r.Zp,{children:[(0,a.jsxs)("div",{className:"flex items-center gap-3 mb-5",children:[(0,a.jsx)("div",{className:"p-2 rounded-lg bg-cyan-500/10 text-cyan-500",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[20px]","aria-hidden":"true",children:"fingerprint"})}),(0,a.jsxs)("div",{className:"flex-1",children:[(0,a.jsx)("h3",{className:"text-lg font-semibold",children:e("activeSessions")}),(0,a.jsx)("p",{className:"text-sm text-text-muted",children:"Tracked via request fingerprinting • Auto-refresh 5s"})]}),(0,a.jsx)("div",{className:"flex items-center gap-2",children:(0,a.jsxs)("span",{className:"flex items-center gap-1.5 px-3 py-1.5 rounded-full bg-cyan-500/10 border border-cyan-500/20",children:[(0,a.jsx)("span",{className:"w-2 h-2 rounded-full bg-cyan-500 animate-pulse"}),(0,a.jsx)("span",{className:"text-sm font-semibold tabular-nums text-cyan-400",children:t.count})]})})]}),0===t.sessions.length?(0,a.jsxs)("div",{className:"text-center py-8 text-text-muted",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[40px] mb-2 block opacity-40",children:"fingerprint"}),(0,a.jsx)("p",{className:"text-sm",children:e("noSessions")}),(0,a.jsx)("p",{className:"text-xs mt-1",children:e("sessionsHint")})]}):(0,a.jsx)("div",{className:"overflow-x-auto",children:(0,a.jsxs)("table",{className:"w-full text-sm",children:[(0,a.jsx)("thead",{children:(0,a.jsxs)("tr",{className:"border-b border-border/30",children:[(0,a.jsx)("th",{className:"text-left py-2 px-3 text-xs font-semibold text-text-muted uppercase tracking-wider",children:e("session")}),(0,a.jsx)("th",{className:"text-left py-2 px-3 text-xs font-semibold text-text-muted uppercase tracking-wider",children:e("age")}),(0,a.jsx)("th",{className:"text-right py-2 px-3 text-xs font-semibold text-text-muted uppercase tracking-wider",children:e("requests")}),(0,a.jsx)("th",{className:"text-left py-2 px-3 text-xs font-semibold text-text-muted uppercase tracking-wider",children:e("connection")})]})}),(0,a.jsx)("tbody",{children:t.sessions.map(e=>{var t;return(0,a.jsxs)("tr",{className:"border-b border-border/10 hover:bg-surface/20 transition-colors",children:[(0,a.jsx)("td",{className:"py-2.5 px-3",children:(0,a.jsxs)("span",{className:"font-mono text-xs px-2 py-1 rounded bg-surface/40 text-text-muted",children:[e.sessionId.slice(0,12),"…"]})}),(0,a.jsx)("td",{className:"py-2.5 px-3 text-text-muted tabular-nums",children:(t=e.ageMs)<6e4?`${Math.floor(t/1e3)}s`:t<36e5?`${Math.floor(t/6e4)}m`:`${Math.floor(t/36e5)}h`}),(0,a.jsx)("td",{className:"py-2.5 px-3 text-right",children:(0,a.jsx)("span",{className:"font-semibold tabular-nums",children:e.requestCount})}),(0,a.jsx)("td",{className:"py-2.5 px-3",children:e.connectionId?(0,a.jsx)("span",{className:"text-xs font-mono text-cyan-400",children:e.connectionId.slice(0,10)}):(0,a.jsx)("span",{className:"text-text-muted/40",children:"—"})})]},e.sessionId)})})]})})]})}function j(){return(0,a.jsxs)("div",{className:"flex flex-col gap-6",children:[(0,a.jsx)(l.Suspense,{fallback:(0,a.jsx)(r.Qv,{}),children:(0,a.jsx)(f,{})}),(0,a.jsx)(b,{}),(0,a.jsx)(g,{})]})}}},e=>{e.O(0,[3418,8500,9751,782,6458,5846,993,8441,3794,7358],()=>e(e.s=39387)),_N_E=e.O()}]);
@@ -0,0 +1 @@
1
+ (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[2134],{56411:(e,t,r)=>{Promise.resolve().then(r.bind(r,88618))},88618:(e,t,r)=>{"use strict";r.r(t),r.d(t,{default:()=>g});var s=r(95155),a=r(12115),i=r(67671),l=r(14051),o=r.n(l),n=r(73321),d=r(98500),c=r.n(d),m=r(5772),p=r(50910),u=r(40993),x=r(20909),h=r(81135),f=r(30949);function g(){let e=(0,n.useParams)(),t=(0,n.useRouter)(),r=e.id,[i,l]=(0,a.useState)([]),[o,d]=(0,a.useState)(!0),[g,b]=(0,a.useState)(null),[w,k]=(0,a.useState)(!1),[T,E]=(0,a.useState)(!1),[R,I]=(0,a.useState)(!1),[O,P]=(0,a.useState)(!1),[_,q]=(0,a.useState)(null),[U,D]=(0,a.useState)(null),[F,K]=(0,a.useState)({}),[L,M]=(0,a.useState)(!1),{copied:z,copy:J}=(0,f.C)(),V=(0,p.c)("providers"),W=(0,a.useRef)(!1),B=(0,a.useRef)(!1),[G,Z]=(0,a.useState)(null),[H,Q]=(0,a.useState)(null),[X,Y]=(0,a.useState)(!1),[ee,et]=(0,a.useState)(!1),[er,es]=(0,a.useState)({current:0,total:0,phase:"idle",status:"",logs:[],error:"",importedCount:0}),ea=g?{id:g.id,name:g.name||("anthropic-compatible"===g.type?"Anthropic Compatible":"OpenAI Compatible"),color:"anthropic-compatible"===g.type?"#D97757":"#10A37F",textIcon:"anthropic-compatible"===g.type?"AC":"OC",apiType:g.apiType,baseUrl:g.baseUrl,type:g.type}:x.IS[r]||x.zN[r]||x.fg[r],ei=!!x.IS[r]||!!x.zN[r],el=(0,h.KC)(r),eo=(0,x.wG)(r),en=(0,x.mq)(r),ed=(0,x.gb)(r),ec=en||ed,em=ec?r:eo,ep=ec?g?.prefix||r:eo,eu=(0,a.useCallback)(async()=>{try{let e=await fetch("/api/models/alias"),t=await e.json();e.ok&&K(t.aliases||{})}catch(e){console.log("Error fetching aliases:",e)}},[]),ex=(0,a.useCallback)(async()=>{try{let[e,t]=await Promise.all([fetch("/api/providers",{cache:"no-store"}),fetch("/api/provider-nodes",{cache:"no-store"})]),s=await e.json(),a=await t.json();if(e.ok){let e=(s.connections||[]).filter(e=>e.provider===r);l(e)}if(t.ok){let e=(a.nodes||[]).find(e=>e.id===r)||null;if(!e&&ec)for(let t=0;t<3;t+=1){await new Promise(e=>setTimeout(e,150));let t=await fetch("/api/provider-nodes",{cache:"no-store"});if(t.ok&&(e=((await t.json()).nodes||[]).find(e=>e.id===r)||null))break}b(e)}}catch(e){console.log("Error fetching connections:",e)}finally{d(!1)}},[r,ec]),eh=async e=>{try{let t=await fetch(`/api/provider-nodes/${r}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}),s=await t.json();t.ok&&(b(s.node),await ex(),P(!1))}catch(e){console.log("Error updating provider node:",e)}};(0,a.useEffect)(()=>{ex(),eu(),fetch("/api/settings/proxy").then(e=>e.ok?e.json():null).then(e=>Q(e)).catch(()=>{})},[ex,eu]),(0,a.useEffect)(()=>{o||0!==i.length||!ea||ec||W.current||B.current||(W.current=!0,ei?k(!0):E(!0))},[o]);let ef=async(e,t,r=eo)=>{let s=`${r}/${e}`;try{let e=await fetch("/api/models/alias",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({model:s,alias:t})});if(e.ok)await eu();else{let t=await e.json();alert(t.error||V("failedSetAlias"))}}catch(e){console.log("Error setting alias:",e)}},eg=async e=>{try{(await fetch(`/api/models/alias?alias=${encodeURIComponent(e)}`,{method:"DELETE"})).ok&&await eu()}catch(e){console.log("Error deleting alias:",e)}},ey=async e=>{if(confirm(V("deleteConnectionConfirm")))try{(await fetch(`/api/providers/${e}`,{method:"DELETE"})).ok&&l(i.filter(t=>t.id!==e))}catch(e){console.log("Error deleting connection:",e)}},ev=(0,a.useCallback)(()=>{ex(),k(!1)},[ex]),eb=async e=>{try{let t=await fetch("/api/providers",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:r,...e})});if(t.ok)return await ex(),E(!1),null;let s=await t.json().catch(()=>({}));return s.error?.message||s.error||V("failedSaveConnection")}catch(e){return console.log("Error saving connection:",e),V("failedSaveConnectionRetry")}},ej=async e=>{try{(await fetch(`/api/providers/${_.id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})).ok&&(await ex(),I(!1))}catch(e){console.log("Error updating connection:",e)}},eN=async(e,t)=>{try{(await fetch(`/api/providers/${e}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({isActive:t})})).ok&&l(r=>r.map(r=>r.id===e?{...r,isActive:t}:r))}catch(e){console.log("Error updating connection status:",e)}},ew=async(e,t)=>{try{(await fetch("/api/rate-limits",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({connectionId:e,enabled:t})})).ok&&l(r=>r.map(r=>r.id===e?{...r,rateLimitProtection:t}:r))}catch(e){console.error("Error toggling rate limit:",e)}},ek=async e=>{if(e&&!U){D(e);try{let t=await fetch(`/api/providers/${e}/test`,{method:"POST"});if(!t.ok){let e=await t.json().catch(()=>({}));alert(e.error||V("failedRetestConnection"));return}await ex()}catch(e){console.error("Error retesting connection:",e)}finally{D(null)}}},eC=async(e,t)=>{if(e&&t)try{let r=t.priority,s=e.priority;r===s&&(r=i.indexOf(e)>i.indexOf(t)?t.priority-.5:t.priority+.5),await Promise.all([fetch(`/api/providers/${e.id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({priority:r})}),fetch(`/api/providers/${t.id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({priority:s})})]),await ex()}catch(e){console.log("Error swapping priority:",e)}},eS=async()=>{if(X)return;let e=i.find(e=>!1!==e.isActive);if(e){Y(!0),et(!0),es({current:0,total:0,phase:"fetching",status:V("fetchingModels"),logs:[],error:"",importedCount:0});try{let t=await fetch(`/api/providers/${e.id}/models`),s=await t.json();if(!t.ok)return void es(e=>({...e,phase:"error",status:V("failedFetchModels"),error:s.error||"Failed to import models"}));let a=s.models||[];if(0===a.length)return void es(e=>({...e,phase:"done",status:V("noModelsFound"),logs:["No models returned from /models endpoint."]}));es(e=>({...e,phase:"importing",total:a.length,status:`Importing 0 of ${a.length} models...`,logs:[`Found ${a.length} models. Starting import...`]}));let i=0;for(let e=0;e<a.length;e++){let t=a[e],s=t.id||t.name||t.model;if(!s)continue;let l=s.split("/"),o=l[l.length-1];es(t=>({...t,current:e+1,status:`Importing ${e+1} of ${a.length} models...`,logs:[...t.logs,`Importing ${s}...`]})),await fetch("/api/provider-models",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:r,modelId:s,modelName:t.name||s,source:"imported"})}),F[o]||await ef(s,o,em),i+=1}await eu(),es(e=>({...e,phase:"done",current:a.length,status:i>0?`Successfully imported ${i} model${1===i?"":"s"}!`:"No new models were added (all already exist).",logs:[...e.logs,i>0?`✓ Done! ${i} model${1===i?"":"s"} imported.`:"No new models were added."],importedCount:i})),i>0&&setTimeout(()=>{window.location.reload()},2e3)}catch(e){console.log("Error importing models:",e),es(t=>({...t,phase:"error",status:V("importFailed"),error:e instanceof Error?e.message:"An unexpected error occurred"}))}finally{Y(!1)}}},e$=async(e,t)=>{et(!0),es({current:0,total:0,phase:"fetching",status:V("fetchingModels"),logs:[],error:"",importedCount:0});try{let r=(await e()).models||[];if(0===r.length)return void es(e=>({...e,phase:"done",status:V("noModelsFound"),logs:["No models returned from /models endpoint."]}));es(e=>({...e,phase:"importing",total:r.length,status:`Importing 0 of ${r.length} models...`,logs:[`Found ${r.length} models. Starting import...`]}));let s=0;for(let e=0;e<r.length;e++){let a=r[e],i=a.id||a.name||a.model;i&&(es(t=>({...t,current:e+1,status:`Importing ${e+1} of ${r.length} models...`,logs:[...t.logs,`Importing ${i}...`]})),await t(a)&&(s+=1))}es(e=>({...e,phase:"done",current:r.length,status:s>0?`Successfully imported ${s} model${1===s?"":"s"}!`:"No new models were added.",logs:[...e.logs,s>0?`✓ Done! ${s} model${1===s?"":"s"} imported.`:"No new models were added."],importedCount:s})),s>0&&setTimeout(()=>{window.location.reload()},2e3)}catch(e){console.log("Error importing models:",e),es(t=>({...t,phase:"error",status:V("importFailed"),error:e instanceof Error?e.message:"An unexpected error occurred"}))}},eA=i.some(e=>!1!==e.isActive);return o?(0,s.jsxs)("div",{className:"flex flex-col gap-8",children:[(0,s.jsx)(u.Qv,{}),(0,s.jsx)(u.Qv,{})]}):ea?(0,s.jsxs)("div",{className:"flex flex-col gap-8",children:[(0,s.jsxs)("div",{children:[(0,s.jsxs)(c(),{href:"/dashboard/providers",className:"inline-flex items-center gap-1 text-sm text-text-muted hover:text-primary transition-colors mb-4",children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-lg",children:"arrow_back"}),V("backToProviders")]}),(0,s.jsxs)("div",{className:"flex items-center gap-4",children:[(0,s.jsx)("div",{className:"rounded-lg flex items-center justify-center",style:{backgroundColor:`${ea.color}15`},children:L?(0,s.jsx)("span",{className:"text-sm font-bold",style:{color:ea.color},children:ea.textIcon||ea.id.slice(0,2).toUpperCase()}):(0,s.jsx)(m.default,{src:en&&ea.apiType?"responses"===ea.apiType?"/providers/oai-r.png":"/providers/oai-cc.png":ed?"/providers/anthropic-m.png":`/providers/${ea.id}.png`,alt:ea.name,width:48,height:48,className:"object-contain rounded-lg max-w-[48px] max-h-[48px]",sizes:"48px",onError:()=>M(!0)})}),(0,s.jsxs)("div",{children:[ea.website?(0,s.jsxs)("a",{href:ea.website,target:"_blank",rel:"noopener noreferrer",className:"text-3xl font-semibold tracking-tight hover:underline inline-flex items-center gap-2",style:{color:ea.color},children:[ea.name,(0,s.jsx)("span",{className:"material-symbols-outlined text-lg opacity-60",children:"open_in_new"})]}):(0,s.jsx)("h1",{className:"text-3xl font-semibold tracking-tight",children:ea.name}),(0,s.jsxs)("p",{className:"text-text-muted",children:[i.length," connection",1===i.length?"":"s"]})]})]})]}),ec&&g&&(0,s.jsxs)(u.Zp,{children:[(0,s.jsxs)("div",{className:"flex items-center justify-between mb-4",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("h2",{className:"text-lg font-semibold",children:ed?V("anthropicCompatibleDetails"):V("openaiCompatibleDetails")}),(0,s.jsxs)("p",{className:"text-sm text-text-muted",children:[ed?V("messagesApi"):"responses"===g.apiType?V("responsesApi"):V("chatCompletions")," ","\xb7 ",(g.baseUrl||"").replace(/\/$/,""),"/",ed?"messages":"responses"===g.apiType?"responses":"chat/completions"]})]}),(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)(u.$n,{size:"sm",icon:"add",onClick:()=>E(!0),disabled:i.length>0,children:"Add"}),(0,s.jsx)(u.$n,{size:"sm",variant:"secondary",icon:"edit",onClick:()=>P(!0),children:"Edit"}),(0,s.jsx)(u.$n,{size:"sm",variant:"secondary",icon:"delete",onClick:async()=>{if(confirm(`Delete this ${ed?"Anthropic":"OpenAI"} Compatible node?`))try{(await fetch(`/api/provider-nodes/${r}`,{method:"DELETE"})).ok&&t.push("/dashboard/providers")}catch(e){console.log("Error deleting provider node:",e)}},children:"Delete"})]})]}),i.length>0&&(0,s.jsx)("p",{className:"text-sm text-text-muted",children:"Only one connection is allowed per compatible node. Add another node if you need more connections."})]}),(0,s.jsxs)(u.Zp,{children:[(0,s.jsxs)("div",{className:"flex items-center justify-between mb-4",children:[(0,s.jsxs)("div",{className:"flex items-center gap-3",children:[(0,s.jsx)("h2",{className:"text-lg font-semibold",children:"Connections"}),(0,s.jsxs)("button",{onClick:()=>Z({level:"provider",id:r,label:ea?.name||r}),className:`inline-flex items-center gap-1 px-2 py-1 rounded text-xs font-medium transition-all ${H?.providers?.[r]?"bg-amber-500/15 text-amber-500 hover:bg-amber-500/25":"bg-black/[0.03] dark:bg-white/[0.03] text-text-muted/50 hover:text-text-muted hover:bg-black/[0.06] dark:hover:bg-white/[0.06]"}`,title:H?.providers?.[r]?`Provider proxy: ${H.providers[r].host||"configured"}`:"Configure proxy for all connections of this provider",children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"vpn_lock"}),H?.providers?.[r]&&H.providers[r].host||"Provider Proxy"]})]}),!ec&&(0,s.jsx)(u.$n,{size:"sm",icon:"add",onClick:()=>ei?k(!0):E(!0),children:"Add"})]}),0===i.length?(0,s.jsxs)("div",{className:"text-center py-12",children:[(0,s.jsx)("div",{className:"inline-flex items-center justify-center w-16 h-16 rounded-full bg-primary/10 text-primary mb-4",children:(0,s.jsx)("span",{className:"material-symbols-outlined text-[32px]",children:ei?"lock":"key"})}),(0,s.jsx)("p",{className:"text-text-main font-medium mb-1",children:"No connections yet"}),(0,s.jsx)("p",{className:"text-sm text-text-muted mb-4",children:"Add your first connection to get started"}),!ec&&(0,s.jsx)(u.$n,{icon:"add",onClick:()=>ei?k(!0):E(!0),children:"Add Connection"})]}):(0,s.jsx)("div",{className:"flex flex-col divide-y divide-black/[0.03] dark:divide-white/[0.03]",children:i.sort((e,t)=>(e.priority||0)-(t.priority||0)).map((e,t)=>(0,s.jsx)(C,{connection:e,isOAuth:ei,isFirst:0===t,isLast:t===i.length-1,onMoveUp:()=>eC(e,i[t-1]),onMoveDown:()=>eC(e,i[t+1]),onToggleActive:t=>eN(e.id,t),onToggleRateLimit:t=>ew(e.id,t),onRetest:()=>ek(e.id),isRetesting:U===e.id,onEdit:()=>{q(e),I(!0)},onDelete:()=>ey(e.id),onReauth:ei?()=>k(!0):void 0,onProxy:()=>Z({level:"key",id:e.id,label:e.name||e.email||e.id}),hasProxy:!!(H?.keys?.[e.id]||H?.providers?.[r]||H?.global),proxySource:H?.keys?.[e.id]?"key":H?.providers?.[r]?"provider":H?.global?"global":null,proxyHost:(H?.keys?.[e.id]||H?.providers?.[r]||H?.global)?.host||null},e.id))})]}),(0,s.jsxs)(u.Zp,{children:[(0,s.jsx)("h2",{className:"text-lg font-semibold mb-4",children:"Available Models"}),(()=>{if(ec)return(0,s.jsx)(N,{providerStorageAlias:em,providerDisplayAlias:ep,modelAliases:F,copied:z,onCopy:J,onSetAlias:ef,onDeleteAlias:eg,connections:i,isAnthropic:ed,onImportWithProgress:e$});if(ea.passthroughModels)return(0,s.jsxs)("div",{children:[(0,s.jsxs)("div",{className:"flex items-center gap-2 mb-4",children:[(0,s.jsx)(u.$n,{size:"sm",variant:"secondary",icon:"download",onClick:eS,disabled:!eA||X,children:X?V("importingModels"):V("importFromModels")}),!eA&&(0,s.jsx)("span",{className:"text-xs text-text-muted",children:V("addConnectionToImport")})]}),(0,s.jsx)(v,{providerAlias:eo,modelAliases:F,copied:z,onCopy:J,onSetAlias:ef,onDeleteAlias:eg})]});let e=(0,s.jsxs)("div",{className:"flex items-center gap-2 mb-4",children:[(0,s.jsx)(u.$n,{size:"sm",variant:"secondary",icon:"download",onClick:eS,disabled:!eA||X,children:X?V("importingModels"):V("importFromModels")}),!eA&&(0,s.jsx)("span",{className:"text-xs text-text-muted",children:V("addConnectionToImport")})]});return 0===el.length?(0,s.jsxs)("div",{children:[e,(0,s.jsx)("p",{className:"text-sm text-text-muted",children:V("noModelsConfigured")})]}):(0,s.jsxs)("div",{children:[e,(0,s.jsx)("div",{className:"flex flex-wrap gap-3",children:el.map(e=>{let t=`${em}/${e.id}`,a=`${r}/${e.id}`,i=Object.entries(F).find(([,e])=>e===t||e===a)?.[0];return(0,s.jsx)(y,{model:e,fullModel:`${ep}/${e.id}`,alias:i,copied:z,onCopy:J,onSetAlias:t=>ef(e.id,t,em),onDeleteAlias:()=>eg(i)},e.id)})})]})})(),!ec&&(0,s.jsx)(j,{providerId:r,providerAlias:ep,copied:z,onCopy:J})]}),"kiro"===r?(0,s.jsx)(u.Mh,{isOpen:w,providerInfo:ea,onSuccess:ev,onClose:()=>{B.current=!0,k(!1)}}):"cursor"===r?(0,s.jsx)(u.G9,{isOpen:w,onSuccess:ev,onClose:()=>{B.current=!0,k(!1)}}):(0,s.jsx)(u.LF,{isOpen:w,provider:r,providerInfo:ea,onSuccess:ev,onClose:()=>{B.current=!0,k(!1)}}),(0,s.jsx)(S,{isOpen:T,provider:r,providerName:ea.name,isCompatible:ec,isAnthropic:ed,onSave:eb,onClose:()=>E(!1)}),(0,s.jsx)($,{isOpen:R,connection:_,onSave:ej,onClose:()=>I(!1)}),ec&&(0,s.jsx)(A,{isOpen:O,node:g,onSave:eh,onClose:()=>P(!1),isAnthropic:ed}),G&&(0,s.jsx)(u.KN,{isOpen:!!G,onClose:()=>Z(null),level:G.level,levelId:G.id,levelLabel:G.label}),(0,s.jsx)(u.aF,{isOpen:ee,onClose:()=>{("done"===er.phase||"error"===er.phase)&&et(!1)},title:"Importing Models",size:"md",closeOnOverlay:!1,showCloseButton:"done"===er.phase||"error"===er.phase,children:(0,s.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,s.jsxs)("div",{className:"flex items-center gap-3",children:["fetching"===er.phase&&(0,s.jsx)("span",{className:"material-symbols-outlined text-primary animate-spin",children:"progress_activity"}),"importing"===er.phase&&(0,s.jsx)("span",{className:"material-symbols-outlined text-primary animate-spin",children:"progress_activity"}),"done"===er.phase&&(0,s.jsx)("span",{className:"material-symbols-outlined text-green-500",children:"check_circle"}),"error"===er.phase&&(0,s.jsx)("span",{className:"material-symbols-outlined text-red-500",children:"error"}),(0,s.jsx)("span",{className:"text-sm font-medium text-text-main",children:er.status})]}),("importing"===er.phase||"done"===er.phase)&&er.total>0&&(0,s.jsxs)("div",{className:"w-full",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between mb-1",children:[(0,s.jsxs)("span",{className:"text-xs text-text-muted",children:[er.current," / ",er.total]}),(0,s.jsxs)("span",{className:"text-xs text-text-muted",children:[Math.round(er.current/er.total*100),"%"]})]}),(0,s.jsx)("div",{className:"w-full h-2.5 bg-black/10 dark:bg-white/10 rounded-full overflow-hidden",children:(0,s.jsx)("div",{className:"h-full rounded-full transition-all duration-300 ease-out",style:{width:`${er.current/er.total*100}%`,background:"done"===er.phase?"linear-gradient(90deg, #22c55e, #16a34a)":"linear-gradient(90deg, var(--color-primary), var(--color-primary-hover, var(--color-primary)))"}})})]}),"fetching"===er.phase&&(0,s.jsx)("div",{className:"w-full h-2.5 bg-black/10 dark:bg-white/10 rounded-full overflow-hidden",children:(0,s.jsx)("div",{className:"h-full rounded-full animate-pulse",style:{width:"60%",background:"linear-gradient(90deg, var(--color-primary), var(--color-primary-hover, var(--color-primary)))"}})}),"error"===er.phase&&er.error&&(0,s.jsx)("div",{className:"p-3 rounded-lg bg-red-500/10 border border-red-500/20",children:(0,s.jsx)("p",{className:"text-sm text-red-400",children:er.error})}),er.logs.length>0&&(0,s.jsx)("div",{className:"max-h-48 overflow-y-auto rounded-lg bg-black/5 dark:bg-white/5 p-3 border border-black/5 dark:border-white/5",children:(0,s.jsx)("div",{className:"flex flex-col gap-1",children:er.logs.map((e,t)=>(0,s.jsx)("p",{className:`text-xs font-mono ${e.startsWith("✓")?"text-green-500 font-semibold":"text-text-muted"}`,children:e},t))})}),"done"===er.phase&&er.importedCount>0&&(0,s.jsx)("p",{className:"text-xs text-text-muted text-center animate-pulse",children:"Page will refresh automatically..."})]})})]}):(0,s.jsxs)("div",{className:"text-center py-20",children:[(0,s.jsx)("p",{className:"text-text-muted",children:V("providerNotFound")}),(0,s.jsx)(c(),{href:"/dashboard/providers",className:"text-primary mt-4 inline-block",children:V("backToProviders")})]})}function y({model:e,fullModel:t,alias:r,copied:a,onCopy:i,onSetAlias:l,onDeleteAlias:o}){return(0,s.jsxs)("div",{className:"flex items-center gap-2 px-3 py-2 rounded-lg border border-border hover:bg-sidebar/50",children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-base text-text-muted",children:"smart_toy"}),(0,s.jsx)("code",{className:"text-xs text-text-muted font-mono bg-sidebar px-1.5 py-0.5 rounded",children:t}),(0,s.jsx)("button",{onClick:()=>i(t,`model-${e.id}`),className:"p-0.5 hover:bg-sidebar rounded text-text-muted hover:text-primary",title:"Copy model",children:(0,s.jsx)("span",{className:"material-symbols-outlined text-sm",children:a===`model-${e.id}`?"check":"content_copy"})})]})}function v({providerAlias:e,modelAliases:t,copied:r,onCopy:i,onSetAlias:l,onDeleteAlias:o}){let[n,d]=(0,a.useState)(""),[c,m]=(0,a.useState)(!1),p=Object.entries(t).filter(([,t])=>t.startsWith(`${e}/`)).map(([t,r])=>({modelId:r.replace(`${e}/`,""),fullModel:r,alias:t})),x=async()=>{let e;if(!n.trim()||c)return;let r=n.trim(),s=(e=r.split("/"))[e.length-1];if(t[s])return void alert(`Alias "${s}" already exists. Please use a different model or edit existing alias.`);m(!0);try{await l(r,s),d("")}catch(e){console.log("Error adding model:",e)}finally{m(!1)}};return(0,s.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,s.jsx)("p",{className:"text-sm text-text-muted",children:"OpenRouter supports any model. Add models and create aliases for quick access."}),(0,s.jsxs)("div",{className:"flex items-end gap-2",children:[(0,s.jsxs)("div",{className:"flex-1",children:[(0,s.jsx)("label",{htmlFor:"new-model-input",className:"text-xs text-text-muted mb-1 block",children:"Model ID (from OpenRouter)"}),(0,s.jsx)("input",{id:"new-model-input",type:"text",value:n,onChange:e=>d(e.target.value),onKeyDown:e=>"Enter"===e.key&&x(),placeholder:"anthropic/claude-3-opus",className:"w-full px-3 py-2 text-sm border border-border rounded-lg bg-background focus:outline-none focus:border-primary"})]}),(0,s.jsx)(u.$n,{size:"sm",icon:"add",onClick:x,disabled:!n.trim()||c,children:c?"Adding...":"Add"})]}),p.length>0&&(0,s.jsx)("div",{className:"flex flex-col gap-3",children:p.map(({modelId:e,fullModel:t,alias:a})=>(0,s.jsx)(b,{modelId:e,fullModel:t,copied:r,onCopy:i,onDeleteAlias:()=>o(a)},t))})]})}function b({modelId:e,fullModel:t,copied:r,onCopy:a,onDeleteAlias:i}){return(0,s.jsxs)("div",{className:"flex items-center gap-3 p-3 rounded-lg border border-border hover:bg-sidebar/50",children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-base text-text-muted",children:"smart_toy"}),(0,s.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,s.jsx)("p",{className:"text-sm font-medium truncate",children:e}),(0,s.jsxs)("div",{className:"flex items-center gap-1 mt-1",children:[(0,s.jsx)("code",{className:"text-xs text-text-muted font-mono bg-sidebar px-1.5 py-0.5 rounded",children:t}),(0,s.jsx)("button",{onClick:()=>a(t,`model-${e}`),className:"p-0.5 hover:bg-sidebar rounded text-text-muted hover:text-primary",title:"Copy model",children:(0,s.jsx)("span",{className:"material-symbols-outlined text-sm",children:r===`model-${e}`?"check":"content_copy"})})]})]}),(0,s.jsx)("button",{onClick:i,className:"p-1 hover:bg-red-50 rounded text-red-500",title:"Remove model",children:(0,s.jsx)("span",{className:"material-symbols-outlined text-sm",children:"delete"})})]})}function j({providerId:e,providerAlias:t,copied:r,onCopy:i}){let[l,o]=(0,a.useState)([]),[n,d]=(0,a.useState)(""),[c,m]=(0,a.useState)(""),[p,x]=(0,a.useState)(!1),[h,f]=(0,a.useState)(!0),g=(0,a.useCallback)(async()=>{try{let t=await fetch(`/api/provider-models?provider=${encodeURIComponent(e)}`);if(t.ok){let e=await t.json();o(e.models||[])}}catch(e){console.error("Failed to fetch custom models:",e)}finally{f(!1)}},[e]);(0,a.useEffect)(()=>{g()},[g]);let y=async()=>{if(n.trim()&&!p){x(!0);try{(await fetch("/api/provider-models",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:e,modelId:n.trim(),modelName:c.trim()||void 0})})).ok&&(d(""),m(""),await g())}catch(e){console.error("Failed to add custom model:",e)}finally{x(!1)}}},v=async t=>{try{await fetch(`/api/provider-models?provider=${encodeURIComponent(e)}&model=${encodeURIComponent(t)}`,{method:"DELETE"}),await g()}catch(e){console.error("Failed to remove custom model:",e)}};return(0,s.jsxs)("div",{className:"mt-6 pt-6 border-t border-border",children:[(0,s.jsxs)("h3",{className:"text-sm font-semibold mb-3 flex items-center gap-2",children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-base text-primary",children:"tune"}),"Custom Models"]}),(0,s.jsx)("p",{className:"text-xs text-text-muted mb-3",children:"Add model IDs not in the default list. These will be available for routing."}),(0,s.jsxs)("div",{className:"flex items-end gap-2 mb-3",children:[(0,s.jsxs)("div",{className:"flex-1",children:[(0,s.jsx)("label",{htmlFor:"custom-model-id",className:"text-xs text-text-muted mb-1 block",children:"Model ID"}),(0,s.jsx)("input",{id:"custom-model-id",type:"text",value:n,onChange:e=>d(e.target.value),onKeyDown:e=>"Enter"===e.key&&y(),placeholder:"e.g. gpt-4.5-turbo",className:"w-full px-3 py-2 text-sm border border-border rounded-lg bg-background focus:outline-none focus:border-primary"})]}),(0,s.jsxs)("div",{className:"w-40",children:[(0,s.jsx)("label",{htmlFor:"custom-model-name",className:"text-xs text-text-muted mb-1 block",children:"Display Name"}),(0,s.jsx)("input",{id:"custom-model-name",type:"text",value:c,onChange:e=>m(e.target.value),onKeyDown:e=>"Enter"===e.key&&y(),placeholder:"Optional",className:"w-full px-3 py-2 text-sm border border-border rounded-lg bg-background focus:outline-none focus:border-primary"})]}),(0,s.jsx)(u.$n,{size:"sm",icon:"add",onClick:y,disabled:!n.trim()||p,children:p?"Adding...":"Add"})]}),h?(0,s.jsx)("p",{className:"text-xs text-text-muted",children:"Loading..."}):l.length>0?(0,s.jsx)("div",{className:"flex flex-col gap-2",children:l.map(e=>{let a=`${t}/${e.id}`,l=`custom-${e.id}`;return(0,s.jsxs)("div",{className:"flex items-center gap-3 p-3 rounded-lg border border-border hover:bg-sidebar/50",children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-base text-primary",children:"tune"}),(0,s.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,s.jsx)("p",{className:"text-sm font-medium truncate",children:e.name||e.id}),(0,s.jsxs)("div",{className:"flex items-center gap-1 mt-1",children:[(0,s.jsx)("code",{className:"text-xs text-text-muted font-mono bg-sidebar px-1.5 py-0.5 rounded",children:a}),(0,s.jsx)("button",{onClick:()=>i(a,l),className:"p-0.5 hover:bg-sidebar rounded text-text-muted hover:text-primary",title:"Copy model",children:(0,s.jsx)("span",{className:"material-symbols-outlined text-sm",children:r===l?"check":"content_copy"})})]})]}),(0,s.jsx)("button",{onClick:()=>v(e.id),className:"p-1 hover:bg-red-50 rounded text-red-500",title:"Remove custom model",children:(0,s.jsx)("span",{className:"material-symbols-outlined text-sm",children:"delete"})})]},e.id)})}):(0,s.jsx)("p",{className:"text-xs text-text-muted",children:"No custom models added yet."})]})}function N({providerStorageAlias:e,providerDisplayAlias:t,modelAliases:r,copied:l,onCopy:o,onSetAlias:n,onDeleteAlias:d,connections:c,isAnthropic:m,onImportWithProgress:p}){let[x,h]=(0,a.useState)(""),[f,g]=(0,a.useState)(!1),[y,v]=(0,a.useState)(!1),j=(0,i.i)(),N=Object.entries(r).filter(([,t])=>t.startsWith(`${e}/`)).map(([t,r])=>({modelId:r.replace(`${e}/`,""),fullModel:r,alias:t})),w=e=>{let s,a=(s=e.split("/"))[s.length-1];if(!r[a])return a;let i=`${t}-${a}`;return r[i]?null:i},k=async()=>{if(!x.trim()||f)return;let t=x.trim(),r=w(t);if(!r)return void j.error("All suggested aliases already exist. Please choose a different model or remove conflicting aliases.");g(!0);try{let s=await fetch("/api/provider-models",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:e,modelId:t,modelName:t,source:"manual"})});if(!s.ok){let e={};try{e=await s.json()}catch(e){console.error("Failed to parse error response from custom model API:",e)}throw Error(e.error?.message||"Failed to save custom model")}await n(t,r,e),h(""),j.success(`Model ${t} added successfully`)}catch(e){console.error("Error adding model:",e),j.error(e instanceof Error?e.message:"Failed to add model. Please try again.")}finally{g(!1)}},C=async()=>{if(y)return;let t=c.find(e=>!1!==e.isActive);if(t){v(!0);try{await p(async()=>{let e=await fetch(`/api/providers/${t.id}/models`),r=await e.json();if(!e.ok)throw Error(r.error||"Failed to import models");return r},async t=>{let r=t.id||t.name||t.model;if(!r)return!1;let s=w(r);return!!s&&((await fetch("/api/provider-models",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:e,modelId:r,modelName:t.name||r,source:"imported"})})).ok?(await n(r,s,e),!0):(j.error("Failed to save imported model to custom database"),!1))})}catch(e){console.error("Error importing models:",e),j.error("Failed to import models. Please try again.")}finally{v(!1)}}},S=c.some(e=>!1!==e.isActive),$=async(t,r)=>{try{if(!(await fetch(`/api/provider-models?provider=${encodeURIComponent(e)}&model=${encodeURIComponent(t)}`,{method:"DELETE"})).ok)throw Error("Failed to remove model from database");await d(r),j.success("Model removed successfully")}catch(e){console.error("Error deleting model:",e),j.error(e instanceof Error?e.message:"Failed to delete model. Please try again.")}};return(0,s.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,s.jsxs)("p",{className:"text-sm text-text-muted",children:["Add ",m?"Anthropic":"OpenAI","-compatible models manually or import them from the /models endpoint."]}),(0,s.jsxs)("div",{className:"flex items-end gap-2 flex-wrap",children:[(0,s.jsxs)("div",{className:"flex-1 min-w-[240px]",children:[(0,s.jsx)("label",{htmlFor:"new-compatible-model-input",className:"text-xs text-text-muted mb-1 block",children:"Model ID"}),(0,s.jsx)("input",{id:"new-compatible-model-input",type:"text",value:x,onChange:e=>h(e.target.value),onKeyDown:e=>"Enter"===e.key&&k(),placeholder:m?"claude-3-opus-20240229":"gpt-4o",className:"w-full px-3 py-2 text-sm border border-border rounded-lg bg-background focus:outline-none focus:border-primary"})]}),(0,s.jsx)(u.$n,{size:"sm",icon:"add",onClick:k,disabled:!x.trim()||f,children:f?"Adding...":"Add"}),(0,s.jsx)(u.$n,{size:"sm",variant:"secondary",icon:"download",onClick:C,disabled:!S||y,children:y?"Importing...":"Import from /models"})]}),!S&&(0,s.jsx)("p",{className:"text-xs text-text-muted",children:"Add a connection to enable importing models."}),N.length>0&&(0,s.jsx)("div",{className:"flex flex-col gap-3",children:N.map(({modelId:e,fullModel:r,alias:a})=>(0,s.jsx)(b,{modelId:e,fullModel:`${t}/${e}`,copied:l,onCopy:o,onDeleteAlias:()=>$(e,a)},r))})]})}function w({until:e}){let[t,r]=(0,a.useState)("");return((0,a.useEffect)(()=>{let t=()=>{let t=new Date(e).getTime()-Date.now();if(t<=0)return void r("");let s=Math.floor(t/1e3);if(s<60)r(`${s}s`);else if(s<3600)r(`${Math.floor(s/60)}m ${s%60}s`);else{let e=Math.floor(s/3600),t=Math.floor(s%3600/60);r(`${e}h ${t}m`)}};t();let s=setInterval(t,1e3);return()=>clearInterval(s)},[e]),t)?(0,s.jsxs)("span",{className:"text-xs text-orange-500 font-mono",children:["⏱ ",t]}):null}y.propTypes={model:o().shape({id:o().string.isRequired}).isRequired,fullModel:o().string.isRequired,alias:o().string,copied:o().string,onCopy:o().func.isRequired},v.propTypes={providerAlias:o().string.isRequired,modelAliases:o().object.isRequired,copied:o().string,onCopy:o().func.isRequired,onSetAlias:o().func.isRequired,onDeleteAlias:o().func.isRequired},b.propTypes={modelId:o().string.isRequired,fullModel:o().string.isRequired,copied:o().string,onCopy:o().func.isRequired,onDeleteAlias:o().func.isRequired},j.propTypes={providerId:o().string.isRequired,providerAlias:o().string.isRequired,copied:o().string,onCopy:o().func.isRequired},N.propTypes={providerStorageAlias:o().string.isRequired,providerDisplayAlias:o().string.isRequired,modelAliases:o().object.isRequired,copied:o().string,onCopy:o().func.isRequired,onSetAlias:o().func.isRequired,onDeleteAlias:o().func.isRequired,connections:o().arrayOf(o().shape({id:o().string,isActive:o().bool})).isRequired,isAnthropic:o().bool,onImportWithProgress:o().func.isRequired},w.propTypes={until:o().string.isRequired};let k={runtime_error:{label:"Local runtime",variant:"warning"},upstream_auth_error:{label:"Upstream auth",variant:"error"},auth_missing:{label:"Missing credential",variant:"warning"},token_refresh_failed:{label:"Refresh failed",variant:"warning"},token_expired:{label:"Token expired",variant:"warning"},upstream_rate_limited:{label:"Rate limited",variant:"warning"},upstream_unavailable:{label:"Upstream unavailable",variant:"error"},network_error:{label:"Network error",variant:"warning"},unsupported:{label:"Test unsupported",variant:"default"},upstream_error:{label:"Upstream error",variant:"error"}};function C({connection:e,isOAuth:t,isFirst:r,isLast:i,onMoveUp:l,onMoveDown:o,onToggleActive:n,onToggleRateLimit:d,onRetest:c,isRetesting:m,onEdit:p,onDelete:x,onReauth:h,onProxy:f,hasProxy:g,proxySource:y,proxyHost:v}){let b=t?e.name||e.email||e.displayName||"OAuth Account":e.name,[j,N]=(0,a.useState)(!1);(0,a.useEffect)(()=>{let t=()=>{N(e.rateLimitedUntil&&new Date(e.rateLimitedUntil).getTime()>Date.now())};t();let r=e.rateLimitedUntil?setInterval(t,1e3):null;return()=>{r&&clearInterval(r)}},[e.rateLimitedUntil]);let C="unavailable"!==e.testStatus||j?e.testStatus:"active",S=function(e,t,r){if(!1===e.isActive)return{statusVariant:"default",statusLabel:"disabled",errorType:null,errorBadge:null,errorTextClass:"text-text-muted"};if("active"===t||"success"===t)return{statusVariant:"success",statusLabel:"connected",errorType:null,errorBadge:null,errorTextClass:"text-text-muted"};let s=function(e,t){if(t)return"upstream_rate_limited";if(e.lastErrorType)return e.lastErrorType;let r=Number(e.errorCode);if(401===r||403===r)return"upstream_auth_error";if(429===r)return"upstream_rate_limited";if(r>=500)return"upstream_unavailable";let s=(e.lastError||"").toLowerCase();return s?s.includes("runtime")||s.includes("not runnable")||s.includes("not installed")||s.includes("healthcheck")?"runtime_error":s.includes("refresh failed")?"token_refresh_failed":s.includes("token expired")||s.includes("expired")?"token_expired":s.includes("invalid api key")||s.includes("token invalid")||s.includes("revoked")||s.includes("access denied")||s.includes("unauthorized")?"upstream_auth_error":s.includes("rate limit")||s.includes("quota")||s.includes("too many requests")||s.includes("429")?"upstream_rate_limited":s.includes("fetch failed")||s.includes("network")||s.includes("timeout")||s.includes("econn")||s.includes("enotfound")?"network_error":s.includes("not supported")?"unsupported":"upstream_error":null}(e,r),a=s&&k[s]||null;return"runtime_error"===s?{statusVariant:"warning",statusLabel:"runtime issue",errorType:s,errorBadge:a,errorTextClass:"text-yellow-600 dark:text-yellow-400"}:"upstream_auth_error"===s||"auth_missing"===s||"token_refresh_failed"===s||"token_expired"===s?{statusVariant:"error",statusLabel:"auth failed",errorType:s,errorBadge:a,errorTextClass:"text-red-500"}:"upstream_rate_limited"===s?{statusVariant:"warning",statusLabel:"rate limited",errorType:s,errorBadge:a,errorTextClass:"text-yellow-600 dark:text-yellow-400"}:"network_error"===s?{statusVariant:"warning",statusLabel:"network issue",errorType:s,errorBadge:a,errorTextClass:"text-yellow-600 dark:text-yellow-400"}:"unsupported"===s?{statusVariant:"default",statusLabel:"test unsupported",errorType:s,errorBadge:a,errorTextClass:"text-text-muted"}:{statusVariant:"error",statusLabel:t||"error",errorType:s,errorBadge:a,errorTextClass:"text-red-500"}}(e,C,j),$=!!e.rateLimitProtection;return(0,s.jsxs)("div",{className:`group flex items-center justify-between p-3 rounded-lg hover:bg-black/[0.02] dark:hover:bg-white/[0.02] transition-colors ${!1===e.isActive?"opacity-60":""}`,children:[(0,s.jsxs)("div",{className:"flex items-center gap-3 flex-1 min-w-0",children:[(0,s.jsxs)("div",{className:"flex flex-col",children:[(0,s.jsx)("button",{onClick:l,disabled:r,className:`p-0.5 rounded ${r?"text-text-muted/30 cursor-not-allowed":"hover:bg-sidebar text-text-muted hover:text-primary"}`,children:(0,s.jsx)("span",{className:"material-symbols-outlined text-sm",children:"keyboard_arrow_up"})}),(0,s.jsx)("button",{onClick:o,disabled:i,className:`p-0.5 rounded ${i?"text-text-muted/30 cursor-not-allowed":"hover:bg-sidebar text-text-muted hover:text-primary"}`,children:(0,s.jsx)("span",{className:"material-symbols-outlined text-sm",children:"keyboard_arrow_down"})})]}),(0,s.jsx)("span",{className:"material-symbols-outlined text-base text-text-muted",children:t?"lock":"key"}),(0,s.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,s.jsx)("p",{className:"text-sm font-medium truncate",children:b}),(0,s.jsxs)("div",{className:"flex items-center gap-2 mt-1 flex-wrap",children:[(0,s.jsx)(u.Ex,{variant:S.statusVariant,size:"sm",dot:!0,children:S.statusLabel}),j&&!1!==e.isActive&&(0,s.jsx)(w,{until:e.rateLimitedUntil}),S.errorBadge&&!1!==e.isActive&&(0,s.jsx)(u.Ex,{variant:S.errorBadge.variant,size:"sm",children:S.errorBadge.label}),e.lastError&&!1!==e.isActive&&(0,s.jsx)("span",{className:`text-xs truncate max-w-[300px] ${S.errorTextClass}`,title:e.lastError,children:e.lastError}),(0,s.jsxs)("span",{className:"text-xs text-text-muted",children:["#",e.priority]}),e.globalPriority&&(0,s.jsxs)("span",{className:"text-xs text-text-muted",children:["Auto: ",e.globalPriority]}),(0,s.jsx)("span",{className:"text-text-muted/30 select-none",children:"|"}),(0,s.jsxs)("button",{onClick:()=>d(!$),className:`inline-flex items-center gap-1 px-1.5 py-0.5 rounded text-xs font-medium transition-all cursor-pointer ${$?"bg-emerald-500/15 text-emerald-500 hover:bg-emerald-500/25":"bg-black/[0.03] dark:bg-white/[0.03] text-text-muted/50 hover:text-text-muted hover:bg-black/[0.06] dark:hover:bg-white/[0.06]"}`,title:$?"Click to disable rate limit protection":"Click to enable rate limit protection",children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-[13px]",children:"shield"}),$?"Protected":"Unprotected"]}),g&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("span",{className:"text-text-muted/30 select-none",children:"|"}),(0,s.jsxs)("span",{className:`inline-flex items-center gap-0.5 px-1.5 py-0.5 rounded text-xs font-medium ${"global"===y?"bg-emerald-500/15 text-emerald-500":"provider"===y?"bg-amber-500/15 text-amber-500":"bg-blue-500/15 text-blue-500"}`,title:`Proxy (${"global"===y?"Global":"provider"===y?"Provider":"Key"}): ${v||"configured"}`,children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-[13px]",children:"vpn_lock"}),v||"Proxy"]})]})]})]})]}),(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)(u.$n,{size:"sm",variant:"ghost",icon:"refresh",loading:m,disabled:!1===e.isActive,onClick:c,className:"!h-7 !px-2 text-xs",title:"Retest authentication",children:"Retest"}),(0,s.jsx)(u.lM,{size:"sm",checked:e.isActive??!0,onChange:n,title:e.isActive??!0?"Disable connection":"Enable connection"}),(0,s.jsxs)("div",{className:"flex gap-1 ml-1 opacity-0 group-hover:opacity-100 transition-opacity",children:[h&&(0,s.jsx)("button",{onClick:h,className:"p-2 hover:bg-amber-500/10 rounded text-amber-600 hover:text-amber-500",title:"Re-authenticate this connection",children:(0,s.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:"passkey"})}),(0,s.jsx)("button",{onClick:p,className:"p-2 hover:bg-black/5 dark:hover:bg-white/5 rounded text-text-muted hover:text-primary",children:(0,s.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:"edit"})}),(0,s.jsx)("button",{onClick:f,className:"p-2 hover:bg-black/5 dark:hover:bg-white/5 rounded text-text-muted hover:text-primary",title:"Proxy config",children:(0,s.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:"vpn_lock"})}),(0,s.jsx)("button",{onClick:x,className:"p-2 hover:bg-red-500/10 rounded text-red-500",children:(0,s.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:"delete"})})]})]})]})}function S({isOpen:e,provider:t,providerName:r,isCompatible:i,isAnthropic:l,onSave:o,onClose:n}){let[d,c]=(0,a.useState)({name:"",apiKey:"",priority:1}),[m,p]=(0,a.useState)(!1),[x,h]=(0,a.useState)(null),[f,g]=(0,a.useState)(!1),[y,v]=(0,a.useState)(null),b=async()=>{p(!0),v(null);try{let e=await fetch("/api/providers/validate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:t,apiKey:d.apiKey})}),r=await e.json();h(r.valid?"success":"failed")}catch{h("failed")}finally{p(!1)}},j=async()=>{if(t&&d.apiKey){g(!0),v(null);try{let e=!1;try{p(!0),h(null);let r=await fetch("/api/providers/validate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:t,apiKey:d.apiKey})});e=!!(await r.json()).valid,h(e?"success":"failed")}catch{h("failed")}finally{p(!1)}if(!e)return void v("API key validation failed. Please check your key and try again.");let r=await o({name:d.name,apiKey:d.apiKey,priority:d.priority,testStatus:"active"});r&&v("string"==typeof r?r:"Failed to save connection")}finally{g(!1)}}};return t?(0,s.jsx)(u.aF,{isOpen:e,title:`Add ${r||t} API Key`,onClose:n,children:(0,s.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,s.jsx)(u.pd,{label:"Name",value:d.name,onChange:e=>c({...d,name:e.target.value}),placeholder:"Production Key"}),(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsx)(u.pd,{label:"API Key",type:"password",value:d.apiKey,onChange:e=>c({...d,apiKey:e.target.value}),className:"flex-1"}),(0,s.jsx)("div",{className:"pt-6",children:(0,s.jsx)(u.$n,{onClick:b,disabled:!d.apiKey||m||f,variant:"secondary",children:m?"Checking...":"Check"})})]}),x&&(0,s.jsx)(u.Ex,{variant:"success"===x?"success":"error",children:"success"===x?"Valid":"Invalid"}),y&&(0,s.jsx)("div",{className:"text-sm text-red-500 bg-red-500/10 border border-red-500/20 rounded-lg px-3 py-2",children:y}),i&&(0,s.jsx)("p",{className:"text-xs text-text-muted",children:l?`Validation checks ${r||"Anthropic Compatible"} by verifying the API key.`:`Validation checks ${r||"OpenAI Compatible"} via /models on your base URL.`}),(0,s.jsx)(u.pd,{label:"Priority",type:"number",value:d.priority,onChange:e=>c({...d,priority:Number.parseInt(e.target.value)||1})}),(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsx)(u.$n,{onClick:j,fullWidth:!0,disabled:!d.name||!d.apiKey||f,children:f?"Saving...":"Save"}),(0,s.jsx)(u.$n,{onClick:n,variant:"ghost",fullWidth:!0,children:"Cancel"})]})]})}):null}function $({isOpen:e,connection:t,onSave:r,onClose:i}){let[l,o]=(0,a.useState)({name:"",priority:1,apiKey:"",healthCheckInterval:60}),[n,d]=(0,a.useState)(!1),[c,m]=(0,a.useState)(null),[p,h]=(0,a.useState)(!1),[f,g]=(0,a.useState)(null),[y,v]=(0,a.useState)(!1);(0,a.useEffect)(()=>{t&&(o({name:t.name||"",priority:t.priority||1,apiKey:"",healthCheckInterval:t.healthCheckInterval??60}),m(null),g(null))},[t]);let b=async()=>{if(t?.provider){d(!0),m(null);try{let e=await fetch(`/api/providers/${t.id}/test`,{method:"POST"}),r=await e.json();m({valid:!!r.valid,diagnosis:r.diagnosis||null,message:r.error||null})}catch{m({valid:!1,diagnosis:{type:"network_error"},message:"Failed to test connection"})}finally{d(!1)}}},j=async()=>{if(t?.provider&&l.apiKey){h(!0),g(null);try{let e=await fetch("/api/providers/validate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:t.provider,apiKey:l.apiKey})}),r=await e.json();g(r.valid?"success":"failed")}catch{g("failed")}finally{h(!1)}}},N=async()=>{v(!0);try{let e={name:l.name,priority:l.priority,healthCheckInterval:l.healthCheckInterval};if(!w&&l.apiKey){e.apiKey=l.apiKey;let r="success"===f;if(!r)try{h(!0),g(null);let e=await fetch("/api/providers/validate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:t.provider,apiKey:l.apiKey})});r=!!(await e.json()).valid,g(r?"success":"failed")}catch{g("failed")}finally{h(!1)}r&&(e.testStatus="active",e.lastError=null,e.lastErrorAt=null,e.lastErrorType=null,e.lastErrorSource=null,e.errorCode=null,e.rateLimitedUntil=null)}await r(e)}finally{v(!1)}};if(!t)return null;let w="oauth"===t.authType,C=(0,x.mq)(t.provider)||(0,x.gb)(t.provider),S=!c?.valid&&c?.diagnosis?.type&&k[c.diagnosis.type]||null;return(0,s.jsx)(u.aF,{isOpen:e,title:"Edit Connection",onClose:i,children:(0,s.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,s.jsx)(u.pd,{label:"Name",value:l.name,onChange:e=>o({...l,name:e.target.value}),placeholder:w?"Account name":"Production Key"}),w&&t.email&&(0,s.jsxs)("div",{className:"bg-sidebar/50 p-3 rounded-lg",children:[(0,s.jsx)("p",{className:"text-sm text-text-muted mb-1",children:"Email"}),(0,s.jsx)("p",{className:"font-medium",children:t.email})]}),w&&(0,s.jsx)(u.pd,{label:"Health Check (min)",type:"number",value:l.healthCheckInterval,onChange:e=>o({...l,healthCheckInterval:Math.max(0,Number.parseInt(e.target.value)||0)}),hint:"Proactive token refresh interval. 0 = disabled."}),(0,s.jsx)(u.pd,{label:"Priority",type:"number",value:l.priority,onChange:e=>o({...l,priority:Number.parseInt(e.target.value)||1})}),!w&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsx)(u.pd,{label:"API Key",type:"password",value:l.apiKey,onChange:e=>o({...l,apiKey:e.target.value}),placeholder:"Enter new API key",hint:"Leave blank to keep the current API key.",className:"flex-1"}),(0,s.jsx)("div",{className:"pt-6",children:(0,s.jsx)(u.$n,{onClick:j,disabled:!l.apiKey||p||y,variant:"secondary",children:p?"Checking...":"Check"})})]}),f&&(0,s.jsx)(u.Ex,{variant:"success"===f?"success":"error",children:"success"===f?"Valid":"Invalid"})]}),!C&&(0,s.jsxs)("div",{className:"flex items-center gap-3",children:[(0,s.jsx)(u.$n,{onClick:b,variant:"secondary",disabled:n,children:n?"Testing...":"Test Connection"}),c&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(u.Ex,{variant:c.valid?"success":"error",children:c.valid?"Valid":"Failed"}),S&&(0,s.jsx)(u.Ex,{variant:S.variant,children:S.label})]})]}),(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsx)(u.$n,{onClick:N,fullWidth:!0,disabled:y,children:y?"Saving...":"Save"}),(0,s.jsx)(u.$n,{onClick:i,variant:"ghost",fullWidth:!0,children:"Cancel"})]})]})})}function A({isOpen:e,node:t,onSave:r,onClose:i,isAnthropic:l}){let[o,n]=(0,a.useState)({name:"",prefix:"",apiType:"chat",baseUrl:"https://api.openai.com/v1"}),[d,c]=(0,a.useState)(!1),[m,p]=(0,a.useState)(""),[x,h]=(0,a.useState)(!1),[f,g]=(0,a.useState)(null);(0,a.useEffect)(()=>{t&&n({name:t.name||"",prefix:t.prefix||"",apiType:t.apiType||"chat",baseUrl:t.baseUrl||(l?"https://api.anthropic.com/v1":"https://api.openai.com/v1")})},[t,l]);let y=async()=>{if(o.name.trim()&&o.prefix.trim()&&o.baseUrl.trim()){c(!0);try{let e={name:o.name,prefix:o.prefix,baseUrl:o.baseUrl};l||(e.apiType=o.apiType),await r(e)}finally{c(!1)}}},v=async()=>{h(!0);try{let e=await fetch("/api/provider-nodes/validate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({baseUrl:o.baseUrl,apiKey:m,type:l?"anthropic-compatible":"openai-compatible"})}),t=await e.json();g(t.valid?"success":"failed")}catch{g("failed")}finally{h(!1)}};return t?(0,s.jsx)(u.aF,{isOpen:e,title:`Edit ${l?"Anthropic":"OpenAI"} Compatible`,onClose:i,children:(0,s.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,s.jsx)(u.pd,{label:"Name",value:o.name,onChange:e=>n({...o,name:e.target.value}),placeholder:`${l?"Anthropic":"OpenAI"} Compatible (Prod)`,hint:"Required. A friendly label for this node."}),(0,s.jsx)(u.pd,{label:"Prefix",value:o.prefix,onChange:e=>n({...o,prefix:e.target.value}),placeholder:l?"ac-prod":"oc-prod",hint:"Required. Used as the provider prefix for model IDs."}),!l&&(0,s.jsx)(u.l6,{label:"API Type",options:[{value:"chat",label:"Chat Completions"},{value:"responses",label:"Responses API"}],value:o.apiType,onChange:e=>n({...o,apiType:e.target.value})}),(0,s.jsx)(u.pd,{label:"Base URL",value:o.baseUrl,onChange:e=>n({...o,baseUrl:e.target.value}),placeholder:l?"https://api.anthropic.com/v1":"https://api.openai.com/v1",hint:`Use the base URL (ending in /v1) for your ${l?"Anthropic":"OpenAI"}-compatible API.`}),(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsx)(u.pd,{label:"API Key (for Check)",type:"password",value:m,onChange:e=>p(e.target.value),className:"flex-1"}),(0,s.jsx)("div",{className:"pt-6",children:(0,s.jsx)(u.$n,{onClick:v,disabled:!m||x||!o.baseUrl.trim(),variant:"secondary",children:x?"Checking...":"Check"})})]}),f&&(0,s.jsx)(u.Ex,{variant:"success"===f?"success":"error",children:"success"===f?"Valid":"Invalid"}),(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsx)(u.$n,{onClick:y,fullWidth:!0,disabled:!o.name.trim()||!o.prefix.trim()||!o.baseUrl.trim()||d,children:d?"Saving...":"Save"}),(0,s.jsx)(u.$n,{onClick:i,variant:"ghost",fullWidth:!0,children:"Cancel"})]})]})}):null}C.propTypes={connection:o().shape({id:o().string,name:o().string,email:o().string,displayName:o().string,rateLimitedUntil:o().string,rateLimitProtection:o().bool,testStatus:o().string,isActive:o().bool,priority:o().number,lastError:o().string,lastErrorType:o().string,lastErrorSource:o().string,errorCode:o().oneOfType([o().string,o().number]),globalPriority:o().number}).isRequired,isOAuth:o().bool.isRequired,isFirst:o().bool.isRequired,isLast:o().bool.isRequired,onMoveUp:o().func.isRequired,onMoveDown:o().func.isRequired,onToggleActive:o().func.isRequired,onToggleRateLimit:o().func.isRequired,onRetest:o().func.isRequired,isRetesting:o().bool,onEdit:o().func.isRequired,onDelete:o().func.isRequired,onReauth:o().func},S.propTypes={isOpen:o().bool.isRequired,provider:o().string,providerName:o().string,isCompatible:o().bool,isAnthropic:o().bool,onSave:o().func.isRequired,onClose:o().func.isRequired},$.propTypes={isOpen:o().bool.isRequired,connection:o().shape({id:o().string,name:o().string,email:o().string,priority:o().number,authType:o().string,provider:o().string}),onSave:o().func.isRequired,onClose:o().func.isRequired},A.propTypes={isOpen:o().bool.isRequired,node:o().shape({id:o().string,name:o().string,prefix:o().string,apiType:o().string,baseUrl:o().string}),onSave:o().func.isRequired,onClose:o().func.isRequired,isAnthropic:o().bool}}},e=>{e.O(0,[3418,8500,9751,782,6458,5846,993,8441,3794,7358],()=>e(e.s=56411)),_N_E=e.O()}]);
@@ -0,0 +1,4 @@
1
+ (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[3528],{2824:(e,t,s)=>{"use strict";s.d(t,{default:()=>k});var a=s(95155),r=s(50910),n=s(12115),l=s(40993);let i=[{id:"simple-chat",name:"Simple Chat",icon:"chat",description:"Basic text message",formats:{openai:{model:"gpt-4o",messages:[{role:"system",content:"You are a helpful assistant."},{role:"user",content:"Hello! How are you today?"}],stream:!0},claude:{model:"claude-sonnet-4-20250514",system:"You are a helpful assistant.",max_tokens:1024,messages:[{role:"user",content:"Hello! How are you today?"}],stream:!0},gemini:{model:"gemini-2.5-flash",contents:[{role:"user",parts:[{text:"Hello! How are you today?"}]}],systemInstruction:{parts:[{text:"You are a helpful assistant."}]}},"openai-responses":{model:"gpt-4o",input:"Hello! How are you today?",instructions:"You are a helpful assistant."}}},{id:"tool-calling",name:"Tool Calling",icon:"build",description:"Function/tool invocation",formats:{openai:{model:"gpt-4o",messages:[{role:"user",content:"What's the weather in S\xe3o Paulo?"}],tools:[{type:"function",function:{name:"get_weather",description:"Get current weather for a location",parameters:{type:"object",properties:{location:{type:"string",description:"City name"},unit:{type:"string",enum:["celsius","fahrenheit"]}},required:["location"]}}}],stream:!0},claude:{model:"claude-sonnet-4-20250514",max_tokens:1024,messages:[{role:"user",content:"What's the weather in S\xe3o Paulo?"}],tools:[{name:"get_weather",description:"Get current weather for a location",input_schema:{type:"object",properties:{location:{type:"string",description:"City name"},unit:{type:"string",enum:["celsius","fahrenheit"]}},required:["location"]}}],stream:!0},gemini:{model:"gemini-2.5-flash",contents:[{role:"user",parts:[{text:"What's the weather in S\xe3o Paulo?"}]}],tools:[{functionDeclarations:[{name:"get_weather",description:"Get current weather for a location",parameters:{type:"object",properties:{location:{type:"string",description:"City name"},unit:{type:"string",enum:["celsius","fahrenheit"]}},required:["location"]}}]}]}}},{id:"multi-turn",name:"Multi-turn",icon:"forum",description:"Conversation with history",formats:{openai:{model:"gpt-4o",messages:[{role:"system",content:"You are a coding assistant."},{role:"user",content:"Write a function to sort an array in Python."},{role:"assistant",content:"Here's a simple sort function:\n\n```python\ndef sort_array(arr):\n return sorted(arr)\n```"},{role:"user",content:"Now make it sort in descending order."}],stream:!0},claude:{model:"claude-sonnet-4-20250514",system:"You are a coding assistant.",max_tokens:1024,messages:[{role:"user",content:"Write a function to sort an array in Python."},{role:"assistant",content:"Here's a simple sort function:\n\n```python\ndef sort_array(arr):\n return sorted(arr)\n```"},{role:"user",content:"Now make it sort in descending order."}],stream:!0},gemini:{model:"gemini-2.5-flash",contents:[{role:"user",parts:[{text:"Write a function to sort an array in Python."}]},{role:"model",parts:[{text:"Here's a simple sort function:\n\n```python\ndef sort_array(arr):\n return sorted(arr)\n```"}]},{role:"user",parts:[{text:"Now make it sort in descending order."}]}],systemInstruction:{parts:[{text:"You are a coding assistant."}]}}}},{id:"thinking",name:"Thinking",icon:"psychology",description:"Extended thinking / reasoning",formats:{openai:{model:"o3-mini",messages:[{role:"user",content:"What is the sum of the first 100 prime numbers?"}],stream:!0},claude:{model:"claude-sonnet-4-20250514",max_tokens:16e3,thinking:{type:"enabled",budget_tokens:1e4},messages:[{role:"user",content:"What is the sum of the first 100 prime numbers?"}],stream:!0},gemini:{model:"gemini-2.5-flash-thinking",contents:[{role:"user",parts:[{text:"What is the sum of the first 100 prime numbers?"}]}],generationConfig:{thinkingConfig:{thinkingBudget:1e4}}}}},{id:"system-prompt",name:"System Prompt",icon:"settings",description:"Complex system instructions",formats:{openai:{model:"gpt-4o",messages:[{role:"system",content:"You are a senior software engineer specializing in distributed systems. Answer questions concisely using industry best practices. Always provide code examples when relevant. Format your responses using markdown."},{role:"user",content:"How do I implement a circuit breaker pattern?"}],temperature:.7,stream:!0},claude:{model:"claude-sonnet-4-20250514",system:"You are a senior software engineer specializing in distributed systems. Answer questions concisely using industry best practices. Always provide code examples when relevant. Format your responses using markdown.",max_tokens:2048,messages:[{role:"user",content:"How do I implement a circuit breaker pattern?"}],temperature:.7,stream:!0},gemini:{model:"gemini-2.5-flash",contents:[{role:"user",parts:[{text:"How do I implement a circuit breaker pattern?"}]}],systemInstruction:{parts:[{text:"You are a senior software engineer specializing in distributed systems. Answer questions concisely using industry best practices. Always provide code examples when relevant. Format your responses using markdown."}]},generationConfig:{temperature:.7}}}},{id:"streaming",name:"Streaming",icon:"stream",description:"SSE streaming request",formats:{openai:{model:"gpt-4o",messages:[{role:"user",content:"Tell me a short story about a robot learning to paint."}],stream:!0,stream_options:{include_usage:!0}},claude:{model:"claude-sonnet-4-20250514",max_tokens:1024,messages:[{role:"user",content:"Tell me a short story about a robot learning to paint."}],stream:!0},gemini:{model:"gemini-2.5-flash",contents:[{role:"user",parts:[{text:"Tell me a short story about a robot learning to paint."}]}]}}}],o={openai:{label:"OpenAI",color:"emerald",icon:"smart_toy"},"openai-responses":{label:"OpenAI Responses",color:"amber",icon:"swap_horiz"},claude:{label:"Claude",color:"orange",icon:"psychology"},gemini:{label:"Gemini",color:"blue",icon:"auto_awesome"},antigravity:{label:"Antigravity",color:"purple",icon:"rocket_launch"},kiro:{label:"Kiro",color:"cyan",icon:"terminal"},cursor:{label:"Cursor",color:"pink",icon:"edit"},codex:{label:"Codex",color:"yellow",icon:"code"}},c=Object.entries(o).map(([e,t])=>({value:e,label:t.label}));var d=s(75707),m=s.n(d);let u=m()(()=>s.e(8202).then(s.bind(s,28202)),{loadableGenerated:{webpack:()=>[28202]},ssr:!1});function x(){let e=(0,r.c)("translator"),t=(0,r.c)("common"),[s,d]=(0,n.useState)("claude"),[m,x]=(0,n.useState)("openai"),[p,h]=(0,n.useState)(""),[g,f]=(0,n.useState)(""),[b,y]=(0,n.useState)(null),[j,v]=(0,n.useState)(!1),[N,w]=(0,n.useState)(!1),[k,S]=(0,n.useState)(null),_=(0,n.useCallback)(async e=>{if(!e||e.trim().length<5)return void y(null);try{let t=JSON.parse(e);w(!0);let s=await fetch("/api/translator/detect",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({body:t})}),a=await s.json();a.success&&(y(a.format),d(a.format))}catch{}finally{w(!1)}},[]);(0,n.useEffect)(()=>{let e=setTimeout(()=>{_(p)},600);return()=>clearTimeout(e)},[p,_]);let C=async()=>{if(p.trim()){v(!0),f("");try{let e=JSON.parse(p),t=await fetch("/api/translator/translate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({step:"direct",sourceFormat:s,targetFormat:m,body:e})}),a=await t.json();a.success?f(JSON.stringify(a.result,null,2)):f(JSON.stringify({error:a.error},null,2))}catch(e){f(JSON.stringify({error:e.message},null,2))}v(!1)}},O=async e=>{try{await navigator.clipboard.writeText(e)}catch{}},T=o[s]||o.openai,P=o[m]||o.openai;return(0,a.jsxs)("div",{className:"space-y-5",children:[(0,a.jsxs)("div",{className:"flex items-start gap-3 px-4 py-3 rounded-lg bg-primary/5 border border-primary/10 text-sm text-text-muted",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-primary text-[20px] mt-0.5 shrink-0",children:"info"}),(0,a.jsxs)("div",{children:[(0,a.jsx)("p",{className:"font-medium text-text-main mb-0.5",children:e("formatConverter")}),(0,a.jsx)("p",{children:e("formatConverterDescription")})]})]}),(0,a.jsx)(l.Zp,{children:(0,a.jsxs)("div",{className:"p-4 flex flex-col sm:flex-row items-center gap-4",children:[(0,a.jsxs)("div",{className:"flex-1 w-full",children:[(0,a.jsx)("label",{className:"block text-xs font-medium text-text-muted mb-1.5 uppercase tracking-wider",children:e("source")}),(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("span",{className:`material-symbols-outlined text-[20px] text-${T.color}-500`,children:T.icon}),(0,a.jsx)(l.l6,{value:s,onChange:e=>{d(e.target.value),y(null)},options:c,className:"flex-1"}),b&&(0,a.jsx)(l.Ex,{variant:"primary",size:"sm",icon:"auto_awesome",children:e("auto")})]})]}),(0,a.jsx)("button",{onClick:()=>{d(m),x(s),h(g),f(""),y(null)},className:"p-2 rounded-full hover:bg-primary/10 text-text-muted hover:text-primary transition-all mt-4 sm:mt-5",title:e("swapFormats"),children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[24px]",children:"swap_horiz"})}),(0,a.jsxs)("div",{className:"flex-1 w-full",children:[(0,a.jsx)("label",{className:"block text-xs font-medium text-text-muted mb-1.5 uppercase tracking-wider",children:e("target")}),(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("span",{className:`material-symbols-outlined text-[20px] text-${P.color}-500`,children:P.icon}),(0,a.jsx)(l.l6,{value:m,onChange:e=>x(e.target.value),options:c,className:"flex-1"})]})]}),(0,a.jsx)("div",{className:"pt-0 sm:pt-5",children:(0,a.jsx)(l.$n,{icon:"arrow_forward",onClick:C,loading:j,disabled:!p.trim()||j,className:"whitespace-nowrap",children:e("translateAction")})})]})}),(0,a.jsxs)("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-4",children:[(0,a.jsx)(l.Zp,{children:(0,a.jsxs)("div",{className:"p-4 space-y-3",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px] text-text-muted",children:"input"}),(0,a.jsx)("h3",{className:"text-sm font-semibold text-text-main",children:e("input")}),b&&(0,a.jsx)(l.Ex,{variant:"info",size:"sm",dot:!0,children:o[b]?.label||b}),N&&(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px] text-text-muted animate-spin",children:"progress_activity"})]}),(0,a.jsxs)("div",{className:"flex items-center gap-1",children:[(0,a.jsx)("button",{onClick:()=>O(p),className:"p-1.5 rounded hover:bg-black/5 dark:hover:bg-white/5 text-text-muted hover:text-text-main transition-colors",title:t("copy"),children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[16px]",children:"content_copy"})}),(0,a.jsx)("button",{onClick:()=>{h(""),f(""),y(null),S(null)},className:"p-1.5 rounded hover:bg-black/5 dark:hover:bg-white/5 text-text-muted hover:text-text-main transition-colors",title:e("clear"),children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[16px]",children:"delete"})})]})]}),(0,a.jsx)("div",{className:"border border-border rounded-lg overflow-hidden",children:(0,a.jsx)(u,{height:"400px",defaultLanguage:"json",value:p,onChange:e=>h(e||""),theme:"vs-dark",options:{minimap:{enabled:!1},fontSize:12,lineNumbers:"on",scrollBeyondLastLine:!1,wordWrap:"on",automaticLayout:!0,formatOnPaste:!0,placeholder:e("inputPlaceholder")}})})]})}),(0,a.jsx)(l.Zp,{children:(0,a.jsxs)("div",{className:"p-4 space-y-3",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px] text-text-muted",children:"output"}),(0,a.jsx)("h3",{className:"text-sm font-semibold text-text-main",children:e("output")}),g&&(0,a.jsx)(l.Ex,{variant:"success",size:"sm",dot:!0,children:o[m]?.label||m})]}),(0,a.jsx)("div",{className:"flex items-center gap-1",children:(0,a.jsx)("button",{onClick:()=>O(g),className:"p-1.5 rounded hover:bg-black/5 dark:hover:bg-white/5 text-text-muted hover:text-text-main transition-colors",title:t("copy"),children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[16px]",children:"content_copy"})})})]}),(0,a.jsx)("div",{className:"border border-border rounded-lg overflow-hidden",children:(0,a.jsx)(u,{height:"400px",defaultLanguage:"json",value:g,theme:"vs-dark",options:{minimap:{enabled:!1},fontSize:12,lineNumbers:"on",scrollBeyondLastLine:!1,wordWrap:"on",automaticLayout:!0,readOnly:!0}})})]})})]}),(0,a.jsx)(l.Zp,{children:(0,a.jsxs)("div",{className:"p-4 space-y-3",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px] text-primary",children:"library_books"}),(0,a.jsx)("h3",{className:"text-sm font-semibold text-text-main",children:e("exampleTemplates")}),(0,a.jsx)("span",{className:"text-xs text-text-muted",children:e("exampleTemplatesHint")})]}),(0,a.jsx)("div",{className:"grid grid-cols-2 sm:grid-cols-3 md:grid-cols-6 gap-2",children:i.map(e=>(0,a.jsxs)("button",{onClick:()=>{h(JSON.stringify(e.formats[s]||e.formats.openai,null,2)),S(e.id),f("")},className:`
2
+ group flex flex-col items-center gap-1.5 p-3 rounded-lg border transition-all text-center
3
+ ${k===e.id?"border-primary bg-primary/5 text-primary":"border-border hover:border-primary/30 hover:bg-primary/5 text-text-muted hover:text-text-main"}
4
+ `,children:[(0,a.jsx)("span",{className:`material-symbols-outlined text-[22px] ${k===e.id?"text-primary":"text-text-muted group-hover:text-primary"} transition-colors`,children:e.icon}),(0,a.jsx)("span",{className:"text-xs font-medium leading-tight",children:e.name})]},e.id))}),k&&(0,a.jsxs)("div",{className:"flex items-center gap-2 text-xs text-text-muted",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"info"}),e("templateLoadHint",{format:o[s]?.label||s})]})]})})]})}var p=s(20909);function h(e="openai"){let[t,s]=(0,n.useState)(e),[a,r]=(0,n.useState)([]),[l,i]=(0,n.useState)(!0);return(0,n.useEffect)(()=>{(async()=>{try{let[e,t]=await Promise.all([fetch("/api/providers"),fetch("/api/provider-nodes")]),[a,n]=await Promise.all([e.json(),t.json()]),l=new Map((n.nodes||[]).map(e=>[e.id,e])),i=[...new Set((a.connections||[]).filter(e=>!1!==e.isActive).map(e=>e.provider))].map(e=>{let t=p.Q2[e],s=l.get(e),a=t?.name||s?.name||e;return!t&&e.startsWith(p.JH)&&(a=s?.name||"OpenAI Compatible"),!t&&e.startsWith(p.DI)&&(a=s?.name||"Anthropic Compatible"),{value:e,label:a}}).sort((e,t)=>e.label.localeCompare(t.label)),o=i.length>0?i:Object.entries(p.Q2).map(([e,t])=>({value:e,label:t.name}));r(o),o.length>0&&s(e=>o.some(t=>t.value===e)?e:o[0].value)}catch{let e=Object.entries(p.Q2).map(([e,t])=>({value:e,label:t.name}));r(e),e.length>0&&s(t=>e.some(e=>e.value===t)?t:e[0].value)}finally{i(!1)}})()},[]),{provider:t,setProvider:s,providerOptions:a,loading:l}}let g={openai:["gpt-","o1-","o3-","o4-"],"openai-responses":["gpt-","o1-","o3-","o4-"],claude:["claude-"],gemini:["gemini-"]};function f(){let[e,t]=(0,n.useState)(""),[s,a]=(0,n.useState)([]),[r,l]=(0,n.useState)(!0);(0,n.useEffect)(()=>{(async()=>{try{let e=await fetch("/api/v1/models"),t=((await e.json()).data||[]).map(e=>e.id).sort((e,t)=>e.localeCompare(t));a(t)}catch{a([])}finally{l(!1)}})()},[]);let i=(0,n.useCallback)(e=>{if(0===s.length)return"";for(let t of g[e]||[]){let e=s.find(e=>e.startsWith(t));if(e)return e}return s[0]},[s]);return{model:e,setModel:t,availableModels:s,loading:r,pickModelForFormat:i}}let b=m()(()=>s.e(8202).then(s.bind(s,28202)),{loadableGenerated:{webpack:()=>[28202]},ssr:!1});function y(){let e=(0,r.c)("translator"),{provider:t,setProvider:s,providerOptions:i}=h("openai"),{model:d,setModel:m,availableModels:u,pickModelForFormat:x}=f(),[p,g]=(0,n.useState)("openai"),[y,j]=(0,n.useState)(""),[v,N]=(0,n.useState)(!1),[w,k]=(0,n.useState)([]),[S,_]=(0,n.useState)(null),[C,O]=(0,n.useState)(null),T=(0,n.useRef)(null);(0,n.useEffect)(()=>{let e=x(p);e&&m(e)},[p,x,m]);let P=()=>{T.current?.scrollIntoView({behavior:"smooth"})},D=async()=>{if(!y.trim()||v)return;let s=y.trim();j(""),N(!0),k(e=>[...e,{role:"user",content:s}]);let a=[];try{let r,n=[...w.map(e=>({role:e.role,content:e.content})),{role:"user",content:s}];r="claude"===p?{model:d,max_tokens:1024,messages:n,stream:!0}:"gemini"===p?{model:d,contents:n.map(e=>({role:"assistant"===e.role?"model":"user",parts:[{text:e.content}]}))}:"openai-responses"===p?{model:d,input:n.map(e=>({type:"message",role:e.role,content:[{type:"input_text",text:e.content}]})),stream:!0}:{model:d,messages:n,stream:!0},a.push({id:1,name:e("clientRequest"),description:e("clientRequestDescription"),format:p,content:JSON.stringify(r,null,2),status:"done"});let l=await fetch("/api/translator/detect",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({body:r})}),i=(await l.json()).format||p;a.push({id:2,name:e("formatDetected"),description:e("formatDetectedDescription"),format:i,content:JSON.stringify({detectedFormat:i,clientFormat:p,match:i===p},null,2),status:"done"});let o=await fetch("/api/translator/translate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({step:"direct",sourceFormat:i,targetFormat:"openai",body:r})}),c=await o.json();a.push({id:3,name:e("openaiIntermediate"),description:e("openaiIntermediateDescription"),format:"openai",content:JSON.stringify(c.result||c,null,2),status:c.success?"done":"error"});let m=await fetch("/api/translator/translate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({step:"direct",sourceFormat:"openai",provider:t,body:c.result})}),u=await m.json(),x=u.targetFormat||"openai";a.push({id:4,name:e("providerFormat"),description:e("providerFormatDescription"),format:x,content:JSON.stringify(u.result||u,null,2),status:u.success?"done":"error"});let h=await fetch("/api/translator/send",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:t,body:u.result||c.result})});if(h.ok){let t=h.body.getReader(),s=new TextDecoder,r="";for(;;){let{done:e,value:a}=await t.read();if(e)break;r+=s.decode(a,{stream:!0})}a.push({id:5,name:e("providerResponse"),description:e("providerResponseSseDescription"),format:x,content:r.slice(0,5e3)+(r.length>5e3?"\n... (truncated)":""),status:"done"});let n=function(e){let t="";for(let s of e.split("\n")){if(!s.startsWith("data: "))continue;let e=s.slice(6).trim();if("[DONE]"===e)break;try{let s=JSON.parse(e),a=s.choices?.[0]?.delta;a?.content&&(t+=a.content),"content_block_delta"===s.type&&s.delta?.text&&(t+=s.delta.text)}catch{}}return t||e.slice(0,500)}(r);k(t=>[...t,{role:"assistant",content:n||e("noTextExtracted")}])}else{let t=await h.json().catch(()=>({error:e("requestFailed")}));a.push({id:5,name:e("providerResponse"),description:e("providerResponseRawDescription"),format:x,content:JSON.stringify(t,null,2),status:"error"}),k(s=>[...s,{role:"assistant",content:e("errorMessage",{message:t.error||e("requestFailed")})}])}}catch(t){a.push({id:a.length+1,name:e("error"),description:e("unexpectedError"),format:"error",content:JSON.stringify({error:t.message},null,2),status:"error"}),k(s=>[...s,{role:"assistant",content:e("errorMessage",{message:t.message})}])}_(a),O(a.length>0?a[a.length-1].id:null),N(!1),setTimeout(P,100)};return(0,a.jsxs)("div",{className:"space-y-4",children:[(0,a.jsxs)("div",{className:"flex items-start gap-3 px-4 py-3 rounded-lg bg-primary/5 border border-primary/10 text-sm text-text-muted",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-primary text-[20px] mt-0.5 shrink-0",children:"info"}),(0,a.jsxs)("div",{children:[(0,a.jsx)("p",{className:"font-medium text-text-main mb-0.5",children:e("pipelineDebugger")}),(0,a.jsx)("p",{children:e("chatTesterDescription")}),(0,a.jsxs)("p",{children:[(0,a.jsx)("strong",{className:"text-text-main",children:e("chatTesterFlow")}),"."," ",e("clickStepToInspect")]})]})]}),(0,a.jsxs)("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-4",children:[(0,a.jsxs)("div",{className:"space-y-4",children:[(0,a.jsx)(l.Zp,{children:(0,a.jsxs)("div",{className:"p-4 flex flex-col gap-3",children:[(0,a.jsxs)("div",{className:"flex flex-col sm:flex-row gap-3",children:[(0,a.jsxs)("div",{className:"flex-1",children:[(0,a.jsx)("label",{className:"block text-xs font-medium text-text-muted mb-1 uppercase tracking-wider",children:e("clientFormat")}),(0,a.jsx)(l.l6,{value:p,onChange:e=>g(e.target.value),options:c.filter(e=>["openai","claude","gemini","openai-responses"].includes(e.value))})]}),(0,a.jsxs)("div",{className:"flex-1",children:[(0,a.jsx)("label",{className:"block text-xs font-medium text-text-muted mb-1 uppercase tracking-wider",children:e("provider")}),(0,a.jsx)(l.l6,{value:t,onChange:e=>s(e.target.value),options:i})]})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("label",{className:"block text-xs font-medium text-text-muted mb-1 uppercase tracking-wider",children:e("model")}),(0,a.jsxs)("div",{className:"relative",children:[(0,a.jsx)("input",{type:"text",value:d,onChange:e=>m(e.target.value),list:"model-suggestions",placeholder:e("modelPlaceholder"),className:"w-full bg-bg-subtle border border-border rounded-lg px-3 py-2 text-sm text-text-main placeholder:text-text-muted focus:outline-none focus:border-primary transition-colors"}),(0,a.jsx)("datalist",{id:"model-suggestions",children:u.map(e=>(0,a.jsx)("option",{value:e},e))})]})]})]})}),(0,a.jsxs)(l.Zp,{className:"min-h-[400px] flex flex-col",children:[(0,a.jsxs)("div",{className:"p-4 flex-1 overflow-y-auto max-h-[500px] space-y-3",children:[0===w.length&&(0,a.jsxs)("div",{className:"flex flex-col items-center justify-center h-full text-text-muted py-12",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[48px] mb-3 opacity-30",children:"chat"}),(0,a.jsx)("p",{className:"text-sm font-medium mb-1",children:e("sendMessageToSeePipeline")}),(0,a.jsxs)("p",{className:"text-xs text-center max-w-xs",children:[e("chatMessageHintPrefix")," ",(0,a.jsx)("strong",{children:o[p]?.label})," ",e("chatMessageHintSuffix")]})]}),w.map((t,s)=>(0,a.jsx)("div",{className:`flex ${"user"===t.role?"justify-end":"justify-start"}`,children:(0,a.jsxs)("div",{className:`max-w-[85%] rounded-lg px-3 py-2 text-sm ${"user"===t.role?"bg-primary/10 text-text-main border border-primary/20":"bg-bg-subtle text-text-main border border-border"}`,children:[(0,a.jsx)("p",{className:"text-[10px] font-semibold text-text-muted mb-1 uppercase",children:"user"===t.role?e("youWithFormat",{format:o[p]?.label}):e("assistant")}),(0,a.jsx)("p",{className:"whitespace-pre-wrap",children:t.content})]})},s)),(0,a.jsx)("div",{ref:T})]}),(0,a.jsx)("div",{className:"p-3 border-t border-border",children:(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsx)("input",{type:"text",value:y,onChange:e=>j(e.target.value),onKeyDown:e=>"Enter"===e.key&&!e.shiftKey&&D(),placeholder:e("typeMessage"),className:"flex-1 bg-bg-subtle border border-border rounded-lg px-3 py-2 text-sm text-text-main placeholder:text-text-muted focus:outline-none focus:border-primary transition-colors",disabled:v}),(0,a.jsx)(l.$n,{icon:"send",onClick:D,loading:v,disabled:!y.trim()||v,children:e("send")})]})})]})]}),(0,a.jsxs)("div",{className:"space-y-4",children:[(0,a.jsx)(l.Zp,{children:(0,a.jsxs)("div",{className:"p-4 space-y-1",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px] text-primary",children:"account_tree"}),(0,a.jsx)("h3",{className:"text-sm font-semibold text-text-main",children:e("translationPipeline")})]}),(0,a.jsx)("p",{className:"text-xs text-text-muted",children:e("clickStepToInspect")})]})}),S?(0,a.jsx)("div",{className:"space-y-2",children:S.map((e,t)=>{let s=o[e.format]||{label:e.format,color:"gray",icon:"code"},r=C===e.id;return(0,a.jsxs)("div",{children:[t>0&&(0,a.jsx)("div",{className:"flex justify-center py-1",children:(0,a.jsx)("div",{className:"w-px h-4 bg-border"})}),(0,a.jsxs)(l.Zp,{className:"error"===e.status?"border-red-500/30":r?"border-primary/30":"",children:[(0,a.jsxs)("button",{onClick:()=>O(r?null:e.id),className:"w-full p-3 flex items-center gap-3 text-left",children:[(0,a.jsx)("div",{className:`flex items-center justify-center w-7 h-7 rounded-full text-xs font-bold ${"error"===e.status?"bg-red-500/10 text-red-500":"done"===e.status?`bg-${s.color}-500/10 text-${s.color}-500`:"bg-bg-subtle text-text-muted"}`,children:"error"===e.status?"!":e.id}),(0,a.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,a.jsx)("p",{className:"text-sm font-medium text-text-main",children:e.name}),e.description&&(0,a.jsx)("p",{className:"text-[10px] text-text-muted truncate",children:e.description})]}),(0,a.jsx)(l.Ex,{variant:"error"===e.status?"error":"default",size:"sm",children:s.label}),(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px] text-text-muted",children:r?"expand_less":"expand_more"})]}),r&&(0,a.jsx)("div",{className:"px-3 pb-3",children:(0,a.jsx)("div",{className:"border border-border rounded-lg overflow-hidden",children:(0,a.jsx)(b,{height:"250px",defaultLanguage:"json",value:e.content,theme:"vs-dark",options:{minimap:{enabled:!1},fontSize:11,lineNumbers:"on",scrollBeyondLastLine:!1,wordWrap:"on",automaticLayout:!0,readOnly:!0}})})})]})]},e.id)})}):(0,a.jsx)(l.Zp,{children:(0,a.jsxs)("div",{className:"p-8 flex flex-col items-center justify-center text-text-muted",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[48px] mb-3 opacity-30",children:"account_tree"}),(0,a.jsx)("p",{className:"text-sm font-medium mb-1",children:e("pipelineVisualization")}),(0,a.jsx)("p",{className:"text-xs text-center max-w-xs",children:e("pipelineVisualizationHint")})]})})]})]})]})}let j=[{id:"simple-chat",name:"Simple Chat",icon:"chat",templateId:"simple-chat"},{id:"tool-calling",name:"Tool Calling",icon:"build",templateId:"tool-calling"},{id:"multi-turn",name:"Multi-turn",icon:"forum",templateId:"multi-turn"},{id:"thinking",name:"Thinking",icon:"psychology",templateId:"thinking"},{id:"system-prompt",name:"System Prompt",icon:"settings",templateId:"system-prompt"},{id:"streaming",name:"Streaming",icon:"stream",templateId:"streaming"}];function v(){let e=(0,r.c)("translator"),[t,s]=(0,n.useState)("claude"),{provider:d,setProvider:m,providerOptions:u}=h("openai"),{model:x,setModel:p,availableModels:g,pickModelForFormat:b}=f(),[y,v]=(0,n.useState)({}),[N,w]=(0,n.useState)(!1);(0,n.useEffect)(()=>{let e=b(t);e&&p(e)},[t,b,p]);let k=async e=>{v(t=>({...t,[e.id]:{status:"running"}}));let s=Date.now();try{let a=i.find(t=>t.id===e.templateId),r=a?.formats[t]||a?.formats.openai;if(!r)return void v(t=>({...t,[e.id]:{status:"error",error:"No template for this format",latency:0}}));let n={...r,model:x};r.contents&&(n.model=x);let l=await fetch("/api/translator/translate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({step:"direct",sourceFormat:t,provider:d,body:n})}),o=await l.json();if(!o.success)return void v(t=>({...t,[e.id]:{status:"error",error:`Translation failed: ${o.error}`,latency:Date.now()-s}}));let c=await fetch("/api/translator/send",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:d,body:o.result})}),m=Date.now()-s;if(!c.ok){let t=await c.json().catch(()=>({}));v(s=>({...s,[e.id]:{status:"error",error:t.error||`HTTP ${c.status}`,latency:m,httpStatus:c.status}}));return}let u=c.body.getReader(),p=0;for(;;){let{done:e}=await u.read();if(e)break;p++}v(t=>({...t,[e.id]:{status:"pass",latency:Date.now()-s,chunks:p}}))}catch(t){v(a=>({...a,[e.id]:{status:"error",error:t.message,latency:Date.now()-s}}))}},S=async()=>{for(let e of(w(!0),v({}),j))await k(e);w(!1)},_=Object.values(y).filter(e=>"pass"===e.status).length,C=Object.values(y).filter(e=>"error"===e.status).length,O=_+C,T=O>0?Math.round(_/O*100):0,P=o[t]||o.openai;return(0,a.jsxs)("div",{className:"space-y-5",children:[(0,a.jsxs)("div",{className:"flex items-start gap-3 px-4 py-3 rounded-lg bg-primary/5 border border-primary/10 text-sm text-text-muted",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-primary text-[20px] mt-0.5 shrink-0",children:"info"}),(0,a.jsxs)("div",{children:[(0,a.jsx)("p",{className:"font-medium text-text-main mb-0.5",children:e("compatibilityTester")}),(0,a.jsx)("p",{children:"Run predefined scenarios (Simple Chat, Tool Calling, etc.) to verify translation and provider compatibility. Select a source format and target provider, then run all tests to see a compatibility percentage. Use this to find which features work across providers."})]})]}),(0,a.jsx)(l.Zp,{children:(0,a.jsxs)("div",{className:"p-4 flex flex-col gap-4",children:[(0,a.jsxs)("div",{className:"flex flex-col sm:flex-row items-end gap-4",children:[(0,a.jsxs)("div",{className:"flex-1 w-full",children:[(0,a.jsx)("label",{className:"block text-xs font-medium text-text-muted mb-1.5 uppercase tracking-wider",children:"Source Format"}),(0,a.jsx)(l.l6,{value:t,onChange:e=>{s(e.target.value),v({})},options:c.filter(e=>["openai","claude","gemini","openai-responses"].includes(e.value))})]}),(0,a.jsx)("div",{className:"flex items-center justify-center px-2",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[22px] text-text-muted",children:"arrow_forward"})}),(0,a.jsxs)("div",{className:"flex-1 w-full",children:[(0,a.jsx)("label",{className:"block text-xs font-medium text-text-muted mb-1.5 uppercase tracking-wider",children:"Target Provider"}),(0,a.jsx)(l.l6,{value:d,onChange:e=>{m(e.target.value),v({})},options:u})]}),(0,a.jsx)(l.$n,{icon:"play_arrow",onClick:S,loading:N,disabled:N,children:"Run All Tests"})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("label",{className:"block text-xs font-medium text-text-muted mb-1.5 uppercase tracking-wider",children:"Model"}),(0,a.jsxs)("div",{className:"relative",children:[(0,a.jsx)("input",{type:"text",value:x,onChange:e=>p(e.target.value),list:"testbench-model-suggestions",placeholder:"Select or type a model name...",className:"w-full bg-bg-subtle border border-border rounded-lg px-3 py-2 text-sm text-text-main placeholder:text-text-muted focus:outline-none focus:border-primary transition-colors"}),(0,a.jsx)("datalist",{id:"testbench-model-suggestions",children:g.map(e=>(0,a.jsx)("option",{value:e},e))})]})]})]})}),O>0&&(0,a.jsx)(l.Zp,{children:(0,a.jsxs)("div",{className:"p-4",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between mb-3",children:[(0,a.jsxs)("div",{className:"flex items-center gap-3",children:[(0,a.jsx)("h3",{className:"text-sm font-semibold text-text-main",children:e("compatibilityReport")}),(0,a.jsxs)(l.Ex,{variant:T>=80?"success":T>=50?"warning":"error",size:"lg",children:[T,"%"]})]}),(0,a.jsxs)("div",{className:"flex items-center gap-3 text-xs text-text-muted",children:[(0,a.jsxs)("span",{className:"flex items-center gap-1",children:[(0,a.jsx)("span",{className:"size-2 rounded-full bg-green-500"})," ",_," passed"]}),(0,a.jsxs)("span",{className:"flex items-center gap-1",children:[(0,a.jsx)("span",{className:"size-2 rounded-full bg-red-500"})," ",C," failed"]})]})]}),(0,a.jsx)("div",{className:"w-full h-2 bg-bg-subtle rounded-full overflow-hidden",children:(0,a.jsx)("div",{className:"h-full bg-gradient-to-r from-green-500 to-emerald-400 rounded-full transition-all duration-500",style:{width:`${T}%`}})})]})}),(0,a.jsx)("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-3",children:j.map(e=>{let t=y[e.id],s=t?.status==="running";return(0,a.jsx)(l.Zp,{className:`transition-all ${t?.status==="pass"?"border-green-500/30":t?.status==="error"?"border-red-500/30":""}`,children:(0,a.jsxs)("div",{className:"p-4 space-y-3",children:[(0,a.jsx)("div",{className:"flex items-center justify-between",children:(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("div",{className:`flex items-center justify-center w-9 h-9 rounded-lg ${t?.status==="pass"?"bg-green-500/10 text-green-500":t?.status==="error"?"bg-red-500/10 text-red-500":"bg-bg-subtle text-text-muted"}`,children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[20px]",children:s?"progress_activity":t?.status==="pass"?"check_circle":t?.status==="error"?"error":e.icon})}),(0,a.jsxs)("div",{children:[(0,a.jsx)("p",{className:"text-sm font-medium text-text-main",children:e.name}),(0,a.jsxs)("p",{className:"text-[10px] text-text-muted uppercase",children:[P.label," →"," ",u.find(e=>e.value===d)?.label||d]})]})]})}),t&&"running"!==t.status&&(0,a.jsx)("div",{className:`rounded-lg p-2 text-xs ${"pass"===t.status?"bg-green-500/5 text-green-600 dark:text-green-400":"bg-red-500/5 text-red-600 dark:text-red-400"}`,children:"pass"===t.status?(0,a.jsxs)("div",{className:"flex items-center justify-between",children:[(0,a.jsx)("span",{children:"✅ Passed"}),(0,a.jsxs)("span",{className:"text-text-muted",children:[t.latency,"ms • ",t.chunks," chunks"]})]}):(0,a.jsxs)("div",{children:[(0,a.jsxs)("p",{children:["❌ ",t.error]}),(0,a.jsxs)("p",{className:"text-text-muted mt-0.5",children:[t.latency,"ms"]})]})}),(0,a.jsx)(l.$n,{size:"sm",variant:t?.status==="pass"?"ghost":"outline",icon:s?"progress_activity":"play_arrow",onClick:()=>k(e),disabled:s||N,className:"w-full",children:s?"Running...":t?"Re-run":"Run Test"})]})},e.id)})})]})}function N(){let e=(0,r.c)("translator"),t=(0,r.c)("common"),[s,i]=(0,n.useState)([]),[c,d]=(0,n.useState)(!0),[m,u]=(0,n.useState)(!0),x=(0,n.useRef)(null),p=async()=>{try{let e=await fetch("/api/translator/history?limit=50");if(e.ok){let t=await e.json();i(t.events||[])}}catch{}finally{d(!1)}};(0,n.useEffect)(()=>(p(),m&&(x.current=setInterval(p,3e3)),()=>{x.current&&clearInterval(x.current)}),[m]);let h=s.filter(e=>"success"===e.status).length,g=s.filter(e=>"error"===e.status).length,f=s.length>0?Math.round(s.reduce((e,t)=>e+(t.latency||0),0)/s.length):0;return(0,a.jsxs)("div",{className:"space-y-5",children:[(0,a.jsxs)("div",{className:"flex items-start gap-3 px-4 py-3 rounded-lg bg-primary/5 border border-primary/10 text-sm text-text-muted",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-primary text-[20px] mt-0.5 shrink-0",children:"info"}),(0,a.jsxs)("div",{children:[(0,a.jsx)("p",{className:"font-medium text-text-main mb-0.5",children:e("realtime")}),(0,a.jsxs)("p",{children:[e("liveMonitorDescriptionPrefix")," ",(0,a.jsx)("strong",{className:"text-text-main",children:e("chatTester")}),","," ",(0,a.jsx)("strong",{className:"text-text-main",children:e("testBench")}),e("liveMonitorDescriptionSuffix")]})]})]}),(0,a.jsxs)("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-3",children:[(0,a.jsx)(w,{icon:"translate",label:e("totalTranslations"),value:s.length,color:"blue"}),(0,a.jsx)(w,{icon:"check_circle",label:e("successful"),value:h,color:"green"}),(0,a.jsx)(w,{icon:"error",label:e("errors"),value:g,color:"red"}),(0,a.jsx)(w,{icon:"speed",label:e("avgLatency"),value:`${f}ms`,color:"purple"})]}),(0,a.jsx)(l.Zp,{children:(0,a.jsxs)("div",{className:"p-3 flex items-center justify-between",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("span",{className:`material-symbols-outlined text-[18px] ${m?"text-green-500 animate-pulse":"text-text-muted"}`,children:m?"radio_button_checked":"radio_button_unchecked"}),(0,a.jsx)("button",{onClick:()=>u(!m),className:"text-sm text-text-main hover:text-primary transition-colors",children:m?e("liveAutoRefreshing"):e("paused")})]}),(0,a.jsxs)("button",{onClick:p,className:"flex items-center gap-1 text-xs text-text-muted hover:text-primary transition-colors",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[16px]",children:"refresh"}),t("refresh")]})]})}),(0,a.jsx)(l.Zp,{children:(0,a.jsxs)("div",{className:"p-4",children:[(0,a.jsx)("h3",{className:"text-sm font-semibold text-text-main mb-3",children:e("recentTranslations")}),c?(0,a.jsxs)("div",{className:"flex items-center justify-center py-12 text-text-muted",children:[(0,a.jsx)("span",{className:"material-symbols-outlined animate-spin mr-2",children:"progress_activity"}),t("loading")]}):0===s.length?(0,a.jsxs)("div",{className:"flex flex-col items-center justify-center py-12 text-text-muted",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[48px] mb-3 opacity-30",children:"monitoring"}),(0,a.jsx)("p",{className:"text-sm font-medium mb-1",children:e("noTranslations")}),(0,a.jsx)("p",{className:"text-xs text-center max-w-sm",children:e("eventsAppearHint")}),(0,a.jsxs)("div",{className:"flex flex-wrap gap-2 mt-3 text-xs",children:[(0,a.jsx)("span",{className:"px-2 py-1 rounded-md bg-bg-subtle border border-border",children:e("chatTesterTab")}),(0,a.jsx)("span",{className:"px-2 py-1 rounded-md bg-bg-subtle border border-border",children:e("testBenchTab")}),(0,a.jsx)("span",{className:"px-2 py-1 rounded-md bg-bg-subtle border border-border",children:e("externalApiCalls")}),(0,a.jsx)("span",{className:"px-2 py-1 rounded-md bg-bg-subtle border border-border",children:e("ideCliIntegrations")})]}),(0,a.jsx)("p",{className:"text-[10px] mt-3 text-text-muted/70",children:e("inMemoryNote")})]}):(0,a.jsx)("div",{className:"overflow-x-auto",children:(0,a.jsxs)("table",{className:"w-full text-sm",children:[(0,a.jsx)("thead",{children:(0,a.jsxs)("tr",{className:"text-left text-xs text-text-muted border-b border-border",children:[(0,a.jsx)("th",{className:"pb-2 pr-4",children:e("time")}),(0,a.jsx)("th",{className:"pb-2 pr-4",children:e("source")}),(0,a.jsx)("th",{className:"pb-2 pr-4"}),(0,a.jsx)("th",{className:"pb-2 pr-4",children:e("target")}),(0,a.jsx)("th",{className:"pb-2 pr-4",children:e("model")}),(0,a.jsx)("th",{className:"pb-2 pr-4",children:e("status")}),(0,a.jsx)("th",{className:"pb-2 text-right",children:e("latency")})]})}),(0,a.jsx)("tbody",{children:s.map((t,s)=>{let r=o[t.sourceFormat]||{label:t.sourceFormat||"?",color:"gray"},n=o[t.targetFormat]||{label:t.targetFormat||"?",color:"gray"};return(0,a.jsxs)("tr",{className:"border-b border-border/50 hover:bg-bg-subtle/50 transition-colors",children:[(0,a.jsx)("td",{className:"py-2 pr-4 text-xs text-text-muted whitespace-nowrap",children:t.timestamp?new Date(t.timestamp).toLocaleTimeString():"—"}),(0,a.jsx)("td",{className:"py-2 pr-4",children:(0,a.jsx)(l.Ex,{variant:"default",size:"sm",children:r.label})}),(0,a.jsx)("td",{className:"py-2 pr-4 text-text-muted",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"arrow_forward"})}),(0,a.jsx)("td",{className:"py-2 pr-4",children:(0,a.jsx)(l.Ex,{variant:"primary",size:"sm",children:n.label})}),(0,a.jsx)("td",{className:"py-2 pr-4 text-xs font-mono text-text-muted",children:t.model||"—"}),(0,a.jsx)("td",{className:"py-2 pr-4",children:"success"===t.status?(0,a.jsx)(l.Ex,{variant:"success",size:"sm",dot:!0,children:e("ok")}):(0,a.jsx)(l.Ex,{variant:"error",size:"sm",dot:!0,children:t.statusCode||e("errorShort")})}),(0,a.jsx)("td",{className:"py-2 text-right text-xs text-text-muted",children:t.latency?`${t.latency}ms`:"—"})]},t.id||s)})})]})})]})})]})}function w({icon:e,label:t,value:s,color:r}){return(0,a.jsx)(l.Zp,{children:(0,a.jsxs)("div",{className:"p-4 flex items-center gap-3",children:[(0,a.jsx)("div",{className:`flex items-center justify-center w-10 h-10 rounded-lg bg-${r}-500/10`,children:(0,a.jsx)("span",{className:`material-symbols-outlined text-[22px] text-${r}-500`,children:e})}),(0,a.jsxs)("div",{children:[(0,a.jsx)("p",{className:"text-lg font-bold text-text-main",children:s}),(0,a.jsx)("p",{className:"text-[10px] text-text-muted uppercase tracking-wider",children:t})]})]})})}function k(){let e=(0,r.c)("translator"),[t,s]=(0,n.useState)("playground"),i=[{value:"playground",label:e("playground"),icon:"code"},{value:"chat-tester",label:e("chatTester"),icon:"chat"},{value:"test-bench",label:e("testBench"),icon:"science"},{value:"live-monitor",label:e("liveMonitor"),icon:"monitoring"}],o={playground:e("modeDescriptionPlayground"),"chat-tester":e("modeDescriptionChatTester"),"test-bench":e("modeDescriptionTestBench"),"live-monitor":e("modeDescriptionLiveMonitor")};return(0,a.jsxs)("div",{className:"p-8 space-y-6",children:[(0,a.jsxs)("div",{className:"flex flex-col sm:flex-row items-start sm:items-center justify-between gap-4",children:[(0,a.jsxs)("div",{children:[(0,a.jsxs)("h1",{className:"text-2xl font-bold text-text-main flex items-center gap-2",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-primary text-[28px]",children:"translate"}),e("playgroundTitle")]}),(0,a.jsx)("p",{className:"text-sm text-text-muted mt-1",children:o[t]||e("modeDescriptionFallback")})]}),(0,a.jsx)(l.Iz,{options:i,value:t,onChange:s,size:"md"})]}),"playground"===t&&(0,a.jsx)(x,{}),"chat-tester"===t&&(0,a.jsx)(y,{}),"test-bench"===t&&(0,a.jsx)(v,{}),"live-monitor"===t&&(0,a.jsx)(N,{})]})}},5214:(e,t,s)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),Object.defineProperty(t,"workAsyncStorage",{enumerable:!0,get:function(){return a.workAsyncStorageInstance}});let a=s(17828)},17828:(e,t,s)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),Object.defineProperty(t,"workAsyncStorageInstance",{enumerable:!0,get:function(){return a}});let a=(0,s(64054).createAsyncLocalStorage)()},21957:(e,t,s)=>{"use strict";function a({moduleIds:e}){return null}Object.defineProperty(t,"__esModule",{value:!0}),Object.defineProperty(t,"PreloadChunks",{enumerable:!0,get:function(){return a}}),s(95155),s(47650),s(5214),s(2451),s(53887)},41112:(e,t,s)=>{"use strict";function a({reason:e,children:t}){return t}Object.defineProperty(t,"__esModule",{value:!0}),Object.defineProperty(t,"BailoutToCSR",{enumerable:!0,get:function(){return a}}),s(1980)},64054:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});var s={bindSnapshot:function(){return o},createAsyncLocalStorage:function(){return i},createSnapshot:function(){return c}};for(var a in s)Object.defineProperty(t,a,{enumerable:!0,get:s[a]});let r=Object.defineProperty(Error("Invariant: AsyncLocalStorage accessed in runtime where it is not available"),"__NEXT_ERROR_CODE",{value:"E504",enumerable:!1,configurable:!0});class n{disable(){throw r}getStore(){}run(){throw r}exit(){throw r}enterWith(){throw r}static bind(e){return e}}let l="u">typeof globalThis&&globalThis.AsyncLocalStorage;function i(){return l?new l:new n}function o(e){return l?l.bind(e):n.bind(e)}function c(){return l?l.snapshot():function(e,...t){return e(...t)}}},65355:(e,t,s)=>{Promise.resolve().then(s.bind(s,2824))},68635:(e,t,s)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),Object.defineProperty(t,"default",{enumerable:!0,get:function(){return o}});let a=s(95155),r=s(12115),n=s(41112);function l(e){return{default:e&&"default"in e?e.default:e}}s(21957);let i={loader:()=>Promise.resolve(l(()=>null)),loading:null,ssr:!0},o=function(e){let t={...i,...e},s=(0,r.lazy)(()=>t.loader().then(l)),o=t.loading;function c(e){let l=o?(0,a.jsx)(o,{isLoading:!0,pastDelay:!0,error:null}):null,i=!t.ssr||!!t.loading,c=i?r.Suspense:r.Fragment,d=t.ssr?(0,a.jsxs)(a.Fragment,{children:[null,(0,a.jsx)(s,{...e})]}):(0,a.jsx)(n.BailoutToCSR,{reason:"next/dynamic",children:(0,a.jsx)(s,{...e})});return(0,a.jsx)(c,{...i?{fallback:l}:{},children:d})}return c.displayName="LoadableComponent",c}},75707:(e,t,s)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),Object.defineProperty(t,"default",{enumerable:!0,get:function(){return r}});let a=s(73623)._(s(68635));function r(e,t){let s={};"function"==typeof e&&(s.loader=e);let r={...s,...t};return(0,a.default)({...r,modules:r.loadableGenerated?.modules})}("function"==typeof t.default||"object"==typeof t.default&&null!==t.default)&&void 0===t.default.__esModule&&(Object.defineProperty(t.default,"__esModule",{value:!0}),Object.assign(t.default,t),e.exports=t.default)}},e=>{e.O(0,[3418,8500,9751,782,6458,5846,993,8441,3794,7358],()=>e(e.s=65355)),_N_E=e.O()}]);
@@ -0,0 +1 @@
1
+ (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[2162],{40182:(e,s,t)=>{"use strict";t.r(s),t.d(s,{default:()=>d});var l=t(95155),a=t(50910),r=t(98500),i=t.n(r),n=t(40993);function d(){let e=(0,a.c)("auth");return(0,l.jsx)("div",{className:"min-h-screen flex items-center justify-center bg-bg p-4",children:(0,l.jsxs)("div",{className:"w-full max-w-lg",children:[(0,l.jsxs)("div",{className:"text-center mb-8",children:[(0,l.jsx)("h1",{className:"text-3xl font-bold text-primary mb-2",children:e("resetPassword")}),(0,l.jsx)("p",{className:"text-text-muted",children:e("resetDescription")})]}),(0,l.jsx)(n.Zp,{className:"mb-4",children:(0,l.jsxs)("div",{className:"flex items-start gap-4 p-2",children:[(0,l.jsx)("div",{className:"flex items-center justify-center size-10 rounded-lg bg-primary/10 text-primary shrink-0 mt-0.5",children:(0,l.jsx)("span",{className:"material-symbols-outlined text-[20px]",children:"terminal"})}),(0,l.jsxs)("div",{className:"flex-1",children:[(0,l.jsx)("h2",{className:"text-lg font-semibold mb-1",children:"Method 1: CLI Reset"}),(0,l.jsx)("p",{className:"text-sm text-text-muted mb-3",children:"Run the following command on the server where OmniRoute is running:"}),(0,l.jsx)("div",{className:"bg-black/30 rounded-lg p-3 mb-3 font-mono text-sm text-green-400 border border-white/5",children:(0,l.jsx)("code",{children:"npx omniroute reset-password"})}),(0,l.jsx)("p",{className:"text-xs text-text-muted",children:"This will prompt you to set a new password. The server must be stopped first."})]})]})}),(0,l.jsx)(n.Zp,{className:"mb-6",children:(0,l.jsxs)("div",{className:"flex items-start gap-4 p-2",children:[(0,l.jsx)("div",{className:"flex items-center justify-center size-10 rounded-lg bg-amber-500/10 text-amber-500 shrink-0 mt-0.5",children:(0,l.jsx)("span",{className:"material-symbols-outlined text-[20px]",children:"database"})}),(0,l.jsxs)("div",{className:"flex-1",children:[(0,l.jsx)("h2",{className:"text-lg font-semibold mb-1",children:"Method 2: Manual Reset"}),(0,l.jsx)("p",{className:"text-sm text-text-muted mb-3",children:"Delete the password from the database and set a new one on startup:"}),(0,l.jsxs)("ol",{className:"text-sm text-text-muted space-y-2 list-decimal list-inside mb-3",children:[(0,l.jsx)("li",{children:e("stopServer")}),(0,l.jsxs)("li",{children:["Set a new password in your"," ",(0,l.jsx)("code",{className:"bg-black/30 px-1 rounded text-text-main",children:".env"})," file:",(0,l.jsx)("div",{className:"bg-black/30 rounded-lg p-2 mt-1 font-mono text-xs text-green-400 border border-white/5",children:"INITIAL_PASSWORD=your_new_password"})]}),(0,l.jsxs)("li",{children:["Delete"," ",(0,l.jsx)("code",{className:"bg-black/30 px-1 rounded text-text-main",children:"data/settings.json"})," ","(or remove the"," ",(0,l.jsx)("code",{className:"bg-black/30 px-1 rounded text-text-main",children:"passwordHash"})," ","field)"]}),(0,l.jsx)("li",{children:"Restart the server — it will use the new password"})]})]})]})}),(0,l.jsx)("div",{className:"text-center",children:(0,l.jsxs)(i(),{href:"/login",className:"text-sm text-primary hover:underline inline-flex items-center gap-1",children:[(0,l.jsx)("span",{className:"material-symbols-outlined text-[16px]",children:"arrow_back"}),"Back to Login"]})})]})})}},50057:(e,s,t)=>{Promise.resolve().then(t.bind(t,40182))}},e=>{e.O(0,[3418,8500,9751,782,6458,5846,993,8441,3794,7358],()=>e(e.s=50057)),_N_E=e.O()}]);
@@ -0,0 +1 @@
1
+ (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[4520],{13504:(e,t,s)=>{"use strict";s.r(t),s.d(t,{default:()=>d});var a=s(95155),r=s(50910),i=s(12115),n=s(40993),l=s(73321);function d(){let e=(0,r.c)("auth"),[t,s]=(0,i.useState)(""),[d,c]=(0,i.useState)(""),[o,m]=(0,i.useState)(!1),[x,u]=(0,i.useState)(null),[h,p]=(0,i.useState)(null),[b,f]=(0,i.useState)(!1),y=(0,l.useRouter)();(0,i.useEffect)(()=>{f(!0),async function(){let e=new AbortController,t=setTimeout(()=>e.abort(),5e3),s=window.location.origin;try{let a=await fetch(`${s}/api/settings`,{signal:e.signal});if(clearTimeout(t),a.ok){let e=await a.json();if(!1===e.requireLogin){y.push("/dashboard"),y.refresh();return}u(!!e.hasPassword),p(!!e.setupComplete)}else u(!0),p(!0)}catch(e){clearTimeout(t),u(!0),p(!0)}}()},[y]);let j=async e=>{e.preventDefault(),m(!0),c("");try{let e=await fetch("/api/auth/login",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({password:t})});if(e.ok)sessionStorage.setItem("omniroute_login_time",String(Date.now())),y.push("/dashboard"),y.refresh();else{let t=await e.json();c(t.error||"Invalid password")}}catch(e){c("An error occurred. Please try again.")}finally{m(!1)}};return null===x||null===h?(0,a.jsx)("div",{className:"min-h-screen flex items-center justify-center bg-bg",children:(0,a.jsxs)("div",{className:"flex flex-col items-center gap-3",children:[(0,a.jsxs)("div",{className:"relative",children:[(0,a.jsx)("div",{className:"w-10 h-10 border-2 border-primary/20 rounded-full"}),(0,a.jsx)("div",{className:"absolute inset-0 w-10 h-10 border-2 border-primary border-t-transparent rounded-full animate-spin"})]}),(0,a.jsx)("span",{className:"text-sm text-text-muted",children:"Loading..."})]})}):x||h?!x&&h?(0,a.jsx)("div",{className:"min-h-screen flex items-center justify-center bg-bg p-6",children:(0,a.jsxs)("div",{className:`w-full max-w-md transition-all duration-700 ease-out ${b?"opacity-100 translate-y-0":"opacity-0 translate-y-4"}`,children:[(0,a.jsxs)("div",{className:"text-center mb-10",children:[(0,a.jsx)("div",{className:"inline-flex items-center justify-center w-20 h-20 rounded-3xl bg-gradient-to-br from-amber-500/10 to-amber-500/5 border border-amber-500/10 mb-6",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-amber-500 text-[40px]",children:"shield_person"})}),(0,a.jsx)("h1",{className:"text-3xl font-bold text-text-main tracking-tight",children:"Secure Your Instance"}),(0,a.jsx)("p",{className:"text-text-muted mt-2",children:e("passwordNotEnabled")})]}),(0,a.jsx)("div",{className:"bg-surface border border-border rounded-2xl p-8 shadow-soft",children:(0,a.jsxs)("div",{className:"text-center",children:[(0,a.jsx)("p",{className:"text-text-muted leading-relaxed mb-6",children:"Set a password to protect your dashboard and secure your API endpoints from unauthorized access."}),(0,a.jsx)(n.$n,{variant:"primary",className:"w-full h-11 text-sm font-medium",onClick:()=>y.push("/dashboard/settings?tab=security"),children:"Configure Password"})]})}),(0,a.jsx)("p",{className:"text-center text-xs text-text-muted/60 mt-8",children:"OmniRoute — Unified AI API Proxy"})]})}):(0,a.jsxs)("div",{className:"min-h-screen flex bg-bg",children:[(0,a.jsx)("div",{className:"flex-1 flex items-center justify-center p-6",children:(0,a.jsxs)("div",{className:`w-full max-w-sm transition-all duration-700 ease-out ${b?"opacity-100 translate-y-0":"opacity-0 translate-y-4"}`,children:[(0,a.jsxs)("div",{className:"mb-10",children:[(0,a.jsxs)("div",{className:"flex items-center gap-3 mb-8",children:[(0,a.jsx)("div",{className:"w-10 h-10 rounded-xl bg-gradient-to-br from-primary to-primary-hover flex items-center justify-center",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-white text-[20px]",children:"hub"})}),(0,a.jsx)("span",{className:"text-xl font-semibold text-text-main tracking-tight",children:"OmniRoute"})]}),(0,a.jsx)("h1",{className:"text-2xl font-bold text-text-main tracking-tight",children:e("signIn")}),(0,a.jsx)("p",{className:"text-text-muted mt-1.5",children:e("enterPassword")})]}),(0,a.jsxs)("form",{onSubmit:j,className:"space-y-5",children:[(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsx)("label",{className:"text-sm font-medium text-text-main",children:e("password")}),(0,a.jsx)(n.pd,{type:"password",placeholder:"Enter your password",value:t,onChange:e=>s(e.target.value),required:!0,autoFocus:!0,className:"h-11"}),d&&(0,a.jsxs)("p",{className:"text-sm text-red-500 flex items-center gap-1.5 pt-1",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-base",children:"error"}),d]})]}),(0,a.jsx)(n.$n,{type:"submit",variant:"primary",className:"w-full h-11 text-sm font-medium",loading:o,children:"Continue"})]}),(0,a.jsx)("div",{className:"mt-6 pt-6 border-t border-border",children:(0,a.jsx)("a",{href:"/forgot-password",className:"text-sm text-text-muted hover:text-primary transition-colors",children:"Forgot your password?"})})]})}),(0,a.jsx)("div",{className:"hidden lg:flex lg:w-1/2 bg-gradient-to-br from-primary/5 via-primary/3 to-transparent items-center justify-center p-12",children:(0,a.jsx)("div",{className:`max-w-md transition-all duration-700 delay-200 ease-out ${b?"opacity-100 translate-y-0":"opacity-0 translate-y-4"}`,children:(0,a.jsxs)("div",{className:"space-y-8",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("h2",{className:"text-2xl font-bold text-text-main mb-3",children:"Unified AI API Proxy"}),(0,a.jsx)("p",{className:"text-text-muted leading-relaxed",children:"Route requests to multiple AI providers through a single endpoint. Load balancing, failover, and usage tracking built in."})]}),(0,a.jsx)("div",{className:"space-y-4",children:[{icon:"swap_horiz",title:"Multi-Provider",desc:"OpenAI, Anthropic, Google, and more"},{icon:"speed",title:"Load Balancing",desc:"Distribute requests intelligently"},{icon:"analytics",title:"Usage Tracking",desc:"Monitor costs and tokens"}].map(e=>(0,a.jsxs)("div",{className:"flex items-start gap-4 p-4 rounded-xl bg-surface/50 border border-border",children:[(0,a.jsx)("div",{className:"w-10 h-10 rounded-lg bg-primary/10 flex items-center justify-center flex-shrink-0",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-primary text-[20px]",children:e.icon})}),(0,a.jsxs)("div",{children:[(0,a.jsx)("h3",{className:"font-medium text-text-main",children:e.title}),(0,a.jsx)("p",{className:"text-sm text-text-muted",children:e.desc})]})]},e.icon))})]})})})]}):(0,a.jsx)("div",{className:"min-h-screen flex items-center justify-center bg-bg p-6",children:(0,a.jsxs)("div",{className:`w-full max-w-md transition-all duration-700 ease-out ${b?"opacity-100 translate-y-0":"opacity-0 translate-y-4"}`,children:[(0,a.jsxs)("div",{className:"text-center mb-10",children:[(0,a.jsx)("div",{className:"inline-flex items-center justify-center w-20 h-20 rounded-3xl bg-gradient-to-br from-primary/10 to-primary/5 border border-primary/10 mb-6",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-primary text-[40px]",children:"rocket_launch"})}),(0,a.jsx)("h1",{className:"text-3xl font-bold text-text-main tracking-tight",children:e("welcome")}),(0,a.jsx)("p",{className:"text-text-muted mt-2",children:"Let's get your OmniRoute instance configured"})]}),(0,a.jsx)("div",{className:"bg-surface border border-border rounded-2xl p-8 shadow-soft",children:(0,a.jsxs)("div",{className:"text-center",children:[(0,a.jsx)("p",{className:"text-text-muted leading-relaxed mb-6",children:"Run the onboarding wizard to set up your password and connect your first AI provider."}),(0,a.jsx)(n.$n,{variant:"primary",className:"w-full h-11 text-sm font-medium",onClick:()=>y.push("/dashboard/onboarding"),children:"Start Onboarding"})]})}),(0,a.jsxs)("p",{className:"text-center text-xs text-text-muted/60 mt-8",children:["OmniRoute — ",e("unifiedProxy")]})]})})}},90723:(e,t,s)=>{Promise.resolve().then(s.bind(s,13504))}},e=>{e.O(0,[3418,8500,9751,782,6458,5846,993,8441,3794,7358],()=>e(e.s=90723)),_N_E=e.O()}]);