prozygent 0.7.13 → 0.7.14

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 (376) hide show
  1. package/app/.next-cli-build/BUILD_ID +1 -1
  2. package/app/.next-cli-build/app-path-routes-manifest.json +12 -12
  3. package/app/.next-cli-build/build-manifest.json +2 -2
  4. package/app/.next-cli-build/server/app/(dashboard)/dashboard/basic-chat/page_client-reference-manifest.js +1 -1
  5. package/app/.next-cli-build/server/app/(dashboard)/dashboard/cli-tools/[toolId]/page.js.nft.json +1 -1
  6. package/app/.next-cli-build/server/app/(dashboard)/dashboard/cli-tools/[toolId]/page_client-reference-manifest.js +1 -1
  7. package/app/.next-cli-build/server/app/(dashboard)/dashboard/cli-tools/page.js.nft.json +1 -1
  8. package/app/.next-cli-build/server/app/(dashboard)/dashboard/cli-tools/page_client-reference-manifest.js +1 -1
  9. package/app/.next-cli-build/server/app/(dashboard)/dashboard/combos/page_client-reference-manifest.js +1 -1
  10. package/app/.next-cli-build/server/app/(dashboard)/dashboard/console-log/page_client-reference-manifest.js +1 -1
  11. package/app/.next-cli-build/server/app/(dashboard)/dashboard/endpoint/page.js.nft.json +1 -1
  12. package/app/.next-cli-build/server/app/(dashboard)/dashboard/endpoint/page_client-reference-manifest.js +1 -1
  13. package/app/.next-cli-build/server/app/(dashboard)/dashboard/media-providers/[kind]/[id]/page_client-reference-manifest.js +1 -1
  14. package/app/.next-cli-build/server/app/(dashboard)/dashboard/media-providers/[kind]/page_client-reference-manifest.js +1 -1
  15. package/app/.next-cli-build/server/app/(dashboard)/dashboard/media-providers/combo/[id]/page_client-reference-manifest.js +1 -1
  16. package/app/.next-cli-build/server/app/(dashboard)/dashboard/media-providers/web/page_client-reference-manifest.js +1 -1
  17. package/app/.next-cli-build/server/app/(dashboard)/dashboard/mitm/page_client-reference-manifest.js +1 -1
  18. package/app/.next-cli-build/server/app/(dashboard)/dashboard/page_client-reference-manifest.js +1 -1
  19. package/app/.next-cli-build/server/app/(dashboard)/dashboard/profile/page_client-reference-manifest.js +1 -1
  20. package/app/.next-cli-build/server/app/(dashboard)/dashboard/providers/[id]/page_client-reference-manifest.js +1 -1
  21. package/app/.next-cli-build/server/app/(dashboard)/dashboard/providers/new/page_client-reference-manifest.js +1 -1
  22. package/app/.next-cli-build/server/app/(dashboard)/dashboard/providers/page_client-reference-manifest.js +1 -1
  23. package/app/.next-cli-build/server/app/(dashboard)/dashboard/proxy-pools/page_client-reference-manifest.js +1 -1
  24. package/app/.next-cli-build/server/app/(dashboard)/dashboard/quota/page_client-reference-manifest.js +1 -1
  25. package/app/.next-cli-build/server/app/(dashboard)/dashboard/skills/page_client-reference-manifest.js +1 -1
  26. package/app/.next-cli-build/server/app/(dashboard)/dashboard/translator/page_client-reference-manifest.js +1 -1
  27. package/app/.next-cli-build/server/app/(dashboard)/dashboard/usage/page_client-reference-manifest.js +1 -1
  28. package/app/.next-cli-build/server/app/_global-error/page_client-reference-manifest.js +1 -1
  29. package/app/.next-cli-build/server/app/_global-error.html +1 -1
  30. package/app/.next-cli-build/server/app/_global-error.rsc +1 -1
  31. package/app/.next-cli-build/server/app/_global-error.segments/_full.segment.rsc +1 -1
  32. package/app/.next-cli-build/server/app/_global-error.segments/_global-error/__PAGE__.segment.rsc +1 -1
  33. package/app/.next-cli-build/server/app/_global-error.segments/_global-error.segment.rsc +1 -1
  34. package/app/.next-cli-build/server/app/_global-error.segments/_head.segment.rsc +1 -1
  35. package/app/.next-cli-build/server/app/_global-error.segments/_index.segment.rsc +1 -1
  36. package/app/.next-cli-build/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  37. package/app/.next-cli-build/server/app/_not-found/page_client-reference-manifest.js +1 -1
  38. package/app/.next-cli-build/server/app/_not-found.html +1 -1
  39. package/app/.next-cli-build/server/app/_not-found.rsc +4 -4
  40. package/app/.next-cli-build/server/app/_not-found.segments/_full.segment.rsc +4 -4
  41. package/app/.next-cli-build/server/app/_not-found.segments/_head.segment.rsc +1 -1
  42. package/app/.next-cli-build/server/app/_not-found.segments/_index.segment.rsc +4 -4
  43. package/app/.next-cli-build/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +1 -1
  44. package/app/.next-cli-build/server/app/_not-found.segments/_not-found.segment.rsc +1 -1
  45. package/app/.next-cli-build/server/app/_not-found.segments/_tree.segment.rsc +1 -1
  46. package/app/.next-cli-build/server/app/api/auth/login/route.js.nft.json +1 -1
  47. package/app/.next-cli-build/server/app/api/auth/logout/route.js.nft.json +1 -1
  48. package/app/.next-cli-build/server/app/api/auth/oidc/callback/route.js.nft.json +1 -1
  49. package/app/.next-cli-build/server/app/api/auth/oidc/start/route.js.nft.json +1 -1
  50. package/app/.next-cli-build/server/app/api/auth/oidc/test/route.js.nft.json +1 -1
  51. package/app/.next-cli-build/server/app/api/auth/reset-password/route.js.nft.json +1 -1
  52. package/app/.next-cli-build/server/app/api/auth/status/route.js.nft.json +1 -1
  53. package/app/.next-cli-build/server/app/api/cli-tools/all-statuses/route.js.nft.json +1 -1
  54. package/app/.next-cli-build/server/app/api/cli-tools/antigravity-mitm/alias/route.js.nft.json +1 -1
  55. package/app/.next-cli-build/server/app/api/cli-tools/antigravity-mitm/route.js.nft.json +1 -1
  56. package/app/.next-cli-build/server/app/api/cli-tools/copilot-settings/route.js.nft.json +1 -1
  57. package/app/.next-cli-build/server/app/api/cli-tools/cowork-settings/route.js.nft.json +1 -1
  58. package/app/.next-cli-build/server/app/api/combos/[id]/route.js.nft.json +1 -1
  59. package/app/.next-cli-build/server/app/api/combos/route.js.nft.json +1 -1
  60. package/app/.next-cli-build/server/app/api/headroom/start/route.js.nft.json +1 -1
  61. package/app/.next-cli-build/server/app/api/headroom/status/route.js.nft.json +1 -1
  62. package/app/.next-cli-build/server/app/api/headroom/stop/route.js.nft.json +1 -1
  63. package/app/.next-cli-build/server/app/api/keys/[id]/route.js.nft.json +1 -1
  64. package/app/.next-cli-build/server/app/api/keys/route.js.nft.json +1 -1
  65. package/app/.next-cli-build/server/app/api/media-providers/tts/deepgram/voices/route.js.nft.json +1 -1
  66. package/app/.next-cli-build/server/app/api/media-providers/tts/elevenlabs/voices/route.js.nft.json +1 -1
  67. package/app/.next-cli-build/server/app/api/media-providers/tts/inworld/voices/route.js.nft.json +1 -1
  68. package/app/.next-cli-build/server/app/api/media-providers/tts/minimax/voices/route.js.nft.json +1 -1
  69. package/app/.next-cli-build/server/app/api/models/alias/route.js.nft.json +1 -1
  70. package/app/.next-cli-build/server/app/api/models/availability/route.js.nft.json +1 -1
  71. package/app/.next-cli-build/server/app/api/models/custom/route.js.nft.json +1 -1
  72. package/app/.next-cli-build/server/app/api/models/disabled/route.js.nft.json +1 -1
  73. package/app/.next-cli-build/server/app/api/models/route.js +1 -1
  74. package/app/.next-cli-build/server/app/api/models/route.js.nft.json +1 -1
  75. package/app/.next-cli-build/server/app/api/models/test/route.js.nft.json +1 -1
  76. package/app/.next-cli-build/server/app/api/oauth/[provider]/[action]/route.js +1 -1
  77. package/app/.next-cli-build/server/app/api/oauth/[provider]/[action]/route.js.nft.json +1 -1
  78. package/app/.next-cli-build/server/app/api/oauth/codex/bulk-import/route.js +1 -1
  79. package/app/.next-cli-build/server/app/api/oauth/codex/bulk-import/route.js.nft.json +1 -1
  80. package/app/.next-cli-build/server/app/api/oauth/codex/import-token/route.js +1 -1
  81. package/app/.next-cli-build/server/app/api/oauth/codex/import-token/route.js.nft.json +1 -1
  82. package/app/.next-cli-build/server/app/api/oauth/cursor/import/route.js +1 -1
  83. package/app/.next-cli-build/server/app/api/oauth/cursor/import/route.js.nft.json +1 -1
  84. package/app/.next-cli-build/server/app/api/oauth/gitlab/pat/route.js.nft.json +1 -1
  85. package/app/.next-cli-build/server/app/api/oauth/iflow/cookie/route.js.nft.json +1 -1
  86. package/app/.next-cli-build/server/app/api/oauth/kiro/api-key/route.js +1 -1
  87. package/app/.next-cli-build/server/app/api/oauth/kiro/api-key/route.js.nft.json +1 -1
  88. package/app/.next-cli-build/server/app/api/oauth/kiro/import/route.js +1 -1
  89. package/app/.next-cli-build/server/app/api/oauth/kiro/import/route.js.nft.json +1 -1
  90. package/app/.next-cli-build/server/app/api/oauth/kiro/social-authorize/route.js +1 -1
  91. package/app/.next-cli-build/server/app/api/oauth/kiro/social-exchange/route.js +1 -1
  92. package/app/.next-cli-build/server/app/api/oauth/kiro/social-exchange/route.js.nft.json +1 -1
  93. package/app/.next-cli-build/server/app/api/pricing/route.js.nft.json +1 -1
  94. package/app/.next-cli-build/server/app/api/provider-nodes/[id]/route.js.nft.json +1 -1
  95. package/app/.next-cli-build/server/app/api/provider-nodes/route.js.nft.json +1 -1
  96. package/app/.next-cli-build/server/app/api/provider-nodes/validate/route.js.nft.json +1 -1
  97. package/app/.next-cli-build/server/app/api/providers/[id]/models/route.js +1 -1
  98. package/app/.next-cli-build/server/app/api/providers/[id]/models/route.js.nft.json +1 -1
  99. package/app/.next-cli-build/server/app/api/providers/[id]/route.js.nft.json +1 -1
  100. package/app/.next-cli-build/server/app/api/providers/[id]/test/route.js.nft.json +1 -1
  101. package/app/.next-cli-build/server/app/api/providers/[id]/test-models/route.js.nft.json +1 -1
  102. package/app/.next-cli-build/server/app/api/providers/client/route.js +1 -1
  103. package/app/.next-cli-build/server/app/api/providers/client/route.js.nft.json +1 -1
  104. package/app/.next-cli-build/server/app/api/providers/route.js +1 -1
  105. package/app/.next-cli-build/server/app/api/providers/route.js.nft.json +1 -1
  106. package/app/.next-cli-build/server/app/api/providers/test-batch/route.js.nft.json +1 -1
  107. package/app/.next-cli-build/server/app/api/providers/validate/route.js.nft.json +1 -1
  108. package/app/.next-cli-build/server/app/api/proxy-pools/[id]/route.js.nft.json +1 -1
  109. package/app/.next-cli-build/server/app/api/proxy-pools/[id]/test/route.js.nft.json +1 -1
  110. package/app/.next-cli-build/server/app/api/proxy-pools/cloudflare-deploy/route.js.nft.json +1 -1
  111. package/app/.next-cli-build/server/app/api/proxy-pools/deno-deploy/route.js.nft.json +1 -1
  112. package/app/.next-cli-build/server/app/api/proxy-pools/route.js.nft.json +1 -1
  113. package/app/.next-cli-build/server/app/api/proxy-pools/vercel-deploy/route.js.nft.json +1 -1
  114. package/app/.next-cli-build/server/app/api/settings/database/route.js.nft.json +1 -1
  115. package/app/.next-cli-build/server/app/api/settings/migrate-9router/route.js.nft.json +1 -1
  116. package/app/.next-cli-build/server/app/api/settings/require-login/route.js.nft.json +1 -1
  117. package/app/.next-cli-build/server/app/api/settings/route.js.nft.json +1 -1
  118. package/app/.next-cli-build/server/app/api/translator/console-logs/route.js +1 -1
  119. package/app/.next-cli-build/server/app/api/translator/console-logs/stream/route.js +1 -1
  120. package/app/.next-cli-build/server/app/api/translator/send/route.js.nft.json +1 -1
  121. package/app/.next-cli-build/server/app/api/translator/translate/route.js.nft.json +1 -1
  122. package/app/.next-cli-build/server/app/api/tunnel/disable/route.js.nft.json +1 -1
  123. package/app/.next-cli-build/server/app/api/tunnel/enable/route.js.nft.json +1 -1
  124. package/app/.next-cli-build/server/app/api/tunnel/status/route.js.nft.json +1 -1
  125. package/app/.next-cli-build/server/app/api/tunnel/tailscale-check/route.js.nft.json +1 -1
  126. package/app/.next-cli-build/server/app/api/tunnel/tailscale-disable/route.js.nft.json +1 -1
  127. package/app/.next-cli-build/server/app/api/tunnel/tailscale-enable/route.js.nft.json +1 -1
  128. package/app/.next-cli-build/server/app/api/tunnel/tailscale-install/route.js.nft.json +1 -1
  129. package/app/.next-cli-build/server/app/api/usage/[connectionId]/codex-reset-credits/route.js.nft.json +1 -1
  130. package/app/.next-cli-build/server/app/api/usage/[connectionId]/route.js.nft.json +1 -1
  131. package/app/.next-cli-build/server/app/api/usage/chart/route.js.nft.json +1 -1
  132. package/app/.next-cli-build/server/app/api/usage/history/route.js.nft.json +1 -1
  133. package/app/.next-cli-build/server/app/api/usage/logs/route.js.nft.json +1 -1
  134. package/app/.next-cli-build/server/app/api/usage/providers/route.js.nft.json +1 -1
  135. package/app/.next-cli-build/server/app/api/usage/request-details/route.js.nft.json +1 -1
  136. package/app/.next-cli-build/server/app/api/usage/request-logs/route.js.nft.json +1 -1
  137. package/app/.next-cli-build/server/app/api/usage/stats/route.js.nft.json +1 -1
  138. package/app/.next-cli-build/server/app/api/usage/stream/route.js.nft.json +1 -1
  139. package/app/.next-cli-build/server/app/api/v1/api/chat/route.js.nft.json +1 -1
  140. package/app/.next-cli-build/server/app/api/v1/audio/speech/route.js.nft.json +1 -1
  141. package/app/.next-cli-build/server/app/api/v1/audio/transcriptions/route.js.nft.json +1 -1
  142. package/app/.next-cli-build/server/app/api/v1/chat/completions/route.js.nft.json +1 -1
  143. package/app/.next-cli-build/server/app/api/v1/embeddings/route.js.nft.json +1 -1
  144. package/app/.next-cli-build/server/app/api/v1/images/generations/route.js.nft.json +1 -1
  145. package/app/.next-cli-build/server/app/api/v1/messages/route.js.nft.json +1 -1
  146. package/app/.next-cli-build/server/app/api/v1/models/[kind]/route.js.nft.json +1 -1
  147. package/app/.next-cli-build/server/app/api/v1/models/route.js.nft.json +1 -1
  148. package/app/.next-cli-build/server/app/api/v1/responses/compact/route.js.nft.json +1 -1
  149. package/app/.next-cli-build/server/app/api/v1/responses/route.js.nft.json +1 -1
  150. package/app/.next-cli-build/server/app/api/v1/route.js.nft.json +1 -1
  151. package/app/.next-cli-build/server/app/api/v1/search/route.js.nft.json +1 -1
  152. package/app/.next-cli-build/server/app/api/v1/web/fetch/route.js.nft.json +1 -1
  153. package/app/.next-cli-build/server/app/api/v1beta/models/[...path]/route.js.nft.json +1 -1
  154. package/app/.next-cli-build/server/app/api/version/hot-update/route.js.nft.json +1 -1
  155. package/app/.next-cli-build/server/app/api/version/route.js +1 -1
  156. package/app/.next-cli-build/server/app/api/version/shutdown/route.js.nft.json +1 -1
  157. package/app/.next-cli-build/server/app/api/version/update/route.js.nft.json +1 -1
  158. package/app/.next-cli-build/server/app/callback/page_client-reference-manifest.js +1 -1
  159. package/app/.next-cli-build/server/app/callback.html +1 -1
  160. package/app/.next-cli-build/server/app/callback.rsc +4 -4
  161. package/app/.next-cli-build/server/app/callback.segments/_full.segment.rsc +4 -4
  162. package/app/.next-cli-build/server/app/callback.segments/_head.segment.rsc +1 -1
  163. package/app/.next-cli-build/server/app/callback.segments/_index.segment.rsc +4 -4
  164. package/app/.next-cli-build/server/app/callback.segments/_tree.segment.rsc +1 -1
  165. package/app/.next-cli-build/server/app/callback.segments/callback/__PAGE__.segment.rsc +1 -1
  166. package/app/.next-cli-build/server/app/callback.segments/callback.segment.rsc +1 -1
  167. package/app/.next-cli-build/server/app/dashboard/basic-chat.html +1 -1
  168. package/app/.next-cli-build/server/app/dashboard/basic-chat.rsc +6 -6
  169. package/app/.next-cli-build/server/app/dashboard/basic-chat.segments/!KGRhc2hib2FyZCk/dashboard/basic-chat/__PAGE__.segment.rsc +2 -2
  170. package/app/.next-cli-build/server/app/dashboard/basic-chat.segments/!KGRhc2hib2FyZCk/dashboard/basic-chat.segment.rsc +1 -1
  171. package/app/.next-cli-build/server/app/dashboard/basic-chat.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  172. package/app/.next-cli-build/server/app/dashboard/basic-chat.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  173. package/app/.next-cli-build/server/app/dashboard/basic-chat.segments/_full.segment.rsc +6 -6
  174. package/app/.next-cli-build/server/app/dashboard/basic-chat.segments/_head.segment.rsc +1 -1
  175. package/app/.next-cli-build/server/app/dashboard/basic-chat.segments/_index.segment.rsc +4 -4
  176. package/app/.next-cli-build/server/app/dashboard/basic-chat.segments/_tree.segment.rsc +1 -1
  177. package/app/.next-cli-build/server/app/dashboard/cli-tools.html +1 -1
  178. package/app/.next-cli-build/server/app/dashboard/cli-tools.rsc +6 -6
  179. package/app/.next-cli-build/server/app/dashboard/cli-tools.segments/!KGRhc2hib2FyZCk/dashboard/cli-tools/__PAGE__.segment.rsc +2 -2
  180. package/app/.next-cli-build/server/app/dashboard/cli-tools.segments/!KGRhc2hib2FyZCk/dashboard/cli-tools.segment.rsc +1 -1
  181. package/app/.next-cli-build/server/app/dashboard/cli-tools.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  182. package/app/.next-cli-build/server/app/dashboard/cli-tools.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  183. package/app/.next-cli-build/server/app/dashboard/cli-tools.segments/_full.segment.rsc +6 -6
  184. package/app/.next-cli-build/server/app/dashboard/cli-tools.segments/_head.segment.rsc +1 -1
  185. package/app/.next-cli-build/server/app/dashboard/cli-tools.segments/_index.segment.rsc +4 -4
  186. package/app/.next-cli-build/server/app/dashboard/cli-tools.segments/_tree.segment.rsc +1 -1
  187. package/app/.next-cli-build/server/app/dashboard/combos.html +1 -1
  188. package/app/.next-cli-build/server/app/dashboard/combos.rsc +6 -6
  189. package/app/.next-cli-build/server/app/dashboard/combos.segments/!KGRhc2hib2FyZCk/dashboard/combos/__PAGE__.segment.rsc +2 -2
  190. package/app/.next-cli-build/server/app/dashboard/combos.segments/!KGRhc2hib2FyZCk/dashboard/combos.segment.rsc +1 -1
  191. package/app/.next-cli-build/server/app/dashboard/combos.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  192. package/app/.next-cli-build/server/app/dashboard/combos.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  193. package/app/.next-cli-build/server/app/dashboard/combos.segments/_full.segment.rsc +6 -6
  194. package/app/.next-cli-build/server/app/dashboard/combos.segments/_head.segment.rsc +1 -1
  195. package/app/.next-cli-build/server/app/dashboard/combos.segments/_index.segment.rsc +4 -4
  196. package/app/.next-cli-build/server/app/dashboard/combos.segments/_tree.segment.rsc +1 -1
  197. package/app/.next-cli-build/server/app/dashboard/endpoint.html +1 -1
  198. package/app/.next-cli-build/server/app/dashboard/endpoint.rsc +6 -6
  199. package/app/.next-cli-build/server/app/dashboard/endpoint.segments/!KGRhc2hib2FyZCk/dashboard/endpoint/__PAGE__.segment.rsc +2 -2
  200. package/app/.next-cli-build/server/app/dashboard/endpoint.segments/!KGRhc2hib2FyZCk/dashboard/endpoint.segment.rsc +1 -1
  201. package/app/.next-cli-build/server/app/dashboard/endpoint.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  202. package/app/.next-cli-build/server/app/dashboard/endpoint.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  203. package/app/.next-cli-build/server/app/dashboard/endpoint.segments/_full.segment.rsc +6 -6
  204. package/app/.next-cli-build/server/app/dashboard/endpoint.segments/_head.segment.rsc +1 -1
  205. package/app/.next-cli-build/server/app/dashboard/endpoint.segments/_index.segment.rsc +4 -4
  206. package/app/.next-cli-build/server/app/dashboard/endpoint.segments/_tree.segment.rsc +1 -1
  207. package/app/.next-cli-build/server/app/dashboard/media-providers/web.html +1 -1
  208. package/app/.next-cli-build/server/app/dashboard/media-providers/web.rsc +6 -6
  209. package/app/.next-cli-build/server/app/dashboard/media-providers/web.segments/!KGRhc2hib2FyZCk/dashboard/media-providers/web/__PAGE__.segment.rsc +2 -2
  210. package/app/.next-cli-build/server/app/dashboard/media-providers/web.segments/!KGRhc2hib2FyZCk/dashboard/media-providers/web.segment.rsc +1 -1
  211. package/app/.next-cli-build/server/app/dashboard/media-providers/web.segments/!KGRhc2hib2FyZCk/dashboard/media-providers.segment.rsc +1 -1
  212. package/app/.next-cli-build/server/app/dashboard/media-providers/web.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  213. package/app/.next-cli-build/server/app/dashboard/media-providers/web.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  214. package/app/.next-cli-build/server/app/dashboard/media-providers/web.segments/_full.segment.rsc +6 -6
  215. package/app/.next-cli-build/server/app/dashboard/media-providers/web.segments/_head.segment.rsc +1 -1
  216. package/app/.next-cli-build/server/app/dashboard/media-providers/web.segments/_index.segment.rsc +4 -4
  217. package/app/.next-cli-build/server/app/dashboard/media-providers/web.segments/_tree.segment.rsc +1 -1
  218. package/app/.next-cli-build/server/app/dashboard/mitm.html +1 -1
  219. package/app/.next-cli-build/server/app/dashboard/mitm.rsc +6 -6
  220. package/app/.next-cli-build/server/app/dashboard/mitm.segments/!KGRhc2hib2FyZCk/dashboard/mitm/__PAGE__.segment.rsc +2 -2
  221. package/app/.next-cli-build/server/app/dashboard/mitm.segments/!KGRhc2hib2FyZCk/dashboard/mitm.segment.rsc +1 -1
  222. package/app/.next-cli-build/server/app/dashboard/mitm.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  223. package/app/.next-cli-build/server/app/dashboard/mitm.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  224. package/app/.next-cli-build/server/app/dashboard/mitm.segments/_full.segment.rsc +6 -6
  225. package/app/.next-cli-build/server/app/dashboard/mitm.segments/_head.segment.rsc +1 -1
  226. package/app/.next-cli-build/server/app/dashboard/mitm.segments/_index.segment.rsc +4 -4
  227. package/app/.next-cli-build/server/app/dashboard/mitm.segments/_tree.segment.rsc +1 -1
  228. package/app/.next-cli-build/server/app/dashboard/profile.html +1 -1
  229. package/app/.next-cli-build/server/app/dashboard/profile.rsc +6 -6
  230. package/app/.next-cli-build/server/app/dashboard/profile.segments/!KGRhc2hib2FyZCk/dashboard/profile/__PAGE__.segment.rsc +2 -2
  231. package/app/.next-cli-build/server/app/dashboard/profile.segments/!KGRhc2hib2FyZCk/dashboard/profile.segment.rsc +1 -1
  232. package/app/.next-cli-build/server/app/dashboard/profile.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  233. package/app/.next-cli-build/server/app/dashboard/profile.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  234. package/app/.next-cli-build/server/app/dashboard/profile.segments/_full.segment.rsc +6 -6
  235. package/app/.next-cli-build/server/app/dashboard/profile.segments/_head.segment.rsc +1 -1
  236. package/app/.next-cli-build/server/app/dashboard/profile.segments/_index.segment.rsc +4 -4
  237. package/app/.next-cli-build/server/app/dashboard/profile.segments/_tree.segment.rsc +1 -1
  238. package/app/.next-cli-build/server/app/dashboard/providers/new.html +1 -1
  239. package/app/.next-cli-build/server/app/dashboard/providers/new.rsc +6 -6
  240. package/app/.next-cli-build/server/app/dashboard/providers/new.segments/!KGRhc2hib2FyZCk/dashboard/providers/new/__PAGE__.segment.rsc +2 -2
  241. package/app/.next-cli-build/server/app/dashboard/providers/new.segments/!KGRhc2hib2FyZCk/dashboard/providers/new.segment.rsc +1 -1
  242. package/app/.next-cli-build/server/app/dashboard/providers/new.segments/!KGRhc2hib2FyZCk/dashboard/providers.segment.rsc +1 -1
  243. package/app/.next-cli-build/server/app/dashboard/providers/new.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  244. package/app/.next-cli-build/server/app/dashboard/providers/new.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  245. package/app/.next-cli-build/server/app/dashboard/providers/new.segments/_full.segment.rsc +6 -6
  246. package/app/.next-cli-build/server/app/dashboard/providers/new.segments/_head.segment.rsc +1 -1
  247. package/app/.next-cli-build/server/app/dashboard/providers/new.segments/_index.segment.rsc +4 -4
  248. package/app/.next-cli-build/server/app/dashboard/providers/new.segments/_tree.segment.rsc +1 -1
  249. package/app/.next-cli-build/server/app/dashboard/providers.html +1 -1
  250. package/app/.next-cli-build/server/app/dashboard/providers.rsc +6 -6
  251. package/app/.next-cli-build/server/app/dashboard/providers.segments/!KGRhc2hib2FyZCk/dashboard/providers/__PAGE__.segment.rsc +2 -2
  252. package/app/.next-cli-build/server/app/dashboard/providers.segments/!KGRhc2hib2FyZCk/dashboard/providers.segment.rsc +1 -1
  253. package/app/.next-cli-build/server/app/dashboard/providers.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  254. package/app/.next-cli-build/server/app/dashboard/providers.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  255. package/app/.next-cli-build/server/app/dashboard/providers.segments/_full.segment.rsc +6 -6
  256. package/app/.next-cli-build/server/app/dashboard/providers.segments/_head.segment.rsc +1 -1
  257. package/app/.next-cli-build/server/app/dashboard/providers.segments/_index.segment.rsc +4 -4
  258. package/app/.next-cli-build/server/app/dashboard/providers.segments/_tree.segment.rsc +1 -1
  259. package/app/.next-cli-build/server/app/dashboard/proxy-pools.html +1 -1
  260. package/app/.next-cli-build/server/app/dashboard/proxy-pools.rsc +6 -6
  261. package/app/.next-cli-build/server/app/dashboard/proxy-pools.segments/!KGRhc2hib2FyZCk/dashboard/proxy-pools/__PAGE__.segment.rsc +2 -2
  262. package/app/.next-cli-build/server/app/dashboard/proxy-pools.segments/!KGRhc2hib2FyZCk/dashboard/proxy-pools.segment.rsc +1 -1
  263. package/app/.next-cli-build/server/app/dashboard/proxy-pools.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  264. package/app/.next-cli-build/server/app/dashboard/proxy-pools.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  265. package/app/.next-cli-build/server/app/dashboard/proxy-pools.segments/_full.segment.rsc +6 -6
  266. package/app/.next-cli-build/server/app/dashboard/proxy-pools.segments/_head.segment.rsc +1 -1
  267. package/app/.next-cli-build/server/app/dashboard/proxy-pools.segments/_index.segment.rsc +4 -4
  268. package/app/.next-cli-build/server/app/dashboard/proxy-pools.segments/_tree.segment.rsc +1 -1
  269. package/app/.next-cli-build/server/app/dashboard/quota.html +2 -2
  270. package/app/.next-cli-build/server/app/dashboard/quota.rsc +7 -7
  271. package/app/.next-cli-build/server/app/dashboard/quota.segments/!KGRhc2hib2FyZCk/dashboard/quota/__PAGE__.segment.rsc +3 -3
  272. package/app/.next-cli-build/server/app/dashboard/quota.segments/!KGRhc2hib2FyZCk/dashboard/quota.segment.rsc +1 -1
  273. package/app/.next-cli-build/server/app/dashboard/quota.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  274. package/app/.next-cli-build/server/app/dashboard/quota.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  275. package/app/.next-cli-build/server/app/dashboard/quota.segments/_full.segment.rsc +7 -7
  276. package/app/.next-cli-build/server/app/dashboard/quota.segments/_head.segment.rsc +1 -1
  277. package/app/.next-cli-build/server/app/dashboard/quota.segments/_index.segment.rsc +4 -4
  278. package/app/.next-cli-build/server/app/dashboard/quota.segments/_tree.segment.rsc +1 -1
  279. package/app/.next-cli-build/server/app/dashboard/settings/pricing/page_client-reference-manifest.js +1 -1
  280. package/app/.next-cli-build/server/app/dashboard/settings/pricing.html +1 -1
  281. package/app/.next-cli-build/server/app/dashboard/settings/pricing.rsc +4 -4
  282. package/app/.next-cli-build/server/app/dashboard/settings/pricing.segments/_full.segment.rsc +4 -4
  283. package/app/.next-cli-build/server/app/dashboard/settings/pricing.segments/_head.segment.rsc +1 -1
  284. package/app/.next-cli-build/server/app/dashboard/settings/pricing.segments/_index.segment.rsc +4 -4
  285. package/app/.next-cli-build/server/app/dashboard/settings/pricing.segments/_tree.segment.rsc +1 -1
  286. package/app/.next-cli-build/server/app/dashboard/settings/pricing.segments/dashboard/settings/pricing/__PAGE__.segment.rsc +1 -1
  287. package/app/.next-cli-build/server/app/dashboard/settings/pricing.segments/dashboard/settings/pricing.segment.rsc +1 -1
  288. package/app/.next-cli-build/server/app/dashboard/settings/pricing.segments/dashboard/settings.segment.rsc +1 -1
  289. package/app/.next-cli-build/server/app/dashboard/settings/pricing.segments/dashboard.segment.rsc +1 -1
  290. package/app/.next-cli-build/server/app/dashboard/skills.html +1 -1
  291. package/app/.next-cli-build/server/app/dashboard/skills.rsc +6 -6
  292. package/app/.next-cli-build/server/app/dashboard/skills.segments/!KGRhc2hib2FyZCk/dashboard/skills/__PAGE__.segment.rsc +2 -2
  293. package/app/.next-cli-build/server/app/dashboard/skills.segments/!KGRhc2hib2FyZCk/dashboard/skills.segment.rsc +1 -1
  294. package/app/.next-cli-build/server/app/dashboard/skills.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  295. package/app/.next-cli-build/server/app/dashboard/skills.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  296. package/app/.next-cli-build/server/app/dashboard/skills.segments/_full.segment.rsc +6 -6
  297. package/app/.next-cli-build/server/app/dashboard/skills.segments/_head.segment.rsc +1 -1
  298. package/app/.next-cli-build/server/app/dashboard/skills.segments/_index.segment.rsc +4 -4
  299. package/app/.next-cli-build/server/app/dashboard/skills.segments/_tree.segment.rsc +1 -1
  300. package/app/.next-cli-build/server/app/dashboard/translator.html +1 -1
  301. package/app/.next-cli-build/server/app/dashboard/translator.rsc +6 -6
  302. package/app/.next-cli-build/server/app/dashboard/translator.segments/!KGRhc2hib2FyZCk/dashboard/translator/__PAGE__.segment.rsc +2 -2
  303. package/app/.next-cli-build/server/app/dashboard/translator.segments/!KGRhc2hib2FyZCk/dashboard/translator.segment.rsc +1 -1
  304. package/app/.next-cli-build/server/app/dashboard/translator.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  305. package/app/.next-cli-build/server/app/dashboard/translator.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  306. package/app/.next-cli-build/server/app/dashboard/translator.segments/_full.segment.rsc +6 -6
  307. package/app/.next-cli-build/server/app/dashboard/translator.segments/_head.segment.rsc +1 -1
  308. package/app/.next-cli-build/server/app/dashboard/translator.segments/_index.segment.rsc +4 -4
  309. package/app/.next-cli-build/server/app/dashboard/translator.segments/_tree.segment.rsc +1 -1
  310. package/app/.next-cli-build/server/app/dashboard/usage.html +1 -1
  311. package/app/.next-cli-build/server/app/dashboard/usage.rsc +6 -6
  312. package/app/.next-cli-build/server/app/dashboard/usage.segments/!KGRhc2hib2FyZCk/dashboard/usage/__PAGE__.segment.rsc +2 -2
  313. package/app/.next-cli-build/server/app/dashboard/usage.segments/!KGRhc2hib2FyZCk/dashboard/usage.segment.rsc +1 -1
  314. package/app/.next-cli-build/server/app/dashboard/usage.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  315. package/app/.next-cli-build/server/app/dashboard/usage.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  316. package/app/.next-cli-build/server/app/dashboard/usage.segments/_full.segment.rsc +6 -6
  317. package/app/.next-cli-build/server/app/dashboard/usage.segments/_head.segment.rsc +1 -1
  318. package/app/.next-cli-build/server/app/dashboard/usage.segments/_index.segment.rsc +4 -4
  319. package/app/.next-cli-build/server/app/dashboard/usage.segments/_tree.segment.rsc +1 -1
  320. package/app/.next-cli-build/server/app/dashboard.html +1 -1
  321. package/app/.next-cli-build/server/app/dashboard.rsc +6 -6
  322. package/app/.next-cli-build/server/app/dashboard.segments/!KGRhc2hib2FyZCk/dashboard/__PAGE__.segment.rsc +2 -2
  323. package/app/.next-cli-build/server/app/dashboard.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  324. package/app/.next-cli-build/server/app/dashboard.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  325. package/app/.next-cli-build/server/app/dashboard.segments/_full.segment.rsc +6 -6
  326. package/app/.next-cli-build/server/app/dashboard.segments/_head.segment.rsc +1 -1
  327. package/app/.next-cli-build/server/app/dashboard.segments/_index.segment.rsc +4 -4
  328. package/app/.next-cli-build/server/app/dashboard.segments/_tree.segment.rsc +1 -1
  329. package/app/.next-cli-build/server/app/index.html +1 -1
  330. package/app/.next-cli-build/server/app/index.rsc +4 -4
  331. package/app/.next-cli-build/server/app/index.segments/__PAGE__.segment.rsc +1 -1
  332. package/app/.next-cli-build/server/app/index.segments/_full.segment.rsc +4 -4
  333. package/app/.next-cli-build/server/app/index.segments/_head.segment.rsc +1 -1
  334. package/app/.next-cli-build/server/app/index.segments/_index.segment.rsc +4 -4
  335. package/app/.next-cli-build/server/app/index.segments/_tree.segment.rsc +1 -1
  336. package/app/.next-cli-build/server/app/landing/page_client-reference-manifest.js +1 -1
  337. package/app/.next-cli-build/server/app/landing.html +1 -1
  338. package/app/.next-cli-build/server/app/landing.rsc +4 -4
  339. package/app/.next-cli-build/server/app/landing.segments/_full.segment.rsc +4 -4
  340. package/app/.next-cli-build/server/app/landing.segments/_head.segment.rsc +1 -1
  341. package/app/.next-cli-build/server/app/landing.segments/_index.segment.rsc +4 -4
  342. package/app/.next-cli-build/server/app/landing.segments/_tree.segment.rsc +1 -1
  343. package/app/.next-cli-build/server/app/landing.segments/landing/__PAGE__.segment.rsc +1 -1
  344. package/app/.next-cli-build/server/app/landing.segments/landing.segment.rsc +1 -1
  345. package/app/.next-cli-build/server/app/login/page_client-reference-manifest.js +1 -1
  346. package/app/.next-cli-build/server/app/login.html +1 -1
  347. package/app/.next-cli-build/server/app/login.rsc +5 -5
  348. package/app/.next-cli-build/server/app/login.segments/_full.segment.rsc +5 -5
  349. package/app/.next-cli-build/server/app/login.segments/_head.segment.rsc +1 -1
  350. package/app/.next-cli-build/server/app/login.segments/_index.segment.rsc +4 -4
  351. package/app/.next-cli-build/server/app/login.segments/_tree.segment.rsc +1 -1
  352. package/app/.next-cli-build/server/app/login.segments/login/__PAGE__.segment.rsc +2 -2
  353. package/app/.next-cli-build/server/app/login.segments/login.segment.rsc +1 -1
  354. package/app/.next-cli-build/server/app/page_client-reference-manifest.js +1 -1
  355. package/app/.next-cli-build/server/app-paths-manifest.json +12 -12
  356. package/app/.next-cli-build/server/chunks/1241.js +1 -1
  357. package/app/.next-cli-build/server/chunks/2231.js +1 -1
  358. package/app/.next-cli-build/server/chunks/318.js +1 -1
  359. package/app/.next-cli-build/server/chunks/3535.js +1 -1
  360. package/app/.next-cli-build/server/chunks/412.js +1 -1
  361. package/app/.next-cli-build/server/chunks/4746.js +1 -1
  362. package/app/.next-cli-build/server/chunks/4827.js +1 -1
  363. package/app/.next-cli-build/server/chunks/4914.js +1 -1
  364. package/app/.next-cli-build/server/chunks/5615.js +1 -1
  365. package/app/.next-cli-build/server/chunks/8238.js +1 -1
  366. package/app/.next-cli-build/server/middleware-build-manifest.js +1 -1
  367. package/app/.next-cli-build/server/pages/404.html +1 -1
  368. package/app/.next-cli-build/server/pages/500.html +1 -1
  369. package/app/.next-cli-build/static/chunks/{1321-3d0168ec6fc64a44.js → 1321-1be13e2a05dc06f3.js} +1 -1
  370. package/app/.next-cli-build/static/chunks/{5497-2d117cecb2567489.js → 5497-79c08890f080f49d.js} +1 -1
  371. package/app/cli/.build-home/.prozygent/db/backups/{upgrade-0.7.12-to-0.7.11-0.7.11-20260711-203346 → upgrade-0.7.13-to-0.7.14-0.7.14-20260711-225635}/data.sqlite +0 -0
  372. package/app/cli/.build-home/.prozygent/db/data.sqlite +0 -0
  373. package/app/package.json +1 -1
  374. package/package.json +1 -1
  375. /package/app/.next-cli-build/static/{oWRnXLeJgZkFX-ZaiUn9h → ag3MzWBL5ah172TKWpYan}/_buildManifest.js +0 -0
  376. /package/app/.next-cli-build/static/{oWRnXLeJgZkFX-ZaiUn9h → ag3MzWBL5ah172TKWpYan}/_ssgManifest.js +0 -0
@@ -4,4 +4,4 @@
4
4
  `,children:[j.includes(e.name)&&(0,a.jsx)("span",{className:"material-symbols-outlined leading-none",style:{fontSize:"10px"},children:"check"}),e.name]},e.id)})})]}),Object.entries(M).map(([e,t])=>(0,a.jsxs)("div",{children:[(0,a.jsxs)("div",{className:"flex items-center gap-1.5 mb-1.5 sticky top-0 bg-surface py-0.5",children:[(0,a.jsx)(o.A,{src:`/providers/${e}.png`,alt:t.name,size:14,fallbackText:(t.name||e).slice(0,2).toUpperCase(),fallbackColor:t.color}),(0,a.jsx)("span",{className:"text-xs font-medium text-primary",children:t.name}),(0,a.jsxs)("span",{className:"text-[10px] text-text-muted",children:["(",t.models.length,")"]})]}),(0,a.jsx)("div",{className:"flex flex-wrap gap-1.5",children:t.models.map(e=>{let t=l===e.value,s=e.isPlaceholder;return(0,a.jsx)("button",{onClick:()=>U(e),title:s?"Select to pre-fill, then edit model ID in the input":void 0,className:`
5
5
  px-2 py-1 rounded-xl text-xs font-medium transition-all border hover:cursor-pointer
6
6
  ${s?"border-dashed border-border text-text-muted hover:border-primary/50 hover:text-primary bg-surface italic":t?"bg-primary text-white border-primary":j.includes(e.value)?"bg-primary border-primary text-white hover:bg-primary-hover":"bg-surface border-border text-text-main hover:border-primary/50 hover:bg-primary/5"}
7
- `,children:(0,a.jsxs)("span",{className:"flex items-center gap-1",children:[j.includes(e.value)&&!s&&(0,a.jsx)("span",{className:"material-symbols-outlined leading-none",style:{fontSize:"10px"},children:"check"}),s?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[11px]",children:"edit"}),e.name]}):e.isCustom?(0,a.jsxs)(a.Fragment,{children:[e.name,(0,a.jsx)("span",{className:"text-[9px] opacity-60 font-normal",children:"custom"}),(0,a.jsx)(d.default,{caps:w(e.value)})]}):(0,a.jsxs)(a.Fragment,{children:[e.name,(0,a.jsx)(d.default,{caps:w(e.value)})]})]})},e.value)})})]},e)),0===Object.keys(M).length&&0===q.length&&(0,a.jsxs)("div",{className:"text-center py-4 text-text-muted",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-2xl mb-1 block",children:"search_off"}),(0,a.jsx)("p",{className:"text-xs",children:"No models found"})]})]})]})}h.propTypes={isOpen:l().bool.isRequired,onClose:l().func.isRequired,onSelect:l().func.isRequired,onDeselect:l().func,selectedModel:l().string,activeProviders:l().arrayOf(l().shape({provider:l().string.isRequired})),title:l().string,modelAliases:l().object,kindFilter:l().string,addedModelValues:l().arrayOf(l().string),closeOnSelect:l().bool}},73579:(e,t,s)=>{s.d(t,{default:()=>m});var a=s(95155),r=s(12115),n=s(14051),l=s.n(n),i=s(81127),o=s(11910),d=s(92542),c=s(56061),x=s(88105);function m({isOpen:e,connection:t,proxyPools:s,onSave:n,onClose:l}){let[u,p]=(0,r.useState)({name:"",priority:1,apiKey:""}),[h,f]=(0,r.useState)({azureEndpoint:"",apiVersion:"2024-10-01-preview",deployment:"",organization:""}),[b,g]=(0,r.useState)({accountId:""}),[v,j]=(0,r.useState)({sessionToken:"",cfClearance:""}),[y,N]=(0,r.useState)(!1),[w,k]=(0,r.useState)(null),[C,S]=(0,r.useState)(!1),[O,T]=(0,r.useState)(null),[P,$]=(0,r.useState)(!1);(0,r.useEffect)(()=>{t&&(p({name:t.name||"",priority:t.priority||1,apiKey:""}),"azure"===t.provider&&t.providerSpecificData&&f({azureEndpoint:t.providerSpecificData.azureEndpoint||"",apiVersion:t.providerSpecificData.apiVersion||"2024-10-01-preview",deployment:t.providerSpecificData.deployment||"",organization:t.providerSpecificData.organization||""}),"cloudflare-ai"===t.provider&&t.providerSpecificData&&g({accountId:t.providerSpecificData.accountId||""}),"merlin"===t.provider&&t.providerSpecificData&&j({sessionToken:t.providerSpecificData.sessionToken||"",cfClearance:t.providerSpecificData.cfClearance||""}),k(null),T(null))},[t]);let I=t?.authType==="oauth",F=t?.provider==="azure",E=t?.provider==="cloudflare-ai",_=t?.provider==="merlin",A=!!t&&((0,x.mq)(t.provider)||(0,x.gb)(t.provider)),W=async()=>{if(t?.provider){N(!0),k(null);try{let e=await fetch(`/api/providers/${t.id}/test`,{method:"POST"}),s=await e.json();k(s.valid?"success":"failed")}catch{k("failed")}finally{N(!1)}}},R=async()=>{if(!t?.provider)return;let e=_?`${v.sessionToken};;${v.cfClearance}`:u.apiKey;if(e&&(!_||v.sessionToken&&v.cfClearance)){S(!0),T(null);try{let s=await fetch("/api/providers/validate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:t.provider,apiKey:e,...F?{providerSpecificData:h}:{},...E?{providerSpecificData:b}:{}})}),a=await s.json();T(a.valid?"success":"failed")}catch{T("failed")}finally{S(!1)}}},L=async()=>{if(t){$(!0);try{let e={name:u.name,priority:u.priority};if(!I&&(u.apiKey||_)){e.apiKey=_?`${v.sessionToken};;${v.cfClearance}`:u.apiKey;let s="success"===O;if(!s)try{S(!0),T(null);let a=await fetch("/api/providers/validate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:t.provider,apiKey:e.apiKey,...F?{providerSpecificData:h}:{},...E?{providerSpecificData:b}:{}})});s=!!(await a.json()).valid,T(s?"success":"failed")}catch{T("failed")}finally{S(!1)}s&&(e.testStatus="active",e.lastError=null,e.lastErrorAt=null)}F&&(e.providerSpecificData={azureEndpoint:h.azureEndpoint,apiVersion:h.apiVersion,deployment:h.deployment,organization:h.organization}),E&&(e.providerSpecificData={accountId:b.accountId}),_&&(e.providerSpecificData={sessionToken:v.sessionToken,cfClearance:v.cfClearance}),await n(e)}finally{$(!1)}}};return t?(0,a.jsx)(i.default,{isOpen:e,title:"Edit Connection",onClose:l,children:(0,a.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,a.jsx)(o.default,{label:"Name",value:u.name,onChange:e=>p({...u,name:e.target.value}),placeholder:I?"Account name":"Production Key"}),I&&t.email&&(0,a.jsxs)("div",{className:"bg-sidebar/50 p-3 rounded-2xl",children:[(0,a.jsx)("p",{className:"text-sm text-text-muted mb-1",children:"Email"}),(0,a.jsx)("p",{className:"font-medium",children:t.email})]}),(0,a.jsx)(o.default,{label:"Priority",type:"number",value:u.priority,onChange:e=>p({...u,priority:Number.parseInt(e.target.value,10)||1})}),!I&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsx)(o.default,{label:"API Key",type:"password",value:u.apiKey,onChange:e=>p({...u,apiKey:e.target.value}),placeholder:"Enter new API key",hint:"Leave blank to keep the current API key.",className:"flex-1"}),(0,a.jsx)("div",{className:"pt-6",children:(0,a.jsx)(d.default,{onClick:R,disabled:!u.apiKey||C||P,variant:"secondary",children:C?"Checking...":"Check"})})]}),O&&(0,a.jsx)(c.default,{variant:"success"===O?"success":"error",children:"success"===O?"Valid":"Invalid"})]}),F&&(0,a.jsxs)("div",{className:"bg-sidebar/50 p-4 rounded-2xl border border-accent/20",children:[(0,a.jsx)("h3",{className:"font-semibold mb-3 text-sm",children:"Azure OpenAI Configuration"}),(0,a.jsxs)("div",{className:"flex flex-col gap-3",children:[(0,a.jsx)(o.default,{label:"Azure Endpoint",value:h.azureEndpoint,onChange:e=>f({...h,azureEndpoint:e.target.value}),placeholder:"https://your-resource.openai.azure.com",hint:"Your Azure OpenAI resource endpoint URL"}),(0,a.jsx)(o.default,{label:"Deployment Name",value:h.deployment,onChange:e=>f({...h,deployment:e.target.value}),placeholder:"gpt-4",hint:"The deployment name in your Azure resource"}),(0,a.jsx)(o.default,{label:"API Version",value:h.apiVersion,onChange:e=>f({...h,apiVersion:e.target.value}),placeholder:"2024-10-01-preview",hint:"Azure OpenAI API version to use"}),(0,a.jsx)(o.default,{label:"Organization",value:h.organization,onChange:e=>f({...h,organization:e.target.value}),placeholder:"Organization ID",hint:"Required for billing"})]})]}),_&&(0,a.jsxs)("div",{className:"bg-sidebar/50 p-4 rounded-2xl border border-accent/20",children:[(0,a.jsx)("h3",{className:"font-semibold mb-3 text-sm",children:"Merlin Cookies"}),(0,a.jsx)("p",{className:"text-xs text-text-muted mb-3",children:"DevTools (F12) → Application → Cookies → getmerlin.in"}),(0,a.jsxs)("div",{className:"flex flex-col gap-3",children:[(0,a.jsx)(o.default,{label:"Session Token (__Secure-authjs.session-token)",type:"password",value:v.sessionToken,onChange:e=>j({...v,sessionToken:e.target.value}),placeholder:"eyJhbGciOi...",hint:"The __Secure-authjs.session-token cookie value"}),(0,a.jsx)(o.default,{label:"CF Clearance (cf_clearance)",type:"password",value:v.cfClearance,onChange:e=>j({...v,cfClearance:e.target.value}),placeholder:"JIj9UKw...",hint:"The cf_clearance cookie value"})]})]}),!A&&!F&&!E&&!_&&(0,a.jsxs)("div",{className:"flex items-center gap-3",children:[(0,a.jsx)(d.default,{onClick:W,variant:"secondary",disabled:y,children:y?"Testing...":"Test Connection"}),w&&(0,a.jsx)(c.default,{variant:"success"===w?"success":"error",children:"success"===w?"Valid":"Failed"})]}),(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsx)(d.default,{onClick:L,fullWidth:!0,disabled:P,children:P?"Saving...":"Save"}),(0,a.jsx)(d.default,{onClick:l,variant:"ghost",fullWidth:!0,children:"Cancel"})]})]})}):null}m.propTypes={isOpen:l().bool.isRequired,connection:l().shape({id:l().string,name:l().string,email:l().string,priority:l().number,authType:l().string,provider:l().string,providerSpecificData:l().object}),proxyPools:l().arrayOf(l().shape({id:l().string,name:l().string})),onSave:l().func.isRequired,onClose:l().func.isRequired}},80752:(e,t,s)=>{s.d(t,{default:()=>x});var a=s(95155),r=s(12115),n=s(14051),l=s.n(n),i=s(1620),o=s(40197),d=s(81127);function c({icon:e,label:t,onClick:s,trailing:r,danger:n}){return(0,a.jsxs)("button",{onClick:s,className:`flex items-center gap-3 w-full px-4 py-2.5 text-sm transition-colors ${n?"text-red-500 hover:bg-red-500/10":"text-text-main hover:bg-surface/50"}`,children:[(0,a.jsx)("span",{className:`material-symbols-outlined text-[20px] ${n?"":"text-text-muted"}`,children:e}),(0,a.jsx)("span",{className:"flex-1 text-left",children:t}),r&&(0,a.jsx)("span",{className:"text-base",children:r})]})}function x({onLogout:e}){let[t,s]=(0,r.useState)(!1),[n,l]=(0,r.useState)(!1),[m,u]=(0,r.useState)(!1),[p,h]=(0,r.useState)(!1),{toggleTheme:f,isDark:b}=(0,i.D)(),g=(0,r.useRef)(null),v=async()=>{h(!0);try{await fetch("/api/version/shutdown",{method:"POST"})}catch(e){}h(!1),u(!1)};return(0,r.useEffect)(()=>{let e=e=>{g.current&&!g.current.contains(e.target)&&s(!1)};if(t)return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[t]),(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{className:"relative",ref:g,children:[(0,a.jsx)("button",{onClick:()=>s(e=>!e),className:"flex items-center justify-center p-2 rounded-lg text-text-muted hover:text-text-main hover:bg-surface/50 transition-all",title:"Menu",children:(0,a.jsx)("span",{className:"material-symbols-outlined",children:"grid_view"})}),t&&(0,a.jsxs)("div",{className:"absolute right-0 top-full mt-2 w-60 bg-surface border border-border rounded-xl shadow-2xl z-50 animate-in fade-in zoom-in-95 duration-150 overflow-hidden py-1",children:[(0,a.jsx)(c,{icon:"history",label:"Change Log",onClick:()=>{s(!1),l(!0)}}),(0,a.jsx)(c,{icon:b?"light_mode":"dark_mode",label:"Theme",onClick:()=>{f(),s(!1)}}),(0,a.jsx)(c,{icon:"power_settings_new",label:"Shutdown",danger:!0,onClick:()=>{s(!1),u(!0)}}),(0,a.jsx)(c,{icon:"logout",label:"Logout",danger:!0,onClick:()=>{s(!1),e()}})]})]}),(0,a.jsx)(o.default,{isOpen:n,onClose:()=>l(!1)}),(0,a.jsx)(d.ConfirmModal,{isOpen:m,onClose:()=>u(!1),onConfirm:v,title:"Close Proxy",message:"Are you sure you want to close the proxy server?",confirmText:"Close",cancelText:"Cancel",variant:"danger",loading:p})]})}c.propTypes={icon:l().string.isRequired,label:l().string.isRequired,onClick:l().func.isRequired,trailing:l().node,danger:l().bool},x.propTypes={onLogout:l().func.isRequired}},81127:(e,t,s)=>{s.d(t,{ConfirmModal:()=>d,default:()=>o});var a=s(95155),r=s(12115),n=s(47650),l=s(31474),i=s(92542);function o({isOpen:e,onClose:t,title:s,children:i,footer:d,size:c="md",closeOnOverlay:x=!0,showTrafficLights:m=!1,className:u}){let[p,h]=(0,r.useState)(!1);if((0,r.useEffect)(()=>{h(!0)},[]),(0,r.useEffect)(()=>(e?document.body.style.overflow="hidden":document.body.style.overflow="",()=>{document.body.style.overflow=""}),[e]),(0,r.useEffect)(()=>{let s=s=>{"Escape"===s.key&&e&&t()};return document.addEventListener("keydown",s),()=>document.removeEventListener("keydown",s)},[e,t]),!e||!p)return null;let f=(0,a.jsxs)("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4",children:[(0,a.jsx)("div",{className:"absolute inset-0 bg-black/40 fade-in",onClick:x?t:void 0}),(0,a.jsxs)("div",{className:(0,l.cn)("relative w-full bg-surface","border border-border","rounded-2xl shadow-[var(--neo-raised)]","slide-up",{sm:"max-w-sm",md:"max-w-md",lg:"max-w-lg",xl:"max-w-xl",full:"max-w-4xl"}[c],u),children:[(s||m)&&(0,a.jsxs)("div",{className:"flex items-center justify-between px-5 py-4 border-b border-border",children:[(0,a.jsx)("div",{className:"flex items-center gap-3",children:s&&(0,a.jsx)("h2",{className:"text-base font-semibold text-text",children:s})}),(0,a.jsx)("button",{onClick:t,"aria-label":"Close",className:"p-1.5 rounded-lg text-text-muted hover:bg-surface-hover hover:text-text transition-colors",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[20px]",children:"close"})})]}),(0,a.jsx)("div",{className:"p-6 max-h-[calc(85vh-100px)] overflow-y-auto custom-scrollbar",children:i}),d&&(0,a.jsx)("div",{className:"flex items-center justify-end gap-3 px-6 py-4 border-t border-border",children:d})]})]});return(0,n.createPortal)(f,document.body)}function d({isOpen:e,onClose:t,onConfirm:s,title:r="Confirm",message:n,confirmText:l="Confirm",cancelText:c="Cancel",variant:x="danger",loading:m=!1}){return(0,a.jsx)(o,{isOpen:e,onClose:t,title:r,size:"sm",footer:(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(i.default,{variant:"ghost",onClick:t,disabled:m,children:c}),(0,a.jsx)(i.default,{variant:x,onClick:s,loading:m,children:l})]}),children:(0,a.jsx)("p",{className:"text-text-muted text-sm",children:n})})}s(97677)},90882:(e,t,s)=>{s.d(t,{default:()=>d});var a=s(95155),r=s(12115),n=s(14051),l=s.n(n),i=s(35497),o=s(11059);function d({isOpen:e,provider:t,providerInfo:s,onSuccess:n,onClose:l,oauthMeta:c,idcConfig:x}){let[m,u]=(0,r.useState)("waiting"),[p,h]=(0,r.useState)(null),[f,b]=(0,r.useState)(""),[g,v]=(0,r.useState)(null),[j,y]=(0,r.useState)(!1),[N,w]=(0,r.useState)(null),[k,C]=(0,r.useState)(!1),S=(0,r.useRef)(null),O=(0,r.useRef)(!1),T=(0,r.useRef)(!1),{copied:P,copy:$}=(0,o.C)(),[I,F]=(0,r.useState)(!1),[E,_]=(0,r.useState)("/callback?code=..."),A=(0,r.useRef)(!1);(0,r.useEffect)(()=>{F("localhost"===window.location.hostname||"127.0.0.1"===window.location.hostname),_(`${window.location.origin}/callback?code=...`)},[]);let W=(0,r.useCallback)(async(e,s)=>{if(p)try{let a=await fetch(`/api/oauth/${t}/exchange`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({code:e,redirectUri:p.redirectUri,codeVerifier:p.codeVerifier,state:s,...c?{meta:c}:{}})}),r=await a.json();if(!a.ok)throw Error(r.error);u("success"),n?.()}catch(e){v(e.message),u("error")}},[p,t,n]),R=(0,r.useCallback)(async e=>{if(p?.state)try{let t=await fetch("/api/oauth/xai/manual-code",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({code:e,state:p.state})}),s=await t.json();if(!t.ok)throw Error(s.error);u("success"),n?.()}catch(e){v(e.message),u("error")}},[p,n]),L=(0,r.useCallback)(async(e,s,a,r,l)=>{O.current=!1,C(!0);let i=Date.now()+(Number.isFinite(l)&&l>0?l:12e4);for(;Date.now()<i;){if(O.current){console.log("[OAuthModal] Polling aborted"),C(!1);return}if(await new Promise(e=>setTimeout(e,1e3*a)),O.current){console.log("[OAuthModal] Polling aborted after sleep"),C(!1);return}try{let l=await fetch(`/api/oauth/${t}/poll`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({deviceCode:e,codeVerifier:s,extraData:r})}),i=await l.json();if(i.success){O.current=!0,u("success"),C(!1),n?.();return}if("expired_token"===i.error||"access_denied"===i.error)throw Error(i.errorDescription||i.error);"slow_down"===i.error&&(a=Math.min(a+5,30))}catch(e){v(e.message),u("error"),C(!1);return}}v("Authorization timeout"),u("error"),C(!1)},[t,n]),z=(0,r.useCallback)(async()=>{if(t)try{let e;if(v(null),["github","qwen","kiro","kimi-coding","kilocode","codebuddy-cn","qoder"].includes(t)){y(!0),u("waiting");let e=new URL(`/api/oauth/${t}/device-code`,window.location.origin);"kiro"===t&&x?.startUrl&&(e.searchParams.set("start_url",x.startUrl),x.region&&e.searchParams.set("region",x.region),e.searchParams.set("auth_method","idc"));let s=await fetch(e.toString()),a=await s.json();if(!s.ok)throw Error(a.error);w(a);let r=a.verification_uri_complete||a.verification_uri;r&&window.open(r,"_blank","noopener,noreferrer");let n="kiro"===t?{_clientId:a._clientId,_clientSecret:a._clientSecret,_region:a._region,_authMethod:a._authMethod,_startUrl:a._startUrl}:"qoder"===t?{_qoderNonce:a._qoderNonce,_qoderMachineId:a._qoderMachineId,_qoderVerifier:a.codeVerifier}:null;L(a.device_code,a.codeVerifier,a.interval||5,n,Number.isFinite(a.expires_in)&&a.expires_in>0?1e3*a.expires_in:void 0);return}let s=window.location.port||("https:"===window.location.protocol?"443":"80");e="codex"===t?"http://localhost:1455/auth/callback":"xai"===t?"http://127.0.0.1:56121/callback":`http://localhost:${s}/callback`;let a=new URL(`/api/oauth/${t}/authorize`,window.location.origin);a.searchParams.set("redirect_uri",e),c&&Object.entries(c).forEach(([e,t])=>{t&&a.searchParams.set(e,t)});let r=await fetch(a.toString()),n=await r.json();if(!r.ok)throw Error(n.error);let l=!1,i=!1;if("codex"===t)try{let t=new URL("/api/oauth/codex/start-proxy",window.location.origin);t.searchParams.set("app_port",s),t.searchParams.set("state",n.state),t.searchParams.set("code_verifier",n.codeVerifier),t.searchParams.set("redirect_uri",e);let a=await fetch(t.toString()),r=await a.json();l=r.success,i=!!r.serverSide}catch{l=!1}let o=!1,d=!1;if("xai"===t)try{let t=new URL("/api/oauth/xai/start-proxy",window.location.origin);t.searchParams.set("app_port",s),t.searchParams.set("state",n.state),t.searchParams.set("code_verifier",n.codeVerifier),t.searchParams.set("redirect_uri",e);let a=await fetch(t.toString()),r=await a.json();if(o=r.success,d=!!r.serverSide,!o&&"port_busy"===r.reason)throw Error("Port 56121 in use; close the conflicting process and retry")}catch(e){if(e?.message)throw e;o=!1}h({...n,redirectUri:e,codexServerSide:i,xaiServerSide:d}),"codex"===t&&l||"xai"===t&&o||I&&"codex"!==t&&"xai"!==t?(u("waiting"),S.current=window.open(n.authUrl,"oauth_popup","width=600,height=700"),S.current||u("input")):(u("input"),window.open(n.authUrl,"_blank"))}catch(e){v(e.message),u("error")}},[t,I,L,c,x]);(0,r.useEffect)(()=>{e&&t?T.current||(T.current=!0,h(null),b(""),v(null),y(!1),w(null),C(!1),O.current=!1,z()):e||(O.current=!0,T.current=!1,"codex"===t?fetch("/api/oauth/codex/stop-proxy").catch(()=>{}):"xai"===t&&fetch("/api/oauth/xai/stop-proxy").catch(()=>{}))},[e,t,z]),(0,r.useEffect)(()=>{let e=p?.codexServerSide?"codex":p?.xaiServerSide?"xai":null;if(!e||!p?.state||A.current)return;let t=!1,s=0,a=async()=>{if(!t&&!A.current){s+=1;try{let s=await fetch(`/api/oauth/${e}/poll-status?state=${encodeURIComponent(p.state)}`),a=await s.json();if(t||A.current)return;if("done"===a.status){A.current=!0,u("success"),n?.();return}if("error"===a.status){A.current=!0,v(a.error||"Authentication failed"),u("error");return}}catch{}if(s>=200){A.current=!0,v("Authentication timeout"),u("error");return}setTimeout(a,1500)}};return setTimeout(a,1500),()=>{t=!0}},[p,n]),(0,r.useEffect)(()=>{let e;if(!p)return;A.current=!1;let t=async e=>{if(A.current)return;let{code:t,state:s,error:a,errorDescription:r}=e;if(a){A.current=!0,v(r||a),u("error");return}t&&(A.current=!0,await W(t,s))},s=e=>{let s=e.origin.includes("localhost")||e.origin.includes("127.0.0.1"),a=e.origin===window.location.origin;(s||a)&&e.data?.type==="oauth_callback"&&t(e.data.data)};window.addEventListener("message",s);try{(e=new BroadcastChannel("oauth_callback")).onmessage=e=>t(e.data)}catch(e){console.log("BroadcastChannel not supported")}let a=e=>{if("oauth_callback"===e.key&&e.newValue)try{let s=JSON.parse(e.newValue);t(s),localStorage.removeItem("oauth_callback")}catch(e){console.log("Failed to parse localStorage data")}};window.addEventListener("storage",a);try{let e=localStorage.getItem("oauth_callback");if(e){let s=JSON.parse(e);s.timestamp&&Date.now()-s.timestamp<3e4&&t(s),localStorage.removeItem("oauth_callback")}}catch{}return()=>{window.removeEventListener("message",s),window.removeEventListener("storage",a),e&&e.close()}},[p,W]);let q=async()=>{try{v(null);let e=f.trim();if(e.startsWith("eyJ")&&e.includes("."))return void await W(e,null);if("xai"===t&&e&&!e.includes("://")&&!e.includes("?")&&!e.includes("code="))return void await R(e);let s=new URL(e),a=s.searchParams.get("code"),r=s.searchParams.get("state"),n=s.searchParams.get("error");if(n)throw Error(s.searchParams.get("error_description")||n);if(!a)throw Error("xai"===t?"Paste the callback URL or copied xAI code":"No authorization code found in URL");await W(a,r)}catch(e){v(e.message),u("error")}},M=(0,r.useCallback)(()=>{"codex"===t?fetch("/api/oauth/codex/stop-proxy").catch(()=>{}):"xai"===t&&fetch("/api/oauth/xai/stop-proxy").catch(()=>{}),l()},[l,t]);if(!t||!s)return null;let U="xai"===t,D=N?.verification_uri_complete||N?.verification_uri||"",K=U?"Connect Grok Build OAuth":`Connect ${s.name}`;return(0,a.jsx)(i.aF,{isOpen:e,title:K,onClose:M,size:"lg",children:(0,a.jsxs)("div",{className:"flex flex-col gap-4",children:[("waiting"===m||"input"===m)&&!j&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{className:"flex items-center gap-2 px-3 py-2 border border-border rounded-2xl bg-sidebar/50",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-base text-primary animate-spin",children:"progress_activity"}),(0,a.jsx)("span",{className:"text-sm",children:U?"Waiting for Grok Build OAuth…":"Waiting for popup authorization…"})]}),(0,a.jsxs)("div",{className:"flex items-center gap-3 my-1",children:[(0,a.jsx)("div",{className:"flex-1 h-px bg-border"}),(0,a.jsx)("span",{className:"text-xs text-text-muted uppercase tracking-wider",children:"Or paste callback URL manually"}),(0,a.jsx)("div",{className:"flex-1 h-px bg-border"})]}),(0,a.jsxs)("div",{className:"space-y-4",children:[(0,a.jsxs)("div",{children:[(0,a.jsxs)("p",{className:"text-sm font-medium mb-2",children:["Step 1: Open this ",U?"Grok Build OAuth URL":"URL"," in your browser"]}),(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsx)(i.pd,{value:p?.authUrl||"",readOnly:!0,className:"flex-1 font-mono text-xs"}),(0,a.jsx)(i.$n,{variant:"secondary",icon:"auth_url"===P?"check":"content_copy",onClick:()=>$(p?.authUrl,"auth_url"),disabled:!p?.authUrl,children:"Copy"})]})]}),(0,a.jsxs)("div",{children:[(0,a.jsxs)("p",{className:"text-sm font-medium mb-2",children:["Step 2: Paste the ","xai"===t?"callback URL or copied code":"callback URL"," here"]}),(0,a.jsx)("p",{className:"text-xs text-text-muted mb-2",children:"xai"===t?"If xAI shows a code instead of redirecting, paste that code here.":"After authorization, copy the full URL from your browser."}),(0,a.jsx)(i.pd,{value:f,onChange:e=>b(e.target.value),placeholder:U?"http://127.0.0.1:56121/callback?code=... or copied code":E,className:"font-mono text-xs"})]})]}),(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsx)(i.$n,{onClick:q,fullWidth:!0,disabled:!f,children:"Connect"}),(0,a.jsx)(i.$n,{onClick:M,variant:"ghost",fullWidth:!0,children:"Cancel"})]})]}),"waiting"===m&&j&&N&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{className:"text-center py-4",children:[(0,a.jsx)("p",{className:"text-sm text-text-muted mb-4",children:"Visit the login URL below and authorize:"}),(0,a.jsxs)("div",{className:"bg-sidebar p-4 rounded-2xl mb-4",children:[(0,a.jsx)("p",{className:"text-xs text-text-muted mb-1",children:"Login URL"}),(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("code",{className:"flex-1 text-sm break-all",children:D}),(0,a.jsx)(i.$n,{size:"sm",variant:"ghost",icon:"login_url"===P?"check":"content_copy",onClick:()=>$(D,"login_url"),disabled:!D}),(0,a.jsx)(i.$n,{size:"sm",variant:"ghost",icon:"open_in_new",onClick:()=>window.open(D,"_blank","noopener,noreferrer"),disabled:!D,children:"Open"})]})]}),(0,a.jsxs)("div",{className:"bg-primary/10 p-4 rounded-2xl",children:[(0,a.jsx)("p",{className:"text-xs text-text-muted mb-1",children:"Your Code"}),(0,a.jsxs)("div",{className:"flex items-center justify-center gap-2",children:[(0,a.jsx)("p",{className:"text-2xl font-mono font-bold text-primary",children:N.user_code}),(0,a.jsx)(i.$n,{size:"sm",variant:"ghost",icon:"user_code"===P?"check":"content_copy",onClick:()=>$(N.user_code,"user_code")})]})]})]}),k&&(0,a.jsxs)("div",{className:"flex items-center justify-center gap-2 text-sm text-text-muted",children:[(0,a.jsx)("span",{className:"material-symbols-outlined animate-spin",children:"progress_activity"}),"Waiting for authorization..."]})]}),"success"===m&&(0,a.jsxs)("div",{className:"text-center py-6",children:[(0,a.jsx)("div",{className:"size-16 mx-auto mb-4 rounded-full bg-green-100 dark:bg-green-900/30 flex items-center justify-center",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-3xl text-green-600",children:"check_circle"})}),(0,a.jsx)("h3",{className:"text-lg font-semibold mb-2",children:"Connected Successfully!"}),(0,a.jsxs)("p",{className:"text-sm text-text-muted mb-4",children:["Your ",s.name," account has been connected."]}),(0,a.jsx)(i.$n,{onClick:M,fullWidth:!0,children:"Done"})]}),"error"===m&&(0,a.jsxs)("div",{className:"text-center py-6",children:[(0,a.jsx)("div",{className:"size-16 mx-auto mb-4 rounded-full bg-red-100 dark:bg-red-900/30 flex items-center justify-center",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-3xl text-red-600",children:"error"})}),(0,a.jsx)("h3",{className:"text-lg font-semibold mb-2",children:"Connection Failed"}),(0,a.jsx)("p",{className:"text-sm text-red-600 mb-4",children:g}),(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsx)(i.$n,{onClick:z,variant:"secondary",fullWidth:!0,children:"Try Again"}),(0,a.jsx)(i.$n,{onClick:M,variant:"ghost",fullWidth:!0,children:"Cancel"})]})]})]})})}d.propTypes={isOpen:l().bool.isRequired,provider:l().string,providerInfo:l().shape({name:l().string}),onSuccess:l().func,onClose:l().func.isRequired,oauthMeta:l().object,idcConfig:l().shape({startUrl:l().string,region:l().string})}},91450:(e,t,s)=>{s.d(t,{default:()=>i});var a=s(95155),r=s(14051),n=s.n(r),l=s(38587);function i({children:e}){return(0,a.jsxs)("div",{className:"min-h-screen flex flex-col relative bg-bg transition-colors duration-500 overflow-x-hidden selection:bg-primary/20 selection:text-primary",children:[(0,a.jsx)("div",{className:"fixed top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 w-[800px] h-[800px] bg-primary/5 dark:bg-primary/5 rounded-full blur-[100px] pointer-events-none z-0"}),(0,a.jsx)("div",{className:"fixed bottom-0 right-0 w-[600px] h-[600px] bg-orange-200/20 dark:bg-orange-900/10 rounded-full blur-[120px] pointer-events-none z-0 translate-y-1/3 translate-x-1/3"}),(0,a.jsx)("div",{className:"absolute top-6 right-6 z-20",children:(0,a.jsx)(l.default,{variant:"card"})}),(0,a.jsx)("main",{className:"flex-1 flex flex-col items-center justify-center p-4 sm:p-6 z-10 w-full h-full",children:e})]})}i.propTypes={children:n().node.isRequired}},92173:(e,t,s)=>{s.d(t,{default:()=>c});var a=s(95155),r=s(98500),n=s.n(r),l=s(90620);let i=[{label:"Features",href:"#features"},{label:"Pricing",href:"#pricing"},{label:"Changelog",href:"#"}],o=[{label:"Documentation",href:"#"},{label:"API Reference",href:"#"},{label:"Help Center",href:"#"}],d=[{label:"About",href:"#"},{label:"Blog",href:"#"},{label:"Contact",href:"#"}];function c(){return(0,a.jsx)("footer",{className:"bg-bg border-t border-border pt-16 pb-12",children:(0,a.jsxs)("div",{className:"container mx-auto px-4 sm:px-6 lg:px-8",children:[(0,a.jsxs)("div",{className:"grid grid-cols-2 md:grid-cols-4 lg:grid-cols-5 gap-10 mb-12",children:[(0,a.jsxs)("div",{className:"col-span-2 lg:col-span-2",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2 mb-6",children:[(0,a.jsx)("div",{className:"size-6 text-primary",children:(0,a.jsx)("svg",{className:"w-full h-full",fill:"currentColor",viewBox:"0 0 48 48",children:(0,a.jsx)("path",{clipRule:"evenodd",d:"M12.0799 24L4 19.2479L9.95537 8.75216L18.04 13.4961L18.0446 4H29.9554L29.96 13.4961L38.0446 8.75216L44 19.2479L35.92 24L44 28.7521L38.0446 39.2479L29.96 34.5039L29.9554 44H18.0446L18.04 34.5039L9.95537 39.2479L4 28.7521L12.0799 24Z",fillRule:"evenodd"})})}),(0,a.jsx)("span",{className:"text-xl font-bold text-text-main",children:l.vQ.name})]}),(0,a.jsx)("p",{className:"text-text-muted mb-6 max-w-sm font-light",children:"The unified interface for modern AI infrastructure. Secure, observable, and scalable."}),(0,a.jsxs)("div",{className:"flex gap-4",children:[(0,a.jsx)("a",{href:"#",className:"text-gray-400 hover:text-primary transition-colors","aria-label":"Twitter",children:(0,a.jsx)("svg",{className:"w-5 h-5",fill:"currentColor",viewBox:"0 0 24 24",children:(0,a.jsx)("path",{d:"M22.46 6c-.77.35-1.6.58-2.46.69.88-.53 1.56-1.37 1.88-2.38-.83.5-1.75.85-2.72 1.05C18.37 4.5 17.26 4 16 4c-2.35 0-4.27 1.92-4.27 4.29 0 .34.04.67.11.98C8.28 9.09 5.11 7.38 3 4.79c-.37.63-.58 1.37-.58 2.15 0 1.49.75 2.81 1.91 3.56-.71 0-1.37-.2-1.95-.5v.03c0 2.08 1.48 3.82 3.44 4.21a4.22 4.22 0 0 1-1.93.07 4.28 4.28 0 0 0 4 2.98 8.521 8.521 0 0 1-5.33 1.84c-.34 0-.68-.02-1.02-.06C3.44 20.29 5.7 21 8.12 21 16 21 20.33 14.46 20.33 8.79c0-.19 0-.37-.01-.56.84-.6 1.56-1.36 2.14-2.23z"})})}),(0,a.jsx)("a",{href:"#",className:"text-gray-400 hover:text-primary transition-colors","aria-label":"GitHub",children:(0,a.jsx)("svg",{className:"w-5 h-5",fill:"currentColor",viewBox:"0 0 24 24",children:(0,a.jsx)("path",{d:"M12 2C6.477 2 2 6.484 2 12.017c0 4.425 2.865 8.18 6.839 9.504.5.092.682-.217.682-.483 0-.237-.008-.868-.013-1.703-2.782.605-3.369-1.343-3.369-1.343-.454-1.158-1.11-1.466-1.11-1.466-.908-.62.069-.608.069-.608 1.003.07 1.531 1.032 1.531 1.032.892 1.53 2.341 1.088 2.91.832.092-.647.35-1.088.636-1.338-2.22-.253-4.555-1.113-4.555-4.951 0-1.093.39-1.988 1.029-2.688-.103-.253-.446-1.272.098-2.65 0 0 .84-.27 2.75 1.026A9.564 9.564 0 0 1 12 6.844c.85.004 1.705.115 2.504.337 1.909-1.296 2.747-1.027 2.747-1.027.546 1.379.202 2.398.1 2.651.64.7 1.028 1.595 1.028 2.688 0 3.848-2.339 4.695-4.566 4.943.359.309.678.92.678 1.855 0 1.338-.012 2.419-.012 2.747 0 .268.18.58.688.482A10.019 10.019 0 0 0 22 12.017C22 6.484 17.522 2 12 2z"})})})]})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("h4",{className:"font-semibold text-text-main mb-4",children:"Product"}),(0,a.jsx)("ul",{className:"flex flex-col gap-3 text-sm text-text-muted font-light",children:i.map(e=>(0,a.jsx)("li",{children:(0,a.jsx)(n(),{href:e.href,className:"hover:text-primary transition-colors",children:e.label})},e.label))})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("h4",{className:"font-semibold text-text-main mb-4",children:"Resources"}),(0,a.jsx)("ul",{className:"flex flex-col gap-3 text-sm text-text-muted font-light",children:o.map(e=>(0,a.jsx)("li",{children:(0,a.jsx)(n(),{href:e.href,className:"hover:text-primary transition-colors",children:e.label})},e.label))})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("h4",{className:"font-semibold text-text-main mb-4",children:"Company"}),(0,a.jsx)("ul",{className:"flex flex-col gap-3 text-sm text-text-muted font-light",children:d.map(e=>(0,a.jsx)("li",{children:(0,a.jsx)(n(),{href:e.href,className:"hover:text-primary transition-colors",children:e.label})},e.label))})]})]}),(0,a.jsxs)("div",{className:"border-t border-border pt-8 flex flex-col md:flex-row justify-between items-center gap-4",children:[(0,a.jsxs)("p",{className:"text-sm text-text-muted",children:["\xa9 ",new Date().getFullYear()," ",l.vQ.name," Inc. All rights reserved."]}),(0,a.jsxs)("div",{className:"flex gap-6 text-sm text-text-muted",children:[(0,a.jsx)(n(),{href:"#",className:"hover:text-primary transition-colors",children:"Privacy Policy"}),(0,a.jsx)(n(),{href:"#",className:"hover:text-primary transition-colors",children:"Terms of Service"})]})]})]})})}},92542:(e,t,s)=>{s.d(t,{default:()=>i});var a=s(95155),r=s(31474);let n={primary:(0,r.cn)("bg-brand text-white border border-brand/20","shadow-[var(--neo-raised-sm)] hover:shadow-[var(--neo-raised)] hover:bg-brand-hover","disabled:bg-text-subtle disabled:text-surface disabled:border-transparent disabled:shadow-none"),secondary:(0,r.cn)("bg-surface hover:bg-surface-hover text-text border border-border","shadow-[var(--neo-flat)] hover:shadow-[var(--neo-raised-sm)]","disabled:opacity-50"),outline:(0,r.cn)("border border-border text-text bg-transparent","hover:bg-surface-hover hover:border-text-subtle","disabled:opacity-50"),ghost:(0,r.cn)("text-text-muted hover:bg-surface-hover hover:text-text","disabled:opacity-50"),danger:(0,r.cn)("bg-red-500 text-white border border-red-500/20","shadow-[var(--neo-raised-sm)] hover:shadow-[var(--neo-raised)] hover:bg-red-600","disabled:bg-text-subtle disabled:text-surface disabled:border-transparent disabled:shadow-none"),success:(0,r.cn)("bg-green-500 text-white border border-green-500/20","shadow-[var(--neo-raised-sm)] hover:shadow-[var(--neo-raised)] hover:bg-green-600","disabled:bg-text-subtle disabled:text-surface disabled:border-transparent disabled:shadow-none")},l={sm:"h-8 px-3 text-xs rounded-lg gap-1.5",md:"h-10 px-4 text-sm rounded-xl gap-2",lg:"h-12 px-6 text-sm rounded-xl gap-2"};function i({children:e,variant:t="primary",size:s="md",icon:o,iconRight:d,disabled:c=!1,loading:x=!1,fullWidth:m=!1,className:u,...p}){return(0,a.jsxs)("button",{className:(0,r.cn)("inline-flex items-center justify-center font-semibold transition-all duration-150 ease-out cursor-pointer","active:shadow-[var(--neo-pressed)] disabled:opacity-50 disabled:cursor-not-allowed disabled:active:shadow-none",n[t],l[s],m&&"w-full",u),disabled:c||x,...p,children:[x?(0,a.jsx)("span",{className:"material-symbols-outlined animate-spin text-[18px]",children:"progress_activity"}):o?(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:o}):null,e,d&&!x&&(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:d})]})}},94230:(e,t,s)=>{s.d(t,{default:()=>d});var a=s(95155),r=s(12115),n=s(14051),l=s.n(n),i=s(35497),o=s(11059);function d({isOpen:e,provider:t,onSuccess:s,onClose:n}){let[l,c]=(0,r.useState)("loading"),[x,m]=(0,r.useState)(""),[u,p]=(0,r.useState)(null),[h,f]=(0,r.useState)(""),[b,g]=(0,r.useState)(null),{copied:v,copy:j}=(0,o.C)(),y=(0,r.useRef)(!1);(0,r.useEffect)(()=>{e||(y.current=!1)},[e]),(0,r.useEffect)(()=>{e&&t&&(async()=>{try{g(null),c("loading");let e=await fetch(`/api/oauth/kiro/social-authorize?provider=${t}`),s=await e.json();if(!e.ok)throw Error(s.error);p(s),m(s.authUrl),c("input"),y.current||(y.current=!0,window.open(s.authUrl,"_blank"))}catch(e){g(e.message),c("error")}})()},[e,t]);let N=async()=>{try{let e;g(null);try{e=new URL(h)}catch(e){throw Error("Invalid callback URL format")}let a=e.searchParams.get("code");e.searchParams.get("state");let r=e.searchParams.get("error");if(r)throw Error(e.searchParams.get("error_description")||r);if(!a)throw Error("No authorization code found in URL");let n=await fetch("/api/oauth/kiro/social-exchange",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({code:a,codeVerifier:u.codeVerifier,provider:t})}),l=await n.json();if(!n.ok)throw Error(l.error);c("success"),s?.()}catch(e){g(e.message),c("error")}},w="google"===t?"Google":"GitHub";return(0,a.jsx)(i.aF,{isOpen:e,title:`Connect Kiro via ${w}`,onClose:n,size:"lg",children:(0,a.jsxs)("div",{className:"flex flex-col gap-4",children:["loading"===l&&(0,a.jsxs)("div",{className:"text-center py-6",children:[(0,a.jsx)("div",{className:"size-16 mx-auto mb-4 rounded-full bg-primary/10 flex items-center justify-center",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-3xl text-primary animate-spin",children:"progress_activity"})}),(0,a.jsx)("h3",{className:"text-lg font-semibold mb-2",children:"Initializing..."}),(0,a.jsxs)("p",{className:"text-sm text-text-muted",children:["Setting up ",w," authentication"]})]}),"input"===l&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{className:"space-y-4",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("p",{className:"text-sm font-medium mb-2",children:"Step 1: Open this URL in your browser"}),(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsx)(i.pd,{value:x,readOnly:!0,className:"flex-1 font-mono text-xs"}),(0,a.jsx)(i.$n,{variant:"secondary",icon:"auth_url"===v?"check":"content_copy",onClick:()=>j(x,"auth_url"),children:"Copy"})]})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("p",{className:"text-sm font-medium mb-2",children:"Step 2: Paste the callback URL here"}),(0,a.jsx)("p",{className:"text-xs text-text-muted mb-2",children:"After authorization, copy the full URL from your browser address bar."}),(0,a.jsx)(i.pd,{value:h,onChange:e=>f(e.target.value),placeholder:"kiro://kiro.kiroAgent/authenticate-success?code=...",className:"font-mono text-xs"})]})]}),(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsx)(i.$n,{onClick:N,fullWidth:!0,disabled:!h,children:"Connect"}),(0,a.jsx)(i.$n,{onClick:n,variant:"ghost",fullWidth:!0,children:"Cancel"})]})]}),"success"===l&&(0,a.jsxs)("div",{className:"text-center py-6",children:[(0,a.jsx)("div",{className:"size-16 mx-auto mb-4 rounded-full bg-green-100 dark:bg-green-900/30 flex items-center justify-center",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-3xl text-green-600",children:"check_circle"})}),(0,a.jsx)("h3",{className:"text-lg font-semibold mb-2",children:"Connected Successfully!"}),(0,a.jsxs)("p",{className:"text-sm text-text-muted mb-4",children:["Your Kiro account via ",w," has been connected."]}),(0,a.jsx)(i.$n,{onClick:n,fullWidth:!0,children:"Done"})]}),"error"===l&&(0,a.jsxs)("div",{className:"text-center py-6",children:[(0,a.jsx)("div",{className:"size-16 mx-auto mb-4 rounded-full bg-red-100 dark:bg-red-900/30 flex items-center justify-center",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-3xl text-red-600",children:"error"})}),(0,a.jsx)("h3",{className:"text-lg font-semibold mb-2",children:"Connection Failed"}),(0,a.jsx)("p",{className:"text-sm text-red-600 mb-4",children:b}),(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsx)(i.$n,{onClick:()=>c("input"),variant:"secondary",fullWidth:!0,children:"Try Again"}),(0,a.jsx)(i.$n,{onClick:n,variant:"ghost",fullWidth:!0,children:"Cancel"})]})]})]})})}d.propTypes={isOpen:l().bool.isRequired,provider:l().oneOf(["google","github"]).isRequired,onSuccess:l().func,onClose:l().func.isRequired}},95088:(e,t,s)=>{s.d(t,{default:()=>d});var a=s(95155),r=s(12115),n=s(14051),l=s.n(n),i=s(35497);let o="https://gitlab.com";function d({isOpen:e,providerInfo:t,onSuccess:s,onClose:n}){let l,[c,x]=(0,r.useState)(null),[m,u]=(0,r.useState)(o),[p,h]=(0,r.useState)(""),[f,b]=(0,r.useState)(""),[g,v]=(0,r.useState)(""),[j,y]=(0,r.useState)(!1),[N,w]=(0,r.useState)(null),[k,C]=(0,r.useState)(!1),[S,O]=(0,r.useState)(null),T=()=>{x(null),u(o),h(""),b(""),v(""),w(null),y(!1),C(!1),O(null),n()},P=async()=>{if(!g.trim())return void w("Personal Access Token is required");y(!0),w(null);try{let e=await fetch("/api/oauth/gitlab/pat",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({token:g.trim(),baseUrl:m.trim()||o})}),t=await e.json();if(!e.ok)throw Error(t.error||"Authentication failed");s?.(),T()}catch(e){w(e.message)}finally{y(!1)}};return e?k&&S?(0,a.jsx)(i.LF,{isOpen:!0,provider:"gitlab",providerInfo:t,oauthMeta:S,onSuccess:()=>{s?.(),T()},onClose:()=>{C(!1),O(null)}}):(0,a.jsx)(i.aF,{isOpen:e,title:"Connect GitLab Duo",onClose:T,size:"lg",children:(0,a.jsxs)("div",{className:"flex flex-col gap-4",children:[!c&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("p",{className:"text-sm text-text-muted",children:"Choose how to authenticate with GitLab Duo:"}),(0,a.jsxs)("div",{className:"grid grid-cols-2 gap-3",children:[(0,a.jsxs)("button",{onClick:()=>x("oauth"),className:"flex flex-col items-center gap-2 p-4 rounded-lg border border-border hover:border-primary hover:bg-primary/5 transition-colors text-left",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-2xl text-primary",children:"lock_open"}),(0,a.jsxs)("div",{children:[(0,a.jsx)("p",{className:"text-sm font-medium",children:"OAuth App"}),(0,a.jsx)("p",{className:"text-xs text-text-muted",children:"Use a GitLab OAuth application"})]})]}),(0,a.jsxs)("button",{onClick:()=>x("pat"),className:"flex flex-col items-center gap-2 p-4 rounded-lg border border-border hover:border-primary hover:bg-primary/5 transition-colors text-left",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-2xl text-primary",children:"key"}),(0,a.jsxs)("div",{children:[(0,a.jsx)("p",{className:"text-sm font-medium",children:"Personal Access Token"}),(0,a.jsx)("p",{className:"text-xs text-text-muted",children:"Use a GitLab PAT with api scope"})]})]})]})]}),"oauth"===c&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("p",{className:"text-xs text-text-muted",children:["Create an OAuth app at"," ",(0,a.jsx)("a",{href:`${m.trim()||o}/-/profile/applications`,target:"_blank",rel:"noreferrer",className:"text-primary underline",children:"GitLab Applications"})," ","with redirect URI"," ",(0,a.jsx)("code",{className:"bg-sidebar px-1 rounded text-xs",children:(l=window.location.port||("https:"===window.location.protocol?"443":"80"),`http://localhost:${l}/callback`)})]}),(0,a.jsx)(i.pd,{label:"GitLab Base URL",value:m,onChange:e=>u(e.target.value),placeholder:o}),(0,a.jsx)(i.pd,{label:"Client ID",value:p,onChange:e=>h(e.target.value),placeholder:"Your OAuth application client ID"}),(0,a.jsx)(i.pd,{label:"Client Secret (optional for PKCE)",value:f,onChange:e=>b(e.target.value),placeholder:"Leave empty for public PKCE app"}),N&&(0,a.jsx)("p",{className:"text-sm text-red-500",children:N}),(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsx)(i.$n,{onClick:()=>{p.trim()?(w(null),O({baseUrl:m.trim()||o,clientId:p.trim(),clientSecret:f.trim()}),C(!0)):w("Client ID is required")},fullWidth:!0,disabled:!p.trim(),children:"Authorize"}),(0,a.jsx)(i.$n,{onClick:()=>{x(null),w(null)},variant:"ghost",fullWidth:!0,children:"Back"})]})]}),"pat"===c&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("p",{className:"text-xs text-text-muted",children:["Create a PAT at"," ",(0,a.jsx)("a",{href:`${m.trim()||o}/-/user_settings/personal_access_tokens`,target:"_blank",rel:"noreferrer",className:"text-primary underline",children:"GitLab Access Tokens"})," ","with scopes: ",(0,a.jsx)("code",{className:"bg-sidebar px-1 rounded text-xs",children:"api"}),","," ",(0,a.jsx)("code",{className:"bg-sidebar px-1 rounded text-xs",children:"read_user"}),", and"," ",(0,a.jsx)("code",{className:"bg-sidebar px-1 rounded text-xs",children:"ai_features"}),"."]}),(0,a.jsx)(i.pd,{label:"GitLab Base URL",value:m,onChange:e=>u(e.target.value),placeholder:o}),(0,a.jsx)(i.pd,{label:"Personal Access Token",value:g,onChange:e=>v(e.target.value),placeholder:"glpat-xxxxxxxxxxxxxxxxxxxx",type:"password"}),N&&(0,a.jsx)("p",{className:"text-sm text-red-500",children:N}),(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsx)(i.$n,{onClick:P,fullWidth:!0,disabled:!g.trim()||j,loading:j,children:"Connect"}),(0,a.jsx)(i.$n,{onClick:()=>{x(null),w(null)},variant:"ghost",fullWidth:!0,children:"Back"})]})]})]})}):null}d.propTypes={isOpen:l().bool.isRequired,providerInfo:l().shape({name:l().string}),onSuccess:l().func,onClose:l().func.isRequired}},96748:(e,t,s)=>{s.d(t,{default:()=>d});var a=s(95155),r=s(12115),n=s(14051),l=s.n(n),i=s(35497);let o="https://api.openai.com/v1";function d({isOpen:e,onClose:t,onCreated:s,onSaved:n,node:l}){let c=!!l,[x,m]=(0,r.useState)({name:"",prefix:"",baseUrl:o}),[u,p]=(0,r.useState)(!1),[h,f]=(0,r.useState)(""),[b,g]=(0,r.useState)(""),[v,j]=(0,r.useState)(!1),[y,N]=(0,r.useState)(null);(0,r.useEffect)(()=>{e&&(N(null),f(""),g(""),c?m({name:l.name||"",prefix:l.prefix||"",baseUrl:l.baseUrl||o}):m({name:"",prefix:"",baseUrl:o}))},[e,c,l]);let w=async()=>{if(x.name.trim()&&x.prefix.trim()&&x.baseUrl.trim()){p(!0);try{let e=c?`/api/provider-nodes/${l.id}`:"/api/provider-nodes",t=c?"PUT":"POST",a={name:x.name,prefix:x.prefix,baseUrl:x.baseUrl};c||(a.type="custom-embedding");let r=await fetch(e,{method:t,headers:{"Content-Type":"application/json"},body:JSON.stringify(a)}),i=await r.json();r.ok&&(c?n?.(i.node):s?.(i.node))}catch(e){console.log("Error saving custom embedding node:",e)}finally{p(!1)}}},k=async()=>{j(!0);try{let e=await fetch("/api/provider-nodes/validate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({baseUrl:x.baseUrl,apiKey:h,type:"custom-embedding",modelId:b.trim()||void 0})}),t=await e.json();N(t)}catch{N({valid:!1,error:"Network error"})}finally{j(!1)}};return(0,a.jsx)(i.aF,{isOpen:e,title:c?"Edit Custom Embedding":"Add Custom Embedding",onClose:t,children:(0,a.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,a.jsx)(i.pd,{label:"Name",value:x.name,onChange:e=>m({...x,name:e.target.value}),placeholder:"Voyage AI",hint:"Required. A friendly label for this embedding provider."}),(0,a.jsx)(i.pd,{label:"Prefix",value:x.prefix,onChange:e=>m({...x,prefix:e.target.value}),placeholder:"voyage",hint:"Required. Used as the provider prefix for model IDs (e.g. voyage/voyage-3)."}),(0,a.jsx)(i.pd,{label:"Base URL",value:x.baseUrl,onChange:e=>m({...x,baseUrl:e.target.value}),placeholder:"https://api.voyageai.com/v1",hint:"Most embedding APIs are OpenAI-compatible: Voyage, Cohere, Jina, Mistral, Together..."}),(0,a.jsx)(i.pd,{label:"API Key (for Check)",type:"password",value:h,onChange:e=>f(e.target.value)}),(0,a.jsx)(i.pd,{label:"Model ID (for Check)",value:b,onChange:e=>g(e.target.value),placeholder:"e.g. voyage-3, embed-english-v3.0, text-embedding-3-small",hint:"Required for validation. Will send a test embeddings request."}),(0,a.jsxs)("div",{className:"flex items-center gap-3",children:[(0,a.jsx)(i.$n,{onClick:k,disabled:!h||!b.trim()||v||!x.baseUrl.trim(),variant:"secondary",children:v?"Checking...":"Check"}),(()=>{if(!y)return null;let{valid:e,error:t,dimensions:s}=y;return e?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(i.Ex,{variant:"success",children:"Valid"}),s&&(0,a.jsxs)("span",{className:"text-sm text-text-muted",children:[s," dims"]})]}):(0,a.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,a.jsx)(i.Ex,{variant:"error",children:"Invalid"}),t&&(0,a.jsx)("span",{className:"text-sm text-red-500",children:t})]})})()]}),(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsx)(i.$n,{onClick:w,fullWidth:!0,disabled:!x.name.trim()||!x.prefix.trim()||!x.baseUrl.trim()||u,children:u?c?"Saving...":"Creating...":c?"Save":"Create"}),(0,a.jsx)(i.$n,{onClick:t,variant:"ghost",fullWidth:!0,children:"Cancel"})]})]})})}d.propTypes={isOpen:l().bool.isRequired,onClose:l().func.isRequired,onCreated:l().func,onSaved:l().func,node:l().shape({id:l().string,name:l().string,prefix:l().string,baseUrl:l().string})}},97677:(e,t,s)=>{s.d(t,{default:()=>r});var a=s(95155);function r({text:e,children:t,position:s="top",color:n}){let l=n?"":"bg-gray-900";return(0,a.jsxs)("div",{className:"relative inline-flex group/tt",children:[t,(0,a.jsx)("div",{className:`pointer-events-none absolute ${{top:"bottom-full left-1/2 -translate-x-1/2 mb-1.5",bottom:"top-full left-1/2 -translate-x-1/2 mt-1.5",left:"right-full top-1/2 -translate-y-1/2 mr-1.5",right:"left-full top-1/2 -translate-y-1/2 ml-1.5"}[s]} z-50 w-max max-w-56 rounded px-2 py-1 text-[11px] leading-snug ${l} text-white opacity-0 group-hover/tt:opacity-100 transition-opacity duration-150 whitespace-normal`,style:n?{backgroundColor:n}:{},children:e})]})}},98542:(e,t,s)=>{s.d(t,{default:()=>n});var a=s(95155),r=s(31474);function n({checked:e=!1,onChange:t,label:s,description:l,disabled:i=!1,size:o="md",className:d}){let c={sm:{track:"w-8 h-4",thumb:"size-3",translate:"translate-x-4"},md:{track:"w-11 h-6",thumb:"size-5",translate:"translate-x-5"},lg:{track:"w-14 h-7",thumb:"size-6",translate:"translate-x-7"}};return(0,a.jsxs)("div",{className:(0,r.cn)("flex items-center gap-3",i&&"opacity-50 cursor-not-allowed",d),children:[(0,a.jsx)("button",{type:"button",role:"switch","aria-checked":e,disabled:i,onClick:()=>{!i&&t&&t(!e)},className:(0,r.cn)("relative inline-flex shrink-0 cursor-pointer rounded-full","transition-colors duration-200 border","focus:outline-none focus:ring-2 focus:ring-brand/30",e?"bg-brand border-brand/20 shadow-[var(--neo-pressed)]":"bg-bg-alt border-border shadow-[var(--neo-flat)]",c[o].track,i&&"cursor-not-allowed"),children:(0,a.jsx)("span",{className:(0,r.cn)("pointer-events-none inline-block rounded-full bg-white shadow-sm","transition-transform duration-200",e?c[o].translate:"translate-x-0.5",c[o].thumb,"mt-0.5")})}),(s||l)&&(0,a.jsxs)("div",{className:"flex flex-col",children:[s&&(0,a.jsx)("span",{className:"text-sm font-medium text-text leading-tight",children:s}),l&&(0,a.jsx)("span",{className:"text-xs text-text-muted mt-0.5",children:l})]})]})}},99069:(e,t,s)=>{s.d(t,{default:()=>V});var a=s(95155),r=s(12115),n=s(73321),l=s(88105),i=s(56061),o=s(84588),d=s(14051),c=s.n(d);let x=[{key:"totalRequests",label:"Total Requests",icon:"bolt",accent:"brand"},{key:"totalPromptTokens",label:"Input Tokens",icon:"input",accent:"blue"},{key:"totalCompletionTokens",label:"Output Tokens",icon:"output",accent:"green"},{key:"totalCost",label:"Est. Cost",icon:"payments",accent:"amber",format:"cost"}],m={brand:{icon:"text-brand",value:"text-brand"},blue:{icon:"text-blue-500",value:"text-blue-500"},green:{icon:"text-green-500",value:"text-green-500"},amber:{icon:"text-amber-500",value:"text-amber-500"}};function u({stats:e}){return(0,a.jsx)("div",{className:"grid min-w-0 grid-cols-1 gap-3 sm:grid-cols-2 md:grid-cols-4",children:x.map(t=>{let s=m[t.accent],r=e?.[t.key]||0,n="cost"===t.format?`~$${(r||0).toFixed(2)}`:new Intl.NumberFormat().format(r||0);return(0,a.jsxs)("div",{className:"neo-raised p-4",children:[(0,a.jsxs)("div",{className:"flex items-start justify-between mb-2",children:[(0,a.jsx)("span",{className:"text-[10px] font-medium uppercase tracking-wide text-text-muted",children:t.label}),(0,a.jsx)("span",{className:`material-symbols-outlined text-[16px] ${s.icon}`,children:t.icon})]}),(0,a.jsx)("div",{className:`text-xl font-bold ${s.value}`,children:n}),"cost"===t.format&&(0,a.jsx)("div",{className:"text-[10px] text-text-subtle mt-1",children:"Estimated, not actual billing"})]},t.key)})})}u.propTypes={stats:c().object.isRequired};let p=e=>new Intl.NumberFormat().format(e||0),h=e=>`$${(e||0).toFixed(2)}`;function f(e){if(!e)return"Never";let t=Math.floor((Date.now()-new Date(e))/6e4);return t<1?"Just now":t<60?`${t}m ago`:t<1440?`${Math.floor(t/60)}h ago`:new Date(e).toLocaleDateString()}function b({field:e,currentSort:t,currentOrder:s}){return t!==e?(0,a.jsx)("span",{className:"ml-1 opacity-20",children:"↕"}):(0,a.jsx)("span",{className:"ml-1",children:"asc"===s?"↑":"↓"})}function g({item:e,viewMode:t,isSummary:s=!1}){return"tokens"===t?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("td",{className:"px-6 py-3 text-right text-text-muted",children:s&&void 0===e.promptTokens?"—":p(e.promptTokens)}),(0,a.jsx)("td",{className:"px-6 py-3 text-right text-text-muted",children:s&&void 0===e.completionTokens?"—":p(e.completionTokens)}),(0,a.jsx)("td",{className:"px-6 py-3 text-right font-medium",children:p(e.totalTokens)})]}):(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("td",{className:"px-6 py-3 text-right text-text-muted",children:s&&void 0===e.inputCost?"—":h(e.inputCost)}),(0,a.jsx)("td",{className:"px-6 py-3 text-right text-text-muted",children:s&&void 0===e.outputCost?"—":h(e.outputCost)}),(0,a.jsx)("td",{className:"px-6 py-3 text-right font-medium text-warning",children:h(e.totalCost||e.cost)})]})}function v({title:e,columns:t,groupedData:s,tableType:n,sortBy:l,sortOrder:i,onToggleSort:d,viewMode:c,storageKey:x,renderDetailCells:m,renderSummaryCells:u,emptyMessage:p}){let[h,f]=(0,r.useState)(new Set);(0,r.useEffect)(()=>{try{let e=localStorage.getItem(x);e&&f(new Set(JSON.parse(e)))}catch(e){console.error(`Failed to load ${x}:`,e)}},[x]),(0,r.useEffect)(()=>{try{localStorage.setItem(x,JSON.stringify([...h]))}catch(e){console.error(`Failed to save ${x}:`,e)}},[h,x]);let j=(0,r.useCallback)(e=>{f(t=>{let s=new Set(t);return s.has(e)?s.delete(e):s.add(e),s})},[]),y=(0,r.useMemo)(()=>"tokens"===c?[{field:"promptTokens",label:"Input Tokens"},{field:"completionTokens",label:"Output Tokens"},{field:"totalTokens",label:"Total Tokens"}]:[{field:"promptTokens",label:"Input Cost"},{field:"completionTokens",label:"Output Cost"},{field:"cost",label:"Total Cost"}],[c]),N=t.length+y.length;return(0,a.jsxs)(o.default,{className:"overflow-hidden",children:[(0,a.jsx)("div",{className:"p-4 border-b border-border bg-bg-subtle/50",children:(0,a.jsx)("h3",{className:"font-semibold",children:e})}),(0,a.jsx)("div",{className:"overflow-x-auto",children:(0,a.jsxs)("table",{className:"w-full text-sm text-left",children:[(0,a.jsx)("thead",{className:"bg-bg-subtle/30 text-text-muted uppercase text-xs",children:(0,a.jsxs)("tr",{children:[t.map(e=>(0,a.jsxs)("th",{className:`px-6 py-3 cursor-pointer hover:bg-bg-subtle/50 ${"right"===e.align?"text-right":""}`,onClick:()=>d(n,e.field),children:[e.label," ",(0,a.jsx)(b,{field:e.field,currentSort:l,currentOrder:i})]},e.field)),y.map(e=>(0,a.jsxs)("th",{className:"px-6 py-3 text-right cursor-pointer hover:bg-bg-subtle/50",onClick:()=>d(n,e.field),children:[e.label," ",(0,a.jsx)(b,{field:e.field,currentSort:l,currentOrder:i})]},e.field))]})}),(0,a.jsxs)("tbody",{className:"divide-y divide-border",children:[s.map(e=>(0,a.jsxs)(r.Fragment,{children:[(0,a.jsxs)("tr",{className:"group-summary cursor-pointer hover:bg-bg-subtle/50 transition-colors",onClick:()=>j(e.groupKey),children:[(0,a.jsx)("td",{className:"px-6 py-3",children:(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("span",{className:`material-symbols-outlined text-[18px] text-text-muted transition-transform ${h.has(e.groupKey)?"rotate-90":""}`,children:"chevron_right"}),(0,a.jsx)("span",{className:`font-medium transition-colors ${e.summary.pending>0?"text-primary":""}`,children:e.groupKey})]})}),u(e),(0,a.jsx)(g,{item:e.summary,viewMode:c,isSummary:!0})]}),h.has(e.groupKey)&&e.items.map(e=>(0,a.jsxs)("tr",{className:"group-detail hover:bg-bg-subtle/20 transition-colors",children:[m(e),(0,a.jsx)(g,{item:e,viewMode:c})]},`detail-${e.key}`))]},e.groupKey)),0===s.length&&(0,a.jsx)("tr",{children:(0,a.jsx)("td",{colSpan:N,className:"px-6 py-8 text-center text-text-muted",children:p})})]})]})})]})}function j(e){return l.Q2[e]||{color:"#6b7280",name:e}}function y({providerId:e,color:t,size:s=28}){let[n,l]=(0,r.useState)(!1),i=j(e).textIcon||(e||"?").slice(0,2).toUpperCase();return(0,a.jsx)("div",{className:"flex items-center justify-center rounded-lg shrink-0",style:{width:s,height:s,backgroundColor:`color-mix(in srgb, ${t} 12%, transparent)`},children:n?(0,a.jsx)("span",{className:"font-bold",style:{color:t,fontSize:.35*s},children:i}):(0,a.jsx)("img",{src:`/providers/${e}.png`,alt:e,className:"rounded object-contain",style:{width:.7*s,height:.7*s},onError:()=>l(!0)})})}function N({provider:e,active:t,error:s,last:r,requests:n,maxRequests:l}){let i=j(e.provider),o=i.color||"#6b7280",d=(i.name!==e.provider?i.name:null)||e.nodeName||e.name||e.provider,c=t?o:s?"#ef4444":r?"#f59e0b":"var(--border)",x=t?`color-mix(in srgb, ${o} 6%, var(--surface))`:"var(--surface)";return(0,a.jsxs)("div",{className:"flex items-center gap-3 p-3 rounded-xl border transition-all",style:{borderColor:c,background:x,boxShadow:t?`0 0 16px color-mix(in srgb, ${o} 12%, transparent)`:"var(--neo-raised-sm)"},children:[(0,a.jsx)(y,{providerId:e.provider,color:o}),(0,a.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("span",{className:"text-sm font-semibold truncate",style:{color:t?o:"var(--text)"},children:d}),t&&(0,a.jsxs)("span",{className:"relative flex h-2 w-2 shrink-0",children:[(0,a.jsx)("span",{className:"absolute inline-flex h-full w-full rounded-full opacity-40",style:{backgroundColor:o,animation:"pulse 2s infinite"}}),(0,a.jsx)("span",{className:"relative inline-flex rounded-full h-2 w-2",style:{backgroundColor:o}})]}),s&&!t&&(0,a.jsx)("span",{className:"block h-2 w-2 rounded-full bg-red-500 shrink-0"}),!t&&!s&&!r&&(0,a.jsx)("span",{className:"block h-2 w-2 rounded-full bg-text-subtle shrink-0"}),r&&!t&&!s&&(0,a.jsx)("span",{className:"block h-2 w-2 rounded-full bg-amber-500 shrink-0"})]}),(0,a.jsx)("div",{className:"mt-2 h-1.5 rounded-full overflow-hidden",style:{background:"var(--bg-alt)"},children:(0,a.jsx)("div",{className:"h-full rounded-full transition-all duration-500",style:{width:`${l>0?n/l*100:0}%`,background:t?o:s?"#ef4444":r?"#f59e0b":"var(--text-subtle)"}})}),(0,a.jsxs)("div",{className:"mt-1 flex items-center justify-between",children:[(0,a.jsx)("span",{className:"text-[10px] text-text-muted",children:i.name!==e.provider?e.provider:""}),(0,a.jsx)("span",{className:"text-[10px] font-mono text-text-muted",children:n>0?`${n} req${1!==n?"s":""}`:"idle"})]})]})]})}function w({providers:e=[],activeRequests:t=[],lastProvider:s="",errorProvider:n=""}){let[l,i]=(0,r.useState)(!1),d=(0,r.useRef)({}),[c,x]=(0,r.useState)(0),m=(0,r.useMemo)(()=>t.map(e=>e.provider?.toLowerCase()).filter(Boolean).sort().join(","),[t]),u=s?.toLowerCase()||"",p=n?.toLowerCase()||"",h=(0,r.useMemo)(()=>new Set(m?m.split(","):[]),[m]);(0,r.useEffect)(()=>{let e=d.current,t=Date.now();for(let s of h)e[s]||(e[s]=t);for(let t of Object.keys(e))h.has(t)||delete e[t]},[h]),(0,r.useEffect)(()=>{if(0===h.size)return;let e=setInterval(()=>x(e=>e+1),1e3);return()=>clearInterval(e)},[h]);let f=(0,r.useMemo)(()=>{let e=Date.now(),t=new Set;for(let s of h){let a=d.current[s];(!a||e-a<6e4)&&t.add(s)}return t},[h,c]),b=(0,r.useMemo)(()=>{let e={};for(let s of t){let t=s.provider?.toLowerCase();t&&(e[t]=(e[t]||0)+1)}return e},[t]),g=(0,r.useMemo)(()=>[...e].sort((e,t)=>{let s=e.provider?.toLowerCase(),a=t.provider?.toLowerCase(),r=+!f.has(s),n=+!f.has(a);if(r!==n)return r-n;let l=+(p!==s),i=+(p!==a);return l!==i?l-i:(u!==s)-(u!==a)}),[e,f,u,p]),v=(0,r.useMemo)(()=>Math.max(1,...g.map(e=>b[e.provider?.toLowerCase()]||0)),[g,b]),j=l?g:g.slice(0,12),y=g.length-12;return 0===e.length?(0,a.jsx)(o.default,{className:"flex items-center justify-center h-[320px]",padding:"none",children:(0,a.jsx)("div",{className:"text-text-muted text-sm",children:"No providers connected"})}):(0,a.jsxs)(o.default,{className:"overflow-hidden",padding:"none",children:[(0,a.jsxs)("div",{className:"px-4 py-3 border-b border-border flex items-center justify-between",children:[(0,a.jsxs)("div",{className:"flex items-center gap-3",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2 px-3 py-1.5 rounded-xl bg-brand/10 border border-brand/20",children:[(0,a.jsx)("img",{src:"/favicon.svg",alt:"Prozygent",className:"w-4 h-4"}),(0,a.jsx)("span",{className:"text-xs font-bold text-brand",children:"Prozygent"}),f.size>0&&(0,a.jsx)("span",{className:"px-1.5 py-0.5 rounded-full bg-brand text-white text-[9px] font-bold",children:f.size})]}),(0,a.jsx)("span",{className:"material-symbols-outlined text-text-subtle text-[16px]",children:"arrow_downward"}),(0,a.jsx)("h3",{className:"text-sm font-semibold text-text",children:"Providers"})]}),(0,a.jsxs)("div",{className:"flex items-center gap-3 text-[10px] text-text-muted",children:[(0,a.jsxs)("span",{className:"flex items-center gap-1",children:[(0,a.jsx)("span",{className:"w-2 h-2 rounded-full bg-green-500"})," Active"]}),(0,a.jsxs)("span",{className:"flex items-center gap-1",children:[(0,a.jsx)("span",{className:"w-2 h-2 rounded-full bg-amber-500"})," Last"]}),(0,a.jsxs)("span",{className:"flex items-center gap-1",children:[(0,a.jsx)("span",{className:"w-2 h-2 rounded-full bg-red-500"})," Error"]}),(0,a.jsx)("span",{className:"text-text-subtle",children:"|"}),(0,a.jsxs)("span",{children:[e.length," total"]})]})]}),(0,a.jsx)("div",{className:"flex justify-center",children:(0,a.jsx)("div",{className:"w-px h-4 bg-border"})}),(0,a.jsxs)("div",{className:"px-4 pb-4",children:[(0,a.jsx)("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-2",children:j.map(e=>(0,a.jsx)(N,{provider:e,active:f.has(e.provider?.toLowerCase()),error:p===e.provider?.toLowerCase(),last:u===e.provider?.toLowerCase()&&!f.has(e.provider?.toLowerCase()),requests:b[e.provider?.toLowerCase()]||0,maxRequests:v},e.provider))}),!l&&y>0&&(0,a.jsxs)("button",{onClick:()=>i(!0),className:"mt-3 w-full py-2 rounded-xl border border-border text-xs font-medium text-text-muted hover:text-text hover:bg-surface-hover transition-colors",children:["Show ",y," more providers"]}),l&&y>0&&(0,a.jsx)("button",{onClick:()=>i(!1),className:"mt-3 w-full py-2 rounded-xl border border-border text-xs font-medium text-text-muted hover:text-text hover:bg-surface-hover transition-colors",children:"Show less"})]})]})}b.propTypes={field:c().string.isRequired,currentSort:c().string.isRequired,currentOrder:c().string.isRequired},g.propTypes={item:c().object.isRequired,viewMode:c().string.isRequired,isSummary:c().bool},v.propTypes={title:c().string.isRequired,columns:c().arrayOf(c().shape({field:c().string.isRequired,label:c().string.isRequired,align:c().string})).isRequired,groupedData:c().array.isRequired,tableType:c().string.isRequired,sortBy:c().string.isRequired,sortOrder:c().string.isRequired,onToggleSort:c().func.isRequired,viewMode:c().string.isRequired,storageKey:c().string.isRequired,renderDetailCells:c().func.isRequired,renderSummaryCells:c().func.isRequired,emptyMessage:c().string.isRequired},w.propTypes={providers:c().arrayOf(c().shape({id:c().string,provider:c().string,name:c().string})),activeRequests:c().arrayOf(c().shape({provider:c().string,model:c().string,account:c().string})),lastProvider:c().string,errorProvider:c().string};var k=s(21742),C=s(63346),S=s(28408),O=s(32539),T=s(59656),P=s(55433),$=s(40968);let I=e=>e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}K`:String(e||0),F=e=>`$${(e||0).toFixed(4)}`;function E({active:e,payload:t,label:s,viewMode:r}){if(!e||!t||!t.length)return null;let n=t[0].value;return(0,a.jsxs)("div",{className:"neo-raised-sm px-3 py-2 rounded-xl text-xs",children:[(0,a.jsx)("div",{className:"text-text-muted mb-1",children:s}),(0,a.jsx)("div",{className:"font-semibold text-text",children:"tokens"===r?I(n):F(n)})]})}function _({period:e="7d"}){let[t,s]=(0,r.useState)([]),[n,l]=(0,r.useState)(!0),[i,d]=(0,r.useState)("tokens"),c=(0,r.useCallback)(async()=>{l(!0);try{let t=await fetch(`/api/usage/chart?period=${e}`);if(t.ok){let e=await t.json();s(e)}}catch(e){console.error("Failed to fetch chart data:",e)}finally{l(!1)}},[e]);(0,r.useEffect)(()=>{c()},[c]);let x=t.some(e=>e.tokens>0||e.cost>0);return(0,a.jsxs)(o.default,{className:"flex min-w-0 flex-col gap-3 p-3 sm:p-4",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between",children:[(0,a.jsx)("h3",{className:"text-sm font-semibold text-text",children:"Usage Over Time"}),(0,a.jsxs)("div",{className:"grid grid-cols-2 items-center gap-1 rounded-xl border border-border bg-bg-alt p-1",children:[(0,a.jsx)("button",{onClick:()=>d("tokens"),className:`px-3 py-1 rounded-lg text-xs font-medium transition-colors ${"tokens"===i?"bg-brand text-white shadow-sm":"text-text-muted hover:text-text"}`,children:"Tokens"}),(0,a.jsx)("button",{onClick:()=>d("cost"),className:`px-3 py-1 rounded-lg text-xs font-medium transition-colors ${"cost"===i?"bg-brand text-white shadow-sm":"text-text-muted hover:text-text"}`,children:"Cost"})]})]}),n?(0,a.jsx)("div",{className:"h-48 flex items-center justify-center text-text-muted text-sm",children:"Loading..."}):x?(0,a.jsx)(k.u,{width:"100%",height:220,children:(0,a.jsxs)(C.Q,{data:t,margin:{top:4,right:8,left:0,bottom:0},children:[(0,a.jsxs)("defs",{children:[(0,a.jsxs)("linearGradient",{id:"gradTokens",x1:"0",y1:"0",x2:"0",y2:"1",children:[(0,a.jsx)("stop",{offset:"5%",stopColor:"#6c63ff",stopOpacity:.2}),(0,a.jsx)("stop",{offset:"95%",stopColor:"#6c63ff",stopOpacity:0})]}),(0,a.jsxs)("linearGradient",{id:"gradCost",x1:"0",y1:"0",x2:"0",y2:"1",children:[(0,a.jsx)("stop",{offset:"5%",stopColor:"#f59e0b",stopOpacity:.2}),(0,a.jsx)("stop",{offset:"95%",stopColor:"#f59e0b",stopOpacity:0})]})]}),(0,a.jsx)(S.d,{strokeDasharray:"3 3",stroke:"var(--border)"}),(0,a.jsx)(O.W,{dataKey:"label",tick:{fontSize:10,fill:"var(--text-muted)"},tickLine:!1,axisLine:!1,interval:"preserveStartEnd"}),(0,a.jsx)(T.h,{tick:{fontSize:10,fill:"var(--text-muted)"},tickLine:!1,axisLine:!1,tickFormatter:"tokens"===i?I:F,width:50}),(0,a.jsx)(P.m,{content:(0,a.jsx)(E,{viewMode:i})}),"tokens"===i?(0,a.jsx)($.Gk,{type:"monotone",dataKey:"tokens",stroke:"#6c63ff",strokeWidth:2,fill:"url(#gradTokens)",dot:!1,activeDot:{r:4,fill:"#6c63ff",stroke:"var(--surface)",strokeWidth:2}}):(0,a.jsx)($.Gk,{type:"monotone",dataKey:"cost",stroke:"#f59e0b",strokeWidth:2,fill:"url(#gradCost)",dot:!1,activeDot:{r:4,fill:"#f59e0b",stroke:"var(--surface)",strokeWidth:2}})]})}):(0,a.jsx)("div",{className:"h-48 flex items-center justify-center text-text-muted text-sm",children:"No data for this period"})]})}function A(e){let t=l.Q2[e];return!t?.serviceKinds||t.serviceKinds.includes("llm")}function W({timestamp:e}){let t,[,s]=(0,r.useState)(0);return(0,r.useEffect)(()=>{let e=setInterval(()=>s(e=>e+1),1e3);return()=>clearInterval(e)},[]),(0,a.jsx)(a.Fragment,{children:(t=Math.floor((Date.now()-new Date(e))/1e3))<60?`${t}s ago`:t<3600?`${Math.floor(t/60)}m ago`:t<86400?`${Math.floor(t/3600)}h ago`:`${Math.floor(t/86400)}d ago`})}function R({requests:e=[]}){return(0,a.jsxs)(o.default,{className:"flex min-w-0 flex-col overflow-hidden",padding:"sm",style:{height:480},children:[(0,a.jsx)("div",{className:"px-1 py-2 border-b border-border shrink-0",children:(0,a.jsx)("span",{className:"text-xs font-semibold text-text-muted uppercase tracking-wide",children:"Recent Requests"})}),e.length?(0,a.jsx)("div",{className:"flex-1 overflow-y-auto",children:(0,a.jsxs)("table",{className:"w-full min-w-[300px] border-collapse text-xs",children:[(0,a.jsx)("thead",{className:"sticky top-0 bg-bg z-10",children:(0,a.jsxs)("tr",{className:"border-b border-border",children:[(0,a.jsx)("th",{className:"py-1.5 text-left font-semibold text-text-muted w-2"}),(0,a.jsx)("th",{className:"py-1.5 text-left font-semibold text-text-muted",children:"Model"}),(0,a.jsx)("th",{className:"py-1.5 text-right font-semibold text-text-muted whitespace-nowrap",children:"In / Out"}),(0,a.jsx)("th",{className:"py-1.5 text-right font-semibold text-text-muted",children:"When"})]})}),(0,a.jsx)("tbody",{className:"divide-y divide-border/50",children:e.map((e,t)=>{let s=!e.status||"ok"===e.status||"success"===e.status;return(0,a.jsxs)("tr",{className:"hover:bg-bg-subtle transition-colors",children:[(0,a.jsx)("td",{className:"py-1.5",children:(0,a.jsx)("span",{className:`block w-1.5 h-1.5 rounded-full ${s?"bg-success":"bg-error"}`})}),(0,a.jsx)("td",{className:"py-1.5 font-mono truncate max-w-[120px]",title:e.model,children:e.model}),(0,a.jsxs)("td",{className:"py-1.5 text-right whitespace-nowrap",children:[(0,a.jsxs)("span",{className:"text-primary",children:[p(e.promptTokens),"↑"]})," ",(0,a.jsxs)("span",{className:"text-success",children:[p(e.completionTokens),"↓"]})]}),(0,a.jsx)("td",{className:"py-1.5 text-right text-text-muted whitespace-nowrap",children:(0,a.jsx)(W,{timestamp:e.timestamp})})]},t)})})]})}):(0,a.jsx)("div",{className:"flex-1 flex items-center justify-center text-text-muted text-sm",children:"No requests yet."})]})}function L(e,t={},s,a){return Object.entries(e||{}).map(([e,s])=>{let a=(s.promptTokens||0)+(s.completionTokens||0),r=s.cost||0,n=a>0?(s.promptTokens||0)*(r/a):0,l=a>0?(s.completionTokens||0)*(r/a):0;return{...s,key:e,totalTokens:a,totalCost:r,inputCost:n,outputCost:l,pending:t[e]||0}}).sort((e,t)=>{let r=e[s],n=t[s];return("string"==typeof r&&(r=r.toLowerCase()),"string"==typeof n&&(n=n.toLowerCase()),r<n)?"asc"===a?-1:1:r>n?"asc"===a?1:-1:0})}function z(e,t){if(!Array.isArray(e))return[];let s={};return e.forEach(e=>{let a=function(e,t){switch(t){case"rawModel":return e.rawModel||"Unknown Model";case"accountName":return e.accountName||`Account ${e.connectionId?.slice(0,8)}...`||"Unknown Account";case"keyName":return e.keyName||"Unknown Key";case"endpoint":return e.endpoint||"Unknown Endpoint";default:return e[t]||"Unknown"}}(e,t);s[a]||(s[a]={groupKey:a,summary:{requests:0,promptTokens:0,completionTokens:0,totalTokens:0,cost:0,inputCost:0,outputCost:0,lastUsed:null,pending:0},items:[]});let r=s[a].summary;r.requests+=e.requests||0,r.promptTokens+=e.promptTokens||0,r.completionTokens+=e.completionTokens||0,r.totalTokens+=e.totalTokens||0,r.cost+=e.cost||0,r.inputCost+=e.inputCost||0,r.outputCost+=e.outputCost||0,r.pending+=e.pending||0,e.lastUsed&&(!r.lastUsed||new Date(e.lastUsed)>new Date(r.lastUsed))&&(r.lastUsed=e.lastUsed),s[a].items.push(e)}),Object.values(s)}_.propTypes={period:c().string};let q=[{field:"rawModel",label:"Model"},{field:"provider",label:"Provider"},{field:"requests",label:"Requests",align:"right"},{field:"lastUsed",label:"Last Used",align:"right"}],M=[{field:"rawModel",label:"Model"},{field:"provider",label:"Provider"},{field:"accountName",label:"Account"},{field:"requests",label:"Requests",align:"right"},{field:"lastUsed",label:"Last Used",align:"right"}],U=[{field:"keyName",label:"API Key Name"},{field:"rawModel",label:"Model"},{field:"provider",label:"Provider"},{field:"requests",label:"Requests",align:"right"},{field:"lastUsed",label:"Last Used",align:"right"}],D=[{field:"endpoint",label:"Endpoint"},{field:"rawModel",label:"Model"},{field:"provider",label:"Provider"},{field:"requests",label:"Requests",align:"right"},{field:"lastUsed",label:"Last Used",align:"right"}],K=[{value:"model",label:"Usage by Model"},{value:"account",label:"Usage by Account"},{value:"apiKey",label:"Usage by API Key"},{value:"endpoint",label:"Usage by Endpoint"}],B=[{value:"today",label:"Today"},{value:"24h",label:"24h"},{value:"7d",label:"7D"},{value:"30d",label:"30D"},{value:"60d",label:"60D"}];function V({period:e,setPeriod:t,hidePeriodSelector:s=!1}={}){let o=(0,n.useRouter)(),d=(0,n.useSearchParams)(),c=d.get("sortBy")||"rawModel",x=d.get("sortOrder")||"asc",[m,h]=(0,r.useState)(null),[b,g]=(0,r.useState)(!0),[j,y]=(0,r.useState)(!1),[N,k]=(0,r.useState)("model"),[C,S]=(0,r.useState)("costs"),[O,T]=(0,r.useState)([]),[P,$]=(0,r.useState)("today"),I=(0,r.useRef)(!0),F=(0,r.useRef)(!1),E=e??P,W=t??$;(0,r.useEffect)(()=>{Promise.all([fetch("/api/providers").then(e=>e.ok?e.json():null),fetch("/api/provider-nodes").then(e=>e.ok?e.json():null)]).then(([e,t])=>{let s={};for(let e of t?.nodes||[])s[e.id]=e.name;let a=new Set;T([...(e?.connections||[]).filter(e=>!(!1===e.isActive||!A(e.provider)||a.has(e.provider))&&(a.add(e.provider),!0)).map(e=>({...e,nodeName:s[e.provider]||null})),...Object.values(l.IS).filter(e=>e.noAuth&&!a.has(e.id)&&A(e.id)).map(e=>({provider:e.id,name:e.name}))])}).catch(()=>{})},[]),(0,r.useEffect)(()=>{I.current?(I.current=!1,g(!0)):y(!0),fetch(`/api/usage/stats?period=${E}`).then(e=>e.ok?e.json():null).then(e=>{e&&(F.current=!0,h(t=>({...t,...e})))}).catch(()=>{}).finally(()=>{g(!1),y(!1)})},[E]),(0,r.useEffect)(()=>{let e=new EventSource("/api/usage/stream");return e.onmessage=e=>{try{let t=JSON.parse(e.data);h(e=>e?{...e,activeRequests:t.activeRequests,recentRequests:t.recentRequests,errorProvider:t.errorProvider,pending:t.pending}:e),F.current&&g(!1)}catch(e){console.error("[SSE CLIENT] parse error:",e)}},e.onerror=()=>g(!1),()=>e.close()},[]);let G=(0,r.useCallback)((e,t)=>{let s=new URLSearchParams(d.toString());s.get("sortBy")===t?s.set("sortOrder","asc"===s.get("sortOrder")?"desc":"asc"):(s.set("sortBy",t),s.set("sortOrder","asc")),o.replace(`?${s.toString()}`,{scroll:!1})},[d,o]),J=(0,r.useMemo)(()=>{if(!m)return null;switch(N){case"model":{let e=m.pending?.byModel||{};return{columns:q,groupedData:z(L(m.byModel,e,c,x),"rawModel"),storageKey:"usage-stats:expanded-models",emptyMessage:"No usage recorded yet.",renderSummaryCells:e=>(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("td",{className:"px-6 py-3 text-text-muted",children:"—"}),(0,a.jsx)("td",{className:"px-6 py-3 text-right",children:p(e.summary.requests)}),(0,a.jsx)("td",{className:"px-6 py-3 text-right text-text-muted whitespace-nowrap",children:f(e.summary.lastUsed)})]}),renderDetailCells:e=>(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("td",{className:`px-6 py-3 font-medium transition-colors ${e.pending>0?"text-primary":""}`,children:e.rawModel}),(0,a.jsx)("td",{className:"px-6 py-3",children:(0,a.jsx)(i.default,{variant:e.pending>0?"primary":"neutral",size:"sm",children:e.provider})}),(0,a.jsx)("td",{className:"px-6 py-3 text-right",children:p(e.requests)}),(0,a.jsx)("td",{className:"px-6 py-3 text-right text-text-muted whitespace-nowrap",children:f(e.lastUsed)})]})}}case"account":{let e={};return m?.pending?.byAccount&&Object.entries(m.byAccount||{}).forEach(([t,s])=>{let a=m.pending.byAccount[s.connectionId];if(a){let r=s.provider?`${s.rawModel} (${s.provider})`:s.rawModel;e[t]=a[r]||0}}),{columns:M,groupedData:z(L(m.byAccount,e,c,x),"accountName"),storageKey:"usage-stats:expanded-accounts",emptyMessage:"No account-specific usage recorded yet.",renderSummaryCells:e=>(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("td",{className:"px-6 py-3 text-text-muted",children:"—"}),(0,a.jsx)("td",{className:"px-6 py-3 text-text-muted",children:"—"}),(0,a.jsx)("td",{className:"px-6 py-3 text-right",children:p(e.summary.requests)}),(0,a.jsx)("td",{className:"px-6 py-3 text-right text-text-muted whitespace-nowrap",children:f(e.summary.lastUsed)})]}),renderDetailCells:e=>(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("td",{className:`px-6 py-3 font-medium transition-colors ${e.pending>0?"text-primary":""}`,children:e.accountName||`Account ${e.connectionId?.slice(0,8)}...`}),(0,a.jsx)("td",{className:`px-6 py-3 font-medium transition-colors ${e.pending>0?"text-primary":""}`,children:e.rawModel}),(0,a.jsx)("td",{className:"px-6 py-3",children:(0,a.jsx)(i.default,{variant:e.pending>0?"primary":"neutral",size:"sm",children:e.provider})}),(0,a.jsx)("td",{className:"px-6 py-3 text-right",children:p(e.requests)}),(0,a.jsx)("td",{className:"px-6 py-3 text-right text-text-muted whitespace-nowrap",children:f(e.lastUsed)})]})}}case"apiKey":return{columns:U,groupedData:z(L(m.byApiKey,{},c,x),"keyName"),storageKey:"usage-stats:expanded-apikeys",emptyMessage:"No API key usage recorded yet.",renderSummaryCells:e=>(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("td",{className:"px-6 py-3 text-text-muted",children:"—"}),(0,a.jsx)("td",{className:"px-6 py-3 text-text-muted",children:"—"}),(0,a.jsx)("td",{className:"px-6 py-3 text-right",children:p(e.summary.requests)}),(0,a.jsx)("td",{className:"px-6 py-3 text-right text-text-muted whitespace-nowrap",children:f(e.summary.lastUsed)})]}),renderDetailCells:e=>(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("td",{className:"px-6 py-3 font-medium",children:e.keyName}),(0,a.jsx)("td",{className:"px-6 py-3",children:e.rawModel}),(0,a.jsx)("td",{className:"px-6 py-3",children:(0,a.jsx)(i.default,{variant:"neutral",size:"sm",children:e.provider})}),(0,a.jsx)("td",{className:"px-6 py-3 text-right",children:p(e.requests)}),(0,a.jsx)("td",{className:"px-6 py-3 text-right text-text-muted whitespace-nowrap",children:f(e.lastUsed)})]})};default:return{columns:D,groupedData:z(L(m.byEndpoint,{},c,x),"endpoint"),storageKey:"usage-stats:expanded-endpoints",emptyMessage:"No endpoint usage recorded yet.",renderSummaryCells:e=>(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("td",{className:"px-6 py-3 text-text-muted",children:"—"}),(0,a.jsx)("td",{className:"px-6 py-3 text-text-muted",children:"—"}),(0,a.jsx)("td",{className:"px-6 py-3 text-right",children:p(e.summary.requests)}),(0,a.jsx)("td",{className:"px-6 py-3 text-right text-text-muted whitespace-nowrap",children:f(e.summary.lastUsed)})]}),renderDetailCells:e=>(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("td",{className:"px-6 py-3 font-medium font-mono text-sm",children:e.endpoint}),(0,a.jsx)("td",{className:"px-6 py-3",children:e.rawModel}),(0,a.jsx)("td",{className:"px-6 py-3",children:(0,a.jsx)(i.default,{variant:"neutral",size:"sm",children:e.provider})}),(0,a.jsx)("td",{className:"px-6 py-3 text-right",children:p(e.requests)}),(0,a.jsx)("td",{className:"px-6 py-3 text-right text-text-muted whitespace-nowrap",children:f(e.lastUsed)})]})}}},[m,N,c,x]);if(!m&&!b)return(0,a.jsx)("div",{className:"text-text-muted",children:"Failed to load usage statistics."});let Q=(0,a.jsx)("div",{className:"flex items-center justify-center py-12 text-text-muted",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[32px] animate-spin",children:"progress_activity"})});return(0,a.jsxs)("div",{className:"flex min-w-0 flex-col gap-6",children:[!s&&(0,a.jsxs)("div",{className:"flex w-full items-center gap-2 sm:w-auto sm:self-end",children:[(0,a.jsx)("div",{className:"grid flex-1 grid-cols-5 items-center gap-1 rounded-2xl border border-border bg-bg-subtle p-1 sm:flex sm:flex-none",children:B.map(e=>(0,a.jsx)("button",{onClick:()=>W(e.value),disabled:j,className:`rounded-md px-3 py-1 text-sm font-medium transition-colors ${E===e.value?"bg-primary text-white shadow-sm":"text-text-muted hover:bg-bg-hover hover:text-text"}`,children:e.label},e.value))}),j&&(0,a.jsx)("span",{className:"material-symbols-outlined text-[16px] text-text-muted animate-spin",children:"progress_activity"})]}),b?Q:(0,a.jsx)(u,{stats:m}),b?Q:(0,a.jsxs)("div",{className:"grid min-w-0 grid-cols-1 items-stretch gap-2 lg:grid-cols-[minmax(0,2fr)_minmax(280px,1fr)]",children:[(0,a.jsx)(w,{providers:O,activeRequests:m.activeRequests||[],lastProvider:m.recentRequests?.[0]?.provider||"",errorProvider:m.errorProvider||""}),(0,a.jsx)(R,{requests:m.recentRequests||[]})]}),b?Q:(0,a.jsx)(_,{period:E}),(0,a.jsxs)("div",{className:"flex flex-col gap-3",children:[(0,a.jsxs)("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between",children:[(0,a.jsx)("select",{value:N,onChange:e=>k(e.target.value),className:"w-full rounded-2xl border border-border bg-surface px-3 py-1.5 text-sm font-medium text-text-main focus:outline-none focus:ring-2 focus:ring-primary/50 sm:w-auto",style:{colorScheme:"auto"},children:K.map(e=>(0,a.jsx)("option",{value:e.value,children:e.label},e.value))}),(0,a.jsxs)("div",{className:"grid grid-cols-2 items-center gap-1 rounded-2xl border border-border bg-bg-subtle p-1 sm:flex",children:[(0,a.jsx)("button",{onClick:()=>S("costs"),className:`px-3 py-1 rounded-md text-sm font-medium transition-colors ${"costs"===C?"bg-primary text-white shadow-sm":"text-text-muted hover:text-text hover:bg-bg-hover"}`,children:"Costs"}),(0,a.jsx)("button",{onClick:()=>S("tokens"),className:`px-3 py-1 rounded-md text-sm font-medium transition-colors ${"tokens"===C?"bg-primary text-white shadow-sm":"text-text-muted hover:text-text hover:bg-bg-hover"}`,children:"Tokens"})]})]}),b?Q:J&&(0,a.jsx)(v,{title:"",columns:J.columns,groupedData:J.groupedData,tableType:N,sortBy:c,sortOrder:x,onToggleSort:G,viewMode:C,storageKey:J.storageKey,renderSummaryCells:J.renderSummaryCells,renderDetailCells:J.renderDetailCells,emptyMessage:J.emptyMessage})]})]})}}}]);
7
+ `,children:(0,a.jsxs)("span",{className:"flex items-center gap-1",children:[j.includes(e.value)&&!s&&(0,a.jsx)("span",{className:"material-symbols-outlined leading-none",style:{fontSize:"10px"},children:"check"}),s?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[11px]",children:"edit"}),e.name]}):e.isCustom?(0,a.jsxs)(a.Fragment,{children:[e.name,(0,a.jsx)("span",{className:"text-[9px] opacity-60 font-normal",children:"custom"}),(0,a.jsx)(d.default,{caps:w(e.value)})]}):(0,a.jsxs)(a.Fragment,{children:[e.name,(0,a.jsx)(d.default,{caps:w(e.value)})]})]})},e.value)})})]},e)),0===Object.keys(M).length&&0===q.length&&(0,a.jsxs)("div",{className:"text-center py-4 text-text-muted",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-2xl mb-1 block",children:"search_off"}),(0,a.jsx)("p",{className:"text-xs",children:"No models found"})]})]})]})}h.propTypes={isOpen:l().bool.isRequired,onClose:l().func.isRequired,onSelect:l().func.isRequired,onDeselect:l().func,selectedModel:l().string,activeProviders:l().arrayOf(l().shape({provider:l().string.isRequired})),title:l().string,modelAliases:l().object,kindFilter:l().string,addedModelValues:l().arrayOf(l().string),closeOnSelect:l().bool}},73579:(e,t,s)=>{s.d(t,{default:()=>m});var a=s(95155),r=s(12115),n=s(14051),l=s.n(n),i=s(81127),o=s(11910),d=s(92542),c=s(56061),x=s(88105);function m({isOpen:e,connection:t,proxyPools:s,onSave:n,onClose:l}){let[u,p]=(0,r.useState)({name:"",priority:1,apiKey:""}),[h,f]=(0,r.useState)({azureEndpoint:"",apiVersion:"2024-10-01-preview",deployment:"",organization:""}),[b,g]=(0,r.useState)({accountId:""}),[v,j]=(0,r.useState)({sessionToken:"",cfClearance:""}),[y,N]=(0,r.useState)(!1),[w,k]=(0,r.useState)(null),[C,S]=(0,r.useState)(!1),[O,T]=(0,r.useState)(null),[P,$]=(0,r.useState)(!1);(0,r.useEffect)(()=>{t&&(p({name:t.name||"",priority:t.priority||1,apiKey:""}),"azure"===t.provider&&t.providerSpecificData&&f({azureEndpoint:t.providerSpecificData.azureEndpoint||"",apiVersion:t.providerSpecificData.apiVersion||"2024-10-01-preview",deployment:t.providerSpecificData.deployment||"",organization:t.providerSpecificData.organization||""}),"cloudflare-ai"===t.provider&&t.providerSpecificData&&g({accountId:t.providerSpecificData.accountId||""}),"merlin"===t.provider&&t.providerSpecificData&&j({sessionToken:t.providerSpecificData.sessionToken||"",cfClearance:t.providerSpecificData.cfClearance||""}),k(null),T(null))},[t]);let I=t?.authType==="oauth",F=t?.provider==="azure",E=t?.provider==="cloudflare-ai",_=t?.provider==="merlin",A=!!t&&((0,x.mq)(t.provider)||(0,x.gb)(t.provider)),W=async()=>{if(t?.provider){N(!0),k(null);try{let e=await fetch(`/api/providers/${t.id}/test`,{method:"POST"}),s=await e.json();k(s.valid?"success":"failed")}catch{k("failed")}finally{N(!1)}}},R=async()=>{if(!t?.provider)return;let e=_?`${v.sessionToken};;${v.cfClearance}`:u.apiKey;if(e&&(!_||v.sessionToken&&v.cfClearance)){S(!0),T(null);try{let s=await fetch("/api/providers/validate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:t.provider,apiKey:e,...F?{providerSpecificData:h}:{},...E?{providerSpecificData:b}:{}})}),a=await s.json();T(a.valid?"success":"failed")}catch{T("failed")}finally{S(!1)}}},L=async()=>{if(t){$(!0);try{let e={name:u.name,priority:u.priority};if(!I&&(u.apiKey||_)){e.apiKey=_?`${v.sessionToken};;${v.cfClearance}`:u.apiKey;let s="success"===O;if(!s)try{S(!0),T(null);let a=await fetch("/api/providers/validate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:t.provider,apiKey:e.apiKey,...F?{providerSpecificData:h}:{},...E?{providerSpecificData:b}:{}})});s=!!(await a.json()).valid,T(s?"success":"failed")}catch{T("failed")}finally{S(!1)}s&&(e.testStatus="active",e.lastError=null,e.lastErrorAt=null)}F&&(e.providerSpecificData={azureEndpoint:h.azureEndpoint,apiVersion:h.apiVersion,deployment:h.deployment,organization:h.organization}),E&&(e.providerSpecificData={accountId:b.accountId}),_&&(e.providerSpecificData={sessionToken:v.sessionToken,cfClearance:v.cfClearance}),await n(e)}finally{$(!1)}}};return t?(0,a.jsx)(i.default,{isOpen:e,title:"Edit Connection",onClose:l,children:(0,a.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,a.jsx)(o.default,{label:"Name",value:u.name,onChange:e=>p({...u,name:e.target.value}),placeholder:I?"Account name":"Production Key"}),I&&t.email&&(0,a.jsxs)("div",{className:"bg-sidebar/50 p-3 rounded-2xl",children:[(0,a.jsx)("p",{className:"text-sm text-text-muted mb-1",children:"Email"}),(0,a.jsx)("p",{className:"font-medium",children:t.email})]}),(0,a.jsx)(o.default,{label:"Priority",type:"number",value:u.priority,onChange:e=>p({...u,priority:Number.parseInt(e.target.value,10)||1})}),!I&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsx)(o.default,{label:"API Key",type:"password",value:u.apiKey,onChange:e=>p({...u,apiKey:e.target.value}),placeholder:"Enter new API key",hint:"Leave blank to keep the current API key.",className:"flex-1"}),(0,a.jsx)("div",{className:"pt-6",children:(0,a.jsx)(d.default,{onClick:R,disabled:!u.apiKey||C||P,variant:"secondary",children:C?"Checking...":"Check"})})]}),O&&(0,a.jsx)(c.default,{variant:"success"===O?"success":"error",children:"success"===O?"Valid":"Invalid"})]}),F&&(0,a.jsxs)("div",{className:"bg-sidebar/50 p-4 rounded-2xl border border-accent/20",children:[(0,a.jsx)("h3",{className:"font-semibold mb-3 text-sm",children:"Azure OpenAI Configuration"}),(0,a.jsxs)("div",{className:"flex flex-col gap-3",children:[(0,a.jsx)(o.default,{label:"Azure Endpoint",value:h.azureEndpoint,onChange:e=>f({...h,azureEndpoint:e.target.value}),placeholder:"https://your-resource.openai.azure.com",hint:"Your Azure OpenAI resource endpoint URL"}),(0,a.jsx)(o.default,{label:"Deployment Name",value:h.deployment,onChange:e=>f({...h,deployment:e.target.value}),placeholder:"gpt-4",hint:"The deployment name in your Azure resource"}),(0,a.jsx)(o.default,{label:"API Version",value:h.apiVersion,onChange:e=>f({...h,apiVersion:e.target.value}),placeholder:"2024-10-01-preview",hint:"Azure OpenAI API version to use"}),(0,a.jsx)(o.default,{label:"Organization",value:h.organization,onChange:e=>f({...h,organization:e.target.value}),placeholder:"Organization ID",hint:"Required for billing"})]})]}),_&&(0,a.jsxs)("div",{className:"bg-sidebar/50 p-4 rounded-2xl border border-accent/20",children:[(0,a.jsx)("h3",{className:"font-semibold mb-3 text-sm",children:"Merlin Cookies"}),(0,a.jsx)("p",{className:"text-xs text-text-muted mb-3",children:"DevTools (F12) → Application → Cookies → getmerlin.in"}),(0,a.jsxs)("div",{className:"flex flex-col gap-3",children:[(0,a.jsx)(o.default,{label:"Session Token (__Secure-authjs.session-token)",type:"password",value:v.sessionToken,onChange:e=>j({...v,sessionToken:e.target.value}),placeholder:"eyJhbGciOi...",hint:"The __Secure-authjs.session-token cookie value"}),(0,a.jsx)(o.default,{label:"CF Clearance (cf_clearance)",type:"password",value:v.cfClearance,onChange:e=>j({...v,cfClearance:e.target.value}),placeholder:"JIj9UKw...",hint:"The cf_clearance cookie value"})]})]}),!A&&!F&&!E&&!_&&(0,a.jsxs)("div",{className:"flex items-center gap-3",children:[(0,a.jsx)(d.default,{onClick:W,variant:"secondary",disabled:y,children:y?"Testing...":"Test Connection"}),w&&(0,a.jsx)(c.default,{variant:"success"===w?"success":"error",children:"success"===w?"Valid":"Failed"})]}),(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsx)(d.default,{onClick:L,fullWidth:!0,disabled:P,children:P?"Saving...":"Save"}),(0,a.jsx)(d.default,{onClick:l,variant:"ghost",fullWidth:!0,children:"Cancel"})]})]})}):null}m.propTypes={isOpen:l().bool.isRequired,connection:l().shape({id:l().string,name:l().string,email:l().string,priority:l().number,authType:l().string,provider:l().string,providerSpecificData:l().object}),proxyPools:l().arrayOf(l().shape({id:l().string,name:l().string})),onSave:l().func.isRequired,onClose:l().func.isRequired}},80752:(e,t,s)=>{s.d(t,{default:()=>x});var a=s(95155),r=s(12115),n=s(14051),l=s.n(n),i=s(1620),o=s(40197),d=s(81127);function c({icon:e,label:t,onClick:s,trailing:r,danger:n}){return(0,a.jsxs)("button",{onClick:s,className:`flex items-center gap-3 w-full px-4 py-2.5 text-sm transition-colors ${n?"text-red-500 hover:bg-red-500/10":"text-text-main hover:bg-surface/50"}`,children:[(0,a.jsx)("span",{className:`material-symbols-outlined text-[20px] ${n?"":"text-text-muted"}`,children:e}),(0,a.jsx)("span",{className:"flex-1 text-left",children:t}),r&&(0,a.jsx)("span",{className:"text-base",children:r})]})}function x({onLogout:e}){let[t,s]=(0,r.useState)(!1),[n,l]=(0,r.useState)(!1),[m,u]=(0,r.useState)(!1),[p,h]=(0,r.useState)(!1),{toggleTheme:f,isDark:b}=(0,i.D)(),g=(0,r.useRef)(null),v=async()=>{h(!0);try{await fetch("/api/version/shutdown",{method:"POST"})}catch(e){}h(!1),u(!1)};return(0,r.useEffect)(()=>{let e=e=>{g.current&&!g.current.contains(e.target)&&s(!1)};if(t)return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[t]),(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{className:"relative",ref:g,children:[(0,a.jsx)("button",{onClick:()=>s(e=>!e),className:"flex items-center justify-center p-2 rounded-lg text-text-muted hover:text-text-main hover:bg-surface/50 transition-all",title:"Menu",children:(0,a.jsx)("span",{className:"material-symbols-outlined",children:"grid_view"})}),t&&(0,a.jsxs)("div",{className:"absolute right-0 top-full mt-2 w-60 bg-surface border border-border rounded-xl shadow-2xl z-50 animate-in fade-in zoom-in-95 duration-150 overflow-hidden py-1",children:[(0,a.jsx)(c,{icon:"history",label:"Change Log",onClick:()=>{s(!1),l(!0)}}),(0,a.jsx)(c,{icon:b?"light_mode":"dark_mode",label:"Theme",onClick:()=>{f(),s(!1)}}),(0,a.jsx)(c,{icon:"power_settings_new",label:"Shutdown",danger:!0,onClick:()=>{s(!1),u(!0)}}),(0,a.jsx)(c,{icon:"logout",label:"Logout",danger:!0,onClick:()=>{s(!1),e()}})]})]}),(0,a.jsx)(o.default,{isOpen:n,onClose:()=>l(!1)}),(0,a.jsx)(d.ConfirmModal,{isOpen:m,onClose:()=>u(!1),onConfirm:v,title:"Close Proxy",message:"Are you sure you want to close the proxy server?",confirmText:"Close",cancelText:"Cancel",variant:"danger",loading:p})]})}c.propTypes={icon:l().string.isRequired,label:l().string.isRequired,onClick:l().func.isRequired,trailing:l().node,danger:l().bool},x.propTypes={onLogout:l().func.isRequired}},81127:(e,t,s)=>{s.d(t,{ConfirmModal:()=>d,default:()=>o});var a=s(95155),r=s(12115),n=s(47650),l=s(31474),i=s(92542);function o({isOpen:e,onClose:t,title:s,children:i,footer:d,size:c="md",closeOnOverlay:x=!0,showTrafficLights:m=!1,className:u}){let[p,h]=(0,r.useState)(!1);if((0,r.useEffect)(()=>{h(!0)},[]),(0,r.useEffect)(()=>(e?document.body.style.overflow="hidden":document.body.style.overflow="",()=>{document.body.style.overflow=""}),[e]),(0,r.useEffect)(()=>{let s=s=>{"Escape"===s.key&&e&&t()};return document.addEventListener("keydown",s),()=>document.removeEventListener("keydown",s)},[e,t]),!e||!p)return null;let f=(0,a.jsxs)("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4",children:[(0,a.jsx)("div",{className:"absolute inset-0 bg-black/40 fade-in",onClick:x?t:void 0}),(0,a.jsxs)("div",{className:(0,l.cn)("relative w-full bg-surface","border border-border","rounded-2xl shadow-[var(--neo-raised)]","slide-up",{sm:"max-w-sm",md:"max-w-md",lg:"max-w-lg",xl:"max-w-xl",full:"max-w-4xl"}[c],u),children:[(s||m)&&(0,a.jsxs)("div",{className:"flex items-center justify-between px-5 py-4 border-b border-border",children:[(0,a.jsx)("div",{className:"flex items-center gap-3",children:s&&(0,a.jsx)("h2",{className:"text-base font-semibold text-text",children:s})}),(0,a.jsx)("button",{onClick:t,"aria-label":"Close",className:"p-1.5 rounded-lg text-text-muted hover:bg-surface-hover hover:text-text transition-colors",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[20px]",children:"close"})})]}),(0,a.jsx)("div",{className:"p-6 max-h-[calc(85vh-100px)] overflow-y-auto custom-scrollbar",children:i}),d&&(0,a.jsx)("div",{className:"flex items-center justify-end gap-3 px-6 py-4 border-t border-border",children:d})]})]});return(0,n.createPortal)(f,document.body)}function d({isOpen:e,onClose:t,onConfirm:s,title:r="Confirm",message:n,confirmText:l="Confirm",cancelText:c="Cancel",variant:x="danger",loading:m=!1}){return(0,a.jsx)(o,{isOpen:e,onClose:t,title:r,size:"sm",footer:(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(i.default,{variant:"ghost",onClick:t,disabled:m,children:c}),(0,a.jsx)(i.default,{variant:x,onClick:s,loading:m,children:l})]}),children:(0,a.jsx)("p",{className:"text-text-muted text-sm",children:n})})}s(97677)},90882:(e,t,s)=>{s.d(t,{default:()=>d});var a=s(95155),r=s(12115),n=s(14051),l=s.n(n),i=s(35497),o=s(11059);function d({isOpen:e,provider:t,providerInfo:s,onSuccess:n,onClose:l,oauthMeta:c,idcConfig:x}){let[m,u]=(0,r.useState)("waiting"),[p,h]=(0,r.useState)(null),[f,b]=(0,r.useState)(""),[g,v]=(0,r.useState)(null),[j,y]=(0,r.useState)(!1),[N,w]=(0,r.useState)(null),[k,C]=(0,r.useState)(!1),S=(0,r.useRef)(null),O=(0,r.useRef)(!1),T=(0,r.useRef)(!1),{copied:P,copy:$}=(0,o.C)(),[I,F]=(0,r.useState)(!1),[E,_]=(0,r.useState)("/callback?code=..."),A=(0,r.useRef)(!1);(0,r.useEffect)(()=>{F("localhost"===window.location.hostname||"127.0.0.1"===window.location.hostname),_(`${window.location.origin}/callback?code=...`)},[]);let W=(0,r.useCallback)(async(e,s)=>{if(p)try{let a=await fetch(`/api/oauth/${t}/exchange`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({code:e,redirectUri:p.redirectUri,codeVerifier:p.codeVerifier,state:s,...c?{meta:c}:{}})}),r=await a.json();if(!a.ok)throw Error(r.error);u("success"),n?.()}catch(e){v(e.message),u("error")}},[p,t,n]),R=(0,r.useCallback)(async e=>{if(p?.state)try{let t=await fetch("/api/oauth/xai/manual-code",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({code:e,state:p.state})}),s=await t.json();if(!t.ok)throw Error(s.error);u("success"),n?.()}catch(e){v(e.message),u("error")}},[p,n]),L=(0,r.useCallback)(async(e,s,a,r,l)=>{O.current=!1,C(!0);let i=Date.now()+(Number.isFinite(l)&&l>0?l:12e4);for(;Date.now()<i;){if(O.current){console.log("[OAuthModal] Polling aborted"),C(!1);return}if(await new Promise(e=>setTimeout(e,1e3*a)),O.current){console.log("[OAuthModal] Polling aborted after sleep"),C(!1);return}try{let l=await fetch(`/api/oauth/${t}/poll`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({deviceCode:e,codeVerifier:s,extraData:r})}),i=await l.json();if(i.success){O.current=!0,u("success"),C(!1),n?.();return}if("expired_token"===i.error||"access_denied"===i.error)throw Error(i.errorDescription||i.error);"slow_down"===i.error&&(a=Math.min(a+5,30))}catch(e){v(e.message),u("error"),C(!1);return}}v("Authorization timeout"),u("error"),C(!1)},[t,n]),z=(0,r.useCallback)(async()=>{if(t)try{let e;if(v(null),["github","qwen","kiro","kimi-coding","kilocode","codebuddy-cn","qoder","grok-cli"].includes(t)){y(!0),u("waiting");let e=new URL(`/api/oauth/${t}/device-code`,window.location.origin);"kiro"===t&&x?.startUrl&&(e.searchParams.set("start_url",x.startUrl),x.region&&e.searchParams.set("region",x.region),e.searchParams.set("auth_method","idc"));let s=await fetch(e.toString()),a=await s.json();if(!s.ok)throw Error(a.error);w(a);let r=a.verification_uri_complete||a.verification_uri;r&&window.open(r,"_blank","noopener,noreferrer");let n="kiro"===t?{_clientId:a._clientId,_clientSecret:a._clientSecret,_region:a._region,_authMethod:a._authMethod,_startUrl:a._startUrl}:"qoder"===t?{_qoderNonce:a._qoderNonce,_qoderMachineId:a._qoderMachineId,_qoderVerifier:a.codeVerifier}:null;L(a.device_code,a.codeVerifier,a.interval||5,n,Number.isFinite(a.expires_in)&&a.expires_in>0?1e3*a.expires_in:void 0);return}let s=window.location.port||("https:"===window.location.protocol?"443":"80");e="codex"===t?"http://localhost:1455/auth/callback":"xai"===t?"http://127.0.0.1:56121/callback":`http://localhost:${s}/callback`;let a=new URL(`/api/oauth/${t}/authorize`,window.location.origin);a.searchParams.set("redirect_uri",e),c&&Object.entries(c).forEach(([e,t])=>{t&&a.searchParams.set(e,t)});let r=await fetch(a.toString()),n=await r.json();if(!r.ok)throw Error(n.error);let l=!1,i=!1;if("codex"===t)try{let t=new URL("/api/oauth/codex/start-proxy",window.location.origin);t.searchParams.set("app_port",s),t.searchParams.set("state",n.state),t.searchParams.set("code_verifier",n.codeVerifier),t.searchParams.set("redirect_uri",e);let a=await fetch(t.toString()),r=await a.json();l=r.success,i=!!r.serverSide}catch{l=!1}let o=!1,d=!1;if("xai"===t)try{let t=new URL("/api/oauth/xai/start-proxy",window.location.origin);t.searchParams.set("app_port",s),t.searchParams.set("state",n.state),t.searchParams.set("code_verifier",n.codeVerifier),t.searchParams.set("redirect_uri",e);let a=await fetch(t.toString()),r=await a.json();if(o=r.success,d=!!r.serverSide,!o&&"port_busy"===r.reason)throw Error("Port 56121 in use; close the conflicting process and retry")}catch(e){if(e?.message)throw e;o=!1}h({...n,redirectUri:e,codexServerSide:i,xaiServerSide:d}),"codex"===t&&l||"xai"===t&&o||I&&"codex"!==t&&"xai"!==t?(u("waiting"),S.current=window.open(n.authUrl,"oauth_popup","width=600,height=700"),S.current||u("input")):(u("input"),window.open(n.authUrl,"_blank"))}catch(e){v(e.message),u("error")}},[t,I,L,c,x]);(0,r.useEffect)(()=>{e&&t?T.current||(T.current=!0,h(null),b(""),v(null),y(!1),w(null),C(!1),O.current=!1,z()):e||(O.current=!0,T.current=!1,"codex"===t?fetch("/api/oauth/codex/stop-proxy").catch(()=>{}):"xai"===t&&fetch("/api/oauth/xai/stop-proxy").catch(()=>{}))},[e,t,z]),(0,r.useEffect)(()=>{let e=p?.codexServerSide?"codex":p?.xaiServerSide?"xai":null;if(!e||!p?.state||A.current)return;let t=!1,s=0,a=async()=>{if(!t&&!A.current){s+=1;try{let s=await fetch(`/api/oauth/${e}/poll-status?state=${encodeURIComponent(p.state)}`),a=await s.json();if(t||A.current)return;if("done"===a.status){A.current=!0,u("success"),n?.();return}if("error"===a.status){A.current=!0,v(a.error||"Authentication failed"),u("error");return}}catch{}if(s>=200){A.current=!0,v("Authentication timeout"),u("error");return}setTimeout(a,1500)}};return setTimeout(a,1500),()=>{t=!0}},[p,n]),(0,r.useEffect)(()=>{let e;if(!p)return;A.current=!1;let t=async e=>{if(A.current)return;let{code:t,state:s,error:a,errorDescription:r}=e;if(a){A.current=!0,v(r||a),u("error");return}t&&(A.current=!0,await W(t,s))},s=e=>{let s=e.origin.includes("localhost")||e.origin.includes("127.0.0.1"),a=e.origin===window.location.origin;(s||a)&&e.data?.type==="oauth_callback"&&t(e.data.data)};window.addEventListener("message",s);try{(e=new BroadcastChannel("oauth_callback")).onmessage=e=>t(e.data)}catch(e){console.log("BroadcastChannel not supported")}let a=e=>{if("oauth_callback"===e.key&&e.newValue)try{let s=JSON.parse(e.newValue);t(s),localStorage.removeItem("oauth_callback")}catch(e){console.log("Failed to parse localStorage data")}};window.addEventListener("storage",a);try{let e=localStorage.getItem("oauth_callback");if(e){let s=JSON.parse(e);s.timestamp&&Date.now()-s.timestamp<3e4&&t(s),localStorage.removeItem("oauth_callback")}}catch{}return()=>{window.removeEventListener("message",s),window.removeEventListener("storage",a),e&&e.close()}},[p,W]);let q=async()=>{try{v(null);let e=f.trim();if(e.startsWith("eyJ")&&e.includes("."))return void await W(e,null);if("xai"===t&&e&&!e.includes("://")&&!e.includes("?")&&!e.includes("code="))return void await R(e);let s=new URL(e),a=s.searchParams.get("code"),r=s.searchParams.get("state"),n=s.searchParams.get("error");if(n)throw Error(s.searchParams.get("error_description")||n);if(!a)throw Error("xai"===t?"Paste the callback URL or copied xAI code":"No authorization code found in URL");await W(a,r)}catch(e){v(e.message),u("error")}},M=(0,r.useCallback)(()=>{"codex"===t?fetch("/api/oauth/codex/stop-proxy").catch(()=>{}):"xai"===t&&fetch("/api/oauth/xai/stop-proxy").catch(()=>{}),l()},[l,t]);if(!t||!s)return null;let U="xai"===t,D=N?.verification_uri_complete||N?.verification_uri||"",K=U?"Connect Grok Build OAuth":`Connect ${s.name}`;return(0,a.jsx)(i.aF,{isOpen:e,title:K,onClose:M,size:"lg",children:(0,a.jsxs)("div",{className:"flex flex-col gap-4",children:[("waiting"===m||"input"===m)&&!j&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{className:"flex items-center gap-2 px-3 py-2 border border-border rounded-2xl bg-sidebar/50",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-base text-primary animate-spin",children:"progress_activity"}),(0,a.jsx)("span",{className:"text-sm",children:U?"Waiting for Grok Build OAuth…":"Waiting for popup authorization…"})]}),(0,a.jsxs)("div",{className:"flex items-center gap-3 my-1",children:[(0,a.jsx)("div",{className:"flex-1 h-px bg-border"}),(0,a.jsx)("span",{className:"text-xs text-text-muted uppercase tracking-wider",children:"Or paste callback URL manually"}),(0,a.jsx)("div",{className:"flex-1 h-px bg-border"})]}),(0,a.jsxs)("div",{className:"space-y-4",children:[(0,a.jsxs)("div",{children:[(0,a.jsxs)("p",{className:"text-sm font-medium mb-2",children:["Step 1: Open this ",U?"Grok Build OAuth URL":"URL"," in your browser"]}),(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsx)(i.pd,{value:p?.authUrl||"",readOnly:!0,className:"flex-1 font-mono text-xs"}),(0,a.jsx)(i.$n,{variant:"secondary",icon:"auth_url"===P?"check":"content_copy",onClick:()=>$(p?.authUrl,"auth_url"),disabled:!p?.authUrl,children:"Copy"})]})]}),(0,a.jsxs)("div",{children:[(0,a.jsxs)("p",{className:"text-sm font-medium mb-2",children:["Step 2: Paste the ","xai"===t?"callback URL or copied code":"callback URL"," here"]}),(0,a.jsx)("p",{className:"text-xs text-text-muted mb-2",children:"xai"===t?"If xAI shows a code instead of redirecting, paste that code here.":"After authorization, copy the full URL from your browser."}),(0,a.jsx)(i.pd,{value:f,onChange:e=>b(e.target.value),placeholder:U?"http://127.0.0.1:56121/callback?code=... or copied code":E,className:"font-mono text-xs"})]})]}),(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsx)(i.$n,{onClick:q,fullWidth:!0,disabled:!f,children:"Connect"}),(0,a.jsx)(i.$n,{onClick:M,variant:"ghost",fullWidth:!0,children:"Cancel"})]})]}),"waiting"===m&&j&&N&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{className:"text-center py-4",children:[(0,a.jsx)("p",{className:"text-sm text-text-muted mb-4",children:"Visit the login URL below and authorize:"}),(0,a.jsxs)("div",{className:"bg-sidebar p-4 rounded-2xl mb-4",children:[(0,a.jsx)("p",{className:"text-xs text-text-muted mb-1",children:"Login URL"}),(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("code",{className:"flex-1 text-sm break-all",children:D}),(0,a.jsx)(i.$n,{size:"sm",variant:"ghost",icon:"login_url"===P?"check":"content_copy",onClick:()=>$(D,"login_url"),disabled:!D}),(0,a.jsx)(i.$n,{size:"sm",variant:"ghost",icon:"open_in_new",onClick:()=>window.open(D,"_blank","noopener,noreferrer"),disabled:!D,children:"Open"})]})]}),(0,a.jsxs)("div",{className:"bg-primary/10 p-4 rounded-2xl",children:[(0,a.jsx)("p",{className:"text-xs text-text-muted mb-1",children:"Your Code"}),(0,a.jsxs)("div",{className:"flex items-center justify-center gap-2",children:[(0,a.jsx)("p",{className:"text-2xl font-mono font-bold text-primary",children:N.user_code}),(0,a.jsx)(i.$n,{size:"sm",variant:"ghost",icon:"user_code"===P?"check":"content_copy",onClick:()=>$(N.user_code,"user_code")})]})]})]}),k&&(0,a.jsxs)("div",{className:"flex items-center justify-center gap-2 text-sm text-text-muted",children:[(0,a.jsx)("span",{className:"material-symbols-outlined animate-spin",children:"progress_activity"}),"Waiting for authorization..."]})]}),"success"===m&&(0,a.jsxs)("div",{className:"text-center py-6",children:[(0,a.jsx)("div",{className:"size-16 mx-auto mb-4 rounded-full bg-green-100 dark:bg-green-900/30 flex items-center justify-center",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-3xl text-green-600",children:"check_circle"})}),(0,a.jsx)("h3",{className:"text-lg font-semibold mb-2",children:"Connected Successfully!"}),(0,a.jsxs)("p",{className:"text-sm text-text-muted mb-4",children:["Your ",s.name," account has been connected."]}),(0,a.jsx)(i.$n,{onClick:M,fullWidth:!0,children:"Done"})]}),"error"===m&&(0,a.jsxs)("div",{className:"text-center py-6",children:[(0,a.jsx)("div",{className:"size-16 mx-auto mb-4 rounded-full bg-red-100 dark:bg-red-900/30 flex items-center justify-center",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-3xl text-red-600",children:"error"})}),(0,a.jsx)("h3",{className:"text-lg font-semibold mb-2",children:"Connection Failed"}),(0,a.jsx)("p",{className:"text-sm text-red-600 mb-4",children:g}),(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsx)(i.$n,{onClick:z,variant:"secondary",fullWidth:!0,children:"Try Again"}),(0,a.jsx)(i.$n,{onClick:M,variant:"ghost",fullWidth:!0,children:"Cancel"})]})]})]})})}d.propTypes={isOpen:l().bool.isRequired,provider:l().string,providerInfo:l().shape({name:l().string}),onSuccess:l().func,onClose:l().func.isRequired,oauthMeta:l().object,idcConfig:l().shape({startUrl:l().string,region:l().string})}},91450:(e,t,s)=>{s.d(t,{default:()=>i});var a=s(95155),r=s(14051),n=s.n(r),l=s(38587);function i({children:e}){return(0,a.jsxs)("div",{className:"min-h-screen flex flex-col relative bg-bg transition-colors duration-500 overflow-x-hidden selection:bg-primary/20 selection:text-primary",children:[(0,a.jsx)("div",{className:"fixed top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 w-[800px] h-[800px] bg-primary/5 dark:bg-primary/5 rounded-full blur-[100px] pointer-events-none z-0"}),(0,a.jsx)("div",{className:"fixed bottom-0 right-0 w-[600px] h-[600px] bg-orange-200/20 dark:bg-orange-900/10 rounded-full blur-[120px] pointer-events-none z-0 translate-y-1/3 translate-x-1/3"}),(0,a.jsx)("div",{className:"absolute top-6 right-6 z-20",children:(0,a.jsx)(l.default,{variant:"card"})}),(0,a.jsx)("main",{className:"flex-1 flex flex-col items-center justify-center p-4 sm:p-6 z-10 w-full h-full",children:e})]})}i.propTypes={children:n().node.isRequired}},92173:(e,t,s)=>{s.d(t,{default:()=>c});var a=s(95155),r=s(98500),n=s.n(r),l=s(90620);let i=[{label:"Features",href:"#features"},{label:"Pricing",href:"#pricing"},{label:"Changelog",href:"#"}],o=[{label:"Documentation",href:"#"},{label:"API Reference",href:"#"},{label:"Help Center",href:"#"}],d=[{label:"About",href:"#"},{label:"Blog",href:"#"},{label:"Contact",href:"#"}];function c(){return(0,a.jsx)("footer",{className:"bg-bg border-t border-border pt-16 pb-12",children:(0,a.jsxs)("div",{className:"container mx-auto px-4 sm:px-6 lg:px-8",children:[(0,a.jsxs)("div",{className:"grid grid-cols-2 md:grid-cols-4 lg:grid-cols-5 gap-10 mb-12",children:[(0,a.jsxs)("div",{className:"col-span-2 lg:col-span-2",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2 mb-6",children:[(0,a.jsx)("div",{className:"size-6 text-primary",children:(0,a.jsx)("svg",{className:"w-full h-full",fill:"currentColor",viewBox:"0 0 48 48",children:(0,a.jsx)("path",{clipRule:"evenodd",d:"M12.0799 24L4 19.2479L9.95537 8.75216L18.04 13.4961L18.0446 4H29.9554L29.96 13.4961L38.0446 8.75216L44 19.2479L35.92 24L44 28.7521L38.0446 39.2479L29.96 34.5039L29.9554 44H18.0446L18.04 34.5039L9.95537 39.2479L4 28.7521L12.0799 24Z",fillRule:"evenodd"})})}),(0,a.jsx)("span",{className:"text-xl font-bold text-text-main",children:l.vQ.name})]}),(0,a.jsx)("p",{className:"text-text-muted mb-6 max-w-sm font-light",children:"The unified interface for modern AI infrastructure. Secure, observable, and scalable."}),(0,a.jsxs)("div",{className:"flex gap-4",children:[(0,a.jsx)("a",{href:"#",className:"text-gray-400 hover:text-primary transition-colors","aria-label":"Twitter",children:(0,a.jsx)("svg",{className:"w-5 h-5",fill:"currentColor",viewBox:"0 0 24 24",children:(0,a.jsx)("path",{d:"M22.46 6c-.77.35-1.6.58-2.46.69.88-.53 1.56-1.37 1.88-2.38-.83.5-1.75.85-2.72 1.05C18.37 4.5 17.26 4 16 4c-2.35 0-4.27 1.92-4.27 4.29 0 .34.04.67.11.98C8.28 9.09 5.11 7.38 3 4.79c-.37.63-.58 1.37-.58 2.15 0 1.49.75 2.81 1.91 3.56-.71 0-1.37-.2-1.95-.5v.03c0 2.08 1.48 3.82 3.44 4.21a4.22 4.22 0 0 1-1.93.07 4.28 4.28 0 0 0 4 2.98 8.521 8.521 0 0 1-5.33 1.84c-.34 0-.68-.02-1.02-.06C3.44 20.29 5.7 21 8.12 21 16 21 20.33 14.46 20.33 8.79c0-.19 0-.37-.01-.56.84-.6 1.56-1.36 2.14-2.23z"})})}),(0,a.jsx)("a",{href:"#",className:"text-gray-400 hover:text-primary transition-colors","aria-label":"GitHub",children:(0,a.jsx)("svg",{className:"w-5 h-5",fill:"currentColor",viewBox:"0 0 24 24",children:(0,a.jsx)("path",{d:"M12 2C6.477 2 2 6.484 2 12.017c0 4.425 2.865 8.18 6.839 9.504.5.092.682-.217.682-.483 0-.237-.008-.868-.013-1.703-2.782.605-3.369-1.343-3.369-1.343-.454-1.158-1.11-1.466-1.11-1.466-.908-.62.069-.608.069-.608 1.003.07 1.531 1.032 1.531 1.032.892 1.53 2.341 1.088 2.91.832.092-.647.35-1.088.636-1.338-2.22-.253-4.555-1.113-4.555-4.951 0-1.093.39-1.988 1.029-2.688-.103-.253-.446-1.272.098-2.65 0 0 .84-.27 2.75 1.026A9.564 9.564 0 0 1 12 6.844c.85.004 1.705.115 2.504.337 1.909-1.296 2.747-1.027 2.747-1.027.546 1.379.202 2.398.1 2.651.64.7 1.028 1.595 1.028 2.688 0 3.848-2.339 4.695-4.566 4.943.359.309.678.92.678 1.855 0 1.338-.012 2.419-.012 2.747 0 .268.18.58.688.482A10.019 10.019 0 0 0 22 12.017C22 6.484 17.522 2 12 2z"})})})]})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("h4",{className:"font-semibold text-text-main mb-4",children:"Product"}),(0,a.jsx)("ul",{className:"flex flex-col gap-3 text-sm text-text-muted font-light",children:i.map(e=>(0,a.jsx)("li",{children:(0,a.jsx)(n(),{href:e.href,className:"hover:text-primary transition-colors",children:e.label})},e.label))})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("h4",{className:"font-semibold text-text-main mb-4",children:"Resources"}),(0,a.jsx)("ul",{className:"flex flex-col gap-3 text-sm text-text-muted font-light",children:o.map(e=>(0,a.jsx)("li",{children:(0,a.jsx)(n(),{href:e.href,className:"hover:text-primary transition-colors",children:e.label})},e.label))})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("h4",{className:"font-semibold text-text-main mb-4",children:"Company"}),(0,a.jsx)("ul",{className:"flex flex-col gap-3 text-sm text-text-muted font-light",children:d.map(e=>(0,a.jsx)("li",{children:(0,a.jsx)(n(),{href:e.href,className:"hover:text-primary transition-colors",children:e.label})},e.label))})]})]}),(0,a.jsxs)("div",{className:"border-t border-border pt-8 flex flex-col md:flex-row justify-between items-center gap-4",children:[(0,a.jsxs)("p",{className:"text-sm text-text-muted",children:["\xa9 ",new Date().getFullYear()," ",l.vQ.name," Inc. All rights reserved."]}),(0,a.jsxs)("div",{className:"flex gap-6 text-sm text-text-muted",children:[(0,a.jsx)(n(),{href:"#",className:"hover:text-primary transition-colors",children:"Privacy Policy"}),(0,a.jsx)(n(),{href:"#",className:"hover:text-primary transition-colors",children:"Terms of Service"})]})]})]})})}},92542:(e,t,s)=>{s.d(t,{default:()=>i});var a=s(95155),r=s(31474);let n={primary:(0,r.cn)("bg-brand text-white border border-brand/20","shadow-[var(--neo-raised-sm)] hover:shadow-[var(--neo-raised)] hover:bg-brand-hover","disabled:bg-text-subtle disabled:text-surface disabled:border-transparent disabled:shadow-none"),secondary:(0,r.cn)("bg-surface hover:bg-surface-hover text-text border border-border","shadow-[var(--neo-flat)] hover:shadow-[var(--neo-raised-sm)]","disabled:opacity-50"),outline:(0,r.cn)("border border-border text-text bg-transparent","hover:bg-surface-hover hover:border-text-subtle","disabled:opacity-50"),ghost:(0,r.cn)("text-text-muted hover:bg-surface-hover hover:text-text","disabled:opacity-50"),danger:(0,r.cn)("bg-red-500 text-white border border-red-500/20","shadow-[var(--neo-raised-sm)] hover:shadow-[var(--neo-raised)] hover:bg-red-600","disabled:bg-text-subtle disabled:text-surface disabled:border-transparent disabled:shadow-none"),success:(0,r.cn)("bg-green-500 text-white border border-green-500/20","shadow-[var(--neo-raised-sm)] hover:shadow-[var(--neo-raised)] hover:bg-green-600","disabled:bg-text-subtle disabled:text-surface disabled:border-transparent disabled:shadow-none")},l={sm:"h-8 px-3 text-xs rounded-lg gap-1.5",md:"h-10 px-4 text-sm rounded-xl gap-2",lg:"h-12 px-6 text-sm rounded-xl gap-2"};function i({children:e,variant:t="primary",size:s="md",icon:o,iconRight:d,disabled:c=!1,loading:x=!1,fullWidth:m=!1,className:u,...p}){return(0,a.jsxs)("button",{className:(0,r.cn)("inline-flex items-center justify-center font-semibold transition-all duration-150 ease-out cursor-pointer","active:shadow-[var(--neo-pressed)] disabled:opacity-50 disabled:cursor-not-allowed disabled:active:shadow-none",n[t],l[s],m&&"w-full",u),disabled:c||x,...p,children:[x?(0,a.jsx)("span",{className:"material-symbols-outlined animate-spin text-[18px]",children:"progress_activity"}):o?(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:o}):null,e,d&&!x&&(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:d})]})}},94230:(e,t,s)=>{s.d(t,{default:()=>d});var a=s(95155),r=s(12115),n=s(14051),l=s.n(n),i=s(35497),o=s(11059);function d({isOpen:e,provider:t,onSuccess:s,onClose:n}){let[l,c]=(0,r.useState)("loading"),[x,m]=(0,r.useState)(""),[u,p]=(0,r.useState)(null),[h,f]=(0,r.useState)(""),[b,g]=(0,r.useState)(null),{copied:v,copy:j}=(0,o.C)(),y=(0,r.useRef)(!1);(0,r.useEffect)(()=>{e||(y.current=!1)},[e]),(0,r.useEffect)(()=>{e&&t&&(async()=>{try{g(null),c("loading");let e=await fetch(`/api/oauth/kiro/social-authorize?provider=${t}`),s=await e.json();if(!e.ok)throw Error(s.error);p(s),m(s.authUrl),c("input"),y.current||(y.current=!0,window.open(s.authUrl,"_blank"))}catch(e){g(e.message),c("error")}})()},[e,t]);let N=async()=>{try{let e;g(null);try{e=new URL(h)}catch(e){throw Error("Invalid callback URL format")}let a=e.searchParams.get("code");e.searchParams.get("state");let r=e.searchParams.get("error");if(r)throw Error(e.searchParams.get("error_description")||r);if(!a)throw Error("No authorization code found in URL");let n=await fetch("/api/oauth/kiro/social-exchange",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({code:a,codeVerifier:u.codeVerifier,provider:t})}),l=await n.json();if(!n.ok)throw Error(l.error);c("success"),s?.()}catch(e){g(e.message),c("error")}},w="google"===t?"Google":"GitHub";return(0,a.jsx)(i.aF,{isOpen:e,title:`Connect Kiro via ${w}`,onClose:n,size:"lg",children:(0,a.jsxs)("div",{className:"flex flex-col gap-4",children:["loading"===l&&(0,a.jsxs)("div",{className:"text-center py-6",children:[(0,a.jsx)("div",{className:"size-16 mx-auto mb-4 rounded-full bg-primary/10 flex items-center justify-center",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-3xl text-primary animate-spin",children:"progress_activity"})}),(0,a.jsx)("h3",{className:"text-lg font-semibold mb-2",children:"Initializing..."}),(0,a.jsxs)("p",{className:"text-sm text-text-muted",children:["Setting up ",w," authentication"]})]}),"input"===l&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{className:"space-y-4",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("p",{className:"text-sm font-medium mb-2",children:"Step 1: Open this URL in your browser"}),(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsx)(i.pd,{value:x,readOnly:!0,className:"flex-1 font-mono text-xs"}),(0,a.jsx)(i.$n,{variant:"secondary",icon:"auth_url"===v?"check":"content_copy",onClick:()=>j(x,"auth_url"),children:"Copy"})]})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("p",{className:"text-sm font-medium mb-2",children:"Step 2: Paste the callback URL here"}),(0,a.jsx)("p",{className:"text-xs text-text-muted mb-2",children:"After authorization, copy the full URL from your browser address bar."}),(0,a.jsx)(i.pd,{value:h,onChange:e=>f(e.target.value),placeholder:"kiro://kiro.kiroAgent/authenticate-success?code=...",className:"font-mono text-xs"})]})]}),(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsx)(i.$n,{onClick:N,fullWidth:!0,disabled:!h,children:"Connect"}),(0,a.jsx)(i.$n,{onClick:n,variant:"ghost",fullWidth:!0,children:"Cancel"})]})]}),"success"===l&&(0,a.jsxs)("div",{className:"text-center py-6",children:[(0,a.jsx)("div",{className:"size-16 mx-auto mb-4 rounded-full bg-green-100 dark:bg-green-900/30 flex items-center justify-center",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-3xl text-green-600",children:"check_circle"})}),(0,a.jsx)("h3",{className:"text-lg font-semibold mb-2",children:"Connected Successfully!"}),(0,a.jsxs)("p",{className:"text-sm text-text-muted mb-4",children:["Your Kiro account via ",w," has been connected."]}),(0,a.jsx)(i.$n,{onClick:n,fullWidth:!0,children:"Done"})]}),"error"===l&&(0,a.jsxs)("div",{className:"text-center py-6",children:[(0,a.jsx)("div",{className:"size-16 mx-auto mb-4 rounded-full bg-red-100 dark:bg-red-900/30 flex items-center justify-center",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-3xl text-red-600",children:"error"})}),(0,a.jsx)("h3",{className:"text-lg font-semibold mb-2",children:"Connection Failed"}),(0,a.jsx)("p",{className:"text-sm text-red-600 mb-4",children:b}),(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsx)(i.$n,{onClick:()=>c("input"),variant:"secondary",fullWidth:!0,children:"Try Again"}),(0,a.jsx)(i.$n,{onClick:n,variant:"ghost",fullWidth:!0,children:"Cancel"})]})]})]})})}d.propTypes={isOpen:l().bool.isRequired,provider:l().oneOf(["google","github"]).isRequired,onSuccess:l().func,onClose:l().func.isRequired}},95088:(e,t,s)=>{s.d(t,{default:()=>d});var a=s(95155),r=s(12115),n=s(14051),l=s.n(n),i=s(35497);let o="https://gitlab.com";function d({isOpen:e,providerInfo:t,onSuccess:s,onClose:n}){let l,[c,x]=(0,r.useState)(null),[m,u]=(0,r.useState)(o),[p,h]=(0,r.useState)(""),[f,b]=(0,r.useState)(""),[g,v]=(0,r.useState)(""),[j,y]=(0,r.useState)(!1),[N,w]=(0,r.useState)(null),[k,C]=(0,r.useState)(!1),[S,O]=(0,r.useState)(null),T=()=>{x(null),u(o),h(""),b(""),v(""),w(null),y(!1),C(!1),O(null),n()},P=async()=>{if(!g.trim())return void w("Personal Access Token is required");y(!0),w(null);try{let e=await fetch("/api/oauth/gitlab/pat",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({token:g.trim(),baseUrl:m.trim()||o})}),t=await e.json();if(!e.ok)throw Error(t.error||"Authentication failed");s?.(),T()}catch(e){w(e.message)}finally{y(!1)}};return e?k&&S?(0,a.jsx)(i.LF,{isOpen:!0,provider:"gitlab",providerInfo:t,oauthMeta:S,onSuccess:()=>{s?.(),T()},onClose:()=>{C(!1),O(null)}}):(0,a.jsx)(i.aF,{isOpen:e,title:"Connect GitLab Duo",onClose:T,size:"lg",children:(0,a.jsxs)("div",{className:"flex flex-col gap-4",children:[!c&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("p",{className:"text-sm text-text-muted",children:"Choose how to authenticate with GitLab Duo:"}),(0,a.jsxs)("div",{className:"grid grid-cols-2 gap-3",children:[(0,a.jsxs)("button",{onClick:()=>x("oauth"),className:"flex flex-col items-center gap-2 p-4 rounded-lg border border-border hover:border-primary hover:bg-primary/5 transition-colors text-left",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-2xl text-primary",children:"lock_open"}),(0,a.jsxs)("div",{children:[(0,a.jsx)("p",{className:"text-sm font-medium",children:"OAuth App"}),(0,a.jsx)("p",{className:"text-xs text-text-muted",children:"Use a GitLab OAuth application"})]})]}),(0,a.jsxs)("button",{onClick:()=>x("pat"),className:"flex flex-col items-center gap-2 p-4 rounded-lg border border-border hover:border-primary hover:bg-primary/5 transition-colors text-left",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-2xl text-primary",children:"key"}),(0,a.jsxs)("div",{children:[(0,a.jsx)("p",{className:"text-sm font-medium",children:"Personal Access Token"}),(0,a.jsx)("p",{className:"text-xs text-text-muted",children:"Use a GitLab PAT with api scope"})]})]})]})]}),"oauth"===c&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("p",{className:"text-xs text-text-muted",children:["Create an OAuth app at"," ",(0,a.jsx)("a",{href:`${m.trim()||o}/-/profile/applications`,target:"_blank",rel:"noreferrer",className:"text-primary underline",children:"GitLab Applications"})," ","with redirect URI"," ",(0,a.jsx)("code",{className:"bg-sidebar px-1 rounded text-xs",children:(l=window.location.port||("https:"===window.location.protocol?"443":"80"),`http://localhost:${l}/callback`)})]}),(0,a.jsx)(i.pd,{label:"GitLab Base URL",value:m,onChange:e=>u(e.target.value),placeholder:o}),(0,a.jsx)(i.pd,{label:"Client ID",value:p,onChange:e=>h(e.target.value),placeholder:"Your OAuth application client ID"}),(0,a.jsx)(i.pd,{label:"Client Secret (optional for PKCE)",value:f,onChange:e=>b(e.target.value),placeholder:"Leave empty for public PKCE app"}),N&&(0,a.jsx)("p",{className:"text-sm text-red-500",children:N}),(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsx)(i.$n,{onClick:()=>{p.trim()?(w(null),O({baseUrl:m.trim()||o,clientId:p.trim(),clientSecret:f.trim()}),C(!0)):w("Client ID is required")},fullWidth:!0,disabled:!p.trim(),children:"Authorize"}),(0,a.jsx)(i.$n,{onClick:()=>{x(null),w(null)},variant:"ghost",fullWidth:!0,children:"Back"})]})]}),"pat"===c&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("p",{className:"text-xs text-text-muted",children:["Create a PAT at"," ",(0,a.jsx)("a",{href:`${m.trim()||o}/-/user_settings/personal_access_tokens`,target:"_blank",rel:"noreferrer",className:"text-primary underline",children:"GitLab Access Tokens"})," ","with scopes: ",(0,a.jsx)("code",{className:"bg-sidebar px-1 rounded text-xs",children:"api"}),","," ",(0,a.jsx)("code",{className:"bg-sidebar px-1 rounded text-xs",children:"read_user"}),", and"," ",(0,a.jsx)("code",{className:"bg-sidebar px-1 rounded text-xs",children:"ai_features"}),"."]}),(0,a.jsx)(i.pd,{label:"GitLab Base URL",value:m,onChange:e=>u(e.target.value),placeholder:o}),(0,a.jsx)(i.pd,{label:"Personal Access Token",value:g,onChange:e=>v(e.target.value),placeholder:"glpat-xxxxxxxxxxxxxxxxxxxx",type:"password"}),N&&(0,a.jsx)("p",{className:"text-sm text-red-500",children:N}),(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsx)(i.$n,{onClick:P,fullWidth:!0,disabled:!g.trim()||j,loading:j,children:"Connect"}),(0,a.jsx)(i.$n,{onClick:()=>{x(null),w(null)},variant:"ghost",fullWidth:!0,children:"Back"})]})]})]})}):null}d.propTypes={isOpen:l().bool.isRequired,providerInfo:l().shape({name:l().string}),onSuccess:l().func,onClose:l().func.isRequired}},96748:(e,t,s)=>{s.d(t,{default:()=>d});var a=s(95155),r=s(12115),n=s(14051),l=s.n(n),i=s(35497);let o="https://api.openai.com/v1";function d({isOpen:e,onClose:t,onCreated:s,onSaved:n,node:l}){let c=!!l,[x,m]=(0,r.useState)({name:"",prefix:"",baseUrl:o}),[u,p]=(0,r.useState)(!1),[h,f]=(0,r.useState)(""),[b,g]=(0,r.useState)(""),[v,j]=(0,r.useState)(!1),[y,N]=(0,r.useState)(null);(0,r.useEffect)(()=>{e&&(N(null),f(""),g(""),c?m({name:l.name||"",prefix:l.prefix||"",baseUrl:l.baseUrl||o}):m({name:"",prefix:"",baseUrl:o}))},[e,c,l]);let w=async()=>{if(x.name.trim()&&x.prefix.trim()&&x.baseUrl.trim()){p(!0);try{let e=c?`/api/provider-nodes/${l.id}`:"/api/provider-nodes",t=c?"PUT":"POST",a={name:x.name,prefix:x.prefix,baseUrl:x.baseUrl};c||(a.type="custom-embedding");let r=await fetch(e,{method:t,headers:{"Content-Type":"application/json"},body:JSON.stringify(a)}),i=await r.json();r.ok&&(c?n?.(i.node):s?.(i.node))}catch(e){console.log("Error saving custom embedding node:",e)}finally{p(!1)}}},k=async()=>{j(!0);try{let e=await fetch("/api/provider-nodes/validate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({baseUrl:x.baseUrl,apiKey:h,type:"custom-embedding",modelId:b.trim()||void 0})}),t=await e.json();N(t)}catch{N({valid:!1,error:"Network error"})}finally{j(!1)}};return(0,a.jsx)(i.aF,{isOpen:e,title:c?"Edit Custom Embedding":"Add Custom Embedding",onClose:t,children:(0,a.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,a.jsx)(i.pd,{label:"Name",value:x.name,onChange:e=>m({...x,name:e.target.value}),placeholder:"Voyage AI",hint:"Required. A friendly label for this embedding provider."}),(0,a.jsx)(i.pd,{label:"Prefix",value:x.prefix,onChange:e=>m({...x,prefix:e.target.value}),placeholder:"voyage",hint:"Required. Used as the provider prefix for model IDs (e.g. voyage/voyage-3)."}),(0,a.jsx)(i.pd,{label:"Base URL",value:x.baseUrl,onChange:e=>m({...x,baseUrl:e.target.value}),placeholder:"https://api.voyageai.com/v1",hint:"Most embedding APIs are OpenAI-compatible: Voyage, Cohere, Jina, Mistral, Together..."}),(0,a.jsx)(i.pd,{label:"API Key (for Check)",type:"password",value:h,onChange:e=>f(e.target.value)}),(0,a.jsx)(i.pd,{label:"Model ID (for Check)",value:b,onChange:e=>g(e.target.value),placeholder:"e.g. voyage-3, embed-english-v3.0, text-embedding-3-small",hint:"Required for validation. Will send a test embeddings request."}),(0,a.jsxs)("div",{className:"flex items-center gap-3",children:[(0,a.jsx)(i.$n,{onClick:k,disabled:!h||!b.trim()||v||!x.baseUrl.trim(),variant:"secondary",children:v?"Checking...":"Check"}),(()=>{if(!y)return null;let{valid:e,error:t,dimensions:s}=y;return e?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(i.Ex,{variant:"success",children:"Valid"}),s&&(0,a.jsxs)("span",{className:"text-sm text-text-muted",children:[s," dims"]})]}):(0,a.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,a.jsx)(i.Ex,{variant:"error",children:"Invalid"}),t&&(0,a.jsx)("span",{className:"text-sm text-red-500",children:t})]})})()]}),(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsx)(i.$n,{onClick:w,fullWidth:!0,disabled:!x.name.trim()||!x.prefix.trim()||!x.baseUrl.trim()||u,children:u?c?"Saving...":"Creating...":c?"Save":"Create"}),(0,a.jsx)(i.$n,{onClick:t,variant:"ghost",fullWidth:!0,children:"Cancel"})]})]})})}d.propTypes={isOpen:l().bool.isRequired,onClose:l().func.isRequired,onCreated:l().func,onSaved:l().func,node:l().shape({id:l().string,name:l().string,prefix:l().string,baseUrl:l().string})}},97677:(e,t,s)=>{s.d(t,{default:()=>r});var a=s(95155);function r({text:e,children:t,position:s="top",color:n}){let l=n?"":"bg-gray-900";return(0,a.jsxs)("div",{className:"relative inline-flex group/tt",children:[t,(0,a.jsx)("div",{className:`pointer-events-none absolute ${{top:"bottom-full left-1/2 -translate-x-1/2 mb-1.5",bottom:"top-full left-1/2 -translate-x-1/2 mt-1.5",left:"right-full top-1/2 -translate-y-1/2 mr-1.5",right:"left-full top-1/2 -translate-y-1/2 ml-1.5"}[s]} z-50 w-max max-w-56 rounded px-2 py-1 text-[11px] leading-snug ${l} text-white opacity-0 group-hover/tt:opacity-100 transition-opacity duration-150 whitespace-normal`,style:n?{backgroundColor:n}:{},children:e})]})}},98542:(e,t,s)=>{s.d(t,{default:()=>n});var a=s(95155),r=s(31474);function n({checked:e=!1,onChange:t,label:s,description:l,disabled:i=!1,size:o="md",className:d}){let c={sm:{track:"w-8 h-4",thumb:"size-3",translate:"translate-x-4"},md:{track:"w-11 h-6",thumb:"size-5",translate:"translate-x-5"},lg:{track:"w-14 h-7",thumb:"size-6",translate:"translate-x-7"}};return(0,a.jsxs)("div",{className:(0,r.cn)("flex items-center gap-3",i&&"opacity-50 cursor-not-allowed",d),children:[(0,a.jsx)("button",{type:"button",role:"switch","aria-checked":e,disabled:i,onClick:()=>{!i&&t&&t(!e)},className:(0,r.cn)("relative inline-flex shrink-0 cursor-pointer rounded-full","transition-colors duration-200 border","focus:outline-none focus:ring-2 focus:ring-brand/30",e?"bg-brand border-brand/20 shadow-[var(--neo-pressed)]":"bg-bg-alt border-border shadow-[var(--neo-flat)]",c[o].track,i&&"cursor-not-allowed"),children:(0,a.jsx)("span",{className:(0,r.cn)("pointer-events-none inline-block rounded-full bg-white shadow-sm","transition-transform duration-200",e?c[o].translate:"translate-x-0.5",c[o].thumb,"mt-0.5")})}),(s||l)&&(0,a.jsxs)("div",{className:"flex flex-col",children:[s&&(0,a.jsx)("span",{className:"text-sm font-medium text-text leading-tight",children:s}),l&&(0,a.jsx)("span",{className:"text-xs text-text-muted mt-0.5",children:l})]})]})}},99069:(e,t,s)=>{s.d(t,{default:()=>V});var a=s(95155),r=s(12115),n=s(73321),l=s(88105),i=s(56061),o=s(84588),d=s(14051),c=s.n(d);let x=[{key:"totalRequests",label:"Total Requests",icon:"bolt",accent:"brand"},{key:"totalPromptTokens",label:"Input Tokens",icon:"input",accent:"blue"},{key:"totalCompletionTokens",label:"Output Tokens",icon:"output",accent:"green"},{key:"totalCost",label:"Est. Cost",icon:"payments",accent:"amber",format:"cost"}],m={brand:{icon:"text-brand",value:"text-brand"},blue:{icon:"text-blue-500",value:"text-blue-500"},green:{icon:"text-green-500",value:"text-green-500"},amber:{icon:"text-amber-500",value:"text-amber-500"}};function u({stats:e}){return(0,a.jsx)("div",{className:"grid min-w-0 grid-cols-1 gap-3 sm:grid-cols-2 md:grid-cols-4",children:x.map(t=>{let s=m[t.accent],r=e?.[t.key]||0,n="cost"===t.format?`~$${(r||0).toFixed(2)}`:new Intl.NumberFormat().format(r||0);return(0,a.jsxs)("div",{className:"neo-raised p-4",children:[(0,a.jsxs)("div",{className:"flex items-start justify-between mb-2",children:[(0,a.jsx)("span",{className:"text-[10px] font-medium uppercase tracking-wide text-text-muted",children:t.label}),(0,a.jsx)("span",{className:`material-symbols-outlined text-[16px] ${s.icon}`,children:t.icon})]}),(0,a.jsx)("div",{className:`text-xl font-bold ${s.value}`,children:n}),"cost"===t.format&&(0,a.jsx)("div",{className:"text-[10px] text-text-subtle mt-1",children:"Estimated, not actual billing"})]},t.key)})})}u.propTypes={stats:c().object.isRequired};let p=e=>new Intl.NumberFormat().format(e||0),h=e=>`$${(e||0).toFixed(2)}`;function f(e){if(!e)return"Never";let t=Math.floor((Date.now()-new Date(e))/6e4);return t<1?"Just now":t<60?`${t}m ago`:t<1440?`${Math.floor(t/60)}h ago`:new Date(e).toLocaleDateString()}function b({field:e,currentSort:t,currentOrder:s}){return t!==e?(0,a.jsx)("span",{className:"ml-1 opacity-20",children:"↕"}):(0,a.jsx)("span",{className:"ml-1",children:"asc"===s?"↑":"↓"})}function g({item:e,viewMode:t,isSummary:s=!1}){return"tokens"===t?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("td",{className:"px-6 py-3 text-right text-text-muted",children:s&&void 0===e.promptTokens?"—":p(e.promptTokens)}),(0,a.jsx)("td",{className:"px-6 py-3 text-right text-text-muted",children:s&&void 0===e.completionTokens?"—":p(e.completionTokens)}),(0,a.jsx)("td",{className:"px-6 py-3 text-right font-medium",children:p(e.totalTokens)})]}):(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("td",{className:"px-6 py-3 text-right text-text-muted",children:s&&void 0===e.inputCost?"—":h(e.inputCost)}),(0,a.jsx)("td",{className:"px-6 py-3 text-right text-text-muted",children:s&&void 0===e.outputCost?"—":h(e.outputCost)}),(0,a.jsx)("td",{className:"px-6 py-3 text-right font-medium text-warning",children:h(e.totalCost||e.cost)})]})}function v({title:e,columns:t,groupedData:s,tableType:n,sortBy:l,sortOrder:i,onToggleSort:d,viewMode:c,storageKey:x,renderDetailCells:m,renderSummaryCells:u,emptyMessage:p}){let[h,f]=(0,r.useState)(new Set);(0,r.useEffect)(()=>{try{let e=localStorage.getItem(x);e&&f(new Set(JSON.parse(e)))}catch(e){console.error(`Failed to load ${x}:`,e)}},[x]),(0,r.useEffect)(()=>{try{localStorage.setItem(x,JSON.stringify([...h]))}catch(e){console.error(`Failed to save ${x}:`,e)}},[h,x]);let j=(0,r.useCallback)(e=>{f(t=>{let s=new Set(t);return s.has(e)?s.delete(e):s.add(e),s})},[]),y=(0,r.useMemo)(()=>"tokens"===c?[{field:"promptTokens",label:"Input Tokens"},{field:"completionTokens",label:"Output Tokens"},{field:"totalTokens",label:"Total Tokens"}]:[{field:"promptTokens",label:"Input Cost"},{field:"completionTokens",label:"Output Cost"},{field:"cost",label:"Total Cost"}],[c]),N=t.length+y.length;return(0,a.jsxs)(o.default,{className:"overflow-hidden",children:[(0,a.jsx)("div",{className:"p-4 border-b border-border bg-bg-subtle/50",children:(0,a.jsx)("h3",{className:"font-semibold",children:e})}),(0,a.jsx)("div",{className:"overflow-x-auto",children:(0,a.jsxs)("table",{className:"w-full text-sm text-left",children:[(0,a.jsx)("thead",{className:"bg-bg-subtle/30 text-text-muted uppercase text-xs",children:(0,a.jsxs)("tr",{children:[t.map(e=>(0,a.jsxs)("th",{className:`px-6 py-3 cursor-pointer hover:bg-bg-subtle/50 ${"right"===e.align?"text-right":""}`,onClick:()=>d(n,e.field),children:[e.label," ",(0,a.jsx)(b,{field:e.field,currentSort:l,currentOrder:i})]},e.field)),y.map(e=>(0,a.jsxs)("th",{className:"px-6 py-3 text-right cursor-pointer hover:bg-bg-subtle/50",onClick:()=>d(n,e.field),children:[e.label," ",(0,a.jsx)(b,{field:e.field,currentSort:l,currentOrder:i})]},e.field))]})}),(0,a.jsxs)("tbody",{className:"divide-y divide-border",children:[s.map(e=>(0,a.jsxs)(r.Fragment,{children:[(0,a.jsxs)("tr",{className:"group-summary cursor-pointer hover:bg-bg-subtle/50 transition-colors",onClick:()=>j(e.groupKey),children:[(0,a.jsx)("td",{className:"px-6 py-3",children:(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("span",{className:`material-symbols-outlined text-[18px] text-text-muted transition-transform ${h.has(e.groupKey)?"rotate-90":""}`,children:"chevron_right"}),(0,a.jsx)("span",{className:`font-medium transition-colors ${e.summary.pending>0?"text-primary":""}`,children:e.groupKey})]})}),u(e),(0,a.jsx)(g,{item:e.summary,viewMode:c,isSummary:!0})]}),h.has(e.groupKey)&&e.items.map(e=>(0,a.jsxs)("tr",{className:"group-detail hover:bg-bg-subtle/20 transition-colors",children:[m(e),(0,a.jsx)(g,{item:e,viewMode:c})]},`detail-${e.key}`))]},e.groupKey)),0===s.length&&(0,a.jsx)("tr",{children:(0,a.jsx)("td",{colSpan:N,className:"px-6 py-8 text-center text-text-muted",children:p})})]})]})})]})}function j(e){return l.Q2[e]||{color:"#6b7280",name:e}}function y({providerId:e,color:t,size:s=28}){let[n,l]=(0,r.useState)(!1),i=j(e).textIcon||(e||"?").slice(0,2).toUpperCase();return(0,a.jsx)("div",{className:"flex items-center justify-center rounded-lg shrink-0",style:{width:s,height:s,backgroundColor:`color-mix(in srgb, ${t} 12%, transparent)`},children:n?(0,a.jsx)("span",{className:"font-bold",style:{color:t,fontSize:.35*s},children:i}):(0,a.jsx)("img",{src:`/providers/${e}.png`,alt:e,className:"rounded object-contain",style:{width:.7*s,height:.7*s},onError:()=>l(!0)})})}function N({provider:e,active:t,error:s,last:r,requests:n,maxRequests:l}){let i=j(e.provider),o=i.color||"#6b7280",d=(i.name!==e.provider?i.name:null)||e.nodeName||e.name||e.provider,c=t?o:s?"#ef4444":r?"#f59e0b":"var(--border)",x=t?`color-mix(in srgb, ${o} 6%, var(--surface))`:"var(--surface)";return(0,a.jsxs)("div",{className:"flex items-center gap-3 p-3 rounded-xl border transition-all",style:{borderColor:c,background:x,boxShadow:t?`0 0 16px color-mix(in srgb, ${o} 12%, transparent)`:"var(--neo-raised-sm)"},children:[(0,a.jsx)(y,{providerId:e.provider,color:o}),(0,a.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("span",{className:"text-sm font-semibold truncate",style:{color:t?o:"var(--text)"},children:d}),t&&(0,a.jsxs)("span",{className:"relative flex h-2 w-2 shrink-0",children:[(0,a.jsx)("span",{className:"absolute inline-flex h-full w-full rounded-full opacity-40",style:{backgroundColor:o,animation:"pulse 2s infinite"}}),(0,a.jsx)("span",{className:"relative inline-flex rounded-full h-2 w-2",style:{backgroundColor:o}})]}),s&&!t&&(0,a.jsx)("span",{className:"block h-2 w-2 rounded-full bg-red-500 shrink-0"}),!t&&!s&&!r&&(0,a.jsx)("span",{className:"block h-2 w-2 rounded-full bg-text-subtle shrink-0"}),r&&!t&&!s&&(0,a.jsx)("span",{className:"block h-2 w-2 rounded-full bg-amber-500 shrink-0"})]}),(0,a.jsx)("div",{className:"mt-2 h-1.5 rounded-full overflow-hidden",style:{background:"var(--bg-alt)"},children:(0,a.jsx)("div",{className:"h-full rounded-full transition-all duration-500",style:{width:`${l>0?n/l*100:0}%`,background:t?o:s?"#ef4444":r?"#f59e0b":"var(--text-subtle)"}})}),(0,a.jsxs)("div",{className:"mt-1 flex items-center justify-between",children:[(0,a.jsx)("span",{className:"text-[10px] text-text-muted",children:i.name!==e.provider?e.provider:""}),(0,a.jsx)("span",{className:"text-[10px] font-mono text-text-muted",children:n>0?`${n} req${1!==n?"s":""}`:"idle"})]})]})]})}function w({providers:e=[],activeRequests:t=[],lastProvider:s="",errorProvider:n=""}){let[l,i]=(0,r.useState)(!1),d=(0,r.useRef)({}),[c,x]=(0,r.useState)(0),m=(0,r.useMemo)(()=>t.map(e=>e.provider?.toLowerCase()).filter(Boolean).sort().join(","),[t]),u=s?.toLowerCase()||"",p=n?.toLowerCase()||"",h=(0,r.useMemo)(()=>new Set(m?m.split(","):[]),[m]);(0,r.useEffect)(()=>{let e=d.current,t=Date.now();for(let s of h)e[s]||(e[s]=t);for(let t of Object.keys(e))h.has(t)||delete e[t]},[h]),(0,r.useEffect)(()=>{if(0===h.size)return;let e=setInterval(()=>x(e=>e+1),1e3);return()=>clearInterval(e)},[h]);let f=(0,r.useMemo)(()=>{let e=Date.now(),t=new Set;for(let s of h){let a=d.current[s];(!a||e-a<6e4)&&t.add(s)}return t},[h,c]),b=(0,r.useMemo)(()=>{let e={};for(let s of t){let t=s.provider?.toLowerCase();t&&(e[t]=(e[t]||0)+1)}return e},[t]),g=(0,r.useMemo)(()=>[...e].sort((e,t)=>{let s=e.provider?.toLowerCase(),a=t.provider?.toLowerCase(),r=+!f.has(s),n=+!f.has(a);if(r!==n)return r-n;let l=+(p!==s),i=+(p!==a);return l!==i?l-i:(u!==s)-(u!==a)}),[e,f,u,p]),v=(0,r.useMemo)(()=>Math.max(1,...g.map(e=>b[e.provider?.toLowerCase()]||0)),[g,b]),j=l?g:g.slice(0,12),y=g.length-12;return 0===e.length?(0,a.jsx)(o.default,{className:"flex items-center justify-center h-[320px]",padding:"none",children:(0,a.jsx)("div",{className:"text-text-muted text-sm",children:"No providers connected"})}):(0,a.jsxs)(o.default,{className:"overflow-hidden",padding:"none",children:[(0,a.jsxs)("div",{className:"px-4 py-3 border-b border-border flex items-center justify-between",children:[(0,a.jsxs)("div",{className:"flex items-center gap-3",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2 px-3 py-1.5 rounded-xl bg-brand/10 border border-brand/20",children:[(0,a.jsx)("img",{src:"/favicon.svg",alt:"Prozygent",className:"w-4 h-4"}),(0,a.jsx)("span",{className:"text-xs font-bold text-brand",children:"Prozygent"}),f.size>0&&(0,a.jsx)("span",{className:"px-1.5 py-0.5 rounded-full bg-brand text-white text-[9px] font-bold",children:f.size})]}),(0,a.jsx)("span",{className:"material-symbols-outlined text-text-subtle text-[16px]",children:"arrow_downward"}),(0,a.jsx)("h3",{className:"text-sm font-semibold text-text",children:"Providers"})]}),(0,a.jsxs)("div",{className:"flex items-center gap-3 text-[10px] text-text-muted",children:[(0,a.jsxs)("span",{className:"flex items-center gap-1",children:[(0,a.jsx)("span",{className:"w-2 h-2 rounded-full bg-green-500"})," Active"]}),(0,a.jsxs)("span",{className:"flex items-center gap-1",children:[(0,a.jsx)("span",{className:"w-2 h-2 rounded-full bg-amber-500"})," Last"]}),(0,a.jsxs)("span",{className:"flex items-center gap-1",children:[(0,a.jsx)("span",{className:"w-2 h-2 rounded-full bg-red-500"})," Error"]}),(0,a.jsx)("span",{className:"text-text-subtle",children:"|"}),(0,a.jsxs)("span",{children:[e.length," total"]})]})]}),(0,a.jsx)("div",{className:"flex justify-center",children:(0,a.jsx)("div",{className:"w-px h-4 bg-border"})}),(0,a.jsxs)("div",{className:"px-4 pb-4",children:[(0,a.jsx)("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-2",children:j.map(e=>(0,a.jsx)(N,{provider:e,active:f.has(e.provider?.toLowerCase()),error:p===e.provider?.toLowerCase(),last:u===e.provider?.toLowerCase()&&!f.has(e.provider?.toLowerCase()),requests:b[e.provider?.toLowerCase()]||0,maxRequests:v},e.provider))}),!l&&y>0&&(0,a.jsxs)("button",{onClick:()=>i(!0),className:"mt-3 w-full py-2 rounded-xl border border-border text-xs font-medium text-text-muted hover:text-text hover:bg-surface-hover transition-colors",children:["Show ",y," more providers"]}),l&&y>0&&(0,a.jsx)("button",{onClick:()=>i(!1),className:"mt-3 w-full py-2 rounded-xl border border-border text-xs font-medium text-text-muted hover:text-text hover:bg-surface-hover transition-colors",children:"Show less"})]})]})}b.propTypes={field:c().string.isRequired,currentSort:c().string.isRequired,currentOrder:c().string.isRequired},g.propTypes={item:c().object.isRequired,viewMode:c().string.isRequired,isSummary:c().bool},v.propTypes={title:c().string.isRequired,columns:c().arrayOf(c().shape({field:c().string.isRequired,label:c().string.isRequired,align:c().string})).isRequired,groupedData:c().array.isRequired,tableType:c().string.isRequired,sortBy:c().string.isRequired,sortOrder:c().string.isRequired,onToggleSort:c().func.isRequired,viewMode:c().string.isRequired,storageKey:c().string.isRequired,renderDetailCells:c().func.isRequired,renderSummaryCells:c().func.isRequired,emptyMessage:c().string.isRequired},w.propTypes={providers:c().arrayOf(c().shape({id:c().string,provider:c().string,name:c().string})),activeRequests:c().arrayOf(c().shape({provider:c().string,model:c().string,account:c().string})),lastProvider:c().string,errorProvider:c().string};var k=s(21742),C=s(63346),S=s(28408),O=s(32539),T=s(59656),P=s(55433),$=s(40968);let I=e=>e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}K`:String(e||0),F=e=>`$${(e||0).toFixed(4)}`;function E({active:e,payload:t,label:s,viewMode:r}){if(!e||!t||!t.length)return null;let n=t[0].value;return(0,a.jsxs)("div",{className:"neo-raised-sm px-3 py-2 rounded-xl text-xs",children:[(0,a.jsx)("div",{className:"text-text-muted mb-1",children:s}),(0,a.jsx)("div",{className:"font-semibold text-text",children:"tokens"===r?I(n):F(n)})]})}function _({period:e="7d"}){let[t,s]=(0,r.useState)([]),[n,l]=(0,r.useState)(!0),[i,d]=(0,r.useState)("tokens"),c=(0,r.useCallback)(async()=>{l(!0);try{let t=await fetch(`/api/usage/chart?period=${e}`);if(t.ok){let e=await t.json();s(e)}}catch(e){console.error("Failed to fetch chart data:",e)}finally{l(!1)}},[e]);(0,r.useEffect)(()=>{c()},[c]);let x=t.some(e=>e.tokens>0||e.cost>0);return(0,a.jsxs)(o.default,{className:"flex min-w-0 flex-col gap-3 p-3 sm:p-4",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between",children:[(0,a.jsx)("h3",{className:"text-sm font-semibold text-text",children:"Usage Over Time"}),(0,a.jsxs)("div",{className:"grid grid-cols-2 items-center gap-1 rounded-xl border border-border bg-bg-alt p-1",children:[(0,a.jsx)("button",{onClick:()=>d("tokens"),className:`px-3 py-1 rounded-lg text-xs font-medium transition-colors ${"tokens"===i?"bg-brand text-white shadow-sm":"text-text-muted hover:text-text"}`,children:"Tokens"}),(0,a.jsx)("button",{onClick:()=>d("cost"),className:`px-3 py-1 rounded-lg text-xs font-medium transition-colors ${"cost"===i?"bg-brand text-white shadow-sm":"text-text-muted hover:text-text"}`,children:"Cost"})]})]}),n?(0,a.jsx)("div",{className:"h-48 flex items-center justify-center text-text-muted text-sm",children:"Loading..."}):x?(0,a.jsx)(k.u,{width:"100%",height:220,children:(0,a.jsxs)(C.Q,{data:t,margin:{top:4,right:8,left:0,bottom:0},children:[(0,a.jsxs)("defs",{children:[(0,a.jsxs)("linearGradient",{id:"gradTokens",x1:"0",y1:"0",x2:"0",y2:"1",children:[(0,a.jsx)("stop",{offset:"5%",stopColor:"#6c63ff",stopOpacity:.2}),(0,a.jsx)("stop",{offset:"95%",stopColor:"#6c63ff",stopOpacity:0})]}),(0,a.jsxs)("linearGradient",{id:"gradCost",x1:"0",y1:"0",x2:"0",y2:"1",children:[(0,a.jsx)("stop",{offset:"5%",stopColor:"#f59e0b",stopOpacity:.2}),(0,a.jsx)("stop",{offset:"95%",stopColor:"#f59e0b",stopOpacity:0})]})]}),(0,a.jsx)(S.d,{strokeDasharray:"3 3",stroke:"var(--border)"}),(0,a.jsx)(O.W,{dataKey:"label",tick:{fontSize:10,fill:"var(--text-muted)"},tickLine:!1,axisLine:!1,interval:"preserveStartEnd"}),(0,a.jsx)(T.h,{tick:{fontSize:10,fill:"var(--text-muted)"},tickLine:!1,axisLine:!1,tickFormatter:"tokens"===i?I:F,width:50}),(0,a.jsx)(P.m,{content:(0,a.jsx)(E,{viewMode:i})}),"tokens"===i?(0,a.jsx)($.Gk,{type:"monotone",dataKey:"tokens",stroke:"#6c63ff",strokeWidth:2,fill:"url(#gradTokens)",dot:!1,activeDot:{r:4,fill:"#6c63ff",stroke:"var(--surface)",strokeWidth:2}}):(0,a.jsx)($.Gk,{type:"monotone",dataKey:"cost",stroke:"#f59e0b",strokeWidth:2,fill:"url(#gradCost)",dot:!1,activeDot:{r:4,fill:"#f59e0b",stroke:"var(--surface)",strokeWidth:2}})]})}):(0,a.jsx)("div",{className:"h-48 flex items-center justify-center text-text-muted text-sm",children:"No data for this period"})]})}function A(e){let t=l.Q2[e];return!t?.serviceKinds||t.serviceKinds.includes("llm")}function W({timestamp:e}){let t,[,s]=(0,r.useState)(0);return(0,r.useEffect)(()=>{let e=setInterval(()=>s(e=>e+1),1e3);return()=>clearInterval(e)},[]),(0,a.jsx)(a.Fragment,{children:(t=Math.floor((Date.now()-new Date(e))/1e3))<60?`${t}s ago`:t<3600?`${Math.floor(t/60)}m ago`:t<86400?`${Math.floor(t/3600)}h ago`:`${Math.floor(t/86400)}d ago`})}function R({requests:e=[]}){return(0,a.jsxs)(o.default,{className:"flex min-w-0 flex-col overflow-hidden",padding:"sm",style:{height:480},children:[(0,a.jsx)("div",{className:"px-1 py-2 border-b border-border shrink-0",children:(0,a.jsx)("span",{className:"text-xs font-semibold text-text-muted uppercase tracking-wide",children:"Recent Requests"})}),e.length?(0,a.jsx)("div",{className:"flex-1 overflow-y-auto",children:(0,a.jsxs)("table",{className:"w-full min-w-[300px] border-collapse text-xs",children:[(0,a.jsx)("thead",{className:"sticky top-0 bg-bg z-10",children:(0,a.jsxs)("tr",{className:"border-b border-border",children:[(0,a.jsx)("th",{className:"py-1.5 text-left font-semibold text-text-muted w-2"}),(0,a.jsx)("th",{className:"py-1.5 text-left font-semibold text-text-muted",children:"Model"}),(0,a.jsx)("th",{className:"py-1.5 text-right font-semibold text-text-muted whitespace-nowrap",children:"In / Out"}),(0,a.jsx)("th",{className:"py-1.5 text-right font-semibold text-text-muted",children:"When"})]})}),(0,a.jsx)("tbody",{className:"divide-y divide-border/50",children:e.map((e,t)=>{let s=!e.status||"ok"===e.status||"success"===e.status;return(0,a.jsxs)("tr",{className:"hover:bg-bg-subtle transition-colors",children:[(0,a.jsx)("td",{className:"py-1.5",children:(0,a.jsx)("span",{className:`block w-1.5 h-1.5 rounded-full ${s?"bg-success":"bg-error"}`})}),(0,a.jsx)("td",{className:"py-1.5 font-mono truncate max-w-[120px]",title:e.model,children:e.model}),(0,a.jsxs)("td",{className:"py-1.5 text-right whitespace-nowrap",children:[(0,a.jsxs)("span",{className:"text-primary",children:[p(e.promptTokens),"↑"]})," ",(0,a.jsxs)("span",{className:"text-success",children:[p(e.completionTokens),"↓"]})]}),(0,a.jsx)("td",{className:"py-1.5 text-right text-text-muted whitespace-nowrap",children:(0,a.jsx)(W,{timestamp:e.timestamp})})]},t)})})]})}):(0,a.jsx)("div",{className:"flex-1 flex items-center justify-center text-text-muted text-sm",children:"No requests yet."})]})}function L(e,t={},s,a){return Object.entries(e||{}).map(([e,s])=>{let a=(s.promptTokens||0)+(s.completionTokens||0),r=s.cost||0,n=a>0?(s.promptTokens||0)*(r/a):0,l=a>0?(s.completionTokens||0)*(r/a):0;return{...s,key:e,totalTokens:a,totalCost:r,inputCost:n,outputCost:l,pending:t[e]||0}}).sort((e,t)=>{let r=e[s],n=t[s];return("string"==typeof r&&(r=r.toLowerCase()),"string"==typeof n&&(n=n.toLowerCase()),r<n)?"asc"===a?-1:1:r>n?"asc"===a?1:-1:0})}function z(e,t){if(!Array.isArray(e))return[];let s={};return e.forEach(e=>{let a=function(e,t){switch(t){case"rawModel":return e.rawModel||"Unknown Model";case"accountName":return e.accountName||`Account ${e.connectionId?.slice(0,8)}...`||"Unknown Account";case"keyName":return e.keyName||"Unknown Key";case"endpoint":return e.endpoint||"Unknown Endpoint";default:return e[t]||"Unknown"}}(e,t);s[a]||(s[a]={groupKey:a,summary:{requests:0,promptTokens:0,completionTokens:0,totalTokens:0,cost:0,inputCost:0,outputCost:0,lastUsed:null,pending:0},items:[]});let r=s[a].summary;r.requests+=e.requests||0,r.promptTokens+=e.promptTokens||0,r.completionTokens+=e.completionTokens||0,r.totalTokens+=e.totalTokens||0,r.cost+=e.cost||0,r.inputCost+=e.inputCost||0,r.outputCost+=e.outputCost||0,r.pending+=e.pending||0,e.lastUsed&&(!r.lastUsed||new Date(e.lastUsed)>new Date(r.lastUsed))&&(r.lastUsed=e.lastUsed),s[a].items.push(e)}),Object.values(s)}_.propTypes={period:c().string};let q=[{field:"rawModel",label:"Model"},{field:"provider",label:"Provider"},{field:"requests",label:"Requests",align:"right"},{field:"lastUsed",label:"Last Used",align:"right"}],M=[{field:"rawModel",label:"Model"},{field:"provider",label:"Provider"},{field:"accountName",label:"Account"},{field:"requests",label:"Requests",align:"right"},{field:"lastUsed",label:"Last Used",align:"right"}],U=[{field:"keyName",label:"API Key Name"},{field:"rawModel",label:"Model"},{field:"provider",label:"Provider"},{field:"requests",label:"Requests",align:"right"},{field:"lastUsed",label:"Last Used",align:"right"}],D=[{field:"endpoint",label:"Endpoint"},{field:"rawModel",label:"Model"},{field:"provider",label:"Provider"},{field:"requests",label:"Requests",align:"right"},{field:"lastUsed",label:"Last Used",align:"right"}],K=[{value:"model",label:"Usage by Model"},{value:"account",label:"Usage by Account"},{value:"apiKey",label:"Usage by API Key"},{value:"endpoint",label:"Usage by Endpoint"}],B=[{value:"today",label:"Today"},{value:"24h",label:"24h"},{value:"7d",label:"7D"},{value:"30d",label:"30D"},{value:"60d",label:"60D"}];function V({period:e,setPeriod:t,hidePeriodSelector:s=!1}={}){let o=(0,n.useRouter)(),d=(0,n.useSearchParams)(),c=d.get("sortBy")||"rawModel",x=d.get("sortOrder")||"asc",[m,h]=(0,r.useState)(null),[b,g]=(0,r.useState)(!0),[j,y]=(0,r.useState)(!1),[N,k]=(0,r.useState)("model"),[C,S]=(0,r.useState)("costs"),[O,T]=(0,r.useState)([]),[P,$]=(0,r.useState)("today"),I=(0,r.useRef)(!0),F=(0,r.useRef)(!1),E=e??P,W=t??$;(0,r.useEffect)(()=>{Promise.all([fetch("/api/providers").then(e=>e.ok?e.json():null),fetch("/api/provider-nodes").then(e=>e.ok?e.json():null)]).then(([e,t])=>{let s={};for(let e of t?.nodes||[])s[e.id]=e.name;let a=new Set;T([...(e?.connections||[]).filter(e=>!(!1===e.isActive||!A(e.provider)||a.has(e.provider))&&(a.add(e.provider),!0)).map(e=>({...e,nodeName:s[e.provider]||null})),...Object.values(l.IS).filter(e=>e.noAuth&&!a.has(e.id)&&A(e.id)).map(e=>({provider:e.id,name:e.name}))])}).catch(()=>{})},[]),(0,r.useEffect)(()=>{I.current?(I.current=!1,g(!0)):y(!0),fetch(`/api/usage/stats?period=${E}`).then(e=>e.ok?e.json():null).then(e=>{e&&(F.current=!0,h(t=>({...t,...e})))}).catch(()=>{}).finally(()=>{g(!1),y(!1)})},[E]),(0,r.useEffect)(()=>{let e=new EventSource("/api/usage/stream");return e.onmessage=e=>{try{let t=JSON.parse(e.data);h(e=>e?{...e,activeRequests:t.activeRequests,recentRequests:t.recentRequests,errorProvider:t.errorProvider,pending:t.pending}:e),F.current&&g(!1)}catch(e){console.error("[SSE CLIENT] parse error:",e)}},e.onerror=()=>g(!1),()=>e.close()},[]);let G=(0,r.useCallback)((e,t)=>{let s=new URLSearchParams(d.toString());s.get("sortBy")===t?s.set("sortOrder","asc"===s.get("sortOrder")?"desc":"asc"):(s.set("sortBy",t),s.set("sortOrder","asc")),o.replace(`?${s.toString()}`,{scroll:!1})},[d,o]),J=(0,r.useMemo)(()=>{if(!m)return null;switch(N){case"model":{let e=m.pending?.byModel||{};return{columns:q,groupedData:z(L(m.byModel,e,c,x),"rawModel"),storageKey:"usage-stats:expanded-models",emptyMessage:"No usage recorded yet.",renderSummaryCells:e=>(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("td",{className:"px-6 py-3 text-text-muted",children:"—"}),(0,a.jsx)("td",{className:"px-6 py-3 text-right",children:p(e.summary.requests)}),(0,a.jsx)("td",{className:"px-6 py-3 text-right text-text-muted whitespace-nowrap",children:f(e.summary.lastUsed)})]}),renderDetailCells:e=>(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("td",{className:`px-6 py-3 font-medium transition-colors ${e.pending>0?"text-primary":""}`,children:e.rawModel}),(0,a.jsx)("td",{className:"px-6 py-3",children:(0,a.jsx)(i.default,{variant:e.pending>0?"primary":"neutral",size:"sm",children:e.provider})}),(0,a.jsx)("td",{className:"px-6 py-3 text-right",children:p(e.requests)}),(0,a.jsx)("td",{className:"px-6 py-3 text-right text-text-muted whitespace-nowrap",children:f(e.lastUsed)})]})}}case"account":{let e={};return m?.pending?.byAccount&&Object.entries(m.byAccount||{}).forEach(([t,s])=>{let a=m.pending.byAccount[s.connectionId];if(a){let r=s.provider?`${s.rawModel} (${s.provider})`:s.rawModel;e[t]=a[r]||0}}),{columns:M,groupedData:z(L(m.byAccount,e,c,x),"accountName"),storageKey:"usage-stats:expanded-accounts",emptyMessage:"No account-specific usage recorded yet.",renderSummaryCells:e=>(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("td",{className:"px-6 py-3 text-text-muted",children:"—"}),(0,a.jsx)("td",{className:"px-6 py-3 text-text-muted",children:"—"}),(0,a.jsx)("td",{className:"px-6 py-3 text-right",children:p(e.summary.requests)}),(0,a.jsx)("td",{className:"px-6 py-3 text-right text-text-muted whitespace-nowrap",children:f(e.summary.lastUsed)})]}),renderDetailCells:e=>(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("td",{className:`px-6 py-3 font-medium transition-colors ${e.pending>0?"text-primary":""}`,children:e.accountName||`Account ${e.connectionId?.slice(0,8)}...`}),(0,a.jsx)("td",{className:`px-6 py-3 font-medium transition-colors ${e.pending>0?"text-primary":""}`,children:e.rawModel}),(0,a.jsx)("td",{className:"px-6 py-3",children:(0,a.jsx)(i.default,{variant:e.pending>0?"primary":"neutral",size:"sm",children:e.provider})}),(0,a.jsx)("td",{className:"px-6 py-3 text-right",children:p(e.requests)}),(0,a.jsx)("td",{className:"px-6 py-3 text-right text-text-muted whitespace-nowrap",children:f(e.lastUsed)})]})}}case"apiKey":return{columns:U,groupedData:z(L(m.byApiKey,{},c,x),"keyName"),storageKey:"usage-stats:expanded-apikeys",emptyMessage:"No API key usage recorded yet.",renderSummaryCells:e=>(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("td",{className:"px-6 py-3 text-text-muted",children:"—"}),(0,a.jsx)("td",{className:"px-6 py-3 text-text-muted",children:"—"}),(0,a.jsx)("td",{className:"px-6 py-3 text-right",children:p(e.summary.requests)}),(0,a.jsx)("td",{className:"px-6 py-3 text-right text-text-muted whitespace-nowrap",children:f(e.summary.lastUsed)})]}),renderDetailCells:e=>(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("td",{className:"px-6 py-3 font-medium",children:e.keyName}),(0,a.jsx)("td",{className:"px-6 py-3",children:e.rawModel}),(0,a.jsx)("td",{className:"px-6 py-3",children:(0,a.jsx)(i.default,{variant:"neutral",size:"sm",children:e.provider})}),(0,a.jsx)("td",{className:"px-6 py-3 text-right",children:p(e.requests)}),(0,a.jsx)("td",{className:"px-6 py-3 text-right text-text-muted whitespace-nowrap",children:f(e.lastUsed)})]})};default:return{columns:D,groupedData:z(L(m.byEndpoint,{},c,x),"endpoint"),storageKey:"usage-stats:expanded-endpoints",emptyMessage:"No endpoint usage recorded yet.",renderSummaryCells:e=>(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("td",{className:"px-6 py-3 text-text-muted",children:"—"}),(0,a.jsx)("td",{className:"px-6 py-3 text-text-muted",children:"—"}),(0,a.jsx)("td",{className:"px-6 py-3 text-right",children:p(e.summary.requests)}),(0,a.jsx)("td",{className:"px-6 py-3 text-right text-text-muted whitespace-nowrap",children:f(e.summary.lastUsed)})]}),renderDetailCells:e=>(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("td",{className:"px-6 py-3 font-medium font-mono text-sm",children:e.endpoint}),(0,a.jsx)("td",{className:"px-6 py-3",children:e.rawModel}),(0,a.jsx)("td",{className:"px-6 py-3",children:(0,a.jsx)(i.default,{variant:"neutral",size:"sm",children:e.provider})}),(0,a.jsx)("td",{className:"px-6 py-3 text-right",children:p(e.requests)}),(0,a.jsx)("td",{className:"px-6 py-3 text-right text-text-muted whitespace-nowrap",children:f(e.lastUsed)})]})}}},[m,N,c,x]);if(!m&&!b)return(0,a.jsx)("div",{className:"text-text-muted",children:"Failed to load usage statistics."});let Q=(0,a.jsx)("div",{className:"flex items-center justify-center py-12 text-text-muted",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[32px] animate-spin",children:"progress_activity"})});return(0,a.jsxs)("div",{className:"flex min-w-0 flex-col gap-6",children:[!s&&(0,a.jsxs)("div",{className:"flex w-full items-center gap-2 sm:w-auto sm:self-end",children:[(0,a.jsx)("div",{className:"grid flex-1 grid-cols-5 items-center gap-1 rounded-2xl border border-border bg-bg-subtle p-1 sm:flex sm:flex-none",children:B.map(e=>(0,a.jsx)("button",{onClick:()=>W(e.value),disabled:j,className:`rounded-md px-3 py-1 text-sm font-medium transition-colors ${E===e.value?"bg-primary text-white shadow-sm":"text-text-muted hover:bg-bg-hover hover:text-text"}`,children:e.label},e.value))}),j&&(0,a.jsx)("span",{className:"material-symbols-outlined text-[16px] text-text-muted animate-spin",children:"progress_activity"})]}),b?Q:(0,a.jsx)(u,{stats:m}),b?Q:(0,a.jsxs)("div",{className:"grid min-w-0 grid-cols-1 items-stretch gap-2 lg:grid-cols-[minmax(0,2fr)_minmax(280px,1fr)]",children:[(0,a.jsx)(w,{providers:O,activeRequests:m.activeRequests||[],lastProvider:m.recentRequests?.[0]?.provider||"",errorProvider:m.errorProvider||""}),(0,a.jsx)(R,{requests:m.recentRequests||[]})]}),b?Q:(0,a.jsx)(_,{period:E}),(0,a.jsxs)("div",{className:"flex flex-col gap-3",children:[(0,a.jsxs)("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between",children:[(0,a.jsx)("select",{value:N,onChange:e=>k(e.target.value),className:"w-full rounded-2xl border border-border bg-surface px-3 py-1.5 text-sm font-medium text-text-main focus:outline-none focus:ring-2 focus:ring-primary/50 sm:w-auto",style:{colorScheme:"auto"},children:K.map(e=>(0,a.jsx)("option",{value:e.value,children:e.label},e.value))}),(0,a.jsxs)("div",{className:"grid grid-cols-2 items-center gap-1 rounded-2xl border border-border bg-bg-subtle p-1 sm:flex",children:[(0,a.jsx)("button",{onClick:()=>S("costs"),className:`px-3 py-1 rounded-md text-sm font-medium transition-colors ${"costs"===C?"bg-primary text-white shadow-sm":"text-text-muted hover:text-text hover:bg-bg-hover"}`,children:"Costs"}),(0,a.jsx)("button",{onClick:()=>S("tokens"),className:`px-3 py-1 rounded-md text-sm font-medium transition-colors ${"tokens"===C?"bg-primary text-white shadow-sm":"text-text-muted hover:text-text hover:bg-bg-hover"}`,children:"Tokens"})]})]}),b?Q:J&&(0,a.jsx)(v,{title:"",columns:J.columns,groupedData:J.groupedData,tableType:N,sortBy:c,sortOrder:x,onToggleSort:G,viewMode:C,storageKey:J.storageKey,renderSummaryCells:J.renderSummaryCells,renderDetailCells:J.renderDetailCells,emptyMessage:J.emptyMessage})]})]})}}}]);
package/app/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "prozygent-app",
3
- "version": "0.7.13",
3
+ "version": "0.7.14",
4
4
  "description": "Prozygent web dashboard",
5
5
  "private": true,
6
6
  "scripts": {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "prozygent",
3
- "version": "0.7.13",
3
+ "version": "0.7.14",
4
4
  "description": "Prozygent - FREE AI Router & Token Saver. Never stop coding. Save 20-40% tokens with RTK + auto-fallback to FREE & cheap AI models.",
5
5
  "bin": {
6
6
  "prozygent": "./cli.js"