zevairouter 1.0.40 → 1.0.42

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 (309) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/cli/app/.next-cli-build/BUILD_ID +1 -1
  3. package/cli/app/.next-cli-build/app-path-routes-manifest.json +10 -10
  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/profile/page_client-reference-manifest.js +1 -1
  20. package/cli/app/.next-cli-build/server/app/(dashboard)/dashboard/providers/[id]/page_client-reference-manifest.js +1 -1
  21. package/cli/app/.next-cli-build/server/app/(dashboard)/dashboard/providers/new/page_client-reference-manifest.js +1 -1
  22. package/cli/app/.next-cli-build/server/app/(dashboard)/dashboard/providers/page_client-reference-manifest.js +1 -1
  23. package/cli/app/.next-cli-build/server/app/(dashboard)/dashboard/proxy-pools/page_client-reference-manifest.js +1 -1
  24. package/cli/app/.next-cli-build/server/app/(dashboard)/dashboard/pxpipe/page_client-reference-manifest.js +1 -1
  25. package/cli/app/.next-cli-build/server/app/(dashboard)/dashboard/quota/page.js +1 -1
  26. package/cli/app/.next-cli-build/server/app/(dashboard)/dashboard/quota/page_client-reference-manifest.js +1 -1
  27. package/cli/app/.next-cli-build/server/app/(dashboard)/dashboard/token-saver/page_client-reference-manifest.js +1 -1
  28. package/cli/app/.next-cli-build/server/app/(dashboard)/dashboard/translator/page_client-reference-manifest.js +1 -1
  29. package/cli/app/.next-cli-build/server/app/(dashboard)/dashboard/usage/page_client-reference-manifest.js +1 -1
  30. package/cli/app/.next-cli-build/server/app/_global-error/page_client-reference-manifest.js +1 -1
  31. package/cli/app/.next-cli-build/server/app/_global-error.html +1 -1
  32. package/cli/app/.next-cli-build/server/app/_global-error.rsc +1 -1
  33. package/cli/app/.next-cli-build/server/app/_global-error.segments/_full.segment.rsc +1 -1
  34. package/cli/app/.next-cli-build/server/app/_global-error.segments/_global-error/__PAGE__.segment.rsc +1 -1
  35. package/cli/app/.next-cli-build/server/app/_global-error.segments/_global-error.segment.rsc +1 -1
  36. package/cli/app/.next-cli-build/server/app/_global-error.segments/_head.segment.rsc +1 -1
  37. package/cli/app/.next-cli-build/server/app/_global-error.segments/_index.segment.rsc +1 -1
  38. package/cli/app/.next-cli-build/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  39. package/cli/app/.next-cli-build/server/app/_not-found/page_client-reference-manifest.js +1 -1
  40. package/cli/app/.next-cli-build/server/app/_not-found.html +1 -1
  41. package/cli/app/.next-cli-build/server/app/_not-found.rsc +3 -3
  42. package/cli/app/.next-cli-build/server/app/_not-found.segments/_full.segment.rsc +3 -3
  43. package/cli/app/.next-cli-build/server/app/_not-found.segments/_head.segment.rsc +1 -1
  44. package/cli/app/.next-cli-build/server/app/_not-found.segments/_index.segment.rsc +3 -3
  45. package/cli/app/.next-cli-build/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +1 -1
  46. package/cli/app/.next-cli-build/server/app/_not-found.segments/_not-found.segment.rsc +1 -1
  47. package/cli/app/.next-cli-build/server/app/_not-found.segments/_tree.segment.rsc +1 -1
  48. package/cli/app/.next-cli-build/server/app/api/models/route.js +1 -1
  49. package/cli/app/.next-cli-build/server/app/api/models/test/route.js +1 -1
  50. package/cli/app/.next-cli-build/server/app/api/providers/[id]/test-models/route.js +1 -1
  51. package/cli/app/.next-cli-build/server/app/api/providers/client/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 +3 -3
  62. package/cli/app/.next-cli-build/server/app/callback.segments/_full.segment.rsc +3 -3
  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 +3 -3
  65. package/cli/app/.next-cli-build/server/app/callback.segments/_tree.segment.rsc +1 -1
  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 +5 -5
  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 +5 -5
  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 +3 -3
  77. package/cli/app/.next-cli-build/server/app/dashboard/automation.segments/_tree.segment.rsc +1 -1
  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 +5 -5
  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 +5 -5
  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 +3 -3
  87. package/cli/app/.next-cli-build/server/app/dashboard/basic-chat.segments/_tree.segment.rsc +1 -1
  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 +5 -5
  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 +5 -5
  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 +3 -3
  97. package/cli/app/.next-cli-build/server/app/dashboard/cli-tools.segments/_tree.segment.rsc +1 -1
  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 +5 -5
  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 +5 -5
  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 +3 -3
  107. package/cli/app/.next-cli-build/server/app/dashboard/combos.segments/_tree.segment.rsc +1 -1
  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 +5 -5
  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 +5 -5
  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 +3 -3
  117. package/cli/app/.next-cli-build/server/app/dashboard/context.segments/_tree.segment.rsc +1 -1
  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 +5 -5
  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 +5 -5
  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 +3 -3
  127. package/cli/app/.next-cli-build/server/app/dashboard/endpoint.segments/_tree.segment.rsc +1 -1
  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 +5 -5
  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 +5 -5
  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 +3 -3
  138. package/cli/app/.next-cli-build/server/app/dashboard/media-providers/web.segments/_tree.segment.rsc +1 -1
  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 +5 -5
  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 +5 -5
  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 +3 -3
  148. package/cli/app/.next-cli-build/server/app/dashboard/mitm.segments/_tree.segment.rsc +1 -1
  149. package/cli/app/.next-cli-build/server/app/dashboard/profile.html +1 -1
  150. package/cli/app/.next-cli-build/server/app/dashboard/profile.rsc +5 -5
  151. package/cli/app/.next-cli-build/server/app/dashboard/profile.segments/!KGRhc2hib2FyZCk/dashboard/profile/__PAGE__.segment.rsc +2 -2
  152. package/cli/app/.next-cli-build/server/app/dashboard/profile.segments/!KGRhc2hib2FyZCk/dashboard/profile.segment.rsc +1 -1
  153. package/cli/app/.next-cli-build/server/app/dashboard/profile.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  154. package/cli/app/.next-cli-build/server/app/dashboard/profile.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  155. package/cli/app/.next-cli-build/server/app/dashboard/profile.segments/_full.segment.rsc +5 -5
  156. package/cli/app/.next-cli-build/server/app/dashboard/profile.segments/_head.segment.rsc +1 -1
  157. package/cli/app/.next-cli-build/server/app/dashboard/profile.segments/_index.segment.rsc +3 -3
  158. package/cli/app/.next-cli-build/server/app/dashboard/profile.segments/_tree.segment.rsc +1 -1
  159. package/cli/app/.next-cli-build/server/app/dashboard/providers/new.html +1 -1
  160. package/cli/app/.next-cli-build/server/app/dashboard/providers/new.rsc +5 -5
  161. package/cli/app/.next-cli-build/server/app/dashboard/providers/new.segments/!KGRhc2hib2FyZCk/dashboard/providers/new/__PAGE__.segment.rsc +2 -2
  162. package/cli/app/.next-cli-build/server/app/dashboard/providers/new.segments/!KGRhc2hib2FyZCk/dashboard/providers/new.segment.rsc +1 -1
  163. package/cli/app/.next-cli-build/server/app/dashboard/providers/new.segments/!KGRhc2hib2FyZCk/dashboard/providers.segment.rsc +1 -1
  164. package/cli/app/.next-cli-build/server/app/dashboard/providers/new.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  165. package/cli/app/.next-cli-build/server/app/dashboard/providers/new.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  166. package/cli/app/.next-cli-build/server/app/dashboard/providers/new.segments/_full.segment.rsc +5 -5
  167. package/cli/app/.next-cli-build/server/app/dashboard/providers/new.segments/_head.segment.rsc +1 -1
  168. package/cli/app/.next-cli-build/server/app/dashboard/providers/new.segments/_index.segment.rsc +3 -3
  169. package/cli/app/.next-cli-build/server/app/dashboard/providers/new.segments/_tree.segment.rsc +1 -1
  170. package/cli/app/.next-cli-build/server/app/dashboard/providers.html +1 -1
  171. package/cli/app/.next-cli-build/server/app/dashboard/providers.rsc +5 -5
  172. package/cli/app/.next-cli-build/server/app/dashboard/providers.segments/!KGRhc2hib2FyZCk/dashboard/providers/__PAGE__.segment.rsc +2 -2
  173. package/cli/app/.next-cli-build/server/app/dashboard/providers.segments/!KGRhc2hib2FyZCk/dashboard/providers.segment.rsc +1 -1
  174. package/cli/app/.next-cli-build/server/app/dashboard/providers.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  175. package/cli/app/.next-cli-build/server/app/dashboard/providers.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  176. package/cli/app/.next-cli-build/server/app/dashboard/providers.segments/_full.segment.rsc +5 -5
  177. package/cli/app/.next-cli-build/server/app/dashboard/providers.segments/_head.segment.rsc +1 -1
  178. package/cli/app/.next-cli-build/server/app/dashboard/providers.segments/_index.segment.rsc +3 -3
  179. package/cli/app/.next-cli-build/server/app/dashboard/providers.segments/_tree.segment.rsc +1 -1
  180. package/cli/app/.next-cli-build/server/app/dashboard/proxy-pools.html +1 -1
  181. package/cli/app/.next-cli-build/server/app/dashboard/proxy-pools.rsc +5 -5
  182. package/cli/app/.next-cli-build/server/app/dashboard/proxy-pools.segments/!KGRhc2hib2FyZCk/dashboard/proxy-pools/__PAGE__.segment.rsc +2 -2
  183. package/cli/app/.next-cli-build/server/app/dashboard/proxy-pools.segments/!KGRhc2hib2FyZCk/dashboard/proxy-pools.segment.rsc +1 -1
  184. package/cli/app/.next-cli-build/server/app/dashboard/proxy-pools.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  185. package/cli/app/.next-cli-build/server/app/dashboard/proxy-pools.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  186. package/cli/app/.next-cli-build/server/app/dashboard/proxy-pools.segments/_full.segment.rsc +5 -5
  187. package/cli/app/.next-cli-build/server/app/dashboard/proxy-pools.segments/_head.segment.rsc +1 -1
  188. package/cli/app/.next-cli-build/server/app/dashboard/proxy-pools.segments/_index.segment.rsc +3 -3
  189. package/cli/app/.next-cli-build/server/app/dashboard/proxy-pools.segments/_tree.segment.rsc +1 -1
  190. package/cli/app/.next-cli-build/server/app/dashboard/pxpipe.html +1 -1
  191. package/cli/app/.next-cli-build/server/app/dashboard/pxpipe.rsc +5 -5
  192. package/cli/app/.next-cli-build/server/app/dashboard/pxpipe.segments/!KGRhc2hib2FyZCk/dashboard/pxpipe/__PAGE__.segment.rsc +2 -2
  193. package/cli/app/.next-cli-build/server/app/dashboard/pxpipe.segments/!KGRhc2hib2FyZCk/dashboard/pxpipe.segment.rsc +1 -1
  194. package/cli/app/.next-cli-build/server/app/dashboard/pxpipe.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  195. package/cli/app/.next-cli-build/server/app/dashboard/pxpipe.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  196. package/cli/app/.next-cli-build/server/app/dashboard/pxpipe.segments/_full.segment.rsc +5 -5
  197. package/cli/app/.next-cli-build/server/app/dashboard/pxpipe.segments/_head.segment.rsc +1 -1
  198. package/cli/app/.next-cli-build/server/app/dashboard/pxpipe.segments/_index.segment.rsc +3 -3
  199. package/cli/app/.next-cli-build/server/app/dashboard/pxpipe.segments/_tree.segment.rsc +1 -1
  200. package/cli/app/.next-cli-build/server/app/dashboard/quota.html +2 -2
  201. package/cli/app/.next-cli-build/server/app/dashboard/quota.rsc +6 -6
  202. package/cli/app/.next-cli-build/server/app/dashboard/quota.segments/!KGRhc2hib2FyZCk/dashboard/quota/__PAGE__.segment.rsc +3 -3
  203. package/cli/app/.next-cli-build/server/app/dashboard/quota.segments/!KGRhc2hib2FyZCk/dashboard/quota.segment.rsc +1 -1
  204. package/cli/app/.next-cli-build/server/app/dashboard/quota.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  205. package/cli/app/.next-cli-build/server/app/dashboard/quota.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  206. package/cli/app/.next-cli-build/server/app/dashboard/quota.segments/_full.segment.rsc +6 -6
  207. package/cli/app/.next-cli-build/server/app/dashboard/quota.segments/_head.segment.rsc +1 -1
  208. package/cli/app/.next-cli-build/server/app/dashboard/quota.segments/_index.segment.rsc +3 -3
  209. package/cli/app/.next-cli-build/server/app/dashboard/quota.segments/_tree.segment.rsc +1 -1
  210. package/cli/app/.next-cli-build/server/app/dashboard/settings/pricing/page_client-reference-manifest.js +1 -1
  211. package/cli/app/.next-cli-build/server/app/dashboard/settings/pricing.html +1 -1
  212. package/cli/app/.next-cli-build/server/app/dashboard/settings/pricing.rsc +3 -3
  213. package/cli/app/.next-cli-build/server/app/dashboard/settings/pricing.segments/_full.segment.rsc +3 -3
  214. package/cli/app/.next-cli-build/server/app/dashboard/settings/pricing.segments/_head.segment.rsc +1 -1
  215. package/cli/app/.next-cli-build/server/app/dashboard/settings/pricing.segments/_index.segment.rsc +3 -3
  216. package/cli/app/.next-cli-build/server/app/dashboard/settings/pricing.segments/_tree.segment.rsc +1 -1
  217. package/cli/app/.next-cli-build/server/app/dashboard/settings/pricing.segments/dashboard/settings/pricing/__PAGE__.segment.rsc +1 -1
  218. package/cli/app/.next-cli-build/server/app/dashboard/settings/pricing.segments/dashboard/settings/pricing.segment.rsc +1 -1
  219. package/cli/app/.next-cli-build/server/app/dashboard/settings/pricing.segments/dashboard/settings.segment.rsc +1 -1
  220. package/cli/app/.next-cli-build/server/app/dashboard/settings/pricing.segments/dashboard.segment.rsc +1 -1
  221. package/cli/app/.next-cli-build/server/app/dashboard/token-saver.html +1 -1
  222. package/cli/app/.next-cli-build/server/app/dashboard/token-saver.rsc +5 -5
  223. package/cli/app/.next-cli-build/server/app/dashboard/token-saver.segments/!KGRhc2hib2FyZCk/dashboard/token-saver/__PAGE__.segment.rsc +2 -2
  224. package/cli/app/.next-cli-build/server/app/dashboard/token-saver.segments/!KGRhc2hib2FyZCk/dashboard/token-saver.segment.rsc +1 -1
  225. package/cli/app/.next-cli-build/server/app/dashboard/token-saver.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  226. package/cli/app/.next-cli-build/server/app/dashboard/token-saver.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  227. package/cli/app/.next-cli-build/server/app/dashboard/token-saver.segments/_full.segment.rsc +5 -5
  228. package/cli/app/.next-cli-build/server/app/dashboard/token-saver.segments/_head.segment.rsc +1 -1
  229. package/cli/app/.next-cli-build/server/app/dashboard/token-saver.segments/_index.segment.rsc +3 -3
  230. package/cli/app/.next-cli-build/server/app/dashboard/token-saver.segments/_tree.segment.rsc +1 -1
  231. package/cli/app/.next-cli-build/server/app/dashboard/translator.html +1 -1
  232. package/cli/app/.next-cli-build/server/app/dashboard/translator.rsc +5 -5
  233. package/cli/app/.next-cli-build/server/app/dashboard/translator.segments/!KGRhc2hib2FyZCk/dashboard/translator/__PAGE__.segment.rsc +2 -2
  234. package/cli/app/.next-cli-build/server/app/dashboard/translator.segments/!KGRhc2hib2FyZCk/dashboard/translator.segment.rsc +1 -1
  235. package/cli/app/.next-cli-build/server/app/dashboard/translator.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  236. package/cli/app/.next-cli-build/server/app/dashboard/translator.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  237. package/cli/app/.next-cli-build/server/app/dashboard/translator.segments/_full.segment.rsc +5 -5
  238. package/cli/app/.next-cli-build/server/app/dashboard/translator.segments/_head.segment.rsc +1 -1
  239. package/cli/app/.next-cli-build/server/app/dashboard/translator.segments/_index.segment.rsc +3 -3
  240. package/cli/app/.next-cli-build/server/app/dashboard/translator.segments/_tree.segment.rsc +1 -1
  241. package/cli/app/.next-cli-build/server/app/dashboard/usage.html +1 -1
  242. package/cli/app/.next-cli-build/server/app/dashboard/usage.rsc +5 -5
  243. package/cli/app/.next-cli-build/server/app/dashboard/usage.segments/!KGRhc2hib2FyZCk/dashboard/usage/__PAGE__.segment.rsc +2 -2
  244. package/cli/app/.next-cli-build/server/app/dashboard/usage.segments/!KGRhc2hib2FyZCk/dashboard/usage.segment.rsc +1 -1
  245. package/cli/app/.next-cli-build/server/app/dashboard/usage.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  246. package/cli/app/.next-cli-build/server/app/dashboard/usage.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  247. package/cli/app/.next-cli-build/server/app/dashboard/usage.segments/_full.segment.rsc +5 -5
  248. package/cli/app/.next-cli-build/server/app/dashboard/usage.segments/_head.segment.rsc +1 -1
  249. package/cli/app/.next-cli-build/server/app/dashboard/usage.segments/_index.segment.rsc +3 -3
  250. package/cli/app/.next-cli-build/server/app/dashboard/usage.segments/_tree.segment.rsc +1 -1
  251. package/cli/app/.next-cli-build/server/app/dashboard.html +1 -1
  252. package/cli/app/.next-cli-build/server/app/dashboard.rsc +5 -5
  253. package/cli/app/.next-cli-build/server/app/dashboard.segments/!KGRhc2hib2FyZCk/dashboard/__PAGE__.segment.rsc +2 -2
  254. package/cli/app/.next-cli-build/server/app/dashboard.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  255. package/cli/app/.next-cli-build/server/app/dashboard.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  256. package/cli/app/.next-cli-build/server/app/dashboard.segments/_full.segment.rsc +5 -5
  257. package/cli/app/.next-cli-build/server/app/dashboard.segments/_head.segment.rsc +1 -1
  258. package/cli/app/.next-cli-build/server/app/dashboard.segments/_index.segment.rsc +3 -3
  259. package/cli/app/.next-cli-build/server/app/dashboard.segments/_tree.segment.rsc +1 -1
  260. package/cli/app/.next-cli-build/server/app/index.html +1 -1
  261. package/cli/app/.next-cli-build/server/app/index.rsc +3 -3
  262. package/cli/app/.next-cli-build/server/app/index.segments/__PAGE__.segment.rsc +1 -1
  263. package/cli/app/.next-cli-build/server/app/index.segments/_full.segment.rsc +3 -3
  264. package/cli/app/.next-cli-build/server/app/index.segments/_head.segment.rsc +1 -1
  265. package/cli/app/.next-cli-build/server/app/index.segments/_index.segment.rsc +3 -3
  266. package/cli/app/.next-cli-build/server/app/index.segments/_tree.segment.rsc +1 -1
  267. package/cli/app/.next-cli-build/server/app/landing/page_client-reference-manifest.js +1 -1
  268. package/cli/app/.next-cli-build/server/app/landing.html +1 -1
  269. package/cli/app/.next-cli-build/server/app/landing.rsc +3 -3
  270. package/cli/app/.next-cli-build/server/app/landing.segments/_full.segment.rsc +3 -3
  271. package/cli/app/.next-cli-build/server/app/landing.segments/_head.segment.rsc +1 -1
  272. package/cli/app/.next-cli-build/server/app/landing.segments/_index.segment.rsc +3 -3
  273. package/cli/app/.next-cli-build/server/app/landing.segments/_tree.segment.rsc +1 -1
  274. package/cli/app/.next-cli-build/server/app/landing.segments/landing/__PAGE__.segment.rsc +1 -1
  275. package/cli/app/.next-cli-build/server/app/landing.segments/landing.segment.rsc +1 -1
  276. package/cli/app/.next-cli-build/server/app/login/page_client-reference-manifest.js +1 -1
  277. package/cli/app/.next-cli-build/server/app/login.html +1 -1
  278. package/cli/app/.next-cli-build/server/app/login.rsc +4 -4
  279. package/cli/app/.next-cli-build/server/app/login.segments/_full.segment.rsc +4 -4
  280. package/cli/app/.next-cli-build/server/app/login.segments/_head.segment.rsc +1 -1
  281. package/cli/app/.next-cli-build/server/app/login.segments/_index.segment.rsc +3 -3
  282. package/cli/app/.next-cli-build/server/app/login.segments/_tree.segment.rsc +1 -1
  283. package/cli/app/.next-cli-build/server/app/login.segments/login/__PAGE__.segment.rsc +2 -2
  284. package/cli/app/.next-cli-build/server/app/login.segments/login.segment.rsc +1 -1
  285. package/cli/app/.next-cli-build/server/app/page_client-reference-manifest.js +1 -1
  286. package/cli/app/.next-cli-build/server/app-paths-manifest.json +10 -10
  287. package/cli/app/.next-cli-build/server/chunks/4746.js +1 -1
  288. package/cli/app/.next-cli-build/server/chunks/5681.js +1 -1
  289. package/cli/app/.next-cli-build/server/chunks/6896.js +1 -1
  290. package/cli/app/.next-cli-build/server/chunks/7153.js +1 -1
  291. package/cli/app/.next-cli-build/server/chunks/7276.js +1 -1
  292. package/cli/app/.next-cli-build/server/chunks/8242.js +2 -2
  293. package/cli/app/.next-cli-build/server/middleware-build-manifest.js +1 -1
  294. package/cli/app/.next-cli-build/server/pages/404.html +1 -1
  295. package/cli/app/.next-cli-build/server/pages/500.html +1 -1
  296. package/cli/app/.next-cli-build/static/chunks/{1321-fe2fcab7940ae8d5.js → 1321-89d6a896f3dae03e.js} +1 -1
  297. package/cli/app/.next-cli-build/static/chunks/523-f867c3d02c72b48f.js +3 -0
  298. package/cli/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/quota/page-5c75e636ebf21297.js +1 -0
  299. package/cli/app/package.json +1 -1
  300. package/cli/package.json +1 -1
  301. package/package.json +1 -1
  302. package/src/app/(dashboard)/dashboard/endpoint/EndpointPageClient.js +17 -214
  303. package/src/app/(dashboard)/dashboard/usage/components/ProviderLimits/utils.js +21 -1
  304. package/src/app/api/providers/client/route.js +11 -3
  305. package/src/shared/constants/providers.js +5 -1
  306. package/cli/app/.next-cli-build/static/chunks/523-9807fa9a0746de61.js +0 -3
  307. package/cli/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/quota/page-3b33a64814f8c670.js +0 -1
  308. /package/cli/app/.next-cli-build/static/{Fgc4vdsr6a_wWu8yVkotQ → WPP0ARz-9ieVVo7WDF86q}/_buildManifest.js +0 -0
  309. /package/cli/app/.next-cli-build/static/{Fgc4vdsr6a_wWu8yVkotQ → WPP0ARz-9ieVVo7WDF86q}/_ssgManifest.js +0 -0
@@ -0,0 +1,3 @@
1
+ (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[523],{80523:(e,t,s)=>{Promise.resolve().then(s.bind(s,95907))},95907:(e,t,s)=>{"use strict";s.d(t,{default:()=>h});var a=s(95155),l=s(12115),n=s(14051),r=s.n(n),i=s(98500),o=s.n(i),c=s(35497),d=s(11059);let m=[{icon:"public",title:"Access Anywhere",desc:"Use your API from any network"},{icon:"group",title:"Share Endpoint",desc:"Share URL with team members"},{icon:"code",title:"Use in Cursor/Cline",desc:"Connect AI tools remotely"},{icon:"lock",title:"Encrypted",desc:"End-to-end TLS via Cloudflare"}];async function u(e){if(!e)return!1;try{return(await fetch(`${e}/api/health`,{mode:"cors",cache:"no-store",signal:AbortSignal.timeout(5e3)})).ok}catch{return!1}}async function x(...e){let t=e.filter(Boolean).map(u);return!!t.length&&new Promise(e=>{let s=t.length;t.forEach(t=>t.then(t=>{t?e(!0):0==--s&&e(!1)}))})}function h({machineId:e}){let[t,s]=(0,l.useState)([]),[n,r]=(0,l.useState)(!0),[i,f]=(0,l.useState)(!1),[j,k]=(0,l.useState)(""),[v,w]=(0,l.useState)(null),[N,C]=(0,l.useState)(null),[S,T]=(0,l.useState)(!1),[P,_]=(0,l.useState)(!0),[E,$]=(0,l.useState)(!0),[A,I]=(0,l.useState)(!1),[O,U]=(0,l.useState)(!0),[D,F]=(0,l.useState)(!1),[R,q]=(0,l.useState)(!1),[W,L]=(0,l.useState)(""),[K,z]=(0,l.useState)(""),[J,H]=(0,l.useState)(!1),[Z,B]=(0,l.useState)(""),[M,Q]=(0,l.useState)(null),[V,X]=(0,l.useState)(!1),[G,Y]=(0,l.useState)(!1),[ee,et]=(0,l.useState)(!1),[es,ea]=(0,l.useState)(!1),[el,en]=(0,l.useState)(""),[er,ei]=(0,l.useState)(!1),[eo,ec]=(0,l.useState)(""),[ed,em]=(0,l.useState)(null),[eu,ex]=(0,l.useState)(""),[eh,ep]=(0,l.useState)(""),[ey,eb]=(0,l.useState)(null),[eg,ef]=(0,l.useState)(!1),[ej,ek]=(0,l.useState)([]),[ev,ew]=(0,l.useState)(""),[eN,eC]=(0,l.useState)(!1),[eS,eT]=(0,l.useState)(!1),[eP,e_]=(0,l.useState)(!1),eE=(0,l.useRef)(null),e$=(0,l.useRef)(0),eA=(0,l.useRef)(0),eI=(0,l.useRef)(!1),eO=(0,l.useRef)(!1),eU=(0,l.useRef)(!1),eD=(0,l.useRef)(!1),[eF,eR]=(0,l.useState)(!1),[eq,eW]=(0,l.useState)(!1),[eL,eK]=(0,l.useState)(new Set),[ez,eJ]=(0,l.useState)(!1);(0,l.useEffect)(()=>{eJ(!["localhost","127.0.0.1","::1"].includes(window.location.hostname))},[]);let{copied:eH,copy:eZ}=(0,d.C)(),eB=!P||!E,eM=P?"Change the default dashboard password before activating the tunnel.":'Enable "Require login" and set a custom password before activating the tunnel.';(0,l.useEffect)(()=>{eE.current&&(eE.current.scrollTop=eE.current.scrollHeight)},[ej]),(0,l.useEffect)(()=>{e0(),eX()},[]),(0,l.useEffect)(()=>{if(!(D||ee))return;let e=!D||R,t=!ee||es,s=()=>{document.hidden||eV()};if(document.addEventListener("visibilitychange",s),e&&t)return()=>document.removeEventListener("visibilitychange",s);let a=setInterval(()=>{document.hidden||eV()},5e3);return()=>{clearInterval(a),document.removeEventListener("visibilitychange",s)}},[D,ee,R,es]),(0,l.useEffect)(()=>{let e=async()=>{if(!document.hidden){if(D&&(W||K)){let e=await x(K,W);eI.current=e,e?(e$.current=0,q(!0),eU.current||(eU.current=!0,eR(!0))):(e$.current+=1,e$.current>=5&&q(!1))}else eI.current=!1;if(ee&&el){let e=await u(el);eO.current=e,e?(eA.current=0,ea(!0),eD.current||(eD.current=!0,eW(!0))):(eA.current+=1,eA.current>=5&&ea(!1))}else eO.current=!1}};if(!(D&&(W||K)||ee&&el))return;e();let t=!ee||es;if((!D||R)&&t)return;let s=setInterval(e,1e4);return()=>clearInterval(s)},[D,W,K,ee,el,R,es]);let eQ=(0,l.useCallback)((e,t,s,a,l,n)=>{t.current?(s.current=0,a(!0),l.current||(l.current=!0,n(!0))):(s.current+=1,s.current>=5&&a(!1))},[]),eV=async()=>{try{let e=await fetch("/api/tunnel/status",{cache:"no-store"});if(!e.ok)return;let t=await e.json(),s=t.tunnel?.settingsEnabled??t.tunnel?.enabled??!1,a=t.tunnel?.tunnelUrl||"";L(a),z(t.tunnel?.publicUrl||""),F(s),eQ(null,eI,e$,q,eU,eR);let l=t.tailscale?.settingsEnabled??t.tailscale?.enabled??!1,n=t.tailscale?.tunnelUrl||"";en(n),et(l),eQ(null,eO,eA,ea,eD,eW)}catch{}},eX=async()=>{U(!0);try{let[e,t]=await Promise.all([fetch("/api/settings"),fetch("/api/tunnel/status",{cache:"no-store"})]);if(e.ok){let t=await e.json();T(t.requireApiKey||!1),_(!1!==t.requireLogin),$(t.hasPassword||!1),I(t.tunnelDashboardAccess||!1)}if(t.ok){let e=await t.json(),s=e.tunnel?.settingsEnabled??e.tunnel?.enabled??!1,a=e.tunnel?.tunnelUrl||"";L(a),z(e.tunnel?.publicUrl||""),F(s),eQ(null,eI,e$,q,eU,eR);let l=e.tailscale?.settingsEnabled??e.tailscale?.enabled??!1,n=e.tailscale?.tunnelUrl||"";en(n),et(l),eQ(null,eO,eA,ea,eD,eW)}}catch(e){console.log("Error loading settings:",e)}finally{U(!1)}},eG=async e=>{try{(await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({tunnelDashboardAccess:e})})).ok&&I(e)}catch(e){console.log("Error updating tunnelDashboardAccess:",e)}},eY=async e=>{try{(await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({requireApiKey:e})})).ok&&T(e)}catch(e){console.log("Error updating requireApiKey:",e)}},e0=async()=>{try{let e=await fetch("/api/keys"),t=await e.json();e.ok&&s(t.keys||[])}catch(e){console.log("Error fetching data:",e)}finally{r(!1)}},e1=async(...e)=>{H(!0),B("Waiting for tunnel ready...");let t=e.filter(Boolean).map(e=>`${e}/api/health`),s=Date.now();for(;Date.now()-s<3e5;){if(await new Promise(e=>setTimeout(e,2e3)),await Promise.any(t.map(async e=>{if((await fetch(e,{mode:"cors",cache:"no-store"})).ok)return!0;throw Error("not ready")})).catch(()=>!1))return F(!0),H(!1),B(""),!0;if((Date.now()-s)%1e4<2e3)try{let e=await fetch("/api/tunnel/status");if(e.ok){let t=await e.json();if(!t.tunnel?.enabled)return Q({type:"error",message:"Tunnel process stopped unexpectedly."}),H(!1),B(""),!1}}catch{}}return Q({type:"error",message:"Tunnel created but not reachable. Please try again."}),H(!1),B(""),!1},e5=async()=>{X(!1),H(!0),Q(null),B("Creating tunnel...");let e=!0;(async()=>{for(;e;){try{let t=await fetch("/api/tunnel/status");if(t.ok){let s=await t.json();s.download?.downloading?B(`Downloading cloudflared... ${s.download.progress}%`):e&&B("Creating tunnel...")}}catch{}await new Promise(e=>setTimeout(e,1e3))}})();try{let t=await fetch("/api/tunnel/enable",{method:"POST"});e=!1;let s=await t.json();if(!t.ok)return void Q({type:"error",message:s.error||"Failed to enable tunnel"});let a=s.tunnelUrl;if(!a)return void Q({type:"error",message:"No tunnel URL returned"});L(a),z(s.publicUrl||""),await e1(s.publicUrl,a)}catch(e){Q({type:"error",message:e.message})}finally{e=!1,H(!1),B("")}},e2=async()=>{H(!0),Q(null);try{let e=await fetch("/api/tunnel/disable",{method:"POST"}),t=await e.json();e.ok?(F(!1),L(""),Y(!1),Q({type:"success",message:"Tunnel disabled"})):Q({type:"error",message:t.error||"Failed to disable tunnel"})}catch(e){Q({type:"error",message:e.message})}finally{H(!1)}},e4=async()=>{eb(null);try{let e=await fetch("/api/tunnel/tailscale-check");if(e.ok){let t=await e.json();return eb(t.installed),t}}catch{}return eb(!1),{installed:!1}},e3=async()=>{ef(!0),em(null),ek([]);try{let e=await fetch("/api/tunnel/tailscale-install",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sudoPassword:ev})});ew("");let t=e.body.getReader(),s=new TextDecoder,a="";for(;;){let{done:e,value:l}=await t.read();if(e)break;let n=(a+=s.decode(l,{stream:!0})).split("\n\n");for(let e of(a=n.pop()||"",n)){let t=e.split("\n"),s="progress",a=null;for(let e of t)if(e.startsWith("event: ")&&(s=e.slice(7).trim()),e.startsWith("data: "))try{a=JSON.parse(e.slice(6))}catch{}if(a)if("progress"===s)ek(e=>[...e.slice(-50),a.message]);else if("done"===s){eb(!0),ef(!1),eT(!1),e7();return}else"error"===s&&em({type:"error",message:a.error||"Install failed"})}}}catch(e){em({type:"error",message:e.message})}finally{ef(!1)}},e8=async e=>{ec("Waiting for Tailscale ready...");let t=`${e}/api/health`,s=Date.now();for(;Date.now()-s<3e5;){await new Promise(e=>setTimeout(e,2e3));try{let e=await fetch(t,{mode:"no-cors",cache:"no-store"});if(e.ok||"opaque"===e.type)return!0}catch{}}return!1},e6=(e,t)=>{ex(e),ep(t)},e9=()=>{ex(""),ep("")},e7=async()=>{eT(!1),eC(!0),ei(!0),em(null),ec("Connecting..."),e9();try{let e=await fetch("/api/tunnel/tailscale-enable",{method:"POST"}),t=await e.json();if(e.ok&&t.success){en(t.tunnelUrl||"");let e=await e8(t.tunnelUrl);et(!0),em(e?null:{type:"warning",message:"Connected but not reachable yet."});return}if(t.needsLogin&&t.authUrl){e6(t.authUrl,"Open Login Page"),ec('Login required — click "Open Login Page" to continue');for(let e=0;e<40;e++){await new Promise(e=>setTimeout(e,3e3));try{let e=await fetch("/api/tunnel/tailscale-check");if(e.ok&&(await e.json()).loggedIn){e9(),ec("Starting funnel...");let e=await fetch("/api/tunnel/tailscale-enable",{method:"POST"}),t=await e.json();if(e.ok&&t.success){en(t.tunnelUrl||"");let e=await e8(t.tunnelUrl);et(!0),em(e?null:{type:"warning",message:"Connected but not reachable yet."})}else t.funnelNotEnabled&&t.enableUrl?await te(t.enableUrl):em({type:"error",message:t.error||"Failed to start funnel"});return}}catch{}}e9(),em({type:"error",message:"Login timed out. Please try again."});return}if(t.funnelNotEnabled&&t.enableUrl)return void await te(t.enableUrl);em({type:"error",message:t.error||"Failed to connect"})}catch(e){em({type:"error",message:e.message})}finally{ei(!1),eC(!1),ec(""),e9()}},te=async e=>{e6(e,"Open Funnel Settings"),ec('Click "Open Funnel Settings" to enable Funnel...');for(let e=0;e<40;e++){await new Promise(e=>setTimeout(e,3e3));try{let e=await fetch("/api/tunnel/tailscale-enable",{method:"POST"}),t=await e.json();if(e.ok&&t.success){e9(),en(t.tunnelUrl||"");let e=await e8(t.tunnelUrl);et(!0),em(e?null:{type:"warning",message:"Connected but not reachable yet."});return}if(t.funnelNotEnabled)continue;if(t.error){e9(),em({type:"error",message:t.error});return}}catch{}}e9(),em({type:"error",message:"Timed out waiting for Funnel to be enabled."})},tt=async()=>{ei(!0),em(null);try{let e=await fetch("/api/tunnel/tailscale-disable",{method:"POST"}),t=await e.json();e.ok?(et(!1),en(""),e_(!1),em({type:"success",message:"Tailscale disabled"})):em({type:"error",message:t.error||"Failed to disable Tailscale"})}catch(e){em({type:"error",message:e.message})}finally{ei(!1)}},ts=async()=>{em(null),ek([]);let e=await e4();e?.installed&&e?.hasCachedPassword?e7():eT(!0)},ta=async()=>{if(j.trim())try{let e=await fetch("/api/keys",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:j})}),t=await e.json();e.ok&&(w(t.key),await e0(),k(""),f(!1))}catch(e){console.log("Error creating key:",e)}},tl=async e=>{C({title:"Delete API Key",message:"Delete this API key?",onConfirm:async()=>{C(null);try{(await fetch(`/api/keys/${e}`,{method:"DELETE"})).ok&&(s(t.filter(t=>t.id!==e)),eK(t=>{let s=new Set(t);return s.delete(e),s}))}catch(e){console.log("Error deleting key:",e)}}})},tn=async(e,t)=>{try{(await fetch(`/api/keys/${e}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({isActive:t})})).ok&&s(s=>s.map(s=>s.id===e?{...s,isActive:t}:s))}catch(e){console.log("Error toggling key:",e)}},[tr,ti]=(0,l.useState)("/v1");return((0,l.useEffect)(()=>{ti(`${window.location.origin}/v1`)},[]),n)?(0,a.jsxs)("div",{className:"flex flex-col gap-8",children:[(0,a.jsx)(c.Qv,{}),(0,a.jsx)(c.Qv,{})]}):(0,a.jsxs)("div",{className:"flex flex-col gap-8",children:[(0,a.jsxs)(c.Zp,{children:[(0,a.jsxs)("h2",{className:"text-lg font-semibold mb-4 flex items-center gap-2",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-primary",children:"api"}),"API Endpoint"]}),(0,a.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,a.jsx)(p,{label:"Local",url:tr,copyId:"local_url",copied:eH,onCopy:eZ}),(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("span",{className:`text-xs font-mono px-1.5 py-0.5 rounded shrink-0 min-w-[88px] text-center ${D?"bg-primary/10 text-primary":"bg-surface-2 text-text-muted"}`,children:"Tunnel"}),D&&!J&&R?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(c.pd,{value:`${K||W}/v1`,readOnly:!0,className:"flex-1 font-mono text-sm"}),(0,a.jsx)("button",{onClick:()=>eZ(`${K||W}/v1`,"tunnel_url"),className:"p-2 hover:bg-black/5 dark:hover:bg-white/5 rounded text-text-muted hover:text-primary transition-colors shrink-0",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:"tunnel_url"===eH?"check":"content_copy"})}),(0,a.jsx)("button",{onClick:()=>Y(!0),className:"p-2 hover:bg-red-500/10 rounded text-red-500 transition-colors shrink-0",title:"Disable Tunnel",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:"power_settings_new"})})]}):!D||J||R?J?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{className:"flex-1 flex items-center gap-2 px-3 py-1.5 rounded border border-border bg-input text-sm text-text-muted",children:[(0,a.jsx)("span",{className:"material-symbols-outlined animate-spin text-sm",children:"progress_activity"}),Z||"Creating tunnel..."]}),(0,a.jsx)("button",{onClick:()=>{H(!1),B("")},className:"p-2 hover:bg-red-500/10 rounded text-red-500 transition-colors shrink-0",title:"Stop",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:"power_settings_new"})})]}):M?.type==="error"?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{className:"flex-1 flex items-center gap-2 px-3 py-1.5 rounded border border-red-300 dark:border-red-800 bg-red-500/5 text-sm text-red-600 dark:text-red-400",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-sm",children:"error"}),M.message]}),(0,a.jsx)(c.$n,{size:"sm",icon:"cloud_upload",onClick:()=>X(!0),children:"Enable"})]}):O?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{className:"flex-1 flex items-center gap-2 px-3 py-1.5 rounded border border-border bg-input text-sm text-text-muted",children:[(0,a.jsx)("span",{className:"material-symbols-outlined animate-spin text-sm",children:"progress_activity"}),"Checking..."]}),(0,a.jsx)("button",{onClick:()=>U(!1),className:"p-2 hover:bg-red-500/10 rounded text-red-500 transition-colors shrink-0",title:"Stop",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:"power_settings_new"})})]}):(0,a.jsx)(c.$n,{size:"sm",icon:"cloud_upload",onClick:()=>{eB?Q({type:"error",message:`Security required: ${eM}`}):S?X(!0):Q({type:"error",message:'Security required: Enable "Require API key" before activating the tunnel.'})},children:"Enable"}):(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{className:"flex-1 flex items-center gap-2 px-3 py-1.5 rounded border border-amber-300 dark:border-amber-800 bg-amber-500/5 text-sm text-amber-600 dark:text-amber-400",children:[(0,a.jsx)("span",{className:"material-symbols-outlined animate-spin text-sm",children:"progress_activity"}),eF?"Tunnel reconnecting...":"Tunnel checking..."]}),(0,a.jsx)("button",{onClick:()=>Y(!0),className:"p-2 hover:bg-red-500/10 rounded text-red-500 transition-colors shrink-0",title:"Disable Tunnel",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:"power_settings_new"})})]})]}),(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("span",{className:`text-xs font-mono px-1.5 py-0.5 rounded shrink-0 min-w-[88px] text-center ${ee?"bg-primary/10 text-primary":"bg-surface-2 text-text-muted"}`,children:"Tailscale"}),ee&&!er&&es?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(c.pd,{value:`${el}/v1`,readOnly:!0,className:"flex-1 font-mono text-sm"}),(0,a.jsx)("button",{onClick:()=>eZ(`${el}/v1`,"ts_url"),className:"p-2 hover:bg-black/5 dark:hover:bg-white/5 rounded text-text-muted hover:text-primary transition-colors shrink-0",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:"ts_url"===eH?"check":"content_copy"})}),(0,a.jsx)("button",{onClick:()=>e_(!0),className:"p-2 hover:bg-red-500/10 rounded text-red-500 transition-colors shrink-0",title:"Disable Tailscale",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:"power_settings_new"})})]}):!ee||er||es?er||eN?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{className:"flex-1 flex items-center gap-2 px-3 py-1.5 rounded border border-border bg-input text-sm text-text-muted",children:[(0,a.jsx)("span",{className:"material-symbols-outlined animate-spin text-sm",children:"progress_activity"}),eo||"Connecting..."]}),eu&&(0,a.jsx)(c.$n,{size:"sm",icon:"open_in_new",onClick:()=>window.open(eu,"tailscale_auth","width=600,height=700,noopener,noreferrer"),children:eh||"Open"}),(0,a.jsx)("button",{onClick:()=>{ei(!1),eC(!1),ec(""),e9()},className:"p-2 hover:bg-red-500/10 rounded text-red-500 transition-colors shrink-0",title:"Stop",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:"power_settings_new"})})]}):ed?.type==="error"?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{className:"flex-1 flex items-center gap-2 px-3 py-1.5 rounded border border-red-300 dark:border-red-800 bg-red-500/5 text-sm text-red-600 dark:text-red-400",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-sm",children:"error"}),ed.message]}),(0,a.jsx)(c.$n,{size:"sm",icon:"vpn_lock",onClick:ts,children:"Enable"})]}):(0,a.jsx)(c.$n,{size:"sm",icon:"vpn_lock",onClick:()=>{eB?em({type:"error",message:`Security required: ${eM}`}):ts()},className:"bg-linear-to-r from-indigo-500 to-purple-500 hover:from-indigo-600 hover:to-purple-600 text-white!",children:"Enable"}):(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{className:"flex-1 flex items-center gap-2 px-3 py-1.5 rounded border border-amber-300 dark:border-amber-800 bg-amber-500/5 text-sm text-amber-600 dark:text-amber-400",children:[(0,a.jsx)("span",{className:"material-symbols-outlined animate-spin text-sm",children:"progress_activity"}),eq?"Tailscale reconnecting...":"Tailscale checking..."]}),(0,a.jsx)("button",{onClick:()=>e_(!0),className:"p-2 hover:bg-red-500/10 rounded text-red-500 transition-colors shrink-0",title:"Disable Tailscale",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:"power_settings_new"})})]})]})]}),eB&&!D&&!ee&&(0,a.jsx)("div",{className:"mt-4",children:(0,a.jsx)(g,{message:eM,action:{label:"Open settings",href:"/dashboard/profile"}})}),(D||ee)&&(0,a.jsxs)("div",{className:"mt-4 flex flex-col gap-2",children:[!S&&(0,a.jsx)(g,{message:"Require API key is disabled — your endpoint is publicly accessible without authentication.",action:{label:"Enable",href:"#require-api-key"}}),(!P||!E)&&(0,a.jsx)(g,{message:P?"Dashboard uses the default password — change it in Profile settings.":"Require login is disabled — anyone can access your dashboard via tunnel.",action:{label:P?"Change password":"Enable",href:"/dashboard/profile"}})]}),(D||ee)&&(0,a.jsxs)("div",{className:"mt-4 pt-4 border-t border-border flex items-center gap-3",children:[(0,a.jsx)(c.lM,{checked:A,onChange:()=>eG(!A)}),(0,a.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,a.jsx)("p",{className:"font-medium text-sm",children:"Allow dashboard access via tunnel"}),(0,a.jsx)(b,{text:"When enabled, the dashboard can be accessed through your tunnel or Tailscale URL (login still required). When disabled, dashboard access via tunnel/Tailscale is completely blocked."})]})]})]}),(0,a.jsx)(c.Zp,{id:"rtk",children:(0,a.jsxs)("div",{className:"flex items-center justify-between gap-4",children:[(0,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsxs)("h2",{className:"text-lg font-semibold flex items-center gap-2",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-primary",children:"bolt"}),"Token Saver"]}),(0,a.jsx)("p",{className:"text-sm text-text-muted mt-1",children:"RTK, Caveman, Ponytail, Headroom, and PXPIPE live on the Token Saver page."})]}),(0,a.jsxs)(o(),{href:"/dashboard/token-saver",className:"shrink-0 inline-flex items-center gap-1.5 rounded-lg border border-border px-3 py-2 text-sm font-medium text-text-main hover:border-primary/40 hover:text-primary transition-colors",children:["Open",(0,a.jsx)("span",{className:"material-symbols-outlined text-[16px]",children:"arrow_forward"})]})]})}),(0,a.jsxs)(c.Zp,{id:"require-api-key",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between mb-4",children:[(0,a.jsxs)("h2",{className:"text-lg font-semibold flex items-center gap-2",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-primary",children:"vpn_key"}),"API Keys"]}),(0,a.jsx)(c.$n,{icon:"add",onClick:()=>f(!0),children:"Create Key"})]}),(0,a.jsxs)("div",{className:"flex items-center justify-between pb-4 mb-4 border-b border-border",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("p",{className:"font-medium",children:"Require API key"}),(0,a.jsx)("p",{className:"text-sm text-text-muted",children:"Requests without a valid key will be rejected"})]}),(0,a.jsx)(c.lM,{checked:S,onChange:()=>eY(!S)})]}),ez&&!S&&(0,a.jsx)("div",{className:"mb-4 -mt-2",children:(0,a.jsx)(g,{message:"Endpoint is exposed without an API key."})}),0===t.length?(0,a.jsxs)("div",{className:"text-center py-12",children:[(0,a.jsx)("div",{className:"inline-flex items-center justify-center w-16 h-16 rounded-full bg-primary/10 text-primary mb-4",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[32px]",children:"vpn_key"})}),(0,a.jsx)("p",{className:"text-text-main font-medium mb-1",children:"No API keys yet"}),(0,a.jsx)("p",{className:"text-sm text-text-muted mb-4",children:"Create your first API key to get started"}),(0,a.jsx)(c.$n,{icon:"add",onClick:()=>f(!0),children:"Create Key"})]}):(0,a.jsx)("div",{className:"flex flex-col",children:t.map(e=>{var t;return(0,a.jsxs)("div",{className:`group flex items-center justify-between py-3 border-b border-black/[0.03] dark:border-white/[0.03] last:border-b-0 ${!1===e.isActive?"opacity-60":""}`,children:[(0,a.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,a.jsx)("p",{className:"text-sm font-medium",children:e.name}),(0,a.jsxs)("div",{className:"flex items-center gap-2 mt-1",children:[(0,a.jsx)("code",{className:"text-xs text-text-muted font-mono",children:eL.has(e.id)?e.key:(t=e.key)?t.length>8?t.slice(0,8)+"...":t:""}),(0,a.jsx)("button",{onClick:()=>{var t;return t=e.id,void eK(e=>{let s=new Set(e);return s.has(t)?s.delete(t):s.add(t),s})},className:"p-1 hover:bg-black/5 dark:hover:bg-white/5 rounded text-text-muted hover:text-primary opacity-100 sm:opacity-0 sm:group-hover:opacity-100 transition-all",title:eL.has(e.id)?"Hide key":"Show key",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:eL.has(e.id)?"visibility_off":"visibility"})}),(0,a.jsx)("button",{onClick:()=>eZ(e.key,e.id),className:"p-1 hover:bg-black/5 dark:hover:bg-white/5 rounded text-text-muted hover:text-primary opacity-100 sm:opacity-0 sm:group-hover:opacity-100 transition-all",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:eH===e.id?"check":"content_copy"})})]}),(0,a.jsxs)("p",{className:"text-xs text-text-muted mt-1",children:["Created ",new Date(e.createdAt).toLocaleDateString()]}),!1===e.isActive&&(0,a.jsx)("p",{className:"text-xs text-orange-500 mt-1",children:"Paused"})]}),(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)(c.lM,{size:"sm",checked:e.isActive??!0,onChange:t=>{e.isActive&&!t?C({title:"Pause API Key",message:`Pause API key "${e.name}"?
2
+
3
+ This key will stop working immediately but can be resumed later.`,onConfirm:async()=>{C(null),tn(e.id,t)}}):tn(e.id,t)},title:e.isActive?"Pause key":"Resume key"}),(0,a.jsx)("button",{onClick:()=>tl(e.id),className:"p-2 hover:bg-red-500/10 rounded text-red-500 opacity-100 sm:opacity-0 sm:group-hover:opacity-100 transition-all",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:"delete"})})]})]},e.id)})})]}),(0,a.jsx)(c.aF,{isOpen:i,title:"Create API Key",onClose:()=>{f(!1),k("")},children:(0,a.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,a.jsx)(c.pd,{label:"Key Name",value:j,onChange:e=>k(e.target.value),placeholder:"Production Key"}),(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsx)(c.$n,{onClick:ta,fullWidth:!0,disabled:!j.trim(),children:"Create"}),(0,a.jsx)(c.$n,{onClick:()=>{f(!1),k("")},variant:"ghost",fullWidth:!0,children:"Cancel"})]})]})}),(0,a.jsx)(c.aF,{isOpen:!!v,title:"API Key Created",onClose:()=>w(null),children:(0,a.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,a.jsxs)("div",{className:"bg-yellow-50 dark:bg-yellow-900/20 border border-yellow-200 dark:border-yellow-800 rounded-lg p-4",children:[(0,a.jsx)("p",{className:"text-sm text-yellow-800 dark:text-yellow-200 mb-2 font-medium",children:"Save this key now!"}),(0,a.jsx)("p",{className:"text-sm text-yellow-700 dark:text-yellow-300",children:"This is the only time you will see this key. Store it securely."})]}),(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsx)(c.pd,{value:v||"",readOnly:!0,className:"flex-1 font-mono text-sm"}),(0,a.jsx)(c.$n,{variant:"secondary",icon:"created_key"===eH?"check":"content_copy",onClick:()=>eZ(v,"created_key"),children:"created_key"===eH?"Copied!":"Copy"})]}),(0,a.jsx)(c.$n,{onClick:()=>w(null),fullWidth:!0,children:"Done"})]})}),(0,a.jsx)(c.aF,{isOpen:V,title:"Enable Tunnel",onClose:()=>X(!1),children:(0,a.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,a.jsx)("div",{className:"bg-surface-2 border border-border-subtle rounded-lg p-4",children:(0,a.jsxs)("div",{className:"flex items-start gap-3",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-primary",children:"cloud_upload"}),(0,a.jsxs)("div",{children:[(0,a.jsx)("p",{className:"text-sm text-text-main font-medium mb-1",children:"Cloudflare Tunnel"}),(0,a.jsx)("p",{className:"text-sm text-text-muted",children:"Expose your local ZevaiRouter to the internet. No port forwarding, no static IP needed. Share endpoint URL with your team or use it in Cursor, Cline, and other AI tools from anywhere."})]})]})}),(0,a.jsx)("div",{className:"grid grid-cols-2 gap-3",children:m.map(e=>(0,a.jsxs)("div",{className:"flex flex-col items-center text-center p-3 rounded-lg bg-sidebar/50",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-xl text-primary mb-1",children:e.icon}),(0,a.jsx)("p",{className:"text-xs font-semibold",children:e.title}),(0,a.jsx)("p",{className:"text-xs text-text-muted",children:e.desc})]},e.title))}),(0,a.jsx)("p",{className:"text-xs text-text-muted",children:"Requires outbound port 7844 (TCP/UDP). Connection may take 10-30s."}),(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsx)(c.$n,{onClick:e5,fullWidth:!0,children:"Start Tunnel"}),(0,a.jsx)(c.$n,{onClick:()=>X(!1),variant:"ghost",fullWidth:!0,children:"Cancel"})]})]})}),(0,a.jsx)(c.aF,{isOpen:G,title:"Disable Tunnel",onClose:()=>!J&&Y(!1),children:(0,a.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,a.jsx)("p",{className:"text-sm text-text-muted",children:"The Cloudflare tunnel will be disconnected. Remote access via tunnel URL will stop working."}),(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsx)(c.$n,{onClick:e2,fullWidth:!0,disabled:J,variant:"danger",children:J?"Disabling...":"Disable"}),(0,a.jsx)(c.$n,{onClick:()=>Y(!1),variant:"ghost",fullWidth:!0,disabled:J,children:"Cancel"})]})]})}),(0,a.jsx)(c.aF,{isOpen:eS,title:"Tailscale Funnel",onClose:()=>{eg||(eT(!1),ew(""),em(null))},children:(0,a.jsxs)("div",{className:"flex flex-col gap-4",children:[null===ey&&(0,a.jsxs)("p",{className:"text-sm text-text-muted flex items-center gap-2",children:[(0,a.jsx)("span",{className:"material-symbols-outlined animate-spin text-sm",children:"progress_activity"}),"Checking..."]}),!1===ey&&!eg&&(0,a.jsxs)("div",{className:"flex flex-col gap-3",children:[(0,a.jsx)("p",{className:"text-sm text-text-muted",children:"Tailscale is not installed. Install it to enable Funnel."}),(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsx)(c.$n,{onClick:e3,fullWidth:!0,children:"Install Tailscale"}),(0,a.jsx)(c.$n,{onClick:()=>eT(!1),variant:"ghost",fullWidth:!0,children:"Cancel"})]})]}),eg&&(0,a.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2 text-sm text-text-muted",children:[(0,a.jsx)("span",{className:"material-symbols-outlined animate-spin text-sm",children:"progress_activity"}),"Installing Tailscale..."]}),ej.length>0&&(0,a.jsx)("div",{ref:eE,className:"bg-black/5 dark:bg-white/5 rounded p-2 max-h-40 overflow-y-auto font-mono text-xs text-text-muted",children:ej.map((e,t)=>(0,a.jsx)("div",{children:e},t))})]}),!0===ey&&!eg&&(0,a.jsxs)("div",{className:"flex flex-col gap-3",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2 text-sm text-green-600 dark:text-green-400",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[16px]",children:"check_circle"}),"Tailscale installed"]}),(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsx)(c.$n,{onClick:()=>e7(),fullWidth:!0,children:"Connect"}),(0,a.jsx)(c.$n,{onClick:()=>eT(!1),variant:"ghost",fullWidth:!0,children:"Cancel"})]})]}),ed&&(0,a.jsx)(y,{status:ed})]})}),(0,a.jsx)(c.aF,{isOpen:eP,title:"Disable Tailscale",onClose:()=>!er&&e_(!1),children:(0,a.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,a.jsx)("p",{className:"text-sm text-text-muted",children:"Tailscale Funnel will be stopped. Remote access via Tailscale URL will stop working."}),(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsx)(c.$n,{onClick:tt,fullWidth:!0,disabled:er,variant:"danger",children:er?"Disabling...":"Disable"}),(0,a.jsx)(c.$n,{onClick:()=>e_(!1),variant:"ghost",fullWidth:!0,disabled:er,children:"Cancel"})]})]})}),(0,a.jsx)(c.uo,{isOpen:!!N,onClose:()=>C(null),onConfirm:N?.onConfirm,title:N?.title||"Confirm",message:N?.message,variant:"danger"})]})}function p({label:e,url:t,copyId:s,copied:l,onCopy:n,badge:r,actions:i}){return(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("span",{className:`text-xs font-mono px-1.5 py-0.5 rounded shrink-0 min-w-[88px] text-center ${"CF"===r||"TS"===r?"bg-primary/10 text-primary":"bg-surface-2 text-text-muted"}`,children:e}),(0,a.jsx)(c.pd,{value:t,readOnly:!0,className:"flex-1 font-mono text-sm"}),(0,a.jsx)("button",{onClick:()=>n(t,s),className:"p-2 hover:bg-black/5 dark:hover:bg-white/5 rounded text-text-muted hover:text-primary transition-colors shrink-0",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:l===s?"check":"content_copy"})}),i]})}function y({status:e,className:t=""}){return(0,a.jsx)("div",{className:`p-2 rounded text-sm ${t} ${"success"===e.type?"bg-green-500/10 text-green-600 dark:text-green-400":"warning"===e.type?"bg-yellow-500/10 text-yellow-600 dark:text-yellow-400":"info"===e.type?"bg-blue-500/10 text-blue-600 dark:text-blue-400":"bg-red-500/10 text-red-600 dark:text-red-400"}`,children:e.message.split(/(https?:\/\/[^\s]+)/g).map((e,t)=>/^https?:\/\//.test(e)?(0,a.jsx)("a",{href:e,target:"_blank",rel:"noreferrer",className:"underline font-medium",children:e},t):e)})}function b({text:e}){return(0,a.jsxs)("span",{className:"relative group inline-flex items-center",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px] text-text-muted cursor-help",children:"help"}),(0,a.jsx)("span",{className:"pointer-events-none absolute left-5 top-1/2 -translate-y-1/2 z-50 w-64 rounded bg-gray-900 dark:bg-gray-800 text-white text-xs px-2.5 py-1.5 opacity-0 group-hover:opacity-100 transition-opacity shadow-lg",children:e})]})}function g({message:e,action:t}){return(0,a.jsxs)("div",{className:"flex items-center gap-2 px-3 py-2 rounded-lg bg-amber-500/10 border border-amber-500/20 text-amber-700 dark:text-amber-400",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[16px] shrink-0 mt-0.5",children:"warning"}),(0,a.jsx)("p",{className:"text-xs flex-1",children:e}),t&&(0,a.jsx)("a",{href:t.href,className:"text-xs font-medium underline shrink-0 hover:opacity-80",onClick:t.href.startsWith("#")?e=>{e.preventDefault(),document.getElementById(t.href.slice(1))?.scrollIntoView({behavior:"smooth"})}:void 0,children:t.label})]})}h.propTypes={machineId:r().string.isRequired}}}]);
@@ -0,0 +1 @@
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:()=>A});var r=a(95155),s=a(12115),n=a(57250),l=a(42793);function i(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])=>{a.push({name:e,used:t.used||0,total:t.total||0,resetAt:t.resetAt||null,remainingPercentage:t.remainingPercentage,unlimited:!0===t.unlimited})});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,l.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,s=a.modelKey||a.name;return(e.get(r)??999)-(e.get(s)??999)})}return a}function c({quotas:e=[],compact:t=!1,sortMode:a="default",showSortLabel:n=!1}){let[l,o]=(0,s.useState)(1),d=(0,s.useMemo)(()=>e.map((e,t)=>({...e,index:t,remaining:e?.remaining!==void 0?Math.max(0,Math.round(e.remaining)):e?.remainingPercentage!==void 0?Math.round(e.remainingPercentage):i(e?.used,e?.total)})),[e]),u=(0,s.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,s.useEffect)(()=>{o(1)},[a,e]),(0,s.useEffect)(()=>{o(e=>Math.min(e,m))},[m]),!e||0===e.length)return null;let h=u.slice((l-1)*10,10*l),x=0===u.length?0:(l-1)*10+1,b=Math.min(10*l,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":""]}),n&&(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:h.map(e=>{var a;let s=(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"},n=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 s=Math.ceil(r/6e4);if(s<60)return`${s}m`;let n=Math.floor(s/60),l=s%60;if(n<24)return`${n}h ${l}m`;let i=Math.floor(n/24);return`${i}d ${n%24}h ${l}m`}catch(e){return"-"}}(e.resetAt),l=function(e){if(!e)return null;try{let t=new Date(e),a=new Date,r=new Date(a.getFullYear(),a.getMonth(),a.getDate()),s=new Date(r);s.setDate(s.getDate()+1);let n="";n=t>=r&&t<s?"Today":t>=s&&t<new Date(s.getTime()+864e5)?"Tomorrow":t.toLocaleDateString("en-US",{month:"short",day:"numeric"});let l=t.toLocaleTimeString("en-US",{hour:"numeric",minute:"2-digit",hour12:!0});return`${n}, ${l}`}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:s.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 ${s.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 ${s.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.jsxs)("span",{className:"text-text-muted",children:[e.used.toLocaleString()," / ",e.total>0?e.total.toLocaleString():"∞"]}),(0,r.jsxs)("span",{className:`font-medium ${s.text}`,children:[e.remaining,"%"]})]})]})}),(0,r.jsx)("td",{className:`${p} w-[25%]`,children:"-"!==n||l?t?(0,r.jsx)("div",{className:`${f} text-text-primary font-medium truncate`,title:l||"",children:"-"!==n?`in ${n}`:l}):(0,r.jsxs)("div",{className:"space-y-0.5",children:["-"!==n&&(0,r.jsxs)("div",{className:`${f} text-text-primary font-medium`,children:["in ",n]}),l&&(0,r.jsx)("div",{className:`${v} text-text-muted`,children:l})]}):(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 ",x,"-",b," of ",u.length]}),(0,r.jsxs)("span",{children:["Page ",l," / ",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===l,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:l===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),h=a(52679);function x(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 h.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 A(){let[e,t]=(0,s.useState)([]),[a,l]=(0,s.useState)({}),[A,q]=(0,s.useState)({}),[E,P]=(0,s.useState)({}),[M,D]=(0,s.useState)(!0),[O,I]=(0,s.useState)(null),[T,L]=(0,s.useState)(!1),[_,z]=(0,s.useState)(!1),[F,U]=(0,s.useState)(60),[R,J]=(0,s.useState)(!0),[K,B]=(0,s.useState)(null),[Q,W]=(0,s.useState)(null),[G,H]=(0,s.useState)(!1),[Y,V]=(0,s.useState)(null),[X,Z]=(0,s.useState)([]),[ee,et]=(0,s.useState)("all"),[ea,er]=(0,s.useState)([]),[es,en]=(0,s.useState)("single"),[el,ei]=(0,s.useState)("all"),[eo,ec]=(0,s.useState)("default"),[ed,eu]=(0,s.useState)(!1),[em,eh]=(0,s.useState)(!1),[ex,eb]=(0,s.useState)(!1),[ep,eg]=(0,s.useState)({}),[ef,ev]=(0,s.useState)({}),[ey,ek]=(0,s.useState)(1),[ew,ej]=(0,s.useState)(20),[eN,eS]=(0,s.useState)(String(20)),[eC,e$]=(0,s.useState)({page:1,pageSize:20,total:0,totalPages:1}),[eA,eq]=(0,s.useState)({eligibleConnections:0,providerFilteredConnections:0}),eE=(0,s.useRef)(null),eP=(0,s.useRef)(null),eM=(0,s.useCallback)(async(e=ey)=>{try{var a,r;let s=new URLSearchParams({page:String(e),pageSize:String(ew),accountStatus:el,sort:"priority"});"all"!==ee&&s.set("provider",ee);let n=await fetch(`/api/providers/client?${s.toString()}`);if(!n.ok)throw Error("Failed to fetch connections");let l=await n.json(),i=l.connections||[],o=(a=l.pagination,a||{page:1,pageSize:ew,total:0,totalPages:1}),c=function(e,t=0){return e||{eligibleConnections:t,providerFilteredConnections:t}}(l.totals,i.length);return t(i),er(l.providerOptions||[]),e$(o),eq(c),ek((r=l.pagination,r?.page||e)),i}catch(e){return console.error("Error fetching connections:",e),t([]),er([]),e$({page:1,pageSize:ew,total:0,totalPages:1}),eq({eligibleConnections:0,providerFilteredConnections:0}),[]}},[el,ey,ew,ee]),eD=(0,s.useCallback)(async(e,t,a=!1)=>{q(t=>({...t,[e]:!0})),P(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};l(t=>({...t,[e]:r})),w(e,r);return}throw Error(`HTTP ${r.status}: ${a}`)}let s=await r.json();console.log(`[ProviderLimits] Got quota for ${t}:`,s);let n={quotas:o(t,s),plan:s.plan||null,message:s.message||null,raw:s};l(t=>({...t,[e]:n})),w(e,n)}catch(a){console.error(`[ProviderLimits] Error fetching quota for ${t} (${e}):`,a),P(t=>({...t,[e]:a.message||"Failed to fetch quota"}))}finally{q(t=>({...t,[e]:!1}))}},[]),eO=(0,s.useCallback)(async(e,t)=>{await eD(e,t),I(new Date)},[eD]),eI=(0,s.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 s=await r.json(),n=o(e,s);eg(t=>({...t,[e]:{quotas:n,plan:s.plan||null,accountCount:s.accountCount||0,accountsWithQuota:s.accountsWithQuota||0,deadCount:s.deadCount||0}}))}catch(t){console.error(`[ProviderLimits] Aggregate fetch error for ${e}:`,t)}finally{ev(t=>({...t,[e]:!1}))}}},[]),eT=(0,s.useCallback)(async(e,t)=>{if("bulk"===es&&t){await eI(t,!0),I(new Date);return}e?.length&&(q(t=>({...t,...Object.fromEntries(e.map(e=>[e,!0]))})),await Promise.all(e.map(e=>eD(e,t))),I(new Date))},[eD,es,eI]),eL=(0,s.useCallback)(async e=>{if(confirm("Delete this connection?")){B(e);try{if((await fetch(`/api/providers/${e}`,{method:"DELETE"})).ok){l(t=>{let a={...t};return delete a[e],a}),q(t=>{let a={...t};return delete a[e],a}),P(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]),e_=(0,s.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&&(l(e=>({...e})),await v(eM,ey))}catch(e){console.error("Error updating connection status:",e)}finally{W(null)}},[eM,ey]),ez=(0,s.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),h.wb.includes(a)&&await eD(t,a))}catch(e){console.error("Error saving connection:",e)}},[Y,eM,eD]);(0,s.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 eF=(0,s.useCallback)(async()=>{if(!_){z(!0),U(60);try{let e=await eM(ey);q(g(e)),P(t=>f(t,e)),l(t=>f(t,e)),await Promise.all(e.map(e=>eD(e.id,e.provider,!0))),"bulk"===es&&("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{z(!1)}}},[_,eM,eD,ey,es,ee,ea,eI]);(0,s.useEffect)(()=>{(async()=>{J(!0);let e=await eM(ey);J(!1),q(g(e)),P(t=>f(t,e)),l(t=>f(t,e)),await Promise.all(e.map(e=>eD(e.id,e.provider))),I(new Date)})()},[eM,eD,ey]),(0,s.useEffect)(()=>{"bulk"!==es||("all"!==ee?[ee]:ea.map(e=>e.value||e).filter(e=>"all"!==e)).forEach(e=>eI(e))},[es,ee,ea,eI]),(0,s.useEffect)(()=>{let e=window.localStorage.getItem(j);D(null===e||"true"===e),L(!0)},[]),(0,s.useEffect)(()=>{T&&window.localStorage.setItem(j,String(M))},[M,T]),(0,s.useEffect)(()=>{if(!T||!M){eE.current&&(clearInterval(eE.current),eE.current=null),eP.current&&(clearInterval(eP.current),eP.current=null);return}return eE.current=setInterval(()=>{eF()},6e4),eP.current=setInterval(()=>{U(e=>e<=1?60:e-1)},1e3),()=>{eE.current&&clearInterval(eE.current),eP.current&&clearInterval(eP.current)}},[M,eF,T]),(0,s.useEffect)(()=>{let e=()=>{document.hidden?(eE.current&&(clearInterval(eE.current),eE.current=null),eP.current&&(clearInterval(eP.current),eP.current=null)):M&&T&&(eE.current=setInterval(eF,6e4),eP.current=setInterval(()=>{U(e=>e<=1?60:e-1)},1e3))};return document.addEventListener("visibilitychange",e),()=>{document.removeEventListener("visibilitychange",e)}},[M,eF,T]);let eU=(0,s.useMemo)(()=>(function(e,t,a,r,s){if("codex"===r&&"default"!==s)return[...e].sort((e,a)=>{let r=b(e,t),n=b(a,t),l="remaining-asc"===s?r-n:n-r;return 0!==l?l:(x(e)||"").localeCompare(x(a)||"")});if(!a)return e;let n=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=n(e)-n(t);return 0!==a?a:(e.provider||"").localeCompare(t.provider||"")||(x(e)||"").localeCompare(x(t)||"")})})(e,a,ed,ee,eo),[e,a,ed,ee,eo]),eR=(0,s.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,s){if(!t.length)return null;let n=[],l=[],i=null,o=!1;return t.forEach(e=>{let t=a[e.id];Array.isArray(t?.quotas)&&n.push(...t.quotas),t?.message&&!i&&(i=t.message),s[e.id]&&l.push(s[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};a.used+=Number(e.used)||0,a.total+=Number(e.total)||0,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()]}(n),message:0===n.length&&i||null},isLoading:o,error:!n.length&&l.length>0?l[0]:null,connectionIds:t.map(e=>e.id)}})(e,t,a,A,E)).filter(Boolean)},[eU,a,A,E]),eJ=(0,s.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,s.useMemo)(()=>"bulk"===es?eJ:eU,[es,eJ,eU]),eB=e=>{let t=a[e.id]?.quotas;return!!t?.length&&t.some(e=>!!e.total&&!(e.total<=0)&&5>=i(e.used,e.total))},eQ=(0,s.useCallback)(async(e,t)=>{if(e.length&&!ex){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)}}},[ex,eM,ey]),eW="all"===ee?"All providers":ee,eG=eA.eligibleConnections>0,eH=eK.length>0,eY=eA.eligibleConnections?eA.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"===el?"turned off":"active"===el?"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:()=>eh(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)(n.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:()=>eh(!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"),eh(!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),eh(!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)(n.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:()=>en(e.value),"aria-pressed":es===e.value,className:`flex h-full items-center gap-1.5 px-2 text-xs transition-colors ${es===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:el,onChange:e=>{let t=e.target.value;el!==t&&ek(1),ei(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:ex,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:ex,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:["(",F,"s)"]})]}),(0,r.jsx)("button",{type:"button",onClick:eF,disabled:_,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] ${_?"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,s=t?e.quota:a[e.id],l=t?e.isLoading:A[e.id],i=t?e.error:E[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)(n.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)}),x(e)?(0,r.jsx)("p",{className:"text-xs text-text-muted truncate",children:x(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:l||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 ${l?"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:()=>eL(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=>e_(e.id,t)})})]})]})]})}),(0,r.jsx)("div",{className:"px-2 py-1.5",children:l?(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"})}):i?(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:i})]}):s?.message?(0,r.jsx)("div",{className:"text-center py-5",children:(0,r.jsx)("p",{className:"text-xs text-text-muted",children:s.message})}):(0,r.jsx)(c,{quotas:s?.quotas,compact:!0,sortMode:"default",showSortLabel:"codex"===e.provider&&"default"!==eo})})]},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||_,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||_,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||_,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||_,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:ez,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,4343,1321,5497,8441,3794,7358],()=>e(e.s=5498)),_N_E=e.O()}]);
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zevairouter",
3
- "version": "1.0.40",
3
+ "version": "1.0.42",
4
4
  "description": "ZevaiRouter - AI Router with provider automation, multi-account workflows, and quota tracking",
5
5
  "bin": {
6
6
  "zevai": "./cli/cli.js"
package/cli/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zevairouter-cli",
3
- "version": "1.0.40",
3
+ "version": "1.0.42",
4
4
  "description": "ZevaiRouter CLI - Start and manage ZevaiRouter server",
5
5
  "bin": {
6
6
  "zevai": "./cli.js"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zevairouter",
3
- "version": "1.0.40",
3
+ "version": "1.0.42",
4
4
  "description": "ZevaiRouter - AI Router with provider automation, multi-account workflows, and quota tracking",
5
5
  "bin": {
6
6
  "zevai": "./cli/cli.js"
@@ -2,12 +2,9 @@
2
2
 
3
3
  import { useState, useEffect, useRef, useCallback } from "react";
4
4
  import PropTypes from "prop-types";
5
+ import Link from "next/link";
5
6
  import { Card, Button, Input, Modal, CardSkeleton, Toggle, ConfirmModal } from "@/shared/components";
6
7
  import { useCopyToClipboard } from "@/shared/hooks/useCopyToClipboard";
7
- import { getCurrentLocale, onLocaleChange } from "@/i18n/runtime";
8
-
9
- // Locales that unlock wenyan (classical Chinese) caveman levels
10
- const WENYAN_LOCALES = ["zh-CN", "zh-TW"];
11
8
 
12
9
  const TUNNEL_BENEFITS = [
13
10
  { icon: "public", title: "Access Anywhere", desc: "Use your API from any network" },
@@ -53,20 +50,6 @@ async function clientPingAny(...urls) {
53
50
  });
54
51
  }
55
52
 
56
- const CAVEMAN_LEVELS = [
57
- { id: "lite", label: "Lite", desc: "Drop filler, keep grammar" },
58
- { id: "full", label: "Full", desc: "Drop articles, fragments OK" },
59
- { id: "ultra", label: "Ultra", desc: "Telegraphic, max compression" },
60
- { id: "wenyan-lite", label: "文 Lite", desc: "Classical Chinese, light compression", wenyan: true },
61
- { id: "wenyan", label: "文 Full", desc: "Maximum 文言文, 80-90% reduction", wenyan: true },
62
- { id: "wenyan-ultra", label: "文 Ultra", desc: "Extreme classical compression", wenyan: true },
63
- ];
64
-
65
- const PONYTAIL_LEVELS = [
66
- { id: "lite", label: "Lite", desc: "Suggest lazier alternative" },
67
- { id: "full", label: "Full", desc: "Enforce the ladder, shortest diff" },
68
- { id: "ultra", label: "Ultra", desc: "YAGNI extremist, one-liner or bust" },
69
- ];
70
53
  export default function APIPageClient({ machineId }) {
71
54
  const [keys, setKeys] = useState([]);
72
55
  const [loading, setLoading] = useState(true);
@@ -79,12 +62,6 @@ export default function APIPageClient({ machineId }) {
79
62
  const [requireLogin, setRequireLogin] = useState(true);
80
63
  const [hasPassword, setHasPassword] = useState(true);
81
64
  const [tunnelDashboardAccess, setTunnelDashboardAccess] = useState(false);
82
- const [rtkEnabled, setRtkEnabledState] = useState(true);
83
- const [cavemanEnabled, setCavemanEnabled] = useState(false);
84
- const [cavemanLevel, setCavemanLevel] = useState("full");
85
- const [ponytailEnabled, setPonytailEnabled] = useState(false);
86
- const [ponytailLevel, setPonytailLevel] = useState("full");
87
- const [locale, setLocale] = useState("en");
88
65
 
89
66
  // Cloudflare Tunnel state
90
67
  const [tunnelChecking, setTunnelChecking] = useState(true);
@@ -140,26 +117,6 @@ export default function APIPageClient({ machineId }) {
140
117
  setIsRemoteHost(!["localhost", "127.0.0.1", "::1"].includes(window.location.hostname));
141
118
  }, []);
142
119
 
143
- // Track app UI locale to gate wenyan caveman levels
144
- useEffect(() => {
145
- setLocale(getCurrentLocale());
146
- return onLocaleChange(() => setLocale(getCurrentLocale()));
147
- }, []);
148
-
149
- const isWenyanLocale = WENYAN_LOCALES.includes(locale);
150
- const visibleCavemanLevels = isWenyanLocale
151
- ? CAVEMAN_LEVELS
152
- : CAVEMAN_LEVELS.filter((lvl) => !lvl.wenyan);
153
-
154
- // Reset wenyan level to "ultra" when leaving a Chinese locale
155
- useEffect(() => {
156
- const current = CAVEMAN_LEVELS.find((lvl) => lvl.id === cavemanLevel);
157
- if (current?.wenyan && !isWenyanLocale) {
158
- setCavemanLevel("ultra");
159
- patchSetting({ cavemanLevel: "ultra" });
160
- }
161
- }, [isWenyanLocale, cavemanLevel]);
162
-
163
120
  const { copied, copy } = useCopyToClipboard();
164
121
 
165
122
  // Security gate: block remote exposure while dashboard uses default password or login is off.
@@ -280,11 +237,6 @@ export default function APIPageClient({ machineId }) {
280
237
  setRequireLogin(data.requireLogin !== false);
281
238
  setHasPassword(data.hasPassword || false);
282
239
  setTunnelDashboardAccess(data.tunnelDashboardAccess || false);
283
- setRtkEnabledState(data.rtkEnabled !== false);
284
- setCavemanEnabled(!!data.cavemanEnabled);
285
- setCavemanLevel(data.cavemanLevel || "full");
286
- setPonytailEnabled(!!data.ponytailEnabled);
287
- setPonytailLevel(data.ponytailLevel || "full");
288
240
  }
289
241
  if (statusRes.ok) {
290
242
  const data = await statusRes.json();
@@ -334,51 +286,6 @@ export default function APIPageClient({ machineId }) {
334
286
  }
335
287
  };
336
288
 
337
- const handleRtkEnabled = async (value) => {
338
- try {
339
- const res = await fetch("/api/settings", {
340
- method: "PATCH",
341
- headers: { "Content-Type": "application/json" },
342
- body: JSON.stringify({ rtkEnabled: value }),
343
- });
344
- if (res.ok) setRtkEnabledState(value);
345
- } catch (error) {
346
- console.log("Error updating rtkEnabled:", error);
347
- }
348
- };
349
-
350
- const patchSetting = async (patch) => {
351
- try {
352
- await fetch("/api/settings", {
353
- method: "PATCH",
354
- headers: { "Content-Type": "application/json" },
355
- body: JSON.stringify(patch),
356
- });
357
- } catch (error) {
358
- console.log("Error updating setting:", error);
359
- }
360
- };
361
-
362
- const handleCavemanEnabled = (value) => {
363
- setCavemanEnabled(value);
364
- patchSetting({ cavemanEnabled: value });
365
- };
366
-
367
- const handleCavemanLevel = (level) => {
368
- setCavemanLevel(level);
369
- patchSetting({ cavemanLevel: level });
370
- };
371
-
372
- const handlePonytailEnabled = (value) => {
373
- setPonytailEnabled(value);
374
- patchSetting({ ponytailEnabled: value });
375
- };
376
-
377
- const handlePonytailLevel = (level) => {
378
- setPonytailLevel(level);
379
- patchSetting({ ponytailLevel: level });
380
- };
381
-
382
289
  const fetchData = async () => {
383
290
  try {
384
291
  const keysRes = await fetch("/api/keys");
@@ -1074,129 +981,25 @@ export default function APIPageClient({ machineId }) {
1074
981
  )}
1075
982
  </Card>
1076
983
 
1077
- {/* Token Saver (RTK + Caveman) */}
984
+ {/* Token Saver moved to its own page */}
1078
985
  <Card id="rtk">
1079
- <div className="flex items-center justify-between mb-2">
1080
- <h2 className="text-lg font-semibold flex items-center gap-2">
1081
- <span className="material-symbols-outlined text-primary">bolt</span>
1082
- Token Saver
1083
- </h2>
1084
- </div>
1085
- <div className="flex items-center justify-between pt-2 pb-4 border-b border-border gap-4">
1086
- <div className="min-w-0 flex-1">
1087
- <p className="font-medium">
1088
- Compress tool output{" "}
1089
- <a
1090
- href="https://github.com/rtk-ai/rtk"
1091
- target="_blank"
1092
- rel="noreferrer"
1093
- className="text-xs font-normal text-primary underline hover:opacity-80"
1094
- >
1095
- (RTK)
1096
- </a>
1097
- </p>
1098
- <p className="text-sm text-text-muted">
1099
- git/grep/ls/tree/logs → 60-90% fewer input tokens
1100
- </p>
1101
- </div>
1102
- <Toggle
1103
- checked={rtkEnabled}
1104
- onChange={() => handleRtkEnabled(!rtkEnabled)}
1105
- />
1106
- </div>
1107
- <div className="flex items-center justify-between pt-4 gap-4 flex-wrap">
1108
- <div className="min-w-0 flex-1">
1109
- <p className="font-medium">
1110
- Compress LLM output{" "}
1111
- <a
1112
- href="https://github.com/JuliusBrussee/caveman"
1113
- target="_blank"
1114
- rel="noreferrer"
1115
- className="text-xs font-normal text-primary underline hover:opacity-80"
1116
- >
1117
- (Caveman)
1118
- </a>
1119
- </p>
1120
- <p className="text-sm text-text-muted">
1121
- Terse-style system prompt → ~65% fewer output tokens (up to 87%)
986
+ <div className="flex items-center justify-between gap-4">
987
+ <div className="min-w-0">
988
+ <h2 className="text-lg font-semibold flex items-center gap-2">
989
+ <span className="material-symbols-outlined text-primary">bolt</span>
990
+ Token Saver
991
+ </h2>
992
+ <p className="text-sm text-text-muted mt-1">
993
+ RTK, Caveman, Ponytail, Headroom, and PXPIPE live on the Token Saver page.
1122
994
  </p>
1123
995
  </div>
1124
- <div className="flex items-center gap-3 shrink-0">
1125
- {cavemanEnabled && (
1126
- <div className="flex flex-col items-end gap-1">
1127
- <div className="flex items-center gap-1.5">
1128
- {visibleCavemanLevels.map((lvl) => (
1129
- <button
1130
- key={lvl.id}
1131
- onClick={() => handleCavemanLevel(lvl.id)}
1132
- className={`px-3 py-1.5 rounded text-xs font-medium border transition-colors ${
1133
- cavemanLevel === lvl.id
1134
- ? "bg-primary text-white border-primary"
1135
- : "bg-transparent border-border text-text-muted hover:bg-surface-2"
1136
- }`}
1137
- title={lvl.desc}
1138
- >
1139
- {lvl.label}
1140
- </button>
1141
- ))}
1142
- </div>
1143
- <p className="text-xs text-primary">
1144
- {CAVEMAN_LEVELS.find((lvl) => lvl.id === cavemanLevel)?.desc}
1145
- </p>
1146
- </div>
1147
- )}
1148
- <Toggle
1149
- checked={cavemanEnabled}
1150
- onChange={() => handleCavemanEnabled(!cavemanEnabled)}
1151
- />
1152
- </div>
1153
- </div>
1154
- <div className="flex items-center justify-between pt-4 border-t border-border gap-4 flex-wrap">
1155
- <div className="min-w-0 flex-1">
1156
- <p className="font-medium">
1157
- Lazy code style{" "}
1158
- <a
1159
- href="https://github.com/DietrichGebert/ponytail"
1160
- target="_blank"
1161
- rel="noreferrer"
1162
- className="text-xs font-normal text-primary underline hover:opacity-80"
1163
- >
1164
- (Ponytail)
1165
- </a>
1166
- </p>
1167
- <p className="text-sm text-text-muted">
1168
- YAGNI ladder → shortest diff, minimal code
1169
- </p>
1170
- </div>
1171
- <div className="flex items-center gap-3 shrink-0">
1172
- {ponytailEnabled && (
1173
- <div className="flex flex-col items-end gap-1">
1174
- <div className="flex items-center gap-1.5">
1175
- {PONYTAIL_LEVELS.map((lvl) => (
1176
- <button
1177
- key={lvl.id}
1178
- onClick={() => handlePonytailLevel(lvl.id)}
1179
- className={`px-3 py-1.5 rounded text-xs font-medium border transition-colors ${
1180
- ponytailLevel === lvl.id
1181
- ? "bg-primary text-white border-primary"
1182
- : "bg-transparent border-border text-text-muted hover:bg-surface-2"
1183
- }`}
1184
- title={lvl.desc}
1185
- >
1186
- {lvl.label}
1187
- </button>
1188
- ))}
1189
- </div>
1190
- <p className="text-xs text-primary">
1191
- {PONYTAIL_LEVELS.find((lvl) => lvl.id === ponytailLevel)?.desc}
1192
- </p>
1193
- </div>
1194
- )}
1195
- <Toggle
1196
- checked={ponytailEnabled}
1197
- onChange={() => handlePonytailEnabled(!ponytailEnabled)}
1198
- />
1199
- </div>
996
+ <Link
997
+ href="/dashboard/token-saver"
998
+ className="shrink-0 inline-flex items-center gap-1.5 rounded-lg border border-border px-3 py-2 text-sm font-medium text-text-main hover:border-primary/40 hover:text-primary transition-colors"
999
+ >
1000
+ Open
1001
+ <span className="material-symbols-outlined text-[16px]">arrow_forward</span>
1002
+ </Link>
1200
1003
  </div>
1201
1004
  </Card>
1202
1005
 
@@ -224,8 +224,24 @@ export function parseQuotaData(provider, data) {
224
224
  }
225
225
  break;
226
226
 
227
+ case "grok-cli":
228
+ // Grok Build billing: On-demand / Prepaid / Credits with remainingPercentage
229
+ if (data.quotas) {
230
+ Object.entries(data.quotas).forEach(([name, quota]) => {
231
+ normalizedQuotas.push({
232
+ name,
233
+ used: quota.used || 0,
234
+ total: quota.total || 0,
235
+ resetAt: quota.resetAt || null,
236
+ remainingPercentage: quota.remainingPercentage,
237
+ unlimited: quota.unlimited === true,
238
+ });
239
+ });
240
+ }
241
+ break;
242
+
227
243
  default:
228
- // Generic fallback for unknown providers
244
+ // Generic fallback for unknown providers (pass through remaining % when present)
229
245
  if (data.quotas) {
230
246
  Object.entries(data.quotas).forEach(([name, quota]) => {
231
247
  normalizedQuotas.push({
@@ -233,6 +249,10 @@ export function parseQuotaData(provider, data) {
233
249
  used: quota.used || 0,
234
250
  total: quota.total || 0,
235
251
  resetAt: quota.resetAt || null,
252
+ ...(quota.remainingPercentage != null
253
+ ? { remainingPercentage: quota.remainingPercentage }
254
+ : {}),
255
+ ...(quota.unlimited === true ? { unlimited: true } : {}),
236
256
  });
237
257
  });
238
258
  }
@@ -42,10 +42,18 @@ function sanitize(c) {
42
42
  return safe;
43
43
  }
44
44
 
45
+ function normalizeAuthType(authType) {
46
+ const t = String(authType || "").toLowerCase().trim();
47
+ if (t === "api-key" || t === "api_key" || t === "api key") return "apikey";
48
+ return t;
49
+ }
50
+
45
51
  function isUsageEligible(connection) {
46
- return USAGE_SUPPORTED_PROVIDERS.includes(connection.provider) && (
47
- connection.authType === "oauth" || USAGE_APIKEY_PROVIDERS.includes(connection.provider)
48
- );
52
+ if (!USAGE_SUPPORTED_PROVIDERS.includes(connection.provider)) return false;
53
+ const authType = normalizeAuthType(connection.authType);
54
+ // OAuth sessions always eligible; API-key only for known usage providers
55
+ if (authType === "oauth" || authType === "access_token") return true;
56
+ return authType === "apikey" && USAGE_APIKEY_PROVIDERS.includes(connection.provider);
49
57
  }
50
58
 
51
59
  function parsePositiveInt(value, fallback) {
@@ -404,7 +404,7 @@ export function getProvidersByKind(kind) {
404
404
  .sort((a, b) => (a.mediaPriority ?? 100) - (b.mediaPriority ?? 100));
405
405
  }
406
406
 
407
- // Providers that support usage/quota API
407
+ // Providers that support usage/quota API (must match getUsageForProvider cases)
408
408
  export const USAGE_SUPPORTED_PROVIDERS = [
409
409
  "claude",
410
410
  "antigravity",
@@ -422,6 +422,10 @@ export const USAGE_SUPPORTED_PROVIDERS = [
422
422
  "minimax",
423
423
  "minimax-cn",
424
424
  "autoclaw",
425
+ "qwen",
426
+ "iflow",
427
+ // Wave 2: Grok CLI / Grok Build billing
428
+ "grok-cli",
425
429
  ];
426
430
 
427
431
  // Subset that uses apikey auth (still surfaced on quota page)