zevairouter 1.0.145 → 1.0.147

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 (338) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/cli/app/.next-cli-build/BUILD_ID +1 -1
  3. package/cli/app/.next-cli-build/app-path-routes-manifest.json +9 -9
  4. package/cli/app/.next-cli-build/build-manifest.json +2 -2
  5. package/cli/app/.next-cli-build/server/app/(dashboard)/dashboard/automation/page_client-reference-manifest.js +1 -1
  6. package/cli/app/.next-cli-build/server/app/(dashboard)/dashboard/basic-chat/page_client-reference-manifest.js +1 -1
  7. package/cli/app/.next-cli-build/server/app/(dashboard)/dashboard/cli-tools/[toolId]/page_client-reference-manifest.js +1 -1
  8. package/cli/app/.next-cli-build/server/app/(dashboard)/dashboard/cli-tools/page_client-reference-manifest.js +1 -1
  9. package/cli/app/.next-cli-build/server/app/(dashboard)/dashboard/combos/page_client-reference-manifest.js +1 -1
  10. package/cli/app/.next-cli-build/server/app/(dashboard)/dashboard/console-log/page_client-reference-manifest.js +1 -1
  11. package/cli/app/.next-cli-build/server/app/(dashboard)/dashboard/context/page_client-reference-manifest.js +1 -1
  12. package/cli/app/.next-cli-build/server/app/(dashboard)/dashboard/endpoint/page_client-reference-manifest.js +1 -1
  13. package/cli/app/.next-cli-build/server/app/(dashboard)/dashboard/media-providers/[kind]/[id]/page_client-reference-manifest.js +1 -1
  14. package/cli/app/.next-cli-build/server/app/(dashboard)/dashboard/media-providers/[kind]/page_client-reference-manifest.js +1 -1
  15. package/cli/app/.next-cli-build/server/app/(dashboard)/dashboard/media-providers/combo/[id]/page_client-reference-manifest.js +1 -1
  16. package/cli/app/.next-cli-build/server/app/(dashboard)/dashboard/media-providers/web/page_client-reference-manifest.js +1 -1
  17. package/cli/app/.next-cli-build/server/app/(dashboard)/dashboard/mitm/page_client-reference-manifest.js +1 -1
  18. package/cli/app/.next-cli-build/server/app/(dashboard)/dashboard/page_client-reference-manifest.js +1 -1
  19. package/cli/app/.next-cli-build/server/app/(dashboard)/dashboard/playground/page_client-reference-manifest.js +1 -1
  20. package/cli/app/.next-cli-build/server/app/(dashboard)/dashboard/profile/page_client-reference-manifest.js +1 -1
  21. package/cli/app/.next-cli-build/server/app/(dashboard)/dashboard/providers/[id]/page_client-reference-manifest.js +1 -1
  22. package/cli/app/.next-cli-build/server/app/(dashboard)/dashboard/providers/new/page_client-reference-manifest.js +1 -1
  23. package/cli/app/.next-cli-build/server/app/(dashboard)/dashboard/providers/page.js +1 -1
  24. package/cli/app/.next-cli-build/server/app/(dashboard)/dashboard/providers/page_client-reference-manifest.js +1 -1
  25. package/cli/app/.next-cli-build/server/app/(dashboard)/dashboard/proxy-pools/page_client-reference-manifest.js +1 -1
  26. package/cli/app/.next-cli-build/server/app/(dashboard)/dashboard/pxpipe/page_client-reference-manifest.js +1 -1
  27. package/cli/app/.next-cli-build/server/app/(dashboard)/dashboard/quota/page.js +1 -1
  28. package/cli/app/.next-cli-build/server/app/(dashboard)/dashboard/quota/page_client-reference-manifest.js +1 -1
  29. package/cli/app/.next-cli-build/server/app/(dashboard)/dashboard/terminal/page_client-reference-manifest.js +1 -1
  30. package/cli/app/.next-cli-build/server/app/(dashboard)/dashboard/token-saver/page_client-reference-manifest.js +1 -1
  31. package/cli/app/.next-cli-build/server/app/(dashboard)/dashboard/translator/page_client-reference-manifest.js +1 -1
  32. package/cli/app/.next-cli-build/server/app/(dashboard)/dashboard/usage/page_client-reference-manifest.js +1 -1
  33. package/cli/app/.next-cli-build/server/app/_global-error/page_client-reference-manifest.js +1 -1
  34. package/cli/app/.next-cli-build/server/app/_global-error.html +1 -1
  35. package/cli/app/.next-cli-build/server/app/_global-error.rsc +1 -1
  36. package/cli/app/.next-cli-build/server/app/_global-error.segments/_full.segment.rsc +1 -1
  37. package/cli/app/.next-cli-build/server/app/_global-error.segments/_global-error/__PAGE__.segment.rsc +1 -1
  38. package/cli/app/.next-cli-build/server/app/_global-error.segments/_global-error.segment.rsc +1 -1
  39. package/cli/app/.next-cli-build/server/app/_global-error.segments/_head.segment.rsc +1 -1
  40. package/cli/app/.next-cli-build/server/app/_global-error.segments/_index.segment.rsc +1 -1
  41. package/cli/app/.next-cli-build/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  42. package/cli/app/.next-cli-build/server/app/_not-found/page_client-reference-manifest.js +1 -1
  43. package/cli/app/.next-cli-build/server/app/_not-found.html +1 -1
  44. package/cli/app/.next-cli-build/server/app/_not-found.rsc +4 -4
  45. package/cli/app/.next-cli-build/server/app/_not-found.segments/_full.segment.rsc +4 -4
  46. package/cli/app/.next-cli-build/server/app/_not-found.segments/_head.segment.rsc +1 -1
  47. package/cli/app/.next-cli-build/server/app/_not-found.segments/_index.segment.rsc +4 -4
  48. package/cli/app/.next-cli-build/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +1 -1
  49. package/cli/app/.next-cli-build/server/app/_not-found.segments/_not-found.segment.rsc +1 -1
  50. package/cli/app/.next-cli-build/server/app/_not-found.segments/_tree.segment.rsc +2 -2
  51. package/cli/app/.next-cli-build/server/app/api/models/route.js +1 -1
  52. package/cli/app/.next-cli-build/server/app/api/providers/route.js +1 -1
  53. package/cli/app/.next-cli-build/server/app/api/providers/validate/route.js +1 -1
  54. package/cli/app/.next-cli-build/server/app/api/translator/console-logs/route.js +1 -1
  55. package/cli/app/.next-cli-build/server/app/api/translator/console-logs/stream/route.js +1 -1
  56. package/cli/app/.next-cli-build/server/app/api/version/route.js +1 -1
  57. package/cli/app/.next-cli-build/server/app/api/version/shutdown/route.js +1 -1
  58. package/cli/app/.next-cli-build/server/app/api/version/update/route.js +1 -1
  59. package/cli/app/.next-cli-build/server/app/callback/page_client-reference-manifest.js +1 -1
  60. package/cli/app/.next-cli-build/server/app/callback.html +1 -1
  61. package/cli/app/.next-cli-build/server/app/callback.rsc +4 -4
  62. package/cli/app/.next-cli-build/server/app/callback.segments/_full.segment.rsc +4 -4
  63. package/cli/app/.next-cli-build/server/app/callback.segments/_head.segment.rsc +1 -1
  64. package/cli/app/.next-cli-build/server/app/callback.segments/_index.segment.rsc +4 -4
  65. package/cli/app/.next-cli-build/server/app/callback.segments/_tree.segment.rsc +2 -2
  66. package/cli/app/.next-cli-build/server/app/callback.segments/callback/__PAGE__.segment.rsc +1 -1
  67. package/cli/app/.next-cli-build/server/app/callback.segments/callback.segment.rsc +1 -1
  68. package/cli/app/.next-cli-build/server/app/dashboard/automation.html +1 -1
  69. package/cli/app/.next-cli-build/server/app/dashboard/automation.rsc +6 -6
  70. package/cli/app/.next-cli-build/server/app/dashboard/automation.segments/!KGRhc2hib2FyZCk/dashboard/automation/__PAGE__.segment.rsc +2 -2
  71. package/cli/app/.next-cli-build/server/app/dashboard/automation.segments/!KGRhc2hib2FyZCk/dashboard/automation.segment.rsc +1 -1
  72. package/cli/app/.next-cli-build/server/app/dashboard/automation.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  73. package/cli/app/.next-cli-build/server/app/dashboard/automation.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  74. package/cli/app/.next-cli-build/server/app/dashboard/automation.segments/_full.segment.rsc +6 -6
  75. package/cli/app/.next-cli-build/server/app/dashboard/automation.segments/_head.segment.rsc +1 -1
  76. package/cli/app/.next-cli-build/server/app/dashboard/automation.segments/_index.segment.rsc +4 -4
  77. package/cli/app/.next-cli-build/server/app/dashboard/automation.segments/_tree.segment.rsc +2 -2
  78. package/cli/app/.next-cli-build/server/app/dashboard/basic-chat.html +1 -1
  79. package/cli/app/.next-cli-build/server/app/dashboard/basic-chat.rsc +6 -6
  80. package/cli/app/.next-cli-build/server/app/dashboard/basic-chat.segments/!KGRhc2hib2FyZCk/dashboard/basic-chat/__PAGE__.segment.rsc +2 -2
  81. package/cli/app/.next-cli-build/server/app/dashboard/basic-chat.segments/!KGRhc2hib2FyZCk/dashboard/basic-chat.segment.rsc +1 -1
  82. package/cli/app/.next-cli-build/server/app/dashboard/basic-chat.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  83. package/cli/app/.next-cli-build/server/app/dashboard/basic-chat.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  84. package/cli/app/.next-cli-build/server/app/dashboard/basic-chat.segments/_full.segment.rsc +6 -6
  85. package/cli/app/.next-cli-build/server/app/dashboard/basic-chat.segments/_head.segment.rsc +1 -1
  86. package/cli/app/.next-cli-build/server/app/dashboard/basic-chat.segments/_index.segment.rsc +4 -4
  87. package/cli/app/.next-cli-build/server/app/dashboard/basic-chat.segments/_tree.segment.rsc +2 -2
  88. package/cli/app/.next-cli-build/server/app/dashboard/cli-tools.html +1 -1
  89. package/cli/app/.next-cli-build/server/app/dashboard/cli-tools.rsc +6 -6
  90. package/cli/app/.next-cli-build/server/app/dashboard/cli-tools.segments/!KGRhc2hib2FyZCk/dashboard/cli-tools/__PAGE__.segment.rsc +2 -2
  91. package/cli/app/.next-cli-build/server/app/dashboard/cli-tools.segments/!KGRhc2hib2FyZCk/dashboard/cli-tools.segment.rsc +1 -1
  92. package/cli/app/.next-cli-build/server/app/dashboard/cli-tools.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  93. package/cli/app/.next-cli-build/server/app/dashboard/cli-tools.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  94. package/cli/app/.next-cli-build/server/app/dashboard/cli-tools.segments/_full.segment.rsc +6 -6
  95. package/cli/app/.next-cli-build/server/app/dashboard/cli-tools.segments/_head.segment.rsc +1 -1
  96. package/cli/app/.next-cli-build/server/app/dashboard/cli-tools.segments/_index.segment.rsc +4 -4
  97. package/cli/app/.next-cli-build/server/app/dashboard/cli-tools.segments/_tree.segment.rsc +2 -2
  98. package/cli/app/.next-cli-build/server/app/dashboard/combos.html +1 -1
  99. package/cli/app/.next-cli-build/server/app/dashboard/combos.rsc +6 -6
  100. package/cli/app/.next-cli-build/server/app/dashboard/combos.segments/!KGRhc2hib2FyZCk/dashboard/combos/__PAGE__.segment.rsc +2 -2
  101. package/cli/app/.next-cli-build/server/app/dashboard/combos.segments/!KGRhc2hib2FyZCk/dashboard/combos.segment.rsc +1 -1
  102. package/cli/app/.next-cli-build/server/app/dashboard/combos.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  103. package/cli/app/.next-cli-build/server/app/dashboard/combos.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  104. package/cli/app/.next-cli-build/server/app/dashboard/combos.segments/_full.segment.rsc +6 -6
  105. package/cli/app/.next-cli-build/server/app/dashboard/combos.segments/_head.segment.rsc +1 -1
  106. package/cli/app/.next-cli-build/server/app/dashboard/combos.segments/_index.segment.rsc +4 -4
  107. package/cli/app/.next-cli-build/server/app/dashboard/combos.segments/_tree.segment.rsc +2 -2
  108. package/cli/app/.next-cli-build/server/app/dashboard/context.html +1 -1
  109. package/cli/app/.next-cli-build/server/app/dashboard/context.rsc +6 -6
  110. package/cli/app/.next-cli-build/server/app/dashboard/context.segments/!KGRhc2hib2FyZCk/dashboard/context/__PAGE__.segment.rsc +2 -2
  111. package/cli/app/.next-cli-build/server/app/dashboard/context.segments/!KGRhc2hib2FyZCk/dashboard/context.segment.rsc +1 -1
  112. package/cli/app/.next-cli-build/server/app/dashboard/context.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  113. package/cli/app/.next-cli-build/server/app/dashboard/context.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  114. package/cli/app/.next-cli-build/server/app/dashboard/context.segments/_full.segment.rsc +6 -6
  115. package/cli/app/.next-cli-build/server/app/dashboard/context.segments/_head.segment.rsc +1 -1
  116. package/cli/app/.next-cli-build/server/app/dashboard/context.segments/_index.segment.rsc +4 -4
  117. package/cli/app/.next-cli-build/server/app/dashboard/context.segments/_tree.segment.rsc +2 -2
  118. package/cli/app/.next-cli-build/server/app/dashboard/endpoint.html +1 -1
  119. package/cli/app/.next-cli-build/server/app/dashboard/endpoint.rsc +6 -6
  120. package/cli/app/.next-cli-build/server/app/dashboard/endpoint.segments/!KGRhc2hib2FyZCk/dashboard/endpoint/__PAGE__.segment.rsc +2 -2
  121. package/cli/app/.next-cli-build/server/app/dashboard/endpoint.segments/!KGRhc2hib2FyZCk/dashboard/endpoint.segment.rsc +1 -1
  122. package/cli/app/.next-cli-build/server/app/dashboard/endpoint.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  123. package/cli/app/.next-cli-build/server/app/dashboard/endpoint.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  124. package/cli/app/.next-cli-build/server/app/dashboard/endpoint.segments/_full.segment.rsc +6 -6
  125. package/cli/app/.next-cli-build/server/app/dashboard/endpoint.segments/_head.segment.rsc +1 -1
  126. package/cli/app/.next-cli-build/server/app/dashboard/endpoint.segments/_index.segment.rsc +4 -4
  127. package/cli/app/.next-cli-build/server/app/dashboard/endpoint.segments/_tree.segment.rsc +2 -2
  128. package/cli/app/.next-cli-build/server/app/dashboard/media-providers/web.html +1 -1
  129. package/cli/app/.next-cli-build/server/app/dashboard/media-providers/web.rsc +6 -6
  130. package/cli/app/.next-cli-build/server/app/dashboard/media-providers/web.segments/!KGRhc2hib2FyZCk/dashboard/media-providers/web/__PAGE__.segment.rsc +2 -2
  131. package/cli/app/.next-cli-build/server/app/dashboard/media-providers/web.segments/!KGRhc2hib2FyZCk/dashboard/media-providers/web.segment.rsc +1 -1
  132. package/cli/app/.next-cli-build/server/app/dashboard/media-providers/web.segments/!KGRhc2hib2FyZCk/dashboard/media-providers.segment.rsc +1 -1
  133. package/cli/app/.next-cli-build/server/app/dashboard/media-providers/web.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  134. package/cli/app/.next-cli-build/server/app/dashboard/media-providers/web.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  135. package/cli/app/.next-cli-build/server/app/dashboard/media-providers/web.segments/_full.segment.rsc +6 -6
  136. package/cli/app/.next-cli-build/server/app/dashboard/media-providers/web.segments/_head.segment.rsc +1 -1
  137. package/cli/app/.next-cli-build/server/app/dashboard/media-providers/web.segments/_index.segment.rsc +4 -4
  138. package/cli/app/.next-cli-build/server/app/dashboard/media-providers/web.segments/_tree.segment.rsc +2 -2
  139. package/cli/app/.next-cli-build/server/app/dashboard/mitm.html +1 -1
  140. package/cli/app/.next-cli-build/server/app/dashboard/mitm.rsc +6 -6
  141. package/cli/app/.next-cli-build/server/app/dashboard/mitm.segments/!KGRhc2hib2FyZCk/dashboard/mitm/__PAGE__.segment.rsc +2 -2
  142. package/cli/app/.next-cli-build/server/app/dashboard/mitm.segments/!KGRhc2hib2FyZCk/dashboard/mitm.segment.rsc +1 -1
  143. package/cli/app/.next-cli-build/server/app/dashboard/mitm.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  144. package/cli/app/.next-cli-build/server/app/dashboard/mitm.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  145. package/cli/app/.next-cli-build/server/app/dashboard/mitm.segments/_full.segment.rsc +6 -6
  146. package/cli/app/.next-cli-build/server/app/dashboard/mitm.segments/_head.segment.rsc +1 -1
  147. package/cli/app/.next-cli-build/server/app/dashboard/mitm.segments/_index.segment.rsc +4 -4
  148. package/cli/app/.next-cli-build/server/app/dashboard/mitm.segments/_tree.segment.rsc +2 -2
  149. package/cli/app/.next-cli-build/server/app/dashboard/playground.html +1 -1
  150. package/cli/app/.next-cli-build/server/app/dashboard/playground.rsc +6 -6
  151. package/cli/app/.next-cli-build/server/app/dashboard/playground.segments/!KGRhc2hib2FyZCk/dashboard/playground/__PAGE__.segment.rsc +2 -2
  152. package/cli/app/.next-cli-build/server/app/dashboard/playground.segments/!KGRhc2hib2FyZCk/dashboard/playground.segment.rsc +1 -1
  153. package/cli/app/.next-cli-build/server/app/dashboard/playground.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  154. package/cli/app/.next-cli-build/server/app/dashboard/playground.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  155. package/cli/app/.next-cli-build/server/app/dashboard/playground.segments/_full.segment.rsc +6 -6
  156. package/cli/app/.next-cli-build/server/app/dashboard/playground.segments/_head.segment.rsc +1 -1
  157. package/cli/app/.next-cli-build/server/app/dashboard/playground.segments/_index.segment.rsc +4 -4
  158. package/cli/app/.next-cli-build/server/app/dashboard/playground.segments/_tree.segment.rsc +2 -2
  159. package/cli/app/.next-cli-build/server/app/dashboard/profile.html +1 -1
  160. package/cli/app/.next-cli-build/server/app/dashboard/profile.rsc +6 -6
  161. package/cli/app/.next-cli-build/server/app/dashboard/profile.segments/!KGRhc2hib2FyZCk/dashboard/profile/__PAGE__.segment.rsc +2 -2
  162. package/cli/app/.next-cli-build/server/app/dashboard/profile.segments/!KGRhc2hib2FyZCk/dashboard/profile.segment.rsc +1 -1
  163. package/cli/app/.next-cli-build/server/app/dashboard/profile.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  164. package/cli/app/.next-cli-build/server/app/dashboard/profile.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  165. package/cli/app/.next-cli-build/server/app/dashboard/profile.segments/_full.segment.rsc +6 -6
  166. package/cli/app/.next-cli-build/server/app/dashboard/profile.segments/_head.segment.rsc +1 -1
  167. package/cli/app/.next-cli-build/server/app/dashboard/profile.segments/_index.segment.rsc +4 -4
  168. package/cli/app/.next-cli-build/server/app/dashboard/profile.segments/_tree.segment.rsc +2 -2
  169. package/cli/app/.next-cli-build/server/app/dashboard/providers/new.html +1 -1
  170. package/cli/app/.next-cli-build/server/app/dashboard/providers/new.rsc +6 -6
  171. package/cli/app/.next-cli-build/server/app/dashboard/providers/new.segments/!KGRhc2hib2FyZCk/dashboard/providers/new/__PAGE__.segment.rsc +2 -2
  172. package/cli/app/.next-cli-build/server/app/dashboard/providers/new.segments/!KGRhc2hib2FyZCk/dashboard/providers/new.segment.rsc +1 -1
  173. package/cli/app/.next-cli-build/server/app/dashboard/providers/new.segments/!KGRhc2hib2FyZCk/dashboard/providers.segment.rsc +1 -1
  174. package/cli/app/.next-cli-build/server/app/dashboard/providers/new.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  175. package/cli/app/.next-cli-build/server/app/dashboard/providers/new.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  176. package/cli/app/.next-cli-build/server/app/dashboard/providers/new.segments/_full.segment.rsc +6 -6
  177. package/cli/app/.next-cli-build/server/app/dashboard/providers/new.segments/_head.segment.rsc +1 -1
  178. package/cli/app/.next-cli-build/server/app/dashboard/providers/new.segments/_index.segment.rsc +4 -4
  179. package/cli/app/.next-cli-build/server/app/dashboard/providers/new.segments/_tree.segment.rsc +2 -2
  180. package/cli/app/.next-cli-build/server/app/dashboard/providers.html +1 -1
  181. package/cli/app/.next-cli-build/server/app/dashboard/providers.rsc +6 -6
  182. package/cli/app/.next-cli-build/server/app/dashboard/providers.segments/!KGRhc2hib2FyZCk/dashboard/providers/__PAGE__.segment.rsc +2 -2
  183. package/cli/app/.next-cli-build/server/app/dashboard/providers.segments/!KGRhc2hib2FyZCk/dashboard/providers.segment.rsc +1 -1
  184. package/cli/app/.next-cli-build/server/app/dashboard/providers.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  185. package/cli/app/.next-cli-build/server/app/dashboard/providers.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  186. package/cli/app/.next-cli-build/server/app/dashboard/providers.segments/_full.segment.rsc +6 -6
  187. package/cli/app/.next-cli-build/server/app/dashboard/providers.segments/_head.segment.rsc +1 -1
  188. package/cli/app/.next-cli-build/server/app/dashboard/providers.segments/_index.segment.rsc +4 -4
  189. package/cli/app/.next-cli-build/server/app/dashboard/providers.segments/_tree.segment.rsc +2 -2
  190. package/cli/app/.next-cli-build/server/app/dashboard/proxy-pools.html +1 -1
  191. package/cli/app/.next-cli-build/server/app/dashboard/proxy-pools.rsc +6 -6
  192. package/cli/app/.next-cli-build/server/app/dashboard/proxy-pools.segments/!KGRhc2hib2FyZCk/dashboard/proxy-pools/__PAGE__.segment.rsc +2 -2
  193. package/cli/app/.next-cli-build/server/app/dashboard/proxy-pools.segments/!KGRhc2hib2FyZCk/dashboard/proxy-pools.segment.rsc +1 -1
  194. package/cli/app/.next-cli-build/server/app/dashboard/proxy-pools.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  195. package/cli/app/.next-cli-build/server/app/dashboard/proxy-pools.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  196. package/cli/app/.next-cli-build/server/app/dashboard/proxy-pools.segments/_full.segment.rsc +6 -6
  197. package/cli/app/.next-cli-build/server/app/dashboard/proxy-pools.segments/_head.segment.rsc +1 -1
  198. package/cli/app/.next-cli-build/server/app/dashboard/proxy-pools.segments/_index.segment.rsc +4 -4
  199. package/cli/app/.next-cli-build/server/app/dashboard/proxy-pools.segments/_tree.segment.rsc +2 -2
  200. package/cli/app/.next-cli-build/server/app/dashboard/pxpipe.html +1 -1
  201. package/cli/app/.next-cli-build/server/app/dashboard/pxpipe.rsc +6 -6
  202. package/cli/app/.next-cli-build/server/app/dashboard/pxpipe.segments/!KGRhc2hib2FyZCk/dashboard/pxpipe/__PAGE__.segment.rsc +2 -2
  203. package/cli/app/.next-cli-build/server/app/dashboard/pxpipe.segments/!KGRhc2hib2FyZCk/dashboard/pxpipe.segment.rsc +1 -1
  204. package/cli/app/.next-cli-build/server/app/dashboard/pxpipe.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  205. package/cli/app/.next-cli-build/server/app/dashboard/pxpipe.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  206. package/cli/app/.next-cli-build/server/app/dashboard/pxpipe.segments/_full.segment.rsc +6 -6
  207. package/cli/app/.next-cli-build/server/app/dashboard/pxpipe.segments/_head.segment.rsc +1 -1
  208. package/cli/app/.next-cli-build/server/app/dashboard/pxpipe.segments/_index.segment.rsc +4 -4
  209. package/cli/app/.next-cli-build/server/app/dashboard/pxpipe.segments/_tree.segment.rsc +2 -2
  210. package/cli/app/.next-cli-build/server/app/dashboard/quota.html +2 -2
  211. package/cli/app/.next-cli-build/server/app/dashboard/quota.rsc +7 -7
  212. package/cli/app/.next-cli-build/server/app/dashboard/quota.segments/!KGRhc2hib2FyZCk/dashboard/quota/__PAGE__.segment.rsc +3 -3
  213. package/cli/app/.next-cli-build/server/app/dashboard/quota.segments/!KGRhc2hib2FyZCk/dashboard/quota.segment.rsc +1 -1
  214. package/cli/app/.next-cli-build/server/app/dashboard/quota.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  215. package/cli/app/.next-cli-build/server/app/dashboard/quota.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  216. package/cli/app/.next-cli-build/server/app/dashboard/quota.segments/_full.segment.rsc +7 -7
  217. package/cli/app/.next-cli-build/server/app/dashboard/quota.segments/_head.segment.rsc +1 -1
  218. package/cli/app/.next-cli-build/server/app/dashboard/quota.segments/_index.segment.rsc +4 -4
  219. package/cli/app/.next-cli-build/server/app/dashboard/quota.segments/_tree.segment.rsc +2 -2
  220. package/cli/app/.next-cli-build/server/app/dashboard/settings/pricing/page_client-reference-manifest.js +1 -1
  221. package/cli/app/.next-cli-build/server/app/dashboard/settings/pricing.html +1 -1
  222. package/cli/app/.next-cli-build/server/app/dashboard/settings/pricing.rsc +4 -4
  223. package/cli/app/.next-cli-build/server/app/dashboard/settings/pricing.segments/_full.segment.rsc +4 -4
  224. package/cli/app/.next-cli-build/server/app/dashboard/settings/pricing.segments/_head.segment.rsc +1 -1
  225. package/cli/app/.next-cli-build/server/app/dashboard/settings/pricing.segments/_index.segment.rsc +4 -4
  226. package/cli/app/.next-cli-build/server/app/dashboard/settings/pricing.segments/_tree.segment.rsc +2 -2
  227. package/cli/app/.next-cli-build/server/app/dashboard/settings/pricing.segments/dashboard/settings/pricing/__PAGE__.segment.rsc +1 -1
  228. package/cli/app/.next-cli-build/server/app/dashboard/settings/pricing.segments/dashboard/settings/pricing.segment.rsc +1 -1
  229. package/cli/app/.next-cli-build/server/app/dashboard/settings/pricing.segments/dashboard/settings.segment.rsc +1 -1
  230. package/cli/app/.next-cli-build/server/app/dashboard/settings/pricing.segments/dashboard.segment.rsc +1 -1
  231. package/cli/app/.next-cli-build/server/app/dashboard/token-saver.html +1 -1
  232. package/cli/app/.next-cli-build/server/app/dashboard/token-saver.rsc +6 -6
  233. package/cli/app/.next-cli-build/server/app/dashboard/token-saver.segments/!KGRhc2hib2FyZCk/dashboard/token-saver/__PAGE__.segment.rsc +2 -2
  234. package/cli/app/.next-cli-build/server/app/dashboard/token-saver.segments/!KGRhc2hib2FyZCk/dashboard/token-saver.segment.rsc +1 -1
  235. package/cli/app/.next-cli-build/server/app/dashboard/token-saver.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  236. package/cli/app/.next-cli-build/server/app/dashboard/token-saver.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  237. package/cli/app/.next-cli-build/server/app/dashboard/token-saver.segments/_full.segment.rsc +6 -6
  238. package/cli/app/.next-cli-build/server/app/dashboard/token-saver.segments/_head.segment.rsc +1 -1
  239. package/cli/app/.next-cli-build/server/app/dashboard/token-saver.segments/_index.segment.rsc +4 -4
  240. package/cli/app/.next-cli-build/server/app/dashboard/token-saver.segments/_tree.segment.rsc +2 -2
  241. package/cli/app/.next-cli-build/server/app/dashboard/translator.html +1 -1
  242. package/cli/app/.next-cli-build/server/app/dashboard/translator.rsc +6 -6
  243. package/cli/app/.next-cli-build/server/app/dashboard/translator.segments/!KGRhc2hib2FyZCk/dashboard/translator/__PAGE__.segment.rsc +2 -2
  244. package/cli/app/.next-cli-build/server/app/dashboard/translator.segments/!KGRhc2hib2FyZCk/dashboard/translator.segment.rsc +1 -1
  245. package/cli/app/.next-cli-build/server/app/dashboard/translator.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  246. package/cli/app/.next-cli-build/server/app/dashboard/translator.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  247. package/cli/app/.next-cli-build/server/app/dashboard/translator.segments/_full.segment.rsc +6 -6
  248. package/cli/app/.next-cli-build/server/app/dashboard/translator.segments/_head.segment.rsc +1 -1
  249. package/cli/app/.next-cli-build/server/app/dashboard/translator.segments/_index.segment.rsc +4 -4
  250. package/cli/app/.next-cli-build/server/app/dashboard/translator.segments/_tree.segment.rsc +2 -2
  251. package/cli/app/.next-cli-build/server/app/dashboard/usage.html +1 -1
  252. package/cli/app/.next-cli-build/server/app/dashboard/usage.rsc +6 -6
  253. package/cli/app/.next-cli-build/server/app/dashboard/usage.segments/!KGRhc2hib2FyZCk/dashboard/usage/__PAGE__.segment.rsc +2 -2
  254. package/cli/app/.next-cli-build/server/app/dashboard/usage.segments/!KGRhc2hib2FyZCk/dashboard/usage.segment.rsc +1 -1
  255. package/cli/app/.next-cli-build/server/app/dashboard/usage.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  256. package/cli/app/.next-cli-build/server/app/dashboard/usage.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  257. package/cli/app/.next-cli-build/server/app/dashboard/usage.segments/_full.segment.rsc +6 -6
  258. package/cli/app/.next-cli-build/server/app/dashboard/usage.segments/_head.segment.rsc +1 -1
  259. package/cli/app/.next-cli-build/server/app/dashboard/usage.segments/_index.segment.rsc +4 -4
  260. package/cli/app/.next-cli-build/server/app/dashboard/usage.segments/_tree.segment.rsc +2 -2
  261. package/cli/app/.next-cli-build/server/app/dashboard.html +1 -1
  262. package/cli/app/.next-cli-build/server/app/dashboard.rsc +6 -6
  263. package/cli/app/.next-cli-build/server/app/dashboard.segments/!KGRhc2hib2FyZCk/dashboard/__PAGE__.segment.rsc +2 -2
  264. package/cli/app/.next-cli-build/server/app/dashboard.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  265. package/cli/app/.next-cli-build/server/app/dashboard.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  266. package/cli/app/.next-cli-build/server/app/dashboard.segments/_full.segment.rsc +6 -6
  267. package/cli/app/.next-cli-build/server/app/dashboard.segments/_head.segment.rsc +1 -1
  268. package/cli/app/.next-cli-build/server/app/dashboard.segments/_index.segment.rsc +4 -4
  269. package/cli/app/.next-cli-build/server/app/dashboard.segments/_tree.segment.rsc +2 -2
  270. package/cli/app/.next-cli-build/server/app/index.html +1 -1
  271. package/cli/app/.next-cli-build/server/app/index.rsc +4 -4
  272. package/cli/app/.next-cli-build/server/app/index.segments/__PAGE__.segment.rsc +1 -1
  273. package/cli/app/.next-cli-build/server/app/index.segments/_full.segment.rsc +4 -4
  274. package/cli/app/.next-cli-build/server/app/index.segments/_head.segment.rsc +1 -1
  275. package/cli/app/.next-cli-build/server/app/index.segments/_index.segment.rsc +4 -4
  276. package/cli/app/.next-cli-build/server/app/index.segments/_tree.segment.rsc +2 -2
  277. package/cli/app/.next-cli-build/server/app/landing/page_client-reference-manifest.js +1 -1
  278. package/cli/app/.next-cli-build/server/app/landing.html +1 -1
  279. package/cli/app/.next-cli-build/server/app/landing.rsc +5 -5
  280. package/cli/app/.next-cli-build/server/app/landing.segments/_full.segment.rsc +5 -5
  281. package/cli/app/.next-cli-build/server/app/landing.segments/_head.segment.rsc +1 -1
  282. package/cli/app/.next-cli-build/server/app/landing.segments/_index.segment.rsc +4 -4
  283. package/cli/app/.next-cli-build/server/app/landing.segments/_tree.segment.rsc +2 -2
  284. package/cli/app/.next-cli-build/server/app/landing.segments/landing/__PAGE__.segment.rsc +2 -2
  285. package/cli/app/.next-cli-build/server/app/landing.segments/landing.segment.rsc +1 -1
  286. package/cli/app/.next-cli-build/server/app/login/page_client-reference-manifest.js +1 -1
  287. package/cli/app/.next-cli-build/server/app/login.html +1 -1
  288. package/cli/app/.next-cli-build/server/app/login.rsc +5 -5
  289. package/cli/app/.next-cli-build/server/app/login.segments/_full.segment.rsc +5 -5
  290. package/cli/app/.next-cli-build/server/app/login.segments/_head.segment.rsc +1 -1
  291. package/cli/app/.next-cli-build/server/app/login.segments/_index.segment.rsc +4 -4
  292. package/cli/app/.next-cli-build/server/app/login.segments/_tree.segment.rsc +2 -2
  293. package/cli/app/.next-cli-build/server/app/login.segments/login/__PAGE__.segment.rsc +2 -2
  294. package/cli/app/.next-cli-build/server/app/login.segments/login.segment.rsc +1 -1
  295. package/cli/app/.next-cli-build/server/app/page_client-reference-manifest.js +1 -1
  296. package/cli/app/.next-cli-build/server/app-paths-manifest.json +9 -9
  297. package/cli/app/.next-cli-build/server/chunks/3155.js +1 -1
  298. package/cli/app/.next-cli-build/server/chunks/412.js +2 -2
  299. package/cli/app/.next-cli-build/server/chunks/4746.js +1 -1
  300. package/cli/app/.next-cli-build/server/chunks/5307.js +1 -1
  301. package/cli/app/.next-cli-build/server/chunks/5469.js +1 -1
  302. package/cli/app/.next-cli-build/server/chunks/8242.js +2 -2
  303. package/cli/app/.next-cli-build/server/chunks/8306.js +1 -1
  304. package/cli/app/.next-cli-build/server/chunks/9621.js +1 -1
  305. package/cli/app/.next-cli-build/server/middleware-build-manifest.js +1 -1
  306. package/cli/app/.next-cli-build/server/pages/404.html +1 -1
  307. package/cli/app/.next-cli-build/server/pages/500.html +1 -1
  308. package/cli/app/.next-cli-build/static/chunks/523-176a0660a9383518.js +3 -0
  309. package/cli/app/.next-cli-build/static/chunks/5497-8d0ec2995dc0a392.js +7 -0
  310. package/cli/app/.next-cli-build/static/chunks/{620-b21eb963d0189283.js → 620-375754e53341e85b.js} +1 -1
  311. package/cli/app/.next-cli-build/static/chunks/9126-7d5476f17beddfb0.js +1 -0
  312. package/cli/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/providers/page-2468e6ba8d1efeec.js +1 -0
  313. package/cli/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/quota/page-579bf915396efc69.js +1 -0
  314. package/cli/app/.next-cli-build/static/css/87ffa46afc2273f4.css +1 -0
  315. package/cli/app/CHANGELOG.md +17 -0
  316. package/cli/app/package.json +1 -1
  317. package/cli/package.json +1 -1
  318. package/package.json +1 -1
  319. package/src/app/(dashboard)/dashboard/basic-chat/BasicChatPageClient.js +91 -38
  320. package/src/app/(dashboard)/dashboard/endpoint/EndpointPageClient.js +45 -38
  321. package/src/app/(dashboard)/dashboard/providers/page.js +199 -173
  322. package/src/app/(dashboard)/dashboard/usage/components/OverviewCards.js +11 -17
  323. package/src/app/(dashboard)/dashboard/usage/components/ProviderLimits/QuotaTable.js +15 -9
  324. package/src/app/(dashboard)/dashboard/usage/components/ProviderLimits/index.js +188 -120
  325. package/src/app/(dashboard)/dashboard/usage/components/ProviderTopology.js +149 -24
  326. package/src/shared/components/Header.js +4 -4
  327. package/src/shared/components/HeaderLanguage.js +2 -1
  328. package/src/shared/components/HeaderMenu.js +2 -1
  329. package/src/shared/components/Toggle.js +28 -12
  330. package/src/shared/components/UsageStats.js +3 -3
  331. package/cli/app/.next-cli-build/static/chunks/523-078802482e95c757.js +0 -3
  332. package/cli/app/.next-cli-build/static/chunks/5497-276ef7bcaaa911b7.js +0 -7
  333. package/cli/app/.next-cli-build/static/chunks/9126-9e1755f122b943cd.js +0 -1
  334. package/cli/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/providers/page-2cedde97aaf3c729.js +0 -1
  335. package/cli/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/quota/page-6050ac2547c62b54.js +0 -1
  336. package/cli/app/.next-cli-build/static/css/b912482d9fc0b2ed.css +0 -1
  337. /package/cli/app/.next-cli-build/static/{x2eyEbk18Mgl67fqRmEFx → y-U4C09T7DItXT7CZZV41}/_buildManifest.js +0 -0
  338. /package/cli/app/.next-cli-build/static/{x2eyEbk18Mgl67fqRmEFx → y-U4C09T7DItXT7CZZV41}/_ssgManifest.js +0 -0
@@ -1 +0,0 @@
1
- (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[9126],{19126:(e,t,r)=>{Promise.resolve().then(r.bind(r,88512))},88512:(e,t,r)=>{"use strict";r.d(t,{default:()=>k});var a=r(95155),s=r(12115),l=r(9233),n=r(91992),i=r(35497),o=r(28777),d=r(52679);let c="basic-chat.sessions",m="basic-chat.activeSessionId",u="basic-chat.activeProviderId",x="basic-chat.draft",p="basic-chat.temperature",h="basic-chat.systemPrompt",b=[],f=["Explain this project like I'm new","Write a concise PR description","Debug this error message","Summarize the key trade-offs"];function g(){return globalThis.crypto?.randomUUID?globalThis.crypto.randomUUID():`chat_${Date.now()}_${Math.random().toString(16).slice(2)}`}function y(e){if("string"==typeof e)return e;if(null==e)return"";if(Array.isArray(e))return e.map(y).filter(Boolean).join(" ");if("object"==typeof e){if("string"==typeof e.message)return e.message;if("string"==typeof e.error)return e.error;try{return JSON.stringify(e)}catch{}}return String(e)}function v(e=""){let t=y(e).replace(/\s+/g," ").trim();return t?t.length>52?`${t.slice(0,52).trimEnd()}…`:t:"New chat"}async function N(e){return await new Promise((t,r)=>{let a=new FileReader;a.onload=()=>t(String(a.result||"")),a.onerror=()=>r(a.error||Error("Failed to read file")),a.readAsDataURL(e)})}function j(e){let t=e?.provider||e?.id,r=t?d.Q2[t]:null;return r?.name||function(e=""){return String(e).replace(/[-_]/g," ").replace(/\b\w/g,e=>e.toUpperCase()).trim()||"Unknown"}(t||"provider")}function w(e){return Array.from(e.values()).map(e=>({...e,models:(function(e){let t=new Map;for(let r of e)r?.id&&(t.has(r.id)||t.set(r.id,r));return Array.from(t.values())})(e.models).sort((e,t)=>e.name.localeCompare(t.name))})).filter(e=>e.models.length>0).sort((e,t)=>e.providerName.localeCompare(t.providerName))}async function S(e,t={},r=8e3){let a=new AbortController,s=setTimeout(()=>a.abort(),r);try{return await fetch(e,{...t,signal:a.signal})}finally{clearTimeout(s)}}async function I(e,t,r){if(!e.length)return[];let a=Array(e.length),s=0,l=Array.from({length:Math.min(t,e.length)},async()=>{for(;s<e.length;){let t=s;s+=1,a[t]=await r(e[t],t)}});return await Promise.all(l),a}function k(){let[e,t]=(0,s.useState)([]),[r,k]=(0,s.useState)(!0),[A,C]=(0,s.useState)(""),[T,$]=(0,s.useState)(()=>{try{let e=function(e,t){try{return JSON.parse(e)}catch{return t}}(globalThis.localStorage.getItem(c),[]);return Array.isArray(e)?e.map(e=>({...e,messages:Array.isArray(e.messages)?e.messages:[]})):[]}catch{return[]}}),[E,M]=(0,s.useState)(()=>globalThis.localStorage.getItem(m)||""),[D,_]=(0,s.useState)(()=>globalThis.localStorage.getItem(u)||""),[O,R]=(0,s.useState)(""),[z,U]=(0,s.useState)(()=>globalThis.localStorage.getItem(x)||""),[L,P]=(0,s.useState)([]),[q,F]=(0,s.useState)(!1),[J,B]=(0,s.useState)(""),[H,W]=(0,s.useState)(""),[K,Y]=(0,s.useState)(!1),[G,Q]=(0,s.useState)(!1),[V,Z]=(0,s.useState)(""),[X,ee]=(0,s.useState)(!1),[et,er]=(0,s.useState)(!1),[ea,es]=(0,s.useState)(""),[el,en]=(0,s.useState)(()=>{let e=Number(globalThis.localStorage.getItem(p));return Number.isFinite(e)?Math.min(2,Math.max(0,e)):.7}),[ei,eo]=(0,s.useState)(()=>globalThis.localStorage.getItem(h)||""),ed=(0,s.useRef)(null),ec=(0,s.useRef)(null),em=(0,s.useRef)(!1),eu=(0,s.useRef)(null),ex=(0,s.useRef)(null),ep=(0,s.useRef)(null),eh=(0,s.useRef)(null),eb=(0,s.useRef)(null);(0,s.useEffect)(()=>{Y(!0)},[]),(0,s.useEffect)(()=>{let e=!1;return async function(){k(!0),C("");try{let r=await S("/api/providers",{cache:"no-store"},15e3),a=await r.json().catch(()=>({})),s=Array.isArray(a.connections)?a.connections.filter(e=>e?.isActive!==!1):[];if(0===s.length){e||(t([]),C("No providers connected yet."),k(!1));return}let l=new Map,n=[];for(let e of s){let t=e.provider||e.id,r=j(e),a=(0,d.mq)(t)?"openai-compatible":(0,d.gb)(t)?"anthropic-compatible":t;if(!l.has(t)){l.set(t,{providerId:t,providerName:r,providerType:a,connections:[],models:[]});let s=(0,o.KC)(t).map(t=>t?.id?{id:`${e.provider}/${t.id}`,requestModel:`${e.provider}/${t.id}`,name:t.name||t.id,providerId:e.provider,providerName:j(e),source:"static"}:null).filter(Boolean);l.get(t).models.push(...s),n.push(e)}let s=l.get(t);s.providerName=s.providerName||r,s.providerType=s.providerType||a,s.connections.push(e)}let i=w(l);e||(t(i),0===i.length?C("Loading live models…"):C(""),k(!1));let c=await I(n,6,async t=>{if(e)return{connection:t,models:[]};try{let e=await S(`/api/providers/${t.id}/models`,{cache:"no-store"},8e3),r=await e.json().catch(()=>({}));if(!e.ok)return{connection:t,models:[]};let a=(Array.isArray(r?.models)?r.models:Array.isArray(r?.data)?r.data:Array.isArray(r?.results)?r.results:Array.isArray(r)?r:[]).map(e=>(function(e,t){let r="string"==typeof e?e:e?.id||e?.name||e?.model||"";if(!r)return null;let a="string"==typeof e?e:e?.name||e?.displayName||r,s=r;return((0,d.mq)(t.provider)||(0,d.gb)(t.provider))&&!r.includes("/")&&(s=`${t.provider}/${r}`),{id:s,requestModel:s,name:a,providerId:t.provider,providerName:j(t),source:"live"}})(e,t)).filter(Boolean);return{connection:t,models:a}}catch{return{connection:t,models:[]}}});if(e)return;for(let e of c){let t=e.connection.provider||e.connection.id,r=l.get(t);r&&e.models?.length&&r.models.push(...e.models)}let m=w(l);e||(t(m),0===m.length?C("Providers connected but no models available."):C(""))}catch(r){e||(C(y(r?.message)||"Failed to load providers/models."),t([]),k(!1))}}(),()=>{e=!0}},[]),(0,s.useEffect)(()=>{let e=e=>{eu.current&&!eu.current.contains(e.target)&&Q(!1),ex.current&&!ex.current.contains(e.target)&&ee(!1),ep.current&&!ep.current.contains(e.target)&&er(!1)},t=e=>{"Escape"===e.key&&(Q(!1),Z(""),er(!1),ee(!1))};return document.addEventListener("mousedown",e),document.addEventListener("keydown",t),()=>{document.removeEventListener("mousedown",e),document.removeEventListener("keydown",t)}},[]),(0,s.useEffect)(()=>{try{globalThis.localStorage.setItem(p,String(el))}catch{}},[el]),(0,s.useEffect)(()=>{try{globalThis.localStorage.setItem(h,ei)}catch{}},[ei]);let ef=(0,s.useMemo)(()=>{let t=new Map;for(let r of e)for(let e of r.models)t.set(e.id,{...e,providerId:r.providerId,providerName:r.providerName});return t},[e]),eg=(0,s.useMemo)(()=>e.find(e=>e.providerId===D)||e[0]||null,[e,D]),ey=(0,s.useMemo)(()=>{if(O&&ef.has(O))return ef.get(O);if(E){let e=T.find(e=>e.id===E);if(e?.modelId&&ef.has(e.modelId))return ef.get(e.modelId)}return eg?.models?.[0]||null},[O,ef,eg,T,E]),ev=(0,s.useMemo)(()=>T.find(e=>e.id===E)||null,[T,E]),eN=ev?.messages||b,ej=(0,s.useMemo)(()=>[...T].sort((e,t)=>new Date(t.updatedAt).getTime()-new Date(e.updatedAt).getTime()),[T]),ew=!q&&!!ey&&(z.trim().length>0||L.length>0);(0,s.useEffect)(()=>{if(K)try{globalThis.localStorage.setItem(c,JSON.stringify(T)),globalThis.localStorage.setItem(m,E),globalThis.localStorage.setItem(u,D),globalThis.localStorage.setItem(x,z)}catch{}},[K,T,E,D,z]),(0,s.useEffect)(()=>{if(!K||r||em.current||0===e.length)return;let t=e.find(e=>e.providerId===D)||e[0],a=O&&ef.has(O)?ef.get(O):t.models[0];if(T.length>0){let e=T.find(e=>e.id===E)||T[0],r=e?.modelId&&ef.has(e.modelId)?ef.get(e.modelId):a;em.current=!0,M(e.id),_(r?.providerId||t.providerId),R(r?.id||a.id);return}let s={id:g(),title:"New chat",providerId:t.providerId,providerName:t.providerName,modelId:a.id,modelName:a.name,createdAt:new Date().toISOString(),updatedAt:new Date().toISOString(),messages:[]};em.current=!0,$([s]),M(s.id),_(t.providerId),R(a.id)},[K,r,e,ef,T,E,D,O]);let eS=(e,t)=>{$(r=>r.map(r=>r.id===e?t({...r,messages:Array.isArray(r.messages)?r.messages.map(e=>({...e})):[]}):r))},eI=e=>e?{id:g(),title:"New chat",providerId:e.providerId,providerName:e.providerName,modelId:e.id,modelName:e.name,createdAt:new Date().toISOString(),updatedAt:new Date().toISOString(),messages:[]}:null,ek=()=>{if(!ey)return;let e=eI(ey);e&&($(t=>[e,...t]),M(e.id),_(e.providerId),R(e.modelId),U(""),P([]),B(""),W(""))},eA=async e=>{let t=Array.from(e.target.files||[]);if(0===t.length)return;let r=t.filter(e=>e.type.startsWith("image/"));if(0===r.length){e.target.value="";return}let a=await Promise.all(r.map(async e=>({id:g(),name:e.name,type:e.type,size:e.size,dataUrl:await N(e)})));P(e=>[...e,...a]),e.target.value=""},eC=(e,t)=>{let r=v(t);eS(e,e=>({...e,title:"New chat"===e.title?r:e.title,updatedAt:new Date().toISOString()}))};(0,s.useEffect)(()=>{let e;(e=eh.current)&&(e.style.height="auto",e.style.height=`${Math.min(e.scrollHeight,Math.round(.28*window.innerHeight))}px`)},[z]),(0,s.useEffect)(()=>{eb.current?.scrollIntoView({behavior:"smooth",block:"end"})},[eN,H,q]);let eT=async(e,t)=>{try{await navigator.clipboard.writeText(y(t)),es(e),setTimeout(()=>es(t=>t===e?"":t),1500)}catch{}},e$=async(e={})=>{let t=ey||eg?.models?.[0]||null;if(!t)return;let r=!0===e.regenerate,a=E,s=T.find(e=>e.id===a),l="string"==typeof e.userText?e.userText:z.trim(),n=Array.isArray(e.attachments)?e.attachments:L;if(r){if(!s)return;let e=[...s.messages||[]];for(;e.length&&e[e.length-1]?.role==="assistant";)e.pop();let t=[...e].reverse().find(e=>"user"===e.role);if(!t)return;l=y(t.content).trim(),n=Array.isArray(t.attachments)?t.attachments:[],s={...s,messages:e},$(e=>e.map(e=>e.id===a?s:e))}if(!l&&(!n||0===n.length))return;if(!s){if(!(s=eI(t)))return;a=s.id,$(e=>[s,...e]),M(a)}let i=r?null:{id:g(),role:"user",content:l,attachments:(n||[]).map(e=>({id:e.id,name:e.name,type:e.type,dataUrl:e.dataUrl})),createdAt:new Date().toISOString()},o=g(),d={id:o,role:"assistant",content:"",createdAt:new Date().toISOString(),status:"streaming"},c=[...r?[...s.messages||[]]:[...s.messages||[],i],d];$(e=>e.map(e=>e.id===a?{...e,providerId:t.providerId,providerName:t.providerName,modelId:t.id,modelName:t.name,messages:c,updatedAt:new Date().toISOString(),title:"New chat"===e.title?v(l):e.title}:e)),!r&&(U(""),P([]),eh.current&&(eh.current.style.height="auto")),F(!0),B(o),W(""),ec.current?.abort(),ec.current=new AbortController;let m=c.filter(e=>"assistant"!==e.role||e.id!==o).map(e=>({role:e.role,content:"user"===e.role?function(e){let t=y(e.content).trim(),r=Array.isArray(e.attachments)?e.attachments:[];if(0===r.length)return t;let a=[];for(let e of(t&&a.push({type:"text",text:t}),r))e?.dataUrl&&a.push({type:"image_url",image_url:{url:e.dataUrl}});return a.length>0?a:t}(e):e.content})),u=ei.trim(),x=u?[{role:"system",content:u},...m]:m;try{let e=await fetch("/api/dashboard/chat/completions",{method:"POST",headers:{"Content-Type":"application/json",Accept:"text/event-stream"},body:JSON.stringify({model:t.requestModel||t.id,messages:x,stream:!0,temperature:el}),signal:ec.current.signal});if(!e.ok){let t=await e.json().catch(()=>({}));throw Error(y(t.error||t.message||`Request failed (${e.status})`))}let r=e.body?.getReader();if(!r){let t=await e.json().catch(()=>({})),r=y(t?.choices?.[0]?.message?.content||t?.output_text||t?.error||t?.message||"");eS(a,e=>({...e,messages:e.messages.map(e=>e.id===o?{...e,content:r,status:"done"}:e),updatedAt:new Date().toISOString()}));return}let s=new TextDecoder,n="",i="";for(;;){let{value:e,done:t}=await r.read();if(t)break;let l=(n+=s.decode(e,{stream:!0})).split(/\r?\n/);for(let e of(n=l.pop()||"",l)){let t=e.trim();if(!t.startsWith("data:"))continue;let r=t.slice(5).trim();if(r&&"[DONE]"!==r)try{let e=JSON.parse(r),t=function(e){if(!e||"object"!=typeof e)return"";let t=e.choices?.[0];return[(t?.delta||{}).content,t?.message?.content,e.output_text,e.text].map(y).filter(Boolean)[0]||""}(e);if(!t)continue;i+=t,W(i),eS(a,e=>({...e,messages:e.messages.map(e=>e.id===o?{...e,content:i,status:"streaming"}:e),updatedAt:new Date().toISOString()}))}catch{}}}eS(a,e=>({...e,messages:e.messages.map(e=>e.id===o?{...e,content:i||e.content,status:"done"}:e),updatedAt:new Date().toISOString()})),eC(a,l)}catch(e){if("AbortError"===e.name)eS(a,e=>({...e,messages:e.messages.map(e=>e.id===o?{...e,content:e.content||"Stopped",status:"stopped"}:e),updatedAt:new Date().toISOString()})),eC(a,l);else{let t=y(e?.message||e);eS(a,e=>({...e,messages:e.messages.map(e=>e.id===o?{...e,content:e.content||`Error: ${t}`,status:"error"}:e),updatedAt:new Date().toISOString()}))}}finally{F(!1),B(""),W(""),ec.current=null}},eE=ey?ey.name:"Select model",eM=ey?`${ey.providerName||""} \xb7 ${ey.requestModel||ey.id}`.replace(/^ · /,""):"Connected providers only",eD=(0,s.useMemo)(()=>{let t=V.trim().toLowerCase();return t?e.map(e=>{let r=(e.providerName||"").toLowerCase().includes(t)||(e.providerId||"").toLowerCase().includes(t)?e.models:e.models.filter(e=>`${e.name||""} ${e.requestModel||""} ${e.id||""}`.toLowerCase().includes(t));return{...e,models:r}}).filter(e=>e.models.length>0):e},[e,V]);return(0,a.jsxs)("div",{className:"relative flex h-full min-h-0 min-w-0 flex-1 overflow-hidden bg-bg text-text-main",children:[(0,a.jsxs)("aside",{id:"playground-history",className:`${X?"flex":"hidden"} fixed inset-y-0 left-0 z-30 w-[min(85vw,260px)] shrink-0 flex-col border-r border-border-subtle bg-surface/95 backdrop-blur-xl lg:static lg:z-auto lg:flex lg:w-[260px] lg:bg-surface/60`,children:[(0,a.jsxs)("div",{className:"flex items-center gap-2 border-b border-border-subtle p-3",children:[(0,a.jsxs)("button",{type:"button",onClick:ek,disabled:!ey,className:"flex h-9 flex-1 items-center justify-center gap-2 rounded-[10px] bg-primary text-sm font-semibold text-white transition hover:bg-primary-hover disabled:cursor-not-allowed disabled:opacity-50",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:"add"}),"New chat"]}),(0,a.jsx)("button",{type:"button",className:"flex size-11 items-center justify-center rounded-[10px] border border-border text-text-muted lg:hidden hover:bg-surface-2",onClick:()=>ee(!1),"aria-label":"Close history",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:"close"})})]}),(0,a.jsxs)("div",{ref:ex,className:"flex-1 overflow-y-auto p-2 custom-scrollbar",children:[(0,a.jsx)("p",{className:"px-2 py-2 text-[11px] font-semibold uppercase tracking-wider text-text-subtle",children:"Chats"}),0===ej.length?(0,a.jsx)("div",{className:"rounded-[10px] border border-dashed border-border px-3 py-6 text-center text-xs text-text-muted",children:"No conversations yet"}):(0,a.jsx)("div",{className:"space-y-0.5",children:ej.map(e=>{let t=e.id===E,r=[...e.messages||[]].reverse().find(e=>"user"===e.role)||e.messages?.[0];return(0,a.jsxs)("button",{type:"button",onClick:()=>{var t;let r;t=e.id,(r=T.find(e=>e.id===t))&&(M(t),_(r.providerId||D),R(r.modelId||O),ee(!1)),window.innerWidth<1024&&ee(!1)},className:`group flex w-full items-start gap-2 rounded-[10px] px-2.5 py-2.5 text-left transition ${t?"bg-primary/10 text-primary":"text-text-muted hover:bg-surface-2 hover:text-text-main"}`,children:[(0,a.jsx)("span",{className:"material-symbols-outlined mt-0.5 text-[16px] opacity-70",children:"chat_bubble"}),(0,a.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,a.jsx)("p",{className:"truncate text-[13px] font-medium leading-snug",children:e.title||"New chat"}),(0,a.jsxs)("p",{className:"mt-0.5 truncate text-[11px] opacity-60",children:[y(r?.content)||"Empty"," \xb7"," ",function(e){if(!e)return"Now";let t=new Date(e).getTime();if(Number.isNaN(t))return"Now";let r=Math.max(1,Math.round((Date.now()-t)/6e4));if(r<60)return`${r}m`;let a=Math.round(r/60);return a<24?`${a}h`:`${Math.round(a/24)}d`}(e.updatedAt)]})]})]},e.id)})})]}),(0,a.jsx)("div",{className:"border-t border-border-subtle p-3",children:(0,a.jsxs)("button",{type:"button",onClick:()=>{if(!E)return;let e=T.filter(e=>e.id!==E),t=e[0]||null;$(e),t?(M(t.id),_(t.providerId),R(t.modelId)):(M(""),_(""),R(""))},disabled:!E||0===T.length,className:"flex h-8 w-full items-center justify-center gap-1.5 rounded-[8px] text-xs font-medium text-text-muted transition hover:bg-surface-2 hover:text-danger disabled:opacity-40",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[16px]",children:"delete"}),"Delete current chat"]})})]}),(0,a.jsxs)("div",{className:"relative flex min-w-0 flex-1 flex-col",children:[(0,a.jsxs)("div",{className:"flex shrink-0 items-center justify-between gap-2 border-b border-border-subtle px-3 py-2 lg:hidden",children:[(0,a.jsx)("button",{type:"button",onClick:()=>ee(!0),className:"flex size-11 items-center justify-center rounded-[10px] border border-border text-text-muted hover:bg-surface-2","aria-label":"Open chats","aria-expanded":X,"aria-controls":"playground-history",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[20px]",children:"history"})}),(0,a.jsxs)("div",{className:"min-w-0 text-center",children:[(0,a.jsx)("p",{className:"truncate text-sm font-semibold",children:eE}),(0,a.jsx)("p",{className:"truncate text-[11px] text-text-subtle",children:eM})]}),(0,a.jsx)("button",{type:"button",onClick:ek,disabled:!ey,className:"flex size-11 items-center justify-center rounded-[10px] border border-border text-text-muted hover:bg-surface-2 disabled:opacity-40","aria-label":"New chat",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[20px]",children:"edit_square"})})]}),A?(0,a.jsx)("div",{role:"alert",className:"mx-4 mt-3 rounded-[10px] border border-danger/25 bg-danger/10 px-3 py-2.5 text-sm text-danger",children:(0,a.jsxs)("div",{className:"flex items-start gap-2",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:"error"}),(0,a.jsx)("p",{children:A})]})}):null,(0,a.jsx)("div",{className:"flex-1 overflow-y-auto custom-scrollbar",children:0===eN.length?(0,a.jsxs)("div",{className:"flex min-h-full flex-col items-center justify-center px-6 pb-36 pt-10 text-center",children:[(0,a.jsx)("div",{className:"mb-4 flex size-12 items-center justify-center rounded-2xl border border-border bg-surface text-primary shadow-soft",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[26px]",children:"forum"})}),(0,a.jsx)("h2",{className:"text-[22px] font-semibold tracking-tight text-text-main",children:"How can I help?"}),(0,a.jsx)("p",{className:"mt-1.5 max-w-md text-[13px] leading-relaxed text-text-muted",children:"Pick a model below, then ask anything through your connected providers."}),(0,a.jsx)("div",{className:"mt-6 flex max-w-xl flex-wrap items-center justify-center gap-2",children:f.map(e=>(0,a.jsx)("button",{type:"button",disabled:!ey||r,onClick:()=>{U(e),requestAnimationFrame(()=>eh.current?.focus())},className:"rounded-full border border-border bg-surface px-3.5 py-2 text-left text-[12.5px] text-text-muted transition hover:border-primary/35 hover:bg-primary/5 hover:text-text-main disabled:opacity-40",children:e},e))}),r?(0,a.jsx)("p",{className:"mt-4 text-xs text-text-subtle",children:"Loading models…"}):null]}):(0,a.jsxs)("div",{className:"mx-auto w-full max-w-3xl px-4 py-6 lg:px-8",children:[eN.map((e,t)=>{let r="user"===e.role,s="assistant"===e.role,i=s&&e.id===J&&"streaming"===e.status,o=y(e.content)||(s?H:""),d="error"===e.status,c="stopped"===e.status,m=s&&t===eN.length-1&&"streaming"!==e.status;return(0,a.jsx)("div",{className:"group relative mb-1 border-b border-border-subtle/50 py-5 last:border-0",children:(0,a.jsxs)("div",{className:"flex gap-3.5",children:[(0,a.jsx)("div",{className:`flex size-7 shrink-0 items-center justify-center rounded-full text-[11px] font-bold ${r?"bg-primary text-white":"border border-border bg-surface-2 text-text-muted"}`,children:r?"Y":"AI"}),(0,a.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,a.jsx)("p",{className:"mb-1.5 text-[12px] font-semibold text-text-main",children:r?"You":ey?.name||"Assistant"}),e.attachments?.length?(0,a.jsx)("div",{className:"mb-3 grid max-w-md grid-cols-2 gap-2 sm:grid-cols-3",children:e.attachments.map(e=>(0,a.jsx)("a",{href:e.dataUrl,target:"_blank",rel:"noreferrer",className:"overflow-hidden rounded-lg border border-border",children:(0,a.jsx)("img",{src:e.dataUrl,alt:e.name,className:"h-24 w-full object-cover"})},e.id))}):null,s&&!d?(0,a.jsx)("div",{className:"playground-md text-[14.5px] leading-[1.7] text-text-main",dangerouslySetInnerHTML:{__html:function(e){let t=y(e);if(!t)return"";try{return n.A.sanitize(l.xI.parse(t))}catch{return t.replace(/</g,"&lt;").replace(/>/g,"&gt;")}}(o)||""}}):(0,a.jsx)("div",{className:`whitespace-pre-wrap break-words text-[14.5px] leading-[1.7] ${d?"text-danger":"text-text-main"}`,children:o}),s&&i?(0,a.jsx)("span",{className:"ml-0.5 inline-block animate-pulse text-primary",children:"▋"}):null,c?(0,a.jsx)("p",{className:"mt-2 text-xs text-text-muted",children:"Generation stopped"}):null,s&&o&&!i?(0,a.jsxs)("div",{className:"mt-2 flex items-center gap-1 opacity-100 transition sm:opacity-0 sm:group-hover:opacity-100 sm:group-focus-within:opacity-100",children:[(0,a.jsxs)("button",{type:"button",onClick:()=>eT(e.id,o),className:"inline-flex h-7 items-center gap-1 rounded-md px-2 text-[11px] font-medium text-text-muted hover:bg-surface-2 hover:text-text-main",title:"Copy",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:ea===e.id?"check":"content_copy"}),ea===e.id?"Copied":"Copy"]}),m&&!q?(0,a.jsxs)("button",{type:"button",onClick:()=>e$({regenerate:!0}),className:"inline-flex h-7 items-center gap-1 rounded-md px-2 text-[11px] font-medium text-text-muted hover:bg-surface-2 hover:text-text-main",title:"Regenerate",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"refresh"}),"Retry"]}):null]}):null]})]})},e.id)}),(0,a.jsx)("div",{ref:eb})]})}),(0,a.jsx)("div",{className:"shrink-0 border-t border-border-subtle bg-bg/90 backdrop-blur-xl",children:(0,a.jsxs)("div",{className:"mx-auto w-full max-w-3xl px-4 pb-4 pt-3 lg:px-6",children:[L.length>0?(0,a.jsx)("div",{className:"mb-2 flex flex-wrap gap-2",children:L.map(e=>(0,a.jsxs)("div",{className:"flex items-center gap-2 rounded-full border border-border bg-surface px-3 py-1.5",children:[(0,a.jsx)("span",{className:"max-w-[10rem] truncate text-xs text-text-muted",children:e.name}),(0,a.jsx)("button",{type:"button",onClick:()=>{var t;return t=e.id,void P(e=>e.filter(e=>e.id!==t))},className:"text-text-subtle hover:text-text-main","aria-label":"Remove attachment",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[16px]",children:"close"})})]},e.id))}):null,(0,a.jsxs)("div",{className:"rounded-2xl border border-border-subtle bg-surface-2/80 shadow-soft ring-1 ring-border-subtle focus-within:border-primary/50 focus-within:ring-primary/20 transition",children:[(0,a.jsx)("textarea",{ref:eh,"aria-label":"Message",value:z,onChange:e=>U(e.target.value),onKeyDown:e=>{"Enter"===e.key&&!e.shiftKey&&(e.preventDefault(),ew&&e$())},placeholder:ey?`Message ${ey.name}…`:"Select a model below to start chatting",rows:1,disabled:!ey||r,className:"max-h-[28vh] min-h-[52px] w-full resize-none overflow-y-auto bg-transparent px-4 pt-3.5 text-[15px] leading-6 text-text-main outline-none placeholder:text-text-subtle custom-scrollbar disabled:opacity-50"}),(0,a.jsxs)("div",{className:"flex items-center justify-between gap-2 px-2.5 pb-2.5 pt-1",children:[(0,a.jsxs)("div",{className:"flex min-w-0 items-center gap-1.5",children:[(0,a.jsxs)("button",{type:"button",onClick:()=>ed.current?.click(),disabled:!ey||r,className:"inline-flex h-11 items-center gap-1.5 rounded-full border border-border bg-surface px-3 text-[12px] font-medium text-text-main transition hover:border-primary/40 hover:bg-primary/10 hover:text-primary disabled:cursor-not-allowed disabled:opacity-40",title:"Upload image",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:"add_photo_alternate"}),(0,a.jsx)("span",{className:"hidden sm:inline",children:"Image"})]}),(0,a.jsx)("input",{ref:ed,type:"file",accept:"image/*",multiple:!0,className:"hidden",onChange:eA}),(0,a.jsxs)("div",{ref:ep,className:"relative",children:[(0,a.jsxs)("button",{type:"button",onClick:()=>er(e=>!e),className:`inline-flex h-11 items-center gap-1.5 rounded-full border px-3 text-[12px] font-medium transition ${et||ei.trim()||.7!==el?"border-primary/40 bg-primary/10 text-primary":"border-border bg-surface text-text-main hover:border-primary/40 hover:bg-primary/10 hover:text-primary"}`,title:"Chat settings","aria-label":"Chat settings","aria-expanded":et,"aria-controls":"playground-chat-settings",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:"tune"}),(0,a.jsx)("span",{className:"hidden sm:inline tabular-nums",children:el.toFixed(1)})]}),et?(0,a.jsxs)("div",{id:"playground-chat-settings",className:"absolute bottom-[calc(100%+8px)] left-0 z-40 w-[min(320px,calc(100vw-2rem))] space-y-3 rounded-xl border border-border bg-surface p-3 shadow-elevated",children:[(0,a.jsxs)("div",{children:[(0,a.jsxs)("div",{className:"mb-1.5 flex items-center justify-between gap-2",children:[(0,a.jsx)("p",{className:"text-[11px] font-semibold uppercase tracking-wider text-text-subtle",children:"Temperature"}),(0,a.jsx)("span",{className:"text-xs font-semibold tabular-nums text-text-main",children:el.toFixed(2)})]}),(0,a.jsx)("input",{type:"range",min:0,max:2,step:.05,value:el,onChange:e=>en(Number(e.target.value)),className:"w-full accent-[var(--color-primary,#E56A4A)]"}),(0,a.jsxs)("div",{className:"mt-1 flex justify-between text-[10px] text-text-subtle",children:[(0,a.jsx)("span",{children:"Precise"}),(0,a.jsx)("span",{children:"Creative"})]})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("p",{className:"mb-1.5 text-[11px] font-semibold uppercase tracking-wider text-text-subtle",children:"System prompt"}),(0,a.jsx)("textarea",{value:ei,onChange:e=>eo(e.target.value),rows:4,placeholder:"Optional instructions for the model…",className:"w-full resize-y rounded-lg border border-border bg-bg px-2.5 py-2 text-[12.5px] leading-5 text-text-main outline-none placeholder:text-text-subtle focus:border-primary/40 custom-scrollbar"})]}),(0,a.jsx)("button",{type:"button",onClick:()=>{en(.7),eo("")},className:"text-[11px] font-medium text-text-muted hover:text-text-main",children:"Reset defaults"})]}):null]}),(0,a.jsxs)("div",{ref:eu,className:"relative min-w-0",children:[(0,a.jsxs)("button",{type:"button",onClick:()=>{Q(e=>{let t=!e;return t||Z(""),t})},disabled:r||0===e.length,"aria-label":`Choose model, currently ${eE}`,"aria-haspopup":"listbox","aria-expanded":G,"aria-controls":"playground-model-menu",className:"inline-flex h-11 max-w-[min(100vw-12rem,260px)] items-center gap-1.5 rounded-full border border-border bg-surface px-3 text-left transition hover:border-primary/40 hover:bg-surface-2 disabled:opacity-50",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px] text-primary shrink-0",children:"smart_toy"}),(0,a.jsx)("span",{className:"min-w-0 truncate text-[12.5px] font-semibold text-text-main",children:r?"Loading…":eE}),(0,a.jsx)("span",{className:"material-symbols-outlined shrink-0 text-[16px] text-text-muted",children:G?"expand_less":"expand_more"})]}),G?(0,a.jsxs)("div",{id:"playground-model-menu",role:"listbox","aria-label":"Models",className:"absolute bottom-[calc(100%+8px)] left-0 z-40 w-[min(420px,calc(100vw-2rem))] overflow-hidden rounded-xl border border-border bg-surface shadow-elevated",children:[(0,a.jsxs)("div",{className:"border-b border-border-subtle px-3 py-2.5 space-y-2",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("p",{className:"text-[11px] font-semibold uppercase tracking-wider text-text-subtle",children:"Models"}),(0,a.jsxs)("p",{className:"text-xs text-text-muted",children:[e.length," providers \xb7 search by name"]})]}),(0,a.jsxs)("div",{className:"relative",children:[(0,a.jsx)("span",{className:"material-symbols-outlined pointer-events-none absolute left-2.5 top-1/2 -translate-y-1/2 text-[16px] text-text-subtle",children:"search"}),(0,a.jsx)("input",{type:"search",value:V,onChange:e=>Z(e.target.value),placeholder:"Search models…",autoFocus:!0,className:"w-full rounded-lg border border-border bg-bg py-1.5 pl-8 pr-3 text-[16px] text-text-main outline-none placeholder:text-text-subtle focus:border-primary/40"})]})]}),(0,a.jsx)("div",{className:"max-h-[min(50vh,360px)] overflow-y-auto p-1.5 custom-scrollbar",children:0===eD.length?(0,a.jsxs)("p",{className:"px-3 py-6 text-center text-xs text-text-muted",children:["No models match “",V.trim(),"”"]}):eD.map(e=>(0,a.jsxs)("div",{className:"mb-1",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between px-2 py-1.5",children:[(0,a.jsx)("p",{className:"text-[11px] font-semibold uppercase tracking-wide text-text-subtle",children:e.providerName}),(0,a.jsx)(i.Ex,{size:"sm",variant:"default",children:e.models.length})]}),(0,a.jsx)("div",{className:"space-y-0.5",children:e.models.map(e=>{let t=e.id===O;return(0,a.jsxs)("button",{type:"button",role:"option","aria-selected":t,onClick:()=>{(e=>{let t=ef.get(e);if(!t)return;let r=T.find(e=>e.id===E);if(r&&r.messages.length>0){let e=eI(t);if(!e)return;$(t=>[e,...t]),M(e.id)}else if(r)$(e=>e.map(e=>e.id===r.id?{...e,providerId:t.providerId,providerName:t.providerName,modelId:t.id,modelName:t.name}:e)),M(r.id);else{let e=eI(t);if(!e)return;$(t=>[e,...t]),M(e.id)}_(t.providerId),R(t.id),Q(!1)})(e.id),Z("")},className:`flex w-full items-center gap-2 rounded-lg px-2.5 py-2 text-left transition ${t?"bg-primary/10 text-primary":"text-text-muted hover:bg-surface-2 hover:text-text-main"}`,children:[(0,a.jsxs)("span",{className:"min-w-0 flex-1",children:[(0,a.jsx)("span",{className:"block truncate text-[13px] font-medium",children:e.name}),(0,a.jsx)("span",{className:"block truncate text-[11px] opacity-60",children:e.requestModel})]}),t?(0,a.jsx)("span",{className:"material-symbols-outlined text-[16px]",children:"check"}):null]},e.id)})})]},e.providerId))})]}):null]})]}),(0,a.jsxs)("div",{className:"flex shrink-0 items-center gap-2",children:[q?(0,a.jsxs)("button",{type:"button",onClick:()=>{ec.current?.abort()},className:"inline-flex h-11 items-center gap-1.5 rounded-full border border-border bg-surface px-3 text-[12px] font-semibold text-text-main transition hover:bg-surface-2",title:"Stop generating",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:"stop_circle"}),(0,a.jsx)("span",{className:"hidden sm:inline",children:"Stop"})]}):null,(0,a.jsxs)("button",{type:"button",onClick:e$,disabled:!ew,className:`inline-flex h-11 min-w-9 items-center justify-center gap-1.5 rounded-full px-3.5 text-[13px] font-semibold transition ${ew?"bg-primary text-white shadow-[0_2px_12px_rgba(229,106,74,0.45)] hover:bg-primary-hover active:scale-[0.97]":"bg-surface-3 text-text-subtle cursor-not-allowed opacity-70"}`,title:"Send message",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px] font-bold",children:"send"}),(0,a.jsx)("span",{className:"hidden sm:inline",children:"Send"})]})]})]})]}),(0,a.jsx)("p",{className:"mt-2 text-center text-[11px] text-text-subtle",children:"Routed through ZevaiRouter \xb7 Enter to send \xb7 Shift+Enter for new line"})]})})]}),X?(0,a.jsx)("button",{type:"button",className:"fixed inset-0 z-20 bg-black/40 lg:hidden","aria-label":"Close history",onClick:()=>ee(!1)}):null]})}l.xI.setOptions({gfm:!0,breaks:!0})}}]);
@@ -1 +0,0 @@
1
- (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[8460],{31703:(e,t,s)=>{Promise.resolve().then(s.bind(s,52154))},52154:(e,t,s)=>{"use strict";s.r(t),s.d(t,{default:()=>v});var r=s(95155),a=s(12115),i=s(14051),l=s.n(i),n=s(35497),o=s(57250),d=s(90620),c=s(52679),p=s(98500),m=s.n(p),x=s(65921),u=s(38003);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),[s,i]=(0,a.useState)(!0),[l,o]=(0,a.useState)(!1),[d,c]=(0,a.useState)(null),p=(0,a.useRef)(null),m=(0,x.i)(),u=(0,a.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,a.useEffect)(()=>{u();let e=setInterval(u,3e4);return()=>clearInterval(e)},[u]),(0,a.useEffect)(()=>{let e=e=>{p.current&&!p.current.contains(e.target)&&o(!1)};return l&&document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[l]);let f=async(e,t)=>{c(`${e}:${t}`);try{(await fetch("/api/models/availability",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"clearCooldown",provider:e,model:t})})).ok?(m.success(`Cooldown cleared for ${t}`),await u()):m.error("Failed to clear cooldown")}catch{m.error("Failed to clear cooldown")}finally{c(null)}};if(s)return null;let g=e?.models||[],b=0===(e?.unavailableCount||g.filter(e=>"available"!==e.status).length),v={};return g.forEach(e=>{if("available"===e.status)return;let t=e.provider||"unknown";v[t]||(v[t]=[]),v[t].push(e)}),(0,r.jsx)("div",{className:"relative",ref:p,children:l&&(0,r.jsxs)("div",{className:"absolute top-full right-0 mt-2 w-80 bg-surface border border-border rounded-xl shadow-2xl z-50 overflow-hidden",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border bg-bg",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("span",{className:"material-symbols-outlined text-[16px]",style:{color:b?"#22c55e":"#f59e0b"},children:b?"verified":"warning"}),(0,r.jsx)("span",{className:"text-sm font-semibold text-text-main",children:"Model Status"})]}),(0,r.jsx)("button",{onClick:u,className:"p-1 rounded-lg hover:bg-surface text-text-muted hover:text-text-main transition-colors",title:"Refresh",children:(0,r.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"refresh"})})]}),(0,r.jsx)("div",{className:"px-4 py-3 max-h-60 overflow-y-auto",children:b?(0,r.jsx)("p",{className:"text-sm text-text-muted text-center py-2",children:"All models are responding normally."}):(0,r.jsx)("div",{className:"flex flex-col gap-2.5",children:Object.entries(v).map(([e,t])=>(0,r.jsxs)("div",{children:[(0,r.jsx)("p",{className:"text-xs font-semibold text-text-main mb-1.5 capitalize",children:e}),(0,r.jsx)("div",{className:"flex flex-col gap-1",children:t.map(e=>{let t=h[e.status]||h.unknown,s=d===`${e.provider}:${e.model}`;return(0,r.jsxs)("div",{className:"flex items-center justify-between px-2.5 py-1.5 rounded-lg bg-surface/30",children:[(0,r.jsxs)("div",{className:"flex items-center gap-1.5 min-w-0",children:[(0,r.jsx)("span",{className:"material-symbols-outlined text-[14px] shrink-0",style:{color:t.color},children:t.icon}),(0,r.jsx)("span",{className:"font-mono text-xs text-text-main truncate",children:e.model})]}),"cooldown"===e.status&&(0,r.jsx)(n.$n,{size:"sm",variant:"ghost",onClick:()=>f(e.provider,e.model),disabled:s,className:"text-[10px] px-1.5! py-0.5! ml-2",children:s?"...":"Clear"})]},`${e.provider}-${e.model}`)})})]},e))})})]})})}function g(e,t,s){let a=[];if(e>0&&a.push((0,r.jsxs)(n.Ex,{variant:"success",size:"sm",dot:!0,children:[e," Connected"]},"connected")),t>0){let e=s?`${t} Error (${s})`:`${t} Error`;a.push((0,r.jsx)(n.Ex,{variant:"error",size:"sm",dot:!0,children:e},"error"))}return 0===a.length?(0,r.jsx)("span",{className:"text-text-muted",children:"No connections"}):a}async function b(e){let t=new AbortController,s=window.setTimeout(()=>t.abort(),8e3);try{let s=await fetch(e,{cache:"no-store",signal:t.signal}),r=null;try{r=await s.json()}catch{r=null}return{response:s,data:r}}finally{window.clearTimeout(s)}}function v(){let e,t,[s,i]=(0,a.useState)([]),[l,o]=(0,a.useState)([]),[p,m]=(0,a.useState)(!0),[h,g]=(0,a.useState)(""),[v,T]=(0,a.useState)(1),[A,I]=(0,a.useState)(20),[S,$]=(0,a.useState)(!1),[R,E]=(0,a.useState)(!1),[O,P]=(0,a.useState)(null),[U,_]=(0,a.useState)(null),z=(0,x.i)(),q=(0,u.C)(e=>e.query),M=(0,u.C)(e=>e.register),D=(0,u.C)(e=>e.unregister);(0,a.useEffect)(()=>(M("Search providers..."),()=>D()),[M,D]),(0,a.useEffect)(()=>{T(1)},[q,A]);let F=e=>!q.trim()||e.toLowerCase().includes(q.trim().toLowerCase());(0,a.useEffect)(()=>{(async()=>{try{g("");let[e,t]=await Promise.allSettled([b("/api/providers"),b("/api/provider-nodes")]);"fulfilled"===e.status&&e.value.response.ok?i(e.value.data?.connections||[]):(i([]),g("Provider connection stats could not be loaded. The provider catalog is still available.")),"fulfilled"===t.status&&t.value.response.ok?o(t.value.data?.nodes||[]):(o([]),g(e=>e||"Custom provider data could not be loaded. The provider catalog is still available."))}catch(e){console.log("Error fetching data:",e),g("Provider data could not be loaded. The provider catalog is still available.")}finally{m(!1)}})()},[]);let K=(0,a.useMemo)(()=>{let e=new Map;for(let t of s){let s=t.provider||t.id;e.has(s)||e.set(s,[]),e.get(s).push(t)}return e},[s]),L=s.length,J=(0,a.useMemo)(()=>s.filter(e=>!1!==e.isActive).length,[s]),W=K.size,H=Math.max(0,L-J),B=L>0?Math.round(J/L*100):0,Q=(e,t)=>{let s=Array.isArray(t)?t:[t],r=(K.get(e)||[]).filter(e=>s.includes(e.authType)),a=r.filter(e=>{let t,s=(t=Object.entries(e).some(([e,t])=>e.startsWith("modelLock_")&&t&&new Date(t).getTime()>Date.now()),"unavailable"!==e.testStatus||t?e.testStatus:"active");return"error"===s||"expired"===s||"unavailable"===s}),i=r.length>0?r.length:0,l=r.length>0?0:a.length,n=r.length,o=n>0&&r.every(e=>!1===e.isActive),d=a.sort((e,t)=>new Date(t.lastErrorAt||0)-new Date(e.lastErrorAt||0))[0];return{connected:i,error:l,total:n,errorCode:d?function(e){if(!e)return null;let t=e.lastErrorType;if("runtime_error"===t)return"RUNTIME";if("upstream_auth_error"===t||"auth_missing"===t||"token_refresh_failed"===t||"token_expired"===t)return"AUTH";if("upstream_rate_limited"===t)return"429";if("upstream_unavailable"===t)return"5XX";if("network_error"===t)return"NET";let s=Number(e.errorCode);if(Number.isFinite(s)&&s>=400)return String(s);let r=function(e){if(!e)return null;let t=e.match(/\b([45]\d{2})\b/);return t?t[1]:"ERR"}(e.lastError);if("401"===r||"403"===r)return"AUTH";if(r&&"ERR"!==r)return r;let a=(e.lastError||"").toLowerCase();return a.includes("runtime")||a.includes("not runnable")||a.includes("not installed")?"RUNTIME":a.includes("invalid api key")||a.includes("token invalid")||a.includes("revoked")||a.includes("unauthorized")?"AUTH":"ERR"}(d):null,errorTime:d?.lastErrorAt?function(e){if(!e)return"";let t=Math.floor((Date.now()-new Date(e).getTime())/6e4);if(t<1)return"just now";if(t<60)return`${t}m ago`;let s=Math.floor(t/60);if(s<24)return`${s}h ago`;let r=Math.floor(s/24);return`${r}d ago`}(d.lastErrorAt):null,allDisabled:o}},V=async(e,t,r)=>{let a=s.filter(s=>s.provider===e&&s.authType===t);i(s=>s.map(s=>s.provider===e&&s.authType===t?{...s,isActive:r}:s)),await Promise.allSettled(a.map(e=>fetch(`/api/providers/${e.id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({isActive:r})})))},X=async(e,t=null)=>{if(!O){P("provider"===e?t:e),_(null);try{let s=await fetch("/api/providers/test-batch",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mode:e,providerId:t})}),r=await s.json();if(_(r),r.summary){let{passed:e,failed:t,total:s}=r.summary;0===t?z.success(`All ${s} tests passed`):z.warning(`${e}/${s} passed, ${t} failed`)}}catch(e){_({error:"Test request failed"}),z.error("Provider test failed")}finally{P(null)}}},Z=l.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=>F(e.name)),G=l.filter(e=>"anthropic-compatible"===e.type).map(e=>({id:e.id,name:e.name||"Anthropic Compatible",color:"#D97757",textIcon:"AC"})).filter(e=>F(e.name)),Y=Object.entries(d.zN).filter(([,e])=>!e.hidden&&F(e.name)),ee=Object.entries(c.IS).filter(([,e])=>!e.hidden&&F(e.name)),et=Object.entries(c.nJ).filter(([,e])=>!e.hidden&&F(e.name)),es=(e=Object.entries(d.fg).filter(([,e])=>!e.hidden&&(e.serviceKinds??["llm"]).includes("llm")&&F(e.name)),t="apikey",[...e].sort(([e,s],[r,a])=>{let i=Q(e,t),l=Q(r,t),n=+(i.connected>0),o=+(l.connected>0);return n!==o?o-n:(s.name||"").localeCompare(a.name||"")})),er=Math.min(v,Math.max(1,Math.ceil(es.length/A))),ea=es.slice((er-1)*A,er*A);if(p)return(0,r.jsxs)("div",{className:"flex flex-col gap-8",children:[(0,r.jsx)(n.Qv,{}),(0,r.jsx)(n.Qv,{})]});let ei=Y.length>0||ee.length>0||et.length>0||es.length>0||Z.length>0||G.length>0;return(0,r.jsxs)("div",{className:"flex min-w-0 flex-col gap-6 px-1 sm:px-0 lg:gap-7",children:[L>0&&(0,r.jsxs)("div",{className:"overflow-hidden rounded-2xl border border-primary/15 bg-surface/85 shadow-[0_20px_45px_-38px_rgba(229,106,74,0.8)] backdrop-blur-sm",children:[(0,r.jsxs)("div",{className:"grid grid-cols-2 divide-x divide-y divide-border-subtle sm:grid-cols-4 sm:divide-y-0",children:[(0,r.jsxs)("div",{className:"col-span-2 flex items-center gap-3 px-4 py-3.5 sm:col-span-1",children:[(0,r.jsx)("span",{className:"flex size-10 shrink-0 items-center justify-center rounded-xl bg-primary/10 text-primary ring-1 ring-primary/15",children:(0,r.jsx)("span",{"aria-hidden":"true",className:"material-symbols-outlined",style:{fontSize:20},children:"dns"})}),(0,r.jsxs)("div",{children:[(0,r.jsx)("p",{className:"text-[10px] font-bold uppercase tracking-[0.12em] text-text-muted",children:"Connection health"}),(0,r.jsxs)("p",{className:"mt-0.5 text-sm font-semibold text-text-main",children:[B,"% active"]})]})]}),(0,r.jsxs)("div",{className:"px-4 py-3.5",children:[(0,r.jsx)("p",{className:"text-[10px] font-bold uppercase tracking-[0.1em] text-text-muted",children:"Connections"}),(0,r.jsx)("p",{className:"mt-1 text-xl font-bold tracking-tight text-text-main",children:L})]}),(0,r.jsxs)("div",{className:"px-4 py-3.5",children:[(0,r.jsx)("p",{className:"text-[10px] font-bold uppercase tracking-[0.1em] text-text-muted",children:"Active"}),(0,r.jsxs)("div",{className:"mt-1 flex items-baseline gap-2",children:[(0,r.jsx)("p",{className:"text-xl font-bold tracking-tight text-success",children:J}),H>0&&(0,r.jsxs)("span",{className:"text-[10px] text-text-muted",children:[H," paused"]})]})]}),(0,r.jsxs)("div",{className:"px-4 py-3.5",children:[(0,r.jsx)("p",{className:"text-[10px] font-bold uppercase tracking-[0.1em] text-text-muted",children:"Providers"}),(0,r.jsx)("p",{className:"mt-1 text-xl font-bold tracking-tight text-info",children:W})]})]}),L>=100&&(0,r.jsxs)("div",{className:"flex items-center gap-2 border-t border-border-subtle bg-surface-2/35 px-4 py-2 text-[11px] text-text-muted",children:[(0,r.jsx)("span",{"aria-hidden":"true",className:"material-symbols-outlined text-[15px] text-primary",children:"filter_alt"}),"Open a provider to search and filter its paginated connections."]})]}),h&&(0,r.jsx)("div",{className:"rounded-lg border border-amber-200 bg-amber-50 px-4 py-3 text-sm text-amber-700 dark:border-amber-800 dark:bg-amber-900/20 dark:text-amber-300",children:h}),!ei&&(0,r.jsxs)("div",{className:"text-center py-8 border border-dashed border-border rounded-xl",children:[(0,r.jsx)("span",{className:"material-symbols-outlined text-[32px] text-text-muted mb-2",children:"search_off"}),(0,r.jsx)("p",{className:"text-text-muted text-sm",children:"No providers match your search"})]}),(0,r.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,r.jsx)(y,{icon:"extension",title:"Custom Providers",description:"OpenAI and Anthropic-compatible endpoints",children:(0,r.jsxs)("div",{className:"grid grid-cols-1 gap-2 sm:flex sm:w-auto",children:[(0,r.jsx)(n.$n,{size:"sm",icon:"add",onClick:()=>E(!0),className:"w-full sm:w-auto",children:"Add Anthropic Compatible"}),(0,r.jsx)(n.$n,{size:"sm",variant:"secondary",icon:"add",onClick:()=>$(!0),className:"w-full !bg-white !text-black hover:!bg-gray-100 sm:w-auto",children:"Add OpenAI Compatible"})]})}),0===Z.length&&0===G.length?(0,r.jsxs)("div",{className:"flex items-center gap-3 rounded-xl border border-dashed border-border bg-surface/45 px-4 py-3 text-text-muted",children:[(0,r.jsx)("span",{"aria-hidden":"true",className:"material-symbols-outlined flex size-9 shrink-0 items-center justify-center rounded-lg bg-surface-2 text-[18px]",children:"add_link"}),(0,r.jsxs)("div",{children:[(0,r.jsx)("p",{className:"text-sm font-medium text-text-main",children:"No custom endpoints yet"}),(0,r.jsx)("p",{className:"mt-0.5 text-xs",children:"Add an OpenAI or Anthropic-compatible endpoint when you need one."})]})]}):(0,r.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:[...Z,...G].map(e=>(0,r.jsx)(N,{providerId:e.id,provider:e,stats:Q(e.id,"apikey"),authType:"compatible",onToggle:t=>V(e.id,"apikey",t)},e.id))})]}),Y.length>0&&(0,r.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,r.jsx)(y,{icon:"passkey",title:"OAuth Providers",description:"Connect existing provider accounts securely",children:(0,r.jsxs)("div",{className:"flex w-full flex-col gap-2 sm:w-auto sm:flex-row sm:items-center",children:[(0,r.jsx)(f,{}),(0,r.jsxs)("button",{onClick:()=>X("oauth"),disabled:!!O,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"===O?"bg-primary/20 border-primary/40 text-primary animate-pulse":"bg-bg border-border text-text-muted hover:text-text-main hover:border-primary/40"}`,title:"Test all OAuth connections","aria-label":"Test all OAuth connections",children:[(0,r.jsx)("span",{className:`material-symbols-outlined text-[14px]${"oauth"===O?" animate-spin":""}`,children:"play_arrow"}),"oauth"===O?"Testing...":"Test All"]})]})}),(0,r.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,r.jsx)(j,{providerId:e,provider:t,stats:Q(e,"oauth"),authType:"oauth",onToggle:t=>V(e,"oauth",t)},e))})]}),(ee.length>0||et.length>0)&&(0,r.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,r.jsx)(y,{icon:"savings",title:"Free Tier Providers",description:"Ready-to-use and free-tier routing options",children:(0,r.jsxs)("button",{onClick:()=>X("free"),disabled:!!O,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"===O?"bg-primary/20 border-primary/40 text-primary animate-pulse":"bg-bg border-border text-text-muted hover:text-text-main hover:border-primary/40"}`,title:"Test all Free connections","aria-label":"Test all Free provider connections",children:[(0,r.jsx)("span",{className:`material-symbols-outlined text-[14px]${"free"===O?" animate-spin":""}`,children:"play_arrow"}),"free"===O?"Testing...":"Test All"]})}),(0,r.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:[ee.map(([e,t])=>{let s=Array.isArray(t?.authModes)&&t.authModes.includes("apikey");return(0,r.jsx)(j,{providerId:e,provider:t,stats:Q(e,s?["oauth","apikey"]:"oauth"),authType:"free",onToggle:t=>V(e,s?"apikey":"oauth",t)},e)}),et.map(([e,t])=>(0,r.jsx)(N,{providerId:e,provider:t,stats:Q(e,"apikey"),authType:"apikey",onToggle:t=>V(e,"apikey",t)},e))]})]}),es.length>0&&(0,r.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,r.jsx)(y,{icon:"key",title:"API Key Providers",description:"Bring your own provider credentials",children:(0,r.jsxs)("button",{onClick:()=>X("apikey"),disabled:!!O,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"===O?"bg-primary/20 border-primary/40 text-primary animate-pulse":"bg-bg border-border text-text-muted hover:text-text-main hover:border-primary/40"}`,title:"Test all API Key connections","aria-label":"Test all API Key connections",children:[(0,r.jsx)("span",{className:`material-symbols-outlined text-[14px]${"apikey"===O?" animate-spin":""}`,children:"play_arrow"}),"apikey"===O?"Testing...":"Test All"]})}),(0,r.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:ea.map(([e,t])=>(0,r.jsx)(N,{providerId:e,provider:t,stats:Q(e,"apikey"),authType:"apikey",onToggle:t=>V(e,"apikey",t)},e))}),es.length>0&&(0,r.jsx)(n.dK,{currentPage:er,pageSize:A,totalItems:es.length,onPageChange:T,onPageSizeChange:e=>{I(e),T(1)}})]}),(0,r.jsx)(w,{isOpen:S,onClose:()=>$(!1),onCreated:e=>{o(t=>[...t,e]),$(!1)}}),(0,r.jsx)(k,{isOpen:R,onClose:()=>E(!1),onCreated:e=>{o(t=>[...t,e]),E(!1)}}),U&&(0,r.jsxs)("div",{className:"fixed inset-0 z-50 flex items-start justify-center px-3 pt-[6vh] sm:pt-[10vh]",onClick:()=>_(null),children:[(0,r.jsx)("div",{className:"absolute inset-0 bg-black/60 backdrop-blur-sm"}),(0,r.jsxs)("div",{className:"relative bg-surface border border-border rounded-xl w-full max-w-[600px] max-h-[86vh] sm:max-h-[80vh] overflow-y-auto shadow-2xl",onClick:e=>e.stopPropagation(),children:[(0,r.jsxs)("div",{className:"sticky top-0 z-10 flex items-center justify-between px-5 py-3 border-b border-border bg-surface/95 backdrop-blur-sm rounded-t-xl",children:[(0,r.jsx)("h3",{className:"font-semibold",children:"Test Results"}),(0,r.jsx)("button",{onClick:()=>_(null),className:"p-1 rounded-lg hover:bg-bg text-text-muted hover:text-text-main transition-colors","aria-label":"Close test results",children:(0,r.jsx)("span",{className:"material-symbols-outlined text-lg",children:"close"})})]}),(0,r.jsx)("div",{className:"p-5",children:(0,r.jsx)(C,{results:U})})]})]})]})}function y({icon:e,title:t,description:s,children:a}){return(0,r.jsxs)("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[(0,r.jsxs)("div",{className:"flex min-w-0 items-center gap-3",children:[(0,r.jsx)("span",{"aria-hidden":"true",className:"material-symbols-outlined flex size-10 shrink-0 items-center justify-center rounded-xl bg-primary/10 text-[20px] text-primary ring-1 ring-primary/15",children:e}),(0,r.jsxs)("div",{className:"min-w-0",children:[(0,r.jsx)("h2",{className:"text-lg font-semibold leading-tight sm:text-xl",children:t}),(0,r.jsx)("p",{className:"mt-0.5 text-xs text-text-muted",children:s})]})]}),a]})}function j({providerId:e,provider:t,stats:s,authType:a,onToggle:i}){let{connected:l,error:d,errorCode:c,allDisabled:p}=s,x=!!t.noAuth,u=!p&&(l>0||x);return(0,r.jsx)(m(),{href:`/dashboard/providers/${e}`,className:"group min-w-0",children:(0,r.jsxs)(n.Zp,{padding:"none",className:`relative h-[82px] min-h-[82px] cursor-pointer overflow-hidden transition-[border-color,box-shadow,opacity] sm:h-[94px] sm:min-h-[94px] ${u?"border-success/25 bg-linear-to-br from-success/[0.045] to-transparent":"group-hover:border-primary/25"} ${p?"opacity-55":""}`,children:[u&&(0,r.jsx)("span",{className:"absolute inset-y-3 left-0 w-0.5 rounded-r-full bg-success"}),(0,r.jsxs)("div",{className:"flex h-full min-w-0 items-center justify-between gap-3 p-3.5",children:[(0,r.jsxs)("div",{className:"flex min-w-0 items-center gap-3",children:[(0,r.jsx)("div",{className:"flex size-10 shrink-0 items-center justify-center rounded-xl ring-1 ring-black/[0.04] dark:ring-white/[0.06]",style:{backgroundColor:`${t.color?.length>7?t.color:t.color+"15"}`},children:(0,r.jsx)(o.A,{src:`/providers/${t.id}.png`,alt:"",size:30,className:"max-h-[32px] max-w-[32px] rounded-lg object-contain",fallbackText:t.textIcon||t.id.slice(0,2).toUpperCase(),fallbackColor:t.color})}),(0,r.jsxs)("div",{className:"min-w-0",children:[(0,r.jsx)("h3",{className:"truncate text-sm font-semibold text-text-main",children:t.name}),(0,r.jsxs)("div",{className:"mt-1 flex min-w-0 items-center gap-1.5 overflow-hidden whitespace-nowrap text-xs",children:[(0,r.jsxs)("span",{className:"inline-flex items-center gap-1 text-[10px] font-medium text-text-muted",children:[(0,r.jsx)("span",{"aria-hidden":"true",className:`size-1.5 rounded-full ${{free:"bg-green-500",oauth:"bg-blue-500",apikey:"bg-amber-500",compatible:"bg-orange-500"}[a]||"bg-text-muted"}`}),{free:"Free",oauth:"OAuth",apikey:"API Key",compatible:"Compatible"}[a]||"Provider"]}),p?(0,r.jsx)(n.Ex,{variant:"default",size:"sm",children:(0,r.jsxs)("span",{className:"flex items-center gap-1",children:[(0,r.jsx)("span",{className:"material-symbols-outlined text-[12px]",children:"pause_circle"}),"Disabled"]})}):x?(0,r.jsx)(n.Ex,{variant:"success",size:"sm",dot:!0,children:"Ready"}):(0,r.jsx)(r.Fragment,{children:g(l,d,c)})]})]})]}),(0,r.jsxs)("div",{className:"flex shrink-0 items-center gap-2",children:[s.total>0&&(0,r.jsx)("div",{className:"opacity-100 transition-opacity sm:opacity-0 sm:group-hover:opacity-100",onClick:e=>{e.preventDefault(),e.stopPropagation(),i(!!p)},children:(0,r.jsx)(n.lM,{size:"sm",checked:!p,onChange:()=>{},title:p?"Enable provider":"Disable provider"})}),(0,r.jsx)("span",{"aria-hidden":"true",className:"material-symbols-outlined text-[18px] text-text-subtle transition-[transform,color] group-hover:translate-x-0.5 group-hover:text-primary",children:"chevron_right"})]})]})]})})}function N({providerId:e,provider:t,stats:s,authType:a,onToggle:i}){let{connected:l,error:d,errorCode:p,allDisabled:x}=s,u=!x&&l>0,h=e.startsWith(c.JH),f=e.startsWith(c.DI);return(0,r.jsx)(m(),{href:`/dashboard/providers/${e}`,className:"group min-w-0",children:(0,r.jsxs)(n.Zp,{padding:"none",className:`relative h-[82px] min-h-[82px] cursor-pointer overflow-hidden transition-[border-color,box-shadow,opacity] sm:h-[94px] sm:min-h-[94px] ${u?"border-success/25 bg-linear-to-br from-success/[0.045] to-transparent":"group-hover:border-primary/25"} ${x?"opacity-55":""}`,children:[u&&(0,r.jsx)("span",{className:"absolute inset-y-3 left-0 w-0.5 rounded-r-full bg-success"}),(0,r.jsxs)("div",{className:"flex h-full min-w-0 items-center justify-between gap-3 p-3.5",children:[(0,r.jsxs)("div",{className:"flex min-w-0 items-center gap-3",children:[(0,r.jsx)("div",{className:"flex size-10 shrink-0 items-center justify-center rounded-xl ring-1 ring-black/[0.04] dark:ring-white/[0.06]",style:{backgroundColor:`${t.color?.length>7?t.color:t.color+"15"}`},children:(0,r.jsx)(o.A,{src:"featherless"===t.id?null:h?"responses"===t.apiType?"/providers/oai-r.png":"/providers/oai-cc.png":f?"/providers/anthropic-m.png":`/providers/${t.id}.png`,alt:"",size:30,className:"max-h-[32px] max-w-[32px] rounded-lg object-contain",fallbackText:t.textIcon||t.id.slice(0,2).toUpperCase(),fallbackColor:t.color})}),(0,r.jsxs)("div",{className:"min-w-0",children:[(0,r.jsx)("h3",{className:"truncate text-sm font-semibold text-text-main",children:t.name}),(0,r.jsxs)("div",{className:"mt-1 flex min-w-0 items-center gap-1.5 overflow-hidden whitespace-nowrap text-xs",children:[(0,r.jsxs)("span",{className:"inline-flex items-center gap-1 text-[10px] font-medium text-text-muted",children:[(0,r.jsx)("span",{"aria-hidden":"true",className:`size-1.5 rounded-full ${{free:"bg-green-500",oauth:"bg-blue-500",apikey:"bg-amber-500",compatible:"bg-orange-500"}[a]||"bg-text-muted"}`}),{free:"Free",oauth:"OAuth",apikey:"API Key",compatible:"Compatible"}[a]||"Provider"]}),x?(0,r.jsx)(n.Ex,{variant:"default",size:"sm",children:(0,r.jsxs)("span",{className:"flex items-center gap-1",children:[(0,r.jsx)("span",{className:"material-symbols-outlined text-[12px]",children:"pause_circle"}),"Disabled"]})}):(0,r.jsxs)(r.Fragment,{children:[g(l,d,p),h&&(0,r.jsx)(n.Ex,{variant:"default",size:"sm",children:"responses"===t.apiType?"Responses":"Chat"}),f&&(0,r.jsx)(n.Ex,{variant:"default",size:"sm",children:"Messages"})]})]})]})]}),(0,r.jsxs)("div",{className:"flex shrink-0 items-center gap-2",children:[s.total>0&&(0,r.jsx)("div",{className:"opacity-100 transition-opacity sm:opacity-0 sm:group-hover:opacity-100",onClick:e=>{e.preventDefault(),e.stopPropagation(),i(!!x)},children:(0,r.jsx)(n.lM,{size:"sm",checked:!x,onChange:()=>{},title:x?"Enable provider":"Disable provider"})}),(0,r.jsx)("span",{"aria-hidden":"true",className:"material-symbols-outlined text-[18px] text-text-subtle transition-[transform,color] group-hover:translate-x-0.5 group-hover:text-primary",children:"chevron_right"})]})]})]})})}function w({isOpen:e,onClose:t,onCreated:s}){let[i,l]=(0,a.useState)({name:"",prefix:"",apiType:"chat",baseUrl:"https://api.openai.com/v1"}),[o,d]=(0,a.useState)(!1),[c,p]=(0,a.useState)(""),[m,x]=(0,a.useState)(""),[u,h]=(0,a.useState)(!1),[f,g]=(0,a.useState)(null);(0,a.useEffect)(()=>{let e="https://api.openai.com/v1";l(t=>t.baseUrl&&t.baseUrl!==e?t:{...t,baseUrl:e})},[i.apiType]);let b=async()=>{if(i.name.trim()&&i.prefix.trim()&&i.baseUrl.trim()){d(!0);try{let e=await fetch("/api/provider-nodes",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:i.name,prefix:i.prefix,apiType:i.apiType,baseUrl:i.baseUrl,type:"openai-compatible"})}),t=await e.json();e.ok&&(s(t.node),l({name:"",prefix:"",apiType:"chat",baseUrl:"https://api.openai.com/v1"}),p(""),g(null))}catch(e){console.log("Error creating OpenAI Compatible node:",e)}finally{d(!1)}}},v=async()=>{h(!0);try{let e=await fetch("/api/provider-nodes/validate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({baseUrl:i.baseUrl,apiKey:c,type:"openai-compatible",modelId:m.trim()||void 0})}),t=await e.json();g(t)}catch{g({valid:!1,error:"Network error"})}finally{h(!1)}};return(0,r.jsx)(n.aF,{isOpen:e,title:"Add OpenAI Compatible",onClose:t,children:(0,r.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,r.jsx)(n.pd,{label:"Name",value:i.name,onChange:e=>l({...i,name:e.target.value}),placeholder:"OpenAI Compatible (Prod)",hint:"Required. A friendly label for this node."}),(0,r.jsx)(n.pd,{label:"Prefix",value:i.prefix,onChange:e=>l({...i,prefix:e.target.value}),placeholder:"oc-prod",hint:"Required. Used as the provider prefix for model IDs."}),(0,r.jsx)(n.l6,{label:"API Type",options:[{value:"chat",label:"Chat Completions"},{value:"responses",label:"Responses API"}],value:i.apiType,onChange:e=>l({...i,apiType:e.target.value})}),(0,r.jsx)(n.pd,{label:"Base URL",value:i.baseUrl,onChange:e=>l({...i,baseUrl:e.target.value}),placeholder:"https://api.openai.com/v1",hint:"Use the base URL (ending in /v1) for your OpenAI-compatible API."}),(0,r.jsx)(n.pd,{label:"API Key (for Check)",type:"password",value:c,onChange:e=>p(e.target.value)}),(0,r.jsx)(n.pd,{label:"Model ID (optional)",value:m,onChange:e=>x(e.target.value),placeholder:"e.g. gpt-4, claude-3-opus",hint:"If provider lacks /models endpoint, enter a model ID to validate via chat/completions instead."}),(0,r.jsxs)("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center",children:[(0,r.jsx)(n.$n,{onClick:v,disabled:!c||u||!i.baseUrl.trim(),variant:"secondary",className:"w-full sm:w-auto",children:u?"Checking...":"Check"}),(()=>{if(!f)return null;let{valid:e,error:t,method:s}=f;return e?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(n.Ex,{variant:"success",children:"Valid"}),"chat"===s&&(0,r.jsx)("span",{className:"text-sm text-text-muted",children:"(via inference test)"})]}):(0,r.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,r.jsx)(n.Ex,{variant:"error",children:"Invalid"}),t&&(0,r.jsx)("span",{className:"text-sm text-red-500",children:t})]})})()]}),(0,r.jsxs)("div",{className:"flex flex-col gap-2 sm:flex-row",children:[(0,r.jsx)(n.$n,{onClick:b,fullWidth:!0,disabled:!i.name.trim()||!i.prefix.trim()||!i.baseUrl.trim()||o,children:o?"Creating...":"Create"}),(0,r.jsx)(n.$n,{onClick:t,variant:"ghost",fullWidth:!0,children:"Cancel"})]})]})})}function k({isOpen:e,onClose:t,onCreated:s}){let[i,l]=(0,a.useState)({name:"",prefix:"",baseUrl:"https://api.anthropic.com/v1"}),[o,d]=(0,a.useState)(!1),[c,p]=(0,a.useState)(""),[m,x]=(0,a.useState)(""),[u,h]=(0,a.useState)(!1),[f,g]=(0,a.useState)(null);(0,a.useEffect)(()=>{e&&(g(null),p(""),x(""))},[e]);let b=async()=>{if(i.name.trim()&&i.prefix.trim()&&i.baseUrl.trim()){d(!0);try{let e=await fetch("/api/provider-nodes",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:i.name,prefix:i.prefix,baseUrl:i.baseUrl,type:"anthropic-compatible"})}),t=await e.json();e.ok&&(s(t.node),l({name:"",prefix:"",baseUrl:"https://api.anthropic.com/v1"}),p(""),g(null))}catch(e){console.log("Error creating Anthropic Compatible node:",e)}finally{d(!1)}}},v=async()=>{h(!0);try{let e=await fetch("/api/provider-nodes/validate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({baseUrl:i.baseUrl,apiKey:c,type:"anthropic-compatible",modelId:m.trim()||void 0})}),t=await e.json();g(t)}catch{g({valid:!1,error:"Network error"})}finally{h(!1)}};return(0,r.jsx)(n.aF,{isOpen:e,title:"Add Anthropic Compatible",onClose:t,children:(0,r.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,r.jsx)(n.pd,{label:"Name",value:i.name,onChange:e=>l({...i,name:e.target.value}),placeholder:"Anthropic Compatible (Prod)",hint:"Required. A friendly label for this node."}),(0,r.jsx)(n.pd,{label:"Prefix",value:i.prefix,onChange:e=>l({...i,prefix:e.target.value}),placeholder:"ac-prod",hint:"Required. Used as the provider prefix for model IDs."}),(0,r.jsx)(n.pd,{label:"Base URL",value:i.baseUrl,onChange:e=>l({...i,baseUrl:e.target.value}),placeholder:"https://api.anthropic.com/v1",hint:"Use the base URL (ending in /v1) for your Anthropic-compatible API. The system will append /messages."}),(0,r.jsx)(n.pd,{label:"API Key (for Check)",type:"password",value:c,onChange:e=>p(e.target.value)}),(0,r.jsx)(n.pd,{label:"Model ID (optional)",value:m,onChange:e=>x(e.target.value),placeholder:"e.g. claude-3-opus",hint:"If provider lacks /models endpoint, enter a model ID to validate via chat/completions instead."}),(0,r.jsxs)("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center",children:[(0,r.jsx)(n.$n,{onClick:v,disabled:!c||u||!i.baseUrl.trim(),variant:"secondary",className:"w-full sm:w-auto",children:u?"Checking...":"Check"}),(()=>{if(!f)return null;let{valid:e,error:t,method:s}=f;return e?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(n.Ex,{variant:"success",children:"Valid"}),"chat"===s&&(0,r.jsx)("span",{className:"text-sm text-text-muted",children:"(via inference test)"})]}):(0,r.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,r.jsx)(n.Ex,{variant:"error",children:"Invalid"}),t&&(0,r.jsx)("span",{className:"text-sm text-red-500",children:t})]})})()]}),(0,r.jsxs)("div",{className:"flex flex-col gap-2 sm:flex-row",children:[(0,r.jsx)(n.$n,{onClick:b,fullWidth:!0,disabled:!i.name.trim()||!i.prefix.trim()||!i.baseUrl.trim()||o,children:o?"Creating...":"Create"}),(0,r.jsx)(n.$n,{onClick:t,variant:"ghost",fullWidth:!0,children:"Cancel"})]})]})})}function C({results:e}){if(e.error&&!e.results)return(0,r.jsxs)("div",{className:"text-center py-6",children:[(0,r.jsx)("span",{className:"material-symbols-outlined text-red-500 text-[32px] mb-2 block",children:"error"}),(0,r.jsx)("p",{className:"text-sm text-red-400",children:e.error})]});let{summary:t,mode:s}=e,a=e.results||[];return(0,r.jsxs)("div",{className:"flex min-w-0 flex-col gap-3",children:[t&&(0,r.jsxs)("div",{className:"flex flex-wrap items-center gap-2 text-xs mb-1 sm:gap-3",children:[(0,r.jsxs)("span",{className:"text-text-muted",children:[{oauth:"OAuth",free:"Free",apikey:"API Key",provider:"Provider",all:"All"}[s]||s," Test"]}),(0,r.jsxs)("span",{className:"px-2 py-0.5 rounded bg-emerald-500/15 text-emerald-400 font-medium",children:[t.passed," passed"]}),t.failed>0&&(0,r.jsxs)("span",{className:"px-2 py-0.5 rounded bg-red-500/15 text-red-400 font-medium",children:[t.failed," failed"]}),(0,r.jsxs)("span",{className:"text-text-muted sm:ml-auto",children:[t.total," tested"]})]}),a.map((e,t)=>(0,r.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,r.jsx)("span",{className:`material-symbols-outlined text-[16px] ${e.valid?"text-emerald-500":"text-red-500"}`,children:e.valid?"check_circle":"error"}),(0,r.jsxs)("div",{className:"min-w-0 flex-[1_1_160px]",children:[(0,r.jsx)("span",{className:"block truncate font-medium sm:inline",children:e.connectionName}),(0,r.jsxs)("span",{className:"block truncate text-text-muted sm:ml-1.5 sm:inline",children:["(",e.provider,")"]})]}),void 0!==e.latencyMs&&(0,r.jsxs)("span",{className:"shrink-0 text-text-muted font-mono tabular-nums",children:[e.latencyMs,"ms"]}),(0,r.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,r.jsx)("div",{className:"text-center py-4 text-text-muted text-sm",children:"No active connections found for this group."})]})}y.propTypes={icon:l().string.isRequired,title:l().string.isRequired,description:l().string.isRequired,children:l().node},j.propTypes={providerId:l().string.isRequired,provider:l().shape({id:l().string.isRequired,name:l().string.isRequired,color:l().string,textIcon:l().string}).isRequired,stats:l().shape({connected:l().number,error:l().number,errorCode:l().string,errorTime:l().string,total:l().number,allDisabled:l().bool}).isRequired,authType:l().string,onToggle:l().func},N.propTypes={providerId:l().string.isRequired,provider:l().shape({id:l().string.isRequired,name:l().string.isRequired,color:l().string,textIcon:l().string,apiType:l().string}).isRequired,stats:l().shape({connected:l().number,error:l().number,errorCode:l().string,errorTime:l().string,total:l().number,allDisabled:l().bool}).isRequired,authType:l().string,onToggle:l().func},w.propTypes={isOpen:l().bool.isRequired,onClose:l().func.isRequired,onCreated:l().func.isRequired},k.propTypes={isOpen:l().bool.isRequired,onClose:l().func.isRequired,onCreated:l().func.isRequired},C.propTypes={results:l().shape({mode:l().string,results:l().array,summary:l().shape({total:l().number,passed:l().number,failed:l().number}),error:l().string}).isRequired}}},e=>{e.O(0,[2574,3862,3745,9802,620,5497,8441,3794,7358],()=>e(e.s=31703)),_N_E=e.O()}]);
@@ -1 +0,0 @@
1
- (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[3826],{5498:(e,t,a)=>{Promise.resolve().then(a.bind(a,75095)),Promise.resolve().then(a.bind(a,25086))},75095:(e,t,a)=>{"use strict";a.d(t,{default:()=>P});var r=a(95155),n=a(12115),s=a(57250),i=a(42793);function l(e,t){return t&&0!==t?!e||e<0?100:e>=t?0:Math.round((t-e)/t*100):0}function o(e,t){if(!t||"object"!=typeof t)return[];let a=[];try{switch(e.toLowerCase()){case"github":t.quotas&&Object.entries(t.quotas).forEach(([e,t])=>{a.push({name:e,used:t.used||0,total:t.total||0,resetAt:t.resetAt||null})});break;case"antigravity":t.quotas&&Object.entries(t.quotas).forEach(([e,t])=>{a.push({name:t.displayName||e,modelKey:e,used:t.used||0,total:t.total||0,resetAt:t.resetAt||null,remainingPercentage:t.remainingPercentage})});break;case"codex":t.quotas&&Object.entries(t.quotas).forEach(([e,t])=>{a.push({name:e,used:t.used||0,total:t.total||0,remaining:t.remaining,resetAt:t.resetAt||null})});break;case"kiro":t.quotas&&Object.entries(t.quotas).forEach(([e,t])=>{a.push({name:e,used:t.used||0,total:t.total||0,resetAt:t.resetAt||null})});break;case"qoder":t.quotas&&Object.entries(t.quotas).forEach(([e,t])=>{("organization"!==e||t&&0!==(Number(t.total)||0))&&a.push({name:"user"===e?"Personal":"organization"===e?"Organization":e,used:t.used||0,total:t.total||0,unit:t.unit,resetAt:t.resetAt||null})});break;case"autoclaw":t.quotas&&Object.entries(t.quotas).forEach(([e,t])=>{a.push({name:"points"===e?"Points":e,used:t.used||0,total:t.total||0,unit:t.unit,resetAt:t.resetAt||null})});break;case"claude":t.message?a.push({name:"error",used:0,total:0,resetAt:null,message:t.message}):t.quotas&&Object.entries(t.quotas).forEach(([e,t])=>{a.push({name:e,used:t.used||0,total:t.total||0,resetAt:t.resetAt||null})});break;case"grok-cli":t.quotas&&Object.entries(t.quotas).forEach(([e,t])=>{let r=!0===t.unlimited||!(t.total>0)&&t.remainingPercentage>0;a.push({name:e,used:t.used||0,total:r?0:t.total||0,resetAt:t.resetAt||null,remainingPercentage:null!=t.remainingPercentage?t.remainingPercentage:r?100:void 0,unlimited:r})});break;case"cloudflare-ai":t.quotas&&Object.entries(t.quotas).forEach(([e,t])=>{let r=!0===t.unlimited||!(t.total>0);a.push({name:e,used:t.used||0,total:r?0:t.total||0,resetAt:t.resetAt||null,remainingPercentage:null!=t.remainingPercentage?t.remainingPercentage:100*!!r,unlimited:r})});break;default:t.quotas&&Object.entries(t.quotas).forEach(([e,t])=>{a.push({name:e,used:t.used||0,total:t.total||0,resetAt:t.resetAt||null,...null!=t.remainingPercentage?{remainingPercentage:t.remainingPercentage}:{},...!0===t.unlimited?{unlimited:!0}:{}})})}}catch(t){return console.error(`Error parsing quota data for ${e}:`,t),[]}let r=(0,i.KC)(e);if(r.length>0){let e=new Map(r.map((e,t)=>[e.id,t]));a.sort((t,a)=>{let r=t.modelKey||t.name,n=a.modelKey||a.name;return(e.get(r)??999)-(e.get(n)??999)})}return a}function c({quotas:e=[],compact:t=!1,sortMode:a="default",showSortLabel:s=!1}){let[i,o]=(0,n.useState)(1),d=(0,n.useMemo)(()=>e.map((e,t)=>({...e,index:t,remaining:function(e){if(e?.unlimited===!0)return e?.remainingPercentage!==void 0&&Number.isFinite(Number(e.remainingPercentage))?Math.max(0,Math.min(100,Math.round(Number(e.remainingPercentage)))):100;if(e?.remainingPercentage!==void 0&&Number.isFinite(Number(e.remainingPercentage)))return Math.max(0,Math.min(100,Math.round(Number(e.remainingPercentage))));if(e?.remaining!==void 0&&Number.isFinite(Number(e.remaining))){let t=Number(e.remaining);if(t>=0&&t<=100&&!(e.total>100&&t<=100&&null!=e.used))return e.total>0?l(e.used,e.total):Math.round(t)}return l(e?.used,e?.total)}(e)})),[e]),u=(0,n.useMemo)(()=>"remaining-asc"===a?[...d].sort((e,t)=>e.remaining-t.remaining||e.name.localeCompare(t.name)):"remaining-desc"===a?[...d].sort((e,t)=>t.remaining-e.remaining||e.name.localeCompare(t.name)):d,[d,a]),m=Math.max(1,Math.ceil(u.length/10));if((0,n.useEffect)(()=>{o(1)},[a,e]),(0,n.useEffect)(()=>{o(e=>Math.min(e,m))},[m]),!e||0===e.length)return null;let x=u.slice((i-1)*10,10*i),h=0===u.length?0:(i-1)*10+1,b=Math.min(10*i,u.length),p=t?"py-1 px-1.5":"py-2 px-3",g=t?"text-[11px]":"text-sm",f=t?"text-[11px]":"text-sm",v=t?"text-[10px] leading-tight":"text-xs";return(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,r.jsxs)("div",{className:"text-[10px] text-text-muted",children:[u.length," quota",u.length>1?"s":""]}),s&&(0,r.jsx)("div",{className:"rounded-md border border-black/10 bg-black/[0.02] px-2 py-1 text-[10px] text-text-muted dark:border-white/10 dark:bg-white/[0.03]",children:"Sorted by account remaining"})]}),(0,r.jsx)("div",{className:"overflow-x-auto",children:(0,r.jsx)("table",{className:"w-full table-fixed text-left",children:(0,r.jsx)("tbody",{children:x.map(e=>{var a;let n=(a=e.remaining)>70?{text:"text-green-600 dark:text-green-400",bg:"bg-green-500",bgLight:"bg-green-500/10",emoji:"\uD83D\uDFE2"}:a>=30?{text:"text-yellow-600 dark:text-yellow-400",bg:"bg-yellow-500",bgLight:"bg-yellow-500/10",emoji:"\uD83D\uDFE1"}:{text:"text-red-600 dark:text-red-400",bg:"bg-red-500",bgLight:"bg-red-500/10",emoji:"\uD83D\uDD34"},s=function(e){if(!e)return"-";try{let t="string"==typeof e?new Date(e):e,a=new Date,r=t-a;if(r<=0)return"-";let n=Math.ceil(r/6e4);if(n<60)return`${n}m`;let s=Math.floor(n/60),i=n%60;if(s<24)return`${s}h ${i}m`;let l=Math.floor(s/24);return`${l}d ${s%24}h ${i}m`}catch(e){return"-"}}(e.resetAt),i=function(e){if(!e)return null;try{let t=new Date(e),a=new Date,r=new Date(a.getFullYear(),a.getMonth(),a.getDate()),n=new Date(r);n.setDate(n.getDate()+1);let s="";s=t>=r&&t<n?"Today":t>=n&&t<new Date(n.getTime()+864e5)?"Tomorrow":t.toLocaleDateString("en-US",{month:"short",day:"numeric"});let i=t.toLocaleTimeString("en-US",{hour:"numeric",minute:"2-digit",hour12:!0});return`${s}, ${i}`}catch{return null}}(e.resetAt);return(0,r.jsxs)("tr",{className:"border-b border-black/5 dark:border-white/5 hover:bg-black/[0.02] dark:hover:bg-white/[0.02] transition-colors",children:[(0,r.jsx)("td",{className:`${p} w-[30%]`,children:(0,r.jsxs)("div",{className:"flex items-center gap-1.5 min-w-0",children:[(0,r.jsx)("span",{className:"text-[10px] shrink-0",children:n.emoji}),(0,r.jsx)("span",{className:`${g} font-medium text-text-primary truncate`,children:e.name})]})}),(0,r.jsx)("td",{className:`${p} w-[45%]`,children:(0,r.jsxs)("div",{className:t?"space-y-1":"space-y-1.5",children:[(0,r.jsx)("div",{className:`${t?"h-1":"h-1.5"} rounded-full overflow-hidden border ${n.bgLight} ${0===e.remaining?"border-black/10 dark:border-white/10":"border-transparent"}`,children:(0,r.jsx)("div",{className:`h-full transition-all duration-300 ${n.bg}`,style:{width:`${Math.min(e.remaining,100)}%`}})}),(0,r.jsxs)("div",{className:`flex items-center justify-between ${t?"text-[10px]":"text-xs"}`,children:[(0,r.jsx)("span",{className:"text-text-muted",children:!0!==e.unlimited&&e.total>0?`${e.used.toLocaleString()} / ${e.total.toLocaleString()}`:!0===e.unlimited?"Included / ∞":`${e.used.toLocaleString()} / ∞`}),(0,r.jsx)("span",{className:`font-medium ${n.text}`,children:Number.isFinite(e.remaining)?`${e.remaining}%`:"—"})]})]})}),(0,r.jsx)("td",{className:`${p} w-[25%]`,children:"-"!==s||i?t?(0,r.jsx)("div",{className:`${f} text-text-primary font-medium truncate`,title:i||"",children:"-"!==s?`in ${s}`:i}):(0,r.jsxs)("div",{className:"space-y-0.5",children:["-"!==s&&(0,r.jsxs)("div",{className:`${f} text-text-primary font-medium`,children:["in ",s]}),i&&(0,r.jsx)("div",{className:`${v} text-text-muted`,children:i})]}):(0,r.jsx)("div",{className:`${f} text-text-muted italic`,children:"N/A"})})]},`${e.name}-${e.index}`)})})})}),m>1&&(0,r.jsxs)("div",{className:"rounded-md border border-black/10 bg-black/[0.02] px-2 py-1.5 dark:border-white/10 dark:bg-white/[0.03]",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between gap-2 text-[10px] text-text-muted",children:[(0,r.jsxs)("span",{children:["Showing ",h,"-",b," of ",u.length]}),(0,r.jsxs)("span",{children:["Page ",i," / ",m]})]}),(0,r.jsxs)("div",{className:"mt-1.5 flex items-center justify-end gap-1",children:[(0,r.jsx)("button",{type:"button",onClick:()=>o(e=>Math.max(1,e-1)),disabled:1===i,className:"flex h-6 items-center rounded-md border border-black/10 px-2 text-[10px] text-text-primary transition-colors hover:bg-black/5 disabled:cursor-not-allowed disabled:opacity-40 dark:border-white/10 dark:hover:bg-white/5",children:"Prev"}),(0,r.jsx)("button",{type:"button",onClick:()=>o(e=>Math.min(m,e+1)),disabled:i===m,className:"flex h-6 items-center rounded-md border border-black/10 px-2 text-[10px] text-text-primary transition-colors hover:bg-black/5 disabled:cursor-not-allowed disabled:opacity-40 dark:border-white/10 dark:hover:bg-white/5",children:"Next"})]})]})]})}var d=a(98542),u=a(84588),m=a(35497),x=a(52679);function h(e){let t=e=>"string"==typeof e&&/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e);return t(e.email)?e.email:(t(e.name),e.name)}function b(e,t){let a=t[e.id]?.quotas?.[0];return a&&"number"==typeof a.remaining?a.remaining:1/0}function p(e){return x.Q2[e]?.name||e}function g(e){let t={};return e.forEach(e=>{t[e.id]=!0}),t}function f(e,t){let a=new Set(t.map(e=>e.id));return Object.fromEntries(Object.entries(e).filter(([e])=>a.has(e)))}async function v(e,t){return await e(t)}let y="quotaCacheData";function k(){try{let e=window.localStorage.getItem(y);return e?JSON.parse(e):{}}catch(e){return console.error("Error reading quota cache:",e),{}}}function w(e,t){try{let a=k();a[e]={...t,cachedAt:new Date().toISOString()},window.localStorage.setItem(y,JSON.stringify(a))}catch(e){console.error("Error writing quota cache:",e)}}let j="quotaAutoRefresh",N=[{value:"all",label:"All accounts"},{value:"active",label:"Active"},{value:"inactive",label:"Turned off"}],S=[{value:"single",label:"Satuan",icon:"account_circle"},{value:"bulk",label:"Bulk",icon:"stacks"}],C=[{value:"default",label:"Default quota order"},{value:"remaining-asc",label:"% quota: low to high"},{value:"remaining-desc",label:"% quota: high to low"}],$=[10,20,50,100];function P(){let[e,t]=(0,n.useState)([]),[a,i]=(0,n.useState)({}),[P,A]=(0,n.useState)({}),[q,E]=(0,n.useState)({}),[M,D]=(0,n.useState)(!0),[O,I]=(0,n.useState)(null),[T,_]=(0,n.useState)(!1),[F,L]=(0,n.useState)(!1),[z,U]=(0,n.useState)(60),[R,J]=(0,n.useState)(!0),[K,B]=(0,n.useState)(null),[Q,W]=(0,n.useState)(null),[G,H]=(0,n.useState)(!1),[Y,V]=(0,n.useState)(null),[X,Z]=(0,n.useState)([]),[ee,et]=(0,n.useState)("all"),[ea,er]=(0,n.useState)([]),[en,es]=(0,n.useState)("single"),[ei,el]=(0,n.useState)("all"),[eo,ec]=(0,n.useState)("default"),[ed,eu]=(0,n.useState)(!1),[em,ex]=(0,n.useState)(!1),[eh,eb]=(0,n.useState)(!1),[ep,eg]=(0,n.useState)({}),[ef,ev]=(0,n.useState)({}),[ey,ek]=(0,n.useState)(1),[ew,ej]=(0,n.useState)(20),[eN,eS]=(0,n.useState)(String(20)),[eC,e$]=(0,n.useState)({page:1,pageSize:20,total:0,totalPages:1}),[eP,eA]=(0,n.useState)({eligibleConnections:0,providerFilteredConnections:0}),eq=(0,n.useRef)(null),eE=(0,n.useRef)(null),eM=(0,n.useCallback)(async(e=ey)=>{try{var a,r;let n=new URLSearchParams({page:String(e),pageSize:String(ew),accountStatus:ei,sort:"priority"});"all"!==ee&&n.set("provider",ee);let s=await fetch(`/api/providers/client?${n.toString()}`);if(!s.ok)throw Error("Failed to fetch connections");let i=await s.json(),l=i.connections||[],o=(a=i.pagination,a||{page:1,pageSize:ew,total:0,totalPages:1}),c=function(e,t=0){return e||{eligibleConnections:t,providerFilteredConnections:t}}(i.totals,l.length);return t(l),er(i.providerOptions||[]),e$(o),eA(c),ek((r=i.pagination,r?.page||e)),l}catch(e){return console.error("Error fetching connections:",e),t([]),er([]),e$({page:1,pageSize:ew,total:0,totalPages:1}),eA({eligibleConnections:0,providerFilteredConnections:0}),[]}},[ei,ey,ew,ee]),eD=(0,n.useCallback)(async(e,t,a=!1)=>{A(t=>({...t,[e]:!0})),E(t=>({...t,[e]:null}));try{console.log(`[ProviderLimits] Fetching quota for ${t} (${e})`);let r=await fetch(`/api/usage/${e}${a?"?refresh=1":""}`);if(!r.ok){let a=(await r.json().catch(()=>({}))).error||r.statusText;if(404===r.status)return void console.warn(`[ProviderLimits] Connection not found for ${t}, skipping`);if(401===r.status){console.warn(`[ProviderLimits] Auth error for ${t}:`,a);let r={quotas:[],message:a};i(t=>({...t,[e]:r})),w(e,r);return}throw Error(`HTTP ${r.status}: ${a}`)}let n=await r.json();console.log(`[ProviderLimits] Got quota for ${t}:`,n);let s={quotas:o(t,n),plan:n.plan||null,message:n.message||null,raw:n};i(t=>({...t,[e]:s})),w(e,s)}catch(a){console.error(`[ProviderLimits] Error fetching quota for ${t} (${e}):`,a),E(t=>({...t,[e]:a.message||"Failed to fetch quota"}))}finally{A(t=>({...t,[e]:!1}))}},[]),eO=(0,n.useCallback)(async(e,t)=>{await eD(e,t),I(new Date)},[eD]),eI=(0,n.useCallback)(async(e,t=!1)=>{if(e&&"all"!==e){ev(t=>({...t,[e]:!0}));try{let a=`/api/usage/aggregate?provider=${encodeURIComponent(e)}${t?"&refresh=1":""}`,r=await fetch(a);if(!r.ok)throw Error("Failed to fetch aggregate");let n=await r.json(),s=o(e,n);eg(t=>({...t,[e]:{quotas:s,plan:n.plan||null,accountCount:n.accountCount||0,accountsWithQuota:n.accountsWithQuota||0,deadCount:n.deadCount||0}}))}catch(t){console.error(`[ProviderLimits] Aggregate fetch error for ${e}:`,t)}finally{ev(t=>({...t,[e]:!1}))}}},[]),eT=(0,n.useCallback)(async(e,t)=>{if("bulk"===en&&t){await eI(t,!0),I(new Date);return}e?.length&&(A(t=>({...t,...Object.fromEntries(e.map(e=>[e,!0]))})),await Promise.all(e.map(e=>eD(e,t))),I(new Date))},[eD,en,eI]),e_=(0,n.useCallback)(async e=>{if(confirm("Delete this connection?")){B(e);try{if((await fetch(`/api/providers/${e}`,{method:"DELETE"})).ok){i(t=>{let a={...t};return delete a[e],a}),A(t=>{let a={...t};return delete a[e],a}),E(t=>{let a={...t};return delete a[e],a});try{let t=k();t[e]&&(delete t[e],window.localStorage.setItem(y,JSON.stringify(t)))}catch(e){console.error("Error deleting cache entry:",e)}await v(eM,ey)}}catch(e){console.error("Error deleting connection:",e)}finally{B(null)}}},[eM,ey]),eF=(0,n.useCallback)(async(e,t)=>{W(e);try{(await fetch(`/api/providers/${e}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({isActive:t})})).ok&&(i(e=>({...e})),await v(eM,ey))}catch(e){console.error("Error updating connection status:",e)}finally{W(null)}},[eM,ey]),eL=(0,n.useCallback)(async e=>{if(!Y?.id)return;let t=Y.id,a=Y.provider;try{(await fetch(`/api/providers/${t}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})).ok&&(await eM(),H(!1),V(null),x.wb.includes(a)&&await eD(t,a))}catch(e){console.error("Error saving connection:",e)}},[Y,eM,eD]);(0,n.useEffect)(()=>{let e=!1;return fetch("/api/proxy-pools?isActive=true",{cache:"no-store"}).then(e=>e.json()).then(t=>{!e&&t?.proxyPools&&Z(t.proxyPools)}).catch(()=>{}),()=>{e=!0}},[]);let ez=(0,n.useCallback)(async()=>{if(!F){L(!0),U(60);try{let e=await eM(ey);A(g(e)),E(t=>f(t,e)),i(t=>f(t,e)),await Promise.all(e.map(e=>eD(e.id,e.provider,!0))),"bulk"===en&&("all"!==ee?[ee]:ea.map(e=>e.value||e).filter(e=>"all"!==e)).forEach(e=>eI(e,!0)),I(new Date)}catch(e){console.error("Error refreshing all providers:",e)}finally{L(!1)}}},[F,eM,eD,ey,en,ee,ea,eI]);(0,n.useEffect)(()=>{(async()=>{J(!0);let e=await eM(ey);J(!1),A(g(e)),E(t=>f(t,e)),i(t=>f(t,e)),await Promise.all(e.map(e=>eD(e.id,e.provider))),I(new Date)})()},[eM,eD,ey]),(0,n.useEffect)(()=>{"bulk"!==en||("all"!==ee?[ee]:ea.map(e=>e.value||e).filter(e=>"all"!==e)).forEach(e=>eI(e))},[en,ee,ea,eI]),(0,n.useEffect)(()=>{let e=window.localStorage.getItem(j);D(null===e||"true"===e),_(!0)},[]),(0,n.useEffect)(()=>{T&&window.localStorage.setItem(j,String(M))},[M,T]),(0,n.useEffect)(()=>{if(!T||!M){eq.current&&(clearInterval(eq.current),eq.current=null),eE.current&&(clearInterval(eE.current),eE.current=null);return}return eq.current=setInterval(()=>{ez()},6e4),eE.current=setInterval(()=>{U(e=>e<=1?60:e-1)},1e3),()=>{eq.current&&clearInterval(eq.current),eE.current&&clearInterval(eE.current)}},[M,ez,T]),(0,n.useEffect)(()=>{let e=()=>{document.hidden?(eq.current&&(clearInterval(eq.current),eq.current=null),eE.current&&(clearInterval(eE.current),eE.current=null)):M&&T&&(eq.current=setInterval(ez,6e4),eE.current=setInterval(()=>{U(e=>e<=1?60:e-1)},1e3))};return document.addEventListener("visibilitychange",e),()=>{document.removeEventListener("visibilitychange",e)}},[M,ez,T]);let eU=(0,n.useMemo)(()=>(function(e,t,a,r,n){if("codex"===r&&"default"!==n)return[...e].sort((e,a)=>{let r=b(e,t),s=b(a,t),i="remaining-asc"===n?r-s:s-r;return 0!==i?i:(h(e)||"").localeCompare(h(a)||"")});if(!a)return e;let s=e=>{let a=(t[e.id]?.quotas||[]).map(e=>e.resetAt?new Date(e.resetAt).getTime():1/0).filter(e=>Number.isFinite(e));return a.length>0?Math.min(...a):1/0};return[...e].sort((e,t)=>{let a=s(e)-s(t);return 0!==a?a:(e.provider||"").localeCompare(t.provider||"")||(h(e)||"").localeCompare(h(t)||"")})})(e,a,ed,ee,eo),[e,a,ed,ee,eo]),eR=(0,n.useMemo)(()=>{let e;return e=new Map,eU.forEach(t=>{t.provider&&(e.has(t.provider)||e.set(t.provider,[]),e.get(t.provider).push(t))}),[...e.entries()].map(([e,t])=>(function(e,t,a,r,n){if(!t.length)return null;let s=[],i=[],l=null,o=!1;return t.forEach(e=>{let t=a[e.id];Array.isArray(t?.quotas)&&s.push(...t.quotas),t?.message&&!l&&(l=t.message),n[e.id]&&i.push(n[e.id]),r[e.id]&&(o=!0)}),{id:`${e}-aggregate`,provider:e,name:p(e),email:`${t.length} accounts`,isActive:t.some(e=>e.isActive??!0),isAggregate:!0,quota:{quotas:function(e=[]){let t=new Map;return e.forEach(e=>{if(!e?.name)return;let a=t.get(e.name)||{name:e.name,used:0,total:0,resetAt:e.resetAt||null,remainingPercentage:null,unlimited:!1,_pctSum:0,_pctCount:0};a.used+=Number(e.used)||0,a.total+=Number(e.total)||0,!0===e.unlimited&&(a.unlimited=!0),null!=e.remainingPercentage&&Number.isFinite(Number(e.remainingPercentage))&&(a._pctSum+=Number(e.remainingPercentage),a._pctCount+=1),e.resetAt&&(!a.resetAt||new Date(e.resetAt).getTime()<new Date(a.resetAt).getTime())&&(a.resetAt=e.resetAt),t.set(e.name,a)}),[...t.values()].map(e=>{let{_pctSum:t,_pctCount:a,...r}=e;return r.unlimited?(r.remainingPercentage=100,r.total=0):r.total>0?r.remainingPercentage=(r.total-r.used)/r.total*100:a>0?r.remainingPercentage=t/a:r.remainingPercentage=0,r})}(s),message:0===s.length&&l||null},isLoading:o,error:!s.length&&i.length>0?i[0]:null,connectionIds:t.map(e=>e.id)}})(e,t,a,P,q)).filter(Boolean)},[eU,a,P,q]),eJ=(0,n.useMemo)(()=>Object.keys(ep).length?eR.map(e=>{let t=ep[e.provider];return t&&t.quotas?.length?{...e,email:`${t.accountCount||e.connectionIds?.length||0} accounts`,quota:{...e.quota,quotas:t.quotas,message:null},isLoading:ef[e.provider]||!1}:e}):eR,[eR,ep,ef]),eK=(0,n.useMemo)(()=>"bulk"===en?eJ:eU,[en,eJ,eU]),eB=e=>{let t=a[e.id]?.quotas;return!!t?.length&&t.some(e=>!!e.total&&!(e.total<=0)&&5>=l(e.used,e.total))},eQ=(0,n.useCallback)(async(e,t)=>{if(e.length&&!eh){eb(!0);try{await Promise.all(e.map(e=>fetch(`/api/providers/${e}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({isActive:t})}))),await v(eM,ey)}catch(e){console.error("Error bulk toggling connections:",e)}finally{eb(!1)}}},[eh,eM,ey]),eW="all"===ee?"All providers":ee,eG=eP.eligibleConnections>0,eH=eK.length>0,eY=eP.eligibleConnections?eP.providerFilteredConnections?{icon:"filter_alt_off",title:"No Accounts On This Page",description:"Try moving to another page or refreshing the current filters."}:{icon:"filter_alt_off",title:"No Accounts Match Current Filters",description:"all"===ee?"Try changing the account status filter to see more quota trackers.":`No ${"inactive"===ei?"turned off":"active"===ei?"active":"matching"} accounts found for ${ee}.`}:{icon:"cloud_off",title:"No Providers Connected",description:"Connect to providers with OAuth to track your API quota limits and usage."},eV=function(e){var t;let{start:a,end:r}=(t=e).total?{start:(t.page-1)*t.pageSize+1,end:Math.min(t.page*t.pageSize,t.total)}:{start:0,end:0};return`Showing ${a}-${r} of ${e.total}`}(eC),eX=!$.includes(ew);return R||eG?R||eH?(0,r.jsxs)("div",{className:"space-y-6",children:[(0,r.jsx)("div",{className:"flex flex-col gap-4 sm:flex-row sm:items-center sm:justify-end",children:(0,r.jsxs)("div",{className:"flex flex-wrap items-center gap-1.5",children:[(0,r.jsxs)("div",{className:"relative",children:[(0,r.jsxs)("button",{type:"button",onClick:()=>ex(e=>!e),className:"flex h-8 items-center justify-between gap-1 rounded-lg border border-black/10 bg-black/[0.02] px-2 text-xs text-text-primary transition-colors hover:bg-black/5 dark:border-white/10 dark:bg-white/[0.03] dark:hover:bg-white/10","aria-haspopup":"menu","aria-expanded":em,title:"Filter quota providers",children:[(0,r.jsxs)("span",{className:"flex min-w-0 items-center gap-1.5",children:["all"===ee?(0,r.jsx)("span",{className:"material-symbols-outlined text-[14px] text-text-muted",children:"apps"}):(0,r.jsx)(s.A,{src:`/providers/${ee}.png`,alt:ee,size:18,className:"size-[18px] rounded object-contain",fallbackText:ee.slice(0,2).toUpperCase()}),(0,r.jsx)("span",{className:"truncate capitalize hidden lg:inline",children:eW})]}),(0,r.jsx)("span",{className:"material-symbols-outlined text-[14px] text-text-muted",children:"expand_more"})]}),em&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("button",{type:"button",className:"fixed inset-0 z-30 bg-transparent","aria-label":"Close provider filter",onClick:()=>ex(!1)}),(0,r.jsxs)("div",{className:"absolute left-0 z-40 mt-2 w-64 overflow-hidden rounded-2xl border border-black/10 bg-surface/95 p-1.5 shadow-xl shadow-black/10 backdrop-blur dark:border-white/10 dark:bg-surface/95 sm:w-72",children:[(0,r.jsxs)("button",{type:"button",onClick:()=>{"all"!==ee&&ek(1),et("all"),ex(!1)},className:`flex w-full items-center gap-3 rounded-xl px-3 py-2.5 text-left text-sm transition-colors ${"all"===ee?"bg-primary/10 text-primary":"text-text-primary hover:bg-black/5 dark:hover:bg-white/10"}`,children:[(0,r.jsx)("span",{className:"material-symbols-outlined text-[22px]",children:"apps"}),(0,r.jsx)("span",{className:"font-medium",children:"All providers"}),"all"===ee&&(0,r.jsx)("span",{className:"material-symbols-outlined ml-auto text-[20px]",children:"check"})]}),(0,r.jsx)("div",{className:"my-1 h-px bg-black/10 dark:bg-white/10"}),(0,r.jsx)("div",{className:"max-h-72 overflow-y-auto pr-1",children:ea.map(e=>(0,r.jsxs)("button",{type:"button",onClick:()=>{ee!==e&&ek(1),et(e),ex(!1)},className:`flex w-full items-center gap-3 rounded-xl px-3 py-2.5 text-left text-sm transition-colors ${ee===e?"bg-primary/10 text-primary":"text-text-primary hover:bg-black/5 dark:hover:bg-white/10"}`,children:[(0,r.jsx)(s.A,{src:`/providers/${e}.png`,alt:e,size:24,className:"size-6 rounded-md object-contain",fallbackText:e.slice(0,2).toUpperCase()}),(0,r.jsx)("span",{className:"font-medium capitalize",children:e}),ee===e&&(0,r.jsx)("span",{className:"material-symbols-outlined ml-auto text-[20px]",children:"check"})]},e))})]})]})]}),(0,r.jsx)("div",{className:"inline-flex h-8 overflow-hidden rounded-lg border border-black/10 bg-black/[0.02] dark:border-white/10 dark:bg-white/[0.03]",children:S.map(e=>(0,r.jsxs)("button",{type:"button",onClick:()=>es(e.value),"aria-pressed":en===e.value,className:`flex h-full items-center gap-1.5 px-2 text-xs transition-colors ${en===e.value?"bg-primary text-white":"text-text-primary hover:bg-black/5 dark:hover:bg-white/10"}`,title:`Show quota in ${e.label} mode`,children:[(0,r.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:e.icon}),(0,r.jsx)("span",{className:"hidden sm:inline",children:e.label})]},e.value))}),(0,r.jsx)("select",{value:ei,onChange:e=>{let t=e.target.value;ei!==t&&ek(1),el(t)},className:"h-8 rounded-lg border border-black/10 bg-black/[0.02] px-2 text-xs text-text-primary outline-none transition-colors hover:bg-black/5 dark:border-white/10 dark:bg-white/[0.03] dark:hover:bg-white/10","aria-label":"Filter accounts by status",children:N.map(e=>(0,r.jsx)("option",{value:e.value,children:e.label},e.value))}),"codex"===ee&&(0,r.jsx)("select",{value:eo,onChange:e=>ec(e.target.value),className:"h-8 rounded-lg border border-black/10 bg-black/[0.02] px-2 text-xs text-text-primary outline-none transition-colors hover:bg-black/5 dark:border-white/10 dark:bg-white/[0.03] dark:hover:bg-white/10","aria-label":"Sort Codex quotas by remaining",children:C.map(e=>(0,r.jsx)("option",{value:e.value,children:e.label},e.value))}),(0,r.jsxs)("button",{type:"button",onClick:()=>eu(e=>!e),"aria-pressed":ed,className:`flex h-8 shrink-0 items-center gap-1 rounded-lg border px-2 text-xs transition-colors ${ed?"border-amber-500/40 bg-amber-500/10 text-amber-500":"border-black/10 text-text-primary hover:bg-black/5 dark:border-white/10 dark:hover:bg-white/5"}`,title:"Sort accounts by earliest quota reset time",children:[(0,r.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"hourglass_top"}),(0,r.jsx)("span",{className:"hidden sm:inline",children:"Expiring first"})]}),(0,r.jsxs)("button",{type:"button",onClick:()=>{eQ(eU.filter(e=>(e.isActive??!0)&&eB(e)).map(e=>e.id),!1)},disabled:eh,className:"flex h-8 shrink-0 items-center gap-1 rounded-lg border border-red-500/30 px-2 text-xs text-red-500 transition-colors hover:bg-red-500/10 disabled:opacity-50",title:"Disable connections with depleted quota on the current page",children:[(0,r.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"block"}),(0,r.jsx)("span",{className:"hidden sm:inline",children:"Turn off Empty"})]}),(0,r.jsxs)("button",{type:"button",onClick:()=>{eQ(eU.filter(e=>!(e.isActive??!0)&&!eB(e)).map(e=>e.id),!0)},disabled:eh,className:"flex h-8 shrink-0 items-center gap-1 rounded-lg border border-emerald-500/30 px-2 text-xs text-emerald-500 transition-colors hover:bg-emerald-500/10 disabled:opacity-50",title:"Enable connections that still have quota on the current page",children:[(0,r.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"check_circle"}),(0,r.jsx)("span",{className:"hidden sm:inline",children:"Turn on Available"})]}),(0,r.jsxs)("button",{onClick:()=>D(e=>!e),className:"flex h-8 shrink-0 items-center gap-1 rounded-lg border border-black/10 px-2 text-xs transition-colors hover:bg-black/5 dark:border-white/10 dark:hover:bg-white/5",title:M?"Disable auto-refresh":"Enable auto-refresh",children:[(0,r.jsx)("span",{className:`material-symbols-outlined text-[14px] ${M?"text-primary":"text-text-muted"}`,children:M?"toggle_on":"toggle_off"}),(0,r.jsx)("span",{className:"hidden text-text-primary sm:inline",children:"Auto-refresh"}),M&&(0,r.jsxs)("span",{className:"text-[10px] text-text-muted tabular-nums",children:["(",z,"s)"]})]}),(0,r.jsx)("button",{type:"button",onClick:ez,disabled:F,className:"flex h-8 shrink-0 items-center gap-1 rounded-lg border border-black/10 px-2 text-xs text-text-primary transition-colors hover:bg-black/5 dark:border-white/10 dark:hover:bg-white/5 disabled:opacity-50",title:"Refresh all",children:(0,r.jsx)("span",{className:`material-symbols-outlined text-[14px] ${F?"animate-spin":""}`,children:"refresh"})})]})}),ed&&(0,r.jsx)("div",{className:"rounded-xl border border-amber-500/20 bg-amber-500/10 px-3 py-2 text-xs text-amber-700 dark:text-amber-300",children:"Expiring-first currently reorders accounts inside the current page. Cross-page ordering still follows backend pagination."}),(0,r.jsx)("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:eK.map(e=>{let t=!0===e.isAggregate,n=t?e.quota:a[e.id],i=t?e.isLoading:P[e.id],l=t?e.error:q[e.id],o=!1===e.isActive,m=!t&&(K===e.id||Q===e.id);return(0,r.jsxs)(u.default,{padding:"none",className:`min-w-0 ${o?"opacity-60":""}`,children:[(0,r.jsx)("div",{className:"px-3 py-2 border-b border-black/10 dark:border-white/10",children:(0,r.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2 min-w-0",children:[(0,r.jsx)("div",{className:"w-8 h-8 shrink-0 rounded-md flex items-center justify-center overflow-hidden",children:(0,r.jsx)(s.A,{src:`/providers/${e.provider}.png`,alt:e.provider,size:32,className:"object-contain",fallbackText:e.provider?.slice(0,2).toUpperCase()||"PR"})}),(0,r.jsxs)("div",{className:"min-w-0",children:[(0,r.jsx)("h3",{className:"text-sm font-semibold text-text-primary capitalize truncate",children:e.name||p(e.provider)}),h(e)?(0,r.jsx)("p",{className:"text-xs text-text-muted truncate",children:h(e)}):null]})]}),(0,r.jsxs)("div",{className:"flex items-center gap-1 shrink-0",children:[(0,r.jsx)("button",{type:"button",onClick:()=>t?eT(e.connectionIds,e.provider):eO(e.id,e.provider),disabled:i||m,"aria-label":"Refresh quota",className:"p-1.5 rounded-lg hover:bg-black/5 dark:hover:bg-white/5 transition-colors disabled:opacity-50",title:"Refresh quota",children:(0,r.jsx)("span",{className:`material-symbols-outlined text-[18px] text-text-muted ${i?"animate-spin":""}`,children:"refresh"})}),!t&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("button",{type:"button",onClick:()=>{V(e),H(!0)},disabled:m,"aria-label":"Edit connection",className:"p-1.5 rounded-lg hover:bg-black/5 dark:hover:bg-white/5 text-text-muted hover:text-primary transition-colors disabled:opacity-50",title:"Edit connection",children:(0,r.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:"edit"})}),(0,r.jsx)("button",{type:"button",onClick:()=>e_(e.id),disabled:m,"aria-label":"Delete connection",className:"p-1.5 rounded-lg hover:bg-red-500/10 text-red-500 transition-colors disabled:opacity-50",title:"Delete connection",children:(0,r.jsx)("span",{className:`material-symbols-outlined text-[18px] ${K===e.id?"animate-pulse":""}`,children:"delete"})}),(0,r.jsx)("div",{className:"inline-flex items-center pl-0.5",title:e.isActive??!0?"Disable connection":"Enable connection",children:(0,r.jsx)(d.default,{size:"sm",checked:e.isActive??!0,disabled:m,onChange:t=>eF(e.id,t)})})]})]})]})}),(0,r.jsx)("div",{className:"px-2 py-1.5",children:i?(0,r.jsx)("div",{className:"text-center py-5 text-text-muted",children:(0,r.jsx)("span",{className:"material-symbols-outlined text-[28px] animate-spin",children:"progress_activity"})}):l?(0,r.jsxs)("div",{className:"text-center py-5",children:[(0,r.jsx)("span",{className:"material-symbols-outlined text-[28px] text-red-500",children:"error"}),(0,r.jsx)("p",{className:"mt-1.5 text-xs text-text-muted",children:l})]}):n?.quotas?.length>0?(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsx)(c,{quotas:n.quotas,compact:!0,sortMode:"default",showSortLabel:"codex"===e.provider&&"default"!==eo}),n?.message?(0,r.jsx)("p",{className:"px-1 text-[10px] text-text-muted",children:n.message}):null]}):n?.message?(0,r.jsx)("div",{className:"text-center py-5",children:(0,r.jsx)("p",{className:"text-xs text-text-muted",children:n.message})}):(0,r.jsx)("div",{className:"text-center py-5 text-text-muted",children:(0,r.jsx)("p",{className:"text-xs",children:"No quota data available"})})})]},e.id)})}),(0,r.jsx)("div",{className:"rounded-xl border border-black/10 bg-black/[0.02] px-3 py-2 dark:border-white/10 dark:bg-white/[0.03]",children:(0,r.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[(0,r.jsx)("span",{className:"text-xs text-text-muted",children:eV}),(0,r.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,r.jsxs)("select",{value:eX?"custom":String(ew),onChange:e=>{let t=e.target.value;if("custom"===t)return;let a=Number.parseInt(t,10);Number.isFinite(a)&&(ek(1),ej(a),eS(String(a)))},className:"h-8 rounded-lg border border-black/10 bg-black/[0.02] px-2 text-xs text-text-primary outline-none transition-colors hover:bg-black/5 dark:border-white/10 dark:bg-white/[0.03] dark:hover:bg-white/10","aria-label":"Accounts per page",children:[$.map(e=>(0,r.jsxs)("option",{value:String(e),children:[e," / page"]},e)),(0,r.jsx)("option",{value:"custom",children:"Custom"})]}),(0,r.jsx)("input",{type:"number",min:"1",max:String(500),inputMode:"numeric",value:eN,onChange:e=>eS(e.target.value),onBlur:()=>{let e=Number.parseInt(eN,10);if(!Number.isFinite(e))return void eS(String(ew));let t=Math.min(500,Math.max(1,e));ek(1),ej(t),eS(String(t))},onKeyDown:e=>{if("Enter"!==e.key)return;let t=Number.parseInt(eN,10);if(!Number.isFinite(t))return void eS(String(ew));let a=Math.min(500,Math.max(1,t));ek(1),ej(a),eS(String(a))},className:"h-8 w-20 rounded-lg border border-black/10 bg-black/[0.02] px-2 text-xs text-text-primary outline-none transition-colors hover:bg-black/5 dark:border-white/10 dark:bg-white/[0.03] dark:hover:bg-white/10","aria-label":"Custom accounts per page",placeholder:"Custom"}),(0,r.jsxs)("span",{className:"text-xs text-text-muted",children:["Page ",eC.page," / ",eC.totalPages]})]}),(0,r.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,r.jsx)("button",{type:"button",onClick:()=>ek(1),disabled:eC.page<=1||R||F,className:"flex h-8 items-center rounded-lg border border-black/10 px-3 text-xs text-text-primary transition-colors hover:bg-black/5 disabled:cursor-not-allowed disabled:opacity-40 dark:border-white/10 dark:hover:bg-white/5",children:"First Page"}),(0,r.jsx)("button",{type:"button",onClick:()=>ek(e=>Math.max(1,e-1)),disabled:eC.page<=1||R||F,className:"flex h-8 w-8 items-center justify-center rounded-lg border border-black/10 text-text-primary transition-colors hover:bg-black/5 disabled:cursor-not-allowed disabled:opacity-40 dark:border-white/10 dark:hover:bg-white/5","aria-label":"Previous accounts page",children:(0,r.jsx)("span",{className:"material-symbols-outlined text-[16px]",children:"chevron_left"})}),(0,r.jsx)("button",{type:"button",onClick:()=>ek(e=>Math.min(eC.totalPages,e+1)),disabled:eC.page>=eC.totalPages||R||F,className:"flex h-8 w-8 items-center justify-center rounded-lg border border-black/10 text-text-primary transition-colors hover:bg-black/5 disabled:cursor-not-allowed disabled:opacity-40 dark:border-white/10 dark:hover:bg-white/5","aria-label":"Next accounts page",children:(0,r.jsx)("span",{className:"material-symbols-outlined text-[16px]",children:"chevron_right"})}),(0,r.jsx)("button",{type:"button",onClick:()=>ek(eC.totalPages),disabled:eC.page>=eC.totalPages||R||F,className:"flex h-8 items-center rounded-lg border border-black/10 px-3 text-xs text-text-primary transition-colors hover:bg-black/5 disabled:cursor-not-allowed disabled:opacity-40 dark:border-white/10 dark:hover:bg-white/5",children:"Last Page"})]})]})}),(0,r.jsx)(m.wI,{isOpen:G,connection:Y,proxyPools:X,onSave:eL,onClose:()=>{H(!1),V(null)}})]}):(0,r.jsx)(u.default,{padding:"lg",children:(0,r.jsxs)("div",{className:"text-center py-12",children:[(0,r.jsx)("span",{className:"material-symbols-outlined text-[64px] text-text-muted opacity-20",children:eY.icon}),(0,r.jsx)("h3",{className:"mt-4 text-lg font-semibold text-text-primary",children:eY.title}),(0,r.jsx)("p",{className:"mt-2 text-sm text-text-muted max-w-md mx-auto",children:eY.description})]})}):(0,r.jsx)(u.default,{padding:"lg",children:(0,r.jsxs)("div",{className:"text-center py-12",children:[(0,r.jsx)("span",{className:"material-symbols-outlined text-[64px] text-text-muted opacity-20",children:"cloud_off"}),(0,r.jsx)("h3",{className:"mt-4 text-lg font-semibold text-text-primary",children:"No Providers Connected"}),(0,r.jsx)("p",{className:"mt-2 text-sm text-text-muted max-w-md mx-auto",children:"Connect to providers with OAuth to track your API quota limits and usage."})]})})}}},e=>{e.O(0,[2574,3862,3745,9802,620,5497,8441,3794,7358],()=>e(e.s=5498)),_N_E=e.O()}]);