vansrouter 0.91.5 → 0.91.6

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 (330) hide show
  1. package/app/.next-cli-build/BUILD_ID +1 -1
  2. package/app/.next-cli-build/app-path-routes-manifest.json +14 -14
  3. package/app/.next-cli-build/build-manifest.json +2 -2
  4. package/app/.next-cli-build/prerender-manifest.json +3 -3
  5. package/app/.next-cli-build/server/app/(dashboard)/dashboard/basic-chat/page_client-reference-manifest.js +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_client-reference-manifest.js +1 -1
  8. package/app/.next-cli-build/server/app/(dashboard)/dashboard/combos/page_client-reference-manifest.js +1 -1
  9. package/app/.next-cli-build/server/app/(dashboard)/dashboard/console-log/page_client-reference-manifest.js +1 -1
  10. package/app/.next-cli-build/server/app/(dashboard)/dashboard/endpoint/page_client-reference-manifest.js +1 -1
  11. package/app/.next-cli-build/server/app/(dashboard)/dashboard/media-providers/[kind]/[id]/page.js +1 -1
  12. package/app/.next-cli-build/server/app/(dashboard)/dashboard/media-providers/[kind]/[id]/page_client-reference-manifest.js +1 -1
  13. package/app/.next-cli-build/server/app/(dashboard)/dashboard/media-providers/[kind]/page_client-reference-manifest.js +1 -1
  14. package/app/.next-cli-build/server/app/(dashboard)/dashboard/media-providers/combo/[id]/page_client-reference-manifest.js +1 -1
  15. package/app/.next-cli-build/server/app/(dashboard)/dashboard/media-providers/web/page_client-reference-manifest.js +1 -1
  16. package/app/.next-cli-build/server/app/(dashboard)/dashboard/mitm/page_client-reference-manifest.js +1 -1
  17. package/app/.next-cli-build/server/app/(dashboard)/dashboard/page_client-reference-manifest.js +1 -1
  18. package/app/.next-cli-build/server/app/(dashboard)/dashboard/profile/page_client-reference-manifest.js +1 -1
  19. package/app/.next-cli-build/server/app/(dashboard)/dashboard/providers/[id]/page.js +1 -1
  20. package/app/.next-cli-build/server/app/(dashboard)/dashboard/providers/[id]/page_client-reference-manifest.js +1 -1
  21. package/app/.next-cli-build/server/app/(dashboard)/dashboard/providers/new/page_client-reference-manifest.js +1 -1
  22. package/app/.next-cli-build/server/app/(dashboard)/dashboard/providers/page.js +2 -2
  23. package/app/.next-cli-build/server/app/(dashboard)/dashboard/providers/page_client-reference-manifest.js +1 -1
  24. package/app/.next-cli-build/server/app/(dashboard)/dashboard/proxy-fitness/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/pxpipe/page_client-reference-manifest.js +1 -1
  27. package/app/.next-cli-build/server/app/(dashboard)/dashboard/quota/page_client-reference-manifest.js +1 -1
  28. package/app/.next-cli-build/server/app/(dashboard)/dashboard/skills/page_client-reference-manifest.js +1 -1
  29. package/app/.next-cli-build/server/app/(dashboard)/dashboard/token-saver/page_client-reference-manifest.js +1 -1
  30. package/app/.next-cli-build/server/app/(dashboard)/dashboard/translator/page_client-reference-manifest.js +1 -1
  31. package/app/.next-cli-build/server/app/(dashboard)/dashboard/usage/page_client-reference-manifest.js +1 -1
  32. package/app/.next-cli-build/server/app/_global-error/page_client-reference-manifest.js +1 -1
  33. package/app/.next-cli-build/server/app/_global-error.html +1 -1
  34. package/app/.next-cli-build/server/app/_global-error.rsc +1 -1
  35. package/app/.next-cli-build/server/app/_global-error.segments/_full.segment.rsc +1 -1
  36. package/app/.next-cli-build/server/app/_global-error.segments/_global-error/__PAGE__.segment.rsc +1 -1
  37. package/app/.next-cli-build/server/app/_global-error.segments/_global-error.segment.rsc +1 -1
  38. package/app/.next-cli-build/server/app/_global-error.segments/_head.segment.rsc +1 -1
  39. package/app/.next-cli-build/server/app/_global-error.segments/_index.segment.rsc +1 -1
  40. package/app/.next-cli-build/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  41. package/app/.next-cli-build/server/app/_not-found/page_client-reference-manifest.js +1 -1
  42. package/app/.next-cli-build/server/app/_not-found.html +1 -1
  43. package/app/.next-cli-build/server/app/_not-found.rsc +3 -3
  44. package/app/.next-cli-build/server/app/_not-found.segments/_full.segment.rsc +3 -3
  45. package/app/.next-cli-build/server/app/_not-found.segments/_head.segment.rsc +1 -1
  46. package/app/.next-cli-build/server/app/_not-found.segments/_index.segment.rsc +3 -3
  47. package/app/.next-cli-build/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +1 -1
  48. package/app/.next-cli-build/server/app/_not-found.segments/_not-found.segment.rsc +1 -1
  49. package/app/.next-cli-build/server/app/_not-found.segments/_tree.segment.rsc +1 -1
  50. package/app/.next-cli-build/server/app/api/cli-tools/all-statuses/route.js +5 -5
  51. package/app/.next-cli-build/server/app/api/cli-tools/antigravity-mitm/alias/route.js +1 -1
  52. package/app/.next-cli-build/server/app/api/cli-tools/claude-settings/route.js +2 -2
  53. package/app/.next-cli-build/server/app/api/cli-tools/cline-settings/route.js +2 -2
  54. package/app/.next-cli-build/server/app/api/cli-tools/codex-settings/route.js +1 -1
  55. package/app/.next-cli-build/server/app/api/cli-tools/copilot-settings/route.js +2 -2
  56. package/app/.next-cli-build/server/app/api/cli-tools/cowork-mcp-registry/route.js +2 -2
  57. package/app/.next-cli-build/server/app/api/cli-tools/cowork-mcp-tools/route.js +2 -2
  58. package/app/.next-cli-build/server/app/api/cli-tools/cowork-settings/route.js +1 -1
  59. package/app/.next-cli-build/server/app/api/cli-tools/deepseek-tui-settings/route.js +1 -1
  60. package/app/.next-cli-build/server/app/api/cli-tools/devin-settings/route.js +2 -2
  61. package/app/.next-cli-build/server/app/api/cli-tools/droid-settings/route.js +2 -2
  62. package/app/.next-cli-build/server/app/api/cli-tools/grok-build-settings/route.js +1 -1
  63. package/app/.next-cli-build/server/app/api/cli-tools/hermes-settings/route.js +2 -2
  64. package/app/.next-cli-build/server/app/api/cli-tools/jcode-settings/route.js +2 -2
  65. package/app/.next-cli-build/server/app/api/cli-tools/kilo-settings/route.js +2 -2
  66. package/app/.next-cli-build/server/app/api/cli-tools/openclaw-settings/route.js +1 -1
  67. package/app/.next-cli-build/server/app/api/cli-tools/opencode-settings/route.js +2 -2
  68. package/app/.next-cli-build/server/app/api/oauth/codex/bulk-import/route.js +1 -1
  69. package/app/.next-cli-build/server/app/api/oauth/codex/import-token/route.js +1 -1
  70. package/app/.next-cli-build/server/app/api/oauth/cursor/import/route.js +1 -1
  71. package/app/.next-cli-build/server/app/api/oauth/kiro/api-key/route.js +1 -1
  72. package/app/.next-cli-build/server/app/api/oauth/kiro/import/route.js +1 -1
  73. package/app/.next-cli-build/server/app/api/oauth/kiro/import-cli-proxy/route.js +1 -1
  74. package/app/.next-cli-build/server/app/api/oauth/kiro/social-authorize/route.js +1 -1
  75. package/app/.next-cli-build/server/app/api/oauth/kiro/social-exchange/route.js +1 -1
  76. package/app/.next-cli-build/server/app/api/providers/[id]/models/route.js +1 -1
  77. package/app/.next-cli-build/server/app/api/providers/client/route.js +1 -1
  78. package/app/.next-cli-build/server/app/api/providers/route.js +1 -1
  79. package/app/.next-cli-build/server/app/api/tunnel/tailscale-install/route.js +2 -2
  80. package/app/.next-cli-build/server/app/api/version/route.js +1 -1
  81. package/app/.next-cli-build/server/app/callback/page_client-reference-manifest.js +1 -1
  82. package/app/.next-cli-build/server/app/callback.html +1 -1
  83. package/app/.next-cli-build/server/app/callback.rsc +3 -3
  84. package/app/.next-cli-build/server/app/callback.segments/_full.segment.rsc +3 -3
  85. package/app/.next-cli-build/server/app/callback.segments/_head.segment.rsc +1 -1
  86. package/app/.next-cli-build/server/app/callback.segments/_index.segment.rsc +3 -3
  87. package/app/.next-cli-build/server/app/callback.segments/_tree.segment.rsc +1 -1
  88. package/app/.next-cli-build/server/app/callback.segments/callback/__PAGE__.segment.rsc +1 -1
  89. package/app/.next-cli-build/server/app/callback.segments/callback.segment.rsc +1 -1
  90. package/app/.next-cli-build/server/app/dashboard/basic-chat.html +1 -1
  91. package/app/.next-cli-build/server/app/dashboard/basic-chat.rsc +5 -5
  92. package/app/.next-cli-build/server/app/dashboard/basic-chat.segments/!KGRhc2hib2FyZCk/dashboard/basic-chat/__PAGE__.segment.rsc +2 -2
  93. package/app/.next-cli-build/server/app/dashboard/basic-chat.segments/!KGRhc2hib2FyZCk/dashboard/basic-chat.segment.rsc +1 -1
  94. package/app/.next-cli-build/server/app/dashboard/basic-chat.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  95. package/app/.next-cli-build/server/app/dashboard/basic-chat.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  96. package/app/.next-cli-build/server/app/dashboard/basic-chat.segments/_full.segment.rsc +5 -5
  97. package/app/.next-cli-build/server/app/dashboard/basic-chat.segments/_head.segment.rsc +1 -1
  98. package/app/.next-cli-build/server/app/dashboard/basic-chat.segments/_index.segment.rsc +3 -3
  99. package/app/.next-cli-build/server/app/dashboard/basic-chat.segments/_tree.segment.rsc +1 -1
  100. package/app/.next-cli-build/server/app/dashboard/cli-tools.html +1 -1
  101. package/app/.next-cli-build/server/app/dashboard/cli-tools.rsc +5 -5
  102. package/app/.next-cli-build/server/app/dashboard/cli-tools.segments/!KGRhc2hib2FyZCk/dashboard/cli-tools/__PAGE__.segment.rsc +2 -2
  103. package/app/.next-cli-build/server/app/dashboard/cli-tools.segments/!KGRhc2hib2FyZCk/dashboard/cli-tools.segment.rsc +1 -1
  104. package/app/.next-cli-build/server/app/dashboard/cli-tools.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  105. package/app/.next-cli-build/server/app/dashboard/cli-tools.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  106. package/app/.next-cli-build/server/app/dashboard/cli-tools.segments/_full.segment.rsc +5 -5
  107. package/app/.next-cli-build/server/app/dashboard/cli-tools.segments/_head.segment.rsc +1 -1
  108. package/app/.next-cli-build/server/app/dashboard/cli-tools.segments/_index.segment.rsc +3 -3
  109. package/app/.next-cli-build/server/app/dashboard/cli-tools.segments/_tree.segment.rsc +1 -1
  110. package/app/.next-cli-build/server/app/dashboard/combos.html +1 -1
  111. package/app/.next-cli-build/server/app/dashboard/combos.rsc +5 -5
  112. package/app/.next-cli-build/server/app/dashboard/combos.segments/!KGRhc2hib2FyZCk/dashboard/combos/__PAGE__.segment.rsc +2 -2
  113. package/app/.next-cli-build/server/app/dashboard/combos.segments/!KGRhc2hib2FyZCk/dashboard/combos.segment.rsc +1 -1
  114. package/app/.next-cli-build/server/app/dashboard/combos.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  115. package/app/.next-cli-build/server/app/dashboard/combos.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  116. package/app/.next-cli-build/server/app/dashboard/combos.segments/_full.segment.rsc +5 -5
  117. package/app/.next-cli-build/server/app/dashboard/combos.segments/_head.segment.rsc +1 -1
  118. package/app/.next-cli-build/server/app/dashboard/combos.segments/_index.segment.rsc +3 -3
  119. package/app/.next-cli-build/server/app/dashboard/combos.segments/_tree.segment.rsc +1 -1
  120. package/app/.next-cli-build/server/app/dashboard/endpoint.html +1 -1
  121. package/app/.next-cli-build/server/app/dashboard/endpoint.rsc +5 -5
  122. package/app/.next-cli-build/server/app/dashboard/endpoint.segments/!KGRhc2hib2FyZCk/dashboard/endpoint/__PAGE__.segment.rsc +2 -2
  123. package/app/.next-cli-build/server/app/dashboard/endpoint.segments/!KGRhc2hib2FyZCk/dashboard/endpoint.segment.rsc +1 -1
  124. package/app/.next-cli-build/server/app/dashboard/endpoint.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  125. package/app/.next-cli-build/server/app/dashboard/endpoint.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  126. package/app/.next-cli-build/server/app/dashboard/endpoint.segments/_full.segment.rsc +5 -5
  127. package/app/.next-cli-build/server/app/dashboard/endpoint.segments/_head.segment.rsc +1 -1
  128. package/app/.next-cli-build/server/app/dashboard/endpoint.segments/_index.segment.rsc +3 -3
  129. package/app/.next-cli-build/server/app/dashboard/endpoint.segments/_tree.segment.rsc +1 -1
  130. package/app/.next-cli-build/server/app/dashboard/media-providers/web.html +1 -1
  131. package/app/.next-cli-build/server/app/dashboard/media-providers/web.rsc +5 -5
  132. package/app/.next-cli-build/server/app/dashboard/media-providers/web.segments/!KGRhc2hib2FyZCk/dashboard/media-providers/web/__PAGE__.segment.rsc +2 -2
  133. package/app/.next-cli-build/server/app/dashboard/media-providers/web.segments/!KGRhc2hib2FyZCk/dashboard/media-providers/web.segment.rsc +1 -1
  134. package/app/.next-cli-build/server/app/dashboard/media-providers/web.segments/!KGRhc2hib2FyZCk/dashboard/media-providers.segment.rsc +1 -1
  135. package/app/.next-cli-build/server/app/dashboard/media-providers/web.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  136. package/app/.next-cli-build/server/app/dashboard/media-providers/web.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  137. package/app/.next-cli-build/server/app/dashboard/media-providers/web.segments/_full.segment.rsc +5 -5
  138. package/app/.next-cli-build/server/app/dashboard/media-providers/web.segments/_head.segment.rsc +1 -1
  139. package/app/.next-cli-build/server/app/dashboard/media-providers/web.segments/_index.segment.rsc +3 -3
  140. package/app/.next-cli-build/server/app/dashboard/media-providers/web.segments/_tree.segment.rsc +1 -1
  141. package/app/.next-cli-build/server/app/dashboard/mitm.html +1 -1
  142. package/app/.next-cli-build/server/app/dashboard/mitm.rsc +5 -5
  143. package/app/.next-cli-build/server/app/dashboard/mitm.segments/!KGRhc2hib2FyZCk/dashboard/mitm/__PAGE__.segment.rsc +2 -2
  144. package/app/.next-cli-build/server/app/dashboard/mitm.segments/!KGRhc2hib2FyZCk/dashboard/mitm.segment.rsc +1 -1
  145. package/app/.next-cli-build/server/app/dashboard/mitm.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  146. package/app/.next-cli-build/server/app/dashboard/mitm.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  147. package/app/.next-cli-build/server/app/dashboard/mitm.segments/_full.segment.rsc +5 -5
  148. package/app/.next-cli-build/server/app/dashboard/mitm.segments/_head.segment.rsc +1 -1
  149. package/app/.next-cli-build/server/app/dashboard/mitm.segments/_index.segment.rsc +3 -3
  150. package/app/.next-cli-build/server/app/dashboard/mitm.segments/_tree.segment.rsc +1 -1
  151. package/app/.next-cli-build/server/app/dashboard/profile.html +1 -1
  152. package/app/.next-cli-build/server/app/dashboard/profile.rsc +5 -5
  153. package/app/.next-cli-build/server/app/dashboard/profile.segments/!KGRhc2hib2FyZCk/dashboard/profile/__PAGE__.segment.rsc +2 -2
  154. package/app/.next-cli-build/server/app/dashboard/profile.segments/!KGRhc2hib2FyZCk/dashboard/profile.segment.rsc +1 -1
  155. package/app/.next-cli-build/server/app/dashboard/profile.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  156. package/app/.next-cli-build/server/app/dashboard/profile.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  157. package/app/.next-cli-build/server/app/dashboard/profile.segments/_full.segment.rsc +5 -5
  158. package/app/.next-cli-build/server/app/dashboard/profile.segments/_head.segment.rsc +1 -1
  159. package/app/.next-cli-build/server/app/dashboard/profile.segments/_index.segment.rsc +3 -3
  160. package/app/.next-cli-build/server/app/dashboard/profile.segments/_tree.segment.rsc +1 -1
  161. package/app/.next-cli-build/server/app/dashboard/providers/new.html +1 -1
  162. package/app/.next-cli-build/server/app/dashboard/providers/new.rsc +5 -5
  163. package/app/.next-cli-build/server/app/dashboard/providers/new.segments/!KGRhc2hib2FyZCk/dashboard/providers/new/__PAGE__.segment.rsc +2 -2
  164. package/app/.next-cli-build/server/app/dashboard/providers/new.segments/!KGRhc2hib2FyZCk/dashboard/providers/new.segment.rsc +1 -1
  165. package/app/.next-cli-build/server/app/dashboard/providers/new.segments/!KGRhc2hib2FyZCk/dashboard/providers.segment.rsc +1 -1
  166. package/app/.next-cli-build/server/app/dashboard/providers/new.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  167. package/app/.next-cli-build/server/app/dashboard/providers/new.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  168. package/app/.next-cli-build/server/app/dashboard/providers/new.segments/_full.segment.rsc +5 -5
  169. package/app/.next-cli-build/server/app/dashboard/providers/new.segments/_head.segment.rsc +1 -1
  170. package/app/.next-cli-build/server/app/dashboard/providers/new.segments/_index.segment.rsc +3 -3
  171. package/app/.next-cli-build/server/app/dashboard/providers/new.segments/_tree.segment.rsc +1 -1
  172. package/app/.next-cli-build/server/app/dashboard/providers.html +1 -1
  173. package/app/.next-cli-build/server/app/dashboard/providers.rsc +5 -5
  174. package/app/.next-cli-build/server/app/dashboard/providers.segments/!KGRhc2hib2FyZCk/dashboard/providers/__PAGE__.segment.rsc +2 -2
  175. package/app/.next-cli-build/server/app/dashboard/providers.segments/!KGRhc2hib2FyZCk/dashboard/providers.segment.rsc +1 -1
  176. package/app/.next-cli-build/server/app/dashboard/providers.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  177. package/app/.next-cli-build/server/app/dashboard/providers.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  178. package/app/.next-cli-build/server/app/dashboard/providers.segments/_full.segment.rsc +5 -5
  179. package/app/.next-cli-build/server/app/dashboard/providers.segments/_head.segment.rsc +1 -1
  180. package/app/.next-cli-build/server/app/dashboard/providers.segments/_index.segment.rsc +3 -3
  181. package/app/.next-cli-build/server/app/dashboard/providers.segments/_tree.segment.rsc +1 -1
  182. package/app/.next-cli-build/server/app/dashboard/proxy-fitness.html +1 -1
  183. package/app/.next-cli-build/server/app/dashboard/proxy-fitness.rsc +5 -5
  184. package/app/.next-cli-build/server/app/dashboard/proxy-fitness.segments/!KGRhc2hib2FyZCk/dashboard/proxy-fitness/__PAGE__.segment.rsc +2 -2
  185. package/app/.next-cli-build/server/app/dashboard/proxy-fitness.segments/!KGRhc2hib2FyZCk/dashboard/proxy-fitness.segment.rsc +1 -1
  186. package/app/.next-cli-build/server/app/dashboard/proxy-fitness.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  187. package/app/.next-cli-build/server/app/dashboard/proxy-fitness.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  188. package/app/.next-cli-build/server/app/dashboard/proxy-fitness.segments/_full.segment.rsc +5 -5
  189. package/app/.next-cli-build/server/app/dashboard/proxy-fitness.segments/_head.segment.rsc +1 -1
  190. package/app/.next-cli-build/server/app/dashboard/proxy-fitness.segments/_index.segment.rsc +3 -3
  191. package/app/.next-cli-build/server/app/dashboard/proxy-fitness.segments/_tree.segment.rsc +1 -1
  192. package/app/.next-cli-build/server/app/dashboard/proxy-pools.html +1 -1
  193. package/app/.next-cli-build/server/app/dashboard/proxy-pools.rsc +5 -5
  194. package/app/.next-cli-build/server/app/dashboard/proxy-pools.segments/!KGRhc2hib2FyZCk/dashboard/proxy-pools/__PAGE__.segment.rsc +2 -2
  195. package/app/.next-cli-build/server/app/dashboard/proxy-pools.segments/!KGRhc2hib2FyZCk/dashboard/proxy-pools.segment.rsc +1 -1
  196. package/app/.next-cli-build/server/app/dashboard/proxy-pools.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  197. package/app/.next-cli-build/server/app/dashboard/proxy-pools.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  198. package/app/.next-cli-build/server/app/dashboard/proxy-pools.segments/_full.segment.rsc +5 -5
  199. package/app/.next-cli-build/server/app/dashboard/proxy-pools.segments/_head.segment.rsc +1 -1
  200. package/app/.next-cli-build/server/app/dashboard/proxy-pools.segments/_index.segment.rsc +3 -3
  201. package/app/.next-cli-build/server/app/dashboard/proxy-pools.segments/_tree.segment.rsc +1 -1
  202. package/app/.next-cli-build/server/app/dashboard/pxpipe.html +1 -1
  203. package/app/.next-cli-build/server/app/dashboard/pxpipe.rsc +5 -5
  204. package/app/.next-cli-build/server/app/dashboard/pxpipe.segments/!KGRhc2hib2FyZCk/dashboard/pxpipe/__PAGE__.segment.rsc +2 -2
  205. package/app/.next-cli-build/server/app/dashboard/pxpipe.segments/!KGRhc2hib2FyZCk/dashboard/pxpipe.segment.rsc +1 -1
  206. package/app/.next-cli-build/server/app/dashboard/pxpipe.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  207. package/app/.next-cli-build/server/app/dashboard/pxpipe.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  208. package/app/.next-cli-build/server/app/dashboard/pxpipe.segments/_full.segment.rsc +5 -5
  209. package/app/.next-cli-build/server/app/dashboard/pxpipe.segments/_head.segment.rsc +1 -1
  210. package/app/.next-cli-build/server/app/dashboard/pxpipe.segments/_index.segment.rsc +3 -3
  211. package/app/.next-cli-build/server/app/dashboard/pxpipe.segments/_tree.segment.rsc +1 -1
  212. package/app/.next-cli-build/server/app/dashboard/quota.html +2 -2
  213. package/app/.next-cli-build/server/app/dashboard/quota.rsc +6 -6
  214. package/app/.next-cli-build/server/app/dashboard/quota.segments/!KGRhc2hib2FyZCk/dashboard/quota/__PAGE__.segment.rsc +3 -3
  215. package/app/.next-cli-build/server/app/dashboard/quota.segments/!KGRhc2hib2FyZCk/dashboard/quota.segment.rsc +1 -1
  216. package/app/.next-cli-build/server/app/dashboard/quota.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  217. package/app/.next-cli-build/server/app/dashboard/quota.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  218. package/app/.next-cli-build/server/app/dashboard/quota.segments/_full.segment.rsc +6 -6
  219. package/app/.next-cli-build/server/app/dashboard/quota.segments/_head.segment.rsc +1 -1
  220. package/app/.next-cli-build/server/app/dashboard/quota.segments/_index.segment.rsc +3 -3
  221. package/app/.next-cli-build/server/app/dashboard/quota.segments/_tree.segment.rsc +1 -1
  222. package/app/.next-cli-build/server/app/dashboard/settings/pricing/page_client-reference-manifest.js +1 -1
  223. package/app/.next-cli-build/server/app/dashboard/settings/pricing.html +1 -1
  224. package/app/.next-cli-build/server/app/dashboard/settings/pricing.rsc +3 -3
  225. package/app/.next-cli-build/server/app/dashboard/settings/pricing.segments/_full.segment.rsc +3 -3
  226. package/app/.next-cli-build/server/app/dashboard/settings/pricing.segments/_head.segment.rsc +1 -1
  227. package/app/.next-cli-build/server/app/dashboard/settings/pricing.segments/_index.segment.rsc +3 -3
  228. package/app/.next-cli-build/server/app/dashboard/settings/pricing.segments/_tree.segment.rsc +1 -1
  229. package/app/.next-cli-build/server/app/dashboard/settings/pricing.segments/dashboard/settings/pricing/__PAGE__.segment.rsc +1 -1
  230. package/app/.next-cli-build/server/app/dashboard/settings/pricing.segments/dashboard/settings/pricing.segment.rsc +1 -1
  231. package/app/.next-cli-build/server/app/dashboard/settings/pricing.segments/dashboard/settings.segment.rsc +1 -1
  232. package/app/.next-cli-build/server/app/dashboard/settings/pricing.segments/dashboard.segment.rsc +1 -1
  233. package/app/.next-cli-build/server/app/dashboard/skills.html +1 -1
  234. package/app/.next-cli-build/server/app/dashboard/skills.rsc +5 -5
  235. package/app/.next-cli-build/server/app/dashboard/skills.segments/!KGRhc2hib2FyZCk/dashboard/skills/__PAGE__.segment.rsc +2 -2
  236. package/app/.next-cli-build/server/app/dashboard/skills.segments/!KGRhc2hib2FyZCk/dashboard/skills.segment.rsc +1 -1
  237. package/app/.next-cli-build/server/app/dashboard/skills.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  238. package/app/.next-cli-build/server/app/dashboard/skills.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  239. package/app/.next-cli-build/server/app/dashboard/skills.segments/_full.segment.rsc +5 -5
  240. package/app/.next-cli-build/server/app/dashboard/skills.segments/_head.segment.rsc +1 -1
  241. package/app/.next-cli-build/server/app/dashboard/skills.segments/_index.segment.rsc +3 -3
  242. package/app/.next-cli-build/server/app/dashboard/skills.segments/_tree.segment.rsc +1 -1
  243. package/app/.next-cli-build/server/app/dashboard/token-saver.html +1 -1
  244. package/app/.next-cli-build/server/app/dashboard/token-saver.rsc +5 -5
  245. package/app/.next-cli-build/server/app/dashboard/token-saver.segments/!KGRhc2hib2FyZCk/dashboard/token-saver/__PAGE__.segment.rsc +2 -2
  246. package/app/.next-cli-build/server/app/dashboard/token-saver.segments/!KGRhc2hib2FyZCk/dashboard/token-saver.segment.rsc +1 -1
  247. package/app/.next-cli-build/server/app/dashboard/token-saver.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  248. package/app/.next-cli-build/server/app/dashboard/token-saver.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  249. package/app/.next-cli-build/server/app/dashboard/token-saver.segments/_full.segment.rsc +5 -5
  250. package/app/.next-cli-build/server/app/dashboard/token-saver.segments/_head.segment.rsc +1 -1
  251. package/app/.next-cli-build/server/app/dashboard/token-saver.segments/_index.segment.rsc +3 -3
  252. package/app/.next-cli-build/server/app/dashboard/token-saver.segments/_tree.segment.rsc +1 -1
  253. package/app/.next-cli-build/server/app/dashboard/translator.html +1 -1
  254. package/app/.next-cli-build/server/app/dashboard/translator.rsc +5 -5
  255. package/app/.next-cli-build/server/app/dashboard/translator.segments/!KGRhc2hib2FyZCk/dashboard/translator/__PAGE__.segment.rsc +2 -2
  256. package/app/.next-cli-build/server/app/dashboard/translator.segments/!KGRhc2hib2FyZCk/dashboard/translator.segment.rsc +1 -1
  257. package/app/.next-cli-build/server/app/dashboard/translator.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  258. package/app/.next-cli-build/server/app/dashboard/translator.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  259. package/app/.next-cli-build/server/app/dashboard/translator.segments/_full.segment.rsc +5 -5
  260. package/app/.next-cli-build/server/app/dashboard/translator.segments/_head.segment.rsc +1 -1
  261. package/app/.next-cli-build/server/app/dashboard/translator.segments/_index.segment.rsc +3 -3
  262. package/app/.next-cli-build/server/app/dashboard/translator.segments/_tree.segment.rsc +1 -1
  263. package/app/.next-cli-build/server/app/dashboard/usage.html +1 -1
  264. package/app/.next-cli-build/server/app/dashboard/usage.rsc +5 -5
  265. package/app/.next-cli-build/server/app/dashboard/usage.segments/!KGRhc2hib2FyZCk/dashboard/usage/__PAGE__.segment.rsc +2 -2
  266. package/app/.next-cli-build/server/app/dashboard/usage.segments/!KGRhc2hib2FyZCk/dashboard/usage.segment.rsc +1 -1
  267. package/app/.next-cli-build/server/app/dashboard/usage.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  268. package/app/.next-cli-build/server/app/dashboard/usage.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  269. package/app/.next-cli-build/server/app/dashboard/usage.segments/_full.segment.rsc +5 -5
  270. package/app/.next-cli-build/server/app/dashboard/usage.segments/_head.segment.rsc +1 -1
  271. package/app/.next-cli-build/server/app/dashboard/usage.segments/_index.segment.rsc +3 -3
  272. package/app/.next-cli-build/server/app/dashboard/usage.segments/_tree.segment.rsc +1 -1
  273. package/app/.next-cli-build/server/app/dashboard.html +1 -1
  274. package/app/.next-cli-build/server/app/dashboard.rsc +5 -5
  275. package/app/.next-cli-build/server/app/dashboard.segments/!KGRhc2hib2FyZCk/dashboard/__PAGE__.segment.rsc +2 -2
  276. package/app/.next-cli-build/server/app/dashboard.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  277. package/app/.next-cli-build/server/app/dashboard.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  278. package/app/.next-cli-build/server/app/dashboard.segments/_full.segment.rsc +5 -5
  279. package/app/.next-cli-build/server/app/dashboard.segments/_head.segment.rsc +1 -1
  280. package/app/.next-cli-build/server/app/dashboard.segments/_index.segment.rsc +3 -3
  281. package/app/.next-cli-build/server/app/dashboard.segments/_tree.segment.rsc +1 -1
  282. package/app/.next-cli-build/server/app/landing/page_client-reference-manifest.js +1 -1
  283. package/app/.next-cli-build/server/app/landing.html +1 -1
  284. package/app/.next-cli-build/server/app/landing.rsc +3 -3
  285. package/app/.next-cli-build/server/app/landing.segments/_full.segment.rsc +3 -3
  286. package/app/.next-cli-build/server/app/landing.segments/_head.segment.rsc +1 -1
  287. package/app/.next-cli-build/server/app/landing.segments/_index.segment.rsc +3 -3
  288. package/app/.next-cli-build/server/app/landing.segments/_tree.segment.rsc +1 -1
  289. package/app/.next-cli-build/server/app/landing.segments/landing/__PAGE__.segment.rsc +1 -1
  290. package/app/.next-cli-build/server/app/landing.segments/landing.segment.rsc +1 -1
  291. package/app/.next-cli-build/server/app/login/page_client-reference-manifest.js +1 -1
  292. package/app/.next-cli-build/server/app/login.html +1 -1
  293. package/app/.next-cli-build/server/app/login.rsc +4 -4
  294. package/app/.next-cli-build/server/app/login.segments/_full.segment.rsc +4 -4
  295. package/app/.next-cli-build/server/app/login.segments/_head.segment.rsc +1 -1
  296. package/app/.next-cli-build/server/app/login.segments/_index.segment.rsc +3 -3
  297. package/app/.next-cli-build/server/app/login.segments/_tree.segment.rsc +1 -1
  298. package/app/.next-cli-build/server/app/login.segments/login/__PAGE__.segment.rsc +2 -2
  299. package/app/.next-cli-build/server/app/login.segments/login.segment.rsc +1 -1
  300. package/app/.next-cli-build/server/app/masuk/page_client-reference-manifest.js +1 -1
  301. package/app/.next-cli-build/server/app-paths-manifest.json +14 -14
  302. package/app/.next-cli-build/server/chunks/1632.js +1 -1
  303. package/app/.next-cli-build/server/chunks/2764.js +1 -1
  304. package/app/.next-cli-build/server/chunks/32.js +1 -1
  305. package/app/.next-cli-build/server/chunks/3398.js +5 -5
  306. package/app/.next-cli-build/server/chunks/4105.js +1 -1
  307. package/app/.next-cli-build/server/chunks/4502.js +2 -2
  308. package/app/.next-cli-build/server/chunks/4574.js +3 -5
  309. package/app/.next-cli-build/server/chunks/5006.js +1 -1
  310. package/app/.next-cli-build/server/chunks/5198.js +1 -1
  311. package/app/.next-cli-build/server/chunks/5302.js +1 -1
  312. package/app/.next-cli-build/server/chunks/5598.js +1 -1
  313. package/app/.next-cli-build/server/chunks/6085.js +1 -1
  314. package/app/.next-cli-build/server/chunks/6931.js +1 -1
  315. package/app/.next-cli-build/server/chunks/7104.js +1 -1
  316. package/app/.next-cli-build/server/chunks/9984.js +1 -1
  317. package/app/.next-cli-build/server/middleware-build-manifest.js +1 -1
  318. package/app/.next-cli-build/server/pages/404.html +1 -1
  319. package/app/.next-cli-build/server/pages/500.html +1 -1
  320. package/app/.next-cli-build/server/server-reference-manifest.js +1 -1
  321. package/app/.next-cli-build/server/server-reference-manifest.json +1 -1
  322. package/app/.next-cli-build/static/chunks/{4385-c0914bc328af003a.js → 4385-24528786d2acf9c4.js} +1 -1
  323. package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/media-providers/[kind]/[id]/{page-7e4411e7070e11c8.js → page-775d2e9133c07844.js} +1 -1
  324. package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/providers/[id]/{page-5039d324c1af44cd.js → page-02f13efbe14c5c68.js} +1 -1
  325. package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/providers/page-44af31c220b203a8.js +1 -0
  326. package/app/package.json +1 -1
  327. package/package.json +1 -1
  328. package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/providers/page-ac56e568902351a0.js +0 -1
  329. /package/app/.next-cli-build/static/{WuRuQCoSteIg58fPNKmNT → SxricHoV60EwiDAVPTwV7}/_buildManifest.js +0 -0
  330. /package/app/.next-cli-build/static/{WuRuQCoSteIg58fPNKmNT → SxricHoV60EwiDAVPTwV7}/_ssgManifest.js +0 -0
@@ -1,4 +1,4 @@
1
- (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[182],{2710:(e,t,a)=>{Promise.resolve().then(a.bind(a,64347))},21863:(e,t,a)=>{"use strict";function s(e,t){return!1===e?"default":"active"===t||"success"===t?"success":"error"===t||"expired"===t||"unavailable"===t?"error":"default"}function r(e){let t=e?.testStatus;return e?.isActive===!1||"unavailable"===t||"error"===t||"expired"===t?"unavailable":"active"}a.d(t,{d:()=>r,g:()=>s})},64347:(e,t,a)=>{"use strict";a.r(t),a.d(t,{default:()=>B});var s=a(15102),r=a(93278),l=a(93885),o=a.n(l),n=a(82030),i=a(92940),d=a(31704),c=a(31038),m=a(21863);function u({until:e}){let[t,a]=(0,n.useState)("");return((0,n.useEffect)(()=>{let t=()=>{let t=new Date(e).getTime()-Date.now();if(t<=0)return void a("");let s=Math.floor(t/1e3);s<60?a(`${s}s`):s<3600?a(`${Math.floor(s/60)}m ${s%60}s`):a(`${Math.floor(s/3600)}h ${Math.floor(s%3600/60)}m`)};t();let s=setInterval(t,1e3);return()=>clearInterval(s)},[e]),t)?(0,s.jsxs)("span",{className:"text-xs text-orange-500 font-mono",children:["⏱ ",t]}):null}function x({connection:e,proxyPools:t,isOAuth:a,isFirst:r,isLast:l,onMoveUp:o,onMoveDown:d,onToggleActive:c,onUpdateProxy:p,onEdit:h,onDelete:b}){let[g,f]=(0,n.useState)(!1),[y,j]=(0,n.useState)(!1),[v,w]=(0,n.useState)(!1),N=(0,n.useRef)(null),k=new Map((t||[]).map(e=>[e.id,e])),C=e.providerSpecificData?.proxyPoolId||null,S=C?k.get(C):null,$=e.providerSpecificData?.connectionProxyEnabled===!0&&!!e.providerSpecificData?.connectionProxyUrl,P=!!C||$,_=S?`Pool: ${S.name}`:C?`Pool: ${C} (inactive/missing)`:$?`Legacy: ${e.providerSpecificData?.connectionProxyUrl}`:"",I="",A=S?.proxyUrl||e.providerSpecificData?.connectionProxyUrl;if(A)try{let e=new URL(A);I=`${e.protocol}//${e.hostname}${e.port?`:${e.port}`:""}`}catch{I=A}let E=S?.noProxy||e.providerSpecificData?.connectionNoProxy||"",T=S?.isActive===!0?"success":C||$?"error":"default",B=Object.entries(e).filter(([e])=>e.startsWith("modelLock_")).map(([,e])=>e).filter(Boolean).sort()[0]||null;(0,n.useEffect)(()=>{let t=null,a=()=>{w(!!Object.entries(e).filter(([e])=>e.startsWith("modelLock_")).map(([,e])=>e).filter(e=>e&&new Date(e).getTime()>Date.now()).sort()[0])};return a(),B&&(t=setInterval(a,1e3)),()=>{t&&clearInterval(t)}},[B,e]),(0,n.useEffect)(()=>{if(!g)return;let e=e=>{N.current&&!N.current.contains(e.target)&&f(!1)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[g]);let M="unavailable"!==e.testStatus||v?e.testStatus:"active",O=a?e.name||e.email||e.displayName||"OAuth Account":e.name,K=async e=>{j(!0);try{await p("__none__"===e?null:e)}finally{j(!1),f(!1)}};return(0,s.jsxs)("div",{className:`group flex flex-col gap-3 p-2 rounded-lg sm:flex-row sm:items-center sm:justify-between hover:bg-black/[0.02] dark:hover:bg-white/[0.02] transition-colors ${!1===e.isActive?"opacity-60":""}`,children:[(0,s.jsxs)("div",{className:"flex w-full min-w-0 flex-1 items-start gap-3 sm:items-center",children:[(0,s.jsxs)("div",{className:"flex flex-col",children:[(0,s.jsx)("button",{onClick:o,disabled:r,className:`p-0.5 rounded ${r?"text-text-muted/30 cursor-not-allowed":"hover:bg-sidebar text-text-muted hover:text-primary"}`,children:(0,s.jsx)("span",{className:"material-symbols-outlined text-sm",children:"keyboard_arrow_up"})}),(0,s.jsx)("button",{onClick:d,disabled:l,className:`p-0.5 rounded ${l?"text-text-muted/30 cursor-not-allowed":"hover:bg-sidebar text-text-muted hover:text-primary"}`,children:(0,s.jsx)("span",{className:"material-symbols-outlined text-sm",children:"keyboard_arrow_down"})})]}),(0,s.jsx)("span",{className:"material-symbols-outlined text-base text-text-muted",children:a?"lock":"key"}),(0,s.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,s.jsx)("p",{className:"text-sm font-medium truncate",children:O}),(0,s.jsxs)("div",{className:"flex flex-wrap items-center gap-2 mt-1",children:[(0,s.jsx)(i.Badge,{variant:(0,m.g)(e.isActive,M),size:"sm",dot:!0,children:!1===e.isActive?"disabled":M||"Unknown"}),P&&(0,s.jsx)(i.Badge,{variant:T,size:"sm",children:"Proxy"}),v&&!1!==e.isActive&&(0,s.jsx)(u,{until:B}),e.lastError&&!1!==e.isActive&&(0,s.jsx)("span",{className:"text-xs text-red-500 truncate max-w-[300px]",title:e.lastError,children:e.lastError}),(0,s.jsxs)("span",{className:"text-xs text-text-muted",children:["#",e.priority]})]}),P&&(0,s.jsxs)("div",{className:"mt-1 flex flex-wrap items-center gap-2",children:[(0,s.jsx)("span",{className:"text-[11px] text-text-muted truncate max-w-[420px]",title:_,children:_}),I&&(0,s.jsx)("code",{className:"text-[10px] font-mono bg-black/5 dark:bg-white/5 px-1 py-0.5 rounded text-text-muted",children:I}),E&&(0,s.jsxs)("span",{className:"text-[11px] text-text-muted truncate max-w-[320px]",title:E,children:["no_proxy: ",E]})]})]})]}),(0,s.jsxs)("div",{className:"flex w-full flex-wrap items-center justify-between gap-2 sm:w-auto sm:justify-end",children:[(0,s.jsxs)("div",{className:"flex flex-wrap gap-1",children:[(t||[]).length>0&&(0,s.jsxs)("div",{className:"relative",ref:N,children:[(0,s.jsxs)("button",{onClick:()=>f(e=>!e),className:`flex flex-col items-center px-2 py-1 rounded hover:bg-black/5 dark:hover:bg-white/5 transition-colors ${P?"text-primary":"text-text-muted hover:text-primary"}`,disabled:y,children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:y?"progress_activity":"lan"}),(0,s.jsx)("span",{className:"text-[10px] leading-tight",children:"Proxy"})]}),g&&(0,s.jsxs)("div",{className:"absolute right-0 top-full mt-1 z-50 bg-bg border border-border rounded-lg shadow-lg py-1 min-w-[160px]",children:[(0,s.jsx)("button",{onClick:()=>K("__none__"),className:`w-full text-left px-3 py-1.5 text-sm hover:bg-black/5 dark:hover:bg-white/5 ${!C?"text-primary font-medium":"text-text-main"}`,children:"None"}),(t||[]).map(e=>(0,s.jsx)("button",{onClick:()=>K(e.id),className:`w-full text-left px-3 py-1.5 text-sm hover:bg-black/5 dark:hover:bg-white/5 ${C===e.id?"text-primary font-medium":"text-text-main"}`,children:e.name},e.id))]})]}),(0,s.jsxs)("button",{onClick:h,className:"flex flex-col items-center px-2 py-1 rounded hover:bg-black/5 dark:hover:bg-white/5 text-text-muted hover:text-primary",children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:"edit"}),(0,s.jsx)("span",{className:"text-[10px] leading-tight",children:"Edit"})]}),(0,s.jsxs)("button",{onClick:b,className:"flex flex-col items-center px-2 py-1 rounded hover:bg-red-500/10 text-red-500",children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:"delete"}),(0,s.jsx)("span",{className:"text-[10px] leading-tight",children:"Delete"})]})]}),(0,s.jsx)(i.Toggle,{size:"sm",checked:e.isActive??!0,onChange:c,title:e.isActive??!0?"Disable":"Enable"})]})]})}function p({isOpen:e,provider:t,providerName:a,proxyPools:r,onSave:l,onClose:o}){let d="__none__",[c,m]=(0,n.useState)({name:"",apiKey:"",priority:1,proxyPoolId:d}),[u,x]=(0,n.useState)(!1),[h,b]=(0,n.useState)(null),[g,f]=(0,n.useState)(!1),y=async()=>{x(!0);try{let e=await fetch("/api/providers/validate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:t,apiKey:c.apiKey})}),a=await e.json();b(a.valid?"success":"failed")}catch{b("failed")}finally{x(!1)}},j=async()=>{if(t&&c.apiKey){f(!0);try{let e=!1;try{x(!0),b(null);let a=await fetch("/api/providers/validate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:t,apiKey:c.apiKey})});e=!!(await a.json()).valid,b(e?"success":"failed")}catch{b("failed")}finally{x(!1)}await l({name:c.name,apiKey:c.apiKey,priority:c.priority,proxyPoolId:c.proxyPoolId===d?null:c.proxyPoolId,testStatus:e?"active":"unknown"})}finally{f(!1)}}};return t?(0,s.jsx)(i.Modal,{isOpen:e,title:`Add ${a||t} API Key`,onClose:o,children:(0,s.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{className:"text-xs text-text-muted mb-1 block",children:"Name"}),(0,s.jsx)("input",{className:"w-full px-3 py-2 text-sm border border-border rounded-lg bg-background focus:outline-none focus:border-primary",value:c.name,onChange:e=>m({...c,name:e.target.value}),placeholder:"Production Key"})]}),(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsxs)("div",{className:"flex-1",children:[(0,s.jsx)("label",{className:"text-xs text-text-muted mb-1 block",children:"API Key"}),(0,s.jsx)("input",{type:"password",className:"w-full px-3 py-2 text-sm border border-border rounded-lg bg-background focus:outline-none focus:border-primary",value:c.apiKey,onChange:e=>m({...c,apiKey:e.target.value})})]}),(0,s.jsx)("div",{className:"pt-6",children:(0,s.jsx)(i.Button,{onClick:y,disabled:!c.apiKey||u||g,variant:"secondary",children:u?"Checking...":"Check"})})]}),h&&(0,s.jsx)(i.Badge,{variant:"success"===h?"success":"error",children:"success"===h?"Valid":"Invalid"}),(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{className:"text-xs text-text-muted mb-1 block",children:"Priority"}),(0,s.jsx)("input",{type:"number",className:"w-full px-3 py-2 text-sm border border-border rounded-lg bg-background focus:outline-none focus:border-primary",value:c.priority,onChange:e=>m({...c,priority:Number.parseInt(e.target.value)||1})})]}),(0,s.jsx)(i.Select,{label:"Proxy Pool",value:c.proxyPoolId,onChange:e=>m({...c,proxyPoolId:e.target.value}),options:[{value:d,label:"None"},...(r||[]).map(e=>({value:e.id,label:e.name}))]}),(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsx)(i.Button,{onClick:j,fullWidth:!0,disabled:!c.name||!c.apiKey||g,children:g?"Saving...":"Save"}),(0,s.jsx)(i.Button,{onClick:o,variant:"ghost",fullWidth:!0,children:"Cancel"})]})]})}):null}function h({providerId:e,isOAuth:t}){let[a,r]=(0,n.useState)([]),[l,o]=(0,n.useState)([]),[d,c]=(0,n.useState)(!0),[m,u]=(0,n.useState)(!1),[b,g]=(0,n.useState)(!1),[f,y]=(0,n.useState)(null),[j,v]=(0,n.useState)(null),[w,N]=(0,n.useState)("1"),[k,C]=(0,n.useState)(null),S=(0,n.useCallback)(async()=>{try{let[t,a,s]=await Promise.all([fetch("/api/providers",{cache:"no-store"}),fetch("/api/proxy-pools?isActive=true",{cache:"no-store"}),fetch("/api/settings",{cache:"no-store"})]),l=await t.json(),n=await a.json(),i=s.ok?await s.json():{};t.ok&&r((l.connections||[]).filter(t=>t.provider===e)),a.ok&&o(n.proxyPools||[]);let d=(i.providerStrategies||{})[e]||{};v(d.fallbackStrategy||null),N(null!=d.stickyRoundRobinLimit?String(d.stickyRoundRobinLimit):"1")}catch(e){console.log("ConnectionsCard fetch error:",e)}finally{c(!1)}},[e]);(0,n.useEffect)(()=>{S()},[S]);let $=async(t,a)=>{try{let s=await fetch("/api/settings",{cache:"no-store"}),r=(s.ok?await s.json():{}).providerStrategies||{},l={};t&&(l.fallbackStrategy=t),"round-robin"===t&&""!==a&&(l.stickyRoundRobinLimit=Number(a)||3);let o={...r};0===Object.keys(l).length?delete o[e]:o[e]=l,await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({providerStrategies:o})})}catch(e){console.log("saveStrategy error:",e)}},P=async(e,t)=>{let s=[...a];[s[e],s[t]]=[s[t],s[e]],r(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{await S()}},_=async e=>{C({title:"Delete Connection",message:"Delete this connection?",onConfirm:async()=>{C(null);try{(await fetch(`/api/providers/${e}`,{method:"DELETE"})).ok&&r(t=>t.filter(t=>t.id!==e))}catch(e){console.log("delete error:",e)}}})},I=async(e,t)=>{try{(await fetch(`/api/providers/${e}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({isActive:t})})).ok&&r(a=>a.map(a=>a.id===e?{...a,isActive:t}:a))}catch(e){console.log("toggle error:",e)}},A=async(e,t)=>{try{(await fetch(`/api/providers/${e}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({proxyPoolId:t||null})})).ok&&r(a=>a.map(a=>a.id===e?{...a,providerSpecificData:{...a.providerSpecificData,proxyPoolId:t||null}}:a))}catch(e){console.log("proxy error:",e)}},E=async t=>{try{(await fetch("/api/providers",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:e,...t})})).ok&&(await S(),u(!1))}catch(e){console.log("save apikey error:",e)}},T=async e=>{try{(await fetch(`/api/providers/${f.id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})).ok&&(await S(),g(!1))}catch(e){console.log("update connection error:",e)}};return d?(0,s.jsx)(i.Card,{children:(0,s.jsx)("div",{className:"h-20 animate-pulse bg-black/5 rounded-lg"})}):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)(i.Card,{children:[(0,s.jsxs)("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between mb-4",children:[(0,s.jsx)("h2",{className:"text-lg font-semibold",children:"Connections"}),(0,s.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,s.jsx)("span",{className:"text-xs text-text-muted font-medium",children:"Round Robin"}),(0,s.jsx)(i.Toggle,{checked:"round-robin"===j,onChange:e=>{let t=e?"round-robin":null;v(t),e&&!w&&N("1"),$(t,e?w||"1":w)}}),"round-robin"===j&&(0,s.jsxs)("div",{className:"flex flex-wrap items-center gap-1.5",children:[(0,s.jsx)("span",{className:"text-xs text-text-muted",children:"Sticky:"}),(0,s.jsx)("input",{type:"number",min:1,value:w,onChange:e=>{N(e.target.value),$("round-robin",e.target.value)},className:"w-16 px-2 py-1 text-xs border border-border rounded-md bg-background focus:outline-none focus:border-primary"})]})]})]}),0===a.length?(0,s.jsxs)("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[(0,s.jsx)("p",{className:"text-sm text-text-muted",children:"No connections yet"}),(0,s.jsx)(i.Button,{size:"sm",icon:"add",onClick:()=>u(!0),children:"Add Connection"})]}):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("div",{className:"flex flex-col divide-y divide-black/[0.03] dark:divide-white/[0.03]",children:a.map((e,r)=>(0,s.jsx)(x,{connection:e,proxyPools:l,isOAuth:t,isFirst:0===r,isLast:r===a.length-1,onMoveUp:()=>P(r,r-1),onMoveDown:()=>P(r,r+1),onToggleActive:t=>I(e.id,t),onUpdateProxy:t=>A(e.id,t),onEdit:()=>{y(e),g(!0)},onDelete:()=>_(e.id)},e.id))}),(0,s.jsx)("div",{className:"mt-4 flex justify-stretch sm:justify-start",children:(0,s.jsx)(i.Button,{size:"sm",icon:"add",onClick:()=>u(!0),children:"Add"})})]})]}),(0,s.jsx)(p,{isOpen:m,provider:e,proxyPools:l,onSave:E,onClose:()=>u(!1)}),(0,s.jsx)(i.EditConnectionModal,{isOpen:b,connection:f,proxyPools:l,onSave:T,onClose:()=>g(!1)}),(0,s.jsx)(i.ConfirmModal,{isOpen:!!k,onClose:()=>C(null),onConfirm:k?.onConfirm,title:k?.title||"Confirm",message:k?.message,variant:"danger"})]})}var b=a(55223),g=a(21577);function f({model:e,fullModel:t,copied:a,onCopy:r,testStatus:l,isCustom:o,isFree:n,onDeleteAlias:i,onTest:d,isTesting:c}){let m="ok"===l?"#22c55e":"error"===l?"#ef4444":void 0;return(0,s.jsx)("div",{className:`group px-3 py-2 rounded-lg border ${"ok"===l?"border-green-500/40":"error"===l?"border-red-500/40":"border-border"} hover:bg-sidebar/50`,children:(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-base",style:m?{color:m}:void 0,children:"ok"===l?"check_circle":"error"===l?"cancel":"smart_toy"}),(0,s.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,s.jsx)("code",{className:"text-xs text-text-muted font-mono bg-sidebar px-1.5 py-0.5 rounded",children:t}),e.name&&(0,s.jsx)("span",{className:"text-[9px] text-text-muted/70 italic pl-1",children:e.name})]}),d&&(0,s.jsxs)("div",{className:"relative group/btn",children:[(0,s.jsx)("button",{onClick:d,disabled:c,className:`p-0.5 hover:bg-sidebar rounded text-text-muted hover:text-primary transition-opacity ${c?"opacity-100":"opacity-0 group-hover:opacity-100"}`,children:(0,s.jsx)("span",{className:"material-symbols-outlined text-sm",style:c?{animation:"spin 1s linear infinite"}:void 0,children:c?"progress_activity":"science"})}),(0,s.jsx)("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:c?"Testing...":"Test"})]}),(0,s.jsxs)("div",{className:"relative group/btn",children:[(0,s.jsx)("button",{onClick:()=>r(t,`model-${e.id}`),className:"p-0.5 hover:bg-sidebar rounded text-text-muted hover:text-primary",children:(0,s.jsx)("span",{className:"material-symbols-outlined text-sm",children:a===`model-${e.id}`?"check":"content_copy"})}),(0,s.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:a===`model-${e.id}`?"Copied!":"Copy"})]}),n&&(0,s.jsx)("span",{className:"text-[10px] font-bold text-green-500 bg-green-500/10 px-1.5 py-0.5 rounded",children:"FREE"}),o&&(0,s.jsx)("button",{onClick:i,className:"p-0.5 hover:bg-red-500/10 rounded text-text-muted hover:text-red-500 opacity-0 group-hover:opacity-100 transition-opacity ml-auto",title:"Remove custom model",children:(0,s.jsx)("span",{className:"material-symbols-outlined text-sm",children:"close"})})]})})}function y({isOpen:e,onSave:t,onClose:a}){let[r,l]=(0,n.useState)(""),o=()=>{r.trim()&&(t(r.trim()),l(""))};return(0,s.jsx)(i.Modal,{isOpen:e,title:"Add Custom Model",onClose:a,children:(0,s.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{className:"text-xs text-text-muted mb-1 block",children:"Model ID"}),(0,s.jsx)("input",{className:"w-full px-3 py-2 text-sm border border-border rounded-lg bg-background focus:outline-none focus:border-primary",value:r,onChange:e=>l(e.target.value),onKeyDown:e=>"Enter"===e.key&&o(),placeholder:"e.g. tts-1-hd",autoFocus:!0})]}),(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsx)(i.Button,{onClick:o,fullWidth:!0,disabled:!r.trim(),children:"Add"}),(0,s.jsx)(i.Button,{onClick:a,variant:"ghost",fullWidth:!0,children:"Cancel"})]})]})})}function j({providerId:e,kindFilter:t,providerAliasOverride:a}){let{copied:r,copy:l}=(0,g.C)(),[o,d]=(0,n.useState)({}),[m,u]=(0,n.useState)([]),[x,p]=(0,n.useState)({}),[h,v]=(0,n.useState)(null),[w,N]=(0,n.useState)(""),[k,C]=(0,n.useState)(!1),S=a||(0,c.wG)(e),$=t||"llm",P=(0,n.useCallback)(async()=>{try{let[e,t]=await Promise.all([fetch("/api/models/alias"),fetch("/api/models/custom",{cache:"no-store"})]),a=await e.json(),s=await t.json();e.ok&&d(a.aliases||{}),t.ok&&u(s.models||[])}catch(e){console.log("ModelsCard fetch error:",e)}},[]);(0,n.useEffect)(()=>{P()},[P]);let _=async(e,t)=>{let a=`${S}/${e}`;try{(await fetch("/api/models/alias",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({model:a,alias:t})})).ok&&await P()}catch(e){console.log("set alias error:",e)}},I=async e=>{try{(await fetch(`/api/models/alias?alias=${encodeURIComponent(e)}`,{method:"DELETE"})).ok&&await P()}catch(e){console.log("delete alias error:",e)}},A=async e=>{try{(await fetch("/api/models/custom",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({providerAlias:S,id:e,type:$})})).ok&&(await P(),window.dispatchEvent(new CustomEvent("customModelChanged")))}catch(e){console.log("add custom model error:",e)}},E=async e=>{try{let t=new URLSearchParams({providerAlias:S,id:e,type:$});(await fetch(`/api/models/custom?${t}`,{method:"DELETE"})).ok&&(await P(),window.dispatchEvent(new CustomEvent("customModelChanged")))}catch(e){console.log("delete custom model error:",e)}},T=async e=>{if(!h){v(e);try{let a=await fetch("/api/models/test",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({model:`${S}/${e}`,kind:t})}),s=await a.json();p(t=>({...t,[e]:s.ok?"ok":"error"})),N(s.ok?"":s.error||"Model not reachable")}catch{p(t=>({...t,[e]:"error"})),N("Network error")}finally{v(null)}}},B=(0,b.KC)(e),M=t?B.filter(e=>e.kinds?e.kinds.includes(t):(0,b.CP)(e,"llm")===t):B,O=m.filter(e=>e.providerAlias===S&&(0,b.CP)(e,"llm")===$&&!M.some(t=>t.id===e.id));return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)(i.Card,{children:[(0,s.jsx)("div",{className:"flex items-center justify-between mb-4",children:(0,s.jsxs)("h2",{className:"text-lg font-semibold",children:["Models",t?` — ${t.toUpperCase()}`:""]})}),w&&(0,s.jsx)("p",{className:"text-xs text-red-500 mb-3 break-words",children:w}),(0,s.jsxs)("div",{className:"flex flex-wrap gap-3",children:[M.map(e=>{let t=`${S}/${e.id}`,a=Object.entries(o).find(([,e])=>e===t)?.[0];return(0,s.jsx)(f,{model:e,fullModel:`${S}/${e.id}`,alias:a,copied:r,onCopy:l,onSetAlias:t=>_(e.id,t),onDeleteAlias:()=>I(a),testStatus:x[e.id],onTest:()=>T(e.id),isTesting:h===e.id,isFree:e.isFree},e.id)}),O.map(e=>(0,s.jsx)(f,{model:{id:e.id,name:e.name},fullModel:`${S}/${e.id}`,copied:r,onCopy:l,onSetAlias:()=>{},onDeleteAlias:()=>E(e.id),testStatus:x[e.id],onTest:()=>T(e.id),isTesting:h===e.id,isCustom:!0},`${e.id}-${e.type}`)),(0,s.jsxs)("button",{onClick:()=>C(!0),className:"flex items-center gap-1.5 px-3 py-2 rounded-lg border border-dashed border-black/15 dark:border-white/15 text-xs text-text-muted hover:text-primary hover:border-primary/40 transition-colors",children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-sm",children:"add"}),"Add Model"]})]})]}),(0,s.jsx)(y,{isOpen:k,onSave:async e=>{await A(e),C(!1)},onClose:()=>C(!1)})]})}function v({label:e,children:t}){return(0,s.jsxs)("div",{className:"flex min-w-0 flex-col gap-1.5 sm:flex-row sm:items-center sm:gap-3",children:[(0,s.jsx)("span",{className:"w-full text-xs font-medium text-text-muted sm:w-20 sm:shrink-0",children:e}),(0,s.jsx)("div",{className:"w-full min-w-0 flex-1",children:t})]})}let w={webSearch:{inputLabel:"Query",inputPlaceholder:"What is the latest news about AI?",defaultInput:"What is the latest news about AI?",bodyKey:"query",defaultResponse:`{
1
+ (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[182],{2710:(e,t,a)=>{Promise.resolve().then(a.bind(a,64347))},21863:(e,t,a)=>{"use strict";function s(e,t){return!1===e?"default":"active"===t||"success"===t?"success":"error"===t||"expired"===t||"unavailable"===t?"error":"default"}a.d(t,{g:()=>s})},64347:(e,t,a)=>{"use strict";a.r(t),a.d(t,{default:()=>B});var s=a(15102),r=a(93278),l=a(93885),o=a.n(l),n=a(82030),i=a(92940),d=a(31704),c=a(31038),m=a(21863);function u({until:e}){let[t,a]=(0,n.useState)("");return((0,n.useEffect)(()=>{let t=()=>{let t=new Date(e).getTime()-Date.now();if(t<=0)return void a("");let s=Math.floor(t/1e3);s<60?a(`${s}s`):s<3600?a(`${Math.floor(s/60)}m ${s%60}s`):a(`${Math.floor(s/3600)}h ${Math.floor(s%3600/60)}m`)};t();let s=setInterval(t,1e3);return()=>clearInterval(s)},[e]),t)?(0,s.jsxs)("span",{className:"text-xs text-orange-500 font-mono",children:["⏱ ",t]}):null}function x({connection:e,proxyPools:t,isOAuth:a,isFirst:r,isLast:l,onMoveUp:o,onMoveDown:d,onToggleActive:c,onUpdateProxy:p,onEdit:h,onDelete:b}){let[g,f]=(0,n.useState)(!1),[y,j]=(0,n.useState)(!1),[v,w]=(0,n.useState)(!1),N=(0,n.useRef)(null),k=new Map((t||[]).map(e=>[e.id,e])),C=e.providerSpecificData?.proxyPoolId||null,S=C?k.get(C):null,$=e.providerSpecificData?.connectionProxyEnabled===!0&&!!e.providerSpecificData?.connectionProxyUrl,P=!!C||$,_=S?`Pool: ${S.name}`:C?`Pool: ${C} (inactive/missing)`:$?`Legacy: ${e.providerSpecificData?.connectionProxyUrl}`:"",I="",A=S?.proxyUrl||e.providerSpecificData?.connectionProxyUrl;if(A)try{let e=new URL(A);I=`${e.protocol}//${e.hostname}${e.port?`:${e.port}`:""}`}catch{I=A}let E=S?.noProxy||e.providerSpecificData?.connectionNoProxy||"",T=S?.isActive===!0?"success":C||$?"error":"default",B=Object.entries(e).filter(([e])=>e.startsWith("modelLock_")).map(([,e])=>e).filter(Boolean).sort()[0]||null;(0,n.useEffect)(()=>{let t=null,a=()=>{w(!!Object.entries(e).filter(([e])=>e.startsWith("modelLock_")).map(([,e])=>e).filter(e=>e&&new Date(e).getTime()>Date.now()).sort()[0])};return a(),B&&(t=setInterval(a,1e3)),()=>{t&&clearInterval(t)}},[B,e]),(0,n.useEffect)(()=>{if(!g)return;let e=e=>{N.current&&!N.current.contains(e.target)&&f(!1)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[g]);let M="unavailable"!==e.testStatus||v?e.testStatus:"active",O=a?e.name||e.email||e.displayName||"OAuth Account":e.name,K=async e=>{j(!0);try{await p("__none__"===e?null:e)}finally{j(!1),f(!1)}};return(0,s.jsxs)("div",{className:`group flex flex-col gap-3 p-2 rounded-lg sm:flex-row sm:items-center sm:justify-between hover:bg-black/[0.02] dark:hover:bg-white/[0.02] transition-colors ${!1===e.isActive?"opacity-60":""}`,children:[(0,s.jsxs)("div",{className:"flex w-full min-w-0 flex-1 items-start gap-3 sm:items-center",children:[(0,s.jsxs)("div",{className:"flex flex-col",children:[(0,s.jsx)("button",{onClick:o,disabled:r,className:`p-0.5 rounded ${r?"text-text-muted/30 cursor-not-allowed":"hover:bg-sidebar text-text-muted hover:text-primary"}`,children:(0,s.jsx)("span",{className:"material-symbols-outlined text-sm",children:"keyboard_arrow_up"})}),(0,s.jsx)("button",{onClick:d,disabled:l,className:`p-0.5 rounded ${l?"text-text-muted/30 cursor-not-allowed":"hover:bg-sidebar text-text-muted hover:text-primary"}`,children:(0,s.jsx)("span",{className:"material-symbols-outlined text-sm",children:"keyboard_arrow_down"})})]}),(0,s.jsx)("span",{className:"material-symbols-outlined text-base text-text-muted",children:a?"lock":"key"}),(0,s.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,s.jsx)("p",{className:"text-sm font-medium truncate",children:O}),(0,s.jsxs)("div",{className:"flex flex-wrap items-center gap-2 mt-1",children:[(0,s.jsx)(i.Badge,{variant:(0,m.g)(e.isActive,M),size:"sm",dot:!0,children:!1===e.isActive?"disabled":M||"Unknown"}),P&&(0,s.jsx)(i.Badge,{variant:T,size:"sm",children:"Proxy"}),v&&!1!==e.isActive&&(0,s.jsx)(u,{until:B}),e.lastError&&!1!==e.isActive&&(0,s.jsx)("span",{className:"text-xs text-red-500 truncate max-w-[300px]",title:e.lastError,children:e.lastError}),(0,s.jsxs)("span",{className:"text-xs text-text-muted",children:["#",e.priority]})]}),P&&(0,s.jsxs)("div",{className:"mt-1 flex flex-wrap items-center gap-2",children:[(0,s.jsx)("span",{className:"text-[11px] text-text-muted truncate max-w-[420px]",title:_,children:_}),I&&(0,s.jsx)("code",{className:"text-[10px] font-mono bg-black/5 dark:bg-white/5 px-1 py-0.5 rounded text-text-muted",children:I}),E&&(0,s.jsxs)("span",{className:"text-[11px] text-text-muted truncate max-w-[320px]",title:E,children:["no_proxy: ",E]})]})]})]}),(0,s.jsxs)("div",{className:"flex w-full flex-wrap items-center justify-between gap-2 sm:w-auto sm:justify-end",children:[(0,s.jsxs)("div",{className:"flex flex-wrap gap-1",children:[(t||[]).length>0&&(0,s.jsxs)("div",{className:"relative",ref:N,children:[(0,s.jsxs)("button",{onClick:()=>f(e=>!e),className:`flex flex-col items-center px-2 py-1 rounded hover:bg-black/5 dark:hover:bg-white/5 transition-colors ${P?"text-primary":"text-text-muted hover:text-primary"}`,disabled:y,children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:y?"progress_activity":"lan"}),(0,s.jsx)("span",{className:"text-[10px] leading-tight",children:"Proxy"})]}),g&&(0,s.jsxs)("div",{className:"absolute right-0 top-full mt-1 z-50 bg-bg border border-border rounded-lg shadow-lg py-1 min-w-[160px]",children:[(0,s.jsx)("button",{onClick:()=>K("__none__"),className:`w-full text-left px-3 py-1.5 text-sm hover:bg-black/5 dark:hover:bg-white/5 ${!C?"text-primary font-medium":"text-text-main"}`,children:"None"}),(t||[]).map(e=>(0,s.jsx)("button",{onClick:()=>K(e.id),className:`w-full text-left px-3 py-1.5 text-sm hover:bg-black/5 dark:hover:bg-white/5 ${C===e.id?"text-primary font-medium":"text-text-main"}`,children:e.name},e.id))]})]}),(0,s.jsxs)("button",{onClick:h,className:"flex flex-col items-center px-2 py-1 rounded hover:bg-black/5 dark:hover:bg-white/5 text-text-muted hover:text-primary",children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:"edit"}),(0,s.jsx)("span",{className:"text-[10px] leading-tight",children:"Edit"})]}),(0,s.jsxs)("button",{onClick:b,className:"flex flex-col items-center px-2 py-1 rounded hover:bg-red-500/10 text-red-500",children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:"delete"}),(0,s.jsx)("span",{className:"text-[10px] leading-tight",children:"Delete"})]})]}),(0,s.jsx)(i.Toggle,{size:"sm",checked:e.isActive??!0,onChange:c,title:e.isActive??!0?"Disable":"Enable"})]})]})}function p({isOpen:e,provider:t,providerName:a,proxyPools:r,onSave:l,onClose:o}){let d="__none__",[c,m]=(0,n.useState)({name:"",apiKey:"",priority:1,proxyPoolId:d}),[u,x]=(0,n.useState)(!1),[h,b]=(0,n.useState)(null),[g,f]=(0,n.useState)(!1),y=async()=>{x(!0);try{let e=await fetch("/api/providers/validate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:t,apiKey:c.apiKey})}),a=await e.json();b(a.valid?"success":"failed")}catch{b("failed")}finally{x(!1)}},j=async()=>{if(t&&c.apiKey){f(!0);try{let e=!1;try{x(!0),b(null);let a=await fetch("/api/providers/validate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:t,apiKey:c.apiKey})});e=!!(await a.json()).valid,b(e?"success":"failed")}catch{b("failed")}finally{x(!1)}await l({name:c.name,apiKey:c.apiKey,priority:c.priority,proxyPoolId:c.proxyPoolId===d?null:c.proxyPoolId,testStatus:e?"active":"unknown"})}finally{f(!1)}}};return t?(0,s.jsx)(i.Modal,{isOpen:e,title:`Add ${a||t} API Key`,onClose:o,children:(0,s.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{className:"text-xs text-text-muted mb-1 block",children:"Name"}),(0,s.jsx)("input",{className:"w-full px-3 py-2 text-sm border border-border rounded-lg bg-background focus:outline-none focus:border-primary",value:c.name,onChange:e=>m({...c,name:e.target.value}),placeholder:"Production Key"})]}),(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsxs)("div",{className:"flex-1",children:[(0,s.jsx)("label",{className:"text-xs text-text-muted mb-1 block",children:"API Key"}),(0,s.jsx)("input",{type:"password",className:"w-full px-3 py-2 text-sm border border-border rounded-lg bg-background focus:outline-none focus:border-primary",value:c.apiKey,onChange:e=>m({...c,apiKey:e.target.value})})]}),(0,s.jsx)("div",{className:"pt-6",children:(0,s.jsx)(i.Button,{onClick:y,disabled:!c.apiKey||u||g,variant:"secondary",children:u?"Checking...":"Check"})})]}),h&&(0,s.jsx)(i.Badge,{variant:"success"===h?"success":"error",children:"success"===h?"Valid":"Invalid"}),(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{className:"text-xs text-text-muted mb-1 block",children:"Priority"}),(0,s.jsx)("input",{type:"number",className:"w-full px-3 py-2 text-sm border border-border rounded-lg bg-background focus:outline-none focus:border-primary",value:c.priority,onChange:e=>m({...c,priority:Number.parseInt(e.target.value)||1})})]}),(0,s.jsx)(i.Select,{label:"Proxy Pool",value:c.proxyPoolId,onChange:e=>m({...c,proxyPoolId:e.target.value}),options:[{value:d,label:"None"},...(r||[]).map(e=>({value:e.id,label:e.name}))]}),(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsx)(i.Button,{onClick:j,fullWidth:!0,disabled:!c.name||!c.apiKey||g,children:g?"Saving...":"Save"}),(0,s.jsx)(i.Button,{onClick:o,variant:"ghost",fullWidth:!0,children:"Cancel"})]})]})}):null}function h({providerId:e,isOAuth:t}){let[a,r]=(0,n.useState)([]),[l,o]=(0,n.useState)([]),[d,c]=(0,n.useState)(!0),[m,u]=(0,n.useState)(!1),[b,g]=(0,n.useState)(!1),[f,y]=(0,n.useState)(null),[j,v]=(0,n.useState)(null),[w,N]=(0,n.useState)("1"),[k,C]=(0,n.useState)(null),S=(0,n.useCallback)(async()=>{try{let[t,a,s]=await Promise.all([fetch("/api/providers",{cache:"no-store"}),fetch("/api/proxy-pools?isActive=true",{cache:"no-store"}),fetch("/api/settings",{cache:"no-store"})]),l=await t.json(),n=await a.json(),i=s.ok?await s.json():{};t.ok&&r((l.connections||[]).filter(t=>t.provider===e)),a.ok&&o(n.proxyPools||[]);let d=(i.providerStrategies||{})[e]||{};v(d.fallbackStrategy||null),N(null!=d.stickyRoundRobinLimit?String(d.stickyRoundRobinLimit):"1")}catch(e){console.log("ConnectionsCard fetch error:",e)}finally{c(!1)}},[e]);(0,n.useEffect)(()=>{S()},[S]);let $=async(t,a)=>{try{let s=await fetch("/api/settings",{cache:"no-store"}),r=(s.ok?await s.json():{}).providerStrategies||{},l={};t&&(l.fallbackStrategy=t),"round-robin"===t&&""!==a&&(l.stickyRoundRobinLimit=Number(a)||3);let o={...r};0===Object.keys(l).length?delete o[e]:o[e]=l,await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({providerStrategies:o})})}catch(e){console.log("saveStrategy error:",e)}},P=async(e,t)=>{let s=[...a];[s[e],s[t]]=[s[t],s[e]],r(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{await S()}},_=async e=>{C({title:"Delete Connection",message:"Delete this connection?",onConfirm:async()=>{C(null);try{(await fetch(`/api/providers/${e}`,{method:"DELETE"})).ok&&r(t=>t.filter(t=>t.id!==e))}catch(e){console.log("delete error:",e)}}})},I=async(e,t)=>{try{(await fetch(`/api/providers/${e}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({isActive:t})})).ok&&r(a=>a.map(a=>a.id===e?{...a,isActive:t}:a))}catch(e){console.log("toggle error:",e)}},A=async(e,t)=>{try{(await fetch(`/api/providers/${e}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({proxyPoolId:t||null})})).ok&&r(a=>a.map(a=>a.id===e?{...a,providerSpecificData:{...a.providerSpecificData,proxyPoolId:t||null}}:a))}catch(e){console.log("proxy error:",e)}},E=async t=>{try{(await fetch("/api/providers",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:e,...t})})).ok&&(await S(),u(!1))}catch(e){console.log("save apikey error:",e)}},T=async e=>{try{(await fetch(`/api/providers/${f.id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})).ok&&(await S(),g(!1))}catch(e){console.log("update connection error:",e)}};return d?(0,s.jsx)(i.Card,{children:(0,s.jsx)("div",{className:"h-20 animate-pulse bg-black/5 rounded-lg"})}):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)(i.Card,{children:[(0,s.jsxs)("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between mb-4",children:[(0,s.jsx)("h2",{className:"text-lg font-semibold",children:"Connections"}),(0,s.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,s.jsx)("span",{className:"text-xs text-text-muted font-medium",children:"Round Robin"}),(0,s.jsx)(i.Toggle,{checked:"round-robin"===j,onChange:e=>{let t=e?"round-robin":null;v(t),e&&!w&&N("1"),$(t,e?w||"1":w)}}),"round-robin"===j&&(0,s.jsxs)("div",{className:"flex flex-wrap items-center gap-1.5",children:[(0,s.jsx)("span",{className:"text-xs text-text-muted",children:"Sticky:"}),(0,s.jsx)("input",{type:"number",min:1,value:w,onChange:e=>{N(e.target.value),$("round-robin",e.target.value)},className:"w-16 px-2 py-1 text-xs border border-border rounded-md bg-background focus:outline-none focus:border-primary"})]})]})]}),0===a.length?(0,s.jsxs)("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[(0,s.jsx)("p",{className:"text-sm text-text-muted",children:"No connections yet"}),(0,s.jsx)(i.Button,{size:"sm",icon:"add",onClick:()=>u(!0),children:"Add Connection"})]}):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("div",{className:"flex flex-col divide-y divide-black/[0.03] dark:divide-white/[0.03]",children:a.map((e,r)=>(0,s.jsx)(x,{connection:e,proxyPools:l,isOAuth:t,isFirst:0===r,isLast:r===a.length-1,onMoveUp:()=>P(r,r-1),onMoveDown:()=>P(r,r+1),onToggleActive:t=>I(e.id,t),onUpdateProxy:t=>A(e.id,t),onEdit:()=>{y(e),g(!0)},onDelete:()=>_(e.id)},e.id))}),(0,s.jsx)("div",{className:"mt-4 flex justify-stretch sm:justify-start",children:(0,s.jsx)(i.Button,{size:"sm",icon:"add",onClick:()=>u(!0),children:"Add"})})]})]}),(0,s.jsx)(p,{isOpen:m,provider:e,proxyPools:l,onSave:E,onClose:()=>u(!1)}),(0,s.jsx)(i.EditConnectionModal,{isOpen:b,connection:f,proxyPools:l,onSave:T,onClose:()=>g(!1)}),(0,s.jsx)(i.ConfirmModal,{isOpen:!!k,onClose:()=>C(null),onConfirm:k?.onConfirm,title:k?.title||"Confirm",message:k?.message,variant:"danger"})]})}var b=a(55223),g=a(21577);function f({model:e,fullModel:t,copied:a,onCopy:r,testStatus:l,isCustom:o,isFree:n,onDeleteAlias:i,onTest:d,isTesting:c}){let m="ok"===l?"#22c55e":"error"===l?"#ef4444":void 0;return(0,s.jsx)("div",{className:`group px-3 py-2 rounded-lg border ${"ok"===l?"border-green-500/40":"error"===l?"border-red-500/40":"border-border"} hover:bg-sidebar/50`,children:(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-base",style:m?{color:m}:void 0,children:"ok"===l?"check_circle":"error"===l?"cancel":"smart_toy"}),(0,s.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,s.jsx)("code",{className:"text-xs text-text-muted font-mono bg-sidebar px-1.5 py-0.5 rounded",children:t}),e.name&&(0,s.jsx)("span",{className:"text-[9px] text-text-muted/70 italic pl-1",children:e.name})]}),d&&(0,s.jsxs)("div",{className:"relative group/btn",children:[(0,s.jsx)("button",{onClick:d,disabled:c,className:`p-0.5 hover:bg-sidebar rounded text-text-muted hover:text-primary transition-opacity ${c?"opacity-100":"opacity-0 group-hover:opacity-100"}`,children:(0,s.jsx)("span",{className:"material-symbols-outlined text-sm",style:c?{animation:"spin 1s linear infinite"}:void 0,children:c?"progress_activity":"science"})}),(0,s.jsx)("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:c?"Testing...":"Test"})]}),(0,s.jsxs)("div",{className:"relative group/btn",children:[(0,s.jsx)("button",{onClick:()=>r(t,`model-${e.id}`),className:"p-0.5 hover:bg-sidebar rounded text-text-muted hover:text-primary",children:(0,s.jsx)("span",{className:"material-symbols-outlined text-sm",children:a===`model-${e.id}`?"check":"content_copy"})}),(0,s.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:a===`model-${e.id}`?"Copied!":"Copy"})]}),n&&(0,s.jsx)("span",{className:"text-[10px] font-bold text-green-500 bg-green-500/10 px-1.5 py-0.5 rounded",children:"FREE"}),o&&(0,s.jsx)("button",{onClick:i,className:"p-0.5 hover:bg-red-500/10 rounded text-text-muted hover:text-red-500 opacity-0 group-hover:opacity-100 transition-opacity ml-auto",title:"Remove custom model",children:(0,s.jsx)("span",{className:"material-symbols-outlined text-sm",children:"close"})})]})})}function y({isOpen:e,onSave:t,onClose:a}){let[r,l]=(0,n.useState)(""),o=()=>{r.trim()&&(t(r.trim()),l(""))};return(0,s.jsx)(i.Modal,{isOpen:e,title:"Add Custom Model",onClose:a,children:(0,s.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{className:"text-xs text-text-muted mb-1 block",children:"Model ID"}),(0,s.jsx)("input",{className:"w-full px-3 py-2 text-sm border border-border rounded-lg bg-background focus:outline-none focus:border-primary",value:r,onChange:e=>l(e.target.value),onKeyDown:e=>"Enter"===e.key&&o(),placeholder:"e.g. tts-1-hd",autoFocus:!0})]}),(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsx)(i.Button,{onClick:o,fullWidth:!0,disabled:!r.trim(),children:"Add"}),(0,s.jsx)(i.Button,{onClick:a,variant:"ghost",fullWidth:!0,children:"Cancel"})]})]})})}function j({providerId:e,kindFilter:t,providerAliasOverride:a}){let{copied:r,copy:l}=(0,g.C)(),[o,d]=(0,n.useState)({}),[m,u]=(0,n.useState)([]),[x,p]=(0,n.useState)({}),[h,v]=(0,n.useState)(null),[w,N]=(0,n.useState)(""),[k,C]=(0,n.useState)(!1),S=a||(0,c.wG)(e),$=t||"llm",P=(0,n.useCallback)(async()=>{try{let[e,t]=await Promise.all([fetch("/api/models/alias"),fetch("/api/models/custom",{cache:"no-store"})]),a=await e.json(),s=await t.json();e.ok&&d(a.aliases||{}),t.ok&&u(s.models||[])}catch(e){console.log("ModelsCard fetch error:",e)}},[]);(0,n.useEffect)(()=>{P()},[P]);let _=async(e,t)=>{let a=`${S}/${e}`;try{(await fetch("/api/models/alias",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({model:a,alias:t})})).ok&&await P()}catch(e){console.log("set alias error:",e)}},I=async e=>{try{(await fetch(`/api/models/alias?alias=${encodeURIComponent(e)}`,{method:"DELETE"})).ok&&await P()}catch(e){console.log("delete alias error:",e)}},A=async e=>{try{(await fetch("/api/models/custom",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({providerAlias:S,id:e,type:$})})).ok&&(await P(),window.dispatchEvent(new CustomEvent("customModelChanged")))}catch(e){console.log("add custom model error:",e)}},E=async e=>{try{let t=new URLSearchParams({providerAlias:S,id:e,type:$});(await fetch(`/api/models/custom?${t}`,{method:"DELETE"})).ok&&(await P(),window.dispatchEvent(new CustomEvent("customModelChanged")))}catch(e){console.log("delete custom model error:",e)}},T=async e=>{if(!h){v(e);try{let a=await fetch("/api/models/test",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({model:`${S}/${e}`,kind:t})}),s=await a.json();p(t=>({...t,[e]:s.ok?"ok":"error"})),N(s.ok?"":s.error||"Model not reachable")}catch{p(t=>({...t,[e]:"error"})),N("Network error")}finally{v(null)}}},B=(0,b.KC)(e),M=t?B.filter(e=>e.kinds?e.kinds.includes(t):(0,b.CP)(e,"llm")===t):B,O=m.filter(e=>e.providerAlias===S&&(0,b.CP)(e,"llm")===$&&!M.some(t=>t.id===e.id));return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)(i.Card,{children:[(0,s.jsx)("div",{className:"flex items-center justify-between mb-4",children:(0,s.jsxs)("h2",{className:"text-lg font-semibold",children:["Models",t?` — ${t.toUpperCase()}`:""]})}),w&&(0,s.jsx)("p",{className:"text-xs text-red-500 mb-3 break-words",children:w}),(0,s.jsxs)("div",{className:"flex flex-wrap gap-3",children:[M.map(e=>{let t=`${S}/${e.id}`,a=Object.entries(o).find(([,e])=>e===t)?.[0];return(0,s.jsx)(f,{model:e,fullModel:`${S}/${e.id}`,alias:a,copied:r,onCopy:l,onSetAlias:t=>_(e.id,t),onDeleteAlias:()=>I(a),testStatus:x[e.id],onTest:()=>T(e.id),isTesting:h===e.id,isFree:e.isFree},e.id)}),O.map(e=>(0,s.jsx)(f,{model:{id:e.id,name:e.name},fullModel:`${S}/${e.id}`,copied:r,onCopy:l,onSetAlias:()=>{},onDeleteAlias:()=>E(e.id),testStatus:x[e.id],onTest:()=>T(e.id),isTesting:h===e.id,isCustom:!0},`${e.id}-${e.type}`)),(0,s.jsxs)("button",{onClick:()=>C(!0),className:"flex items-center gap-1.5 px-3 py-2 rounded-lg border border-dashed border-black/15 dark:border-white/15 text-xs text-text-muted hover:text-primary hover:border-primary/40 transition-colors",children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-sm",children:"add"}),"Add Model"]})]})]}),(0,s.jsx)(y,{isOpen:k,onSave:async e=>{await A(e),C(!1)},onClose:()=>C(!1)})]})}function v({label:e,children:t}){return(0,s.jsxs)("div",{className:"flex min-w-0 flex-col gap-1.5 sm:flex-row sm:items-center sm:gap-3",children:[(0,s.jsx)("span",{className:"w-full text-xs font-medium text-text-muted sm:w-20 sm:shrink-0",children:e}),(0,s.jsx)("div",{className:"w-full min-w-0 flex-1",children:t})]})}let w={webSearch:{inputLabel:"Query",inputPlaceholder:"What is the latest news about AI?",defaultInput:"What is the latest news about AI?",bodyKey:"query",defaultResponse:`{
2
2
  "results": [
3
3
  { "title": "...", "url": "...", "snippet": "..." }
4
4
  ]
@@ -9,4 +9,4 @@ sk-key-only-auto-named`:O,[J,q]=(0,i.useState)("single"),[W,H]=(0,i.useState)(""
9
9
  "idToken": "eyJhbGc...",
10
10
  "email": "user@example.com"
11
11
  }
12
- ]`;function R({isOpen:e,onClose:t,onSuccess:a}){let[l,r]=(0,i.useState)(""),[o,n]=(0,i.useState)(!1),[c,m]=(0,i.useState)(""),[p,x]=(0,i.useState)(null),u=()=>{o||(r(""),m(""),x(null),t())},h=async()=>{var e;let t;m(""),x(null);let s=l.trim();if(!s)return;try{t=JSON.parse(s)}catch(e){m(`${(0,j.Tl)("Invalid JSON")}: ${e.message}`);return}let i=Array.isArray(e=t)?e:e&&"object"==typeof e?Array.isArray(e.accounts)?e.accounts:[e]:null;if(!i||0===i.length)return void m((0,j.Tl)("No accounts found in input"));n(!0);try{let e=await fetch("/api/oauth/codex/bulk-import",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({accounts:i})}),t=await e.json();if(!e.ok)return void m(t?.error||`Request failed: ${e.status}`);x(t),t.success>0&&"function"==typeof a&&a()}catch(e){m(e.message||(0,j.Tl)("Request failed"))}finally{n(!1)}},f=p?.results?.filter(e=>!e.ok)||[];return(0,s.jsx)(d.Modal,{isOpen:e,title:(0,j.Tl)("Bulk Add Codex Accounts"),onClose:u,children:(0,s.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,s.jsx)("p",{className:"text-xs text-text-muted",children:(0,j.Tl)("Paste an array of codex account JSON objects. Each must include accessToken (and ideally refreshToken, idToken).")}),(0,s.jsx)("textarea",{className:"w-full rounded border border-accent/30 bg-sidebar p-2 text-sm font-mono resize-y min-h-[240px] focus:outline-none focus:ring-1 focus:ring-primary",placeholder:B,value:l,onChange:e=>r(e.target.value),disabled:o}),c&&(0,s.jsx)("p",{className:"text-xs text-red-500 break-words",children:c}),p&&(0,s.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,s.jsxs)("div",{className:`text-sm font-medium ${p.failed>0?"text-yellow-400":"text-green-400"}`,children:["✓ ",p.success," ",(0,j.Tl)("added"),p.failed>0?`, ✗ ${p.failed} ${(0,j.Tl)("failed")}`:""]}),f.length>0&&(0,s.jsx)("ul",{className:"rounded border border-accent/20 bg-sidebar/50 p-2 text-xs font-mono max-h-40 overflow-y-auto",children:f.map(e=>(0,s.jsxs)("li",{className:"text-red-400",children:["[",e.index,"] ",e.error]},e.index))})]}),(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsx)(d.Button,{onClick:h,fullWidth:!0,disabled:o||!l.trim(),children:o?(0,j.Tl)("Importing..."):(0,j.Tl)("Import All")}),(0,s.jsx)(d.Button,{onClick:u,variant:"ghost",fullWidth:!0,disabled:o,children:(0,j.Tl)("Close")})]})]})})}let K={claude:"claudeAutoPing",codex:"codexAutoPing"};function L(){let e,t,a,r,p=(0,l.useParams)(),x=(0,l.useRouter)(),u=p.id,{getCaps:h}=(0,v.y)(),[f,g]=(0,i.useState)([]),[w,C]=(0,i.useState)(!0),[T,I]=(0,i.useState)(null),[$,E]=(0,i.useState)([]),[O,_]=(0,i.useState)(!1),[M,B]=(0,i.useState)(!1),[L,F]=(0,i.useState)(!1),[J,q]=(0,i.useState)(""),[W,H]=(0,i.useState)(!1),[V,G]=(0,i.useState)(!1),[Q,X]=(0,i.useState)(!1),[Y,Z]=(0,i.useState)(!1),[ee,et]=(0,i.useState)(null),[ea,es]=(0,i.useState)({}),[ei,el]=(0,i.useState)([]),[er,eo]=(0,i.useState)(!1),[en,ed]=(0,i.useState)({}),[ec,em]=(0,i.useState)(""),[ep,ex]=(0,i.useState)(()=>new Set),[eu,eh]=(0,i.useState)(!1),[ef,eg]=(0,i.useState)([]),[ey,eb]=(0,i.useState)(1),[ev,ej]=(0,i.useState)("__none__"),[ew,eN]=(0,i.useState)(!1),[ek,eS]=(0,i.useState)(null),[eC,eA]=(0,i.useState)(""),[eT,eI]=(0,i.useState)(!1),[eP,e$]=(0,i.useState)("auto"),[eE,eO]=(0,i.useState)({enabled:!1,connections:{}}),[eD,e_]=(0,i.useState)([]),[eU,eM]=(0,i.useState)([]),[ez,eB]=(0,i.useState)([]),[eR,eK]=(0,i.useState)([]),[eL,eF]=(0,i.useState)(null),[eJ,eq]=(0,i.useState)(!1),[eW,eH]=(0,i.useState)(!1),[eV,eG]=(0,i.useState)(!1),[eQ,eX]=(0,i.useState)(null),[eY,eZ]=(0,i.useState)({}),[e0,e1]=(0,i.useState)(null),e2=(0,i.useRef)(!1),[e5,e3]=(0,i.useState)(!1),{copied:e4,copy:e6}=(0,b.C)(),e8="ag_risk_confirmed",e7=()=>{_(!0)},e9=()=>{"antigravity"===u&&"true"!==window.localStorage.getItem(e8)?eq(!0):ti?e7():(q(""),F(!0))},te=()=>{q(""),F(!0)},tt=()=>{ti?e9():te()},ta=T?{id:T.id,name:T.name||("anthropic-compatible"===T.type?"Anthropic Compatible":"OpenAI Compatible"),color:"anthropic-compatible"===T.type?"#D97757":"#10A37F",textIcon:"anthropic-compatible"===T.type?"AC":"OC",apiType:T.apiType,baseUrl:T.baseUrl,type:T.type}:c.zN[u]||c.fg[u]||c.IS[u]||c.nJ[u]||c.br[u],ts=ta?.authModes||[],ti=!!c.zN[u]||!!c.IS[u]||ts.includes("oauth"),tl=!!c.fg[u]||ts.includes("apikey"),tr=!!c.IS[u]?.noAuth,to=(0,m.KC)(u),tn="cursor"===u&&eU.length>0?eU:to,td=(0,c.wG)(u),tc=(0,c.mq)(u),tm=(0,c.gb)(u),tp=tc||tm,tx=!tp&&ti&&tl,tu="xai"===u?"Grok Build OAuth":"grok-cli"===u?"Grok CLI Device Login":"kimi"===u?"Kimi Coding OAuth":"OAuth",th="xai"===u?"xAI API Key":"kimi"===u?"Kimi API Key":"qoder"===u?"PAT":"API Key",tf=e=>{if(!eP||"auto"===eP)return null;let t=y(u,e);return t&&t.includes(eP)?eP:null},tg=tp?u:td,ty=(e=new Map,t=t=>{t?.id&&!e.has(t.id)&&e.set(t.id,t)},tn.forEach(t),ei.forEach(e=>{e.providerAlias===tg&&"llm"===(e.kind||e.type||"llm")&&t(e)}),a=new Set(eR),[...e.values()].filter(e=>!a.has(e.id))),tb=(()=>{let e=new Set,t=new Set,a=a=>{if(!a||t.has(a))return;t.add(a);let s=y(u,a);s&&s.forEach(t=>{"none"!==t&&e.add(t)})};for(let e of tn)a(e.id);for(let e of ez)a(e.id);for(let e of ei)e.providerAlias===tg&&"llm"===(e.kind||e.type||"llm")&&a(e.id);return e.size?["auto",...e]:null})(),tv=tp?T?.prefix||u:td,tj=(0,i.useCallback)(async()=>{try{let e=await fetch(`/api/models/disabled?providerAlias=${encodeURIComponent(tg)}`,{cache:"no-store"}),t=await e.json();e.ok&&eK(t.ids||[])}catch(e){console.log("Error fetching disabled models:",e)}},[tg]),tw=async e=>{try{(await fetch("/api/models/disabled",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({providerAlias:tg,ids:[e]})})).ok&&await tj()}catch(e){console.log("Error disabling model:",e)}},tN=async e=>{try{(await fetch(`/api/models/disabled?providerAlias=${encodeURIComponent(tg)}&id=${encodeURIComponent(e)}`,{method:"DELETE"})).ok&&await tj()}catch(e){console.log("Error enabling model:",e)}},tk=async e=>{e.length&&eF({title:"Disable All Models",message:`Disable all ${e.length} model(s)?`,onConfirm:async()=>{eF(null);try{(await fetch("/api/models/disabled",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({providerAlias:tg,ids:e})})).ok&&await tj()}catch(e){console.log("Error disabling all models:",e)}}})},tS=async()=>{try{(await fetch(`/api/models/disabled?providerAlias=${encodeURIComponent(tg)}`,{method:"DELETE"})).ok&&await tj()}catch(e){console.log("Error enabling all models:",e)}},tC=(0,i.useCallback)(async()=>{try{let e=await fetch("/api/models/alias"),t=await e.json();e.ok&&es(t.aliases||{})}catch(e){console.log("Error fetching aliases:",e)}},[]),tA=(0,i.useCallback)(async()=>{try{let e=await fetch("/api/models/custom",{cache:"no-store"}),t=await e.json();e.ok&&el(t.models||[])}catch(e){console.log("Error fetching custom models:",e)}},[]);(0,i.useEffect)(()=>{"kilocode"===u&&fetch("/api/providers/kilo/free-models").then(e=>e.json()).then(e=>{e.models?.length&&eB(e.models)}).catch(()=>{})},[u]);let tT=(0,i.useCallback)(async()=>{try{let[e,t,a,s]=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(),r=await a.json(),o=s.ok?await s.json():{};if(e.ok){let e=(i.connections||[]).filter(e=>e.provider===u);g(e)}a.ok&&E(r.proxyPools||[]);let n=(o.providerStrategies||{})[u]||{};eS(n.fallbackStrategy||null),eA(null!=n.stickyRoundRobinLimit?String(n.stickyRoundRobinLimit):"1"),eI(!0===n.strictModelAssignment);let d=(o.providerThinking||{})[u]||{};e$(d.mode||"auto");let c=K[u],m=c&&o[c]||{};if(eO({enabled:!0===m.enabled,connections:m.connections||{}}),t.ok){let e=(l.nodes||[]).find(e=>e.id===u)||null;if(!e&&tp)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===u)||null))break}I(e)}}catch(e){console.log("Error fetching connections:",e)}finally{C(!1)}},[u,tp]),tI=async e=>{try{let t=await fetch(`/api/provider-nodes/${u}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}),a=await t.json();t.ok&&(I(a.node),await tT(),X(!1))}catch(e){console.log("Error updating provider node:",e)}},tP=async(e,t)=>{try{let a=await fetch("/api/settings",{cache:"no-store"}),s=(a.ok?await a.json():{}).providerStrategies||{},i={...s[u]||{}};e?i.fallbackStrategy=e:(delete i.fallbackStrategy,delete i.stickyRoundRobinLimit),"round-robin"===e&&""!==t&&(i.stickyRoundRobinLimit=Number(t)||3);let l={...s};0===Object.keys(i).length?delete l[u]:l[u]=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)}},t$=async e=>{eI(e);try{let t=await fetch("/api/settings",{cache:"no-store"}),a=(t.ok?await t.json():{}).providerStrategies||{};await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({providerStrategies:{...a,[u]:{...a[u]||{},strictModelAssignment:e}}})})}catch(e){console.log("Error saving Freebuff strict assignment:",e)}},tE=async(e,t)=>{try{(await fetch(`/api/providers/${e}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({providerSpecificData:{assignedModel:t||null}})})).ok&&g(a=>a.map(a=>a.id===e?{...a,providerSpecificData:{...a.providerSpecificData||{},assignedModel:t||null}}:a))}catch(e){console.log("Error saving Freebuff model assignment:",e)}},tO=async e=>{try{let t=await fetch("/api/settings",{cache:"no-store"}),a={...(t.ok?await t.json():{}).providerThinking||{}};e&&"auto"!==e?a[u]={mode:e}:delete a[u],await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({providerThinking:a})})}catch(e){console.log("Error saving thinking config:",e)}},tD=async e=>{let t=K[u];if(t){eO(e);try{await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({[t]:e})})}catch(e){console.log("Error saving auto-ping config:",e)}}};(0,i.useEffect)(()=>{tT(),tC(),tA(),tj()},[tT,tC,tA,tj]),(0,i.useEffect)(()=>{if("cursor"!==u)return void eM([]);let e=f.find(e=>!1!==e.isActive);if(!e?.id)return void eM([]);let t=!1;return fetch(`/api/providers/${e.id}/models`,{cache:"no-store"}).then(async e=>({ok:e.ok,data:await e.json()})).then(({ok:e,data:a})=>{!t&&e&&Array.isArray(a.models)&&a.models.length>0&&eM(a.models)}).catch(()=>{}),()=>{t=!0}},[u,f]),(0,i.useEffect)(()=>{let e=(c.zN[u]||c.fg[u]||c.IS[u]||c.nJ[u])?.modelsFetcher;e&&N(e).then(e_)},[u]);let t_=async(e,t,a=td)=>{let s=`${a}/${e}`;try{let e=await fetch("/api/models/alias",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({model:s,alias:t})});if(e.ok)await tC();else{let t=await e.json();alert(t.error||"Failed to set alias")}}catch(e){console.log("Error setting alias:",e)}},tU=async e=>{try{(await fetch(`/api/models/alias?alias=${encodeURIComponent(e)}`,{method:"DELETE"})).ok&&await tC()}catch(e){console.log("Error deleting alias:",e)}},tM=async(e,t="llm",a=tg)=>{try{let s=await fetch("/api/models/custom",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({providerAlias:a,id:e,type:t})});if(s.ok)await tA(),window.dispatchEvent(new CustomEvent("customModelChanged"));else{let e=await s.json();alert(e.error||"Failed to add custom model")}}catch(e){console.log("Error adding custom model:",e)}},tz=async(e,t="llm",a=tg)=>{try{let s=new URLSearchParams({providerAlias:a,id:e,type:t});(await fetch(`/api/models/custom?${s}`,{method:"DELETE"})).ok&&(await tA(),window.dispatchEvent(new CustomEvent("customModelChanged")))}catch(e){console.log("Error deleting custom model:",e)}},tB=async()=>{if(e5)return;let e=f.find(e=>!1!==e.isActive);if(!e)return void alert((0,j.Tl)("Please add an active Qoder connection first"));e3(!0);try{let t=await fetch(`/api/providers/${e.id}/models`),a=await t.json();if(!t.ok)return void alert(a.error||(0,j.Tl)("Failed to fetch models"));let s=a.models||[];if(0===s.length)return void alert((0,j.Tl)("No models returned"));let i=0;for(let e of s){let t=e.id||e.name;if(!t)continue;let a=t.replace(/^qoder\//,"");ei.some(e=>e.providerAlias===tg&&e.id===a&&"llm"===(e.kind||e.type||"llm"))||Object.values(ea).includes(`${tg}/${a}`)||(await tM(a,"llm",tg),i+=1)}0===i?alert((0,j.Tl)("All models already exist, no new models added")):alert((0,j.Tl)("Successfully added")+` ${i} `+(0,j.Tl)("models"))}catch(e){console.log("Error importing Qoder models:",e),alert((0,j.Tl)("Error fetching models")+": "+e.message)}finally{e3(!1)}},tR=async()=>{if(eW||0===f.length)return;let e=Object.fromEntries(f.map(e=>[e.id,{state:"queued",error:null}]));e2.current=!1,eH(!0),eG(!1),eX(null),eZ(e),e1({total:f.length,completed:0,passed:0,failed:0,stopped:!1});let t=0,a=0;try{for(let e=0;e<f.length;e+=1){if(e2.current){e1({total:f.length,completed:e,passed:t,failed:a,stopped:!0});break}let s=f[e];eX(s.id),eZ(e=>({...e,[s.id]:{state:"testing",error:null}}));try{let e=await fetch(`/api/providers/${s.id}/test`,{method:"POST"}),i=await e.json(),l=!!i.valid;l?t+=1:a+=1,eZ(e=>({...e,[s.id]:{state:l?"success":"failed",error:l?null:i.error||null}}))}catch(e){a+=1,eZ(t=>({...t,[s.id]:{state:"failed",error:e.message||"Test failed"}}))}e1({total:f.length,completed:e+1,passed:t,failed:a,stopped:!1}),e<f.length-1&&await new Promise(e=>setTimeout(e,1e3))}}finally{eX(null),eH(!1),eG(!1),e2.current=!1}},tK=async e=>{eF({title:"Delete Connection",message:"Delete this connection?",onConfirm:async()=>{eF(null);try{(await fetch(`/api/providers/${e}`,{method:"DELETE"})).ok&&g(t=>t.filter(t=>t.id!==e))}catch(e){console.log("Error deleting connection:",e)}}})},tL=()=>{tT(),_(!1)},tF=async e=>{q("");try{let t=await fetch("/api/providers",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:u,...e})}),a=null;try{a=await t.json()}catch{a=null}if(t.ok){await tT(),F(!1);return}q(a?.error||"Failed to save connection")}catch(e){console.log("Error saving connection:",e),q("Failed to save connection")}},tJ=async e=>{try{(await fetch(`/api/providers/${ee.id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})).ok&&(await tT(),G(!1))}catch(e){console.log("Error updating connection:",e)}},tq=async(e,t)=>{try{(await fetch(`/api/providers/${e}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({isActive:t})})).ok&&g(a=>a.map(a=>a.id===e?{...a,isActive:t}:a))}catch(e){console.log("Error updating connection status:",e)}},tW=async(e,t)=>{let a=[...f];[a[e],a[t]]=[a[t],a[e]],g(a);try{await Promise.all([fetch(`/api/providers/${a[e].id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({priority:e})}),fetch(`/api/providers/${a[t].id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({priority:t})})])}catch(e){console.log("Error swapping priority:",e),await tT()}},tH=f.filter(e=>ef.includes(e.id)),{currentPage:tV,totalPages:tG,items:tQ,start:tX}=function(e=[],t=1){let a=Array.isArray(e)?e:[],s=a.length,i=Math.max(1,Math.ceil(s/10)),l=Math.floor(Number(t)),r=Math.min(Number.isFinite(l)&&l>0?l:1,i),o=(r-1)*10,n=a.slice(o,o+10);return{currentPage:r,totalPages:i,totalItems:s,start:o,items:n,pageSize:10}}(f,ey),tY=f.length>0&&ef.length===f.length;(0,i.useEffect)(()=>{eg(e=>e.filter(e=>f.some(t=>t.id===e)))},[f]);let tZ=(()=>{if(0===tH.length)return"";let e=new Set(tH.map(e=>e.providerSpecificData?.proxyPoolId||"__none__"));if(1===e.size){let t=[...e][0];if("__none__"===t)return"All selected currently unbound";let a=$.find(e=>e.id===t);return`All selected currently bound to ${a?.name||t}`}return"Selected connections have mixed proxy bindings"})(),t0=()=>{ew||Z(!1)},t1=async(e,t)=>{let a=await fetch(`/api/providers/${e}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!a.ok)throw Error((await a.json().catch(()=>({}))).error||`Proxy update failed (${a.status})`);return a.json()},t2=async e=>{eN(!0);try{let t=[];for(let{connectionId:a,proxyPoolId:s,proxyPoolIds:i,proxyRotationStrategy:l}of e)try{let e=i?{proxyPoolIds:i,proxyRotationStrategy:l}:{proxyPoolId:s};await t1(a,e)}catch(e){console.log("Error applying proxy for",a,e),t.push(a)}if(await tT(),t.length>0)return void alert(`Updated with ${t.length} failed request(s). Retry the selected connections.`);Z(!1),eg([]),ej("__none__")}finally{eN(!1)}},t5=e=>t2((ef.length>0?tH:f).map(t=>({connectionId:t.id,proxyPoolId:e}))),t3=(0,s.jsxs)("div",{className:"flex min-w-0 flex-col divide-y divide-black/[0.03] dark:divide-white/[0.03]",children:[tQ.map((e,t)=>{let a,i=tX+t;return(0,s.jsxs)("div",{className:"flex min-w-0 items-stretch",children:[(0,s.jsx)("div",{className:"flex shrink-0 items-center pl-1 sm:pl-2",children:(0,s.jsx)("input",{type:"checkbox",checked:(a=e.id,ef.includes(a)),onChange:()=>{var t;return t=e.id,void eg(e=>e.includes(t)?e.filter(e=>e!==t):[...e,t])},className:"h-4 w-4 rounded border-gray-300 text-primary focus:ring-primary"})}),(0,s.jsx)("div",{className:"flex-1 min-w-0",children:(0,s.jsx)(P,{connection:e,proxyPools:$,isOAuth:ti,isFirst:0===i,isLast:i===f.length-1,onMoveUp:()=>tW(i,i-1),onMoveDown:()=>tW(i,i+1),onToggleActive:t=>tq(e.id,t),autoPing:K[u]&&"oauth"===e.authType?{on:!0===eE.connections[e.id],onToggle:t=>{var a;return a=e.id,void tD({...eE,connections:{...eE.connections,[a]:t}})},provider:u}:null,onUpdateProxy:async t=>{try{let a="object"==typeof t?t:{proxyPoolId:t||null};if((await fetch(`/api/providers/${e.id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)})).ok){let t={...e.providerSpecificData};a.proxyPoolIds?(t.proxyPoolIds=a.proxyPoolIds,t.proxyRotationStrategy=a.proxyRotationStrategy,delete t.proxyPoolId):(a.proxyPoolId?t.proxyPoolId=a.proxyPoolId:delete t.proxyPoolId,delete t.proxyPoolIds,delete t.proxyRotationStrategy),g(a=>a.map(a=>a.id===e.id?{...a,providerSpecificData:t}:a))}}catch(e){console.log("Error updating proxy:",e)}},onEdit:()=>{et(e),G(!0)},onDelete:()=>tK(e.id),oneByOneStatus:eY[e.id]||null,modelAssignmentOptions:"freebuff"===u?ty:null,onModelAssignmentChange:"freebuff"===u?t=>tE(e.id,t):null,strictModelAssignment:eT})})]},e.id)}),f.length>10&&(0,s.jsx)(d.Pagination,{currentPage:tV,pageSize:10,totalItems:f.length,onPageChange:eb})]}),t4=$.filter(e=>!0===e.isActive),t6=(0,s.jsx)(d.Modal,{isOpen:Y,onClose:t0,title:ef.length>0?`Apply Proxy (${ef.length} selected)`:`Apply Proxy (All ${f.length} connections)`,children:(0,s.jsxs)("div",{className:"flex flex-col gap-4",children:[tZ&&(0,s.jsx)("p",{className:"text-xs text-text-muted bg-surface-2 px-3 py-2 rounded-lg border border-border/50",children:tZ}),(0,s.jsxs)("div",{className:"flex flex-col divide-y divide-border/30 border border-border/50 rounded-xl overflow-hidden bg-surface",children:[(0,s.jsxs)("div",{className:"p-3 flex flex-col gap-1",children:[(0,s.jsx)("p",{className:"px-3 pb-1 text-[10px] font-semibold uppercase tracking-wider text-text-muted",children:"Dynamic Strategies"}),(0,s.jsxs)("button",{type:"button",onClick:()=>{let e=$.filter(e=>!0===e.isActive);return 0===e.length?void alert("No active proxy pools available."):t2((ef.length>0?tH:f).map((t,a)=>({connectionId:t.id,proxyPoolId:e[a%e.length].id})))},disabled:ew||0===t4.length,className:"flex items-center gap-3 rounded-lg px-3 py-2 text-left transition-colors hover:bg-surface-2 disabled:cursor-not-allowed disabled:opacity-50",children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-text-muted text-[20px]",children:"sync_alt"}),(0,s.jsxs)("div",{className:"flex flex-col",children:[(0,s.jsx)("span",{className:"text-sm font-medium text-text-main",children:"One-to-one (rotate)"}),(0,s.jsx)("span",{className:"text-[10px] text-text-muted mt-0.5",children:"Distribute active proxy pools round-robin"})]})]}),["fill-first","round-robin","random","smart"].map(e=>(0,s.jsxs)("button",{type:"button",onClick:()=>{let t;return(t=t4.map(e=>e.id).filter(e=>$.find(t=>t.id===e)?.isActive===!0)).length?t2((ef.length>0?tH:f).map(a=>({connectionId:a.id,proxyPoolIds:t,proxyRotationStrategy:e}))):void alert("No active proxy pools selected.")},disabled:ew||0===t4.length,className:"flex items-center gap-3 rounded-lg px-3 py-2 text-left transition-colors hover:bg-surface-2 disabled:cursor-not-allowed disabled:opacity-50",children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-text-muted text-[20px]",children:"autorenew"}),(0,s.jsxs)("div",{className:"flex flex-col",children:[(0,s.jsxs)("span",{className:"text-sm font-medium text-text-main capitalize",children:[e," strategy"]}),(0,s.jsx)("span",{className:"text-[10px] text-text-muted mt-0.5",children:"smart"===e?"Bypass pools marked unfit for provider/model":`Rotate over all active pools using ${e}`})]})]},e))]}),(0,s.jsxs)("div",{className:"p-3 flex flex-col gap-1",children:[(0,s.jsx)("p",{className:"px-3 pb-1 text-[10px] font-semibold uppercase tracking-wider text-text-muted",children:"Static Assignment"}),(0,s.jsxs)("button",{type:"button",onClick:()=>t5(null),disabled:ew,className:"flex items-center gap-3 rounded-lg px-3 py-2 text-left transition-colors hover:bg-surface-2 disabled:cursor-not-allowed disabled:opacity-50",children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-text-muted text-[20px]",children:"link_off"}),(0,s.jsxs)("div",{className:"flex flex-col",children:[(0,s.jsx)("span",{className:"text-sm font-medium text-text-main",children:"None (unbind all)"}),(0,s.jsx)("span",{className:"text-[10px] text-text-muted mt-0.5",children:"Direct routing without proxy"})]})]}),$.map(e=>(0,s.jsxs)("button",{type:"button",onClick:()=>t5(e.id),disabled:ew||!0!==e.isActive,className:"flex items-center gap-3 rounded-lg px-3 py-2 text-left transition-colors hover:bg-surface-2 disabled:cursor-not-allowed disabled:opacity-50",children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-text-muted text-[20px]",children:"lan"}),(0,s.jsxs)("div",{className:"flex flex-col min-w-0 flex-1",children:[(0,s.jsx)("span",{className:"truncate text-sm font-medium text-text-main",children:e.name}),(0,s.jsx)("span",{className:"text-[10px] text-text-muted truncate mt-0.5",children:e.proxyUrl})]}),!0!==e.isActive&&(0,s.jsx)(d.Badge,{variant:"secondary",size:"sm",className:"ml-auto shrink-0",children:"inactive"})]},e.id))]})]}),ew&&(0,s.jsx)("p",{className:"text-xs text-text-muted animate-pulse px-1",children:"Applying proxy configuration..."}),(0,s.jsx)(d.Button,{onClick:t0,variant:"ghost",fullWidth:!0,disabled:ew,children:"Cancel"})]})}),t8=async e=>{if(!ep.has(e)){ex(t=>new Set(t).add(e));try{let t=await fetch("/api/models/test",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({model:`${tg}/${e}`})}),a=await t.json();ed(t=>({...t,[e]:a.ok?"ok":"error"})),em(a.ok?"":a.error||"Model not reachable")}catch{ed(t=>({...t,[e]:"error"})),em("Network error")}finally{ex(t=>{let a=new Set(t);return a.delete(e),a})}}};return w?(0,s.jsxs)("div",{className:"flex flex-col gap-8",children:[(0,s.jsx)(d.CardSkeleton,{}),(0,s.jsx)(d.CardSkeleton,{})]}):ta?(0,s.jsxs)("div",{className:"flex min-w-0 flex-col gap-6 px-1 sm:gap-8 sm:px-0",children:[(0,s.jsxs)("div",{className:"min-w-0",children:[(0,s.jsxs)(o(),{href:"/dashboard/providers",className:"inline-flex items-center gap-1 text-sm text-text-muted hover:text-primary transition-colors mb-4",children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-lg",children:"arrow_back"}),"Back to Providers"]}),(0,s.jsxs)("div",{className:"flex min-w-0 items-center gap-3 sm:gap-4",children:[(0,s.jsx)(n.A,{providerId:ta.id,size:48,alt:ta.name,className:"shrink-0 rounded-lg",fallbackText:ta.textIcon||ta.id.slice(0,2).toUpperCase(),fallbackColor:ta.color}),(0,s.jsxs)("div",{className:"min-w-0",children:[(0,s.jsxs)("div",{className:"flex items-center gap-3 flex-wrap",children:[(0,s.jsx)("h1",{className:"truncate text-2xl font-semibold tracking-tight sm:text-3xl",children:ta.name}),(ta.notice?.apiKeyUrl||ta.notice?.signupUrl||ta.website)&&(0,s.jsxs)("a",{href:ta.notice?.apiKeyUrl||ta.notice?.signupUrl||ta.website,target:"_blank",rel:"noopener noreferrer",className:"text-xs text-primary hover:underline inline-flex items-center gap-1",children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-sm",children:"open_in_new"}),ta.notice?.apiKeyUrl?"Get API Key":"Sign up / Learn more"]})]}),(0,s.jsxs)("p",{className:"text-text-muted",children:[f.length," connection",1===f.length?"":"s"]})]})]})]}),ta.deprecated&&(0,s.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,s.jsx)("span",{className:"material-symbols-outlined text-[16px] text-yellow-500 mt-0.5 shrink-0",children:"warning"}),(0,s.jsx)("p",{className:"text-xs text-red-600 dark:text-yellow-400 leading-relaxed",children:ta.deprecationNotice})]}),ta.notice?.text&&!ta.deprecated&&(0,s.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,s.jsx)("span",{className:"material-symbols-outlined text-[16px] text-blue-500 shrink-0",children:"info"}),(0,s.jsx)("p",{className:"min-w-0 flex-1 text-xs leading-relaxed text-blue-600 dark:text-blue-400",children:ta.notice.text}),ta.notice.apiKeyUrl&&(0,s.jsx)("a",{href:ta.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 →"})]}),tp&&T&&(0,s.jsx)(d.Card,{children:(0,s.jsxs)("div",{className:"mb-4 flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between",children:[(0,s.jsxs)("div",{className:"min-w-0",children:[(0,s.jsx)("h2",{className:"text-lg font-semibold",children:tm?"Anthropic Compatible Details":"OpenAI Compatible Details"}),(0,s.jsxs)("p",{className:"break-all text-sm text-text-muted",children:[tm?"Messages API":"responses"===T.apiType?"Responses API":"Chat Completions"," \xb7 ",(T.baseUrl||"").replace(/\/$/,""),"/",tm?"messages":"responses"===T.apiType?"responses":"chat/completions"]})]}),(0,s.jsxs)("div",{className:"grid grid-cols-1 gap-2 sm:flex sm:items-center",children:[(0,s.jsx)(d.Button,{size:"sm",icon:"add",onClick:()=>{q(""),F(!0)},className:"w-full sm:w-auto",children:"Add API Key"}),(0,s.jsx)(d.Button,{size:"sm",variant:"secondary",icon:"edit",onClick:()=>X(!0),className:"w-full sm:w-auto",children:"Edit"}),(0,s.jsx)(d.Button,{size:"sm",variant:"secondary",icon:"delete",onClick:async()=>{eF({title:"Delete Compatible Node",message:`Delete this ${tm?"Anthropic":"OpenAI"} Compatible node?`,onConfirm:async()=>{eF(null);try{(await fetch(`/api/provider-nodes/${u}`,{method:"DELETE"})).ok&&x.push("/dashboard/providers")}catch(e){console.log("Error deleting provider node:",e)}}})},className:"w-full sm:w-auto",children:"Delete"})]})]})}),tr?(0,s.jsx)(d.NoAuthProxyCard,{providerId:u}):(0,s.jsxs)(d.Card,{children:[(0,s.jsxs)("div",{className:"mb-4 flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[(0,s.jsx)("h2",{className:"text-lg font-semibold",children:"Connections"}),(0,s.jsxs)("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:gap-4",children:[f.length>0&&$.length>0&&(0,s.jsx)(d.Button,{size:"sm",variant:"secondary",icon:"lan",onClick:()=>Z(!0),children:"Apply Proxy"}),f.length>0&&(0,s.jsxs)(s.Fragment,{children:[ef.length>0&&(0,s.jsxs)(d.Button,{size:"sm",variant:"danger",icon:"delete",onClick:()=>{let e=ef.length;0!==e&&eF({title:`Delete ${e} Connection${e>1?"s":""}`,message:`Delete ${e} connection${e>1?"s":""}? This cannot be undone.`,onConfirm:async()=>{eF(null);let e=0,t=[...ef];for(let a of t)try{(await fetch(`/api/providers/${a}`,{method:"DELETE"})).ok||(e+=1)}catch(t){console.log("Error deleting connection:",t),e+=1}g(e=>e.filter(e=>!t.includes(e.id))),eg([]),e>0&&alert(`Deleted ${t.length-e} connection(s), ${e} failed.`)}})},children:["Delete Selected (",ef.length,")"]}),(0,s.jsx)(d.Button,{size:"sm",variant:"secondary",icon:"sync",onClick:tR,disabled:eW,children:eW?"Testing Connection One-by-One...":"Test Connection One-by-One"}),eW&&(0,s.jsx)(d.Button,{size:"sm",variant:"ghost",icon:"stop",onClick:()=>{eW&&(e2.current=!0,eG(!0))},disabled:eV,children:eV?"Stopping...":"Stop"})]}),(0,s.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,s.jsx)("span",{className:"text-xs text-text-muted font-medium",children:"Round Robin"}),(0,s.jsx)(d.Toggle,{checked:"round-robin"===ek,onChange:e=>{let t=e?"round-robin":null,a=e?eC||"1":eC;e&&!eC&&eA("1"),eS(t),tP(t,a)}}),"round-robin"===ek&&(0,s.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,s.jsx)("span",{className:"text-xs text-text-muted",children:"Sticky:"}),(0,s.jsx)("input",{type:"number",min:1,value:eC,onChange:e=>{var t;eA(t=e.target.value),tP("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"})]})]}),"freebuff"===u&&(0,s.jsxs)("div",{className:"flex flex-wrap items-center gap-2 border-t border-black/[0.03] pt-2 dark:border-white/[0.03]",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("span",{className:"text-xs text-text-muted font-medium",children:"Strict Model Assignment"}),(0,s.jsx)("p",{className:"text-[10px] text-text-muted",children:"Only assigned accounts can serve each Freebuff model."})]}),(0,s.jsx)(d.Toggle,{checked:eT,onChange:t$})]})]})]}),0===f.length?(0,s.jsxs)("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[(0,s.jsxs)("div",{className:"flex items-center gap-3",children:[(0,s.jsx)("div",{className:"inline-flex items-center justify-center w-9 h-9 rounded-full bg-primary/10 text-primary shrink-0",children:(0,s.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:ti?"lock":"key"})}),(0,s.jsxs)("div",{className:"min-w-0",children:[(0,s.jsx)("p",{className:"text-sm text-text-muted",children:"No connections yet"}),tx&&(0,s.jsxs)("p",{className:"text-xs text-text-muted",children:["Choose ",tu," or ",th,"."]})]})]}),(0,s.jsx)("div",{className:"flex gap-2",children:tx?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(d.Button,{size:"sm",icon:"lock",variant:"secondary",onClick:e9,children:tu}),(0,s.jsx)(d.Button,{size:"sm",icon:"key",onClick:te,children:th})]}):(0,s.jsxs)(s.Fragment,{children:[!tp&&"iflow"===u&&(0,s.jsx)(d.Button,{size:"sm",icon:"cookie",variant:"secondary",onClick:()=>B(!0),children:"Cookie"}),"codex"===u&&(0,s.jsx)(d.Button,{size:"sm",icon:"playlist_add",variant:"secondary",onClick:()=>H(!0),children:(0,j.Tl)("Bulk Add")}),(0,s.jsx)(d.Button,{size:"sm",icon:"add",onClick:tt,children:tp?"Add API Key":"iflow"===u?"OAuth":"Add Connection"})]})})]}):(0,s.jsxs)(s.Fragment,{children:[e0&&(0,s.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,s.jsxs)("div",{className:"flex flex-wrap items-center gap-3",children:[(0,s.jsxs)("span",{children:["Total: ",e0.total]}),(0,s.jsxs)("span",{children:["Completed: ",e0.completed]}),(0,s.jsxs)("span",{children:["Passed: ",e0.passed]}),(0,s.jsxs)("span",{children:["Failed: ",e0.failed]}),e0.stopped&&(0,s.jsx)("span",{className:"text-amber-600 dark:text-amber-400",children:"Stopped"}),eW&&eQ&&(0,s.jsxs)("span",{children:["Running: ",f.find(e=>e.id===eQ)?.name||eQ]})]})}),f.length>0&&(0,s.jsx)("div",{className:"mb-3 flex items-center gap-2 border-b border-black/[0.03] pb-2 dark:border-white/[0.03]",children:(0,s.jsxs)("label",{className:"flex cursor-pointer items-center gap-1.5 text-xs text-text-muted hover:text-primary",children:[(0,s.jsx)("input",{type:"checkbox",checked:tY,onChange:()=>{tY?eg([]):eg(f.map(e=>e.id))},className:"h-3.5 w-3.5 rounded border-gray-300 text-primary focus:ring-primary"}),"Select All"]})}),t3,!tp&&(0,s.jsxs)("div",{className:"mt-4 grid grid-cols-1 gap-2 sm:flex",children:["iflow"===u&&(0,s.jsx)(d.Button,{size:"sm",icon:"cookie",variant:"secondary",onClick:()=>B(!0),title:"Add connection using browser cookie",className:"w-full sm:w-auto",children:"Cookie"}),"codex"===u&&(0,s.jsx)(d.Button,{size:"sm",icon:"playlist_add",variant:"secondary",onClick:()=>H(!0),title:(0,j.Tl)("Bulk import codex accounts from JSON"),className:"w-full sm:w-auto",children:(0,j.Tl)("Bulk Add")}),tx?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(d.Button,{size:"sm",icon:"lock",variant:"secondary",onClick:e9,className:"w-full sm:w-auto",children:tu}),(0,s.jsx)(d.Button,{size:"sm",icon:"key",onClick:te,className:"w-full sm:w-auto",children:th})]}):(0,s.jsx)(d.Button,{size:"sm",icon:"add",onClick:tt,className:"w-full sm:w-auto",children:"Add"})]})]})]}),(0,s.jsxs)(d.Card,{children:[(0,s.jsxs)("div",{className:"mb-4 flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between",children:[(0,s.jsxs)("div",{className:"flex items-center gap-3",children:[(0,s.jsx)("h2",{className:"text-lg font-semibold",children:"Available Models"}),tb&&(0,s.jsx)("select",{value:eP,onChange:e=>{var t;e$(t=e.target.value),tO(t)},title:"Appends (level) suffix to copied model names",className:"rounded-md border border-border bg-background px-2 py-1 text-xs focus:border-primary focus:outline-none",children:tb.map(e=>(0,s.jsx)("option",{value:e,children:`Thinking: ${e.charAt(0).toUpperCase()+e.slice(1)}`},e))})]}),!tp&&(r=[...tn,...ez.filter(e=>!tn.some(t=>t.id===e.id))].filter(e=>{let t=(0,m.CP)(e);return!t||"llm"===t}).map(e=>e.id).filter(e=>!eR.includes(e)),(0,s.jsxs)("div",{className:"flex gap-2",children:[eR.length>0&&(0,s.jsx)(d.Button,{size:"sm",variant:"secondary",icon:"restart_alt",onClick:tS,children:"Active All"}),r.length>0&&(0,s.jsx)(d.Button,{size:"sm",variant:"secondary",icon:"block",onClick:()=>tk(r),children:"Disable All"})]}))]}),!!ec&&(0,s.jsx)("p",{className:"text-xs text-red-500 mb-3 break-words",children:ec}),(()=>{let e,t,a;if(tp)return(0,s.jsx)(A,{providerStorageAlias:tg,providerDisplayAlias:tv,modelAliases:ea,customModels:ei,copied:e4,onCopy:e6,onSetAlias:t_,onDeleteAlias:tU,onAddCustomModel:e=>tM(e,"llm",tg),onDeleteCustomModel:e=>tz(e,"llm",tg),connections:f,isAnthropic:tm});let i=[...tn,...ez.filter(e=>!tn.some(t=>t.id===e.id))].filter(e=>{let t=(0,m.CP)(e);return!t||"llm"===t}),l=new Set(eR),r=i.filter(e=>!l.has(e.id)),o=i.filter(e=>l.has(e.id)),n=k({customModels:ei,modelAliases:ea,providerAlias:tg,builtInModels:tn,type:"llm"});return(0,s.jsxs)("div",{className:"flex flex-wrap gap-3",children:[n.map(e=>(0,s.jsx)(S,{model:{id:e.id,name:e.name},fullModel:`${tv}/${e.id}`,alias:e.alias,copied:e4,onCopy:e6,onSetAlias:()=>{},onDeleteAlias:()=>{"custom"===e.source?tz(e.id,"llm",tg):tU(e.alias)},testStatus:en[e.id],onTest:f.length>0||tr?()=>t8(e.id):void 0,isTesting:ep.has(e.id),isCustom:!0,isFree:!1,caps:h(`${u}/${e.id}`),thinkingSuffix:tf(e.id)},`${e.source}-${e.fullModel}`)),r.map(e=>{let t=`${tg}/${e.id}`,a=`${u}/${e.id}`,i=Object.entries(ea).find(([,e])=>e===t||e===a)?.[0];return(0,s.jsx)(S,{model:e,fullModel:`${tv}/${e.id}`,alias:i,copied:e4,onCopy:e6,onSetAlias:t=>t_(e.id,t,tg),onDeleteAlias:()=>tU(i),testStatus:en[e.id],onTest:f.length>0||tr?()=>t8(e.id):void 0,isTesting:ep.has(e.id),isFree:e.isFree,onDisable:()=>tw(e.id),caps:h(`${u}/${e.id}`),thinkingSuffix:tf(e.id)},e.id)}),(0,s.jsxs)("button",{onClick:()=>eh(!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,s.jsx)("span",{className:"material-symbols-outlined text-sm",children:"add"}),"Add Model"]}),"qoder"===u&&f.some(e=>!1!==e.isActive)&&(0,s.jsxs)("button",{onClick:tB,disabled:e5,className:"flex w-full items-center justify-center gap-1.5 rounded-lg border border-dashed border-blue-500/40 px-3 py-2 text-xs text-blue-600 dark:text-blue-400 transition-colors hover:border-blue-500 hover:bg-blue-500/5 sm:w-auto disabled:opacity-50 disabled:cursor-not-allowed",children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-sm",style:e5?{animation:"spin 1s linear infinite"}:void 0,children:e5?"progress_activity":"download"}),e5?(0,j.Tl)("Fetching..."):(0,j.Tl)("Fetch Qoder Models")]}),eD.length>0&&(e=new Set([...Object.values(ea),...n.map(e=>e.fullModel)]),t=new Set(tn.map(e=>e.id)),0===(a=eD.filter(a=>!e.has(`${tg}/${a.id}`)&&!t.has(a.id))).length?null:(0,s.jsxs)("div",{className:"w-full mt-2",children:[(0,s.jsx)("p",{className:"text-xs text-text-muted mb-2",children:"Suggested free models (≥200k context):"}),(0,s.jsx)("div",{className:"flex flex-wrap gap-2",children:a.map(e=>(0,s.jsxs)("button",{onClick:async()=>{await tM(e.id,"llm",tg)},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,s.jsx)("span",{className:"material-symbols-outlined text-[13px]",children:"add"}),e.id.split("/").pop()]},e.id))})]})),o.length>0&&(0,s.jsxs)("div",{className:"w-full mt-2",children:[(0,s.jsxs)("p",{className:"text-xs text-text-muted mb-2",children:["Disabled models (",o.length,"):"]}),(0,s.jsx)("div",{className:"flex flex-wrap gap-2",children:o.map(e=>(0,s.jsxs)("button",{onClick:()=>tN(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,s.jsx)("span",{className:"material-symbols-outlined text-[13px]",children:"add"}),e.id]},e.id))})]})]})})()]}),t6,"kiro"===u?(0,s.jsx)(d.KiroOAuthWrapper,{isOpen:O,providerInfo:ta,onSuccess:tL,onClose:()=>_(!1)}):"cursor"===u?(0,s.jsx)(d.CursorAuthModal,{isOpen:O,onSuccess:tL,onClose:()=>_(!1)}):"gitlab"===u?(0,s.jsx)(d.GitLabAuthModal,{isOpen:O,providerInfo:ta,onSuccess:tL,onClose:()=>_(!1)}):(0,s.jsx)(d.OAuthModal,{isOpen:O,provider:u,providerInfo:ta,onSuccess:tL,onClose:()=>_(!1)}),"iflow"===u&&(0,s.jsx)(d.IFlowCookieModal,{isOpen:M,onSuccess:()=>{tT(),B(!1)},onClose:()=>B(!1)}),(0,s.jsx)(D,{isOpen:L,provider:u,providerName:ta.name,isCompatible:tp,isAnthropic:tm,authType:ta?.authType,authHint:ta?.authHint,website:ta?.website,proxyPools:$,error:J,existingNames:f.map(e=>e.name).filter(Boolean),onSave:tF,onBulkDone:tT,onClose:()=>{q(""),F(!1)}}),(0,s.jsx)(d.EditConnectionModal,{isOpen:V,connection:ee,proxyPools:$,onSave:tJ,onClose:()=>G(!1)}),tp&&(0,s.jsx)(U,{isOpen:Q,node:T,onSave:tI,onClose:()=>X(!1),isAnthropic:tm}),!tp&&(0,s.jsx)(z,{isOpen:eu,providerAlias:tg,providerDisplayAlias:tv,onSave:async e=>{await tM(e,"llm",tg),eh(!1)},onClose:()=>eh(!1)}),"codex"===u&&(0,s.jsx)(R,{isOpen:W,onClose:()=>H(!1),onSuccess:tT}),(0,s.jsx)(d.ConfirmModal,{isOpen:eJ,onClose:()=>eq(!1),onConfirm:()=>{(window.localStorage.setItem(e8,"true"),eq(!1),ti)?e7():te()},title:"Risk Notice",message:ta?.deprecationNotice,confirmText:"I Understand, Continue",cancelText:"Cancel",variant:"danger"}),(0,s.jsx)(d.ConfirmModal,{isOpen:!!eL,onClose:()=>eF(null),onConfirm:eL?.onConfirm,title:eL?.title||"Confirm",message:eL?.message,variant:"danger"})]}):(0,s.jsxs)("div",{className:"text-center py-20",children:[(0,s.jsx)("p",{className:"text-text-muted",children:"Provider not found"}),(0,s.jsx)(o(),{href:"/dashboard/providers",className:"text-primary mt-4 inline-block",children:"Back to Providers"})]})}},21863:(e,t,a)=>{"use strict";function s(e,t){return!1===e?"default":"active"===t||"success"===t?"success":"error"===t||"expired"===t||"unavailable"===t?"error":"default"}function i(e){let t=e?.testStatus;return e?.isActive===!1||"unavailable"===t||"error"===t||"expired"===t?"unavailable":"active"}a.d(t,{d:()=>i,g:()=>s})},68810:(e,t,a)=>{Promise.resolve().then(a.bind(a,6))}},e=>{e.O(0,[3885,2318,4385,2940,7236,5479,2147,3204,7358],()=>e(e.s=68810)),_N_E=e.O()}]);
12
+ ]`;function R({isOpen:e,onClose:t,onSuccess:a}){let[l,r]=(0,i.useState)(""),[o,n]=(0,i.useState)(!1),[c,m]=(0,i.useState)(""),[p,x]=(0,i.useState)(null),u=()=>{o||(r(""),m(""),x(null),t())},h=async()=>{var e;let t;m(""),x(null);let s=l.trim();if(!s)return;try{t=JSON.parse(s)}catch(e){m(`${(0,j.Tl)("Invalid JSON")}: ${e.message}`);return}let i=Array.isArray(e=t)?e:e&&"object"==typeof e?Array.isArray(e.accounts)?e.accounts:[e]:null;if(!i||0===i.length)return void m((0,j.Tl)("No accounts found in input"));n(!0);try{let e=await fetch("/api/oauth/codex/bulk-import",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({accounts:i})}),t=await e.json();if(!e.ok)return void m(t?.error||`Request failed: ${e.status}`);x(t),t.success>0&&"function"==typeof a&&a()}catch(e){m(e.message||(0,j.Tl)("Request failed"))}finally{n(!1)}},f=p?.results?.filter(e=>!e.ok)||[];return(0,s.jsx)(d.Modal,{isOpen:e,title:(0,j.Tl)("Bulk Add Codex Accounts"),onClose:u,children:(0,s.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,s.jsx)("p",{className:"text-xs text-text-muted",children:(0,j.Tl)("Paste an array of codex account JSON objects. Each must include accessToken (and ideally refreshToken, idToken).")}),(0,s.jsx)("textarea",{className:"w-full rounded border border-accent/30 bg-sidebar p-2 text-sm font-mono resize-y min-h-[240px] focus:outline-none focus:ring-1 focus:ring-primary",placeholder:B,value:l,onChange:e=>r(e.target.value),disabled:o}),c&&(0,s.jsx)("p",{className:"text-xs text-red-500 break-words",children:c}),p&&(0,s.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,s.jsxs)("div",{className:`text-sm font-medium ${p.failed>0?"text-yellow-400":"text-green-400"}`,children:["✓ ",p.success," ",(0,j.Tl)("added"),p.failed>0?`, ✗ ${p.failed} ${(0,j.Tl)("failed")}`:""]}),f.length>0&&(0,s.jsx)("ul",{className:"rounded border border-accent/20 bg-sidebar/50 p-2 text-xs font-mono max-h-40 overflow-y-auto",children:f.map(e=>(0,s.jsxs)("li",{className:"text-red-400",children:["[",e.index,"] ",e.error]},e.index))})]}),(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsx)(d.Button,{onClick:h,fullWidth:!0,disabled:o||!l.trim(),children:o?(0,j.Tl)("Importing..."):(0,j.Tl)("Import All")}),(0,s.jsx)(d.Button,{onClick:u,variant:"ghost",fullWidth:!0,disabled:o,children:(0,j.Tl)("Close")})]})]})})}let K={claude:"claudeAutoPing",codex:"codexAutoPing"};function L(){let e,t,a,r,p=(0,l.useParams)(),x=(0,l.useRouter)(),u=p.id,{getCaps:h}=(0,v.y)(),[f,g]=(0,i.useState)([]),[w,C]=(0,i.useState)(!0),[T,I]=(0,i.useState)(null),[$,E]=(0,i.useState)([]),[O,_]=(0,i.useState)(!1),[M,B]=(0,i.useState)(!1),[L,F]=(0,i.useState)(!1),[J,q]=(0,i.useState)(""),[W,H]=(0,i.useState)(!1),[V,G]=(0,i.useState)(!1),[Q,X]=(0,i.useState)(!1),[Y,Z]=(0,i.useState)(!1),[ee,et]=(0,i.useState)(null),[ea,es]=(0,i.useState)({}),[ei,el]=(0,i.useState)([]),[er,eo]=(0,i.useState)(!1),[en,ed]=(0,i.useState)({}),[ec,em]=(0,i.useState)(""),[ep,ex]=(0,i.useState)(()=>new Set),[eu,eh]=(0,i.useState)(!1),[ef,eg]=(0,i.useState)([]),[ey,eb]=(0,i.useState)(1),[ev,ej]=(0,i.useState)("__none__"),[ew,eN]=(0,i.useState)(!1),[ek,eS]=(0,i.useState)(null),[eC,eA]=(0,i.useState)(""),[eT,eI]=(0,i.useState)(!1),[eP,e$]=(0,i.useState)("auto"),[eE,eO]=(0,i.useState)({enabled:!1,connections:{}}),[eD,e_]=(0,i.useState)([]),[eU,eM]=(0,i.useState)([]),[ez,eB]=(0,i.useState)([]),[eR,eK]=(0,i.useState)([]),[eL,eF]=(0,i.useState)(null),[eJ,eq]=(0,i.useState)(!1),[eW,eH]=(0,i.useState)(!1),[eV,eG]=(0,i.useState)(!1),[eQ,eX]=(0,i.useState)(null),[eY,eZ]=(0,i.useState)({}),[e0,e1]=(0,i.useState)(null),e2=(0,i.useRef)(!1),[e5,e3]=(0,i.useState)(!1),{copied:e4,copy:e6}=(0,b.C)(),e8="ag_risk_confirmed",e7=()=>{_(!0)},e9=()=>{"antigravity"===u&&"true"!==window.localStorage.getItem(e8)?eq(!0):ti?e7():(q(""),F(!0))},te=()=>{q(""),F(!0)},tt=()=>{ti?e9():te()},ta=T?{id:T.id,name:T.name||("anthropic-compatible"===T.type?"Anthropic Compatible":"OpenAI Compatible"),color:"anthropic-compatible"===T.type?"#D97757":"#10A37F",textIcon:"anthropic-compatible"===T.type?"AC":"OC",apiType:T.apiType,baseUrl:T.baseUrl,type:T.type}:c.zN[u]||c.fg[u]||c.IS[u]||c.nJ[u]||c.br[u],ts=ta?.authModes||[],ti=!!c.zN[u]||!!c.IS[u]||ts.includes("oauth"),tl=!!c.fg[u]||ts.includes("apikey"),tr=!!c.IS[u]?.noAuth,to=(0,m.KC)(u),tn="cursor"===u&&eU.length>0?eU:to,td=(0,c.wG)(u),tc=(0,c.mq)(u),tm=(0,c.gb)(u),tp=tc||tm,tx=!tp&&ti&&tl,tu="xai"===u?"Grok Build OAuth":"grok-cli"===u?"Grok CLI Device Login":"kimi"===u?"Kimi Coding OAuth":"OAuth",th="xai"===u?"xAI API Key":"kimi"===u?"Kimi API Key":"qoder"===u?"PAT":"API Key",tf=e=>{if(!eP||"auto"===eP)return null;let t=y(u,e);return t&&t.includes(eP)?eP:null},tg=tp?u:td,ty=(e=new Map,t=t=>{t?.id&&!e.has(t.id)&&e.set(t.id,t)},tn.forEach(t),ei.forEach(e=>{e.providerAlias===tg&&"llm"===(e.kind||e.type||"llm")&&t(e)}),a=new Set(eR),[...e.values()].filter(e=>!a.has(e.id))),tb=(()=>{let e=new Set,t=new Set,a=a=>{if(!a||t.has(a))return;t.add(a);let s=y(u,a);s&&s.forEach(t=>{"none"!==t&&e.add(t)})};for(let e of tn)a(e.id);for(let e of ez)a(e.id);for(let e of ei)e.providerAlias===tg&&"llm"===(e.kind||e.type||"llm")&&a(e.id);return e.size?["auto",...e]:null})(),tv=tp?T?.prefix||u:td,tj=(0,i.useCallback)(async()=>{try{let e=await fetch(`/api/models/disabled?providerAlias=${encodeURIComponent(tg)}`,{cache:"no-store"}),t=await e.json();e.ok&&eK(t.ids||[])}catch(e){console.log("Error fetching disabled models:",e)}},[tg]),tw=async e=>{try{(await fetch("/api/models/disabled",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({providerAlias:tg,ids:[e]})})).ok&&await tj()}catch(e){console.log("Error disabling model:",e)}},tN=async e=>{try{(await fetch(`/api/models/disabled?providerAlias=${encodeURIComponent(tg)}&id=${encodeURIComponent(e)}`,{method:"DELETE"})).ok&&await tj()}catch(e){console.log("Error enabling model:",e)}},tk=async e=>{e.length&&eF({title:"Disable All Models",message:`Disable all ${e.length} model(s)?`,onConfirm:async()=>{eF(null);try{(await fetch("/api/models/disabled",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({providerAlias:tg,ids:e})})).ok&&await tj()}catch(e){console.log("Error disabling all models:",e)}}})},tS=async()=>{try{(await fetch(`/api/models/disabled?providerAlias=${encodeURIComponent(tg)}`,{method:"DELETE"})).ok&&await tj()}catch(e){console.log("Error enabling all models:",e)}},tC=(0,i.useCallback)(async()=>{try{let e=await fetch("/api/models/alias"),t=await e.json();e.ok&&es(t.aliases||{})}catch(e){console.log("Error fetching aliases:",e)}},[]),tA=(0,i.useCallback)(async()=>{try{let e=await fetch("/api/models/custom",{cache:"no-store"}),t=await e.json();e.ok&&el(t.models||[])}catch(e){console.log("Error fetching custom models:",e)}},[]);(0,i.useEffect)(()=>{"kilocode"===u&&fetch("/api/providers/kilo/free-models").then(e=>e.json()).then(e=>{e.models?.length&&eB(e.models)}).catch(()=>{})},[u]);let tT=(0,i.useCallback)(async()=>{try{let[e,t,a,s]=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(),r=await a.json(),o=s.ok?await s.json():{};if(e.ok){let e=(i.connections||[]).filter(e=>e.provider===u);g(e)}a.ok&&E(r.proxyPools||[]);let n=(o.providerStrategies||{})[u]||{};eS(n.fallbackStrategy||null),eA(null!=n.stickyRoundRobinLimit?String(n.stickyRoundRobinLimit):"1"),eI(!0===n.strictModelAssignment);let d=(o.providerThinking||{})[u]||{};e$(d.mode||"auto");let c=K[u],m=c&&o[c]||{};if(eO({enabled:!0===m.enabled,connections:m.connections||{}}),t.ok){let e=(l.nodes||[]).find(e=>e.id===u)||null;if(!e&&tp)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===u)||null))break}I(e)}}catch(e){console.log("Error fetching connections:",e)}finally{C(!1)}},[u,tp]),tI=async e=>{try{let t=await fetch(`/api/provider-nodes/${u}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}),a=await t.json();t.ok&&(I(a.node),await tT(),X(!1))}catch(e){console.log("Error updating provider node:",e)}},tP=async(e,t)=>{try{let a=await fetch("/api/settings",{cache:"no-store"}),s=(a.ok?await a.json():{}).providerStrategies||{},i={...s[u]||{}};e?i.fallbackStrategy=e:(delete i.fallbackStrategy,delete i.stickyRoundRobinLimit),"round-robin"===e&&""!==t&&(i.stickyRoundRobinLimit=Number(t)||3);let l={...s};0===Object.keys(i).length?delete l[u]:l[u]=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)}},t$=async e=>{eI(e);try{let t=await fetch("/api/settings",{cache:"no-store"}),a=(t.ok?await t.json():{}).providerStrategies||{};await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({providerStrategies:{...a,[u]:{...a[u]||{},strictModelAssignment:e}}})})}catch(e){console.log("Error saving Freebuff strict assignment:",e)}},tE=async(e,t)=>{try{(await fetch(`/api/providers/${e}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({providerSpecificData:{assignedModel:t||null}})})).ok&&g(a=>a.map(a=>a.id===e?{...a,providerSpecificData:{...a.providerSpecificData||{},assignedModel:t||null}}:a))}catch(e){console.log("Error saving Freebuff model assignment:",e)}},tO=async e=>{try{let t=await fetch("/api/settings",{cache:"no-store"}),a={...(t.ok?await t.json():{}).providerThinking||{}};e&&"auto"!==e?a[u]={mode:e}:delete a[u],await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({providerThinking:a})})}catch(e){console.log("Error saving thinking config:",e)}},tD=async e=>{let t=K[u];if(t){eO(e);try{await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({[t]:e})})}catch(e){console.log("Error saving auto-ping config:",e)}}};(0,i.useEffect)(()=>{tT(),tC(),tA(),tj()},[tT,tC,tA,tj]),(0,i.useEffect)(()=>{if("cursor"!==u)return void eM([]);let e=f.find(e=>!1!==e.isActive);if(!e?.id)return void eM([]);let t=!1;return fetch(`/api/providers/${e.id}/models`,{cache:"no-store"}).then(async e=>({ok:e.ok,data:await e.json()})).then(({ok:e,data:a})=>{!t&&e&&Array.isArray(a.models)&&a.models.length>0&&eM(a.models)}).catch(()=>{}),()=>{t=!0}},[u,f]),(0,i.useEffect)(()=>{let e=(c.zN[u]||c.fg[u]||c.IS[u]||c.nJ[u])?.modelsFetcher;e&&N(e).then(e_)},[u]);let t_=async(e,t,a=td)=>{let s=`${a}/${e}`;try{let e=await fetch("/api/models/alias",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({model:s,alias:t})});if(e.ok)await tC();else{let t=await e.json();alert(t.error||"Failed to set alias")}}catch(e){console.log("Error setting alias:",e)}},tU=async e=>{try{(await fetch(`/api/models/alias?alias=${encodeURIComponent(e)}`,{method:"DELETE"})).ok&&await tC()}catch(e){console.log("Error deleting alias:",e)}},tM=async(e,t="llm",a=tg)=>{try{let s=await fetch("/api/models/custom",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({providerAlias:a,id:e,type:t})});if(s.ok)await tA(),window.dispatchEvent(new CustomEvent("customModelChanged"));else{let e=await s.json();alert(e.error||"Failed to add custom model")}}catch(e){console.log("Error adding custom model:",e)}},tz=async(e,t="llm",a=tg)=>{try{let s=new URLSearchParams({providerAlias:a,id:e,type:t});(await fetch(`/api/models/custom?${s}`,{method:"DELETE"})).ok&&(await tA(),window.dispatchEvent(new CustomEvent("customModelChanged")))}catch(e){console.log("Error deleting custom model:",e)}},tB=async()=>{if(e5)return;let e=f.find(e=>!1!==e.isActive);if(!e)return void alert((0,j.Tl)("Please add an active Qoder connection first"));e3(!0);try{let t=await fetch(`/api/providers/${e.id}/models`),a=await t.json();if(!t.ok)return void alert(a.error||(0,j.Tl)("Failed to fetch models"));let s=a.models||[];if(0===s.length)return void alert((0,j.Tl)("No models returned"));let i=0;for(let e of s){let t=e.id||e.name;if(!t)continue;let a=t.replace(/^qoder\//,"");ei.some(e=>e.providerAlias===tg&&e.id===a&&"llm"===(e.kind||e.type||"llm"))||Object.values(ea).includes(`${tg}/${a}`)||(await tM(a,"llm",tg),i+=1)}0===i?alert((0,j.Tl)("All models already exist, no new models added")):alert((0,j.Tl)("Successfully added")+` ${i} `+(0,j.Tl)("models"))}catch(e){console.log("Error importing Qoder models:",e),alert((0,j.Tl)("Error fetching models")+": "+e.message)}finally{e3(!1)}},tR=async()=>{if(eW||0===f.length)return;let e=Object.fromEntries(f.map(e=>[e.id,{state:"queued",error:null}]));e2.current=!1,eH(!0),eG(!1),eX(null),eZ(e),e1({total:f.length,completed:0,passed:0,failed:0,stopped:!1});let t=0,a=0;try{for(let e=0;e<f.length;e+=1){if(e2.current){e1({total:f.length,completed:e,passed:t,failed:a,stopped:!0});break}let s=f[e];eX(s.id),eZ(e=>({...e,[s.id]:{state:"testing",error:null}}));try{let e=await fetch(`/api/providers/${s.id}/test`,{method:"POST"}),i=await e.json(),l=!!i.valid;l?t+=1:a+=1,eZ(e=>({...e,[s.id]:{state:l?"success":"failed",error:l?null:i.error||null}}))}catch(e){a+=1,eZ(t=>({...t,[s.id]:{state:"failed",error:e.message||"Test failed"}}))}e1({total:f.length,completed:e+1,passed:t,failed:a,stopped:!1}),e<f.length-1&&await new Promise(e=>setTimeout(e,1e3))}}finally{eX(null),eH(!1),eG(!1),e2.current=!1}},tK=async e=>{eF({title:"Delete Connection",message:"Delete this connection?",onConfirm:async()=>{eF(null);try{(await fetch(`/api/providers/${e}`,{method:"DELETE"})).ok&&g(t=>t.filter(t=>t.id!==e))}catch(e){console.log("Error deleting connection:",e)}}})},tL=()=>{tT(),_(!1)},tF=async e=>{q("");try{let t=await fetch("/api/providers",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:u,...e})}),a=null;try{a=await t.json()}catch{a=null}if(t.ok){await tT(),F(!1);return}q(a?.error||"Failed to save connection")}catch(e){console.log("Error saving connection:",e),q("Failed to save connection")}},tJ=async e=>{try{(await fetch(`/api/providers/${ee.id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})).ok&&(await tT(),G(!1))}catch(e){console.log("Error updating connection:",e)}},tq=async(e,t)=>{try{(await fetch(`/api/providers/${e}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({isActive:t})})).ok&&g(a=>a.map(a=>a.id===e?{...a,isActive:t}:a))}catch(e){console.log("Error updating connection status:",e)}},tW=async(e,t)=>{let a=[...f];[a[e],a[t]]=[a[t],a[e]],g(a);try{await Promise.all([fetch(`/api/providers/${a[e].id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({priority:e})}),fetch(`/api/providers/${a[t].id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({priority:t})})])}catch(e){console.log("Error swapping priority:",e),await tT()}},tH=f.filter(e=>ef.includes(e.id)),{currentPage:tV,totalPages:tG,items:tQ,start:tX}=function(e=[],t=1){let a=Array.isArray(e)?e:[],s=a.length,i=Math.max(1,Math.ceil(s/10)),l=Math.floor(Number(t)),r=Math.min(Number.isFinite(l)&&l>0?l:1,i),o=(r-1)*10,n=a.slice(o,o+10);return{currentPage:r,totalPages:i,totalItems:s,start:o,items:n,pageSize:10}}(f,ey),tY=f.length>0&&ef.length===f.length;(0,i.useEffect)(()=>{eg(e=>e.filter(e=>f.some(t=>t.id===e)))},[f]);let tZ=(()=>{if(0===tH.length)return"";let e=new Set(tH.map(e=>e.providerSpecificData?.proxyPoolId||"__none__"));if(1===e.size){let t=[...e][0];if("__none__"===t)return"All selected currently unbound";let a=$.find(e=>e.id===t);return`All selected currently bound to ${a?.name||t}`}return"Selected connections have mixed proxy bindings"})(),t0=()=>{ew||Z(!1)},t1=async(e,t)=>{let a=await fetch(`/api/providers/${e}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!a.ok)throw Error((await a.json().catch(()=>({}))).error||`Proxy update failed (${a.status})`);return a.json()},t2=async e=>{eN(!0);try{let t=[];for(let{connectionId:a,proxyPoolId:s,proxyPoolIds:i,proxyRotationStrategy:l}of e)try{let e=i?{proxyPoolIds:i,proxyRotationStrategy:l}:{proxyPoolId:s};await t1(a,e)}catch(e){console.log("Error applying proxy for",a,e),t.push(a)}if(await tT(),t.length>0)return void alert(`Updated with ${t.length} failed request(s). Retry the selected connections.`);Z(!1),eg([]),ej("__none__")}finally{eN(!1)}},t5=e=>t2((ef.length>0?tH:f).map(t=>({connectionId:t.id,proxyPoolId:e}))),t3=(0,s.jsxs)("div",{className:"flex min-w-0 flex-col divide-y divide-black/[0.03] dark:divide-white/[0.03]",children:[tQ.map((e,t)=>{let a,i=tX+t;return(0,s.jsxs)("div",{className:"flex min-w-0 items-stretch",children:[(0,s.jsx)("div",{className:"flex shrink-0 items-center pl-1 sm:pl-2",children:(0,s.jsx)("input",{type:"checkbox",checked:(a=e.id,ef.includes(a)),onChange:()=>{var t;return t=e.id,void eg(e=>e.includes(t)?e.filter(e=>e!==t):[...e,t])},className:"h-4 w-4 rounded border-gray-300 text-primary focus:ring-primary"})}),(0,s.jsx)("div",{className:"flex-1 min-w-0",children:(0,s.jsx)(P,{connection:e,proxyPools:$,isOAuth:ti,isFirst:0===i,isLast:i===f.length-1,onMoveUp:()=>tW(i,i-1),onMoveDown:()=>tW(i,i+1),onToggleActive:t=>tq(e.id,t),autoPing:K[u]&&"oauth"===e.authType?{on:!0===eE.connections[e.id],onToggle:t=>{var a;return a=e.id,void tD({...eE,connections:{...eE.connections,[a]:t}})},provider:u}:null,onUpdateProxy:async t=>{try{let a="object"==typeof t?t:{proxyPoolId:t||null};if((await fetch(`/api/providers/${e.id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)})).ok){let t={...e.providerSpecificData};a.proxyPoolIds?(t.proxyPoolIds=a.proxyPoolIds,t.proxyRotationStrategy=a.proxyRotationStrategy,delete t.proxyPoolId):(a.proxyPoolId?t.proxyPoolId=a.proxyPoolId:delete t.proxyPoolId,delete t.proxyPoolIds,delete t.proxyRotationStrategy),g(a=>a.map(a=>a.id===e.id?{...a,providerSpecificData:t}:a))}}catch(e){console.log("Error updating proxy:",e)}},onEdit:()=>{et(e),G(!0)},onDelete:()=>tK(e.id),oneByOneStatus:eY[e.id]||null,modelAssignmentOptions:"freebuff"===u?ty:null,onModelAssignmentChange:"freebuff"===u?t=>tE(e.id,t):null,strictModelAssignment:eT})})]},e.id)}),f.length>10&&(0,s.jsx)(d.Pagination,{currentPage:tV,pageSize:10,totalItems:f.length,onPageChange:eb})]}),t4=$.filter(e=>!0===e.isActive),t6=(0,s.jsx)(d.Modal,{isOpen:Y,onClose:t0,title:ef.length>0?`Apply Proxy (${ef.length} selected)`:`Apply Proxy (All ${f.length} connections)`,children:(0,s.jsxs)("div",{className:"flex flex-col gap-4",children:[tZ&&(0,s.jsx)("p",{className:"text-xs text-text-muted bg-surface-2 px-3 py-2 rounded-lg border border-border/50",children:tZ}),(0,s.jsxs)("div",{className:"flex flex-col divide-y divide-border/30 border border-border/50 rounded-xl overflow-hidden bg-surface",children:[(0,s.jsxs)("div",{className:"p-3 flex flex-col gap-1",children:[(0,s.jsx)("p",{className:"px-3 pb-1 text-[10px] font-semibold uppercase tracking-wider text-text-muted",children:"Dynamic Strategies"}),(0,s.jsxs)("button",{type:"button",onClick:()=>{let e=$.filter(e=>!0===e.isActive);return 0===e.length?void alert("No active proxy pools available."):t2((ef.length>0?tH:f).map((t,a)=>({connectionId:t.id,proxyPoolId:e[a%e.length].id})))},disabled:ew||0===t4.length,className:"flex items-center gap-3 rounded-lg px-3 py-2 text-left transition-colors hover:bg-surface-2 disabled:cursor-not-allowed disabled:opacity-50",children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-text-muted text-[20px]",children:"sync_alt"}),(0,s.jsxs)("div",{className:"flex flex-col",children:[(0,s.jsx)("span",{className:"text-sm font-medium text-text-main",children:"One-to-one (rotate)"}),(0,s.jsx)("span",{className:"text-[10px] text-text-muted mt-0.5",children:"Distribute active proxy pools round-robin"})]})]}),["fill-first","round-robin","random","smart"].map(e=>(0,s.jsxs)("button",{type:"button",onClick:()=>{let t;return(t=t4.map(e=>e.id).filter(e=>$.find(t=>t.id===e)?.isActive===!0)).length?t2((ef.length>0?tH:f).map(a=>({connectionId:a.id,proxyPoolIds:t,proxyRotationStrategy:e}))):void alert("No active proxy pools selected.")},disabled:ew||0===t4.length,className:"flex items-center gap-3 rounded-lg px-3 py-2 text-left transition-colors hover:bg-surface-2 disabled:cursor-not-allowed disabled:opacity-50",children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-text-muted text-[20px]",children:"autorenew"}),(0,s.jsxs)("div",{className:"flex flex-col",children:[(0,s.jsxs)("span",{className:"text-sm font-medium text-text-main capitalize",children:[e," strategy"]}),(0,s.jsx)("span",{className:"text-[10px] text-text-muted mt-0.5",children:"smart"===e?"Bypass pools marked unfit for provider/model":`Rotate over all active pools using ${e}`})]})]},e))]}),(0,s.jsxs)("div",{className:"p-3 flex flex-col gap-1",children:[(0,s.jsx)("p",{className:"px-3 pb-1 text-[10px] font-semibold uppercase tracking-wider text-text-muted",children:"Static Assignment"}),(0,s.jsxs)("button",{type:"button",onClick:()=>t5(null),disabled:ew,className:"flex items-center gap-3 rounded-lg px-3 py-2 text-left transition-colors hover:bg-surface-2 disabled:cursor-not-allowed disabled:opacity-50",children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-text-muted text-[20px]",children:"link_off"}),(0,s.jsxs)("div",{className:"flex flex-col",children:[(0,s.jsx)("span",{className:"text-sm font-medium text-text-main",children:"None (unbind all)"}),(0,s.jsx)("span",{className:"text-[10px] text-text-muted mt-0.5",children:"Direct routing without proxy"})]})]}),$.map(e=>(0,s.jsxs)("button",{type:"button",onClick:()=>t5(e.id),disabled:ew||!0!==e.isActive,className:"flex items-center gap-3 rounded-lg px-3 py-2 text-left transition-colors hover:bg-surface-2 disabled:cursor-not-allowed disabled:opacity-50",children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-text-muted text-[20px]",children:"lan"}),(0,s.jsxs)("div",{className:"flex flex-col min-w-0 flex-1",children:[(0,s.jsx)("span",{className:"truncate text-sm font-medium text-text-main",children:e.name}),(0,s.jsx)("span",{className:"text-[10px] text-text-muted truncate mt-0.5",children:e.proxyUrl})]}),!0!==e.isActive&&(0,s.jsx)(d.Badge,{variant:"secondary",size:"sm",className:"ml-auto shrink-0",children:"inactive"})]},e.id))]})]}),ew&&(0,s.jsx)("p",{className:"text-xs text-text-muted animate-pulse px-1",children:"Applying proxy configuration..."}),(0,s.jsx)(d.Button,{onClick:t0,variant:"ghost",fullWidth:!0,disabled:ew,children:"Cancel"})]})}),t8=async e=>{if(!ep.has(e)){ex(t=>new Set(t).add(e));try{let t=await fetch("/api/models/test",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({model:`${tg}/${e}`})}),a=await t.json();ed(t=>({...t,[e]:a.ok?"ok":"error"})),em(a.ok?"":a.error||"Model not reachable")}catch{ed(t=>({...t,[e]:"error"})),em("Network error")}finally{ex(t=>{let a=new Set(t);return a.delete(e),a})}}};return w?(0,s.jsxs)("div",{className:"flex flex-col gap-8",children:[(0,s.jsx)(d.CardSkeleton,{}),(0,s.jsx)(d.CardSkeleton,{})]}):ta?(0,s.jsxs)("div",{className:"flex min-w-0 flex-col gap-6 px-1 sm:gap-8 sm:px-0",children:[(0,s.jsxs)("div",{className:"min-w-0",children:[(0,s.jsxs)(o(),{href:"/dashboard/providers",className:"inline-flex items-center gap-1 text-sm text-text-muted hover:text-primary transition-colors mb-4",children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-lg",children:"arrow_back"}),"Back to Providers"]}),(0,s.jsxs)("div",{className:"flex min-w-0 items-center gap-3 sm:gap-4",children:[(0,s.jsx)(n.A,{providerId:ta.id,size:48,alt:ta.name,className:"shrink-0 rounded-lg",fallbackText:ta.textIcon||ta.id.slice(0,2).toUpperCase(),fallbackColor:ta.color}),(0,s.jsxs)("div",{className:"min-w-0",children:[(0,s.jsxs)("div",{className:"flex items-center gap-3 flex-wrap",children:[(0,s.jsx)("h1",{className:"truncate text-2xl font-semibold tracking-tight sm:text-3xl",children:ta.name}),(ta.notice?.apiKeyUrl||ta.notice?.signupUrl||ta.website)&&(0,s.jsxs)("a",{href:ta.notice?.apiKeyUrl||ta.notice?.signupUrl||ta.website,target:"_blank",rel:"noopener noreferrer",className:"text-xs text-primary hover:underline inline-flex items-center gap-1",children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-sm",children:"open_in_new"}),ta.notice?.apiKeyUrl?"Get API Key":"Sign up / Learn more"]})]}),(0,s.jsxs)("p",{className:"text-text-muted",children:[f.length," connection",1===f.length?"":"s"]})]})]})]}),ta.deprecated&&(0,s.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,s.jsx)("span",{className:"material-symbols-outlined text-[16px] text-yellow-500 mt-0.5 shrink-0",children:"warning"}),(0,s.jsx)("p",{className:"text-xs text-red-600 dark:text-yellow-400 leading-relaxed",children:ta.deprecationNotice})]}),ta.notice?.text&&!ta.deprecated&&(0,s.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,s.jsx)("span",{className:"material-symbols-outlined text-[16px] text-blue-500 shrink-0",children:"info"}),(0,s.jsx)("p",{className:"min-w-0 flex-1 text-xs leading-relaxed text-blue-600 dark:text-blue-400",children:ta.notice.text}),ta.notice.apiKeyUrl&&(0,s.jsx)("a",{href:ta.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 →"})]}),tp&&T&&(0,s.jsx)(d.Card,{children:(0,s.jsxs)("div",{className:"mb-4 flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between",children:[(0,s.jsxs)("div",{className:"min-w-0",children:[(0,s.jsx)("h2",{className:"text-lg font-semibold",children:tm?"Anthropic Compatible Details":"OpenAI Compatible Details"}),(0,s.jsxs)("p",{className:"break-all text-sm text-text-muted",children:[tm?"Messages API":"responses"===T.apiType?"Responses API":"Chat Completions"," \xb7 ",(T.baseUrl||"").replace(/\/$/,""),"/",tm?"messages":"responses"===T.apiType?"responses":"chat/completions"]})]}),(0,s.jsxs)("div",{className:"grid grid-cols-1 gap-2 sm:flex sm:items-center",children:[(0,s.jsx)(d.Button,{size:"sm",icon:"add",onClick:()=>{q(""),F(!0)},className:"w-full sm:w-auto",children:"Add API Key"}),(0,s.jsx)(d.Button,{size:"sm",variant:"secondary",icon:"edit",onClick:()=>X(!0),className:"w-full sm:w-auto",children:"Edit"}),(0,s.jsx)(d.Button,{size:"sm",variant:"secondary",icon:"delete",onClick:async()=>{eF({title:"Delete Compatible Node",message:`Delete this ${tm?"Anthropic":"OpenAI"} Compatible node?`,onConfirm:async()=>{eF(null);try{(await fetch(`/api/provider-nodes/${u}`,{method:"DELETE"})).ok&&x.push("/dashboard/providers")}catch(e){console.log("Error deleting provider node:",e)}}})},className:"w-full sm:w-auto",children:"Delete"})]})]})}),tr?(0,s.jsx)(d.NoAuthProxyCard,{providerId:u}):(0,s.jsxs)(d.Card,{children:[(0,s.jsxs)("div",{className:"mb-4 flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[(0,s.jsx)("h2",{className:"text-lg font-semibold",children:"Connections"}),(0,s.jsxs)("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:gap-4",children:[f.length>0&&$.length>0&&(0,s.jsx)(d.Button,{size:"sm",variant:"secondary",icon:"lan",onClick:()=>Z(!0),children:"Apply Proxy"}),f.length>0&&(0,s.jsxs)(s.Fragment,{children:[ef.length>0&&(0,s.jsxs)(d.Button,{size:"sm",variant:"danger",icon:"delete",onClick:()=>{let e=ef.length;0!==e&&eF({title:`Delete ${e} Connection${e>1?"s":""}`,message:`Delete ${e} connection${e>1?"s":""}? This cannot be undone.`,onConfirm:async()=>{eF(null);let e=0,t=[...ef];for(let a of t)try{(await fetch(`/api/providers/${a}`,{method:"DELETE"})).ok||(e+=1)}catch(t){console.log("Error deleting connection:",t),e+=1}g(e=>e.filter(e=>!t.includes(e.id))),eg([]),e>0&&alert(`Deleted ${t.length-e} connection(s), ${e} failed.`)}})},children:["Delete Selected (",ef.length,")"]}),(0,s.jsx)(d.Button,{size:"sm",variant:"secondary",icon:"sync",onClick:tR,disabled:eW,children:eW?"Testing Connection One-by-One...":"Test Connection One-by-One"}),eW&&(0,s.jsx)(d.Button,{size:"sm",variant:"ghost",icon:"stop",onClick:()=>{eW&&(e2.current=!0,eG(!0))},disabled:eV,children:eV?"Stopping...":"Stop"})]}),(0,s.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,s.jsx)("span",{className:"text-xs text-text-muted font-medium",children:"Round Robin"}),(0,s.jsx)(d.Toggle,{checked:"round-robin"===ek,onChange:e=>{let t=e?"round-robin":null,a=e?eC||"1":eC;e&&!eC&&eA("1"),eS(t),tP(t,a)}}),"round-robin"===ek&&(0,s.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,s.jsx)("span",{className:"text-xs text-text-muted",children:"Sticky:"}),(0,s.jsx)("input",{type:"number",min:1,value:eC,onChange:e=>{var t;eA(t=e.target.value),tP("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"})]})]}),"freebuff"===u&&(0,s.jsxs)("div",{className:"flex flex-wrap items-center gap-2 border-t border-black/[0.03] pt-2 dark:border-white/[0.03]",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("span",{className:"text-xs text-text-muted font-medium",children:"Strict Model Assignment"}),(0,s.jsx)("p",{className:"text-[10px] text-text-muted",children:"Only assigned accounts can serve each Freebuff model."})]}),(0,s.jsx)(d.Toggle,{checked:eT,onChange:t$})]})]})]}),0===f.length?(0,s.jsxs)("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[(0,s.jsxs)("div",{className:"flex items-center gap-3",children:[(0,s.jsx)("div",{className:"inline-flex items-center justify-center w-9 h-9 rounded-full bg-primary/10 text-primary shrink-0",children:(0,s.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:ti?"lock":"key"})}),(0,s.jsxs)("div",{className:"min-w-0",children:[(0,s.jsx)("p",{className:"text-sm text-text-muted",children:"No connections yet"}),tx&&(0,s.jsxs)("p",{className:"text-xs text-text-muted",children:["Choose ",tu," or ",th,"."]})]})]}),(0,s.jsx)("div",{className:"flex gap-2",children:tx?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(d.Button,{size:"sm",icon:"lock",variant:"secondary",onClick:e9,children:tu}),(0,s.jsx)(d.Button,{size:"sm",icon:"key",onClick:te,children:th})]}):(0,s.jsxs)(s.Fragment,{children:[!tp&&"iflow"===u&&(0,s.jsx)(d.Button,{size:"sm",icon:"cookie",variant:"secondary",onClick:()=>B(!0),children:"Cookie"}),"codex"===u&&(0,s.jsx)(d.Button,{size:"sm",icon:"playlist_add",variant:"secondary",onClick:()=>H(!0),children:(0,j.Tl)("Bulk Add")}),(0,s.jsx)(d.Button,{size:"sm",icon:"add",onClick:tt,children:tp?"Add API Key":"iflow"===u?"OAuth":"Add Connection"})]})})]}):(0,s.jsxs)(s.Fragment,{children:[e0&&(0,s.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,s.jsxs)("div",{className:"flex flex-wrap items-center gap-3",children:[(0,s.jsxs)("span",{children:["Total: ",e0.total]}),(0,s.jsxs)("span",{children:["Completed: ",e0.completed]}),(0,s.jsxs)("span",{children:["Passed: ",e0.passed]}),(0,s.jsxs)("span",{children:["Failed: ",e0.failed]}),e0.stopped&&(0,s.jsx)("span",{className:"text-amber-600 dark:text-amber-400",children:"Stopped"}),eW&&eQ&&(0,s.jsxs)("span",{children:["Running: ",f.find(e=>e.id===eQ)?.name||eQ]})]})}),f.length>0&&(0,s.jsx)("div",{className:"mb-3 flex items-center gap-2 border-b border-black/[0.03] pb-2 dark:border-white/[0.03]",children:(0,s.jsxs)("label",{className:"flex cursor-pointer items-center gap-1.5 text-xs text-text-muted hover:text-primary",children:[(0,s.jsx)("input",{type:"checkbox",checked:tY,onChange:()=>{tY?eg([]):eg(f.map(e=>e.id))},className:"h-3.5 w-3.5 rounded border-gray-300 text-primary focus:ring-primary"}),"Select All"]})}),t3,!tp&&(0,s.jsxs)("div",{className:"mt-4 grid grid-cols-1 gap-2 sm:flex",children:["iflow"===u&&(0,s.jsx)(d.Button,{size:"sm",icon:"cookie",variant:"secondary",onClick:()=>B(!0),title:"Add connection using browser cookie",className:"w-full sm:w-auto",children:"Cookie"}),"codex"===u&&(0,s.jsx)(d.Button,{size:"sm",icon:"playlist_add",variant:"secondary",onClick:()=>H(!0),title:(0,j.Tl)("Bulk import codex accounts from JSON"),className:"w-full sm:w-auto",children:(0,j.Tl)("Bulk Add")}),tx?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(d.Button,{size:"sm",icon:"lock",variant:"secondary",onClick:e9,className:"w-full sm:w-auto",children:tu}),(0,s.jsx)(d.Button,{size:"sm",icon:"key",onClick:te,className:"w-full sm:w-auto",children:th})]}):(0,s.jsx)(d.Button,{size:"sm",icon:"add",onClick:tt,className:"w-full sm:w-auto",children:"Add"})]})]})]}),(0,s.jsxs)(d.Card,{children:[(0,s.jsxs)("div",{className:"mb-4 flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between",children:[(0,s.jsxs)("div",{className:"flex items-center gap-3",children:[(0,s.jsx)("h2",{className:"text-lg font-semibold",children:"Available Models"}),tb&&(0,s.jsx)("select",{value:eP,onChange:e=>{var t;e$(t=e.target.value),tO(t)},title:"Appends (level) suffix to copied model names",className:"rounded-md border border-border bg-background px-2 py-1 text-xs focus:border-primary focus:outline-none",children:tb.map(e=>(0,s.jsx)("option",{value:e,children:`Thinking: ${e.charAt(0).toUpperCase()+e.slice(1)}`},e))})]}),!tp&&(r=[...tn,...ez.filter(e=>!tn.some(t=>t.id===e.id))].filter(e=>{let t=(0,m.CP)(e);return!t||"llm"===t}).map(e=>e.id).filter(e=>!eR.includes(e)),(0,s.jsxs)("div",{className:"flex gap-2",children:[eR.length>0&&(0,s.jsx)(d.Button,{size:"sm",variant:"secondary",icon:"restart_alt",onClick:tS,children:"Active All"}),r.length>0&&(0,s.jsx)(d.Button,{size:"sm",variant:"secondary",icon:"block",onClick:()=>tk(r),children:"Disable All"})]}))]}),!!ec&&(0,s.jsx)("p",{className:"text-xs text-red-500 mb-3 break-words",children:ec}),(()=>{let e,t,a;if(tp)return(0,s.jsx)(A,{providerStorageAlias:tg,providerDisplayAlias:tv,modelAliases:ea,customModels:ei,copied:e4,onCopy:e6,onSetAlias:t_,onDeleteAlias:tU,onAddCustomModel:e=>tM(e,"llm",tg),onDeleteCustomModel:e=>tz(e,"llm",tg),connections:f,isAnthropic:tm});let i=[...tn,...ez.filter(e=>!tn.some(t=>t.id===e.id))].filter(e=>{let t=(0,m.CP)(e);return!t||"llm"===t}),l=new Set(eR),r=i.filter(e=>!l.has(e.id)),o=i.filter(e=>l.has(e.id)),n=k({customModels:ei,modelAliases:ea,providerAlias:tg,builtInModels:tn,type:"llm"});return(0,s.jsxs)("div",{className:"flex flex-wrap gap-3",children:[n.map(e=>(0,s.jsx)(S,{model:{id:e.id,name:e.name},fullModel:`${tv}/${e.id}`,alias:e.alias,copied:e4,onCopy:e6,onSetAlias:()=>{},onDeleteAlias:()=>{"custom"===e.source?tz(e.id,"llm",tg):tU(e.alias)},testStatus:en[e.id],onTest:f.length>0||tr?()=>t8(e.id):void 0,isTesting:ep.has(e.id),isCustom:!0,isFree:!1,caps:h(`${u}/${e.id}`),thinkingSuffix:tf(e.id)},`${e.source}-${e.fullModel}`)),r.map(e=>{let t=`${tg}/${e.id}`,a=`${u}/${e.id}`,i=Object.entries(ea).find(([,e])=>e===t||e===a)?.[0];return(0,s.jsx)(S,{model:e,fullModel:`${tv}/${e.id}`,alias:i,copied:e4,onCopy:e6,onSetAlias:t=>t_(e.id,t,tg),onDeleteAlias:()=>tU(i),testStatus:en[e.id],onTest:f.length>0||tr?()=>t8(e.id):void 0,isTesting:ep.has(e.id),isFree:e.isFree,onDisable:()=>tw(e.id),caps:h(`${u}/${e.id}`),thinkingSuffix:tf(e.id)},e.id)}),(0,s.jsxs)("button",{onClick:()=>eh(!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,s.jsx)("span",{className:"material-symbols-outlined text-sm",children:"add"}),"Add Model"]}),"qoder"===u&&f.some(e=>!1!==e.isActive)&&(0,s.jsxs)("button",{onClick:tB,disabled:e5,className:"flex w-full items-center justify-center gap-1.5 rounded-lg border border-dashed border-blue-500/40 px-3 py-2 text-xs text-blue-600 dark:text-blue-400 transition-colors hover:border-blue-500 hover:bg-blue-500/5 sm:w-auto disabled:opacity-50 disabled:cursor-not-allowed",children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-sm",style:e5?{animation:"spin 1s linear infinite"}:void 0,children:e5?"progress_activity":"download"}),e5?(0,j.Tl)("Fetching..."):(0,j.Tl)("Fetch Qoder Models")]}),eD.length>0&&(e=new Set([...Object.values(ea),...n.map(e=>e.fullModel)]),t=new Set(tn.map(e=>e.id)),0===(a=eD.filter(a=>!e.has(`${tg}/${a.id}`)&&!t.has(a.id))).length?null:(0,s.jsxs)("div",{className:"w-full mt-2",children:[(0,s.jsx)("p",{className:"text-xs text-text-muted mb-2",children:"Suggested free models (≥200k context):"}),(0,s.jsx)("div",{className:"flex flex-wrap gap-2",children:a.map(e=>(0,s.jsxs)("button",{onClick:async()=>{await tM(e.id,"llm",tg)},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,s.jsx)("span",{className:"material-symbols-outlined text-[13px]",children:"add"}),e.id.split("/").pop()]},e.id))})]})),o.length>0&&(0,s.jsxs)("div",{className:"w-full mt-2",children:[(0,s.jsxs)("p",{className:"text-xs text-text-muted mb-2",children:["Disabled models (",o.length,"):"]}),(0,s.jsx)("div",{className:"flex flex-wrap gap-2",children:o.map(e=>(0,s.jsxs)("button",{onClick:()=>tN(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,s.jsx)("span",{className:"material-symbols-outlined text-[13px]",children:"add"}),e.id]},e.id))})]})]})})()]}),t6,"kiro"===u?(0,s.jsx)(d.KiroOAuthWrapper,{isOpen:O,providerInfo:ta,onSuccess:tL,onClose:()=>_(!1)}):"cursor"===u?(0,s.jsx)(d.CursorAuthModal,{isOpen:O,onSuccess:tL,onClose:()=>_(!1)}):"gitlab"===u?(0,s.jsx)(d.GitLabAuthModal,{isOpen:O,providerInfo:ta,onSuccess:tL,onClose:()=>_(!1)}):(0,s.jsx)(d.OAuthModal,{isOpen:O,provider:u,providerInfo:ta,onSuccess:tL,onClose:()=>_(!1)}),"iflow"===u&&(0,s.jsx)(d.IFlowCookieModal,{isOpen:M,onSuccess:()=>{tT(),B(!1)},onClose:()=>B(!1)}),(0,s.jsx)(D,{isOpen:L,provider:u,providerName:ta.name,isCompatible:tp,isAnthropic:tm,authType:ta?.authType,authHint:ta?.authHint,website:ta?.website,proxyPools:$,error:J,existingNames:f.map(e=>e.name).filter(Boolean),onSave:tF,onBulkDone:tT,onClose:()=>{q(""),F(!1)}}),(0,s.jsx)(d.EditConnectionModal,{isOpen:V,connection:ee,proxyPools:$,onSave:tJ,onClose:()=>G(!1)}),tp&&(0,s.jsx)(U,{isOpen:Q,node:T,onSave:tI,onClose:()=>X(!1),isAnthropic:tm}),!tp&&(0,s.jsx)(z,{isOpen:eu,providerAlias:tg,providerDisplayAlias:tv,onSave:async e=>{await tM(e,"llm",tg),eh(!1)},onClose:()=>eh(!1)}),"codex"===u&&(0,s.jsx)(R,{isOpen:W,onClose:()=>H(!1),onSuccess:tT}),(0,s.jsx)(d.ConfirmModal,{isOpen:eJ,onClose:()=>eq(!1),onConfirm:()=>{(window.localStorage.setItem(e8,"true"),eq(!1),ti)?e7():te()},title:"Risk Notice",message:ta?.deprecationNotice,confirmText:"I Understand, Continue",cancelText:"Cancel",variant:"danger"}),(0,s.jsx)(d.ConfirmModal,{isOpen:!!eL,onClose:()=>eF(null),onConfirm:eL?.onConfirm,title:eL?.title||"Confirm",message:eL?.message,variant:"danger"})]}):(0,s.jsxs)("div",{className:"text-center py-20",children:[(0,s.jsx)("p",{className:"text-text-muted",children:"Provider not found"}),(0,s.jsx)(o(),{href:"/dashboard/providers",className:"text-primary mt-4 inline-block",children:"Back to Providers"})]})}},21863:(e,t,a)=>{"use strict";function s(e,t){return!1===e?"default":"active"===t||"success"===t?"success":"error"===t||"expired"===t||"unavailable"===t?"error":"default"}a.d(t,{g:()=>s})},68810:(e,t,a)=>{Promise.resolve().then(a.bind(a,6))}},e=>{e.O(0,[3885,2318,4385,2940,7236,5479,2147,3204,7358],()=>e(e.s=68810)),_N_E=e.O()}]);
@@ -0,0 +1 @@
1
+ (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[8460],{48271:(e,t,r)=>{"use strict";r.d(t,{gm:()=>a});let s=new Map;function a(e,t={}){s.delete(JSON.stringify([String(e),t?.method||"GET",t?.headers||{},t?.body||null]))}},48504:(e,t,r)=>{"use strict";r.r(t),r.d(t,{default:()=>N});var s=r(15102),a=r(82030),l=r(92940),i=r(31704),n=r(19965);function o(e,t){return"kiro"===t?["oauth","apikey","api_key"]:Array.isArray(e?.authModes)&&e.authModes.length>0?e.authModes:e?.hasOAuth?["oauth"]:["apikey"]}var c=r(11434),d=r(31038),m=r(93885),p=r.n(m),x=r(25795),u=r(71389);r(48271);let h={available:{icon:"check_circle",color:"#22c55e",label:"Available"},cooldown:{icon:"schedule",color:"#f59e0b",label:"Cooldown"},unavailable:{icon:"error",color:"#ef4444",label:"Unavailable"},unknown:{icon:"help",color:"#6b7280",label:"Unknown"}};function f(){let[e,t]=(0,a.useState)(null),[r,i]=(0,a.useState)(!0),[n,o]=(0,a.useState)(!1),[c,d]=(0,a.useState)(null),m=(0,a.useRef)(null),p=(0,x.i)(),u=(0,a.useCallback)(async()=>{try{let e=await fetch("/api/models/availability");if(e.ok){let r=await e.json();t(r)}}catch{}finally{i(!1)}},[]);(0,a.useEffect)(()=>{u();let e=setInterval(u,3e4);return()=>clearInterval(e)},[u]),(0,a.useEffect)(()=>{let e=e=>{m.current&&!m.current.contains(e.target)&&o(!1)};return n&&document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[n]);let f=async(e,t)=>{d(`${e}:${t}`);try{(await fetch("/api/models/availability",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"clearCooldown",provider:e,model:t})})).ok?(p.success(`Cooldown cleared for ${t}`),await u()):p.error("Failed to clear cooldown")}catch{p.error("Failed to clear cooldown")}finally{d(null)}};if(r)return null;let b=e?.models||[],g=0===(e?.unavailableCount||b.filter(e=>"available"!==e.status).length),y={};return b.forEach(e=>{if("available"===e.status)return;let t=e.provider||"unknown";y[t]||(y[t]=[]),y[t].push(e)}),(0,s.jsx)("div",{className:"relative",ref:m,children:n&&(0,s.jsxs)("div",{className:"absolute top-full right-0 mt-2 w-80 bg-surface border border-border rounded-xl shadow-2xl z-50 overflow-hidden",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border bg-bg",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-[16px]",style:{color:g?"#22c55e":"#f59e0b"},children:g?"verified":"warning"}),(0,s.jsx)("span",{className:"text-sm font-semibold text-text-main",children:"Model Status"})]}),(0,s.jsx)("button",{type:"button",onClick:u,className:"p-1 rounded-lg hover:bg-surface text-text-muted hover:text-text-main transition-colors",title:"Refresh",children:(0,s.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"refresh"})})]}),(0,s.jsx)("div",{className:"px-4 py-3 max-h-60 overflow-y-auto",children:g?(0,s.jsx)("p",{className:"text-sm text-text-muted text-center py-2",children:"All models are responding normally."}):(0,s.jsx)("div",{className:"flex flex-col gap-2.5",children:Object.entries(y).map(([e,t])=>(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:"text-xs font-semibold text-text-main mb-1.5 capitalize",children:e}),(0,s.jsx)("div",{className:"flex flex-col gap-1",children:t.map(e=>{let t=h[e.status]||h.unknown,r=c===`${e.provider}:${e.model}`;return(0,s.jsxs)("div",{className:"flex items-center justify-between px-2.5 py-1.5 rounded-lg bg-surface/30",children:[(0,s.jsxs)("div",{className:"flex items-center gap-1.5 min-w-0",children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-[14px] shrink-0",style:{color:t.color},children:t.icon}),(0,s.jsx)("span",{className:"font-mono text-xs text-text-main truncate",children:e.model})]}),"cooldown"===e.status&&(0,s.jsx)(l.Button,{size:"sm",variant:"ghost",onClick:()=>f(e.provider,e.model),disabled:r,className:"text-[10px] px-1.5! py-0.5! ml-2",children:r?"...":"Clear"})]},`${e.provider}-${e.model}`)})})]},e))})})]})})}let b={openai:{title:"Add OpenAI Compatible",type:"openai-compatible",defaultBaseUrl:"https://api.openai.com/v1",namePlaceholder:"OpenAI Compatible (Prod)",prefixPlaceholder:"oc-prod",baseUrlHint:"Use the base URL (ending in /v1) for your OpenAI-compatible API.",modelIdPlaceholder:"e.g. gpt-4, claude-3-opus",errorLabel:"OpenAI Compatible",hasApiType:!0},anthropic:{title:"Add Anthropic Compatible",type:"anthropic-compatible",defaultBaseUrl:"https://api.anthropic.com/v1",namePlaceholder:"Anthropic Compatible (Prod)",prefixPlaceholder:"ac-prod",baseUrlHint:"Use the base URL (ending in /v1) for your Anthropic-compatible API. The system will append /messages.",modelIdPlaceholder:"e.g. claude-3-opus",errorLabel:"Anthropic Compatible",hasApiType:!1}},g=[{value:"chat",label:"Chat Completions"},{value:"responses",label:"Responses API"}],y=function({variant:e,isOpen:t,onClose:r,onCreated:i}){let n=b[e],o=()=>({name:"",prefix:"",...n.hasApiType?{apiType:"chat"}:{},baseUrl:n.defaultBaseUrl}),[c,d]=(0,a.useState)(o),[m,p]=(0,a.useState)(!1),[x,u]=(0,a.useState)(""),[h,f]=(0,a.useState)(""),[y,v]=(0,a.useState)(!1),[j,N]=(0,a.useState)(null);(0,a.useEffect)(()=>{n.hasApiType?d(e=>({...e,baseUrl:n.defaultBaseUrl})):t&&(N(null),u(""),f(""))},[n.hasApiType?c.apiType:t]);let w=async()=>{if(c.name.trim()&&c.prefix.trim()&&c.baseUrl.trim()){p(!0);try{let e=await fetch("/api/provider-nodes",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:c.name,prefix:c.prefix,...n.hasApiType?{apiType:c.apiType}:{},baseUrl:c.baseUrl,type:n.type})}),t=await e.json();e.ok&&(i(t.node),d(o()),u(""),N(null))}catch(e){console.log(`Error creating ${n.errorLabel} node:`,e)}finally{p(!1)}}},k=async()=>{v(!0);try{let e=await fetch("/api/provider-nodes/validate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({baseUrl:c.baseUrl,apiKey:x,type:n.type,modelId:h.trim()||void 0})}),t=await e.json();N(t)}catch{N({valid:!1,error:"Network error"})}finally{v(!1)}};return(0,s.jsx)(l.Modal,{isOpen:t,title:n.title,onClose:r,children:(0,s.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,s.jsx)(l.Input,{label:"Name",value:c.name,onChange:e=>d({...c,name:e.target.value}),placeholder:n.namePlaceholder,hint:"Required. A friendly label for this node."}),(0,s.jsx)(l.Input,{label:"Prefix",value:c.prefix,onChange:e=>d({...c,prefix:e.target.value}),placeholder:n.prefixPlaceholder,hint:"Required. Used as the provider prefix for model IDs."}),n.hasApiType&&(0,s.jsx)(l.Select,{label:"API Type",options:g,value:c.apiType,onChange:e=>d({...c,apiType:e.target.value})}),(0,s.jsx)(l.Input,{label:"Base URL",value:c.baseUrl,onChange:e=>d({...c,baseUrl:e.target.value}),placeholder:n.defaultBaseUrl,hint:n.baseUrlHint}),(0,s.jsx)(l.Input,{label:"API Key (for Check)",type:"password",value:x,onChange:e=>u(e.target.value)}),(0,s.jsx)(l.Input,{label:"Model ID (optional)",value:h,onChange:e=>f(e.target.value),placeholder:n.modelIdPlaceholder,hint:"If provider lacks /models endpoint, enter a model ID to validate via chat/completions instead."}),(0,s.jsxs)("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center",children:[(0,s.jsx)(l.Button,{onClick:k,disabled:!x||y||!c.baseUrl.trim(),variant:"secondary",className:"w-full sm:w-auto",children:y?"Checking...":"Check"}),(()=>{if(!j)return null;let{valid:e,error:t,method:r}=j;return e?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(l.Badge,{variant:"success",children:"Valid"}),"chat"===r&&(0,s.jsx)("span",{className:"text-sm text-text-muted",children:"(via inference test)"})]}):(0,s.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,s.jsx)(l.Badge,{variant:"error",children:"Invalid"}),t&&(0,s.jsx)("span",{className:"text-sm text-red-500",children:t})]})})()]}),(0,s.jsxs)("div",{className:"flex flex-col gap-2 sm:flex-row",children:[(0,s.jsx)(l.Button,{onClick:w,fullWidth:!0,disabled:!c.name.trim()||!c.prefix.trim()||!c.baseUrl.trim()||m,children:m?"Creating...":"Create"}),(0,s.jsx)(l.Button,{onClick:r,variant:"ghost",fullWidth:!0,children:"Cancel"})]})]})})};function v({status:e,onReset:t}){if(!e||"CLOSED"===e.state)return null;let r={DEGRADED:{color:"bg-amber-100 text-amber-700 dark:bg-amber-900/30 dark:text-amber-400",icon:"warning",label:"Degraded"},OPEN:{color:"bg-red-100 text-red-700 dark:bg-red-900/30 dark:text-red-400",icon:"power",label:"Circuit Open"},HALF_OPEN:{color:"bg-blue-100 text-blue-700 dark:bg-blue-900/30 dark:text-blue-400",icon:"autorenew",label:"Recovering"}},a=r[e.state]||r.DEGRADED,l=e.retryAfterMs>0?` (${Math.ceil(e.retryAfterMs/1e3)}s)`:"";return(0,s.jsxs)("span",{className:`inline-flex items-center gap-1 rounded-full px-2 py-0.5 text-[10px] font-medium ${a.color}`,children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-[12px]",children:a.icon}),a.label,l,"OPEN"===e.state&&t&&(0,s.jsx)("button",{onClick:e=>{e.preventDefault(),e.stopPropagation(),t()},className:"ml-0.5 hover:opacity-70 transition-opacity",title:"Reset circuit breaker",children:(0,s.jsx)("span",{className:"material-symbols-outlined text-[12px]",children:"refresh"})})]})}function j(e,t,r){let a=[];if(e>0&&a.push((0,s.jsxs)(l.Badge,{variant:"success",size:"sm",dot:!0,children:[e," Connected"]},"connected")),t>0){let e=r?`${t} Error (${r})`:`${t} Error`;a.push((0,s.jsx)(l.Badge,{variant:"error",size:"sm",dot:!0,children:e},"error"))}return 0===a.length?(0,s.jsx)("span",{className:"text-text-muted",children:"No connections"}):a}function N(){let e,t,[r,i]=(0,a.useState)([]),[n,m]=(0,a.useState)([]),[p,h]=(0,a.useState)(!0),[b,g]=(0,a.useState)(!1),[v,j]=(0,a.useState)(!1),[N,A]=(0,a.useState)(!1),[T,I]=(0,a.useState)(null),[P,O]=(0,a.useState)(null),S=(0,x.i)(),E=(0,u.C)(e=>e.query),$=(0,u.C)(e=>e.register),U=(0,u.C)(e=>e.unregister),{getCircuitBreakerForProvider:_,resetCircuitBreaker:R}=function(){let[e,t]=(0,a.useState)([]),[r,s]=(0,a.useState)(!0),l=(0,a.useCallback)(async()=>{try{let e=await fetch("/api/providers/circuit-breakers"),r=await e.json();t(r.statuses||[])}catch(e){console.error("Failed to fetch circuit breakers:",e)}finally{s(!1)}},[]);return(0,a.useEffect)(()=>{let e=!1,r=async()=>{try{let r=await fetch("/api/providers/circuit-breakers"),s=await r.json();e||t(s.statuses||[])}catch(t){e||console.error("Failed to fetch circuit breakers:",t)}finally{e||s(!1)}};r();let a=setInterval(r,5e3);return()=>{e=!0,clearInterval(a)}},[]),{statuses:e,loading:r,getCircuitBreakerForProvider:t=>e.find(e=>e.name===t),resetCircuitBreaker:async e=>{try{return await fetch(`/api/providers/circuit-breakers/${encodeURIComponent(e)}/reset`,{method:"POST"}),await l(),!0}catch(e){return console.error("Failed to reset circuit breaker:",e),!1}},refresh:l}}();(0,a.useEffect)(()=>($("Search providers..."),()=>U()),[$,U]);let B=e=>!E.trim()||e.toLowerCase().includes(E.trim().toLowerCase());(0,a.useEffect)(()=>{(async()=>{try{let[e,t]=await Promise.all([fetch("/api/providers",{cache:"no-store"}),fetch("/api/provider-nodes",{cache:"no-store"})]),r=await e.json(),s=await t.json();e.ok&&i(r.connections||[]),t.ok&&m(s.nodes||[])}catch(e){console.log("Error fetching data:",e)}finally{h(!1)}})()},[]);let D=(e,t)=>{let s=Array.isArray(t)?t:[t],a=r.filter(t=>t.provider===e&&s.includes(t.authType)),l=e=>{let t=Object.entries(e).some(([e,t])=>e.startsWith("modelLock_")&&t&&new Date(t).getTime()>Date.now());return"unavailable"!==e.testStatus||t?e.testStatus:"active"},i=a.filter(e=>{let t=l(e);return"active"===t||"success"===t}).length,n=a.filter(e=>{let t=l(e);return"error"===t||"expired"===t||"unavailable"===t}),o=n.length,c=a.length,d=c>0&&a.every(e=>!1===e.isActive),m=n.sort((e,t)=>new Date(t.lastErrorAt||0)-new Date(e.lastErrorAt||0))[0];return{connected:i,error:o,total:c,errorCode:m?function(e){if(!e)return null;let t=e.lastErrorType;if("runtime_error"===t)return"RUNTIME";if("upstream_auth_error"===t||"auth_missing"===t||"token_refresh_failed"===t||"token_expired"===t)return"AUTH";if("upstream_rate_limited"===t)return"429";if("upstream_unavailable"===t)return"5XX";if("network_error"===t)return"NET";let r=Number(e.errorCode);if(Number.isFinite(r)&&r>=400)return String(r);let s=function(e){if(!e)return null;let t=e.match(/\b([45]\d{2})\b/);return t?t[1]:"ERR"}(e.lastError);if("401"===s||"403"===s)return"AUTH";if(s&&"ERR"!==s)return s;let a=(e.lastError||"").toLowerCase();return a.includes("runtime")||a.includes("not runnable")||a.includes("not installed")?"RUNTIME":a.includes("invalid api key")||a.includes("token invalid")||a.includes("revoked")||a.includes("unauthorized")?"AUTH":"ERR"}(m):null,errorTime:m?.lastErrorAt?function(e){if(!e)return"";let t=Math.floor((Date.now()-new Date(e).getTime())/6e4);if(t<1)return"just now";if(t<60)return`${t}m ago`;let r=Math.floor(t/60);if(r<24)return`${r}h ago`;let s=Math.floor(r/24);return`${s}d ago`}(m.lastErrorAt):null,allDisabled:d}},z=async(e,t,s)=>{let a=Array.isArray(t)?t:[t],l=t=>t.provider===e&&a.includes(t.authType),n=r.filter(l);i(e=>e.map(e=>l(e)?{...e,isActive:s}:e)),await Promise.allSettled(n.map(e=>fetch(`/api/providers/${e.id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({isActive:s})})))},M=async(e,t=null)=>{if(!T){I("provider"===e?t:e),O(null);try{let r=await fetch("/api/providers/test-batch",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mode:e,providerId:t})}),s=await r.json();if(O(s),s.summary){let{passed:e,failed:t,total:r}=s.summary;0===t?S.success(`All ${r} tests passed`):S.warning(`${e}/${r} passed, ${t} failed`)}}catch(e){O({error:"Test request failed"}),S.error("Provider test failed")}finally{I(null)}}},F=n.filter(e=>"openai-compatible"===e.type).map(e=>({id:e.id,name:e.name||"OpenAI Compatible",color:"#10A37F",textIcon:"OC",apiType:e.apiType})).filter(e=>B(e.name)),L=n.filter(e=>"anthropic-compatible"===e.type).map(e=>({id:e.id,name:e.name||"Anthropic Compatible",color:"#D97757",textIcon:"AC"})).filter(e=>B(e.name)),H=(e=Object.entries(c.zN).filter(([,e])=>!e.hidden&&B(e.name)),t="oauth",[...e].sort(([e,r],[s,a])=>{let l=r.priority??999,i=a.priority??999;if(l!==i)return l-i;let n=D(e,t),o=D(s,t),c=+(n.connected>0),d=+(o.connected>0);return c!==d?d-c:(r.name||"").localeCompare(a.name||"")})),K=Object.entries(d.IS).filter(([,e])=>!e.hidden&&B(e.name)).sort(([,e],[,t])=>!!t.noAuth-!!e.noAuth),J=Object.entries(d.nJ).filter(([,e])=>!e.hidden&&B(e.name)&&(e.serviceKinds??["llm"]).includes("llm")).sort(([e,t],[r,s])=>{let a=t.priority??999,l=s.priority??999;if(a!==l)return a-l;let i=!!s.noAuth-!!t.noAuth;if(0!==i)return i;let n=D(e,o(t,e)).connected>0?0:1,c=D(r,o(s,r)).connected>0?0:1;return n!==c?n-c:(t.name||"").localeCompare(s.name||"")}),W=Object.entries(c.fg).filter(([,e])=>!e.hidden&&(e.serviceKinds??["llm"]).includes("llm")&&B(e.name)).sort(([e,t],[r,s])=>{let a=D(e,"apikey").total>0?0:1,l=D(r,"apikey").total>0?0:1;return a!==l?a-l:(t.name||"").localeCompare(s.name||"")}),q=Object.entries(d.br).filter(([,e])=>!e.hidden&&B(e.name)).sort(([e,t],[r,s])=>{let a=D(e,"cookie").total>0?0:1,l=D(r,"cookie").total>0?0:1;return a!==l?a-l:(t.name||"").localeCompare(s.name||"")}),G=!!E.trim(),X=G||b?W:W.slice(0,20),V=W.length-20;if(p)return(0,s.jsxs)("div",{className:"flex flex-col gap-8",children:[(0,s.jsx)(l.CardSkeleton,{}),(0,s.jsx)(l.CardSkeleton,{})]});let Y=H.length>0||K.length>0||J.length>0||W.length>0||q.length>0||F.length>0||L.length>0;return(0,s.jsxs)("div",{className:"flex min-w-0 flex-col gap-6 px-1 sm:px-0",children:[!Y&&(0,s.jsxs)("div",{className:"text-center py-8 border border-dashed border-border rounded-xl",children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-[32px] text-text-muted mb-2",children:"search_off"}),(0,s.jsx)("p",{className:"text-text-muted text-sm",children:"No providers match your search"})]}),(0,s.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,s.jsxs)("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[(0,s.jsxs)("h2",{className:"text-lg sm:text-xl font-semibold flex items-center gap-2 leading-tight",children:["Custom Providers (OpenAI/Anthropic Compatible)"," "]}),(0,s.jsxs)("div",{className:"grid grid-cols-1 gap-2 sm:flex sm:w-auto",children:[(0,s.jsx)(l.Button,{size:"sm",icon:"add",onClick:()=>A(!0),className:"w-full sm:w-auto",children:"Add Anthropic Compatible"}),(0,s.jsx)(l.Button,{size:"sm",variant:"secondary",icon:"add",onClick:()=>j(!0),className:"w-full !bg-white !text-black hover:!bg-gray-100 sm:w-auto",children:"Add OpenAI Compatible"})]})]}),0===F.length&&0===L.length?(0,s.jsxs)("div",{className:"flex items-center justify-center gap-2 py-2 border border-dashed border-border rounded-xl text-text-muted text-sm",children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:"extension"}),(0,s.jsx)("span",{children:"No custom providers — use buttons above to add OpenAI/Anthropic compatible endpoints"})]}):(0,s.jsx)("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-2 sm:gap-4 lg:grid-cols-3 xl:grid-cols-4",children:[...F,...L].map(e=>(0,s.jsx)(k,{providerId:e.id,provider:e,stats:D(e.id,"apikey"),authType:"compatible",circuitBreaker:_(e.id),onResetCircuit:R,onToggle:t=>z(e.id,"apikey",t)},e.id))})]}),H.length>0&&(0,s.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,s.jsxs)("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[(0,s.jsx)("h2",{className:"text-lg sm:text-xl font-semibold flex items-center gap-2 leading-tight",children:"OAuth Providers"}),(0,s.jsxs)("div",{className:"flex w-full flex-col gap-2 sm:w-auto sm:flex-row sm:items-center",children:[(0,s.jsx)(f,{}),(0,s.jsxs)("button",{onClick:()=>M("oauth"),disabled:!!T,className:`flex w-full items-center justify-center gap-1.5 rounded-lg border px-3 py-2 text-xs font-medium transition-colors sm:w-auto sm:py-1.5 ${"oauth"===T?"bg-primary/20 border-primary/40 text-primary animate-pulse":"bg-bg border-border text-text-muted hover:text-text-main hover:border-primary/40"}`,title:"Test all OAuth connections","aria-label":"Test all OAuth connections",children:[(0,s.jsx)("span",{className:`material-symbols-outlined text-[14px]${"oauth"===T?" animate-spin":""}`,children:"play_arrow"}),"oauth"===T?"Testing...":"Test All"]})]})]}),(0,s.jsx)("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-2 sm:gap-4 lg:grid-cols-3 xl:grid-cols-4",children:H.map(([e,t])=>(0,s.jsx)(w,{providerId:e,provider:t,stats:D(e,"oauth"),authType:"oauth",circuitBreaker:_(e),onResetCircuit:R,onToggle:t=>z(e,"oauth",t)},e))})]}),(K.length>0||J.length>0)&&(0,s.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,s.jsxs)("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[(0,s.jsx)("h2",{className:"text-lg sm:text-xl font-semibold flex items-center gap-2 leading-tight",children:"Free Tier Providers"}),(0,s.jsxs)("button",{onClick:()=>M("free"),disabled:!!T,className:`flex w-full items-center justify-center gap-1.5 rounded-lg border px-3 py-2 text-xs font-medium transition-colors sm:w-auto sm:py-1.5 ${"free"===T?"bg-primary/20 border-primary/40 text-primary animate-pulse":"bg-bg border-border text-text-muted hover:text-text-main hover:border-primary/40"}`,title:"Test all Free connections","aria-label":"Test all Free provider connections",children:[(0,s.jsx)("span",{className:`material-symbols-outlined text-[14px]${"free"===T?" animate-spin":""}`,children:"play_arrow"}),"free"===T?"Testing...":"Test All"]})]}),(0,s.jsxs)("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-2 sm:gap-4 lg:grid-cols-3 xl:grid-cols-4",children:[K.map(([e,t])=>{let r="kiro"===e?["oauth","apikey","api_key"]:"oauth";return(0,s.jsx)(w,{providerId:e,provider:t,stats:D(e,r),authType:"free",circuitBreaker:_(e),onResetCircuit:R,onToggle:t=>z(e,r,t)},e)}),J.map(([e,t])=>{let r=o(t,e);return(0,s.jsx)(k,{providerId:e,provider:t,stats:D(e,r),authType:Array.isArray(r)?r[0]??"apikey":r,onToggle:t=>z(e,r,t)},e)})]})]}),W.length>0&&(0,s.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,s.jsxs)("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[(0,s.jsxs)("h2",{className:"text-lg sm:text-xl font-semibold flex items-center gap-2 leading-tight",children:["API Key Providers"," "]}),(0,s.jsxs)("button",{onClick:()=>M("apikey"),disabled:!!T,className:`flex w-full items-center justify-center gap-1.5 rounded-lg border px-3 py-2 text-xs font-medium transition-colors sm:w-auto sm:py-1.5 ${"apikey"===T?"bg-primary/20 border-primary/40 text-primary animate-pulse":"bg-bg border-border text-text-muted hover:text-text-main hover:border-primary/40"}`,title:"Test all API Key connections","aria-label":"Test all API Key connections",children:[(0,s.jsx)("span",{className:`material-symbols-outlined text-[14px]${"apikey"===T?" animate-spin":""}`,children:"play_arrow"}),"apikey"===T?"Testing...":"Test All"]})]}),(0,s.jsx)("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-2 sm:gap-4 lg:grid-cols-3 xl:grid-cols-4",children:X.map(([e,t])=>(0,s.jsx)(k,{providerId:e,provider:t,stats:D(e,"apikey"),authType:"apikey",onToggle:t=>z(e,"apikey",t)},e))}),!G&&!b&&V>0&&(0,s.jsxs)("button",{onClick:()=>g(!0),className:"flex w-full items-center justify-center gap-1.5 rounded-lg border border-dashed border-primary/40 px-3 py-2.5 text-sm font-medium text-primary transition-colors hover:border-primary hover:bg-primary/5",children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-[16px]",children:"expand_more"}),"Show all ",W.length," providers"]})]}),q.length>0&&(0,s.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,s.jsx)("div",{className:"flex items-center justify-between",children:(0,s.jsxs)("h2",{className:"text-lg sm:text-xl font-semibold flex items-center gap-2 leading-tight",children:["Web Cookie Providers"," "]})}),(0,s.jsx)("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-4",children:q.map(([e,t])=>(0,s.jsx)(k,{providerId:e,provider:t,stats:D(e,"cookie"),authType:"cookie",onToggle:t=>z(e,"cookie",t)},e))})]}),(0,s.jsx)(y,{variant:"openai",isOpen:v,onClose:()=>j(!1),onCreated:e=>{m(t=>[...t,e]),j(!1)}}),(0,s.jsx)(y,{variant:"anthropic",isOpen:N,onClose:()=>A(!1),onCreated:e=>{m(t=>[...t,e]),A(!1)}}),P&&(0,s.jsxs)("div",{className:"fixed inset-0 z-50 flex items-start justify-center px-3 pt-[6vh] sm:pt-[10vh]",onClick:()=>O(null),children:[(0,s.jsx)("div",{className:"absolute inset-0 bg-black/60 backdrop-blur-sm"}),(0,s.jsxs)("div",{className:"relative bg-surface border border-border rounded-xl w-full max-w-[600px] max-h-[86vh] sm:max-h-[80vh] overflow-y-auto shadow-2xl",onClick:e=>e.stopPropagation(),children:[(0,s.jsxs)("div",{className:"sticky top-0 z-10 flex items-center justify-between px-5 py-3 border-b border-border bg-surface/95 backdrop-blur-sm rounded-t-xl",children:[(0,s.jsx)("h3",{className:"font-semibold",children:"Test Results"}),(0,s.jsx)("button",{onClick:()=>O(null),className:"p-1 rounded-lg hover:bg-bg text-text-muted hover:text-text-main transition-colors","aria-label":"Close test results",children:(0,s.jsx)("span",{className:"material-symbols-outlined text-lg",children:"close"})})]}),(0,s.jsx)("div",{className:"p-5",children:(0,s.jsx)(C,{results:P})})]})]})]})}function w({providerId:e,provider:t,stats:r,authType:a,onToggle:n,circuitBreaker:o,onResetCircuit:c}){let{connected:d,error:m,errorCode:x,errorTime:u,allDisabled:h}=r,f=!!t.noAuth;return(0,s.jsx)(p(),{href:`/dashboard/providers/${e}`,className:"group min-w-0",children:(0,s.jsx)(l.Card,{padding:"xs",className:`h-full hover:bg-black/[0.01] dark:hover:bg-white/[0.01] transition-colors cursor-pointer ${h?"opacity-50":""}`,children:(0,s.jsxs)("div",{className:"flex min-w-0 items-center justify-between gap-3",children:[(0,s.jsxs)("div",{className:"flex min-w-0 items-center gap-3",children:[(0,s.jsx)("div",{className:"size-8 shrink-0 rounded-lg flex items-center justify-center",style:{backgroundColor:`${t.color?.length>7?t.color:t.color+"15"}`},children:(0,s.jsx)(i.A,{src:`/providers/${t.id}.webp`,alt:t.name,size:30,className:"object-contain rounded-lg max-w-[32px] max-h-[32px]",fallbackText:t.textIcon||t.id.slice(0,2).toUpperCase(),fallbackColor:t.color})}),(0,s.jsxs)("div",{className:"min-w-0",children:[(0,s.jsx)("h3",{className:"truncate font-semibold",children:t.name}),(0,s.jsx)("div",{className:"flex min-w-0 items-center gap-1.5 text-xs flex-wrap",children:h?(0,s.jsx)(l.Badge,{variant:"default",size:"sm",children:(0,s.jsxs)("span",{className:"flex items-center gap-1",children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-[12px]",children:"pause_circle"}),"Disabled"]})}):f?(0,s.jsx)(l.Badge,{variant:"success",size:"sm",dot:!0,children:"Ready"}):(0,s.jsxs)(s.Fragment,{children:[j(d,m,x),o&&(0,s.jsx)(v,{status:o,onReset:()=>c(e)}),u&&(0,s.jsx)("span",{className:"text-text-muted",children:u})]})})]})]}),(0,s.jsx)("div",{className:"flex shrink-0 items-center gap-2",children:r.total>0&&(0,s.jsx)("div",{className:"opacity-100 transition-opacity sm:opacity-0 sm:group-hover:opacity-100",onClick:e=>{e.preventDefault(),e.stopPropagation(),n(!!h)},children:(0,s.jsx)(l.Toggle,{size:"sm",checked:!h,onChange:()=>{},title:h?"Enable provider":"Disable provider"})})})]})})})}function k({providerId:e,provider:t,stats:r,authType:a,onToggle:o,circuitBreaker:c,onResetCircuit:m}){let{connected:x,error:u,errorCode:h,errorTime:f,allDisabled:b}=r,g=e.startsWith(d.JH),y=e.startsWith(d.DI);return(0,s.jsx)(p(),{href:`/dashboard/providers/${e}`,className:"group min-w-0",children:(0,s.jsx)(l.Card,{padding:"xs",className:`h-full hover:bg-black/[0.01] dark:hover:bg-white/[0.01] transition-colors cursor-pointer ${b?"opacity-50":""}`,children:(0,s.jsxs)("div",{className:"flex min-w-0 items-center justify-between gap-3",children:[(0,s.jsxs)("div",{className:"flex min-w-0 items-center gap-3",children:[(0,s.jsx)("div",{className:"size-8 shrink-0 rounded-lg flex items-center justify-center",style:{backgroundColor:`${t.color?.length>7?t.color:t.color+"15"}`},children:(0,s.jsx)(i.A,{src:g&&t.apiType?"responses"===t.apiType?"/providers/oai-r.webp":"/providers/oai-cc.webp":y?"/providers/anthropic-m.webp":(0,n.HY)(t.id),alt:t.name,size:30,className:"object-contain rounded-lg max-w-[30px] max-h-[30px]",fallbackText:t.textIcon||t.id.slice(0,2).toUpperCase(),fallbackColor:t.color})}),(0,s.jsxs)("div",{className:"min-w-0",children:[(0,s.jsx)("h3",{className:"truncate font-semibold",children:t.name}),(0,s.jsx)("div",{className:"flex min-w-0 items-center gap-1.5 text-xs flex-wrap",children:b?(0,s.jsx)(l.Badge,{variant:"default",size:"sm",children:(0,s.jsxs)("span",{className:"flex items-center gap-1",children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-[12px]",children:"pause_circle"}),"Disabled"]})}):(0,s.jsxs)(s.Fragment,{children:[j(x,u,h),g&&(0,s.jsx)(l.Badge,{variant:"default",size:"sm",children:"responses"===t.apiType?"Responses":"Chat"}),y&&(0,s.jsx)(l.Badge,{variant:"default",size:"sm",children:"Messages"}),f&&(0,s.jsx)("span",{className:"text-text-muted",children:f})]})})]})]}),(0,s.jsx)("div",{className:"flex shrink-0 items-center gap-2",children:r.total>0&&(0,s.jsx)("div",{className:"opacity-100 transition-opacity sm:opacity-0 sm:group-hover:opacity-100",onClick:e=>{e.preventDefault(),e.stopPropagation(),o(!!b)},children:(0,s.jsx)(l.Toggle,{size:"sm",checked:!b,onChange:()=>{},title:b?"Enable provider":"Disable provider"})})})]})})})}function C({results:e}){if(e.error&&!e.results)return(0,s.jsxs)("div",{className:"text-center py-6",children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-red-500 text-[32px] mb-2 block",children:"error"}),(0,s.jsx)("p",{className:"text-sm text-red-400",children:e.error})]});let{summary:t,mode:r}=e,a=e.results||[];return(0,s.jsxs)("div",{className:"flex min-w-0 flex-col gap-3",children:[t&&(0,s.jsxs)("div",{className:"flex flex-wrap items-center gap-2 text-xs mb-1 sm:gap-3",children:[(0,s.jsxs)("span",{className:"text-text-muted",children:[{oauth:"OAuth",free:"Free",apikey:"API Key",provider:"Provider",all:"All"}[r]||r," Test"]}),(0,s.jsxs)("span",{className:"px-2 py-0.5 rounded bg-emerald-500/15 text-emerald-400 font-medium",children:[t.passed," passed"]}),t.failed>0&&(0,s.jsxs)("span",{className:"px-2 py-0.5 rounded bg-red-500/15 text-red-400 font-medium",children:[t.failed," failed"]}),(0,s.jsxs)("span",{className:"text-text-muted sm:ml-auto",children:[t.total," tested"]})]}),a.map((e,t)=>(0,s.jsxs)("div",{className:"flex min-w-0 flex-wrap items-center gap-2 rounded-lg bg-black/[0.03] px-3 py-2 text-xs dark:bg-white/[0.03] sm:flex-nowrap",children:[(0,s.jsx)("span",{className:`material-symbols-outlined text-[16px] ${e.valid?"text-emerald-500":"text-red-500"}`,children:e.valid?"check_circle":"error"}),(0,s.jsxs)("div",{className:"min-w-0 flex-[1_1_160px]",children:[(0,s.jsx)("span",{className:"block truncate font-medium sm:inline",children:e.connectionName}),(0,s.jsxs)("span",{className:"block truncate text-text-muted sm:ml-1.5 sm:inline",children:["(",e.provider,")"]})]}),void 0!==e.latencyMs&&(0,s.jsxs)("span",{className:"shrink-0 text-text-muted font-mono tabular-nums",children:[e.latencyMs,"ms"]}),(0,s.jsx)("span",{className:`shrink-0 text-[10px] uppercase font-bold px-1.5 py-0.5 rounded ${e.valid?"bg-emerald-500/15 text-emerald-400":"bg-red-500/15 text-red-400"}`,children:e.valid?"OK":e.diagnosis?.type||"ERROR"})]},e.connectionId||t)),0===a.length&&(0,s.jsx)("div",{className:"text-center py-4 text-text-muted text-sm",children:"No active connections found for this group."})]})}},77048:(e,t,r)=>{Promise.resolve().then(r.bind(r,48504))}},e=>{e.O(0,[3885,2318,4385,2940,2147,3204,7358],()=>e(e.s=77048)),_N_E=e.O()}]);
package/app/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vansrouter-app",
3
- "version": "0.91.5",
3
+ "version": "0.91.6",
4
4
  "description": "9Router web dashboard",
5
5
  "private": true,
6
6
  "engines": {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vansrouter",
3
- "version": "0.91.5",
3
+ "version": "0.91.6",
4
4
  "description": "Vansrouter CLI - Start and manage Vansrouter server",
5
5
  "engines": {
6
6
  "node": ">=22.5.0"
@@ -1 +0,0 @@
1
- (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[8460],{21511:(e,t,s)=>{"use strict";s.r(t),s.d(t,{default:()=>w});var a=s(15102),r=s(82030),l=s(92940),i=s(31704),n=s(19965);function o(e,t){return"kiro"===t?["oauth","apikey","api_key"]:Array.isArray(e?.authModes)&&e.authModes.length>0?e.authModes:e?.hasOAuth?["oauth"]:["apikey"]}var c=s(11434),d=s(31038),m=s(93885),p=s.n(m),x=s(25795),u=s(71389);s(48271);let h={available:{icon:"check_circle",color:"#22c55e",label:"Available"},cooldown:{icon:"schedule",color:"#f59e0b",label:"Cooldown"},unavailable:{icon:"error",color:"#ef4444",label:"Unavailable"},unknown:{icon:"help",color:"#6b7280",label:"Unknown"}};function f(){let[e,t]=(0,r.useState)(null),[s,i]=(0,r.useState)(!0),[n,o]=(0,r.useState)(!1),[c,d]=(0,r.useState)(null),m=(0,r.useRef)(null),p=(0,x.i)(),u=(0,r.useCallback)(async()=>{try{let e=await fetch("/api/models/availability");if(e.ok){let s=await e.json();t(s)}}catch{}finally{i(!1)}},[]);(0,r.useEffect)(()=>{u();let e=setInterval(u,3e4);return()=>clearInterval(e)},[u]),(0,r.useEffect)(()=>{let e=e=>{m.current&&!m.current.contains(e.target)&&o(!1)};return n&&document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[n]);let f=async(e,t)=>{d(`${e}:${t}`);try{(await fetch("/api/models/availability",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"clearCooldown",provider:e,model:t})})).ok?(p.success(`Cooldown cleared for ${t}`),await u()):p.error("Failed to clear cooldown")}catch{p.error("Failed to clear cooldown")}finally{d(null)}};if(s)return null;let b=e?.models||[],g=0===(e?.unavailableCount||b.filter(e=>"available"!==e.status).length),y={};return b.forEach(e=>{if("available"===e.status)return;let t=e.provider||"unknown";y[t]||(y[t]=[]),y[t].push(e)}),(0,a.jsx)("div",{className:"relative",ref:m,children:n&&(0,a.jsxs)("div",{className:"absolute top-full right-0 mt-2 w-80 bg-surface border border-border rounded-xl shadow-2xl z-50 overflow-hidden",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border bg-bg",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[16px]",style:{color:g?"#22c55e":"#f59e0b"},children:g?"verified":"warning"}),(0,a.jsx)("span",{className:"text-sm font-semibold text-text-main",children:"Model Status"})]}),(0,a.jsx)("button",{type:"button",onClick:u,className:"p-1 rounded-lg hover:bg-surface text-text-muted hover:text-text-main transition-colors",title:"Refresh",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"refresh"})})]}),(0,a.jsx)("div",{className:"px-4 py-3 max-h-60 overflow-y-auto",children:g?(0,a.jsx)("p",{className:"text-sm text-text-muted text-center py-2",children:"All models are responding normally."}):(0,a.jsx)("div",{className:"flex flex-col gap-2.5",children:Object.entries(y).map(([e,t])=>(0,a.jsxs)("div",{children:[(0,a.jsx)("p",{className:"text-xs font-semibold text-text-main mb-1.5 capitalize",children:e}),(0,a.jsx)("div",{className:"flex flex-col gap-1",children:t.map(e=>{let t=h[e.status]||h.unknown,s=c===`${e.provider}:${e.model}`;return(0,a.jsxs)("div",{className:"flex items-center justify-between px-2.5 py-1.5 rounded-lg bg-surface/30",children:[(0,a.jsxs)("div",{className:"flex items-center gap-1.5 min-w-0",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px] shrink-0",style:{color:t.color},children:t.icon}),(0,a.jsx)("span",{className:"font-mono text-xs text-text-main truncate",children:e.model})]}),"cooldown"===e.status&&(0,a.jsx)(l.Button,{size:"sm",variant:"ghost",onClick:()=>f(e.provider,e.model),disabled:s,className:"text-[10px] px-1.5! py-0.5! ml-2",children:s?"...":"Clear"})]},`${e.provider}-${e.model}`)})})]},e))})})]})})}let b={openai:{title:"Add OpenAI Compatible",type:"openai-compatible",defaultBaseUrl:"https://api.openai.com/v1",namePlaceholder:"OpenAI Compatible (Prod)",prefixPlaceholder:"oc-prod",baseUrlHint:"Use the base URL (ending in /v1) for your OpenAI-compatible API.",modelIdPlaceholder:"e.g. gpt-4, claude-3-opus",errorLabel:"OpenAI Compatible",hasApiType:!0},anthropic:{title:"Add Anthropic Compatible",type:"anthropic-compatible",defaultBaseUrl:"https://api.anthropic.com/v1",namePlaceholder:"Anthropic Compatible (Prod)",prefixPlaceholder:"ac-prod",baseUrlHint:"Use the base URL (ending in /v1) for your Anthropic-compatible API. The system will append /messages.",modelIdPlaceholder:"e.g. claude-3-opus",errorLabel:"Anthropic Compatible",hasApiType:!1}},g=[{value:"chat",label:"Chat Completions"},{value:"responses",label:"Responses API"}],y=function({variant:e,isOpen:t,onClose:s,onCreated:i}){let n=b[e],o=()=>({name:"",prefix:"",...n.hasApiType?{apiType:"chat"}:{},baseUrl:n.defaultBaseUrl}),[c,d]=(0,r.useState)(o),[m,p]=(0,r.useState)(!1),[x,u]=(0,r.useState)(""),[h,f]=(0,r.useState)(""),[y,v]=(0,r.useState)(!1),[j,N]=(0,r.useState)(null);(0,r.useEffect)(()=>{n.hasApiType?d(e=>({...e,baseUrl:n.defaultBaseUrl})):t&&(N(null),u(""),f(""))},[n.hasApiType?c.apiType:t]);let w=async()=>{if(c.name.trim()&&c.prefix.trim()&&c.baseUrl.trim()){p(!0);try{let e=await fetch("/api/provider-nodes",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:c.name,prefix:c.prefix,...n.hasApiType?{apiType:c.apiType}:{},baseUrl:c.baseUrl,type:n.type})}),t=await e.json();e.ok&&(i(t.node),d(o()),u(""),N(null))}catch(e){console.log(`Error creating ${n.errorLabel} node:`,e)}finally{p(!1)}}},k=async()=>{v(!0);try{let e=await fetch("/api/provider-nodes/validate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({baseUrl:c.baseUrl,apiKey:x,type:n.type,modelId:h.trim()||void 0})}),t=await e.json();N(t)}catch{N({valid:!1,error:"Network error"})}finally{v(!1)}};return(0,a.jsx)(l.Modal,{isOpen:t,title:n.title,onClose:s,children:(0,a.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,a.jsx)(l.Input,{label:"Name",value:c.name,onChange:e=>d({...c,name:e.target.value}),placeholder:n.namePlaceholder,hint:"Required. A friendly label for this node."}),(0,a.jsx)(l.Input,{label:"Prefix",value:c.prefix,onChange:e=>d({...c,prefix:e.target.value}),placeholder:n.prefixPlaceholder,hint:"Required. Used as the provider prefix for model IDs."}),n.hasApiType&&(0,a.jsx)(l.Select,{label:"API Type",options:g,value:c.apiType,onChange:e=>d({...c,apiType:e.target.value})}),(0,a.jsx)(l.Input,{label:"Base URL",value:c.baseUrl,onChange:e=>d({...c,baseUrl:e.target.value}),placeholder:n.defaultBaseUrl,hint:n.baseUrlHint}),(0,a.jsx)(l.Input,{label:"API Key (for Check)",type:"password",value:x,onChange:e=>u(e.target.value)}),(0,a.jsx)(l.Input,{label:"Model ID (optional)",value:h,onChange:e=>f(e.target.value),placeholder:n.modelIdPlaceholder,hint:"If provider lacks /models endpoint, enter a model ID to validate via chat/completions instead."}),(0,a.jsxs)("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center",children:[(0,a.jsx)(l.Button,{onClick:k,disabled:!x||y||!c.baseUrl.trim(),variant:"secondary",className:"w-full sm:w-auto",children:y?"Checking...":"Check"}),(()=>{if(!j)return null;let{valid:e,error:t,method:s}=j;return e?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(l.Badge,{variant:"success",children:"Valid"}),"chat"===s&&(0,a.jsx)("span",{className:"text-sm text-text-muted",children:"(via inference test)"})]}):(0,a.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,a.jsx)(l.Badge,{variant:"error",children:"Invalid"}),t&&(0,a.jsx)("span",{className:"text-sm text-red-500",children:t})]})})()]}),(0,a.jsxs)("div",{className:"flex flex-col gap-2 sm:flex-row",children:[(0,a.jsx)(l.Button,{onClick:w,fullWidth:!0,disabled:!c.name.trim()||!c.prefix.trim()||!c.baseUrl.trim()||m,children:m?"Creating...":"Create"}),(0,a.jsx)(l.Button,{onClick:s,variant:"ghost",fullWidth:!0,children:"Cancel"})]})]})})};function v({status:e,onReset:t}){if(!e||"CLOSED"===e.state)return null;let s={DEGRADED:{color:"bg-amber-100 text-amber-700 dark:bg-amber-900/30 dark:text-amber-400",icon:"warning",label:"Degraded"},OPEN:{color:"bg-red-100 text-red-700 dark:bg-red-900/30 dark:text-red-400",icon:"power",label:"Circuit Open"},HALF_OPEN:{color:"bg-blue-100 text-blue-700 dark:bg-blue-900/30 dark:text-blue-400",icon:"autorenew",label:"Recovering"}},r=s[e.state]||s.DEGRADED,l=e.retryAfterMs>0?` (${Math.ceil(e.retryAfterMs/1e3)}s)`:"";return(0,a.jsxs)("span",{className:`inline-flex items-center gap-1 rounded-full px-2 py-0.5 text-[10px] font-medium ${r.color}`,children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[12px]",children:r.icon}),r.label,l,"OPEN"===e.state&&t&&(0,a.jsx)("button",{onClick:e=>{e.preventDefault(),e.stopPropagation(),t()},className:"ml-0.5 hover:opacity-70 transition-opacity",title:"Reset circuit breaker",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[12px]",children:"refresh"})})]})}var j=s(21863);function N(e){let{connected:t,unavailable:s}=e,r=[];return(t>0&&r.push((0,a.jsxs)(l.Badge,{variant:"success",size:"sm",dot:!0,children:[t," Connected"]},"connected")),s>0&&r.push((0,a.jsxs)(l.Badge,{variant:"warning",size:"sm",dot:!0,children:[s," Unavailable"]},"unavailable")),0===r.length)?(0,a.jsx)("span",{className:"text-text-muted",children:"No connections"}):r}function w(){let e,t,[s,i]=(0,r.useState)([]),[n,m]=(0,r.useState)([]),[p,h]=(0,r.useState)(!0),[b,g]=(0,r.useState)(!1),[v,N]=(0,r.useState)(!1),[w,T]=(0,r.useState)(!1),[I,P]=(0,r.useState)(null),[O,S]=(0,r.useState)(null),U=(0,x.i)(),$=(0,u.C)(e=>e.query),B=(0,u.C)(e=>e.register),E=(0,u.C)(e=>e.unregister),{getCircuitBreakerForProvider:R,resetCircuitBreaker:z}=function(){let[e,t]=(0,r.useState)([]),[s,a]=(0,r.useState)(!0),l=(0,r.useCallback)(async()=>{try{let e=await fetch("/api/providers/circuit-breakers"),s=await e.json();t(s.statuses||[])}catch(e){console.error("Failed to fetch circuit breakers:",e)}finally{a(!1)}},[]);return(0,r.useEffect)(()=>{let e=!1,s=async()=>{try{let s=await fetch("/api/providers/circuit-breakers"),a=await s.json();e||t(a.statuses||[])}catch(t){e||console.error("Failed to fetch circuit breakers:",t)}finally{e||a(!1)}};s();let r=setInterval(s,5e3);return()=>{e=!0,clearInterval(r)}},[]),{statuses:e,loading:s,getCircuitBreakerForProvider:t=>e.find(e=>e.name===t),resetCircuitBreaker:async e=>{try{return await fetch(`/api/providers/circuit-breakers/${encodeURIComponent(e)}/reset`,{method:"POST"}),await l(),!0}catch(e){return console.error("Failed to reset circuit breaker:",e),!1}},refresh:l}}();(0,r.useEffect)(()=>(B("Search providers..."),()=>E()),[B,E]);let D=e=>!$.trim()||e.toLowerCase().includes($.trim().toLowerCase());(0,r.useEffect)(()=>{(async()=>{try{let[e,t]=await Promise.all([fetch("/api/providers",{cache:"no-store"}),fetch("/api/provider-nodes",{cache:"no-store"})]),s=await e.json(),a=await t.json();e.ok&&i(s.connections||[]),t.ok&&m(a.nodes||[])}catch(e){console.log("Error fetching data:",e)}finally{h(!1)}})()},[]);let _=(e,t)=>{let a=Array.isArray(t)?t:[t],r=s.filter(t=>t.provider===e&&a.includes(t.authType)),l=r.filter(e=>"active"===(0,j.d)(e)).length,i=r.length-l,n=r.length,o=n>0&&r.every(e=>!1===e.isActive);return{connected:l,unavailable:i,total:n,allDisabled:o}},F=async(e,t,a)=>{let r=Array.isArray(t)?t:[t],l=t=>t.provider===e&&r.includes(t.authType),n=s.filter(l);i(e=>e.map(e=>l(e)?{...e,isActive:a}:e)),await Promise.allSettled(n.map(e=>fetch(`/api/providers/${e.id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({isActive:a})})))},M=async(e,t=null)=>{if(!I){P("provider"===e?t:e),S(null);try{let s=await fetch("/api/providers/test-batch",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mode:e,providerId:t})}),a=await s.json();if(S(a),a.summary){let{passed:e,failed:t,total:s}=a.summary;0===t?U.success(`All ${s} tests passed`):U.warning(`${e}/${s} passed, ${t} failed`)}}catch(e){S({error:"Test request failed"}),U.error("Provider test failed")}finally{P(null)}}},L=n.filter(e=>"openai-compatible"===e.type).map(e=>({id:e.id,name:e.name||"OpenAI Compatible",color:"#10A37F",textIcon:"OC",apiType:e.apiType})).filter(e=>D(e.name)),K=n.filter(e=>"anthropic-compatible"===e.type).map(e=>({id:e.id,name:e.name||"Anthropic Compatible",color:"#D97757",textIcon:"AC"})).filter(e=>D(e.name)),J=(e=Object.entries(c.zN).filter(([,e])=>!e.hidden&&D(e.name)),t="oauth",[...e].sort(([e,s],[a,r])=>{let l=s.priority??999,i=r.priority??999;if(l!==i)return l-i;let n=_(e,t),o=_(a,t),c=+(n.connected>0),d=+(o.connected>0);return c!==d?d-c:(s.name||"").localeCompare(r.name||"")})),H=Object.entries(d.IS).filter(([,e])=>!e.hidden&&D(e.name)).sort(([,e],[,t])=>!!t.noAuth-!!e.noAuth),W=Object.entries(d.nJ).filter(([,e])=>!e.hidden&&D(e.name)&&(e.serviceKinds??["llm"]).includes("llm")).sort(([e,t],[s,a])=>{let r=t.priority??999,l=a.priority??999;if(r!==l)return r-l;let i=!!a.noAuth-!!t.noAuth;if(0!==i)return i;let n=_(e,o(t,e)).connected>0?0:1,c=_(s,o(a,s)).connected>0?0:1;return n!==c?n-c:(t.name||"").localeCompare(a.name||"")}),q=Object.entries(c.fg).filter(([,e])=>!e.hidden&&(e.serviceKinds??["llm"]).includes("llm")&&D(e.name)).sort(([e,t],[s,a])=>{let r=_(e,"apikey").total>0?0:1,l=_(s,"apikey").total>0?0:1;return r!==l?r-l:(t.name||"").localeCompare(a.name||"")}),G=Object.entries(d.br).filter(([,e])=>!e.hidden&&D(e.name)).sort(([e,t],[s,a])=>{let r=_(e,"cookie").total>0?0:1,l=_(s,"cookie").total>0?0:1;return r!==l?r-l:(t.name||"").localeCompare(a.name||"")}),V=!!$.trim(),Y=V||b?q:q.slice(0,20),Q=q.length-20;if(p)return(0,a.jsxs)("div",{className:"flex flex-col gap-8",children:[(0,a.jsx)(l.CardSkeleton,{}),(0,a.jsx)(l.CardSkeleton,{})]});let X=J.length>0||H.length>0||W.length>0||q.length>0||G.length>0||L.length>0||K.length>0;return(0,a.jsxs)("div",{className:"flex min-w-0 flex-col gap-6 px-1 sm:px-0",children:[!X&&(0,a.jsxs)("div",{className:"text-center py-8 border border-dashed border-border rounded-xl",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[32px] text-text-muted mb-2",children:"search_off"}),(0,a.jsx)("p",{className:"text-text-muted text-sm",children:"No providers match your search"})]}),(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)("h2",{className:"text-lg sm:text-xl font-semibold flex items-center gap-2 leading-tight",children:["Custom Providers (OpenAI/Anthropic Compatible)"," "]}),(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-2 sm:flex sm:w-auto",children:[(0,a.jsx)(l.Button,{size:"sm",icon:"add",onClick:()=>T(!0),className:"w-full sm:w-auto",children:"Add Anthropic Compatible"}),(0,a.jsx)(l.Button,{size:"sm",variant:"secondary",icon:"add",onClick:()=>N(!0),className:"w-full !bg-white !text-black hover:!bg-gray-100 sm:w-auto",children:"Add OpenAI Compatible"})]})]}),0===L.length&&0===K.length?(0,a.jsxs)("div",{className:"flex items-center justify-center gap-2 py-2 border border-dashed border-border rounded-xl text-text-muted text-sm",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:"extension"}),(0,a.jsx)("span",{children:"No custom providers — use buttons above to add OpenAI/Anthropic compatible endpoints"})]}):(0,a.jsx)("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-2 sm:gap-4 lg:grid-cols-3 xl:grid-cols-4",children:[...L,...K].map(e=>(0,a.jsx)(C,{providerId:e.id,provider:e,stats:_(e.id,"apikey"),authType:"compatible",circuitBreaker:R(e.id),onResetCircuit:z,onToggle:t=>F(e.id,"apikey",t)},e.id))})]}),J.length>0&&(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.jsx)("h2",{className:"text-lg sm:text-xl font-semibold flex items-center gap-2 leading-tight",children:"OAuth Providers"}),(0,a.jsxs)("div",{className:"flex w-full flex-col gap-2 sm:w-auto sm:flex-row sm:items-center",children:[(0,a.jsx)(f,{}),(0,a.jsxs)("button",{onClick:()=>M("oauth"),disabled:!!I,className:`flex w-full items-center justify-center gap-1.5 rounded-lg border px-3 py-2 text-xs font-medium transition-colors sm:w-auto sm:py-1.5 ${"oauth"===I?"bg-primary/20 border-primary/40 text-primary animate-pulse":"bg-bg border-border text-text-muted hover:text-text-main hover:border-primary/40"}`,title:"Test all OAuth connections","aria-label":"Test all OAuth connections",children:[(0,a.jsx)("span",{className:`material-symbols-outlined text-[14px]${"oauth"===I?" animate-spin":""}`,children:"play_arrow"}),"oauth"===I?"Testing...":"Test All"]})]})]}),(0,a.jsx)("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-2 sm:gap-4 lg:grid-cols-3 xl:grid-cols-4",children:J.map(([e,t])=>(0,a.jsx)(k,{providerId:e,provider:t,stats:_(e,"oauth"),authType:"oauth",circuitBreaker:R(e),onResetCircuit:z,onToggle:t=>F(e,"oauth",t)},e))})]}),(H.length>0||W.length>0)&&(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.jsx)("h2",{className:"text-lg sm:text-xl font-semibold flex items-center gap-2 leading-tight",children:"Free Tier Providers"}),(0,a.jsxs)("button",{onClick:()=>M("free"),disabled:!!I,className:`flex w-full items-center justify-center gap-1.5 rounded-lg border px-3 py-2 text-xs font-medium transition-colors sm:w-auto sm:py-1.5 ${"free"===I?"bg-primary/20 border-primary/40 text-primary animate-pulse":"bg-bg border-border text-text-muted hover:text-text-main hover:border-primary/40"}`,title:"Test all Free connections","aria-label":"Test all Free provider connections",children:[(0,a.jsx)("span",{className:`material-symbols-outlined text-[14px]${"free"===I?" animate-spin":""}`,children:"play_arrow"}),"free"===I?"Testing...":"Test All"]})]}),(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-2 sm:gap-4 lg:grid-cols-3 xl:grid-cols-4",children:[H.map(([e,t])=>{let s="kiro"===e?["oauth","apikey","api_key"]:"oauth";return(0,a.jsx)(k,{providerId:e,provider:t,stats:_(e,s),authType:"free",circuitBreaker:R(e),onResetCircuit:z,onToggle:t=>F(e,s,t)},e)}),W.map(([e,t])=>{let s=o(t,e);return(0,a.jsx)(C,{providerId:e,provider:t,stats:_(e,s),authType:Array.isArray(s)?s[0]??"apikey":s,onToggle:t=>F(e,s,t)},e)})]})]}),q.length>0&&(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)("h2",{className:"text-lg sm:text-xl font-semibold flex items-center gap-2 leading-tight",children:["API Key Providers"," "]}),(0,a.jsxs)("button",{onClick:()=>M("apikey"),disabled:!!I,className:`flex w-full items-center justify-center gap-1.5 rounded-lg border px-3 py-2 text-xs font-medium transition-colors sm:w-auto sm:py-1.5 ${"apikey"===I?"bg-primary/20 border-primary/40 text-primary animate-pulse":"bg-bg border-border text-text-muted hover:text-text-main hover:border-primary/40"}`,title:"Test all API Key connections","aria-label":"Test all API Key connections",children:[(0,a.jsx)("span",{className:`material-symbols-outlined text-[14px]${"apikey"===I?" animate-spin":""}`,children:"play_arrow"}),"apikey"===I?"Testing...":"Test All"]})]}),(0,a.jsx)("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-2 sm:gap-4 lg:grid-cols-3 xl:grid-cols-4",children:Y.map(([e,t])=>(0,a.jsx)(C,{providerId:e,provider:t,stats:_(e,"apikey"),authType:"apikey",onToggle:t=>F(e,"apikey",t)},e))}),!V&&!b&&Q>0&&(0,a.jsxs)("button",{onClick:()=>g(!0),className:"flex w-full items-center justify-center gap-1.5 rounded-lg border border-dashed border-primary/40 px-3 py-2.5 text-sm font-medium text-primary transition-colors hover:border-primary hover:bg-primary/5",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[16px]",children:"expand_more"}),"Show all ",q.length," providers"]})]}),G.length>0&&(0,a.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,a.jsx)("div",{className:"flex items-center justify-between",children:(0,a.jsxs)("h2",{className:"text-lg sm:text-xl font-semibold flex items-center gap-2 leading-tight",children:["Web Cookie Providers"," "]})}),(0,a.jsx)("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-4",children:G.map(([e,t])=>(0,a.jsx)(C,{providerId:e,provider:t,stats:_(e,"cookie"),authType:"cookie",onToggle:t=>F(e,"cookie",t)},e))})]}),(0,a.jsx)(y,{variant:"openai",isOpen:v,onClose:()=>N(!1),onCreated:e=>{m(t=>[...t,e]),N(!1)}}),(0,a.jsx)(y,{variant:"anthropic",isOpen:w,onClose:()=>T(!1),onCreated:e=>{m(t=>[...t,e]),T(!1)}}),O&&(0,a.jsxs)("div",{className:"fixed inset-0 z-50 flex items-start justify-center px-3 pt-[6vh] sm:pt-[10vh]",onClick:()=>S(null),children:[(0,a.jsx)("div",{className:"absolute inset-0 bg-black/60 backdrop-blur-sm"}),(0,a.jsxs)("div",{className:"relative bg-surface border border-border rounded-xl w-full max-w-[600px] max-h-[86vh] sm:max-h-[80vh] overflow-y-auto shadow-2xl",onClick:e=>e.stopPropagation(),children:[(0,a.jsxs)("div",{className:"sticky top-0 z-10 flex items-center justify-between px-5 py-3 border-b border-border bg-surface/95 backdrop-blur-sm rounded-t-xl",children:[(0,a.jsx)("h3",{className:"font-semibold",children:"Test Results"}),(0,a.jsx)("button",{onClick:()=>S(null),className:"p-1 rounded-lg hover:bg-bg text-text-muted hover:text-text-main transition-colors","aria-label":"Close test results",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-lg",children:"close"})})]}),(0,a.jsx)("div",{className:"p-5",children:(0,a.jsx)(A,{results:O})})]})]})]})}function k({providerId:e,provider:t,stats:s,authType:r,onToggle:n,circuitBreaker:o,onResetCircuit:c}){let{allDisabled:d}=s,m=!!t.noAuth;return(0,a.jsx)(p(),{href:`/dashboard/providers/${e}`,className:"group min-w-0",children:(0,a.jsx)(l.Card,{padding:"xs",className:`h-full hover:bg-black/[0.01] dark:hover:bg-white/[0.01] transition-colors cursor-pointer ${d?"opacity-50":""}`,children:(0,a.jsxs)("div",{className:"flex min-w-0 items-center justify-between gap-3",children:[(0,a.jsxs)("div",{className:"flex min-w-0 items-center gap-3",children:[(0,a.jsx)("div",{className:"size-8 shrink-0 rounded-lg flex items-center justify-center",style:{backgroundColor:`${t.color?.length>7?t.color:t.color+"15"}`},children:(0,a.jsx)(i.A,{src:`/providers/${t.id}.webp`,alt:t.name,size:30,className:"object-contain rounded-lg max-w-[32px] max-h-[32px]",fallbackText:t.textIcon||t.id.slice(0,2).toUpperCase(),fallbackColor:t.color})}),(0,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsx)("h3",{className:"truncate font-semibold",children:t.name}),(0,a.jsx)("div",{className:"flex min-w-0 items-center gap-1.5 text-xs flex-wrap",children:d?(0,a.jsx)(l.Badge,{variant:"default",size:"sm",children:(0,a.jsxs)("span",{className:"flex items-center gap-1",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[12px]",children:"pause_circle"}),"Disabled"]})}):m?(0,a.jsx)(l.Badge,{variant:"success",size:"sm",dot:!0,children:"Ready"}):(0,a.jsxs)(a.Fragment,{children:[N(s),o&&(0,a.jsx)(v,{status:o,onReset:()=>c(e)})]})})]})]}),(0,a.jsx)("div",{className:"flex shrink-0 items-center gap-2",children:s.total>0&&(0,a.jsx)("div",{className:"opacity-100 transition-opacity sm:opacity-0 sm:group-hover:opacity-100",onClick:e=>{e.preventDefault(),e.stopPropagation(),n(!!d)},children:(0,a.jsx)(l.Toggle,{size:"sm",checked:!d,onChange:()=>{},title:d?"Enable provider":"Disable provider"})})})]})})})}function C({providerId:e,provider:t,stats:s,authType:r,onToggle:o,circuitBreaker:c,onResetCircuit:m}){let{allDisabled:x}=s,u=e.startsWith(d.JH),h=e.startsWith(d.DI);return(0,a.jsx)(p(),{href:`/dashboard/providers/${e}`,className:"group min-w-0",children:(0,a.jsx)(l.Card,{padding:"xs",className:`h-full hover:bg-black/[0.01] dark:hover:bg-white/[0.01] transition-colors cursor-pointer ${x?"opacity-50":""}`,children:(0,a.jsxs)("div",{className:"flex min-w-0 items-center justify-between gap-3",children:[(0,a.jsxs)("div",{className:"flex min-w-0 items-center gap-3",children:[(0,a.jsx)("div",{className:"size-8 shrink-0 rounded-lg flex items-center justify-center",style:{backgroundColor:`${t.color?.length>7?t.color:t.color+"15"}`},children:(0,a.jsx)(i.A,{src:u&&t.apiType?"responses"===t.apiType?"/providers/oai-r.webp":"/providers/oai-cc.webp":h?"/providers/anthropic-m.webp":(0,n.HY)(t.id),alt:t.name,size:30,className:"object-contain rounded-lg max-w-[30px] max-h-[30px]",fallbackText:t.textIcon||t.id.slice(0,2).toUpperCase(),fallbackColor:t.color})}),(0,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsx)("h3",{className:"truncate font-semibold",children:t.name}),(0,a.jsx)("div",{className:"flex min-w-0 items-center gap-1.5 text-xs flex-wrap",children:x?(0,a.jsx)(l.Badge,{variant:"default",size:"sm",children:(0,a.jsxs)("span",{className:"flex items-center gap-1",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[12px]",children:"pause_circle"}),"Disabled"]})}):(0,a.jsxs)(a.Fragment,{children:[N(s),u&&(0,a.jsx)(l.Badge,{variant:"default",size:"sm",children:"responses"===t.apiType?"Responses":"Chat"}),h&&(0,a.jsx)(l.Badge,{variant:"default",size:"sm",children:"Messages"})]})})]})]}),(0,a.jsx)("div",{className:"flex shrink-0 items-center gap-2",children:s.total>0&&(0,a.jsx)("div",{className:"opacity-100 transition-opacity sm:opacity-0 sm:group-hover:opacity-100",onClick:e=>{e.preventDefault(),e.stopPropagation(),o(!!x)},children:(0,a.jsx)(l.Toggle,{size:"sm",checked:!x,onChange:()=>{},title:x?"Enable provider":"Disable provider"})})})]})})})}function A({results:e}){if(e.error&&!e.results)return(0,a.jsxs)("div",{className:"text-center py-6",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-red-500 text-[32px] mb-2 block",children:"error"}),(0,a.jsx)("p",{className:"text-sm text-red-400",children:e.error})]});let{summary:t,mode:s}=e,r=e.results||[];return(0,a.jsxs)("div",{className:"flex min-w-0 flex-col gap-3",children:[t&&(0,a.jsxs)("div",{className:"flex flex-wrap items-center gap-2 text-xs mb-1 sm:gap-3",children:[(0,a.jsxs)("span",{className:"text-text-muted",children:[{oauth:"OAuth",free:"Free",apikey:"API Key",provider:"Provider",all:"All"}[s]||s," Test"]}),(0,a.jsxs)("span",{className:"px-2 py-0.5 rounded bg-emerald-500/15 text-emerald-400 font-medium",children:[t.passed," passed"]}),t.failed>0&&(0,a.jsxs)("span",{className:"px-2 py-0.5 rounded bg-red-500/15 text-red-400 font-medium",children:[t.failed," failed"]}),(0,a.jsxs)("span",{className:"text-text-muted sm:ml-auto",children:[t.total," tested"]})]}),r.map((e,t)=>(0,a.jsxs)("div",{className:"flex min-w-0 flex-wrap items-center gap-2 rounded-lg bg-black/[0.03] px-3 py-2 text-xs dark:bg-white/[0.03] sm:flex-nowrap",children:[(0,a.jsx)("span",{className:`material-symbols-outlined text-[16px] ${e.valid?"text-emerald-500":"text-red-500"}`,children:e.valid?"check_circle":"error"}),(0,a.jsxs)("div",{className:"min-w-0 flex-[1_1_160px]",children:[(0,a.jsx)("span",{className:"block truncate font-medium sm:inline",children:e.connectionName}),(0,a.jsxs)("span",{className:"block truncate text-text-muted sm:ml-1.5 sm:inline",children:["(",e.provider,")"]})]}),void 0!==e.latencyMs&&(0,a.jsxs)("span",{className:"shrink-0 text-text-muted font-mono tabular-nums",children:[e.latencyMs,"ms"]}),(0,a.jsx)("span",{className:`shrink-0 text-[10px] uppercase font-bold px-1.5 py-0.5 rounded ${e.valid?"bg-emerald-500/15 text-emerald-400":"bg-red-500/15 text-red-400"}`,children:e.valid?"OK":e.diagnosis?.type||"ERROR"})]},e.connectionId||t)),0===r.length&&(0,a.jsx)("div",{className:"text-center py-4 text-text-muted text-sm",children:"No active connections found for this group."})]})}},21863:(e,t,s)=>{"use strict";function a(e,t){return!1===e?"default":"active"===t||"success"===t?"success":"error"===t||"expired"===t||"unavailable"===t?"error":"default"}function r(e){let t=e?.testStatus;return e?.isActive===!1||"unavailable"===t||"error"===t||"expired"===t?"unavailable":"active"}s.d(t,{d:()=>r,g:()=>a})},48271:(e,t,s)=>{"use strict";s.d(t,{gm:()=>r});let a=new Map;function r(e,t={}){a.delete(JSON.stringify([String(e),t?.method||"GET",t?.headers||{},t?.body||null]))}},77048:(e,t,s)=>{Promise.resolve().then(s.bind(s,21511))}},e=>{e.O(0,[3885,2318,4385,2940,2147,3204,7358],()=>e(e.s=77048)),_N_E=e.O()}]);