9router 0.4.12 → 0.4.13

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 (343) hide show
  1. package/app/.next/BUILD_ID +1 -1
  2. package/app/.next/app-path-routes-manifest.json +4 -4
  3. package/app/.next/build-manifest.json +2 -2
  4. package/app/.next/server/app/(dashboard)/dashboard/basic-chat/page.js +1 -1
  5. package/app/.next/server/app/(dashboard)/dashboard/basic-chat/page_client-reference-manifest.js +1 -1
  6. package/app/.next/server/app/(dashboard)/dashboard/cli-tools/page.js +2 -2
  7. package/app/.next/server/app/(dashboard)/dashboard/cli-tools/page.js.nft.json +1 -1
  8. package/app/.next/server/app/(dashboard)/dashboard/cli-tools/page_client-reference-manifest.js +1 -1
  9. package/app/.next/server/app/(dashboard)/dashboard/combos/page.js +2 -2
  10. package/app/.next/server/app/(dashboard)/dashboard/combos/page_client-reference-manifest.js +1 -1
  11. package/app/.next/server/app/(dashboard)/dashboard/console-log/page.js +1 -1
  12. package/app/.next/server/app/(dashboard)/dashboard/console-log/page_client-reference-manifest.js +1 -1
  13. package/app/.next/server/app/(dashboard)/dashboard/endpoint/page.js +1 -1
  14. package/app/.next/server/app/(dashboard)/dashboard/endpoint/page_client-reference-manifest.js +1 -1
  15. package/app/.next/server/app/(dashboard)/dashboard/media-providers/[kind]/[id]/page.js +4 -4
  16. package/app/.next/server/app/(dashboard)/dashboard/media-providers/[kind]/[id]/page_client-reference-manifest.js +1 -1
  17. package/app/.next/server/app/(dashboard)/dashboard/media-providers/[kind]/page.js +1 -1
  18. package/app/.next/server/app/(dashboard)/dashboard/media-providers/[kind]/page_client-reference-manifest.js +1 -1
  19. package/app/.next/server/app/(dashboard)/dashboard/media-providers/web/combo/[id]/page.js +2 -2
  20. package/app/.next/server/app/(dashboard)/dashboard/media-providers/web/combo/[id]/page_client-reference-manifest.js +1 -1
  21. package/app/.next/server/app/(dashboard)/dashboard/media-providers/web/page.js +1 -1
  22. package/app/.next/server/app/(dashboard)/dashboard/media-providers/web/page_client-reference-manifest.js +1 -1
  23. package/app/.next/server/app/(dashboard)/dashboard/mitm/page.js +1 -1
  24. package/app/.next/server/app/(dashboard)/dashboard/mitm/page.js.nft.json +1 -1
  25. package/app/.next/server/app/(dashboard)/dashboard/mitm/page_client-reference-manifest.js +1 -1
  26. package/app/.next/server/app/(dashboard)/dashboard/page.js +1 -1
  27. package/app/.next/server/app/(dashboard)/dashboard/page_client-reference-manifest.js +1 -1
  28. package/app/.next/server/app/(dashboard)/dashboard/profile/page.js +1 -1
  29. package/app/.next/server/app/(dashboard)/dashboard/profile/page_client-reference-manifest.js +1 -1
  30. package/app/.next/server/app/(dashboard)/dashboard/providers/[id]/page.js +1 -1
  31. package/app/.next/server/app/(dashboard)/dashboard/providers/[id]/page_client-reference-manifest.js +1 -1
  32. package/app/.next/server/app/(dashboard)/dashboard/providers/new/page.js +1 -1
  33. package/app/.next/server/app/(dashboard)/dashboard/providers/new/page_client-reference-manifest.js +1 -1
  34. package/app/.next/server/app/(dashboard)/dashboard/providers/page.js +1 -1
  35. package/app/.next/server/app/(dashboard)/dashboard/providers/page_client-reference-manifest.js +1 -1
  36. package/app/.next/server/app/(dashboard)/dashboard/proxy-pools/page.js +1 -1
  37. package/app/.next/server/app/(dashboard)/dashboard/proxy-pools/page_client-reference-manifest.js +1 -1
  38. package/app/.next/server/app/(dashboard)/dashboard/quota/page.js +1 -1
  39. package/app/.next/server/app/(dashboard)/dashboard/quota/page_client-reference-manifest.js +1 -1
  40. package/app/.next/server/app/(dashboard)/dashboard/translator/page.js +1 -1
  41. package/app/.next/server/app/(dashboard)/dashboard/translator/page_client-reference-manifest.js +1 -1
  42. package/app/.next/server/app/(dashboard)/dashboard/usage/page.js +1 -1
  43. package/app/.next/server/app/(dashboard)/dashboard/usage/page_client-reference-manifest.js +1 -1
  44. package/app/.next/server/app/_global-error/page_client-reference-manifest.js +1 -1
  45. package/app/.next/server/app/_global-error.html +1 -1
  46. package/app/.next/server/app/_global-error.rsc +1 -1
  47. package/app/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
  48. package/app/.next/server/app/_global-error.segments/_global-error/__PAGE__.segment.rsc +1 -1
  49. package/app/.next/server/app/_global-error.segments/_global-error.segment.rsc +1 -1
  50. package/app/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
  51. package/app/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
  52. package/app/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  53. package/app/.next/server/app/_not-found/page.js +1 -1
  54. package/app/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
  55. package/app/.next/server/app/_not-found.html +1 -1
  56. package/app/.next/server/app/_not-found.rsc +4 -4
  57. package/app/.next/server/app/_not-found.segments/_full.segment.rsc +4 -4
  58. package/app/.next/server/app/_not-found.segments/_head.segment.rsc +1 -1
  59. package/app/.next/server/app/_not-found.segments/_index.segment.rsc +4 -4
  60. package/app/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +1 -1
  61. package/app/.next/server/app/_not-found.segments/_not-found.segment.rsc +1 -1
  62. package/app/.next/server/app/_not-found.segments/_tree.segment.rsc +2 -2
  63. package/app/.next/server/app/api/cli-tools/antigravity-mitm/route.js +1 -1
  64. package/app/.next/server/app/api/init/route.js +1 -1
  65. package/app/.next/server/app/api/models/route.js +1 -1
  66. package/app/.next/server/app/api/oauth/cursor/import/route.js +1 -1
  67. package/app/.next/server/app/api/providers/[id]/models/route.js +1 -1
  68. package/app/.next/server/app/api/providers/route.js +1 -1
  69. package/app/.next/server/app/api/providers/validate/route.js +1 -1
  70. package/app/.next/server/app/api/translator/console-logs/route.js +1 -1
  71. package/app/.next/server/app/api/translator/console-logs/stream/route.js +4 -4
  72. package/app/.next/server/app/api/translator/translate/route.js +1 -1
  73. package/app/.next/server/app/api/translator/translate/route.js.nft.json +1 -1
  74. package/app/.next/server/app/api/tunnel/disable/route.js +1 -1
  75. package/app/.next/server/app/api/tunnel/enable/route.js +1 -1
  76. package/app/.next/server/app/api/tunnel/status/route.js +1 -1
  77. package/app/.next/server/app/api/tunnel/tailscale-check/route.js +11 -13
  78. package/app/.next/server/app/api/tunnel/tailscale-disable/route.js +1 -1
  79. package/app/.next/server/app/api/tunnel/tailscale-enable/route.js +1 -1
  80. package/app/.next/server/app/api/tunnel/tailscale-login/route.js +11 -13
  81. package/app/.next/server/app/api/usage/[connectionId]/route.js +1 -1
  82. package/app/.next/server/app/api/v1/audio/speech/route.js +1 -1
  83. package/app/.next/server/app/api/v1/images/generations/route.js +2 -2
  84. package/app/.next/server/app/api/v1/images/generations/route.js.nft.json +1 -1
  85. package/app/.next/server/app/api/v1/models/route.js +1 -1
  86. package/app/.next/server/app/api/v1/models/route.js.nft.json +1 -1
  87. package/app/.next/server/app/api/v1/route.js +1 -1
  88. package/app/.next/server/app/api/v1/route.js.nft.json +1 -1
  89. package/app/.next/server/app/api/version/route.js +1 -1
  90. package/app/.next/server/app/api/version/update/route.js +1 -1
  91. package/app/.next/server/app/callback/page.js +1 -1
  92. package/app/.next/server/app/callback/page_client-reference-manifest.js +1 -1
  93. package/app/.next/server/app/callback.html +1 -1
  94. package/app/.next/server/app/callback.rsc +4 -4
  95. package/app/.next/server/app/callback.segments/_full.segment.rsc +4 -4
  96. package/app/.next/server/app/callback.segments/_head.segment.rsc +1 -1
  97. package/app/.next/server/app/callback.segments/_index.segment.rsc +4 -4
  98. package/app/.next/server/app/callback.segments/_tree.segment.rsc +2 -2
  99. package/app/.next/server/app/callback.segments/callback/__PAGE__.segment.rsc +1 -1
  100. package/app/.next/server/app/callback.segments/callback.segment.rsc +1 -1
  101. package/app/.next/server/app/dashboard/basic-chat.html +1 -1
  102. package/app/.next/server/app/dashboard/basic-chat.rsc +6 -6
  103. package/app/.next/server/app/dashboard/basic-chat.segments/!KGRhc2hib2FyZCk/dashboard/basic-chat/__PAGE__.segment.rsc +2 -2
  104. package/app/.next/server/app/dashboard/basic-chat.segments/!KGRhc2hib2FyZCk/dashboard/basic-chat.segment.rsc +1 -1
  105. package/app/.next/server/app/dashboard/basic-chat.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  106. package/app/.next/server/app/dashboard/basic-chat.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  107. package/app/.next/server/app/dashboard/basic-chat.segments/_full.segment.rsc +6 -6
  108. package/app/.next/server/app/dashboard/basic-chat.segments/_head.segment.rsc +1 -1
  109. package/app/.next/server/app/dashboard/basic-chat.segments/_index.segment.rsc +4 -4
  110. package/app/.next/server/app/dashboard/basic-chat.segments/_tree.segment.rsc +2 -2
  111. package/app/.next/server/app/dashboard/cli-tools.html +1 -1
  112. package/app/.next/server/app/dashboard/cli-tools.rsc +6 -6
  113. package/app/.next/server/app/dashboard/cli-tools.segments/!KGRhc2hib2FyZCk/dashboard/cli-tools/__PAGE__.segment.rsc +2 -2
  114. package/app/.next/server/app/dashboard/cli-tools.segments/!KGRhc2hib2FyZCk/dashboard/cli-tools.segment.rsc +1 -1
  115. package/app/.next/server/app/dashboard/cli-tools.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  116. package/app/.next/server/app/dashboard/cli-tools.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  117. package/app/.next/server/app/dashboard/cli-tools.segments/_full.segment.rsc +6 -6
  118. package/app/.next/server/app/dashboard/cli-tools.segments/_head.segment.rsc +1 -1
  119. package/app/.next/server/app/dashboard/cli-tools.segments/_index.segment.rsc +4 -4
  120. package/app/.next/server/app/dashboard/cli-tools.segments/_tree.segment.rsc +2 -2
  121. package/app/.next/server/app/dashboard/combos.html +1 -1
  122. package/app/.next/server/app/dashboard/combos.rsc +6 -6
  123. package/app/.next/server/app/dashboard/combos.segments/!KGRhc2hib2FyZCk/dashboard/combos/__PAGE__.segment.rsc +2 -2
  124. package/app/.next/server/app/dashboard/combos.segments/!KGRhc2hib2FyZCk/dashboard/combos.segment.rsc +1 -1
  125. package/app/.next/server/app/dashboard/combos.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  126. package/app/.next/server/app/dashboard/combos.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  127. package/app/.next/server/app/dashboard/combos.segments/_full.segment.rsc +6 -6
  128. package/app/.next/server/app/dashboard/combos.segments/_head.segment.rsc +1 -1
  129. package/app/.next/server/app/dashboard/combos.segments/_index.segment.rsc +4 -4
  130. package/app/.next/server/app/dashboard/combos.segments/_tree.segment.rsc +2 -2
  131. package/app/.next/server/app/dashboard/endpoint.html +1 -1
  132. package/app/.next/server/app/dashboard/endpoint.rsc +6 -6
  133. package/app/.next/server/app/dashboard/endpoint.segments/!KGRhc2hib2FyZCk/dashboard/endpoint/__PAGE__.segment.rsc +2 -2
  134. package/app/.next/server/app/dashboard/endpoint.segments/!KGRhc2hib2FyZCk/dashboard/endpoint.segment.rsc +1 -1
  135. package/app/.next/server/app/dashboard/endpoint.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  136. package/app/.next/server/app/dashboard/endpoint.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  137. package/app/.next/server/app/dashboard/endpoint.segments/_full.segment.rsc +6 -6
  138. package/app/.next/server/app/dashboard/endpoint.segments/_head.segment.rsc +1 -1
  139. package/app/.next/server/app/dashboard/endpoint.segments/_index.segment.rsc +4 -4
  140. package/app/.next/server/app/dashboard/endpoint.segments/_tree.segment.rsc +2 -2
  141. package/app/.next/server/app/dashboard/media-providers/web.html +1 -1
  142. package/app/.next/server/app/dashboard/media-providers/web.rsc +6 -6
  143. package/app/.next/server/app/dashboard/media-providers/web.segments/!KGRhc2hib2FyZCk/dashboard/media-providers/web/__PAGE__.segment.rsc +2 -2
  144. package/app/.next/server/app/dashboard/media-providers/web.segments/!KGRhc2hib2FyZCk/dashboard/media-providers/web.segment.rsc +1 -1
  145. package/app/.next/server/app/dashboard/media-providers/web.segments/!KGRhc2hib2FyZCk/dashboard/media-providers.segment.rsc +1 -1
  146. package/app/.next/server/app/dashboard/media-providers/web.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  147. package/app/.next/server/app/dashboard/media-providers/web.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  148. package/app/.next/server/app/dashboard/media-providers/web.segments/_full.segment.rsc +6 -6
  149. package/app/.next/server/app/dashboard/media-providers/web.segments/_head.segment.rsc +1 -1
  150. package/app/.next/server/app/dashboard/media-providers/web.segments/_index.segment.rsc +4 -4
  151. package/app/.next/server/app/dashboard/media-providers/web.segments/_tree.segment.rsc +2 -2
  152. package/app/.next/server/app/dashboard/mitm.html +1 -1
  153. package/app/.next/server/app/dashboard/mitm.rsc +6 -6
  154. package/app/.next/server/app/dashboard/mitm.segments/!KGRhc2hib2FyZCk/dashboard/mitm/__PAGE__.segment.rsc +2 -2
  155. package/app/.next/server/app/dashboard/mitm.segments/!KGRhc2hib2FyZCk/dashboard/mitm.segment.rsc +1 -1
  156. package/app/.next/server/app/dashboard/mitm.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  157. package/app/.next/server/app/dashboard/mitm.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  158. package/app/.next/server/app/dashboard/mitm.segments/_full.segment.rsc +6 -6
  159. package/app/.next/server/app/dashboard/mitm.segments/_head.segment.rsc +1 -1
  160. package/app/.next/server/app/dashboard/mitm.segments/_index.segment.rsc +4 -4
  161. package/app/.next/server/app/dashboard/mitm.segments/_tree.segment.rsc +2 -2
  162. package/app/.next/server/app/dashboard/profile.html +1 -1
  163. package/app/.next/server/app/dashboard/profile.rsc +6 -6
  164. package/app/.next/server/app/dashboard/profile.segments/!KGRhc2hib2FyZCk/dashboard/profile/__PAGE__.segment.rsc +2 -2
  165. package/app/.next/server/app/dashboard/profile.segments/!KGRhc2hib2FyZCk/dashboard/profile.segment.rsc +1 -1
  166. package/app/.next/server/app/dashboard/profile.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  167. package/app/.next/server/app/dashboard/profile.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  168. package/app/.next/server/app/dashboard/profile.segments/_full.segment.rsc +6 -6
  169. package/app/.next/server/app/dashboard/profile.segments/_head.segment.rsc +1 -1
  170. package/app/.next/server/app/dashboard/profile.segments/_index.segment.rsc +4 -4
  171. package/app/.next/server/app/dashboard/profile.segments/_tree.segment.rsc +2 -2
  172. package/app/.next/server/app/dashboard/providers/new.html +1 -1
  173. package/app/.next/server/app/dashboard/providers/new.rsc +6 -6
  174. package/app/.next/server/app/dashboard/providers/new.segments/!KGRhc2hib2FyZCk/dashboard/providers/new/__PAGE__.segment.rsc +2 -2
  175. package/app/.next/server/app/dashboard/providers/new.segments/!KGRhc2hib2FyZCk/dashboard/providers/new.segment.rsc +1 -1
  176. package/app/.next/server/app/dashboard/providers/new.segments/!KGRhc2hib2FyZCk/dashboard/providers.segment.rsc +1 -1
  177. package/app/.next/server/app/dashboard/providers/new.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  178. package/app/.next/server/app/dashboard/providers/new.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  179. package/app/.next/server/app/dashboard/providers/new.segments/_full.segment.rsc +6 -6
  180. package/app/.next/server/app/dashboard/providers/new.segments/_head.segment.rsc +1 -1
  181. package/app/.next/server/app/dashboard/providers/new.segments/_index.segment.rsc +4 -4
  182. package/app/.next/server/app/dashboard/providers/new.segments/_tree.segment.rsc +2 -2
  183. package/app/.next/server/app/dashboard/providers.html +1 -1
  184. package/app/.next/server/app/dashboard/providers.rsc +6 -6
  185. package/app/.next/server/app/dashboard/providers.segments/!KGRhc2hib2FyZCk/dashboard/providers/__PAGE__.segment.rsc +2 -2
  186. package/app/.next/server/app/dashboard/providers.segments/!KGRhc2hib2FyZCk/dashboard/providers.segment.rsc +1 -1
  187. package/app/.next/server/app/dashboard/providers.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  188. package/app/.next/server/app/dashboard/providers.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  189. package/app/.next/server/app/dashboard/providers.segments/_full.segment.rsc +6 -6
  190. package/app/.next/server/app/dashboard/providers.segments/_head.segment.rsc +1 -1
  191. package/app/.next/server/app/dashboard/providers.segments/_index.segment.rsc +4 -4
  192. package/app/.next/server/app/dashboard/providers.segments/_tree.segment.rsc +2 -2
  193. package/app/.next/server/app/dashboard/proxy-pools.html +1 -1
  194. package/app/.next/server/app/dashboard/proxy-pools.rsc +6 -6
  195. package/app/.next/server/app/dashboard/proxy-pools.segments/!KGRhc2hib2FyZCk/dashboard/proxy-pools/__PAGE__.segment.rsc +2 -2
  196. package/app/.next/server/app/dashboard/proxy-pools.segments/!KGRhc2hib2FyZCk/dashboard/proxy-pools.segment.rsc +1 -1
  197. package/app/.next/server/app/dashboard/proxy-pools.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  198. package/app/.next/server/app/dashboard/proxy-pools.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  199. package/app/.next/server/app/dashboard/proxy-pools.segments/_full.segment.rsc +6 -6
  200. package/app/.next/server/app/dashboard/proxy-pools.segments/_head.segment.rsc +1 -1
  201. package/app/.next/server/app/dashboard/proxy-pools.segments/_index.segment.rsc +4 -4
  202. package/app/.next/server/app/dashboard/proxy-pools.segments/_tree.segment.rsc +2 -2
  203. package/app/.next/server/app/dashboard/quota.html +2 -2
  204. package/app/.next/server/app/dashboard/quota.rsc +7 -7
  205. package/app/.next/server/app/dashboard/quota.segments/!KGRhc2hib2FyZCk/dashboard/quota/__PAGE__.segment.rsc +3 -3
  206. package/app/.next/server/app/dashboard/quota.segments/!KGRhc2hib2FyZCk/dashboard/quota.segment.rsc +1 -1
  207. package/app/.next/server/app/dashboard/quota.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  208. package/app/.next/server/app/dashboard/quota.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  209. package/app/.next/server/app/dashboard/quota.segments/_full.segment.rsc +7 -7
  210. package/app/.next/server/app/dashboard/quota.segments/_head.segment.rsc +1 -1
  211. package/app/.next/server/app/dashboard/quota.segments/_index.segment.rsc +4 -4
  212. package/app/.next/server/app/dashboard/quota.segments/_tree.segment.rsc +2 -2
  213. package/app/.next/server/app/dashboard/settings/pricing/page.js +1 -1
  214. package/app/.next/server/app/dashboard/settings/pricing/page_client-reference-manifest.js +1 -1
  215. package/app/.next/server/app/dashboard/settings/pricing.html +1 -1
  216. package/app/.next/server/app/dashboard/settings/pricing.rsc +5 -5
  217. package/app/.next/server/app/dashboard/settings/pricing.segments/_full.segment.rsc +5 -5
  218. package/app/.next/server/app/dashboard/settings/pricing.segments/_head.segment.rsc +1 -1
  219. package/app/.next/server/app/dashboard/settings/pricing.segments/_index.segment.rsc +4 -4
  220. package/app/.next/server/app/dashboard/settings/pricing.segments/_tree.segment.rsc +2 -2
  221. package/app/.next/server/app/dashboard/settings/pricing.segments/dashboard/settings/pricing/__PAGE__.segment.rsc +2 -2
  222. package/app/.next/server/app/dashboard/settings/pricing.segments/dashboard/settings/pricing.segment.rsc +1 -1
  223. package/app/.next/server/app/dashboard/settings/pricing.segments/dashboard/settings.segment.rsc +1 -1
  224. package/app/.next/server/app/dashboard/settings/pricing.segments/dashboard.segment.rsc +1 -1
  225. package/app/.next/server/app/dashboard/translator.html +1 -1
  226. package/app/.next/server/app/dashboard/translator.rsc +6 -6
  227. package/app/.next/server/app/dashboard/translator.segments/!KGRhc2hib2FyZCk/dashboard/translator/__PAGE__.segment.rsc +2 -2
  228. package/app/.next/server/app/dashboard/translator.segments/!KGRhc2hib2FyZCk/dashboard/translator.segment.rsc +1 -1
  229. package/app/.next/server/app/dashboard/translator.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  230. package/app/.next/server/app/dashboard/translator.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  231. package/app/.next/server/app/dashboard/translator.segments/_full.segment.rsc +6 -6
  232. package/app/.next/server/app/dashboard/translator.segments/_head.segment.rsc +1 -1
  233. package/app/.next/server/app/dashboard/translator.segments/_index.segment.rsc +4 -4
  234. package/app/.next/server/app/dashboard/translator.segments/_tree.segment.rsc +2 -2
  235. package/app/.next/server/app/dashboard/usage.html +1 -1
  236. package/app/.next/server/app/dashboard/usage.rsc +6 -6
  237. package/app/.next/server/app/dashboard/usage.segments/!KGRhc2hib2FyZCk/dashboard/usage/__PAGE__.segment.rsc +2 -2
  238. package/app/.next/server/app/dashboard/usage.segments/!KGRhc2hib2FyZCk/dashboard/usage.segment.rsc +1 -1
  239. package/app/.next/server/app/dashboard/usage.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  240. package/app/.next/server/app/dashboard/usage.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  241. package/app/.next/server/app/dashboard/usage.segments/_full.segment.rsc +6 -6
  242. package/app/.next/server/app/dashboard/usage.segments/_head.segment.rsc +1 -1
  243. package/app/.next/server/app/dashboard/usage.segments/_index.segment.rsc +4 -4
  244. package/app/.next/server/app/dashboard/usage.segments/_tree.segment.rsc +2 -2
  245. package/app/.next/server/app/dashboard.html +1 -1
  246. package/app/.next/server/app/dashboard.rsc +6 -6
  247. package/app/.next/server/app/dashboard.segments/!KGRhc2hib2FyZCk/dashboard/__PAGE__.segment.rsc +2 -2
  248. package/app/.next/server/app/dashboard.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  249. package/app/.next/server/app/dashboard.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  250. package/app/.next/server/app/dashboard.segments/_full.segment.rsc +6 -6
  251. package/app/.next/server/app/dashboard.segments/_head.segment.rsc +1 -1
  252. package/app/.next/server/app/dashboard.segments/_index.segment.rsc +4 -4
  253. package/app/.next/server/app/dashboard.segments/_tree.segment.rsc +2 -2
  254. package/app/.next/server/app/index.html +1 -1
  255. package/app/.next/server/app/index.rsc +4 -4
  256. package/app/.next/server/app/index.segments/__PAGE__.segment.rsc +1 -1
  257. package/app/.next/server/app/index.segments/_full.segment.rsc +4 -4
  258. package/app/.next/server/app/index.segments/_head.segment.rsc +1 -1
  259. package/app/.next/server/app/index.segments/_index.segment.rsc +4 -4
  260. package/app/.next/server/app/index.segments/_tree.segment.rsc +2 -2
  261. package/app/.next/server/app/landing/page.js +1 -1
  262. package/app/.next/server/app/landing/page_client-reference-manifest.js +1 -1
  263. package/app/.next/server/app/landing.html +1 -1
  264. package/app/.next/server/app/landing.rsc +4 -4
  265. package/app/.next/server/app/landing.segments/_full.segment.rsc +4 -4
  266. package/app/.next/server/app/landing.segments/_head.segment.rsc +1 -1
  267. package/app/.next/server/app/landing.segments/_index.segment.rsc +4 -4
  268. package/app/.next/server/app/landing.segments/_tree.segment.rsc +2 -2
  269. package/app/.next/server/app/landing.segments/landing/__PAGE__.segment.rsc +1 -1
  270. package/app/.next/server/app/landing.segments/landing.segment.rsc +1 -1
  271. package/app/.next/server/app/login/page.js +2 -2
  272. package/app/.next/server/app/login/page_client-reference-manifest.js +1 -1
  273. package/app/.next/server/app/login.html +1 -1
  274. package/app/.next/server/app/login.rsc +5 -5
  275. package/app/.next/server/app/login.segments/_full.segment.rsc +5 -5
  276. package/app/.next/server/app/login.segments/_head.segment.rsc +1 -1
  277. package/app/.next/server/app/login.segments/_index.segment.rsc +4 -4
  278. package/app/.next/server/app/login.segments/_tree.segment.rsc +2 -2
  279. package/app/.next/server/app/login.segments/login/__PAGE__.segment.rsc +2 -2
  280. package/app/.next/server/app/login.segments/login.segment.rsc +1 -1
  281. package/app/.next/server/app/page.js +1 -1
  282. package/app/.next/server/app/page_client-reference-manifest.js +1 -1
  283. package/app/.next/server/app-paths-manifest.json +4 -4
  284. package/app/.next/server/chunks/1574.js +2 -2
  285. package/app/.next/server/chunks/1578.js +1 -1
  286. package/app/.next/server/chunks/2049.js +1 -1
  287. package/app/.next/server/chunks/21.js +1 -1
  288. package/app/.next/server/chunks/2141.js +1 -1
  289. package/app/.next/server/chunks/253.js +1 -1
  290. package/app/.next/server/chunks/2692.js +23 -0
  291. package/app/.next/server/chunks/450.js +2 -2
  292. package/app/.next/server/chunks/5339.js +1 -1
  293. package/app/.next/server/chunks/7770.js +1 -1
  294. package/app/.next/server/chunks/8035.js +1 -1
  295. package/app/.next/server/chunks/8193.js +1 -1
  296. package/app/.next/server/chunks/8202.js +5 -5
  297. package/app/.next/server/chunks/8513.js +13 -15
  298. package/app/.next/server/chunks/8565.js +1 -0
  299. package/app/.next/server/middleware-build-manifest.js +1 -1
  300. package/app/.next/server/middleware.js +1 -1
  301. package/app/.next/server/pages/404.html +1 -1
  302. package/app/.next/server/pages/500.html +1 -1
  303. package/app/.next/static/chunks/3116-cec85bb5f212583f.js +23 -0
  304. package/app/.next/static/chunks/4156-cb6c83e3583f0406.js +7 -0
  305. package/app/.next/static/chunks/505-18fef307aacf3205.js +1 -0
  306. package/app/.next/static/chunks/8035-51e868622e22263b.js +3 -0
  307. package/app/.next/static/chunks/app/(dashboard)/dashboard/cli-tools/page-2709902f127ecc7a.js +1 -0
  308. package/app/.next/static/chunks/app/(dashboard)/dashboard/combos/page-24f203d25ad3f861.js +1 -0
  309. package/app/.next/static/chunks/app/(dashboard)/dashboard/media-providers/[kind]/[id]/page-99e1297a29f0994e.js +53 -0
  310. package/app/.next/static/chunks/app/(dashboard)/dashboard/media-providers/[kind]/page-e95c413c30b592eb.js +1 -0
  311. package/app/.next/static/chunks/app/(dashboard)/dashboard/media-providers/web/combo/[id]/page-8b1737ee82d2cbfa.js +4 -0
  312. package/app/.next/static/chunks/app/(dashboard)/dashboard/media-providers/web/page-c32e5ceca2e291dd.js +1 -0
  313. package/app/.next/static/chunks/app/(dashboard)/dashboard/mitm/page-dc8502d8e3b95e92.js +1 -0
  314. package/app/.next/static/chunks/app/(dashboard)/dashboard/providers/[id]/{page-22e6b2c60c4849ad.js → page-20eb7b59c080e8f7.js} +1 -1
  315. package/app/.next/static/chunks/app/(dashboard)/dashboard/usage/page-92b9dd8c50ab5e50.js +1 -0
  316. package/app/.next/static/chunks/app/dashboard/settings/pricing/page-77a73529baba955b.js +1 -0
  317. package/app/.next/static/chunks/app/login/page-2f45309b2d2ca209.js +1 -0
  318. package/app/.next/static/css/c5a3b7a7aed78240.css +1 -0
  319. package/app/package.json +1 -1
  320. package/app/public/i18n/literals/zh-CN.json +404 -127
  321. package/app/public/providers/cloudflare-ai.png +0 -0
  322. package/app/public/providers/nebius.png +0 -0
  323. package/app/src/mitm/server.js +34 -31
  324. package/cli.js +6 -0
  325. package/package.json +1 -1
  326. package/app/.next/server/chunks/6762.js +0 -23
  327. package/app/.next/static/chunks/4156-3dd571c503014372.js +0 -7
  328. package/app/.next/static/chunks/4380-7f3ec9a5adb060e2.js +0 -23
  329. package/app/.next/static/chunks/505-61eefa51ae7fae57.js +0 -1
  330. package/app/.next/static/chunks/8035-be13431b81f6e555.js +0 -3
  331. package/app/.next/static/chunks/app/(dashboard)/dashboard/cli-tools/page-3d80412b21111041.js +0 -1
  332. package/app/.next/static/chunks/app/(dashboard)/dashboard/combos/page-3390652c042161bf.js +0 -1
  333. package/app/.next/static/chunks/app/(dashboard)/dashboard/media-providers/[kind]/[id]/page-51ab2246cec930f0.js +0 -53
  334. package/app/.next/static/chunks/app/(dashboard)/dashboard/media-providers/[kind]/page-1cd57da85dc9a5a0.js +0 -1
  335. package/app/.next/static/chunks/app/(dashboard)/dashboard/media-providers/web/combo/[id]/page-55f152f000244dfd.js +0 -4
  336. package/app/.next/static/chunks/app/(dashboard)/dashboard/media-providers/web/page-c02c96576b763028.js +0 -1
  337. package/app/.next/static/chunks/app/(dashboard)/dashboard/mitm/page-ef2689a6b468da49.js +0 -1
  338. package/app/.next/static/chunks/app/(dashboard)/dashboard/usage/page-17d9ef16d4d56317.js +0 -1
  339. package/app/.next/static/chunks/app/dashboard/settings/pricing/page-d9a2df5b3f666b3b.js +0 -1
  340. package/app/.next/static/chunks/app/login/page-2424ce8673ecf5cb.js +0 -1
  341. package/app/.next/static/css/06f471e66daf399e.css +0 -1
  342. /package/app/.next/static/{twJQz13yvhkiPdQu-x4vH → 7D6ZXM7R9e5iCcGAVJvY1}/_buildManifest.js +0 -0
  343. /package/app/.next/static/{twJQz13yvhkiPdQu-x4vH → 7D6ZXM7R9e5iCcGAVJvY1}/_ssgManifest.js +0 -0
@@ -1,3 +0,0 @@
1
- (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[8035],{64795:(e,t,s)=>{"use strict";s.d(t,{default:()=>m});var a=s(73365),l=s(1521),r=s(86447),n=s.n(r),i=s(74156),o=s(96459);let c=[{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"}],d=[{id:"lite",label:"Lite",desc:"Drop filler, keep grammar"},{id:"full",label:"Full",desc:"Drop articles, fragments OK"},{id:"ultra",label:"Ultra",desc:"Telegraphic, max compression"}];function m({machineId:e}){let[t,s]=(0,l.useState)([]),[r,n]=(0,l.useState)(!0),[b,g]=(0,l.useState)(!1),[y,f]=(0,l.useState)(""),[j,k]=(0,l.useState)(null),[w,v]=(0,l.useState)(!1),[N,C]=(0,l.useState)(!0),[S,T]=(0,l.useState)(!0),[_,P]=(0,l.useState)(!1),[E,$]=(0,l.useState)(!0),[A,U]=(0,l.useState)(!1),[D,O]=(0,l.useState)("full"),[F,I]=(0,l.useState)(!0),[L,W]=(0,l.useState)(!1),[R,q]=(0,l.useState)(""),[K,J]=(0,l.useState)(""),[M,z]=(0,l.useState)(!1),[H,Z]=(0,l.useState)(""),[B,Q]=(0,l.useState)(null),[V,G]=(0,l.useState)(!1),[X,Y]=(0,l.useState)(!1),[ee,et]=(0,l.useState)(!1),[es,ea]=(0,l.useState)(""),[el,er]=(0,l.useState)(!1),[en,ei]=(0,l.useState)(""),[eo,ec]=(0,l.useState)(null),[ed,em]=(0,l.useState)(null),[ex,eh]=(0,l.useState)(!1),[eu,ep]=(0,l.useState)([]),[eb,eg]=(0,l.useState)(""),[ey,ef]=(0,l.useState)(!1),[ej,ek]=(0,l.useState)(!1),[ew,ev]=(0,l.useState)(!1),eN=(0,l.useRef)(null),[eC,eS]=(0,l.useState)(new Set),{copied:eT,copy:e_}=(0,o.C)();(0,l.useEffect)(()=>{eN.current&&(eN.current.scrollTop=eN.current.scrollHeight)},[eu]),(0,l.useEffect)(()=>{eD(),eP()},[]);let eP=async()=>{I(!0);try{let[e,t]=await Promise.all([fetch("/api/settings"),fetch("/api/tunnel/status")]);if(e.ok){let t=await e.json();v(t.requireApiKey||!1),C(!1!==t.requireLogin),T(t.hasPassword||!1),P(t.tunnelDashboardAccess||!1),$(!1!==t.rtkEnabled),U(!!t.cavemanEnabled),O(t.cavemanLevel||"full")}if(t.ok){let e=await t.json(),s=e.tunnel?.enabled||!1,a=e.tunnel?.tunnelUrl||"",l=e.tunnel?.publicUrl||"";q(a),J(l);let r=e.tailscale?.enabled||!1,n=e.tailscale?.tunnelUrl||"";if(ea(n),r&&n){er(!0),ei("Checking Tailscale...");let e=`${n}/api/health`;try{let t=await fetch(e,{mode:"no-cors",cache:"no-store"});if(t.ok||"opaque"===t.type)et(!0);else{let e=await eR(n);et(e),e||ec({type:"warning",message:"Tailscale not reachable."})}}catch{let e=await eR(n);et(e),e||ec({type:"warning",message:"Tailscale not reachable."})}finally{er(!1),ei("")}}else et(r);if(s&&(l||a)){let e=`${l||a}/api/health`;try{(await fetch(e,{cache:"no-store"})).ok?W(!0):eO(l||a)}catch{eO(l||a)}}else W(s)}}catch(e){console.log("Error loading settings:",e)}finally{I(!1)}},eE=async e=>{try{(await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({tunnelDashboardAccess:e})})).ok&&P(e)}catch(e){console.log("Error updating tunnelDashboardAccess:",e)}},e$=async e=>{try{(await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({requireApiKey:e})})).ok&&v(e)}catch(e){console.log("Error updating requireApiKey:",e)}},eA=async e=>{try{(await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({rtkEnabled:e})})).ok&&$(e)}catch(e){console.log("Error updating rtkEnabled:",e)}},eU=async e=>{try{await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})}catch(e){console.log("Error updating setting:",e)}},eD=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{n(!1)}},eO=async e=>{z(!0),Z("Waiting for tunnel 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 W(!0),z(!1),Z(""),!0}catch{}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."}),z(!1),Z(""),!1}}catch{}}return Q({type:"error",message:"Tunnel created but not reachable. Please try again."}),z(!1),Z(""),!1},eF=async()=>{G(!1),z(!0),Q(null),Z("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?Z(`Downloading cloudflared... ${s.download.progress}%`):e&&Z("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.publicUrl||s.tunnelUrl;if(!a)return void Q({type:"error",message:"No tunnel URL returned"});q(s.tunnelUrl||""),J(s.publicUrl||""),await eO(a)}catch(e){Q({type:"error",message:e.message})}finally{e=!1,z(!1),Z("")}},eI=async()=>{z(!0),Q(null);try{let e=await fetch("/api/tunnel/disable",{method:"POST"}),t=await e.json();e.ok?(W(!1),q(""),J(""),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{z(!1)}},eL=async()=>{em(null);try{let e=await fetch("/api/tunnel/tailscale-check");if(e.ok){let t=await e.json();return em(t.installed),t}}catch{}return em(!1),{installed:!1}},eW=async()=>{eh(!0),ec(null),ep([]);try{let e=await fetch("/api/tunnel/tailscale-install",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sudoPassword:eb})});eg("");let t=e.body.getReader(),s=new TextDecoder,a="";for(;;){let{done:e,value:l}=await t.read();if(e)break;let r=(a+=s.decode(l,{stream:!0})).split("\n\n");for(let e of(a=r.pop()||"",r)){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)ep(e=>[...e.slice(-50),a.message]);else if("done"===s){em(!0),eh(!1);return}else"error"===s&&ec({type:"error",message:a.error||"Install failed"})}}}catch(e){ec({type:"error",message:e.message})}finally{eh(!1)}},eR=async e=>{ei("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},eq=async e=>{let t=e||null;ek(!1),ef(!0),er(!0),ec(null),ei("Connecting...");try{let e=await fetch("/api/tunnel/tailscale-enable",{method:"POST"}),s=await e.json();if(e.ok&&s.success){t&&t.close(),ea(s.tunnelUrl||""),await eR(s.tunnelUrl)?(et(!0),ec(null)):(et(!0),ec({type:"warning",message:"Connected but not reachable yet."}));return}if(s.needsLogin&&s.authUrl){t?t.location.href=s.authUrl:window.open(s.authUrl,"tailscale_auth","width=600,height=700"),ei("Waiting for login...");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){ei("Starting funnel...");let e=await fetch("/api/tunnel/tailscale-enable",{method:"POST"}),s=await e.json();e.ok&&s.success?(t&&t.close(),ea(s.tunnelUrl||""),await eR(s.tunnelUrl)?(et(!0),ec(null)):(et(!0),ec({type:"warning",message:"Connected but not reachable yet."}))):s.funnelNotEnabled&&s.enableUrl?await eK(s.enableUrl,t):ec({type:"error",message:s.error||"Failed to start funnel"});return}}catch{}}ec({type:"error",message:"Login timed out. Please try again."});return}if(s.funnelNotEnabled&&s.enableUrl)return void await eK(s.enableUrl,t);t&&t.close(),ec({type:"error",message:s.error||"Failed to connect"})}catch(e){t&&t.close(),ec({type:"error",message:e.message})}finally{er(!1),ef(!1),ei("")}},eK=async(e,t)=>{t?t.location.href=e:window.open(e,"tailscale_auth","width=600,height=700"),ei("Enable Funnel in browser, waiting...");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"}),s=await e.json();if(e.ok&&s.success){t&&t.close(),ea(s.tunnelUrl||""),await eR(s.tunnelUrl)?(et(!0),ec(null)):(et(!0),ec({type:"warning",message:"Connected but not reachable yet."}));return}if(s.funnelNotEnabled)continue;if(s.error)return void ec({type:"error",message:s.error})}catch{}}ec({type:"error",message:"Timed out waiting for Funnel to be enabled."})},eJ=async()=>{er(!0),ec(null);try{let e=await fetch("/api/tunnel/tailscale-disable",{method:"POST"}),t=await e.json();e.ok?(et(!1),ea(""),ev(!1),ec({type:"success",message:"Tailscale disabled"})):ec({type:"error",message:t.error||"Failed to disable Tailscale"})}catch(e){ec({type:"error",message:e.message})}finally{er(!1)}},eM=async()=>{ec(null),ep([]),ek(!0),await eL()},ez=async()=>{if(y.trim())try{let e=await fetch("/api/keys",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:y})}),t=await e.json();e.ok&&(k(t.key),await eD(),f(""),g(!1))}catch(e){console.log("Error creating key:",e)}},eH=async e=>{if(confirm("Delete this API key?"))try{(await fetch(`/api/keys/${e}`,{method:"DELETE"})).ok&&(s(t.filter(t=>t.id!==e)),eS(t=>{let s=new Set(t);return s.delete(e),s}))}catch(e){console.log("Error deleting key:",e)}},eZ=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)}},[eB,eQ]=(0,l.useState)("/v1");return((0,l.useEffect)(()=>{eQ(`${window.location.origin}/v1`)},[]),r)?(0,a.jsxs)("div",{className:"flex flex-col gap-8",children:[(0,a.jsx)(i.Qv,{}),(0,a.jsx)(i.Qv,{})]}):(0,a.jsxs)("div",{className:"flex flex-col gap-8",children:[(0,a.jsxs)(i.Zp,{children:[(0,a.jsx)("h2",{className:"text-lg font-semibold mb-4",children:"API Endpoint"}),(0,a.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,a.jsx)(x,{label:"Local",url:eB,copyId:"local_url",copied:eT,onCopy:e_}),(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-[68px] text-center ${L?"bg-orange-100 dark:bg-orange-900/30 text-orange-600 dark:text-orange-400":"bg-sidebar text-text-muted"}`,children:"Tunnel"}),L&&!M?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(i.pd,{value:`${K||R}/v1`,readOnly:!0,className:"flex-1 font-mono text-sm"}),(0,a.jsx)("button",{onClick:()=>e_(`${K||R}/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"===eT?"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"})})]}):M?(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"}),H||"Creating tunnel..."]}),(0,a.jsx)("button",{onClick:()=>{z(!1),Z("")},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"})})]}):B?.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"}),B.message]}),(0,a.jsx)(i.$n,{size:"sm",icon:"cloud_upload",onClick:()=>G(!0),children:"Enable"})]}):F?(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:()=>I(!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)(i.$n,{size:"sm",icon:"cloud_upload",onClick:()=>{w?G(!0):Q({type:"error",message:'Security required: Enable "Require API key" before activating the tunnel.'})},className:"bg-linear-to-r from-primary to-blue-500 hover:from-primary-hover hover:to-blue-600 text-white!",children:"Enable"})]}),(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-[68px] text-center ${ee?"bg-purple-100 dark:bg-purple-900/30 text-purple-600 dark:text-purple-400":"bg-sidebar text-text-muted"}`,children:"Tailscale"}),ee&&!el?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(i.pd,{value:`${es}/v1`,readOnly:!0,className:"flex-1 font-mono text-sm"}),(0,a.jsx)("button",{onClick:()=>e_(`${es}/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"===eT?"check":"content_copy"})}),(0,a.jsx)("button",{onClick:()=>ev(!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"})})]}):el||ey?(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"}),en||"Connecting..."]}),(0,a.jsx)("button",{onClick:()=>{er(!1),ef(!1),ei("")},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"})})]}):eo?.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"}),eo.message]}),(0,a.jsx)(i.$n,{size:"sm",icon:"vpn_lock",onClick:eM,children:"Enable"})]}):(0,a.jsx)(i.$n,{size:"sm",icon:"vpn_lock",onClick:eM,className:"bg-linear-to-r from-indigo-500 to-purple-500 hover:from-indigo-600 hover:to-purple-600 text-white!",children:"Enable"})]})]}),(L||ee)&&(0,a.jsxs)("div",{className:"mt-4 flex flex-col gap-2",children:[!w&&(0,a.jsx)(p,{message:"Require API key is disabled — your endpoint is publicly accessible without authentication.",action:{label:"Enable",href:"#require-api-key"}}),(!N||!S)&&(0,a.jsx)(p,{message:N?"Dashboard uses the default password — change it in Profile settings.":"Require login is disabled — anyone can access your dashboard via tunnel.",action:{label:N?"Change password":"Enable",href:"/dashboard/profile"}})]}),(L||ee)&&(0,a.jsxs)("div",{className:"mt-4 pt-4 border-t border-border flex items-center gap-3",children:[(0,a.jsx)(i.lM,{checked:_,onChange:()=>eE(!_)}),(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)(u,{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.jsxs)(i.Zp,{id:"rtk",children:[(0,a.jsx)("div",{className:"flex items-center justify-between mb-2",children:(0,a.jsx)("h2",{className:"text-lg font-semibold",children:"Token Saver"})}),(0,a.jsxs)("div",{className:"flex items-center justify-between pt-2 pb-4 border-b border-border",children:[(0,a.jsxs)("div",{className:"pr-4",children:[(0,a.jsxs)("p",{className:"font-medium",children:["Compress tool output"," ",(0,a.jsx)("a",{href:"https://github.com/rtk-ai/rtk",target:"_blank",rel:"noreferrer",className:"text-xs font-normal text-primary underline hover:opacity-80",children:"(RTK)"})]}),(0,a.jsx)("p",{className:"text-sm text-text-muted",children:"Auto-compress tool output (git diff/grep/ls/tree/logs) before sending to LLM (60-90% fewer input tokens on common dev commands). Disable if you see issues."})]}),(0,a.jsx)(i.lM,{checked:E,onChange:()=>eA(!E)})]}),(0,a.jsxs)("div",{className:"flex items-center justify-between pt-4",children:[(0,a.jsxs)("div",{className:"pr-4",children:[(0,a.jsxs)("p",{className:"font-medium",children:["Compress LLM output"," ",(0,a.jsx)("a",{href:"https://github.com/JuliusBrussee/caveman",target:"_blank",rel:"noreferrer",className:"text-xs font-normal text-primary underline hover:opacity-80",children:"(Caveman)"})]}),(0,a.jsx)("p",{className:"text-sm text-text-muted",children:"Inject a terse-style instruction into the system prompt so the LLM replies shorter (~65% fewer output tokens on average, up to 87%). Code, errors and warnings stay exact."})]}),(0,a.jsx)(i.lM,{checked:A,onChange:()=>{var e;U(e=!A),eU({cavemanEnabled:e})}})]}),A&&(0,a.jsx)("div",{className:"mt-3 flex items-center gap-2",children:d.map(e=>(0,a.jsx)("button",{onClick:()=>{var t;O(t=e.id),eU({cavemanLevel:t})},className:`px-3 py-1.5 rounded text-xs font-medium border transition-colors ${D===e.id?"bg-primary text-white border-primary":"bg-transparent border-border text-text-muted hover:bg-black/5 dark:hover:bg-white/5"}`,title:e.desc,children:e.label},e.id))})]}),(0,a.jsxs)(i.Zp,{id:"require-api-key",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between mb-4",children:[(0,a.jsx)("h2",{className:"text-lg font-semibold",children:"API Keys"}),(0,a.jsx)(i.$n,{icon:"add",onClick:()=>g(!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)(i.lM,{checked:w,onChange:()=>e$(!w)})]}),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)(i.$n,{icon:"add",onClick:()=>g(!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:eC.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 eS(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-0 group-hover:opacity-100 transition-all",title:eC.has(e.id)?"Hide key":"Show key",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:eC.has(e.id)?"visibility_off":"visibility"})}),(0,a.jsx)("button",{onClick:()=>e_(e.key,e.id),className:"p-1 hover:bg-black/5 dark:hover:bg-white/5 rounded text-text-muted hover:text-primary opacity-0 group-hover:opacity-100 transition-all",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:eT===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)(i.lM,{size:"sm",checked:e.isActive??!0,onChange:t=>{e.isActive&&!t?confirm(`Pause API key "${e.name}"?
2
-
3
- This key will stop working immediately but can be resumed later.`)&&eZ(e.id,t):eZ(e.id,t)},title:e.isActive?"Pause key":"Resume key"}),(0,a.jsx)("button",{onClick:()=>eH(e.id),className:"p-2 hover:bg-red-500/10 rounded text-red-500 opacity-0 group-hover:opacity-100 transition-all",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:"delete"})})]})]},e.id)})})]}),(0,a.jsx)(i.aF,{isOpen:b,title:"Create API Key",onClose:()=>{g(!1),f("")},children:(0,a.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,a.jsx)(i.pd,{label:"Key Name",value:y,onChange:e=>f(e.target.value),placeholder:"Production Key"}),(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsx)(i.$n,{onClick:ez,fullWidth:!0,disabled:!y.trim(),children:"Create"}),(0,a.jsx)(i.$n,{onClick:()=>{g(!1),f("")},variant:"ghost",fullWidth:!0,children:"Cancel"})]})]})}),(0,a.jsx)(i.aF,{isOpen:!!j,title:"API Key Created",onClose:()=>k(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)(i.pd,{value:j||"",readOnly:!0,className:"flex-1 font-mono text-sm"}),(0,a.jsx)(i.$n,{variant:"secondary",icon:"created_key"===eT?"check":"content_copy",onClick:()=>e_(j,"created_key"),children:"created_key"===eT?"Copied!":"Copy"})]}),(0,a.jsx)(i.$n,{onClick:()=>k(null),fullWidth:!0,children:"Done"})]})}),(0,a.jsx)(i.aF,{isOpen:V,title:"Enable Tunnel",onClose:()=>G(!1),children:(0,a.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,a.jsx)("div",{className:"bg-blue-50 dark:bg-blue-900/20 border border-blue-200 dark:border-blue-800 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-blue-600 dark:text-blue-400",children:"cloud_upload"}),(0,a.jsxs)("div",{children:[(0,a.jsx)("p",{className:"text-sm text-blue-800 dark:text-blue-200 font-medium mb-1",children:"Cloudflare Tunnel"}),(0,a.jsx)("p",{className:"text-sm text-blue-700 dark:text-blue-300",children:"Expose your local 9Router 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:c.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)(i.$n,{onClick:eF,fullWidth:!0,className:"bg-linear-to-r from-primary to-blue-500 hover:from-primary-hover hover:to-blue-600 text-white!",children:"Start Tunnel"}),(0,a.jsx)(i.$n,{onClick:()=>G(!1),variant:"ghost",fullWidth:!0,children:"Cancel"})]})]})}),(0,a.jsx)(i.aF,{isOpen:X,title:"Disable Tunnel",onClose:()=>!M&&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)(i.$n,{onClick:eI,fullWidth:!0,disabled:M,className:"bg-red-500! hover:bg-red-600! text-white!",children:M?"Disabling...":"Disable"}),(0,a.jsx)(i.$n,{onClick:()=>Y(!1),variant:"ghost",fullWidth:!0,disabled:M,children:"Cancel"})]})]})}),(0,a.jsx)(i.aF,{isOpen:ej,title:"Tailscale Funnel",onClose:()=>{ex||(ek(!1),eg(""),ec(null))},children:(0,a.jsxs)("div",{className:"flex flex-col gap-4",children:[null===ed&&(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===ed&&!ex&&(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)(i.$n,{onClick:eW,fullWidth:!0,className:"bg-linear-to-r from-indigo-500 to-purple-500 hover:from-indigo-600 hover:to-purple-600 text-white!",children:"Install Tailscale"}),(0,a.jsx)(i.$n,{onClick:()=>ek(!1),variant:"ghost",fullWidth:!0,children:"Cancel"})]})]}),ex&&(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..."]}),eu.length>0&&(0,a.jsx)("div",{ref:eN,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:eu.map((e,t)=>(0,a.jsx)("div",{children:e},t))})]}),!0===ed&&!ex&&(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)(i.$n,{onClick:()=>{let e=window.open("","tailscale_auth","width=600,height=700");e&&e.document.write("<p style='font-family:sans-serif;text-align:center;margin-top:40px'>Connecting to Tailscale...</p>"),eq(e)},fullWidth:!0,className:"bg-linear-to-r from-indigo-500 to-purple-500 hover:from-indigo-600 hover:to-purple-600 text-white!",children:"Connect"}),(0,a.jsx)(i.$n,{onClick:()=>ek(!1),variant:"ghost",fullWidth:!0,children:"Cancel"})]})]}),eo&&(0,a.jsx)(h,{status:eo})]})}),(0,a.jsx)(i.aF,{isOpen:ew,title:"Disable Tailscale",onClose:()=>!el&&ev(!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)(i.$n,{onClick:eJ,fullWidth:!0,disabled:el,className:"bg-red-500! hover:bg-red-600! text-white!",children:el?"Disabling...":"Disable"}),(0,a.jsx)(i.$n,{onClick:()=>ev(!1),variant:"ghost",fullWidth:!0,disabled:el,children:"Cancel"})]})]})})]})}function x({label:e,url:t,copyId:s,copied:l,onCopy:r,badge:n,actions:o}){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-[68px] text-center ${"CF"===n?"bg-orange-100 dark:bg-orange-900/30 text-orange-600 dark:text-orange-400":"TS"===n?"bg-purple-100 dark:bg-purple-900/30 text-purple-600 dark:text-purple-400":"bg-sidebar text-text-muted"}`,children:e}),(0,a.jsx)(i.pd,{value:t,readOnly:!0,className:"flex-1 font-mono text-sm"}),(0,a.jsx)("button",{onClick:()=>r(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"})}),o]})}function h({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 u({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 p({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})]})}m.propTypes={machineId:n().string.isRequired}},78035:(e,t,s)=>{Promise.resolve().then(s.bind(s,64795))}}]);
@@ -1 +0,0 @@
1
- (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[2326],{46772:(e,t,s)=>{"use strict";s.d(t,{default:()=>u});var a=s(73365),i=s(1521),l=s(74156),o=s(97990),r=s(69633),c=s(7127);let n=s(89651).env.NEXT_PUBLIC_CLOUD_URL,d={claude:"/api/cli-tools/claude-settings",codex:"/api/cli-tools/codex-settings",opencode:"/api/cli-tools/opencode-settings",droid:"/api/cli-tools/droid-settings",openclaw:"/api/cli-tools/openclaw-settings",hermes:"/api/cli-tools/hermes-settings"};function u({machineId:e}){let t,s,x,[p,h]=(0,i.useState)([]),[v,m]=(0,i.useState)(!0),[g,f]=(0,i.useState)(null),[j,b]=(0,i.useState)({}),[w,E]=(0,i.useState)(!1),[y,P]=(0,i.useState)(!1),[S,N]=(0,i.useState)(""),[k,C]=(0,i.useState)([]),[_,O]=(0,i.useState)({});(0,i.useEffect)(()=>{T(),M(),I(),A()},[]);let A=async()=>{try{let e=await Promise.all(Object.entries(d).map(async([e,t])=>{try{let s=await fetch(t),a=await s.json();return[e,a]}catch{return[e,null]}}));O(Object.fromEntries(e))}catch(e){console.log("Error fetching tool statuses:",e)}},M=async()=>{try{let[e,t]=await Promise.all([fetch("/api/settings"),fetch("/api/tunnel/status")]);if(e.ok){let t=await e.json();E(t.cloudEnabled||!1)}if(t.ok){let e=await t.json();P(e.enabled||!1),N(e.publicUrl||"")}}catch(e){console.log("Error loading settings:",e)}},I=async()=>{try{let e=await fetch("/api/keys");if(e.ok){let t=await e.json();C(t.keys||[])}}catch(e){console.log("Error fetching API keys:",e)}},T=async()=>{try{let e=await fetch("/api/providers"),t=await e.json();e.ok&&h(t.connections||[])}catch(e){console.log("Error fetching connections:",e)}finally{m(!1)}},U=()=>p.filter(e=>!1!==e.isActive),L=(0,i.useCallback)((e,t,s)=>{b(a=>a[e]?.[t]===s?a:{...a,[e]:{...a[e],[t]:s}})},[]);if(v)return(0,a.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,a.jsx)(l.Qv,{}),(0,a.jsx)(l.Qv,{}),(0,a.jsx)(l.Qv,{})]});let $=(t=U(),s=[],x=new Set,t.forEach(e=>{let t=r.Xg[e.provider]||e.provider;(0,r.KC)(e.provider).forEach(a=>{let i=`${t}/${a.id}`;x.has(i)||(x.add(i),s.push({value:i,label:`${t}/${a.id}`,provider:e.provider,alias:t,connectionName:e.name,modelId:a.id}))})}),s).length>0,Q=Object.entries(o.dM),R=Object.entries(o.wn);return(0,a.jsxs)("div",{className:"mx-auto flex w-full max-w-5xl flex-col gap-6 px-1 sm:px-0",children:[(0,a.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,a.jsx)("h1",{className:"text-xl font-semibold text-text-main sm:text-2xl",children:"CLI Tools"}),(0,a.jsx)("p",{className:"text-sm text-text-muted",children:"Configure local coding tools to use your 9Router providers."})]}),(0,a.jsx)("div",{className:"grid gap-3 sm:gap-4",children:Q.map(([e,t])=>((e,t)=>{let s={tool:t,isExpanded:g===e,onToggle:()=>f(g===e?null:e),baseUrl:y&&S?S:w&&n?n:window.location.origin,apiKeys:k};switch(e){case"claude":return(0,a.jsx)(c.Tk,{...s,activeProviders:U(),modelMappings:j[e]||{},onModelMappingChange:(t,s)=>L(e,t,s),hasActiveProviders:$,cloudEnabled:w,initialStatus:_.claude},e);case"codex":return(0,a.jsx)(c.Ah,{...s,activeProviders:U(),cloudEnabled:w,initialStatus:_.codex},e);case"opencode":return(0,a.jsx)(c.qO,{...s,activeProviders:U(),cloudEnabled:w,initialStatus:_.opencode},e);case"droid":return(0,a.jsx)(c.ZM,{...s,activeProviders:U(),hasActiveProviders:$,cloudEnabled:w,initialStatus:_.droid},e);case"openclaw":return(0,a.jsx)(c.yZ,{...s,activeProviders:U(),hasActiveProviders:$,cloudEnabled:w,initialStatus:_.openclaw},e);case"hermes":return(0,a.jsx)(c.RF,{...s,activeProviders:U(),hasActiveProviders:$,cloudEnabled:w,initialStatus:_.hermes},e);default:return(0,a.jsx)(c.a7,{toolId:e,...s,activeProviders:U(),cloudEnabled:w,tunnelEnabled:y},e)}})(e,t))}),(0,a.jsxs)("div",{className:"grid gap-3 sm:gap-4",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2 px-1",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px] text-primary",children:"security"}),(0,a.jsx)("h2",{className:"text-sm font-semibold text-text-main",children:"MITM Tools"})]}),R.map(([e,t])=>(0,a.jsx)(c.gY,{tool:t},e))]})]})}},71438:(e,t,s)=>{Promise.resolve().then(s.bind(s,46772))}},e=>{e.O(0,[7848,4335,6795,8872,505,4156,4380,2347,5158,7358],()=>e(e.s=71438)),_N_E=e.O()}]);
@@ -1 +0,0 @@
1
- (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[3649],{37175:(e,t,s)=>{"use strict";s.r(t),s.d(t,{default:()=>i});var a=s(73365),l=s(1521),o=s(74156),r=s(96459);s(82495);let n=/^[a-zA-Z0-9_.\-]+$/;function i(){let[e,t]=(0,l.useState)([]),[s,n]=(0,l.useState)(!0),[i,d]=(0,l.useState)(!1),[x,h]=(0,l.useState)(null),[p,u]=(0,l.useState)([]),[b,f]=(0,l.useState)({}),{copied:g,copy:j}=(0,r.C)();(0,l.useEffect)(()=>{y()},[]);let y=async()=>{try{let[e,s,a]=await Promise.all([fetch("/api/combos"),fetch("/api/providers"),fetch("/api/settings")]),l=await e.json(),o=await s.json(),r=a.ok?await a.json():{};e.ok&&t(l.combos||[]),s.ok&&u(o.connections||[]),f(r.comboStrategies||{})}catch(e){console.log("Error fetching data:",e)}finally{n(!1)}},v=async e=>{try{let t=await fetch("/api/combos",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(t.ok)await y(),d(!1);else{let e=await t.json();alert(e.error||"Failed to create combo")}}catch(e){console.log("Error creating combo:",e)}},w=async(e,t)=>{try{let s=await fetch(`/api/combos/${e}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(s.ok)await y(),h(null);else{let e=await s.json();alert(e.error||"Failed to update combo")}}catch(e){console.log("Error updating combo:",e)}},N=async s=>{if(confirm("Delete this combo?"))try{(await fetch(`/api/combos/${s}`,{method:"DELETE"})).ok&&t(e.filter(e=>e.id!==s))}catch(e){console.log("Error deleting combo:",e)}},k=async(e,t)=>{try{let s={...b};t?s[e]={fallbackStrategy:"round-robin"}:delete s[e],await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({comboStrategies:s})}),f(s)}catch(e){console.log("Error updating combo strategy:",e)}};return s?(0,a.jsxs)("div",{className:"flex flex-col gap-6",children:[(0,a.jsx)(o.Qv,{}),(0,a.jsx)(o.Qv,{})]}):(0,a.jsxs)("div",{className:"flex min-w-0 flex-col gap-6 px-1 sm:px-0",children:[(0,a.jsxs)("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[(0,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsx)("h1",{className:"text-2xl font-semibold",children:"Combos"}),(0,a.jsx)("p",{className:"text-sm text-text-muted mt-1",children:"Create model combos with fallback support"})]}),(0,a.jsx)(o.$n,{icon:"add",onClick:()=>d(!0),className:"w-full sm:w-auto",children:"Create Combo"})]}),0===e.length?(0,a.jsx)(o.Zp,{children:(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:"layers"})}),(0,a.jsx)("p",{className:"text-text-main font-medium mb-1",children:"No combos yet"}),(0,a.jsx)("p",{className:"text-sm text-text-muted mb-4",children:"Create model combos with fallback support"}),(0,a.jsx)(o.$n,{icon:"add",onClick:()=>d(!0),className:"w-full sm:w-auto",children:"Create Combo"})]})}):(0,a.jsx)("div",{className:"flex flex-col gap-4",children:e.map(e=>(0,a.jsx)(c,{combo:e,copied:g,onCopy:j,onEdit:()=>h(e),onDelete:()=>N(e.id),roundRobinEnabled:b[e.name]?.fallbackStrategy==="round-robin",onToggleRoundRobin:t=>k(e.name,t)},e.id))}),(0,a.jsx)(m,{isOpen:i,onClose:()=>d(!1),onSave:v,activeProviders:p},"create"),(0,a.jsx)(m,{isOpen:!!x,combo:x,onClose:()=>h(null),onSave:e=>w(x.id,e),activeProviders:p},x?.id||"new")]})}function c({combo:e,copied:t,onCopy:s,onEdit:l,onDelete:r,roundRobinEnabled:n,onToggleRoundRobin:i}){return(0,a.jsx)(o.Zp,{padding:"sm",className:"group",children:(0,a.jsxs)("div",{className:"flex min-w-0 flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[(0,a.jsxs)("div",{className:"flex min-w-0 flex-1 items-start gap-3 sm:items-center",children:[(0,a.jsx)("div",{className:"size-8 rounded-lg bg-primary/10 flex items-center justify-center shrink-0",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-primary text-[18px]",children:"layers"})}),(0,a.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,a.jsx)("code",{className:"block truncate font-mono text-sm font-medium",children:e.name}),(0,a.jsxs)("div",{className:"mt-1 flex min-w-0 flex-wrap items-center gap-1",children:[0===e.models.length?(0,a.jsx)("span",{className:"text-xs text-text-muted italic",children:"No models"}):e.models.slice(0,3).map((e,t)=>(0,a.jsx)("code",{className:"max-w-full truncate rounded bg-black/5 px-1.5 py-0.5 font-mono text-[10px] text-text-muted dark:bg-white/5 sm:max-w-[220px]",children:e},t)),e.models.length>3&&(0,a.jsxs)("span",{className:"text-[10px] text-text-muted",children:["+",e.models.length-3," more"]})]})]})]}),(0,a.jsxs)("div",{className:"flex w-full flex-col gap-2 sm:w-auto sm:flex-row sm:items-center sm:gap-3 sm:shrink-0",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between gap-1.5 rounded-lg bg-black/[0.02] px-2 py-1.5 dark:bg-white/[0.02] sm:justify-start sm:bg-transparent sm:px-0 sm:py-0 sm:dark:bg-transparent",children:[(0,a.jsx)("span",{className:"text-xs text-text-muted font-medium",children:"Round Robin"}),(0,a.jsx)(o.lM,{size:"sm",checked:n,onChange:i})]}),(0,a.jsxs)("div",{className:"grid grid-cols-3 gap-1 sm:flex",children:[(0,a.jsxs)("button",{onClick:t=>{t.stopPropagation(),s(e.name,`combo-${e.id}`)},className:"flex flex-col items-center rounded px-2 py-1 text-text-muted transition-colors hover:bg-black/5 hover:text-primary dark:hover:bg-white/5",title:"Copy combo name",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:t===`combo-${e.id}`?"check":"content_copy"}),(0,a.jsx)("span",{className:"text-[10px] leading-tight",children:"Copy"})]}),(0,a.jsxs)("button",{onClick:l,className:"flex flex-col items-center rounded px-2 py-1 text-text-muted transition-colors hover:bg-black/5 hover:text-primary dark:hover:bg-white/5",title:"Edit",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:"edit"}),(0,a.jsx)("span",{className:"text-[10px] leading-tight",children:"Edit"})]}),(0,a.jsxs)("button",{onClick:r,className:"flex flex-col items-center rounded px-2 py-1 text-red-500 transition-colors hover:bg-red-500/10",title:"Delete",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:"delete"}),(0,a.jsx)("span",{className:"text-[10px] leading-tight",children:"Delete"})]})]})]})]})})}function d({index:e,model:t,isFirst:s,isLast:o,onEdit:r,onMoveUp:n,onMoveDown:i,onRemove:c}){let[m,x]=(0,l.useState)(!1),[h,p]=(0,l.useState)(t),u=()=>{let e=h.trim();e&&e!==t?r(e):p(t),x(!1)};return(0,a.jsxs)("div",{className:"group flex min-w-0 items-center gap-1.5 rounded-md bg-black/[0.02] px-2 py-1 transition-colors hover:bg-black/[0.04] dark:bg-white/[0.02] dark:hover:bg-white/[0.04]",children:[(0,a.jsx)("span",{className:"text-[10px] font-medium text-text-muted w-3 text-center shrink-0",children:e+1}),m?(0,a.jsx)("input",{autoFocus:!0,value:h,onChange:e=>p(e.target.value),onBlur:u,onKeyDown:e=>{"Enter"===e.key&&u(),"Escape"===e.key&&(p(t),x(!1))},className:"min-w-0 flex-1 rounded border border-primary/40 bg-white px-1.5 py-0.5 font-mono text-xs text-text-main outline-none dark:bg-black/20"}):(0,a.jsx)("div",{className:"min-w-0 flex-1 cursor-text truncate rounded px-1.5 py-0.5 font-mono text-xs text-text-main hover:bg-black/5 dark:hover:bg-white/5",onClick:()=>x(!0),title:"Click to edit",children:t}),(0,a.jsxs)("div",{className:"flex shrink-0 items-center gap-0.5",children:[(0,a.jsx)("button",{onClick:n,disabled:s,className:`p-0.5 rounded ${s?"text-text-muted/20 cursor-not-allowed":"text-text-muted hover:text-primary hover:bg-black/5 dark:hover:bg-white/5"}`,title:"Move up",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[12px]",children:"arrow_upward"})}),(0,a.jsx)("button",{onClick:i,disabled:o,className:`p-0.5 rounded ${o?"text-text-muted/20 cursor-not-allowed":"text-text-muted hover:text-primary hover:bg-black/5 dark:hover:bg-white/5"}`,title:"Move down",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[12px]",children:"arrow_downward"})})]}),(0,a.jsx)("button",{onClick:c,className:"p-0.5 hover:bg-red-500/10 rounded text-text-muted hover:text-red-500 transition-all",title:"Remove",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[12px]",children:"close"})})]})}function m({isOpen:e,combo:t,onClose:s,onSave:r,activeProviders:i,kindFilter:c=null}){let[x,h]=(0,l.useState)(t?.name||""),[p,u]=(0,l.useState)(t?.models||[]),[b,f]=(0,l.useState)(!1),[g,j]=(0,l.useState)(!1),[y,v]=(0,l.useState)(""),[w,N]=(0,l.useState)({}),k=async()=>{try{let e=await fetch("/api/models/alias");if(!e.ok)return;let t=await e.json();N(t.aliases||{})}catch(e){console.error("Error fetching modal data:",e)}};(0,l.useEffect)(()=>{e&&k()},[e]);let C=e=>e.trim()?n.test(e)?(v(""),!0):(v("Only letters, numbers, -, _ and . allowed"),!1):(v("Name is required"),!1),S=async()=>{C(x)&&(j(!0),await r({name:x.trim(),models:p}),j(!1))},E=!!t;return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(o.aF,{isOpen:e,onClose:s,title:E?"Edit Combo":"Create Combo",children:(0,a.jsxs)("div",{className:"flex flex-col gap-3",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)(o.pd,{label:"Combo Name",value:x,onChange:e=>{let t=e.target.value;h(t),t?C(t):v("")},placeholder:"my-combo",error:y}),(0,a.jsx)("p",{className:"text-[10px] text-text-muted mt-0.5",children:"Only letters, numbers, -, _ and . allowed"})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("label",{className:"text-sm font-medium mb-1.5 block",children:"Models"}),0===p.length?(0,a.jsxs)("div",{className:"text-center py-4 border border-dashed border-black/10 dark:border-white/10 rounded-lg bg-black/[0.01] dark:bg-white/[0.01]",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-text-muted text-xl mb-1",children:"layers"}),(0,a.jsx)("p",{className:"text-xs text-text-muted",children:"No models added yet"})]}):(0,a.jsx)("div",{className:"flex max-h-[55vh] min-w-0 flex-col gap-1 overflow-y-auto sm:max-h-[350px]",children:p.map((e,t)=>(0,a.jsx)(d,{index:t,model:e,isFirst:0===t,isLast:t===p.length-1,onEdit:e=>{let s=[...p];s[t]=e,u(s)},onMoveUp:()=>(e=>{if(0===e)return;let t=[...p];[t[e-1],t[e]]=[t[e],t[e-1]],u(t)})(t),onMoveDown:()=>(e=>{if(e===p.length-1)return;let t=[...p];[t[e],t[e+1]]=[t[e+1],t[e]],u(t)})(t),onRemove:()=>{u(p.filter((e,s)=>s!==t))}},t))}),(0,a.jsxs)("button",{onClick:()=>f(!0),className:"w-full mt-2 py-2 border border-dashed border-black/10 dark:border-white/10 rounded-lg text-xs text-primary font-medium hover:text-primary hover:border-primary/50 transition-colors flex items-center justify-center gap-1",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[16px]",children:"add"}),"Add Model"]})]}),(0,a.jsxs)("div",{className:"flex flex-col gap-2 pt-1 sm:flex-row",children:[(0,a.jsx)(o.$n,{onClick:s,variant:"ghost",fullWidth:!0,size:"sm",children:"Cancel"}),(0,a.jsx)(o.$n,{onClick:S,fullWidth:!0,size:"sm",disabled:!x.trim()||!!y||g,children:g?"Saving...":E?"Save":"Create"})]})]})}),(0,a.jsx)(o.rq,{isOpen:b,onClose:()=>f(!1),onSelect:e=>{p.includes(e.value)||u([...p,e.value])},activeProviders:i,modelAliases:w,title:"Add Model to Combo",kindFilter:c})]})}},73540:(e,t,s)=>{Promise.resolve().then(s.bind(s,37175))}},e=>{e.O(0,[7848,4335,6795,505,4156,2347,5158,7358],()=>e(e.s=73540)),_N_E=e.O()}]);
@@ -1,53 +0,0 @@
1
- (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[182],{597:(e,t,s)=>{Promise.resolve().then(s.bind(s,38596))},38596:(e,t,s)=>{"use strict";s.r(t),s.d(t,{default:()=>T});var a=s(73365),r=s(29717),o=s(99568),l=s.n(o),i=s(1521),n=s(74156),d=s(68266),c=s(82495),p=s(69633),x=s(96459),u=s(86447),m=s.n(u);function h({until:e}){let[t,s]=(0,i.useState)("");return((0,i.useEffect)(()=>{let t=()=>{let t=new Date(e).getTime()-Date.now();if(t<=0)return void s("");let a=Math.floor(t/1e3);a<60?s(`${a}s`):a<3600?s(`${Math.floor(a/60)}m ${a%60}s`):s(`${Math.floor(a/3600)}h ${Math.floor(a%3600/60)}m`)};t();let a=setInterval(t,1e3);return()=>clearInterval(a)},[e]),t)?(0,a.jsxs)("span",{className:"text-xs text-orange-500 font-mono",children:["⏱ ",t]}):null}function b({connection:e,proxyPools:t,isOAuth:s,isFirst:r,isLast:o,onMoveUp:l,onMoveDown:d,onToggleActive:c,onUpdateProxy:p,onEdit:x,onDelete:u}){let[m,g]=(0,i.useState)(!1),[y,f]=(0,i.useState)(!1),[j,v]=(0,i.useState)(!1),N=(0,i.useRef)(null),w=new Map((t||[]).map(e=>[e.id,e])),k=e.providerSpecificData?.proxyPoolId||null,S=k?w.get(k):null,C=e.providerSpecificData?.connectionProxyEnabled===!0&&!!e.providerSpecificData?.connectionProxyUrl,$=!!k||C,P=S?`Pool: ${S.name}`:k?`Pool: ${k} (inactive/missing)`:C?`Legacy: ${e.providerSpecificData?.connectionProxyUrl}`:"",A="",R=S?.proxyUrl||e.providerSpecificData?.connectionProxyUrl;if(R)try{let e=new URL(R);A=`${e.protocol}//${e.hostname}${e.port?`:${e.port}`:""}`}catch{A=R}let T=S?.noProxy||e.providerSpecificData?.connectionNoProxy||"",I=S?.isActive===!0?"success":k||C?"error":"default",_=Object.entries(e).filter(([e])=>e.startsWith("modelLock_")).map(([,e])=>e).filter(Boolean).sort()[0]||null;(0,i.useEffect)(()=>{let t=()=>{v(!!Object.entries(e).filter(([e])=>e.startsWith("modelLock_")).map(([,e])=>e).filter(e=>e&&new Date(e).getTime()>Date.now()).sort()[0])};t();let s=_?setInterval(t,1e3):null;return()=>{s&&clearInterval(s)}},[_]),(0,i.useEffect)(()=>{if(!m)return;let e=e=>{N.current&&!N.current.contains(e.target)&&g(!1)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[m]);let O="unavailable"!==e.testStatus||j?e.testStatus:"active",E=s?e.name||e.email||e.displayName||"OAuth Account":e.name,K=async e=>{f(!0);try{await p("__none__"===e?null:e)}finally{f(!1),g(!1)}};return(0,a.jsxs)("div",{className:`group flex items-center justify-between p2 rounded-lg hover:bg-black/[0.02] dark:hover:bg-white/[0.02] transition-colors ${!1===e.isActive?"opacity-60":""}`,children:[(0,a.jsxs)("div",{className:"flex items-center gap-3 flex-1 min-w-0",children:[(0,a.jsxs)("div",{className:"flex flex-col",children:[(0,a.jsx)("button",{onClick:l,disabled:r,className:`p-0.5 rounded ${r?"text-text-muted/30 cursor-not-allowed":"hover:bg-sidebar text-text-muted hover:text-primary"}`,children:(0,a.jsx)("span",{className:"material-symbols-outlined text-sm",children:"keyboard_arrow_up"})}),(0,a.jsx)("button",{onClick:d,disabled:o,className:`p-0.5 rounded ${o?"text-text-muted/30 cursor-not-allowed":"hover:bg-sidebar text-text-muted hover:text-primary"}`,children:(0,a.jsx)("span",{className:"material-symbols-outlined text-sm",children:"keyboard_arrow_down"})})]}),(0,a.jsx)("span",{className:"material-symbols-outlined text-base text-text-muted",children:s?"lock":"key"}),(0,a.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,a.jsx)("p",{className:"text-sm font-medium truncate",children:E}),(0,a.jsxs)("div",{className:"flex items-center gap-2 mt-1 flex-wrap",children:[(0,a.jsx)(n.Ex,{variant:!1===e.isActive?"default":"active"===O||"success"===O?"success":"error"===O||"expired"===O||"unavailable"===O?"error":"default",size:"sm",dot:!0,children:!1===e.isActive?"disabled":O||"Unknown"}),$&&(0,a.jsx)(n.Ex,{variant:I,size:"sm",children:"Proxy"}),j&&!1!==e.isActive&&(0,a.jsx)(h,{until:_}),e.lastError&&!1!==e.isActive&&(0,a.jsx)("span",{className:"text-xs text-red-500 truncate max-w-[300px]",title:e.lastError,children:e.lastError}),(0,a.jsxs)("span",{className:"text-xs text-text-muted",children:["#",e.priority]})]}),$&&(0,a.jsxs)("div",{className:"mt-1 flex items-center gap-2 flex-wrap",children:[(0,a.jsx)("span",{className:"text-[11px] text-text-muted truncate max-w-[420px]",title:P,children:P}),A&&(0,a.jsx)("code",{className:"text-[10px] font-mono bg-black/5 dark:bg-white/5 px-1 py-0.5 rounded text-text-muted",children:A}),T&&(0,a.jsxs)("span",{className:"text-[11px] text-text-muted truncate max-w-[320px]",title:T,children:["no_proxy: ",T]})]})]})]}),(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsxs)("div",{className:"flex gap-1",children:[(t||[]).length>0&&(0,a.jsxs)("div",{className:"relative",ref:N,children:[(0,a.jsxs)("button",{onClick:()=>g(e=>!e),className:`flex flex-col items-center px-2 py-1 rounded hover:bg-black/5 dark:hover:bg-white/5 transition-colors ${$?"text-primary":"text-text-muted hover:text-primary"}`,disabled:y,children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:y?"progress_activity":"lan"}),(0,a.jsx)("span",{className:"text-[10px] leading-tight",children:"Proxy"})]}),m&&(0,a.jsxs)("div",{className:"absolute right-0 top-full mt-1 z-50 bg-bg border border-border rounded-lg shadow-lg py-1 min-w-[160px]",children:[(0,a.jsx)("button",{onClick:()=>K("__none__"),className:`w-full text-left px-3 py-1.5 text-sm hover:bg-black/5 dark:hover:bg-white/5 ${!k?"text-primary font-medium":"text-text-main"}`,children:"None"}),(t||[]).map(e=>(0,a.jsx)("button",{onClick:()=>K(e.id),className:`w-full text-left px-3 py-1.5 text-sm hover:bg-black/5 dark:hover:bg-white/5 ${k===e.id?"text-primary font-medium":"text-text-main"}`,children:e.name},e.id))]})]}),(0,a.jsxs)("button",{onClick:x,className:"flex flex-col items-center px-2 py-1 rounded hover:bg-black/5 dark:hover:bg-white/5 text-text-muted hover:text-primary",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:"edit"}),(0,a.jsx)("span",{className:"text-[10px] leading-tight",children:"Edit"})]}),(0,a.jsxs)("button",{onClick:u,className:"flex flex-col items-center px-2 py-1 rounded hover:bg-red-500/10 text-red-500",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:"delete"}),(0,a.jsx)("span",{className:"text-[10px] leading-tight",children:"Delete"})]})]}),(0,a.jsx)(n.lM,{size:"sm",checked:e.isActive??!0,onChange:c,title:e.isActive??!0?"Disable":"Enable"})]})]})}function g({isOpen:e,provider:t,providerName:s,proxyPools:r,onSave:o,onClose:l}){let d="__none__",[c,p]=(0,i.useState)({name:"",apiKey:"",priority:1,proxyPoolId:d}),[x,u]=(0,i.useState)(!1),[m,h]=(0,i.useState)(null),[b,y]=(0,i.useState)(!1),f=async()=>{u(!0);try{let e=await fetch("/api/providers/validate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:t,apiKey:c.apiKey})}),s=await e.json();h(s.valid?"success":"failed")}catch{h("failed")}finally{u(!1)}},j=async()=>{if(t&&c.apiKey){y(!0);try{let e=!1;try{u(!0),h(null);let s=await fetch("/api/providers/validate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:t,apiKey:c.apiKey})});e=!!(await s.json()).valid,h(e?"success":"failed")}catch{h("failed")}finally{u(!1)}await o({name:c.name,apiKey:c.apiKey,priority:c.priority,proxyPoolId:c.proxyPoolId===d?null:c.proxyPoolId,testStatus:e?"active":"unknown"})}finally{y(!1)}}};return t?(0,a.jsx)(n.aF,{isOpen:e,title:`Add ${s||t} API Key`,onClose:l,children:(0,a.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("label",{className:"text-xs text-text-muted mb-1 block",children:"Name"}),(0,a.jsx)("input",{className:"w-full px-3 py-2 text-sm border border-border rounded-lg bg-background focus:outline-none focus:border-primary",value:c.name,onChange:e=>p({...c,name:e.target.value}),placeholder:"Production Key"})]}),(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsxs)("div",{className:"flex-1",children:[(0,a.jsx)("label",{className:"text-xs text-text-muted mb-1 block",children:"API Key"}),(0,a.jsx)("input",{type:"password",className:"w-full px-3 py-2 text-sm border border-border rounded-lg bg-background focus:outline-none focus:border-primary",value:c.apiKey,onChange:e=>p({...c,apiKey:e.target.value})})]}),(0,a.jsx)("div",{className:"pt-6",children:(0,a.jsx)(n.$n,{onClick:f,disabled:!c.apiKey||x||b,variant:"secondary",children:x?"Checking...":"Check"})})]}),m&&(0,a.jsx)(n.Ex,{variant:"success"===m?"success":"error",children:"success"===m?"Valid":"Invalid"}),(0,a.jsxs)("div",{children:[(0,a.jsx)("label",{className:"text-xs text-text-muted mb-1 block",children:"Priority"}),(0,a.jsx)("input",{type:"number",className:"w-full px-3 py-2 text-sm border border-border rounded-lg bg-background focus:outline-none focus:border-primary",value:c.priority,onChange:e=>p({...c,priority:Number.parseInt(e.target.value)||1})})]}),(0,a.jsx)(n.l6,{label:"Proxy Pool",value:c.proxyPoolId,onChange:e=>p({...c,proxyPoolId:e.target.value}),options:[{value:d,label:"None"},...(r||[]).map(e=>({value:e.id,label:e.name}))]}),(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsx)(n.$n,{onClick:j,fullWidth:!0,disabled:!c.name||!c.apiKey||b,children:b?"Saving...":"Save"}),(0,a.jsx)(n.$n,{onClick:l,variant:"ghost",fullWidth:!0,children:"Cancel"})]})]})}):null}function y({providerId:e,isOAuth:t}){let[s,r]=(0,i.useState)([]),[o,l]=(0,i.useState)([]),[d,c]=(0,i.useState)(!0),[p,x]=(0,i.useState)(!1),[u,m]=(0,i.useState)(!1),[h,f]=(0,i.useState)(null),[j,v]=(0,i.useState)(null),[N,w]=(0,i.useState)("1"),k=(0,i.useCallback)(async()=>{try{let[t,s,a]=await Promise.all([fetch("/api/providers",{cache:"no-store"}),fetch("/api/proxy-pools?isActive=true",{cache:"no-store"}),fetch("/api/settings",{cache:"no-store"})]),o=await t.json(),i=await s.json(),n=a.ok?await a.json():{};t.ok&&r((o.connections||[]).filter(t=>t.provider===e)),s.ok&&l(i.proxyPools||[]);let d=(n.providerStrategies||{})[e]||{};v(d.fallbackStrategy||null),w(null!=d.stickyRoundRobinLimit?String(d.stickyRoundRobinLimit):"1")}catch(e){console.log("ConnectionsCard fetch error:",e)}finally{c(!1)}},[e]);(0,i.useEffect)(()=>{k()},[k]);let S=async(t,s)=>{try{let a=await fetch("/api/settings",{cache:"no-store"}),r=(a.ok?await a.json():{}).providerStrategies||{},o={};t&&(o.fallbackStrategy=t),"round-robin"===t&&""!==s&&(o.stickyRoundRobinLimit=Number(s)||3);let l={...r};0===Object.keys(o).length?delete l[e]:l[e]=o,await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({providerStrategies:l})})}catch(e){console.log("saveStrategy error:",e)}},C=async(e,t)=>{let a=[...s];[a[e],a[t]]=[a[t],a[e]],r(a);try{await Promise.all([fetch(`/api/providers/${a[e].id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({priority:e})}),fetch(`/api/providers/${a[t].id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({priority:t})})])}catch{await k()}},$=async e=>{if(confirm("Delete this connection?"))try{(await fetch(`/api/providers/${e}`,{method:"DELETE"})).ok&&r(t=>t.filter(t=>t.id!==e))}catch(e){console.log("delete error:",e)}},P=async(e,t)=>{try{(await fetch(`/api/providers/${e}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({isActive:t})})).ok&&r(s=>s.map(s=>s.id===e?{...s,isActive:t}:s))}catch(e){console.log("toggle error:",e)}},A=async(e,t)=>{try{(await fetch(`/api/providers/${e}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({proxyPoolId:t||null})})).ok&&r(s=>s.map(s=>s.id===e?{...s,providerSpecificData:{...s.providerSpecificData,proxyPoolId:t||null}}:s))}catch(e){console.log("proxy error:",e)}},R=async t=>{try{(await fetch("/api/providers",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:e,...t})})).ok&&(await k(),x(!1))}catch(e){console.log("save apikey error:",e)}},T=async e=>{try{(await fetch(`/api/providers/${h.id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})).ok&&(await k(),m(!1))}catch(e){console.log("update connection error:",e)}};return d?(0,a.jsx)(n.Zp,{children:(0,a.jsx)("div",{className:"h-20 animate-pulse bg-black/5 rounded-lg"})}):(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)(n.Zp,{children:[(0,a.jsxs)("div",{className:"flex items-center justify-between mb-4",children:[(0,a.jsx)("h2",{className:"text-lg font-semibold",children:"Connections"}),(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("span",{className:"text-xs text-text-muted font-medium",children:"Round Robin"}),(0,a.jsx)(n.lM,{checked:"round-robin"===j,onChange:e=>{let t=e?"round-robin":null;v(t),e&&!N&&w("1"),S(t,e?N||"1":N)}}),"round-robin"===j&&(0,a.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,a.jsx)("span",{className:"text-xs text-text-muted",children:"Sticky:"}),(0,a.jsx)("input",{type:"number",min:1,value:N,onChange:e=>{w(e.target.value),S("round-robin",e.target.value)},className:"w-14 px-2 py-1 text-xs border border-border rounded-md bg-background focus:outline-none focus:border-primary"})]})]})]}),0===s.length?(0,a.jsxs)("div",{className:"flex items-center justify-between",children:[(0,a.jsx)("p",{className:"text-sm text-text-muted",children:"No connections yet"}),(0,a.jsx)(n.$n,{size:"sm",icon:"add",onClick:()=>x(!0),children:"Add Connection"})]}):(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("div",{className:"flex flex-col divide-y divide-black/[0.03] dark:divide-white/[0.03]",children:s.map((e,r)=>(0,a.jsx)(b,{connection:e,proxyPools:o,isOAuth:t,isFirst:0===r,isLast:r===s.length-1,onMoveUp:()=>C(r,r-1),onMoveDown:()=>C(r,r+1),onToggleActive:t=>P(e.id,t),onUpdateProxy:t=>A(e.id,t),onEdit:()=>{f(e),m(!0)},onDelete:()=>$(e.id)},e.id))}),(0,a.jsx)("div",{className:"mt-4",children:(0,a.jsx)(n.$n,{size:"sm",icon:"add",onClick:()=>x(!0),children:"Add"})})]})]}),(0,a.jsx)(g,{isOpen:p,provider:e,proxyPools:o,onSave:R,onClose:()=>x(!1)}),(0,a.jsx)(n.wI,{isOpen:u,connection:h,proxyPools:o,onSave:T,onClose:()=>m(!1)})]})}function f({model:e,fullModel:t,copied:s,onCopy:r,testStatus:o,isCustom:l,isFree:i,onDeleteAlias:n,onTest:d,isTesting:c}){let p="ok"===o?"#22c55e":"error"===o?"#ef4444":void 0;return(0,a.jsx)("div",{className:`group px-3 py-2 rounded-lg border ${"ok"===o?"border-green-500/40":"error"===o?"border-red-500/40":"border-border"} hover:bg-sidebar/50`,children:(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-base",style:p?{color:p}:void 0,children:"ok"===o?"check_circle":"error"===o?"cancel":"smart_toy"}),(0,a.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,a.jsx)("code",{className:"text-xs text-text-muted font-mono bg-sidebar px-1.5 py-0.5 rounded",children:t}),e.name&&(0,a.jsx)("span",{className:"text-[9px] text-text-muted/70 italic pl-1",children:e.name})]}),d&&(0,a.jsxs)("div",{className:"relative group/btn",children:[(0,a.jsx)("button",{onClick:d,disabled:c,className:`p-0.5 hover:bg-sidebar rounded text-text-muted hover:text-primary transition-opacity ${c?"opacity-100":"opacity-0 group-hover:opacity-100"}`,children:(0,a.jsx)("span",{className:"material-symbols-outlined text-sm",style:c?{animation:"spin 1s linear infinite"}:void 0,children:c?"progress_activity":"science"})}),(0,a.jsx)("span",{className:"pointer-events-none absolute mt-1 top-5 left-1/2 -translate-x-1/2 text-[10px] text-text-muted whitespace-nowrap opacity-0 group-hover/btn:opacity-100 transition-opacity",children:c?"Testing...":"Test"})]}),(0,a.jsxs)("div",{className:"relative group/btn",children:[(0,a.jsx)("button",{onClick:()=>r(t,`model-${e.id}`),className:"p-0.5 hover:bg-sidebar rounded text-text-muted hover:text-primary",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-sm",children:s===`model-${e.id}`?"check":"content_copy"})}),(0,a.jsx)("span",{className:"pointer-events-none absolute mt-1 top-5 left-1/2 -translate-x-1/2 text-[10px] text-text-muted whitespace-nowrap opacity-0 group-hover/btn:opacity-100 transition-opacity",children:s===`model-${e.id}`?"Copied!":"Copy"})]}),i&&(0,a.jsx)("span",{className:"text-[10px] font-bold text-green-500 bg-green-500/10 px-1.5 py-0.5 rounded",children:"FREE"}),l&&(0,a.jsx)("button",{onClick:n,className:"p-0.5 hover:bg-red-500/10 rounded text-text-muted hover:text-red-500 opacity-0 group-hover:opacity-100 transition-opacity ml-auto",title:"Remove custom model",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-sm",children:"close"})})]})})}function j({isOpen:e,onSave:t,onClose:s}){let[r,o]=(0,i.useState)(""),l=()=>{r.trim()&&(t(r.trim()),o(""))};return(0,a.jsx)(n.aF,{isOpen:e,title:"Add Custom Model",onClose:s,children:(0,a.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("label",{className:"text-xs text-text-muted mb-1 block",children:"Model ID"}),(0,a.jsx)("input",{className:"w-full px-3 py-2 text-sm border border-border rounded-lg bg-background focus:outline-none focus:border-primary",value:r,onChange:e=>o(e.target.value),onKeyDown:e=>"Enter"===e.key&&l(),placeholder:"e.g. tts-1-hd",autoFocus:!0})]}),(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsx)(n.$n,{onClick:l,fullWidth:!0,disabled:!r.trim(),children:"Add"}),(0,a.jsx)(n.$n,{onClick:s,variant:"ghost",fullWidth:!0,children:"Cancel"})]})]})})}function v({providerId:e,kindFilter:t,providerAliasOverride:s}){let{copied:r,copy:o}=(0,x.C)(),[l,d]=(0,i.useState)({}),[u,m]=(0,i.useState)([]),[h,b]=(0,i.useState)({}),[g,y]=(0,i.useState)(null),[N,w]=(0,i.useState)(""),[k,S]=(0,i.useState)(!1),[C,$]=(0,i.useState)([]),P=s||(0,c.wG)(e),A=t||"llm",R=(0,i.useCallback)(async()=>{try{let[t,s,a]=await Promise.all([fetch("/api/models/alias"),fetch("/api/providers",{cache:"no-store"}),fetch("/api/models/custom",{cache:"no-store"})]),r=await t.json(),o=await s.json(),l=await a.json();t.ok&&d(r.aliases||{}),s.ok&&$((o.connections||[]).filter(t=>t.provider===e)),a.ok&&m(l.models||[])}catch(e){console.log("ModelsCard fetch error:",e)}},[e]);(0,i.useEffect)(()=>{R()},[R]);let T=async(e,t)=>{let s=`${P}/${e}`;try{(await fetch("/api/models/alias",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({model:s,alias:t})})).ok&&await R()}catch(e){console.log("set alias error:",e)}},I=async e=>{try{(await fetch(`/api/models/alias?alias=${encodeURIComponent(e)}`,{method:"DELETE"})).ok&&await R()}catch(e){console.log("delete alias error:",e)}},_=async e=>{try{(await fetch("/api/models/custom",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({providerAlias:P,id:e,type:A})})).ok&&await R()}catch(e){console.log("add custom model error:",e)}},O=async e=>{try{let t=new URLSearchParams({providerAlias:P,id:e,type:A});(await fetch(`/api/models/custom?${t}`,{method:"DELETE"})).ok&&await R()}catch(e){console.log("delete custom model error:",e)}},E=async e=>{if(!g){y(e);try{let s=await fetch("/api/models/test",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({model:`${P}/${e}`,kind:t})}),a=await s.json();b(t=>({...t,[e]:a.ok?"ok":"error"})),w(a.ok?"":a.error||"Model not reachable")}catch{b(t=>({...t,[e]:"error"})),w("Network error")}finally{y(null)}}},K=(0,p.KC)(e),M=t?K.filter(e=>e.kinds?e.kinds.includes(t):(e.type||"llm")===t):K,U=u.filter(e=>e.providerAlias===P&&(e.type||"llm")===A&&!M.some(t=>t.id===e.id));return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)(n.Zp,{children:[(0,a.jsx)("div",{className:"flex items-center justify-between mb-4",children:(0,a.jsxs)("h2",{className:"text-lg font-semibold",children:["Models",t?` — ${t.toUpperCase()}`:""]})}),N&&(0,a.jsx)("p",{className:"text-xs text-red-500 mb-3 break-words",children:N}),(0,a.jsxs)("div",{className:"flex flex-wrap gap-3",children:[M.map(e=>{let t=`${P}/${e.id}`,s=Object.entries(l).find(([,e])=>e===t)?.[0];return(0,a.jsx)(f,{model:e,fullModel:`${P}/${e.id}`,alias:s,copied:r,onCopy:o,onSetAlias:t=>T(e.id,t),onDeleteAlias:()=>I(s),testStatus:h[e.id],onTest:C.length>0?()=>E(e.id):void 0,isTesting:g===e.id,isFree:e.isFree},e.id)}),U.map(e=>(0,a.jsx)(f,{model:{id:e.id,name:e.name},fullModel:`${P}/${e.id}`,copied:r,onCopy:o,onSetAlias:()=>{},onDeleteAlias:()=>O(e.id),testStatus:h[e.id],onTest:C.length>0?()=>E(e.id):void 0,isTesting:g===e.id,isCustom:!0},`${e.id}-${e.type}`)),(0,a.jsxs)("button",{onClick:()=>S(!0),className:"flex items-center gap-1.5 px-3 py-2 rounded-lg border border-dashed border-black/15 dark:border-white/15 text-xs text-text-muted hover:text-primary hover:border-primary/40 transition-colors",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-sm",children:"add"}),"Add Model"]})]})]}),(0,a.jsx)(j,{isOpen:k,onSave:async e=>{await _(e),S(!1)},onClose:()=>S(!1)})]})}h.propTypes={until:m().string.isRequired},b.propTypes={connection:m().shape({id:m().string,name:m().string,email:m().string,displayName:m().string,testStatus:m().string,isActive:m().bool,lastError:m().string,priority:m().number}).isRequired,proxyPools:m().array,isOAuth:m().bool.isRequired,isFirst:m().bool.isRequired,isLast:m().bool.isRequired,onMoveUp:m().func.isRequired,onMoveDown:m().func.isRequired,onToggleActive:m().func.isRequired,onUpdateProxy:m().func,onEdit:m().func.isRequired,onDelete:m().func.isRequired},g.propTypes={isOpen:m().bool.isRequired,provider:m().string,providerName:m().string,proxyPools:m().array,onSave:m().func.isRequired,onClose:m().func.isRequired},y.propTypes={providerId:m().string.isRequired,isOAuth:m().bool},f.propTypes={model:m().shape({id:m().string.isRequired}).isRequired,fullModel:m().string.isRequired,copied:m().string,onCopy:m().func.isRequired,testStatus:m().oneOf(["ok","error"]),isCustom:m().bool,isFree:m().bool,onDeleteAlias:m().func,onTest:m().func,isTesting:m().bool},j.propTypes={isOpen:m().bool.isRequired,onSave:m().func.isRequired,onClose:m().func.isRequired},v.propTypes={providerId:m().string.isRequired,kindFilter:m().string,providerAliasOverride:m().string};let N={"google-tts":{hasLanguageDropdown:!1,hasModelSelector:!1,hasBrowseButton:!0,voiceSource:"hardcoded"},openai:{hasLanguageDropdown:!1,hasModelSelector:!0,hasBrowseButton:!1,voiceSource:"hardcoded",modelKey:"openai-tts-models",voiceKey:"openai-tts-voices",voicesPerModel:!0},openrouter:{hasLanguageDropdown:!1,hasModelSelector:!0,hasBrowseButton:!1,voiceSource:"hardcoded",modelKey:"openrouter-tts-models",voiceKey:"openrouter-tts-voices",voicesPerModel:!0},elevenlabs:{hasLanguageDropdown:!1,hasModelSelector:!0,hasBrowseButton:!0,hasVoiceIdInput:!0,voiceSource:"api-language",modelKey:"elevenlabs-tts-models",apiEndpoint:"/api/media-providers/tts/elevenlabs/voices"},"edge-tts":{hasLanguageDropdown:!1,hasModelSelector:!1,hasBrowseButton:!0,voiceSource:"api-language"},"local-device":{hasLanguageDropdown:!1,hasModelSelector:!1,hasBrowseButton:!0,voiceSource:"api-language"},nvidia:{hasModelSelector:!0,hasBrowseButton:!1,hasVoiceIdInput:!0,voiceSource:"config"},hyperbolic:{hasModelSelector:!0,hasBrowseButton:!1,voiceSource:"config"},deepgram:{hasModelSelector:!1,hasBrowseButton:!0,voiceSource:"api-language",apiEndpoint:"/api/media-providers/tts/deepgram/voices"},huggingface:{hasModelSelector:!0,hasBrowseButton:!1,voiceSource:"config"},cartesia:{hasModelSelector:!0,hasBrowseButton:!1,hasVoiceIdInput:!0,voiceSource:"config"},playht:{hasModelSelector:!0,hasBrowseButton:!1,hasVoiceIdInput:!0,voiceSource:"config"},coqui:{hasModelSelector:!0,hasBrowseButton:!1,hasVoiceIdInput:!0,voiceSource:"config"},tortoise:{hasModelSelector:!0,hasBrowseButton:!1,hasVoiceIdInput:!0,voiceSource:"config"},inworld:{hasModelSelector:!0,hasBrowseButton:!0,hasVoiceIdInput:!0,voiceSource:"api-language",modelKey:"inworld-tts-models",apiEndpoint:"/api/media-providers/tts/inworld/voices"},qwen:{hasModelSelector:!0,hasBrowseButton:!1,hasVoiceIdInput:!0,voiceSource:"config"}};var w=s(36698);function k({label:e,children:t}){return(0,a.jsxs)("div",{className:"flex items-center gap-3",children:[(0,a.jsx)("span",{className:"text-xs text-text-muted w-20 shrink-0",children:e}),(0,a.jsx)("div",{className:"flex-1",children:t})]})}let S=`// Audio will appear here after running.
2
- // Example JSON response (response_format=json):
3
- {
4
- "format": "mp3",
5
- "audio": "//NExAANaAIIAUAAANNNNNNNN..." // base64 encoded MP3
6
- }`,C=`{
7
- "object": "list",
8
- "data": [{
9
- "object": "embedding",
10
- "index": 0,
11
- "embedding": [0.002301, -0.019212, 0.004815, -0.031249, ...]
12
- }],
13
- "model": "...",
14
- "usage": { "prompt_tokens": 9, "total_tokens": 9 }
15
- }`,$={webSearch:{inputLabel:"Query",inputPlaceholder:"What is the latest news about AI?",defaultInput:"What is the latest news about AI?",bodyKey:"query",defaultResponse:`{
16
- "results": [
17
- { "title": "...", "url": "...", "snippet": "..." }
18
- ]
19
- }`,extraFields:[{key:"search_type",label:"Type",type:"select",default:"web",options:["web","news"]},{key:"max_results",label:"Max results",type:"number",default:5,min:1,max:100},{key:"country",label:"Country",type:"text",default:""},{key:"language",label:"Language",type:"text",default:""}]},webFetch:{inputLabel:"URL",inputPlaceholder:"https://example.com",defaultInput:"https://example.com",bodyKey:"url",defaultResponse:`{
20
- "content": "...",
21
- "title": "...",
22
- "url": "..."
23
- }`,extraFields:[{key:"format",label:"Format",type:"select",default:"markdown",options:["markdown","text","html"]},{key:"max_characters",label:"Max chars",type:"number",default:0,min:0}]},image:{inputLabel:"Prompt",inputPlaceholder:"A cute cat wearing a hat",defaultInput:"A cute cat wearing a hat",bodyKey:"prompt",defaultResponse:`{
24
- "data": [
25
- { "url": "...", "b64_json": "..." }
26
- ]
27
- }`,extraFields:[{key:"n",label:"n",type:"number",default:1,min:1,max:4},{key:"size",label:"Size",type:"select",default:"auto",options:["auto","1024x1024","1024x1536","1536x1024","1024x1792","1792x1024"]},{key:"quality",label:"Quality",type:"select",default:"auto",options:["auto","low","medium","high","standard","hd"]},{key:"background",label:"Background",type:"select",default:"auto",options:["auto","transparent","opaque"]},{key:"style",label:"Style",type:"select",default:"",options:["","vivid","natural"]},{key:"response_format",label:"Format",type:"select",default:"",options:["","url","b64_json"]},{key:"image_detail",label:"Image Detail",type:"select",default:"high",options:["auto","low","high","original"]},{key:"output_format",label:"Codec",type:"select",default:"png",options:["png","jpeg","webp"]}]},imageToText:{inputLabel:"Image URL",inputPlaceholder:"https://example.com/image.png",defaultInput:"https://upload.wikimedia.org/wikipedia/commons/thumb/3/3a/Cat03.jpg/1200px-Cat03.jpg",bodyKey:"url",extraBody:{prompt:"Describe this image in detail"},defaultResponse:`{
28
- "text": "A cat sitting on a windowsill...",
29
- "model": "..."
30
- }`},stt:{inputLabel:"Audio URL",inputPlaceholder:"https://example.com/audio.mp3",defaultInput:"",bodyKey:"url",defaultResponse:`{
31
- "text": "Hello world...",
32
- "model": "..."
33
- }`},video:{inputLabel:"Prompt",inputPlaceholder:"A serene lake at sunset",defaultInput:"A serene lake at sunset",bodyKey:"prompt",defaultResponse:`{
34
- "data": [
35
- { "url": "..." }
36
- ]
37
- }`},music:{inputLabel:"Prompt",inputPlaceholder:"A calm piano melody",defaultInput:"A calm piano melody",bodyKey:"prompt",defaultResponse:`{
38
- "data": [
39
- { "url": "...", "format": "mp3" }
40
- ]
41
- }`}};function P({providerId:e,customAlias:t}){let s=(0,c.gC)(e),r=s?t||e:(0,c.wG)(e),o=s?[]:(0,p.KC)(e).filter(e=>"embedding"===e.type),[l,d]=(0,i.useState)(o[0]?.id??""),[u,m]=(0,i.useState)("The quick brown fox jumps over the lazy dog"),[h,b]=(0,i.useState)(""),[g,y]=(0,i.useState)(""),[f,j]=(0,i.useState)(!1),[v,N]=(0,i.useState)(""),[w,S]=(0,i.useState)(""),[$,A]=(0,i.useState)(null),[R,T]=(0,i.useState)(!1),[I,_]=(0,i.useState)(""),{copied:O,copy:E}=(0,x.C)(),{copied:K,copy:M}=(0,x.C)();(0,i.useEffect)(()=>{N(window.location.origin),fetch("/api/keys").then(e=>e.json()).then(e=>{y((e.keys||[]).find(e=>!1!==e.isActive)?.key||"")}).catch(()=>{}),fetch("/api/tunnel/status").then(e=>e.json()).then(e=>{e.publicUrl&&S(e.publicUrl)}).catch(()=>{})},[]);let U=f?w:v,L=l?`${r}/${l}`:"",D=()=>{let e={model:L,input:u.trim()},t=Number(h);return h&&Number.isFinite(t)&&t>0&&(e.dimensions=t),e},B=`curl -X POST ${U}/v1/embeddings \\
42
- -H "Content-Type: application/json" \\
43
- -H "Authorization: Bearer ${g||"YOUR_KEY"}" \\
44
- -d '${JSON.stringify(D())}'`,F=async()=>{if(!u.trim()||!L)return;T(!0),_(""),A(null);let e=Date.now();try{let t={"Content-Type":"application/json"};g&&(t.Authorization=`Bearer ${g}`);let s=await fetch("/api/v1/embeddings",{method:"POST",headers:t,body:JSON.stringify(D())}),a=Date.now()-e,r=await s.json();if(!s.ok)return void _(r?.error?.message||r?.error||`HTTP ${s.status}`);A({data:r,latencyMs:a})}catch(e){_(e.message||"Network error")}finally{T(!1)}},q=$?JSON.stringify($.data,null,2):"";return(0,a.jsxs)(n.Zp,{children:[(0,a.jsx)("h2",{className:"text-lg font-semibold mb-4",children:"Example"}),(0,a.jsxs)("div",{className:"flex flex-col gap-2.5",children:[(0,a.jsx)(k,{label:"Model",children:s?(0,a.jsx)("input",{value:l,onChange:e=>d(e.target.value),placeholder:"e.g. voyage-3, embed-english-v3.0, text-embedding-3-small",className:"w-full px-3 py-1.5 text-sm border border-border rounded-lg bg-background focus:outline-none focus:border-primary font-mono"}):(0,a.jsx)("select",{value:l,onChange:e=>d(e.target.value),className:"w-full px-3 py-1.5 text-sm border border-border rounded-lg bg-background focus:outline-none focus:border-primary",children:o.map(e=>(0,a.jsx)("option",{value:e.id,children:e.name||e.id},e.id))})}),(0,a.jsx)(k,{label:"Endpoint",children:(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("input",{value:U,onChange:e=>f?S(e.target.value):N(e.target.value),className:"flex-1 px-3 py-1.5 text-sm border border-border rounded-lg bg-background focus:outline-none focus:border-primary font-mono",placeholder:"http://localhost:3000"}),w&&(0,a.jsxs)("button",{onClick:()=>j(e=>!e),title:f?"Using tunnel":"Using local",className:`flex items-center gap-1 text-xs px-2 py-1.5 rounded-lg border shrink-0 transition-colors ${f?"border-primary/40 bg-primary/10 text-primary":"border-border text-text-muted hover:text-primary"}`,children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"wifi_tethering"}),"Tunnel"]})]})}),(0,a.jsx)(k,{label:"API Key",children:(0,a.jsx)("input",{type:"password",value:g,onChange:e=>y(e.target.value),placeholder:"sk-...",className:"w-full px-3 py-1.5 text-sm border border-border rounded-lg bg-background focus:outline-none focus:border-primary font-mono"})}),(0,a.jsx)(k,{label:"Input",children:(0,a.jsxs)("div",{className:"relative",children:[(0,a.jsx)("input",{value:u,onChange:e=>m(e.target.value),className:"w-full px-3 py-1.5 pr-7 text-sm border border-border rounded-lg bg-background focus:outline-none focus:border-primary"}),u&&(0,a.jsx)("button",{type:"button",onClick:()=>m(""),className:"absolute right-2 top-1/2 -translate-y-1/2 text-text-muted hover:text-primary transition-colors",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"close"})})]})}),(0,a.jsx)(k,{label:"Dimensions",children:(0,a.jsx)("input",{type:"number",min:"1",value:h,onChange:e=>b(e.target.value),placeholder:"optional, e.g. 512, 1024 (leave empty for default)",className:"w-full px-3 py-1.5 text-sm border border-border rounded-lg bg-background focus:outline-none focus:border-primary"})}),(0,a.jsxs)("div",{className:"mt-1",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between mb-1.5",children:[(0,a.jsx)("span",{className:"text-xs font-semibold text-text-muted uppercase tracking-wider",children:"Request"}),(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsxs)("button",{onClick:()=>E(B),className:"flex items-center gap-1 text-xs text-text-muted hover:text-primary transition-colors",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:O?"check":"content_copy"}),O?"Copied":"Copy"]}),(0,a.jsxs)("button",{onClick:F,disabled:R||!u.trim()||!L,className:"flex items-center gap-1.5 px-3 py-1 rounded-lg bg-primary text-white text-xs font-medium hover:bg-primary/90 transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px]",style:R?{animation:"spin 1s linear infinite"}:void 0,children:"play_arrow"}),R?"Running...":"Run"]})]})]}),(0,a.jsx)("pre",{className:"bg-sidebar rounded-lg px-3 py-2.5 text-xs font-mono text-text-main overflow-x-auto whitespace-pre",children:B})]}),I&&(0,a.jsx)("p",{className:"text-xs text-red-500 break-words",children:I}),(0,a.jsxs)("div",{children:[(0,a.jsxs)("div",{className:"flex items-center justify-between mb-1.5",children:[(0,a.jsxs)("span",{className:"text-xs font-semibold text-text-muted uppercase tracking-wider",children:["Response ",$&&(0,a.jsxs)("span",{className:"font-normal normal-case",children:["⚡ ",$.latencyMs,"ms"]})]}),$&&(0,a.jsxs)("button",{onClick:()=>M(q),className:"flex items-center gap-1 text-xs text-text-muted hover:text-primary transition-colors",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:K?"check":"content_copy"}),K?"Copied":"Copy"]})]}),(0,a.jsx)("pre",{className:"bg-sidebar rounded-lg px-3 py-2.5 text-xs font-mono text-text-main overflow-x-auto whitespace-pre opacity-70",children:(e=>{if(!e)return C;let t=JSON.parse(JSON.stringify(e));return(t.data||[]).forEach(e=>{Array.isArray(e.embedding)&&e.embedding.length>4&&(e.embedding=[...e.embedding.slice(0,4).map(e=>parseFloat(e.toFixed(6))),`... (${e.embedding.length} dims)`])}),JSON.stringify(t,null,2)})($?.data)})]})]})]})}function A({providerId:e}){let t=(0,c.wG)(e),s=N[e]||N["edge-tts"],[r,o]=(0,i.useState)(""),[l,d]=(0,i.useState)(""),[u,m]=(0,i.useState)(""),[h,b]=(0,i.useState)([]),[g,y]=(0,i.useState)(""),[f,j]=(0,i.useState)(()=>{let t=c.Q2[e]?.ttsConfig?.models;if(t?.length)return t[0].id;if(s.hasModelSelector&&s.modelKey){let e=(0,p.KC)(s.modelKey);return e?.[0]?.id||""}return""}),[v,C]=(0,i.useState)("Hello, this is a text to speech test."),[$,P]=(0,i.useState)(""),[R,T]=(0,i.useState)(!1),[I,_]=(0,i.useState)(""),[O,E]=(0,i.useState)(""),[K,M]=(0,i.useState)("mp3"),[U,L]=(0,i.useState)(""),[D,B]=(0,i.useState)(null),[F,q]=(0,i.useState)(!1),[J,z]=(0,i.useState)(""),[V,H]=(0,i.useState)(null),{copied:W,copy:G}=(0,x.C)(),[Q,Y]=(0,i.useState)(!1),[Z,X]=(0,i.useState)([]),[ee,et]=(0,i.useState)(!1),[es,ea]=(0,i.useState)(""),[er,eo]=(0,i.useState)(""),[el,ei]=(0,i.useState)({});(0,i.useEffect)(()=>{if(_(window.location.origin),fetch("/api/keys").then(e=>e.json()).then(e=>{P((e.keys||[]).find(e=>!1!==e.isActive)?.key||"")}).catch(()=>{}),fetch("/api/tunnel/status").then(e=>e.json()).then(e=>{e.publicUrl&&E(e.publicUrl)}).catch(()=>{}),"hardcoded"===s.voiceSource){let t=s.hasModelSelector&&s.modelKey&&(0,p.KC)(s.modelKey)?.[0]?.id||"",a=s.voicesPerModel&&t?(0,w.jY)(e,t)||[]:(0,p.KC)(s.voiceKey||e).filter(e=>"tts"===e.type);if(a.length)if(s.hasBrowseButton){let e=a.find(e=>"en"===e.id)||a[0];y(e.id),o(e.id),d(e.name),b([{id:e.id,name:e.name}])}else b(a),o(a[0].id),d(a[0].name||a[0].id)}},[e]),(0,i.useEffect)(()=>{if(!s.voicesPerModel||!f)return;let t=(0,w.jY)(e,f)||[];b(t),t.length&&(o(t[0].id),d(t[0].name||t[0].id))},[f]);let en=async()=>{if(Y(!0),ea(""),eo(""),!Z.length){et(!0);try{if("hardcoded"===s.voiceSource){let t=s.voiceKey||e,a=(0,p.KC)(t).filter(e=>"tts"===e.type),r={};for(let e of a)r[e.id]||(r[e.id]={code:e.id,name:e.name,voices:[{id:e.id,name:e.name}]});ei(r),X(Object.values(r).sort((e,t)=>e.name.localeCompare(t.name)))}else{let t=s.apiEndpoint?s.apiEndpoint:`/api/media-providers/tts/voices?provider=${"local-device"===e?"local-device":"edge-tts"}`,a=await fetch(t),r=await a.json();if(r.error)return void eo(r.error);X(r.languages||[]),ei(r.byLang||{})}}catch(e){eo(e.message)}finally{et(!1)}}},ed=es?Z.filter(e=>e.name.toLowerCase().includes(es.toLowerCase())||e.code.toLowerCase().includes(es.toLowerCase())):Z,ec=R?O:I,ep=s.hasVoiceIdInput&&u||r,ex=s.hasModelSelector&&f&&ep?`${t}/${f}/${ep}`:s.hasModelSelector&&f?`${t}/${f}`:ep?`${t}/${ep}`:"",eu=`curl -X POST ${ec}/v1/audio/speech${"json"===K?"?response_format=json":""} \\
45
- -H "Content-Type: application/json" \\
46
- -H "Authorization: Bearer ${$||"YOUR_KEY"}" \\
47
- -d '{"model": "${ex}", "input": "${v}"}' \\
48
- ${"json"===K?"":"--output speech.mp3"}`,em=async()=>{if(!v.trim()||!ex)return;q(!0),z(""),L(""),B(null);let e=Date.now();try{let t={"Content-Type":"application/json"};$&&(t.Authorization=`Bearer ${$}`);let s=`/api/v1/audio/speech${"json"===K?"?response_format=json":""}`,a=await fetch(s,{method:"POST",headers:t,body:JSON.stringify({model:ex,input:v.trim()})});if(H(Date.now()-e),!a.ok){let e=await a.json().catch(()=>({}));z(e?.error?.message||e?.error||`HTTP ${a.status}`);return}if("json"===K){let e=await a.json();B(e);let t=await fetch(`data:audio/mp3;base64,${e.audio}`).then(e=>e.blob());L(URL.createObjectURL(t))}else{let e=await a.blob();L(URL.createObjectURL(e))}}catch(e){z(e.message||"Network error")}finally{q(!1)}};return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)(n.Zp,{children:[(0,a.jsx)("h2",{className:"text-lg font-semibold mb-4",children:"Example"}),(0,a.jsxs)("div",{className:"flex flex-col gap-2.5",children:[(0,a.jsx)(k,{label:"Endpoint",children:(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsxs)("span",{className:"flex-1 px-3 py-1.5 text-sm font-mono text-text-main bg-sidebar rounded-lg truncate",children:[ec,"/v1/audio/speech"]}),O&&(0,a.jsxs)("button",{onClick:()=>T(e=>!e),title:R?"Using tunnel":"Using local",className:`flex items-center gap-1 text-xs px-2 py-1.5 rounded-lg border shrink-0 transition-colors ${R?"border-primary/40 bg-primary/10 text-primary":"border-border text-text-muted hover:text-primary"}`,children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"wifi_tethering"}),"Tunnel"]})]})}),(0,a.jsx)(k,{label:"API Key",children:(0,a.jsx)("span",{className:"px-3 py-1.5 text-sm font-mono text-text-main bg-sidebar rounded-lg truncate block",children:$?`${$.slice(0,8)}${"•".repeat(Math.min(20,$.length-8))}`:(0,a.jsx)("span",{className:"text-text-muted italic",children:"No key configured"})})}),s.hasModelSelector&&(s.modelKey||c.Q2[e]?.ttsConfig?.models?.length)&&(0,a.jsx)(k,{label:"Model",children:(0,a.jsx)("select",{value:f,onChange:e=>j(e.target.value),className:"w-full px-3 py-1.5 text-sm border border-border rounded-lg bg-background focus:outline-none focus:border-primary",children:((c.Q2[e]?.ttsConfig?.models?.length?c.Q2[e].ttsConfig.models:(0,p.KC)(s.modelKey))||[]).map(e=>(0,a.jsx)("option",{value:e.id,children:e.name||e.id},e.id))})}),s.hasBrowseButton&&(0,a.jsx)(k,{label:"Language",children:(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("button",{onClick:en,className:"flex-1 px-3 py-1.5 text-sm border border-border rounded-lg bg-background font-mono truncate text-left hover:border-primary/40 transition-colors",children:g?(0,a.jsx)("span",{className:"text-text-main",children:Z.find(e=>e.code===g)?.name||g}):(0,a.jsx)("span",{className:"text-text-muted",children:"No language selected"})}),(0,a.jsxs)("button",{onClick:en,className:"flex items-center gap-1 text-xs px-2.5 py-1.5 rounded-lg border border-border text-text-muted hover:text-primary hover:border-primary/40 transition-colors shrink-0",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"language"}),"Select language"]})]})}),h.length>0&&(0,a.jsx)(k,{label:"Voice",children:(0,a.jsx)("div",{className:"flex flex-wrap gap-1.5",children:h.map(e=>(0,a.jsxs)("button",{onClick:()=>{o(e.id),d(e.name),s.hasVoiceIdInput&&m(e.id)},className:`px-2.5 py-1 rounded-full text-xs border transition-colors ${r===e.id?"bg-primary/15 border-primary/40 text-primary font-medium":"border-border text-text-muted hover:text-primary hover:border-primary/40"}`,children:[e.name,e.gender?` \xb7 ${e.gender[0].toUpperCase()}`:"",!0===e.free_users_allowed&&(0,a.jsx)("span",{className:"ml-1.5 px-1 py-0.5 text-[9px] font-semibold rounded bg-green-500/15 text-green-600 border border-green-500/20",children:"Free"}),!1===e.free_users_allowed&&(0,a.jsx)("span",{className:"ml-1.5 px-1 py-0.5 text-[9px] font-semibold rounded bg-amber-500/15 text-amber-600 border border-amber-500/20",children:"Paid"})]},e.id))})}),s.hasVoiceIdInput&&(0,a.jsx)(k,{label:"Voice ID",children:(0,a.jsx)("div",{className:"flex flex-col gap-1",children:(0,a.jsxs)("div",{className:"relative",children:[(0,a.jsx)("input",{value:u,onChange:e=>{m(e.target.value),o(e.target.value)},placeholder:"e.g. CwhRBWXzGAHq8TQ4Fs17",className:"w-full px-3 py-1.5 pr-7 text-sm border border-border rounded-lg bg-background focus:outline-none focus:border-primary font-mono"}),u&&(0,a.jsx)("button",{type:"button",onClick:()=>{m(""),o("")},className:"absolute right-2 top-1/2 -translate-y-1/2 text-text-muted hover:text-primary transition-colors",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"close"})})]})})}),s.hasLanguageDropdown&&(0,a.jsx)(k,{label:"Language",children:(0,a.jsx)("select",{value:r,onChange:t=>{let s=(0,p.KC)(e).filter(e=>"tts"===e.type).find(e=>e.id===t.target.value);o(t.target.value),d(s?.name||t.target.value)},className:"w-full px-3 py-1.5 text-sm border border-border rounded-lg bg-background focus:outline-none focus:border-primary",children:(0,p.KC)(e).filter(e=>"tts"===e.type).map(e=>(0,a.jsx)("option",{value:e.id,children:e.name||e.id},e.id))})}),(0,a.jsx)(k,{label:"Input",children:(0,a.jsxs)("div",{className:"relative",children:[(0,a.jsx)("input",{value:v,onChange:e=>C(e.target.value),className:"w-full px-3 py-1.5 pr-7 text-sm border border-border rounded-lg bg-background focus:outline-none focus:border-primary"}),v&&(0,a.jsx)("button",{type:"button",onClick:()=>C(""),className:"absolute right-2 top-1/2 -translate-y-1/2 text-text-muted hover:text-primary transition-colors",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"close"})})]})}),(0,a.jsx)(k,{label:"Output Format",children:(0,a.jsxs)("select",{value:K,onChange:e=>M(e.target.value),className:"w-full px-3 py-1.5 text-sm border border-border rounded-lg bg-background focus:outline-none focus:border-primary",children:[(0,a.jsx)("option",{value:"mp3",children:"MP3 (Binary)"}),(0,a.jsx)("option",{value:"json",children:"JSON (Base64)"})]})}),(0,a.jsxs)("div",{className:"mt-1",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between mb-1.5",children:[(0,a.jsx)("span",{className:"text-xs font-semibold text-text-muted uppercase tracking-wider",children:"Request"}),(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsxs)("button",{onClick:()=>G(eu),className:"flex items-center gap-1 text-xs text-text-muted hover:text-primary transition-colors",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:W?"check":"content_copy"}),W?"Copied":"Copy"]}),(0,a.jsxs)("button",{onClick:em,disabled:F||!v.trim()||!ex,className:"flex items-center gap-1.5 px-3 py-1 rounded-lg bg-primary text-white text-xs font-medium hover:bg-primary/90 transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px]",style:F?{animation:"spin 1s linear infinite"}:void 0,children:"play_arrow"}),F?"Generating...":"Run"]})]})]}),(0,a.jsx)("pre",{className:"bg-sidebar rounded-lg px-3 py-2.5 text-xs font-mono text-text-main overflow-x-auto whitespace-pre",children:eu})]}),J&&(0,a.jsx)("p",{className:"text-xs text-red-500 break-words",children:J}),U?(0,a.jsxs)("div",{children:[(0,a.jsxs)("div",{className:"flex items-center justify-between mb-1.5",children:[(0,a.jsxs)("span",{className:"text-xs font-semibold text-text-muted uppercase tracking-wider",children:["Response ",V&&(0,a.jsxs)("span",{className:"font-normal normal-case",children:["⚡ ",V,"ms"]})]}),(0,a.jsxs)("a",{href:U,download:"speech.mp3",className:"flex items-center gap-1 text-xs text-text-muted hover:text-primary transition-colors",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"download"}),"Download"]})]}),(0,a.jsx)("audio",{controls:!0,src:U,className:"w-full"}),D&&(0,a.jsxs)("div",{className:"mt-3",children:[(0,a.jsx)("div",{className:"flex items-center justify-between mb-1.5",children:(0,a.jsx)("span",{className:"text-xs font-semibold text-text-muted uppercase tracking-wider",children:"JSON Response"})}),(0,a.jsx)("pre",{className:"bg-sidebar rounded-lg px-3 py-2.5 text-xs font-mono text-text-main overflow-x-auto whitespace-pre-wrap break-all",children:JSON.stringify({format:D.format,audio:D.audio?`${D.audio.substring(0,100)}...`:""},null,2)})]})]}):(0,a.jsxs)("div",{children:[(0,a.jsx)("span",{className:"text-xs font-semibold text-text-muted uppercase tracking-wider",children:"Response"}),(0,a.jsx)("pre",{className:"mt-1.5 bg-sidebar rounded-lg px-3 py-2.5 text-xs font-mono text-text-main overflow-x-auto whitespace-pre opacity-50",children:S})]})]})]}),Q&&(0,a.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center",style:{backgroundColor:"rgba(0,0,0,0.6)",backdropFilter:"blur(2px)"},onClick:()=>Y(!1),children:(0,a.jsxs)("div",{className:"border border-border rounded-xl shadow-2xl w-full max-w-md mx-4 flex flex-col max-h-[80vh]",style:{backgroundColor:"var(--color-bg)",isolation:"isolate"},onClick:e=>e.stopPropagation(),children:[(0,a.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border shrink-0 rounded-t-xl",children:[(0,a.jsx)("h3",{className:"text-sm font-semibold",children:"Select Language"}),(0,a.jsx)("button",{onClick:()=>Y(!1),className:"text-text-muted hover:text-primary transition-colors",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[20px]",children:"close"})})]}),(0,a.jsx)("div",{className:"px-4 py-2.5 border-b border-border shrink-0",children:(0,a.jsx)("input",{autoFocus:!0,value:es,onChange:e=>ea(e.target.value),placeholder:"Search language...",className:"w-full px-3 py-1.5 text-sm border border-border rounded-lg bg-background focus:outline-none focus:border-primary"})}),(0,a.jsxs)("div",{className:"overflow-y-auto flex-1 p-2",children:[er&&(0,a.jsx)("p",{className:"text-xs text-red-500 px-2 py-1",children:er}),ee?(0,a.jsx)("p",{className:"text-xs text-text-muted px-2 py-3",children:"Loading..."}):(0,a.jsxs)("div",{className:"flex flex-col gap-0.5",children:[ed.map(e=>(0,a.jsxs)("button",{onClick:()=>{let t;return Y(!1),y(e.code),void(b(t=el[e.code]?.voices||[]),t.length&&(o(t[0].id),d(t[0].name),s.hasVoiceIdInput&&m(t[0].id)))},className:`flex items-center justify-between w-full px-3 py-2 rounded-lg text-left hover:bg-sidebar transition-colors ${g===e.code?"bg-primary/10 text-primary":""}`,children:[(0,a.jsx)("span",{className:"text-sm",children:e.name}),(0,a.jsxs)("div",{className:"flex items-center gap-2 shrink-0",children:[(0,a.jsxs)("span",{className:"text-xs text-text-muted",children:[e.voices.length," voices"]}),g===e.code&&(0,a.jsx)("span",{className:"material-symbols-outlined text-[16px] text-primary",children:"check"})]})]},e.code)),0===ed.length&&(0,a.jsx)("p",{className:"text-xs text-text-muted px-2 py-3",children:"No languages found."})]})]})]})})]})}function R({providerId:e,kind:t}){let s=(0,c.wG)(e),r=c.rj.find(e=>e.id===t),o=$[t],l=o||{},d=(0,p.KC)(e).filter(e=>e.type===t),[u,m]=(0,i.useState)(d[0]?.id??""),h=d.find(e=>e.id===u),b=!!h?.capabilities?.includes("edit"),[g,y]=(0,i.useState)(l.defaultInput||""),[f,j]=(0,i.useState)(""),[v,N]=(0,i.useState)(()=>(l.extraFields||[]).reduce((e,t)=>(e[t.key]=t.default??"",e),{})),[w,S]=(0,i.useState)(""),[C,P]=(0,i.useState)(!1),[A,T]=(0,i.useState)(""),[I,_]=(0,i.useState)(""),[O,E]=(0,i.useState)(null),[K,M]=(0,i.useState)(null),[U,L]=(0,i.useState)(null),[D,B]=(0,i.useState)("json"),[F,q]=(0,i.useState)(""),[J,z]=(0,i.useState)(!1),[V,H]=(0,i.useState)(""),[W,G]=(0,i.useState)([]),[Q,Y]=(0,i.useState)(""),{copied:Z,copy:X}=(0,x.C)(),{copied:ee,copy:et}=(0,x.C)();if((0,i.useEffect)(()=>{T(window.location.origin),fetch("/api/keys").then(e=>e.json()).then(e=>{S((e.keys||[]).find(e=>!1!==e.isActive)?.key||"")}).catch(()=>{}),fetch("/api/tunnel/status").then(e=>e.json()).then(e=>{e.publicUrl&&_(e.publicUrl)}).catch(()=>{}),fetch("/api/providers/client").then(e=>e.json()).then(t=>{G((t.connections||[]).filter(t=>t.provider===e&&!1!==t.isActive))}).catch(()=>{})},[e]),!r||!o)return null;let es=C?I:A,ea=r.endpoint.path,er=0===d.length?s:u?`${s}/${u}`:"",eo=Object.entries(v).reduce((e,[t,s])=>(""===s||null==s||"number"==typeof s&&Number.isNaN(s)||(e[t]=s),e),{}),el={model:er,[o.bodyKey]:g,...o.extraBody,...eo,...b&&f.trim()?{image:f.trim()}:{}},ei="image"===t&&"binary"===D,en="image"===t&&"codex"===e&&!ei,ed=`${ea}${ei?"?response_format=binary":""}`,ec=`-H "Content-Type: application/json" \\
49
- -H "Authorization: Bearer ${w||"YOUR_KEY"}"${Q?` \\
50
- -H "x-connection-id: ${Q}"`:""}${en?` \\
51
- -H "Accept: text/event-stream"`:""}`,ep=`curl -X ${r.endpoint.method} ${es}${ed} \\
52
- ${ec.replace(/\\\n /g,"\\\n ")} \\
53
- -d '${JSON.stringify(el)}'${ei?" \\\n --output image.png":""}`,ex=async()=>{if(!g.trim()||!er)return;if(z(!0),H(""),E(null),M(null),L(null),F){try{URL.revokeObjectURL(F)}catch{}q("")}let e=Date.now();try{let t={"Content-Type":"application/json"};w&&(t.Authorization=`Bearer ${w}`),Q&&(t["x-connection-id"]=Q),en&&(t.Accept="text/event-stream");let s={...el,model:er},a=await fetch(`/api${ed}`,{method:r.endpoint.method,headers:t,body:JSON.stringify(s)});if(!a.ok){let e=await a.json().catch(()=>({}));H(e?.error?.message||e?.error||`HTTP ${a.status}`);return}let o=a.headers.get("content-type")||"";if(o.startsWith("image/")){let t=await a.blob(),s=URL.createObjectURL(t);q(s),E({data:{binary:!0,mime:o,size:t.size},latencyMs:Date.now()-e});return}if(o.includes("text/event-stream")&&a.body){let t=a.body.getReader(),s=new TextDecoder,r="",o=null,l=null;for(;;){let e,{done:a,value:i}=await t.read();if(a)break;for(r+=s.decode(i,{stream:!0});-1!==(e=r.indexOf("\n\n"));){let t=r.slice(0,e);r=r.slice(e+2);let s=null,a="";for(let e of t.split("\n"))e.startsWith("event:")?s=e.slice(6).trim():e.startsWith("data:")&&(a+=e.slice(5).trim());if(s)try{let e=a?JSON.parse(a):{};"progress"===s?M(e):"partial_image"===s?L(e):"done"===s?o=e:"error"===s&&(l=e?.message||"Stream error")}catch{}}}let i=Date.now()-e;if(l)return void H(l);o&&E({data:o,latencyMs:i})}else{let t=await a.json(),s=Date.now()-e;E({data:t,latencyMs:s})}}catch(e){H(e.message||"Network error")}finally{z(!1)}},eu=e=>{if(!e||"object"!=typeof e)return e;if(Array.isArray(e))return e.map(eu);let t={};for(let[s,a]of Object.entries(e))t[s]="b64_json"===s&&"string"==typeof a&&a.length>100?`<${a.length} chars base64>`:eu(a);return t},em=O?JSON.stringify(eu(O.data),null,2):"";return(0,a.jsxs)(n.Zp,{children:[(0,a.jsx)("h2",{className:"text-lg font-semibold mb-4",children:"Example"}),(0,a.jsxs)("div",{className:"flex flex-col gap-2.5",children:[d.length>0&&(0,a.jsx)(k,{label:"Model",children:(0,a.jsx)("select",{value:u,onChange:e=>m(e.target.value),className:"w-full px-3 py-1.5 text-sm border border-border rounded-lg bg-background focus:outline-none focus:border-primary",children:d.map(e=>(0,a.jsx)("option",{value:e.id,children:e.name||e.id},e.id))})}),(0,a.jsx)(k,{label:"Endpoint",children:(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsxs)("span",{className:"flex-1 px-3 py-1.5 text-sm font-mono text-text-main bg-sidebar rounded-lg truncate",children:[es,ea]}),I&&(0,a.jsxs)("button",{onClick:()=>P(e=>!e),title:C?"Using tunnel":"Using local",className:`flex items-center gap-1 text-xs px-2 py-1.5 rounded-lg border shrink-0 transition-colors ${C?"border-primary/40 bg-primary/10 text-primary":"border-border text-text-muted hover:text-primary"}`,children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"wifi_tethering"}),"Tunnel"]})]})}),(0,a.jsx)(k,{label:"API Key",children:(0,a.jsx)("span",{className:"px-3 py-1.5 text-sm font-mono text-text-main bg-sidebar rounded-lg truncate block",children:w?`${w.slice(0,8)}${"•".repeat(Math.min(20,w.length-8))}`:(0,a.jsx)("span",{className:"text-text-muted italic",children:"No key configured"})})}),W.length>0&&(0,a.jsx)(k,{label:"Connection",children:(0,a.jsxs)("select",{value:Q,onChange:e=>Y(e.target.value),className:"w-full px-3 py-1.5 text-sm border border-border rounded-lg bg-background focus:outline-none focus:border-primary",children:[(0,a.jsx)("option",{value:"",children:"Auto (by priority)"}),W.map(e=>{let t=e.providerSpecificData?.chatgptPlanType,s=e.email||e.name||e.id.slice(0,8);return(0,a.jsxs)("option",{value:e.id,children:[s,t?` [${t}]`:""]},e.id)})]})}),(0,a.jsx)(k,{label:o.inputLabel,children:(0,a.jsxs)("div",{className:"relative",children:[(0,a.jsx)("input",{value:g,onChange:e=>y(e.target.value),placeholder:o.inputPlaceholder,className:"w-full px-3 py-1.5 pr-7 text-sm border border-border rounded-lg bg-background focus:outline-none focus:border-primary"}),g&&(0,a.jsx)("button",{type:"button",onClick:()=>y(""),className:"absolute right-2 top-1/2 -translate-y-1/2 text-text-muted hover:text-primary transition-colors",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"close"})})]})}),b&&(0,a.jsx)(k,{label:"Ref Image (URL)",children:(0,a.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,a.jsxs)("div",{className:"relative",children:[(0,a.jsx)("input",{value:f,onChange:e=>j(e.target.value),placeholder:"https://example.com/source.png",className:"w-full px-3 py-1.5 pr-7 text-sm border border-border rounded-lg bg-background focus:outline-none focus:border-primary"}),f&&(0,a.jsx)("button",{type:"button",onClick:()=>j(""),className:"absolute right-2 top-1/2 -translate-y-1/2 text-text-muted hover:text-primary transition-colors",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"close"})})]}),f.trim()&&(0,a.jsx)("img",{src:f.trim(),alt:"Reference",className:"max-h-40 rounded-lg border border-border object-contain bg-sidebar",onError:e=>{e.currentTarget.style.display="none"},onLoad:e=>{e.currentTarget.style.display="block"}})]})}),(o.extraFields||[]).filter(e=>0===d.length||Array.isArray(h?.params)&&h.params.includes(e.key)).map(e=>(0,a.jsx)(k,{label:e.label,children:"select"===e.type?(0,a.jsx)("select",{value:v[e.key]??"",onChange:t=>N(s=>({...s,[e.key]:t.target.value})),className:"w-full px-3 py-1.5 text-sm border border-border rounded-lg bg-background focus:outline-none focus:border-primary",children:(e.options||[]).map(e=>(0,a.jsx)("option",{value:e,children:""===e?"(default)":e},e))}):"text"===e.type?(0,a.jsx)("input",{type:"text",value:v[e.key]??"",placeholder:e.placeholder,onChange:t=>N(s=>({...s,[e.key]:t.target.value})),className:"w-full px-3 py-1.5 text-sm border border-border rounded-lg bg-background focus:outline-none focus:border-primary"}):(0,a.jsx)("input",{type:"number",value:v[e.key]??"",min:e.min,max:e.max,onChange:t=>N(s=>({...s,[e.key]:""===t.target.value?"":Number(t.target.value)})),className:"w-full px-3 py-1.5 text-sm border border-border rounded-lg bg-background focus:outline-none focus:border-primary"})},e.key)),"image"===t&&(0,a.jsx)(k,{label:"Output Format",children:(0,a.jsxs)("select",{value:D,onChange:e=>B(e.target.value),className:"w-full px-3 py-1.5 text-sm border border-border rounded-lg bg-background focus:outline-none focus:border-primary",children:[(0,a.jsx)("option",{value:"json",children:"JSON (Base64)"}),(0,a.jsx)("option",{value:"binary",children:"Binary File"})]})}),(0,a.jsxs)("div",{className:"mt-1",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between mb-1.5",children:[(0,a.jsx)("span",{className:"text-xs font-semibold text-text-muted uppercase tracking-wider",children:"Request"}),(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsxs)("button",{onClick:()=>X(ep),className:"flex items-center gap-1 text-xs text-text-muted hover:text-primary transition-colors",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:Z?"check":"content_copy"}),Z?"Copied":"Copy"]}),(0,a.jsxs)("button",{onClick:ex,disabled:J||!g.trim()||!er,className:"flex items-center gap-1.5 px-3 py-1 rounded-lg bg-primary text-white text-xs font-medium hover:bg-primary/90 transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px]",style:J?{animation:"spin 1s linear infinite"}:void 0,children:"play_arrow"}),J?"Running...":"Run"]})]})]}),(0,a.jsx)("pre",{className:"bg-sidebar rounded-lg px-3 py-2.5 text-xs font-mono text-text-main overflow-x-auto whitespace-pre",children:ep})]}),(J||K)&&en&&(0,a.jsxs)("div",{className:"flex items-center gap-3 px-3 py-2 rounded-lg bg-sidebar border border-border",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[16px] text-primary",style:J?{animation:"spin 1s linear infinite"}:void 0,children:J?"progress_activity":"check_circle"}),(0,a.jsxs)("span",{className:"text-xs text-text-muted",children:[K?.stage||"starting",!J&&K?.bytesReceived?` \xb7 ${(K.bytesReceived/1024).toFixed(1)} KB`:""]})]}),U?.b64_json&&!O&&(0,a.jsxs)("div",{children:[(0,a.jsx)("span",{className:"text-xs font-semibold text-text-muted uppercase tracking-wider",children:"Partial preview"}),(0,a.jsx)("img",{src:`data:image/png;base64,${U.b64_json}`,alt:"Partial",className:"max-w-full rounded-lg border border-border mt-1.5 opacity-80"})]}),V&&(0,a.jsx)("p",{className:"text-xs text-red-500 break-words",children:V}),(0,a.jsxs)("div",{children:[(0,a.jsxs)("div",{className:"flex items-center justify-between mb-1.5",children:[(0,a.jsxs)("span",{className:"text-xs font-semibold text-text-muted uppercase tracking-wider",children:["Response ",O&&(0,a.jsxs)("span",{className:"font-normal normal-case",children:["⚡ ",O.latencyMs,"ms"]})]}),O&&(0,a.jsxs)("button",{onClick:()=>et(em),className:"flex items-center gap-1 text-xs text-text-muted hover:text-primary transition-colors",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:ee?"check":"content_copy"}),ee?"Copied":"Copy"]})]}),(0,a.jsx)("pre",{className:"bg-sidebar rounded-lg px-3 py-2.5 text-xs font-mono text-text-main overflow-x-auto whitespace-pre opacity-70",children:O?em:o.defaultResponse}),"image"===t&&(F||O?.data?.data?.[0])&&(0,a.jsxs)("div",{className:"mt-2",children:[(0,a.jsx)("div",{className:"flex items-center justify-end mb-1.5",children:(0,a.jsxs)("a",{href:F||(O?.data?.data?.[0]?.b64_json?`data:image/png;base64,${O.data.data[0].b64_json}`:O?.data?.data?.[0]?.url||""),download:"image.png",className:"flex items-center gap-1 text-xs text-text-muted hover:text-primary transition-colors",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"download"}),"Download"]})}),(0,a.jsx)("img",{src:F||(O?.data?.data?.[0]?.b64_json?`data:image/png;base64,${O.data.data[0].b64_json}`:O?.data?.data?.[0]?.url),alt:"Generated",className:"max-w-full rounded-lg border border-border"})]})]})]})]})}function T(){let{kind:e,id:t}=(0,r.useParams)(),s=(0,r.useRouter)(),o=c.rj.find(t=>t.id===e),p=(0,c.gC)(t)&&"embedding"===e,x=async()=>{if(confirm("Delete this Custom Embedding node?"))try{(await fetch(`/api/provider-nodes/${t}`,{method:"DELETE"})).ok&&s.push(`/dashboard/media-providers/${e}`)}catch(e){console.log("Error deleting custom embedding node:",e)}},[u,m]=(0,i.useState)(null),[h,b]=(0,i.useState)(p),[g,f]=(0,i.useState)(!1);if((0,i.useEffect)(()=>{if(!p)return;let e=!1;return fetch("/api/provider-nodes",{cache:"no-store"}).then(e=>e.json()).then(s=>{e||(m((s.nodes||[]).find(e=>e.id===t)||null),b(!1))}).catch(()=>{e||b(!1)}),()=>{e=!0}},[t,p]),!o)return(0,r.notFound)();let j=c.Q2[t],N=p?u?{id:t,name:u.name||"Custom Embedding",color:"#6366F1",textIcon:"CE"}:null:j;if(!p&&!j||p&&!h&&!u)return(0,r.notFound)();if(p&&h)return(0,a.jsx)("div",{className:"text-text-muted text-sm py-12 text-center",children:"Loading..."});let w=p?["embedding"]:N.serviceKinds??["llm"];return p||w.includes(e)?(0,a.jsxs)("div",{className:"flex flex-col gap-8",children:[(0,a.jsxs)("div",{children:[(0,a.jsxs)(l(),{href:`/dashboard/media-providers/${e}`,className:"inline-flex items-center gap-1 text-sm text-text-muted hover:text-primary transition-colors mb-4",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-lg",children:"arrow_back"}),o.label]}),(0,a.jsxs)("div",{className:"flex items-center gap-4",children:[(0,a.jsx)("div",{className:"size-12 rounded-lg flex items-center justify-center shrink-0",style:{backgroundColor:`${N.color}15`},children:(0,a.jsx)(d.A,{src:`/providers/${N.id}.png`,alt:N.name,size:48,className:"object-contain rounded-lg max-w-[48px] max-h-[48px]",fallbackText:N.textIcon||N.id.slice(0,2).toUpperCase(),fallbackColor:N.color})}),(0,a.jsxs)("div",{className:"flex-1",children:[(0,a.jsxs)("div",{className:"flex items-center gap-3 flex-wrap",children:[(0,a.jsx)("h1",{className:"text-3xl font-semibold tracking-tight",children:N.name}),!p&&N.notice?.apiKeyUrl&&(0,a.jsxs)("a",{href:N.notice.apiKeyUrl,target:"_blank",rel:"noopener noreferrer",className:"text-xs text-primary hover:underline inline-flex items-center gap-1",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-sm",children:"open_in_new"}),"Get API Key"]})]}),(0,a.jsxs)("div",{className:"flex items-center gap-1.5 mt-1 flex-wrap",children:[p&&(0,a.jsxs)(n.Ex,{variant:"default",size:"sm",children:["Custom \xb7 ",u?.prefix]}),w.map(t=>(0,a.jsx)(n.Ex,{variant:t===e?"primary":"default",size:"sm",children:t.toUpperCase()},t))]})]}),p&&(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)(n.$n,{size:"sm",variant:"secondary",icon:"edit",onClick:()=>f(!0),children:"Edit"}),(0,a.jsx)(n.$n,{size:"sm",variant:"secondary",icon:"delete",onClick:x,children:"Delete"})]})]})]}),!p&&N.kindNotice?.[e]&&(0,a.jsxs)("div",{className:"flex items-start gap-3 px-4 py-3 rounded-lg bg-amber-500/10 border border-amber-500/30 text-amber-700 dark:text-amber-400",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[20px] mt-0.5",children:"warning"}),(0,a.jsx)("p",{className:"text-sm",children:N.kindNotice[e]})]}),!p&&N.notice?.text&&!N.deprecated&&(0,a.jsxs)("div",{className:"flex flex-col gap-2 rounded-lg border border-blue-500/30 bg-blue-500/10 px-3 py-2 sm:flex-row sm:items-center",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[16px] text-blue-500 shrink-0",children:"info"}),(0,a.jsx)("p",{className:"min-w-0 flex-1 text-xs leading-relaxed text-blue-600 dark:text-blue-400",children:N.notice.text}),N.notice.apiKeyUrl&&(0,a.jsx)("a",{href:N.notice.apiKeyUrl,target:"_blank",rel:"noopener noreferrer",className:"inline-flex justify-center rounded bg-blue-500 px-2 py-1 text-xs font-medium text-white transition-colors hover:bg-blue-600 sm:py-0.5",children:"Get API Key →"})]}),!p&&N.noAuth?(0,a.jsx)(n.gw,{providerId:t}):(0,a.jsx)(y,{providerId:t,isOAuth:!1}),"tts"!==e&&"webSearch"!==e&&"webFetch"!==e&&(0,a.jsx)(v,{providerId:t,kindFilter:e,providerAliasOverride:p?u?.prefix:void 0}),!p&&(N.searchConfig||N.fetchConfig||N.ttsConfig||N.embeddingConfig||N.searchViaChat)&&(0,a.jsx)(n.Wx,{config:"webFetch"===e?N.fetchConfig:"tts"===e?N.ttsConfig:"embedding"===e?N.embeddingConfig:N.searchConfig||{mode:"chat-completions",defaultModel:N.searchViaChat?.defaultModel,pricingUrl:N.searchViaChat?.pricingUrl,freeTier:N.searchViaChat?.freeTier},provider:N,title:`${o.label} Config`}),"embedding"===e&&(0,a.jsx)(P,{providerId:t,customAlias:u?.prefix}),"tts"===e&&(0,a.jsx)(A,{providerId:t}),!p&&$[e]&&(0,a.jsx)(R,{providerId:t,kind:e}),p&&(0,a.jsx)(n.x0,{isOpen:g,node:u,onClose:()=>f(!1),onSaved:e=>{m(e),f(!1)}})]}):(0,r.notFound)()}}},e=>{e.O(0,[7848,4335,6795,505,4156,2347,5158,7358],()=>e(e.s=597)),_N_E=e.O()}]);
@@ -1 +0,0 @@
1
- (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[6620],{20021:(e,s,t)=>{Promise.resolve().then(t.bind(t,47432))},47432:(e,s,t)=>{"use strict";t.r(s),t.d(s,{default:()=>h});var r=t(73365),i=t(29717),n=t(99568),d=t.n(n),a=t(1521),c=t(74156),o=t(68266),l=t(82495);function x(e){let s=Object.entries(e).some(([e,s])=>e.startsWith("modelLock_")&&s&&new Date(s).getTime()>Date.now());return"unavailable"!==e.testStatus||s?e.testStatus:"active"}function m({provider:e,kind:s,connections:t,isCustom:i}){let n=l.Q2[e.id],a=!!n?.noAuth,h=t.filter(s=>s.provider===e.id),u=h.filter(e=>{let s=x(e);return"active"===s||"success"===s}).length,p=h.filter(e=>{let s=x(e);return"error"===s||"expired"===s||"unavailable"===s}).length,f=h.length,v=f>0&&h.every(e=>!1===e.isActive);return(0,r.jsx)(d(),{href:`/dashboard/media-providers/${s}/${e.id}`,className:"group",children:(0,r.jsx)(c.Zp,{padding:"xs",className:`h-full hover:bg-black/[0.01] dark:hover:bg-white/[0.01] transition-colors cursor-pointer ${v?"opacity-50":""}`,children:(0,r.jsxs)("div",{className:"flex items-center gap-3",children:[(0,r.jsx)("div",{className:"size-8 rounded-lg flex items-center justify-center shrink-0",style:{backgroundColor:`${e.color?.length>7?e.color:(e.color??"#888")+"15"}`},children:(0,r.jsx)(o.A,{src:`/providers/${e.id}.png`,alt:e.name,size:30,className:"object-contain rounded-lg max-w-[30px] max-h-[30px]",fallbackText:e.textIcon||e.id.slice(0,2).toUpperCase(),fallbackColor:e.color})}),(0,r.jsxs)("div",{children:[(0,r.jsx)("h3",{className:"font-semibold text-sm",children:e.name}),(0,r.jsxs)("div",{className:"flex items-center gap-2 mt-0.5 flex-wrap",children:[i&&(0,r.jsx)(c.Ex,{variant:"default",size:"sm",children:"Custom"}),a?(0,r.jsx)(c.Ex,{variant:"success",size:"sm",children:"Ready"}):v?(0,r.jsx)(c.Ex,{variant:"default",size:"sm",children:"Disabled"}):0===f?(0,r.jsx)("span",{className:"text-xs text-text-muted",children:"No connections"}):(0,r.jsxs)(r.Fragment,{children:[u>0&&(0,r.jsxs)(c.Ex,{variant:"success",size:"sm",dot:!0,children:[u," Connected"]}),p>0&&(0,r.jsxs)(c.Ex,{variant:"error",size:"sm",dot:!0,children:[p," Error"]}),0===u&&0===p&&(0,r.jsxs)(c.Ex,{variant:"default",size:"sm",children:[f," Added"]})]})]})]})]})})})}function h(){let{kind:e}=(0,i.useParams)(),s=(0,i.useRouter)(),[t,n]=(0,a.useState)([]),[d,o]=(0,a.useState)([]),[x,h]=(0,a.useState)(!1);(0,a.useEffect)(()=>{("webSearch"===e||"webFetch"===e)&&s.replace("/dashboard/media-providers/web")},[e,s]);let u=l.rj.find(s=>s.id===e),p="embedding"===e;if((0,a.useEffect)(()=>{u&&(fetch("/api/providers",{cache:"no-store"}).then(e=>e.json()).then(e=>n(e.connections||[])).catch(()=>{}),p&&fetch("/api/provider-nodes",{cache:"no-store"}).then(e=>e.json()).then(e=>o((e.nodes||[]).filter(e=>"custom-embedding"===e.type))).catch(()=>{}))},[p,u]),!u)return(0,i.notFound)();let f=(0,l.o5)(e),v=d.map(e=>({id:e.id,name:e.name||"Custom Embedding",color:"#6366F1",textIcon:"CE"})),j=[...f,...v];return(0,r.jsxs)("div",{className:"flex flex-col gap-6",children:[p&&(0,r.jsx)("div",{className:"flex items-center justify-end",children:(0,r.jsx)(c.$n,{size:"sm",icon:"add",onClick:()=>h(!0),children:"Add Custom Embedding"})}),0===j.length?(0,r.jsxs)("div",{className:"text-center py-12 border border-dashed border-border rounded-xl text-text-muted text-sm",children:["No providers support ",(0,r.jsx)("strong",{children:u.label})," yet."]}):(0,r.jsxs)("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-4",children:[f.map(s=>(0,r.jsx)(m,{provider:s,kind:e,connections:t},s.id)),v.map(s=>(0,r.jsx)(m,{provider:s,kind:e,connections:t,isCustom:!0},s.id))]}),p&&(0,r.jsx)(c.x0,{isOpen:x,onClose:()=>h(!1),onCreated:e=>{o(s=>[...s,e]),h(!1)}})]})}}},e=>{e.O(0,[7848,4335,6795,505,4156,2347,5158,7358],()=>e(e.s=20021)),_N_E=e.O()}]);
@@ -1,4 +0,0 @@
1
- (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[4701],{13648:(e,t,s)=>{Promise.resolve().then(s.bind(s,83307))},83307:(e,t,s)=>{"use strict";s.r(t),s.d(t,{default:()=>b});var a=s(73365),r=s(29717),n=s(1521),l=s(99568),i=s.n(l),o=s(74156),c=s(68266),d=s(82495);let m=/^[a-zA-Z0-9_.\-]+$/,x={webSearch:"Web Search",webFetch:"Web Fetch"},h={webSearch:"/v1/search",webFetch:"/v1/web/fetch"},u={webSearch:e=>({model:e,query:"What is the latest news about AI?",search_type:"web",max_results:5}),webFetch:e=>({model:e,url:"https://example.com",format:"markdown"})};function p({isOpen:e,onClose:t,onPick:s,kind:r,currentIds:n,connections:l}){let i=new Set((l||[]).filter(e=>{if(!1===e.isActive)return!1;let t=e.testStatus;return"active"===t||"success"===t||"unavailable"===t}).map(e=>e.provider)),m=(r?(0,d.o5)(r):[]).filter(e=>e.noAuth||i.has(e.id));return(0,a.jsx)(o.aF,{isOpen:e,onClose:t,title:`Add ${x[r]||""} Provider`,size:"md",children:0===m.length?(0,a.jsxs)("div",{className:"text-center py-6 text-sm text-text-muted",children:["No connected providers available. Add a connection first in the ",x[r]," section."]}):(0,a.jsx)("div",{className:"grid grid-cols-2 sm:grid-cols-3 gap-2 max-h-[400px] overflow-y-auto",children:m.map(e=>{let r=n.includes(e.id);return(0,a.jsxs)("button",{disabled:r,onClick:()=>{s(e.id),t()},className:`flex items-center gap-2 p-2 rounded-lg border transition-colors ${r?"border-border opacity-40 cursor-not-allowed":"border-border hover:border-primary/50 hover:bg-primary/5 cursor-pointer"}`,children:[(0,a.jsx)(c.A,{src:`/providers/${e.id}.png`,alt:e.name,size:24,className:"object-contain rounded shrink-0",fallbackText:e.textIcon||e.id.slice(0,2).toUpperCase(),fallbackColor:e.color}),(0,a.jsx)("span",{className:"text-xs font-medium truncate text-left",children:e.name}),r&&(0,a.jsx)("span",{className:"text-[9px] text-text-muted ml-auto",children:"added"})]},e.id)})})})}function b(){let{id:e}=(0,r.useParams)(),t=(0,r.useRouter)(),[s,l]=(0,n.useState)(null),[b,f]=(0,n.useState)(!0),[j,g]=(0,n.useState)(""),[w,v]=(0,n.useState)(""),[N,y]=(0,n.useState)([]),[k,S]=(0,n.useState)(!1),[C,$]=(0,n.useState)(!1),[_,O]=(0,n.useState)([]),[A,T]=(0,n.useState)(!1),[P,E]=(0,n.useState)(""),[z,R]=(0,n.useState)(""),[F,J]=(0,n.useState)([]),U=async()=>{try{let[t,s,a,r,n]=await Promise.all([fetch(`/api/combos/${e}`,{cache:"no-store"}),fetch("/api/settings",{cache:"no-store"}),fetch("/api/usage/logs",{cache:"no-store"}),fetch("/api/keys",{cache:"no-store"}),fetch("/api/providers",{cache:"no-store"})]);if(r.ok){let e=await r.json();R((e.keys||[]).find(e=>!1!==e.isActive)?.key||"")}if(n.ok&&J((await n.json()).connections||[]),!t.ok){l(null),f(!1);return}let i=await t.json();l(i),g(i.name),y(i.models||[]);let o=s.ok?await s.json():{};S(o.comboStrategies?.[i.name]?.fallbackStrategy==="round-robin");let c=a.ok?await a.json():[];O(c.filter(e=>"string"==typeof e&&e.includes(i.name)).slice(0,50))}catch{}f(!1)};(0,n.useEffect)(()=>{U()},[e]);let Z=e=>e.trim()?m.test(e)?(v(""),!0):(v("Only letters, numbers, -, _ and ."),!1):(v("Name is required"),!1),I=async t=>{let s=await fetch(`/api/combos/${e}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});return!!s.ok||(alert((await s.json()).error||"Failed to save"),!1)},W=async()=>{!Z(j)||j===s.name||await I({name:j})&&await U()},q=async e=>{let t=[...N,e];y(t),await I({models:t})},B=async e=>{let t=N.filter((t,s)=>s!==e);y(t),await I({models:t})},D=async(e,t)=>{let s=[...N],a=e+t;a<0||a>=s.length||([s[e],s[a]]=[s[a],s[e]],y(s),await I({models:s}))},H=async e=>{S(e);let t=await fetch("/api/settings",{cache:"no-store"}),a={...(t.ok?await t.json():{}).comboStrategies||{}};e?a[s.name]={fallbackStrategy:"round-robin"}:delete a[s.name],await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({comboStrategies:a})})},L=async()=>{!confirm(`Delete combo "${s.name}"?`)||(await fetch(`/api/combos/${e}`,{method:"DELETE"})).ok&&t.push("/dashboard/media-providers/web")},M=async()=>{T(!0),E("");try{let e=h[s.kind],t=u[s.kind](s.name),a={"Content-Type":"application/json"};z&&(a.Authorization=`Bearer ${z}`);let r=await fetch(`/api${e}`,{method:"POST",headers:a,body:JSON.stringify(t)}),n=await r.json().catch(()=>({}));E(JSON.stringify(n,null,2))}catch(e){E(`Error: ${e.message}`)}T(!1)};if(b)return(0,a.jsx)("div",{className:"text-text-muted text-sm",children:"Loading..."});if(!s)return(0,r.notFound)();let Y=x[s.kind]||"Web",K=h[s.kind],Q=s.kind?u[s.kind](s.name):null,X=K?`curl -X POST http://localhost:20128${K} \\
2
- -H "Content-Type: application/json" \\
3
- -H "Authorization: Bearer ${z||"YOUR_KEY"}" \\
4
- -d '${JSON.stringify(Q)}'`:"";return(0,a.jsxs)("div",{className:"flex flex-col gap-6",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between gap-4",children:[(0,a.jsxs)("div",{className:"flex items-center gap-3 min-w-0",children:[(0,a.jsx)(i(),{href:"/dashboard/media-providers/web",className:"text-text-muted hover:text-primary",children:(0,a.jsx)("span",{className:"material-symbols-outlined",children:"arrow_back"})}),(0,a.jsx)("div",{className:"size-10 rounded-lg bg-primary/10 flex items-center justify-center",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-primary",children:"layers"})}),(0,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsxs)("p",{className:"text-xs text-text-muted",children:[Y," Combo"]}),(0,a.jsx)("code",{className:"text-lg font-semibold font-mono",children:s.name})]})]}),(0,a.jsx)(o.$n,{variant:"outline",icon:"delete",onClick:L,className:"text-red-500 border-red-200 hover:bg-red-50",children:"Delete"})]}),(0,a.jsxs)(o.Zp,{children:[(0,a.jsx)("h2",{className:"text-lg font-semibold mb-3",children:"Settings"}),(0,a.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)(o.pd,{label:"Combo Name",value:j,onChange:e=>{g(e.target.value),Z(e.target.value)},onBlur:W,error:w}),(0,a.jsx)("p",{className:"text-[10px] text-text-muted mt-0.5",children:"Only letters, numbers, -, _ and ."})]}),(0,a.jsxs)("div",{className:"flex items-center justify-between",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("p",{className:"text-sm font-medium",children:"Round Robin"}),(0,a.jsx)("p",{className:"text-xs text-text-muted",children:"Rotate providers across requests instead of strict fallback order."})]}),(0,a.jsx)(o.lM,{checked:k,onChange:H})]})]})]}),(0,a.jsxs)(o.Zp,{children:[(0,a.jsxs)("div",{className:"flex items-center justify-between mb-3",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("h2",{className:"text-lg font-semibold",children:"Providers"}),(0,a.jsx)("p",{className:"text-xs text-text-muted",children:"Tried in order (top-down) or rotated when round-robin is on."})]}),(0,a.jsx)(o.$n,{size:"sm",icon:"add",onClick:()=>$(!0),children:"Add Provider"})]}),0===N.length?(0,a.jsx)("div",{className:"text-center py-6 border border-dashed border-border rounded-lg text-text-muted text-sm",children:"No providers yet."}):(0,a.jsx)("div",{className:"flex flex-col gap-2",children:N.map((e,t)=>{let s=d.Q2[e];return(0,a.jsxs)("div",{className:"flex items-center gap-3 p-2 rounded-lg bg-black/[0.02] dark:bg-white/[0.02]",children:[(0,a.jsx)("span",{className:"text-xs text-text-muted w-5 text-center",children:t+1}),(0,a.jsx)(c.A,{src:`/providers/${e}.png`,alt:s?.name||e,size:24,className:"object-contain rounded shrink-0",fallbackText:s?.textIcon||e.slice(0,2).toUpperCase(),fallbackColor:s?.color}),(0,a.jsx)("span",{className:"text-sm font-medium flex-1 truncate",children:s?.name||e}),(0,a.jsxs)("div",{className:"flex items-center gap-0.5",children:[(0,a.jsx)("button",{onClick:()=>D(t,-1),disabled:0===t,className:`p-1 rounded ${0===t?"text-text-muted/20":"text-text-muted hover:text-primary hover:bg-black/5"}`,title:"Move up",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[16px]",children:"arrow_upward"})}),(0,a.jsx)("button",{onClick:()=>D(t,1),disabled:t===N.length-1,className:`p-1 rounded ${t===N.length-1?"text-text-muted/20":"text-text-muted hover:text-primary hover:bg-black/5"}`,title:"Move down",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[16px]",children:"arrow_downward"})}),(0,a.jsx)("button",{onClick:()=>B(t),className:"p-1 rounded text-text-muted hover:text-red-500 hover:bg-red-500/10",title:"Remove",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[16px]",children:"close"})})]})]},`${e}-${t}`)})})]}),s.kind&&(0,a.jsxs)(o.Zp,{children:[(0,a.jsxs)("div",{className:"flex items-center justify-between mb-3",children:[(0,a.jsx)("h2",{className:"text-lg font-semibold",children:"Test Example"}),(0,a.jsx)(o.$n,{size:"sm",icon:"play_arrow",onClick:M,disabled:A||0===N.length,children:A?"Running...":"Run"})]}),(0,a.jsx)("pre",{className:"text-xs font-mono bg-black/[0.03] dark:bg-white/[0.03] p-3 rounded-lg overflow-x-auto whitespace-pre-wrap break-all",children:X}),P&&(0,a.jsx)("pre",{className:"mt-3 text-xs font-mono bg-black/[0.03] dark:bg-white/[0.03] p-3 rounded-lg overflow-auto max-h-[300px]",children:P})]}),(0,a.jsxs)(o.Zp,{children:[(0,a.jsx)("h2",{className:"text-lg font-semibold mb-3",children:"Usage Logs"}),0===_.length?(0,a.jsx)("p",{className:"text-xs text-text-muted italic",children:"No usage yet."}):(0,a.jsx)("pre",{className:"text-[11px] font-mono bg-black/[0.03] dark:bg-white/[0.03] p-3 rounded-lg overflow-auto max-h-[400px] whitespace-pre-wrap",children:_.join("\n")})]}),(0,a.jsx)(p,{isOpen:C,onClose:()=>$(!1),onPick:q,kind:s.kind,currentIds:N,connections:F})]})}}},e=>{e.O(0,[7848,4335,6795,505,4156,2347,5158,7358],()=>e(e.s=13648)),_N_E=e.O()}]);
@@ -1 +0,0 @@
1
- (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[9260],{51181:(e,s,t)=>{Promise.resolve().then(t.bind(t,69640))},69640:(e,s,t)=>{"use strict";t.r(s),t.d(s,{default:()=>p});var r=t(73365),a=t(99568),i=t.n(a),l=t(1521),c=t(29717),o=t(74156),n=t(68266),d=t(82495);function m(e){let s=Object.entries(e).some(([e,s])=>e.startsWith("modelLock_")&&s&&new Date(s).getTime()>Date.now());return"unavailable"!==e.testStatus||s?e.testStatus:"active"}function x({provider:e,kind:s,connections:t}){let a=d.Q2[e.id],l=!!a?.noAuth,c=t.filter(s=>s.provider===e.id),h=c.filter(e=>{let s=m(e);return"active"===s||"success"===s}).length,b=c.filter(e=>{let s=m(e);return"error"===s||"expired"===s||"unavailable"===s}).length,p=c.length,u=p>0&&c.every(e=>!1===e.isActive);return(0,r.jsx)(i(),{href:`/dashboard/media-providers/${s}/${e.id}`,className:"group",children:(0,r.jsx)(o.Zp,{padding:"xs",className:`h-full hover:bg-black/[0.01] dark:hover:bg-white/[0.01] transition-colors cursor-pointer ${u?"opacity-50":""}`,children:(0,r.jsxs)("div",{className:"flex items-center gap-3",children:[(0,r.jsx)("div",{className:"size-8 rounded-lg flex items-center justify-center shrink-0",style:{backgroundColor:`${e.color?.length>7?e.color:(e.color??"#888")+"15"}`},children:(0,r.jsx)(n.A,{src:`/providers/${e.id}.png`,alt:e.name,size:30,className:"object-contain rounded-lg max-w-[30px] max-h-[30px]",fallbackText:e.textIcon||e.id.slice(0,2).toUpperCase(),fallbackColor:e.color})}),(0,r.jsxs)("div",{children:[(0,r.jsx)("h3",{className:"font-semibold text-sm",children:e.name}),(0,r.jsx)("div",{className:"flex items-center gap-2 mt-0.5 flex-wrap",children:l?(0,r.jsx)(o.Ex,{variant:"success",size:"sm",children:"Ready"}):u?(0,r.jsx)(o.Ex,{variant:"default",size:"sm",children:"Disabled"}):0===p?(0,r.jsx)("span",{className:"text-xs text-text-muted",children:"No connections"}):(0,r.jsxs)(r.Fragment,{children:[h>0&&(0,r.jsxs)(o.Ex,{variant:"success",size:"sm",dot:!0,children:[h," Connected"]}),b>0&&(0,r.jsxs)(o.Ex,{variant:"error",size:"sm",dot:!0,children:[b," Error"]}),0===h&&0===b&&(0,r.jsxs)(o.Ex,{variant:"default",size:"sm",children:[p," Added"]})]})})]})]})})})}function h({combos:e}){return 0===e.length?(0,r.jsx)("p",{className:"text-xs text-text-muted italic",children:"No combos yet."}):(0,r.jsx)("div",{className:"flex flex-col gap-2",children:e.map(e=>(0,r.jsx)(i(),{href:`/dashboard/media-providers/web/combo/${e.id}`,children:(0,r.jsx)(o.Zp,{padding:"xs",className:"hover:bg-black/[0.02] dark:hover:bg-white/[0.02] transition-colors cursor-pointer",children:(0,r.jsxs)("div",{className:"flex items-center gap-3",children:[(0,r.jsx)("span",{className:"material-symbols-outlined text-primary text-[18px]",children:"layers"}),(0,r.jsx)("code",{className:"text-sm font-mono font-medium flex-1 truncate",children:e.name}),(0,r.jsxs)("div",{className:"flex items-center gap-1 shrink-0",children:[e.models.slice(0,6).map((e,s)=>{let t=d.Q2[e];return(0,r.jsx)("div",{title:t?.name||e,className:"size-5 rounded flex items-center justify-center",style:{backgroundColor:`${t?.color??"#888"}15`},children:(0,r.jsx)(n.A,{src:`/providers/${e}.png`,alt:t?.name||e,size:18,className:"object-contain rounded max-w-[18px] max-h-[18px]",fallbackText:t?.textIcon||e.slice(0,2).toUpperCase(),fallbackColor:t?.color})},`${e}-${s}`)}),e.models.length>6&&(0,r.jsxs)("span",{className:"text-[10px] text-text-muted ml-1",children:["+",e.models.length-6]})]}),(0,r.jsx)("span",{className:"text-[11px] text-text-muted shrink-0",children:e.models.length}),(0,r.jsx)("span",{className:"material-symbols-outlined text-text-muted text-[16px]",children:"chevron_right"})]})})},e.id))})}function b({title:e,icon:s,kind:t,providers:a,connections:i,combos:l,onCreateCombo:c}){return(0,r.jsxs)("div",{children:[(0,r.jsxs)("div",{className:"flex items-center justify-between mb-3",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("span",{className:"material-symbols-outlined text-primary",children:s}),(0,r.jsx)("h2",{className:"text-base font-semibold",children:e}),(0,r.jsxs)("span",{className:"text-xs text-text-muted",children:["(",a.length," providers \xb7 ",l.length," combos)"]})]}),(0,r.jsx)(o.$n,{size:"sm",icon:"add",onClick:c,children:"Create Combo"})]}),l.length>0&&(0,r.jsx)("div",{className:"mb-4",children:(0,r.jsx)(h,{combos:l})}),0===a.length?(0,r.jsx)("div",{className:"text-center py-8 border border-dashed border-border rounded-xl text-text-muted text-sm",children:"No providers."}):(0,r.jsx)("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-4",children:a.map(e=>(0,r.jsx)(x,{provider:e,kind:t,connections:i},e.id))})]})}function p(){let e=(0,c.useRouter)(),[s,t]=(0,l.useState)([]),[a,i]=(0,l.useState)([]),o=async()=>{try{let[e,s]=await Promise.all([fetch("/api/providers",{cache:"no-store"}),fetch("/api/combos",{cache:"no-store"})]);e.ok&&t((await e.json()).connections||[]),s.ok&&i((await s.json()).combos||[])}catch{}};(0,l.useEffect)(()=>{o()},[]);let n=(0,d.o5)("webSearch"),m=(0,d.o5)("webFetch"),x=a.filter(e=>"webSearch"===e.kind),h=a.filter(e=>"webFetch"===e.kind),p=async s=>{let t="webSearch"===s?"search-combo":"fetch-combo",r=t,i=1,l=new Set(a.map(e=>e.name));for(;l.has(r);)r=`${t}-${i++}`;let c=await fetch("/api/combos",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:r,models:[],kind:s})});if(c.ok){let s=await c.json();e.push(`/dashboard/media-providers/web/combo/${s.id}`)}else alert((await c.json()).error||"Failed to create combo")};return(0,r.jsxs)("div",{className:"flex flex-col gap-8",children:[(0,r.jsx)(b,{title:"Web Search",icon:"search",kind:"webSearch",providers:n,connections:s,combos:x,onCreateCombo:()=>p("webSearch")}),(0,r.jsx)("div",{className:"border-t border-border"}),(0,r.jsx)(b,{title:"Web Fetch",icon:"travel_explore",kind:"webFetch",providers:m,connections:s,combos:h,onCreateCombo:()=>p("webFetch")})]})}}},e=>{e.O(0,[7848,4335,6795,505,4156,2347,5158,7358],()=>e(e.s=51181)),_N_E=e.O()}]);
@@ -1 +0,0 @@
1
- (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[6607],{71103:(e,t,s)=>{"use strict";s.d(t,{default:()=>d});var a=s(73365),i=s(1521),n=s(97990),l=s(69633),c=s(82495),o=s(7127);function d(){let[e,t]=(0,i.useState)([]),[s,d]=(0,i.useState)([]),[r,u]=(0,i.useState)({}),[h,x]=(0,i.useState)(!1),[p,f]=(0,i.useState)(null),[m,w]=(0,i.useState)({running:!1,certExists:!1,dnsStatus:{},hasCachedPassword:!1});(0,i.useEffect)(()=>{g(),v(),S(),j()},[]);let g=async()=>{try{let e=await fetch("/api/providers");if(e.ok){let s=await e.json();t(s.connections||[])}}catch{}},v=async()=>{try{let e=await fetch("/api/keys");if(e.ok){let t=await e.json();d(t.keys||[])}}catch{}},S=async()=>{try{let e=await fetch("/api/models/alias");if(e.ok){let t=await e.json();u(t.aliases||{})}}catch{}},j=async()=>{try{let e=await fetch("/api/settings");if(e.ok){let t=await e.json();x(t.cloudEnabled||!1)}}catch{}},y=()=>e.filter(e=>!1!==e.isActive),k=Object.entries(n.wn);return(0,a.jsxs)("div",{className:"mx-auto flex w-full max-w-5xl flex-col gap-6 px-1 sm:px-0",children:[(0,a.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,a.jsx)("h1",{className:"text-xl font-semibold text-text-main sm:text-2xl",children:"MITM"}),(0,a.jsx)("p",{className:"text-sm text-text-muted",children:"Route supported IDE traffic through 9Router with local DNS interception."})]}),(0,a.jsx)(o.tA,{apiKeys:s,cloudEnabled:h,onStatusChange:w}),(0,a.jsx)("div",{className:"grid gap-3 sm:gap-4",children:k.map(([e,t])=>(0,a.jsx)(o.kn,{tool:t,isExpanded:p===e,onToggle:()=>f(p===e?null:e),serverRunning:m.running,dnsActive:m.dnsStatus?.[e]||!1,hasCachedPassword:m.hasCachedPassword||!1,apiKeys:s,activeProviders:y(),hasActiveProviders:y().some(e=>(0,l.KC)(e.provider).length>0||(0,c.mq)(e.provider)||(0,c.gb)(e.provider)),modelAliases:r,cloudEnabled:h,onDnsChange:e=>w(t=>({...t,dnsStatus:e.dnsStatus??t.dnsStatus}))},e))})]})}},85999:(e,t,s)=>{Promise.resolve().then(s.bind(s,71103))}},e=>{e.O(0,[7848,4335,6795,8872,505,4156,4380,2347,5158,7358],()=>e(e.s=85999)),_N_E=e.O()}]);
@@ -1 +0,0 @@
1
- (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[2825],{33154:(e,t,s)=>{Promise.resolve().then(s.bind(s,83101))},83101:(e,t,s)=>{"use strict";s.r(t),s.d(t,{default:()=>v});var a=s(73365),l=s(1521),n=s(29717),r=s(74156),i=s(292),d=s(38230),o=s(87706);function c({isOpen:e,onClose:t,title:s,children:n,width:r="md",className:i}){let d={sm:"w-[400px]",md:"w-[500px]",lg:"w-[600px]",xl:"w-[800px]",full:"w-full"};return((0,l.useEffect)(()=>(e?document.body.style.overflow="hidden":document.body.style.overflow="",()=>{document.body.style.overflow=""}),[e]),(0,l.useEffect)(()=>{let s=s=>{"Escape"===s.key&&e&&t()};return document.addEventListener("keydown",s),()=>document.removeEventListener("keydown",s)},[e,t]),e)?(0,a.jsxs)("div",{className:"fixed inset-0 z-50",children:[(0,a.jsx)("div",{className:"absolute inset-0 bg-black/50 backdrop-blur-sm transition-opacity cursor-pointer",onClick:t,"aria-hidden":"true"}),(0,a.jsxs)("div",{className:(0,o.cn)("absolute right-0 top-0 h-full bg-surface shadow-2xl flex flex-col","animate-in slide-in-from-right duration-200","border-l border-black/10 dark:border-white/10",d[r]||d.md,i),children:[(0,a.jsxs)("div",{className:"flex items-center justify-between p-6 border-b border-black/5 dark:border-white/5 flex-shrink-0",children:[(0,a.jsx)("div",{className:"flex items-center gap-3",children:s&&(0,a.jsx)("h2",{className:"text-lg font-semibold text-text-main",children:s})}),(0,a.jsx)("button",{type:"button",onClick:t,className:"p-1.5 rounded-lg text-text-muted hover:bg-black/5 dark:hover:bg-white/5 transition-colors",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[20px]",children:"close"})})]}),(0,a.jsx)("div",{className:"flex-1 overflow-y-auto p-6",children:n})]})]}):null}function x({currentPage:e,pageSize:t,totalItems:s,onPageChange:l,onPageSizeChange:n,className:r}){let i=Math.ceil(s/t),c=s>0?(e-1)*t+1:0,m=Math.min(e*t,s),h=(()=>{let t=[],s=Math.max(1,e-2),a=Math.min(i,s+5-1);a-s+1<5&&(s=Math.max(1,a-5+1));for(let e=s;e<=a;e++)t.push(e);return t})();return(0,a.jsxs)("div",{className:(0,o.cn)("flex flex-col sm:flex-row items-center justify-between gap-4 py-4",r),children:[s>0&&(0,a.jsxs)("div",{className:"text-sm text-text-muted",children:["Showing ",(0,a.jsx)("span",{className:"font-medium text-text-main",children:c})," to"," ",(0,a.jsx)("span",{className:"font-medium text-text-main",children:m})," of"," ",(0,a.jsx)("span",{className:"font-medium text-text-main",children:s})," results"]}),(0,a.jsxs)("div",{className:"flex items-center gap-4",children:[n&&(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("span",{className:"text-sm text-text-muted",children:"Rows:"}),(0,a.jsx)("select",{value:t,onChange:e=>n(Number(e.target.value)),className:(0,o.cn)("h-9 rounded-lg border border-black/10 dark:border-white/10 bg-surface","text-sm text-text-main focus:outline-none focus:ring-2 focus:ring-primary/20","cursor-pointer"),children:[10,20,50].map(e=>(0,a.jsx)("option",{value:e,children:e},e))})]}),i>1&&(0,a.jsxs)("div",{className:"flex items-center gap-1",children:[(0,a.jsx)(d.default,{variant:"outline",size:"sm",onClick:()=>l(e-1),disabled:1===e,className:"w-9 px-0",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:"chevron_left"})}),h[0]>1&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(d.default,{variant:"ghost",size:"sm",onClick:()=>l(1),className:"w-9 px-0",children:"1"}),h[0]>2&&(0,a.jsx)("span",{className:"text-text-muted px-1",children:"..."})]}),h.map(t=>(0,a.jsx)(d.default,{variant:e===t?"primary":"ghost",size:"sm",onClick:()=>l(t),className:"w-9 px-0",children:t},t)),h[h.length-1]<i&&(0,a.jsxs)(a.Fragment,{children:[h[h.length-1]<i-1&&(0,a.jsx)("span",{className:"text-text-muted px-1",children:"..."}),(0,a.jsx)(d.default,{variant:"ghost",size:"sm",onClick:()=>l(i),className:"w-9 px-0",children:i})]}),(0,a.jsx)(d.default,{variant:"outline",size:"sm",onClick:()=>l(e+1),disabled:e===i,className:"w-9 px-0",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:"chevron_right"})})]})]})]})}var m=s(82495);let h=null,p=null;async function u(){if(h&&p)return{providerNameCache:h,providerNodesCache:p};let e=await fetch("/api/provider-nodes"),t=(await e.json()).nodes||[];for(let e of(p={},t))p[e.id]=e.name;return{providerNameCache:h={...m.Q2,...p},providerNodesCache:p}}function f(e,t){if(!e||!t)return e;let s=t[e];if("string"==typeof s)return s;if(s?.name)return s.name;let a=(0,m.zt)(e)||m.Q2[e];return a?.name||e}function b({title:e,children:t,defaultOpen:s=!1,icon:n=null}){let[r,i]=(0,l.useState)(s);return(0,a.jsxs)("div",{className:"border border-black/5 dark:border-white/5 rounded-lg overflow-hidden",children:[(0,a.jsxs)("button",{type:"button",onClick:()=>i(!r),className:"w-full flex items-center justify-between p-3 bg-black/[0.02] dark:bg-white/[0.02] hover:bg-black/[0.04] dark:hover:bg-white/[0.04] transition-colors",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[n&&(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px] text-text-muted",children:n}),(0,a.jsx)("span",{className:"font-semibold text-sm text-text-main",children:e})]}),(0,a.jsx)("span",{className:(0,o.cn)("material-symbols-outlined text-[20px] text-text-muted transition-transform duration-200",r?"rotate-90":""),children:"chevron_right"})]}),r&&(0,a.jsx)("div",{className:"p-4 border-t border-black/5 dark:border-white/5",children:t})]})}function g(e){let t=e?.prompt_tokens||e?.input_tokens||0,s=e?.cached_tokens||e?.cache_read_input_tokens||0;return t<s?s:t}function j(){let[e,t]=(0,l.useState)([]),[s,n]=(0,l.useState)({page:1,pageSize:20,totalItems:0,totalPages:0}),[r,m]=(0,l.useState)(!1),[h,p]=(0,l.useState)(null),[j,v]=(0,l.useState)(!1),[N,w]=(0,l.useState)([]),[k,y]=(0,l.useState)(null),[S,C]=(0,l.useState)({provider:"",startDate:"",endDate:""}),D=(0,l.useCallback)(async()=>{try{let e=await fetch("/api/usage/providers"),t=await e.json();w(t.providers||[]);let s=await u();y(s.providerNameCache)}catch(e){console.error("Failed to fetch providers:",e)}},[]),_=(0,l.useCallback)(async()=>{m(!0);try{let e=new URLSearchParams({page:s.page.toString(),pageSize:s.pageSize.toString()});S.provider&&e.append("provider",S.provider),S.startDate&&e.append("startDate",S.startDate),S.endDate&&e.append("endDate",S.endDate);let a=await fetch(`/api/usage/request-details?${e}`),l=await a.json();t(l.details||[]),n(e=>({...e,...l.pagination}))}catch(e){console.error("Failed to fetch request details:",e)}finally{m(!1)}},[s.page,s.pageSize,S]);return(0,l.useEffect)(()=>{D()},[D]),(0,l.useEffect)(()=>{_()},[_]),(0,a.jsxs)("div",{className:"flex min-w-0 flex-col gap-6",children:[(0,a.jsx)(i.default,{padding:"md",children:(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-4",children:[(0,a.jsxs)("div",{className:"flex min-w-0 flex-col gap-2",children:[(0,a.jsx)("label",{htmlFor:"provider-filter",className:"text-sm font-medium text-text-main",children:"Provider"}),(0,a.jsxs)("select",{id:"provider-filter",value:S.provider,onChange:e=>C({...S,provider:e.target.value}),className:(0,o.cn)("h-9 px-3 rounded-lg border border-black/10 dark:border-white/10 bg-surface","text-sm text-text-main focus:outline-none focus:ring-2 focus:ring-primary/20","w-full min-w-0 cursor-pointer"),children:[(0,a.jsx)("option",{value:"",children:"All Providers"}),N.map(e=>(0,a.jsx)("option",{value:e.id,children:e.name},e.id))]})]}),(0,a.jsxs)("div",{className:"flex min-w-0 flex-col gap-2",children:[(0,a.jsx)("label",{htmlFor:"start-date-filter",className:"text-sm font-medium text-text-main",children:"Start Date"}),(0,a.jsx)("input",{id:"start-date-filter",type:"datetime-local",value:S.startDate,onChange:e=>C({...S,startDate:e.target.value}),className:(0,o.cn)("h-9 px-3 rounded-lg border border-black/10 dark:border-white/10 bg-surface","w-full min-w-0 text-sm text-text-main focus:outline-none focus:ring-2 focus:ring-primary/20")})]}),(0,a.jsxs)("div",{className:"flex min-w-0 flex-col gap-2",children:[(0,a.jsx)("label",{htmlFor:"end-date-filter",className:"text-sm font-medium text-text-main",children:"End Date"}),(0,a.jsx)("input",{id:"end-date-filter",type:"datetime-local",value:S.endDate,onChange:e=>C({...S,endDate:e.target.value}),className:(0,o.cn)("h-9 px-3 rounded-lg border border-black/10 dark:border-white/10 bg-surface","w-full min-w-0 text-sm text-text-main focus:outline-none focus:ring-2 focus:ring-primary/20")})]}),(0,a.jsxs)("div",{className:"flex min-w-0 flex-col gap-2 sm:col-span-2 lg:col-span-1",children:[(0,a.jsx)("span",{className:"hidden text-sm font-medium text-text-main opacity-0 lg:block","aria-hidden":"true",children:"Clear"}),(0,a.jsx)(d.default,{variant:"ghost",onClick:()=>{C({provider:"",startDate:"",endDate:""})},disabled:!S.provider&&!S.startDate&&!S.endDate,className:"w-full",children:"Clear Filters"})]})]})}),(0,a.jsxs)(i.default,{padding:"none",children:[(0,a.jsx)("div",{className:"overflow-x-auto",children:(0,a.jsxs)("table",{className:"w-full min-w-[880px]",children:[(0,a.jsx)("thead",{children:(0,a.jsxs)("tr",{className:"border-b border-black/5 dark:border-white/5",children:[(0,a.jsx)("th",{className:"text-left p-4 text-sm font-semibold text-text-main",children:"Timestamp"}),(0,a.jsx)("th",{className:"text-left p-4 text-sm font-semibold text-text-main",children:"Model"}),(0,a.jsx)("th",{className:"text-left p-4 text-sm font-semibold text-text-main",children:"Provider"}),(0,a.jsx)("th",{className:"text-right p-4 text-sm font-semibold text-text-main",children:"Input Tokens"}),(0,a.jsx)("th",{className:"text-right p-4 text-sm font-semibold text-text-main",children:"Output Tokens"}),(0,a.jsx)("th",{className:"text-left p-4 text-sm font-semibold text-text-main",children:"Latency"}),(0,a.jsx)("th",{className:"text-center p-4 text-sm font-semibold text-text-main",children:"Action"})]})}),(0,a.jsx)("tbody",{children:r?(0,a.jsx)("tr",{children:(0,a.jsx)("td",{colSpan:"7",className:"p-8 text-center text-text-muted",children:(0,a.jsxs)("div",{className:"flex items-center justify-center gap-2",children:[(0,a.jsx)("span",{className:"material-symbols-outlined animate-spin text-[20px]",children:"progress_activity"}),"Loading..."]})})}):0===e.length?(0,a.jsx)("tr",{children:(0,a.jsx)("td",{colSpan:"7",className:"p-8 text-center text-text-muted",children:"No request details found"})}):e.map((e,t)=>(0,a.jsxs)("tr",{className:"border-b border-black/5 dark:border-white/5 last:border-b-0 hover:bg-black/[0.02] dark:hover:bg-white/[0.02] transition-colors",children:[(0,a.jsx)("td",{className:"whitespace-nowrap p-4 text-sm text-text-main",children:new Date(e.timestamp).toLocaleString()}),(0,a.jsx)("td",{className:"max-w-[260px] truncate p-4 font-mono text-sm text-text-main",children:e.model}),(0,a.jsx)("td",{className:"max-w-[180px] truncate p-4 text-sm text-text-main",children:(0,a.jsx)("span",{className:"font-medium",children:f(e.provider,k)})}),(0,a.jsx)("td",{className:"p-4 text-sm text-text-main text-right font-mono",children:g(e.tokens).toLocaleString()}),(0,a.jsx)("td",{className:"p-4 text-sm text-text-main text-right font-mono",children:e.tokens?.completion_tokens?.toLocaleString()||0}),(0,a.jsx)("td",{className:"p-4 text-sm text-text-muted",children:(0,a.jsxs)("div",{className:"flex flex-col gap-0.5",children:[(0,a.jsxs)("div",{children:["TTFT: ",(0,a.jsxs)("span",{className:"font-mono",children:[e.latency?.ttft||0,"ms"]})]}),(0,a.jsxs)("div",{children:["Total: ",(0,a.jsxs)("span",{className:"font-mono",children:[e.latency?.total||0,"ms"]})]})]})}),(0,a.jsx)("td",{className:"p-4 text-center",children:(0,a.jsx)(d.default,{variant:"outline",size:"sm",onClick:()=>{p(e),v(!0)},children:"Detail"})})]},`${e.id}-${t}`))})]})}),!r&&e.length>0&&(0,a.jsx)("div",{className:"border-t border-black/5 dark:border-white/5",children:(0,a.jsx)(x,{currentPage:s.page,pageSize:s.pageSize,totalItems:s.totalItems,onPageChange:e=>{n(t=>({...t,page:e}))},onPageSizeChange:e=>{n(t=>({...t,pageSize:e,page:1}))}})})]}),(0,a.jsx)(c,{isOpen:j,onClose:()=>v(!1),title:"Request Details",width:"lg",children:h&&(0,a.jsxs)("div",{className:"space-y-6",children:[(0,a.jsxs)("div",{className:"grid min-w-0 grid-cols-1 gap-4 text-sm sm:grid-cols-2",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("span",{className:"text-text-muted",children:"ID:"})," ",(0,a.jsx)("span",{className:"break-all font-mono text-text-main",children:h.id})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("span",{className:"text-text-muted",children:"Timestamp:"})," ",(0,a.jsx)("span",{className:"text-text-main",children:new Date(h.timestamp).toLocaleString()})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("span",{className:"text-text-muted",children:"Provider:"})," ",(0,a.jsx)("span",{className:"text-text-main font-medium",children:f(h.provider,k)})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("span",{className:"text-text-muted",children:"Model:"})," ",(0,a.jsx)("span",{className:"text-text-main font-mono",children:h.model})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("span",{className:"text-text-muted",children:"Status:"})," ",(0,a.jsx)("span",{className:(0,o.cn)("font-medium","success"===h.status?"text-green-600":"text-red-600"),children:h.status})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("span",{className:"text-text-muted",children:"Latency:"})," ",(0,a.jsxs)("span",{className:"text-text-main font-mono",children:["TTFT ",h.latency?.ttft||0,"ms / Total ",h.latency?.total||0,"ms"]})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("span",{className:"text-text-muted",children:"Input Tokens:"})," ",(0,a.jsx)("span",{className:"text-text-main font-mono",children:g(h.tokens).toLocaleString()})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("span",{className:"text-text-muted",children:"Output Tokens:"})," ",(0,a.jsx)("span",{className:"text-text-main font-mono",children:h.tokens?.completion_tokens?.toLocaleString()||0})]})]}),(0,a.jsxs)("div",{className:"space-y-4",children:[(0,a.jsx)(b,{title:"1. Client Request (Input)",defaultOpen:!0,icon:"input",children:(0,a.jsx)("pre",{className:"max-h-[300px] max-w-full overflow-auto rounded-lg border border-black/5 bg-black/5 p-3 font-mono text-xs text-text-main dark:border-white/5 dark:bg-white/5 sm:p-4",children:JSON.stringify(h.request,null,2)})}),h.providerRequest&&(0,a.jsx)(b,{title:"2. Provider Request (Translated)",icon:"translate",children:(0,a.jsx)("pre",{className:"max-h-[300px] max-w-full overflow-auto rounded-lg border border-black/5 bg-black/5 p-3 font-mono text-xs text-text-main dark:border-white/5 dark:bg-white/5 sm:p-4",children:JSON.stringify(h.providerRequest,null,2)})}),h.providerResponse&&(0,a.jsx)(b,{title:"3. Provider Response (Raw)",icon:"data_object",children:(0,a.jsx)("pre",{className:"max-h-[300px] max-w-full overflow-auto rounded-lg border border-black/5 bg-black/5 p-3 font-mono text-xs text-text-main dark:border-white/5 dark:bg-white/5 sm:p-4",children:"object"==typeof h.providerResponse?JSON.stringify(h.providerResponse,null,2):h.providerResponse})}),(0,a.jsxs)(b,{title:"4. Client Response (Final)",defaultOpen:!0,icon:"output",children:[h.response?.thinking&&(0,a.jsxs)("div",{className:"mb-4",children:[(0,a.jsxs)("h4",{className:"font-semibold text-text-main mb-2 flex items-center gap-2 text-xs uppercase tracking-wide opacity-70",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[16px]",children:"psychology"}),"Thinking Process"]}),(0,a.jsx)("pre",{className:"max-h-[200px] max-w-full overflow-auto rounded-lg border border-amber-200 bg-amber-50 p-3 font-mono text-xs text-amber-900 dark:border-amber-800 dark:bg-amber-950/30 dark:text-amber-100 sm:p-4",children:h.response.thinking})]}),(0,a.jsx)("h4",{className:"font-semibold text-text-main mb-2 text-xs uppercase tracking-wide opacity-70",children:"Content"}),(0,a.jsx)("pre",{className:"max-h-[300px] max-w-full overflow-auto rounded-lg border border-black/5 bg-black/5 p-3 font-mono text-xs text-text-main dark:border-white/5 dark:bg-white/5 sm:p-4",children:h.response?.content||"[No content]"})]})]})]})})]})}function v(){return(0,a.jsx)(l.Suspense,{fallback:(0,a.jsx)(r.Qv,{}),children:(0,a.jsx)(N,{})})}function N(){let e=(0,n.useSearchParams)(),t=(0,n.useRouter)(),[s,i]=(0,l.useState)(!1),d=e.get("tab"),o=d&&["overview","logs","details"].includes(d)?d:"overview";return(0,a.jsxs)("div",{className:"flex min-w-0 flex-col gap-6 px-1 sm:px-0",children:[(0,a.jsx)(r.Iz,{options:[{value:"overview",label:"Overview"},{value:"details",label:"Details"}],value:o,onChange:s=>{if(s===o)return;i(!0);let a=new URLSearchParams(e);a.set("tab",s),t.push(`/dashboard/usage?${a.toString()}`,{scroll:!1}),setTimeout(()=>i(!1),300)},className:"w-full sm:w-auto"}),s?(0,a.jsx)(r.Qv,{}):(0,a.jsxs)(a.Fragment,{children:["overview"===o&&(0,a.jsx)(l.Suspense,{fallback:(0,a.jsx)(r.Qv,{}),children:(0,a.jsx)(r.jK,{})}),"logs"===o&&(0,a.jsx)(r.gM,{}),"details"===o&&(0,a.jsx)(j,{})]})]})}}},e=>{e.O(0,[7848,4335,6795,505,4156,2347,5158,7358],()=>e(e.s=33154)),_N_E=e.O()}]);
@@ -1 +0,0 @@
1
- (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[7370],{292:(e,t,s)=>{"use strict";s.d(t,{default:()=>i});var r=s(73365),a=s(87706);function i({children:e,title:t,subtitle:s,icon:n,action:l,padding:c="md",hover:d=!1,className:o,...x}){return(0,r.jsxs)("div",{className:(0,a.cn)("bg-surface","border border-black/5 dark:border-white/5","rounded-lg shadow-sm",d&&"hover:shadow-md hover:border-primary/30 transition-all cursor-pointer",{none:"",xs:"p-3",sm:"p-4",md:"p-6",lg:"p-8"}[c],o),...x,children:[(t||l)&&(0,r.jsxs)("div",{className:"flex items-center justify-between mb-4",children:[(0,r.jsxs)("div",{className:"flex items-center gap-3",children:[n&&(0,r.jsx)("div",{className:"p-2 rounded-lg bg-bg text-text-muted",children:(0,r.jsx)("span",{className:"material-symbols-outlined text-[20px]",children:n})}),(0,r.jsxs)("div",{children:[t&&(0,r.jsx)("h3",{className:"text-text-main font-semibold",children:t}),s&&(0,r.jsx)("p",{className:"text-sm text-text-muted",children:s})]})]}),l]}),e]})}i.Section=function({children:e,className:t,...s}){return(0,r.jsx)("div",{className:(0,a.cn)("p-4 rounded-lg","bg-black/[0.02] dark:bg-white/[0.02]","border border-black/5 dark:border-white/5",t),...s,children:e})},i.Row=function({children:e,className:t,...s}){return(0,r.jsx)("div",{className:(0,a.cn)("p-3 -mx-3 px-3 transition-colors","border-b border-black/5 dark:border-white/5 last:border-b-0","hover:bg-black/[0.02] dark:hover:bg-white/[0.02]",t),...s,children:e})},i.ListItem=function({children:e,actions:t,className:s,...i}){return(0,r.jsxs)("div",{className:(0,a.cn)("group flex items-center justify-between p-3 -mx-3 px-3","border-b border-black/[0.03] dark:border-white/[0.03] last:border-b-0","hover:bg-black/[0.02] dark:hover:bg-white/[0.02]","transition-colors",s),...i,children:[(0,r.jsx)("div",{className:"flex-1 min-w-0",children:e}),t&&(0,r.jsx)("div",{className:"flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity",children:t})]})}},10075:(e,t,s)=>{Promise.resolve().then(s.bind(s,32530))},29717:(e,t,s)=>{"use strict";var r=s(21505);s.o(r,"notFound")&&s.d(t,{notFound:function(){return r.notFound}}),s.o(r,"useParams")&&s.d(t,{useParams:function(){return r.useParams}}),s.o(r,"usePathname")&&s.d(t,{usePathname:function(){return r.usePathname}}),s.o(r,"useRouter")&&s.d(t,{useRouter:function(){return r.useRouter}}),s.o(r,"useSearchParams")&&s.d(t,{useSearchParams:function(){return r.useSearchParams}})},32530:(e,t,s)=>{"use strict";s.r(t),s.d(t,{default:()=>d});var r=s(73365),a=s(1521),i=s(29717),n=s(292);let l={gh:{"gpt-5.3-codex":{input:1.75,output:14,cached:.175,reasoning:14,cache_creation:1.75}}};function c({isOpen:e,onClose:t,onSave:s}){let[i,n]=(0,a.useState)({}),[d,o]=(0,a.useState)(!0),[x,m]=(0,a.useState)(!1);(0,a.useEffect)(()=>{e&&h()},[e]);let h=async()=>{o(!0);try{let e=await fetch("/api/pricing");if(e.ok){let t=await e.json();n(t)}else n(l)}catch(e){console.error("Failed to load pricing:",e),n(l)}finally{o(!1)}},u=async()=>{m(!0);try{let e=await fetch("/api/pricing",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(i)});if(e.ok)s?.(),t();else{let t=await e.json();alert(`Failed to save pricing: ${t.error}`)}}catch(e){console.error("Failed to save pricing:",e),alert("Failed to save pricing")}finally{m(!1)}},p=async()=>{if(confirm("Reset all pricing to defaults? This cannot be undone."))try{(await fetch("/api/pricing",{method:"DELETE"})).ok&&n(l)}catch(e){console.error("Failed to reset pricing:",e),alert("Failed to reset pricing")}};if(!e)return null;let b=Object.keys(i).sort(),j=["input","output","cached","reasoning","cache_creation"];return(0,r.jsx)("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:(0,r.jsxs)("div",{className:"bg-bg-base border border-border rounded-lg shadow-xl max-w-6xl w-full max-h-[90vh] overflow-hidden flex flex-col",children:[(0,r.jsxs)("div",{className:"p-4 border-b border-border flex items-center justify-between",children:[(0,r.jsx)("h2",{className:"text-xl font-semibold",children:"Pricing Configuration"}),(0,r.jsx)("button",{onClick:t,className:"text-text-muted hover:text-text text-2xl leading-none",children:"\xd7"})]}),(0,r.jsx)("div",{className:"flex-1 overflow-auto p-4",children:d?(0,r.jsx)("div",{className:"text-center py-8 text-text-muted",children:"Loading pricing data..."}):(0,r.jsxs)("div",{className:"space-y-6",children:[(0,r.jsxs)("div",{className:"bg-bg-subtle border border-border rounded-lg p-3 text-sm",children:[(0,r.jsx)("p",{className:"font-medium mb-1",children:"Pricing Rates Format"}),(0,r.jsxs)("p",{className:"text-text-muted",children:["All rates are in ",(0,r.jsx)("strong",{children:"dollars per million tokens"})," ($/1M tokens). Example: Input rate of 2.50 means $2.50 per 1,000,000 input tokens."]})]}),b.map(e=>{let t=Object.keys(i[e]).sort();return(0,r.jsxs)("div",{className:"border border-border rounded-lg overflow-hidden",children:[(0,r.jsx)("div",{className:"bg-bg-subtle px-4 py-2 font-semibold text-sm",children:e.toUpperCase()}),(0,r.jsx)("div",{className:"overflow-x-auto",children:(0,r.jsxs)("table",{className:"w-full text-sm",children:[(0,r.jsx)("thead",{className:"bg-bg-hover text-text-muted uppercase text-xs",children:(0,r.jsxs)("tr",{children:[(0,r.jsx)("th",{className:"px-3 py-2 text-left",children:"Model"}),(0,r.jsx)("th",{className:"px-3 py-2 text-right",children:"Input"}),(0,r.jsx)("th",{className:"px-3 py-2 text-right",children:"Output"}),(0,r.jsx)("th",{className:"px-3 py-2 text-right",children:"Cached"}),(0,r.jsx)("th",{className:"px-3 py-2 text-right",children:"Reasoning"}),(0,r.jsx)("th",{className:"px-3 py-2 text-right",children:"Cache Creation"})]})}),(0,r.jsx)("tbody",{className:"divide-y divide-border",children:t.map(t=>(0,r.jsxs)("tr",{className:"hover:bg-bg-subtle/50",children:[(0,r.jsx)("td",{className:"px-3 py-2 font-medium",children:t}),j.map(s=>(0,r.jsx)("td",{className:"px-3 py-2",children:(0,r.jsx)("input",{type:"number",step:"0.01",min:"0",value:i[e][t][s]||0,onChange:r=>{let a;!isNaN(a=parseFloat(r.target.value))&&!(a<0)&&n(r=>{let i={...r};return i[e]||(i[e]={}),i[e][t]||(i[e][t]={}),i[e][t][s]=a,i})},className:"w-20 px-2 py-1 text-right bg-bg-base border border-border rounded focus:outline-none focus:border-primary"})},s))]},t))})]})})]},e)}),0===b.length&&(0,r.jsx)("div",{className:"text-center py-8 text-text-muted",children:"No pricing data available"})]})}),(0,r.jsxs)("div",{className:"p-4 border-t border-border flex items-center justify-between gap-2",children:[(0,r.jsx)("button",{onClick:p,className:"px-4 py-2 text-sm text-red-500 hover:bg-red-500/10 rounded border border-red-500/20 transition-colors",disabled:x,children:"Reset to Defaults"}),(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsx)("button",{onClick:t,className:"px-4 py-2 text-sm text-text-muted hover:text-text border border-border rounded transition-colors",disabled:x,children:"Cancel"}),(0,r.jsx)("button",{onClick:u,className:"px-4 py-2 text-sm bg-primary text-white rounded hover:bg-primary/90 transition-colors disabled:opacity-50",disabled:x,children:x?"Saving...":"Save Changes"})]})]})]})})}function d(){(0,i.useRouter)();let[e,t]=(0,a.useState)(!1),[s,l]=(0,a.useState)(null),[d,o]=(0,a.useState)(!0);(0,a.useEffect)(()=>{x()},[]);let x=async()=>{o(!0);try{let e=await fetch("/api/pricing");if(e.ok){let t=await e.json();l(t)}}catch(e){console.error("Failed to load pricing:",e)}finally{o(!1)}};return(0,r.jsxs)("div",{className:"max-w-6xl mx-auto p-6 space-y-6",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("h1",{className:"text-3xl font-bold",children:"Pricing Settings"}),(0,r.jsx)("p",{className:"text-text-muted mt-1",children:"Configure pricing rates for cost tracking and calculations"})]}),(0,r.jsx)("button",{onClick:()=>t(!0),className:"px-4 py-2 bg-primary text-white rounded hover:bg-primary/90 transition-colors",children:"Edit Pricing"})]}),(0,r.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[(0,r.jsxs)(n.default,{className:"p-4",children:[(0,r.jsx)("div",{className:"text-text-muted text-sm uppercase font-semibold",children:"Total Models"}),(0,r.jsx)("div",{className:"text-2xl font-bold mt-1",children:d?"...":(()=>{if(!s)return 0;let e=0;for(let t in s)e+=Object.keys(s[t]).length;return e})()})]}),(0,r.jsxs)(n.default,{className:"p-4",children:[(0,r.jsx)("div",{className:"text-text-muted text-sm uppercase font-semibold",children:"Providers"}),(0,r.jsx)("div",{className:"text-2xl font-bold mt-1",children:d?"...":(!s?[]:Object.keys(s).sort()).length})]}),(0,r.jsxs)(n.default,{className:"p-4",children:[(0,r.jsx)("div",{className:"text-text-muted text-sm uppercase font-semibold",children:"Status"}),(0,r.jsx)("div",{className:"text-2xl font-bold mt-1 text-success",children:d?"...":"Active"})]})]}),(0,r.jsxs)(n.default,{className:"p-6",children:[(0,r.jsx)("h2",{className:"text-xl font-semibold mb-4",children:"How Pricing Works"}),(0,r.jsxs)("div",{className:"space-y-3 text-sm text-text-muted",children:[(0,r.jsxs)("p",{children:[(0,r.jsx)("strong",{children:"Cost Calculation:"}),"Costs are calculated based on token usage and pricing rates. Each request's cost is determined by: (input_tokens \xd7 input_rate) + (output_tokens \xd7 output_rate) + (cached_tokens \xd7 cached_rate)"]}),(0,r.jsxs)("p",{children:[(0,r.jsx)("strong",{children:"Pricing Format:"})," All rates are in ",(0,r.jsx)("strong",{children:"dollars per million tokens"})," ($/1M tokens). Example: An input rate of 2.50 means $2.50 per 1,000,000 input tokens."]}),(0,r.jsx)("p",{children:(0,r.jsx)("strong",{children:"Token Types:"})}),(0,r.jsxs)("ul",{className:"list-disc list-inside ml-4 space-y-1",children:[(0,r.jsxs)("li",{children:[(0,r.jsx)("strong",{children:"Input:"})," Standard prompt tokens"]}),(0,r.jsxs)("li",{children:[(0,r.jsx)("strong",{children:"Output:"})," Completion/response tokens"]}),(0,r.jsxs)("li",{children:[(0,r.jsx)("strong",{children:"Cached:"})," Cached input tokens (typically 50% of input rate)"]}),(0,r.jsxs)("li",{children:[(0,r.jsx)("strong",{children:"Reasoning:"})," Special reasoning/thinking tokens (fallback to output rate)"]}),(0,r.jsxs)("li",{children:[(0,r.jsx)("strong",{children:"Cache Creation:"})," Tokens used to create cache entries (fallback to input rate)"]})]}),(0,r.jsxs)("p",{children:[(0,r.jsx)("strong",{children:"Custom Pricing:"})," You can override default pricing for specific models. Reset to defaults anytime to restore standard rates."]})]})]}),(0,r.jsxs)(n.default,{className:"p-6",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between mb-4",children:[(0,r.jsx)("h2",{className:"text-xl font-semibold",children:"Current Pricing Overview"}),(0,r.jsx)("button",{onClick:()=>t(!0),className:"text-primary hover:underline text-sm",children:"View Full Details"})]}),d?(0,r.jsx)("div",{className:"text-center py-4 text-text-muted",children:"Loading pricing data..."}):s?(0,r.jsxs)("div",{className:"space-y-3",children:[Object.keys(s).slice(0,5).map(e=>(0,r.jsxs)("div",{className:"text-sm",children:[(0,r.jsxs)("span",{className:"font-semibold",children:[e.toUpperCase(),":"]})," ",(0,r.jsxs)("span",{className:"text-text-muted",children:[Object.keys(s[e]).length," models"]})]},e)),Object.keys(s).length>5&&(0,r.jsxs)("div",{className:"text-sm text-text-muted",children:["+ ",Object.keys(s).length-5," more providers"]})]}):(0,r.jsx)("div",{className:"text-text-muted",children:"No pricing data available"})]}),e&&(0,r.jsx)(c,{isOpen:e,onClose:()=>t(!1),onSave:()=>{x()}})]})}},87706:(e,t,s)=>{"use strict";function r(...e){return e.filter(Boolean).join(" ").replace(/\s+/g," ").trim()}s.d(t,{cn:()=>r})}},e=>{e.O(0,[2347,5158,7358],()=>e(e.s=10075)),_N_E=e.O()}]);
@@ -1 +0,0 @@
1
- (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[4520],{15872:(e,s,t)=>{"use strict";t.r(s),t.d(s,{default:()=>i});var a=t(73365),r=t(1521),l=t(74156),n=t(29717);function i(){let[e,s]=(0,r.useState)(""),[t,i]=(0,r.useState)(""),[c,d]=(0,r.useState)(!1),[o,u]=(0,r.useState)(null),m=(0,n.useRouter)();(0,r.useEffect)(()=>{!async function(){let e=new AbortController,s=setTimeout(()=>e.abort(),5e3),t=window.location.origin;try{let a=await fetch(`${t}/api/settings`,{signal:e.signal});if(clearTimeout(s),a.ok){let e=await a.json();if(!1===e.requireLogin){m.push("/dashboard"),m.refresh();return}u(!!e.hasPassword)}else u(!0)}catch(e){clearTimeout(s),u(!0)}}()},[m]);let x=async s=>{s.preventDefault(),d(!0),i("");try{let s=await fetch("/api/auth/login",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({password:e})});if(s.ok)m.push("/dashboard"),m.refresh();else{let e=await s.json();i(e.error||"Invalid password")}}catch(e){i("An error occurred. Please try again.")}finally{d(!1)}};return null===o?(0,a.jsx)("div",{className:"min-h-screen flex items-center justify-center bg-bg p-4",children:(0,a.jsxs)("div",{className:"text-center",children:[(0,a.jsx)("div",{className:"inline-block animate-spin rounded-full h-8 w-8 border-b-2 border-primary"}),(0,a.jsx)("p",{className:"text-text-muted mt-4",children:"Loading..."})]})}):(0,a.jsx)("div",{className:"min-h-screen flex items-center justify-center bg-bg p-4",children:(0,a.jsxs)("div",{className:"w-full max-w-md",children:[(0,a.jsxs)("div",{className:"text-center mb-8",children:[(0,a.jsx)("h1",{className:"text-3xl font-bold text-primary mb-2",children:"9Router"}),(0,a.jsx)("p",{className:"text-text-muted",children:"Enter your password to access the dashboard"})]}),(0,a.jsx)(l.Zp,{children:(0,a.jsxs)("form",{onSubmit:x,className:"flex flex-col gap-4",children:[(0,a.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,a.jsx)("label",{className:"text-sm font-medium",children:"Password"}),(0,a.jsx)(l.pd,{type:"password",placeholder:"Enter password",value:e,onChange:e=>s(e.target.value),required:!0,autoFocus:!0}),t&&(0,a.jsx)("p",{className:"text-xs text-red-500",children:t})]}),(0,a.jsx)(l.$n,{type:"submit",variant:"primary",className:"w-full",loading:c,children:"Login"}),(0,a.jsxs)("p",{className:"text-xs text-center text-text-muted mt-2",children:["Default password is ",(0,a.jsx)("code",{className:"bg-sidebar px-1 rounded",children:"123456"})]})]})})]})})}},92943:(e,s,t)=>{Promise.resolve().then(t.bind(t,15872))}},e=>{e.O(0,[7848,4335,6795,505,4156,2347,5158,7358],()=>e(e.s=92943)),_N_E=e.O()}]);