@fudrouter/fsrouter 0.6.72 → 0.6.74

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 (314) hide show
  1. package/dist/lib/headroom/detect.js +97 -7
  2. package/dist/lib/headroom/process.js +136 -4
  3. package/dist/open-sse/config/appConstants.js +23 -79
  4. package/dist/open-sse/config/cliFingerprints.js +1 -1
  5. package/dist/open-sse/config/errorConfig.js +0 -11
  6. package/dist/open-sse/config/grokCli.js +10 -0
  7. package/dist/open-sse/config/kiroConstants.js +99 -46
  8. package/dist/open-sse/config/runtimeConfig.js +2 -0
  9. package/dist/open-sse/config/ttsModels.js +2 -0
  10. package/dist/open-sse/executors/antigravity.js +250 -164
  11. package/dist/open-sse/executors/base.js +16 -11
  12. package/dist/open-sse/executors/codex.js +269 -1108
  13. package/dist/open-sse/executors/commandCode.js +1 -1
  14. package/dist/open-sse/executors/commandcode.js +10 -4
  15. package/dist/open-sse/executors/cursor.js +96 -203
  16. package/dist/open-sse/executors/default.js +146 -244
  17. package/dist/open-sse/executors/github.js +128 -73
  18. package/dist/open-sse/executors/grok-cli.js +527 -94
  19. package/dist/open-sse/executors/grok-web.js +5 -7
  20. package/dist/open-sse/executors/index.js +12 -0
  21. package/dist/open-sse/executors/kiro.js +150 -61
  22. package/dist/open-sse/executors/opencode-go.js +12 -4
  23. package/dist/open-sse/executors/opencode.js +1 -1
  24. package/dist/open-sse/executors/perplexity-web.js +20 -96
  25. package/dist/open-sse/executors/qoder.js +28 -18
  26. package/dist/open-sse/executors/vertex.js +53 -7
  27. package/dist/open-sse/executors/xiaomi-tokenplan.js +6 -5
  28. package/dist/open-sse/handlers/chatCore/nonStreamingHandler.js +97 -85
  29. package/dist/open-sse/handlers/chatCore/requestDetail.js +32 -8
  30. package/dist/open-sse/handlers/chatCore/sseToJsonHandler.js +13 -7
  31. package/dist/open-sse/handlers/chatCore/streamingHandler.js +74 -25
  32. package/dist/open-sse/handlers/chatCore.js +35 -41
  33. package/dist/open-sse/handlers/embeddingProviders/index.js +1 -0
  34. package/dist/open-sse/handlers/embeddingProviders/openai.js +8 -16
  35. package/dist/open-sse/handlers/imageProviders/blackForestLabs.js +2 -21
  36. package/dist/open-sse/handlers/imageProviders/cloudflareAi.js +2 -30
  37. package/dist/open-sse/handlers/imageProviders/codex.js +2 -20
  38. package/dist/open-sse/handlers/imageProviders/comfyui.js +5 -18
  39. package/dist/open-sse/handlers/imageProviders/falAi.js +2 -22
  40. package/dist/open-sse/handlers/imageProviders/gemini.js +2 -16
  41. package/dist/open-sse/handlers/imageProviders/huggingface.js +2 -17
  42. package/dist/open-sse/handlers/imageProviders/index.js +3 -4
  43. package/dist/open-sse/handlers/imageProviders/leonardo.js +1 -1
  44. package/dist/open-sse/handlers/imageProviders/nanobanana.js +4 -23
  45. package/dist/open-sse/handlers/imageProviders/openai.js +15 -43
  46. package/dist/open-sse/handlers/imageProviders/runwayml.js +2 -26
  47. package/dist/open-sse/handlers/imageProviders/sdwebui.js +4 -20
  48. package/dist/open-sse/handlers/imageProviders/stabilityAi.js +2 -26
  49. package/dist/open-sse/handlers/imageProviders/weavy.js +1 -1
  50. package/dist/open-sse/handlers/search/chatSearch.js +60 -14
  51. package/dist/open-sse/handlers/ttsProviders/gemini.js +14 -3
  52. package/dist/open-sse/handlers/ttsProviders/index.js +4 -2
  53. package/dist/open-sse/handlers/ttsProviders/openai.js +4 -1
  54. package/dist/open-sse/handlers/ttsProviders/openrouter.js +7 -4
  55. package/dist/open-sse/handlers/videoCore.js +166 -0
  56. package/dist/open-sse/handlers/videoProviders/weavy.js +1 -1
  57. package/dist/open-sse/mcp-server/catalog.js +1 -1
  58. package/dist/open-sse/mcp-server/server.js +2 -2
  59. package/dist/open-sse/mcp-server/tools/advancedTools.js +2 -2
  60. package/dist/open-sse/mcp-server/tools/agentSkillTools.js +1 -1
  61. package/dist/open-sse/mcp-server/tools/compressionTools.js +4 -4
  62. package/dist/open-sse/mcp-server/tools/gamificationTools.js +10 -10
  63. package/dist/open-sse/mcp-server/tools/githubSkillTools.js +1 -1
  64. package/dist/open-sse/mcp-server/tools/memoryTools.js +3 -3
  65. package/dist/open-sse/mcp-server/tools/notionTools.js +2 -2
  66. package/dist/open-sse/mcp-server/tools/obsidianTools.js +2 -2
  67. package/dist/open-sse/mcp-server/tools/pickFastestModel.js +1 -1
  68. package/dist/open-sse/mcp-server/tools/pluginTools.js +4 -4
  69. package/dist/open-sse/mcp-server/tools/skillTools.js +2 -2
  70. package/dist/open-sse/providers/capabilities.js +24 -4
  71. package/dist/open-sse/providers/registry/alicode-intl.js +1 -1
  72. package/dist/open-sse/providers/registry/anthropic.js +1 -8
  73. package/dist/open-sse/providers/registry/codex.js +0 -9
  74. package/dist/open-sse/providers/registry/cohere.js +0 -2
  75. package/dist/open-sse/providers/registry/gemini.js +0 -2
  76. package/dist/open-sse/providers/registry/github.js +9 -6
  77. package/dist/open-sse/providers/registry/grok-cli.js +28 -18
  78. package/dist/open-sse/providers/registry/index.js +74 -80
  79. package/dist/open-sse/providers/registry/kiro.js +12 -0
  80. package/dist/open-sse/providers/registry/mistral.js +0 -3
  81. package/dist/open-sse/providers/registry/openai.js +0 -3
  82. package/dist/open-sse/providers/registry/perplexity.js +0 -2
  83. package/dist/open-sse/providers/registry/xai.js +5 -3
  84. package/dist/open-sse/rtk/autodetect.js +10 -2
  85. package/dist/open-sse/rtk/caveman.js +2 -93
  86. package/dist/open-sse/rtk/cavemanPrompts.js +34 -2
  87. package/dist/open-sse/rtk/constants.js +7 -2
  88. package/dist/open-sse/rtk/headroom.js +133 -0
  89. package/dist/open-sse/rtk/ponytail.js +1 -1
  90. package/dist/open-sse/rtk/registry.js +2 -0
  91. package/dist/open-sse/services/accountFallback.js +0 -108
  92. package/dist/open-sse/services/combo/quotaExhaustionCutoff.js +2 -2
  93. package/dist/open-sse/services/combo/quotaShareStrategy.js +1 -1
  94. package/dist/open-sse/services/combo/resolveAutoStrategy.js +1 -1
  95. package/dist/open-sse/services/combo/sessionStickiness.js +1 -1
  96. package/dist/open-sse/services/combo/targetSorters.js +2 -2
  97. package/dist/open-sse/services/combo/validateQuality.js +1 -1
  98. package/dist/open-sse/services/comboConfig.js +1 -1
  99. package/dist/open-sse/services/emergencyFallback.js +1 -1
  100. package/dist/open-sse/services/grokCliModels.js +127 -0
  101. package/dist/open-sse/services/model.js +7 -1
  102. package/dist/open-sse/services/provider.js +1 -1
  103. package/dist/open-sse/services/proxyAutoSelector.js +1 -1
  104. package/dist/open-sse/services/tokenRefresh/providers.js +3 -3
  105. package/dist/open-sse/services/usage/codex.js +148 -214
  106. package/dist/open-sse/services/usage/grok-cli.js +61 -7
  107. package/dist/open-sse/services/usage/misc.js +0 -19
  108. package/dist/open-sse/services/usage.js +0 -2
  109. package/dist/open-sse/translator/concerns/paramSupport.js +2 -2
  110. package/dist/open-sse/translator/concerns/thinkingUnified.js +6 -0
  111. package/dist/open-sse/translator/index.js +97 -59
  112. package/dist/open-sse/translator/request/claude-to-kiro.js +67 -40
  113. package/dist/open-sse/translator/request/openai-responses.js +1 -0
  114. package/dist/open-sse/translator/request/openai-to-commandcode.js +0 -4
  115. package/dist/open-sse/translator/request/openai-to-kiro.js +49 -20
  116. package/dist/open-sse/translator/response/commandcode-to-openai.js +0 -4
  117. package/dist/open-sse/utils/bypassHandler.js +18 -3
  118. package/dist/open-sse/utils/claudeCloaking.js +15 -5
  119. package/dist/open-sse/utils/cursorImages.js +1 -1
  120. package/dist/open-sse/utils/error.js +0 -17
  121. package/dist/open-sse/utils/keepaliveThreshold.js +4 -4
  122. package/dist/open-sse/utils/kiroSessionReplay.js +125 -0
  123. package/dist/open-sse/utils/noThinkingAlias.js +1 -1
  124. package/dist/open-sse/utils/proxyFetch.js +0 -1
  125. package/dist/open-sse/utils/reasoningContentInjector.js +4 -7
  126. package/dist/open-sse/utils/responsesStatePolicy.js +1 -1
  127. package/dist/open-sse/utils/responsesStreamHelpers.js +1 -0
  128. package/dist/open-sse/utils/sessionManager.js +49 -22
  129. package/dist/open-sse/utils/stream.js +54 -77
  130. package/dist/open-sse/utils/streamHandler.js +19 -15
  131. package/dist/open-sse/utils/streamHelpers.js +2 -17
  132. package/dist/open-sse/utils/usageTracking.js +103 -12
  133. package/dist/routes/headroom/extras/route.js +58 -0
  134. package/dist/routes/headroom/restart/route.js +33 -0
  135. package/open-sse/config/appConstants.js +23 -79
  136. package/open-sse/config/errorConfig.js +0 -11
  137. package/open-sse/config/grokCli.js +10 -0
  138. package/open-sse/config/kiroConstants.js +99 -46
  139. package/open-sse/config/runtimeConfig.js +2 -0
  140. package/open-sse/config/ttsModels.js +2 -0
  141. package/open-sse/executors/antigravity.js +250 -164
  142. package/open-sse/executors/base.js +16 -11
  143. package/open-sse/executors/codex.js +269 -1108
  144. package/open-sse/executors/commandcode.js +10 -4
  145. package/open-sse/executors/cursor.js +96 -203
  146. package/open-sse/executors/default.js +146 -244
  147. package/open-sse/executors/github.js +128 -73
  148. package/open-sse/executors/grok-cli.js +527 -94
  149. package/open-sse/executors/grok-web.js +5 -7
  150. package/open-sse/executors/index.js +12 -0
  151. package/open-sse/executors/kiro.js +150 -61
  152. package/open-sse/executors/opencode-go.js +12 -4
  153. package/open-sse/executors/opencode.js +1 -1
  154. package/open-sse/executors/perplexity-web.js +20 -96
  155. package/open-sse/executors/qoder.js +28 -18
  156. package/open-sse/executors/vertex.js +53 -7
  157. package/open-sse/executors/xiaomi-tokenplan.js +6 -5
  158. package/open-sse/handlers/chatCore/nonStreamingHandler.js +97 -85
  159. package/open-sse/handlers/chatCore/requestDetail.js +32 -8
  160. package/open-sse/handlers/chatCore/sseToJsonHandler.js +13 -7
  161. package/open-sse/handlers/chatCore/streamingHandler.js +74 -25
  162. package/open-sse/handlers/chatCore.js +35 -41
  163. package/open-sse/handlers/embeddingProviders/index.js +1 -0
  164. package/open-sse/handlers/embeddingProviders/openai.js +8 -16
  165. package/open-sse/handlers/imageProviders/blackForestLabs.js +2 -21
  166. package/open-sse/handlers/imageProviders/cloudflareAi.js +2 -30
  167. package/open-sse/handlers/imageProviders/codex.js +2 -20
  168. package/open-sse/handlers/imageProviders/comfyui.js +5 -18
  169. package/open-sse/handlers/imageProviders/falAi.js +2 -22
  170. package/open-sse/handlers/imageProviders/gemini.js +2 -16
  171. package/open-sse/handlers/imageProviders/huggingface.js +2 -17
  172. package/open-sse/handlers/imageProviders/index.js +3 -4
  173. package/open-sse/handlers/imageProviders/leonardo.js +1 -1
  174. package/open-sse/handlers/imageProviders/nanobanana.js +4 -23
  175. package/open-sse/handlers/imageProviders/openai.js +15 -43
  176. package/open-sse/handlers/imageProviders/runwayml.js +2 -26
  177. package/open-sse/handlers/imageProviders/sdwebui.js +4 -20
  178. package/open-sse/handlers/imageProviders/stabilityAi.js +2 -26
  179. package/open-sse/handlers/imageProviders/weavy.js +1 -1
  180. package/open-sse/handlers/search/chatSearch.js +60 -14
  181. package/open-sse/handlers/ttsProviders/gemini.js +14 -3
  182. package/open-sse/handlers/ttsProviders/index.js +4 -2
  183. package/open-sse/handlers/ttsProviders/openai.js +4 -1
  184. package/open-sse/handlers/ttsProviders/openrouter.js +7 -4
  185. package/open-sse/handlers/videoCore.js +166 -0
  186. package/open-sse/handlers/videoProviders/weavy.js +1 -1
  187. package/open-sse/mcp-server/audit.js +1 -1
  188. package/open-sse/mcp-server/catalog.js +2 -2
  189. package/open-sse/mcp-server/descriptionCompressor.js +1 -1
  190. package/open-sse/mcp-server/mcpCallerIdentity.js +1 -1
  191. package/open-sse/mcp-server/schemas/tools.js +1 -1
  192. package/open-sse/mcp-server/server.js +4 -4
  193. package/open-sse/mcp-server/tools/advancedTools.js +5 -5
  194. package/open-sse/mcp-server/tools/agentSkillTools.js +1 -1
  195. package/open-sse/mcp-server/tools/compressionTools.js +4 -4
  196. package/open-sse/mcp-server/tools/gamificationTools.js +10 -10
  197. package/open-sse/mcp-server/tools/githubSkillTools.js +1 -1
  198. package/open-sse/mcp-server/tools/memoryTools.js +3 -3
  199. package/open-sse/mcp-server/tools/notionTools.js +2 -2
  200. package/open-sse/mcp-server/tools/obsidianTools.js +2 -2
  201. package/open-sse/mcp-server/tools/pickFastestModel.js +3 -3
  202. package/open-sse/mcp-server/tools/pluginTools.js +4 -4
  203. package/open-sse/mcp-server/tools/skillTools.js +2 -2
  204. package/open-sse/providers/capabilities.js +24 -4
  205. package/open-sse/providers/registry/alicode-intl.js +1 -1
  206. package/open-sse/providers/registry/anthropic.js +1 -8
  207. package/open-sse/providers/registry/codex.js +0 -9
  208. package/open-sse/providers/registry/cohere.js +0 -2
  209. package/open-sse/providers/registry/gemini.js +0 -2
  210. package/open-sse/providers/registry/github.js +9 -6
  211. package/open-sse/providers/registry/grok-cli.js +28 -18
  212. package/open-sse/providers/registry/index.js +74 -80
  213. package/open-sse/providers/registry/kiro.js +12 -0
  214. package/open-sse/providers/registry/mistral.js +0 -3
  215. package/open-sse/providers/registry/openai.js +0 -3
  216. package/open-sse/providers/registry/perplexity.js +0 -2
  217. package/open-sse/providers/registry/xai.js +5 -3
  218. package/open-sse/rtk/autodetect.js +10 -2
  219. package/open-sse/rtk/caveman.js +2 -93
  220. package/open-sse/rtk/cavemanPrompts.js +34 -2
  221. package/open-sse/rtk/constants.js +7 -2
  222. package/open-sse/rtk/headroom.js +133 -0
  223. package/open-sse/rtk/ponytail.js +1 -1
  224. package/open-sse/rtk/registry.js +2 -0
  225. package/open-sse/services/accountFallback.js +0 -108
  226. package/open-sse/services/combo/quotaExhaustionCutoff.js +2 -2
  227. package/open-sse/services/combo/quotaShareStrategy.js +1 -1
  228. package/open-sse/services/combo/resolveAutoStrategy.js +1 -1
  229. package/open-sse/services/combo/sessionStickiness.js +1 -1
  230. package/open-sse/services/combo/shadowRouting.js +1 -1
  231. package/open-sse/services/combo/targetSorters.js +4 -4
  232. package/open-sse/services/combo/validateQuality.js +1 -1
  233. package/open-sse/services/evalRouting.js +1 -1
  234. package/open-sse/services/grokCliModels.js +127 -0
  235. package/open-sse/services/model.js +7 -1
  236. package/open-sse/services/modelCapabilities.js +1 -1
  237. package/open-sse/services/modelFamilyFallback.js +1 -1
  238. package/open-sse/services/provider.js +1 -1
  239. package/open-sse/services/providerCooldownTracker.js +1 -1
  240. package/open-sse/services/rateLimitManager.js +1 -1
  241. package/open-sse/services/tokenRefresh/providers.js +3 -3
  242. package/open-sse/services/usage/codex.js +148 -214
  243. package/open-sse/services/usage/grok-cli.js +61 -7
  244. package/open-sse/services/usage/misc.js +0 -19
  245. package/open-sse/services/usage.js +0 -2
  246. package/open-sse/translator/concerns/paramSupport.js +2 -2
  247. package/open-sse/translator/concerns/thinkingUnified.js +6 -0
  248. package/open-sse/translator/index.js +97 -59
  249. package/open-sse/translator/request/claude-to-kiro.js +67 -40
  250. package/open-sse/translator/request/openai-responses.js +1 -0
  251. package/open-sse/translator/request/openai-to-commandcode.js +0 -4
  252. package/open-sse/translator/request/openai-to-kiro.js +49 -20
  253. package/open-sse/translator/response/commandcode-to-openai.js +0 -4
  254. package/open-sse/utils/bypassHandler.js +18 -3
  255. package/open-sse/utils/claudeCloaking.js +15 -5
  256. package/open-sse/utils/error.js +0 -17
  257. package/open-sse/utils/kiroSessionReplay.js +125 -0
  258. package/open-sse/utils/logger.js +1 -1
  259. package/open-sse/utils/proxyFetch.js +0 -1
  260. package/open-sse/utils/reasoningContentInjector.js +4 -7
  261. package/open-sse/utils/responsesStreamHelpers.js +1 -0
  262. package/open-sse/utils/sessionManager.js +49 -22
  263. package/open-sse/utils/stream.js +54 -77
  264. package/open-sse/utils/streamHandler.js +19 -15
  265. package/open-sse/utils/streamHelpers.js +2 -17
  266. package/open-sse/utils/usageTracking.js +103 -12
  267. package/package.json +4 -7
  268. package/public/assets/EndpointPageClient.C2WMTYy0.js +6 -0
  269. package/public/assets/{Loading.Bj-WGl4k.js → Loading.BHPtQ9vj.js} +1 -1
  270. package/public/assets/{NoAuthProxyCard.qAv57b-0.js → NoAuthProxyCard.BDcXaWvM.js} +1 -1
  271. package/public/assets/index.Be3gbrBl.js +89 -0
  272. package/public/assets/index.COMgQZYj.css +1 -0
  273. package/public/assets/{page.CbkENBd5.js → page.-lpNgYAw.js} +1 -1
  274. package/public/assets/{page.CssmrzTT.js → page.11hpNKmq.js} +1 -1
  275. package/public/assets/{page.C72FTTJr.js → page.B-LxsnqU.js} +1 -1
  276. package/public/assets/{page.sOFOrxqq.js → page.B-dzeIUC.js} +1 -1
  277. package/public/assets/{page.CsxWmPoI.js → page.B-nBR75u.js} +1 -1
  278. package/public/assets/{page.Dx_GRRdT.js → page.B3QqvLep.js} +1 -1
  279. package/public/assets/{page.DPyOkPVo.js → page.B8xdkCWA.js} +1 -1
  280. package/public/assets/{page.DUI8kqOY.js → page.BFb7yUd8.js} +1 -1
  281. package/public/assets/page.BbPPdoas.js +1 -0
  282. package/public/assets/page.BdS20a1O.js +1 -0
  283. package/public/assets/{page.DibhF7f-.js → page.BfmI9KYe.js} +1 -1
  284. package/public/assets/{page.DX4Nno6M.js → page.BgGJovOg.js} +1 -1
  285. package/public/assets/{page.BnmTC5jG.js → page.C0gBvR4O.js} +1 -1
  286. package/public/assets/{page.D5gj98Oe.js → page.C6bYizL7.js} +1 -1
  287. package/public/assets/{page.vla5Mzki.js → page.C8sLEMa6.js} +1 -1
  288. package/public/assets/{page.CXd_R9yU.js → page.CCNsZBXp.js} +1 -1
  289. package/public/assets/{page.CQlVGoXg.js → page.CF_YSLwP.js} +1 -1
  290. package/public/assets/{page.BbO1pspY.js → page.CPTtRDxw.js} +1 -1
  291. package/public/assets/{page.D1oKew1j.js → page.CdMmlUEm.js} +1 -1
  292. package/public/assets/{page.DxMDTbSx.js → page.Cged1bOZ.js} +1 -1
  293. package/public/assets/{page.Cj5h09Zo.js → page.Ch647dVk.js} +1 -1
  294. package/public/assets/{page.DVIHRbxB.js → page.CpvXDkQF.js} +1 -1
  295. package/public/assets/{page.i4KDuWcM.js → page.CrBl7f8N.js} +1 -1
  296. package/public/assets/{page.BSLJ4tx5.js → page.CrP7niA2.js} +1 -1
  297. package/public/assets/{page.CnTop8Zt.js → page.CvUFZzXr.js} +1 -1
  298. package/public/assets/{page.O2ddJYoT.js → page.CyUqJPmx.js} +1 -1
  299. package/public/assets/{page.DBhu4Arl.js → page.D8Rp8fFR.js} +1 -1
  300. package/public/assets/{page.CPZav1_c.js → page.Df9qtrdG.js} +1 -1
  301. package/public/assets/{page.Qkkv8roc.js → page.DiL4Gwqe.js} +1 -1
  302. package/public/assets/{page.BdmJ3yY3.js → page.Dl1apZE2.js} +1 -1
  303. package/public/assets/{page.1qjqvrwX.js → page.HV0w1d5C.js} +1 -1
  304. package/public/assets/{page.ChX1NqmC.js → page.N1x4YL8_.js} +1 -1
  305. package/public/assets/{page.Dh5f0XJC.js → page.P2Ny5veR.js} +1 -1
  306. package/public/assets/{page.CSs3-gdt.js → page.fOOCr18J.js} +1 -1
  307. package/public/assets/{page.Ir7KvKcF.js → page.sUIPWIiF.js} +1 -1
  308. package/public/assets/{page.CzlQTyAL.js → page.tE7PpWYW.js} +1 -1
  309. package/public/assets/{page.DzZLqI5Q.js → page.uziaGZsT.js} +1 -1
  310. package/public/index.html +2 -2
  311. package/public/assets/EndpointPageClient.LyNNvZ4z.js +0 -6
  312. package/public/assets/index.BuPfZebu.css +0 -1
  313. package/public/assets/index.CShjRV_B.js +0 -89
  314. package/public/assets/page.DD_czjjP.js +0 -1
@@ -1,4 +1,4 @@
1
- import{j as e}from"./index.CShjRV_B.js";import{b as l}from"./router.Cjj1--8t.js";import"./zustand.akaTi5uX.js";function b({value:r,label:d="Copy"}){const[t,i]=l.useState(!1),a=async()=>{if(r)try{await navigator.clipboard.writeText(r),i(!0),setTimeout(()=>i(!1),1500)}catch{const n=document.createElement("textarea");n.value=r,document.body.appendChild(n),n.select(),document.execCommand("copy"),document.body.removeChild(n),i(!0),setTimeout(()=>i(!1),1500)}};return e.jsx("button",{onClick:a,disabled:!r,title:r?r.slice(0,60)+(r.length>60?"…":""):"Tidak tersedia",style:{padding:"2px 10px",fontSize:11,borderRadius:4,border:"1px solid",cursor:r?"pointer":"not-allowed",borderColor:t?"#22c55e":r?"#6366f1":"#374151",background:t?"#166534":r?"#1e1b4b":"#111827",color:t?"#86efac":r?"#a5b4fc":"#4b5563",transition:"all 0.15s",whiteSpace:"nowrap",minWidth:60},children:t?"✓ Copied!":d})}function y({value:r,maxLen:d=22}){const[t,i]=l.useState(!1);if(!r)return e.jsx("span",{style:{color:"#6b7280",fontSize:12},children:"—"});const a=t?r:r.slice(0,d)+"…";return e.jsxs("span",{style:{fontFamily:"monospace",fontSize:11,color:"#d1d5db"},children:[a,e.jsx("button",{onClick:()=>i(n=>!n),style:{marginLeft:4,fontSize:10,color:"#6366f1",background:"none",border:"none",cursor:"pointer"},children:t?"hide":"show"})]})}function w(r){const d=r.map(s=>({email:s.email,firebase_refresh_token:s.firebaseRefreshToken,firebase_api_key:s.firebaseApiKey,jwt:s.jwt,jwt_expires_at:s.jwtExpiresAt,balance:s.balance})),t=JSON.stringify(d,null,2),i=new Blob([t],{type:"application/json"}),a=URL.createObjectURL(i),n=document.createElement("a");n.href=a,n.download=`weavy-tokens-${Date.now()}.json`,n.click(),URL.revokeObjectURL(a)}function S(r){const t=`email,firebase_refresh_token,firebase_api_key
1
+ import{j as e}from"./index.Be3gbrBl.js";import{b as l}from"./router.Cjj1--8t.js";import"./zustand.akaTi5uX.js";function b({value:r,label:d="Copy"}){const[t,i]=l.useState(!1),a=async()=>{if(r)try{await navigator.clipboard.writeText(r),i(!0),setTimeout(()=>i(!1),1500)}catch{const n=document.createElement("textarea");n.value=r,document.body.appendChild(n),n.select(),document.execCommand("copy"),document.body.removeChild(n),i(!0),setTimeout(()=>i(!1),1500)}};return e.jsx("button",{onClick:a,disabled:!r,title:r?r.slice(0,60)+(r.length>60?"…":""):"Tidak tersedia",style:{padding:"2px 10px",fontSize:11,borderRadius:4,border:"1px solid",cursor:r?"pointer":"not-allowed",borderColor:t?"#22c55e":r?"#6366f1":"#374151",background:t?"#166534":r?"#1e1b4b":"#111827",color:t?"#86efac":r?"#a5b4fc":"#4b5563",transition:"all 0.15s",whiteSpace:"nowrap",minWidth:60},children:t?"✓ Copied!":d})}function y({value:r,maxLen:d=22}){const[t,i]=l.useState(!1);if(!r)return e.jsx("span",{style:{color:"#6b7280",fontSize:12},children:"—"});const a=t?r:r.slice(0,d)+"…";return e.jsxs("span",{style:{fontFamily:"monospace",fontSize:11,color:"#d1d5db"},children:[a,e.jsx("button",{onClick:()=>i(n=>!n),style:{marginLeft:4,fontSize:10,color:"#6366f1",background:"none",border:"none",cursor:"pointer"},children:t?"hide":"show"})]})}function w(r){const d=r.map(s=>({email:s.email,firebase_refresh_token:s.firebaseRefreshToken,firebase_api_key:s.firebaseApiKey,jwt:s.jwt,jwt_expires_at:s.jwtExpiresAt,balance:s.balance})),t=JSON.stringify(d,null,2),i=new Blob([t],{type:"application/json"}),a=URL.createObjectURL(i),n=document.createElement("a");n.href=a,n.download=`weavy-tokens-${Date.now()}.json`,n.click(),URL.revokeObjectURL(a)}function S(r){const t=`email,firebase_refresh_token,firebase_api_key
2
2
  `+r.filter(s=>s.firebaseRefreshToken&&s.firebaseApiKey).map(s=>`${s.email},${s.firebaseRefreshToken},${s.firebaseApiKey}`).join(`
3
3
  `),i=new Blob([t],{type:"text/csv"}),a=URL.createObjectURL(i),n=document.createElement("a");n.href=a,n.download=`weavy-refresh-tokens-${Date.now()}.csv`,n.click(),URL.revokeObjectURL(a)}function C(){const[r,d]=l.useState([]),[t,i]=l.useState(null),[a,n]=l.useState(!0),[s,g]=l.useState(""),[x,m]=l.useState(""),[p,j]=l.useState("all"),h=l.useCallback(async()=>{n(!0),g("");try{const c=await(await fetch("/api/providers/weavy/pool")).json();if(!c.ok)throw new Error(c.error||"Failed");d(c.pool||[]),i(c.stats||null)}catch(o){g(o.message)}finally{n(!1)}},[]);l.useEffect(()=>{h()},[h]);const u=r.filter(o=>{const c=!x||o.email.toLowerCase().includes(x.toLowerCase()),k=p==="all"?!0:p==="hasToken"?!!o.firebaseRefreshToken:p==="noToken"?!o.firebaseRefreshToken:p==="validJwt"?o.jwtValid:!0;return c&&k}),v={background:"#111827",border:"1px solid #1f2937",borderRadius:8,padding:"10px 14px",marginBottom:8},f=(o,c,k="#6366f1")=>e.jsxs("div",{style:{background:"#0f172a",borderRadius:8,padding:"12px 20px",border:"1px solid #1f2937",textAlign:"center",minWidth:100},children:[e.jsx("div",{style:{fontSize:28,fontWeight:700,color:k},children:c}),e.jsx("div",{style:{fontSize:11,color:"#9ca3af",marginTop:2},children:o})]});return e.jsxs("div",{style:{minHeight:"100vh",background:"#030712",color:"#e5e7eb",padding:"24px 32px",fontFamily:"Inter, sans-serif"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:24},children:[e.jsxs("div",{children:[e.jsx("h1",{style:{margin:0,fontSize:22,fontWeight:700,color:"#f9fafb"},children:"🪄 Weavy Token Pool"}),e.jsx("p",{style:{margin:"4px 0 0",fontSize:13,color:"#6b7280"},children:"Copy firebase_refresh_token + firebase_api_key ke kliperspro atau sistem lain"})]}),e.jsxs("div",{style:{display:"flex",gap:8},children:[e.jsx("button",{onClick:h,style:{padding:"6px 14px",borderRadius:6,background:"#1f2937",border:"1px solid #374151",color:"#d1d5db",cursor:"pointer",fontSize:13},children:"↻ Refresh"}),e.jsx("button",{onClick:()=>S(r),style:{padding:"6px 14px",borderRadius:6,background:"#1e1b4b",border:"1px solid #4338ca",color:"#a5b4fc",cursor:"pointer",fontSize:13},children:"⬇ Export CSV"}),e.jsx("button",{onClick:()=>w(r),style:{padding:"6px 14px",borderRadius:6,background:"#14532d",border:"1px solid #166534",color:"#86efac",cursor:"pointer",fontSize:13},children:"⬇ Export JSON"})]})]}),t&&e.jsxs("div",{style:{display:"flex",gap:12,marginBottom:24,flexWrap:"wrap"},children:[f("Total Akun",t.total,"#e5e7eb"),f("Aktif",t.active,"#22c55e"),f("JWT Valid",t.jwtValid,"#6366f1"),f("Punya Refresh Token",t.hasRefreshToken,"#f59e0b")]}),t&&t.hasRefreshToken===0&&e.jsxs("div",{style:{background:"#431407",border:"1px solid #7c2d12",borderRadius:8,padding:"12px 16px",marginBottom:20,fontSize:13,color:"#fed7aa"},children:["⚠️ ",e.jsx("strong",{children:"firebase_refresh_token masih kosong"})," untuk semua akun. Jalankan ulang signup untuk akun-akun ini agar refresh token tertangkap dari IndexedDB."]}),e.jsxs("div",{style:{background:"#0c1a2e",border:"1px solid #1e3a5f",borderRadius:8,padding:"12px 16px",marginBottom:20,fontSize:12},children:[e.jsx("strong",{style:{color:"#60a5fa"},children:"📋 Cara pakai di kliperspro (production):"}),e.jsx("pre",{style:{margin:"8px 0 0",color:"#93c5fd",fontSize:11,overflow:"auto"},children:`POST https://securetoken.googleapis.com/v1/token?key=<firebase_api_key>
4
4
  Body: grant_type=refresh_token&refresh_token=<firebase_refresh_token>
@@ -1 +1 @@
1
- import{j as e,B as h}from"./index.CShjRV_B.js";import{b as r}from"./router.Cjj1--8t.js";import"./NoAuthProxyCard.qAv57b-0.js";import"./zustand.akaTi5uX.js";function R(){const[l,s]=r.useState(!1),[c,a]=r.useState(""),[o,m]=r.useState(""),i=r.useRef(null),f=()=>{window.location.href="/api/db"},b=()=>{i.current&&i.current.click()},g=async n=>{const t=n.target.files[0];if(t){if(!t.name.endsWith(".fud")&&!t.name.endsWith(".json")){a("Format file tidak didukung. Harap gunakan file berekstensi .fud");return}if(!window.confirm("PERINGATAN: Memulihkan database akan MENIMPA semua data, pengaturan, dan provider saat ini! Server akan di-restart otomatis. Lanjutkan?")){n.target.value="";return}a(""),m(""),s(!0);try{const d=new FileReader;d.onload=async j=>{try{const x=j.target.result,k=JSON.parse(x),u=await fetch("/api/db",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(k)}),p=await u.json();u.ok&&p.success?(m("Restore berhasil! Server sedang merestart, harap tunggu beberapa saat..."),setTimeout(()=>{window.location.reload()},5e3)):(a(p.error||"Gagal melakukan restore."),s(!1))}catch{a("File backup corrupt atau tidak valid."),s(!1)}},d.readAsText(t)}catch{a("Gagal membaca file."),s(!1)}n.target.value=""}};return e.jsxs("div",{className:"max-w-4xl mx-auto p-4 space-y-6",children:[e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsxs("h1",{className:"text-2xl font-bold text-text-main flex items-center gap-2",children:[e.jsx("span",{className:"material-symbols-outlined text-[28px] text-primary",children:"backup"}),"Backup & Restore"]}),e.jsx("p",{className:"text-xs text-text-muted",children:"Amankan seluruh data FSRouter Anda ke dalam satu file .fud, atau pulihkan data dari file backup sebelumnya."})]}),c&&e.jsxs("div",{className:"p-4 bg-red-500/10 border border-red-500/20 text-red-500 text-sm rounded-lg flex items-center gap-2",children:[e.jsx("span",{className:"material-symbols-outlined text-sm",children:"error"}),c]}),o&&e.jsxs("div",{className:"p-4 bg-green-500/10 border border-green-500/20 text-green-500 text-sm rounded-lg flex items-center gap-2",children:[e.jsx("span",{className:"material-symbols-outlined text-sm",children:"check_circle"}),o]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"p-6 rounded-[14px] border border-border-subtle bg-surface flex flex-col gap-4",children:[e.jsxs("div",{className:"flex items-center gap-3 text-text-main",children:[e.jsx("div",{className:"size-10 rounded-full bg-blue-500/10 text-blue-500 flex items-center justify-center",children:e.jsx("span",{className:"material-symbols-outlined text-xl",children:"cloud_download"})}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-sm font-semibold",children:"Buat Backup"}),e.jsx("p",{className:"text-[11px] text-text-muted",children:"Simpan data ke perangkat Anda"})]})]}),e.jsxs("div",{className:"text-xs text-text-muted leading-relaxed flex-1",children:[e.jsx("p",{className:"mb-2",children:"File backup (.fud) berisi keseluruhan state sistem:"}),e.jsxs("ul",{className:"list-disc list-inside space-y-1 ml-1",children:[e.jsx("li",{children:"Konfigurasi Providers & Endpoint"}),e.jsx("li",{children:"Riwayat Penggunaan & Limits"}),e.jsx("li",{children:"Akun Otomatis & FSmail"}),e.jsx("li",{children:"Proxy Pools & Identitas Perangkat"})]})]}),e.jsx(h,{variant:"primary",fullWidth:!0,onClick:f,icon:"download",children:"Download Backup (.fud)"})]}),e.jsxs("div",{className:"p-6 rounded-[14px] border border-border-subtle bg-surface flex flex-col gap-4",children:[e.jsxs("div",{className:"flex items-center gap-3 text-text-main",children:[e.jsx("div",{className:"size-10 rounded-full bg-amber-500/10 text-amber-500 flex items-center justify-center",children:e.jsx("span",{className:"material-symbols-outlined text-xl",children:"restore"})}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-sm font-semibold",children:"Pulihkan Backup"}),e.jsx("p",{className:"text-[11px] text-text-muted",children:"Timpa data dari file .fud"})]})]}),e.jsxs("div",{className:"text-xs text-text-muted leading-relaxed flex-1",children:[e.jsx("p",{className:"mb-2 text-amber-500/90 font-medium",children:"Perhatian sebelum memulihkan:"}),e.jsx("p",{children:"Proses restore akan menghapus dan menimpa database yang berjalan saat ini dengan database yang ada di file backup. FSRouter akan melakukan restart layanan setelah proses restore selesai."})]}),e.jsx("input",{type:"file",accept:".fud,.json",ref:i,onChange:g,className:"hidden"}),e.jsx(h,{variant:"secondary",fullWidth:!0,onClick:b,disabled:l,icon:l?"sync":"upload",children:l?"Sedang Memulihkan...":"Pilih File & Restore"})]})]})]})}export{R as default};
1
+ import{j as e,B as h}from"./index.Be3gbrBl.js";import{b as r}from"./router.Cjj1--8t.js";import"./NoAuthProxyCard.BDcXaWvM.js";import"./zustand.akaTi5uX.js";function R(){const[l,s]=r.useState(!1),[c,a]=r.useState(""),[o,m]=r.useState(""),i=r.useRef(null),f=()=>{window.location.href="/api/db"},b=()=>{i.current&&i.current.click()},g=async n=>{const t=n.target.files[0];if(t){if(!t.name.endsWith(".fud")&&!t.name.endsWith(".json")){a("Format file tidak didukung. Harap gunakan file berekstensi .fud");return}if(!window.confirm("PERINGATAN: Memulihkan database akan MENIMPA semua data, pengaturan, dan provider saat ini! Server akan di-restart otomatis. Lanjutkan?")){n.target.value="";return}a(""),m(""),s(!0);try{const d=new FileReader;d.onload=async j=>{try{const x=j.target.result,k=JSON.parse(x),u=await fetch("/api/db",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(k)}),p=await u.json();u.ok&&p.success?(m("Restore berhasil! Server sedang merestart, harap tunggu beberapa saat..."),setTimeout(()=>{window.location.reload()},5e3)):(a(p.error||"Gagal melakukan restore."),s(!1))}catch{a("File backup corrupt atau tidak valid."),s(!1)}},d.readAsText(t)}catch{a("Gagal membaca file."),s(!1)}n.target.value=""}};return e.jsxs("div",{className:"max-w-4xl mx-auto p-4 space-y-6",children:[e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsxs("h1",{className:"text-2xl font-bold text-text-main flex items-center gap-2",children:[e.jsx("span",{className:"material-symbols-outlined text-[28px] text-primary",children:"backup"}),"Backup & Restore"]}),e.jsx("p",{className:"text-xs text-text-muted",children:"Amankan seluruh data FSRouter Anda ke dalam satu file .fud, atau pulihkan data dari file backup sebelumnya."})]}),c&&e.jsxs("div",{className:"p-4 bg-red-500/10 border border-red-500/20 text-red-500 text-sm rounded-lg flex items-center gap-2",children:[e.jsx("span",{className:"material-symbols-outlined text-sm",children:"error"}),c]}),o&&e.jsxs("div",{className:"p-4 bg-green-500/10 border border-green-500/20 text-green-500 text-sm rounded-lg flex items-center gap-2",children:[e.jsx("span",{className:"material-symbols-outlined text-sm",children:"check_circle"}),o]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"p-6 rounded-[14px] border border-border-subtle bg-surface flex flex-col gap-4",children:[e.jsxs("div",{className:"flex items-center gap-3 text-text-main",children:[e.jsx("div",{className:"size-10 rounded-full bg-blue-500/10 text-blue-500 flex items-center justify-center",children:e.jsx("span",{className:"material-symbols-outlined text-xl",children:"cloud_download"})}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-sm font-semibold",children:"Buat Backup"}),e.jsx("p",{className:"text-[11px] text-text-muted",children:"Simpan data ke perangkat Anda"})]})]}),e.jsxs("div",{className:"text-xs text-text-muted leading-relaxed flex-1",children:[e.jsx("p",{className:"mb-2",children:"File backup (.fud) berisi keseluruhan state sistem:"}),e.jsxs("ul",{className:"list-disc list-inside space-y-1 ml-1",children:[e.jsx("li",{children:"Konfigurasi Providers & Endpoint"}),e.jsx("li",{children:"Riwayat Penggunaan & Limits"}),e.jsx("li",{children:"Akun Otomatis & FSmail"}),e.jsx("li",{children:"Proxy Pools & Identitas Perangkat"})]})]}),e.jsx(h,{variant:"primary",fullWidth:!0,onClick:f,icon:"download",children:"Download Backup (.fud)"})]}),e.jsxs("div",{className:"p-6 rounded-[14px] border border-border-subtle bg-surface flex flex-col gap-4",children:[e.jsxs("div",{className:"flex items-center gap-3 text-text-main",children:[e.jsx("div",{className:"size-10 rounded-full bg-amber-500/10 text-amber-500 flex items-center justify-center",children:e.jsx("span",{className:"material-symbols-outlined text-xl",children:"restore"})}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-sm font-semibold",children:"Pulihkan Backup"}),e.jsx("p",{className:"text-[11px] text-text-muted",children:"Timpa data dari file .fud"})]})]}),e.jsxs("div",{className:"text-xs text-text-muted leading-relaxed flex-1",children:[e.jsx("p",{className:"mb-2 text-amber-500/90 font-medium",children:"Perhatian sebelum memulihkan:"}),e.jsx("p",{children:"Proses restore akan menghapus dan menimpa database yang berjalan saat ini dengan database yang ada di file backup. FSRouter akan melakukan restart layanan setelah proses restore selesai."})]}),e.jsx("input",{type:"file",accept:".fud,.json",ref:i,onChange:g,className:"hidden"}),e.jsx(h,{variant:"secondary",fullWidth:!0,onClick:b,disabled:l,icon:l?"sync":"upload",children:l?"Sedang Memulihkan...":"Pilih File & Restore"})]})]})]})}export{R as default};
@@ -1,4 +1,4 @@
1
- import{u as ze,j as e,M as Ue,B as q,w as De,x as Be,y as ke,z as He,h as We}from"./index.CShjRV_B.js";import{b as t,L as Te,h as Je,N as qe}from"./router.Cjj1--8t.js";import{C as Le}from"./cliTools.CsdwAybi.js";import{g as Pe}from"./machine.CagOtseJ.js";import{I as Ge,M as fe,C as ge}from"./NoAuthProxyCard.qAv57b-0.js";import{C as Ve}from"./Loading.Bj-WGl4k.js";import"./zustand.akaTi5uX.js";function ye({isOpen:d,onClose:r,title:L="Manual Configuration",configs:Y=[]}){const{copy:g}=ze(),[l,A]=t.useState(null),O=(E,_)=>{g(E,`manualconfig-${_}`),A(_),setTimeout(()=>A(null),2e3)};return e.jsx(Ue,{isOpen:d,onClose:r,title:L,size:"xl",children:e.jsx("div",{className:"flex flex-col gap-4",children:Y.map((E,_)=>e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-sm font-medium text-text-main",children:E.filename}),e.jsxs(q,{variant:"ghost",size:"sm",onClick:()=>O(E.content,_),children:[e.jsx("span",{className:"material-symbols-outlined text-[14px] mr-1",children:l===_?"check":"content_copy"}),l===_?"Copied!":"Copy"]})]}),e.jsx("pre",{className:"px-3 py-2 bg-black/5 dark:bg-white/5 rounded font-mono text-xs overflow-x-auto whitespace-pre-wrap break-all max-h-60 overflow-y-auto border border-border",children:E.content})]},_))})})}const Ye=/^[a-zA-Z0-9_.\-]+$/;function Xe({index:d,model:r,isFirst:L,isLast:Y,onEdit:g,onMoveUp:l,onMoveDown:A,onRemove:O}){const[E,_]=t.useState(!1),[B,U]=t.useState(r),o=()=>{const i=B.trim();i&&i!==r?g(i):U(r),_(!1)},s=i=>{i.key==="Enter"&&o(),i.key==="Escape"&&(U(r),_(!1))};return e.jsxs("div",{className:"group flex min-w-0 items-center gap-1.5 rounded-md bg-black/[0.02] px-2 py-1 transition-colors hover:bg-black/[0.04] dark:bg-white/[0.02] dark:hover:bg-white/[0.04]",children:[e.jsx("span",{className:"text-[10px] font-medium text-text-muted w-3 text-center shrink-0",children:d+1}),E?e.jsx("input",{autoFocus:!0,value:B,onChange:i=>U(i.target.value),onBlur:o,onKeyDown:s,className:"min-w-0 flex-1 rounded border border-primary/40 bg-white px-1.5 py-0.5 font-mono text-xs text-text-main outline-none dark:bg-black/20"}):e.jsx("div",{className:"min-w-0 flex-1 cursor-text truncate rounded px-1.5 py-0.5 font-mono text-xs text-text-main hover:bg-black/5 dark:hover:bg-white/5",onClick:()=>_(!0),title:"Click to edit",children:r}),e.jsxs("div",{className:"flex shrink-0 items-center gap-0.5",children:[e.jsx("button",{onClick:l,disabled:L,className:`p-0.5 rounded ${L?"text-text-muted/20 cursor-not-allowed":"text-text-muted hover:text-primary hover:bg-black/5 dark:hover:bg-white/5"}`,title:"Move up",children:e.jsx("span",{className:"material-symbols-outlined text-[12px]",children:"arrow_upward"})}),e.jsx("button",{onClick:A,disabled:Y,className:`p-0.5 rounded ${Y?"text-text-muted/20 cursor-not-allowed":"text-text-muted hover:text-primary hover:bg-black/5 dark:hover:bg-white/5"}`,title:"Move down",children:e.jsx("span",{className:"material-symbols-outlined text-[12px]",children:"arrow_downward"})})]}),e.jsx("button",{onClick:O,className:"p-0.5 hover:bg-red-500/10 rounded text-text-muted hover:text-red-500 transition-all",title:"Remove",children:e.jsx("span",{className:"material-symbols-outlined text-[12px]",children:"close"})})]})}function Qe({isOpen:d,combo:r,onClose:L,onSave:Y,activeProviders:g,kindFilter:l=null,forcePrefix:A="",title:O}){const E=r!=null&&r.name?A&&r.name.startsWith(A)?r.name.slice(A.length):r.name:"",[_,B]=t.useState(E),[U,o]=t.useState((r==null?void 0:r.models)||[]),[s,i]=t.useState(!1),[M,Q]=t.useState(!1),[P,K]=t.useState(""),[ee,W]=t.useState({});t.useEffect(()=>{d&&fetch("/api/models/alias").then(m=>m.ok?m.json():null).then(m=>m&&W(m.aliases||{})).catch(()=>{})},[d]);const b=m=>{if(!m.trim())return K("Name is required"),!1;const h=A+m;return Ye.test(h)?(K(""),!0):(K("Only letters, numbers, -, _ and . allowed"),!1)},y=m=>{let h=m.target.value;A&&h.startsWith(A)&&(h=h.slice(A.length)),B(h),h?b(h):K("")},w=m=>{U.includes(m.value)||o([...U,m.value])},x=m=>{o(U.filter(h=>h!==m.value))},C=m=>o(U.filter((h,v)=>v!==m)),j=m=>{if(m===0)return;const h=[...U];[h[m-1],h[m]]=[h[m],h[m-1]],o(h)},T=m=>{if(m===U.length-1)return;const h=[...U];[h[m],h[m+1]]=[h[m+1],h[m]],o(h)},p=async()=>{b(_)&&(Q(!0),await Y({name:A+_.trim(),models:U}),Q(!1))},a=!!r;return e.jsxs(e.Fragment,{children:[e.jsx(Ue,{isOpen:d,onClose:L,title:O||(a?"Edit Combo":"Create Combo"),children:e.jsxs("div",{className:"flex flex-col gap-3",children:[e.jsxs("div",{children:[A?e.jsxs(e.Fragment,{children:[e.jsx("label",{className:"text-sm font-medium mb-1 block",children:"Combo Name"}),e.jsxs("div",{className:"flex items-stretch",children:[e.jsx("span",{className:"inline-flex items-center px-2 rounded-l border border-r-0 border-black/10 dark:border-white/10 bg-black/[0.04] dark:bg-white/[0.04] text-text-muted font-mono text-sm",children:A}),e.jsx("input",{value:_,onChange:y,placeholder:"my-combo",className:"flex-1 min-w-0 rounded-r border border-black/10 dark:border-white/10 bg-white dark:bg-black/20 px-2 py-1.5 font-mono text-sm outline-none focus:border-primary"})]}),P&&e.jsx("p",{className:"text-[11px] text-red-500 mt-0.5",children:P})]}):e.jsx(Ge,{label:"Combo Name",value:_,onChange:y,placeholder:"my-combo",error:P}),e.jsxs("p",{className:"text-[10px] text-text-muted mt-0.5",children:[A?`Auto-prefixed with "${A}". `:"","Only letters, numbers, -, _ and . allowed"]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium mb-1.5 block",children:"Models"}),U.length===0?e.jsxs("div",{className:"text-center py-4 border border-dashed border-black/10 dark:border-white/10 rounded-lg bg-black/[0.01] dark:bg-white/[0.01]",children:[e.jsx("span",{className:"material-symbols-outlined text-text-muted text-xl mb-1",children:"layers"}),e.jsx("p",{className:"text-xs text-text-muted",children:"No models added yet"})]}):e.jsx("div",{className:"flex max-h-[55vh] min-w-0 flex-col gap-1 overflow-y-auto sm:max-h-[350px]",children:U.map((m,h)=>e.jsx(Xe,{index:h,model:m,isFirst:h===0,isLast:h===U.length-1,onEdit:v=>{const I=[...U];I[h]=v,o(I)},onMoveUp:()=>j(h),onMoveDown:()=>T(h),onRemove:()=>C(h)},h))}),e.jsxs("button",{onClick:()=>i(!0),className:"w-full mt-2 py-2 border border-dashed border-black/10 dark:border-white/10 rounded-lg text-xs text-primary font-medium hover:text-primary hover:border-primary/50 transition-colors flex items-center justify-center gap-1",children:[e.jsx("span",{className:"material-symbols-outlined text-[16px]",children:"add"}),"Add Model"]})]}),e.jsxs("div",{className:"flex flex-col gap-2 pt-1 sm:flex-row",children:[e.jsx(q,{onClick:L,variant:"ghost",fullWidth:!0,size:"sm",children:"Cancel"}),e.jsx(q,{onClick:p,fullWidth:!0,size:"sm",disabled:!_.trim()||!!P||M,children:M?"Saving...":a?"Save":"Create"})]})]})}),e.jsx(fe,{isOpen:s,onClose:()=>i(!1),onSelect:w,onDeselect:x,activeProviders:g,modelAliases:ee,title:"Add Model to Combo",kindFilter:l,addedModelValues:U,closeOnSelect:!1})]})}const Ze="/api/cli-tools/cowork-mcp-registry",Ke="/api/cli-tools/cowork-mcp-tools";function et({isOpen:d,onClose:r,onAdd:L,addedNames:Y=[]}){const[g,l]=t.useState([]),[A,O]=t.useState(!1),[E,_]=t.useState(""),[B,U]=t.useState("all"),[o,s]=t.useState(null),[i,M]=t.useState(null),[Q,P]=t.useState({}),[K,ee]=t.useState({}),[W,b]=t.useState({});t.useEffect(()=>{d&&(g.length>0||(O(!0),fetch(Ze).then(a=>a.json()).then(a=>{a.error?s(a.error):l(a.servers||[])}).catch(a=>s(a.message)).finally(()=>O(!1))))},[d]);const y=t.useMemo(()=>new Set(Y),[Y]),w=t.useMemo(()=>{const a=E.trim().toLowerCase();return g.filter(m=>B==="authless"&&m.oauth||B==="oauth"&&!m.oauth?!1:a?(m.title||"").toLowerCase().includes(a)||(m.description||"").toLowerCase().includes(a)||(m.name||"").toLowerCase().includes(a):!0)},[g,E,B]),x=async a=>{if(!Q[a.url]){ee(m=>({...m,[a.url]:!0}));try{const h=await(await fetch(Ke,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({url:a.url})})).json(),v=h.tools||[],I=Array.isArray(a.toolNames)?a.toolNames:[],G=v.length>0?v.map(V=>V.name):I;P(V=>({...V,[a.url]:{tools:v,requiresAuth:!!h.requiresAuth,error:h.error}})),b(V=>({...V,[a.url]:Object.fromEntries(G.map(ae=>[ae,!0]))}))}catch(m){P(h=>({...h,[a.url]:{tools:[],error:m.message}}))}finally{ee(m=>({...m,[a.url]:!1}))}}},C=a=>{if(i===a.url){M(null);return}M(a.url),x(a)},j=(a,m)=>{b(h=>{var v;return{...h,[a]:{...h[a],[m]:!((v=h[a])!=null&&v[m])}}})},T=(a,m)=>{const h=W[a]||{};b(v=>({...v,[a]:Object.fromEntries(Object.keys(h).map(I=>[I,m]))}))},p=a=>{const m=W[a.url]||{},h=Object.keys(m).filter(v=>m[v]);L==null||L({name:a.slug||a.name,title:a.title,description:a.description,url:a.url,transport:a.transport,oauth:a.oauth,toolNames:h}),M(null)};return e.jsx(Ue,{isOpen:d,onClose:r,title:"Browse MCP Marketplace",size:"lg",children:e.jsxs("div",{className:"flex flex-col gap-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"text",value:E,onChange:a=>_(a.target.value),placeholder:"Search by name or description...",className:"flex-1 px-2 py-1.5 bg-surface rounded text-xs border border-border focus:outline-none focus:ring-1 focus:ring-primary/50"}),e.jsxs("select",{value:B,onChange:a=>U(a.target.value),className:"px-2 py-1.5 bg-surface rounded text-xs border border-border focus:outline-none focus:ring-1 focus:ring-primary/50",children:[e.jsx("option",{value:"all",children:"All"}),e.jsx("option",{value:"authless",children:"Authless"}),e.jsx("option",{value:"oauth",children:"OAuth"})]})]}),o&&e.jsx("div",{className:"px-2 py-1.5 rounded text-xs bg-red-500/10 text-red-600",children:o}),A&&e.jsxs("div",{className:"flex items-center gap-2 text-text-muted text-xs py-4 justify-center",children:[e.jsx("span",{className:"material-symbols-outlined animate-spin text-[18px]",children:"progress_activity"}),e.jsx("span",{children:"Loading registry..."})]}),!A&&e.jsxs("div",{className:"flex flex-col gap-1 max-h-[60vh] overflow-y-auto",children:[w.length===0&&e.jsx("div",{className:"text-center text-xs text-text-muted py-6",children:"No servers match filter"}),w.map(a=>{const m=y.has(a.slug||a.name),h=i===a.url,v=Q[a.url],I=K[a.url],G=W[a.url]||{},V=Object.keys(G),ae=Object.values(G).filter(Boolean).length;return e.jsxs("div",{className:"rounded border border-transparent hover:border-border",children:[e.jsxs("div",{className:"flex items-start gap-2 px-2 py-2 hover:bg-black/5 dark:hover:bg-white/5",children:[a.iconUrl?e.jsx("img",{src:a.iconUrl,alt:"",className:"size-7 rounded shrink-0 object-contain",onError:F=>{F.target.style.display="none"}}):e.jsx("div",{className:"size-7 rounded bg-surface shrink-0"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-1.5 flex-wrap",children:[e.jsx("span",{className:"font-medium text-xs",children:a.title}),a.oauth?e.jsx("span",{className:"px-1 py-0.5 text-[9px] rounded bg-amber-500/10 text-amber-600",children:"OAuth"}):e.jsx("span",{className:"px-1 py-0.5 text-[9px] rounded bg-green-500/10 text-green-600",children:"Authless"}),a.toolCount>0&&e.jsxs("span",{className:"text-[10px] text-text-muted",children:[a.toolCount," tools"]})]}),a.description&&e.jsx("p",{className:"text-[10px] text-text-muted line-clamp-2 mt-0.5",children:a.description})]}),e.jsx("button",{onClick:()=>m?null:C(a),disabled:m,className:`shrink-0 px-2 py-1 rounded text-[10px] font-medium transition-colors ${m?"bg-green-500/10 text-green-600 cursor-default":h?"bg-surface border border-border text-text-muted hover:bg-black/5":"bg-primary/10 border border-primary/40 text-primary hover:bg-primary/20"}`,children:m?"Added":h?"Cancel":"+ Add"})]}),h&&e.jsxs("div",{className:"px-3 py-2 bg-surface/40 border-t border-border flex flex-col gap-2",children:[I&&e.jsxs("div",{className:"flex items-center gap-2 text-text-muted text-[10px] py-1",children:[e.jsx("span",{className:"material-symbols-outlined animate-spin text-[14px]",children:"progress_activity"}),e.jsx("span",{children:"Probing server for tools..."})]}),!I&&(v==null?void 0:v.requiresAuth)&&e.jsx("p",{className:"text-[10px] text-amber-600 bg-amber-500/10 px-2 py-1 rounded",children:"🔐 OAuth required. Add now and authenticate after Apply; tool list will be discovered after first connect."}),!I&&(v==null?void 0:v.error)&&!(v!=null&&v.requiresAuth)&&e.jsxs("p",{className:"text-[10px] text-red-600 bg-red-500/10 px-2 py-1 rounded",children:["Probe failed: ",v.error]}),!I&&V.length===0&&!(v!=null&&v.requiresAuth)&&!(v!=null&&v.error)&&e.jsx("p",{className:"text-[10px] text-text-muted",children:"No tools advertised by server."}),!I&&V.length>0&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("span",{className:"text-[10px] text-text-muted",children:[ae,"/",V.length," tools enabled"]}),e.jsxs("div",{className:"flex gap-1",children:[e.jsx("button",{onClick:()=>T(a.url,!0),className:"text-[10px] text-primary hover:underline",children:"All"}),e.jsx("span",{className:"text-[10px] text-text-muted",children:"·"}),e.jsx("button",{onClick:()=>T(a.url,!1),className:"text-[10px] text-primary hover:underline",children:"None"})]})]}),e.jsx("div",{className:"grid grid-cols-2 gap-1 max-h-40 overflow-y-auto",children:V.map(F=>e.jsxs("label",{className:"flex items-center gap-1.5 text-[10px] cursor-pointer hover:bg-black/5 dark:hover:bg-white/5 px-1 rounded",children:[e.jsx("input",{type:"checkbox",checked:!!G[F],onChange:()=>j(a.url,F),className:"size-3"}),e.jsx("span",{className:"truncate",children:F})]},F))})]}),e.jsx("button",{onClick:()=>p(a),className:"self-end px-2 py-1 rounded text-[10px] font-medium bg-primary text-white hover:bg-primary/90",children:"✓ Confirm Add"})]})]},a.url)})]}),e.jsxs("div",{className:"text-[10px] text-text-muted text-right",children:[w.length," of ",g.length," servers"]})]})})}const Fe="fsrouter.cliToolEndpointPresets",ve="__custom__",Re="__save__",tt=d=>{const r=(d||"").replace(/\/+$/,"");return r?/\/v1$/.test(r)?r:`${r}/v1`:""},st=()=>{if(typeof window>"u")return[];try{const d=JSON.parse(window.localStorage.getItem(Fe)||"[]");return Array.isArray(d)?d.filter(r=>(r==null?void 0:r.name)&&(r==null?void 0:r.baseUrl)):[]}catch{return[]}},Ie=d=>{typeof window>"u"||window.localStorage.setItem(Fe,JSON.stringify(d))},lt=({requiresExternalUrl:d,tunnelEnabled:r,tunnelPublicUrl:L,tailscaleEnabled:Y,tailscaleUrl:g,cloudEnabled:l,cloudUrl:A,savedPresets:O,withV1:E})=>{const _=[],B=U=>E?tt(U):(U||"").replace(/\/+$/,"");if(!d){const U=B(`http://127.0.0.1:${De()}`);_.push({value:"local",label:U,url:U})}if(r&&L){const U=B(L);_.push({value:"tunnel",label:U,url:U})}if(Y&&g){const U=B(g);_.push({value:"tailscale",label:U,url:U})}if(l&&A){const U=B(A);_.push({value:"cloud",label:U,url:U})}return O.forEach(U=>{_.push({value:`saved:${U.name}`,label:U.baseUrl,url:U.baseUrl,saved:!0})}),_.push({value:ve,label:"Custom URL...",url:""}),_};function je({value:d,onChange:r,requiresExternalUrl:L=!1,tunnelEnabled:Y=!1,tunnelPublicUrl:g="",tailscaleEnabled:l=!1,tailscaleUrl:A="",cloudEnabled:O=!1,cloudUrl:E="",withV1:_=!0}){const[B,U]=t.useState([]),[o,s]=t.useState(""),[i,M]=t.useState(""),Q=t.useRef(!1);t.useEffect(()=>{U(st())},[]);const P=t.useMemo(()=>lt({requiresExternalUrl:L,tunnelEnabled:Y,tunnelPublicUrl:g,tailscaleEnabled:l,tailscaleUrl:A,cloudEnabled:O,cloudUrl:E,savedPresets:B,withV1:_}),[L,Y,g,l,A,O,E,B,_]);t.useEffect(()=>{if(Q.current||P.length===0)return;Q.current=!0;const x=P.find(C=>C.value!==ve);x?(s(x.value),r(x.url)):s(ve)},[P,r]);const K=x=>{const C=x.target.value;if(C===Re){const T=(d||"").trim();if(!T)return;let p=T;try{p=new URL(T).host}catch{}const a=window.prompt("Save endpoint as:",p);if(!(a!=null&&a.trim()))return;const m=[...B.filter(h=>h.name!==a.trim()),{name:a.trim(),baseUrl:T}].sort((h,v)=>h.name.localeCompare(v.name));U(m),Ie(m);return}if(s(C),C===ve){M(""),r("");return}const j=P.find(T=>T.value===C);j&&r(j.url)},ee=x=>{const C=x.target.value;M(C),r(C)},W=()=>{if(!o.startsWith("saved:"))return;const x=o.slice(6),C=B.filter(j=>j.name!==x);U(C),Ie(C),s(ve),M(""),r("")},b=o.startsWith("saved:"),y=o===ve,w=y&&(i||"").trim().length>0;return e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("select",{value:o,onChange:K,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:[P.map(x=>e.jsx("option",{value:x.value,children:x.label},x.value)),w&&e.jsx("option",{value:Re,children:"+ Save current as..."})]}),b&&e.jsx("button",{type:"button",onClick:W,className:"p-1 text-text-muted hover:text-red-500 rounded transition-colors shrink-0",title:"Delete saved endpoint",children:e.jsx("span",{className:"material-symbols-outlined text-[14px]",children:"delete"})})]}),y&&e.jsx("input",{type:"text",value:i,onChange:ee,placeholder:_?"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"})]})}const we="__custom__";function be({value:d,onChange:r,apiKeys:L=[],cloudEnabled:Y=!1,className:g=""}){const l=!L.some(s=>s.key===d)&&d!=="",[A,O]=t.useState(()=>d?L.some(s=>s.key===d)?d:we:L.length>0?L[0].key:we),[E,_]=t.useState(l?d:""),B=s=>{const i=s.target.value;O(i),i===we?(_(""),r("")):r(i)},U=s=>{const i=s.target.value;_(i),r(i)};return L.length===0&&A!==we&&A!==we?e.jsx("span",{className:`min-w-0 rounded bg-surface/40 px-2 py-2 text-xs text-text-muted sm:py-1.5 ${g}`,children:Y?"No API keys - Create one in Keys page":"sk_fsrouter (default)"}):e.jsxs("div",{className:`flex flex-col gap-1.5 ${g}`,children:[e.jsxs("select",{value:A,onChange:B,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:[L.map(s=>e.jsx("option",{value:s.key,children:s.key},s.id)),e.jsx("option",{value:we,children:"Custom..."})]}),A===we&&e.jsx("input",{type:"text",value:E,onChange:U,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"})]})}const Se=d=>(d||"").replace(/\/+$/,"");function Ne(d,r={}){if(!d)return!1;const L=Se(d),{tunnelPublicUrl:Y,tailscaleUrl:g,cloudUrl:l}=r;return!!(/localhost|127\.0\.0\.1|0\.0\.0\.0/.test(L)||Y&&L.startsWith(Se(Y))||g&&L.startsWith(Se(g))||l&&L.startsWith(Se(l)))}var rt={};const at=rt.NEXT_PUBLIC_CLOUD_URL;function nt({tool:d,isExpanded:r,onToggle:L,activeProviders:Y,modelMappings:g,onModelMappingChange:l,baseUrl:A,hasActiveProviders:O,apiKeys:E,cloudEnabled:_,initialStatus:B,tunnelEnabled:U,tunnelPublicUrl:o,tailscaleEnabled:s,tailscaleUrl:i}){var pe,R;const[M,Q]=t.useState(B||null),[P,K]=t.useState(!1),[ee,W]=t.useState(!1),[b,y]=t.useState(!1),[w,x]=t.useState(null),[C,j]=t.useState(!1),[T,p]=t.useState(!1),[a,m]=t.useState(null),[h,v]=t.useState(""),[I,G]=t.useState({}),[V,ae]=t.useState(!1),[F,oe]=t.useState(""),[ie,te]=t.useState(!1),se=t.useRef(!1),ne=(()=>{var z,le;if(!(M!=null&&M.installed))return null;const n=(le=(z=M.settings)==null?void 0:z.env)==null?void 0:le.ANTHROPIC_BASE_URL;return n?Ne(n,{tunnelPublicUrl:o,tailscaleUrl:i,cloudUrl:_?at:null})?"configured":"other":"not_configured"})();t.useEffect(()=>{(E==null?void 0:E.length)>0&&!h&&v(E[0].key)},[E,h]),t.useEffect(()=>{B&&Q(B)},[B]),t.useEffect(()=>{r&&!M&&(f(),H()),r&&H()},[r]),t.useEffect(()=>{fetch("/api/settings").then(n=>n.json()).then(n=>{te(!!n.ccFilterNaming)}).catch(()=>{})},[]);const ue=async n=>{const z=n.target.checked;te(z),await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({ccFilterNaming:z})}).catch(()=>{})},H=async()=>{try{const n=await fetch("/api/models/alias"),z=await n.json();n.ok&&G(z.aliases||{})}catch(n){console.log("Error fetching model aliases:",n)}};t.useEffect(()=>{var n;if(M!=null&&M.installed&&!se.current){se.current=!0;const z=((n=M.settings)==null?void 0:n.env)||{};d.defaultModels.forEach(k=>{if(k.envKey){const J=z[k.envKey]||k.defaultValue||"";J&&l(k.alias,J)}});const le=z.ANTHROPIC_AUTH_TOKEN;le&&(E!=null&&E.some(k=>k.key===le))&&v(le)}},[M,E,d.defaultModels,l]);const f=async()=>{K(!0);try{const z=await(await fetch("/api/cli-tools/claude-settings")).json();Q(z)}catch(n){Q({installed:!1,error:n.message})}finally{K(!1)}},$=()=>{const n=F||A;return n.endsWith("/v1")?n:`${n}/v1`},X=()=>{const n=F||A;return n.endsWith("/v1")?n:`${n}/v1`},u=async()=>{W(!0),x(null);try{const n={ANTHROPIC_BASE_URL:$()},z=(h==null?void 0:h.trim())||((E==null?void 0:E.length)>0?E[0].key:null)||(_?null:"sk_fsrouter");z&&(n.ANTHROPIC_AUTH_TOKEN=z),d.defaultModels.forEach(J=>{const de=g[J.alias];de&&J.envKey&&(n[J.envKey]=de)});const le=await fetch("/api/cli-tools/claude-settings",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({env:n})}),k=await le.json();le.ok?(x({type:"success",text:"Settings applied successfully!"}),Q(J=>({...J,hasBackup:!0,settings:{...J==null?void 0:J.settings,env:n}}))):x({type:"error",text:k.error||"Failed to apply settings"})}catch(n){x({type:"error",text:n.message})}finally{W(!1)}},N=async()=>{y(!0),x(null);try{const n=await fetch("/api/cli-tools/claude-settings",{method:"DELETE"}),z=await n.json();n.ok?(x({type:"success",text:"Settings reset successfully!"}),d.defaultModels.forEach(le=>l(le.alias,le.defaultValue||"")),v("")):x({type:"error",text:z.error||"Failed to reset settings"})}catch(n){x({type:"error",text:n.message})}finally{y(!1)}},S=n=>{m(n),p(!0)},ce=n=>{a&&l(a,n.value)},xe=()=>{const n=h&&h.trim()?h:_?"<API_KEY_FROM_DASHBOARD>":"sk_fsrouter",z={ANTHROPIC_BASE_URL:$(),ANTHROPIC_AUTH_TOKEN:n};return d.defaultModels.forEach(le=>{const k=g[le.alias];k&&le.envKey&&(z[le.envKey]=k)}),[{filename:"~/.claude/settings.json",content:JSON.stringify({hasCompletedOnboarding:!0,env:z},null,2)}]};return e.jsxs(ge,{padding:"xs",className:"overflow-hidden",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3 hover:cursor-pointer sm:items-center",onClick:L,children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-3",children:[e.jsx("div",{className:"size-8 flex items-center justify-center shrink-0",children:e.jsx("img",{src:"/providers/claude.png",alt:d.name,width:32,height:32,className:"size-8 object-contain rounded-lg",sizes:"32px",onError:n=>{n.target.style.display="none"}})}),e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-2",children:[e.jsx("h3",{className:"font-medium text-sm",children:d.name}),ne==="configured"&&e.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"}),ne==="not_configured"&&e.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"}),ne==="other"&&e.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"})]}),e.jsx("p",{className:"text-xs text-text-muted truncate",children:d.description})]})]}),e.jsx("span",{className:`material-symbols-outlined text-text-muted text-[20px] transition-transform ${r?"rotate-180":""}`,children:"expand_more"})]}),r&&e.jsxs("div",{className:"mt-4 pt-4 border-t border-border flex flex-col gap-4",children:[P&&e.jsxs("div",{className:"flex items-center gap-2 text-text-muted",children:[e.jsx("span",{className:"material-symbols-outlined animate-spin",children:"progress_activity"}),e.jsx("span",{children:"Checking Claude CLI..."})]}),!P&&M&&!M.installed&&e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsxs("div",{className:"flex flex-col gap-3 p-4 bg-yellow-500/10 border border-yellow-500/30 rounded-lg",children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("span",{className:"material-symbols-outlined text-yellow-500",children:"warning"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"font-medium text-yellow-600 dark:text-yellow-400",children:"Claude CLI not detected locally"}),e.jsx("p",{className:"text-sm text-text-muted",children:"Manual configuration is still available if fsrouter is deployed on a remote server."})]})]}),e.jsxs("div",{className:"flex items-center gap-2 pl-9",children:[e.jsxs(q,{variant:"secondary",size:"sm",onClick:()=>ae(!0),className:"!bg-yellow-500/20 !border-yellow-500/40 !text-yellow-700 dark:!text-yellow-300 hover:!bg-yellow-500/30",children:[e.jsx("span",{className:"material-symbols-outlined text-[18px] mr-1",children:"content_copy"}),"Manual Config"]}),e.jsxs(q,{variant:"outline",size:"sm",onClick:()=>j(!C),children:[e.jsx("span",{className:"material-symbols-outlined text-[18px] mr-1",children:C?"expand_less":"help"}),C?"Hide":"How to Install"]})]})]}),C&&e.jsxs("div",{className:"p-4 bg-surface border border-border rounded-lg",children:[e.jsx("h4",{className:"font-medium mb-3",children:"Installation Guide"}),e.jsxs("div",{className:"space-y-3 text-sm",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-text-muted mb-1",children:"macOS / Linux / Windows:"}),e.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"})]}),e.jsxs("p",{className:"text-text-muted",children:["After installation, run ",e.jsx("code",{className:"px-1 bg-black/5 dark:bg-white/5 rounded",children:"claude"})," to verify."]})]})]})]}),!P&&(M==null?void 0:M.installed)&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsxs("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr] sm:items-center sm:gap-2",children:[e.jsx("span",{className:"text-xs font-semibold text-text-main sm:text-right sm:text-sm",children:"Select Endpoint"}),e.jsx("span",{className:"material-symbols-outlined hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),e.jsx(je,{value:F||X(),onChange:oe,requiresExternalUrl:d.requiresExternalUrl,tunnelEnabled:U,tunnelPublicUrl:o,tailscaleEnabled:s,tailscaleUrl:i})]}),((R=(pe=M==null?void 0:M.settings)==null?void 0:pe.env)==null?void 0:R.ANTHROPIC_BASE_URL)&&e.jsxs("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr_auto] sm:items-center sm:gap-2",children:[e.jsx("span",{className:"text-xs font-semibold text-text-main sm:text-right sm:text-sm",children:"Current"}),e.jsx("span",{className:"material-symbols-outlined hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),e.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:M.settings.env.ANTHROPIC_BASE_URL})]}),e.jsxs("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr_auto] sm:items-center sm:gap-2",children:[e.jsx("span",{className:"text-xs font-semibold text-text-main sm:text-right sm:text-sm",children:"API Key"}),e.jsx("span",{className:"material-symbols-outlined hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),e.jsx(be,{value:h,onChange:v,apiKeys:E,cloudEnabled:_})]}),d.defaultModels.map(n=>e.jsxs("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr_auto] sm:items-center sm:gap-2",children:[e.jsx("span",{className:"text-xs font-semibold text-text-main sm:text-right sm:text-sm",children:n.name}),e.jsx("span",{className:"material-symbols-outlined hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),e.jsxs("div",{className:"relative w-full min-w-0",children:[e.jsx("input",{type:"text",value:g[n.alias]||"",onChange:z=>l(n.alias,z.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"}),g[n.alias]&&e.jsx("button",{onClick:()=>l(n.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:e.jsx("span",{className:"material-symbols-outlined text-[14px]",children:"close"})})]}),e.jsx("button",{onClick:()=>S(n.alias),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 Model"})]},n.alias)),e.jsxs("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr_auto] sm:items-center sm:gap-2",children:[e.jsx("span",{className:"text-xs font-semibold text-text-main sm:text-right sm:text-sm",children:"Filter naming"}),e.jsx("span",{className:"material-symbols-outlined hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),e.jsxs("label",{className:"flex items-center gap-1.5 cursor-pointer select-none",children:[e.jsx("input",{type:"checkbox",checked:ie,onChange:ue,className:"w-3.5 h-3.5 accent-primary cursor-pointer"}),e.jsx("span",{className:"text-xs text-text-muted",children:"Filter naming requests"})]}),e.jsx(Be,{text:"Intercepts Claude Code's topic-naming requests and returns a fake response locally, saving API tokens.",children:e.jsx("span",{className:"material-symbols-outlined text-text-muted text-[14px] cursor-help",children:"info"})})]})]}),w&&e.jsxs("div",{className:`flex items-center gap-2 px-2 py-1.5 rounded text-xs ${w.type==="success"?"bg-green-500/10 text-green-600":"bg-red-500/10 text-red-600"}`,children:[e.jsx("span",{className:"material-symbols-outlined text-[14px]",children:w.type==="success"?"check_circle":"error"}),e.jsx("span",{children:w.text})]}),e.jsxs("div",{className:"grid grid-cols-1 gap-2 sm:flex sm:items-center",children:[e.jsxs(q,{variant:"primary",size:"sm",onClick:u,disabled:!O,loading:ee,children:[e.jsx("span",{className:"material-symbols-outlined text-[14px] mr-1",children:"save"}),"Apply"]}),e.jsxs(q,{variant:"outline",size:"sm",onClick:N,disabled:!(M!=null&&M.hasFSRouter),loading:b,children:[e.jsx("span",{className:"material-symbols-outlined text-[14px] mr-1",children:"restore"}),"Reset"]}),e.jsxs(q,{variant:"ghost",size:"sm",onClick:()=>ae(!0),children:[e.jsx("span",{className:"material-symbols-outlined text-[14px] mr-1",children:"content_copy"}),"Manual Config"]})]})]})]}),e.jsx(fe,{isOpen:T,onClose:()=>p(!1),onSelect:ce,selectedModel:a?g[a]:null,activeProviders:Y,modelAliases:I,title:`Select model for ${a}`}),e.jsx(ye,{isOpen:V,onClose:()=>ae(!1),title:"Claude CLI - Manual Configuration",configs:xe()})]})}function ot({tool:d,isExpanded:r,onToggle:L,baseUrl:Y,apiKeys:g,activeProviders:l,cloudEnabled:A,initialStatus:O,tunnelEnabled:E,tunnelPublicUrl:_,tailscaleEnabled:B,tailscaleUrl:U}){const[o,s]=t.useState(O||null),[i,M]=t.useState(!1),[Q,P]=t.useState(!1),[K,ee]=t.useState(!1),[W,b]=t.useState(null),[y,w]=t.useState(!1),[x,C]=t.useState(""),[j,T]=t.useState(""),[p,a]=t.useState(""),[m,h]=t.useState(!1),[v,I]=t.useState(!1),[G,V]=t.useState({}),[ae,F]=t.useState(!1),[oe,ie]=t.useState("");t.useEffect(()=>{(g==null?void 0:g.length)>0&&!x&&C(g[0].key)},[g,x]),t.useEffect(()=>{O&&s(O)},[O]),t.useEffect(()=>{r&&!o&&(H(),te()),r&&te()},[r]);const te=async()=>{try{const N=await fetch("/api/models/alias"),S=await N.json();N.ok&&V(S.aliases||{})}catch(N){console.log("Error fetching model aliases:",N)}};t.useEffect(()=>{if(o!=null&&o.config){const N=o.config.match(/^model\s*=\s*"([^"]+)"/m);N&&T(N[1]);const S=o.config.match(/\[agents\.subagent\]\s*\n\s*model\s*=\s*"([^"]+)"/m);S&&a(S[1])}},[o]);const Z=(()=>{if(!(o!=null&&o.installed))return null;if(!o.config)return"not_configured";const N=o.config.match(/base_url\s*=\s*"([^"]+)"/),S=N?N[1]:"";return Ne(S,{tunnelPublicUrl:_,tailscaleUrl:U})?"configured":"other"})(),ne=()=>{const N=oe||`${Y}/v1`;return N.endsWith("/v1")?N:`${N}/v1`},ue=()=>oe||`${Y}/v1`,H=async()=>{M(!0);try{const S=await(await fetch("/api/cli-tools/codex-settings")).json();s(S)}catch(N){s({installed:!1,error:N.message})}finally{M(!1)}},f=async()=>{P(!0),b(null);try{const N=x&&x.trim()||A?x:"sk_fsrouter",S=await fetch("/api/cli-tools/codex-settings",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({baseUrl:ne(),apiKey:N,model:j,subagentModel:p||j})}),ce=await S.json();S.ok?(b({type:"success",text:"Settings applied successfully!"}),H()):b({type:"error",text:ce.error||"Failed to apply settings"})}catch(N){b({type:"error",text:N.message})}finally{P(!1)}},$=async()=>{ee(!0),b(null);try{const N=await fetch("/api/cli-tools/codex-settings",{method:"DELETE"}),S=await N.json();N.ok?(b({type:"success",text:"Settings reset successfully!"}),T(""),a(""),H()):b({type:"error",text:S.error||"Failed to reset settings"})}catch(N){b({type:"error",text:N.message})}finally{ee(!1)}},X=N=>{T(N.value),p||a(N.value),h(!1)},u=()=>{const N=x&&x.trim()?x:A?"<API_KEY_FROM_DASHBOARD>":"sk_fsrouter",S=p||j,ce=`# FSRouter Configuration for Codex CLI
1
+ import{u as ze,j as e,M as Ue,B as q,w as De,x as Be,y as ke,z as He,h as We}from"./index.Be3gbrBl.js";import{b as t,L as Te,h as Je,N as qe}from"./router.Cjj1--8t.js";import{C as Le}from"./cliTools.CsdwAybi.js";import{g as Pe}from"./machine.CagOtseJ.js";import{I as Ge,M as fe,C as ge}from"./NoAuthProxyCard.BDcXaWvM.js";import{C as Ve}from"./Loading.BHPtQ9vj.js";import"./zustand.akaTi5uX.js";function ye({isOpen:d,onClose:r,title:L="Manual Configuration",configs:Y=[]}){const{copy:g}=ze(),[l,A]=t.useState(null),O=(E,_)=>{g(E,`manualconfig-${_}`),A(_),setTimeout(()=>A(null),2e3)};return e.jsx(Ue,{isOpen:d,onClose:r,title:L,size:"xl",children:e.jsx("div",{className:"flex flex-col gap-4",children:Y.map((E,_)=>e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-sm font-medium text-text-main",children:E.filename}),e.jsxs(q,{variant:"ghost",size:"sm",onClick:()=>O(E.content,_),children:[e.jsx("span",{className:"material-symbols-outlined text-[14px] mr-1",children:l===_?"check":"content_copy"}),l===_?"Copied!":"Copy"]})]}),e.jsx("pre",{className:"px-3 py-2 bg-black/5 dark:bg-white/5 rounded font-mono text-xs overflow-x-auto whitespace-pre-wrap break-all max-h-60 overflow-y-auto border border-border",children:E.content})]},_))})})}const Ye=/^[a-zA-Z0-9_.\-]+$/;function Xe({index:d,model:r,isFirst:L,isLast:Y,onEdit:g,onMoveUp:l,onMoveDown:A,onRemove:O}){const[E,_]=t.useState(!1),[B,U]=t.useState(r),o=()=>{const i=B.trim();i&&i!==r?g(i):U(r),_(!1)},s=i=>{i.key==="Enter"&&o(),i.key==="Escape"&&(U(r),_(!1))};return e.jsxs("div",{className:"group flex min-w-0 items-center gap-1.5 rounded-md bg-black/[0.02] px-2 py-1 transition-colors hover:bg-black/[0.04] dark:bg-white/[0.02] dark:hover:bg-white/[0.04]",children:[e.jsx("span",{className:"text-[10px] font-medium text-text-muted w-3 text-center shrink-0",children:d+1}),E?e.jsx("input",{autoFocus:!0,value:B,onChange:i=>U(i.target.value),onBlur:o,onKeyDown:s,className:"min-w-0 flex-1 rounded border border-primary/40 bg-white px-1.5 py-0.5 font-mono text-xs text-text-main outline-none dark:bg-black/20"}):e.jsx("div",{className:"min-w-0 flex-1 cursor-text truncate rounded px-1.5 py-0.5 font-mono text-xs text-text-main hover:bg-black/5 dark:hover:bg-white/5",onClick:()=>_(!0),title:"Click to edit",children:r}),e.jsxs("div",{className:"flex shrink-0 items-center gap-0.5",children:[e.jsx("button",{onClick:l,disabled:L,className:`p-0.5 rounded ${L?"text-text-muted/20 cursor-not-allowed":"text-text-muted hover:text-primary hover:bg-black/5 dark:hover:bg-white/5"}`,title:"Move up",children:e.jsx("span",{className:"material-symbols-outlined text-[12px]",children:"arrow_upward"})}),e.jsx("button",{onClick:A,disabled:Y,className:`p-0.5 rounded ${Y?"text-text-muted/20 cursor-not-allowed":"text-text-muted hover:text-primary hover:bg-black/5 dark:hover:bg-white/5"}`,title:"Move down",children:e.jsx("span",{className:"material-symbols-outlined text-[12px]",children:"arrow_downward"})})]}),e.jsx("button",{onClick:O,className:"p-0.5 hover:bg-red-500/10 rounded text-text-muted hover:text-red-500 transition-all",title:"Remove",children:e.jsx("span",{className:"material-symbols-outlined text-[12px]",children:"close"})})]})}function Qe({isOpen:d,combo:r,onClose:L,onSave:Y,activeProviders:g,kindFilter:l=null,forcePrefix:A="",title:O}){const E=r!=null&&r.name?A&&r.name.startsWith(A)?r.name.slice(A.length):r.name:"",[_,B]=t.useState(E),[U,o]=t.useState((r==null?void 0:r.models)||[]),[s,i]=t.useState(!1),[M,Q]=t.useState(!1),[P,K]=t.useState(""),[ee,W]=t.useState({});t.useEffect(()=>{d&&fetch("/api/models/alias").then(m=>m.ok?m.json():null).then(m=>m&&W(m.aliases||{})).catch(()=>{})},[d]);const b=m=>{if(!m.trim())return K("Name is required"),!1;const h=A+m;return Ye.test(h)?(K(""),!0):(K("Only letters, numbers, -, _ and . allowed"),!1)},y=m=>{let h=m.target.value;A&&h.startsWith(A)&&(h=h.slice(A.length)),B(h),h?b(h):K("")},w=m=>{U.includes(m.value)||o([...U,m.value])},x=m=>{o(U.filter(h=>h!==m.value))},C=m=>o(U.filter((h,v)=>v!==m)),j=m=>{if(m===0)return;const h=[...U];[h[m-1],h[m]]=[h[m],h[m-1]],o(h)},T=m=>{if(m===U.length-1)return;const h=[...U];[h[m],h[m+1]]=[h[m+1],h[m]],o(h)},p=async()=>{b(_)&&(Q(!0),await Y({name:A+_.trim(),models:U}),Q(!1))},a=!!r;return e.jsxs(e.Fragment,{children:[e.jsx(Ue,{isOpen:d,onClose:L,title:O||(a?"Edit Combo":"Create Combo"),children:e.jsxs("div",{className:"flex flex-col gap-3",children:[e.jsxs("div",{children:[A?e.jsxs(e.Fragment,{children:[e.jsx("label",{className:"text-sm font-medium mb-1 block",children:"Combo Name"}),e.jsxs("div",{className:"flex items-stretch",children:[e.jsx("span",{className:"inline-flex items-center px-2 rounded-l border border-r-0 border-black/10 dark:border-white/10 bg-black/[0.04] dark:bg-white/[0.04] text-text-muted font-mono text-sm",children:A}),e.jsx("input",{value:_,onChange:y,placeholder:"my-combo",className:"flex-1 min-w-0 rounded-r border border-black/10 dark:border-white/10 bg-white dark:bg-black/20 px-2 py-1.5 font-mono text-sm outline-none focus:border-primary"})]}),P&&e.jsx("p",{className:"text-[11px] text-red-500 mt-0.5",children:P})]}):e.jsx(Ge,{label:"Combo Name",value:_,onChange:y,placeholder:"my-combo",error:P}),e.jsxs("p",{className:"text-[10px] text-text-muted mt-0.5",children:[A?`Auto-prefixed with "${A}". `:"","Only letters, numbers, -, _ and . allowed"]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium mb-1.5 block",children:"Models"}),U.length===0?e.jsxs("div",{className:"text-center py-4 border border-dashed border-black/10 dark:border-white/10 rounded-lg bg-black/[0.01] dark:bg-white/[0.01]",children:[e.jsx("span",{className:"material-symbols-outlined text-text-muted text-xl mb-1",children:"layers"}),e.jsx("p",{className:"text-xs text-text-muted",children:"No models added yet"})]}):e.jsx("div",{className:"flex max-h-[55vh] min-w-0 flex-col gap-1 overflow-y-auto sm:max-h-[350px]",children:U.map((m,h)=>e.jsx(Xe,{index:h,model:m,isFirst:h===0,isLast:h===U.length-1,onEdit:v=>{const I=[...U];I[h]=v,o(I)},onMoveUp:()=>j(h),onMoveDown:()=>T(h),onRemove:()=>C(h)},h))}),e.jsxs("button",{onClick:()=>i(!0),className:"w-full mt-2 py-2 border border-dashed border-black/10 dark:border-white/10 rounded-lg text-xs text-primary font-medium hover:text-primary hover:border-primary/50 transition-colors flex items-center justify-center gap-1",children:[e.jsx("span",{className:"material-symbols-outlined text-[16px]",children:"add"}),"Add Model"]})]}),e.jsxs("div",{className:"flex flex-col gap-2 pt-1 sm:flex-row",children:[e.jsx(q,{onClick:L,variant:"ghost",fullWidth:!0,size:"sm",children:"Cancel"}),e.jsx(q,{onClick:p,fullWidth:!0,size:"sm",disabled:!_.trim()||!!P||M,children:M?"Saving...":a?"Save":"Create"})]})]})}),e.jsx(fe,{isOpen:s,onClose:()=>i(!1),onSelect:w,onDeselect:x,activeProviders:g,modelAliases:ee,title:"Add Model to Combo",kindFilter:l,addedModelValues:U,closeOnSelect:!1})]})}const Ze="/api/cli-tools/cowork-mcp-registry",Ke="/api/cli-tools/cowork-mcp-tools";function et({isOpen:d,onClose:r,onAdd:L,addedNames:Y=[]}){const[g,l]=t.useState([]),[A,O]=t.useState(!1),[E,_]=t.useState(""),[B,U]=t.useState("all"),[o,s]=t.useState(null),[i,M]=t.useState(null),[Q,P]=t.useState({}),[K,ee]=t.useState({}),[W,b]=t.useState({});t.useEffect(()=>{d&&(g.length>0||(O(!0),fetch(Ze).then(a=>a.json()).then(a=>{a.error?s(a.error):l(a.servers||[])}).catch(a=>s(a.message)).finally(()=>O(!1))))},[d]);const y=t.useMemo(()=>new Set(Y),[Y]),w=t.useMemo(()=>{const a=E.trim().toLowerCase();return g.filter(m=>B==="authless"&&m.oauth||B==="oauth"&&!m.oauth?!1:a?(m.title||"").toLowerCase().includes(a)||(m.description||"").toLowerCase().includes(a)||(m.name||"").toLowerCase().includes(a):!0)},[g,E,B]),x=async a=>{if(!Q[a.url]){ee(m=>({...m,[a.url]:!0}));try{const h=await(await fetch(Ke,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({url:a.url})})).json(),v=h.tools||[],I=Array.isArray(a.toolNames)?a.toolNames:[],G=v.length>0?v.map(V=>V.name):I;P(V=>({...V,[a.url]:{tools:v,requiresAuth:!!h.requiresAuth,error:h.error}})),b(V=>({...V,[a.url]:Object.fromEntries(G.map(ae=>[ae,!0]))}))}catch(m){P(h=>({...h,[a.url]:{tools:[],error:m.message}}))}finally{ee(m=>({...m,[a.url]:!1}))}}},C=a=>{if(i===a.url){M(null);return}M(a.url),x(a)},j=(a,m)=>{b(h=>{var v;return{...h,[a]:{...h[a],[m]:!((v=h[a])!=null&&v[m])}}})},T=(a,m)=>{const h=W[a]||{};b(v=>({...v,[a]:Object.fromEntries(Object.keys(h).map(I=>[I,m]))}))},p=a=>{const m=W[a.url]||{},h=Object.keys(m).filter(v=>m[v]);L==null||L({name:a.slug||a.name,title:a.title,description:a.description,url:a.url,transport:a.transport,oauth:a.oauth,toolNames:h}),M(null)};return e.jsx(Ue,{isOpen:d,onClose:r,title:"Browse MCP Marketplace",size:"lg",children:e.jsxs("div",{className:"flex flex-col gap-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"text",value:E,onChange:a=>_(a.target.value),placeholder:"Search by name or description...",className:"flex-1 px-2 py-1.5 bg-surface rounded text-xs border border-border focus:outline-none focus:ring-1 focus:ring-primary/50"}),e.jsxs("select",{value:B,onChange:a=>U(a.target.value),className:"px-2 py-1.5 bg-surface rounded text-xs border border-border focus:outline-none focus:ring-1 focus:ring-primary/50",children:[e.jsx("option",{value:"all",children:"All"}),e.jsx("option",{value:"authless",children:"Authless"}),e.jsx("option",{value:"oauth",children:"OAuth"})]})]}),o&&e.jsx("div",{className:"px-2 py-1.5 rounded text-xs bg-red-500/10 text-red-600",children:o}),A&&e.jsxs("div",{className:"flex items-center gap-2 text-text-muted text-xs py-4 justify-center",children:[e.jsx("span",{className:"material-symbols-outlined animate-spin text-[18px]",children:"progress_activity"}),e.jsx("span",{children:"Loading registry..."})]}),!A&&e.jsxs("div",{className:"flex flex-col gap-1 max-h-[60vh] overflow-y-auto",children:[w.length===0&&e.jsx("div",{className:"text-center text-xs text-text-muted py-6",children:"No servers match filter"}),w.map(a=>{const m=y.has(a.slug||a.name),h=i===a.url,v=Q[a.url],I=K[a.url],G=W[a.url]||{},V=Object.keys(G),ae=Object.values(G).filter(Boolean).length;return e.jsxs("div",{className:"rounded border border-transparent hover:border-border",children:[e.jsxs("div",{className:"flex items-start gap-2 px-2 py-2 hover:bg-black/5 dark:hover:bg-white/5",children:[a.iconUrl?e.jsx("img",{src:a.iconUrl,alt:"",className:"size-7 rounded shrink-0 object-contain",onError:F=>{F.target.style.display="none"}}):e.jsx("div",{className:"size-7 rounded bg-surface shrink-0"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-1.5 flex-wrap",children:[e.jsx("span",{className:"font-medium text-xs",children:a.title}),a.oauth?e.jsx("span",{className:"px-1 py-0.5 text-[9px] rounded bg-amber-500/10 text-amber-600",children:"OAuth"}):e.jsx("span",{className:"px-1 py-0.5 text-[9px] rounded bg-green-500/10 text-green-600",children:"Authless"}),a.toolCount>0&&e.jsxs("span",{className:"text-[10px] text-text-muted",children:[a.toolCount," tools"]})]}),a.description&&e.jsx("p",{className:"text-[10px] text-text-muted line-clamp-2 mt-0.5",children:a.description})]}),e.jsx("button",{onClick:()=>m?null:C(a),disabled:m,className:`shrink-0 px-2 py-1 rounded text-[10px] font-medium transition-colors ${m?"bg-green-500/10 text-green-600 cursor-default":h?"bg-surface border border-border text-text-muted hover:bg-black/5":"bg-primary/10 border border-primary/40 text-primary hover:bg-primary/20"}`,children:m?"Added":h?"Cancel":"+ Add"})]}),h&&e.jsxs("div",{className:"px-3 py-2 bg-surface/40 border-t border-border flex flex-col gap-2",children:[I&&e.jsxs("div",{className:"flex items-center gap-2 text-text-muted text-[10px] py-1",children:[e.jsx("span",{className:"material-symbols-outlined animate-spin text-[14px]",children:"progress_activity"}),e.jsx("span",{children:"Probing server for tools..."})]}),!I&&(v==null?void 0:v.requiresAuth)&&e.jsx("p",{className:"text-[10px] text-amber-600 bg-amber-500/10 px-2 py-1 rounded",children:"🔐 OAuth required. Add now and authenticate after Apply; tool list will be discovered after first connect."}),!I&&(v==null?void 0:v.error)&&!(v!=null&&v.requiresAuth)&&e.jsxs("p",{className:"text-[10px] text-red-600 bg-red-500/10 px-2 py-1 rounded",children:["Probe failed: ",v.error]}),!I&&V.length===0&&!(v!=null&&v.requiresAuth)&&!(v!=null&&v.error)&&e.jsx("p",{className:"text-[10px] text-text-muted",children:"No tools advertised by server."}),!I&&V.length>0&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("span",{className:"text-[10px] text-text-muted",children:[ae,"/",V.length," tools enabled"]}),e.jsxs("div",{className:"flex gap-1",children:[e.jsx("button",{onClick:()=>T(a.url,!0),className:"text-[10px] text-primary hover:underline",children:"All"}),e.jsx("span",{className:"text-[10px] text-text-muted",children:"·"}),e.jsx("button",{onClick:()=>T(a.url,!1),className:"text-[10px] text-primary hover:underline",children:"None"})]})]}),e.jsx("div",{className:"grid grid-cols-2 gap-1 max-h-40 overflow-y-auto",children:V.map(F=>e.jsxs("label",{className:"flex items-center gap-1.5 text-[10px] cursor-pointer hover:bg-black/5 dark:hover:bg-white/5 px-1 rounded",children:[e.jsx("input",{type:"checkbox",checked:!!G[F],onChange:()=>j(a.url,F),className:"size-3"}),e.jsx("span",{className:"truncate",children:F})]},F))})]}),e.jsx("button",{onClick:()=>p(a),className:"self-end px-2 py-1 rounded text-[10px] font-medium bg-primary text-white hover:bg-primary/90",children:"✓ Confirm Add"})]})]},a.url)})]}),e.jsxs("div",{className:"text-[10px] text-text-muted text-right",children:[w.length," of ",g.length," servers"]})]})})}const Fe="fsrouter.cliToolEndpointPresets",ve="__custom__",Re="__save__",tt=d=>{const r=(d||"").replace(/\/+$/,"");return r?/\/v1$/.test(r)?r:`${r}/v1`:""},st=()=>{if(typeof window>"u")return[];try{const d=JSON.parse(window.localStorage.getItem(Fe)||"[]");return Array.isArray(d)?d.filter(r=>(r==null?void 0:r.name)&&(r==null?void 0:r.baseUrl)):[]}catch{return[]}},Ie=d=>{typeof window>"u"||window.localStorage.setItem(Fe,JSON.stringify(d))},lt=({requiresExternalUrl:d,tunnelEnabled:r,tunnelPublicUrl:L,tailscaleEnabled:Y,tailscaleUrl:g,cloudEnabled:l,cloudUrl:A,savedPresets:O,withV1:E})=>{const _=[],B=U=>E?tt(U):(U||"").replace(/\/+$/,"");if(!d){const U=B(`http://127.0.0.1:${De()}`);_.push({value:"local",label:U,url:U})}if(r&&L){const U=B(L);_.push({value:"tunnel",label:U,url:U})}if(Y&&g){const U=B(g);_.push({value:"tailscale",label:U,url:U})}if(l&&A){const U=B(A);_.push({value:"cloud",label:U,url:U})}return O.forEach(U=>{_.push({value:`saved:${U.name}`,label:U.baseUrl,url:U.baseUrl,saved:!0})}),_.push({value:ve,label:"Custom URL...",url:""}),_};function je({value:d,onChange:r,requiresExternalUrl:L=!1,tunnelEnabled:Y=!1,tunnelPublicUrl:g="",tailscaleEnabled:l=!1,tailscaleUrl:A="",cloudEnabled:O=!1,cloudUrl:E="",withV1:_=!0}){const[B,U]=t.useState([]),[o,s]=t.useState(""),[i,M]=t.useState(""),Q=t.useRef(!1);t.useEffect(()=>{U(st())},[]);const P=t.useMemo(()=>lt({requiresExternalUrl:L,tunnelEnabled:Y,tunnelPublicUrl:g,tailscaleEnabled:l,tailscaleUrl:A,cloudEnabled:O,cloudUrl:E,savedPresets:B,withV1:_}),[L,Y,g,l,A,O,E,B,_]);t.useEffect(()=>{if(Q.current||P.length===0)return;Q.current=!0;const x=P.find(C=>C.value!==ve);x?(s(x.value),r(x.url)):s(ve)},[P,r]);const K=x=>{const C=x.target.value;if(C===Re){const T=(d||"").trim();if(!T)return;let p=T;try{p=new URL(T).host}catch{}const a=window.prompt("Save endpoint as:",p);if(!(a!=null&&a.trim()))return;const m=[...B.filter(h=>h.name!==a.trim()),{name:a.trim(),baseUrl:T}].sort((h,v)=>h.name.localeCompare(v.name));U(m),Ie(m);return}if(s(C),C===ve){M(""),r("");return}const j=P.find(T=>T.value===C);j&&r(j.url)},ee=x=>{const C=x.target.value;M(C),r(C)},W=()=>{if(!o.startsWith("saved:"))return;const x=o.slice(6),C=B.filter(j=>j.name!==x);U(C),Ie(C),s(ve),M(""),r("")},b=o.startsWith("saved:"),y=o===ve,w=y&&(i||"").trim().length>0;return e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("select",{value:o,onChange:K,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:[P.map(x=>e.jsx("option",{value:x.value,children:x.label},x.value)),w&&e.jsx("option",{value:Re,children:"+ Save current as..."})]}),b&&e.jsx("button",{type:"button",onClick:W,className:"p-1 text-text-muted hover:text-red-500 rounded transition-colors shrink-0",title:"Delete saved endpoint",children:e.jsx("span",{className:"material-symbols-outlined text-[14px]",children:"delete"})})]}),y&&e.jsx("input",{type:"text",value:i,onChange:ee,placeholder:_?"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"})]})}const we="__custom__";function be({value:d,onChange:r,apiKeys:L=[],cloudEnabled:Y=!1,className:g=""}){const l=!L.some(s=>s.key===d)&&d!=="",[A,O]=t.useState(()=>d?L.some(s=>s.key===d)?d:we:L.length>0?L[0].key:we),[E,_]=t.useState(l?d:""),B=s=>{const i=s.target.value;O(i),i===we?(_(""),r("")):r(i)},U=s=>{const i=s.target.value;_(i),r(i)};return L.length===0&&A!==we&&A!==we?e.jsx("span",{className:`min-w-0 rounded bg-surface/40 px-2 py-2 text-xs text-text-muted sm:py-1.5 ${g}`,children:Y?"No API keys - Create one in Keys page":"sk_fsrouter (default)"}):e.jsxs("div",{className:`flex flex-col gap-1.5 ${g}`,children:[e.jsxs("select",{value:A,onChange:B,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:[L.map(s=>e.jsx("option",{value:s.key,children:s.key},s.id)),e.jsx("option",{value:we,children:"Custom..."})]}),A===we&&e.jsx("input",{type:"text",value:E,onChange:U,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"})]})}const Se=d=>(d||"").replace(/\/+$/,"");function Ne(d,r={}){if(!d)return!1;const L=Se(d),{tunnelPublicUrl:Y,tailscaleUrl:g,cloudUrl:l}=r;return!!(/localhost|127\.0\.0\.1|0\.0\.0\.0/.test(L)||Y&&L.startsWith(Se(Y))||g&&L.startsWith(Se(g))||l&&L.startsWith(Se(l)))}var rt={};const at=rt.NEXT_PUBLIC_CLOUD_URL;function nt({tool:d,isExpanded:r,onToggle:L,activeProviders:Y,modelMappings:g,onModelMappingChange:l,baseUrl:A,hasActiveProviders:O,apiKeys:E,cloudEnabled:_,initialStatus:B,tunnelEnabled:U,tunnelPublicUrl:o,tailscaleEnabled:s,tailscaleUrl:i}){var pe,R;const[M,Q]=t.useState(B||null),[P,K]=t.useState(!1),[ee,W]=t.useState(!1),[b,y]=t.useState(!1),[w,x]=t.useState(null),[C,j]=t.useState(!1),[T,p]=t.useState(!1),[a,m]=t.useState(null),[h,v]=t.useState(""),[I,G]=t.useState({}),[V,ae]=t.useState(!1),[F,oe]=t.useState(""),[ie,te]=t.useState(!1),se=t.useRef(!1),ne=(()=>{var z,le;if(!(M!=null&&M.installed))return null;const n=(le=(z=M.settings)==null?void 0:z.env)==null?void 0:le.ANTHROPIC_BASE_URL;return n?Ne(n,{tunnelPublicUrl:o,tailscaleUrl:i,cloudUrl:_?at:null})?"configured":"other":"not_configured"})();t.useEffect(()=>{(E==null?void 0:E.length)>0&&!h&&v(E[0].key)},[E,h]),t.useEffect(()=>{B&&Q(B)},[B]),t.useEffect(()=>{r&&!M&&(f(),H()),r&&H()},[r]),t.useEffect(()=>{fetch("/api/settings").then(n=>n.json()).then(n=>{te(!!n.ccFilterNaming)}).catch(()=>{})},[]);const ue=async n=>{const z=n.target.checked;te(z),await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({ccFilterNaming:z})}).catch(()=>{})},H=async()=>{try{const n=await fetch("/api/models/alias"),z=await n.json();n.ok&&G(z.aliases||{})}catch(n){console.log("Error fetching model aliases:",n)}};t.useEffect(()=>{var n;if(M!=null&&M.installed&&!se.current){se.current=!0;const z=((n=M.settings)==null?void 0:n.env)||{};d.defaultModels.forEach(k=>{if(k.envKey){const J=z[k.envKey]||k.defaultValue||"";J&&l(k.alias,J)}});const le=z.ANTHROPIC_AUTH_TOKEN;le&&(E!=null&&E.some(k=>k.key===le))&&v(le)}},[M,E,d.defaultModels,l]);const f=async()=>{K(!0);try{const z=await(await fetch("/api/cli-tools/claude-settings")).json();Q(z)}catch(n){Q({installed:!1,error:n.message})}finally{K(!1)}},$=()=>{const n=F||A;return n.endsWith("/v1")?n:`${n}/v1`},X=()=>{const n=F||A;return n.endsWith("/v1")?n:`${n}/v1`},u=async()=>{W(!0),x(null);try{const n={ANTHROPIC_BASE_URL:$()},z=(h==null?void 0:h.trim())||((E==null?void 0:E.length)>0?E[0].key:null)||(_?null:"sk_fsrouter");z&&(n.ANTHROPIC_AUTH_TOKEN=z),d.defaultModels.forEach(J=>{const de=g[J.alias];de&&J.envKey&&(n[J.envKey]=de)});const le=await fetch("/api/cli-tools/claude-settings",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({env:n})}),k=await le.json();le.ok?(x({type:"success",text:"Settings applied successfully!"}),Q(J=>({...J,hasBackup:!0,settings:{...J==null?void 0:J.settings,env:n}}))):x({type:"error",text:k.error||"Failed to apply settings"})}catch(n){x({type:"error",text:n.message})}finally{W(!1)}},N=async()=>{y(!0),x(null);try{const n=await fetch("/api/cli-tools/claude-settings",{method:"DELETE"}),z=await n.json();n.ok?(x({type:"success",text:"Settings reset successfully!"}),d.defaultModels.forEach(le=>l(le.alias,le.defaultValue||"")),v("")):x({type:"error",text:z.error||"Failed to reset settings"})}catch(n){x({type:"error",text:n.message})}finally{y(!1)}},S=n=>{m(n),p(!0)},ce=n=>{a&&l(a,n.value)},xe=()=>{const n=h&&h.trim()?h:_?"<API_KEY_FROM_DASHBOARD>":"sk_fsrouter",z={ANTHROPIC_BASE_URL:$(),ANTHROPIC_AUTH_TOKEN:n};return d.defaultModels.forEach(le=>{const k=g[le.alias];k&&le.envKey&&(z[le.envKey]=k)}),[{filename:"~/.claude/settings.json",content:JSON.stringify({hasCompletedOnboarding:!0,env:z},null,2)}]};return e.jsxs(ge,{padding:"xs",className:"overflow-hidden",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3 hover:cursor-pointer sm:items-center",onClick:L,children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-3",children:[e.jsx("div",{className:"size-8 flex items-center justify-center shrink-0",children:e.jsx("img",{src:"/providers/claude.png",alt:d.name,width:32,height:32,className:"size-8 object-contain rounded-lg",sizes:"32px",onError:n=>{n.target.style.display="none"}})}),e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-2",children:[e.jsx("h3",{className:"font-medium text-sm",children:d.name}),ne==="configured"&&e.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"}),ne==="not_configured"&&e.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"}),ne==="other"&&e.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"})]}),e.jsx("p",{className:"text-xs text-text-muted truncate",children:d.description})]})]}),e.jsx("span",{className:`material-symbols-outlined text-text-muted text-[20px] transition-transform ${r?"rotate-180":""}`,children:"expand_more"})]}),r&&e.jsxs("div",{className:"mt-4 pt-4 border-t border-border flex flex-col gap-4",children:[P&&e.jsxs("div",{className:"flex items-center gap-2 text-text-muted",children:[e.jsx("span",{className:"material-symbols-outlined animate-spin",children:"progress_activity"}),e.jsx("span",{children:"Checking Claude CLI..."})]}),!P&&M&&!M.installed&&e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsxs("div",{className:"flex flex-col gap-3 p-4 bg-yellow-500/10 border border-yellow-500/30 rounded-lg",children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("span",{className:"material-symbols-outlined text-yellow-500",children:"warning"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"font-medium text-yellow-600 dark:text-yellow-400",children:"Claude CLI not detected locally"}),e.jsx("p",{className:"text-sm text-text-muted",children:"Manual configuration is still available if fsrouter is deployed on a remote server."})]})]}),e.jsxs("div",{className:"flex items-center gap-2 pl-9",children:[e.jsxs(q,{variant:"secondary",size:"sm",onClick:()=>ae(!0),className:"!bg-yellow-500/20 !border-yellow-500/40 !text-yellow-700 dark:!text-yellow-300 hover:!bg-yellow-500/30",children:[e.jsx("span",{className:"material-symbols-outlined text-[18px] mr-1",children:"content_copy"}),"Manual Config"]}),e.jsxs(q,{variant:"outline",size:"sm",onClick:()=>j(!C),children:[e.jsx("span",{className:"material-symbols-outlined text-[18px] mr-1",children:C?"expand_less":"help"}),C?"Hide":"How to Install"]})]})]}),C&&e.jsxs("div",{className:"p-4 bg-surface border border-border rounded-lg",children:[e.jsx("h4",{className:"font-medium mb-3",children:"Installation Guide"}),e.jsxs("div",{className:"space-y-3 text-sm",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-text-muted mb-1",children:"macOS / Linux / Windows:"}),e.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"})]}),e.jsxs("p",{className:"text-text-muted",children:["After installation, run ",e.jsx("code",{className:"px-1 bg-black/5 dark:bg-white/5 rounded",children:"claude"})," to verify."]})]})]})]}),!P&&(M==null?void 0:M.installed)&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsxs("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr] sm:items-center sm:gap-2",children:[e.jsx("span",{className:"text-xs font-semibold text-text-main sm:text-right sm:text-sm",children:"Select Endpoint"}),e.jsx("span",{className:"material-symbols-outlined hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),e.jsx(je,{value:F||X(),onChange:oe,requiresExternalUrl:d.requiresExternalUrl,tunnelEnabled:U,tunnelPublicUrl:o,tailscaleEnabled:s,tailscaleUrl:i})]}),((R=(pe=M==null?void 0:M.settings)==null?void 0:pe.env)==null?void 0:R.ANTHROPIC_BASE_URL)&&e.jsxs("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr_auto] sm:items-center sm:gap-2",children:[e.jsx("span",{className:"text-xs font-semibold text-text-main sm:text-right sm:text-sm",children:"Current"}),e.jsx("span",{className:"material-symbols-outlined hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),e.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:M.settings.env.ANTHROPIC_BASE_URL})]}),e.jsxs("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr_auto] sm:items-center sm:gap-2",children:[e.jsx("span",{className:"text-xs font-semibold text-text-main sm:text-right sm:text-sm",children:"API Key"}),e.jsx("span",{className:"material-symbols-outlined hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),e.jsx(be,{value:h,onChange:v,apiKeys:E,cloudEnabled:_})]}),d.defaultModels.map(n=>e.jsxs("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr_auto] sm:items-center sm:gap-2",children:[e.jsx("span",{className:"text-xs font-semibold text-text-main sm:text-right sm:text-sm",children:n.name}),e.jsx("span",{className:"material-symbols-outlined hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),e.jsxs("div",{className:"relative w-full min-w-0",children:[e.jsx("input",{type:"text",value:g[n.alias]||"",onChange:z=>l(n.alias,z.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"}),g[n.alias]&&e.jsx("button",{onClick:()=>l(n.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:e.jsx("span",{className:"material-symbols-outlined text-[14px]",children:"close"})})]}),e.jsx("button",{onClick:()=>S(n.alias),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 Model"})]},n.alias)),e.jsxs("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr_auto] sm:items-center sm:gap-2",children:[e.jsx("span",{className:"text-xs font-semibold text-text-main sm:text-right sm:text-sm",children:"Filter naming"}),e.jsx("span",{className:"material-symbols-outlined hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),e.jsxs("label",{className:"flex items-center gap-1.5 cursor-pointer select-none",children:[e.jsx("input",{type:"checkbox",checked:ie,onChange:ue,className:"w-3.5 h-3.5 accent-primary cursor-pointer"}),e.jsx("span",{className:"text-xs text-text-muted",children:"Filter naming requests"})]}),e.jsx(Be,{text:"Intercepts Claude Code's topic-naming requests and returns a fake response locally, saving API tokens.",children:e.jsx("span",{className:"material-symbols-outlined text-text-muted text-[14px] cursor-help",children:"info"})})]})]}),w&&e.jsxs("div",{className:`flex items-center gap-2 px-2 py-1.5 rounded text-xs ${w.type==="success"?"bg-green-500/10 text-green-600":"bg-red-500/10 text-red-600"}`,children:[e.jsx("span",{className:"material-symbols-outlined text-[14px]",children:w.type==="success"?"check_circle":"error"}),e.jsx("span",{children:w.text})]}),e.jsxs("div",{className:"grid grid-cols-1 gap-2 sm:flex sm:items-center",children:[e.jsxs(q,{variant:"primary",size:"sm",onClick:u,disabled:!O,loading:ee,children:[e.jsx("span",{className:"material-symbols-outlined text-[14px] mr-1",children:"save"}),"Apply"]}),e.jsxs(q,{variant:"outline",size:"sm",onClick:N,disabled:!(M!=null&&M.hasFSRouter),loading:b,children:[e.jsx("span",{className:"material-symbols-outlined text-[14px] mr-1",children:"restore"}),"Reset"]}),e.jsxs(q,{variant:"ghost",size:"sm",onClick:()=>ae(!0),children:[e.jsx("span",{className:"material-symbols-outlined text-[14px] mr-1",children:"content_copy"}),"Manual Config"]})]})]})]}),e.jsx(fe,{isOpen:T,onClose:()=>p(!1),onSelect:ce,selectedModel:a?g[a]:null,activeProviders:Y,modelAliases:I,title:`Select model for ${a}`}),e.jsx(ye,{isOpen:V,onClose:()=>ae(!1),title:"Claude CLI - Manual Configuration",configs:xe()})]})}function ot({tool:d,isExpanded:r,onToggle:L,baseUrl:Y,apiKeys:g,activeProviders:l,cloudEnabled:A,initialStatus:O,tunnelEnabled:E,tunnelPublicUrl:_,tailscaleEnabled:B,tailscaleUrl:U}){const[o,s]=t.useState(O||null),[i,M]=t.useState(!1),[Q,P]=t.useState(!1),[K,ee]=t.useState(!1),[W,b]=t.useState(null),[y,w]=t.useState(!1),[x,C]=t.useState(""),[j,T]=t.useState(""),[p,a]=t.useState(""),[m,h]=t.useState(!1),[v,I]=t.useState(!1),[G,V]=t.useState({}),[ae,F]=t.useState(!1),[oe,ie]=t.useState("");t.useEffect(()=>{(g==null?void 0:g.length)>0&&!x&&C(g[0].key)},[g,x]),t.useEffect(()=>{O&&s(O)},[O]),t.useEffect(()=>{r&&!o&&(H(),te()),r&&te()},[r]);const te=async()=>{try{const N=await fetch("/api/models/alias"),S=await N.json();N.ok&&V(S.aliases||{})}catch(N){console.log("Error fetching model aliases:",N)}};t.useEffect(()=>{if(o!=null&&o.config){const N=o.config.match(/^model\s*=\s*"([^"]+)"/m);N&&T(N[1]);const S=o.config.match(/\[agents\.subagent\]\s*\n\s*model\s*=\s*"([^"]+)"/m);S&&a(S[1])}},[o]);const Z=(()=>{if(!(o!=null&&o.installed))return null;if(!o.config)return"not_configured";const N=o.config.match(/base_url\s*=\s*"([^"]+)"/),S=N?N[1]:"";return Ne(S,{tunnelPublicUrl:_,tailscaleUrl:U})?"configured":"other"})(),ne=()=>{const N=oe||`${Y}/v1`;return N.endsWith("/v1")?N:`${N}/v1`},ue=()=>oe||`${Y}/v1`,H=async()=>{M(!0);try{const S=await(await fetch("/api/cli-tools/codex-settings")).json();s(S)}catch(N){s({installed:!1,error:N.message})}finally{M(!1)}},f=async()=>{P(!0),b(null);try{const N=x&&x.trim()||A?x:"sk_fsrouter",S=await fetch("/api/cli-tools/codex-settings",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({baseUrl:ne(),apiKey:N,model:j,subagentModel:p||j})}),ce=await S.json();S.ok?(b({type:"success",text:"Settings applied successfully!"}),H()):b({type:"error",text:ce.error||"Failed to apply settings"})}catch(N){b({type:"error",text:N.message})}finally{P(!1)}},$=async()=>{ee(!0),b(null);try{const N=await fetch("/api/cli-tools/codex-settings",{method:"DELETE"}),S=await N.json();N.ok?(b({type:"success",text:"Settings reset successfully!"}),T(""),a(""),H()):b({type:"error",text:S.error||"Failed to reset settings"})}catch(N){b({type:"error",text:N.message})}finally{ee(!1)}},X=N=>{T(N.value),p||a(N.value),h(!1)},u=()=>{const N=x&&x.trim()?x:A?"<API_KEY_FROM_DASHBOARD>":"sk_fsrouter",S=p||j,ce=`# FSRouter Configuration for Codex CLI
2
2
  model = "${j}"
3
3
  model_provider = "fsrouter"
4
4
 
@@ -1,2 +1,2 @@
1
1
  const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index.1VBQU7rF.js","assets/router.Cjj1--8t.js"])))=>i.map(i=>d[i]);
2
- import{u as z,j as t,B as c,_ as F}from"./index.CShjRV_B.js";import{b as x}from"./router.Cjj1--8t.js";import{C as $}from"./NoAuthProxyCard.qAv57b-0.js";import"./zustand.akaTi5uX.js";const B=x.lazy(()=>F(()=>import("./index.1VBQU7rF.js"),__vite__mapDeps([0,1]))),v=[{id:1,label:"Client Request",file:"1_req_client.json",lang:"json",desc:"Raw request from client"},{id:2,label:"Source Body",file:"2_req_source.json",lang:"json",desc:"After initial conversion"},{id:3,label:"OpenAI Intermediate",file:"3_req_openai.json",lang:"json",desc:"source → openai"},{id:4,label:"Target Request",file:"4_req_target.json",lang:"json",desc:"openai → target + URL + headers"},{id:5,label:"Provider Response",file:"5_res_provider.txt",lang:"text",desc:"Raw SSE from provider"},{id:6,label:"OpenAI Response",file:"6_res_openai.txt",lang:"text",desc:"target → openai (response)"},{id:7,label:"Client Response",file:"7_res_client.txt",lang:"text",desc:"Final response to client"}],I={minimap:{enabled:!1},fontSize:12,lineNumbers:"on",scrollBeyondLastLine:!1,wordWrap:"on",automaticLayout:!0};function W(){const[i,h]=x.useState({}),[g,u]=x.useState({1:!0}),[p,S]=x.useState({}),[o,w]=x.useState(null),l=(e,s)=>S(a=>({...a,[e]:s})),d=(e,s)=>h(a=>({...a,[e]:s})),O=e=>u(s=>({...s,[e]:!s[e]})),j=e=>u(s=>{const a={};return v.forEach(n=>{a[n.id]=!1}),a[e]=!0,a}),_=async e=>{const s=v.find(a=>a.id===e);l(`load-${e}`,!0);try{const n=await(await fetch(`/api/translator/load?file=${s.file}`)).json();n.success?(d(e,n.content),e===1&&await N(n.content)):alert(n.error||"File not found")}catch(a){alert(a.message)}l(`load-${e}`,!1)},N=async e=>{try{const s=typeof e=="string"?JSON.parse(e):e,n=await(await fetch("/api/translator/translate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({step:1,body:s})})).json();n.success&&w(n.result)}catch{}},f=(e,s)=>fetch("/api/translator/save",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({file:e,content:s})}).catch(()=>{}),T=async()=>{l("toOpenAI",!0);try{const e=i[1],s=JSON.parse(e);f("1_req_client.json",e),f("2_req_source.json",JSON.stringify({timestamp:new Date().toISOString(),headers:{},body:s.body||s},null,2));const n=await(await fetch("/api/translator/translate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({step:2,body:s})})).json();if(!n.success){alert(n.error);return}const r=JSON.stringify(n.result.body,null,2);d(3,r),j(3)}catch(e){alert(e.message)}l("toOpenAI",!1)},C=async()=>{l("toTarget",!0);try{const e=i[3],s=JSON.parse(e);f("3_req_openai.json",e);const n=await(await fetch("/api/translator/translate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({step:3,body:{...s,provider:o==null?void 0:o.provider,model:o==null?void 0:o.model}})})).json();if(!n.success){alert(n.error);return}const r={...n.result,provider:o==null?void 0:o.provider,model:o==null?void 0:o.model};d(4,JSON.stringify(r,null,2)),j(4)}catch(e){alert(e.message)}l("toTarget",!1)},J=async()=>{l("send",!0);try{const e=i[4],s=JSON.parse(e);f("4_req_target.json",e);const a=s.provider||(o==null?void 0:o.provider),n=s.model||(o==null?void 0:o.model);if(!a||!n){alert("Missing provider or model. Please run step 1 first to detect them.");return}const r=await fetch("/api/translator/send",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:a,model:n,body:s.body||s})});if(!r.ok){const b=await r.json().catch(()=>({error:r.statusText}));alert(b.error||"Send failed");return}const E=r.body.getReader(),A=new TextDecoder;let y="";for(;;){const{done:b,value:L}=await E.read();if(b)break;y+=A.decode(L,{stream:!0})}d(5,y),j(5),await fetch("/api/translator/save",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({file:"5_res_provider.txt",content:y})})}catch(e){alert(e.message)}finally{l("send",!1)}},{copy:P}=z(),R=async e=>{i[e]&&P(i[e],`translator-step-${e}`)},k=e=>{try{const s=JSON.parse(i[e]);d(e,JSON.stringify(s,null,2))}catch{}},q=e=>e===1?t.jsx(c,{size:"sm",icon:"arrow_forward",loading:p.toOpenAI,onClick:T,children:"→ OpenAI"}):e===3?t.jsx(c,{size:"sm",icon:"arrow_forward",loading:p.toTarget,onClick:C,children:"→ Target"}):e===4?t.jsx(c,{size:"sm",icon:"send",loading:p.send,onClick:J,children:"Send"}):null;return t.jsxs("div",{className:"p-8 space-y-3",children:[t.jsxs("div",{className:"flex items-center justify-between mb-2",children:[t.jsxs("div",{children:[t.jsx("h1",{className:"text-2xl font-bold text-text-main",children:"Translator Debug"}),t.jsx("p",{className:"text-sm text-text-muted mt-1",children:"Replay request flow — matches log files"})]}),o&&t.jsxs("div",{className:"flex items-center gap-2 flex-wrap justify-end",children:[t.jsx(m,{label:"src",value:o.sourceFormat,color:"blue"}),t.jsx("span",{className:"material-symbols-outlined text-text-muted text-[14px]",children:"arrow_forward"}),t.jsx(m,{label:"dst",value:o.targetFormat,color:"orange"}),t.jsx(m,{label:"provider",value:o.provider,color:"green"}),t.jsx(m,{label:"model",value:o.model,color:"purple"})]})]}),v.map(e=>{const s=q(e.id),a=!!g[e.id],n=i[e.id]||"";return t.jsx($,{children:t.jsxs("div",{className:"p-4 space-y-3",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("button",{onClick:()=>O(e.id),className:"flex items-center gap-2 flex-1 text-left group",children:[t.jsx("span",{className:"material-symbols-outlined text-[20px] text-text-muted group-hover:text-primary transition-colors",children:a?"expand_more":"chevron_right"}),t.jsx("span",{className:"text-xs font-mono text-text-muted/60 w-4",children:e.id}),t.jsx("h3",{className:"text-sm font-semibold text-text-main",children:e.label}),t.jsx("span",{className:"text-xs text-text-muted/60 font-mono",children:e.file}),n&&t.jsxs("span",{className:"text-xs text-green-500",children:["(",n.length," chars)"]})]}),!a&&t.jsxs("div",{className:"flex gap-1 shrink-0",children:[t.jsx(c,{size:"sm",variant:"ghost",icon:"folder_open",loading:p[`load-${e.id}`],onClick:()=>_(e.id)}),s]})]}),a&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"border border-border rounded-lg overflow-hidden",children:t.jsx(B,{height:"400px",defaultLanguage:e.lang==="text"?"plaintext":"json",value:n,onChange:r=>{d(e.id,r||""),e.id===1&&N(r||"")},theme:"vs-dark",options:I})}),t.jsxs("div",{className:"flex gap-2 flex-wrap",children:[t.jsx(c,{size:"sm",variant:"outline",icon:"folder_open",loading:p[`load-${e.id}`],onClick:()=>_(e.id),children:"Load"}),t.jsx(c,{size:"sm",variant:"outline",icon:"data_object",onClick:()=>k(e.id),children:"Format"}),t.jsx(c,{size:"sm",variant:"outline",icon:"content_copy",onClick:()=>R(e.id),children:"Copy"}),s]})]})]})},e.id)})]})}function m({label:i,value:h,color:g}){const u={blue:"bg-blue-500/10 text-blue-500",orange:"bg-orange-500/10 text-orange-500",green:"bg-green-500/10 text-green-500",purple:"bg-purple-500/10 text-purple-500"};return t.jsxs("span",{className:`inline-flex items-center gap-1 px-2 py-0.5 rounded text-xs font-mono ${u[g]}`,children:[t.jsxs("span",{className:"text-text-muted/70 font-sans text-[10px]",children:[i,":"]}),h]})}export{W as default};
2
+ import{u as z,j as t,B as c,_ as F}from"./index.Be3gbrBl.js";import{b as x}from"./router.Cjj1--8t.js";import{C as $}from"./NoAuthProxyCard.BDcXaWvM.js";import"./zustand.akaTi5uX.js";const B=x.lazy(()=>F(()=>import("./index.1VBQU7rF.js"),__vite__mapDeps([0,1]))),v=[{id:1,label:"Client Request",file:"1_req_client.json",lang:"json",desc:"Raw request from client"},{id:2,label:"Source Body",file:"2_req_source.json",lang:"json",desc:"After initial conversion"},{id:3,label:"OpenAI Intermediate",file:"3_req_openai.json",lang:"json",desc:"source → openai"},{id:4,label:"Target Request",file:"4_req_target.json",lang:"json",desc:"openai → target + URL + headers"},{id:5,label:"Provider Response",file:"5_res_provider.txt",lang:"text",desc:"Raw SSE from provider"},{id:6,label:"OpenAI Response",file:"6_res_openai.txt",lang:"text",desc:"target → openai (response)"},{id:7,label:"Client Response",file:"7_res_client.txt",lang:"text",desc:"Final response to client"}],I={minimap:{enabled:!1},fontSize:12,lineNumbers:"on",scrollBeyondLastLine:!1,wordWrap:"on",automaticLayout:!0};function W(){const[i,h]=x.useState({}),[g,u]=x.useState({1:!0}),[p,S]=x.useState({}),[o,w]=x.useState(null),l=(e,s)=>S(a=>({...a,[e]:s})),d=(e,s)=>h(a=>({...a,[e]:s})),O=e=>u(s=>({...s,[e]:!s[e]})),j=e=>u(s=>{const a={};return v.forEach(n=>{a[n.id]=!1}),a[e]=!0,a}),_=async e=>{const s=v.find(a=>a.id===e);l(`load-${e}`,!0);try{const n=await(await fetch(`/api/translator/load?file=${s.file}`)).json();n.success?(d(e,n.content),e===1&&await N(n.content)):alert(n.error||"File not found")}catch(a){alert(a.message)}l(`load-${e}`,!1)},N=async e=>{try{const s=typeof e=="string"?JSON.parse(e):e,n=await(await fetch("/api/translator/translate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({step:1,body:s})})).json();n.success&&w(n.result)}catch{}},f=(e,s)=>fetch("/api/translator/save",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({file:e,content:s})}).catch(()=>{}),T=async()=>{l("toOpenAI",!0);try{const e=i[1],s=JSON.parse(e);f("1_req_client.json",e),f("2_req_source.json",JSON.stringify({timestamp:new Date().toISOString(),headers:{},body:s.body||s},null,2));const n=await(await fetch("/api/translator/translate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({step:2,body:s})})).json();if(!n.success){alert(n.error);return}const r=JSON.stringify(n.result.body,null,2);d(3,r),j(3)}catch(e){alert(e.message)}l("toOpenAI",!1)},C=async()=>{l("toTarget",!0);try{const e=i[3],s=JSON.parse(e);f("3_req_openai.json",e);const n=await(await fetch("/api/translator/translate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({step:3,body:{...s,provider:o==null?void 0:o.provider,model:o==null?void 0:o.model}})})).json();if(!n.success){alert(n.error);return}const r={...n.result,provider:o==null?void 0:o.provider,model:o==null?void 0:o.model};d(4,JSON.stringify(r,null,2)),j(4)}catch(e){alert(e.message)}l("toTarget",!1)},J=async()=>{l("send",!0);try{const e=i[4],s=JSON.parse(e);f("4_req_target.json",e);const a=s.provider||(o==null?void 0:o.provider),n=s.model||(o==null?void 0:o.model);if(!a||!n){alert("Missing provider or model. Please run step 1 first to detect them.");return}const r=await fetch("/api/translator/send",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:a,model:n,body:s.body||s})});if(!r.ok){const b=await r.json().catch(()=>({error:r.statusText}));alert(b.error||"Send failed");return}const E=r.body.getReader(),A=new TextDecoder;let y="";for(;;){const{done:b,value:L}=await E.read();if(b)break;y+=A.decode(L,{stream:!0})}d(5,y),j(5),await fetch("/api/translator/save",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({file:"5_res_provider.txt",content:y})})}catch(e){alert(e.message)}finally{l("send",!1)}},{copy:P}=z(),R=async e=>{i[e]&&P(i[e],`translator-step-${e}`)},k=e=>{try{const s=JSON.parse(i[e]);d(e,JSON.stringify(s,null,2))}catch{}},q=e=>e===1?t.jsx(c,{size:"sm",icon:"arrow_forward",loading:p.toOpenAI,onClick:T,children:"→ OpenAI"}):e===3?t.jsx(c,{size:"sm",icon:"arrow_forward",loading:p.toTarget,onClick:C,children:"→ Target"}):e===4?t.jsx(c,{size:"sm",icon:"send",loading:p.send,onClick:J,children:"Send"}):null;return t.jsxs("div",{className:"p-8 space-y-3",children:[t.jsxs("div",{className:"flex items-center justify-between mb-2",children:[t.jsxs("div",{children:[t.jsx("h1",{className:"text-2xl font-bold text-text-main",children:"Translator Debug"}),t.jsx("p",{className:"text-sm text-text-muted mt-1",children:"Replay request flow — matches log files"})]}),o&&t.jsxs("div",{className:"flex items-center gap-2 flex-wrap justify-end",children:[t.jsx(m,{label:"src",value:o.sourceFormat,color:"blue"}),t.jsx("span",{className:"material-symbols-outlined text-text-muted text-[14px]",children:"arrow_forward"}),t.jsx(m,{label:"dst",value:o.targetFormat,color:"orange"}),t.jsx(m,{label:"provider",value:o.provider,color:"green"}),t.jsx(m,{label:"model",value:o.model,color:"purple"})]})]}),v.map(e=>{const s=q(e.id),a=!!g[e.id],n=i[e.id]||"";return t.jsx($,{children:t.jsxs("div",{className:"p-4 space-y-3",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("button",{onClick:()=>O(e.id),className:"flex items-center gap-2 flex-1 text-left group",children:[t.jsx("span",{className:"material-symbols-outlined text-[20px] text-text-muted group-hover:text-primary transition-colors",children:a?"expand_more":"chevron_right"}),t.jsx("span",{className:"text-xs font-mono text-text-muted/60 w-4",children:e.id}),t.jsx("h3",{className:"text-sm font-semibold text-text-main",children:e.label}),t.jsx("span",{className:"text-xs text-text-muted/60 font-mono",children:e.file}),n&&t.jsxs("span",{className:"text-xs text-green-500",children:["(",n.length," chars)"]})]}),!a&&t.jsxs("div",{className:"flex gap-1 shrink-0",children:[t.jsx(c,{size:"sm",variant:"ghost",icon:"folder_open",loading:p[`load-${e.id}`],onClick:()=>_(e.id)}),s]})]}),a&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"border border-border rounded-lg overflow-hidden",children:t.jsx(B,{height:"400px",defaultLanguage:e.lang==="text"?"plaintext":"json",value:n,onChange:r=>{d(e.id,r||""),e.id===1&&N(r||"")},theme:"vs-dark",options:I})}),t.jsxs("div",{className:"flex gap-2 flex-wrap",children:[t.jsx(c,{size:"sm",variant:"outline",icon:"folder_open",loading:p[`load-${e.id}`],onClick:()=>_(e.id),children:"Load"}),t.jsx(c,{size:"sm",variant:"outline",icon:"data_object",onClick:()=>k(e.id),children:"Format"}),t.jsx(c,{size:"sm",variant:"outline",icon:"content_copy",onClick:()=>R(e.id),children:"Copy"}),s]})]})]})},e.id)})]})}function m({label:i,value:h,color:g}){const u={blue:"bg-blue-500/10 text-blue-500",orange:"bg-orange-500/10 text-orange-500",green:"bg-green-500/10 text-green-500",purple:"bg-purple-500/10 text-purple-500"};return t.jsxs("span",{className:`inline-flex items-center gap-1 px-2 py-0.5 rounded text-xs font-mono ${u[g]}`,children:[t.jsxs("span",{className:"text-text-muted/70 font-sans text-[10px]",children:[i,":"]}),h]})}export{W as default};
@@ -1,4 +1,4 @@
1
- import{j as e,N as pe,y as fe,B as A,P as be,g as ge}from"./index.CShjRV_B.js";import{h as je,d as we,b as c,L as ve}from"./router.Cjj1--8t.js";import{C as S,I as ye,T as Ne,M as ke}from"./NoAuthProxyCard.qAv57b-0.js";import"./zustand.akaTi5uX.js";function Se(o){if(typeof o!="string")return{providerId:"",model:""};const g=o.indexOf("/");return g<0?{providerId:o,model:""}:{providerId:o.slice(0,g),model:o.slice(g+1)}}const Re=/^[a-zA-Z0-9_.\-]+$/,Ee={webSearch:"Web Search",webFetch:"Web Fetch",image:"Text to Image",tts:"Text To Speech"},V={webSearch:"/v1/search",webFetch:"/v1/web/fetch",image:"/v1/images/generations",tts:"/v1/audio/speech"},L={webSearch:o=>({model:o,query:"What is the latest news about AI?",search_type:"web",max_results:5}),webFetch:o=>({model:o,url:"https://example.com",format:"markdown"}),image:o=>({model:o,prompt:"A cute cat playing piano",n:1,size:"1024x1024"}),tts:o=>({model:o,input:"Hello, this is a test.",voice:"alloy"})};function X(o){return o==="webSearch"||o==="webFetch"?"/dashboard/media-providers/web":`/dashboard/media-providers/${o}`}function Le(){var K;const{id:o}=je(),g=we(),[r,P]=c.useState(null),[q,O]=c.useState(!0),[N,_]=c.useState(""),[G,R]=c.useState(""),[m,j]=c.useState([]),[Y,$]=c.useState(!1),[Z,M]=c.useState(!1),[D,Q]=c.useState([]),[I,B]=c.useState(!1),[l,w]=c.useState(null),[z,E]=c.useState(""),[U,ee]=c.useState(""),[te,se]=c.useState([]),[ae,ne]=c.useState({}),H=async()=>{var t,s,a;try{const[n,i,k,y,x,p]=await Promise.all([fetch(`/api/combos/${o}`,{cache:"no-store"}),fetch("/api/settings",{cache:"no-store"}),fetch("/api/usage/logs",{cache:"no-store"}),fetch("/api/keys",{cache:"no-store"}),fetch("/api/providers",{cache:"no-store"}),fetch("/api/models/alias",{cache:"no-store"})]);if(p.ok&&ne((await p.json()).aliases||{}),y.ok){const b=await y.json();ee(((t=(b.keys||[]).find(d=>d.isActive!==!1))==null?void 0:t.key)||"")}if(x.ok&&se((await x.json()).connections||[]),!n.ok){P(null),O(!1);return}const h=await n.json();P(h),_(h.name),j(h.models||[]);const f=i.ok?await i.json():{};$(((a=(s=f.comboStrategies)==null?void 0:s[h.name])==null?void 0:a.fallbackStrategy)==="round-robin");const u=k.ok?await k.json():[];Q(u.filter(b=>typeof b=="string"&&b.includes(h.name)).slice(0,50))}catch{}O(!1)};c.useEffect(()=>{H()},[o]);const F=t=>t.trim()?Re.test(t)?(R(""),!0):(R("Only letters, numbers, -, _ and ."),!1):(R("Name is required"),!1),v=async t=>{const s=await fetch(`/api/combos/${o}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!s.ok){const a=await s.json();return alert(a.error||"Failed to save"),!1}return!0},oe=async()=>{if(!F(N)||N===r.name)return;await v({name:N})&&await H()},re=async t=>{const s=(t==null?void 0:t.value)||t;if(!s||m.includes(s))return;const a=[...m,s];j(a),await v({models:a})},le=async t=>{const s=(t==null?void 0:t.value)||t;if(!s||!m.includes(s))return;const a=m.filter(n=>n!==s);j(a),await v({models:a})},ie=async t=>{const s=m.filter((a,n)=>n!==t);j(s),await v({models:s})},J=async(t,s)=>{const a=[...m],n=t+s;n<0||n>=a.length||([a[t],a[n]]=[a[n],a[t]],j(a),await v({models:a}))},ce=async t=>{$(t);const s=await fetch("/api/settings",{cache:"no-store"}),n={...(s.ok?await s.json():{}).comboStrategies||{}};t?n[r.name]={fallbackStrategy:"round-robin"}:delete n[r.name],await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({comboStrategies:n})})},de=async()=>{if(!confirm(`Delete combo "${r.name}"?`))return;(await fetch(`/api/combos/${o}`,{method:"DELETE"})).ok&&g(X(r.kind))},me=async()=>{var s,a,n;if(B(!0),w(null),E(""),l!=null&&l.audioUrl)try{URL.revokeObjectURL(l.audioUrl)}catch{}if((s=l==null?void 0:l.imageUrl)!=null&&s.startsWith("blob:"))try{URL.revokeObjectURL(l.imageUrl)}catch{}const t=Date.now();try{const i=V[r.kind],k=L[r.kind](r.name),y={"Content-Type":"application/json"};U&&(y.Authorization=`Bearer ${U}`);const x=await fetch(`/api${i}`,{method:"POST",headers:y,body:JSON.stringify(k)}),p=Date.now()-t;if(!x.ok){const d=await x.json().catch(()=>({}));E(((a=d==null?void 0:d.error)==null?void 0:a.message)||(d==null?void 0:d.error)||`HTTP ${x.status}`),w({json:JSON.stringify(d,null,2),latencyMs:p});return}const h=x.headers.get("content-type")||"";if(h.startsWith("image/")){const d=await x.blob();w({imageUrl:URL.createObjectURL(d),latencyMs:p});return}if(h.startsWith("audio/")||h==="application/octet-stream"){const d=await x.blob();w({audioUrl:URL.createObjectURL(d),latencyMs:p});return}const f=await x.json(),u=(n=f==null?void 0:f.data)==null?void 0:n[0],b=u!=null&&u.b64_json?`data:image/png;base64,${u.b64_json}`:(u==null?void 0:u.url)||"";w({json:JSON.stringify(C(f),null,2),imageUrl:b,latencyMs:p})}catch(i){E(i.message||"Network error")}B(!1)};function C(t){if(!t||typeof t!="object")return t;if(Array.isArray(t))return t.map(C);const s={};for(const[a,n]of Object.entries(t))s[a]=a==="b64_json"&&typeof n=="string"&&n.length>100?`<${n.length} chars base64>`:C(n);return s}if(q)return e.jsx("div",{className:"text-text-muted text-sm",children:"Loading..."});if(!r)return null;const W=Ee[r.kind]||((K=pe.find(t=>t.id===r.kind))==null?void 0:K.label)||"Combo",T=V[r.kind],xe=r.kind&&L[r.kind]?L[r.kind](r.name):null,he=T?`curl -X POST ${fe()}${T} \\
1
+ import{j as e,N as pe,y as fe,B as A,P as be,g as ge}from"./index.Be3gbrBl.js";import{h as je,d as we,b as c,L as ve}from"./router.Cjj1--8t.js";import{C as S,I as ye,T as Ne,M as ke}from"./NoAuthProxyCard.BDcXaWvM.js";import"./zustand.akaTi5uX.js";function Se(o){if(typeof o!="string")return{providerId:"",model:""};const g=o.indexOf("/");return g<0?{providerId:o,model:""}:{providerId:o.slice(0,g),model:o.slice(g+1)}}const Re=/^[a-zA-Z0-9_.\-]+$/,Ee={webSearch:"Web Search",webFetch:"Web Fetch",image:"Text to Image",tts:"Text To Speech"},V={webSearch:"/v1/search",webFetch:"/v1/web/fetch",image:"/v1/images/generations",tts:"/v1/audio/speech"},L={webSearch:o=>({model:o,query:"What is the latest news about AI?",search_type:"web",max_results:5}),webFetch:o=>({model:o,url:"https://example.com",format:"markdown"}),image:o=>({model:o,prompt:"A cute cat playing piano",n:1,size:"1024x1024"}),tts:o=>({model:o,input:"Hello, this is a test.",voice:"alloy"})};function X(o){return o==="webSearch"||o==="webFetch"?"/dashboard/media-providers/web":`/dashboard/media-providers/${o}`}function Le(){var K;const{id:o}=je(),g=we(),[r,P]=c.useState(null),[q,O]=c.useState(!0),[N,_]=c.useState(""),[G,R]=c.useState(""),[m,j]=c.useState([]),[Y,$]=c.useState(!1),[Z,M]=c.useState(!1),[D,Q]=c.useState([]),[I,B]=c.useState(!1),[l,w]=c.useState(null),[z,E]=c.useState(""),[U,ee]=c.useState(""),[te,se]=c.useState([]),[ae,ne]=c.useState({}),H=async()=>{var t,s,a;try{const[n,i,k,y,x,p]=await Promise.all([fetch(`/api/combos/${o}`,{cache:"no-store"}),fetch("/api/settings",{cache:"no-store"}),fetch("/api/usage/logs",{cache:"no-store"}),fetch("/api/keys",{cache:"no-store"}),fetch("/api/providers",{cache:"no-store"}),fetch("/api/models/alias",{cache:"no-store"})]);if(p.ok&&ne((await p.json()).aliases||{}),y.ok){const b=await y.json();ee(((t=(b.keys||[]).find(d=>d.isActive!==!1))==null?void 0:t.key)||"")}if(x.ok&&se((await x.json()).connections||[]),!n.ok){P(null),O(!1);return}const h=await n.json();P(h),_(h.name),j(h.models||[]);const f=i.ok?await i.json():{};$(((a=(s=f.comboStrategies)==null?void 0:s[h.name])==null?void 0:a.fallbackStrategy)==="round-robin");const u=k.ok?await k.json():[];Q(u.filter(b=>typeof b=="string"&&b.includes(h.name)).slice(0,50))}catch{}O(!1)};c.useEffect(()=>{H()},[o]);const F=t=>t.trim()?Re.test(t)?(R(""),!0):(R("Only letters, numbers, -, _ and ."),!1):(R("Name is required"),!1),v=async t=>{const s=await fetch(`/api/combos/${o}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!s.ok){const a=await s.json();return alert(a.error||"Failed to save"),!1}return!0},oe=async()=>{if(!F(N)||N===r.name)return;await v({name:N})&&await H()},re=async t=>{const s=(t==null?void 0:t.value)||t;if(!s||m.includes(s))return;const a=[...m,s];j(a),await v({models:a})},le=async t=>{const s=(t==null?void 0:t.value)||t;if(!s||!m.includes(s))return;const a=m.filter(n=>n!==s);j(a),await v({models:a})},ie=async t=>{const s=m.filter((a,n)=>n!==t);j(s),await v({models:s})},J=async(t,s)=>{const a=[...m],n=t+s;n<0||n>=a.length||([a[t],a[n]]=[a[n],a[t]],j(a),await v({models:a}))},ce=async t=>{$(t);const s=await fetch("/api/settings",{cache:"no-store"}),n={...(s.ok?await s.json():{}).comboStrategies||{}};t?n[r.name]={fallbackStrategy:"round-robin"}:delete n[r.name],await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({comboStrategies:n})})},de=async()=>{if(!confirm(`Delete combo "${r.name}"?`))return;(await fetch(`/api/combos/${o}`,{method:"DELETE"})).ok&&g(X(r.kind))},me=async()=>{var s,a,n;if(B(!0),w(null),E(""),l!=null&&l.audioUrl)try{URL.revokeObjectURL(l.audioUrl)}catch{}if((s=l==null?void 0:l.imageUrl)!=null&&s.startsWith("blob:"))try{URL.revokeObjectURL(l.imageUrl)}catch{}const t=Date.now();try{const i=V[r.kind],k=L[r.kind](r.name),y={"Content-Type":"application/json"};U&&(y.Authorization=`Bearer ${U}`);const x=await fetch(`/api${i}`,{method:"POST",headers:y,body:JSON.stringify(k)}),p=Date.now()-t;if(!x.ok){const d=await x.json().catch(()=>({}));E(((a=d==null?void 0:d.error)==null?void 0:a.message)||(d==null?void 0:d.error)||`HTTP ${x.status}`),w({json:JSON.stringify(d,null,2),latencyMs:p});return}const h=x.headers.get("content-type")||"";if(h.startsWith("image/")){const d=await x.blob();w({imageUrl:URL.createObjectURL(d),latencyMs:p});return}if(h.startsWith("audio/")||h==="application/octet-stream"){const d=await x.blob();w({audioUrl:URL.createObjectURL(d),latencyMs:p});return}const f=await x.json(),u=(n=f==null?void 0:f.data)==null?void 0:n[0],b=u!=null&&u.b64_json?`data:image/png;base64,${u.b64_json}`:(u==null?void 0:u.url)||"";w({json:JSON.stringify(C(f),null,2),imageUrl:b,latencyMs:p})}catch(i){E(i.message||"Network error")}B(!1)};function C(t){if(!t||typeof t!="object")return t;if(Array.isArray(t))return t.map(C);const s={};for(const[a,n]of Object.entries(t))s[a]=a==="b64_json"&&typeof n=="string"&&n.length>100?`<${n.length} chars base64>`:C(n);return s}if(q)return e.jsx("div",{className:"text-text-muted text-sm",children:"Loading..."});if(!r)return null;const W=Ee[r.kind]||((K=pe.find(t=>t.id===r.kind))==null?void 0:K.label)||"Combo",T=V[r.kind],xe=r.kind&&L[r.kind]?L[r.kind](r.name):null,he=T?`curl -X POST ${fe()}${T} \\
2
2
  -H "Content-Type: application/json" \\
3
3
  -H "Authorization: Bearer ${U||"YOUR_KEY"}" \\
4
4
  -d '${JSON.stringify(xe)}'`:"",ue=X(r.kind);return e.jsxs("div",{className:"flex flex-col gap-6",children:[e.jsxs("div",{className:"flex flex-col gap-4 sm:flex-row sm:items-center sm:justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[e.jsx(ve,{to:ue,className:"text-text-muted hover:text-primary",children:e.jsx("span",{className:"material-symbols-outlined",children:"arrow_back"})}),e.jsx("div",{className:"size-10 rounded-lg bg-primary/10 flex items-center justify-center",children:e.jsx("span",{className:"material-symbols-outlined text-primary",children:"layers"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsxs("p",{className:"text-xs text-text-muted",children:[W," Combo"]}),e.jsx("code",{className:"text-lg font-semibold font-mono",children:r.name})]})]}),e.jsx(A,{variant:"outline",icon:"delete",onClick:de,className:"text-red-500 border-red-200 hover:bg-red-50",children:"Delete"})]}),e.jsxs(S,{children:[e.jsx("h2",{className:"text-lg font-semibold mb-3",children:"Settings"}),e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsxs("div",{children:[e.jsx(ye,{label:"Combo Name",value:N,onChange:t=>{_(t.target.value),F(t.target.value)},onBlur:oe,error:G}),e.jsx("p",{className:"text-[10px] text-text-muted mt-0.5",children:"Only letters, numbers, -, _ and ."})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:"Round Robin"}),e.jsx("p",{className:"text-xs text-text-muted",children:"Rotate providers across requests instead of strict fallback order."})]}),e.jsx(Ne,{checked:Y,onChange:ce})]})]})]}),e.jsxs(S,{children:[e.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between mb-3",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-semibold",children:"Providers"}),e.jsx("p",{className:"text-xs text-text-muted",children:"Tried in order (top-down) or rotated when round-robin is on."})]}),e.jsx(A,{size:"sm",icon:"add",onClick:()=>M(!0),children:"Add Provider"})]}),m.length===0?e.jsx("div",{className:"text-center py-6 border border-dashed border-border rounded-lg text-text-muted text-sm",children:"No providers yet."}):e.jsx("div",{className:"flex flex-col gap-2",children:m.map((t,s)=>{const{providerId:a,model:n}=Se(t),i=ge[a];return e.jsxs("div",{className:"flex items-center gap-3 p-2 rounded-lg bg-black/[0.02] dark:bg-white/[0.02]",children:[e.jsx("span",{className:"text-xs text-text-muted w-5 text-center",children:s+1}),e.jsx(be,{src:`/providers/${a}.png`,alt:(i==null?void 0:i.name)||a,size:24,className:"object-contain rounded shrink-0",fallbackText:(i==null?void 0:i.textIcon)||a.slice(0,2).toUpperCase(),fallbackColor:i==null?void 0:i.color}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"text-sm font-medium truncate",children:(i==null?void 0:i.name)||a}),n&&e.jsx("code",{className:"text-[10px] text-text-muted font-mono truncate block",children:n})]}),e.jsxs("div",{className:"flex items-center gap-0.5",children:[e.jsx("button",{onClick:()=>J(s,-1),disabled:s===0,className:`p-1 rounded ${s===0?"text-text-muted/20":"text-text-muted hover:text-primary hover:bg-black/5"}`,title:"Move up",children:e.jsx("span",{className:"material-symbols-outlined text-[16px]",children:"arrow_upward"})}),e.jsx("button",{onClick:()=>J(s,1),disabled:s===m.length-1,className:`p-1 rounded ${s===m.length-1?"text-text-muted/20":"text-text-muted hover:text-primary hover:bg-black/5"}`,title:"Move down",children:e.jsx("span",{className:"material-symbols-outlined text-[16px]",children:"arrow_downward"})}),e.jsx("button",{onClick:()=>ie(s),className:"p-1 rounded text-text-muted hover:text-red-500 hover:bg-red-500/10",title:"Remove",children:e.jsx("span",{className:"material-symbols-outlined text-[16px]",children:"close"})})]})]},`${t}-${s}`)})})]}),r.kind&&T&&e.jsxs(S,{children:[e.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between mb-3",children:[e.jsx("h2",{className:"text-lg font-semibold",children:"Test Example"}),e.jsx(A,{size:"sm",icon:"play_arrow",onClick:me,disabled:I||m.length===0,children:I?"Running...":"Run"})]}),e.jsx("pre",{className:"text-xs font-mono bg-black/[0.03] dark:bg-white/[0.03] p-3 rounded-lg overflow-x-auto whitespace-pre-wrap break-all",children:he}),z&&e.jsx("p",{className:"mt-3 text-xs text-red-500 break-words",children:z}),l&&e.jsxs("div",{className:"mt-3 flex flex-col gap-3",children:[l.latencyMs!=null&&e.jsxs("span",{className:"text-[11px] text-text-muted",children:["⚡ ",l.latencyMs,"ms"]}),l.imageUrl&&e.jsxs("div",{children:[e.jsx("div",{className:"flex items-center justify-end mb-1.5",children:e.jsxs("a",{href:l.imageUrl,download:"image.png",className:"inline-flex items-center gap-1 text-xs text-text-muted hover:text-primary transition-colors",children:[e.jsx("span",{className:"material-symbols-outlined text-[14px]",children:"download"}),"Download"]})}),e.jsx("img",{src:l.imageUrl,alt:"Generated",className:"max-w-full rounded-lg border border-border"})]}),l.audioUrl&&e.jsxs("div",{children:[e.jsx("div",{className:"flex items-center justify-end mb-1.5",children:e.jsxs("a",{href:l.audioUrl,download:"speech.mp3",className:"inline-flex items-center gap-1 text-xs text-text-muted hover:text-primary transition-colors",children:[e.jsx("span",{className:"material-symbols-outlined text-[14px]",children:"download"}),"Download"]})}),e.jsx("audio",{controls:!0,src:l.audioUrl,className:"w-full"})]}),l.json&&e.jsx("pre",{className:"text-xs font-mono bg-black/[0.03] dark:bg-white/[0.03] p-3 rounded-lg overflow-auto max-h-[300px] whitespace-pre-wrap break-all",children:l.json})]})]}),e.jsxs(S,{children:[e.jsx("h2",{className:"text-lg font-semibold mb-3",children:"Usage Logs"}),D.length===0?e.jsx("p",{className:"text-xs text-text-muted italic",children:"No usage yet."}):e.jsx("pre",{className:"text-[11px] font-mono bg-black/[0.03] dark:bg-white/[0.03] p-3 rounded-lg overflow-auto max-h-[400px] whitespace-pre-wrap",children:D.join(`
@@ -1 +1 @@
1
- import{j as e}from"./index.CShjRV_B.js";import{L as m,b as i}from"./router.Cjj1--8t.js";import{g as u}from"./machine.CagOtseJ.js";import{C as d}from"./NoAuthProxyCard.qAv57b-0.js";import{C as r}from"./Loading.Bj-WGl4k.js";import{C as p,M as h}from"./cliTools.CsdwAybi.js";import"./zustand.akaTi5uX.js";function f({tool:s}){return e.jsx(m,{to:"/dashboard/mitm",className:"block",children:e.jsx(d,{padding:"sm",className:"overflow-hidden hover:border-primary/50 transition-colors cursor-pointer",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("img",{src:s.image,alt:s.name,width:32,height:32,className:"size-8 object-contain rounded-lg",onError:t=>{t.target.style.display="none"}}),e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h3",{className:"font-medium text-sm",children:s.name}),e.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"})]}),e.jsx("p",{className:"text-xs text-text-muted truncate",children:s.description})]})]}),e.jsx("span",{className:"material-symbols-outlined text-text-muted text-[20px]",children:"chevron_right"})]})})})}function j(s){return s?s.installed?s.hasFSRouter?{label:"Connected",cls:"bg-green-500/10 text-green-600 dark:text-green-400"}:{label:"Not configured",cls:"bg-yellow-500/10 text-yellow-600 dark:text-yellow-400"}:{label:"Not installed",cls:"bg-gray-500/10 text-gray-500"}:{label:"Unknown",cls:"bg-gray-500/10 text-gray-500"}}function N({toolId:s,tool:t,status:c}){const n=j(c);return e.jsx(m,{to:`/dashboard/cli-tools/${s}`,className:"block",children:e.jsx(d,{padding:"sm",className:"h-full overflow-hidden hover:border-primary/50 transition-colors cursor-pointer",children:e.jsx("div",{className:"flex h-full flex-col gap-2",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"size-8 flex items-center justify-center shrink-0",children:t.image?e.jsx("img",{src:t.image,alt:t.name,width:32,height:32,className:"size-8 object-contain rounded-lg",sizes:"32px",onError:o=>{o.target.style.display="none"}}):t.icon?e.jsx("span",{className:"material-symbols-outlined text-[28px]",style:{color:t.color},children:t.icon}):null}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("h3",{className:"font-medium text-sm truncate",children:t.name}),e.jsx("span",{className:`inline-block mt-1 px-1.5 py-0.5 text-[10px] font-medium rounded-full ${n.cls}`,children:n.label})]}),e.jsx("span",{className:"material-symbols-outlined text-text-muted text-[18px] shrink-0",children:"chevron_right"})]})})})})}const b="/api/cli-tools/all-statuses";function y({machineId:s}){const[t,c]=i.useState(!0),[n,o]=i.useState({});if(i.useEffect(()=>{let a=!0;return(async()=>{try{const l=await fetch(b);l.ok&&a&&o(await l.json())}catch(l){console.log("Error fetching tool statuses:",l)}finally{a&&c(!1)}})(),()=>{a=!1}},[]),t)return e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-3 sm:gap-4",children:[e.jsx(r,{}),e.jsx(r,{}),e.jsx(r,{}),e.jsx(r,{}),e.jsx(r,{}),e.jsx(r,{})]});const x=Object.entries(p),g=Object.entries(h);return e.jsxs("div",{className:"mx-auto flex w-full max-w-5xl flex-col gap-6 px-1 sm:px-0",children:[e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-3 sm:gap-4",children:x.map(([a,l])=>e.jsx(N,{toolId:a,tool:l,status:n[a]},a))}),e.jsxs("div",{className:"flex flex-col gap-3 sm:gap-4",children:[e.jsxs("div",{className:"flex items-center gap-2 px-1",children:[e.jsx("span",{className:"material-symbols-outlined text-[18px] text-primary",children:"security"}),e.jsx("h2",{className:"text-sm font-semibold text-text-main",children:"MITM Tools"})]}),e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-3 sm:gap-4",children:g.map(([a,l])=>e.jsx(f,{tool:l},a))})]})]})}function M(){const[s,t]=i.useState("");return i.useEffect(()=>{u().then(t)},[]),s?e.jsx(y,{machineId:s}):null}export{M as default};
1
+ import{j as e}from"./index.Be3gbrBl.js";import{L as m,b as i}from"./router.Cjj1--8t.js";import{g as u}from"./machine.CagOtseJ.js";import{C as d}from"./NoAuthProxyCard.BDcXaWvM.js";import{C as r}from"./Loading.BHPtQ9vj.js";import{C as p,M as h}from"./cliTools.CsdwAybi.js";import"./zustand.akaTi5uX.js";function f({tool:s}){return e.jsx(m,{to:"/dashboard/mitm",className:"block",children:e.jsx(d,{padding:"sm",className:"overflow-hidden hover:border-primary/50 transition-colors cursor-pointer",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("img",{src:s.image,alt:s.name,width:32,height:32,className:"size-8 object-contain rounded-lg",onError:t=>{t.target.style.display="none"}}),e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h3",{className:"font-medium text-sm",children:s.name}),e.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"})]}),e.jsx("p",{className:"text-xs text-text-muted truncate",children:s.description})]})]}),e.jsx("span",{className:"material-symbols-outlined text-text-muted text-[20px]",children:"chevron_right"})]})})})}function j(s){return s?s.installed?s.hasFSRouter?{label:"Connected",cls:"bg-green-500/10 text-green-600 dark:text-green-400"}:{label:"Not configured",cls:"bg-yellow-500/10 text-yellow-600 dark:text-yellow-400"}:{label:"Not installed",cls:"bg-gray-500/10 text-gray-500"}:{label:"Unknown",cls:"bg-gray-500/10 text-gray-500"}}function N({toolId:s,tool:t,status:c}){const n=j(c);return e.jsx(m,{to:`/dashboard/cli-tools/${s}`,className:"block",children:e.jsx(d,{padding:"sm",className:"h-full overflow-hidden hover:border-primary/50 transition-colors cursor-pointer",children:e.jsx("div",{className:"flex h-full flex-col gap-2",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"size-8 flex items-center justify-center shrink-0",children:t.image?e.jsx("img",{src:t.image,alt:t.name,width:32,height:32,className:"size-8 object-contain rounded-lg",sizes:"32px",onError:o=>{o.target.style.display="none"}}):t.icon?e.jsx("span",{className:"material-symbols-outlined text-[28px]",style:{color:t.color},children:t.icon}):null}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("h3",{className:"font-medium text-sm truncate",children:t.name}),e.jsx("span",{className:`inline-block mt-1 px-1.5 py-0.5 text-[10px] font-medium rounded-full ${n.cls}`,children:n.label})]}),e.jsx("span",{className:"material-symbols-outlined text-text-muted text-[18px] shrink-0",children:"chevron_right"})]})})})})}const b="/api/cli-tools/all-statuses";function y({machineId:s}){const[t,c]=i.useState(!0),[n,o]=i.useState({});if(i.useEffect(()=>{let a=!0;return(async()=>{try{const l=await fetch(b);l.ok&&a&&o(await l.json())}catch(l){console.log("Error fetching tool statuses:",l)}finally{a&&c(!1)}})(),()=>{a=!1}},[]),t)return e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-3 sm:gap-4",children:[e.jsx(r,{}),e.jsx(r,{}),e.jsx(r,{}),e.jsx(r,{}),e.jsx(r,{}),e.jsx(r,{})]});const x=Object.entries(p),g=Object.entries(h);return e.jsxs("div",{className:"mx-auto flex w-full max-w-5xl flex-col gap-6 px-1 sm:px-0",children:[e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-3 sm:gap-4",children:x.map(([a,l])=>e.jsx(N,{toolId:a,tool:l,status:n[a]},a))}),e.jsxs("div",{className:"flex flex-col gap-3 sm:gap-4",children:[e.jsxs("div",{className:"flex items-center gap-2 px-1",children:[e.jsx("span",{className:"material-symbols-outlined text-[18px] text-primary",children:"security"}),e.jsx("h2",{className:"text-sm font-semibold text-text-main",children:"MITM Tools"})]}),e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-3 sm:gap-4",children:g.map(([a,l])=>e.jsx(f,{tool:l},a))})]})]})}function M(){const[s,t]=i.useState("");return i.useEffect(()=>{u().then(t)},[]),s?e.jsx(y,{machineId:s}):null}export{M as default};
@@ -1 +1 @@
1
- import{j as e}from"./index.CShjRV_B.js";import{b as n,f as h}from"./router.Cjj1--8t.js";import"./zustand.akaTi5uX.js";function u(){const[s]=h(),[a,l]=n.useState("processing");return n.useEffect(()=>{const r=s.get("code"),i=s.get("state"),o=s.get("error"),d=s.get("error_description"),c={code:r,state:i,error:o,errorDescription:d,fullUrl:window.location.href},m=[window.location.origin,"http://localhost:1455","http://localhost:51121"];if(window.opener)for(const t of m)try{window.opener.postMessage({type:"oauth_callback",data:c},t)}catch(x){console.log("postMessage failed:",x)}try{const t=new BroadcastChannel("oauth_callback");t.postMessage(c),t.close()}catch(t){console.log("BroadcastChannel failed:",t)}try{localStorage.setItem("oauth_callback",JSON.stringify({...c,timestamp:Date.now()}))}catch(t){console.log("localStorage failed:",t)}if(!(r||o)){setTimeout(()=>l("manual"),0);return}l("success"),setTimeout(()=>{window.close(),setTimeout(()=>l("done"),500)},1500)},[s]),e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-bg",children:e.jsxs("div",{className:"text-center p-8 max-w-md",children:[a==="processing"&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"w-16 h-16 mx-auto mb-4 rounded-full bg-primary/10 flex items-center justify-center",children:e.jsx("span",{className:"material-symbols-outlined text-3xl text-primary animate-spin",children:"progress_activity"})}),e.jsx("h1",{className:"text-xl font-semibold mb-2",children:"Processing..."}),e.jsx("p",{className:"text-text-muted",children:"Please wait while we complete the authorization."})]}),(a==="success"||a==="done")&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"w-16 h-16 mx-auto mb-4 rounded-full bg-green-100 dark:bg-green-900/30 flex items-center justify-center",children:e.jsx("span",{className:"material-symbols-outlined text-3xl text-green-600",children:"check_circle"})}),e.jsx("h1",{className:"text-xl font-semibold mb-2",children:"Authorization Successful!"}),e.jsx("p",{className:"text-text-muted",children:a==="success"?"This window will close automatically...":"You can close this tab now."})]}),a==="manual"&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"w-16 h-16 mx-auto mb-4 rounded-full bg-yellow-100 dark:bg-yellow-900/30 flex items-center justify-center",children:e.jsx("span",{className:"material-symbols-outlined text-3xl text-yellow-600",children:"info"})}),e.jsx("h1",{className:"text-xl font-semibold mb-2",children:"Copy This URL"}),e.jsx("p",{className:"text-text-muted mb-4",children:"Please copy the URL from the address bar and paste it in the application."}),e.jsx("div",{className:"bg-surface border border-border rounded-lg p-3 text-left",children:e.jsx("code",{className:"text-xs break-all",children:typeof window<"u"?window.location.href:""})})]})]})})}function b(){return e.jsx(n.Suspense,{fallback:e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-bg",children:e.jsxs("div",{className:"text-center p-8",children:[e.jsx("div",{className:"w-16 h-16 mx-auto mb-4 rounded-full bg-primary/10 flex items-center justify-center",children:e.jsx("span",{className:"material-symbols-outlined text-3xl text-primary animate-spin",children:"progress_activity"})}),e.jsx("p",{className:"text-text-muted",children:"Loading..."})]})}),children:e.jsx(u,{})})}export{b as default};
1
+ import{j as e}from"./index.Be3gbrBl.js";import{b as n,f as h}from"./router.Cjj1--8t.js";import"./zustand.akaTi5uX.js";function u(){const[s]=h(),[a,l]=n.useState("processing");return n.useEffect(()=>{const r=s.get("code"),i=s.get("state"),o=s.get("error"),d=s.get("error_description"),c={code:r,state:i,error:o,errorDescription:d,fullUrl:window.location.href},m=[window.location.origin,"http://localhost:1455","http://localhost:51121"];if(window.opener)for(const t of m)try{window.opener.postMessage({type:"oauth_callback",data:c},t)}catch(x){console.log("postMessage failed:",x)}try{const t=new BroadcastChannel("oauth_callback");t.postMessage(c),t.close()}catch(t){console.log("BroadcastChannel failed:",t)}try{localStorage.setItem("oauth_callback",JSON.stringify({...c,timestamp:Date.now()}))}catch(t){console.log("localStorage failed:",t)}if(!(r||o)){setTimeout(()=>l("manual"),0);return}l("success"),setTimeout(()=>{window.close(),setTimeout(()=>l("done"),500)},1500)},[s]),e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-bg",children:e.jsxs("div",{className:"text-center p-8 max-w-md",children:[a==="processing"&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"w-16 h-16 mx-auto mb-4 rounded-full bg-primary/10 flex items-center justify-center",children:e.jsx("span",{className:"material-symbols-outlined text-3xl text-primary animate-spin",children:"progress_activity"})}),e.jsx("h1",{className:"text-xl font-semibold mb-2",children:"Processing..."}),e.jsx("p",{className:"text-text-muted",children:"Please wait while we complete the authorization."})]}),(a==="success"||a==="done")&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"w-16 h-16 mx-auto mb-4 rounded-full bg-green-100 dark:bg-green-900/30 flex items-center justify-center",children:e.jsx("span",{className:"material-symbols-outlined text-3xl text-green-600",children:"check_circle"})}),e.jsx("h1",{className:"text-xl font-semibold mb-2",children:"Authorization Successful!"}),e.jsx("p",{className:"text-text-muted",children:a==="success"?"This window will close automatically...":"You can close this tab now."})]}),a==="manual"&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"w-16 h-16 mx-auto mb-4 rounded-full bg-yellow-100 dark:bg-yellow-900/30 flex items-center justify-center",children:e.jsx("span",{className:"material-symbols-outlined text-3xl text-yellow-600",children:"info"})}),e.jsx("h1",{className:"text-xl font-semibold mb-2",children:"Copy This URL"}),e.jsx("p",{className:"text-text-muted mb-4",children:"Please copy the URL from the address bar and paste it in the application."}),e.jsx("div",{className:"bg-surface border border-border rounded-lg p-3 text-left",children:e.jsx("code",{className:"text-xs break-all",children:typeof window<"u"?window.location.href:""})})]})]})})}function b(){return e.jsx(n.Suspense,{fallback:e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-bg",children:e.jsxs("div",{className:"text-center p-8",children:[e.jsx("div",{className:"w-16 h-16 mx-auto mb-4 rounded-full bg-primary/10 flex items-center justify-center",children:e.jsx("span",{className:"material-symbols-outlined text-3xl text-primary animate-spin",children:"progress_activity"})}),e.jsx("p",{className:"text-text-muted",children:"Loading..."})]})}),children:e.jsx(u,{})})}export{b as default};
@@ -1 +1 @@
1
- import{j as e}from"./index.CShjRV_B.js";import{b as r}from"./router.Cjj1--8t.js";import{C as j}from"./Loading.Bj-WGl4k.js";import"./zustand.akaTi5uX.js";function P(){return e.jsx(r.Suspense,{fallback:e.jsx(j,{}),children:e.jsx(y,{})})}function y(){const[a,h]=r.useState([]),[p,b]=r.useState(!0),[s,f]=r.useState(""),[o,n]=r.useState(null),[i,d]=r.useState(!1),[l,c]=r.useState(""),[x,m]=r.useState(null);r.useEffect(()=>{fetch("/api/media-providers/webSearch").then(t=>t.json()).then(t=>{h(Array.isArray(t)?t:[]),t.length>0&&c(t[0].id)}).catch(()=>{}).finally(()=>b(!1))},[]);const u=async()=>{if(s.trim()){d(!0),m(null),n(null);try{const t=await fetch("/api/media/webSearch",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({query:s,providerId:l||void 0})});if(!t.ok)throw new Error(`HTTP ${t.status}`);const g=await t.json();n(g)}catch(t){m(t.message)}finally{d(!1)}}};return e.jsxs("div",{className:"flex min-w-0 flex-col gap-6 px-1 sm:px-0",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:"material-symbols-outlined text-[28px] text-primary",children:"search"}),e.jsx("h1",{className:"text-xl font-semibold text-text-main",children:"Search"})]}),e.jsxs("div",{className:"rounded-xl border border-border-subtle bg-surface p-4",children:[e.jsx("h2",{className:"text-sm font-semibold text-text-main mb-3",children:"Search Providers"}),p?e.jsx("p",{className:"text-xs text-text-muted",children:"Loading providers..."}):a.length===0?e.jsx("p",{className:"text-xs text-text-muted",children:"No search providers configured. Add one in Media Providers."}):e.jsx("div",{className:"flex flex-wrap gap-2",children:a.map(t=>e.jsx("button",{onClick:()=>c(t.id),className:`px-3 py-1.5 rounded-lg text-xs font-medium transition-colors cursor-pointer ${l===t.id?"bg-primary/10 text-primary border border-primary/30":"bg-surface-2 text-text-muted hover:text-text-main border border-transparent"}`,children:t.name||t.id},t.id))})]}),e.jsxs("div",{className:"rounded-xl border border-border-subtle bg-surface p-4",children:[e.jsx("h2",{className:"text-sm font-semibold text-text-main mb-3",children:"Test Search"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{type:"text",value:s,onChange:t=>f(t.target.value),onKeyDown:t=>t.key==="Enter"&&u(),placeholder:"Enter search query...",className:"flex-1 rounded-lg border border-border-subtle bg-surface-2 px-3 py-2 text-sm text-text-main placeholder:text-text-muted/50 focus:outline-none focus:ring-1 focus:ring-primary/50"}),e.jsx("button",{onClick:u,disabled:i||!s.trim(),className:"px-4 py-2 rounded-lg bg-primary text-white text-sm font-medium hover:bg-primary/90 disabled:opacity-50 transition-colors cursor-pointer",children:i?"Searching...":"Search"})]})]}),x&&e.jsx("div",{className:"rounded-xl border border-red-500/30 bg-red-500/10 p-4",children:e.jsx("p",{className:"text-sm text-red-400",children:x})}),o&&e.jsxs("div",{className:"rounded-xl border border-border-subtle bg-surface p-4",children:[e.jsx("h2",{className:"text-sm font-semibold text-text-main mb-3",children:"Results"}),e.jsx("pre",{className:"text-xs text-text-muted overflow-auto max-h-96 bg-surface-2 rounded-lg p-3 font-mono whitespace-pre-wrap",children:JSON.stringify(o,null,2)})]})]})}export{P as default};
1
+ import{j as e}from"./index.Be3gbrBl.js";import{b as r}from"./router.Cjj1--8t.js";import{C as j}from"./Loading.BHPtQ9vj.js";import"./zustand.akaTi5uX.js";function P(){return e.jsx(r.Suspense,{fallback:e.jsx(j,{}),children:e.jsx(y,{})})}function y(){const[a,h]=r.useState([]),[p,b]=r.useState(!0),[s,f]=r.useState(""),[o,n]=r.useState(null),[i,d]=r.useState(!1),[l,c]=r.useState(""),[x,m]=r.useState(null);r.useEffect(()=>{fetch("/api/media-providers/webSearch").then(t=>t.json()).then(t=>{h(Array.isArray(t)?t:[]),t.length>0&&c(t[0].id)}).catch(()=>{}).finally(()=>b(!1))},[]);const u=async()=>{if(s.trim()){d(!0),m(null),n(null);try{const t=await fetch("/api/media/webSearch",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({query:s,providerId:l||void 0})});if(!t.ok)throw new Error(`HTTP ${t.status}`);const g=await t.json();n(g)}catch(t){m(t.message)}finally{d(!1)}}};return e.jsxs("div",{className:"flex min-w-0 flex-col gap-6 px-1 sm:px-0",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:"material-symbols-outlined text-[28px] text-primary",children:"search"}),e.jsx("h1",{className:"text-xl font-semibold text-text-main",children:"Search"})]}),e.jsxs("div",{className:"rounded-xl border border-border-subtle bg-surface p-4",children:[e.jsx("h2",{className:"text-sm font-semibold text-text-main mb-3",children:"Search Providers"}),p?e.jsx("p",{className:"text-xs text-text-muted",children:"Loading providers..."}):a.length===0?e.jsx("p",{className:"text-xs text-text-muted",children:"No search providers configured. Add one in Media Providers."}):e.jsx("div",{className:"flex flex-wrap gap-2",children:a.map(t=>e.jsx("button",{onClick:()=>c(t.id),className:`px-3 py-1.5 rounded-lg text-xs font-medium transition-colors cursor-pointer ${l===t.id?"bg-primary/10 text-primary border border-primary/30":"bg-surface-2 text-text-muted hover:text-text-main border border-transparent"}`,children:t.name||t.id},t.id))})]}),e.jsxs("div",{className:"rounded-xl border border-border-subtle bg-surface p-4",children:[e.jsx("h2",{className:"text-sm font-semibold text-text-main mb-3",children:"Test Search"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{type:"text",value:s,onChange:t=>f(t.target.value),onKeyDown:t=>t.key==="Enter"&&u(),placeholder:"Enter search query...",className:"flex-1 rounded-lg border border-border-subtle bg-surface-2 px-3 py-2 text-sm text-text-main placeholder:text-text-muted/50 focus:outline-none focus:ring-1 focus:ring-primary/50"}),e.jsx("button",{onClick:u,disabled:i||!s.trim(),className:"px-4 py-2 rounded-lg bg-primary text-white text-sm font-medium hover:bg-primary/90 disabled:opacity-50 transition-colors cursor-pointer",children:i?"Searching...":"Search"})]})]}),x&&e.jsx("div",{className:"rounded-xl border border-red-500/30 bg-red-500/10 p-4",children:e.jsx("p",{className:"text-sm text-red-400",children:x})}),o&&e.jsxs("div",{className:"rounded-xl border border-border-subtle bg-surface p-4",children:[e.jsx("h2",{className:"text-sm font-semibold text-text-main mb-3",children:"Results"}),e.jsx("pre",{className:"text-xs text-text-muted overflow-auto max-h-96 bg-surface-2 rounded-lg p-3 font-mono whitespace-pre-wrap",children:JSON.stringify(o,null,2)})]})]})}export{P as default};
@@ -1,4 +1,4 @@
1
- import{u as On,j as f,B as Je,C as Ln,p as Jt,s as Qt,q as Zt,P as en,M as zn}from"./index.CShjRV_B.js";import{b as l,W as U,c as Te}from"./router.Cjj1--8t.js";import{C as tn,I as Pn,M as Bn}from"./NoAuthProxyCard.qAv57b-0.js";import{C as Lt}from"./Loading.Bj-WGl4k.js";import"./zustand.akaTi5uX.js";function $n(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return l.useMemo(()=>r=>{t.forEach(o=>o(r))},t)}const nt=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function De(e){const t=Object.prototype.toString.call(e);return t==="[object Window]"||t==="[object global]"}function bt(e){return"nodeType"in e}function X(e){var t,n;return e?De(e)?e:bt(e)&&(t=(n=e.ownerDocument)==null?void 0:n.defaultView)!=null?t:window:window}function xt(e){const{Document:t}=X(e);return e instanceof t}function Ue(e){return De(e)?!1:e instanceof X(e).HTMLElement}function nn(e){return e instanceof X(e).SVGElement}function Re(e){return e?De(e)?e.document:bt(e)?xt(e)?e:Ue(e)||nn(e)?e.ownerDocument:document:document:document}const re=nt?l.useLayoutEffect:l.useEffect;function yt(e){const t=l.useRef(e);return re(()=>{t.current=e}),l.useCallback(function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return t.current==null?void 0:t.current(...r)},[])}function Fn(){const e=l.useRef(null),t=l.useCallback((r,o)=>{e.current=setInterval(r,o)},[]),n=l.useCallback(()=>{e.current!==null&&(clearInterval(e.current),e.current=null)},[]);return[t,n]}function Pe(e,t){t===void 0&&(t=[e]);const n=l.useRef(e);return re(()=>{n.current!==e&&(n.current=e)},t),n}function Xe(e,t){const n=l.useRef();return l.useMemo(()=>{const r=e(n.current);return n.current=r,r},[...t])}function Qe(e){const t=yt(e),n=l.useRef(null),r=l.useCallback(o=>{o!==n.current&&(t==null||t(o,n.current)),n.current=o},[]);return[n,r]}function ht(e){const t=l.useRef();return l.useEffect(()=>{t.current=e},[e]),t.current}let ct={};function We(e,t){return l.useMemo(()=>{if(t)return t;const n=ct[e]==null?0:ct[e]+1;return ct[e]=n,e+"-"+n},[e,t])}function rn(e){return function(t){for(var n=arguments.length,r=new Array(n>1?n-1:0),o=1;o<n;o++)r[o-1]=arguments[o];return r.reduce((s,i)=>{const a=Object.entries(i);for(const[c,d]of a){const h=s[c];h!=null&&(s[c]=h+e*d)}return s},{...t})}}const Se=rn(1),Be=rn(-1);function Un(e){return"clientX"in e&&"clientY"in e}function wt(e){if(!e)return!1;const{KeyboardEvent:t}=X(e.target);return t&&e instanceof t}function Xn(e){if(!e)return!1;const{TouchEvent:t}=X(e.target);return t&&e instanceof t}function gt(e){if(Xn(e)){if(e.touches&&e.touches.length){const{clientX:t,clientY:n}=e.touches[0];return{x:t,y:n}}else if(e.changedTouches&&e.changedTouches.length){const{clientX:t,clientY:n}=e.changedTouches[0];return{x:t,y:n}}}return Un(e)?{x:e.clientX,y:e.clientY}:null}const $e=Object.freeze({Translate:{toString(e){if(!e)return;const{x:t,y:n}=e;return"translate3d("+(t?Math.round(t):0)+"px, "+(n?Math.round(n):0)+"px, 0)"}},Scale:{toString(e){if(!e)return;const{scaleX:t,scaleY:n}=e;return"scaleX("+t+") scaleY("+n+")"}},Transform:{toString(e){if(e)return[$e.Translate.toString(e),$e.Scale.toString(e)].join(" ")}},Transition:{toString(e){let{property:t,duration:n,easing:r}=e;return t+" "+n+"ms "+r}}}),zt="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function Wn(e){return e.matches(zt)?e:e.querySelector(zt)}const Yn={display:"none"};function Vn(e){let{id:t,value:n}=e;return U.createElement("div",{id:t,style:Yn},n)}function Hn(e){let{id:t,announcement:n,ariaLiveType:r="assertive"}=e;const o={position:"fixed",top:0,left:0,width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0 0 0 0)",clipPath:"inset(100%)",whiteSpace:"nowrap"};return U.createElement("div",{id:t,style:o,role:"status","aria-live":r,"aria-atomic":!0},n)}function Kn(){const[e,t]=l.useState("");return{announce:l.useCallback(r=>{r!=null&&t(r)},[]),announcement:e}}const on=l.createContext(null);function _n(e){const t=l.useContext(on);l.useEffect(()=>{if(!t)throw new Error("useDndMonitor must be used within a children of <DndContext>");return t(e)},[e,t])}function qn(){const[e]=l.useState(()=>new Set),t=l.useCallback(r=>(e.add(r),()=>e.delete(r)),[e]);return[l.useCallback(r=>{let{type:o,event:s}=r;e.forEach(i=>{var a;return(a=i[o])==null?void 0:a.call(i,s)})},[e]),t]}const Gn={draggable:`
1
+ import{u as On,j as f,B as Je,C as Ln,p as Jt,s as Qt,q as Zt,P as en,M as zn}from"./index.Be3gbrBl.js";import{b as l,W as U,c as Te}from"./router.Cjj1--8t.js";import{C as tn,I as Pn,M as Bn}from"./NoAuthProxyCard.BDcXaWvM.js";import{C as Lt}from"./Loading.BHPtQ9vj.js";import"./zustand.akaTi5uX.js";function $n(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return l.useMemo(()=>r=>{t.forEach(o=>o(r))},t)}const nt=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function De(e){const t=Object.prototype.toString.call(e);return t==="[object Window]"||t==="[object global]"}function bt(e){return"nodeType"in e}function X(e){var t,n;return e?De(e)?e:bt(e)&&(t=(n=e.ownerDocument)==null?void 0:n.defaultView)!=null?t:window:window}function xt(e){const{Document:t}=X(e);return e instanceof t}function Ue(e){return De(e)?!1:e instanceof X(e).HTMLElement}function nn(e){return e instanceof X(e).SVGElement}function Re(e){return e?De(e)?e.document:bt(e)?xt(e)?e:Ue(e)||nn(e)?e.ownerDocument:document:document:document}const re=nt?l.useLayoutEffect:l.useEffect;function yt(e){const t=l.useRef(e);return re(()=>{t.current=e}),l.useCallback(function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return t.current==null?void 0:t.current(...r)},[])}function Fn(){const e=l.useRef(null),t=l.useCallback((r,o)=>{e.current=setInterval(r,o)},[]),n=l.useCallback(()=>{e.current!==null&&(clearInterval(e.current),e.current=null)},[]);return[t,n]}function Pe(e,t){t===void 0&&(t=[e]);const n=l.useRef(e);return re(()=>{n.current!==e&&(n.current=e)},t),n}function Xe(e,t){const n=l.useRef();return l.useMemo(()=>{const r=e(n.current);return n.current=r,r},[...t])}function Qe(e){const t=yt(e),n=l.useRef(null),r=l.useCallback(o=>{o!==n.current&&(t==null||t(o,n.current)),n.current=o},[]);return[n,r]}function ht(e){const t=l.useRef();return l.useEffect(()=>{t.current=e},[e]),t.current}let ct={};function We(e,t){return l.useMemo(()=>{if(t)return t;const n=ct[e]==null?0:ct[e]+1;return ct[e]=n,e+"-"+n},[e,t])}function rn(e){return function(t){for(var n=arguments.length,r=new Array(n>1?n-1:0),o=1;o<n;o++)r[o-1]=arguments[o];return r.reduce((s,i)=>{const a=Object.entries(i);for(const[c,d]of a){const h=s[c];h!=null&&(s[c]=h+e*d)}return s},{...t})}}const Se=rn(1),Be=rn(-1);function Un(e){return"clientX"in e&&"clientY"in e}function wt(e){if(!e)return!1;const{KeyboardEvent:t}=X(e.target);return t&&e instanceof t}function Xn(e){if(!e)return!1;const{TouchEvent:t}=X(e.target);return t&&e instanceof t}function gt(e){if(Xn(e)){if(e.touches&&e.touches.length){const{clientX:t,clientY:n}=e.touches[0];return{x:t,y:n}}else if(e.changedTouches&&e.changedTouches.length){const{clientX:t,clientY:n}=e.changedTouches[0];return{x:t,y:n}}}return Un(e)?{x:e.clientX,y:e.clientY}:null}const $e=Object.freeze({Translate:{toString(e){if(!e)return;const{x:t,y:n}=e;return"translate3d("+(t?Math.round(t):0)+"px, "+(n?Math.round(n):0)+"px, 0)"}},Scale:{toString(e){if(!e)return;const{scaleX:t,scaleY:n}=e;return"scaleX("+t+") scaleY("+n+")"}},Transform:{toString(e){if(e)return[$e.Translate.toString(e),$e.Scale.toString(e)].join(" ")}},Transition:{toString(e){let{property:t,duration:n,easing:r}=e;return t+" "+n+"ms "+r}}}),zt="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function Wn(e){return e.matches(zt)?e:e.querySelector(zt)}const Yn={display:"none"};function Vn(e){let{id:t,value:n}=e;return U.createElement("div",{id:t,style:Yn},n)}function Hn(e){let{id:t,announcement:n,ariaLiveType:r="assertive"}=e;const o={position:"fixed",top:0,left:0,width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0 0 0 0)",clipPath:"inset(100%)",whiteSpace:"nowrap"};return U.createElement("div",{id:t,style:o,role:"status","aria-live":r,"aria-atomic":!0},n)}function Kn(){const[e,t]=l.useState("");return{announce:l.useCallback(r=>{r!=null&&t(r)},[]),announcement:e}}const on=l.createContext(null);function _n(e){const t=l.useContext(on);l.useEffect(()=>{if(!t)throw new Error("useDndMonitor must be used within a children of <DndContext>");return t(e)},[e,t])}function qn(){const[e]=l.useState(()=>new Set),t=l.useCallback(r=>(e.add(r),()=>e.delete(r)),[e]);return[l.useCallback(r=>{let{type:o,event:s}=r;e.forEach(i=>{var a;return(a=i[o])==null?void 0:a.call(i,s)})},[e]),t]}const Gn={draggable:`
2
2
  To pick up a draggable item, press the space bar.
3
3
  While dragging, use the arrow keys to move the item.
4
4
  Press space again to drop the item in its new position, or press escape to cancel.
@@ -1 +1 @@
1
- import{j as a}from"./index.CShjRV_B.js";import{b as e}from"./router.Cjj1--8t.js";import{g as m}from"./machine.CagOtseJ.js";import{A as c}from"./EndpointPageClient.LyNNvZ4z.js";import"./zustand.akaTi5uX.js";import"./NoAuthProxyCard.qAv57b-0.js";import"./Loading.Bj-WGl4k.js";function h(){const[i,s]=e.useState(null),[n,r]=e.useState(!0);return e.useEffect(()=>{let t=!0;return m().then(o=>{t&&(s(o),r(!1))}).catch(()=>{t&&r(!1)}),()=>{t=!1}},[]),n?a.jsx("div",{className:"text-text-muted text-sm py-12 text-center",children:"Loading..."}):a.jsx(c,{machineId:i})}export{h as default};
1
+ import{j as a}from"./index.Be3gbrBl.js";import{b as e}from"./router.Cjj1--8t.js";import{g as m}from"./machine.CagOtseJ.js";import{A as c}from"./EndpointPageClient.C2WMTYy0.js";import"./zustand.akaTi5uX.js";import"./NoAuthProxyCard.BDcXaWvM.js";import"./Loading.BHPtQ9vj.js";function h(){const[i,s]=e.useState(null),[n,r]=e.useState(!0);return e.useEffect(()=>{let t=!0;return m().then(o=>{t&&(s(o),r(!1))}).catch(()=>{t&&r(!1)}),()=>{t=!1}},[]),n?a.jsx("div",{className:"text-text-muted text-sm py-12 text-center",children:"Loading..."}):a.jsx(c,{machineId:i})}export{h as default};