@synthever/jrouter 1.0.0 → 1.0.2

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 (378) hide show
  1. package/app/.next-cli-build/BUILD_ID +1 -1
  2. package/app/.next-cli-build/app-path-routes-manifest.json +14 -14
  3. package/app/.next-cli-build/build-manifest.json +2 -2
  4. package/app/.next-cli-build/prerender-manifest.json +2 -2
  5. package/app/.next-cli-build/server/app/(dashboard)/dashboard/basic-chat/page_client-reference-manifest.js +1 -1
  6. package/app/.next-cli-build/server/app/(dashboard)/dashboard/cli-tools/[toolId]/page.js +1 -1
  7. package/app/.next-cli-build/server/app/(dashboard)/dashboard/cli-tools/[toolId]/page_client-reference-manifest.js +1 -1
  8. package/app/.next-cli-build/server/app/(dashboard)/dashboard/cli-tools/page.js +1 -1
  9. package/app/.next-cli-build/server/app/(dashboard)/dashboard/cli-tools/page_client-reference-manifest.js +1 -1
  10. package/app/.next-cli-build/server/app/(dashboard)/dashboard/combos/page_client-reference-manifest.js +1 -1
  11. package/app/.next-cli-build/server/app/(dashboard)/dashboard/console-log/page_client-reference-manifest.js +1 -1
  12. package/app/.next-cli-build/server/app/(dashboard)/dashboard/endpoint/page.js +1 -1
  13. package/app/.next-cli-build/server/app/(dashboard)/dashboard/endpoint/page_client-reference-manifest.js +1 -1
  14. package/app/.next-cli-build/server/app/(dashboard)/dashboard/health/page_client-reference-manifest.js +1 -1
  15. package/app/.next-cli-build/server/app/(dashboard)/dashboard/media-providers/[kind]/[id]/page_client-reference-manifest.js +1 -1
  16. package/app/.next-cli-build/server/app/(dashboard)/dashboard/media-providers/[kind]/page_client-reference-manifest.js +1 -1
  17. package/app/.next-cli-build/server/app/(dashboard)/dashboard/media-providers/combo/[id]/page_client-reference-manifest.js +1 -1
  18. package/app/.next-cli-build/server/app/(dashboard)/dashboard/media-providers/web/page_client-reference-manifest.js +1 -1
  19. package/app/.next-cli-build/server/app/(dashboard)/dashboard/mitm/page_client-reference-manifest.js +1 -1
  20. package/app/.next-cli-build/server/app/(dashboard)/dashboard/page.js +1 -1
  21. package/app/.next-cli-build/server/app/(dashboard)/dashboard/page_client-reference-manifest.js +1 -1
  22. package/app/.next-cli-build/server/app/(dashboard)/dashboard/playground/page_client-reference-manifest.js +1 -1
  23. package/app/.next-cli-build/server/app/(dashboard)/dashboard/profile/page.js +1 -1
  24. package/app/.next-cli-build/server/app/(dashboard)/dashboard/profile/page_client-reference-manifest.js +1 -1
  25. package/app/.next-cli-build/server/app/(dashboard)/dashboard/providers/[id]/page_client-reference-manifest.js +1 -1
  26. package/app/.next-cli-build/server/app/(dashboard)/dashboard/providers/new/page_client-reference-manifest.js +1 -1
  27. package/app/.next-cli-build/server/app/(dashboard)/dashboard/providers/page_client-reference-manifest.js +1 -1
  28. package/app/.next-cli-build/server/app/(dashboard)/dashboard/proxy-pools/page_client-reference-manifest.js +1 -1
  29. package/app/.next-cli-build/server/app/(dashboard)/dashboard/pxpipe/page_client-reference-manifest.js +1 -1
  30. package/app/.next-cli-build/server/app/(dashboard)/dashboard/quota/page_client-reference-manifest.js +1 -1
  31. package/app/.next-cli-build/server/app/(dashboard)/dashboard/skills/page.js +1 -1
  32. package/app/.next-cli-build/server/app/(dashboard)/dashboard/skills/page_client-reference-manifest.js +1 -1
  33. package/app/.next-cli-build/server/app/(dashboard)/dashboard/token-saver/page.js +1 -1
  34. package/app/.next-cli-build/server/app/(dashboard)/dashboard/token-saver/page_client-reference-manifest.js +1 -1
  35. package/app/.next-cli-build/server/app/(dashboard)/dashboard/translator/page_client-reference-manifest.js +1 -1
  36. package/app/.next-cli-build/server/app/(dashboard)/dashboard/usage/page_client-reference-manifest.js +1 -1
  37. package/app/.next-cli-build/server/app/_global-error/page_client-reference-manifest.js +1 -1
  38. package/app/.next-cli-build/server/app/_global-error.html +1 -1
  39. package/app/.next-cli-build/server/app/_global-error.rsc +1 -1
  40. package/app/.next-cli-build/server/app/_global-error.segments/_full.segment.rsc +1 -1
  41. package/app/.next-cli-build/server/app/_global-error.segments/_global-error/__PAGE__.segment.rsc +1 -1
  42. package/app/.next-cli-build/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  43. package/app/.next-cli-build/server/app/_not-found/page_client-reference-manifest.js +1 -1
  44. package/app/.next-cli-build/server/app/_not-found.html +1 -1
  45. package/app/.next-cli-build/server/app/_not-found.rsc +5 -5
  46. package/app/.next-cli-build/server/app/_not-found.segments/_full.segment.rsc +5 -5
  47. package/app/.next-cli-build/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +4 -4
  48. package/app/.next-cli-build/server/app/_not-found.segments/_tree.segment.rsc +1 -1
  49. package/app/.next-cli-build/server/app/api/auth/login/route.js +1 -1
  50. package/app/.next-cli-build/server/app/api/auth/logout/route.js +1 -1
  51. package/app/.next-cli-build/server/app/api/auth/oidc/callback/route.js +1 -1
  52. package/app/.next-cli-build/server/app/api/auth/oidc/start/route.js +1 -1
  53. package/app/.next-cli-build/server/app/api/auth/oidc/test/route.js +1 -1
  54. package/app/.next-cli-build/server/app/api/auth/reset-password/route.js +1 -1
  55. package/app/.next-cli-build/server/app/api/auth/saml/acs/route.js +1 -1
  56. package/app/.next-cli-build/server/app/api/auth/saml/metadata/route.js +1 -1
  57. package/app/.next-cli-build/server/app/api/auth/saml/start/route.js +1 -1
  58. package/app/.next-cli-build/server/app/api/auth/saml/test/route.js +1 -1
  59. package/app/.next-cli-build/server/app/api/auth/status/route.js +1 -1
  60. package/app/.next-cli-build/server/app/api/cli-tools/all-statuses/route.js +9 -9
  61. package/app/.next-cli-build/server/app/api/cli-tools/antigravity-mitm/alias/route.js +1 -1
  62. package/app/.next-cli-build/server/app/api/cli-tools/antigravity-mitm/route.js +1 -1
  63. package/app/.next-cli-build/server/app/api/cli-tools/claude-settings/route.js +1 -1
  64. package/app/.next-cli-build/server/app/api/cli-tools/cline-settings/route.js +1 -1
  65. package/app/.next-cli-build/server/app/api/cli-tools/codewhale-settings/route.js +1 -1
  66. package/app/.next-cli-build/server/app/api/cli-tools/codex-profiles/route.js +1 -1
  67. package/app/.next-cli-build/server/app/api/cli-tools/codex-settings/route.js +1 -1
  68. package/app/.next-cli-build/server/app/api/cli-tools/copilot-settings/route.js +2 -2
  69. package/app/.next-cli-build/server/app/api/cli-tools/cowork-mcp-registry/route.js +1 -1
  70. package/app/.next-cli-build/server/app/api/cli-tools/cowork-mcp-tools/route.js +1 -1
  71. package/app/.next-cli-build/server/app/api/cli-tools/crush-settings/route.js +2 -2
  72. package/app/.next-cli-build/server/app/api/cli-tools/deepseek-tui-settings/route.js +3 -3
  73. package/app/.next-cli-build/server/app/api/cli-tools/droid-settings/route.js +1 -1
  74. package/app/.next-cli-build/server/app/api/cli-tools/forge-settings/route.js +1 -1
  75. package/app/.next-cli-build/server/app/api/cli-tools/grok-build-settings/route.js +5 -5
  76. package/app/.next-cli-build/server/app/api/cli-tools/hermes-profiles/route.js +2 -2
  77. package/app/.next-cli-build/server/app/api/cli-tools/jcode-settings/route.js +2 -2
  78. package/app/.next-cli-build/server/app/api/cli-tools/kilo-settings/route.js +1 -1
  79. package/app/.next-cli-build/server/app/api/cli-tools/omp-settings/route.js +3 -3
  80. package/app/.next-cli-build/server/app/api/cli-tools/openclaw-settings/route.js +1 -1
  81. package/app/.next-cli-build/server/app/api/cli-tools/opencode-settings/route.js +1 -1
  82. package/app/.next-cli-build/server/app/api/cli-tools/pi-settings/route.js +1 -1
  83. package/app/.next-cli-build/server/app/api/cli-tools/smelt-settings/route.js +1 -1
  84. package/app/.next-cli-build/server/app/api/combos/[id]/route.js +1 -1
  85. package/app/.next-cli-build/server/app/api/combos/presets/route.js +1 -1
  86. package/app/.next-cli-build/server/app/api/combos/route.js +1 -1
  87. package/app/.next-cli-build/server/app/api/headroom/proxy/[...path]/route.js +1 -1
  88. package/app/.next-cli-build/server/app/api/headroom/restart/route.js +1 -1
  89. package/app/.next-cli-build/server/app/api/headroom/start/route.js +1 -1
  90. package/app/.next-cli-build/server/app/api/keys/[id]/route.js +1 -1
  91. package/app/.next-cli-build/server/app/api/keys/[id]/secret/route.js +1 -1
  92. package/app/.next-cli-build/server/app/api/keys/route.js +1 -1
  93. package/app/.next-cli-build/server/app/api/mcp/[plugin]/message/route.js +2 -2
  94. package/app/.next-cli-build/server/app/api/mcp/[plugin]/sse/route.js +2 -2
  95. package/app/.next-cli-build/server/app/api/media-providers/tts/deepgram/voices/route.js +1 -1
  96. package/app/.next-cli-build/server/app/api/media-providers/tts/elevenlabs/voices/route.js +1 -1
  97. package/app/.next-cli-build/server/app/api/media-providers/tts/inworld/voices/route.js +1 -1
  98. package/app/.next-cli-build/server/app/api/media-providers/tts/minimax/voices/route.js +1 -1
  99. package/app/.next-cli-build/server/app/api/model-health/check/route.js +1 -1
  100. package/app/.next-cli-build/server/app/api/model-health/check-all/route.js +1 -1
  101. package/app/.next-cli-build/server/app/api/model-health/config/route.js +1 -1
  102. package/app/.next-cli-build/server/app/api/model-health/history/route.js +1 -1
  103. package/app/.next-cli-build/server/app/api/model-health/model/route.js +1 -1
  104. package/app/.next-cli-build/server/app/api/model-health/models/route.js +1 -1
  105. package/app/.next-cli-build/server/app/api/model-health/route.js +1 -1
  106. package/app/.next-cli-build/server/app/api/model-health/run-scheduled/route.js +1 -1
  107. package/app/.next-cli-build/server/app/api/model-health/summary/route.js +1 -1
  108. package/app/.next-cli-build/server/app/api/models/alias/route.js +1 -1
  109. package/app/.next-cli-build/server/app/api/models/availability/route.js +1 -1
  110. package/app/.next-cli-build/server/app/api/models/catalog-sync/route.js +1 -1
  111. package/app/.next-cli-build/server/app/api/models/custom/route.js +1 -1
  112. package/app/.next-cli-build/server/app/api/models/disabled/route.js +1 -1
  113. package/app/.next-cli-build/server/app/api/models/limits/route.js +1 -1
  114. package/app/.next-cli-build/server/app/api/models/route.js +1 -1
  115. package/app/.next-cli-build/server/app/api/oauth/[provider]/[action]/route.js +1 -1
  116. package/app/.next-cli-build/server/app/api/oauth/codex/bulk-import/route.js +1 -1
  117. package/app/.next-cli-build/server/app/api/oauth/codex/import-token/route.js +1 -1
  118. package/app/.next-cli-build/server/app/api/oauth/cursor/import/route.js +1 -1
  119. package/app/.next-cli-build/server/app/api/oauth/gitlab/pat/route.js +1 -1
  120. package/app/.next-cli-build/server/app/api/oauth/grok-cli/bulk-import/route.js +1 -1
  121. package/app/.next-cli-build/server/app/api/oauth/iflow/cookie/route.js +1 -1
  122. package/app/.next-cli-build/server/app/api/oauth/kiro/api-key/route.js +1 -1
  123. package/app/.next-cli-build/server/app/api/oauth/kiro/import/route.js +1 -1
  124. package/app/.next-cli-build/server/app/api/oauth/kiro/import-cli-proxy/route.js +1 -1
  125. package/app/.next-cli-build/server/app/api/oauth/kiro/social-exchange/route.js +1 -1
  126. package/app/.next-cli-build/server/app/api/oauth/xiaomi-mimo/api-key/route.js +1 -1
  127. package/app/.next-cli-build/server/app/api/oauth/xiaomi-mimo/auto-import/route.js +1 -1
  128. package/app/.next-cli-build/server/app/api/oauth/zed/import/route.js +1 -1
  129. package/app/.next-cli-build/server/app/api/pricing/route.js +1 -1
  130. package/app/.next-cli-build/server/app/api/provider-nodes/[id]/route.js +1 -1
  131. package/app/.next-cli-build/server/app/api/provider-nodes/route.js +1 -1
  132. package/app/.next-cli-build/server/app/api/provider-nodes/validate/route.js +1 -1
  133. package/app/.next-cli-build/server/app/api/providers/[id]/connections/keys/route.js +1 -1
  134. package/app/.next-cli-build/server/app/api/providers/[id]/models/route.js +1 -1
  135. package/app/.next-cli-build/server/app/api/providers/[id]/overrides/route.js +1 -1
  136. package/app/.next-cli-build/server/app/api/providers/[id]/route.js +1 -1
  137. package/app/.next-cli-build/server/app/api/providers/client/route.js +1 -1
  138. package/app/.next-cli-build/server/app/api/providers/route.js +1 -1
  139. package/app/.next-cli-build/server/app/api/providers/validate/route.js +1 -1
  140. package/app/.next-cli-build/server/app/api/proxy-pools/[id]/route.js +1 -1
  141. package/app/.next-cli-build/server/app/api/proxy-pools/[id]/test/route.js +1 -1
  142. package/app/.next-cli-build/server/app/api/proxy-pools/cloudflare-deploy/route.js +1 -1
  143. package/app/.next-cli-build/server/app/api/proxy-pools/deno-deploy/route.js +2 -2
  144. package/app/.next-cli-build/server/app/api/proxy-pools/netlify-deploy/route.js +4 -4
  145. package/app/.next-cli-build/server/app/api/proxy-pools/route.js +1 -1
  146. package/app/.next-cli-build/server/app/api/proxy-pools/vercel-deploy/route.js +1 -1
  147. package/app/.next-cli-build/server/app/api/pxpipe/health/route.js +1 -1
  148. package/app/.next-cli-build/server/app/api/pxpipe/install/route.js +1 -1
  149. package/app/.next-cli-build/server/app/api/pxpipe/logs/route.js +1 -1
  150. package/app/.next-cli-build/server/app/api/pxpipe/restart/route.js +1 -1
  151. package/app/.next-cli-build/server/app/api/pxpipe/start/route.js +1 -1
  152. package/app/.next-cli-build/server/app/api/pxpipe/stats/route.js +1 -1
  153. package/app/.next-cli-build/server/app/api/pxpipe/status/route.js +1 -1
  154. package/app/.next-cli-build/server/app/api/pxpipe/stop/route.js +1 -1
  155. package/app/.next-cli-build/server/app/api/settings/database/route.js +1 -1
  156. package/app/.next-cli-build/server/app/api/settings/proxy-test/route.js +1 -1
  157. package/app/.next-cli-build/server/app/api/settings/require-login/route.js +1 -1
  158. package/app/.next-cli-build/server/app/api/settings/route.js +1 -1
  159. package/app/.next-cli-build/server/app/api/translator/console-logs/route.js +1 -1
  160. package/app/.next-cli-build/server/app/api/translator/console-logs/stream/route.js +1 -1
  161. package/app/.next-cli-build/server/app/api/translator/send/route.js +1 -1
  162. package/app/.next-cli-build/server/app/api/translator/translate/route.js +1 -1
  163. package/app/.next-cli-build/server/app/api/usage/[connectionId]/claude-reset/route.js +1 -1
  164. package/app/.next-cli-build/server/app/api/usage/[connectionId]/codex-reset-credits/route.js +1 -1
  165. package/app/.next-cli-build/server/app/api/usage/[connectionId]/route.js +1 -1
  166. package/app/.next-cli-build/server/app/api/usage/chart/route.js +1 -1
  167. package/app/.next-cli-build/server/app/api/usage/history/route.js +1 -1
  168. package/app/.next-cli-build/server/app/api/usage/logs/route.js +1 -1
  169. package/app/.next-cli-build/server/app/api/usage/providers/route.js +1 -1
  170. package/app/.next-cli-build/server/app/api/usage/request-details/route.js +1 -1
  171. package/app/.next-cli-build/server/app/api/usage/request-logs/route.js +1 -1
  172. package/app/.next-cli-build/server/app/api/usage/stats/route.js +1 -1
  173. package/app/.next-cli-build/server/app/api/usage/stream/route.js +1 -1
  174. package/app/.next-cli-build/server/app/api/v1/audio/voices/route.js +1 -1
  175. package/app/.next-cli-build/server/app/api/v1/messages/count_tokens/route.js +1 -1
  176. package/app/.next-cli-build/server/app/api/v1/models/info/route.js +1 -1
  177. package/app/.next-cli-build/server/app/api/version/route.js +1 -1
  178. package/app/.next-cli-build/server/app/callback/page_client-reference-manifest.js +1 -1
  179. package/app/.next-cli-build/server/app/callback.html +1 -1
  180. package/app/.next-cli-build/server/app/callback.rsc +5 -5
  181. package/app/.next-cli-build/server/app/callback.segments/_full.segment.rsc +5 -5
  182. package/app/.next-cli-build/server/app/callback.segments/_tree.segment.rsc +1 -1
  183. package/app/.next-cli-build/server/app/callback.segments/callback/__PAGE__.segment.rsc +4 -4
  184. package/app/.next-cli-build/server/app/dashboard/basic-chat.html +1 -1
  185. package/app/.next-cli-build/server/app/dashboard/basic-chat.rsc +7 -7
  186. package/app/.next-cli-build/server/app/dashboard/basic-chat.segments/!KGRhc2hib2FyZCk/dashboard/basic-chat/__PAGE__.segment.rsc +6 -6
  187. package/app/.next-cli-build/server/app/dashboard/basic-chat.segments/_full.segment.rsc +7 -7
  188. package/app/.next-cli-build/server/app/dashboard/basic-chat.segments/_tree.segment.rsc +1 -1
  189. package/app/.next-cli-build/server/app/dashboard/cli-tools.html +1 -1
  190. package/app/.next-cli-build/server/app/dashboard/cli-tools.rsc +7 -7
  191. package/app/.next-cli-build/server/app/dashboard/cli-tools.segments/!KGRhc2hib2FyZCk/dashboard/cli-tools/__PAGE__.segment.rsc +6 -6
  192. package/app/.next-cli-build/server/app/dashboard/cli-tools.segments/_full.segment.rsc +7 -7
  193. package/app/.next-cli-build/server/app/dashboard/cli-tools.segments/_tree.segment.rsc +1 -1
  194. package/app/.next-cli-build/server/app/dashboard/combos.html +1 -1
  195. package/app/.next-cli-build/server/app/dashboard/combos.rsc +7 -7
  196. package/app/.next-cli-build/server/app/dashboard/combos.segments/!KGRhc2hib2FyZCk/dashboard/combos/__PAGE__.segment.rsc +6 -6
  197. package/app/.next-cli-build/server/app/dashboard/combos.segments/_full.segment.rsc +7 -7
  198. package/app/.next-cli-build/server/app/dashboard/combos.segments/_tree.segment.rsc +1 -1
  199. package/app/.next-cli-build/server/app/dashboard/endpoint.html +1 -1
  200. package/app/.next-cli-build/server/app/dashboard/endpoint.rsc +7 -7
  201. package/app/.next-cli-build/server/app/dashboard/endpoint.segments/!KGRhc2hib2FyZCk/dashboard/endpoint/__PAGE__.segment.rsc +6 -6
  202. package/app/.next-cli-build/server/app/dashboard/endpoint.segments/_full.segment.rsc +7 -7
  203. package/app/.next-cli-build/server/app/dashboard/endpoint.segments/_tree.segment.rsc +1 -1
  204. package/app/.next-cli-build/server/app/dashboard/health.html +1 -1
  205. package/app/.next-cli-build/server/app/dashboard/health.rsc +6 -6
  206. package/app/.next-cli-build/server/app/dashboard/health.segments/!KGRhc2hib2FyZCk/dashboard/health/__PAGE__.segment.rsc +5 -5
  207. package/app/.next-cli-build/server/app/dashboard/health.segments/_full.segment.rsc +6 -6
  208. package/app/.next-cli-build/server/app/dashboard/health.segments/_tree.segment.rsc +1 -1
  209. package/app/.next-cli-build/server/app/dashboard/media-providers/web.html +1 -1
  210. package/app/.next-cli-build/server/app/dashboard/media-providers/web.rsc +7 -7
  211. package/app/.next-cli-build/server/app/dashboard/media-providers/web.segments/!KGRhc2hib2FyZCk/dashboard/media-providers/web/__PAGE__.segment.rsc +6 -6
  212. package/app/.next-cli-build/server/app/dashboard/media-providers/web.segments/_full.segment.rsc +7 -7
  213. package/app/.next-cli-build/server/app/dashboard/media-providers/web.segments/_tree.segment.rsc +1 -1
  214. package/app/.next-cli-build/server/app/dashboard/mitm.html +1 -1
  215. package/app/.next-cli-build/server/app/dashboard/mitm.rsc +7 -7
  216. package/app/.next-cli-build/server/app/dashboard/mitm.segments/!KGRhc2hib2FyZCk/dashboard/mitm/__PAGE__.segment.rsc +6 -6
  217. package/app/.next-cli-build/server/app/dashboard/mitm.segments/_full.segment.rsc +7 -7
  218. package/app/.next-cli-build/server/app/dashboard/mitm.segments/_tree.segment.rsc +1 -1
  219. package/app/.next-cli-build/server/app/dashboard/playground.html +1 -1
  220. package/app/.next-cli-build/server/app/dashboard/playground.rsc +7 -7
  221. package/app/.next-cli-build/server/app/dashboard/playground.segments/!KGRhc2hib2FyZCk/dashboard/playground/__PAGE__.segment.rsc +6 -6
  222. package/app/.next-cli-build/server/app/dashboard/playground.segments/_full.segment.rsc +7 -7
  223. package/app/.next-cli-build/server/app/dashboard/playground.segments/_tree.segment.rsc +1 -1
  224. package/app/.next-cli-build/server/app/dashboard/profile.html +1 -1
  225. package/app/.next-cli-build/server/app/dashboard/profile.rsc +7 -7
  226. package/app/.next-cli-build/server/app/dashboard/profile.segments/!KGRhc2hib2FyZCk/dashboard/profile/__PAGE__.segment.rsc +6 -6
  227. package/app/.next-cli-build/server/app/dashboard/profile.segments/_full.segment.rsc +7 -7
  228. package/app/.next-cli-build/server/app/dashboard/profile.segments/_tree.segment.rsc +1 -1
  229. package/app/.next-cli-build/server/app/dashboard/providers/new.html +1 -1
  230. package/app/.next-cli-build/server/app/dashboard/providers/new.rsc +7 -7
  231. package/app/.next-cli-build/server/app/dashboard/providers/new.segments/!KGRhc2hib2FyZCk/dashboard/providers/new/__PAGE__.segment.rsc +6 -6
  232. package/app/.next-cli-build/server/app/dashboard/providers/new.segments/_full.segment.rsc +7 -7
  233. package/app/.next-cli-build/server/app/dashboard/providers/new.segments/_tree.segment.rsc +1 -1
  234. package/app/.next-cli-build/server/app/dashboard/providers.html +1 -1
  235. package/app/.next-cli-build/server/app/dashboard/providers.rsc +7 -7
  236. package/app/.next-cli-build/server/app/dashboard/providers.segments/!KGRhc2hib2FyZCk/dashboard/providers/__PAGE__.segment.rsc +6 -6
  237. package/app/.next-cli-build/server/app/dashboard/providers.segments/_full.segment.rsc +7 -7
  238. package/app/.next-cli-build/server/app/dashboard/providers.segments/_tree.segment.rsc +1 -1
  239. package/app/.next-cli-build/server/app/dashboard/proxy-pools.html +1 -1
  240. package/app/.next-cli-build/server/app/dashboard/proxy-pools.rsc +7 -7
  241. package/app/.next-cli-build/server/app/dashboard/proxy-pools.segments/!KGRhc2hib2FyZCk/dashboard/proxy-pools/__PAGE__.segment.rsc +6 -6
  242. package/app/.next-cli-build/server/app/dashboard/proxy-pools.segments/_full.segment.rsc +7 -7
  243. package/app/.next-cli-build/server/app/dashboard/proxy-pools.segments/_tree.segment.rsc +1 -1
  244. package/app/.next-cli-build/server/app/dashboard/pxpipe.html +1 -1
  245. package/app/.next-cli-build/server/app/dashboard/pxpipe.rsc +7 -7
  246. package/app/.next-cli-build/server/app/dashboard/pxpipe.segments/!KGRhc2hib2FyZCk/dashboard/pxpipe/__PAGE__.segment.rsc +6 -6
  247. package/app/.next-cli-build/server/app/dashboard/pxpipe.segments/_full.segment.rsc +7 -7
  248. package/app/.next-cli-build/server/app/dashboard/pxpipe.segments/_tree.segment.rsc +1 -1
  249. package/app/.next-cli-build/server/app/dashboard/quota.html +1 -1
  250. package/app/.next-cli-build/server/app/dashboard/quota.rsc +8 -8
  251. package/app/.next-cli-build/server/app/dashboard/quota.segments/!KGRhc2hib2FyZCk/dashboard/quota/__PAGE__.segment.rsc +7 -7
  252. package/app/.next-cli-build/server/app/dashboard/quota.segments/_full.segment.rsc +8 -8
  253. package/app/.next-cli-build/server/app/dashboard/quota.segments/_tree.segment.rsc +1 -1
  254. package/app/.next-cli-build/server/app/dashboard/settings/pricing/page_client-reference-manifest.js +1 -1
  255. package/app/.next-cli-build/server/app/dashboard/settings/pricing.html +1 -1
  256. package/app/.next-cli-build/server/app/dashboard/settings/pricing.rsc +5 -5
  257. package/app/.next-cli-build/server/app/dashboard/settings/pricing.segments/_full.segment.rsc +5 -5
  258. package/app/.next-cli-build/server/app/dashboard/settings/pricing.segments/_tree.segment.rsc +1 -1
  259. package/app/.next-cli-build/server/app/dashboard/settings/pricing.segments/dashboard/settings/pricing/__PAGE__.segment.rsc +4 -4
  260. package/app/.next-cli-build/server/app/dashboard/skills.html +1 -1
  261. package/app/.next-cli-build/server/app/dashboard/skills.rsc +7 -7
  262. package/app/.next-cli-build/server/app/dashboard/skills.segments/!KGRhc2hib2FyZCk/dashboard/skills/__PAGE__.segment.rsc +6 -6
  263. package/app/.next-cli-build/server/app/dashboard/skills.segments/_full.segment.rsc +7 -7
  264. package/app/.next-cli-build/server/app/dashboard/skills.segments/_tree.segment.rsc +1 -1
  265. package/app/.next-cli-build/server/app/dashboard/token-saver.html +1 -1
  266. package/app/.next-cli-build/server/app/dashboard/token-saver.rsc +7 -7
  267. package/app/.next-cli-build/server/app/dashboard/token-saver.segments/!KGRhc2hib2FyZCk/dashboard/token-saver/__PAGE__.segment.rsc +6 -6
  268. package/app/.next-cli-build/server/app/dashboard/token-saver.segments/_full.segment.rsc +7 -7
  269. package/app/.next-cli-build/server/app/dashboard/token-saver.segments/_tree.segment.rsc +1 -1
  270. package/app/.next-cli-build/server/app/dashboard/translator.html +1 -1
  271. package/app/.next-cli-build/server/app/dashboard/translator.rsc +7 -7
  272. package/app/.next-cli-build/server/app/dashboard/translator.segments/!KGRhc2hib2FyZCk/dashboard/translator/__PAGE__.segment.rsc +6 -6
  273. package/app/.next-cli-build/server/app/dashboard/translator.segments/_full.segment.rsc +7 -7
  274. package/app/.next-cli-build/server/app/dashboard/translator.segments/_tree.segment.rsc +1 -1
  275. package/app/.next-cli-build/server/app/dashboard/usage.html +1 -1
  276. package/app/.next-cli-build/server/app/dashboard/usage.rsc +7 -7
  277. package/app/.next-cli-build/server/app/dashboard/usage.segments/!KGRhc2hib2FyZCk/dashboard/usage/__PAGE__.segment.rsc +6 -6
  278. package/app/.next-cli-build/server/app/dashboard/usage.segments/_full.segment.rsc +7 -7
  279. package/app/.next-cli-build/server/app/dashboard/usage.segments/_tree.segment.rsc +1 -1
  280. package/app/.next-cli-build/server/app/dashboard.html +1 -1
  281. package/app/.next-cli-build/server/app/dashboard.rsc +6 -6
  282. package/app/.next-cli-build/server/app/dashboard.segments/!KGRhc2hib2FyZCk/dashboard/__PAGE__.segment.rsc +5 -5
  283. package/app/.next-cli-build/server/app/dashboard.segments/_full.segment.rsc +6 -6
  284. package/app/.next-cli-build/server/app/dashboard.segments/_tree.segment.rsc +1 -1
  285. package/app/.next-cli-build/server/app/index.html +1 -1
  286. package/app/.next-cli-build/server/app/index.rsc +5 -5
  287. package/app/.next-cli-build/server/app/index.segments/__PAGE__.segment.rsc +4 -4
  288. package/app/.next-cli-build/server/app/index.segments/_full.segment.rsc +5 -5
  289. package/app/.next-cli-build/server/app/index.segments/_tree.segment.rsc +1 -1
  290. package/app/.next-cli-build/server/app/landing/page.js +1 -1
  291. package/app/.next-cli-build/server/app/landing/page_client-reference-manifest.js +1 -1
  292. package/app/.next-cli-build/server/app/landing.html +1 -1
  293. package/app/.next-cli-build/server/app/landing.rsc +6 -6
  294. package/app/.next-cli-build/server/app/landing.segments/_full.segment.rsc +6 -6
  295. package/app/.next-cli-build/server/app/landing.segments/_tree.segment.rsc +1 -1
  296. package/app/.next-cli-build/server/app/landing.segments/landing/__PAGE__.segment.rsc +5 -5
  297. package/app/.next-cli-build/server/app/login/page.js +1 -1
  298. package/app/.next-cli-build/server/app/login/page_client-reference-manifest.js +1 -1
  299. package/app/.next-cli-build/server/app/login.html +1 -1
  300. package/app/.next-cli-build/server/app/login.rsc +6 -6
  301. package/app/.next-cli-build/server/app/login.segments/_full.segment.rsc +6 -6
  302. package/app/.next-cli-build/server/app/login.segments/_tree.segment.rsc +1 -1
  303. package/app/.next-cli-build/server/app/login.segments/login/__PAGE__.segment.rsc +5 -5
  304. package/app/.next-cli-build/server/app/manifest.webmanifest/route.js +1 -1
  305. package/app/.next-cli-build/server/app/manifest.webmanifest.body +1 -1
  306. package/app/.next-cli-build/server/app/page_client-reference-manifest.js +1 -1
  307. package/app/.next-cli-build/server/app-paths-manifest.json +14 -14
  308. package/app/.next-cli-build/server/chunks/1133.js +1 -1
  309. package/app/.next-cli-build/server/chunks/1757.js +2 -2
  310. package/app/.next-cli-build/server/chunks/2132.js +1 -1
  311. package/app/.next-cli-build/server/chunks/2524.js +1 -1
  312. package/app/.next-cli-build/server/chunks/2732.js +1 -1
  313. package/app/.next-cli-build/server/chunks/2760.js +1 -1
  314. package/app/.next-cli-build/server/chunks/3192.js +1 -1
  315. package/app/.next-cli-build/server/chunks/3360.js +1 -1
  316. package/app/.next-cli-build/server/chunks/3535.js +1 -1
  317. package/app/.next-cli-build/server/chunks/3966.js +6 -6
  318. package/app/.next-cli-build/server/chunks/412.js +1 -1
  319. package/app/.next-cli-build/server/chunks/4123.js +3 -3
  320. package/app/.next-cli-build/server/chunks/4152.js +1 -1
  321. package/app/.next-cli-build/server/chunks/436.js +1 -1
  322. package/app/.next-cli-build/server/chunks/455.js +1 -1
  323. package/app/.next-cli-build/server/chunks/4642.js +1 -1
  324. package/app/.next-cli-build/server/chunks/4746.js +1 -1
  325. package/app/.next-cli-build/server/chunks/4764.js +1 -1
  326. package/app/.next-cli-build/server/chunks/4827.js +1 -1
  327. package/app/.next-cli-build/server/chunks/4864.js +6 -6
  328. package/app/.next-cli-build/server/chunks/5299.js +25 -25
  329. package/app/.next-cli-build/server/chunks/5330.js +1 -1
  330. package/app/.next-cli-build/server/chunks/5615.js +2 -2
  331. package/app/.next-cli-build/server/chunks/6296.js +5 -5
  332. package/app/.next-cli-build/server/chunks/735.js +1 -1
  333. package/app/.next-cli-build/server/chunks/7373.js +1 -1
  334. package/app/.next-cli-build/server/chunks/7716.js +1 -1
  335. package/app/.next-cli-build/server/chunks/8126.js +1 -1
  336. package/app/.next-cli-build/server/chunks/8306.js +1 -1
  337. package/app/.next-cli-build/server/chunks/8432.js +1 -1
  338. package/app/.next-cli-build/server/chunks/8749.js +1 -1
  339. package/app/.next-cli-build/server/chunks/9032.js +1 -1
  340. package/app/.next-cli-build/server/chunks/9046.js +1 -1
  341. package/app/.next-cli-build/server/chunks/9128.js +1 -1
  342. package/app/.next-cli-build/server/chunks/9489.js +1 -1
  343. package/app/.next-cli-build/server/chunks/9609.js +1 -1
  344. package/app/.next-cli-build/server/middleware-build-manifest.js +1 -1
  345. package/app/.next-cli-build/server/middleware.js +2 -2
  346. package/app/.next-cli-build/server/pages/404.html +1 -1
  347. package/app/.next-cli-build/server/pages/500.html +1 -1
  348. package/app/.next-cli-build/static/chunks/{1321-b2785838003873e1.js → 1321-9eb7d54c5b900efb.js} +1 -1
  349. package/app/.next-cli-build/static/chunks/{5497-66e7c2a2b715a638.js → 5497-973a06c94a94aff7.js} +1 -1
  350. package/app/.next-cli-build/static/chunks/761-1bcb7334763d5645.js +132 -0
  351. package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/cli-tools/{page-9f4426c30039c7d5.js → page-3960bffd1fddbbad.js} +1 -1
  352. package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/endpoint/{page-0c7b45a45ba51753.js → page-61b17862582ff807.js} +1 -1
  353. package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/profile/{page-de6dfc43c2687bd8.js → page-1a560f2b5cdf2e31.js} +1 -1
  354. package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/skills/page-4c6b176d5c59d8a4.js +1 -0
  355. package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/token-saver/{page-e631d28dd402dc1e.js → page-d0031965cf7eff51.js} +1 -1
  356. package/app/.next-cli-build/static/chunks/app/landing/{page-431f7e8093b8ca51.js → page-5bc39b166588b878.js} +1 -1
  357. package/app/.next-cli-build/static/chunks/app/login/{page-80c4e229a5f38a6b.js → page-f2b166590b653d36.js} +1 -1
  358. package/app/custom-server.js +2 -2
  359. package/app/package.json +1 -1
  360. package/app/src/lib/oauth/providers/xiaomi-mimo.js +2 -2
  361. package/app/src/lib/updater/updater.js +3 -3
  362. package/app/src/mitm/server.js +10 -10
  363. package/cli.js +6 -6
  364. package/hooks/postinstall.js +2 -2
  365. package/hooks/sqliteRuntime.js +2 -2
  366. package/hooks/trayRuntime.js +3 -3
  367. package/package.json +7 -3
  368. package/src/cli/api/client.js +3 -3
  369. package/src/cli/commands/connect.js +3 -3
  370. package/src/cli/commands/connectTools.js +12 -12
  371. package/src/cli/commands/xaiVideo.js +1 -1
  372. package/src/cli/menus/cliTools.js +18 -18
  373. package/src/cli/menus/settings.js +1 -1
  374. package/src/cli/tray/autostart.js +1 -1
  375. package/app/.next-cli-build/static/chunks/761-57ed45cdddcf32eb.js +0 -132
  376. package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/skills/page-316b3186a841d862.js +0 -1
  377. /package/app/.next-cli-build/static/{fjLlI_-eBYMOp6J-a-q-6 → MDZXE-9g1sq006f6JNky9}/_buildManifest.js +0 -0
  378. /package/app/.next-cli-build/static/{fjLlI_-eBYMOp6J-a-q-6 → MDZXE-9g1sq006f6JNky9}/_ssgManifest.js +0 -0
@@ -1 +1 @@
1
- (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[2326],{75882:(e,a,s)=>{"use strict";s.d(a,{default:()=>N});var l=s(95155),t=s(96439),i=s(12115),n=s(35497),r=s(3534),c=s(10761),d=s(66119),o=s(98500),h=s.n(o),u=s(5772),m=s(30535),x=s.n(m);function j({toolId:e,tool:a,status:s}){let i=a?.configType==="guide"?{label:"Guide",variant:"default"}:s?s.installed?s.has9Router?{label:"Connected",variant:"success"}:{label:"Not configured",variant:"warning"}:{label:"Not installed",variant:"default"}:{label:"Unknown",variant:"default"};return(0,l.jsx)(h(),{href:`/dashboard/cli-tools/${e}`,className:x().toolLink,children:(0,l.jsxs)(n.Zp,{padding:"none",className:x().tile,children:[(0,l.jsx)("div",{className:x().toolIcon,children:a.image?(0,l.jsx)(u.default,{src:a.image,alt:a.name,width:32,height:32,className:"size-8 object-contain rounded-lg",sizes:"32px",onError:e=>{e.target.style.display="none"},loading:"lazy",decoding:"async"}):a.icon?(0,l.jsx)(t.default,{className:"text-[28px]",style:{color:a.color},children:a.icon}):null}),(0,l.jsxs)("div",{className:x().identity,children:[(0,l.jsx)("h3",{className:x().title,title:a.name,children:a.name}),"Guide"===i.label?(0,l.jsx)(n.Ex,{variant:"info",size:"sm",className:x().infoStatus,children:i.label}):(0,l.jsx)(d.A,{variant:i.variant,dot:"Connected"===i.label||"Not configured"===i.label,className:x().status,children:i.label})]}),(0,l.jsx)(t.default,{className:x().chevron,size:18,children:"chevron_right"})]})})}function N({machineId:e}){let[a,s]=(0,i.useState)(!0),[d,o]=(0,i.useState)({});if((0,i.useEffect)(()=>{let e=!0;return(async()=>{try{let a=await fetch("/api/cli-tools/all-statuses");a.ok&&e&&o(await a.json())}catch(e){console.log("Error fetching tool statuses:",e)}finally{e&&s(!1)}})(),()=>{e=!1}},[]),a)return(0,l.jsx)("div",{className:x().page,"aria-busy":"true","aria-label":"Loading CLI tools",children:(0,l.jsx)("div",{className:x().grid,children:Array.from({length:6},(e,a)=>(0,l.jsxs)(n.Zp,{padding:"none",className:x().tile,children:[(0,l.jsx)(n.EA,{className:"size-8 shrink-0"}),(0,l.jsxs)("div",{className:x().identity,children:[(0,l.jsx)(n.EA,{className:"h-4 w-28 max-w-full"}),(0,l.jsx)(n.EA,{className:"mt-2 h-4 w-20 max-w-full"})]})]},a))})});let h=Object.entries(r.dM),u=Object.entries(r.wn);return(0,l.jsxs)("div",{className:x().page,children:[(0,l.jsx)("div",{className:x().grid,children:h.map(([e,a])=>(0,l.jsx)(j,{toolId:e,tool:a,status:d[e]},e))}),(0,l.jsxs)("div",{className:x().group,children:[(0,l.jsxs)("div",{className:x().groupHeader,children:[(0,l.jsx)(t.default,{className:"text-[18px]",children:"security"}),(0,l.jsx)("h2",{children:"MITM Tools"})]}),(0,l.jsx)("div",{className:x().grid,children:u.map(([e,a])=>(0,l.jsx)(c.gY,{tool:a},e))})]})]})}},77852:(e,a,s)=>{Promise.resolve().then(s.bind(s,75882))}},e=>{e.O(0,[3493,8679,970,2904,6506,8500,3847,5772,1321,705,5497,761,8441,3794,7358],()=>e(e.s=77852)),_N_E=e.O()}]);
1
+ (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[2326],{75882:(e,a,s)=>{"use strict";s.d(a,{default:()=>N});var l=s(95155),t=s(96439),i=s(12115),n=s(35497),r=s(3534),c=s(10761),d=s(66119),o=s(98500),h=s.n(o),u=s(5772),m=s(30535),x=s.n(m);function j({toolId:e,tool:a,status:s}){let i=a?.configType==="guide"?{label:"Guide",variant:"default"}:s?s.installed?s.hasJRouter?{label:"Connected",variant:"success"}:{label:"Not configured",variant:"warning"}:{label:"Not installed",variant:"default"}:{label:"Unknown",variant:"default"};return(0,l.jsx)(h(),{href:`/dashboard/cli-tools/${e}`,className:x().toolLink,children:(0,l.jsxs)(n.Zp,{padding:"none",className:x().tile,children:[(0,l.jsx)("div",{className:x().toolIcon,children:a.image?(0,l.jsx)(u.default,{src:a.image,alt:a.name,width:32,height:32,className:"size-8 object-contain rounded-lg",sizes:"32px",onError:e=>{e.target.style.display="none"},loading:"lazy",decoding:"async"}):a.icon?(0,l.jsx)(t.default,{className:"text-[28px]",style:{color:a.color},children:a.icon}):null}),(0,l.jsxs)("div",{className:x().identity,children:[(0,l.jsx)("h3",{className:x().title,title:a.name,children:a.name}),"Guide"===i.label?(0,l.jsx)(n.Ex,{variant:"info",size:"sm",className:x().infoStatus,children:i.label}):(0,l.jsx)(d.A,{variant:i.variant,dot:"Connected"===i.label||"Not configured"===i.label,className:x().status,children:i.label})]}),(0,l.jsx)(t.default,{className:x().chevron,size:18,children:"chevron_right"})]})})}function N({machineId:e}){let[a,s]=(0,i.useState)(!0),[d,o]=(0,i.useState)({});if((0,i.useEffect)(()=>{let e=!0;return(async()=>{try{let a=await fetch("/api/cli-tools/all-statuses");a.ok&&e&&o(await a.json())}catch(e){console.log("Error fetching tool statuses:",e)}finally{e&&s(!1)}})(),()=>{e=!1}},[]),a)return(0,l.jsx)("div",{className:x().page,"aria-busy":"true","aria-label":"Loading CLI tools",children:(0,l.jsx)("div",{className:x().grid,children:Array.from({length:6},(e,a)=>(0,l.jsxs)(n.Zp,{padding:"none",className:x().tile,children:[(0,l.jsx)(n.EA,{className:"size-8 shrink-0"}),(0,l.jsxs)("div",{className:x().identity,children:[(0,l.jsx)(n.EA,{className:"h-4 w-28 max-w-full"}),(0,l.jsx)(n.EA,{className:"mt-2 h-4 w-20 max-w-full"})]})]},a))})});let h=Object.entries(r.dM),u=Object.entries(r.wn);return(0,l.jsxs)("div",{className:x().page,children:[(0,l.jsx)("div",{className:x().grid,children:h.map(([e,a])=>(0,l.jsx)(j,{toolId:e,tool:a,status:d[e]},e))}),(0,l.jsxs)("div",{className:x().group,children:[(0,l.jsxs)("div",{className:x().groupHeader,children:[(0,l.jsx)(t.default,{className:"text-[18px]",children:"security"}),(0,l.jsx)("h2",{children:"MITM Tools"})]}),(0,l.jsx)("div",{className:x().grid,children:u.map(([e,a])=>(0,l.jsx)(c.gY,{tool:a},e))})]})]})}},77852:(e,a,s)=>{Promise.resolve().then(s.bind(s,75882))}},e=>{e.O(0,[3493,8679,970,2904,6506,8500,3847,5772,1321,705,5497,761,8441,3794,7358],()=>e(e.s=77852)),_N_E=e.O()}]);
@@ -1,3 +1,3 @@
1
1
  (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[6099],{15536:(e,t,a)=>{"use strict";a.d(t,{Cp:()=>i,Hx:()=>l,Iv:()=>d,Nv:()=>m,RL:()=>c,ev:()=>u,fl:()=>r,hT:()=>s,oX:()=>n,t6:()=>o});let s=["zh-CN","zh-TW"],n=[{icon:"public",title:"Access Anywhere",desc:"Use your API from any network"},{icon:"group",title:"Share Endpoint",desc:"Share URL with team members"},{icon:"code",title:"Use in Cursor/Cline",desc:"Connect AI tools remotely"},{icon:"lock",title:"Encrypted",desc:"End-to-end TLS via Cloudflare"}],l=2e3,i=3e5,r=5e3,o=5,c=1e4,d=5e3,u=[{id:"lite",label:"Lite",desc:"Drop filler, keep grammar"},{id:"full",label:"Full",desc:"Drop articles, fragments OK"},{id:"ultra",label:"Ultra",desc:"Telegraphic, max compression"},{id:"wenyan-lite",label:"文 Lite",desc:"Classical Chinese, light compression",wenyan:!0},{id:"wenyan",label:"文 Full",desc:"Maximum 文言文, 80-90% reduction",wenyan:!0},{id:"wenyan-ultra",label:"文 Ultra",desc:"Extreme classical compression",wenyan:!0}],m=[{id:"lite",label:"Lite",desc:"Build asked, name lazier option"},{id:"full",label:"Full",desc:"Ladder enforced: stdlib/native first"},{id:"ultra",label:"Ultra",desc:"YAGNI extremist, deletion first"}]},25843:e=>{e.exports={page:"endpoint_page__vZHIb",panel:"endpoint_panel__fWuDy",header:"endpoint_header__K0LDJ",description:"endpoint_description__a7ZK4",dialog:"endpoint_dialog__nv9TH",row:"endpoint_row__0qJCh",label:"endpoint_label__vtk1u",statusBadge:"endpoint_statusBadge__LECCE",statusWarning:"endpoint_statusWarning__K7IpG",statusError:"endpoint_statusError__CeNBO",field:"endpoint_field__pDkqU",endpointValue:"endpoint_endpointValue__pqS36",iconButton:"endpoint_iconButton__LMI_i",dangerButton:"endpoint_dangerButton__zSy_6",keyRow:"endpoint_keyRow__kiHrX",status:"endpoint_status__hHtLP",alert:"endpoint_alert__cHEww",warning:"endpoint_warning__5f9aV",success:"endpoint_success__9ZYAB",error:"endpoint_error__WyDtQ",info:"endpoint_info__Tw6zj",settingsRow:"endpoint_settingsRow__MBLvY",keyDetails:"endpoint_keyDetails__U2vBF",keyName:"endpoint_keyName__TLg8o",keyCredential:"endpoint_keyCredential__MoMsr",keyValue:"endpoint_keyValue__ZPpnv",keyActions:"endpoint_keyActions__xsIoj",tooltip:"endpoint_tooltip__STh9w",keyMeta:"endpoint_keyMeta__0D6K4"}},43728:(e,t,a)=>{"use strict";a.d(t,{default:()=>O});var s=a(95155),n=a(96439),l=a(12115),i=a(14051),r=a.n(i),o=a(35497),c=a(66119),d=a(11059),u=a(15536);async function m(e){if(!e)return!1;try{return(await fetch(`${e}/api/health`,{mode:"cors",cache:"no-store",signal:AbortSignal.timeout(u.Iv)})).ok}catch{return!1}}async function h(...e){let t=e.filter(Boolean).map(m);return!!t.length&&new Promise(e=>{let a=t.length;t.forEach(t=>t.then(t=>{t?e(!0):0==--a&&e(!1)}))})}var x=a(72767),p=a(25843),g=a.n(p);function f({label:e,url:t,copyId:a,copied:l,onCopy:i,actions:r}){return(0,s.jsxs)("div",{className:g().row,children:[(0,s.jsx)("span",{className:g().label,children:e}),(0,s.jsx)("div",{className:g().field,children:(0,s.jsx)("output",{className:`${g().endpointValue} font-mono`,"aria-label":`${e} endpoint`,tabIndex:0,children:t})}),(0,s.jsx)("button",{onClick:()=>i(t,a),className:g().iconButton,"aria-label":`Copy ${e} endpoint`,children:(0,s.jsx)(n.default,{className:"text-[18px]",children:l===a?"check":"content_copy"})}),r]})}function y({status:e,className:t=""}){return(0,s.jsx)("div",{role:"status",className:`${g().alert} ${t} ${"success"===e.type?g().success:"warning"===e.type?g().warning:"info"===e.type?g().info:g().error}`,children:e.message.split(/(https?:\/\/[^\s]+)/g).map((e,t)=>/^https?:\/\//.test(e)?(0,s.jsx)("a",{href:e,target:"_blank",rel:"noreferrer",className:"underline font-medium",children:e},t):e)})}function b({text:e}){return(0,s.jsxs)("span",{className:"relative group inline-flex items-center rounded-[var(--r1)] focus-visible:outline-2 focus-visible:outline-text-muted",tabIndex:0,"aria-label":e,children:[(0,s.jsx)(n.default,{className:"text-[14px] text-text-muted cursor-help",children:"help"}),(0,s.jsx)("span",{className:`${g().tooltip} pointer-events-none invisible group-hover:visible group-focus:visible`,children:e})]})}function j({message:e,action:t}){return(0,s.jsxs)("div",{className:`${g().alert} ${g().warning}`,children:[(0,s.jsx)(n.default,{className:"text-[16px] shrink-0 mt-1",children:"warning"}),(0,s.jsx)("p",{className:"flex-1 min-w-0",children:e}),t&&(0,s.jsx)("a",{href:t.href,className:"text-sm font-medium underline underline-offset-4 shrink-0 hover:opacity-80",onClick:t.href.startsWith("#")?e=>{e.preventDefault(),document.getElementById(t.href.slice(1))?.scrollIntoView({behavior:"smooth"})}:void 0,children:t.label})]})}var v=a(65921);let k=[{value:"chat",label:"Chat / Responses",hint:"Chat completions, Responses, Claude, Gemini and Ollama"},{value:"embeddings",label:"Embeddings",hint:"Text embeddings"},{value:"images",label:"Images",hint:"Image generation"},{value:"audio",label:"Audio",hint:"Speech, transcription and voices"},{value:"web",label:"Web / Search",hint:"Search and web fetch"},{value:"videos",label:"Videos",hint:"Generation, edits, extensions and job status"},{value:"systemone",label:"SystemOne",hint:"SystemOne browser automation"}],w=["lifetime","hourly","daily","weekly","monthly"],N={description:"",maxTokensQuota:null,maxCostUsd:null,quotaResetCycle:"lifetime",tokenMultiplier:1,maxOutputTokens:null,rateLimitRpm:null,rateLimitTpm:null,expiresAt:null,allowedModels:[],blockedModels:[],allowedEndpoints:null};var C=a(44625),_=a(80435);function S({title:e,hint:t,children:a}){return(0,s.jsxs)("section",{className:"space-y-4 border-b border-[var(--line)] pb-6 last:border-0 last:pb-0",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("h3",{className:"text-sm font-semibold text-[var(--text)]",children:e}),t&&(0,s.jsx)("p",{className:"mt-1 text-xs text-[var(--text-2)]",children:t})]}),a]})}function $({field:e,label:t,form:a,onChange:n,hint:l,placeholder:i="Unlimited",decimal:r=!1,min:c=1}){return(0,s.jsx)(o.pd,{label:t,type:"number",min:c,step:r?"any":"1",value:a[e],onChange:t=>n(e,t.target.value),placeholder:i,hint:l,hintClassName:"!text-[var(--text-2)]",required:"tokenMultiplier"===e})}function T({form:e,onChange:t}){return(0,s.jsxs)(S,{title:"Quota & Limits",hint:"Counters reset at UTC calendar boundaries. Lifetime usage never resets automatically.",children:[(0,s.jsxs)("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[(0,s.jsx)($,{field:"maxTokensQuota",label:"Max Tokens Quota",form:e,onChange:t,min:0,hint:"Leave empty for unlimited tokens."}),(0,s.jsx)($,{field:"maxCostUsd",label:"Max Cost (USD)",form:e,onChange:t,min:0,decimal:!0,hint:"Leave empty for unlimited cost. Cost quotas require model pricing."})]}),(0,s.jsx)(o.l6,{label:"Quota Reset Cycle",value:e.quotaResetCycle,onChange:e=>t("quotaResetCycle",e.target.value),options:w.map(e=>({value:e,label:"lifetime"===e?"No Reset / Lifetime":e[0].toUpperCase()+e.slice(1)}))})]})}function E({form:e,onChange:t}){return(0,s.jsx)(S,{title:"Request & Multiplier Controls",children:(0,s.jsxs)("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[(0,s.jsx)($,{field:"tokenMultiplier",label:"Token / Billing Multiplier",form:e,onChange:t,min:1e-6,decimal:!0,placeholder:"1",hint:"1.5 records 1.5x token and cost usage. Provider token counts stay unchanged."}),(0,s.jsx)($,{field:"maxOutputTokens",label:"Max Output Tokens / Request",form:e,onChange:t,placeholder:"e.g. 4096",hint:"Caps output tokens. Requests above this maximum are rejected."})]})})}function A({form:e,onChange:t}){return(0,s.jsxs)(S,{title:"Rate Limiting & Expiration",children:[(0,s.jsxs)("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[(0,s.jsx)($,{field:"rateLimitRpm",label:"Rate Limit (RPM)",form:e,onChange:t,hint:"Maximum requests per rolling minute. Empty means unlimited."}),(0,s.jsx)($,{field:"rateLimitTpm",label:"Rate Limit (TPM)",form:e,onChange:t,hint:"Maximum raw tokens per rolling minute. Empty means unlimited."})]}),(0,s.jsx)(o.pd,{label:"Expiration Date",type:"datetime-local",value:e.expiresAt,onChange:e=>t("expiresAt",e.target.value),hint:"Your local timezone. Leave empty for no expiration.",hintClassName:"!text-[var(--text-2)]"})]})}function P({title:e,values:t,onChange:a,activeProviders:i,modelAliases:r,hint:c}){let[d,u]=(0,l.useState)(!1),{visibleGroups:m,filteredCombos:h,searchQuery:x,setSearchQuery:p}=(0,_.c)({isOpen:d,activeProviders:i,modelAliases:r,addedModelValues:t});function g(e){a(t.includes(e)?t.filter(t=>t!==e):[...t,e])}return(0,s.jsxs)("div",{className:"space-y-2 min-w-0",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,s.jsx)("span",{className:"text-sm font-medium",children:e}),(0,s.jsx)(o.$n,{type:"button",variant:"secondary",size:"sm",icon:"add",onClick:()=>u(!d),"aria-expanded":d,children:d?"Close picker":"Choose models"})]}),(0,s.jsx)("p",{className:"text-xs text-[var(--text-2)]",children:c}),t.length>0&&(0,s.jsx)("div",{className:"flex flex-wrap gap-2",children:t.map(t=>(0,s.jsxs)("button",{type:"button",onClick:()=>g(t),"aria-label":`Remove ${t} from ${e.toLowerCase()}`,className:"inline-flex items-center gap-1.5 max-w-full rounded-[var(--r1)] border border-[var(--line-2)] bg-[var(--surface-2)] px-2 py-1 text-xs hover:bg-[var(--surface-hover)] focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-[var(--text)]",children:[(0,s.jsx)("span",{className:"break-all",children:t}),(0,s.jsx)(n.default,{name:"close",className:"text-[14px] shrink-0"})]},t))}),d&&(0,s.jsx)("div",{className:"rounded-[var(--r2)] border border-[var(--line-2)] p-3",children:(0,s.jsx)(C.A,{searchQuery:x,onSearchChange:p,combos:h,groups:m,addedModelValues:t,onSelect:e=>{e.isPlaceholder||g(e.value||e.name)}})})]})}function R({form:e,onChange:t,activeProviders:a,modelAliases:n}){return(0,s.jsxs)(S,{title:"Model Restrictions",hint:"Blocked models override allowed models, including resolved aliases and combo members.",children:[(0,s.jsx)(P,{title:"Allowed Models",values:e.allowedModels,onChange:e=>t("allowedModels",e),activeProviders:a,modelAliases:n,hint:"Leave empty to allow all models."}),(0,s.jsx)(P,{title:"Blocked Models",values:e.blockedModels,onChange:e=>t("blockedModels",e),activeProviders:a,modelAliases:n,hint:"Leave empty to block no models."})]})}function L({values:e,onChange:t}){return(0,s.jsx)(S,{title:"Allowed Endpoints / Modalities",hint:"Only endpoint families supported by JRouter are listed. Clearing every permission denies all inference requests.",children:(0,s.jsx)("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:k.map(({value:a,label:n,hint:l})=>(0,s.jsxs)("label",{className:`flex items-start gap-3 cursor-pointer rounded-[var(--r2)] border p-3 transition-colors ${e.includes(a)?"border-[var(--accent-line)] bg-[var(--surface-2)]":"border-[var(--line)] hover:bg-[var(--surface-2)]"}`,children:[(0,s.jsx)("input",{type:"checkbox",checked:e.includes(a),onChange:s=>t(s.target.checked?[...e,a]:e.filter(e=>e!==a)),className:"mt-0.5 size-4 accent-[var(--text)] shrink-0 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-[var(--text)]"}),(0,s.jsxs)("span",{children:[(0,s.jsx)("span",{className:"block text-sm font-medium",children:n}),(0,s.jsx)("span",{className:"block mt-1 text-xs text-[var(--text-2)]",children:l})]})]},a))})})}let I=["maxTokensQuota","maxCostUsd","tokenMultiplier","maxOutputTokens","rateLimitRpm","rateLimitTpm"];function D({keyId:e,onClose:t,onSaved:a}){let[n,i]=(0,l.useState)(null),[r,c]=(0,l.useState)(null),[d,u]=(0,l.useState)(""),[m,h]=(0,l.useState)(!1),[x,p]=(0,l.useState)([]),[g,f]=(0,l.useState)({});(0,l.useEffect)(()=>{let t=!1;return async function(){try{let a=await fetch(`/api/keys/${e}`,{cache:"no-store"}),s=await a.json();if(!a.ok)throw Error(s.error||"Unable to load key settings.");if(t)return;c(s.key),i(function(e){let t={...N,...e,name:e.name||"",expiresAt:function(e){if(!e)return"";let t=new Date(e);return new Date(t.getTime()-6e4*t.getTimezoneOffset()).toISOString().slice(0,16)}(e.expiresAt),allowedEndpoints:e.allowedEndpoints??k.map(e=>e.value)};for(let e of I)t[e]=String(t[e]??"");return t}(s.key));let n=await Promise.allSettled([fetch("/api/providers").then(e=>e.json()),fetch("/api/models/alias").then(e=>e.json())]);if(t)return;"fulfilled"===n[0].status&&p((n[0].value.connections||[]).filter(e=>!1!==e.isActive)),"fulfilled"===n[1].status&&f(n[1].value.aliases||{})}catch(e){t||u(e.message||"Unable to load key settings.")}}(),()=>{t=!0}},[e]);let y=(0,l.useCallback)(()=>{m||t()},[m,t]);function b(e,t){i(a=>({...a,[e]:t}))}async function j(s){if(s.preventDefault(),!m&&n){h(!0),u("");try{let s=Object.fromEntries([...Object.keys(N),"name"].map(e=>[e,n[e]]));for(let e of I)s[e]=""===n[e].trim()?null:Number(n[e]);s.expiresAt=n.expiresAt?new Date(n.expiresAt).toISOString():null,s.allowedEndpoints.length===k.length&&(s.allowedEndpoints=null);let l=await fetch(`/api/keys/${e}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)}),i=await l.json();if(!l.ok)throw Error(i.error||"Unable to save key settings.");v.i.getState().success("API key settings saved."),a(i.key),t()}catch(t){let e=t.message||"Unable to save key settings.";u(e),v.i.getState().error(e)}finally{h(!1)}}}return(0,s.jsxs)(o.aF,{isOpen:!0,onClose:y,title:"Configure API Key",size:"full",trapFocus:!0,closeOnOverlay:!m,footer:(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(o.$n,{variant:"ghost",onClick:y,disabled:m,children:"Cancel"}),(0,s.jsx)(o.$n,{variant:"contrast",type:"submit",form:"api-key-settings",loading:m,disabled:!n||m,children:"Save Settings"})]}),children:[d&&(0,s.jsx)("div",{role:"alert",className:"mb-5 rounded-[var(--r1)] border border-[var(--danger)]/30 bg-[var(--danger)]/5 p-3 text-sm text-[var(--danger)]",children:d}),n?(0,s.jsx)("form",{id:"api-key-settings",onSubmit:j,className:"space-y-6",children:(0,s.jsxs)("fieldset",{disabled:m,className:"space-y-6 min-w-0",children:[(0,s.jsxs)(S,{title:"General Information",children:[(0,s.jsx)(o.pd,{label:"Key Name",value:n.name,onChange:e=>b("name",e.target.value),required:!0,maxLength:120}),(0,s.jsx)(o.pd,{label:"Description",value:n.description,onChange:e=>b("description",e.target.value),placeholder:"Internal description (optional)",maxLength:500}),(0,s.jsxs)("p",{className:"text-xs text-[var(--text-2)] break-all",children:[r.keyPrefix," \xb7 Used ",Number(r.quotaTokens||0).toLocaleString()," accounted tokens / $",Number(r.quotaCost||0).toFixed(4)," this period"]})]}),(0,s.jsx)(T,{form:n,onChange:b}),(0,s.jsx)(E,{form:n,onChange:b}),(0,s.jsx)(A,{form:n,onChange:b}),(0,s.jsx)(R,{form:n,onChange:b,activeProviders:x,modelAliases:g}),(0,s.jsx)(L,{values:n.allowedEndpoints,onChange:e=>b("allowedEndpoints",e)})]})}):(0,s.jsx)("p",{className:"text-sm text-[var(--text-2)]",role:"status",children:d?"Close this dialog and try Configure again.":"Loading key settings…"})]})}function U({enabled:e,reachable:t,loading:a,checking:n,previouslyReachable:l,error:i,loadingLabel:r}){let o="Disabled",d="default";return a?o=r:e?(o=t?"Connected":l?"Reconnecting":"Checking",d=t?"success":"warning"):i?(o="Error",d="error"):n&&(o="Checking"),(0,s.jsx)(c.A,{variant:d,className:`${g().statusBadge} ${"warning"===d?g().statusWarning:"error"===d?g().statusError:""}`,children:o})}function O({machineId:e}){let[t,a]=(0,l.useState)([]),[i,r]=(0,l.useState)(!0),[p,k]=(0,l.useState)(!1),[w,N]=(0,l.useState)(""),[C,_]=(0,l.useState)(null),[S,$]=(0,l.useState)(null),[T,E]=(0,l.useState)(null),[A,P]=(0,l.useState)(!1),[R,L]=(0,l.useState)(!0),[I,q]=(0,l.useState)(!0),[B,M]=(0,l.useState)(!1),[F,W]=(0,l.useState)(!0),[K,z]=(0,l.useState)(!1),[V,Q]=(0,l.useState)(!1),[H,J]=(0,l.useState)(""),[Z,G]=(0,l.useState)(""),[Y,X]=(0,l.useState)(!1),[ee,et]=(0,l.useState)(""),[ea,es]=(0,l.useState)(null),[en,el]=(0,l.useState)(!1),[ei,er]=(0,l.useState)(!1),[eo,ec]=(0,l.useState)(!1),[ed,eu]=(0,l.useState)(!1),[em,eh]=(0,l.useState)(""),[ex,ep]=(0,l.useState)(!1),[eg,ef]=(0,l.useState)(""),[ey,eb]=(0,l.useState)(null),[ej,ev]=(0,l.useState)(""),[ek,ew]=(0,l.useState)(""),[eN,eC]=(0,l.useState)(null),[e_,eS]=(0,l.useState)(!1),[e$,eT]=(0,l.useState)([]),[eE,eA]=(0,l.useState)(""),[eP,eR]=(0,l.useState)(!1),[eL,eI]=(0,l.useState)(!1),[eD,eU]=(0,l.useState)(!1),eO=(0,l.useRef)(null),eq=(0,l.useRef)(0),eB=(0,l.useRef)(0),eM=(0,l.useRef)(!1),eF=(0,l.useRef)(!1),eW=(0,l.useRef)(!1),eK=(0,l.useRef)(!1),[ez,eV]=(0,l.useState)(!1),[eQ,eH]=(0,l.useState)(!1),[eJ,eZ]=(0,l.useState)(!1);(0,l.useEffect)(()=>{eZ(!["localhost","127.0.0.1","::1"].includes(window.location.hostname))},[]);let{copied:eG,copy:eY}=(0,d.C)(),eX=!R||!I,e0=R?"Change the default dashboard password before activating the tunnel.":'Enable "Require login" and set a custom password before activating the tunnel.';(0,l.useEffect)(()=>{eO.current&&(eO.current.scrollTop=eO.current.scrollHeight)},[e$]),(0,l.useEffect)(()=>{e6(),e4()},[]),(0,l.useEffect)(()=>{if(!(K||eo))return;let e=!K||V,t=!eo||ed,a=()=>{document.hidden||e2()};if(document.addEventListener("visibilitychange",a),e&&t)return()=>document.removeEventListener("visibilitychange",a);let s=setInterval(()=>{document.hidden||e2()},u.fl);return()=>{clearInterval(s),document.removeEventListener("visibilitychange",a)}},[K,eo,V,ed]),(0,l.useEffect)(()=>{let e=async()=>{if(!document.hidden){if(K&&(H||Z)){let e=await h(Z,H);eM.current=e,e?(eq.current=0,Q(!0),eW.current||(eW.current=!0,eV(!0))):(eq.current+=1,eq.current>=u.t6&&Q(!1))}else eM.current=!1;if(eo&&em){let e=await m(em);eF.current=e,e?(eB.current=0,eu(!0),eK.current||(eK.current=!0,eH(!0))):(eB.current+=1,eB.current>=u.t6&&eu(!1))}else eF.current=!1}};if(!(K&&(H||Z)||eo&&em))return;e();let t=!eo||ed;if((!K||V)&&t)return;let a=setInterval(e,u.RL);return()=>clearInterval(a)},[K,H,Z,eo,em,V,ed]);let e1=(0,l.useCallback)((e,t,a,s,n,l)=>{t.current?(a.current=0,s(!0),n.current||(n.current=!0,l(!0))):(a.current+=1,a.current>=u.t6&&s(!1))},[]),e2=async()=>{try{let e=await fetch("/api/tunnel/status",{cache:"no-store"});if(!e.ok)return;let t=await e.json(),a=t.tunnel?.settingsEnabled??t.tunnel?.enabled??!1,s=t.tunnel?.tunnelUrl||"";J(s),G(t.tunnel?.publicUrl||""),z(a),e1(null,eM,eq,Q,eW,eV);let n=t.tailscale?.settingsEnabled??t.tailscale?.enabled??!1,l=t.tailscale?.tunnelUrl||"";eh(l),ec(n),e1(null,eF,eB,eu,eK,eH)}catch{}},e4=async()=>{W(!0);try{let[e,t]=await Promise.all([x.A.getState().fetchSettings(),fetch("/api/tunnel/status",{cache:"no-store"})]);if(e&&(P(e.requireApiKey||!1),L(!1!==e.requireLogin),q(e.hasPassword||!1),M(e.tunnelDashboardAccess||!1)),t.ok){let e=await t.json(),a=e.tunnel?.settingsEnabled??e.tunnel?.enabled??!1,s=e.tunnel?.tunnelUrl||"";J(s),G(e.tunnel?.publicUrl||""),z(a),e1(null,eM,eq,Q,eW,eV);let n=e.tailscale?.settingsEnabled??e.tailscale?.enabled??!1,l=e.tailscale?.tunnelUrl||"";eh(l),ec(n),e1(null,eF,eB,eu,eK,eH)}}catch(e){console.log("Error loading settings:",e)}finally{W(!1)}},e3=async e=>{try{await x.A.getState().patchSettings({tunnelDashboardAccess:e})&&M(e)}catch(e){console.log("Error updating tunnelDashboardAccess:",e)}},e5=async e=>{try{await x.A.getState().patchSettings({requireApiKey:e})&&P(e)}catch(e){console.log("Error updating requireApiKey:",e)}},e6=async()=>{try{let e=async()=>{let e=await fetch("/api/keys?view=settings",{cache:"no-store"});return e.ok&&(await e.json()).keys||[]},t=await e();if(0===t.length)try{(await fetch("/api/keys",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:"Default Key"})})).ok&&(t=await e())}catch{}a(t)}catch(e){console.log("Error fetching data:",e)}finally{r(!1)}},e8=async(...e)=>{X(!0),et("Waiting for tunnel ready...");let t=e.filter(Boolean).map(e=>`${e}/api/health`),a=Date.now();for(;Date.now()-a<u.Cp;){if(await new Promise(e=>setTimeout(e,u.Hx)),await Promise.any(t.map(async e=>{if((await fetch(e,{mode:"cors",cache:"no-store"})).ok)return!0;throw Error("not ready")})).catch(()=>!1))return z(!0),X(!1),et(""),!0;if((Date.now()-a)%1e4<u.Hx)try{let e=await fetch("/api/tunnel/status");if(e.ok){let t=await e.json();if(!t.tunnel?.enabled)return es({type:"error",message:"Tunnel process stopped unexpectedly."}),X(!1),et(""),!1}}catch{}}return es({type:"error",message:"Tunnel created but not reachable. Please try again."}),X(!1),et(""),!1},e9=async()=>{el(!1),X(!0),es(null),et("Creating tunnel...");let e=!0;(async()=>{for(;e;){try{let t=await fetch("/api/tunnel/status");if(t.ok){let a=await t.json();a.download?.downloading?et(`Downloading cloudflared... ${a.download.progress}%`):e&&et("Creating tunnel...")}}catch{}await new Promise(e=>setTimeout(e,1e3))}})();try{let t=await fetch("/api/tunnel/enable",{method:"POST"});e=!1;let a=await t.json();if(!t.ok)return void es({type:"error",message:a.error||"Failed to enable tunnel"});let s=a.tunnelUrl;if(!s)return void es({type:"error",message:"No tunnel URL returned"});J(s),G(a.publicUrl||""),await e8(a.publicUrl,s)}catch(e){es({type:"error",message:e.message})}finally{e=!1,X(!1),et("")}},e7=async()=>{X(!0),es(null);try{let e=await fetch("/api/tunnel/disable",{method:"POST"}),t=await e.json();e.ok?(z(!1),J(""),er(!1),es({type:"success",message:"Tunnel disabled"})):es({type:"error",message:t.error||"Failed to disable tunnel"})}catch(e){es({type:"error",message:e.message})}finally{X(!1)}},te=async()=>{eC(null);try{let e=await fetch("/api/tunnel/tailscale-check");if(e.ok){let t=await e.json();return eC(t.installed),t}}catch{}return eC(!1),{installed:!1}},tt=async()=>{eS(!0),eb(null),eT([]);try{let e=await fetch("/api/tunnel/tailscale-install",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sudoPassword:eE})});eA("");let t=e.body.getReader(),a=new TextDecoder,s="";for(;;){let{done:e,value:n}=await t.read();if(e)break;let l=(s+=a.decode(n,{stream:!0})).split("\n\n");for(let e of(s=l.pop()||"",l)){let t=e.split("\n"),a="progress",s=null;for(let e of t)if(e.startsWith("event: ")&&(a=e.slice(7).trim()),e.startsWith("data: "))try{s=JSON.parse(e.slice(6))}catch{}if(s)if("progress"===a)eT(e=>[...e.slice(-50),s.message]);else if("done"===a){eC(!0),eS(!1),eI(!1),tl();return}else"error"===a&&eb({type:"error",message:s.error||"Install failed"})}}}catch(e){eb({type:"error",message:e.message})}finally{eS(!1)}},ta=async e=>{ef("Waiting for Tailscale ready...");let t=`${e}/api/health`,a=Date.now();for(;Date.now()-a<u.Cp;){await new Promise(e=>setTimeout(e,u.Hx));try{let e=await fetch(t,{mode:"no-cors",cache:"no-store"});if(e.ok||"opaque"===e.type)return!0}catch{}}return!1},ts=(e,t)=>{ev(e),ew(t)},tn=()=>{ev(""),ew("")},tl=async()=>{eI(!1),eR(!0),ep(!0),eb(null),ef("Connecting..."),tn();try{let e=await fetch("/api/tunnel/tailscale-enable",{method:"POST"}),t=await e.json();if(e.ok&&t.success){eh(t.tunnelUrl||"");let e=await ta(t.tunnelUrl);ec(!0),eb(e?null:{type:"warning",message:"Connected but not reachable yet."});return}if(t.needsLogin&&t.authUrl){ts(t.authUrl,"Open Login Page"),ef('Login required — click "Open Login Page" to continue');for(let e=0;e<40;e++){await new Promise(e=>setTimeout(e,3e3));try{let e=await fetch("/api/tunnel/tailscale-check");if(e.ok&&(await e.json()).loggedIn){tn(),ef("Starting funnel...");let e=await fetch("/api/tunnel/tailscale-enable",{method:"POST"}),t=await e.json();if(e.ok&&t.success){eh(t.tunnelUrl||"");let e=await ta(t.tunnelUrl);ec(!0),eb(e?null:{type:"warning",message:"Connected but not reachable yet."})}else t.funnelNotEnabled&&t.enableUrl?await ti(t.enableUrl):eb({type:"error",message:t.error||"Failed to start funnel"});return}}catch{}}tn(),eb({type:"error",message:"Login timed out. Please try again."});return}if(t.funnelNotEnabled&&t.enableUrl)return void await ti(t.enableUrl);eb({type:"error",message:t.error||"Failed to connect"})}catch(e){eb({type:"error",message:e.message})}finally{ep(!1),eR(!1),ef(""),tn()}},ti=async e=>{ts(e,"Open Funnel Settings"),ef('Click "Open Funnel Settings" to enable Funnel...');for(let e=0;e<40;e++){await new Promise(e=>setTimeout(e,3e3));try{let e=await fetch("/api/tunnel/tailscale-enable",{method:"POST"}),t=await e.json();if(e.ok&&t.success){tn(),eh(t.tunnelUrl||"");let e=await ta(t.tunnelUrl);ec(!0),eb(e?null:{type:"warning",message:"Connected but not reachable yet."});return}if(t.funnelNotEnabled)continue;if(t.error){tn(),eb({type:"error",message:t.error});return}}catch{}}tn(),eb({type:"error",message:"Timed out waiting for Funnel to be enabled."})},tr=async()=>{ep(!0),eb(null);try{let e=await fetch("/api/tunnel/tailscale-disable",{method:"POST"}),t=await e.json();e.ok?(ec(!1),eh(""),eU(!1),eb({type:"success",message:"Tailscale disabled"})):eb({type:"error",message:t.error||"Failed to disable Tailscale"})}catch(e){eb({type:"error",message:e.message})}finally{ep(!1)}},to=async()=>{eb(null),eT([]);let e=await te();e?.installed&&e?.hasCachedPassword?tl():eI(!0)},tc=async()=>{if(w.trim())try{let e=await fetch("/api/keys",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:w})}),t=await e.json();e.ok&&(_(t.key),await e6(),N(""),k(!1))}catch(e){console.log("Error creating key:",e)}},td=async e=>{$({title:"Delete API Key",message:"Delete this API key?",onConfirm:async()=>{$(null);try{(await fetch(`/api/keys/${e}`,{method:"DELETE"})).ok&&a(t.filter(t=>t.id!==e))}catch(e){console.log("Error deleting key:",e)}}})},tu=async(e,t)=>{try{(await fetch(`/api/keys/${e}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({isActive:t})})).ok&&a(a=>a.map(a=>a.id===e?{...a,isActive:t}:a))}catch(e){console.log("Error toggling key:",e)}},tm=async e=>{try{let t=await fetch(`/api/keys/${e}/secret`,{cache:"no-store"}),a=await t.json();if(!t.ok)throw Error(a.error||"Unable to copy API key.");await eY(a.key,e)}catch(e){v.i.getState().error(e.message)}},[th,tx]=(0,l.useState)("/v1");return((0,l.useEffect)(()=>{tx(`${window.location.origin}/v1`)},[]),i)?(0,s.jsxs)("div",{className:`dashboard-surface ${g().page}`,"aria-busy":"true","aria-label":"Loading endpoint settings",children:[(0,s.jsx)(o.Qv,{}),(0,s.jsx)(o.Qv,{})]}):(0,s.jsxs)("div",{className:`dashboard-surface ${g().page}`,children:[(0,s.jsxs)(o.Zp,{className:`ui-card ${g().panel}`,children:[(0,s.jsx)("div",{className:g().header,children:(0,s.jsxs)("div",{children:[(0,s.jsxs)("h2",{className:"ui-eyebrow",children:[(0,s.jsx)(n.default,{className:"text-[16px]",children:"api"}),"API Endpoint"]}),(0,s.jsx)("p",{className:g().description,children:"Connect your tools locally or enable secure remote access."})]})}),(0,s.jsxs)("div",{className:"flex flex-col",children:[(0,s.jsx)(f,{label:"Local",url:th,copyId:"local_url",copied:eG,onCopy:eY}),(0,s.jsxs)("div",{className:g().row,children:[(0,s.jsxs)("span",{className:g().label,children:["Tunnel",(0,s.jsx)(U,{enabled:K,reachable:V,loading:Y,checking:F,previouslyReachable:ez,error:ea?.type==="error",loadingLabel:"Starting"})]}),K&&!Y&&V?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("div",{className:g().field,children:(0,s.jsx)("output",{className:`${g().endpointValue} font-mono`,"aria-label":"Tunnel endpoint",tabIndex:0,children:`${Z||H}/v1`})}),(0,s.jsx)("button",{onClick:()=>eY(`${Z||H}/v1`,"tunnel_url"),className:g().iconButton,"aria-label":"Copy tunnel endpoint",children:(0,s.jsx)(n.default,{className:"text-[18px]",children:"tunnel_url"===eG?"check":"content_copy"})}),(0,s.jsx)("button",{onClick:()=>er(!0),className:`${g().iconButton} ${g().dangerButton}`,title:"Disable Tunnel","aria-label":"Disable Tunnel",children:(0,s.jsx)(n.default,{className:"text-[18px]",children:"power_settings_new"})})]}):!K||Y||V?Y?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("div",{className:g().status,children:[(0,s.jsx)(n.default,{className:"animate-spin text-sm",children:"progress_activity"}),ee||"Creating tunnel..."]}),(0,s.jsx)("button",{onClick:()=>{X(!1),et("")},className:`${g().iconButton} ${g().dangerButton}`,title:"Stop","aria-label":"Stop creating tunnel",children:(0,s.jsx)(n.default,{className:"text-[18px]",children:"power_settings_new"})})]}):ea?.type==="error"?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("div",{className:`${g().status} ${g().error}`,children:[(0,s.jsx)(n.default,{className:"text-sm",children:"error"}),ea.message]}),(0,s.jsx)(o.$n,{variant:"secondary",size:"sm",icon:"cloud_upload",onClick:()=>el(!0),children:"Enable"})]}):F?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("div",{className:g().status,children:[(0,s.jsx)(n.default,{className:"animate-spin text-sm",children:"progress_activity"}),"Checking..."]}),(0,s.jsx)("button",{onClick:()=>W(!1),className:`${g().iconButton} ${g().dangerButton}`,title:"Stop","aria-label":"Stop checking tunnel",children:(0,s.jsx)(n.default,{className:"text-[18px]",children:"power_settings_new"})})]}):(0,s.jsx)(o.$n,{variant:"secondary",size:"sm",icon:"cloud_upload",onClick:()=>{eX?es({type:"error",message:`Security required: ${e0}`}):A?el(!0):es({type:"error",message:'Security required: Enable "Require API key" before activating the tunnel.'})},children:"Enable"}):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("div",{className:`${g().status} ${g().warning}`,children:[(0,s.jsx)(n.default,{className:"animate-spin text-sm",children:"progress_activity"}),ez?"Tunnel reconnecting...":"Tunnel checking..."]}),(0,s.jsx)("button",{onClick:()=>er(!0),className:`${g().iconButton} ${g().dangerButton}`,title:"Disable Tunnel","aria-label":"Disable Tunnel",children:(0,s.jsx)(n.default,{className:"text-[18px]",children:"power_settings_new"})})]})]}),(0,s.jsxs)("div",{className:g().row,children:[(0,s.jsxs)("span",{className:g().label,children:["Tailscale",(0,s.jsx)(U,{enabled:eo,reachable:ed,loading:ex||eP,previouslyReachable:eQ,error:ey?.type==="error",loadingLabel:"Connecting"})]}),eo&&!ex&&ed?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("div",{className:g().field,children:(0,s.jsx)("output",{className:`${g().endpointValue} font-mono`,"aria-label":"Tailscale endpoint",tabIndex:0,children:`${em}/v1`})}),(0,s.jsx)("button",{onClick:()=>eY(`${em}/v1`,"ts_url"),className:g().iconButton,"aria-label":"Copy Tailscale endpoint",children:(0,s.jsx)(n.default,{className:"text-[18px]",children:"ts_url"===eG?"check":"content_copy"})}),(0,s.jsx)("button",{onClick:()=>eU(!0),className:`${g().iconButton} ${g().dangerButton}`,title:"Disable Tailscale","aria-label":"Disable Tailscale",children:(0,s.jsx)(n.default,{className:"text-[18px]",children:"power_settings_new"})})]}):!eo||ex||ed?ex||eP?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("div",{className:g().status,children:[(0,s.jsx)(n.default,{className:"animate-spin text-sm",children:"progress_activity"}),eg||"Connecting..."]}),ej&&(0,s.jsx)(o.$n,{variant:"secondary",size:"sm",icon:"open_in_new",onClick:()=>window.open(ej,"tailscale_auth","width=600,height=700,noopener,noreferrer"),children:ek||"Open"}),(0,s.jsx)("button",{onClick:()=>{ep(!1),eR(!1),ef(""),tn()},className:`${g().iconButton} ${g().dangerButton}`,title:"Stop","aria-label":"Stop connecting Tailscale",children:(0,s.jsx)(n.default,{className:"text-[18px]",children:"power_settings_new"})})]}):ey?.type==="error"?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("div",{className:`${g().status} ${g().error}`,children:[(0,s.jsx)(n.default,{className:"text-sm",children:"error"}),ey.message]}),(0,s.jsx)(o.$n,{variant:"secondary",size:"sm",icon:"vpn_lock",onClick:to,children:"Enable"})]}):(0,s.jsx)(o.$n,{size:"sm",icon:"vpn_lock",onClick:()=>{eX?eb({type:"error",message:`Security required: ${e0}`}):to()},variant:"secondary",children:"Enable"}):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("div",{className:`${g().status} ${g().warning}`,children:[(0,s.jsx)(n.default,{className:"animate-spin text-sm",children:"progress_activity"}),eQ?"Tailscale reconnecting...":"Tailscale checking..."]}),(0,s.jsx)("button",{onClick:()=>eU(!0),className:`${g().iconButton} ${g().dangerButton}`,title:"Disable Tailscale","aria-label":"Disable Tailscale",children:(0,s.jsx)(n.default,{className:"text-[18px]",children:"power_settings_new"})})]})]})]}),eX&&!K&&!eo&&(0,s.jsx)("div",{className:"mt-4",children:(0,s.jsx)(j,{message:e0,action:{label:"Open settings",href:"/dashboard/profile"}})}),(K||eo)&&(0,s.jsxs)("div",{className:"mt-4 flex flex-col gap-2",children:[!A&&(0,s.jsx)(j,{message:"Require API key is disabled — your endpoint is publicly accessible without authentication.",action:{label:"Enable",href:"#require-api-key"}}),(!R||!I)&&(0,s.jsx)(j,{message:R?"Dashboard uses the default password — change it in Profile settings.":"Require login is disabled — anyone can access your dashboard via tunnel.",action:{label:R?"Change password":"Enable",href:"/dashboard/profile"}})]}),(K||eo)&&(0,s.jsxs)("div",{className:"mt-5 pt-5 border-t border-border-subtle flex items-center gap-3",children:[(0,s.jsx)(o.lM,{"aria-label":"Allow dashboard access via tunnel",checked:B,onChange:()=>e3(!B)}),(0,s.jsxs)("div",{className:"flex items-center gap-1.5 min-w-0",children:[(0,s.jsx)("p",{className:"font-medium text-sm",children:"Allow dashboard access via tunnel"}),(0,s.jsx)(b,{text:"When enabled, the dashboard can be accessed through your tunnel or Tailscale URL (login still required). When disabled, dashboard access via tunnel/Tailscale is completely blocked."})]})]})]}),(0,s.jsxs)(o.Zp,{className:`ui-card ${g().panel}`,id:"require-api-key",children:[(0,s.jsxs)("div",{className:g().header,children:[(0,s.jsxs)("div",{children:[(0,s.jsxs)("h2",{className:"ui-eyebrow",children:[(0,s.jsx)(n.default,{className:"text-[16px]",children:"vpn_key"}),"API Keys"]}),(0,s.jsx)("p",{className:g().description,children:"Manage credentials used to authenticate API requests."})]}),(0,s.jsx)(o.$n,{variant:"contrast",icon:"add",onClick:()=>k(!0),children:"Create Key"})]}),(0,s.jsxs)("div",{className:g().settingsRow,children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:"text-sm font-medium",children:"Require API key"}),(0,s.jsx)("p",{className:"text-xs text-text-muted mt-1",children:"Requests without a valid key will be rejected"})]}),(0,s.jsx)(o.lM,{"aria-label":"Require API key",checked:A,onChange:()=>e5(!A)})]}),eJ&&!A&&(0,s.jsx)("div",{className:"mb-4 -mt-2",children:(0,s.jsx)(j,{message:"Endpoint is exposed without an API key."})}),0===t.length?(0,s.jsxs)("div",{className:"text-center py-8",children:[(0,s.jsx)("div",{className:"inline-flex items-center justify-center text-text-muted mb-4",children:(0,s.jsx)(n.default,{className:"text-[32px]",children:"vpn_key"})}),(0,s.jsx)("p",{className:"text-text-main font-medium mb-1",children:"No API keys yet"}),(0,s.jsx)("p",{className:"text-sm text-text-muted mb-4",children:"Create your first API key to get started"}),(0,s.jsx)(o.$n,{variant:"contrast",icon:"add",onClick:()=>k(!0),children:"Create Key"})]}):(0,s.jsx)("div",{className:"flex flex-col",children:t.map(e=>(0,s.jsxs)("div",{className:g().keyRow,children:[(0,s.jsxs)("div",{className:g().keyDetails,children:[(0,s.jsxs)("div",{className:g().keyName,children:[(0,s.jsx)("p",{className:"text-sm font-medium break-words min-w-0",children:e.name}),(0,s.jsx)(c.A,{variant:!1===e.isActive?"default":e.isExpired?"error":"success",className:g().statusBadge,children:!1===e.isActive?"Paused":e.isExpired?"Expired":"Active"})]}),(0,s.jsxs)("div",{className:g().keyCredential,children:[(0,s.jsx)("code",{className:`${g().keyValue} text-xs text-text-muted font-mono`,"data-i18n-skip":!0,children:e.keyPrefix}),(0,s.jsx)("button",{onClick:()=>tm(e.id),className:g().iconButton,"aria-label":"Copy API key",children:(0,s.jsx)(n.default,{className:"text-[14px]",children:eG===e.id?"check":"content_copy"})})]}),(0,s.jsxs)("p",{className:`${g().keyMeta} text-xs text-text-muted mt-1`,children:["Created ",new Date(e.createdAt).toLocaleDateString(),e.lastUsedAt&&` \xb7 Last used ${new Date(e.lastUsedAt).toLocaleDateString()}`]}),(0,s.jsxs)("p",{className:"text-xs text-text-muted mt-1",children:[null!=e.maxTokensQuota?`${Number(e.quotaTokens||0).toLocaleString()} / ${Number(e.maxTokensQuota).toLocaleString()} tokens`:null!=e.maxCostUsd?`$${Number(e.quotaCost||0).toFixed(2)} / $${Number(e.maxCostUsd).toFixed(2)}`:"Unlimited quota",null!=e.rateLimitRpm&&` \xb7 ${e.rateLimitRpm} RPM`,(e.allowedModels?.length>0||e.blockedModels?.length>0)&&" \xb7 Restricted models"]})]}),(0,s.jsxs)("div",{className:g().keyActions,children:[(0,s.jsx)(o.$n,{variant:"secondary",size:"sm",icon:"settings",onClick:()=>E(e.id),"aria-label":`Configure ${e.name}`,children:"Configure"}),(0,s.jsx)(o.lM,{"aria-label":`${!1===e.isActive?"Resume":"Pause"} ${e.name}`,size:"sm",checked:e.isActive??!0,onChange:t=>{e.isActive&&!t?$({title:"Pause API Key",message:`Pause API key "${e.name}"?
2
2
 
3
- This key will stop working immediately but can be resumed later.`,onConfirm:async()=>{$(null),tu(e.id,t)}}):tu(e.id,t)},title:e.isActive?"Pause key":"Resume key"}),(0,s.jsx)("button",{onClick:()=>td(e.id),className:`${g().iconButton} ${g().dangerButton}`,"aria-label":"Delete API key",children:(0,s.jsx)(n.default,{className:"text-[18px]",children:"delete"})})]})]},e.id))})]}),T&&(0,s.jsx)(D,{keyId:T,onClose:()=>E(null),onSaved:e=>a(t=>t.map(t=>t.id===e.id?e:t))},T),(0,s.jsx)(o.aF,{className:g().dialog,isOpen:p,title:"Create API Key",onClose:()=>{k(!1),N("")},children:(0,s.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,s.jsx)(o.pd,{label:"Key Name","aria-label":"Key Name",value:w,onChange:e=>N(e.target.value),placeholder:"Production Key"}),(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsx)(o.$n,{variant:"contrast",onClick:tc,fullWidth:!0,disabled:!w.trim(),children:"Create"}),(0,s.jsx)(o.$n,{onClick:()=>{k(!1),N("")},variant:"ghost",fullWidth:!0,children:"Cancel"})]})]})}),(0,s.jsx)(o.aF,{className:g().dialog,isOpen:!!C,title:"API Key Created",onClose:()=>_(null),children:(0,s.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,s.jsxs)("div",{className:`${g().warning} rounded-[var(--r2)] p-4`,children:[(0,s.jsx)("p",{className:"text-sm mb-2 font-medium",children:"Save this key now!"}),(0,s.jsx)("p",{className:"text-sm",children:"This is the only time you will see this key. Store it securely."})]}),(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsx)(o.pd,{value:C||"",readOnly:!0,className:g().field,inputClassName:"font-mono","aria-label":"Created API key"}),(0,s.jsx)(o.$n,{variant:"secondary",icon:"created_key"===eG?"check":"content_copy",onClick:()=>eY(C,"created_key"),children:"created_key"===eG?"Copied!":"Copy"})]}),(0,s.jsx)(o.$n,{variant:"contrast",onClick:()=>_(null),fullWidth:!0,children:"Done"})]})}),(0,s.jsx)(o.aF,{className:g().dialog,isOpen:en,title:"Enable Tunnel",onClose:()=>el(!1),children:(0,s.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,s.jsx)("div",{className:"bg-surface-2 border border-border-subtle rounded-lg p-4",children:(0,s.jsxs)("div",{className:"flex items-start gap-3",children:[(0,s.jsx)(n.default,{className:"text-text-muted shrink-0",children:"cloud_upload"}),(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:"text-sm text-text-main font-medium mb-1",children:"Cloudflare Tunnel"}),(0,s.jsx)("p",{className:"text-sm text-text-muted",children:"Expose your local 9Router to the internet. No port forwarding, no static IP needed. Share endpoint URL with your team or use it in Cursor, Cline, and other AI tools from anywhere."})]})]})}),(0,s.jsx)("div",{className:"grid grid-cols-2 gap-3",children:u.oX.map(e=>(0,s.jsxs)("div",{className:"flex flex-col items-center text-center p-3 rounded-[var(--r2)] bg-surface-2",children:[(0,s.jsx)(n.default,{className:"text-xl text-text-muted mb-1",children:e.icon}),(0,s.jsx)("p",{className:"text-xs font-semibold",children:e.title}),(0,s.jsx)("p",{className:"text-xs text-text-muted",children:e.desc})]},e.title))}),(0,s.jsx)("p",{className:"text-xs text-text-muted",children:"Requires outbound port 7844 (TCP/UDP). Connection may take 10-30s."}),(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsx)(o.$n,{variant:"contrast",onClick:e9,fullWidth:!0,children:"Start Tunnel"}),(0,s.jsx)(o.$n,{onClick:()=>el(!1),variant:"ghost",fullWidth:!0,children:"Cancel"})]})]})}),(0,s.jsx)(o.aF,{className:g().dialog,isOpen:ei,title:"Disable Tunnel",onClose:()=>!Y&&er(!1),children:(0,s.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,s.jsx)("p",{className:"text-sm text-text-muted",children:"The Cloudflare tunnel will be disconnected. Remote access via tunnel URL will stop working."}),(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsx)(o.$n,{className:g().dangerButton,onClick:e7,fullWidth:!0,disabled:Y,variant:"danger",children:Y?"Disabling...":"Disable"}),(0,s.jsx)(o.$n,{onClick:()=>er(!1),variant:"ghost",fullWidth:!0,disabled:Y,children:"Cancel"})]})]})}),(0,s.jsx)(o.aF,{className:g().dialog,isOpen:eL,title:"Tailscale Funnel",onClose:()=>{e_||(eI(!1),eA(""),eb(null))},children:(0,s.jsxs)("div",{className:"flex flex-col gap-4",children:[null===eN&&(0,s.jsxs)("p",{className:"text-sm text-text-muted flex items-center gap-2",children:[(0,s.jsx)(n.default,{className:"animate-spin text-sm",children:"progress_activity"}),"Checking..."]}),!1===eN&&!e_&&(0,s.jsxs)("div",{className:"flex flex-col gap-3",children:[(0,s.jsx)("p",{className:"text-sm text-text-muted",children:"Tailscale is not installed. Install it to enable Funnel."}),(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsx)(o.$n,{variant:"contrast",onClick:tt,fullWidth:!0,children:"Install Tailscale"}),(0,s.jsx)(o.$n,{onClick:()=>eI(!1),variant:"ghost",fullWidth:!0,children:"Cancel"})]})]}),e_&&(0,s.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2 text-sm text-text-muted",children:[(0,s.jsx)(n.default,{className:"animate-spin text-sm",children:"progress_activity"}),"Installing Tailscale..."]}),e$.length>0&&(0,s.jsx)("div",{ref:eO,className:"bg-surface-inset rounded-[var(--r1)] p-3 max-h-40 overflow-y-auto font-mono text-xs text-text-muted","data-i18n-skip":!0,children:e$.map((e,t)=>(0,s.jsx)("div",{children:e},t))})]}),!0===eN&&!e_&&(0,s.jsxs)("div",{className:"flex flex-col gap-3",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2 text-sm text-[var(--pos)]",children:[(0,s.jsx)(n.default,{className:"text-[16px]",children:"check_circle"}),"Tailscale installed"]}),(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsx)(o.$n,{variant:"contrast",onClick:()=>tl(),fullWidth:!0,children:"Connect"}),(0,s.jsx)(o.$n,{onClick:()=>eI(!1),variant:"ghost",fullWidth:!0,children:"Cancel"})]})]}),ey&&(0,s.jsx)(y,{status:ey})]})}),(0,s.jsx)(o.aF,{className:g().dialog,isOpen:eD,title:"Disable Tailscale",onClose:()=>!ex&&eU(!1),children:(0,s.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,s.jsx)("p",{className:"text-sm text-text-muted",children:"Tailscale Funnel will be stopped. Remote access via Tailscale URL will stop working."}),(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsx)(o.$n,{className:g().dangerButton,onClick:tr,fullWidth:!0,disabled:ex,variant:"danger",children:ex?"Disabling...":"Disable"}),(0,s.jsx)(o.$n,{onClick:()=>eU(!1),variant:"ghost",fullWidth:!0,disabled:ex,children:"Cancel"})]})]})}),(0,s.jsx)(o.uo,{className:g().dialog,isOpen:!!S,onClose:()=>$(null),onConfirm:S?.onConfirm,title:S?.title||"Confirm",message:S?.message,variant:"danger"})]})}O.propTypes={machineId:r().string.isRequired}},44029:(e,t,a)=>{Promise.resolve().then(a.bind(a,43728))}},e=>{e.O(0,[3493,8679,4660,2904,6506,8500,3847,1321,705,5497,8441,3794,7358],()=>e(e.s=44029)),_N_E=e.O()}]);
3
+ This key will stop working immediately but can be resumed later.`,onConfirm:async()=>{$(null),tu(e.id,t)}}):tu(e.id,t)},title:e.isActive?"Pause key":"Resume key"}),(0,s.jsx)("button",{onClick:()=>td(e.id),className:`${g().iconButton} ${g().dangerButton}`,"aria-label":"Delete API key",children:(0,s.jsx)(n.default,{className:"text-[18px]",children:"delete"})})]})]},e.id))})]}),T&&(0,s.jsx)(D,{keyId:T,onClose:()=>E(null),onSaved:e=>a(t=>t.map(t=>t.id===e.id?e:t))},T),(0,s.jsx)(o.aF,{className:g().dialog,isOpen:p,title:"Create API Key",onClose:()=>{k(!1),N("")},children:(0,s.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,s.jsx)(o.pd,{label:"Key Name","aria-label":"Key Name",value:w,onChange:e=>N(e.target.value),placeholder:"Production Key"}),(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsx)(o.$n,{variant:"contrast",onClick:tc,fullWidth:!0,disabled:!w.trim(),children:"Create"}),(0,s.jsx)(o.$n,{onClick:()=>{k(!1),N("")},variant:"ghost",fullWidth:!0,children:"Cancel"})]})]})}),(0,s.jsx)(o.aF,{className:g().dialog,isOpen:!!C,title:"API Key Created",onClose:()=>_(null),children:(0,s.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,s.jsxs)("div",{className:`${g().warning} rounded-[var(--r2)] p-4`,children:[(0,s.jsx)("p",{className:"text-sm mb-2 font-medium",children:"Save this key now!"}),(0,s.jsx)("p",{className:"text-sm",children:"This is the only time you will see this key. Store it securely."})]}),(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsx)(o.pd,{value:C||"",readOnly:!0,className:g().field,inputClassName:"font-mono","aria-label":"Created API key"}),(0,s.jsx)(o.$n,{variant:"secondary",icon:"created_key"===eG?"check":"content_copy",onClick:()=>eY(C,"created_key"),children:"created_key"===eG?"Copied!":"Copy"})]}),(0,s.jsx)(o.$n,{variant:"contrast",onClick:()=>_(null),fullWidth:!0,children:"Done"})]})}),(0,s.jsx)(o.aF,{className:g().dialog,isOpen:en,title:"Enable Tunnel",onClose:()=>el(!1),children:(0,s.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,s.jsx)("div",{className:"bg-surface-2 border border-border-subtle rounded-lg p-4",children:(0,s.jsxs)("div",{className:"flex items-start gap-3",children:[(0,s.jsx)(n.default,{className:"text-text-muted shrink-0",children:"cloud_upload"}),(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:"text-sm text-text-main font-medium mb-1",children:"Cloudflare Tunnel"}),(0,s.jsx)("p",{className:"text-sm text-text-muted",children:"Expose your local JRouter to the internet. No port forwarding, no static IP needed. Share endpoint URL with your team or use it in Cursor, Cline, and other AI tools from anywhere."})]})]})}),(0,s.jsx)("div",{className:"grid grid-cols-2 gap-3",children:u.oX.map(e=>(0,s.jsxs)("div",{className:"flex flex-col items-center text-center p-3 rounded-[var(--r2)] bg-surface-2",children:[(0,s.jsx)(n.default,{className:"text-xl text-text-muted mb-1",children:e.icon}),(0,s.jsx)("p",{className:"text-xs font-semibold",children:e.title}),(0,s.jsx)("p",{className:"text-xs text-text-muted",children:e.desc})]},e.title))}),(0,s.jsx)("p",{className:"text-xs text-text-muted",children:"Requires outbound port 7844 (TCP/UDP). Connection may take 10-30s."}),(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsx)(o.$n,{variant:"contrast",onClick:e9,fullWidth:!0,children:"Start Tunnel"}),(0,s.jsx)(o.$n,{onClick:()=>el(!1),variant:"ghost",fullWidth:!0,children:"Cancel"})]})]})}),(0,s.jsx)(o.aF,{className:g().dialog,isOpen:ei,title:"Disable Tunnel",onClose:()=>!Y&&er(!1),children:(0,s.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,s.jsx)("p",{className:"text-sm text-text-muted",children:"The Cloudflare tunnel will be disconnected. Remote access via tunnel URL will stop working."}),(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsx)(o.$n,{className:g().dangerButton,onClick:e7,fullWidth:!0,disabled:Y,variant:"danger",children:Y?"Disabling...":"Disable"}),(0,s.jsx)(o.$n,{onClick:()=>er(!1),variant:"ghost",fullWidth:!0,disabled:Y,children:"Cancel"})]})]})}),(0,s.jsx)(o.aF,{className:g().dialog,isOpen:eL,title:"Tailscale Funnel",onClose:()=>{e_||(eI(!1),eA(""),eb(null))},children:(0,s.jsxs)("div",{className:"flex flex-col gap-4",children:[null===eN&&(0,s.jsxs)("p",{className:"text-sm text-text-muted flex items-center gap-2",children:[(0,s.jsx)(n.default,{className:"animate-spin text-sm",children:"progress_activity"}),"Checking..."]}),!1===eN&&!e_&&(0,s.jsxs)("div",{className:"flex flex-col gap-3",children:[(0,s.jsx)("p",{className:"text-sm text-text-muted",children:"Tailscale is not installed. Install it to enable Funnel."}),(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsx)(o.$n,{variant:"contrast",onClick:tt,fullWidth:!0,children:"Install Tailscale"}),(0,s.jsx)(o.$n,{onClick:()=>eI(!1),variant:"ghost",fullWidth:!0,children:"Cancel"})]})]}),e_&&(0,s.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2 text-sm text-text-muted",children:[(0,s.jsx)(n.default,{className:"animate-spin text-sm",children:"progress_activity"}),"Installing Tailscale..."]}),e$.length>0&&(0,s.jsx)("div",{ref:eO,className:"bg-surface-inset rounded-[var(--r1)] p-3 max-h-40 overflow-y-auto font-mono text-xs text-text-muted","data-i18n-skip":!0,children:e$.map((e,t)=>(0,s.jsx)("div",{children:e},t))})]}),!0===eN&&!e_&&(0,s.jsxs)("div",{className:"flex flex-col gap-3",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2 text-sm text-[var(--pos)]",children:[(0,s.jsx)(n.default,{className:"text-[16px]",children:"check_circle"}),"Tailscale installed"]}),(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsx)(o.$n,{variant:"contrast",onClick:()=>tl(),fullWidth:!0,children:"Connect"}),(0,s.jsx)(o.$n,{onClick:()=>eI(!1),variant:"ghost",fullWidth:!0,children:"Cancel"})]})]}),ey&&(0,s.jsx)(y,{status:ey})]})}),(0,s.jsx)(o.aF,{className:g().dialog,isOpen:eD,title:"Disable Tailscale",onClose:()=>!ex&&eU(!1),children:(0,s.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,s.jsx)("p",{className:"text-sm text-text-muted",children:"Tailscale Funnel will be stopped. Remote access via Tailscale URL will stop working."}),(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsx)(o.$n,{className:g().dangerButton,onClick:tr,fullWidth:!0,disabled:ex,variant:"danger",children:ex?"Disabling...":"Disable"}),(0,s.jsx)(o.$n,{onClick:()=>eU(!1),variant:"ghost",fullWidth:!0,disabled:ex,children:"Cancel"})]})]})}),(0,s.jsx)(o.uo,{className:g().dialog,isOpen:!!S,onClose:()=>$(null),onConfirm:S?.onConfirm,title:S?.title||"Confirm",message:S?.message,variant:"danger"})]})}O.propTypes={machineId:r().string.isRequired}},44029:(e,t,a)=>{Promise.resolve().then(a.bind(a,43728))}},e=>{e.O(0,[3493,8679,4660,2904,6506,8500,3847,1321,705,5497,8441,3794,7358],()=>e(e.s=44029)),_N_E=e.O()}]);
@@ -1 +1 @@
1
- (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[3471],{29404:(e,s,t)=>{"use strict";t.r(s),t.d(s,{default:()=>f});var a=t(95155),i=t(96439),r=t(12115),l=t(35497),o=t(81127),n=t(21931),d=t(1620),c=t(90620),m=t(93308);let p={en:"\uD83C\uDDFA\uD83C\uDDF8",vi:"\uD83C\uDDFB\uD83C\uDDF3","zh-CN":"\uD83C\uDDE8\uD83C\uDDF3","zh-TW":"\uD83C\uDDF9\uD83C\uDDFC",ja:"\uD83C\uDDEF\uD83C\uDDF5","pt-BR":"\uD83C\uDDE7\uD83C\uDDF7","pt-PT":"\uD83C\uDDF5\uD83C\uDDF9",ko:"\uD83C\uDDF0\uD83C\uDDF7",es:"\uD83C\uDDEA\uD83C\uDDF8",de:"\uD83C\uDDE9\uD83C\uDDEA",fr:"\uD83C\uDDEB\uD83C\uDDF7",he:"\uD83C\uDDEE\uD83C\uDDF1",ar:"\uD83C\uDDF8\uD83C\uDDE6",ru:"\uD83C\uDDF7\uD83C\uDDFA",pl:"\uD83C\uDDF5\uD83C\uDDF1",cs:"\uD83C\uDDE8\uD83C\uDDFF",nl:"\uD83C\uDDF3\uD83C\uDDF1",tr:"\uD83C\uDDF9\uD83C\uDDF7",uk:"\uD83C\uDDFA\uD83C\uDDE6",tl:"\uD83C\uDDF5\uD83C\uDDED",id:"\uD83C\uDDEE\uD83C\uDDE9",th:"\uD83C\uDDF9\uD83C\uDDED",km:"\uD83C\uDDF0\uD83C\uDDED",hi:"\uD83C\uDDEE\uD83C\uDDF3",bn:"\uD83C\uDDE7\uD83C\uDDE9",ur:"\uD83C\uDDF5\uD83C\uDDF0",ro:"\uD83C\uDDF7\uD83C\uDDF4",sv:"\uD83C\uDDF8\uD83C\uDDEA",it:"\uD83C\uDDEE\uD83C\uDDF9",el:"\uD83C\uDDEC\uD83C\uDDF7",hu:"\uD83C\uDDED\uD83C\uDDFA",fi:"\uD83C\uDDEB\uD83C\uDDEE",da:"\uD83C\uDDE9\uD83C\uDDF0",no:"\uD83C\uDDF3\uD83C\uDDF4",fa:"\uD83C\uDDEE\uD83C\uDDF7"};var u=t(48535),x=t.n(u);function h({id:e,title:s,icon:t,description:r,children:o}){return(0,a.jsx)("section",{"aria-labelledby":e,children:(0,a.jsxs)(l.Zp,{padding:"none",className:x().section,children:[(0,a.jsx)("div",{className:x().sectionHeader,children:(0,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsxs)("h2",{id:e,className:"ui-eyebrow",children:[(0,a.jsx)(i.default,{className:"text-[16px]","aria-hidden":"true",children:t}),s]}),r&&(0,a.jsx)("p",{className:x().sectionDescription,children:r})]})}),o]})})}function g({status:e}){return e.message?(0,a.jsxs)("p",{className:x().status,"data-status":e.type,role:"error"===e.type?"alert":"status",children:[(0,a.jsx)(i.default,{className:"shrink-0 text-[14px]","aria-hidden":"true",children:"error"===e.type?"error":"check_circle"}),e.message]}):null}function b(){return(0,a.jsx)("header",{className:x().header,children:(0,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsxs)("h1",{className:"ui-eyebrow",children:[(0,a.jsx)(i.default,{className:"text-[16px]","aria-hidden":"true",children:"person"}),"Profile"]}),(0,a.jsx)("p",{className:x().description,children:"Preferences, security, and settings for your JRouter instance."})]})})}function f(){let{theme:e,setTheme:s}=(0,d.D)(),[t,u]=(0,r.useState)(()=>(function(){if("u"<typeof document)return"en";let e=document.cookie.split(";").find(e=>e.trim().startsWith(`${m.CL}=`)),s=e?decodeURIComponent(e.split("=")[1]):"en";return(0,m.QC)(s)})()),[f,y]=(0,r.useState)(!1),[j,N]=(0,r.useState)(!1),[w,v]=(0,r.useState)(!1),[S,C]=(0,r.useState)({fallbackStrategy:"fill-first"}),[_,k]=(0,r.useState)(!0),[L,I]=(0,r.useState)(""),[A,P]=(0,r.useState)({current:"",new:"",confirm:""}),[O,M]=(0,r.useState)({type:"",message:""}),[R,D]=(0,r.useState)(!1),[E,T]=(0,r.useState)(!1),[U,F]=(0,r.useState)({type:"",message:""}),[$,q]=(0,r.useState)({open:!1,mode:"",password:""}),H=(0,r.useRef)(null),[X,B]=(0,r.useState)({authMode:"password",oidcIssuerUrl:"",oidcClientId:"",oidcScopes:"openid profile email",oidcLoginLabel:"Sign in with OIDC"}),[J,z]=(0,r.useState)(""),[G,K]=(0,r.useState)({type:"",message:""}),[Z,V]=(0,r.useState)(!1),[Q,W]=(0,r.useState)(!1),[Y,ee]=(0,r.useState)({type:"",message:""}),[es,et]=(0,r.useState)(!1),ea=window.location.origin,ei=ea?`${ea}/api/auth/oidc/callback`:"/api/auth/oidc/callback",er=ea?`${ea}/api/auth/saml/acs`:"/api/auth/saml/acs",el=ea?`${ea}/api/auth/saml/metadata`:"/api/auth/saml/metadata",[eo,en]=(0,r.useState)("saml"),[ed,ec]=(0,r.useState)({samlEntryPoint:"",samlIssuer:"urn:9router:sp",samlCert:"",samlLoginLabel:"Sign in with SAML SSO",samlAttributeEmail:"email",samlAttributeName:"name"}),[em,ep]=(0,r.useState)({type:"",message:""}),[eu,ex]=(0,r.useState)(!1),[eh,eg]=(0,r.useState)(!1),[eb,ef]=(0,r.useState)({type:"",message:""}),[ey,ej]=(0,r.useState)(!1),eN=(0,r.useRef)(null),ew=(0,r.useRef)(null),ev=(0,r.useRef)(null),[eS,eC]=(0,r.useState)({outboundProxyEnabled:!1,outboundProxyUrl:"",outboundNoProxy:""}),[e_,ek]=(0,r.useState)({type:"",message:""}),[eL,eI]=(0,r.useState)(!1),[eA,eP]=(0,r.useState)(!1),[eO,eM]=(0,r.useState)(!1);(0,r.useEffect)(()=>{eM(!["localhost","127.0.0.1","::1"].includes(window.location.hostname))},[]);let eR=(0,r.useCallback)(()=>{fetch("/api/settings").then(e=>{if(!e.ok)throw Error("Failed to load settings");return e.json()}).then(e=>{C(e),B({authMode:e?.authMode||"password",oidcIssuerUrl:e?.oidcIssuerUrl||"",oidcClientId:e?.oidcClientId||"",oidcScopes:e?.oidcScopes||"openid profile email",oidcLoginLabel:e?.oidcLoginLabel||"Sign in with OIDC"}),z(""),en(e?.ssoType||"saml"),ec({samlEntryPoint:e?.samlEntryPoint||"",samlIssuer:e?.samlIssuer||"urn:9router:sp",samlCert:e?.samlCert||"",samlLoginLabel:e?.samlLoginLabel||"Sign in with SAML SSO",samlAttributeEmail:e?.samlAttributeEmail||"email",samlAttributeName:e?.samlAttributeName||"name"}),(e?.authMode==="sso"||e?.authMode==="saml"||e?.authMode==="oidc"||e?.authMode==="both")&&et(!0),eC({outboundProxyEnabled:e?.outboundProxyEnabled===!0,outboundProxyUrl:e?.outboundProxyUrl||"",outboundNoProxy:e?.outboundNoProxy||""}),k(!1)}).catch(e=>{console.error("Failed to fetch settings:",e),I("Could not load your instance settings. Try again."),k(!1)})},[]);(0,r.useEffect)(()=>{eR()},[eR]);let eD=async e=>{if(e.preventDefault(),!0===S.outboundProxyEnabled){eI(!0),ek({type:"",message:""});try{let e=await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({outboundProxyUrl:eS.outboundProxyUrl,outboundNoProxy:eS.outboundNoProxy})}),s=await e.json();e.ok?(C(e=>({...e,...s})),ek({type:"success",message:"Proxy settings applied"})):ek({type:"error",message:s.error||"Failed to update proxy settings"})}catch(e){ek({type:"error",message:"An error occurred"})}finally{eI(!1)}}},eE=async()=>{if(!0!==S.outboundProxyEnabled)return;let e=(eS.outboundProxyUrl||"").trim();if(!e)return void ek({type:"error",message:"Please enter a Proxy URL to test"});eP(!0),ek({type:"",message:""});try{let s=await fetch("/api/settings/proxy-test",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({proxyUrl:e})}),t=await s.json();s.ok&&t?.ok?ek({type:"success",message:`Proxy test OK (${t.status}) in ${t.elapsedMs}ms`}):ek({type:"error",message:t?.error||"Proxy test failed"})}catch(e){ek({type:"error",message:"An error occurred"})}finally{eP(!1)}},eT=async e=>{eI(!0),ek({type:"",message:""});try{let s=await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({outboundProxyEnabled:e})}),t=await s.json();s.ok?(C(e=>({...e,...t})),eC(e=>({...e,outboundProxyEnabled:t?.outboundProxyEnabled===!0})),ek({type:"success",message:e?"Proxy enabled":"Proxy disabled"})):ek({type:"error",message:t.error||"Failed to update proxy settings"})}catch(e){ek({type:"error",message:"An error occurred"})}finally{eI(!1)}},eU=async e=>{if(e.preventDefault(),A.new!==A.confirm)return void M({type:"error",message:"Passwords do not match"});D(!0),M({type:"",message:""});try{let e=await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({currentPassword:A.current,newPassword:A.new})}),s=await e.json();e.ok?(M({type:"success",message:"Password updated successfully"}),P({current:"",new:"",confirm:""})):M({type:"error",message:s.error||"Failed to update password"})}catch(e){M({type:"error",message:"An error occurred"})}finally{D(!1)}},eF=async e=>{try{(await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({fallbackStrategy:e})})).ok&&C(s=>({...s,fallbackStrategy:e}))}catch(e){console.error("Failed to update settings:",e)}},e$=async e=>{try{(await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({comboStrategy:e})})).ok&&C(s=>({...s,comboStrategy:e}))}catch(e){console.error("Failed to update combo strategy:",e)}},eq=async e=>{let s=parseInt(e);if(!isNaN(s)&&!(s<1))try{(await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({stickyRoundRobinLimit:s})})).ok&&C(e=>({...e,stickyRoundRobinLimit:s}))}catch(e){console.error("Failed to update sticky limit:",e)}},eH=async e=>{let s=parseInt(e);if(!isNaN(s)&&!(s<1))try{(await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({comboStickyRoundRobinLimit:s})})).ok&&C(e=>({...e,comboStickyRoundRobinLimit:s}))}catch(e){console.error("Failed to update combo sticky limit:",e)}},eX=async e=>{try{(await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({requireLogin:e})})).ok&&C(s=>({...s,requireLogin:e}))}catch(e){console.error("Failed to update require login:",e)}},eB=(e,s)=>{B(t=>({...t,[e]:s}))},eJ=async(e=X.authMode||"password")=>{let s=X.oidcIssuerUrl.trim(),t=X.oidcClientId.trim(),a=X.oidcScopes.trim(),i=X.oidcLoginLabel.trim(),r=J.trim();if("password"!==e&&(!s||!t||!r)&&!S.oidcConfigured)return void K({type:"error",message:"Issuer URL, client ID, and client secret are required to enable OIDC."});V(!0),K({type:"",message:""}),ee({type:"",message:""});try{let l={authMode:e,ssoType:"oidc",oidcIssuerUrl:s,oidcClientId:t,oidcScopes:a||"openid profile email",oidcLoginLabel:i||"Sign in with OIDC"};r&&(l.oidcClientSecret=r);let o=await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(l)}),n=await o.json();o.ok?(C(e=>({...e,...n})),B({authMode:n?.authMode||e,oidcIssuerUrl:n?.oidcIssuerUrl||s,oidcClientId:n?.oidcClientId||t,oidcScopes:n?.oidcScopes||a||"openid profile email",oidcLoginLabel:n?.oidcLoginLabel||i||"Sign in with OIDC"}),z(""),K({type:"success",message:"oidc"===e?"OIDC login enabled":"both"===e?"Password and OIDC login enabled":"OIDC settings saved"})):K({type:"error",message:n.error||"Failed to save OIDC settings"})}catch(e){K({type:"error",message:"An error occurred"})}finally{V(!1)}},ez=async()=>{let e=X.oidcIssuerUrl.trim(),s=X.oidcClientId.trim(),t=X.oidcScopes.trim(),a=J.trim();if(!e||!s)return void ee({type:"error",message:"Issuer URL and client ID are required to test the connection."});W(!0),K({type:"",message:""}),ee({type:"",message:""});try{let i=await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({authMode:X.authMode||S.authMode||"password",oidcIssuerUrl:e,oidcClientId:s,oidcScopes:t||"openid profile email",oidcLoginLabel:X.oidcLoginLabel.trim()||"Sign in with OIDC",...a?{oidcClientSecret:a}:{}})}),r=await i.json().catch(()=>({}));if(!i.ok)return void ee({type:"error",message:r.error||"Failed to save OIDC settings before testing"});let l=await fetch("/api/auth/oidc/test",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({issuerUrl:r.oidcIssuerUrl||e,clientId:r.oidcClientId||s,scopes:r.oidcScopes||t||"openid profile email"})}),o=await l.json().catch(()=>({}));if(l.ok&&o?.ok){let e=o.clientSecretTested?!0===o.clientSecretValid?`Connection OK. Discovery loaded from ${o.issuerUrl}. Client secret validated too.`:`Connection OK. Discovery loaded from ${o.issuerUrl}. Client secret was not checked.`:`Connection OK. Discovery loaded from ${o.issuerUrl}.`;ee({type:"success",message:e})}else ee({type:"error",message:o.error||"OIDC connection test failed"})}catch(e){ee({type:"error",message:"An error occurred"})}finally{W(!1)}},eG=(e,s)=>{ec(t=>({...t,[e]:s}))},eK=async(e=X.authMode||"password")=>{ex(!0),ep({type:"",message:""}),ef({type:"",message:""});try{let s={authMode:e,ssoType:"saml",samlEntryPoint:ed.samlEntryPoint.trim(),samlIssuer:ed.samlIssuer.trim()||"urn:9router:sp",samlCert:ed.samlCert.trim(),samlLoginLabel:ed.samlLoginLabel.trim()||"Sign in with SAML SSO",samlAttributeEmail:ed.samlAttributeEmail.trim()||"email",samlAttributeName:ed.samlAttributeName.trim()||"name"},t=await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)}),a=await t.json();t.ok?(C(e=>({...e,...a})),ec({samlEntryPoint:a?.samlEntryPoint||s.samlEntryPoint,samlIssuer:a?.samlIssuer||s.samlIssuer,samlCert:a?.samlCert||s.samlCert,samlLoginLabel:a?.samlLoginLabel||s.samlLoginLabel,samlAttributeEmail:a?.samlAttributeEmail||s.samlAttributeEmail,samlAttributeName:a?.samlAttributeName||s.samlAttributeName}),ep({type:"success",message:"sso"===e||"saml"===e?"SAML SSO login enabled":"both"===e?"Password and SAML SSO login enabled":"SAML 2.0 settings saved"})):ep({type:"error",message:a.error||"Failed to save SAML settings"})}catch{ep({type:"error",message:"An error occurred while saving SAML settings"})}finally{ex(!1)}},eZ=async()=>{eg(!0),ep({type:"",message:""}),ef({type:"",message:""});try{let e=await fetch("/api/auth/saml/test",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({samlEntryPoint:ed.samlEntryPoint.trim(),samlIssuer:ed.samlIssuer.trim(),samlCert:ed.samlCert.trim()})}),s=await e.json();e.ok&&s.ok?ef({type:"success",message:s.message||"SAML configuration verified!"}):ef({type:"error",message:s.error||"SAML configuration test failed"})}catch{ef({type:"error",message:"An error occurred while testing SAML configuration"})}finally{eg(!1)}},eV=async e=>{try{(await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({enableObservability:e})})).ok&&C(s=>({...s,enableObservability:e}))}catch(e){console.error("Failed to update enableObservability:",e)}},eQ=async()=>{try{let e=await fetch("/api/settings");if(!e.ok)return;let s=await e.json();C(s)}catch(e){console.error("Failed to reload settings:",e)}},eW=async e=>{T(!0),F({type:"",message:""});try{let s=await fetch("/api/settings/database",{headers:{"x-9r-password":e}});if(!s.ok){let e=await s.json().catch(()=>({}));throw Error(e.error||"Failed to export database")}let t=await s.json(),a=JSON.stringify(t,null,2),i=new Blob([a],{type:"application/json"}),r=URL.createObjectURL(i),l=document.createElement("a"),o=new Date().toISOString().replace(/[.:]/g,"-");l.href=r,l.download=`9router-backup-${o}.json`,document.body.appendChild(l),l.click(),document.body.removeChild(l),URL.revokeObjectURL(r),F({type:"success",message:"Database backup downloaded"})}catch(e){F({type:"error",message:e.message||"Failed to export database"})}finally{T(!1)}},eY=async e=>{let s=H.current;if(s){T(!0);try{let t=await s.text(),a=JSON.parse(t),i=await fetch("/api/settings/database",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...a,password:e})}),r=await i.json().catch(()=>({}));if(!i.ok)throw Error(r.error||"Failed to import database");await eQ(),F({type:"success",message:"Database imported successfully"})}catch(e){F({type:"error",message:e.message||"Invalid backup file"})}finally{H.current=null,T(!1)}}},e0=async()=>{let{mode:e,password:s}=$;q({open:!1,mode:"",password:""}),"export"===e?await eW(s):"import"===e&&await eY(s)},e1=!0===S.enableObservability,e2=async()=>{v(!0);try{await fetch("/api/version/shutdown",{method:"POST"})}catch(e){}v(!1),N(!1)},e5=async()=>{try{(await fetch("/api/auth/logout",{method:"POST"})).ok&&window.location.assign("/login")}catch(e){console.error("Failed to logout:",e)}};return(0,a.jsxs)("div",{className:`dashboard-surface ${x().page}`,children:[(0,a.jsx)(b,{}),_?(0,a.jsxs)("div",{className:x().stack,"aria-busy":"true","aria-label":"Loading profile settings",children:[["Preferences","Security","Routing and network"].map(e=>(0,a.jsxs)(l.Zp,{padding:"none",className:x().section,children:[(0,a.jsx)(l.EA,{className:"mb-5 h-4 w-32"}),(0,a.jsxs)("div",{className:x().formGrid,children:[(0,a.jsx)(l.EA,{className:"h-10"}),(0,a.jsx)(l.EA,{className:"h-10"})]}),(0,a.jsx)(l.EA,{className:"mt-4 h-4 w-48 max-w-full"})]},e)),(0,a.jsx)("p",{className:x().description,role:"status",children:"Loading profile settings…"})]}):L?(0,a.jsxs)(l.Zp,{padding:"none",className:x().section,children:[(0,a.jsx)(g,{status:{type:"error",message:L}}),(0,a.jsx)(l.$n,{variant:"secondary",onClick:()=>{k(!0),I(""),eR()},className:"mt-3",icon:"refresh",children:"Retry"})]}):(0,a.jsxs)("div",{className:x().stack,children:[(0,a.jsxs)(h,{id:"profile-preferences",title:"Preferences & data",icon:"settings",description:"Display preferences and database backups.",children:[(0,a.jsxs)("div",{className:x().settingRow,children:[(0,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsx)("p",{className:x().settingTitle,children:"Appearance"}),(0,a.jsx)("p",{className:x().settingDescription,children:"Use a light, dark, or system theme."})]}),(0,a.jsx)(l.Iz,{"aria-label":"Appearance",value:e,onChange:s,options:[{value:"light",label:"Light",icon:"light_mode"},{value:"dark",label:"Dark",icon:"dark_mode"},{value:"system",label:"System",icon:"contrast"}]})]}),(0,a.jsxs)("div",{className:x().settingRow,children:[(0,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsx)("p",{className:x().settingTitle,children:"Display language"}),(0,a.jsx)("p",{className:x().settingDescription,children:"Choose the language used in the dashboard."})]}),(0,a.jsxs)(l.$n,{variant:"secondary",onClick:()=>y(!0),"aria-label":"Change display language","data-i18n-skip":"true",children:[(0,a.jsx)("span",{"aria-hidden":"true",children:p[t]||"\uD83C\uDF10"}),(0,a.jsx)("span",{children:t}),(0,a.jsx)(i.default,{className:"text-[14px]","aria-hidden":"true",children:"expand_more"})]})]}),(0,a.jsx)("div",{className:x().settingRow,children:(0,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsx)("p",{className:x().settingTitle,children:eO?"Remote Mode":"Local Mode"}),(0,a.jsx)("p",{className:x().settingDescription,children:eO?"Connected to a remote instance.":"Running on your machine."})]})}),(0,a.jsxs)("div",{className:x().settingRow,children:[(0,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsx)("p",{className:x().settingTitle,children:"Database Location"}),(0,a.jsx)("code",{className:x().settingDescription,children:"~/.9router/db/data.sqlite"})]}),(0,a.jsxs)("div",{className:x().actions,children:[(0,a.jsx)(l.$n,{variant:"secondary",icon:"download",onClick:()=>q({open:!0,mode:"export",password:""}),loading:E,className:"w-full sm:w-auto",children:"Download Backup"}),(0,a.jsx)(l.$n,{variant:"secondary",icon:"upload",onClick:()=>ev.current?.click(),disabled:E,className:"w-full sm:w-auto",children:"Import Backup"}),(0,a.jsx)("input",{ref:ev,type:"file",accept:"application/json,.json",className:"hidden",onChange:e=>{let s=e.target.files?.[0];ev.current&&(ev.current.value=""),s&&(H.current=s,F({type:"",message:""}),q({open:!0,mode:"import",password:""}))}})]})]}),(0,a.jsx)(g,{status:U})]}),(0,a.jsx)(h,{id:"profile-security",title:"Security",icon:"shield",description:"Dashboard access and password management.",children:(0,a.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,a.jsxs)("div",{className:x().settingRow,children:[(0,a.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,a.jsx)("p",{className:"font-medium text-sm sm:text-base",children:"Require login"}),(0,a.jsx)("p",{className:"text-xs sm:text-sm text-text-muted",children:"When ON, dashboard requires password. When OFF, access without login."})]}),(0,a.jsx)(l.lM,{"aria-label":"Require login",checked:!0===S.requireLogin,onChange:()=>eX(!S.requireLogin),disabled:_})]}),!0===S.requireLogin&&(0,a.jsxs)("form",{onSubmit:eU,className:x().form,children:[S.hasPassword&&(0,a.jsx)("div",{className:"flex flex-col gap-2",children:(0,a.jsx)(l.pd,{label:"Current Password",autoComplete:"current-password",type:"password",placeholder:"Enter current password",value:A.current,onChange:e=>P({...A,current:e.target.value}),required:!0})}),(0,a.jsxs)("div",{className:x().formGrid,children:[(0,a.jsx)("div",{className:"flex flex-col gap-2",children:(0,a.jsx)(l.pd,{label:"New Password",autoComplete:"new-password",type:"password",placeholder:"Enter new password",value:A.new,onChange:e=>P({...A,new:e.target.value}),required:!0})}),(0,a.jsx)("div",{className:"flex flex-col gap-2",children:(0,a.jsx)(l.pd,{label:"Confirm New Password",autoComplete:"new-password",type:"password",placeholder:"Confirm new password",value:A.confirm,onChange:e=>P({...A,confirm:e.target.value}),required:!0})})]}),(0,a.jsx)(g,{status:O}),(0,a.jsx)("div",{className:"pt-2",children:(0,a.jsx)(l.$n,{type:"submit",variant:"contrast",loading:R,className:"w-full sm:w-auto",children:S.hasPassword?"Update Password":"Set Password"})})]})]})}),(0,a.jsx)("section",{"aria-labelledby":"profile-sso",children:(0,a.jsxs)(l.Zp,{padding:"none",className:x().section,children:[(0,a.jsxs)("button",{type:"button",onClick:()=>et(e=>!e),className:x().disclosure,"aria-expanded":es,"aria-controls":"profile-sso-settings",children:[(0,a.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,a.jsxs)("h2",{id:"profile-sso",className:"ui-eyebrow",children:[(0,a.jsx)(i.default,{className:"text-[16px]","aria-hidden":"true",children:"lock_open"}),"Single Sign-On (SSO)"]}),(0,a.jsx)("p",{className:x().sectionDescription,children:"sso"===S.authMode||"oidc"===S.authMode||"saml"===S.authMode?`${"saml"===S.ssoType?"SAML 2.0":"OIDC"} SSO active`:"both"===S.authMode?`Password + ${"saml"===S.ssoType?"SAML 2.0":"OIDC"} active`:"Optional SSO via Okta, Entra ID, Keycloak, or OIDC"})]}),(0,a.jsx)(i.default,{className:"text-text-muted shrink-0",children:es?"expand_less":"expand_more"})]}),es&&(0,a.jsxs)("div",{id:"profile-sso-settings",className:x().ssoForm,children:[(0,a.jsx)("p",{className:"text-xs sm:text-sm text-text-muted",children:"Configure enterprise Single Sign-On (SSO) for dashboard access using SAML 2.0 or OIDC."}),(0,a.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,a.jsx)("p",{className:x().fieldLabel,children:"SSO Protocol"}),(0,a.jsx)(l.Iz,{"aria-label":"SSO Protocol",value:eo,onChange:en,options:[{value:"saml",label:"SAML 2.0"},{value:"oidc",label:"OIDC"}],className:"self-start"})]}),(0,a.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,a.jsx)("p",{className:x().fieldLabel,children:"Auth Mode"}),(0,a.jsx)("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-2",children:[{value:"password",title:"Password only",desc:"Keep legacy password login."},{value:"sso",title:`${"saml"===eo?"SAML":"OIDC"} only`,desc:"Require SSO for dashboard access."},{value:"both",title:"Both",desc:"Allow password or SSO login."}].map(e=>{let s=X.authMode,t="password"===e.value?"password"===s:"sso"===e.value?"sso"===s||"saml"===s||"oidc"===s:"both"===s;return(0,a.jsxs)(l.$n,{type:"button",onClick:()=>eB("authMode",e.value),variant:"outline",className:x().choice,"aria-pressed":t,disabled:_||Z||eu,children:[(0,a.jsx)("span",{className:x().settingTitle,children:e.title}),(0,a.jsx)("span",{className:x().settingDescription,children:e.desc})]},e.value)})})]}),"saml"===eo?(0,a.jsxs)("div",{className:"flex flex-col gap-4 pt-2 border-t border-border/50",children:[(0,a.jsxs)("div",{className:x().inset,children:[(0,a.jsxs)("button",{type:"button",onClick:()=>ej(e=>!e),className:x().disclosure,"aria-expanded":ey,"aria-controls":"profile-saml-guide",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)(i.default,{className:"text-text-muted text-lg","aria-hidden":"true",children:"menu_book"}),(0,a.jsxs)("div",{children:[(0,a.jsx)("p",{className:"font-semibold text-xs sm:text-sm text-text-main",children:"IdP Setup Guidelines & Provider Configuration Instructions"}),(0,a.jsx)("p",{className:"text-[11px] text-text-muted",children:"Click to view setup steps for AWS IAM Identity Center, Okta, Entra ID, Keycloak, & Authentik"})]})]}),(0,a.jsx)(i.default,{className:"text-text-muted transition-transform text-lg",style:{transform:ey?"rotate(180deg)":"none"},children:"expand_more"})]}),ey&&(0,a.jsxs)("div",{id:"profile-saml-guide",className:x().guide,children:[(0,a.jsxs)("div",{className:x().inset,children:[(0,a.jsx)("p",{className:"font-semibold mb-1",children:"Required Service Provider (SP) Values for your IdP Setup:"}),(0,a.jsxs)("ul",{className:"list-disc pl-4 space-y-1 font-mono text-[11px]",children:[(0,a.jsxs)("li",{children:[(0,a.jsx)("b",{children:"Assertion Consumer Service (ACS) URL:"})," ",(0,a.jsx)("code",{className:"bg-bg px-1 py-0.5 rounded break-all",children:er})]}),(0,a.jsxs)("li",{children:[(0,a.jsx)("b",{children:"SP Entity ID / Audience URI:"})," ",(0,a.jsx)("code",{className:"bg-bg px-1 py-0.5 rounded break-all",children:ed.samlIssuer||"urn:9router:sp"})]}),(0,a.jsxs)("li",{children:[(0,a.jsx)("b",{children:"NameID Format:"})," ",(0,a.jsx)("code",{className:"bg-bg px-1 py-0.5 rounded",children:"EmailAddress"})," or ",(0,a.jsx)("code",{className:"bg-bg px-1 py-0.5 rounded",children:"Unspecified"})]})]})]}),(0,a.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3 pt-1",children:[(0,a.jsxs)("div",{className:"p-3 rounded border border-border bg-bg/50 flex flex-col gap-1.5",children:[(0,a.jsx)("p",{className:"font-semibold text-text-main flex items-center gap-1.5",children:"AWS IAM Identity Center"}),(0,a.jsxs)("ol",{className:"list-decimal pl-4 text-text-muted space-y-1",children:[(0,a.jsxs)("li",{children:["Applications → ",(0,a.jsx)("b",{children:"Add application"})," → Select ",(0,a.jsx)("b",{children:"Add custom SAML 2.0 application"}),"."]}),(0,a.jsxs)("li",{children:["Set ",(0,a.jsx)("b",{children:"Application ACS URL"})," to ",(0,a.jsx)("code",{className:"text-text-main font-mono",children:er}),"."]}),(0,a.jsxs)("li",{children:["Set ",(0,a.jsx)("b",{children:"Application SAML audience"})," to ",(0,a.jsx)("code",{className:"text-text-main font-mono",children:ed.samlIssuer||"urn:9router:sp"}),"."]}),(0,a.jsxs)("li",{children:["Under ",(0,a.jsx)("i",{children:"Attribute mappings"}),", map ",(0,a.jsx)("code",{className:"text-text-main font-mono",children:"Subject"})," or ",(0,a.jsx)("code",{className:"text-text-main font-mono",children:"email"})," to ",(0,a.jsxs)("code",{className:"text-text-main font-mono",children:["$","{user:email}"]}),"."]}),(0,a.jsxs)("li",{children:["Download ",(0,a.jsx)("b",{children:"IAM Identity Center SAML metadata XML"})," file and use 1-Click Import below!"]})]})]}),(0,a.jsxs)("div",{className:"p-3 rounded border border-border bg-bg/50 flex flex-col gap-1.5",children:[(0,a.jsx)("p",{className:"font-semibold text-text-main flex items-center gap-1.5",children:"Microsoft Entra ID (Azure AD)"}),(0,a.jsxs)("ol",{className:"list-decimal pl-4 text-text-muted space-y-1",children:[(0,a.jsxs)("li",{children:["Enterprise Applications → ",(0,a.jsx)("b",{children:"New application"})," → ",(0,a.jsx)("b",{children:"Create your own application"}),"."]}),(0,a.jsxs)("li",{children:["Select ",(0,a.jsx)("b",{children:"Single sign-on"})," → ",(0,a.jsx)("b",{children:"SAML"}),"."]}),(0,a.jsxs)("li",{children:[(0,a.jsx)("b",{children:"Identifier (Entity ID):"})," ",(0,a.jsx)("code",{className:"text-text-main font-mono",children:ed.samlIssuer||"urn:9router:sp"})]}),(0,a.jsxs)("li",{children:[(0,a.jsx)("b",{children:"Reply URL (ACS):"})," ",(0,a.jsx)("code",{className:"text-text-main font-mono",children:er})]}),(0,a.jsxs)("li",{children:["Download ",(0,a.jsx)("b",{children:"Federation Metadata XML"})," and import or copy X.509 Certificate."]})]})]}),(0,a.jsxs)("div",{className:"p-3 rounded border border-border bg-bg/50 flex flex-col gap-1.5",children:[(0,a.jsx)("p",{className:"font-semibold text-text-main flex items-center gap-1.5",children:"Okta / Auth0"}),(0,a.jsxs)("ol",{className:"list-decimal pl-4 text-text-muted space-y-1",children:[(0,a.jsxs)("li",{children:["Applications → ",(0,a.jsx)("b",{children:"Create App Integration"})," → Select ",(0,a.jsx)("b",{children:"SAML 2.0"}),"."]}),(0,a.jsxs)("li",{children:[(0,a.jsx)("b",{children:"Single Sign-On URL:"})," ",(0,a.jsx)("code",{className:"text-text-main font-mono",children:er})]}),(0,a.jsxs)("li",{children:[(0,a.jsx)("b",{children:"Audience URI (SP Entity ID):"})," ",(0,a.jsx)("code",{className:"text-text-main font-mono",children:ed.samlIssuer||"urn:9router:sp"})]}),(0,a.jsxs)("li",{children:["Name ID format: ",(0,a.jsx)("i",{children:"EmailAddress"}),"."]}),(0,a.jsx)("li",{children:"Download Identity Provider metadata XML or copy the X.509 cert."})]})]}),(0,a.jsxs)("div",{className:"p-3 rounded border border-border bg-bg/50 flex flex-col gap-1.5",children:[(0,a.jsx)("p",{className:"font-semibold text-text-main flex items-center gap-1.5",children:"Keycloak / Authentik"}),(0,a.jsxs)("ol",{className:"list-decimal pl-4 text-text-muted space-y-1",children:[(0,a.jsxs)("li",{children:["Clients → ",(0,a.jsx)("b",{children:"Create client"})," → Select ",(0,a.jsx)("b",{children:"SAML"}),"."]}),(0,a.jsxs)("li",{children:[(0,a.jsx)("b",{children:"Client ID:"})," ",(0,a.jsx)("code",{className:"text-text-main font-mono",children:ed.samlIssuer||"urn:9router:sp"})]}),(0,a.jsxs)("li",{children:[(0,a.jsx)("b",{children:"Master SAML Processing URL:"})," ",(0,a.jsx)("code",{className:"text-text-main font-mono",children:er})]}),(0,a.jsx)("li",{children:"Export SAML Descriptor XML or copy IDP Certificate PEM."})]})]})]})]})]}),(0,a.jsxs)("div",{className:x().settingRow,children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("p",{className:"font-medium text-sm text-text-main",children:"1-Click IdP Metadata XML Import"}),(0,a.jsx)("p",{className:"text-xs text-text-muted",children:"Auto-fill SSO URL, Issuer & Cert from XML metadata"})]}),(0,a.jsx)(l.$n,{type:"button",variant:"outline",size:"sm",icon:"upload_file",onClick:()=>eN.current?.click(),children:"Upload Metadata XML"}),(0,a.jsx)("input",{ref:eN,type:"file",accept:".xml,application/xml,text/xml",className:"hidden",onChange:e=>{let s=e.target.files?.[0];if(eN.current&&(eN.current.value=""),!s)return;let t=new FileReader;t.onload=e=>{try{let s=e.target?.result||"",t=new DOMParser().parseFromString(s,"text/xml");if(t.querySelector("parsererror"))return void ep({type:"error",message:"Unable to parse valid SAML IdP metadata from XML file"});let a=t.documentElement.getAttribute("entityID")||"",i=Array.from(t.querySelectorAll("SingleSignOnService, *|SingleSignOnService")),r="";for(let e of i){let s=e.getAttribute("Binding")||"",t=e.getAttribute("Location")||"";if(t&&(r=t,s.includes("HTTP-Redirect")))break}let l=Array.from(t.querySelectorAll("X509Certificate, *|X509Certificate")),o="";l.length>0&&(o=l[0].textContent.trim()),ec(e=>({...e,samlEntryPoint:r||e.samlEntryPoint,samlIssuer:e.samlIssuer||"urn:9router:sp",samlCert:o||e.samlCert})),ep({type:"success",message:`IdP Metadata imported! (SSO URL: ${r?"found":"not found"}, EntityID: ${a?"found":"not found"}, Cert: ${o?"found":"not found"})`})}catch(e){ep({type:"error",message:"Error reading IdP Metadata XML file"})}},t.readAsText(s)}})]}),(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-4",children:[(0,a.jsx)("div",{className:"flex flex-col gap-2",children:(0,a.jsx)(l.pd,{label:"Single Sign-On Service URL (samlEntryPoint)",placeholder:"https://idp.example.com/app/saml/sso/...",value:ed.samlEntryPoint,onChange:e=>eG("samlEntryPoint",e.target.value),disabled:_||eu})}),(0,a.jsx)("div",{className:"flex flex-col gap-2",children:(0,a.jsx)(l.pd,{label:"SP Entity ID / Audience (samlIssuer)",placeholder:"urn:9router:sp",value:ed.samlIssuer,onChange:e=>eG("samlIssuer",e.target.value),disabled:_||eu})}),(0,a.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,a.jsxs)("div",{className:x().actions,children:[(0,a.jsx)("label",{htmlFor:"profile-saml-cert",className:x().fieldLabel,children:"IdP X.509 Certificate (samlCert)"}),(0,a.jsx)(l.$n,{type:"button",variant:"outline",size:"sm",icon:"file_upload",onClick:()=>ew.current?.click(),children:"Upload Certificate"}),(0,a.jsx)("input",{ref:ew,type:"file",accept:".crt,.pem,.cer,text/plain",className:"hidden",onChange:e=>{let s=e.target.files?.[0];if(ew.current&&(ew.current.value=""),!s)return;let t=new FileReader;t.onload=e=>{let s=e.target?.result||"";ec(e=>({...e,samlCert:s.trim()})),ep({type:"success",message:"Certificate file loaded into configuration."})},t.readAsText(s)}})]}),(0,a.jsx)("textarea",{id:"profile-saml-cert","aria-describedby":"profile-saml-cert-hint",rows:4,placeholder:"-----BEGIN CERTIFICATE-----\nMIIC...\n-----END CERTIFICATE-----",value:ed.samlCert,onChange:e=>eG("samlCert",e.target.value),className:"w-full font-mono resize-y",disabled:_||eu}),(0,a.jsx)("p",{id:"profile-saml-cert-hint",className:x().settingDescription,children:"Paste raw Base64 certificate or PEM block."})]}),(0,a.jsxs)("div",{className:x().formGrid,children:[(0,a.jsx)("div",{className:"flex flex-col gap-2",children:(0,a.jsx)(l.pd,{label:"Login Button Label",placeholder:"Sign in with SAML SSO",value:ed.samlLoginLabel,onChange:e=>eG("samlLoginLabel",e.target.value),disabled:_||eu})}),(0,a.jsx)("div",{className:"flex flex-col gap-2",children:(0,a.jsx)(l.pd,{label:"Email Claim Attribute",placeholder:"email",value:ed.samlAttributeEmail,onChange:e=>eG("samlAttributeEmail",e.target.value),disabled:_||eu})}),(0,a.jsx)("div",{className:"flex flex-col gap-2",children:(0,a.jsx)(l.pd,{label:"Display Name Claim",placeholder:"name",value:ed.samlAttributeName,onChange:e=>eG("samlAttributeName",e.target.value),disabled:_||eu})})]})]}),(0,a.jsxs)("div",{className:x().inset,children:[(0,a.jsxs)("div",{className:x().settingRow,children:[(0,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsx)("p",{className:"font-medium text-text-main",children:"ACS Callback URL"}),(0,a.jsx)("code",{className:"block break-all font-mono text-xs",children:er})]}),(0,a.jsx)(l.$n,{type:"button",variant:"outline",size:"sm",icon:"content_copy","aria-label":"Copy ACS Callback URL",onClick:()=>{navigator.clipboard.writeText(er),ep({type:"success",message:"ACS URL copied to clipboard!"})},children:"Copy"})]}),(0,a.jsxs)("div",{className:x().settingRow,children:[(0,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsx)("p",{className:"font-medium text-text-main",children:"SP XML Metadata"}),(0,a.jsx)("code",{className:"block break-all font-mono text-xs",children:el})]}),(0,a.jsxs)("a",{href:el,target:"_blank",rel:"noopener noreferrer",download:"9router-sp-metadata.xml",className:x().linkButton,children:[(0,a.jsx)(i.default,{className:"text-[16px]",children:"download"}),"Download XML"]})]})]}),(0,a.jsxs)("div",{className:"flex flex-col sm:flex-row gap-2 pt-2 border-t border-border/50",children:[(0,a.jsx)(l.$n,{type:"button",variant:"contrast",loading:eu,onClick:()=>eK(X.authMode),className:"w-full sm:w-auto",children:"Save SAML settings"}),(0,a.jsx)(l.$n,{type:"button",variant:"outline",loading:eh,onClick:eZ,className:"w-full sm:w-auto",children:"Test SAML settings"})]}),(0,a.jsx)(g,{status:eb}),(0,a.jsx)(g,{status:em})]}):(0,a.jsxs)("div",{className:"flex flex-col gap-4 pt-2 border-t border-border/50",children:[(0,a.jsxs)("div",{className:x().formGrid,children:[(0,a.jsx)("div",{className:"flex flex-col gap-2",children:(0,a.jsx)(l.pd,{label:"Issuer URL",placeholder:"https://auth.example.com/application/o/9router/",value:X.oidcIssuerUrl,onChange:e=>eB("oidcIssuerUrl",e.target.value),disabled:_||Z})}),(0,a.jsx)("div",{className:"flex flex-col gap-2",children:(0,a.jsx)(l.pd,{label:"Client ID",placeholder:"9router-dashboard",value:X.oidcClientId,onChange:e=>eB("oidcClientId",e.target.value),disabled:_||Z})}),(0,a.jsx)("div",{className:"flex flex-col gap-2",children:(0,a.jsx)(l.pd,{label:"Client Secret",hint:"This value is write-only after saving.",type:"password",placeholder:"Leave blank to keep existing secret",value:J,onChange:e=>z(e.target.value),disabled:_||Z})}),(0,a.jsx)("div",{className:"flex flex-col gap-2",children:(0,a.jsx)(l.pd,{label:"Scopes",placeholder:"openid profile email",value:X.oidcScopes,onChange:e=>eB("oidcScopes",e.target.value),disabled:_||Z})}),(0,a.jsx)("div",{className:"flex flex-col gap-2",children:(0,a.jsx)(l.pd,{label:"Login Button Label",placeholder:"Sign in with OIDC",value:X.oidcLoginLabel,onChange:e=>eB("oidcLoginLabel",e.target.value),disabled:_||Z})})]}),(0,a.jsxs)("div",{className:x().inset,children:[(0,a.jsx)("p",{className:"font-medium text-text-main mb-1",children:"Redirect URI"}),(0,a.jsx)("code",{className:"block break-all font-mono",children:ei})]}),(0,a.jsxs)("div",{className:"flex flex-col sm:flex-row gap-2 pt-2 border-t border-border/50",children:[(0,a.jsx)(l.$n,{type:"button",variant:"contrast",loading:Z,onClick:()=>eJ(),className:"w-full sm:w-auto",children:"Save OIDC settings"}),(0,a.jsx)(l.$n,{type:"button",variant:"outline",loading:Q,onClick:ez,className:"w-full sm:w-auto",children:"Test connection"})]}),(0,a.jsx)(g,{status:Y}),(0,a.jsx)(g,{status:G})]}),"oidc"===S.authMode||"saml"===S.authMode||"sso"===S.authMode?(0,a.jsxs)("p",{className:x().notice,role:"status",children:["SSO login (","saml"===S.ssoType?"SAML 2.0":"OIDC",") is currently active. Password login is disabled until you switch back."]}):null,"both"===S.authMode&&(0,a.jsxs)("p",{className:x().notice,role:"status",children:["Password and SSO login (","saml"===S.ssoType?"SAML 2.0":"OIDC",") are both active."]})]})]})}),(0,a.jsx)(h,{id:"profile-routing",title:"Routing Strategy",icon:"route",description:"Account and combo rotation preferences.",children:(0,a.jsxs)("div",{children:[(0,a.jsxs)("div",{className:x().settingRow,children:[(0,a.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,a.jsx)("p",{className:"font-medium text-sm sm:text-base",children:"Round Robin"}),(0,a.jsx)("p",{className:"text-xs sm:text-sm text-text-muted",children:"Cycle through accounts to distribute load"})]}),(0,a.jsx)(l.lM,{"aria-label":"Round Robin",checked:"round-robin"===S.fallbackStrategy,onChange:()=>eF("round-robin"===S.fallbackStrategy?"fill-first":"round-robin"),disabled:_})]}),"round-robin"===S.fallbackStrategy&&(0,a.jsxs)("div",{className:x().settingRow,children:[(0,a.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,a.jsx)("p",{className:"font-medium text-sm sm:text-base",children:"Sticky Limit"}),(0,a.jsx)("p",{className:"text-xs sm:text-sm text-text-muted",children:"Calls per account before switching"})]}),(0,a.jsx)(l.pd,{"aria-label":"Sticky Limit",type:"number",min:"1",max:"10",value:S.stickyRoundRobinLimit||3,onChange:e=>eq(e.target.value),disabled:_,className:"w-16 sm:w-20 text-center shrink-0"})]}),(0,a.jsxs)("div",{className:x().settingRow,children:[(0,a.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,a.jsx)("p",{className:"font-medium text-sm sm:text-base",children:"Combo Round Robin"}),(0,a.jsx)("p",{className:"text-xs sm:text-sm text-text-muted",children:"Cycle through providers in combos instead of always starting with first"})]}),(0,a.jsx)(l.lM,{"aria-label":"Combo Round Robin",checked:"round-robin"===S.comboStrategy,onChange:()=>e$("round-robin"===S.comboStrategy?"fallback":"round-robin"),disabled:_})]}),"round-robin"===S.comboStrategy&&(0,a.jsxs)("div",{className:x().settingRow,children:[(0,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsx)("p",{className:"font-medium",children:"Combo Sticky Limit"}),(0,a.jsx)("p",{className:"text-sm text-text-muted",children:"Calls per combo model before switching"})]}),(0,a.jsx)(l.pd,{"aria-label":"Combo Sticky Limit",type:"number",min:"1",max:"100",value:S.comboStickyRoundRobinLimit||1,onChange:e=>eH(e.target.value),disabled:_,className:"w-20 text-center"})]}),(0,a.jsxs)("p",{className:"text-xs text-text-muted italic pt-2 border-t border-border/50",children:["round-robin"===S.fallbackStrategy?`Currently distributing requests across all available accounts with ${S.stickyRoundRobinLimit||3} calls per account.`:"Currently using accounts in priority order (Fill First).","round-robin"===S.comboStrategy?` Combos rotate after ${S.comboStickyRoundRobinLimit||1} call${1===(S.comboStickyRoundRobinLimit||1)?"":"s"} per model.`:" Combos always start with their first model."]})]})}),(0,a.jsx)(h,{id:"profile-network",title:"Network",icon:"wifi",description:"Outbound connections for OAuth and provider requests.",children:(0,a.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,a.jsxs)("div",{className:x().settingRow,children:[(0,a.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,a.jsx)("p",{className:"font-medium text-sm sm:text-base",children:"Outbound Proxy"}),(0,a.jsx)("p",{className:"text-xs sm:text-sm text-text-muted",children:"Enable proxy for OAuth + provider outbound requests."})]}),(0,a.jsx)(l.lM,{"aria-label":"Outbound Proxy",checked:!0===S.outboundProxyEnabled,onChange:()=>eT(!0!==S.outboundProxyEnabled),disabled:_||eL})]}),!0===S.outboundProxyEnabled&&(0,a.jsxs)("form",{onSubmit:eD,className:x().form,children:[(0,a.jsxs)("div",{className:x().formGrid,children:[(0,a.jsx)("div",{className:"flex flex-col gap-2",children:(0,a.jsx)(l.pd,{label:"Proxy URL",hint:"Leave empty to inherit existing env proxy (if any).",placeholder:"http://127.0.0.1:7897",value:eS.outboundProxyUrl,onChange:e=>eC(s=>({...s,outboundProxyUrl:e.target.value})),disabled:_||eL})}),(0,a.jsx)("div",{className:"flex flex-col gap-2",children:(0,a.jsx)(l.pd,{label:"No Proxy",hint:"Comma-separated hostnames/domains to bypass the proxy.",placeholder:"localhost,127.0.0.1",value:eS.outboundNoProxy,onChange:e=>eC(s=>({...s,outboundNoProxy:e.target.value})),disabled:_||eL})})]}),(0,a.jsxs)("div",{className:"pt-2 border-t border-border/50 flex flex-col sm:flex-row items-stretch sm:items-center gap-2",children:[(0,a.jsx)(l.$n,{type:"button",variant:"secondary",loading:eA,disabled:_||eL,onClick:eE,className:"w-full sm:w-auto",children:"Test proxy URL"}),(0,a.jsx)(l.$n,{type:"submit",variant:"contrast",loading:eL,className:"w-full sm:w-auto",children:"Apply"})]})]}),(0,a.jsx)(g,{status:e_})]})}),(0,a.jsx)(h,{id:"profile-observability",title:"Observability",icon:"monitoring",children:(0,a.jsxs)("div",{className:x().settingRow,children:[(0,a.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,a.jsx)("p",{className:"font-medium text-sm sm:text-base",children:"Enable Observability"}),(0,a.jsx)("p",{className:"text-xs sm:text-sm text-text-muted",children:"Record request details for inspection in the logs view"})]}),(0,a.jsx)(l.lM,{"aria-label":"Enable Observability",checked:e1,onChange:eV,disabled:_})]})}),(0,a.jsxs)(h,{id:"profile-session",title:"Session & server",icon:"logout",children:[(0,a.jsxs)("div",{className:x().settingRow,children:[(0,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsx)("p",{className:x().settingTitle,children:"Dashboard session"}),(0,a.jsx)("p",{className:x().settingDescription,children:"Sign out of the dashboard."})]}),(0,a.jsx)(l.$n,{variant:"secondary",icon:"logout",onClick:e5,children:"Logout"})]}),(0,a.jsxs)("div",{className:x().settingRow,children:[(0,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsx)("p",{className:x().settingTitle,children:"Stop proxy server"}),(0,a.jsx)("p",{className:x().settingDescription,children:"Shut down this JRouter instance."})]}),(0,a.jsx)(l.$n,{variant:"danger",icon:"power_settings_new",onClick:()=>N(!0),className:x().dangerButton,children:"Shutdown"})]})]}),(0,a.jsxs)("div",{className:x().appInfo,children:[(0,a.jsxs)("p",{children:[c.vQ.name," v",c.vQ.version]}),(0,a.jsx)("p",{className:"mt-1",children:eO?"Remote Mode":"Local Mode - All data stored on your machine"})]})]}),(0,a.jsx)(n.default,{dialogClassName:x().languageDialog,hideTrigger:!0,isOpen:f,onClose:e=>{y(!1),u(e)}}),(0,a.jsx)(o.ConfirmModal,{className:x().dialog,isOpen:j,onClose:()=>N(!1),onConfirm:e2,title:"Close Proxy",message:"Are you sure you want to close the proxy server?",confirmText:"Close",cancelText:"Cancel",variant:"danger",loading:w}),(0,a.jsxs)(o.default,{className:x().dialog,isOpen:$.open,onClose:()=>q({open:!1,mode:"",password:""}),title:"Confirm Password",size:"sm",footer:(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(l.$n,{variant:"ghost",onClick:()=>q({open:!1,mode:"",password:""}),disabled:E,children:"Cancel"}),(0,a.jsx)(l.$n,{variant:"contrast",onClick:e0,loading:E,disabled:!$.password,children:"Confirm"})]}),children:[(0,a.jsxs)("p",{className:"text-text-muted mb-3 text-sm",children:["Enter your current password to ","export"===$.mode?"export":"import"," the database."]}),(0,a.jsx)(l.pd,{label:"Current password",autoComplete:"current-password",type:"password",value:$.password,onChange:e=>q(s=>({...s,password:e.target.value})),onKeyDown:e=>{"Enter"===e.key&&$.password&&e0()},placeholder:"Current password",autoFocus:!0})]})]})}},48535:e=>{e.exports={page:"profile_page___tjyP token-saver_page__79V8u usage_page__TfrVH DashboardControls_formScope__ID02o DashboardControls_fields__IY485",header:"profile_header__IkyVh usage_header__Pj5rE",description:"profile_description__NXRzM usage_description___N7_0",section:"profile_section__UAY_s usage_section__Q1FLM",sectionHeader:"profile_sectionHeader___cLAs usage_sectionHeader__ikyc_",sectionDescription:"profile_sectionDescription__ZbT8S usage_sectionDescription__hUHjE",fieldLabel:"profile_fieldLabel__TDwV7 usage_fieldLabel__QyUjE",inset:"profile_inset__DdQQ3 usage_inset__ua4iZ",dialog:"profile_dialog__vjXNZ DashboardControls_dialog__YyPS4",dangerButton:"profile_dangerButton__gObBc endpoint_dangerButton__zSy_6",linkButton:"profile_linkButton__Ohf76 skills_linkButton__mVXTi",stack:"profile_stack__stIZ4",settingRow:"profile_settingRow__SqVZr endpoint_settingsRow__MBLvY",settingTitle:"profile_settingTitle__c_bHF token-saver_title__9opCy",settingDescription:"profile_settingDescription__5HFh3 token-saver_metadata__ktGrx",actions:"profile_actions__W0G3b",form:"profile_form__lLMlh",ssoForm:"profile_ssoForm__QKyCp",formGrid:"profile_formGrid__S7IE_",disclosure:"profile_disclosure__OXS9X",choice:"profile_choice__RAEhZ",guide:"profile_guide__Yl3qV",status:"profile_status__dFw2G",notice:"profile_notice__z5zKe",appInfo:"profile_appInfo__zIFC1",languageDialog:"profile_languageDialog__4pCcf DashboardControls_dialog__YyPS4"}},96754:(e,s,t)=>{Promise.resolve().then(t.bind(t,29404))}},e=>{e.O(0,[3493,8679,970,636,4660,2904,6506,8500,3847,1321,705,5497,8441,3794,7358],()=>e(e.s=96754)),_N_E=e.O()}]);
1
+ (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[3471],{29404:(e,s,t)=>{"use strict";t.r(s),t.d(s,{default:()=>f});var a=t(95155),i=t(96439),r=t(12115),l=t(35497),o=t(81127),n=t(21931),d=t(1620),c=t(90620),m=t(93308);let p={en:"\uD83C\uDDFA\uD83C\uDDF8",vi:"\uD83C\uDDFB\uD83C\uDDF3","zh-CN":"\uD83C\uDDE8\uD83C\uDDF3","zh-TW":"\uD83C\uDDF9\uD83C\uDDFC",ja:"\uD83C\uDDEF\uD83C\uDDF5","pt-BR":"\uD83C\uDDE7\uD83C\uDDF7","pt-PT":"\uD83C\uDDF5\uD83C\uDDF9",ko:"\uD83C\uDDF0\uD83C\uDDF7",es:"\uD83C\uDDEA\uD83C\uDDF8",de:"\uD83C\uDDE9\uD83C\uDDEA",fr:"\uD83C\uDDEB\uD83C\uDDF7",he:"\uD83C\uDDEE\uD83C\uDDF1",ar:"\uD83C\uDDF8\uD83C\uDDE6",ru:"\uD83C\uDDF7\uD83C\uDDFA",pl:"\uD83C\uDDF5\uD83C\uDDF1",cs:"\uD83C\uDDE8\uD83C\uDDFF",nl:"\uD83C\uDDF3\uD83C\uDDF1",tr:"\uD83C\uDDF9\uD83C\uDDF7",uk:"\uD83C\uDDFA\uD83C\uDDE6",tl:"\uD83C\uDDF5\uD83C\uDDED",id:"\uD83C\uDDEE\uD83C\uDDE9",th:"\uD83C\uDDF9\uD83C\uDDED",km:"\uD83C\uDDF0\uD83C\uDDED",hi:"\uD83C\uDDEE\uD83C\uDDF3",bn:"\uD83C\uDDE7\uD83C\uDDE9",ur:"\uD83C\uDDF5\uD83C\uDDF0",ro:"\uD83C\uDDF7\uD83C\uDDF4",sv:"\uD83C\uDDF8\uD83C\uDDEA",it:"\uD83C\uDDEE\uD83C\uDDF9",el:"\uD83C\uDDEC\uD83C\uDDF7",hu:"\uD83C\uDDED\uD83C\uDDFA",fi:"\uD83C\uDDEB\uD83C\uDDEE",da:"\uD83C\uDDE9\uD83C\uDDF0",no:"\uD83C\uDDF3\uD83C\uDDF4",fa:"\uD83C\uDDEE\uD83C\uDDF7"};var u=t(48535),x=t.n(u);function h({id:e,title:s,icon:t,description:r,children:o}){return(0,a.jsx)("section",{"aria-labelledby":e,children:(0,a.jsxs)(l.Zp,{padding:"none",className:x().section,children:[(0,a.jsx)("div",{className:x().sectionHeader,children:(0,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsxs)("h2",{id:e,className:"ui-eyebrow",children:[(0,a.jsx)(i.default,{className:"text-[16px]","aria-hidden":"true",children:t}),s]}),r&&(0,a.jsx)("p",{className:x().sectionDescription,children:r})]})}),o]})})}function g({status:e}){return e.message?(0,a.jsxs)("p",{className:x().status,"data-status":e.type,role:"error"===e.type?"alert":"status",children:[(0,a.jsx)(i.default,{className:"shrink-0 text-[14px]","aria-hidden":"true",children:"error"===e.type?"error":"check_circle"}),e.message]}):null}function b(){return(0,a.jsx)("header",{className:x().header,children:(0,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsxs)("h1",{className:"ui-eyebrow",children:[(0,a.jsx)(i.default,{className:"text-[16px]","aria-hidden":"true",children:"person"}),"Profile"]}),(0,a.jsx)("p",{className:x().description,children:"Preferences, security, and settings for your JRouter instance."})]})})}function f(){let{theme:e,setTheme:s}=(0,d.D)(),[t,u]=(0,r.useState)(()=>(function(){if("u"<typeof document)return"en";let e=document.cookie.split(";").find(e=>e.trim().startsWith(`${m.CL}=`)),s=e?decodeURIComponent(e.split("=")[1]):"en";return(0,m.QC)(s)})()),[f,y]=(0,r.useState)(!1),[j,N]=(0,r.useState)(!1),[w,v]=(0,r.useState)(!1),[S,C]=(0,r.useState)({fallbackStrategy:"fill-first"}),[_,k]=(0,r.useState)(!0),[L,I]=(0,r.useState)(""),[A,P]=(0,r.useState)({current:"",new:"",confirm:""}),[O,M]=(0,r.useState)({type:"",message:""}),[R,D]=(0,r.useState)(!1),[E,T]=(0,r.useState)(!1),[U,F]=(0,r.useState)({type:"",message:""}),[$,q]=(0,r.useState)({open:!1,mode:"",password:""}),H=(0,r.useRef)(null),[X,B]=(0,r.useState)({authMode:"password",oidcIssuerUrl:"",oidcClientId:"",oidcScopes:"openid profile email",oidcLoginLabel:"Sign in with OIDC"}),[J,z]=(0,r.useState)(""),[G,K]=(0,r.useState)({type:"",message:""}),[Z,V]=(0,r.useState)(!1),[Q,W]=(0,r.useState)(!1),[Y,ee]=(0,r.useState)({type:"",message:""}),[es,et]=(0,r.useState)(!1),ea=window.location.origin,ei=ea?`${ea}/api/auth/oidc/callback`:"/api/auth/oidc/callback",er=ea?`${ea}/api/auth/saml/acs`:"/api/auth/saml/acs",el=ea?`${ea}/api/auth/saml/metadata`:"/api/auth/saml/metadata",[eo,en]=(0,r.useState)("saml"),[ed,ec]=(0,r.useState)({samlEntryPoint:"",samlIssuer:"urn:jrouter:sp",samlCert:"",samlLoginLabel:"Sign in with SAML SSO",samlAttributeEmail:"email",samlAttributeName:"name"}),[em,ep]=(0,r.useState)({type:"",message:""}),[eu,ex]=(0,r.useState)(!1),[eh,eg]=(0,r.useState)(!1),[eb,ef]=(0,r.useState)({type:"",message:""}),[ey,ej]=(0,r.useState)(!1),eN=(0,r.useRef)(null),ew=(0,r.useRef)(null),ev=(0,r.useRef)(null),[eS,eC]=(0,r.useState)({outboundProxyEnabled:!1,outboundProxyUrl:"",outboundNoProxy:""}),[e_,ek]=(0,r.useState)({type:"",message:""}),[eL,eI]=(0,r.useState)(!1),[eA,eP]=(0,r.useState)(!1),[eO,eM]=(0,r.useState)(!1);(0,r.useEffect)(()=>{eM(!["localhost","127.0.0.1","::1"].includes(window.location.hostname))},[]);let eR=(0,r.useCallback)(()=>{fetch("/api/settings").then(e=>{if(!e.ok)throw Error("Failed to load settings");return e.json()}).then(e=>{C(e),B({authMode:e?.authMode||"password",oidcIssuerUrl:e?.oidcIssuerUrl||"",oidcClientId:e?.oidcClientId||"",oidcScopes:e?.oidcScopes||"openid profile email",oidcLoginLabel:e?.oidcLoginLabel||"Sign in with OIDC"}),z(""),en(e?.ssoType||"saml"),ec({samlEntryPoint:e?.samlEntryPoint||"",samlIssuer:e?.samlIssuer||"urn:jrouter:sp",samlCert:e?.samlCert||"",samlLoginLabel:e?.samlLoginLabel||"Sign in with SAML SSO",samlAttributeEmail:e?.samlAttributeEmail||"email",samlAttributeName:e?.samlAttributeName||"name"}),(e?.authMode==="sso"||e?.authMode==="saml"||e?.authMode==="oidc"||e?.authMode==="both")&&et(!0),eC({outboundProxyEnabled:e?.outboundProxyEnabled===!0,outboundProxyUrl:e?.outboundProxyUrl||"",outboundNoProxy:e?.outboundNoProxy||""}),k(!1)}).catch(e=>{console.error("Failed to fetch settings:",e),I("Could not load your instance settings. Try again."),k(!1)})},[]);(0,r.useEffect)(()=>{eR()},[eR]);let eD=async e=>{if(e.preventDefault(),!0===S.outboundProxyEnabled){eI(!0),ek({type:"",message:""});try{let e=await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({outboundProxyUrl:eS.outboundProxyUrl,outboundNoProxy:eS.outboundNoProxy})}),s=await e.json();e.ok?(C(e=>({...e,...s})),ek({type:"success",message:"Proxy settings applied"})):ek({type:"error",message:s.error||"Failed to update proxy settings"})}catch(e){ek({type:"error",message:"An error occurred"})}finally{eI(!1)}}},eE=async()=>{if(!0!==S.outboundProxyEnabled)return;let e=(eS.outboundProxyUrl||"").trim();if(!e)return void ek({type:"error",message:"Please enter a Proxy URL to test"});eP(!0),ek({type:"",message:""});try{let s=await fetch("/api/settings/proxy-test",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({proxyUrl:e})}),t=await s.json();s.ok&&t?.ok?ek({type:"success",message:`Proxy test OK (${t.status}) in ${t.elapsedMs}ms`}):ek({type:"error",message:t?.error||"Proxy test failed"})}catch(e){ek({type:"error",message:"An error occurred"})}finally{eP(!1)}},eT=async e=>{eI(!0),ek({type:"",message:""});try{let s=await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({outboundProxyEnabled:e})}),t=await s.json();s.ok?(C(e=>({...e,...t})),eC(e=>({...e,outboundProxyEnabled:t?.outboundProxyEnabled===!0})),ek({type:"success",message:e?"Proxy enabled":"Proxy disabled"})):ek({type:"error",message:t.error||"Failed to update proxy settings"})}catch(e){ek({type:"error",message:"An error occurred"})}finally{eI(!1)}},eU=async e=>{if(e.preventDefault(),A.new!==A.confirm)return void M({type:"error",message:"Passwords do not match"});D(!0),M({type:"",message:""});try{let e=await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({currentPassword:A.current,newPassword:A.new})}),s=await e.json();e.ok?(M({type:"success",message:"Password updated successfully"}),P({current:"",new:"",confirm:""})):M({type:"error",message:s.error||"Failed to update password"})}catch(e){M({type:"error",message:"An error occurred"})}finally{D(!1)}},eF=async e=>{try{(await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({fallbackStrategy:e})})).ok&&C(s=>({...s,fallbackStrategy:e}))}catch(e){console.error("Failed to update settings:",e)}},e$=async e=>{try{(await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({comboStrategy:e})})).ok&&C(s=>({...s,comboStrategy:e}))}catch(e){console.error("Failed to update combo strategy:",e)}},eq=async e=>{let s=parseInt(e);if(!isNaN(s)&&!(s<1))try{(await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({stickyRoundRobinLimit:s})})).ok&&C(e=>({...e,stickyRoundRobinLimit:s}))}catch(e){console.error("Failed to update sticky limit:",e)}},eH=async e=>{let s=parseInt(e);if(!isNaN(s)&&!(s<1))try{(await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({comboStickyRoundRobinLimit:s})})).ok&&C(e=>({...e,comboStickyRoundRobinLimit:s}))}catch(e){console.error("Failed to update combo sticky limit:",e)}},eX=async e=>{try{(await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({requireLogin:e})})).ok&&C(s=>({...s,requireLogin:e}))}catch(e){console.error("Failed to update require login:",e)}},eB=(e,s)=>{B(t=>({...t,[e]:s}))},eJ=async(e=X.authMode||"password")=>{let s=X.oidcIssuerUrl.trim(),t=X.oidcClientId.trim(),a=X.oidcScopes.trim(),i=X.oidcLoginLabel.trim(),r=J.trim();if("password"!==e&&(!s||!t||!r)&&!S.oidcConfigured)return void K({type:"error",message:"Issuer URL, client ID, and client secret are required to enable OIDC."});V(!0),K({type:"",message:""}),ee({type:"",message:""});try{let l={authMode:e,ssoType:"oidc",oidcIssuerUrl:s,oidcClientId:t,oidcScopes:a||"openid profile email",oidcLoginLabel:i||"Sign in with OIDC"};r&&(l.oidcClientSecret=r);let o=await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(l)}),n=await o.json();o.ok?(C(e=>({...e,...n})),B({authMode:n?.authMode||e,oidcIssuerUrl:n?.oidcIssuerUrl||s,oidcClientId:n?.oidcClientId||t,oidcScopes:n?.oidcScopes||a||"openid profile email",oidcLoginLabel:n?.oidcLoginLabel||i||"Sign in with OIDC"}),z(""),K({type:"success",message:"oidc"===e?"OIDC login enabled":"both"===e?"Password and OIDC login enabled":"OIDC settings saved"})):K({type:"error",message:n.error||"Failed to save OIDC settings"})}catch(e){K({type:"error",message:"An error occurred"})}finally{V(!1)}},ez=async()=>{let e=X.oidcIssuerUrl.trim(),s=X.oidcClientId.trim(),t=X.oidcScopes.trim(),a=J.trim();if(!e||!s)return void ee({type:"error",message:"Issuer URL and client ID are required to test the connection."});W(!0),K({type:"",message:""}),ee({type:"",message:""});try{let i=await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({authMode:X.authMode||S.authMode||"password",oidcIssuerUrl:e,oidcClientId:s,oidcScopes:t||"openid profile email",oidcLoginLabel:X.oidcLoginLabel.trim()||"Sign in with OIDC",...a?{oidcClientSecret:a}:{}})}),r=await i.json().catch(()=>({}));if(!i.ok)return void ee({type:"error",message:r.error||"Failed to save OIDC settings before testing"});let l=await fetch("/api/auth/oidc/test",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({issuerUrl:r.oidcIssuerUrl||e,clientId:r.oidcClientId||s,scopes:r.oidcScopes||t||"openid profile email"})}),o=await l.json().catch(()=>({}));if(l.ok&&o?.ok){let e=o.clientSecretTested?!0===o.clientSecretValid?`Connection OK. Discovery loaded from ${o.issuerUrl}. Client secret validated too.`:`Connection OK. Discovery loaded from ${o.issuerUrl}. Client secret was not checked.`:`Connection OK. Discovery loaded from ${o.issuerUrl}.`;ee({type:"success",message:e})}else ee({type:"error",message:o.error||"OIDC connection test failed"})}catch(e){ee({type:"error",message:"An error occurred"})}finally{W(!1)}},eG=(e,s)=>{ec(t=>({...t,[e]:s}))},eK=async(e=X.authMode||"password")=>{ex(!0),ep({type:"",message:""}),ef({type:"",message:""});try{let s={authMode:e,ssoType:"saml",samlEntryPoint:ed.samlEntryPoint.trim(),samlIssuer:ed.samlIssuer.trim()||"urn:jrouter:sp",samlCert:ed.samlCert.trim(),samlLoginLabel:ed.samlLoginLabel.trim()||"Sign in with SAML SSO",samlAttributeEmail:ed.samlAttributeEmail.trim()||"email",samlAttributeName:ed.samlAttributeName.trim()||"name"},t=await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)}),a=await t.json();t.ok?(C(e=>({...e,...a})),ec({samlEntryPoint:a?.samlEntryPoint||s.samlEntryPoint,samlIssuer:a?.samlIssuer||s.samlIssuer,samlCert:a?.samlCert||s.samlCert,samlLoginLabel:a?.samlLoginLabel||s.samlLoginLabel,samlAttributeEmail:a?.samlAttributeEmail||s.samlAttributeEmail,samlAttributeName:a?.samlAttributeName||s.samlAttributeName}),ep({type:"success",message:"sso"===e||"saml"===e?"SAML SSO login enabled":"both"===e?"Password and SAML SSO login enabled":"SAML 2.0 settings saved"})):ep({type:"error",message:a.error||"Failed to save SAML settings"})}catch{ep({type:"error",message:"An error occurred while saving SAML settings"})}finally{ex(!1)}},eZ=async()=>{eg(!0),ep({type:"",message:""}),ef({type:"",message:""});try{let e=await fetch("/api/auth/saml/test",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({samlEntryPoint:ed.samlEntryPoint.trim(),samlIssuer:ed.samlIssuer.trim(),samlCert:ed.samlCert.trim()})}),s=await e.json();e.ok&&s.ok?ef({type:"success",message:s.message||"SAML configuration verified!"}):ef({type:"error",message:s.error||"SAML configuration test failed"})}catch{ef({type:"error",message:"An error occurred while testing SAML configuration"})}finally{eg(!1)}},eV=async e=>{try{(await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({enableObservability:e})})).ok&&C(s=>({...s,enableObservability:e}))}catch(e){console.error("Failed to update enableObservability:",e)}},eQ=async()=>{try{let e=await fetch("/api/settings");if(!e.ok)return;let s=await e.json();C(s)}catch(e){console.error("Failed to reload settings:",e)}},eW=async e=>{T(!0),F({type:"",message:""});try{let s=await fetch("/api/settings/database",{headers:{"x-9r-password":e}});if(!s.ok){let e=await s.json().catch(()=>({}));throw Error(e.error||"Failed to export database")}let t=await s.json(),a=JSON.stringify(t,null,2),i=new Blob([a],{type:"application/json"}),r=URL.createObjectURL(i),l=document.createElement("a"),o=new Date().toISOString().replace(/[.:]/g,"-");l.href=r,l.download=`jrouter-backup-${o}.json`,document.body.appendChild(l),l.click(),document.body.removeChild(l),URL.revokeObjectURL(r),F({type:"success",message:"Database backup downloaded"})}catch(e){F({type:"error",message:e.message||"Failed to export database"})}finally{T(!1)}},eY=async e=>{let s=H.current;if(s){T(!0);try{let t=await s.text(),a=JSON.parse(t),i=await fetch("/api/settings/database",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...a,password:e})}),r=await i.json().catch(()=>({}));if(!i.ok)throw Error(r.error||"Failed to import database");await eQ(),F({type:"success",message:"Database imported successfully"})}catch(e){F({type:"error",message:e.message||"Invalid backup file"})}finally{H.current=null,T(!1)}}},e0=async()=>{let{mode:e,password:s}=$;q({open:!1,mode:"",password:""}),"export"===e?await eW(s):"import"===e&&await eY(s)},e1=!0===S.enableObservability,e2=async()=>{v(!0);try{await fetch("/api/version/shutdown",{method:"POST"})}catch(e){}v(!1),N(!1)},e5=async()=>{try{(await fetch("/api/auth/logout",{method:"POST"})).ok&&window.location.assign("/login")}catch(e){console.error("Failed to logout:",e)}};return(0,a.jsxs)("div",{className:`dashboard-surface ${x().page}`,children:[(0,a.jsx)(b,{}),_?(0,a.jsxs)("div",{className:x().stack,"aria-busy":"true","aria-label":"Loading profile settings",children:[["Preferences","Security","Routing and network"].map(e=>(0,a.jsxs)(l.Zp,{padding:"none",className:x().section,children:[(0,a.jsx)(l.EA,{className:"mb-5 h-4 w-32"}),(0,a.jsxs)("div",{className:x().formGrid,children:[(0,a.jsx)(l.EA,{className:"h-10"}),(0,a.jsx)(l.EA,{className:"h-10"})]}),(0,a.jsx)(l.EA,{className:"mt-4 h-4 w-48 max-w-full"})]},e)),(0,a.jsx)("p",{className:x().description,role:"status",children:"Loading profile settings…"})]}):L?(0,a.jsxs)(l.Zp,{padding:"none",className:x().section,children:[(0,a.jsx)(g,{status:{type:"error",message:L}}),(0,a.jsx)(l.$n,{variant:"secondary",onClick:()=>{k(!0),I(""),eR()},className:"mt-3",icon:"refresh",children:"Retry"})]}):(0,a.jsxs)("div",{className:x().stack,children:[(0,a.jsxs)(h,{id:"profile-preferences",title:"Preferences & data",icon:"settings",description:"Display preferences and database backups.",children:[(0,a.jsxs)("div",{className:x().settingRow,children:[(0,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsx)("p",{className:x().settingTitle,children:"Appearance"}),(0,a.jsx)("p",{className:x().settingDescription,children:"Use a light, dark, or system theme."})]}),(0,a.jsx)(l.Iz,{"aria-label":"Appearance",value:e,onChange:s,options:[{value:"light",label:"Light",icon:"light_mode"},{value:"dark",label:"Dark",icon:"dark_mode"},{value:"system",label:"System",icon:"contrast"}]})]}),(0,a.jsxs)("div",{className:x().settingRow,children:[(0,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsx)("p",{className:x().settingTitle,children:"Display language"}),(0,a.jsx)("p",{className:x().settingDescription,children:"Choose the language used in the dashboard."})]}),(0,a.jsxs)(l.$n,{variant:"secondary",onClick:()=>y(!0),"aria-label":"Change display language","data-i18n-skip":"true",children:[(0,a.jsx)("span",{"aria-hidden":"true",children:p[t]||"\uD83C\uDF10"}),(0,a.jsx)("span",{children:t}),(0,a.jsx)(i.default,{className:"text-[14px]","aria-hidden":"true",children:"expand_more"})]})]}),(0,a.jsx)("div",{className:x().settingRow,children:(0,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsx)("p",{className:x().settingTitle,children:eO?"Remote Mode":"Local Mode"}),(0,a.jsx)("p",{className:x().settingDescription,children:eO?"Connected to a remote instance.":"Running on your machine."})]})}),(0,a.jsxs)("div",{className:x().settingRow,children:[(0,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsx)("p",{className:x().settingTitle,children:"Database Location"}),(0,a.jsx)("code",{className:x().settingDescription,children:"~/.jrouter/db/data.sqlite"})]}),(0,a.jsxs)("div",{className:x().actions,children:[(0,a.jsx)(l.$n,{variant:"secondary",icon:"download",onClick:()=>q({open:!0,mode:"export",password:""}),loading:E,className:"w-full sm:w-auto",children:"Download Backup"}),(0,a.jsx)(l.$n,{variant:"secondary",icon:"upload",onClick:()=>ev.current?.click(),disabled:E,className:"w-full sm:w-auto",children:"Import Backup"}),(0,a.jsx)("input",{ref:ev,type:"file",accept:"application/json,.json",className:"hidden",onChange:e=>{let s=e.target.files?.[0];ev.current&&(ev.current.value=""),s&&(H.current=s,F({type:"",message:""}),q({open:!0,mode:"import",password:""}))}})]})]}),(0,a.jsx)(g,{status:U})]}),(0,a.jsx)(h,{id:"profile-security",title:"Security",icon:"shield",description:"Dashboard access and password management.",children:(0,a.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,a.jsxs)("div",{className:x().settingRow,children:[(0,a.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,a.jsx)("p",{className:"font-medium text-sm sm:text-base",children:"Require login"}),(0,a.jsx)("p",{className:"text-xs sm:text-sm text-text-muted",children:"When ON, dashboard requires password. When OFF, access without login."})]}),(0,a.jsx)(l.lM,{"aria-label":"Require login",checked:!0===S.requireLogin,onChange:()=>eX(!S.requireLogin),disabled:_})]}),!0===S.requireLogin&&(0,a.jsxs)("form",{onSubmit:eU,className:x().form,children:[S.hasPassword&&(0,a.jsx)("div",{className:"flex flex-col gap-2",children:(0,a.jsx)(l.pd,{label:"Current Password",autoComplete:"current-password",type:"password",placeholder:"Enter current password",value:A.current,onChange:e=>P({...A,current:e.target.value}),required:!0})}),(0,a.jsxs)("div",{className:x().formGrid,children:[(0,a.jsx)("div",{className:"flex flex-col gap-2",children:(0,a.jsx)(l.pd,{label:"New Password",autoComplete:"new-password",type:"password",placeholder:"Enter new password",value:A.new,onChange:e=>P({...A,new:e.target.value}),required:!0})}),(0,a.jsx)("div",{className:"flex flex-col gap-2",children:(0,a.jsx)(l.pd,{label:"Confirm New Password",autoComplete:"new-password",type:"password",placeholder:"Confirm new password",value:A.confirm,onChange:e=>P({...A,confirm:e.target.value}),required:!0})})]}),(0,a.jsx)(g,{status:O}),(0,a.jsx)("div",{className:"pt-2",children:(0,a.jsx)(l.$n,{type:"submit",variant:"contrast",loading:R,className:"w-full sm:w-auto",children:S.hasPassword?"Update Password":"Set Password"})})]})]})}),(0,a.jsx)("section",{"aria-labelledby":"profile-sso",children:(0,a.jsxs)(l.Zp,{padding:"none",className:x().section,children:[(0,a.jsxs)("button",{type:"button",onClick:()=>et(e=>!e),className:x().disclosure,"aria-expanded":es,"aria-controls":"profile-sso-settings",children:[(0,a.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,a.jsxs)("h2",{id:"profile-sso",className:"ui-eyebrow",children:[(0,a.jsx)(i.default,{className:"text-[16px]","aria-hidden":"true",children:"lock_open"}),"Single Sign-On (SSO)"]}),(0,a.jsx)("p",{className:x().sectionDescription,children:"sso"===S.authMode||"oidc"===S.authMode||"saml"===S.authMode?`${"saml"===S.ssoType?"SAML 2.0":"OIDC"} SSO active`:"both"===S.authMode?`Password + ${"saml"===S.ssoType?"SAML 2.0":"OIDC"} active`:"Optional SSO via Okta, Entra ID, Keycloak, or OIDC"})]}),(0,a.jsx)(i.default,{className:"text-text-muted shrink-0",children:es?"expand_less":"expand_more"})]}),es&&(0,a.jsxs)("div",{id:"profile-sso-settings",className:x().ssoForm,children:[(0,a.jsx)("p",{className:"text-xs sm:text-sm text-text-muted",children:"Configure enterprise Single Sign-On (SSO) for dashboard access using SAML 2.0 or OIDC."}),(0,a.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,a.jsx)("p",{className:x().fieldLabel,children:"SSO Protocol"}),(0,a.jsx)(l.Iz,{"aria-label":"SSO Protocol",value:eo,onChange:en,options:[{value:"saml",label:"SAML 2.0"},{value:"oidc",label:"OIDC"}],className:"self-start"})]}),(0,a.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,a.jsx)("p",{className:x().fieldLabel,children:"Auth Mode"}),(0,a.jsx)("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-2",children:[{value:"password",title:"Password only",desc:"Keep legacy password login."},{value:"sso",title:`${"saml"===eo?"SAML":"OIDC"} only`,desc:"Require SSO for dashboard access."},{value:"both",title:"Both",desc:"Allow password or SSO login."}].map(e=>{let s=X.authMode,t="password"===e.value?"password"===s:"sso"===e.value?"sso"===s||"saml"===s||"oidc"===s:"both"===s;return(0,a.jsxs)(l.$n,{type:"button",onClick:()=>eB("authMode",e.value),variant:"outline",className:x().choice,"aria-pressed":t,disabled:_||Z||eu,children:[(0,a.jsx)("span",{className:x().settingTitle,children:e.title}),(0,a.jsx)("span",{className:x().settingDescription,children:e.desc})]},e.value)})})]}),"saml"===eo?(0,a.jsxs)("div",{className:"flex flex-col gap-4 pt-2 border-t border-border/50",children:[(0,a.jsxs)("div",{className:x().inset,children:[(0,a.jsxs)("button",{type:"button",onClick:()=>ej(e=>!e),className:x().disclosure,"aria-expanded":ey,"aria-controls":"profile-saml-guide",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)(i.default,{className:"text-text-muted text-lg","aria-hidden":"true",children:"menu_book"}),(0,a.jsxs)("div",{children:[(0,a.jsx)("p",{className:"font-semibold text-xs sm:text-sm text-text-main",children:"IdP Setup Guidelines & Provider Configuration Instructions"}),(0,a.jsx)("p",{className:"text-[11px] text-text-muted",children:"Click to view setup steps for AWS IAM Identity Center, Okta, Entra ID, Keycloak, & Authentik"})]})]}),(0,a.jsx)(i.default,{className:"text-text-muted transition-transform text-lg",style:{transform:ey?"rotate(180deg)":"none"},children:"expand_more"})]}),ey&&(0,a.jsxs)("div",{id:"profile-saml-guide",className:x().guide,children:[(0,a.jsxs)("div",{className:x().inset,children:[(0,a.jsx)("p",{className:"font-semibold mb-1",children:"Required Service Provider (SP) Values for your IdP Setup:"}),(0,a.jsxs)("ul",{className:"list-disc pl-4 space-y-1 font-mono text-[11px]",children:[(0,a.jsxs)("li",{children:[(0,a.jsx)("b",{children:"Assertion Consumer Service (ACS) URL:"})," ",(0,a.jsx)("code",{className:"bg-bg px-1 py-0.5 rounded break-all",children:er})]}),(0,a.jsxs)("li",{children:[(0,a.jsx)("b",{children:"SP Entity ID / Audience URI:"})," ",(0,a.jsx)("code",{className:"bg-bg px-1 py-0.5 rounded break-all",children:ed.samlIssuer||"urn:jrouter:sp"})]}),(0,a.jsxs)("li",{children:[(0,a.jsx)("b",{children:"NameID Format:"})," ",(0,a.jsx)("code",{className:"bg-bg px-1 py-0.5 rounded",children:"EmailAddress"})," or ",(0,a.jsx)("code",{className:"bg-bg px-1 py-0.5 rounded",children:"Unspecified"})]})]})]}),(0,a.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3 pt-1",children:[(0,a.jsxs)("div",{className:"p-3 rounded border border-border bg-bg/50 flex flex-col gap-1.5",children:[(0,a.jsx)("p",{className:"font-semibold text-text-main flex items-center gap-1.5",children:"AWS IAM Identity Center"}),(0,a.jsxs)("ol",{className:"list-decimal pl-4 text-text-muted space-y-1",children:[(0,a.jsxs)("li",{children:["Applications → ",(0,a.jsx)("b",{children:"Add application"})," → Select ",(0,a.jsx)("b",{children:"Add custom SAML 2.0 application"}),"."]}),(0,a.jsxs)("li",{children:["Set ",(0,a.jsx)("b",{children:"Application ACS URL"})," to ",(0,a.jsx)("code",{className:"text-text-main font-mono",children:er}),"."]}),(0,a.jsxs)("li",{children:["Set ",(0,a.jsx)("b",{children:"Application SAML audience"})," to ",(0,a.jsx)("code",{className:"text-text-main font-mono",children:ed.samlIssuer||"urn:jrouter:sp"}),"."]}),(0,a.jsxs)("li",{children:["Under ",(0,a.jsx)("i",{children:"Attribute mappings"}),", map ",(0,a.jsx)("code",{className:"text-text-main font-mono",children:"Subject"})," or ",(0,a.jsx)("code",{className:"text-text-main font-mono",children:"email"})," to ",(0,a.jsxs)("code",{className:"text-text-main font-mono",children:["$","{user:email}"]}),"."]}),(0,a.jsxs)("li",{children:["Download ",(0,a.jsx)("b",{children:"IAM Identity Center SAML metadata XML"})," file and use 1-Click Import below!"]})]})]}),(0,a.jsxs)("div",{className:"p-3 rounded border border-border bg-bg/50 flex flex-col gap-1.5",children:[(0,a.jsx)("p",{className:"font-semibold text-text-main flex items-center gap-1.5",children:"Microsoft Entra ID (Azure AD)"}),(0,a.jsxs)("ol",{className:"list-decimal pl-4 text-text-muted space-y-1",children:[(0,a.jsxs)("li",{children:["Enterprise Applications → ",(0,a.jsx)("b",{children:"New application"})," → ",(0,a.jsx)("b",{children:"Create your own application"}),"."]}),(0,a.jsxs)("li",{children:["Select ",(0,a.jsx)("b",{children:"Single sign-on"})," → ",(0,a.jsx)("b",{children:"SAML"}),"."]}),(0,a.jsxs)("li",{children:[(0,a.jsx)("b",{children:"Identifier (Entity ID):"})," ",(0,a.jsx)("code",{className:"text-text-main font-mono",children:ed.samlIssuer||"urn:jrouter:sp"})]}),(0,a.jsxs)("li",{children:[(0,a.jsx)("b",{children:"Reply URL (ACS):"})," ",(0,a.jsx)("code",{className:"text-text-main font-mono",children:er})]}),(0,a.jsxs)("li",{children:["Download ",(0,a.jsx)("b",{children:"Federation Metadata XML"})," and import or copy X.509 Certificate."]})]})]}),(0,a.jsxs)("div",{className:"p-3 rounded border border-border bg-bg/50 flex flex-col gap-1.5",children:[(0,a.jsx)("p",{className:"font-semibold text-text-main flex items-center gap-1.5",children:"Okta / Auth0"}),(0,a.jsxs)("ol",{className:"list-decimal pl-4 text-text-muted space-y-1",children:[(0,a.jsxs)("li",{children:["Applications → ",(0,a.jsx)("b",{children:"Create App Integration"})," → Select ",(0,a.jsx)("b",{children:"SAML 2.0"}),"."]}),(0,a.jsxs)("li",{children:[(0,a.jsx)("b",{children:"Single Sign-On URL:"})," ",(0,a.jsx)("code",{className:"text-text-main font-mono",children:er})]}),(0,a.jsxs)("li",{children:[(0,a.jsx)("b",{children:"Audience URI (SP Entity ID):"})," ",(0,a.jsx)("code",{className:"text-text-main font-mono",children:ed.samlIssuer||"urn:jrouter:sp"})]}),(0,a.jsxs)("li",{children:["Name ID format: ",(0,a.jsx)("i",{children:"EmailAddress"}),"."]}),(0,a.jsx)("li",{children:"Download Identity Provider metadata XML or copy the X.509 cert."})]})]}),(0,a.jsxs)("div",{className:"p-3 rounded border border-border bg-bg/50 flex flex-col gap-1.5",children:[(0,a.jsx)("p",{className:"font-semibold text-text-main flex items-center gap-1.5",children:"Keycloak / Authentik"}),(0,a.jsxs)("ol",{className:"list-decimal pl-4 text-text-muted space-y-1",children:[(0,a.jsxs)("li",{children:["Clients → ",(0,a.jsx)("b",{children:"Create client"})," → Select ",(0,a.jsx)("b",{children:"SAML"}),"."]}),(0,a.jsxs)("li",{children:[(0,a.jsx)("b",{children:"Client ID:"})," ",(0,a.jsx)("code",{className:"text-text-main font-mono",children:ed.samlIssuer||"urn:jrouter:sp"})]}),(0,a.jsxs)("li",{children:[(0,a.jsx)("b",{children:"Master SAML Processing URL:"})," ",(0,a.jsx)("code",{className:"text-text-main font-mono",children:er})]}),(0,a.jsx)("li",{children:"Export SAML Descriptor XML or copy IDP Certificate PEM."})]})]})]})]})]}),(0,a.jsxs)("div",{className:x().settingRow,children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("p",{className:"font-medium text-sm text-text-main",children:"1-Click IdP Metadata XML Import"}),(0,a.jsx)("p",{className:"text-xs text-text-muted",children:"Auto-fill SSO URL, Issuer & Cert from XML metadata"})]}),(0,a.jsx)(l.$n,{type:"button",variant:"outline",size:"sm",icon:"upload_file",onClick:()=>eN.current?.click(),children:"Upload Metadata XML"}),(0,a.jsx)("input",{ref:eN,type:"file",accept:".xml,application/xml,text/xml",className:"hidden",onChange:e=>{let s=e.target.files?.[0];if(eN.current&&(eN.current.value=""),!s)return;let t=new FileReader;t.onload=e=>{try{let s=e.target?.result||"",t=new DOMParser().parseFromString(s,"text/xml");if(t.querySelector("parsererror"))return void ep({type:"error",message:"Unable to parse valid SAML IdP metadata from XML file"});let a=t.documentElement.getAttribute("entityID")||"",i=Array.from(t.querySelectorAll("SingleSignOnService, *|SingleSignOnService")),r="";for(let e of i){let s=e.getAttribute("Binding")||"",t=e.getAttribute("Location")||"";if(t&&(r=t,s.includes("HTTP-Redirect")))break}let l=Array.from(t.querySelectorAll("X509Certificate, *|X509Certificate")),o="";l.length>0&&(o=l[0].textContent.trim()),ec(e=>({...e,samlEntryPoint:r||e.samlEntryPoint,samlIssuer:e.samlIssuer||"urn:jrouter:sp",samlCert:o||e.samlCert})),ep({type:"success",message:`IdP Metadata imported! (SSO URL: ${r?"found":"not found"}, EntityID: ${a?"found":"not found"}, Cert: ${o?"found":"not found"})`})}catch(e){ep({type:"error",message:"Error reading IdP Metadata XML file"})}},t.readAsText(s)}})]}),(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-4",children:[(0,a.jsx)("div",{className:"flex flex-col gap-2",children:(0,a.jsx)(l.pd,{label:"Single Sign-On Service URL (samlEntryPoint)",placeholder:"https://idp.example.com/app/saml/sso/...",value:ed.samlEntryPoint,onChange:e=>eG("samlEntryPoint",e.target.value),disabled:_||eu})}),(0,a.jsx)("div",{className:"flex flex-col gap-2",children:(0,a.jsx)(l.pd,{label:"SP Entity ID / Audience (samlIssuer)",placeholder:"urn:jrouter:sp",value:ed.samlIssuer,onChange:e=>eG("samlIssuer",e.target.value),disabled:_||eu})}),(0,a.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,a.jsxs)("div",{className:x().actions,children:[(0,a.jsx)("label",{htmlFor:"profile-saml-cert",className:x().fieldLabel,children:"IdP X.509 Certificate (samlCert)"}),(0,a.jsx)(l.$n,{type:"button",variant:"outline",size:"sm",icon:"file_upload",onClick:()=>ew.current?.click(),children:"Upload Certificate"}),(0,a.jsx)("input",{ref:ew,type:"file",accept:".crt,.pem,.cer,text/plain",className:"hidden",onChange:e=>{let s=e.target.files?.[0];if(ew.current&&(ew.current.value=""),!s)return;let t=new FileReader;t.onload=e=>{let s=e.target?.result||"";ec(e=>({...e,samlCert:s.trim()})),ep({type:"success",message:"Certificate file loaded into configuration."})},t.readAsText(s)}})]}),(0,a.jsx)("textarea",{id:"profile-saml-cert","aria-describedby":"profile-saml-cert-hint",rows:4,placeholder:"-----BEGIN CERTIFICATE-----\nMIIC...\n-----END CERTIFICATE-----",value:ed.samlCert,onChange:e=>eG("samlCert",e.target.value),className:"w-full font-mono resize-y",disabled:_||eu}),(0,a.jsx)("p",{id:"profile-saml-cert-hint",className:x().settingDescription,children:"Paste raw Base64 certificate or PEM block."})]}),(0,a.jsxs)("div",{className:x().formGrid,children:[(0,a.jsx)("div",{className:"flex flex-col gap-2",children:(0,a.jsx)(l.pd,{label:"Login Button Label",placeholder:"Sign in with SAML SSO",value:ed.samlLoginLabel,onChange:e=>eG("samlLoginLabel",e.target.value),disabled:_||eu})}),(0,a.jsx)("div",{className:"flex flex-col gap-2",children:(0,a.jsx)(l.pd,{label:"Email Claim Attribute",placeholder:"email",value:ed.samlAttributeEmail,onChange:e=>eG("samlAttributeEmail",e.target.value),disabled:_||eu})}),(0,a.jsx)("div",{className:"flex flex-col gap-2",children:(0,a.jsx)(l.pd,{label:"Display Name Claim",placeholder:"name",value:ed.samlAttributeName,onChange:e=>eG("samlAttributeName",e.target.value),disabled:_||eu})})]})]}),(0,a.jsxs)("div",{className:x().inset,children:[(0,a.jsxs)("div",{className:x().settingRow,children:[(0,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsx)("p",{className:"font-medium text-text-main",children:"ACS Callback URL"}),(0,a.jsx)("code",{className:"block break-all font-mono text-xs",children:er})]}),(0,a.jsx)(l.$n,{type:"button",variant:"outline",size:"sm",icon:"content_copy","aria-label":"Copy ACS Callback URL",onClick:()=>{navigator.clipboard.writeText(er),ep({type:"success",message:"ACS URL copied to clipboard!"})},children:"Copy"})]}),(0,a.jsxs)("div",{className:x().settingRow,children:[(0,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsx)("p",{className:"font-medium text-text-main",children:"SP XML Metadata"}),(0,a.jsx)("code",{className:"block break-all font-mono text-xs",children:el})]}),(0,a.jsxs)("a",{href:el,target:"_blank",rel:"noopener noreferrer",download:"jrouter-sp-metadata.xml",className:x().linkButton,children:[(0,a.jsx)(i.default,{className:"text-[16px]",children:"download"}),"Download XML"]})]})]}),(0,a.jsxs)("div",{className:"flex flex-col sm:flex-row gap-2 pt-2 border-t border-border/50",children:[(0,a.jsx)(l.$n,{type:"button",variant:"contrast",loading:eu,onClick:()=>eK(X.authMode),className:"w-full sm:w-auto",children:"Save SAML settings"}),(0,a.jsx)(l.$n,{type:"button",variant:"outline",loading:eh,onClick:eZ,className:"w-full sm:w-auto",children:"Test SAML settings"})]}),(0,a.jsx)(g,{status:eb}),(0,a.jsx)(g,{status:em})]}):(0,a.jsxs)("div",{className:"flex flex-col gap-4 pt-2 border-t border-border/50",children:[(0,a.jsxs)("div",{className:x().formGrid,children:[(0,a.jsx)("div",{className:"flex flex-col gap-2",children:(0,a.jsx)(l.pd,{label:"Issuer URL",placeholder:"https://auth.example.com/application/o/jrouter/",value:X.oidcIssuerUrl,onChange:e=>eB("oidcIssuerUrl",e.target.value),disabled:_||Z})}),(0,a.jsx)("div",{className:"flex flex-col gap-2",children:(0,a.jsx)(l.pd,{label:"Client ID",placeholder:"jrouter-dashboard",value:X.oidcClientId,onChange:e=>eB("oidcClientId",e.target.value),disabled:_||Z})}),(0,a.jsx)("div",{className:"flex flex-col gap-2",children:(0,a.jsx)(l.pd,{label:"Client Secret",hint:"This value is write-only after saving.",type:"password",placeholder:"Leave blank to keep existing secret",value:J,onChange:e=>z(e.target.value),disabled:_||Z})}),(0,a.jsx)("div",{className:"flex flex-col gap-2",children:(0,a.jsx)(l.pd,{label:"Scopes",placeholder:"openid profile email",value:X.oidcScopes,onChange:e=>eB("oidcScopes",e.target.value),disabled:_||Z})}),(0,a.jsx)("div",{className:"flex flex-col gap-2",children:(0,a.jsx)(l.pd,{label:"Login Button Label",placeholder:"Sign in with OIDC",value:X.oidcLoginLabel,onChange:e=>eB("oidcLoginLabel",e.target.value),disabled:_||Z})})]}),(0,a.jsxs)("div",{className:x().inset,children:[(0,a.jsx)("p",{className:"font-medium text-text-main mb-1",children:"Redirect URI"}),(0,a.jsx)("code",{className:"block break-all font-mono",children:ei})]}),(0,a.jsxs)("div",{className:"flex flex-col sm:flex-row gap-2 pt-2 border-t border-border/50",children:[(0,a.jsx)(l.$n,{type:"button",variant:"contrast",loading:Z,onClick:()=>eJ(),className:"w-full sm:w-auto",children:"Save OIDC settings"}),(0,a.jsx)(l.$n,{type:"button",variant:"outline",loading:Q,onClick:ez,className:"w-full sm:w-auto",children:"Test connection"})]}),(0,a.jsx)(g,{status:Y}),(0,a.jsx)(g,{status:G})]}),"oidc"===S.authMode||"saml"===S.authMode||"sso"===S.authMode?(0,a.jsxs)("p",{className:x().notice,role:"status",children:["SSO login (","saml"===S.ssoType?"SAML 2.0":"OIDC",") is currently active. Password login is disabled until you switch back."]}):null,"both"===S.authMode&&(0,a.jsxs)("p",{className:x().notice,role:"status",children:["Password and SSO login (","saml"===S.ssoType?"SAML 2.0":"OIDC",") are both active."]})]})]})}),(0,a.jsx)(h,{id:"profile-routing",title:"Routing Strategy",icon:"route",description:"Account and combo rotation preferences.",children:(0,a.jsxs)("div",{children:[(0,a.jsxs)("div",{className:x().settingRow,children:[(0,a.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,a.jsx)("p",{className:"font-medium text-sm sm:text-base",children:"Round Robin"}),(0,a.jsx)("p",{className:"text-xs sm:text-sm text-text-muted",children:"Cycle through accounts to distribute load"})]}),(0,a.jsx)(l.lM,{"aria-label":"Round Robin",checked:"round-robin"===S.fallbackStrategy,onChange:()=>eF("round-robin"===S.fallbackStrategy?"fill-first":"round-robin"),disabled:_})]}),"round-robin"===S.fallbackStrategy&&(0,a.jsxs)("div",{className:x().settingRow,children:[(0,a.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,a.jsx)("p",{className:"font-medium text-sm sm:text-base",children:"Sticky Limit"}),(0,a.jsx)("p",{className:"text-xs sm:text-sm text-text-muted",children:"Calls per account before switching"})]}),(0,a.jsx)(l.pd,{"aria-label":"Sticky Limit",type:"number",min:"1",max:"10",value:S.stickyRoundRobinLimit||3,onChange:e=>eq(e.target.value),disabled:_,className:"w-16 sm:w-20 text-center shrink-0"})]}),(0,a.jsxs)("div",{className:x().settingRow,children:[(0,a.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,a.jsx)("p",{className:"font-medium text-sm sm:text-base",children:"Combo Round Robin"}),(0,a.jsx)("p",{className:"text-xs sm:text-sm text-text-muted",children:"Cycle through providers in combos instead of always starting with first"})]}),(0,a.jsx)(l.lM,{"aria-label":"Combo Round Robin",checked:"round-robin"===S.comboStrategy,onChange:()=>e$("round-robin"===S.comboStrategy?"fallback":"round-robin"),disabled:_})]}),"round-robin"===S.comboStrategy&&(0,a.jsxs)("div",{className:x().settingRow,children:[(0,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsx)("p",{className:"font-medium",children:"Combo Sticky Limit"}),(0,a.jsx)("p",{className:"text-sm text-text-muted",children:"Calls per combo model before switching"})]}),(0,a.jsx)(l.pd,{"aria-label":"Combo Sticky Limit",type:"number",min:"1",max:"100",value:S.comboStickyRoundRobinLimit||1,onChange:e=>eH(e.target.value),disabled:_,className:"w-20 text-center"})]}),(0,a.jsxs)("p",{className:"text-xs text-text-muted italic pt-2 border-t border-border/50",children:["round-robin"===S.fallbackStrategy?`Currently distributing requests across all available accounts with ${S.stickyRoundRobinLimit||3} calls per account.`:"Currently using accounts in priority order (Fill First).","round-robin"===S.comboStrategy?` Combos rotate after ${S.comboStickyRoundRobinLimit||1} call${1===(S.comboStickyRoundRobinLimit||1)?"":"s"} per model.`:" Combos always start with their first model."]})]})}),(0,a.jsx)(h,{id:"profile-network",title:"Network",icon:"wifi",description:"Outbound connections for OAuth and provider requests.",children:(0,a.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,a.jsxs)("div",{className:x().settingRow,children:[(0,a.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,a.jsx)("p",{className:"font-medium text-sm sm:text-base",children:"Outbound Proxy"}),(0,a.jsx)("p",{className:"text-xs sm:text-sm text-text-muted",children:"Enable proxy for OAuth + provider outbound requests."})]}),(0,a.jsx)(l.lM,{"aria-label":"Outbound Proxy",checked:!0===S.outboundProxyEnabled,onChange:()=>eT(!0!==S.outboundProxyEnabled),disabled:_||eL})]}),!0===S.outboundProxyEnabled&&(0,a.jsxs)("form",{onSubmit:eD,className:x().form,children:[(0,a.jsxs)("div",{className:x().formGrid,children:[(0,a.jsx)("div",{className:"flex flex-col gap-2",children:(0,a.jsx)(l.pd,{label:"Proxy URL",hint:"Leave empty to inherit existing env proxy (if any).",placeholder:"http://127.0.0.1:7897",value:eS.outboundProxyUrl,onChange:e=>eC(s=>({...s,outboundProxyUrl:e.target.value})),disabled:_||eL})}),(0,a.jsx)("div",{className:"flex flex-col gap-2",children:(0,a.jsx)(l.pd,{label:"No Proxy",hint:"Comma-separated hostnames/domains to bypass the proxy.",placeholder:"localhost,127.0.0.1",value:eS.outboundNoProxy,onChange:e=>eC(s=>({...s,outboundNoProxy:e.target.value})),disabled:_||eL})})]}),(0,a.jsxs)("div",{className:"pt-2 border-t border-border/50 flex flex-col sm:flex-row items-stretch sm:items-center gap-2",children:[(0,a.jsx)(l.$n,{type:"button",variant:"secondary",loading:eA,disabled:_||eL,onClick:eE,className:"w-full sm:w-auto",children:"Test proxy URL"}),(0,a.jsx)(l.$n,{type:"submit",variant:"contrast",loading:eL,className:"w-full sm:w-auto",children:"Apply"})]})]}),(0,a.jsx)(g,{status:e_})]})}),(0,a.jsx)(h,{id:"profile-observability",title:"Observability",icon:"monitoring",children:(0,a.jsxs)("div",{className:x().settingRow,children:[(0,a.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,a.jsx)("p",{className:"font-medium text-sm sm:text-base",children:"Enable Observability"}),(0,a.jsx)("p",{className:"text-xs sm:text-sm text-text-muted",children:"Record request details for inspection in the logs view"})]}),(0,a.jsx)(l.lM,{"aria-label":"Enable Observability",checked:e1,onChange:eV,disabled:_})]})}),(0,a.jsxs)(h,{id:"profile-session",title:"Session & server",icon:"logout",children:[(0,a.jsxs)("div",{className:x().settingRow,children:[(0,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsx)("p",{className:x().settingTitle,children:"Dashboard session"}),(0,a.jsx)("p",{className:x().settingDescription,children:"Sign out of the dashboard."})]}),(0,a.jsx)(l.$n,{variant:"secondary",icon:"logout",onClick:e5,children:"Logout"})]}),(0,a.jsxs)("div",{className:x().settingRow,children:[(0,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsx)("p",{className:x().settingTitle,children:"Stop proxy server"}),(0,a.jsx)("p",{className:x().settingDescription,children:"Shut down this JRouter instance."})]}),(0,a.jsx)(l.$n,{variant:"danger",icon:"power_settings_new",onClick:()=>N(!0),className:x().dangerButton,children:"Shutdown"})]})]}),(0,a.jsxs)("div",{className:x().appInfo,children:[(0,a.jsxs)("p",{children:[c.vQ.name," v",c.vQ.version]}),(0,a.jsx)("p",{className:"mt-1",children:eO?"Remote Mode":"Local Mode - All data stored on your machine"})]})]}),(0,a.jsx)(n.default,{dialogClassName:x().languageDialog,hideTrigger:!0,isOpen:f,onClose:e=>{y(!1),u(e)}}),(0,a.jsx)(o.ConfirmModal,{className:x().dialog,isOpen:j,onClose:()=>N(!1),onConfirm:e2,title:"Close Proxy",message:"Are you sure you want to close the proxy server?",confirmText:"Close",cancelText:"Cancel",variant:"danger",loading:w}),(0,a.jsxs)(o.default,{className:x().dialog,isOpen:$.open,onClose:()=>q({open:!1,mode:"",password:""}),title:"Confirm Password",size:"sm",footer:(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(l.$n,{variant:"ghost",onClick:()=>q({open:!1,mode:"",password:""}),disabled:E,children:"Cancel"}),(0,a.jsx)(l.$n,{variant:"contrast",onClick:e0,loading:E,disabled:!$.password,children:"Confirm"})]}),children:[(0,a.jsxs)("p",{className:"text-text-muted mb-3 text-sm",children:["Enter your current password to ","export"===$.mode?"export":"import"," the database."]}),(0,a.jsx)(l.pd,{label:"Current password",autoComplete:"current-password",type:"password",value:$.password,onChange:e=>q(s=>({...s,password:e.target.value})),onKeyDown:e=>{"Enter"===e.key&&$.password&&e0()},placeholder:"Current password",autoFocus:!0})]})]})}},48535:e=>{e.exports={page:"profile_page___tjyP token-saver_page__79V8u usage_page__TfrVH DashboardControls_formScope__ID02o DashboardControls_fields__IY485",header:"profile_header__IkyVh usage_header__Pj5rE",description:"profile_description__NXRzM usage_description___N7_0",section:"profile_section__UAY_s usage_section__Q1FLM",sectionHeader:"profile_sectionHeader___cLAs usage_sectionHeader__ikyc_",sectionDescription:"profile_sectionDescription__ZbT8S usage_sectionDescription__hUHjE",fieldLabel:"profile_fieldLabel__TDwV7 usage_fieldLabel__QyUjE",inset:"profile_inset__DdQQ3 usage_inset__ua4iZ",dialog:"profile_dialog__vjXNZ DashboardControls_dialog__YyPS4",dangerButton:"profile_dangerButton__gObBc endpoint_dangerButton__zSy_6",linkButton:"profile_linkButton__Ohf76 skills_linkButton__mVXTi",stack:"profile_stack__stIZ4",settingRow:"profile_settingRow__SqVZr endpoint_settingsRow__MBLvY",settingTitle:"profile_settingTitle__c_bHF token-saver_title__9opCy",settingDescription:"profile_settingDescription__5HFh3 token-saver_metadata__ktGrx",actions:"profile_actions__W0G3b",form:"profile_form__lLMlh",ssoForm:"profile_ssoForm__QKyCp",formGrid:"profile_formGrid__S7IE_",disclosure:"profile_disclosure__OXS9X",choice:"profile_choice__RAEhZ",guide:"profile_guide__Yl3qV",status:"profile_status__dFw2G",notice:"profile_notice__z5zKe",appInfo:"profile_appInfo__zIFC1",languageDialog:"profile_languageDialog__4pCcf DashboardControls_dialog__YyPS4"}},96754:(e,s,t)=>{Promise.resolve().then(t.bind(t,29404))}},e=>{e.O(0,[3493,8679,970,636,4660,2904,6506,8500,3847,1321,705,5497,8441,3794,7358],()=>e(e.s=96754)),_N_E=e.O()}]);
@@ -0,0 +1 @@
1
+ (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[9516],{5895:(e,s,i)=>{Promise.resolve().then(i.bind(i,64082))},51513:e=>{e.exports={page:"skills_page__BcOXn usage_page__TfrVH DashboardControls_formScope__ID02o",header:"skills_header__B0vSK usage_header__Pj5rE",description:"skills_description__cVcfA usage_description___N7_0",section:"skills_section__HcGBd usage_section__Q1FLM",sectionHeader:"skills_sectionHeader__Po5WD usage_sectionHeader__ikyc_",sectionDescription:"skills_sectionDescription__B36_K usage_sectionDescription__hUHjE",hint:"skills_hint__e9ECF",command:"skills_command__2tMeb",rows:"skills_rows__Zf9N_",row:"skills_row__DbV7C",identity:"skills_identity__XRZ9Z",icon:"skills_icon__d_qRC",titleLine:"skills_titleLine__vDBuc",title:"skills_title__RWwN8",endpoint:"skills_endpoint__GrxIx",metadata:"skills_metadata__NYKys",url:"skills_url__13nhN",urlText:"skills_urlText__HNFGe",actions:"skills_actions__bY309",linkButton:"skills_linkButton__mVXTi"}},64082:(e,s,i)=>{"use strict";i.r(s),i.d(s,{default:()=>b});var a=i(95155),n=i(96439),t=i(35497),l=i(66119),r=i(11059);let c="Synthever/JRouter",o="master",d="skills",h=`https://github.com/${c}`,_=`https://raw.githubusercontent.com/${c}/refs/heads/${o}/${d}`,m=`https://github.com/${c}/blob/${o}/${d}`,p=[{id:"jrouter",name:"JRouter (Entry)",description:"Setup + index of all capabilities. Start here — covers base URL, auth, model discovery, and links to every capability skill.",endpoint:null,icon:"hub",isEntry:!0},{id:"jrouter-chat",name:"Chat",description:"Chat / code-gen via OpenAI or Anthropic format with streaming.",endpoint:"/v1/chat/completions",icon:"chat"},{id:"jrouter-image",name:"Image Generation",description:"Text-to-image via DALL-E, Imagen, FLUX, MiniMax, SDWebUI…",endpoint:"/v1/images/generations",icon:"image"},{id:"jrouter-tts",name:"Text-to-Speech",description:"OpenAI / ElevenLabs / Edge / Google / Deepgram voices.",endpoint:"/v1/audio/speech",icon:"record_voice_over"},{id:"jrouter-stt",name:"Speech-to-Text",description:"Transcribe audio via OpenAI Whisper, Groq, Gemini, Deepgram, AssemblyAI…",endpoint:"/v1/audio/transcriptions",icon:"mic"},{id:"jrouter-embeddings",name:"Embeddings",description:"Vectors for RAG / semantic search via OpenAI, Gemini, Mistral…",endpoint:"/v1/embeddings",icon:"scatter_plot"},{id:"jrouter-web-search",name:"Web Search",description:"Web and X search via Tavily / Exa / Brave / Serper / SearXNG / Google PSE / You.com / Xquik.",endpoint:"/v1/search",icon:"search"},{id:"jrouter-web-fetch",name:"Web Fetch",description:"URL → markdown / text / HTML via Firecrawl, Jina, Tavily, Exa.",endpoint:"/v1/web/fetch",icon:"language"}];function u(e){return`${_}/${e}/SKILL.md`}var x=i(51513),k=i.n(x);function j({value:e,skillName:s,label:i="Copy link"}){let{copied:n,copy:l}=(0,r.C)(2e3);return(0,a.jsx)(t.$n,{variant:"secondary",size:"sm",icon:n?"check":"content_copy",onClick:()=>l(e),title:e,"aria-label":n?`Copied ${s} link`:`${i} for ${s}`,children:n?"Copied!":i})}function N({skill:e}){var s;let i=u(e.id);return(0,a.jsxs)("li",{className:k().row,children:[(0,a.jsxs)("div",{className:k().identity,children:[(0,a.jsx)("span",{className:k().icon,"data-entry":e.isEntry?"true":"false","aria-hidden":"true",children:(0,a.jsx)(n.default,{className:"text-[18px]",children:e.icon})}),(0,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsxs)("div",{className:k().titleLine,children:[(0,a.jsx)("h3",{className:k().title,children:e.name}),e.isEntry&&(0,a.jsx)(l.A,{dot:!1,children:"Start here"}),e.endpoint&&(0,a.jsx)("code",{className:k().endpoint,children:e.endpoint})]}),(0,a.jsx)("p",{className:k().metadata,children:e.description}),(0,a.jsxs)("a",{className:k().url,href:(s=e.id,`${m}/${s}/SKILL.md`),target:"_blank",rel:"noreferrer",title:i,children:[(0,a.jsx)("span",{className:k().urlText,children:i}),(0,a.jsx)(n.default,{className:"mt-[3px] shrink-0 text-[13px]",children:"open_in_new"})]})]})]}),(0,a.jsx)("div",{className:k().actions,children:(0,a.jsx)(j,{value:i,skillName:e.name})})]})}function b(){return(0,a.jsxs)("div",{className:`dashboard-surface ${k().page}`,children:[(0,a.jsx)("header",{className:k().header,children:(0,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsxs)("h1",{className:"ui-eyebrow flex items-center gap-2",children:[(0,a.jsx)(n.default,{className:"text-[16px]",children:"extension"})," Skills"]}),(0,a.jsx)("p",{className:k().description,children:"Reusable agent skills — copy a raw URL and paste it into any AI agent"})]})}),(0,a.jsxs)("section",{className:`ui-card ${k().section}`,"aria-labelledby":"skills-quickstart-heading",children:[(0,a.jsx)("div",{className:k().sectionHeader,children:(0,a.jsx)("h2",{id:"skills-quickstart-heading",className:"ui-eyebrow",children:"Quick start"})}),(0,a.jsx)("p",{className:k().hint,children:"Paste this to your AI:"}),(0,a.jsx)("div",{className:k().command,children:(0,a.jsxs)("code",{children:["Read this skill and use it: ",u("jrouter")]})})]}),(0,a.jsxs)("section",{className:`ui-card ${k().section}`,"aria-labelledby":"skills-list-heading",children:[(0,a.jsx)("div",{className:k().sectionHeader,children:(0,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsxs)("h2",{id:"skills-list-heading",className:"ui-eyebrow flex items-center gap-2",children:[(0,a.jsx)(n.default,{className:"text-[16px]",children:"list_alt"})," Available skills"]}),(0,a.jsxs)("p",{className:k().sectionDescription,children:[p.length," skills \xb7 each one is a single SKILL.md you can hand to an agent"]})]})}),(0,a.jsx)("ul",{className:k().rows,children:p.map(e=>(0,a.jsx)(N,{skill:e},e.id))})]}),(0,a.jsx)("section",{className:`ui-card ${k().section}`,"aria-labelledby":"skills-repo-heading",children:(0,a.jsxs)("div",{className:k().sectionHeader,children:[(0,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsx)("h2",{id:"skills-repo-heading",className:"ui-eyebrow",children:"More on GitHub"}),(0,a.jsx)("p",{className:k().sectionDescription,children:"Browse source, README, and examples."})]}),(0,a.jsxs)("a",{className:k().linkButton,href:`${h}/tree/master/skills`,target:"_blank",rel:"noreferrer",children:[(0,a.jsx)(n.default,{className:"text-[16px]",children:"open_in_new"}),"View on GitHub"]})]})})]})}}},e=>{e.O(0,[3493,8679,970,2904,6506,8500,3847,1321,705,5497,8441,3794,7358],()=>e(e.s=5895)),_N_E=e.O()}]);
@@ -1 +1 @@
1
- (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[9839],{15536:(e,a,s)=>{"use strict";s.d(a,{Cp:()=>i,Hx:()=>n,Iv:()=>d,Nv:()=>m,RL:()=>c,ev:()=>h,fl:()=>r,hT:()=>t,oX:()=>l,t6:()=>o});let t=["zh-CN","zh-TW"],l=[{icon:"public",title:"Access Anywhere",desc:"Use your API from any network"},{icon:"group",title:"Share Endpoint",desc:"Share URL with team members"},{icon:"code",title:"Use in Cursor/Cline",desc:"Connect AI tools remotely"},{icon:"lock",title:"Encrypted",desc:"End-to-end TLS via Cloudflare"}],n=2e3,i=3e5,r=5e3,o=5,c=1e4,d=5e3,h=[{id:"lite",label:"Lite",desc:"Drop filler, keep grammar"},{id:"full",label:"Full",desc:"Drop articles, fragments OK"},{id:"ultra",label:"Ultra",desc:"Telegraphic, max compression"},{id:"wenyan-lite",label:"文 Lite",desc:"Classical Chinese, light compression",wenyan:!0},{id:"wenyan",label:"文 Full",desc:"Maximum 文言文, 80-90% reduction",wenyan:!0},{id:"wenyan-ultra",label:"文 Ultra",desc:"Extreme classical compression",wenyan:!0}],m=[{id:"lite",label:"Lite",desc:"Build asked, name lazier option"},{id:"full",label:"Full",desc:"Ladder enforced: stdlib/native first"},{id:"ultra",label:"Ultra",desc:"YAGNI extremist, deletion first"}]},43407:(e,a,s)=>{Promise.resolve().then(s.bind(s,61203))},61203:(e,a,s)=>{"use strict";s.d(a,{default:()=>x});var t=s(95155),l=s(96439),n=s(12115),i=s(35497),r=s(66119),o=s(11059),c=s(73006),d=s(15536),h=s(96091),m=s.n(h);let p='pip install "headroom-ai[proxy]"';function u({icon:e,title:a,doc:s,docHref:n,active:i,description:o,control:c,children:d}){return(0,t.jsxs)("div",{className:m().strategy,children:[(0,t.jsxs)("div",{className:m().strategyHeader,children:[(0,t.jsxs)("div",{className:m().identity,children:[(0,t.jsx)(l.default,{className:"shrink-0 text-[16px] text-[var(--text-2)]",children:e}),(0,t.jsxs)("div",{className:"min-w-0",children:[(0,t.jsxs)("div",{className:m().titleLine,children:[(0,t.jsx)("span",{className:m().title,children:a}),(0,t.jsx)("a",{href:n,target:"_blank",rel:"noreferrer",className:m().docLink,children:s}),(0,t.jsx)(r.A,{variant:i?"success":"default",children:i?"Active":"Off"})]}),(0,t.jsx)("p",{className:m().metadata,children:o})]})]}),(0,t.jsx)("div",{className:m().actions,children:c})]}),d]})}function x(){let[e,a]=(0,n.useState)(!0),[s,h]=(0,n.useState)(!1),[x,v]=(0,n.useState)("http://localhost:8787"),[g,f]=(0,n.useState)(3e3),[_,j]=(0,n.useState)({installed:!1,running:!1,python:null,loading:!0}),[y,k]=(0,n.useState)(!1),[b,C]=(0,n.useState)(!1),[N,S]=(0,n.useState)(""),[w,E]=(0,n.useState)({version:null,extras:{code:!1,ml:!1},available:["code","ml"],loading:!1}),[H,L]=(0,n.useState)([]),[P,T]=(0,n.useState)(!1),[R,M]=(0,n.useState)(""),[I,$]=(0,n.useState)(null),[O,U]=(0,n.useState)(""),[A,D]=(0,n.useState)(null),[z,B]=(0,n.useState)(!1),[F,J]=(0,n.useState)(!0),[K,W]=(0,n.useState)(!1),G=(0,n.useRef)(null),[X,q]=(0,n.useState)(!1),[Y,Q]=(0,n.useState)("full"),[V,Z]=(0,n.useState)(!1),[ee,ea]=(0,n.useState)("full"),[es,et]=(0,n.useState)(!1),[el,en]=(0,n.useState)(25e3),[ei,er]=(0,n.useState)({installed:!1,installing:!1,running:!1,version:null,loading:!0}),[eo,ec]=(0,n.useState)(null),[ed,eh]=(0,n.useState)(!1),[em,ep]=(0,n.useState)(!1),[eu,ex]=(0,n.useState)(""),[ev,eg]=(0,n.useState)("en"),{copied:ef,copy:e_}=(0,o.C)();(0,n.useEffect)(()=>(eg((0,c.kk)()),(0,c.oQ)(()=>eg((0,c.kk)()))),[]);let ej=d.hT.includes(ev),ey=ej?d.ev:d.ev.filter(e=>!e.wenyan);(0,n.useEffect)(()=>{let e=d.ev.find(e=>e.id===Y);e?.wenyan&&!ej&&(Q("ultra"),ek({cavemanLevel:"ultra"}))},[ej,Y]);let ek=async e=>{try{await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})}catch(e){console.log("Error updating setting:",e)}},eb=async e=>{try{(await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({rtkEnabled:e})})).ok&&a(e)}catch(e){console.log("Error updating rtkEnabled:",e)}},eC=async()=>{let e=x.trim()||"http://localhost:8787";v(e),await ek({headroomUrl:e}),eN()},eN=(0,n.useCallback)(async()=>{j(e=>({...e,loading:!0}));try{let e=await fetch("/api/headroom/status",{headers:{"Cache-Control":"no-store"}}),a=await e.json();if(j({...a,loading:!1}),!a?.installed){E({version:null,extras:{code:!1,ml:!1},available:["code","ml"],loading:!1}),L([]);return}try{let e=await fetch("/api/headroom/extras",{headers:{"Cache-Control":"no-store"}});if(!e.ok)throw Error("extras status failed");let a=await e.json();E(e=>({...e,version:a.version??null,extras:a.extras||{code:!1,ml:!1},available:a.available||["code","ml"],loading:!1})),L([])}catch{E({version:null,extras:{code:!1,ml:!1},available:["code","ml"],loading:!1}),L([])}}catch{j({installed:!1,running:!1,python:null,loading:!1}),E({version:null,extras:{code:!1,ml:!1},available:["code","ml"],loading:!1}),L([])}},[]),eS=(0,n.useCallback)(async()=>{S(""),C(!0);try{let e=await fetch("/api/headroom/start",{method:"POST"}),a=await e.json().catch(()=>({}));if(!e.ok)throw Error(a.error||"Failed to start proxy");await eN()}catch(e){S(e.message)}finally{C(!1)}},[eN]),ew=(0,n.useCallback)(async()=>{C(!0);try{await fetch("/api/headroom/stop",{method:"POST"}),await eN()}finally{C(!1)}},[eN]),eE=(0,n.useCallback)(()=>{U(""),G.current&&clearInterval(G.current);let e=async()=>{try{let e=await fetch("/api/headroom/extras?log=1",{headers:{"Cache-Control":"no-store"}}),a=await e.json().catch(()=>({}));"string"==typeof a.log&&U(a.log)}catch{}};e(),G.current=setInterval(e,1500)},[]),eH=(0,n.useCallback)(()=>{G.current&&(clearInterval(G.current),G.current=null)},[]);(0,n.useEffect)(()=>()=>eH(),[eH]);let eL=(0,n.useCallback)(async()=>{if(0!==H.length){T(!0),M(""),eE();try{let e=await fetch("/api/headroom/extras",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({extras:H})}),a=await e.json().catch(()=>({}));if(!e.ok)throw Error(a.error||"Install failed");E(e=>({...e,version:a.version??e.version,extras:a.extras||e.extras})),L([])}catch(e){M(e.message)}finally{eH(),T(!1)}}},[H,eE,eH]),eP=(0,n.useCallback)(async e=>{$(e),M(""),eE();try{let a=await fetch("/api/headroom/extras",{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({extras:[e]})}),s=await a.json().catch(()=>({}));if(!a.ok)throw Error(s.error||"Remove failed");E(e=>({...e,version:s.version??e.version,extras:s.extras||e.extras}))}catch(e){M(e.message)}finally{eH(),$(null)}},[eE,eH]),eT=(0,n.useCallback)(()=>{if(0!==H.length){if(H.includes("ml"))return void D({title:"Install [ml]",message:"[ml] downloads ~1 GB (torch + huggingface-hub). Continue?",confirmText:"Install",variant:"primary",onConfirm:eL});eL()}},[H,eL]),eR=(0,n.useCallback)(e=>{D({title:`Remove [${e}]`,message:`Remove [${e}] and its packages?`,confirmText:"Remove",variant:"danger",onConfirm:()=>eP(e)})},[eP]),eM=(0,n.useCallback)(async(e,a)=>{if(M(""),"code"===e&&B(a),"ml"===e&&J(a),await ek({["code"===e?"headroomCodeAware":"headroomKompress"]:a}),_.running){W(!0);try{let e=await fetch("/api/headroom/restart",{method:"POST"}),a=await e.json().catch(()=>({}));if(!e.ok)throw Error(a.error||"Restart failed");await eN()}catch(e){M(e.message)}finally{W(!1)}}},[_.running,eN]),eI=(0,n.useCallback)(async()=>{er(e=>({...e,loading:!0}));try{let e=await fetch("/api/pxpipe/status",{headers:{"Cache-Control":"no-store"}}),a=await e.json();er({...a,loading:!1}),"number"==typeof a.minChars&&en(a.minChars)}catch{er({installed:!1,installing:!1,running:!1,version:null,loading:!1})}},[]),e$=(0,n.useCallback)(async()=>{try{let e=await fetch("/api/pxpipe/health",{method:"POST"});ec(await e.json())}catch(e){ec({healthy:!1,checks:[],error:e.message})}},[]),eO=(0,n.useCallback)(async e=>{ex(""),ep(!0);try{let a=await fetch(`/api/pxpipe/${e}`,{method:"POST"}),s=await a.json().catch(()=>({}));if(!a.ok)throw Error(s.error||`PXPIPE ${e} failed`);await eI(),await e$()}catch(e){ex(e.message)}finally{ep(!1)}},[eI,e$]);(0,n.useEffect)(()=>{(async()=>{try{let e=await fetch("/api/settings");if(e.ok){let s=await e.json();a(!1!==s.rtkEnabled),h(!!s.headroomEnabled),v(s.headroomUrl||"http://localhost:8787"),"number"==typeof s.headroomTimeoutMs&&f(s.headroomTimeoutMs),B(!0===s.headroomCodeAware),J(!1!==s.headroomKompress),q(!!s.cavemanEnabled),Q(s.cavemanLevel||"full"),Z(!!s.ponytailEnabled),ea(s.ponytailLevel||"full"),et(!!s.pxpipeEnabled),"number"==typeof s.pxpipeMinChars&&en(s.pxpipeMinChars),eN(),eI().then(e$)}}catch{}})()},[eN,eI,e$]);let eU=!!_.running,eA=_.loading?"Checking…":eU?"Running":!1===_.localUrl||_.installed?!1!==_.localUrl?"Stopped":"External":"Not installed",eD=!1!==_.localUrl,ez=!!_.canStart,eB=eD&&!!_.managedPid,eF=_.loading?"default":eU?"success":"warning",eJ=eD&&(eU||ez||!_.installed),eK=eo?.healthy===!0,eW=ei.loading?"Checking…":ei.installing?"Installing…":ei.installed?eK?"Healthy":ei.running?"Running":"Stopped":"Not installed",eG=(0,n.useMemo)(()=>ey.map(e=>({value:e.id,label:e.label,title:e.desc})),[ey]),eX=(0,n.useMemo)(()=>d.Nv.map(e=>({value:e.id,label:e.label,title:e.desc})),[]),eq=[e,s,X,V].filter(Boolean).length;return(0,t.jsxs)("div",{className:`dashboard-surface ${m().page}`,children:[(0,t.jsxs)("header",{className:m().header,children:[(0,t.jsxs)("div",{className:"min-w-0",children:[(0,t.jsxs)("h1",{className:"ui-eyebrow flex items-center gap-2",children:[(0,t.jsx)(l.default,{className:"text-[16px]",children:"bolt"})," Token Saver"]}),(0,t.jsx)("p",{className:m().description,children:"Request-time compression that cuts prompt and completion tokens before they reach the model"})]}),(0,t.jsx)("div",{className:m().summary,children:(0,t.jsxs)(r.A,{variant:eq>0?"success":"default",children:[eq," of 4 strategies active"]})})]}),(0,t.jsxs)("section",{className:`ui-card ${m().section}`,"aria-labelledby":"token-saver-strategies-heading",children:[(0,t.jsx)("div",{className:m().sectionHeader,children:(0,t.jsxs)("div",{className:"min-w-0",children:[(0,t.jsxs)("h2",{id:"token-saver-strategies-heading",className:"ui-eyebrow flex items-center gap-2",children:[(0,t.jsx)(l.default,{className:"text-[16px]",children:"list_alt"})," Strategies"]}),(0,t.jsx)("p",{className:m().sectionDescription,children:"Each strategy is applied independently. Changes save immediately."})]})}),(0,t.jsx)(u,{icon:"bolt",title:"Compress tool output",doc:"RTK",docHref:"https://github.com/rtk-ai/rtk",active:e,description:"git/grep/ls/tree/logs → 60-90% fewer input tokens",control:(0,t.jsx)(i.lM,{checked:e,onChange:()=>eb(!e),"aria-label":"Compress tool output (RTK)"})}),(0,t.jsx)(u,{icon:"layers",title:"Compress context",doc:"Headroom",docHref:"https://github.com/chopratejas/headroom",active:s,description:"Compress prompts via /v1/compress before routing to the model",control:(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(r.A,{variant:eF,children:eA}),eJ&&(0,t.jsx)(i.$n,{variant:"secondary",size:"sm",onClick:()=>k(!0),children:eU?"Manage":"Setup"}),(0,t.jsx)(i.lM,{checked:s,onChange:()=>{var e;let a;return e=!s,void(v(a=x.trim()||"http://localhost:8787"),h(e),ek({headroomEnabled:e,headroomUrl:a}))},"aria-label":"Compress context (Headroom)"})]}),children:_.installed&&(0,t.jsxs)("div",{className:m().extras,children:[(0,t.jsxs)("div",{className:m().extrasHeader,children:[(0,t.jsxs)("span",{className:m().extrasMeta,children:["Compression extras",w.version?` \xb7 v${w.version}`:""]}),H.length>0&&(0,t.jsx)(i.$n,{size:"sm",variant:"contrast",onClick:eT,disabled:P,loading:P,children:`Install [proxy,${H.join(",")}]`})]}),(0,t.jsx)("div",{className:m().chips,children:w.available.map(e=>{let a=!!w.extras[e],s=H.includes(e),l="code"===e?"tree-sitter AST compression for code responses":"Kompress-v2 HF model for prose/agentic traces (~+1GB)";if(a){let a="code"===e?z:F;return(0,t.jsxs)("div",{className:m().chip,"data-installed":"true",title:l,children:[(0,t.jsx)(i.lM,{size:"sm",checked:a,disabled:K,onChange:()=>eM(e,!a),"aria-label":`${a?"Disable":"Enable"} [${e}]`}),(0,t.jsxs)("span",{children:["[",e,"]"]}),(0,t.jsx)("button",{type:"button",onClick:()=>eR(e),disabled:I===e,className:m().uninstall,title:`Uninstall [${e}]`,children:I===e?"Uninstalling…":"Uninstall"})]},e)}return(0,t.jsxs)("label",{className:m().chip,"data-selected":s?"true":"false",title:l,children:[(0,t.jsx)("input",{type:"checkbox",checked:s,onChange:()=>{L(a=>a.includes(e)?a.filter(a=>a!==e):[...a,e])}}),(0,t.jsxs)("span",{children:["[",e,"]"]}),(0,t.jsx)("span",{className:m().chipNote,children:"not installed"})]},e)})}),R&&(0,t.jsx)("p",{className:m().notice,children:R}),K&&(0,t.jsx)("p",{className:m().progressNote,children:"Restarting proxy…"}),(P||I)&&O&&(0,t.jsx)("pre",{className:m().installLog,children:O}),(0,t.jsxs)("p",{className:m().extrasHelp,children:["Installing adds the package; use ",(0,t.jsx)("code",{children:"on"}),"/",(0,t.jsx)("code",{children:"off"})," to activate it (restarts the proxy). Default install is ",(0,t.jsx)("code",{children:"[proxy]"})," only (SmartCrusher for JSON). Adding ",(0,t.jsx)("code",{children:"[code]"})," enables AST compression (Python/JS/TS/Go/Rust/Java/C/C++/Perl). Adding ",(0,t.jsx)("code",{children:"[ml]"})," enables the Kompress-v2 HF model for prose/agentic traces but adds ~1 GB (torch + huggingface-hub)."]})]})}),(0,t.jsx)(u,{icon:"record_voice_over",title:"Compress LLM output",doc:"Caveman",docHref:"https://github.com/JuliusBrussee/caveman",active:X,description:"Terse-style system prompt → ~65% fewer output tokens (up to 87%)",control:(0,t.jsxs)(t.Fragment,{children:[X&&(0,t.jsxs)("div",{className:m().levels,children:[(0,t.jsx)(i.Iz,{options:eG,value:Y,onChange:e=>{Q(e),ek({cavemanLevel:e})},size:"sm","aria-label":"Caveman compression level"}),(0,t.jsx)("p",{className:m().levelHint,children:d.ev.find(e=>e.id===Y)?.desc})]}),(0,t.jsx)(i.lM,{checked:X,onChange:()=>{var e;q(e=!X),ek({cavemanEnabled:e})},"aria-label":"Compress LLM output (Caveman)"})]})}),(0,t.jsx)(u,{icon:"code",title:"Lazy senior dev",doc:"Ponytail",docHref:"https://github.com/DietrichGebert/ponytail",active:V,description:"Bias the model toward minimal code: YAGNI, reuse stdlib, deletion over addition",control:(0,t.jsxs)(t.Fragment,{children:[V&&(0,t.jsxs)("div",{className:m().levels,children:[(0,t.jsx)(i.Iz,{options:eX,value:ee,onChange:e=>{ea(e),ek({ponytailLevel:e})},size:"sm","aria-label":"Ponytail level"}),(0,t.jsx)("p",{className:m().levelHint,children:d.Nv.find(e=>e.id===ee)?.desc})]}),(0,t.jsx)(i.lM,{checked:V,onChange:()=>{var e;Z(e=!V),ek({ponytailEnabled:e})},"aria-label":"Lazy senior dev (Ponytail)"})]})}),!1]}),(0,t.jsx)(i.aF,{className:m().dialog,isOpen:y,title:eU?"Headroom":"Setup Headroom",onClose:()=>k(!1),children:(0,t.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,t.jsxs)("div",{className:m().statusRow,children:[(0,t.jsx)("span",{children:"Status"}),(0,t.jsx)(r.A,{variant:eF,children:eA})]}),eU&&(0,t.jsx)("a",{href:"/api/headroom/proxy/dashboard",target:"_blank",rel:"noreferrer",className:m().linkButton,children:"Open Headroom Dashboard"}),(0,t.jsx)(i.pd,{label:"Proxy URL",value:x,onChange:e=>v(e.target.value),onBlur:eC,placeholder:"http://localhost:8787",hint:"Use a local proxy for Start/Stop, or an external Docker sidecar like http://headroom:8787.",inputClassName:"font-mono text-xs"}),(0,t.jsx)(i.pd,{label:"Timeout (ms)",value:String(g),onChange:e=>f(e.target.value),onBlur:()=>{let e=Math.round(Number(g)),a=Number.isFinite(e)&&e>0?e:3e3;f(a),ek({headroomTimeoutMs:a})},placeholder:"3000",hint:"Request timeout in milliseconds. Defaults to 3000 ms.",inputClassName:"font-mono text-xs"}),eB?(0,t.jsx)(i.$n,{onClick:ew,variant:"ghost",fullWidth:!0,disabled:b,children:b?"Stopping…":"Stop Headroom"}):eU?(0,t.jsx)("p",{className:m().progressNote,children:"Headroom proxy is reachable. You can enable the token saver."}):ez?(0,t.jsx)(i.$n,{onClick:eS,variant:"contrast",fullWidth:!0,disabled:b,children:b?"Starting…":"Start Headroom"}):eD?_.python?(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,t.jsx)("p",{className:m().fieldLabel,children:"Install then click Start"}),(0,t.jsxs)("div",{className:m().installCommand,children:[(0,t.jsx)("code",{className:"flex-1",children:p}),(0,t.jsx)(i.$n,{size:"sm",variant:"secondary",onClick:()=>e_(p),children:ef?"Copied":"Copy"})]})]}):(0,t.jsx)("p",{className:m().notice,children:"Python ≥ 3.10 required for local managed mode. Install Python first, or use an external proxy URL."}):(0,t.jsx)("p",{className:m().notice,children:"Start Headroom separately at the configured URL, then recheck."}),N&&(0,t.jsx)("p",{className:m().notice,children:N}),(0,t.jsxs)("div",{className:"flex gap-2",children:[(0,t.jsx)(i.$n,{onClick:()=>eN(),variant:"ghost",fullWidth:!0,children:"Recheck"}),(0,t.jsx)(i.$n,{onClick:()=>k(!1),variant:"contrast",fullWidth:!0,children:"Done"})]})]})}),(0,t.jsx)(i.aF,{className:m().dialog,isOpen:!1,title:ei.installed?"PXPIPE":"Setup PXPIPE",onClose:()=>eh(!1),children:(0,t.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,t.jsx)("p",{className:m().description,children:"Compress prompts using multimodal encoding. Runs in-process — no extra server or environment variables required."}),(0,t.jsxs)("div",{className:m().statusRow,children:[(0,t.jsx)("span",{children:"Status"}),(0,t.jsxs)(r.A,{variant:eK||ei.running?"success":"warning",children:[eW,ei.version?` \xb7 v${ei.version}`:""]})]}),eo?.checks?.length>0&&(0,t.jsxs)("div",{className:m().extras,children:[(0,t.jsx)("p",{className:m().fieldLabel,children:"Health check"}),(0,t.jsx)("div",{className:"flex flex-col gap-1",children:eo.checks.map(e=>(0,t.jsxs)("div",{className:m().statusRow,children:[(0,t.jsx)(r.A,{variant:e.ok?"success":"warning",dot:!1,children:e.label}),e.detail&&(0,t.jsx)("span",{className:`${m().extrasMeta} truncate max-w-[50%]`,children:e.detail})]},e.id))}),eo.error&&(0,t.jsx)("p",{className:m().notice,children:eo.error})]}),ei.installed?(0,t.jsxs)("div",{className:"grid grid-cols-2 gap-2",children:[ei.running?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(i.$n,{onClick:()=>eO("restart"),variant:"ghost",disabled:em,children:"Restart"}),(0,t.jsx)(i.$n,{onClick:()=>eO("stop"),variant:"ghost",disabled:em,children:"Stop"})]}):(0,t.jsx)(i.$n,{onClick:()=>eO("start"),variant:"contrast",disabled:em,children:em?"Starting…":"Start"}),(0,t.jsx)(i.$n,{onClick:()=>eO("install"),variant:"ghost",disabled:em,children:"Repair"}),(0,t.jsx)("a",{href:"/dashboard/pxpipe#logs",className:`${m().linkButton} col-span-2`,children:"Open Logs"})]}):(0,t.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,t.jsx)("p",{className:m().notice,children:"PXPIPE is not installed."}),(0,t.jsx)(i.$n,{onClick:()=>eO("install"),variant:"contrast",fullWidth:!0,disabled:em||ei.installing,children:em||ei.installing?"Installing…":"Install"}),(0,t.jsxs)("p",{className:m().description,children:["Installs the npm package ",(0,t.jsx)("code",{className:m().hintCode,children:"pxpipe-proxy"})," into the 9Router data directory. May take a few minutes."]})]}),(0,t.jsx)(i.pd,{label:"Minimum prompt size (chars)",value:String(el),onChange:e=>en(e.target.value),onBlur:()=>{let e=Math.max(0,Number(el)||25e3);en(e),ek({pxpipeMinChars:e})},placeholder:"25000",hint:"Requests smaller than this bypass PXPIPE and are sent as-is.",inputClassName:"font-mono text-xs"}),eu&&(0,t.jsx)("p",{className:m().notice,children:eu}),(0,t.jsxs)("div",{className:"flex gap-2",children:[(0,t.jsx)(i.$n,{onClick:()=>eI().then(e$),variant:"ghost",fullWidth:!0,children:"Recheck"}),(0,t.jsx)(i.$n,{onClick:()=>eh(!1),variant:"contrast",fullWidth:!0,children:"Done"})]})]})}),(0,t.jsx)(i.uo,{className:m().dialog,isOpen:!!A,onClose:()=>D(null),onConfirm:()=>{let e=A?.onConfirm;D(null),e?.()},title:A?.title,message:A?.message,confirmText:A?.confirmText,variant:A?.variant})]})}},96091:e=>{e.exports={page:"token-saver_page__79V8u usage_page__TfrVH DashboardControls_formScope__ID02o",header:"token-saver_header__Qk3iN usage_header__Pj5rE",description:"token-saver_description__WdRoO usage_description___N7_0",section:"token-saver_section__UHCch usage_section__Q1FLM",sectionHeader:"token-saver_sectionHeader__s_oJS usage_sectionHeader__ikyc_",sectionDescription:"token-saver_sectionDescription__JPhfC usage_sectionDescription__hUHjE",dialog:"token-saver_dialog___IKgp DashboardControls_dialog__YyPS4",inset:"token-saver_inset__biEJH usage_inset__ua4iZ",fieldLabel:"token-saver_fieldLabel__0zEKO usage_fieldLabel__QyUjE",summary:"token-saver_summary__WL02H",strategy:"token-saver_strategy__SOcTp",strategyHeader:"token-saver_strategyHeader__2JL_c",identity:"token-saver_identity__nhMJs",titleLine:"token-saver_titleLine__rRvzO",title:"token-saver_title__9opCy",docLink:"token-saver_docLink__Kfjx_",metadata:"token-saver_metadata__ktGrx",actions:"token-saver_actions__xqMmb",levels:"token-saver_levels__J1_s1",levelHint:"token-saver_levelHint__GXnJL",extras:"token-saver_extras__eedyn",extrasHeader:"token-saver_extrasHeader__E7uTh",extrasMeta:"token-saver_extrasMeta__VHRl_",chips:"token-saver_chips__tXaAY",chip:"token-saver_chip__n9SqO",chipNote:"token-saver_chipNote__urLM1",uninstall:"token-saver_uninstall__oAeyS",extrasHelp:"token-saver_extrasHelp__uU9VU",installCommand:"token-saver_installCommand__DWC4N",hintCode:"token-saver_hintCode__FXy2E",installLog:"token-saver_installLog__Aug__",notice:"token-saver_notice__YUKZQ",progressNote:"token-saver_progressNote__5mq8C",statusRow:"token-saver_statusRow__sBf3V",linkButton:"token-saver_linkButton__vEGct"}}},e=>{e.O(0,[3493,8679,970,636,2904,6506,8500,3847,1321,705,5497,8441,3794,7358],()=>e(e.s=43407)),_N_E=e.O()}]);
1
+ (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[9839],{15536:(e,a,s)=>{"use strict";s.d(a,{Cp:()=>i,Hx:()=>n,Iv:()=>d,Nv:()=>m,RL:()=>c,ev:()=>h,fl:()=>r,hT:()=>t,oX:()=>l,t6:()=>o});let t=["zh-CN","zh-TW"],l=[{icon:"public",title:"Access Anywhere",desc:"Use your API from any network"},{icon:"group",title:"Share Endpoint",desc:"Share URL with team members"},{icon:"code",title:"Use in Cursor/Cline",desc:"Connect AI tools remotely"},{icon:"lock",title:"Encrypted",desc:"End-to-end TLS via Cloudflare"}],n=2e3,i=3e5,r=5e3,o=5,c=1e4,d=5e3,h=[{id:"lite",label:"Lite",desc:"Drop filler, keep grammar"},{id:"full",label:"Full",desc:"Drop articles, fragments OK"},{id:"ultra",label:"Ultra",desc:"Telegraphic, max compression"},{id:"wenyan-lite",label:"文 Lite",desc:"Classical Chinese, light compression",wenyan:!0},{id:"wenyan",label:"文 Full",desc:"Maximum 文言文, 80-90% reduction",wenyan:!0},{id:"wenyan-ultra",label:"文 Ultra",desc:"Extreme classical compression",wenyan:!0}],m=[{id:"lite",label:"Lite",desc:"Build asked, name lazier option"},{id:"full",label:"Full",desc:"Ladder enforced: stdlib/native first"},{id:"ultra",label:"Ultra",desc:"YAGNI extremist, deletion first"}]},43407:(e,a,s)=>{Promise.resolve().then(s.bind(s,61203))},61203:(e,a,s)=>{"use strict";s.d(a,{default:()=>x});var t=s(95155),l=s(96439),n=s(12115),i=s(35497),r=s(66119),o=s(11059),c=s(73006),d=s(15536),h=s(96091),m=s.n(h);let p='pip install "headroom-ai[proxy]"';function u({icon:e,title:a,doc:s,docHref:n,active:i,description:o,control:c,children:d}){return(0,t.jsxs)("div",{className:m().strategy,children:[(0,t.jsxs)("div",{className:m().strategyHeader,children:[(0,t.jsxs)("div",{className:m().identity,children:[(0,t.jsx)(l.default,{className:"shrink-0 text-[16px] text-[var(--text-2)]",children:e}),(0,t.jsxs)("div",{className:"min-w-0",children:[(0,t.jsxs)("div",{className:m().titleLine,children:[(0,t.jsx)("span",{className:m().title,children:a}),(0,t.jsx)("a",{href:n,target:"_blank",rel:"noreferrer",className:m().docLink,children:s}),(0,t.jsx)(r.A,{variant:i?"success":"default",children:i?"Active":"Off"})]}),(0,t.jsx)("p",{className:m().metadata,children:o})]})]}),(0,t.jsx)("div",{className:m().actions,children:c})]}),d]})}function x(){let[e,a]=(0,n.useState)(!0),[s,h]=(0,n.useState)(!1),[x,v]=(0,n.useState)("http://localhost:8787"),[g,f]=(0,n.useState)(3e3),[_,j]=(0,n.useState)({installed:!1,running:!1,python:null,loading:!0}),[y,k]=(0,n.useState)(!1),[b,C]=(0,n.useState)(!1),[N,S]=(0,n.useState)(""),[w,E]=(0,n.useState)({version:null,extras:{code:!1,ml:!1},available:["code","ml"],loading:!1}),[H,L]=(0,n.useState)([]),[P,T]=(0,n.useState)(!1),[R,M]=(0,n.useState)(""),[I,$]=(0,n.useState)(null),[O,U]=(0,n.useState)(""),[A,D]=(0,n.useState)(null),[z,J]=(0,n.useState)(!1),[B,F]=(0,n.useState)(!0),[K,W]=(0,n.useState)(!1),G=(0,n.useRef)(null),[X,q]=(0,n.useState)(!1),[Y,Q]=(0,n.useState)("full"),[V,Z]=(0,n.useState)(!1),[ee,ea]=(0,n.useState)("full"),[es,et]=(0,n.useState)(!1),[el,en]=(0,n.useState)(25e3),[ei,er]=(0,n.useState)({installed:!1,installing:!1,running:!1,version:null,loading:!0}),[eo,ec]=(0,n.useState)(null),[ed,eh]=(0,n.useState)(!1),[em,ep]=(0,n.useState)(!1),[eu,ex]=(0,n.useState)(""),[ev,eg]=(0,n.useState)("en"),{copied:ef,copy:e_}=(0,o.C)();(0,n.useEffect)(()=>(eg((0,c.kk)()),(0,c.oQ)(()=>eg((0,c.kk)()))),[]);let ej=d.hT.includes(ev),ey=ej?d.ev:d.ev.filter(e=>!e.wenyan);(0,n.useEffect)(()=>{let e=d.ev.find(e=>e.id===Y);e?.wenyan&&!ej&&(Q("ultra"),ek({cavemanLevel:"ultra"}))},[ej,Y]);let ek=async e=>{try{await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})}catch(e){console.log("Error updating setting:",e)}},eb=async e=>{try{(await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({rtkEnabled:e})})).ok&&a(e)}catch(e){console.log("Error updating rtkEnabled:",e)}},eC=async()=>{let e=x.trim()||"http://localhost:8787";v(e),await ek({headroomUrl:e}),eN()},eN=(0,n.useCallback)(async()=>{j(e=>({...e,loading:!0}));try{let e=await fetch("/api/headroom/status",{headers:{"Cache-Control":"no-store"}}),a=await e.json();if(j({...a,loading:!1}),!a?.installed){E({version:null,extras:{code:!1,ml:!1},available:["code","ml"],loading:!1}),L([]);return}try{let e=await fetch("/api/headroom/extras",{headers:{"Cache-Control":"no-store"}});if(!e.ok)throw Error("extras status failed");let a=await e.json();E(e=>({...e,version:a.version??null,extras:a.extras||{code:!1,ml:!1},available:a.available||["code","ml"],loading:!1})),L([])}catch{E({version:null,extras:{code:!1,ml:!1},available:["code","ml"],loading:!1}),L([])}}catch{j({installed:!1,running:!1,python:null,loading:!1}),E({version:null,extras:{code:!1,ml:!1},available:["code","ml"],loading:!1}),L([])}},[]),eS=(0,n.useCallback)(async()=>{S(""),C(!0);try{let e=await fetch("/api/headroom/start",{method:"POST"}),a=await e.json().catch(()=>({}));if(!e.ok)throw Error(a.error||"Failed to start proxy");await eN()}catch(e){S(e.message)}finally{C(!1)}},[eN]),ew=(0,n.useCallback)(async()=>{C(!0);try{await fetch("/api/headroom/stop",{method:"POST"}),await eN()}finally{C(!1)}},[eN]),eE=(0,n.useCallback)(()=>{U(""),G.current&&clearInterval(G.current);let e=async()=>{try{let e=await fetch("/api/headroom/extras?log=1",{headers:{"Cache-Control":"no-store"}}),a=await e.json().catch(()=>({}));"string"==typeof a.log&&U(a.log)}catch{}};e(),G.current=setInterval(e,1500)},[]),eH=(0,n.useCallback)(()=>{G.current&&(clearInterval(G.current),G.current=null)},[]);(0,n.useEffect)(()=>()=>eH(),[eH]);let eL=(0,n.useCallback)(async()=>{if(0!==H.length){T(!0),M(""),eE();try{let e=await fetch("/api/headroom/extras",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({extras:H})}),a=await e.json().catch(()=>({}));if(!e.ok)throw Error(a.error||"Install failed");E(e=>({...e,version:a.version??e.version,extras:a.extras||e.extras})),L([])}catch(e){M(e.message)}finally{eH(),T(!1)}}},[H,eE,eH]),eP=(0,n.useCallback)(async e=>{$(e),M(""),eE();try{let a=await fetch("/api/headroom/extras",{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({extras:[e]})}),s=await a.json().catch(()=>({}));if(!a.ok)throw Error(s.error||"Remove failed");E(e=>({...e,version:s.version??e.version,extras:s.extras||e.extras}))}catch(e){M(e.message)}finally{eH(),$(null)}},[eE,eH]),eT=(0,n.useCallback)(()=>{if(0!==H.length){if(H.includes("ml"))return void D({title:"Install [ml]",message:"[ml] downloads ~1 GB (torch + huggingface-hub). Continue?",confirmText:"Install",variant:"primary",onConfirm:eL});eL()}},[H,eL]),eR=(0,n.useCallback)(e=>{D({title:`Remove [${e}]`,message:`Remove [${e}] and its packages?`,confirmText:"Remove",variant:"danger",onConfirm:()=>eP(e)})},[eP]),eM=(0,n.useCallback)(async(e,a)=>{if(M(""),"code"===e&&J(a),"ml"===e&&F(a),await ek({["code"===e?"headroomCodeAware":"headroomKompress"]:a}),_.running){W(!0);try{let e=await fetch("/api/headroom/restart",{method:"POST"}),a=await e.json().catch(()=>({}));if(!e.ok)throw Error(a.error||"Restart failed");await eN()}catch(e){M(e.message)}finally{W(!1)}}},[_.running,eN]),eI=(0,n.useCallback)(async()=>{er(e=>({...e,loading:!0}));try{let e=await fetch("/api/pxpipe/status",{headers:{"Cache-Control":"no-store"}}),a=await e.json();er({...a,loading:!1}),"number"==typeof a.minChars&&en(a.minChars)}catch{er({installed:!1,installing:!1,running:!1,version:null,loading:!1})}},[]),e$=(0,n.useCallback)(async()=>{try{let e=await fetch("/api/pxpipe/health",{method:"POST"});ec(await e.json())}catch(e){ec({healthy:!1,checks:[],error:e.message})}},[]),eO=(0,n.useCallback)(async e=>{ex(""),ep(!0);try{let a=await fetch(`/api/pxpipe/${e}`,{method:"POST"}),s=await a.json().catch(()=>({}));if(!a.ok)throw Error(s.error||`PXPIPE ${e} failed`);await eI(),await e$()}catch(e){ex(e.message)}finally{ep(!1)}},[eI,e$]);(0,n.useEffect)(()=>{(async()=>{try{let e=await fetch("/api/settings");if(e.ok){let s=await e.json();a(!1!==s.rtkEnabled),h(!!s.headroomEnabled),v(s.headroomUrl||"http://localhost:8787"),"number"==typeof s.headroomTimeoutMs&&f(s.headroomTimeoutMs),J(!0===s.headroomCodeAware),F(!1!==s.headroomKompress),q(!!s.cavemanEnabled),Q(s.cavemanLevel||"full"),Z(!!s.ponytailEnabled),ea(s.ponytailLevel||"full"),et(!!s.pxpipeEnabled),"number"==typeof s.pxpipeMinChars&&en(s.pxpipeMinChars),eN(),eI().then(e$)}}catch{}})()},[eN,eI,e$]);let eU=!!_.running,eA=_.loading?"Checking…":eU?"Running":!1===_.localUrl||_.installed?!1!==_.localUrl?"Stopped":"External":"Not installed",eD=!1!==_.localUrl,ez=!!_.canStart,eJ=eD&&!!_.managedPid,eB=_.loading?"default":eU?"success":"warning",eF=eD&&(eU||ez||!_.installed),eK=eo?.healthy===!0,eW=ei.loading?"Checking…":ei.installing?"Installing…":ei.installed?eK?"Healthy":ei.running?"Running":"Stopped":"Not installed",eG=(0,n.useMemo)(()=>ey.map(e=>({value:e.id,label:e.label,title:e.desc})),[ey]),eX=(0,n.useMemo)(()=>d.Nv.map(e=>({value:e.id,label:e.label,title:e.desc})),[]),eq=[e,s,X,V].filter(Boolean).length;return(0,t.jsxs)("div",{className:`dashboard-surface ${m().page}`,children:[(0,t.jsxs)("header",{className:m().header,children:[(0,t.jsxs)("div",{className:"min-w-0",children:[(0,t.jsxs)("h1",{className:"ui-eyebrow flex items-center gap-2",children:[(0,t.jsx)(l.default,{className:"text-[16px]",children:"bolt"})," Token Saver"]}),(0,t.jsx)("p",{className:m().description,children:"Request-time compression that cuts prompt and completion tokens before they reach the model"})]}),(0,t.jsx)("div",{className:m().summary,children:(0,t.jsxs)(r.A,{variant:eq>0?"success":"default",children:[eq," of 4 strategies active"]})})]}),(0,t.jsxs)("section",{className:`ui-card ${m().section}`,"aria-labelledby":"token-saver-strategies-heading",children:[(0,t.jsx)("div",{className:m().sectionHeader,children:(0,t.jsxs)("div",{className:"min-w-0",children:[(0,t.jsxs)("h2",{id:"token-saver-strategies-heading",className:"ui-eyebrow flex items-center gap-2",children:[(0,t.jsx)(l.default,{className:"text-[16px]",children:"list_alt"})," Strategies"]}),(0,t.jsx)("p",{className:m().sectionDescription,children:"Each strategy is applied independently. Changes save immediately."})]})}),(0,t.jsx)(u,{icon:"bolt",title:"Compress tool output",doc:"RTK",docHref:"https://github.com/rtk-ai/rtk",active:e,description:"git/grep/ls/tree/logs → 60-90% fewer input tokens",control:(0,t.jsx)(i.lM,{checked:e,onChange:()=>eb(!e),"aria-label":"Compress tool output (RTK)"})}),(0,t.jsx)(u,{icon:"layers",title:"Compress context",doc:"Headroom",docHref:"https://github.com/chopratejas/headroom",active:s,description:"Compress prompts via /v1/compress before routing to the model",control:(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(r.A,{variant:eB,children:eA}),eF&&(0,t.jsx)(i.$n,{variant:"secondary",size:"sm",onClick:()=>k(!0),children:eU?"Manage":"Setup"}),(0,t.jsx)(i.lM,{checked:s,onChange:()=>{var e;let a;return e=!s,void(v(a=x.trim()||"http://localhost:8787"),h(e),ek({headroomEnabled:e,headroomUrl:a}))},"aria-label":"Compress context (Headroom)"})]}),children:_.installed&&(0,t.jsxs)("div",{className:m().extras,children:[(0,t.jsxs)("div",{className:m().extrasHeader,children:[(0,t.jsxs)("span",{className:m().extrasMeta,children:["Compression extras",w.version?` \xb7 v${w.version}`:""]}),H.length>0&&(0,t.jsx)(i.$n,{size:"sm",variant:"contrast",onClick:eT,disabled:P,loading:P,children:`Install [proxy,${H.join(",")}]`})]}),(0,t.jsx)("div",{className:m().chips,children:w.available.map(e=>{let a=!!w.extras[e],s=H.includes(e),l="code"===e?"tree-sitter AST compression for code responses":"Kompress-v2 HF model for prose/agentic traces (~+1GB)";if(a){let a="code"===e?z:B;return(0,t.jsxs)("div",{className:m().chip,"data-installed":"true",title:l,children:[(0,t.jsx)(i.lM,{size:"sm",checked:a,disabled:K,onChange:()=>eM(e,!a),"aria-label":`${a?"Disable":"Enable"} [${e}]`}),(0,t.jsxs)("span",{children:["[",e,"]"]}),(0,t.jsx)("button",{type:"button",onClick:()=>eR(e),disabled:I===e,className:m().uninstall,title:`Uninstall [${e}]`,children:I===e?"Uninstalling…":"Uninstall"})]},e)}return(0,t.jsxs)("label",{className:m().chip,"data-selected":s?"true":"false",title:l,children:[(0,t.jsx)("input",{type:"checkbox",checked:s,onChange:()=>{L(a=>a.includes(e)?a.filter(a=>a!==e):[...a,e])}}),(0,t.jsxs)("span",{children:["[",e,"]"]}),(0,t.jsx)("span",{className:m().chipNote,children:"not installed"})]},e)})}),R&&(0,t.jsx)("p",{className:m().notice,children:R}),K&&(0,t.jsx)("p",{className:m().progressNote,children:"Restarting proxy…"}),(P||I)&&O&&(0,t.jsx)("pre",{className:m().installLog,children:O}),(0,t.jsxs)("p",{className:m().extrasHelp,children:["Installing adds the package; use ",(0,t.jsx)("code",{children:"on"}),"/",(0,t.jsx)("code",{children:"off"})," to activate it (restarts the proxy). Default install is ",(0,t.jsx)("code",{children:"[proxy]"})," only (SmartCrusher for JSON). Adding ",(0,t.jsx)("code",{children:"[code]"})," enables AST compression (Python/JS/TS/Go/Rust/Java/C/C++/Perl). Adding ",(0,t.jsx)("code",{children:"[ml]"})," enables the Kompress-v2 HF model for prose/agentic traces but adds ~1 GB (torch + huggingface-hub)."]})]})}),(0,t.jsx)(u,{icon:"record_voice_over",title:"Compress LLM output",doc:"Caveman",docHref:"https://github.com/JuliusBrussee/caveman",active:X,description:"Terse-style system prompt → ~65% fewer output tokens (up to 87%)",control:(0,t.jsxs)(t.Fragment,{children:[X&&(0,t.jsxs)("div",{className:m().levels,children:[(0,t.jsx)(i.Iz,{options:eG,value:Y,onChange:e=>{Q(e),ek({cavemanLevel:e})},size:"sm","aria-label":"Caveman compression level"}),(0,t.jsx)("p",{className:m().levelHint,children:d.ev.find(e=>e.id===Y)?.desc})]}),(0,t.jsx)(i.lM,{checked:X,onChange:()=>{var e;q(e=!X),ek({cavemanEnabled:e})},"aria-label":"Compress LLM output (Caveman)"})]})}),(0,t.jsx)(u,{icon:"code",title:"Lazy senior dev",doc:"Ponytail",docHref:"https://github.com/DietrichGebert/ponytail",active:V,description:"Bias the model toward minimal code: YAGNI, reuse stdlib, deletion over addition",control:(0,t.jsxs)(t.Fragment,{children:[V&&(0,t.jsxs)("div",{className:m().levels,children:[(0,t.jsx)(i.Iz,{options:eX,value:ee,onChange:e=>{ea(e),ek({ponytailLevel:e})},size:"sm","aria-label":"Ponytail level"}),(0,t.jsx)("p",{className:m().levelHint,children:d.Nv.find(e=>e.id===ee)?.desc})]}),(0,t.jsx)(i.lM,{checked:V,onChange:()=>{var e;Z(e=!V),ek({ponytailEnabled:e})},"aria-label":"Lazy senior dev (Ponytail)"})]})}),!1]}),(0,t.jsx)(i.aF,{className:m().dialog,isOpen:y,title:eU?"Headroom":"Setup Headroom",onClose:()=>k(!1),children:(0,t.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,t.jsxs)("div",{className:m().statusRow,children:[(0,t.jsx)("span",{children:"Status"}),(0,t.jsx)(r.A,{variant:eB,children:eA})]}),eU&&(0,t.jsx)("a",{href:"/api/headroom/proxy/dashboard",target:"_blank",rel:"noreferrer",className:m().linkButton,children:"Open Headroom Dashboard"}),(0,t.jsx)(i.pd,{label:"Proxy URL",value:x,onChange:e=>v(e.target.value),onBlur:eC,placeholder:"http://localhost:8787",hint:"Use a local proxy for Start/Stop, or an external Docker sidecar like http://headroom:8787.",inputClassName:"font-mono text-xs"}),(0,t.jsx)(i.pd,{label:"Timeout (ms)",value:String(g),onChange:e=>f(e.target.value),onBlur:()=>{let e=Math.round(Number(g)),a=Number.isFinite(e)&&e>0?e:3e3;f(a),ek({headroomTimeoutMs:a})},placeholder:"3000",hint:"Request timeout in milliseconds. Defaults to 3000 ms.",inputClassName:"font-mono text-xs"}),eJ?(0,t.jsx)(i.$n,{onClick:ew,variant:"ghost",fullWidth:!0,disabled:b,children:b?"Stopping…":"Stop Headroom"}):eU?(0,t.jsx)("p",{className:m().progressNote,children:"Headroom proxy is reachable. You can enable the token saver."}):ez?(0,t.jsx)(i.$n,{onClick:eS,variant:"contrast",fullWidth:!0,disabled:b,children:b?"Starting…":"Start Headroom"}):eD?_.python?(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,t.jsx)("p",{className:m().fieldLabel,children:"Install then click Start"}),(0,t.jsxs)("div",{className:m().installCommand,children:[(0,t.jsx)("code",{className:"flex-1",children:p}),(0,t.jsx)(i.$n,{size:"sm",variant:"secondary",onClick:()=>e_(p),children:ef?"Copied":"Copy"})]})]}):(0,t.jsx)("p",{className:m().notice,children:"Python ≥ 3.10 required for local managed mode. Install Python first, or use an external proxy URL."}):(0,t.jsx)("p",{className:m().notice,children:"Start Headroom separately at the configured URL, then recheck."}),N&&(0,t.jsx)("p",{className:m().notice,children:N}),(0,t.jsxs)("div",{className:"flex gap-2",children:[(0,t.jsx)(i.$n,{onClick:()=>eN(),variant:"ghost",fullWidth:!0,children:"Recheck"}),(0,t.jsx)(i.$n,{onClick:()=>k(!1),variant:"contrast",fullWidth:!0,children:"Done"})]})]})}),(0,t.jsx)(i.aF,{className:m().dialog,isOpen:!1,title:ei.installed?"PXPIPE":"Setup PXPIPE",onClose:()=>eh(!1),children:(0,t.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,t.jsx)("p",{className:m().description,children:"Compress prompts using multimodal encoding. Runs in-process — no extra server or environment variables required."}),(0,t.jsxs)("div",{className:m().statusRow,children:[(0,t.jsx)("span",{children:"Status"}),(0,t.jsxs)(r.A,{variant:eK||ei.running?"success":"warning",children:[eW,ei.version?` \xb7 v${ei.version}`:""]})]}),eo?.checks?.length>0&&(0,t.jsxs)("div",{className:m().extras,children:[(0,t.jsx)("p",{className:m().fieldLabel,children:"Health check"}),(0,t.jsx)("div",{className:"flex flex-col gap-1",children:eo.checks.map(e=>(0,t.jsxs)("div",{className:m().statusRow,children:[(0,t.jsx)(r.A,{variant:e.ok?"success":"warning",dot:!1,children:e.label}),e.detail&&(0,t.jsx)("span",{className:`${m().extrasMeta} truncate max-w-[50%]`,children:e.detail})]},e.id))}),eo.error&&(0,t.jsx)("p",{className:m().notice,children:eo.error})]}),ei.installed?(0,t.jsxs)("div",{className:"grid grid-cols-2 gap-2",children:[ei.running?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(i.$n,{onClick:()=>eO("restart"),variant:"ghost",disabled:em,children:"Restart"}),(0,t.jsx)(i.$n,{onClick:()=>eO("stop"),variant:"ghost",disabled:em,children:"Stop"})]}):(0,t.jsx)(i.$n,{onClick:()=>eO("start"),variant:"contrast",disabled:em,children:em?"Starting…":"Start"}),(0,t.jsx)(i.$n,{onClick:()=>eO("install"),variant:"ghost",disabled:em,children:"Repair"}),(0,t.jsx)("a",{href:"/dashboard/pxpipe#logs",className:`${m().linkButton} col-span-2`,children:"Open Logs"})]}):(0,t.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,t.jsx)("p",{className:m().notice,children:"PXPIPE is not installed."}),(0,t.jsx)(i.$n,{onClick:()=>eO("install"),variant:"contrast",fullWidth:!0,disabled:em||ei.installing,children:em||ei.installing?"Installing…":"Install"}),(0,t.jsxs)("p",{className:m().description,children:["Installs the npm package ",(0,t.jsx)("code",{className:m().hintCode,children:"pxpipe-proxy"})," into the JRouter data directory. May take a few minutes."]})]}),(0,t.jsx)(i.pd,{label:"Minimum prompt size (chars)",value:String(el),onChange:e=>en(e.target.value),onBlur:()=>{let e=Math.max(0,Number(el)||25e3);en(e),ek({pxpipeMinChars:e})},placeholder:"25000",hint:"Requests smaller than this bypass PXPIPE and are sent as-is.",inputClassName:"font-mono text-xs"}),eu&&(0,t.jsx)("p",{className:m().notice,children:eu}),(0,t.jsxs)("div",{className:"flex gap-2",children:[(0,t.jsx)(i.$n,{onClick:()=>eI().then(e$),variant:"ghost",fullWidth:!0,children:"Recheck"}),(0,t.jsx)(i.$n,{onClick:()=>eh(!1),variant:"contrast",fullWidth:!0,children:"Done"})]})]})}),(0,t.jsx)(i.uo,{className:m().dialog,isOpen:!!A,onClose:()=>D(null),onConfirm:()=>{let e=A?.onConfirm;D(null),e?.()},title:A?.title,message:A?.message,confirmText:A?.confirmText,variant:A?.variant})]})}},96091:e=>{e.exports={page:"token-saver_page__79V8u usage_page__TfrVH DashboardControls_formScope__ID02o",header:"token-saver_header__Qk3iN usage_header__Pj5rE",description:"token-saver_description__WdRoO usage_description___N7_0",section:"token-saver_section__UHCch usage_section__Q1FLM",sectionHeader:"token-saver_sectionHeader__s_oJS usage_sectionHeader__ikyc_",sectionDescription:"token-saver_sectionDescription__JPhfC usage_sectionDescription__hUHjE",dialog:"token-saver_dialog___IKgp DashboardControls_dialog__YyPS4",inset:"token-saver_inset__biEJH usage_inset__ua4iZ",fieldLabel:"token-saver_fieldLabel__0zEKO usage_fieldLabel__QyUjE",summary:"token-saver_summary__WL02H",strategy:"token-saver_strategy__SOcTp",strategyHeader:"token-saver_strategyHeader__2JL_c",identity:"token-saver_identity__nhMJs",titleLine:"token-saver_titleLine__rRvzO",title:"token-saver_title__9opCy",docLink:"token-saver_docLink__Kfjx_",metadata:"token-saver_metadata__ktGrx",actions:"token-saver_actions__xqMmb",levels:"token-saver_levels__J1_s1",levelHint:"token-saver_levelHint__GXnJL",extras:"token-saver_extras__eedyn",extrasHeader:"token-saver_extrasHeader__E7uTh",extrasMeta:"token-saver_extrasMeta__VHRl_",chips:"token-saver_chips__tXaAY",chip:"token-saver_chip__n9SqO",chipNote:"token-saver_chipNote__urLM1",uninstall:"token-saver_uninstall__oAeyS",extrasHelp:"token-saver_extrasHelp__uU9VU",installCommand:"token-saver_installCommand__DWC4N",hintCode:"token-saver_hintCode__FXy2E",installLog:"token-saver_installLog__Aug__",notice:"token-saver_notice__YUKZQ",progressNote:"token-saver_progressNote__5mq8C",statusRow:"token-saver_statusRow__sBf3V",linkButton:"token-saver_linkButton__vEGct"}}},e=>{e.O(0,[3493,8679,970,636,2904,6506,8500,3847,1321,705,5497,8441,3794,7358],()=>e(e.s=43407)),_N_E=e.O()}]);