@thangnm.nip/irouter 0.0.2 → 0.0.4

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 (669) hide show
  1. package/app/.next/BUILD_ID +1 -1
  2. package/app/.next/app-path-routes-manifest.json +10 -5
  3. package/app/.next/build-manifest.json +3 -3
  4. package/app/.next/prerender-manifest.json +24 -0
  5. package/app/.next/required-server-files.json +3 -3
  6. package/app/.next/routes-manifest.json +36 -0
  7. package/app/.next/server/app/(dashboard)/dashboard/cli-tools/page.js +2 -2
  8. package/app/.next/server/app/(dashboard)/dashboard/cli-tools/page.js.nft.json +1 -1
  9. package/app/.next/server/app/(dashboard)/dashboard/cli-tools/page_client-reference-manifest.js +1 -1
  10. package/app/.next/server/app/(dashboard)/dashboard/combos/page.js +2 -2
  11. package/app/.next/server/app/(dashboard)/dashboard/combos/page.js.nft.json +1 -1
  12. package/app/.next/server/app/(dashboard)/dashboard/combos/page_client-reference-manifest.js +1 -1
  13. package/app/.next/server/app/(dashboard)/dashboard/console-log/page.js +2 -2
  14. package/app/.next/server/app/(dashboard)/dashboard/console-log/page.js.nft.json +1 -1
  15. package/app/.next/server/app/(dashboard)/dashboard/console-log/page_client-reference-manifest.js +1 -1
  16. package/app/.next/server/app/(dashboard)/dashboard/employees/[keyId]/page.js +2 -0
  17. package/app/.next/server/app/(dashboard)/dashboard/employees/[keyId]/page.js.nft.json +1 -0
  18. package/app/.next/server/app/(dashboard)/dashboard/employees/[keyId]/page_client-reference-manifest.js +1 -0
  19. package/app/.next/server/app/(dashboard)/dashboard/employees/page.js +2 -0
  20. package/app/.next/server/app/(dashboard)/dashboard/employees/page.js.nft.json +1 -0
  21. package/app/.next/server/app/(dashboard)/dashboard/employees/page_client-reference-manifest.js +1 -0
  22. package/app/.next/server/app/(dashboard)/dashboard/endpoint/page.js +4 -2
  23. package/app/.next/server/app/(dashboard)/dashboard/endpoint/page.js.nft.json +1 -1
  24. package/app/.next/server/app/(dashboard)/dashboard/endpoint/page_client-reference-manifest.js +1 -1
  25. package/app/.next/server/app/(dashboard)/dashboard/mitm/page.js +2 -2
  26. package/app/.next/server/app/(dashboard)/dashboard/mitm/page.js.nft.json +1 -1
  27. package/app/.next/server/app/(dashboard)/dashboard/mitm/page_client-reference-manifest.js +1 -1
  28. package/app/.next/server/app/(dashboard)/dashboard/page.js +2 -2
  29. package/app/.next/server/app/(dashboard)/dashboard/page.js.nft.json +1 -1
  30. package/app/.next/server/app/(dashboard)/dashboard/page_client-reference-manifest.js +1 -1
  31. package/app/.next/server/app/(dashboard)/dashboard/profile/page.js +2 -2
  32. package/app/.next/server/app/(dashboard)/dashboard/profile/page.js.nft.json +1 -1
  33. package/app/.next/server/app/(dashboard)/dashboard/profile/page_client-reference-manifest.js +1 -1
  34. package/app/.next/server/app/(dashboard)/dashboard/providers/[id]/page.js +2 -2
  35. package/app/.next/server/app/(dashboard)/dashboard/providers/[id]/page.js.nft.json +1 -1
  36. package/app/.next/server/app/(dashboard)/dashboard/providers/[id]/page_client-reference-manifest.js +1 -1
  37. package/app/.next/server/app/(dashboard)/dashboard/providers/new/page.js +2 -2
  38. package/app/.next/server/app/(dashboard)/dashboard/providers/new/page.js.nft.json +1 -1
  39. package/app/.next/server/app/(dashboard)/dashboard/providers/new/page_client-reference-manifest.js +1 -1
  40. package/app/.next/server/app/(dashboard)/dashboard/providers/page.js +2 -2
  41. package/app/.next/server/app/(dashboard)/dashboard/providers/page.js.nft.json +1 -1
  42. package/app/.next/server/app/(dashboard)/dashboard/providers/page_client-reference-manifest.js +1 -1
  43. package/app/.next/server/app/(dashboard)/dashboard/proxy-pools/page.js +3 -3
  44. package/app/.next/server/app/(dashboard)/dashboard/proxy-pools/page.js.nft.json +1 -1
  45. package/app/.next/server/app/(dashboard)/dashboard/proxy-pools/page_client-reference-manifest.js +1 -1
  46. package/app/.next/server/app/(dashboard)/dashboard/quota/page.js +2 -2
  47. package/app/.next/server/app/(dashboard)/dashboard/quota/page.js.nft.json +1 -1
  48. package/app/.next/server/app/(dashboard)/dashboard/quota/page_client-reference-manifest.js +1 -1
  49. package/app/.next/server/app/(dashboard)/dashboard/translator/page.js +2 -2
  50. package/app/.next/server/app/(dashboard)/dashboard/translator/page.js.nft.json +1 -1
  51. package/app/.next/server/app/(dashboard)/dashboard/translator/page_client-reference-manifest.js +1 -1
  52. package/app/.next/server/app/(dashboard)/dashboard/usage/page.js +2 -2
  53. package/app/.next/server/app/(dashboard)/dashboard/usage/page.js.nft.json +1 -1
  54. package/app/.next/server/app/(dashboard)/dashboard/usage/page_client-reference-manifest.js +1 -1
  55. package/app/.next/server/app/_global-error/page.js +3 -3
  56. package/app/.next/server/app/_global-error/page_client-reference-manifest.js +1 -1
  57. package/app/.next/server/app/_global-error.html +1 -1
  58. package/app/.next/server/app/_global-error.rsc +1 -1
  59. package/app/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
  60. package/app/.next/server/app/_global-error.segments/_global-error/__PAGE__.segment.rsc +1 -1
  61. package/app/.next/server/app/_global-error.segments/_global-error.segment.rsc +1 -1
  62. package/app/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
  63. package/app/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
  64. package/app/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  65. package/app/.next/server/app/_not-found/page.js +2 -2
  66. package/app/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
  67. package/app/.next/server/app/_not-found.html +1 -1
  68. package/app/.next/server/app/_not-found.rsc +5 -5
  69. package/app/.next/server/app/_not-found.segments/_full.segment.rsc +5 -5
  70. package/app/.next/server/app/_not-found.segments/_head.segment.rsc +1 -1
  71. package/app/.next/server/app/_not-found.segments/_index.segment.rsc +4 -4
  72. package/app/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +1 -1
  73. package/app/.next/server/app/_not-found.segments/_not-found.segment.rsc +1 -1
  74. package/app/.next/server/app/_not-found.segments/_tree.segment.rsc +2 -2
  75. package/app/.next/server/app/api/auth/login/route.js +1 -1
  76. package/app/.next/server/app/api/auth/login/route.js.nft.json +1 -1
  77. package/app/.next/server/app/api/auth/logout/route.js +1 -1
  78. package/app/.next/server/app/api/auth/logout/route.js.nft.json +1 -1
  79. package/app/.next/server/app/api/cli-tools/antigravity-mitm/alias/route.js +1 -1
  80. package/app/.next/server/app/api/cli-tools/antigravity-mitm/alias/route.js.nft.json +1 -1
  81. package/app/.next/server/app/api/cli-tools/antigravity-mitm/route.js +2 -2
  82. package/app/.next/server/app/api/cli-tools/antigravity-mitm/route.js.nft.json +1 -1
  83. package/app/.next/server/app/api/cli-tools/claude-settings/route.js +1 -1
  84. package/app/.next/server/app/api/cli-tools/claude-settings/route.js.nft.json +1 -1
  85. package/app/.next/server/app/api/cli-tools/codex-settings/route.js +2 -2
  86. package/app/.next/server/app/api/cli-tools/codex-settings/route.js.nft.json +1 -1
  87. package/app/.next/server/app/api/cli-tools/copilot-settings/route.js +2 -2
  88. package/app/.next/server/app/api/cli-tools/copilot-settings/route.js.nft.json +1 -1
  89. package/app/.next/server/app/api/cli-tools/droid-settings/route.js +2 -2
  90. package/app/.next/server/app/api/cli-tools/droid-settings/route.js.nft.json +1 -1
  91. package/app/.next/server/app/api/cli-tools/openclaw-settings/route.js +1 -1
  92. package/app/.next/server/app/api/cli-tools/openclaw-settings/route.js.nft.json +1 -1
  93. package/app/.next/server/app/api/cli-tools/opencode-settings/route.js +2 -2
  94. package/app/.next/server/app/api/cli-tools/opencode-settings/route.js.nft.json +1 -1
  95. package/app/.next/server/app/api/cloud/auth/route.js +1 -1
  96. package/app/.next/server/app/api/cloud/auth/route.js.nft.json +1 -1
  97. package/app/.next/server/app/api/cloud/credentials/update/route.js +1 -1
  98. package/app/.next/server/app/api/cloud/credentials/update/route.js.nft.json +1 -1
  99. package/app/.next/server/app/api/cloud/model/resolve/route.js +1 -1
  100. package/app/.next/server/app/api/cloud/model/resolve/route.js.nft.json +1 -1
  101. package/app/.next/server/app/api/cloud/models/alias/route.js +1 -1
  102. package/app/.next/server/app/api/cloud/models/alias/route.js.nft.json +1 -1
  103. package/app/.next/server/app/api/combos/[id]/route.js +1 -1
  104. package/app/.next/server/app/api/combos/[id]/route.js.nft.json +1 -1
  105. package/app/.next/server/app/api/combos/route.js +1 -1
  106. package/app/.next/server/app/api/combos/route.js.nft.json +1 -1
  107. package/app/.next/server/app/api/employees/[keyId]/stats/route.js +1 -0
  108. package/app/.next/server/app/api/employees/[keyId]/stats/route.js.nft.json +1 -0
  109. package/app/.next/server/app/api/employees/[keyId]/stats/route_client-reference-manifest.js +1 -0
  110. package/app/.next/server/app/api/employees/stats/route.js +1 -0
  111. package/app/.next/server/app/api/employees/stats/route.js.nft.json +1 -0
  112. package/app/.next/server/app/api/employees/stats/route_client-reference-manifest.js +1 -0
  113. package/app/.next/server/app/api/init/route.js +1 -1
  114. package/app/.next/server/app/api/init/route.js.nft.json +1 -1
  115. package/app/.next/server/app/api/keys/[id]/route.js +1 -1
  116. package/app/.next/server/app/api/keys/[id]/route.js.nft.json +1 -1
  117. package/app/.next/server/app/api/keys/route.js +1 -1
  118. package/app/.next/server/app/api/keys/route.js.nft.json +1 -1
  119. package/app/.next/server/app/api/locale/route.js +1 -1
  120. package/app/.next/server/app/api/locale/route.js.nft.json +1 -1
  121. package/app/.next/server/app/api/models/alias/route.js +1 -1
  122. package/app/.next/server/app/api/models/alias/route.js.nft.json +1 -1
  123. package/app/.next/server/app/api/models/route.js +1 -1
  124. package/app/.next/server/app/api/models/route.js.nft.json +1 -1
  125. package/app/.next/server/app/api/models/test/route.js +1 -1
  126. package/app/.next/server/app/api/models/test/route.js.nft.json +1 -1
  127. package/app/.next/server/app/api/oauth/[provider]/[action]/route.js +1 -1
  128. package/app/.next/server/app/api/oauth/[provider]/[action]/route.js.nft.json +1 -1
  129. package/app/.next/server/app/api/oauth/cursor/auto-import/route.js +2 -2
  130. package/app/.next/server/app/api/oauth/cursor/auto-import/route.js.nft.json +1 -1
  131. package/app/.next/server/app/api/oauth/cursor/import/route.js +1 -1
  132. package/app/.next/server/app/api/oauth/cursor/import/route.js.nft.json +1 -1
  133. package/app/.next/server/app/api/oauth/iflow/cookie/route.js +1 -1
  134. package/app/.next/server/app/api/oauth/iflow/cookie/route.js.nft.json +1 -1
  135. package/app/.next/server/app/api/oauth/kiro/auto-import/route.js +1 -1
  136. package/app/.next/server/app/api/oauth/kiro/auto-import/route.js.nft.json +1 -1
  137. package/app/.next/server/app/api/oauth/kiro/import/route.js +1 -1
  138. package/app/.next/server/app/api/oauth/kiro/import/route.js.nft.json +1 -1
  139. package/app/.next/server/app/api/oauth/kiro/social-authorize/route.js +1 -1
  140. package/app/.next/server/app/api/oauth/kiro/social-authorize/route.js.nft.json +1 -1
  141. package/app/.next/server/app/api/oauth/kiro/social-exchange/route.js +1 -1
  142. package/app/.next/server/app/api/oauth/kiro/social-exchange/route.js.nft.json +1 -1
  143. package/app/.next/server/app/api/pricing/route.js +1 -1
  144. package/app/.next/server/app/api/pricing/route.js.nft.json +1 -1
  145. package/app/.next/server/app/api/provider-nodes/[id]/route.js +1 -1
  146. package/app/.next/server/app/api/provider-nodes/[id]/route.js.nft.json +1 -1
  147. package/app/.next/server/app/api/provider-nodes/route.js +1 -1
  148. package/app/.next/server/app/api/provider-nodes/route.js.nft.json +1 -1
  149. package/app/.next/server/app/api/provider-nodes/validate/route.js +1 -1
  150. package/app/.next/server/app/api/provider-nodes/validate/route.js.nft.json +1 -1
  151. package/app/.next/server/app/api/providers/[id]/models/route.js +1 -1
  152. package/app/.next/server/app/api/providers/[id]/models/route.js.nft.json +1 -1
  153. package/app/.next/server/app/api/providers/[id]/route.js +1 -1
  154. package/app/.next/server/app/api/providers/[id]/route.js.nft.json +1 -1
  155. package/app/.next/server/app/api/providers/[id]/test/route.js +1 -1
  156. package/app/.next/server/app/api/providers/[id]/test/route.js.nft.json +1 -1
  157. package/app/.next/server/app/api/providers/[id]/test-models/route.js +1 -1
  158. package/app/.next/server/app/api/providers/[id]/test-models/route.js.nft.json +1 -1
  159. package/app/.next/server/app/api/providers/client/route.js +1 -1
  160. package/app/.next/server/app/api/providers/client/route.js.nft.json +1 -1
  161. package/app/.next/server/app/api/providers/route.js +1 -1
  162. package/app/.next/server/app/api/providers/route.js.nft.json +1 -1
  163. package/app/.next/server/app/api/providers/test-batch/route.js +1 -1
  164. package/app/.next/server/app/api/providers/test-batch/route.js.nft.json +1 -1
  165. package/app/.next/server/app/api/providers/validate/route.js +1 -1
  166. package/app/.next/server/app/api/providers/validate/route.js.nft.json +1 -1
  167. package/app/.next/server/app/api/proxy-pools/[id]/route.js +1 -1
  168. package/app/.next/server/app/api/proxy-pools/[id]/route.js.nft.json +1 -1
  169. package/app/.next/server/app/api/proxy-pools/[id]/test/route.js +1 -1
  170. package/app/.next/server/app/api/proxy-pools/[id]/test/route.js.nft.json +1 -1
  171. package/app/.next/server/app/api/proxy-pools/route.js +1 -1
  172. package/app/.next/server/app/api/proxy-pools/route.js.nft.json +1 -1
  173. package/app/.next/server/app/api/settings/database/route.js +1 -1
  174. package/app/.next/server/app/api/settings/database/route.js.nft.json +1 -1
  175. package/app/.next/server/app/api/settings/proxy-test/route.js +1 -1
  176. package/app/.next/server/app/api/settings/proxy-test/route.js.nft.json +1 -1
  177. package/app/.next/server/app/api/settings/require-login/route.js +1 -1
  178. package/app/.next/server/app/api/settings/require-login/route.js.nft.json +1 -1
  179. package/app/.next/server/app/api/settings/route.js +1 -1
  180. package/app/.next/server/app/api/settings/route.js.nft.json +1 -1
  181. package/app/.next/server/app/api/shutdown/route.js +1 -1
  182. package/app/.next/server/app/api/shutdown/route.js.nft.json +1 -1
  183. package/app/.next/server/app/api/tags/route.js +1 -1
  184. package/app/.next/server/app/api/translator/console-logs/route.js +1 -1
  185. package/app/.next/server/app/api/translator/console-logs/route.js.nft.json +1 -1
  186. package/app/.next/server/app/api/translator/console-logs/stream/route.js +2 -2
  187. package/app/.next/server/app/api/translator/load/route.js +1 -1
  188. package/app/.next/server/app/api/translator/load/route.js.nft.json +1 -1
  189. package/app/.next/server/app/api/translator/save/route.js +1 -1
  190. package/app/.next/server/app/api/translator/save/route.js.nft.json +1 -1
  191. package/app/.next/server/app/api/translator/send/route.js +1 -1
  192. package/app/.next/server/app/api/translator/send/route.js.nft.json +1 -1
  193. package/app/.next/server/app/api/translator/translate/route.js +1 -1
  194. package/app/.next/server/app/api/translator/translate/route.js.nft.json +1 -1
  195. package/app/.next/server/app/api/tunnel/disable/route.js +1 -1
  196. package/app/.next/server/app/api/tunnel/disable/route.js.nft.json +1 -1
  197. package/app/.next/server/app/api/tunnel/enable/route.js +1 -1
  198. package/app/.next/server/app/api/tunnel/enable/route.js.nft.json +1 -1
  199. package/app/.next/server/app/api/tunnel/status/route.js +1 -1
  200. package/app/.next/server/app/api/tunnel/status/route.js.nft.json +1 -1
  201. package/app/.next/server/app/api/usage/[connectionId]/route.js +1 -1
  202. package/app/.next/server/app/api/usage/[connectionId]/route.js.nft.json +1 -1
  203. package/app/.next/server/app/api/usage/chart/route.js +1 -1
  204. package/app/.next/server/app/api/usage/chart/route.js.nft.json +1 -1
  205. package/app/.next/server/app/api/usage/history/route.js +1 -1
  206. package/app/.next/server/app/api/usage/history/route.js.nft.json +1 -1
  207. package/app/.next/server/app/api/usage/logs/route.js +1 -1
  208. package/app/.next/server/app/api/usage/logs/route.js.nft.json +1 -1
  209. package/app/.next/server/app/api/usage/providers/route.js +1 -1
  210. package/app/.next/server/app/api/usage/providers/route.js.nft.json +1 -1
  211. package/app/.next/server/app/api/usage/request-details/[id]/route.js +1 -0
  212. package/app/.next/server/app/api/usage/request-details/[id]/route.js.nft.json +1 -0
  213. package/app/.next/server/app/api/usage/request-details/[id]/route_client-reference-manifest.js +1 -0
  214. package/app/.next/server/app/api/usage/request-details/route.js +1 -1
  215. package/app/.next/server/app/api/usage/request-details/route.js.nft.json +1 -1
  216. package/app/.next/server/app/api/usage/request-logs/route.js +1 -1
  217. package/app/.next/server/app/api/usage/request-logs/route.js.nft.json +1 -1
  218. package/app/.next/server/app/api/usage/stats/route.js +1 -1
  219. package/app/.next/server/app/api/usage/stats/route.js.nft.json +1 -1
  220. package/app/.next/server/app/api/usage/stream/route.js +2 -2
  221. package/app/.next/server/app/api/usage/stream/route.js.nft.json +1 -1
  222. package/app/.next/server/app/api/v1/api/chat/route.js +1 -1
  223. package/app/.next/server/app/api/v1/api/chat/route.js.nft.json +1 -1
  224. package/app/.next/server/app/api/v1/chat/completions/route.js +1 -1
  225. package/app/.next/server/app/api/v1/chat/completions/route.js.nft.json +1 -1
  226. package/app/.next/server/app/api/v1/embeddings/route.js +1 -1
  227. package/app/.next/server/app/api/v1/embeddings/route.js.nft.json +1 -1
  228. package/app/.next/server/app/api/v1/messages/count_tokens/route.js +1 -1
  229. package/app/.next/server/app/api/v1/messages/route.js +1 -1
  230. package/app/.next/server/app/api/v1/messages/route.js.nft.json +1 -1
  231. package/app/.next/server/app/api/v1/models/route.js +1 -1
  232. package/app/.next/server/app/api/v1/models/route.js.nft.json +1 -1
  233. package/app/.next/server/app/api/v1/responses/route.js +1 -1
  234. package/app/.next/server/app/api/v1/responses/route.js.nft.json +1 -1
  235. package/app/.next/server/app/api/v1/route.js +1 -1
  236. package/app/.next/server/app/api/v1beta/models/[...path]/route.js +1 -1
  237. package/app/.next/server/app/api/v1beta/models/[...path]/route.js.nft.json +1 -1
  238. package/app/.next/server/app/api/v1beta/models/route.js +1 -1
  239. package/app/.next/server/app/api/v1internal/route.js +1 -1
  240. package/app/.next/server/app/api/v1internal/route.js.nft.json +1 -1
  241. package/app/.next/server/app/api/version/route.js +1 -1
  242. package/app/.next/server/app/callback/page.js +2 -2
  243. package/app/.next/server/app/callback/page_client-reference-manifest.js +1 -1
  244. package/app/.next/server/app/callback.html +1 -1
  245. package/app/.next/server/app/callback.rsc +5 -5
  246. package/app/.next/server/app/callback.segments/_full.segment.rsc +5 -5
  247. package/app/.next/server/app/callback.segments/_head.segment.rsc +1 -1
  248. package/app/.next/server/app/callback.segments/_index.segment.rsc +4 -4
  249. package/app/.next/server/app/callback.segments/_tree.segment.rsc +2 -2
  250. package/app/.next/server/app/callback.segments/callback/__PAGE__.segment.rsc +1 -1
  251. package/app/.next/server/app/callback.segments/callback.segment.rsc +1 -1
  252. package/app/.next/server/app/dashboard/cli-tools.html +1 -1
  253. package/app/.next/server/app/dashboard/cli-tools.rsc +7 -7
  254. package/app/.next/server/app/dashboard/cli-tools.segments/!KGRhc2hib2FyZCk/dashboard/cli-tools/__PAGE__.segment.rsc +2 -2
  255. package/app/.next/server/app/dashboard/cli-tools.segments/!KGRhc2hib2FyZCk/dashboard/cli-tools.segment.rsc +1 -1
  256. package/app/.next/server/app/dashboard/cli-tools.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  257. package/app/.next/server/app/dashboard/cli-tools.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  258. package/app/.next/server/app/dashboard/cli-tools.segments/_full.segment.rsc +7 -7
  259. package/app/.next/server/app/dashboard/cli-tools.segments/_head.segment.rsc +1 -1
  260. package/app/.next/server/app/dashboard/cli-tools.segments/_index.segment.rsc +4 -4
  261. package/app/.next/server/app/dashboard/cli-tools.segments/_tree.segment.rsc +2 -2
  262. package/app/.next/server/app/dashboard/combos.html +1 -1
  263. package/app/.next/server/app/dashboard/combos.rsc +7 -7
  264. package/app/.next/server/app/dashboard/combos.segments/!KGRhc2hib2FyZCk/dashboard/combos/__PAGE__.segment.rsc +2 -2
  265. package/app/.next/server/app/dashboard/combos.segments/!KGRhc2hib2FyZCk/dashboard/combos.segment.rsc +1 -1
  266. package/app/.next/server/app/dashboard/combos.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  267. package/app/.next/server/app/dashboard/combos.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  268. package/app/.next/server/app/dashboard/combos.segments/_full.segment.rsc +7 -7
  269. package/app/.next/server/app/dashboard/combos.segments/_head.segment.rsc +1 -1
  270. package/app/.next/server/app/dashboard/combos.segments/_index.segment.rsc +4 -4
  271. package/app/.next/server/app/dashboard/combos.segments/_tree.segment.rsc +2 -2
  272. package/app/.next/server/app/dashboard/employees.html +1 -0
  273. package/app/.next/server/app/dashboard/employees.meta +17 -0
  274. package/app/.next/server/app/dashboard/employees.rsc +26 -0
  275. package/app/.next/server/app/dashboard/employees.segments/!KGRhc2hib2FyZCk/dashboard/employees/__PAGE__.segment.rsc +9 -0
  276. package/app/.next/server/app/dashboard/employees.segments/!KGRhc2hib2FyZCk/dashboard/employees.segment.rsc +5 -0
  277. package/app/.next/server/app/dashboard/employees.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +5 -0
  278. package/app/.next/server/app/dashboard/employees.segments/!KGRhc2hib2FyZCk.segment.rsc +6 -0
  279. package/app/.next/server/app/dashboard/employees.segments/_full.segment.rsc +26 -0
  280. package/app/.next/server/app/dashboard/employees.segments/_head.segment.rsc +6 -0
  281. package/app/.next/server/app/dashboard/employees.segments/_index.segment.rsc +8 -0
  282. package/app/.next/server/app/dashboard/employees.segments/_tree.segment.rsc +5 -0
  283. package/app/.next/server/app/dashboard/endpoint.html +1 -1
  284. package/app/.next/server/app/dashboard/endpoint.rsc +7 -7
  285. package/app/.next/server/app/dashboard/endpoint.segments/!KGRhc2hib2FyZCk/dashboard/endpoint/__PAGE__.segment.rsc +2 -2
  286. package/app/.next/server/app/dashboard/endpoint.segments/!KGRhc2hib2FyZCk/dashboard/endpoint.segment.rsc +1 -1
  287. package/app/.next/server/app/dashboard/endpoint.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  288. package/app/.next/server/app/dashboard/endpoint.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  289. package/app/.next/server/app/dashboard/endpoint.segments/_full.segment.rsc +7 -7
  290. package/app/.next/server/app/dashboard/endpoint.segments/_head.segment.rsc +1 -1
  291. package/app/.next/server/app/dashboard/endpoint.segments/_index.segment.rsc +4 -4
  292. package/app/.next/server/app/dashboard/endpoint.segments/_tree.segment.rsc +2 -2
  293. package/app/.next/server/app/dashboard/mitm.html +1 -1
  294. package/app/.next/server/app/dashboard/mitm.rsc +7 -7
  295. package/app/.next/server/app/dashboard/mitm.segments/!KGRhc2hib2FyZCk/dashboard/mitm/__PAGE__.segment.rsc +2 -2
  296. package/app/.next/server/app/dashboard/mitm.segments/!KGRhc2hib2FyZCk/dashboard/mitm.segment.rsc +1 -1
  297. package/app/.next/server/app/dashboard/mitm.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  298. package/app/.next/server/app/dashboard/mitm.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  299. package/app/.next/server/app/dashboard/mitm.segments/_full.segment.rsc +7 -7
  300. package/app/.next/server/app/dashboard/mitm.segments/_head.segment.rsc +1 -1
  301. package/app/.next/server/app/dashboard/mitm.segments/_index.segment.rsc +4 -4
  302. package/app/.next/server/app/dashboard/mitm.segments/_tree.segment.rsc +2 -2
  303. package/app/.next/server/app/dashboard/profile.html +1 -1
  304. package/app/.next/server/app/dashboard/profile.rsc +7 -7
  305. package/app/.next/server/app/dashboard/profile.segments/!KGRhc2hib2FyZCk/dashboard/profile/__PAGE__.segment.rsc +2 -2
  306. package/app/.next/server/app/dashboard/profile.segments/!KGRhc2hib2FyZCk/dashboard/profile.segment.rsc +1 -1
  307. package/app/.next/server/app/dashboard/profile.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  308. package/app/.next/server/app/dashboard/profile.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  309. package/app/.next/server/app/dashboard/profile.segments/_full.segment.rsc +7 -7
  310. package/app/.next/server/app/dashboard/profile.segments/_head.segment.rsc +1 -1
  311. package/app/.next/server/app/dashboard/profile.segments/_index.segment.rsc +4 -4
  312. package/app/.next/server/app/dashboard/profile.segments/_tree.segment.rsc +2 -2
  313. package/app/.next/server/app/dashboard/providers/new.html +1 -1
  314. package/app/.next/server/app/dashboard/providers/new.rsc +7 -7
  315. package/app/.next/server/app/dashboard/providers/new.segments/!KGRhc2hib2FyZCk/dashboard/providers/new/__PAGE__.segment.rsc +2 -2
  316. package/app/.next/server/app/dashboard/providers/new.segments/!KGRhc2hib2FyZCk/dashboard/providers/new.segment.rsc +1 -1
  317. package/app/.next/server/app/dashboard/providers/new.segments/!KGRhc2hib2FyZCk/dashboard/providers.segment.rsc +1 -1
  318. package/app/.next/server/app/dashboard/providers/new.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  319. package/app/.next/server/app/dashboard/providers/new.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  320. package/app/.next/server/app/dashboard/providers/new.segments/_full.segment.rsc +7 -7
  321. package/app/.next/server/app/dashboard/providers/new.segments/_head.segment.rsc +1 -1
  322. package/app/.next/server/app/dashboard/providers/new.segments/_index.segment.rsc +4 -4
  323. package/app/.next/server/app/dashboard/providers/new.segments/_tree.segment.rsc +2 -2
  324. package/app/.next/server/app/dashboard/providers.html +1 -1
  325. package/app/.next/server/app/dashboard/providers.rsc +7 -7
  326. package/app/.next/server/app/dashboard/providers.segments/!KGRhc2hib2FyZCk/dashboard/providers/__PAGE__.segment.rsc +2 -2
  327. package/app/.next/server/app/dashboard/providers.segments/!KGRhc2hib2FyZCk/dashboard/providers.segment.rsc +1 -1
  328. package/app/.next/server/app/dashboard/providers.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  329. package/app/.next/server/app/dashboard/providers.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  330. package/app/.next/server/app/dashboard/providers.segments/_full.segment.rsc +7 -7
  331. package/app/.next/server/app/dashboard/providers.segments/_head.segment.rsc +1 -1
  332. package/app/.next/server/app/dashboard/providers.segments/_index.segment.rsc +4 -4
  333. package/app/.next/server/app/dashboard/providers.segments/_tree.segment.rsc +2 -2
  334. package/app/.next/server/app/dashboard/proxy-pools.html +1 -1
  335. package/app/.next/server/app/dashboard/proxy-pools.rsc +7 -7
  336. package/app/.next/server/app/dashboard/proxy-pools.segments/!KGRhc2hib2FyZCk/dashboard/proxy-pools/__PAGE__.segment.rsc +2 -2
  337. package/app/.next/server/app/dashboard/proxy-pools.segments/!KGRhc2hib2FyZCk/dashboard/proxy-pools.segment.rsc +1 -1
  338. package/app/.next/server/app/dashboard/proxy-pools.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  339. package/app/.next/server/app/dashboard/proxy-pools.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  340. package/app/.next/server/app/dashboard/proxy-pools.segments/_full.segment.rsc +7 -7
  341. package/app/.next/server/app/dashboard/proxy-pools.segments/_head.segment.rsc +1 -1
  342. package/app/.next/server/app/dashboard/proxy-pools.segments/_index.segment.rsc +4 -4
  343. package/app/.next/server/app/dashboard/proxy-pools.segments/_tree.segment.rsc +2 -2
  344. package/app/.next/server/app/dashboard/quota.html +2 -2
  345. package/app/.next/server/app/dashboard/quota.rsc +6 -6
  346. package/app/.next/server/app/dashboard/quota.segments/!KGRhc2hib2FyZCk/dashboard/quota/__PAGE__.segment.rsc +1 -1
  347. package/app/.next/server/app/dashboard/quota.segments/!KGRhc2hib2FyZCk/dashboard/quota.segment.rsc +1 -1
  348. package/app/.next/server/app/dashboard/quota.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  349. package/app/.next/server/app/dashboard/quota.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  350. package/app/.next/server/app/dashboard/quota.segments/_full.segment.rsc +6 -6
  351. package/app/.next/server/app/dashboard/quota.segments/_head.segment.rsc +1 -1
  352. package/app/.next/server/app/dashboard/quota.segments/_index.segment.rsc +4 -4
  353. package/app/.next/server/app/dashboard/quota.segments/_tree.segment.rsc +2 -2
  354. package/app/.next/server/app/dashboard/settings/pricing/page.js +2 -2
  355. package/app/.next/server/app/dashboard/settings/pricing/page_client-reference-manifest.js +1 -1
  356. package/app/.next/server/app/dashboard/settings/pricing.html +1 -1
  357. package/app/.next/server/app/dashboard/settings/pricing.rsc +5 -5
  358. package/app/.next/server/app/dashboard/settings/pricing.segments/_full.segment.rsc +5 -5
  359. package/app/.next/server/app/dashboard/settings/pricing.segments/_head.segment.rsc +1 -1
  360. package/app/.next/server/app/dashboard/settings/pricing.segments/_index.segment.rsc +4 -4
  361. package/app/.next/server/app/dashboard/settings/pricing.segments/_tree.segment.rsc +2 -2
  362. package/app/.next/server/app/dashboard/settings/pricing.segments/dashboard/settings/pricing/__PAGE__.segment.rsc +1 -1
  363. package/app/.next/server/app/dashboard/settings/pricing.segments/dashboard/settings/pricing.segment.rsc +1 -1
  364. package/app/.next/server/app/dashboard/settings/pricing.segments/dashboard/settings.segment.rsc +1 -1
  365. package/app/.next/server/app/dashboard/settings/pricing.segments/dashboard.segment.rsc +1 -1
  366. package/app/.next/server/app/dashboard/translator.html +1 -1
  367. package/app/.next/server/app/dashboard/translator.rsc +7 -7
  368. package/app/.next/server/app/dashboard/translator.segments/!KGRhc2hib2FyZCk/dashboard/translator/__PAGE__.segment.rsc +2 -2
  369. package/app/.next/server/app/dashboard/translator.segments/!KGRhc2hib2FyZCk/dashboard/translator.segment.rsc +1 -1
  370. package/app/.next/server/app/dashboard/translator.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  371. package/app/.next/server/app/dashboard/translator.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  372. package/app/.next/server/app/dashboard/translator.segments/_full.segment.rsc +7 -7
  373. package/app/.next/server/app/dashboard/translator.segments/_head.segment.rsc +1 -1
  374. package/app/.next/server/app/dashboard/translator.segments/_index.segment.rsc +4 -4
  375. package/app/.next/server/app/dashboard/translator.segments/_tree.segment.rsc +2 -2
  376. package/app/.next/server/app/dashboard/usage.html +1 -1
  377. package/app/.next/server/app/dashboard/usage.rsc +7 -7
  378. package/app/.next/server/app/dashboard/usage.segments/!KGRhc2hib2FyZCk/dashboard/usage/__PAGE__.segment.rsc +2 -2
  379. package/app/.next/server/app/dashboard/usage.segments/!KGRhc2hib2FyZCk/dashboard/usage.segment.rsc +1 -1
  380. package/app/.next/server/app/dashboard/usage.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  381. package/app/.next/server/app/dashboard/usage.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  382. package/app/.next/server/app/dashboard/usage.segments/_full.segment.rsc +7 -7
  383. package/app/.next/server/app/dashboard/usage.segments/_head.segment.rsc +1 -1
  384. package/app/.next/server/app/dashboard/usage.segments/_index.segment.rsc +4 -4
  385. package/app/.next/server/app/dashboard/usage.segments/_tree.segment.rsc +2 -2
  386. package/app/.next/server/app/dashboard.html +1 -1
  387. package/app/.next/server/app/dashboard.meta +2 -0
  388. package/app/.next/server/app/dashboard.rsc +8 -9
  389. package/app/.next/server/app/dashboard.segments/!KGRhc2hib2FyZCk/dashboard/__PAGE__.segment.rsc +2 -2
  390. package/app/.next/server/app/dashboard.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  391. package/app/.next/server/app/dashboard.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  392. package/app/.next/server/app/dashboard.segments/_full.segment.rsc +8 -9
  393. package/app/.next/server/app/dashboard.segments/_head.segment.rsc +1 -1
  394. package/app/.next/server/app/dashboard.segments/_index.segment.rsc +4 -4
  395. package/app/.next/server/app/dashboard.segments/_tree.segment.rsc +2 -2
  396. package/app/.next/server/app/favicon.ico/route.js +1 -1
  397. package/app/.next/server/app/favicon.ico/route.js.nft.json +1 -1
  398. package/app/.next/server/app/index.html +1 -1
  399. package/app/.next/server/app/index.meta +1 -1
  400. package/app/.next/server/app/index.rsc +6 -6
  401. package/app/.next/server/app/index.segments/__PAGE__.segment.rsc +2 -2
  402. package/app/.next/server/app/index.segments/_full.segment.rsc +6 -6
  403. package/app/.next/server/app/index.segments/_head.segment.rsc +1 -1
  404. package/app/.next/server/app/index.segments/_index.segment.rsc +4 -4
  405. package/app/.next/server/app/index.segments/_tree.segment.rsc +2 -2
  406. package/app/.next/server/app/landing/page.js +2 -2
  407. package/app/.next/server/app/landing/page_client-reference-manifest.js +1 -1
  408. package/app/.next/server/app/landing.html +1 -1
  409. package/app/.next/server/app/landing.rsc +5 -5
  410. package/app/.next/server/app/landing.segments/_full.segment.rsc +5 -5
  411. package/app/.next/server/app/landing.segments/_head.segment.rsc +1 -1
  412. package/app/.next/server/app/landing.segments/_index.segment.rsc +4 -4
  413. package/app/.next/server/app/landing.segments/_tree.segment.rsc +2 -2
  414. package/app/.next/server/app/landing.segments/landing/__PAGE__.segment.rsc +1 -1
  415. package/app/.next/server/app/landing.segments/landing.segment.rsc +1 -1
  416. package/app/.next/server/app/login/page.js +2 -2
  417. package/app/.next/server/app/login/page.js.nft.json +1 -1
  418. package/app/.next/server/app/login/page_client-reference-manifest.js +1 -1
  419. package/app/.next/server/app/login.html +1 -1
  420. package/app/.next/server/app/login.rsc +6 -6
  421. package/app/.next/server/app/login.segments/_full.segment.rsc +6 -6
  422. package/app/.next/server/app/login.segments/_head.segment.rsc +1 -1
  423. package/app/.next/server/app/login.segments/_index.segment.rsc +4 -4
  424. package/app/.next/server/app/login.segments/_tree.segment.rsc +2 -2
  425. package/app/.next/server/app/login.segments/login/__PAGE__.segment.rsc +2 -2
  426. package/app/.next/server/app/login.segments/login.segment.rsc +1 -1
  427. package/app/.next/server/app/manifest.webmanifest/route.js +2 -2
  428. package/app/.next/server/app/manifest.webmanifest/route.js.nft.json +1 -1
  429. package/app/.next/server/app/page.js +2 -2
  430. package/app/.next/server/app/page.js.nft.json +1 -1
  431. package/app/.next/server/app/page_client-reference-manifest.js +1 -1
  432. package/app/.next/server/app-paths-manifest.json +10 -5
  433. package/app/.next/server/chunks/1424.js +1 -1
  434. package/app/.next/server/chunks/2664.js +1 -1
  435. package/app/.next/server/chunks/{318.js → 3093.js} +3 -3
  436. package/app/.next/server/chunks/336.js +1 -0
  437. package/app/.next/server/chunks/412.js +2 -2
  438. package/app/.next/server/chunks/4989.js +2 -2
  439. package/app/.next/server/chunks/6828.js +1 -0
  440. package/app/.next/server/chunks/8895.js +2 -2
  441. package/app/.next/server/chunks/9718.js +1 -1
  442. package/app/.next/server/middleware-build-manifest.js +1 -1
  443. package/app/.next/server/pages/404.html +1 -1
  444. package/app/.next/server/pages/500.html +1 -1
  445. package/app/.next/static/chunks/{5497-1e3ca6e102213311.js → 5497-95288063cad27087.js} +2 -2
  446. package/app/.next/static/chunks/5909-8229484e56dff5af.js +1 -0
  447. package/app/.next/static/chunks/6902-59c9bd4da89daa6c.js +1 -0
  448. package/app/.next/static/chunks/app/(dashboard)/dashboard/cli-tools/{page-b8a81c97c0f303e5.js → page-61e6d1dcc53a6f64.js} +1 -1
  449. package/app/.next/static/chunks/app/(dashboard)/dashboard/combos/{page-7a2c4bfc2d094dc8.js → page-eaaa0b2e7a9f2432.js} +1 -1
  450. package/app/.next/static/chunks/app/(dashboard)/dashboard/console-log/{page-9817f7dfd3db200f.js → page-0818a8d1c21dc842.js} +1 -1
  451. package/app/.next/static/chunks/app/(dashboard)/dashboard/employees/[keyId]/page-6d9ae639968fc1dd.js +1 -0
  452. package/app/.next/static/chunks/app/(dashboard)/dashboard/employees/page-ceaf0dc344eec2fe.js +1 -0
  453. package/app/.next/static/chunks/{8093-1d753947a159f3d6.js → app/(dashboard)/dashboard/endpoint/page-88605a2347dee47b.js} +2 -2
  454. package/app/.next/static/chunks/app/(dashboard)/dashboard/mitm/{page-ef761ecb487fe564.js → page-4b7378e5137f3fd8.js} +1 -1
  455. package/app/.next/static/chunks/app/(dashboard)/dashboard/page-aed1b231bb49a704.js +1 -0
  456. package/app/.next/static/chunks/app/(dashboard)/dashboard/profile/{page-26e2348f80c5fb86.js → page-d9fef809999e6003.js} +1 -1
  457. package/app/.next/static/chunks/app/(dashboard)/dashboard/providers/[id]/{page-d97e0153ce2081b1.js → page-91259a6310563c56.js} +1 -1
  458. package/app/.next/static/chunks/app/(dashboard)/dashboard/providers/new/{page-33a2031d2a33ee5a.js → page-def2087e830977cb.js} +1 -1
  459. package/app/.next/static/chunks/app/(dashboard)/dashboard/providers/{page-2fdc1cf4d09ba309.js → page-b5a0564904ed5969.js} +1 -1
  460. package/app/.next/static/chunks/app/(dashboard)/dashboard/proxy-pools/{page-6213cf39d4b20426.js → page-b62fbf4b69474242.js} +1 -1
  461. package/app/.next/static/chunks/app/(dashboard)/dashboard/translator/{page-3057dc573c7b21f0.js → page-e919a2e0bd879140.js} +1 -1
  462. package/app/.next/static/chunks/app/(dashboard)/dashboard/usage/page-a4c18af18bf2985a.js +1 -0
  463. package/app/.next/static/chunks/app/(dashboard)/{layout-3ef047ee09079701.js → layout-ce060c64625acbdc.js} +1 -1
  464. package/app/.next/static/chunks/app/_global-error/page-aed1b231bb49a704.js +1 -0
  465. package/app/.next/static/chunks/app/api/auth/login/route-aed1b231bb49a704.js +1 -0
  466. package/app/.next/static/chunks/app/api/auth/logout/route-aed1b231bb49a704.js +1 -0
  467. package/app/.next/static/chunks/app/api/cli-tools/antigravity-mitm/alias/route-aed1b231bb49a704.js +1 -0
  468. package/app/.next/static/chunks/app/api/cli-tools/antigravity-mitm/route-aed1b231bb49a704.js +1 -0
  469. package/app/.next/static/chunks/app/api/cli-tools/claude-settings/route-aed1b231bb49a704.js +1 -0
  470. package/app/.next/static/chunks/app/api/cli-tools/codex-settings/route-aed1b231bb49a704.js +1 -0
  471. package/app/.next/static/chunks/app/api/cli-tools/copilot-settings/route-aed1b231bb49a704.js +1 -0
  472. package/app/.next/static/chunks/app/api/cli-tools/droid-settings/route-aed1b231bb49a704.js +1 -0
  473. package/app/.next/static/chunks/app/api/cli-tools/openclaw-settings/route-aed1b231bb49a704.js +1 -0
  474. package/app/.next/static/chunks/app/api/cli-tools/opencode-settings/route-aed1b231bb49a704.js +1 -0
  475. package/app/.next/static/chunks/app/api/cloud/auth/route-aed1b231bb49a704.js +1 -0
  476. package/app/.next/static/chunks/app/api/cloud/credentials/update/route-aed1b231bb49a704.js +1 -0
  477. package/app/.next/static/chunks/app/api/cloud/model/resolve/route-aed1b231bb49a704.js +1 -0
  478. package/app/.next/static/chunks/app/api/cloud/models/alias/route-aed1b231bb49a704.js +1 -0
  479. package/app/.next/static/chunks/app/api/combos/[id]/route-aed1b231bb49a704.js +1 -0
  480. package/app/.next/static/chunks/app/api/combos/route-aed1b231bb49a704.js +1 -0
  481. package/app/.next/static/chunks/app/api/employees/[keyId]/stats/route-aed1b231bb49a704.js +1 -0
  482. package/app/.next/static/chunks/app/api/employees/stats/route-aed1b231bb49a704.js +1 -0
  483. package/app/.next/static/chunks/app/api/init/route-aed1b231bb49a704.js +1 -0
  484. package/app/.next/static/chunks/app/api/keys/[id]/route-aed1b231bb49a704.js +1 -0
  485. package/app/.next/static/chunks/app/api/keys/route-aed1b231bb49a704.js +1 -0
  486. package/app/.next/static/chunks/app/api/locale/route-aed1b231bb49a704.js +1 -0
  487. package/app/.next/static/chunks/app/api/models/alias/route-aed1b231bb49a704.js +1 -0
  488. package/app/.next/static/chunks/app/api/models/route-aed1b231bb49a704.js +1 -0
  489. package/app/.next/static/chunks/app/api/models/test/route-aed1b231bb49a704.js +1 -0
  490. package/app/.next/static/chunks/app/api/oauth/[provider]/[action]/route-aed1b231bb49a704.js +1 -0
  491. package/app/.next/static/chunks/app/api/oauth/cursor/auto-import/route-aed1b231bb49a704.js +1 -0
  492. package/app/.next/static/chunks/app/api/oauth/cursor/import/route-aed1b231bb49a704.js +1 -0
  493. package/app/.next/static/chunks/app/api/oauth/iflow/cookie/route-aed1b231bb49a704.js +1 -0
  494. package/app/.next/static/chunks/app/api/oauth/kiro/auto-import/route-aed1b231bb49a704.js +1 -0
  495. package/app/.next/static/chunks/app/api/oauth/kiro/import/route-aed1b231bb49a704.js +1 -0
  496. package/app/.next/static/chunks/app/api/oauth/kiro/social-authorize/route-aed1b231bb49a704.js +1 -0
  497. package/app/.next/static/chunks/app/api/oauth/kiro/social-exchange/route-aed1b231bb49a704.js +1 -0
  498. package/app/.next/static/chunks/app/api/pricing/route-aed1b231bb49a704.js +1 -0
  499. package/app/.next/static/chunks/app/api/provider-nodes/[id]/route-aed1b231bb49a704.js +1 -0
  500. package/app/.next/static/chunks/app/api/provider-nodes/route-aed1b231bb49a704.js +1 -0
  501. package/app/.next/static/chunks/app/api/provider-nodes/validate/route-aed1b231bb49a704.js +1 -0
  502. package/app/.next/static/chunks/app/api/providers/[id]/models/route-aed1b231bb49a704.js +1 -0
  503. package/app/.next/static/chunks/app/api/providers/[id]/route-aed1b231bb49a704.js +1 -0
  504. package/app/.next/static/chunks/app/api/providers/[id]/test/route-aed1b231bb49a704.js +1 -0
  505. package/app/.next/static/chunks/app/api/providers/[id]/test-models/route-aed1b231bb49a704.js +1 -0
  506. package/app/.next/static/chunks/app/api/providers/client/route-aed1b231bb49a704.js +1 -0
  507. package/app/.next/static/chunks/app/api/providers/route-aed1b231bb49a704.js +1 -0
  508. package/app/.next/static/chunks/app/api/providers/test-batch/route-aed1b231bb49a704.js +1 -0
  509. package/app/.next/static/chunks/app/api/providers/validate/route-aed1b231bb49a704.js +1 -0
  510. package/app/.next/static/chunks/app/api/proxy-pools/[id]/route-aed1b231bb49a704.js +1 -0
  511. package/app/.next/static/chunks/app/api/proxy-pools/[id]/test/route-aed1b231bb49a704.js +1 -0
  512. package/app/.next/static/chunks/app/api/proxy-pools/route-aed1b231bb49a704.js +1 -0
  513. package/app/.next/static/chunks/app/api/settings/database/route-aed1b231bb49a704.js +1 -0
  514. package/app/.next/static/chunks/app/api/settings/proxy-test/route-aed1b231bb49a704.js +1 -0
  515. package/app/.next/static/chunks/app/api/settings/require-login/route-aed1b231bb49a704.js +1 -0
  516. package/app/.next/static/chunks/app/api/settings/route-aed1b231bb49a704.js +1 -0
  517. package/app/.next/static/chunks/app/api/shutdown/route-aed1b231bb49a704.js +1 -0
  518. package/app/.next/static/chunks/app/api/tags/route-aed1b231bb49a704.js +1 -0
  519. package/app/.next/static/chunks/app/api/translator/console-logs/route-aed1b231bb49a704.js +1 -0
  520. package/app/.next/static/chunks/app/api/translator/console-logs/stream/route-aed1b231bb49a704.js +1 -0
  521. package/app/.next/static/chunks/app/api/translator/load/route-aed1b231bb49a704.js +1 -0
  522. package/app/.next/static/chunks/app/api/translator/save/route-aed1b231bb49a704.js +1 -0
  523. package/app/.next/static/chunks/app/api/translator/send/route-aed1b231bb49a704.js +1 -0
  524. package/app/.next/static/chunks/app/api/translator/translate/route-aed1b231bb49a704.js +1 -0
  525. package/app/.next/static/chunks/app/api/tunnel/disable/route-aed1b231bb49a704.js +1 -0
  526. package/app/.next/static/chunks/app/api/tunnel/enable/route-aed1b231bb49a704.js +1 -0
  527. package/app/.next/static/chunks/app/api/tunnel/status/route-aed1b231bb49a704.js +1 -0
  528. package/app/.next/static/chunks/app/api/usage/[connectionId]/route-aed1b231bb49a704.js +1 -0
  529. package/app/.next/static/chunks/app/api/usage/chart/route-aed1b231bb49a704.js +1 -0
  530. package/app/.next/static/chunks/app/api/usage/history/route-aed1b231bb49a704.js +1 -0
  531. package/app/.next/static/chunks/app/api/usage/logs/route-aed1b231bb49a704.js +1 -0
  532. package/app/.next/static/chunks/app/api/usage/providers/route-aed1b231bb49a704.js +1 -0
  533. package/app/.next/static/chunks/app/api/usage/request-details/[id]/route-aed1b231bb49a704.js +1 -0
  534. package/app/.next/static/chunks/app/api/usage/request-details/route-aed1b231bb49a704.js +1 -0
  535. package/app/.next/static/chunks/app/api/usage/request-logs/route-aed1b231bb49a704.js +1 -0
  536. package/app/.next/static/chunks/app/api/usage/stats/route-aed1b231bb49a704.js +1 -0
  537. package/app/.next/static/chunks/app/api/usage/stream/route-aed1b231bb49a704.js +1 -0
  538. package/app/.next/static/chunks/app/api/v1/api/chat/route-aed1b231bb49a704.js +1 -0
  539. package/app/.next/static/chunks/app/api/v1/chat/completions/route-aed1b231bb49a704.js +1 -0
  540. package/app/.next/static/chunks/app/api/v1/embeddings/route-aed1b231bb49a704.js +1 -0
  541. package/app/.next/static/chunks/app/api/v1/messages/count_tokens/route-aed1b231bb49a704.js +1 -0
  542. package/app/.next/static/chunks/app/api/v1/messages/route-aed1b231bb49a704.js +1 -0
  543. package/app/.next/static/chunks/app/api/v1/models/route-aed1b231bb49a704.js +1 -0
  544. package/app/.next/static/chunks/app/api/v1/responses/route-aed1b231bb49a704.js +1 -0
  545. package/app/.next/static/chunks/app/api/v1/route-aed1b231bb49a704.js +1 -0
  546. package/app/.next/static/chunks/app/api/v1beta/models/[...path]/route-aed1b231bb49a704.js +1 -0
  547. package/app/.next/static/chunks/app/api/v1beta/models/route-aed1b231bb49a704.js +1 -0
  548. package/app/.next/static/chunks/app/api/v1internal/route-aed1b231bb49a704.js +1 -0
  549. package/app/.next/static/chunks/app/api/version/route-aed1b231bb49a704.js +1 -0
  550. package/app/.next/static/chunks/app/{layout-7d320cc74dc582e9.js → layout-5f14b5ffaa464c15.js} +1 -1
  551. package/app/.next/static/chunks/app/login/{page-025e378eb5cdb421.js → page-5e162056267a89f6.js} +1 -1
  552. package/app/.next/static/chunks/app/manifest.webmanifest/route-aed1b231bb49a704.js +1 -0
  553. package/app/.next/static/chunks/app/page-aed1b231bb49a704.js +1 -0
  554. package/app/.next/static/chunks/next/dist/client/components/builtin/app-error-aed1b231bb49a704.js +1 -0
  555. package/app/.next/static/chunks/next/dist/client/components/builtin/forbidden-aed1b231bb49a704.js +1 -0
  556. package/app/.next/static/chunks/next/dist/client/components/builtin/not-found-aed1b231bb49a704.js +1 -0
  557. package/app/.next/static/chunks/next/dist/client/components/builtin/unauthorized-aed1b231bb49a704.js +1 -0
  558. package/app/.next/static/chunks/webpack-1094c4a28660424b.js +1 -0
  559. package/app/.next/static/css/e83da33dd60e45a9.css +3 -0
  560. package/app/.next/static/kziRUh9x_T6WFTaeglA8u/_buildManifest.js +1 -0
  561. package/app/open-sse/executors/antigravity.js +27 -4
  562. package/app/open-sse/handlers/chatCore/nonStreamingHandler.js +1 -1
  563. package/app/open-sse/handlers/chatCore/requestDetail.js +1 -0
  564. package/app/open-sse/handlers/chatCore/sseToJsonHandler.js +1 -1
  565. package/app/open-sse/handlers/chatCore/streamingHandler.js +5 -5
  566. package/app/open-sse/handlers/chatCore.js +2 -2
  567. package/app/open-sse/handlers/internalChatCore.js +6 -6
  568. package/app/package.json +3 -3
  569. package/app/server.js +1 -1
  570. package/package.json +1 -1
  571. package/app/.next/server/chunks/1386.js +0 -3
  572. package/app/.next/server/chunks/4689.js +0 -1
  573. package/app/.next/static/L6G1Bw3njbM3GTWLVjBSx/_buildManifest.js +0 -1
  574. package/app/.next/static/chunks/123-58257c9badaeaf84.js +0 -1
  575. package/app/.next/static/chunks/app/(dashboard)/dashboard/endpoint/page-4a59bbf5f1889d13.js +0 -1
  576. package/app/.next/static/chunks/app/(dashboard)/dashboard/page-ab4c1f7ada9eefda.js +0 -1
  577. package/app/.next/static/chunks/app/(dashboard)/dashboard/usage/page-4c59e920e2fecc16.js +0 -1
  578. package/app/.next/static/chunks/app/_global-error/page-b30d6a5358c02312.js +0 -1
  579. package/app/.next/static/chunks/app/api/auth/login/route-b30d6a5358c02312.js +0 -1
  580. package/app/.next/static/chunks/app/api/auth/logout/route-b30d6a5358c02312.js +0 -1
  581. package/app/.next/static/chunks/app/api/cli-tools/antigravity-mitm/alias/route-b30d6a5358c02312.js +0 -1
  582. package/app/.next/static/chunks/app/api/cli-tools/antigravity-mitm/route-b30d6a5358c02312.js +0 -1
  583. package/app/.next/static/chunks/app/api/cli-tools/claude-settings/route-b30d6a5358c02312.js +0 -1
  584. package/app/.next/static/chunks/app/api/cli-tools/codex-settings/route-b30d6a5358c02312.js +0 -1
  585. package/app/.next/static/chunks/app/api/cli-tools/copilot-settings/route-b30d6a5358c02312.js +0 -1
  586. package/app/.next/static/chunks/app/api/cli-tools/droid-settings/route-b30d6a5358c02312.js +0 -1
  587. package/app/.next/static/chunks/app/api/cli-tools/openclaw-settings/route-b30d6a5358c02312.js +0 -1
  588. package/app/.next/static/chunks/app/api/cli-tools/opencode-settings/route-b30d6a5358c02312.js +0 -1
  589. package/app/.next/static/chunks/app/api/cloud/auth/route-b30d6a5358c02312.js +0 -1
  590. package/app/.next/static/chunks/app/api/cloud/credentials/update/route-b30d6a5358c02312.js +0 -1
  591. package/app/.next/static/chunks/app/api/cloud/model/resolve/route-b30d6a5358c02312.js +0 -1
  592. package/app/.next/static/chunks/app/api/cloud/models/alias/route-b30d6a5358c02312.js +0 -1
  593. package/app/.next/static/chunks/app/api/combos/[id]/route-b30d6a5358c02312.js +0 -1
  594. package/app/.next/static/chunks/app/api/combos/route-b30d6a5358c02312.js +0 -1
  595. package/app/.next/static/chunks/app/api/init/route-b30d6a5358c02312.js +0 -1
  596. package/app/.next/static/chunks/app/api/keys/[id]/route-b30d6a5358c02312.js +0 -1
  597. package/app/.next/static/chunks/app/api/keys/route-b30d6a5358c02312.js +0 -1
  598. package/app/.next/static/chunks/app/api/locale/route-b30d6a5358c02312.js +0 -1
  599. package/app/.next/static/chunks/app/api/models/alias/route-b30d6a5358c02312.js +0 -1
  600. package/app/.next/static/chunks/app/api/models/route-b30d6a5358c02312.js +0 -1
  601. package/app/.next/static/chunks/app/api/models/test/route-b30d6a5358c02312.js +0 -1
  602. package/app/.next/static/chunks/app/api/oauth/[provider]/[action]/route-b30d6a5358c02312.js +0 -1
  603. package/app/.next/static/chunks/app/api/oauth/cursor/auto-import/route-b30d6a5358c02312.js +0 -1
  604. package/app/.next/static/chunks/app/api/oauth/cursor/import/route-b30d6a5358c02312.js +0 -1
  605. package/app/.next/static/chunks/app/api/oauth/iflow/cookie/route-b30d6a5358c02312.js +0 -1
  606. package/app/.next/static/chunks/app/api/oauth/kiro/auto-import/route-b30d6a5358c02312.js +0 -1
  607. package/app/.next/static/chunks/app/api/oauth/kiro/import/route-b30d6a5358c02312.js +0 -1
  608. package/app/.next/static/chunks/app/api/oauth/kiro/social-authorize/route-b30d6a5358c02312.js +0 -1
  609. package/app/.next/static/chunks/app/api/oauth/kiro/social-exchange/route-b30d6a5358c02312.js +0 -1
  610. package/app/.next/static/chunks/app/api/pricing/route-b30d6a5358c02312.js +0 -1
  611. package/app/.next/static/chunks/app/api/provider-nodes/[id]/route-b30d6a5358c02312.js +0 -1
  612. package/app/.next/static/chunks/app/api/provider-nodes/route-b30d6a5358c02312.js +0 -1
  613. package/app/.next/static/chunks/app/api/provider-nodes/validate/route-b30d6a5358c02312.js +0 -1
  614. package/app/.next/static/chunks/app/api/providers/[id]/models/route-b30d6a5358c02312.js +0 -1
  615. package/app/.next/static/chunks/app/api/providers/[id]/route-b30d6a5358c02312.js +0 -1
  616. package/app/.next/static/chunks/app/api/providers/[id]/test/route-b30d6a5358c02312.js +0 -1
  617. package/app/.next/static/chunks/app/api/providers/[id]/test-models/route-b30d6a5358c02312.js +0 -1
  618. package/app/.next/static/chunks/app/api/providers/client/route-b30d6a5358c02312.js +0 -1
  619. package/app/.next/static/chunks/app/api/providers/route-b30d6a5358c02312.js +0 -1
  620. package/app/.next/static/chunks/app/api/providers/test-batch/route-b30d6a5358c02312.js +0 -1
  621. package/app/.next/static/chunks/app/api/providers/validate/route-b30d6a5358c02312.js +0 -1
  622. package/app/.next/static/chunks/app/api/proxy-pools/[id]/route-b30d6a5358c02312.js +0 -1
  623. package/app/.next/static/chunks/app/api/proxy-pools/[id]/test/route-b30d6a5358c02312.js +0 -1
  624. package/app/.next/static/chunks/app/api/proxy-pools/route-b30d6a5358c02312.js +0 -1
  625. package/app/.next/static/chunks/app/api/settings/database/route-b30d6a5358c02312.js +0 -1
  626. package/app/.next/static/chunks/app/api/settings/proxy-test/route-b30d6a5358c02312.js +0 -1
  627. package/app/.next/static/chunks/app/api/settings/require-login/route-b30d6a5358c02312.js +0 -1
  628. package/app/.next/static/chunks/app/api/settings/route-b30d6a5358c02312.js +0 -1
  629. package/app/.next/static/chunks/app/api/shutdown/route-b30d6a5358c02312.js +0 -1
  630. package/app/.next/static/chunks/app/api/tags/route-b30d6a5358c02312.js +0 -1
  631. package/app/.next/static/chunks/app/api/translator/console-logs/route-b30d6a5358c02312.js +0 -1
  632. package/app/.next/static/chunks/app/api/translator/console-logs/stream/route-b30d6a5358c02312.js +0 -1
  633. package/app/.next/static/chunks/app/api/translator/load/route-b30d6a5358c02312.js +0 -1
  634. package/app/.next/static/chunks/app/api/translator/save/route-b30d6a5358c02312.js +0 -1
  635. package/app/.next/static/chunks/app/api/translator/send/route-b30d6a5358c02312.js +0 -1
  636. package/app/.next/static/chunks/app/api/translator/translate/route-b30d6a5358c02312.js +0 -1
  637. package/app/.next/static/chunks/app/api/tunnel/disable/route-b30d6a5358c02312.js +0 -1
  638. package/app/.next/static/chunks/app/api/tunnel/enable/route-b30d6a5358c02312.js +0 -1
  639. package/app/.next/static/chunks/app/api/tunnel/status/route-b30d6a5358c02312.js +0 -1
  640. package/app/.next/static/chunks/app/api/usage/[connectionId]/route-b30d6a5358c02312.js +0 -1
  641. package/app/.next/static/chunks/app/api/usage/chart/route-b30d6a5358c02312.js +0 -1
  642. package/app/.next/static/chunks/app/api/usage/history/route-b30d6a5358c02312.js +0 -1
  643. package/app/.next/static/chunks/app/api/usage/logs/route-b30d6a5358c02312.js +0 -1
  644. package/app/.next/static/chunks/app/api/usage/providers/route-b30d6a5358c02312.js +0 -1
  645. package/app/.next/static/chunks/app/api/usage/request-details/route-b30d6a5358c02312.js +0 -1
  646. package/app/.next/static/chunks/app/api/usage/request-logs/route-b30d6a5358c02312.js +0 -1
  647. package/app/.next/static/chunks/app/api/usage/stats/route-b30d6a5358c02312.js +0 -1
  648. package/app/.next/static/chunks/app/api/usage/stream/route-b30d6a5358c02312.js +0 -1
  649. package/app/.next/static/chunks/app/api/v1/api/chat/route-b30d6a5358c02312.js +0 -1
  650. package/app/.next/static/chunks/app/api/v1/chat/completions/route-b30d6a5358c02312.js +0 -1
  651. package/app/.next/static/chunks/app/api/v1/embeddings/route-b30d6a5358c02312.js +0 -1
  652. package/app/.next/static/chunks/app/api/v1/messages/count_tokens/route-b30d6a5358c02312.js +0 -1
  653. package/app/.next/static/chunks/app/api/v1/messages/route-b30d6a5358c02312.js +0 -1
  654. package/app/.next/static/chunks/app/api/v1/models/route-b30d6a5358c02312.js +0 -1
  655. package/app/.next/static/chunks/app/api/v1/responses/route-b30d6a5358c02312.js +0 -1
  656. package/app/.next/static/chunks/app/api/v1/route-b30d6a5358c02312.js +0 -1
  657. package/app/.next/static/chunks/app/api/v1beta/models/[...path]/route-b30d6a5358c02312.js +0 -1
  658. package/app/.next/static/chunks/app/api/v1beta/models/route-b30d6a5358c02312.js +0 -1
  659. package/app/.next/static/chunks/app/api/v1internal/route-b30d6a5358c02312.js +0 -1
  660. package/app/.next/static/chunks/app/api/version/route-b30d6a5358c02312.js +0 -1
  661. package/app/.next/static/chunks/app/manifest.webmanifest/route-b30d6a5358c02312.js +0 -1
  662. package/app/.next/static/chunks/app/page-b30d6a5358c02312.js +0 -1
  663. package/app/.next/static/chunks/next/dist/client/components/builtin/app-error-b30d6a5358c02312.js +0 -1
  664. package/app/.next/static/chunks/next/dist/client/components/builtin/forbidden-b30d6a5358c02312.js +0 -1
  665. package/app/.next/static/chunks/next/dist/client/components/builtin/not-found-b30d6a5358c02312.js +0 -1
  666. package/app/.next/static/chunks/next/dist/client/components/builtin/unauthorized-b30d6a5358c02312.js +0 -1
  667. package/app/.next/static/chunks/webpack-819d2440cd722d0f.js +0 -1
  668. package/app/.next/static/css/c29219c65952419f.css +0 -3
  669. /package/app/.next/static/{L6G1Bw3njbM3GTWLVjBSx → kziRUh9x_T6WFTaeglA8u}/_ssgManifest.js +0 -0
@@ -1 +1 @@
1
- (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[2134],{16113:(e,t,i)=>{Promise.resolve().then(i.bind(i,97162))},97162:(e,t,i)=>{"use strict";i.r(t),i.d(t,{default:()=>h});var s=i(95155),a=i(12115),r=i(14051),l=i.n(r),o=i(73321),n=i(98500),d=i.n(n),c=i(5772),p=i(35497),m=i(52679),x=i(28777),u=i(11059);function h(){let e=(0,o.useParams)(),t=(0,o.useRouter)(),i=e.id,[r,l]=(0,a.useState)([]),[n,h]=(0,a.useState)(!0),[g,b]=(0,a.useState)(null),[S,A]=(0,a.useState)([]),[$,P]=(0,a.useState)(!1),[T,O]=(0,a.useState)(!1),[E,R]=(0,a.useState)(!1),[I,_]=(0,a.useState)(!1),[D,q]=(0,a.useState)(!1),[U,K]=(0,a.useState)(!1),[M,L]=(0,a.useState)(null),[z,J]=(0,a.useState)({}),[F,W]=(0,a.useState)(!1),[V,B]=(0,a.useState)({}),[Z,G]=(0,a.useState)(""),[Q,H]=(0,a.useState)(null),[X,Y]=(0,a.useState)(!1),[ee,et]=(0,a.useState)([]),[ei,es]=(0,a.useState)("__none__"),[ea,er]=(0,a.useState)(!1),[el,eo]=(0,a.useState)(null),[en,ed]=(0,a.useState)(""),{copied:ec,copy:ep}=(0,u.C)(),em=g?{id:g.id,name:g.name||("anthropic-compatible"===g.type?"Anthropic Compatible":"OpenAI Compatible"),color:"anthropic-compatible"===g.type?"#D97757":"#10A37F",textIcon:"anthropic-compatible"===g.type?"AC":"OC",apiType:g.apiType,baseUrl:g.baseUrl,type:g.type}:m.zN[i]||m.fg[i]||m.IS[i],ex=!!m.zN[i]||!!m.IS[i],eu=(0,x.KC)(i),eh=(0,m.wG)(i),ey=(0,m.mq)(i),ef=(0,m.gb)(i),eg=ey||ef,ev=eg?i:eh,eb=eg?g?.prefix||i:eh,ej=(0,a.useCallback)(async()=>{try{let e=await fetch("/api/models/alias"),t=await e.json();e.ok&&J(t.aliases||{})}catch(e){console.log("Error fetching aliases:",e)}},[]),eN=(0,a.useCallback)(async()=>{try{let[e,t,s,a]=await Promise.all([fetch("/api/providers",{cache:"no-store"}),fetch("/api/provider-nodes",{cache:"no-store"}),fetch("/api/proxy-pools?isActive=true",{cache:"no-store"}),fetch("/api/settings",{cache:"no-store"})]),r=await e.json(),o=await t.json(),n=await s.json(),d=a.ok?await a.json():{};if(e.ok){let e=(r.connections||[]).filter(e=>e.provider===i);l(e)}s.ok&&A(n.proxyPools||[]);let c=(d.providerStrategies||{})[i]||{};if(eo(c.fallbackStrategy||null),ed(null!=c.stickyRoundRobinLimit?String(c.stickyRoundRobinLimit):"1"),t.ok){let e=(o.nodes||[]).find(e=>e.id===i)||null;if(!e&&eg)for(let t=0;t<3;t+=1){await new Promise(e=>setTimeout(e,150));let t=await fetch("/api/provider-nodes",{cache:"no-store"});if(t.ok&&(e=((await t.json()).nodes||[]).find(e=>e.id===i)||null))break}b(e)}}catch(e){console.log("Error fetching connections:",e)}finally{h(!1)}},[i,eg]),ek=async e=>{try{let t=await fetch(`/api/provider-nodes/${i}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}),s=await t.json();t.ok&&(b(s.node),await eN(),q(!1))}catch(e){console.log("Error updating provider node:",e)}},eC=async(e,t)=>{try{let s=await fetch("/api/settings",{cache:"no-store"}),a=(s.ok?await s.json():{}).providerStrategies||{},r={};e&&(r.fallbackStrategy=e),"round-robin"===e&&""!==t&&(r.stickyRoundRobinLimit=Number(t)||3);let l={...a};0===Object.keys(r).length?delete l[i]:l[i]=r,await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({providerStrategies:l})})}catch(e){console.log("Error saving provider strategy:",e)}};(0,a.useEffect)(()=>{eN(),ej()},[eN,ej]);let ew=async(e,t,i=eh)=>{let s=`${i}/${e}`;try{let e=await fetch("/api/models/alias",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({model:s,alias:t})});if(e.ok)await ej();else{let t=await e.json();alert(t.error||"Failed to set alias")}}catch(e){console.log("Error setting alias:",e)}},eS=async e=>{try{(await fetch(`/api/models/alias?alias=${encodeURIComponent(e)}`,{method:"DELETE"})).ok&&await ej()}catch(e){console.log("Error deleting alias:",e)}},eA=async e=>{if(confirm("Delete this connection?"))try{(await fetch(`/api/providers/${e}`,{method:"DELETE"})).ok&&l(r.filter(t=>t.id!==e))}catch(e){console.log("Error deleting connection:",e)}},e$=()=>{eN(),P(!1)},eP=async e=>{try{(await fetch("/api/providers",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:i,...e})})).ok&&(await eN(),R(!1))}catch(e){console.log("Error saving connection:",e)}},eT=async e=>{try{(await fetch(`/api/providers/${M.id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})).ok&&(await eN(),_(!1))}catch(e){console.log("Error updating connection:",e)}},eO=async(e,t)=>{try{(await fetch(`/api/providers/${e}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({isActive:t})})).ok&&l(i=>i.map(i=>i.id===e?{...i,isActive:t}:i))}catch(e){console.log("Error updating connection status:",e)}},eE=async(e,t)=>{let i=[...r];[i[e],i[t]]=[i[t],i[e]],l(i);try{await Promise.all([fetch(`/api/providers/${i[e].id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({priority:e})}),fetch(`/api/providers/${i[t].id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({priority:t})})])}catch(e){console.log("Error swapping priority:",e),await eN()}},eR=r.filter(e=>ee.includes(e.id));r.length>0&&(ee.length,r.length),(0,a.useEffect)(()=>{et(e=>e.filter(e=>r.some(t=>t.id===e)))},[r]);let eI=(()=>{if(0===eR.length)return"";let e=new Set(eR.map(e=>e.providerSpecificData?.proxyPoolId||"__none__"));if(1===e.size){let t=[...e][0];if("__none__"===t)return"All selected currently unbound";let i=S.find(e=>e.id===t);return`All selected currently bound to ${i?.name||t}`}return"Selected connections have mixed proxy bindings"})(),e_=()=>{ea||K(!1)},eD=async()=>{if(0===ee.length)return;let e="__none__"===ei?null:ei;er(!0);try{let t=[];for(let i of ee)try{let s=await fetch(`/api/providers/${i}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({proxyPoolId:e})});t.push(s.ok)}catch(e){console.log("Error applying bulk proxy pool for",i,e),t.push(!1)}let i=t.filter(e=>!e).length;i>0&&alert(`Updated with ${i} failed request(s).`),await eN(),et([]),es("__none__"),K(!1)}catch(e){console.log("Error applying bulk proxy pool:",e)}finally{er(!1)}},eq=(0,s.jsx)("div",{className:"flex flex-col divide-y divide-black/[0.03] dark:divide-white/[0.03]",children:r.map((e,t)=>(0,s.jsx)("div",{className:"flex items-stretch",children:(0,s.jsx)("div",{className:"flex-1 min-w-0",children:(0,s.jsx)(j,{connection:e,proxyPools:S,isOAuth:ex,isFirst:0===t,isLast:t===r.length-1,onMoveUp:()=>eE(t,t-1),onMoveDown:()=>eE(t,t+1),onToggleActive:t=>eO(e.id,t),onUpdateProxy:async t=>{try{(await fetch(`/api/providers/${e.id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({proxyPoolId:t||null})})).ok&&l(i=>i.map(i=>i.id===e.id?{...i,providerSpecificData:{...i.providerSpecificData,proxyPoolId:t||null}}:i))}catch(e){console.log("Error updating proxy:",e)}},onEdit:()=>{L(e),_(!0)},onDelete:()=>eA(e.id)})})},e.id))}),eU=[{value:"__none__",label:"None"},...S.map(e=>({value:e.id,label:e.name}))],eK=0===ee.length?"Select one or more connections, then click Proxy Action.":eI,eM=ee.length>0&&!ea,eL=(0,s.jsx)(p.aF,{isOpen:U,onClose:e_,title:`Proxy Action (${ee.length} selected)`,children:(0,s.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,s.jsx)(p.l6,{label:"Proxy Pool",value:ei,onChange:e=>es(e.target.value),options:eU,placeholder:"None"}),(0,s.jsx)("p",{className:"text-xs text-text-muted",children:eK}),(0,s.jsx)("p",{className:"text-xs text-text-muted",children:"Selecting None will unbind selected connections from proxy pool."}),(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsx)(p.$n,{onClick:eD,fullWidth:!0,disabled:!eM,children:ea?"Applying...":"Apply"}),(0,s.jsx)(p.$n,{onClick:e_,variant:"ghost",fullWidth:!0,disabled:ea,children:"Cancel"})]})]})}),ez=async e=>{if(!Q){H(e);try{let t=await fetch("/api/models/test",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({model:`${ev}/${e}`})}),i=await t.json();B(t=>({...t,[e]:i.ok?"ok":"error"})),G(i.ok?"":i.error||"Model not reachable")}catch{B(t=>({...t,[e]:"error"})),G("Network error")}finally{H(null)}}};return n?(0,s.jsxs)("div",{className:"flex flex-col gap-8",children:[(0,s.jsx)(p.Qv,{}),(0,s.jsx)(p.Qv,{})]}):em?(0,s.jsxs)("div",{className:"flex flex-col gap-8",children:[(0,s.jsxs)("div",{children:[(0,s.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,s.jsx)("span",{className:"material-symbols-outlined text-lg",children:"arrow_back"}),"Back to Providers"]}),(0,s.jsxs)("div",{className:"flex items-center gap-4",children:[(0,s.jsx)("div",{className:"rounded-lg flex items-center justify-center",style:{backgroundColor:`${em.color}15`},children:F?(0,s.jsx)("span",{className:"text-sm font-bold",style:{color:em.color},children:em.textIcon||em.id.slice(0,2).toUpperCase()}):(0,s.jsx)(c.default,{src:ey&&em.apiType?"responses"===em.apiType?"/providers/oai-r.png":"/providers/oai-cc.png":ef?"/providers/anthropic-m.png":`/providers/${em.id}.png`,alt:em.name,width:48,height:48,className:"object-contain rounded-lg max-w-[48px] max-h-[48px]",sizes:"48px",onError:()=>W(!0)})}),(0,s.jsxs)("div",{children:[(0,s.jsx)("h1",{className:"text-3xl font-semibold tracking-tight",children:em.name}),(0,s.jsxs)("p",{className:"text-text-muted",children:[r.length," connection",1===r.length?"":"s"]})]})]})]}),eg&&g&&(0,s.jsxs)(p.Zp,{children:[(0,s.jsxs)("div",{className:"flex items-center justify-between mb-4",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("h2",{className:"text-lg font-semibold",children:ef?"Anthropic Compatible Details":"OpenAI Compatible Details"}),(0,s.jsxs)("p",{className:"text-sm text-text-muted",children:[ef?"Messages API":"responses"===g.apiType?"Responses API":"Chat Completions"," \xb7 ",(g.baseUrl||"").replace(/\/$/,""),"/",ef?"messages":"responses"===g.apiType?"responses":"chat/completions"]})]}),(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)(p.$n,{size:"sm",icon:"add",onClick:()=>R(!0),disabled:r.length>0,children:"Add"}),(0,s.jsx)(p.$n,{size:"sm",variant:"secondary",icon:"edit",onClick:()=>q(!0),children:"Edit"}),(0,s.jsx)(p.$n,{size:"sm",variant:"secondary",icon:"delete",onClick:async()=>{if(confirm(`Delete this ${ef?"Anthropic":"OpenAI"} Compatible node?`))try{(await fetch(`/api/provider-nodes/${i}`,{method:"DELETE"})).ok&&t.push("/dashboard/providers")}catch(e){console.log("Error deleting provider node:",e)}},children:"Delete"})]})]}),r.length>0&&(0,s.jsx)("p",{className:"text-sm text-text-muted",children:"Only one connection is allowed per compatible node. Add another node if you need more connections."})]}),(0,s.jsxs)(p.Zp,{children:[(0,s.jsxs)("div",{className:"flex items-center justify-between mb-4",children:[(0,s.jsx)("h2",{className:"text-lg font-semibold",children:"Connections"}),(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)("span",{className:"text-xs text-text-muted font-medium",children:"Round Robin"}),(0,s.jsx)(p.lM,{checked:"round-robin"===el,onChange:e=>{let t=e?"round-robin":null,i=e?en||"1":en;e&&!en&&ed("1"),eo(t),eC(t,i)}}),"round-robin"===el&&(0,s.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,s.jsx)("span",{className:"text-xs text-text-muted",children:"Sticky:"}),(0,s.jsx)("input",{type:"number",min:1,value:en,onChange:e=>{var t;ed(t=e.target.value),eC("round-robin",t)},placeholder:"1",className:"w-14 px-2 py-1 text-xs border border-border rounded-md bg-background focus:outline-none focus:border-primary"})]})]})]}),0===r.length?(0,s.jsxs)("div",{className:"text-center py-12",children:[(0,s.jsx)("div",{className:"inline-flex items-center justify-center w-16 h-16 rounded-full bg-primary/10 text-primary mb-4",children:(0,s.jsx)("span",{className:"material-symbols-outlined text-[32px]",children:ex?"lock":"key"})}),(0,s.jsx)("p",{className:"text-text-main font-medium mb-1",children:"No connections yet"}),(0,s.jsx)("p",{className:"text-sm text-text-muted mb-4",children:"Add your first connection to get started"}),!eg&&(0,s.jsxs)("div",{className:"flex gap-2 justify-center",children:["iflow"===i&&(0,s.jsx)(p.$n,{icon:"cookie",variant:"secondary",onClick:()=>O(!0),children:"Cookie Auth"}),(0,s.jsx)(p.$n,{icon:"add",onClick:()=>ex?P(!0):R(!0),children:"iflow"===i?"OAuth":"Add Connection"})]})]}):(0,s.jsxs)(s.Fragment,{children:[eq,!eg&&(0,s.jsxs)("div",{className:"flex gap-2 mt-4",children:["iflow"===i&&(0,s.jsx)(p.$n,{size:"sm",icon:"cookie",variant:"secondary",onClick:()=>O(!0),title:"Add connection using browser cookie",children:"Cookie"}),(0,s.jsx)(p.$n,{size:"sm",icon:"add",onClick:()=>ex?P(!0):R(!0),children:"Add"})]})]})]}),(0,s.jsxs)(p.Zp,{children:[(0,s.jsx)("div",{className:"flex items-center justify-between mb-4",children:(0,s.jsx)("h2",{className:"text-lg font-semibold",children:em.passthroughModels?"Model Aliases":"Available Models"})}),!!Z&&(0,s.jsx)("p",{className:"text-xs text-red-500 mb-3 break-words",children:Z}),(()=>{if(eg)return(0,s.jsx)(v,{providerStorageAlias:ev,providerDisplayAlias:eb,modelAliases:z,copied:ec,onCopy:ep,onSetAlias:ew,onDeleteAlias:eS,connections:r,isAnthropic:ef});if(em.passthroughModels)return(0,s.jsx)(f,{providerAlias:eh,modelAliases:z,copied:ec,onCopy:ep,onSetAlias:ew,onDeleteAlias:eS});let e=Object.entries(z).filter(([e,t])=>{let i=`${ev}/`;if(!t.startsWith(i))return!1;let s=t.slice(i.length);return!eu.some(e=>e.id===s)&&e===s}).map(([e,t])=>({id:t.slice(`${ev}/`.length),alias:e,fullModel:t}));return(0,s.jsxs)("div",{className:"flex flex-wrap gap-3",children:[eu.map(e=>{let t=`${ev}/${e.id}`,a=`${i}/${e.id}`,l=Object.entries(z).find(([,e])=>e===t||e===a)?.[0];return(0,s.jsx)(y,{model:e,fullModel:`${eb}/${e.id}`,alias:l,copied:ec,onCopy:ep,onSetAlias:t=>ew(e.id,t,ev),onDeleteAlias:()=>eS(l),testStatus:V[e.id],onTest:r.length>0?()=>ez(e.id):void 0,isTesting:Q===e.id},e.id)}),e.map(e=>(0,s.jsx)(y,{model:{id:e.id},fullModel:`${eb}/${e.id}`,alias:e.alias,copied:ec,onCopy:ep,onSetAlias:()=>{},onDeleteAlias:()=>eS(e.alias),testStatus:V[e.id],onTest:r.length>0?()=>ez(e.id):void 0,isTesting:Q===e.id,isCustom:!0},e.id)),(0,s.jsxs)("button",{onClick:()=>Y(!0),className:"flex items-center gap-1.5 px-3 py-2 rounded-lg border border-dashed border-black/15 dark:border-white/15 text-xs text-text-muted hover:text-primary hover:border-primary/40 transition-colors",children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-sm",children:"add"}),"Add Model"]})]})})()]}),eL,"kiro"===i?(0,s.jsx)(p.Mh,{isOpen:$,providerInfo:em,onSuccess:e$,onClose:()=>P(!1)}):"cursor"===i?(0,s.jsx)(p.G9,{isOpen:$,onSuccess:e$,onClose:()=>P(!1)}):(0,s.jsx)(p.LF,{isOpen:$,provider:i,providerInfo:em,onSuccess:e$,onClose:()=>P(!1)}),"iflow"===i&&(0,s.jsx)(p.vE,{isOpen:T,onSuccess:()=>{eN(),O(!1)},onClose:()=>O(!1)}),(0,s.jsx)(N,{isOpen:E,provider:i,providerName:em.name,isCompatible:eg,isAnthropic:ef,proxyPools:S,onSave:eP,onClose:()=>R(!1)}),(0,s.jsx)(k,{isOpen:I,connection:M,proxyPools:S,onSave:eT,onClose:()=>_(!1)}),eg&&(0,s.jsx)(C,{isOpen:D,node:g,onSave:ek,onClose:()=>q(!1),isAnthropic:ef}),!eg&&!em?.passthroughModels&&(0,s.jsx)(w,{isOpen:X,providerAlias:ev,providerDisplayAlias:eb,onSave:async e=>{await ew(e,e,ev),Y(!1)},onClose:()=>Y(!1)})]}):(0,s.jsxs)("div",{className:"text-center py-20",children:[(0,s.jsx)("p",{className:"text-text-muted",children:"Provider not found"}),(0,s.jsx)(d(),{href:"/dashboard/providers",className:"text-primary mt-4 inline-block",children:"Back to Providers"})]})}function y({model:e,fullModel:t,alias:i,copied:a,onCopy:r,testStatus:l,isCustom:o,onDeleteAlias:n,onTest:d,isTesting:c}){let p="ok"===l?"#22c55e":"error"===l?"#ef4444":void 0;return(0,s.jsx)("div",{className:`group px-3 py-2 rounded-lg border ${"ok"===l?"border-green-500/40":"error"===l?"border-red-500/40":"border-border"} hover:bg-sidebar/50`,children:(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-base",style:p?{color:p}:void 0,children:"ok"===l?"check_circle":"error"===l?"cancel":"smart_toy"}),(0,s.jsx)("code",{className:"text-xs text-text-muted font-mono bg-sidebar px-1.5 py-0.5 rounded",children:t}),d&&(0,s.jsx)("button",{onClick:d,disabled:c,className:`p-0.5 hover:bg-sidebar rounded text-text-muted hover:text-primary transition-opacity ${c?"opacity-100":"opacity-0 group-hover:opacity-100"}`,title:"Test model",children:(0,s.jsx)("span",{className:"material-symbols-outlined text-sm",style:c?{animation:"spin 1s linear infinite"}:void 0,children:c?"progress_activity":"science"})}),(0,s.jsx)("button",{onClick:()=>r(t,`model-${e.id}`),className:"p-0.5 hover:bg-sidebar rounded text-text-muted hover:text-primary",title:"Copy model",children:(0,s.jsx)("span",{className:"material-symbols-outlined text-sm",children:a===`model-${e.id}`?"check":"content_copy"})}),o&&(0,s.jsx)("button",{onClick:n,className:"p-0.5 hover:bg-red-500/10 rounded text-text-muted hover:text-red-500 opacity-0 group-hover:opacity-100 transition-opacity ml-auto",title:"Remove custom model",children:(0,s.jsx)("span",{className:"material-symbols-outlined text-sm",children:"close"})})]})})}function f({providerAlias:e,modelAliases:t,copied:i,onCopy:r,onSetAlias:l,onDeleteAlias:o}){let[n,d]=(0,a.useState)(""),[c,m]=(0,a.useState)(!1),x=Object.entries(t).filter(([,t])=>t.startsWith(`${e}/`)).map(([t,i])=>({modelId:i.replace(`${e}/`,""),fullModel:i,alias:t})),u=async()=>{let e;if(!n.trim()||c)return;let i=n.trim(),s=(e=i.split("/"))[e.length-1];if(t[s])return void alert(`Alias "${s}" already exists. Please use a different model or edit existing alias.`);m(!0);try{await l(i,s),d("")}catch(e){console.log("Error adding model:",e)}finally{m(!1)}};return(0,s.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,s.jsx)("p",{className:"text-sm text-text-muted",children:"OpenRouter supports any model. Add models and create aliases for quick access."}),(0,s.jsxs)("div",{className:"flex items-end gap-2",children:[(0,s.jsxs)("div",{className:"flex-1",children:[(0,s.jsx)("label",{htmlFor:"new-model-input",className:"text-xs text-text-muted mb-1 block",children:"Model ID (from OpenRouter)"}),(0,s.jsx)("input",{id:"new-model-input",type:"text",value:n,onChange:e=>d(e.target.value),onKeyDown:e=>"Enter"===e.key&&u(),placeholder:"anthropic/claude-3-opus",className:"w-full px-3 py-2 text-sm border border-border rounded-lg bg-background focus:outline-none focus:border-primary"})]}),(0,s.jsx)(p.$n,{size:"sm",icon:"add",onClick:u,disabled:!n.trim()||c,children:c?"Adding...":"Add"})]}),x.length>0&&(0,s.jsx)("div",{className:"flex flex-col gap-3",children:x.map(({modelId:e,fullModel:t,alias:a})=>(0,s.jsx)(g,{modelId:e,fullModel:t,copied:i,onCopy:r,onDeleteAlias:()=>o(a)},t))})]})}function g({modelId:e,fullModel:t,copied:i,onCopy:a,onDeleteAlias:r,onTest:l,testStatus:o,isTesting:n}){let d="ok"===o?"#22c55e":"error"===o?"#ef4444":void 0;return(0,s.jsxs)("div",{className:`flex items-center gap-3 p-3 rounded-lg border ${"ok"===o?"border-green-500/40":"error"===o?"border-red-500/40":"border-border"} hover:bg-sidebar/50`,children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-base text-text-muted",style:d?{color:d}:void 0,children:"ok"===o?"check_circle":"error"===o?"cancel":"smart_toy"}),(0,s.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,s.jsx)("p",{className:"text-sm font-medium truncate",children:e}),(0,s.jsxs)("div",{className:"flex items-center gap-1 mt-1",children:[(0,s.jsx)("code",{className:"text-xs text-text-muted font-mono bg-sidebar px-1.5 py-0.5 rounded",children:t}),(0,s.jsx)("button",{onClick:()=>a(t,`model-${e}`),className:"p-0.5 hover:bg-sidebar rounded text-text-muted hover:text-primary",title:"Copy model",children:(0,s.jsx)("span",{className:"material-symbols-outlined text-sm",children:i===`model-${e}`?"check":"content_copy"})}),l&&(0,s.jsx)("button",{onClick:l,disabled:n,className:"p-0.5 hover:bg-sidebar rounded text-text-muted hover:text-primary transition-colors",title:"Test model",children:(0,s.jsx)("span",{className:"material-symbols-outlined text-sm",style:n?{animation:"spin 1s linear infinite"}:void 0,children:n?"progress_activity":"science"})})]})]}),(0,s.jsx)("button",{onClick:r,className:"p-1 hover:bg-red-50 rounded text-red-500",title:"Remove model",children:(0,s.jsx)("span",{className:"material-symbols-outlined text-sm",children:"delete"})})]})}function v({providerStorageAlias:e,providerDisplayAlias:t,modelAliases:i,copied:r,onCopy:l,onSetAlias:o,onDeleteAlias:n,connections:d,isAnthropic:c}){let[m,x]=(0,a.useState)(""),[u,h]=(0,a.useState)(!1),[y,f]=(0,a.useState)(!1),[b,j]=(0,a.useState)(null),[N,k]=(0,a.useState)({}),C=async t=>{if(!b){j(t);try{let i=await fetch("/api/models/test",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({model:`${e}/${t}`})}),s=await i.json();k(e=>({...e,[t]:s.ok?"ok":"error"}))}catch{k(e=>({...e,[t]:"error"}))}finally{j(null)}}},w=Object.entries(i).filter(([,t])=>t.startsWith(`${e}/`)).map(([t,i])=>({modelId:i.replace(`${e}/`,""),fullModel:i,alias:t})),S=e=>{let s,a=(s=e.split("/"))[s.length-1];if(!i[a])return a;let r=`${t}-${a}`;return i[r]?null:r},A=async()=>{if(!m.trim()||u)return;let t=m.trim(),i=S(t);if(!i)return void alert("All suggested aliases already exist. Please choose a different model or remove conflicting aliases.");h(!0);try{await o(t,i,e),x("")}catch(e){console.log("Error adding model:",e)}finally{h(!1)}},$=async()=>{if(y)return;let t=d.find(e=>!1!==e.isActive);if(t){f(!0);try{let i=await fetch(`/api/providers/${t.id}/models`),s=await i.json();if(!i.ok)return void alert(s.error||"Failed to import models");let a=s.models||[];if(0===a.length)return void alert("No models returned from /models.");let r=0;for(let t of a){let i=t.id||t.name||t.model;if(!i)continue;let s=S(i);s&&(await o(i,s,e),r+=1)}0===r&&alert("No new models were added.")}catch(e){console.log("Error importing models:",e)}finally{f(!1)}}},P=d.some(e=>!1!==e.isActive);return(0,s.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,s.jsxs)("p",{className:"text-sm text-text-muted",children:["Add ",c?"Anthropic":"OpenAI","-compatible models manually or import them from the /models endpoint."]}),(0,s.jsxs)("div",{className:"flex items-end gap-2 flex-wrap",children:[(0,s.jsxs)("div",{className:"flex-1 min-w-[240px]",children:[(0,s.jsx)("label",{htmlFor:"new-compatible-model-input",className:"text-xs text-text-muted mb-1 block",children:"Model ID"}),(0,s.jsx)("input",{id:"new-compatible-model-input",type:"text",value:m,onChange:e=>x(e.target.value),onKeyDown:e=>"Enter"===e.key&&A(),placeholder:c?"claude-3-opus-20240229":"gpt-4o",className:"w-full px-3 py-2 text-sm border border-border rounded-lg bg-background focus:outline-none focus:border-primary"})]}),(0,s.jsx)(p.$n,{size:"sm",icon:"add",onClick:A,disabled:!m.trim()||u,children:u?"Adding...":"Add"}),(0,s.jsx)(p.$n,{size:"sm",variant:"secondary",icon:"download",onClick:$,disabled:!P||y,children:y?"Importing...":"Import from /models"})]}),!P&&(0,s.jsx)("p",{className:"text-xs text-text-muted",children:"Add a connection to enable importing models."}),w.length>0&&(0,s.jsx)("div",{className:"flex flex-col gap-3",children:w.map(({modelId:e,fullModel:i,alias:a})=>(0,s.jsx)(g,{modelId:e,fullModel:`${t}/${e}`,copied:r,onCopy:l,onDeleteAlias:()=>n(a),onTest:d.length>0?()=>C(e):void 0,testStatus:N[e],isTesting:b===e},i))})]})}function b({until:e}){let[t,i]=(0,a.useState)("");return((0,a.useEffect)(()=>{let t=()=>{let t=new Date(e).getTime()-Date.now();if(t<=0)return void i("");let s=Math.floor(t/1e3);if(s<60)i(`${s}s`);else if(s<3600)i(`${Math.floor(s/60)}m ${s%60}s`);else{let e=Math.floor(s/3600),t=Math.floor(s%3600/60);i(`${e}h ${t}m`)}};t();let s=setInterval(t,1e3);return()=>clearInterval(s)},[e]),t)?(0,s.jsxs)("span",{className:"text-xs text-orange-500 font-mono",children:["⏱ ",t]}):null}function j({connection:e,proxyPools:t,isOAuth:i,isFirst:r,isLast:l,onMoveUp:o,onMoveDown:n,onToggleActive:d,onUpdateProxy:c,onEdit:m,onDelete:x}){let[u,h]=(0,a.useState)(!1),[y,f]=(0,a.useState)(!1),g=(0,a.useRef)(null),v=new Map((t||[]).map(e=>[e.id,e])),N=e.providerSpecificData?.proxyPoolId||null,k=N?v.get(N):null,C=e.providerSpecificData?.connectionProxyEnabled===!0&&!!e.providerSpecificData?.connectionProxyUrl,w=!!N||C,S=k?`Pool: ${k.name}`:N?`Pool: ${N} (inactive/missing)`:C?`Legacy: ${e.providerSpecificData?.connectionProxyUrl}`:"",A="";if(k?.proxyUrl||e.providerSpecificData?.connectionProxyUrl){let t=k?.proxyUrl||e.providerSpecificData?.connectionProxyUrl;try{let e=new URL(t);A=`${e.protocol}//${e.hostname}${e.port?`:${e.port}`:""}`}catch{A=t}}let $=k?.noProxy||e.providerSpecificData?.connectionNoProxy||"",P="default";k?.isActive===!0?P="success":(N||C)&&(P="error"),(0,a.useEffect)(()=>{if(!u)return;let e=e=>{g.current&&!g.current.contains(e.target)&&h(!1)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[u]);let T=async e=>{f(!0);try{await c("__none__"===e?null:e)}finally{f(!1),h(!1)}},O=i?e.name||e.email||e.displayName||"OAuth Account":e.name,[E,R]=(0,a.useState)(!1),I=Object.entries(e).filter(([e])=>e.startsWith("modelLock_")).map(([,e])=>e).filter(e=>!!e).sort()[0]||null;(0,a.useEffect)(()=>{let t=()=>{R(!!Object.entries(e).filter(([e])=>e.startsWith("modelLock_")).map(([,e])=>e).filter(e=>e&&new Date(e).getTime()>Date.now()).sort()[0])};t();let i=I?setInterval(t,1e3):null;return()=>{i&&clearInterval(i)}},[I]);let _="unavailable"!==e.testStatus||E?e.testStatus:"active";return(0,s.jsxs)("div",{className:`group flex items-center justify-between p-3 rounded-lg hover:bg-black/[0.02] dark:hover:bg-white/[0.02] transition-colors ${!1===e.isActive?"opacity-60":""}`,children:[(0,s.jsxs)("div",{className:"flex items-center gap-3 flex-1 min-w-0",children:[(0,s.jsxs)("div",{className:"flex flex-col",children:[(0,s.jsx)("button",{onClick:o,disabled:r,className:`p-0.5 rounded ${r?"text-text-muted/30 cursor-not-allowed":"hover:bg-sidebar text-text-muted hover:text-primary"}`,children:(0,s.jsx)("span",{className:"material-symbols-outlined text-sm",children:"keyboard_arrow_up"})}),(0,s.jsx)("button",{onClick:n,disabled:l,className:`p-0.5 rounded ${l?"text-text-muted/30 cursor-not-allowed":"hover:bg-sidebar text-text-muted hover:text-primary"}`,children:(0,s.jsx)("span",{className:"material-symbols-outlined text-sm",children:"keyboard_arrow_down"})})]}),(0,s.jsx)("span",{className:"material-symbols-outlined text-base text-text-muted",children:i?"lock":"key"}),(0,s.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,s.jsx)("p",{className:"text-sm font-medium truncate",children:O}),(0,s.jsxs)("div",{className:"flex items-center gap-2 mt-1",children:[(0,s.jsx)(p.Ex,{variant:!1===e.isActive?"default":"active"===_||"success"===_?"success":"error"===_||"expired"===_||"unavailable"===_?"error":"default",size:"sm",dot:!0,children:!1===e.isActive?"disabled":_||"Unknown"}),w&&(0,s.jsx)(p.Ex,{variant:P,size:"sm",children:"Proxy"}),E&&!1!==e.isActive&&(0,s.jsx)(b,{until:I}),e.lastError&&!1!==e.isActive&&(0,s.jsx)("span",{className:"text-xs text-red-500 truncate max-w-[300px]",title:e.lastError,children:e.lastError}),(0,s.jsxs)("span",{className:"text-xs text-text-muted",children:["#",e.priority]}),e.globalPriority&&(0,s.jsxs)("span",{className:"text-xs text-text-muted",children:["Auto: ",e.globalPriority]})]}),w&&(0,s.jsxs)("div",{className:"mt-1 flex items-center gap-2 flex-wrap",children:[(0,s.jsx)("span",{className:"text-[11px] text-text-muted truncate max-w-[420px]",title:S,children:S}),A&&(0,s.jsx)("code",{className:"text-[10px] font-mono bg-black/5 dark:bg-white/5 px-1 py-0.5 rounded text-text-muted",children:A}),$&&(0,s.jsxs)("span",{className:"text-[11px] text-text-muted truncate max-w-[320px]",title:$,children:["no_proxy: ",$]})]})]})]}),(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsxs)("div",{className:"flex gap-1 opacity-0 group-hover:opacity-100 transition-opacity",children:[(t||[]).length>0&&(0,s.jsxs)("div",{className:"relative",ref:g,children:[(0,s.jsxs)("button",{onClick:()=>h(e=>!e),className:`flex flex-col items-center px-2 py-1 rounded hover:bg-black/5 dark:hover:bg-white/5 transition-colors ${w?"text-primary":"text-text-muted hover:text-primary"}`,disabled:y,children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:y?"progress_activity":"lan"}),(0,s.jsx)("span",{className:"text-[10px] leading-tight",children:"Proxy"})]}),u&&(0,s.jsxs)("div",{className:"absolute right-0 top-full mt-1 z-50 bg-bg border border-border rounded-lg shadow-lg py-1 min-w-[160px]",children:[(0,s.jsx)("button",{onClick:()=>T("__none__"),className:`w-full text-left px-3 py-1.5 text-sm hover:bg-black/5 dark:hover:bg-white/5 ${!N?"text-primary font-medium":"text-text-main"}`,children:"None"}),(t||[]).map(e=>(0,s.jsx)("button",{onClick:()=>T(e.id),className:`w-full text-left px-3 py-1.5 text-sm hover:bg-black/5 dark:hover:bg-white/5 ${N===e.id?"text-primary font-medium":"text-text-main"}`,children:e.name},e.id))]})]}),(0,s.jsxs)("button",{onClick:m,className:"flex flex-col items-center px-2 py-1 rounded hover:bg-black/5 dark:hover:bg-white/5 text-text-muted hover:text-primary",children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:"edit"}),(0,s.jsx)("span",{className:"text-[10px] leading-tight",children:"Edit"})]}),(0,s.jsxs)("button",{onClick:x,className:"flex flex-col items-center px-2 py-1 rounded hover:bg-red-500/10 text-red-500",children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:"delete"}),(0,s.jsx)("span",{className:"text-[10px] leading-tight",children:"Delete"})]})]}),(0,s.jsx)(p.lM,{size:"sm",checked:e.isActive??!0,onChange:d,title:e.isActive??!0?"Disable connection":"Enable connection"})]})]})}function N({isOpen:e,provider:t,providerName:i,isCompatible:r,isAnthropic:l,proxyPools:o,onSave:n,onClose:d}){let c="__none__",[m,x]=(0,a.useState)({name:"",apiKey:"",priority:1,proxyPoolId:c}),[u,h]=(0,a.useState)(!1),[y,f]=(0,a.useState)(null),[g,v]=(0,a.useState)(!1),b=async()=>{h(!0);try{let e=await fetch("/api/providers/validate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:t,apiKey:m.apiKey})}),i=await e.json();f(i.valid?"success":"failed")}catch{f("failed")}finally{h(!1)}},j=async()=>{if(t&&m.apiKey){v(!0);try{let e=!1;try{h(!0),f(null);let i=await fetch("/api/providers/validate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:t,apiKey:m.apiKey})});e=!!(await i.json()).valid,f(e?"success":"failed")}catch{f("failed")}finally{h(!1)}await n({name:m.name,apiKey:m.apiKey,priority:m.priority,proxyPoolId:m.proxyPoolId===c?null:m.proxyPoolId,testStatus:e?"active":"unknown",providerSpecificData:void 0})}finally{v(!1)}}};return t?(0,s.jsx)(p.aF,{isOpen:e,title:`Add ${i||t} API Key`,onClose:d,children:(0,s.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,s.jsx)(p.pd,{label:"Name",value:m.name,onChange:e=>x({...m,name:e.target.value}),placeholder:"Production Key"}),(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsx)(p.pd,{label:"API Key",type:"password",value:m.apiKey,onChange:e=>x({...m,apiKey:e.target.value}),className:"flex-1"}),(0,s.jsx)("div",{className:"pt-6",children:(0,s.jsx)(p.$n,{onClick:b,disabled:!m.apiKey||u||g,variant:"secondary",children:u?"Checking...":"Check"})})]}),y&&(0,s.jsx)(p.Ex,{variant:"success"===y?"success":"error",children:"success"===y?"Valid":"Invalid"}),r&&(0,s.jsx)("p",{className:"text-xs text-text-muted",children:l?`Validation checks ${i||"Anthropic Compatible"} by verifying the API key.`:`Validation checks ${i||"OpenAI Compatible"} via /models on your base URL.`}),(0,s.jsx)(p.pd,{label:"Priority",type:"number",value:m.priority,onChange:e=>x({...m,priority:Number.parseInt(e.target.value)||1})}),(0,s.jsx)(p.l6,{label:"Proxy Pool",value:m.proxyPoolId,onChange:e=>x({...m,proxyPoolId:e.target.value}),options:[{value:c,label:"None"},...(o||[]).map(e=>({value:e.id,label:e.name}))],placeholder:"None"}),0===(o||[]).length&&(0,s.jsx)("p",{className:"text-xs text-text-muted",children:"No active proxy pools available. Create one in Proxy Pools page first."}),(0,s.jsx)("p",{className:"text-xs text-text-muted",children:"Legacy manual proxy fields are still accepted by API for backward compatibility."}),(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsx)(p.$n,{onClick:j,fullWidth:!0,disabled:!m.name||!m.apiKey||g,children:g?"Saving...":"Save"}),(0,s.jsx)(p.$n,{onClick:d,variant:"ghost",fullWidth:!0,children:"Cancel"})]})]})}):null}function k({isOpen:e,connection:t,proxyPools:i,onSave:r,onClose:l}){let[o,n]=(0,a.useState)({name:"",priority:1,apiKey:""}),[d,c]=(0,a.useState)(!1),[x,u]=(0,a.useState)(null),[h,y]=(0,a.useState)(!1),[f,g]=(0,a.useState)(null),[v,b]=(0,a.useState)(!1);(0,a.useEffect)(()=>{t&&(n({name:t.name||"",priority:t.priority||1,apiKey:""}),u(null),g(null))},[t]);let j=async()=>{if(t?.provider){c(!0),u(null);try{let e=await fetch(`/api/providers/${t.id}/test`,{method:"POST"}),i=await e.json();u(i.valid?"success":"failed")}catch{u("failed")}finally{c(!1)}}},N=async()=>{if(t?.provider&&o.apiKey){y(!0),g(null);try{let e=await fetch("/api/providers/validate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:t.provider,apiKey:o.apiKey})}),i=await e.json();g(i.valid?"success":"failed")}catch{g("failed")}finally{y(!1)}}},C=async()=>{b(!0);try{let e={name:o.name,priority:o.priority};if(!w&&o.apiKey){e.apiKey=o.apiKey;let i="success"===f;if(!i)try{y(!0),g(null);let e=await fetch("/api/providers/validate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:t.provider,apiKey:o.apiKey})});i=!!(await e.json()).valid,g(i?"success":"failed")}catch{g("failed")}finally{y(!1)}i&&(e.testStatus="active",e.lastError=null,e.lastErrorAt=null)}await r(e)}finally{b(!1)}};if(!t)return null;let w="oauth"===t.authType,S=(0,m.mq)(t.provider)||(0,m.gb)(t.provider);return(0,s.jsx)(p.aF,{isOpen:e,title:"Edit Connection",onClose:l,children:(0,s.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,s.jsx)(p.pd,{label:"Name",value:o.name,onChange:e=>n({...o,name:e.target.value}),placeholder:w?"Account name":"Production Key"}),w&&t.email&&(0,s.jsxs)("div",{className:"bg-sidebar/50 p-3 rounded-lg",children:[(0,s.jsx)("p",{className:"text-sm text-text-muted mb-1",children:"Email"}),(0,s.jsx)("p",{className:"font-medium",children:t.email})]}),(0,s.jsx)(p.pd,{label:"Priority",type:"number",value:o.priority,onChange:e=>n({...o,priority:Number.parseInt(e.target.value)||1})}),!w&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsx)(p.pd,{label:"API Key",type:"password",value:o.apiKey,onChange:e=>n({...o,apiKey:e.target.value}),placeholder:"Enter new API key",hint:"Leave blank to keep the current API key.",className:"flex-1"}),(0,s.jsx)("div",{className:"pt-6",children:(0,s.jsx)(p.$n,{onClick:N,disabled:!o.apiKey||h||v,variant:"secondary",children:h?"Checking...":"Check"})})]}),f&&(0,s.jsx)(p.Ex,{variant:"success"===f?"success":"error",children:"success"===f?"Valid":"Invalid"})]}),!S&&(0,s.jsxs)("div",{className:"flex items-center gap-3",children:[(0,s.jsx)(p.$n,{onClick:j,variant:"secondary",disabled:d,children:d?"Testing...":"Test Connection"}),x&&(0,s.jsx)(p.Ex,{variant:"success"===x?"success":"error",children:"success"===x?"Valid":"Failed"})]}),(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsx)(p.$n,{onClick:C,fullWidth:!0,disabled:v,children:v?"Saving...":"Save"}),(0,s.jsx)(p.$n,{onClick:l,variant:"ghost",fullWidth:!0,children:"Cancel"})]})]})})}function C({isOpen:e,node:t,onSave:i,onClose:r,isAnthropic:l}){let[o,n]=(0,a.useState)({name:"",prefix:"",apiType:"chat",baseUrl:"https://api.openai.com/v1"}),[d,c]=(0,a.useState)(!1),[m,x]=(0,a.useState)(""),[u,h]=(0,a.useState)(""),[y,f]=(0,a.useState)(!1),[g,v]=(0,a.useState)(null);(0,a.useEffect)(()=>{t&&n({name:t.name||"",prefix:t.prefix||"",apiType:t.apiType||"chat",baseUrl:t.baseUrl||(l?"https://api.anthropic.com/v1":"https://api.openai.com/v1")})},[t,l]);let b=async()=>{if(o.name.trim()&&o.prefix.trim()&&o.baseUrl.trim()){c(!0);try{let e={name:o.name,prefix:o.prefix,baseUrl:o.baseUrl};l||(e.apiType=o.apiType),await i(e)}finally{c(!1)}}},j=async()=>{f(!0);try{let e=await fetch("/api/provider-nodes/validate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({baseUrl:o.baseUrl,apiKey:m,type:l?"anthropic-compatible":"openai-compatible",modelId:u.trim()||void 0})}),t=await e.json();v(t.valid?"success":"failed")}catch{v("failed")}finally{f(!1)}};return t?(0,s.jsx)(p.aF,{isOpen:e,title:`Edit ${l?"Anthropic":"OpenAI"} Compatible`,onClose:r,children:(0,s.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,s.jsx)(p.pd,{label:"Name",value:o.name,onChange:e=>n({...o,name:e.target.value}),placeholder:`${l?"Anthropic":"OpenAI"} Compatible (Prod)`,hint:"Required. A friendly label for this node."}),(0,s.jsx)(p.pd,{label:"Prefix",value:o.prefix,onChange:e=>n({...o,prefix:e.target.value}),placeholder:l?"ac-prod":"oc-prod",hint:"Required. Used as the provider prefix for model IDs."}),!l&&(0,s.jsx)(p.l6,{label:"API Type",options:[{value:"chat",label:"Chat Completions"},{value:"responses",label:"Responses API"}],value:o.apiType,onChange:e=>n({...o,apiType:e.target.value})}),(0,s.jsx)(p.pd,{label:"Base URL",value:o.baseUrl,onChange:e=>n({...o,baseUrl:e.target.value}),placeholder:l?"https://api.anthropic.com/v1":"https://api.openai.com/v1",hint:`Use the base URL (ending in /v1) for your ${l?"Anthropic":"OpenAI"}-compatible API.`}),(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsx)(p.pd,{label:"API Key (for Check)",type:"password",value:m,onChange:e=>x(e.target.value),className:"flex-1"}),(0,s.jsx)("div",{className:"pt-6",children:(0,s.jsx)(p.$n,{onClick:j,disabled:!m||y||!o.baseUrl.trim(),variant:"secondary",children:y?"Checking...":"Check"})})]}),(0,s.jsx)(p.pd,{label:"Model ID (optional)",value:u,onChange:e=>h(e.target.value),placeholder:"e.g. my-model-id",hint:"If provider lacks /models endpoint, enter a model ID to validate via chat/completions instead."}),g&&(0,s.jsx)(p.Ex,{variant:"success"===g?"success":"error",children:"success"===g?"Valid":"Invalid"}),(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsx)(p.$n,{onClick:b,fullWidth:!0,disabled:!o.name.trim()||!o.prefix.trim()||!o.baseUrl.trim()||d,children:d?"Saving...":"Save"}),(0,s.jsx)(p.$n,{onClick:r,variant:"ghost",fullWidth:!0,children:"Cancel"})]})]})}):null}function w({isOpen:e,providerAlias:t,providerDisplayAlias:i,onSave:r,onClose:l}){let[o,n]=(0,a.useState)(""),[d,c]=(0,a.useState)(null),[m,x]=(0,a.useState)(""),[u,h]=(0,a.useState)(!1);(0,a.useEffect)(()=>{e&&(n(""),c(null),x(""))},[e]);let y=async()=>{if(o.trim()){c("testing"),x("");try{let e=await fetch("/api/models/test",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({model:`${t}/${o.trim()}`})}),i=await e.json();c(i.ok?"ok":"error"),x(i.error||"")}catch(e){c("error"),x(e.message)}}},f=async()=>{if(o.trim()&&!u){h(!0);try{await r(o.trim())}finally{h(!1)}}};return(0,s.jsx)(p.aF,{isOpen:e,onClose:l,title:"Add Custom Model",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 mb-1.5 block",children:"Model ID"}),(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsx)("input",{type:"text",value:o,onChange:e=>{n(e.target.value),c(null),x("")},onKeyDown:e=>{"Enter"===e.key&&y()},placeholder:"e.g. claude-opus-4-5",className:"flex-1 px-3 py-2 text-sm border border-border rounded-lg bg-background focus:outline-none focus:border-primary",autoFocus:!0}),(0,s.jsx)(p.$n,{variant:"secondary",icon:"science",loading:"testing"===d,onClick:y,disabled:!o.trim()||"testing"===d,children:"testing"===d?"Testing...":"Test"})]}),(0,s.jsxs)("p",{className:"text-xs text-text-muted mt-1",children:["Sent to provider as: ",(0,s.jsx)("code",{className:"font-mono bg-sidebar px-1 rounded",children:o.trim()||"model-id"})]})]}),"ok"===d&&(0,s.jsxs)("div",{className:"flex items-center gap-2 text-sm text-green-600",children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-base",children:"check_circle"}),"Model is reachable"]}),"error"===d&&(0,s.jsxs)("div",{className:"flex items-start gap-2 text-sm text-red-500",children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-base shrink-0",children:"cancel"}),(0,s.jsx)("span",{children:m||"Model not reachable"})]}),(0,s.jsxs)("div",{className:"flex gap-2 pt-1",children:[(0,s.jsx)(p.$n,{onClick:l,variant:"ghost",fullWidth:!0,size:"sm",children:"Cancel"}),(0,s.jsx)(p.$n,{onClick:f,fullWidth:!0,size:"sm",disabled:!o.trim()||u,children:u?"Adding...":"Add Model"})]})]})})}y.propTypes={model:l().shape({id:l().string.isRequired}).isRequired,fullModel:l().string.isRequired,alias:l().string,copied:l().string,onCopy:l().func.isRequired,testStatus:l().oneOf(["ok","error"]),isCustom:l().bool,onDeleteAlias:l().func,onTest:l().func,isTesting:l().bool},f.propTypes={providerAlias:l().string.isRequired,modelAliases:l().object.isRequired,copied:l().string,onCopy:l().func.isRequired,onSetAlias:l().func.isRequired,onDeleteAlias:l().func.isRequired},g.propTypes={modelId:l().string.isRequired,fullModel:l().string.isRequired,copied:l().string,onCopy:l().func.isRequired,onDeleteAlias:l().func.isRequired,onTest:l().func,testStatus:l().oneOf(["ok","error"]),isTesting:l().bool},v.propTypes={providerStorageAlias:l().string.isRequired,providerDisplayAlias:l().string.isRequired,modelAliases:l().object.isRequired,copied:l().string,onCopy:l().func.isRequired,onSetAlias:l().func.isRequired,onDeleteAlias:l().func.isRequired,connections:l().arrayOf(l().shape({id:l().string,isActive:l().bool})).isRequired,isAnthropic:l().bool},b.propTypes={until:l().string.isRequired},j.propTypes={connection:l().shape({id:l().string,name:l().string,email:l().string,displayName:l().string,modelLockUntil:l().string,testStatus:l().string,isActive:l().bool,lastError:l().string,priority:l().number,globalPriority:l().number}).isRequired,proxyPools:l().arrayOf(l().shape({id:l().string,name:l().string,proxyUrl:l().string,noProxy:l().string,isActive:l().bool})),isOAuth:l().bool.isRequired,isFirst:l().bool.isRequired,isLast:l().bool.isRequired,onMoveUp:l().func.isRequired,onMoveDown:l().func.isRequired,onToggleActive:l().func.isRequired,onUpdateProxy:l().func,onEdit:l().func.isRequired,onDelete:l().func.isRequired},N.propTypes={isOpen:l().bool.isRequired,provider:l().string,providerName:l().string,isCompatible:l().bool,isAnthropic:l().bool,proxyPools:l().arrayOf(l().shape({id:l().string,name:l().string})),onSave:l().func.isRequired,onClose:l().func.isRequired},k.propTypes={isOpen:l().bool.isRequired,connection:l().shape({id:l().string,name:l().string,email:l().string,priority:l().number,authType:l().string,provider:l().string,providerSpecificData:l().object}),proxyPools:l().arrayOf(l().shape({id:l().string,name:l().string})),onSave:l().func.isRequired,onClose:l().func.isRequired},C.propTypes={isOpen:l().bool.isRequired,node:l().shape({id:l().string,name:l().string,prefix:l().string,apiType:l().string,baseUrl:l().string}),onSave:l().func.isRequired,onClose:l().func.isRequired,isAnthropic:l().bool},w.propTypes={isOpen:l().bool.isRequired,providerAlias:l().string.isRequired,providerDisplayAlias:l().string.isRequired,onSave:l().func.isRequired,onClose:l().func.isRequired}}},e=>{e.O(0,[2574,3862,5772,123,2652,5497,8441,3794,7358],()=>e(e.s=16113)),_N_E=e.O()}]);
1
+ (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[2134],{16113:(e,t,i)=>{Promise.resolve().then(i.bind(i,97162))},97162:(e,t,i)=>{"use strict";i.r(t),i.d(t,{default:()=>h});var s=i(95155),a=i(12115),r=i(14051),l=i.n(r),o=i(73321),n=i(98500),d=i.n(n),c=i(5772),p=i(35497),m=i(52679),x=i(28777),u=i(11059);function h(){let e=(0,o.useParams)(),t=(0,o.useRouter)(),i=e.id,[r,l]=(0,a.useState)([]),[n,h]=(0,a.useState)(!0),[g,b]=(0,a.useState)(null),[S,A]=(0,a.useState)([]),[$,P]=(0,a.useState)(!1),[T,O]=(0,a.useState)(!1),[E,R]=(0,a.useState)(!1),[I,_]=(0,a.useState)(!1),[D,q]=(0,a.useState)(!1),[U,K]=(0,a.useState)(!1),[M,L]=(0,a.useState)(null),[z,J]=(0,a.useState)({}),[F,W]=(0,a.useState)(!1),[V,B]=(0,a.useState)({}),[Z,G]=(0,a.useState)(""),[Q,H]=(0,a.useState)(null),[X,Y]=(0,a.useState)(!1),[ee,et]=(0,a.useState)([]),[ei,es]=(0,a.useState)("__none__"),[ea,er]=(0,a.useState)(!1),[el,eo]=(0,a.useState)(null),[en,ed]=(0,a.useState)(""),{copied:ec,copy:ep}=(0,u.C)(),em=g?{id:g.id,name:g.name||("anthropic-compatible"===g.type?"Anthropic Compatible":"OpenAI Compatible"),color:"anthropic-compatible"===g.type?"#D97757":"#10A37F",textIcon:"anthropic-compatible"===g.type?"AC":"OC",apiType:g.apiType,baseUrl:g.baseUrl,type:g.type}:m.zN[i]||m.fg[i]||m.IS[i],ex=!!m.zN[i]||!!m.IS[i],eu=(0,x.KC)(i),eh=(0,m.wG)(i),ey=(0,m.mq)(i),ef=(0,m.gb)(i),eg=ey||ef,ev=eg?i:eh,eb=eg?g?.prefix||i:eh,ej=(0,a.useCallback)(async()=>{try{let e=await fetch("/api/models/alias"),t=await e.json();e.ok&&J(t.aliases||{})}catch(e){console.log("Error fetching aliases:",e)}},[]),eN=(0,a.useCallback)(async()=>{try{let[e,t,s,a]=await Promise.all([fetch("/api/providers",{cache:"no-store"}),fetch("/api/provider-nodes",{cache:"no-store"}),fetch("/api/proxy-pools?isActive=true",{cache:"no-store"}),fetch("/api/settings",{cache:"no-store"})]),r=await e.json(),o=await t.json(),n=await s.json(),d=a.ok?await a.json():{};if(e.ok){let e=(r.connections||[]).filter(e=>e.provider===i);l(e)}s.ok&&A(n.proxyPools||[]);let c=(d.providerStrategies||{})[i]||{};if(eo(c.fallbackStrategy||null),ed(null!=c.stickyRoundRobinLimit?String(c.stickyRoundRobinLimit):"1"),t.ok){let e=(o.nodes||[]).find(e=>e.id===i)||null;if(!e&&eg)for(let t=0;t<3;t+=1){await new Promise(e=>setTimeout(e,150));let t=await fetch("/api/provider-nodes",{cache:"no-store"});if(t.ok&&(e=((await t.json()).nodes||[]).find(e=>e.id===i)||null))break}b(e)}}catch(e){console.log("Error fetching connections:",e)}finally{h(!1)}},[i,eg]),ek=async e=>{try{let t=await fetch(`/api/provider-nodes/${i}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}),s=await t.json();t.ok&&(b(s.node),await eN(),q(!1))}catch(e){console.log("Error updating provider node:",e)}},eC=async(e,t)=>{try{let s=await fetch("/api/settings",{cache:"no-store"}),a=(s.ok?await s.json():{}).providerStrategies||{},r={};e&&(r.fallbackStrategy=e),"round-robin"===e&&""!==t&&(r.stickyRoundRobinLimit=Number(t)||3);let l={...a};0===Object.keys(r).length?delete l[i]:l[i]=r,await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({providerStrategies:l})})}catch(e){console.log("Error saving provider strategy:",e)}};(0,a.useEffect)(()=>{eN(),ej()},[eN,ej]);let ew=async(e,t,i=eh)=>{let s=`${i}/${e}`;try{let e=await fetch("/api/models/alias",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({model:s,alias:t})});if(e.ok)await ej();else{let t=await e.json();alert(t.error||"Failed to set alias")}}catch(e){console.log("Error setting alias:",e)}},eS=async e=>{try{(await fetch(`/api/models/alias?alias=${encodeURIComponent(e)}`,{method:"DELETE"})).ok&&await ej()}catch(e){console.log("Error deleting alias:",e)}},eA=async e=>{if(confirm("Delete this connection?"))try{(await fetch(`/api/providers/${e}`,{method:"DELETE"})).ok&&l(r.filter(t=>t.id!==e))}catch(e){console.log("Error deleting connection:",e)}},e$=()=>{eN(),P(!1)},eP=async e=>{try{(await fetch("/api/providers",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:i,...e})})).ok&&(await eN(),R(!1))}catch(e){console.log("Error saving connection:",e)}},eT=async e=>{try{(await fetch(`/api/providers/${M.id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})).ok&&(await eN(),_(!1))}catch(e){console.log("Error updating connection:",e)}},eO=async(e,t)=>{try{(await fetch(`/api/providers/${e}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({isActive:t})})).ok&&l(i=>i.map(i=>i.id===e?{...i,isActive:t}:i))}catch(e){console.log("Error updating connection status:",e)}},eE=async(e,t)=>{let i=[...r];[i[e],i[t]]=[i[t],i[e]],l(i);try{await Promise.all([fetch(`/api/providers/${i[e].id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({priority:e})}),fetch(`/api/providers/${i[t].id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({priority:t})})])}catch(e){console.log("Error swapping priority:",e),await eN()}},eR=r.filter(e=>ee.includes(e.id));r.length>0&&(ee.length,r.length),(0,a.useEffect)(()=>{et(e=>e.filter(e=>r.some(t=>t.id===e)))},[r]);let eI=(()=>{if(0===eR.length)return"";let e=new Set(eR.map(e=>e.providerSpecificData?.proxyPoolId||"__none__"));if(1===e.size){let t=[...e][0];if("__none__"===t)return"All selected currently unbound";let i=S.find(e=>e.id===t);return`All selected currently bound to ${i?.name||t}`}return"Selected connections have mixed proxy bindings"})(),e_=()=>{ea||K(!1)},eD=async()=>{if(0===ee.length)return;let e="__none__"===ei?null:ei;er(!0);try{let t=[];for(let i of ee)try{let s=await fetch(`/api/providers/${i}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({proxyPoolId:e})});t.push(s.ok)}catch(e){console.log("Error applying bulk proxy pool for",i,e),t.push(!1)}let i=t.filter(e=>!e).length;i>0&&alert(`Updated with ${i} failed request(s).`),await eN(),et([]),es("__none__"),K(!1)}catch(e){console.log("Error applying bulk proxy pool:",e)}finally{er(!1)}},eq=(0,s.jsx)("div",{className:"flex flex-col divide-y divide-black/[0.03] dark:divide-white/[0.03]",children:r.map((e,t)=>(0,s.jsx)("div",{className:"flex items-stretch",children:(0,s.jsx)("div",{className:"flex-1 min-w-0",children:(0,s.jsx)(j,{connection:e,proxyPools:S,isOAuth:ex,isFirst:0===t,isLast:t===r.length-1,onMoveUp:()=>eE(t,t-1),onMoveDown:()=>eE(t,t+1),onToggleActive:t=>eO(e.id,t),onUpdateProxy:async t=>{try{(await fetch(`/api/providers/${e.id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({proxyPoolId:t||null})})).ok&&l(i=>i.map(i=>i.id===e.id?{...i,providerSpecificData:{...i.providerSpecificData,proxyPoolId:t||null}}:i))}catch(e){console.log("Error updating proxy:",e)}},onEdit:()=>{L(e),_(!0)},onDelete:()=>eA(e.id)})})},e.id))}),eU=[{value:"__none__",label:"None"},...S.map(e=>({value:e.id,label:e.name}))],eK=0===ee.length?"Select one or more connections, then click Proxy Action.":eI,eM=ee.length>0&&!ea,eL=(0,s.jsx)(p.aF,{isOpen:U,onClose:e_,title:`Proxy Action (${ee.length} selected)`,children:(0,s.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,s.jsx)(p.l6,{label:"Proxy Pool",value:ei,onChange:e=>es(e.target.value),options:eU,placeholder:"None"}),(0,s.jsx)("p",{className:"text-xs text-text-muted",children:eK}),(0,s.jsx)("p",{className:"text-xs text-text-muted",children:"Selecting None will unbind selected connections from proxy pool."}),(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsx)(p.$n,{onClick:eD,fullWidth:!0,disabled:!eM,children:ea?"Applying...":"Apply"}),(0,s.jsx)(p.$n,{onClick:e_,variant:"ghost",fullWidth:!0,disabled:ea,children:"Cancel"})]})]})}),ez=async e=>{if(!Q){H(e);try{let t=await fetch("/api/models/test",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({model:`${ev}/${e}`})}),i=await t.json();B(t=>({...t,[e]:i.ok?"ok":"error"})),G(i.ok?"":i.error||"Model not reachable")}catch{B(t=>({...t,[e]:"error"})),G("Network error")}finally{H(null)}}};return n?(0,s.jsxs)("div",{className:"flex flex-col gap-8",children:[(0,s.jsx)(p.Qv,{}),(0,s.jsx)(p.Qv,{})]}):em?(0,s.jsxs)("div",{className:"flex flex-col gap-8",children:[(0,s.jsxs)("div",{children:[(0,s.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,s.jsx)("span",{className:"material-symbols-outlined text-lg",children:"arrow_back"}),"Back to Providers"]}),(0,s.jsxs)("div",{className:"flex items-center gap-4",children:[(0,s.jsx)("div",{className:"rounded-lg flex items-center justify-center",style:{backgroundColor:`${em.color}15`},children:F?(0,s.jsx)("span",{className:"text-sm font-bold",style:{color:em.color},children:em.textIcon||em.id.slice(0,2).toUpperCase()}):(0,s.jsx)(c.default,{src:ey&&em.apiType?"responses"===em.apiType?"/providers/oai-r.png":"/providers/oai-cc.png":ef?"/providers/anthropic-m.png":`/providers/${em.id}.png`,alt:em.name,width:48,height:48,className:"object-contain rounded-lg max-w-[48px] max-h-[48px]",sizes:"48px",onError:()=>W(!0)})}),(0,s.jsxs)("div",{children:[(0,s.jsx)("h1",{className:"text-3xl font-semibold tracking-tight",children:em.name}),(0,s.jsxs)("p",{className:"text-text-muted",children:[r.length," connection",1===r.length?"":"s"]})]})]})]}),eg&&g&&(0,s.jsxs)(p.Zp,{children:[(0,s.jsxs)("div",{className:"flex items-center justify-between mb-4",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("h2",{className:"text-lg font-semibold",children:ef?"Anthropic Compatible Details":"OpenAI Compatible Details"}),(0,s.jsxs)("p",{className:"text-sm text-text-muted",children:[ef?"Messages API":"responses"===g.apiType?"Responses API":"Chat Completions"," \xb7 ",(g.baseUrl||"").replace(/\/$/,""),"/",ef?"messages":"responses"===g.apiType?"responses":"chat/completions"]})]}),(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)(p.$n,{size:"sm",icon:"add",onClick:()=>R(!0),disabled:r.length>0,children:"Add"}),(0,s.jsx)(p.$n,{size:"sm",variant:"secondary",icon:"edit",onClick:()=>q(!0),children:"Edit"}),(0,s.jsx)(p.$n,{size:"sm",variant:"secondary",icon:"delete",onClick:async()=>{if(confirm(`Delete this ${ef?"Anthropic":"OpenAI"} Compatible node?`))try{(await fetch(`/api/provider-nodes/${i}`,{method:"DELETE"})).ok&&t.push("/dashboard/providers")}catch(e){console.log("Error deleting provider node:",e)}},children:"Delete"})]})]}),r.length>0&&(0,s.jsx)("p",{className:"text-sm text-text-muted",children:"Only one connection is allowed per compatible node. Add another node if you need more connections."})]}),(0,s.jsxs)(p.Zp,{children:[(0,s.jsxs)("div",{className:"flex items-center justify-between mb-4",children:[(0,s.jsx)("h2",{className:"text-lg font-semibold",children:"Connections"}),(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)("span",{className:"text-xs text-text-muted font-medium",children:"Round Robin"}),(0,s.jsx)(p.lM,{checked:"round-robin"===el,onChange:e=>{let t=e?"round-robin":null,i=e?en||"1":en;e&&!en&&ed("1"),eo(t),eC(t,i)}}),"round-robin"===el&&(0,s.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,s.jsx)("span",{className:"text-xs text-text-muted",children:"Sticky:"}),(0,s.jsx)("input",{type:"number",min:1,value:en,onChange:e=>{var t;ed(t=e.target.value),eC("round-robin",t)},placeholder:"1",className:"w-14 px-2 py-1 text-xs border border-border rounded-md bg-background focus:outline-none focus:border-primary"})]})]})]}),0===r.length?(0,s.jsxs)("div",{className:"text-center py-12",children:[(0,s.jsx)("div",{className:"inline-flex items-center justify-center w-16 h-16 rounded-full bg-primary/10 text-primary mb-4",children:(0,s.jsx)("span",{className:"material-symbols-outlined text-[32px]",children:ex?"lock":"key"})}),(0,s.jsx)("p",{className:"text-text-main font-medium mb-1",children:"No connections yet"}),(0,s.jsx)("p",{className:"text-sm text-text-muted mb-4",children:"Add your first connection to get started"}),!eg&&(0,s.jsxs)("div",{className:"flex gap-2 justify-center",children:["iflow"===i&&(0,s.jsx)(p.$n,{icon:"cookie",variant:"secondary",onClick:()=>O(!0),children:"Cookie Auth"}),(0,s.jsx)(p.$n,{icon:"add",onClick:()=>ex?P(!0):R(!0),children:"iflow"===i?"OAuth":"Add Connection"})]})]}):(0,s.jsxs)(s.Fragment,{children:[eq,!eg&&(0,s.jsxs)("div",{className:"flex gap-2 mt-4",children:["iflow"===i&&(0,s.jsx)(p.$n,{size:"sm",icon:"cookie",variant:"secondary",onClick:()=>O(!0),title:"Add connection using browser cookie",children:"Cookie"}),(0,s.jsx)(p.$n,{size:"sm",icon:"add",onClick:()=>ex?P(!0):R(!0),children:"Add"})]})]})]}),(0,s.jsxs)(p.Zp,{children:[(0,s.jsx)("div",{className:"flex items-center justify-between mb-4",children:(0,s.jsx)("h2",{className:"text-lg font-semibold",children:em.passthroughModels?"Model Aliases":"Available Models"})}),!!Z&&(0,s.jsx)("p",{className:"text-xs text-red-500 mb-3 break-words",children:Z}),(()=>{if(eg)return(0,s.jsx)(v,{providerStorageAlias:ev,providerDisplayAlias:eb,modelAliases:z,copied:ec,onCopy:ep,onSetAlias:ew,onDeleteAlias:eS,connections:r,isAnthropic:ef});if(em.passthroughModels)return(0,s.jsx)(f,{providerAlias:eh,modelAliases:z,copied:ec,onCopy:ep,onSetAlias:ew,onDeleteAlias:eS});let e=Object.entries(z).filter(([e,t])=>{let i=`${ev}/`;if(!t.startsWith(i))return!1;let s=t.slice(i.length);return!eu.some(e=>e.id===s)&&e===s}).map(([e,t])=>({id:t.slice(`${ev}/`.length),alias:e,fullModel:t}));return(0,s.jsxs)("div",{className:"flex flex-wrap gap-3",children:[eu.map(e=>{let t=`${ev}/${e.id}`,a=`${i}/${e.id}`,l=Object.entries(z).find(([,e])=>e===t||e===a)?.[0];return(0,s.jsx)(y,{model:e,fullModel:`${eb}/${e.id}`,alias:l,copied:ec,onCopy:ep,onSetAlias:t=>ew(e.id,t,ev),onDeleteAlias:()=>eS(l),testStatus:V[e.id],onTest:r.length>0?()=>ez(e.id):void 0,isTesting:Q===e.id},e.id)}),e.map(e=>(0,s.jsx)(y,{model:{id:e.id},fullModel:`${eb}/${e.id}`,alias:e.alias,copied:ec,onCopy:ep,onSetAlias:()=>{},onDeleteAlias:()=>eS(e.alias),testStatus:V[e.id],onTest:r.length>0?()=>ez(e.id):void 0,isTesting:Q===e.id,isCustom:!0},e.id)),(0,s.jsxs)("button",{onClick:()=>Y(!0),className:"flex items-center gap-1.5 px-3 py-2 rounded-lg border border-dashed border-black/15 dark:border-white/15 text-xs text-text-muted hover:text-primary hover:border-primary/40 transition-colors",children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-sm",children:"add"}),"Add Model"]})]})})()]}),eL,"kiro"===i?(0,s.jsx)(p.Mh,{isOpen:$,providerInfo:em,onSuccess:e$,onClose:()=>P(!1)}):"cursor"===i?(0,s.jsx)(p.G9,{isOpen:$,onSuccess:e$,onClose:()=>P(!1)}):(0,s.jsx)(p.LF,{isOpen:$,provider:i,providerInfo:em,onSuccess:e$,onClose:()=>P(!1)}),"iflow"===i&&(0,s.jsx)(p.vE,{isOpen:T,onSuccess:()=>{eN(),O(!1)},onClose:()=>O(!1)}),(0,s.jsx)(N,{isOpen:E,provider:i,providerName:em.name,isCompatible:eg,isAnthropic:ef,proxyPools:S,onSave:eP,onClose:()=>R(!1)}),(0,s.jsx)(k,{isOpen:I,connection:M,proxyPools:S,onSave:eT,onClose:()=>_(!1)}),eg&&(0,s.jsx)(C,{isOpen:D,node:g,onSave:ek,onClose:()=>q(!1),isAnthropic:ef}),!eg&&!em?.passthroughModels&&(0,s.jsx)(w,{isOpen:X,providerAlias:ev,providerDisplayAlias:eb,onSave:async e=>{await ew(e,e,ev),Y(!1)},onClose:()=>Y(!1)})]}):(0,s.jsxs)("div",{className:"text-center py-20",children:[(0,s.jsx)("p",{className:"text-text-muted",children:"Provider not found"}),(0,s.jsx)(d(),{href:"/dashboard/providers",className:"text-primary mt-4 inline-block",children:"Back to Providers"})]})}function y({model:e,fullModel:t,alias:i,copied:a,onCopy:r,testStatus:l,isCustom:o,onDeleteAlias:n,onTest:d,isTesting:c}){let p="ok"===l?"#22c55e":"error"===l?"#ef4444":void 0;return(0,s.jsx)("div",{className:`group px-3 py-2 rounded-lg border ${"ok"===l?"border-green-500/40":"error"===l?"border-red-500/40":"border-border"} hover:bg-sidebar/50`,children:(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-base",style:p?{color:p}:void 0,children:"ok"===l?"check_circle":"error"===l?"cancel":"smart_toy"}),(0,s.jsx)("code",{className:"text-xs text-text-muted font-mono bg-sidebar px-1.5 py-0.5 rounded",children:t}),d&&(0,s.jsx)("button",{onClick:d,disabled:c,className:`p-0.5 hover:bg-sidebar rounded text-text-muted hover:text-primary transition-opacity ${c?"opacity-100":"opacity-0 group-hover:opacity-100"}`,title:"Test model",children:(0,s.jsx)("span",{className:"material-symbols-outlined text-sm",style:c?{animation:"spin 1s linear infinite"}:void 0,children:c?"progress_activity":"science"})}),(0,s.jsx)("button",{onClick:()=>r(t,`model-${e.id}`),className:"p-0.5 hover:bg-sidebar rounded text-text-muted hover:text-primary",title:"Copy model",children:(0,s.jsx)("span",{className:"material-symbols-outlined text-sm",children:a===`model-${e.id}`?"check":"content_copy"})}),o&&(0,s.jsx)("button",{onClick:n,className:"p-0.5 hover:bg-red-500/10 rounded text-text-muted hover:text-red-500 opacity-0 group-hover:opacity-100 transition-opacity ml-auto",title:"Remove custom model",children:(0,s.jsx)("span",{className:"material-symbols-outlined text-sm",children:"close"})})]})})}function f({providerAlias:e,modelAliases:t,copied:i,onCopy:r,onSetAlias:l,onDeleteAlias:o}){let[n,d]=(0,a.useState)(""),[c,m]=(0,a.useState)(!1),x=Object.entries(t).filter(([,t])=>t.startsWith(`${e}/`)).map(([t,i])=>({modelId:i.replace(`${e}/`,""),fullModel:i,alias:t})),u=async()=>{let e;if(!n.trim()||c)return;let i=n.trim(),s=(e=i.split("/"))[e.length-1];if(t[s])return void alert(`Alias "${s}" already exists. Please use a different model or edit existing alias.`);m(!0);try{await l(i,s),d("")}catch(e){console.log("Error adding model:",e)}finally{m(!1)}};return(0,s.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,s.jsx)("p",{className:"text-sm text-text-muted",children:"OpenRouter supports any model. Add models and create aliases for quick access."}),(0,s.jsxs)("div",{className:"flex items-end gap-2",children:[(0,s.jsxs)("div",{className:"flex-1",children:[(0,s.jsx)("label",{htmlFor:"new-model-input",className:"text-xs text-text-muted mb-1 block",children:"Model ID (from OpenRouter)"}),(0,s.jsx)("input",{id:"new-model-input",type:"text",value:n,onChange:e=>d(e.target.value),onKeyDown:e=>"Enter"===e.key&&u(),placeholder:"anthropic/claude-3-opus",className:"w-full px-3 py-2 text-sm border border-border rounded-lg bg-background focus:outline-none focus:border-primary"})]}),(0,s.jsx)(p.$n,{size:"sm",icon:"add",onClick:u,disabled:!n.trim()||c,children:c?"Adding...":"Add"})]}),x.length>0&&(0,s.jsx)("div",{className:"flex flex-col gap-3",children:x.map(({modelId:e,fullModel:t,alias:a})=>(0,s.jsx)(g,{modelId:e,fullModel:t,copied:i,onCopy:r,onDeleteAlias:()=>o(a)},t))})]})}function g({modelId:e,fullModel:t,copied:i,onCopy:a,onDeleteAlias:r,onTest:l,testStatus:o,isTesting:n}){let d="ok"===o?"#22c55e":"error"===o?"#ef4444":void 0;return(0,s.jsxs)("div",{className:`flex items-center gap-3 p-3 rounded-lg border ${"ok"===o?"border-green-500/40":"error"===o?"border-red-500/40":"border-border"} hover:bg-sidebar/50`,children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-base text-text-muted",style:d?{color:d}:void 0,children:"ok"===o?"check_circle":"error"===o?"cancel":"smart_toy"}),(0,s.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,s.jsx)("p",{className:"text-sm font-medium truncate",children:e}),(0,s.jsxs)("div",{className:"flex items-center gap-1 mt-1",children:[(0,s.jsx)("code",{className:"text-xs text-text-muted font-mono bg-sidebar px-1.5 py-0.5 rounded",children:t}),(0,s.jsx)("button",{onClick:()=>a(t,`model-${e}`),className:"p-0.5 hover:bg-sidebar rounded text-text-muted hover:text-primary",title:"Copy model",children:(0,s.jsx)("span",{className:"material-symbols-outlined text-sm",children:i===`model-${e}`?"check":"content_copy"})}),l&&(0,s.jsx)("button",{onClick:l,disabled:n,className:"p-0.5 hover:bg-sidebar rounded text-text-muted hover:text-primary transition-colors",title:"Test model",children:(0,s.jsx)("span",{className:"material-symbols-outlined text-sm",style:n?{animation:"spin 1s linear infinite"}:void 0,children:n?"progress_activity":"science"})})]})]}),(0,s.jsx)("button",{onClick:r,className:"p-1 hover:bg-red-50 rounded text-red-500",title:"Remove model",children:(0,s.jsx)("span",{className:"material-symbols-outlined text-sm",children:"delete"})})]})}function v({providerStorageAlias:e,providerDisplayAlias:t,modelAliases:i,copied:r,onCopy:l,onSetAlias:o,onDeleteAlias:n,connections:d,isAnthropic:c}){let[m,x]=(0,a.useState)(""),[u,h]=(0,a.useState)(!1),[y,f]=(0,a.useState)(!1),[b,j]=(0,a.useState)(null),[N,k]=(0,a.useState)({}),C=async t=>{if(!b){j(t);try{let i=await fetch("/api/models/test",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({model:`${e}/${t}`})}),s=await i.json();k(e=>({...e,[t]:s.ok?"ok":"error"}))}catch{k(e=>({...e,[t]:"error"}))}finally{j(null)}}},w=Object.entries(i).filter(([,t])=>t.startsWith(`${e}/`)).map(([t,i])=>({modelId:i.replace(`${e}/`,""),fullModel:i,alias:t})),S=e=>{let s,a=(s=e.split("/"))[s.length-1];if(!i[a])return a;let r=`${t}-${a}`;return i[r]?null:r},A=async()=>{if(!m.trim()||u)return;let t=m.trim(),i=S(t);if(!i)return void alert("All suggested aliases already exist. Please choose a different model or remove conflicting aliases.");h(!0);try{await o(t,i,e),x("")}catch(e){console.log("Error adding model:",e)}finally{h(!1)}},$=async()=>{if(y)return;let t=d.find(e=>!1!==e.isActive);if(t){f(!0);try{let i=await fetch(`/api/providers/${t.id}/models`),s=await i.json();if(!i.ok)return void alert(s.error||"Failed to import models");let a=s.models||[];if(0===a.length)return void alert("No models returned from /models.");let r=0;for(let t of a){let i=t.id||t.name||t.model;if(!i)continue;let s=S(i);s&&(await o(i,s,e),r+=1)}0===r&&alert("No new models were added.")}catch(e){console.log("Error importing models:",e)}finally{f(!1)}}},P=d.some(e=>!1!==e.isActive);return(0,s.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,s.jsxs)("p",{className:"text-sm text-text-muted",children:["Add ",c?"Anthropic":"OpenAI","-compatible models manually or import them from the /models endpoint."]}),(0,s.jsxs)("div",{className:"flex items-end gap-2 flex-wrap",children:[(0,s.jsxs)("div",{className:"flex-1 min-w-[240px]",children:[(0,s.jsx)("label",{htmlFor:"new-compatible-model-input",className:"text-xs text-text-muted mb-1 block",children:"Model ID"}),(0,s.jsx)("input",{id:"new-compatible-model-input",type:"text",value:m,onChange:e=>x(e.target.value),onKeyDown:e=>"Enter"===e.key&&A(),placeholder:c?"claude-3-opus-20240229":"gpt-4o",className:"w-full px-3 py-2 text-sm border border-border rounded-lg bg-background focus:outline-none focus:border-primary"})]}),(0,s.jsx)(p.$n,{size:"sm",icon:"add",onClick:A,disabled:!m.trim()||u,children:u?"Adding...":"Add"}),(0,s.jsx)(p.$n,{size:"sm",variant:"secondary",icon:"download",onClick:$,disabled:!P||y,children:y?"Importing...":"Import from /models"})]}),!P&&(0,s.jsx)("p",{className:"text-xs text-text-muted",children:"Add a connection to enable importing models."}),w.length>0&&(0,s.jsx)("div",{className:"flex flex-col gap-3",children:w.map(({modelId:e,fullModel:i,alias:a})=>(0,s.jsx)(g,{modelId:e,fullModel:`${t}/${e}`,copied:r,onCopy:l,onDeleteAlias:()=>n(a),onTest:d.length>0?()=>C(e):void 0,testStatus:N[e],isTesting:b===e},i))})]})}function b({until:e}){let[t,i]=(0,a.useState)("");return((0,a.useEffect)(()=>{let t=()=>{let t=new Date(e).getTime()-Date.now();if(t<=0)return void i("");let s=Math.floor(t/1e3);if(s<60)i(`${s}s`);else if(s<3600)i(`${Math.floor(s/60)}m ${s%60}s`);else{let e=Math.floor(s/3600),t=Math.floor(s%3600/60);i(`${e}h ${t}m`)}};t();let s=setInterval(t,1e3);return()=>clearInterval(s)},[e]),t)?(0,s.jsxs)("span",{className:"text-xs text-orange-500 font-mono",children:["⏱ ",t]}):null}function j({connection:e,proxyPools:t,isOAuth:i,isFirst:r,isLast:l,onMoveUp:o,onMoveDown:n,onToggleActive:d,onUpdateProxy:c,onEdit:m,onDelete:x}){let[u,h]=(0,a.useState)(!1),[y,f]=(0,a.useState)(!1),g=(0,a.useRef)(null),v=new Map((t||[]).map(e=>[e.id,e])),N=e.providerSpecificData?.proxyPoolId||null,k=N?v.get(N):null,C=e.providerSpecificData?.connectionProxyEnabled===!0&&!!e.providerSpecificData?.connectionProxyUrl,w=!!N||C,S=k?`Pool: ${k.name}`:N?`Pool: ${N} (inactive/missing)`:C?`Legacy: ${e.providerSpecificData?.connectionProxyUrl}`:"",A="";if(k?.proxyUrl||e.providerSpecificData?.connectionProxyUrl){let t=k?.proxyUrl||e.providerSpecificData?.connectionProxyUrl;try{let e=new URL(t);A=`${e.protocol}//${e.hostname}${e.port?`:${e.port}`:""}`}catch{A=t}}let $=k?.noProxy||e.providerSpecificData?.connectionNoProxy||"",P="default";k?.isActive===!0?P="success":(N||C)&&(P="error"),(0,a.useEffect)(()=>{if(!u)return;let e=e=>{g.current&&!g.current.contains(e.target)&&h(!1)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[u]);let T=async e=>{f(!0);try{await c("__none__"===e?null:e)}finally{f(!1),h(!1)}},O=i?e.name||e.email||e.displayName||"OAuth Account":e.name,[E,R]=(0,a.useState)(!1),I=Object.entries(e).filter(([e])=>e.startsWith("modelLock_")).map(([,e])=>e).filter(e=>!!e).sort()[0]||null;(0,a.useEffect)(()=>{let t=()=>{R(!!Object.entries(e).filter(([e])=>e.startsWith("modelLock_")).map(([,e])=>e).filter(e=>e&&new Date(e).getTime()>Date.now()).sort()[0])};t();let i=I?setInterval(t,1e3):null;return()=>{i&&clearInterval(i)}},[I]);let _="unavailable"!==e.testStatus||E?e.testStatus:"active";return(0,s.jsxs)("div",{className:`group flex items-center justify-between p-3 rounded-lg hover:bg-black/[0.02] dark:hover:bg-white/[0.02] transition-colors ${!1===e.isActive?"opacity-60":""}`,children:[(0,s.jsxs)("div",{className:"flex items-center gap-3 flex-1 min-w-0",children:[(0,s.jsxs)("div",{className:"flex flex-col",children:[(0,s.jsx)("button",{onClick:o,disabled:r,className:`p-0.5 rounded ${r?"text-text-muted/30 cursor-not-allowed":"hover:bg-sidebar text-text-muted hover:text-primary"}`,children:(0,s.jsx)("span",{className:"material-symbols-outlined text-sm",children:"keyboard_arrow_up"})}),(0,s.jsx)("button",{onClick:n,disabled:l,className:`p-0.5 rounded ${l?"text-text-muted/30 cursor-not-allowed":"hover:bg-sidebar text-text-muted hover:text-primary"}`,children:(0,s.jsx)("span",{className:"material-symbols-outlined text-sm",children:"keyboard_arrow_down"})})]}),(0,s.jsx)("span",{className:"material-symbols-outlined text-base text-text-muted",children:i?"lock":"key"}),(0,s.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,s.jsx)("p",{className:"text-sm font-medium truncate",children:O}),(0,s.jsxs)("div",{className:"flex items-center gap-2 mt-1",children:[(0,s.jsx)(p.Ex,{variant:!1===e.isActive?"default":"active"===_||"success"===_?"success":"error"===_||"expired"===_||"unavailable"===_?"error":"default",size:"sm",dot:!0,children:!1===e.isActive?"disabled":_||"Unknown"}),w&&(0,s.jsx)(p.Ex,{variant:P,size:"sm",children:"Proxy"}),E&&!1!==e.isActive&&(0,s.jsx)(b,{until:I}),e.lastError&&!1!==e.isActive&&(0,s.jsx)("span",{className:"text-xs text-red-500 truncate max-w-[300px]",title:e.lastError,children:e.lastError}),(0,s.jsxs)("span",{className:"text-xs text-text-muted",children:["#",e.priority]}),e.globalPriority&&(0,s.jsxs)("span",{className:"text-xs text-text-muted",children:["Auto: ",e.globalPriority]})]}),w&&(0,s.jsxs)("div",{className:"mt-1 flex items-center gap-2 flex-wrap",children:[(0,s.jsx)("span",{className:"text-[11px] text-text-muted truncate max-w-[420px]",title:S,children:S}),A&&(0,s.jsx)("code",{className:"text-[10px] font-mono bg-black/5 dark:bg-white/5 px-1 py-0.5 rounded text-text-muted",children:A}),$&&(0,s.jsxs)("span",{className:"text-[11px] text-text-muted truncate max-w-[320px]",title:$,children:["no_proxy: ",$]})]})]})]}),(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsxs)("div",{className:"flex gap-1 opacity-0 group-hover:opacity-100 transition-opacity",children:[(t||[]).length>0&&(0,s.jsxs)("div",{className:"relative",ref:g,children:[(0,s.jsxs)("button",{onClick:()=>h(e=>!e),className:`flex flex-col items-center px-2 py-1 rounded hover:bg-black/5 dark:hover:bg-white/5 transition-colors ${w?"text-primary":"text-text-muted hover:text-primary"}`,disabled:y,children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:y?"progress_activity":"lan"}),(0,s.jsx)("span",{className:"text-[10px] leading-tight",children:"Proxy"})]}),u&&(0,s.jsxs)("div",{className:"absolute right-0 top-full mt-1 z-50 bg-bg border border-border rounded-lg shadow-lg py-1 min-w-[160px]",children:[(0,s.jsx)("button",{onClick:()=>T("__none__"),className:`w-full text-left px-3 py-1.5 text-sm hover:bg-black/5 dark:hover:bg-white/5 ${!N?"text-primary font-medium":"text-text-main"}`,children:"None"}),(t||[]).map(e=>(0,s.jsx)("button",{onClick:()=>T(e.id),className:`w-full text-left px-3 py-1.5 text-sm hover:bg-black/5 dark:hover:bg-white/5 ${N===e.id?"text-primary font-medium":"text-text-main"}`,children:e.name},e.id))]})]}),(0,s.jsxs)("button",{onClick:m,className:"flex flex-col items-center px-2 py-1 rounded hover:bg-black/5 dark:hover:bg-white/5 text-text-muted hover:text-primary",children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:"edit"}),(0,s.jsx)("span",{className:"text-[10px] leading-tight",children:"Edit"})]}),(0,s.jsxs)("button",{onClick:x,className:"flex flex-col items-center px-2 py-1 rounded hover:bg-red-500/10 text-red-500",children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:"delete"}),(0,s.jsx)("span",{className:"text-[10px] leading-tight",children:"Delete"})]})]}),(0,s.jsx)(p.lM,{size:"sm",checked:e.isActive??!0,onChange:d,title:e.isActive??!0?"Disable connection":"Enable connection"})]})]})}function N({isOpen:e,provider:t,providerName:i,isCompatible:r,isAnthropic:l,proxyPools:o,onSave:n,onClose:d}){let c="__none__",[m,x]=(0,a.useState)({name:"",apiKey:"",priority:1,proxyPoolId:c}),[u,h]=(0,a.useState)(!1),[y,f]=(0,a.useState)(null),[g,v]=(0,a.useState)(!1),b=async()=>{h(!0);try{let e=await fetch("/api/providers/validate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:t,apiKey:m.apiKey})}),i=await e.json();f(i.valid?"success":"failed")}catch{f("failed")}finally{h(!1)}},j=async()=>{if(t&&m.apiKey){v(!0);try{let e=!1;try{h(!0),f(null);let i=await fetch("/api/providers/validate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:t,apiKey:m.apiKey})});e=!!(await i.json()).valid,f(e?"success":"failed")}catch{f("failed")}finally{h(!1)}await n({name:m.name,apiKey:m.apiKey,priority:m.priority,proxyPoolId:m.proxyPoolId===c?null:m.proxyPoolId,testStatus:e?"active":"unknown",providerSpecificData:void 0})}finally{v(!1)}}};return t?(0,s.jsx)(p.aF,{isOpen:e,title:`Add ${i||t} API Key`,onClose:d,children:(0,s.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,s.jsx)(p.pd,{label:"Name",value:m.name,onChange:e=>x({...m,name:e.target.value}),placeholder:"Production Key"}),(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsx)(p.pd,{label:"API Key",type:"password",value:m.apiKey,onChange:e=>x({...m,apiKey:e.target.value}),className:"flex-1"}),(0,s.jsx)("div",{className:"pt-6",children:(0,s.jsx)(p.$n,{onClick:b,disabled:!m.apiKey||u||g,variant:"secondary",children:u?"Checking...":"Check"})})]}),y&&(0,s.jsx)(p.Ex,{variant:"success"===y?"success":"error",children:"success"===y?"Valid":"Invalid"}),r&&(0,s.jsx)("p",{className:"text-xs text-text-muted",children:l?`Validation checks ${i||"Anthropic Compatible"} by verifying the API key.`:`Validation checks ${i||"OpenAI Compatible"} via /models on your base URL.`}),(0,s.jsx)(p.pd,{label:"Priority",type:"number",value:m.priority,onChange:e=>x({...m,priority:Number.parseInt(e.target.value)||1})}),(0,s.jsx)(p.l6,{label:"Proxy Pool",value:m.proxyPoolId,onChange:e=>x({...m,proxyPoolId:e.target.value}),options:[{value:c,label:"None"},...(o||[]).map(e=>({value:e.id,label:e.name}))],placeholder:"None"}),0===(o||[]).length&&(0,s.jsx)("p",{className:"text-xs text-text-muted",children:"No active proxy pools available. Create one in Proxy Pools page first."}),(0,s.jsx)("p",{className:"text-xs text-text-muted",children:"Legacy manual proxy fields are still accepted by API for backward compatibility."}),(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsx)(p.$n,{onClick:j,fullWidth:!0,disabled:!m.name||!m.apiKey||g,children:g?"Saving...":"Save"}),(0,s.jsx)(p.$n,{onClick:d,variant:"ghost",fullWidth:!0,children:"Cancel"})]})]})}):null}function k({isOpen:e,connection:t,proxyPools:i,onSave:r,onClose:l}){let[o,n]=(0,a.useState)({name:"",priority:1,apiKey:""}),[d,c]=(0,a.useState)(!1),[x,u]=(0,a.useState)(null),[h,y]=(0,a.useState)(!1),[f,g]=(0,a.useState)(null),[v,b]=(0,a.useState)(!1);(0,a.useEffect)(()=>{t&&(n({name:t.name||"",priority:t.priority||1,apiKey:""}),u(null),g(null))},[t]);let j=async()=>{if(t?.provider){c(!0),u(null);try{let e=await fetch(`/api/providers/${t.id}/test`,{method:"POST"}),i=await e.json();u(i.valid?"success":"failed")}catch{u("failed")}finally{c(!1)}}},N=async()=>{if(t?.provider&&o.apiKey){y(!0),g(null);try{let e=await fetch("/api/providers/validate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:t.provider,apiKey:o.apiKey})}),i=await e.json();g(i.valid?"success":"failed")}catch{g("failed")}finally{y(!1)}}},C=async()=>{b(!0);try{let e={name:o.name,priority:o.priority};if(!w&&o.apiKey){e.apiKey=o.apiKey;let i="success"===f;if(!i)try{y(!0),g(null);let e=await fetch("/api/providers/validate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:t.provider,apiKey:o.apiKey})});i=!!(await e.json()).valid,g(i?"success":"failed")}catch{g("failed")}finally{y(!1)}i&&(e.testStatus="active",e.lastError=null,e.lastErrorAt=null)}await r(e)}finally{b(!1)}};if(!t)return null;let w="oauth"===t.authType,S=(0,m.mq)(t.provider)||(0,m.gb)(t.provider);return(0,s.jsx)(p.aF,{isOpen:e,title:"Edit Connection",onClose:l,children:(0,s.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,s.jsx)(p.pd,{label:"Name",value:o.name,onChange:e=>n({...o,name:e.target.value}),placeholder:w?"Account name":"Production Key"}),w&&t.email&&(0,s.jsxs)("div",{className:"bg-sidebar/50 p-3 rounded-lg",children:[(0,s.jsx)("p",{className:"text-sm text-text-muted mb-1",children:"Email"}),(0,s.jsx)("p",{className:"font-medium",children:t.email})]}),(0,s.jsx)(p.pd,{label:"Priority",type:"number",value:o.priority,onChange:e=>n({...o,priority:Number.parseInt(e.target.value)||1})}),!w&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsx)(p.pd,{label:"API Key",type:"password",value:o.apiKey,onChange:e=>n({...o,apiKey:e.target.value}),placeholder:"Enter new API key",hint:"Leave blank to keep the current API key.",className:"flex-1"}),(0,s.jsx)("div",{className:"pt-6",children:(0,s.jsx)(p.$n,{onClick:N,disabled:!o.apiKey||h||v,variant:"secondary",children:h?"Checking...":"Check"})})]}),f&&(0,s.jsx)(p.Ex,{variant:"success"===f?"success":"error",children:"success"===f?"Valid":"Invalid"})]}),!S&&(0,s.jsxs)("div",{className:"flex items-center gap-3",children:[(0,s.jsx)(p.$n,{onClick:j,variant:"secondary",disabled:d,children:d?"Testing...":"Test Connection"}),x&&(0,s.jsx)(p.Ex,{variant:"success"===x?"success":"error",children:"success"===x?"Valid":"Failed"})]}),(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsx)(p.$n,{onClick:C,fullWidth:!0,disabled:v,children:v?"Saving...":"Save"}),(0,s.jsx)(p.$n,{onClick:l,variant:"ghost",fullWidth:!0,children:"Cancel"})]})]})})}function C({isOpen:e,node:t,onSave:i,onClose:r,isAnthropic:l}){let[o,n]=(0,a.useState)({name:"",prefix:"",apiType:"chat",baseUrl:"https://api.openai.com/v1"}),[d,c]=(0,a.useState)(!1),[m,x]=(0,a.useState)(""),[u,h]=(0,a.useState)(""),[y,f]=(0,a.useState)(!1),[g,v]=(0,a.useState)(null);(0,a.useEffect)(()=>{t&&n({name:t.name||"",prefix:t.prefix||"",apiType:t.apiType||"chat",baseUrl:t.baseUrl||(l?"https://api.anthropic.com/v1":"https://api.openai.com/v1")})},[t,l]);let b=async()=>{if(o.name.trim()&&o.prefix.trim()&&o.baseUrl.trim()){c(!0);try{let e={name:o.name,prefix:o.prefix,baseUrl:o.baseUrl};l||(e.apiType=o.apiType),await i(e)}finally{c(!1)}}},j=async()=>{f(!0);try{let e=await fetch("/api/provider-nodes/validate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({baseUrl:o.baseUrl,apiKey:m,type:l?"anthropic-compatible":"openai-compatible",modelId:u.trim()||void 0})}),t=await e.json();v(t.valid?"success":"failed")}catch{v("failed")}finally{f(!1)}};return t?(0,s.jsx)(p.aF,{isOpen:e,title:`Edit ${l?"Anthropic":"OpenAI"} Compatible`,onClose:r,children:(0,s.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,s.jsx)(p.pd,{label:"Name",value:o.name,onChange:e=>n({...o,name:e.target.value}),placeholder:`${l?"Anthropic":"OpenAI"} Compatible (Prod)`,hint:"Required. A friendly label for this node."}),(0,s.jsx)(p.pd,{label:"Prefix",value:o.prefix,onChange:e=>n({...o,prefix:e.target.value}),placeholder:l?"ac-prod":"oc-prod",hint:"Required. Used as the provider prefix for model IDs."}),!l&&(0,s.jsx)(p.l6,{label:"API Type",options:[{value:"chat",label:"Chat Completions"},{value:"responses",label:"Responses API"}],value:o.apiType,onChange:e=>n({...o,apiType:e.target.value})}),(0,s.jsx)(p.pd,{label:"Base URL",value:o.baseUrl,onChange:e=>n({...o,baseUrl:e.target.value}),placeholder:l?"https://api.anthropic.com/v1":"https://api.openai.com/v1",hint:`Use the base URL (ending in /v1) for your ${l?"Anthropic":"OpenAI"}-compatible API.`}),(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsx)(p.pd,{label:"API Key (for Check)",type:"password",value:m,onChange:e=>x(e.target.value),className:"flex-1"}),(0,s.jsx)("div",{className:"pt-6",children:(0,s.jsx)(p.$n,{onClick:j,disabled:!m||y||!o.baseUrl.trim(),variant:"secondary",children:y?"Checking...":"Check"})})]}),(0,s.jsx)(p.pd,{label:"Model ID (optional)",value:u,onChange:e=>h(e.target.value),placeholder:"e.g. my-model-id",hint:"If provider lacks /models endpoint, enter a model ID to validate via chat/completions instead."}),g&&(0,s.jsx)(p.Ex,{variant:"success"===g?"success":"error",children:"success"===g?"Valid":"Invalid"}),(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsx)(p.$n,{onClick:b,fullWidth:!0,disabled:!o.name.trim()||!o.prefix.trim()||!o.baseUrl.trim()||d,children:d?"Saving...":"Save"}),(0,s.jsx)(p.$n,{onClick:r,variant:"ghost",fullWidth:!0,children:"Cancel"})]})]})}):null}function w({isOpen:e,providerAlias:t,providerDisplayAlias:i,onSave:r,onClose:l}){let[o,n]=(0,a.useState)(""),[d,c]=(0,a.useState)(null),[m,x]=(0,a.useState)(""),[u,h]=(0,a.useState)(!1);(0,a.useEffect)(()=>{e&&(n(""),c(null),x(""))},[e]);let y=async()=>{if(o.trim()){c("testing"),x("");try{let e=await fetch("/api/models/test",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({model:`${t}/${o.trim()}`})}),i=await e.json();c(i.ok?"ok":"error"),x(i.error||"")}catch(e){c("error"),x(e.message)}}},f=async()=>{if(o.trim()&&!u){h(!0);try{await r(o.trim())}finally{h(!1)}}};return(0,s.jsx)(p.aF,{isOpen:e,onClose:l,title:"Add Custom Model",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 mb-1.5 block",children:"Model ID"}),(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsx)("input",{type:"text",value:o,onChange:e=>{n(e.target.value),c(null),x("")},onKeyDown:e=>{"Enter"===e.key&&y()},placeholder:"e.g. claude-opus-4-5",className:"flex-1 px-3 py-2 text-sm border border-border rounded-lg bg-background focus:outline-none focus:border-primary",autoFocus:!0}),(0,s.jsx)(p.$n,{variant:"secondary",icon:"science",loading:"testing"===d,onClick:y,disabled:!o.trim()||"testing"===d,children:"testing"===d?"Testing...":"Test"})]}),(0,s.jsxs)("p",{className:"text-xs text-text-muted mt-1",children:["Sent to provider as: ",(0,s.jsx)("code",{className:"font-mono bg-sidebar px-1 rounded",children:o.trim()||"model-id"})]})]}),"ok"===d&&(0,s.jsxs)("div",{className:"flex items-center gap-2 text-sm text-green-600",children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-base",children:"check_circle"}),"Model is reachable"]}),"error"===d&&(0,s.jsxs)("div",{className:"flex items-start gap-2 text-sm text-red-500",children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-base shrink-0",children:"cancel"}),(0,s.jsx)("span",{children:m||"Model not reachable"})]}),(0,s.jsxs)("div",{className:"flex gap-2 pt-1",children:[(0,s.jsx)(p.$n,{onClick:l,variant:"ghost",fullWidth:!0,size:"sm",children:"Cancel"}),(0,s.jsx)(p.$n,{onClick:f,fullWidth:!0,size:"sm",disabled:!o.trim()||u,children:u?"Adding...":"Add Model"})]})]})})}y.propTypes={model:l().shape({id:l().string.isRequired}).isRequired,fullModel:l().string.isRequired,alias:l().string,copied:l().string,onCopy:l().func.isRequired,testStatus:l().oneOf(["ok","error"]),isCustom:l().bool,onDeleteAlias:l().func,onTest:l().func,isTesting:l().bool},f.propTypes={providerAlias:l().string.isRequired,modelAliases:l().object.isRequired,copied:l().string,onCopy:l().func.isRequired,onSetAlias:l().func.isRequired,onDeleteAlias:l().func.isRequired},g.propTypes={modelId:l().string.isRequired,fullModel:l().string.isRequired,copied:l().string,onCopy:l().func.isRequired,onDeleteAlias:l().func.isRequired,onTest:l().func,testStatus:l().oneOf(["ok","error"]),isTesting:l().bool},v.propTypes={providerStorageAlias:l().string.isRequired,providerDisplayAlias:l().string.isRequired,modelAliases:l().object.isRequired,copied:l().string,onCopy:l().func.isRequired,onSetAlias:l().func.isRequired,onDeleteAlias:l().func.isRequired,connections:l().arrayOf(l().shape({id:l().string,isActive:l().bool})).isRequired,isAnthropic:l().bool},b.propTypes={until:l().string.isRequired},j.propTypes={connection:l().shape({id:l().string,name:l().string,email:l().string,displayName:l().string,modelLockUntil:l().string,testStatus:l().string,isActive:l().bool,lastError:l().string,priority:l().number,globalPriority:l().number}).isRequired,proxyPools:l().arrayOf(l().shape({id:l().string,name:l().string,proxyUrl:l().string,noProxy:l().string,isActive:l().bool})),isOAuth:l().bool.isRequired,isFirst:l().bool.isRequired,isLast:l().bool.isRequired,onMoveUp:l().func.isRequired,onMoveDown:l().func.isRequired,onToggleActive:l().func.isRequired,onUpdateProxy:l().func,onEdit:l().func.isRequired,onDelete:l().func.isRequired},N.propTypes={isOpen:l().bool.isRequired,provider:l().string,providerName:l().string,isCompatible:l().bool,isAnthropic:l().bool,proxyPools:l().arrayOf(l().shape({id:l().string,name:l().string})),onSave:l().func.isRequired,onClose:l().func.isRequired},k.propTypes={isOpen:l().bool.isRequired,connection:l().shape({id:l().string,name:l().string,email:l().string,priority:l().number,authType:l().string,provider:l().string,providerSpecificData:l().object}),proxyPools:l().arrayOf(l().shape({id:l().string,name:l().string})),onSave:l().func.isRequired,onClose:l().func.isRequired},C.propTypes={isOpen:l().bool.isRequired,node:l().shape({id:l().string,name:l().string,prefix:l().string,apiType:l().string,baseUrl:l().string}),onSave:l().func.isRequired,onClose:l().func.isRequired,isAnthropic:l().bool},w.propTypes={isOpen:l().bool.isRequired,providerAlias:l().string.isRequired,providerDisplayAlias:l().string.isRequired,onSave:l().func.isRequired,onClose:l().func.isRequired}}},e=>{e.O(0,[2574,3862,5772,6902,2652,5497,8441,3794,7358],()=>e(e.s=16113)),_N_E=e.O()}]);
@@ -1 +1 @@
1
- (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[9089],{15615:(e,r,t)=>{"use strict";t.r(r),t.d(r,{default:()=>u});var a=t(95155),s=t(12115),i=t(73321),l=t(98500),d=t.n(l),o=t(35497),n=t(90620);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"})]})]})})]})}},68690:(e,r,t)=>{Promise.resolve().then(t.bind(t,15615))}},e=>{e.O(0,[2574,3862,5772,123,2652,5497,8441,3794,7358],()=>e(e.s=68690)),_N_E=e.O()}]);
1
+ (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[9089],{15615:(e,r,t)=>{"use strict";t.r(r),t.d(r,{default:()=>u});var a=t(95155),s=t(12115),i=t(73321),l=t(98500),d=t.n(l),o=t(35497),n=t(90620);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"})]})]})})]})}},68690:(e,r,t)=>{Promise.resolve().then(t.bind(t,15615))}},e=>{e.O(0,[2574,3862,5772,6902,2652,5497,8441,3794,7358],()=>e(e.s=68690)),_N_E=e.O()}]);
@@ -1 +1 @@
1
- (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[8460],{52154:(e,t,s)=>{"use strict";s.r(t),s.d(t,{default:()=>b});var r=s(95155),a=s(12115),l=s(5772),i=s(14051),n=s.n(i),o=s(35497),d=s(90620),c=s(52679),p=s(98500),m=s.n(p),x=s(65921);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,n]=(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)&&n(!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||[],g=0===(e?.unavailableCount||b.filter(e=>"available"!==e.status).length),v={};return b.forEach(e=>{if("available"===e.status)return;let t=e.provider||"unknown";v[t]||(v[t]=[]),v[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:g?"#22c55e":"#f59e0b"},children:g?"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:g?(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(v).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)(o.$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)(o.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)(o.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,n]=(0,a.useState)(!0),[p,m]=(0,a.useState)(!1),[u,f]=(0,a.useState)(!1),[b,C]=(0,a.useState)(null),[w,k]=(0,a.useState)(null),T=(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{n(!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})})))},E=async(e,t=null)=>{if(!b){C("provider"===e?t:e),k(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(k(r),r.summary){let{passed:e,failed:t,total:s}=r.summary;0===t?T.success(`All ${s} tests passed`):T.warning(`${e}/${s} passed, ${t} failed`)}}catch(e){k({error:"Test request failed"}),T.error("Provider test failed")}finally{C(null)}}},S=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.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)(o.Qv,{}),(0,r.jsx)(o.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:()=>E("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)(g,{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 Providers"}),(0,r.jsxs)("button",{onClick:()=>E("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.jsx)("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)(g,{providerId:e,provider:t,stats:A(e,"oauth"),authType:"free",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.jsxs)("h2",{className:"text-xl font-semibold flex items-center gap-2",children:["API Key Providers"," "]}),(0,r.jsxs)("button",{onClick:()=>E("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).map(([e,t])=>(0,r.jsx)(v,{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)(o.$n,{size:"sm",icon:"add",onClick:()=>f(!0),children:"Add Anthropic Compatible"}),(0,r.jsx)(o.$n,{size:"sm",variant:"secondary",icon:"add",onClick:()=>m(!0),className:"!bg-white !text-black hover:!bg-gray-100",children:"Add OpenAI Compatible"})]})]}),0===S.length&&0===$.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:[...S,...$].map(e=>(0,r.jsx)(v,{providerId:e.id,provider:e,stats:A(e.id,"apikey"),authType:"compatible",onToggle:t=>I(e.id,"apikey",t)},e.id))})]}),(0,r.jsx)(j,{isOpen:p,onClose:()=>m(!1),onCreated:e=>{l(t=>[...t,e]),m(!1)}}),(0,r.jsx)(y,{isOpen:u,onClose:()=>f(!1),onCreated:e=>{l(t=>[...t,e]),f(!1)}}),w&&(0,r.jsxs)("div",{className:"fixed inset-0 z-50 flex items-start justify-center pt-[10vh]",onClick:()=>k(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:()=>k(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:w})})]})]})]})}function g({providerId:e,provider:t,stats:s,authType:i,onToggle:n}){let{connected:d,error:c,errorCode:p,errorTime:x,allDisabled:u}=s,[h,b]=(0,a.useState)(!1);return(0,r.jsx)(m(),{href:`/dashboard/providers/${e}`,className:"group",children:(0,r.jsx)(o.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:h?(0,r.jsx)("span",{className:"text-xs font-bold",style:{color:t.color},children:t.textIcon||t.id.slice(0,2).toUpperCase()}):(0,r.jsx)(l.default,{src:`/providers/${t.id}.png`,alt:t.name,width:30,height:30,className:"object-contain rounded-lg max-w-[32px] max-h-[32px]",sizes:"32px",onError:()=>b(!0)})}),(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)(o.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(d,c,p),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(),n(!!u)},children:(0,r.jsx)(o.lM,{size:"sm",checked:!u,onChange:()=>{},title:u?"Enable provider":"Disable provider"})})})]})})})}function v({providerId:e,provider:t,stats:s,authType:i,onToggle:n}){let{connected:d,error:p,errorCode:x,errorTime:u,allDisabled:h}=s,b=e.startsWith(c.JH),g=e.startsWith(c.DI),[j,y]=(0,a.useState)(!1);return(0,r.jsx)(m(),{href:`/dashboard/providers/${e}`,className:"group",children:(0,r.jsx)(o.Zp,{padding:"xs",className:`h-full hover:bg-black/[0.01] dark:hover:bg-white/[0.01] transition-colors cursor-pointer ${h?"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:j?(0,r.jsx)("span",{className:"text-xs font-bold",style:{color:t.color},children:t.textIcon||t.id.slice(0,2).toUpperCase()}):(0,r.jsx)(l.default,{src:b?"responses"===t.apiType?"/providers/oai-r.png":"/providers/oai-cc.png":g?"/providers/anthropic-m.png":`/providers/${t.id}.png`,alt:t.name,width:30,height:30,className:"object-contain rounded-lg max-w-[30px] max-h-[30px]",sizes:"30px",onError:()=>y(!0)})}),(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:h?(0,r.jsx)(o.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(d,p,x),b&&(0,r.jsx)(o.Ex,{variant:"default",size:"sm",children:"responses"===t.apiType?"Responses":"Chat"}),g&&(0,r.jsx)(o.Ex,{variant:"default",size:"sm",children:"Messages"}),u&&(0,r.jsx)("span",{className:"text-text-muted",children:u})]})})]})]}),(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(),n(!!h)},children:(0,r.jsx)(o.lM,{size:"sm",checked:!h,onChange:()=>{},title:h?"Enable provider":"Disable provider"})})})]})})})}function j({isOpen:e,onClose:t,onCreated:s}){let[l,i]=(0,a.useState)({name:"",prefix:"",apiType:"chat",baseUrl:"https://api.openai.com/v1"}),[n,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 g=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)}}},v=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)(o.aF,{isOpen:e,title:"Add OpenAI Compatible",onClose:t,children:(0,r.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,r.jsx)(o.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)(o.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)(o.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)(o.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)(o.pd,{label:"API Key (for Check)",type:"password",value:c,onChange:e=>p(e.target.value)}),(0,r.jsx)(o.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)(o.$n,{onClick:v,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)(o.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)(o.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)(o.$n,{onClick:g,fullWidth:!0,disabled:!l.name.trim()||!l.prefix.trim()||!l.baseUrl.trim()||n,children:n?"Creating...":"Create"}),(0,r.jsx)(o.$n,{onClick:t,variant:"ghost",fullWidth:!0,children:"Cancel"})]})]})})}function y({isOpen:e,onClose:t,onCreated:s}){let[l,i]=(0,a.useState)({name:"",prefix:"",baseUrl:"https://api.anthropic.com/v1"}),[n,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 g=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)}}},v=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)(o.aF,{isOpen:e,title:"Add Anthropic Compatible",onClose:t,children:(0,r.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,r.jsx)(o.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)(o.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)(o.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)(o.pd,{label:"API Key (for Check)",type:"password",value:c,onChange:e=>p(e.target.value)}),(0,r.jsx)(o.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)(o.$n,{onClick:v,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)(o.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)(o.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)(o.$n,{onClick:g,fullWidth:!0,disabled:!l.name.trim()||!l.prefix.trim()||!l.baseUrl.trim()||n,children:n?"Creating...":"Create"}),(0,r.jsx)(o.$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."})]})}g.propTypes={providerId:n().string.isRequired,provider:n().shape({id:n().string.isRequired,name:n().string.isRequired,color:n().string,textIcon:n().string}).isRequired,stats:n().shape({connected:n().number,error:n().number,errorCode:n().string,errorTime:n().string}).isRequired,authType:n().string,onToggle:n().func},v.propTypes={providerId:n().string.isRequired,provider:n().shape({id:n().string.isRequired,name:n().string.isRequired,color:n().string,textIcon:n().string,apiType:n().string}).isRequired,stats:n().shape({connected:n().number,error:n().number,errorCode:n().string,errorTime:n().string}).isRequired,authType:n().string,onToggle:n().func},j.propTypes={isOpen:n().bool.isRequired,onClose:n().func.isRequired,onCreated:n().func.isRequired},y.propTypes={isOpen:n().bool.isRequired,onClose:n().func.isRequired,onCreated:n().func.isRequired},N.propTypes={results:n().shape({mode:n().string,results:n().array,summary:n().shape({total:n().number,passed:n().number,failed:n().number}),error:n().string}).isRequired}},62473:(e,t,s)=>{Promise.resolve().then(s.bind(s,52154))}},e=>{e.O(0,[2574,3862,5772,123,2652,5497,8441,3794,7358],()=>e(e.s=62473)),_N_E=e.O()}]);
1
+ (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[8460],{52154:(e,t,s)=>{"use strict";s.r(t),s.d(t,{default:()=>b});var r=s(95155),a=s(12115),l=s(5772),i=s(14051),n=s.n(i),o=s(35497),d=s(90620),c=s(52679),p=s(98500),m=s.n(p),x=s(65921);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,n]=(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)&&n(!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||[],g=0===(e?.unavailableCount||b.filter(e=>"available"!==e.status).length),v={};return b.forEach(e=>{if("available"===e.status)return;let t=e.provider||"unknown";v[t]||(v[t]=[]),v[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:g?"#22c55e":"#f59e0b"},children:g?"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:g?(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(v).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)(o.$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)(o.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)(o.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,n]=(0,a.useState)(!0),[p,m]=(0,a.useState)(!1),[u,f]=(0,a.useState)(!1),[b,C]=(0,a.useState)(null),[w,k]=(0,a.useState)(null),T=(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{n(!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})})))},E=async(e,t=null)=>{if(!b){C("provider"===e?t:e),k(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(k(r),r.summary){let{passed:e,failed:t,total:s}=r.summary;0===t?T.success(`All ${s} tests passed`):T.warning(`${e}/${s} passed, ${t} failed`)}}catch(e){k({error:"Test request failed"}),T.error("Provider test failed")}finally{C(null)}}},S=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.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)(o.Qv,{}),(0,r.jsx)(o.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:()=>E("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)(g,{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 Providers"}),(0,r.jsxs)("button",{onClick:()=>E("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.jsx)("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)(g,{providerId:e,provider:t,stats:A(e,"oauth"),authType:"free",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.jsxs)("h2",{className:"text-xl font-semibold flex items-center gap-2",children:["API Key Providers"," "]}),(0,r.jsxs)("button",{onClick:()=>E("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).map(([e,t])=>(0,r.jsx)(v,{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)(o.$n,{size:"sm",icon:"add",onClick:()=>f(!0),children:"Add Anthropic Compatible"}),(0,r.jsx)(o.$n,{size:"sm",variant:"secondary",icon:"add",onClick:()=>m(!0),className:"!bg-white !text-black hover:!bg-gray-100",children:"Add OpenAI Compatible"})]})]}),0===S.length&&0===$.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:[...S,...$].map(e=>(0,r.jsx)(v,{providerId:e.id,provider:e,stats:A(e.id,"apikey"),authType:"compatible",onToggle:t=>I(e.id,"apikey",t)},e.id))})]}),(0,r.jsx)(j,{isOpen:p,onClose:()=>m(!1),onCreated:e=>{l(t=>[...t,e]),m(!1)}}),(0,r.jsx)(y,{isOpen:u,onClose:()=>f(!1),onCreated:e=>{l(t=>[...t,e]),f(!1)}}),w&&(0,r.jsxs)("div",{className:"fixed inset-0 z-50 flex items-start justify-center pt-[10vh]",onClick:()=>k(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:()=>k(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:w})})]})]})]})}function g({providerId:e,provider:t,stats:s,authType:i,onToggle:n}){let{connected:d,error:c,errorCode:p,errorTime:x,allDisabled:u}=s,[h,b]=(0,a.useState)(!1);return(0,r.jsx)(m(),{href:`/dashboard/providers/${e}`,className:"group",children:(0,r.jsx)(o.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:h?(0,r.jsx)("span",{className:"text-xs font-bold",style:{color:t.color},children:t.textIcon||t.id.slice(0,2).toUpperCase()}):(0,r.jsx)(l.default,{src:`/providers/${t.id}.png`,alt:t.name,width:30,height:30,className:"object-contain rounded-lg max-w-[32px] max-h-[32px]",sizes:"32px",onError:()=>b(!0)})}),(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)(o.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(d,c,p),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(),n(!!u)},children:(0,r.jsx)(o.lM,{size:"sm",checked:!u,onChange:()=>{},title:u?"Enable provider":"Disable provider"})})})]})})})}function v({providerId:e,provider:t,stats:s,authType:i,onToggle:n}){let{connected:d,error:p,errorCode:x,errorTime:u,allDisabled:h}=s,b=e.startsWith(c.JH),g=e.startsWith(c.DI),[j,y]=(0,a.useState)(!1);return(0,r.jsx)(m(),{href:`/dashboard/providers/${e}`,className:"group",children:(0,r.jsx)(o.Zp,{padding:"xs",className:`h-full hover:bg-black/[0.01] dark:hover:bg-white/[0.01] transition-colors cursor-pointer ${h?"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:j?(0,r.jsx)("span",{className:"text-xs font-bold",style:{color:t.color},children:t.textIcon||t.id.slice(0,2).toUpperCase()}):(0,r.jsx)(l.default,{src:b?"responses"===t.apiType?"/providers/oai-r.png":"/providers/oai-cc.png":g?"/providers/anthropic-m.png":`/providers/${t.id}.png`,alt:t.name,width:30,height:30,className:"object-contain rounded-lg max-w-[30px] max-h-[30px]",sizes:"30px",onError:()=>y(!0)})}),(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:h?(0,r.jsx)(o.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(d,p,x),b&&(0,r.jsx)(o.Ex,{variant:"default",size:"sm",children:"responses"===t.apiType?"Responses":"Chat"}),g&&(0,r.jsx)(o.Ex,{variant:"default",size:"sm",children:"Messages"}),u&&(0,r.jsx)("span",{className:"text-text-muted",children:u})]})})]})]}),(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(),n(!!h)},children:(0,r.jsx)(o.lM,{size:"sm",checked:!h,onChange:()=>{},title:h?"Enable provider":"Disable provider"})})})]})})})}function j({isOpen:e,onClose:t,onCreated:s}){let[l,i]=(0,a.useState)({name:"",prefix:"",apiType:"chat",baseUrl:"https://api.openai.com/v1"}),[n,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 g=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)}}},v=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)(o.aF,{isOpen:e,title:"Add OpenAI Compatible",onClose:t,children:(0,r.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,r.jsx)(o.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)(o.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)(o.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)(o.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)(o.pd,{label:"API Key (for Check)",type:"password",value:c,onChange:e=>p(e.target.value)}),(0,r.jsx)(o.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)(o.$n,{onClick:v,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)(o.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)(o.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)(o.$n,{onClick:g,fullWidth:!0,disabled:!l.name.trim()||!l.prefix.trim()||!l.baseUrl.trim()||n,children:n?"Creating...":"Create"}),(0,r.jsx)(o.$n,{onClick:t,variant:"ghost",fullWidth:!0,children:"Cancel"})]})]})})}function y({isOpen:e,onClose:t,onCreated:s}){let[l,i]=(0,a.useState)({name:"",prefix:"",baseUrl:"https://api.anthropic.com/v1"}),[n,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 g=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)}}},v=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)(o.aF,{isOpen:e,title:"Add Anthropic Compatible",onClose:t,children:(0,r.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,r.jsx)(o.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)(o.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)(o.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)(o.pd,{label:"API Key (for Check)",type:"password",value:c,onChange:e=>p(e.target.value)}),(0,r.jsx)(o.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)(o.$n,{onClick:v,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)(o.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)(o.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)(o.$n,{onClick:g,fullWidth:!0,disabled:!l.name.trim()||!l.prefix.trim()||!l.baseUrl.trim()||n,children:n?"Creating...":"Create"}),(0,r.jsx)(o.$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."})]})}g.propTypes={providerId:n().string.isRequired,provider:n().shape({id:n().string.isRequired,name:n().string.isRequired,color:n().string,textIcon:n().string}).isRequired,stats:n().shape({connected:n().number,error:n().number,errorCode:n().string,errorTime:n().string}).isRequired,authType:n().string,onToggle:n().func},v.propTypes={providerId:n().string.isRequired,provider:n().shape({id:n().string.isRequired,name:n().string.isRequired,color:n().string,textIcon:n().string,apiType:n().string}).isRequired,stats:n().shape({connected:n().number,error:n().number,errorCode:n().string,errorTime:n().string}).isRequired,authType:n().string,onToggle:n().func},j.propTypes={isOpen:n().bool.isRequired,onClose:n().func.isRequired,onCreated:n().func.isRequired},y.propTypes={isOpen:n().bool.isRequired,onClose:n().func.isRequired,onCreated:n().func.isRequired},N.propTypes={results:n().shape({mode:n().string,results:n().array,summary:n().shape({total:n().number,passed:n().number,failed:n().number}),error:n().string}).isRequired}},62473:(e,t,s)=>{Promise.resolve().then(s.bind(s,52154))}},e=>{e.O(0,[2574,3862,5772,6902,2652,5497,8441,3794,7358],()=>e(e.s=62473)),_N_E=e.O()}]);
@@ -1,2 +1,2 @@
1
1
  (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[6812],{57076:(e,t,r)=>{"use strict";r.r(t),r.d(t,{default:()=>n});var s=r(95155),o=r(12115),i=r(35497),l=r(65921);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"})]})]})})]})}},88325:(e,t,r)=>{Promise.resolve().then(r.bind(r,57076))}},e=>{e.O(0,[2574,3862,5772,123,2652,5497,8441,3794,7358],()=>e(e.s=88325)),_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"})]})]})})]})}},88325:(e,t,r)=>{Promise.resolve().then(r.bind(r,57076))}},e=>{e.O(0,[2574,3862,5772,6902,2652,5497,8441,3794,7358],()=>e(e.s=88325)),_N_E=e.O()}]);
@@ -1 +1 @@
1
- (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[3528],{5214:(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(17828)},9695:(e,t,n)=>{Promise.resolve().then(n.bind(n,69472))},17828:(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(64054).createAsyncLocalStorage)()},21957:(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(95155),n(47650),n(5214),n(2451),n(53887)},41112:(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(1980)},64054:(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)}}},68635:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),Object.defineProperty(t,"default",{enumerable:!0,get:function(){return i}});let r=n(95155),a=n(12115),s=n(41112);function l(e){return{default:e&&"default"in e?e.default:e}}n(21957);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}},69472:(e,t,n)=>{"use strict";n.r(t),n.d(t,{default:()=>c});var r=n(95155),a=n(12115),s=n(35497),l=n(75707);let o=n.n(l)()(()=>n.e(8202).then(n.bind(n,28202)),{loadableGenerated:{webpack:()=>[28202]},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]})}},75707:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),Object.defineProperty(t,"default",{enumerable:!0,get:function(){return a}});let r=n(73623)._(n(68635));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)}},e=>{e.O(0,[2574,3862,5772,123,2652,5497,8441,3794,7358],()=>e(e.s=9695)),_N_E=e.O()}]);
1
+ (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[3528],{5214:(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(17828)},9695:(e,t,n)=>{Promise.resolve().then(n.bind(n,69472))},17828:(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(64054).createAsyncLocalStorage)()},21957:(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(95155),n(47650),n(5214),n(2451),n(53887)},41112:(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(1980)},64054:(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)}}},68635:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),Object.defineProperty(t,"default",{enumerable:!0,get:function(){return i}});let r=n(95155),a=n(12115),s=n(41112);function l(e){return{default:e&&"default"in e?e.default:e}}n(21957);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}},69472:(e,t,n)=>{"use strict";n.r(t),n.d(t,{default:()=>c});var r=n(95155),a=n(12115),s=n(35497),l=n(75707);let o=n.n(l)()(()=>n.e(8202).then(n.bind(n,28202)),{loadableGenerated:{webpack:()=>[28202]},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]})}},75707:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),Object.defineProperty(t,"default",{enumerable:!0,get:function(){return a}});let r=n(73623)._(n(68635));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)}},e=>{e.O(0,[2574,3862,5772,6902,2652,5497,8441,3794,7358],()=>e(e.s=9695)),_N_E=e.O()}]);