@sifxprime/krouter 0.5.166 → 0.5.168

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 (865) hide show
  1. package/app/.next-cli-build/BUILD_ID +1 -1
  2. package/app/.next-cli-build/app-path-routes-manifest.json +15 -15
  3. package/app/.next-cli-build/build-manifest.json +5 -5
  4. package/app/.next-cli-build/prerender-manifest.json +29 -29
  5. package/app/.next-cli-build/react-loadable-manifest.json +2 -2
  6. package/app/.next-cli-build/required-server-files.json +16 -1
  7. package/app/.next-cli-build/server/app/(dashboard)/dashboard/basic-chat/page.js +1 -1
  8. package/app/.next-cli-build/server/app/(dashboard)/dashboard/basic-chat/page_client-reference-manifest.js +1 -1
  9. package/app/.next-cli-build/server/app/(dashboard)/dashboard/cli-tools/[toolId]/page.js +2 -2
  10. package/app/.next-cli-build/server/app/(dashboard)/dashboard/cli-tools/[toolId]/page_client-reference-manifest.js +1 -1
  11. package/app/.next-cli-build/server/app/(dashboard)/dashboard/cli-tools/page.js +1 -1
  12. package/app/.next-cli-build/server/app/(dashboard)/dashboard/cli-tools/page_client-reference-manifest.js +1 -1
  13. package/app/.next-cli-build/server/app/(dashboard)/dashboard/combos/page.js +1 -1
  14. package/app/.next-cli-build/server/app/(dashboard)/dashboard/combos/page_client-reference-manifest.js +1 -1
  15. package/app/.next-cli-build/server/app/(dashboard)/dashboard/console-log/page.js +1 -1
  16. package/app/.next-cli-build/server/app/(dashboard)/dashboard/console-log/page_client-reference-manifest.js +1 -1
  17. package/app/.next-cli-build/server/app/(dashboard)/dashboard/endpoint/page.js +1 -1
  18. package/app/.next-cli-build/server/app/(dashboard)/dashboard/endpoint/page_client-reference-manifest.js +1 -1
  19. package/app/.next-cli-build/server/app/(dashboard)/dashboard/environment/page.js +1 -1
  20. package/app/.next-cli-build/server/app/(dashboard)/dashboard/environment/page_client-reference-manifest.js +1 -1
  21. package/app/.next-cli-build/server/app/(dashboard)/dashboard/media-providers/[kind]/[id]/page.js +1 -1
  22. package/app/.next-cli-build/server/app/(dashboard)/dashboard/media-providers/[kind]/[id]/page_client-reference-manifest.js +1 -1
  23. package/app/.next-cli-build/server/app/(dashboard)/dashboard/media-providers/[kind]/page.js +1 -1
  24. package/app/.next-cli-build/server/app/(dashboard)/dashboard/media-providers/[kind]/page_client-reference-manifest.js +1 -1
  25. package/app/.next-cli-build/server/app/(dashboard)/dashboard/media-providers/combo/[id]/page.js +2 -2
  26. package/app/.next-cli-build/server/app/(dashboard)/dashboard/media-providers/combo/[id]/page_client-reference-manifest.js +1 -1
  27. package/app/.next-cli-build/server/app/(dashboard)/dashboard/media-providers/web/page.js +1 -1
  28. package/app/.next-cli-build/server/app/(dashboard)/dashboard/media-providers/web/page_client-reference-manifest.js +1 -1
  29. package/app/.next-cli-build/server/app/(dashboard)/dashboard/mitm/page.js +1 -1
  30. package/app/.next-cli-build/server/app/(dashboard)/dashboard/mitm/page_client-reference-manifest.js +1 -1
  31. package/app/.next-cli-build/server/app/(dashboard)/dashboard/page.js +1 -1
  32. package/app/.next-cli-build/server/app/(dashboard)/dashboard/page_client-reference-manifest.js +1 -1
  33. package/app/.next-cli-build/server/app/(dashboard)/dashboard/presidio/page.js +1 -1
  34. package/app/.next-cli-build/server/app/(dashboard)/dashboard/presidio/page_client-reference-manifest.js +1 -1
  35. package/app/.next-cli-build/server/app/(dashboard)/dashboard/profile/page.js +1 -1
  36. package/app/.next-cli-build/server/app/(dashboard)/dashboard/profile/page_client-reference-manifest.js +1 -1
  37. package/app/.next-cli-build/server/app/(dashboard)/dashboard/providers/[id]/page.js +2 -2
  38. package/app/.next-cli-build/server/app/(dashboard)/dashboard/providers/[id]/page_client-reference-manifest.js +1 -1
  39. package/app/.next-cli-build/server/app/(dashboard)/dashboard/providers/new/page.js +1 -1
  40. package/app/.next-cli-build/server/app/(dashboard)/dashboard/providers/new/page_client-reference-manifest.js +1 -1
  41. package/app/.next-cli-build/server/app/(dashboard)/dashboard/providers/page.js +1 -1
  42. package/app/.next-cli-build/server/app/(dashboard)/dashboard/providers/page_client-reference-manifest.js +1 -1
  43. package/app/.next-cli-build/server/app/(dashboard)/dashboard/proxy-pools/page.js +1 -1
  44. package/app/.next-cli-build/server/app/(dashboard)/dashboard/proxy-pools/page_client-reference-manifest.js +1 -1
  45. package/app/.next-cli-build/server/app/(dashboard)/dashboard/pxpipe/page.js +1 -1
  46. package/app/.next-cli-build/server/app/(dashboard)/dashboard/pxpipe/page_client-reference-manifest.js +1 -1
  47. package/app/.next-cli-build/server/app/(dashboard)/dashboard/quota/page.js +1 -1
  48. package/app/.next-cli-build/server/app/(dashboard)/dashboard/quota/page_client-reference-manifest.js +1 -1
  49. package/app/.next-cli-build/server/app/(dashboard)/dashboard/skills/page.js +1 -1
  50. package/app/.next-cli-build/server/app/(dashboard)/dashboard/skills/page_client-reference-manifest.js +1 -1
  51. package/app/.next-cli-build/server/app/(dashboard)/dashboard/token-saver/page.js +1 -1
  52. package/app/.next-cli-build/server/app/(dashboard)/dashboard/token-saver/page_client-reference-manifest.js +1 -1
  53. package/app/.next-cli-build/server/app/(dashboard)/dashboard/translator/page.js +1 -1
  54. package/app/.next-cli-build/server/app/(dashboard)/dashboard/translator/page_client-reference-manifest.js +1 -1
  55. package/app/.next-cli-build/server/app/(dashboard)/dashboard/usage/page.js +1 -1
  56. package/app/.next-cli-build/server/app/(dashboard)/dashboard/usage/page_client-reference-manifest.js +1 -1
  57. package/app/.next-cli-build/server/app/_global-error/page.js +1 -1
  58. package/app/.next-cli-build/server/app/_global-error/page_client-reference-manifest.js +1 -1
  59. package/app/.next-cli-build/server/app/_global-error.html +1 -1
  60. package/app/.next-cli-build/server/app/_global-error.rsc +15 -11
  61. package/app/.next-cli-build/server/app/_global-error.segments/_full.segment.rsc +15 -11
  62. package/app/.next-cli-build/server/app/_global-error.segments/_global-error/__PAGE__.segment.rsc +20 -16
  63. package/app/.next-cli-build/server/app/_global-error.segments/_tree.segment.rsc +3 -1
  64. package/app/.next-cli-build/server/app/_not-found/page.js +1 -1
  65. package/app/.next-cli-build/server/app/_not-found/page_client-reference-manifest.js +1 -1
  66. package/app/.next-cli-build/server/app/_not-found.html +1 -1
  67. package/app/.next-cli-build/server/app/_not-found.rsc +26 -16
  68. package/app/.next-cli-build/server/app/_not-found.segments/_full.segment.rsc +26 -16
  69. package/app/.next-cli-build/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +32 -22
  70. package/app/.next-cli-build/server/app/_not-found.segments/_tree.segment.rsc +3 -1
  71. package/app/.next-cli-build/server/app/api/auth/login/route.js +1 -1
  72. package/app/.next-cli-build/server/app/api/auth/logout/route.js +1 -1
  73. package/app/.next-cli-build/server/app/api/auth/oidc/callback/route.js +1 -1
  74. package/app/.next-cli-build/server/app/api/auth/oidc/start/route.js +1 -1
  75. package/app/.next-cli-build/server/app/api/auth/oidc/test/route.js +1 -1
  76. package/app/.next-cli-build/server/app/api/auth/reset-password/route.js +1 -1
  77. package/app/.next-cli-build/server/app/api/auth/status/route.js +1 -1
  78. package/app/.next-cli-build/server/app/api/cache/route.js +1 -1
  79. package/app/.next-cli-build/server/app/api/cli-tools/all-statuses/route.js +6 -6
  80. package/app/.next-cli-build/server/app/api/cli-tools/antigravity-mitm/alias/route.js +2 -2
  81. package/app/.next-cli-build/server/app/api/cli-tools/antigravity-mitm/route.js +1 -1
  82. package/app/.next-cli-build/server/app/api/cli-tools/claude-settings/route.js +2 -2
  83. package/app/.next-cli-build/server/app/api/cli-tools/cline-settings/route.js +3 -3
  84. package/app/.next-cli-build/server/app/api/cli-tools/codex-settings/route.js +1 -1
  85. package/app/.next-cli-build/server/app/api/cli-tools/copilot-settings/route.js +2 -2
  86. package/app/.next-cli-build/server/app/api/cli-tools/cowork-mcp-registry/route.js +2 -2
  87. package/app/.next-cli-build/server/app/api/cli-tools/cowork-mcp-tools/route.js +2 -2
  88. package/app/.next-cli-build/server/app/api/cli-tools/cowork-settings/route.js +1 -1
  89. package/app/.next-cli-build/server/app/api/cli-tools/deepseek-tui-settings/route.js +3 -3
  90. package/app/.next-cli-build/server/app/api/cli-tools/droid-settings/route.js +2 -2
  91. package/app/.next-cli-build/server/app/api/cli-tools/hermes-settings/route.js +4 -4
  92. package/app/.next-cli-build/server/app/api/cli-tools/jcode-settings/route.js +3 -3
  93. package/app/.next-cli-build/server/app/api/cli-tools/kilo-settings/route.js +2 -2
  94. package/app/.next-cli-build/server/app/api/cli-tools/openclaw-settings/route.js +2 -2
  95. package/app/.next-cli-build/server/app/api/cli-tools/opencode-settings/route.js +2 -2
  96. package/app/.next-cli-build/server/app/api/combos/[id]/route.js +1 -1
  97. package/app/.next-cli-build/server/app/api/combos/route.js +1 -1
  98. package/app/.next-cli-build/server/app/api/headroom/extras/route.js +1 -1
  99. package/app/.next-cli-build/server/app/api/headroom/proxy/[...path]/route.js +1 -1
  100. package/app/.next-cli-build/server/app/api/headroom/restart/route.js +1 -1
  101. package/app/.next-cli-build/server/app/api/headroom/start/route.js +1 -1
  102. package/app/.next-cli-build/server/app/api/headroom/status/route.js +1 -1
  103. package/app/.next-cli-build/server/app/api/headroom/stop/route.js +1 -1
  104. package/app/.next-cli-build/server/app/api/health/route.js +1 -1
  105. package/app/.next-cli-build/server/app/api/import/route.js +1 -1
  106. package/app/.next-cli-build/server/app/api/init/route.js +1 -1
  107. package/app/.next-cli-build/server/app/api/keys/[id]/route.js +1 -1
  108. package/app/.next-cli-build/server/app/api/keys/route.js +1 -1
  109. package/app/.next-cli-build/server/app/api/locale/route.js +1 -1
  110. package/app/.next-cli-build/server/app/api/mcp/[plugin]/message/route.js +1 -1
  111. package/app/.next-cli-build/server/app/api/mcp/[plugin]/sse/route.js +1 -1
  112. package/app/.next-cli-build/server/app/api/media-providers/tts/deepgram/voices/route.js +1 -1
  113. package/app/.next-cli-build/server/app/api/media-providers/tts/elevenlabs/voices/route.js +1 -1
  114. package/app/.next-cli-build/server/app/api/media-providers/tts/inworld/voices/route.js +1 -1
  115. package/app/.next-cli-build/server/app/api/media-providers/tts/minimax/voices/route.js +1 -1
  116. package/app/.next-cli-build/server/app/api/media-providers/tts/voices/route.js +1 -1
  117. package/app/.next-cli-build/server/app/api/mitm/cert/route.js +1 -1
  118. package/app/.next-cli-build/server/app/api/models/alias/route.js +1 -1
  119. package/app/.next-cli-build/server/app/api/models/availability/route.js +1 -1
  120. package/app/.next-cli-build/server/app/api/models/custom/route.js +1 -1
  121. package/app/.next-cli-build/server/app/api/models/disabled/route.js +1 -1
  122. package/app/.next-cli-build/server/app/api/models/live/route.js +1 -1
  123. package/app/.next-cli-build/server/app/api/models/live-by-connection/route.js +1 -1
  124. package/app/.next-cli-build/server/app/api/models/preview/route.js +1 -1
  125. package/app/.next-cli-build/server/app/api/models/route.js +1 -1
  126. package/app/.next-cli-build/server/app/api/models/test/route.js +1 -1
  127. package/app/.next-cli-build/server/app/api/oauth/[provider]/[action]/route.js +1 -1
  128. package/app/.next-cli-build/server/app/api/oauth/codex/bulk-import/route.js +1 -1
  129. package/app/.next-cli-build/server/app/api/oauth/codex/import-token/route.js +1 -1
  130. package/app/.next-cli-build/server/app/api/oauth/cursor/auto-import/route.js +1 -1
  131. package/app/.next-cli-build/server/app/api/oauth/cursor/import/route.js +1 -1
  132. package/app/.next-cli-build/server/app/api/oauth/gitlab/pat/route.js +1 -1
  133. package/app/.next-cli-build/server/app/api/oauth/iflow/cookie/route.js +1 -1
  134. package/app/.next-cli-build/server/app/api/oauth/kiro/api-key/route.js +1 -1
  135. package/app/.next-cli-build/server/app/api/oauth/kiro/auto-import/route.js +1 -1
  136. package/app/.next-cli-build/server/app/api/oauth/kiro/import/route.js +1 -1
  137. package/app/.next-cli-build/server/app/api/oauth/kiro/social-authorize/route.js +1 -1
  138. package/app/.next-cli-build/server/app/api/oauth/kiro/social-exchange/route.js +1 -1
  139. package/app/.next-cli-build/server/app/api/pricing/route.js +1 -1
  140. package/app/.next-cli-build/server/app/api/provider-nodes/[id]/route.js +1 -1
  141. package/app/.next-cli-build/server/app/api/provider-nodes/route.js +1 -1
  142. package/app/.next-cli-build/server/app/api/provider-nodes/validate/route.js +1 -1
  143. package/app/.next-cli-build/server/app/api/providers/[id]/models/route.js +2 -2
  144. package/app/.next-cli-build/server/app/api/providers/[id]/route.js +1 -1
  145. package/app/.next-cli-build/server/app/api/providers/[id]/test/route.js +1 -1
  146. package/app/.next-cli-build/server/app/api/providers/[id]/test-models/route.js +1 -1
  147. package/app/.next-cli-build/server/app/api/providers/client/route.js +1 -1
  148. package/app/.next-cli-build/server/app/api/providers/health/route.js +1 -1
  149. package/app/.next-cli-build/server/app/api/providers/kilo/free-models/route.js +1 -1
  150. package/app/.next-cli-build/server/app/api/providers/route.js +1 -1
  151. package/app/.next-cli-build/server/app/api/providers/suggested-models/route.js +1 -1
  152. package/app/.next-cli-build/server/app/api/providers/test-batch/route.js +1 -1
  153. package/app/.next-cli-build/server/app/api/providers/validate/route.js +1 -1
  154. package/app/.next-cli-build/server/app/api/providers/zenith/log/route.js +1 -1
  155. package/app/.next-cli-build/server/app/api/providers/zenith/route.js +1 -1
  156. package/app/.next-cli-build/server/app/api/proxy-pools/[id]/route.js +1 -1
  157. package/app/.next-cli-build/server/app/api/proxy-pools/[id]/test/route.js +1 -1
  158. package/app/.next-cli-build/server/app/api/proxy-pools/cloudflare-deploy/route.js +1 -1
  159. package/app/.next-cli-build/server/app/api/proxy-pools/deno-deploy/route.js +2 -2
  160. package/app/.next-cli-build/server/app/api/proxy-pools/route.js +1 -1
  161. package/app/.next-cli-build/server/app/api/proxy-pools/vercel-deploy/route.js +2 -2
  162. package/app/.next-cli-build/server/app/api/pxpipe/health/route.js +2 -2
  163. package/app/.next-cli-build/server/app/api/pxpipe/install/route.js +2 -2
  164. package/app/.next-cli-build/server/app/api/pxpipe/restart/route.js +2 -2
  165. package/app/.next-cli-build/server/app/api/pxpipe/start/route.js +2 -2
  166. package/app/.next-cli-build/server/app/api/pxpipe/stats/route.js +2 -2
  167. package/app/.next-cli-build/server/app/api/pxpipe/status/route.js +2 -2
  168. package/app/.next-cli-build/server/app/api/pxpipe/stop/route.js +2 -2
  169. package/app/.next-cli-build/server/app/api/settings/database/route.js +1 -1
  170. package/app/.next-cli-build/server/app/api/settings/environment/route.js +1 -1
  171. package/app/.next-cli-build/server/app/api/settings/presidio/route.js +3 -3
  172. package/app/.next-cli-build/server/app/api/settings/proxy-test/route.js +1 -1
  173. package/app/.next-cli-build/server/app/api/settings/require-login/route.js +1 -1
  174. package/app/.next-cli-build/server/app/api/settings/route.js +1 -1
  175. package/app/.next-cli-build/server/app/api/shutdown/route.js +1 -1
  176. package/app/.next-cli-build/server/app/api/tags/route.js +1 -1
  177. package/app/.next-cli-build/server/app/api/translator/console-logs/route.js +1 -1
  178. package/app/.next-cli-build/server/app/api/translator/console-logs/stream/route.js +2 -2
  179. package/app/.next-cli-build/server/app/api/translator/load/route.js +1 -1
  180. package/app/.next-cli-build/server/app/api/translator/save/route.js +1 -1
  181. package/app/.next-cli-build/server/app/api/translator/send/route.js +1 -1
  182. package/app/.next-cli-build/server/app/api/translator/translate/route.js +1 -1
  183. package/app/.next-cli-build/server/app/api/tunnel/disable/route.js +1 -1
  184. package/app/.next-cli-build/server/app/api/tunnel/enable/route.js +1 -1
  185. package/app/.next-cli-build/server/app/api/tunnel/status/route.js +1 -1
  186. package/app/.next-cli-build/server/app/api/tunnel/tailscale-check/route.js +1 -1
  187. package/app/.next-cli-build/server/app/api/tunnel/tailscale-disable/route.js +1 -1
  188. package/app/.next-cli-build/server/app/api/tunnel/tailscale-enable/route.js +1 -1
  189. package/app/.next-cli-build/server/app/api/tunnel/tailscale-install/route.js +2 -2
  190. package/app/.next-cli-build/server/app/api/usage/[connectionId]/route.js +1 -1
  191. package/app/.next-cli-build/server/app/api/usage/chart/route.js +1 -1
  192. package/app/.next-cli-build/server/app/api/usage/history/route.js +1 -1
  193. package/app/.next-cli-build/server/app/api/usage/providers/route.js +1 -1
  194. package/app/.next-cli-build/server/app/api/usage/request-details/route.js +1 -1
  195. package/app/.next-cli-build/server/app/api/usage/request-logs/route.js +1 -1
  196. package/app/.next-cli-build/server/app/api/usage/stats/route.js +1 -1
  197. package/app/.next-cli-build/server/app/api/usage/stream/route.js +1 -1
  198. package/app/.next-cli-build/server/app/api/v1/api/chat/route.js +1 -1
  199. package/app/.next-cli-build/server/app/api/v1/audio/speech/route.js +1 -1
  200. package/app/.next-cli-build/server/app/api/v1/audio/transcriptions/route.js +2 -2
  201. package/app/.next-cli-build/server/app/api/v1/audio/voices/route.js +1 -1
  202. package/app/.next-cli-build/server/app/api/v1/chat/completions/route.js +1 -1
  203. package/app/.next-cli-build/server/app/api/v1/embeddings/route.js +1 -1
  204. package/app/.next-cli-build/server/app/api/v1/images/generations/route.js +1 -1
  205. package/app/.next-cli-build/server/app/api/v1/messages/count_tokens/route.js +1 -1
  206. package/app/.next-cli-build/server/app/api/v1/messages/route.js +1 -1
  207. package/app/.next-cli-build/server/app/api/v1/models/[...model]/route.js +1 -1
  208. package/app/.next-cli-build/server/app/api/v1/models/info/route.js +1 -1
  209. package/app/.next-cli-build/server/app/api/v1/models/route.js +1 -1
  210. package/app/.next-cli-build/server/app/api/v1/responses/compact/route.js +1 -1
  211. package/app/.next-cli-build/server/app/api/v1/responses/route.js +1 -1
  212. package/app/.next-cli-build/server/app/api/v1/route.js +1 -1
  213. package/app/.next-cli-build/server/app/api/v1/search/route.js +2 -2
  214. package/app/.next-cli-build/server/app/api/v1/videos/[id]/route.js +1 -1
  215. package/app/.next-cli-build/server/app/api/v1/videos/edits/route.js +1 -1
  216. package/app/.next-cli-build/server/app/api/v1/videos/extensions/route.js +1 -1
  217. package/app/.next-cli-build/server/app/api/v1/videos/generations/route.js +1 -1
  218. package/app/.next-cli-build/server/app/api/v1/web/fetch/route.js +1 -1
  219. package/app/.next-cli-build/server/app/api/v1beta/models/[...path]/route.js +1 -1
  220. package/app/.next-cli-build/server/app/api/v1beta/models/route.js +1 -1
  221. package/app/.next-cli-build/server/app/api/version/route.js +1 -1
  222. package/app/.next-cli-build/server/app/api/version/shutdown/route.js +1 -1
  223. package/app/.next-cli-build/server/app/api/version/update/route.js +1 -1
  224. package/app/.next-cli-build/server/app/callback/page.js +1 -1
  225. package/app/.next-cli-build/server/app/callback/page_client-reference-manifest.js +1 -1
  226. package/app/.next-cli-build/server/app/callback.html +1 -1
  227. package/app/.next-cli-build/server/app/callback.rsc +29 -18
  228. package/app/.next-cli-build/server/app/callback.segments/_full.segment.rsc +29 -18
  229. package/app/.next-cli-build/server/app/callback.segments/_tree.segment.rsc +3 -1
  230. package/app/.next-cli-build/server/app/callback.segments/callback/__PAGE__.segment.rsc +37 -26
  231. package/app/.next-cli-build/server/app/dashboard/basic-chat.html +1 -1
  232. package/app/.next-cli-build/server/app/dashboard/basic-chat.rsc +31 -18
  233. package/app/.next-cli-build/server/app/dashboard/basic-chat.segments/!KGRhc2hib2FyZCk/dashboard/basic-chat/__PAGE__.segment.rsc +38 -26
  234. package/app/.next-cli-build/server/app/dashboard/basic-chat.segments/_full.segment.rsc +31 -18
  235. package/app/.next-cli-build/server/app/dashboard/basic-chat.segments/_tree.segment.rsc +5 -1
  236. package/app/.next-cli-build/server/app/dashboard/cli-tools.html +1 -1
  237. package/app/.next-cli-build/server/app/dashboard/cli-tools.rsc +34 -19
  238. package/app/.next-cli-build/server/app/dashboard/cli-tools.segments/!KGRhc2hib2FyZCk/dashboard/cli-tools/__PAGE__.segment.rsc +40 -27
  239. package/app/.next-cli-build/server/app/dashboard/cli-tools.segments/_full.segment.rsc +34 -19
  240. package/app/.next-cli-build/server/app/dashboard/cli-tools.segments/_tree.segment.rsc +5 -1
  241. package/app/.next-cli-build/server/app/dashboard/combos.html +1 -1
  242. package/app/.next-cli-build/server/app/dashboard/combos.rsc +35 -21
  243. package/app/.next-cli-build/server/app/dashboard/combos.segments/!KGRhc2hib2FyZCk/dashboard/combos/__PAGE__.segment.rsc +42 -30
  244. package/app/.next-cli-build/server/app/dashboard/combos.segments/_full.segment.rsc +35 -21
  245. package/app/.next-cli-build/server/app/dashboard/combos.segments/_tree.segment.rsc +5 -1
  246. package/app/.next-cli-build/server/app/dashboard/endpoint.html +1 -1
  247. package/app/.next-cli-build/server/app/dashboard/endpoint.rsc +33 -19
  248. package/app/.next-cli-build/server/app/dashboard/endpoint.segments/!KGRhc2hib2FyZCk/dashboard/endpoint/__PAGE__.segment.rsc +39 -27
  249. package/app/.next-cli-build/server/app/dashboard/endpoint.segments/_full.segment.rsc +33 -19
  250. package/app/.next-cli-build/server/app/dashboard/endpoint.segments/_tree.segment.rsc +5 -1
  251. package/app/.next-cli-build/server/app/dashboard/environment.html +1 -1
  252. package/app/.next-cli-build/server/app/dashboard/environment.rsc +34 -21
  253. package/app/.next-cli-build/server/app/dashboard/environment.segments/!KGRhc2hib2FyZCk/dashboard/environment/__PAGE__.segment.rsc +41 -30
  254. package/app/.next-cli-build/server/app/dashboard/environment.segments/_full.segment.rsc +34 -21
  255. package/app/.next-cli-build/server/app/dashboard/environment.segments/_tree.segment.rsc +5 -1
  256. package/app/.next-cli-build/server/app/dashboard/media-providers/web.html +1 -1
  257. package/app/.next-cli-build/server/app/dashboard/media-providers/web.rsc +36 -23
  258. package/app/.next-cli-build/server/app/dashboard/media-providers/web.segments/!KGRhc2hib2FyZCk/dashboard/media-providers/web/__PAGE__.segment.rsc +44 -32
  259. package/app/.next-cli-build/server/app/dashboard/media-providers/web.segments/_full.segment.rsc +36 -23
  260. package/app/.next-cli-build/server/app/dashboard/media-providers/web.segments/_tree.segment.rsc +6 -1
  261. package/app/.next-cli-build/server/app/dashboard/mitm.html +1 -1
  262. package/app/.next-cli-build/server/app/dashboard/mitm.rsc +33 -18
  263. package/app/.next-cli-build/server/app/dashboard/mitm.segments/!KGRhc2hib2FyZCk/dashboard/mitm/__PAGE__.segment.rsc +40 -26
  264. package/app/.next-cli-build/server/app/dashboard/mitm.segments/_full.segment.rsc +33 -18
  265. package/app/.next-cli-build/server/app/dashboard/mitm.segments/_tree.segment.rsc +5 -1
  266. package/app/.next-cli-build/server/app/dashboard/presidio.html +1 -1
  267. package/app/.next-cli-build/server/app/dashboard/presidio.rsc +34 -21
  268. package/app/.next-cli-build/server/app/dashboard/presidio.segments/!KGRhc2hib2FyZCk/dashboard/presidio/__PAGE__.segment.rsc +41 -30
  269. package/app/.next-cli-build/server/app/dashboard/presidio.segments/_full.segment.rsc +34 -21
  270. package/app/.next-cli-build/server/app/dashboard/presidio.segments/_tree.segment.rsc +5 -1
  271. package/app/.next-cli-build/server/app/dashboard/profile.html +1 -1
  272. package/app/.next-cli-build/server/app/dashboard/profile.rsc +34 -21
  273. package/app/.next-cli-build/server/app/dashboard/profile.segments/!KGRhc2hib2FyZCk/dashboard/profile/__PAGE__.segment.rsc +41 -30
  274. package/app/.next-cli-build/server/app/dashboard/profile.segments/_full.segment.rsc +34 -21
  275. package/app/.next-cli-build/server/app/dashboard/profile.segments/_tree.segment.rsc +5 -1
  276. package/app/.next-cli-build/server/app/dashboard/providers/new.html +1 -1
  277. package/app/.next-cli-build/server/app/dashboard/providers/new.rsc +35 -23
  278. package/app/.next-cli-build/server/app/dashboard/providers/new.segments/!KGRhc2hib2FyZCk/dashboard/providers/new/__PAGE__.segment.rsc +44 -32
  279. package/app/.next-cli-build/server/app/dashboard/providers/new.segments/_full.segment.rsc +35 -23
  280. package/app/.next-cli-build/server/app/dashboard/providers/new.segments/_tree.segment.rsc +6 -1
  281. package/app/.next-cli-build/server/app/dashboard/providers.html +1 -1
  282. package/app/.next-cli-build/server/app/dashboard/providers.rsc +34 -21
  283. package/app/.next-cli-build/server/app/dashboard/providers.segments/!KGRhc2hib2FyZCk/dashboard/providers/__PAGE__.segment.rsc +41 -30
  284. package/app/.next-cli-build/server/app/dashboard/providers.segments/_full.segment.rsc +34 -21
  285. package/app/.next-cli-build/server/app/dashboard/providers.segments/_tree.segment.rsc +5 -1
  286. package/app/.next-cli-build/server/app/dashboard/proxy-pools.html +1 -1
  287. package/app/.next-cli-build/server/app/dashboard/proxy-pools.rsc +34 -21
  288. package/app/.next-cli-build/server/app/dashboard/proxy-pools.segments/!KGRhc2hib2FyZCk/dashboard/proxy-pools/__PAGE__.segment.rsc +41 -30
  289. package/app/.next-cli-build/server/app/dashboard/proxy-pools.segments/_full.segment.rsc +34 -21
  290. package/app/.next-cli-build/server/app/dashboard/proxy-pools.segments/_tree.segment.rsc +5 -1
  291. package/app/.next-cli-build/server/app/dashboard/pxpipe.html +1 -1
  292. package/app/.next-cli-build/server/app/dashboard/pxpipe.rsc +31 -18
  293. package/app/.next-cli-build/server/app/dashboard/pxpipe.segments/!KGRhc2hib2FyZCk/dashboard/pxpipe/__PAGE__.segment.rsc +38 -26
  294. package/app/.next-cli-build/server/app/dashboard/pxpipe.segments/_full.segment.rsc +31 -18
  295. package/app/.next-cli-build/server/app/dashboard/pxpipe.segments/_tree.segment.rsc +5 -1
  296. package/app/.next-cli-build/server/app/dashboard/quota.html +2 -2
  297. package/app/.next-cli-build/server/app/dashboard/quota.rsc +32 -19
  298. package/app/.next-cli-build/server/app/dashboard/quota.segments/!KGRhc2hib2FyZCk/dashboard/quota/__PAGE__.segment.rsc +39 -28
  299. package/app/.next-cli-build/server/app/dashboard/quota.segments/_full.segment.rsc +32 -19
  300. package/app/.next-cli-build/server/app/dashboard/quota.segments/_tree.segment.rsc +5 -1
  301. package/app/.next-cli-build/server/app/dashboard/settings/pricing/page.js +1 -1
  302. package/app/.next-cli-build/server/app/dashboard/settings/pricing/page_client-reference-manifest.js +1 -1
  303. package/app/.next-cli-build/server/app/dashboard/settings/pricing.html +1 -1
  304. package/app/.next-cli-build/server/app/dashboard/settings/pricing.rsc +31 -18
  305. package/app/.next-cli-build/server/app/dashboard/settings/pricing.segments/_full.segment.rsc +31 -18
  306. package/app/.next-cli-build/server/app/dashboard/settings/pricing.segments/_tree.segment.rsc +5 -1
  307. package/app/.next-cli-build/server/app/dashboard/settings/pricing.segments/dashboard/settings/pricing/__PAGE__.segment.rsc +40 -27
  308. package/app/.next-cli-build/server/app/dashboard/skills.html +1 -1
  309. package/app/.next-cli-build/server/app/dashboard/skills.rsc +34 -21
  310. package/app/.next-cli-build/server/app/dashboard/skills.segments/!KGRhc2hib2FyZCk/dashboard/skills/__PAGE__.segment.rsc +41 -30
  311. package/app/.next-cli-build/server/app/dashboard/skills.segments/_full.segment.rsc +34 -21
  312. package/app/.next-cli-build/server/app/dashboard/skills.segments/_tree.segment.rsc +5 -1
  313. package/app/.next-cli-build/server/app/dashboard/token-saver.html +1 -1
  314. package/app/.next-cli-build/server/app/dashboard/token-saver.rsc +31 -18
  315. package/app/.next-cli-build/server/app/dashboard/token-saver.segments/!KGRhc2hib2FyZCk/dashboard/token-saver/__PAGE__.segment.rsc +38 -26
  316. package/app/.next-cli-build/server/app/dashboard/token-saver.segments/_full.segment.rsc +31 -18
  317. package/app/.next-cli-build/server/app/dashboard/token-saver.segments/_tree.segment.rsc +5 -1
  318. package/app/.next-cli-build/server/app/dashboard/translator.html +1 -1
  319. package/app/.next-cli-build/server/app/dashboard/translator.rsc +34 -21
  320. package/app/.next-cli-build/server/app/dashboard/translator.segments/!KGRhc2hib2FyZCk/dashboard/translator/__PAGE__.segment.rsc +41 -30
  321. package/app/.next-cli-build/server/app/dashboard/translator.segments/_full.segment.rsc +34 -21
  322. package/app/.next-cli-build/server/app/dashboard/translator.segments/_tree.segment.rsc +5 -1
  323. package/app/.next-cli-build/server/app/dashboard/usage.html +1 -1
  324. package/app/.next-cli-build/server/app/dashboard/usage.rsc +34 -21
  325. package/app/.next-cli-build/server/app/dashboard/usage.segments/!KGRhc2hib2FyZCk/dashboard/usage/__PAGE__.segment.rsc +41 -30
  326. package/app/.next-cli-build/server/app/dashboard/usage.segments/_full.segment.rsc +34 -21
  327. package/app/.next-cli-build/server/app/dashboard/usage.segments/_tree.segment.rsc +5 -1
  328. package/app/.next-cli-build/server/app/dashboard.html +1 -1
  329. package/app/.next-cli-build/server/app/dashboard.rsc +32 -19
  330. package/app/.next-cli-build/server/app/dashboard.segments/!KGRhc2hib2FyZCk/dashboard/__PAGE__.segment.rsc +38 -25
  331. package/app/.next-cli-build/server/app/dashboard.segments/_full.segment.rsc +32 -19
  332. package/app/.next-cli-build/server/app/dashboard.segments/_tree.segment.rsc +4 -1
  333. package/app/.next-cli-build/server/app/favicon.ico/route.js +1 -1
  334. package/app/.next-cli-build/server/app/index.html +1 -1
  335. package/app/.next-cli-build/server/app/index.rsc +24 -15
  336. package/app/.next-cli-build/server/app/index.segments/__PAGE__.segment.rsc +29 -20
  337. package/app/.next-cli-build/server/app/index.segments/_full.segment.rsc +24 -15
  338. package/app/.next-cli-build/server/app/index.segments/_tree.segment.rsc +2 -1
  339. package/app/.next-cli-build/server/app/landing/page.js +1 -1
  340. package/app/.next-cli-build/server/app/landing/page_client-reference-manifest.js +1 -1
  341. package/app/.next-cli-build/server/app/landing.html +1 -1
  342. package/app/.next-cli-build/server/app/landing.rsc +30 -18
  343. package/app/.next-cli-build/server/app/landing.segments/_full.segment.rsc +30 -18
  344. package/app/.next-cli-build/server/app/landing.segments/_tree.segment.rsc +3 -1
  345. package/app/.next-cli-build/server/app/landing.segments/landing/__PAGE__.segment.rsc +38 -26
  346. package/app/.next-cli-build/server/app/login/page.js +1 -1
  347. package/app/.next-cli-build/server/app/login/page_client-reference-manifest.js +1 -1
  348. package/app/.next-cli-build/server/app/login.html +1 -1
  349. package/app/.next-cli-build/server/app/login.rsc +29 -18
  350. package/app/.next-cli-build/server/app/login.segments/_full.segment.rsc +29 -18
  351. package/app/.next-cli-build/server/app/login.segments/_tree.segment.rsc +3 -1
  352. package/app/.next-cli-build/server/app/login.segments/login/__PAGE__.segment.rsc +37 -26
  353. package/app/.next-cli-build/server/app/manifest.webmanifest/route.js +2 -2
  354. package/app/.next-cli-build/server/app/page.js +1 -1
  355. package/app/.next-cli-build/server/app/page_client-reference-manifest.js +1 -1
  356. package/app/.next-cli-build/server/app-paths-manifest.json +15 -15
  357. package/app/.next-cli-build/server/chunks/1220.js +3 -3
  358. package/app/.next-cli-build/server/chunks/1344.js +2 -2
  359. package/app/.next-cli-build/server/chunks/1350.js +1 -1
  360. package/app/.next-cli-build/server/chunks/1450.js +1 -1
  361. package/app/.next-cli-build/server/chunks/1738.js +1 -1
  362. package/app/.next-cli-build/server/chunks/1813.js +23 -1
  363. package/app/.next-cli-build/server/chunks/2430.js +215 -31
  364. package/app/.next-cli-build/server/chunks/2722.js +6 -6
  365. package/app/.next-cli-build/server/chunks/2750.js +1 -1
  366. package/app/.next-cli-build/server/chunks/2970.js +163 -23
  367. package/app/.next-cli-build/server/chunks/3120.js +2 -2
  368. package/app/.next-cli-build/server/chunks/369.js +5 -5
  369. package/app/.next-cli-build/server/chunks/412.js +1 -1
  370. package/app/.next-cli-build/server/chunks/4161.js +1 -1
  371. package/app/.next-cli-build/server/chunks/4177.js +1 -1
  372. package/app/.next-cli-build/server/chunks/4306.js +1 -1
  373. package/app/.next-cli-build/server/chunks/4315.js +1 -1
  374. package/app/.next-cli-build/server/chunks/4380.js +1 -1
  375. package/app/.next-cli-build/server/chunks/4730.js +2 -2
  376. package/app/.next-cli-build/server/chunks/4884.js +4 -4
  377. package/app/.next-cli-build/server/chunks/523.js +1 -1
  378. package/app/.next-cli-build/server/chunks/5330.js +4 -4
  379. package/app/.next-cli-build/server/chunks/5433.js +1 -1
  380. package/app/.next-cli-build/server/chunks/5470.js +3 -3
  381. package/app/.next-cli-build/server/chunks/5573.js +1 -1
  382. package/app/.next-cli-build/server/chunks/5718.js +1 -1
  383. package/app/.next-cli-build/server/chunks/595.js +1 -1
  384. package/app/.next-cli-build/server/chunks/6182.js +2 -2
  385. package/app/.next-cli-build/server/chunks/7153.js +1 -1
  386. package/app/.next-cli-build/server/chunks/7774.js +13 -13
  387. package/app/.next-cli-build/server/chunks/7833.js +1 -1
  388. package/app/.next-cli-build/server/chunks/8238.js +1 -1
  389. package/app/.next-cli-build/server/chunks/8895.js +1 -1
  390. package/app/.next-cli-build/server/chunks/8962.js +1 -1
  391. package/app/.next-cli-build/server/chunks/9055.js +2 -2
  392. package/app/.next-cli-build/server/chunks/9958.js +1 -1
  393. package/app/.next-cli-build/server/middleware-build-manifest.js +1 -1
  394. package/app/.next-cli-build/server/middleware-react-loadable-manifest.js +1 -1
  395. package/app/.next-cli-build/server/middleware.js +186 -24
  396. package/app/.next-cli-build/server/pages/404.html +1 -1
  397. package/app/.next-cli-build/server/pages/500.html +1 -1
  398. package/app/.next-cli-build/server/preview-props.json +5 -0
  399. package/app/.next-cli-build/server/server-reference-manifest.js +1 -1
  400. package/app/.next-cli-build/server/server-reference-manifest.json +1 -1
  401. package/app/.next-cli-build/static/chunks/1321-91a272a5139df5f2.js +1 -0
  402. package/app/.next-cli-build/static/chunks/3794-39f2d5bb0d40336b.js +52 -0
  403. package/app/.next-cli-build/static/chunks/4bd1b696-8cd12253b448cc13.js +1 -0
  404. package/app/.next-cli-build/static/chunks/5353-0085e26d68aca1f0.js +1 -0
  405. package/app/.next-cli-build/static/chunks/{5497-1af4fbf829c885c4.js → 5497-ff8c2e5da835ea40.js} +1 -1
  406. package/app/.next-cli-build/static/chunks/5772-9e7c7f235304c527.js +3 -0
  407. package/app/.next-cli-build/static/chunks/6069-31c2febe26d36d92.js +73 -0
  408. package/app/.next-cli-build/static/chunks/{6357.aa5754cdb37976a7.js → 6357.5f2532e76bf2cc51.js} +1 -1
  409. package/app/.next-cli-build/static/chunks/7504-5249aa88b6205df1.js +64 -0
  410. package/app/.next-cli-build/static/chunks/8202.69dace5daa86686d.js +1 -0
  411. package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/basic-chat/page-8a99890727166f8a.js +1 -0
  412. package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/cli-tools/page-ce0c6b650a822e25.js +1 -0
  413. package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/providers/[id]/page-589743e8ea1d9673.js +11 -0
  414. package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/translator/page-eacf2780757238ff.js +1 -0
  415. package/app/.next-cli-build/static/chunks/main-00cd8c01f6f6e461.js +5 -0
  416. package/app/.next-cli-build/static/chunks/{webpack-53609978799ebbca.js → webpack-cc312041cf710f25.js} +1 -1
  417. package/app/cli/package.json +1 -1
  418. package/app/node_modules/@next/env/package.json +1 -1
  419. package/app/node_modules/nanoid/package.json +3 -3
  420. package/app/node_modules/next/dist/build/analysis/get-page-static-info.js +58 -76
  421. package/app/node_modules/next/dist/build/babel/loader/get-config.js +7 -16
  422. package/app/node_modules/next/dist/build/babel/plugins/next-font-unsupported.js +1 -5
  423. package/app/node_modules/next/dist/build/babel/plugins/next-page-config.js +5 -25
  424. package/app/node_modules/next/dist/build/babel/plugins/next-page-disallow-re-export-all-exports.js +1 -5
  425. package/app/node_modules/next/dist/build/babel/plugins/next-ssg-transform.js +4 -20
  426. package/app/node_modules/next/dist/build/browser-variant-modules.js +1 -0
  427. package/app/node_modules/next/dist/build/create-compiler-aliases.js +19 -11
  428. package/app/node_modules/next/dist/build/define-env.js +12 -18
  429. package/app/node_modules/next/dist/build/entries.js +132 -8
  430. package/app/node_modules/next/dist/build/get-babel-loader-config.js +10 -10
  431. package/app/node_modules/next/dist/build/get-convention-file-base-name.js +29 -0
  432. package/app/node_modules/next/dist/build/get-static-info-including-layouts.js +0 -1
  433. package/app/node_modules/next/dist/build/handle-externals.js +1 -5
  434. package/app/node_modules/next/dist/build/load-jsconfig.js +1 -5
  435. package/app/node_modules/next/dist/build/lockfile.js +1 -5
  436. package/app/node_modules/next/dist/build/next-config-ts/transpile-config.js +1 -5
  437. package/app/node_modules/next/dist/build/nft.js +119 -0
  438. package/app/node_modules/next/dist/build/normalize-catchall-routes.js +18 -66
  439. package/app/node_modules/next/dist/build/print-build-errors.js +57 -7
  440. package/app/node_modules/next/dist/build/route-discovery.js +32 -4
  441. package/app/node_modules/next/dist/build/segment-config/app/app-segment-config.js +19 -5
  442. package/app/node_modules/next/dist/build/segment-config/app/app-segments.js +120 -29
  443. package/app/node_modules/next/dist/build/segment-config/app/collect-root-param-keys.js +1 -5
  444. package/app/node_modules/next/dist/build/static-paths/app/extract-pathname-route-param-segments-from-loader-tree.js +8 -2
  445. package/app/node_modules/next/dist/build/static-paths/app.js +230 -133
  446. package/app/node_modules/next/dist/build/static-paths/pages.js +8 -40
  447. package/app/node_modules/next/dist/build/static-paths/param-matching.js +200 -0
  448. package/app/node_modules/next/dist/build/swc/index.js +92 -162
  449. package/app/node_modules/next/dist/build/utils.js +180 -90
  450. package/app/node_modules/next/dist/build/webpack/cache-invalidation.js +1 -5
  451. package/app/node_modules/next/dist/build/webpack/config/blocks/css/plugins.js +7 -35
  452. package/app/node_modules/next/dist/build/webpack/loaders/css-loader/src/CssSyntaxError.js +0 -5
  453. package/app/node_modules/next/dist/build/webpack/loaders/css-loader/src/camelcase.js +1 -5
  454. package/app/node_modules/next/dist/build/webpack/loaders/css-loader/src/index.js +5 -25
  455. package/app/node_modules/next/dist/build/webpack/loaders/css-loader/src/plugins/postcss-import-parser.js +4 -20
  456. package/app/node_modules/next/dist/build/webpack/loaders/lightningcss-loader/src/index.js +3 -16
  457. package/app/node_modules/next/dist/build/webpack/loaders/lightningcss-loader/src/interface.js +0 -1
  458. package/app/node_modules/next/dist/build/webpack/loaders/lightningcss-loader/src/loader.js +2 -10
  459. package/app/node_modules/next/dist/build/webpack/loaders/next-flight-css-loader.js +1 -5
  460. package/app/node_modules/next/dist/build/webpack/loaders/next-flight-loader/index.js +3 -15
  461. package/app/node_modules/next/dist/build/webpack/loaders/next-route-loader/index.js +3 -15
  462. package/app/node_modules/next/dist/build/webpack/loaders/postcss-loader/src/Error.js +0 -5
  463. package/app/node_modules/next/dist/build/webpack/loaders/postcss-loader/src/Warning.js +0 -5
  464. package/app/node_modules/next/dist/build/webpack/loaders/postcss-loader/src/index.js +2 -10
  465. package/app/node_modules/next/dist/build/webpack/loaders/resolve-url-loader/index.js +2 -6
  466. package/app/node_modules/next/dist/build/webpack/loaders/resolve-url-loader/lib/file-protocol.js +2 -10
  467. package/app/node_modules/next/dist/build/webpack/loaders/resolve-url-loader/lib/join-function.js +1 -5
  468. package/app/node_modules/next/dist/build/webpack/loaders/resolve-url-loader/lib/postcss.js +1 -5
  469. package/app/node_modules/next/dist/build/webpack/plugins/build-manifest-plugin.js +1 -5
  470. package/app/node_modules/next/dist/build/webpack/plugins/deferred-entries-plugin.js +9 -0
  471. package/app/node_modules/next/dist/build/webpack/plugins/flight-manifest-plugin.js +2 -6
  472. package/app/node_modules/next/dist/build/webpack/plugins/middleware-plugin.js +1 -5
  473. package/app/node_modules/next/dist/build/webpack/plugins/next-trace-entrypoints-plugin.js +2 -10
  474. package/app/node_modules/next/dist/build/webpack/plugins/next-types-plugin/index.js +3 -1
  475. package/app/node_modules/next/dist/build/webpack/plugins/slow-module-detection-plugin.js +3 -15
  476. package/app/node_modules/next/dist/build/webpack/plugins/subresource-integrity-plugin.js +1 -5
  477. package/app/node_modules/next/dist/build/webpack-config.js +16 -33
  478. package/app/node_modules/next/dist/cli/next-test.js +4 -0
  479. package/app/node_modules/next/dist/client/app-call-server.js +16 -18
  480. package/app/node_modules/next/dist/client/components/app-router-instance.js +43 -187
  481. package/app/node_modules/next/dist/client/components/{segment-cache/navigation.js → app-router-state.js} +88 -334
  482. package/app/node_modules/next/dist/client/components/app-router-utils.js +1 -5
  483. package/app/node_modules/next/dist/client/components/app-router.js +83 -74
  484. package/app/node_modules/next/dist/client/components/dev-root-http-access-fallback-boundary.js +1 -5
  485. package/app/node_modules/next/dist/client/components/forbidden.js +2 -10
  486. package/app/node_modules/next/dist/client/components/handle-isr-error.js +19 -4
  487. package/app/node_modules/next/dist/client/components/instant-samples.js +4 -11
  488. package/app/node_modules/next/dist/client/components/links.js +6 -7
  489. package/app/node_modules/next/dist/client/components/navigation-dynamic-rendering.js +3 -3
  490. package/app/node_modules/next/dist/client/components/navigation-untracked.js +1 -2
  491. package/app/node_modules/next/dist/client/components/navigation.js +2 -6
  492. package/app/node_modules/next/dist/client/components/navigation.react-server.js +1 -5
  493. package/app/node_modules/next/dist/client/components/navigator.js +73 -0
  494. package/app/node_modules/next/dist/client/components/not-found.js +1 -5
  495. package/app/node_modules/next/dist/client/components/prefetch.js +83 -0
  496. package/app/node_modules/next/dist/client/components/readonly-url-search-params.js +0 -5
  497. package/app/node_modules/next/dist/client/components/redirect.js +3 -15
  498. package/app/node_modules/next/dist/client/components/{router-reducer/ppr-navigations.js → render-tree.js} +365 -400
  499. package/app/node_modules/next/dist/client/components/router-reducer/compute-changed-path.js +13 -5
  500. package/app/node_modules/next/dist/client/components/router-reducer/create-initial-router-state.js +67 -54
  501. package/app/node_modules/next/dist/client/components/router-reducer/create-router-cache-key.js +1 -7
  502. package/app/node_modules/next/dist/client/components/router-reducer/create-segment-key.js +42 -0
  503. package/app/node_modules/next/dist/client/components/router-reducer/fetch-server-response.js +71 -50
  504. package/app/node_modules/next/dist/client/components/router-reducer/is-navigating-to-new-root-layout.js +4 -4
  505. package/app/node_modules/next/dist/client/components/router-reducer/reducers/hmr-refresh-reducer.js +2 -2
  506. package/app/node_modules/next/dist/client/components/router-reducer/reducers/navigate-reducer.js +5 -5
  507. package/app/node_modules/next/dist/client/components/router-reducer/reducers/refresh-reducer.js +11 -8
  508. package/app/node_modules/next/dist/client/components/router-reducer/reducers/restore-reducer.js +12 -9
  509. package/app/node_modules/next/dist/client/components/router-reducer/reducers/server-action-reducer.js +30 -29
  510. package/app/node_modules/next/dist/client/components/router-reducer/reducers/server-patch-reducer.js +5 -5
  511. package/app/node_modules/next/dist/client/components/router-reducer/router-reducer.js +2 -10
  512. package/app/node_modules/next/dist/client/components/segment-cache/bfcache.js +11 -21
  513. package/app/node_modules/next/dist/client/components/segment-cache/cache.js +1168 -1181
  514. package/app/node_modules/next/dist/client/components/segment-cache/decode-server-response.js +419 -0
  515. package/app/node_modules/next/dist/client/components/segment-cache/navigation-testing-lock.js +1 -1
  516. package/app/node_modules/next/dist/client/components/segment-cache/optimistic-routes.js +77 -82
  517. package/app/node_modules/next/dist/client/components/segment-cache/scheduler.js +464 -425
  518. package/app/node_modules/next/dist/client/components/segment-cache/types.js +12 -3
  519. package/app/node_modules/next/dist/client/components/segment-cache/vary-path.js +140 -126
  520. package/app/node_modules/next/dist/client/components/sequential-router-queue.js +163 -0
  521. package/app/node_modules/next/dist/client/components/unauthorized.js +2 -10
  522. package/app/node_modules/next/dist/client/components/unstable-rethrow.js +1 -2
  523. package/app/node_modules/next/dist/client/components/use-action-queue.js +2 -10
  524. package/app/node_modules/next/dist/client/dev/debug-channel.js +6 -323
  525. package/app/node_modules/next/dist/client/dev/hot-reloader/app/hot-reloader-app.js +49 -31
  526. package/app/node_modules/next/dist/client/dev/hot-reloader/app/web-socket.js +14 -21
  527. package/app/node_modules/next/dist/client/dev/hot-reloader/pages/hot-reloader-pages.js +15 -6
  528. package/app/node_modules/next/dist/client/dev/hot-reloader/runtime-error-state.js +72 -0
  529. package/app/node_modules/next/dist/client/flight-data-helpers.js +41 -94
  530. package/app/node_modules/next/dist/client/route-loader.js +6 -30
  531. package/app/node_modules/next/dist/client/route-params.js +34 -12
  532. package/app/node_modules/next/dist/client/router.js +2 -10
  533. package/app/node_modules/next/dist/client/sequential-call-server.js +45 -0
  534. package/app/node_modules/next/dist/compiled/@mswjs/interceptors/ClientRequest/index.js +1 -1
  535. package/app/node_modules/next/dist/compiled/next-devtools/index.js +279 -229
  536. package/app/node_modules/next/dist/compiled/next-server/app-page-experimental.runtime.prod.js +203 -59
  537. package/app/node_modules/next/dist/compiled/next-server/app-page-turbo-experimental.runtime.prod.js +203 -59
  538. package/app/node_modules/next/dist/compiled/next-server/app-page-turbo.runtime.prod.js +203 -59
  539. package/app/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js +203 -59
  540. package/app/node_modules/next/dist/compiled/next-server/app-route.runtime.prod.js +5 -3
  541. package/app/node_modules/next/dist/compiled/next-server/pages-turbo.runtime.prod.js +13 -13
  542. package/app/node_modules/next/dist/compiled/next-server/pages.runtime.prod.js +13 -13
  543. package/app/node_modules/next/dist/compiled/react-is/package.json +1 -1
  544. package/app/node_modules/next/dist/compiled/stacktrace-parser/stack-trace-parser.cjs.js +1 -1
  545. package/app/node_modules/next/dist/compiled/unistore/unistore.js +1 -1
  546. package/app/node_modules/next/dist/experimental/testmode/fetch.js +2 -10
  547. package/app/node_modules/next/dist/export/helpers/create-incremental-cache.js +21 -16
  548. package/app/node_modules/next/dist/export/utils.js +21 -8
  549. package/app/node_modules/next/dist/lib/batcher.js +2 -2
  550. package/app/node_modules/next/dist/lib/dist-dir.js +88 -0
  551. package/app/node_modules/next/dist/lib/download-swc.js +2 -10
  552. package/app/node_modules/next/dist/lib/fallback.js +3 -15
  553. package/app/node_modules/next/dist/lib/find-pages-dir.js +2 -10
  554. package/app/node_modules/next/dist/lib/helpers/get-cache-directory.js +1 -5
  555. package/app/node_modules/next/dist/lib/helpers/get-registry.js +1 -5
  556. package/app/node_modules/next/dist/lib/is-error.js +3 -15
  557. package/app/node_modules/next/dist/lib/is-serializable-props.js +6 -35
  558. package/app/node_modules/next/dist/lib/patch-incorrect-lockfile.js +4 -8
  559. package/app/node_modules/next/dist/lib/picocolors.js +10 -0
  560. package/app/node_modules/next/dist/lib/recursive-delete.js +50 -11
  561. package/app/node_modules/next/dist/lib/resolve-from.js +2 -10
  562. package/app/node_modules/next/dist/lib/static-env.js +1 -5
  563. package/app/node_modules/next/dist/lib/typescript/getTypeScriptConfiguration.js +3 -15
  564. package/app/node_modules/next/dist/lib/typescript/missingDependencyError.js +1 -5
  565. package/app/node_modules/next/dist/lib/typescript/runTypeCheck.js +1 -9
  566. package/app/node_modules/next/dist/lib/typescript/runTypeCheckCli.js +0 -1
  567. package/app/node_modules/next/dist/lib/typescript/runTypeScriptCli.js +4 -16
  568. package/app/node_modules/next/dist/lib/verify-partytown-setup.js +1 -5
  569. package/app/node_modules/next/dist/lib/warn-missing-react-dependencies.js +33 -0
  570. package/app/node_modules/next/dist/next-devtools/server/attach-nodejs-debugger-middleware.js +1 -5
  571. package/app/node_modules/next/dist/next-devtools/server/shared.js +3 -2
  572. package/app/node_modules/next/dist/next-devtools/shared/console-error.js +1 -5
  573. package/app/node_modules/next/dist/next-devtools/userspace/app/errors/replay-ssr-only-errors.js +1 -5
  574. package/app/node_modules/next/dist/next-devtools/userspace/app/errors/runtime-error-metadata.js +39 -0
  575. package/app/node_modules/next/dist/next-devtools/userspace/app/errors/stitched-error.js +1 -5
  576. package/app/node_modules/next/dist/next-devtools/userspace/app/errors/use-error-handler.js +48 -19
  577. package/app/node_modules/next/dist/next-devtools/userspace/app/segment-explorer-node.js +1 -5
  578. package/app/node_modules/next/dist/server/accept-header.js +3 -15
  579. package/app/node_modules/next/dist/server/after/after-context.js +5 -25
  580. package/app/node_modules/next/dist/server/after/awaiter.js +1 -5
  581. package/app/node_modules/next/dist/server/after/run-with-after.js +2 -2
  582. package/app/node_modules/next/dist/server/api-utils/index.js +1 -10
  583. package/app/node_modules/next/dist/server/api-utils/node/parse-body.js +3 -15
  584. package/app/node_modules/next/dist/server/app-render/action-async-storage-instance.js +1 -1
  585. package/app/node_modules/next/dist/server/app-render/action-handler.js +104 -141
  586. package/app/node_modules/next/dist/server/app-render/after-task-async-storage-instance.js +1 -1
  587. package/app/node_modules/next/dist/server/app-render/app-render-prerender-utils.js +6 -30
  588. package/app/node_modules/next/dist/server/app-render/app-render-render-utils.js +1 -5
  589. package/app/node_modules/next/dist/server/app-render/app-render-scheduling.js +3 -15
  590. package/app/node_modules/next/dist/server/app-render/app-render.js +1346 -1211
  591. package/app/node_modules/next/dist/server/app-render/async-local-storage.js +11 -6
  592. package/app/node_modules/next/dist/server/app-render/blocking-route-messages.js +119 -70
  593. package/app/node_modules/next/dist/server/app-render/cache-signal.js +61 -35
  594. package/app/node_modules/next/dist/server/app-render/console-async-storage-instance.js +1 -1
  595. package/app/node_modules/next/dist/server/app-render/create-component-tree.js +136 -160
  596. package/app/node_modules/next/dist/server/app-render/create-error-handler.js +12 -6
  597. package/app/node_modules/next/dist/server/app-render/create-transport-tree-from-loader-tree.js +190 -0
  598. package/app/node_modules/next/dist/server/app-render/debug-channel-server.web.js +1 -5
  599. package/app/node_modules/next/dist/server/app-render/dev-validation-scheduler.js +4 -5
  600. package/app/node_modules/next/dist/server/app-render/dev-validation-worker-snapshot.js +3 -1
  601. package/app/node_modules/next/dist/server/app-render/dynamic-access-async-storage-instance.js +1 -1
  602. package/app/node_modules/next/dist/server/app-render/dynamic-access-async-storage.external.js +26 -3
  603. package/app/node_modules/next/dist/server/app-render/dynamic-rendering-client.js +124 -0
  604. package/app/node_modules/next/dist/server/app-render/dynamic-rendering.js +260 -329
  605. package/app/node_modules/next/dist/server/app-render/encryption-utils.js +1 -5
  606. package/app/node_modules/next/dist/server/app-render/instant-validation/boundary-tracking.js +2 -2
  607. package/app/node_modules/next/dist/server/app-render/instant-validation/instant-config.js +4 -12
  608. package/app/node_modules/next/dist/server/app-render/instant-validation/instant-samples.js +13 -62
  609. package/app/node_modules/next/dist/server/app-render/instant-validation/stream-utils.js +2 -10
  610. package/app/node_modules/next/dist/server/app-render/manifests-singleton.js +110 -38
  611. package/app/node_modules/next/dist/server/app-render/module-loading/track-module-loading.instance.js +1 -1
  612. package/app/node_modules/next/dist/server/app-render/parse-and-validate-flight-router-state.js +3 -15
  613. package/app/node_modules/next/dist/server/app-render/postponed-state.js +87 -51
  614. package/app/node_modules/next/dist/server/app-render/prospective-render-utils.js +2 -6
  615. package/app/node_modules/next/dist/server/app-render/render-in-browser.js +27 -0
  616. package/app/node_modules/next/dist/server/app-render/required-scripts.js +1 -5
  617. package/app/node_modules/next/dist/server/app-render/segment-config/ensure-static.js +206 -0
  618. package/app/node_modules/next/dist/server/app-render/staged-rendering.js +46 -54
  619. package/app/node_modules/next/dist/server/app-render/stream-ops.node.js +18 -12
  620. package/app/node_modules/next/dist/server/app-render/stream-ops.web.js +4 -20
  621. package/app/node_modules/next/dist/server/app-render/sync-io-messages.js +2 -10
  622. package/app/node_modules/next/dist/server/app-render/types.js +2 -1
  623. package/app/node_modules/next/dist/server/app-render/use-flight-response.js +4 -17
  624. package/app/node_modules/next/dist/server/app-render/vary-params.js +12 -11
  625. package/app/node_modules/next/dist/server/app-render/walk-tree-with-flight-router-state.js +95 -97
  626. package/app/node_modules/next/dist/server/app-render/work-async-storage-instance.js +1 -1
  627. package/app/node_modules/next/dist/server/app-render/work-unit-async-storage-instance.js +1 -1
  628. package/app/node_modules/next/dist/server/app-render/work-unit-async-storage.external.js +36 -26
  629. package/app/node_modules/next/dist/server/async-storage/draft-mode-provider.js +1 -5
  630. package/app/node_modules/next/dist/server/async-storage/request-store.js +6 -5
  631. package/app/node_modules/next/dist/server/async-storage/work-store.js +24 -26
  632. package/app/node_modules/next/dist/server/base-http/node.js +1 -5
  633. package/app/node_modules/next/dist/server/base-server.js +346 -155
  634. package/app/node_modules/next/dist/server/client-component-renderer-logger.js +129 -28
  635. package/app/node_modules/next/dist/server/config-schema.js +61 -9
  636. package/app/node_modules/next/dist/server/config-shared.js +26 -4
  637. package/app/node_modules/next/dist/server/config.js +154 -332
  638. package/app/node_modules/next/dist/server/dev/debug-channel.js +1 -5
  639. package/app/node_modules/next/dist/server/dev/dev-validation-worker-pool.js +1 -0
  640. package/app/node_modules/next/dist/server/dev/get-source-map-from-file.js +5 -25
  641. package/app/node_modules/next/dist/server/dev/hot-middleware.js +27 -1
  642. package/app/node_modules/next/dist/server/dev/hot-reloader-turbopack.js +338 -200
  643. package/app/node_modules/next/dist/server/dev/hot-reloader-types.js +3 -0
  644. package/app/node_modules/next/dist/server/dev/hot-reloader-webpack.js +26 -20
  645. package/app/node_modules/next/dist/server/dev/messages.js +2 -10
  646. package/app/node_modules/next/dist/server/dev/middleware-turbopack.js +4 -20
  647. package/app/node_modules/next/dist/server/dev/middleware-webpack.js +2 -10
  648. package/app/node_modules/next/dist/server/dev/next-dev-server.js +33 -95
  649. package/app/node_modules/next/dist/server/dev/node-stack-frames.js +2 -19
  650. package/app/node_modules/next/dist/server/dev/on-demand-entry-handler.js +12 -12
  651. package/app/node_modules/next/dist/server/dev/runtime-error-state.js +220 -0
  652. package/app/node_modules/next/dist/server/dev/serialized-errors.js +1 -5
  653. package/app/node_modules/next/dist/server/dev/static-paths-worker.js +16 -15
  654. package/app/node_modules/next/dist/server/dev/turbopack-utils.js +20 -36
  655. package/app/node_modules/next/dist/server/dev/use-cache-probe-pool.js +1 -0
  656. package/app/node_modules/next/dist/server/dynamic-rendering-utils.js +298 -55
  657. package/app/node_modules/next/dist/server/image-optimizer/detect-content-type.js +229 -0
  658. package/app/node_modules/next/dist/server/image-optimizer/extract-etag.js +53 -0
  659. package/app/node_modules/next/dist/server/image-optimizer/get-image-size.js +25 -0
  660. package/app/node_modules/next/dist/server/image-optimizer/get-max-age.js +41 -0
  661. package/app/node_modules/next/dist/server/image-optimizer/get-previously-cached-image-or-null.js +22 -0
  662. package/app/node_modules/next/dist/server/image-optimizer/image-error.js +23 -0
  663. package/app/node_modules/next/dist/server/image-optimizer/image-type.js +86 -0
  664. package/app/node_modules/next/dist/server/image-optimizer/transform.js +227 -0
  665. package/app/node_modules/next/dist/server/image-optimizer.js +78 -674
  666. package/app/node_modules/next/dist/server/lib/app-info-log.js +19 -9
  667. package/app/node_modules/next/dist/server/lib/cache-handlers/default.js +9 -13
  668. package/app/node_modules/next/dist/server/lib/chrome-devtools-workspace.js +1 -5
  669. package/app/node_modules/next/dist/server/lib/dedupe-fetch.js +1 -5
  670. package/app/node_modules/next/dist/server/lib/dev-bundler-service.js +6 -6
  671. package/app/node_modules/next/dist/server/lib/generate-agent-files.js +158 -35
  672. package/app/node_modules/next/dist/server/lib/i18n-provider.js +1 -5
  673. package/app/node_modules/next/dist/server/lib/incremental-cache/file-system-cache.js +14 -20
  674. package/app/node_modules/next/dist/server/lib/incremental-cache/index.js +19 -29
  675. package/app/node_modules/next/dist/server/lib/incremental-cache/memory-cache.external.js +1 -5
  676. package/app/node_modules/next/dist/server/lib/lru-cache.js +1 -5
  677. package/app/node_modules/next/dist/server/lib/mock-request.js +24 -120
  678. package/app/node_modules/next/dist/server/lib/module-loader/node-module-loader.js +1 -5
  679. package/app/node_modules/next/dist/server/lib/patch-fetch.js +44 -38
  680. package/app/node_modules/next/dist/server/lib/postponed-request-body.js +1 -5
  681. package/app/node_modules/next/dist/server/lib/render-server.js +2 -10
  682. package/app/node_modules/next/dist/server/lib/router-server.js +106 -36
  683. package/app/node_modules/next/dist/server/lib/router-utils/build-data-route.js +26 -3
  684. package/app/node_modules/next/dist/server/lib/router-utils/cache-life-type-utils.js +14 -45
  685. package/app/node_modules/next/dist/server/lib/router-utils/decode-path-params.js +1 -5
  686. package/app/node_modules/next/dist/server/lib/router-utils/filesystem.js +212 -31
  687. package/app/node_modules/next/dist/server/lib/router-utils/instrumentation-globals.external.js +61 -1
  688. package/app/node_modules/next/dist/server/lib/router-utils/instrumentation-node-extensions.js +1 -5
  689. package/app/node_modules/next/dist/server/lib/router-utils/normalize-catchall-routes.js +320 -0
  690. package/app/node_modules/next/dist/server/lib/router-utils/proxy-request.js +2 -2
  691. package/app/node_modules/next/dist/server/lib/router-utils/resolve-routes.js +17 -11
  692. package/app/node_modules/next/dist/server/lib/router-utils/setup-dev-bundler.js +258 -76
  693. package/app/node_modules/next/dist/server/lib/router-utils/strict-route-matching-config.js +28 -0
  694. package/app/node_modules/next/dist/server/lib/router-utils/typegen.js +56 -10
  695. package/app/node_modules/next/dist/server/lib/start-server.js +48 -38
  696. package/app/node_modules/next/dist/server/lib/trace/constants.js +40 -0
  697. package/app/node_modules/next/dist/server/lib/trace/request-insights-identity.js +1 -3
  698. package/app/node_modules/next/dist/server/lib/trace/tracer.js +10 -10
  699. package/app/node_modules/next/dist/server/lib/utils.js +66 -15
  700. package/app/node_modules/next/dist/server/load-components.js +7 -2
  701. package/app/node_modules/next/dist/server/load-manifest.external.js +16 -17
  702. package/app/node_modules/next/dist/server/mcp/tools/utils/browser-communication.js +2 -10
  703. package/app/node_modules/next/dist/server/mcp/tools/utils/format-errors.js +5 -5
  704. package/app/node_modules/next/dist/server/next-server.js +130 -124
  705. package/app/node_modules/next/dist/server/next.js +25 -37
  706. package/app/node_modules/next/dist/server/node-environment-extensions/console-dim.external.js +1 -2
  707. package/app/node_modules/next/dist/server/node-environment-extensions/fast-set-immediate.external.js +115 -62
  708. package/app/node_modules/next/dist/server/node-environment-extensions/global-behaviors.js +1 -5
  709. package/app/node_modules/next/dist/server/node-environment-extensions/io-utils.js +11 -10
  710. package/app/node_modules/next/dist/server/node-environment-extensions/process-error-handlers.js +0 -9
  711. package/app/node_modules/next/dist/server/node-environment-extensions/unhandled-rejection.external.js +1 -12
  712. package/app/node_modules/next/dist/server/normalizers/built/app/app-page-normalizer.js +1 -1
  713. package/app/node_modules/next/dist/server/normalizers/request/base-path.js +1 -5
  714. package/app/node_modules/next/dist/server/normalizers/request/next-data.js +1 -5
  715. package/app/node_modules/next/dist/server/normalizers/request/prefix.js +1 -5
  716. package/app/node_modules/next/dist/server/patch-error-inspect.js +19 -11
  717. package/app/node_modules/next/dist/server/pipe-readable.js +42 -30
  718. package/app/node_modules/next/dist/server/render-result.js +5 -17
  719. package/app/node_modules/next/dist/server/render.js +37 -183
  720. package/app/node_modules/next/dist/server/request/fallback-params.js +23 -9
  721. package/app/node_modules/next/dist/server/response-cache/index.js +54 -32
  722. package/app/node_modules/next/dist/server/response-cache/utils.js +1 -5
  723. package/app/node_modules/next/dist/server/resume-data-cache/cache-store.js +18 -0
  724. package/app/node_modules/next/dist/server/resume-data-cache/resume-data-cache.js +51 -49
  725. package/app/node_modules/next/dist/server/revalidation-utils.js +15 -13
  726. package/app/node_modules/next/dist/server/route-modules/app-page/dev-render-context.js +23 -0
  727. package/app/node_modules/next/dist/server/route-modules/app-page/helpers/prerender-manifest-matcher.js +5 -4
  728. package/app/node_modules/next/dist/server/route-modules/app-page/module.js +13 -1
  729. package/app/node_modules/next/dist/server/route-modules/app-page/module.render.js +26 -11
  730. package/app/node_modules/next/dist/server/route-modules/app-page/parse-request-headers.js +58 -0
  731. package/app/node_modules/next/dist/server/route-modules/app-page/vendored/rsc/entrypoints.js +1 -5
  732. package/app/node_modules/next/dist/server/route-modules/app-page/vendored/ssr/entrypoints.js +1 -5
  733. package/app/node_modules/next/dist/server/route-modules/pages/module.render.js +1 -5
  734. package/app/node_modules/next/dist/server/route-modules/pages/pages-handler.js +20 -16
  735. package/app/node_modules/next/dist/server/route-modules/route-module.js +57 -61
  736. package/app/node_modules/next/dist/server/serve-static.js +1 -5
  737. package/app/node_modules/next/dist/server/setup-http-agent-env.js +1 -5
  738. package/app/node_modules/next/dist/server/stream-utils/encoded-tags.js +1 -1
  739. package/app/node_modules/next/dist/server/stream-utils/node-web-streams-helper.js +7 -11
  740. package/app/node_modules/next/dist/server/typescript/constant.js +2 -0
  741. package/app/node_modules/next/dist/server/typescript/rules/config.js +29 -2
  742. package/app/node_modules/next/dist/server/use-cache/cache-life-profile.js +6 -30
  743. package/app/node_modules/next/dist/server/use-cache/constants.js +1 -5
  744. package/app/node_modules/next/dist/server/use-cache/handlers.js +27 -36
  745. package/app/node_modules/next/dist/server/use-cache/tiered-cache-handler.js +6 -4
  746. package/app/node_modules/next/dist/server/web/adapter.js +14 -35
  747. package/app/node_modules/next/dist/server/web/error.js +0 -15
  748. package/app/node_modules/next/dist/server/web/globals.js +3 -15
  749. package/app/node_modules/next/dist/server/web/next-url.js +1 -5
  750. package/app/node_modules/next/dist/server/web/sandbox/context.js +10 -34
  751. package/app/node_modules/next/dist/server/web/sandbox/sandbox.js +1 -5
  752. package/app/node_modules/next/dist/server/web/spec-extension/adapters/headers.js +0 -5
  753. package/app/node_modules/next/dist/server/web/spec-extension/adapters/next-request.js +1 -5
  754. package/app/node_modules/next/dist/server/web/spec-extension/adapters/request-cookies.js +0 -5
  755. package/app/node_modules/next/dist/server/web/spec-extension/fetch-event.js +2 -10
  756. package/app/node_modules/next/dist/server/web/spec-extension/response.js +2 -10
  757. package/app/node_modules/next/dist/server/web/utils.js +1 -5
  758. package/app/node_modules/next/dist/server/web/web-on-close.js +2 -10
  759. package/app/node_modules/next/dist/shared/lib/app-router-types.js +38 -28
  760. package/app/node_modules/next/dist/shared/lib/constants.js +5 -0
  761. package/app/node_modules/next/dist/shared/lib/deployment-id.js +1 -1
  762. package/app/node_modules/next/dist/shared/lib/errors/code-frame.js +3 -2
  763. package/app/node_modules/next/dist/shared/lib/errors/empty-generate-static-params-error.js +1 -5
  764. package/app/node_modules/next/dist/shared/lib/errors/ensure-static-gsp-errors.js +30 -0
  765. package/app/node_modules/next/dist/shared/lib/errors/hard-deprecated-config-error.js +0 -5
  766. package/app/node_modules/next/dist/shared/lib/errors/incompatible-parallel-route-slots-error.js +36 -0
  767. package/app/node_modules/next/dist/shared/lib/errors/missing-canonical-interception-routes-error.js +20 -0
  768. package/app/node_modules/next/dist/shared/lib/errors/unmatched-app-pages-error.js +20 -0
  769. package/app/node_modules/next/dist/shared/lib/get-rspack.js +1 -5
  770. package/app/node_modules/next/dist/shared/lib/html-context.shared-runtime.js +1 -5
  771. package/app/node_modules/next/dist/shared/lib/image-config.js +52 -1
  772. package/app/node_modules/next/dist/shared/lib/instant-messages.js +2 -10
  773. package/app/node_modules/next/dist/shared/lib/invariant-error.js +0 -5
  774. package/app/node_modules/next/dist/shared/lib/lazy-dynamic/react-browser-bailout.js +45 -0
  775. package/app/node_modules/next/dist/shared/lib/magic-identifier.js +5 -25
  776. package/app/node_modules/next/dist/shared/lib/match-remote-pattern.js +1 -5
  777. package/app/node_modules/next/dist/shared/lib/router/router.js +95 -77
  778. package/app/node_modules/next/dist/shared/lib/router/routes/app.js +3 -15
  779. package/app/node_modules/next/dist/shared/lib/router/utils/app-paths.js +6 -1
  780. package/app/node_modules/next/dist/shared/lib/router/utils/get-dynamic-param.js +4 -12
  781. package/app/node_modules/next/dist/shared/lib/router/utils/interception-routes.js +63 -20
  782. package/app/node_modules/next/dist/shared/lib/router/utils/parse-relative-url.js +1 -5
  783. package/app/node_modules/next/dist/shared/lib/router/utils/prepare-destination.js +1 -5
  784. package/app/node_modules/next/dist/shared/lib/router/utils/querystring.js +31 -0
  785. package/app/node_modules/next/dist/shared/lib/router/utils/resolve-param-value.js +1 -5
  786. package/app/node_modules/next/dist/shared/lib/router/utils/route-matcher.js +1 -5
  787. package/app/node_modules/next/dist/shared/lib/router/utils/sorted-routes.js +11 -55
  788. package/app/node_modules/next/dist/shared/lib/rsc-transport.js +108 -0
  789. package/app/node_modules/next/dist/shared/lib/segment-cache/segment-value-encoding.js +0 -13
  790. package/app/node_modules/next/dist/shared/lib/segment-cache/vary-params-decoding.js +48 -27
  791. package/app/node_modules/next/dist/shared/lib/segment.js +1 -13
  792. package/app/node_modules/next/dist/shared/lib/turbopack/compilation-events.js +7 -7
  793. package/app/node_modules/next/dist/shared/lib/turbopack/internal-error.js +2 -7
  794. package/app/node_modules/next/dist/shared/lib/turbopack/manifest-loader.js +2 -6
  795. package/app/node_modules/next/dist/shared/lib/turbopack/utils.js +3 -11
  796. package/app/node_modules/next/dist/shared/lib/utils.js +2 -11
  797. package/app/node_modules/next/dist/shared/lib/zod.js +2 -6
  798. package/app/node_modules/next/dist/telemetry/anonymous-meta.js +1 -1
  799. package/app/node_modules/next/dist/telemetry/detached-flush.js +8 -15
  800. package/app/node_modules/next/dist/telemetry/events/build.js +1 -2
  801. package/app/node_modules/next/dist/telemetry/events/swc-load-failure.js +1 -1
  802. package/app/node_modules/next/dist/telemetry/events/version.js +2 -2
  803. package/app/node_modules/next/dist/telemetry/post-telemetry-payload.js +1 -5
  804. package/app/node_modules/next/dist/telemetry/storage.js +31 -19
  805. package/app/node_modules/next/dist/trace/report/index.js +5 -2
  806. package/app/node_modules/next/dist/trace/report/to-json-build.js +4 -2
  807. package/app/node_modules/next/dist/trace/report/to-json.js +141 -97
  808. package/app/node_modules/next/dist/trace/trace.js +14 -9
  809. package/app/node_modules/next/package.json +12 -11
  810. package/app/package.json +4 -4
  811. package/app/server.js +1 -1
  812. package/app/src/mitm/server.js +43 -39
  813. package/package.json +1 -1
  814. package/app/.next-cli-build/static/chunks/1321-c5b3011761e0228b.js +0 -1
  815. package/app/.next-cli-build/static/chunks/3794-83acfce05009cf38.js +0 -52
  816. package/app/.next-cli-build/static/chunks/4bd1b696-8a4ab4fdf0ae305a.js +0 -1
  817. package/app/.next-cli-build/static/chunks/5353-d31cc8d476bc534e.js +0 -1
  818. package/app/.next-cli-build/static/chunks/5772-6cf78180ecf9dce0.js +0 -3
  819. package/app/.next-cli-build/static/chunks/6069-7e7f824c6e2d4291.js +0 -73
  820. package/app/.next-cli-build/static/chunks/7504-6f7ca1eab428dd5e.js +0 -64
  821. package/app/.next-cli-build/static/chunks/8202.1ffc6ce531e066ce.js +0 -1
  822. package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/basic-chat/page-90b9aed7279ea50e.js +0 -1
  823. package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/cli-tools/page-eaf6e24edeca4e51.js +0 -1
  824. package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/providers/[id]/page-2f53d5dd5b247cf1.js +0 -11
  825. package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/translator/page-bbc10fd10f7af626.js +0 -1
  826. package/app/.next-cli-build/static/chunks/main-1eaba0b776683ce7.js +0 -5
  827. package/app/node_modules/next/dist/build/webpack/loaders/lightningcss-loader/src/minify.js +0 -94
  828. package/app/node_modules/next/dist/client/components/match-segments.js +0 -32
  829. package/app/node_modules/next/dist/client/components/router-reducer/reducers/find-head-in-cache.js +0 -63
  830. package/app/node_modules/next/dist/client/components/segment-cache/prefetch.js +0 -32
  831. package/app/node_modules/next/dist/compiled/webpack-sources3/index.js +0 -1
  832. package/app/node_modules/next/dist/compiled/webpack-sources3/package.json +0 -1
  833. package/app/node_modules/next/dist/lib/detached-promise.js +0 -32
  834. package/app/node_modules/next/dist/lib/error-telemetry-utils.js +0 -42
  835. package/app/node_modules/next/dist/next-devtools/server/get-next-error-feedback-middleware.js +0 -42
  836. package/app/node_modules/next/dist/server/app-render/create-flight-router-state-from-loader-tree.js +0 -154
  837. package/app/node_modules/next/dist/server/lib/experimental/ppr.js +0 -47
  838. package/app/node_modules/next/dist/server/lib/params-utils.js +0 -70
  839. package/app/node_modules/next/dist/server/lib/router-utils/is-postpone.js +0 -16
  840. package/app/node_modules/next/dist/server/route-matcher-managers/default-route-matcher-manager.js +0 -239
  841. package/app/node_modules/next/dist/server/route-matcher-managers/dev-route-matcher-manager.js +0 -120
  842. package/app/node_modules/next/dist/server/route-matcher-providers/app-page-route-matcher-provider.js +0 -55
  843. package/app/node_modules/next/dist/server/route-matcher-providers/app-route-route-matcher-provider.js +0 -43
  844. package/app/node_modules/next/dist/server/route-matcher-providers/dev/dev-app-page-route-matcher-provider.js +0 -91
  845. package/app/node_modules/next/dist/server/route-matcher-providers/dev/dev-app-route-route-matcher-provider.js +0 -112
  846. package/app/node_modules/next/dist/server/route-matcher-providers/dev/dev-pages-api-route-matcher-provider.js +0 -77
  847. package/app/node_modules/next/dist/server/route-matcher-providers/dev/dev-pages-route-matcher-provider.js +0 -77
  848. package/app/node_modules/next/dist/server/route-matcher-providers/dev/file-cache-route-matcher-provider.js +0 -28
  849. package/app/node_modules/next/dist/server/route-matcher-providers/dev/helpers/file-reader/batched-file-reader.js +0 -106
  850. package/app/node_modules/next/dist/server/route-matcher-providers/dev/helpers/file-reader/default-file-reader.js +0 -42
  851. package/app/node_modules/next/dist/server/route-matcher-providers/helpers/cached-route-matcher-provider.js +0 -30
  852. package/app/node_modules/next/dist/server/route-matcher-providers/helpers/manifest-loaders/node-manifest-loader.js +0 -34
  853. package/app/node_modules/next/dist/server/route-matcher-providers/helpers/manifest-loaders/server-manifest-loader.js +0 -20
  854. package/app/node_modules/next/dist/server/route-matcher-providers/manifest-route-matcher-provider.js +0 -21
  855. package/app/node_modules/next/dist/server/route-matcher-providers/pages-api-route-matcher-provider.js +0 -55
  856. package/app/node_modules/next/dist/server/route-matcher-providers/pages-route-matcher-provider.js +0 -64
  857. package/app/node_modules/next/dist/server/route-matchers/app-page-route-matcher.js +0 -18
  858. package/app/node_modules/next/dist/server/route-matchers/app-route-route-matcher.js +0 -15
  859. package/app/node_modules/next/dist/server/route-matchers/locale-route-matcher.js +0 -68
  860. package/app/node_modules/next/dist/server/route-matchers/pages-api-route-matcher.js +0 -30
  861. package/app/node_modules/next/dist/server/route-matchers/pages-route-matcher.js +0 -30
  862. package/app/node_modules/next/dist/server/route-matchers/route-matcher.js +0 -54
  863. package/app/node_modules/next/dist/telemetry/events/error-feedback.js +0 -31
  864. /package/app/.next-cli-build/static/{i0cMBMqFdYWpbajovDyfY → em-yyr0O7qRIA9N8Clc4I}/_buildManifest.js +0 -0
  865. /package/app/.next-cli-build/static/{i0cMBMqFdYWpbajovDyfY → em-yyr0O7qRIA9N8Clc4I}/_ssgManifest.js +0 -0
@@ -0,0 +1,73 @@
1
+ "use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[6069],{3534:(e,t,s)=>{s.d(t,{dM:()=>a,wn:()=>l});let l={antigravity:{id:"antigravity",name:"Antigravity",image:"/providers/antigravity.png",color:"#4285F4",description:"Google Antigravity IDE with MITM",configType:"mitm",mitmDomain:"daily-cloudcode-pa.googleapis.com",modelAliases:["gemini-4-argon-high","gemini-3.8-flash-high","gemini-3.8-flash-medium","gemini-3.8-flash-low","gemini-3.7-flash-high","gemini-3.7-flash-medium","gemini-3.7-flash-low","gemini-3.6-flash-high","gemini-3.6-flash-medium","gemini-3.6-flash-low","gemini-3.1-pro-high","gemini-3.1-pro-low","gemini-pro-agent","claude-sonnet-5-5","claude-sonnet-5-5-high","claude-sonnet-5-5-medium","claude-sonnet-5-5-low","claude-opus-5-5","claude-opus-5-5-high","claude-opus-5-5-medium","claude-opus-5-5-low","claude-sonnet-4-6","claude-opus-4-6-thinking","gpt-oss-120b-medium"],defaultModels:[{id:"gemini-3.8-flash-medium",name:"Gemini 3.8 Flash (Medium) / Default",alias:"gemini-3.8-flash-medium",mandatory:!0},{id:"gemini-3.8-flash-high",name:"Gemini 3.8 Flash (High)",alias:"gemini-3.8-flash-high"},{id:"gemini-3.8-flash-low",name:"Gemini 3.8 Flash (Low)",alias:"gemini-3.8-flash-low"},{id:"gemini-4-argon-high",name:"Gemini 4 Argon (High)",alias:"gemini-4-argon-high"},{id:"gemini-3.7-flash-high",name:"Gemini 3.7 Flash (High)",alias:"gemini-3.7-flash-high"},{id:"gemini-3.7-flash-medium",name:"Gemini 3.7 Flash (Medium)",alias:"gemini-3.7-flash-medium"},{id:"gemini-3.7-flash-low",name:"Gemini 3.7 Flash (Low)",alias:"gemini-3.7-flash-low"},{id:"gemini-3.6-flash-high",name:"Gemini 3.6 Flash (High)",alias:"gemini-3.6-flash-high"},{id:"gemini-3.6-flash-medium",name:"Gemini 3.6 Flash (Medium)",alias:"gemini-3.6-flash-medium"},{id:"gemini-3.6-flash-low",name:"Gemini 3.6 Flash (Low)",alias:"gemini-3.6-flash-low"},{id:"gemini-3.1-pro-high",name:"Gemini 3.1 Pro (High)",alias:"gemini-3.1-pro-high"},{id:"gemini-3.1-pro-low",name:"Gemini 3.1 Pro (Low)",alias:"gemini-3.1-pro-low"},{id:"gemini-pro-agent",name:"Gemini 3.1 Pro (High) / Legacy",alias:"gemini-pro-agent"},{id:"claude-sonnet-5-5",name:"Claude Sonnet 5.5 (Thinking)",alias:"claude-sonnet-5-5"},{id:"claude-sonnet-5-5-high",name:"Claude Sonnet 5.5 (High)",alias:"claude-sonnet-5-5-high"},{id:"claude-sonnet-5-5-medium",name:"Claude Sonnet 5.5 (Medium)",alias:"claude-sonnet-5-5-medium"},{id:"claude-sonnet-5-5-low",name:"Claude Sonnet 5.5 (Low)",alias:"claude-sonnet-5-5-low"},{id:"claude-opus-5-5",name:"Claude Opus 5.5 (Thinking)",alias:"claude-opus-5-5"},{id:"claude-opus-5-5-high",name:"Claude Opus 5.5 (High)",alias:"claude-opus-5-5-high"},{id:"claude-opus-5-5-medium",name:"Claude Opus 5.5 (Medium)",alias:"claude-opus-5-5-medium"},{id:"claude-opus-5-5-low",name:"Claude Opus 5.5 (Low)",alias:"claude-opus-5-5-low"},{id:"claude-sonnet-4-6",name:"Claude Sonnet 4.6 (Thinking)",alias:"claude-sonnet-4-6"},{id:"claude-opus-4-6-thinking",name:"Claude Opus 4.6 (Thinking)",alias:"claude-opus-4-6-thinking"},{id:"gpt-oss-120b-medium",name:"GPT-OSS 120B (Medium)",alias:"gpt-oss-120b-medium"}]},copilot:{id:"copilot",name:"GitHub Copilot",image:"/providers/copilot.png",color:"#1F6FEB",description:"GitHub Copilot IDE with MITM",configType:"mitm",mitmDomain:"api.individual.githubcopilot.com",modelAliases:["gpt-5-mini","gpt-5.4-nano","claude-haiku-4.5","gpt-4o","gpt-4.1"],defaultModels:[{id:"gpt-5-mini",name:"GPT-5 mini",alias:"gpt-5-mini"},{id:"gpt-5.4-nano",name:"GPT-5.4 nano",alias:"gpt-5.4-nano"},{id:"claude-haiku-4.5",name:"Claude Haiku 4.5",alias:"claude-haiku-4.5"},{id:"gpt-4o",name:"GPT-4o",alias:"gpt-4o"},{id:"gpt-4.1",name:"GPT-4.1",alias:"gpt-4.1"}]},kiro:{id:"kiro",name:"Kiro",image:"/providers/kiro.png",color:"#FF6B00",description:"Kiro IDE with MITM",configType:"mitm",mitmDomain:"runtime.us-east-1.kiro.dev",defaultModels:[{id:"auto",name:"Auto (Kiro agent default)",alias:"auto"},{id:"claude-sonnet-5",name:"Claude Sonnet 5",alias:"claude-sonnet-5"},{id:"claude-sonnet-4.5",name:"Claude Sonnet 4.5",alias:"claude-sonnet-4.5"},{id:"claude-sonnet-4",name:"Claude Sonnet 4",alias:"claude-sonnet-4"},{id:"claude-haiku-4.5",name:"Claude Haiku 4.5",alias:"claude-haiku-4.5"},{id:"deepseek-3.2",name:"DeepSeek 3.2",alias:"deepseek-3.2"},{id:"minimax-m2.1",name:"MiniMax M2.1",alias:"minimax-m2.1"},{id:"simple-task",name:"Qwen3 Coder Next",alias:"simple-task"}]},claude:{id:"claude",name:"Claude Desktop",image:"/providers/claude.png",color:"#D97757",description:"Anthropic Claude Desktop app (Electron). Intercepts api.anthropic.com so the desktop app routes through kRouter to whichever provider you've mapped (your Claude OAuth, Antigravity, etc.). The Claude Code CLI does NOT need this — use ANTHROPIC_BASE_URL instead.",configType:"mitm",mitmDomain:"api.anthropic.com",defaultModels:[{id:"claude-opus-4-7",name:"Claude Opus 4.7",alias:"claude-opus-4-7"},{id:"claude-opus-4-6",name:"Claude Opus 4.6",alias:"claude-opus-4-6"},{id:"claude-sonnet-4-6",name:"Claude Sonnet 4.6",alias:"claude-sonnet-4-6"},{id:"claude-sonnet-4-5",name:"Claude Sonnet 4.5",alias:"claude-sonnet-4-5"},{id:"claude-haiku-4-5",name:"Claude Haiku 4.5",alias:"claude-haiku-4-5"}]}},a={claude:{id:"claude",name:"Claude Code",image:"/providers/claude.png",color:"#D97757",description:"Anthropic Claude Code CLI",configType:"env",envVars:{baseUrl:"ANTHROPIC_BASE_URL",model:"ANTHROPIC_MODEL",opusModel:"ANTHROPIC_DEFAULT_OPUS_MODEL",sonnetModel:"ANTHROPIC_DEFAULT_SONNET_MODEL",haikuModel:"ANTHROPIC_DEFAULT_HAIKU_MODEL"},modelAliases:["default","sonnet","opus","haiku","opusplan"],settingsFile:"~/.claude/settings.json",defaultModels:[{id:"opus",name:"Claude Opus",alias:"opus",envKey:"ANTHROPIC_DEFAULT_OPUS_MODEL",defaultValue:"cc/claude-opus-4-6"},{id:"sonnet",name:"Claude Sonnet",alias:"sonnet",envKey:"ANTHROPIC_DEFAULT_SONNET_MODEL",defaultValue:"cc/claude-sonnet-4-6"},{id:"haiku",name:"Claude Haiku",alias:"haiku",envKey:"ANTHROPIC_DEFAULT_HAIKU_MODEL",defaultValue:"cc/claude-haiku-4-5-20251001"}]},openclaw:{id:"openclaw",name:"Open Claw",image:"/providers/openclaw.png",color:"#FF6B35",description:"Open Claw AI Assistant",configType:"custom"},codex:{id:"codex",name:"OpenAI Codex CLI / App",image:"/providers/codex.png",color:"#10A37F",description:"OpenAI Codex CLI",configType:"custom"},opencode:{id:"opencode",name:"OpenCode",image:"/providers/opencode.png",color:"#E87040",description:"OpenCode AI Terminal Assistant",configType:"custom"},cowork:{id:"cowork",name:"Claude Cowork",image:"/providers/claude.png",color:"#D97757",description:"Claude Desktop Cowork (third-party inference)",configType:"custom"},hermes:{id:"hermes",name:"Hermes Agent",image:"/providers/hermes.png",color:"#8B5CF6",description:"Nous Research self-improving AI agent",configType:"custom"},droid:{id:"droid",name:"Factory Droid",image:"/providers/droid.png",color:"#00D4FF",description:"Factory Droid AI Assistant",configType:"custom"},cursor:{id:"cursor",name:"Cursor",image:"/providers/cursor.png",color:"#000000",description:"Cursor AI Code Editor",configType:"guide",requiresExternalUrl:!0,notes:[{type:"warning",text:"Requires Cursor Pro account to use this feature."},{type:"cloudCheck",text:"Cursor routes requests through its own server, so local endpoint is not supported. Please enable Tunnel or Cloud Endpoint in Settings."}],guideSteps:[{step:1,title:"Open Settings",desc:"Go to Settings → Models"},{step:2,title:"Enable OpenAI API",desc:'Enable "OpenAI API key" option'},{step:3,title:"Base URL",value:"{{baseUrl}}",copyable:!0},{step:4,title:"API Key",type:"apiKeySelector"},{step:5,title:"Add Custom Model",desc:'Click "View All Model" → "Add Custom Model"'},{step:6,title:"Select Model",type:"modelSelector"}]},cline:{id:"cline",name:"Cline",image:"/providers/cline.png",color:"#00D1B2",description:"Cline AI Coding Assistant",configType:"custom"},kilo:{id:"kilo",name:"Kilo Code",image:"/providers/kilocode.png",color:"#FF6B6B",description:"Kilo Code AI Assistant",configType:"custom"},roo:{id:"roo",name:"Roo",image:"/providers/roo.png",color:"#FF6B6B",description:"Roo AI Assistant",configType:"guide",guideSteps:[{step:1,title:"Open Settings",desc:"Go to Roo Settings panel"},{step:2,title:"Select Provider",desc:"Choose API Provider → Ollama"},{step:3,title:"Base URL",value:"{{baseUrl}}",copyable:!0},{step:4,title:"API Key",type:"apiKeySelector"},{step:5,title:"Select Model",type:"modelSelector"}]},continue:{id:"continue",name:"Continue",image:"/providers/continue.png",color:"#7C3AED",description:"Continue AI Assistant",configType:"guide",guideSteps:[{step:1,title:"Open Config",desc:"Open ~/.continue/config.yaml (Windows: %USERPROFILE%\\.continue\\config.yaml). In Continue, the gear next to Local Config opens it."},{step:2,title:"API Key",type:"apiKeySelector"},{step:3,title:"Select Model",type:"modelSelector"},{step:4,title:"Add Model Config",desc:"Empty file: paste the whole block. If the file has models: [] (Continue's default), replace that line with the models: section below. If models: already lists entries, add only the - name: entry under them."}],codeBlock:{language:"yaml",code:`name: kRouter
2
+ version: 0.0.1
3
+ schema: v1
4
+ models:
5
+ - name: "{{model}} (kRouter)"
6
+ provider: openai
7
+ model: "{{model}}"
8
+ apiBase: "{{baseUrl}}"
9
+ apiKey: "{{apiKey}}"`}},amp:{id:"amp",name:"Amp CLI",image:"/providers/amp.png",color:"#F97316",description:"Sourcegraph Amp coding assistant CLI",docsUrl:"/docs?section=cli-tools&tool=amp",configType:"guide",defaultCommand:"amp",modelAliases:["g25p","g25f","cs45","g54"],notes:[{type:"info",text:"Use kRouter model aliases to keep Amp shorthand mappings stable across provider updates."},{type:"warning",text:"Suggested shorthand examples: g25p → gemini/gemini-2.5-pro, g25f → gemini/gemini-2.5-flash, cs45 → cc/claude-sonnet-4-5-20250929."}],guideSteps:[{step:1,title:"Install Amp",desc:"Install the Amp CLI using the package manager supported by your environment."},{step:2,title:"API Key",type:"apiKeySelector"},{step:3,title:"Base URL",value:"{{baseUrl}}",copyable:!0},{step:4,title:"Select Model",type:"modelSelector"},{step:5,title:"Add Shorthands",desc:"Map Amp shorthand names such as g25p or cs45 to kRouter aliases in your local config."}],codeBlock:{language:"bash",code:`export OPENAI_API_KEY="{{apiKey}}"
10
+ export OPENAI_BASE_URL="{{baseUrl}}"
11
+ amp --model "{{model}}"
12
+ # Example shorthand aliases you can map locally:
13
+ # g25p -> gemini/gemini-2.5-pro
14
+ # cs45 -> cc/claude-sonnet-4-5-20250929`}},qwen:{id:"qwen",name:"Qwen Code",image:"/providers/qwen.png",color:"#10B981",description:"Alibaba Qwen Code CLI — supports OpenAI, Anthropic & Gemini providers via kRouter",docsUrl:"https://qwenlm.github.io/qwen-code-docs/en/users/configuration/model-providers/",configType:"guide",defaultCommand:"qwen",notes:[{type:"info",text:"Qwen Code supports multiple provider types (openai, anthropic, gemini) via modelProviders in settings.json. kRouter works as an OpenAI-compatible endpoint."},{type:"info",text:"Any model available in kRouter can be used — not just Qwen models. Select from Qwen, Claude, Gemini, GPT, and more."},{type:"warning",text:"Config path: Linux/macOS ~/.qwen/settings.json • Windows %USERPROFILE%\\.qwen\\settings.json"},{type:"error",text:"Qwen OAuth free tier was discontinued on 2026-04-15. Use kRouter with alicode/openrouter/anthropic/gemini providers instead."}],modelAliases:["coder-model","qwen3-coder-plus","qwen3-coder-flash","vision-model","claude-sonnet-4-6","claude-opus-4-6-thinking","gemini-3-flash","gemini-3.1-pro-high"],defaultModels:[{id:"coder-model",name:"Coder Model (Qwen 3.6 Plus)",alias:"coder-model",envKey:"OPENAI_MODEL",defaultValue:"coder-model",isTopLevel:!0},{id:"qwen3-coder-plus",name:"Qwen 3 Coder Plus",alias:"qwen3-coder-plus",envKey:"OPENAI_MODEL",defaultValue:"qwen3-coder-plus"},{id:"qwen3-coder-flash",name:"Qwen 3 Coder Flash",alias:"qwen3-coder-flash",envKey:"OPENAI_MODEL",defaultValue:"qwen3-coder-flash"},{id:"vision-model",name:"Vision Model (Multimodal)",alias:"vision-model",envKey:"OPENAI_MODEL",defaultValue:"vision-model"},{id:"claude-sonnet-4-6",name:"Claude Sonnet 4.6",alias:"claude-sonnet-4-6",envKey:"OPENAI_MODEL",defaultValue:"claude-sonnet-4-6"},{id:"claude-opus-4-6-thinking",name:"Claude Opus 4.6 Thinking",alias:"claude-opus-4-6-thinking",envKey:"OPENAI_MODEL",defaultValue:"claude-opus-4-6-thinking"},{id:"gemini-3.1-pro-high",name:"Gemini 3.1 Pro High",alias:"gemini-3.1-pro-high",envKey:"OPENAI_MODEL",defaultValue:"gemini-3.1-pro-high"},{id:"gemini-3-flash",name:"Gemini 3 Flash",alias:"gemini-3-flash",envKey:"OPENAI_MODEL",defaultValue:"gemini-3-flash"}],guideSteps:[{step:1,title:"Install Qwen Code",desc:"npm install -g @qwen-code/qwen-code"},{step:2,title:"API Key",type:"apiKeySelector"},{step:3,title:"Base URL",value:"{{baseUrl}}",copyable:!0},{step:4,title:"Select Model",type:"modelSelector"},{step:5,title:"Save Config",desc:"Copy the JSON below to your ~/.qwen/settings.json file."}],codeBlock:{language:"json",code:`{
15
+ "security": {
16
+ "auth": {
17
+ "selectedType": "openai",
18
+ "apiKey": "{{apiKey}}",
19
+ "baseUrl": "{{baseUrl}}"
20
+ }
21
+ },
22
+ "model": {
23
+ "name": "{{model}}"
24
+ }
25
+ }`}},"deepseek-tui":{id:"deepseek-tui",name:"DeepSeek TUI",image:"/providers/deepseek-tui.png",color:"#4D6BFE",description:"DeepSeek Terminal Coding Agent (Rust TUI)",docsUrl:"https://github.com/DeepSeek-TUI/DeepSeek-TUI",configType:"custom",defaultCommand:"deepseek",modelAliases:["deepseek-v4-pro","deepseek-v4-flash","deepseek-chat","deepseek-reasoner"],defaultModels:[{id:"deepseek-v4-pro",name:"DeepSeek V4 Pro",alias:"deepseek-v4-pro"},{id:"deepseek-v4-flash",name:"DeepSeek V4 Flash",alias:"deepseek-v4-flash"},{id:"deepseek-chat",name:"DeepSeek V3 Chat",alias:"deepseek-chat"}],notes:[{type:"info",text:"DeepSeek TUI uses ~/.deepseek/config.toml for configuration. kRouter will update the provider to 'openai' mode with your base_url, api_key, and model."},{type:"warning",text:"Config path: Linux/macOS ~/.deepseek/config.toml • Windows %USERPROFILE%\\.deepseek\\config.toml"}]},jcode:{id:"jcode",name:"jcode",image:"/providers/jcode.png",color:"#FF6B35",description:"High-performance Rust-based coding agent harness",configType:"custom",docsUrl:"https://github.com/1jehuang/jcode",notes:[{type:"info",text:"jcode is a Rust-based coding agent with semantic memory, multi-agent swarms, and extreme performance (27.8 MB RAM, 14ms boot)."},{type:"info",text:"Configure kRouter as an OpenAI-compatible provider to route all jcode requests through kRouter's optimization layer."},{type:"warning",text:"Requires jcode installed. Install via: curl -fsSL https://raw.githubusercontent.com/1jehuang/jcode/master/scripts/install.sh | bash"}],defaultModels:[{id:"claude-opus-4-7",name:"Claude Opus 4.7",alias:"opus",defaultValue:"cc/claude-opus-4-7"},{id:"claude-sonnet-4-6",name:"Claude Sonnet 4.6",alias:"sonnet",defaultValue:"cc/claude-sonnet-4-6"},{id:"gpt-6.1-sol",name:"GPT 6.1 Sol",alias:"gpt5",defaultValue:"cx/gpt-6.1-sol"},{id:"gemini-3.1-pro",name:"Gemini 3.1 Pro",alias:"gemini",defaultValue:"gemini/gemini-3.1-pro"}]},opendesign:{id:"opendesign",name:"OpenDesign",image:"/providers/opendesign.png",color:"#7C3AED",description:"OpenDesign — claude.ai/design open-sourced! Agent-native design skills pack",docsUrl:"https://github.com/manalkaff/opendesign",configType:"guide",notes:[{type:"info",text:"OpenDesign ships as a plugin/skills pack installed into Claude Code, Cursor, OpenAI Codex, Gemini CLI, or OpenCode. It inherits the host agent's model config, so once your host points at kRouter, /opendesign design sessions route through kRouter automatically — no extra env vars needed."},{type:"info",text:"Invoke with /opendesign <brief>. Covers decks, wireframes, interactive prototypes, design-system extraction, and brand systems, with a verifier subagent that checks output against the brief."}],guideSteps:[{step:1,title:"Install the plugin",desc:"Pick your host below and run the matching install command from the matrix."},{step:2,title:"No config needed",desc:"OpenDesign runs inside your host agent and uses its model config. If the host already routes through kRouter, /opendesign traffic does too."},{step:3,title:"Start designing",desc:"Invoke OpenDesign from your agent:",value:"/opendesign make a pitch deck for a seed-stage AI company, 10 slides",copyable:!0}],codeBlock:{language:"bash",code:`# Claude Code
26
+ /plugin marketplace add manalkaff/opendesign
27
+ /plugin install opendesign@opendesign
28
+
29
+ # Cursor
30
+ /add-plugin opendesign
31
+
32
+ # OpenAI Codex CLI
33
+ /plugins # search "opendesign" -> Install Plugin
34
+
35
+ # Gemini CLI
36
+ gemini extensions install https://github.com/manalkaff/opendesign
37
+
38
+ # OpenCode
39
+ # Fetch and follow .opencode/INSTALL.md from the repo`}}}},40295:e=>{e.exports={TOOL_HOSTS:{antigravity:["daily-cloudcode-pa.googleapis.com","cloudcode-pa.googleapis.com"],copilot:["api.individual.githubcopilot.com"],kiro:["runtime.us-east-1.kiro.dev","q.us-east-1.amazonaws.com","codewhisperer.us-east-1.amazonaws.com"],cursor:["api2.cursor.sh"],claude:["api.anthropic.com"]}}},43666:(e,t,s)=>{s.d(t,{Tk:()=>b,aG:()=>P,Ah:()=>j,h1:()=>I,Q6:()=>M,lF:()=>$,a7:()=>S,ZM:()=>v,RF:()=>C,mW:()=>U,c9:()=>R,gY:()=>H,tA:()=>D,kn:()=>z,yZ:()=>w,qO:()=>E});var l=s(95155),a=s(12115),r=s(35497),i=s(5772),n=s(90620);let o="krouter.cliToolEndpointPresets",d="__custom__",c="__save__",m=e=>{window.localStorage.setItem(o,JSON.stringify(e))};function x({value:e,onChange:t,requiresExternalUrl:s=!1,tunnelEnabled:r=!1,tunnelPublicUrl:i="",tailscaleEnabled:p=!1,tailscaleUrl:u="",cloudEnabled:h=!1,cloudUrl:g="",withV1:f=!0}){let[y,b]=(0,a.useState)([]),[j,N]=(0,a.useState)(""),[v,w]=(0,a.useState)(""),k=(0,a.useRef)(!1);(0,a.useEffect)(()=>{b((()=>{try{let e=window.localStorage.getItem(o),t=JSON.parse(e||"[]");if(!Array.isArray(t))return[];return t.filter(e=>e?.name&&e?.baseUrl)}catch{return[]}})())},[]);let C=(0,a.useMemo)(()=>(({requiresExternalUrl:e,tunnelEnabled:t,tunnelPublicUrl:s,tailscaleEnabled:l,tailscaleUrl:a,cloudEnabled:r,cloudUrl:i,savedPresets:o,withV1:c})=>{let m=[],x=e=>{let t;return c?(t=(e||"").replace(/\/+$/,""))?/\/v1$/.test(t)?t:`${t}/v1`:"":(e||"").replace(/\/+$/,"")};if(!e){let e=x(`http://127.0.0.1:${n.h0.appPort}`);m.push({value:"local",label:e,url:e})}if(t&&s){let e=x(s);m.push({value:"tunnel",label:e,url:e})}if(l&&a){let e=x(a);m.push({value:"tailscale",label:e,url:e})}if(r&&i){let e=x(i);m.push({value:"cloud",label:e,url:e})}return o.forEach(e=>{m.push({value:`saved:${e.name}`,label:e.baseUrl,url:e.baseUrl,saved:!0})}),m.push({value:d,label:"Custom URL...",url:""}),m})({requiresExternalUrl:s,tunnelEnabled:r,tunnelPublicUrl:i,tailscaleEnabled:p,tailscaleUrl:u,cloudEnabled:h,cloudUrl:g,savedPresets:y,withV1:f}),[s,r,i,p,u,h,g,y,f]);(0,a.useEffect)(()=>{if(k.current||0===C.length)return;k.current=!0;let e=C.find(e=>e.value!==d);e?(N(e.value),t(e.url)):N(d)},[C,t]);let _=j.startsWith("saved:"),S=j===d,E=S&&(v||"").trim().length>0;return(0,l.jsxs)("div",{className:"flex flex-col gap-1.5",children:[(0,l.jsxs)("div",{className:"flex items-center gap-2",children:[(0,l.jsxs)("select",{value:j,onChange:s=>{let l=s.target.value;if(l===c){let t=(e||"").trim();if(!t)return;let s=t;try{s=new URL(t).host}catch{}let l=window.prompt("Save endpoint as:",s);if(!l?.trim())return;let a=[...y.filter(e=>e.name!==l.trim()),{name:l.trim(),baseUrl:t}].sort((e,t)=>e.name.localeCompare(t.name));b(a),m(a);return}if(N(l),l===d){w(""),t("");return}let a=C.find(e=>e.value===l);a&&t(a.url)},className:"flex-1 min-w-0 px-2 py-2 bg-surface rounded text-xs border border-border focus:outline-none focus:ring-1 focus:ring-primary/50 sm:py-1.5",children:[C.map(e=>(0,l.jsx)("option",{value:e.value,children:e.label},e.value)),E&&(0,l.jsx)("option",{value:c,children:"+ Save current as..."})]}),_&&(0,l.jsx)("button",{type:"button",onClick:()=>{if(!j.startsWith("saved:"))return;let e=j.slice(6),s=y.filter(t=>t.name!==e);b(s),m(s),N(d),w(""),t("")},className:"p-1 text-text-muted hover:text-red-500 rounded transition-colors shrink-0",title:"Delete saved endpoint",children:(0,l.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"delete"})})]}),S&&(0,l.jsx)("input",{type:"text",value:v,onChange:e=>{let s=e.target.value;w(s),t(s)},placeholder:f?"https://example.com/v1":"https://example.com",className:"w-full min-w-0 px-2 py-2 bg-surface rounded border border-border text-xs focus:outline-none focus:ring-1 focus:ring-primary/50 sm:py-1.5"})]})}let p="__custom__";function u({value:e,onChange:t,apiKeys:s=[],cloudEnabled:r=!1,className:i=""}){let n=!s.some(t=>t.key===e)&&""!==e,[o,d]=(0,a.useState)(()=>e?s.some(t=>t.key===e)?e:p:s.length>0?s[0].key:p),[c,m]=(0,a.useState)(n?e:"");return 0===s.length&&o!==p&&o!==p?(0,l.jsx)("span",{className:`min-w-0 rounded bg-surface/40 px-2 py-2 text-xs text-text-muted sm:py-1.5 ${i}`,children:r?"No API keys - Create one in Keys page":"sk_krouter (default)"}):(0,l.jsxs)("div",{className:`flex flex-col gap-1.5 ${i}`,children:[(0,l.jsxs)("select",{value:o,onChange:e=>{let s=e.target.value;d(s),s===p?(m(""),t("")):t(s)},className:"w-full min-w-0 px-2 py-2 bg-surface rounded text-xs border border-border focus:outline-none focus:ring-1 focus:ring-primary/50 sm:py-1.5",children:[s.map(e=>(0,l.jsx)("option",{value:e.key,children:e.key},e.id)),(0,l.jsx)("option",{value:p,children:"Custom..."})]}),o===p&&(0,l.jsx)("input",{type:"text",value:c,onChange:e=>{let s=e.target.value;m(s),t(s)},placeholder:"sk-...",className:"w-full min-w-0 px-2 py-2 bg-surface rounded border border-border text-xs focus:outline-none focus:ring-1 focus:ring-primary/50 sm:py-1.5"})]})}let h=e=>(e||"").replace(/\/+$/,"");function g(e,t={}){if(!e)return!1;let s=h(e),{tunnelPublicUrl:l,tailscaleUrl:a,cloudUrl:r}=t;return!!(/localhost|127\.0\.0\.1|0\.0\.0\.0/.test(s)||l&&s.startsWith(h(l))||a&&s.startsWith(h(a))||r&&s.startsWith(h(r)))}let f=s(41463).env.NEXT_PUBLIC_CLOUD_URL,y=[{label:"Default",value:""},{label:"200K",value:"198000"},{label:"300K",value:"298000"},{label:"500K",value:"498000"},{label:"1M",value:"998000"}];function b({tool:e,isExpanded:t,onToggle:s,activeProviders:n,modelMappings:o,onModelMappingChange:d,baseUrl:c,hasActiveProviders:m,apiKeys:p,cloudEnabled:h,initialStatus:j,tunnelEnabled:N,tunnelPublicUrl:v,tailscaleEnabled:w,tailscaleUrl:k}){let C,_,S,[E,A]=(0,a.useState)(j||null),[O,M]=(0,a.useState)(!1),[I,P]=(0,a.useState)(!1),[R,T]=(0,a.useState)(!1),[$,U]=(0,a.useState)(null),[K,D]=(0,a.useState)(!1),[L,z]=(0,a.useState)(!1),[F,q]=(0,a.useState)(null),[H,B]=(0,a.useState)(""),[G,J]=(0,a.useState)({}),[V,W]=(0,a.useState)(!1),[Y,Z]=(0,a.useState)(""),[Q,X]=(0,a.useState)(!1),[ee,et]=(0,a.useState)(""),es=(0,a.useRef)(!1),el=(()=>{if(!E?.installed)return null;let e=E.settings?.env?.ANTHROPIC_BASE_URL;return e?g(e,{tunnelPublicUrl:v,tailscaleUrl:k,cloudUrl:h?f:null})?"configured":"other":"not_configured"})();(0,a.useEffect)(()=>{p?.length>0&&!H&&B(p[0].key)},[p,H]),(0,a.useEffect)(()=>{j&&A(j)},[j]),(0,a.useEffect)(()=>{t&&!E&&(ei(),er()),t&&er()},[t]),(0,a.useEffect)(()=>{fetch("/api/settings").then(e=>e.json()).then(e=>{X(!!e.ccFilterNaming)}).catch(()=>{})},[]);let ea=async e=>{let t=e.target.checked;X(t),await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({ccFilterNaming:t})}).catch(()=>{})},er=async()=>{try{let e=await fetch("/api/models/alias"),t=await e.json();e.ok&&J(t.aliases||{})}catch(e){console.log("Error fetching model aliases:",e)}};(0,a.useEffect)(()=>{if(E?.installed&&!es.current){es.current=!0;let t=E.settings?.env||{};e.defaultModels.forEach(e=>{if(e.envKey){let s=t[e.envKey]||e.defaultValue||"";s&&d(e.alias,s)}});let s=t.ANTHROPIC_AUTH_TOKEN;s&&p?.some(e=>e.key===s)&&B(s),et(t.CLAUDE_CODE_MAX_CONTEXT_TOKENS||"")}},[E,p,e.defaultModels,d]);let ei=async()=>{M(!0);try{let e=await fetch("/api/cli-tools/claude-settings"),t=await e.json();A(t)}catch(e){A({installed:!1,error:e.message})}finally{M(!1)}},en=()=>{let e=Y||c;return e.endsWith("/v1")?e:`${e}/v1`},eo=async()=>{P(!0),U(null);try{let t={ANTHROPIC_BASE_URL:en()},s=H?.trim()||(p?.length>0?p[0].key:null)||(h?null:"sk_krouter");s&&(t.ANTHROPIC_AUTH_TOKEN=s),e.defaultModels.forEach(e=>{let s=o[e.alias];s&&e.envKey&&(t[e.envKey]=s)}),ee&&(t.CLAUDE_CODE_MAX_CONTEXT_TOKENS=ee);let l=await fetch("/api/cli-tools/claude-settings",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({env:t})}),a=await l.json();l.ok?(U({type:"success",text:"Settings applied successfully!"}),A(e=>({...e,hasBackup:!0,settings:{...e?.settings,env:t}}))):U({type:"error",text:a.error||"Failed to apply settings"})}catch(e){U({type:"error",text:e.message})}finally{P(!1)}},ed=async()=>{T(!0),U(null);try{let t=await fetch("/api/cli-tools/claude-settings",{method:"DELETE"}),s=await t.json();t.ok?(U({type:"success",text:"Settings reset successfully!"}),e.defaultModels.forEach(e=>d(e.alias,e.defaultValue||"")),B(""),et("")):U({type:"error",text:s.error||"Failed to reset settings"})}catch(e){U({type:"error",text:e.message})}finally{T(!1)}};return(0,l.jsxs)(r.Zp,{padding:"xs",className:"overflow-hidden",children:[(0,l.jsxs)("div",{className:"flex items-start justify-between gap-3 hover:cursor-pointer sm:items-center",onClick:s,children:[(0,l.jsxs)("div",{className:"flex min-w-0 items-center gap-3",children:[(0,l.jsx)("div",{className:"size-8 flex items-center justify-center shrink-0",children:(0,l.jsx)(i.A,{src:"/providers/claude.png",alt:e.name,width:32,height:32,className:"size-8 object-contain rounded-lg",sizes:"32px",onError:e=>{e.target.style.display="none"}})}),(0,l.jsxs)("div",{className:"min-w-0",children:[(0,l.jsxs)("div",{className:"flex min-w-0 flex-wrap items-center gap-2",children:[(0,l.jsx)("h3",{className:"font-medium text-sm",children:e.name}),"configured"===el&&(0,l.jsx)("span",{className:"px-1.5 py-0.5 text-[10px] font-medium bg-green-500/10 text-green-600 dark:text-green-400 rounded-full",children:"Connected"}),"not_configured"===el&&(0,l.jsx)("span",{className:"px-1.5 py-0.5 text-[10px] font-medium bg-yellow-500/10 text-yellow-600 dark:text-yellow-400 rounded-full",children:"Not configured"}),"other"===el&&(0,l.jsx)("span",{className:"px-1.5 py-0.5 text-[10px] font-medium bg-blue-500/10 text-blue-600 dark:text-blue-400 rounded-full",children:"Other"})]}),(0,l.jsx)("p",{className:"text-xs text-text-muted truncate",children:e.description})]})]}),(0,l.jsx)("span",{className:`material-symbols-outlined text-text-muted text-[20px] transition-transform ${t?"rotate-180":""}`,children:"expand_more"})]}),t&&(0,l.jsxs)("div",{className:"mt-4 pt-4 border-t border-border flex flex-col gap-4",children:[O&&(0,l.jsxs)("div",{className:"flex items-center gap-2 text-text-muted",children:[(0,l.jsx)("span",{className:"material-symbols-outlined animate-spin",children:"progress_activity"}),(0,l.jsx)("span",{children:"Checking Claude CLI..."})]}),!O&&E&&!E.installed&&(0,l.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,l.jsxs)("div",{className:"flex flex-col gap-3 p-4 bg-yellow-500/10 border border-yellow-500/30 rounded-lg",children:[(0,l.jsxs)("div",{className:"flex items-start gap-3",children:[(0,l.jsx)("span",{className:"material-symbols-outlined text-yellow-500",children:"warning"}),(0,l.jsxs)("div",{className:"flex-1",children:[(0,l.jsx)("p",{className:"font-medium text-yellow-600 dark:text-yellow-400",children:"Claude CLI not detected locally"}),(0,l.jsx)("p",{className:"text-sm text-text-muted",children:"Manual configuration is still available if kRouter is deployed on a remote server."})]})]}),(0,l.jsxs)("div",{className:"flex items-center gap-2 pl-9",children:[(0,l.jsxs)(r.$n,{variant:"secondary",size:"sm",onClick:()=>W(!0),className:"!bg-yellow-500/20 !border-yellow-500/40 !text-yellow-700 dark:!text-yellow-300 hover:!bg-yellow-500/30",children:[(0,l.jsx)("span",{className:"material-symbols-outlined text-[18px] mr-1",children:"content_copy"}),"Manual Config"]}),(0,l.jsxs)(r.$n,{variant:"outline",size:"sm",onClick:()=>D(!K),children:[(0,l.jsx)("span",{className:"material-symbols-outlined text-[18px] mr-1",children:K?"expand_less":"help"}),K?"Hide":"How to Install"]})]})]}),K&&(0,l.jsxs)("div",{className:"p-4 bg-surface border border-border rounded-lg",children:[(0,l.jsx)("h4",{className:"font-medium mb-3",children:"Installation Guide"}),(0,l.jsxs)("div",{className:"space-y-3 text-sm",children:[(0,l.jsxs)("div",{children:[(0,l.jsx)("p",{className:"text-text-muted mb-1",children:"macOS / Linux / Windows:"}),(0,l.jsx)("code",{className:"block px-3 py-2 bg-black/5 dark:bg-white/5 rounded font-mono text-xs",children:"npm install -g @anthropic-ai/claude-code"})]}),(0,l.jsxs)("p",{className:"text-text-muted",children:["After installation, run ",(0,l.jsx)("code",{className:"px-1 bg-black/5 dark:bg-white/5 rounded",children:"claude"})," to verify."]})]})]})]}),!O&&E?.installed&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,l.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr] sm:items-center sm:gap-2",children:[(0,l.jsx)("span",{className:"text-xs font-semibold text-text-main sm:text-right sm:text-sm",children:"Select Endpoint"}),(0,l.jsx)("span",{className:"material-symbols-outlined hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,l.jsx)(x,{value:Y||((C=Y||c).endsWith("/v1")?C:`${C}/v1`),onChange:Z,requiresExternalUrl:e.requiresExternalUrl,tunnelEnabled:N,tunnelPublicUrl:v,tailscaleEnabled:w,tailscaleUrl:k})]}),E?.settings?.env?.ANTHROPIC_BASE_URL&&(0,l.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr_auto] sm:items-center sm:gap-2",children:[(0,l.jsx)("span",{className:"text-xs font-semibold text-text-main sm:text-right sm:text-sm",children:"Current"}),(0,l.jsx)("span",{className:"material-symbols-outlined hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,l.jsx)("span",{className:"min-w-0 truncate rounded bg-surface/40 px-2 py-2 text-xs text-text-muted sm:py-1.5",children:E.settings.env.ANTHROPIC_BASE_URL})]}),(0,l.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr_auto] sm:items-center sm:gap-2",children:[(0,l.jsx)("span",{className:"text-xs font-semibold text-text-main sm:text-right sm:text-sm",children:"API Key"}),(0,l.jsx)("span",{className:"material-symbols-outlined hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,l.jsx)(u,{value:H,onChange:B,apiKeys:p,cloudEnabled:h})]}),e.defaultModels.map(e=>(0,l.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr_auto] sm:items-center sm:gap-2",children:[(0,l.jsx)("span",{className:"text-xs font-semibold text-text-main sm:text-right sm:text-sm",children:e.name}),(0,l.jsx)("span",{className:"material-symbols-outlined hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,l.jsxs)("div",{className:"relative w-full min-w-0",children:[(0,l.jsx)("input",{type:"text",value:o[e.alias]||"",onChange:t=>d(e.alias,t.target.value),placeholder:"provider/model-id",className:"w-full min-w-0 pl-2 pr-7 py-2 bg-surface rounded border border-border text-xs focus:outline-none focus:ring-1 focus:ring-primary/50 sm:py-1.5"}),o[e.alias]&&(0,l.jsx)("button",{onClick:()=>d(e.alias,""),className:"absolute right-1 top-1/2 -translate-y-1/2 p-0.5 text-text-muted hover:text-red-500 rounded transition-colors",title:"Clear",children:(0,l.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"close"})})]}),(0,l.jsx)("button",{onClick:()=>{q(e.alias),z(!0)},disabled:!m,className:`w-full sm:w-auto rounded border px-2 py-2 text-xs transition-colors sm:py-1.5 whitespace-nowrap sm:shrink-0 ${m?"bg-surface border-border text-text-main hover:border-primary cursor-pointer":"opacity-50 cursor-not-allowed border-border"}`,children:"Select Model"})]},e.alias)),(0,l.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr_auto] sm:items-center sm:gap-2",children:[(0,l.jsx)("span",{className:"text-xs font-semibold text-text-main sm:text-right sm:text-sm",children:"Filter naming"}),(0,l.jsx)("span",{className:"material-symbols-outlined hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,l.jsxs)("label",{className:"flex items-center gap-1.5 cursor-pointer select-none",children:[(0,l.jsx)("input",{type:"checkbox",checked:Q,onChange:ea,className:"w-3.5 h-3.5 accent-primary cursor-pointer"}),(0,l.jsx)("span",{className:"text-xs text-text-muted",children:"Filter naming requests"})]}),(0,l.jsx)(r.m_,{text:"Intercepts Claude Code's topic-naming requests and returns a fake response locally, saving API tokens.",children:(0,l.jsx)("span",{className:"material-symbols-outlined text-text-muted text-[14px] cursor-help",children:"info"})})]}),(0,l.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr_auto] sm:items-center sm:gap-2",children:[(0,l.jsx)("span",{className:"text-xs font-semibold text-text-main sm:text-right sm:text-sm",children:"Max context"}),(0,l.jsx)("span",{className:"material-symbols-outlined hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,l.jsx)("select",{value:ee,onChange:e=>et(e.target.value),className:"w-full min-w-0 pl-2 pr-7 py-2 bg-surface rounded border border-border text-xs focus:outline-none focus:ring-1 focus:ring-primary/50 sm:py-1.5",children:y.map(e=>(0,l.jsx)("option",{value:e.value,children:e.label},e.label))}),(0,l.jsx)(r.m_,{text:"Overrides Claude Code's context window (CLAUDE_CODE_MAX_CONTEXT_TOKENS). Applied when you click Apply Settings.",children:(0,l.jsx)("span",{className:"material-symbols-outlined text-text-muted text-[14px] cursor-help",children:"info"})})]})]}),$&&(0,l.jsxs)("div",{className:`flex items-center gap-2 px-2 py-1.5 rounded text-xs ${"success"===$.type?"bg-green-500/10 text-green-600":"bg-red-500/10 text-red-600"}`,children:[(0,l.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"success"===$.type?"check_circle":"error"}),(0,l.jsx)("span",{children:$.text})]}),(0,l.jsxs)("div",{className:"grid grid-cols-1 gap-2 sm:flex sm:items-center",children:[(0,l.jsxs)(r.$n,{variant:"primary",size:"sm",onClick:eo,disabled:!m,loading:I,children:[(0,l.jsx)("span",{className:"material-symbols-outlined text-[14px] mr-1",children:"save"}),"Apply"]}),(0,l.jsxs)(r.$n,{variant:"outline",size:"sm",onClick:ed,disabled:!E?.hasKRouter,loading:R,children:[(0,l.jsx)("span",{className:"material-symbols-outlined text-[14px] mr-1",children:"restore"}),"Reset"]}),(0,l.jsxs)(r.$n,{variant:"ghost",size:"sm",onClick:()=>W(!0),children:[(0,l.jsx)("span",{className:"material-symbols-outlined text-[14px] mr-1",children:"content_copy"}),"Manual Config"]})]})]})]}),(0,l.jsx)(r.rq,{isOpen:L,onClose:()=>z(!1),onSelect:e=>{F&&d(F,e.value)},selectedModel:F?o[F]:null,activeProviders:n,modelAliases:G,title:`Select model for ${F}`}),(0,l.jsx)(r.uR,{isOpen:V,onClose:()=>W(!1),title:"Claude CLI - Manual Configuration",configs:(_=H&&H.trim()?H:h?"<API_KEY_FROM_DASHBOARD>":"sk_krouter",S={ANTHROPIC_BASE_URL:en(),ANTHROPIC_AUTH_TOKEN:_},e.defaultModels.forEach(e=>{let t=o[e.alias];t&&e.envKey&&(S[e.envKey]=t)}),ee&&(S.CLAUDE_CODE_MAX_CONTEXT_TOKENS=ee),[{filename:"~/.claude/settings.json",content:JSON.stringify({hasCompletedOnboarding:!0,env:S},null,2)}])})]})}function j({tool:e,isExpanded:t,onToggle:s,baseUrl:n,apiKeys:o,activeProviders:d,cloudEnabled:c,initialStatus:m,tunnelEnabled:p,tunnelPublicUrl:h,tailscaleEnabled:f,tailscaleUrl:y}){let b,N,[v,w]=(0,a.useState)(m||null),[k,C]=(0,a.useState)(!1),[_,S]=(0,a.useState)(!1),[E,A]=(0,a.useState)(!1),[O,M]=(0,a.useState)(null),[I,P]=(0,a.useState)(!1),[R,T]=(0,a.useState)(""),[$,U]=(0,a.useState)(""),[K,D]=(0,a.useState)(""),[L,z]=(0,a.useState)(!1),[F,q]=(0,a.useState)(!1),[H,B]=(0,a.useState)({}),[G,J]=(0,a.useState)(!1),[V,W]=(0,a.useState)("");(0,a.useEffect)(()=>{o?.length>0&&!R&&T(o[0].key)},[o,R]),(0,a.useEffect)(()=>{m&&w(m)},[m]),(0,a.useEffect)(()=>{t&&!v&&(et(),Y()),t&&Y()},[t]);let Y=async()=>{try{let e=await fetch("/api/models/alias"),t=await e.json();e.ok&&B(t.aliases||{})}catch(e){console.log("Error fetching model aliases:",e)}};(0,a.useEffect)(()=>{if(v?.config){let e=v.config.match(/^model\s*=\s*"([^"]+)"/m);e&&U(e[1]);let t=v.config.match(/^default_subagent_model\s*=\s*"([^"]+)"/m);t&&D(t[1])}},[v]);let Z=v?.activeProvider?.baseUrl||"",Q=v?.activeProvider?.apiKey||"";(0,a.useEffect)(()=>{Q&&o?.some(e=>e.key===Q)&&T(Q)},[Q,o]);let X=v?.installed?v.config?g(Z,{tunnelPublicUrl:h,tailscaleUrl:y})?"configured":"other":"not_configured":null,ee=()=>{let e=(V||`${n}/v1`).replace(/\/+$/,"");return e.endsWith("/v1")?e:`${e}/v1`},et=async()=>{C(!0);try{let e=await fetch("/api/cli-tools/codex-settings",{cache:"no-store"}),t=await e.json();w(t)}catch(e){w({installed:!1,error:e.message})}finally{C(!1)}},es=async()=>{S(!0),M(null);try{let e=R&&R.trim()||c?R:"sk_krouter",t=await fetch("/api/cli-tools/codex-settings",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({baseUrl:ee(),apiKey:e,model:$,subagentModel:K||$})}),s=await t.json();t.ok?(M({type:"success",text:"Settings applied successfully!"}),et()):M({type:"error",text:s.error||"Failed to apply settings"})}catch(e){M({type:"error",text:e.message})}finally{S(!1)}},el=async()=>{A(!0),M(null);try{let e=await fetch("/api/cli-tools/codex-settings",{method:"DELETE"}),t=await e.json();e.ok?(M({type:"success",text:"Settings reset successfully!"}),U(""),D(""),et()):M({type:"error",text:t.error||"Failed to reset settings"})}catch(e){M({type:"error",text:e.message})}finally{A(!1)}};return(0,l.jsxs)(r.Zp,{padding:"xs",className:"overflow-hidden",children:[(0,l.jsxs)("div",{className:"flex items-start justify-between gap-3 hover:cursor-pointer sm:items-center",onClick:s,children:[(0,l.jsxs)("div",{className:"flex min-w-0 items-center gap-3",children:[(0,l.jsx)("div",{className:"size-8 flex items-center justify-center shrink-0",children:(0,l.jsx)(i.A,{src:"/providers/codex.png",alt:e.name,width:32,height:32,className:"size-8 object-contain rounded-lg",sizes:"32px",onError:e=>{e.target.style.display="none"}})}),(0,l.jsxs)("div",{className:"min-w-0",children:[(0,l.jsxs)("div",{className:"flex min-w-0 flex-wrap items-center gap-2",children:[(0,l.jsx)("h3",{className:"font-medium text-sm",children:e.name}),"configured"===X&&(0,l.jsx)("span",{className:"px-1.5 py-0.5 text-[10px] font-medium bg-green-500/10 text-green-600 dark:text-green-400 rounded-full",children:"Connected"}),"not_configured"===X&&(0,l.jsx)("span",{className:"px-1.5 py-0.5 text-[10px] font-medium bg-yellow-500/10 text-yellow-600 dark:text-yellow-400 rounded-full",children:"Not configured"}),"other"===X&&(0,l.jsx)("span",{className:"px-1.5 py-0.5 text-[10px] font-medium bg-blue-500/10 text-blue-600 dark:text-blue-400 rounded-full",children:"Other"})]}),(0,l.jsx)("p",{className:"text-xs text-text-muted truncate",children:e.description})]})]}),(0,l.jsx)("span",{className:`material-symbols-outlined text-text-muted text-[20px] transition-transform ${t?"rotate-180":""}`,children:"expand_more"})]}),t&&(0,l.jsxs)("div",{className:"mt-4 pt-4 border-t border-border flex flex-col gap-4",children:[k&&(0,l.jsxs)("div",{className:"flex items-center gap-2 text-text-muted",children:[(0,l.jsx)("span",{className:"material-symbols-outlined animate-spin",children:"progress_activity"}),(0,l.jsx)("span",{children:"Checking Codex CLI..."})]}),!k&&v&&!v.installed&&(0,l.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,l.jsxs)("div",{className:"flex flex-col gap-3 p-4 bg-yellow-500/10 border border-yellow-500/30 rounded-lg",children:[(0,l.jsxs)("div",{className:"flex items-start gap-3",children:[(0,l.jsx)("span",{className:"material-symbols-outlined text-yellow-500",children:"warning"}),(0,l.jsxs)("div",{className:"flex-1",children:[(0,l.jsx)("p",{className:"font-medium text-yellow-600 dark:text-yellow-400",children:"Codex CLI not detected locally"}),(0,l.jsx)("p",{className:"text-sm text-text-muted",children:"Manual configuration is still available if kRouter is deployed on a remote server."})]})]}),(0,l.jsxs)("div",{className:"flex items-center gap-2 pl-9",children:[(0,l.jsxs)(r.$n,{variant:"secondary",size:"sm",onClick:()=>J(!0),className:"!bg-yellow-500/20 !border-yellow-500/40 !text-yellow-700 dark:!text-yellow-300 hover:!bg-yellow-500/30",children:[(0,l.jsx)("span",{className:"material-symbols-outlined text-[18px] mr-1",children:"content_copy"}),"Manual Config"]}),(0,l.jsxs)(r.$n,{variant:"outline",size:"sm",onClick:()=>P(!I),children:[(0,l.jsx)("span",{className:"material-symbols-outlined text-[18px] mr-1",children:I?"expand_less":"help"}),I?"Hide":"How to Install"]})]})]}),I&&(0,l.jsxs)("div",{className:"p-4 bg-surface border border-border rounded-lg",children:[(0,l.jsx)("h4",{className:"font-medium mb-3",children:"Installation Guide"}),(0,l.jsxs)("div",{className:"space-y-3 text-sm",children:[(0,l.jsxs)("div",{children:[(0,l.jsx)("p",{className:"text-text-muted mb-1",children:"macOS / Linux / Windows:"}),(0,l.jsx)("code",{className:"block px-3 py-2 bg-black/5 dark:bg-white/5 rounded font-mono text-xs",children:"npm install -g @openai/codex"})]}),(0,l.jsxs)("p",{className:"text-text-muted",children:["After installation, run ",(0,l.jsx)("code",{className:"px-1 bg-black/5 dark:bg-white/5 rounded",children:"codex"})," to verify."]}),(0,l.jsx)("div",{className:"pt-2 border-t border-border",children:(0,l.jsxs)("p",{className:"text-text-muted text-xs",children:["Codex reads the key from ",(0,l.jsx)("code",{className:"px-1 bg-black/5 dark:bg-white/5 rounded",children:"http_headers"})," in ",(0,l.jsx)("code",{className:"px-1 bg-black/5 dark:bg-white/5 rounded",children:"~/.codex/config.toml"})," — a custom provider ignores ",(0,l.jsx)("code",{className:"px-1 bg-black/5 dark:bg-white/5 rounded",children:"auth.json"}),', so your ChatGPT login stays untouched. Click "Apply" to auto-configure.']})})]})]})]}),!k&&v?.installed&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,l.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr] sm:items-center sm:gap-2",children:[(0,l.jsx)("span",{className:"text-xs font-semibold text-text-main sm:text-right sm:text-sm",children:"Select Endpoint"}),(0,l.jsx)("span",{className:"material-symbols-outlined hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,l.jsx)(x,{value:V||V||`${n}/v1`,onChange:W,requiresExternalUrl:e.requiresExternalUrl,tunnelEnabled:p,tunnelPublicUrl:h,tailscaleEnabled:f,tailscaleUrl:y})]}),Z&&(0,l.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr_auto] sm:items-center sm:gap-2",children:[(0,l.jsx)("span",{className:"text-xs font-semibold text-text-main sm:text-right sm:text-sm",children:"Current"}),(0,l.jsx)("span",{className:"material-symbols-outlined hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,l.jsx)("span",{className:"min-w-0 truncate rounded bg-surface/40 px-2 py-2 text-xs text-text-muted sm:py-1.5",children:Z})]}),(0,l.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr_auto] sm:items-center sm:gap-2",children:[(0,l.jsx)("span",{className:"text-xs font-semibold text-text-main sm:text-right sm:text-sm",children:"API Key"}),(0,l.jsx)("span",{className:"material-symbols-outlined hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,l.jsx)(u,{value:R,onChange:T,apiKeys:o,cloudEnabled:c})]}),(0,l.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr_auto] sm:items-center sm:gap-2",children:[(0,l.jsx)("span",{className:"text-xs font-semibold text-text-main sm:text-right sm:text-sm",children:"Model"}),(0,l.jsx)("span",{className:"material-symbols-outlined hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,l.jsxs)("div",{className:"relative w-full min-w-0",children:[(0,l.jsx)("input",{type:"text",value:$,onChange:e=>U(e.target.value),placeholder:"provider/model-id",className:"w-full min-w-0 pl-2 pr-7 py-2 bg-surface rounded border border-border text-xs focus:outline-none focus:ring-1 focus:ring-primary/50 sm:py-1.5"}),$&&(0,l.jsx)("button",{onClick:()=>U(""),className:"absolute right-1 top-1/2 -translate-y-1/2 p-0.5 text-text-muted hover:text-red-500 rounded transition-colors",title:"Clear",children:(0,l.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"close"})})]}),(0,l.jsx)("button",{onClick:()=>z(!0),disabled:!d?.length,className:`w-full sm:w-auto rounded border px-2 py-2 text-xs transition-colors sm:py-1.5 whitespace-nowrap sm:shrink-0 ${d?.length?"bg-surface border-border text-text-main hover:border-primary cursor-pointer":"opacity-50 cursor-not-allowed border-border"}`,children:"Select Model"})]}),(0,l.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr_auto] sm:items-center sm:gap-2",children:[(0,l.jsx)("span",{className:"text-xs font-semibold text-text-main sm:text-right sm:text-sm",children:"Subagent Model"}),(0,l.jsx)("span",{className:"material-symbols-outlined hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,l.jsxs)("div",{className:"relative w-full min-w-0",children:[(0,l.jsx)("input",{type:"text",value:K,onChange:e=>D(e.target.value),placeholder:$||"provider/model-id (defaults to main model)",className:"w-full min-w-0 pl-2 pr-7 py-2 bg-surface rounded border border-border text-xs focus:outline-none focus:ring-1 focus:ring-primary/50 sm:py-1.5"}),K&&(0,l.jsx)("button",{onClick:()=>D(""),className:"absolute right-1 top-1/2 -translate-y-1/2 p-0.5 text-text-muted hover:text-red-500 rounded transition-colors",title:"Clear (will use main model)",children:(0,l.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"close"})})]}),(0,l.jsx)("button",{onClick:()=>q(!0),disabled:!d?.length,className:`w-full sm:w-auto rounded border px-2 py-2 text-xs transition-colors sm:py-1.5 whitespace-nowrap sm:shrink-0 ${d?.length?"bg-surface border-border text-text-main hover:border-primary cursor-pointer":"opacity-50 cursor-not-allowed border-border"}`,children:"Select Model"})]})]}),O&&(0,l.jsxs)("div",{className:`flex items-center gap-2 px-2 py-1.5 rounded text-xs ${"success"===O.type?"bg-green-500/10 text-green-600":"bg-red-500/10 text-red-600"}`,children:[(0,l.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"success"===O.type?"check_circle":"error"}),(0,l.jsx)("span",{children:O.text})]}),(0,l.jsxs)("div",{className:"grid grid-cols-1 gap-2 sm:flex sm:items-center",children:[(0,l.jsxs)(r.$n,{variant:"primary",size:"sm",onClick:es,disabled:!R&&c&&o.length>0||!$,loading:_,children:[(0,l.jsx)("span",{className:"material-symbols-outlined text-[14px] mr-1",children:"save"}),"Apply"]}),(0,l.jsxs)(r.$n,{variant:"outline",size:"sm",onClick:el,disabled:E,loading:E,children:[(0,l.jsx)("span",{className:"material-symbols-outlined text-[14px] mr-1",children:"restore"}),"Reset"]}),(0,l.jsxs)(r.$n,{variant:"ghost",size:"sm",onClick:()=>J(!0),children:[(0,l.jsx)("span",{className:"material-symbols-outlined text-[14px] mr-1",children:"content_copy"}),"Manual Config"]})]})]})]}),(0,l.jsx)(r.rq,{isOpen:L,onClose:()=>z(!1),onSelect:e=>{U(e.value),K||D(e.value),z(!1)},selectedModel:$,activeProviders:d,modelAliases:H,title:"Select Model for Codex"}),(0,l.jsx)(r.rq,{isOpen:F,onClose:()=>q(!1),onSelect:e=>{D(e.value),q(!1)},selectedModel:K,activeProviders:d,modelAliases:H,title:"Select Subagent Model for Codex"}),(0,l.jsx)(r.uR,{isOpen:G,onClose:()=>J(!1),title:"Codex CLI - Manual Configuration",configs:(b=R&&R.trim()?R:c?"<API_KEY_FROM_DASHBOARD>":"sk_krouter",N=K||$,[{filename:"~/.codex/config.toml",content:`# kRouter Configuration for Codex CLI
40
+ model = "${$}"
41
+ model_provider = "krouter"
42
+
43
+ [model_providers.krouter]
44
+ name = "kRouter"
45
+ base_url = "${ee()}"
46
+ wire_api = "responses"
47
+
48
+ [model_providers.krouter.http_headers]
49
+ Authorization = "Bearer ${b}"
50
+
51
+ [agents]
52
+ default_subagent_model = "${N}"
53
+ `}])})]})}let N=s(41463).env.NEXT_PUBLIC_CLOUD_URL;function v({tool:e,isExpanded:t,onToggle:s,baseUrl:n,hasActiveProviders:o,apiKeys:d,activeProviders:c,cloudEnabled:m,initialStatus:p,tunnelEnabled:h,tunnelPublicUrl:f,tailscaleEnabled:y,tailscaleUrl:b}){let j,w,k,C,[_,S]=(0,a.useState)(p||null),[E,A]=(0,a.useState)(!1),[O,M]=(0,a.useState)(!1),[I,P]=(0,a.useState)(!1),[R,T]=(0,a.useState)(null),[$,U]=(0,a.useState)(""),[K,D]=(0,a.useState)([]),[L,z]=(0,a.useState)(""),[F,q]=(0,a.useState)(!1),[H,B]=(0,a.useState)({}),[G,J]=(0,a.useState)(!1),[V,W]=(0,a.useState)(!1),[Y,Z]=(0,a.useState)(""),Q=(0,a.useRef)(!1),X=(()=>{if(!_?.installed)return null;let e=_.settings?.customModels?.find(isOurCustomEntry);return e?g(e.baseUrl,{tunnelPublicUrl:f,tailscaleUrl:b,cloudUrl:m?N:null})?"configured":"other":"not_configured"})();(0,a.useEffect)(()=>{d?.length>0&&!$&&U(d[0].key)},[d,$]),(0,a.useEffect)(()=>{p&&S(p)},[p]),(0,a.useEffect)(()=>{t&&!_&&(et(),ee()),t&&ee()},[t]);let ee=async()=>{try{let e=await fetch("/api/models/alias"),t=await e.json();e.ok&&B(t.aliases||{})}catch(e){console.log("Error fetching model aliases:",e)}};(0,a.useEffect)(()=>{if(_?.installed&&!Q.current){Q.current=!0;let e=(_.settings?.customModels||[]).filter(isOurCustomEntry).sort((e,t)=>(e.index||0)-(t.index||0)).map(e=>e.model);if(e.length>0)D(e);else{let e=_.settings?.customModels?.find(e=>"custom:kRouter-0"===e.id);e?.model&&D([e.model])}}},[_]);let et=async()=>{A(!0);try{let e=await fetch("/api/cli-tools/droid-settings"),t=await e.json();S(t)}catch(e){S({installed:!1,error:e.message})}finally{A(!1)}},es=()=>{let e=Y||n;return e.endsWith("/v1")?e:`${e}/v1`},el=()=>{let e=L.trim();!e||K.includes(e)||(D(t=>[...t,e]),z(""))},ea=async()=>{M(!0),T(null);try{let e=$?.trim()||(d?.length>0?d[0].key:null)||(m?null:"sk_krouter"),t=await fetch("/api/cli-tools/droid-settings",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({baseUrl:es(),apiKey:e,models:K,activeModel:K[0]||""})}),s=await t.json();t.ok?(T({type:"success",text:"Settings applied successfully!"}),et()):T({type:"error",text:s.error||"Failed to apply settings"})}catch(e){T({type:"error",text:e.message})}finally{M(!1)}},er=async()=>{P(!0),T(null);try{let e=await fetch("/api/cli-tools/droid-settings",{method:"DELETE"}),t=await e.json();e.ok?(T({type:"success",text:"Settings reset successfully!"}),D([]),et()):T({type:"error",text:t.error||"Failed to reset settings"})}catch(e){T({type:"error",text:e.message})}finally{P(!1)}};return(0,l.jsxs)(r.Zp,{padding:"xs",className:"overflow-hidden",children:[(0,l.jsxs)("div",{className:"flex items-start justify-between gap-3 hover:cursor-pointer sm:items-center",onClick:s,children:[(0,l.jsxs)("div",{className:"flex min-w-0 items-center gap-3",children:[(0,l.jsx)("div",{className:"size-8 flex items-center justify-center shrink-0",children:(0,l.jsx)(i.A,{src:"/providers/droid.png",alt:e.name,width:32,height:32,className:"size-8 object-contain rounded-lg",sizes:"32px",onError:e=>{e.target.style.display="none"}})}),(0,l.jsxs)("div",{className:"min-w-0",children:[(0,l.jsxs)("div",{className:"flex min-w-0 flex-wrap items-center gap-2",children:[(0,l.jsx)("h3",{className:"font-medium text-sm",children:e.name}),"configured"===X&&(0,l.jsx)("span",{className:"px-1.5 py-0.5 text-[10px] font-medium bg-green-500/10 text-green-600 dark:text-green-400 rounded-full",children:"Connected"}),"not_configured"===X&&(0,l.jsx)("span",{className:"px-1.5 py-0.5 text-[10px] font-medium bg-yellow-500/10 text-yellow-600 dark:text-yellow-400 rounded-full",children:"Not configured"}),"other"===X&&(0,l.jsx)("span",{className:"px-1.5 py-0.5 text-[10px] font-medium bg-blue-500/10 text-blue-600 dark:text-blue-400 rounded-full",children:"Other"})]}),(0,l.jsx)("p",{className:"text-xs text-text-muted truncate",children:e.description})]})]}),(0,l.jsx)("span",{className:`material-symbols-outlined text-text-muted text-[20px] transition-transform ${t?"rotate-180":""}`,children:"expand_more"})]}),t&&(0,l.jsxs)("div",{className:"mt-4 pt-4 border-t border-border flex flex-col gap-4",children:[E&&(0,l.jsxs)("div",{className:"flex items-center gap-2 text-text-muted",children:[(0,l.jsx)("span",{className:"material-symbols-outlined animate-spin",children:"progress_activity"}),(0,l.jsx)("span",{children:"Checking Factory Droid CLI..."})]}),!E&&_&&!_.installed&&(0,l.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,l.jsxs)("div",{className:"flex flex-col gap-3 p-4 bg-yellow-500/10 border border-yellow-500/30 rounded-lg",children:[(0,l.jsxs)("div",{className:"flex items-start gap-3",children:[(0,l.jsx)("span",{className:"material-symbols-outlined text-yellow-500",children:"warning"}),(0,l.jsxs)("div",{className:"flex-1",children:[(0,l.jsx)("p",{className:"font-medium text-yellow-600 dark:text-yellow-400",children:"Factory Droid CLI not detected locally"}),(0,l.jsx)("p",{className:"text-sm text-text-muted",children:"Manual configuration is still available if kRouter is deployed on a remote server."})]})]}),(0,l.jsxs)("div",{className:"flex items-center gap-2 pl-9",children:[(0,l.jsxs)(r.$n,{variant:"secondary",size:"sm",onClick:()=>J(!0),className:"!bg-yellow-500/20 !border-yellow-500/40 !text-yellow-700 dark:!text-yellow-300 hover:!bg-yellow-500/30",children:[(0,l.jsx)("span",{className:"material-symbols-outlined text-[18px] mr-1",children:"content_copy"}),"Manual Config"]}),(0,l.jsxs)(r.$n,{variant:"outline",size:"sm",onClick:()=>W(!V),children:[(0,l.jsx)("span",{className:"material-symbols-outlined text-[18px] mr-1",children:V?"expand_less":"help"}),V?"Hide":"How to Install"]})]})]}),V&&(0,l.jsxs)("div",{className:"p-4 bg-surface border border-border rounded-lg",children:[(0,l.jsx)("h4",{className:"font-medium mb-3",children:"Installation Guide"}),(0,l.jsxs)("div",{className:"space-y-3 text-sm",children:[(0,l.jsxs)("div",{children:[(0,l.jsx)("p",{className:"text-text-muted mb-1",children:"macOS / Linux / Windows:"}),(0,l.jsx)("code",{className:"block px-3 py-2 bg-black/5 dark:bg-white/5 rounded font-mono text-xs",children:"curl -fsSL https://app.factory.ai/cli | sh"})]}),(0,l.jsxs)("p",{className:"text-text-muted",children:["After installation, run ",(0,l.jsx)("code",{className:"px-1 bg-black/5 dark:bg-white/5 rounded",children:"droid"})," to verify."]})]})]})]}),!E&&_?.installed&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,l.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr] sm:items-center sm:gap-2",children:[(0,l.jsx)("span",{className:"text-xs font-semibold text-text-main sm:text-right sm:text-sm",children:"Select Endpoint"}),(0,l.jsx)("span",{className:"material-symbols-outlined hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,l.jsx)(x,{value:Y||((j=Y||n).endsWith("/v1")?j:`${j}/v1`),onChange:Z,requiresExternalUrl:e.requiresExternalUrl,tunnelEnabled:h,tunnelPublicUrl:f,tailscaleEnabled:y,tailscaleUrl:b})]}),(0,l.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr_auto] sm:items-center sm:gap-2",children:[(0,l.jsx)("span",{className:"text-xs font-semibold text-text-main sm:text-right sm:text-sm",children:"API Key"}),(0,l.jsx)("span",{className:"material-symbols-outlined hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,l.jsx)(u,{value:$,onChange:U,apiKeys:d,cloudEnabled:m})]}),(0,l.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr_auto] sm:items-center sm:gap-2",children:[(0,l.jsxs)("span",{className:"text-xs font-semibold text-text-main sm:text-right sm:text-sm",children:["Models ",K.length>0&&(0,l.jsxs)("span",{className:"text-primary",children:["(",K.length,")"]})]}),(0,l.jsx)("span",{className:"material-symbols-outlined hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,l.jsxs)("div",{className:"flex-1 flex flex-col gap-1",children:[K.length>0&&(0,l.jsx)("div",{className:"flex flex-col gap-0.5 mb-1",children:K.map(e=>(0,l.jsxs)("div",{className:"flex items-center gap-1.5 px-2 py-1 bg-bg-secondary rounded border border-border",children:[(0,l.jsx)("span",{className:"flex-1 text-xs font-mono truncate",children:e}),(0,l.jsx)("button",{onClick:()=>D(t=>t.filter(t=>t!==e)),className:"text-text-muted hover:text-red-500 transition-colors shrink-0",title:"Remove",children:(0,l.jsx)("span",{className:"material-symbols-outlined text-[12px]",children:"close"})})]},e))}),(0,l.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,l.jsx)("input",{type:"text",value:L,onChange:e=>z(e.target.value),onKeyDown:e=>{"Enter"===e.key&&(e.preventDefault(),el())},placeholder:"provider/model-id",className:"w-full min-w-0 px-2 py-2 bg-surface rounded border border-border text-xs focus:outline-none focus:ring-1 focus:ring-primary/50 sm:py-1.5"}),(0,l.jsx)("button",{onClick:()=>q(!0),disabled:!o,className:`px-2 py-1.5 rounded border text-xs shrink-0 ${o?"bg-surface border-border hover:border-primary cursor-pointer":"opacity-50 cursor-not-allowed border-border"}`,children:"Select"}),(0,l.jsx)("button",{onClick:el,disabled:!L.trim(),className:"px-2 py-1.5 rounded border bg-surface border-border hover:border-primary text-xs shrink-0 disabled:opacity-50",title:"Add model",children:(0,l.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"add"})})]})]})]})]}),R&&(0,l.jsxs)("div",{className:`flex items-center gap-2 px-2 py-1.5 rounded text-xs ${"success"===R.type?"bg-green-500/10 text-green-600":"bg-red-500/10 text-red-600"}`,children:[(0,l.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"success"===R.type?"check_circle":"error"}),(0,l.jsx)("span",{children:R.text})]}),(0,l.jsxs)("div",{className:"grid grid-cols-1 gap-2 sm:flex sm:items-center",children:[(0,l.jsxs)(r.$n,{variant:"primary",size:"sm",onClick:ea,disabled:0===K.length,loading:O,children:[(0,l.jsx)("span",{className:"material-symbols-outlined text-[14px] mr-1",children:"save"}),"Apply"]}),(0,l.jsxs)(r.$n,{variant:"outline",size:"sm",onClick:er,disabled:!_?.hasKRouter,loading:I,children:[(0,l.jsx)("span",{className:"material-symbols-outlined text-[14px] mr-1",children:"restore"}),"Reset"]}),(0,l.jsxs)(r.$n,{variant:"ghost",size:"sm",onClick:()=>J(!0),children:[(0,l.jsx)("span",{className:"material-symbols-outlined text-[14px] mr-1",children:"content_copy"}),"Manual Config"]})]})]})]}),(0,l.jsx)(r.rq,{isOpen:F,onClose:()=>q(!1),onSelect:e=>{!e.value||K.includes(e.value)||(D(t=>[...t,e.value]),q(!1))},selectedModel:null,activeProviders:c,modelAliases:H,title:"Select Model for Factory Droid"}),(0,l.jsx)(r.uR,{isOpen:G,onClose:()=>J(!1),title:"Factory Droid - Manual Configuration",configs:(w=$&&$.trim()?$:m?"<API_KEY_FROM_DASHBOARD>":"sk_krouter",k={customModels:K.map((e,t)=>({model:e,id:`custom:kRouter-${t}`,index:t,baseUrl:es(),apiKey:w,displayName:e,maxOutputTokens:131072,noImageSupport:!1,provider:"openai"}))},C="u">typeof navigator&&navigator.platform,[{filename:C?.toLowerCase().includes("win")?"%USERPROFILE%\\.factory\\settings.json":"~/.factory/settings.json",content:JSON.stringify(k,null,2)}])})]})}function w({tool:e,isExpanded:t,onToggle:s,baseUrl:n,hasActiveProviders:o,apiKeys:d,activeProviders:c,cloudEnabled:m,initialStatus:p,tunnelEnabled:h,tunnelPublicUrl:f,tailscaleEnabled:y,tailscaleUrl:b}){let j,N,[v,k]=(0,a.useState)(p||null),[C,_]=(0,a.useState)(!1),[S,E]=(0,a.useState)(!1),[A,O]=(0,a.useState)(!1),[M,I]=(0,a.useState)(null),[P,R]=(0,a.useState)(""),[T,$]=(0,a.useState)(""),[U,K]=(0,a.useState)({}),[D,L]=(0,a.useState)(null),[z,F]=(0,a.useState)(!1),[q,H]=(0,a.useState)({}),[B,G]=(0,a.useState)(!1),[J,V]=(0,a.useState)(""),W=(0,a.useRef)(!1),Y=()=>v?.settings?.models?.providers?.krouter??null,Z=(()=>{if(!v?.installed)return null;let e=Y();return e?g(e.baseUrl,{tunnelPublicUrl:f,tailscaleUrl:b})?"configured":"other":"not_configured"})();(0,a.useEffect)(()=>{d?.length>0&&!P&&R(d[0].key)},[d,P]),(0,a.useEffect)(()=>{p&&k(p)},[p]),(0,a.useEffect)(()=>{t&&!v&&(X(),Q()),t&&Q()},[t]);let Q=async()=>{try{let e=await fetch("/api/models/alias"),t=await e.json();e.ok&&H(t.aliases||{})}catch(e){console.log("Error fetching model aliases:",e)}};(0,a.useEffect)(()=>{if(v?.installed&&!W.current){W.current=!0;let e=Y();if(e){let t=v.settings?.agents?.defaults?.model?.primary;t&&$(t.replace(/^krouter\//,"")),e.apiKey&&d?.some(t=>t.key===e.apiKey)&&R(e.apiKey)}let t=v.agents||[],s={};t.forEach(e=>{e.currentModel&&(s[e.id]=e.currentModel)}),K(s)}},[v,d]);let X=async()=>{_(!0);try{let e=await fetch("/api/cli-tools/openclaw-settings"),t=await e.json();k(t)}catch(e){k({installed:!1,error:e.message})}finally{_(!1)}},ee=()=>window.location.origin.replace("://localhost","://127.0.0.1"),et=()=>{let e=J||ee();return e.endsWith("/v1")?e:`${e}/v1`},es=async()=>{E(!0),I(null);try{let e=P?.trim()||(d?.length>0?d[0].key:null)||(m?null:"sk_krouter"),t=await fetch("/api/cli-tools/openclaw-settings",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({baseUrl:et(),apiKey:e,model:T,agentModels:U})}),s=await t.json();t.ok?(I({type:"success",text:"Settings applied successfully!"}),X()):I({type:"error",text:s.error||"Failed to apply settings"})}catch(e){I({type:"error",text:e.message})}finally{E(!1)}},el=async()=>{O(!0),I(null);try{let e=await fetch("/api/cli-tools/openclaw-settings",{method:"DELETE"}),t=await e.json();e.ok?(I({type:"success",text:"Settings reset successfully!"}),$(""),R(""),X()):I({type:"error",text:t.error||"Failed to reset settings"})}catch(e){I({type:"error",text:e.message})}finally{O(!1)}};return(0,l.jsxs)(r.Zp,{padding:"xs",className:"overflow-hidden",children:[(0,l.jsxs)("div",{className:"flex items-start justify-between gap-3 hover:cursor-pointer sm:items-center",onClick:s,children:[(0,l.jsxs)("div",{className:"flex min-w-0 items-center gap-3",children:[(0,l.jsx)("div",{className:"size-8 flex items-center justify-center shrink-0",children:(0,l.jsx)(i.A,{src:"/providers/openclaw.png",alt:e.name,width:32,height:32,className:"size-8 object-contain rounded-lg",sizes:"32px",onError:e=>{e.target.style.display="none"}})}),(0,l.jsxs)("div",{className:"min-w-0",children:[(0,l.jsxs)("div",{className:"flex min-w-0 flex-wrap items-center gap-2",children:[(0,l.jsx)("h3",{className:"font-medium text-sm",children:e.name}),"configured"===Z&&(0,l.jsx)("span",{className:"px-1.5 py-0.5 text-[10px] font-medium bg-green-500/10 text-green-600 dark:text-green-400 rounded-full",children:"Connected"}),"not_configured"===Z&&(0,l.jsx)("span",{className:"px-1.5 py-0.5 text-[10px] font-medium bg-yellow-500/10 text-yellow-600 dark:text-yellow-400 rounded-full",children:"Not configured"}),"other"===Z&&(0,l.jsx)("span",{className:"px-1.5 py-0.5 text-[10px] font-medium bg-blue-500/10 text-blue-600 dark:text-blue-400 rounded-full",children:"Other"})]}),(0,l.jsx)("p",{className:"text-xs text-text-muted truncate",children:e.description})]})]}),(0,l.jsx)("span",{className:`material-symbols-outlined text-text-muted text-[20px] transition-transform ${t?"rotate-180":""}`,children:"expand_more"})]}),t&&(0,l.jsxs)("div",{className:"mt-4 pt-4 border-t border-border flex flex-col gap-4",children:[C&&(0,l.jsxs)("div",{className:"flex items-center gap-2 text-text-muted",children:[(0,l.jsx)("span",{className:"material-symbols-outlined animate-spin",children:"progress_activity"}),(0,l.jsx)("span",{children:"Checking Open Claw CLI..."})]}),!C&&v&&!v.installed&&(0,l.jsx)("div",{className:"flex flex-col gap-4",children:(0,l.jsxs)("div",{className:"flex flex-col gap-3 p-4 bg-yellow-500/10 border border-yellow-500/30 rounded-lg",children:[(0,l.jsxs)("div",{className:"flex items-start gap-3",children:[(0,l.jsx)("span",{className:"material-symbols-outlined text-yellow-500",children:"warning"}),(0,l.jsxs)("div",{className:"flex-1",children:[(0,l.jsx)("p",{className:"font-medium text-yellow-600 dark:text-yellow-400",children:"Open Claw CLI not detected locally"}),(0,l.jsx)("p",{className:"text-sm text-text-muted",children:"Manual configuration is still available if kRouter is deployed on a remote server."})]})]}),(0,l.jsx)("div",{className:"flex items-center gap-2 pl-9",children:(0,l.jsxs)(r.$n,{variant:"secondary",size:"sm",onClick:()=>G(!0),className:"!bg-yellow-500/20 !border-yellow-500/40 !text-yellow-700 dark:!text-yellow-300 hover:!bg-yellow-500/30",children:[(0,l.jsx)("span",{className:"material-symbols-outlined text-[18px] mr-1",children:"content_copy"}),"Manual Config"]})})]})}),!C&&v?.installed&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,l.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr] sm:items-center sm:gap-2",children:[(0,l.jsx)("span",{className:"text-xs font-semibold text-text-main sm:text-right sm:text-sm",children:"Select Endpoint"}),(0,l.jsx)("span",{className:"material-symbols-outlined hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,l.jsx)(x,{value:J||((j=J||ee()).endsWith("/v1")?j:`${j}/v1`),onChange:V,requiresExternalUrl:e.requiresExternalUrl,tunnelEnabled:h,tunnelPublicUrl:f,tailscaleEnabled:y,tailscaleUrl:b})]}),Y()?.baseUrl&&(0,l.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr_auto] sm:items-center sm:gap-2",children:[(0,l.jsx)("span",{className:"text-xs font-semibold text-text-main sm:text-right sm:text-sm",children:"Current"}),(0,l.jsx)("span",{className:"material-symbols-outlined hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,l.jsx)("span",{className:"min-w-0 truncate rounded bg-surface/40 px-2 py-2 text-xs text-text-muted sm:py-1.5",children:Y()?.baseUrl})]}),(0,l.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr_auto] sm:items-center sm:gap-2",children:[(0,l.jsx)("span",{className:"text-xs font-semibold text-text-main sm:text-right sm:text-sm",children:"API Key"}),(0,l.jsx)("span",{className:"material-symbols-outlined hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,l.jsx)(u,{value:P,onChange:R,apiKeys:d,cloudEnabled:m})]}),(0,l.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr_auto] sm:items-center sm:gap-2",children:[(0,l.jsx)("span",{className:"text-xs font-semibold text-text-main sm:text-right sm:text-sm",children:"Default Model"}),(0,l.jsx)("span",{className:"material-symbols-outlined hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,l.jsxs)("div",{className:"relative w-full min-w-0",children:[(0,l.jsx)("input",{type:"text",value:T,onChange:e=>$(e.target.value),placeholder:"provider/model-id",className:"w-full min-w-0 pl-2 pr-7 py-2 bg-surface rounded border border-border text-xs focus:outline-none focus:ring-1 focus:ring-primary/50 sm:py-1.5"}),T&&(0,l.jsx)("button",{onClick:()=>$(""),className:"absolute right-1 top-1/2 -translate-y-1/2 p-0.5 text-text-muted hover:text-red-500 rounded transition-colors",title:"Clear",children:(0,l.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"close"})})]}),(0,l.jsx)("button",{onClick:()=>{L(null),F(!0)},disabled:!o,className:`w-full sm:w-auto rounded border px-2 py-2 text-xs transition-colors sm:py-1.5 whitespace-nowrap sm:shrink-0 ${o?"bg-surface border-border text-text-main hover:border-primary cursor-pointer":"opacity-50 cursor-not-allowed border-border"}`,children:"Select"})]}),(v.agents||[]).filter(e=>e.agentDir).map(e=>(0,l.jsxs)("div",{className:"flex items-center gap-2 pl-4",children:[(0,l.jsxs)("span",{className:"w-32 shrink-0 text-xs text-primary text-right truncate",title:e.name||e.id,children:["Agent ",e.name||e.id]}),(0,l.jsx)("span",{className:"material-symbols-outlined hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,l.jsxs)("div",{className:"relative w-full min-w-0",children:[(0,l.jsx)("input",{type:"text",value:U[e.id]||"",onChange:t=>K(s=>({...s,[e.id]:t.target.value})),placeholder:`default (${T||"provider/model-id"})`,className:"w-full min-w-0 pl-2 pr-7 py-2 bg-surface rounded border border-border text-xs focus:outline-none focus:ring-1 focus:ring-primary/50 sm:py-1.5"}),U[e.id]&&(0,l.jsx)("button",{onClick:()=>K(t=>({...t,[e.id]:""})),className:"absolute right-1 top-1/2 -translate-y-1/2 p-0.5 text-text-muted hover:text-red-500 rounded transition-colors",title:"Clear",children:(0,l.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"close"})})]}),(0,l.jsx)("button",{onClick:()=>{L(e.id),F(!0)},disabled:!o,className:`w-full sm:w-auto rounded border px-2 py-2 text-xs transition-colors sm:py-1.5 whitespace-nowrap sm:shrink-0 ${o?"bg-surface border-border text-text-main hover:border-primary cursor-pointer":"opacity-50 cursor-not-allowed border-border"}`,children:"Select"})]},e.id))]}),M&&(0,l.jsxs)("div",{className:`flex items-center gap-2 px-2 py-1.5 rounded text-xs ${"success"===M.type?"bg-green-500/10 text-green-600":"bg-red-500/10 text-red-600"}`,children:[(0,l.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"success"===M.type?"check_circle":"error"}),(0,l.jsx)("span",{children:M.text})]}),(0,l.jsxs)("div",{className:"grid grid-cols-1 gap-2 sm:flex sm:items-center",children:[(0,l.jsxs)(r.$n,{variant:"primary",size:"sm",onClick:es,disabled:!T,loading:S,children:[(0,l.jsx)("span",{className:"material-symbols-outlined text-[14px] mr-1",children:"save"}),"Apply"]}),(0,l.jsxs)(r.$n,{variant:"outline",size:"sm",onClick:el,disabled:!v?.hasKRouter,loading:A,children:[(0,l.jsx)("span",{className:"material-symbols-outlined text-[14px] mr-1",children:"restore"}),"Reset"]}),(0,l.jsxs)(r.$n,{variant:"ghost",size:"sm",onClick:()=>G(!0),children:[(0,l.jsx)("span",{className:"material-symbols-outlined text-[14px] mr-1",children:"content_copy"}),"Manual Config"]})]})]})]}),(0,l.jsx)(r.rq,{isOpen:z,onClose:()=>F(!1),onSelect:e=>{D?(K(t=>({...t,[D]:e.value})),L(null)):$(e.value),F(!1)},selectedModel:T,activeProviders:c,modelAliases:q,title:"Select Model for Open Claw"}),(0,l.jsx)(r.uR,{isOpen:B,onClose:()=>G(!1),title:"Open Claw - Manual Configuration",configs:(N=P&&P.trim()?P:m?"<API_KEY_FROM_DASHBOARD>":"sk_krouter",[{filename:"~/.openclaw/openclaw.json",content:JSON.stringify({agents:{defaults:{model:{primary:`krouter/${T||"provider/model-id"}`}}},models:{providers:{krouter:{baseUrl:et(),apiKey:N,api:"openai-completions",models:[{id:T||"provider/model-id",name:(T||"provider/model-id").split("/").pop()}]}}}},null,2)}])})]})}let k="/api/cli-tools/hermes-settings";function C({tool:e,isExpanded:t,onToggle:s,baseUrl:n,hasActiveProviders:o,apiKeys:d,activeProviders:c,cloudEnabled:m,initialStatus:p,tunnelEnabled:h,tunnelPublicUrl:f,tailscaleEnabled:y,tailscaleUrl:b}){let j,[N,v]=(0,a.useState)(p||null),[w,_]=(0,a.useState)(!1),[S,E]=(0,a.useState)(!1),[A,O]=(0,a.useState)(!1),[M,I]=(0,a.useState)(null),[P,R]=(0,a.useState)(""),[T,$]=(0,a.useState)(""),[U,K]=(0,a.useState)(!1),[D,L]=(0,a.useState)({}),[z,F]=(0,a.useState)(!1),[q,H]=(0,a.useState)(""),B=(0,a.useRef)(!1),G=(()=>{if(!N?.installed)return null;let e=N.settings?.model;return e?.base_url?g(e.base_url,{tunnelPublicUrl:f,tailscaleUrl:b})?"configured":"other":"not_configured"})();(0,a.useEffect)(()=>{d?.length>0&&!P&&R(d[0].key)},[d,P]),(0,a.useEffect)(()=>{p&&v(p)},[p]),(0,a.useEffect)(()=>{t&&!N&&(V(),J()),t&&J()},[t]);let J=async()=>{try{let e=await fetch("/api/models/alias"),t=await e.json();e.ok&&L(t.aliases||{})}catch(e){console.log("Error fetching model aliases:",e)}};(0,a.useEffect)(()=>{if(N?.installed&&!B.current){B.current=!0;let e=N.settings?.model;e?.default&&$(e.default)}},[N]);let V=async()=>{_(!0);try{let e=await fetch(k),t=await e.json();v(t)}catch(e){v({installed:!1,error:e.message})}finally{_(!1)}},W=()=>{let e=q||window.location.origin.replace("://localhost","://127.0.0.1");return e.endsWith("/v1")?e:`${e}/v1`},Y=async()=>{E(!0),I(null);try{let e=P?.trim()||(d?.length>0?d[0].key:null)||(m?null:"sk_krouter"),t=await fetch(k,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({baseUrl:W(),apiKey:e,model:T})}),s=await t.json();t.ok?(I({type:"success",text:"Settings applied successfully!"}),V()):I({type:"error",text:s.error||"Failed to apply settings"})}catch(e){I({type:"error",text:e.message})}finally{E(!1)}},Z=async()=>{O(!0),I(null);try{let e=await fetch(k,{method:"DELETE"}),t=await e.json();e.ok?(I({type:"success",text:"Settings reset successfully!"}),$(""),V()):I({type:"error",text:t.error||"Failed to reset settings"})}catch(e){I({type:"error",text:e.message})}finally{O(!1)}};return(0,l.jsxs)(r.Zp,{padding:"xs",className:"overflow-hidden",children:[(0,l.jsxs)("div",{className:"flex items-start justify-between gap-3 hover:cursor-pointer sm:items-center",onClick:s,children:[(0,l.jsxs)("div",{className:"flex min-w-0 items-center gap-3",children:[(0,l.jsx)("div",{className:"size-8 flex items-center justify-center shrink-0",children:(0,l.jsx)(i.A,{src:"/providers/hermes.png",alt:e.name,width:32,height:32,className:"size-8 object-contain rounded-lg",sizes:"32px",onError:e=>{e.target.style.display="none"}})}),(0,l.jsxs)("div",{className:"min-w-0",children:[(0,l.jsxs)("div",{className:"flex min-w-0 flex-wrap items-center gap-2",children:[(0,l.jsx)("h3",{className:"font-medium text-sm",children:e.name}),"configured"===G&&(0,l.jsx)("span",{className:"px-1.5 py-0.5 text-[10px] font-medium bg-green-500/10 text-green-600 dark:text-green-400 rounded-full",children:"Connected"}),"not_configured"===G&&(0,l.jsx)("span",{className:"px-1.5 py-0.5 text-[10px] font-medium bg-yellow-500/10 text-yellow-600 dark:text-yellow-400 rounded-full",children:"Not configured"}),"other"===G&&(0,l.jsx)("span",{className:"px-1.5 py-0.5 text-[10px] font-medium bg-blue-500/10 text-blue-600 dark:text-blue-400 rounded-full",children:"Other"})]}),(0,l.jsx)("p",{className:"text-xs text-text-muted truncate",children:e.description})]})]}),(0,l.jsx)("span",{className:`material-symbols-outlined text-text-muted text-[20px] transition-transform ${t?"rotate-180":""}`,children:"expand_more"})]}),t&&(0,l.jsxs)("div",{className:"mt-4 pt-4 border-t border-border flex flex-col gap-4",children:[w&&(0,l.jsxs)("div",{className:"flex items-center gap-2 text-text-muted",children:[(0,l.jsx)("span",{className:"material-symbols-outlined animate-spin",children:"progress_activity"}),(0,l.jsx)("span",{children:"Checking Hermes Agent..."})]}),!w&&N&&!N.installed&&(0,l.jsx)("div",{className:"flex flex-col gap-4",children:(0,l.jsxs)("div",{className:"flex flex-col gap-3 p-4 bg-yellow-500/10 border border-yellow-500/30 rounded-lg",children:[(0,l.jsxs)("div",{className:"flex items-start gap-3",children:[(0,l.jsx)("span",{className:"material-symbols-outlined text-yellow-500",children:"warning"}),(0,l.jsxs)("div",{className:"flex-1",children:[(0,l.jsx)("p",{className:"font-medium text-yellow-600 dark:text-yellow-400",children:"Hermes Agent not detected locally"}),(0,l.jsx)("p",{className:"text-sm text-text-muted",children:"Install: curl -fsSL https://raw.githubusercontent.com/NousResearch/hermes-agent/main/scripts/install.sh | bash"})]})]}),(0,l.jsx)("div",{className:"flex flex-col sm:flex-row sm:items-center gap-2 pl-0 sm:pl-9",children:(0,l.jsxs)(r.$n,{variant:"secondary",size:"sm",onClick:()=>F(!0),className:"w-full sm:w-auto !bg-yellow-500/20 !border-yellow-500/40 !text-yellow-700 dark:!text-yellow-300 hover:!bg-yellow-500/30",children:[(0,l.jsx)("span",{className:"material-symbols-outlined text-[18px] mr-1",children:"content_copy"}),"Manual Config"]})})]})}),!w&&N?.installed&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,l.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr] sm:items-center sm:gap-2",children:[(0,l.jsx)("span",{className:"text-xs font-semibold text-text-main sm:text-right sm:text-sm",children:"Select Endpoint"}),(0,l.jsx)("span",{className:"material-symbols-outlined hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,l.jsx)(x,{value:q||W(),onChange:H,requiresExternalUrl:e.requiresExternalUrl,tunnelEnabled:h,tunnelPublicUrl:f,tailscaleEnabled:y,tailscaleUrl:b})]}),N?.settings?.model?.base_url&&(0,l.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr_auto] sm:items-center sm:gap-2",children:[(0,l.jsx)("span",{className:"text-xs font-semibold text-text-main sm:text-right sm:text-sm",children:"Current"}),(0,l.jsx)("span",{className:"material-symbols-outlined hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,l.jsx)("span",{className:"min-w-0 truncate rounded bg-surface/40 px-2 py-2 text-xs text-text-muted sm:py-1.5",children:N.settings.model.base_url})]}),(0,l.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr_auto] sm:items-center sm:gap-2",children:[(0,l.jsx)("span",{className:"text-xs font-semibold text-text-main sm:text-right sm:text-sm",children:"API Key"}),(0,l.jsx)("span",{className:"material-symbols-outlined hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,l.jsx)(u,{value:P,onChange:R,apiKeys:d,cloudEnabled:m})]}),(0,l.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr_auto] sm:items-center sm:gap-2",children:[(0,l.jsx)("span",{className:"text-xs font-semibold text-text-main sm:text-right sm:text-sm",children:"Default Model"}),(0,l.jsx)("span",{className:"material-symbols-outlined hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,l.jsxs)("div",{className:"relative w-full min-w-0",children:[(0,l.jsx)("input",{type:"text",value:T,onChange:e=>$(e.target.value),placeholder:"provider/model-id",className:"w-full min-w-0 pl-2 pr-7 py-2 bg-surface rounded border border-border text-xs focus:outline-none focus:ring-1 focus:ring-primary/50 sm:py-1.5"}),T&&(0,l.jsx)("button",{onClick:()=>$(""),className:"absolute right-1 top-1/2 -translate-y-1/2 p-0.5 text-text-muted hover:text-red-500 rounded transition-colors",title:"Clear",children:(0,l.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"close"})})]}),(0,l.jsx)("button",{onClick:()=>K(!0),disabled:!o,className:`w-full sm:w-auto rounded border px-2 py-2 text-xs transition-colors sm:py-1.5 whitespace-nowrap sm:shrink-0 ${o?"bg-surface border-border text-text-main hover:border-primary cursor-pointer":"opacity-50 cursor-not-allowed border-border"}`,children:"Select"})]})]}),M&&(0,l.jsxs)("div",{className:`flex items-center gap-2 px-2 py-1.5 rounded text-xs ${"success"===M.type?"bg-green-500/10 text-green-600":"bg-red-500/10 text-red-600"}`,children:[(0,l.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"success"===M.type?"check_circle":"error"}),(0,l.jsx)("span",{children:M.text})]}),(0,l.jsxs)("div",{className:"flex flex-col sm:flex-row sm:items-center gap-2",children:[(0,l.jsxs)(r.$n,{variant:"primary",size:"sm",onClick:Y,disabled:!T,loading:S,className:"w-full sm:w-auto",children:[(0,l.jsx)("span",{className:"material-symbols-outlined text-[14px] mr-1",children:"save"}),"Apply"]}),(0,l.jsxs)(r.$n,{variant:"outline",size:"sm",onClick:Z,disabled:!N?.hasKRouter,loading:A,className:"w-full sm:w-auto",children:[(0,l.jsx)("span",{className:"material-symbols-outlined text-[14px] mr-1",children:"restore"}),"Reset"]}),(0,l.jsxs)(r.$n,{variant:"ghost",size:"sm",onClick:()=>F(!0),className:"w-full sm:w-auto",children:[(0,l.jsx)("span",{className:"material-symbols-outlined text-[14px] mr-1",children:"content_copy"}),"Manual Config"]})]})]})]}),(0,l.jsx)(r.rq,{isOpen:U,onClose:()=>K(!1),onSelect:e=>{$(e.value),K(!1)},selectedModel:T,activeProviders:c,modelAliases:D,title:"Select Model for Hermes Agent"}),(0,l.jsx)(r.uR,{isOpen:z,onClose:()=>F(!1),title:"Hermes Agent - Manual Configuration",configs:(j=P&&P.trim()?P:m?"<API_KEY_FROM_DASHBOARD>":"sk_krouter",[{filename:"~/.hermes/config.yaml",content:`model:
54
+ default: "${T||"provider/model-id"}"
55
+ provider: "custom"
56
+ base_url: "${W()}"
57
+ api_key: $\{OPENAI_API_KEY}
58
+ `},{filename:"~/.hermes/.env",content:`OPENAI_API_KEY=${j}
59
+ `}])})]})}var _=s(11059);function S({toolId:e,tool:t,isExpanded:s,onToggle:n,baseUrl:o,apiKeys:d,activeProviders:c=[],cloudEnabled:m=!1,tunnelEnabled:x=!1}){let[p,h]=(0,a.useState)(null),[g,f]=(0,a.useState)(!1),[y,b]=(0,a.useState)(""),[j,N]=(0,a.useState)(()=>d?.length>0?d[0].key:""),v=e=>{let t=j&&j.trim()?j:m?"your-api-key":"sk_krouter",s=o||"http://localhost:20128",l=s.endsWith("/v1")?s:`${s}/v1`;return e.replace(/\{\{baseUrl\}\}/g,l).replace(/\{\{apiKey\}\}/g,t).replace(/\{\{model\}\}/g,y||"provider/model-id")},{copy:w}=(0,_.C)(),k=async(e,t)=>{await w(v(e),`toolcard-${t}`),h(t),setTimeout(()=>h(null),2e3)},C=c.length>0,E=()=>(!t.requiresExternalUrl||!!m||!!x)&&(!t.requiresCloud||!!m);return(0,l.jsxs)(r.Zp,{padding:"xs",className:"overflow-hidden overflow-x-hidden",children:[(0,l.jsxs)("div",{className:"flex items-center justify-between hover:cursor-pointer",onClick:n,children:[(0,l.jsxs)("div",{className:"flex items-center gap-3",children:[(0,l.jsx)("div",{className:"size-8 rounded-lg flex items-center justify-center shrink-0",children:t.image?(0,l.jsx)(i.A,{src:t.image,alt:t.name,width:32,height:32,className:"size-8 object-contain rounded-lg",sizes:"32px",onError:e=>{e.target.style.display="none"}}):t.icon?(0,l.jsx)("span",{className:"material-symbols-outlined text-xl",style:{color:t.color},children:t.icon}):(0,l.jsx)(i.A,{src:`/providers/${e}.png`,alt:t.name,width:32,height:32,className:"size-8 object-contain rounded-lg",sizes:"32px",onError:e=>{e.target.style.display="none"}})}),(0,l.jsxs)("div",{className:"min-w-0",children:[(0,l.jsx)("h3",{className:"font-medium text-sm",children:t.name}),(0,l.jsx)("p",{className:"text-xs text-text-muted truncate",children:t.description})]})]}),(0,l.jsx)("span",{className:`material-symbols-outlined text-text-muted text-[20px] transition-transform ${s?"rotate-180":""}`,children:"expand_more"})]}),s&&(0,l.jsx)("div",{className:"mt-6 pt-6 border-t border-border",children:t.guideSteps?(0,l.jsxs)("div",{className:"flex flex-col gap-4",children:[t.notes&&0!==t.notes.length?(0,l.jsx)("div",{className:"flex flex-col gap-2 mb-4",children:t.notes.map((e,t)=>{if("cloudCheck"===e.type&&(m||x))return null;let s="warning"===e.type,a="cloudCheck"===e.type&&!m&&!x,r="bg-blue-500/10 border-blue-500/30",i="text-blue-600 dark:text-blue-400",n="text-blue-500",o="info";return s?(r="bg-yellow-500/10 border-yellow-500/30",i="text-yellow-600 dark:text-yellow-400",n="text-yellow-500",o="warning"):a&&(r="bg-red-500/10 border-red-500/30",i="text-red-600 dark:text-red-400",n="text-red-500",o="error"),(0,l.jsxs)("div",{className:`flex items-start gap-3 p-3 rounded-lg border ${r}`,children:[(0,l.jsx)("span",{className:`material-symbols-outlined text-lg ${n}`,children:o}),(0,l.jsx)("p",{className:`text-sm ${i}`,children:e.text})]},t)})}):null,E()&&t.guideSteps.map(e=>(0,l.jsxs)("div",{className:"flex items-start gap-4",children:[(0,l.jsx)("div",{className:"size-8 rounded-full flex items-center justify-center shrink-0 text-sm font-semibold text-white",style:{backgroundColor:t.color},children:e.step}),(0,l.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,l.jsx)("p",{className:"font-medium text-text",children:e.title}),e.desc&&(0,l.jsx)("p",{className:"text-sm text-text-muted mt-0.5",children:e.desc}),"apiKeySelector"===e.type&&(0,l.jsx)("div",{className:"mt-2 flex flex-col sm:flex-row sm:items-center gap-2",children:(0,l.jsx)(u,{value:j,onChange:N,apiKeys:d,cloudEnabled:m,className:"flex-1"})}),"modelSelector"===e.type&&(0,l.jsxs)("div",{className:"mt-2 flex flex-col sm:flex-row sm:items-center gap-2",children:[(0,l.jsx)("input",{type:"text",value:y,onChange:e=>b(e.target.value),placeholder:"provider/model-id",className:"w-full sm:w-auto flex-1 px-3 py-2 bg-bg-secondary rounded-lg text-sm border border-border focus:outline-none focus:ring-1 focus:ring-primary/50"}),(0,l.jsx)("button",{onClick:()=>f(!0),disabled:!C,className:`shrink-0 px-3 py-2 rounded-lg border text-sm transition-colors ${C?"bg-bg-secondary border-border text-text-main hover:border-primary cursor-pointer":"opacity-50 cursor-not-allowed border-border"}`,children:"Select Model"}),y&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)("button",{onClick:()=>k(y,"model"),className:"shrink-0 px-3 py-2 bg-bg-secondary hover:bg-bg-tertiary rounded-lg border border-border transition-colors",children:(0,l.jsx)("span",{className:"material-symbols-outlined text-lg",children:"model"===p?"check":"content_copy"})}),(0,l.jsx)("button",{onClick:()=>b(""),className:"p-2 text-text-muted hover:text-red-500 rounded transition-colors",title:"Clear",children:(0,l.jsx)("span",{className:"material-symbols-outlined text-lg",children:"close"})})]})]}),e.value&&(0,l.jsxs)("div",{className:"mt-2 flex flex-col sm:flex-row sm:items-center gap-2",children:[(0,l.jsx)("code",{className:"w-full sm:w-auto flex-1 px-3 py-2 bg-bg-secondary rounded-lg text-sm font-mono border border-border truncate",children:v(e.value)}),e.copyable&&(0,l.jsx)("button",{onClick:()=>k(e.value,`${e.step}-${e.title}`),className:"shrink-0 px-3 py-2 bg-bg-secondary hover:bg-bg-tertiary rounded-lg border border-border transition-colors",children:(0,l.jsx)("span",{className:"material-symbols-outlined text-lg",children:p===`${e.step}-${e.title}`?"check":"content_copy"})})]})]})]},e.step)),E()&&t.codeBlock&&(0,l.jsxs)("div",{className:"mt-2",children:[(0,l.jsxs)("div",{className:"flex items-center justify-between mb-2",children:[(0,l.jsx)("span",{className:"text-xs text-text-muted uppercase tracking-wide",children:t.codeBlock.language}),(0,l.jsxs)("button",{onClick:()=>k(t.codeBlock.code,"codeblock"),className:"flex items-center gap-1 px-2 py-1 text-xs bg-bg-secondary hover:bg-bg-tertiary rounded border border-border transition-colors",children:[(0,l.jsx)("span",{className:"material-symbols-outlined text-sm",children:"codeblock"===p?"check":"content_copy"}),"codeblock"===p?"Copied!":"Copy"]})]}),(0,l.jsx)("pre",{className:"p-4 bg-bg-secondary rounded-lg border border-border overflow-x-auto",children:(0,l.jsx)("code",{className:"text-sm font-mono whitespace-pre",children:v(t.codeBlock.code)})})]})]}):(0,l.jsx)("p",{className:"text-text-muted text-sm",children:"Coming soon..."})}),(0,l.jsx)(r.rq,{isOpen:g,onClose:()=>f(!1),onSelect:e=>{b(e.value)},selectedModel:y,activeProviders:c,title:"Select Model"})]})}function E({tool:e,isExpanded:t,onToggle:s,baseUrl:n,apiKeys:o,activeProviders:d,cloudEnabled:c,initialStatus:m,tunnelEnabled:p,tunnelPublicUrl:h,tailscaleEnabled:f,tailscaleUrl:y}){let b,j,N,v,w,[k,C]=(0,a.useState)(m||null),[_,S]=(0,a.useState)(!1),[A,O]=(0,a.useState)(!1),[M,I]=(0,a.useState)(!1),[P,R]=(0,a.useState)(null),[T,$]=(0,a.useState)(!1),[U,K]=(0,a.useState)(""),[D,L]=(0,a.useState)(""),[z,F]=(0,a.useState)(""),[q,H]=(0,a.useState)(!1),[B,G]=(0,a.useState)(!1),[J,V]=(0,a.useState)({}),[W,Y]=(0,a.useState)(!1),[Z,Q]=(0,a.useState)(""),[X,ee]=(0,a.useState)([]),[et,es]=(0,a.useState)(""),el=(0,a.useRef)([]);(0,a.useEffect)(()=>{el.current=X},[X]),(0,a.useEffect)(()=>{o?.length>0&&!U&&K(o[0].key)},[o,U]),(0,a.useEffect)(()=>{m&&C(m)},[m]),(0,a.useEffect)(()=>{t&&!k&&(ed(),ea()),t&&ea()},[t]),(0,a.useEffect)(()=>{k?.opencode?.models&&ee(k.opencode.models),k?.opencode?.activeModel&&es(k.opencode.activeModel);let e=k?.config?.agent?.explorer?.model||"",t=/^krouter\/(.+)/.exec(e);t&&F(t[1])},[k]);let ea=async()=>{try{let e=await fetch("/api/models/alias"),t=await e.json();e.ok&&V(t.aliases||{})}catch(e){console.log("Error fetching model aliases:",e)}},er=async e=>{try{let t=U&&U.trim()||c?U:"sk_krouter",s=e.includes(et)?et:e[0]||"";await fetch("/api/cli-tools/opencode-settings",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({baseUrl:eo(),apiKey:t,models:e,activeModel:s,subagentModel:z})})}catch(e){console.log("Error saving models:",e)}},ei=()=>k?.config?.provider?.krouter??null,en=k?.installed?k.config&&k.hasKRouter?g(ei()?.options?.baseURL||"",{tunnelPublicUrl:h,tailscaleUrl:y})?"configured":"other":"not_configured":null,eo=()=>{let e=Z||n;return e.endsWith("/v1")?e:`${e}/v1`},ed=async()=>{S(!0);try{let e=await fetch("/api/cli-tools/opencode-settings"),t=await e.json();C(t)}catch(e){C({installed:!1,error:e.message})}finally{S(!1)}},ec=async()=>{O(!0),R(null);try{let e=U&&U.trim()||c?U:"sk_krouter",t=await fetch("/api/cli-tools/opencode-settings",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({baseUrl:eo(),apiKey:e,models:X,activeModel:""===et?"":et||X[0],subagentModel:z})}),s=await t.json();t.ok?(R({type:"success",text:"Settings applied successfully!"}),ed()):R({type:"error",text:s.error||"Failed to apply settings"})}catch(e){R({type:"error",text:e.message})}finally{O(!1)}},em=async()=>{I(!0),R(null);try{let e=await fetch("/api/cli-tools/opencode-settings",{method:"DELETE"}),t=await e.json();e.ok?(R({type:"success",text:"Settings reset successfully!"}),L(""),F(""),ee([]),es(""),ed()):R({type:"error",text:t.error||"Failed to reset settings"})}catch(e){R({type:"error",text:e.message})}finally{I(!1)}};return(0,l.jsxs)(r.Zp,{padding:"xs",className:"overflow-hidden",children:[(0,l.jsxs)("div",{className:"flex items-start justify-between gap-3 hover:cursor-pointer sm:items-center",onClick:s,children:[(0,l.jsxs)("div",{className:"flex min-w-0 items-center gap-3",children:[(0,l.jsx)("div",{className:"size-8 flex items-center justify-center shrink-0",children:(0,l.jsx)(i.A,{src:"/providers/opencode.png",alt:e.name,width:32,height:32,className:"size-8 object-contain rounded-lg",sizes:"32px",onError:e=>{e.target.style.display="none"}})}),(0,l.jsxs)("div",{className:"min-w-0",children:[(0,l.jsxs)("div",{className:"flex min-w-0 flex-wrap items-center gap-2",children:[(0,l.jsx)("h3",{className:"font-medium text-sm",children:e.name}),"configured"===en&&(0,l.jsx)("span",{className:"px-1.5 py-0.5 text-[10px] font-medium bg-green-500/10 text-green-600 dark:text-green-400 rounded-full",children:"Connected"}),"not_configured"===en&&(0,l.jsx)("span",{className:"px-1.5 py-0.5 text-[10px] font-medium bg-yellow-500/10 text-yellow-600 dark:text-yellow-400 rounded-full",children:"Not configured"}),"other"===en&&(0,l.jsx)("span",{className:"px-1.5 py-0.5 text-[10px] font-medium bg-blue-500/10 text-blue-600 dark:text-blue-400 rounded-full",children:"Other"})]}),(0,l.jsx)("p",{className:"text-xs text-text-muted truncate",children:e.description})]})]}),(0,l.jsx)("span",{className:`material-symbols-outlined text-text-muted text-[20px] transition-transform ${t?"rotate-180":""}`,children:"expand_more"})]}),t&&(0,l.jsxs)("div",{className:"mt-4 pt-4 border-t border-border flex flex-col gap-4",children:[_&&(0,l.jsxs)("div",{className:"flex items-center gap-2 text-text-muted",children:[(0,l.jsx)("span",{className:"material-symbols-outlined animate-spin",children:"progress_activity"}),(0,l.jsx)("span",{children:"Checking OpenCode CLI..."})]}),!_&&k&&!k.installed&&(0,l.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,l.jsxs)("div",{className:"flex flex-col gap-3 p-4 bg-yellow-500/10 border border-yellow-500/30 rounded-lg",children:[(0,l.jsxs)("div",{className:"flex items-start gap-3",children:[(0,l.jsx)("span",{className:"material-symbols-outlined text-yellow-500",children:"warning"}),(0,l.jsxs)("div",{className:"flex-1",children:[(0,l.jsx)("p",{className:"font-medium text-yellow-600 dark:text-yellow-400",children:"OpenCode CLI not detected locally"}),(0,l.jsx)("p",{className:"text-sm text-text-muted",children:"Manual configuration is still available if kRouter is deployed on a remote server."})]})]}),(0,l.jsxs)("div",{className:"flex items-center gap-2 pl-9",children:[(0,l.jsxs)(r.$n,{variant:"secondary",size:"sm",onClick:()=>Y(!0),className:"!bg-yellow-500/20 !border-yellow-500/40 !text-yellow-700 dark:!text-yellow-300 hover:!bg-yellow-500/30",children:[(0,l.jsx)("span",{className:"material-symbols-outlined text-[18px] mr-1",children:"content_copy"}),"Manual Config"]}),(0,l.jsxs)(r.$n,{variant:"outline",size:"sm",onClick:()=>$(!T),children:[(0,l.jsx)("span",{className:"material-symbols-outlined text-[18px] mr-1",children:T?"expand_less":"help"}),T?"Hide":"How to Install"]})]})]}),T&&(0,l.jsxs)("div",{className:"p-4 bg-surface border border-border rounded-lg",children:[(0,l.jsx)("h4",{className:"font-medium mb-3",children:"Installation Guide"}),(0,l.jsxs)("div",{className:"space-y-3 text-sm",children:[(0,l.jsxs)("div",{children:[(0,l.jsx)("p",{className:"text-text-muted mb-1",children:"macOS / Linux:"}),(0,l.jsx)("code",{className:"block px-3 py-2 bg-black/5 dark:bg-white/5 rounded font-mono text-xs",children:"npm install -g opencode-ai"})]}),(0,l.jsxs)("p",{className:"text-text-muted",children:["After installation, run ",(0,l.jsx)("code",{className:"px-1 bg-black/5 dark:bg-white/5 rounded",children:"opencode"})," to verify."]})]})]})]}),!_&&k?.installed&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,l.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr] sm:items-center sm:gap-2",children:[(0,l.jsx)("span",{className:"text-xs font-semibold text-text-main sm:text-right sm:text-sm",children:"Select Endpoint"}),(0,l.jsx)("span",{className:"material-symbols-outlined hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,l.jsx)(x,{value:Z||Z||`${n}/v1`,onChange:Q,requiresExternalUrl:e.requiresExternalUrl,tunnelEnabled:p,tunnelPublicUrl:h,tailscaleEnabled:f,tailscaleUrl:y})]}),ei()?.options?.baseURL&&(0,l.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr_auto] sm:items-center sm:gap-2",children:[(0,l.jsx)("span",{className:"text-xs font-semibold text-text-main sm:text-right sm:text-sm",children:"Current"}),(0,l.jsx)("span",{className:"material-symbols-outlined hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,l.jsx)("span",{className:"min-w-0 truncate rounded bg-surface/40 px-2 py-2 text-xs text-text-muted sm:py-1.5",children:ei()?.options?.baseURL})]}),(0,l.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr_auto] sm:items-center sm:gap-2",children:[(0,l.jsx)("span",{className:"text-xs font-semibold text-text-main sm:text-right sm:text-sm",children:"API Key"}),(0,l.jsx)("span",{className:"material-symbols-outlined hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,l.jsx)(u,{value:U,onChange:K,apiKeys:o,cloudEnabled:c})]}),(0,l.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr] sm:items-start sm:gap-2",children:[(0,l.jsx)("span",{className:"w-32 shrink-0 text-sm font-semibold text-text-main text-right pt-1",children:"Models"}),(0,l.jsx)("span",{className:"material-symbols-outlined text-text-muted text-[14px] mt-1.5",children:"arrow_forward"}),(0,l.jsxs)("div",{className:"flex-1 flex flex-col gap-2",children:[(0,l.jsx)("div",{className:"flex flex-wrap gap-1.5 min-h-[28px] px-2 py-1.5 bg-surface rounded border border-border",children:0===X.length?(0,l.jsx)("span",{className:"text-xs text-text-muted",children:"No models selected"}):X.map(e=>(0,l.jsxs)("span",{onClick:async()=>{if(e===et)try{(await fetch("/api/cli-tools/opencode-settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({clearActiveModel:!0})})).ok&&(es(""),ed())}catch(e){console.log("Error clearing active model:",e)}else es(e)},className:`inline-flex items-center gap-1 px-2 py-0.5 rounded text-xs cursor-pointer transition-colors ${e===et?"bg-primary/10 text-primary border border-primary":"bg-black/5 dark:bg-white/5 text-text-muted border border-transparent hover:border-border"}`,title:e===et?"Click to clear active model":"Click to set as active",children:[e===et&&(0,l.jsx)("span",{className:"material-symbols-outlined text-[10px]",children:"star"}),e,(0,l.jsx)("button",{onClick:async t=>{t.stopPropagation();try{if((await fetch(`/api/cli-tools/opencode-settings?model=${encodeURIComponent(e)}`,{method:"DELETE"})).ok){let t=X.filter(t=>t!==e);ee(t),et===e&&es(""),ed()}}catch(e){console.log("Error removing model:",e)}},className:"ml-0.5 hover:text-red-500",children:(0,l.jsx)("span",{className:"material-symbols-outlined text-[12px]",children:"close"})})]},e))}),(0,l.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr_auto] sm:items-center sm:gap-2",children:[(0,l.jsx)("button",{onClick:()=>H(!0),disabled:!d?.length,className:`px-2 py-1 rounded border text-xs transition-colors ${d?.length?"bg-surface border-border text-text-main hover:border-primary cursor-pointer":"opacity-50 cursor-not-allowed border-border"}`,children:"Add Model"}),(0,l.jsx)("span",{className:"text-xs text-text-muted",children:X.length>0&&et?(0,l.jsxs)(l.Fragment,{children:["Active: ",(0,l.jsx)("span",{className:"text-primary",children:et})]}):X.length>0?(0,l.jsx)("span",{className:"text-yellow-500",children:"Click a model to set/clear active"}):"Select models to add"})]})]})]}),(0,l.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr_auto] sm:items-center sm:gap-2",children:[(0,l.jsx)("span",{className:"text-xs font-semibold text-text-main sm:text-right sm:text-sm",children:"Subagent Model"}),(0,l.jsx)("span",{className:"material-symbols-outlined hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,l.jsx)("input",{type:"text",value:z,onChange:e=>F(e.target.value),placeholder:D||"provider/model-id (defaults to main model)",className:"w-full min-w-0 px-2 py-2 bg-surface rounded border border-border text-xs focus:outline-none focus:ring-1 focus:ring-primary/50 sm:py-1.5"}),(0,l.jsx)("button",{onClick:()=>G(!0),disabled:!d?.length,className:`w-full sm:w-auto rounded border px-2 py-2 text-xs transition-colors sm:py-1.5 whitespace-nowrap sm:shrink-0 ${d?.length?"bg-surface border-border text-text-main hover:border-primary cursor-pointer":"opacity-50 cursor-not-allowed border-border"}`,children:"Select Model"}),z&&(0,l.jsx)("button",{onClick:()=>F(""),className:"p-1 text-text-muted hover:text-red-500 rounded transition-colors",title:"Clear (will use main model)",children:(0,l.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"close"})})]})]}),P&&(0,l.jsxs)("div",{className:`flex items-center gap-2 px-2 py-1.5 rounded text-xs ${"success"===P.type?"bg-green-500/10 text-green-600":"bg-red-500/10 text-red-600"}`,children:[(0,l.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"success"===P.type?"check_circle":"error"}),(0,l.jsx)("span",{children:P.text})]}),(0,l.jsxs)("div",{className:"grid grid-cols-1 gap-2 sm:flex sm:items-center",children:[(0,l.jsxs)(r.$n,{variant:"primary",size:"sm",onClick:ec,disabled:0===X.length,loading:A,children:[(0,l.jsx)("span",{className:"material-symbols-outlined text-[14px] mr-1",children:"save"}),"Apply"]}),(0,l.jsxs)(r.$n,{variant:"outline",size:"sm",onClick:em,disabled:!k.hasKRouter,loading:M,children:[(0,l.jsx)("span",{className:"material-symbols-outlined text-[14px] mr-1",children:"restore"}),"Reset"]}),(0,l.jsxs)(r.$n,{variant:"ghost",size:"sm",onClick:()=>Y(!0),children:[(0,l.jsx)("span",{className:"material-symbols-outlined text-[14px] mr-1",children:"content_copy"}),"Manual Config"]})]})]})]}),(0,l.jsx)(r.rq,{isOpen:q,onClose:()=>{H(!1),er(el.current)},onSelect:e=>{!X.includes(e.value)&&(ee([...X,e.value]),et||es(e.value))},onDeselect:e=>{let t=X.filter(t=>t!==e.value);ee(t),et===e.value&&es(t[0]||"")},selectedModel:null,activeProviders:d,modelAliases:J,addedModelValues:X,closeOnSelect:!1,title:"Add Model for OpenCode"}),(0,l.jsx)(r.rq,{isOpen:B,onClose:()=>G(!1),onSelect:e=>{F(e.value),G(!1)},selectedModel:z,activeProviders:d,modelAliases:J,title:"Select Subagent Model for OpenCode"}),(0,l.jsx)(r.uR,{isOpen:W,onClose:()=>Y(!1),title:"OpenCode - Manual Configuration",configs:(b=U&&U.trim()?U:c?"<API_KEY_FROM_DASHBOARD>":"sk_krouter",j=X.length>0?X:["provider/model-id"],N=et||X[0]||j[0],v=z||N,w={},j.forEach(e=>{w[e]={name:e,modalities:{input:["text","image"],output:["text"]}}}),[{filename:"~/.config/opencode/opencode.json",content:JSON.stringify({provider:{krouter:{npm:"@ai-sdk/openai-compatible",options:{baseURL:eo(),apiKey:b},models:w}},model:`krouter/${N}`,agent:{explorer:{description:"Fast explorer subagent for codebase exploration",mode:"subagent",model:`krouter/${v}`}}},null,2)}])})]})}let A="/api/cli-tools/cowork-settings",O=e=>(e||"").replace(/\/v1\/?$/,"");function M({tool:e,isExpanded:t,onToggle:s,baseUrl:n,apiKeys:o,activeProviders:d,hasActiveProviders:c,cloudEnabled:m,cloudUrl:p,tunnelEnabled:h,tunnelPublicUrl:g,tailscaleEnabled:f,tailscaleUrl:y,initialStatus:b}){let j,N,v,w,[k,C]=(0,a.useState)(b||null),[_,S]=(0,a.useState)(!1),[E,I]=(0,a.useState)(!1),[P,R]=(0,a.useState)(!1),[T,$]=(0,a.useState)(null),[U,K]=(0,a.useState)(""),[D,L]=(0,a.useState)([]),[z,F]=(0,a.useState)(!1),[q,H]=(0,a.useState)(""),[B,G]=(0,a.useState)([]),[J,V]=(0,a.useState)([]),[W,Y]=(0,a.useState)([]),[Z,Q]=(0,a.useState)({}),[X,ee]=(0,a.useState)(!1),[et,es]=(0,a.useState)(!1),[el,ea]=(0,a.useState)(!1),[er,ei]=(0,a.useState)(!1),[en,eo]=(0,a.useState)({name:"",url:""});(0,a.useEffect)(()=>{o?.length>0&&!U&&K(o[0].key)},[o,U]),(0,a.useEffect)(()=>{b&&C(b)},[b]),(0,a.useEffect)(()=>{t&&!k&&ed()},[t]),(0,a.useEffect)(()=>{t&&fetch("/api/models/alias").then(e=>e.ok?e.json():null).then(e=>{e&&Q(e.aliases||{})}).catch(()=>{})},[t]),(0,a.useEffect)(()=>{k?.cowork?.models?.length&&L(k.cowork.models),k?.cowork?.baseUrl&&!q&&H(O(k.cowork.baseUrl)),Array.isArray(k?.cowork?.plugins)&&k.cowork.plugins.length>0?G(k.cowork.plugins):0===B.length&&Array.isArray(k?.defaultPlugins)&&G(k.defaultPlugins),Array.isArray(k?.cowork?.localPlugins)&&V(k.cowork.localPlugins),Array.isArray(k?.cowork?.customPlugins)&&k.cowork.customPlugins.length>0&&Y(k.cowork.customPlugins)},[k]);let ed=async()=>{S(!0);try{let e=await fetch(A),t=await e.json();C(t)}catch(e){C({installed:!1,error:e.message})}finally{S(!1)}},ec=()=>{let e;return(e=(q||"").replace(/\/+$/,""))?/\/v1$/.test(e)?e:`${e}/v1`:""},em=k?.installed?k?.cowork?.baseUrl?k.hasKRouter?"configured":"other":"not_configured":null,ex=async()=>{$(null);let e=ec();if(0===D.length)return void $({type:"error",text:"Please select at least one model"});I(!0);try{let t=U?.trim()||(o?.length>0?o[0].key:null)||(m?null:"sk_krouter"),s=await fetch(A,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({baseUrl:e,apiKey:t,models:D,plugins:B,localPlugins:J,customPlugins:W})}),l=await s.json();s.ok?($({type:"success",text:"Settings applied. Quit & reopen Claude Desktop to load."}),ed()):$({type:"error",text:l.error||"Failed to apply settings"})}catch(e){$({type:"error",text:e.message})}finally{I(!1)}},ep=async({name:e,models:t})=>{try{let s=await fetch("/api/combos",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:e,models:t})});if(!s.ok){let e=await s.json();$({type:"error",text:e.error||"Failed to create combo"});return}D.includes(e)||L([...D,e]),ee(!1),$({type:"success",text:`Combo "${e}" created and added.`})}catch(e){$({type:"error",text:e.message})}},eu=e=>{let t=e?.value||e?.name||e;L(e=>e.filter(e=>e!==t))},eh=async()=>{R(!0),$(null);try{let e=await fetch(A,{method:"DELETE"}),t=await e.json();e.ok?($({type:"success",text:"Settings reset successfully"}),L([]),G(k?.defaultPlugins||[]),V([]),Y([]),ed()):$({type:"error",text:t.error||"Failed to reset"})}catch(e){$({type:"error",text:e.message})}finally{R(!1)}};return(0,l.jsxs)(r.Zp,{padding:"xs",className:"overflow-hidden",children:[(0,l.jsxs)("div",{className:"flex items-start justify-between gap-3 hover:cursor-pointer sm:items-center",onClick:s,children:[(0,l.jsxs)("div",{className:"flex min-w-0 items-center gap-3",children:[(0,l.jsx)("div",{className:"size-8 flex items-center justify-center shrink-0",children:(0,l.jsx)(i.A,{src:e.image,alt:e.name,width:32,height:32,className:"size-8 object-contain rounded-lg",sizes:"32px",onError:e=>{e.target.style.display="none"}})}),(0,l.jsxs)("div",{className:"min-w-0",children:[(0,l.jsxs)("div",{className:"flex min-w-0 flex-wrap items-center gap-2",children:[(0,l.jsx)("h3",{className:"font-medium text-sm",children:e.name}),"configured"===em&&(0,l.jsx)("span",{className:"px-1.5 py-0.5 text-[10px] font-medium bg-green-500/10 text-green-600 dark:text-green-400 rounded-full",children:"Connected"}),"not_configured"===em&&(0,l.jsx)("span",{className:"px-1.5 py-0.5 text-[10px] font-medium bg-yellow-500/10 text-yellow-600 dark:text-yellow-400 rounded-full",children:"Not configured"}),"other"===em&&(0,l.jsx)("span",{className:"px-1.5 py-0.5 text-[10px] font-medium bg-blue-500/10 text-blue-600 dark:text-blue-400 rounded-full",children:"Other"})]}),(0,l.jsx)("p",{className:"text-xs text-text-muted truncate",children:e.description})]})]}),(0,l.jsx)("span",{className:`material-symbols-outlined text-text-muted text-[20px] transition-transform ${t?"rotate-180":""}`,children:"expand_more"})]}),t&&(0,l.jsxs)("div",{className:"mt-4 pt-4 border-t border-border flex flex-col gap-4",children:[_&&(0,l.jsxs)("div",{className:"flex items-center gap-2 text-text-muted",children:[(0,l.jsx)("span",{className:"material-symbols-outlined animate-spin",children:"progress_activity"}),(0,l.jsx)("span",{children:"Checking Claude Cowork..."})]}),!_&&k&&!k.installed&&(0,l.jsxs)("div",{className:"flex flex-col gap-3 p-4 bg-yellow-500/10 border border-yellow-500/30 rounded-lg",children:[(0,l.jsxs)("div",{className:"flex items-start gap-3",children:[(0,l.jsx)("span",{className:"material-symbols-outlined text-yellow-500",children:"warning"}),(0,l.jsxs)("div",{className:"flex-1",children:[(0,l.jsx)("p",{className:"font-medium text-yellow-600 dark:text-yellow-400",children:"Claude Desktop (Cowork mode) not detected"}),(0,l.jsx)("p",{className:"text-sm text-text-muted",children:"Open Claude Desktop → Help → Troubleshooting → Enable Developer mode → Configure third-party inference, then return here."})]})]}),(0,l.jsx)("div",{className:"pl-9",children:(0,l.jsxs)(r.$n,{variant:"secondary",size:"sm",onClick:()=>F(!0),className:"!bg-yellow-500/20 !border-yellow-500/40 !text-yellow-700 dark:!text-yellow-300 hover:!bg-yellow-500/30",children:[(0,l.jsx)("span",{className:"material-symbols-outlined text-[18px] mr-1",children:"content_copy"}),"Manual Config"]})})]}),!_&&k?.installed&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,l.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr] sm:items-center sm:gap-2",children:[(0,l.jsx)("span",{className:"text-xs font-semibold text-text-main sm:text-right sm:text-sm",children:"Select Endpoint"}),(0,l.jsx)("span",{className:"material-symbols-outlined hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,l.jsx)(x,{value:ec(),onChange:e=>H(O(e)),tunnelEnabled:h,tunnelPublicUrl:g,tailscaleEnabled:f,tailscaleUrl:y,cloudEnabled:m,cloudUrl:p})]}),k?.cowork?.baseUrl&&(0,l.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr_auto] sm:items-center sm:gap-2",children:[(0,l.jsx)("span",{className:"text-xs font-semibold text-text-main sm:text-right sm:text-sm",children:"Current"}),(0,l.jsx)("span",{className:"material-symbols-outlined hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,l.jsx)("span",{className:"min-w-0 truncate rounded bg-surface/40 px-2 py-2 text-xs text-text-muted sm:py-1.5",children:k.cowork.baseUrl})]}),(0,l.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr_auto] sm:items-center sm:gap-2",children:[(0,l.jsx)("span",{className:"text-xs font-semibold text-text-main sm:text-right sm:text-sm",children:"API Key"}),(0,l.jsx)("span",{className:"material-symbols-outlined hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,l.jsx)(u,{value:U,onChange:K,apiKeys:o,cloudEnabled:m})]}),(0,l.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr] sm:items-center sm:gap-2",children:[(0,l.jsx)("span",{className:"w-32 shrink-0 text-sm font-semibold text-text-main text-right",children:"Models"}),(0,l.jsx)("span",{className:"material-symbols-outlined text-text-muted text-[14px]",children:"arrow_forward"}),(0,l.jsxs)("div",{className:"flex-1 flex items-center gap-2",children:[(0,l.jsx)("div",{className:"flex-1 flex flex-wrap gap-1.5 min-h-[28px] px-2 py-1.5 bg-surface rounded border border-border",children:0===D.length?(0,l.jsx)("span",{className:"text-xs text-text-muted",children:"No models selected"}):D.map(e=>(0,l.jsxs)("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 rounded text-xs bg-black/5 dark:bg-white/5 text-text-muted border border-transparent hover:border-border",children:[e,(0,l.jsx)("button",{onClick:()=>eu(e),className:"ml-0.5 hover:text-red-500",children:(0,l.jsx)("span",{className:"material-symbols-outlined text-[12px]",children:"close"})})]},e))}),(0,l.jsx)("button",{onClick:()=>ee(!0),disabled:!c,className:`shrink-0 px-2 py-1.5 rounded border text-xs whitespace-nowrap transition-colors ${c?"bg-primary/10 border-primary/40 text-primary hover:bg-primary/20 cursor-pointer":"opacity-50 cursor-not-allowed border-border"}`,children:"+ Combo"})]})]}),(0,l.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr] sm:items-start sm:gap-2",children:[(0,l.jsx)("span",{className:"w-32 shrink-0 text-sm font-semibold text-text-main text-right pt-2",children:"MCP"}),(0,l.jsx)("span",{className:"material-symbols-outlined text-text-muted text-[14px] mt-2",children:"arrow_forward"}),(0,l.jsxs)("div",{className:"flex-1 flex flex-col gap-1",children:[B.filter(e=>"exa"!==e.name).map(e=>(0,l.jsxs)("div",{className:"flex items-center gap-2 px-2 py-1 bg-surface rounded border border-border",children:[(0,l.jsx)("span",{className:"text-xs font-medium min-w-0 truncate flex-shrink-0",children:e.title||e.name}),e.oauth&&(0,l.jsx)("span",{className:"text-[8px] text-amber-600 shrink-0",children:"OAuth"}),(0,l.jsxs)("div",{className:"flex-1 flex flex-wrap gap-1 overflow-hidden",style:{maxHeight:"1.5rem"},children:[Array.isArray(e.toolNames)&&e.toolNames.slice(0,6).map(e=>(0,l.jsx)("span",{className:"text-[9px] px-1 py-0.5 rounded bg-black/5 dark:bg-white/5 text-text-muted whitespace-nowrap",children:e},e)),Array.isArray(e.toolNames)&&e.toolNames.length>6&&(0,l.jsxs)("span",{className:"text-[9px] px-1 py-0.5 rounded bg-black/5 dark:bg-white/5 text-text-muted whitespace-nowrap",children:["+",e.toolNames.length-6]})]}),(0,l.jsx)("button",{onClick:()=>{var t;return t=e.name,void G(B.filter(e=>e.name!==t))},className:"shrink-0 hover:text-red-500 ml-auto",children:(0,l.jsx)("span",{className:"material-symbols-outlined text-[12px]",children:"close"})})]},e.name)),W.map(e=>(0,l.jsxs)("div",{className:"flex items-center gap-2 px-2 py-1 bg-surface rounded border border-border",children:[(0,l.jsx)("span",{className:"text-xs font-medium min-w-0 truncate flex-shrink-0",children:e.name}),(0,l.jsx)("span",{className:"text-[8px] px-1 py-0.5 rounded bg-blue-500/10 text-blue-500 shrink-0",children:"custom"}),(0,l.jsx)("span",{className:"flex-1 text-[9px] text-text-muted truncate",children:e.url}),(0,l.jsx)("button",{onClick:()=>Y(W.filter(t=>t.name!==e.name)),className:"shrink-0 hover:text-red-500 ml-auto",children:(0,l.jsx)("span",{className:"material-symbols-outlined text-[12px]",children:"close"})})]},e.name)),0===B.filter(e=>"exa"!==e.name).length&&0===W.length&&(0,l.jsx)("div",{className:"px-2 py-1.5 bg-surface rounded border border-border text-xs text-text-muted",children:"No MCPs added"}),(0,l.jsxs)("div",{className:"flex items-center gap-2 mt-0.5",children:[(0,l.jsx)("button",{onClick:()=>ea(!0),className:"px-2 py-1 rounded border text-xs bg-primary/10 border-primary/40 text-primary hover:bg-primary/20 cursor-pointer whitespace-nowrap",children:"+ Browse"}),(0,l.jsx)("button",{onClick:()=>{eo({name:"",url:""}),ei(!0)},className:"px-2 py-1 rounded border text-xs bg-surface border-border text-text-muted hover:border-primary hover:text-primary cursor-pointer whitespace-nowrap",children:"+ Custom"}),(0,l.jsx)("a",{href:"https://mcp.so",target:"_blank",rel:"noopener noreferrer",className:"text-[10px] text-text-muted hover:text-primary underline ml-auto",children:"Find MCPs →"})]})]})]}),(0,l.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr] sm:items-start sm:gap-2",children:[(0,l.jsx)("span",{className:"w-32 shrink-0 text-sm font-semibold text-text-main text-right pt-1",children:"Tools"}),(0,l.jsx)("span",{className:"material-symbols-outlined text-text-muted text-[14px] mt-1.5",children:"arrow_forward"}),(0,l.jsxs)("div",{className:"flex-1 flex flex-col gap-1.5",children:[(j=B.some(e=>"exa"===e.name),N=(k?.defaultPlugins||[]).find(e=>"exa"===e.name),(0,l.jsxs)("label",{className:"flex items-start gap-2 cursor-pointer px-2 py-1.5 bg-surface rounded border border-border",children:[(0,l.jsx)("input",{type:"checkbox",checked:j,onChange:e=>{e.target.checked&&N?G([...B.filter(e=>"exa"!==e.name),N]):G(B.filter(e=>"exa"!==e.name))},className:"mt-0.5"}),(0,l.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,l.jsx)("div",{className:"text-xs font-medium",children:"Web Search & Fetch (Exa)"}),(0,l.jsx)("p",{className:"text-[10px] text-text-muted leading-snug",children:"Replaces built-in WebSearch/WebFetch. Auto-strips duplicates from tool list."})]})]})),(()=>{let e=(k?.localStdioPlugins||[]).find(e=>"browsermcp"===e.name);if(!e)return null;let t=J.includes("browsermcp");return(0,l.jsxs)("label",{className:"flex items-start gap-2 cursor-pointer px-2 py-1.5 bg-surface rounded border border-border",children:[(0,l.jsx)("input",{type:"checkbox",checked:t,onChange:e=>V(e.target.checked?[...J,"browsermcp"]:J.filter(e=>"browsermcp"!==e)),className:"mt-0.5"}),(0,l.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,l.jsx)("div",{className:"text-xs font-medium",children:"Browser Control (Browser MCP)"}),(0,l.jsxs)("p",{className:"text-[10px] text-text-muted leading-snug",children:["Controls your running Chrome. Auto-strips Cowork's built-in browser tools."," ",(0,l.jsx)("a",{href:e.extensionUrl,target:"_blank",rel:"noopener noreferrer",className:"text-primary underline",children:"Install Chrome extension"})]})]})]})})()]})]}),Array.isArray(k?.localStdioPlugins)&&k.localStdioPlugins.filter(e=>"browsermcp"!==e.name).length>0&&(0,l.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr] sm:items-start sm:gap-2",children:[(0,l.jsx)("span",{className:"w-32 shrink-0 text-sm font-semibold text-text-main text-right pt-1",children:"Local Plugins"}),(0,l.jsx)("span",{className:"material-symbols-outlined text-text-muted text-[14px] mt-1.5",children:"arrow_forward"}),(0,l.jsxs)("div",{className:"flex-1 flex flex-col gap-2",children:[(0,l.jsx)("div",{className:"flex flex-col gap-1.5 px-2 py-1.5 bg-surface rounded border border-border",children:k.localStdioPlugins.filter(e=>"browsermcp"!==e.name).map(e=>{let t=J.includes(e.name);return(0,l.jsxs)("label",{className:"flex items-start gap-2 cursor-pointer",children:[(0,l.jsx)("input",{type:"checkbox",checked:t,onChange:t=>V(t.target.checked?[...J,e.name]:J.filter(t=>t!==e.name)),className:"mt-0.5"}),(0,l.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,l.jsxs)("div",{className:"flex flex-wrap items-center gap-1.5",children:[(0,l.jsx)("span",{className:"text-xs font-medium",children:e.title}),(0,l.jsx)("span",{className:"text-[8px] text-amber-600",children:"stdio"})]}),(0,l.jsx)("p",{className:"text-[10px] text-text-muted leading-snug",children:e.description}),e.extensionUrl&&(0,l.jsx)("a",{href:e.extensionUrl,target:"_blank",rel:"noopener noreferrer",className:"text-[10px] text-primary underline",children:"Install Chrome extension"})]})]},e.name)})}),(0,l.jsxs)("p",{className:"text-[10px] text-text-muted leading-snug",children:["⚠️ Local plugins run as subprocess via ",(0,l.jsx)("code",{className:"px-1 py-0.5 rounded bg-black/5 dark:bg-white/5",children:"npx"}),". Requires Node.js installed."]})]})]})]}),T&&(0,l.jsxs)("div",{className:`flex items-center gap-2 px-2 py-1.5 rounded text-xs ${"success"===T.type?"bg-green-500/10 text-green-600":"bg-red-500/10 text-red-600"}`,children:[(0,l.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"success"===T.type?"check_circle":"error"}),(0,l.jsx)("span",{children:T.text})]}),(0,l.jsxs)("div",{className:"flex flex-col sm:flex-row sm:items-center gap-2",children:[(0,l.jsxs)(r.$n,{variant:"primary",size:"sm",onClick:ex,disabled:0===D.length,loading:E,className:"w-full sm:w-auto",children:[(0,l.jsx)("span",{className:"material-symbols-outlined text-[14px] mr-1",children:"save"}),"Apply"]}),(0,l.jsxs)(r.$n,{variant:"outline",size:"sm",onClick:eh,disabled:!k.hasKRouter,loading:P,className:"w-full sm:w-auto",children:[(0,l.jsx)("span",{className:"material-symbols-outlined text-[14px] mr-1",children:"restore"}),"Reset"]}),(0,l.jsxs)(r.$n,{variant:"ghost",size:"sm",onClick:()=>F(!0),className:"w-full sm:w-auto",children:[(0,l.jsx)("span",{className:"material-symbols-outlined text-[14px] mr-1",children:"content_copy"}),"Manual Config"]})]})]})]}),(0,l.jsx)(r.uR,{isOpen:z,onClose:()=>F(!1),title:"Claude Cowork - Manual Configuration",configs:(v=U&&U.trim()?U:m?"<API_KEY_FROM_DASHBOARD>":"sk_krouter",w=D.length>0?D:["provider/model-id"],[{filename:"~/Library/Application Support/Claude-3p/configLibrary/<appliedId>.json",content:JSON.stringify({inferenceProvider:"gateway",inferenceGatewayBaseUrl:ec()||"https://your-public-host/v1",inferenceGatewayApiKey:v,inferenceModels:w.map(e=>({name:e}))},null,2)}])}),(0,l.jsx)(r.CK,{isOpen:X,combo:null,onClose:()=>ee(!1),onSave:ep,activeProviders:d,forcePrefix:"claude-",title:"Create Cowork Combo"}),(0,l.jsx)(r.rq,{isOpen:et,onClose:()=>es(!1),onSelect:e=>{let t=e?.value||e?.name||e;!t||D.includes(t)||L(e=>[...e,t])},onDeselect:eu,activeProviders:d,modelAliases:Z,title:"Select Cowork Model",addedModelValues:D,closeOnSelect:!1}),(0,l.jsx)(r.Nf,{isOpen:el,onClose:()=>ea(!1),onAdd:e=>{B.some(t=>t.name===e.name)||G([...B,e])},addedNames:B.map(e=>e.name)}),er&&(0,l.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/40",onClick:()=>ei(!1),children:(0,l.jsxs)("div",{className:"bg-surface border border-border rounded-xl shadow-xl w-full max-w-sm mx-4 p-5 flex flex-col gap-4",onClick:e=>e.stopPropagation(),children:[(0,l.jsxs)("div",{className:"flex items-center justify-between",children:[(0,l.jsx)("h3",{className:"font-semibold text-sm",children:"Add Custom MCP"}),(0,l.jsx)("button",{onClick:()=>ei(!1),className:"text-text-muted hover:text-text-main",children:(0,l.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:"close"})})]}),(0,l.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,l.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,l.jsx)("label",{className:"text-[11px] text-text-muted font-medium",children:"Name"}),(0,l.jsx)("input",{type:"text",placeholder:"my-mcp",value:en.name,onChange:e=>eo(t=>({...t,name:e.target.value.replace(/\s+/g,"-").toLowerCase()})),className:"px-2 py-1.5 rounded border border-border bg-surface text-xs outline-none focus:border-primary"})]}),(0,l.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,l.jsx)("label",{className:"text-[11px] text-text-muted font-medium",children:"SSE URL"}),(0,l.jsx)("input",{type:"text",placeholder:"https://your-mcp-server.com/sse",value:en.url,onChange:e=>eo(t=>({...t,url:e.target.value})),className:"px-2 py-1.5 rounded border border-border bg-surface text-xs outline-none focus:border-primary"})]})]}),(0,l.jsxs)("div",{className:"flex gap-2 justify-end",children:[(0,l.jsx)("button",{onClick:()=>ei(!1),className:"px-3 py-1.5 rounded border border-border text-xs text-text-muted hover:bg-surface cursor-pointer",children:"Cancel"}),(0,l.jsx)("button",{onClick:()=>{let e=en.name.trim();e&&en.url.trim()&&(Y(t=>[...t.filter(t=>t.name!==e),{name:e,url:en.url.trim(),transport:"sse",custom:!0}]),ei(!1))},className:"px-3 py-1.5 rounded bg-primary text-white text-xs font-medium hover:opacity-90 cursor-pointer",children:"Add"})]})]})})]})}function I({tool:e,isExpanded:t,onToggle:s,baseUrl:n,apiKeys:o,activeProviders:d,cloudEnabled:c,initialStatus:m,tunnelEnabled:p,tunnelPublicUrl:h,tailscaleEnabled:f,tailscaleUrl:y}){let b,j,[N,v]=(0,a.useState)(m||null),[w,k]=(0,a.useState)(!1),[C,_]=(0,a.useState)(!1),[S,E]=(0,a.useState)(!1),[A,O]=(0,a.useState)(null),[M,P]=(0,a.useState)(""),[R,T]=(0,a.useState)(""),[$,U]=(0,a.useState)({}),[K,D]=(0,a.useState)(!1),[L,z]=(0,a.useState)([]),[F,q]=(0,a.useState)(!1),H=(0,a.useRef)([]);(0,a.useEffect)(()=>{H.current=L},[L]),(0,a.useEffect)(()=>{o?.length>0&&!M&&P(o[0].key)},[o,M]),(0,a.useEffect)(()=>{m&&v(m)},[m]),(0,a.useEffect)(()=>{t&&!N&&(W(),B()),t&&B()},[t]),(0,a.useEffect)(()=>{if(N?.config&&Array.isArray(N.config)&&0===L.length){let e=N.config.find(e=>"kRouter"===e.name);e?.models?.length>0&&z(e.models.map(e=>e.id))}},[N]);let B=async()=>{try{let e=await fetch("/api/models/alias"),t=await e.json();e.ok&&U(t.aliases||{})}catch(e){console.log("Error fetching model aliases:",e)}},G=async e=>{try{let t=M&&M.trim()||c?M:"sk_krouter";await fetch("/api/cli-tools/copilot-settings",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({baseUrl:V(),apiKey:t,models:e})})}catch(e){console.log("Error saving models:",e)}},J=N?N.hasKRouter?g(N.currentUrl||"",{tunnelPublicUrl:h,tailscaleUrl:y})?"configured":"other":"not_configured":null,V=()=>{let e=R||n;return e.endsWith("/v1")?e:`${e}/v1`},W=async()=>{k(!0);try{let e=await fetch("/api/cli-tools/copilot-settings"),t=await e.json();v(t)}catch(e){v({error:e.message})}finally{k(!1)}},Y=async()=>{_(!0),O(null);try{let e=M&&M.trim()||c?M:"sk_krouter",t=await fetch("/api/cli-tools/copilot-settings",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({baseUrl:V(),apiKey:e,models:L})}),s=await t.json();t.ok?(O({type:"success",text:s.message||"Settings applied! Reload VS Code."}),W()):O({type:"error",text:s.error||"Failed to apply settings"})}catch(e){O({type:"error",text:e.message})}finally{_(!1)}},Z=async()=>{E(!0),O(null);try{let e=await fetch("/api/cli-tools/copilot-settings",{method:"DELETE"}),t=await e.json();e.ok?(O({type:"success",text:"Settings reset successfully!"}),z([]),W()):O({type:"error",text:t.error||"Failed to reset settings"})}catch(e){O({type:"error",text:e.message})}finally{E(!1)}};return(0,l.jsxs)(r.Zp,{padding:"xs",className:"overflow-hidden",children:[(0,l.jsxs)("div",{className:"flex items-start justify-between gap-3 hover:cursor-pointer sm:items-center",onClick:s,children:[(0,l.jsxs)("div",{className:"flex min-w-0 items-center gap-3",children:[(0,l.jsx)("div",{className:"size-8 flex items-center justify-center shrink-0",children:(0,l.jsx)(i.A,{src:"/providers/copilot.png",alt:e.name,width:32,height:32,className:"size-8 object-contain rounded-lg",sizes:"32px",onError:e=>{e.target.style.display="none"}})}),(0,l.jsxs)("div",{className:"min-w-0",children:[(0,l.jsxs)("div",{className:"flex min-w-0 flex-wrap items-center gap-2",children:[(0,l.jsx)("h3",{className:"font-medium text-sm",children:e.name}),"configured"===J&&(0,l.jsx)("span",{className:"px-1.5 py-0.5 text-[10px] font-medium bg-green-500/10 text-green-600 dark:text-green-400 rounded-full",children:"Connected"}),"not_configured"===J&&(0,l.jsx)("span",{className:"px-1.5 py-0.5 text-[10px] font-medium bg-yellow-500/10 text-yellow-600 dark:text-yellow-400 rounded-full",children:"Not configured"}),"other"===J&&(0,l.jsx)("span",{className:"px-1.5 py-0.5 text-[10px] font-medium bg-blue-500/10 text-blue-600 dark:text-blue-400 rounded-full",children:"Other"})]}),(0,l.jsx)("p",{className:"text-xs text-text-muted truncate",children:e.description})]})]}),(0,l.jsx)("span",{className:`material-symbols-outlined text-text-muted text-[20px] transition-transform ${t?"rotate-180":""}`,children:"expand_more"})]}),t&&(0,l.jsxs)("div",{className:"mt-4 pt-4 border-t border-border flex flex-col gap-4",children:[w&&(0,l.jsxs)("div",{className:"flex items-center gap-2 text-text-muted",children:[(0,l.jsx)("span",{className:"material-symbols-outlined animate-spin",children:"progress_activity"}),(0,l.jsx)("span",{children:"Checking Copilot config..."})]}),!w&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)("div",{className:"flex items-start gap-3 p-3 bg-blue-500/10 border border-blue-500/30 rounded-lg",children:[(0,l.jsx)("span",{className:"material-symbols-outlined text-blue-500 text-lg",children:"info"}),(0,l.jsxs)("div",{className:"text-xs text-blue-700 dark:text-blue-300",children:[(0,l.jsxs)("p",{className:"font-medium",children:["Writes to ",(0,l.jsx)("code",{className:"px-1 bg-black/5 dark:bg-white/10 rounded",children:"chatLanguageModels.json"})]}),(0,l.jsx)("p",{className:"mt-0.5 opacity-80",children:"Reload VS Code after applying for changes to take effect."})]})]}),(0,l.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,l.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr] sm:items-center sm:gap-2",children:[(0,l.jsx)("span",{className:"text-xs font-semibold text-text-main sm:text-right sm:text-sm",children:"Select Endpoint"}),(0,l.jsx)("span",{className:"material-symbols-outlined hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,l.jsx)(x,{value:R||R||`${n}/v1`,onChange:T,requiresExternalUrl:e.requiresExternalUrl,tunnelEnabled:p,tunnelPublicUrl:h,tailscaleEnabled:f,tailscaleUrl:y})]}),(0,l.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr_auto] sm:items-center sm:gap-2",children:[(0,l.jsx)("span",{className:"text-xs font-semibold text-text-main sm:text-right sm:text-sm",children:"API Key"}),(0,l.jsx)("span",{className:"material-symbols-outlined hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,l.jsx)(u,{value:M,onChange:P,apiKeys:o,cloudEnabled:c})]}),(0,l.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr] sm:items-start sm:gap-2",children:[(0,l.jsx)("span",{className:"w-32 shrink-0 text-sm font-semibold text-text-main text-right pt-1",children:"Models"}),(0,l.jsx)("span",{className:"material-symbols-outlined text-text-muted text-[14px] mt-1.5",children:"arrow_forward"}),(0,l.jsxs)("div",{className:"flex-1 flex flex-col gap-2",children:[(0,l.jsx)("div",{className:"flex flex-wrap gap-1.5 min-h-[28px] px-2 py-1.5 bg-surface rounded border border-border",children:0===L.length?(0,l.jsx)("span",{className:"text-xs text-text-muted",children:"No models selected"}):L.map(e=>(0,l.jsxs)("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 rounded text-xs bg-black/5 dark:bg-white/5 text-text-muted border border-transparent hover:border-border",children:[e,(0,l.jsx)("button",{onClick:t=>{t.stopPropagation(),z(t=>t.filter(t=>t!==e))},className:"ml-0.5 hover:text-red-500",children:(0,l.jsx)("span",{className:"material-symbols-outlined text-[12px]",children:"close"})})]},e))}),(0,l.jsx)("div",{children:(0,l.jsx)("button",{onClick:()=>q(!0),disabled:!d?.length,className:`px-2 py-1 rounded border text-xs transition-colors ${d?.length?"bg-surface border-border text-text-main hover:border-primary cursor-pointer":"opacity-50 cursor-not-allowed border-border"}`,children:"Add Model"})})]})]})]}),A&&(0,l.jsxs)("div",{className:`flex items-center gap-2 px-2 py-1.5 rounded text-xs ${"success"===A.type?"bg-green-500/10 text-green-600":"bg-red-500/10 text-red-600"}`,children:[(0,l.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"success"===A.type?"check_circle":"error"}),(0,l.jsx)("span",{children:A.text})]}),(0,l.jsxs)("div",{className:"grid grid-cols-1 gap-2 sm:flex sm:items-center",children:[(0,l.jsxs)(r.$n,{variant:"primary",size:"sm",onClick:Y,disabled:0===L.length,loading:C,children:[(0,l.jsx)("span",{className:"material-symbols-outlined text-[14px] mr-1",children:"save"}),"Apply"]}),(0,l.jsxs)(r.$n,{variant:"outline",size:"sm",onClick:Z,disabled:!N?.hasKRouter,loading:S,children:[(0,l.jsx)("span",{className:"material-symbols-outlined text-[14px] mr-1",children:"restore"}),"Reset"]}),(0,l.jsxs)(r.$n,{variant:"ghost",size:"sm",onClick:()=>D(!0),disabled:0===L.length,children:[(0,l.jsx)("span",{className:"material-symbols-outlined text-[14px] mr-1",children:"content_copy"}),"Manual Config"]})]})]})]}),(0,l.jsx)(r.rq,{isOpen:F,onClose:()=>{q(!1),G(H.current)},onSelect:e=>{L.includes(e.value)||z([...L,e.value])},onDeselect:e=>{z(L.filter(t=>t!==e.value))},selectedModel:null,activeProviders:d,modelAliases:$,addedModelValues:L,closeOnSelect:!1,title:"Add Model for GitHub Copilot"}),(0,l.jsx)(r.uR,{isOpen:K,onClose:()=>D(!1),title:"GitHub Copilot - Manual Configuration",configs:(b=M&&M.trim()?M:c?"<API_KEY_FROM_DASHBOARD>":"sk_krouter",j=V(),[{filename:"~/Library/Application Support/Code/User/chatLanguageModels.json",content:JSON.stringify([{name:"kRouter",vendor:"azure",apiKey:b,models:(L.length>0?L:["provider/model-id"]).map(e=>({id:e,name:e,url:`${j}/chat/completions#models.ai.azure.com`,toolCalling:!0,vision:!1,maxInputTokens:128e3,maxOutputTokens:16e3}))}],null,2)}])})]})}function P({tool:e,isExpanded:t,onToggle:s,baseUrl:n,apiKeys:o,activeProviders:d,cloudEnabled:c,initialStatus:m,tunnelEnabled:p,tunnelPublicUrl:h,tailscaleEnabled:f,tailscaleUrl:y}){let b,j,N,[v,w]=(0,a.useState)(m||null),[k,C]=(0,a.useState)(!1),[_,S]=(0,a.useState)(!1),[E,A]=(0,a.useState)(!1),[O,M]=(0,a.useState)(null),[I,R]=(0,a.useState)(!1),[T,$]=(0,a.useState)(""),[U,K]=(0,a.useState)(""),[D,L]=(0,a.useState)(!1),[z,F]=(0,a.useState)({}),[q,H]=(0,a.useState)(!1),[B,G]=(0,a.useState)("");(0,a.useEffect)(()=>{o?.length>0&&!T&&$(o[0].key)},[o,T]),(0,a.useEffect)(()=>{m&&w(m)},[m]),(0,a.useEffect)(()=>{t&&!v&&(Y(),J()),t&&J()},[t]),(0,a.useEffect)(()=>{v?.settings?.openAiModelId&&K(v.settings.openAiModelId)},[v]);let J=async()=>{try{let e=await fetch("/api/models/alias"),t=await e.json();e.ok&&F(t.aliases||{})}catch(e){console.log("Error fetching model aliases:",e)}},V=v?.installed?v.hasKRouter?g(v.settings?.openAiBaseUrl||"",{tunnelPublicUrl:h,tailscaleUrl:y})?"configured":"other":"not_configured":null,W=()=>{let e=B||`${n}/v1`;return e.endsWith("/v1")?e:`${e}/v1`},Y=async()=>{C(!0);try{let e=await fetch("/api/cli-tools/cline-settings"),t=await e.json();w(t)}catch(e){w({installed:!1,error:e.message})}finally{C(!1)}},Z=async()=>{S(!0),M(null);try{let e=T&&T.trim()||c?T:"sk_krouter",t=await fetch("/api/cli-tools/cline-settings",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({baseUrl:W(),apiKey:e,model:U})}),s=await t.json();t.ok?(M({type:"success",text:"Settings applied successfully!"}),Y()):M({type:"error",text:s.error||"Failed to apply settings"})}catch(e){M({type:"error",text:e.message})}finally{S(!1)}},Q=async()=>{A(!0),M(null);try{let e=[W(),`${n}/v1`,h,y].filter(Boolean),t=await fetch("/api/cli-tools/cline-settings",{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({baseUrls:e})}),s=await t.json();t.ok?(M({type:"success",text:"Settings reset successfully!"}),K(""),Y()):M({type:"error",text:s.error||"Failed to reset settings"})}catch(e){M({type:"error",text:e.message})}finally{A(!1)}};return(0,l.jsxs)(r.Zp,{padding:"xs",className:"overflow-hidden",children:[(0,l.jsxs)("div",{className:"flex items-start justify-between gap-3 hover:cursor-pointer sm:items-center",onClick:s,children:[(0,l.jsxs)("div",{className:"flex min-w-0 items-center gap-3",children:[(0,l.jsx)("div",{className:"size-8 flex items-center justify-center shrink-0",children:(0,l.jsx)(i.A,{src:"/providers/cline.png",alt:e.name,width:32,height:32,className:"size-8 object-contain rounded-lg",sizes:"32px",onError:e=>{e.target.style.display="none"}})}),(0,l.jsxs)("div",{className:"min-w-0",children:[(0,l.jsxs)("div",{className:"flex min-w-0 flex-wrap items-center gap-2",children:[(0,l.jsx)("h3",{className:"font-medium text-sm",children:e.name}),"configured"===V&&(0,l.jsx)("span",{className:"px-1.5 py-0.5 text-[10px] font-medium bg-green-500/10 text-green-600 dark:text-green-400 rounded-full",children:"Connected"}),"not_configured"===V&&(0,l.jsx)("span",{className:"px-1.5 py-0.5 text-[10px] font-medium bg-yellow-500/10 text-yellow-600 dark:text-yellow-400 rounded-full",children:"Not configured"}),"other"===V&&(0,l.jsx)("span",{className:"px-1.5 py-0.5 text-[10px] font-medium bg-blue-500/10 text-blue-600 dark:text-blue-400 rounded-full",children:"Other"})]}),(0,l.jsx)("p",{className:"text-xs text-text-muted truncate",children:e.description})]})]}),(0,l.jsx)("span",{className:`material-symbols-outlined text-text-muted text-[20px] transition-transform ${t?"rotate-180":""}`,children:"expand_more"})]}),t&&(0,l.jsxs)("div",{className:"mt-4 pt-4 border-t border-border flex flex-col gap-4",children:[(0,l.jsxs)("div",{className:"flex items-start gap-3 p-3 rounded-lg border bg-blue-500/10 border-blue-500/30",children:[(0,l.jsx)("span",{className:"material-symbols-outlined text-lg text-blue-500",children:"info"}),(0,l.jsxs)("div",{className:"flex flex-col gap-1 text-sm text-blue-600 dark:text-blue-400",children:[(0,l.jsx)("p",{children:"Apply writes ~/.cline/data on the machine running kRouter. The Cline CLI picks it up on its next run."}),(0,l.jsxs)("p",{children:['Recent versions of the Cline VS Code extension share that folder but read it only when VS Code starts. Quit VS Code before Apply, then reopen it. Or set it up by hand in Cline settings: API Provider "OpenAI Compatible", Base URL ',(0,l.jsx)("code",{className:"font-mono break-all",children:W()}),", your kRouter API Key, and the Model ID."]})]})]}),k&&(0,l.jsxs)("div",{className:"flex items-center gap-2 text-text-muted",children:[(0,l.jsx)("span",{className:"material-symbols-outlined animate-spin",children:"progress_activity"}),(0,l.jsx)("span",{children:"Checking Cline..."})]}),!k&&v&&!v.installed&&(0,l.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,l.jsxs)("div",{className:"flex flex-col gap-3 p-4 bg-yellow-500/10 border border-yellow-500/30 rounded-lg",children:[(0,l.jsxs)("div",{className:"flex items-start gap-3",children:[(0,l.jsx)("span",{className:"material-symbols-outlined text-yellow-500",children:"warning"}),(0,l.jsxs)("div",{className:"flex-1",children:[(0,l.jsx)("p",{className:"font-medium text-yellow-600 dark:text-yellow-400",children:"Cline not detected locally"}),(0,l.jsx)("p",{className:"text-sm text-text-muted",children:"Manual configuration is still available if kRouter is deployed on a remote server."})]})]}),(0,l.jsxs)("div",{className:"flex items-center gap-2 pl-9",children:[(0,l.jsxs)(r.$n,{variant:"secondary",size:"sm",onClick:()=>H(!0),className:"!bg-yellow-500/20 !border-yellow-500/40 !text-yellow-700 dark:!text-yellow-300 hover:!bg-yellow-500/30",children:[(0,l.jsx)("span",{className:"material-symbols-outlined text-[18px] mr-1",children:"content_copy"}),"Manual Config"]}),(0,l.jsxs)(r.$n,{variant:"outline",size:"sm",onClick:()=>R(!I),children:[(0,l.jsx)("span",{className:"material-symbols-outlined text-[18px] mr-1",children:I?"expand_less":"help"}),I?"Hide":"How to Install"]})]})]}),I&&(0,l.jsxs)("div",{className:"p-4 bg-surface border border-border rounded-lg",children:[(0,l.jsx)("h4",{className:"font-medium mb-3",children:"Installation Guide"}),(0,l.jsx)("div",{className:"space-y-3 text-sm",children:(0,l.jsxs)("p",{className:"text-text-muted",children:["Install Cline VS Code extension or CLI from ",(0,l.jsx)("a",{className:"text-primary underline",href:"https://docs.cline.bot/",target:"_blank",rel:"noreferrer",children:"docs.cline.bot"}),"."]})})]})]}),!k&&v?.installed&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,l.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr] sm:items-center sm:gap-2",children:[(0,l.jsx)("span",{className:"text-xs font-semibold text-text-main sm:text-right sm:text-sm",children:"Select Endpoint"}),(0,l.jsx)("span",{className:"material-symbols-outlined hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,l.jsx)(x,{value:B||B||`${n}/v1`,onChange:G,requiresExternalUrl:e.requiresExternalUrl,tunnelEnabled:p,tunnelPublicUrl:h,tailscaleEnabled:f,tailscaleUrl:y})]}),v?.settings?.openAiBaseUrl&&(0,l.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr_auto] sm:items-center sm:gap-2",children:[(0,l.jsx)("span",{className:"text-xs font-semibold text-text-main sm:text-right sm:text-sm",children:"Current"}),(0,l.jsx)("span",{className:"material-symbols-outlined hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,l.jsx)("span",{className:"min-w-0 truncate rounded bg-surface/40 px-2 py-2 text-xs text-text-muted sm:py-1.5",children:v.settings.openAiBaseUrl})]}),(0,l.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr_auto] sm:items-center sm:gap-2",children:[(0,l.jsx)("span",{className:"text-xs font-semibold text-text-main sm:text-right sm:text-sm",children:"API Key"}),(0,l.jsx)("span",{className:"material-symbols-outlined hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,l.jsx)(u,{value:T,onChange:$,apiKeys:o,cloudEnabled:c})]}),(0,l.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr_auto] sm:items-center sm:gap-2",children:[(0,l.jsx)("span",{className:"text-xs font-semibold text-text-main sm:text-right sm:text-sm",children:"Model"}),(0,l.jsx)("span",{className:"material-symbols-outlined hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,l.jsxs)("div",{className:"relative w-full min-w-0",children:[(0,l.jsx)("input",{type:"text",value:U,onChange:e=>K(e.target.value),placeholder:"provider/model-id",className:"w-full min-w-0 pl-2 pr-7 py-2 bg-surface rounded border border-border text-xs focus:outline-none focus:ring-1 focus:ring-primary/50 sm:py-1.5"}),U&&(0,l.jsx)("button",{onClick:()=>K(""),className:"absolute right-1 top-1/2 -translate-y-1/2 p-0.5 text-text-muted hover:text-red-500 rounded transition-colors",title:"Clear",children:(0,l.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"close"})})]}),(0,l.jsx)("button",{onClick:()=>L(!0),disabled:!d?.length,className:`w-full sm:w-auto rounded border px-2 py-2 text-xs transition-colors sm:py-1.5 whitespace-nowrap sm:shrink-0 ${d?.length?"bg-surface border-border text-text-main hover:border-primary cursor-pointer":"opacity-50 cursor-not-allowed border-border"}`,children:"Select Model"})]})]}),O&&(0,l.jsxs)("div",{className:`flex items-center gap-2 px-2 py-1.5 rounded text-xs ${"success"===O.type?"bg-green-500/10 text-green-600":"bg-red-500/10 text-red-600"}`,children:[(0,l.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"success"===O.type?"check_circle":"error"}),(0,l.jsx)("span",{children:O.text})]}),(0,l.jsxs)("div",{className:"grid grid-cols-1 gap-2 sm:flex sm:items-center",children:[(0,l.jsxs)(r.$n,{variant:"primary",size:"sm",onClick:Z,disabled:!T&&c&&o.length>0||!U,loading:_,children:[(0,l.jsx)("span",{className:"material-symbols-outlined text-[14px] mr-1",children:"save"}),"Apply"]}),(0,l.jsxs)(r.$n,{variant:"outline",size:"sm",onClick:Q,disabled:E,loading:E,children:[(0,l.jsx)("span",{className:"material-symbols-outlined text-[14px] mr-1",children:"restore"}),"Reset"]}),(0,l.jsxs)(r.$n,{variant:"ghost",size:"sm",onClick:()=>H(!0),children:[(0,l.jsx)("span",{className:"material-symbols-outlined text-[14px] mr-1",children:"content_copy"}),"Manual Config"]})]})]})]}),(0,l.jsx)(r.rq,{isOpen:D,onClose:()=>L(!1),onSelect:e=>{K(e.value),L(!1)},selectedModel:U,activeProviders:d,modelAliases:z,title:"Select Model for Cline"}),(0,l.jsx)(r.uR,{isOpen:q,onClose:()=>H(!1),title:"Cline - Manual Configuration",configs:(b=T&&T.trim()?T:c?"<API_KEY_FROM_DASHBOARD>":"sk_krouter",j=W(),N=U||"provider/model-id",[{filename:"Cline CLI (run in a terminal)",content:`cline auth --provider openai-compatible --apikey "${b}" --modelid "${N}" --baseurl "${j}"`},{filename:"~/.cline/data/globalState.json (VS Code extension, edit with VS Code closed)",content:JSON.stringify({actModeApiProvider:"openai",planModeApiProvider:"openai",openAiBaseUrl:j,actModeOpenAiModelId:N,planModeOpenAiModelId:N},null,2)},{filename:"~/.cline/data/secrets.json",content:JSON.stringify({openAiApiKey:b},null,2)}])})]})}function R({tool:e,isExpanded:t,onToggle:s,baseUrl:n,apiKeys:o,activeProviders:d,cloudEnabled:c,initialStatus:m,tunnelEnabled:p,tunnelPublicUrl:h,tailscaleEnabled:g,tailscaleUrl:f}){let[y,b]=(0,a.useState)(m||null),[j,N]=(0,a.useState)(!1),[v,w]=(0,a.useState)(!1),[k,C]=(0,a.useState)(!1),[_,S]=(0,a.useState)(null),[E,A]=(0,a.useState)(!1),[O,M]=(0,a.useState)(""),[I,P]=(0,a.useState)(""),[T,$]=(0,a.useState)(!1),[U,K]=(0,a.useState)({}),[D,L]=(0,a.useState)(!1),[z,F]=(0,a.useState)("");(0,a.useEffect)(()=>{o?.length>0&&!O&&M(o[0].key)},[o,O]),(0,a.useEffect)(()=>{m&&b(m)},[m]),(0,a.useEffect)(()=>{t&&!y&&(G(),q()),t&&q()},[t]);let q=async()=>{try{let e=await fetch("/api/models/alias"),t=await e.json();e.ok&&K(t.aliases||{})}catch(e){console.log("Error fetching model aliases:",e)}},H=y?.installed?y.hasKRouter?"configured":"not_configured":null,B=()=>{let e=z||`${n}/v1`;return e.endsWith("/v1")?e:`${e}/v1`},G=async()=>{N(!0);try{let e=await fetch("/api/cli-tools/kilo-settings"),t=await e.json();b(t)}catch(e){b({installed:!1,error:e.message})}finally{N(!1)}},J=async()=>{w(!0),S(null);try{let e=O&&O.trim()||c?O:"sk_krouter",t=await fetch("/api/cli-tools/kilo-settings",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({baseUrl:B(),apiKey:e,model:I})}),s=await t.json();t.ok?(S({type:"success",text:"Settings applied successfully!"}),G()):S({type:"error",text:s.error||"Failed to apply settings"})}catch(e){S({type:"error",text:e.message})}finally{w(!1)}},V=async()=>{C(!0),S(null);try{let e=await fetch("/api/cli-tools/kilo-settings",{method:"DELETE"}),t=await e.json();e.ok?(S({type:"success",text:"Settings reset successfully!"}),P(""),G()):S({type:"error",text:t.error||"Failed to reset settings"})}catch(e){S({type:"error",text:e.message})}finally{C(!1)}};return(0,l.jsxs)(r.Zp,{padding:"xs",className:"overflow-hidden",children:[(0,l.jsxs)("div",{className:"flex items-start justify-between gap-3 hover:cursor-pointer sm:items-center",onClick:s,children:[(0,l.jsxs)("div",{className:"flex min-w-0 items-center gap-3",children:[(0,l.jsx)("div",{className:"size-8 flex items-center justify-center shrink-0",children:(0,l.jsx)(i.A,{src:"/providers/kilocode.png",alt:e.name,width:32,height:32,className:"size-8 object-contain rounded-lg",sizes:"32px",onError:e=>{e.target.style.display="none"}})}),(0,l.jsxs)("div",{className:"min-w-0",children:[(0,l.jsxs)("div",{className:"flex min-w-0 flex-wrap items-center gap-2",children:[(0,l.jsx)("h3",{className:"font-medium text-sm",children:e.name}),"configured"===H&&(0,l.jsx)("span",{className:"px-1.5 py-0.5 text-[10px] font-medium bg-green-500/10 text-green-600 dark:text-green-400 rounded-full",children:"Connected"}),"not_configured"===H&&(0,l.jsx)("span",{className:"px-1.5 py-0.5 text-[10px] font-medium bg-yellow-500/10 text-yellow-600 dark:text-yellow-400 rounded-full",children:"Not configured"})]}),(0,l.jsx)("p",{className:"text-xs text-text-muted truncate",children:e.description})]})]}),(0,l.jsx)("span",{className:`material-symbols-outlined text-text-muted text-[20px] transition-transform ${t?"rotate-180":""}`,children:"expand_more"})]}),t&&(0,l.jsxs)("div",{className:"mt-4 pt-4 border-t border-border flex flex-col gap-4",children:[j&&(0,l.jsxs)("div",{className:"flex items-center gap-2 text-text-muted",children:[(0,l.jsx)("span",{className:"material-symbols-outlined animate-spin",children:"progress_activity"}),(0,l.jsx)("span",{children:"Checking Kilo Code..."})]}),!j&&y&&!y.installed&&(0,l.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,l.jsxs)("div",{className:"flex flex-col gap-3 p-4 bg-yellow-500/10 border border-yellow-500/30 rounded-lg",children:[(0,l.jsxs)("div",{className:"flex items-start gap-3",children:[(0,l.jsx)("span",{className:"material-symbols-outlined text-yellow-500",children:"warning"}),(0,l.jsxs)("div",{className:"flex-1",children:[(0,l.jsx)("p",{className:"font-medium text-yellow-600 dark:text-yellow-400",children:"Kilo Code not detected locally"}),(0,l.jsx)("p",{className:"text-sm text-text-muted",children:"Manual configuration is still available if kRouter is deployed on a remote server."})]})]}),(0,l.jsxs)("div",{className:"flex items-center gap-2 pl-9",children:[(0,l.jsxs)(r.$n,{variant:"secondary",size:"sm",onClick:()=>L(!0),className:"!bg-yellow-500/20 !border-yellow-500/40 !text-yellow-700 dark:!text-yellow-300 hover:!bg-yellow-500/30",children:[(0,l.jsx)("span",{className:"material-symbols-outlined text-[18px] mr-1",children:"content_copy"}),"Manual Config"]}),(0,l.jsxs)(r.$n,{variant:"outline",size:"sm",onClick:()=>A(!E),children:[(0,l.jsx)("span",{className:"material-symbols-outlined text-[18px] mr-1",children:E?"expand_less":"help"}),E?"Hide":"How to Install"]})]})]}),E&&(0,l.jsxs)("div",{className:"p-4 bg-surface border border-border rounded-lg",children:[(0,l.jsx)("h4",{className:"font-medium mb-3",children:"Installation Guide"}),(0,l.jsxs)("p",{className:"text-sm text-text-muted",children:["Install Kilo Code from ",(0,l.jsx)("a",{className:"text-primary underline",href:"https://kilocode.ai",target:"_blank",rel:"noreferrer",children:"kilocode.ai"})," or VS Code extension marketplace."]})]})]}),!j&&y?.installed&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,l.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr] sm:items-center sm:gap-2",children:[(0,l.jsx)("span",{className:"text-xs font-semibold text-text-main sm:text-right sm:text-sm",children:"Select Endpoint"}),(0,l.jsx)("span",{className:"material-symbols-outlined hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,l.jsx)(x,{value:z||z||`${n}/v1`,onChange:F,requiresExternalUrl:e.requiresExternalUrl,tunnelEnabled:p,tunnelPublicUrl:h,tailscaleEnabled:g,tailscaleUrl:f})]}),(0,l.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr_auto] sm:items-center sm:gap-2",children:[(0,l.jsx)("span",{className:"text-xs font-semibold text-text-main sm:text-right sm:text-sm",children:"API Key"}),(0,l.jsx)("span",{className:"material-symbols-outlined hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,l.jsx)(u,{value:O,onChange:M,apiKeys:o,cloudEnabled:c})]}),(0,l.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr_auto] sm:items-center sm:gap-2",children:[(0,l.jsx)("span",{className:"text-xs font-semibold text-text-main sm:text-right sm:text-sm",children:"Model"}),(0,l.jsx)("span",{className:"material-symbols-outlined hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,l.jsxs)("div",{className:"relative w-full min-w-0",children:[(0,l.jsx)("input",{type:"text",value:I,onChange:e=>P(e.target.value),placeholder:"provider/model-id",className:"w-full min-w-0 pl-2 pr-7 py-2 bg-surface rounded border border-border text-xs focus:outline-none focus:ring-1 focus:ring-primary/50 sm:py-1.5"}),I&&(0,l.jsx)("button",{onClick:()=>P(""),className:"absolute right-1 top-1/2 -translate-y-1/2 p-0.5 text-text-muted hover:text-red-500 rounded transition-colors",title:"Clear",children:(0,l.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"close"})})]}),(0,l.jsx)("button",{onClick:()=>$(!0),disabled:!d?.length,className:`w-full sm:w-auto rounded border px-2 py-2 text-xs transition-colors sm:py-1.5 whitespace-nowrap sm:shrink-0 ${d?.length?"bg-surface border-border text-text-main hover:border-primary cursor-pointer":"opacity-50 cursor-not-allowed border-border"}`,children:"Select Model"})]})]}),_&&(0,l.jsxs)("div",{className:`flex items-center gap-2 px-2 py-1.5 rounded text-xs ${"success"===_.type?"bg-green-500/10 text-green-600":"bg-red-500/10 text-red-600"}`,children:[(0,l.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"success"===_.type?"check_circle":"error"}),(0,l.jsx)("span",{children:_.text})]}),(0,l.jsxs)("div",{className:"grid grid-cols-1 gap-2 sm:flex sm:items-center",children:[(0,l.jsxs)(r.$n,{variant:"primary",size:"sm",onClick:J,disabled:!O&&c&&o.length>0||!I,loading:v,children:[(0,l.jsx)("span",{className:"material-symbols-outlined text-[14px] mr-1",children:"save"}),"Apply"]}),(0,l.jsxs)(r.$n,{variant:"outline",size:"sm",onClick:V,disabled:k,loading:k,children:[(0,l.jsx)("span",{className:"material-symbols-outlined text-[14px] mr-1",children:"restore"}),"Reset"]}),(0,l.jsxs)(r.$n,{variant:"ghost",size:"sm",onClick:()=>L(!0),children:[(0,l.jsx)("span",{className:"material-symbols-outlined text-[14px] mr-1",children:"content_copy"}),"Manual Config"]})]})]})]}),(0,l.jsx)(r.rq,{isOpen:T,onClose:()=>$(!1),onSelect:e=>{P(e.value),$(!1)},selectedModel:I,activeProviders:d,modelAliases:U,title:"Select Model for Kilo Code"}),(0,l.jsx)(r.uR,{isOpen:D,onClose:()=>L(!1),title:"Kilo Code - Manual Configuration",configs:[{filename:"~/.local/share/kilo/auth.json",content:JSON.stringify({"openai-compatible":{type:"api-key",apiKey:O&&O.trim()?O:c?"<API_KEY_FROM_DASHBOARD>":"sk_krouter",baseUrl:B(),model:I||"provider/model-id"}},null,2)}]})]})}let T="/api/cli-tools/deepseek-tui-settings";function $({tool:e,isExpanded:t,onToggle:s,baseUrl:n,hasActiveProviders:o,apiKeys:d,activeProviders:c,cloudEnabled:m,initialStatus:p,tunnelEnabled:h,tunnelPublicUrl:f,tailscaleEnabled:y,tailscaleUrl:b}){let j,[N,v]=(0,a.useState)(p||null),[w,k]=(0,a.useState)(!1),[C,_]=(0,a.useState)(!1),[S,E]=(0,a.useState)(!1),[A,O]=(0,a.useState)(null),[M,I]=(0,a.useState)(""),[P,R]=(0,a.useState)(""),[U,K]=(0,a.useState)(!1),[D,L]=(0,a.useState)({}),[z,F]=(0,a.useState)(!1),[q,H]=(0,a.useState)(""),B=(0,a.useRef)(!1),G=(()=>{if(!N?.installed)return null;let e=N.settings?.["providers.openai"];return e?.base_url?g(e.base_url,{tunnelPublicUrl:f,tailscaleUrl:b})?"configured":"other":"not_configured"})();(0,a.useEffect)(()=>{d?.length>0&&!M&&I(d[0].key)},[d,M]),(0,a.useEffect)(()=>{p&&v(p)},[p]),(0,a.useEffect)(()=>{t&&!N&&(V(),J()),t&&J()},[t]);let J=async()=>{try{let e=await fetch("/api/models/alias"),t=await e.json();e.ok&&L(t.aliases||{})}catch(e){console.log("Error fetching model aliases:",e)}};(0,a.useEffect)(()=>{if(N?.installed&&!B.current){B.current=!0;let e=N.settings?.["providers.openai"];e?.model&&R(e.model)}},[N]);let V=async()=>{k(!0);try{let e=await fetch(T),t=await e.json();v(t)}catch(e){v({installed:!1,error:e.message})}finally{k(!1)}},W=()=>{let e=q||window.location.origin.replace("://localhost","://127.0.0.1");return e.endsWith("/v1")?e:`${e}/v1`},Y=async()=>{_(!0),O(null);try{let e=M?.trim()||(d?.length>0?d[0].key:null)||(m?null:"sk_krouter"),t=await fetch(T,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({baseUrl:W(),apiKey:e,model:P})}),s=await t.json();t.ok?(O({type:"success",text:"Settings applied successfully!"}),V()):O({type:"error",text:s.error||"Failed to apply settings"})}catch(e){O({type:"error",text:e.message})}finally{_(!1)}},Z=async()=>{E(!0),O(null);try{let e=await fetch(T,{method:"DELETE"}),t=await e.json();e.ok?(O({type:"success",text:"Settings reset successfully!"}),R(""),V()):O({type:"error",text:t.error||"Failed to reset settings"})}catch(e){O({type:"error",text:e.message})}finally{E(!1)}};return(0,l.jsxs)(r.Zp,{padding:"xs",className:"overflow-hidden",children:[(0,l.jsxs)("div",{className:"flex items-start justify-between gap-3 hover:cursor-pointer sm:items-center",onClick:s,children:[(0,l.jsxs)("div",{className:"flex min-w-0 items-center gap-3",children:[(0,l.jsx)("div",{className:"size-8 flex items-center justify-center shrink-0",children:(0,l.jsx)(i.A,{src:e.image||"/providers/deepseek-tui.png",alt:e.name,width:32,height:32,className:"size-8 object-contain rounded-lg",sizes:"32px",onError:e=>{e.target.style.display="none"}})}),(0,l.jsxs)("div",{className:"min-w-0",children:[(0,l.jsxs)("div",{className:"flex min-w-0 flex-wrap items-center gap-2",children:[(0,l.jsx)("h3",{className:"font-medium text-sm",children:e.name}),"configured"===G&&(0,l.jsx)("span",{className:"px-1.5 py-0.5 text-[10px] font-medium bg-green-500/10 text-green-600 dark:text-green-400 rounded-full",children:"Connected"}),"not_configured"===G&&(0,l.jsx)("span",{className:"px-1.5 py-0.5 text-[10px] font-medium bg-yellow-500/10 text-yellow-600 dark:text-yellow-400 rounded-full",children:"Not configured"}),"other"===G&&(0,l.jsx)("span",{className:"px-1.5 py-0.5 text-[10px] font-medium bg-blue-500/10 text-blue-600 dark:text-blue-400 rounded-full",children:"Other"})]}),(0,l.jsx)("p",{className:"text-xs text-text-muted truncate",children:e.description})]})]}),(0,l.jsx)("span",{className:`material-symbols-outlined text-text-muted text-[20px] transition-transform ${t?"rotate-180":""}`,children:"expand_more"})]}),t&&(0,l.jsxs)("div",{className:"mt-4 pt-4 border-t border-border flex flex-col gap-4",children:[w&&(0,l.jsxs)("div",{className:"flex items-center gap-2 text-text-muted",children:[(0,l.jsx)("span",{className:"material-symbols-outlined animate-spin",children:"progress_activity"}),(0,l.jsx)("span",{children:"Checking DeepSeek TUI..."})]}),!w&&N&&!N.installed&&(0,l.jsx)("div",{className:"flex flex-col gap-4",children:(0,l.jsxs)("div",{className:"flex flex-col gap-3 p-4 bg-yellow-500/10 border border-yellow-500/30 rounded-lg",children:[(0,l.jsxs)("div",{className:"flex items-start gap-3",children:[(0,l.jsx)("span",{className:"material-symbols-outlined text-yellow-500",children:"warning"}),(0,l.jsxs)("div",{className:"flex-1",children:[(0,l.jsx)("p",{className:"font-medium text-yellow-600 dark:text-yellow-400",children:"DeepSeek TUI not detected locally"}),(0,l.jsx)("p",{className:"text-sm text-text-muted mt-1",children:"Install via npm:"}),(0,l.jsx)("code",{className:"block mt-2 p-2 bg-black/20 rounded text-xs font-mono",children:"npm install -g deepseek-tui"}),(0,l.jsx)("p",{className:"text-sm text-text-muted mt-2",children:"Manual configuration is still available if kRouter is deployed on a remote server."})]})]}),(0,l.jsx)("div",{className:"flex items-center gap-2 pl-9",children:(0,l.jsxs)(r.$n,{variant:"secondary",size:"sm",onClick:()=>F(!0),className:"!bg-yellow-500/20 !border-yellow-500/40 !text-yellow-700 dark:!text-yellow-300 hover:!bg-yellow-500/30",children:[(0,l.jsx)("span",{className:"material-symbols-outlined text-[18px] mr-1",children:"content_copy"}),"Manual Config"]})})]})}),!w&&N?.installed&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)("div",{className:"flex flex-col gap-2",children:[e.notes&&e.notes.length>0&&(0,l.jsx)("div",{className:"flex flex-col gap-2 mb-2",children:e.notes.map((e,t)=>(0,l.jsxs)("div",{className:`flex items-start gap-2 p-2 rounded text-xs ${"warning"===e.type?"bg-yellow-500/10 text-yellow-600 dark:text-yellow-400":"error"===e.type?"bg-red-500/10 text-red-600 dark:text-red-400":"bg-blue-500/10 text-blue-600 dark:text-blue-400"}`,children:[(0,l.jsx)("span",{className:"material-symbols-outlined text-[14px] mt-0.5",children:"warning"===e.type?"warning":"error"===e.type?"error":"info"}),(0,l.jsx)("span",{children:e.text})]},t))}),(0,l.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr] sm:items-center sm:gap-2",children:[(0,l.jsx)("span",{className:"text-xs font-semibold text-text-main sm:text-right sm:text-sm",children:"Select Endpoint"}),(0,l.jsx)("span",{className:"material-symbols-outlined hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,l.jsx)(x,{value:q||W(),onChange:H,requiresExternalUrl:e.requiresExternalUrl,tunnelEnabled:h,tunnelPublicUrl:f,tailscaleEnabled:y,tailscaleUrl:b})]}),N?.settings?.["providers.openai"]?.base_url&&(0,l.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr_auto] sm:items-center sm:gap-2",children:[(0,l.jsx)("span",{className:"text-xs font-semibold text-text-main sm:text-right sm:text-sm",children:"Current"}),(0,l.jsx)("span",{className:"material-symbols-outlined hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,l.jsx)("span",{className:"min-w-0 truncate rounded bg-surface/40 px-2 py-2 text-xs text-text-muted sm:py-1.5",children:N.settings["providers.openai"].base_url})]}),(0,l.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr_auto] sm:items-center sm:gap-2",children:[(0,l.jsx)("span",{className:"text-xs font-semibold text-text-main sm:text-right sm:text-sm",children:"API Key"}),(0,l.jsx)("span",{className:"material-symbols-outlined hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,l.jsx)(u,{value:M,onChange:I,apiKeys:d,cloudEnabled:m})]}),(0,l.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr_auto] sm:items-center sm:gap-2",children:[(0,l.jsx)("span",{className:"text-xs font-semibold text-text-main sm:text-right sm:text-sm",children:"Default Model"}),(0,l.jsx)("span",{className:"material-symbols-outlined hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,l.jsxs)("div",{className:"relative w-full min-w-0",children:[(0,l.jsx)("input",{type:"text",value:P,onChange:e=>R(e.target.value),placeholder:"provider/model-id",className:"w-full min-w-0 pl-2 pr-7 py-2 bg-surface rounded border border-border text-xs focus:outline-none focus:ring-1 focus:ring-primary/50 sm:py-1.5"}),P&&(0,l.jsx)("button",{onClick:()=>R(""),className:"absolute right-1 top-1/2 -translate-y-1/2 p-0.5 text-text-muted hover:text-red-500 rounded transition-colors",title:"Clear",children:(0,l.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"close"})})]}),(0,l.jsx)("button",{onClick:()=>K(!0),disabled:!o,className:`w-full sm:w-auto rounded border px-2 py-2 text-xs transition-colors sm:py-1.5 whitespace-nowrap sm:shrink-0 ${o?"bg-surface border-border text-text-main hover:border-primary cursor-pointer":"opacity-50 cursor-not-allowed border-border"}`,children:"Select"})]})]}),A&&(0,l.jsxs)("div",{className:`flex items-center gap-2 px-2 py-1.5 rounded text-xs ${"success"===A.type?"bg-green-500/10 text-green-600":"bg-red-500/10 text-red-600"}`,children:[(0,l.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"success"===A.type?"check_circle":"error"}),(0,l.jsx)("span",{children:A.text})]}),(0,l.jsxs)("div",{className:"grid grid-cols-1 gap-2 sm:flex sm:items-center",children:[(0,l.jsxs)(r.$n,{variant:"primary",size:"sm",onClick:Y,disabled:!P,loading:C,children:[(0,l.jsx)("span",{className:"material-symbols-outlined text-[14px] mr-1",children:"save"}),"Apply"]}),(0,l.jsxs)(r.$n,{variant:"outline",size:"sm",onClick:Z,disabled:!N?.hasKRouter,loading:S,children:[(0,l.jsx)("span",{className:"material-symbols-outlined text-[14px] mr-1",children:"restore"}),"Reset"]}),(0,l.jsxs)(r.$n,{variant:"ghost",size:"sm",onClick:()=>F(!0),children:[(0,l.jsx)("span",{className:"material-symbols-outlined text-[14px] mr-1",children:"content_copy"}),"Manual Config"]})]})]})]}),(0,l.jsx)(r.rq,{isOpen:U,onClose:()=>K(!1),onSelect:e=>{R(e.value),K(!1)},selectedModel:P,activeProviders:c,modelAliases:D,title:"Select Model for DeepSeek TUI"}),(0,l.jsx)(r.uR,{isOpen:z,onClose:()=>F(!1),title:"DeepSeek TUI - Manual Configuration",configs:(j=M&&M.trim()?M:m?"<API_KEY_FROM_DASHBOARD>":"sk_krouter",[{filename:"~/.deepseek/config.toml",content:`[providers.openai]
60
+ base_url = "${W()}"
61
+ api_key = "${j}"
62
+ model = "${P||"provider/model-id"}"
63
+ `}])})]})}function U({tool:e,isExpanded:t,onToggle:s,baseUrl:n,hasActiveProviders:o,apiKeys:d,activeProviders:c,cloudEnabled:m,initialStatus:p,tunnelEnabled:h,tunnelPublicUrl:f,tailscaleEnabled:y,tailscaleUrl:b}){let j,N,[v,w]=(0,a.useState)(p||null),[k,C]=(0,a.useState)(!1),[_,S]=(0,a.useState)(!1),[E,A]=(0,a.useState)(!1),[O,M]=(0,a.useState)(null),[I,P]=(0,a.useState)(""),[R,T]=(0,a.useState)(""),[$,K]=(0,a.useState)(!1),[D,L]=(0,a.useState)({}),[z,F]=(0,a.useState)(!1),[q,H]=(0,a.useState)(""),B=(0,a.useRef)(!1),G=()=>v?.config?.providers?.krouter??null,J=(()=>{if(!v?.installed)return null;if(!v?.hasKRouter)return"not_configured";let e=G();return e?g(e.base_url,{tunnelPublicUrl:f,tailscaleUrl:b})?"configured":"other":"not_configured"})();(0,a.useEffect)(()=>{d?.length>0&&!I&&P(d[0].key)},[d,I]),(0,a.useEffect)(()=>{p&&w(p)},[p]),(0,a.useEffect)(()=>{t&&!v&&(W(),V()),t&&V()},[t]);let V=async()=>{try{let e=await fetch("/api/models/alias"),t=await e.json();e.ok&&L(t.aliases||{})}catch(e){console.log("Error fetching model aliases:",e)}};(0,a.useEffect)(()=>{if(v?.installed&&!B.current){B.current=!0;let e=v.config?.providers?.krouter;if(e){e.default_model&&T(e.default_model);let t=v.envApiKey;t&&d?.some(e=>e.key===t)&&P(t)}}},[v,d]);let W=async()=>{C(!0);try{let e=await fetch("/api/cli-tools/jcode-settings"),t=await e.json();w(t)}catch(e){w({installed:!1,error:e.message})}finally{C(!1)}},Y=()=>window.location.origin.replace("://localhost","://127.0.0.1"),Z=()=>{let e=q||Y();return e.endsWith("/v1")?e:`${e}/v1`},Q=async()=>{S(!0),M(null);try{let e=I?.trim()||(d?.length>0?d[0].key:null)||(m?null:"sk_krouter"),t=await fetch("/api/cli-tools/jcode-settings",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({baseUrl:Z(),apiKey:e,models:R?[R]:[]})}),s=await t.json();t.ok?(M({type:"success",text:"Settings applied successfully!"}),W()):M({type:"error",text:s.error||"Failed to apply settings"})}catch(e){M({type:"error",text:e.message})}finally{S(!1)}},X=async()=>{A(!0),M(null);try{let e=await fetch("/api/cli-tools/jcode-settings",{method:"DELETE"}),t=await e.json();e.ok?(M({type:"success",text:"Settings reset successfully!"}),T(""),P(""),W()):M({type:"error",text:t.error||"Failed to reset settings"})}catch(e){M({type:"error",text:e.message})}finally{A(!1)}};return(0,l.jsxs)(r.Zp,{padding:"xs",className:"overflow-hidden",children:[(0,l.jsxs)("div",{className:"flex items-start justify-between gap-3 hover:cursor-pointer sm:items-center",onClick:s,children:[(0,l.jsxs)("div",{className:"flex min-w-0 items-center gap-3",children:[(0,l.jsx)("div",{className:"size-8 flex items-center justify-center shrink-0",children:(0,l.jsx)(i.A,{src:e.image||"/providers/jcode.png",alt:e.name,width:32,height:32,className:"size-8 object-contain rounded-lg",sizes:"32px",onError:e=>{e.target.style.display="none"}})}),(0,l.jsxs)("div",{className:"min-w-0",children:[(0,l.jsxs)("div",{className:"flex min-w-0 flex-wrap items-center gap-2",children:[(0,l.jsx)("h3",{className:"font-medium text-sm",children:e.name}),"configured"===J&&(0,l.jsx)("span",{className:"px-1.5 py-0.5 text-[10px] font-medium bg-green-500/10 text-green-600 dark:text-green-400 rounded-full",children:"Connected"}),"not_configured"===J&&(0,l.jsx)("span",{className:"px-1.5 py-0.5 text-[10px] font-medium bg-yellow-500/10 text-yellow-600 dark:text-yellow-400 rounded-full",children:"Not configured"}),"other"===J&&(0,l.jsx)("span",{className:"px-1.5 py-0.5 text-[10px] font-medium bg-blue-500/10 text-blue-600 dark:text-blue-400 rounded-full",children:"Other"})]}),(0,l.jsx)("p",{className:"text-xs text-text-muted truncate",children:e.description})]})]}),(0,l.jsx)("span",{className:`material-symbols-outlined text-text-muted text-[20px] transition-transform ${t?"rotate-180":""}`,children:"expand_more"})]}),t&&(0,l.jsxs)("div",{className:"mt-4 pt-4 border-t border-border flex flex-col gap-4",children:[k&&(0,l.jsxs)("div",{className:"flex items-center gap-2 text-text-muted",children:[(0,l.jsx)("span",{className:"material-symbols-outlined animate-spin",children:"progress_activity"}),(0,l.jsx)("span",{children:"Checking jcode CLI..."})]}),!k&&v&&!v.installed&&(0,l.jsx)("div",{className:"flex flex-col gap-4",children:(0,l.jsxs)("div",{className:"flex flex-col gap-3 p-4 bg-yellow-500/10 border border-yellow-500/30 rounded-lg",children:[(0,l.jsxs)("div",{className:"flex items-start gap-3",children:[(0,l.jsx)("span",{className:"material-symbols-outlined text-yellow-500",children:"warning"}),(0,l.jsxs)("div",{className:"flex-1",children:[(0,l.jsx)("p",{className:"font-medium text-yellow-600 dark:text-yellow-400",children:"jcode CLI not detected locally"}),(0,l.jsx)("p",{className:"text-sm text-text-muted mt-1",children:"Install jcode to enable automatic configuration:"}),(0,l.jsx)("code",{className:"block mt-2 p-2 bg-black/20 rounded text-xs font-mono",children:"curl -fsSL https://raw.githubusercontent.com/1jehuang/jcode/master/scripts/install.sh | bash"}),(0,l.jsx)("p",{className:"text-sm text-text-muted mt-2",children:"Manual configuration is still available if kRouter is deployed on a remote server."})]})]}),(0,l.jsx)("div",{className:"flex items-center gap-2 pl-9",children:(0,l.jsxs)(r.$n,{variant:"secondary",size:"sm",onClick:()=>F(!0),className:"!bg-yellow-500/20 !border-yellow-500/40 !text-yellow-700 dark:!text-yellow-300 hover:!bg-yellow-500/30",children:[(0,l.jsx)("span",{className:"material-symbols-outlined text-[18px] mr-1",children:"content_copy"}),"Manual Config"]})})]})}),!k&&v?.installed&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)("div",{className:"flex flex-col gap-2",children:[e.notes&&e.notes.length>0&&(0,l.jsx)("div",{className:"flex flex-col gap-2 mb-2",children:e.notes.map((e,t)=>(0,l.jsxs)("div",{className:`flex items-start gap-2 p-2 rounded text-xs ${"info"===e.type?"bg-blue-500/10 text-blue-600 dark:text-blue-400":"warning"===e.type?"bg-yellow-500/10 text-yellow-600 dark:text-yellow-400":"bg-gray-500/10 text-text-muted"}`,children:[(0,l.jsx)("span",{className:"material-symbols-outlined text-[14px] mt-0.5",children:"info"===e.type?"info":"warning"===e.type?"warning":"help"}),(0,l.jsx)("span",{children:e.text})]},t))}),(0,l.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr] sm:items-center sm:gap-2",children:[(0,l.jsx)("span",{className:"text-xs font-semibold text-text-main sm:text-right sm:text-sm",children:"Select Endpoint"}),(0,l.jsx)("span",{className:"material-symbols-outlined hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,l.jsx)(x,{value:q||((j=q||Y()).endsWith("/v1")?j:`${j}/v1`),onChange:H,requiresExternalUrl:e.requiresExternalUrl,tunnelEnabled:h,tunnelPublicUrl:f,tailscaleEnabled:y,tailscaleUrl:b})]}),G()?.base_url&&(0,l.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr_auto] sm:items-center sm:gap-2",children:[(0,l.jsx)("span",{className:"text-xs font-semibold text-text-main sm:text-right sm:text-sm",children:"Current"}),(0,l.jsx)("span",{className:"material-symbols-outlined hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,l.jsx)("span",{className:"min-w-0 truncate rounded bg-surface/40 px-2 py-2 text-xs text-text-muted sm:py-1.5",children:G()?.base_url})]}),(0,l.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr_auto] sm:items-center sm:gap-2",children:[(0,l.jsx)("span",{className:"text-xs font-semibold text-text-main sm:text-right sm:text-sm",children:"API Key"}),(0,l.jsx)("span",{className:"material-symbols-outlined hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,l.jsx)(u,{value:I,onChange:P,apiKeys:d,cloudEnabled:m})]}),(0,l.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr_auto] sm:items-center sm:gap-2",children:[(0,l.jsx)("span",{className:"text-xs font-semibold text-text-main sm:text-right sm:text-sm",children:"Default Model"}),(0,l.jsx)("span",{className:"material-symbols-outlined hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,l.jsxs)("div",{className:"relative w-full min-w-0",children:[(0,l.jsx)("input",{type:"text",value:R,onChange:e=>T(e.target.value),placeholder:"cc/claude-opus-4-7",className:"w-full min-w-0 pl-2 pr-7 py-2 bg-surface rounded border border-border text-xs focus:outline-none focus:ring-1 focus:ring-primary/50 sm:py-1.5"}),R&&(0,l.jsx)("button",{onClick:()=>T(""),className:"absolute right-1 top-1/2 -translate-y-1/2 p-0.5 text-text-muted hover:text-red-500 rounded transition-colors",title:"Clear",children:(0,l.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"close"})})]}),(0,l.jsx)("button",{onClick:()=>K(!0),disabled:!o,className:`w-full sm:w-auto rounded border px-2 py-2 text-xs transition-colors sm:py-1.5 whitespace-nowrap sm:shrink-0 ${o?"bg-surface border-border text-text-main hover:border-primary cursor-pointer":"opacity-50 cursor-not-allowed border-border"}`,children:"Select"})]}),(0,l.jsxs)("div",{className:"flex flex-col gap-1 p-3 bg-blue-500/5 border border-blue-500/20 rounded-lg",children:[(0,l.jsx)("p",{className:"text-xs font-medium text-blue-600 dark:text-blue-400",children:"Usage:"}),(0,l.jsx)("code",{className:"text-xs font-mono text-text-muted",children:"jcode --provider-profile krouter"}),(0,l.jsxs)("code",{className:"text-xs font-mono text-text-muted",children:["jcode --provider-profile krouter --model ",R||"cc/claude-opus-4-7"]})]})]}),O&&(0,l.jsxs)("div",{className:`flex items-center gap-2 px-2 py-1.5 rounded text-xs ${"success"===O.type?"bg-green-500/10 text-green-600":"bg-red-500/10 text-red-600"}`,children:[(0,l.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"success"===O.type?"check_circle":"error"}),(0,l.jsx)("span",{children:O.text})]}),(0,l.jsxs)("div",{className:"grid grid-cols-1 gap-2 sm:flex sm:items-center",children:[(0,l.jsxs)(r.$n,{variant:"primary",size:"sm",onClick:Q,disabled:!R,loading:_,children:[(0,l.jsx)("span",{className:"material-symbols-outlined text-[14px] mr-1",children:"save"}),"Apply"]}),(0,l.jsxs)(r.$n,{variant:"outline",size:"sm",onClick:X,disabled:!v?.hasKRouter,loading:E,children:[(0,l.jsx)("span",{className:"material-symbols-outlined text-[14px] mr-1",children:"restore"}),"Reset"]}),(0,l.jsxs)(r.$n,{variant:"ghost",size:"sm",onClick:()=>F(!0),children:[(0,l.jsx)("span",{className:"material-symbols-outlined text-[14px] mr-1",children:"content_copy"}),"Manual Config"]})]})]})]}),(0,l.jsx)(r.rq,{isOpen:$,onClose:()=>K(!1),onSelect:e=>{T(e.value),K(!1)},selectedModel:R,activeProviders:c,modelAliases:D,title:"Select Model for jcode"}),(0,l.jsx)(r.uR,{isOpen:z,onClose:()=>F(!1),title:"jcode - Manual Configuration",configs:(N=I&&I.trim()?I:m?"<API_KEY_FROM_DASHBOARD>":"sk_krouter",[{filename:"~/.jcode/config.toml",content:`[providers.krouter]
64
+ type = "openai-compatible"
65
+ base_url = "${Z()}"
66
+ auth = "bearer"
67
+ api_key_env = "JCODE_KROUTER_API_KEY"
68
+ env_file = "provider-krouter.env"
69
+ default_model = "${R||"cc/claude-opus-4-7"}"
70
+ requires_api_key = true
71
+
72
+ [[providers.krouter.models]]
73
+ id = "${R||"cc/claude-opus-4-7"}"`},{filename:"~/.config/jcode/provider-krouter.env",content:`JCODE_KROUTER_API_KEY="${N}"`}])})]})}let K="http://localhost:20128";function D({apiKeys:e,cloudEnabled:t,onStatusChange:s}){let[i,n]=(0,a.useState)(null),[o,d]=(0,a.useState)(!1),[c,m]=(0,a.useState)(!1),[x,p]=(0,a.useState)(""),[u,h]=(0,a.useState)(()=>e?.[0]?.key||""),[g,f]=(0,a.useState)(null),[y,b]=(0,a.useState)(null),[j,N]=(0,a.useState)(null),[v,w]=(0,a.useState)(K),[k,C]=(0,a.useState)(null),_=i?.isWin===!0,S=_||i?.hasCachedPassword||i?.needsSudoPassword===!1,E=i?.isAdmin!==!1;!E&&(_||i?.hasCachedPassword||i?.needsSudoPassword);let A=(0,a.useCallback)(async()=>{try{let e=await fetch("/api/cli-tools/antigravity-mitm");if(e.ok){let t=await e.json();n(t),t.mitmRouterBaseUrl&&w(t.mitmRouterBaseUrl),s?.(t)}}catch{n({running:!1,certExists:!1,dnsStatus:{}})}},[s]);(0,a.useEffect)(()=>{queueMicrotask(()=>{A()})},[A]);let O=e=>{N(null),i&&(S?M(e,""):(f(e),m(!0),b(null)))},M=async(s,l,a=!1)=>{d(!0),N(null);try{let r;if("trust-cert"===s)r=await fetch("/api/cli-tools/antigravity-mitm",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"trust-cert",sudoPassword:l})});else if("start"===s){let s=u?.trim()||(e?.length>0?e[0].key:null)||(t?null:"sk_krouter");r=await fetch("/api/cli-tools/antigravity-mitm",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({apiKey:s,sudoPassword:l,mitmRouterBaseUrl:v.trim()||K,forceKillPort443:a})})}else r=await fetch("/api/cli-tools/antigravity-mitm",{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({sudoPassword:l})});if(!r.ok){let e=await r.json().catch(()=>({}));if("PORT_443_BUSY"===e.code&&e.portOwner){m(!1),C({owner:e.portOwner,password:l});return}N(e.error||`Failed to ${s} MITM server`);return}m(!1),p(""),C(null),await A()}catch(e){N(e.message||"Network error")}finally{d(!1),f(null)}},I=()=>{x.trim()?M(g,x):b("Sudo password is required")},P=i?.running,R=i?.containerized===!0,T=i?.containerKind||"a container";return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(r.Zp,{padding:"sm",className:"border-primary/20 bg-primary/5",children:(0,l.jsxs)("div",{className:"flex flex-col gap-3",children:[(0,l.jsxs)("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between",children:[(0,l.jsxs)("div",{className:"flex min-w-0 flex-wrap items-center gap-2",children:[(0,l.jsx)("span",{className:"material-symbols-outlined text-primary text-[20px]",children:"security"}),(0,l.jsx)("span",{className:"font-semibold text-sm text-text-main",children:"MITM Server"}),P?(0,l.jsx)(r.Ex,{variant:"success",size:"sm",children:"Running"}):(0,l.jsx)(r.Ex,{variant:"default",size:"sm",children:"Stopped"})]}),(0,l.jsx)("div",{className:"flex flex-wrap items-center gap-1 text-xs text-text-muted","data-i18n-skip":"true",children:[{label:"Cert",ok:i?.certExists},{label:"Trusted",ok:i?.certTrusted},{label:"Server",ok:P}].map(({label:e,ok:t})=>(0,l.jsxs)("span",{className:`flex items-center gap-0.5 px-1.5 py-0.5 rounded ${t?"text-green-600":"text-text-muted"}`,children:[(0,l.jsx)("span",{className:"material-symbols-outlined text-[12px]",children:t?"check_circle":"cancel"}),e]},e))})]}),(0,l.jsxs)("div",{className:"px-2 py-2 rounded-lg bg-surface/50 border border-border/50 flex flex-col gap-2",children:[(0,l.jsxs)("p",{className:"text-[11px] text-text-muted leading-relaxed",children:[(0,l.jsx)("span",{className:"font-medium text-text-main",children:"Purpose:"})," Use Antigravity IDE & GitHub Copilot → with ANY provider/model from kRouter"]}),(0,l.jsxs)("p",{className:"text-[11px] text-text-muted leading-relaxed",children:[(0,l.jsx)("span",{className:"font-medium text-text-main",children:"How it works:"})," Antigravity/Copilot IDE request → DNS redirect to localhost:443 → MITM proxy intercepts → kRouter → response to Antigravity/Copilot"]})]}),(0,l.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,l.jsxs)("div",{className:"grid gap-1 sm:grid-cols-[8rem_auto_1fr] sm:items-center sm:gap-2",children:[(0,l.jsx)("span",{className:"text-xs font-semibold text-text-main sm:text-right sm:text-sm",children:"kRouter Base URL"}),(0,l.jsx)("span",{className:"material-symbols-outlined hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,l.jsx)("input",{type:"text",value:v,onChange:e=>w(e.target.value),placeholder:K,disabled:P,className:"flex-1 min-w-0 px-2 py-1.5 bg-surface rounded border border-border text-xs text-text-main focus:outline-none focus:ring-1 focus:ring-primary/50 disabled:opacity-50"})]}),!P&&(0,l.jsxs)("div",{className:"grid gap-1 sm:grid-cols-[8rem_auto_1fr] sm:items-center sm:gap-2",children:[(0,l.jsx)("span",{className:"text-xs font-semibold text-text-main sm:text-right sm:text-sm",children:"API Key"}),(0,l.jsx)("span",{className:"material-symbols-outlined hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,l.jsx)("input",{type:"text",list:"mitm-api-keys",value:u,onChange:e=>h(e.target.value),placeholder:t?"Enter or pick API key":"sk_krouter (default)",className:"flex-1 min-w-0 px-2 py-1.5 bg-surface rounded border border-border text-xs text-text-main focus:outline-none focus:ring-1 focus:ring-primary/50"}),e?.length>0&&(0,l.jsx)("datalist",{id:"mitm-api-keys",children:e.map(e=>(0,l.jsx)("option",{value:e.key,children:e.name||e.key},e.id))})]})]}),R?(0,l.jsxs)("div",{className:"px-3 py-2.5 rounded-lg bg-surface/50 border border-border/50 flex flex-col gap-1",children:[(0,l.jsxs)("p",{className:"text-[11px] font-medium text-text-main",children:["Not available in ",T]}),(0,l.jsx)("p",{className:"text-[11px] text-text-muted leading-relaxed",children:"Interception redirects provider hostnames in the operating system's hosts file and terminates TLS on port 443. In a container both belong to the container, while Antigravity, Copilot, Kiro and Cursor run on your host and never read them — the server would start and intercept nothing. Run kRouter directly on the host to use MITM, or point those tools at this instance's base URL instead, which needs no interception."})]}):(0,l.jsxs)("div",{className:"flex flex-col gap-2 sm:flex-row sm:flex-wrap sm:items-center","data-i18n-skip":"true",children:[i?.certExists&&!i?.certTrusted&&(0,l.jsxs)("button",{onClick:()=>O("trust-cert"),disabled:o,className:"flex w-full items-center justify-center gap-1.5 rounded-lg border border-yellow-500/30 bg-yellow-500/10 px-4 py-2 text-xs font-medium text-yellow-600 transition-colors hover:bg-yellow-500/20 disabled:opacity-50 sm:w-auto sm:py-1.5",children:[(0,l.jsx)("span",{className:"material-symbols-outlined text-[16px]",children:"verified_user"}),"Trust Cert"]}),P?(0,l.jsxs)("button",{onClick:()=>O("stop"),disabled:o,className:"flex w-full items-center justify-center gap-1.5 rounded-lg border border-red-500/30 bg-red-500/10 px-4 py-2 text-xs font-medium text-red-500 transition-colors hover:bg-red-500/20 disabled:opacity-50 sm:w-auto sm:py-1.5",children:[(0,l.jsx)("span",{className:"material-symbols-outlined text-[16px]",children:"stop_circle"}),"Stop Server"]}):(0,l.jsxs)("button",{onClick:()=>O("start"),disabled:o||!i||_&&!E,title:_&&!E?"Administrator required":void 0,className:"flex w-full items-center justify-center gap-1.5 rounded-lg border border-primary/30 bg-primary/10 px-4 py-2 text-xs font-medium text-primary transition-colors hover:bg-primary/20 disabled:opacity-50 sm:w-auto sm:py-1.5",children:[(0,l.jsx)("span",{className:"material-symbols-outlined text-[16px]",children:"play_circle"}),"Start Server"]}),P&&(0,l.jsx)("p",{className:"text-xs text-text-muted",children:"Enable DNS per tool below to activate interception"})]}),j&&(0,l.jsxs)("div",{className:"flex items-start gap-2 px-2 py-1.5 rounded text-xs bg-red-500/10 text-red-600 dark:text-red-400 border border-red-500/20",children:[(0,l.jsx)("span",{className:"material-symbols-outlined text-[14px] mt-0.5 shrink-0",children:"error"}),(0,l.jsx)("span",{children:j})]}),_&&!E&&(0,l.jsxs)("div",{className:"flex items-center gap-2 px-2 py-1.5 rounded text-xs bg-red-500/10 text-red-600 border border-red-500/20",children:[(0,l.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"shield_lock"}),(0,l.jsx)("span",{children:"Administrator required — restart kRouter as Administrator to use MITM"})]})]})}),c&&(0,l.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50 backdrop-blur-sm",children:(0,l.jsxs)("div",{className:"mx-4 flex w-full max-w-sm flex-col gap-4 rounded-xl border border-border bg-surface p-5 shadow-xl sm:p-6",children:[(0,l.jsx)("h3",{className:"font-semibold text-text-main",children:"Sudo Password Required"}),(0,l.jsxs)("div",{className:"flex items-start gap-3 p-3 bg-yellow-500/10 border border-yellow-500/30 rounded-lg",children:[(0,l.jsx)("span",{className:"material-symbols-outlined text-yellow-500 text-[20px]",children:"warning"}),(0,l.jsx)("p",{className:"text-xs text-text-muted",children:"Required for SSL certificate and server startup"})]}),(0,l.jsx)(r.pd,{type:"password",placeholder:"Enter sudo password",value:x,onChange:e=>p(e.target.value),onKeyDown:e=>{"Enter"!==e.key||o||I()}}),y&&(0,l.jsxs)("div",{className:"flex items-center gap-2 px-2 py-1.5 rounded text-xs bg-red-500/10 text-red-600",children:[(0,l.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"error"}),(0,l.jsx)("span",{children:y})]}),(0,l.jsxs)("div",{className:"flex items-center justify-end gap-2",children:[(0,l.jsx)(r.$n,{variant:"ghost",size:"sm",onClick:()=>{m(!1),p(""),b(null)},disabled:o,children:"Cancel"}),(0,l.jsx)(r.$n,{variant:"primary",size:"sm",onClick:I,loading:o,children:"Confirm"})]})]})}),k&&(0,l.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50 backdrop-blur-sm",children:(0,l.jsxs)("div",{className:"mx-4 flex w-full max-w-md flex-col gap-4 rounded-xl border border-border bg-surface p-5 shadow-xl sm:p-6",children:[(0,l.jsx)("h3",{className:"font-semibold text-text-main",children:"Port 443 Already In Use"}),(0,l.jsxs)("div",{className:"flex items-start gap-3 p-3 bg-yellow-500/10 border border-yellow-500/30 rounded-lg",children:[(0,l.jsx)("span",{className:"material-symbols-outlined text-yellow-500 text-[20px]",children:"warning"}),(0,l.jsxs)("div",{className:"flex flex-col gap-1 text-xs text-text-muted",children:[(0,l.jsx)("p",{children:"Port 443 is currently used by another process:"}),(0,l.jsxs)("p",{className:"font-mono text-text-main","data-i18n-skip":"true",children:[k.owner.name," (PID ",k.owner.pid,")"]}),(0,l.jsx)("p",{children:"Kill this process to start MITM Server?"})]})]}),(0,l.jsxs)("div",{className:"flex items-center justify-end gap-2",children:[(0,l.jsx)(r.$n,{variant:"ghost",size:"sm",onClick:()=>{C(null),d(!1)},disabled:o,children:"Cancel"}),(0,l.jsx)(r.$n,{variant:"primary",size:"sm",onClick:()=>{M("start",k?.password||"",!0)},loading:o,children:"Kill & Start"})]})]})})]})}var L=s(40295);function z({tool:e,isExpanded:t,onToggle:s,serverRunning:n,dnsActive:o,hasCachedPassword:d,needsSudoPassword:c,isWin:m,apiKeys:x,activeProviders:p,hasActiveProviders:u,modelAliases:h={},cloudEnabled:g,onDnsChange:f}){let[y,b]=(0,a.useState)(!1),[j,N]=(0,a.useState)(null),[v,w]=(0,a.useState)(!1),[k,C]=(0,a.useState)(""),[_,S]=(0,a.useState)(null),[E,A]=(0,a.useState)(null),[O,M]=(0,a.useState)(null),[I,P]=(0,a.useState)({}),[R,T]=(0,a.useState)(!1),[$,U]=(0,a.useState)(null),K=L.TOOL_HOSTS[e.id]??[],D=m||d||!1===c;(0,a.useEffect)(()=>{t&&F()},[t]);let F=async()=>{try{let t=await fetch(`/api/cli-tools/antigravity-mitm/alias?tool=${e.id}`);if(t.ok){let e=await t.json();Object.keys(e.aliases||{}).length>0&&P(e.aliases)}}catch(t){console.warn(`[MitmToolCard] could not load saved mappings for ${e.id}:`,t?.message)}},q=(0,a.useCallback)(async t=>{try{let s=await fetch("/api/cli-tools/antigravity-mitm/alias",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({tool:e.id,mappings:t})});if(!s.ok){let e=await s.json().catch(()=>({}));M(e.error||`Could not save model mapping (${s.status})`);return}M(null)}catch(e){M(e?.message||"Could not save model mapping")}},[e.id]),H=(e,t)=>{P(s=>({...s,[e]:t}))},B=()=>{if(!n)return;let e=o?"disable":"enable";D?G(e,""):(S(e),w(!0),A(null))},G=async(t,s)=>{b(!0),N(null),M(null),A(null);try{let l=await fetch("/api/cli-tools/antigravity-mitm",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({tool:e.id,action:t,sudoPassword:s})}),a=await l.json();if(!l.ok)throw Error(a.error||"Failed to toggle DNS");"enable"===t&&N(`Restart ${e.name} to apply changes`),w(!1),C(""),f?.(a)}catch(t){let e=t?.message||"Failed to toggle DNS";v?A(e):M(e),b(!1);return}finally{b(!1)}S(null)},J=()=>{k.trim()?G(_,k):A("Sudo password is required")};return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)(r.Zp,{padding:"xs",className:"overflow-hidden",children:[(0,l.jsxs)("div",{className:"flex items-start justify-between gap-3 hover:cursor-pointer sm:items-center",onClick:s,children:[(0,l.jsxs)("div",{className:"flex min-w-0 items-center gap-3",children:[(0,l.jsx)("div",{className:"size-8 flex items-center justify-center shrink-0",children:(0,l.jsx)(i.A,{src:e.image,alt:e.name,width:32,height:32,className:"size-8 object-contain rounded-lg",sizes:"32px",onError:e=>{e.target.style.display="none"}})}),(0,l.jsxs)("div",{className:"min-w-0",children:[(0,l.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,l.jsx)("h3",{className:"font-medium text-sm",children:e.name}),n?o?(0,l.jsx)(r.Ex,{variant:"success",size:"sm",children:"Active"}):(0,l.jsx)(r.Ex,{variant:"warning",size:"sm",children:"DNS off"}):(0,l.jsx)(r.Ex,{variant:"default",size:"sm",children:"Server off"})]}),(0,l.jsxs)("p",{className:"text-xs text-text-muted sm:truncate",children:["Intercept ",e.name," requests via MITM proxy"]})]})]}),(0,l.jsx)("span",{className:`material-symbols-outlined text-text-muted text-[20px] transition-transform ${t?"rotate-180":""}`,children:"expand_more"})]}),t&&(0,l.jsxs)("div",{className:"mt-4 pt-4 border-t border-border flex flex-col gap-4",children:[K.length>0&&(0,l.jsxs)("div",{className:"mt-2 rounded-md border border-border bg-surface/50 px-2 py-1.5",children:[(0,l.jsx)("p",{className:"text-[10px] font-medium tracking-wide text-text-main/80 mb-1",children:"Edit hosts file manually to add the following entries:"}),(0,l.jsx)("ul",{className:"list-none space-y-0.5 font-mono text-[10px] text-text-muted break-all",children:K.map(e=>(0,l.jsxs)("li",{children:["127.0.0.1 ",e]},e))})]}),(0,l.jsxs)("div",{className:"flex flex-col gap-0.5 text-[11px] text-text-muted px-1",children:[(0,l.jsxs)("p",{children:["Toggle DNS to redirect ",e.name," traffic through kRouter via MITM."]}),!o&&(0,l.jsx)("p",{className:"text-amber-600 text-[10px] mt-1",children:"⚠️ Enable DNS to edit model mappings"})]}),e.defaultModels?.length>0&&(0,l.jsx)("div",{className:"flex flex-col gap-2",children:e.defaultModels.map(e=>(0,l.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[9rem_auto_1fr_auto] sm:items-center sm:gap-2",children:[(0,l.jsx)("span",{className:"text-xs font-semibold text-text-main sm:text-right",children:e.name}),(0,l.jsx)("span",{className:"material-symbols-outlined hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,l.jsxs)("div",{className:"relative w-full min-w-0",children:[(0,l.jsx)("input",{type:"text",value:I[e.alias]||"",onChange:t=>H(e.alias,t.target.value),onBlur:t=>{var s,l;return s=e.alias,l=t.target.value,void q({...I,[s]:l})},placeholder:"provider/model-id",disabled:!o,className:`w-full min-w-0 pl-2 pr-7 py-2 bg-surface rounded border border-border text-xs focus:outline-none focus:ring-1 focus:ring-primary/50 sm:py-1.5 ${!o?"opacity-50 cursor-not-allowed":""}`}),I[e.alias]&&(0,l.jsx)("button",{onClick:()=>{H(e.alias,""),q({...I,[e.alias]:""})},className:"absolute right-1 top-1/2 -translate-y-1/2 p-0.5 text-text-muted hover:text-red-500 rounded transition-colors",title:"Clear",children:(0,l.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"close"})})]}),(0,l.jsx)("button",{onClick:()=>{U(e.alias),T(!0)},disabled:!u||!o,className:`rounded border px-2 py-2 text-xs transition-colors sm:py-1.5 ${u&&o?"bg-surface border-border hover:border-primary cursor-pointer":"opacity-50 cursor-not-allowed border-border"}`,children:"Select"})]},e.alias))}),e.defaultModels?.length===0&&(0,l.jsx)("p",{className:"text-xs text-text-muted px-1",children:"Model mappings will be available soon."}),(0,l.jsxs)("div",{className:"flex flex-col gap-2 sm:items-start",children:[o?(0,l.jsxs)("button",{onClick:B,disabled:!n||y,className:"flex w-full items-center justify-center gap-1.5 rounded-lg border border-red-500/30 bg-red-500/10 px-4 py-2 text-xs font-medium text-red-500 transition-colors hover:bg-red-500/20 disabled:cursor-not-allowed disabled:opacity-50 sm:w-auto sm:py-1.5",children:[(0,l.jsx)("span",{className:"material-symbols-outlined text-[16px]",children:"stop_circle"}),"Stop DNS"]}):(0,l.jsxs)("button",{onClick:B,disabled:!n||y,className:"flex w-full items-center justify-center gap-1.5 rounded-lg border border-primary/30 bg-primary/10 px-4 py-2 text-xs font-medium text-primary transition-colors hover:bg-primary/20 disabled:cursor-not-allowed disabled:opacity-50 sm:w-auto sm:py-1.5",children:[(0,l.jsx)("span",{className:"material-symbols-outlined text-[16px]",children:"play_circle"}),"Start DNS"]}),j&&(0,l.jsxs)("div",{className:"flex items-center gap-2 px-2 py-1.5 rounded text-xs text-amber-500",children:[(0,l.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"warning"}),(0,l.jsx)("span",{children:j})]}),O&&(0,l.jsxs)("div",{className:"flex items-center gap-2 px-2 py-1.5 rounded text-xs text-red-500",children:[(0,l.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"error"}),(0,l.jsx)("span",{children:O})]})]})]})]}),v&&(0,l.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50 backdrop-blur-sm",children:(0,l.jsxs)("div",{className:"mx-4 flex w-full max-w-sm flex-col gap-4 rounded-xl border border-border bg-surface p-5 shadow-xl sm:p-6",children:[(0,l.jsx)("h3",{className:"font-semibold text-text-main",children:"Sudo Password Required"}),(0,l.jsxs)("div",{className:"flex items-start gap-3 p-3 bg-yellow-500/10 border border-yellow-500/30 rounded-lg",children:[(0,l.jsx)("span",{className:"material-symbols-outlined text-yellow-500 text-[20px]",children:"warning"}),(0,l.jsx)("p",{className:"text-xs text-text-muted",children:"Required to modify /etc/hosts and flush DNS cache"})]}),(0,l.jsx)(r.pd,{type:"password",placeholder:"Enter sudo password",value:k,onChange:e=>C(e.target.value),onKeyDown:e=>{"Enter"!==e.key||y||J()}}),E&&(0,l.jsxs)("div",{className:"flex items-center gap-2 px-2 py-1.5 rounded text-xs bg-red-500/10 text-red-600",children:[(0,l.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"error"}),(0,l.jsx)("span",{children:E})]}),(0,l.jsxs)("div",{className:"flex items-center justify-end gap-2",children:[(0,l.jsx)(r.$n,{variant:"ghost",size:"sm",onClick:()=>{w(!1),C(""),A(null)},disabled:y,children:"Cancel"}),(0,l.jsx)(r.$n,{variant:"primary",size:"sm",onClick:J,loading:y,children:"Confirm"})]})]})}),(0,l.jsx)(r.rq,{isOpen:R,onClose:()=>T(!1),onSelect:e=>{if(!$||e.isPlaceholder)return;let t={...I,[$]:e.value};P(t),q(t)},selectedModel:$?I[$]:null,activeProviders:p,modelAliases:h,title:`Select model for ${$}`})]})}var F=s(98500),q=s.n(F);function H({tool:e}){return(0,l.jsx)(q(),{href:"/dashboard/mitm",className:"block",children:(0,l.jsx)(r.Zp,{padding:"sm",className:"overflow-hidden hover:border-primary/50 transition-colors cursor-pointer",children:(0,l.jsxs)("div",{className:"flex items-center justify-between",children:[(0,l.jsxs)("div",{className:"flex items-center gap-3",children:[(0,l.jsx)("div",{className:"size-8 flex items-center justify-center shrink-0",children:(0,l.jsx)(i.A,{src:e.image,alt:e.name,width:32,height:32,className:"size-8 object-contain rounded-lg",sizes:"32px",onError:e=>{e.target.style.display="none"}})}),(0,l.jsxs)("div",{className:"min-w-0",children:[(0,l.jsxs)("div",{className:"flex items-center gap-2",children:[(0,l.jsx)("h3",{className:"font-medium text-sm",children:e.name}),(0,l.jsx)("span",{className:"px-1.5 py-0.5 text-[10px] font-medium bg-purple-500/10 text-purple-600 dark:text-purple-400 rounded-full",children:"MITM"})]}),(0,l.jsx)("p",{className:"text-xs text-text-muted truncate",children:e.description})]})]}),(0,l.jsx)("span",{className:"material-symbols-outlined text-text-muted text-[20px]",children:"chevron_right"})]})})})}}}]);