n9router 0.3.99 → 0.4.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.
- package/.next/standalone/.next/BUILD_ID +1 -1
- package/.next/standalone/.next/app-path-routes-manifest.json +4 -4
- package/.next/standalone/.next/build-manifest.json +2 -2
- package/.next/standalone/.next/prerender-manifest.json +3 -3
- package/.next/standalone/.next/server/app/(dashboard)/dashboard/basic-chat/page_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/(dashboard)/dashboard/cli-tools/page_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/(dashboard)/dashboard/combos/page_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/(dashboard)/dashboard/console-log/page_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/(dashboard)/dashboard/endpoint/page_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/(dashboard)/dashboard/media-providers/[kind]/[id]/page_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/(dashboard)/dashboard/media-providers/[kind]/page_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/(dashboard)/dashboard/mitm/page_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/(dashboard)/dashboard/page_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/(dashboard)/dashboard/profile/page_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/(dashboard)/dashboard/providers/[id]/page_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/(dashboard)/dashboard/providers/new/page_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/(dashboard)/dashboard/providers/page_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/(dashboard)/dashboard/proxy-pools/page_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/(dashboard)/dashboard/quota/page_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/(dashboard)/dashboard/translator/page_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/(dashboard)/dashboard/usage/page_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/_global-error/page_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/_global-error.html +1 -1
- package/.next/standalone/.next/server/app/_global-error.rsc +1 -1
- package/.next/standalone/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/_global-error.segments/_global-error/__PAGE__.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/_global-error.segments/_global-error.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/_not-found.html +1 -1
- package/.next/standalone/.next/server/app/_not-found.rsc +3 -3
- package/.next/standalone/.next/server/app/_not-found.segments/_full.segment.rsc +3 -3
- package/.next/standalone/.next/server/app/_not-found.segments/_head.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/_not-found.segments/_index.segment.rsc +3 -3
- package/.next/standalone/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/_not-found.segments/_not-found.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/_not-found.segments/_tree.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/api/antigravity-tools/import/route.js +1 -1
- package/.next/standalone/.next/server/app/api/antigravity-tools/import-refresh-tokens/route.js +1 -1
- package/.next/standalone/.next/server/app/api/cli-tools/antigravity-mitm/alias/route.js +2 -2
- package/.next/standalone/.next/server/app/api/cli-tools/antigravity-mitm/route.js +1 -1
- package/.next/standalone/.next/server/app/api/cli-tools/claude-settings/route.js +2 -2
- package/.next/standalone/.next/server/app/api/cli-tools/codex-settings/route.js +1 -1
- package/.next/standalone/.next/server/app/api/cli-tools/copilot-settings/route.js +2 -2
- package/.next/standalone/.next/server/app/api/cli-tools/droid-settings/route.js +1 -1
- package/.next/standalone/.next/server/app/api/cli-tools/openclaw-settings/route.js +2 -2
- package/.next/standalone/.next/server/app/api/cli-tools/opencode-settings/route.js +1 -1
- package/.next/standalone/.next/server/app/api/oauth/[provider]/[action]/route.js +1 -1
- package/.next/standalone/.next/server/app/api/providers/[id]/test/route.js +1 -1
- package/.next/standalone/.next/server/app/api/providers/test-batch/route.js +1 -1
- package/.next/standalone/.next/server/app/api/translator/send/route.js +1 -1
- package/.next/standalone/.next/server/app/api/translator/translate/route.js +1 -1
- package/.next/standalone/.next/server/app/api/usage/[connectionId]/route.js +1 -1
- package/.next/standalone/.next/server/app/api/v1/api/chat/route.js +1 -1
- package/.next/standalone/.next/server/app/api/v1/chat/completions/route.js +1 -1
- package/.next/standalone/.next/server/app/api/v1/embeddings/route.js +1 -1
- package/.next/standalone/.next/server/app/api/v1/messages/route.js +1 -1
- package/.next/standalone/.next/server/app/api/v1/responses/route.js +1 -1
- package/.next/standalone/.next/server/app/api/v1beta/models/[...path]/route.js +1 -1
- package/.next/standalone/.next/server/app/api/version/route.js +1 -1
- package/.next/standalone/.next/server/app/callback/page_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/callback.html +1 -1
- package/.next/standalone/.next/server/app/callback.rsc +3 -3
- package/.next/standalone/.next/server/app/callback.segments/_full.segment.rsc +3 -3
- package/.next/standalone/.next/server/app/callback.segments/_head.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/callback.segments/_index.segment.rsc +3 -3
- package/.next/standalone/.next/server/app/callback.segments/_tree.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/callback.segments/callback/__PAGE__.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/callback.segments/callback.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/dashboard/basic-chat.html +1 -1
- package/.next/standalone/.next/server/app/dashboard/basic-chat.rsc +5 -5
- package/.next/standalone/.next/server/app/dashboard/basic-chat.segments/!KGRhc2hib2FyZCk/dashboard/basic-chat/__PAGE__.segment.rsc +2 -2
- package/.next/standalone/.next/server/app/dashboard/basic-chat.segments/!KGRhc2hib2FyZCk/dashboard/basic-chat.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/dashboard/basic-chat.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/dashboard/basic-chat.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
- package/.next/standalone/.next/server/app/dashboard/basic-chat.segments/_full.segment.rsc +5 -5
- package/.next/standalone/.next/server/app/dashboard/basic-chat.segments/_head.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/dashboard/basic-chat.segments/_index.segment.rsc +3 -3
- package/.next/standalone/.next/server/app/dashboard/basic-chat.segments/_tree.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/dashboard/cli-tools.html +1 -1
- package/.next/standalone/.next/server/app/dashboard/cli-tools.rsc +5 -5
- package/.next/standalone/.next/server/app/dashboard/cli-tools.segments/!KGRhc2hib2FyZCk/dashboard/cli-tools/__PAGE__.segment.rsc +2 -2
- package/.next/standalone/.next/server/app/dashboard/cli-tools.segments/!KGRhc2hib2FyZCk/dashboard/cli-tools.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/dashboard/cli-tools.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/dashboard/cli-tools.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
- package/.next/standalone/.next/server/app/dashboard/cli-tools.segments/_full.segment.rsc +5 -5
- package/.next/standalone/.next/server/app/dashboard/cli-tools.segments/_head.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/dashboard/cli-tools.segments/_index.segment.rsc +3 -3
- package/.next/standalone/.next/server/app/dashboard/cli-tools.segments/_tree.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/dashboard/combos.html +1 -1
- package/.next/standalone/.next/server/app/dashboard/combos.rsc +5 -5
- package/.next/standalone/.next/server/app/dashboard/combos.segments/!KGRhc2hib2FyZCk/dashboard/combos/__PAGE__.segment.rsc +2 -2
- package/.next/standalone/.next/server/app/dashboard/combos.segments/!KGRhc2hib2FyZCk/dashboard/combos.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/dashboard/combos.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/dashboard/combos.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
- package/.next/standalone/.next/server/app/dashboard/combos.segments/_full.segment.rsc +5 -5
- package/.next/standalone/.next/server/app/dashboard/combos.segments/_head.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/dashboard/combos.segments/_index.segment.rsc +3 -3
- package/.next/standalone/.next/server/app/dashboard/combos.segments/_tree.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/dashboard/endpoint.html +1 -1
- package/.next/standalone/.next/server/app/dashboard/endpoint.rsc +5 -5
- package/.next/standalone/.next/server/app/dashboard/endpoint.segments/!KGRhc2hib2FyZCk/dashboard/endpoint/__PAGE__.segment.rsc +2 -2
- package/.next/standalone/.next/server/app/dashboard/endpoint.segments/!KGRhc2hib2FyZCk/dashboard/endpoint.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/dashboard/endpoint.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/dashboard/endpoint.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
- package/.next/standalone/.next/server/app/dashboard/endpoint.segments/_full.segment.rsc +5 -5
- package/.next/standalone/.next/server/app/dashboard/endpoint.segments/_head.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/dashboard/endpoint.segments/_index.segment.rsc +3 -3
- package/.next/standalone/.next/server/app/dashboard/endpoint.segments/_tree.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/dashboard/mitm.html +1 -1
- package/.next/standalone/.next/server/app/dashboard/mitm.rsc +5 -5
- package/.next/standalone/.next/server/app/dashboard/mitm.segments/!KGRhc2hib2FyZCk/dashboard/mitm/__PAGE__.segment.rsc +2 -2
- package/.next/standalone/.next/server/app/dashboard/mitm.segments/!KGRhc2hib2FyZCk/dashboard/mitm.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/dashboard/mitm.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/dashboard/mitm.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
- package/.next/standalone/.next/server/app/dashboard/mitm.segments/_full.segment.rsc +5 -5
- package/.next/standalone/.next/server/app/dashboard/mitm.segments/_head.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/dashboard/mitm.segments/_index.segment.rsc +3 -3
- package/.next/standalone/.next/server/app/dashboard/mitm.segments/_tree.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/dashboard/profile.html +1 -1
- package/.next/standalone/.next/server/app/dashboard/profile.rsc +5 -5
- package/.next/standalone/.next/server/app/dashboard/profile.segments/!KGRhc2hib2FyZCk/dashboard/profile/__PAGE__.segment.rsc +2 -2
- package/.next/standalone/.next/server/app/dashboard/profile.segments/!KGRhc2hib2FyZCk/dashboard/profile.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/dashboard/profile.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/dashboard/profile.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
- package/.next/standalone/.next/server/app/dashboard/profile.segments/_full.segment.rsc +5 -5
- package/.next/standalone/.next/server/app/dashboard/profile.segments/_head.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/dashboard/profile.segments/_index.segment.rsc +3 -3
- package/.next/standalone/.next/server/app/dashboard/profile.segments/_tree.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/dashboard/providers/new.html +1 -1
- package/.next/standalone/.next/server/app/dashboard/providers/new.rsc +5 -5
- package/.next/standalone/.next/server/app/dashboard/providers/new.segments/!KGRhc2hib2FyZCk/dashboard/providers/new/__PAGE__.segment.rsc +2 -2
- package/.next/standalone/.next/server/app/dashboard/providers/new.segments/!KGRhc2hib2FyZCk/dashboard/providers/new.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/dashboard/providers/new.segments/!KGRhc2hib2FyZCk/dashboard/providers.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/dashboard/providers/new.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/dashboard/providers/new.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
- package/.next/standalone/.next/server/app/dashboard/providers/new.segments/_full.segment.rsc +5 -5
- package/.next/standalone/.next/server/app/dashboard/providers/new.segments/_head.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/dashboard/providers/new.segments/_index.segment.rsc +3 -3
- package/.next/standalone/.next/server/app/dashboard/providers/new.segments/_tree.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/dashboard/providers.html +1 -1
- package/.next/standalone/.next/server/app/dashboard/providers.rsc +5 -5
- package/.next/standalone/.next/server/app/dashboard/providers.segments/!KGRhc2hib2FyZCk/dashboard/providers/__PAGE__.segment.rsc +2 -2
- package/.next/standalone/.next/server/app/dashboard/providers.segments/!KGRhc2hib2FyZCk/dashboard/providers.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/dashboard/providers.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/dashboard/providers.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
- package/.next/standalone/.next/server/app/dashboard/providers.segments/_full.segment.rsc +5 -5
- package/.next/standalone/.next/server/app/dashboard/providers.segments/_head.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/dashboard/providers.segments/_index.segment.rsc +3 -3
- package/.next/standalone/.next/server/app/dashboard/providers.segments/_tree.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/dashboard/proxy-pools.html +1 -1
- package/.next/standalone/.next/server/app/dashboard/proxy-pools.rsc +5 -5
- package/.next/standalone/.next/server/app/dashboard/proxy-pools.segments/!KGRhc2hib2FyZCk/dashboard/proxy-pools/__PAGE__.segment.rsc +2 -2
- package/.next/standalone/.next/server/app/dashboard/proxy-pools.segments/!KGRhc2hib2FyZCk/dashboard/proxy-pools.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/dashboard/proxy-pools.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/dashboard/proxy-pools.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
- package/.next/standalone/.next/server/app/dashboard/proxy-pools.segments/_full.segment.rsc +5 -5
- package/.next/standalone/.next/server/app/dashboard/proxy-pools.segments/_head.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/dashboard/proxy-pools.segments/_index.segment.rsc +3 -3
- package/.next/standalone/.next/server/app/dashboard/proxy-pools.segments/_tree.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/dashboard/quota.html +2 -2
- package/.next/standalone/.next/server/app/dashboard/quota.rsc +6 -6
- package/.next/standalone/.next/server/app/dashboard/quota.segments/!KGRhc2hib2FyZCk/dashboard/quota/__PAGE__.segment.rsc +3 -3
- package/.next/standalone/.next/server/app/dashboard/quota.segments/!KGRhc2hib2FyZCk/dashboard/quota.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/dashboard/quota.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/dashboard/quota.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
- package/.next/standalone/.next/server/app/dashboard/quota.segments/_full.segment.rsc +6 -6
- package/.next/standalone/.next/server/app/dashboard/quota.segments/_head.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/dashboard/quota.segments/_index.segment.rsc +3 -3
- package/.next/standalone/.next/server/app/dashboard/quota.segments/_tree.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/dashboard/settings/pricing/page_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/dashboard/settings/pricing.html +1 -1
- package/.next/standalone/.next/server/app/dashboard/settings/pricing.rsc +3 -3
- package/.next/standalone/.next/server/app/dashboard/settings/pricing.segments/_full.segment.rsc +3 -3
- package/.next/standalone/.next/server/app/dashboard/settings/pricing.segments/_head.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/dashboard/settings/pricing.segments/_index.segment.rsc +3 -3
- package/.next/standalone/.next/server/app/dashboard/settings/pricing.segments/_tree.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/dashboard/settings/pricing.segments/dashboard/settings/pricing/__PAGE__.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/dashboard/settings/pricing.segments/dashboard/settings/pricing.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/dashboard/settings/pricing.segments/dashboard/settings.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/dashboard/settings/pricing.segments/dashboard.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/dashboard/translator.html +1 -1
- package/.next/standalone/.next/server/app/dashboard/translator.rsc +5 -5
- package/.next/standalone/.next/server/app/dashboard/translator.segments/!KGRhc2hib2FyZCk/dashboard/translator/__PAGE__.segment.rsc +2 -2
- package/.next/standalone/.next/server/app/dashboard/translator.segments/!KGRhc2hib2FyZCk/dashboard/translator.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/dashboard/translator.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/dashboard/translator.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
- package/.next/standalone/.next/server/app/dashboard/translator.segments/_full.segment.rsc +5 -5
- package/.next/standalone/.next/server/app/dashboard/translator.segments/_head.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/dashboard/translator.segments/_index.segment.rsc +3 -3
- package/.next/standalone/.next/server/app/dashboard/translator.segments/_tree.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/dashboard/usage.html +1 -1
- package/.next/standalone/.next/server/app/dashboard/usage.rsc +5 -5
- package/.next/standalone/.next/server/app/dashboard/usage.segments/!KGRhc2hib2FyZCk/dashboard/usage/__PAGE__.segment.rsc +2 -2
- package/.next/standalone/.next/server/app/dashboard/usage.segments/!KGRhc2hib2FyZCk/dashboard/usage.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/dashboard/usage.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/dashboard/usage.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
- package/.next/standalone/.next/server/app/dashboard/usage.segments/_full.segment.rsc +5 -5
- package/.next/standalone/.next/server/app/dashboard/usage.segments/_head.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/dashboard/usage.segments/_index.segment.rsc +3 -3
- package/.next/standalone/.next/server/app/dashboard/usage.segments/_tree.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/dashboard.html +1 -1
- package/.next/standalone/.next/server/app/dashboard.rsc +5 -5
- package/.next/standalone/.next/server/app/dashboard.segments/!KGRhc2hib2FyZCk/dashboard/__PAGE__.segment.rsc +2 -2
- package/.next/standalone/.next/server/app/dashboard.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/dashboard.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
- package/.next/standalone/.next/server/app/dashboard.segments/_full.segment.rsc +5 -5
- package/.next/standalone/.next/server/app/dashboard.segments/_head.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/dashboard.segments/_index.segment.rsc +3 -3
- package/.next/standalone/.next/server/app/dashboard.segments/_tree.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/index.html +1 -1
- package/.next/standalone/.next/server/app/index.rsc +3 -3
- package/.next/standalone/.next/server/app/index.segments/__PAGE__.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/index.segments/_full.segment.rsc +3 -3
- package/.next/standalone/.next/server/app/index.segments/_head.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/index.segments/_index.segment.rsc +3 -3
- package/.next/standalone/.next/server/app/index.segments/_tree.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/landing/page_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/landing.html +1 -1
- package/.next/standalone/.next/server/app/landing.rsc +3 -3
- package/.next/standalone/.next/server/app/landing.segments/_full.segment.rsc +3 -3
- package/.next/standalone/.next/server/app/landing.segments/_head.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/landing.segments/_index.segment.rsc +3 -3
- package/.next/standalone/.next/server/app/landing.segments/_tree.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/landing.segments/landing/__PAGE__.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/landing.segments/landing.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/login/page_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/login.html +1 -1
- package/.next/standalone/.next/server/app/login.rsc +4 -4
- package/.next/standalone/.next/server/app/login.segments/_full.segment.rsc +4 -4
- package/.next/standalone/.next/server/app/login.segments/_head.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/login.segments/_index.segment.rsc +3 -3
- package/.next/standalone/.next/server/app/login.segments/_tree.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/login.segments/login/__PAGE__.segment.rsc +2 -2
- package/.next/standalone/.next/server/app/login.segments/login.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/page_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app-paths-manifest.json +4 -4
- package/.next/standalone/.next/server/chunks/318.js +1 -1
- package/.next/standalone/.next/server/chunks/3646.js +1 -1
- package/.next/standalone/.next/server/chunks/6182.js +4 -4
- package/.next/standalone/.next/server/chunks/7491.js +1 -1
- package/.next/standalone/.next/server/chunks/8220.js +1 -1
- package/.next/standalone/.next/server/chunks/869.js +1 -1
- package/.next/standalone/.next/server/chunks/9609.js +1 -1
- package/.next/standalone/.next/server/middleware-build-manifest.js +1 -1
- package/.next/standalone/.next/server/pages/404.html +1 -1
- package/.next/standalone/.next/server/pages/500.html +1 -1
- package/.next/standalone/.next/server/server-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/server-reference-manifest.json +1 -1
- package/.next/standalone/.next/static/chunks/{1321-a1aa9f7980d68e31.js → 1321-835e375749d721a9.js} +1 -1
- package/.next/{static/chunks/5507-ee4bdb0d72f2bf5a.js → standalone/.next/static/chunks/5507-fb71a0c2e754e069.js} +2 -2
- package/.next/standalone/mitm/dns/dnsConfig.js +93 -7
- package/.next/standalone/mitm/manager.js +24 -5
- package/.next/standalone/mitm/server.js +3 -4
- package/.next/standalone/mitm/tokenPool.js +20 -59
- package/.next/standalone/package.json +1 -1
- package/.next/standalone/src/mitm/server.js +3 -4
- package/.next/static/chunks/{1321-a1aa9f7980d68e31.js → 1321-835e375749d721a9.js} +1 -1
- package/.next/{standalone/.next/static/chunks/5507-ee4bdb0d72f2bf5a.js → static/chunks/5507-fb71a0c2e754e069.js} +2 -2
- package/bin/n9router.js +117 -1
- package/package.json +1 -1
- /package/.next/standalone/.next/static/{gpb-csizE4h9ZQ3ZXLajG → Z3suC1MLsVxstppcjgL5J}/_buildManifest.js +0 -0
- /package/.next/standalone/.next/static/{gpb-csizE4h9ZQ3ZXLajG → Z3suC1MLsVxstppcjgL5J}/_ssgManifest.js +0 -0
- /package/.next/static/{gpb-csizE4h9ZQ3ZXLajG → Z3suC1MLsVxstppcjgL5J}/_buildManifest.js +0 -0
- /package/.next/static/{gpb-csizE4h9ZQ3ZXLajG → Z3suC1MLsVxstppcjgL5J}/_ssgManifest.js +0 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
"use strict";exports.id=6182,exports.ids=[6182],exports.modules={8578:(a,b,c)=>{let d=c(33873),e=c(29021),f=c(15296),{MITM_DIR:g}=c(82193),h=d.join(g,"rootCA.key"),i=d.join(g,"rootCA.crt");function j(a){try{let b=f.pki.certificateFromPem(e.readFileSync(a,"utf8")),c=new Date(Date.now()+2592e6);return b.validity.notAfter<c}catch{return!0}}a.exports={generateRootCA:async function a(){let a=e.existsSync(h)&&e.existsSync(i);if(a&&!j(i))return console.log("✅ Root CA already exists"),{key:h,cert:i};if(a){console.log("\uD83D\uDD10 Root CA expired or expiring soon — regenerating...");try{e.unlinkSync(h)}catch{}try{e.unlinkSync(i)}catch{}}e.existsSync(g)||e.mkdirSync(g,{recursive:!0}),console.log("\uD83D\uDD10 Generating Root CA certificate...");let b=f.pki.rsa.generateKeyPair(2048),c=f.pki.createCertificate();c.publicKey=b.publicKey,c.serialNumber="01",c.validity.notBefore=new Date,c.validity.notAfter=new Date,c.validity.notAfter.setFullYear(c.validity.notBefore.getFullYear()+10);let d=[{name:"commonName",value:"9Router MITM Root CA"},{name:"organizationName",value:"9Router"},{name:"countryName",value:"US"}];c.setSubject(d),c.setIssuer(d),c.setExtensions([{name:"basicConstraints",cA:!0,critical:!0},{name:"keyUsage",keyCertSign:!0,cRLSign:!0,critical:!0},{name:"subjectKeyIdentifier"}]),c.sign(b.privateKey,f.md.sha256.create());let k=f.pki.privateKeyToPem(b.privateKey),l=f.pki.certificateToPem(c);return e.writeFileSync(h,k),e.writeFileSync(i,l),console.log("✅ Root CA generated successfully"),{key:h,cert:i}},loadRootCA:function(){if(!e.existsSync(h)||!e.existsSync(i))throw Error("Root CA not found. Generate it first.");let a=e.readFileSync(h,"utf8"),b=e.readFileSync(i,"utf8");return{key:f.pki.privateKeyFromPem(a),cert:f.pki.certificateFromPem(b)}},generateLeafCert:function(a,b){let c=f.pki.rsa.generateKeyPair(2048),d=f.pki.createCertificate();return d.publicKey=c.publicKey,d.serialNumber=Math.floor(1e6*Math.random()).toString(),d.validity.notBefore=new Date,d.validity.notAfter=new Date,d.validity.notAfter.setFullYear(d.validity.notBefore.getFullYear()+1),d.setSubject([{name:"commonName",value:a}]),d.setIssuer(b.cert.subject.attributes),d.setExtensions([{name:"basicConstraints",cA:!1},{name:"keyUsage",digitalSignature:!0,keyEncipherment:!0},{name:"extKeyUsage",serverAuth:!0,clientAuth:!0},{name:"subjectAltName",altNames:[{type:2,value:a},{type:2,value:`*.${a}`}]}]),d.sign(b.key,f.md.sha256.create()),{key:f.pki.privateKeyToPem(c.privateKey),cert:f.pki.certificateToPem(d)}},isCertExpired:j,ROOT_CA_CERT_PATH:i,ROOT_CA_KEY_PATH:h}},9631:(a,b,c)=>{let d=c(29021),e=c(55511),{exec:f,execFileSync:g}=c(79646),{execWithPassword:h,isSudoAvailable:i}=c(66936),{log:j,err:k}=c(87777),l="win32"===process.platform,m="darwin"===process.platform,n="/usr/local/share/ca-certificates",o="/usr/bin/security";function p(){if("linux"!==process.platform)return!1;try{let a=d.readFileSync("/proc/version","utf8").toLowerCase();return a.includes("microsoft")||a.includes("wsl")}catch{return!1}}function q(){return l?"certutil":p()?"/mnt/c/Windows/System32/certutil.exe":"certutil"}function r(a){let b=d.readFileSync(a,"utf-8"),c=Buffer.from(b.replace(/-----[^-]+-----/g,"").replace(/\s/g,""),"base64");return e.createHash("sha1").update(c).digest("hex").toUpperCase().match(/.{2}/g).join(":")}async function s(a){var b;let c,e;return l||p()?(c=q(),new Promise(a=>{f(`${c} -store Root "9Router MITM Root CA"`,{windowsHide:!0},b=>{if(!b)return a(!0);f(`${c} -user -store Root "9Router MITM Root CA"`,{windowsHide:!0},b=>{if(!b)return a(!0);let c=p()?"/mnt/c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe":"powershell";f(`${c} -NoProfile -NonInteractive -Command "$m = Get-ChildItem -Path Cert:\\LocalMachine\\Root -ErrorAction SilentlyContinue | Where-Object { $_.Subject -like '*CN=9Router MITM Root CA*' } | Select-Object -First 1; $u = Get-ChildItem -Path Cert:\\CurrentUser\\Root -ErrorAction SilentlyContinue | Where-Object { $_.Subject -like '*CN=9Router MITM Root CA*' } | Select-Object -First 1; if ($m -or $u) { exit 0 } else { exit 1 }"`,{windowsHide:!0},b=>{a(!b)})})})})):m?(b=a,new Promise(a=>{try{if(!d.existsSync(o))return a(!1);let c=r(b).replace(/:/g,"");f(`${o} verify-cert -c "${b}" -p ssl -k /Library/Keychains/System.keychain 2>/dev/null`,b=>{if(!b)return a(!0);f(`${o} dump-trust-settings -d 2>/dev/null | grep -i "${c}"`,(b,c)=>{a(!b&&!!c?.trim())})})}catch{a(!1)}})):(e=`${n}/9router-root-ca.crt`,Promise.resolve(d.existsSync(e)))}async function t(a,b){if(!d.existsSync(o))throw Error("Certificate install failed: macOS Keychain tools not found at /usr/bin/security. Trust the PEM manually or use a full macOS environment.");let c=`${o} delete-certificate -c "9Router MITM Root CA" /Library/Keychains/System.keychain 2>/dev/null || true`,e=`${o} add-trusted-cert -d -r trustRoot -k /Library/Keychains/System.keychain "${b}"`;try{await h(`${c} && ${e}`,a),j("\uD83D\uDD10 Cert: ✅ installed to system keychain")}catch(a){throw Error(a.message?.includes("canceled")?"User canceled authorization":`Certificate install failed: ${a.message||"unknown error"}`)}}async function u(a){let b=q(),c=function(a){if(l)return a;if(p())try{return g("wslpath",["-w",a],{encoding:"utf8"}).trim()}catch(a){throw Error(`Failed to map certificate path for Windows trust: ${a.message}`)}return a}(a),d=p()?"/mnt/c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe":"powershell";return new Promise((a,e)=>{f(`${b} -addstore Root "${c}"`,{windowsHide:!0},(g,h,i)=>{if(!g)return j("\uD83D\uDD10 Cert: ✅ installed to Windows LocalMachine Root store"),a();f(`${b} -user -addstore Root "${c}"`,{windowsHide:!0},(b,g,h)=>{if(!b)return j("\uD83D\uDD10 Cert: ✅ installed to Windows CurrentUser Root store"),a();let k=`Import-Certificate -FilePath '${c.replace(/'/g,"''")}' -CertStoreLocation 'Cert:\\CurrentUser\\Root' | Out-Null`;f(`${d} -NoProfile -NonInteractive -Command "${k}"`,{windowsHide:!0},(b,c,d)=>{if(!b)return j("\uD83D\uDD10 Cert: ✅ installed to Windows CurrentUser Root store (PowerShell)"),a();let f=[i,h,d].filter(Boolean).join(" | ").trim();e(Error(`Failed to install certificate on Windows Root store(s)${f?`: ${f}`:""}`))})})})})}async function v(a,b){let c=r(b).replace(/:/g,""),d=`${o} delete-certificate -Z "${c}" /Library/Keychains/System.keychain`;try{await h(d,a),j("\uD83D\uDD10 Cert: ✅ uninstalled from system keychain")}catch(a){throw Error("Failed to uninstall certificate")}}async function w(){let a=q(),b=p()?"/mnt/c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe":"powershell";return new Promise((c,d)=>{f(`${a} -delstore Root "9Router MITM Root CA"`,{windowsHide:!0},()=>{f(`${a} -user -delstore Root "9Router MITM Root CA"`,{windowsHide:!0},()=>{f(`${b} -NoProfile -NonInteractive -Command "$m = Get-ChildItem -Path Cert:\\LocalMachine\\Root -ErrorAction SilentlyContinue | Where-Object { $_.Subject -like '*CN=9Router MITM Root CA*' }; $u = Get-ChildItem -Path Cert:\\CurrentUser\\Root -ErrorAction SilentlyContinue | Where-Object { $_.Subject -like '*CN=9Router MITM Root CA*' }; $m | Remove-Item -ErrorAction SilentlyContinue; $u | Remove-Item -ErrorAction SilentlyContinue"`,{windowsHide:!0},a=>{if(a)return d(Error(`Failed to uninstall certificate: ${a.message}`));j("\uD83D\uDD10 Cert: ✅ uninstalled from Windows Root store(s)"),c()})})})})}async function x(a,b){if(!i())return void j(`🔐 Cert: cannot install to system store without sudo — trust this file on clients: ${b}`);let c=`${n}/9router-root-ca.crt`,d=`cp "${b}" "${c}" && (update-ca-certificates 2>/dev/null || update-ca-trust 2>/dev/null || true)`;try{await h(d,a),j("\uD83D\uDD10 Cert: ✅ installed to Linux trust store")}catch(a){throw Error(`Certificate install failed: ${a.message||"unknown error"}`)}}async function y(a){if(!i())return;let b=`${n}/9router-root-ca.crt`,c=`rm -f "${b}" && (update-ca-certificates 2>/dev/null || update-ca-trust 2>/dev/null || true)`;try{await h(c,a),j("\uD83D\uDD10 Cert: ✅ uninstalled from Linux trust store")}catch(a){throw Error("Failed to uninstall certificate")}}a.exports={installCert:async function a(a,b){if(!d.existsSync(b))throw Error(`Certificate file not found: ${b}`);await s(b)?j("\uD83D\uDD10 Cert: already trusted ✅"):l||p()?await u(b):m?await t(a,b):await x(a,b)},uninstallCert:async function a(a,b){await s(b)?l||p()?await w():m?await v(a,b):await y(a):j("\uD83D\uDD10 Cert: not found in system store")},checkCertInstalled:s,isWSL:p}},26033:(a,b,c)=>{c(33873),c(29021);let{MITM_DIR:d}=c(82193),{generateRootCA:e,loadRootCA:f,generateLeafCert:g}=c(8578);a.exports={generateCert:async function a(){return await e()},getCertForDomain:function(a){try{let b=f(),c=g(a,b);return{key:c.key,cert:c.cert}}catch(b){return console.error(`Failed to generate cert for ${a}:`,b.message),null}}}},66936:(a,b,c)=>{let{exec:d,spawn:e,execSync:f}=c(79646),g=c(29021),h=c(33873),i=c(21820),{log:j,err:k}=c(87777),l={antigravity:["daily-cloudcode-pa.googleapis.com","cloudcode-pa.googleapis.com"],copilot:["api.individual.githubcopilot.com"],kiro:["q.us-east-1.amazonaws.com","codewhisperer.us-east-1.amazonaws.com"],cursor:["api2.cursor.sh"]},m="win32"===process.platform,n="darwin"===process.platform,o=m?h.join(process.env.SystemRoot||"C:\\Windows","System32","drivers","etc","hosts"):"/etc/hosts";function p(a){return null==a?"":String(a).replace(/\s+/g," ").trim()}function q(a,b={}){let c=[];c.push(b.action||"DNS operation failed"),b.tool&&c.push(`tool=${b.tool}`),b.hostsFile&&c.push(`hostsFile=${b.hostsFile}`),b.hosts&&b.hosts.length&&c.push(`hosts=${b.hosts.join(", ")}`),a?.code&&c.push(`code=${a.code}`),a?.syscall&&c.push(`syscall=${a.syscall}`),a?.path&&c.push(`path=${a.path}`);let d=p(a?.stdout),e=p(a?.stderr),f=p(a?.message);return f&&c.push(`message=${f}`),e&&c.push(`stderr=${e}`),d&&c.push(`stdout=${d}`),c.join(" | ")}function r(){try{f("ipconfig /flushdns",{windowsHide:!0,encoding:"utf8",stdio:["ignore","pipe","pipe"]})}catch(a){throw Error(q(a,{action:"Failed to flush Windows DNS cache"}))}}function s(){if(m)return!1;try{return f("command -v sudo",{stdio:"ignore"}),!0}catch{return!1}}function t(a,b){return new Promise((c,d)=>{let f=s(),g=f?e("sudo",["-S","sh","-c",a],{stdio:["pipe","pipe","pipe"]}):e("sh",["-c",a],{stdio:["ignore","pipe","pipe"]}),h="",i="";g.stdout.on("data",a=>{h+=a}),g.stderr.on("data",a=>{i+=a}),g.on("close",a=>{0===a?c(h):d(Error(i||`Exit code ${a}`))}),f&&(g.stdin.write(`${b}
|
|
2
|
-
`),g.stdin.end())})}async function
|
|
1
|
+
"use strict";exports.id=6182,exports.ids=[6182],exports.modules={8578:(a,b,c)=>{let d=c(33873),e=c(29021),f=c(15296),{MITM_DIR:g}=c(82193),h=d.join(g,"rootCA.key"),i=d.join(g,"rootCA.crt");function j(a){try{let b=f.pki.certificateFromPem(e.readFileSync(a,"utf8")),c=new Date(Date.now()+2592e6);return b.validity.notAfter<c}catch{return!0}}a.exports={generateRootCA:async function a(){let a=e.existsSync(h)&&e.existsSync(i);if(a&&!j(i))return console.log("✅ Root CA already exists"),{key:h,cert:i};if(a){console.log("\uD83D\uDD10 Root CA expired or expiring soon — regenerating...");try{e.unlinkSync(h)}catch{}try{e.unlinkSync(i)}catch{}}e.existsSync(g)||e.mkdirSync(g,{recursive:!0}),console.log("\uD83D\uDD10 Generating Root CA certificate...");let b=f.pki.rsa.generateKeyPair(2048),c=f.pki.createCertificate();c.publicKey=b.publicKey,c.serialNumber="01",c.validity.notBefore=new Date,c.validity.notAfter=new Date,c.validity.notAfter.setFullYear(c.validity.notBefore.getFullYear()+10);let d=[{name:"commonName",value:"9Router MITM Root CA"},{name:"organizationName",value:"9Router"},{name:"countryName",value:"US"}];c.setSubject(d),c.setIssuer(d),c.setExtensions([{name:"basicConstraints",cA:!0,critical:!0},{name:"keyUsage",keyCertSign:!0,cRLSign:!0,critical:!0},{name:"subjectKeyIdentifier"}]),c.sign(b.privateKey,f.md.sha256.create());let k=f.pki.privateKeyToPem(b.privateKey),l=f.pki.certificateToPem(c);return e.writeFileSync(h,k),e.writeFileSync(i,l),console.log("✅ Root CA generated successfully"),{key:h,cert:i}},loadRootCA:function(){if(!e.existsSync(h)||!e.existsSync(i))throw Error("Root CA not found. Generate it first.");let a=e.readFileSync(h,"utf8"),b=e.readFileSync(i,"utf8");return{key:f.pki.privateKeyFromPem(a),cert:f.pki.certificateFromPem(b)}},generateLeafCert:function(a,b){let c=f.pki.rsa.generateKeyPair(2048),d=f.pki.createCertificate();return d.publicKey=c.publicKey,d.serialNumber=Math.floor(1e6*Math.random()).toString(),d.validity.notBefore=new Date,d.validity.notAfter=new Date,d.validity.notAfter.setFullYear(d.validity.notBefore.getFullYear()+1),d.setSubject([{name:"commonName",value:a}]),d.setIssuer(b.cert.subject.attributes),d.setExtensions([{name:"basicConstraints",cA:!1},{name:"keyUsage",digitalSignature:!0,keyEncipherment:!0},{name:"extKeyUsage",serverAuth:!0,clientAuth:!0},{name:"subjectAltName",altNames:[{type:2,value:a},{type:2,value:`*.${a}`}]}]),d.sign(b.key,f.md.sha256.create()),{key:f.pki.privateKeyToPem(c.privateKey),cert:f.pki.certificateToPem(d)}},isCertExpired:j,ROOT_CA_CERT_PATH:i,ROOT_CA_KEY_PATH:h}},9631:(a,b,c)=>{let d=c(29021),e=c(55511),{exec:f,execFileSync:g}=c(79646),{execWithPassword:h,isSudoAvailable:i}=c(66936),{log:j,err:k}=c(87777),l="win32"===process.platform,m="darwin"===process.platform,n="/usr/local/share/ca-certificates",o="/usr/bin/security";function p(){if("linux"!==process.platform)return!1;try{let a=d.readFileSync("/proc/version","utf8").toLowerCase();return a.includes("microsoft")||a.includes("wsl")}catch{return!1}}function q(){return l?"certutil":p()?"/mnt/c/Windows/System32/certutil.exe":"certutil"}function r(a){let b=d.readFileSync(a,"utf-8"),c=Buffer.from(b.replace(/-----[^-]+-----/g,"").replace(/\s/g,""),"base64");return e.createHash("sha1").update(c).digest("hex").toUpperCase().match(/.{2}/g).join(":")}async function s(a){var b;let c,e;return l||p()?(c=q(),new Promise(a=>{f(`${c} -store Root "9Router MITM Root CA"`,{windowsHide:!0},b=>{if(!b)return a(!0);f(`${c} -user -store Root "9Router MITM Root CA"`,{windowsHide:!0},b=>{if(!b)return a(!0);let c=p()?"/mnt/c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe":"powershell";f(`${c} -NoProfile -NonInteractive -Command "$m = Get-ChildItem -Path Cert:\\LocalMachine\\Root -ErrorAction SilentlyContinue | Where-Object { $_.Subject -like '*CN=9Router MITM Root CA*' } | Select-Object -First 1; $u = Get-ChildItem -Path Cert:\\CurrentUser\\Root -ErrorAction SilentlyContinue | Where-Object { $_.Subject -like '*CN=9Router MITM Root CA*' } | Select-Object -First 1; if ($m -or $u) { exit 0 } else { exit 1 }"`,{windowsHide:!0},b=>{a(!b)})})})})):m?(b=a,new Promise(a=>{try{if(!d.existsSync(o))return a(!1);let c=r(b).replace(/:/g,"");f(`${o} verify-cert -c "${b}" -p ssl -k /Library/Keychains/System.keychain 2>/dev/null`,b=>{if(!b)return a(!0);f(`${o} dump-trust-settings -d 2>/dev/null | grep -i "${c}"`,(b,c)=>{a(!b&&!!c?.trim())})})}catch{a(!1)}})):(e=`${n}/9router-root-ca.crt`,Promise.resolve(d.existsSync(e)))}async function t(a,b){if(!d.existsSync(o))throw Error("Certificate install failed: macOS Keychain tools not found at /usr/bin/security. Trust the PEM manually or use a full macOS environment.");let c=`${o} delete-certificate -c "9Router MITM Root CA" /Library/Keychains/System.keychain 2>/dev/null || true`,e=`${o} add-trusted-cert -d -r trustRoot -k /Library/Keychains/System.keychain "${b}"`;try{await h(`${c} && ${e}`,a),j("\uD83D\uDD10 Cert: ✅ installed to system keychain")}catch(a){throw Error(a.message?.includes("canceled")?"User canceled authorization":`Certificate install failed: ${a.message||"unknown error"}`)}}async function u(a){let b=q(),c=function(a){if(l)return a;if(p())try{return g("wslpath",["-w",a],{encoding:"utf8"}).trim()}catch(a){throw Error(`Failed to map certificate path for Windows trust: ${a.message}`)}return a}(a),d=p()?"/mnt/c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe":"powershell";return new Promise((a,e)=>{f(`${b} -addstore Root "${c}"`,{windowsHide:!0},(g,h,i)=>{if(!g)return j("\uD83D\uDD10 Cert: ✅ installed to Windows LocalMachine Root store"),a();f(`${b} -user -addstore Root "${c}"`,{windowsHide:!0},(b,g,h)=>{if(!b)return j("\uD83D\uDD10 Cert: ✅ installed to Windows CurrentUser Root store"),a();let k=`Import-Certificate -FilePath '${c.replace(/'/g,"''")}' -CertStoreLocation 'Cert:\\CurrentUser\\Root' | Out-Null`;f(`${d} -NoProfile -NonInteractive -Command "${k}"`,{windowsHide:!0},(b,c,d)=>{if(!b)return j("\uD83D\uDD10 Cert: ✅ installed to Windows CurrentUser Root store (PowerShell)"),a();let f=[i,h,d].filter(Boolean).join(" | ").trim();e(Error(`Failed to install certificate on Windows Root store(s)${f?`: ${f}`:""}`))})})})})}async function v(a,b){let c=r(b).replace(/:/g,""),d=`${o} delete-certificate -Z "${c}" /Library/Keychains/System.keychain`;try{await h(d,a),j("\uD83D\uDD10 Cert: ✅ uninstalled from system keychain")}catch(a){throw Error("Failed to uninstall certificate")}}async function w(){let a=q(),b=p()?"/mnt/c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe":"powershell";return new Promise((c,d)=>{f(`${a} -delstore Root "9Router MITM Root CA"`,{windowsHide:!0},()=>{f(`${a} -user -delstore Root "9Router MITM Root CA"`,{windowsHide:!0},()=>{f(`${b} -NoProfile -NonInteractive -Command "$m = Get-ChildItem -Path Cert:\\LocalMachine\\Root -ErrorAction SilentlyContinue | Where-Object { $_.Subject -like '*CN=9Router MITM Root CA*' }; $u = Get-ChildItem -Path Cert:\\CurrentUser\\Root -ErrorAction SilentlyContinue | Where-Object { $_.Subject -like '*CN=9Router MITM Root CA*' }; $m | Remove-Item -ErrorAction SilentlyContinue; $u | Remove-Item -ErrorAction SilentlyContinue"`,{windowsHide:!0},a=>{if(a)return d(Error(`Failed to uninstall certificate: ${a.message}`));j("\uD83D\uDD10 Cert: ✅ uninstalled from Windows Root store(s)"),c()})})})})}async function x(a,b){if(!i())return void j(`🔐 Cert: cannot install to system store without sudo — trust this file on clients: ${b}`);let c=`${n}/9router-root-ca.crt`,d=`cp "${b}" "${c}" && (update-ca-certificates 2>/dev/null || update-ca-trust 2>/dev/null || true)`;try{await h(d,a),j("\uD83D\uDD10 Cert: ✅ installed to Linux trust store")}catch(a){throw Error(`Certificate install failed: ${a.message||"unknown error"}`)}}async function y(a){if(!i())return;let b=`${n}/9router-root-ca.crt`,c=`rm -f "${b}" && (update-ca-certificates 2>/dev/null || update-ca-trust 2>/dev/null || true)`;try{await h(c,a),j("\uD83D\uDD10 Cert: ✅ uninstalled from Linux trust store")}catch(a){throw Error("Failed to uninstall certificate")}}a.exports={installCert:async function a(a,b){if(!d.existsSync(b))throw Error(`Certificate file not found: ${b}`);await s(b)?j("\uD83D\uDD10 Cert: already trusted ✅"):l||p()?await u(b):m?await t(a,b):await x(a,b)},uninstallCert:async function a(a,b){await s(b)?l||p()?await w():m?await v(a,b):await y(a):j("\uD83D\uDD10 Cert: not found in system store")},checkCertInstalled:s,isWSL:p}},26033:(a,b,c)=>{c(33873),c(29021);let{MITM_DIR:d}=c(82193),{generateRootCA:e,loadRootCA:f,generateLeafCert:g}=c(8578);a.exports={generateCert:async function a(){return await e()},getCertForDomain:function(a){try{let b=f(),c=g(a,b);return{key:c.key,cert:c.cert}}catch(b){return console.error(`Failed to generate cert for ${a}:`,b.message),null}}}},66936:(a,b,c)=>{let{exec:d,spawn:e,execSync:f}=c(79646),g=c(29021),h=c(33873),i=c(21820),{log:j,err:k}=c(87777),l={antigravity:["daily-cloudcode-pa.googleapis.com","cloudcode-pa.googleapis.com"],copilot:["api.individual.githubcopilot.com"],kiro:["q.us-east-1.amazonaws.com","codewhisperer.us-east-1.amazonaws.com"],cursor:["api2.cursor.sh"]},m="win32"===process.platform,n="darwin"===process.platform,o=m?h.join(process.env.SystemRoot||"C:\\Windows","System32","drivers","etc","hosts"):"/etc/hosts";function p(a){return null==a?"":String(a).replace(/\s+/g," ").trim()}function q(a,b={}){let c=[];c.push(b.action||"DNS operation failed"),b.tool&&c.push(`tool=${b.tool}`),b.hostsFile&&c.push(`hostsFile=${b.hostsFile}`),b.hosts&&b.hosts.length&&c.push(`hosts=${b.hosts.join(", ")}`),a?.code&&c.push(`code=${a.code}`),a?.syscall&&c.push(`syscall=${a.syscall}`),a?.path&&c.push(`path=${a.path}`);let d=p(a?.stdout),e=p(a?.stderr),f=p(a?.message);return f&&c.push(`message=${f}`),e&&c.push(`stderr=${e}`),d&&c.push(`stdout=${d}`),c.join(" | ")}function r(a=o){return`Windows DNS changes require Administrator privileges. Restart 9Router as Administrator so it can update ${a} and flush the DNS cache.`}function s(a,b={}){let c=q(a,b);return(b.isWindows??m)&&(a?.code==="EACCES"||a?.code==="EPERM")?`${c} | hint=${r(b.hostsFile||o)}`:c}function t(){if(!m)return!1;try{return f("net session >nul 2>&1",{windowsHide:!0,stdio:"ignore"}),!0}catch{return!1}}function u(a,b={}){let c=Error(a);return Object.assign(c,b),c}function v(a,b,c){if(m){if(!t())throw u(`${b} blocked | tool=${a} | hostsFile=${o} | reason=process-not-elevated | hint=${r(o)}`,{code:"WINDOWS_ADMIN_REQUIRED",statusCode:403});try{g.accessSync(o,g.constants.R_OK|g.constants.W_OK)}catch(d){throw u(s(d,{action:b,tool:a,hostsFile:o,hosts:c}),{code:d?.code==="EACCES"||d?.code==="EPERM"?"WINDOWS_ADMIN_REQUIRED":d?.code,statusCode:d?.code==="EACCES"||d?.code==="EPERM"?403:500})}}}function w(a,b){let c=l[a]||[],d=g.readFileSync(o,"utf8");if(c.every(a=>d.includes(a))!==b)throw u(`DNS verification failed | tool=${a} | hostsFile=${o} | expected=${b?"present":"absent"} | hosts=${c.join(", ")}`)}function x(){try{j("\uD83C\uDF10 Windows DNS: flushing resolver cache..."),f("ipconfig /flushdns",{windowsHide:!0,encoding:"utf8",stdio:["ignore","pipe","pipe"]}),j("\uD83C\uDF10 Windows DNS: resolver cache flushed")}catch(a){throw u(s(a,{action:"Failed to flush Windows DNS cache",hostsFile:o}),{code:a?.code,statusCode:a?.code==="EACCES"||a?.code==="EPERM"?403:500})}}function y(){if(m)return!1;try{return f("command -v sudo",{stdio:"ignore"}),!0}catch{return!1}}function z(a,b){return new Promise((c,d)=>{let f=y(),g=f?e("sudo",["-S","sh","-c",a],{stdio:["pipe","pipe","pipe"]}):e("sh",["-c",a],{stdio:["ignore","pipe","pipe"]}),h="",i="";g.stdout.on("data",a=>{h+=a}),g.stderr.on("data",a=>{i+=a}),g.on("close",a=>{0===a?c(h):d(Error(i||`Exit code ${a}`))}),f&&(g.stdin.write(`${b}
|
|
2
|
+
`),g.stdin.end())})}async function A(a){m||(n?await z("dscacheutil -flushcache && killall -HUP mDNSResponder",a):await z("resolvectl flush-caches 2>/dev/null || true",a))}function B(a=null){try{let b=g.readFileSync(o,"utf8");if(a)return b.includes(a);return l.antigravity.every(a=>b.includes(a))}catch{return!1}}async function C(a,b){let c=l[a];if(!c)throw Error(`Unknown tool: ${a}`);let d=c.filter(a=>!B(a));if(0===d.length)return void j(`🌐 DNS ${a}: already active`);let e=d.map(a=>`127.0.0.1 ${a}`).join("\n");try{if(j(`🌐 DNS ${a}: enabling (${d.join(", ")})`),m){v(a,"Enable Windows DNS override",d);let b=d.map(a=>`127.0.0.1 ${a}`).join("\r\n")+"\r\n";j(`🌐 DNS ${a}: appending entries to ${o}`),g.appendFileSync(o,b,"utf8"),x(),w(a,!0)}else await z(`echo "${e}" >> ${o}`,b),await A(b);j(`🌐 DNS ${a}: ✅ added ${d.join(", ")} (hosts=${o})`)}catch(c){let b=c.message?.includes("incorrect password")?"Wrong sudo password":s(c,{action:"Failed to add DNS entry",tool:a,hostsFile:o,hosts:d});throw k(`DNS ${a}: add failed — ${b}`),Error(b)}}async function D(a,b){let c=l[a];if(!c)throw Error(`Unknown tool: ${a}`);let d=c.filter(a=>B(a));if(0===d.length)return void j(`🌐 DNS ${a}: already inactive`);try{if(j(`🌐 DNS ${a}: disabling (${d.join(", ")})`),m){v(a,"Disable Windows DNS override",d);let b=g.readFileSync(o,"utf8").split(/\r?\n/).filter(a=>!d.some(b=>a.includes(b))).join("\r\n");j(`🌐 DNS ${a}: rewriting ${o} without ${d.join(", ")}`),g.writeFileSync(o,b,"utf8"),x(),w(a,!1)}else{for(let a of d){let c=n?`sed -i '' '/${a}/d' ${o}`:`sed -i '/${a}/d' ${o}`;await z(c,b)}await A(b)}j(`🌐 DNS ${a}: ✅ removed ${d.join(", ")} (hosts=${o})`)}catch(c){let b=c.message?.includes("incorrect password")?"Wrong sudo password":s(c,{action:"Failed to remove DNS entry",tool:a,hostsFile:o,hosts:d});throw k(`DNS ${a}: remove failed — ${b}`),Error(b)}}async function E(a){for(let b of Object.keys(l))try{await D(b,a)}catch(a){k(`DNS ${b}: failed to remove — ${a.message}`)}}a.exports={TOOL_HOSTS:l,addDNSEntry:C,removeDNSEntry:D,removeAllDNSEntries:E,execWithPassword:z,isSudoAvailable:y,executeElevatedPowerShell:function(a,b=3e4){let c=h.join(i.tmpdir(),`ps_done_${Date.now()}.flag`),e=g.readFileSync(a,"utf8");e+=`
|
|
3
3
|
Set-Content -Path '${c.replace(/'/g,"''")}' -Value 'done' -Encoding UTF8
|
|
4
|
-
`,g.writeFileSync(a,e,"utf8");let f=`Start-Process powershell -ArgumentList '-NoProfile','-ExecutionPolicy','Bypass','-WindowStyle','Hidden','-File','${a.replace(/'/g,"''")}' -Verb RunAs -WindowStyle Hidden`;return new Promise((e,h)=>{let i=!1,j=(a,b)=>{i||(i=!0,a(b))};d(`powershell -NoProfile -NonInteractive -WindowStyle Hidden -Command "${f}"`,{windowsHide:!0},()=>{});let k=Date.now()+b,l=()=>{if(!i){if(g.existsSync(c)){try{g.unlinkSync(c),g.unlinkSync(a)}catch{}return j(e)}if(Date.now()>k){try{g.unlinkSync(a)}catch{}return j(h,Error("Timed out waiting for UAC confirmation"))}setTimeout(l,500)}};setTimeout(l,300)})},checkDNSEntry:
|
|
5
|
-
`),O.stdin.end()):O=e(process.execPath,[L],{detached:!1,stdio:["ignore","pipe","pipe"],env:{...process.env,ROUTER_API_KEY:a,NODE_ENV:"production",MITM_ROUTER_BASE:D}});O&&(P=O.pid,h.writeFileSync(G,String(P)),J=Date.now());let H=null;O&&(O.stdout.on("data",a=>{process.stdout.write(a)}),O.stderr.on("data",a=>{let b=a.toString().trim();b&&(s||!b.includes("Password:")&&!b.includes("password for"))&&(C(b),H=b),!s&&(b.includes("incorrect password")||b.includes("no password was provided"))&&(R(null),Y(),K=!0)}),O.on("exit",b=>{B(`Server exited (code: ${b})`),O=null,P=null;try{h.unlinkSync(G)}catch{}0===b||K||aa(a)}));let I=await function(a=443){return new Promise(b=>{let c=Date.now()+8e3,d=()=>{let e=k.request({hostname:"127.0.0.1",port:a,path:"/_mitm_health",method:"GET",rejectUnauthorized:!1},a=>{let c="";a.on("data",a=>{c+=a}),a.on("end",()=>{try{let a=JSON.parse(c);b(!0===a.ok?{ok:!0,pid:a.pid||null}:null)}catch{b(null)}})});e.on("error",()=>{Date.now()<c?setTimeout(d,500):b(null)}),e.end()};d()})}(443);if(!I){if(O&&!O.killed){try{O.kill()}catch{}O=null}let a=function(){try{if(s){let a=f('powershell -NonInteractive -WindowStyle Hidden -Command "$c = Get-NetTCPConnection -LocalPort 443 -State Listen -ErrorAction SilentlyContinue | Select-Object -First 1; if ($c) { $c.OwningProcess } else { 0 }"',{encoding:"utf8",windowsHide:!0}).trim(),b=parseInt(a,10);if(b&&b>4){let a=f(`tasklist /FI "PID eq ${b}" /FO CSV /NH`,{encoding:"utf8",windowsHide:!0}).match(/"([^"]+)"/);if(a)return a[1].replace(".exe","")}}else{let a=f("lsof -i :443",{encoding:"utf8"}).trim().split("\n");if(a.length>1)return a[1].split(/\s+/)[0]}}catch{}return null}(),b=a?` Port 443 already in use by ${a}.`:"",c=H||`Check sudo password or port 443 access.${b}`;throw Error(`MITM server failed to start. ${c}`)}for(let[a,b]of(W&&await W({mitmCertInstalled:!0}).catch(()=>{}),B(`✅ Server healthy (PID: ${P||I.pid})`),Object.entries(p())))B(`🌐 DNS ${a}: ${b?"✅ active":"❌ inactive"}`);return await X(!0,b),b&&R(b),{running:!0,pid:P}}async function ac(a){K=!0,I=0,B("⏹ Stopping server...");let b=O,d=b&&!b.killed?b.pid:(()=>{try{return parseInt(h.readFileSync(G,"utf-8").trim(),10)}catch{return null}})();if(d&&S(d)&&(B(`Killing server (PID: ${d})...`),T(d,!1,a),await new Promise(a=>setTimeout(a,1e3)),S(d)&&T(d,!0,a)),O=null,P=null,s){let a=g.join(process.env.SystemRoot||"C:\\Windows","System32","drivers","etc","hosts"),b=Object.values(q).flat();try{let d=h.readFileSync(a,"utf8").split(/\r?\n/).filter(a=>!b.some(b=>a.includes(b))).join("\r\n");h.writeFileSync(a,d,"utf8"),c(79646).execSync("ipconfig /flushdns",{windowsHide:!0})}catch(a){C(`Failed to clean hosts: ${a.message}`)}}else await o(a);try{h.unlinkSync(G)}catch{}return await X(!1,null),K=!1,{running:!1,pid:null}}async function ad(a,b){
|
|
4
|
+
`,g.writeFileSync(a,e,"utf8");let f=`Start-Process powershell -ArgumentList '-NoProfile','-ExecutionPolicy','Bypass','-WindowStyle','Hidden','-File','${a.replace(/'/g,"''")}' -Verb RunAs -WindowStyle Hidden`;return new Promise((e,h)=>{let i=!1,j=(a,b)=>{i||(i=!0,a(b))};d(`powershell -NoProfile -NonInteractive -WindowStyle Hidden -Command "${f}"`,{windowsHide:!0},()=>{});let k=Date.now()+b,l=()=>{if(!i){if(g.existsSync(c)){try{g.unlinkSync(c),g.unlinkSync(a)}catch{}return j(e)}if(Date.now()>k){try{g.unlinkSync(a)}catch{}return j(h,Error("Timed out waiting for UAC confirmation"))}setTimeout(l,500)}};setTimeout(l,300)})},checkDNSEntry:B,checkAllDNSStatus:function(){try{let a=g.readFileSync(o,"utf8"),b={};for(let[c,d]of Object.entries(l))b[c]=d.every(b=>a.includes(b));return b}catch{return Object.fromEntries(Object.keys(l).map(a=>[a,!1]))}},buildWindowsAdminHint:r,buildDnsOperationError:s,describeDnsError:q,isWindowsAdmin:t}},82193:(a,b,c)=>{let d=c(33873),e=c(21820),f=c(29021),g=process.env.DATA_DIR?process.env.DATA_DIR:"win32"===process.platform?d.join(process.env.APPDATA||d.join(e.homedir(),"AppData","Roaming"),"n9router"):d.join(e.homedir(),".n9router"),h=d.join(g,"mitm");if("win32"===process.platform)try{let a=d.join(e.homedir(),".n9router","mitm"),b=d.join(h,"rootCA.key"),c=d.join(a,"rootCA.key");!f.existsSync(b)&&f.existsSync(c)&&(f.mkdirSync(h,{recursive:!0}),f.cpSync(a,h,{recursive:!0}))}catch(a){console.error("[n9router mitm] Could not sync MITM from ~/.n9router/mitm:",a.message)}a.exports={DATA_DIR:g,MITM_DIR:h}},87777:a=>{function b(){return new Date().toLocaleTimeString("en-US",{hour12:!1})}a.exports={log:a=>console.log(`[${b()}] [MITM] ${a}`),err:a=>console.error(`[${b()}] ❌ [MITM] ${a}`)}},96182:(a,b,c)=>{let{exec:d,spawn:e,execSync:f}=c(79646),g=c(33873),h=c(29021),i=c(21820),j=c(91645),k=c(55591),l=c(55511),{addDNSEntry:m,removeDNSEntry:n,removeAllDNSEntries:o,checkAllDNSStatus:p,TOOL_HOSTS:q,isSudoAvailable:r}=c(66936),s="win32"===process.platform,t="darwin"===process.platform,{generateCert:u}=c(26033),{installCert:v,uninstallCert:w,checkCertInstalled:x,isWSL:y}=c(9631),{isCertExpired:z}=c(8578),{MITM_DIR:A}=c(82193),{log:B,err:C}=c(87777),D="http://localhost:20128";function E(a){return null==a||""===a?"''":`'${String(a).replace(/'/g,"'\\''")}'`}async function F(){if(!V)return D;try{let a=await V(),b=a&&null!=a.mitmRouterBaseUrl?String(a.mitmRouterBaseUrl).trim():"";if(!b)return D;let c=new URL(b);if("http:"!==c.protocol&&"https:"!==c.protocol)return D;return b.replace(/\/+$/,"")}catch{return D}}let G=g.join(A,".mitm.pid"),H=[5e3,1e4,2e4,3e4,6e4],I=0,J=0,K=!1,L=function(){if(process.env.MITM_SERVER_PATH)return process.env.MITM_SERVER_PATH;let a=g.join(__dirname,"server.js");if(h.existsSync(a))return a;let b=g.join(process.cwd(),"src","mitm","server.js");if(h.existsSync(b))return b;let c=g.join(process.cwd(),"..","src","mitm","server.js");return h.existsSync(c)?c:b}(),M="aes-256-gcm",N="9router-mitm-pwd",O=null,P=null;function Q(){return globalThis.__mitmSudoPassword||null}function R(a){globalThis.__mitmSudoPassword=a}function S(a){try{return process.kill(a,0),!0}catch(a){return"EACCES"===a.code}}function T(a,b=!1,e=null){if(s)d(`taskkill ${b?"/F ":""}/PID ${a}`,{windowsHide:!0},()=>{});else{let f=b?"SIGKILL":"SIGTERM",g=`pkill -${f} -P ${a} 2>/dev/null; kill -${f} ${a} 2>/dev/null`;if(e){let{execWithPassword:a}=c(66936);a(g,e).catch(()=>d(g,()=>{}))}else d(g,()=>{})}}function U(){try{let{machineIdSync:a}=c(19713),b=a();return l.createHash("sha256").update(b+N).digest()}catch{return l.createHash("sha256").update(N).digest()}}let V=null,W=null;async function X(a,b){if(W)try{let c,d,e,f,g,h={mitmEnabled:a};b&&(c=U(),d=l.randomBytes(12),e=l.createCipheriv(M,c,d),f=Buffer.concat([e.update(b,"utf8"),e.final()]),g=e.getAuthTag(),h.mitmSudoEncrypted=`${d.toString("hex")}:${g.toString("hex")}:${f.toString("hex")}`),await W(h)}catch(a){C(`Failed to save settings: ${a.message}`)}}async function Y(){if(W)try{await W({mitmSudoEncrypted:null})}catch(a){C(`Failed to clear encrypted password: ${a.message}`)}}async function Z(){if(!V)return null;try{let a=await V();if(!a.mitmSudoEncrypted)return null;return function(a){try{let[b,c,d]=a.split(":");if(!b||!c||!d)return null;let e=U(),f=l.createDecipheriv(M,e,Buffer.from(b,"hex"));return f.setAuthTag(Buffer.from(c,"hex")),f.update(Buffer.from(d,"hex"))+f.final("utf8")}catch{return null}}(a.mitmSudoEncrypted)}catch{return null}}async function $(a){if(O&&!O.killed){try{O.kill("SIGKILL")}catch{}O=null,P=null}try{if(h.existsSync(G)){let b=parseInt(h.readFileSync(G,"utf-8").trim(),10);b&&S(b)&&(T(b,!0,a),await new Promise(a=>setTimeout(a,500))),h.unlinkSync(G)}}catch{}if(!s&&L)try{let b=L.replace(/'/g,"'\\''");if(a){let{execWithPassword:d}=c(66936);await d(`pkill -SIGKILL -f "${b}" 2>/dev/null || true`,a).catch(()=>{})}else d(`pkill -SIGKILL -f "${b}" 2>/dev/null || true`,()=>{});await new Promise(a=>setTimeout(a,500))}catch{}}async function _(){let a=null!==O&&!O.killed,b=P;if(!a)try{if(h.existsSync(G)){let c=parseInt(h.readFileSync(G,"utf-8").trim(),10);c&&S(c)?(a=!0,b=c):h.unlinkSync(G)}}catch{}let c=p(),d=g.join(A,"rootCA.crt"),e=h.existsSync(d),f=!!e&&await x(d);return{running:a,pid:b,certExists:e,certTrusted:f,dnsStatus:c}}async function aa(a){if(K)return;if(Date.now()-J>=6e4&&(I=0),I>=5)return void C("Max restart attempts reached. Giving up.");let b=H[Math.min(I,H.length-1)];I++,K=!0,B(`Restarting in ${b/1e3}s... (${I}/5)`),await new Promise(a=>setTimeout(a,b));try{let b=V?await V():null;if(b&&!b.mitmEnabled){B("MITM disabled, skipping restart"),K=!1;return}let c=Q()||await Z();if(!c&&!s){C("No cached password, cannot auto-restart"),K=!1;return}await ab(a,c),B("\uD83D\uDD04 Restarted successfully"),I=0,K=!1}catch(b){C(`Restart attempt ${I}/5 failed: ${b.message}`),K=!1,aa(a)}}async function ab(a,b){if(!O||O.killed)try{if(h.existsSync(G)){let a=parseInt(h.readFileSync(G,"utf-8").trim(),10);if(a&&S(a))return P=a,B(`♻️ Reusing existing process (PID: ${a})`),await X(!0,b),b&&R(b),{running:!0,pid:a};h.unlinkSync(G)}}catch{}if(O&&!O.killed)throw Error("MITM server is already running");if(await $(b),!s){let a=await new Promise(a=>{let b=j.createServer();b.once("error",b=>{"EADDRINUSE"===b.code?a("in-use"):a("no-permission")}),b.once("listening",()=>{b.close(()=>a("free"))}),b.listen(443,"127.0.0.1")});if("in-use"===a||"no-permission"===a){let a=await new Promise(a=>{s?d('powershell -NonInteractive -WindowStyle Hidden -Command "$c = Get-NetTCPConnection -LocalPort 443 -State Listen -ErrorAction SilentlyContinue | Select-Object -First 1; if ($c) { $c.OwningProcess } else { 0 }"',{windowsHide:!0},(b,c)=>{if(b)return a(null);let e=parseInt(c.trim(),10);if(!e||e<=4)return a(null);d(`tasklist /FI "PID eq ${e}" /FO CSV /NH`,{windowsHide:!0},(b,c)=>{let d=c?.match(/"([^"]+)"/);a({pid:e,name:d?d[1]:"unknown"})})}):d('ps aux | grep "[s]erver.js"',(b,c)=>{if(!c?.trim())return a(null);for(let b of c.split("\n")){let c=parseInt(b.trim().split(/\s+/)[1],10);if(!isNaN(c))return a({pid:c,name:"node"})}a(null)})});if(a&&"node"===a.name){B(`Killing orphan node process on port 443 (PID ${a.pid})...`);try{let{execWithPassword:d}=c(66936);await d(`kill -9 ${a.pid}`,b),await new Promise(a=>setTimeout(a,800))}catch{}}else if(a){let b=a.name.includes("/")?a.name.split("/").filter(Boolean).pop():a.name;throw Error(`Port 443 is already in use by "${b}" (PID ${a.pid}). Stop that process first.`)}}}let l=g.join(A,"rootCA.crt"),m=g.join(A,"rootCA.key"),n=h.existsSync(l)&&h.existsSync(m);if(!n||z(l)){if(n){B("\uD83D\uDD10 Cert expired — uninstalling old cert...");let a=b||Q()||await Z();try{await w(a,l)}catch{}}B("\uD83D\uDD10 Generating Root CA..."),await u()}let o=await x(l),q=!s&&!t&&!r()&&!y();if(o)B("\uD83D\uDD10 Cert: already trusted ✅");else{B("\uD83D\uDD10 Cert: not trusted → installing...");let a=b||Q()||await Z();if(q)B(`🔐 Cert: skipping system trust (no sudo). Install ${l} as a trusted CA on machines that use this proxy.`);else{if(!a&&!s&&!y())throw Error("Sudo password required to install Root CA certificate");try{await v(a,l),B("\uD83D\uDD10 Cert: ✅ trusted")}catch(a){throw Error(`Failed to trust certificate: ${a.message}`)}}}let D=await F();if(B(`🚀 Starting server... (router: ${D})`),s){try{f('powershell -NonInteractive -WindowStyle Hidden -Command "$c = Get-NetTCPConnection -LocalPort 443 -State Listen -ErrorAction SilentlyContinue | Select-Object -First 1; if ($c -and $c.OwningProcess -gt 4) { Stop-Process -Id $c.OwningProcess -Force -ErrorAction SilentlyContinue }"',{windowsHide:!0}),await new Promise(a=>setTimeout(a,500))}catch{}O=e(process.execPath,[L],{detached:!1,windowsHide:!0,stdio:["ignore","pipe","pipe"],env:{...process.env,ROUTER_API_KEY:a,NODE_ENV:"production",MITM_ROUTER_BASE:D}}),W&&await W({mitmCertInstalled:!0}).catch(()=>{})}else r()?((O=e("sudo",["-S","-E","sh","-c",[`HOME=${E(i.homedir())}`,`ROUTER_API_KEY=${E(a)}`,`MITM_ROUTER_BASE=${E(D)}`,"NODE_ENV=production",E(process.execPath),E(L)].join(" ")],{detached:!1,stdio:["pipe","pipe","pipe"]})).stdin.write(`${b}
|
|
5
|
+
`),O.stdin.end()):O=e(process.execPath,[L],{detached:!1,stdio:["ignore","pipe","pipe"],env:{...process.env,ROUTER_API_KEY:a,NODE_ENV:"production",MITM_ROUTER_BASE:D}});O&&(P=O.pid,h.writeFileSync(G,String(P)),J=Date.now());let H=null;O&&(O.stdout.on("data",a=>{process.stdout.write(a)}),O.stderr.on("data",a=>{let b=a.toString().trim();b&&(s||!b.includes("Password:")&&!b.includes("password for"))&&(C(b),H=b),!s&&(b.includes("incorrect password")||b.includes("no password was provided"))&&(R(null),Y(),K=!0)}),O.on("exit",b=>{B(`Server exited (code: ${b})`),O=null,P=null;try{h.unlinkSync(G)}catch{}0===b||K||aa(a)}));let I=await function(a=443){return new Promise(b=>{let c=Date.now()+8e3,d=()=>{let e=k.request({hostname:"127.0.0.1",port:a,path:"/_mitm_health",method:"GET",rejectUnauthorized:!1},a=>{let c="";a.on("data",a=>{c+=a}),a.on("end",()=>{try{let a=JSON.parse(c);b(!0===a.ok?{ok:!0,pid:a.pid||null}:null)}catch{b(null)}})});e.on("error",()=>{Date.now()<c?setTimeout(d,500):b(null)}),e.end()};d()})}(443);if(!I){if(O&&!O.killed){try{O.kill()}catch{}O=null}let a=function(){try{if(s){let a=f('powershell -NonInteractive -WindowStyle Hidden -Command "$c = Get-NetTCPConnection -LocalPort 443 -State Listen -ErrorAction SilentlyContinue | Select-Object -First 1; if ($c) { $c.OwningProcess } else { 0 }"',{encoding:"utf8",windowsHide:!0}).trim(),b=parseInt(a,10);if(b&&b>4){let a=f(`tasklist /FI "PID eq ${b}" /FO CSV /NH`,{encoding:"utf8",windowsHide:!0}).match(/"([^"]+)"/);if(a)return a[1].replace(".exe","")}}else{let a=f("lsof -i :443",{encoding:"utf8"}).trim().split("\n");if(a.length>1)return a[1].split(/\s+/)[0]}}catch{}return null}(),b=a?` Port 443 already in use by ${a}.`:"",c=H||`Check sudo password or port 443 access.${b}`;throw Error(`MITM server failed to start. ${c}`)}for(let[a,b]of(W&&await W({mitmCertInstalled:!0}).catch(()=>{}),B(`✅ Server healthy (PID: ${P||I.pid})`),Object.entries(p())))B(`🌐 DNS ${a}: ${b?"✅ active":"❌ inactive"}`);return await X(!0,b),b&&R(b),{running:!0,pid:P}}async function ac(a){K=!0,I=0,B("⏹ Stopping server...");let b=O,d=b&&!b.killed?b.pid:(()=>{try{return parseInt(h.readFileSync(G,"utf-8").trim(),10)}catch{return null}})();if(d&&S(d)&&(B(`Killing server (PID: ${d})...`),T(d,!1,a),await new Promise(a=>setTimeout(a,1e3)),S(d)&&T(d,!0,a)),O=null,P=null,s){let a=g.join(process.env.SystemRoot||"C:\\Windows","System32","drivers","etc","hosts"),b=Object.values(q).flat();try{let d=h.readFileSync(a,"utf8").split(/\r?\n/).filter(a=>!b.some(b=>a.includes(b))).join("\r\n");h.writeFileSync(a,d,"utf8"),c(79646).execSync("ipconfig /flushdns",{windowsHide:!0})}catch(a){C(`Failed to clean hosts: ${a.message}`)}}else await o(a);try{h.unlinkSync(G)}catch{}return await X(!1,null),K=!1,{running:!1,pid:null}}async function ad(a,b){B(`🌐 DNS ${a}: enable requested (platform=${process.platform})`);let c=await _();if(!c.running)throw Error("MITM server is not running. Start the server first.");B(`🌐 DNS ${a}: pre-check running=${c.running} active=${!!c.dnsStatus?.[a]}`);let d=b||Q()||await Z();try{await m(a,d)}catch(b){throw C(`DNS ${a}: enable failed in manager — ${b?.message||String(b)}`),b}let e=p();return B(`🌐 DNS ${a}: post-check active=${!!e[a]}`),{success:!0,dnsStatus:e}}a.exports={getMitmStatus:_,startServer:ab,stopServer:ac,enableToolDNS:ad,disableToolDNS:async function a(a,b){B(`🌐 DNS ${a}: disable requested (platform=${process.platform})`);let c=b||Q()||await Z();try{await n(a,c)}catch(b){throw C(`DNS ${a}: disable failed in manager — ${b?.message||String(b)}`),b}let d=p();return B(`🌐 DNS ${a}: post-check active=${!!d[a]}`),{success:!0,dnsStatus:d}},trustCert:async function a(a){let b=g.join(A,"rootCA.crt");if(!h.existsSync(b))throw Error("Root CA not found. Start server first to generate it.");if(!s&&!t&&!r()&&!y())return void B(`🔐 Cert: system trust unavailable (no sudo). Use file: ${b}`);let c=a||Q()||await Z();if(!c&&!s&&!y())throw Error("Sudo password required to trust certificate");await v(c,b),c&&R(c)},startMitm:ab,stopMitm:ac,getCachedPassword:Q,setCachedPassword:R,loadEncryptedPassword:Z,clearEncryptedPassword:Y,initDbHooks:function(a,b){V=a,W=b}}}};
|
|
@@ -12,4 +12,4 @@ model_provider = "9router"
|
|
|
12
12
|
name = "9Router"
|
|
13
13
|
base_url = "${P()}"
|
|
14
14
|
wire_api = "responses"
|
|
15
|
-
`},{filename:"~/.codex/auth.json",content:JSON.stringify({OPENAI_API_KEY:p},null,2)}])})]})}let k="https://9router.com";function l({tool:a,isExpanded:b,onToggle:c,baseUrl:h,hasActiveProviders:i,apiKeys:j,activeProviders:m,cloudEnabled:n,initialStatus:o}){let p,q,r,s,[t,u]=(0,e.useState)(o||null),[v,w]=(0,e.useState)(!1),[x,y]=(0,e.useState)(!1),[z,A]=(0,e.useState)(!1),[B,C]=(0,e.useState)(null),[D,E]=(0,e.useState)(""),[F,G]=(0,e.useState)(""),[H,I]=(0,e.useState)(!1),[J,K]=(0,e.useState)({}),[L,M]=(0,e.useState)(!1),[N,O]=(0,e.useState)("");(0,e.useRef)(!1);let P=(()=>{if(!t?.installed)return null;let a=t.settings?.customModels?.find(a=>"custom:9Router-0"===a.id);if(!a)return"not_configured";let b=a.baseUrl?.includes("localhost")||a.baseUrl?.includes("127.0.0.1"),c=n&&k&&a.baseUrl?.startsWith(k),d=h&&a.baseUrl?.startsWith(h);return b||c||d?"configured":"other"})(),Q=async()=>{w(!0);try{let a=await fetch("/api/cli-tools/droid-settings"),b=await a.json();u(b)}catch(a){u({installed:!1,error:a.message})}finally{w(!1)}},R=()=>{let a=N||h;return a.endsWith("/v1")?a:`${a}/v1`},S=async()=>{y(!0),C(null);try{let a=D?.trim()||(j?.length>0?j[0].key:null)||(n?null:"sk_9router"),b=await fetch("/api/cli-tools/droid-settings",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({baseUrl:R(),apiKey:a,model:F})}),c=await b.json();b.ok?(C({type:"success",text:"Settings applied successfully!"}),Q()):C({type:"error",text:c.error||"Failed to apply settings"})}catch(a){C({type:"error",text:a.message})}finally{y(!1)}},T=async()=>{A(!0),C(null);try{let a=await fetch("/api/cli-tools/droid-settings",{method:"DELETE"}),b=await a.json();a.ok?(C({type:"success",text:"Settings reset successfully!"}),G(""),E(""),Q()):C({type:"error",text:b.error||"Failed to reset settings"})}catch(a){C({type:"error",text:a.message})}finally{A(!1)}};return(0,d.jsxs)(f.Zp,{padding:"xs",className:"overflow-hidden",children:[(0,d.jsxs)("div",{className:"flex items-center justify-between hover:cursor-pointer",onClick:c,children:[(0,d.jsxs)("div",{className:"flex items-center gap-3",children:[(0,d.jsx)("div",{className:"size-8 flex items-center justify-center shrink-0",children:(0,d.jsx)(g.default,{src:"/providers/droid.png",alt:a.name,width:32,height:32,className:"size-8 object-contain rounded-lg",sizes:"32px",onError:a=>{a.target.style.display="none"}})}),(0,d.jsxs)("div",{className:"min-w-0",children:[(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)("h3",{className:"font-medium text-sm",children:a.name}),"configured"===P&&(0,d.jsx)("span",{className:"px-1.5 py-0.5 text-[10px] font-medium bg-green-500/10 text-green-600 dark:text-green-400 rounded-full",children:"Connected"}),"not_configured"===P&&(0,d.jsx)("span",{className:"px-1.5 py-0.5 text-[10px] font-medium bg-yellow-500/10 text-yellow-600 dark:text-yellow-400 rounded-full",children:"Not configured"}),"other"===P&&(0,d.jsx)("span",{className:"px-1.5 py-0.5 text-[10px] font-medium bg-blue-500/10 text-blue-600 dark:text-blue-400 rounded-full",children:"Other"})]}),(0,d.jsx)("p",{className:"text-xs text-text-muted truncate",children:a.description})]})]}),(0,d.jsx)("span",{className:`material-symbols-outlined text-text-muted text-[20px] transition-transform ${b?"rotate-180":""}`,children:"expand_more"})]}),b&&(0,d.jsxs)("div",{className:"mt-4 pt-4 border-t border-border flex flex-col gap-4",children:[v&&(0,d.jsxs)("div",{className:"flex items-center gap-2 text-text-muted",children:[(0,d.jsx)("span",{className:"material-symbols-outlined animate-spin",children:"progress_activity"}),(0,d.jsx)("span",{children:"Checking Factory Droid CLI..."})]}),!v&&t&&!t.installed&&(0,d.jsxs)("div",{className:"flex items-center gap-3 p-4 bg-yellow-500/10 border border-yellow-500/30 rounded-lg",children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-yellow-500",children:"warning"}),(0,d.jsxs)("div",{className:"flex-1",children:[(0,d.jsx)("p",{className:"font-medium text-yellow-600 dark:text-yellow-400",children:"Factory Droid CLI not installed"}),(0,d.jsx)("p",{className:"text-sm text-text-muted",children:"Please install Factory Droid CLI to use this feature."})]})]}),!v&&t?.installed&&(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)("div",{className:"flex flex-col gap-2",children:[t?.settings?.customModels?.find(a=>"custom:9Router-0"===a.id)?.baseUrl&&(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)("span",{className:"w-32 shrink-0 text-sm font-semibold text-text-main text-right",children:"Current"}),(0,d.jsx)("span",{className:"material-symbols-outlined text-text-muted text-[14px]",children:"arrow_forward"}),(0,d.jsx)("span",{className:"flex-1 px-2 py-1.5 text-xs text-text-muted truncate",children:t.settings.customModels.find(a=>"custom:9Router-0"===a.id).baseUrl})]}),(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)("span",{className:"w-32 shrink-0 text-sm font-semibold text-text-main text-right",children:"Base URL"}),(0,d.jsx)("span",{className:"material-symbols-outlined text-text-muted text-[14px]",children:"arrow_forward"}),(0,d.jsx)("input",{type:"text",value:(p=N||h).endsWith("/v1")?p:`${p}/v1`,onChange:a=>O(a.target.value),placeholder:"https://.../v1",className:"flex-1 px-2 py-1.5 bg-surface rounded border border-border text-xs focus:outline-none focus:ring-1 focus:ring-primary/50"}),N&&N!==h&&(0,d.jsx)("button",{onClick:()=>O(""),className:"p-1 text-text-muted hover:text-primary rounded transition-colors",title:"Reset to default",children:(0,d.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"restart_alt"})})]}),(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)("span",{className:"w-32 shrink-0 text-sm font-semibold text-text-main text-right",children:"API Key"}),(0,d.jsx)("span",{className:"material-symbols-outlined text-text-muted text-[14px]",children:"arrow_forward"}),j.length>0?(0,d.jsx)("select",{value:D,onChange:a=>E(a.target.value),className:"flex-1 px-2 py-1.5 bg-surface rounded text-xs border border-border focus:outline-none focus:ring-1 focus:ring-primary/50",children:j.map(a=>(0,d.jsx)("option",{value:a.key,children:a.key},a.id))}):(0,d.jsx)("span",{className:"flex-1 text-xs text-text-muted px-2 py-1.5",children:n?"No API keys - Create one in Keys page":"sk_9router (default)"})]}),(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)("span",{className:"w-32 shrink-0 text-sm font-semibold text-text-main text-right",children:"Model"}),(0,d.jsx)("span",{className:"material-symbols-outlined text-text-muted text-[14px]",children:"arrow_forward"}),(0,d.jsx)("input",{type:"text",value:F,onChange:a=>G(a.target.value),placeholder:"provider/model-id",className:"flex-1 px-2 py-1.5 bg-surface rounded border border-border text-xs focus:outline-none focus:ring-1 focus:ring-primary/50"}),(0,d.jsx)("button",{onClick:()=>I(!0),disabled:!i,className:`px-2 py-1.5 rounded border text-xs transition-colors shrink-0 whitespace-nowrap ${i?"bg-surface border-border text-text-main hover:border-primary cursor-pointer":"opacity-50 cursor-not-allowed border-border"}`,children:"Select Model"}),F&&(0,d.jsx)("button",{onClick:()=>G(""),className:"p-1 text-text-muted hover:text-red-500 rounded transition-colors",title:"Clear",children:(0,d.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"close"})})]})]}),B&&(0,d.jsxs)("div",{className:`flex items-center gap-2 px-2 py-1.5 rounded text-xs ${"success"===B.type?"bg-green-500/10 text-green-600":"bg-red-500/10 text-red-600"}`,children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"success"===B.type?"check_circle":"error"}),(0,d.jsx)("span",{children:B.text})]}),(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsxs)(f.$n,{variant:"primary",size:"sm",onClick:S,disabled:!F,loading:x,children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-[14px] mr-1",children:"save"}),"Apply"]}),(0,d.jsxs)(f.$n,{variant:"outline",size:"sm",onClick:T,disabled:!t?.has9Router,loading:z,children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-[14px] mr-1",children:"restore"}),"Reset"]}),(0,d.jsxs)(f.$n,{variant:"ghost",size:"sm",onClick:()=>M(!0),children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-[14px] mr-1",children:"content_copy"}),"Manual Config"]})]})]})]}),(0,d.jsx)(f.rq,{isOpen:H,onClose:()=>I(!1),onSelect:a=>{G(a.value),I(!1)},selectedModel:F,activeProviders:m,modelAliases:J,title:"Select Model for Factory Droid"}),(0,d.jsx)(f.uR,{isOpen:L,onClose:()=>M(!1),title:"Factory Droid - Manual Configuration",configs:(q=D&&D.trim()?D:n?"<API_KEY_FROM_DASHBOARD>":"sk_9router",r={customModels:[{model:F||"provider/model-id",id:"custom:9Router-0",index:0,baseUrl:R(),apiKey:q,displayName:F||"provider/model-id",maxOutputTokens:131072,noImageSupport:!1,provider:"openai"}]},s="u">typeof navigator&&navigator.platform,[{filename:s?.toLowerCase().includes("win")?"%USERPROFILE%\\.factory\\settings.json":"~/.factory/settings.json",content:JSON.stringify(r,null,2)}])})]})}function m({tool:a,isExpanded:b,onToggle:c,baseUrl:h,hasActiveProviders:i,apiKeys:j,activeProviders:k,cloudEnabled:l,initialStatus:n}){let o,p,[q,r]=(0,e.useState)(n||null),[s,t]=(0,e.useState)(!1),[u,v]=(0,e.useState)(!1),[w,x]=(0,e.useState)(!1),[y,z]=(0,e.useState)(null),[A,B]=(0,e.useState)(""),[C,D]=(0,e.useState)(""),[E,F]=(0,e.useState)({}),[G,H]=(0,e.useState)(null),[I,J]=(0,e.useState)(!1),[K,L]=(0,e.useState)({}),[M,N]=(0,e.useState)(!1),[O,P]=(0,e.useState)("");(0,e.useRef)(!1);let Q=(()=>{if(!q?.installed)return null;let a=q.settings?.models?.providers?.["9router"];if(!a)return"not_configured";let b=a.baseUrl?.includes("localhost")||a.baseUrl?.includes("127.0.0.1")||a.baseUrl?.includes("0.0.0.0"),c=h&&a.baseUrl?.startsWith(h);return b||c?"configured":"other"})(),R=async()=>{t(!0);try{let a=await fetch("/api/cli-tools/openclaw-settings"),b=await a.json();r(b)}catch(a){r({installed:!1,error:a.message})}finally{t(!1)}},S=()=>{let a=O||"http://127.0.0.1:20128";return a.endsWith("/v1")?a:`${a}/v1`},T=async()=>{v(!0),z(null);try{let a=A?.trim()||(j?.length>0?j[0].key:null)||(l?null:"sk_9router"),b=await fetch("/api/cli-tools/openclaw-settings",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({baseUrl:S(),apiKey:a,model:C,agentModels:E})}),c=await b.json();b.ok?(z({type:"success",text:"Settings applied successfully!"}),R()):z({type:"error",text:c.error||"Failed to apply settings"})}catch(a){z({type:"error",text:a.message})}finally{v(!1)}},U=async()=>{x(!0),z(null);try{let a=await fetch("/api/cli-tools/openclaw-settings",{method:"DELETE"}),b=await a.json();a.ok?(z({type:"success",text:"Settings reset successfully!"}),D(""),B(""),R()):z({type:"error",text:b.error||"Failed to reset settings"})}catch(a){z({type:"error",text:a.message})}finally{x(!1)}};return(0,d.jsxs)(f.Zp,{padding:"xs",className:"overflow-hidden",children:[(0,d.jsxs)("div",{className:"flex items-center justify-between hover:cursor-pointer",onClick:c,children:[(0,d.jsxs)("div",{className:"flex items-center gap-3",children:[(0,d.jsx)("div",{className:"size-8 flex items-center justify-center shrink-0",children:(0,d.jsx)(g.default,{src:"/providers/openclaw.png",alt:a.name,width:32,height:32,className:"size-8 object-contain rounded-lg",sizes:"32px",onError:a=>{a.target.style.display="none"}})}),(0,d.jsxs)("div",{className:"min-w-0",children:[(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)("h3",{className:"font-medium text-sm",children:a.name}),"configured"===Q&&(0,d.jsx)("span",{className:"px-1.5 py-0.5 text-[10px] font-medium bg-green-500/10 text-green-600 dark:text-green-400 rounded-full",children:"Connected"}),"not_configured"===Q&&(0,d.jsx)("span",{className:"px-1.5 py-0.5 text-[10px] font-medium bg-yellow-500/10 text-yellow-600 dark:text-yellow-400 rounded-full",children:"Not configured"}),"other"===Q&&(0,d.jsx)("span",{className:"px-1.5 py-0.5 text-[10px] font-medium bg-blue-500/10 text-blue-600 dark:text-blue-400 rounded-full",children:"Other"})]}),(0,d.jsx)("p",{className:"text-xs text-text-muted truncate",children:a.description})]})]}),(0,d.jsx)("span",{className:`material-symbols-outlined text-text-muted text-[20px] transition-transform ${b?"rotate-180":""}`,children:"expand_more"})]}),b&&(0,d.jsxs)("div",{className:"mt-4 pt-4 border-t border-border flex flex-col gap-4",children:[s&&(0,d.jsxs)("div",{className:"flex items-center gap-2 text-text-muted",children:[(0,d.jsx)("span",{className:"material-symbols-outlined animate-spin",children:"progress_activity"}),(0,d.jsx)("span",{children:"Checking Open Claw CLI..."})]}),!s&&q&&!q.installed&&(0,d.jsxs)("div",{className:"flex items-center gap-3 p-4 bg-yellow-500/10 border border-yellow-500/30 rounded-lg",children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-yellow-500",children:"warning"}),(0,d.jsxs)("div",{className:"flex-1",children:[(0,d.jsx)("p",{className:"font-medium text-yellow-600 dark:text-yellow-400",children:"Open Claw CLI not installed"}),(0,d.jsx)("p",{className:"text-sm text-text-muted",children:"Please install Open Claw CLI to use this feature."})]})]}),!s&&q?.installed&&(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)("div",{className:"flex flex-col gap-2",children:[q?.settings?.models?.providers?.["9router"]?.baseUrl&&(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)("span",{className:"w-32 shrink-0 text-sm font-semibold text-text-main text-right",children:"Current"}),(0,d.jsx)("span",{className:"material-symbols-outlined text-text-muted text-[14px]",children:"arrow_forward"}),(0,d.jsx)("span",{className:"flex-1 px-2 py-1.5 text-xs text-text-muted truncate",children:q.settings.models.providers["9router"].baseUrl})]}),(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)("span",{className:"w-32 shrink-0 text-sm font-semibold text-text-main text-right",children:"Base URL"}),(0,d.jsx)("span",{className:"material-symbols-outlined text-text-muted text-[14px]",children:"arrow_forward"}),(0,d.jsx)("input",{type:"text",value:(o=O||"http://127.0.0.1:20128").endsWith("/v1")?o:`${o}/v1`,onChange:a=>P(a.target.value),placeholder:"https://.../v1",className:"flex-1 px-2 py-1.5 bg-surface rounded border border-border text-xs focus:outline-none focus:ring-1 focus:ring-primary/50"}),O&&O!==h&&(0,d.jsx)("button",{onClick:()=>P(""),className:"p-1 text-text-muted hover:text-primary rounded transition-colors",title:"Reset to default",children:(0,d.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"restart_alt"})})]}),(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)("span",{className:"w-32 shrink-0 text-sm font-semibold text-text-main text-right",children:"API Key"}),(0,d.jsx)("span",{className:"material-symbols-outlined text-text-muted text-[14px]",children:"arrow_forward"}),j.length>0?(0,d.jsx)("select",{value:A,onChange:a=>B(a.target.value),className:"flex-1 px-2 py-1.5 bg-surface rounded text-xs border border-border focus:outline-none focus:ring-1 focus:ring-primary/50",children:j.map(a=>(0,d.jsx)("option",{value:a.key,children:a.key},a.id))}):(0,d.jsx)("span",{className:"flex-1 text-xs text-text-muted px-2 py-1.5",children:l?"No API keys - Create one in Keys page":"sk_9router (default)"})]}),(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)("span",{className:"w-32 shrink-0 text-sm font-semibold text-text-main text-right",children:"Default Model"}),(0,d.jsx)("span",{className:"material-symbols-outlined text-text-muted text-[14px]",children:"arrow_forward"}),(0,d.jsx)("input",{type:"text",value:C,onChange:a=>D(a.target.value),placeholder:"provider/model-id",className:"flex-1 px-2 py-1.5 bg-surface rounded border border-border text-xs focus:outline-none focus:ring-1 focus:ring-primary/50"}),(0,d.jsx)("button",{onClick:()=>{H(null),J(!0)},disabled:!i,className:`px-2 py-1.5 rounded border text-xs transition-colors shrink-0 whitespace-nowrap ${i?"bg-surface border-border text-text-main hover:border-primary cursor-pointer":"opacity-50 cursor-not-allowed border-border"}`,children:"Select"}),C&&(0,d.jsx)("button",{onClick:()=>D(""),className:"p-1 text-text-muted hover:text-red-500 rounded transition-colors",title:"Clear",children:(0,d.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"close"})})]}),(q.agents||[]).filter(a=>a.agentDir).map(a=>(0,d.jsxs)("div",{className:"flex items-center gap-2 pl-4",children:[(0,d.jsxs)("span",{className:"w-32 shrink-0 text-xs text-primary text-right truncate",title:a.name||a.id,children:["Agent ",a.name||a.id]}),(0,d.jsx)("span",{className:"material-symbols-outlined text-text-muted text-[14px]",children:"arrow_forward"}),(0,d.jsx)("input",{type:"text",value:E[a.id]||"",onChange:b=>F(c=>({...c,[a.id]:b.target.value})),placeholder:`default (${C||"provider/model-id"})`,className:"flex-1 px-2 py-1.5 bg-surface rounded border border-border text-xs focus:outline-none focus:ring-1 focus:ring-primary/50"}),(0,d.jsx)("button",{onClick:()=>{H(a.id),J(!0)},disabled:!i,className:`px-2 py-1.5 rounded border text-xs transition-colors shrink-0 whitespace-nowrap ${i?"bg-surface border-border text-text-main hover:border-primary cursor-pointer":"opacity-50 cursor-not-allowed border-border"}`,children:"Select"}),E[a.id]&&(0,d.jsx)("button",{onClick:()=>F(b=>({...b,[a.id]:""})),className:"p-1 text-text-muted hover:text-red-500 rounded transition-colors",title:"Clear",children:(0,d.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"close"})})]},a.id))]}),y&&(0,d.jsxs)("div",{className:`flex items-center gap-2 px-2 py-1.5 rounded text-xs ${"success"===y.type?"bg-green-500/10 text-green-600":"bg-red-500/10 text-red-600"}`,children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"success"===y.type?"check_circle":"error"}),(0,d.jsx)("span",{children:y.text})]}),(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsxs)(f.$n,{variant:"primary",size:"sm",onClick:T,disabled:!C,loading:u,children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-[14px] mr-1",children:"save"}),"Apply"]}),(0,d.jsxs)(f.$n,{variant:"outline",size:"sm",onClick:U,disabled:!q?.has9Router,loading:w,children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-[14px] mr-1",children:"restore"}),"Reset"]}),(0,d.jsxs)(f.$n,{variant:"ghost",size:"sm",onClick:()=>N(!0),children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-[14px] mr-1",children:"content_copy"}),"Manual Config"]})]})]})]}),(0,d.jsx)(f.rq,{isOpen:I,onClose:()=>J(!1),onSelect:a=>{G?(F(b=>({...b,[G]:a.value})),H(null)):D(a.value),J(!1)},selectedModel:C,activeProviders:k,modelAliases:K,title:"Select Model for Open Claw"}),(0,d.jsx)(f.uR,{isOpen:M,onClose:()=>N(!1),title:"Open Claw - Manual Configuration",configs:(p=A&&A.trim()?A:l?"<API_KEY_FROM_DASHBOARD>":"sk_9router",[{filename:"~/.openclaw/openclaw.json",content:JSON.stringify({agents:{defaults:{model:{primary:`9router/${C||"provider/model-id"}`}}},models:{providers:{"9router":{baseUrl:S(),apiKey:p,api:"openai-completions",models:[{id:C||"provider/model-id",name:(C||"provider/model-id").split("/").pop()}]}}}},null,2)}])})]})}function n({toolId:a,tool:b,isExpanded:c,onToggle:h,baseUrl:i,apiKeys:j,activeProviders:k=[],cloudEnabled:l=!1,tunnelEnabled:m=!1}){let[o,p]=(0,e.useState)(null),[q,r]=(0,e.useState)(!1),[s,t]=(0,e.useState)(""),[u,v]=(0,e.useState)(()=>j?.length>0?j[0].key:""),w=a=>{let b=u&&u.trim()?u:l?"your-api-key":"sk_9router",c=i||"http://localhost:20128",d=c.endsWith("/v1")?c:`${c}/v1`;return a.replace(/\{\{baseUrl\}\}/g,d).replace(/\{\{apiKey\}\}/g,b).replace(/\{\{model\}\}/g,s||"provider/model-id")},x=async(a,b)=>{await navigator.clipboard.writeText(w(a)),p(b),setTimeout(()=>p(null),2e3)},y=k.length>0,z=()=>(!b.requiresExternalUrl||!!l||!!m)&&(!b.requiresCloud||!!l);return(0,d.jsxs)(f.Zp,{padding:"xs",className:"overflow-hidden",children:[(0,d.jsxs)("div",{className:"flex items-center justify-between hover:cursor-pointer",onClick:h,children:[(0,d.jsxs)("div",{className:"flex items-center gap-3",children:[(0,d.jsx)("div",{className:"size-8 rounded-lg flex items-center justify-center shrink-0",children:b.image?(0,d.jsx)(g.default,{src:b.image,alt:b.name,width:32,height:32,className:"size-8 object-contain rounded-lg",sizes:"32px",onError:a=>{a.target.style.display="none"}}):b.icon?(0,d.jsx)("span",{className:"material-symbols-outlined text-xl",style:{color:b.color},children:b.icon}):(0,d.jsx)(g.default,{src:`/providers/${a}.png`,alt:b.name,width:32,height:32,className:"size-8 object-contain rounded-lg",sizes:"32px",onError:a=>{a.target.style.display="none"}})}),(0,d.jsxs)("div",{className:"min-w-0",children:[(0,d.jsx)("h3",{className:"font-medium text-sm",children:b.name}),(0,d.jsx)("p",{className:"text-xs text-text-muted truncate",children:b.description})]})]}),(0,d.jsx)("span",{className:`material-symbols-outlined text-text-muted text-[20px] transition-transform ${c?"rotate-180":""}`,children:"expand_more"})]}),c&&(0,d.jsx)("div",{className:"mt-6 pt-6 border-t border-border",children:b.guideSteps?(0,d.jsxs)("div",{className:"flex flex-col gap-4",children:[b.notes&&0!==b.notes.length?(0,d.jsx)("div",{className:"flex flex-col gap-2 mb-4",children:b.notes.map((a,b)=>{if("cloudCheck"===a.type&&(l||m))return null;let c="warning"===a.type,e="cloudCheck"===a.type&&!l&&!m,f="bg-blue-500/10 border-blue-500/30",g="text-blue-600 dark:text-blue-400",h="text-blue-500",i="info";return c?(f="bg-yellow-500/10 border-yellow-500/30",g="text-yellow-600 dark:text-yellow-400",h="text-yellow-500",i="warning"):e&&(f="bg-red-500/10 border-red-500/30",g="text-red-600 dark:text-red-400",h="text-red-500",i="error"),(0,d.jsxs)("div",{className:`flex items-start gap-3 p-3 rounded-lg border ${f}`,children:[(0,d.jsx)("span",{className:`material-symbols-outlined text-lg ${h}`,children:i}),(0,d.jsx)("p",{className:`text-sm ${g}`,children:a.text})]},b)})}):null,z()&&b.guideSteps.map(a=>(0,d.jsxs)("div",{className:"flex items-start gap-4",children:[(0,d.jsx)("div",{className:"size-8 rounded-full flex items-center justify-center shrink-0 text-sm font-semibold text-white",style:{backgroundColor:b.color},children:a.step}),(0,d.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,d.jsx)("p",{className:"font-medium text-text",children:a.title}),a.desc&&(0,d.jsx)("p",{className:"text-sm text-text-muted mt-0.5",children:a.desc}),"apiKeySelector"===a.type&&(0,d.jsx)("div",{className:"mt-2 flex items-center gap-2",children:j&&j.length>0?(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("select",{value:u,onChange:a=>v(a.target.value),className:"flex-1 px-3 py-2 bg-bg-secondary rounded-lg text-sm border border-border focus:outline-none focus:ring-1 focus:ring-primary/50",children:j.map(a=>(0,d.jsx)("option",{value:a.key,children:a.key},a.id))}),(0,d.jsx)("button",{onClick:()=>x(u,"apiKey"),className:"shrink-0 px-3 py-2 bg-bg-secondary hover:bg-bg-tertiary rounded-lg border border-border transition-colors",children:(0,d.jsx)("span",{className:"material-symbols-outlined text-lg",children:"apiKey"===o?"check":"content_copy"})})]}):(0,d.jsx)("span",{className:"text-sm text-text-muted",children:l?"No API keys - Create one in Keys page":"sk_9router"})}),"modelSelector"===a.type&&(0,d.jsxs)("div",{className:"mt-2 flex items-center gap-2",children:[(0,d.jsx)("input",{type:"text",value:s,onChange:a=>t(a.target.value),placeholder:"provider/model-id",className:"flex-1 px-3 py-2 bg-bg-secondary rounded-lg text-sm border border-border focus:outline-none focus:ring-1 focus:ring-primary/50"}),(0,d.jsx)("button",{onClick:()=>r(!0),disabled:!y,className:`shrink-0 px-3 py-2 rounded-lg border text-sm transition-colors ${y?"bg-bg-secondary border-border text-text-main hover:border-primary cursor-pointer":"opacity-50 cursor-not-allowed border-border"}`,children:"Select Model"}),s&&(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("button",{onClick:()=>x(s,"model"),className:"shrink-0 px-3 py-2 bg-bg-secondary hover:bg-bg-tertiary rounded-lg border border-border transition-colors",children:(0,d.jsx)("span",{className:"material-symbols-outlined text-lg",children:"model"===o?"check":"content_copy"})}),(0,d.jsx)("button",{onClick:()=>t(""),className:"p-2 text-text-muted hover:text-red-500 rounded transition-colors",title:"Clear",children:(0,d.jsx)("span",{className:"material-symbols-outlined text-lg",children:"close"})})]})]}),a.value&&(0,d.jsxs)("div",{className:"mt-2 flex items-center gap-2",children:[(0,d.jsx)("code",{className:"flex-1 px-3 py-2 bg-bg-secondary rounded-lg text-sm font-mono border border-border truncate",children:w(a.value)}),a.copyable&&(0,d.jsx)("button",{onClick:()=>x(a.value,`${a.step}-${a.title}`),className:"shrink-0 px-3 py-2 bg-bg-secondary hover:bg-bg-tertiary rounded-lg border border-border transition-colors",children:(0,d.jsx)("span",{className:"material-symbols-outlined text-lg",children:o===`${a.step}-${a.title}`?"check":"content_copy"})})]})]})]},a.step)),z()&&b.codeBlock&&(0,d.jsxs)("div",{className:"mt-2",children:[(0,d.jsxs)("div",{className:"flex items-center justify-between mb-2",children:[(0,d.jsx)("span",{className:"text-xs text-text-muted uppercase tracking-wide",children:b.codeBlock.language}),(0,d.jsxs)("button",{onClick:()=>x(b.codeBlock.code,"codeblock"),className:"flex items-center gap-1 px-2 py-1 text-xs bg-bg-secondary hover:bg-bg-tertiary rounded border border-border transition-colors",children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-sm",children:"codeblock"===o?"check":"content_copy"}),"codeblock"===o?"Copied!":"Copy"]})]}),(0,d.jsx)("pre",{className:"p-4 bg-bg-secondary rounded-lg border border-border overflow-x-auto",children:(0,d.jsx)("code",{className:"text-sm font-mono whitespace-pre",children:w(b.codeBlock.code)})})]})]}):(0,d.jsx)("p",{className:"text-text-muted text-sm",children:"Coming soon..."})}),(0,d.jsx)(f.rq,{isOpen:q,onClose:()=>r(!1),onSelect:a=>{t(a.value)},selectedModel:s,activeProviders:k,title:"Select Model"})]})}function o({tool:a,isExpanded:b,onToggle:c,baseUrl:h,apiKeys:i,activeProviders:j,cloudEnabled:k,initialStatus:l}){let m,[n,p]=(0,e.useState)(l||null),[q,r]=(0,e.useState)(!1),[s,t]=(0,e.useState)(!1),[u,v]=(0,e.useState)(!1),[w,x]=(0,e.useState)(null),[y,z]=(0,e.useState)(!1),[A,B]=(0,e.useState)(""),[C,D]=(0,e.useState)(""),[E,F]=(0,e.useState)(!1),[G,H]=(0,e.useState)({}),[I,J]=(0,e.useState)(!1),[K,L]=(0,e.useState)(""),M=(()=>{if(!n?.installed)return null;if(!n.config)return"not_configured";let a=n.config?.provider?.["9router"]?.options?.baseURL||"",b=a.includes("localhost")||a.includes("127.0.0.1");return n.has9Router&&(b||a.includes(h))?"configured":n.has9Router?"other":"not_configured"})(),N=()=>{let a=K||h;return a.endsWith("/v1")?a:`${a}/v1`},O=async()=>{r(!0);try{let a=await fetch("/api/cli-tools/opencode-settings"),b=await a.json();p(b)}catch(a){p({installed:!1,error:a.message})}finally{r(!1)}},P=async()=>{t(!0),x(null);try{let a=A&&A.trim()||k?A:"sk_9router",b=await fetch("/api/cli-tools/opencode-settings",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({baseUrl:N(),apiKey:a,model:C})}),c=await b.json();b.ok?(x({type:"success",text:"Settings applied successfully!"}),O()):x({type:"error",text:c.error||"Failed to apply settings"})}catch(a){x({type:"error",text:a.message})}finally{t(!1)}},Q=async()=>{v(!0),x(null);try{let a=await fetch("/api/cli-tools/opencode-settings",{method:"DELETE"}),b=await a.json();a.ok?(x({type:"success",text:"Settings reset successfully!"}),D(""),O()):x({type:"error",text:b.error||"Failed to reset settings"})}catch(a){x({type:"error",text:a.message})}finally{v(!1)}};return(0,d.jsxs)(f.Zp,{padding:"xs",className:"overflow-hidden",children:[(0,d.jsxs)("div",{className:"flex items-center justify-between hover:cursor-pointer",onClick:c,children:[(0,d.jsxs)("div",{className:"flex items-center gap-3",children:[(0,d.jsx)("div",{className:"size-8 flex items-center justify-center shrink-0",children:(0,d.jsx)(g.default,{src:"/providers/opencode.png",alt:a.name,width:32,height:32,className:"size-8 object-contain rounded-lg",sizes:"32px",onError:a=>{a.target.style.display="none"}})}),(0,d.jsxs)("div",{className:"min-w-0",children:[(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)("h3",{className:"font-medium text-sm",children:a.name}),"configured"===M&&(0,d.jsx)("span",{className:"px-1.5 py-0.5 text-[10px] font-medium bg-green-500/10 text-green-600 dark:text-green-400 rounded-full",children:"Connected"}),"not_configured"===M&&(0,d.jsx)("span",{className:"px-1.5 py-0.5 text-[10px] font-medium bg-yellow-500/10 text-yellow-600 dark:text-yellow-400 rounded-full",children:"Not configured"}),"other"===M&&(0,d.jsx)("span",{className:"px-1.5 py-0.5 text-[10px] font-medium bg-blue-500/10 text-blue-600 dark:text-blue-400 rounded-full",children:"Other"})]}),(0,d.jsx)("p",{className:"text-xs text-text-muted truncate",children:a.description})]})]}),(0,d.jsx)("span",{className:`material-symbols-outlined text-text-muted text-[20px] transition-transform ${b?"rotate-180":""}`,children:"expand_more"})]}),b&&(0,d.jsxs)("div",{className:"mt-4 pt-4 border-t border-border flex flex-col gap-4",children:[q&&(0,d.jsxs)("div",{className:"flex items-center gap-2 text-text-muted",children:[(0,d.jsx)("span",{className:"material-symbols-outlined animate-spin",children:"progress_activity"}),(0,d.jsx)("span",{children:"Checking OpenCode CLI..."})]}),!q&&n&&!n.installed&&(0,d.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,d.jsxs)("div",{className:"flex items-center gap-3 p-4 bg-yellow-500/10 border border-yellow-500/30 rounded-lg",children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-yellow-500",children:"warning"}),(0,d.jsxs)("div",{className:"flex-1",children:[(0,d.jsx)("p",{className:"font-medium text-yellow-600 dark:text-yellow-400",children:"OpenCode CLI not installed"}),(0,d.jsx)("p",{className:"text-sm text-text-muted",children:"Please install OpenCode CLI to use auto-apply feature."})]}),(0,d.jsxs)(f.$n,{variant:"outline",size:"sm",onClick:()=>z(!y),children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-[18px] mr-1",children:y?"expand_less":"help"}),y?"Hide":"How to Install"]})]}),y&&(0,d.jsxs)("div",{className:"p-4 bg-surface border border-border rounded-lg",children:[(0,d.jsx)("h4",{className:"font-medium mb-3",children:"Installation Guide"}),(0,d.jsxs)("div",{className:"space-y-3 text-sm",children:[(0,d.jsxs)("div",{children:[(0,d.jsx)("p",{className:"text-text-muted mb-1",children:"macOS / Linux:"}),(0,d.jsx)("code",{className:"block px-3 py-2 bg-black/5 dark:bg-white/5 rounded font-mono text-xs",children:"npm install -g opencode-ai"})]}),(0,d.jsxs)("p",{className:"text-text-muted",children:["After installation, run ",(0,d.jsx)("code",{className:"px-1 bg-black/5 dark:bg-white/5 rounded",children:"opencode"})," to verify."]})]})]})]}),!q&&n?.installed&&(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)("div",{className:"flex flex-col gap-2",children:[n?.config?.provider?.["9router"]?.options?.baseURL&&(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)("span",{className:"w-32 shrink-0 text-sm font-semibold text-text-main text-right",children:"Current"}),(0,d.jsx)("span",{className:"material-symbols-outlined text-text-muted text-[14px]",children:"arrow_forward"}),(0,d.jsx)("span",{className:"flex-1 px-2 py-1.5 text-xs text-text-muted truncate",children:n.config.provider["9router"].options.baseURL})]}),(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)("span",{className:"w-32 shrink-0 text-sm font-semibold text-text-main text-right",children:"Base URL"}),(0,d.jsx)("span",{className:"material-symbols-outlined text-text-muted text-[14px]",children:"arrow_forward"}),(0,d.jsx)("input",{type:"text",value:K||`${h}/v1`,onChange:a=>L(a.target.value),placeholder:"https://.../v1",className:"flex-1 px-2 py-1.5 bg-surface rounded border border-border text-xs focus:outline-none focus:ring-1 focus:ring-primary/50"}),K&&K!==`${h}/v1`&&(0,d.jsx)("button",{onClick:()=>L(""),className:"p-1 text-text-muted hover:text-primary rounded transition-colors",title:"Reset to default",children:(0,d.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"restart_alt"})})]}),(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)("span",{className:"w-32 shrink-0 text-sm font-semibold text-text-main text-right",children:"API Key"}),(0,d.jsx)("span",{className:"material-symbols-outlined text-text-muted text-[14px]",children:"arrow_forward"}),i.length>0?(0,d.jsx)("select",{value:A,onChange:a=>B(a.target.value),className:"flex-1 px-2 py-1.5 bg-surface rounded text-xs border border-border focus:outline-none focus:ring-1 focus:ring-primary/50",children:i.map(a=>(0,d.jsx)("option",{value:a.key,children:a.key},a.id))}):(0,d.jsx)("span",{className:"flex-1 text-xs text-text-muted px-2 py-1.5",children:k?"No API keys - Create one in Keys page":"sk_9router (default)"})]}),(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)("span",{className:"w-32 shrink-0 text-sm font-semibold text-text-main text-right",children:"Model"}),(0,d.jsx)("span",{className:"material-symbols-outlined text-text-muted text-[14px]",children:"arrow_forward"}),(0,d.jsx)("input",{type:"text",value:C,onChange:a=>D(a.target.value),placeholder:"provider/model-id",className:"flex-1 px-2 py-1.5 bg-surface rounded border border-border text-xs focus:outline-none focus:ring-1 focus:ring-primary/50"}),(0,d.jsx)("button",{onClick:()=>F(!0),disabled:!j?.length,className:`px-2 py-1.5 rounded border text-xs transition-colors shrink-0 whitespace-nowrap ${j?.length?"bg-surface border-border text-text-main hover:border-primary cursor-pointer":"opacity-50 cursor-not-allowed border-border"}`,children:"Select Model"}),C&&(0,d.jsx)("button",{onClick:()=>D(""),className:"p-1 text-text-muted hover:text-red-500 rounded transition-colors",title:"Clear",children:(0,d.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"close"})})]})]}),w&&(0,d.jsxs)("div",{className:`flex items-center gap-2 px-2 py-1.5 rounded text-xs ${"success"===w.type?"bg-green-500/10 text-green-600":"bg-red-500/10 text-red-600"}`,children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"success"===w.type?"check_circle":"error"}),(0,d.jsx)("span",{children:w.text})]}),(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsxs)(f.$n,{variant:"primary",size:"sm",onClick:P,disabled:!C,loading:s,children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-[14px] mr-1",children:"save"}),"Apply"]}),(0,d.jsxs)(f.$n,{variant:"outline",size:"sm",onClick:Q,disabled:!n.has9Router,loading:u,children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-[14px] mr-1",children:"restore"}),"Reset"]}),(0,d.jsxs)(f.$n,{variant:"ghost",size:"sm",onClick:()=>J(!0),children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-[14px] mr-1",children:"content_copy"}),"Manual Config"]})]})]})]}),(0,d.jsx)(f.rq,{isOpen:E,onClose:()=>F(!1),onSelect:a=>{D(a.value),F(!1)},selectedModel:C,activeProviders:j,modelAliases:G,title:"Select Model for OpenCode"}),(0,d.jsx)(f.uR,{isOpen:I,onClose:()=>J(!1),title:"OpenCode - Manual Configuration",configs:(m=A&&A.trim()?A:k?"<API_KEY_FROM_DASHBOARD>":"sk_9router",[{filename:"~/.config/opencode/opencode.json",content:JSON.stringify({provider:{"9router":{npm:"@ai-sdk/openai-compatible",options:{baseURL:N(),apiKey:m},models:{[C||"provider/model-id"]:{name:C||"provider/model-id"}}}},model:`9router/${C||"provider/model-id"}`},null,2)}])})]})}let p="http://localhost:20128";function q({apiKeys:a,cloudEnabled:b,onStatusChange:c}){let[g,h]=(0,e.useState)(null),[i,j]=(0,e.useState)(!1),[k,l]=(0,e.useState)(!1),[m,n]=(0,e.useState)(""),[o,r]=(0,e.useState)(""),[s,t]=(0,e.useState)(null),[u,v]=(0,e.useState)(null),[w,x]=(0,e.useState)(null),[y,z]=(0,e.useState)(p),A="u">typeof navigator&&navigator.userAgent?.includes("Windows"),B=g?.isAdmin!==!1,C=async()=>{try{let a=await fetch("/api/cli-tools/antigravity-mitm");if(a.ok){let b=await a.json();h(b),b.mitmRouterBaseUrl&&z(b.mitmRouterBaseUrl),c?.(b)}}catch{h({running:!1,certExists:!1,dnsStatus:{}})}},D=a=>{A||g?.hasCachedPassword?E(a,""):(t(a),l(!0),v(null))},E=async(c,d)=>{j(!0),x(null);try{let e;if("trust-cert"===c)e=await fetch("/api/cli-tools/antigravity-mitm",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"trust-cert",sudoPassword:d})});else if("start"===c){let c=o?.trim()||(a?.length>0?a[0].key:null)||(b?null:"sk_9router");e=await fetch("/api/cli-tools/antigravity-mitm",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({apiKey:c,sudoPassword:d,mitmRouterBaseUrl:y.trim()||p})})}else e=await fetch("/api/cli-tools/antigravity-mitm",{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({sudoPassword:d})});let f=await e.json().catch(()=>({}));if(!e.ok)throw Error(f.error||"MITM action failed");l(!1),n(""),v(null),await C()}catch(b){let a=b?.message||"MITM action failed";x(a),k&&v(a)}finally{j(!1),t(null)}},F=()=>{m?E(s,m):v("Sudo password is required")},G=g?.running;return(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(f.Zp,{padding:"sm",className:"border-primary/20 bg-primary/5",children:(0,d.jsxs)("div",{className:"flex flex-col gap-3",children:[(0,d.jsxs)("div",{className:"flex items-center justify-between",children:[(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-primary text-[20px]",children:"security"}),(0,d.jsx)("span",{className:"font-semibold text-sm text-text-main",children:"MITM Server"}),G?(0,d.jsx)(f.Ex,{variant:"success",size:"sm",children:"Running"}):(0,d.jsx)(f.Ex,{variant:"default",size:"sm",children:"Stopped"})]}),(0,d.jsx)("div",{className:"flex items-center gap-1 text-xs text-text-muted","data-i18n-skip":"true",children:[{label:"Cert",ok:g?.certExists},{label:"Trusted",ok:g?.certTrusted},{label:"Server",ok:G}].map(({label:a,ok:b})=>(0,d.jsxs)("span",{className:`flex items-center gap-0.5 px-1.5 py-0.5 rounded ${b?"text-green-600":"text-text-muted"}`,children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-[12px]",children:b?"check_circle":"cancel"}),a]},a))})]}),(0,d.jsxs)("div",{className:"px-2 py-2 rounded-lg bg-surface/50 border border-border/50 flex flex-col gap-2",children:[(0,d.jsxs)("p",{className:"text-[11px] text-text-muted leading-relaxed",children:[(0,d.jsx)("span",{className:"font-medium text-text-main",children:"Purpose:"})," Use Antigravity IDE & GitHub Copilot → with ANY provider/model from 9Router"]}),(0,d.jsxs)("p",{className:"text-[11px] text-text-muted leading-relaxed",children:[(0,d.jsx)("span",{className:"font-medium text-text-main",children:"How it works:"})," Antigravity/Copilot IDE request → DNS redirect to localhost:443 → MITM proxy intercepts → 9Router → response to Antigravity/Copilot"]})]}),(0,d.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)("span",{className:"w-32 shrink-0 text-sm font-semibold text-text-main text-right",children:"9Router Base URL"}),(0,d.jsx)("span",{className:"material-symbols-outlined text-text-muted text-[14px]",children:"arrow_forward"}),(0,d.jsx)("input",{type:"text",value:y,onChange:a=>z(a.target.value),placeholder:p,disabled:G,className:"flex-1 min-w-0 px-2 py-1.5 bg-surface rounded border border-border text-xs text-text-main focus:outline-none focus:ring-1 focus:ring-primary/50 disabled:opacity-50"})]}),!G&&(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)("span",{className:"w-32 shrink-0 text-sm font-semibold text-text-main text-right",children:"API Key"}),(0,d.jsx)("span",{className:"material-symbols-outlined text-text-muted text-[14px]",children:"arrow_forward"}),a?.length>0?(0,d.jsx)("select",{value:o,onChange:a=>r(a.target.value),className:"flex-1 min-w-0 px-2 py-1.5 bg-surface rounded text-xs border border-border text-text-main focus:outline-none focus:ring-1 focus:ring-primary/50",children:a.map(a=>(0,d.jsx)("option",{value:a.key,children:a.key},a.id))}):(0,d.jsx)("span",{className:"flex-1 px-2 py-1.5 text-xs text-text-muted",children:b?"No API keys — create one in Keys page":"sk_9router (default)"})]})]}),(0,d.jsxs)("div",{className:"flex items-center gap-2 flex-wrap","data-i18n-skip":"true",children:[g?.certExists&&!g?.certTrusted&&(0,d.jsxs)("button",{onClick:()=>D("trust-cert"),disabled:i,className:"px-4 py-1.5 rounded-lg bg-yellow-500/10 border border-yellow-500/30 text-yellow-600 font-medium text-xs flex items-center gap-1.5 hover:bg-yellow-500/20 transition-colors disabled:opacity-50",children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-[16px]",children:"verified_user"}),"Trust Cert"]}),G?(0,d.jsxs)("button",{onClick:()=>D("stop"),disabled:i,className:"px-4 py-1.5 rounded-lg bg-red-500/10 border border-red-500/30 text-red-500 font-medium text-xs flex items-center gap-1.5 hover:bg-red-500/20 transition-colors disabled:opacity-50",children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-[16px]",children:"stop_circle"}),"Stop Server"]}):(0,d.jsxs)("button",{onClick:()=>D("start"),disabled:i||A&&!B,className:"px-4 py-1.5 rounded-lg bg-primary/10 border border-primary/30 text-primary font-medium text-xs flex items-center gap-1.5 hover:bg-primary/20 transition-colors disabled:opacity-50",children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-[16px]",children:"play_circle"}),"Start Server"]}),G&&(0,d.jsx)("p",{className:"text-xs text-text-muted",children:"Enable DNS per tool below to activate interception"})]}),w&&(0,d.jsxs)("div",{className:"flex items-center gap-2 px-2 py-1.5 rounded text-xs bg-red-500/10 text-red-600 border border-red-500/20",children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"error"}),(0,d.jsx)("span",{children:w})]}),A&&!B&&(0,d.jsxs)("div",{className:"flex items-center gap-2 px-2 py-1.5 rounded text-xs bg-red-500/10 text-red-600 border border-red-500/20",children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"shield_lock"}),(0,d.jsx)("span",{children:"Administrator required — restart 9Router as Administrator to use MITM"})]})]})}),k&&(0,d.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50 backdrop-blur-sm",children:(0,d.jsxs)("div",{className:"bg-surface border border-border rounded-xl p-6 w-full max-w-sm flex flex-col gap-4 shadow-xl",children:[(0,d.jsx)("h3",{className:"font-semibold text-text-main",children:"Sudo Password Required"}),(0,d.jsxs)("div",{className:"flex items-start gap-3 p-3 bg-yellow-500/10 border border-yellow-500/30 rounded-lg",children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-yellow-500 text-[20px]",children:"warning"}),(0,d.jsx)("p",{className:"text-xs text-text-muted",children:"Required for SSL certificate and server startup"})]}),(0,d.jsx)(f.pd,{type:"password",placeholder:"Enter sudo password",value:m,onChange:a=>n(a.target.value),onKeyDown:a=>{"Enter"!==a.key||i||F()}}),u&&(0,d.jsxs)("div",{className:"flex items-center gap-2 px-2 py-1.5 rounded text-xs bg-red-500/10 text-red-600",children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"error"}),(0,d.jsx)("span",{children:u})]}),(0,d.jsxs)("div",{className:"flex items-center justify-end gap-2",children:[(0,d.jsx)(f.$n,{variant:"ghost",size:"sm",onClick:()=>{l(!1),n(""),v(null)},disabled:i,children:"Cancel"}),(0,d.jsx)(f.$n,{variant:"primary",size:"sm",onClick:F,loading:i,children:"Confirm"})]})]})})]})}function r({tool:a,isExpanded:b,onToggle:c,serverRunning:h,dnsActive:i,hasCachedPassword:j,apiKeys:k,activeProviders:l,hasActiveProviders:m,modelAliases:n={},cloudEnabled:o,onDnsChange:p,tokenSwapActive:q=!1}){let[t,u]=(0,e.useState)(!1),[v,w]=(0,e.useState)(null),[x,y]=(0,e.useState)(!1),[z,A]=(0,e.useState)(""),[B,C]=(0,e.useState)(null),[D,E]=(0,e.useState)(null),[F,G]=(0,e.useState)({}),[H,I]=(0,e.useState)(!1),[J,K]=(0,e.useState)(null),L="u">typeof navigator&&navigator.userAgent?.includes("Windows"),M=(0,e.useCallback)(async b=>{try{await fetch("/api/cli-tools/antigravity-mitm/alias",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({tool:a.id,mappings:b})})}catch{}},[a.id]),N=(a,b)=>{G(c=>({...c,[a]:b}))},O=()=>{if(!h)return;let a=i?"disable":"enable";L||j?P(a,""):(C(a),y(!0),E(null))},P=async(b,c)=>{u(!0),w(null);try{let d=await fetch("/api/cli-tools/antigravity-mitm",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({tool:a.id,action:b,sudoPassword:c})}),e=await d.json();if(!d.ok)throw Error(e.error||"Failed to toggle DNS");"enable"===b&&w(`Restart ${a.name} to apply changes`),y(!1),A(""),p?.(e)}catch{}finally{u(!1),C(null)}},Q=()=>{z?P(B,z):E("Sudo password is required")};return(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)(f.Zp,{padding:"xs",className:"overflow-hidden",children:[(0,d.jsxs)("div",{className:"flex items-center justify-between hover:cursor-pointer",onClick:c,children:[(0,d.jsxs)("div",{className:"flex items-center gap-3",children:[(0,d.jsx)("div",{className:"size-8 flex items-center justify-center shrink-0",children:(0,d.jsx)(g.default,{src:a.image,alt:a.name,width:32,height:32,className:"size-8 object-contain rounded-lg",sizes:"32px",onError:a=>{a.target.style.display="none"}})}),(0,d.jsxs)("div",{className:"min-w-0",children:[(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)("h3",{className:"font-medium text-sm",children:a.name}),a.supportsTokenSwap&&(0,d.jsx)("span",{className:"text-[9px] uppercase tracking-wider text-text-muted bg-surface border border-border px-1.5 py-0.5 rounded font-semibold",children:"Mode A"}),h?q?(0,d.jsx)(f.Ex,{variant:"default",size:"sm",children:"Bypassed"}):i?(0,d.jsx)(f.Ex,{variant:"success",size:"sm",children:"Active"}):(0,d.jsx)(f.Ex,{variant:"warning",size:"sm",children:"DNS off"}):(0,d.jsx)(f.Ex,{variant:"default",size:"sm",children:"Server off"})]}),(0,d.jsx)("p",{className:"text-xs text-text-muted",children:"Model routing — remap model IDs in intercepted requests"})]})]}),(0,d.jsx)("span",{className:`material-symbols-outlined text-text-muted text-[20px] transition-transform ${b?"rotate-180":""}`,children:"expand_more"})]}),b&&(0,d.jsxs)("div",{className:"mt-4 pt-4 border-t border-border flex flex-col gap-4",children:[q&&(0,d.jsxs)("div",{className:"flex items-start gap-2 px-2 py-2 rounded-lg bg-violet-500/5 border border-violet-500/15",children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-[14px] text-violet-400 mt-0.5 shrink-0",children:"info"}),(0,d.jsx)("p",{className:"text-[11px] text-violet-400",children:"Token Rotation (Mode B) is active — model routing is currently bypassed. Disable Token Rotation to use model routing."})]}),"antigravity"===a.id&&(0,d.jsx)(s,{}),(0,d.jsxs)("div",{className:"flex flex-col gap-0.5 text-[11px] text-text-muted px-1",children:[(0,d.jsxs)("p",{children:["Toggle DNS to redirect ",a.name," traffic through 9Router via MITM."]}),!i&&(0,d.jsx)("p",{className:"text-amber-600 text-[10px] mt-1",children:"⚠️ Enable DNS to edit model mappings"})]}),a.defaultModels?.length>0&&(0,d.jsx)("div",{className:"flex flex-col gap-2",children:a.defaultModels.map(a=>(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)("span",{className:"w-36 shrink-0 text-xs font-semibold text-text-main text-right",children:a.name}),(0,d.jsx)("span",{className:"material-symbols-outlined text-text-muted text-[14px]",children:"arrow_forward"}),(0,d.jsx)("input",{type:"text",value:F[a.alias]||"",onChange:b=>N(a.alias,b.target.value),onBlur:b=>{var c,d;return c=a.alias,d=b.target.value,void M({...F,[c]:d})},placeholder:"provider/model-id",disabled:!i,className:`flex-1 px-2 py-1.5 bg-surface rounded border border-border text-xs focus:outline-none focus:ring-1 focus:ring-primary/50 ${!i?"opacity-50 cursor-not-allowed":""}`}),(0,d.jsx)("button",{onClick:()=>{K(a.alias),I(!0)},disabled:!m||!i,className:`px-2 py-1.5 rounded border text-xs transition-colors shrink-0 ${m&&i?"bg-surface border-border hover:border-primary cursor-pointer":"opacity-50 cursor-not-allowed border-border"}`,children:"Select"}),F[a.alias]&&(0,d.jsx)("button",{onClick:()=>{N(a.alias,""),M({...F,[a.alias]:""})},className:"p-1 text-text-muted hover:text-red-500 rounded transition-colors",title:"Clear",children:(0,d.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"close"})})]},a.alias))}),a.defaultModels?.length===0&&(0,d.jsx)("p",{className:"text-xs text-text-muted px-1",children:"Model mappings will be available soon."}),(0,d.jsxs)("div",{className:"flex flex-col gap-2 items-start",children:[i?(0,d.jsxs)("button",{onClick:O,disabled:!h||t,className:"px-4 py-1.5 rounded-lg bg-red-500/10 border border-red-500/30 text-red-500 font-medium text-xs flex items-center gap-1.5 hover:bg-red-500/20 transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-[16px]",children:"stop_circle"}),"Stop DNS"]}):(0,d.jsxs)("button",{onClick:O,disabled:!h||t,className:"px-4 py-1.5 rounded-lg bg-primary/10 border border-primary/30 text-primary font-medium text-xs flex items-center gap-1.5 hover:bg-primary/20 transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-[16px]",children:"play_circle"}),"Start DNS"]}),v&&(0,d.jsxs)("div",{className:"flex items-center gap-2 px-2 py-1.5 rounded text-xs text-amber-500",children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"warning"}),(0,d.jsx)("span",{children:v})]})]})]})]}),x&&(0,d.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50 backdrop-blur-sm",children:(0,d.jsxs)("div",{className:"bg-surface border border-border rounded-xl p-6 w-full max-w-sm flex flex-col gap-4 shadow-xl",children:[(0,d.jsx)("h3",{className:"font-semibold text-text-main",children:"Sudo Password Required"}),(0,d.jsxs)("div",{className:"flex items-start gap-3 p-3 bg-yellow-500/10 border border-yellow-500/30 rounded-lg",children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-yellow-500 text-[20px]",children:"warning"}),(0,d.jsx)("p",{className:"text-xs text-text-muted",children:"Required to modify /etc/hosts and flush DNS cache"})]}),(0,d.jsx)(f.pd,{type:"password",placeholder:"Enter sudo password",value:z,onChange:a=>A(a.target.value),onKeyDown:a=>{"Enter"!==a.key||t||Q()}}),D&&(0,d.jsxs)("div",{className:"flex items-center gap-2 px-2 py-1.5 rounded text-xs bg-red-500/10 text-red-600",children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"error"}),(0,d.jsx)("span",{children:D})]}),(0,d.jsxs)("div",{className:"flex items-center justify-end gap-2",children:[(0,d.jsx)(f.$n,{variant:"ghost",size:"sm",onClick:()=>{y(!1),A(""),E(null)},disabled:t,children:"Cancel"}),(0,d.jsx)(f.$n,{variant:"primary",size:"sm",onClick:Q,loading:t,children:"Confirm"})]})]})}),(0,d.jsx)(f.rq,{isOpen:H,onClose:()=>I(!1),onSelect:a=>{if(!J||a.isPlaceholder)return;let b={...F,[J]:a.value};G(b),M(b)},selectedModel:J?F[J]:null,activeProviders:l,modelAliases:n,title:`Select model for ${J}`})]})}function s(){let[a,b]=(0,e.useState)(null),[c,f]=(0,e.useState)(!1),[g,h]=(0,e.useState)(null),i=(0,e.useCallback)(async()=>{try{let a=await fetch("/api/antigravity-ide");a.ok&&b(await a.json())}catch{}},[]),j=async()=>{f(!0),h(null);try{let a=await fetch("/api/antigravity-ide",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"close"})}),b=await a.json();h(b),setTimeout(i,1e3)}catch(a){h({success:!1,error:a.message})}f(!1)};return(0,d.jsxs)("div",{className:"flex items-center gap-2 px-1",children:[(0,d.jsxs)("button",{onClick:j,disabled:c||!a?.running,className:"flex items-center gap-1.5 px-2.5 py-1.5 rounded-lg text-xs font-medium border border-red-500/30 text-red-500 bg-red-500/5 hover:bg-red-500/15 transition-colors disabled:opacity-50 disabled:cursor-not-allowed",title:a?.running?"Close all Antigravity IDE processes":"Antigravity IDE is not running",children:[(0,d.jsx)("span",{className:`material-symbols-outlined text-[14px] ${c?"animate-spin":""}`,children:c?"progress_activity":"close"}),c?"Closing…":"Close IDE"]}),a&&(0,d.jsxs)("span",{className:"flex items-center gap-1 text-[10px] text-text-muted",children:[(0,d.jsx)("span",{className:`inline-block w-1.5 h-1.5 rounded-full ${!a.installed?"bg-gray-400":a.running?"bg-green-500":"bg-red-400"}`}),a.installed?a.running?"Running":"Stopped":"Not installed"]}),g&&!c&&(0,d.jsxs)("span",{className:`text-[10px] ${g.success?"text-green-500":"text-red-400"}`,children:[g.success?"✓":"✗"," ",g.message||g.error]})]})}var t=c(2116),u=c.n(t);function v(a){if(null==a)return null;let b=String(a).trim();if(!b)return null;let c=b.toLowerCase();return c.includes("ultra")?"Ultra":c.includes("pro")?"Pro":c.includes("free")?"Free":null}["Free","Pro","Ultra"].map(a=>({value:a,label:a}));var w=c(4088);function x(a){if(!a||"string"!=typeof a)return a;let b=a.indexOf("@");if(b<=0||b===a.length-1)return a;let c=a.slice(0,b),d=a.slice(b+1);return 1===c.length?`${c[0]}**@${d}`:2===c.length?`${c[0]}**${c[1]}@${d}`:`${c[0]}**${c[c.length-1]}@${d}`}function y({tool:a,connections:b=[],serverRunning:c,dnsActive:g,onToggle:h,onRefreshConnections:i}){let[j,k]=(0,e.useState)(!1),[l,m]=(0,e.useState)(!1),[n,o]=(0,e.useState)("round-robin"),[p,q]=(0,e.useState)(!1),[r,s]=(0,e.useState)(!1),[t,z]=(0,e.useState)(!1),[A,B]=(0,e.useState)(null),[C,D]=(0,e.useState)(null),[E,F]=(0,e.useState)(!1),[G,H]=(0,e.useState)({}),I=(0,e.useRef)({});(0,e.useCallback)(async()=>{try{let a=await fetch("/api/settings");if(a.ok){let b=await a.json();k(!!b.tokenSwapEnabled),o(b.tokenSwapStrategy||"round-robin"),s(!!b.tokenSwapMaskEmails)}}catch{}},[]);let J=(0,e.useCallback)(async(b,c=!1)=>{if(!b||0===b.length)return;let d=Date.now(),e=[],f={};if(b.forEach(a=>{let b=I.current[a.id];!c&&b&&d-b.ts<12e4?f[a.id]={quotas:b.data,error:b.error,loading:!1,accountType:b.accountType||null}:e.push(a)}),Object.keys(f).length>0&&H(a=>({...a,...f})),0===e.length)return;let g={};e.forEach(a=>{g[a.id]={quotas:[],error:null,loading:!0}}),H(a=>({...a,...g})),await Promise.all(e.map(async b=>{try{let c=await fetch(`/api/usage/${b.id}`);if(!c.ok){let a=(await c.json().catch(()=>({}))).error||`HTTP ${c.status}`;I.current[b.id]={data:[],error:a,ts:Date.now(),accountType:null},H(c=>({...c,[b.id]:{quotas:[],error:a,loading:!1,accountType:null}}));return}let d=await c.json(),e=(0,w.W_)(a.tokenSwapProvider||"antigravity",d),f=function(a){if(!a)return null;if("string"==typeof a)return v(a);for(let b of[a.accountType,a.plan,a.paidTier?.name,a.subscriptionTier,a.subscription_tier,a.currentTier?.name,a.subscriptionInfo?.paidTier?.name,a.quota?.subscription_tier,a.subscriptionInfo?.currentTier?.name]){let a=v(b);if(a)return a}return null}(d);I.current[b.id]={data:e,error:null,ts:Date.now(),accountType:f},H(a=>({...a,[b.id]:{quotas:e,error:null,loading:!1,accountType:f}}))}catch(c){let a=c.message||"Failed";I.current[b.id]={data:[],error:a,ts:Date.now(),accountType:null},H(c=>({...c,[b.id]:{quotas:[],error:a,loading:!1,accountType:null}}))}}))},[a.tokenSwapProvider]);if(!a?.supportsTokenSwap)return null;let K=async()=>{m(!0);let a=!j;try{(await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({tokenSwapEnabled:a})})).ok&&(k(a),h?.(a))}catch{}m(!1)},L=async a=>{if(a!==n&&!p){q(!0);try{(await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({tokenSwapStrategy:a})})).ok&&o(a)}catch{}q(!1)}},M=async()=>{if(t)return;z(!0);let a=!r;try{(await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({tokenSwapMaskEmails:a})})).ok&&s(a)}catch{}z(!1)},N=b.filter(b=>b.provider===a.tokenSwapProvider),O=N.filter(a=>!1!==a.isActive),P=O.length;O.map(a=>a.id).join("|");let Q=a?.stickyRoundRobinLimit||3,R=function(a,b,c){if(!a||0===a.length)return null;if(1===a.length)return a[0].id;let d=[...a].sort((a,b)=>a.lastUsedAt||b.lastUsedAt?a.lastUsedAt?b.lastUsedAt?new Date(b.lastUsedAt)-new Date(a.lastUsedAt):-1:1:(a.priority||999)-(b.priority||999));if("sticky"===b)return d[0]?.id||null;let e=d[0],f=e?.consecutiveUseCount||0;if(e?.lastUsedAt&&f<c)return e.id;let g=[...a].sort((a,b)=>a.lastUsedAt||b.lastUsedAt?a.lastUsedAt?b.lastUsedAt?new Date(a.lastUsedAt)-new Date(b.lastUsedAt):1:-1:(a.priority||999)-(b.priority||999));return g[0]?.id||null}(O,n,Q),S=c&&g,T=j&&S&&P>0,U=async(a,b)=>{if(a&&!A&&!E&&!C){B(a);try{(await fetch(`/api/providers/${a}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({isActive:b})})).ok&&await i?.()}catch{}B(null)}},V=async a=>{if(a&&!C&&!E&&!A){D(a);try{(await fetch(`/api/providers/${a}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({lastUsedAt:null,consecutiveUseCount:0})})).ok&&await i?.()}catch{}D(null)}},W=async()=>{if(!E&&!C&&!A&&0!==N.length){F(!0);try{await Promise.all(N.map(a=>fetch(`/api/providers/${a.id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({lastUsedAt:null,consecutiveUseCount:0})}))),await i?.()}catch{}F(!1)}};return(0,d.jsxs)(f.Zp,{padding:"xs",className:"overflow-hidden",children:[(0,d.jsxs)("div",{className:"flex items-center justify-between",children:[(0,d.jsxs)("div",{className:"flex items-center gap-3",children:[(0,d.jsx)("div",{className:"size-8 flex items-center justify-center shrink-0 rounded-lg bg-violet-500/10",children:(0,d.jsx)("span",{className:"material-symbols-outlined text-violet-400 text-[18px]",children:"swap_horiz"})}),(0,d.jsxs)("div",{className:"min-w-0",children:[(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)("h3",{className:"font-medium text-sm",children:"Token Rotation"}),(0,d.jsx)("span",{className:"text-[9px] uppercase tracking-wider text-text-muted bg-surface border border-border px-1.5 py-0.5 rounded font-semibold",children:"Mode B"}),T?(0,d.jsx)(f.Ex,{variant:"success",size:"sm",children:"Active"}):j?(0,d.jsx)(f.Ex,{variant:"warning",size:"sm",children:"Enabled"}):(0,d.jsx)(f.Ex,{variant:"default",size:"sm",children:"Off"})]}),(0,d.jsx)("p",{className:"text-xs text-text-muted",children:"Rotate auth tokens across pool accounts to bypass per-account quota"})]})]}),(0,d.jsx)("button",{onClick:K,disabled:l,className:`relative inline-flex h-5 w-9 items-center rounded-full transition-colors shrink-0 ${j?"bg-violet-500":"bg-surface-alt border border-border"} ${l?"opacity-50":"cursor-pointer"}`,title:j?"Disable Token Rotation":"Enable Token Rotation",children:(0,d.jsx)("span",{className:`inline-block h-3.5 w-3.5 transform rounded-full bg-white transition-transform shadow-sm ${j?"translate-x-4":"translate-x-0.5"}`})})]}),j&&(0,d.jsxs)("div",{className:"mt-3 pt-3 border-t border-border/50 flex flex-col gap-3",children:[(0,d.jsxs)("div",{className:"flex items-start gap-2 px-2 py-2 rounded-lg bg-violet-500/5 border border-violet-500/15",children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-[14px] text-violet-400 mt-0.5 shrink-0",children:"info"}),(0,d.jsxs)("div",{className:"text-[11px] text-text-muted leading-relaxed",children:[(0,d.jsx)("p",{children:"Intercepts Antigravity requests → swaps IDE's auth token with a pool account → auto-retries on 429 quota error with next account in pool."}),(0,d.jsx)("p",{className:"mt-1 text-violet-400/80 font-medium",children:"⚠ When active, Model Routing (Mode A) is bypassed."})]})]}),(0,d.jsxs)("div",{className:"flex flex-col gap-1.5 px-1",children:[(0,d.jsx)("p",{className:"text-[10px] uppercase tracking-wider text-text-muted font-semibold",children:"Rotation Strategy"}),(0,d.jsxs)("div",{className:"flex gap-1.5",children:[(0,d.jsxs)("button",{onClick:()=>L("round-robin"),disabled:p,className:`flex-1 flex flex-col items-center gap-0.5 px-2 py-2 rounded-lg border text-[11px] font-medium transition-colors ${"round-robin"===n?"border-violet-500/50 bg-violet-500/10 text-violet-400":"border-border bg-surface text-text-muted hover:border-border-alt"} disabled:opacity-50`,children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"autorenew"}),"Round Robin"]}),(0,d.jsxs)("button",{onClick:()=>L("sticky"),disabled:p,className:`flex-1 flex flex-col items-center gap-0.5 px-2 py-2 rounded-lg border text-[11px] font-medium transition-colors ${"sticky"===n?"border-violet-500/50 bg-violet-500/10 text-violet-400":"border-border bg-surface text-text-muted hover:border-border-alt"} disabled:opacity-50`,children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"push_pin"}),"Sticky"]})]}),(0,d.jsx)("p",{className:"text-[10px] text-text-muted px-0.5",children:"sticky"===n?"Stays on the same account until its quota is exhausted for the requested model, then switches. Optimizes session-level token cache.":"Rotates accounts after each session (sticky round-robin). Distributes load evenly across the pool."})]}),(0,d.jsxs)("div",{className:"flex flex-col gap-1 px-1",children:[(0,d.jsx)("p",{className:"text-[10px] uppercase tracking-wider text-text-muted font-semibold mb-0.5",children:"Prerequisites"}),(0,d.jsxs)("div",{className:"flex items-center gap-2 text-xs",children:[(0,d.jsx)("span",{className:`material-symbols-outlined text-[14px] ${c?"text-green-500":"text-red-400"}`,children:c?"check_circle":"cancel"}),(0,d.jsx)("span",{className:c?"text-text-main":"text-text-muted",children:"MITM Server"})]}),(0,d.jsxs)("div",{className:"flex items-center gap-2 text-xs",children:[(0,d.jsx)("span",{className:`material-symbols-outlined text-[14px] ${g?"text-green-500":"text-red-400"}`,children:g?"check_circle":"cancel"}),(0,d.jsxs)("span",{className:g?"text-text-main":"text-text-muted",children:["DNS redirect",!g&&(0,d.jsx)("span",{className:"text-[10px] text-text-muted ml-1",children:"— enable via Antigravity card above"})]})]})]}),(0,d.jsxs)("div",{className:"flex flex-col gap-1 px-1",children:[(0,d.jsxs)("div",{className:"flex items-center justify-between mb-0.5",children:[(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)("p",{className:"text-[10px] uppercase tracking-wider text-text-muted font-semibold",children:"Pool Accounts"}),(0,d.jsx)("span",{className:"text-[10px] text-text-muted",children:N.length>0?`${P}/${N.length} active`:"none"}),P>1&&(0,d.jsx)("span",{className:"text-[9px] text-text-muted bg-surface border border-border px-1 py-0.5 rounded",children:"round-robin"})]}),(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[P>0&&(0,d.jsx)("button",{onClick:()=>J(O,!0),className:"text-[10px] text-text-muted hover:text-primary flex items-center gap-0.5 transition-colors",title:"Refresh quotas",children:(0,d.jsx)("span",{className:"material-symbols-outlined text-[12px]",children:"refresh"})}),N.length>0&&(0,d.jsxs)("button",{onClick:W,disabled:E||!!C,className:"text-[10px] text-text-muted hover:text-primary disabled:opacity-50 flex items-center gap-0.5 transition-colors",title:"Reset all streak counts",children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-[12px]",children:"restart_alt"}),"Reset all"]})]})]}),(0,d.jsxs)("p",{className:"text-[10px] text-text-muted px-0.5",children:["Sticky round robin keeps the current account until its streak reaches ",Q,", then rotates to the least recently used account."]}),(0,d.jsxs)("div",{className:"flex items-center justify-between gap-3 px-2 py-2 rounded-lg border border-border bg-surface-alt/40",children:[(0,d.jsxs)("div",{className:"min-w-0",children:[(0,d.jsx)("p",{className:"text-[11px] font-medium text-text-main",children:"Mask account emails"}),(0,d.jsxs)("p",{className:"text-[10px] text-text-muted",children:["Hide pool account emails in token swap logs and this panel. Example: ",x("email@gmail.com")]})]}),(0,d.jsx)("button",{onClick:M,disabled:t,className:`relative inline-flex h-5 w-9 items-center rounded-full transition-colors shrink-0 ${r?"bg-violet-500":"bg-surface border border-border"} ${t?"opacity-50":"cursor-pointer"}`,title:r?"Disable email masking":"Enable email masking",children:(0,d.jsx)("span",{className:`inline-block h-3.5 w-3.5 transform rounded-full bg-white transition-transform shadow-sm ${r?"translate-x-4":"translate-x-0.5"}`})})]}),N.length>0?(0,d.jsxs)(d.Fragment,{children:[N.map(a=>{let b=v(G[a.id]?.accountType)||v(a.accountType)||null;return(0,d.jsxs)("div",{className:`rounded-xl border border-border bg-surface-alt/30 px-3 py-2.5 transition-colors ${!1===a.isActive?"opacity-65":"hover:bg-surface-alt/50"}`,children:[(0,d.jsxs)("div",{className:"flex items-start justify-between gap-3",children:[(0,d.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,d.jsxs)("div",{className:"flex items-center gap-2 min-w-0",children:[(0,d.jsx)("span",{className:`material-symbols-outlined text-[14px] shrink-0 ${!1===a.isActive?"text-text-muted":"text-green-500"}`,children:!1===a.isActive?"pause_circle":"check_circle"}),(0,d.jsx)("span",{className:"text-xs font-medium text-text-main truncate",children:a.email?r?x(a.email):a.email:a.name||a.id.slice(0,16)}),b&&(0,d.jsx)(f.Ex,{variant:"Ultra"===b?"warning":"Pro"===b?"primary":"Free"===b?"info":"default",size:"sm",children:b}),R===a.id&&!1!==a.isActive&&(0,d.jsx)("span",{className:"text-[9px] text-violet-300 bg-violet-500/10 border border-violet-500/20 px-1 py-0.5 rounded shrink-0",children:"next"}),(0,d.jsx)(f.Ex,{variant:!1===a.isActive?"default":"success",size:"sm",children:!1===a.isActive?"disabled":"active"})]}),(0,d.jsxs)("div",{className:"mt-1 flex items-center gap-2 flex-wrap text-[10px] text-text-muted",children:[(0,d.jsxs)("span",{children:["Priority #",a.priority??"-"]}),(0,d.jsxs)("span",{children:["Streak ",a.consecutiveUseCount||0,"/",Q]}),a.lastUsedAt&&(0,d.jsxs)("span",{children:["Last used ",new Date(a.lastUsedAt).toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit"})]})]})]}),(0,d.jsxs)("div",{className:"flex items-center gap-3 shrink-0",children:[(0,d.jsx)("button",{onClick:()=>V(a.id),disabled:E||A===a.id||C===a.id,className:"text-[10px] text-text-muted hover:text-primary disabled:opacity-50 transition-colors",title:"Reset this account streak",children:C===a.id?"...":"Reset Streak"}),(0,d.jsx)(f.lM,{size:"sm",checked:!1!==a.isActive,disabled:E||C===a.id||A===a.id,onChange:b=>U(a.id,b)})]})]}),(0,d.jsx)("div",{className:"mt-2 pl-6",children:!1===a.isActive?(0,d.jsx)("div",{className:"text-[10px] text-text-muted",children:"Enable this account to include it in token rotation and load quota reset info."}):(a=>{let b=(a=>{let b=G[a];if(!b)return{state:"empty"};if(b.loading)return{state:"loading"};if(b.error)return{state:"error",error:b.error};if(!b.quotas||0===b.quotas.length)return{state:"no-data"};let c=b.quotas.find(a=>a.modelKey?.includes("claude-sonnet-4-6")||a.name?.toLowerCase().includes("opus"))||b.quotas[0];if(!c)return{state:"no-data"};let d=void 0!==c.remainingPercentage?Math.round(c.remainingPercentage):c.total>0?Math.round((c.total-c.used)/c.total*100):null,e=(c.resetAt&&new Date(c.resetAt).getTime()>Date.now()?c.resetAt:null)||[...b.quotas].map(a=>a.resetAt).filter(Boolean).filter(a=>new Date(a).getTime()>Date.now()).sort((a,b)=>new Date(a).getTime()-new Date(b).getTime())[0]||null;return{state:null===d?"no-data":"ready",highlight:c,accountType:b.accountType||null,pct:d,nextResetAt:e,resetCountdown:(0,w.mO)(e),resetDisplay:(0,w.sQ)(e)}})(a);if(!b||"empty"===b.state)return(0,d.jsx)("span",{className:"text-[10px] text-text-muted",children:"Enable to load quota data"});if("loading"===b.state)return(0,d.jsx)("span",{className:"text-[10px] text-text-muted animate-pulse",children:"Loading quota…"});if("error"===b.state)return(0,d.jsx)("span",{className:"text-[10px] text-red-400",title:b.error,children:"Quota unavailable"});if("no-data"===b.state)return(0,d.jsx)("span",{className:"text-[10px] text-text-muted",children:"No quota data"});let{highlight:c,pct:e,resetCountdown:f,resetDisplay:g}=b;return(0,d.jsxs)("div",{className:"flex flex-col gap-1.5 min-w-0",children:[(0,d.jsxs)("div",{className:"flex items-center gap-2 min-w-0",children:[(0,d.jsx)("span",{className:"text-[10px] text-text-muted truncate",children:c.name}),(0,d.jsx)("div",{className:"flex-1 h-1.5 rounded-full bg-surface-alt overflow-hidden min-w-[56px]",children:(0,d.jsx)("div",{className:`h-full rounded-full ${e>70?"bg-green-500":e>=30?"bg-yellow-500":"bg-red-500"}`,style:{width:`${Math.min(e,100)}%`}})}),(0,d.jsxs)("span",{className:`text-[10px] font-medium shrink-0 ${e>70?"text-green-500":e>=30?"text-yellow-500":"text-red-500"}`,children:[e,"%"]})]}),"-"!==f&&g?(0,d.jsxs)("div",{className:"text-[10px] text-text-muted",children:["Reset in ",(0,d.jsx)("span",{className:"text-text-main",children:f}),(0,d.jsxs)("span",{className:"text-text-muted/70",children:[" • ",g]})]}):(0,d.jsx)("div",{className:"text-[10px] text-text-muted",children:"Reset time unavailable"})]})})(a.id)})]},a.id)}),(0,d.jsxs)(u(),{href:"/dashboard/providers",className:"text-[11px] text-primary hover:underline flex items-center gap-1 px-1 mt-1",children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-[12px]",children:"open_in_new"}),"Manage accounts"]})]}):(0,d.jsx)("div",{className:"px-1",children:(0,d.jsxs)("p",{className:"text-xs text-text-muted",children:["No active ",a.name," accounts in pool."," ",(0,d.jsx)(u(),{href:"/dashboard/providers",className:"text-primary hover:underline",children:"Add account →"})]})})]}),!S&&(0,d.jsxs)("div",{className:"flex items-center gap-2 px-2 py-1.5 rounded text-xs bg-amber-500/10 text-amber-600 border border-amber-500/20",children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"warning"}),(0,d.jsx)("span",{children:"Start MITM server and enable DNS to activate token rotation"})]})]})]})}}};
|
|
15
|
+
`},{filename:"~/.codex/auth.json",content:JSON.stringify({OPENAI_API_KEY:p},null,2)}])})]})}let k="https://9router.com";function l({tool:a,isExpanded:b,onToggle:c,baseUrl:h,hasActiveProviders:i,apiKeys:j,activeProviders:m,cloudEnabled:n,initialStatus:o}){let p,q,r,s,[t,u]=(0,e.useState)(o||null),[v,w]=(0,e.useState)(!1),[x,y]=(0,e.useState)(!1),[z,A]=(0,e.useState)(!1),[B,C]=(0,e.useState)(null),[D,E]=(0,e.useState)(""),[F,G]=(0,e.useState)(""),[H,I]=(0,e.useState)(!1),[J,K]=(0,e.useState)({}),[L,M]=(0,e.useState)(!1),[N,O]=(0,e.useState)("");(0,e.useRef)(!1);let P=(()=>{if(!t?.installed)return null;let a=t.settings?.customModels?.find(a=>"custom:9Router-0"===a.id);if(!a)return"not_configured";let b=a.baseUrl?.includes("localhost")||a.baseUrl?.includes("127.0.0.1"),c=n&&k&&a.baseUrl?.startsWith(k),d=h&&a.baseUrl?.startsWith(h);return b||c||d?"configured":"other"})(),Q=async()=>{w(!0);try{let a=await fetch("/api/cli-tools/droid-settings"),b=await a.json();u(b)}catch(a){u({installed:!1,error:a.message})}finally{w(!1)}},R=()=>{let a=N||h;return a.endsWith("/v1")?a:`${a}/v1`},S=async()=>{y(!0),C(null);try{let a=D?.trim()||(j?.length>0?j[0].key:null)||(n?null:"sk_9router"),b=await fetch("/api/cli-tools/droid-settings",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({baseUrl:R(),apiKey:a,model:F})}),c=await b.json();b.ok?(C({type:"success",text:"Settings applied successfully!"}),Q()):C({type:"error",text:c.error||"Failed to apply settings"})}catch(a){C({type:"error",text:a.message})}finally{y(!1)}},T=async()=>{A(!0),C(null);try{let a=await fetch("/api/cli-tools/droid-settings",{method:"DELETE"}),b=await a.json();a.ok?(C({type:"success",text:"Settings reset successfully!"}),G(""),E(""),Q()):C({type:"error",text:b.error||"Failed to reset settings"})}catch(a){C({type:"error",text:a.message})}finally{A(!1)}};return(0,d.jsxs)(f.Zp,{padding:"xs",className:"overflow-hidden",children:[(0,d.jsxs)("div",{className:"flex items-center justify-between hover:cursor-pointer",onClick:c,children:[(0,d.jsxs)("div",{className:"flex items-center gap-3",children:[(0,d.jsx)("div",{className:"size-8 flex items-center justify-center shrink-0",children:(0,d.jsx)(g.default,{src:"/providers/droid.png",alt:a.name,width:32,height:32,className:"size-8 object-contain rounded-lg",sizes:"32px",onError:a=>{a.target.style.display="none"}})}),(0,d.jsxs)("div",{className:"min-w-0",children:[(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)("h3",{className:"font-medium text-sm",children:a.name}),"configured"===P&&(0,d.jsx)("span",{className:"px-1.5 py-0.5 text-[10px] font-medium bg-green-500/10 text-green-600 dark:text-green-400 rounded-full",children:"Connected"}),"not_configured"===P&&(0,d.jsx)("span",{className:"px-1.5 py-0.5 text-[10px] font-medium bg-yellow-500/10 text-yellow-600 dark:text-yellow-400 rounded-full",children:"Not configured"}),"other"===P&&(0,d.jsx)("span",{className:"px-1.5 py-0.5 text-[10px] font-medium bg-blue-500/10 text-blue-600 dark:text-blue-400 rounded-full",children:"Other"})]}),(0,d.jsx)("p",{className:"text-xs text-text-muted truncate",children:a.description})]})]}),(0,d.jsx)("span",{className:`material-symbols-outlined text-text-muted text-[20px] transition-transform ${b?"rotate-180":""}`,children:"expand_more"})]}),b&&(0,d.jsxs)("div",{className:"mt-4 pt-4 border-t border-border flex flex-col gap-4",children:[v&&(0,d.jsxs)("div",{className:"flex items-center gap-2 text-text-muted",children:[(0,d.jsx)("span",{className:"material-symbols-outlined animate-spin",children:"progress_activity"}),(0,d.jsx)("span",{children:"Checking Factory Droid CLI..."})]}),!v&&t&&!t.installed&&(0,d.jsxs)("div",{className:"flex items-center gap-3 p-4 bg-yellow-500/10 border border-yellow-500/30 rounded-lg",children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-yellow-500",children:"warning"}),(0,d.jsxs)("div",{className:"flex-1",children:[(0,d.jsx)("p",{className:"font-medium text-yellow-600 dark:text-yellow-400",children:"Factory Droid CLI not installed"}),(0,d.jsx)("p",{className:"text-sm text-text-muted",children:"Please install Factory Droid CLI to use this feature."})]})]}),!v&&t?.installed&&(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)("div",{className:"flex flex-col gap-2",children:[t?.settings?.customModels?.find(a=>"custom:9Router-0"===a.id)?.baseUrl&&(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)("span",{className:"w-32 shrink-0 text-sm font-semibold text-text-main text-right",children:"Current"}),(0,d.jsx)("span",{className:"material-symbols-outlined text-text-muted text-[14px]",children:"arrow_forward"}),(0,d.jsx)("span",{className:"flex-1 px-2 py-1.5 text-xs text-text-muted truncate",children:t.settings.customModels.find(a=>"custom:9Router-0"===a.id).baseUrl})]}),(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)("span",{className:"w-32 shrink-0 text-sm font-semibold text-text-main text-right",children:"Base URL"}),(0,d.jsx)("span",{className:"material-symbols-outlined text-text-muted text-[14px]",children:"arrow_forward"}),(0,d.jsx)("input",{type:"text",value:(p=N||h).endsWith("/v1")?p:`${p}/v1`,onChange:a=>O(a.target.value),placeholder:"https://.../v1",className:"flex-1 px-2 py-1.5 bg-surface rounded border border-border text-xs focus:outline-none focus:ring-1 focus:ring-primary/50"}),N&&N!==h&&(0,d.jsx)("button",{onClick:()=>O(""),className:"p-1 text-text-muted hover:text-primary rounded transition-colors",title:"Reset to default",children:(0,d.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"restart_alt"})})]}),(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)("span",{className:"w-32 shrink-0 text-sm font-semibold text-text-main text-right",children:"API Key"}),(0,d.jsx)("span",{className:"material-symbols-outlined text-text-muted text-[14px]",children:"arrow_forward"}),j.length>0?(0,d.jsx)("select",{value:D,onChange:a=>E(a.target.value),className:"flex-1 px-2 py-1.5 bg-surface rounded text-xs border border-border focus:outline-none focus:ring-1 focus:ring-primary/50",children:j.map(a=>(0,d.jsx)("option",{value:a.key,children:a.key},a.id))}):(0,d.jsx)("span",{className:"flex-1 text-xs text-text-muted px-2 py-1.5",children:n?"No API keys - Create one in Keys page":"sk_9router (default)"})]}),(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)("span",{className:"w-32 shrink-0 text-sm font-semibold text-text-main text-right",children:"Model"}),(0,d.jsx)("span",{className:"material-symbols-outlined text-text-muted text-[14px]",children:"arrow_forward"}),(0,d.jsx)("input",{type:"text",value:F,onChange:a=>G(a.target.value),placeholder:"provider/model-id",className:"flex-1 px-2 py-1.5 bg-surface rounded border border-border text-xs focus:outline-none focus:ring-1 focus:ring-primary/50"}),(0,d.jsx)("button",{onClick:()=>I(!0),disabled:!i,className:`px-2 py-1.5 rounded border text-xs transition-colors shrink-0 whitespace-nowrap ${i?"bg-surface border-border text-text-main hover:border-primary cursor-pointer":"opacity-50 cursor-not-allowed border-border"}`,children:"Select Model"}),F&&(0,d.jsx)("button",{onClick:()=>G(""),className:"p-1 text-text-muted hover:text-red-500 rounded transition-colors",title:"Clear",children:(0,d.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"close"})})]})]}),B&&(0,d.jsxs)("div",{className:`flex items-center gap-2 px-2 py-1.5 rounded text-xs ${"success"===B.type?"bg-green-500/10 text-green-600":"bg-red-500/10 text-red-600"}`,children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"success"===B.type?"check_circle":"error"}),(0,d.jsx)("span",{children:B.text})]}),(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsxs)(f.$n,{variant:"primary",size:"sm",onClick:S,disabled:!F,loading:x,children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-[14px] mr-1",children:"save"}),"Apply"]}),(0,d.jsxs)(f.$n,{variant:"outline",size:"sm",onClick:T,disabled:!t?.has9Router,loading:z,children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-[14px] mr-1",children:"restore"}),"Reset"]}),(0,d.jsxs)(f.$n,{variant:"ghost",size:"sm",onClick:()=>M(!0),children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-[14px] mr-1",children:"content_copy"}),"Manual Config"]})]})]})]}),(0,d.jsx)(f.rq,{isOpen:H,onClose:()=>I(!1),onSelect:a=>{G(a.value),I(!1)},selectedModel:F,activeProviders:m,modelAliases:J,title:"Select Model for Factory Droid"}),(0,d.jsx)(f.uR,{isOpen:L,onClose:()=>M(!1),title:"Factory Droid - Manual Configuration",configs:(q=D&&D.trim()?D:n?"<API_KEY_FROM_DASHBOARD>":"sk_9router",r={customModels:[{model:F||"provider/model-id",id:"custom:9Router-0",index:0,baseUrl:R(),apiKey:q,displayName:F||"provider/model-id",maxOutputTokens:131072,noImageSupport:!1,provider:"openai"}]},s="u">typeof navigator&&navigator.platform,[{filename:s?.toLowerCase().includes("win")?"%USERPROFILE%\\.factory\\settings.json":"~/.factory/settings.json",content:JSON.stringify(r,null,2)}])})]})}function m({tool:a,isExpanded:b,onToggle:c,baseUrl:h,hasActiveProviders:i,apiKeys:j,activeProviders:k,cloudEnabled:l,initialStatus:n}){let o,p,[q,r]=(0,e.useState)(n||null),[s,t]=(0,e.useState)(!1),[u,v]=(0,e.useState)(!1),[w,x]=(0,e.useState)(!1),[y,z]=(0,e.useState)(null),[A,B]=(0,e.useState)(""),[C,D]=(0,e.useState)(""),[E,F]=(0,e.useState)({}),[G,H]=(0,e.useState)(null),[I,J]=(0,e.useState)(!1),[K,L]=(0,e.useState)({}),[M,N]=(0,e.useState)(!1),[O,P]=(0,e.useState)("");(0,e.useRef)(!1);let Q=(()=>{if(!q?.installed)return null;let a=q.settings?.models?.providers?.["9router"];if(!a)return"not_configured";let b=a.baseUrl?.includes("localhost")||a.baseUrl?.includes("127.0.0.1")||a.baseUrl?.includes("0.0.0.0"),c=h&&a.baseUrl?.startsWith(h);return b||c?"configured":"other"})(),R=async()=>{t(!0);try{let a=await fetch("/api/cli-tools/openclaw-settings"),b=await a.json();r(b)}catch(a){r({installed:!1,error:a.message})}finally{t(!1)}},S=()=>{let a=O||"http://127.0.0.1:20128";return a.endsWith("/v1")?a:`${a}/v1`},T=async()=>{v(!0),z(null);try{let a=A?.trim()||(j?.length>0?j[0].key:null)||(l?null:"sk_9router"),b=await fetch("/api/cli-tools/openclaw-settings",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({baseUrl:S(),apiKey:a,model:C,agentModels:E})}),c=await b.json();b.ok?(z({type:"success",text:"Settings applied successfully!"}),R()):z({type:"error",text:c.error||"Failed to apply settings"})}catch(a){z({type:"error",text:a.message})}finally{v(!1)}},U=async()=>{x(!0),z(null);try{let a=await fetch("/api/cli-tools/openclaw-settings",{method:"DELETE"}),b=await a.json();a.ok?(z({type:"success",text:"Settings reset successfully!"}),D(""),B(""),R()):z({type:"error",text:b.error||"Failed to reset settings"})}catch(a){z({type:"error",text:a.message})}finally{x(!1)}};return(0,d.jsxs)(f.Zp,{padding:"xs",className:"overflow-hidden",children:[(0,d.jsxs)("div",{className:"flex items-center justify-between hover:cursor-pointer",onClick:c,children:[(0,d.jsxs)("div",{className:"flex items-center gap-3",children:[(0,d.jsx)("div",{className:"size-8 flex items-center justify-center shrink-0",children:(0,d.jsx)(g.default,{src:"/providers/openclaw.png",alt:a.name,width:32,height:32,className:"size-8 object-contain rounded-lg",sizes:"32px",onError:a=>{a.target.style.display="none"}})}),(0,d.jsxs)("div",{className:"min-w-0",children:[(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)("h3",{className:"font-medium text-sm",children:a.name}),"configured"===Q&&(0,d.jsx)("span",{className:"px-1.5 py-0.5 text-[10px] font-medium bg-green-500/10 text-green-600 dark:text-green-400 rounded-full",children:"Connected"}),"not_configured"===Q&&(0,d.jsx)("span",{className:"px-1.5 py-0.5 text-[10px] font-medium bg-yellow-500/10 text-yellow-600 dark:text-yellow-400 rounded-full",children:"Not configured"}),"other"===Q&&(0,d.jsx)("span",{className:"px-1.5 py-0.5 text-[10px] font-medium bg-blue-500/10 text-blue-600 dark:text-blue-400 rounded-full",children:"Other"})]}),(0,d.jsx)("p",{className:"text-xs text-text-muted truncate",children:a.description})]})]}),(0,d.jsx)("span",{className:`material-symbols-outlined text-text-muted text-[20px] transition-transform ${b?"rotate-180":""}`,children:"expand_more"})]}),b&&(0,d.jsxs)("div",{className:"mt-4 pt-4 border-t border-border flex flex-col gap-4",children:[s&&(0,d.jsxs)("div",{className:"flex items-center gap-2 text-text-muted",children:[(0,d.jsx)("span",{className:"material-symbols-outlined animate-spin",children:"progress_activity"}),(0,d.jsx)("span",{children:"Checking Open Claw CLI..."})]}),!s&&q&&!q.installed&&(0,d.jsxs)("div",{className:"flex items-center gap-3 p-4 bg-yellow-500/10 border border-yellow-500/30 rounded-lg",children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-yellow-500",children:"warning"}),(0,d.jsxs)("div",{className:"flex-1",children:[(0,d.jsx)("p",{className:"font-medium text-yellow-600 dark:text-yellow-400",children:"Open Claw CLI not installed"}),(0,d.jsx)("p",{className:"text-sm text-text-muted",children:"Please install Open Claw CLI to use this feature."})]})]}),!s&&q?.installed&&(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)("div",{className:"flex flex-col gap-2",children:[q?.settings?.models?.providers?.["9router"]?.baseUrl&&(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)("span",{className:"w-32 shrink-0 text-sm font-semibold text-text-main text-right",children:"Current"}),(0,d.jsx)("span",{className:"material-symbols-outlined text-text-muted text-[14px]",children:"arrow_forward"}),(0,d.jsx)("span",{className:"flex-1 px-2 py-1.5 text-xs text-text-muted truncate",children:q.settings.models.providers["9router"].baseUrl})]}),(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)("span",{className:"w-32 shrink-0 text-sm font-semibold text-text-main text-right",children:"Base URL"}),(0,d.jsx)("span",{className:"material-symbols-outlined text-text-muted text-[14px]",children:"arrow_forward"}),(0,d.jsx)("input",{type:"text",value:(o=O||"http://127.0.0.1:20128").endsWith("/v1")?o:`${o}/v1`,onChange:a=>P(a.target.value),placeholder:"https://.../v1",className:"flex-1 px-2 py-1.5 bg-surface rounded border border-border text-xs focus:outline-none focus:ring-1 focus:ring-primary/50"}),O&&O!==h&&(0,d.jsx)("button",{onClick:()=>P(""),className:"p-1 text-text-muted hover:text-primary rounded transition-colors",title:"Reset to default",children:(0,d.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"restart_alt"})})]}),(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)("span",{className:"w-32 shrink-0 text-sm font-semibold text-text-main text-right",children:"API Key"}),(0,d.jsx)("span",{className:"material-symbols-outlined text-text-muted text-[14px]",children:"arrow_forward"}),j.length>0?(0,d.jsx)("select",{value:A,onChange:a=>B(a.target.value),className:"flex-1 px-2 py-1.5 bg-surface rounded text-xs border border-border focus:outline-none focus:ring-1 focus:ring-primary/50",children:j.map(a=>(0,d.jsx)("option",{value:a.key,children:a.key},a.id))}):(0,d.jsx)("span",{className:"flex-1 text-xs text-text-muted px-2 py-1.5",children:l?"No API keys - Create one in Keys page":"sk_9router (default)"})]}),(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)("span",{className:"w-32 shrink-0 text-sm font-semibold text-text-main text-right",children:"Default Model"}),(0,d.jsx)("span",{className:"material-symbols-outlined text-text-muted text-[14px]",children:"arrow_forward"}),(0,d.jsx)("input",{type:"text",value:C,onChange:a=>D(a.target.value),placeholder:"provider/model-id",className:"flex-1 px-2 py-1.5 bg-surface rounded border border-border text-xs focus:outline-none focus:ring-1 focus:ring-primary/50"}),(0,d.jsx)("button",{onClick:()=>{H(null),J(!0)},disabled:!i,className:`px-2 py-1.5 rounded border text-xs transition-colors shrink-0 whitespace-nowrap ${i?"bg-surface border-border text-text-main hover:border-primary cursor-pointer":"opacity-50 cursor-not-allowed border-border"}`,children:"Select"}),C&&(0,d.jsx)("button",{onClick:()=>D(""),className:"p-1 text-text-muted hover:text-red-500 rounded transition-colors",title:"Clear",children:(0,d.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"close"})})]}),(q.agents||[]).filter(a=>a.agentDir).map(a=>(0,d.jsxs)("div",{className:"flex items-center gap-2 pl-4",children:[(0,d.jsxs)("span",{className:"w-32 shrink-0 text-xs text-primary text-right truncate",title:a.name||a.id,children:["Agent ",a.name||a.id]}),(0,d.jsx)("span",{className:"material-symbols-outlined text-text-muted text-[14px]",children:"arrow_forward"}),(0,d.jsx)("input",{type:"text",value:E[a.id]||"",onChange:b=>F(c=>({...c,[a.id]:b.target.value})),placeholder:`default (${C||"provider/model-id"})`,className:"flex-1 px-2 py-1.5 bg-surface rounded border border-border text-xs focus:outline-none focus:ring-1 focus:ring-primary/50"}),(0,d.jsx)("button",{onClick:()=>{H(a.id),J(!0)},disabled:!i,className:`px-2 py-1.5 rounded border text-xs transition-colors shrink-0 whitespace-nowrap ${i?"bg-surface border-border text-text-main hover:border-primary cursor-pointer":"opacity-50 cursor-not-allowed border-border"}`,children:"Select"}),E[a.id]&&(0,d.jsx)("button",{onClick:()=>F(b=>({...b,[a.id]:""})),className:"p-1 text-text-muted hover:text-red-500 rounded transition-colors",title:"Clear",children:(0,d.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"close"})})]},a.id))]}),y&&(0,d.jsxs)("div",{className:`flex items-center gap-2 px-2 py-1.5 rounded text-xs ${"success"===y.type?"bg-green-500/10 text-green-600":"bg-red-500/10 text-red-600"}`,children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"success"===y.type?"check_circle":"error"}),(0,d.jsx)("span",{children:y.text})]}),(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsxs)(f.$n,{variant:"primary",size:"sm",onClick:T,disabled:!C,loading:u,children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-[14px] mr-1",children:"save"}),"Apply"]}),(0,d.jsxs)(f.$n,{variant:"outline",size:"sm",onClick:U,disabled:!q?.has9Router,loading:w,children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-[14px] mr-1",children:"restore"}),"Reset"]}),(0,d.jsxs)(f.$n,{variant:"ghost",size:"sm",onClick:()=>N(!0),children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-[14px] mr-1",children:"content_copy"}),"Manual Config"]})]})]})]}),(0,d.jsx)(f.rq,{isOpen:I,onClose:()=>J(!1),onSelect:a=>{G?(F(b=>({...b,[G]:a.value})),H(null)):D(a.value),J(!1)},selectedModel:C,activeProviders:k,modelAliases:K,title:"Select Model for Open Claw"}),(0,d.jsx)(f.uR,{isOpen:M,onClose:()=>N(!1),title:"Open Claw - Manual Configuration",configs:(p=A&&A.trim()?A:l?"<API_KEY_FROM_DASHBOARD>":"sk_9router",[{filename:"~/.openclaw/openclaw.json",content:JSON.stringify({agents:{defaults:{model:{primary:`9router/${C||"provider/model-id"}`}}},models:{providers:{"9router":{baseUrl:S(),apiKey:p,api:"openai-completions",models:[{id:C||"provider/model-id",name:(C||"provider/model-id").split("/").pop()}]}}}},null,2)}])})]})}function n({toolId:a,tool:b,isExpanded:c,onToggle:h,baseUrl:i,apiKeys:j,activeProviders:k=[],cloudEnabled:l=!1,tunnelEnabled:m=!1}){let[o,p]=(0,e.useState)(null),[q,r]=(0,e.useState)(!1),[s,t]=(0,e.useState)(""),[u,v]=(0,e.useState)(()=>j?.length>0?j[0].key:""),w=a=>{let b=u&&u.trim()?u:l?"your-api-key":"sk_9router",c=i||"http://localhost:20128",d=c.endsWith("/v1")?c:`${c}/v1`;return a.replace(/\{\{baseUrl\}\}/g,d).replace(/\{\{apiKey\}\}/g,b).replace(/\{\{model\}\}/g,s||"provider/model-id")},x=async(a,b)=>{await navigator.clipboard.writeText(w(a)),p(b),setTimeout(()=>p(null),2e3)},y=k.length>0,z=()=>(!b.requiresExternalUrl||!!l||!!m)&&(!b.requiresCloud||!!l);return(0,d.jsxs)(f.Zp,{padding:"xs",className:"overflow-hidden",children:[(0,d.jsxs)("div",{className:"flex items-center justify-between hover:cursor-pointer",onClick:h,children:[(0,d.jsxs)("div",{className:"flex items-center gap-3",children:[(0,d.jsx)("div",{className:"size-8 rounded-lg flex items-center justify-center shrink-0",children:b.image?(0,d.jsx)(g.default,{src:b.image,alt:b.name,width:32,height:32,className:"size-8 object-contain rounded-lg",sizes:"32px",onError:a=>{a.target.style.display="none"}}):b.icon?(0,d.jsx)("span",{className:"material-symbols-outlined text-xl",style:{color:b.color},children:b.icon}):(0,d.jsx)(g.default,{src:`/providers/${a}.png`,alt:b.name,width:32,height:32,className:"size-8 object-contain rounded-lg",sizes:"32px",onError:a=>{a.target.style.display="none"}})}),(0,d.jsxs)("div",{className:"min-w-0",children:[(0,d.jsx)("h3",{className:"font-medium text-sm",children:b.name}),(0,d.jsx)("p",{className:"text-xs text-text-muted truncate",children:b.description})]})]}),(0,d.jsx)("span",{className:`material-symbols-outlined text-text-muted text-[20px] transition-transform ${c?"rotate-180":""}`,children:"expand_more"})]}),c&&(0,d.jsx)("div",{className:"mt-6 pt-6 border-t border-border",children:b.guideSteps?(0,d.jsxs)("div",{className:"flex flex-col gap-4",children:[b.notes&&0!==b.notes.length?(0,d.jsx)("div",{className:"flex flex-col gap-2 mb-4",children:b.notes.map((a,b)=>{if("cloudCheck"===a.type&&(l||m))return null;let c="warning"===a.type,e="cloudCheck"===a.type&&!l&&!m,f="bg-blue-500/10 border-blue-500/30",g="text-blue-600 dark:text-blue-400",h="text-blue-500",i="info";return c?(f="bg-yellow-500/10 border-yellow-500/30",g="text-yellow-600 dark:text-yellow-400",h="text-yellow-500",i="warning"):e&&(f="bg-red-500/10 border-red-500/30",g="text-red-600 dark:text-red-400",h="text-red-500",i="error"),(0,d.jsxs)("div",{className:`flex items-start gap-3 p-3 rounded-lg border ${f}`,children:[(0,d.jsx)("span",{className:`material-symbols-outlined text-lg ${h}`,children:i}),(0,d.jsx)("p",{className:`text-sm ${g}`,children:a.text})]},b)})}):null,z()&&b.guideSteps.map(a=>(0,d.jsxs)("div",{className:"flex items-start gap-4",children:[(0,d.jsx)("div",{className:"size-8 rounded-full flex items-center justify-center shrink-0 text-sm font-semibold text-white",style:{backgroundColor:b.color},children:a.step}),(0,d.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,d.jsx)("p",{className:"font-medium text-text",children:a.title}),a.desc&&(0,d.jsx)("p",{className:"text-sm text-text-muted mt-0.5",children:a.desc}),"apiKeySelector"===a.type&&(0,d.jsx)("div",{className:"mt-2 flex items-center gap-2",children:j&&j.length>0?(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("select",{value:u,onChange:a=>v(a.target.value),className:"flex-1 px-3 py-2 bg-bg-secondary rounded-lg text-sm border border-border focus:outline-none focus:ring-1 focus:ring-primary/50",children:j.map(a=>(0,d.jsx)("option",{value:a.key,children:a.key},a.id))}),(0,d.jsx)("button",{onClick:()=>x(u,"apiKey"),className:"shrink-0 px-3 py-2 bg-bg-secondary hover:bg-bg-tertiary rounded-lg border border-border transition-colors",children:(0,d.jsx)("span",{className:"material-symbols-outlined text-lg",children:"apiKey"===o?"check":"content_copy"})})]}):(0,d.jsx)("span",{className:"text-sm text-text-muted",children:l?"No API keys - Create one in Keys page":"sk_9router"})}),"modelSelector"===a.type&&(0,d.jsxs)("div",{className:"mt-2 flex items-center gap-2",children:[(0,d.jsx)("input",{type:"text",value:s,onChange:a=>t(a.target.value),placeholder:"provider/model-id",className:"flex-1 px-3 py-2 bg-bg-secondary rounded-lg text-sm border border-border focus:outline-none focus:ring-1 focus:ring-primary/50"}),(0,d.jsx)("button",{onClick:()=>r(!0),disabled:!y,className:`shrink-0 px-3 py-2 rounded-lg border text-sm transition-colors ${y?"bg-bg-secondary border-border text-text-main hover:border-primary cursor-pointer":"opacity-50 cursor-not-allowed border-border"}`,children:"Select Model"}),s&&(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("button",{onClick:()=>x(s,"model"),className:"shrink-0 px-3 py-2 bg-bg-secondary hover:bg-bg-tertiary rounded-lg border border-border transition-colors",children:(0,d.jsx)("span",{className:"material-symbols-outlined text-lg",children:"model"===o?"check":"content_copy"})}),(0,d.jsx)("button",{onClick:()=>t(""),className:"p-2 text-text-muted hover:text-red-500 rounded transition-colors",title:"Clear",children:(0,d.jsx)("span",{className:"material-symbols-outlined text-lg",children:"close"})})]})]}),a.value&&(0,d.jsxs)("div",{className:"mt-2 flex items-center gap-2",children:[(0,d.jsx)("code",{className:"flex-1 px-3 py-2 bg-bg-secondary rounded-lg text-sm font-mono border border-border truncate",children:w(a.value)}),a.copyable&&(0,d.jsx)("button",{onClick:()=>x(a.value,`${a.step}-${a.title}`),className:"shrink-0 px-3 py-2 bg-bg-secondary hover:bg-bg-tertiary rounded-lg border border-border transition-colors",children:(0,d.jsx)("span",{className:"material-symbols-outlined text-lg",children:o===`${a.step}-${a.title}`?"check":"content_copy"})})]})]})]},a.step)),z()&&b.codeBlock&&(0,d.jsxs)("div",{className:"mt-2",children:[(0,d.jsxs)("div",{className:"flex items-center justify-between mb-2",children:[(0,d.jsx)("span",{className:"text-xs text-text-muted uppercase tracking-wide",children:b.codeBlock.language}),(0,d.jsxs)("button",{onClick:()=>x(b.codeBlock.code,"codeblock"),className:"flex items-center gap-1 px-2 py-1 text-xs bg-bg-secondary hover:bg-bg-tertiary rounded border border-border transition-colors",children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-sm",children:"codeblock"===o?"check":"content_copy"}),"codeblock"===o?"Copied!":"Copy"]})]}),(0,d.jsx)("pre",{className:"p-4 bg-bg-secondary rounded-lg border border-border overflow-x-auto",children:(0,d.jsx)("code",{className:"text-sm font-mono whitespace-pre",children:w(b.codeBlock.code)})})]})]}):(0,d.jsx)("p",{className:"text-text-muted text-sm",children:"Coming soon..."})}),(0,d.jsx)(f.rq,{isOpen:q,onClose:()=>r(!1),onSelect:a=>{t(a.value)},selectedModel:s,activeProviders:k,title:"Select Model"})]})}function o({tool:a,isExpanded:b,onToggle:c,baseUrl:h,apiKeys:i,activeProviders:j,cloudEnabled:k,initialStatus:l}){let m,[n,p]=(0,e.useState)(l||null),[q,r]=(0,e.useState)(!1),[s,t]=(0,e.useState)(!1),[u,v]=(0,e.useState)(!1),[w,x]=(0,e.useState)(null),[y,z]=(0,e.useState)(!1),[A,B]=(0,e.useState)(""),[C,D]=(0,e.useState)(""),[E,F]=(0,e.useState)(!1),[G,H]=(0,e.useState)({}),[I,J]=(0,e.useState)(!1),[K,L]=(0,e.useState)(""),M=(()=>{if(!n?.installed)return null;if(!n.config)return"not_configured";let a=n.config?.provider?.["9router"]?.options?.baseURL||"",b=a.includes("localhost")||a.includes("127.0.0.1");return n.has9Router&&(b||a.includes(h))?"configured":n.has9Router?"other":"not_configured"})(),N=()=>{let a=K||h;return a.endsWith("/v1")?a:`${a}/v1`},O=async()=>{r(!0);try{let a=await fetch("/api/cli-tools/opencode-settings"),b=await a.json();p(b)}catch(a){p({installed:!1,error:a.message})}finally{r(!1)}},P=async()=>{t(!0),x(null);try{let a=A&&A.trim()||k?A:"sk_9router",b=await fetch("/api/cli-tools/opencode-settings",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({baseUrl:N(),apiKey:a,model:C})}),c=await b.json();b.ok?(x({type:"success",text:"Settings applied successfully!"}),O()):x({type:"error",text:c.error||"Failed to apply settings"})}catch(a){x({type:"error",text:a.message})}finally{t(!1)}},Q=async()=>{v(!0),x(null);try{let a=await fetch("/api/cli-tools/opencode-settings",{method:"DELETE"}),b=await a.json();a.ok?(x({type:"success",text:"Settings reset successfully!"}),D(""),O()):x({type:"error",text:b.error||"Failed to reset settings"})}catch(a){x({type:"error",text:a.message})}finally{v(!1)}};return(0,d.jsxs)(f.Zp,{padding:"xs",className:"overflow-hidden",children:[(0,d.jsxs)("div",{className:"flex items-center justify-between hover:cursor-pointer",onClick:c,children:[(0,d.jsxs)("div",{className:"flex items-center gap-3",children:[(0,d.jsx)("div",{className:"size-8 flex items-center justify-center shrink-0",children:(0,d.jsx)(g.default,{src:"/providers/opencode.png",alt:a.name,width:32,height:32,className:"size-8 object-contain rounded-lg",sizes:"32px",onError:a=>{a.target.style.display="none"}})}),(0,d.jsxs)("div",{className:"min-w-0",children:[(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)("h3",{className:"font-medium text-sm",children:a.name}),"configured"===M&&(0,d.jsx)("span",{className:"px-1.5 py-0.5 text-[10px] font-medium bg-green-500/10 text-green-600 dark:text-green-400 rounded-full",children:"Connected"}),"not_configured"===M&&(0,d.jsx)("span",{className:"px-1.5 py-0.5 text-[10px] font-medium bg-yellow-500/10 text-yellow-600 dark:text-yellow-400 rounded-full",children:"Not configured"}),"other"===M&&(0,d.jsx)("span",{className:"px-1.5 py-0.5 text-[10px] font-medium bg-blue-500/10 text-blue-600 dark:text-blue-400 rounded-full",children:"Other"})]}),(0,d.jsx)("p",{className:"text-xs text-text-muted truncate",children:a.description})]})]}),(0,d.jsx)("span",{className:`material-symbols-outlined text-text-muted text-[20px] transition-transform ${b?"rotate-180":""}`,children:"expand_more"})]}),b&&(0,d.jsxs)("div",{className:"mt-4 pt-4 border-t border-border flex flex-col gap-4",children:[q&&(0,d.jsxs)("div",{className:"flex items-center gap-2 text-text-muted",children:[(0,d.jsx)("span",{className:"material-symbols-outlined animate-spin",children:"progress_activity"}),(0,d.jsx)("span",{children:"Checking OpenCode CLI..."})]}),!q&&n&&!n.installed&&(0,d.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,d.jsxs)("div",{className:"flex items-center gap-3 p-4 bg-yellow-500/10 border border-yellow-500/30 rounded-lg",children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-yellow-500",children:"warning"}),(0,d.jsxs)("div",{className:"flex-1",children:[(0,d.jsx)("p",{className:"font-medium text-yellow-600 dark:text-yellow-400",children:"OpenCode CLI not installed"}),(0,d.jsx)("p",{className:"text-sm text-text-muted",children:"Please install OpenCode CLI to use auto-apply feature."})]}),(0,d.jsxs)(f.$n,{variant:"outline",size:"sm",onClick:()=>z(!y),children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-[18px] mr-1",children:y?"expand_less":"help"}),y?"Hide":"How to Install"]})]}),y&&(0,d.jsxs)("div",{className:"p-4 bg-surface border border-border rounded-lg",children:[(0,d.jsx)("h4",{className:"font-medium mb-3",children:"Installation Guide"}),(0,d.jsxs)("div",{className:"space-y-3 text-sm",children:[(0,d.jsxs)("div",{children:[(0,d.jsx)("p",{className:"text-text-muted mb-1",children:"macOS / Linux:"}),(0,d.jsx)("code",{className:"block px-3 py-2 bg-black/5 dark:bg-white/5 rounded font-mono text-xs",children:"npm install -g opencode-ai"})]}),(0,d.jsxs)("p",{className:"text-text-muted",children:["After installation, run ",(0,d.jsx)("code",{className:"px-1 bg-black/5 dark:bg-white/5 rounded",children:"opencode"})," to verify."]})]})]})]}),!q&&n?.installed&&(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)("div",{className:"flex flex-col gap-2",children:[n?.config?.provider?.["9router"]?.options?.baseURL&&(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)("span",{className:"w-32 shrink-0 text-sm font-semibold text-text-main text-right",children:"Current"}),(0,d.jsx)("span",{className:"material-symbols-outlined text-text-muted text-[14px]",children:"arrow_forward"}),(0,d.jsx)("span",{className:"flex-1 px-2 py-1.5 text-xs text-text-muted truncate",children:n.config.provider["9router"].options.baseURL})]}),(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)("span",{className:"w-32 shrink-0 text-sm font-semibold text-text-main text-right",children:"Base URL"}),(0,d.jsx)("span",{className:"material-symbols-outlined text-text-muted text-[14px]",children:"arrow_forward"}),(0,d.jsx)("input",{type:"text",value:K||`${h}/v1`,onChange:a=>L(a.target.value),placeholder:"https://.../v1",className:"flex-1 px-2 py-1.5 bg-surface rounded border border-border text-xs focus:outline-none focus:ring-1 focus:ring-primary/50"}),K&&K!==`${h}/v1`&&(0,d.jsx)("button",{onClick:()=>L(""),className:"p-1 text-text-muted hover:text-primary rounded transition-colors",title:"Reset to default",children:(0,d.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"restart_alt"})})]}),(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)("span",{className:"w-32 shrink-0 text-sm font-semibold text-text-main text-right",children:"API Key"}),(0,d.jsx)("span",{className:"material-symbols-outlined text-text-muted text-[14px]",children:"arrow_forward"}),i.length>0?(0,d.jsx)("select",{value:A,onChange:a=>B(a.target.value),className:"flex-1 px-2 py-1.5 bg-surface rounded text-xs border border-border focus:outline-none focus:ring-1 focus:ring-primary/50",children:i.map(a=>(0,d.jsx)("option",{value:a.key,children:a.key},a.id))}):(0,d.jsx)("span",{className:"flex-1 text-xs text-text-muted px-2 py-1.5",children:k?"No API keys - Create one in Keys page":"sk_9router (default)"})]}),(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)("span",{className:"w-32 shrink-0 text-sm font-semibold text-text-main text-right",children:"Model"}),(0,d.jsx)("span",{className:"material-symbols-outlined text-text-muted text-[14px]",children:"arrow_forward"}),(0,d.jsx)("input",{type:"text",value:C,onChange:a=>D(a.target.value),placeholder:"provider/model-id",className:"flex-1 px-2 py-1.5 bg-surface rounded border border-border text-xs focus:outline-none focus:ring-1 focus:ring-primary/50"}),(0,d.jsx)("button",{onClick:()=>F(!0),disabled:!j?.length,className:`px-2 py-1.5 rounded border text-xs transition-colors shrink-0 whitespace-nowrap ${j?.length?"bg-surface border-border text-text-main hover:border-primary cursor-pointer":"opacity-50 cursor-not-allowed border-border"}`,children:"Select Model"}),C&&(0,d.jsx)("button",{onClick:()=>D(""),className:"p-1 text-text-muted hover:text-red-500 rounded transition-colors",title:"Clear",children:(0,d.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"close"})})]})]}),w&&(0,d.jsxs)("div",{className:`flex items-center gap-2 px-2 py-1.5 rounded text-xs ${"success"===w.type?"bg-green-500/10 text-green-600":"bg-red-500/10 text-red-600"}`,children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"success"===w.type?"check_circle":"error"}),(0,d.jsx)("span",{children:w.text})]}),(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsxs)(f.$n,{variant:"primary",size:"sm",onClick:P,disabled:!C,loading:s,children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-[14px] mr-1",children:"save"}),"Apply"]}),(0,d.jsxs)(f.$n,{variant:"outline",size:"sm",onClick:Q,disabled:!n.has9Router,loading:u,children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-[14px] mr-1",children:"restore"}),"Reset"]}),(0,d.jsxs)(f.$n,{variant:"ghost",size:"sm",onClick:()=>J(!0),children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-[14px] mr-1",children:"content_copy"}),"Manual Config"]})]})]})]}),(0,d.jsx)(f.rq,{isOpen:E,onClose:()=>F(!1),onSelect:a=>{D(a.value),F(!1)},selectedModel:C,activeProviders:j,modelAliases:G,title:"Select Model for OpenCode"}),(0,d.jsx)(f.uR,{isOpen:I,onClose:()=>J(!1),title:"OpenCode - Manual Configuration",configs:(m=A&&A.trim()?A:k?"<API_KEY_FROM_DASHBOARD>":"sk_9router",[{filename:"~/.config/opencode/opencode.json",content:JSON.stringify({provider:{"9router":{npm:"@ai-sdk/openai-compatible",options:{baseURL:N(),apiKey:m},models:{[C||"provider/model-id"]:{name:C||"provider/model-id"}}}},model:`9router/${C||"provider/model-id"}`},null,2)}])})]})}let p="http://localhost:20128";function q({apiKeys:a,cloudEnabled:b,onStatusChange:c}){let[g,h]=(0,e.useState)(null),[i,j]=(0,e.useState)(!1),[k,l]=(0,e.useState)(!1),[m,n]=(0,e.useState)(""),[o,r]=(0,e.useState)(""),[s,t]=(0,e.useState)(null),[u,v]=(0,e.useState)(null),[w,x]=(0,e.useState)(null),[y,z]=(0,e.useState)(p),A="u">typeof navigator&&navigator.userAgent?.includes("Windows"),B=g?.isAdmin!==!1,C=async()=>{try{let a=await fetch("/api/cli-tools/antigravity-mitm");if(a.ok){let b=await a.json();h(b),b.mitmRouterBaseUrl&&z(b.mitmRouterBaseUrl),c?.(b)}}catch{h({running:!1,certExists:!1,dnsStatus:{}})}},D=a=>{A||g?.hasCachedPassword?E(a,""):(t(a),l(!0),v(null))},E=async(c,d)=>{j(!0),x(null);try{let e;if("trust-cert"===c)e=await fetch("/api/cli-tools/antigravity-mitm",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"trust-cert",sudoPassword:d})});else if("start"===c){let c=o?.trim()||(a?.length>0?a[0].key:null)||(b?null:"sk_9router");e=await fetch("/api/cli-tools/antigravity-mitm",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({apiKey:c,sudoPassword:d,mitmRouterBaseUrl:y.trim()||p})})}else e=await fetch("/api/cli-tools/antigravity-mitm",{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({sudoPassword:d})});let f=await e.json().catch(()=>({}));if(!e.ok)throw Error(f.error||"MITM action failed");l(!1),n(""),v(null),await C()}catch(b){let a=b?.message||"MITM action failed";x(a),k&&v(a)}finally{j(!1),t(null)}},F=()=>{m?E(s,m):v("Sudo password is required")},G=g?.running;return(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(f.Zp,{padding:"sm",className:"border-primary/20 bg-primary/5",children:(0,d.jsxs)("div",{className:"flex flex-col gap-3",children:[(0,d.jsxs)("div",{className:"flex items-center justify-between",children:[(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-primary text-[20px]",children:"security"}),(0,d.jsx)("span",{className:"font-semibold text-sm text-text-main",children:"MITM Server"}),G?(0,d.jsx)(f.Ex,{variant:"success",size:"sm",children:"Running"}):(0,d.jsx)(f.Ex,{variant:"default",size:"sm",children:"Stopped"})]}),(0,d.jsx)("div",{className:"flex items-center gap-1 text-xs text-text-muted","data-i18n-skip":"true",children:[{label:"Cert",ok:g?.certExists},{label:"Trusted",ok:g?.certTrusted},{label:"Server",ok:G}].map(({label:a,ok:b})=>(0,d.jsxs)("span",{className:`flex items-center gap-0.5 px-1.5 py-0.5 rounded ${b?"text-green-600":"text-text-muted"}`,children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-[12px]",children:b?"check_circle":"cancel"}),a]},a))})]}),(0,d.jsxs)("div",{className:"px-2 py-2 rounded-lg bg-surface/50 border border-border/50 flex flex-col gap-2",children:[(0,d.jsxs)("p",{className:"text-[11px] text-text-muted leading-relaxed",children:[(0,d.jsx)("span",{className:"font-medium text-text-main",children:"Purpose:"})," Use Antigravity IDE & GitHub Copilot → with ANY provider/model from 9Router"]}),(0,d.jsxs)("p",{className:"text-[11px] text-text-muted leading-relaxed",children:[(0,d.jsx)("span",{className:"font-medium text-text-main",children:"How it works:"})," Antigravity/Copilot IDE request → DNS redirect to localhost:443 → MITM proxy intercepts → 9Router → response to Antigravity/Copilot"]})]}),(0,d.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)("span",{className:"w-32 shrink-0 text-sm font-semibold text-text-main text-right",children:"9Router Base URL"}),(0,d.jsx)("span",{className:"material-symbols-outlined text-text-muted text-[14px]",children:"arrow_forward"}),(0,d.jsx)("input",{type:"text",value:y,onChange:a=>z(a.target.value),placeholder:p,disabled:G,className:"flex-1 min-w-0 px-2 py-1.5 bg-surface rounded border border-border text-xs text-text-main focus:outline-none focus:ring-1 focus:ring-primary/50 disabled:opacity-50"})]}),!G&&(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)("span",{className:"w-32 shrink-0 text-sm font-semibold text-text-main text-right",children:"API Key"}),(0,d.jsx)("span",{className:"material-symbols-outlined text-text-muted text-[14px]",children:"arrow_forward"}),a?.length>0?(0,d.jsx)("select",{value:o,onChange:a=>r(a.target.value),className:"flex-1 min-w-0 px-2 py-1.5 bg-surface rounded text-xs border border-border text-text-main focus:outline-none focus:ring-1 focus:ring-primary/50",children:a.map(a=>(0,d.jsx)("option",{value:a.key,children:a.key},a.id))}):(0,d.jsx)("span",{className:"flex-1 px-2 py-1.5 text-xs text-text-muted",children:b?"No API keys — create one in Keys page":"sk_9router (default)"})]})]}),(0,d.jsxs)("div",{className:"flex items-center gap-2 flex-wrap","data-i18n-skip":"true",children:[g?.certExists&&!g?.certTrusted&&(0,d.jsxs)("button",{onClick:()=>D("trust-cert"),disabled:i,className:"px-4 py-1.5 rounded-lg bg-yellow-500/10 border border-yellow-500/30 text-yellow-600 font-medium text-xs flex items-center gap-1.5 hover:bg-yellow-500/20 transition-colors disabled:opacity-50",children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-[16px]",children:"verified_user"}),"Trust Cert"]}),G?(0,d.jsxs)("button",{onClick:()=>D("stop"),disabled:i,className:"px-4 py-1.5 rounded-lg bg-red-500/10 border border-red-500/30 text-red-500 font-medium text-xs flex items-center gap-1.5 hover:bg-red-500/20 transition-colors disabled:opacity-50",children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-[16px]",children:"stop_circle"}),"Stop Server"]}):(0,d.jsxs)("button",{onClick:()=>D("start"),disabled:i||A&&!B,className:"px-4 py-1.5 rounded-lg bg-primary/10 border border-primary/30 text-primary font-medium text-xs flex items-center gap-1.5 hover:bg-primary/20 transition-colors disabled:opacity-50",children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-[16px]",children:"play_circle"}),"Start Server"]}),G&&(0,d.jsx)("p",{className:"text-xs text-text-muted",children:"Enable DNS per tool below to activate interception"})]}),w&&(0,d.jsxs)("div",{className:"flex items-center gap-2 px-2 py-1.5 rounded text-xs bg-red-500/10 text-red-600 border border-red-500/20",children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"error"}),(0,d.jsx)("span",{children:w})]}),A&&!B&&(0,d.jsxs)("div",{className:"flex items-center gap-2 px-2 py-1.5 rounded text-xs bg-red-500/10 text-red-600 border border-red-500/20",children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"shield_lock"}),(0,d.jsx)("span",{children:"Administrator required — restart 9Router as Administrator to use MITM"})]})]})}),k&&(0,d.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50 backdrop-blur-sm",children:(0,d.jsxs)("div",{className:"bg-surface border border-border rounded-xl p-6 w-full max-w-sm flex flex-col gap-4 shadow-xl",children:[(0,d.jsx)("h3",{className:"font-semibold text-text-main",children:"Sudo Password Required"}),(0,d.jsxs)("div",{className:"flex items-start gap-3 p-3 bg-yellow-500/10 border border-yellow-500/30 rounded-lg",children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-yellow-500 text-[20px]",children:"warning"}),(0,d.jsx)("p",{className:"text-xs text-text-muted",children:"Required for SSL certificate and server startup"})]}),(0,d.jsx)(f.pd,{type:"password",placeholder:"Enter sudo password",value:m,onChange:a=>n(a.target.value),onKeyDown:a=>{"Enter"!==a.key||i||F()}}),u&&(0,d.jsxs)("div",{className:"flex items-center gap-2 px-2 py-1.5 rounded text-xs bg-red-500/10 text-red-600",children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"error"}),(0,d.jsx)("span",{children:u})]}),(0,d.jsxs)("div",{className:"flex items-center justify-end gap-2",children:[(0,d.jsx)(f.$n,{variant:"ghost",size:"sm",onClick:()=>{l(!1),n(""),v(null)},disabled:i,children:"Cancel"}),(0,d.jsx)(f.$n,{variant:"primary",size:"sm",onClick:F,loading:i,children:"Confirm"})]})]})})]})}function r({tool:a,isExpanded:b,onToggle:c,serverRunning:h,dnsActive:i,hasCachedPassword:j,apiKeys:k,activeProviders:l,hasActiveProviders:m,modelAliases:n={},cloudEnabled:o,onDnsChange:p,tokenSwapActive:q=!1}){let[t,u]=(0,e.useState)(!1),[v,w]=(0,e.useState)(null),[x,y]=(0,e.useState)(null),[z,A]=(0,e.useState)(!1),[B,C]=(0,e.useState)(""),[D,E]=(0,e.useState)(null),[F,G]=(0,e.useState)(null),[H,I]=(0,e.useState)({}),[J,K]=(0,e.useState)(!1),[L,M]=(0,e.useState)(null),N="u">typeof navigator&&navigator.userAgent?.includes("Windows");(0,e.useCallback)(async()=>{try{let b=await fetch(`/api/cli-tools/antigravity-mitm/alias?tool=${a.id}`);if(b.ok){let a=await b.json();Object.keys(a.aliases||{}).length>0&&I(a.aliases)}}catch{}},[a.id]);let O=(0,e.useCallback)(async b=>{try{await fetch("/api/cli-tools/antigravity-mitm/alias",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({tool:a.id,mappings:b})})}catch{}},[a.id]),P=(a,b)=>{I(c=>({...c,[a]:b}))},Q=()=>{if(!h)return;let a=i?"disable":"enable";N||j?R(a,""):(E(a),A(!0),G(null))},R=async(b,c)=>{u(!0),w(null),y(null);try{let d=await fetch("/api/cli-tools/antigravity-mitm",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({tool:a.id,action:b,sudoPassword:c})}),e=await d.json().catch(()=>({}));if(!d.ok)throw Error(e.error||`Failed to ${b} DNS`);"enable"===b&&w(`Restart ${a.name} to apply changes`),A(!1),C(""),p?.(e)}catch(a){y(a.message||`Failed to ${b} DNS`)}finally{u(!1),E(null)}},S=()=>{B?R(D,B):G("Sudo password is required")};return(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)(f.Zp,{padding:"xs",className:"overflow-hidden",children:[(0,d.jsxs)("div",{className:"flex items-center justify-between hover:cursor-pointer",onClick:c,children:[(0,d.jsxs)("div",{className:"flex items-center gap-3",children:[(0,d.jsx)("div",{className:"size-8 flex items-center justify-center shrink-0",children:(0,d.jsx)(g.default,{src:a.image,alt:a.name,width:32,height:32,className:"size-8 object-contain rounded-lg",sizes:"32px",onError:a=>{a.target.style.display="none"}})}),(0,d.jsxs)("div",{className:"min-w-0",children:[(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)("h3",{className:"font-medium text-sm",children:a.name}),a.supportsTokenSwap&&(0,d.jsx)("span",{className:"text-[9px] uppercase tracking-wider text-text-muted bg-surface border border-border px-1.5 py-0.5 rounded font-semibold",children:"Mode A"}),h?q?(0,d.jsx)(f.Ex,{variant:"default",size:"sm",children:"Bypassed"}):i?(0,d.jsx)(f.Ex,{variant:"success",size:"sm",children:"Active"}):(0,d.jsx)(f.Ex,{variant:"warning",size:"sm",children:"DNS off"}):(0,d.jsx)(f.Ex,{variant:"default",size:"sm",children:"Server off"})]}),(0,d.jsx)("p",{className:"text-xs text-text-muted",children:"Model routing — remap model IDs in intercepted requests"})]})]}),(0,d.jsx)("span",{className:`material-symbols-outlined text-text-muted text-[20px] transition-transform ${b?"rotate-180":""}`,children:"expand_more"})]}),b&&(0,d.jsxs)("div",{className:"mt-4 pt-4 border-t border-border flex flex-col gap-4",children:[q&&(0,d.jsxs)("div",{className:"flex items-start gap-2 px-2 py-2 rounded-lg bg-violet-500/5 border border-violet-500/15",children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-[14px] text-violet-400 mt-0.5 shrink-0",children:"info"}),(0,d.jsx)("p",{className:"text-[11px] text-violet-400",children:"Token Rotation (Mode B) is active — model routing is currently bypassed. Disable Token Rotation to use model routing."})]}),"antigravity"===a.id&&(0,d.jsx)(s,{}),(0,d.jsxs)("div",{className:"flex flex-col gap-0.5 text-[11px] text-text-muted px-1",children:[(0,d.jsxs)("p",{children:["Toggle DNS to redirect ",a.name," traffic through 9Router via MITM."]}),!i&&(0,d.jsx)("p",{className:"text-amber-600 text-[10px] mt-1",children:"⚠️ Enable DNS to edit model mappings"})]}),a.defaultModels?.length>0&&(0,d.jsx)("div",{className:"flex flex-col gap-2",children:a.defaultModels.map(a=>(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)("span",{className:"w-36 shrink-0 text-xs font-semibold text-text-main text-right",children:a.name}),(0,d.jsx)("span",{className:"material-symbols-outlined text-text-muted text-[14px]",children:"arrow_forward"}),(0,d.jsx)("input",{type:"text",value:H[a.alias]||"",onChange:b=>P(a.alias,b.target.value),onBlur:b=>{var c,d;return c=a.alias,d=b.target.value,void O({...H,[c]:d})},placeholder:"provider/model-id",disabled:!i,className:`flex-1 px-2 py-1.5 bg-surface rounded border border-border text-xs focus:outline-none focus:ring-1 focus:ring-primary/50 ${!i?"opacity-50 cursor-not-allowed":""}`}),(0,d.jsx)("button",{onClick:()=>{M(a.alias),K(!0)},disabled:!m||!i,className:`px-2 py-1.5 rounded border text-xs transition-colors shrink-0 ${m&&i?"bg-surface border-border hover:border-primary cursor-pointer":"opacity-50 cursor-not-allowed border-border"}`,children:"Select"}),H[a.alias]&&(0,d.jsx)("button",{onClick:()=>{P(a.alias,""),O({...H,[a.alias]:""})},className:"p-1 text-text-muted hover:text-red-500 rounded transition-colors",title:"Clear",children:(0,d.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"close"})})]},a.alias))}),a.defaultModels?.length===0&&(0,d.jsx)("p",{className:"text-xs text-text-muted px-1",children:"Model mappings will be available soon."}),(0,d.jsxs)("div",{className:"flex flex-col gap-2 items-start",children:[i?(0,d.jsxs)("button",{onClick:Q,disabled:!h||t,className:"px-4 py-1.5 rounded-lg bg-red-500/10 border border-red-500/30 text-red-500 font-medium text-xs flex items-center gap-1.5 hover:bg-red-500/20 transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-[16px]",children:"stop_circle"}),"Stop DNS"]}):(0,d.jsxs)("button",{onClick:Q,disabled:!h||t,className:"px-4 py-1.5 rounded-lg bg-primary/10 border border-primary/30 text-primary font-medium text-xs flex items-center gap-1.5 hover:bg-primary/20 transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-[16px]",children:"play_circle"}),"Start DNS"]}),v&&(0,d.jsxs)("div",{className:"flex items-center gap-2 px-2 py-1.5 rounded text-xs text-amber-500",children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"warning"}),(0,d.jsx)("span",{children:v})]}),x&&(0,d.jsxs)("div",{className:"flex items-center gap-2 px-2 py-1.5 rounded text-xs bg-red-500/10 text-red-600",children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"error"}),(0,d.jsx)("span",{children:x})]})]})]})]}),z&&(0,d.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50 backdrop-blur-sm",children:(0,d.jsxs)("div",{className:"bg-surface border border-border rounded-xl p-6 w-full max-w-sm flex flex-col gap-4 shadow-xl",children:[(0,d.jsx)("h3",{className:"font-semibold text-text-main",children:"Sudo Password Required"}),(0,d.jsxs)("div",{className:"flex items-start gap-3 p-3 bg-yellow-500/10 border border-yellow-500/30 rounded-lg",children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-yellow-500 text-[20px]",children:"warning"}),(0,d.jsx)("p",{className:"text-xs text-text-muted",children:"Required to modify /etc/hosts and flush DNS cache"})]}),(0,d.jsx)(f.pd,{type:"password",placeholder:"Enter sudo password",value:B,onChange:a=>C(a.target.value),onKeyDown:a=>{"Enter"!==a.key||t||S()}}),F&&(0,d.jsxs)("div",{className:"flex items-center gap-2 px-2 py-1.5 rounded text-xs bg-red-500/10 text-red-600",children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"error"}),(0,d.jsx)("span",{children:F})]}),(0,d.jsxs)("div",{className:"flex items-center justify-end gap-2",children:[(0,d.jsx)(f.$n,{variant:"ghost",size:"sm",onClick:()=>{A(!1),C(""),G(null)},disabled:t,children:"Cancel"}),(0,d.jsx)(f.$n,{variant:"primary",size:"sm",onClick:S,loading:t,children:"Confirm"})]})]})}),(0,d.jsx)(f.rq,{isOpen:J,onClose:()=>K(!1),onSelect:a=>{if(!L||a.isPlaceholder)return;let b={...H,[L]:a.value};I(b),O(b)},selectedModel:L?H[L]:null,activeProviders:l,modelAliases:n,title:`Select model for ${L}`})]})}function s(){let[a,b]=(0,e.useState)(null),[c,f]=(0,e.useState)(!1),[g,h]=(0,e.useState)(null),i=(0,e.useCallback)(async()=>{try{let a=await fetch("/api/antigravity-ide");a.ok&&b(await a.json())}catch{}},[]),j=async()=>{f(!0),h(null);try{let a=await fetch("/api/antigravity-ide",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"close"})}),b=await a.json();h(b),setTimeout(i,1e3)}catch(a){h({success:!1,error:a.message})}f(!1)};return(0,d.jsxs)("div",{className:"flex items-center gap-2 px-1",children:[(0,d.jsxs)("button",{onClick:j,disabled:c||!a?.running,className:"flex items-center gap-1.5 px-2.5 py-1.5 rounded-lg text-xs font-medium border border-red-500/30 text-red-500 bg-red-500/5 hover:bg-red-500/15 transition-colors disabled:opacity-50 disabled:cursor-not-allowed",title:a?.running?"Close all Antigravity IDE processes":"Antigravity IDE is not running",children:[(0,d.jsx)("span",{className:`material-symbols-outlined text-[14px] ${c?"animate-spin":""}`,children:c?"progress_activity":"close"}),c?"Closing…":"Close IDE"]}),a&&(0,d.jsxs)("span",{className:"flex items-center gap-1 text-[10px] text-text-muted",children:[(0,d.jsx)("span",{className:`inline-block w-1.5 h-1.5 rounded-full ${!a.installed?"bg-gray-400":a.running?"bg-green-500":"bg-red-400"}`}),a.installed?a.running?"Running":"Stopped":"Not installed"]}),g&&!c&&(0,d.jsxs)("span",{className:`text-[10px] ${g.success?"text-green-500":"text-red-400"}`,children:[g.success?"✓":"✗"," ",g.message||g.error]})]})}var t=c(2116),u=c.n(t);function v(a){if(null==a)return null;let b=String(a).trim();if(!b)return null;let c=b.toLowerCase();return c.includes("ultra")?"Ultra":c.includes("pro")?"Pro":c.includes("free")?"Free":null}["Free","Pro","Ultra"].map(a=>({value:a,label:a}));var w=c(4088);function x(a){if(!a||"string"!=typeof a)return a;let b=a.indexOf("@");if(b<=0||b===a.length-1)return a;let c=a.slice(0,b),d=a.slice(b+1);return 1===c.length?`${c[0]}**@${d}`:2===c.length?`${c[0]}**${c[1]}@${d}`:`${c[0]}**${c[c.length-1]}@${d}`}function y({tool:a,connections:b=[],serverRunning:c,dnsActive:g,onToggle:h,onRefreshConnections:i}){let[j,k]=(0,e.useState)(!1),[l,m]=(0,e.useState)(!1),[n,o]=(0,e.useState)("round-robin"),[p,q]=(0,e.useState)(!1),[r,s]=(0,e.useState)(!1),[t,z]=(0,e.useState)(!1),[A,B]=(0,e.useState)(null),[C,D]=(0,e.useState)(null),[E,F]=(0,e.useState)(!1),[G,H]=(0,e.useState)({}),I=(0,e.useRef)({});(0,e.useCallback)(async()=>{try{let a=await fetch("/api/settings");if(a.ok){let b=await a.json();k(!!b.tokenSwapEnabled),o(b.tokenSwapStrategy||"round-robin"),s(!!b.tokenSwapMaskEmails)}}catch{}},[]);let J=(0,e.useCallback)(async(b,c=!1)=>{if(!b||0===b.length)return;let d=Date.now(),e=[],f={};if(b.forEach(a=>{let b=I.current[a.id];!c&&b&&d-b.ts<12e4?f[a.id]={quotas:b.data,error:b.error,loading:!1,accountType:b.accountType||null}:e.push(a)}),Object.keys(f).length>0&&H(a=>({...a,...f})),0===e.length)return;let g={};e.forEach(a=>{g[a.id]={quotas:[],error:null,loading:!0}}),H(a=>({...a,...g})),await Promise.all(e.map(async b=>{try{let c=await fetch(`/api/usage/${b.id}`);if(!c.ok){let a=(await c.json().catch(()=>({}))).error||`HTTP ${c.status}`;I.current[b.id]={data:[],error:a,ts:Date.now(),accountType:null},H(c=>({...c,[b.id]:{quotas:[],error:a,loading:!1,accountType:null}}));return}let d=await c.json(),e=(0,w.W_)(a.tokenSwapProvider||"antigravity",d),f=function(a){if(!a)return null;if("string"==typeof a)return v(a);for(let b of[a.accountType,a.plan,a.paidTier?.name,a.subscriptionTier,a.subscription_tier,a.currentTier?.name,a.subscriptionInfo?.paidTier?.name,a.quota?.subscription_tier,a.subscriptionInfo?.currentTier?.name]){let a=v(b);if(a)return a}return null}(d);I.current[b.id]={data:e,error:null,ts:Date.now(),accountType:f},H(a=>({...a,[b.id]:{quotas:e,error:null,loading:!1,accountType:f}}))}catch(c){let a=c.message||"Failed";I.current[b.id]={data:[],error:a,ts:Date.now(),accountType:null},H(c=>({...c,[b.id]:{quotas:[],error:a,loading:!1,accountType:null}}))}}))},[a.tokenSwapProvider]);if(!a?.supportsTokenSwap)return null;let K=async()=>{m(!0);let a=!j;try{(await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({tokenSwapEnabled:a})})).ok&&(k(a),h?.(a))}catch{}m(!1)},L=async a=>{if(a!==n&&!p){q(!0);try{(await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({tokenSwapStrategy:a})})).ok&&o(a)}catch{}q(!1)}},M=async()=>{if(t)return;z(!0);let a=!r;try{(await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({tokenSwapMaskEmails:a})})).ok&&s(a)}catch{}z(!1)},N=b.filter(b=>b.provider===a.tokenSwapProvider),O=N.filter(a=>!1!==a.isActive),P=O.length;O.map(a=>a.id).join("|");let Q=function(a,b){if(!a||0===a.length)return null;if(1===a.length)return a[0].id;let c=[...a].sort((a,b)=>a.lastUsedAt||b.lastUsedAt?a.lastUsedAt?b.lastUsedAt?new Date(b.lastUsedAt)-new Date(a.lastUsedAt):-1:1:(a.priority||999)-(b.priority||999));if("sticky"===b)return c[0]?.id||null;let d=[...a].sort((a,b)=>a.lastUsedAt||b.lastUsedAt?a.lastUsedAt?b.lastUsedAt?new Date(a.lastUsedAt)-new Date(b.lastUsedAt):1:-1:(a.priority||999)-(b.priority||999));return d[0]?.id||null}(O,n),R=c&&g,S=j&&R&&P>0,T=async(a,b)=>{if(a&&!A&&!E&&!C){B(a);try{(await fetch(`/api/providers/${a}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({isActive:b})})).ok&&await i?.()}catch{}B(null)}},U=async a=>{if(a&&!C&&!E&&!A){D(a);try{(await fetch(`/api/providers/${a}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({lastUsedAt:null})})).ok&&await i?.()}catch{}D(null)}},V=async()=>{if(!E&&!C&&!A&&0!==N.length){F(!0);try{await Promise.all(N.map(a=>fetch(`/api/providers/${a.id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({lastUsedAt:null})}))),await i?.()}catch{}F(!1)}};return(0,d.jsxs)(f.Zp,{padding:"xs",className:"overflow-hidden",children:[(0,d.jsxs)("div",{className:"flex items-center justify-between",children:[(0,d.jsxs)("div",{className:"flex items-center gap-3",children:[(0,d.jsx)("div",{className:"size-8 flex items-center justify-center shrink-0 rounded-lg bg-violet-500/10",children:(0,d.jsx)("span",{className:"material-symbols-outlined text-violet-400 text-[18px]",children:"swap_horiz"})}),(0,d.jsxs)("div",{className:"min-w-0",children:[(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)("h3",{className:"font-medium text-sm",children:"Token Rotation"}),(0,d.jsx)("span",{className:"text-[9px] uppercase tracking-wider text-text-muted bg-surface border border-border px-1.5 py-0.5 rounded font-semibold",children:"Mode B"}),S?(0,d.jsx)(f.Ex,{variant:"success",size:"sm",children:"Active"}):j?(0,d.jsx)(f.Ex,{variant:"warning",size:"sm",children:"Enabled"}):(0,d.jsx)(f.Ex,{variant:"default",size:"sm",children:"Off"})]}),(0,d.jsx)("p",{className:"text-xs text-text-muted",children:"Rotate auth tokens across pool accounts to bypass per-account quota"})]})]}),(0,d.jsx)("button",{onClick:K,disabled:l,className:`relative inline-flex h-5 w-9 items-center rounded-full transition-colors shrink-0 ${j?"bg-violet-500":"bg-surface-alt border border-border"} ${l?"opacity-50":"cursor-pointer"}`,title:j?"Disable Token Rotation":"Enable Token Rotation",children:(0,d.jsx)("span",{className:`inline-block h-3.5 w-3.5 transform rounded-full bg-white transition-transform shadow-sm ${j?"translate-x-4":"translate-x-0.5"}`})})]}),j&&(0,d.jsxs)("div",{className:"mt-3 pt-3 border-t border-border/50 flex flex-col gap-3",children:[(0,d.jsxs)("div",{className:"flex items-start gap-2 px-2 py-2 rounded-lg bg-violet-500/5 border border-violet-500/15",children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-[14px] text-violet-400 mt-0.5 shrink-0",children:"info"}),(0,d.jsxs)("div",{className:"text-[11px] text-text-muted leading-relaxed",children:[(0,d.jsx)("p",{children:"Intercepts Antigravity requests → swaps IDE's auth token with a pool account → auto-retries on 429 quota error with next account in pool."}),(0,d.jsx)("p",{className:"mt-1 text-violet-400/80 font-medium",children:"⚠ When active, Model Routing (Mode A) is bypassed."})]})]}),(0,d.jsxs)("div",{className:"flex flex-col gap-1.5 px-1",children:[(0,d.jsx)("p",{className:"text-[10px] uppercase tracking-wider text-text-muted font-semibold",children:"Rotation Strategy"}),(0,d.jsxs)("div",{className:"flex gap-1.5",children:[(0,d.jsxs)("button",{onClick:()=>L("round-robin"),disabled:p,className:`flex-1 flex flex-col items-center gap-0.5 px-2 py-2 rounded-lg border text-[11px] font-medium transition-colors ${"round-robin"===n?"border-violet-500/50 bg-violet-500/10 text-violet-400":"border-border bg-surface text-text-muted hover:border-border-alt"} disabled:opacity-50`,children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"autorenew"}),"Round Robin"]}),(0,d.jsxs)("button",{onClick:()=>L("sticky"),disabled:p,className:`flex-1 flex flex-col items-center gap-0.5 px-2 py-2 rounded-lg border text-[11px] font-medium transition-colors ${"sticky"===n?"border-violet-500/50 bg-violet-500/10 text-violet-400":"border-border bg-surface text-text-muted hover:border-border-alt"} disabled:opacity-50`,children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"push_pin"}),"Sticky"]})]}),(0,d.jsx)("p",{className:"text-[10px] text-text-muted px-0.5",children:"sticky"===n?"Stays on the same account until its quota is exhausted for the requested model, then switches. Optimizes session-level token cache.":"Chooses the least recently used eligible account first. Each successful request updates that account's last-used time."})]}),(0,d.jsxs)("div",{className:"flex flex-col gap-1 px-1",children:[(0,d.jsx)("p",{className:"text-[10px] uppercase tracking-wider text-text-muted font-semibold mb-0.5",children:"Prerequisites"}),(0,d.jsxs)("div",{className:"flex items-center gap-2 text-xs",children:[(0,d.jsx)("span",{className:`material-symbols-outlined text-[14px] ${c?"text-green-500":"text-red-400"}`,children:c?"check_circle":"cancel"}),(0,d.jsx)("span",{className:c?"text-text-main":"text-text-muted",children:"MITM Server"})]}),(0,d.jsxs)("div",{className:"flex items-center gap-2 text-xs",children:[(0,d.jsx)("span",{className:`material-symbols-outlined text-[14px] ${g?"text-green-500":"text-red-400"}`,children:g?"check_circle":"cancel"}),(0,d.jsxs)("span",{className:g?"text-text-main":"text-text-muted",children:["DNS redirect",!g&&(0,d.jsx)("span",{className:"text-[10px] text-text-muted ml-1",children:"— enable via Antigravity card above"})]})]})]}),(0,d.jsxs)("div",{className:"flex flex-col gap-1 px-1",children:[(0,d.jsxs)("div",{className:"flex items-center justify-between mb-0.5",children:[(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)("p",{className:"text-[10px] uppercase tracking-wider text-text-muted font-semibold",children:"Pool Accounts"}),(0,d.jsx)("span",{className:"text-[10px] text-text-muted",children:N.length>0?`${P}/${N.length} active`:"none"}),P>1&&(0,d.jsx)("span",{className:"text-[9px] text-text-muted bg-surface border border-border px-1 py-0.5 rounded",children:"round-robin"})]}),(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[P>0&&(0,d.jsx)("button",{onClick:()=>J(O,!0),className:"text-[10px] text-text-muted hover:text-primary flex items-center gap-0.5 transition-colors",title:"Refresh quotas",children:(0,d.jsx)("span",{className:"material-symbols-outlined text-[12px]",children:"refresh"})}),"round-robin"===n&&N.length>0&&(0,d.jsxs)("button",{onClick:V,disabled:E||!!C,className:"inline-flex items-center gap-1 rounded-md border border-border bg-surface px-2 py-1 text-[10px] font-medium text-text-main hover:border-border-alt hover:bg-surface-alt disabled:opacity-50 disabled:cursor-not-allowed transition-colors",title:"Clear last-used timestamps for all pool accounts",children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-[12px]",children:"restart_alt"}),"Reset order"]})]})]}),(0,d.jsx)("p",{className:"text-[10px] text-text-muted px-0.5",children:"Round robin uses least-recently-used ordering. Accounts with no usage timestamp are tried first, then older timestamps rotate ahead of newer ones."}),(0,d.jsxs)("div",{className:"flex items-center justify-between gap-3 px-2 py-2 rounded-lg border border-border bg-surface-alt/40",children:[(0,d.jsxs)("div",{className:"min-w-0",children:[(0,d.jsx)("p",{className:"text-[11px] font-medium text-text-main",children:"Mask account emails"}),(0,d.jsxs)("p",{className:"text-[10px] text-text-muted",children:["Hide pool account emails in token swap logs and this panel. Example: ",x("email@gmail.com")]})]}),(0,d.jsx)("button",{onClick:M,disabled:t,className:`relative inline-flex h-5 w-9 items-center rounded-full transition-colors shrink-0 ${r?"bg-violet-500":"bg-surface border border-border"} ${t?"opacity-50":"cursor-pointer"}`,title:r?"Disable email masking":"Enable email masking",children:(0,d.jsx)("span",{className:`inline-block h-3.5 w-3.5 transform rounded-full bg-white transition-transform shadow-sm ${r?"translate-x-4":"translate-x-0.5"}`})})]}),N.length>0?(0,d.jsxs)(d.Fragment,{children:[N.map(a=>{let b=v(G[a.id]?.accountType)||v(a.accountType)||null;return(0,d.jsxs)("div",{className:`rounded-xl border border-border bg-surface-alt/30 px-3 py-2.5 transition-colors ${!1===a.isActive?"opacity-65":"hover:bg-surface-alt/50"}`,children:[(0,d.jsxs)("div",{className:"flex items-start justify-between gap-3",children:[(0,d.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,d.jsxs)("div",{className:"flex items-center gap-2 min-w-0",children:[(0,d.jsx)("span",{className:`material-symbols-outlined text-[14px] shrink-0 ${!1===a.isActive?"text-text-muted":"text-green-500"}`,children:!1===a.isActive?"pause_circle":"check_circle"}),(0,d.jsx)("span",{className:"text-xs font-medium text-text-main truncate",children:a.email?r?x(a.email):a.email:a.name||a.id.slice(0,16)}),b&&(0,d.jsx)(f.Ex,{variant:"Ultra"===b?"warning":"Pro"===b?"primary":"Free"===b?"info":"default",size:"sm",children:b}),Q===a.id&&!1!==a.isActive&&(0,d.jsx)("span",{className:"text-[9px] text-violet-300 bg-violet-500/10 border border-violet-500/20 px-1 py-0.5 rounded shrink-0",children:"next"}),(0,d.jsx)(f.Ex,{variant:!1===a.isActive?"default":"success",size:"sm",children:!1===a.isActive?"disabled":"active"})]}),(0,d.jsxs)("div",{className:"mt-1 flex items-center gap-2 flex-wrap text-[10px] text-text-muted",children:[(0,d.jsxs)("span",{children:["Priority #",a.priority??"-"]}),a.lastUsedAt&&(0,d.jsxs)("span",{children:["Last used ",new Date(a.lastUsedAt).toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit"})]})]})]}),(0,d.jsxs)("div",{className:"flex items-center gap-3 shrink-0",children:["round-robin"===n&&(0,d.jsxs)("button",{onClick:()=>U(a.id),disabled:E||A===a.id||C===a.id,className:"inline-flex items-center gap-1 rounded-md border border-border bg-surface px-2 py-1 text-[10px] font-medium text-text-main hover:border-border-alt hover:bg-surface-alt disabled:opacity-50 disabled:cursor-not-allowed transition-colors",title:"Clear this account's last-used timestamp",children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-[12px]",children:"restart_alt"}),C===a.id?"...":"Reset Order"]}),(0,d.jsx)(f.lM,{size:"sm",checked:!1!==a.isActive,disabled:E||C===a.id||A===a.id,onChange:b=>T(a.id,b)})]})]}),(0,d.jsx)("div",{className:"mt-2 pl-6",children:!1===a.isActive?(0,d.jsx)("div",{className:"text-[10px] text-text-muted",children:"Enable this account to include it in token rotation and load quota reset info."}):(a=>{let b=(a=>{let b=G[a];if(!b)return{state:"empty"};if(b.loading)return{state:"loading"};if(b.error)return{state:"error",error:b.error};if(!b.quotas||0===b.quotas.length)return{state:"no-data"};let c=b.quotas.find(a=>a.modelKey?.includes("claude-sonnet-4-6")||a.name?.toLowerCase().includes("opus"))||b.quotas[0];if(!c)return{state:"no-data"};let d=void 0!==c.remainingPercentage?Math.round(c.remainingPercentage):c.total>0?Math.round((c.total-c.used)/c.total*100):null,e=(c.resetAt&&new Date(c.resetAt).getTime()>Date.now()?c.resetAt:null)||[...b.quotas].map(a=>a.resetAt).filter(Boolean).filter(a=>new Date(a).getTime()>Date.now()).sort((a,b)=>new Date(a).getTime()-new Date(b).getTime())[0]||null;return{state:null===d?"no-data":"ready",highlight:c,accountType:b.accountType||null,pct:d,nextResetAt:e,resetCountdown:(0,w.mO)(e),resetDisplay:(0,w.sQ)(e)}})(a);if(!b||"empty"===b.state)return(0,d.jsx)("span",{className:"text-[10px] text-text-muted",children:"Enable to load quota data"});if("loading"===b.state)return(0,d.jsx)("span",{className:"text-[10px] text-text-muted animate-pulse",children:"Loading quota…"});if("error"===b.state)return(0,d.jsx)("span",{className:"text-[10px] text-red-400",title:b.error,children:"Quota unavailable"});if("no-data"===b.state)return(0,d.jsx)("span",{className:"text-[10px] text-text-muted",children:"No quota data"});let{highlight:c,pct:e,resetCountdown:f,resetDisplay:g}=b;return(0,d.jsxs)("div",{className:"flex flex-col gap-1.5 min-w-0",children:[(0,d.jsxs)("div",{className:"flex items-center gap-2 min-w-0",children:[(0,d.jsx)("span",{className:"text-[10px] text-text-muted truncate",children:c.name}),(0,d.jsx)("div",{className:"flex-1 h-1.5 rounded-full bg-surface-alt overflow-hidden min-w-[56px]",children:(0,d.jsx)("div",{className:`h-full rounded-full ${e>70?"bg-green-500":e>=30?"bg-yellow-500":"bg-red-500"}`,style:{width:`${Math.min(e,100)}%`}})}),(0,d.jsxs)("span",{className:`text-[10px] font-medium shrink-0 ${e>70?"text-green-500":e>=30?"text-yellow-500":"text-red-500"}`,children:[e,"%"]})]}),"-"!==f&&g?(0,d.jsxs)("div",{className:"text-[10px] text-text-muted",children:["Reset in ",(0,d.jsx)("span",{className:"text-text-main",children:f}),(0,d.jsxs)("span",{className:"text-text-muted/70",children:[" • ",g]})]}):(0,d.jsx)("div",{className:"text-[10px] text-text-muted",children:"Reset time unavailable"})]})})(a.id)})]},a.id)}),(0,d.jsxs)(u(),{href:"/dashboard/providers",className:"text-[11px] text-primary hover:underline flex items-center gap-1 px-1 mt-1",children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-[12px]",children:"open_in_new"}),"Manage accounts"]})]}):(0,d.jsx)("div",{className:"px-1",children:(0,d.jsxs)("p",{className:"text-xs text-text-muted",children:["No active ",a.name," accounts in pool."," ",(0,d.jsx)(u(),{href:"/dashboard/providers",className:"text-primary hover:underline",children:"Add account →"})]})})]}),!R&&(0,d.jsxs)("div",{className:"flex items-center gap-2 px-2 py-1.5 rounded text-xs bg-amber-500/10 text-amber-600 border border-amber-500/20",children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"warning"}),(0,d.jsx)("span",{children:"Start MITM server and enable DNS to activate token rotation"})]})]})]})}}};
|