omniroute 3.0.6 → 3.0.8

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 (251) hide show
  1. package/app/.next/BUILD_ID +1 -1
  2. package/app/.next/build-manifest.json +2 -2
  3. package/app/.next/prerender-manifest.json +3 -3
  4. package/app/.next/server/app/(dashboard)/dashboard/a2a/page.js +2 -2
  5. package/app/.next/server/app/(dashboard)/dashboard/a2a/page.js.nft.json +1 -1
  6. package/app/.next/server/app/(dashboard)/dashboard/a2a/page_client-reference-manifest.js +1 -1
  7. package/app/.next/server/app/(dashboard)/dashboard/agents/page.js +2 -2
  8. package/app/.next/server/app/(dashboard)/dashboard/agents/page.js.nft.json +1 -1
  9. package/app/.next/server/app/(dashboard)/dashboard/agents/page_client-reference-manifest.js +1 -1
  10. package/app/.next/server/app/(dashboard)/dashboard/analytics/page.js +2 -2
  11. package/app/.next/server/app/(dashboard)/dashboard/analytics/page.js.nft.json +1 -1
  12. package/app/.next/server/app/(dashboard)/dashboard/analytics/page_client-reference-manifest.js +1 -1
  13. package/app/.next/server/app/(dashboard)/dashboard/api-manager/page.js +2 -2
  14. package/app/.next/server/app/(dashboard)/dashboard/api-manager/page.js.nft.json +1 -1
  15. package/app/.next/server/app/(dashboard)/dashboard/api-manager/page_client-reference-manifest.js +1 -1
  16. package/app/.next/server/app/(dashboard)/dashboard/audit-log/page.js +2 -2
  17. package/app/.next/server/app/(dashboard)/dashboard/audit-log/page.js.nft.json +1 -1
  18. package/app/.next/server/app/(dashboard)/dashboard/audit-log/page_client-reference-manifest.js +1 -1
  19. package/app/.next/server/app/(dashboard)/dashboard/auto-combo/page.js +2 -2
  20. package/app/.next/server/app/(dashboard)/dashboard/auto-combo/page.js.nft.json +1 -1
  21. package/app/.next/server/app/(dashboard)/dashboard/auto-combo/page_client-reference-manifest.js +1 -1
  22. package/app/.next/server/app/(dashboard)/dashboard/cli-tools/page.js +2 -2
  23. package/app/.next/server/app/(dashboard)/dashboard/cli-tools/page.js.nft.json +1 -1
  24. package/app/.next/server/app/(dashboard)/dashboard/cli-tools/page_client-reference-manifest.js +1 -1
  25. package/app/.next/server/app/(dashboard)/dashboard/combos/page.js +2 -2
  26. package/app/.next/server/app/(dashboard)/dashboard/combos/page.js.nft.json +1 -1
  27. package/app/.next/server/app/(dashboard)/dashboard/combos/page_client-reference-manifest.js +1 -1
  28. package/app/.next/server/app/(dashboard)/dashboard/costs/page.js +2 -2
  29. package/app/.next/server/app/(dashboard)/dashboard/costs/page.js.nft.json +1 -1
  30. package/app/.next/server/app/(dashboard)/dashboard/costs/page_client-reference-manifest.js +1 -1
  31. package/app/.next/server/app/(dashboard)/dashboard/endpoint/page.js +2 -2
  32. package/app/.next/server/app/(dashboard)/dashboard/endpoint/page.js.nft.json +1 -1
  33. package/app/.next/server/app/(dashboard)/dashboard/endpoint/page_client-reference-manifest.js +1 -1
  34. package/app/.next/server/app/(dashboard)/dashboard/health/page.js +2 -2
  35. package/app/.next/server/app/(dashboard)/dashboard/health/page.js.nft.json +1 -1
  36. package/app/.next/server/app/(dashboard)/dashboard/health/page_client-reference-manifest.js +1 -1
  37. package/app/.next/server/app/(dashboard)/dashboard/limits/page.js +2 -2
  38. package/app/.next/server/app/(dashboard)/dashboard/limits/page.js.nft.json +1 -1
  39. package/app/.next/server/app/(dashboard)/dashboard/limits/page_client-reference-manifest.js +1 -1
  40. package/app/.next/server/app/(dashboard)/dashboard/logs/page.js +2 -2
  41. package/app/.next/server/app/(dashboard)/dashboard/logs/page.js.nft.json +1 -1
  42. package/app/.next/server/app/(dashboard)/dashboard/logs/page_client-reference-manifest.js +1 -1
  43. package/app/.next/server/app/(dashboard)/dashboard/mcp/page.js +2 -2
  44. package/app/.next/server/app/(dashboard)/dashboard/mcp/page.js.nft.json +1 -1
  45. package/app/.next/server/app/(dashboard)/dashboard/mcp/page_client-reference-manifest.js +1 -1
  46. package/app/.next/server/app/(dashboard)/dashboard/media/page.js +2 -2
  47. package/app/.next/server/app/(dashboard)/dashboard/media/page.js.nft.json +1 -1
  48. package/app/.next/server/app/(dashboard)/dashboard/media/page_client-reference-manifest.js +1 -1
  49. package/app/.next/server/app/(dashboard)/dashboard/onboarding/page.js +2 -2
  50. package/app/.next/server/app/(dashboard)/dashboard/onboarding/page.js.nft.json +1 -1
  51. package/app/.next/server/app/(dashboard)/dashboard/onboarding/page_client-reference-manifest.js +1 -1
  52. package/app/.next/server/app/(dashboard)/dashboard/page.js +2 -2
  53. package/app/.next/server/app/(dashboard)/dashboard/page.js.nft.json +1 -1
  54. package/app/.next/server/app/(dashboard)/dashboard/page_client-reference-manifest.js +1 -1
  55. package/app/.next/server/app/(dashboard)/dashboard/playground/page.js +2 -2
  56. package/app/.next/server/app/(dashboard)/dashboard/playground/page.js.nft.json +1 -1
  57. package/app/.next/server/app/(dashboard)/dashboard/playground/page_client-reference-manifest.js +1 -1
  58. package/app/.next/server/app/(dashboard)/dashboard/profile/page.js +2 -2
  59. package/app/.next/server/app/(dashboard)/dashboard/profile/page.js.nft.json +1 -1
  60. package/app/.next/server/app/(dashboard)/dashboard/profile/page_client-reference-manifest.js +1 -1
  61. package/app/.next/server/app/(dashboard)/dashboard/providers/[id]/page.js +2 -2
  62. package/app/.next/server/app/(dashboard)/dashboard/providers/[id]/page.js.nft.json +1 -1
  63. package/app/.next/server/app/(dashboard)/dashboard/providers/[id]/page_client-reference-manifest.js +1 -1
  64. package/app/.next/server/app/(dashboard)/dashboard/providers/new/page.js +2 -2
  65. package/app/.next/server/app/(dashboard)/dashboard/providers/new/page.js.nft.json +1 -1
  66. package/app/.next/server/app/(dashboard)/dashboard/providers/new/page_client-reference-manifest.js +1 -1
  67. package/app/.next/server/app/(dashboard)/dashboard/providers/page.js +2 -2
  68. package/app/.next/server/app/(dashboard)/dashboard/providers/page.js.nft.json +1 -1
  69. package/app/.next/server/app/(dashboard)/dashboard/providers/page_client-reference-manifest.js +1 -1
  70. package/app/.next/server/app/(dashboard)/dashboard/search-tools/page.js +2 -2
  71. package/app/.next/server/app/(dashboard)/dashboard/search-tools/page.js.nft.json +1 -1
  72. package/app/.next/server/app/(dashboard)/dashboard/search-tools/page_client-reference-manifest.js +1 -1
  73. package/app/.next/server/app/(dashboard)/dashboard/settings/page.js +2 -2
  74. package/app/.next/server/app/(dashboard)/dashboard/settings/page.js.nft.json +1 -1
  75. package/app/.next/server/app/(dashboard)/dashboard/settings/page_client-reference-manifest.js +1 -1
  76. package/app/.next/server/app/(dashboard)/dashboard/settings/pricing/page.js +2 -2
  77. package/app/.next/server/app/(dashboard)/dashboard/settings/pricing/page.js.nft.json +1 -1
  78. package/app/.next/server/app/(dashboard)/dashboard/settings/pricing/page_client-reference-manifest.js +1 -1
  79. package/app/.next/server/app/(dashboard)/dashboard/translator/page.js +2 -2
  80. package/app/.next/server/app/(dashboard)/dashboard/translator/page.js.nft.json +1 -1
  81. package/app/.next/server/app/(dashboard)/dashboard/translator/page_client-reference-manifest.js +1 -1
  82. package/app/.next/server/app/(dashboard)/dashboard/usage/page.js +2 -2
  83. package/app/.next/server/app/(dashboard)/dashboard/usage/page.js.nft.json +1 -1
  84. package/app/.next/server/app/(dashboard)/dashboard/usage/page_client-reference-manifest.js +1 -1
  85. package/app/.next/server/app/400/page.js +2 -2
  86. package/app/.next/server/app/400/page.js.nft.json +1 -1
  87. package/app/.next/server/app/400/page_client-reference-manifest.js +1 -1
  88. package/app/.next/server/app/401/page.js +2 -2
  89. package/app/.next/server/app/401/page.js.nft.json +1 -1
  90. package/app/.next/server/app/401/page_client-reference-manifest.js +1 -1
  91. package/app/.next/server/app/403/page.js +2 -2
  92. package/app/.next/server/app/403/page.js.nft.json +1 -1
  93. package/app/.next/server/app/403/page_client-reference-manifest.js +1 -1
  94. package/app/.next/server/app/408/page.js +2 -2
  95. package/app/.next/server/app/408/page.js.nft.json +1 -1
  96. package/app/.next/server/app/408/page_client-reference-manifest.js +1 -1
  97. package/app/.next/server/app/429/page.js +2 -2
  98. package/app/.next/server/app/429/page.js.nft.json +1 -1
  99. package/app/.next/server/app/429/page_client-reference-manifest.js +1 -1
  100. package/app/.next/server/app/500/page.js +2 -2
  101. package/app/.next/server/app/500/page.js.nft.json +1 -1
  102. package/app/.next/server/app/500/page_client-reference-manifest.js +1 -1
  103. package/app/.next/server/app/502/page.js +2 -2
  104. package/app/.next/server/app/502/page.js.nft.json +1 -1
  105. package/app/.next/server/app/502/page_client-reference-manifest.js +1 -1
  106. package/app/.next/server/app/503/page.js +2 -2
  107. package/app/.next/server/app/503/page.js.nft.json +1 -1
  108. package/app/.next/server/app/503/page_client-reference-manifest.js +1 -1
  109. package/app/.next/server/app/_global-error/page.js +1 -1
  110. package/app/.next/server/app/_global-error/page.js.nft.json +1 -1
  111. package/app/.next/server/app/_global-error.html +2 -2
  112. package/app/.next/server/app/_global-error.rsc +1 -1
  113. package/app/.next/server/app/_global-error.segments/__PAGE__.segment.rsc +1 -1
  114. package/app/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
  115. package/app/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
  116. package/app/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
  117. package/app/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  118. package/app/.next/server/app/_not-found/page.js +2 -2
  119. package/app/.next/server/app/_not-found/page.js.nft.json +1 -1
  120. package/app/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
  121. package/app/.next/server/app/api/logs/console/route.js +1 -1
  122. package/app/.next/server/app/api/logs/console/route.js.nft.json +1 -1
  123. package/app/.next/server/app/api/openapi/spec/route.js +1 -1
  124. package/app/.next/server/app/api/openapi/spec/route.js.nft.json +1 -1
  125. package/app/.next/server/app/api/settings/proxy/test/route.js +7 -2
  126. package/app/.next/server/app/api/settings/proxy/test/route.js.nft.json +1 -1
  127. package/app/.next/server/app/api/translator/load/route.js +1 -1
  128. package/app/.next/server/app/api/translator/load/route.js.nft.json +1 -1
  129. package/app/.next/server/app/api/translator/save/route.js +1 -1
  130. package/app/.next/server/app/api/translator/save/route.js.nft.json +1 -1
  131. package/app/.next/server/app/api/usage/[connectionId]/route.js +6 -5
  132. package/app/.next/server/app/api/usage/[connectionId]/route.js.nft.json +1 -1
  133. package/app/.next/server/app/callback/page.js +2 -2
  134. package/app/.next/server/app/callback/page.js.nft.json +1 -1
  135. package/app/.next/server/app/callback/page_client-reference-manifest.js +1 -1
  136. package/app/.next/server/app/docs/page.js +2 -2
  137. package/app/.next/server/app/docs/page.js.nft.json +1 -1
  138. package/app/.next/server/app/docs/page_client-reference-manifest.js +1 -1
  139. package/app/.next/server/app/forbidden/page.js +2 -2
  140. package/app/.next/server/app/forbidden/page.js.nft.json +1 -1
  141. package/app/.next/server/app/forbidden/page_client-reference-manifest.js +1 -1
  142. package/app/.next/server/app/forgot-password/page.js +2 -2
  143. package/app/.next/server/app/forgot-password/page.js.nft.json +1 -1
  144. package/app/.next/server/app/forgot-password/page_client-reference-manifest.js +1 -1
  145. package/app/.next/server/app/landing/page.js +2 -2
  146. package/app/.next/server/app/landing/page.js.nft.json +1 -1
  147. package/app/.next/server/app/landing/page_client-reference-manifest.js +1 -1
  148. package/app/.next/server/app/login/page.js +2 -2
  149. package/app/.next/server/app/login/page.js.nft.json +1 -1
  150. package/app/.next/server/app/login/page_client-reference-manifest.js +1 -1
  151. package/app/.next/server/app/maintenance/page.js +2 -2
  152. package/app/.next/server/app/maintenance/page.js.nft.json +1 -1
  153. package/app/.next/server/app/maintenance/page_client-reference-manifest.js +1 -1
  154. package/app/.next/server/app/offline/page.js +2 -2
  155. package/app/.next/server/app/offline/page.js.nft.json +1 -1
  156. package/app/.next/server/app/offline/page_client-reference-manifest.js +1 -1
  157. package/app/.next/server/app/page.js +2 -2
  158. package/app/.next/server/app/page.js.nft.json +1 -1
  159. package/app/.next/server/app/page_client-reference-manifest.js +1 -1
  160. package/app/.next/server/app/privacy/page.js +2 -2
  161. package/app/.next/server/app/privacy/page.js.nft.json +1 -1
  162. package/app/.next/server/app/privacy/page_client-reference-manifest.js +1 -1
  163. package/app/.next/server/app/status/page.js +2 -2
  164. package/app/.next/server/app/status/page.js.nft.json +1 -1
  165. package/app/.next/server/app/status/page_client-reference-manifest.js +1 -1
  166. package/app/.next/server/app/terms/page.js +2 -2
  167. package/app/.next/server/app/terms/page.js.nft.json +1 -1
  168. package/app/.next/server/app/terms/page_client-reference-manifest.js +1 -1
  169. package/app/.next/server/chunks/[root-of-the-server]__051203a6._.js +1 -1
  170. package/app/.next/server/chunks/[root-of-the-server]__0891af92._.js +1 -1
  171. package/app/.next/server/chunks/{[root-of-the-server]__fea5312b._.js → [root-of-the-server]__1a67cabb._.js} +2 -2
  172. package/app/.next/server/chunks/[root-of-the-server]__1f2b0d89._.js +1 -1
  173. package/app/.next/server/chunks/[root-of-the-server]__228deb98._.js +6 -0
  174. package/app/.next/server/chunks/[root-of-the-server]__3aa1672b._.js +3 -0
  175. package/app/.next/server/chunks/{[root-of-the-server]__9d50d114._.js → [root-of-the-server]__3e31c0c5._.js} +2 -2
  176. package/app/.next/server/chunks/[root-of-the-server]__46e00e59._.js +1 -1
  177. package/app/.next/server/chunks/[root-of-the-server]__4e5a04c2._.js +1 -1
  178. package/app/.next/server/chunks/[root-of-the-server]__6e52619e._.js +1 -1
  179. package/app/.next/server/chunks/[root-of-the-server]__70a3877b._.js +5 -5
  180. package/app/.next/server/chunks/[root-of-the-server]__7ace0fcd._.js +1 -1
  181. package/app/.next/server/chunks/[root-of-the-server]__7d0781e8._.js +6 -0
  182. package/app/.next/server/chunks/[root-of-the-server]__7fa4d14e._.js +1 -1
  183. package/app/.next/server/chunks/{[root-of-the-server]__6ff1ab32._.js → [root-of-the-server]__ab1817d2._.js} +2 -2
  184. package/app/.next/server/chunks/[root-of-the-server]__b013abab._.js +6 -6
  185. package/app/.next/server/chunks/{[root-of-the-server]__e376e668._.js → [root-of-the-server]__b2d1faff._.js} +2 -2
  186. package/app/.next/server/chunks/{[root-of-the-server]__192ce3e4._.js → [root-of-the-server]__b974107a._.js} +2 -2
  187. package/app/.next/server/chunks/[root-of-the-server]__d49fae76._.js +3 -0
  188. package/app/.next/server/chunks/{[root-of-the-server]__1a89bfa5._.js → [root-of-the-server]__d6de923d._.js} +3 -3
  189. package/app/.next/server/chunks/_05c48915._.js +1 -1
  190. package/app/.next/server/chunks/_06515a8a._.js +1 -1
  191. package/app/.next/server/chunks/_2115d8de._.js +1 -1
  192. package/app/.next/server/chunks/_3ac953eb._.js +1 -1
  193. package/app/.next/server/chunks/_4b8fd853._.js +1 -1
  194. package/app/.next/server/chunks/_68683848._.js +1 -1
  195. package/app/.next/server/chunks/_85c0d9b3._.js +1 -1
  196. package/app/.next/server/chunks/_d13cbb6d._.js +3 -0
  197. package/app/.next/server/chunks/_ee9b677b._.js +1 -1
  198. package/app/.next/server/chunks/_efd5ede2._.js +1 -1
  199. package/app/.next/server/chunks/open-sse_config_providerModels_ts_04541468._.js +1 -1
  200. package/app/.next/server/chunks/open-sse_config_providerRegistry_ts_2f74ec2a._.js +1 -1
  201. package/app/.next/server/chunks/open-sse_config_providerRegistry_ts_dec0f840._.js +1 -1
  202. package/app/.next/server/chunks/open-sse_translator_index_ts_f5fd0821._.js +1 -1
  203. package/app/.next/server/chunks/ssr/{[root-of-the-server]__d5a9e5ee._.js → [root-of-the-server]__62183d3b._.js} +2 -2
  204. package/app/.next/server/chunks/ssr/{[root-of-the-server]__e4499d60._.js → [root-of-the-server]__7a1929fd._.js} +2 -2
  205. package/app/.next/server/chunks/ssr/{[root-of-the-server]__18da985c._.js → [root-of-the-server]__9c6249ab._.js} +2 -2
  206. package/app/.next/server/chunks/ssr/[root-of-the-server]__9ef96d20._.js +1 -1
  207. package/app/.next/server/chunks/ssr/[root-of-the-server]__a6942102._.js +1 -1
  208. package/app/.next/server/chunks/ssr/_19b3d5b1._.js +1 -1
  209. package/app/.next/server/chunks/ssr/open-sse_config_providerModels_ts_4cac55e2._.js +1 -1
  210. package/app/.next/server/chunks/ssr/src_608e5edc._.js +1 -1
  211. package/app/.next/server/chunks/ssr/src_app_(dashboard)_dashboard_936a9ee0._.js +1 -1
  212. package/app/.next/server/chunks/ssr/src_app_(dashboard)_dashboard_playground_page_tsx_06c08266._.js +2 -2
  213. package/app/.next/server/chunks/ssr/src_app_(dashboard)_dashboard_settings_9e20fb8d._.js +1 -1
  214. package/app/.next/server/middleware.js +1 -1
  215. package/app/.next/server/pages/500.html +2 -2
  216. package/app/.next/server/server-reference-manifest.js +1 -1
  217. package/app/.next/server/server-reference-manifest.json +1 -1
  218. package/app/.next/static/chunks/{c4538578367f8d6e.js → 29003ec8ef226c62.js} +2 -2
  219. package/app/.next/static/chunks/{98a065e472ead1c5.js → 58d319dd9faa8901.js} +1 -1
  220. package/app/.next/static/chunks/6350bc1d56a7114c.js +2 -0
  221. package/app/.next/static/chunks/{339b27cecfee41d1.js → 6d9bfb06374cbab3.js} +1 -1
  222. package/app/.next/static/chunks/9330486b16098458.js +1 -0
  223. package/app/.next/static/chunks/a622fa7a630e2dc2.js +1 -0
  224. package/app/CHANGELOG.md +35 -0
  225. package/app/docs/openapi.yaml +1 -1
  226. package/app/open-sse/config/providerRegistry.ts +7 -1
  227. package/app/open-sse/handlers/responseSanitizer.ts +58 -0
  228. package/app/open-sse/services/signatureCache.ts +5 -0
  229. package/app/open-sse/translator/response/openai-to-claude.ts +12 -1
  230. package/app/open-sse/utils/usageTracking.ts +44 -5
  231. package/app/package-lock.json +20 -20
  232. package/app/package.json +1 -1
  233. package/app/src/app/(dashboard)/dashboard/cli-tools/CLIToolsPageClient.tsx +40 -0
  234. package/app/src/app/(dashboard)/dashboard/playground/page.tsx +39 -40
  235. package/app/src/app/(dashboard)/dashboard/settings/components/ProxyRegistryManager.tsx +1 -2
  236. package/app/src/app/(dashboard)/dashboard/usage/components/ProviderLimits/index.tsx +1 -1
  237. package/app/src/app/api/settings/proxy/test/route.ts +21 -1
  238. package/app/src/app/api/usage/[connectionId]/route.ts +83 -35
  239. package/app/src/lib/db/combos.ts +5 -5
  240. package/app/src/lib/db/models.ts +9 -9
  241. package/package.json +1 -1
  242. package/app/.next/server/chunks/[root-of-the-server]__5dcab57b._.js +0 -6
  243. package/app/.next/server/chunks/[root-of-the-server]__643f87ad._.js +0 -3
  244. package/app/.next/server/chunks/[root-of-the-server]__765c4417._.js +0 -3
  245. package/app/.next/server/chunks/[root-of-the-server]__7afe1e49._.js +0 -3
  246. package/app/.next/static/chunks/0e39e279bf7e4cd9.js +0 -2
  247. package/app/.next/static/chunks/3f18998354dd49b9.js +0 -1
  248. package/app/.next/static/chunks/f62c550263d8bca8.js +0 -1
  249. /package/app/.next/static/{4vzx2qUM_tiJPdpx_Hiqj → VtLeHcThjUtEgx1Z2skPg}/_buildManifest.js +0 -0
  250. /package/app/.next/static/{4vzx2qUM_tiJPdpx_Hiqj → VtLeHcThjUtEgx1Z2skPg}/_clientMiddlewareManifest.json +0 -0
  251. /package/app/.next/static/{4vzx2qUM_tiJPdpx_Hiqj → VtLeHcThjUtEgx1Z2skPg}/_ssgManifest.js +0 -0
@@ -0,0 +1,2 @@
1
+ (globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,11477,e=>{"use strict";var t=e.i(393718);e.s(["Card",()=>t.default])},565650,e=>{"use strict";e.i(342923),e.i(80173),e.i(907714),e.i(393718),e.i(703166),e.i(454149),e.i(822124),e.i(969353),e.i(635055),e.i(897844),e.i(450222),e.i(647829),e.i(6998),e.i(982131),e.i(116016),e.i(279743),e.i(193464),e.i(548036),e.i(566770),e.i(953789),e.i(8839),e.i(227404),e.i(621745),e.i(567955),e.i(17517),e.i(419947),e.i(323060),e.i(642440),e.i(629342),e.i(816062),e.i(690777),e.i(563201),e.i(115243),e.i(165149),e.i(359505),e.s([],565650)},474078,e=>{"use strict";var t=e.i(342923);e.s(["Button",()=>t.default])},961430,e=>{"use strict";var t=e.i(907714);e.s(["Select",()=>t.default])},628029,e=>{"use strict";var t=e.i(969353);e.s(["Badge",()=>t.default])},667585,(e,t,a)=>{"use strict";Object.defineProperty(a,"__esModule",{value:!0}),Object.defineProperty(a,"BailoutToCSR",{enumerable:!0,get:function(){return s}});let l=e.r(132061);function s({reason:e,children:t}){if("u"<typeof window)throw Object.defineProperty(new l.BailoutToCSRError(e),"__NEXT_ERROR_CODE",{value:"E394",enumerable:!1,configurable:!0});return t}},309885,(e,t,a)=>{"use strict";function l(e){return e.split("/").map(e=>encodeURIComponent(e)).join("/")}Object.defineProperty(a,"__esModule",{value:!0}),Object.defineProperty(a,"encodeURIPath",{enumerable:!0,get:function(){return l}})},652157,(e,t,a)=>{"use strict";Object.defineProperty(a,"__esModule",{value:!0}),Object.defineProperty(a,"PreloadChunks",{enumerable:!0,get:function(){return o}});let l=e.r(843476),s=e.r(174080),r=e.r(563599),i=e.r(309885),n=e.r(543369);function o({moduleIds:e}){if("u">typeof window)return null;let t=r.workAsyncStorage.getStore();if(void 0===t)return null;let a=[];if(t.reactLoadableManifest&&e){let l=t.reactLoadableManifest;for(let t of e){if(!l[t])continue;let e=l[t].files;a.push(...e)}}if(0===a.length)return null;let o=(0,n.getDeploymentIdQueryOrEmptyString)();return(0,l.jsx)(l.Fragment,{children:a.map(e=>{let a=`${t.assetPrefix}/_next/${(0,i.encodeURIPath)(e)}${o}`;return e.endsWith(".css")?(0,l.jsx)("link",{precedence:"dynamic",href:a,rel:"stylesheet",as:"style",nonce:t.nonce},e):((0,s.preload)(a,{as:"script",fetchPriority:"low",nonce:t.nonce}),null)})})}},869093,(e,t,a)=>{"use strict";Object.defineProperty(a,"__esModule",{value:!0}),Object.defineProperty(a,"default",{enumerable:!0,get:function(){return d}});let l=e.r(843476),s=e.r(271645),r=e.r(667585),i=e.r(652157);function n(e){return{default:e&&"default"in e?e.default:e}}let o={loader:()=>Promise.resolve(n(()=>null)),loading:null,ssr:!0},d=function(e){let t={...o,...e},a=(0,s.lazy)(()=>t.loader().then(n)),d=t.loading;function c(e){let n=d?(0,l.jsx)(d,{isLoading:!0,pastDelay:!0,error:null}):null,o=!t.ssr||!!t.loading,c=o?s.Suspense:s.Fragment,u=t.ssr?(0,l.jsxs)(l.Fragment,{children:["u"<typeof window?(0,l.jsx)(i.PreloadChunks,{moduleIds:t.modules}):null,(0,l.jsx)(a,{...e})]}):(0,l.jsx)(r.BailoutToCSR,{reason:"next/dynamic",children:(0,l.jsx)(a,{...e})});return(0,l.jsx)(c,{...o?{fallback:n}:{},children:u})}return c.displayName="LoadableComponent",c}},770703,(e,t,a)=>{"use strict";Object.defineProperty(a,"__esModule",{value:!0}),Object.defineProperty(a,"default",{enumerable:!0,get:function(){return s}});let l=e.r(563141)._(e.r(869093));function s(e,t){let a={};"function"==typeof e&&(a.loader=e);let s={...a,...t};return(0,l.default)({...s,modules:s.loadableGenerated?.modules})}("function"==typeof a.default||"object"==typeof a.default&&null!==a.default)&&void 0===a.default.__esModule&&(Object.defineProperty(a.default,"__esModule",{value:!0}),Object.assign(a.default,a),t.exports=a.default)},988689,e=>{"use strict";var t=e.i(843476),a=e.i(271645);e.i(565650);var l=e.i(11477),s=e.i(474078),r=e.i(961430),i=e.i(628029),n=e.i(623249),o=e.i(770703);let d=(0,o.default)(()=>e.A(653096),{loadableGenerated:{modules:[467211]},ssr:!1}),c=(0,o.default)(()=>e.A(724595),{loadableGenerated:{modules:[896009]},ssr:!1}),u=[{value:"chat",label:"Chat Completions"},{value:"responses",label:"Responses"},{value:"images",label:"Image Generation"},{value:"embeddings",label:"Embeddings"},{value:"speech",label:"Text to Speech"},{value:"transcription",label:"Audio Transcription"},{value:"video",label:"Video Generation"},{value:"music",label:"Music Generation"},{value:"rerank",label:"Rerank"},{value:"search",label:"Web Search"}],m={chat:{model:"",messages:[{role:"user",content:"Hello! Say hi in one sentence."}],max_tokens:100,stream:!1},responses:{model:"",input:"Hello! Say hi in one sentence.",stream:!1},images:{model:"",prompt:"A beautiful sunset over mountains",n:1,size:"1024x1024"},embeddings:{model:"",input:"Hello world",encoding_format:"float"},speech:{model:"openai/tts-1",input:"Hello, this is a test of the text-to-speech endpoint.",voice:"alloy",response_format:"mp3"},transcription:{model:"deepgram/nova-3",language:"en"},video:{model:"comfyui/animatediff",prompt:"A timelapse of a sunset over the ocean",n:1},music:{model:"comfyui/stable-audio",prompt:"Calm ambient piano music with soft reverb",duration:10},rerank:{model:"cohere/rerank-english-v3.0",query:"What is the capital of France?",documents:["Paris is the capital of France.","London is the capital of England.","Berlin is the capital of Germany."],top_n:2},search:{query:"latest AI developments",max_results:5,search_type:"web"}},p={chat:"/v1/chat/completions",responses:"/v1/responses",images:"/v1/images/generations",embeddings:"/v1/embeddings",speech:"/v1/audio/speech",transcription:"/v1/audio/transcriptions",video:"/v1/videos/generations",music:"/v1/music/generations",rerank:"/v1/rerank",search:"/v1/search"},x=["gpt-4o","gpt-4o-mini","gpt-4-turbo","gpt-4-vision","claude-3","claude-sonnet","claude-opus","claude-haiku","gemini","llava","bakllava","pixtral","qwen-vl","qvq","mistral-pixtral"];async function h(e){return new Promise((t,a)=>{let l=new FileReader;l.onload=()=>t(l.result),l.onerror=a,l.readAsDataURL(e)})}function f({data:e}){let a=e?.data||[];return 0===a.length?null:(0,t.jsxs)("div",{className:"p-4 space-y-3",children:[(0,t.jsxs)("p",{className:"text-xs text-text-muted font-medium uppercase tracking-wider",children:[a.length," image",a.length>1?"s":""," generated"]}),(0,t.jsx)("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:a.map((e,a)=>{let l=e.url||(e.b64_json?`data:image/png;base64,${e.b64_json}`:null);return l?(0,t.jsxs)("div",{className:"relative group rounded-lg overflow-hidden border border-border",children:[(0,t.jsx)("img",{src:l,alt:e.revised_prompt||`Generated image ${a+1}`,className:"w-full"}),(0,t.jsxs)("a",{href:l,download:`image-${a+1}.png`,className:"absolute bottom-2 right-2 bg-black/60 text-white text-xs px-2 py-1 rounded opacity-0 group-hover:opacity-100 transition-opacity flex items-center gap-1",children:[(0,t.jsx)("span",{className:"material-symbols-outlined text-[13px]",children:"download"}),"Save"]})]},a):null})})]})}function g(){let e,[o,g]=(0,a.useState)([]),[b,v]=(0,a.useState)([]),[y,j]=(0,a.useState)([]),[N,w]=(0,a.useState)(""),[S,k]=(0,a.useState)(""),[C,_]=(0,a.useState)(""),[O,P]=(0,a.useState)("chat"),[A,R]=(0,a.useState)(""),[T,L]=(0,a.useState)(""),[B,E]=(0,a.useState)(null),[M,D]=(0,a.useState)(null),[$,z]=(0,a.useState)(null),[F,I]=(0,a.useState)(!1),[J,U]=(0,a.useState)(null),[G,W]=(0,a.useState)(null),q=(0,a.useRef)(null),[K,H]=(0,a.useState)(null),[X,V]=(0,a.useState)([]),Q="search"===O,Y="transcription"===O,Z="images"===O,ee="chat"===O&&(e=S.toLowerCase(),x.some(t=>e.includes(t))),et=y.filter(e=>{if(!N)return!1;let t=n.ALIAS_TO_ID[N]||N;return e.provider===t||e.provider===N});(0,a.useEffect)(()=>{fetch("/v1/models").then(e=>e.json()).then(e=>{let t=e?.data||[];g(t);let a=new Set;t.forEach(e=>{let t=e.id.split("/");t.length>=2&&a.add(t[0])});let l=Array.from(a).sort().map(e=>({value:e,label:e}));v(l),l.length>0&&w(l[0].value)}).catch(()=>{}),fetch("/api/providers/client").then(e=>e.json()).then(e=>{let t=[];for(let a of e?.connections||[])t.push({id:a.id,name:a.name||a.email||a.id,provider:a.provider,authType:a.authType||"apiKey"});j(t)}).catch(()=>{})},[]);let ea=o.filter(e=>!N||e.id.startsWith(N+"/")).map(e=>({value:e.id,label:e.id})),el=(e,t)=>{let a={...m[e]};return"model"in a&&(a.model=t),JSON.stringify(a,null,2)},es=()=>{L(""),U(null),W(null),E(null),D(null),z(null)},er=async e=>{let t=Array.from(e.target.files||[]),a=await Promise.all(t.map(h));V(e=>[...e,...a].slice(0,4))},ei=async()=>{if(!A.trim()&&!Y)return;I(!0),es();let e=new AbortController;q.current=e;let t=Date.now();try{let a,l=p[O];if(Y){let t=new FormData;K&&t.append("file",K);try{let e=JSON.parse(A||"{}");for(let[a,l]of Object.entries(e))"file"!==a&&t.append(a,String(l))}catch{}let s={};C&&(s["X-OmniRoute-Connection"]=C),a=await fetch(`/api${l}`,{method:"POST",headers:s,body:t,signal:e.signal})}else{let t=JSON.parse(A);ee&&X.length>0&&(t=((e,t)=>{if(!t.length)return e;let a=[...e.messages||[]];if(0===a.length)return e;let l=a[a.length-1],s="string"==typeof l.content?l.content:"";return a[a.length-1]={...l,content:[{type:"text",text:s},...t.map(e=>({type:"image_url",image_url:{url:e}}))]},{...e,messages:a}})(t,X));let s={"Content-Type":"application/json"};C&&(s["X-OmniRoute-Connection"]=C),a=await fetch(`/api${l}`,{method:"POST",headers:s,body:JSON.stringify(t),signal:e.signal})}U(a.status),W(Date.now()-t);let s=a.headers.get("content-type")||"";if(s.startsWith("audio/")){let e=await a.blob(),t=URL.createObjectURL(e);E(t),L(`// Audio response (${s})
2
+ // Click play below to listen.`)}else if(s.includes("text/event-stream")){let e=a.body?.getReader(),t=new TextDecoder,l="";if(e)for(;;){let{done:a,value:s}=await e.read();if(a)break;l+=t.decode(s,{stream:!0}),L(l)}}else{let e=await a.json();L(JSON.stringify(e,null,2)),Z&&e?.data&&Array.isArray(e.data)&&a.ok&&D(e),Y&&"string"==typeof e?.text&&z(e.text||"(empty result — check provider credentials)")}}catch(e){"AbortError"===e.name?L(JSON.stringify({cancelled:!0},null,2)):L(JSON.stringify({error:e.message},null,2)),W(Date.now()-t)}I(!1)},en=async e=>{try{await navigator.clipboard.writeText(e)}catch{}};return(0,t.jsxs)("div",{className:"space-y-5",children:[(0,t.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,t.jsx)("span",{className:"material-symbols-outlined text-primary text-[20px] mt-0.5 shrink-0",children:"science"}),(0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"font-medium text-text-main mb-0.5",children:"Model Playground"}),(0,t.jsx)("p",{children:"Test any model directly from the dashboard. Pick a provider, model, and endpoint type, then send a request to see the raw response."})]})]}),(0,t.jsx)(l.Card,{children:(0,t.jsxs)("div",{className:"p-4 flex flex-col sm:flex-row items-end gap-4",children:[(0,t.jsxs)("div",{className:"flex-1 w-full",children:[(0,t.jsx)("label",{className:"block text-xs font-medium text-text-muted mb-1.5 uppercase tracking-wider",children:"Endpoint"}),(0,t.jsx)(r.Select,{value:O,onChange:e=>{var t;P(t=e.target.value),R(el(t,S)),H(null),V([]),es()},options:u,className:"w-full"})]}),!Q&&(0,t.jsxs)("div",{className:"flex-1 w-full",children:[(0,t.jsx)("label",{className:"block text-xs font-medium text-text-muted mb-1.5 uppercase tracking-wider",children:"Provider"}),(0,t.jsx)(r.Select,{value:N,onChange:e=>{var t;let a;return w(t=e.target.value),_(""),void(k(a=o.filter(e=>!t||e.id.startsWith(t+"/")).map(e=>e.id)[0]||""),R(el(O,a)),es())},options:b,className:"w-full"})]}),!Q&&(0,t.jsxs)("div",{className:"flex-1 w-full",children:[(0,t.jsx)("label",{className:"block text-xs font-medium text-text-muted mb-1.5 uppercase tracking-wider",children:"Model"}),(0,t.jsx)(r.Select,{value:S,onChange:e=>{var t;k(t=e.target.value),R(el(O,t)),es()},options:ea,className:"w-full"})]}),!Q&&(0,t.jsxs)("div",{className:"flex-1 w-full",children:[(0,t.jsx)("label",{className:"block text-xs font-medium text-text-muted mb-1.5 uppercase tracking-wider",children:"Account / Key"}),(0,t.jsx)(r.Select,{value:C,onChange:e=>_(e.target.value),options:[{value:"",label:et.length>0?`Auto (${et.length} accounts)`:"No accounts"},...et.map(e=>({value:e.id,label:e.name}))],className:"w-full"})]}),!Q&&(0,t.jsx)("div",{className:"shrink-0",children:F?(0,t.jsx)(s.Button,{icon:"stop",variant:"secondary",onClick:()=>{q.current&&q.current.abort()},children:"Cancel"}):(0,t.jsx)(s.Button,{icon:"send",onClick:ei,disabled:!A.trim()&&!Y||!S&&!Y,children:"Send"})})]})}),Q?(0,t.jsx)(c,{}):(0,t.jsxs)(t.Fragment,{children:[(Y||ee)&&(0,t.jsx)(l.Card,{children:(0,t.jsxs)("div",{className:"p-4 space-y-3",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)("span",{className:"material-symbols-outlined text-[18px] text-text-muted",children:"attach_file"}),(0,t.jsx)("h3",{className:"text-sm font-semibold text-text-main",children:Y?"Audio File":"Attach Images (Vision)"}),Y&&(0,t.jsx)(i.Badge,{variant:"info",size:"sm",children:"multipart/form-data"}),ee&&(0,t.jsx)(i.Badge,{variant:"info",size:"sm",children:"up to 4 images"})]}),Y&&(0,t.jsxs)("div",{children:[(0,t.jsx)("input",{type:"file",accept:"audio/*,video/*",onChange:e=>{H(e.target.files?.[0]??null)},className:"w-full px-3 py-2 rounded-lg bg-surface border border-border text-text-main text-sm focus:outline-none focus:ring-2 focus:ring-primary/30 file:mr-3 file:py-1 file:px-3 file:rounded file:border-0 file:bg-primary/10 file:text-primary file:text-sm"}),K&&(0,t.jsxs)("p",{className:"text-xs text-text-muted mt-1 flex items-center gap-1",children:[(0,t.jsx)("span",{className:"material-symbols-outlined text-[12px] text-green-500",children:"check_circle"}),K.name," (",(K.size/1024).toFixed(0)," KB)"]}),!K&&(0,t.jsxs)("p",{className:"text-xs text-amber-500 mt-1 flex items-center gap-1",children:[(0,t.jsx)("span",{className:"material-symbols-outlined text-[12px]",children:"info"}),"Select an audio file to transcribe (mp3, wav, m4a, ogg, flac…)"]})]}),ee&&(0,t.jsxs)("div",{children:[(0,t.jsx)("input",{type:"file",accept:"image/*",multiple:!0,onChange:er,className:"w-full px-3 py-2 rounded-lg bg-surface border border-border text-text-main text-sm focus:outline-none focus:ring-2 focus:ring-primary/30 file:mr-3 file:py-1 file:px-3 file:rounded file:border-0 file:bg-primary/10 file:text-primary file:text-sm"}),X.length>0&&(0,t.jsxs)("div",{className:"flex gap-2 mt-2 flex-wrap",children:[X.map((e,a)=>(0,t.jsxs)("div",{className:"relative group size-16 rounded overflow-hidden border border-border",children:[(0,t.jsx)("img",{src:e,alt:`Attached ${a+1}`,className:"w-full h-full object-cover"}),(0,t.jsx)("button",{onClick:()=>V(e=>e.filter((e,t)=>t!==a)),className:"absolute inset-0 bg-black/50 text-white opacity-0 group-hover:opacity-100 transition-opacity flex items-center justify-center",children:(0,t.jsx)("span",{className:"material-symbols-outlined text-[16px]",children:"close"})})]},a)),(0,t.jsx)("button",{onClick:()=>V([]),className:"text-xs text-text-muted hover:text-red-500 self-center ml-1",children:"Clear all"})]})]})]})}),(0,t.jsxs)("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-4",children:[(0,t.jsx)(l.Card,{children:(0,t.jsxs)("div",{className:"p-4 space-y-3",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)("span",{className:"material-symbols-outlined text-[18px] text-text-muted",children:"upload"}),(0,t.jsx)("h3",{className:"text-sm font-semibold text-text-main",children:"Request"}),(0,t.jsxs)(i.Badge,{variant:"info",size:"sm",children:["POST ",p[O]]})]}),(0,t.jsxs)("div",{className:"flex items-center gap-1",children:[(0,t.jsx)("button",{onClick:()=>en(A),className:"p-1.5 rounded hover:bg-black/5 dark:hover:bg-white/5 text-text-muted hover:text-text-main transition-colors",title:"Copy",children:(0,t.jsx)("span",{className:"material-symbols-outlined text-[16px]",children:"content_copy"})}),(0,t.jsx)("button",{onClick:()=>{let e={...m[O]};"model"in e&&(e.model=S),R(JSON.stringify(e,null,2))},className:"p-1.5 rounded hover:bg-black/5 dark:hover:bg-white/5 text-text-muted hover:text-text-main transition-colors",title:"Reset to default",children:(0,t.jsx)("span",{className:"material-symbols-outlined text-[16px]",children:"restart_alt"})})]})]}),Y&&(0,t.jsxs)("p",{className:"text-xs text-text-muted bg-amber-500/10 border border-amber-500/20 rounded px-2 py-1.5 flex items-start gap-1",children:[(0,t.jsx)("span",{className:"material-symbols-outlined text-[12px] text-amber-500 mt-0.5",children:"info"}),"Transcription uses multipart/form-data. Upload the audio file above — JSON below controls extra params (model, language)."]}),(0,t.jsx)("div",{className:"border border-border rounded-lg overflow-hidden",children:(0,t.jsx)(d,{height:"400px",defaultLanguage:"json",value:A,onChange:e=>R(e||""),theme:"vs-dark",options:{minimap:{enabled:!1},fontSize:12,lineNumbers:"on",scrollBeyondLastLine:!1,wordWrap:"on",automaticLayout:!0,formatOnPaste:!0}})})]})}),(0,t.jsx)(l.Card,{children:(0,t.jsxs)("div",{className:"p-4 space-y-3",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)("span",{className:"material-symbols-outlined text-[18px] text-text-muted",children:"download"}),(0,t.jsx)("h3",{className:"text-sm font-semibold text-text-main",children:"Response"}),null!==J&&(0,t.jsx)(i.Badge,{variant:J>=200&&J<300?"success":"error",size:"sm",children:J}),null!==G&&(0,t.jsxs)("span",{className:"text-xs text-text-muted",children:[G,"ms"]}),F&&(0,t.jsx)("span",{className:"material-symbols-outlined text-[14px] text-primary animate-spin",children:"progress_activity"})]}),(0,t.jsx)("div",{className:"flex items-center gap-1",children:(0,t.jsx)("button",{onClick:()=>en(T),className:"p-1.5 rounded hover:bg-black/5 dark:hover:bg-white/5 text-text-muted hover:text-text-main transition-colors",title:"Copy",children:(0,t.jsx)("span",{className:"material-symbols-outlined text-[16px]",children:"content_copy"})})})]}),(0,t.jsx)("div",{className:"border border-border rounded-lg overflow-hidden",children:B?(0,t.jsxs)("div",{className:"p-4 space-y-3",children:[(0,t.jsx)("audio",{controls:!0,src:B,className:"w-full rounded-lg",autoPlay:!0}),(0,t.jsxs)("a",{href:B,download:"speech.mp3",className:"inline-flex items-center gap-2 text-sm text-primary hover:underline",children:[(0,t.jsx)("span",{className:"material-symbols-outlined text-[16px]",children:"download"}),"Download audio"]})]}):M?(0,t.jsx)(f,{data:M}):null!==$?(0,t.jsxs)("div",{className:"p-4 space-y-2",children:[(0,t.jsx)("p",{className:"text-xs text-text-muted font-medium uppercase tracking-wider",children:"Transcription"}),(0,t.jsx)("div",{className:"bg-surface/50 rounded p-3 text-sm text-text-main leading-relaxed whitespace-pre-wrap",children:$}),(0,t.jsxs)("button",{onClick:()=>en($),className:"text-xs text-primary hover:underline flex items-center gap-1",children:[(0,t.jsx)("span",{className:"material-symbols-outlined text-[12px]",children:"content_copy"}),"Copy text"]})]}):(0,t.jsx)(d,{height:"400px",defaultLanguage:"json",value:T,theme:"vs-dark",options:{minimap:{enabled:!1},fontSize:12,lineNumbers:"on",scrollBeyondLastLine:!1,wordWrap:"on",automaticLayout:!0,readOnly:!0}})})]})})]})]})]})}e.s(["default",()=>g])},653096,e=>{e.v(t=>Promise.all(["static/chunks/54afb78f5db263b9.js"].map(t=>e.l(t))).then(()=>t(467211)))},724595,e=>{e.v(t=>Promise.all(["static/chunks/56bb30976d06ea37.js"].map(t=>e.l(t))).then(()=>t(896009)))}]);
@@ -1 +1 @@
1
- (globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,804730,e=>{e.v({name:"omniroute",version:"3.0.6",description:"Smart AI Router with auto fallback — route to FREE & cheap models, zero downtime. Works with Cursor, Cline, Claude Desktop, Codex, and any OpenAI-compatible tool.",type:"module",bin:{omniroute:"bin/omniroute.mjs","omniroute-reset-password":"bin/reset-password.mjs"},files:["bin/","app/","open-sse/mcp-server/","src/shared/contracts/","scripts/postinstall.mjs","scripts/native-binary-compat.mjs","README.md","LICENSE"],workspaces:["open-sse"],engines:{node:">=18.0.0 <24.0.0"},keywords:["ai","router","proxy","openai","claude","anthropic","gemini","fallback","cursor","cline","codex","llm","auto-fallback"],license:"MIT",author:"diegosouzapw",repository:{type:"git",url:"https://github.com/diegosouzapw/OmniRoute"},homepage:"https://omniroute.online",scripts:{dev:"node scripts/run-next.mjs dev",build:"node scripts/build-next-isolated.mjs","build:cli":"node scripts/prepublish.mjs",start:"node scripts/run-next.mjs start",lint:"eslint .","electron:dev":'concurrently "npm run dev" "wait-on http://localhost:20128 && cd electron && npm run dev"',"electron:build":"npm run build && cd electron && npm run build","electron:build:win":"npm run build && cd electron && npm run build:win","electron:build:mac":"npm run build && cd electron && npm run build:mac","electron:build:linux":"npm run build && cd electron && npm run build:linux",test:"node --import tsx/esm --test tests/unit/*.test.mjs","test:unit":"node --import tsx/esm --test tests/unit/*.test.mjs","test:plan3":"node --import tsx/esm --test tests/unit/plan3-p0.test.mjs","test:fixes":"node --import tsx/esm --test tests/unit/fixes-p1.test.mjs","test:security":"node --import tsx/esm --test tests/unit/security-fase01.test.mjs","check:cycles":"node scripts/check-cycles.mjs","check:route-validation:t06":"node scripts/check-route-validation.mjs","check:any-budget:t11":"node scripts/check-t11-any-budget.mjs","check:docs-sync":"node scripts/check-docs-sync.mjs","typecheck:core":"tsc --pretty false -p tsconfig.typecheck-core.json","typecheck:noimplicit:core":"tsc --pretty false -p tsconfig.typecheck-noimplicit-core.json","test:integration":"node --import tsx/esm --test tests/integration/*.test.mjs","test:e2e":"node scripts/run-playwright-tests.mjs test tests/e2e/*.spec.ts","test:protocols:e2e":"node scripts/run-protocol-clients-tests.mjs","test:vitest":"vitest run open-sse/mcp-server/__tests__/*.test.ts open-sse/services/autoCombo/__tests__/*.test.ts","test:ecosystem":"node scripts/run-ecosystem-tests.mjs","test:coverage":"npx c8 --exclude=open-sse --check-coverage --lines 50 --functions 50 --branches 50 node --import tsx/esm --test tests/unit/*.test.mjs","test:all":"npm run test:unit && npm run test:vitest && npm run test:ecosystem && npm run test:e2e",check:"npm run lint && npm run test",prepublishOnly:"npm run build:cli",postinstall:"node scripts/postinstall.mjs",prepare:"husky","system-info":"node scripts/system-info.mjs"},dependencies:{"@lobehub/icons":"^5.0.1","@modelcontextprotocol/sdk":"^1.27.1","@monaco-editor/react":"^4.7.0","@swc/helpers":"0.5.19",bcryptjs:"^3.0.3","better-sqlite3":"^12.6.2",bottleneck:"^2.19.5",dompurify:"^3.3.2",express:"^5.2.1","fetch-socks":"^1.3.2","http-proxy-middleware":"^3.0.5","https-proxy-agent":"^8.0.0",jose:"^6.1.3",keytar:"^7.9.0",lowdb:"^7.0.1","monaco-editor":"^0.55.1",next:"^16.0.10","next-intl":"^4.8.3","node-machine-id":"^1.1.12",open:"^11.0.0",ora:"^9.1.0",pino:"^10.3.1","pino-pretty":"^13.1.3",react:"19.2.4","react-dom":"19.2.4",recharts:"^3.7.0",selfsigned:"^5.5.0",tsx:"^4.21.0",undici:"^7.19.2",uuid:"^13.0.0","wreq-js":"^2.0.1",zod:"^4.3.6",zustand:"^5.0.10"},devDependencies:{"@playwright/test":"^1.58.2","@tailwindcss/postcss":"^4.1.18","@types/bcryptjs":"^3.0.0","@types/better-sqlite3":"^7.6.13","@types/keytar":"^4.4.0","@types/node":"^25.2.3","@types/react":"^19.2.14","@types/react-dom":"^19.2.3",concurrently:"^9.2.1","cross-env":"^10.1.0",eslint:"^9.39.2","eslint-config-next":"^16.0.10",husky:"^9.1.7","lint-staged":"^16.2.7",prettier:"^3.8.1",tailwindcss:"^4",typescript:"^5.9.3","typescript-eslint":"^8.56.0",vitest:"^4.0.18","wait-on":"^9.0.4"},"lint-staged":{"*.{js,jsx,ts,tsx,mjs}":["prettier --write","eslint --fix --no-error-on-unmatched-pattern"],"*.{json,md,yml,yaml,css}":["prettier --write"]},pnpm:{onlyBuiltDependencies:["@parcel/watcher","@swc/core","better-sqlite3","esbuild","omniroute","sharp"]},overrides:{dompurify:"^3.3.2"}})},175696,e=>{"use strict";var t=e.i(861745),s=e.i(843476);function n({locale:e,...n}){if(!e)throw Error(void 0);return(0,s.jsx)(t.IntlProvider,{locale:e,...n})}e.s(["default",()=>n])}]);
1
+ (globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,804730,e=>{e.v({name:"omniroute",version:"3.0.8",description:"Smart AI Router with auto fallback — route to FREE & cheap models, zero downtime. Works with Cursor, Cline, Claude Desktop, Codex, and any OpenAI-compatible tool.",type:"module",bin:{omniroute:"bin/omniroute.mjs","omniroute-reset-password":"bin/reset-password.mjs"},files:["bin/","app/","open-sse/mcp-server/","src/shared/contracts/","scripts/postinstall.mjs","scripts/native-binary-compat.mjs","README.md","LICENSE"],workspaces:["open-sse"],engines:{node:">=18.0.0 <24.0.0"},keywords:["ai","router","proxy","openai","claude","anthropic","gemini","fallback","cursor","cline","codex","llm","auto-fallback"],license:"MIT",author:"diegosouzapw",repository:{type:"git",url:"https://github.com/diegosouzapw/OmniRoute"},homepage:"https://omniroute.online",scripts:{dev:"node scripts/run-next.mjs dev",build:"node scripts/build-next-isolated.mjs","build:cli":"node scripts/prepublish.mjs",start:"node scripts/run-next.mjs start",lint:"eslint .","electron:dev":'concurrently "npm run dev" "wait-on http://localhost:20128 && cd electron && npm run dev"',"electron:build":"npm run build && cd electron && npm run build","electron:build:win":"npm run build && cd electron && npm run build:win","electron:build:mac":"npm run build && cd electron && npm run build:mac","electron:build:linux":"npm run build && cd electron && npm run build:linux",test:"node --import tsx/esm --test tests/unit/*.test.mjs","test:unit":"node --import tsx/esm --test tests/unit/*.test.mjs","test:plan3":"node --import tsx/esm --test tests/unit/plan3-p0.test.mjs","test:fixes":"node --import tsx/esm --test tests/unit/fixes-p1.test.mjs","test:security":"node --import tsx/esm --test tests/unit/security-fase01.test.mjs","check:cycles":"node scripts/check-cycles.mjs","check:route-validation:t06":"node scripts/check-route-validation.mjs","check:any-budget:t11":"node scripts/check-t11-any-budget.mjs","check:docs-sync":"node scripts/check-docs-sync.mjs","typecheck:core":"tsc --pretty false -p tsconfig.typecheck-core.json","typecheck:noimplicit:core":"tsc --pretty false -p tsconfig.typecheck-noimplicit-core.json","test:integration":"node --import tsx/esm --test tests/integration/*.test.mjs","test:e2e":"node scripts/run-playwright-tests.mjs test tests/e2e/*.spec.ts","test:protocols:e2e":"node scripts/run-protocol-clients-tests.mjs","test:vitest":"vitest run open-sse/mcp-server/__tests__/*.test.ts open-sse/services/autoCombo/__tests__/*.test.ts","test:ecosystem":"node scripts/run-ecosystem-tests.mjs","test:coverage":"npx c8 --exclude=open-sse --check-coverage --lines 50 --functions 50 --branches 50 node --import tsx/esm --test tests/unit/*.test.mjs","test:all":"npm run test:unit && npm run test:vitest && npm run test:ecosystem && npm run test:e2e",check:"npm run lint && npm run test",prepublishOnly:"npm run build:cli",postinstall:"node scripts/postinstall.mjs",prepare:"husky","system-info":"node scripts/system-info.mjs"},dependencies:{"@lobehub/icons":"^5.0.1","@modelcontextprotocol/sdk":"^1.27.1","@monaco-editor/react":"^4.7.0","@swc/helpers":"0.5.19",bcryptjs:"^3.0.3","better-sqlite3":"^12.6.2",bottleneck:"^2.19.5",dompurify:"^3.3.2",express:"^5.2.1","fetch-socks":"^1.3.2","http-proxy-middleware":"^3.0.5","https-proxy-agent":"^8.0.0",jose:"^6.1.3",keytar:"^7.9.0",lowdb:"^7.0.1","monaco-editor":"^0.55.1",next:"^16.0.10","next-intl":"^4.8.3","node-machine-id":"^1.1.12",open:"^11.0.0",ora:"^9.1.0",pino:"^10.3.1","pino-pretty":"^13.1.3",react:"19.2.4","react-dom":"19.2.4",recharts:"^3.7.0",selfsigned:"^5.5.0",tsx:"^4.21.0",undici:"^7.19.2",uuid:"^13.0.0","wreq-js":"^2.0.1",zod:"^4.3.6",zustand:"^5.0.10"},devDependencies:{"@playwright/test":"^1.58.2","@tailwindcss/postcss":"^4.1.18","@types/bcryptjs":"^3.0.0","@types/better-sqlite3":"^7.6.13","@types/keytar":"^4.4.0","@types/node":"^25.2.3","@types/react":"^19.2.14","@types/react-dom":"^19.2.3",concurrently:"^9.2.1","cross-env":"^10.1.0",eslint:"^9.39.2","eslint-config-next":"^16.0.10",husky:"^9.1.7","lint-staged":"^16.2.7",prettier:"^3.8.1",tailwindcss:"^4",typescript:"^5.9.3","typescript-eslint":"^8.56.0",vitest:"^4.0.18","wait-on":"^9.0.4"},"lint-staged":{"*.{js,jsx,ts,tsx,mjs}":["prettier --write","eslint --fix --no-error-on-unmatched-pattern"],"*.{json,md,yml,yaml,css}":["prettier --write"]},pnpm:{onlyBuiltDependencies:["@parcel/watcher","@swc/core","better-sqlite3","esbuild","omniroute","sharp"]},overrides:{dompurify:"^3.3.2"}})},175696,e=>{"use strict";var t=e.i(861745),s=e.i(843476);function n({locale:e,...n}){if(!e)throw Error(void 0);return(0,s.jsx)(t.IntlProvider,{locale:e,...n})}e.s(["default",()=>n])}]);
@@ -0,0 +1 @@
1
+ (globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,565650,e=>{"use strict";e.i(342923),e.i(80173),e.i(907714),e.i(393718),e.i(703166),e.i(454149),e.i(822124),e.i(969353),e.i(635055),e.i(897844),e.i(450222),e.i(647829),e.i(6998),e.i(982131),e.i(116016),e.i(279743),e.i(193464),e.i(548036),e.i(566770),e.i(953789),e.i(8839),e.i(227404),e.i(621745),e.i(567955),e.i(17517),e.i(419947),e.i(323060),e.i(642440),e.i(629342),e.i(816062),e.i(690777),e.i(563201),e.i(115243),e.i(165149),e.i(359505),e.s([],565650)},11477,e=>{"use strict";var t=e.i(393718);e.s(["Card",()=>t.default])},659497,e=>{"use strict";var t=e.i(843476),s=e.i(271645);e.i(565650);var r=e.i(454149),a=e.i(948148),n=e.i(657688),l=e.i(25230),i=e.i(243009);function o(e,t={},s={}){let r=Number(t?.used||0),a=Number(t?.total||0),n=t?.resetAt||null,l=function(e){if(!e)return!1;let t="number"==typeof e?e:"string"==typeof e?Date.parse(e):NaN;return!!Number.isFinite(t)&&Date.now()>=t}(n),c=l?0:r,d=Number.isFinite(a)?a:0,u=(0,i.safePercentage)(t?.remainingPercentage),x=l&&d>0?100:void 0!==u?u:void 0;return{name:e,used:Number.isFinite(c)?c:0,total:d,resetAt:n,staleAfterReset:l,...void 0!==x?{remainingPercentage:x}:{},...s}}function c(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"CLAUDE CODE"===s||"KIMI CODING"===s||"KIRO"===s?{key:"unknown",label:t,variant:"default",rank:0,raw:t}:s.includes("PRO+")||s.includes("PRO PLUS")||s.includes("PROPLUS")?{key:"plus",label:"Pro+",variant:"secondary",rank:4,raw:t}: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("STUDENT")?{key:"pro",label:"Student",variant:"primary",rank:3,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("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=e.i(393718),u=e.i(969353),x=e.i(623249);let m="omniroute:limits:groupBy",p="omniroute:limits:autoRefresh",h="omniroute:limits:expandedGroups",b={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"},glm:{label:"GLM (Z.AI)",color:"#4A90D9"},"kimi-coding":{label:"Kimi Coding",color:"#1E3A8A"}},f=[{key:"all",labelKey:"tierAll"},{key:"enterprise",labelKey:"tierEnterprise"},{key:"team",labelKey:"tierTeam"},{key:"business",labelKey:"tierBusiness"},{key:"ultra",labelKey:"tierUltra"},{key:"pro",labelKey:"tierPro"},{key:"plus",labelKey:"tierPlus"},{key:"free",labelKey:"tierFree"},{key:"unknown",labelKey:"tierUnknown"}];function g(){let e,i=(0,a.useTranslations)("usage"),[g,y]=(0,s.useState)([]),[v,j]=(0,s.useState)({}),[k,N]=(0,s.useState)({}),[w,S]=(0,s.useState)({}),[E,C]=(0,s.useState)(()=>"true"===localStorage.getItem(p)),[I,P]=(0,s.useState)(null),[T,A]=(0,s.useState)(!1),[M,R]=(0,s.useState)(120),[O,D]=(0,s.useState)(!0),[q,U]=(0,s.useState)("all"),[F,K]=(0,s.useState)(()=>{let e=localStorage.getItem(m);return"environment"===e||"none"===e?e:"none"}),[L,_]=(0,s.useState)(()=>{try{let e=localStorage.getItem(h);return e?new Set(JSON.parse(e)):new Set}catch{return new Set}}),B=(0,s.useRef)(null),G=(0,s.useRef)(null),$=(0,s.useRef)({}),H=(0,s.useRef)({}),Q=(0,s.useCallback)(async()=>{try{let e=await fetch("/api/providers/client");if(!e.ok)throw Error("Failed");let t=(await e.json()).connections||[];return y(t),t}catch{return y([]),[]}},[]),z=(0,s.useCallback)(async(e,t,s={})=>{let r=s?.force===!0,a=Date.now(),n=$.current[e]||0;if(r||!(a-n<3e4)){$.current[e]=a,N(t=>({...t,[e]:!0})),S(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 j(s=>({...s,[e]:{quotas:[],message:t}}));throw Error(`HTTP ${s.status}: ${t}`)}let r=await s.json(),a=function(e,t){if(!t||"object"!=typeof t)return[];let s=[];try{switch(e.toLowerCase()){case"github":t.quotas&&Object.entries(t.quotas).forEach(([e,t])=>{(!t?.unlimited||t?.total&&!(t.total<=0))&&s.push(o(e,t))});break;case"antigravity":t.quotas&&Object.entries(t.quotas).forEach(([e,t])=>{s.push(o(t.displayName||e,t,{modelKey:e}))});break;case"codex":t.quotas&&Object.entries(t.quotas).forEach(([e,t])=>{s.push(o(e,t))});break;case"kiro":t.quotas&&Object.entries(t.quotas).forEach(([e,t])=>{s.push(o(e,t))});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(o(e,t))});break;default:t.quotas&&Object.entries(t.quotas).forEach(([e,t])=>{s.push(o(e,t))})}}catch(t){return console.error(`Error parsing quota data for ${e}:`,t),[]}let r=(0,l.getModelsByProviderId)(e);if(r.length>0){let e=new Map(r.map((e,t)=>[e.id,t]));s.sort((t,s)=>{let r=t.modelKey||t.name,a=s.modelKey||s.name;return(e.get(r)??999)-(e.get(a)??999)})}return s}(t,r);if(a.some(e=>e?.staleAfterReset===!0)){let s=H.current[e]||0;Date.now()-s>=3e4&&(H.current[e]=Date.now(),setTimeout(()=>{z(e,t,{force:!0}).catch(()=>{})},5e3))}j(t=>({...t,[e]:{quotas:a,plan:r.plan||null,message:r.message||null,raw:r}}))}catch(t){S(s=>({...s,[e]:t.message||"Failed to fetch quota"}))}finally{N(t=>({...t,[e]:!1}))}}},[]),J=(0,s.useCallback)(async(e,t)=>{await z(e,t),P(new Date)},[z]),V=(0,s.useCallback)(async()=>{if(!T){A(!0),R(120);try{let e=(await Q()).filter(e=>x.USAGE_SUPPORTED_PROVIDERS.includes(e.provider)&&("oauth"===e.authType||"apikey"===e.authType));await Promise.all(e.map(e=>z(e.id,e.provider))),P(new Date)}catch(e){console.error("Error refreshing all:",e)}finally{A(!1)}}},[T,Q,z]);(0,s.useEffect)(()=>{(async()=>{D(!0),await V(),D(!1)})()},[]),(0,s.useEffect)(()=>{if(!E){B.current&&clearInterval(B.current),G.current&&clearInterval(G.current);return}return B.current=setInterval(V,12e4),G.current=setInterval(()=>{R(e=>e<=1?120:e-1)},1e3),()=>{B.current&&clearInterval(B.current),G.current&&clearInterval(G.current)}},[E,V]),(0,s.useEffect)(()=>{let e=()=>{document.hidden?(B.current&&clearInterval(B.current),G.current&&clearInterval(G.current)):E&&(B.current=setInterval(V,12e4),G.current=setInterval(()=>{R(e=>e<=1?120:e-1)},1e3))};return document.addEventListener("visibilitychange",e),()=>document.removeEventListener("visibilitychange",e)},[E,V]);let W=(0,s.useMemo)(()=>g.filter(e=>x.USAGE_SUPPORTED_PROVIDERS.includes(e.provider)&&("oauth"===e.authType||"apikey"===e.authType)),[g]),Z=(0,s.useMemo)(()=>{let e={antigravity:1,github:2,codex:3,claude:4,kiro:5,glm:6,"kimi-coding":7};return[...W].sort((t,s)=>(e[t.provider]||9)-(e[s.provider]||9))},[W]),Y=(0,s.useMemo)(()=>{let e={};for(let t of Z)e[t.id]=c(v[t.id]?.plan);return e},[Z,v]),X=(0,s.useMemo)(()=>{let e={all:Z.length,enterprise:0,team:0,business:0,ultra:0,pro:0,free:0,unknown:0};for(let t of Z){let s=Y[t.id]?.key||"unknown";e[s]=(e[s]||0)+1}return e},[Z,Y]),ee=(0,s.useMemo)(()=>"all"===q?Z:Z.filter(e=>(Y[e.id]?.key||"unknown")===q),[Z,Y,q]),et=(0,s.useMemo)(()=>{if("environment"!==F)return null;let e=new Map;for(let t of ee){let s=t.providerSpecificData?.tag?.trim()||i("ungrouped");e.has(s)||e.set(s,[]),e.get(s).push(t)}return new Map([...e.entries()].sort(([e],[t])=>e===i("ungrouped")?1:t===i("ungrouped")?-1:e.localeCompare(t)))},[F,ee,i]),es=e=>{K(e),localStorage.setItem(m,e)};return((0,s.useEffect)(()=>{null===localStorage.getItem(m)&&g.some(e=>e.providerSpecificData?.tag?.trim())&&K("environment")},[g]),(0,s.useEffect)(()=>{if("environment"===F&&et&&0===L.size){let e=new Set([...et.keys()]);_(e),localStorage.setItem(h,JSON.stringify([...e]))}},[F,et]),O)?(0,t.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,t.jsx)(r.CardSkeleton,{}),(0,t.jsx)(r.CardSkeleton,{})]}):0===Z.length?(0,t.jsx)(d.default,{padding:"lg",children:(0,t.jsxs)("div",{className:"text-center py-12",children:[(0,t.jsx)("span",{className:"material-symbols-outlined text-[64px] opacity-15",children:"cloud_off"}),(0,t.jsx)("h3",{className:"mt-4 text-lg font-semibold text-text-main",children:i("noProviders")}),(0,t.jsx)("p",{className:"mt-2 text-sm text-text-muted max-w-[400px] mx-auto",children:i("connectProvidersForQuota")})]})}):(0,t.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between flex-wrap gap-3",children:[(0,t.jsxs)("div",{className:"flex items-center gap-3",children:[(0,t.jsx)("h2",{className:"text-lg font-semibold text-text-main m-0",children:i("providerLimits")}),(0,t.jsxs)("span",{className:"text-[13px] text-text-muted",children:[i("accountsCount",{count:ee.length}),ee.length!==Z.length&&` ${i("filteredFromCount",{count:Z.length})}`]})]}),(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsxs)("div",{className:"flex rounded-lg border border-border overflow-hidden",children:[(0,t.jsx)("button",{onClick:()=>es("none"),className:"px-2.5 py-1.5 text-[12px] font-medium cursor-pointer border-none",style:{background:"none"===F?"var(--color-bg-subtle)":"transparent",color:"none"===F?"var(--color-text-main)":"var(--color-text-muted)"},children:i("viewFlat")}),(0,t.jsx)("button",{onClick:()=>es("environment"),className:"px-2.5 py-1.5 text-[12px] font-medium cursor-pointer border-none",style:{background:"environment"===F?"var(--color-bg-subtle)":"transparent",color:"environment"===F?"var(--color-text-main)":"var(--color-text-muted)",borderLeft:"1px solid var(--color-border)"},children:i("viewByEnvironment")})]}),(0,t.jsxs)("button",{onClick:()=>{let e=!E;C(e),localStorage.setItem(p,String(e))},className:"flex items-center gap-1.5 px-3 py-1.5 rounded-lg border border-border bg-transparent cursor-pointer text-text-main text-[13px]",children:[(0,t.jsx)("span",{className:"material-symbols-outlined text-[18px]",style:{color:E?"#22c55e":"var(--text-muted)"},children:E?"toggle_on":"toggle_off"}),i("autoRefresh"),E&&(0,t.jsxs)("span",{className:"text-xs text-text-muted",children:["(",M,"s)"]})]}),(0,t.jsxs)("button",{onClick:V,disabled:T,className:"flex items-center gap-1.5 px-3.5 py-1.5 rounded-lg bg-bg-subtle border border-border text-text-main text-[13px] disabled:opacity-50 disabled:cursor-not-allowed cursor-pointer",children:[(0,t.jsx)("span",{className:`material-symbols-outlined text-[16px] ${T?"animate-spin":""}`,children:"refresh"}),i("refreshAll")]})]})]}),(0,t.jsx)("div",{className:"flex items-center gap-2 flex-wrap",children:f.map(e=>{if("all"!==e.key&&!X[e.key])return null;let s=q===e.key;return(0,t.jsxs)("button",{onClick:()=>U(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:s?"1px solid var(--color-primary, #E54D5E)":"1px solid var(--color-border)",background:s?"rgba(229,77,94,0.1)":"transparent",color:s?"var(--color-primary, #E54D5E)":"var(--color-text-muted)"},children:[(0,t.jsx)("span",{children:i(e.labelKey)}),(0,t.jsx)("span",{className:"opacity-85",children:X[e.key]||0})]},e.key)})}),(0,t.jsxs)("div",{className:"rounded-xl border border-border overflow-hidden bg-surface",children:[(0,t.jsxs)("div",{className:"items-center px-4 py-2.5 border-b border-border text-[11px] font-semibold uppercase tracking-wider text-text-muted",style:{display:"grid",gridTemplateColumns:"280px 1fr 100px 48px"},children:[(0,t.jsx)("div",{children:i("account")}),(0,t.jsx)("div",{children:i("modelQuotas")}),(0,t.jsx)("div",{className:"text-center",children:i("lastUsed")}),(0,t.jsx)("div",{className:"text-center",children:i("actions")})]}),(e=(e,s)=>{let r=v[e.id],a=k[e.id],l=w[e.id],o=b[e.provider]||{label:e.provider,color:"#666"},d=Y[e.id]||c(null);return(0,t.jsxs)("div",{className:"items-center px-4 py-3.5 transition-[background] duration-150 hover:bg-black/[0.03] dark:hover:bg-white/[0.02]",style:{display:"grid",gridTemplateColumns:"280px 1fr 100px 48px",borderBottom:s?"none":"1px solid var(--color-border)"},children:[(0,t.jsxs)("div",{className:"flex items-center gap-2.5 min-w-0",children:[(0,t.jsx)("div",{className:"w-8 h-8 rounded-lg flex items-center justify-center overflow-hidden shrink-0",children:(0,t.jsx)(n.default,{src:`/providers/${e.provider}.png`,alt:e.provider,width:32,height:32,className:"object-contain",sizes:"32px"})}),(0,t.jsxs)("div",{className:"min-w-0",children:[(0,t.jsx)("div",{className:"text-[13px] font-semibold text-text-main truncate",children:e.name||o.label}),(0,t.jsxs)("div",{className:"flex items-center gap-1.5 mt-0.5",children:[(0,t.jsx)("span",{title:r?.plan?i("rawPlanWithValue",{plan:r.plan}):i("noPlanFromProvider"),children:(0,t.jsx)(u.default,{variant:d.variant,size:"sm",dot:!0,children:d.label})}),(0,t.jsx)("span",{className:"text-[11px] text-text-muted",children:o.label})]})]})]}),(0,t.jsx)("div",{className:"flex flex-wrap gap-x-3 gap-y-1.5 pr-3",children:a?(0,t.jsxs)("div",{className:"flex items-center gap-1.5 text-text-muted text-xs",children:[(0,t.jsx)("span",{className:"material-symbols-outlined animate-spin text-[14px]",children:"progress_activity"}),i("loadingQuotas")]}):l?(0,t.jsxs)("div",{className:"flex items-center gap-1.5 text-xs text-red-500",children:[(0,t.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"error"}),(0,t.jsx)("span",{className:"overflow-hidden text-ellipsis whitespace-nowrap max-w-[300px]",children:l})]}):r?.message&&(!r.quotas||0===r.quotas.length)?(0,t.jsx)("div",{className:"text-xs text-text-muted italic",children:r.message}):r?.quotas?.length>0?r.quotas.map((e,s)=>{var r,a,n;let l=void 0!==e.remainingPercentage?Math.round(e.remainingPercentage):(r=e.used,(a=e.total)&&0!==a?!r||r<0?100:r>=a?0:Math.round((a-r)/a*100):0),i=l>70?{bar:"#22c55e",text:"#22c55e",bg:"rgba(34,197,94,0.12)"}:l>=30?{bar:"#eab308",text:"#eab308",bg:"rgba(234,179,8,0.12)"}:{bar:"#ef4444",text:"#ef4444",bg:"rgba(239,68,68,0.12)"},o=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),r=Math.floor(t%36e5/6e4);if(s>=24){let e=Math.floor(s/24);return`${e}d ${s%24}h`}return`${s}h ${r}m`}catch{return null}}(e.resetAt),c={"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)"}[n=e.name]||n,d=!0===e.staleAfterReset;return(0,t.jsxs)("div",{className:"flex items-center gap-1.5 min-w-[200px] shrink-0",children:[(0,t.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:c}),d?(0,t.jsx)("span",{className:"text-[10px] text-text-muted whitespace-nowrap",children:"⟳ Refreshing..."}):o?(0,t.jsxs)("span",{className:"text-[10px] text-text-muted whitespace-nowrap",children:["⏱ ",o]}):null,(0,t.jsx)("div",{className:"flex-1 h-1.5 rounded-sm bg-black/[0.06] dark:bg-white/[0.06] min-w-[60px] overflow-hidden",children:(0,t.jsx)("div",{className:"h-full rounded-sm transition-[width] duration-300 ease-out",style:{width:`${Math.min(l,100)}%`,background:i.bar}})}),(0,t.jsxs)("span",{className:"text-[11px] font-semibold min-w-[32px] text-right",style:{color:i.text},children:[l,"%"]})]},s)}):(0,t.jsx)("div",{className:"text-xs text-text-muted italic",children:i("noQuotaData")})}),(0,t.jsx)("div",{className:"text-center text-[11px] text-text-muted",children:I?(0,t.jsx)("span",{children:I.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}):"-"}),(0,t.jsx)("div",{className:"flex justify-center gap-0.5",children:(0,t.jsx)("button",{onClick:()=>J(e.id,e.provider),disabled:a,title:i("refreshQuota"),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,t.jsx)("span",{className:`material-symbols-outlined text-[16px] text-text-muted ${a?"animate-spin":""}`,children:"refresh"})})})]},e.id)},et?[...et.entries()].map(([s,r])=>(0,t.jsxs)("div",{className:"border border-border rounded-lg overflow-hidden mb-2",children:[(0,t.jsxs)("button",{onClick:()=>{_(e=>{let t=new Set(e);return t.has(s)?t.delete(s):t.add(s),localStorage.setItem(h,JSON.stringify([...t])),t})},className:"w-full flex items-center gap-2 px-4 py-2.5 bg-bg-subtle hover:bg-black/[0.04] dark:hover:bg-white/[0.05] transition-colors text-left border-none cursor-pointer",children:[(0,t.jsx)("span",{className:"material-symbols-outlined text-[16px] text-text-muted",children:L.has(s)?"expand_less":"expand_more"}),(0,t.jsx)("span",{className:"material-symbols-outlined text-[16px] text-text-muted",children:"folder"}),(0,t.jsx)("span",{className:"text-[12px] font-semibold text-text-main uppercase tracking-wider flex-1",children:s}),(0,t.jsx)("span",{className:"text-[11px] text-text-muted bg-black/[0.04] dark:bg-white/[0.06] px-2 py-0.5 rounded-full",children:r.length})]}),L.has(s)&&(0,t.jsx)("div",{children:r.map((t,s)=>e(t,s===r.length-1))})]},s)):ee.map((t,s)=>e(t,s===ee.length-1))),0===ee.length&&(0,t.jsxs)("div",{className:"py-6 px-4 text-center text-text-muted text-[13px]",children:[i("noAccountsForTierFilter")," ",(0,t.jsx)("strong",{children:i(f.find(e=>e.key===q)?.labelKey||"tierUnknown")}),"."]})]})]})}var y=e.i(11477);function v(){let e=(0,a.useTranslations)("usage"),r=(0,a.useTranslations)("common"),[n,l]=(0,s.useState)({lockouts:[],cacheStats:null}),[i,o]=(0,s.useState)(!0),c=(0,s.useCallback)(async()=>{try{let e=await fetch("/api/rate-limits");e.ok&&l(await e.json())}catch{}finally{o(!1)}},[]);return(0,s.useEffect)(()=>{c();let e=setInterval(c,1e4);return()=>clearInterval(e)},[c]),(0,t.jsx)("div",{className:"flex flex-col gap-4",children:(0,t.jsxs)(y.Card,{children:[(0,t.jsxs)("div",{className:"flex items-center gap-3 mb-4",children:[(0,t.jsx)("div",{className:"p-2 rounded-lg bg-orange-500/10 text-orange-500",children:(0,t.jsx)("span",{className:"material-symbols-outlined text-[20px]","aria-hidden":"true",children:"lock_clock"})}),(0,t.jsxs)("div",{className:"flex-1",children:[(0,t.jsx)("h3",{className:"text-lg font-semibold",children:e("modelLockouts")}),(0,t.jsx)("p",{className:"text-sm text-text-muted",children:e("lockoutsAutoRefreshHint")})]}),n.lockouts.length>0&&(0,t.jsx)("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:e("lockedCount",{count:n.lockouts.length})})]}),0===n.lockouts.length?(0,t.jsxs)("div",{className:"text-center py-6 text-text-muted",children:[(0,t.jsx)("span",{className:"material-symbols-outlined text-[32px] mb-2 block opacity-40","aria-hidden":"true",children:"lock_open"}),(0,t.jsx)("p",{className:"text-sm",children:e("noLockouts")})]}):(0,t.jsx)("div",{className:"flex flex-col gap-2",children:n.lockouts.map((s,a)=>{var n;return(0,t.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,t.jsxs)("div",{className:"flex items-center gap-3",children:[(0,t.jsx)("span",{className:"material-symbols-outlined text-[16px] text-orange-400","aria-hidden":"true",children:"lock"}),(0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"text-sm font-medium",children:s.model}),(0,t.jsxs)("p",{className:"text-xs text-text-muted",children:[e("account"),":"," ",(0,t.jsx)("span",{className:"font-mono",children:s.accountId?.slice(0,12)||r("none")}),s.reason&&(0,t.jsxs)(t.Fragment,{children:[e("reasonSeparator"),s.reason]})]})]})]}),(0,t.jsx)("span",{className:"text-xs font-mono tabular-nums text-orange-400",children:e("timeLeft",{time:(n=s.remainingMs)<1e3?e("durationMillisecondsShort",{value:n}):n<6e4?e("durationSecondsShort",{value:Math.ceil(n/1e3)}):e("durationMinutesShort",{value:Math.ceil(n/6e4)})})})]},a)})})]})})}function j(){let e=(0,a.useTranslations)("usage"),[r,n]=(0,s.useState)({count:0,sessions:[]}),[l,i]=(0,s.useState)(!0),o=(0,s.useCallback)(async()=>{try{let e=await fetch("/api/sessions");e.ok&&n(await e.json())}catch{}finally{i(!1)}},[]);return(0,s.useEffect)(()=>{o();let e=setInterval(o,5e3);return()=>clearInterval(e)},[o]),(0,t.jsxs)(y.Card,{children:[(0,t.jsxs)("div",{className:"flex items-center gap-3 mb-5",children:[(0,t.jsx)("div",{className:"p-2 rounded-lg bg-cyan-500/10 text-cyan-500",children:(0,t.jsx)("span",{className:"material-symbols-outlined text-[20px]","aria-hidden":"true",children:"fingerprint"})}),(0,t.jsxs)("div",{className:"flex-1",children:[(0,t.jsx)("h3",{className:"text-lg font-semibold",children:e("activeSessions")}),(0,t.jsx)("p",{className:"text-sm text-text-muted",children:e("sessionsTrackedHint")})]}),(0,t.jsx)("div",{className:"flex items-center gap-2",children:(0,t.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,t.jsx)("span",{className:"w-2 h-2 rounded-full bg-cyan-500 animate-pulse"}),(0,t.jsx)("span",{className:"text-sm font-semibold tabular-nums text-cyan-400",children:r.count})]})})]}),0===r.sessions.length?(0,t.jsxs)("div",{className:"text-center py-8 text-text-muted",children:[(0,t.jsx)("span",{className:"material-symbols-outlined text-[40px] mb-2 block opacity-40","aria-hidden":"true",children:"fingerprint"}),(0,t.jsx)("p",{className:"text-sm",children:e("noSessions")}),(0,t.jsx)("p",{className:"text-xs mt-1",children:e("sessionsHint")})]}):(0,t.jsx)("div",{className:"overflow-x-auto",children:(0,t.jsxs)("table",{className:"w-full text-sm",children:[(0,t.jsx)("thead",{children:(0,t.jsxs)("tr",{className:"border-b border-border/30",children:[(0,t.jsx)("th",{className:"text-left py-2 px-3 text-xs font-semibold text-text-muted uppercase tracking-wider",children:e("session")}),(0,t.jsx)("th",{className:"text-left py-2 px-3 text-xs font-semibold text-text-muted uppercase tracking-wider",children:e("age")}),(0,t.jsx)("th",{className:"text-right py-2 px-3 text-xs font-semibold text-text-muted uppercase tracking-wider",children:e("requests")}),(0,t.jsx)("th",{className:"text-left py-2 px-3 text-xs font-semibold text-text-muted uppercase tracking-wider",children:e("connection")})]})}),(0,t.jsx)("tbody",{children:r.sessions.map(s=>{var r;return(0,t.jsxs)("tr",{className:"border-b border-border/10 hover:bg-surface/20 transition-colors",children:[(0,t.jsx)("td",{className:"py-2.5 px-3",children:(0,t.jsxs)("span",{className:"font-mono text-xs px-2 py-1 rounded bg-surface/40 text-text-muted",children:[s.sessionId.slice(0,12),"…"]})}),(0,t.jsx)("td",{className:"py-2.5 px-3 text-text-muted tabular-nums",children:(r=s.ageMs)<6e4?e("durationSecondsShort",{value:Math.floor(r/1e3)}):r<36e5?e("durationMinutesShort",{value:Math.floor(r/6e4)}):e("durationHoursShort",{value:Math.floor(r/36e5)})}),(0,t.jsx)("td",{className:"py-2.5 px-3 text-right",children:(0,t.jsx)("span",{className:"font-semibold tabular-nums",children:s.requestCount})}),(0,t.jsx)("td",{className:"py-2.5 px-3",children:s.connectionId?(0,t.jsx)("span",{className:"text-xs font-mono text-cyan-400",children:s.connectionId.slice(0,10)}):(0,t.jsx)("span",{className:"text-text-muted/40",children:e("notAvailableSymbol")})})]},s.sessionId)})})]})})]})}function k(){return(0,t.jsxs)("div",{className:"flex flex-col gap-6",children:[(0,t.jsx)(s.Suspense,{fallback:(0,t.jsx)(r.CardSkeleton,{}),children:(0,t.jsx)(g,{})}),(0,t.jsx)(j,{}),(0,t.jsx)(v,{})]})}e.s(["default",()=>k],659497)}]);
@@ -0,0 +1 @@
1
+ (globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,667498,e=>{"use strict";var t=e.i(843476),s=e.i(271645),a=e.i(618566),r=e.i(156132),l=e.i(497769),i=e.i(948148);e.i(565650);var n=e.i(11477),d=e.i(474078),c=e.i(628029),o=e.i(861745);function m(){let[e,a]=(0,s.useState)([]),[r,l]=(0,s.useState)(!1),[m,x]=(0,s.useState)(!1),[u,h]=(0,s.useState)({type:"",message:""}),[p,b]=(0,s.useState)(null),[g,f]=(0,s.useState)(null),[j,y]=(0,s.useState)(!1),[v,N]=(0,s.useState)({type:"",message:""}),[k,w]=(0,s.useState)(!1),[C,S]=(0,s.useState)(!1),[T,P]=(0,s.useState)({type:"",message:""}),[A,B]=(0,s.useState)(!1),[D,E]=(0,s.useState)(null),O=(0,s.useRef)(null),L=(0,o.useLocale)(),M=(0,i.useTranslations)("settings"),I=(0,i.useTranslations)("common"),[F,_]=(0,s.useState)({driver:"sqlite",dbPath:"~/.omniroute/storage.sqlite",sizeBytes:0,retentionDays:90,lastBackupAt:null}),R=async()=>{l(!0);try{let e=await fetch("/api/db-backups"),t=await e.json();a(t.backups||[])}catch(e){console.error("Failed to fetch backups:",e)}finally{l(!1)}},$=async()=>{try{let e=await fetch("/api/storage/health");if(!e.ok)return;let t=await e.json();_(e=>({...e,...t}))}catch(e){console.error("Failed to fetch storage health:",e)}},z=async()=>{y(!0),N({type:"",message:""});try{let e=await fetch("/api/db-backups",{method:"PUT"}),t=await e.json();e.ok?(t.filename?N({type:"success",message:M("backupCreated",{file:t.filename})}):N({type:"info",message:t.message||M("noChangesSinceBackup")}),await $(),m&&await R()):N({type:"error",message:t.error||M("backupFailed")})}catch{N({type:"error",message:M("errorOccurred")})}finally{y(!1)}},K=async e=>{b(e),h({type:"",message:""});try{let t=await fetch("/api/db-backups",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({backupId:e})}),s=await t.json();t.ok?(h({type:"success",message:M("restoreSuccess",{connections:s.connectionCount,nodes:s.nodeCount,combos:s.comboCount,apiKeys:s.apiKeyCount})}),await R(),await $()):h({type:"error",message:s.error||M("restoreFailed")})}catch{h({type:"error",message:M("errorDuringRestore")})}finally{b(null),f(null)}};(0,s.useEffect)(()=>{$()},[]);let H=async()=>{w(!0);try{let e=await fetch("/api/db-backups/export");if(!e.ok){let t=await e.json();throw Error(t.error||M("exportFailed"))}let t=await e.blob(),s=URL.createObjectURL(t),a=(e.headers.get("Content-Disposition")||"").match(/filename="(.+)"/),r=a?a[1]:`omniroute-backup-${new Date().toISOString().replace(/[:.]/g,"-")}.sqlite`,l=document.createElement("a");l.href=s,l.download=r,document.body.appendChild(l),l.click(),document.body.removeChild(l),URL.revokeObjectURL(s)}catch(e){console.error("Export failed:",e),P({type:"error",message:M("exportFailedWithError",{error:e.message})})}finally{w(!1)}},q=async()=>{if(D){S(!0),P({type:"",message:""}),B(!1);try{let e=new FormData;e.append("file",D);let t=await fetch("/api/db-backups/import",{method:"POST",body:e}),s=await t.json();t.ok?(P({type:"success",message:M("importSuccess",{connections:s.connectionCount,nodes:s.nodeCount,combos:s.comboCount,apiKeys:s.apiKeyCount})}),await $(),m&&await R()):P({type:"error",message:s.error||M("importFailed")})}catch{P({type:"error",message:M("errorDuringImport")})}finally{S(!1),E(null)}}},U=e=>e&&0!==e?e<1024?`${e} B`:e<1048576?`${(e/1024).toFixed(1)} KB`:`${(e/1048576).toFixed(1)} MB`:"0 B";return(0,t.jsxs)(n.Card,{children:[(0,t.jsxs)("div",{className:"flex items-center gap-3 mb-4",children:[(0,t.jsx)("div",{className:"p-2 rounded-lg bg-green-500/10 text-green-500",children:(0,t.jsx)("span",{className:"material-symbols-outlined text-[20px]","aria-hidden":"true",children:"database"})}),(0,t.jsxs)("div",{className:"flex-1",children:[(0,t.jsx)("h3",{className:"text-lg font-semibold",children:M("systemStorage")}),(0,t.jsx)("p",{className:"text-xs text-text-muted",children:M("allDataLocal")})]}),(0,t.jsx)(c.Badge,{variant:"success",size:"sm",children:F.driver||"json"})]}),(0,t.jsxs)("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3 mb-4",children:[(0,t.jsxs)("div",{className:"p-3 rounded-lg bg-bg border border-border",children:[(0,t.jsx)("p",{className:"text-[11px] text-text-muted uppercase tracking-wide mb-1",children:M("databasePath")}),(0,t.jsx)("p",{className:"text-sm font-mono text-text-main break-all",children:F.dbPath||"~/.omniroute/storage.sqlite"})]}),(0,t.jsxs)("div",{className:"p-3 rounded-lg bg-bg border border-border",children:[(0,t.jsx)("p",{className:"text-[11px] text-text-muted uppercase tracking-wide mb-1",children:M("databaseSize")}),(0,t.jsx)("p",{className:"text-sm font-mono text-text-main",children:U(F.sizeBytes)})]})]}),(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2 mb-4",children:[(0,t.jsxs)(d.Button,{variant:"outline",size:"sm",onClick:H,loading:k,children:[(0,t.jsx)("span",{className:"material-symbols-outlined text-[14px] mr-1","aria-hidden":"true",children:"download"}),M("exportDatabase")]}),(0,t.jsxs)(d.Button,{variant:"outline",size:"sm",onClick:async()=>{w(!0);try{let e=await fetch("/api/db-backups/exportAll");if(!e.ok)throw Error(M("exportFailed"));let t=await e.blob(),s=(e.headers.get("Content-Disposition")||"").match(/filename="?([^"]+)"?/),a=s?.[1]||"omniroute-full-backup.tar.gz",r=URL.createObjectURL(t),l=document.createElement("a");l.href=r,l.download=a,document.body.appendChild(l),l.click(),document.body.removeChild(l),URL.revokeObjectURL(r)}catch(e){P({type:"error",message:M("fullExportFailedWithError",{error:e.message})})}finally{w(!1)}},loading:k,children:[(0,t.jsx)("span",{className:"material-symbols-outlined text-[14px] mr-1","aria-hidden":"true",children:"folder_zip"}),M("exportAll")]}),(0,t.jsxs)(d.Button,{variant:"outline",size:"sm",onClick:()=>{O.current?.click()},loading:C,children:[(0,t.jsx)("span",{className:"material-symbols-outlined text-[14px] mr-1","aria-hidden":"true",children:"upload"}),M("importDatabase")]}),(0,t.jsx)("input",{ref:O,type:"file",accept:".sqlite",className:"hidden",onChange:e=>{let t=e.target.files?.[0];if(t){if(!t.name.endsWith(".sqlite"))return void P({type:"error",message:M("invalidFileType")});E(t),B(!0),O.current&&(O.current.value="")}}})]}),A&&D&&(0,t.jsx)("div",{className:"p-4 rounded-lg mb-4 bg-amber-500/10 border border-amber-500/30",children:(0,t.jsxs)("div",{className:"flex items-start gap-3",children:[(0,t.jsx)("span",{className:"material-symbols-outlined text-[20px] text-amber-500 mt-0.5","aria-hidden":"true",children:"warning"}),(0,t.jsxs)("div",{className:"flex-1",children:[(0,t.jsx)("p",{className:"text-sm font-medium text-amber-500 mb-1",children:M("confirmDbImport")}),(0,t.jsx)("p",{className:"text-xs text-text-muted mb-2",children:M("confirmDbImportDesc",{file:D.name})}),(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)(d.Button,{variant:"primary",size:"sm",onClick:q,className:"!bg-amber-500 hover:!bg-amber-600",children:M("yesImport")}),(0,t.jsx)(d.Button,{variant:"outline",size:"sm",onClick:()=>{B(!1),E(null)},children:I("cancel")})]})]})]})}),T.message&&(0,t.jsx)("div",{className:`p-3 rounded-lg mb-4 text-sm ${"success"===T.type?"bg-green-500/10 text-green-500 border border-green-500/20":"bg-red-500/10 text-red-500 border border-red-500/20"}`,role:"alert",children:(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)("span",{className:"material-symbols-outlined text-[16px]","aria-hidden":"true",children:"success"===T.type?"check_circle":"error"}),T.message]})}),(0,t.jsxs)("div",{className:"flex items-center justify-between p-3 rounded-lg bg-bg border border-border mb-4",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)("span",{className:"material-symbols-outlined text-[16px] text-amber-500","aria-hidden":"true",children:"schedule"}),(0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"text-sm font-medium",children:M("lastBackup")}),(0,t.jsx)("p",{className:"text-xs text-text-muted",children:F.lastBackupAt?`${new Date(F.lastBackupAt).toLocaleString(L)} (${(e=>{if(!e)return null;let t=Math.floor((new Date-new Date(e))/6e4);if(t<1)return M("justNow");if(t<60)return M("minutesAgo",{count:t});let s=Math.floor(t/60);return s<24?M("hoursAgo",{count:s}):M("daysAgo",{count:Math.floor(s/24)})})(F.lastBackupAt)})`:M("noBackupYet")})]})]}),(0,t.jsxs)(d.Button,{variant:"outline",size:"sm",onClick:z,loading:j,children:[(0,t.jsx)("span",{className:"material-symbols-outlined text-[14px] mr-1","aria-hidden":"true",children:"backup"}),M("backupNow")]})]}),v.message&&(0,t.jsx)("div",{className:`p-3 rounded-lg mb-4 text-sm ${"success"===v.type?"bg-green-500/10 text-green-500 border border-green-500/20":"info"===v.type?"bg-blue-500/10 text-blue-500 border border-blue-500/20":"bg-red-500/10 text-red-500 border border-red-500/20"}`,role:"alert",children:(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)("span",{className:"material-symbols-outlined text-[16px]","aria-hidden":"true",children:"success"===v.type?"check_circle":"info"===v.type?"info":"error"}),v.message]})}),(0,t.jsxs)("div",{className:"pt-3 border-t border-border/50",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between mb-3",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)("span",{className:"material-symbols-outlined text-[18px] text-amber-500","aria-hidden":"true",children:"restore"}),(0,t.jsx)("p",{className:"font-medium",children:M("backupRestore")})]}),(0,t.jsx)(d.Button,{variant:"outline",size:"sm",onClick:()=>{x(!m),m||0!==e.length||R()},children:m?M("hide"):M("viewBackups")})]}),(0,t.jsx)("p",{className:"text-xs text-text-muted mb-3",children:M("backupRetentionDesc")}),u.message&&(0,t.jsx)("div",{className:`p-3 rounded-lg mb-3 text-sm ${"success"===u.type?"bg-green-500/10 text-green-500 border border-green-500/20":"bg-red-500/10 text-red-500 border border-red-500/20"}`,role:"alert",children:(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)("span",{className:"material-symbols-outlined text-[16px]","aria-hidden":"true",children:"success"===u.type?"check_circle":"error"}),u.message]})}),m&&(0,t.jsx)("div",{className:"flex flex-col gap-2",children:r?(0,t.jsxs)("div",{className:"flex items-center justify-center py-6 text-text-muted",children:[(0,t.jsx)("span",{className:"material-symbols-outlined animate-spin text-[20px] mr-2","aria-hidden":"true",children:"progress_activity"}),M("loadingBackups")]}):0===e.length?(0,t.jsxs)("div",{className:"text-center py-6 text-text-muted text-sm",children:[(0,t.jsx)("span",{className:"material-symbols-outlined text-[32px] mb-2 block opacity-40","aria-hidden":"true",children:"folder_off"}),M("noBackupsYet")]}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("div",{className:"flex items-center justify-between mb-1",children:[(0,t.jsx)("span",{className:"text-xs text-text-muted",children:M("backupsAvailable",{count:e.length})}),(0,t.jsxs)("button",{onClick:R,className:"text-xs text-primary hover:underline flex items-center gap-1",children:[(0,t.jsx)("span",{className:"material-symbols-outlined text-[14px]","aria-hidden":"true",children:"refresh"}),M("refresh")]})]}),e.map(e=>{var s;return(0,t.jsxs)("div",{className:"flex items-center justify-between p-3 rounded-lg bg-black/[0.02] dark:bg-white/[0.02] border border-border/50 hover:border-border transition-colors",children:[(0,t.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2 mb-1",children:[(0,t.jsx)("span",{className:"material-symbols-outlined text-[16px] text-amber-500","aria-hidden":"true",children:"description"}),(0,t.jsx)("span",{className:"text-sm font-medium truncate",children:new Date(e.createdAt).toLocaleString(L)}),(0,t.jsx)(c.Badge,{variant:"pre-restore"===e.reason?"warning":"manual"===e.reason?"success":"default",size:"sm",children:"manual"===(s=e.reason)?M("backupReasonManual"):"pre-restore"===s?M("backupReasonPreRestore"):s})]}),(0,t.jsxs)("div",{className:"flex items-center gap-3 text-xs text-text-muted ml-6",children:[(0,t.jsx)("span",{children:M("connectionsCount",{count:e.connectionCount})}),(0,t.jsx)("span",{children:"•"}),(0,t.jsx)("span",{children:U(e.size)})]})]}),(0,t.jsx)("div",{className:"flex items-center gap-2 ml-3",children:g===e.id?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("span",{className:"text-xs text-amber-500 font-medium",children:M("confirm")}),(0,t.jsx)(d.Button,{variant:"primary",size:"sm",onClick:()=>K(e.id),loading:p===e.id,className:"!bg-amber-500 hover:!bg-amber-600",children:M("yes")}),(0,t.jsx)(d.Button,{variant:"outline",size:"sm",onClick:()=>f(null),children:M("no")})]}):(0,t.jsxs)(d.Button,{variant:"outline",size:"sm",onClick:()=>f(e.id),children:[(0,t.jsx)("span",{className:"material-symbols-outlined text-[14px] mr-1","aria-hidden":"true",children:"restore"}),M("restore")]})})]},e.id)})]})})]})]})}var x=e.i(339971),u=e.i(148943),h=e.i(623249);let p=[{value:"disabled",labelKey:"ipModeDisabled",icon:"block"},{value:"blacklist",labelKey:"ipModeBlacklist",icon:"do_not_disturb"},{value:"whitelist",labelKey:"ipModeWhitelist",icon:"verified_user"},{value:"whitelist-priority",labelKey:"ipModeWhitelistPriority",icon:"priority_high"}];function b(){let[e,a]=(0,s.useState)({enabled:!1,mode:"blacklist",blacklist:[],whitelist:[],tempBans:[]}),[r,l]=(0,s.useState)(!0),[c,o]=(0,s.useState)(""),[m,u]=(0,s.useState)("blacklist"),h=(0,i.useTranslations)("settings");(0,s.useEffect)(()=>{b()},[]);let b=async()=>{try{let e=await fetch("/api/settings/ip-filter");e.ok&&a(await e.json())}catch{}finally{l(!1)}},g=async e=>{try{let t=await fetch("/api/settings/ip-filter",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});t.ok&&a(await t.json())}catch{}},f=()=>{c.trim()&&(g({["blacklist"===m?"addBlacklist":"addWhitelist"]:c.trim()}),o(""))},j=(e,t)=>{g({["blacklist"===t?"removeBlacklist":"removeWhitelist"]:e})},y=e.enabled?e.mode:"disabled";return(0,t.jsxs)(n.Card,{children:[(0,t.jsxs)("div",{className:"flex items-center gap-3 mb-5",children:[(0,t.jsx)("div",{className:"p-2 rounded-lg bg-red-500/10 text-red-500",children:(0,t.jsx)("span",{className:"material-symbols-outlined text-[20px]","aria-hidden":"true",children:"security"})}),(0,t.jsxs)("div",{className:"flex-1",children:[(0,t.jsx)("h3",{className:"text-lg font-semibold",children:h("ipAccessControl")}),(0,t.jsx)("p",{className:"text-sm text-text-muted",children:h("ipAccessControlDesc")})]})]}),(0,t.jsx)("div",{className:"grid grid-cols-2 lg:grid-cols-4 gap-2 mb-5",children:p.map(e=>(0,t.jsxs)("button",{onClick:()=>{var t;"disabled"===(t=e.value)?g({enabled:!1}):g({enabled:!0,mode:t})},disabled:r,className:`flex flex-col items-center gap-1.5 p-3 rounded-lg border text-center transition-all ${y===e.value?"border-red-500/50 bg-red-500/5 ring-1 ring-red-500/20":"border-border/50 hover:border-border hover:bg-surface/30"}`,children:[(0,t.jsx)("span",{className:`material-symbols-outlined text-[20px] ${y===e.value?"text-red-400":"text-text-muted"}`,children:e.icon}),(0,t.jsx)("span",{className:`text-xs font-medium ${y===e.value?"text-red-400":"text-text-muted"}`,children:h(e.labelKey)})]},e.value))}),e.enabled&&(0,t.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,t.jsxs)("div",{className:"flex flex-col sm:flex-row gap-2 items-stretch sm:items-end",children:[(0,t.jsx)("div",{className:"flex-1",children:(0,t.jsx)(x.Input,{label:h("addIpAddress"),placeholder:h("ipAddressPlaceholder"),value:c,onChange:e=>o(e.target.value),onKeyDown:e=>"Enter"===e.key&&f()})}),(0,t.jsxs)("div",{className:"flex gap-1 pb-[2px]",children:[(0,t.jsx)(d.Button,{size:"sm",variant:"blacklist"===m?"danger":"secondary",onClick:()=>{u("blacklist"),c.trim()&&f()},children:h("block")}),(0,t.jsx)(d.Button,{size:"sm",variant:"whitelist"===m?"primary":"secondary",onClick:()=>{u("whitelist"),c.trim()&&f()},children:h("allow")})]})]}),e.blacklist.length>0&&(0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"text-xs font-semibold text-text-muted uppercase tracking-wider mb-2",children:h("blocked",{count:e.blacklist.length})}),(0,t.jsx)("div",{className:"flex flex-wrap gap-1.5",children:e.blacklist.map(e=>(0,t.jsxs)("span",{className:"inline-flex items-center gap-1.5 px-2.5 py-1 rounded-md text-xs font-mono bg-red-500/10 text-red-400 border border-red-500/20",children:[e,(0,t.jsx)("button",{onClick:()=>j(e,"blacklist"),className:"hover:text-red-300",children:(0,t.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"close"})})]},e))})]}),e.whitelist.length>0&&(0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"text-xs font-semibold text-text-muted uppercase tracking-wider mb-2",children:h("allowed",{count:e.whitelist.length})}),(0,t.jsx)("div",{className:"flex flex-wrap gap-1.5",children:e.whitelist.map(e=>(0,t.jsxs)("span",{className:"inline-flex items-center gap-1.5 px-2.5 py-1 rounded-md text-xs font-mono bg-emerald-500/10 text-emerald-400 border border-emerald-500/20",children:[e,(0,t.jsx)("button",{onClick:()=>j(e,"whitelist"),className:"hover:text-emerald-300",children:(0,t.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"close"})})]},e))})]}),e.tempBans.length>0&&(0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"text-xs font-semibold text-text-muted uppercase tracking-wider mb-2",children:h("temporaryBans",{count:e.tempBans.length})}),(0,t.jsx)("div",{className:"flex flex-col gap-1.5",children:e.tempBans.map(e=>(0,t.jsxs)("div",{className:"flex items-center justify-between gap-2 px-3 py-2 rounded-lg bg-orange-500/5 border border-orange-500/20 text-sm",children:[(0,t.jsxs)("div",{className:"flex min-w-0 items-center gap-2",children:[(0,t.jsx)("span",{className:"font-mono text-xs text-orange-400 shrink-0",children:e.ip}),(0,t.jsxs)("span",{className:"text-xs text-text-muted truncate",children:["— ",e.reason]})]}),(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)("span",{className:"text-xs text-text-muted tabular-nums",children:h("minLeft",{min:Math.ceil(e.remainingMs/6e4)})}),(0,t.jsx)("button",{onClick:()=>g({removeBan:e.ip}),className:"text-text-muted hover:text-orange-400",children:(0,t.jsx)("span",{className:"material-symbols-outlined text-[16px]",children:"delete"})})]})]},e.ip))})]})]})]})}function g(){let[e,a]=(0,s.useState)(null),[r,l]=(0,s.useState)(!0),c=(0,i.useTranslations)("settings");(0,s.useEffect)(()=>{let e=!1;return async function(){let t=sessionStorage.getItem("omniroute_login_time"),s=Date.now(),r=c("unknown");if(t){let e=s-parseInt(t,10),a=Math.floor(e/36e5),l=Math.floor(e%36e5/6e4);r=a>0?`${a}h ${l}m`:`${l}m`}let i=!1;try{let e=await fetch("/api/auth/status",{method:"GET",cache:"no-store"});if(e.ok){let t=await e.json();i=!0===t.authenticated}}catch{}e||(a({authenticated:i,loginTime:t?new Date(parseInt(t,10)).toLocaleString():null,sessionAge:r,ipAddress:"—",userAgent:navigator.userAgent.split(" ").slice(-2).join(" ")||c("unknown")}),l(!1))}(),()=>{e=!0}},[]);let o=async()=>{try{await fetch("/api/auth/logout",{method:"POST"}),sessionStorage.removeItem("omniroute_login_time"),window.location.href="/"}catch{window.location.href="/"}};return r?(0,t.jsx)(n.Card,{children:(0,t.jsx)("div",{className:"animate-pulse h-32 bg-black/5 dark:bg-white/5 rounded-lg"})}):(0,t.jsxs)(n.Card,{children:[(0,t.jsxs)("div",{className:"flex items-center gap-3 mb-4",children:[(0,t.jsx)("div",{className:"p-2 rounded-lg bg-blue-500/10 text-blue-500",children:(0,t.jsx)("span",{className:"material-symbols-outlined text-[20px]","aria-hidden":"true",children:"person"})}),(0,t.jsx)("h3",{className:"text-lg font-semibold",children:c("session")})]}),(0,t.jsxs)("div",{className:"flex flex-col gap-3",role:"list","aria-label":c("sessionDetailsAria"),children:[(0,t.jsxs)("div",{className:"flex justify-between items-center text-sm",role:"listitem",children:[(0,t.jsx)("span",{className:"text-text-muted",children:c("status")}),(0,t.jsxs)("span",{className:"flex items-center gap-1.5",children:[(0,t.jsx)("span",{className:`w-2 h-2 rounded-full ${e?.authenticated?"bg-green-500":"bg-yellow-500"}`,"aria-hidden":"true"}),e?.authenticated?c("authenticated"):c("guest")]})]}),e?.loginTime&&(0,t.jsxs)("div",{className:"flex justify-between items-center text-sm",role:"listitem",children:[(0,t.jsx)("span",{className:"text-text-muted",children:c("loginTime")}),(0,t.jsx)("span",{className:"font-mono text-xs",children:e.loginTime})]}),(0,t.jsxs)("div",{className:"flex justify-between items-center text-sm",role:"listitem",children:[(0,t.jsx)("span",{className:"text-text-muted",children:c("sessionAge")}),(0,t.jsx)("span",{className:"font-mono text-xs",children:e?.sessionAge})]}),(0,t.jsxs)("div",{className:"flex justify-between items-center text-sm",role:"listitem",children:[(0,t.jsx)("span",{className:"text-text-muted",children:c("browser")}),(0,t.jsx)("span",{className:"font-mono text-xs truncate max-w-[200px]",children:e?.userAgent})]})]}),(0,t.jsxs)("div",{className:"flex gap-3 mt-4 pt-4 border-t border-border/50",children:[(0,t.jsx)(d.Button,{variant:"secondary",onClick:()=>{confirm(c("clearLocalDataConfirm"))&&(localStorage.clear(),sessionStorage.clear(),window.location.reload())},children:c("clearLocalData")}),e?.authenticated&&(0,t.jsx)(d.Button,{variant:"danger",onClick:o,children:c("logout")})]})]})}function f(){let[e,a]=(0,s.useState)({requireLogin:!1,hasPassword:!1}),[r,l]=(0,s.useState)(!0),[c,o]=(0,s.useState)({current:"",new:"",confirm:""}),[m,p]=(0,s.useState)({type:"",message:""}),[f,j]=(0,s.useState)(!1),y=(0,i.useTranslations)("settings");(0,s.useEffect)(()=>{fetch("/api/settings").then(e=>e.json()).then(e=>{a(e),l(!1)}).catch(()=>l(!1))},[]);let v=async e=>{try{(await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({requireLogin:e})})).ok&&a(t=>({...t,requireLogin:e}))}catch(e){console.error("Failed to update require login:",e)}},N=async(e,t)=>{try{(await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({[e]:t})})).ok&&a(s=>({...s,[e]:t}))}catch(t){console.error(`Failed to update ${e}:`,t)}},k=async e=>{if(e.preventDefault(),c.new!==c.confirm)return void p({type:"error",message:y("passwordsNoMatch")});j(!0),p({type:"",message:""});try{let e=await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({currentPassword:c.current,newPassword:c.new})}),t=await e.json();e.ok?(p({type:"success",message:y("passwordUpdated")}),o({current:"",new:"",confirm:""})):p({type:"error",message:t.error||y("failedUpdatePassword")})}catch{p({type:"error",message:y("errorOccurred")})}finally{j(!1)}},w=e.blockedProviders||[];return(0,t.jsxs)("div",{className:"flex flex-col gap-6",children:[(0,t.jsxs)(n.Card,{children:[(0,t.jsxs)("div",{className:"flex items-center gap-3 mb-4",children:[(0,t.jsx)("div",{className:"p-2 rounded-lg bg-primary/10 text-primary",children:(0,t.jsx)("span",{className:"material-symbols-outlined text-[20px]","aria-hidden":"true",children:"shield"})}),(0,t.jsx)("h3",{className:"text-lg font-semibold",children:y("security")})]}),(0,t.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"font-medium",children:y("requireLogin")}),(0,t.jsx)("p",{className:"text-sm text-text-muted",children:y("requireLoginDesc")})]}),(0,t.jsx)(u.Toggle,{checked:!0===e.requireLogin,onChange:()=>v(!e.requireLogin),disabled:r})]}),!0===e.requireLogin&&(0,t.jsxs)("form",{onSubmit:k,className:"flex flex-col gap-4 pt-4 border-t border-border/50",children:[e.hasPassword&&(0,t.jsx)(x.Input,{label:y("currentPassword"),type:"password",placeholder:y("enterCurrentPassword"),value:c.current,onChange:e=>o({...c,current:e.target.value}),required:!0}),(0,t.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[(0,t.jsx)(x.Input,{label:y("newPassword"),type:"password",placeholder:y("enterNewPassword"),value:c.new,onChange:e=>o({...c,new:e.target.value}),required:!0}),(0,t.jsx)(x.Input,{label:y("confirmPassword"),type:"password",placeholder:y("confirmPasswordPlaceholder"),value:c.confirm,onChange:e=>o({...c,confirm:e.target.value}),required:!0})]}),m.message&&(0,t.jsx)("p",{className:`text-sm ${"error"===m.type?"text-red-500":"text-green-500"}`,children:m.message}),(0,t.jsx)("div",{className:"pt-2",children:(0,t.jsx)(d.Button,{type:"submit",variant:"primary",loading:f,children:e.hasPassword?y("updatePassword"):y("setPassword")})})]})]})]}),(0,t.jsxs)(n.Card,{children:[(0,t.jsxs)("div",{className:"flex items-center gap-3 mb-4",children:[(0,t.jsx)("div",{className:"p-2 rounded-lg bg-amber-500/10 text-amber-600 dark:text-amber-400",children:(0,t.jsx)("span",{className:"material-symbols-outlined text-[20px]","aria-hidden":"true",children:"api"})}),(0,t.jsx)("h3",{className:"text-lg font-semibold",children:y("apiEndpointProtection")})]}),(0,t.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"font-medium",children:y("requireAuthModels")}),(0,t.jsx)("p",{className:"text-sm text-text-muted",children:y("requireAuthModelsDesc")})]}),(0,t.jsx)(u.Toggle,{checked:!0===e.requireAuthForModels,onChange:()=>N("requireAuthForModels",!e.requireAuthForModels),disabled:r})]}),(0,t.jsxs)("div",{className:"pt-4 border-t border-border/50",children:[(0,t.jsxs)("div",{className:"mb-3",children:[(0,t.jsx)("p",{className:"font-medium",children:y("blockedProviders")}),(0,t.jsx)("p",{className:"text-sm text-text-muted",children:y("blockedProvidersDesc")})]}),(0,t.jsx)("div",{className:"flex flex-wrap gap-2",children:Object.values(h.AI_PROVIDERS).map(s=>{let a=w.includes(s.id);return(0,t.jsxs)("button",{onClick:()=>{var t;let a;return t=s.id,void N("blockedProviders",(a=e.blockedProviders||[]).includes(t)?a.filter(e=>e!==t):[...a,t])},disabled:r,className:`inline-flex items-center gap-1.5 px-2.5 py-1.5 rounded-lg text-xs font-medium transition-all border ${a?"bg-red-500/10 border-red-500/30 text-red-600 dark:text-red-400":"bg-black/[0.02] dark:bg-white/[0.02] border-transparent text-text-muted hover:bg-black/[0.05] dark:hover:bg-white/[0.05]"}`,title:a?y("unblockProviderTitle",{provider:s.name}):y("blockProviderTitle",{provider:s.name}),children:[(0,t.jsx)("span",{className:"material-symbols-outlined text-[14px]",style:{color:a?void 0:s.color},children:a?"block":s.icon}),s.name,a&&(0,t.jsx)("span",{className:"material-symbols-outlined text-[12px] text-red-500",children:"close"})]},s.id)})}),w.length>0&&(0,t.jsxs)("p",{className:"text-xs text-amber-600 dark:text-amber-400 mt-2 flex items-center gap-1",children:[(0,t.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"warning"}),y("providersBlocked",{count:w.length})]})]})]})]}),(0,t.jsx)(g,{}),(0,t.jsx)(b,{})]})}var j=e.i(11131),y=e.i(627949);let v=["#6366f1","#22c55e","#f59e0b","#ef4444","#8b5cf6","#06b6d4","#ec4899","#14b8a6"];function N(){let[e,a]=(0,s.useState)({}),[r,l]=(0,s.useState)(!0),[c,o]=(0,s.useState)(!1),[m,u]=(0,s.useState)(""),[h,p]=(0,s.useState)(""),[b,g]=(0,s.useState)(!1),f=(0,y.useNotificationStore)(),N=(0,i.useTranslations)("settings"),k=(0,i.useTranslations)("common"),w=(0,s.useCallback)(async()=>{try{let e=await fetch("/api/fallback/chains");if(e.ok){let t=await e.json();a(t.chains||t||{})}}catch{}finally{l(!1)}},[]);(0,s.useEffect)(()=>{w()},[w]);let C=async()=>{if(!m.trim()||!h.trim())return void f.warning(N("fillModelAndProviders"));let e=h.split(",").map(e=>e.trim()).filter(Boolean).map((e,t)=>({provider:e,priority:t+1,enabled:!0}));if(0===e.length)return void f.warning(N("addAtLeastOneProvider"));g(!0);try{(await fetch("/api/fallback/chains",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({model:m.trim(),chain:e})})).ok?(f.success(N("chainCreated",{model:m.trim()})),u(""),p(""),o(!1),await w()):f.error(N("failedCreateChain"))}catch{f.error(N("failedCreateChain"))}finally{g(!1)}},S=async e=>{if(confirm(N("deleteChainConfirm",{model:e})))try{(await fetch("/api/fallback/chains",{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({model:e})})).ok?(f.success(N("chainDeleted",{model:e})),await w()):f.error(N("failedDeleteChain"))}catch{f.error(N("failedDeleteChain"))}};if(r)return(0,t.jsx)(n.Card,{className:"p-6 mt-6",children:(0,t.jsxs)("div",{className:"flex items-center gap-2 text-text-muted animate-pulse",children:[(0,t.jsx)("span",{className:"material-symbols-outlined text-[20px]",children:"timeline"}),N("loadingFallbackChains")]})});let T=Object.entries(e);return(0,t.jsxs)(n.Card,{className:"mt-6",children:[(0,t.jsxs)("div",{className:"flex items-center gap-3 mb-4 p-6 pb-0",children:[(0,t.jsx)("div",{className:"p-2 rounded-lg bg-cyan-500/10 text-cyan-500",children:(0,t.jsx)("span",{className:"material-symbols-outlined text-[20px]",children:"timeline"})}),(0,t.jsxs)("div",{className:"flex-1",children:[(0,t.jsx)("h3",{className:"text-lg font-semibold",children:N("fallbackChainsTitle")}),(0,t.jsx)("p",{className:"text-sm text-text-muted",children:N("fallbackChainsDesc")})]}),(0,t.jsx)(d.Button,{size:"sm",variant:"primary",onClick:()=>o(!c),children:c?k("cancel"):N("addChain")})]}),c&&(0,t.jsxs)("div",{className:"mx-6 p-4 rounded-lg border border-border/30 bg-surface/20 mb-4",children:[(0,t.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3 mb-3",children:[(0,t.jsx)(x.Input,{label:N("modelName"),placeholder:N("modelNamePlaceholder"),value:m,onChange:e=>u(e.target.value)}),(0,t.jsx)(x.Input,{label:N("providersCommaSeparated"),placeholder:N("providersCommaSeparatedPlaceholder"),value:h,onChange:e=>p(e.target.value)})]}),(0,t.jsx)(d.Button,{variant:"primary",size:"sm",onClick:C,loading:b,children:N("createChain")})]}),(0,t.jsx)("div",{className:"px-6 pb-6",children:0===T.length?(0,t.jsx)(j.EmptyState,{icon:"timeline",title:N("noFallbackChains"),description:N("noFallbackChainsDesc")}):(0,t.jsx)("div",{className:"flex flex-col gap-2",children:T.map(([e,s])=>(0,t.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 rounded-lg border border-border/20 bg-surface/20 hover:bg-surface/40 transition-colors",children:[(0,t.jsxs)("div",{className:"flex items-center gap-3 flex-1 min-w-0",children:[(0,t.jsx)("span",{className:"font-mono text-sm text-text-main truncate max-w-[200px]",children:e}),(0,t.jsx)("span",{className:"material-symbols-outlined text-[14px] text-text-muted",children:"arrow_forward"}),(0,t.jsx)("div",{className:"flex gap-1.5 flex-wrap",children:(Array.isArray(s)?s:[]).map((e,s)=>(0,t.jsxs)("span",{className:"text-xs px-2 py-0.5 rounded-full font-medium",style:{backgroundColor:`${v[s%v.length]}20`,color:v[s%v.length],border:`1px solid ${v[s%v.length]}40`},children:[s+1,". ",e.provider]},`${e.provider}-${s}`))})]}),(0,t.jsx)("button",{onClick:()=>S(e),className:"text-text-muted hover:text-red-400 transition-colors ml-2",title:N("deleteChain"),children:(0,t.jsx)("span",{className:"material-symbols-outlined text-[16px]",children:"close"})})]},e))})})]})}var k=e.i(516495);let w=k.ROUTING_STRATEGIES.filter(e=>k.SETTINGS_FALLBACK_STRATEGY_VALUES.includes(e.value)).map(e=>({value:e.value,labelKey:e.labelKey,descKey:e.settingsDescKey,icon:e.icon}));function C(){let[e,a]=(0,s.useState)({fallbackStrategy:"fill-first"}),[r,l]=(0,s.useState)(!0),[c,o]=(0,s.useState)([]),[m,u]=(0,s.useState)(""),[h,p]=(0,s.useState)(""),b=(0,i.useTranslations)("settings"),g=w.reduce((e,t)=>(e[t.value]=t.descKey,e),{});(0,s.useEffect)(()=>{fetch("/api/settings").then(e=>e.json()).then(e=>{a(e),o(e.wildcardAliases||[]),l(!1)}).catch(()=>l(!1))},[]);let f=async e=>{try{(await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})).ok&&a(t=>({...t,...e}))}catch(e){console.error("Failed to update settings:",e)}},j=async()=>{if(!m.trim()||!h.trim())return;let e=[...c,{pattern:m.trim(),target:h.trim()}];await f({wildcardAliases:e}),o(e),u(""),p("")},y=async e=>{let t=c.filter((t,s)=>s!==e);await f({wildcardAliases:t}),o(t)};return(0,t.jsxs)("div",{className:"flex flex-col gap-6",children:[(0,t.jsxs)(n.Card,{children:[(0,t.jsxs)("div",{className:"flex items-center gap-3 mb-4",children:[(0,t.jsx)("div",{className:"p-2 rounded-lg bg-blue-500/10 text-blue-500",children:(0,t.jsx)("span",{className:"material-symbols-outlined text-[20px]","aria-hidden":"true",children:"route"})}),(0,t.jsx)("h3",{className:"text-lg font-semibold",children:b("routingStrategy")})]}),(0,t.jsxs)("div",{className:"mb-4 rounded-lg border border-blue-500/20 bg-blue-500/5 p-3",children:[(0,t.jsx)("p",{className:"text-xs font-medium text-blue-700 dark:text-blue-300",children:b("routingAdvancedGuideTitle")}),(0,t.jsx)("p",{className:"text-xs text-text-muted mt-1",children:b("routingAdvancedGuideHint1")}),(0,t.jsx)("p",{className:"text-xs text-text-muted",children:b("routingAdvancedGuideHint2")})]}),(0,t.jsx)("div",{className:"grid grid-cols-1 sm:grid-cols-2 xl:grid-cols-3 gap-2 mb-4",style:{gridAutoRows:"1fr"},children:w.map(s=>(0,t.jsxs)("button",{onClick:()=>f({fallbackStrategy:s.value}),disabled:r,className:`flex flex-col items-center gap-2 p-4 rounded-lg border text-center transition-all ${e.fallbackStrategy===s.value?"border-blue-500/50 bg-blue-500/5 ring-1 ring-blue-500/20":"border-border/50 hover:border-border hover:bg-surface/30"}`,children:[(0,t.jsx)("span",{className:`material-symbols-outlined text-[24px] ${e.fallbackStrategy===s.value?"text-blue-400":"text-text-muted"}`,children:s.icon}),(0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:`text-sm font-medium ${e.fallbackStrategy===s.value?"text-blue-400":""}`,children:b(s.labelKey)}),(0,t.jsx)("p",{className:"text-xs text-text-muted mt-0.5",children:b(s.descKey)})]})]},s.value))}),"round-robin"===e.fallbackStrategy&&(0,t.jsxs)("div",{className:"flex items-center justify-between pt-3 border-t border-border/30",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"text-sm font-medium",children:b("stickyLimit")}),(0,t.jsx)("p",{className:"text-xs text-text-muted",children:b("stickyLimitDesc")})]}),(0,t.jsx)(x.Input,{type:"number",min:"1",max:"10",value:e.stickyRoundRobinLimit||3,onChange:e=>f({stickyRoundRobinLimit:parseInt(e.target.value)}),disabled:r,className:"w-20 text-center"})]}),(0,t.jsx)("p",{className:"text-xs text-text-muted italic pt-3 border-t border-border/30 mt-3",children:b(g[e.fallbackStrategy]||"fillFirstDesc")})]}),(0,t.jsxs)(n.Card,{children:[(0,t.jsxs)("div",{className:"flex items-center gap-3 mb-4",children:[(0,t.jsx)("div",{className:"p-2 rounded-lg bg-purple-500/10 text-purple-500",children:(0,t.jsx)("span",{className:"material-symbols-outlined text-[20px]","aria-hidden":"true",children:"alt_route"})}),(0,t.jsxs)("div",{children:[(0,t.jsx)("h3",{className:"text-lg font-semibold",children:b("modelAliases")}),(0,t.jsx)("p",{className:"text-sm text-text-muted",children:b("modelAliasesDesc")})]})]}),c.length>0&&(0,t.jsx)("div",{className:"flex flex-col gap-1.5 mb-4",children:c.map((e,s)=>(0,t.jsxs)("div",{className:"flex items-center justify-between gap-2 px-3 py-2 rounded-lg bg-surface/30 border border-border/20",children:[(0,t.jsxs)("div",{className:"flex min-w-0 items-center gap-2 text-sm",children:[(0,t.jsx)("span",{className:"font-mono text-purple-400 break-all",children:e.pattern}),(0,t.jsx)("span",{className:"material-symbols-outlined text-[14px] text-text-muted",children:"arrow_forward"}),(0,t.jsx)("span",{className:"font-mono text-text-main break-all",children:e.target})]}),(0,t.jsx)("button",{onClick:()=>y(s),className:"shrink-0 text-text-muted hover:text-red-400 transition-colors",children:(0,t.jsx)("span",{className:"material-symbols-outlined text-[16px]",children:"close"})})]},s))}),(0,t.jsxs)("div",{className:"flex flex-col sm:flex-row gap-2 items-stretch sm:items-end",children:[(0,t.jsx)("div",{className:"flex-1",children:(0,t.jsx)(x.Input,{label:b("pattern"),placeholder:b("aliasPatternPlaceholder"),value:m,onChange:e=>u(e.target.value)})}),(0,t.jsx)("div",{className:"flex-1",children:(0,t.jsx)(x.Input,{label:b("targetModel"),placeholder:b("aliasTargetPlaceholder"),value:h,onChange:e=>p(e.target.value)})}),(0,t.jsx)(d.Button,{size:"sm",variant:"primary",onClick:j,className:"mb-[2px] sm:w-auto w-full",children:b("add")})]})]}),(0,t.jsx)(N,{})]})}function S(){let[e,a]=(0,s.useState)({strategy:"priority",maxRetries:1,retryDelayMs:2e3,timeoutMs:12e4,healthCheckEnabled:!0,healthCheckTimeoutMs:3e3,maxComboDepth:3,trackMetrics:!0}),[l,c]=(0,s.useState)({}),[o,m]=(0,s.useState)(""),[h,p]=(0,s.useState)(!1),b=(0,i.useTranslations)("settings"),g=(0,i.useTranslations)("common"),f=k.ROUTING_STRATEGIES.map(e=>({value:e.value,label:b(e.labelKey),icon:e.icon})),j=[{key:"maxRetries",label:b("maxRetriesLabel"),min:0,max:5},{key:"retryDelayMs",label:b("retryDelayLabel"),min:500,max:1e4,step:500},{key:"timeoutMs",label:b("timeoutLabel"),min:5e3,max:3e5,step:5e3},{key:"maxComboDepth",label:b("maxNestingDepth"),min:1,max:10}];(0,s.useEffect)(()=>{fetch("/api/settings/combo-defaults").then(e=>e.json()).then(e=>{e.comboDefaults&&a(e.comboDefaults),e.providerOverrides&&c(e.providerOverrides)}).catch(e=>console.error("Failed to fetch combo defaults:",e))},[]);let y=async()=>{p(!0);try{await fetch("/api/settings/combo-defaults",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({comboDefaults:e,providerOverrides:l})})}catch(e){console.error("Failed to save combo defaults:",e)}finally{p(!1)}},v=()=>{let e=o.trim().toLowerCase();e&&!l[e]&&(c(t=>({...t,[e]:{maxRetries:1,timeoutMs:12e4}})),m(""))};return(0,t.jsxs)(n.Card,{children:[(0,t.jsxs)("div",{className:"flex items-center gap-3 mb-4",children:[(0,t.jsx)("div",{className:"p-2 rounded-lg bg-amber-500/10 text-amber-500",children:(0,t.jsx)("span",{className:"material-symbols-outlined text-[20px]","aria-hidden":"true",children:"tune"})}),(0,t.jsx)("h3",{className:"text-lg font-semibold",children:b("comboDefaultsTitle")}),(0,t.jsx)("span",{className:"text-xs text-text-muted ml-auto",children:b("globalComboConfig")})]}),(0,t.jsxs)("div",{className:"mb-4 rounded-lg border border-amber-500/20 bg-amber-500/5 p-3",children:[(0,t.jsx)("p",{className:"text-xs font-medium text-amber-700 dark:text-amber-300",children:b("comboDefaultsGuideTitle")}),(0,t.jsx)("p",{className:"text-xs text-text-muted mt-1",children:b("comboDefaultsGuideHint1")}),(0,t.jsx)("p",{className:"text-xs text-text-muted",children:b("comboDefaultsGuideHint2")})]}),(0,t.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"font-medium text-sm",children:b("defaultStrategy")}),(0,t.jsx)("p",{className:"text-xs text-text-muted",children:b("defaultStrategyDesc")})]}),(0,t.jsx)("div",{role:"tablist","aria-label":b("comboStrategyAria"),className:"grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-5 gap-1 p-0.5 rounded-md bg-black/5 dark:bg-white/5",children:f.map(s=>(0,t.jsxs)("button",{role:"tab","aria-selected":e.strategy===s.value,onClick:()=>a(e=>({...e,strategy:s.value})),className:(0,r.cn)("px-2 py-1 rounded text-xs font-medium transition-all flex items-center justify-center gap-0.5",e.strategy===s.value?"bg-white dark:bg-white/10 text-text-main shadow-sm":"text-text-muted hover:text-text-main"),children:[(0,t.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:s.icon}),s.label]},s.value))})]}),(0,t.jsx)("div",{className:"grid grid-cols-2 gap-3 pt-3 border-t border-border/50",children:j.map(({key:s,label:r,min:l,max:i,step:n})=>(0,t.jsx)(x.Input,{label:r,type:"number",min:l,max:i,step:n||1,value:e[s]??"",onChange:e=>a(t=>({...t,[s]:parseInt(e.target.value)||0})),className:"text-sm"},s))}),"round-robin"===e.strategy&&(0,t.jsxs)("div",{className:"grid grid-cols-2 gap-3 pt-3 border-t border-border/50",children:[(0,t.jsx)(x.Input,{label:b("concurrencyPerModel"),type:"number",min:1,max:20,value:e.concurrencyPerModel??"",placeholder:"3",onChange:e=>a(t=>({...t,concurrencyPerModel:parseInt(e.target.value)||0})),className:"text-sm"}),(0,t.jsx)(x.Input,{label:b("queueTimeout"),type:"number",min:1e3,max:12e4,step:1e3,value:e.queueTimeoutMs??"",placeholder:"30000",onChange:e=>a(t=>({...t,queueTimeoutMs:parseInt(e.target.value)||0})),className:"text-sm"})]}),(0,t.jsxs)("div",{className:"flex flex-col gap-3 pt-3 border-t border-border/50",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"font-medium text-sm",children:b("healthCheck")}),(0,t.jsx)("p",{className:"text-xs text-text-muted",children:b("healthCheckDesc")})]}),(0,t.jsx)(u.Toggle,{checked:!1!==e.healthCheckEnabled,onChange:()=>a(e=>({...e,healthCheckEnabled:!e.healthCheckEnabled}))})]}),(0,t.jsxs)("div",{className:"flex items-center justify-between",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"font-medium text-sm",children:b("trackMetrics")}),(0,t.jsx)("p",{className:"text-xs text-text-muted",children:b("trackMetricsDesc")})]}),(0,t.jsx)(u.Toggle,{checked:!1!==e.trackMetrics,onChange:()=>a(e=>({...e,trackMetrics:!e.trackMetrics}))})]})]}),(0,t.jsxs)("div",{className:"pt-3 border-t border-border/50",children:[(0,t.jsx)("p",{className:"font-medium text-sm mb-2",children:b("providerOverrides")}),(0,t.jsx)("p",{className:"text-xs text-text-muted mb-3",children:b("providerOverridesDesc")}),Object.entries(l).map(([e,s])=>(0,t.jsxs)("div",{className:"flex items-center gap-2 mb-2 p-2 rounded-lg bg-black/[0.02] dark:bg-white/[0.02]",children:[(0,t.jsx)("span",{className:"text-xs font-mono font-medium min-w-[80px]",children:e}),(0,t.jsx)(x.Input,{type:"number",min:"0",max:"5",value:s.maxRetries??1,onChange:t=>c(s=>({...s,[e]:{...s[e],maxRetries:parseInt(t.target.value)||0}})),className:"text-xs w-16","aria-label":b("providerMaxRetriesAria",{provider:e})}),(0,t.jsx)("span",{className:"text-[10px] text-text-muted",children:b("retries")}),(0,t.jsx)(x.Input,{type:"number",min:"5000",max:"300000",step:"5000",value:s.timeoutMs??12e4,onChange:t=>c(s=>({...s,[e]:{...s[e],timeoutMs:parseInt(t.target.value)||12e4}})),className:"text-xs w-24","aria-label":b("providerTimeoutAria",{provider:e})}),(0,t.jsx)("span",{className:"text-[10px] text-text-muted",children:b("ms")}),(0,t.jsx)("button",{onClick:()=>{c(t=>{let s={...t};return delete s[e],s})},className:"ml-auto text-red-400 hover:text-red-500 transition-colors","aria-label":b("removeProviderOverrideAria",{provider:e}),children:(0,t.jsx)("span",{className:"material-symbols-outlined text-[16px]","aria-hidden":"true",children:"close"})})]},e)),(0,t.jsxs)("div",{className:"flex items-center gap-2 mt-2",children:[(0,t.jsx)(x.Input,{type:"text",placeholder:b("newProviderNamePlaceholder"),value:o,onChange:e=>m(e.target.value),onKeyDown:e=>"Enter"===e.key&&v(),className:"text-xs flex-1","aria-label":b("newProviderNameAria")}),(0,t.jsx)(d.Button,{variant:"outline",size:"sm",onClick:v,disabled:!o.trim(),children:g("add")})]})]}),(0,t.jsx)("div",{className:"pt-3 border-t border-border/50",children:(0,t.jsx)(d.Button,{variant:"primary",size:"sm",onClick:y,loading:h,children:b("saveComboDefaults")})})]})]})}var T=e.i(105370),P=e.i(87855);let A={id:"",name:"",type:"http",host:"",port:"8080",username:"",password:"",region:"",notes:"",status:"active"};function B(){let[e,a]=(0,s.useState)([]),[r,l]=(0,s.useState)(!1),[i,c]=(0,s.useState)(null),[o,m]=(0,s.useState)(!1),[x,u]=(0,s.useState)(!1),[h,p]=(0,s.useState)(A),[b,g]=(0,s.useState)({}),[f,j]=(0,s.useState)({}),[y,v]=(0,s.useState)({}),[N,k]=(0,s.useState)(null),[w,C]=(0,s.useState)(!1),[S,T]=(0,s.useState)(!1),[B,D]=(0,s.useState)(!1),[E,O]=(0,s.useState)("provider"),[L,M]=(0,s.useState)(""),[I,F]=(0,s.useState)(""),_=(0,s.useMemo)(()=>h.id||"",[h.id]),R=(0,s.useCallback)(async()=>{try{let e=await fetch("/api/settings/proxies/health?hours=24"),t=await e.json().catch(()=>({}));if(!e.ok)return;let s=Array.isArray(t?.items)?t.items:[],a=Object.fromEntries(s.map(e=>[e.proxyId,e]));j(a)}catch{}},[]),$=(0,s.useCallback)(async e=>{if(e.length)try{let t=await Promise.all(e.map(e=>fetch(`/api/settings/proxies/assignments?proxyId=${encodeURIComponent(e)}`).then(e=>e.ok?e.json():null).then(t=>{let s=Array.isArray(t?.items)?t.items:[],a=new Set,r=s.filter(e=>{let t=`${e.scope}:${e.scopeId??""}`;return!a.has(t)&&(a.add(t),!0)});return[e,{count:r.length,assignments:r}]}).catch(()=>[e,{count:0,assignments:[]}])));g(Object.fromEntries(t))}catch{}},[]),z=(0,s.useCallback)(async()=>{l(!0),c(null);try{let e=await fetch("/api/settings/proxies"),t=await e.json().catch(()=>({}));if(!e.ok){c(t?.error?.message||"Failed to load proxy registry"),a([]);return}let s=Array.isArray(t?.items)?t.items:[];a(s);let r=s.map(e=>e.id).filter(Boolean);R(),$(r)}catch(e){c(e?.message||"Failed to load proxy registry"),a([])}finally{l(!1)}},[R,$]);(0,s.useEffect)(()=>{z()},[z]),(0,s.useEffect)(()=>{e.length>0&&!I&&F(e[0].id)},[e,I]);let K=async e=>{if(!N){k(e.id),v(t=>({...t,[e.id]:null}));try{let t=await fetch("/api/settings/proxy/test",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({proxyId:e.id,proxy:{type:e.type||"http",host:e.host,port:String(e.port||8080)}})}),s=await t.json().catch(()=>({}));if(!t.ok)return void v(t=>({...t,[e.id]:{success:!1,error:s?.error?.message||"Test failed"}}));v(t=>({...t,[e.id]:{success:!0,...s}}))}catch(t){v(s=>({...s,[e.id]:{success:!1,error:t?.message}}))}finally{k(null)}}},H=async()=>{if(!h.name.trim()||!h.host.trim())return void c("Name and host are required");u(!0),c(null);let e=h.username.trim(),t=h.password.trim(),s={..._?{id:_}:{},name:h.name.trim(),type:h.type,host:h.host.trim(),port:Number(h.port||8080),region:h.region.trim()||null,notes:h.notes.trim()||null,status:h.status};(!_||e.length>0)&&(s.username=e),(!_||t.length>0)&&(s.password=t);try{let e=await fetch("/api/settings/proxies",{method:_?"PATCH":"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)}),t=await e.json().catch(()=>({}));if(!e.ok)return void c(t?.error?.message||"Failed to save proxy");m(!1),p(A),await z()}catch(e){c(e?.message||"Failed to save proxy")}finally{u(!1)}},q=async e=>{try{let t=await fetch(`/api/settings/proxies?id=${encodeURIComponent(e)}`,{method:"DELETE"});if(t.ok)return void await z();let s=await t.json().catch(()=>({}));if(409===t.status){if(!window.confirm("This proxy is still assigned. Force delete and remove all assignments?"))return;let t=await fetch(`/api/settings/proxies?id=${encodeURIComponent(e)}&force=1`,{method:"DELETE"});if(!t.ok){let e=await t.json().catch(()=>({}));c(e?.error?.message||"Failed to force delete proxy");return}await z();return}c(s?.error?.message||"Failed to delete proxy")}catch(e){c(e?.message||"Failed to delete proxy")}},U=async()=>{C(!0),c(null);try{let e=await fetch("/api/settings/proxies/migrate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({force:!1})}),t=await e.json().catch(()=>({}));if(!e.ok)return void c(t?.error?.message||"Failed to migrate legacy proxy config");await z()}catch(e){c(e?.message||"Failed to migrate legacy proxy config")}finally{C(!1)}},J=async()=>{D(!0),c(null);try{let e="global"===E?[]:L.split(/[\n,]/g).map(e=>e.trim()).filter(Boolean),t=await fetch("/api/settings/proxies/bulk-assign",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({scope:E,scopeIds:e,proxyId:I||null})}),s=await t.json().catch(()=>({}));if(!t.ok)return void c(s?.error?.message||"Failed to run bulk assignment");T(!1),M(""),await z()}catch(e){c(e?.message||"Failed to run bulk assignment")}finally{D(!1)}};return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)(n.Card,{className:"p-6",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between gap-3 mb-4",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("h3",{className:"text-lg font-semibold",children:"Proxy Registry"}),(0,t.jsx)("p",{className:"text-sm text-text-muted",children:"Store reusable proxies and track assignments."})]}),(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)(d.Button,{size:"sm",variant:"secondary",icon:"upgrade",onClick:U,loading:w,"data-testid":"proxy-registry-import-legacy",children:"Import Legacy"}),(0,t.jsx)(d.Button,{size:"sm",variant:"secondary",icon:"account_tree",onClick:()=>T(!0),"data-testid":"proxy-registry-open-bulk",children:"Bulk Assign"}),(0,t.jsx)(d.Button,{size:"sm",icon:"add",onClick:()=>{p(A),m(!0)},"data-testid":"proxy-registry-open-create",children:"Add Proxy"})]})]}),i&&(0,t.jsx)("div",{className:"mb-3 px-3 py-2 rounded border border-red-500/30 bg-red-500/10 text-sm text-red-400",children:i}),r?(0,t.jsx)("div",{className:"text-sm text-text-muted",children:"Loading proxies..."}):0===e.length?(0,t.jsx)("div",{className:"text-sm text-text-muted",children:"No saved proxies yet."}):(0,t.jsx)("div",{className:"overflow-x-auto",children:(0,t.jsxs)("table",{className:"w-full text-sm",children:[(0,t.jsx)("thead",{children:(0,t.jsxs)("tr",{className:"text-left text-text-muted border-b border-border",children:[(0,t.jsx)("th",{className:"py-2 pr-3",children:"Name"}),(0,t.jsx)("th",{className:"py-2 pr-3",children:"Endpoint"}),(0,t.jsx)("th",{className:"py-2 pr-3",children:"Status"}),(0,t.jsx)("th",{className:"py-2 pr-3",children:"Health (24h)"}),(0,t.jsx)("th",{className:"py-2 pr-3",children:"Usage"}),(0,t.jsx)("th",{className:"py-2",children:"Actions"})]})}),(0,t.jsx)("tbody",{children:e.map(e=>{b[e.id];let s=f[e.id];return(0,t.jsxs)("tr",{className:"border-b border-border/60",children:[(0,t.jsxs)("td",{className:"py-2 pr-3",children:[(0,t.jsx)("div",{className:"font-medium text-text-main",children:e.name}),e.region&&(0,t.jsx)("div",{className:"text-xs text-text-muted",children:e.region})]}),(0,t.jsxs)("td",{className:"py-2 pr-3 font-mono text-xs text-text-muted",children:[e.type,"://",e.host,":",e.port]}),(0,t.jsx)("td",{className:"py-2 pr-3",children:(0,t.jsx)("span",{className:"text-xs px-2 py-1 rounded border border-border bg-bg-subtle",children:e.status||"active"})}),(0,t.jsx)("td",{className:"py-2 pr-3 text-xs text-text-muted",children:(0,t.jsx)("div",{className:"flex flex-col gap-0.5",children:y[e.id]?y[e.id].success?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("span",{className:"text-emerald-400",children:["✓ ",y[e.id].publicIp]}),y[e.id].latencyMs&&(0,t.jsxs)("span",{children:[y[e.id].latencyMs,"ms"]})]}):(0,t.jsxs)("span",{className:"text-red-400",children:["✗ ",y[e.id].error||"failed"]}):s?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("span",{children:[s.successRate??0,"% success"]}),(0,t.jsxs)("span",{children:[s.avgLatencyMs??"-"," ms avg"]})]}):(0,t.jsx)("span",{children:"—"})})}),(0,t.jsx)("td",{className:"py-2 pr-3 text-xs text-text-muted",children:null!=b[e.id]?`${b[e.id].count} assignment(s)`:"—"}),(0,t.jsx)("td",{className:"py-2",children:(0,t.jsxs)("div",{className:"flex items-center gap-1",children:[(0,t.jsx)(d.Button,{size:"sm",variant:"ghost",icon:"speed",onClick:()=>void K(e),loading:N===e.id,children:"Test"}),(0,t.jsx)(d.Button,{size:"sm",variant:"ghost",icon:"edit",onClick:()=>{p({id:e.id,name:e.name||"",type:e.type||"http",host:e.host||"",port:String(e.port||8080),username:"",password:"",region:e.region||"",notes:e.notes||"",status:e.status||"active"}),m(!0)},children:"Edit"}),(0,t.jsx)(d.Button,{size:"sm",variant:"ghost",icon:"delete",onClick:()=>void q(e.id),className:"!text-red-400",children:"Delete"})]})})]},e.id)})})]})})]}),(0,t.jsx)(P.Modal,{isOpen:o,onClose:()=>{x||m(!1)},title:_?"Edit Proxy":"Create Proxy",maxWidth:"lg",children:(0,t.jsxs)("div",{className:"flex flex-col gap-3",children:[(0,t.jsxs)("div",{className:"grid grid-cols-2 gap-3",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{className:"text-xs text-text-muted mb-1 block",children:"Name"}),(0,t.jsx)("input",{"data-testid":"proxy-registry-name-input",className:"w-full px-3 py-2 rounded bg-bg-subtle border border-border",value:h.name,onChange:e=>p(t=>({...t,name:e.target.value}))})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{className:"text-xs text-text-muted mb-1 block",children:"Type"}),(0,t.jsxs)("select",{className:"w-full px-3 py-2 rounded bg-bg-subtle border border-border",value:h.type,onChange:e=>p(t=>({...t,type:e.target.value})),children:[(0,t.jsx)("option",{value:"http",children:"HTTP"}),(0,t.jsx)("option",{value:"https",children:"HTTPS"}),(0,t.jsx)("option",{value:"socks5",children:"SOCKS5"})]})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{className:"text-xs text-text-muted mb-1 block",children:"Host"}),(0,t.jsx)("input",{"data-testid":"proxy-registry-host-input",className:"w-full px-3 py-2 rounded bg-bg-subtle border border-border",value:h.host,onChange:e=>p(t=>({...t,host:e.target.value}))})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{className:"text-xs text-text-muted mb-1 block",children:"Port"}),(0,t.jsx)("input",{className:"w-full px-3 py-2 rounded bg-bg-subtle border border-border",value:h.port,onChange:e=>p(t=>({...t,port:e.target.value}))})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{className:"text-xs text-text-muted mb-1 block",children:"Username"}),(0,t.jsx)("input",{className:"w-full px-3 py-2 rounded bg-bg-subtle border border-border",value:h.username,placeholder:_?"Leave blank to keep current username":"",onChange:e=>p(t=>({...t,username:e.target.value}))})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{className:"text-xs text-text-muted mb-1 block",children:"Password"}),(0,t.jsx)("input",{type:"password",className:"w-full px-3 py-2 rounded bg-bg-subtle border border-border",value:h.password,placeholder:_?"Leave blank to keep current password":"",onChange:e=>p(t=>({...t,password:e.target.value}))})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{className:"text-xs text-text-muted mb-1 block",children:"Region"}),(0,t.jsx)("input",{className:"w-full px-3 py-2 rounded bg-bg-subtle border border-border",value:h.region,onChange:e=>p(t=>({...t,region:e.target.value}))})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{className:"text-xs text-text-muted mb-1 block",children:"Status"}),(0,t.jsxs)("select",{className:"w-full px-3 py-2 rounded bg-bg-subtle border border-border",value:h.status,onChange:e=>p(t=>({...t,status:e.target.value})),children:[(0,t.jsx)("option",{value:"active",children:"active"}),(0,t.jsx)("option",{value:"inactive",children:"inactive"})]})]})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{className:"text-xs text-text-muted mb-1 block",children:"Notes"}),(0,t.jsx)("textarea",{className:"w-full px-3 py-2 rounded bg-bg-subtle border border-border",value:h.notes,onChange:e=>p(t=>({...t,notes:e.target.value})),rows:3})]}),(0,t.jsxs)("div",{className:"flex items-center justify-end gap-2 pt-2 border-t border-border",children:[(0,t.jsx)(d.Button,{size:"sm",variant:"secondary",onClick:()=>m(!1),children:"Cancel"}),(0,t.jsx)(d.Button,{size:"sm",icon:"save",onClick:H,loading:x,children:"Save"})]})]})}),(0,t.jsx)(P.Modal,{isOpen:S,onClose:()=>{B||T(!1)},title:"Bulk Proxy Assignment",maxWidth:"lg",children:(0,t.jsxs)("div",{className:"flex flex-col gap-3",children:[(0,t.jsxs)("div",{className:"grid grid-cols-2 gap-3",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{className:"text-xs text-text-muted mb-1 block",children:"Scope"}),(0,t.jsxs)("select",{className:"w-full px-3 py-2 rounded bg-bg-subtle border border-border",value:E,onChange:e=>O(e.target.value),children:[(0,t.jsx)("option",{value:"global",children:"global"}),(0,t.jsx)("option",{value:"provider",children:"provider"}),(0,t.jsx)("option",{value:"account",children:"account"}),(0,t.jsx)("option",{value:"combo",children:"combo"})]})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{className:"text-xs text-text-muted mb-1 block",children:"Proxy"}),(0,t.jsxs)("select",{className:"w-full px-3 py-2 rounded bg-bg-subtle border border-border",value:I,onChange:e=>F(e.target.value),children:[(0,t.jsx)("option",{value:"",children:"(clear assignment)"}),e.map(e=>(0,t.jsxs)("option",{value:e.id,children:[e.name," (",e.type,"://",e.host,":",e.port,")"]},e.id))]})]})]}),"global"!==E&&(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{className:"text-xs text-text-muted mb-1 block",children:"Scope IDs (comma or newline)"}),(0,t.jsx)("textarea",{"data-testid":"proxy-registry-bulk-scopeids-input",className:"w-full px-3 py-2 rounded bg-bg-subtle border border-border",rows:5,value:L,onChange:e=>M(e.target.value),placeholder:"provider-openai,provider-anthropic"})]}),(0,t.jsxs)("div",{className:"flex items-center justify-end gap-2 pt-2 border-t border-border",children:[(0,t.jsx)(d.Button,{size:"sm",variant:"secondary",onClick:()=>T(!1),children:"Cancel"}),(0,t.jsx)(d.Button,{size:"sm",icon:"done_all",onClick:J,loading:B,"data-testid":"proxy-registry-bulk-apply",children:"Apply"})]})]})})]})}function D(){let[e,a]=(0,s.useState)(!1),[r,l]=(0,s.useState)(null),c=(0,s.useRef)(!0),o=(0,i.useTranslations)("settings"),m=(0,i.useTranslations)("common"),x=async()=>{try{let e=await fetch("/api/settings/proxy?level=global");if(e.ok){let t=await e.json();l(t.proxy||null)}}catch{}};return(0,s.useEffect)(()=>(c.current=!0,async function(){try{let e=await fetch("/api/settings/proxy?level=global");if(!c.current)return;if(e.ok){let t=await e.json();c.current&&l(t.proxy||null)}}catch{}}(),()=>{c.current=!1}),[]),(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("div",{className:"flex flex-col gap-6",children:[(0,t.jsx)(n.Card,{className:"p-0 overflow-hidden",children:(0,t.jsxs)("div",{className:"p-6",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2 mb-4",children:[(0,t.jsx)("span",{className:"material-symbols-outlined text-xl text-primary","aria-hidden":"true",children:"vpn_lock"}),(0,t.jsx)("h2",{className:"text-lg font-bold",children:o("globalProxy")})]}),(0,t.jsx)("p",{className:"text-sm text-text-muted mb-4",children:o("globalProxyDesc")}),(0,t.jsxs)("div",{className:"flex items-center gap-3",children:[r?(0,t.jsx)("div",{className:"flex items-center gap-2",children:(0,t.jsxs)("span",{className:"px-2.5 py-1 rounded text-xs font-bold uppercase bg-emerald-500/15 text-emerald-400 border border-emerald-500/30",children:[r.type,"://",r.host,":",r.port]})}):(0,t.jsx)("span",{className:"text-sm text-text-muted",children:o("noGlobalProxy")}),(0,t.jsx)(d.Button,{size:"sm",variant:r?"secondary":"primary",icon:"settings",onClick:()=>{x(),a(!0)},children:r?m("edit"):o("configure")})]})]})}),(0,t.jsx)(B,{})]}),(0,t.jsx)(T.ProxyConfigModal,{isOpen:e,onClose:()=>a(!1),level:"global",levelLabel:o("globalLabel"),onSaved:x})]})}var E=e.i(287531),O=e.i(764119);function L(){let{theme:e,setTheme:a,isDark:l}=(0,E.useTheme)(),{colorTheme:c,customColor:o,setColorTheme:m,setCustomColorTheme:x}=(0,O.default)(),h=(0,i.useTranslations)("settings"),[p,b]=(0,s.useState)({}),[g,f]=(0,s.useState)(!0),[j,y]=(0,s.useState)(o||"#3b82f6"),v=/^#([0-9a-fA-F]{6})$/.test(j.startsWith("#")?j:`#${j}`);(0,s.useEffect)(()=>O.default.subscribe(e=>{e.customColor&&e.customColor!==j&&y(e.customColor)}),[]);let N={light:h("themeLight"),dark:h("themeDark"),system:h("themeSystem")};(0,s.useEffect)(()=>{fetch("/api/settings").then(e=>{if(!e.ok)throw Error(`HTTP error ${e.status}`);return e.json()}).then(e=>{b(e),f(!1)}).catch(()=>f(!1))},[]);let k=async(e,t)=>{try{(await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({[e]:t})})).ok&&b(s=>({...s,[e]:t}))}catch(t){console.error(`Failed to update ${e}:`,t)}},w=[{id:"coral",color:O.COLOR_THEMES.coral,label:h("themeCoral")},{id:"blue",color:O.COLOR_THEMES.blue,label:h("themeBlue")},{id:"red",color:O.COLOR_THEMES.red,label:h("themeRed")},{id:"green",color:O.COLOR_THEMES.green,label:h("themeGreen")},{id:"violet",color:O.COLOR_THEMES.violet,label:h("themeViolet")},{id:"orange",color:O.COLOR_THEMES.orange,label:h("themeOrange")},{id:"cyan",color:O.COLOR_THEMES.cyan,label:h("themeCyan")}];return(0,t.jsxs)(n.Card,{children:[(0,t.jsxs)("div",{className:"flex items-center gap-3 mb-4",children:[(0,t.jsx)("div",{className:"p-2 rounded-lg bg-purple-500/10 text-purple-500",children:(0,t.jsx)("span",{className:"material-symbols-outlined text-[20px]","aria-hidden":"true",children:"palette"})}),(0,t.jsx)("h3",{className:"text-lg font-semibold",children:h("appearance")})]}),(0,t.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"font-medium",children:h("darkMode")}),(0,t.jsx)("p",{className:"text-sm text-text-muted",children:h("switchThemes")})]}),(0,t.jsx)(u.Toggle,{checked:l,onChange:()=>a(l?"light":"dark")})]}),(0,t.jsx)("div",{className:"pt-4 border-t border-border",children:(0,t.jsx)("div",{role:"tablist","aria-label":h("themeSelectionAria"),className:"inline-flex p-1 rounded-lg bg-black/5 dark:bg-white/5",children:["light","dark","system"].map(s=>(0,t.jsxs)("button",{role:"tab","aria-selected":e===s,onClick:()=>a(s),className:(0,r.cn)("flex items-center gap-2 px-4 py-2 rounded-md font-medium transition-all",e===s?"bg-white dark:bg-white/10 text-text-main shadow-sm":"text-text-muted hover:text-text-main"),children:[(0,t.jsx)("span",{className:"material-symbols-outlined text-[20px]","aria-hidden":"true",children:"light"===s?"light_mode":"dark"===s?"dark_mode":"contrast"}),(0,t.jsx)("span",{children:N[s]||s})]},s))})}),(0,t.jsxs)("div",{className:"pt-4 border-t border-border",children:[(0,t.jsx)("p",{className:"font-medium mb-1",children:h("themeAccent")}),(0,t.jsx)("p",{className:"text-sm text-text-muted mb-3",children:h("themeAccentDesc")}),(0,t.jsx)("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-2 mb-3",children:w.map(e=>{let s=c===e.id;return(0,t.jsx)("button",{onClick:()=>m(e.id),className:(0,r.cn)("flex items-center justify-between gap-2 p-2 rounded-lg border transition-colors",s?"border-primary bg-primary/10 text-primary":"border-border hover:bg-surface/50 text-text-main"),children:(0,t.jsxs)("span",{className:"flex items-center gap-2",children:[(0,t.jsx)("span",{className:"size-4 rounded-full border border-black/10 dark:border-white/20",style:{backgroundColor:e.color}}),(0,t.jsx)("span",{className:"text-sm font-medium",children:e.label})]})},e.id)})}),(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)("input",{type:"color",value:j,onChange:e=>y(e.target.value),className:"h-10 w-12 rounded border border-border bg-surface cursor-pointer","aria-label":h("themeCustom")}),(0,t.jsx)("input",{type:"text",value:j,onChange:e=>y(e.target.value),placeholder:"#3b82f6",maxLength:7,className:`flex-1 h-10 px-3 rounded-lg bg-surface border text-sm text-text-main focus:outline-none ${v?"border-border focus:border-primary":"border-red-400 focus:border-red-500"}`}),(0,t.jsx)(d.Button,{onClick:()=>x(j),disabled:!v,children:h("themeCreate")})]})]}),(0,t.jsx)("div",{className:"pt-4 border-t border-border",children:(0,t.jsxs)("div",{className:"flex items-center justify-between",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"font-medium",children:h("hideHealthLogs")}),(0,t.jsx)("p",{className:"text-sm text-text-muted",children:h("hideHealthLogsDesc")})]}),(0,t.jsx)(u.Toggle,{checked:!0===p.hideHealthCheckLogs,onChange:()=>k("hideHealthCheckLogs",!p.hideHealthCheckLogs),disabled:g})]})})]})]})}let M=[{value:"passthrough",labelKey:"passthrough",descKey:"passthroughDesc",icon:"arrow_forward"},{value:"auto",labelKey:"auto",descKey:"autoDesc",icon:"auto_awesome"},{value:"custom",labelKey:"custom",descKey:"customDesc",icon:"tune"},{value:"adaptive",labelKey:"adaptive",descKey:"adaptiveDesc",icon:"trending_up"}],I=[{value:"none",labelKey:"effortNone"},{value:"low",labelKey:"effortLow"},{value:"medium",labelKey:"effortMedium"},{value:"high",labelKey:"effortHigh"}];function F(){let[e,a]=(0,s.useState)({mode:"passthrough",customBudget:10240,effortLevel:"medium"}),[r,l]=(0,s.useState)(!0),[d,c]=(0,s.useState)(!1),[o,m]=(0,s.useState)(""),x=(0,i.useTranslations)("settings");(0,s.useEffect)(()=>{fetch("/api/settings/thinking-budget").then(e=>e.json()).then(e=>{a(e),l(!1)}).catch(()=>l(!1))},[]);let u=async t=>{let s={...e,...t};a(s),c(!0),m("");try{(await fetch("/api/settings/thinking-budget",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)})).ok?(m("saved"),setTimeout(()=>m(""),2e3)):m("error")}catch{m("error")}finally{c(!1)}};return(0,t.jsxs)(n.Card,{children:[(0,t.jsxs)("div",{className:"flex items-center gap-3 mb-5",children:[(0,t.jsx)("div",{className:"p-2 rounded-lg bg-violet-500/10 text-violet-500",children:(0,t.jsx)("span",{className:"material-symbols-outlined text-[20px]","aria-hidden":"true",children:"psychology"})}),(0,t.jsxs)("div",{children:[(0,t.jsx)("h3",{className:"text-lg font-semibold",children:x("thinkingBudgetTitle")}),(0,t.jsx)("p",{className:"text-sm text-text-muted",children:x("thinkingBudgetDesc")})]}),"saved"===o&&(0,t.jsxs)("span",{className:"ml-auto text-xs font-medium text-emerald-500 flex items-center gap-1",children:[(0,t.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"check_circle"})," ",x("saved")]})]}),(0,t.jsx)("div",{className:"grid grid-cols-2 gap-2 mb-5",children:M.map(s=>(0,t.jsxs)("button",{onClick:()=>u({mode:s.value}),disabled:r||d,className:`flex items-start gap-3 p-3 rounded-lg border text-left transition-all ${e.mode===s.value?"border-violet-500/50 bg-violet-500/5 ring-1 ring-violet-500/20":"border-border/50 hover:border-border hover:bg-surface/30"}`,children:[(0,t.jsx)("span",{className:`material-symbols-outlined text-[20px] mt-0.5 ${e.mode===s.value?"text-violet-500":"text-text-muted"}`,children:s.icon}),(0,t.jsxs)("div",{className:"min-w-0",children:[(0,t.jsx)("p",{className:`text-sm font-medium ${e.mode===s.value?"text-violet-400":""}`,children:x(s.labelKey)}),(0,t.jsx)("p",{className:"text-xs text-text-muted mt-0.5 leading-relaxed",children:x(s.descKey)})]})]},s.value))}),"custom"===e.mode&&(0,t.jsxs)("div",{className:"p-4 rounded-lg bg-surface/30 border border-border/30 mb-4",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between mb-3",children:[(0,t.jsx)("p",{className:"text-sm font-medium",children:x("tokenBudget")}),(0,t.jsxs)("span",{className:"text-sm font-mono tabular-nums text-violet-400",children:[e.customBudget.toLocaleString()," ",x("tokens")]})]}),(0,t.jsx)("input",{type:"range",min:"0",max:"131072",step:"1024",value:e.customBudget,onChange:e=>u({customBudget:parseInt(e.target.value)}),className:"w-full accent-violet-500"}),(0,t.jsxs)("div",{className:"flex justify-between text-xs text-text-muted mt-1",children:[(0,t.jsx)("span",{children:x("off")}),(0,t.jsx)("span",{children:"1K"}),(0,t.jsx)("span",{children:"10K"}),(0,t.jsx)("span",{children:"64K"}),(0,t.jsx)("span",{children:"128K"})]})]}),"adaptive"===e.mode&&(0,t.jsxs)("div",{className:"p-4 rounded-lg bg-surface/30 border border-border/30",children:[(0,t.jsx)("p",{className:"text-sm font-medium mb-3",children:x("baseEffortLevel")}),(0,t.jsx)("p",{className:"text-xs text-text-muted mb-3",children:x("adaptiveHint")}),(0,t.jsx)("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-2",children:I.map(s=>(0,t.jsx)("button",{onClick:()=>u({effortLevel:s.value}),disabled:r||d,className:`px-3 py-2 rounded-lg text-xs font-medium border transition-all ${e.effortLevel===s.value?"border-violet-500/50 bg-violet-500/10 text-violet-400":"border-border/50 text-text-muted hover:border-border"}`,children:x(s.labelKey)},s.value))})]})]})}function _(){let[e,a]=(0,s.useState)(!1),[r,l]=(0,s.useState)(!0),[i,d]=(0,s.useState)(!1),[c,o]=(0,s.useState)("");(0,s.useEffect)(()=>{fetch("/api/settings/codex-service-tier").then(e=>e.json()).then(e=>{a(!!e.enabled),l(!1)}).catch(()=>l(!1))},[]);let m=async e=>{a(e),d(!0),o("");try{(await fetch("/api/settings/codex-service-tier",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({enabled:e})})).ok?(o("saved"),setTimeout(()=>o(""),2e3)):(o("error"),a(!e))}catch{o("error"),a(!e)}finally{d(!1)}};return(0,t.jsxs)(n.Card,{children:[(0,t.jsxs)("div",{className:"flex items-center gap-3 mb-5",children:[(0,t.jsx)("div",{className:"p-2 rounded-lg bg-sky-500/10 text-sky-500",children:(0,t.jsx)("span",{className:"material-symbols-outlined text-[20px]","aria-hidden":"true",children:"bolt"})}),(0,t.jsxs)("div",{className:"flex-1",children:[(0,t.jsx)("h3",{className:"text-lg font-semibold",children:"Codex Fast Service Tier"}),(0,t.jsx)("p",{className:"text-sm text-text-muted",children:"Inject `service_tier=fast` into Codex requests when the client leaves it unset."})]}),"saved"===c&&(0,t.jsxs)("span",{className:"text-xs font-medium text-emerald-500 flex items-center gap-1",children:[(0,t.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"check_circle"}),"Saved"]}),"error"===c&&(0,t.jsxs)("span",{className:"text-xs font-medium text-rose-500 flex items-center gap-1",children:[(0,t.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"error"}),"Failed to save"]})]}),(0,t.jsxs)("div",{className:"flex items-center justify-between p-4 rounded-lg bg-surface/30 border border-border/30",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"text-sm font-medium",children:"Force fast tier for Codex"}),(0,t.jsx)("p",{className:"text-xs text-text-muted mt-0.5",children:"Off by default. Applies only to Codex requests and does not override an explicit tier."})]}),(0,t.jsx)("button",{onClick:()=>m(!e),disabled:r||i,className:`relative inline-flex h-6 w-11 items-center rounded-full transition-colors ${e?"bg-sky-500":"bg-white/10"}`,children:(0,t.jsx)("span",{className:`inline-block h-4 w-4 rounded-full bg-white transition-transform ${e?"translate-x-6":"translate-x-1"}`})})]})]})}function R(){let[e,a]=(0,s.useState)({enabled:!1,prompt:""}),[r,l]=(0,s.useState)(!0),[d,c]=(0,s.useState)(""),[o,m]=(0,s.useState)(null),x=(0,i.useTranslations)("settings");(0,s.useEffect)(()=>{fetch("/api/settings/system-prompt").then(e=>e.json()).then(e=>{a(e),l(!1)}).catch(()=>l(!1))},[]);let h=async t=>{let s={...e,...t};a(s),c("");try{(await fetch("/api/settings/system-prompt",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)})).ok&&(c("saved"),setTimeout(()=>c(""),2e3))}catch{c("error")}};return(0,t.jsxs)(n.Card,{children:[(0,t.jsxs)("div",{className:"flex items-center gap-3 mb-5",children:[(0,t.jsx)("div",{className:"p-2 rounded-lg bg-amber-500/10 text-amber-500",children:(0,t.jsx)("span",{className:"material-symbols-outlined text-[20px]","aria-hidden":"true",children:"edit_note"})}),(0,t.jsxs)("div",{className:"flex-1",children:[(0,t.jsx)("h3",{className:"text-lg font-semibold",children:x("globalSystemPrompt")}),(0,t.jsx)("p",{className:"text-sm text-text-muted",children:x("systemPromptDesc")})]}),(0,t.jsxs)("div",{className:"flex items-center gap-3",children:["saved"===d&&(0,t.jsxs)("span",{className:"text-xs font-medium text-emerald-500 flex items-center gap-1",children:[(0,t.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"check_circle"})," ",x("saved")]}),(0,t.jsx)(u.Toggle,{checked:e.enabled,onChange:()=>h({enabled:!e.enabled}),disabled:r})]})]}),e.enabled&&(0,t.jsxs)("div",{className:"flex flex-col gap-3",children:[(0,t.jsxs)("div",{className:"relative",children:[(0,t.jsx)("textarea",{value:e.prompt,onChange:e=>{var t;return t=e.target.value,void(a(e=>({...e,prompt:t})),o&&clearTimeout(o),m(setTimeout(()=>{h({prompt:t})},800)))},placeholder:x("systemPromptPlaceholder"),rows:5,className:"w-full px-4 py-3 rounded-lg border border-border/50 bg-surface/30 text-sm placeholder:text-text-muted/50 resize-y min-h-[120px] focus:outline-none focus:ring-1 focus:ring-amber-500/30 focus:border-amber-500/50 transition-colors",disabled:r}),(0,t.jsx)("div",{className:"absolute bottom-2 right-3 text-xs text-text-muted/60 tabular-nums",children:x("chars",{count:e.prompt.length})})]}),(0,t.jsxs)("p",{className:"text-xs text-text-muted/70 flex items-center gap-1.5",children:[(0,t.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"info"}),x("systemPromptHint")]})]})]})}function $(){let[e,a]=(0,s.useState)({}),[r,l]=(0,s.useState)({}),[d,c]=(0,s.useState)(!0),[o,m]=(0,s.useState)(!1),[x,u]=(0,s.useState)(""),[h,p]=(0,s.useState)(""),[b,g]=(0,s.useState)(""),f=(0,i.useTranslations)("settings");(0,s.useEffect)(()=>{fetch("/api/settings/model-aliases").then(e=>e.json()).then(e=>{a(e.builtIn||{}),l(e.custom||{}),c(!1)}).catch(()=>c(!1))},[]);let j=async()=>{if(h.trim()&&b.trim()){m(!0);try{let e=await fetch("/api/settings/model-aliases",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({from:h.trim(),to:b.trim()})});if(e.ok){let t=await e.json();l(t.custom),p(""),g(""),u("saved"),setTimeout(()=>u(""),2e3)}}catch{u("error")}finally{m(!1)}}},y=async e=>{m(!0);try{let t=await fetch("/api/settings/model-aliases",{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({from:e})});if(t.ok){let e=await t.json();l(e.custom),u("saved"),setTimeout(()=>u(""),2e3)}}catch{u("error")}finally{m(!1)}},v=Object.entries(e),N=Object.entries(r);return(0,t.jsxs)(n.Card,{children:[(0,t.jsxs)("div",{className:"flex items-center gap-3 mb-5",children:[(0,t.jsx)("div",{className:"p-2 rounded-lg bg-amber-500/10 text-amber-500",children:(0,t.jsx)("span",{className:"material-symbols-outlined text-[20px]","aria-hidden":"true",children:"swap_horiz"})}),(0,t.jsxs)("div",{children:[(0,t.jsx)("h3",{className:"text-lg font-semibold",children:f("modelAliasesTitle")||"Model Aliases"}),(0,t.jsx)("p",{className:"text-sm text-text-muted",children:f("modelAliasesDesc")||"Auto-forward deprecated model IDs to their replacements"})]}),"saved"===x&&(0,t.jsxs)("span",{className:"ml-auto text-xs font-medium text-emerald-500 flex items-center gap-1",children:[(0,t.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"check_circle"})," ",f("saved")||"Saved"]})]}),(0,t.jsxs)("div",{className:"p-4 rounded-lg bg-surface/30 border border-border/30 mb-4",children:[(0,t.jsx)("p",{className:"text-sm font-medium mb-3",children:f("addCustomAlias")||"Add Custom Alias"}),(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)("input",{type:"text",placeholder:f("deprecatedModelId")||"Deprecated model ID",value:h,onChange:e=>p(e.target.value),className:"flex-1 px-3 py-2 rounded-lg text-sm bg-surface border border-border/50 focus:border-amber-500/50 focus:outline-none"}),(0,t.jsx)("span",{className:"text-text-muted text-lg",children:"→"}),(0,t.jsx)("input",{type:"text",placeholder:f("newModelId")||"New model ID",value:b,onChange:e=>g(e.target.value),className:"flex-1 px-3 py-2 rounded-lg text-sm bg-surface border border-border/50 focus:border-amber-500/50 focus:outline-none"}),(0,t.jsx)("button",{onClick:j,disabled:o||!h.trim()||!b.trim(),className:"px-4 py-2 rounded-lg text-sm font-medium bg-amber-500/10 text-amber-500 hover:bg-amber-500/20 disabled:opacity-50 transition-all",children:f("add")||"Add"})]})]}),N.length>0&&(0,t.jsxs)("div",{className:"mb-4",children:[(0,t.jsx)("p",{className:"text-xs font-medium text-text-muted uppercase tracking-wider mb-2",children:f("customAliases")||"Custom Aliases"}),(0,t.jsx)("div",{className:"rounded-lg border border-border/30 divide-y divide-border/20",children:N.map(([e,s])=>(0,t.jsxs)("div",{className:"flex items-center gap-3 px-4 py-2.5",children:[(0,t.jsx)("code",{className:"text-xs text-red-400/80 flex-1 truncate",children:e}),(0,t.jsx)("span",{className:"material-symbols-outlined text-[14px] text-text-muted",children:"arrow_forward"}),(0,t.jsx)("code",{className:"text-xs text-emerald-400/80 flex-1 truncate",children:s}),(0,t.jsx)("button",{onClick:()=>y(e),disabled:o,className:"p-1 rounded hover:bg-red-500/10 text-text-muted hover:text-red-400 transition-all",children:(0,t.jsx)("span",{className:"material-symbols-outlined text-[16px]",children:"close"})})]},e))})]}),(0,t.jsxs)("details",{className:"group",children:[(0,t.jsxs)("summary",{className:"text-xs font-medium text-text-muted uppercase tracking-wider cursor-pointer flex items-center gap-1 mb-2",children:[(0,t.jsx)("span",{className:"material-symbols-outlined text-[14px] group-open:rotate-90 transition-transform",children:"chevron_right"}),f("builtInAliases")||"Built-in Aliases"," (",v.length,")"]}),(0,t.jsx)("div",{className:"rounded-lg border border-border/30 divide-y divide-border/20 max-h-60 overflow-y-auto",children:v.map(([e,s])=>(0,t.jsxs)("div",{className:"flex items-center gap-3 px-4 py-2 opacity-60",children:[(0,t.jsx)("code",{className:"text-xs text-red-400/60 flex-1 truncate",children:e}),(0,t.jsx)("span",{className:"material-symbols-outlined text-[14px] text-text-muted",children:"arrow_forward"}),(0,t.jsx)("code",{className:"text-xs text-emerald-400/60 flex-1 truncate",children:s}),(0,t.jsx)("span",{className:"material-symbols-outlined text-[14px] text-text-muted",children:"lock"})]},e))})]})]})}function z(){let[e,a]=(0,s.useState)({enabled:!1,degradationMap:{},detectionPatterns:[],stats:{detected:0,tokensSaved:0}}),[r,l]=(0,s.useState)(!0),[d,c]=(0,s.useState)(!1),[o,m]=(0,s.useState)(""),[x,u]=(0,s.useState)(""),[h,p]=(0,s.useState)(""),[b,g]=(0,s.useState)(""),f=(0,i.useTranslations)("settings");(0,s.useEffect)(()=>{fetch("/api/settings/background-degradation").then(e=>e.json()).then(e=>{a(e),l(!1)}).catch(()=>l(!1))},[]);let j=async t=>{let s={...e,...t};a(s),c(!0),m("");try{let{stats:e,...t}=s,r=await fetch("/api/settings/background-degradation",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(r.ok){let e=await r.json();a(e),m("saved"),setTimeout(()=>m(""),2e3)}else m("error")}catch{m("error")}finally{c(!1)}},y=Object.entries(e.degradationMap||{});return(0,t.jsxs)(n.Card,{children:[(0,t.jsxs)("div",{className:"flex items-center gap-3 mb-5",children:[(0,t.jsx)("div",{className:"p-2 rounded-lg bg-sky-500/10 text-sky-500",children:(0,t.jsx)("span",{className:"material-symbols-outlined text-[20px]","aria-hidden":"true",children:"speed"})}),(0,t.jsxs)("div",{className:"flex-1",children:[(0,t.jsx)("h3",{className:"text-lg font-semibold",children:f("backgroundDegradationTitle")||"Background Task Degradation"}),(0,t.jsx)("p",{className:"text-sm text-text-muted",children:f("backgroundDegradationDesc")||"Auto-redirect background requests (titles, summaries) to cheaper models"})]}),"saved"===o&&(0,t.jsxs)("span",{className:"text-xs font-medium text-emerald-500 flex items-center gap-1",children:[(0,t.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"check_circle"})," ",f("saved")||"Saved"]})]}),(0,t.jsxs)("div",{className:"flex items-center justify-between p-4 rounded-lg bg-surface/30 border border-border/30 mb-4",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"text-sm font-medium",children:f("enableDegradation")||"Enable Background Degradation"}),(0,t.jsx)("p",{className:"text-xs text-text-muted mt-0.5",children:f("enableDegradationHint")||"Automatically use cheaper models for background utility tasks"})]}),(0,t.jsx)("button",{onClick:()=>j({enabled:!e.enabled}),disabled:r||d,className:`relative inline-flex h-6 w-11 items-center rounded-full transition-colors ${e.enabled?"bg-sky-500":"bg-white/10"}`,children:(0,t.jsx)("span",{className:`inline-block h-4 w-4 rounded-full bg-white transition-transform ${e.enabled?"translate-x-6":"translate-x-1"}`})})]}),e.stats&&e.stats.detected>0&&(0,t.jsx)("div",{className:"flex items-center gap-4 p-3 rounded-lg bg-sky-500/5 border border-sky-500/20 mb-4",children:(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)("span",{className:"material-symbols-outlined text-[16px] text-sky-400",children:"analytics"}),(0,t.jsxs)("span",{className:"text-xs text-text-muted",children:[f("tasksDetected")||"Tasks detected",":"]}),(0,t.jsx)("span",{className:"text-sm font-mono font-semibold text-sky-400",children:e.stats.detected})]})}),e.enabled&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("div",{className:"mb-4",children:[(0,t.jsx)("p",{className:"text-xs font-medium text-text-muted uppercase tracking-wider mb-2",children:f("degradationMap")||"Model Degradation Map"}),(0,t.jsxs)("div",{className:"flex items-center gap-2 mb-3",children:[(0,t.jsx)("input",{type:"text",placeholder:f("premiumModel")||"Premium model",value:x,onChange:e=>u(e.target.value),className:"flex-1 px-3 py-2 rounded-lg text-sm bg-surface border border-border/50 focus:border-sky-500/50 focus:outline-none"}),(0,t.jsx)("span",{className:"text-text-muted text-lg",children:"→"}),(0,t.jsx)("input",{type:"text",placeholder:f("cheapModel")||"Cheap model",value:h,onChange:e=>p(e.target.value),className:"flex-1 px-3 py-2 rounded-lg text-sm bg-surface border border-border/50 focus:border-sky-500/50 focus:outline-none"}),(0,t.jsx)("button",{onClick:()=>{x.trim()&&h.trim()&&(j({degradationMap:{...e.degradationMap,[x.trim()]:h.trim()}}),u(""),p(""))},disabled:d||!x.trim()||!h.trim(),className:"px-3 py-2 rounded-lg text-sm font-medium bg-sky-500/10 text-sky-500 hover:bg-sky-500/20 disabled:opacity-50 transition-all",children:f("add")||"Add"})]}),y.length>0&&(0,t.jsx)("div",{className:"rounded-lg border border-border/30 divide-y divide-border/20 max-h-48 overflow-y-auto",children:y.map(([s,a])=>(0,t.jsxs)("div",{className:"flex items-center gap-3 px-4 py-2",children:[(0,t.jsx)("code",{className:"text-xs text-orange-400/80 flex-1 truncate",children:s}),(0,t.jsx)("span",{className:"material-symbols-outlined text-[14px] text-text-muted",children:"arrow_forward"}),(0,t.jsx)("code",{className:"text-xs text-sky-400/80 flex-1 truncate",children:a}),(0,t.jsx)("button",{onClick:()=>{let t;return t={...e.degradationMap},void(delete t[s],j({degradationMap:t}))},disabled:d,className:"p-1 rounded hover:bg-red-500/10 text-text-muted hover:text-red-400 transition-all",children:(0,t.jsx)("span",{className:"material-symbols-outlined text-[16px]",children:"close"})})]},s))})]}),(0,t.jsxs)("details",{className:"group",children:[(0,t.jsxs)("summary",{className:"text-xs font-medium text-text-muted uppercase tracking-wider cursor-pointer flex items-center gap-1 mb-2",children:[(0,t.jsx)("span",{className:"material-symbols-outlined text-[14px] group-open:rotate-90 transition-transform",children:"chevron_right"}),f("detectionPatterns")||"Detection Patterns"," (",e.detectionPatterns?.length||0,")"]}),(0,t.jsxs)("div",{className:"flex items-center gap-2 mb-3",children:[(0,t.jsx)("input",{type:"text",placeholder:f("newPattern")||'e.g. "generate a title"',value:b,onChange:e=>g(e.target.value),className:"flex-1 px-3 py-2 rounded-lg text-sm bg-surface border border-border/50 focus:border-sky-500/50 focus:outline-none"}),(0,t.jsx)("button",{onClick:()=>{b.trim()&&(j({detectionPatterns:[...e.detectionPatterns,b.trim()]}),g(""))},disabled:d||!b.trim(),className:"px-3 py-2 rounded-lg text-sm font-medium bg-sky-500/10 text-sky-500 hover:bg-sky-500/20 disabled:opacity-50 transition-all",children:f("add")||"Add"})]}),(0,t.jsx)("div",{className:"flex flex-wrap gap-2",children:(e.detectionPatterns||[]).map((s,a)=>(0,t.jsxs)("span",{className:"inline-flex items-center gap-1 px-2.5 py-1 rounded-full text-xs bg-sky-500/10 text-sky-400 border border-sky-500/20",children:[s,(0,t.jsx)("button",{onClick:()=>{j({detectionPatterns:e.detectionPatterns.filter((e,t)=>t!==a)})},className:"hover:text-red-400 transition-colors",disabled:d,children:(0,t.jsx)("span",{className:"material-symbols-outlined text-[12px]",children:"close"})})]},a))})]})]})]})}function K(){let[e,a]=(0,s.useState)(null),[r,l]=(0,s.useState)(!1),d=(0,i.useTranslations)("settings"),c=()=>{fetch("/api/cache/stats").then(e=>e.json()).then(a).catch(()=>{})};(0,s.useEffect)(c,[]);let o=async()=>{l(!0);try{await fetch("/api/cache/stats",{method:"DELETE"}),c()}finally{l(!1)}};return(0,t.jsxs)(n.Card,{className:"p-6",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between mb-4",children:[(0,t.jsxs)("h3",{className:"text-lg font-semibold text-text-main flex items-center gap-2",children:[(0,t.jsx)("span",{className:"material-symbols-outlined text-[20px]",children:"cached"}),d("promptCache")]}),(0,t.jsx)("button",{onClick:o,disabled:r,className:"px-3 py-1.5 text-xs rounded-lg bg-red-500/10 text-red-400 hover:bg-red-500/20 transition-colors disabled:opacity-50",children:d(r?"flushing":"flushCache")})]}),e?(0,t.jsxs)("div",{className:"grid grid-cols-2 gap-4 text-sm",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"text-text-muted",children:d("size")}),(0,t.jsxs)("p",{className:"font-mono text-lg text-text-main",children:[e.size,"/",e.maxSize]})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"text-text-muted",children:d("hitRate")}),(0,t.jsxs)("p",{className:"font-mono text-lg text-text-main",children:[e.hitRate?.toFixed(1)??0,"%"]})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"text-text-muted",children:d("hits")}),(0,t.jsx)("p",{className:"font-mono text-text-main",children:e.hits??0})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"text-text-muted",children:d("evictions")}),(0,t.jsx)("p",{className:"font-mono text-text-main",children:e.evictions??0})]})]}):(0,t.jsx)("p",{className:"text-sm text-text-muted",children:d("loadingCacheStats")})]})}let H={CLOSED:{bg:"bg-emerald-500/15",text:"text-emerald-400",border:"border-emerald-500/30",icon:"check_circle"},OPEN:{bg:"bg-red-500/15",text:"text-red-400",border:"border-red-500/30",icon:"error"},HALF_OPEN:{bg:"bg-amber-500/15",text:"text-amber-400",border:"border-amber-500/30",icon:"warning"}},q={closed:{icon:"check_circle",color:"#22c55e"},"half-open":{icon:"pending",color:"#f59e0b"},open:{icon:"error",color:"#ef4444"}};function U(e,t){let s=String(e||"closed").toLowerCase().replaceAll("_","-");return t("open"===s?"breakerStateOpen":"half-open"===s?"breakerStateHalfOpen":"breakerStateClosed")}function J(e){return!e||e<=0?"—":e<1e3?`${e}ms`:e<6e4?`${(e/1e3).toFixed(1)}s`:`${(e/6e4).toFixed(1)}m`}function G(e,t){return e instanceof Error&&e.message?e.message:t}function W({profiles:e,onSave:a,saving:r}){let[l,c]=(0,s.useState)(!1),[o,m]=(0,s.useState)(e),x=(0,i.useTranslations)("settings"),u=(0,i.useTranslations)("common");(0,s.useEffect)(()=>{m(e)},[e]);let h=e=>null==e?"—":`${e}${x("ms")}`,p=[{key:"transientCooldown",label:x("transientCooldown"),format:h},{key:"rateLimitCooldown",label:x("rateLimitCooldown"),format:h},{key:"maxBackoffLevel",label:x("maxBackoffLevel")},{key:"circuitBreakerThreshold",label:x("cbThreshold"),format:e=>null==e?"—":x("failures",{count:e})},{key:"circuitBreakerReset",label:x("cbResetTime"),format:h}];return(0,t.jsx)(n.Card,{className:"p-0 overflow-hidden",children:(0,t.jsxs)("div",{className:"p-6",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between mb-4",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)("span",{className:"material-symbols-outlined text-xl text-primary","aria-hidden":"true",children:"tune"}),(0,t.jsx)("h2",{className:"text-lg font-bold",children:x("providerProfiles")})]}),l?(0,t.jsxs)("div",{className:"flex flex-wrap justify-end gap-2",children:[(0,t.jsx)(d.Button,{size:"sm",variant:"secondary",onClick:()=>c(!1),children:u("cancel")}),(0,t.jsx)(d.Button,{size:"sm",variant:"primary",icon:"save",onClick:()=>{a(o),c(!1)},disabled:r,children:u("save")})]}):(0,t.jsx)(d.Button,{size:"sm",variant:"secondary",icon:"edit",onClick:()=>c(!0),children:u("edit")})]}),(0,t.jsx)("p",{className:"text-sm text-text-muted mb-4",children:x("providerProfilesDesc")}),(0,t.jsx)("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:["oauth","apikey"].map(s=>(0,t.jsxs)("div",{className:"rounded-lg bg-black/5 dark:bg-white/5 p-4",children:[(0,t.jsxs)("h3",{className:"text-sm font-bold uppercase tracking-wider mb-3 flex items-center gap-2",children:[(0,t.jsx)("span",{className:"material-symbols-outlined text-base","aria-hidden":"true",children:"oauth"===s?"lock":"key"}),"oauth"===s?x("oauthProviders"):x("apiKeyProviders")]}),(0,t.jsx)("div",{className:"space-y-2",children:p.map(({key:a,label:r,format:i})=>(0,t.jsxs)("div",{className:"flex items-center justify-between",children:[(0,t.jsx)("span",{className:"text-xs text-text-muted",children:r}),l?(0,t.jsx)("input",{type:"number",min:"0",value:o?.[s]?.[a]??0,onChange:e=>m({...o,[s]:{...o[s],[a]:Number(e.target.value)}}),className:"w-24 px-2 py-1 text-xs rounded bg-white/10 border border-white/20 text-right"}):(0,t.jsx)("span",{className:"text-sm font-mono",children:i?i(e?.[s]?.[a]):e?.[s]?.[a]??"—"})]},a))})]},s))})]})})}function V({rateLimitStatus:e,defaults:a,onSaveDefaults:r,saving:l}){let[c,o]=(0,s.useState)(!1),[m,x]=(0,s.useState)(a||{}),u=(0,i.useTranslations)("settings"),h=(0,i.useTranslations)("common");return(0,s.useEffect)(()=>{a&&x(a)},[a]),(0,t.jsx)(n.Card,{className:"p-0 overflow-hidden",children:(0,t.jsxs)("div",{className:"p-6",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between mb-4",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)("span",{className:"material-symbols-outlined text-xl text-primary","aria-hidden":"true",children:"speed"}),(0,t.jsx)("h2",{className:"text-lg font-bold",children:u("rateLimiting")})]}),c?(0,t.jsxs)("div",{className:"flex gap-2",children:[(0,t.jsx)(d.Button,{size:"sm",variant:"secondary",onClick:()=>o(!1),children:h("cancel")}),(0,t.jsx)(d.Button,{size:"sm",variant:"primary",icon:"save",onClick:()=>{r(m),o(!1)},disabled:l,children:h("save")})]}):(0,t.jsx)(d.Button,{size:"sm",variant:"secondary",icon:"edit",onClick:()=>o(!0),children:h("edit")})]}),(0,t.jsx)("p",{className:"text-sm text-text-muted mb-4",children:u("rateLimitingDesc")}),(0,t.jsxs)("div",{className:"rounded-lg bg-black/5 dark:bg-white/5 p-4 mb-4",children:[(0,t.jsx)("h3",{className:"text-xs font-bold uppercase tracking-wider mb-3 text-text-muted",children:u("defaultSafetyNet")}),(0,t.jsx)("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-4",children:[{key:"requestsPerMinute",label:u("rpm")},{key:"minTimeBetweenRequests",label:u("minGap"),format:J},{key:"concurrentRequests",label:u("maxConcurrent")}].map(({key:e,label:s,format:r})=>(0,t.jsxs)("div",{children:[c?(0,t.jsx)("input",{type:"number",min:"1",value:m[e]??0,onChange:t=>x(s=>({...s,[e]:parseInt(t.target.value)||0})),className:"w-full px-2 py-1 text-lg font-bold rounded bg-white/10 border border-white/20"}):(0,t.jsx)("div",{className:"text-lg font-bold",children:r?r(a?.[e]):a?.[e]??"—"}),(0,t.jsx)("div",{className:"text-xs text-text-muted",children:s})]},e))})]}),e&&e.length>0?(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)("h3",{className:"text-xs font-bold uppercase tracking-wider text-text-muted",children:u("activeLimiters")}),e.map((e,s)=>(0,t.jsxs)("div",{className:"flex items-center justify-between py-2 px-3 rounded-lg bg-black/5 dark:bg-white/5",children:[(0,t.jsx)("span",{className:"text-sm font-medium",children:e.provider||e.key}),(0,t.jsxs)("div",{className:"flex items-center gap-3 text-xs text-text-muted",children:[null!=e.reservoir&&(0,t.jsxs)("span",{children:[u("reservoir"),": ",e.reservoir]}),null!=e.running&&(0,t.jsxs)("span",{children:[u("running"),": ",e.running]}),null!=e.queued&&(0,t.jsxs)("span",{children:[u("queued"),": ",e.queued]})]})]},s))]}):(0,t.jsx)("p",{className:"text-xs text-text-muted",children:u("noActiveLimiters")})]})})}function Y({breakers:e,onReset:s,loading:a}){let r=e.filter(e=>"CLOSED"!==e.state),l=e.length,c=(0,i.useTranslations)("settings");return(0,t.jsx)(n.Card,{className:"p-0 overflow-hidden",children:(0,t.jsxs)("div",{className:"p-6",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between mb-4",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)("span",{className:"material-symbols-outlined text-xl text-primary","aria-hidden":"true",children:"electrical_services"}),(0,t.jsx)("h2",{className:"text-lg font-bold",children:c("circuitBreakers")})]}),(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)("span",{className:"text-xs text-text-muted",children:r.length>0?c("tripped",{count:r.length}):c("healthy",{count:l})}),r.length>0&&(0,t.jsx)(d.Button,{size:"sm",variant:"danger",icon:"restart_alt",onClick:s,disabled:a,children:c("resetAll")})]})]}),0===e.length?(0,t.jsx)("p",{className:"text-sm text-text-muted",children:c("noCircuitBreakers")}):(0,t.jsx)("div",{className:"space-y-2",children:e.map(e=>{let s=H[e.state]||H.CLOSED;return(0,t.jsxs)("div",{className:"flex items-center justify-between py-2 px-3 rounded-lg bg-black/5 dark:bg-white/5",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)("span",{className:`material-symbols-outlined text-base ${s.text}`,"aria-hidden":"true",children:s.icon}),(0,t.jsx)("span",{className:"text-sm font-medium",children:e.name.replace("combo:","")})]}),(0,t.jsxs)("div",{className:"flex items-center gap-3",children:[e.failureCount>0&&(0,t.jsx)("span",{className:"text-xs text-text-muted",children:c("failures",{count:e.failureCount})}),(0,t.jsx)("span",{className:`px-2 py-0.5 rounded text-xs font-bold uppercase ${s.bg} ${s.text} border ${s.border}`,children:U(e.state,c)})]})]},e.name)})})]})})}function Q(){let[e,a]=(0,s.useState)(null),[r,l]=(0,s.useState)(!0),[c,m]=(0,s.useState)(null),x=(0,y.useNotificationStore)(),u=(0,o.useLocale)(),h=(0,i.useTranslations)("settings"),p=(0,s.useCallback)(async()=>{try{let e=await fetch("/api/policies");if(e.ok){let t=await e.json();a(t)}}catch{}finally{l(!1)}},[]);(0,s.useEffect)(()=>{p();let e=setInterval(p,15e3);return()=>clearInterval(e)},[p]);let b=async e=>{m(e);try{(await fetch("/api/policies",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"unlock",identifier:e})})).ok?(x.success(h("unlockedIdentifier",{identifier:e})),await p()):x.error(h("failedUnlock"))}catch{x.error(h("failedUnlock"))}finally{m(null)}},g=e?.circuitBreakers||[],f=e?.lockedIdentifiers||[],j=g.some(e=>"closed"!==e.state)||f.length>0;return r?(0,t.jsx)(n.Card,{className:"p-6",children:(0,t.jsxs)("div",{className:"flex items-center gap-2 text-text-muted animate-pulse",children:[(0,t.jsx)("span",{className:"material-symbols-outlined text-[20px]",children:"policy"}),h("loadingPolicies")]})}):(0,t.jsx)(n.Card,{className:"p-0 overflow-hidden",children:(0,t.jsxs)("div",{className:"p-6",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between mb-4",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)("span",{className:"material-symbols-outlined text-xl text-primary","aria-hidden":"true",children:"policy"}),(0,t.jsx)("h2",{className:"text-lg font-bold",children:h("policiesLocked")})]}),j&&(0,t.jsx)(d.Button,{size:"sm",variant:"ghost",onClick:p,children:(0,t.jsx)("span",{className:"material-symbols-outlined text-[16px]",children:"refresh"})})]}),j?(0,t.jsxs)(t.Fragment,{children:[g.filter(e=>"closed"!==e.state).length>0&&(0,t.jsxs)("div",{className:"mb-4",children:[(0,t.jsx)("p",{className:"text-sm font-medium text-text-muted mb-2",children:h("circuitBreakers")}),(0,t.jsx)("div",{className:"flex flex-col gap-1.5",children:g.filter(e=>"closed"!==e.state).map((e,s)=>{let a=q[e.state]||q.open;return(0,t.jsx)("div",{className:"flex items-center justify-between px-3 py-2 rounded-lg bg-surface/30 border border-border/20",children:(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)("span",{className:"material-symbols-outlined text-[16px]",style:{color:a.color},children:a.icon}),(0,t.jsx)("span",{className:"text-sm text-text-main font-medium",children:e.name||e.provider||h("unknown")}),(0,t.jsx)("span",{className:"text-xs px-1.5 py-0.5 rounded-full",style:{backgroundColor:`${a.color}15`,color:a.color},children:U(e.state,h)}),e.failures>0&&(0,t.jsx)("span",{className:"text-xs text-text-muted",children:h("failures",{count:e.failures})})]})},e.name||s)})})]}),f.length>0&&(0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"text-sm font-medium text-text-muted mb-2",children:h("lockedIdentifiers")}),(0,t.jsx)("div",{className:"flex flex-col gap-1.5",children:f.map((e,s)=>{let a="string"==typeof e?e:e.identifier||e.id;return(0,t.jsxs)("div",{className:"flex items-center justify-between px-3 py-2 rounded-lg bg-surface/30 border border-border/20",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)("span",{className:"material-symbols-outlined text-[16px] text-red-400",children:"lock"}),(0,t.jsx)("span",{className:"font-mono text-sm text-text-main",children:a}),"object"==typeof e&&e.lockedAt&&(0,t.jsx)("span",{className:"text-xs text-text-muted",children:h("sinceDate",{date:new Date(e.lockedAt).toLocaleString(u)})})]}),(0,t.jsx)(d.Button,{size:"sm",variant:"ghost",onClick:()=>b(a),disabled:c===a,className:"text-xs",children:c===a?h("unlocking"):h("forceUnlock")})]},a||s)})})]})]}):(0,t.jsxs)("div",{className:"flex items-center gap-3",children:[(0,t.jsx)("div",{className:"p-2 rounded-lg bg-emerald-500/10 text-emerald-500",children:(0,t.jsx)("span",{className:"material-symbols-outlined text-[20px]",children:"verified_user"})}),(0,t.jsx)("div",{children:(0,t.jsx)("p",{className:"text-sm text-text-muted",children:h("allOperational")})})]})]})})}function X(){let[e,a]=(0,s.useState)(null),[r,l]=(0,s.useState)(!0),[c,o]=(0,s.useState)(!1),[m,x]=(0,s.useState)(null),u=(0,i.useTranslations)("settings"),h=(0,s.useCallback)(async()=>{try{l(!0);let e=await fetch("/api/resilience");if(!e.ok)throw Error(u("failedLoadWithStatus",{status:e.status}));let t=await e.json();a(t),x(null)}catch(e){x(G(e,u("failedLoadResilience")))}finally{l(!1)}},[u]);(0,s.useEffect)(()=>{h();let e=setInterval(h,1e4);return()=>clearInterval(e)},[h]);let p=async()=>{try{if(l(!0),!(await fetch("/api/resilience/reset",{method:"POST"})).ok)throw Error(u("resetFailed"));await h()}catch(e){x(G(e,u("resetFailed")))}finally{l(!1)}},b=async e=>{try{if(o(!0),!(await fetch("/api/resilience",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({profiles:e})})).ok)throw Error(u("saveFailed"));await h()}catch(e){x(G(e,u("saveFailed")))}finally{o(!1)}},g=async e=>{try{if(o(!0),!(await fetch("/api/resilience",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({defaults:e})})).ok)throw Error(u("saveFailed"));await h()}catch(e){x(G(e,u("saveFailed")))}finally{o(!1)}};return r&&!e?(0,t.jsxs)("div",{className:"flex items-center justify-center py-12 text-text-muted",children:[(0,t.jsx)("span",{className:"material-symbols-outlined animate-spin mr-2",children:"hourglass_empty"}),u("loadingResilience")]}):m&&!e?(0,t.jsxs)(n.Card,{className:"p-6",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2 text-red-400",children:[(0,t.jsx)("span",{className:"material-symbols-outlined",children:"error"}),(0,t.jsx)("span",{className:"text-sm",children:m})]}),(0,t.jsx)(d.Button,{size:"sm",variant:"secondary",icon:"refresh",onClick:h,className:"mt-3",children:u("retry")})]}):(0,t.jsxs)("div",{className:"flex flex-col gap-6",children:[(0,t.jsx)(W,{profiles:e?.profiles||{},onSave:b,saving:c}),(0,t.jsx)(V,{rateLimitStatus:e?.rateLimitStatus||[],defaults:e?.defaults||{},onSaveDefaults:g,saving:c}),(0,t.jsx)(Y,{breakers:e?.circuitBreakers||[],onReset:p,loading:r}),(0,t.jsx)(Q,{})]})}let Z=[{id:"general",labelKey:"general",icon:"settings"},{id:"ai",labelKey:"ai",icon:"smart_toy"},{id:"security",labelKey:"security",icon:"shield"},{id:"routing",labelKey:"routing",icon:"route"},{id:"resilience",labelKey:"resilience",icon:"electrical_services"},{id:"advanced",labelKey:"advanced",icon:"tune"}];function ee(){let e=(0,i.useTranslations)("settings"),n=(0,a.useSearchParams)().get("tab"),[d,c]=(0,s.useState)(null),o=d||Z.find(e=>e.id===n)?.id||"general";return(0,t.jsx)("div",{className:"max-w-6xl mx-auto min-w-0",children:(0,t.jsxs)("div",{className:"flex flex-col gap-6",children:[(0,t.jsx)("div",{className:"w-full overflow-x-auto pb-1",children:(0,t.jsx)("div",{role:"tablist","aria-label":e("settingsSectionsAria"),className:"inline-flex items-center p-1 rounded-lg bg-black/5 dark:bg-white/5 min-w-max",children:Z.map(s=>(0,t.jsxs)("button",{role:"tab","aria-selected":o===s.id,tabIndex:o===s.id?0:-1,onClick:()=>c(s.id),className:(0,r.cn)("flex items-center gap-2 px-4 py-2 rounded-md font-medium transition-all text-sm",o===s.id?"bg-white dark:bg-white/10 text-text-main shadow-sm":"text-text-muted hover:text-text-main"),children:[(0,t.jsx)("span",{className:"material-symbols-outlined text-[18px]","aria-hidden":"true",children:s.icon}),(0,t.jsx)("span",{className:"hidden sm:inline whitespace-nowrap",children:e(s.labelKey)})]},s.id))})}),(0,t.jsxs)("div",{role:"tabpanel","aria-label":e(Z.find(e=>e.id===o)?.labelKey||"general"),children:["general"===o&&(0,t.jsx)(t.Fragment,{children:(0,t.jsxs)("div",{className:"flex flex-col gap-6",children:[(0,t.jsx)(m,{}),(0,t.jsx)(L,{})]})}),"ai"===o&&(0,t.jsxs)("div",{className:"flex flex-col gap-6",children:[(0,t.jsx)(F,{}),(0,t.jsx)(_,{}),(0,t.jsx)(R,{}),(0,t.jsx)(K,{})]}),"security"===o&&(0,t.jsx)(f,{}),"routing"===o&&(0,t.jsxs)("div",{className:"flex flex-col gap-6",children:[(0,t.jsx)(C,{}),(0,t.jsx)(S,{}),(0,t.jsx)($,{}),(0,t.jsx)(z,{})]}),"resilience"===o&&(0,t.jsx)(X,{}),"advanced"===o&&(0,t.jsx)(D,{})]}),(0,t.jsxs)("div",{className:"text-center text-sm text-text-muted py-4",children:[(0,t.jsxs)("p",{children:[l.APP_CONFIG.name," v",l.APP_CONFIG.version]}),(0,t.jsx)("p",{className:"mt-1",children:e("localMode")})]})]})})}e.s(["default",()=>ee],667498)}]);
package/app/CHANGELOG.md CHANGED
@@ -4,6 +4,41 @@
4
4
 
5
5
  ---
6
6
 
7
+ ## [3.0.8] — 2026-03-25
8
+
9
+ ### 🐛 Bug Fixes
10
+
11
+ - **Translation Failures for OpenAI-format Providers in Claude CLI (#632):**
12
+ - Handle `reasoning_details[]` array format from StepFun/OpenRouter — converts to `reasoning_content`
13
+ - Handle `reasoning` field alias from some providers → normalized to `reasoning_content`
14
+ - Cross-map usage field names: `input_tokens`↔`prompt_tokens`, `output_tokens`↔`completion_tokens` in `filterUsageForFormat`
15
+ - Fix `extractUsage` to accept both `input_tokens`/`output_tokens` and `prompt_tokens`/`completion_tokens` as valid usage fields
16
+ - Applied to both streaming (`sanitizeStreamingChunk`, `openai-to-claude.ts` translator) and non-streaming (`sanitizeMessage`) paths
17
+
18
+ ---
19
+
20
+ ## [3.0.7] — 2026-03-25
21
+
22
+ ### 🐛 Bug Fixes
23
+
24
+ - **Antigravity Token Refresh:** Fixed `client_secret is missing` error for npm-installed users — the `clientSecretDefault` was empty in providerRegistry, causing Google to reject token refresh requests (#588)
25
+ - **OpenCode Zen Models:** Added `modelsUrl` to the OpenCode Zen registry entry so "Import from /models" works correctly (#612)
26
+ - **Streaming Artifacts:** Fixed excessive newlines left in responses after thinking-tag signature stripping (#626)
27
+ - **Proxy Fallback:** Added automatic retry without proxy when SOCKS5 relay fails
28
+ - **Proxy Test:** Test endpoint now resolves real credentials from DB via proxyId
29
+
30
+ ### ✨ New Features
31
+
32
+ - **Playground Account/Key Selector:** Persistent, always-visible dropdown to select specific provider accounts/keys for testing — fetches all connections at startup and filters by selected provider
33
+ - **CLI Tools Dynamic Models:** Model selection now dynamically fetches from `/v1/models` API — providers like Kiro now show their full model catalog
34
+ - **Antigravity Model List:** Updated with Claude Sonnet 4.5, Claude Sonnet 4, GPT 5, GPT 5 Mini; enabled `passthroughModels` for dynamic model access (#628)
35
+
36
+ ### 🔧 Maintenance
37
+
38
+ - Merged PR #625 — Provider Limits light mode background fix
39
+
40
+ ---
41
+
7
42
  ## [3.0.6] — 2026-03-25
8
43
 
9
44
  ### 🐛 Bug Fixes
@@ -1,7 +1,7 @@
1
1
  openapi: 3.1.0
2
2
  info:
3
3
  title: OmniRoute API
4
- version: 3.0.6
4
+ version: 3.0.8
5
5
  description: |
6
6
  OmniRoute is a local-first AI API proxy router. It provides an OpenAI-compatible
7
7
  endpoint that routes requests to multiple AI providers with load balancing,
@@ -386,16 +386,21 @@ export const REGISTRY: Record<string, RegistryEntry> = {
386
386
  clientIdEnv: "ANTIGRAVITY_OAUTH_CLIENT_ID",
387
387
  clientIdDefault: "1071006060591-tmhssin2h21lcre235vtolojh4g403ep.apps.googleusercontent.com",
388
388
  clientSecretEnv: "ANTIGRAVITY_OAUTH_CLIENT_SECRET",
389
- clientSecretDefault: "",
389
+ clientSecretDefault: "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",
390
390
  },
391
391
  models: [
392
392
  { id: "claude-opus-4-6-thinking", name: "Claude Opus 4.6 Thinking" },
393
393
  { id: "claude-sonnet-4-6", name: "Claude Sonnet 4.6" },
394
+ { id: "claude-sonnet-4-5", name: "Claude Sonnet 4.5" },
395
+ { id: "claude-sonnet-4", name: "Claude Sonnet 4" },
394
396
  { id: "gemini-2.5-pro", name: "Gemini 2.5 Pro" },
395
397
  { id: "gemini-2.5-flash", name: "Gemini 2.5 Flash" },
396
398
  { id: "gemini-2.0-flash", name: "Gemini 2.0 Flash" },
397
399
  { id: "gpt-oss-120b-medium", name: "GPT OSS 120B Medium" },
400
+ { id: "gpt-5", name: "GPT 5" },
401
+ { id: "gpt-5-mini", name: "GPT 5 Mini" },
398
402
  ],
403
+ passthroughModels: true,
399
404
  },
400
405
 
401
406
  github: {
@@ -576,6 +581,7 @@ export const REGISTRY: Record<string, RegistryEntry> = {
576
581
  format: "openai",
577
582
  executor: "opencode",
578
583
  baseUrl: "https://opencode.ai/zen/v1",
584
+ modelsUrl: "https://opencode.ai/zen/v1/models",
579
585
  authType: "apikey",
580
586
  authHeader: "Authorization",
581
587
  authPrefix: "Bearer",