9router 0.3.72 → 0.3.75

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 (424) hide show
  1. package/app/.next/BUILD_ID +1 -1
  2. package/app/.next/app-path-routes-manifest.json +6 -4
  3. package/app/.next/build-manifest.json +2 -2
  4. package/app/.next/routes-manifest.json +17 -0
  5. package/app/.next/server/app/(dashboard)/dashboard/basic-chat/page.js +2 -2
  6. package/app/.next/server/app/(dashboard)/dashboard/basic-chat/page.js.nft.json +1 -1
  7. package/app/.next/server/app/(dashboard)/dashboard/basic-chat/page_client-reference-manifest.js +1 -1
  8. package/app/.next/server/app/(dashboard)/dashboard/cli-tools/page.js +2 -2
  9. package/app/.next/server/app/(dashboard)/dashboard/cli-tools/page.js.nft.json +1 -1
  10. package/app/.next/server/app/(dashboard)/dashboard/cli-tools/page_client-reference-manifest.js +1 -1
  11. package/app/.next/server/app/(dashboard)/dashboard/combos/page.js +2 -2
  12. package/app/.next/server/app/(dashboard)/dashboard/combos/page.js.nft.json +1 -1
  13. package/app/.next/server/app/(dashboard)/dashboard/combos/page_client-reference-manifest.js +1 -1
  14. package/app/.next/server/app/(dashboard)/dashboard/console-log/page.js +2 -2
  15. package/app/.next/server/app/(dashboard)/dashboard/console-log/page.js.nft.json +1 -1
  16. package/app/.next/server/app/(dashboard)/dashboard/console-log/page_client-reference-manifest.js +1 -1
  17. package/app/.next/server/app/(dashboard)/dashboard/endpoint/page.js +2 -2
  18. package/app/.next/server/app/(dashboard)/dashboard/endpoint/page.js.nft.json +1 -1
  19. package/app/.next/server/app/(dashboard)/dashboard/endpoint/page_client-reference-manifest.js +1 -1
  20. package/app/.next/server/app/(dashboard)/dashboard/media-providers/[kind]/[id]/page.js +2 -0
  21. package/app/.next/server/app/(dashboard)/dashboard/media-providers/[kind]/[id]/page.js.nft.json +1 -0
  22. package/app/.next/server/app/(dashboard)/dashboard/media-providers/[kind]/[id]/page_client-reference-manifest.js +1 -0
  23. package/app/.next/server/app/(dashboard)/dashboard/media-providers/[kind]/page.js +2 -0
  24. package/app/.next/server/app/(dashboard)/dashboard/media-providers/[kind]/page.js.nft.json +1 -0
  25. package/app/.next/server/app/(dashboard)/dashboard/media-providers/[kind]/page_client-reference-manifest.js +1 -0
  26. package/app/.next/server/app/(dashboard)/dashboard/mitm/page.js +2 -2
  27. package/app/.next/server/app/(dashboard)/dashboard/mitm/page.js.nft.json +1 -1
  28. package/app/.next/server/app/(dashboard)/dashboard/mitm/page_client-reference-manifest.js +1 -1
  29. package/app/.next/server/app/(dashboard)/dashboard/page.js +2 -2
  30. package/app/.next/server/app/(dashboard)/dashboard/page.js.nft.json +1 -1
  31. package/app/.next/server/app/(dashboard)/dashboard/page_client-reference-manifest.js +1 -1
  32. package/app/.next/server/app/(dashboard)/dashboard/profile/page.js +2 -2
  33. package/app/.next/server/app/(dashboard)/dashboard/profile/page.js.nft.json +1 -1
  34. package/app/.next/server/app/(dashboard)/dashboard/profile/page_client-reference-manifest.js +1 -1
  35. package/app/.next/server/app/(dashboard)/dashboard/providers/[id]/page.js +2 -2
  36. package/app/.next/server/app/(dashboard)/dashboard/providers/[id]/page.js.nft.json +1 -1
  37. package/app/.next/server/app/(dashboard)/dashboard/providers/[id]/page_client-reference-manifest.js +1 -1
  38. package/app/.next/server/app/(dashboard)/dashboard/providers/new/page.js +2 -2
  39. package/app/.next/server/app/(dashboard)/dashboard/providers/new/page.js.nft.json +1 -1
  40. package/app/.next/server/app/(dashboard)/dashboard/providers/new/page_client-reference-manifest.js +1 -1
  41. package/app/.next/server/app/(dashboard)/dashboard/providers/page.js +2 -2
  42. package/app/.next/server/app/(dashboard)/dashboard/providers/page.js.nft.json +1 -1
  43. package/app/.next/server/app/(dashboard)/dashboard/providers/page_client-reference-manifest.js +1 -1
  44. package/app/.next/server/app/(dashboard)/dashboard/proxy-pools/page.js +3 -3
  45. package/app/.next/server/app/(dashboard)/dashboard/proxy-pools/page.js.nft.json +1 -1
  46. package/app/.next/server/app/(dashboard)/dashboard/proxy-pools/page_client-reference-manifest.js +1 -1
  47. package/app/.next/server/app/(dashboard)/dashboard/quota/page.js +2 -2
  48. package/app/.next/server/app/(dashboard)/dashboard/quota/page.js.nft.json +1 -1
  49. package/app/.next/server/app/(dashboard)/dashboard/quota/page_client-reference-manifest.js +1 -1
  50. package/app/.next/server/app/(dashboard)/dashboard/translator/page.js +2 -2
  51. package/app/.next/server/app/(dashboard)/dashboard/translator/page.js.nft.json +1 -1
  52. package/app/.next/server/app/(dashboard)/dashboard/translator/page_client-reference-manifest.js +1 -1
  53. package/app/.next/server/app/(dashboard)/dashboard/usage/page.js +2 -2
  54. package/app/.next/server/app/(dashboard)/dashboard/usage/page.js.nft.json +1 -1
  55. package/app/.next/server/app/(dashboard)/dashboard/usage/page_client-reference-manifest.js +1 -1
  56. package/app/.next/server/app/_global-error/page.js +3 -3
  57. package/app/.next/server/app/_global-error/page_client-reference-manifest.js +1 -1
  58. package/app/.next/server/app/_global-error.html +1 -1
  59. package/app/.next/server/app/_global-error.rsc +1 -1
  60. package/app/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
  61. package/app/.next/server/app/_global-error.segments/_global-error/__PAGE__.segment.rsc +1 -1
  62. package/app/.next/server/app/_global-error.segments/_global-error.segment.rsc +1 -1
  63. package/app/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
  64. package/app/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
  65. package/app/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  66. package/app/.next/server/app/_not-found/page.js +2 -2
  67. package/app/.next/server/app/_not-found/page.js.nft.json +1 -1
  68. package/app/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
  69. package/app/.next/server/app/_not-found.html +1 -1
  70. package/app/.next/server/app/_not-found.rsc +4 -4
  71. package/app/.next/server/app/_not-found.segments/_full.segment.rsc +4 -4
  72. package/app/.next/server/app/_not-found.segments/_head.segment.rsc +1 -1
  73. package/app/.next/server/app/_not-found.segments/_index.segment.rsc +4 -4
  74. package/app/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +1 -1
  75. package/app/.next/server/app/_not-found.segments/_not-found.segment.rsc +1 -1
  76. package/app/.next/server/app/_not-found.segments/_tree.segment.rsc +2 -2
  77. package/app/.next/server/app/api/9remote/install/route.js +1 -1
  78. package/app/.next/server/app/api/9remote/start/route.js +1 -1
  79. package/app/.next/server/app/api/9remote/status/route.js +1 -1
  80. package/app/.next/server/app/api/auth/login/route.js +1 -1
  81. package/app/.next/server/app/api/auth/logout/route.js +1 -1
  82. package/app/.next/server/app/api/cli-tools/antigravity-mitm/alias/route.js +2 -2
  83. package/app/.next/server/app/api/cli-tools/antigravity-mitm/route.js +1 -1
  84. package/app/.next/server/app/api/cli-tools/claude-settings/route.js +2 -2
  85. package/app/.next/server/app/api/cli-tools/codex-settings/route.js +3 -3
  86. package/app/.next/server/app/api/cli-tools/copilot-settings/route.js +2 -2
  87. package/app/.next/server/app/api/cli-tools/droid-settings/route.js +2 -2
  88. package/app/.next/server/app/api/cli-tools/openclaw-settings/route.js +2 -2
  89. package/app/.next/server/app/api/cli-tools/opencode-settings/route.js +1 -1
  90. package/app/.next/server/app/api/cloud/auth/route.js +1 -1
  91. package/app/.next/server/app/api/cloud/credentials/update/route.js +1 -1
  92. package/app/.next/server/app/api/cloud/model/resolve/route.js +1 -1
  93. package/app/.next/server/app/api/cloud/models/alias/route.js +1 -1
  94. package/app/.next/server/app/api/combos/[id]/route.js +1 -1
  95. package/app/.next/server/app/api/combos/route.js +1 -1
  96. package/app/.next/server/app/api/init/route.js +1 -1
  97. package/app/.next/server/app/api/keys/[id]/route.js +1 -1
  98. package/app/.next/server/app/api/keys/route.js +1 -1
  99. package/app/.next/server/app/api/locale/route.js +1 -1
  100. package/app/.next/server/app/api/models/alias/route.js +1 -1
  101. package/app/.next/server/app/api/models/availability/route.js +1 -1
  102. package/app/.next/server/app/api/models/route.js +1 -1
  103. package/app/.next/server/app/api/models/route.js.nft.json +1 -1
  104. package/app/.next/server/app/api/models/test/route.js +1 -1
  105. package/app/.next/server/app/api/oauth/[provider]/[action]/route.js +1 -1
  106. package/app/.next/server/app/api/oauth/cursor/auto-import/route.js +2 -2
  107. package/app/.next/server/app/api/oauth/cursor/import/route.js +1 -1
  108. package/app/.next/server/app/api/oauth/gitlab/pat/route.js +1 -1
  109. package/app/.next/server/app/api/oauth/iflow/cookie/route.js +1 -1
  110. package/app/.next/server/app/api/oauth/kiro/auto-import/route.js +1 -1
  111. package/app/.next/server/app/api/oauth/kiro/import/route.js +1 -1
  112. package/app/.next/server/app/api/oauth/kiro/social-authorize/route.js +1 -1
  113. package/app/.next/server/app/api/oauth/kiro/social-exchange/route.js +1 -1
  114. package/app/.next/server/app/api/pricing/route.js +1 -1
  115. package/app/.next/server/app/api/provider-nodes/[id]/route.js +1 -1
  116. package/app/.next/server/app/api/provider-nodes/route.js +1 -1
  117. package/app/.next/server/app/api/provider-nodes/validate/route.js +1 -1
  118. package/app/.next/server/app/api/providers/[id]/models/route.js +1 -1
  119. package/app/.next/server/app/api/providers/[id]/route.js +1 -1
  120. package/app/.next/server/app/api/providers/[id]/test/route.js +1 -1
  121. package/app/.next/server/app/api/providers/[id]/test-models/route.js +1 -1
  122. package/app/.next/server/app/api/providers/client/route.js +1 -1
  123. package/app/.next/server/app/api/providers/kilo/free-models/route.js +1 -1
  124. package/app/.next/server/app/api/providers/route.js +1 -1
  125. package/app/.next/server/app/api/providers/route.js.nft.json +1 -1
  126. package/app/.next/server/app/api/providers/test-batch/route.js +1 -1
  127. package/app/.next/server/app/api/providers/validate/route.js +1 -1
  128. package/app/.next/server/app/api/proxy-pools/[id]/route.js +1 -1
  129. package/app/.next/server/app/api/proxy-pools/[id]/test/route.js +1 -1
  130. package/app/.next/server/app/api/proxy-pools/route.js +1 -1
  131. package/app/.next/server/app/api/settings/database/route.js +1 -1
  132. package/app/.next/server/app/api/settings/proxy-test/route.js +1 -1
  133. package/app/.next/server/app/api/settings/require-login/route.js +1 -1
  134. package/app/.next/server/app/api/settings/route.js +1 -1
  135. package/app/.next/server/app/api/shutdown/route.js +1 -1
  136. package/app/.next/server/app/api/tags/route.js +1 -1
  137. package/app/.next/server/app/api/translator/console-logs/route.js +1 -1
  138. package/app/.next/server/app/api/translator/console-logs/route.js.nft.json +1 -1
  139. package/app/.next/server/app/api/translator/console-logs/stream/route.js +2 -2
  140. package/app/.next/server/app/api/translator/console-logs/stream/route.js.nft.json +1 -1
  141. package/app/.next/server/app/api/translator/load/route.js +1 -1
  142. package/app/.next/server/app/api/translator/save/route.js +1 -1
  143. package/app/.next/server/app/api/translator/send/route.js +1 -1
  144. package/app/.next/server/app/api/translator/translate/route.js +1 -1
  145. package/app/.next/server/app/api/tunnel/disable/route.js +1 -1
  146. package/app/.next/server/app/api/tunnel/enable/route.js +1 -1
  147. package/app/.next/server/app/api/tunnel/status/route.js +1 -1
  148. package/app/.next/server/app/api/usage/[connectionId]/route.js +1 -1
  149. package/app/.next/server/app/api/usage/chart/route.js +1 -1
  150. package/app/.next/server/app/api/usage/history/route.js +1 -1
  151. package/app/.next/server/app/api/usage/providers/route.js +1 -1
  152. package/app/.next/server/app/api/usage/request-details/route.js +1 -1
  153. package/app/.next/server/app/api/usage/request-logs/route.js +1 -1
  154. package/app/.next/server/app/api/usage/stats/route.js +1 -1
  155. package/app/.next/server/app/api/usage/stream/route.js +2 -2
  156. package/app/.next/server/app/api/v1/api/chat/route.js +1 -1
  157. package/app/.next/server/app/api/v1/chat/completions/route.js +1 -1
  158. package/app/.next/server/app/api/v1/embeddings/route.js +1 -1
  159. package/app/.next/server/app/api/v1/messages/count_tokens/route.js +1 -1
  160. package/app/.next/server/app/api/v1/messages/route.js +1 -1
  161. package/app/.next/server/app/api/v1/models/route.js +1 -1
  162. package/app/.next/server/app/api/v1/responses/route.js +1 -1
  163. package/app/.next/server/app/api/v1/route.js +1 -1
  164. package/app/.next/server/app/api/v1beta/models/[...path]/route.js +1 -1
  165. package/app/.next/server/app/api/v1beta/models/route.js +1 -1
  166. package/app/.next/server/app/api/version/route.js +1 -1
  167. package/app/.next/server/app/callback/page.js +2 -2
  168. package/app/.next/server/app/callback/page.js.nft.json +1 -1
  169. package/app/.next/server/app/callback/page_client-reference-manifest.js +1 -1
  170. package/app/.next/server/app/callback.html +1 -1
  171. package/app/.next/server/app/callback.rsc +5 -5
  172. package/app/.next/server/app/callback.segments/_full.segment.rsc +5 -5
  173. package/app/.next/server/app/callback.segments/_head.segment.rsc +1 -1
  174. package/app/.next/server/app/callback.segments/_index.segment.rsc +4 -4
  175. package/app/.next/server/app/callback.segments/_tree.segment.rsc +2 -2
  176. package/app/.next/server/app/callback.segments/callback/__PAGE__.segment.rsc +2 -2
  177. package/app/.next/server/app/callback.segments/callback.segment.rsc +1 -1
  178. package/app/.next/server/app/dashboard/basic-chat.html +1 -1
  179. package/app/.next/server/app/dashboard/basic-chat.rsc +6 -6
  180. package/app/.next/server/app/dashboard/basic-chat.segments/!KGRhc2hib2FyZCk/dashboard/basic-chat/__PAGE__.segment.rsc +2 -2
  181. package/app/.next/server/app/dashboard/basic-chat.segments/!KGRhc2hib2FyZCk/dashboard/basic-chat.segment.rsc +1 -1
  182. package/app/.next/server/app/dashboard/basic-chat.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  183. package/app/.next/server/app/dashboard/basic-chat.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  184. package/app/.next/server/app/dashboard/basic-chat.segments/_full.segment.rsc +6 -6
  185. package/app/.next/server/app/dashboard/basic-chat.segments/_head.segment.rsc +1 -1
  186. package/app/.next/server/app/dashboard/basic-chat.segments/_index.segment.rsc +4 -4
  187. package/app/.next/server/app/dashboard/basic-chat.segments/_tree.segment.rsc +2 -2
  188. package/app/.next/server/app/dashboard/cli-tools.html +1 -1
  189. package/app/.next/server/app/dashboard/cli-tools.rsc +6 -6
  190. package/app/.next/server/app/dashboard/cli-tools.segments/!KGRhc2hib2FyZCk/dashboard/cli-tools/__PAGE__.segment.rsc +2 -2
  191. package/app/.next/server/app/dashboard/cli-tools.segments/!KGRhc2hib2FyZCk/dashboard/cli-tools.segment.rsc +1 -1
  192. package/app/.next/server/app/dashboard/cli-tools.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  193. package/app/.next/server/app/dashboard/cli-tools.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  194. package/app/.next/server/app/dashboard/cli-tools.segments/_full.segment.rsc +6 -6
  195. package/app/.next/server/app/dashboard/cli-tools.segments/_head.segment.rsc +1 -1
  196. package/app/.next/server/app/dashboard/cli-tools.segments/_index.segment.rsc +4 -4
  197. package/app/.next/server/app/dashboard/cli-tools.segments/_tree.segment.rsc +2 -2
  198. package/app/.next/server/app/dashboard/combos.html +1 -1
  199. package/app/.next/server/app/dashboard/combos.rsc +6 -6
  200. package/app/.next/server/app/dashboard/combos.segments/!KGRhc2hib2FyZCk/dashboard/combos/__PAGE__.segment.rsc +2 -2
  201. package/app/.next/server/app/dashboard/combos.segments/!KGRhc2hib2FyZCk/dashboard/combos.segment.rsc +1 -1
  202. package/app/.next/server/app/dashboard/combos.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  203. package/app/.next/server/app/dashboard/combos.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  204. package/app/.next/server/app/dashboard/combos.segments/_full.segment.rsc +6 -6
  205. package/app/.next/server/app/dashboard/combos.segments/_head.segment.rsc +1 -1
  206. package/app/.next/server/app/dashboard/combos.segments/_index.segment.rsc +4 -4
  207. package/app/.next/server/app/dashboard/combos.segments/_tree.segment.rsc +2 -2
  208. package/app/.next/server/app/dashboard/endpoint.html +1 -1
  209. package/app/.next/server/app/dashboard/endpoint.rsc +6 -6
  210. package/app/.next/server/app/dashboard/endpoint.segments/!KGRhc2hib2FyZCk/dashboard/endpoint/__PAGE__.segment.rsc +2 -2
  211. package/app/.next/server/app/dashboard/endpoint.segments/!KGRhc2hib2FyZCk/dashboard/endpoint.segment.rsc +1 -1
  212. package/app/.next/server/app/dashboard/endpoint.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  213. package/app/.next/server/app/dashboard/endpoint.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  214. package/app/.next/server/app/dashboard/endpoint.segments/_full.segment.rsc +6 -6
  215. package/app/.next/server/app/dashboard/endpoint.segments/_head.segment.rsc +1 -1
  216. package/app/.next/server/app/dashboard/endpoint.segments/_index.segment.rsc +4 -4
  217. package/app/.next/server/app/dashboard/endpoint.segments/_tree.segment.rsc +2 -2
  218. package/app/.next/server/app/dashboard/mitm.html +1 -1
  219. package/app/.next/server/app/dashboard/mitm.rsc +6 -6
  220. package/app/.next/server/app/dashboard/mitm.segments/!KGRhc2hib2FyZCk/dashboard/mitm/__PAGE__.segment.rsc +2 -2
  221. package/app/.next/server/app/dashboard/mitm.segments/!KGRhc2hib2FyZCk/dashboard/mitm.segment.rsc +1 -1
  222. package/app/.next/server/app/dashboard/mitm.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  223. package/app/.next/server/app/dashboard/mitm.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  224. package/app/.next/server/app/dashboard/mitm.segments/_full.segment.rsc +6 -6
  225. package/app/.next/server/app/dashboard/mitm.segments/_head.segment.rsc +1 -1
  226. package/app/.next/server/app/dashboard/mitm.segments/_index.segment.rsc +4 -4
  227. package/app/.next/server/app/dashboard/mitm.segments/_tree.segment.rsc +2 -2
  228. package/app/.next/server/app/dashboard/profile.html +1 -1
  229. package/app/.next/server/app/dashboard/profile.rsc +6 -6
  230. package/app/.next/server/app/dashboard/profile.segments/!KGRhc2hib2FyZCk/dashboard/profile/__PAGE__.segment.rsc +2 -2
  231. package/app/.next/server/app/dashboard/profile.segments/!KGRhc2hib2FyZCk/dashboard/profile.segment.rsc +1 -1
  232. package/app/.next/server/app/dashboard/profile.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  233. package/app/.next/server/app/dashboard/profile.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  234. package/app/.next/server/app/dashboard/profile.segments/_full.segment.rsc +6 -6
  235. package/app/.next/server/app/dashboard/profile.segments/_head.segment.rsc +1 -1
  236. package/app/.next/server/app/dashboard/profile.segments/_index.segment.rsc +4 -4
  237. package/app/.next/server/app/dashboard/profile.segments/_tree.segment.rsc +2 -2
  238. package/app/.next/server/app/dashboard/providers/new.html +1 -1
  239. package/app/.next/server/app/dashboard/providers/new.rsc +6 -6
  240. package/app/.next/server/app/dashboard/providers/new.segments/!KGRhc2hib2FyZCk/dashboard/providers/new/__PAGE__.segment.rsc +2 -2
  241. package/app/.next/server/app/dashboard/providers/new.segments/!KGRhc2hib2FyZCk/dashboard/providers/new.segment.rsc +1 -1
  242. package/app/.next/server/app/dashboard/providers/new.segments/!KGRhc2hib2FyZCk/dashboard/providers.segment.rsc +1 -1
  243. package/app/.next/server/app/dashboard/providers/new.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  244. package/app/.next/server/app/dashboard/providers/new.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  245. package/app/.next/server/app/dashboard/providers/new.segments/_full.segment.rsc +6 -6
  246. package/app/.next/server/app/dashboard/providers/new.segments/_head.segment.rsc +1 -1
  247. package/app/.next/server/app/dashboard/providers/new.segments/_index.segment.rsc +4 -4
  248. package/app/.next/server/app/dashboard/providers/new.segments/_tree.segment.rsc +2 -2
  249. package/app/.next/server/app/dashboard/providers.html +1 -1
  250. package/app/.next/server/app/dashboard/providers.rsc +6 -6
  251. package/app/.next/server/app/dashboard/providers.segments/!KGRhc2hib2FyZCk/dashboard/providers/__PAGE__.segment.rsc +2 -2
  252. package/app/.next/server/app/dashboard/providers.segments/!KGRhc2hib2FyZCk/dashboard/providers.segment.rsc +1 -1
  253. package/app/.next/server/app/dashboard/providers.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  254. package/app/.next/server/app/dashboard/providers.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  255. package/app/.next/server/app/dashboard/providers.segments/_full.segment.rsc +6 -6
  256. package/app/.next/server/app/dashboard/providers.segments/_head.segment.rsc +1 -1
  257. package/app/.next/server/app/dashboard/providers.segments/_index.segment.rsc +4 -4
  258. package/app/.next/server/app/dashboard/providers.segments/_tree.segment.rsc +2 -2
  259. package/app/.next/server/app/dashboard/proxy-pools.html +1 -1
  260. package/app/.next/server/app/dashboard/proxy-pools.rsc +6 -6
  261. package/app/.next/server/app/dashboard/proxy-pools.segments/!KGRhc2hib2FyZCk/dashboard/proxy-pools/__PAGE__.segment.rsc +2 -2
  262. package/app/.next/server/app/dashboard/proxy-pools.segments/!KGRhc2hib2FyZCk/dashboard/proxy-pools.segment.rsc +1 -1
  263. package/app/.next/server/app/dashboard/proxy-pools.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  264. package/app/.next/server/app/dashboard/proxy-pools.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  265. package/app/.next/server/app/dashboard/proxy-pools.segments/_full.segment.rsc +6 -6
  266. package/app/.next/server/app/dashboard/proxy-pools.segments/_head.segment.rsc +1 -1
  267. package/app/.next/server/app/dashboard/proxy-pools.segments/_index.segment.rsc +4 -4
  268. package/app/.next/server/app/dashboard/proxy-pools.segments/_tree.segment.rsc +2 -2
  269. package/app/.next/server/app/dashboard/quota.html +2 -2
  270. package/app/.next/server/app/dashboard/quota.rsc +7 -7
  271. package/app/.next/server/app/dashboard/quota.segments/!KGRhc2hib2FyZCk/dashboard/quota/__PAGE__.segment.rsc +3 -3
  272. package/app/.next/server/app/dashboard/quota.segments/!KGRhc2hib2FyZCk/dashboard/quota.segment.rsc +1 -1
  273. package/app/.next/server/app/dashboard/quota.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  274. package/app/.next/server/app/dashboard/quota.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  275. package/app/.next/server/app/dashboard/quota.segments/_full.segment.rsc +7 -7
  276. package/app/.next/server/app/dashboard/quota.segments/_head.segment.rsc +1 -1
  277. package/app/.next/server/app/dashboard/quota.segments/_index.segment.rsc +4 -4
  278. package/app/.next/server/app/dashboard/quota.segments/_tree.segment.rsc +2 -2
  279. package/app/.next/server/app/dashboard/settings/pricing/page.js +2 -2
  280. package/app/.next/server/app/dashboard/settings/pricing/page.js.nft.json +1 -1
  281. package/app/.next/server/app/dashboard/settings/pricing/page_client-reference-manifest.js +1 -1
  282. package/app/.next/server/app/dashboard/settings/pricing.html +1 -1
  283. package/app/.next/server/app/dashboard/settings/pricing.rsc +5 -5
  284. package/app/.next/server/app/dashboard/settings/pricing.segments/_full.segment.rsc +5 -5
  285. package/app/.next/server/app/dashboard/settings/pricing.segments/_head.segment.rsc +1 -1
  286. package/app/.next/server/app/dashboard/settings/pricing.segments/_index.segment.rsc +4 -4
  287. package/app/.next/server/app/dashboard/settings/pricing.segments/_tree.segment.rsc +2 -2
  288. package/app/.next/server/app/dashboard/settings/pricing.segments/dashboard/settings/pricing/__PAGE__.segment.rsc +2 -2
  289. package/app/.next/server/app/dashboard/settings/pricing.segments/dashboard/settings/pricing.segment.rsc +1 -1
  290. package/app/.next/server/app/dashboard/settings/pricing.segments/dashboard/settings.segment.rsc +1 -1
  291. package/app/.next/server/app/dashboard/settings/pricing.segments/dashboard.segment.rsc +1 -1
  292. package/app/.next/server/app/dashboard/translator.html +1 -1
  293. package/app/.next/server/app/dashboard/translator.rsc +6 -6
  294. package/app/.next/server/app/dashboard/translator.segments/!KGRhc2hib2FyZCk/dashboard/translator/__PAGE__.segment.rsc +2 -2
  295. package/app/.next/server/app/dashboard/translator.segments/!KGRhc2hib2FyZCk/dashboard/translator.segment.rsc +1 -1
  296. package/app/.next/server/app/dashboard/translator.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  297. package/app/.next/server/app/dashboard/translator.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  298. package/app/.next/server/app/dashboard/translator.segments/_full.segment.rsc +6 -6
  299. package/app/.next/server/app/dashboard/translator.segments/_head.segment.rsc +1 -1
  300. package/app/.next/server/app/dashboard/translator.segments/_index.segment.rsc +4 -4
  301. package/app/.next/server/app/dashboard/translator.segments/_tree.segment.rsc +2 -2
  302. package/app/.next/server/app/dashboard/usage.html +1 -1
  303. package/app/.next/server/app/dashboard/usage.rsc +6 -6
  304. package/app/.next/server/app/dashboard/usage.segments/!KGRhc2hib2FyZCk/dashboard/usage/__PAGE__.segment.rsc +2 -2
  305. package/app/.next/server/app/dashboard/usage.segments/!KGRhc2hib2FyZCk/dashboard/usage.segment.rsc +1 -1
  306. package/app/.next/server/app/dashboard/usage.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  307. package/app/.next/server/app/dashboard/usage.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  308. package/app/.next/server/app/dashboard/usage.segments/_full.segment.rsc +6 -6
  309. package/app/.next/server/app/dashboard/usage.segments/_head.segment.rsc +1 -1
  310. package/app/.next/server/app/dashboard/usage.segments/_index.segment.rsc +4 -4
  311. package/app/.next/server/app/dashboard/usage.segments/_tree.segment.rsc +2 -2
  312. package/app/.next/server/app/dashboard.html +1 -1
  313. package/app/.next/server/app/dashboard.rsc +6 -6
  314. package/app/.next/server/app/dashboard.segments/!KGRhc2hib2FyZCk/dashboard/__PAGE__.segment.rsc +2 -2
  315. package/app/.next/server/app/dashboard.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  316. package/app/.next/server/app/dashboard.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  317. package/app/.next/server/app/dashboard.segments/_full.segment.rsc +6 -6
  318. package/app/.next/server/app/dashboard.segments/_head.segment.rsc +1 -1
  319. package/app/.next/server/app/dashboard.segments/_index.segment.rsc +4 -4
  320. package/app/.next/server/app/dashboard.segments/_tree.segment.rsc +2 -2
  321. package/app/.next/server/app/favicon.ico/route.js +1 -1
  322. package/app/.next/server/app/index.html +1 -1
  323. package/app/.next/server/app/index.rsc +4 -4
  324. package/app/.next/server/app/index.segments/__PAGE__.segment.rsc +1 -1
  325. package/app/.next/server/app/index.segments/_full.segment.rsc +4 -4
  326. package/app/.next/server/app/index.segments/_head.segment.rsc +1 -1
  327. package/app/.next/server/app/index.segments/_index.segment.rsc +4 -4
  328. package/app/.next/server/app/index.segments/_tree.segment.rsc +2 -2
  329. package/app/.next/server/app/landing/page.js +2 -2
  330. package/app/.next/server/app/landing/page.js.nft.json +1 -1
  331. package/app/.next/server/app/landing/page_client-reference-manifest.js +1 -1
  332. package/app/.next/server/app/landing.html +1 -1
  333. package/app/.next/server/app/landing.rsc +5 -5
  334. package/app/.next/server/app/landing.segments/_full.segment.rsc +5 -5
  335. package/app/.next/server/app/landing.segments/_head.segment.rsc +1 -1
  336. package/app/.next/server/app/landing.segments/_index.segment.rsc +4 -4
  337. package/app/.next/server/app/landing.segments/_tree.segment.rsc +2 -2
  338. package/app/.next/server/app/landing.segments/landing/__PAGE__.segment.rsc +2 -2
  339. package/app/.next/server/app/landing.segments/landing.segment.rsc +1 -1
  340. package/app/.next/server/app/login/page.js +2 -2
  341. package/app/.next/server/app/login/page.js.nft.json +1 -1
  342. package/app/.next/server/app/login/page_client-reference-manifest.js +1 -1
  343. package/app/.next/server/app/login.html +1 -1
  344. package/app/.next/server/app/login.rsc +5 -5
  345. package/app/.next/server/app/login.segments/_full.segment.rsc +5 -5
  346. package/app/.next/server/app/login.segments/_head.segment.rsc +1 -1
  347. package/app/.next/server/app/login.segments/_index.segment.rsc +4 -4
  348. package/app/.next/server/app/login.segments/_tree.segment.rsc +2 -2
  349. package/app/.next/server/app/login.segments/login/__PAGE__.segment.rsc +2 -2
  350. package/app/.next/server/app/login.segments/login.segment.rsc +1 -1
  351. package/app/.next/server/app/manifest.webmanifest/route.js +2 -2
  352. package/app/.next/server/app/page.js +2 -2
  353. package/app/.next/server/app/page.js.nft.json +1 -1
  354. package/app/.next/server/app/page_client-reference-manifest.js +1 -1
  355. package/app/.next/server/app-paths-manifest.json +6 -4
  356. package/app/.next/server/chunks/1006.js +1 -0
  357. package/app/.next/server/chunks/1021.js +2 -2
  358. package/app/.next/server/chunks/1249.js +1 -1
  359. package/app/.next/server/chunks/126.js +2 -2
  360. package/app/.next/server/chunks/1574.js +1 -1
  361. package/app/.next/server/chunks/1578.js +1 -1
  362. package/app/.next/server/chunks/2049.js +1 -1
  363. package/app/.next/server/chunks/2371.js +1 -1
  364. package/app/.next/server/chunks/242.js +1 -1
  365. package/app/.next/server/chunks/3437.js +1 -1
  366. package/app/.next/server/chunks/450.js +1 -1
  367. package/app/.next/server/chunks/4891.js +1 -1
  368. package/app/.next/server/chunks/514.js +2 -2
  369. package/app/.next/server/chunks/6379.js +2 -2
  370. package/app/.next/server/chunks/7770.js +1 -1
  371. package/app/.next/server/chunks/8202.js +8 -8
  372. package/app/.next/server/chunks/9489.js +1 -0
  373. package/app/.next/server/middleware-build-manifest.js +1 -1
  374. package/app/.next/server/middleware.js +2 -2
  375. package/app/.next/server/pages/404.html +1 -1
  376. package/app/.next/server/pages/500.html +1 -1
  377. package/app/.next/static/{_qgNKf11lJ14fXVq78FHz → Ww_6kqPqPWlQlt6zRVg8A}/_buildManifest.js +1 -1
  378. package/app/.next/static/chunks/2599-ef3aca3d4fdaa96d.js +1 -0
  379. package/app/.next/static/chunks/4156-3f71ff6f6ba6ba05.js +7 -0
  380. package/app/.next/static/chunks/505-89a51ca9c483211d.js +1 -0
  381. package/app/.next/static/chunks/{7400-50da1ed150e33a12.js → 7400-a5c928f6fdd4565c.js} +2 -2
  382. package/app/.next/static/chunks/{8035-50a417d15f2c7add.js → 8035-20ab85a50b665aaf.js} +2 -2
  383. package/app/.next/static/chunks/{8038-eb05e7b987bf8682.js → 8038-368cfbdf9080110b.js} +1 -1
  384. package/app/.next/static/chunks/app/(dashboard)/dashboard/basic-chat/{page-0435d33448929432.js → page-2c8c481b0fc0bb1b.js} +1 -1
  385. package/app/.next/static/chunks/app/(dashboard)/dashboard/cli-tools/{page-0c8d84a9902c82cd.js → page-6af679bf1de2bcd0.js} +1 -1
  386. package/app/.next/static/chunks/app/(dashboard)/dashboard/combos/{page-aae6d82cc06c63dc.js → page-d0ee61fa81abf27e.js} +1 -1
  387. package/app/.next/static/chunks/app/(dashboard)/dashboard/console-log/{page-a71f0b04cec6ce33.js → page-2ffb4689f161ca33.js} +1 -1
  388. package/app/.next/static/chunks/app/(dashboard)/dashboard/endpoint/page-0b58256fd5ccd8b7.js +1 -0
  389. package/app/.next/static/chunks/app/(dashboard)/dashboard/media-providers/[kind]/[id]/page-6c1c6a107653ebda.js +1 -0
  390. package/app/.next/static/chunks/app/(dashboard)/dashboard/media-providers/[kind]/page-a01336ce4983ff58.js +1 -0
  391. package/app/.next/static/chunks/app/(dashboard)/dashboard/mitm/{page-51b86e47f0596937.js → page-7985d81ed92c1758.js} +1 -1
  392. package/app/.next/static/chunks/app/(dashboard)/dashboard/page-9533adb8cd2aa0ac.js +1 -0
  393. package/app/.next/static/chunks/app/(dashboard)/dashboard/profile/{page-8b6cb89a4a896f1d.js → page-354de24a25e94694.js} +1 -1
  394. package/app/.next/static/chunks/app/(dashboard)/dashboard/providers/[id]/page-48b389fbdc1f0080.js +1 -0
  395. package/app/.next/static/chunks/app/(dashboard)/dashboard/providers/new/{page-c37f77536819f259.js → page-426e797917337fd8.js} +1 -1
  396. package/app/.next/static/chunks/app/(dashboard)/dashboard/providers/page-9d13181d51f5e656.js +1 -0
  397. package/app/.next/static/chunks/app/(dashboard)/dashboard/proxy-pools/{page-6db708ca87ef8001.js → page-44d61ed9744d1025.js} +1 -1
  398. package/app/.next/static/chunks/app/(dashboard)/dashboard/quota/page-61704bd0d8bd2bdf.js +1 -0
  399. package/app/.next/static/chunks/app/(dashboard)/dashboard/translator/{page-ea7b3c29209f09f9.js → page-82c184348fd5c917.js} +1 -1
  400. package/app/.next/static/chunks/app/(dashboard)/dashboard/usage/{page-a8264365768d0e3f.js → page-ac2806ccdfd6ecae.js} +1 -1
  401. package/app/.next/static/chunks/app/(dashboard)/layout-28cec0ea8271c92a.js +1 -0
  402. package/app/.next/static/chunks/app/callback/page-80c520a5e353c3ac.js +1 -0
  403. package/app/.next/static/chunks/app/dashboard/settings/pricing/page-d9a2df5b3f666b3b.js +1 -0
  404. package/app/.next/static/chunks/app/layout-c47481f46f5ae72b.js +1 -0
  405. package/app/.next/static/chunks/app/login/{page-4db7bca8c7eaced7.js → page-c0d5d5c52ff7317f.js} +1 -1
  406. package/app/.next/static/css/5ed5a95fa0b29325.css +1 -0
  407. package/app/package.json +1 -1
  408. package/app/src/mitm/server.js +1 -1
  409. package/package.json +1 -1
  410. package/app/.next/server/chunks/7134.js +0 -1
  411. package/app/.next/static/chunks/2599-8f4e92ca3efe2987.js +0 -1
  412. package/app/.next/static/chunks/350-5598fb3601dca0c9.js +0 -1
  413. package/app/.next/static/chunks/4156-f8e9c6334c5964b1.js +0 -7
  414. package/app/.next/static/chunks/app/(dashboard)/dashboard/endpoint/page-c5de25b2450ef326.js +0 -1
  415. package/app/.next/static/chunks/app/(dashboard)/dashboard/page-b7f6d0ad91fad565.js +0 -1
  416. package/app/.next/static/chunks/app/(dashboard)/dashboard/providers/[id]/page-a8c26437a17c1428.js +0 -1
  417. package/app/.next/static/chunks/app/(dashboard)/dashboard/providers/page-4d3ee7c24d230edc.js +0 -1
  418. package/app/.next/static/chunks/app/(dashboard)/dashboard/quota/page-dcc45476a839f9bc.js +0 -1
  419. package/app/.next/static/chunks/app/(dashboard)/layout-3cb0ade24c0d3292.js +0 -1
  420. package/app/.next/static/chunks/app/callback/page-0b1aadd71bae5ed3.js +0 -1
  421. package/app/.next/static/chunks/app/dashboard/settings/pricing/page-18b73be8f4ae3bf2.js +0 -1
  422. package/app/.next/static/chunks/app/layout-76aaa65ecb33e97d.js +0 -1
  423. package/app/.next/static/css/bb060fc0f56debfe.css +0 -1
  424. /package/app/.next/static/{_qgNKf11lJ14fXVq78FHz → Ww_6kqPqPWlQlt6zRVg8A}/_ssgManifest.js +0 -0
@@ -1 +1 @@
1
- (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[9089],{57047:(e,r,t)=>{"use strict";t.r(r),t.d(r,{default:()=>u});var a=t(73365),s=t(1521),i=t(29717),l=t(99568),d=t.n(l),o=t(74156),n=t(43202);let c=Object.values(n.Q2).map(e=>({value:e.id,label:e.name})),p=Object.values(n.MA).map(e=>({value:e.id,label:e.name}));function u(){let e=(0,i.useRouter)(),[r,t]=(0,s.useState)(!1),[l,u]=(0,s.useState)({provider:"",authMethod:"api_key",apiKey:"",displayName:"",isActive:!0}),[h,m]=(0,s.useState)({}),x=(e,r)=>{u(t=>({...t,[e]:r})),h[e]&&m(r=>({...r,[e]:null}))},b=async r=>{let a;if(r.preventDefault(),a={},l.provider||(a.provider="Please select a provider"),"api_key"!==l.authMethod||l.apiKey||(a.apiKey="API Key is required"),m(a),0===Object.keys(a).length){t(!0);try{let r=await fetch("/api/providers",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(l)});if(r.ok)e.push("/dashboard/providers");else{let e=await r.json();m({submit:e.error||"Failed to create provider"})}}catch(e){m({submit:"An error occurred. Please try again."})}finally{t(!1)}}},v=n.Q2[l.provider];return(0,a.jsxs)("div",{className:"max-w-2xl mx-auto",children:[(0,a.jsxs)("div",{className:"mb-8",children:[(0,a.jsxs)(d(),{href:"/dashboard/providers",className:"inline-flex items-center gap-1 text-sm text-text-muted hover:text-primary transition-colors mb-4",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-lg",children:"arrow_back"}),"Back to Providers"]}),(0,a.jsx)("h1",{className:"text-3xl font-semibold tracking-tight",children:"Add New Provider"}),(0,a.jsx)("p",{className:"text-text-muted mt-2",children:"Configure a new AI provider to use with your applications."})]}),(0,a.jsx)(o.Zp,{children:(0,a.jsxs)("form",{onSubmit:b,className:"flex flex-col gap-6",children:[(0,a.jsx)(o.l6,{label:"Provider",options:c,value:l.provider,onChange:e=>x("provider",e.target.value),placeholder:"Select a provider",error:h.provider,required:!0}),v&&(0,a.jsxs)(o.Zp.Section,{className:"flex items-center gap-3",children:[(0,a.jsx)("div",{className:"size-10 rounded-lg flex items-center justify-center bg-bg border border-border",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-xl",style:{color:v.color},children:v.icon})}),(0,a.jsxs)("div",{children:[(0,a.jsx)("p",{className:"font-medium",children:v.name}),(0,a.jsx)("p",{className:"text-sm text-text-muted",children:"Selected provider"})]})]}),(0,a.jsxs)("div",{className:"flex flex-col gap-3",children:[(0,a.jsxs)("label",{className:"text-sm font-medium",children:["Authentication Method ",(0,a.jsx)("span",{className:"text-red-500",children:"*"})]}),(0,a.jsx)("div",{className:"flex gap-3",children:p.map(e=>(0,a.jsxs)("button",{type:"button",onClick:()=>x("authMethod",e.value),className:`flex-1 flex items-center justify-center gap-2 p-4 rounded-lg border transition-all ${l.authMethod===e.value?"border-primary bg-primary/5 text-primary":"border-border hover:border-primary/50"}`,children:[(0,a.jsx)("span",{className:"material-symbols-outlined",children:"api_key"===e.value?"key":"lock"}),(0,a.jsx)("span",{className:"font-medium",children:e.label})]},e.value))})]}),"api_key"===l.authMethod&&(0,a.jsx)(o.pd,{label:"API Key",type:"password",placeholder:"Enter your API key",value:l.apiKey,onChange:e=>x("apiKey",e.target.value),error:h.apiKey,hint:"Your API key will be encrypted and stored securely.",required:!0}),"oauth2"===l.authMethod&&(0,a.jsxs)(o.Zp.Section,{children:[(0,a.jsx)("p",{className:"text-sm text-text-muted mb-4",children:"Connect your account using OAuth2 authentication."}),(0,a.jsx)(o.$n,{type:"button",variant:"secondary",icon:"link",children:"Connect with OAuth2"})]}),(0,a.jsx)(o.pd,{label:"Display Name",placeholder:"e.g., Production API, Dev Environment",value:l.displayName,onChange:e=>x("displayName",e.target.value),hint:"Optional. A friendly name to identify this configuration."}),(0,a.jsx)(o.lM,{checked:l.isActive,onChange:e=>x("isActive",e),label:"Active",description:"Enable this provider for use in your applications"}),h.submit&&(0,a.jsx)("div",{className:"p-4 rounded-lg bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 text-red-600 dark:text-red-400 text-sm",children:h.submit}),(0,a.jsxs)("div",{className:"flex gap-3 pt-4 border-t border-border",children:[(0,a.jsx)(d(),{href:"/dashboard/providers",className:"flex-1",children:(0,a.jsx)(o.$n,{type:"button",variant:"ghost",fullWidth:!0,children:"Cancel"})}),(0,a.jsx)(o.$n,{type:"submit",loading:r,fullWidth:!0,className:"flex-1",children:"Create Provider"})]})]})})]})}},95936:(e,r,t)=>{Promise.resolve().then(t.bind(t,57047))}},e=>{e.O(0,[7848,4335,2599,350,4156,2347,5158,7358],()=>e(e.s=95936)),_N_E=e.O()}]);
1
+ (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[9089],{57047:(e,r,t)=>{"use strict";t.r(r),t.d(r,{default:()=>u});var a=t(73365),s=t(1521),i=t(29717),l=t(99568),d=t.n(l),o=t(74156),n=t(43202);let c=Object.values(n.Q2).map(e=>({value:e.id,label:e.name})),p=Object.values(n.MA).map(e=>({value:e.id,label:e.name}));function u(){let e=(0,i.useRouter)(),[r,t]=(0,s.useState)(!1),[l,u]=(0,s.useState)({provider:"",authMethod:"api_key",apiKey:"",displayName:"",isActive:!0}),[h,m]=(0,s.useState)({}),x=(e,r)=>{u(t=>({...t,[e]:r})),h[e]&&m(r=>({...r,[e]:null}))},b=async r=>{let a;if(r.preventDefault(),a={},l.provider||(a.provider="Please select a provider"),"api_key"!==l.authMethod||l.apiKey||(a.apiKey="API Key is required"),m(a),0===Object.keys(a).length){t(!0);try{let r=await fetch("/api/providers",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(l)});if(r.ok)e.push("/dashboard/providers");else{let e=await r.json();m({submit:e.error||"Failed to create provider"})}}catch(e){m({submit:"An error occurred. Please try again."})}finally{t(!1)}}},v=n.Q2[l.provider];return(0,a.jsxs)("div",{className:"max-w-2xl mx-auto",children:[(0,a.jsxs)("div",{className:"mb-8",children:[(0,a.jsxs)(d(),{href:"/dashboard/providers",className:"inline-flex items-center gap-1 text-sm text-text-muted hover:text-primary transition-colors mb-4",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-lg",children:"arrow_back"}),"Back to Providers"]}),(0,a.jsx)("h1",{className:"text-3xl font-semibold tracking-tight",children:"Add New Provider"}),(0,a.jsx)("p",{className:"text-text-muted mt-2",children:"Configure a new AI provider to use with your applications."})]}),(0,a.jsx)(o.Zp,{children:(0,a.jsxs)("form",{onSubmit:b,className:"flex flex-col gap-6",children:[(0,a.jsx)(o.l6,{label:"Provider",options:c,value:l.provider,onChange:e=>x("provider",e.target.value),placeholder:"Select a provider",error:h.provider,required:!0}),v&&(0,a.jsxs)(o.Zp.Section,{className:"flex items-center gap-3",children:[(0,a.jsx)("div",{className:"size-10 rounded-lg flex items-center justify-center bg-bg border border-border",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-xl",style:{color:v.color},children:v.icon})}),(0,a.jsxs)("div",{children:[(0,a.jsx)("p",{className:"font-medium",children:v.name}),(0,a.jsx)("p",{className:"text-sm text-text-muted",children:"Selected provider"})]})]}),(0,a.jsxs)("div",{className:"flex flex-col gap-3",children:[(0,a.jsxs)("label",{className:"text-sm font-medium",children:["Authentication Method ",(0,a.jsx)("span",{className:"text-red-500",children:"*"})]}),(0,a.jsx)("div",{className:"flex gap-3",children:p.map(e=>(0,a.jsxs)("button",{type:"button",onClick:()=>x("authMethod",e.value),className:`flex-1 flex items-center justify-center gap-2 p-4 rounded-lg border transition-all ${l.authMethod===e.value?"border-primary bg-primary/5 text-primary":"border-border hover:border-primary/50"}`,children:[(0,a.jsx)("span",{className:"material-symbols-outlined",children:"api_key"===e.value?"key":"lock"}),(0,a.jsx)("span",{className:"font-medium",children:e.label})]},e.value))})]}),"api_key"===l.authMethod&&(0,a.jsx)(o.pd,{label:"API Key",type:"password",placeholder:"Enter your API key",value:l.apiKey,onChange:e=>x("apiKey",e.target.value),error:h.apiKey,hint:"Your API key will be encrypted and stored securely.",required:!0}),"oauth2"===l.authMethod&&(0,a.jsxs)(o.Zp.Section,{children:[(0,a.jsx)("p",{className:"text-sm text-text-muted mb-4",children:"Connect your account using OAuth2 authentication."}),(0,a.jsx)(o.$n,{type:"button",variant:"secondary",icon:"link",children:"Connect with OAuth2"})]}),(0,a.jsx)(o.pd,{label:"Display Name",placeholder:"e.g., Production API, Dev Environment",value:l.displayName,onChange:e=>x("displayName",e.target.value),hint:"Optional. A friendly name to identify this configuration."}),(0,a.jsx)(o.lM,{checked:l.isActive,onChange:e=>x("isActive",e),label:"Active",description:"Enable this provider for use in your applications"}),h.submit&&(0,a.jsx)("div",{className:"p-4 rounded-lg bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 text-red-600 dark:text-red-400 text-sm",children:h.submit}),(0,a.jsxs)("div",{className:"flex gap-3 pt-4 border-t border-border",children:[(0,a.jsx)(d(),{href:"/dashboard/providers",className:"flex-1",children:(0,a.jsx)(o.$n,{type:"button",variant:"ghost",fullWidth:!0,children:"Cancel"})}),(0,a.jsx)(o.$n,{type:"submit",loading:r,fullWidth:!0,className:"flex-1",children:"Create Provider"})]})]})})]})}},95936:(e,r,t)=>{Promise.resolve().then(t.bind(t,57047))}},e=>{e.O(0,[7848,4335,2599,505,4156,2347,5158,7358],()=>e(e.s=95936)),_N_E=e.O()}]);
@@ -0,0 +1 @@
1
+ (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[8460],{43007:(e,t,s)=>{Promise.resolve().then(s.bind(s,69692))},69692:(e,t,s)=>{"use strict";s.r(t),s.d(t,{default:()=>b});var r=s(73365),a=s(1521),l=s(86447),i=s.n(l),n=s(74156),o=s(68266),d=s(43202),c=s(82495),p=s(99568),m=s.n(p),x=s(14793);let u={available:{icon:"check_circle",color:"#22c55e",label:"Available"},cooldown:{icon:"schedule",color:"#f59e0b",label:"Cooldown"},unavailable:{icon:"error",color:"#ef4444",label:"Unavailable"},unknown:{icon:"help",color:"#6b7280",label:"Unknown"}};function h(){let[e,t]=(0,a.useState)(null),[s,l]=(0,a.useState)(!0),[i,o]=(0,a.useState)(!1),[d,c]=(0,a.useState)(null),p=(0,a.useRef)(null),m=(0,x.i)(),h=(0,a.useCallback)(async()=>{try{let e=await fetch("/api/models/availability");if(e.ok){let s=await e.json();t(s)}}catch{}finally{l(!1)}},[]);(0,a.useEffect)(()=>{h();let e=setInterval(h,3e4);return()=>clearInterval(e)},[h]),(0,a.useEffect)(()=>{let e=e=>{p.current&&!p.current.contains(e.target)&&o(!1)};return i&&document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[i]);let f=async(e,t)=>{c(`${e}:${t}`);try{(await fetch("/api/models/availability",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"clearCooldown",provider:e,model:t})})).ok?(m.success(`Cooldown cleared for ${t}`),await h()):m.error("Failed to clear cooldown")}catch{m.error("Failed to clear cooldown")}finally{c(null)}};if(s)return null;let b=e?.models||[],v=0===(e?.unavailableCount||b.filter(e=>"available"!==e.status).length),g={};return b.forEach(e=>{if("available"===e.status)return;let t=e.provider||"unknown";g[t]||(g[t]=[]),g[t].push(e)}),(0,r.jsx)("div",{className:"relative",ref:p,children:i&&(0,r.jsxs)("div",{className:"absolute top-full right-0 mt-2 w-80 bg-surface border border-border rounded-xl shadow-2xl z-50 overflow-hidden",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border bg-bg",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("span",{className:"material-symbols-outlined text-[16px]",style:{color:v?"#22c55e":"#f59e0b"},children:v?"verified":"warning"}),(0,r.jsx)("span",{className:"text-sm font-semibold text-text-main",children:"Model Status"})]}),(0,r.jsx)("button",{onClick:h,className:"p-1 rounded-lg hover:bg-surface text-text-muted hover:text-text-main transition-colors",title:"Refresh",children:(0,r.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"refresh"})})]}),(0,r.jsx)("div",{className:"px-4 py-3 max-h-60 overflow-y-auto",children:v?(0,r.jsx)("p",{className:"text-sm text-text-muted text-center py-2",children:"All models are responding normally."}):(0,r.jsx)("div",{className:"flex flex-col gap-2.5",children:Object.entries(g).map(([e,t])=>(0,r.jsxs)("div",{children:[(0,r.jsx)("p",{className:"text-xs font-semibold text-text-main mb-1.5 capitalize",children:e}),(0,r.jsx)("div",{className:"flex flex-col gap-1",children:t.map(e=>{let t=u[e.status]||u.unknown,s=d===`${e.provider}:${e.model}`;return(0,r.jsxs)("div",{className:"flex items-center justify-between px-2.5 py-1.5 rounded-lg bg-surface/30",children:[(0,r.jsxs)("div",{className:"flex items-center gap-1.5 min-w-0",children:[(0,r.jsx)("span",{className:"material-symbols-outlined text-[14px] shrink-0",style:{color:t.color},children:t.icon}),(0,r.jsx)("span",{className:"font-mono text-xs text-text-main truncate",children:e.model})]}),"cooldown"===e.status&&(0,r.jsx)(n.$n,{size:"sm",variant:"ghost",onClick:()=>f(e.provider,e.model),disabled:s,className:"text-[10px] px-1.5! py-0.5! ml-2",children:s?"...":"Clear"})]},`${e.provider}-${e.model}`)})})]},e))})})]})})}function f(e,t,s){let a=[];if(e>0&&a.push((0,r.jsxs)(n.Ex,{variant:"success",size:"sm",dot:!0,children:[e," Connected"]},"connected")),t>0){let e=s?`${t} Error (${s})`:`${t} Error`;a.push((0,r.jsx)(n.Ex,{variant:"error",size:"sm",dot:!0,children:e},"error"))}return 0===a.length?(0,r.jsx)("span",{className:"text-text-muted",children:"No connections"}):a}function b(){let[e,t]=(0,a.useState)([]),[s,l]=(0,a.useState)([]),[i,o]=(0,a.useState)(!0),[p,m]=(0,a.useState)(!1),[u,f]=(0,a.useState)(!1),[b,C]=(0,a.useState)(null),[k,T]=(0,a.useState)(null),w=(0,x.i)();(0,a.useEffect)(()=>{(async()=>{try{let[e,s]=await Promise.all([fetch("/api/providers"),fetch("/api/provider-nodes")]),r=await e.json(),a=await s.json();e.ok&&t(r.connections||[]),s.ok&&l(a.nodes||[])}catch(e){console.log("Error fetching data:",e)}finally{o(!1)}})()},[]);let A=(t,s)=>{let r=e.filter(e=>e.provider===t&&e.authType===s),a=e=>{let t=Object.entries(e).some(([e,t])=>e.startsWith("modelLock_")&&t&&new Date(t).getTime()>Date.now());return"unavailable"!==e.testStatus||t?e.testStatus:"active"},l=r.filter(e=>{let t=a(e);return"active"===t||"success"===t}).length,i=r.filter(e=>{let t=a(e);return"error"===t||"expired"===t||"unavailable"===t}),n=i.length,o=r.length,d=o>0&&r.every(e=>!1===e.isActive),c=i.sort((e,t)=>new Date(t.lastErrorAt||0)-new Date(e.lastErrorAt||0))[0];return{connected:l,error:n,total:o,errorCode:c?function(e){if(!e)return null;let t=e.lastErrorType;if("runtime_error"===t)return"RUNTIME";if("upstream_auth_error"===t||"auth_missing"===t||"token_refresh_failed"===t||"token_expired"===t)return"AUTH";if("upstream_rate_limited"===t)return"429";if("upstream_unavailable"===t)return"5XX";if("network_error"===t)return"NET";let s=Number(e.errorCode);if(Number.isFinite(s)&&s>=400)return String(s);let r=function(e){if(!e)return null;let t=e.match(/\b([45]\d{2})\b/);return t?t[1]:"ERR"}(e.lastError);if("401"===r||"403"===r)return"AUTH";if(r&&"ERR"!==r)return r;let a=(e.lastError||"").toLowerCase();return a.includes("runtime")||a.includes("not runnable")||a.includes("not installed")?"RUNTIME":a.includes("invalid api key")||a.includes("token invalid")||a.includes("revoked")||a.includes("unauthorized")?"AUTH":"ERR"}(c):null,errorTime:c?.lastErrorAt?function(e){if(!e)return"";let t=Math.floor((Date.now()-new Date(e).getTime())/6e4);if(t<1)return"just now";if(t<60)return`${t}m ago`;let s=Math.floor(t/60);if(s<24)return`${s}h ago`;let r=Math.floor(s/24);return`${r}d ago`}(c.lastErrorAt):null,allDisabled:d}},I=async(s,r,a)=>{let l=e.filter(e=>e.provider===s&&e.authType===r);t(e=>e.map(e=>e.provider===s&&e.authType===r?{...e,isActive:a}:e)),await Promise.allSettled(l.map(e=>fetch(`/api/providers/${e.id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({isActive:a})})))},$=async(e,t=null)=>{if(!b){C("provider"===e?t:e),T(null);try{let s=await fetch("/api/providers/test-batch",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mode:e,providerId:t})}),r=await s.json();if(T(r),r.summary){let{passed:e,failed:t,total:s}=r.summary;0===t?w.success(`All ${s} tests passed`):w.warning(`${e}/${s} passed, ${t} failed`)}}catch(e){T({error:"Test request failed"}),w.error("Provider test failed")}finally{C(null)}}},E=s.filter(e=>"openai-compatible"===e.type).map(e=>({id:e.id,name:e.name||"OpenAI Compatible",color:"#10A37F",textIcon:"OC",apiType:e.apiType})),S=s.filter(e=>"anthropic-compatible"===e.type).map(e=>({id:e.id,name:e.name||"Anthropic Compatible",color:"#D97757",textIcon:"AC"}));return i?(0,r.jsxs)("div",{className:"flex flex-col gap-8",children:[(0,r.jsx)(n.Qv,{}),(0,r.jsx)(n.Qv,{})]}):(0,r.jsxs)("div",{className:"flex flex-col gap-6",children:[(0,r.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between",children:[(0,r.jsx)("h2",{className:"text-xl font-semibold flex items-center gap-2",children:"OAuth Providers"}),(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)(h,{}),(0,r.jsxs)("button",{onClick:()=>$("oauth"),disabled:!!b,className:`flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-xs font-medium border transition-colors ${"oauth"===b?"bg-primary/20 border-primary/40 text-primary animate-pulse":"bg-bg border-border text-text-muted hover:text-text-main hover:border-primary/40"}`,title:"Test all OAuth connections","aria-label":"Test all OAuth connections",children:[(0,r.jsx)("span",{className:`material-symbols-outlined text-[14px]${"oauth"===b?" animate-spin":""}`,children:"oauth"===b?"sync":"play_arrow"}),"oauth"===b?"Testing...":"Test All"]})]})]}),(0,r.jsx)("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-4",children:Object.entries(d.zN).map(([e,t])=>(0,r.jsx)(v,{providerId:e,provider:t,stats:A(e,"oauth"),authType:"oauth",onToggle:t=>I(e,"oauth",t)},e))})]}),(0,r.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between",children:[(0,r.jsx)("h2",{className:"text-xl font-semibold flex items-center gap-2",children:"Free & Free Tier Providers"}),(0,r.jsxs)("button",{onClick:()=>$("free"),disabled:!!b,className:`flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-xs font-medium border transition-colors ${"free"===b?"bg-primary/20 border-primary/40 text-primary animate-pulse":"bg-bg border-border text-text-muted hover:text-text-main hover:border-primary/40"}`,title:"Test all Free connections","aria-label":"Test all Free provider connections",children:[(0,r.jsx)("span",{className:`material-symbols-outlined text-[14px]${"free"===b?" animate-spin":""}`,children:"free"===b?"sync":"play_arrow"}),"free"===b?"Testing...":"Test All"]})]}),(0,r.jsxs)("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-4",children:[Object.entries(c.IS).map(([e,t])=>(0,r.jsx)(v,{providerId:e,provider:t,stats:A(e,"oauth"),authType:"free",onToggle:t=>I(e,"oauth",t)},e)),Object.entries(c.nJ).map(([e,t])=>(0,r.jsx)(g,{providerId:e,provider:t,stats:A(e,"apikey"),authType:"apikey",onToggle:t=>I(e,"apikey",t)},e))]})]}),(0,r.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between",children:[(0,r.jsxs)("h2",{className:"text-xl font-semibold flex items-center gap-2",children:["API Key Providers"," "]}),(0,r.jsxs)("button",{onClick:()=>$("apikey"),disabled:!!b,className:`flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-xs font-medium border transition-colors ${"apikey"===b?"bg-primary/20 border-primary/40 text-primary animate-pulse":"bg-bg border-border text-text-muted hover:text-text-main hover:border-primary/40"}`,title:"Test all API Key connections","aria-label":"Test all API Key connections",children:[(0,r.jsx)("span",{className:`material-symbols-outlined text-[14px]${"apikey"===b?" animate-spin":""}`,children:"apikey"===b?"sync":"play_arrow"}),"apikey"===b?"Testing...":"Test All"]})]}),(0,r.jsx)("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-4",children:Object.entries(d.fg).filter(([,e])=>(e.serviceKinds??["llm"]).includes("llm")).map(([e,t])=>(0,r.jsx)(g,{providerId:e,provider:t,stats:A(e,"apikey"),authType:"apikey",onToggle:t=>I(e,"apikey",t)},e))})]}),(0,r.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between",children:[(0,r.jsxs)("h2",{className:"text-xl font-semibold flex items-center gap-2",children:["API Key Compatible Providers"," "]}),(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsx)(n.$n,{size:"sm",icon:"add",onClick:()=>f(!0),children:"Add Anthropic Compatible"}),(0,r.jsx)(n.$n,{size:"sm",variant:"secondary",icon:"add",onClick:()=>m(!0),className:"!bg-white !text-black hover:!bg-gray-100",children:"Add OpenAI Compatible"})]})]}),0===E.length&&0===S.length?(0,r.jsxs)("div",{className:"text-center py-8 border border-dashed border-border rounded-xl",children:[(0,r.jsx)("span",{className:"material-symbols-outlined text-[32px] text-text-muted mb-2",children:"extension"}),(0,r.jsx)("p",{className:"text-text-muted text-sm",children:"No compatible providers added yet"}),(0,r.jsx)("p",{className:"text-text-muted text-xs mt-1",children:"Use the buttons above to add OpenAI or Anthropic compatible endpoints"})]}):(0,r.jsx)("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-4",children:[...E,...S].map(e=>(0,r.jsx)(g,{providerId:e.id,provider:e,stats:A(e.id,"apikey"),authType:"compatible",onToggle:t=>I(e.id,"apikey",t)},e.id))})]}),(0,r.jsx)(y,{isOpen:p,onClose:()=>m(!1),onCreated:e=>{l(t=>[...t,e]),m(!1)}}),(0,r.jsx)(j,{isOpen:u,onClose:()=>f(!1),onCreated:e=>{l(t=>[...t,e]),f(!1)}}),k&&(0,r.jsxs)("div",{className:"fixed inset-0 z-50 flex items-start justify-center pt-[10vh]",onClick:()=>T(null),children:[(0,r.jsx)("div",{className:"absolute inset-0 bg-black/60 backdrop-blur-sm"}),(0,r.jsxs)("div",{className:"relative bg-surface border border-border rounded-xl w-full max-w-[600px] max-h-[80vh] overflow-y-auto shadow-2xl",onClick:e=>e.stopPropagation(),children:[(0,r.jsxs)("div",{className:"sticky top-0 z-10 flex items-center justify-between px-5 py-3 border-b border-border bg-surface/95 backdrop-blur-sm rounded-t-xl",children:[(0,r.jsx)("h3",{className:"font-semibold",children:"Test Results"}),(0,r.jsx)("button",{onClick:()=>T(null),className:"p-1 rounded-lg hover:bg-bg text-text-muted hover:text-text-main transition-colors","aria-label":"Close test results",children:(0,r.jsx)("span",{className:"material-symbols-outlined text-lg",children:"close"})})]}),(0,r.jsx)("div",{className:"p-5",children:(0,r.jsx)(N,{results:k})})]})]})]})}function v({providerId:e,provider:t,stats:s,authType:a,onToggle:l}){let{connected:i,error:d,errorCode:c,errorTime:p,allDisabled:x}=s;return(0,r.jsx)(m(),{href:`/dashboard/providers/${e}`,className:"group",children:(0,r.jsx)(n.Zp,{padding:"xs",className:`h-full hover:bg-black/[0.01] dark:hover:bg-white/[0.01] transition-colors cursor-pointer ${x?"opacity-50":""}`,children:(0,r.jsxs)("div",{className:"flex items-center justify-between",children:[(0,r.jsxs)("div",{className:"flex items-center gap-3",children:[(0,r.jsx)("div",{className:"size-8 rounded-lg flex items-center justify-center",style:{backgroundColor:`${t.color?.length>7?t.color:t.color+"15"}`},children:(0,r.jsx)(o.A,{src:`/providers/${t.id}.png`,alt:t.name,size:30,className:"object-contain rounded-lg max-w-[32px] max-h-[32px]",fallbackText:t.textIcon||t.id.slice(0,2).toUpperCase(),fallbackColor:t.color})}),(0,r.jsxs)("div",{children:[(0,r.jsx)("h3",{className:"font-semibold",children:t.name}),(0,r.jsx)("div",{className:"flex items-center gap-2 text-xs flex-wrap",children:x?(0,r.jsx)(n.Ex,{variant:"default",size:"sm",children:(0,r.jsxs)("span",{className:"flex items-center gap-1",children:[(0,r.jsx)("span",{className:"material-symbols-outlined text-[12px]",children:"pause_circle"}),"Disabled"]})}):(0,r.jsxs)(r.Fragment,{children:[f(i,d,c),p&&(0,r.jsx)("span",{className:"text-text-muted",children:p})]})})]})]}),(0,r.jsx)("div",{className:"flex items-center gap-2",children:s.total>0&&(0,r.jsx)("div",{className:"opacity-0 group-hover:opacity-100 transition-opacity",onClick:e=>{e.preventDefault(),e.stopPropagation(),l(!!x)},children:(0,r.jsx)(n.lM,{size:"sm",checked:!x,onChange:()=>{},title:x?"Enable provider":"Disable provider"})})})]})})})}function g({providerId:e,provider:t,stats:s,authType:a,onToggle:l}){let{connected:i,error:d,errorCode:p,errorTime:x,allDisabled:u}=s,h=e.startsWith(c.JH),b=e.startsWith(c.DI);return(0,r.jsx)(m(),{href:`/dashboard/providers/${e}`,className:"group",children:(0,r.jsx)(n.Zp,{padding:"xs",className:`h-full hover:bg-black/[0.01] dark:hover:bg-white/[0.01] transition-colors cursor-pointer ${u?"opacity-50":""}`,children:(0,r.jsxs)("div",{className:"flex items-center justify-between",children:[(0,r.jsxs)("div",{className:"flex items-center gap-3",children:[(0,r.jsx)("div",{className:"size-8 rounded-lg flex items-center justify-center",style:{backgroundColor:`${t.color?.length>7?t.color:t.color+"15"}`},children:(0,r.jsx)(o.A,{src:h?"responses"===t.apiType?"/providers/oai-r.png":"/providers/oai-cc.png":b?"/providers/anthropic-m.png":`/providers/${t.id}.png`,alt:t.name,size:30,className:"object-contain rounded-lg max-w-[30px] max-h-[30px]",fallbackText:t.textIcon||t.id.slice(0,2).toUpperCase(),fallbackColor:t.color})}),(0,r.jsxs)("div",{children:[(0,r.jsx)("h3",{className:"font-semibold",children:t.name}),(0,r.jsx)("div",{className:"flex items-center gap-2 text-xs flex-wrap",children:u?(0,r.jsx)(n.Ex,{variant:"default",size:"sm",children:(0,r.jsxs)("span",{className:"flex items-center gap-1",children:[(0,r.jsx)("span",{className:"material-symbols-outlined text-[12px]",children:"pause_circle"}),"Disabled"]})}):(0,r.jsxs)(r.Fragment,{children:[f(i,d,p),h&&(0,r.jsx)(n.Ex,{variant:"default",size:"sm",children:"responses"===t.apiType?"Responses":"Chat"}),b&&(0,r.jsx)(n.Ex,{variant:"default",size:"sm",children:"Messages"}),x&&(0,r.jsx)("span",{className:"text-text-muted",children:x})]})})]})]}),(0,r.jsx)("div",{className:"flex items-center gap-2",children:s.total>0&&(0,r.jsx)("div",{className:"opacity-0 group-hover:opacity-100 transition-opacity",onClick:e=>{e.preventDefault(),e.stopPropagation(),l(!!u)},children:(0,r.jsx)(n.lM,{size:"sm",checked:!u,onChange:()=>{},title:u?"Enable provider":"Disable provider"})})})]})})})}function y({isOpen:e,onClose:t,onCreated:s}){let[l,i]=(0,a.useState)({name:"",prefix:"",apiType:"chat",baseUrl:"https://api.openai.com/v1"}),[o,d]=(0,a.useState)(!1),[c,p]=(0,a.useState)(""),[m,x]=(0,a.useState)(""),[u,h]=(0,a.useState)(!1),[f,b]=(0,a.useState)(null);(0,a.useEffect)(()=>{i(e=>({...e,baseUrl:"https://api.openai.com/v1"}))},[l.apiType]);let v=async()=>{if(l.name.trim()&&l.prefix.trim()&&l.baseUrl.trim()){d(!0);try{let e=await fetch("/api/provider-nodes",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:l.name,prefix:l.prefix,apiType:l.apiType,baseUrl:l.baseUrl,type:"openai-compatible"})}),t=await e.json();e.ok&&(s(t.node),i({name:"",prefix:"",apiType:"chat",baseUrl:"https://api.openai.com/v1"}),p(""),b(null))}catch(e){console.log("Error creating OpenAI Compatible node:",e)}finally{d(!1)}}},g=async()=>{h(!0);try{let e=await fetch("/api/provider-nodes/validate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({baseUrl:l.baseUrl,apiKey:c,type:"openai-compatible",modelId:m.trim()||void 0})}),t=await e.json();b(t)}catch{b({valid:!1,error:"Network error"})}finally{h(!1)}};return(0,r.jsx)(n.aF,{isOpen:e,title:"Add OpenAI Compatible",onClose:t,children:(0,r.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,r.jsx)(n.pd,{label:"Name",value:l.name,onChange:e=>i({...l,name:e.target.value}),placeholder:"OpenAI Compatible (Prod)",hint:"Required. A friendly label for this node."}),(0,r.jsx)(n.pd,{label:"Prefix",value:l.prefix,onChange:e=>i({...l,prefix:e.target.value}),placeholder:"oc-prod",hint:"Required. Used as the provider prefix for model IDs."}),(0,r.jsx)(n.l6,{label:"API Type",options:[{value:"chat",label:"Chat Completions"},{value:"responses",label:"Responses API"}],value:l.apiType,onChange:e=>i({...l,apiType:e.target.value})}),(0,r.jsx)(n.pd,{label:"Base URL",value:l.baseUrl,onChange:e=>i({...l,baseUrl:e.target.value}),placeholder:"https://api.openai.com/v1",hint:"Use the base URL (ending in /v1) for your OpenAI-compatible API."}),(0,r.jsx)(n.pd,{label:"API Key (for Check)",type:"password",value:c,onChange:e=>p(e.target.value)}),(0,r.jsx)(n.pd,{label:"Model ID (optional)",value:m,onChange:e=>x(e.target.value),placeholder:"e.g. gpt-4, claude-3-opus",hint:"If provider lacks /models endpoint, enter a model ID to validate via chat/completions instead."}),(0,r.jsxs)("div",{className:"flex items-center gap-3",children:[(0,r.jsx)(n.$n,{onClick:g,disabled:!c||u||!l.baseUrl.trim(),variant:"secondary",children:u?"Checking...":"Check"}),(()=>{if(!f)return null;let{valid:e,error:t,method:s}=f;return e?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(n.Ex,{variant:"success",children:"Valid"}),"chat"===s&&(0,r.jsx)("span",{className:"text-sm text-text-muted",children:"(via inference test)"})]}):(0,r.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,r.jsx)(n.Ex,{variant:"error",children:"Invalid"}),t&&(0,r.jsx)("span",{className:"text-sm text-red-500",children:t})]})})()]}),(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsx)(n.$n,{onClick:v,fullWidth:!0,disabled:!l.name.trim()||!l.prefix.trim()||!l.baseUrl.trim()||o,children:o?"Creating...":"Create"}),(0,r.jsx)(n.$n,{onClick:t,variant:"ghost",fullWidth:!0,children:"Cancel"})]})]})})}function j({isOpen:e,onClose:t,onCreated:s}){let[l,i]=(0,a.useState)({name:"",prefix:"",baseUrl:"https://api.anthropic.com/v1"}),[o,d]=(0,a.useState)(!1),[c,p]=(0,a.useState)(""),[m,x]=(0,a.useState)(""),[u,h]=(0,a.useState)(!1),[f,b]=(0,a.useState)(null);(0,a.useEffect)(()=>{e&&(b(null),p(""),x(""))},[e]);let v=async()=>{if(l.name.trim()&&l.prefix.trim()&&l.baseUrl.trim()){d(!0);try{let e=await fetch("/api/provider-nodes",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:l.name,prefix:l.prefix,baseUrl:l.baseUrl,type:"anthropic-compatible"})}),t=await e.json();e.ok&&(s(t.node),i({name:"",prefix:"",baseUrl:"https://api.anthropic.com/v1"}),p(""),b(null))}catch(e){console.log("Error creating Anthropic Compatible node:",e)}finally{d(!1)}}},g=async()=>{h(!0);try{let e=await fetch("/api/provider-nodes/validate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({baseUrl:l.baseUrl,apiKey:c,type:"anthropic-compatible",modelId:m.trim()||void 0})}),t=await e.json();b(t)}catch{b({valid:!1,error:"Network error"})}finally{h(!1)}};return(0,r.jsx)(n.aF,{isOpen:e,title:"Add Anthropic Compatible",onClose:t,children:(0,r.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,r.jsx)(n.pd,{label:"Name",value:l.name,onChange:e=>i({...l,name:e.target.value}),placeholder:"Anthropic Compatible (Prod)",hint:"Required. A friendly label for this node."}),(0,r.jsx)(n.pd,{label:"Prefix",value:l.prefix,onChange:e=>i({...l,prefix:e.target.value}),placeholder:"ac-prod",hint:"Required. Used as the provider prefix for model IDs."}),(0,r.jsx)(n.pd,{label:"Base URL",value:l.baseUrl,onChange:e=>i({...l,baseUrl:e.target.value}),placeholder:"https://api.anthropic.com/v1",hint:"Use the base URL (ending in /v1) for your Anthropic-compatible API. The system will append /messages."}),(0,r.jsx)(n.pd,{label:"API Key (for Check)",type:"password",value:c,onChange:e=>p(e.target.value)}),(0,r.jsx)(n.pd,{label:"Model ID (optional)",value:m,onChange:e=>x(e.target.value),placeholder:"e.g. claude-3-opus",hint:"If provider lacks /models endpoint, enter a model ID to validate via chat/completions instead."}),(0,r.jsxs)("div",{className:"flex items-center gap-3",children:[(0,r.jsx)(n.$n,{onClick:g,disabled:!c||u||!l.baseUrl.trim(),variant:"secondary",children:u?"Checking...":"Check"}),(()=>{if(!f)return null;let{valid:e,error:t,method:s}=f;return e?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(n.Ex,{variant:"success",children:"Valid"}),"chat"===s&&(0,r.jsx)("span",{className:"text-sm text-text-muted",children:"(via inference test)"})]}):(0,r.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,r.jsx)(n.Ex,{variant:"error",children:"Invalid"}),t&&(0,r.jsx)("span",{className:"text-sm text-red-500",children:t})]})})()]}),(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsx)(n.$n,{onClick:v,fullWidth:!0,disabled:!l.name.trim()||!l.prefix.trim()||!l.baseUrl.trim()||o,children:o?"Creating...":"Create"}),(0,r.jsx)(n.$n,{onClick:t,variant:"ghost",fullWidth:!0,children:"Cancel"})]})]})})}function N({results:e}){if(e.error&&!e.results)return(0,r.jsxs)("div",{className:"text-center py-6",children:[(0,r.jsx)("span",{className:"material-symbols-outlined text-red-500 text-[32px] mb-2 block",children:"error"}),(0,r.jsx)("p",{className:"text-sm text-red-400",children:e.error})]});let{summary:t,mode:s}=e,a=e.results||[];return(0,r.jsxs)("div",{className:"flex flex-col gap-3",children:[t&&(0,r.jsxs)("div",{className:"flex items-center gap-3 text-xs mb-1",children:[(0,r.jsxs)("span",{className:"text-text-muted",children:[{oauth:"OAuth",free:"Free",apikey:"API Key",provider:"Provider",all:"All"}[s]||s," Test"]}),(0,r.jsxs)("span",{className:"px-2 py-0.5 rounded bg-emerald-500/15 text-emerald-400 font-medium",children:[t.passed," passed"]}),t.failed>0&&(0,r.jsxs)("span",{className:"px-2 py-0.5 rounded bg-red-500/15 text-red-400 font-medium",children:[t.failed," failed"]}),(0,r.jsxs)("span",{className:"text-text-muted ml-auto",children:[t.total," tested"]})]}),a.map((e,t)=>(0,r.jsxs)("div",{className:"flex items-center gap-2 text-xs px-3 py-2 rounded-lg bg-black/[0.03] dark:bg-white/[0.03]",children:[(0,r.jsx)("span",{className:`material-symbols-outlined text-[16px] ${e.valid?"text-emerald-500":"text-red-500"}`,children:e.valid?"check_circle":"error"}),(0,r.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,r.jsx)("span",{className:"font-medium",children:e.connectionName}),(0,r.jsxs)("span",{className:"text-text-muted ml-1.5",children:["(",e.provider,")"]})]}),void 0!==e.latencyMs&&(0,r.jsxs)("span",{className:"text-text-muted font-mono tabular-nums",children:[e.latencyMs,"ms"]}),(0,r.jsx)("span",{className:`text-[10px] uppercase font-bold px-1.5 py-0.5 rounded ${e.valid?"bg-emerald-500/15 text-emerald-400":"bg-red-500/15 text-red-400"}`,children:e.valid?"OK":e.diagnosis?.type||"ERROR"})]},e.connectionId||t)),0===a.length&&(0,r.jsx)("div",{className:"text-center py-4 text-text-muted text-sm",children:"No active connections found for this group."})]})}v.propTypes={providerId:i().string.isRequired,provider:i().shape({id:i().string.isRequired,name:i().string.isRequired,color:i().string,textIcon:i().string}).isRequired,stats:i().shape({connected:i().number,error:i().number,errorCode:i().string,errorTime:i().string}).isRequired,authType:i().string,onToggle:i().func},g.propTypes={providerId:i().string.isRequired,provider:i().shape({id:i().string.isRequired,name:i().string.isRequired,color:i().string,textIcon:i().string,apiType:i().string}).isRequired,stats:i().shape({connected:i().number,error:i().number,errorCode:i().string,errorTime:i().string}).isRequired,authType:i().string,onToggle:i().func},y.propTypes={isOpen:i().bool.isRequired,onClose:i().func.isRequired,onCreated:i().func.isRequired},j.propTypes={isOpen:i().bool.isRequired,onClose:i().func.isRequired,onCreated:i().func.isRequired},N.propTypes={results:i().shape({mode:i().string,results:i().array,summary:i().shape({total:i().number,passed:i().number,failed:i().number}),error:i().string}).isRequired}}},e=>{e.O(0,[7848,4335,2599,505,4156,2347,5158,7358],()=>e(e.s=43007)),_N_E=e.O()}]);
@@ -1,2 +1,2 @@
1
1
  (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[6812],{26491:(e,t,r)=>{Promise.resolve().then(r.bind(r,85148))},85148:(e,t,r)=>{"use strict";r.r(t),r.d(t,{default:()=>n});var s=r(73365),o=r(1521),i=r(74156),l=r(14793);function a(e={}){return{name:e.name||"",proxyUrl:e.proxyUrl||"",noProxy:e.noProxy||"",isActive:!1!==e.isActive,strictProxy:!0===e.strictProxy}}function n(){let[e,t]=(0,o.useState)([]),[r,n]=(0,o.useState)(!0),[c,d]=(0,o.useState)(!1),[x,p]=(0,o.useState)(!1),[m,h]=(0,o.useState)(null),[u,y]=(0,o.useState)(a()),[f,v]=(0,o.useState)(""),[j,g]=(0,o.useState)(!1),[b,N]=(0,o.useState)(!1),[P,w]=(0,o.useState)(null),k=(0,l.i)(),C=(0,o.useCallback)(async()=>{try{let e=await fetch("/api/proxy-pools?includeUsage=true",{cache:"no-store"}),r=await e.json();e.ok&&t(r.proxyPools||[])}catch(e){console.log("Error fetching proxy pools:",e)}finally{n(!1)}},[]);(0,o.useEffect)(()=>{C()},[C]);let $=()=>{h(null),y(a())},S=()=>{$(),d(!0)},E=()=>{d(!1),$()},U=async()=>{let e={name:u.name.trim(),proxyUrl:u.proxyUrl.trim(),noProxy:u.noProxy.trim(),isActive:!0===u.isActive,strictProxy:!0===u.strictProxy};if(e.name&&e.proxyUrl){g(!0);try{let t=!!m,r=await fetch(t?`/api/proxy-pools/${m.id}`:"/api/proxy-pools",{method:t?"PUT":"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(r.ok)await C(),E(),k.success(m?"Proxy pool updated":"Proxy pool created");else{let e=await r.json();k.error(e.error||"Failed to save proxy pool")}}catch(e){console.log("Error saving proxy pool:",e)}finally{g(!1)}}},A=async e=>{if(confirm(`Delete proxy pool "${e.name}"?`))try{let r=await fetch(`/api/proxy-pools/${e.id}`,{method:"DELETE"});if(r.ok){t(t=>t.filter(t=>t.id!==e.id)),k.success("Proxy pool deleted");return}let s=await r.json();409===r.status?k.warning(`Cannot delete: ${s.boundConnectionCount||0} connection(s) are still using this pool.`):k.error(s.error||"Failed to delete proxy pool")}catch(e){console.log("Error deleting proxy pool:",e),k.error("Failed to delete proxy pool")}},I=async e=>{w(e);try{let t=await fetch(`/api/proxy-pools/${e}/test`,{method:"POST"}),r=await t.json();if(!t.ok)return void k.error(r.error||"Failed to test proxy");await C(),k.success(r.ok?"Proxy test passed":"Proxy test failed")}catch(e){console.log("Error testing proxy pool:",e),k.error("Failed to test proxy")}finally{w(null)}},O=()=>{b||p(!1)},T=async()=>{let t=f.split(/\r?\n/).map(e=>e.trim()).filter(Boolean);if(0===t.length)return void k.warning("Please paste at least one proxy line.");let r=[],s=[];if(t.forEach((e,t)=>{try{let s=(e=>{let t=e.trim();if(!t)return null;if(t.includes("://")){let e=new URL(t),r=e.port?`${e.hostname}:${e.port}`:e.hostname;return{proxyUrl:e.toString(),name:`Imported ${r}`}}let r=t.split(":");if(4===r.length){let[e,t,s,o]=r;if(!e||!t||!s||!o)throw Error("Invalid host:port:user:pass format");return{proxyUrl:new URL(`http://${encodeURIComponent(s)}:${encodeURIComponent(o)}@${e}:${t}`).toString(),name:`Imported ${e}:${t}`}}throw Error("Unsupported format")})(e);s&&r.push({...s,lineNumber:t+1})}catch(e){s.push(`Line ${t+1}: ${e.message}`)}}),s.length>0)return void k.error(`Invalid proxy format:
2
- ${s.join("\n")}`);N(!0);try{let t=new Set(e.map(e=>`${(e.proxyUrl||"").trim()}|||${(e.noProxy||"").trim()}`)),s=0,o=0,i=0;for(let e of r){let r=`${e.proxyUrl}|||`;if(t.has(r)){o+=1;continue}(await fetch("/api/proxy-pools",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:e.name,proxyUrl:e.proxyUrl,noProxy:"",isActive:!0})})).ok?(s+=1,t.add(r)):i+=1}await C(),p(!1),k.success(`Batch import completed: Created ${s}, Skipped ${o}, Failed ${i}`)}catch(e){console.log("Error batch importing proxies:",e),k.error("Batch import failed")}finally{N(!1)}},F=(0,o.useMemo)(()=>e.filter(e=>!0===e.isActive).length,[e]);return r?(0,s.jsxs)("div",{className:"flex flex-col gap-6",children:[(0,s.jsx)(i.Qv,{}),(0,s.jsx)(i.Qv,{})]}):(0,s.jsxs)("div",{className:"flex flex-col gap-6",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("h1",{className:"text-2xl font-semibold",children:"Proxy Pools"}),(0,s.jsx)("p",{className:"text-sm text-text-muted mt-1",children:"Manage reusable per-connection proxies and bind them to provider connections."})]}),(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)(i.$n,{variant:"secondary",icon:"upload",onClick:()=>{v(""),p(!0)},children:"Batch Import Proxies"}),(0,s.jsx)(i.$n,{icon:"add",onClick:S,children:"Add Proxy Pool"})]})]}),(0,s.jsxs)(i.Zp,{children:[(0,s.jsx)("div",{className:"flex items-center justify-between mb-4",children:(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsxs)(i.Ex,{variant:"default",children:["Total: ",e.length]}),(0,s.jsxs)(i.Ex,{variant:"success",children:["Active: ",F]})]})}),0===e.length?(0,s.jsxs)("div",{className:"text-center py-10",children:[(0,s.jsx)("p",{className:"text-text-main font-medium mb-1",children:"No proxy pool entries yet"}),(0,s.jsx)("p",{className:"text-sm text-text-muted mb-4",children:"Create a proxy pool entry, then assign it to connections."}),(0,s.jsx)(i.$n,{icon:"add",onClick:S,children:"Add Proxy Pool"})]}):(0,s.jsx)("div",{className:"flex flex-col divide-y divide-black/[0.04] dark:divide-white/[0.05]",children:e.map(e=>{var t;return(0,s.jsxs)("div",{className:"py-3 flex items-center justify-between gap-3 group",children:[(0,s.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2 flex-wrap",children:[(0,s.jsx)("p",{className:"text-sm font-medium truncate",children:e.name}),(0,s.jsx)(i.Ex,{variant:"active"===(t=e.testStatus)?"success":"error"===t?"error":"default",size:"sm",dot:!0,children:e.testStatus||"unknown"}),(0,s.jsx)(i.Ex,{variant:e.isActive?"success":"default",size:"sm",children:e.isActive?"active":"inactive"}),(0,s.jsxs)(i.Ex,{variant:"default",size:"sm",children:[e.boundConnectionCount||0," bound"]})]}),(0,s.jsx)("p",{className:"text-xs text-text-muted truncate mt-1",children:e.proxyUrl}),e.noProxy?(0,s.jsxs)("p",{className:"text-xs text-text-muted truncate",children:["No proxy: ",e.noProxy]}):null,(0,s.jsxs)("p",{className:"text-[11px] text-text-muted mt-1",children:["Last tested: ",function(e){if(!e)return"Never";let t=new Date(e);return Number.isNaN(t.getTime())?"Never":t.toLocaleString()}(e.lastTestedAt),e.lastError?` \xb7 ${e.lastError}`:""]})]}),(0,s.jsxs)("div",{className:"flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity",children:[(0,s.jsx)("button",{onClick:()=>I(e.id),className:"p-2 rounded hover:bg-black/5 dark:hover:bg-white/5 text-text-muted hover:text-primary",title:"Test proxy",disabled:P===e.id,children:(0,s.jsx)("span",{className:"material-symbols-outlined text-[18px]",style:P===e.id?{animation:"spin 1s linear infinite"}:void 0,children:P===e.id?"progress_activity":"science"})}),(0,s.jsx)("button",{onClick:()=>{h(e),y(a(e)),d(!0)},className:"p-2 rounded hover:bg-black/5 dark:hover:bg-white/5 text-text-muted hover:text-primary",title:"Edit",children:(0,s.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:"edit"})}),(0,s.jsx)("button",{onClick:()=>A(e),className:"p-2 rounded hover:bg-red-500/10 text-red-500",title:"Delete",children:(0,s.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:"delete"})})]})]},e.id)})})]}),(0,s.jsx)(i.aF,{isOpen:x,title:"Batch Import Proxies",onClose:O,children:(0,s.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{className:"text-sm font-medium text-text-main mb-1 block",children:"Paste Proxy List (One per line)"}),(0,s.jsx)("textarea",{value:f,onChange:e=>v(e.target.value),placeholder:"http://user:pass@127.0.0.1:7897\n127.0.0.1:7897:user:pass",className:"w-full min-h-[180px] py-2 px-3 text-sm text-text-main bg-white dark:bg-white/5 border border-black/10 dark:border-white/10 rounded-md focus:ring-1 focus:ring-primary/30 focus:border-primary/50 focus:outline-none transition-all"}),(0,s.jsx)("p",{className:"text-xs text-text-muted mt-1",children:"Supported formats: protocol://user:pass@host:port, host:port:user:pass"})]}),(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsx)(i.$n,{fullWidth:!0,onClick:T,disabled:!f.trim()||b,children:b?"Importing...":"Import"}),(0,s.jsx)(i.$n,{fullWidth:!0,variant:"ghost",onClick:O,disabled:b,children:"Cancel"})]})]})}),(0,s.jsx)(i.aF,{isOpen:c,title:m?"Edit Proxy Pool":"Add Proxy Pool",onClose:E,children:(0,s.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,s.jsx)(i.pd,{label:"Name",value:u.name,onChange:e=>y(t=>({...t,name:e.target.value})),placeholder:"Office Proxy"}),(0,s.jsx)(i.pd,{label:"Proxy URL",value:u.proxyUrl,onChange:e=>y(t=>({...t,proxyUrl:e.target.value})),placeholder:"http://127.0.0.1:7897"}),(0,s.jsx)(i.pd,{label:"No Proxy",value:u.noProxy,onChange:e=>y(t=>({...t,noProxy:e.target.value})),placeholder:"localhost,127.0.0.1,.internal",hint:"Comma-separated hosts/domains to bypass proxy"}),(0,s.jsxs)("div",{className:"rounded-lg border border-border/50 p-3 flex items-center justify-between",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:"font-medium text-sm",children:"Active"}),(0,s.jsx)("p",{className:"text-xs text-text-muted",children:"Inactive pools are ignored by runtime resolution."})]}),(0,s.jsx)(i.lM,{checked:!0===u.isActive,onChange:()=>y(e=>({...e,isActive:!e.isActive})),disabled:j})]}),(0,s.jsxs)("div",{className:"rounded-lg border border-border/50 p-3 flex items-center justify-between",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:"font-medium text-sm",children:"Strict Proxy"}),(0,s.jsx)("p",{className:"text-xs text-text-muted",children:"Fail request if proxy is unreachable instead of falling back to direct."})]}),(0,s.jsx)(i.lM,{checked:!0===u.strictProxy,onChange:()=>y(e=>({...e,strictProxy:!e.strictProxy})),disabled:j})]}),(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsx)(i.$n,{fullWidth:!0,onClick:U,disabled:!u.name.trim()||!u.proxyUrl.trim()||j,children:j?"Saving...":"Save"}),(0,s.jsx)(i.$n,{fullWidth:!0,variant:"ghost",onClick:E,disabled:j,children:"Cancel"})]})]})})]})}}},e=>{e.O(0,[7848,4335,2599,350,4156,2347,5158,7358],()=>e(e.s=26491)),_N_E=e.O()}]);
2
+ ${s.join("\n")}`);N(!0);try{let t=new Set(e.map(e=>`${(e.proxyUrl||"").trim()}|||${(e.noProxy||"").trim()}`)),s=0,o=0,i=0;for(let e of r){let r=`${e.proxyUrl}|||`;if(t.has(r)){o+=1;continue}(await fetch("/api/proxy-pools",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:e.name,proxyUrl:e.proxyUrl,noProxy:"",isActive:!0})})).ok?(s+=1,t.add(r)):i+=1}await C(),p(!1),k.success(`Batch import completed: Created ${s}, Skipped ${o}, Failed ${i}`)}catch(e){console.log("Error batch importing proxies:",e),k.error("Batch import failed")}finally{N(!1)}},F=(0,o.useMemo)(()=>e.filter(e=>!0===e.isActive).length,[e]);return r?(0,s.jsxs)("div",{className:"flex flex-col gap-6",children:[(0,s.jsx)(i.Qv,{}),(0,s.jsx)(i.Qv,{})]}):(0,s.jsxs)("div",{className:"flex flex-col gap-6",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("h1",{className:"text-2xl font-semibold",children:"Proxy Pools"}),(0,s.jsx)("p",{className:"text-sm text-text-muted mt-1",children:"Manage reusable per-connection proxies and bind them to provider connections."})]}),(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)(i.$n,{variant:"secondary",icon:"upload",onClick:()=>{v(""),p(!0)},children:"Batch Import Proxies"}),(0,s.jsx)(i.$n,{icon:"add",onClick:S,children:"Add Proxy Pool"})]})]}),(0,s.jsxs)(i.Zp,{children:[(0,s.jsx)("div",{className:"flex items-center justify-between mb-4",children:(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsxs)(i.Ex,{variant:"default",children:["Total: ",e.length]}),(0,s.jsxs)(i.Ex,{variant:"success",children:["Active: ",F]})]})}),0===e.length?(0,s.jsxs)("div",{className:"text-center py-10",children:[(0,s.jsx)("p",{className:"text-text-main font-medium mb-1",children:"No proxy pool entries yet"}),(0,s.jsx)("p",{className:"text-sm text-text-muted mb-4",children:"Create a proxy pool entry, then assign it to connections."}),(0,s.jsx)(i.$n,{icon:"add",onClick:S,children:"Add Proxy Pool"})]}):(0,s.jsx)("div",{className:"flex flex-col divide-y divide-black/[0.04] dark:divide-white/[0.05]",children:e.map(e=>{var t;return(0,s.jsxs)("div",{className:"py-3 flex items-center justify-between gap-3 group",children:[(0,s.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2 flex-wrap",children:[(0,s.jsx)("p",{className:"text-sm font-medium truncate",children:e.name}),(0,s.jsx)(i.Ex,{variant:"active"===(t=e.testStatus)?"success":"error"===t?"error":"default",size:"sm",dot:!0,children:e.testStatus||"unknown"}),(0,s.jsx)(i.Ex,{variant:e.isActive?"success":"default",size:"sm",children:e.isActive?"active":"inactive"}),(0,s.jsxs)(i.Ex,{variant:"default",size:"sm",children:[e.boundConnectionCount||0," bound"]})]}),(0,s.jsx)("p",{className:"text-xs text-text-muted truncate mt-1",children:e.proxyUrl}),e.noProxy?(0,s.jsxs)("p",{className:"text-xs text-text-muted truncate",children:["No proxy: ",e.noProxy]}):null,(0,s.jsxs)("p",{className:"text-[11px] text-text-muted mt-1",children:["Last tested: ",function(e){if(!e)return"Never";let t=new Date(e);return Number.isNaN(t.getTime())?"Never":t.toLocaleString()}(e.lastTestedAt),e.lastError?` \xb7 ${e.lastError}`:""]})]}),(0,s.jsxs)("div",{className:"flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity",children:[(0,s.jsx)("button",{onClick:()=>I(e.id),className:"p-2 rounded hover:bg-black/5 dark:hover:bg-white/5 text-text-muted hover:text-primary",title:"Test proxy",disabled:P===e.id,children:(0,s.jsx)("span",{className:"material-symbols-outlined text-[18px]",style:P===e.id?{animation:"spin 1s linear infinite"}:void 0,children:P===e.id?"progress_activity":"science"})}),(0,s.jsx)("button",{onClick:()=>{h(e),y(a(e)),d(!0)},className:"p-2 rounded hover:bg-black/5 dark:hover:bg-white/5 text-text-muted hover:text-primary",title:"Edit",children:(0,s.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:"edit"})}),(0,s.jsx)("button",{onClick:()=>A(e),className:"p-2 rounded hover:bg-red-500/10 text-red-500",title:"Delete",children:(0,s.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:"delete"})})]})]},e.id)})})]}),(0,s.jsx)(i.aF,{isOpen:x,title:"Batch Import Proxies",onClose:O,children:(0,s.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{className:"text-sm font-medium text-text-main mb-1 block",children:"Paste Proxy List (One per line)"}),(0,s.jsx)("textarea",{value:f,onChange:e=>v(e.target.value),placeholder:"http://user:pass@127.0.0.1:7897\n127.0.0.1:7897:user:pass",className:"w-full min-h-[180px] py-2 px-3 text-sm text-text-main bg-white dark:bg-white/5 border border-black/10 dark:border-white/10 rounded-md focus:ring-1 focus:ring-primary/30 focus:border-primary/50 focus:outline-none transition-all"}),(0,s.jsx)("p",{className:"text-xs text-text-muted mt-1",children:"Supported formats: protocol://user:pass@host:port, host:port:user:pass"})]}),(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsx)(i.$n,{fullWidth:!0,onClick:T,disabled:!f.trim()||b,children:b?"Importing...":"Import"}),(0,s.jsx)(i.$n,{fullWidth:!0,variant:"ghost",onClick:O,disabled:b,children:"Cancel"})]})]})}),(0,s.jsx)(i.aF,{isOpen:c,title:m?"Edit Proxy Pool":"Add Proxy Pool",onClose:E,children:(0,s.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,s.jsx)(i.pd,{label:"Name",value:u.name,onChange:e=>y(t=>({...t,name:e.target.value})),placeholder:"Office Proxy"}),(0,s.jsx)(i.pd,{label:"Proxy URL",value:u.proxyUrl,onChange:e=>y(t=>({...t,proxyUrl:e.target.value})),placeholder:"http://127.0.0.1:7897"}),(0,s.jsx)(i.pd,{label:"No Proxy",value:u.noProxy,onChange:e=>y(t=>({...t,noProxy:e.target.value})),placeholder:"localhost,127.0.0.1,.internal",hint:"Comma-separated hosts/domains to bypass proxy"}),(0,s.jsxs)("div",{className:"rounded-lg border border-border/50 p-3 flex items-center justify-between",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:"font-medium text-sm",children:"Active"}),(0,s.jsx)("p",{className:"text-xs text-text-muted",children:"Inactive pools are ignored by runtime resolution."})]}),(0,s.jsx)(i.lM,{checked:!0===u.isActive,onChange:()=>y(e=>({...e,isActive:!e.isActive})),disabled:j})]}),(0,s.jsxs)("div",{className:"rounded-lg border border-border/50 p-3 flex items-center justify-between",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:"font-medium text-sm",children:"Strict Proxy"}),(0,s.jsx)("p",{className:"text-xs text-text-muted",children:"Fail request if proxy is unreachable instead of falling back to direct."})]}),(0,s.jsx)(i.lM,{checked:!0===u.strictProxy,onChange:()=>y(e=>({...e,strictProxy:!e.strictProxy})),disabled:j})]}),(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsx)(i.$n,{fullWidth:!0,onClick:U,disabled:!u.name.trim()||!u.proxyUrl.trim()||j,children:j?"Saving...":"Save"}),(0,s.jsx)(i.$n,{fullWidth:!0,variant:"ghost",onClick:E,disabled:j,children:"Cancel"})]})]})})]})}}},e=>{e.O(0,[7848,4335,2599,505,4156,2347,5158,7358],()=>e(e.s=26491)),_N_E=e.O()}]);
@@ -0,0 +1 @@
1
+ (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[3826],{58944:(e,t,r)=>{Promise.resolve().then(r.bind(r,59295)),Promise.resolve().then(r.bind(r,91494))},59295:(e,t,r)=>{"use strict";r.d(t,{default:()=>h});var s=r(73365),a=r(1521),l=r(68266),n=r(94718);function i(e,t){return t&&0!==t?!e||e<0?100:e>=t?0:Math.round((t-e)/t*100):0}function o({quotas:e=[],compact:t=!1}){if(!e||0===e.length)return null;let r=t?"py-1.5 px-2":"py-2 px-3",a=t?"text-xs":"text-sm",l=t?"text-xs":"text-sm",n=t?"text-[10px] leading-tight":"text-xs";return(0,s.jsx)("div",{className:"overflow-x-auto",children:(0,s.jsxs)("table",{className:"w-full table-fixed text-left",children:[(0,s.jsxs)("colgroup",{children:[(0,s.jsx)("col",{className:"w-[30%]"})," ",(0,s.jsx)("col",{className:"w-[45%]"})," ",(0,s.jsx)("col",{className:"w-[25%]"})," "]}),(0,s.jsx)("tbody",{children:e.map((e,o)=>{let c=void 0!==e.remainingPercentage?Math.round(e.remainingPercentage):i(e.used,e.total),d=c>70?{text:"text-green-600 dark:text-green-400",bg:"bg-green-500",bgLight:"bg-green-500/10",emoji:"\uD83D\uDFE2"}:c>=30?{text:"text-yellow-600 dark:text-yellow-400",bg:"bg-yellow-500",bgLight:"bg-yellow-500/10",emoji:"\uD83D\uDFE1"}:{text:"text-red-600 dark:text-red-400",bg:"bg-red-500",bgLight:"bg-red-500/10",emoji:"\uD83D\uDD34"},u=function(e){if(!e)return"-";try{let t="string"==typeof e?new Date(e):e,r=new Date,s=t-r;if(s<=0)return"-";let a=Math.ceil(s/6e4);if(a<60)return`${a}m`;let l=Math.floor(a/60),n=a%60;if(l<24)return`${l}h ${n}m`;let i=Math.floor(l/24);return`${i}d ${l%24}h ${n}m`}catch(e){return"-"}}(e.resetAt),m=function(e){if(!e)return null;try{let t=new Date(e),r=new Date,s=new Date(r.getFullYear(),r.getMonth(),r.getDate()),a=new Date(s);a.setDate(a.getDate()+1);let l="";l=t>=s&&t<a?"Today":t>=a&&t<new Date(a.getTime()+864e5)?"Tomorrow":t.toLocaleDateString("en-US",{month:"short",day:"numeric"});let n=t.toLocaleTimeString("en-US",{hour:"numeric",minute:"2-digit",hour12:!0});return`${l}, ${n}`}catch{return null}}(e.resetAt);return(0,s.jsxs)("tr",{className:"border-b border-black/5 dark:border-white/5 hover:bg-black/[0.02] dark:hover:bg-white/[0.02] transition-colors",children:[(0,s.jsx)("td",{className:r,children:(0,s.jsxs)("div",{className:"flex items-center gap-1.5 min-w-0",children:[(0,s.jsx)("span",{className:"text-[10px] shrink-0",children:d.emoji}),(0,s.jsx)("span",{className:`${a} font-medium text-text-primary truncate`,children:e.name})]})}),(0,s.jsx)("td",{className:r,children:(0,s.jsxs)("div",{className:t?"space-y-1":"space-y-1.5",children:[(0,s.jsx)("div",{className:`${t?"h-1":"h-1.5"} rounded-full overflow-hidden border ${d.bgLight} ${0===c?"border-black/10 dark:border-white/10":"border-transparent"}`,children:(0,s.jsx)("div",{className:`h-full transition-all duration-300 ${d.bg}`,style:{width:`${Math.min(c,100)}%`}})}),(0,s.jsxs)("div",{className:`flex items-center justify-between ${t?"text-[10px]":"text-xs"}`,children:[(0,s.jsxs)("span",{className:"text-text-muted",children:[e.used.toLocaleString()," / ",e.total>0?e.total.toLocaleString():"∞"]}),(0,s.jsxs)("span",{className:`font-medium ${d.text}`,children:[c,"%"]})]})]})}),(0,s.jsx)("td",{className:r,children:"-"!==u||m?(0,s.jsxs)("div",{className:"space-y-0.5",children:["-"!==u&&(0,s.jsxs)("div",{className:`${l} text-text-primary font-medium`,children:["in ",u]}),m&&(0,s.jsx)("div",{className:`${n} text-text-muted`,children:m})]}):(0,s.jsx)("div",{className:`${l} text-text-muted italic`,children:"N/A"})})]},o)})})]})})}var c=r(14406),d=r(292),u=r(38230),m=r(74156),x=r(82495);function h(){let[e,t]=(0,a.useState)([]),[r,h]=(0,a.useState)({}),[p,f]=(0,a.useState)({}),[g,b]=(0,a.useState)({}),[v,y]=(0,a.useState)(!0),[j,w]=(0,a.useState)(null),[N,k]=(0,a.useState)(!1),[$,E]=(0,a.useState)(60),[C,q]=(0,a.useState)(!0),[A,P]=(0,a.useState)(null),[S,D]=(0,a.useState)(null),[L,T]=(0,a.useState)(!1),[O,I]=(0,a.useState)(null),[M,_]=(0,a.useState)([]),R=(0,a.useRef)(null),U=(0,a.useRef)(null),z=(0,a.useCallback)(async()=>{try{let e=await fetch("/api/providers/client");if(!e.ok)throw Error("Failed to fetch connections");let r=(await e.json()).connections||[];return t(r),r}catch(e){return console.error("Error fetching connections:",e),t([]),[]}},[]),F=(0,a.useCallback)(async(e,t)=>{f(t=>({...t,[e]:!0})),b(t=>({...t,[e]:null}));try{console.log(`[ProviderLimits] Fetching quota for ${t} (${e})`);let r=await fetch(`/api/usage/${e}`);if(!r.ok){let s=(await r.json().catch(()=>({}))).error||r.statusText;if(404===r.status)return void console.warn(`[ProviderLimits] Connection not found for ${t}, skipping`);if(401===r.status){console.warn(`[ProviderLimits] Auth error for ${t}:`,s),h(t=>({...t,[e]:{quotas:[],message:s}}));return}throw Error(`HTTP ${r.status}: ${s}`)}let s=await r.json();console.log(`[ProviderLimits] Got quota for ${t}:`,s);let a=function(e,t){if(!t||"object"!=typeof t)return[];let r=[];try{switch(e.toLowerCase()){case"github":default:t.quotas&&Object.entries(t.quotas).forEach(([e,t])=>{r.push({name:e,used:t.used||0,total:t.total||0,resetAt:t.resetAt||null})});break;case"antigravity":t.quotas&&Object.entries(t.quotas).forEach(([e,t])=>{r.push({name:t.displayName||e,modelKey:e,used:t.used||0,total:t.total||0,resetAt:t.resetAt||null,remainingPercentage:t.remainingPercentage})});break;case"codex":t.quotas&&Object.entries(t.quotas).forEach(([e,t])=>{r.push({name:e,used:t.used||0,total:t.total||0,resetAt:t.resetAt||null})});break;case"kiro":t.quotas&&Object.entries(t.quotas).forEach(([e,t])=>{r.push({name:e,used:t.used||0,total:t.total||0,resetAt:t.resetAt||null})});break;case"claude":t.message?r.push({name:"error",used:0,total:0,resetAt:null,message:t.message}):t.quotas&&Object.entries(t.quotas).forEach(([e,t])=>{r.push({name:e,used:t.used||0,total:t.total||0,resetAt:t.resetAt||null})})}}catch(t){return console.error(`Error parsing quota data for ${e}:`,t),[]}let s=(0,n.KC)(e);if(s.length>0){let e=new Map(s.map((e,t)=>[e.id,t]));r.sort((t,r)=>{let s=t.modelKey||t.name,a=r.modelKey||r.name;return(e.get(s)??999)-(e.get(a)??999)})}return r}(t,s);h(t=>({...t,[e]:{quotas:a,plan:s.plan||null,message:s.message||null,raw:s}}))}catch(r){console.error(`[ProviderLimits] Error fetching quota for ${t} (${e}):`,r),b(t=>({...t,[e]:r.message||"Failed to fetch quota"}))}finally{f(t=>({...t,[e]:!1}))}},[]),K=(0,a.useCallback)(async(e,t)=>{await F(e,t),w(new Date)},[F]),J=(0,a.useCallback)(async e=>{if(confirm("Delete this connection?")){P(e);try{(await fetch(`/api/providers/${e}`,{method:"DELETE"})).ok&&(t(t=>t.filter(t=>t.id!==e)),h(t=>{let r={...t};return delete r[e],r}),f(t=>{let r={...t};return delete r[e],r}),b(t=>{let r={...t};return delete r[e],r}))}catch(e){console.error("Error deleting connection:",e)}finally{P(null)}}},[]),G=(0,a.useCallback)(async(e,r)=>{D(e);try{(await fetch(`/api/providers/${e}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({isActive:r})})).ok&&t(t=>t.map(t=>t.id===e?{...t,isActive:r}:t))}catch(e){console.error("Error updating connection status:",e)}finally{D(null)}},[]),H=(0,a.useCallback)(async e=>{if(!O?.id)return;let t=O.id,r=O.provider;try{(await fetch(`/api/providers/${t}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})).ok&&(await z(),T(!1),I(null),x.wb.includes(r)&&await F(t,r))}catch(e){console.error("Error saving connection:",e)}},[O,z,F]);(0,a.useEffect)(()=>{let e=!1;return fetch("/api/proxy-pools?isActive=true",{cache:"no-store"}).then(e=>e.json()).then(t=>{!e&&t?.proxyPools&&_(t.proxyPools)}).catch(()=>{}),()=>{e=!0}},[]);let Y=(0,a.useCallback)(async()=>{if(!N){k(!0),E(60);try{let e=(await z()).filter(e=>x.wb.includes(e.provider)&&"oauth"===e.authType);await Promise.all(e.map(e=>F(e.id,e.provider))),w(new Date)}catch(e){console.error("Error refreshing all providers:",e)}finally{k(!1)}}},[N,z,F]);(0,a.useEffect)(()=>{(async()=>{q(!0);let e=await z();q(!1);let t=e.filter(e=>x.wb.includes(e.provider)&&"oauth"===e.authType),r={};t.forEach(e=>{r[e.id]=!0}),f(r),await Promise.all(t.map(e=>F(e.id,e.provider))),w(new Date)})()},[]),(0,a.useEffect)(()=>{if(!v){R.current&&(clearInterval(R.current),R.current=null),U.current&&(clearInterval(U.current),U.current=null);return}return R.current=setInterval(()=>{Y()},6e4),U.current=setInterval(()=>{E(e=>e<=1?60:e-1)},1e3),()=>{R.current&&clearInterval(R.current),U.current&&clearInterval(U.current)}},[v,Y]),(0,a.useEffect)(()=>{let e=()=>{document.hidden?(R.current&&(clearInterval(R.current),R.current=null),U.current&&(clearInterval(U.current),U.current=null)):v&&(R.current=setInterval(Y,6e4),U.current=setInterval(()=>{E(e=>e<=1?60:e-1)},1e3))};return document.addEventListener("visibilitychange",e),()=>{document.removeEventListener("visibilitychange",e)}},[v,Y]);let B=(0,a.useCallback)(()=>{if(!j)return"Never";let e=Math.floor((new Date-j)/6e4),t=Math.floor(e/60),r=Math.floor(t/24);return r>0?`${r}d ago`:t>0?`${t}h ago`:e>0?`${e}m ago`:"Just now"},[j]),Q=[...e.filter(e=>x.wb.includes(e.provider)&&"oauth"===e.authType)].sort((e,t)=>{let r=x.wb.indexOf(e.provider),s=x.wb.indexOf(t.provider);return r!==s?r-s:e.provider.localeCompare(t.provider)});return(Q.length,Object.values(r).filter(e=>e?.quotas?.length>0).length,Object.values(r).reduce((e,t)=>t?.quotas?e+ +!!t.quotas.some(e=>30>i(e.used,e.total)&&e.total>0):e,0),C||0!==Q.length)?(0,s.jsxs)("div",{className:"space-y-6",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between flex-wrap gap-4",children:[(0,s.jsxs)("div",{className:"flex items-center gap-3",children:[(0,s.jsx)("h2",{className:"text-xl font-semibold text-text-primary",children:"Provider Limits"}),(0,s.jsxs)("span",{className:"text-sm text-text-muted",children:["Last updated: ",B()]})]}),(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsxs)("button",{onClick:()=>y(e=>!e),className:"flex items-center gap-2 px-3 py-2 rounded-lg border border-black/10 dark:border-white/10 hover:bg-black/5 dark:hover:bg-white/5 transition-colors",title:v?"Disable auto-refresh":"Enable auto-refresh",children:[(0,s.jsx)("span",{className:`material-symbols-outlined text-[18px] ${v?"text-primary":"text-text-muted"}`,children:v?"toggle_on":"toggle_off"}),(0,s.jsx)("span",{className:"text-sm text-text-primary",children:"Auto-refresh"}),v&&(0,s.jsxs)("span",{className:"text-xs text-text-muted",children:["(",$,"s)"]})]}),(0,s.jsx)(u.default,{variant:"secondary",size:"md",icon:"refresh",onClick:Y,disabled:N,loading:N,children:"Refresh All"})]})]}),(0,s.jsx)("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:Q.map(e=>{let t=r[e.id],a=p[e.id],n=g[e.id],i=!1===e.isActive,u=A===e.id||S===e.id;return(0,s.jsxs)(d.default,{padding:"none",className:`min-w-0 ${i?"opacity-60":""}`,children:[(0,s.jsx)("div",{className:"px-4 py-3 border-b border-black/10 dark:border-white/10",children:(0,s.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2 min-w-0",children:[(0,s.jsx)("div",{className:"w-8 h-8 shrink-0 rounded-md flex items-center justify-center overflow-hidden",children:(0,s.jsx)(l.A,{src:`/providers/${e.provider}.png`,alt:e.provider,size:32,className:"object-contain",fallbackText:e.provider?.slice(0,2).toUpperCase()||"PR"})}),(0,s.jsxs)("div",{className:"min-w-0",children:[(0,s.jsx)("h3",{className:"text-sm font-semibold text-text-primary capitalize truncate",children:e.provider}),e.name&&(0,s.jsx)("p",{className:"text-xs text-text-muted truncate",children:e.name})]})]}),(0,s.jsxs)("div",{className:"flex items-center gap-1 shrink-0",children:[(0,s.jsx)("button",{type:"button",onClick:()=>K(e.id,e.provider),disabled:a||u,className:"p-1.5 rounded-lg hover:bg-black/5 dark:hover:bg-white/5 transition-colors disabled:opacity-50",title:"Refresh quota",children:(0,s.jsx)("span",{className:`material-symbols-outlined text-[18px] text-text-muted ${a?"animate-spin":""}`,children:"refresh"})}),(0,s.jsx)("button",{type:"button",onClick:()=>{I(e),T(!0)},disabled:u,className:"p-1.5 rounded-lg hover:bg-black/5 dark:hover:bg-white/5 text-text-muted hover:text-primary transition-colors disabled:opacity-50",title:"Edit connection",children:(0,s.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:"edit"})}),(0,s.jsx)("button",{type:"button",onClick:()=>J(e.id),disabled:u,className:"p-1.5 rounded-lg hover:bg-red-500/10 text-red-500 transition-colors disabled:opacity-50",title:"Delete connection",children:(0,s.jsx)("span",{className:`material-symbols-outlined text-[18px] ${A===e.id?"animate-pulse":""}`,children:"delete"})}),(0,s.jsx)("div",{className:"inline-flex items-center pl-0.5",title:e.isActive??!0?"Disable connection":"Enable connection",children:(0,s.jsx)(c.default,{size:"sm",checked:e.isActive??!0,disabled:u,onChange:t=>G(e.id,t)})})]})]})}),(0,s.jsx)("div",{className:"px-3 py-3",children:a?(0,s.jsx)("div",{className:"text-center py-5 text-text-muted",children:(0,s.jsx)("span",{className:"material-symbols-outlined text-[28px] animate-spin",children:"progress_activity"})}):n?(0,s.jsxs)("div",{className:"text-center py-5",children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-[28px] text-red-500",children:"error"}),(0,s.jsx)("p",{className:"mt-1.5 text-xs text-text-muted",children:n})]}):t?.message?(0,s.jsx)("div",{className:"text-center py-5",children:(0,s.jsx)("p",{className:"text-xs text-text-muted",children:t.message})}):(0,s.jsx)(o,{quotas:t?.quotas,compact:!0})})]},e.id)})}),(0,s.jsx)(m.wI,{isOpen:L,connection:O,proxyPools:M,onSave:H,onClose:()=>{T(!1),I(null)}})]}):(0,s.jsx)(d.default,{padding:"lg",children:(0,s.jsxs)("div",{className:"text-center py-12",children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-[64px] text-text-muted opacity-20",children:"cloud_off"}),(0,s.jsx)("h3",{className:"mt-4 text-lg font-semibold text-text-primary",children:"No Providers Connected"}),(0,s.jsx)("p",{className:"mt-2 text-sm text-text-muted max-w-md mx-auto",children:"Connect to providers with OAuth to track your API quota limits and usage."})]})})}}},e=>{e.O(0,[7848,4335,2599,505,4156,2347,5158,7358],()=>e(e.s=58944)),_N_E=e.O()}]);
@@ -1 +1 @@
1
- (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[3528],{1976:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n={bindSnapshot:function(){return i},createAsyncLocalStorage:function(){return o},createSnapshot:function(){return d}};for(var r in n)Object.defineProperty(t,r,{enumerable:!0,get:n[r]});let a=Object.defineProperty(Error("Invariant: AsyncLocalStorage accessed in runtime where it is not available"),"__NEXT_ERROR_CODE",{value:"E504",enumerable:!1,configurable:!0});class s{disable(){throw a}getStore(){}run(){throw a}exit(){throw a}enterWith(){throw a}static bind(e){return e}}let l="u">typeof globalThis&&globalThis.AsyncLocalStorage;function o(){return l?new l:new s}function i(e){return l?l.bind(e):s.bind(e)}function d(){return l?l.snapshot():function(e,...t){return e(...t)}}},26599:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),Object.defineProperty(t,"default",{enumerable:!0,get:function(){return a}});let r=n(12563)._(n(51343));function a(e,t){let n={};"function"==typeof e&&(n.loader=e);let a={...n,...t};return(0,r.default)({...a,modules:a.loadableGenerated?.modules})}("function"==typeof t.default||"object"==typeof t.default&&null!==t.default)&&void 0===t.default.__esModule&&(Object.defineProperty(t.default,"__esModule",{value:!0}),Object.assign(t.default,t),e.exports=t.default)},38372:(e,t,n)=>{"use strict";function r({reason:e,children:t}){return t}Object.defineProperty(t,"__esModule",{value:!0}),Object.defineProperty(t,"BailoutToCSR",{enumerable:!0,get:function(){return r}}),n(24104)},51343:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),Object.defineProperty(t,"default",{enumerable:!0,get:function(){return i}});let r=n(73365),a=n(1521),s=n(38372);function l(e){return{default:e&&"default"in e?e.default:e}}n(52393);let o={loader:()=>Promise.resolve(l(()=>null)),loading:null,ssr:!0},i=function(e){let t={...o,...e},n=(0,a.lazy)(()=>t.loader().then(l)),i=t.loading;function d(e){let l=i?(0,r.jsx)(i,{isLoading:!0,pastDelay:!0,error:null}):null,o=!t.ssr||!!t.loading,d=o?a.Suspense:a.Fragment,c=t.ssr?(0,r.jsxs)(r.Fragment,{children:[null,(0,r.jsx)(n,{...e})]}):(0,r.jsx)(s.BailoutToCSR,{reason:"next/dynamic",children:(0,r.jsx)(n,{...e})});return(0,r.jsx)(d,{...o?{fallback:l}:{},children:c})}return d.displayName="LoadableComponent",d}},52393:(e,t,n)=>{"use strict";function r({moduleIds:e}){return null}Object.defineProperty(t,"__esModule",{value:!0}),Object.defineProperty(t,"PreloadChunks",{enumerable:!0,get:function(){return r}}),n(73365),n(98196),n(89442),n(91319),n(68491)},54053:(e,t,n)=>{"use strict";n.r(t),n.d(t,{default:()=>c});var r=n(73365),a=n(1521),s=n(74156),l=n(26599);let o=n.n(l)()(()=>n.e(1310).then(n.bind(n,41310)),{loadableGenerated:{webpack:()=>[41310]},ssr:!1}),i=[{id:1,label:"Client Request",file:"1_req_client.json",lang:"json",desc:"Raw request from client"},{id:2,label:"Source Body",file:"2_req_source.json",lang:"json",desc:"After initial conversion"},{id:3,label:"OpenAI Intermediate",file:"3_req_openai.json",lang:"json",desc:"source → openai"},{id:4,label:"Target Request",file:"4_req_target.json",lang:"json",desc:"openai → target + URL + headers"},{id:5,label:"Provider Response",file:"5_res_provider.txt",lang:"text",desc:"Raw SSE from provider"},{id:6,label:"OpenAI Response",file:"6_res_openai.txt",lang:"text",desc:"target → openai (response)"},{id:7,label:"Client Response",file:"7_res_client.txt",lang:"text",desc:"Final response to client"}],d={minimap:{enabled:!1},fontSize:12,lineNumbers:"on",scrollBeyondLastLine:!1,wordWrap:"on",automaticLayout:!0};function c(){let[e,t]=(0,a.useState)({}),[n,l]=(0,a.useState)({1:!0}),[c,p]=(0,a.useState)({}),[f,x]=(0,a.useState)(null),m=(e,t)=>p(n=>({...n,[e]:t})),g=(e,n)=>t(t=>({...t,[e]:n})),h=e=>l(t=>{let n={};return i.forEach(e=>{n[e.id]=!1}),n[e]=!0,n}),b=async e=>{let t=i.find(t=>t.id===e);m(`load-${e}`,!0);try{let n=await fetch(`/api/translator/load?file=${t.file}`),r=await n.json();r.success?(g(e,r.content),1===e&&await y(r.content)):alert(r.error||"File not found")}catch(e){alert(e.message)}m(`load-${e}`,!1)},y=async e=>{try{let t="string"==typeof e?JSON.parse(e):e,n=await fetch("/api/translator/translate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({step:1,body:t})}),r=await n.json();r.success&&x(r.result)}catch{}},j=(e,t)=>fetch("/api/translator/save",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({file:e,content:t})}).catch(()=>{}),_=async()=>{m("toOpenAI",!0);try{let t=e[1],n=JSON.parse(t);j("1_req_client.json",t),j("2_req_source.json",JSON.stringify({timestamp:new Date().toISOString(),headers:{},body:n.body||n},null,2));let r=await fetch("/api/translator/translate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({step:2,body:n})}),a=await r.json();if(!a.success)return void alert(a.error);let s=JSON.stringify(a.result.body,null,2);g(3,s),h(3)}catch(e){alert(e.message)}m("toOpenAI",!1)},v=async()=>{m("toTarget",!0);try{let t=e[3],n=JSON.parse(t);j("3_req_openai.json",t);let r=await fetch("/api/translator/translate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({step:3,body:{...n,provider:f?.provider,model:f?.model}})}),a=await r.json();if(!a.success)return void alert(a.error);let s={...a.result,provider:f?.provider,model:f?.model};g(4,JSON.stringify(s,null,2)),h(4)}catch(e){alert(e.message)}m("toTarget",!1)},O=async()=>{m("send",!0);try{let t=e[4],n=JSON.parse(t);j("4_req_target.json",t);let r=n.provider||f?.provider,a=n.model||f?.model;if(!r||!a)return void alert("Missing provider or model. Please run step 1 first to detect them.");let s=await fetch("/api/translator/send",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:r,model:a,body:n.body||n})});if(!s.ok){let e=await s.json().catch(()=>({error:s.statusText}));alert(e.error||"Send failed");return}let l=s.body.getReader(),o=new TextDecoder,i="";for(;;){let{done:e,value:t}=await l.read();if(e)break;i+=o.decode(t,{stream:!0})}g(5,i),h(5),await fetch("/api/translator/save",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({file:"5_res_provider.txt",content:i})})}catch(e){alert(e.message)}finally{m("send",!1)}},w=async t=>{e[t]&&await navigator.clipboard.writeText(e[t])};return(0,r.jsxs)("div",{className:"p-8 space-y-3",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between mb-2",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("h1",{className:"text-2xl font-bold text-text-main",children:"Translator Debug"}),(0,r.jsx)("p",{className:"text-sm text-text-muted mt-1",children:"Replay request flow — matches log files"})]}),f&&(0,r.jsxs)("div",{className:"flex items-center gap-2 flex-wrap justify-end",children:[(0,r.jsx)(u,{label:"src",value:f.sourceFormat,color:"blue"}),(0,r.jsx)("span",{className:"material-symbols-outlined text-text-muted text-[14px]",children:"arrow_forward"}),(0,r.jsx)(u,{label:"dst",value:f.targetFormat,color:"orange"}),(0,r.jsx)(u,{label:"provider",value:f.provider,color:"green"}),(0,r.jsx)(u,{label:"model",value:f.model,color:"purple"})]})]}),i.map(t=>{var a;let i=1===(a=t.id)?(0,r.jsx)(s.$n,{size:"sm",icon:"arrow_forward",loading:c.toOpenAI,onClick:_,children:"→ OpenAI"}):3===a?(0,r.jsx)(s.$n,{size:"sm",icon:"arrow_forward",loading:c.toTarget,onClick:v,children:"→ Target"}):4===a?(0,r.jsx)(s.$n,{size:"sm",icon:"send",loading:c.send,onClick:O,children:"Send"}):null,u=!!n[t.id],p=e[t.id]||"";return(0,r.jsx)(s.Zp,{children:(0,r.jsxs)("div",{className:"p-4 space-y-3",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between",children:[(0,r.jsxs)("button",{onClick:()=>{let e;return e=t.id,l(t=>({...t,[e]:!t[e]}))},className:"flex items-center gap-2 flex-1 text-left group",children:[(0,r.jsx)("span",{className:"material-symbols-outlined text-[20px] text-text-muted group-hover:text-primary transition-colors",children:u?"expand_more":"chevron_right"}),(0,r.jsx)("span",{className:"text-xs font-mono text-text-muted/60 w-4",children:t.id}),(0,r.jsx)("h3",{className:"text-sm font-semibold text-text-main",children:t.label}),(0,r.jsx)("span",{className:"text-xs text-text-muted/60 font-mono",children:t.file}),p&&(0,r.jsxs)("span",{className:"text-xs text-green-500",children:["(",p.length," chars)"]})]}),!u&&(0,r.jsxs)("div",{className:"flex gap-1 shrink-0",children:[(0,r.jsx)(s.$n,{size:"sm",variant:"ghost",icon:"folder_open",loading:c[`load-${t.id}`],onClick:()=>b(t.id)}),i]})]}),u&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("div",{className:"border border-border rounded-lg overflow-hidden",children:(0,r.jsx)(o,{height:"400px",defaultLanguage:"text"===t.lang?"plaintext":"json",value:p,onChange:e=>{g(t.id,e||""),1===t.id&&y(e||"")},theme:"vs-dark",options:d})}),(0,r.jsxs)("div",{className:"flex gap-2 flex-wrap",children:[(0,r.jsx)(s.$n,{size:"sm",variant:"outline",icon:"folder_open",loading:c[`load-${t.id}`],onClick:()=>b(t.id),children:"Load"}),(0,r.jsx)(s.$n,{size:"sm",variant:"outline",icon:"data_object",onClick:()=>(t=>{try{let n=JSON.parse(e[t]);g(t,JSON.stringify(n,null,2))}catch{}})(t.id),children:"Format"}),(0,r.jsx)(s.$n,{size:"sm",variant:"outline",icon:"content_copy",onClick:()=>w(t.id),children:"Copy"}),i]})]})]})},t.id)})]})}function u({label:e,value:t,color:n}){return(0,r.jsxs)("span",{className:`inline-flex items-center gap-1 px-2 py-0.5 rounded text-xs font-mono ${{blue:"bg-blue-500/10 text-blue-500",orange:"bg-orange-500/10 text-orange-500",green:"bg-green-500/10 text-green-500",purple:"bg-purple-500/10 text-purple-500"}[n]}`,children:[(0,r.jsxs)("span",{className:"text-text-muted/70 font-sans text-[10px]",children:[e,":"]}),t]})}},86673:(e,t,n)=>{Promise.resolve().then(n.bind(n,54053))},89442:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),Object.defineProperty(t,"workAsyncStorage",{enumerable:!0,get:function(){return r.workAsyncStorageInstance}});let r=n(99238)},99238:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),Object.defineProperty(t,"workAsyncStorageInstance",{enumerable:!0,get:function(){return r}});let r=(0,n(1976).createAsyncLocalStorage)()}},e=>{e.O(0,[7848,4335,2599,350,4156,2347,5158,7358],()=>e(e.s=86673)),_N_E=e.O()}]);
1
+ (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[3528],{1976:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n={bindSnapshot:function(){return i},createAsyncLocalStorage:function(){return o},createSnapshot:function(){return d}};for(var r in n)Object.defineProperty(t,r,{enumerable:!0,get:n[r]});let a=Object.defineProperty(Error("Invariant: AsyncLocalStorage accessed in runtime where it is not available"),"__NEXT_ERROR_CODE",{value:"E504",enumerable:!1,configurable:!0});class s{disable(){throw a}getStore(){}run(){throw a}exit(){throw a}enterWith(){throw a}static bind(e){return e}}let l="u">typeof globalThis&&globalThis.AsyncLocalStorage;function o(){return l?new l:new s}function i(e){return l?l.bind(e):s.bind(e)}function d(){return l?l.snapshot():function(e,...t){return e(...t)}}},26599:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),Object.defineProperty(t,"default",{enumerable:!0,get:function(){return a}});let r=n(12563)._(n(51343));function a(e,t){let n={};"function"==typeof e&&(n.loader=e);let a={...n,...t};return(0,r.default)({...a,modules:a.loadableGenerated?.modules})}("function"==typeof t.default||"object"==typeof t.default&&null!==t.default)&&void 0===t.default.__esModule&&(Object.defineProperty(t.default,"__esModule",{value:!0}),Object.assign(t.default,t),e.exports=t.default)},38372:(e,t,n)=>{"use strict";function r({reason:e,children:t}){return t}Object.defineProperty(t,"__esModule",{value:!0}),Object.defineProperty(t,"BailoutToCSR",{enumerable:!0,get:function(){return r}}),n(24104)},51343:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),Object.defineProperty(t,"default",{enumerable:!0,get:function(){return i}});let r=n(73365),a=n(1521),s=n(38372);function l(e){return{default:e&&"default"in e?e.default:e}}n(52393);let o={loader:()=>Promise.resolve(l(()=>null)),loading:null,ssr:!0},i=function(e){let t={...o,...e},n=(0,a.lazy)(()=>t.loader().then(l)),i=t.loading;function d(e){let l=i?(0,r.jsx)(i,{isLoading:!0,pastDelay:!0,error:null}):null,o=!t.ssr||!!t.loading,d=o?a.Suspense:a.Fragment,c=t.ssr?(0,r.jsxs)(r.Fragment,{children:[null,(0,r.jsx)(n,{...e})]}):(0,r.jsx)(s.BailoutToCSR,{reason:"next/dynamic",children:(0,r.jsx)(n,{...e})});return(0,r.jsx)(d,{...o?{fallback:l}:{},children:c})}return d.displayName="LoadableComponent",d}},52393:(e,t,n)=>{"use strict";function r({moduleIds:e}){return null}Object.defineProperty(t,"__esModule",{value:!0}),Object.defineProperty(t,"PreloadChunks",{enumerable:!0,get:function(){return r}}),n(73365),n(98196),n(89442),n(91319),n(68491)},54053:(e,t,n)=>{"use strict";n.r(t),n.d(t,{default:()=>c});var r=n(73365),a=n(1521),s=n(74156),l=n(26599);let o=n.n(l)()(()=>n.e(1310).then(n.bind(n,41310)),{loadableGenerated:{webpack:()=>[41310]},ssr:!1}),i=[{id:1,label:"Client Request",file:"1_req_client.json",lang:"json",desc:"Raw request from client"},{id:2,label:"Source Body",file:"2_req_source.json",lang:"json",desc:"After initial conversion"},{id:3,label:"OpenAI Intermediate",file:"3_req_openai.json",lang:"json",desc:"source → openai"},{id:4,label:"Target Request",file:"4_req_target.json",lang:"json",desc:"openai → target + URL + headers"},{id:5,label:"Provider Response",file:"5_res_provider.txt",lang:"text",desc:"Raw SSE from provider"},{id:6,label:"OpenAI Response",file:"6_res_openai.txt",lang:"text",desc:"target → openai (response)"},{id:7,label:"Client Response",file:"7_res_client.txt",lang:"text",desc:"Final response to client"}],d={minimap:{enabled:!1},fontSize:12,lineNumbers:"on",scrollBeyondLastLine:!1,wordWrap:"on",automaticLayout:!0};function c(){let[e,t]=(0,a.useState)({}),[n,l]=(0,a.useState)({1:!0}),[c,p]=(0,a.useState)({}),[f,x]=(0,a.useState)(null),m=(e,t)=>p(n=>({...n,[e]:t})),g=(e,n)=>t(t=>({...t,[e]:n})),h=e=>l(t=>{let n={};return i.forEach(e=>{n[e.id]=!1}),n[e]=!0,n}),b=async e=>{let t=i.find(t=>t.id===e);m(`load-${e}`,!0);try{let n=await fetch(`/api/translator/load?file=${t.file}`),r=await n.json();r.success?(g(e,r.content),1===e&&await y(r.content)):alert(r.error||"File not found")}catch(e){alert(e.message)}m(`load-${e}`,!1)},y=async e=>{try{let t="string"==typeof e?JSON.parse(e):e,n=await fetch("/api/translator/translate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({step:1,body:t})}),r=await n.json();r.success&&x(r.result)}catch{}},j=(e,t)=>fetch("/api/translator/save",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({file:e,content:t})}).catch(()=>{}),_=async()=>{m("toOpenAI",!0);try{let t=e[1],n=JSON.parse(t);j("1_req_client.json",t),j("2_req_source.json",JSON.stringify({timestamp:new Date().toISOString(),headers:{},body:n.body||n},null,2));let r=await fetch("/api/translator/translate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({step:2,body:n})}),a=await r.json();if(!a.success)return void alert(a.error);let s=JSON.stringify(a.result.body,null,2);g(3,s),h(3)}catch(e){alert(e.message)}m("toOpenAI",!1)},v=async()=>{m("toTarget",!0);try{let t=e[3],n=JSON.parse(t);j("3_req_openai.json",t);let r=await fetch("/api/translator/translate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({step:3,body:{...n,provider:f?.provider,model:f?.model}})}),a=await r.json();if(!a.success)return void alert(a.error);let s={...a.result,provider:f?.provider,model:f?.model};g(4,JSON.stringify(s,null,2)),h(4)}catch(e){alert(e.message)}m("toTarget",!1)},O=async()=>{m("send",!0);try{let t=e[4],n=JSON.parse(t);j("4_req_target.json",t);let r=n.provider||f?.provider,a=n.model||f?.model;if(!r||!a)return void alert("Missing provider or model. Please run step 1 first to detect them.");let s=await fetch("/api/translator/send",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:r,model:a,body:n.body||n})});if(!s.ok){let e=await s.json().catch(()=>({error:s.statusText}));alert(e.error||"Send failed");return}let l=s.body.getReader(),o=new TextDecoder,i="";for(;;){let{done:e,value:t}=await l.read();if(e)break;i+=o.decode(t,{stream:!0})}g(5,i),h(5),await fetch("/api/translator/save",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({file:"5_res_provider.txt",content:i})})}catch(e){alert(e.message)}finally{m("send",!1)}},w=async t=>{e[t]&&await navigator.clipboard.writeText(e[t])};return(0,r.jsxs)("div",{className:"p-8 space-y-3",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between mb-2",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("h1",{className:"text-2xl font-bold text-text-main",children:"Translator Debug"}),(0,r.jsx)("p",{className:"text-sm text-text-muted mt-1",children:"Replay request flow — matches log files"})]}),f&&(0,r.jsxs)("div",{className:"flex items-center gap-2 flex-wrap justify-end",children:[(0,r.jsx)(u,{label:"src",value:f.sourceFormat,color:"blue"}),(0,r.jsx)("span",{className:"material-symbols-outlined text-text-muted text-[14px]",children:"arrow_forward"}),(0,r.jsx)(u,{label:"dst",value:f.targetFormat,color:"orange"}),(0,r.jsx)(u,{label:"provider",value:f.provider,color:"green"}),(0,r.jsx)(u,{label:"model",value:f.model,color:"purple"})]})]}),i.map(t=>{var a;let i=1===(a=t.id)?(0,r.jsx)(s.$n,{size:"sm",icon:"arrow_forward",loading:c.toOpenAI,onClick:_,children:"→ OpenAI"}):3===a?(0,r.jsx)(s.$n,{size:"sm",icon:"arrow_forward",loading:c.toTarget,onClick:v,children:"→ Target"}):4===a?(0,r.jsx)(s.$n,{size:"sm",icon:"send",loading:c.send,onClick:O,children:"Send"}):null,u=!!n[t.id],p=e[t.id]||"";return(0,r.jsx)(s.Zp,{children:(0,r.jsxs)("div",{className:"p-4 space-y-3",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between",children:[(0,r.jsxs)("button",{onClick:()=>{let e;return e=t.id,l(t=>({...t,[e]:!t[e]}))},className:"flex items-center gap-2 flex-1 text-left group",children:[(0,r.jsx)("span",{className:"material-symbols-outlined text-[20px] text-text-muted group-hover:text-primary transition-colors",children:u?"expand_more":"chevron_right"}),(0,r.jsx)("span",{className:"text-xs font-mono text-text-muted/60 w-4",children:t.id}),(0,r.jsx)("h3",{className:"text-sm font-semibold text-text-main",children:t.label}),(0,r.jsx)("span",{className:"text-xs text-text-muted/60 font-mono",children:t.file}),p&&(0,r.jsxs)("span",{className:"text-xs text-green-500",children:["(",p.length," chars)"]})]}),!u&&(0,r.jsxs)("div",{className:"flex gap-1 shrink-0",children:[(0,r.jsx)(s.$n,{size:"sm",variant:"ghost",icon:"folder_open",loading:c[`load-${t.id}`],onClick:()=>b(t.id)}),i]})]}),u&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("div",{className:"border border-border rounded-lg overflow-hidden",children:(0,r.jsx)(o,{height:"400px",defaultLanguage:"text"===t.lang?"plaintext":"json",value:p,onChange:e=>{g(t.id,e||""),1===t.id&&y(e||"")},theme:"vs-dark",options:d})}),(0,r.jsxs)("div",{className:"flex gap-2 flex-wrap",children:[(0,r.jsx)(s.$n,{size:"sm",variant:"outline",icon:"folder_open",loading:c[`load-${t.id}`],onClick:()=>b(t.id),children:"Load"}),(0,r.jsx)(s.$n,{size:"sm",variant:"outline",icon:"data_object",onClick:()=>(t=>{try{let n=JSON.parse(e[t]);g(t,JSON.stringify(n,null,2))}catch{}})(t.id),children:"Format"}),(0,r.jsx)(s.$n,{size:"sm",variant:"outline",icon:"content_copy",onClick:()=>w(t.id),children:"Copy"}),i]})]})]})},t.id)})]})}function u({label:e,value:t,color:n}){return(0,r.jsxs)("span",{className:`inline-flex items-center gap-1 px-2 py-0.5 rounded text-xs font-mono ${{blue:"bg-blue-500/10 text-blue-500",orange:"bg-orange-500/10 text-orange-500",green:"bg-green-500/10 text-green-500",purple:"bg-purple-500/10 text-purple-500"}[n]}`,children:[(0,r.jsxs)("span",{className:"text-text-muted/70 font-sans text-[10px]",children:[e,":"]}),t]})}},86673:(e,t,n)=>{Promise.resolve().then(n.bind(n,54053))},89442:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),Object.defineProperty(t,"workAsyncStorage",{enumerable:!0,get:function(){return r.workAsyncStorageInstance}});let r=n(99238)},99238:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),Object.defineProperty(t,"workAsyncStorageInstance",{enumerable:!0,get:function(){return r}});let r=(0,n(1976).createAsyncLocalStorage)()}},e=>{e.O(0,[7848,4335,2599,505,4156,2347,5158,7358],()=>e(e.s=86673)),_N_E=e.O()}]);
@@ -1 +1 @@
1
- (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[2825],{33154:(e,t,s)=>{Promise.resolve().then(s.bind(s,83101))},83101:(e,t,s)=>{"use strict";s.r(t),s.d(t,{default:()=>g});var a=s(73365),r=s(1521),n=s(29717),l=s(74156),i=s(292),d=s(38230),o=s(87706);function c({isOpen:e,onClose:t,title:s,children:n,width:l="md",className:i}){let d={sm:"w-[400px]",md:"w-[500px]",lg:"w-[600px]",xl:"w-[800px]",full:"w-full"};return((0,r.useEffect)(()=>(e?document.body.style.overflow="hidden":document.body.style.overflow="",()=>{document.body.style.overflow=""}),[e]),(0,r.useEffect)(()=>{let s=s=>{"Escape"===s.key&&e&&t()};return document.addEventListener("keydown",s),()=>document.removeEventListener("keydown",s)},[e,t]),e)?(0,a.jsxs)("div",{className:"fixed inset-0 z-50",children:[(0,a.jsx)("div",{className:"absolute inset-0 bg-black/50 backdrop-blur-sm transition-opacity cursor-pointer",onClick:t,"aria-hidden":"true"}),(0,a.jsxs)("div",{className:(0,o.cn)("absolute right-0 top-0 h-full bg-surface shadow-2xl flex flex-col","animate-in slide-in-from-right duration-200","border-l border-black/10 dark:border-white/10",d[l]||d.md,i),children:[(0,a.jsxs)("div",{className:"flex items-center justify-between p-6 border-b border-black/5 dark:border-white/5 flex-shrink-0",children:[(0,a.jsx)("div",{className:"flex items-center gap-3",children:s&&(0,a.jsx)("h2",{className:"text-lg font-semibold text-text-main",children:s})}),(0,a.jsx)("button",{type:"button",onClick:t,className:"p-1.5 rounded-lg text-text-muted hover:bg-black/5 dark:hover:bg-white/5 transition-colors",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[20px]",children:"close"})})]}),(0,a.jsx)("div",{className:"flex-1 overflow-y-auto p-6",children:n})]})]}):null}function x({currentPage:e,pageSize:t,totalItems:s,onPageChange:r,onPageSizeChange:n,className:l}){let i=Math.ceil(s/t),c=s>0?(e-1)*t+1:0,m=Math.min(e*t,s),h=(()=>{let t=[],s=Math.max(1,e-2),a=Math.min(i,s+5-1);a-s+1<5&&(s=Math.max(1,a-5+1));for(let e=s;e<=a;e++)t.push(e);return t})();return(0,a.jsxs)("div",{className:(0,o.cn)("flex flex-col sm:flex-row items-center justify-between gap-4 py-4",l),children:[s>0&&(0,a.jsxs)("div",{className:"text-sm text-text-muted",children:["Showing ",(0,a.jsx)("span",{className:"font-medium text-text-main",children:c})," to"," ",(0,a.jsx)("span",{className:"font-medium text-text-main",children:m})," of"," ",(0,a.jsx)("span",{className:"font-medium text-text-main",children:s})," results"]}),(0,a.jsxs)("div",{className:"flex items-center gap-4",children:[n&&(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("span",{className:"text-sm text-text-muted",children:"Rows:"}),(0,a.jsx)("select",{value:t,onChange:e=>n(Number(e.target.value)),className:(0,o.cn)("h-9 rounded-lg border border-black/10 dark:border-white/10 bg-surface","text-sm text-text-main focus:outline-none focus:ring-2 focus:ring-primary/20","cursor-pointer"),children:[10,20,50].map(e=>(0,a.jsx)("option",{value:e,children:e},e))})]}),i>1&&(0,a.jsxs)("div",{className:"flex items-center gap-1",children:[(0,a.jsx)(d.default,{variant:"outline",size:"sm",onClick:()=>r(e-1),disabled:1===e,className:"w-9 px-0",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:"chevron_left"})}),h[0]>1&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(d.default,{variant:"ghost",size:"sm",onClick:()=>r(1),className:"w-9 px-0",children:"1"}),h[0]>2&&(0,a.jsx)("span",{className:"text-text-muted px-1",children:"..."})]}),h.map(t=>(0,a.jsx)(d.default,{variant:e===t?"primary":"ghost",size:"sm",onClick:()=>r(t),className:"w-9 px-0",children:t},t)),h[h.length-1]<i&&(0,a.jsxs)(a.Fragment,{children:[h[h.length-1]<i-1&&(0,a.jsx)("span",{className:"text-text-muted px-1",children:"..."}),(0,a.jsx)(d.default,{variant:"ghost",size:"sm",onClick:()=>r(i),className:"w-9 px-0",children:i})]}),(0,a.jsx)(d.default,{variant:"outline",size:"sm",onClick:()=>r(e+1),disabled:e===i,className:"w-9 px-0",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:"chevron_right"})})]})]})]})}var m=s(82495);let h=null,p=null;async function u(){if(h&&p)return{providerNameCache:h,providerNodesCache:p};let e=await fetch("/api/provider-nodes"),t=(await e.json()).nodes||[];for(let e of(p={},t))p[e.id]=e.name;return{providerNameCache:h={...m.Q2,...p},providerNodesCache:p}}function f(e,t){if(!e||!t)return e;let s=t[e];if("string"==typeof s)return s;if(s?.name)return s.name;let a=(0,m.zt)(e)||m.Q2[e];return a?.name||e}function b({title:e,children:t,defaultOpen:s=!1,icon:n=null}){let[l,i]=(0,r.useState)(s);return(0,a.jsxs)("div",{className:"border border-black/5 dark:border-white/5 rounded-lg overflow-hidden",children:[(0,a.jsxs)("button",{type:"button",onClick:()=>i(!l),className:"w-full flex items-center justify-between p-3 bg-black/[0.02] dark:bg-white/[0.02] hover:bg-black/[0.04] dark:hover:bg-white/[0.04] transition-colors",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[n&&(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px] text-text-muted",children:n}),(0,a.jsx)("span",{className:"font-semibold text-sm text-text-main",children:e})]}),(0,a.jsx)("span",{className:(0,o.cn)("material-symbols-outlined text-[20px] text-text-muted transition-transform duration-200",l?"rotate-90":""),children:"chevron_right"})]}),l&&(0,a.jsx)("div",{className:"p-4 border-t border-black/5 dark:border-white/5",children:t})]})}function j(){let[e,t]=(0,r.useState)([]),[s,n]=(0,r.useState)({page:1,pageSize:20,totalItems:0,totalPages:0}),[l,m]=(0,r.useState)(!1),[h,p]=(0,r.useState)(null),[j,g]=(0,r.useState)(!1),[v,N]=(0,r.useState)([]),[k,w]=(0,r.useState)(null),[y,S]=(0,r.useState)({provider:"",startDate:"",endDate:""}),C=(0,r.useCallback)(async()=>{try{let e=await fetch("/api/usage/providers"),t=await e.json();N(t.providers||[]);let s=await u();w(s.providerNameCache)}catch(e){console.error("Failed to fetch providers:",e)}},[]),D=(0,r.useCallback)(async()=>{m(!0);try{let e=new URLSearchParams({page:s.page.toString(),pageSize:s.pageSize.toString()});y.provider&&e.append("provider",y.provider),y.startDate&&e.append("startDate",y.startDate),y.endDate&&e.append("endDate",y.endDate);let a=await fetch(`/api/usage/request-details?${e}`),r=await a.json();t(r.details||[]),n(e=>({...e,...r.pagination}))}catch(e){console.error("Failed to fetch request details:",e)}finally{m(!1)}},[s.page,s.pageSize,y]);return(0,r.useEffect)(()=>{C()},[C]),(0,r.useEffect)(()=>{D()},[D]),(0,a.jsxs)("div",{className:"flex flex-col gap-6",children:[(0,a.jsx)(i.default,{padding:"md",children:(0,a.jsxs)("div",{className:"flex flex-wrap gap-4",children:[(0,a.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,a.jsx)("label",{htmlFor:"provider-filter",className:"text-sm font-medium text-text-main",children:"Provider"}),(0,a.jsxs)("select",{id:"provider-filter",value:y.provider,onChange:e=>S({...y,provider:e.target.value}),className:(0,o.cn)("h-9 px-3 rounded-lg border border-black/10 dark:border-white/10 bg-surface","text-sm text-text-main focus:outline-none focus:ring-2 focus:ring-primary/20","cursor-pointer min-w-[150px]"),children:[(0,a.jsx)("option",{value:"",children:"All Providers"}),v.map(e=>(0,a.jsx)("option",{value:e.id,children:e.name},e.id))]})]}),(0,a.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,a.jsx)("label",{htmlFor:"start-date-filter",className:"text-sm font-medium text-text-main",children:"Start Date"}),(0,a.jsx)("input",{id:"start-date-filter",type:"datetime-local",value:y.startDate,onChange:e=>S({...y,startDate:e.target.value}),className:(0,o.cn)("h-9 px-3 rounded-lg border border-black/10 dark:border-white/10 bg-surface","text-sm text-text-main focus:outline-none focus:ring-2 focus:ring-primary/20")})]}),(0,a.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,a.jsx)("label",{htmlFor:"end-date-filter",className:"text-sm font-medium text-text-main",children:"End Date"}),(0,a.jsx)("input",{id:"end-date-filter",type:"datetime-local",value:y.endDate,onChange:e=>S({...y,endDate:e.target.value}),className:(0,o.cn)("h-9 px-3 rounded-lg border border-black/10 dark:border-white/10 bg-surface","text-sm text-text-main focus:outline-none focus:ring-2 focus:ring-primary/20")})]}),(0,a.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,a.jsx)("span",{className:"text-sm font-medium text-text-main opacity-0","aria-hidden":"true",children:"Clear"}),(0,a.jsx)(d.default,{variant:"ghost",onClick:()=>{S({provider:"",startDate:"",endDate:""})},disabled:!y.provider&&!y.startDate&&!y.endDate,children:"Clear Filters"})]})]})}),(0,a.jsxs)(i.default,{padding:"none",children:[(0,a.jsx)("div",{className:"overflow-x-auto",children:(0,a.jsxs)("table",{className:"w-full",children:[(0,a.jsx)("thead",{children:(0,a.jsxs)("tr",{className:"border-b border-black/5 dark:border-white/5",children:[(0,a.jsx)("th",{className:"text-left p-4 text-sm font-semibold text-text-main",children:"Timestamp"}),(0,a.jsx)("th",{className:"text-left p-4 text-sm font-semibold text-text-main",children:"Model"}),(0,a.jsx)("th",{className:"text-left p-4 text-sm font-semibold text-text-main",children:"Provider"}),(0,a.jsx)("th",{className:"text-right p-4 text-sm font-semibold text-text-main",children:"Input Tokens"}),(0,a.jsx)("th",{className:"text-right p-4 text-sm font-semibold text-text-main",children:"Output Tokens"}),(0,a.jsx)("th",{className:"text-left p-4 text-sm font-semibold text-text-main",children:"Latency"}),(0,a.jsx)("th",{className:"text-center p-4 text-sm font-semibold text-text-main",children:"Action"})]})}),(0,a.jsx)("tbody",{children:l?(0,a.jsx)("tr",{children:(0,a.jsx)("td",{colSpan:"7",className:"p-8 text-center text-text-muted",children:(0,a.jsxs)("div",{className:"flex items-center justify-center gap-2",children:[(0,a.jsx)("span",{className:"material-symbols-outlined animate-spin text-[20px]",children:"progress_activity"}),"Loading..."]})})}):0===e.length?(0,a.jsx)("tr",{children:(0,a.jsx)("td",{colSpan:"7",className:"p-8 text-center text-text-muted",children:"No request details found"})}):e.map((e,t)=>(0,a.jsxs)("tr",{className:"border-b border-black/5 dark:border-white/5 last:border-b-0 hover:bg-black/[0.02] dark:hover:bg-white/[0.02] transition-colors",children:[(0,a.jsx)("td",{className:"p-4 text-sm text-text-main",children:new Date(e.timestamp).toLocaleString()}),(0,a.jsx)("td",{className:"p-4 text-sm text-text-main font-mono",children:e.model}),(0,a.jsx)("td",{className:"p-4 text-sm text-text-main",children:(0,a.jsx)("span",{className:"font-medium",children:f(e.provider,k)})}),(0,a.jsx)("td",{className:"p-4 text-sm text-text-main text-right font-mono",children:e.tokens?.prompt_tokens?.toLocaleString()||0}),(0,a.jsx)("td",{className:"p-4 text-sm text-text-main text-right font-mono",children:e.tokens?.completion_tokens?.toLocaleString()||0}),(0,a.jsx)("td",{className:"p-4 text-sm text-text-muted",children:(0,a.jsxs)("div",{className:"flex flex-col gap-0.5",children:[(0,a.jsxs)("div",{children:["TTFT: ",(0,a.jsxs)("span",{className:"font-mono",children:[e.latency?.ttft||0,"ms"]})]}),(0,a.jsxs)("div",{children:["Total: ",(0,a.jsxs)("span",{className:"font-mono",children:[e.latency?.total||0,"ms"]})]})]})}),(0,a.jsx)("td",{className:"p-4 text-center",children:(0,a.jsx)(d.default,{variant:"outline",size:"sm",onClick:()=>{p(e),g(!0)},children:"Detail"})})]},`${e.id}-${t}`))})]})}),!l&&e.length>0&&(0,a.jsx)("div",{className:"border-t border-black/5 dark:border-white/5",children:(0,a.jsx)(x,{currentPage:s.page,pageSize:s.pageSize,totalItems:s.totalItems,onPageChange:e=>{n(t=>({...t,page:e}))},onPageSizeChange:e=>{n(t=>({...t,pageSize:e,page:1}))}})})]}),(0,a.jsx)(c,{isOpen:j,onClose:()=>g(!1),title:"Request Details",width:"lg",children:h&&(0,a.jsxs)("div",{className:"space-y-6",children:[(0,a.jsxs)("div",{className:"grid grid-cols-2 gap-4 text-sm",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("span",{className:"text-text-muted",children:"ID:"})," ",(0,a.jsx)("span",{className:"text-text-main font-mono",children:h.id})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("span",{className:"text-text-muted",children:"Timestamp:"})," ",(0,a.jsx)("span",{className:"text-text-main",children:new Date(h.timestamp).toLocaleString()})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("span",{className:"text-text-muted",children:"Provider:"})," ",(0,a.jsx)("span",{className:"text-text-main font-medium",children:f(h.provider,k)})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("span",{className:"text-text-muted",children:"Model:"})," ",(0,a.jsx)("span",{className:"text-text-main font-mono",children:h.model})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("span",{className:"text-text-muted",children:"Status:"})," ",(0,a.jsx)("span",{className:(0,o.cn)("font-medium","success"===h.status?"text-green-600":"text-red-600"),children:h.status})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("span",{className:"text-text-muted",children:"Latency:"})," ",(0,a.jsxs)("span",{className:"text-text-main font-mono",children:["TTFT ",h.latency?.ttft||0,"ms / Total ",h.latency?.total||0,"ms"]})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("span",{className:"text-text-muted",children:"Input Tokens:"})," ",(0,a.jsx)("span",{className:"text-text-main font-mono",children:h.tokens?.prompt_tokens?.toLocaleString()||0})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("span",{className:"text-text-muted",children:"Output Tokens:"})," ",(0,a.jsx)("span",{className:"text-text-main font-mono",children:h.tokens?.completion_tokens?.toLocaleString()||0})]})]}),(0,a.jsxs)("div",{className:"space-y-4",children:[(0,a.jsx)(b,{title:"1. Client Request (Input)",defaultOpen:!0,icon:"input",children:(0,a.jsx)("pre",{className:"bg-black/5 dark:bg-white/5 p-4 rounded-lg overflow-auto max-h-[300px] text-xs font-mono text-text-main border border-black/5 dark:border-white/5",children:JSON.stringify(h.request,null,2)})}),h.providerRequest&&(0,a.jsx)(b,{title:"2. Provider Request (Translated)",icon:"translate",children:(0,a.jsx)("pre",{className:"bg-black/5 dark:bg-white/5 p-4 rounded-lg overflow-auto max-h-[300px] text-xs font-mono text-text-main border border-black/5 dark:border-white/5",children:JSON.stringify(h.providerRequest,null,2)})}),h.providerResponse&&(0,a.jsx)(b,{title:"3. Provider Response (Raw)",icon:"data_object",children:(0,a.jsx)("pre",{className:"bg-black/5 dark:bg-white/5 p-4 rounded-lg overflow-auto max-h-[300px] text-xs font-mono text-text-main border border-black/5 dark:border-white/5",children:"object"==typeof h.providerResponse?JSON.stringify(h.providerResponse,null,2):h.providerResponse})}),(0,a.jsxs)(b,{title:"4. Client Response (Final)",defaultOpen:!0,icon:"output",children:[h.response?.thinking&&(0,a.jsxs)("div",{className:"mb-4",children:[(0,a.jsxs)("h4",{className:"font-semibold text-text-main mb-2 flex items-center gap-2 text-xs uppercase tracking-wide opacity-70",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[16px]",children:"psychology"}),"Thinking Process"]}),(0,a.jsx)("pre",{className:"bg-amber-50 dark:bg-amber-950/30 p-4 rounded-lg overflow-auto max-h-[200px] text-xs font-mono text-amber-900 dark:text-amber-100 border border-amber-200 dark:border-amber-800",children:h.response.thinking})]}),(0,a.jsx)("h4",{className:"font-semibold text-text-main mb-2 text-xs uppercase tracking-wide opacity-70",children:"Content"}),(0,a.jsx)("pre",{className:"bg-black/5 dark:bg-white/5 p-4 rounded-lg overflow-auto max-h-[300px] text-xs font-mono text-text-main border border-black/5 dark:border-white/5",children:h.response?.content||"[No content]"})]})]})]})})]})}function g(){return(0,a.jsx)(r.Suspense,{fallback:(0,a.jsx)(l.Qv,{}),children:(0,a.jsx)(v,{})})}function v(){let e=(0,n.useSearchParams)(),t=(0,n.useRouter)(),[s,i]=(0,r.useState)(!1),d=e.get("tab"),o=d&&["overview","logs","details"].includes(d)?d:"overview";return(0,a.jsxs)("div",{className:"flex flex-col gap-6",children:[(0,a.jsx)(l.Iz,{options:[{value:"overview",label:"Overview"},{value:"details",label:"Details"}],value:o,onChange:s=>{if(s===o)return;i(!0);let a=new URLSearchParams(e);a.set("tab",s),t.push(`/dashboard/usage?${a.toString()}`,{scroll:!1}),setTimeout(()=>i(!1),300)}}),s?(0,a.jsx)(l.Qv,{}):(0,a.jsxs)(a.Fragment,{children:["overview"===o&&(0,a.jsx)(r.Suspense,{fallback:(0,a.jsx)(l.Qv,{}),children:(0,a.jsx)(l.jK,{})}),"logs"===o&&(0,a.jsx)(l.gM,{}),"details"===o&&(0,a.jsx)(j,{})]})]})}}},e=>{e.O(0,[7848,4335,2599,350,4156,2347,5158,7358],()=>e(e.s=33154)),_N_E=e.O()}]);
1
+ (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[2825],{33154:(e,t,s)=>{Promise.resolve().then(s.bind(s,83101))},83101:(e,t,s)=>{"use strict";s.r(t),s.d(t,{default:()=>g});var a=s(73365),r=s(1521),n=s(29717),l=s(74156),i=s(292),d=s(38230),o=s(87706);function c({isOpen:e,onClose:t,title:s,children:n,width:l="md",className:i}){let d={sm:"w-[400px]",md:"w-[500px]",lg:"w-[600px]",xl:"w-[800px]",full:"w-full"};return((0,r.useEffect)(()=>(e?document.body.style.overflow="hidden":document.body.style.overflow="",()=>{document.body.style.overflow=""}),[e]),(0,r.useEffect)(()=>{let s=s=>{"Escape"===s.key&&e&&t()};return document.addEventListener("keydown",s),()=>document.removeEventListener("keydown",s)},[e,t]),e)?(0,a.jsxs)("div",{className:"fixed inset-0 z-50",children:[(0,a.jsx)("div",{className:"absolute inset-0 bg-black/50 backdrop-blur-sm transition-opacity cursor-pointer",onClick:t,"aria-hidden":"true"}),(0,a.jsxs)("div",{className:(0,o.cn)("absolute right-0 top-0 h-full bg-surface shadow-2xl flex flex-col","animate-in slide-in-from-right duration-200","border-l border-black/10 dark:border-white/10",d[l]||d.md,i),children:[(0,a.jsxs)("div",{className:"flex items-center justify-between p-6 border-b border-black/5 dark:border-white/5 flex-shrink-0",children:[(0,a.jsx)("div",{className:"flex items-center gap-3",children:s&&(0,a.jsx)("h2",{className:"text-lg font-semibold text-text-main",children:s})}),(0,a.jsx)("button",{type:"button",onClick:t,className:"p-1.5 rounded-lg text-text-muted hover:bg-black/5 dark:hover:bg-white/5 transition-colors",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[20px]",children:"close"})})]}),(0,a.jsx)("div",{className:"flex-1 overflow-y-auto p-6",children:n})]})]}):null}function x({currentPage:e,pageSize:t,totalItems:s,onPageChange:r,onPageSizeChange:n,className:l}){let i=Math.ceil(s/t),c=s>0?(e-1)*t+1:0,m=Math.min(e*t,s),h=(()=>{let t=[],s=Math.max(1,e-2),a=Math.min(i,s+5-1);a-s+1<5&&(s=Math.max(1,a-5+1));for(let e=s;e<=a;e++)t.push(e);return t})();return(0,a.jsxs)("div",{className:(0,o.cn)("flex flex-col sm:flex-row items-center justify-between gap-4 py-4",l),children:[s>0&&(0,a.jsxs)("div",{className:"text-sm text-text-muted",children:["Showing ",(0,a.jsx)("span",{className:"font-medium text-text-main",children:c})," to"," ",(0,a.jsx)("span",{className:"font-medium text-text-main",children:m})," of"," ",(0,a.jsx)("span",{className:"font-medium text-text-main",children:s})," results"]}),(0,a.jsxs)("div",{className:"flex items-center gap-4",children:[n&&(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("span",{className:"text-sm text-text-muted",children:"Rows:"}),(0,a.jsx)("select",{value:t,onChange:e=>n(Number(e.target.value)),className:(0,o.cn)("h-9 rounded-lg border border-black/10 dark:border-white/10 bg-surface","text-sm text-text-main focus:outline-none focus:ring-2 focus:ring-primary/20","cursor-pointer"),children:[10,20,50].map(e=>(0,a.jsx)("option",{value:e,children:e},e))})]}),i>1&&(0,a.jsxs)("div",{className:"flex items-center gap-1",children:[(0,a.jsx)(d.default,{variant:"outline",size:"sm",onClick:()=>r(e-1),disabled:1===e,className:"w-9 px-0",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:"chevron_left"})}),h[0]>1&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(d.default,{variant:"ghost",size:"sm",onClick:()=>r(1),className:"w-9 px-0",children:"1"}),h[0]>2&&(0,a.jsx)("span",{className:"text-text-muted px-1",children:"..."})]}),h.map(t=>(0,a.jsx)(d.default,{variant:e===t?"primary":"ghost",size:"sm",onClick:()=>r(t),className:"w-9 px-0",children:t},t)),h[h.length-1]<i&&(0,a.jsxs)(a.Fragment,{children:[h[h.length-1]<i-1&&(0,a.jsx)("span",{className:"text-text-muted px-1",children:"..."}),(0,a.jsx)(d.default,{variant:"ghost",size:"sm",onClick:()=>r(i),className:"w-9 px-0",children:i})]}),(0,a.jsx)(d.default,{variant:"outline",size:"sm",onClick:()=>r(e+1),disabled:e===i,className:"w-9 px-0",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:"chevron_right"})})]})]})]})}var m=s(82495);let h=null,p=null;async function u(){if(h&&p)return{providerNameCache:h,providerNodesCache:p};let e=await fetch("/api/provider-nodes"),t=(await e.json()).nodes||[];for(let e of(p={},t))p[e.id]=e.name;return{providerNameCache:h={...m.Q2,...p},providerNodesCache:p}}function f(e,t){if(!e||!t)return e;let s=t[e];if("string"==typeof s)return s;if(s?.name)return s.name;let a=(0,m.zt)(e)||m.Q2[e];return a?.name||e}function b({title:e,children:t,defaultOpen:s=!1,icon:n=null}){let[l,i]=(0,r.useState)(s);return(0,a.jsxs)("div",{className:"border border-black/5 dark:border-white/5 rounded-lg overflow-hidden",children:[(0,a.jsxs)("button",{type:"button",onClick:()=>i(!l),className:"w-full flex items-center justify-between p-3 bg-black/[0.02] dark:bg-white/[0.02] hover:bg-black/[0.04] dark:hover:bg-white/[0.04] transition-colors",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[n&&(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px] text-text-muted",children:n}),(0,a.jsx)("span",{className:"font-semibold text-sm text-text-main",children:e})]}),(0,a.jsx)("span",{className:(0,o.cn)("material-symbols-outlined text-[20px] text-text-muted transition-transform duration-200",l?"rotate-90":""),children:"chevron_right"})]}),l&&(0,a.jsx)("div",{className:"p-4 border-t border-black/5 dark:border-white/5",children:t})]})}function j(){let[e,t]=(0,r.useState)([]),[s,n]=(0,r.useState)({page:1,pageSize:20,totalItems:0,totalPages:0}),[l,m]=(0,r.useState)(!1),[h,p]=(0,r.useState)(null),[j,g]=(0,r.useState)(!1),[v,N]=(0,r.useState)([]),[k,w]=(0,r.useState)(null),[y,S]=(0,r.useState)({provider:"",startDate:"",endDate:""}),C=(0,r.useCallback)(async()=>{try{let e=await fetch("/api/usage/providers"),t=await e.json();N(t.providers||[]);let s=await u();w(s.providerNameCache)}catch(e){console.error("Failed to fetch providers:",e)}},[]),D=(0,r.useCallback)(async()=>{m(!0);try{let e=new URLSearchParams({page:s.page.toString(),pageSize:s.pageSize.toString()});y.provider&&e.append("provider",y.provider),y.startDate&&e.append("startDate",y.startDate),y.endDate&&e.append("endDate",y.endDate);let a=await fetch(`/api/usage/request-details?${e}`),r=await a.json();t(r.details||[]),n(e=>({...e,...r.pagination}))}catch(e){console.error("Failed to fetch request details:",e)}finally{m(!1)}},[s.page,s.pageSize,y]);return(0,r.useEffect)(()=>{C()},[C]),(0,r.useEffect)(()=>{D()},[D]),(0,a.jsxs)("div",{className:"flex flex-col gap-6",children:[(0,a.jsx)(i.default,{padding:"md",children:(0,a.jsxs)("div",{className:"flex flex-wrap gap-4",children:[(0,a.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,a.jsx)("label",{htmlFor:"provider-filter",className:"text-sm font-medium text-text-main",children:"Provider"}),(0,a.jsxs)("select",{id:"provider-filter",value:y.provider,onChange:e=>S({...y,provider:e.target.value}),className:(0,o.cn)("h-9 px-3 rounded-lg border border-black/10 dark:border-white/10 bg-surface","text-sm text-text-main focus:outline-none focus:ring-2 focus:ring-primary/20","cursor-pointer min-w-[150px]"),children:[(0,a.jsx)("option",{value:"",children:"All Providers"}),v.map(e=>(0,a.jsx)("option",{value:e.id,children:e.name},e.id))]})]}),(0,a.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,a.jsx)("label",{htmlFor:"start-date-filter",className:"text-sm font-medium text-text-main",children:"Start Date"}),(0,a.jsx)("input",{id:"start-date-filter",type:"datetime-local",value:y.startDate,onChange:e=>S({...y,startDate:e.target.value}),className:(0,o.cn)("h-9 px-3 rounded-lg border border-black/10 dark:border-white/10 bg-surface","text-sm text-text-main focus:outline-none focus:ring-2 focus:ring-primary/20")})]}),(0,a.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,a.jsx)("label",{htmlFor:"end-date-filter",className:"text-sm font-medium text-text-main",children:"End Date"}),(0,a.jsx)("input",{id:"end-date-filter",type:"datetime-local",value:y.endDate,onChange:e=>S({...y,endDate:e.target.value}),className:(0,o.cn)("h-9 px-3 rounded-lg border border-black/10 dark:border-white/10 bg-surface","text-sm text-text-main focus:outline-none focus:ring-2 focus:ring-primary/20")})]}),(0,a.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,a.jsx)("span",{className:"text-sm font-medium text-text-main opacity-0","aria-hidden":"true",children:"Clear"}),(0,a.jsx)(d.default,{variant:"ghost",onClick:()=>{S({provider:"",startDate:"",endDate:""})},disabled:!y.provider&&!y.startDate&&!y.endDate,children:"Clear Filters"})]})]})}),(0,a.jsxs)(i.default,{padding:"none",children:[(0,a.jsx)("div",{className:"overflow-x-auto",children:(0,a.jsxs)("table",{className:"w-full",children:[(0,a.jsx)("thead",{children:(0,a.jsxs)("tr",{className:"border-b border-black/5 dark:border-white/5",children:[(0,a.jsx)("th",{className:"text-left p-4 text-sm font-semibold text-text-main",children:"Timestamp"}),(0,a.jsx)("th",{className:"text-left p-4 text-sm font-semibold text-text-main",children:"Model"}),(0,a.jsx)("th",{className:"text-left p-4 text-sm font-semibold text-text-main",children:"Provider"}),(0,a.jsx)("th",{className:"text-right p-4 text-sm font-semibold text-text-main",children:"Input Tokens"}),(0,a.jsx)("th",{className:"text-right p-4 text-sm font-semibold text-text-main",children:"Output Tokens"}),(0,a.jsx)("th",{className:"text-left p-4 text-sm font-semibold text-text-main",children:"Latency"}),(0,a.jsx)("th",{className:"text-center p-4 text-sm font-semibold text-text-main",children:"Action"})]})}),(0,a.jsx)("tbody",{children:l?(0,a.jsx)("tr",{children:(0,a.jsx)("td",{colSpan:"7",className:"p-8 text-center text-text-muted",children:(0,a.jsxs)("div",{className:"flex items-center justify-center gap-2",children:[(0,a.jsx)("span",{className:"material-symbols-outlined animate-spin text-[20px]",children:"progress_activity"}),"Loading..."]})})}):0===e.length?(0,a.jsx)("tr",{children:(0,a.jsx)("td",{colSpan:"7",className:"p-8 text-center text-text-muted",children:"No request details found"})}):e.map((e,t)=>(0,a.jsxs)("tr",{className:"border-b border-black/5 dark:border-white/5 last:border-b-0 hover:bg-black/[0.02] dark:hover:bg-white/[0.02] transition-colors",children:[(0,a.jsx)("td",{className:"p-4 text-sm text-text-main",children:new Date(e.timestamp).toLocaleString()}),(0,a.jsx)("td",{className:"p-4 text-sm text-text-main font-mono",children:e.model}),(0,a.jsx)("td",{className:"p-4 text-sm text-text-main",children:(0,a.jsx)("span",{className:"font-medium",children:f(e.provider,k)})}),(0,a.jsx)("td",{className:"p-4 text-sm text-text-main text-right font-mono",children:e.tokens?.prompt_tokens?.toLocaleString()||0}),(0,a.jsx)("td",{className:"p-4 text-sm text-text-main text-right font-mono",children:e.tokens?.completion_tokens?.toLocaleString()||0}),(0,a.jsx)("td",{className:"p-4 text-sm text-text-muted",children:(0,a.jsxs)("div",{className:"flex flex-col gap-0.5",children:[(0,a.jsxs)("div",{children:["TTFT: ",(0,a.jsxs)("span",{className:"font-mono",children:[e.latency?.ttft||0,"ms"]})]}),(0,a.jsxs)("div",{children:["Total: ",(0,a.jsxs)("span",{className:"font-mono",children:[e.latency?.total||0,"ms"]})]})]})}),(0,a.jsx)("td",{className:"p-4 text-center",children:(0,a.jsx)(d.default,{variant:"outline",size:"sm",onClick:()=>{p(e),g(!0)},children:"Detail"})})]},`${e.id}-${t}`))})]})}),!l&&e.length>0&&(0,a.jsx)("div",{className:"border-t border-black/5 dark:border-white/5",children:(0,a.jsx)(x,{currentPage:s.page,pageSize:s.pageSize,totalItems:s.totalItems,onPageChange:e=>{n(t=>({...t,page:e}))},onPageSizeChange:e=>{n(t=>({...t,pageSize:e,page:1}))}})})]}),(0,a.jsx)(c,{isOpen:j,onClose:()=>g(!1),title:"Request Details",width:"lg",children:h&&(0,a.jsxs)("div",{className:"space-y-6",children:[(0,a.jsxs)("div",{className:"grid grid-cols-2 gap-4 text-sm",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("span",{className:"text-text-muted",children:"ID:"})," ",(0,a.jsx)("span",{className:"text-text-main font-mono",children:h.id})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("span",{className:"text-text-muted",children:"Timestamp:"})," ",(0,a.jsx)("span",{className:"text-text-main",children:new Date(h.timestamp).toLocaleString()})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("span",{className:"text-text-muted",children:"Provider:"})," ",(0,a.jsx)("span",{className:"text-text-main font-medium",children:f(h.provider,k)})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("span",{className:"text-text-muted",children:"Model:"})," ",(0,a.jsx)("span",{className:"text-text-main font-mono",children:h.model})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("span",{className:"text-text-muted",children:"Status:"})," ",(0,a.jsx)("span",{className:(0,o.cn)("font-medium","success"===h.status?"text-green-600":"text-red-600"),children:h.status})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("span",{className:"text-text-muted",children:"Latency:"})," ",(0,a.jsxs)("span",{className:"text-text-main font-mono",children:["TTFT ",h.latency?.ttft||0,"ms / Total ",h.latency?.total||0,"ms"]})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("span",{className:"text-text-muted",children:"Input Tokens:"})," ",(0,a.jsx)("span",{className:"text-text-main font-mono",children:h.tokens?.prompt_tokens?.toLocaleString()||0})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("span",{className:"text-text-muted",children:"Output Tokens:"})," ",(0,a.jsx)("span",{className:"text-text-main font-mono",children:h.tokens?.completion_tokens?.toLocaleString()||0})]})]}),(0,a.jsxs)("div",{className:"space-y-4",children:[(0,a.jsx)(b,{title:"1. Client Request (Input)",defaultOpen:!0,icon:"input",children:(0,a.jsx)("pre",{className:"bg-black/5 dark:bg-white/5 p-4 rounded-lg overflow-auto max-h-[300px] text-xs font-mono text-text-main border border-black/5 dark:border-white/5",children:JSON.stringify(h.request,null,2)})}),h.providerRequest&&(0,a.jsx)(b,{title:"2. Provider Request (Translated)",icon:"translate",children:(0,a.jsx)("pre",{className:"bg-black/5 dark:bg-white/5 p-4 rounded-lg overflow-auto max-h-[300px] text-xs font-mono text-text-main border border-black/5 dark:border-white/5",children:JSON.stringify(h.providerRequest,null,2)})}),h.providerResponse&&(0,a.jsx)(b,{title:"3. Provider Response (Raw)",icon:"data_object",children:(0,a.jsx)("pre",{className:"bg-black/5 dark:bg-white/5 p-4 rounded-lg overflow-auto max-h-[300px] text-xs font-mono text-text-main border border-black/5 dark:border-white/5",children:"object"==typeof h.providerResponse?JSON.stringify(h.providerResponse,null,2):h.providerResponse})}),(0,a.jsxs)(b,{title:"4. Client Response (Final)",defaultOpen:!0,icon:"output",children:[h.response?.thinking&&(0,a.jsxs)("div",{className:"mb-4",children:[(0,a.jsxs)("h4",{className:"font-semibold text-text-main mb-2 flex items-center gap-2 text-xs uppercase tracking-wide opacity-70",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[16px]",children:"psychology"}),"Thinking Process"]}),(0,a.jsx)("pre",{className:"bg-amber-50 dark:bg-amber-950/30 p-4 rounded-lg overflow-auto max-h-[200px] text-xs font-mono text-amber-900 dark:text-amber-100 border border-amber-200 dark:border-amber-800",children:h.response.thinking})]}),(0,a.jsx)("h4",{className:"font-semibold text-text-main mb-2 text-xs uppercase tracking-wide opacity-70",children:"Content"}),(0,a.jsx)("pre",{className:"bg-black/5 dark:bg-white/5 p-4 rounded-lg overflow-auto max-h-[300px] text-xs font-mono text-text-main border border-black/5 dark:border-white/5",children:h.response?.content||"[No content]"})]})]})]})})]})}function g(){return(0,a.jsx)(r.Suspense,{fallback:(0,a.jsx)(l.Qv,{}),children:(0,a.jsx)(v,{})})}function v(){let e=(0,n.useSearchParams)(),t=(0,n.useRouter)(),[s,i]=(0,r.useState)(!1),d=e.get("tab"),o=d&&["overview","logs","details"].includes(d)?d:"overview";return(0,a.jsxs)("div",{className:"flex flex-col gap-6",children:[(0,a.jsx)(l.Iz,{options:[{value:"overview",label:"Overview"},{value:"details",label:"Details"}],value:o,onChange:s=>{if(s===o)return;i(!0);let a=new URLSearchParams(e);a.set("tab",s),t.push(`/dashboard/usage?${a.toString()}`,{scroll:!1}),setTimeout(()=>i(!1),300)}}),s?(0,a.jsx)(l.Qv,{}):(0,a.jsxs)(a.Fragment,{children:["overview"===o&&(0,a.jsx)(r.Suspense,{fallback:(0,a.jsx)(l.Qv,{}),children:(0,a.jsx)(l.jK,{})}),"logs"===o&&(0,a.jsx)(l.gM,{}),"details"===o&&(0,a.jsx)(j,{})]})]})}}},e=>{e.O(0,[7848,4335,2599,505,4156,2347,5158,7358],()=>e(e.s=33154)),_N_E=e.O()}]);
@@ -0,0 +1 @@
1
+ (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[9305],{20647:(e,s,n)=>{Promise.resolve().then(n.bind(n,82455)),Promise.resolve().then(n.bind(n,35045)),Promise.resolve().then(n.bind(n,38230)),Promise.resolve().then(n.bind(n,292)),Promise.resolve().then(n.bind(n,70391)),Promise.resolve().then(n.bind(n,90163)),Promise.resolve().then(n.bind(n,70789)),Promise.resolve().then(n.bind(n,50136)),Promise.resolve().then(n.bind(n,51123)),Promise.resolve().then(n.bind(n,68600)),Promise.resolve().then(n.bind(n,53038)),Promise.resolve().then(n.bind(n,63380)),Promise.resolve().then(n.bind(n,73531)),Promise.resolve().then(n.bind(n,51454)),Promise.resolve().then(n.bind(n,12003)),Promise.resolve().then(n.bind(n,54546)),Promise.resolve().then(n.bind(n,13048)),Promise.resolve().then(n.bind(n,91494)),Promise.resolve().then(n.bind(n,5671)),Promise.resolve().then(n.bind(n,66911)),Promise.resolve().then(n.bind(n,24372)),Promise.resolve().then(n.bind(n,53524)),Promise.resolve().then(n.bind(n,27249)),Promise.resolve().then(n.bind(n,3242)),Promise.resolve().then(n.bind(n,32135)),Promise.resolve().then(n.bind(n,1755)),Promise.resolve().then(n.bind(n,37066)),Promise.resolve().then(n.bind(n,56550)),Promise.resolve().then(n.bind(n,98814)),Promise.resolve().then(n.bind(n,84675)),Promise.resolve().then(n.bind(n,14406)),Promise.resolve().then(n.bind(n,13333)),Promise.resolve().then(n.bind(n,3412))}},e=>{e.O(0,[7848,4335,2599,505,4156,2347,5158,7358],()=>e(e.s=20647)),_N_E=e.O()}]);
@@ -0,0 +1 @@
1
+ (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[7852],{29717:(e,s,t)=>{"use strict";var a=t(21505);t.o(a,"notFound")&&t.d(s,{notFound:function(){return a.notFound}}),t.o(a,"useParams")&&t.d(s,{useParams:function(){return a.useParams}}),t.o(a,"usePathname")&&t.d(s,{usePathname:function(){return a.usePathname}}),t.o(a,"useRouter")&&t.d(s,{useRouter:function(){return a.useRouter}}),t.o(a,"useSearchParams")&&t.d(s,{useSearchParams:function(){return a.useSearchParams}})},30948:(e,s,t)=>{"use strict";t.r(s),t.d(s,{default:()=>i});var a=t(73365),r=t(1521),l=t(29717);function n(){let e=(0,l.useSearchParams)(),[s,t]=(0,r.useState)("processing");return(0,r.useEffect)(()=>{let s=e.get("code"),a=e.get("state"),r=e.get("error"),l={code:s,state:a,error:r,errorDescription:e.get("error_description"),fullUrl:window.location.href};if(window.location.origin,window.opener)try{window.opener.postMessage({type:"oauth_callback",data:l},"*")}catch(e){console.log("postMessage failed:",e)}try{let e=new BroadcastChannel("oauth_callback");e.postMessage(l),e.close()}catch(e){console.log("BroadcastChannel failed:",e)}try{localStorage.setItem("oauth_callback",JSON.stringify({...l,timestamp:Date.now()}))}catch(e){console.log("localStorage failed:",e)}s||r?(t("success"),setTimeout(()=>{window.close(),setTimeout(()=>t("done"),500)},1500)):setTimeout(()=>t("manual"),0)},[e]),(0,a.jsx)("div",{className:"min-h-screen flex items-center justify-center bg-bg",children:(0,a.jsxs)("div",{className:"text-center p-8 max-w-md",children:["processing"===s&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("div",{className:"size-16 mx-auto mb-4 rounded-full bg-primary/10 flex items-center justify-center",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-3xl text-primary animate-spin",children:"progress_activity"})}),(0,a.jsx)("h1",{className:"text-xl font-semibold mb-2",children:"Processing..."}),(0,a.jsx)("p",{className:"text-text-muted",children:"Please wait while we complete the authorization."})]}),("success"===s||"done"===s)&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("div",{className:"size-16 mx-auto mb-4 rounded-full bg-green-100 dark:bg-green-900/30 flex items-center justify-center",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-3xl text-green-600",children:"check_circle"})}),(0,a.jsx)("h1",{className:"text-xl font-semibold mb-2",children:"Authorization Successful!"}),(0,a.jsx)("p",{className:"text-text-muted",children:"success"===s?"This window will close automatically...":"You can close this tab now."})]}),"manual"===s&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("div",{className:"size-16 mx-auto mb-4 rounded-full bg-yellow-100 dark:bg-yellow-900/30 flex items-center justify-center",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-3xl text-yellow-600",children:"info"})}),(0,a.jsx)("h1",{className:"text-xl font-semibold mb-2",children:"Copy This URL"}),(0,a.jsx)("p",{className:"text-text-muted mb-4",children:"Please copy the URL from the address bar and paste it in the application."}),(0,a.jsx)("div",{className:"bg-surface border border-border rounded-lg p-3 text-left",children:(0,a.jsx)("code",{className:"text-xs break-all",children:window.location.href})})]})]})})}function i(){return(0,a.jsx)(r.Suspense,{fallback:(0,a.jsx)("div",{className:"min-h-screen flex items-center justify-center bg-bg",children:(0,a.jsxs)("div",{className:"text-center p-8",children:[(0,a.jsx)("div",{className:"size-16 mx-auto mb-4 rounded-full bg-primary/10 flex items-center justify-center",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-3xl text-primary animate-spin",children:"progress_activity"})}),(0,a.jsx)("p",{className:"text-text-muted",children:"Loading..."})]})}),children:(0,a.jsx)(n,{})})}},99617:(e,s,t)=>{Promise.resolve().then(t.bind(t,30948))}},e=>{e.O(0,[2347,5158,7358],()=>e(e.s=99617)),_N_E=e.O()}]);
@@ -0,0 +1 @@
1
+ (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[7370],{292:(e,t,s)=>{"use strict";s.d(t,{default:()=>i});var r=s(73365),a=s(87706);function i({children:e,title:t,subtitle:s,icon:n,action:l,padding:c="md",hover:d=!1,className:o,...x}){return(0,r.jsxs)("div",{className:(0,a.cn)("bg-surface","border border-black/5 dark:border-white/5","rounded-lg shadow-sm",d&&"hover:shadow-md hover:border-primary/30 transition-all cursor-pointer",{none:"",xs:"p-3",sm:"p-4",md:"p-6",lg:"p-8"}[c],o),...x,children:[(t||l)&&(0,r.jsxs)("div",{className:"flex items-center justify-between mb-4",children:[(0,r.jsxs)("div",{className:"flex items-center gap-3",children:[n&&(0,r.jsx)("div",{className:"p-2 rounded-lg bg-bg text-text-muted",children:(0,r.jsx)("span",{className:"material-symbols-outlined text-[20px]",children:n})}),(0,r.jsxs)("div",{children:[t&&(0,r.jsx)("h3",{className:"text-text-main font-semibold",children:t}),s&&(0,r.jsx)("p",{className:"text-sm text-text-muted",children:s})]})]}),l]}),e]})}i.Section=function({children:e,className:t,...s}){return(0,r.jsx)("div",{className:(0,a.cn)("p-4 rounded-lg","bg-black/[0.02] dark:bg-white/[0.02]","border border-black/5 dark:border-white/5",t),...s,children:e})},i.Row=function({children:e,className:t,...s}){return(0,r.jsx)("div",{className:(0,a.cn)("p-3 -mx-3 px-3 transition-colors","border-b border-black/5 dark:border-white/5 last:border-b-0","hover:bg-black/[0.02] dark:hover:bg-white/[0.02]",t),...s,children:e})},i.ListItem=function({children:e,actions:t,className:s,...i}){return(0,r.jsxs)("div",{className:(0,a.cn)("group flex items-center justify-between p-3 -mx-3 px-3","border-b border-black/[0.03] dark:border-white/[0.03] last:border-b-0","hover:bg-black/[0.02] dark:hover:bg-white/[0.02]","transition-colors",s),...i,children:[(0,r.jsx)("div",{className:"flex-1 min-w-0",children:e}),t&&(0,r.jsx)("div",{className:"flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity",children:t})]})}},10075:(e,t,s)=>{Promise.resolve().then(s.bind(s,32530))},29717:(e,t,s)=>{"use strict";var r=s(21505);s.o(r,"notFound")&&s.d(t,{notFound:function(){return r.notFound}}),s.o(r,"useParams")&&s.d(t,{useParams:function(){return r.useParams}}),s.o(r,"usePathname")&&s.d(t,{usePathname:function(){return r.usePathname}}),s.o(r,"useRouter")&&s.d(t,{useRouter:function(){return r.useRouter}}),s.o(r,"useSearchParams")&&s.d(t,{useSearchParams:function(){return r.useSearchParams}})},32530:(e,t,s)=>{"use strict";s.r(t),s.d(t,{default:()=>d});var r=s(73365),a=s(1521),i=s(29717),n=s(292);let l={gh:{"gpt-5.3-codex":{input:1.75,output:14,cached:.175,reasoning:14,cache_creation:1.75}}};function c({isOpen:e,onClose:t,onSave:s}){let[i,n]=(0,a.useState)({}),[d,o]=(0,a.useState)(!0),[x,m]=(0,a.useState)(!1);(0,a.useEffect)(()=>{e&&h()},[e]);let h=async()=>{o(!0);try{let e=await fetch("/api/pricing");if(e.ok){let t=await e.json();n(t)}else n(l)}catch(e){console.error("Failed to load pricing:",e),n(l)}finally{o(!1)}},u=async()=>{m(!0);try{let e=await fetch("/api/pricing",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(i)});if(e.ok)s?.(),t();else{let t=await e.json();alert(`Failed to save pricing: ${t.error}`)}}catch(e){console.error("Failed to save pricing:",e),alert("Failed to save pricing")}finally{m(!1)}},p=async()=>{if(confirm("Reset all pricing to defaults? This cannot be undone."))try{(await fetch("/api/pricing",{method:"DELETE"})).ok&&n(l)}catch(e){console.error("Failed to reset pricing:",e),alert("Failed to reset pricing")}};if(!e)return null;let b=Object.keys(i).sort(),j=["input","output","cached","reasoning","cache_creation"];return(0,r.jsx)("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:(0,r.jsxs)("div",{className:"bg-bg-base border border-border rounded-lg shadow-xl max-w-6xl w-full max-h-[90vh] overflow-hidden flex flex-col",children:[(0,r.jsxs)("div",{className:"p-4 border-b border-border flex items-center justify-between",children:[(0,r.jsx)("h2",{className:"text-xl font-semibold",children:"Pricing Configuration"}),(0,r.jsx)("button",{onClick:t,className:"text-text-muted hover:text-text text-2xl leading-none",children:"\xd7"})]}),(0,r.jsx)("div",{className:"flex-1 overflow-auto p-4",children:d?(0,r.jsx)("div",{className:"text-center py-8 text-text-muted",children:"Loading pricing data..."}):(0,r.jsxs)("div",{className:"space-y-6",children:[(0,r.jsxs)("div",{className:"bg-bg-subtle border border-border rounded-lg p-3 text-sm",children:[(0,r.jsx)("p",{className:"font-medium mb-1",children:"Pricing Rates Format"}),(0,r.jsxs)("p",{className:"text-text-muted",children:["All rates are in ",(0,r.jsx)("strong",{children:"dollars per million tokens"})," ($/1M tokens). Example: Input rate of 2.50 means $2.50 per 1,000,000 input tokens."]})]}),b.map(e=>{let t=Object.keys(i[e]).sort();return(0,r.jsxs)("div",{className:"border border-border rounded-lg overflow-hidden",children:[(0,r.jsx)("div",{className:"bg-bg-subtle px-4 py-2 font-semibold text-sm",children:e.toUpperCase()}),(0,r.jsx)("div",{className:"overflow-x-auto",children:(0,r.jsxs)("table",{className:"w-full text-sm",children:[(0,r.jsx)("thead",{className:"bg-bg-hover text-text-muted uppercase text-xs",children:(0,r.jsxs)("tr",{children:[(0,r.jsx)("th",{className:"px-3 py-2 text-left",children:"Model"}),(0,r.jsx)("th",{className:"px-3 py-2 text-right",children:"Input"}),(0,r.jsx)("th",{className:"px-3 py-2 text-right",children:"Output"}),(0,r.jsx)("th",{className:"px-3 py-2 text-right",children:"Cached"}),(0,r.jsx)("th",{className:"px-3 py-2 text-right",children:"Reasoning"}),(0,r.jsx)("th",{className:"px-3 py-2 text-right",children:"Cache Creation"})]})}),(0,r.jsx)("tbody",{className:"divide-y divide-border",children:t.map(t=>(0,r.jsxs)("tr",{className:"hover:bg-bg-subtle/50",children:[(0,r.jsx)("td",{className:"px-3 py-2 font-medium",children:t}),j.map(s=>(0,r.jsx)("td",{className:"px-3 py-2",children:(0,r.jsx)("input",{type:"number",step:"0.01",min:"0",value:i[e][t][s]||0,onChange:r=>{let a;!isNaN(a=parseFloat(r.target.value))&&!(a<0)&&n(r=>{let i={...r};return i[e]||(i[e]={}),i[e][t]||(i[e][t]={}),i[e][t][s]=a,i})},className:"w-20 px-2 py-1 text-right bg-bg-base border border-border rounded focus:outline-none focus:border-primary"})},s))]},t))})]})})]},e)}),0===b.length&&(0,r.jsx)("div",{className:"text-center py-8 text-text-muted",children:"No pricing data available"})]})}),(0,r.jsxs)("div",{className:"p-4 border-t border-border flex items-center justify-between gap-2",children:[(0,r.jsx)("button",{onClick:p,className:"px-4 py-2 text-sm text-red-500 hover:bg-red-500/10 rounded border border-red-500/20 transition-colors",disabled:x,children:"Reset to Defaults"}),(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsx)("button",{onClick:t,className:"px-4 py-2 text-sm text-text-muted hover:text-text border border-border rounded transition-colors",disabled:x,children:"Cancel"}),(0,r.jsx)("button",{onClick:u,className:"px-4 py-2 text-sm bg-primary text-white rounded hover:bg-primary/90 transition-colors disabled:opacity-50",disabled:x,children:x?"Saving...":"Save Changes"})]})]})]})})}function d(){(0,i.useRouter)();let[e,t]=(0,a.useState)(!1),[s,l]=(0,a.useState)(null),[d,o]=(0,a.useState)(!0);(0,a.useEffect)(()=>{x()},[]);let x=async()=>{o(!0);try{let e=await fetch("/api/pricing");if(e.ok){let t=await e.json();l(t)}}catch(e){console.error("Failed to load pricing:",e)}finally{o(!1)}};return(0,r.jsxs)("div",{className:"max-w-6xl mx-auto p-6 space-y-6",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("h1",{className:"text-3xl font-bold",children:"Pricing Settings"}),(0,r.jsx)("p",{className:"text-text-muted mt-1",children:"Configure pricing rates for cost tracking and calculations"})]}),(0,r.jsx)("button",{onClick:()=>t(!0),className:"px-4 py-2 bg-primary text-white rounded hover:bg-primary/90 transition-colors",children:"Edit Pricing"})]}),(0,r.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[(0,r.jsxs)(n.default,{className:"p-4",children:[(0,r.jsx)("div",{className:"text-text-muted text-sm uppercase font-semibold",children:"Total Models"}),(0,r.jsx)("div",{className:"text-2xl font-bold mt-1",children:d?"...":(()=>{if(!s)return 0;let e=0;for(let t in s)e+=Object.keys(s[t]).length;return e})()})]}),(0,r.jsxs)(n.default,{className:"p-4",children:[(0,r.jsx)("div",{className:"text-text-muted text-sm uppercase font-semibold",children:"Providers"}),(0,r.jsx)("div",{className:"text-2xl font-bold mt-1",children:d?"...":(!s?[]:Object.keys(s).sort()).length})]}),(0,r.jsxs)(n.default,{className:"p-4",children:[(0,r.jsx)("div",{className:"text-text-muted text-sm uppercase font-semibold",children:"Status"}),(0,r.jsx)("div",{className:"text-2xl font-bold mt-1 text-success",children:d?"...":"Active"})]})]}),(0,r.jsxs)(n.default,{className:"p-6",children:[(0,r.jsx)("h2",{className:"text-xl font-semibold mb-4",children:"How Pricing Works"}),(0,r.jsxs)("div",{className:"space-y-3 text-sm text-text-muted",children:[(0,r.jsxs)("p",{children:[(0,r.jsx)("strong",{children:"Cost Calculation:"}),"Costs are calculated based on token usage and pricing rates. Each request's cost is determined by: (input_tokens \xd7 input_rate) + (output_tokens \xd7 output_rate) + (cached_tokens \xd7 cached_rate)"]}),(0,r.jsxs)("p",{children:[(0,r.jsx)("strong",{children:"Pricing Format:"})," All rates are in ",(0,r.jsx)("strong",{children:"dollars per million tokens"})," ($/1M tokens). Example: An input rate of 2.50 means $2.50 per 1,000,000 input tokens."]}),(0,r.jsx)("p",{children:(0,r.jsx)("strong",{children:"Token Types:"})}),(0,r.jsxs)("ul",{className:"list-disc list-inside ml-4 space-y-1",children:[(0,r.jsxs)("li",{children:[(0,r.jsx)("strong",{children:"Input:"})," Standard prompt tokens"]}),(0,r.jsxs)("li",{children:[(0,r.jsx)("strong",{children:"Output:"})," Completion/response tokens"]}),(0,r.jsxs)("li",{children:[(0,r.jsx)("strong",{children:"Cached:"})," Cached input tokens (typically 50% of input rate)"]}),(0,r.jsxs)("li",{children:[(0,r.jsx)("strong",{children:"Reasoning:"})," Special reasoning/thinking tokens (fallback to output rate)"]}),(0,r.jsxs)("li",{children:[(0,r.jsx)("strong",{children:"Cache Creation:"})," Tokens used to create cache entries (fallback to input rate)"]})]}),(0,r.jsxs)("p",{children:[(0,r.jsx)("strong",{children:"Custom Pricing:"})," You can override default pricing for specific models. Reset to defaults anytime to restore standard rates."]})]})]}),(0,r.jsxs)(n.default,{className:"p-6",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between mb-4",children:[(0,r.jsx)("h2",{className:"text-xl font-semibold",children:"Current Pricing Overview"}),(0,r.jsx)("button",{onClick:()=>t(!0),className:"text-primary hover:underline text-sm",children:"View Full Details"})]}),d?(0,r.jsx)("div",{className:"text-center py-4 text-text-muted",children:"Loading pricing data..."}):s?(0,r.jsxs)("div",{className:"space-y-3",children:[Object.keys(s).slice(0,5).map(e=>(0,r.jsxs)("div",{className:"text-sm",children:[(0,r.jsxs)("span",{className:"font-semibold",children:[e.toUpperCase(),":"]})," ",(0,r.jsxs)("span",{className:"text-text-muted",children:[Object.keys(s[e]).length," models"]})]},e)),Object.keys(s).length>5&&(0,r.jsxs)("div",{className:"text-sm text-text-muted",children:["+ ",Object.keys(s).length-5," more providers"]})]}):(0,r.jsx)("div",{className:"text-text-muted",children:"No pricing data available"})]}),e&&(0,r.jsx)(c,{isOpen:e,onClose:()=>t(!1),onSave:()=>{x()}})]})}},87706:(e,t,s)=>{"use strict";function r(...e){return e.filter(Boolean).join(" ").replace(/\s+/g," ").trim()}s.d(t,{cn:()=>r})}},e=>{e.O(0,[2347,5158,7358],()=>e(e.s=10075)),_N_E=e.O()}]);
@@ -0,0 +1 @@
1
+ (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[7177],{390:e=>{var t;"u">typeof __nccwpck_require__&&(__nccwpck_require__.ab="//"),(t={}).endianness=function(){return"LE"},t.hostname=function(){return"u">typeof location?location.hostname:""},t.loadavg=function(){return[]},t.uptime=function(){return 0},t.freemem=function(){return Number.MAX_VALUE},t.totalmem=function(){return Number.MAX_VALUE},t.cpus=function(){return[]},t.type=function(){return"Browser"},t.release=function(){return"u">typeof navigator?navigator.appVersion:""},t.networkInterfaces=t.getNetworkInterfaces=function(){return{}},t.arch=function(){return"javascript"},t.platform=function(){return"browser"},t.tmpdir=t.tmpDir=function(){return"/tmp"},t.EOL="\n",t.homedir=function(){return"/"},e.exports=t},2074:(e,t,r)=>{"use strict";r.d(t,{v:()=>u});var n=r(1521);let a=e=>{let t,r=new Set,n=(e,n)=>{let a="function"==typeof e?e(t):e;if(!Object.is(a,t)){let e=t;t=(null!=n?n:"object"!=typeof a||null===a)?a:Object.assign({},t,a),r.forEach(r=>r(t,e))}},a=()=>t,o={setState:n,getState:a,getInitialState:()=>u,subscribe:e=>(r.add(e),()=>r.delete(e))},u=t=e(n,a,o);return o},o=e=>{let t=e?a(e):a,r=e=>(function(e,t=e=>e){let r=n.useSyncExternalStore(e.subscribe,n.useCallback(()=>t(e.getState()),[e,t]),n.useCallback(()=>t(e.getInitialState()),[e,t]));return n.useDebugValue(r),r})(t,e);return Object.assign(r,t),r},u=e=>e?o(e):o},5074:(e,t,r)=>{Promise.resolve().then(r.t.bind(r,43333,23)),Promise.resolve().then(r.bind(r,70339)),Promise.resolve().then(r.bind(r,98814)),Promise.resolve().then(r.t.bind(r,88276,23))},11472:(e,t,r)=>{"use strict";r.d(t,{Zr:()=>a});let n=e=>t=>{try{let r=e(t);if(r instanceof Promise)return r;return{then:e=>n(e)(r),catch(e){return this}}}catch(e){return{then(e){return this},catch:t=>n(t)(e)}}},a=(e,t)=>(r,a,o)=>{let u,i={storage:function(e){let t;try{t=e()}catch(e){return}return{getItem:e=>{var r;let n=e=>null===e?null:JSON.parse(e,void 0),a=null!=(r=t.getItem(e))?r:null;return a instanceof Promise?a.then(n):n(a)},setItem:(e,r)=>t.setItem(e,JSON.stringify(r,void 0)),removeItem:e=>t.removeItem(e)}}(()=>window.localStorage),partialize:e=>e,version:0,merge:(e,t)=>({...t,...e}),...t},s=!1,l=0,c=new Set,m=new Set,f=i.storage;if(!f)return e((...e)=>{console.warn(`[zustand persist middleware] Unable to update item '${i.name}', the given storage is currently unavailable.`),r(...e)},a,o);let d=()=>{let e=i.partialize({...a()});return f.setItem(i.name,{state:e,version:i.version})},h=o.setState;o.setState=(e,t)=>(h(e,t),d());let v=e((...e)=>(r(...e),d()),a,o);o.getInitialState=()=>v;let g=()=>{var e,t;if(!f)return;let o=++l;s=!1,c.forEach(e=>{var t;return e(null!=(t=a())?t:v)});let h=(null==(t=i.onRehydrateStorage)?void 0:t.call(i,null!=(e=a())?e:v))||void 0;return n(f.getItem.bind(f))(i.name).then(e=>{if(e)if("number"!=typeof e.version||e.version===i.version)return[!1,e.state];else{if(i.migrate){let t=i.migrate(e.state,e.version);return t instanceof Promise?t.then(e=>[!0,e]):[!0,t]}console.error("State loaded from storage couldn't be migrated since no migrate function was provided")}return[!1,void 0]}).then(e=>{var t;if(o!==l)return;let[n,s]=e;if(r(u=i.merge(s,null!=(t=a())?t:v),!0),n)return d()}).then(()=>{o===l&&(null==h||h(a(),void 0),u=a(),s=!0,m.forEach(e=>e(u)))}).catch(e=>{o===l&&(null==h||h(void 0,e))})};return o.persist={setOptions:e=>{i={...i,...e},e.storage&&(f=e.storage)},clearStorage:()=>{null==f||f.removeItem(i.name)},getOptions:()=>i,rehydrate:()=>g(),hasHydrated:()=>s,onHydrate:e=>(c.add(e),()=>{c.delete(e)}),onFinishHydration:e=>(m.add(e),()=>{m.delete(e)})},i.skipHydration||g(),u||v}},29717:(e,t,r)=>{"use strict";var n=r(21505);r.o(n,"notFound")&&r.d(t,{notFound:function(){return n.notFound}}),r.o(n,"useParams")&&r.d(t,{useParams:function(){return n.useParams}}),r.o(n,"usePathname")&&r.d(t,{usePathname:function(){return n.usePathname}}),r.o(n,"useRouter")&&r.d(t,{useRouter:function(){return n.useRouter}}),r.o(n,"useSearchParams")&&r.d(t,{useSearchParams:function(){return n.useSearchParams}})},43333:()=>{},70339:(e,t,r)=>{"use strict";r.d(t,{RuntimeI18nProvider:()=>i});var n=r(73365),a=r(1521),o=r(29717),u=r(84502);function i({children:e}){let t=(0,o.usePathname)();return(0,a.useEffect)(()=>{(0,u.FE)()},[]),(0,a.useEffect)(()=>{t&&requestAnimationFrame(()=>{requestAnimationFrame(()=>{(0,u.wn)()})})},[t]),(0,n.jsx)(n.Fragment,{children:e})}},88276:e=>{e.exports={style:{fontFamily:"'Inter', 'Inter Fallback'",fontStyle:"normal"},className:"__className_f367f3",variable:"__variable_f367f3"}}},e=>{e.O(0,[8424,5261,505,2347,5158,7358],()=>e(e.s=5074)),_N_E=e.O()}]);
@@ -1 +1 @@
1
- (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[4520],{15872:(e,s,t)=>{"use strict";t.r(s),t.d(s,{default:()=>i});var a=t(73365),r=t(1521),l=t(74156),n=t(29717);function i(){let[e,s]=(0,r.useState)(""),[t,i]=(0,r.useState)(""),[c,d]=(0,r.useState)(!1),[o,u]=(0,r.useState)(null),m=(0,n.useRouter)();(0,r.useEffect)(()=>{!async function(){let e=new AbortController,s=setTimeout(()=>e.abort(),5e3),t=window.location.origin;try{let a=await fetch(`${t}/api/settings`,{signal:e.signal});if(clearTimeout(s),a.ok){let e=await a.json();if(!1===e.requireLogin){m.push("/dashboard"),m.refresh();return}u(!!e.hasPassword)}else u(!0)}catch(e){clearTimeout(s),u(!0)}}()},[m]);let x=async s=>{s.preventDefault(),d(!0),i("");try{let s=await fetch("/api/auth/login",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({password:e})});if(s.ok)m.push("/dashboard"),m.refresh();else{let e=await s.json();i(e.error||"Invalid password")}}catch(e){i("An error occurred. Please try again.")}finally{d(!1)}};return null===o?(0,a.jsx)("div",{className:"min-h-screen flex items-center justify-center bg-bg p-4",children:(0,a.jsxs)("div",{className:"text-center",children:[(0,a.jsx)("div",{className:"inline-block animate-spin rounded-full h-8 w-8 border-b-2 border-primary"}),(0,a.jsx)("p",{className:"text-text-muted mt-4",children:"Loading..."})]})}):(0,a.jsx)("div",{className:"min-h-screen flex items-center justify-center bg-bg p-4",children:(0,a.jsxs)("div",{className:"w-full max-w-md",children:[(0,a.jsxs)("div",{className:"text-center mb-8",children:[(0,a.jsx)("h1",{className:"text-3xl font-bold text-primary mb-2",children:"9Router"}),(0,a.jsx)("p",{className:"text-text-muted",children:"Enter your password to access the dashboard"})]}),(0,a.jsx)(l.Zp,{children:(0,a.jsxs)("form",{onSubmit:x,className:"flex flex-col gap-4",children:[(0,a.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,a.jsx)("label",{className:"text-sm font-medium",children:"Password"}),(0,a.jsx)(l.pd,{type:"password",placeholder:"Enter password",value:e,onChange:e=>s(e.target.value),required:!0,autoFocus:!0}),t&&(0,a.jsx)("p",{className:"text-xs text-red-500",children:t})]}),(0,a.jsx)(l.$n,{type:"submit",variant:"primary",className:"w-full",loading:c,children:"Login"}),(0,a.jsxs)("p",{className:"text-xs text-center text-text-muted mt-2",children:["Default password is ",(0,a.jsx)("code",{className:"bg-sidebar px-1 rounded",children:"123456"})]})]})})]})})}},92943:(e,s,t)=>{Promise.resolve().then(t.bind(t,15872))}},e=>{e.O(0,[7848,4335,2599,350,4156,2347,5158,7358],()=>e(e.s=92943)),_N_E=e.O()}]);
1
+ (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[4520],{15872:(e,s,t)=>{"use strict";t.r(s),t.d(s,{default:()=>i});var a=t(73365),r=t(1521),l=t(74156),n=t(29717);function i(){let[e,s]=(0,r.useState)(""),[t,i]=(0,r.useState)(""),[c,d]=(0,r.useState)(!1),[o,u]=(0,r.useState)(null),m=(0,n.useRouter)();(0,r.useEffect)(()=>{!async function(){let e=new AbortController,s=setTimeout(()=>e.abort(),5e3),t=window.location.origin;try{let a=await fetch(`${t}/api/settings`,{signal:e.signal});if(clearTimeout(s),a.ok){let e=await a.json();if(!1===e.requireLogin){m.push("/dashboard"),m.refresh();return}u(!!e.hasPassword)}else u(!0)}catch(e){clearTimeout(s),u(!0)}}()},[m]);let x=async s=>{s.preventDefault(),d(!0),i("");try{let s=await fetch("/api/auth/login",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({password:e})});if(s.ok)m.push("/dashboard"),m.refresh();else{let e=await s.json();i(e.error||"Invalid password")}}catch(e){i("An error occurred. Please try again.")}finally{d(!1)}};return null===o?(0,a.jsx)("div",{className:"min-h-screen flex items-center justify-center bg-bg p-4",children:(0,a.jsxs)("div",{className:"text-center",children:[(0,a.jsx)("div",{className:"inline-block animate-spin rounded-full h-8 w-8 border-b-2 border-primary"}),(0,a.jsx)("p",{className:"text-text-muted mt-4",children:"Loading..."})]})}):(0,a.jsx)("div",{className:"min-h-screen flex items-center justify-center bg-bg p-4",children:(0,a.jsxs)("div",{className:"w-full max-w-md",children:[(0,a.jsxs)("div",{className:"text-center mb-8",children:[(0,a.jsx)("h1",{className:"text-3xl font-bold text-primary mb-2",children:"9Router"}),(0,a.jsx)("p",{className:"text-text-muted",children:"Enter your password to access the dashboard"})]}),(0,a.jsx)(l.Zp,{children:(0,a.jsxs)("form",{onSubmit:x,className:"flex flex-col gap-4",children:[(0,a.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,a.jsx)("label",{className:"text-sm font-medium",children:"Password"}),(0,a.jsx)(l.pd,{type:"password",placeholder:"Enter password",value:e,onChange:e=>s(e.target.value),required:!0,autoFocus:!0}),t&&(0,a.jsx)("p",{className:"text-xs text-red-500",children:t})]}),(0,a.jsx)(l.$n,{type:"submit",variant:"primary",className:"w-full",loading:c,children:"Login"}),(0,a.jsxs)("p",{className:"text-xs text-center text-text-muted mt-2",children:["Default password is ",(0,a.jsx)("code",{className:"bg-sidebar px-1 rounded",children:"123456"})]})]})})]})})}},92943:(e,s,t)=>{Promise.resolve().then(t.bind(t,15872))}},e=>{e.O(0,[7848,4335,2599,505,4156,2347,5158,7358],()=>e(e.s=92943)),_N_E=e.O()}]);