@ltgiang/9router 0.4.81 → 0.4.83

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 (375) hide show
  1. package/app/.next-cli-build/BUILD_ID +1 -1
  2. package/app/.next-cli-build/app-path-routes-manifest.json +12 -12
  3. package/app/.next-cli-build/build-manifest.json +2 -2
  4. package/app/.next-cli-build/server/app/(dashboard)/dashboard/basic-chat/page_client-reference-manifest.js +1 -1
  5. package/app/.next-cli-build/server/app/(dashboard)/dashboard/cli-tools/[toolId]/page.js.nft.json +1 -1
  6. package/app/.next-cli-build/server/app/(dashboard)/dashboard/cli-tools/[toolId]/page_client-reference-manifest.js +1 -1
  7. package/app/.next-cli-build/server/app/(dashboard)/dashboard/cli-tools/page.js.nft.json +1 -1
  8. package/app/.next-cli-build/server/app/(dashboard)/dashboard/cli-tools/page_client-reference-manifest.js +1 -1
  9. package/app/.next-cli-build/server/app/(dashboard)/dashboard/combos/page_client-reference-manifest.js +1 -1
  10. package/app/.next-cli-build/server/app/(dashboard)/dashboard/console-log/page_client-reference-manifest.js +1 -1
  11. package/app/.next-cli-build/server/app/(dashboard)/dashboard/endpoint/page.js.nft.json +1 -1
  12. package/app/.next-cli-build/server/app/(dashboard)/dashboard/endpoint/page_client-reference-manifest.js +1 -1
  13. package/app/.next-cli-build/server/app/(dashboard)/dashboard/media-providers/[kind]/[id]/page_client-reference-manifest.js +1 -1
  14. package/app/.next-cli-build/server/app/(dashboard)/dashboard/media-providers/[kind]/page_client-reference-manifest.js +1 -1
  15. package/app/.next-cli-build/server/app/(dashboard)/dashboard/media-providers/combo/[id]/page_client-reference-manifest.js +1 -1
  16. package/app/.next-cli-build/server/app/(dashboard)/dashboard/media-providers/web/page_client-reference-manifest.js +1 -1
  17. package/app/.next-cli-build/server/app/(dashboard)/dashboard/mitm/page_client-reference-manifest.js +1 -1
  18. package/app/.next-cli-build/server/app/(dashboard)/dashboard/page.js.nft.json +1 -1
  19. package/app/.next-cli-build/server/app/(dashboard)/dashboard/page_client-reference-manifest.js +1 -1
  20. package/app/.next-cli-build/server/app/(dashboard)/dashboard/profile/page_client-reference-manifest.js +1 -1
  21. package/app/.next-cli-build/server/app/(dashboard)/dashboard/providers/[id]/page.js +2 -2
  22. package/app/.next-cli-build/server/app/(dashboard)/dashboard/providers/[id]/page_client-reference-manifest.js +1 -1
  23. package/app/.next-cli-build/server/app/(dashboard)/dashboard/providers/new/page_client-reference-manifest.js +1 -1
  24. package/app/.next-cli-build/server/app/(dashboard)/dashboard/providers/page_client-reference-manifest.js +1 -1
  25. package/app/.next-cli-build/server/app/(dashboard)/dashboard/proxy-pools/page_client-reference-manifest.js +1 -1
  26. package/app/.next-cli-build/server/app/(dashboard)/dashboard/quota/page_client-reference-manifest.js +1 -1
  27. package/app/.next-cli-build/server/app/(dashboard)/dashboard/skills/page_client-reference-manifest.js +1 -1
  28. package/app/.next-cli-build/server/app/(dashboard)/dashboard/translator/page_client-reference-manifest.js +1 -1
  29. package/app/.next-cli-build/server/app/(dashboard)/dashboard/usage/page_client-reference-manifest.js +1 -1
  30. package/app/.next-cli-build/server/app/_global-error/page_client-reference-manifest.js +1 -1
  31. package/app/.next-cli-build/server/app/_global-error.html +1 -1
  32. package/app/.next-cli-build/server/app/_global-error.rsc +1 -1
  33. package/app/.next-cli-build/server/app/_global-error.segments/_full.segment.rsc +1 -1
  34. package/app/.next-cli-build/server/app/_global-error.segments/_global-error/__PAGE__.segment.rsc +1 -1
  35. package/app/.next-cli-build/server/app/_global-error.segments/_global-error.segment.rsc +1 -1
  36. package/app/.next-cli-build/server/app/_global-error.segments/_head.segment.rsc +1 -1
  37. package/app/.next-cli-build/server/app/_global-error.segments/_index.segment.rsc +1 -1
  38. package/app/.next-cli-build/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  39. package/app/.next-cli-build/server/app/_not-found/page_client-reference-manifest.js +1 -1
  40. package/app/.next-cli-build/server/app/_not-found.html +1 -1
  41. package/app/.next-cli-build/server/app/_not-found.rsc +4 -4
  42. package/app/.next-cli-build/server/app/_not-found.segments/_full.segment.rsc +4 -4
  43. package/app/.next-cli-build/server/app/_not-found.segments/_head.segment.rsc +1 -1
  44. package/app/.next-cli-build/server/app/_not-found.segments/_index.segment.rsc +4 -4
  45. package/app/.next-cli-build/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +1 -1
  46. package/app/.next-cli-build/server/app/_not-found.segments/_not-found.segment.rsc +1 -1
  47. package/app/.next-cli-build/server/app/_not-found.segments/_tree.segment.rsc +2 -2
  48. package/app/.next-cli-build/server/app/api/auth/login/route.js.nft.json +1 -1
  49. package/app/.next-cli-build/server/app/api/auth/logout/route.js.nft.json +1 -1
  50. package/app/.next-cli-build/server/app/api/auth/oidc/callback/route.js.nft.json +1 -1
  51. package/app/.next-cli-build/server/app/api/auth/oidc/start/route.js.nft.json +1 -1
  52. package/app/.next-cli-build/server/app/api/auth/oidc/test/route.js.nft.json +1 -1
  53. package/app/.next-cli-build/server/app/api/auth/status/route.js.nft.json +1 -1
  54. package/app/.next-cli-build/server/app/api/cli-tools/all-statuses/route.js.nft.json +1 -1
  55. package/app/.next-cli-build/server/app/api/cli-tools/antigravity-mitm/alias/route.js.nft.json +1 -1
  56. package/app/.next-cli-build/server/app/api/cli-tools/antigravity-mitm/route.js.nft.json +1 -1
  57. package/app/.next-cli-build/server/app/api/cli-tools/copilot-settings/route.js.nft.json +1 -1
  58. package/app/.next-cli-build/server/app/api/cli-tools/cowork-settings/route.js.nft.json +1 -1
  59. package/app/.next-cli-build/server/app/api/combos/[id]/route.js.nft.json +1 -1
  60. package/app/.next-cli-build/server/app/api/combos/reorder/route.js.nft.json +1 -1
  61. package/app/.next-cli-build/server/app/api/combos/route.js.nft.json +1 -1
  62. package/app/.next-cli-build/server/app/api/keys/[id]/route.js.nft.json +1 -1
  63. package/app/.next-cli-build/server/app/api/keys/route.js.nft.json +1 -1
  64. package/app/.next-cli-build/server/app/api/mcp/[plugin]/message/route.js.nft.json +1 -1
  65. package/app/.next-cli-build/server/app/api/mcp/[plugin]/sse/route.js.nft.json +1 -1
  66. package/app/.next-cli-build/server/app/api/media-providers/tts/deepgram/voices/route.js.nft.json +1 -1
  67. package/app/.next-cli-build/server/app/api/media-providers/tts/elevenlabs/voices/route.js.nft.json +1 -1
  68. package/app/.next-cli-build/server/app/api/media-providers/tts/inworld/voices/route.js.nft.json +1 -1
  69. package/app/.next-cli-build/server/app/api/media-providers/tts/minimax/voices/route.js.nft.json +1 -1
  70. package/app/.next-cli-build/server/app/api/models/alias/route.js.nft.json +1 -1
  71. package/app/.next-cli-build/server/app/api/models/availability/route.js.nft.json +1 -1
  72. package/app/.next-cli-build/server/app/api/models/custom/route.js.nft.json +1 -1
  73. package/app/.next-cli-build/server/app/api/models/disabled/route.js.nft.json +1 -1
  74. package/app/.next-cli-build/server/app/api/models/order/route.js.nft.json +1 -1
  75. package/app/.next-cli-build/server/app/api/models/route.js +1 -1
  76. package/app/.next-cli-build/server/app/api/models/route.js.nft.json +1 -1
  77. package/app/.next-cli-build/server/app/api/models/test/route.js +1 -1
  78. package/app/.next-cli-build/server/app/api/models/test/route.js.nft.json +1 -1
  79. package/app/.next-cli-build/server/app/api/oauth/[provider]/[action]/route.js.nft.json +1 -1
  80. package/app/.next-cli-build/server/app/api/oauth/codex/import-token/route.js.nft.json +1 -1
  81. package/app/.next-cli-build/server/app/api/oauth/cursor/import/route.js.nft.json +1 -1
  82. package/app/.next-cli-build/server/app/api/oauth/gitlab/pat/route.js.nft.json +1 -1
  83. package/app/.next-cli-build/server/app/api/oauth/iflow/cookie/route.js.nft.json +1 -1
  84. package/app/.next-cli-build/server/app/api/oauth/kiro/import/route.js.nft.json +1 -1
  85. package/app/.next-cli-build/server/app/api/oauth/kiro/social-exchange/route.js.nft.json +1 -1
  86. package/app/.next-cli-build/server/app/api/pricing/route.js.nft.json +1 -1
  87. package/app/.next-cli-build/server/app/api/provider-nodes/[id]/route.js.nft.json +1 -1
  88. package/app/.next-cli-build/server/app/api/provider-nodes/route.js.nft.json +1 -1
  89. package/app/.next-cli-build/server/app/api/providers/[id]/connections/disabled/route.js.nft.json +1 -1
  90. package/app/.next-cli-build/server/app/api/providers/[id]/models/route.js.nft.json +1 -1
  91. package/app/.next-cli-build/server/app/api/providers/[id]/pool/pull/route.js.nft.json +1 -1
  92. package/app/.next-cli-build/server/app/api/providers/[id]/pool/route.js.nft.json +1 -1
  93. package/app/.next-cli-build/server/app/api/providers/[id]/route.js.nft.json +1 -1
  94. package/app/.next-cli-build/server/app/api/providers/[id]/test/route.js.nft.json +1 -1
  95. package/app/.next-cli-build/server/app/api/providers/[id]/test-models/route.js +1 -1
  96. package/app/.next-cli-build/server/app/api/providers/[id]/test-models/route.js.nft.json +1 -1
  97. package/app/.next-cli-build/server/app/api/providers/client/route.js.nft.json +1 -1
  98. package/app/.next-cli-build/server/app/api/providers/route.js +1 -1
  99. package/app/.next-cli-build/server/app/api/providers/route.js.nft.json +1 -1
  100. package/app/.next-cli-build/server/app/api/providers/test-batch/route.js.nft.json +1 -1
  101. package/app/.next-cli-build/server/app/api/providers/validate/route.js.nft.json +1 -1
  102. package/app/.next-cli-build/server/app/api/proxy-pools/[id]/route.js.nft.json +1 -1
  103. package/app/.next-cli-build/server/app/api/proxy-pools/[id]/test/route.js.nft.json +1 -1
  104. package/app/.next-cli-build/server/app/api/proxy-pools/route.js.nft.json +1 -1
  105. package/app/.next-cli-build/server/app/api/proxy-pools/vercel-deploy/route.js.nft.json +1 -1
  106. package/app/.next-cli-build/server/app/api/settings/database/route.js.nft.json +1 -1
  107. package/app/.next-cli-build/server/app/api/settings/require-login/route.js.nft.json +1 -1
  108. package/app/.next-cli-build/server/app/api/settings/route.js.nft.json +1 -1
  109. package/app/.next-cli-build/server/app/api/translator/console-logs/route.js +1 -1
  110. package/app/.next-cli-build/server/app/api/translator/console-logs/stream/route.js +1 -1
  111. package/app/.next-cli-build/server/app/api/translator/send/route.js.nft.json +1 -1
  112. package/app/.next-cli-build/server/app/api/translator/translate/route.js.nft.json +1 -1
  113. package/app/.next-cli-build/server/app/api/tunnel/disable/route.js.nft.json +1 -1
  114. package/app/.next-cli-build/server/app/api/tunnel/enable/route.js.nft.json +1 -1
  115. package/app/.next-cli-build/server/app/api/tunnel/status/route.js.nft.json +1 -1
  116. package/app/.next-cli-build/server/app/api/tunnel/tailscale-check/route.js.nft.json +1 -1
  117. package/app/.next-cli-build/server/app/api/tunnel/tailscale-disable/route.js.nft.json +1 -1
  118. package/app/.next-cli-build/server/app/api/tunnel/tailscale-enable/route.js.nft.json +1 -1
  119. package/app/.next-cli-build/server/app/api/tunnel/tailscale-install/route.js.nft.json +1 -1
  120. package/app/.next-cli-build/server/app/api/tunnel/tailscale-login/route.js.nft.json +1 -1
  121. package/app/.next-cli-build/server/app/api/tunnel/tailscale-start-daemon/route.js.nft.json +1 -1
  122. package/app/.next-cli-build/server/app/api/usage/[connectionId]/route.js.nft.json +1 -1
  123. package/app/.next-cli-build/server/app/api/usage/chart/route.js.nft.json +1 -1
  124. package/app/.next-cli-build/server/app/api/usage/history/route.js.nft.json +1 -1
  125. package/app/.next-cli-build/server/app/api/usage/providers/route.js.nft.json +1 -1
  126. package/app/.next-cli-build/server/app/api/usage/request-details/route.js.nft.json +1 -1
  127. package/app/.next-cli-build/server/app/api/usage/request-logs/route.js.nft.json +1 -1
  128. package/app/.next-cli-build/server/app/api/usage/stats/route.js.nft.json +1 -1
  129. package/app/.next-cli-build/server/app/api/usage/stream/route.js.nft.json +1 -1
  130. package/app/.next-cli-build/server/app/api/v1/api/chat/route.js.nft.json +1 -1
  131. package/app/.next-cli-build/server/app/api/v1/audio/speech/route.js.nft.json +1 -1
  132. package/app/.next-cli-build/server/app/api/v1/audio/transcriptions/route.js.nft.json +1 -1
  133. package/app/.next-cli-build/server/app/api/v1/chat/completions/route.js.nft.json +1 -1
  134. package/app/.next-cli-build/server/app/api/v1/embeddings/route.js.nft.json +1 -1
  135. package/app/.next-cli-build/server/app/api/v1/images/generations/route.js.nft.json +1 -1
  136. package/app/.next-cli-build/server/app/api/v1/messages/route.js.nft.json +1 -1
  137. package/app/.next-cli-build/server/app/api/v1/models/[kind]/route.js.nft.json +1 -1
  138. package/app/.next-cli-build/server/app/api/v1/models/route.js.nft.json +1 -1
  139. package/app/.next-cli-build/server/app/api/v1/responses/compact/route.js.nft.json +1 -1
  140. package/app/.next-cli-build/server/app/api/v1/responses/route.js.nft.json +1 -1
  141. package/app/.next-cli-build/server/app/api/v1/route.js.nft.json +1 -1
  142. package/app/.next-cli-build/server/app/api/v1/search/route.js.nft.json +1 -1
  143. package/app/.next-cli-build/server/app/api/v1/web/fetch/route.js.nft.json +1 -1
  144. package/app/.next-cli-build/server/app/api/v1beta/models/[...path]/route.js.nft.json +1 -1
  145. package/app/.next-cli-build/server/app/api/version/route.js +1 -1
  146. package/app/.next-cli-build/server/app/api/version/shutdown/route.js +1 -1
  147. package/app/.next-cli-build/server/app/api/version/shutdown/route.js.nft.json +1 -1
  148. package/app/.next-cli-build/server/app/api/version/update/route.js +1 -1
  149. package/app/.next-cli-build/server/app/api/version/update/route.js.nft.json +1 -1
  150. package/app/.next-cli-build/server/app/callback/page_client-reference-manifest.js +1 -1
  151. package/app/.next-cli-build/server/app/callback.html +1 -1
  152. package/app/.next-cli-build/server/app/callback.rsc +4 -4
  153. package/app/.next-cli-build/server/app/callback.segments/_full.segment.rsc +4 -4
  154. package/app/.next-cli-build/server/app/callback.segments/_head.segment.rsc +1 -1
  155. package/app/.next-cli-build/server/app/callback.segments/_index.segment.rsc +4 -4
  156. package/app/.next-cli-build/server/app/callback.segments/_tree.segment.rsc +2 -2
  157. package/app/.next-cli-build/server/app/callback.segments/callback/__PAGE__.segment.rsc +1 -1
  158. package/app/.next-cli-build/server/app/callback.segments/callback.segment.rsc +1 -1
  159. package/app/.next-cli-build/server/app/dashboard/basic-chat.html +1 -1
  160. package/app/.next-cli-build/server/app/dashboard/basic-chat.rsc +6 -6
  161. package/app/.next-cli-build/server/app/dashboard/basic-chat.segments/!KGRhc2hib2FyZCk/dashboard/basic-chat/__PAGE__.segment.rsc +2 -2
  162. package/app/.next-cli-build/server/app/dashboard/basic-chat.segments/!KGRhc2hib2FyZCk/dashboard/basic-chat.segment.rsc +1 -1
  163. package/app/.next-cli-build/server/app/dashboard/basic-chat.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  164. package/app/.next-cli-build/server/app/dashboard/basic-chat.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  165. package/app/.next-cli-build/server/app/dashboard/basic-chat.segments/_full.segment.rsc +6 -6
  166. package/app/.next-cli-build/server/app/dashboard/basic-chat.segments/_head.segment.rsc +1 -1
  167. package/app/.next-cli-build/server/app/dashboard/basic-chat.segments/_index.segment.rsc +4 -4
  168. package/app/.next-cli-build/server/app/dashboard/basic-chat.segments/_tree.segment.rsc +2 -2
  169. package/app/.next-cli-build/server/app/dashboard/cli-tools.html +1 -1
  170. package/app/.next-cli-build/server/app/dashboard/cli-tools.rsc +6 -6
  171. package/app/.next-cli-build/server/app/dashboard/cli-tools.segments/!KGRhc2hib2FyZCk/dashboard/cli-tools/__PAGE__.segment.rsc +2 -2
  172. package/app/.next-cli-build/server/app/dashboard/cli-tools.segments/!KGRhc2hib2FyZCk/dashboard/cli-tools.segment.rsc +1 -1
  173. package/app/.next-cli-build/server/app/dashboard/cli-tools.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  174. package/app/.next-cli-build/server/app/dashboard/cli-tools.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  175. package/app/.next-cli-build/server/app/dashboard/cli-tools.segments/_full.segment.rsc +6 -6
  176. package/app/.next-cli-build/server/app/dashboard/cli-tools.segments/_head.segment.rsc +1 -1
  177. package/app/.next-cli-build/server/app/dashboard/cli-tools.segments/_index.segment.rsc +4 -4
  178. package/app/.next-cli-build/server/app/dashboard/cli-tools.segments/_tree.segment.rsc +2 -2
  179. package/app/.next-cli-build/server/app/dashboard/combos.html +1 -1
  180. package/app/.next-cli-build/server/app/dashboard/combos.rsc +6 -6
  181. package/app/.next-cli-build/server/app/dashboard/combos.segments/!KGRhc2hib2FyZCk/dashboard/combos/__PAGE__.segment.rsc +2 -2
  182. package/app/.next-cli-build/server/app/dashboard/combos.segments/!KGRhc2hib2FyZCk/dashboard/combos.segment.rsc +1 -1
  183. package/app/.next-cli-build/server/app/dashboard/combos.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  184. package/app/.next-cli-build/server/app/dashboard/combos.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  185. package/app/.next-cli-build/server/app/dashboard/combos.segments/_full.segment.rsc +6 -6
  186. package/app/.next-cli-build/server/app/dashboard/combos.segments/_head.segment.rsc +1 -1
  187. package/app/.next-cli-build/server/app/dashboard/combos.segments/_index.segment.rsc +4 -4
  188. package/app/.next-cli-build/server/app/dashboard/combos.segments/_tree.segment.rsc +2 -2
  189. package/app/.next-cli-build/server/app/dashboard/endpoint.html +1 -1
  190. package/app/.next-cli-build/server/app/dashboard/endpoint.rsc +6 -6
  191. package/app/.next-cli-build/server/app/dashboard/endpoint.segments/!KGRhc2hib2FyZCk/dashboard/endpoint/__PAGE__.segment.rsc +2 -2
  192. package/app/.next-cli-build/server/app/dashboard/endpoint.segments/!KGRhc2hib2FyZCk/dashboard/endpoint.segment.rsc +1 -1
  193. package/app/.next-cli-build/server/app/dashboard/endpoint.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  194. package/app/.next-cli-build/server/app/dashboard/endpoint.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  195. package/app/.next-cli-build/server/app/dashboard/endpoint.segments/_full.segment.rsc +6 -6
  196. package/app/.next-cli-build/server/app/dashboard/endpoint.segments/_head.segment.rsc +1 -1
  197. package/app/.next-cli-build/server/app/dashboard/endpoint.segments/_index.segment.rsc +4 -4
  198. package/app/.next-cli-build/server/app/dashboard/endpoint.segments/_tree.segment.rsc +2 -2
  199. package/app/.next-cli-build/server/app/dashboard/media-providers/web.html +1 -1
  200. package/app/.next-cli-build/server/app/dashboard/media-providers/web.rsc +6 -6
  201. package/app/.next-cli-build/server/app/dashboard/media-providers/web.segments/!KGRhc2hib2FyZCk/dashboard/media-providers/web/__PAGE__.segment.rsc +2 -2
  202. package/app/.next-cli-build/server/app/dashboard/media-providers/web.segments/!KGRhc2hib2FyZCk/dashboard/media-providers/web.segment.rsc +1 -1
  203. package/app/.next-cli-build/server/app/dashboard/media-providers/web.segments/!KGRhc2hib2FyZCk/dashboard/media-providers.segment.rsc +1 -1
  204. package/app/.next-cli-build/server/app/dashboard/media-providers/web.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  205. package/app/.next-cli-build/server/app/dashboard/media-providers/web.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  206. package/app/.next-cli-build/server/app/dashboard/media-providers/web.segments/_full.segment.rsc +6 -6
  207. package/app/.next-cli-build/server/app/dashboard/media-providers/web.segments/_head.segment.rsc +1 -1
  208. package/app/.next-cli-build/server/app/dashboard/media-providers/web.segments/_index.segment.rsc +4 -4
  209. package/app/.next-cli-build/server/app/dashboard/media-providers/web.segments/_tree.segment.rsc +2 -2
  210. package/app/.next-cli-build/server/app/dashboard/mitm.html +1 -1
  211. package/app/.next-cli-build/server/app/dashboard/mitm.rsc +6 -6
  212. package/app/.next-cli-build/server/app/dashboard/mitm.segments/!KGRhc2hib2FyZCk/dashboard/mitm/__PAGE__.segment.rsc +2 -2
  213. package/app/.next-cli-build/server/app/dashboard/mitm.segments/!KGRhc2hib2FyZCk/dashboard/mitm.segment.rsc +1 -1
  214. package/app/.next-cli-build/server/app/dashboard/mitm.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  215. package/app/.next-cli-build/server/app/dashboard/mitm.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  216. package/app/.next-cli-build/server/app/dashboard/mitm.segments/_full.segment.rsc +6 -6
  217. package/app/.next-cli-build/server/app/dashboard/mitm.segments/_head.segment.rsc +1 -1
  218. package/app/.next-cli-build/server/app/dashboard/mitm.segments/_index.segment.rsc +4 -4
  219. package/app/.next-cli-build/server/app/dashboard/mitm.segments/_tree.segment.rsc +2 -2
  220. package/app/.next-cli-build/server/app/dashboard/profile.html +1 -1
  221. package/app/.next-cli-build/server/app/dashboard/profile.rsc +6 -6
  222. package/app/.next-cli-build/server/app/dashboard/profile.segments/!KGRhc2hib2FyZCk/dashboard/profile/__PAGE__.segment.rsc +2 -2
  223. package/app/.next-cli-build/server/app/dashboard/profile.segments/!KGRhc2hib2FyZCk/dashboard/profile.segment.rsc +1 -1
  224. package/app/.next-cli-build/server/app/dashboard/profile.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  225. package/app/.next-cli-build/server/app/dashboard/profile.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  226. package/app/.next-cli-build/server/app/dashboard/profile.segments/_full.segment.rsc +6 -6
  227. package/app/.next-cli-build/server/app/dashboard/profile.segments/_head.segment.rsc +1 -1
  228. package/app/.next-cli-build/server/app/dashboard/profile.segments/_index.segment.rsc +4 -4
  229. package/app/.next-cli-build/server/app/dashboard/profile.segments/_tree.segment.rsc +2 -2
  230. package/app/.next-cli-build/server/app/dashboard/providers/new.html +1 -1
  231. package/app/.next-cli-build/server/app/dashboard/providers/new.rsc +6 -6
  232. package/app/.next-cli-build/server/app/dashboard/providers/new.segments/!KGRhc2hib2FyZCk/dashboard/providers/new/__PAGE__.segment.rsc +2 -2
  233. package/app/.next-cli-build/server/app/dashboard/providers/new.segments/!KGRhc2hib2FyZCk/dashboard/providers/new.segment.rsc +1 -1
  234. package/app/.next-cli-build/server/app/dashboard/providers/new.segments/!KGRhc2hib2FyZCk/dashboard/providers.segment.rsc +1 -1
  235. package/app/.next-cli-build/server/app/dashboard/providers/new.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  236. package/app/.next-cli-build/server/app/dashboard/providers/new.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  237. package/app/.next-cli-build/server/app/dashboard/providers/new.segments/_full.segment.rsc +6 -6
  238. package/app/.next-cli-build/server/app/dashboard/providers/new.segments/_head.segment.rsc +1 -1
  239. package/app/.next-cli-build/server/app/dashboard/providers/new.segments/_index.segment.rsc +4 -4
  240. package/app/.next-cli-build/server/app/dashboard/providers/new.segments/_tree.segment.rsc +2 -2
  241. package/app/.next-cli-build/server/app/dashboard/providers.html +1 -1
  242. package/app/.next-cli-build/server/app/dashboard/providers.rsc +6 -6
  243. package/app/.next-cli-build/server/app/dashboard/providers.segments/!KGRhc2hib2FyZCk/dashboard/providers/__PAGE__.segment.rsc +2 -2
  244. package/app/.next-cli-build/server/app/dashboard/providers.segments/!KGRhc2hib2FyZCk/dashboard/providers.segment.rsc +1 -1
  245. package/app/.next-cli-build/server/app/dashboard/providers.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  246. package/app/.next-cli-build/server/app/dashboard/providers.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  247. package/app/.next-cli-build/server/app/dashboard/providers.segments/_full.segment.rsc +6 -6
  248. package/app/.next-cli-build/server/app/dashboard/providers.segments/_head.segment.rsc +1 -1
  249. package/app/.next-cli-build/server/app/dashboard/providers.segments/_index.segment.rsc +4 -4
  250. package/app/.next-cli-build/server/app/dashboard/providers.segments/_tree.segment.rsc +2 -2
  251. package/app/.next-cli-build/server/app/dashboard/proxy-pools.html +1 -1
  252. package/app/.next-cli-build/server/app/dashboard/proxy-pools.rsc +6 -6
  253. package/app/.next-cli-build/server/app/dashboard/proxy-pools.segments/!KGRhc2hib2FyZCk/dashboard/proxy-pools/__PAGE__.segment.rsc +2 -2
  254. package/app/.next-cli-build/server/app/dashboard/proxy-pools.segments/!KGRhc2hib2FyZCk/dashboard/proxy-pools.segment.rsc +1 -1
  255. package/app/.next-cli-build/server/app/dashboard/proxy-pools.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  256. package/app/.next-cli-build/server/app/dashboard/proxy-pools.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  257. package/app/.next-cli-build/server/app/dashboard/proxy-pools.segments/_full.segment.rsc +6 -6
  258. package/app/.next-cli-build/server/app/dashboard/proxy-pools.segments/_head.segment.rsc +1 -1
  259. package/app/.next-cli-build/server/app/dashboard/proxy-pools.segments/_index.segment.rsc +4 -4
  260. package/app/.next-cli-build/server/app/dashboard/proxy-pools.segments/_tree.segment.rsc +2 -2
  261. package/app/.next-cli-build/server/app/dashboard/quota.html +2 -2
  262. package/app/.next-cli-build/server/app/dashboard/quota.rsc +7 -7
  263. package/app/.next-cli-build/server/app/dashboard/quota.segments/!KGRhc2hib2FyZCk/dashboard/quota/__PAGE__.segment.rsc +3 -3
  264. package/app/.next-cli-build/server/app/dashboard/quota.segments/!KGRhc2hib2FyZCk/dashboard/quota.segment.rsc +1 -1
  265. package/app/.next-cli-build/server/app/dashboard/quota.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  266. package/app/.next-cli-build/server/app/dashboard/quota.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  267. package/app/.next-cli-build/server/app/dashboard/quota.segments/_full.segment.rsc +7 -7
  268. package/app/.next-cli-build/server/app/dashboard/quota.segments/_head.segment.rsc +1 -1
  269. package/app/.next-cli-build/server/app/dashboard/quota.segments/_index.segment.rsc +4 -4
  270. package/app/.next-cli-build/server/app/dashboard/quota.segments/_tree.segment.rsc +2 -2
  271. package/app/.next-cli-build/server/app/dashboard/settings/pricing/page_client-reference-manifest.js +1 -1
  272. package/app/.next-cli-build/server/app/dashboard/settings/pricing.html +1 -1
  273. package/app/.next-cli-build/server/app/dashboard/settings/pricing.rsc +4 -4
  274. package/app/.next-cli-build/server/app/dashboard/settings/pricing.segments/_full.segment.rsc +4 -4
  275. package/app/.next-cli-build/server/app/dashboard/settings/pricing.segments/_head.segment.rsc +1 -1
  276. package/app/.next-cli-build/server/app/dashboard/settings/pricing.segments/_index.segment.rsc +4 -4
  277. package/app/.next-cli-build/server/app/dashboard/settings/pricing.segments/_tree.segment.rsc +2 -2
  278. package/app/.next-cli-build/server/app/dashboard/settings/pricing.segments/dashboard/settings/pricing/__PAGE__.segment.rsc +1 -1
  279. package/app/.next-cli-build/server/app/dashboard/settings/pricing.segments/dashboard/settings/pricing.segment.rsc +1 -1
  280. package/app/.next-cli-build/server/app/dashboard/settings/pricing.segments/dashboard/settings.segment.rsc +1 -1
  281. package/app/.next-cli-build/server/app/dashboard/settings/pricing.segments/dashboard.segment.rsc +1 -1
  282. package/app/.next-cli-build/server/app/dashboard/skills.html +1 -1
  283. package/app/.next-cli-build/server/app/dashboard/skills.rsc +6 -6
  284. package/app/.next-cli-build/server/app/dashboard/skills.segments/!KGRhc2hib2FyZCk/dashboard/skills/__PAGE__.segment.rsc +2 -2
  285. package/app/.next-cli-build/server/app/dashboard/skills.segments/!KGRhc2hib2FyZCk/dashboard/skills.segment.rsc +1 -1
  286. package/app/.next-cli-build/server/app/dashboard/skills.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  287. package/app/.next-cli-build/server/app/dashboard/skills.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  288. package/app/.next-cli-build/server/app/dashboard/skills.segments/_full.segment.rsc +6 -6
  289. package/app/.next-cli-build/server/app/dashboard/skills.segments/_head.segment.rsc +1 -1
  290. package/app/.next-cli-build/server/app/dashboard/skills.segments/_index.segment.rsc +4 -4
  291. package/app/.next-cli-build/server/app/dashboard/skills.segments/_tree.segment.rsc +2 -2
  292. package/app/.next-cli-build/server/app/dashboard/translator.html +1 -1
  293. package/app/.next-cli-build/server/app/dashboard/translator.rsc +6 -6
  294. package/app/.next-cli-build/server/app/dashboard/translator.segments/!KGRhc2hib2FyZCk/dashboard/translator/__PAGE__.segment.rsc +2 -2
  295. package/app/.next-cli-build/server/app/dashboard/translator.segments/!KGRhc2hib2FyZCk/dashboard/translator.segment.rsc +1 -1
  296. package/app/.next-cli-build/server/app/dashboard/translator.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  297. package/app/.next-cli-build/server/app/dashboard/translator.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  298. package/app/.next-cli-build/server/app/dashboard/translator.segments/_full.segment.rsc +6 -6
  299. package/app/.next-cli-build/server/app/dashboard/translator.segments/_head.segment.rsc +1 -1
  300. package/app/.next-cli-build/server/app/dashboard/translator.segments/_index.segment.rsc +4 -4
  301. package/app/.next-cli-build/server/app/dashboard/translator.segments/_tree.segment.rsc +2 -2
  302. package/app/.next-cli-build/server/app/dashboard/usage.html +1 -1
  303. package/app/.next-cli-build/server/app/dashboard/usage.rsc +6 -6
  304. package/app/.next-cli-build/server/app/dashboard/usage.segments/!KGRhc2hib2FyZCk/dashboard/usage/__PAGE__.segment.rsc +2 -2
  305. package/app/.next-cli-build/server/app/dashboard/usage.segments/!KGRhc2hib2FyZCk/dashboard/usage.segment.rsc +1 -1
  306. package/app/.next-cli-build/server/app/dashboard/usage.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  307. package/app/.next-cli-build/server/app/dashboard/usage.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  308. package/app/.next-cli-build/server/app/dashboard/usage.segments/_full.segment.rsc +6 -6
  309. package/app/.next-cli-build/server/app/dashboard/usage.segments/_head.segment.rsc +1 -1
  310. package/app/.next-cli-build/server/app/dashboard/usage.segments/_index.segment.rsc +4 -4
  311. package/app/.next-cli-build/server/app/dashboard/usage.segments/_tree.segment.rsc +2 -2
  312. package/app/.next-cli-build/server/app/dashboard.html +1 -1
  313. package/app/.next-cli-build/server/app/dashboard.rsc +6 -6
  314. package/app/.next-cli-build/server/app/dashboard.segments/!KGRhc2hib2FyZCk/dashboard/__PAGE__.segment.rsc +2 -2
  315. package/app/.next-cli-build/server/app/dashboard.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  316. package/app/.next-cli-build/server/app/dashboard.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  317. package/app/.next-cli-build/server/app/dashboard.segments/_full.segment.rsc +6 -6
  318. package/app/.next-cli-build/server/app/dashboard.segments/_head.segment.rsc +1 -1
  319. package/app/.next-cli-build/server/app/dashboard.segments/_index.segment.rsc +4 -4
  320. package/app/.next-cli-build/server/app/dashboard.segments/_tree.segment.rsc +2 -2
  321. package/app/.next-cli-build/server/app/index.html +1 -1
  322. package/app/.next-cli-build/server/app/index.rsc +4 -4
  323. package/app/.next-cli-build/server/app/index.segments/__PAGE__.segment.rsc +1 -1
  324. package/app/.next-cli-build/server/app/index.segments/_full.segment.rsc +4 -4
  325. package/app/.next-cli-build/server/app/index.segments/_head.segment.rsc +1 -1
  326. package/app/.next-cli-build/server/app/index.segments/_index.segment.rsc +4 -4
  327. package/app/.next-cli-build/server/app/index.segments/_tree.segment.rsc +2 -2
  328. package/app/.next-cli-build/server/app/landing/page_client-reference-manifest.js +1 -1
  329. package/app/.next-cli-build/server/app/landing.html +1 -1
  330. package/app/.next-cli-build/server/app/landing.rsc +4 -4
  331. package/app/.next-cli-build/server/app/landing.segments/_full.segment.rsc +4 -4
  332. package/app/.next-cli-build/server/app/landing.segments/_head.segment.rsc +1 -1
  333. package/app/.next-cli-build/server/app/landing.segments/_index.segment.rsc +4 -4
  334. package/app/.next-cli-build/server/app/landing.segments/_tree.segment.rsc +2 -2
  335. package/app/.next-cli-build/server/app/landing.segments/landing/__PAGE__.segment.rsc +1 -1
  336. package/app/.next-cli-build/server/app/landing.segments/landing.segment.rsc +1 -1
  337. package/app/.next-cli-build/server/app/login/page_client-reference-manifest.js +1 -1
  338. package/app/.next-cli-build/server/app/login.html +1 -1
  339. package/app/.next-cli-build/server/app/login.rsc +5 -5
  340. package/app/.next-cli-build/server/app/login.segments/_full.segment.rsc +5 -5
  341. package/app/.next-cli-build/server/app/login.segments/_head.segment.rsc +1 -1
  342. package/app/.next-cli-build/server/app/login.segments/_index.segment.rsc +4 -4
  343. package/app/.next-cli-build/server/app/login.segments/_tree.segment.rsc +2 -2
  344. package/app/.next-cli-build/server/app/login.segments/login/__PAGE__.segment.rsc +2 -2
  345. package/app/.next-cli-build/server/app/login.segments/login.segment.rsc +1 -1
  346. package/app/.next-cli-build/server/app/page_client-reference-manifest.js +1 -1
  347. package/app/.next-cli-build/server/app-paths-manifest.json +12 -12
  348. package/app/.next-cli-build/server/chunks/2722.js +1 -1
  349. package/app/.next-cli-build/server/chunks/3110.js +1 -1
  350. package/app/.next-cli-build/server/chunks/4304.js +1 -1
  351. package/app/.next-cli-build/server/chunks/4372.js +1 -1
  352. package/app/.next-cli-build/server/chunks/4746.js +1 -1
  353. package/app/.next-cli-build/server/chunks/5681.js +1 -1
  354. package/app/.next-cli-build/server/chunks/6936.js +2 -2
  355. package/app/.next-cli-build/server/chunks/7153.js +1 -1
  356. package/app/.next-cli-build/server/chunks/914.js +1 -1
  357. package/app/.next-cli-build/server/middleware-build-manifest.js +1 -1
  358. package/app/.next-cli-build/server/middleware.js +1 -1
  359. package/app/.next-cli-build/server/pages/404.html +1 -1
  360. package/app/.next-cli-build/server/pages/500.html +1 -1
  361. package/app/.next-cli-build/static/chunks/{1321-48b3e6f66082983d.js → 1321-05841736b0aebea9.js} +1 -1
  362. package/app/.next-cli-build/static/chunks/{6069-5666665a06945192.js → 6069-cc2decdd4cf8a742.js} +1 -1
  363. package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/providers/[id]/page-294ac9def923be4f.js +3 -0
  364. package/app/.next-cli-build/static/css/090d5175372e4b28.css +1 -0
  365. package/app/cli/.build-home/.9router/db/backups/upgrade-0.4.80-to-0.4.81-0.4.81-20260619-094420/data.sqlite +0 -0
  366. package/app/cli/.build-home/.9router/db/backups/upgrade-0.4.81-to-0.4.82-0.4.82-20260619-102225/data.sqlite +0 -0
  367. package/app/cli/.build-home/.9router/db/backups/upgrade-0.4.82-to-0.4.83-0.4.83-20260625-090010/data.sqlite +0 -0
  368. package/app/cli/.build-home/.9router/db/data.sqlite +0 -0
  369. package/app/package.json +1 -1
  370. package/app/src/mitm/server.js +26 -26
  371. package/package.json +1 -1
  372. package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/providers/[id]/page-535882a5b15c01fd.js +0 -3
  373. package/app/.next-cli-build/static/css/15d7170a78b6a4fd.css +0 -1
  374. /package/app/.next-cli-build/static/{g9K5MbWNgLVJw3cx8SwXw → 9pWCR3GBR9T6_7Z25txkG}/_buildManifest.js +0 -0
  375. /package/app/.next-cli-build/static/{g9K5MbWNgLVJw3cx8SwXw → 9pWCR3GBR9T6_7Z25txkG}/_ssgManifest.js +0 -0
@@ -20,7 +20,7 @@ amp --model "{{model}}"
20
20
  "model": {
21
21
  "name": "{{model}}"
22
22
  }
23
- }`}},"deepseek-tui":{id:"deepseek-tui",name:"DeepSeek TUI",image:"/providers/deepseek-tui.png",color:"#4D6BFE",description:"DeepSeek Terminal Coding Agent (Rust TUI)",docsUrl:"https://github.com/DeepSeek-TUI/DeepSeek-TUI",configType:"custom",defaultCommand:"deepseek",modelAliases:["deepseek-v4-pro","deepseek-v4-flash","deepseek-chat","deepseek-reasoner"],defaultModels:[{id:"deepseek-v4-pro",name:"DeepSeek V4 Pro",alias:"deepseek-v4-pro"},{id:"deepseek-v4-flash",name:"DeepSeek V4 Flash",alias:"deepseek-v4-flash"},{id:"deepseek-chat",name:"DeepSeek V3 Chat",alias:"deepseek-chat"}],notes:[{type:"info",text:"DeepSeek TUI uses ~/.deepseek/config.toml for configuration. 9Router will update the provider to 'openai' mode with your base_url, api_key, and model."},{type:"warning",text:"Config path: Linux/macOS ~/.deepseek/config.toml • Windows %USERPROFILE%\\.deepseek\\config.toml"}]},jcode:{id:"jcode",name:"jcode",image:"/providers/jcode.png",color:"#FF6B35",description:"High-performance Rust-based coding agent harness",configType:"custom",docsUrl:"https://github.com/1jehuang/jcode",notes:[{type:"info",text:"jcode is a Rust-based coding agent with semantic memory, multi-agent swarms, and extreme performance (27.8 MB RAM, 14ms boot)."},{type:"info",text:"Configure 9router as an OpenAI-compatible provider to route all jcode requests through 9router's optimization layer."},{type:"warning",text:"Requires jcode installed. Install via: curl -fsSL https://raw.githubusercontent.com/1jehuang/jcode/master/scripts/install.sh | bash"}],defaultModels:[{id:"claude-opus-4-7",name:"Claude Opus 4.7",alias:"opus",defaultValue:"cc/claude-opus-4-7"},{id:"claude-sonnet-4-6",name:"Claude Sonnet 4.6",alias:"sonnet",defaultValue:"cc/claude-sonnet-4-6"},{id:"gpt-5.5",name:"GPT 5.5",alias:"gpt5",defaultValue:"cx/gpt-5.5"},{id:"gemini-3.1-pro",name:"Gemini 3.1 Pro",alias:"gemini",defaultValue:"gemini/gemini-3.1-pro"}]}}},40295:e=>{e.exports={TOOL_HOSTS:{antigravity:["daily-cloudcode-pa.googleapis.com","cloudcode-pa.googleapis.com"],copilot:["api.individual.githubcopilot.com"],kiro:["q.us-east-1.amazonaws.com","codewhisperer.us-east-1.amazonaws.com"],cursor:["api2.cursor.sh"]}}},43666:(e,t,s)=>{s.d(t,{Tk:()=>y,aG:()=>P,Ah:()=>b,h1:()=>M,Q6:()=>O,lF:()=>R,a7:()=>_,ZM:()=>N,RF:()=>k,mW:()=>U,c9:()=>$,gY:()=>q,tA:()=>D,kn:()=>z,yZ:()=>v,qO:()=>S});var l=s(95155),a=s(12115),r=s(35497),i=s(5772),n=s(90620);let o="9router.cliToolEndpointPresets",d="__custom__",c="__save__",m=e=>{window.localStorage.setItem(o,JSON.stringify(e))};function x({value:e,onChange:t,requiresExternalUrl:s=!1,tunnelEnabled:r=!1,tunnelPublicUrl:i="",tailscaleEnabled:p=!1,tailscaleUrl:u="",cloudEnabled:h=!1,cloudUrl:g="",withV1:f=!0}){let[y,b]=(0,a.useState)([]),[j,N]=(0,a.useState)(""),[v,w]=(0,a.useState)(""),k=(0,a.useRef)(!1);(0,a.useEffect)(()=>{b((()=>{try{let e=JSON.parse(window.localStorage.getItem(o)||"[]");if(!Array.isArray(e))return[];return e.filter(e=>e?.name&&e?.baseUrl)}catch{return[]}})())},[]);let C=(0,a.useMemo)(()=>(({requiresExternalUrl:e,tunnelEnabled:t,tunnelPublicUrl:s,tailscaleEnabled:l,tailscaleUrl:a,cloudEnabled:r,cloudUrl:i,savedPresets:o,withV1:c})=>{let m=[],x=e=>{let t;return c?(t=(e||"").replace(/\/+$/,""))?/\/v1$/.test(t)?t:`${t}/v1`:"":(e||"").replace(/\/+$/,"")};if(!e){let e=x(`http://127.0.0.1:${n.h0.appPort}`);m.push({value:"local",label:e,url:e})}if(t&&s){let e=x(s);m.push({value:"tunnel",label:e,url:e})}if(l&&a){let e=x(a);m.push({value:"tailscale",label:e,url:e})}if(r&&i){let e=x(i);m.push({value:"cloud",label:e,url:e})}return o.forEach(e=>{m.push({value:`saved:${e.name}`,label:e.baseUrl,url:e.baseUrl,saved:!0})}),m.push({value:d,label:"Custom URL...",url:""}),m})({requiresExternalUrl:s,tunnelEnabled:r,tunnelPublicUrl:i,tailscaleEnabled:p,tailscaleUrl:u,cloudEnabled:h,cloudUrl:g,savedPresets:y,withV1:f}),[s,r,i,p,u,h,g,y,f]);(0,a.useEffect)(()=>{if(k.current||0===C.length)return;k.current=!0;let e=C.find(e=>e.value!==d);e?(N(e.value),t(e.url)):N(d)},[C,t]);let _=j.startsWith("saved:"),S=j===d,E=S&&(v||"").trim().length>0;return(0,l.jsxs)("div",{className:"flex flex-col gap-1.5",children:[(0,l.jsxs)("div",{className:"flex items-center gap-2",children:[(0,l.jsxs)("select",{value:j,onChange:s=>{let l=s.target.value;if(l===c){let t=(e||"").trim();if(!t)return;let s=t;try{s=new URL(t).host}catch{}let l=window.prompt("Save endpoint as:",s);if(!l?.trim())return;let a=[...y.filter(e=>e.name!==l.trim()),{name:l.trim(),baseUrl:t}].sort((e,t)=>e.name.localeCompare(t.name));b(a),m(a);return}if(N(l),l===d){w(""),t("");return}let a=C.find(e=>e.value===l);a&&t(a.url)},className:"flex-1 min-w-0 px-2 py-2 bg-surface rounded text-xs border border-border focus:outline-none focus:ring-1 focus:ring-primary/50 sm:py-1.5",children:[C.map(e=>(0,l.jsx)("option",{value:e.value,children:e.label},e.value)),E&&(0,l.jsx)("option",{value:c,children:"+ Save current as..."})]}),_&&(0,l.jsx)("button",{type:"button",onClick:()=>{if(!j.startsWith("saved:"))return;let e=j.slice(6),s=y.filter(t=>t.name!==e);b(s),m(s),N(d),w(""),t("")},className:"p-1 text-text-muted hover:text-red-500 rounded transition-colors shrink-0",title:"Delete saved endpoint",children:(0,l.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"delete"})})]}),S&&(0,l.jsx)("input",{type:"text",value:v,onChange:e=>{let s=e.target.value;w(s),t(s)},placeholder:f?"https://example.com/v1":"https://example.com",className:"w-full min-w-0 px-2 py-2 bg-surface rounded border border-border text-xs focus:outline-none focus:ring-1 focus:ring-primary/50 sm:py-1.5"})]})}let p="__custom__";function u({value:e,onChange:t,apiKeys:s=[],cloudEnabled:r=!1,className:i=""}){let n=!s.some(t=>t.key===e)&&""!==e,[o,d]=(0,a.useState)(()=>e?s.some(t=>t.key===e)?e:p:s.length>0?s[0].key:p),[c,m]=(0,a.useState)(n?e:"");return 0===s.length&&o!==p&&o!==p?(0,l.jsx)("span",{className:`min-w-0 rounded bg-surface/40 px-2 py-2 text-xs text-text-muted sm:py-1.5 ${i}`,children:r?"No API keys - Create one in Keys page":"sk_9router (default)"}):(0,l.jsxs)("div",{className:`flex flex-col gap-1.5 ${i}`,children:[(0,l.jsxs)("select",{value:o,onChange:e=>{let s=e.target.value;d(s),s===p?(m(""),t("")):t(s)},className:"w-full min-w-0 px-2 py-2 bg-surface rounded text-xs border border-border focus:outline-none focus:ring-1 focus:ring-primary/50 sm:py-1.5",children:[s.map(e=>(0,l.jsx)("option",{value:e.key,children:e.key},e.id)),(0,l.jsx)("option",{value:p,children:"Custom..."})]}),o===p&&(0,l.jsx)("input",{type:"text",value:c,onChange:e=>{let s=e.target.value;m(s),t(s)},placeholder:"sk-...",className:"w-full min-w-0 px-2 py-2 bg-surface rounded border border-border text-xs focus:outline-none focus:ring-1 focus:ring-primary/50 sm:py-1.5"})]})}let h=e=>(e||"").replace(/\/+$/,"");function g(e,t={}){if(!e)return!1;let s=h(e),{tunnelPublicUrl:l,tailscaleUrl:a,cloudUrl:r}=t;return!!(/localhost|127\.0\.0\.1|0\.0\.0\.0/.test(s)||l&&s.startsWith(h(l))||a&&s.startsWith(h(a))||r&&s.startsWith(h(r)))}let f=s(41463).env.NEXT_PUBLIC_CLOUD_URL;function y({tool:e,isExpanded:t,onToggle:s,activeProviders:n,modelMappings:o,onModelMappingChange:d,baseUrl:c,hasActiveProviders:m,apiKeys:p,cloudEnabled:h,initialStatus:b,tunnelEnabled:j,tunnelPublicUrl:N,tailscaleEnabled:v,tailscaleUrl:w}){let k,C,_,[S,E]=(0,a.useState)(b||null),[A,O]=(0,a.useState)(!1),[M,P]=(0,a.useState)(!1),[$,I]=(0,a.useState)(!1),[R,U]=(0,a.useState)(null),[T,D]=(0,a.useState)(!1),[K,z]=(0,a.useState)(!1),[L,F]=(0,a.useState)(null),[q,H]=(0,a.useState)(""),[B,W]=(0,a.useState)({}),[J,G]=(0,a.useState)(!1),[V,Y]=(0,a.useState)(""),[Z,Q]=(0,a.useState)(!1),X=(0,a.useRef)(!1),ee=(()=>{if(!S?.installed)return null;let e=S.settings?.env?.ANTHROPIC_BASE_URL;return e?g(e,{tunnelPublicUrl:N,tailscaleUrl:w,cloudUrl:h?f:null})?"configured":"other":"not_configured"})();(0,a.useEffect)(()=>{p?.length>0&&!q&&H(p[0].key)},[p,q]),(0,a.useEffect)(()=>{b&&E(b)},[b]),(0,a.useEffect)(()=>{t&&!S&&(el(),es()),t&&es()},[t]),(0,a.useEffect)(()=>{fetch("/api/settings").then(e=>e.json()).then(e=>{Q(!!e.ccFilterNaming)}).catch(()=>{})},[]);let et=async e=>{let t=e.target.checked;Q(t),await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({ccFilterNaming:t})}).catch(()=>{})},es=async()=>{try{let e=await fetch("/api/models/alias"),t=await e.json();e.ok&&W(t.aliases||{})}catch(e){console.log("Error fetching model aliases:",e)}};(0,a.useEffect)(()=>{if(S?.installed&&!X.current){X.current=!0;let t=S.settings?.env||{};e.defaultModels.forEach(e=>{if(e.envKey){let s=t[e.envKey]||e.defaultValue||"";s&&d(e.alias,s)}});let s=t.ANTHROPIC_AUTH_TOKEN;s&&p?.some(e=>e.key===s)&&H(s)}},[S,p,e.defaultModels,d]);let el=async()=>{O(!0);try{let e=await fetch("/api/cli-tools/claude-settings"),t=await e.json();E(t)}catch(e){E({installed:!1,error:e.message})}finally{O(!1)}},ea=()=>{let e=V||c;return e.endsWith("/v1")?e:`${e}/v1`},er=async()=>{P(!0),U(null);try{let t={ANTHROPIC_BASE_URL:ea()},s=q?.trim()||(p?.length>0?p[0].key:null)||(h?null:"sk_9router");s&&(t.ANTHROPIC_AUTH_TOKEN=s),e.defaultModels.forEach(e=>{let s=o[e.alias];s&&e.envKey&&(t[e.envKey]=s)});let l=await fetch("/api/cli-tools/claude-settings",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({env:t})}),a=await l.json();l.ok?(U({type:"success",text:"Settings applied successfully!"}),E(e=>({...e,hasBackup:!0,settings:{...e?.settings,env:t}}))):U({type:"error",text:a.error||"Failed to apply settings"})}catch(e){U({type:"error",text:e.message})}finally{P(!1)}},ei=async()=>{I(!0),U(null);try{let t=await fetch("/api/cli-tools/claude-settings",{method:"DELETE"}),s=await t.json();t.ok?(U({type:"success",text:"Settings reset successfully!"}),e.defaultModels.forEach(e=>d(e.alias,e.defaultValue||"")),H("")):U({type:"error",text:s.error||"Failed to reset settings"})}catch(e){U({type:"error",text:e.message})}finally{I(!1)}};return(0,l.jsxs)(r.Zp,{padding:"xs",className:"overflow-hidden",children:[(0,l.jsxs)("div",{className:"flex items-start justify-between gap-3 hover:cursor-pointer sm:items-center",onClick:s,children:[(0,l.jsxs)("div",{className:"flex min-w-0 items-center gap-3",children:[(0,l.jsx)("div",{className:"size-8 flex items-center justify-center shrink-0",children:(0,l.jsx)(i.default,{src:"/providers/claude.png",alt:e.name,width:32,height:32,className:"size-8 object-contain rounded-lg",sizes:"32px",onError:e=>{e.target.style.display="none"}})}),(0,l.jsxs)("div",{className:"min-w-0",children:[(0,l.jsxs)("div",{className:"flex min-w-0 flex-wrap items-center gap-2",children:[(0,l.jsx)("h3",{className:"font-medium text-sm",children:e.name}),"configured"===ee&&(0,l.jsx)("span",{className:"px-1.5 py-0.5 text-[10px] font-medium bg-green-500/10 text-green-600 dark:text-green-400 rounded-full",children:"Connected"}),"not_configured"===ee&&(0,l.jsx)("span",{className:"px-1.5 py-0.5 text-[10px] font-medium bg-yellow-500/10 text-yellow-600 dark:text-yellow-400 rounded-full",children:"Not configured"}),"other"===ee&&(0,l.jsx)("span",{className:"px-1.5 py-0.5 text-[10px] font-medium bg-blue-500/10 text-blue-600 dark:text-blue-400 rounded-full",children:"Other"})]}),(0,l.jsx)("p",{className:"text-xs text-text-muted truncate",children:e.description})]})]}),(0,l.jsx)("span",{className:`material-symbols-outlined text-text-muted text-[20px] transition-transform ${t?"rotate-180":""}`,children:"expand_more"})]}),t&&(0,l.jsxs)("div",{className:"mt-4 pt-4 border-t border-border flex flex-col gap-4",children:[A&&(0,l.jsxs)("div",{className:"flex items-center gap-2 text-text-muted",children:[(0,l.jsx)("span",{className:"material-symbols-outlined animate-spin",children:"progress_activity"}),(0,l.jsx)("span",{children:"Checking Claude CLI..."})]}),!A&&S&&!S.installed&&(0,l.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,l.jsxs)("div",{className:"flex flex-col gap-3 p-4 bg-yellow-500/10 border border-yellow-500/30 rounded-lg",children:[(0,l.jsxs)("div",{className:"flex items-start gap-3",children:[(0,l.jsx)("span",{className:"material-symbols-outlined text-yellow-500",children:"warning"}),(0,l.jsxs)("div",{className:"flex-1",children:[(0,l.jsx)("p",{className:"font-medium text-yellow-600 dark:text-yellow-400",children:"Claude CLI not detected locally"}),(0,l.jsx)("p",{className:"text-sm text-text-muted",children:"Manual configuration is still available if 9router is deployed on a remote server."})]})]}),(0,l.jsxs)("div",{className:"flex items-center gap-2 pl-9",children:[(0,l.jsxs)(r.$n,{variant:"secondary",size:"sm",onClick:()=>G(!0),className:"!bg-yellow-500/20 !border-yellow-500/40 !text-yellow-700 dark:!text-yellow-300 hover:!bg-yellow-500/30",children:[(0,l.jsx)("span",{className:"material-symbols-outlined text-[18px] mr-1",children:"content_copy"}),"Manual Config"]}),(0,l.jsxs)(r.$n,{variant:"outline",size:"sm",onClick:()=>D(!T),children:[(0,l.jsx)("span",{className:"material-symbols-outlined text-[18px] mr-1",children:T?"expand_less":"help"}),T?"Hide":"How to Install"]})]})]}),T&&(0,l.jsxs)("div",{className:"p-4 bg-surface border border-border rounded-lg",children:[(0,l.jsx)("h4",{className:"font-medium mb-3",children:"Installation Guide"}),(0,l.jsxs)("div",{className:"space-y-3 text-sm",children:[(0,l.jsxs)("div",{children:[(0,l.jsx)("p",{className:"text-text-muted mb-1",children:"macOS / Linux / Windows:"}),(0,l.jsx)("code",{className:"block px-3 py-2 bg-black/5 dark:bg-white/5 rounded font-mono text-xs",children:"npm install -g @anthropic-ai/claude-code"})]}),(0,l.jsxs)("p",{className:"text-text-muted",children:["After installation, run ",(0,l.jsx)("code",{className:"px-1 bg-black/5 dark:bg-white/5 rounded",children:"claude"})," to verify."]})]})]})]}),!A&&S?.installed&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,l.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr] sm:items-center sm:gap-2",children:[(0,l.jsx)("span",{className:"text-xs font-semibold text-text-main sm:text-right sm:text-sm",children:"Select Endpoint"}),(0,l.jsx)("span",{className:"material-symbols-outlined hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,l.jsx)(x,{value:V||((k=V||c).endsWith("/v1")?k:`${k}/v1`),onChange:Y,requiresExternalUrl:e.requiresExternalUrl,tunnelEnabled:j,tunnelPublicUrl:N,tailscaleEnabled:v,tailscaleUrl:w})]}),S?.settings?.env?.ANTHROPIC_BASE_URL&&(0,l.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr_auto] sm:items-center sm:gap-2",children:[(0,l.jsx)("span",{className:"text-xs font-semibold text-text-main sm:text-right sm:text-sm",children:"Current"}),(0,l.jsx)("span",{className:"material-symbols-outlined hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,l.jsx)("span",{className:"min-w-0 truncate rounded bg-surface/40 px-2 py-2 text-xs text-text-muted sm:py-1.5",children:S.settings.env.ANTHROPIC_BASE_URL})]}),(0,l.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr_auto] sm:items-center sm:gap-2",children:[(0,l.jsx)("span",{className:"text-xs font-semibold text-text-main sm:text-right sm:text-sm",children:"API Key"}),(0,l.jsx)("span",{className:"material-symbols-outlined hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,l.jsx)(u,{value:q,onChange:H,apiKeys:p,cloudEnabled:h})]}),e.defaultModels.map(e=>(0,l.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr_auto] sm:items-center sm:gap-2",children:[(0,l.jsx)("span",{className:"text-xs font-semibold text-text-main sm:text-right sm:text-sm",children:e.name}),(0,l.jsx)("span",{className:"material-symbols-outlined hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,l.jsxs)("div",{className:"relative w-full min-w-0",children:[(0,l.jsx)("input",{type:"text",value:o[e.alias]||"",onChange:t=>d(e.alias,t.target.value),placeholder:"provider/model-id",className:"w-full min-w-0 pl-2 pr-7 py-2 bg-surface rounded border border-border text-xs focus:outline-none focus:ring-1 focus:ring-primary/50 sm:py-1.5"}),o[e.alias]&&(0,l.jsx)("button",{onClick:()=>d(e.alias,""),className:"absolute right-1 top-1/2 -translate-y-1/2 p-0.5 text-text-muted hover:text-red-500 rounded transition-colors",title:"Clear",children:(0,l.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"close"})})]}),(0,l.jsx)("button",{onClick:()=>{F(e.alias),z(!0)},disabled:!m,className:`w-full sm:w-auto rounded border px-2 py-2 text-xs transition-colors sm:py-1.5 whitespace-nowrap sm:shrink-0 ${m?"bg-surface border-border text-text-main hover:border-primary cursor-pointer":"opacity-50 cursor-not-allowed border-border"}`,children:"Select Model"})]},e.alias)),(0,l.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr_auto] sm:items-center sm:gap-2",children:[(0,l.jsx)("span",{className:"text-xs font-semibold text-text-main sm:text-right sm:text-sm",children:"Filter naming"}),(0,l.jsx)("span",{className:"material-symbols-outlined hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,l.jsxs)("label",{className:"flex items-center gap-1.5 cursor-pointer select-none",children:[(0,l.jsx)("input",{type:"checkbox",checked:Z,onChange:et,className:"w-3.5 h-3.5 accent-primary cursor-pointer"}),(0,l.jsx)("span",{className:"text-xs text-text-muted",children:"Filter naming requests"})]}),(0,l.jsx)(r.m_,{text:"Intercepts Claude Code's topic-naming requests and returns a fake response locally, saving API tokens.",children:(0,l.jsx)("span",{className:"material-symbols-outlined text-text-muted text-[14px] cursor-help",children:"info"})})]})]}),R&&(0,l.jsxs)("div",{className:`flex items-center gap-2 px-2 py-1.5 rounded text-xs ${"success"===R.type?"bg-green-500/10 text-green-600":"bg-red-500/10 text-red-600"}`,children:[(0,l.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"success"===R.type?"check_circle":"error"}),(0,l.jsx)("span",{children:R.text})]}),(0,l.jsxs)("div",{className:"grid grid-cols-1 gap-2 sm:flex sm:items-center",children:[(0,l.jsxs)(r.$n,{variant:"primary",size:"sm",onClick:er,disabled:!m,loading:M,children:[(0,l.jsx)("span",{className:"material-symbols-outlined text-[14px] mr-1",children:"save"}),"Apply"]}),(0,l.jsxs)(r.$n,{variant:"outline",size:"sm",onClick:ei,disabled:!S?.has9Router,loading:$,children:[(0,l.jsx)("span",{className:"material-symbols-outlined text-[14px] mr-1",children:"restore"}),"Reset"]}),(0,l.jsxs)(r.$n,{variant:"ghost",size:"sm",onClick:()=>G(!0),children:[(0,l.jsx)("span",{className:"material-symbols-outlined text-[14px] mr-1",children:"content_copy"}),"Manual Config"]})]})]})]}),(0,l.jsx)(r.rq,{isOpen:K,onClose:()=>z(!1),onSelect:e=>{L&&d(L,e.value)},selectedModel:L?o[L]:null,activeProviders:n,modelAliases:B,title:`Select model for ${L}`}),(0,l.jsx)(r.uR,{isOpen:J,onClose:()=>G(!1),title:"Claude CLI - Manual Configuration",configs:(C=q&&q.trim()?q:h?"<API_KEY_FROM_DASHBOARD>":"sk_9router",_={ANTHROPIC_BASE_URL:ea(),ANTHROPIC_AUTH_TOKEN:C},e.defaultModels.forEach(e=>{let t=o[e.alias];t&&e.envKey&&(_[e.envKey]=t)}),[{filename:"~/.claude/settings.json",content:JSON.stringify({hasCompletedOnboarding:!0,env:_},null,2)}])})]})}function b({tool:e,isExpanded:t,onToggle:s,baseUrl:n,apiKeys:o,activeProviders:d,cloudEnabled:c,initialStatus:m,tunnelEnabled:p,tunnelPublicUrl:h,tailscaleEnabled:f,tailscaleUrl:y}){let j,N,v,w,[k,C]=(0,a.useState)(m||null),[_,S]=(0,a.useState)(!1),[E,A]=(0,a.useState)(!1),[O,M]=(0,a.useState)(!1),[P,$]=(0,a.useState)(null),[I,R]=(0,a.useState)(!1),[U,T]=(0,a.useState)(""),[D,K]=(0,a.useState)(""),[z,L]=(0,a.useState)(""),[F,q]=(0,a.useState)(!1),[H,B]=(0,a.useState)(!1),[W,J]=(0,a.useState)({}),[G,V]=(0,a.useState)(!1),[Y,Z]=(0,a.useState)("");(0,a.useEffect)(()=>{o?.length>0&&!U&&T(o[0].key)},[o,U]),(0,a.useEffect)(()=>{m&&C(m)},[m]),(0,a.useEffect)(()=>{t&&!k&&(et(),Q()),t&&Q()},[t]);let Q=async()=>{try{let e=await fetch("/api/models/alias"),t=await e.json();e.ok&&J(t.aliases||{})}catch(e){console.log("Error fetching model aliases:",e)}};(0,a.useEffect)(()=>{if(k?.config){let e=k.config.match(/^model\s*=\s*"([^"]+)"/m);e&&K(e[1]);let t=k.config.match(/\[agents\.subagent\]\s*\n\s*model\s*=\s*"([^"]+)"/m);t&&L(t[1])}},[k]);let X=(()=>{if(!k?.installed)return null;if(!k.config)return"not_configured";let e=k.config.match(/base_url\s*=\s*"([^"]+)"/);return g(e?e[1]:"",{tunnelPublicUrl:h,tailscaleUrl:y})?"configured":"other"})(),ee=()=>{let e=Y||`${n}/v1`;return e.endsWith("/v1")?e:`${e}/v1`},et=async()=>{S(!0);try{let e=await fetch("/api/cli-tools/codex-settings"),t=await e.json();C(t)}catch(e){C({installed:!1,error:e.message})}finally{S(!1)}},es=async()=>{A(!0),$(null);try{let e=U&&U.trim()||c?U:"sk_9router",t=await fetch("/api/cli-tools/codex-settings",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({baseUrl:ee(),apiKey:e,model:D,subagentModel:z||D})}),s=await t.json();t.ok?($({type:"success",text:"Settings applied successfully!"}),et()):$({type:"error",text:s.error||"Failed to apply settings"})}catch(e){$({type:"error",text:e.message})}finally{A(!1)}},el=async()=>{M(!0),$(null);try{let e=await fetch("/api/cli-tools/codex-settings",{method:"DELETE"}),t=await e.json();e.ok?($({type:"success",text:"Settings reset successfully!"}),K(""),L(""),et()):$({type:"error",text:t.error||"Failed to reset settings"})}catch(e){$({type:"error",text:e.message})}finally{M(!1)}};return(0,l.jsxs)(r.Zp,{padding:"xs",className:"overflow-hidden",children:[(0,l.jsxs)("div",{className:"flex items-start justify-between gap-3 hover:cursor-pointer sm:items-center",onClick:s,children:[(0,l.jsxs)("div",{className:"flex min-w-0 items-center gap-3",children:[(0,l.jsx)("div",{className:"size-8 flex items-center justify-center shrink-0",children:(0,l.jsx)(i.default,{src:"/providers/codex.png",alt:e.name,width:32,height:32,className:"size-8 object-contain rounded-lg",sizes:"32px",onError:e=>{e.target.style.display="none"}})}),(0,l.jsxs)("div",{className:"min-w-0",children:[(0,l.jsxs)("div",{className:"flex min-w-0 flex-wrap items-center gap-2",children:[(0,l.jsx)("h3",{className:"font-medium text-sm",children:e.name}),"configured"===X&&(0,l.jsx)("span",{className:"px-1.5 py-0.5 text-[10px] font-medium bg-green-500/10 text-green-600 dark:text-green-400 rounded-full",children:"Connected"}),"not_configured"===X&&(0,l.jsx)("span",{className:"px-1.5 py-0.5 text-[10px] font-medium bg-yellow-500/10 text-yellow-600 dark:text-yellow-400 rounded-full",children:"Not configured"}),"other"===X&&(0,l.jsx)("span",{className:"px-1.5 py-0.5 text-[10px] font-medium bg-blue-500/10 text-blue-600 dark:text-blue-400 rounded-full",children:"Other"})]}),(0,l.jsx)("p",{className:"text-xs text-text-muted truncate",children:e.description})]})]}),(0,l.jsx)("span",{className:`material-symbols-outlined text-text-muted text-[20px] transition-transform ${t?"rotate-180":""}`,children:"expand_more"})]}),t&&(0,l.jsxs)("div",{className:"mt-4 pt-4 border-t border-border flex flex-col gap-4",children:[_&&(0,l.jsxs)("div",{className:"flex items-center gap-2 text-text-muted",children:[(0,l.jsx)("span",{className:"material-symbols-outlined animate-spin",children:"progress_activity"}),(0,l.jsx)("span",{children:"Checking Codex CLI..."})]}),!_&&k&&!k.installed&&(0,l.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,l.jsxs)("div",{className:"flex flex-col gap-3 p-4 bg-yellow-500/10 border border-yellow-500/30 rounded-lg",children:[(0,l.jsxs)("div",{className:"flex items-start gap-3",children:[(0,l.jsx)("span",{className:"material-symbols-outlined text-yellow-500",children:"warning"}),(0,l.jsxs)("div",{className:"flex-1",children:[(0,l.jsx)("p",{className:"font-medium text-yellow-600 dark:text-yellow-400",children:"Codex CLI not detected locally"}),(0,l.jsx)("p",{className:"text-sm text-text-muted",children:"Manual configuration is still available if 9router is deployed on a remote server."})]})]}),(0,l.jsxs)("div",{className:"flex items-center gap-2 pl-9",children:[(0,l.jsxs)(r.$n,{variant:"secondary",size:"sm",onClick:()=>V(!0),className:"!bg-yellow-500/20 !border-yellow-500/40 !text-yellow-700 dark:!text-yellow-300 hover:!bg-yellow-500/30",children:[(0,l.jsx)("span",{className:"material-symbols-outlined text-[18px] mr-1",children:"content_copy"}),"Manual Config"]}),(0,l.jsxs)(r.$n,{variant:"outline",size:"sm",onClick:()=>R(!I),children:[(0,l.jsx)("span",{className:"material-symbols-outlined text-[18px] mr-1",children:I?"expand_less":"help"}),I?"Hide":"How to Install"]})]})]}),I&&(0,l.jsxs)("div",{className:"p-4 bg-surface border border-border rounded-lg",children:[(0,l.jsx)("h4",{className:"font-medium mb-3",children:"Installation Guide"}),(0,l.jsxs)("div",{className:"space-y-3 text-sm",children:[(0,l.jsxs)("div",{children:[(0,l.jsx)("p",{className:"text-text-muted mb-1",children:"macOS / Linux / Windows:"}),(0,l.jsx)("code",{className:"block px-3 py-2 bg-black/5 dark:bg-white/5 rounded font-mono text-xs",children:"npm install -g @openai/codex"})]}),(0,l.jsxs)("p",{className:"text-text-muted",children:["After installation, run ",(0,l.jsx)("code",{className:"px-1 bg-black/5 dark:bg-white/5 rounded",children:"codex"})," to verify."]}),(0,l.jsx)("div",{className:"pt-2 border-t border-border",children:(0,l.jsxs)("p",{className:"text-text-muted text-xs",children:["Codex uses ",(0,l.jsx)("code",{className:"px-1 bg-black/5 dark:bg-white/5 rounded",children:"~/.codex/auth.json"})," with ",(0,l.jsx)("code",{className:"px-1 bg-black/5 dark:bg-white/5 rounded",children:"OPENAI_API_KEY"}),'. Click "Apply" to auto-configure.']})})]})]})]}),!_&&k?.installed&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,l.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr] sm:items-center sm:gap-2",children:[(0,l.jsx)("span",{className:"text-xs font-semibold text-text-main sm:text-right sm:text-sm",children:"Select Endpoint"}),(0,l.jsx)("span",{className:"material-symbols-outlined hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,l.jsx)(x,{value:Y||Y||`${n}/v1`,onChange:Z,requiresExternalUrl:e.requiresExternalUrl,tunnelEnabled:p,tunnelPublicUrl:h,tailscaleEnabled:f,tailscaleUrl:y})]}),k?.config&&((N=(j=k.config.match(/base_url\s*=\s*"([^"]+)"/))?j[1]:null)?(0,l.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr_auto] sm:items-center sm:gap-2",children:[(0,l.jsx)("span",{className:"text-xs font-semibold text-text-main sm:text-right sm:text-sm",children:"Current"}),(0,l.jsx)("span",{className:"material-symbols-outlined hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,l.jsx)("span",{className:"min-w-0 truncate rounded bg-surface/40 px-2 py-2 text-xs text-text-muted sm:py-1.5",children:N})]}):null),(0,l.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr_auto] sm:items-center sm:gap-2",children:[(0,l.jsx)("span",{className:"text-xs font-semibold text-text-main sm:text-right sm:text-sm",children:"API Key"}),(0,l.jsx)("span",{className:"material-symbols-outlined hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,l.jsx)(u,{value:U,onChange:T,apiKeys:o,cloudEnabled:c})]}),(0,l.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr_auto] sm:items-center sm:gap-2",children:[(0,l.jsx)("span",{className:"text-xs font-semibold text-text-main sm:text-right sm:text-sm",children:"Model"}),(0,l.jsx)("span",{className:"material-symbols-outlined hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,l.jsxs)("div",{className:"relative w-full min-w-0",children:[(0,l.jsx)("input",{type:"text",value:D,onChange:e=>K(e.target.value),placeholder:"provider/model-id",className:"w-full min-w-0 pl-2 pr-7 py-2 bg-surface rounded border border-border text-xs focus:outline-none focus:ring-1 focus:ring-primary/50 sm:py-1.5"}),D&&(0,l.jsx)("button",{onClick:()=>K(""),className:"absolute right-1 top-1/2 -translate-y-1/2 p-0.5 text-text-muted hover:text-red-500 rounded transition-colors",title:"Clear",children:(0,l.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"close"})})]}),(0,l.jsx)("button",{onClick:()=>q(!0),disabled:!d?.length,className:`w-full sm:w-auto rounded border px-2 py-2 text-xs transition-colors sm:py-1.5 whitespace-nowrap sm:shrink-0 ${d?.length?"bg-surface border-border text-text-main hover:border-primary cursor-pointer":"opacity-50 cursor-not-allowed border-border"}`,children:"Select Model"})]}),(0,l.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr_auto] sm:items-center sm:gap-2",children:[(0,l.jsx)("span",{className:"text-xs font-semibold text-text-main sm:text-right sm:text-sm",children:"Subagent Model"}),(0,l.jsx)("span",{className:"material-symbols-outlined hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,l.jsxs)("div",{className:"relative w-full min-w-0",children:[(0,l.jsx)("input",{type:"text",value:z,onChange:e=>L(e.target.value),placeholder:D||"provider/model-id (defaults to main model)",className:"w-full min-w-0 pl-2 pr-7 py-2 bg-surface rounded border border-border text-xs focus:outline-none focus:ring-1 focus:ring-primary/50 sm:py-1.5"}),z&&(0,l.jsx)("button",{onClick:()=>L(""),className:"absolute right-1 top-1/2 -translate-y-1/2 p-0.5 text-text-muted hover:text-red-500 rounded transition-colors",title:"Clear (will use main model)",children:(0,l.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"close"})})]}),(0,l.jsx)("button",{onClick:()=>B(!0),disabled:!d?.length,className:`w-full sm:w-auto rounded border px-2 py-2 text-xs transition-colors sm:py-1.5 whitespace-nowrap sm:shrink-0 ${d?.length?"bg-surface border-border text-text-main hover:border-primary cursor-pointer":"opacity-50 cursor-not-allowed border-border"}`,children:"Select Model"})]})]}),P&&(0,l.jsxs)("div",{className:`flex items-center gap-2 px-2 py-1.5 rounded text-xs ${"success"===P.type?"bg-green-500/10 text-green-600":"bg-red-500/10 text-red-600"}`,children:[(0,l.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"success"===P.type?"check_circle":"error"}),(0,l.jsx)("span",{children:P.text})]}),(0,l.jsxs)("div",{className:"grid grid-cols-1 gap-2 sm:flex sm:items-center",children:[(0,l.jsxs)(r.$n,{variant:"primary",size:"sm",onClick:es,disabled:!U&&c&&o.length>0||!D,loading:E,children:[(0,l.jsx)("span",{className:"material-symbols-outlined text-[14px] mr-1",children:"save"}),"Apply"]}),(0,l.jsxs)(r.$n,{variant:"outline",size:"sm",onClick:el,disabled:O,loading:O,children:[(0,l.jsx)("span",{className:"material-symbols-outlined text-[14px] mr-1",children:"restore"}),"Reset"]}),(0,l.jsxs)(r.$n,{variant:"ghost",size:"sm",onClick:()=>V(!0),children:[(0,l.jsx)("span",{className:"material-symbols-outlined text-[14px] mr-1",children:"content_copy"}),"Manual Config"]})]})]})]}),(0,l.jsx)(r.rq,{isOpen:F,onClose:()=>q(!1),onSelect:e=>{K(e.value),z||L(e.value),q(!1)},selectedModel:D,activeProviders:d,modelAliases:W,title:"Select Model for Codex"}),(0,l.jsx)(r.rq,{isOpen:H,onClose:()=>B(!1),onSelect:e=>{L(e.value),B(!1)},selectedModel:z,activeProviders:d,modelAliases:W,title:"Select Subagent Model for Codex"}),(0,l.jsx)(r.uR,{isOpen:G,onClose:()=>V(!1),title:"Codex CLI - Manual Configuration",configs:(v=U&&U.trim()?U:c?"<API_KEY_FROM_DASHBOARD>":"sk_9router",w=z||D,[{filename:"~/.codex/config.toml",content:`# 9Router Configuration for Codex CLI
23
+ }`}},"deepseek-tui":{id:"deepseek-tui",name:"DeepSeek TUI",image:"/providers/deepseek-tui.png",color:"#4D6BFE",description:"DeepSeek Terminal Coding Agent (Rust TUI)",docsUrl:"https://github.com/DeepSeek-TUI/DeepSeek-TUI",configType:"custom",defaultCommand:"deepseek",modelAliases:["deepseek-v4-pro","deepseek-v4-flash","deepseek-chat","deepseek-reasoner"],defaultModels:[{id:"deepseek-v4-pro",name:"DeepSeek V4 Pro",alias:"deepseek-v4-pro"},{id:"deepseek-v4-flash",name:"DeepSeek V4 Flash",alias:"deepseek-v4-flash"},{id:"deepseek-chat",name:"DeepSeek V3 Chat",alias:"deepseek-chat"}],notes:[{type:"info",text:"DeepSeek TUI uses ~/.deepseek/config.toml for configuration. 9Router will update the provider to 'openai' mode with your base_url, api_key, and model."},{type:"warning",text:"Config path: Linux/macOS ~/.deepseek/config.toml • Windows %USERPROFILE%\\.deepseek\\config.toml"}]},jcode:{id:"jcode",name:"jcode",image:"/providers/jcode.png",color:"#FF6B35",description:"High-performance Rust-based coding agent harness",configType:"custom",docsUrl:"https://github.com/1jehuang/jcode",notes:[{type:"info",text:"jcode is a Rust-based coding agent with semantic memory, multi-agent swarms, and extreme performance (27.8 MB RAM, 14ms boot)."},{type:"info",text:"Configure 9router as an OpenAI-compatible provider to route all jcode requests through 9router's optimization layer."},{type:"warning",text:"Requires jcode installed. Install via: curl -fsSL https://raw.githubusercontent.com/1jehuang/jcode/master/scripts/install.sh | bash"}],defaultModels:[{id:"claude-opus-4-7",name:"Claude Opus 4.7",alias:"opus",defaultValue:"cc/claude-opus-4-7"},{id:"claude-sonnet-4-6",name:"Claude Sonnet 4.6",alias:"sonnet",defaultValue:"cc/claude-sonnet-4-6"},{id:"gpt-5.5",name:"GPT 5.5",alias:"gpt5",defaultValue:"cx/gpt-5.5"},{id:"gemini-3.1-pro",name:"Gemini 3.1 Pro",alias:"gemini",defaultValue:"gemini/gemini-3.1-pro"}]}}},40295:e=>{e.exports={TOOL_HOSTS:{antigravity:["daily-cloudcode-pa.googleapis.com","cloudcode-pa.googleapis.com"],copilot:["api.individual.githubcopilot.com"],kiro:["q.us-east-1.amazonaws.com","codewhisperer.us-east-1.amazonaws.com"],cursor:["api2.cursor.sh"],qoder:["openapi.qoder.sh","api2.qoder.sh","center.qoder.sh"]}}},43666:(e,t,s)=>{s.d(t,{Tk:()=>y,aG:()=>P,Ah:()=>b,h1:()=>M,Q6:()=>O,lF:()=>R,a7:()=>_,ZM:()=>N,RF:()=>k,mW:()=>U,c9:()=>$,gY:()=>q,tA:()=>D,kn:()=>z,yZ:()=>v,qO:()=>S});var l=s(95155),a=s(12115),r=s(35497),i=s(5772),n=s(90620);let o="9router.cliToolEndpointPresets",d="__custom__",c="__save__",m=e=>{window.localStorage.setItem(o,JSON.stringify(e))};function x({value:e,onChange:t,requiresExternalUrl:s=!1,tunnelEnabled:r=!1,tunnelPublicUrl:i="",tailscaleEnabled:p=!1,tailscaleUrl:u="",cloudEnabled:h=!1,cloudUrl:g="",withV1:f=!0}){let[y,b]=(0,a.useState)([]),[j,N]=(0,a.useState)(""),[v,w]=(0,a.useState)(""),k=(0,a.useRef)(!1);(0,a.useEffect)(()=>{b((()=>{try{let e=JSON.parse(window.localStorage.getItem(o)||"[]");if(!Array.isArray(e))return[];return e.filter(e=>e?.name&&e?.baseUrl)}catch{return[]}})())},[]);let C=(0,a.useMemo)(()=>(({requiresExternalUrl:e,tunnelEnabled:t,tunnelPublicUrl:s,tailscaleEnabled:l,tailscaleUrl:a,cloudEnabled:r,cloudUrl:i,savedPresets:o,withV1:c})=>{let m=[],x=e=>{let t;return c?(t=(e||"").replace(/\/+$/,""))?/\/v1$/.test(t)?t:`${t}/v1`:"":(e||"").replace(/\/+$/,"")};if(!e){let e=x(`http://127.0.0.1:${n.h0.appPort}`);m.push({value:"local",label:e,url:e})}if(t&&s){let e=x(s);m.push({value:"tunnel",label:e,url:e})}if(l&&a){let e=x(a);m.push({value:"tailscale",label:e,url:e})}if(r&&i){let e=x(i);m.push({value:"cloud",label:e,url:e})}return o.forEach(e=>{m.push({value:`saved:${e.name}`,label:e.baseUrl,url:e.baseUrl,saved:!0})}),m.push({value:d,label:"Custom URL...",url:""}),m})({requiresExternalUrl:s,tunnelEnabled:r,tunnelPublicUrl:i,tailscaleEnabled:p,tailscaleUrl:u,cloudEnabled:h,cloudUrl:g,savedPresets:y,withV1:f}),[s,r,i,p,u,h,g,y,f]);(0,a.useEffect)(()=>{if(k.current||0===C.length)return;k.current=!0;let e=C.find(e=>e.value!==d);e?(N(e.value),t(e.url)):N(d)},[C,t]);let _=j.startsWith("saved:"),S=j===d,E=S&&(v||"").trim().length>0;return(0,l.jsxs)("div",{className:"flex flex-col gap-1.5",children:[(0,l.jsxs)("div",{className:"flex items-center gap-2",children:[(0,l.jsxs)("select",{value:j,onChange:s=>{let l=s.target.value;if(l===c){let t=(e||"").trim();if(!t)return;let s=t;try{s=new URL(t).host}catch{}let l=window.prompt("Save endpoint as:",s);if(!l?.trim())return;let a=[...y.filter(e=>e.name!==l.trim()),{name:l.trim(),baseUrl:t}].sort((e,t)=>e.name.localeCompare(t.name));b(a),m(a);return}if(N(l),l===d){w(""),t("");return}let a=C.find(e=>e.value===l);a&&t(a.url)},className:"flex-1 min-w-0 px-2 py-2 bg-surface rounded text-xs border border-border focus:outline-none focus:ring-1 focus:ring-primary/50 sm:py-1.5",children:[C.map(e=>(0,l.jsx)("option",{value:e.value,children:e.label},e.value)),E&&(0,l.jsx)("option",{value:c,children:"+ Save current as..."})]}),_&&(0,l.jsx)("button",{type:"button",onClick:()=>{if(!j.startsWith("saved:"))return;let e=j.slice(6),s=y.filter(t=>t.name!==e);b(s),m(s),N(d),w(""),t("")},className:"p-1 text-text-muted hover:text-red-500 rounded transition-colors shrink-0",title:"Delete saved endpoint",children:(0,l.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"delete"})})]}),S&&(0,l.jsx)("input",{type:"text",value:v,onChange:e=>{let s=e.target.value;w(s),t(s)},placeholder:f?"https://example.com/v1":"https://example.com",className:"w-full min-w-0 px-2 py-2 bg-surface rounded border border-border text-xs focus:outline-none focus:ring-1 focus:ring-primary/50 sm:py-1.5"})]})}let p="__custom__";function u({value:e,onChange:t,apiKeys:s=[],cloudEnabled:r=!1,className:i=""}){let n=!s.some(t=>t.key===e)&&""!==e,[o,d]=(0,a.useState)(()=>e?s.some(t=>t.key===e)?e:p:s.length>0?s[0].key:p),[c,m]=(0,a.useState)(n?e:"");return 0===s.length&&o!==p&&o!==p?(0,l.jsx)("span",{className:`min-w-0 rounded bg-surface/40 px-2 py-2 text-xs text-text-muted sm:py-1.5 ${i}`,children:r?"No API keys - Create one in Keys page":"sk_9router (default)"}):(0,l.jsxs)("div",{className:`flex flex-col gap-1.5 ${i}`,children:[(0,l.jsxs)("select",{value:o,onChange:e=>{let s=e.target.value;d(s),s===p?(m(""),t("")):t(s)},className:"w-full min-w-0 px-2 py-2 bg-surface rounded text-xs border border-border focus:outline-none focus:ring-1 focus:ring-primary/50 sm:py-1.5",children:[s.map(e=>(0,l.jsx)("option",{value:e.key,children:e.key},e.id)),(0,l.jsx)("option",{value:p,children:"Custom..."})]}),o===p&&(0,l.jsx)("input",{type:"text",value:c,onChange:e=>{let s=e.target.value;m(s),t(s)},placeholder:"sk-...",className:"w-full min-w-0 px-2 py-2 bg-surface rounded border border-border text-xs focus:outline-none focus:ring-1 focus:ring-primary/50 sm:py-1.5"})]})}let h=e=>(e||"").replace(/\/+$/,"");function g(e,t={}){if(!e)return!1;let s=h(e),{tunnelPublicUrl:l,tailscaleUrl:a,cloudUrl:r}=t;return!!(/localhost|127\.0\.0\.1|0\.0\.0\.0/.test(s)||l&&s.startsWith(h(l))||a&&s.startsWith(h(a))||r&&s.startsWith(h(r)))}let f=s(41463).env.NEXT_PUBLIC_CLOUD_URL;function y({tool:e,isExpanded:t,onToggle:s,activeProviders:n,modelMappings:o,onModelMappingChange:d,baseUrl:c,hasActiveProviders:m,apiKeys:p,cloudEnabled:h,initialStatus:b,tunnelEnabled:j,tunnelPublicUrl:N,tailscaleEnabled:v,tailscaleUrl:w}){let k,C,_,[S,E]=(0,a.useState)(b||null),[A,O]=(0,a.useState)(!1),[M,P]=(0,a.useState)(!1),[$,I]=(0,a.useState)(!1),[R,U]=(0,a.useState)(null),[T,D]=(0,a.useState)(!1),[K,z]=(0,a.useState)(!1),[L,F]=(0,a.useState)(null),[q,H]=(0,a.useState)(""),[B,W]=(0,a.useState)({}),[J,G]=(0,a.useState)(!1),[V,Y]=(0,a.useState)(""),[Z,Q]=(0,a.useState)(!1),X=(0,a.useRef)(!1),ee=(()=>{if(!S?.installed)return null;let e=S.settings?.env?.ANTHROPIC_BASE_URL;return e?g(e,{tunnelPublicUrl:N,tailscaleUrl:w,cloudUrl:h?f:null})?"configured":"other":"not_configured"})();(0,a.useEffect)(()=>{p?.length>0&&!q&&H(p[0].key)},[p,q]),(0,a.useEffect)(()=>{b&&E(b)},[b]),(0,a.useEffect)(()=>{t&&!S&&(el(),es()),t&&es()},[t]),(0,a.useEffect)(()=>{fetch("/api/settings").then(e=>e.json()).then(e=>{Q(!!e.ccFilterNaming)}).catch(()=>{})},[]);let et=async e=>{let t=e.target.checked;Q(t),await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({ccFilterNaming:t})}).catch(()=>{})},es=async()=>{try{let e=await fetch("/api/models/alias"),t=await e.json();e.ok&&W(t.aliases||{})}catch(e){console.log("Error fetching model aliases:",e)}};(0,a.useEffect)(()=>{if(S?.installed&&!X.current){X.current=!0;let t=S.settings?.env||{};e.defaultModels.forEach(e=>{if(e.envKey){let s=t[e.envKey]||e.defaultValue||"";s&&d(e.alias,s)}});let s=t.ANTHROPIC_AUTH_TOKEN;s&&p?.some(e=>e.key===s)&&H(s)}},[S,p,e.defaultModels,d]);let el=async()=>{O(!0);try{let e=await fetch("/api/cli-tools/claude-settings"),t=await e.json();E(t)}catch(e){E({installed:!1,error:e.message})}finally{O(!1)}},ea=()=>{let e=V||c;return e.endsWith("/v1")?e:`${e}/v1`},er=async()=>{P(!0),U(null);try{let t={ANTHROPIC_BASE_URL:ea()},s=q?.trim()||(p?.length>0?p[0].key:null)||(h?null:"sk_9router");s&&(t.ANTHROPIC_AUTH_TOKEN=s),e.defaultModels.forEach(e=>{let s=o[e.alias];s&&e.envKey&&(t[e.envKey]=s)});let l=await fetch("/api/cli-tools/claude-settings",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({env:t})}),a=await l.json();l.ok?(U({type:"success",text:"Settings applied successfully!"}),E(e=>({...e,hasBackup:!0,settings:{...e?.settings,env:t}}))):U({type:"error",text:a.error||"Failed to apply settings"})}catch(e){U({type:"error",text:e.message})}finally{P(!1)}},ei=async()=>{I(!0),U(null);try{let t=await fetch("/api/cli-tools/claude-settings",{method:"DELETE"}),s=await t.json();t.ok?(U({type:"success",text:"Settings reset successfully!"}),e.defaultModels.forEach(e=>d(e.alias,e.defaultValue||"")),H("")):U({type:"error",text:s.error||"Failed to reset settings"})}catch(e){U({type:"error",text:e.message})}finally{I(!1)}};return(0,l.jsxs)(r.Zp,{padding:"xs",className:"overflow-hidden",children:[(0,l.jsxs)("div",{className:"flex items-start justify-between gap-3 hover:cursor-pointer sm:items-center",onClick:s,children:[(0,l.jsxs)("div",{className:"flex min-w-0 items-center gap-3",children:[(0,l.jsx)("div",{className:"size-8 flex items-center justify-center shrink-0",children:(0,l.jsx)(i.default,{src:"/providers/claude.png",alt:e.name,width:32,height:32,className:"size-8 object-contain rounded-lg",sizes:"32px",onError:e=>{e.target.style.display="none"}})}),(0,l.jsxs)("div",{className:"min-w-0",children:[(0,l.jsxs)("div",{className:"flex min-w-0 flex-wrap items-center gap-2",children:[(0,l.jsx)("h3",{className:"font-medium text-sm",children:e.name}),"configured"===ee&&(0,l.jsx)("span",{className:"px-1.5 py-0.5 text-[10px] font-medium bg-green-500/10 text-green-600 dark:text-green-400 rounded-full",children:"Connected"}),"not_configured"===ee&&(0,l.jsx)("span",{className:"px-1.5 py-0.5 text-[10px] font-medium bg-yellow-500/10 text-yellow-600 dark:text-yellow-400 rounded-full",children:"Not configured"}),"other"===ee&&(0,l.jsx)("span",{className:"px-1.5 py-0.5 text-[10px] font-medium bg-blue-500/10 text-blue-600 dark:text-blue-400 rounded-full",children:"Other"})]}),(0,l.jsx)("p",{className:"text-xs text-text-muted truncate",children:e.description})]})]}),(0,l.jsx)("span",{className:`material-symbols-outlined text-text-muted text-[20px] transition-transform ${t?"rotate-180":""}`,children:"expand_more"})]}),t&&(0,l.jsxs)("div",{className:"mt-4 pt-4 border-t border-border flex flex-col gap-4",children:[A&&(0,l.jsxs)("div",{className:"flex items-center gap-2 text-text-muted",children:[(0,l.jsx)("span",{className:"material-symbols-outlined animate-spin",children:"progress_activity"}),(0,l.jsx)("span",{children:"Checking Claude CLI..."})]}),!A&&S&&!S.installed&&(0,l.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,l.jsxs)("div",{className:"flex flex-col gap-3 p-4 bg-yellow-500/10 border border-yellow-500/30 rounded-lg",children:[(0,l.jsxs)("div",{className:"flex items-start gap-3",children:[(0,l.jsx)("span",{className:"material-symbols-outlined text-yellow-500",children:"warning"}),(0,l.jsxs)("div",{className:"flex-1",children:[(0,l.jsx)("p",{className:"font-medium text-yellow-600 dark:text-yellow-400",children:"Claude CLI not detected locally"}),(0,l.jsx)("p",{className:"text-sm text-text-muted",children:"Manual configuration is still available if 9router is deployed on a remote server."})]})]}),(0,l.jsxs)("div",{className:"flex items-center gap-2 pl-9",children:[(0,l.jsxs)(r.$n,{variant:"secondary",size:"sm",onClick:()=>G(!0),className:"!bg-yellow-500/20 !border-yellow-500/40 !text-yellow-700 dark:!text-yellow-300 hover:!bg-yellow-500/30",children:[(0,l.jsx)("span",{className:"material-symbols-outlined text-[18px] mr-1",children:"content_copy"}),"Manual Config"]}),(0,l.jsxs)(r.$n,{variant:"outline",size:"sm",onClick:()=>D(!T),children:[(0,l.jsx)("span",{className:"material-symbols-outlined text-[18px] mr-1",children:T?"expand_less":"help"}),T?"Hide":"How to Install"]})]})]}),T&&(0,l.jsxs)("div",{className:"p-4 bg-surface border border-border rounded-lg",children:[(0,l.jsx)("h4",{className:"font-medium mb-3",children:"Installation Guide"}),(0,l.jsxs)("div",{className:"space-y-3 text-sm",children:[(0,l.jsxs)("div",{children:[(0,l.jsx)("p",{className:"text-text-muted mb-1",children:"macOS / Linux / Windows:"}),(0,l.jsx)("code",{className:"block px-3 py-2 bg-black/5 dark:bg-white/5 rounded font-mono text-xs",children:"npm install -g @anthropic-ai/claude-code"})]}),(0,l.jsxs)("p",{className:"text-text-muted",children:["After installation, run ",(0,l.jsx)("code",{className:"px-1 bg-black/5 dark:bg-white/5 rounded",children:"claude"})," to verify."]})]})]})]}),!A&&S?.installed&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,l.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr] sm:items-center sm:gap-2",children:[(0,l.jsx)("span",{className:"text-xs font-semibold text-text-main sm:text-right sm:text-sm",children:"Select Endpoint"}),(0,l.jsx)("span",{className:"material-symbols-outlined hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,l.jsx)(x,{value:V||((k=V||c).endsWith("/v1")?k:`${k}/v1`),onChange:Y,requiresExternalUrl:e.requiresExternalUrl,tunnelEnabled:j,tunnelPublicUrl:N,tailscaleEnabled:v,tailscaleUrl:w})]}),S?.settings?.env?.ANTHROPIC_BASE_URL&&(0,l.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr_auto] sm:items-center sm:gap-2",children:[(0,l.jsx)("span",{className:"text-xs font-semibold text-text-main sm:text-right sm:text-sm",children:"Current"}),(0,l.jsx)("span",{className:"material-symbols-outlined hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,l.jsx)("span",{className:"min-w-0 truncate rounded bg-surface/40 px-2 py-2 text-xs text-text-muted sm:py-1.5",children:S.settings.env.ANTHROPIC_BASE_URL})]}),(0,l.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr_auto] sm:items-center sm:gap-2",children:[(0,l.jsx)("span",{className:"text-xs font-semibold text-text-main sm:text-right sm:text-sm",children:"API Key"}),(0,l.jsx)("span",{className:"material-symbols-outlined hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,l.jsx)(u,{value:q,onChange:H,apiKeys:p,cloudEnabled:h})]}),e.defaultModels.map(e=>(0,l.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr_auto] sm:items-center sm:gap-2",children:[(0,l.jsx)("span",{className:"text-xs font-semibold text-text-main sm:text-right sm:text-sm",children:e.name}),(0,l.jsx)("span",{className:"material-symbols-outlined hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,l.jsxs)("div",{className:"relative w-full min-w-0",children:[(0,l.jsx)("input",{type:"text",value:o[e.alias]||"",onChange:t=>d(e.alias,t.target.value),placeholder:"provider/model-id",className:"w-full min-w-0 pl-2 pr-7 py-2 bg-surface rounded border border-border text-xs focus:outline-none focus:ring-1 focus:ring-primary/50 sm:py-1.5"}),o[e.alias]&&(0,l.jsx)("button",{onClick:()=>d(e.alias,""),className:"absolute right-1 top-1/2 -translate-y-1/2 p-0.5 text-text-muted hover:text-red-500 rounded transition-colors",title:"Clear",children:(0,l.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"close"})})]}),(0,l.jsx)("button",{onClick:()=>{F(e.alias),z(!0)},disabled:!m,className:`w-full sm:w-auto rounded border px-2 py-2 text-xs transition-colors sm:py-1.5 whitespace-nowrap sm:shrink-0 ${m?"bg-surface border-border text-text-main hover:border-primary cursor-pointer":"opacity-50 cursor-not-allowed border-border"}`,children:"Select Model"})]},e.alias)),(0,l.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr_auto] sm:items-center sm:gap-2",children:[(0,l.jsx)("span",{className:"text-xs font-semibold text-text-main sm:text-right sm:text-sm",children:"Filter naming"}),(0,l.jsx)("span",{className:"material-symbols-outlined hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,l.jsxs)("label",{className:"flex items-center gap-1.5 cursor-pointer select-none",children:[(0,l.jsx)("input",{type:"checkbox",checked:Z,onChange:et,className:"w-3.5 h-3.5 accent-primary cursor-pointer"}),(0,l.jsx)("span",{className:"text-xs text-text-muted",children:"Filter naming requests"})]}),(0,l.jsx)(r.m_,{text:"Intercepts Claude Code's topic-naming requests and returns a fake response locally, saving API tokens.",children:(0,l.jsx)("span",{className:"material-symbols-outlined text-text-muted text-[14px] cursor-help",children:"info"})})]})]}),R&&(0,l.jsxs)("div",{className:`flex items-center gap-2 px-2 py-1.5 rounded text-xs ${"success"===R.type?"bg-green-500/10 text-green-600":"bg-red-500/10 text-red-600"}`,children:[(0,l.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"success"===R.type?"check_circle":"error"}),(0,l.jsx)("span",{children:R.text})]}),(0,l.jsxs)("div",{className:"grid grid-cols-1 gap-2 sm:flex sm:items-center",children:[(0,l.jsxs)(r.$n,{variant:"primary",size:"sm",onClick:er,disabled:!m,loading:M,children:[(0,l.jsx)("span",{className:"material-symbols-outlined text-[14px] mr-1",children:"save"}),"Apply"]}),(0,l.jsxs)(r.$n,{variant:"outline",size:"sm",onClick:ei,disabled:!S?.has9Router,loading:$,children:[(0,l.jsx)("span",{className:"material-symbols-outlined text-[14px] mr-1",children:"restore"}),"Reset"]}),(0,l.jsxs)(r.$n,{variant:"ghost",size:"sm",onClick:()=>G(!0),children:[(0,l.jsx)("span",{className:"material-symbols-outlined text-[14px] mr-1",children:"content_copy"}),"Manual Config"]})]})]})]}),(0,l.jsx)(r.rq,{isOpen:K,onClose:()=>z(!1),onSelect:e=>{L&&d(L,e.value)},selectedModel:L?o[L]:null,activeProviders:n,modelAliases:B,title:`Select model for ${L}`}),(0,l.jsx)(r.uR,{isOpen:J,onClose:()=>G(!1),title:"Claude CLI - Manual Configuration",configs:(C=q&&q.trim()?q:h?"<API_KEY_FROM_DASHBOARD>":"sk_9router",_={ANTHROPIC_BASE_URL:ea(),ANTHROPIC_AUTH_TOKEN:C},e.defaultModels.forEach(e=>{let t=o[e.alias];t&&e.envKey&&(_[e.envKey]=t)}),[{filename:"~/.claude/settings.json",content:JSON.stringify({hasCompletedOnboarding:!0,env:_},null,2)}])})]})}function b({tool:e,isExpanded:t,onToggle:s,baseUrl:n,apiKeys:o,activeProviders:d,cloudEnabled:c,initialStatus:m,tunnelEnabled:p,tunnelPublicUrl:h,tailscaleEnabled:f,tailscaleUrl:y}){let j,N,v,w,[k,C]=(0,a.useState)(m||null),[_,S]=(0,a.useState)(!1),[E,A]=(0,a.useState)(!1),[O,M]=(0,a.useState)(!1),[P,$]=(0,a.useState)(null),[I,R]=(0,a.useState)(!1),[U,T]=(0,a.useState)(""),[D,K]=(0,a.useState)(""),[z,L]=(0,a.useState)(""),[F,q]=(0,a.useState)(!1),[H,B]=(0,a.useState)(!1),[W,J]=(0,a.useState)({}),[G,V]=(0,a.useState)(!1),[Y,Z]=(0,a.useState)("");(0,a.useEffect)(()=>{o?.length>0&&!U&&T(o[0].key)},[o,U]),(0,a.useEffect)(()=>{m&&C(m)},[m]),(0,a.useEffect)(()=>{t&&!k&&(et(),Q()),t&&Q()},[t]);let Q=async()=>{try{let e=await fetch("/api/models/alias"),t=await e.json();e.ok&&J(t.aliases||{})}catch(e){console.log("Error fetching model aliases:",e)}};(0,a.useEffect)(()=>{if(k?.config){let e=k.config.match(/^model\s*=\s*"([^"]+)"/m);e&&K(e[1]);let t=k.config.match(/\[agents\.subagent\]\s*\n\s*model\s*=\s*"([^"]+)"/m);t&&L(t[1])}},[k]);let X=(()=>{if(!k?.installed)return null;if(!k.config)return"not_configured";let e=k.config.match(/base_url\s*=\s*"([^"]+)"/);return g(e?e[1]:"",{tunnelPublicUrl:h,tailscaleUrl:y})?"configured":"other"})(),ee=()=>{let e=Y||`${n}/v1`;return e.endsWith("/v1")?e:`${e}/v1`},et=async()=>{S(!0);try{let e=await fetch("/api/cli-tools/codex-settings"),t=await e.json();C(t)}catch(e){C({installed:!1,error:e.message})}finally{S(!1)}},es=async()=>{A(!0),$(null);try{let e=U&&U.trim()||c?U:"sk_9router",t=await fetch("/api/cli-tools/codex-settings",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({baseUrl:ee(),apiKey:e,model:D,subagentModel:z||D})}),s=await t.json();t.ok?($({type:"success",text:"Settings applied successfully!"}),et()):$({type:"error",text:s.error||"Failed to apply settings"})}catch(e){$({type:"error",text:e.message})}finally{A(!1)}},el=async()=>{M(!0),$(null);try{let e=await fetch("/api/cli-tools/codex-settings",{method:"DELETE"}),t=await e.json();e.ok?($({type:"success",text:"Settings reset successfully!"}),K(""),L(""),et()):$({type:"error",text:t.error||"Failed to reset settings"})}catch(e){$({type:"error",text:e.message})}finally{M(!1)}};return(0,l.jsxs)(r.Zp,{padding:"xs",className:"overflow-hidden",children:[(0,l.jsxs)("div",{className:"flex items-start justify-between gap-3 hover:cursor-pointer sm:items-center",onClick:s,children:[(0,l.jsxs)("div",{className:"flex min-w-0 items-center gap-3",children:[(0,l.jsx)("div",{className:"size-8 flex items-center justify-center shrink-0",children:(0,l.jsx)(i.default,{src:"/providers/codex.png",alt:e.name,width:32,height:32,className:"size-8 object-contain rounded-lg",sizes:"32px",onError:e=>{e.target.style.display="none"}})}),(0,l.jsxs)("div",{className:"min-w-0",children:[(0,l.jsxs)("div",{className:"flex min-w-0 flex-wrap items-center gap-2",children:[(0,l.jsx)("h3",{className:"font-medium text-sm",children:e.name}),"configured"===X&&(0,l.jsx)("span",{className:"px-1.5 py-0.5 text-[10px] font-medium bg-green-500/10 text-green-600 dark:text-green-400 rounded-full",children:"Connected"}),"not_configured"===X&&(0,l.jsx)("span",{className:"px-1.5 py-0.5 text-[10px] font-medium bg-yellow-500/10 text-yellow-600 dark:text-yellow-400 rounded-full",children:"Not configured"}),"other"===X&&(0,l.jsx)("span",{className:"px-1.5 py-0.5 text-[10px] font-medium bg-blue-500/10 text-blue-600 dark:text-blue-400 rounded-full",children:"Other"})]}),(0,l.jsx)("p",{className:"text-xs text-text-muted truncate",children:e.description})]})]}),(0,l.jsx)("span",{className:`material-symbols-outlined text-text-muted text-[20px] transition-transform ${t?"rotate-180":""}`,children:"expand_more"})]}),t&&(0,l.jsxs)("div",{className:"mt-4 pt-4 border-t border-border flex flex-col gap-4",children:[_&&(0,l.jsxs)("div",{className:"flex items-center gap-2 text-text-muted",children:[(0,l.jsx)("span",{className:"material-symbols-outlined animate-spin",children:"progress_activity"}),(0,l.jsx)("span",{children:"Checking Codex CLI..."})]}),!_&&k&&!k.installed&&(0,l.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,l.jsxs)("div",{className:"flex flex-col gap-3 p-4 bg-yellow-500/10 border border-yellow-500/30 rounded-lg",children:[(0,l.jsxs)("div",{className:"flex items-start gap-3",children:[(0,l.jsx)("span",{className:"material-symbols-outlined text-yellow-500",children:"warning"}),(0,l.jsxs)("div",{className:"flex-1",children:[(0,l.jsx)("p",{className:"font-medium text-yellow-600 dark:text-yellow-400",children:"Codex CLI not detected locally"}),(0,l.jsx)("p",{className:"text-sm text-text-muted",children:"Manual configuration is still available if 9router is deployed on a remote server."})]})]}),(0,l.jsxs)("div",{className:"flex items-center gap-2 pl-9",children:[(0,l.jsxs)(r.$n,{variant:"secondary",size:"sm",onClick:()=>V(!0),className:"!bg-yellow-500/20 !border-yellow-500/40 !text-yellow-700 dark:!text-yellow-300 hover:!bg-yellow-500/30",children:[(0,l.jsx)("span",{className:"material-symbols-outlined text-[18px] mr-1",children:"content_copy"}),"Manual Config"]}),(0,l.jsxs)(r.$n,{variant:"outline",size:"sm",onClick:()=>R(!I),children:[(0,l.jsx)("span",{className:"material-symbols-outlined text-[18px] mr-1",children:I?"expand_less":"help"}),I?"Hide":"How to Install"]})]})]}),I&&(0,l.jsxs)("div",{className:"p-4 bg-surface border border-border rounded-lg",children:[(0,l.jsx)("h4",{className:"font-medium mb-3",children:"Installation Guide"}),(0,l.jsxs)("div",{className:"space-y-3 text-sm",children:[(0,l.jsxs)("div",{children:[(0,l.jsx)("p",{className:"text-text-muted mb-1",children:"macOS / Linux / Windows:"}),(0,l.jsx)("code",{className:"block px-3 py-2 bg-black/5 dark:bg-white/5 rounded font-mono text-xs",children:"npm install -g @openai/codex"})]}),(0,l.jsxs)("p",{className:"text-text-muted",children:["After installation, run ",(0,l.jsx)("code",{className:"px-1 bg-black/5 dark:bg-white/5 rounded",children:"codex"})," to verify."]}),(0,l.jsx)("div",{className:"pt-2 border-t border-border",children:(0,l.jsxs)("p",{className:"text-text-muted text-xs",children:["Codex uses ",(0,l.jsx)("code",{className:"px-1 bg-black/5 dark:bg-white/5 rounded",children:"~/.codex/auth.json"})," with ",(0,l.jsx)("code",{className:"px-1 bg-black/5 dark:bg-white/5 rounded",children:"OPENAI_API_KEY"}),'. Click "Apply" to auto-configure.']})})]})]})]}),!_&&k?.installed&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,l.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr] sm:items-center sm:gap-2",children:[(0,l.jsx)("span",{className:"text-xs font-semibold text-text-main sm:text-right sm:text-sm",children:"Select Endpoint"}),(0,l.jsx)("span",{className:"material-symbols-outlined hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,l.jsx)(x,{value:Y||Y||`${n}/v1`,onChange:Z,requiresExternalUrl:e.requiresExternalUrl,tunnelEnabled:p,tunnelPublicUrl:h,tailscaleEnabled:f,tailscaleUrl:y})]}),k?.config&&((N=(j=k.config.match(/base_url\s*=\s*"([^"]+)"/))?j[1]:null)?(0,l.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr_auto] sm:items-center sm:gap-2",children:[(0,l.jsx)("span",{className:"text-xs font-semibold text-text-main sm:text-right sm:text-sm",children:"Current"}),(0,l.jsx)("span",{className:"material-symbols-outlined hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,l.jsx)("span",{className:"min-w-0 truncate rounded bg-surface/40 px-2 py-2 text-xs text-text-muted sm:py-1.5",children:N})]}):null),(0,l.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr_auto] sm:items-center sm:gap-2",children:[(0,l.jsx)("span",{className:"text-xs font-semibold text-text-main sm:text-right sm:text-sm",children:"API Key"}),(0,l.jsx)("span",{className:"material-symbols-outlined hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,l.jsx)(u,{value:U,onChange:T,apiKeys:o,cloudEnabled:c})]}),(0,l.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr_auto] sm:items-center sm:gap-2",children:[(0,l.jsx)("span",{className:"text-xs font-semibold text-text-main sm:text-right sm:text-sm",children:"Model"}),(0,l.jsx)("span",{className:"material-symbols-outlined hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,l.jsxs)("div",{className:"relative w-full min-w-0",children:[(0,l.jsx)("input",{type:"text",value:D,onChange:e=>K(e.target.value),placeholder:"provider/model-id",className:"w-full min-w-0 pl-2 pr-7 py-2 bg-surface rounded border border-border text-xs focus:outline-none focus:ring-1 focus:ring-primary/50 sm:py-1.5"}),D&&(0,l.jsx)("button",{onClick:()=>K(""),className:"absolute right-1 top-1/2 -translate-y-1/2 p-0.5 text-text-muted hover:text-red-500 rounded transition-colors",title:"Clear",children:(0,l.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"close"})})]}),(0,l.jsx)("button",{onClick:()=>q(!0),disabled:!d?.length,className:`w-full sm:w-auto rounded border px-2 py-2 text-xs transition-colors sm:py-1.5 whitespace-nowrap sm:shrink-0 ${d?.length?"bg-surface border-border text-text-main hover:border-primary cursor-pointer":"opacity-50 cursor-not-allowed border-border"}`,children:"Select Model"})]}),(0,l.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr_auto] sm:items-center sm:gap-2",children:[(0,l.jsx)("span",{className:"text-xs font-semibold text-text-main sm:text-right sm:text-sm",children:"Subagent Model"}),(0,l.jsx)("span",{className:"material-symbols-outlined hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,l.jsxs)("div",{className:"relative w-full min-w-0",children:[(0,l.jsx)("input",{type:"text",value:z,onChange:e=>L(e.target.value),placeholder:D||"provider/model-id (defaults to main model)",className:"w-full min-w-0 pl-2 pr-7 py-2 bg-surface rounded border border-border text-xs focus:outline-none focus:ring-1 focus:ring-primary/50 sm:py-1.5"}),z&&(0,l.jsx)("button",{onClick:()=>L(""),className:"absolute right-1 top-1/2 -translate-y-1/2 p-0.5 text-text-muted hover:text-red-500 rounded transition-colors",title:"Clear (will use main model)",children:(0,l.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"close"})})]}),(0,l.jsx)("button",{onClick:()=>B(!0),disabled:!d?.length,className:`w-full sm:w-auto rounded border px-2 py-2 text-xs transition-colors sm:py-1.5 whitespace-nowrap sm:shrink-0 ${d?.length?"bg-surface border-border text-text-main hover:border-primary cursor-pointer":"opacity-50 cursor-not-allowed border-border"}`,children:"Select Model"})]})]}),P&&(0,l.jsxs)("div",{className:`flex items-center gap-2 px-2 py-1.5 rounded text-xs ${"success"===P.type?"bg-green-500/10 text-green-600":"bg-red-500/10 text-red-600"}`,children:[(0,l.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"success"===P.type?"check_circle":"error"}),(0,l.jsx)("span",{children:P.text})]}),(0,l.jsxs)("div",{className:"grid grid-cols-1 gap-2 sm:flex sm:items-center",children:[(0,l.jsxs)(r.$n,{variant:"primary",size:"sm",onClick:es,disabled:!U&&c&&o.length>0||!D,loading:E,children:[(0,l.jsx)("span",{className:"material-symbols-outlined text-[14px] mr-1",children:"save"}),"Apply"]}),(0,l.jsxs)(r.$n,{variant:"outline",size:"sm",onClick:el,disabled:O,loading:O,children:[(0,l.jsx)("span",{className:"material-symbols-outlined text-[14px] mr-1",children:"restore"}),"Reset"]}),(0,l.jsxs)(r.$n,{variant:"ghost",size:"sm",onClick:()=>V(!0),children:[(0,l.jsx)("span",{className:"material-symbols-outlined text-[14px] mr-1",children:"content_copy"}),"Manual Config"]})]})]})]}),(0,l.jsx)(r.rq,{isOpen:F,onClose:()=>q(!1),onSelect:e=>{K(e.value),z||L(e.value),q(!1)},selectedModel:D,activeProviders:d,modelAliases:W,title:"Select Model for Codex"}),(0,l.jsx)(r.rq,{isOpen:H,onClose:()=>B(!1),onSelect:e=>{L(e.value),B(!1)},selectedModel:z,activeProviders:d,modelAliases:W,title:"Select Subagent Model for Codex"}),(0,l.jsx)(r.uR,{isOpen:G,onClose:()=>V(!1),title:"Codex CLI - Manual Configuration",configs:(v=U&&U.trim()?U:c?"<API_KEY_FROM_DASHBOARD>":"sk_9router",w=z||D,[{filename:"~/.codex/config.toml",content:`# 9Router Configuration for Codex CLI
24
24
  model = "${D}"
25
25
  model_provider = "9router"
26
26
 
@@ -0,0 +1,3 @@
1
+ (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[2134],{52720:(e,t,s)=>{"use strict";s.r(t),s.d(t,{default:()=>A});var a=s(95155),i=s(12115),l=s(73321),r=s(98500),n=s.n(r),o=s(5772),d=s(35497),c=s(52679),p=s(28777),m=s(11059);let x=new Map;async function u(e){if(!e?.url||!e?.type)return[];let t=x.get(e.url);if(t&&Date.now()<t.expiresAt)return t.data;try{let t=new URLSearchParams({url:e.url,type:e.type}),s=await fetch(`/api/providers/suggested-models?${t}`);if(!s.ok)return[];let a=(await s.json()).data??[];return x.set(e.url,{data:a,expiresAt:Date.now()+6e5}),a}catch{return[]}}var h=s(14051),f=s.n(h);function g({model:e,fullModel:t,alias:s,copied:i,onCopy:l,testStatus:r,isCustom:n,isFree:o,onDeleteAlias:d,onTest:c,isTesting:p,onDisable:m,isFirst:x,isLast:u,onMoveUp:h,onMoveDown:f}){let y="ok"===r?"#22c55e":"error"===r?"#ef4444":void 0;return(0,a.jsx)("div",{className:`group min-w-0 max-w-full rounded-lg border px-3 py-2 ${"ok"===r?"border-green-500/40":"error"===r?"border-red-500/40":"border-border"} hover:bg-sidebar/50`,children:(0,a.jsxs)("div",{className:"flex min-w-0 items-start gap-2 sm:items-center",children:[(h||f)&&(0,a.jsxs)("div",{className:"flex shrink-0 flex-col",children:[(0,a.jsx)("button",{onClick:h,disabled:x,className:`p-0.5 rounded ${x?"text-text-muted/30 cursor-not-allowed":"hover:bg-sidebar text-text-muted hover:text-primary"}`,children:(0,a.jsx)("span",{className:"material-symbols-outlined text-sm",children:"keyboard_arrow_up"})}),(0,a.jsx)("button",{onClick:f,disabled:u,className:`p-0.5 rounded ${u?"text-text-muted/30 cursor-not-allowed":"hover:bg-sidebar text-text-muted hover:text-primary"}`,children:(0,a.jsx)("span",{className:"material-symbols-outlined text-sm",children:"keyboard_arrow_down"})})]}),(0,a.jsx)("span",{className:"material-symbols-outlined shrink-0 text-base",style:y?{color:y}:void 0,children:"ok"===r?"check_circle":"error"===r?"cancel":"smart_toy"}),(0,a.jsxs)("div",{className:"flex min-w-0 flex-1 flex-col gap-1",children:[(0,a.jsx)("code",{className:"max-w-[72vw] truncate rounded bg-sidebar px-1.5 py-0.5 font-mono text-xs text-text-muted sm:max-w-[360px]",children:t}),e.name&&(0,a.jsx)("span",{className:"truncate pl-1 text-[9px] italic text-text-muted/70",children:e.name})]}),c&&(0,a.jsxs)("div",{className:"relative shrink-0 group/btn",children:[(0,a.jsx)("button",{onClick:c,disabled:p,className:`rounded p-0.5 text-text-muted transition-opacity hover:bg-sidebar hover:text-primary ${p?"opacity-100":"opacity-100 sm:opacity-0 sm:group-hover:opacity-100"}`,children:(0,a.jsx)("span",{className:"material-symbols-outlined text-sm",style:p?{animation:"spin 1s linear infinite"}:void 0,children:p?"progress_activity":"science"})}),(0,a.jsx)("span",{className:"pointer-events-none absolute mt-1 top-5 left-1/2 -translate-x-1/2 text-[10px] text-text-muted whitespace-nowrap opacity-0 group-hover/btn:opacity-100 transition-opacity",children:p?"Testing...":"Test"})]}),(0,a.jsxs)("div",{className:"relative shrink-0 group/btn",children:[(0,a.jsx)("button",{onClick:()=>l(t,`model-${e.id}`),className:"rounded p-0.5 text-text-muted hover:bg-sidebar hover:text-primary",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-sm",children:i===`model-${e.id}`?"check":"content_copy"})}),(0,a.jsx)("span",{className:"pointer-events-none absolute mt-1 top-5 left-1/2 -translate-x-1/2 text-[10px] text-text-muted whitespace-nowrap opacity-0 group-hover/btn:opacity-100 transition-opacity",children:i===`model-${e.id}`?"Copied!":"Copy"})]}),n?(0,a.jsx)("button",{onClick:d,className:"ml-auto rounded p-0.5 text-text-muted opacity-100 transition-opacity hover:bg-red-500/10 hover:text-red-500 sm:opacity-0 sm:group-hover:opacity-100",title:"Remove custom model",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-sm",children:"close"})}):m?(0,a.jsx)("button",{onClick:m,className:"ml-auto rounded p-0.5 text-text-muted opacity-100 transition-opacity hover:bg-red-500/10 hover:text-red-500 sm:opacity-0 sm:group-hover:opacity-100",title:"Disable this model",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-sm",children:"close"})}):null]})})}function y({modelId:e,fullModel:t,copied:s,onCopy:i,onDeleteAlias:l,onTest:r,testStatus:n,isTesting:o}){let d="ok"===n?"#22c55e":"error"===n?"#ef4444":void 0;return(0,a.jsxs)("div",{className:`flex items-center gap-3 p-3 rounded-lg border ${"ok"===n?"border-green-500/40":"error"===n?"border-red-500/40":"border-border"} hover:bg-sidebar/50`,children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-base text-text-muted",style:d?{color:d}:void 0,children:"ok"===n?"check_circle":"error"===n?"cancel":"smart_toy"}),(0,a.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,a.jsx)("p",{className:"text-sm font-medium truncate",children:e}),(0,a.jsxs)("div",{className:"flex items-center gap-1 mt-1",children:[(0,a.jsx)("code",{className:"text-xs text-text-muted font-mono bg-sidebar px-1.5 py-0.5 rounded",children:t}),(0,a.jsxs)("div",{className:"relative group/btn",children:[(0,a.jsx)("button",{onClick:()=>i(t,`model-${e}`),className:"p-0.5 hover:bg-sidebar rounded text-text-muted hover:text-primary",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-sm",children:s===`model-${e}`?"check":"content_copy"})}),(0,a.jsx)("span",{className:"pointer-events-none absolute top-5 left-1/2 -translate-x-1/2 text-[10px] text-text-muted whitespace-nowrap opacity-0 group-hover/btn:opacity-100 transition-opacity",children:s===`model-${e}`?"Copied!":"Copy"})]}),r&&(0,a.jsxs)("div",{className:"relative group/btn",children:[(0,a.jsx)("button",{onClick:r,disabled:o,className:"p-0.5 hover:bg-sidebar rounded text-text-muted hover:text-primary transition-colors",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-sm",style:o?{animation:"spin 1s linear infinite"}:void 0,children:o?"progress_activity":"science"})}),(0,a.jsx)("span",{className:"pointer-events-none absolute top-5 left-1/2 -translate-x-1/2 text-[10px] text-text-muted whitespace-nowrap opacity-0 group-hover/btn:opacity-100 transition-opacity",children:o?"Testing...":"Test"})]})]})]}),(0,a.jsx)("button",{onClick:l,className:"p-1 hover:bg-red-50 rounded text-red-500",title:"Remove model",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-sm",children:"delete"})})]})}function b({providerStorageAlias:e,providerDisplayAlias:t,modelAliases:s,copied:l,onCopy:r,onSetAlias:n,onDeleteAlias:o,connections:c,isAnthropic:p}){let[m,x]=(0,i.useState)(""),[u,h]=(0,i.useState)(!1),[f,g]=(0,i.useState)(!1),[v,j]=(0,i.useState)(null),[N,k]=(0,i.useState)({}),w=async t=>{if(!v){j(t);try{let s=await fetch("/api/models/test",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({model:`${e}/${t}`})}),a=await s.json();k(e=>({...e,[t]:a.ok?"ok":"error"}))}catch{k(e=>({...e,[t]:"error"}))}finally{j(null)}}},C=Object.entries(s).filter(([,t])=>t.startsWith(`${e}/`)).map(([t,s])=>({modelId:s.replace(`${e}/`,""),fullModel:s,alias:t})),S=a=>{let i,l=`${e}/${a}`;if(Object.values(s).includes(l))return null;let r=(i=a.split("/"))[i.length-1];if(!s[r])return r;let n=`${t}-${r}`;return s[n]?null:n},$=async()=>{if(!m.trim()||u)return;let t=m.trim(),a=`${e}/${t}`;if(Object.values(s).includes(a))return void alert("Model already added.");let 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 n(t,i,e),x("")}catch(e){console.log("Error adding model:",e)}finally{h(!1)}},A=async()=>{if(f)return;let t=c.find(e=>!1!==e.isActive);if(t){g(!0);try{let s=await fetch(`/api/providers/${t.id}/models`),a=await s.json();if(!s.ok)return void alert(a.error||"Failed to import models");let i=a.models||[];if(0===i.length)return void alert("No models returned from /models.");let l=0;for(let t of i){let s=t.id||t.name||t.model;if(!s)continue;let a=S(s);a&&(await n(s,a,e),l+=1)}0===l&&alert("No new models were added.")}catch(e){console.log("Error importing models:",e)}finally{g(!1)}}},P=c.some(e=>!1!==e.isActive);return(0,a.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,a.jsxs)("p",{className:"text-sm text-text-muted",children:["Add ",p?"Anthropic":"OpenAI","-compatible models manually or import them from the /models endpoint."]}),(0,a.jsxs)("div",{className:"flex items-end gap-2 flex-wrap",children:[(0,a.jsxs)("div",{className:"flex-1 min-w-[240px]",children:[(0,a.jsx)("label",{htmlFor:"new-compatible-model-input",className:"text-xs text-text-muted mb-1 block",children:"Model ID"}),(0,a.jsx)("input",{id:"new-compatible-model-input",type:"text",value:m,onChange:e=>x(e.target.value),onKeyDown:e=>"Enter"===e.key&&$(),placeholder:p?"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,a.jsx)(d.$n,{size:"sm",icon:"add",onClick:$,disabled:!m.trim()||u,children:u?"Adding...":"Add"}),(0,a.jsx)(d.$n,{size:"sm",variant:"secondary",icon:"download",onClick:A,disabled:!P||f,children:f?"Importing...":"Import from /models"})]}),!P&&(0,a.jsx)("p",{className:"text-xs text-text-muted",children:"Add a connection to enable importing models."}),C.length>0&&(0,a.jsx)("div",{className:"flex flex-col gap-3",children:C.map(({modelId:e,fullModel:s,alias:i})=>(0,a.jsx)(y,{modelId:e,fullModel:`${t}/${e}`,copied:l,onCopy:r,onDeleteAlias:()=>o(i),onTest:c.length>0?()=>w(e):void 0,testStatus:N[e],isTesting:v===e},s))})]})}function v({until:e}){let[t,s]=(0,i.useState)("");return((0,i.useEffect)(()=>{let t=()=>{let t=new Date(e).getTime()-Date.now();if(t<=0)return void s("");let a=Math.floor(t/1e3);if(a<60)s(`${a}s`);else if(a<3600)s(`${Math.floor(a/60)}m ${a%60}s`);else{let e=Math.floor(a/3600),t=Math.floor(a%3600/60);s(`${e}h ${t}m`)}};t();let a=setInterval(t,1e3);return()=>clearInterval(a)},[e]),t)?(0,a.jsxs)("span",{className:"text-xs text-orange-500 font-mono",children:["⏱ ",t]}):null}function j({connection:e,proxyPools:t,isOAuth:s,isFirst:l,isLast:r,onMoveUp:n,onMoveDown:o,onToggleActive:c,onUpdateProxy:p,onEdit:m,onDelete:x,oneByOneStatus:u=null}){let[h,f]=(0,i.useState)(!1),[g,y]=(0,i.useState)(!1),b=(0,i.useRef)(null),N=new Map((t||[]).map(e=>[e.id,e])),k=e.providerSpecificData?.proxyPoolId||null,w=k?N.get(k):null,C=e.providerSpecificData?.connectionProxyEnabled===!0&&!!e.providerSpecificData?.connectionProxyUrl,S=!!k||C,$=w?`Pool: ${w.name}`:k?`Pool: ${k} (inactive/missing)`:C?`Legacy: ${e.providerSpecificData?.connectionProxyUrl}`:"",A="";if(w?.proxyUrl||e.providerSpecificData?.connectionProxyUrl){let t=w?.proxyUrl||e.providerSpecificData?.connectionProxyUrl;try{let e=new URL(t);A=`${e.protocol}//${e.hostname}${e.port?`:${e.port}`:""}`}catch{A=t}}let P=w?.noProxy||e.providerSpecificData?.connectionNoProxy||"",T="default";w?.isActive===!0?T="success":(k||C)&&(T="error"),(0,i.useEffect)(()=>{if(!h)return;let e=e=>{b.current&&!b.current.contains(e.target)&&f(!1)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[h]);let O=async e=>{y(!0);try{await p("__none__"===e?null:e)}finally{y(!1),f(!1)}},E=e.authType||(s?"oauth":"apikey"),I="oauth"===E,D="cookie"===E,R=e=>"string"==typeof e&&/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e),U=I?R(e.email)?e.email:R(e.name)?e.name:e.name||e.email||e.displayName||"OAuth Account":e.name||e.email||e.displayName||"API Key",[_,z]=(0,i.useState)(!1),q=Object.entries(e).filter(([e])=>e.startsWith("modelLock_")).map(([,e])=>e).filter(e=>!!e).sort()[0]||null;(0,i.useEffect)(()=>{let t=()=>{z(!!Object.entries(e).filter(([e])=>e.startsWith("modelLock_")).map(([,e])=>e).filter(e=>e&&new Date(e).getTime()>Date.now()).sort()[0])};t();let s=q?setInterval(t,1e3):null;return()=>{s&&clearInterval(s)}},[q]);let M="unavailable"!==e.testStatus||_?e.testStatus:"active",K=()=>u?"queued"===u.state?"queued":"testing"===u.state?"testing":"success"===u.state?"success":"failed"===u.state?u.error?`failed: ${u.error}`:"failed":null:null;return(0,a.jsxs)("div",{className:`group flex min-w-0 flex-col gap-3 rounded-lg p-2 transition-colors hover:bg-black/[0.02] dark:hover:bg-white/[0.02] sm:flex-row sm:items-center sm:justify-between ${!1===e.isActive?"opacity-60":""}`,children:[(0,a.jsxs)("div",{className:"flex min-w-0 flex-1 items-start gap-2 sm:items-center sm:gap-3",children:[(0,a.jsxs)("div",{className:"flex shrink-0 flex-col",children:[(0,a.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,a.jsx)("span",{className:"material-symbols-outlined text-sm",children:"keyboard_arrow_up"})}),(0,a.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,a.jsx)("span",{className:"material-symbols-outlined text-sm",children:"keyboard_arrow_down"})})]}),(0,a.jsx)("span",{className:"material-symbols-outlined shrink-0 text-base text-text-muted",children:D?"cookie":I?"lock":"key"}),(0,a.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,a.jsx)("p",{className:"text-sm font-medium truncate",children:U}),(0,a.jsxs)("div",{className:"mt-1 flex min-w-0 flex-wrap items-center gap-1.5 sm:gap-2",children:[(0,a.jsx)(d.Ex,{variant:!1===e.isActive?"default":"active"===M||"success"===M?"success":"error"===M||"expired"===M||"unavailable"===M?"error":"default",size:"sm",dot:!0,children:!1===e.isActive?"disabled":M||"Unknown"}),(0,a.jsx)(d.Ex,{variant:"default",size:"sm",children:I?"OAuth":D?"Cookie":"API Key"}),S&&(0,a.jsx)(d.Ex,{variant:T,size:"sm",children:"Proxy"}),_&&!1!==e.isActive&&(0,a.jsx)(v,{until:q}),e.lastError&&!1!==e.isActive&&(0,a.jsx)("span",{className:"max-w-full truncate text-xs text-red-500 sm:max-w-[300px]",title:e.lastError,children:e.lastError}),(0,a.jsxs)("span",{className:"text-xs text-text-muted",children:["#",e.priority]}),e.globalPriority&&(0,a.jsxs)("span",{className:"text-xs text-text-muted",children:["Auto: ",e.globalPriority]}),K()&&(0,a.jsx)(d.Ex,{variant:u?"success"===u.state?"success":"failed"===u.state?"error":"testing"===u.state?"primary":"default":"default",size:"sm",children:K()})]}),S&&(0,a.jsxs)("div",{className:"mt-1 flex items-center gap-2 flex-wrap",children:[(0,a.jsx)("span",{className:"max-w-full truncate text-[11px] text-text-muted sm:max-w-[420px]",title:$,children:$}),A&&(0,a.jsx)("code",{className:"max-w-full truncate rounded bg-black/5 px-1 py-0.5 font-mono text-[10px] text-text-muted dark:bg-white/5 sm:max-w-[260px]",children:A}),P&&(0,a.jsxs)("span",{className:"max-w-full truncate text-[11px] text-text-muted sm:max-w-[320px]",title:P,children:["no_proxy: ",P]})]})]})]}),(0,a.jsxs)("div",{className:"flex w-full items-center justify-between gap-2 sm:w-auto sm:justify-end",children:[(0,a.jsxs)("div",{className:"grid flex-1 grid-cols-3 gap-1 sm:flex sm:flex-none",children:[(t||[]).length>0&&(0,a.jsxs)("div",{className:"relative",ref:b,children:[(0,a.jsxs)("button",{onClick:()=>f(e=>!e),className:`flex w-full flex-col items-center rounded px-2 py-1 transition-colors hover:bg-black/5 dark:hover:bg-white/5 ${S?"text-primary":"text-text-muted hover:text-primary"}`,disabled:g,children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:g?"progress_activity":"lan"}),(0,a.jsx)("span",{className:"text-[10px] leading-tight",children:"Proxy"})]}),h&&(0,a.jsxs)("div",{className:"absolute right-0 top-full z-50 mt-1 max-w-[78vw] min-w-[160px] rounded-lg border border-border bg-bg py-1 shadow-lg",children:[(0,a.jsx)("button",{onClick:()=>O("__none__"),className:`w-full text-left px-3 py-1.5 text-sm hover:bg-black/5 dark:hover:bg-white/5 ${!k?"text-primary font-medium":"text-text-main"}`,children:"None"}),(t||[]).map(e=>(0,a.jsx)("button",{onClick:()=>O(e.id),className:`w-full text-left px-3 py-1.5 text-sm hover:bg-black/5 dark:hover:bg-white/5 ${k===e.id?"text-primary font-medium":"text-text-main"}`,children:e.name},e.id))]})]}),(0,a.jsxs)("button",{onClick:m,className:"flex flex-col items-center rounded px-2 py-1 text-text-muted hover:bg-black/5 hover:text-primary dark:hover:bg-white/5",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:"edit"}),(0,a.jsx)("span",{className:"text-[10px] leading-tight",children:"Edit"})]}),(0,a.jsxs)("button",{onClick:x,className:"flex flex-col items-center rounded px-2 py-1 text-red-500 hover:bg-red-500/10",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:"delete"}),(0,a.jsx)("span",{className:"text-[10px] leading-tight",children:"Delete"})]})]}),(0,a.jsx)(d.lM,{size:"sm",checked:e.isActive??!0,onChange:c,title:e.isActive??!0?"Disable connection":"Enable connection"})]})]})}g.propTypes={model:f().shape({id:f().string.isRequired}).isRequired,fullModel:f().string.isRequired,alias:f().string,copied:f().string,onCopy:f().func.isRequired,testStatus:f().oneOf(["ok","error"]),isCustom:f().bool,isFree:f().bool,onDeleteAlias:f().func,onTest:f().func,isTesting:f().bool,onDisable:f().func,isFirst:f().bool,isLast:f().bool,onMoveUp:f().func,onMoveDown:f().func},f().string.isRequired,f().string.isRequired,f().string,f().func.isRequired,f().func.isRequired,f().func,f().oneOf(["ok","error"]),f().bool,f().string.isRequired,f().object.isRequired,f().string,f().func.isRequired,f().func.isRequired,f().func.isRequired,b.propTypes={providerStorageAlias:f().string.isRequired,providerDisplayAlias:f().string.isRequired,modelAliases:f().object.isRequired,copied:f().string,onCopy:f().func.isRequired,onSetAlias:f().func.isRequired,onDeleteAlias:f().func.isRequired,connections:f().arrayOf(f().shape({id:f().string,isActive:f().bool})).isRequired,isAnthropic:f().bool},v.propTypes={until:f().string.isRequired},j.propTypes={connection:f().shape({id:f().string,name:f().string,email:f().string,displayName:f().string,modelLockUntil:f().string,testStatus:f().string,isActive:f().bool,lastError:f().string,priority:f().number,globalPriority:f().number}).isRequired,proxyPools:f().arrayOf(f().shape({id:f().string,name:f().string,proxyUrl:f().string,noProxy:f().string,isActive:f().bool})),isOAuth:f().bool.isRequired,isFirst:f().bool.isRequired,isLast:f().bool.isRequired,onMoveUp:f().func.isRequired,onMoveDown:f().func.isRequired,onToggleActive:f().func.isRequired,onUpdateProxy:f().func,onEdit:f().func.isRequired,onDelete:f().func.isRequired,oneByOneStatus:f().shape({state:f().string,error:f().string})};let N=`name1|sk-key1
2
+ name2|sk-key2
3
+ sk-key-only-auto-named`;function k({isOpen:e,provider:t,providerName:s,isCompatible:l,isAnthropic:r,authType:n,authHint:o,website:p,proxyPools:m,error:x,onSave:u,onBulkDone:h,onClose:f}){let g="__none__",y="ollama-local"===t,b="cookie"===n,v="xai"===t&&!b,j=b?"Cookie Value":"API Key",w="azure"===t,C="cloudflare-ai"===t,S=c.Q2?.[t]?.regions||null,$=c.Q2?.[t]?.defaultRegion||S?.[0]?.id||"",[A,P]=(0,i.useState)({name:"",apiKey:"",defaultModel:"",priority:1,proxyPoolId:g,ollamaHostUrl:""}),[T,O]=(0,i.useState)({azureEndpoint:"",apiVersion:"2024-10-01-preview",deployment:"",organization:""}),[E,I]=(0,i.useState)({accountId:""}),[D,R]=(0,i.useState)($),[U,_]=(0,i.useState)(!1),[z,q]=(0,i.useState)(null),[M,K]=(0,i.useState)(!1),[F,L]=(0,i.useState)("single"),[J,W]=(0,i.useState)(""),[B,H]=(0,i.useState)(null),V=()=>y&&A.ollamaHostUrl.trim()?{baseUrl:A.ollamaHostUrl.trim()}:w?{azureEndpoint:T.azureEndpoint,apiVersion:T.apiVersion,deployment:T.deployment,organization:T.organization}:C?{accountId:E.accountId}:S&&D?{region:D}:void 0,G=async()=>{_(!0);try{let e=await fetch("/api/providers/validate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:t,apiKey:A.apiKey,providerSpecificData:V()})}),s=await e.json();q(s.valid?"success":"failed")}catch{q("failed")}finally{_(!1)}},Q=async()=>{if(t&&(y||A.apiKey)&&(y||A.name)&&(!l||A.defaultModel.trim())){K(!0);try{let e=!1;try{_(!0),q(null);let s=await fetch("/api/providers/validate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:t,apiKey:A.apiKey,providerSpecificData:V()})});e=!!(await s.json()).valid,q(e?"success":"failed")}catch{q("failed")}finally{_(!1)}await u({name:A.name||(y?"Ollama Local":""),apiKey:A.apiKey,defaultModel:l?A.defaultModel.trim():void 0,priority:A.priority,proxyPoolId:A.proxyPoolId===g?null:A.proxyPoolId,testStatus:e?"active":"unknown",providerSpecificData:V()})}finally{K(!1)}}},Z=async()=>{let e=J.split("\n").map(e=>e.trim()).filter(Boolean);if(!e.length)return;K(!0),H(null);let s=0,a=0;for(let i=0;i<e.length;i++){let l=e[i].split("|"),r=l.length>=2?l.slice(1).join("|").trim():l[0].trim(),n=l.length>=2?l[0].trim():"Key",o=`${n} ${i+1}`;try{(await fetch("/api/providers",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:t,apiKey:r,name:o,priority:1,testStatus:"unknown"})})).ok?s++:a++}catch{a++}}K(!1),H({success:s,failed:a}),s>0&&h&&h()};return t?(0,a.jsx)(d.aF,{isOpen:e,title:`Add ${s||t} ${j}`,onClose:f,children:(0,a.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsx)(d.$n,{size:"sm",variant:"single"===F?"primary":"ghost",onClick:()=>{L("single"),H(null)},children:"Single"}),(0,a.jsx)(d.$n,{size:"sm",variant:"bulk"===F?"primary":"ghost",onClick:()=>{L("bulk"),H(null)},children:"Bulk Add"})]}),"bulk"===F&&(0,a.jsxs)("div",{className:"flex flex-col gap-3",children:[(0,a.jsxs)("p",{className:"text-xs text-text-muted",children:["One key per line. Format: ",(0,a.jsx)("code",{children:"name|apiKey"})," or just ",(0,a.jsx)("code",{children:"apiKey"})," (auto-named by index)."]}),(0,a.jsx)("textarea",{className:"w-full rounded border border-accent/30 bg-sidebar p-2 text-sm font-mono resize-y min-h-[140px] focus:outline-none focus:ring-1 focus:ring-primary",placeholder:N,value:J,onChange:e=>W(e.target.value)}),B&&(0,a.jsxs)("div",{className:`text-sm font-medium ${B.failed>0?"text-yellow-400":"text-green-400"}`,children:["✓ ",B.success," added",B.failed>0?`, ✗ ${B.failed} failed`:""]}),(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsx)(d.$n,{onClick:Z,fullWidth:!0,disabled:M||!J.trim(),children:M?"Adding...":"Add All Keys"}),(0,a.jsx)(d.$n,{onClick:f,variant:"ghost",fullWidth:!0,children:"Cancel"})]})]}),"single"===F&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(d.pd,{label:"Name",value:A.name,onChange:e=>P({...A,name:e.target.value}),placeholder:y?"Ollama Local":"Production Key"}),y&&(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsx)(d.pd,{label:"Ollama Host URL",value:A.ollamaHostUrl,onChange:e=>P({...A,ollamaHostUrl:e.target.value}),placeholder:"http://localhost:11434",className:"flex-1"}),(0,a.jsx)("div",{className:"pt-6",children:(0,a.jsx)(d.$n,{onClick:G,disabled:U||M,variant:"secondary",children:U?"Checking...":"Check"})})]}),!y&&(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsx)(d.pd,{label:j,type:b?"text":"password",value:A.apiKey,onChange:e=>P({...A,apiKey:e.target.value}),placeholder:b?"grok-web"===t?"sso=xxxxx... or just the raw value":"eyJhbGciOi...":v?"xai-...":"",className:"flex-1"}),(0,a.jsx)("div",{className:"pt-6",children:(0,a.jsx)(d.$n,{onClick:G,disabled:!A.apiKey||U||M,variant:"secondary",children:U?"Checking...":"Check"})})]}),v&&(0,a.jsx)("p",{className:"text-xs text-text-muted",children:"Use a direct xAI API key from console.x.ai. This is separate from Grok Build OAuth."}),b&&o&&(0,a.jsxs)("p",{className:"text-xs text-text-muted",children:[o,p&&(0,a.jsxs)(a.Fragment,{children:[" ",(0,a.jsxs)("a",{href:p,target:"_blank",rel:"noopener noreferrer",className:"text-primary underline",children:["Open ",p.replace(/^https?:\/\//,"")]})]})]}),S&&(0,a.jsx)(d.l6,{label:"Region",value:D,onChange:e=>R(e.target.value),options:S.map(e=>({value:e.id,label:e.label}))}),l&&(0,a.jsx)(d.pd,{label:"Default Model",value:A.defaultModel,onChange:e=>P({...A,defaultModel:e.target.value}),placeholder:r?"claude-3-5-sonnet-latest":"gpt-4o-mini"}),y&&(0,a.jsxs)("p",{className:"text-xs text-text-muted",children:["Leave blank to use ",(0,a.jsx)("code",{children:"http://localhost:11434"}),". For remote Ollama, enter the full host URL (e.g. ",(0,a.jsx)("code",{children:"http://192.168.1.10:11434"}),")."]}),z&&(0,a.jsx)(d.Ex,{variant:"success"===z?"success":"error",children:"success"===z?"Valid":"Invalid"}),x&&(0,a.jsx)("p",{className:"text-xs text-red-500 break-words",children:x}),l&&(0,a.jsx)("p",{className:"text-xs text-text-muted",children:"Enter the model ID exactly as your compatible endpoint expects it. This model will be saved as the connection default."}),C&&(0,a.jsxs)("div",{className:"bg-sidebar/50 p-4 rounded-lg border border-accent/20",children:[(0,a.jsx)("h3",{className:"font-semibold mb-3 text-sm",children:"Cloudflare Workers AI"}),(0,a.jsx)(d.pd,{label:"Account ID",value:E.accountId,onChange:e=>I({...E,accountId:e.target.value}),placeholder:"abc123def456..."}),(0,a.jsxs)("p",{className:"text-xs text-text-muted mt-2",children:["Find your Account ID in the right sidebar of ",(0,a.jsx)("a",{href:"https://dash.cloudflare.com",target:"_blank",rel:"noopener noreferrer",className:"text-primary underline",children:"dash.cloudflare.com"})]})]}),w&&(0,a.jsxs)("div",{className:"bg-sidebar/50 p-4 rounded-lg border border-accent/20",children:[(0,a.jsx)("h3",{className:"font-semibold mb-3 text-sm",children:"Azure OpenAI Configuration"}),(0,a.jsxs)("div",{className:"flex flex-col gap-3",children:[(0,a.jsx)(d.pd,{label:"Azure Endpoint",value:T.azureEndpoint,onChange:e=>O({...T,azureEndpoint:e.target.value}),placeholder:"https://your-resource.openai.azure.com"}),(0,a.jsx)(d.pd,{label:"Deployment Name",value:T.deployment,onChange:e=>O({...T,deployment:e.target.value}),placeholder:"gpt-4"}),(0,a.jsx)(d.pd,{label:"API Version",value:T.apiVersion,onChange:e=>O({...T,apiVersion:e.target.value}),placeholder:"2024-10-01-preview"}),(0,a.jsx)(d.pd,{label:"Organization",value:T.organization,onChange:e=>O({...T,organization:e.target.value}),placeholder:"Organization ID"})]})]}),(0,a.jsx)(d.pd,{label:"Priority",type:"number",value:A.priority,onChange:e=>P({...A,priority:Number.parseInt(e.target.value)||1})}),(0,a.jsx)(d.l6,{label:"Proxy Pool",value:A.proxyPoolId,onChange:e=>P({...A,proxyPoolId:e.target.value}),options:[{value:g,label:"None"},...(m||[]).map(e=>({value:e.id,label:e.name}))],placeholder:"None"}),0===(m||[]).length&&(0,a.jsx)("p",{className:"text-xs text-text-muted",children:"No active proxy pools available. Create one in Proxy Pools page first."}),(0,a.jsx)("p",{className:"text-xs text-text-muted",children:"Legacy manual proxy fields are still accepted by API for backward compatibility."}),(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsx)(d.$n,{onClick:Q,fullWidth:!0,disabled:M||!y&&(!A.name||!A.apiKey)||l&&!A.defaultModel.trim()||w&&(!T.azureEndpoint||!T.deployment||!T.organization)||C&&!E.accountId,children:M?"Saving...":"Save"}),(0,a.jsx)(d.$n,{onClick:f,variant:"ghost",fullWidth:!0,children:"Cancel"})]})]})]})}):null}function w({isOpen:e,node:t,onSave:s,onClose:l,isAnthropic:r}){let[n,o]=(0,i.useState)({name:"",prefix:"",apiType:"chat",baseUrl:"https://api.openai.com/v1"}),[c,p]=(0,i.useState)(!1),[m,x]=(0,i.useState)(""),[u,h]=(0,i.useState)(""),[f,g]=(0,i.useState)(!1),[y,b]=(0,i.useState)(null);(0,i.useEffect)(()=>{t&&o({name:t.name||"",prefix:t.prefix||"",apiType:t.apiType||"chat",baseUrl:t.baseUrl||(r?"https://api.anthropic.com/v1":"https://api.openai.com/v1")})},[t,r]);let v=async()=>{if(n.name.trim()&&n.prefix.trim()&&n.baseUrl.trim()){p(!0);try{let e={name:n.name,prefix:n.prefix,baseUrl:n.baseUrl};r||(e.apiType=n.apiType),await s(e)}finally{p(!1)}}},j=async()=>{g(!0);try{let e=await fetch("/api/provider-nodes/validate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({baseUrl:n.baseUrl,apiKey:m,type:r?"anthropic-compatible":"openai-compatible",modelId:u.trim()||void 0})}),t=await e.json();b(t.valid?"success":"failed")}catch{b("failed")}finally{g(!1)}};return t?(0,a.jsx)(d.aF,{isOpen:e,title:`Edit ${r?"Anthropic":"OpenAI"} Compatible`,onClose:l,children:(0,a.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,a.jsx)(d.pd,{label:"Name",value:n.name,onChange:e=>o({...n,name:e.target.value}),placeholder:`${r?"Anthropic":"OpenAI"} Compatible (Prod)`,hint:"Required. A friendly label for this node."}),(0,a.jsx)(d.pd,{label:"Prefix",value:n.prefix,onChange:e=>o({...n,prefix:e.target.value}),placeholder:r?"ac-prod":"oc-prod",hint:"Required. Used as the provider prefix for model IDs."}),!r&&(0,a.jsx)(d.l6,{label:"API Type",options:[{value:"chat",label:"Chat Completions"},{value:"responses",label:"Responses API"}],value:n.apiType,onChange:e=>o({...n,apiType:e.target.value})}),(0,a.jsx)(d.pd,{label:"Base URL",value:n.baseUrl,onChange:e=>o({...n,baseUrl:e.target.value}),placeholder:r?"https://api.anthropic.com/v1":"https://api.openai.com/v1",hint:`Use the base URL (ending in /v1) for your ${r?"Anthropic":"OpenAI"}-compatible API.`}),(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsx)(d.pd,{label:"API Key (for Check)",type:"password",value:m,onChange:e=>x(e.target.value),className:"flex-1"}),(0,a.jsx)("div",{className:"pt-6",children:(0,a.jsx)(d.$n,{onClick:j,disabled:!m||f||!n.baseUrl.trim(),variant:"secondary",children:f?"Checking...":"Check"})})]}),(0,a.jsx)(d.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."}),y&&(0,a.jsx)(d.Ex,{variant:"success"===y?"success":"error",children:"success"===y?"Valid":"Invalid"}),(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsx)(d.$n,{onClick:v,fullWidth:!0,disabled:!n.name.trim()||!n.prefix.trim()||!n.baseUrl.trim()||c,children:c?"Saving...":"Save"}),(0,a.jsx)(d.$n,{onClick:l,variant:"ghost",fullWidth:!0,children:"Cancel"})]})]})}):null}function C({isOpen:e,providerAlias:t,providerDisplayAlias:s,onSave:l,onClose:r}){let[n,o]=(0,i.useState)(""),[c,p]=(0,i.useState)(null),[m,x]=(0,i.useState)(""),[u,h]=(0,i.useState)(!1);(0,i.useEffect)(()=>{e&&(o(""),p(null),x(""))},[e]);let f=e=>{let s=`${t}/`;return e.startsWith(s)?e.slice(s.length):e},g=async()=>{let e=f(n.trim());if(e){p("testing"),x("");try{let s=await fetch("/api/models/test",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({model:`${t}/${e}`})}),a=await s.json();p(a.ok?"ok":"error"),x(a.error||"")}catch(e){p("error"),x(e.message)}}},y=async()=>{let e=f(n.trim());if(e&&!u){h(!0);try{await l(e)}finally{h(!1)}}};return(0,a.jsx)(d.aF,{isOpen:e,onClose:r,title:"Add Custom Model",children:(0,a.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("label",{className:"text-sm font-medium mb-1.5 block",children:"Model ID"}),(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsx)("input",{type:"text",value:n,onChange:e=>{o(e.target.value),p(null),x("")},onKeyDown:e=>{"Enter"===e.key&&g()},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,a.jsx)(d.$n,{variant:"secondary",icon:"science",loading:"testing"===c,onClick:g,disabled:!n.trim()||"testing"===c,children:"testing"===c?"Testing...":"Test"})]}),(0,a.jsxs)("p",{className:"text-xs text-text-muted mt-1",children:["Sent to provider as: ",(0,a.jsx)("code",{className:"font-mono bg-sidebar px-1 rounded",children:f(n.trim())||"model-id"})]})]}),"ok"===c&&(0,a.jsxs)("div",{className:"flex items-center gap-2 text-sm text-green-600",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-base",children:"check_circle"}),"Model is reachable"]}),"error"===c&&(0,a.jsxs)("div",{className:"flex items-start gap-2 text-sm text-red-500",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-base shrink-0",children:"cancel"}),(0,a.jsx)("span",{children:m||"Model not reachable"})]}),(0,a.jsxs)("div",{className:"flex gap-2 pt-1",children:[(0,a.jsx)(d.$n,{onClick:r,variant:"ghost",fullWidth:!0,size:"sm",children:"Cancel"}),(0,a.jsx)(d.$n,{onClick:y,fullWidth:!0,size:"sm",disabled:!n.trim()||u,children:u?"Adding...":"Add Model"})]})]})})}function S({isOpen:e,provider:t,onClose:s,onDone:l}){let[r,n]=(0,i.useState)(""),[o,c]=(0,i.useState)(!1),[p,m]=(0,i.useState)(null),[x,u]=(0,i.useState)(""),h=r.split("\n").map(e=>e.trim()).filter(Boolean).filter(e=>{let t=e.indexOf("|");return(-1===t?e:e.slice(t+1).trim()).length>0}).length;async function f(){if(h){c(!0),u(""),m(null);try{let e=await fetch(`/api/providers/${t}/pool`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({lines:r})}),s=await e.json();if(!e.ok)throw Error(s.error||"Failed");m(s),l?.()}catch(e){u(e.message)}finally{c(!1)}}}function g(){n(""),m(null),u(""),s()}return(0,a.jsx)(d.aF,{isOpen:e,onClose:g,title:"Add Keys to Pool",children:(0,a.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,a.jsxs)("div",{children:[(0,a.jsxs)("p",{className:"text-sm text-text-muted mb-2",children:["Paste keys below — one per line. Format: ",(0,a.jsx)("code",{className:"text-xs bg-black/10 dark:bg-white/10 px-1 rounded",children:"name|key"})," or just ",(0,a.jsx)("code",{className:"text-xs bg-black/10 dark:bg-white/10 px-1 rounded",children:"key"}),"."]}),(0,a.jsx)("textarea",{className:"w-full rounded-md border border-border bg-background px-3 py-2 text-sm font-mono focus:outline-none focus:border-primary resize-none",rows:10,placeholder:"my-key-1|sk-ant-api03-...\nmy-key-2|sk-ant-api03-...\nsk-ant-api03-...",value:r,onChange:e=>{n(e.target.value),m(null)}}),(0,a.jsx)("p",{className:"text-xs text-text-muted mt-1",children:h>0?`${h} valid key${1!==h?"s":""} detected`:"Paste keys above"})]}),p&&(0,a.jsxs)("div",{className:"rounded-md border border-green-500/30 bg-green-500/10 px-3 py-2 text-sm text-green-600 dark:text-green-400",children:["Added ",p.added," key",1!==p.added?"s":""," to pool.",p.skipped>0&&` Skipped ${p.skipped} duplicate${1!==p.skipped?"s":""}.`]}),x&&(0,a.jsx)("p",{className:"text-sm text-red-500",children:x}),(0,a.jsxs)("div",{className:"flex justify-end gap-2",children:[(0,a.jsx)(d.$n,{variant:"ghost",onClick:g,children:"Close"}),(0,a.jsx)(d.$n,{onClick:f,disabled:!h||o,children:o?"Adding...":`Add ${h||""} Keys`})]})]})})}function $({provider:e,onPullDone:t}){let[s,l]=(0,i.useState)({keys:[],count:0,page:1,totalPages:1,poolSize:30,autoReplace:!0}),[r,n]=(0,i.useState)(!0),[o,c]=(0,i.useState)(""),[p,m]=(0,i.useState)(!1),[x,u]=(0,i.useState)(null),[h,f]=(0,i.useState)(!1),[g,y]=(0,i.useState)(null),[b,v]=(0,i.useState)(1),j=(0,i.useCallback)(async(t=b)=>{try{let s=await fetch(`/api/providers/${e}/pool?page=${t}&limit=50`,{cache:"no-store"});if(s.ok){let e=await s.json();l(e),o||c(String(e.poolSize))}}catch{}n(!1)},[e,b,o]);async function N(){m(!0),u(null);try{let a=parseInt(o,10)||s.poolSize,i=await fetch(`/api/providers/${e}/pool/pull`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({count:a})}),l=await i.json();if(!i.ok)throw Error(l.error||"Pull failed");u(l),v(1),await j(1),t?.()}catch(e){u({error:e.message})}finally{m(!1)}}async function k(t){y(t);try{await fetch(`/api/providers/${e}/pool?keyId=${t}`,{method:"DELETE"}),await j(b)}finally{y(null)}}async function w(t){l(e=>({...e,autoReplace:t})),await fetch(`/api/providers/${e}/pool`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({autoReplace:t})})}async function C(){let t=parseInt(o,10);!Number.isFinite(t)||t<1||t!==s.poolSize&&(l(e=>({...e,poolSize:t})),await fetch(`/api/providers/${e}/pool`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({poolSize:t})}))}return((0,i.useEffect)(()=>{j(b)},[e,b]),r)?(0,a.jsx)("div",{className:"py-8 text-center text-sm text-text-muted",children:"Loading pool..."}):(0,a.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,a.jsxs)("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[(0,a.jsxs)("div",{className:"flex items-center gap-4",children:[(0,a.jsxs)("span",{className:"font-medium",children:[s.count," key",1!==s.count?"s":""," in pool"]}),(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("span",{className:"text-xs text-text-muted",children:"Auto-replace"}),(0,a.jsx)(d.lM,{checked:s.autoReplace,onChange:w})]})]}),(0,a.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,a.jsx)("span",{className:"text-xs text-text-muted",children:"Pull"}),(0,a.jsx)("input",{type:"number",min:"1",className:"w-16 rounded-md border border-border bg-background px-2 py-1 text-sm text-center focus:outline-none focus:border-primary",value:o,onChange:e=>c(e.target.value),onBlur:C}),(0,a.jsx)("span",{className:"text-xs text-text-muted",children:"keys"}),(0,a.jsx)(d.$n,{size:"sm",icon:"download",onClick:N,disabled:p||0===s.count,children:p?"Pulling...":"Pull from pool"}),(0,a.jsx)(d.$n,{size:"sm",variant:"secondary",icon:"add",onClick:()=>f(!0),children:"Add to pool"})]})]}),x&&(0,a.jsx)("div",{className:`rounded-md border px-3 py-2 text-sm ${x.error?"border-red-500/30 bg-red-500/10 text-red-500":"border-green-500/30 bg-green-500/10 text-green-600 dark:text-green-400"}`,children:x.error?x.error:`Pulled ${x.pulled} key${1!==x.pulled?"s":""} to connections.${x.skipped?` Skipped ${x.skipped} duplicate${1!==x.skipped?"s":""}.`:""}${x.message?` ${x.message}`:""}`}),0===s.keys.length?(0,a.jsxs)("div",{className:"flex flex-col items-center gap-3 rounded-lg border border-border py-10 text-center",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-3xl text-text-muted",children:"key_off"}),(0,a.jsx)("p",{className:"text-sm text-text-muted",children:"No keys in pool"}),(0,a.jsx)(d.$n,{size:"sm",icon:"add",onClick:()=>f(!0),children:"Add Keys to Pool"})]}):(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("div",{className:"overflow-x-auto rounded-lg border border-border",children:(0,a.jsxs)("table",{className:"w-full text-sm",children:[(0,a.jsx)("thead",{children:(0,a.jsxs)("tr",{className:"border-b border-border bg-black/[0.02] dark:bg-white/[0.02] text-xs text-text-muted",children:[(0,a.jsx)("th",{className:"px-4 py-2 text-left font-medium uppercase tracking-wide",children:"Name"}),(0,a.jsx)("th",{className:"px-4 py-2 text-left font-medium uppercase tracking-wide",children:"Key"}),(0,a.jsx)("th",{className:"px-4 py-2 text-right font-medium uppercase tracking-wide",children:"Action"})]})}),(0,a.jsx)("tbody",{children:s.keys.map((e,t)=>(0,a.jsxs)("tr",{className:`border-b border-border last:border-0 ${t%2==0?"":"bg-black/[0.01] dark:bg-white/[0.01]"}`,children:[(0,a.jsx)("td",{className:"px-4 py-2 text-text-muted",children:e.name||(0,a.jsx)("span",{className:"text-text-muted/50 italic",children:"—"})}),(0,a.jsx)("td",{className:"px-4 py-2 font-mono text-xs text-text-muted",children:e.key}),(0,a.jsx)("td",{className:"px-4 py-2 text-right",children:(0,a.jsx)("button",{className:"text-red-500 hover:text-red-400 transition-colors disabled:opacity-40",onClick:()=>k(e.id),disabled:g===e.id,title:"Remove from pool",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-base",children:"close"})})})]},e.id))})]})}),s.totalPages>1&&(0,a.jsxs)("div",{className:"flex items-center justify-between text-sm",children:[(0,a.jsxs)("span",{className:"text-text-muted text-xs",children:["Page ",s.page," of ",s.totalPages," (",s.count," total)"]}),(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsx)(d.$n,{size:"sm",variant:"ghost",icon:"chevron_left",disabled:b<=1,onClick:()=>v(e=>e-1),children:"Prev"}),(0,a.jsx)(d.$n,{size:"sm",variant:"ghost",icon:"chevron_right",disabled:b>=s.totalPages,onClick:()=>v(e=>e+1),children:"Next"})]})]})]}),(0,a.jsx)(S,{isOpen:h,provider:e,onClose:()=>f(!1),onDone:()=>{v(1),j(1)}})]})}function A(){let e,t=(0,l.useParams)(),s=(0,l.useRouter)(),r=t.id,[x,h]=(0,i.useState)([]),[f,y]=(0,i.useState)(!0),[v,N]=(0,i.useState)(null),[S,A]=(0,i.useState)([]),[P,T]=(0,i.useState)(!1),[O,E]=(0,i.useState)(!1),[I,D]=(0,i.useState)(!1),[R,U]=(0,i.useState)(""),[_,z]=(0,i.useState)(!1),[q,M]=(0,i.useState)(!1),[K,F]=(0,i.useState)(!1),[L,J]=(0,i.useState)(null),[W,B]=(0,i.useState)({}),[H,V]=(0,i.useState)(!1),[G,Q]=(0,i.useState)({}),[Z,X]=(0,i.useState)(""),[Y,ee]=(0,i.useState)(null),[et,es]=(0,i.useState)(!1),[ea,ei]=(0,i.useState)([]),[el,er]=(0,i.useState)("__none__"),[en,eo]=(0,i.useState)(!1),[ed,ec]=(0,i.useState)(null),[ep,em]=(0,i.useState)(""),[ex,eu]=(0,i.useState)("auto"),[eh,ef]=(0,i.useState)([]),[eg,ey]=(0,i.useState)([]),[eb,ev]=(0,i.useState)([]),[ej,eN]=(0,i.useState)(null),[ek,ew]=(0,i.useState)(null),[eC,eS]=(0,i.useState)(!1),[e$,eA]=(0,i.useState)("connections"),[eP,eT]=(0,i.useState)(!1),[eO,eE]=(0,i.useState)(!1),[eI,eD]=(0,i.useState)(!1),[eR,eU]=(0,i.useState)(null),[e_,ez]=(0,i.useState)({}),[eq,eM]=(0,i.useState)(null),eK=(0,i.useRef)(!1),{copied:eF,copy:eL}=(0,m.C)(),eJ="ag_risk_confirmed",eW=()=>{T(!0)},eB=()=>{"antigravity"===r&&"true"!==window.localStorage.getItem(eJ)?eS(!0):eZ?eW():(U(""),D(!0))},eH=()=>{U(""),D(!0)},eV=()=>{eZ?eB():eH()},eG=v?{id:v.id,name:v.name||("anthropic-compatible"===v.type?"Anthropic Compatible":"OpenAI Compatible"),color:"anthropic-compatible"===v.type?"#D97757":"#10A37F",textIcon:"anthropic-compatible"===v.type?"AC":"OC",apiType:v.apiType,baseUrl:v.baseUrl,type:v.type}:c.zN[r]||c.fg[r]||c.IS[r]||c.nJ[r]||c.br[r],eQ=eG?.authModes||[],eZ=!!c.zN[r]||!!c.IS[r]||eQ.includes("oauth"),eX=!!c.fg[r]||eQ.includes("apikey"),eY=!!c.IS[r]?.noAuth,e0=(0,p.KC)(r),e1=(0,c.wG)(r),e2=(0,c.mq)(r),e5=(0,c.gb)(r),e3=e2||e5,e4=!e3&&eZ&&eX,e6="xai"===r?"Grok Build OAuth":"OAuth",e7="xai"===r?"xAI API Key":"API Key";c.Q2[r]?.thinkingConfig||c.s9.extended;let e8=e3?r:e1,e9=e3?v?.prefix||r:e1,te=(0,i.useCallback)(async()=>{try{let e=await fetch(`/api/models/disabled?providerAlias=${encodeURIComponent(e8)}`,{cache:"no-store"}),t=await e.json();e.ok&&ev(t.ids||[])}catch(e){console.log("Error fetching disabled models:",e)}},[e8]),tt=(0,i.useCallback)(async()=>{try{let e=await fetch(`/api/models/order?providerAlias=${encodeURIComponent(e8)}`,{cache:"no-store"}),t=await e.json();e.ok&&eN(t.order||null)}catch(e){console.log("Error fetching model order:",e)}},[e8]),ts=async e=>{try{(await fetch("/api/models/disabled",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({providerAlias:e8,ids:[e]})})).ok&&await te()}catch(e){console.log("Error disabling model:",e)}},ta=async e=>{try{(await fetch(`/api/models/disabled?providerAlias=${encodeURIComponent(e8)}&id=${encodeURIComponent(e)}`,{method:"DELETE"})).ok&&await te()}catch(e){console.log("Error enabling model:",e)}},ti=async e=>{e.length&&ew({title:"Disable All Models",message:`Disable all ${e.length} model(s)?`,onConfirm:async()=>{ew(null);try{(await fetch("/api/models/disabled",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({providerAlias:e8,ids:e})})).ok&&await te()}catch(e){console.log("Error disabling all models:",e)}}})},tl=async()=>{try{(await fetch(`/api/models/disabled?providerAlias=${encodeURIComponent(e8)}`,{method:"DELETE"})).ok&&await te()}catch(e){console.log("Error enabling all models:",e)}},tr=async(e,t)=>{let s=[...e0,...eg.filter(e=>!e0.some(t=>t.id===e.id))].filter(e=>!e.type||"llm"===e.type),a=new Set(eb),i=s.filter(e=>!a.has(e.id)).map(e=>e.id),l=ej?[...ej.filter(e=>i.includes(e)),...i.filter(e=>!ej.includes(e))]:i,r=l.indexOf(e);if(-1===r)return;let n="up"===t?r-1:r+1;if(n<0||n>=l.length)return;let o=[...l];[o[r],o[n]]=[o[n],o[r]],eN(o);try{await fetch("/api/models/order",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({providerAlias:e8,order:o})})}catch(e){console.log("Error saving model order:",e),await tt()}},tn=(0,i.useCallback)(async()=>{try{let e=await fetch("/api/models/alias",{cache:"no-store"}),t=await e.json();e.ok&&B(t.aliases||{})}catch(e){console.log("Error fetching aliases:",e)}},[]);(0,i.useEffect)(()=>{"kilocode"===r&&fetch("/api/providers/kilo/free-models").then(e=>e.json()).then(e=>{e.models?.length&&ey(e.models)}).catch(()=>{})},[r]);let to=(0,i.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"})]),i=await e.json(),l=await t.json(),n=await s.json(),o=a.ok?await a.json():{};if(e.ok){let e=(i.connections||[]).filter(e=>e.provider===r);h(e)}s.ok&&A(n.proxyPools||[]);let d=(o.providerStrategies||{})[r]||{};ec(d.fallbackStrategy||null),em(null!=d.stickyRoundRobinLimit?String(d.stickyRoundRobinLimit):"1");let c=(o.providerThinking||{})[r]||{};if(eu(c.mode||"auto"),t.ok){let e=(l.nodes||[]).find(e=>e.id===r)||null;if(!e&&e3)for(let t=0;t<3;t+=1){await new Promise(e=>setTimeout(e,150));let t=await fetch("/api/provider-nodes",{cache:"no-store"});if(t.ok&&(e=((await t.json()).nodes||[]).find(e=>e.id===r)||null))break}N(e)}}catch(e){console.log("Error fetching connections:",e)}finally{y(!1)}},[r,e3]),td=async e=>{try{let t=await fetch(`/api/provider-nodes/${r}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}),s=await t.json();t.ok&&(N(s.node),await to(),M(!1))}catch(e){console.log("Error updating provider node:",e)}},tc=async(e,t)=>{try{let s=await fetch("/api/settings",{cache:"no-store"}),a=(s.ok?await s.json():{}).providerStrategies||{},i={};e&&(i.fallbackStrategy=e),"round-robin"===e&&""!==t&&(i.stickyRoundRobinLimit=Number(t)||3);let l={...a};0===Object.keys(i).length?delete l[r]:l[r]=i,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,i.useEffect)(()=>{to(),tn(),te(),tt()},[to,tn,te,tt]),(0,i.useEffect)(()=>{let e=(c.zN[r]||c.fg[r]||c.IS[r]||c.nJ[r])?.modelsFetcher;e&&u(e).then(ef)},[r]);let tp=async(e,t,s=e1)=>{let a=`${s}/${e}`;try{let e=await fetch("/api/models/alias",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({model:a,alias:t})});if(e.ok)await tn();else{let t=await e.json();alert(t.error||"Failed to set alias")}}catch(e){console.log("Error setting alias:",e)}},tm=async e=>{try{(await fetch(`/api/models/alias?alias=${encodeURIComponent(e)}`,{method:"DELETE"})).ok&&await tn()}catch(e){console.log("Error deleting alias:",e)}},tx=async()=>{if(eO||0===x.length)return;let e=Object.fromEntries(x.map(e=>[e.id,{state:"queued",error:null}]));eK.current=!1,eE(!0),eD(!1),eU(null),ez(e),eM({total:x.length,completed:0,passed:0,failed:0,stopped:!1});let t=0,s=0;try{for(let e=0;e<x.length;e+=1){if(eK.current){eM({total:x.length,completed:e,passed:t,failed:s,stopped:!0});break}let a=x[e];eU(a.id),ez(e=>({...e,[a.id]:{state:"testing",error:null}}));try{let e=await fetch(`/api/providers/${a.id}/test`,{method:"POST"}),i=await e.json(),l=!!i.valid;l?t+=1:s+=1,ez(e=>({...e,[a.id]:{state:l?"success":"failed",error:l?null:i.error||null}}))}catch(e){s+=1,ez(t=>({...t,[a.id]:{state:"failed",error:e.message||"Test failed"}}))}eM({total:x.length,completed:e+1,passed:t,failed:s,stopped:!1}),e<x.length-1&&await new Promise(e=>setTimeout(e,1e3))}}finally{eU(null),eE(!1),eD(!1),eK.current=!1}},tu=async e=>{ew({title:"Delete Connection",message:"Delete this connection?",onConfirm:async()=>{ew(null);try{(await fetch(`/api/providers/${e}`,{method:"DELETE"})).ok&&h(x.filter(t=>t.id!==e))}catch(e){console.log("Error deleting connection:",e)}}})},th=()=>{to(),T(!1)},tf=async e=>{U("");try{let t=await fetch("/api/providers",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:r,...e})}),s=null;try{s=await t.json()}catch{s=null}if(t.ok){await to(),D(!1);return}U(s?.error||"Failed to save connection")}catch(e){console.log("Error saving connection:",e),U("Failed to save connection")}},tg=async e=>{try{(await fetch(`/api/providers/${L.id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})).ok&&(await to(),z(!1))}catch(e){console.log("Error updating connection:",e)}},ty=async(e,t)=>{try{(await fetch(`/api/providers/${e}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({isActive:t})})).ok&&h(s=>s.map(s=>s.id===e?{...s,isActive:t}:s))}catch(e){console.log("Error updating connection status:",e)}},tb=async e=>{h(t=>t.map(t=>({...t,isActive:e})));try{await Promise.all(x.map(t=>fetch(`/api/providers/${t.id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({isActive:e})})))}catch(e){console.log("Error toggling all connections:",e),await to()}},tv=async(e,t)=>{let s=[...x];[s[e],s[t]]=[s[t],s[e]],h(s);try{await Promise.all([fetch(`/api/providers/${s[e].id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({priority:e})}),fetch(`/api/providers/${s[t].id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({priority:t})})])}catch(e){console.log("Error swapping priority:",e),await to()}},tj=x.filter(e=>ea.includes(e.id));x.length>0&&(ea.length,x.length);let tN=x.some(e=>!1!==e.isActive);(0,i.useEffect)(()=>{ei(e=>e.filter(e=>x.some(t=>t.id===e)))},[x]),(()=>{if(0===tj.length)return;let e=new Set(tj.map(e=>e.providerSpecificData?.proxyPoolId||"__none__"));if(1===e.size){let t=[...e][0];if("__none__"===t)return;let s=S.find(e=>e.id===t);return s?.name}})();let tk=()=>{en||F(!1)},tw=async e=>{eo(!0);try{let t=0;for(let{connectionId:s,proxyPoolId:a}of e)try{(await fetch(`/api/providers/${s}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({proxyPoolId:a})})).ok||(t+=1)}catch(e){console.log("Error applying proxy for",s,e),t+=1}t>0&&alert(`Updated with ${t} failed request(s).`),await to(),F(!1)}finally{eo(!1)}},tC=e=>tw(x.map(t=>({connectionId:t.id,proxyPoolId:e}))),tS=(0,a.jsx)("div",{className:"flex min-w-0 flex-col divide-y divide-black/[0.03] dark:divide-white/[0.03]",children:x.map((e,t)=>(0,a.jsx)("div",{className:"flex min-w-0 items-stretch",children:(0,a.jsx)("div",{className:"flex-1 min-w-0",children:(0,a.jsx)(j,{connection:e,proxyPools:S,isOAuth:eZ,isFirst:0===t,isLast:t===x.length-1,onMoveUp:()=>tv(t,t-1),onMoveDown:()=>tv(t,t+1),onToggleActive:t=>ty(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&&h(s=>s.map(s=>s.id===e.id?{...s,providerSpecificData:{...s.providerSpecificData,proxyPoolId:t||null}}:s))}catch(e){console.log("Error updating proxy:",e)}},onEdit:()=>{J(e),z(!0)},onDelete:()=>tu(e.id),oneByOneStatus:e_[e.id]||null})})},e.id))}),t$=S.filter(e=>!0===e.isActive),tA=(0,a.jsx)(d.aF,{isOpen:K,onClose:tk,title:`Apply Proxy (${x.length} connections)`,children:(0,a.jsxs)("div",{className:"flex flex-col gap-3",children:[(0,a.jsxs)("div",{className:"flex flex-col",children:[(0,a.jsxs)("button",{onClick:()=>{let e=S.filter(e=>!0===e.isActive);return 0===e.length?void alert("No active proxy pools available."):tw(x.map((t,s)=>({connectionId:t.id,proxyPoolId:e[s%e.length].id})))},disabled:en||0===t$.length,className:"flex items-center gap-2 rounded-lg px-3 py-2 text-left transition-colors hover:bg-black/[0.04] dark:hover:bg-white/[0.04] disabled:cursor-not-allowed disabled:opacity-50",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-text-muted text-[18px]",children:"sync_alt"}),(0,a.jsx)("span",{className:"text-sm text-text-main",children:"One-to-one (rotate)"})]}),(0,a.jsxs)("button",{onClick:()=>tC(null),disabled:en,className:"flex items-center gap-2 rounded-lg px-3 py-2 text-left transition-colors hover:bg-black/[0.04] dark:hover:bg-white/[0.04] disabled:cursor-not-allowed disabled:opacity-50",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-text-muted text-[18px]",children:"link_off"}),(0,a.jsx)("span",{className:"text-sm text-text-main",children:"None (unbind all)"})]}),S.map(e=>(0,a.jsxs)("button",{onClick:()=>tC(e.id),disabled:en||!0!==e.isActive,className:"flex items-center gap-2 rounded-lg px-3 py-2 text-left transition-colors hover:bg-black/[0.04] dark:hover:bg-white/[0.04] disabled:cursor-not-allowed disabled:opacity-50",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-text-muted text-[18px]",children:"lan"}),(0,a.jsx)("span",{className:"truncate text-sm text-text-main",children:e.name}),!0!==e.isActive&&(0,a.jsx)("span",{className:"text-[10px] text-text-muted",children:"(inactive)"})]},e.id))]}),en&&(0,a.jsx)("p",{className:"text-xs text-text-muted",children:"Applying..."}),(0,a.jsx)(d.$n,{onClick:tk,variant:"ghost",fullWidth:!0,disabled:en,children:"Cancel"})]})}),tP=async e=>{if(!Y){ee(e);try{let t=await fetch("/api/models/test",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({model:`${e8}/${e}`})}),s=await t.json();Q(t=>({...t,[e]:s.ok?"ok":"error"})),X(s.ok?"":s.error||"Model not reachable")}catch{Q(t=>({...t,[e]:"error"})),X("Network error")}finally{ee(null)}}};return f?(0,a.jsxs)("div",{className:"flex flex-col gap-8",children:[(0,a.jsx)(d.Qv,{}),(0,a.jsx)(d.Qv,{})]}):eG?(0,a.jsxs)("div",{className:"flex min-w-0 flex-col gap-6 px-1 sm:gap-8 sm:px-0",children:[(0,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsxs)(n(),{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.jsxs)("div",{className:"flex min-w-0 items-center gap-3 sm:gap-4",children:[(0,a.jsx)("div",{className:"flex size-12 shrink-0 items-center justify-center rounded-lg",style:{backgroundColor:`${eG.color}15`},children:H?(0,a.jsx)("span",{className:"text-sm font-bold",style:{color:eG.color},children:eG.textIcon||eG.id.slice(0,2).toUpperCase()}):(0,a.jsx)(o.default,{src:e2&&eG.apiType?"responses"===eG.apiType?"/providers/oai-r.png":"/providers/oai-cc.png":e5?"/providers/anthropic-m.png":`/providers/${eG.id}.png`,alt:eG.name,width:48,height:48,className:"max-h-12 max-w-12 rounded-lg object-contain",sizes:"48px",onError:()=>V(!0)})}),(0,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsxs)("div",{className:"flex items-center gap-3 flex-wrap",children:[(0,a.jsx)("h1",{className:"truncate text-2xl font-semibold tracking-tight sm:text-3xl",children:eG.name}),(eG.notice?.apiKeyUrl||eG.notice?.signupUrl||eG.website)&&(0,a.jsxs)("a",{href:eG.notice?.apiKeyUrl||eG.notice?.signupUrl||eG.website,target:"_blank",rel:"noopener noreferrer",className:"text-xs text-primary hover:underline inline-flex items-center gap-1",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-sm",children:"open_in_new"}),eG.notice?.apiKeyUrl?"Get API Key":"Sign up / Learn more"]})]}),(0,a.jsxs)("p",{className:"text-text-muted",children:[x.length," connection",1===x.length?"":"s"]})]})]})]}),eG.deprecated&&(0,a.jsxs)("div",{className:"flex items-center gap-2 px-3 py-2 rounded-lg bg-yellow-500/10 border border-yellow-500/30",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[16px] text-yellow-500 mt-0.5 shrink-0",children:"warning"}),(0,a.jsx)("p",{className:"text-xs text-red-600 dark:text-yellow-400 leading-relaxed",children:eG.deprecationNotice})]}),eG.notice?.text&&!eG.deprecated&&(0,a.jsxs)("div",{className:"flex flex-col gap-2 rounded-lg border border-blue-500/30 bg-blue-500/10 px-3 py-2 sm:flex-row sm:items-center",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[16px] text-blue-500 shrink-0",children:"info"}),(0,a.jsx)("p",{className:"min-w-0 flex-1 text-xs leading-relaxed text-blue-600 dark:text-blue-400",children:eG.notice.text}),eG.notice.apiKeyUrl&&(0,a.jsx)("a",{href:eG.notice.apiKeyUrl,target:"_blank",rel:"noopener noreferrer",className:"inline-flex justify-center rounded bg-blue-500 px-2 py-1 text-xs font-medium text-white transition-colors hover:bg-blue-600 sm:py-0.5",children:"Get API Key →"})]}),e3&&v&&(0,a.jsx)(d.Zp,{children:(0,a.jsxs)("div",{className:"mb-4 flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between",children:[(0,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsx)("h2",{className:"text-lg font-semibold",children:e5?"Anthropic Compatible Details":"OpenAI Compatible Details"}),(0,a.jsxs)("p",{className:"break-all text-sm text-text-muted",children:[e5?"Messages API":"responses"===v.apiType?"Responses API":"Chat Completions"," \xb7 ",(v.baseUrl||"").replace(/\/$/,""),"/",e5?"messages":"responses"===v.apiType?"responses":"chat/completions"]})]}),(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-2 sm:flex sm:items-center",children:[(0,a.jsx)(d.$n,{size:"sm",icon:"add",onClick:()=>{U(""),D(!0)},className:"w-full sm:w-auto",children:"Add API Key"}),(0,a.jsx)(d.$n,{size:"sm",variant:"secondary",icon:"edit",onClick:()=>M(!0),className:"w-full sm:w-auto",children:"Edit"}),(0,a.jsx)(d.$n,{size:"sm",variant:"secondary",icon:"delete",onClick:async()=>{ew({title:"Delete Compatible Node",message:`Delete this ${e5?"Anthropic":"OpenAI"} Compatible node?`,onConfirm:async()=>{ew(null);try{(await fetch(`/api/provider-nodes/${r}`,{method:"DELETE"})).ok&&s.push("/dashboard/providers")}catch(e){console.log("Error deleting provider node:",e)}}})},className:"w-full sm:w-auto",children:"Delete"})]})]})}),eY?(0,a.jsx)(d.gw,{providerId:r}):(0,a.jsxs)(d.Zp,{children:[(0,a.jsxs)("div",{className:"mb-4 flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[(0,a.jsxs)("div",{className:"flex items-center gap-1",children:[(0,a.jsxs)("button",{className:`px-3 py-1.5 rounded-md text-sm font-medium transition-colors ${"connections"===e$?"bg-primary text-white":"text-text-muted hover:text-foreground"}`,onClick:()=>eA("connections"),children:["Connections (",x.length,")"]}),(0,a.jsx)("button",{className:`px-3 py-1.5 rounded-md text-sm font-medium transition-colors ${"pool"===e$?"bg-primary text-white":"text-text-muted hover:text-foreground"}`,onClick:()=>eA("pool"),children:"\uD83D\uDD11 Key Pool"})]}),"connections"===e$&&(0,a.jsxs)("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:gap-4",children:[x.some(e=>!e.isActive)&&(0,a.jsx)(d.$n,{size:"sm",variant:"ghost",icon:"delete_sweep",disabled:eP,onClick:async()=>{eT(!0);try{await fetch(`/api/providers/${r}/connections/disabled`,{method:"DELETE"}),await to()}finally{eT(!1)}},children:eP?"Deleting...":`Delete Disabled (${x.filter(e=>!e.isActive).length})`}),x.length>1&&(0,a.jsx)(d.$n,{size:"sm",variant:"secondary",icon:tN?"toggle_off":"toggle_on",onClick:()=>tb(!tN),children:tN?"Disable All":"Enable All"}),x.length>0&&S.length>0&&(0,a.jsx)(d.$n,{size:"sm",variant:"secondary",icon:"lan",onClick:()=>F(!0),children:"Apply Proxy"}),x.length>0&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(d.$n,{size:"sm",variant:"secondary",icon:"sync",onClick:tx,disabled:eO,children:eO?"Testing Connection One-by-One...":"Test Connection One-by-One"}),eO&&(0,a.jsx)(d.$n,{size:"sm",variant:"ghost",icon:"stop",onClick:()=>{eO&&(eK.current=!0,eD(!0))},disabled:eI,children:eI?"Stopping...":"Stop"})]}),(0,a.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,a.jsx)("span",{className:"text-xs text-text-muted font-medium",children:"Round Robin"}),(0,a.jsx)(d.lM,{checked:"round-robin"===ed,onChange:e=>{let t=e?"round-robin":null,s=e?ep||"1":ep;e&&!ep&&em("1"),ec(t),tc(t,s)}}),"round-robin"===ed&&(0,a.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,a.jsx)("span",{className:"text-xs text-text-muted",children:"Sticky:"}),(0,a.jsx)("input",{type:"number",min:1,value:ep,onChange:e=>{var t;em(t=e.target.value),tc("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"})]})]})]})]}),"pool"===e$?(0,a.jsx)($,{provider:r,onPullDone:to}):0===x.length?(0,a.jsxs)("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[(0,a.jsxs)("div",{className:"flex items-center gap-3",children:[(0,a.jsx)("div",{className:"inline-flex items-center justify-center w-9 h-9 rounded-full bg-primary/10 text-primary shrink-0",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:eZ?"lock":"key"})}),(0,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsx)("p",{className:"text-sm text-text-muted",children:"No connections yet"}),e4&&(0,a.jsxs)("p",{className:"text-xs text-text-muted",children:["Choose ",e6," or ",e7,"."]})]})]}),(0,a.jsx)("div",{className:"flex gap-2",children:e4?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(d.$n,{size:"sm",icon:"lock",variant:"secondary",onClick:eB,children:e6}),(0,a.jsx)(d.$n,{size:"sm",icon:"key",onClick:eH,children:e7})]}):(0,a.jsxs)(a.Fragment,{children:[!e3&&"iflow"===r&&(0,a.jsx)(d.$n,{size:"sm",icon:"cookie",variant:"secondary",onClick:()=>E(!0),children:"Cookie"}),(0,a.jsx)(d.$n,{size:"sm",icon:"add",onClick:eV,children:e3?"Add API Key":"iflow"===r?"OAuth":"Add Connection"})]})})]}):(0,a.jsxs)(a.Fragment,{children:[eq&&(0,a.jsx)("div",{className:"mb-4 rounded-lg border border-black/10 bg-black/[0.02] px-3 py-2 text-xs text-text-muted dark:border-white/10 dark:bg-white/[0.03]",children:(0,a.jsxs)("div",{className:"flex flex-wrap items-center gap-3",children:[(0,a.jsxs)("span",{children:["Total: ",eq.total]}),(0,a.jsxs)("span",{children:["Completed: ",eq.completed]}),(0,a.jsxs)("span",{children:["Passed: ",eq.passed]}),(0,a.jsxs)("span",{children:["Failed: ",eq.failed]}),eq.stopped&&(0,a.jsx)("span",{className:"text-amber-600 dark:text-amber-400",children:"Stopped"}),eO&&eR&&(0,a.jsxs)("span",{children:["Running: ",x.find(e=>e.id===eR)?.name||eR]})]})}),tS,!e3&&(0,a.jsxs)("div",{className:"mt-4 grid grid-cols-1 gap-2 sm:flex",children:["iflow"===r&&(0,a.jsx)(d.$n,{size:"sm",icon:"cookie",variant:"secondary",onClick:()=>E(!0),title:"Add connection using browser cookie",className:"w-full sm:w-auto",children:"Cookie"}),e4?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(d.$n,{size:"sm",icon:"lock",variant:"secondary",onClick:eB,className:"w-full sm:w-auto",children:e6}),(0,a.jsx)(d.$n,{size:"sm",icon:"key",onClick:eH,className:"w-full sm:w-auto",children:e7})]}):(0,a.jsx)(d.$n,{size:"sm",icon:"add",onClick:eV,className:"w-full sm:w-auto",children:"Add"})]})]})]}),(0,a.jsxs)(d.Zp,{children:[(0,a.jsxs)("div",{className:"mb-4 flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between",children:[(0,a.jsx)("h2",{className:"text-lg font-semibold",children:"Available Models"}),!e3&&(e=[...e0,...eg.filter(e=>!e0.some(t=>t.id===e.id))].filter(e=>!e.type||"llm"===e.type).map(e=>e.id).filter(e=>!eb.includes(e)),(0,a.jsxs)("div",{className:"flex gap-2",children:[eb.length>0&&(0,a.jsx)(d.$n,{size:"sm",variant:"secondary",icon:"restart_alt",onClick:tl,children:"Active All"}),e.length>0&&(0,a.jsx)(d.$n,{size:"sm",variant:"secondary",icon:"block",onClick:()=>ti(e),children:"Disable All"})]}))]}),!!Z&&(0,a.jsx)("p",{className:"text-xs text-red-500 mb-3 break-words",children:Z}),(()=>{let e,t,s;if(e3)return(0,a.jsx)(b,{providerStorageAlias:e8,providerDisplayAlias:e9,modelAliases:W,copied:eF,onCopy:eL,onSetAlias:tp,onDeleteAlias:tm,connections:x,isAnthropic:e5});let i=[...e0,...eg.filter(e=>!e0.some(t=>t.id===e.id))].filter(e=>!e.type||"llm"===e.type),l=new Set(eb),n=i.filter(e=>!l.has(e.id)),o=i.filter(e=>l.has(e.id)),d=n.map(e=>e.id),c=ej?[...ej.filter(e=>d.includes(e)).map(e=>n.find(t=>t.id===e)),...n.filter(e=>!ej.includes(e.id))]:n,p=Object.entries(W).filter(([e,t])=>{let s=`${e8}/`;if(!t.startsWith(s))return!1;let a=t.slice(s.length);return eG.passthroughModels?!e0.some(e=>e.id===a):!e0.some(e=>e.id===a)&&e===a}).map(([e,t])=>({id:t.slice(`${e8}/`.length),alias:e,fullModel:t}));return(0,a.jsxs)("div",{className:"flex flex-wrap gap-3",children:[p.map(e=>(0,a.jsx)(g,{model:{id:e.id},fullModel:`${e9}/${e.id}`,alias:e.alias,copied:eF,onCopy:eL,onSetAlias:()=>{},onDeleteAlias:()=>tm(e.alias),testStatus:G[e.id],onTest:x.length>0||eY?()=>tP(e.id):void 0,isTesting:Y===e.id,isCustom:!0,isFree:!1},e.id)),c.map((e,t)=>{let s=`${e8}/${e.id}`,i=`${r}/${e.id}`,l=Object.entries(W).find(([,e])=>e===s||e===i)?.[0];return(0,a.jsx)(g,{model:e,fullModel:`${e9}/${e.id}`,alias:l,copied:eF,onCopy:eL,onSetAlias:t=>tp(e.id,t,e8),onDeleteAlias:()=>tm(l),testStatus:G[e.id],onTest:x.length>0||eY?()=>tP(e.id):void 0,isTesting:Y===e.id,isFree:e.isFree,onDisable:()=>ts(e.id),isFirst:0===t,isLast:t===c.length-1,onMoveUp:()=>tr(e.id,"up"),onMoveDown:()=>tr(e.id,"down")},e.id)}),(0,a.jsxs)("button",{onClick:()=>es(!0),className:"flex w-full items-center justify-center gap-1.5 rounded-lg border border-dashed border-primary/40 px-3 py-2 text-xs text-primary transition-colors hover:border-primary hover:bg-primary/5 sm:w-auto",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-sm",children:"add"}),"Add Model"]}),eh.length>0&&(e=new Set(Object.values(W)),t=new Set(e0.map(e=>e.id)),0===(s=eh.filter(s=>!e.has(`${e8}/${s.id}`)&&!t.has(s.id))).length?null:(0,a.jsxs)("div",{className:"w-full mt-2",children:[(0,a.jsx)("p",{className:"text-xs text-text-muted mb-2",children:"Suggested free models (≥200k context):"}),(0,a.jsx)("div",{className:"flex flex-wrap gap-2",children:s.map(e=>(0,a.jsxs)("button",{onClick:async()=>{let t=e.id.split("/").pop();await tp(e.id,t,e8)},className:"flex items-center gap-1 px-2.5 py-1.5 rounded-lg border border-black/10 dark:border-white/10 text-xs text-text-muted hover:text-primary hover:border-primary/40 hover:bg-primary/5 transition-colors",title:`${e.name} \xb7 ${(e.contextLength/1e3).toFixed(0)}k ctx`,children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[13px]",children:"add"}),e.id.split("/").pop()]},e.id))})]})),o.length>0&&(0,a.jsxs)("div",{className:"w-full mt-2",children:[(0,a.jsxs)("p",{className:"text-xs text-text-muted mb-2",children:["Disabled models (",o.length,"):"]}),(0,a.jsx)("div",{className:"flex flex-wrap gap-2",children:o.map(e=>(0,a.jsxs)("button",{onClick:()=>ta(e.id),className:"flex items-center gap-1 px-2.5 py-1.5 rounded-lg border border-dashed border-black/10 dark:border-white/10 text-xs text-text-muted hover:text-primary hover:border-primary/40 hover:bg-primary/5 transition-colors",title:"Restore model",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[13px]",children:"add"}),e.id]},e.id))})]})]})})()]}),tA,"kiro"===r?(0,a.jsx)(d.Mh,{isOpen:P,providerInfo:eG,onSuccess:th,onClose:()=>T(!1)}):"cursor"===r?(0,a.jsx)(d.G9,{isOpen:P,onSuccess:th,onClose:()=>T(!1)}):"gitlab"===r?(0,a.jsx)(d.vj,{isOpen:P,providerInfo:eG,onSuccess:th,onClose:()=>T(!1)}):(0,a.jsx)(d.LF,{isOpen:P,provider:r,providerInfo:eG,onSuccess:th,onClose:()=>T(!1)}),"iflow"===r&&(0,a.jsx)(d.vE,{isOpen:O,onSuccess:()=>{to(),E(!1)},onClose:()=>E(!1)}),(0,a.jsx)(k,{isOpen:I,provider:r,providerName:eG.name,isCompatible:e3,isAnthropic:e5,authType:eG?.authType,authHint:eG?.authHint,website:eG?.website,proxyPools:S,error:R,onSave:tf,onBulkDone:to,onClose:()=>{U(""),D(!1)}}),(0,a.jsx)(d.wI,{isOpen:_,connection:L,proxyPools:S,onSave:tg,onClose:()=>z(!1)}),e3&&(0,a.jsx)(w,{isOpen:q,node:v,onSave:td,onClose:()=>M(!1),isAnthropic:e5}),!e3&&(0,a.jsx)(C,{isOpen:et,providerAlias:e8,providerDisplayAlias:e9,onSave:async e=>{let t=eG?.passthroughModels?e.split("/").pop():e;await tp(e,t,e8),es(!1)},onClose:()=>es(!1)}),(0,a.jsx)(d.uo,{isOpen:eC,onClose:()=>eS(!1),onConfirm:()=>{(window.localStorage.setItem(eJ,"true"),eS(!1),eZ)?eW():eH()},title:"Risk Notice",message:eG?.deprecationNotice,confirmText:"I Understand, Continue",cancelText:"Cancel",variant:"danger"}),(0,a.jsx)(d.uo,{isOpen:!!ek,onClose:()=>ew(null),onConfirm:ek?.onConfirm,title:ek?.title||"Confirm",message:ek?.message,variant:"danger"})]}):(0,a.jsxs)("div",{className:"text-center py-20",children:[(0,a.jsx)("p",{className:"text-text-muted",children:"Provider not found"}),(0,a.jsx)(n(),{href:"/dashboard/providers",className:"text-primary mt-4 inline-block",children:"Back to Providers"})]})}k.propTypes={isOpen:f().bool.isRequired,provider:f().string,providerName:f().string,isCompatible:f().bool,isAnthropic:f().bool,authType:f().string,authHint:f().string,website:f().string,proxyPools:f().arrayOf(f().shape({id:f().string,name:f().string})),error:f().string,onSave:f().func.isRequired,onBulkDone:f().func,onClose:f().func.isRequired},w.propTypes={isOpen:f().bool.isRequired,node:f().shape({id:f().string,name:f().string,prefix:f().string,apiType:f().string,baseUrl:f().string}),onSave:f().func.isRequired,onClose:f().func.isRequired,isAnthropic:f().bool},C.propTypes={isOpen:f().bool.isRequired,providerAlias:f().string.isRequired,providerDisplayAlias:f().string.isRequired,onSave:f().func.isRequired,onClose:f().func.isRequired}},67944:(e,t,s)=>{Promise.resolve().then(s.bind(s,52720))}},e=>{e.O(0,[2574,3862,1051,5772,1321,5497,8441,3794,7358],()=>e(e.s=67944)),_N_E=e.O()}]);