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,4 +1,4 @@
|
|
|
1
|
-
"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[5507],{3176:(e,t,s)=>{s.d(t,{Tk:()=>o,Ah:()=>d,a7:()=>u,ZM:()=>x,tA:()=>g,kn:()=>f,yZ:()=>m,qO:()=>p,xm:()=>k});var a=s(95155),r=s(12115),l=s(35497),i=s(5772);let n="https://9router.com";function o({tool:e,isExpanded:t,onToggle:s,activeProviders:d,modelMappings:c,onModelMappingChange:x,baseUrl:m,hasActiveProviders:u,apiKeys:p,cloudEnabled:h,initialStatus:g}){let f,y,b,[j,N]=(0,r.useState)(g||null),[v,w]=(0,r.useState)(!1),[k,C]=(0,r.useState)(!1),[S,A]=(0,r.useState)(!1),[_,E]=(0,r.useState)(null),[T,O]=(0,r.useState)(!1),[M,P]=(0,r.useState)(!1),[R,I]=(0,r.useState)(null),[$,D]=(0,r.useState)(""),[U,K]=(0,r.useState)({}),[L,F]=(0,r.useState)(!1),[z,q]=(0,r.useState)(""),[H,B]=(0,r.useState)(!1),J=(0,r.useRef)(!1),W=(()=>{if(!j?.installed)return null;let e=j.settings?.env?.ANTHROPIC_BASE_URL;if(!e)return"not_configured";let t=e.includes("localhost")||e.includes("127.0.0.1"),s=h&&n&&e.startsWith(n),a=m&&e.startsWith(m);return t||s||a?"configured":"other"})();(0,r.useEffect)(()=>{p?.length>0&&!$&&D(p[0].key)},[p,$]),(0,r.useEffect)(()=>{g&&N(g)},[g]),(0,r.useEffect)(()=>{t&&!j&&(Y(),Z()),t&&Z()},[t]),(0,r.useEffect)(()=>{fetch("/api/settings").then(e=>e.json()).then(e=>{B(!!e.ccFilterNaming)}).catch(()=>{})},[]);let G=async e=>{let t=e.target.checked;B(t),await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({ccFilterNaming:t})}).catch(()=>{})},Z=async()=>{try{let e=await fetch("/api/models/alias"),t=await e.json();e.ok&&K(t.aliases||{})}catch(e){console.log("Error fetching model aliases:",e)}};(0,r.useEffect)(()=>{if(j?.installed&&!J.current){J.current=!0;let t=j.settings?.env||{};e.defaultModels.forEach(e=>{if(e.envKey){let s=t[e.envKey]||e.defaultValue||"";s&&x(e.alias,s)}});let s=t.ANTHROPIC_AUTH_TOKEN;s&&p?.some(e=>e.key===s)&&D(s)}},[j,p,e.defaultModels,x]);let Y=async()=>{w(!0);try{let e=await fetch("/api/cli-tools/claude-settings"),t=await e.json();N(t)}catch(e){N({installed:!1,error:e.message})}finally{w(!1)}},V=()=>{let e=z||m;return e.endsWith("/v1")?e:`${e}/v1`},Q=async()=>{C(!0),E(null);try{let t={ANTHROPIC_BASE_URL:V()},s=$?.trim()||(p?.length>0?p[0].key:null)||(h?null:"sk_9router");s&&(t.ANTHROPIC_AUTH_TOKEN=s),e.defaultModels.forEach(e=>{let s=c[e.alias];s&&e.envKey&&(t[e.envKey]=s)});let a=await fetch("/api/cli-tools/claude-settings",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({env:t})}),r=await a.json();a.ok?(E({type:"success",text:"Settings applied successfully!"}),N(e=>({...e,hasBackup:!0,settings:{...e?.settings,env:t}}))):E({type:"error",text:r.error||"Failed to apply settings"})}catch(e){E({type:"error",text:e.message})}finally{C(!1)}},X=async()=>{A(!0),E(null);try{let t=await fetch("/api/cli-tools/claude-settings",{method:"DELETE"}),s=await t.json();t.ok?(E({type:"success",text:"Settings reset successfully!"}),e.defaultModels.forEach(e=>x(e.alias,e.defaultValue||"")),D("")):E({type:"error",text:s.error||"Failed to reset settings"})}catch(e){E({type:"error",text:e.message})}finally{A(!1)}};return(0,a.jsxs)(l.Zp,{padding:"xs",className:"overflow-hidden",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between hover:cursor-pointer",onClick:s,children:[(0,a.jsxs)("div",{className:"flex items-center gap-3",children:[(0,a.jsx)("div",{className:"size-8 flex items-center justify-center shrink-0",children:(0,a.jsx)(i.default,{src:"/providers/claude.png",alt:e.name,width:32,height:32,className:"size-8 object-contain rounded-lg",sizes:"32px",onError:e=>{e.target.style.display="none"}})}),(0,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("h3",{className:"font-medium text-sm",children:e.name}),"configured"===W&&(0,a.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"===W&&(0,a.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"===W&&(0,a.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,a.jsx)("p",{className:"text-xs text-text-muted truncate",children:e.description})]})]}),(0,a.jsx)("span",{className:`material-symbols-outlined text-text-muted text-[20px] transition-transform ${t?"rotate-180":""}`,children:"expand_more"})]}),t&&(0,a.jsxs)("div",{className:"mt-4 pt-4 border-t border-border flex flex-col gap-4",children:[v&&(0,a.jsxs)("div",{className:"flex items-center gap-2 text-text-muted",children:[(0,a.jsx)("span",{className:"material-symbols-outlined animate-spin",children:"progress_activity"}),(0,a.jsx)("span",{children:"Checking Claude CLI..."})]}),!v&&j&&!j.installed&&(0,a.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,a.jsxs)("div",{className:"flex items-center gap-3 p-4 bg-yellow-500/10 border border-yellow-500/30 rounded-lg",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-yellow-500",children:"warning"}),(0,a.jsxs)("div",{className:"flex-1",children:[(0,a.jsx)("p",{className:"font-medium text-yellow-600 dark:text-yellow-400",children:"Claude CLI not installed"}),(0,a.jsx)("p",{className:"text-sm text-text-muted",children:"Please install Claude CLI to use this feature."})]}),(0,a.jsxs)(l.$n,{variant:"outline",size:"sm",onClick:()=>O(!T),children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px] mr-1",children:T?"expand_less":"help"}),T?"Hide":"How to Install"]})]}),T&&(0,a.jsxs)("div",{className:"p-4 bg-surface border border-border rounded-lg",children:[(0,a.jsx)("h4",{className:"font-medium mb-3",children:"Installation Guide"}),(0,a.jsxs)("div",{className:"space-y-3 text-sm",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("p",{className:"text-text-muted mb-1",children:"macOS / Linux / Windows:"}),(0,a.jsx)("code",{className:"block px-3 py-2 bg-black/5 dark:bg-white/5 rounded font-mono text-xs",children:"npm install -g @anthropic-ai/claude-code"})]}),(0,a.jsxs)("p",{className:"text-text-muted",children:["After installation, run ",(0,a.jsx)("code",{className:"px-1 bg-black/5 dark:bg-white/5 rounded",children:"claude"})," to verify."]})]})]})]}),!v&&j?.installed&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{className:"flex flex-col gap-2",children:[j?.settings?.env?.ANTHROPIC_BASE_URL&&(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("span",{className:"w-32 shrink-0 text-sm font-semibold text-text-main text-right",children:"Current"}),(0,a.jsx)("span",{className:"material-symbols-outlined text-text-muted text-[14px]",children:"arrow_forward"}),(0,a.jsx)("span",{className:"flex-1 px-2 py-1.5 text-xs text-text-muted truncate",children:j.settings.env.ANTHROPIC_BASE_URL})]}),(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("span",{className:"w-32 shrink-0 text-sm font-semibold text-text-main text-right",children:"Base URL"}),(0,a.jsx)("span",{className:"material-symbols-outlined text-text-muted text-[14px]",children:"arrow_forward"}),(0,a.jsx)("input",{type:"text",value:(f=z||m).endsWith("/v1")?f:`${f}/v1`,onChange:e=>q(e.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"}),z&&z!==m&&(0,a.jsx)("button",{onClick:()=>q(""),className:"p-1 text-text-muted hover:text-primary rounded transition-colors",title:"Reset to default",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"restart_alt"})})]}),(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("span",{className:"w-32 shrink-0 text-sm font-semibold text-text-main text-right",children:"API Key"}),(0,a.jsx)("span",{className:"material-symbols-outlined text-text-muted text-[14px]",children:"arrow_forward"}),p.length>0?(0,a.jsx)("select",{value:$,onChange:e=>D(e.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:p.map(e=>(0,a.jsx)("option",{value:e.key,children:e.key},e.id))}):(0,a.jsx)("span",{className:"flex-1 text-xs text-text-muted px-2 py-1.5",children:h?"No API keys - Create one in Keys page":"sk_9router (default)"})]}),e.defaultModels.map(e=>(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("span",{className:"w-32 shrink-0 text-sm font-semibold text-text-main text-right",children:e.name}),(0,a.jsx)("span",{className:"material-symbols-outlined text-text-muted text-[14px]",children:"arrow_forward"}),(0,a.jsx)("input",{type:"text",value:c[e.alias]||"",onChange:t=>x(e.alias,t.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,a.jsx)("button",{onClick:()=>{I(e.alias),P(!0)},disabled:!u,className:`px-2 py-1.5 rounded border text-xs transition-colors shrink-0 whitespace-nowrap ${u?"bg-surface border-border text-text-main hover:border-primary cursor-pointer":"opacity-50 cursor-not-allowed border-border"}`,children:"Select Model"}),c[e.alias]&&(0,a.jsx)("button",{onClick:()=>x(e.alias,""),className:"p-1 text-text-muted hover:text-red-500 rounded transition-colors",title:"Clear",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"close"})})]},e.alias)),(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("span",{className:"w-32 shrink-0 text-sm font-semibold text-text-main text-right",children:"Filter naming"}),(0,a.jsx)("span",{className:"material-symbols-outlined text-text-muted text-[14px]",children:"arrow_forward"}),(0,a.jsxs)("label",{className:"flex items-center gap-1.5 cursor-pointer select-none",children:[(0,a.jsx)("input",{type:"checkbox",checked:H,onChange:G,className:"w-3.5 h-3.5 accent-primary cursor-pointer"}),(0,a.jsx)("span",{className:"text-xs text-text-muted",children:"Filter naming requests"})]}),(0,a.jsx)(l.m_,{text:"Intercepts Claude Code's topic-naming requests and returns a fake response locally, saving API tokens.",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-text-muted text-[14px] cursor-help",children:"info"})})]})]}),_&&(0,a.jsxs)("div",{className:`flex items-center gap-2 px-2 py-1.5 rounded text-xs ${"success"===_.type?"bg-green-500/10 text-green-600":"bg-red-500/10 text-red-600"}`,children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"success"===_.type?"check_circle":"error"}),(0,a.jsx)("span",{children:_.text})]}),(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsxs)(l.$n,{variant:"primary",size:"sm",onClick:Q,disabled:!u,loading:k,children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px] mr-1",children:"save"}),"Apply"]}),(0,a.jsxs)(l.$n,{variant:"outline",size:"sm",onClick:X,disabled:!j?.has9Router,loading:S,children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px] mr-1",children:"restore"}),"Reset"]}),(0,a.jsxs)(l.$n,{variant:"ghost",size:"sm",onClick:()=>F(!0),children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px] mr-1",children:"content_copy"}),"Manual Config"]})]})]})]}),(0,a.jsx)(l.rq,{isOpen:M,onClose:()=>P(!1),onSelect:e=>{R&&x(R,e.value)},selectedModel:R?c[R]:null,activeProviders:d,modelAliases:U,title:`Select model for ${R}`}),(0,a.jsx)(l.uR,{isOpen:L,onClose:()=>F(!1),title:"Claude CLI - Manual Configuration",configs:(y=$&&$.trim()?$:h?"<API_KEY_FROM_DASHBOARD>":"sk_9router",b={ANTHROPIC_BASE_URL:V(),ANTHROPIC_AUTH_TOKEN:y},e.defaultModels.forEach(e=>{let t=c[e.alias];t&&e.envKey&&(b[e.envKey]=t)}),[{filename:"~/.claude/settings.json",content:JSON.stringify({env:b},null,2)}])})]})}function d({tool:e,isExpanded:t,onToggle:s,baseUrl:n,apiKeys:o,activeProviders:c,cloudEnabled:x,initialStatus:m}){let u,p,h,[g,f]=(0,r.useState)(m||null),[y,b]=(0,r.useState)(!1),[j,N]=(0,r.useState)(!1),[v,w]=(0,r.useState)(!1),[k,C]=(0,r.useState)(null),[S,A]=(0,r.useState)(!1),[_,E]=(0,r.useState)(""),[T,O]=(0,r.useState)(""),[M,P]=(0,r.useState)(!1),[R,I]=(0,r.useState)({}),[$,D]=(0,r.useState)(!1),[U,K]=(0,r.useState)("");(0,r.useEffect)(()=>{o?.length>0&&!_&&E(o[0].key)},[o,_]),(0,r.useEffect)(()=>{m&&f(m)},[m]),(0,r.useEffect)(()=>{t&&!g&&(q(),L()),t&&L()},[t]);let L=async()=>{try{let e=await fetch("/api/models/alias"),t=await e.json();e.ok&&I(t.aliases||{})}catch(e){console.log("Error fetching model aliases:",e)}};(0,r.useEffect)(()=>{if(g?.config){let e=g.config.match(/^model\s*=\s*"([^"]+)"/m);e&&O(e[1])}},[g]);let F=g?.installed?g.config?g.config.includes(n)||g.config.includes("localhost")||g.config.includes("127.0.0.1")?"configured":"other":"not_configured":null,z=()=>{let e=U||`${n}/v1`;return e.endsWith("/v1")?e:`${e}/v1`},q=async()=>{b(!0);try{let e=await fetch("/api/cli-tools/codex-settings"),t=await e.json();f(t)}catch(e){f({installed:!1,error:e.message})}finally{b(!1)}},H=async()=>{N(!0),C(null);try{let e=_&&_.trim()||x?_:"sk_9router",t=await fetch("/api/cli-tools/codex-settings",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({baseUrl:z(),apiKey:e,model:T})}),s=await t.json();t.ok?(C({type:"success",text:"Settings applied successfully!"}),q()):C({type:"error",text:s.error||"Failed to apply settings"})}catch(e){C({type:"error",text:e.message})}finally{N(!1)}},B=async()=>{w(!0),C(null);try{let e=await fetch("/api/cli-tools/codex-settings",{method:"DELETE"}),t=await e.json();e.ok?(C({type:"success",text:"Settings reset successfully!"}),O(""),q()):C({type:"error",text:t.error||"Failed to reset settings"})}catch(e){C({type:"error",text:e.message})}finally{w(!1)}};return(0,a.jsxs)(l.Zp,{padding:"xs",className:"overflow-hidden",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between hover:cursor-pointer",onClick:s,children:[(0,a.jsxs)("div",{className:"flex items-center gap-3",children:[(0,a.jsx)("div",{className:"size-8 flex items-center justify-center shrink-0",children:(0,a.jsx)(i.default,{src:"/providers/codex.png",alt:e.name,width:32,height:32,className:"size-8 object-contain rounded-lg",sizes:"32px",onError:e=>{e.target.style.display="none"}})}),(0,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("h3",{className:"font-medium text-sm",children:e.name}),"configured"===F&&(0,a.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"===F&&(0,a.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"===F&&(0,a.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,a.jsx)("p",{className:"text-xs text-text-muted truncate",children:e.description})]})]}),(0,a.jsx)("span",{className:`material-symbols-outlined text-text-muted text-[20px] transition-transform ${t?"rotate-180":""}`,children:"expand_more"})]}),t&&(0,a.jsxs)("div",{className:"mt-4 pt-4 border-t border-border flex flex-col gap-4",children:[y&&(0,a.jsxs)("div",{className:"flex items-center gap-2 text-text-muted",children:[(0,a.jsx)("span",{className:"material-symbols-outlined animate-spin",children:"progress_activity"}),(0,a.jsx)("span",{children:"Checking Codex CLI..."})]}),!y&&g&&!g.installed&&(0,a.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,a.jsxs)("div",{className:"flex items-center gap-3 p-4 bg-yellow-500/10 border border-yellow-500/30 rounded-lg",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-yellow-500",children:"warning"}),(0,a.jsxs)("div",{className:"flex-1",children:[(0,a.jsx)("p",{className:"font-medium text-yellow-600 dark:text-yellow-400",children:"Codex CLI not installed"}),(0,a.jsx)("p",{className:"text-sm text-text-muted",children:"Please install Codex CLI to use auto-apply feature."})]}),(0,a.jsxs)(l.$n,{variant:"outline",size:"sm",onClick:()=>A(!S),children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px] mr-1",children:S?"expand_less":"help"}),S?"Hide":"How to Install"]})]}),S&&(0,a.jsxs)("div",{className:"p-4 bg-surface border border-border rounded-lg",children:[(0,a.jsx)("h4",{className:"font-medium mb-3",children:"Installation Guide"}),(0,a.jsxs)("div",{className:"space-y-3 text-sm",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("p",{className:"text-text-muted mb-1",children:"macOS / Linux / Windows:"}),(0,a.jsx)("code",{className:"block px-3 py-2 bg-black/5 dark:bg-white/5 rounded font-mono text-xs",children:"npm install -g @openai/codex"})]}),(0,a.jsxs)("p",{className:"text-text-muted",children:["After installation, run ",(0,a.jsx)("code",{className:"px-1 bg-black/5 dark:bg-white/5 rounded",children:"codex"})," to verify."]}),(0,a.jsx)("div",{className:"pt-2 border-t border-border",children:(0,a.jsxs)("p",{className:"text-text-muted text-xs",children:["Codex uses ",(0,a.jsx)("code",{className:"px-1 bg-black/5 dark:bg-white/5 rounded",children:"~/.codex/auth.json"})," with ",(0,a.jsx)("code",{className:"px-1 bg-black/5 dark:bg-white/5 rounded",children:"OPENAI_API_KEY"}),'. Click "Apply" to auto-configure.']})})]})]})]}),!y&&g?.installed&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{className:"flex flex-col gap-2",children:[g?.config&&((p=(u=g.config.match(/base_url\s*=\s*"([^"]+)"/))?u[1]:null)?(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("span",{className:"w-32 shrink-0 text-sm font-semibold text-text-main text-right",children:"Current"}),(0,a.jsx)("span",{className:"material-symbols-outlined text-text-muted text-[14px]",children:"arrow_forward"}),(0,a.jsx)("span",{className:"flex-1 px-2 py-1.5 text-xs text-text-muted truncate",children:p})]}):null),(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("span",{className:"w-32 shrink-0 text-sm font-semibold text-text-main text-right",children:"Base URL"}),(0,a.jsx)("span",{className:"material-symbols-outlined text-text-muted text-[14px]",children:"arrow_forward"}),(0,a.jsx)("input",{type:"text",value:U||`${n}/v1`,onChange:e=>K(e.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"}),U&&U!==`${n}/v1`&&(0,a.jsx)("button",{onClick:()=>K(""),className:"p-1 text-text-muted hover:text-primary rounded transition-colors",title:"Reset to default",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"restart_alt"})})]}),(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("span",{className:"w-32 shrink-0 text-sm font-semibold text-text-main text-right",children:"API Key"}),(0,a.jsx)("span",{className:"material-symbols-outlined text-text-muted text-[14px]",children:"arrow_forward"}),o.length>0?(0,a.jsx)("select",{value:_,onChange:e=>E(e.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:o.map(e=>(0,a.jsx)("option",{value:e.key,children:e.key},e.id))}):(0,a.jsx)("span",{className:"flex-1 text-xs text-text-muted px-2 py-1.5",children:x?"No API keys - Create one in Keys page":"sk_9router (default)"})]}),(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("span",{className:"w-32 shrink-0 text-sm font-semibold text-text-main text-right",children:"Model"}),(0,a.jsx)("span",{className:"material-symbols-outlined text-text-muted text-[14px]",children:"arrow_forward"}),(0,a.jsx)("input",{type:"text",value:T,onChange:e=>O(e.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,a.jsx)("button",{onClick:()=>P(!0),disabled:!c?.length,className:`px-2 py-1.5 rounded border text-xs transition-colors shrink-0 whitespace-nowrap ${c?.length?"bg-surface border-border text-text-main hover:border-primary cursor-pointer":"opacity-50 cursor-not-allowed border-border"}`,children:"Select Model"}),T&&(0,a.jsx)("button",{onClick:()=>O(""),className:"p-1 text-text-muted hover:text-red-500 rounded transition-colors",title:"Clear",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"close"})})]})]}),k&&(0,a.jsxs)("div",{className:`flex items-center gap-2 px-2 py-1.5 rounded text-xs ${"success"===k.type?"bg-green-500/10 text-green-600":"bg-red-500/10 text-red-600"}`,children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"success"===k.type?"check_circle":"error"}),(0,a.jsx)("span",{children:k.text})]}),(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsxs)(l.$n,{variant:"primary",size:"sm",onClick:H,disabled:!_||!T,loading:j,children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px] mr-1",children:"save"}),"Apply"]}),(0,a.jsxs)(l.$n,{variant:"outline",size:"sm",onClick:B,disabled:!g.has9Router,loading:v,children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px] mr-1",children:"restore"}),"Reset"]}),(0,a.jsxs)(l.$n,{variant:"ghost",size:"sm",onClick:()=>D(!0),children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px] mr-1",children:"content_copy"}),"Manual Config"]})]})]})]}),(0,a.jsx)(l.rq,{isOpen:M,onClose:()=>P(!1),onSelect:e=>{O(e.value),P(!1)},selectedModel:T,activeProviders:c,modelAliases:R,title:"Select Model for Codex"}),(0,a.jsx)(l.uR,{isOpen:$,onClose:()=>D(!1),title:"Codex CLI - Manual Configuration",configs:(h=_&&_.trim()?_:x?"<API_KEY_FROM_DASHBOARD>":"sk_9router",[{filename:"~/.codex/config.toml",content:`# 9Router Configuration for Codex CLI
|
|
1
|
+
"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[5507],{3176:(e,t,s)=>{s.d(t,{Tk:()=>o,Ah:()=>d,a7:()=>u,ZM:()=>x,tA:()=>g,kn:()=>f,yZ:()=>m,qO:()=>p,xm:()=>k});var a=s(95155),r=s(12115),l=s(35497),i=s(5772);let n="https://9router.com";function o({tool:e,isExpanded:t,onToggle:s,activeProviders:d,modelMappings:c,onModelMappingChange:x,baseUrl:m,hasActiveProviders:u,apiKeys:p,cloudEnabled:h,initialStatus:g}){let f,y,b,[j,N]=(0,r.useState)(g||null),[v,w]=(0,r.useState)(!1),[k,C]=(0,r.useState)(!1),[S,A]=(0,r.useState)(!1),[_,E]=(0,r.useState)(null),[T,O]=(0,r.useState)(!1),[M,P]=(0,r.useState)(!1),[$,I]=(0,r.useState)(null),[R,D]=(0,r.useState)(""),[U,K]=(0,r.useState)({}),[L,F]=(0,r.useState)(!1),[z,q]=(0,r.useState)(""),[H,B]=(0,r.useState)(!1),J=(0,r.useRef)(!1),W=(()=>{if(!j?.installed)return null;let e=j.settings?.env?.ANTHROPIC_BASE_URL;if(!e)return"not_configured";let t=e.includes("localhost")||e.includes("127.0.0.1"),s=h&&n&&e.startsWith(n),a=m&&e.startsWith(m);return t||s||a?"configured":"other"})();(0,r.useEffect)(()=>{p?.length>0&&!R&&D(p[0].key)},[p,R]),(0,r.useEffect)(()=>{g&&N(g)},[g]),(0,r.useEffect)(()=>{t&&!j&&(Y(),Z()),t&&Z()},[t]),(0,r.useEffect)(()=>{fetch("/api/settings").then(e=>e.json()).then(e=>{B(!!e.ccFilterNaming)}).catch(()=>{})},[]);let G=async e=>{let t=e.target.checked;B(t),await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({ccFilterNaming:t})}).catch(()=>{})},Z=async()=>{try{let e=await fetch("/api/models/alias"),t=await e.json();e.ok&&K(t.aliases||{})}catch(e){console.log("Error fetching model aliases:",e)}};(0,r.useEffect)(()=>{if(j?.installed&&!J.current){J.current=!0;let t=j.settings?.env||{};e.defaultModels.forEach(e=>{if(e.envKey){let s=t[e.envKey]||e.defaultValue||"";s&&x(e.alias,s)}});let s=t.ANTHROPIC_AUTH_TOKEN;s&&p?.some(e=>e.key===s)&&D(s)}},[j,p,e.defaultModels,x]);let Y=async()=>{w(!0);try{let e=await fetch("/api/cli-tools/claude-settings"),t=await e.json();N(t)}catch(e){N({installed:!1,error:e.message})}finally{w(!1)}},V=()=>{let e=z||m;return e.endsWith("/v1")?e:`${e}/v1`},Q=async()=>{C(!0),E(null);try{let t={ANTHROPIC_BASE_URL:V()},s=R?.trim()||(p?.length>0?p[0].key:null)||(h?null:"sk_9router");s&&(t.ANTHROPIC_AUTH_TOKEN=s),e.defaultModels.forEach(e=>{let s=c[e.alias];s&&e.envKey&&(t[e.envKey]=s)});let a=await fetch("/api/cli-tools/claude-settings",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({env:t})}),r=await a.json();a.ok?(E({type:"success",text:"Settings applied successfully!"}),N(e=>({...e,hasBackup:!0,settings:{...e?.settings,env:t}}))):E({type:"error",text:r.error||"Failed to apply settings"})}catch(e){E({type:"error",text:e.message})}finally{C(!1)}},X=async()=>{A(!0),E(null);try{let t=await fetch("/api/cli-tools/claude-settings",{method:"DELETE"}),s=await t.json();t.ok?(E({type:"success",text:"Settings reset successfully!"}),e.defaultModels.forEach(e=>x(e.alias,e.defaultValue||"")),D("")):E({type:"error",text:s.error||"Failed to reset settings"})}catch(e){E({type:"error",text:e.message})}finally{A(!1)}};return(0,a.jsxs)(l.Zp,{padding:"xs",className:"overflow-hidden",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between hover:cursor-pointer",onClick:s,children:[(0,a.jsxs)("div",{className:"flex items-center gap-3",children:[(0,a.jsx)("div",{className:"size-8 flex items-center justify-center shrink-0",children:(0,a.jsx)(i.default,{src:"/providers/claude.png",alt:e.name,width:32,height:32,className:"size-8 object-contain rounded-lg",sizes:"32px",onError:e=>{e.target.style.display="none"}})}),(0,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("h3",{className:"font-medium text-sm",children:e.name}),"configured"===W&&(0,a.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"===W&&(0,a.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"===W&&(0,a.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,a.jsx)("p",{className:"text-xs text-text-muted truncate",children:e.description})]})]}),(0,a.jsx)("span",{className:`material-symbols-outlined text-text-muted text-[20px] transition-transform ${t?"rotate-180":""}`,children:"expand_more"})]}),t&&(0,a.jsxs)("div",{className:"mt-4 pt-4 border-t border-border flex flex-col gap-4",children:[v&&(0,a.jsxs)("div",{className:"flex items-center gap-2 text-text-muted",children:[(0,a.jsx)("span",{className:"material-symbols-outlined animate-spin",children:"progress_activity"}),(0,a.jsx)("span",{children:"Checking Claude CLI..."})]}),!v&&j&&!j.installed&&(0,a.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,a.jsxs)("div",{className:"flex items-center gap-3 p-4 bg-yellow-500/10 border border-yellow-500/30 rounded-lg",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-yellow-500",children:"warning"}),(0,a.jsxs)("div",{className:"flex-1",children:[(0,a.jsx)("p",{className:"font-medium text-yellow-600 dark:text-yellow-400",children:"Claude CLI not installed"}),(0,a.jsx)("p",{className:"text-sm text-text-muted",children:"Please install Claude CLI to use this feature."})]}),(0,a.jsxs)(l.$n,{variant:"outline",size:"sm",onClick:()=>O(!T),children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px] mr-1",children:T?"expand_less":"help"}),T?"Hide":"How to Install"]})]}),T&&(0,a.jsxs)("div",{className:"p-4 bg-surface border border-border rounded-lg",children:[(0,a.jsx)("h4",{className:"font-medium mb-3",children:"Installation Guide"}),(0,a.jsxs)("div",{className:"space-y-3 text-sm",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("p",{className:"text-text-muted mb-1",children:"macOS / Linux / Windows:"}),(0,a.jsx)("code",{className:"block px-3 py-2 bg-black/5 dark:bg-white/5 rounded font-mono text-xs",children:"npm install -g @anthropic-ai/claude-code"})]}),(0,a.jsxs)("p",{className:"text-text-muted",children:["After installation, run ",(0,a.jsx)("code",{className:"px-1 bg-black/5 dark:bg-white/5 rounded",children:"claude"})," to verify."]})]})]})]}),!v&&j?.installed&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{className:"flex flex-col gap-2",children:[j?.settings?.env?.ANTHROPIC_BASE_URL&&(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("span",{className:"w-32 shrink-0 text-sm font-semibold text-text-main text-right",children:"Current"}),(0,a.jsx)("span",{className:"material-symbols-outlined text-text-muted text-[14px]",children:"arrow_forward"}),(0,a.jsx)("span",{className:"flex-1 px-2 py-1.5 text-xs text-text-muted truncate",children:j.settings.env.ANTHROPIC_BASE_URL})]}),(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("span",{className:"w-32 shrink-0 text-sm font-semibold text-text-main text-right",children:"Base URL"}),(0,a.jsx)("span",{className:"material-symbols-outlined text-text-muted text-[14px]",children:"arrow_forward"}),(0,a.jsx)("input",{type:"text",value:(f=z||m).endsWith("/v1")?f:`${f}/v1`,onChange:e=>q(e.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"}),z&&z!==m&&(0,a.jsx)("button",{onClick:()=>q(""),className:"p-1 text-text-muted hover:text-primary rounded transition-colors",title:"Reset to default",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"restart_alt"})})]}),(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("span",{className:"w-32 shrink-0 text-sm font-semibold text-text-main text-right",children:"API Key"}),(0,a.jsx)("span",{className:"material-symbols-outlined text-text-muted text-[14px]",children:"arrow_forward"}),p.length>0?(0,a.jsx)("select",{value:R,onChange:e=>D(e.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:p.map(e=>(0,a.jsx)("option",{value:e.key,children:e.key},e.id))}):(0,a.jsx)("span",{className:"flex-1 text-xs text-text-muted px-2 py-1.5",children:h?"No API keys - Create one in Keys page":"sk_9router (default)"})]}),e.defaultModels.map(e=>(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("span",{className:"w-32 shrink-0 text-sm font-semibold text-text-main text-right",children:e.name}),(0,a.jsx)("span",{className:"material-symbols-outlined text-text-muted text-[14px]",children:"arrow_forward"}),(0,a.jsx)("input",{type:"text",value:c[e.alias]||"",onChange:t=>x(e.alias,t.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,a.jsx)("button",{onClick:()=>{I(e.alias),P(!0)},disabled:!u,className:`px-2 py-1.5 rounded border text-xs transition-colors shrink-0 whitespace-nowrap ${u?"bg-surface border-border text-text-main hover:border-primary cursor-pointer":"opacity-50 cursor-not-allowed border-border"}`,children:"Select Model"}),c[e.alias]&&(0,a.jsx)("button",{onClick:()=>x(e.alias,""),className:"p-1 text-text-muted hover:text-red-500 rounded transition-colors",title:"Clear",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"close"})})]},e.alias)),(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("span",{className:"w-32 shrink-0 text-sm font-semibold text-text-main text-right",children:"Filter naming"}),(0,a.jsx)("span",{className:"material-symbols-outlined text-text-muted text-[14px]",children:"arrow_forward"}),(0,a.jsxs)("label",{className:"flex items-center gap-1.5 cursor-pointer select-none",children:[(0,a.jsx)("input",{type:"checkbox",checked:H,onChange:G,className:"w-3.5 h-3.5 accent-primary cursor-pointer"}),(0,a.jsx)("span",{className:"text-xs text-text-muted",children:"Filter naming requests"})]}),(0,a.jsx)(l.m_,{text:"Intercepts Claude Code's topic-naming requests and returns a fake response locally, saving API tokens.",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-text-muted text-[14px] cursor-help",children:"info"})})]})]}),_&&(0,a.jsxs)("div",{className:`flex items-center gap-2 px-2 py-1.5 rounded text-xs ${"success"===_.type?"bg-green-500/10 text-green-600":"bg-red-500/10 text-red-600"}`,children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"success"===_.type?"check_circle":"error"}),(0,a.jsx)("span",{children:_.text})]}),(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsxs)(l.$n,{variant:"primary",size:"sm",onClick:Q,disabled:!u,loading:k,children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px] mr-1",children:"save"}),"Apply"]}),(0,a.jsxs)(l.$n,{variant:"outline",size:"sm",onClick:X,disabled:!j?.has9Router,loading:S,children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px] mr-1",children:"restore"}),"Reset"]}),(0,a.jsxs)(l.$n,{variant:"ghost",size:"sm",onClick:()=>F(!0),children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px] mr-1",children:"content_copy"}),"Manual Config"]})]})]})]}),(0,a.jsx)(l.rq,{isOpen:M,onClose:()=>P(!1),onSelect:e=>{$&&x($,e.value)},selectedModel:$?c[$]:null,activeProviders:d,modelAliases:U,title:`Select model for ${$}`}),(0,a.jsx)(l.uR,{isOpen:L,onClose:()=>F(!1),title:"Claude CLI - Manual Configuration",configs:(y=R&&R.trim()?R:h?"<API_KEY_FROM_DASHBOARD>":"sk_9router",b={ANTHROPIC_BASE_URL:V(),ANTHROPIC_AUTH_TOKEN:y},e.defaultModels.forEach(e=>{let t=c[e.alias];t&&e.envKey&&(b[e.envKey]=t)}),[{filename:"~/.claude/settings.json",content:JSON.stringify({env:b},null,2)}])})]})}function d({tool:e,isExpanded:t,onToggle:s,baseUrl:n,apiKeys:o,activeProviders:c,cloudEnabled:x,initialStatus:m}){let u,p,h,[g,f]=(0,r.useState)(m||null),[y,b]=(0,r.useState)(!1),[j,N]=(0,r.useState)(!1),[v,w]=(0,r.useState)(!1),[k,C]=(0,r.useState)(null),[S,A]=(0,r.useState)(!1),[_,E]=(0,r.useState)(""),[T,O]=(0,r.useState)(""),[M,P]=(0,r.useState)(!1),[$,I]=(0,r.useState)({}),[R,D]=(0,r.useState)(!1),[U,K]=(0,r.useState)("");(0,r.useEffect)(()=>{o?.length>0&&!_&&E(o[0].key)},[o,_]),(0,r.useEffect)(()=>{m&&f(m)},[m]),(0,r.useEffect)(()=>{t&&!g&&(q(),L()),t&&L()},[t]);let L=async()=>{try{let e=await fetch("/api/models/alias"),t=await e.json();e.ok&&I(t.aliases||{})}catch(e){console.log("Error fetching model aliases:",e)}};(0,r.useEffect)(()=>{if(g?.config){let e=g.config.match(/^model\s*=\s*"([^"]+)"/m);e&&O(e[1])}},[g]);let F=g?.installed?g.config?g.config.includes(n)||g.config.includes("localhost")||g.config.includes("127.0.0.1")?"configured":"other":"not_configured":null,z=()=>{let e=U||`${n}/v1`;return e.endsWith("/v1")?e:`${e}/v1`},q=async()=>{b(!0);try{let e=await fetch("/api/cli-tools/codex-settings"),t=await e.json();f(t)}catch(e){f({installed:!1,error:e.message})}finally{b(!1)}},H=async()=>{N(!0),C(null);try{let e=_&&_.trim()||x?_:"sk_9router",t=await fetch("/api/cli-tools/codex-settings",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({baseUrl:z(),apiKey:e,model:T})}),s=await t.json();t.ok?(C({type:"success",text:"Settings applied successfully!"}),q()):C({type:"error",text:s.error||"Failed to apply settings"})}catch(e){C({type:"error",text:e.message})}finally{N(!1)}},B=async()=>{w(!0),C(null);try{let e=await fetch("/api/cli-tools/codex-settings",{method:"DELETE"}),t=await e.json();e.ok?(C({type:"success",text:"Settings reset successfully!"}),O(""),q()):C({type:"error",text:t.error||"Failed to reset settings"})}catch(e){C({type:"error",text:e.message})}finally{w(!1)}};return(0,a.jsxs)(l.Zp,{padding:"xs",className:"overflow-hidden",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between hover:cursor-pointer",onClick:s,children:[(0,a.jsxs)("div",{className:"flex items-center gap-3",children:[(0,a.jsx)("div",{className:"size-8 flex items-center justify-center shrink-0",children:(0,a.jsx)(i.default,{src:"/providers/codex.png",alt:e.name,width:32,height:32,className:"size-8 object-contain rounded-lg",sizes:"32px",onError:e=>{e.target.style.display="none"}})}),(0,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("h3",{className:"font-medium text-sm",children:e.name}),"configured"===F&&(0,a.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"===F&&(0,a.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"===F&&(0,a.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,a.jsx)("p",{className:"text-xs text-text-muted truncate",children:e.description})]})]}),(0,a.jsx)("span",{className:`material-symbols-outlined text-text-muted text-[20px] transition-transform ${t?"rotate-180":""}`,children:"expand_more"})]}),t&&(0,a.jsxs)("div",{className:"mt-4 pt-4 border-t border-border flex flex-col gap-4",children:[y&&(0,a.jsxs)("div",{className:"flex items-center gap-2 text-text-muted",children:[(0,a.jsx)("span",{className:"material-symbols-outlined animate-spin",children:"progress_activity"}),(0,a.jsx)("span",{children:"Checking Codex CLI..."})]}),!y&&g&&!g.installed&&(0,a.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,a.jsxs)("div",{className:"flex items-center gap-3 p-4 bg-yellow-500/10 border border-yellow-500/30 rounded-lg",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-yellow-500",children:"warning"}),(0,a.jsxs)("div",{className:"flex-1",children:[(0,a.jsx)("p",{className:"font-medium text-yellow-600 dark:text-yellow-400",children:"Codex CLI not installed"}),(0,a.jsx)("p",{className:"text-sm text-text-muted",children:"Please install Codex CLI to use auto-apply feature."})]}),(0,a.jsxs)(l.$n,{variant:"outline",size:"sm",onClick:()=>A(!S),children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px] mr-1",children:S?"expand_less":"help"}),S?"Hide":"How to Install"]})]}),S&&(0,a.jsxs)("div",{className:"p-4 bg-surface border border-border rounded-lg",children:[(0,a.jsx)("h4",{className:"font-medium mb-3",children:"Installation Guide"}),(0,a.jsxs)("div",{className:"space-y-3 text-sm",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("p",{className:"text-text-muted mb-1",children:"macOS / Linux / Windows:"}),(0,a.jsx)("code",{className:"block px-3 py-2 bg-black/5 dark:bg-white/5 rounded font-mono text-xs",children:"npm install -g @openai/codex"})]}),(0,a.jsxs)("p",{className:"text-text-muted",children:["After installation, run ",(0,a.jsx)("code",{className:"px-1 bg-black/5 dark:bg-white/5 rounded",children:"codex"})," to verify."]}),(0,a.jsx)("div",{className:"pt-2 border-t border-border",children:(0,a.jsxs)("p",{className:"text-text-muted text-xs",children:["Codex uses ",(0,a.jsx)("code",{className:"px-1 bg-black/5 dark:bg-white/5 rounded",children:"~/.codex/auth.json"})," with ",(0,a.jsx)("code",{className:"px-1 bg-black/5 dark:bg-white/5 rounded",children:"OPENAI_API_KEY"}),'. Click "Apply" to auto-configure.']})})]})]})]}),!y&&g?.installed&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{className:"flex flex-col gap-2",children:[g?.config&&((p=(u=g.config.match(/base_url\s*=\s*"([^"]+)"/))?u[1]:null)?(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("span",{className:"w-32 shrink-0 text-sm font-semibold text-text-main text-right",children:"Current"}),(0,a.jsx)("span",{className:"material-symbols-outlined text-text-muted text-[14px]",children:"arrow_forward"}),(0,a.jsx)("span",{className:"flex-1 px-2 py-1.5 text-xs text-text-muted truncate",children:p})]}):null),(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("span",{className:"w-32 shrink-0 text-sm font-semibold text-text-main text-right",children:"Base URL"}),(0,a.jsx)("span",{className:"material-symbols-outlined text-text-muted text-[14px]",children:"arrow_forward"}),(0,a.jsx)("input",{type:"text",value:U||`${n}/v1`,onChange:e=>K(e.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"}),U&&U!==`${n}/v1`&&(0,a.jsx)("button",{onClick:()=>K(""),className:"p-1 text-text-muted hover:text-primary rounded transition-colors",title:"Reset to default",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"restart_alt"})})]}),(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("span",{className:"w-32 shrink-0 text-sm font-semibold text-text-main text-right",children:"API Key"}),(0,a.jsx)("span",{className:"material-symbols-outlined text-text-muted text-[14px]",children:"arrow_forward"}),o.length>0?(0,a.jsx)("select",{value:_,onChange:e=>E(e.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:o.map(e=>(0,a.jsx)("option",{value:e.key,children:e.key},e.id))}):(0,a.jsx)("span",{className:"flex-1 text-xs text-text-muted px-2 py-1.5",children:x?"No API keys - Create one in Keys page":"sk_9router (default)"})]}),(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("span",{className:"w-32 shrink-0 text-sm font-semibold text-text-main text-right",children:"Model"}),(0,a.jsx)("span",{className:"material-symbols-outlined text-text-muted text-[14px]",children:"arrow_forward"}),(0,a.jsx)("input",{type:"text",value:T,onChange:e=>O(e.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,a.jsx)("button",{onClick:()=>P(!0),disabled:!c?.length,className:`px-2 py-1.5 rounded border text-xs transition-colors shrink-0 whitespace-nowrap ${c?.length?"bg-surface border-border text-text-main hover:border-primary cursor-pointer":"opacity-50 cursor-not-allowed border-border"}`,children:"Select Model"}),T&&(0,a.jsx)("button",{onClick:()=>O(""),className:"p-1 text-text-muted hover:text-red-500 rounded transition-colors",title:"Clear",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"close"})})]})]}),k&&(0,a.jsxs)("div",{className:`flex items-center gap-2 px-2 py-1.5 rounded text-xs ${"success"===k.type?"bg-green-500/10 text-green-600":"bg-red-500/10 text-red-600"}`,children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"success"===k.type?"check_circle":"error"}),(0,a.jsx)("span",{children:k.text})]}),(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsxs)(l.$n,{variant:"primary",size:"sm",onClick:H,disabled:!_||!T,loading:j,children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px] mr-1",children:"save"}),"Apply"]}),(0,a.jsxs)(l.$n,{variant:"outline",size:"sm",onClick:B,disabled:!g.has9Router,loading:v,children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px] mr-1",children:"restore"}),"Reset"]}),(0,a.jsxs)(l.$n,{variant:"ghost",size:"sm",onClick:()=>D(!0),children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px] mr-1",children:"content_copy"}),"Manual Config"]})]})]})]}),(0,a.jsx)(l.rq,{isOpen:M,onClose:()=>P(!1),onSelect:e=>{O(e.value),P(!1)},selectedModel:T,activeProviders:c,modelAliases:$,title:"Select Model for Codex"}),(0,a.jsx)(l.uR,{isOpen:R,onClose:()=>D(!1),title:"Codex CLI - Manual Configuration",configs:(h=_&&_.trim()?_:x?"<API_KEY_FROM_DASHBOARD>":"sk_9router",[{filename:"~/.codex/config.toml",content:`# 9Router Configuration for Codex CLI
|
|
2
2
|
model = "${T}"
|
|
3
3
|
model_provider = "9router"
|
|
4
4
|
|
|
@@ -6,7 +6,7 @@ model_provider = "9router"
|
|
|
6
6
|
name = "9Router"
|
|
7
7
|
base_url = "${z()}"
|
|
8
8
|
wire_api = "responses"
|
|
9
|
-
`},{filename:"~/.codex/auth.json",content:JSON.stringify({OPENAI_API_KEY:h},null,2)}])})]})}let c="https://9router.com";function x({tool:e,isExpanded:t,onToggle:s,baseUrl:n,hasActiveProviders:o,apiKeys:d,activeProviders:m,cloudEnabled:u,initialStatus:p}){let h,g,f,y,[b,j]=(0,r.useState)(p||null),[N,v]=(0,r.useState)(!1),[w,k]=(0,r.useState)(!1),[C,S]=(0,r.useState)(!1),[A,_]=(0,r.useState)(null),[E,T]=(0,r.useState)(""),[O,M]=(0,r.useState)(""),[P,R]=(0,r.useState)(!1),[I,$]=(0,r.useState)({}),[D,U]=(0,r.useState)(!1),[K,L]=(0,r.useState)(""),F=(0,r.useRef)(!1),z=(()=>{if(!b?.installed)return null;let e=b.settings?.customModels?.find(e=>"custom:9Router-0"===e.id);if(!e)return"not_configured";let t=e.baseUrl?.includes("localhost")||e.baseUrl?.includes("127.0.0.1"),s=u&&c&&e.baseUrl?.startsWith(c),a=n&&e.baseUrl?.startsWith(n);return t||s||a?"configured":"other"})();(0,r.useEffect)(()=>{d?.length>0&&!E&&T(d[0].key)},[d,E]),(0,r.useEffect)(()=>{p&&j(p)},[p]),(0,r.useEffect)(()=>{t&&!b&&(H(),q()),t&&q()},[t]);let q=async()=>{try{let e=await fetch("/api/models/alias"),t=await e.json();e.ok&&$(t.aliases||{})}catch(e){console.log("Error fetching model aliases:",e)}};(0,r.useEffect)(()=>{if(b?.installed&&!F.current){F.current=!0;let e=b.settings?.customModels?.find(e=>"custom:9Router-0"===e.id);e&&(e.model&&M(e.model),e.apiKey&&d?.some(t=>t.key===e.apiKey)&&T(e.apiKey))}},[b,d]);let H=async()=>{v(!0);try{let e=await fetch("/api/cli-tools/droid-settings"),t=await e.json();j(t)}catch(e){j({installed:!1,error:e.message})}finally{v(!1)}},B=()=>{let e=K||n;return e.endsWith("/v1")?e:`${e}/v1`},J=async()=>{k(!0),_(null);try{let e=E?.trim()||(d?.length>0?d[0].key:null)||(u?null:"sk_9router"),t=await fetch("/api/cli-tools/droid-settings",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({baseUrl:B(),apiKey:e,model:O})}),s=await t.json();t.ok?(_({type:"success",text:"Settings applied successfully!"}),H()):_({type:"error",text:s.error||"Failed to apply settings"})}catch(e){_({type:"error",text:e.message})}finally{k(!1)}},W=async()=>{S(!0),_(null);try{let e=await fetch("/api/cli-tools/droid-settings",{method:"DELETE"}),t=await e.json();e.ok?(_({type:"success",text:"Settings reset successfully!"}),M(""),T(""),H()):_({type:"error",text:t.error||"Failed to reset settings"})}catch(e){_({type:"error",text:e.message})}finally{S(!1)}};return(0,a.jsxs)(l.Zp,{padding:"xs",className:"overflow-hidden",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between hover:cursor-pointer",onClick:s,children:[(0,a.jsxs)("div",{className:"flex items-center gap-3",children:[(0,a.jsx)("div",{className:"size-8 flex items-center justify-center shrink-0",children:(0,a.jsx)(i.default,{src:"/providers/droid.png",alt:e.name,width:32,height:32,className:"size-8 object-contain rounded-lg",sizes:"32px",onError:e=>{e.target.style.display="none"}})}),(0,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("h3",{className:"font-medium text-sm",children:e.name}),"configured"===z&&(0,a.jsx)("span",{className:"px-1.5 py-0.5 text-[10px] font-medium bg-green-500/10 text-green-600 dark:text-green-400 rounded-full",children:"Connected"}),"not_configured"===z&&(0,a.jsx)("span",{className:"px-1.5 py-0.5 text-[10px] font-medium bg-yellow-500/10 text-yellow-600 dark:text-yellow-400 rounded-full",children:"Not configured"}),"other"===z&&(0,a.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,a.jsx)("p",{className:"text-xs text-text-muted truncate",children:e.description})]})]}),(0,a.jsx)("span",{className:`material-symbols-outlined text-text-muted text-[20px] transition-transform ${t?"rotate-180":""}`,children:"expand_more"})]}),t&&(0,a.jsxs)("div",{className:"mt-4 pt-4 border-t border-border flex flex-col gap-4",children:[N&&(0,a.jsxs)("div",{className:"flex items-center gap-2 text-text-muted",children:[(0,a.jsx)("span",{className:"material-symbols-outlined animate-spin",children:"progress_activity"}),(0,a.jsx)("span",{children:"Checking Factory Droid CLI..."})]}),!N&&b&&!b.installed&&(0,a.jsxs)("div",{className:"flex items-center gap-3 p-4 bg-yellow-500/10 border border-yellow-500/30 rounded-lg",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-yellow-500",children:"warning"}),(0,a.jsxs)("div",{className:"flex-1",children:[(0,a.jsx)("p",{className:"font-medium text-yellow-600 dark:text-yellow-400",children:"Factory Droid CLI not installed"}),(0,a.jsx)("p",{className:"text-sm text-text-muted",children:"Please install Factory Droid CLI to use this feature."})]})]}),!N&&b?.installed&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{className:"flex flex-col gap-2",children:[b?.settings?.customModels?.find(e=>"custom:9Router-0"===e.id)?.baseUrl&&(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("span",{className:"w-32 shrink-0 text-sm font-semibold text-text-main text-right",children:"Current"}),(0,a.jsx)("span",{className:"material-symbols-outlined text-text-muted text-[14px]",children:"arrow_forward"}),(0,a.jsx)("span",{className:"flex-1 px-2 py-1.5 text-xs text-text-muted truncate",children:b.settings.customModels.find(e=>"custom:9Router-0"===e.id).baseUrl})]}),(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("span",{className:"w-32 shrink-0 text-sm font-semibold text-text-main text-right",children:"Base URL"}),(0,a.jsx)("span",{className:"material-symbols-outlined text-text-muted text-[14px]",children:"arrow_forward"}),(0,a.jsx)("input",{type:"text",value:(h=K||n).endsWith("/v1")?h:`${h}/v1`,onChange:e=>L(e.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!==n&&(0,a.jsx)("button",{onClick:()=>L(""),className:"p-1 text-text-muted hover:text-primary rounded transition-colors",title:"Reset to default",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"restart_alt"})})]}),(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("span",{className:"w-32 shrink-0 text-sm font-semibold text-text-main text-right",children:"API Key"}),(0,a.jsx)("span",{className:"material-symbols-outlined text-text-muted text-[14px]",children:"arrow_forward"}),d.length>0?(0,a.jsx)("select",{value:E,onChange:e=>T(e.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:d.map(e=>(0,a.jsx)("option",{value:e.key,children:e.key},e.id))}):(0,a.jsx)("span",{className:"flex-1 text-xs text-text-muted px-2 py-1.5",children:u?"No API keys - Create one in Keys page":"sk_9router (default)"})]}),(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("span",{className:"w-32 shrink-0 text-sm font-semibold text-text-main text-right",children:"Model"}),(0,a.jsx)("span",{className:"material-symbols-outlined text-text-muted text-[14px]",children:"arrow_forward"}),(0,a.jsx)("input",{type:"text",value:O,onChange:e=>M(e.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,a.jsx)("button",{onClick:()=>R(!0),disabled:!o,className:`px-2 py-1.5 rounded border text-xs transition-colors shrink-0 whitespace-nowrap ${o?"bg-surface border-border text-text-main hover:border-primary cursor-pointer":"opacity-50 cursor-not-allowed border-border"}`,children:"Select Model"}),O&&(0,a.jsx)("button",{onClick:()=>M(""),className:"p-1 text-text-muted hover:text-red-500 rounded transition-colors",title:"Clear",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"close"})})]})]}),A&&(0,a.jsxs)("div",{className:`flex items-center gap-2 px-2 py-1.5 rounded text-xs ${"success"===A.type?"bg-green-500/10 text-green-600":"bg-red-500/10 text-red-600"}`,children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"success"===A.type?"check_circle":"error"}),(0,a.jsx)("span",{children:A.text})]}),(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsxs)(l.$n,{variant:"primary",size:"sm",onClick:J,disabled:!O,loading:w,children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px] mr-1",children:"save"}),"Apply"]}),(0,a.jsxs)(l.$n,{variant:"outline",size:"sm",onClick:W,disabled:!b?.has9Router,loading:C,children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px] mr-1",children:"restore"}),"Reset"]}),(0,a.jsxs)(l.$n,{variant:"ghost",size:"sm",onClick:()=>U(!0),children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px] mr-1",children:"content_copy"}),"Manual Config"]})]})]})]}),(0,a.jsx)(l.rq,{isOpen:P,onClose:()=>R(!1),onSelect:e=>{M(e.value),R(!1)},selectedModel:O,activeProviders:m,modelAliases:I,title:"Select Model for Factory Droid"}),(0,a.jsx)(l.uR,{isOpen:D,onClose:()=>U(!1),title:"Factory Droid - Manual Configuration",configs:(g=E&&E.trim()?E:u?"<API_KEY_FROM_DASHBOARD>":"sk_9router",f={customModels:[{model:O||"provider/model-id",id:"custom:9Router-0",index:0,baseUrl:B(),apiKey:g,displayName:O||"provider/model-id",maxOutputTokens:131072,noImageSupport:!1,provider:"openai"}]},y="u">typeof navigator&&navigator.platform,[{filename:y?.toLowerCase().includes("win")?"%USERPROFILE%\\.factory\\settings.json":"~/.factory/settings.json",content:JSON.stringify(f,null,2)}])})]})}function m({tool:e,isExpanded:t,onToggle:s,baseUrl:n,hasActiveProviders:o,apiKeys:d,activeProviders:c,cloudEnabled:x,initialStatus:u}){let p,h,[g,f]=(0,r.useState)(u||null),[y,b]=(0,r.useState)(!1),[j,N]=(0,r.useState)(!1),[v,w]=(0,r.useState)(!1),[k,C]=(0,r.useState)(null),[S,A]=(0,r.useState)(""),[_,E]=(0,r.useState)(""),[T,O]=(0,r.useState)({}),[M,P]=(0,r.useState)(null),[R,I]=(0,r.useState)(!1),[$,D]=(0,r.useState)({}),[U,K]=(0,r.useState)(!1),[L,F]=(0,r.useState)(""),z=(0,r.useRef)(!1),q=(()=>{if(!g?.installed)return null;let e=g.settings?.models?.providers?.["9router"];if(!e)return"not_configured";let t=e.baseUrl?.includes("localhost")||e.baseUrl?.includes("127.0.0.1")||e.baseUrl?.includes("0.0.0.0"),s=n&&e.baseUrl?.startsWith(n);return t||s?"configured":"other"})();(0,r.useEffect)(()=>{d?.length>0&&!S&&A(d[0].key)},[d,S]),(0,r.useEffect)(()=>{u&&f(u)},[u]),(0,r.useEffect)(()=>{t&&!g&&(B(),H()),t&&H()},[t]);let H=async()=>{try{let e=await fetch("/api/models/alias"),t=await e.json();e.ok&&D(t.aliases||{})}catch(e){console.log("Error fetching model aliases:",e)}};(0,r.useEffect)(()=>{if(g?.installed&&!z.current){z.current=!0;let e=g.settings?.models?.providers?.["9router"];if(e){let t=g.settings?.agents?.defaults?.model?.primary;t&&E(t.replace("9router/","")),e.apiKey&&d?.some(t=>t.key===e.apiKey)&&A(e.apiKey)}let t=g.agents||[],s={};t.forEach(e=>{e.currentModel&&(s[e.id]=e.currentModel)}),O(s)}},[g,d]);let B=async()=>{b(!0);try{let e=await fetch("/api/cli-tools/openclaw-settings"),t=await e.json();f(t)}catch(e){f({installed:!1,error:e.message})}finally{b(!1)}},J=()=>window.location.origin.replace("://localhost","://127.0.0.1"),W=()=>{let e=L||J();return e.endsWith("/v1")?e:`${e}/v1`},G=async()=>{N(!0),C(null);try{let e=S?.trim()||(d?.length>0?d[0].key:null)||(x?null:"sk_9router"),t=await fetch("/api/cli-tools/openclaw-settings",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({baseUrl:W(),apiKey:e,model:_,agentModels:T})}),s=await t.json();t.ok?(C({type:"success",text:"Settings applied successfully!"}),B()):C({type:"error",text:s.error||"Failed to apply settings"})}catch(e){C({type:"error",text:e.message})}finally{N(!1)}},Z=async()=>{w(!0),C(null);try{let e=await fetch("/api/cli-tools/openclaw-settings",{method:"DELETE"}),t=await e.json();e.ok?(C({type:"success",text:"Settings reset successfully!"}),E(""),A(""),B()):C({type:"error",text:t.error||"Failed to reset settings"})}catch(e){C({type:"error",text:e.message})}finally{w(!1)}};return(0,a.jsxs)(l.Zp,{padding:"xs",className:"overflow-hidden",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between hover:cursor-pointer",onClick:s,children:[(0,a.jsxs)("div",{className:"flex items-center gap-3",children:[(0,a.jsx)("div",{className:"size-8 flex items-center justify-center shrink-0",children:(0,a.jsx)(i.default,{src:"/providers/openclaw.png",alt:e.name,width:32,height:32,className:"size-8 object-contain rounded-lg",sizes:"32px",onError:e=>{e.target.style.display="none"}})}),(0,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("h3",{className:"font-medium text-sm",children:e.name}),"configured"===q&&(0,a.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,a.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,a.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,a.jsx)("p",{className:"text-xs text-text-muted truncate",children:e.description})]})]}),(0,a.jsx)("span",{className:`material-symbols-outlined text-text-muted text-[20px] transition-transform ${t?"rotate-180":""}`,children:"expand_more"})]}),t&&(0,a.jsxs)("div",{className:"mt-4 pt-4 border-t border-border flex flex-col gap-4",children:[y&&(0,a.jsxs)("div",{className:"flex items-center gap-2 text-text-muted",children:[(0,a.jsx)("span",{className:"material-symbols-outlined animate-spin",children:"progress_activity"}),(0,a.jsx)("span",{children:"Checking Open Claw CLI..."})]}),!y&&g&&!g.installed&&(0,a.jsxs)("div",{className:"flex items-center gap-3 p-4 bg-yellow-500/10 border border-yellow-500/30 rounded-lg",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-yellow-500",children:"warning"}),(0,a.jsxs)("div",{className:"flex-1",children:[(0,a.jsx)("p",{className:"font-medium text-yellow-600 dark:text-yellow-400",children:"Open Claw CLI not installed"}),(0,a.jsx)("p",{className:"text-sm text-text-muted",children:"Please install Open Claw CLI to use this feature."})]})]}),!y&&g?.installed&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{className:"flex flex-col gap-2",children:[g?.settings?.models?.providers?.["9router"]?.baseUrl&&(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("span",{className:"w-32 shrink-0 text-sm font-semibold text-text-main text-right",children:"Current"}),(0,a.jsx)("span",{className:"material-symbols-outlined text-text-muted text-[14px]",children:"arrow_forward"}),(0,a.jsx)("span",{className:"flex-1 px-2 py-1.5 text-xs text-text-muted truncate",children:g.settings.models.providers["9router"].baseUrl})]}),(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("span",{className:"w-32 shrink-0 text-sm font-semibold text-text-main text-right",children:"Base URL"}),(0,a.jsx)("span",{className:"material-symbols-outlined text-text-muted text-[14px]",children:"arrow_forward"}),(0,a.jsx)("input",{type:"text",value:(p=L||J()).endsWith("/v1")?p:`${p}/v1`,onChange:e=>F(e.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"}),L&&L!==n&&(0,a.jsx)("button",{onClick:()=>F(""),className:"p-1 text-text-muted hover:text-primary rounded transition-colors",title:"Reset to default",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"restart_alt"})})]}),(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("span",{className:"w-32 shrink-0 text-sm font-semibold text-text-main text-right",children:"API Key"}),(0,a.jsx)("span",{className:"material-symbols-outlined text-text-muted text-[14px]",children:"arrow_forward"}),d.length>0?(0,a.jsx)("select",{value:S,onChange:e=>A(e.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:d.map(e=>(0,a.jsx)("option",{value:e.key,children:e.key},e.id))}):(0,a.jsx)("span",{className:"flex-1 text-xs text-text-muted px-2 py-1.5",children:x?"No API keys - Create one in Keys page":"sk_9router (default)"})]}),(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("span",{className:"w-32 shrink-0 text-sm font-semibold text-text-main text-right",children:"Default Model"}),(0,a.jsx)("span",{className:"material-symbols-outlined text-text-muted text-[14px]",children:"arrow_forward"}),(0,a.jsx)("input",{type:"text",value:_,onChange:e=>E(e.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,a.jsx)("button",{onClick:()=>{P(null),I(!0)},disabled:!o,className:`px-2 py-1.5 rounded border text-xs transition-colors shrink-0 whitespace-nowrap ${o?"bg-surface border-border text-text-main hover:border-primary cursor-pointer":"opacity-50 cursor-not-allowed border-border"}`,children:"Select"}),_&&(0,a.jsx)("button",{onClick:()=>E(""),className:"p-1 text-text-muted hover:text-red-500 rounded transition-colors",title:"Clear",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"close"})})]}),(g.agents||[]).filter(e=>e.agentDir).map(e=>(0,a.jsxs)("div",{className:"flex items-center gap-2 pl-4",children:[(0,a.jsxs)("span",{className:"w-32 shrink-0 text-xs text-primary text-right truncate",title:e.name||e.id,children:["Agent ",e.name||e.id]}),(0,a.jsx)("span",{className:"material-symbols-outlined text-text-muted text-[14px]",children:"arrow_forward"}),(0,a.jsx)("input",{type:"text",value:T[e.id]||"",onChange:t=>O(s=>({...s,[e.id]:t.target.value})),placeholder:`default (${_||"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,a.jsx)("button",{onClick:()=>{P(e.id),I(!0)},disabled:!o,className:`px-2 py-1.5 rounded border text-xs transition-colors shrink-0 whitespace-nowrap ${o?"bg-surface border-border text-text-main hover:border-primary cursor-pointer":"opacity-50 cursor-not-allowed border-border"}`,children:"Select"}),T[e.id]&&(0,a.jsx)("button",{onClick:()=>O(t=>({...t,[e.id]:""})),className:"p-1 text-text-muted hover:text-red-500 rounded transition-colors",title:"Clear",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"close"})})]},e.id))]}),k&&(0,a.jsxs)("div",{className:`flex items-center gap-2 px-2 py-1.5 rounded text-xs ${"success"===k.type?"bg-green-500/10 text-green-600":"bg-red-500/10 text-red-600"}`,children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"success"===k.type?"check_circle":"error"}),(0,a.jsx)("span",{children:k.text})]}),(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsxs)(l.$n,{variant:"primary",size:"sm",onClick:G,disabled:!_,loading:j,children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px] mr-1",children:"save"}),"Apply"]}),(0,a.jsxs)(l.$n,{variant:"outline",size:"sm",onClick:Z,disabled:!g?.has9Router,loading:v,children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px] mr-1",children:"restore"}),"Reset"]}),(0,a.jsxs)(l.$n,{variant:"ghost",size:"sm",onClick:()=>K(!0),children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px] mr-1",children:"content_copy"}),"Manual Config"]})]})]})]}),(0,a.jsx)(l.rq,{isOpen:R,onClose:()=>I(!1),onSelect:e=>{M?(O(t=>({...t,[M]:e.value})),P(null)):E(e.value),I(!1)},selectedModel:_,activeProviders:c,modelAliases:$,title:"Select Model for Open Claw"}),(0,a.jsx)(l.uR,{isOpen:U,onClose:()=>K(!1),title:"Open Claw - Manual Configuration",configs:(h=S&&S.trim()?S:x?"<API_KEY_FROM_DASHBOARD>":"sk_9router",[{filename:"~/.openclaw/openclaw.json",content:JSON.stringify({agents:{defaults:{model:{primary:`9router/${_||"provider/model-id"}`}}},models:{providers:{"9router":{baseUrl:W(),apiKey:h,api:"openai-completions",models:[{id:_||"provider/model-id",name:(_||"provider/model-id").split("/").pop()}]}}}},null,2)}])})]})}function u({toolId:e,tool:t,isExpanded:s,onToggle:n,baseUrl:o,apiKeys:d,activeProviders:c=[],cloudEnabled:x=!1,tunnelEnabled:m=!1}){let[p,h]=(0,r.useState)(null),[g,f]=(0,r.useState)(!1),[y,b]=(0,r.useState)(""),[j,N]=(0,r.useState)(()=>d?.length>0?d[0].key:""),v=e=>{let t=j&&j.trim()?j:x?"your-api-key":"sk_9router",s=o||"http://localhost:20128",a=s.endsWith("/v1")?s:`${s}/v1`;return e.replace(/\{\{baseUrl\}\}/g,a).replace(/\{\{apiKey\}\}/g,t).replace(/\{\{model\}\}/g,y||"provider/model-id")},w=async(e,t)=>{await navigator.clipboard.writeText(v(e)),h(t),setTimeout(()=>h(null),2e3)},k=c.length>0,C=()=>(!t.requiresExternalUrl||!!x||!!m)&&(!t.requiresCloud||!!x);return(0,a.jsxs)(l.Zp,{padding:"xs",className:"overflow-hidden",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between hover:cursor-pointer",onClick:n,children:[(0,a.jsxs)("div",{className:"flex items-center gap-3",children:[(0,a.jsx)("div",{className:"size-8 rounded-lg flex items-center justify-center shrink-0",children:t.image?(0,a.jsx)(i.default,{src:t.image,alt:t.name,width:32,height:32,className:"size-8 object-contain rounded-lg",sizes:"32px",onError:e=>{e.target.style.display="none"}}):t.icon?(0,a.jsx)("span",{className:"material-symbols-outlined text-xl",style:{color:t.color},children:t.icon}):(0,a.jsx)(i.default,{src:`/providers/${e}.png`,alt:t.name,width:32,height:32,className:"size-8 object-contain rounded-lg",sizes:"32px",onError:e=>{e.target.style.display="none"}})}),(0,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsx)("h3",{className:"font-medium text-sm",children:t.name}),(0,a.jsx)("p",{className:"text-xs text-text-muted truncate",children:t.description})]})]}),(0,a.jsx)("span",{className:`material-symbols-outlined text-text-muted text-[20px] transition-transform ${s?"rotate-180":""}`,children:"expand_more"})]}),s&&(0,a.jsx)("div",{className:"mt-6 pt-6 border-t border-border",children:t.guideSteps?(0,a.jsxs)("div",{className:"flex flex-col gap-4",children:[t.notes&&0!==t.notes.length?(0,a.jsx)("div",{className:"flex flex-col gap-2 mb-4",children:t.notes.map((e,t)=>{if("cloudCheck"===e.type&&(x||m))return null;let s="warning"===e.type,r="cloudCheck"===e.type&&!x&&!m,l="bg-blue-500/10 border-blue-500/30",i="text-blue-600 dark:text-blue-400",n="text-blue-500",o="info";return s?(l="bg-yellow-500/10 border-yellow-500/30",i="text-yellow-600 dark:text-yellow-400",n="text-yellow-500",o="warning"):r&&(l="bg-red-500/10 border-red-500/30",i="text-red-600 dark:text-red-400",n="text-red-500",o="error"),(0,a.jsxs)("div",{className:`flex items-start gap-3 p-3 rounded-lg border ${l}`,children:[(0,a.jsx)("span",{className:`material-symbols-outlined text-lg ${n}`,children:o}),(0,a.jsx)("p",{className:`text-sm ${i}`,children:e.text})]},t)})}):null,C()&&t.guideSteps.map(e=>(0,a.jsxs)("div",{className:"flex items-start gap-4",children:[(0,a.jsx)("div",{className:"size-8 rounded-full flex items-center justify-center shrink-0 text-sm font-semibold text-white",style:{backgroundColor:t.color},children:e.step}),(0,a.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,a.jsx)("p",{className:"font-medium text-text",children:e.title}),e.desc&&(0,a.jsx)("p",{className:"text-sm text-text-muted mt-0.5",children:e.desc}),"apiKeySelector"===e.type&&(0,a.jsx)("div",{className:"mt-2 flex items-center gap-2",children:d&&d.length>0?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("select",{value:j,onChange:e=>N(e.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:d.map(e=>(0,a.jsx)("option",{value:e.key,children:e.key},e.id))}),(0,a.jsx)("button",{onClick:()=>w(j,"apiKey"),className:"shrink-0 px-3 py-2 bg-bg-secondary hover:bg-bg-tertiary rounded-lg border border-border transition-colors",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-lg",children:"apiKey"===p?"check":"content_copy"})})]}):(0,a.jsx)("span",{className:"text-sm text-text-muted",children:x?"No API keys - Create one in Keys page":"sk_9router"})}),"modelSelector"===e.type&&(0,a.jsxs)("div",{className:"mt-2 flex items-center gap-2",children:[(0,a.jsx)("input",{type:"text",value:y,onChange:e=>b(e.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,a.jsx)("button",{onClick:()=>f(!0),disabled:!k,className:`shrink-0 px-3 py-2 rounded-lg border text-sm transition-colors ${k?"bg-bg-secondary border-border text-text-main hover:border-primary cursor-pointer":"opacity-50 cursor-not-allowed border-border"}`,children:"Select Model"}),y&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("button",{onClick:()=>w(y,"model"),className:"shrink-0 px-3 py-2 bg-bg-secondary hover:bg-bg-tertiary rounded-lg border border-border transition-colors",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-lg",children:"model"===p?"check":"content_copy"})}),(0,a.jsx)("button",{onClick:()=>b(""),className:"p-2 text-text-muted hover:text-red-500 rounded transition-colors",title:"Clear",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-lg",children:"close"})})]})]}),e.value&&(0,a.jsxs)("div",{className:"mt-2 flex items-center gap-2",children:[(0,a.jsx)("code",{className:"flex-1 px-3 py-2 bg-bg-secondary rounded-lg text-sm font-mono border border-border truncate",children:v(e.value)}),e.copyable&&(0,a.jsx)("button",{onClick:()=>w(e.value,`${e.step}-${e.title}`),className:"shrink-0 px-3 py-2 bg-bg-secondary hover:bg-bg-tertiary rounded-lg border border-border transition-colors",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-lg",children:p===`${e.step}-${e.title}`?"check":"content_copy"})})]})]})]},e.step)),C()&&t.codeBlock&&(0,a.jsxs)("div",{className:"mt-2",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between mb-2",children:[(0,a.jsx)("span",{className:"text-xs text-text-muted uppercase tracking-wide",children:t.codeBlock.language}),(0,a.jsxs)("button",{onClick:()=>w(t.codeBlock.code,"codeblock"),className:"flex items-center gap-1 px-2 py-1 text-xs bg-bg-secondary hover:bg-bg-tertiary rounded border border-border transition-colors",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-sm",children:"codeblock"===p?"check":"content_copy"}),"codeblock"===p?"Copied!":"Copy"]})]}),(0,a.jsx)("pre",{className:"p-4 bg-bg-secondary rounded-lg border border-border overflow-x-auto",children:(0,a.jsx)("code",{className:"text-sm font-mono whitespace-pre",children:v(t.codeBlock.code)})})]})]}):(0,a.jsx)("p",{className:"text-text-muted text-sm",children:"Coming soon..."})}),(0,a.jsx)(l.rq,{isOpen:g,onClose:()=>f(!1),onSelect:e=>{b(e.value)},selectedModel:y,activeProviders:c,title:"Select Model"})]})}function p({tool:e,isExpanded:t,onToggle:s,baseUrl:n,apiKeys:o,activeProviders:d,cloudEnabled:c,initialStatus:x}){let m,[u,h]=(0,r.useState)(x||null),[g,f]=(0,r.useState)(!1),[y,b]=(0,r.useState)(!1),[j,N]=(0,r.useState)(!1),[v,w]=(0,r.useState)(null),[k,C]=(0,r.useState)(!1),[S,A]=(0,r.useState)(""),[_,E]=(0,r.useState)(""),[T,O]=(0,r.useState)(!1),[M,P]=(0,r.useState)({}),[R,I]=(0,r.useState)(!1),[$,D]=(0,r.useState)("");(0,r.useEffect)(()=>{o?.length>0&&!S&&A(o[0].key)},[o,S]),(0,r.useEffect)(()=>{x&&h(x)},[x]),(0,r.useEffect)(()=>{t&&!u&&(F(),U()),t&&U()},[t]),(0,r.useEffect)(()=>{u?.config?.model?.startsWith("9router/")&&E(u.config.model.replace("9router/",""))},[u]);let U=async()=>{try{let e=await fetch("/api/models/alias"),t=await e.json();e.ok&&P(t.aliases||{})}catch(e){console.log("Error fetching model aliases:",e)}},K=(()=>{if(!u?.installed)return null;if(!u.config)return"not_configured";let e=u.config?.provider?.["9router"]?.options?.baseURL||"",t=e.includes("localhost")||e.includes("127.0.0.1");return u.has9Router&&(t||e.includes(n))?"configured":u.has9Router?"other":"not_configured"})(),L=()=>{let e=$||n;return e.endsWith("/v1")?e:`${e}/v1`},F=async()=>{f(!0);try{let e=await fetch("/api/cli-tools/opencode-settings"),t=await e.json();h(t)}catch(e){h({installed:!1,error:e.message})}finally{f(!1)}},z=async()=>{b(!0),w(null);try{let e=S&&S.trim()||c?S:"sk_9router",t=await fetch("/api/cli-tools/opencode-settings",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({baseUrl:L(),apiKey:e,model:_})}),s=await t.json();t.ok?(w({type:"success",text:"Settings applied successfully!"}),F()):w({type:"error",text:s.error||"Failed to apply settings"})}catch(e){w({type:"error",text:e.message})}finally{b(!1)}},q=async()=>{N(!0),w(null);try{let e=await fetch("/api/cli-tools/opencode-settings",{method:"DELETE"}),t=await e.json();e.ok?(w({type:"success",text:"Settings reset successfully!"}),E(""),F()):w({type:"error",text:t.error||"Failed to reset settings"})}catch(e){w({type:"error",text:e.message})}finally{N(!1)}};return(0,a.jsxs)(l.Zp,{padding:"xs",className:"overflow-hidden",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between hover:cursor-pointer",onClick:s,children:[(0,a.jsxs)("div",{className:"flex items-center gap-3",children:[(0,a.jsx)("div",{className:"size-8 flex items-center justify-center shrink-0",children:(0,a.jsx)(i.default,{src:"/providers/opencode.png",alt:e.name,width:32,height:32,className:"size-8 object-contain rounded-lg",sizes:"32px",onError:e=>{e.target.style.display="none"}})}),(0,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("h3",{className:"font-medium text-sm",children:e.name}),"configured"===K&&(0,a.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"===K&&(0,a.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"===K&&(0,a.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,a.jsx)("p",{className:"text-xs text-text-muted truncate",children:e.description})]})]}),(0,a.jsx)("span",{className:`material-symbols-outlined text-text-muted text-[20px] transition-transform ${t?"rotate-180":""}`,children:"expand_more"})]}),t&&(0,a.jsxs)("div",{className:"mt-4 pt-4 border-t border-border flex flex-col gap-4",children:[g&&(0,a.jsxs)("div",{className:"flex items-center gap-2 text-text-muted",children:[(0,a.jsx)("span",{className:"material-symbols-outlined animate-spin",children:"progress_activity"}),(0,a.jsx)("span",{children:"Checking OpenCode CLI..."})]}),!g&&u&&!u.installed&&(0,a.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,a.jsxs)("div",{className:"flex items-center gap-3 p-4 bg-yellow-500/10 border border-yellow-500/30 rounded-lg",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-yellow-500",children:"warning"}),(0,a.jsxs)("div",{className:"flex-1",children:[(0,a.jsx)("p",{className:"font-medium text-yellow-600 dark:text-yellow-400",children:"OpenCode CLI not installed"}),(0,a.jsx)("p",{className:"text-sm text-text-muted",children:"Please install OpenCode CLI to use auto-apply feature."})]}),(0,a.jsxs)(l.$n,{variant:"outline",size:"sm",onClick:()=>C(!k),children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px] mr-1",children:k?"expand_less":"help"}),k?"Hide":"How to Install"]})]}),k&&(0,a.jsxs)("div",{className:"p-4 bg-surface border border-border rounded-lg",children:[(0,a.jsx)("h4",{className:"font-medium mb-3",children:"Installation Guide"}),(0,a.jsxs)("div",{className:"space-y-3 text-sm",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("p",{className:"text-text-muted mb-1",children:"macOS / Linux:"}),(0,a.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,a.jsxs)("p",{className:"text-text-muted",children:["After installation, run ",(0,a.jsx)("code",{className:"px-1 bg-black/5 dark:bg-white/5 rounded",children:"opencode"})," to verify."]})]})]})]}),!g&&u?.installed&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{className:"flex flex-col gap-2",children:[u?.config?.provider?.["9router"]?.options?.baseURL&&(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("span",{className:"w-32 shrink-0 text-sm font-semibold text-text-main text-right",children:"Current"}),(0,a.jsx)("span",{className:"material-symbols-outlined text-text-muted text-[14px]",children:"arrow_forward"}),(0,a.jsx)("span",{className:"flex-1 px-2 py-1.5 text-xs text-text-muted truncate",children:u.config.provider["9router"].options.baseURL})]}),(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("span",{className:"w-32 shrink-0 text-sm font-semibold text-text-main text-right",children:"Base URL"}),(0,a.jsx)("span",{className:"material-symbols-outlined text-text-muted text-[14px]",children:"arrow_forward"}),(0,a.jsx)("input",{type:"text",value:$||`${n}/v1`,onChange:e=>D(e.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}/v1`&&(0,a.jsx)("button",{onClick:()=>D(""),className:"p-1 text-text-muted hover:text-primary rounded transition-colors",title:"Reset to default",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"restart_alt"})})]}),(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("span",{className:"w-32 shrink-0 text-sm font-semibold text-text-main text-right",children:"API Key"}),(0,a.jsx)("span",{className:"material-symbols-outlined text-text-muted text-[14px]",children:"arrow_forward"}),o.length>0?(0,a.jsx)("select",{value:S,onChange:e=>A(e.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:o.map(e=>(0,a.jsx)("option",{value:e.key,children:e.key},e.id))}):(0,a.jsx)("span",{className:"flex-1 text-xs text-text-muted px-2 py-1.5",children:c?"No API keys - Create one in Keys page":"sk_9router (default)"})]}),(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("span",{className:"w-32 shrink-0 text-sm font-semibold text-text-main text-right",children:"Model"}),(0,a.jsx)("span",{className:"material-symbols-outlined text-text-muted text-[14px]",children:"arrow_forward"}),(0,a.jsx)("input",{type:"text",value:_,onChange:e=>E(e.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,a.jsx)("button",{onClick:()=>O(!0),disabled:!d?.length,className:`px-2 py-1.5 rounded border text-xs transition-colors shrink-0 whitespace-nowrap ${d?.length?"bg-surface border-border text-text-main hover:border-primary cursor-pointer":"opacity-50 cursor-not-allowed border-border"}`,children:"Select Model"}),_&&(0,a.jsx)("button",{onClick:()=>E(""),className:"p-1 text-text-muted hover:text-red-500 rounded transition-colors",title:"Clear",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"close"})})]})]}),v&&(0,a.jsxs)("div",{className:`flex items-center gap-2 px-2 py-1.5 rounded text-xs ${"success"===v.type?"bg-green-500/10 text-green-600":"bg-red-500/10 text-red-600"}`,children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"success"===v.type?"check_circle":"error"}),(0,a.jsx)("span",{children:v.text})]}),(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsxs)(l.$n,{variant:"primary",size:"sm",onClick:z,disabled:!_,loading:y,children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px] mr-1",children:"save"}),"Apply"]}),(0,a.jsxs)(l.$n,{variant:"outline",size:"sm",onClick:q,disabled:!u.has9Router,loading:j,children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px] mr-1",children:"restore"}),"Reset"]}),(0,a.jsxs)(l.$n,{variant:"ghost",size:"sm",onClick:()=>I(!0),children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px] mr-1",children:"content_copy"}),"Manual Config"]})]})]})]}),(0,a.jsx)(l.rq,{isOpen:T,onClose:()=>O(!1),onSelect:e=>{E(e.value),O(!1)},selectedModel:_,activeProviders:d,modelAliases:M,title:"Select Model for OpenCode"}),(0,a.jsx)(l.uR,{isOpen:R,onClose:()=>I(!1),title:"OpenCode - Manual Configuration",configs:(m=S&&S.trim()?S:c?"<API_KEY_FROM_DASHBOARD>":"sk_9router",[{filename:"~/.config/opencode/opencode.json",content:JSON.stringify({provider:{"9router":{npm:"@ai-sdk/openai-compatible",options:{baseURL:L(),apiKey:m},models:{[_||"provider/model-id"]:{name:_||"provider/model-id"}}}},model:`9router/${_||"provider/model-id"}`},null,2)}])})]})}let h="http://localhost:20128";function g({apiKeys:e,cloudEnabled:t,onStatusChange:s}){let[i,n]=(0,r.useState)(null),[o,d]=(0,r.useState)(!1),[c,x]=(0,r.useState)(!1),[m,u]=(0,r.useState)(""),[p,f]=(0,r.useState)(""),[y,b]=(0,r.useState)(null),[j,N]=(0,r.useState)(null),[v,w]=(0,r.useState)(null),[k,C]=(0,r.useState)(h),S="u">typeof navigator&&navigator.userAgent?.includes("Windows"),A=i?.isAdmin!==!1;(0,r.useEffect)(()=>{e?.length>0&&!p&&f(e[0].key)},[e,p]),(0,r.useEffect)(()=>{_()},[]);let _=async()=>{try{let e=await fetch("/api/cli-tools/antigravity-mitm");if(e.ok){let t=await e.json();n(t),t.mitmRouterBaseUrl&&C(t.mitmRouterBaseUrl),s?.(t)}}catch{n({running:!1,certExists:!1,dnsStatus:{}})}},E=e=>{S||i?.hasCachedPassword?T(e,""):(b(e),x(!0),N(null))},T=async(s,a)=>{d(!0),w(null);try{let r;if("trust-cert"===s)r=await fetch("/api/cli-tools/antigravity-mitm",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"trust-cert",sudoPassword:a})});else if("start"===s){let s=p?.trim()||(e?.length>0?e[0].key:null)||(t?null:"sk_9router");r=await fetch("/api/cli-tools/antigravity-mitm",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({apiKey:s,sudoPassword:a,mitmRouterBaseUrl:k.trim()||h})})}else r=await fetch("/api/cli-tools/antigravity-mitm",{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({sudoPassword:a})});let l=await r.json().catch(()=>({}));if(!r.ok)throw Error(l.error||"MITM action failed");x(!1),u(""),N(null),await _()}catch(t){let e=t?.message||"MITM action failed";w(e),c&&N(e)}finally{d(!1),b(null)}},O=()=>{m?T(y,m):N("Sudo password is required")},M=i?.running;return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(l.Zp,{padding:"sm",className:"border-primary/20 bg-primary/5",children:(0,a.jsxs)("div",{className:"flex flex-col gap-3",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-primary text-[20px]",children:"security"}),(0,a.jsx)("span",{className:"font-semibold text-sm text-text-main",children:"MITM Server"}),M?(0,a.jsx)(l.Ex,{variant:"success",size:"sm",children:"Running"}):(0,a.jsx)(l.Ex,{variant:"default",size:"sm",children:"Stopped"})]}),(0,a.jsx)("div",{className:"flex items-center gap-1 text-xs text-text-muted","data-i18n-skip":"true",children:[{label:"Cert",ok:i?.certExists},{label:"Trusted",ok:i?.certTrusted},{label:"Server",ok:M}].map(({label:e,ok:t})=>(0,a.jsxs)("span",{className:`flex items-center gap-0.5 px-1.5 py-0.5 rounded ${t?"text-green-600":"text-text-muted"}`,children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[12px]",children:t?"check_circle":"cancel"}),e]},e))})]}),(0,a.jsxs)("div",{className:"px-2 py-2 rounded-lg bg-surface/50 border border-border/50 flex flex-col gap-2",children:[(0,a.jsxs)("p",{className:"text-[11px] text-text-muted leading-relaxed",children:[(0,a.jsx)("span",{className:"font-medium text-text-main",children:"Purpose:"})," Use Antigravity IDE & GitHub Copilot → with ANY provider/model from 9Router"]}),(0,a.jsxs)("p",{className:"text-[11px] text-text-muted leading-relaxed",children:[(0,a.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,a.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("span",{className:"w-32 shrink-0 text-sm font-semibold text-text-main text-right",children:"9Router Base URL"}),(0,a.jsx)("span",{className:"material-symbols-outlined text-text-muted text-[14px]",children:"arrow_forward"}),(0,a.jsx)("input",{type:"text",value:k,onChange:e=>C(e.target.value),placeholder:h,disabled:M,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"})]}),!M&&(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("span",{className:"w-32 shrink-0 text-sm font-semibold text-text-main text-right",children:"API Key"}),(0,a.jsx)("span",{className:"material-symbols-outlined text-text-muted text-[14px]",children:"arrow_forward"}),e?.length>0?(0,a.jsx)("select",{value:p,onChange:e=>f(e.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:e.map(e=>(0,a.jsx)("option",{value:e.key,children:e.key},e.id))}):(0,a.jsx)("span",{className:"flex-1 px-2 py-1.5 text-xs text-text-muted",children:t?"No API keys — create one in Keys page":"sk_9router (default)"})]})]}),(0,a.jsxs)("div",{className:"flex items-center gap-2 flex-wrap","data-i18n-skip":"true",children:[i?.certExists&&!i?.certTrusted&&(0,a.jsxs)("button",{onClick:()=>E("trust-cert"),disabled:o,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,a.jsx)("span",{className:"material-symbols-outlined text-[16px]",children:"verified_user"}),"Trust Cert"]}),M?(0,a.jsxs)("button",{onClick:()=>E("stop"),disabled:o,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,a.jsx)("span",{className:"material-symbols-outlined text-[16px]",children:"stop_circle"}),"Stop Server"]}):(0,a.jsxs)("button",{onClick:()=>E("start"),disabled:o||S&&!A,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,a.jsx)("span",{className:"material-symbols-outlined text-[16px]",children:"play_circle"}),"Start Server"]}),M&&(0,a.jsx)("p",{className:"text-xs text-text-muted",children:"Enable DNS per tool below to activate interception"})]}),v&&(0,a.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,a.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"error"}),(0,a.jsx)("span",{children:v})]}),S&&!A&&(0,a.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,a.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"shield_lock"}),(0,a.jsx)("span",{children:"Administrator required — restart 9Router as Administrator to use MITM"})]})]})}),c&&(0,a.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50 backdrop-blur-sm",children:(0,a.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,a.jsx)("h3",{className:"font-semibold text-text-main",children:"Sudo Password Required"}),(0,a.jsxs)("div",{className:"flex items-start gap-3 p-3 bg-yellow-500/10 border border-yellow-500/30 rounded-lg",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-yellow-500 text-[20px]",children:"warning"}),(0,a.jsx)("p",{className:"text-xs text-text-muted",children:"Required for SSL certificate and server startup"})]}),(0,a.jsx)(l.pd,{type:"password",placeholder:"Enter sudo password",value:m,onChange:e=>u(e.target.value),onKeyDown:e=>{"Enter"!==e.key||o||O()}}),j&&(0,a.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,a.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"error"}),(0,a.jsx)("span",{children:j})]}),(0,a.jsxs)("div",{className:"flex items-center justify-end gap-2",children:[(0,a.jsx)(l.$n,{variant:"ghost",size:"sm",onClick:()=>{x(!1),u(""),N(null)},disabled:o,children:"Cancel"}),(0,a.jsx)(l.$n,{variant:"primary",size:"sm",onClick:O,loading:o,children:"Confirm"})]})]})})]})}function f({tool:e,isExpanded:t,onToggle:s,serverRunning:n,dnsActive:o,hasCachedPassword:d,apiKeys:c,activeProviders:x,hasActiveProviders:m,modelAliases:u={},cloudEnabled:p,onDnsChange:h,tokenSwapActive:g=!1}){let[b,j]=(0,r.useState)(!1),[N,v]=(0,r.useState)(null),[w,k]=(0,r.useState)(!1),[C,S]=(0,r.useState)(""),[A,_]=(0,r.useState)(null),[E,T]=(0,r.useState)(null),[O,M]=(0,r.useState)({}),[P,R]=(0,r.useState)(!1),[I,$]=(0,r.useState)(null),D="u">typeof navigator&&navigator.userAgent?.includes("Windows");(0,r.useEffect)(()=>{t&&U()},[t]);let U=async()=>{try{let t=await fetch(`/api/cli-tools/antigravity-mitm/alias?tool=${e.id}`);if(t.ok){let e=await t.json();Object.keys(e.aliases||{}).length>0&&M(e.aliases)}}catch{}},K=(0,r.useCallback)(async t=>{try{await fetch("/api/cli-tools/antigravity-mitm/alias",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({tool:e.id,mappings:t})})}catch{}},[e.id]),L=(e,t)=>{M(s=>({...s,[e]:t}))},F=()=>{if(!n)return;let e=o?"disable":"enable";D||d?z(e,""):(_(e),k(!0),T(null))},z=async(t,s)=>{j(!0),v(null);try{let a=await fetch("/api/cli-tools/antigravity-mitm",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({tool:e.id,action:t,sudoPassword:s})}),r=await a.json();if(!a.ok)throw Error(r.error||"Failed to toggle DNS");"enable"===t&&v(`Restart ${e.name} to apply changes`),k(!1),S(""),h?.(r)}catch{}finally{j(!1),_(null)}},q=()=>{C?z(A,C):T("Sudo password is required")};return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)(l.Zp,{padding:"xs",className:"overflow-hidden",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between hover:cursor-pointer",onClick:s,children:[(0,a.jsxs)("div",{className:"flex items-center gap-3",children:[(0,a.jsx)("div",{className:"size-8 flex items-center justify-center shrink-0",children:(0,a.jsx)(i.default,{src:e.image,alt:e.name,width:32,height:32,className:"size-8 object-contain rounded-lg",sizes:"32px",onError:e=>{e.target.style.display="none"}})}),(0,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("h3",{className:"font-medium text-sm",children:e.name}),e.supportsTokenSwap&&(0,a.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"}),n?g?(0,a.jsx)(l.Ex,{variant:"default",size:"sm",children:"Bypassed"}):o?(0,a.jsx)(l.Ex,{variant:"success",size:"sm",children:"Active"}):(0,a.jsx)(l.Ex,{variant:"warning",size:"sm",children:"DNS off"}):(0,a.jsx)(l.Ex,{variant:"default",size:"sm",children:"Server off"})]}),(0,a.jsx)("p",{className:"text-xs text-text-muted",children:"Model routing — remap model IDs in intercepted requests"})]})]}),(0,a.jsx)("span",{className:`material-symbols-outlined text-text-muted text-[20px] transition-transform ${t?"rotate-180":""}`,children:"expand_more"})]}),t&&(0,a.jsxs)("div",{className:"mt-4 pt-4 border-t border-border flex flex-col gap-4",children:[g&&(0,a.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,a.jsx)("span",{className:"material-symbols-outlined text-[14px] text-violet-400 mt-0.5 shrink-0",children:"info"}),(0,a.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"===e.id&&(0,a.jsx)(y,{}),(0,a.jsxs)("div",{className:"flex flex-col gap-0.5 text-[11px] text-text-muted px-1",children:[(0,a.jsxs)("p",{children:["Toggle DNS to redirect ",e.name," traffic through 9Router via MITM."]}),!o&&(0,a.jsx)("p",{className:"text-amber-600 text-[10px] mt-1",children:"⚠️ Enable DNS to edit model mappings"})]}),e.defaultModels?.length>0&&(0,a.jsx)("div",{className:"flex flex-col gap-2",children:e.defaultModels.map(e=>(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("span",{className:"w-36 shrink-0 text-xs font-semibold text-text-main text-right",children:e.name}),(0,a.jsx)("span",{className:"material-symbols-outlined text-text-muted text-[14px]",children:"arrow_forward"}),(0,a.jsx)("input",{type:"text",value:O[e.alias]||"",onChange:t=>L(e.alias,t.target.value),onBlur:t=>{var s,a;return s=e.alias,a=t.target.value,void K({...O,[s]:a})},placeholder:"provider/model-id",disabled:!o,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?"opacity-50 cursor-not-allowed":""}`}),(0,a.jsx)("button",{onClick:()=>{$(e.alias),R(!0)},disabled:!m||!o,className:`px-2 py-1.5 rounded border text-xs transition-colors shrink-0 ${m&&o?"bg-surface border-border hover:border-primary cursor-pointer":"opacity-50 cursor-not-allowed border-border"}`,children:"Select"}),O[e.alias]&&(0,a.jsx)("button",{onClick:()=>{L(e.alias,""),K({...O,[e.alias]:""})},className:"p-1 text-text-muted hover:text-red-500 rounded transition-colors",title:"Clear",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"close"})})]},e.alias))}),e.defaultModels?.length===0&&(0,a.jsx)("p",{className:"text-xs text-text-muted px-1",children:"Model mappings will be available soon."}),(0,a.jsxs)("div",{className:"flex flex-col gap-2 items-start",children:[o?(0,a.jsxs)("button",{onClick:F,disabled:!n||b,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,a.jsx)("span",{className:"material-symbols-outlined text-[16px]",children:"stop_circle"}),"Stop DNS"]}):(0,a.jsxs)("button",{onClick:F,disabled:!n||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 disabled:cursor-not-allowed",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[16px]",children:"play_circle"}),"Start DNS"]}),N&&(0,a.jsxs)("div",{className:"flex items-center gap-2 px-2 py-1.5 rounded text-xs text-amber-500",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"warning"}),(0,a.jsx)("span",{children:N})]})]})]})]}),w&&(0,a.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50 backdrop-blur-sm",children:(0,a.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,a.jsx)("h3",{className:"font-semibold text-text-main",children:"Sudo Password Required"}),(0,a.jsxs)("div",{className:"flex items-start gap-3 p-3 bg-yellow-500/10 border border-yellow-500/30 rounded-lg",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-yellow-500 text-[20px]",children:"warning"}),(0,a.jsx)("p",{className:"text-xs text-text-muted",children:"Required to modify /etc/hosts and flush DNS cache"})]}),(0,a.jsx)(l.pd,{type:"password",placeholder:"Enter sudo password",value:C,onChange:e=>S(e.target.value),onKeyDown:e=>{"Enter"!==e.key||b||q()}}),E&&(0,a.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,a.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"error"}),(0,a.jsx)("span",{children:E})]}),(0,a.jsxs)("div",{className:"flex items-center justify-end gap-2",children:[(0,a.jsx)(l.$n,{variant:"ghost",size:"sm",onClick:()=>{k(!1),S(""),T(null)},disabled:b,children:"Cancel"}),(0,a.jsx)(l.$n,{variant:"primary",size:"sm",onClick:q,loading:b,children:"Confirm"})]})]})}),(0,a.jsx)(l.rq,{isOpen:P,onClose:()=>R(!1),onSelect:e=>{if(!I||e.isPlaceholder)return;let t={...O,[I]:e.value};M(t),K(t)},selectedModel:I?O[I]:null,activeProviders:x,modelAliases:u,title:`Select model for ${I}`})]})}function y(){let[e,t]=(0,r.useState)(null),[s,l]=(0,r.useState)(!1),[i,n]=(0,r.useState)(null),o=(0,r.useCallback)(async()=>{try{let e=await fetch("/api/antigravity-ide");e.ok&&t(await e.json())}catch{}},[]);(0,r.useEffect)(()=>{let e=!0;return(async()=>{try{let s=await fetch("/api/antigravity-ide");s.ok&&e&&t(await s.json())}catch{}})(),()=>{e=!1}},[]);let d=async()=>{l(!0),n(null);try{let e=await fetch("/api/antigravity-ide",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"close"})}),t=await e.json();n(t),setTimeout(o,1e3)}catch(e){n({success:!1,error:e.message})}l(!1)};return(0,a.jsxs)("div",{className:"flex items-center gap-2 px-1",children:[(0,a.jsxs)("button",{onClick:d,disabled:s||!e?.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:e?.running?"Close all Antigravity IDE processes":"Antigravity IDE is not running",children:[(0,a.jsx)("span",{className:`material-symbols-outlined text-[14px] ${s?"animate-spin":""}`,children:s?"progress_activity":"close"}),s?"Closing…":"Close IDE"]}),e&&(0,a.jsxs)("span",{className:"flex items-center gap-1 text-[10px] text-text-muted",children:[(0,a.jsx)("span",{className:`inline-block w-1.5 h-1.5 rounded-full ${!e.installed?"bg-gray-400":e.running?"bg-green-500":"bg-red-400"}`}),e.installed?e.running?"Running":"Stopped":"Not installed"]}),i&&!s&&(0,a.jsxs)("span",{className:`text-[10px] ${i.success?"text-green-500":"text-red-400"}`,children:[i.success?"✓":"✗"," ",i.message||i.error]})]})}var b=s(98500),j=s.n(b);function N(e){if(null==e)return null;let t=String(e).trim();if(!t)return null;let s=t.toLowerCase();return s.includes("ultra")?"Ultra":s.includes("pro")?"Pro":s.includes("free")?"Free":null}["Free","Pro","Ultra"].map(e=>({value:e,label:e}));var v=s(57294);function w(e){if(!e||"string"!=typeof e)return e;let t=e.indexOf("@");if(t<=0||t===e.length-1)return e;let s=e.slice(0,t),a=e.slice(t+1);return 1===s.length?`${s[0]}**@${a}`:2===s.length?`${s[0]}**${s[1]}@${a}`:`${s[0]}**${s[s.length-1]}@${a}`}function k({tool:e,connections:t=[],serverRunning:s,dnsActive:i,onToggle:n,onRefreshConnections:o}){let[d,c]=(0,r.useState)(!1),[x,m]=(0,r.useState)(!1),[u,p]=(0,r.useState)("round-robin"),[h,g]=(0,r.useState)(!1),[f,y]=(0,r.useState)(!1),[b,C]=(0,r.useState)(!1),[S,A]=(0,r.useState)(null),[_,E]=(0,r.useState)(null),[T,O]=(0,r.useState)(!1),[M,P]=(0,r.useState)({}),R=(0,r.useRef)({}),I=(0,r.useCallback)(async()=>{try{let e=await fetch("/api/settings");if(e.ok){let t=await e.json();c(!!t.tokenSwapEnabled),p(t.tokenSwapStrategy||"round-robin"),y(!!t.tokenSwapMaskEmails)}}catch{}},[]);(0,r.useEffect)(()=>{I()},[I]);let $=(0,r.useCallback)(async(t,s=!1)=>{if(!t||0===t.length)return;let a=Date.now(),r=[],l={};if(t.forEach(e=>{let t=R.current[e.id];!s&&t&&a-t.ts<12e4?l[e.id]={quotas:t.data,error:t.error,loading:!1,accountType:t.accountType||null}:r.push(e)}),Object.keys(l).length>0&&P(e=>({...e,...l})),0===r.length)return;let i={};r.forEach(e=>{i[e.id]={quotas:[],error:null,loading:!0}}),P(e=>({...e,...i})),await Promise.all(r.map(async t=>{try{let s=await fetch(`/api/usage/${t.id}`);if(!s.ok){let e=(await s.json().catch(()=>({}))).error||`HTTP ${s.status}`;R.current[t.id]={data:[],error:e,ts:Date.now(),accountType:null},P(s=>({...s,[t.id]:{quotas:[],error:e,loading:!1,accountType:null}}));return}let a=await s.json(),r=(0,v.W_)(e.tokenSwapProvider||"antigravity",a),l=function(e){if(!e)return null;if("string"==typeof e)return N(e);for(let t of[e.accountType,e.plan,e.paidTier?.name,e.subscriptionTier,e.subscription_tier,e.currentTier?.name,e.subscriptionInfo?.paidTier?.name,e.quota?.subscription_tier,e.subscriptionInfo?.currentTier?.name]){let e=N(t);if(e)return e}return null}(a);R.current[t.id]={data:r,error:null,ts:Date.now(),accountType:l},P(e=>({...e,[t.id]:{quotas:r,error:null,loading:!1,accountType:l}}))}catch(s){let e=s.message||"Failed";R.current[t.id]={data:[],error:e,ts:Date.now(),accountType:null},P(s=>({...s,[t.id]:{quotas:[],error:e,loading:!1,accountType:null}}))}}))},[e.tokenSwapProvider]);if(!e?.supportsTokenSwap)return null;let D=async()=>{m(!0);let e=!d;try{(await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({tokenSwapEnabled:e})})).ok&&(c(e),n?.(e))}catch{}m(!1)},U=async e=>{if(e!==u&&!h){g(!0);try{(await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({tokenSwapStrategy:e})})).ok&&p(e)}catch{}g(!1)}},K=async()=>{if(b)return;C(!0);let e=!f;try{(await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({tokenSwapMaskEmails:e})})).ok&&y(e)}catch{}C(!1)},L=t.filter(t=>t.provider===e.tokenSwapProvider),F=L.filter(e=>!1!==e.isActive),z=F.length,q=F.map(e=>e.id).join("|"),H=e?.stickyRoundRobinLimit||3,B=function(e,t,s){if(!e||0===e.length)return null;if(1===e.length)return e[0].id;let a=[...e].sort((e,t)=>e.lastUsedAt||t.lastUsedAt?e.lastUsedAt?t.lastUsedAt?new Date(t.lastUsedAt)-new Date(e.lastUsedAt):-1:1:(e.priority||999)-(t.priority||999));if("sticky"===t)return a[0]?.id||null;let r=a[0],l=r?.consecutiveUseCount||0;if(r?.lastUsedAt&&l<s)return r.id;let i=[...e].sort((e,t)=>e.lastUsedAt||t.lastUsedAt?e.lastUsedAt?t.lastUsedAt?new Date(e.lastUsedAt)-new Date(t.lastUsedAt):1:-1:(e.priority||999)-(t.priority||999));return i[0]?.id||null}(F,u,H);(0,r.useEffect)(()=>{d&&z>0&&$(F)},[d,z,q,$]);let J=s&&i,W=d&&J&&z>0,G=async(e,t)=>{if(e&&!S&&!T&&!_){A(e);try{(await fetch(`/api/providers/${e}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({isActive:t})})).ok&&await o?.()}catch{}A(null)}},Z=async e=>{if(e&&!_&&!T&&!S){E(e);try{(await fetch(`/api/providers/${e}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({lastUsedAt:null,consecutiveUseCount:0})})).ok&&await o?.()}catch{}E(null)}},Y=async()=>{if(!T&&!_&&!S&&0!==L.length){O(!0);try{await Promise.all(L.map(e=>fetch(`/api/providers/${e.id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({lastUsedAt:null,consecutiveUseCount:0})}))),await o?.()}catch{}O(!1)}};return(0,a.jsxs)(l.Zp,{padding:"xs",className:"overflow-hidden",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between",children:[(0,a.jsxs)("div",{className:"flex items-center gap-3",children:[(0,a.jsx)("div",{className:"size-8 flex items-center justify-center shrink-0 rounded-lg bg-violet-500/10",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-violet-400 text-[18px]",children:"swap_horiz"})}),(0,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("h3",{className:"font-medium text-sm",children:"Token Rotation"}),(0,a.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"}),W?(0,a.jsx)(l.Ex,{variant:"success",size:"sm",children:"Active"}):d?(0,a.jsx)(l.Ex,{variant:"warning",size:"sm",children:"Enabled"}):(0,a.jsx)(l.Ex,{variant:"default",size:"sm",children:"Off"})]}),(0,a.jsx)("p",{className:"text-xs text-text-muted",children:"Rotate auth tokens across pool accounts to bypass per-account quota"})]})]}),(0,a.jsx)("button",{onClick:D,disabled:x,className:`relative inline-flex h-5 w-9 items-center rounded-full transition-colors shrink-0 ${d?"bg-violet-500":"bg-surface-alt border border-border"} ${x?"opacity-50":"cursor-pointer"}`,title:d?"Disable Token Rotation":"Enable Token Rotation",children:(0,a.jsx)("span",{className:`inline-block h-3.5 w-3.5 transform rounded-full bg-white transition-transform shadow-sm ${d?"translate-x-4":"translate-x-0.5"}`})})]}),d&&(0,a.jsxs)("div",{className:"mt-3 pt-3 border-t border-border/50 flex flex-col gap-3",children:[(0,a.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,a.jsx)("span",{className:"material-symbols-outlined text-[14px] text-violet-400 mt-0.5 shrink-0",children:"info"}),(0,a.jsxs)("div",{className:"text-[11px] text-text-muted leading-relaxed",children:[(0,a.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,a.jsx)("p",{className:"mt-1 text-violet-400/80 font-medium",children:"⚠ When active, Model Routing (Mode A) is bypassed."})]})]}),(0,a.jsxs)("div",{className:"flex flex-col gap-1.5 px-1",children:[(0,a.jsx)("p",{className:"text-[10px] uppercase tracking-wider text-text-muted font-semibold",children:"Rotation Strategy"}),(0,a.jsxs)("div",{className:"flex gap-1.5",children:[(0,a.jsxs)("button",{onClick:()=>U("round-robin"),disabled:h,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"===u?"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,a.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"autorenew"}),"Round Robin"]}),(0,a.jsxs)("button",{onClick:()=>U("sticky"),disabled:h,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"===u?"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,a.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"push_pin"}),"Sticky"]})]}),(0,a.jsx)("p",{className:"text-[10px] text-text-muted px-0.5",children:"sticky"===u?"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,a.jsxs)("div",{className:"flex flex-col gap-1 px-1",children:[(0,a.jsx)("p",{className:"text-[10px] uppercase tracking-wider text-text-muted font-semibold mb-0.5",children:"Prerequisites"}),(0,a.jsxs)("div",{className:"flex items-center gap-2 text-xs",children:[(0,a.jsx)("span",{className:`material-symbols-outlined text-[14px] ${s?"text-green-500":"text-red-400"}`,children:s?"check_circle":"cancel"}),(0,a.jsx)("span",{className:s?"text-text-main":"text-text-muted",children:"MITM Server"})]}),(0,a.jsxs)("div",{className:"flex items-center gap-2 text-xs",children:[(0,a.jsx)("span",{className:`material-symbols-outlined text-[14px] ${i?"text-green-500":"text-red-400"}`,children:i?"check_circle":"cancel"}),(0,a.jsxs)("span",{className:i?"text-text-main":"text-text-muted",children:["DNS redirect",!i&&(0,a.jsx)("span",{className:"text-[10px] text-text-muted ml-1",children:"— enable via Antigravity card above"})]})]})]}),(0,a.jsxs)("div",{className:"flex flex-col gap-1 px-1",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between mb-0.5",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("p",{className:"text-[10px] uppercase tracking-wider text-text-muted font-semibold",children:"Pool Accounts"}),(0,a.jsx)("span",{className:"text-[10px] text-text-muted",children:L.length>0?`${z}/${L.length} active`:"none"}),z>1&&(0,a.jsx)("span",{className:"text-[9px] text-text-muted bg-surface border border-border px-1 py-0.5 rounded",children:"round-robin"})]}),(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[z>0&&(0,a.jsx)("button",{onClick:()=>$(F,!0),className:"text-[10px] text-text-muted hover:text-primary flex items-center gap-0.5 transition-colors",title:"Refresh quotas",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[12px]",children:"refresh"})}),L.length>0&&(0,a.jsxs)("button",{onClick:Y,disabled:T||!!_,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,a.jsx)("span",{className:"material-symbols-outlined text-[12px]",children:"restart_alt"}),"Reset all"]})]})]}),(0,a.jsxs)("p",{className:"text-[10px] text-text-muted px-0.5",children:["Sticky round robin keeps the current account until its streak reaches ",H,", then rotates to the least recently used account."]}),(0,a.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,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsx)("p",{className:"text-[11px] font-medium text-text-main",children:"Mask account emails"}),(0,a.jsxs)("p",{className:"text-[10px] text-text-muted",children:["Hide pool account emails in token swap logs and this panel. Example: ",w("email@gmail.com")]})]}),(0,a.jsx)("button",{onClick:K,disabled:b,className:`relative inline-flex h-5 w-9 items-center rounded-full transition-colors shrink-0 ${f?"bg-violet-500":"bg-surface border border-border"} ${b?"opacity-50":"cursor-pointer"}`,title:f?"Disable email masking":"Enable email masking",children:(0,a.jsx)("span",{className:`inline-block h-3.5 w-3.5 transform rounded-full bg-white transition-transform shadow-sm ${f?"translate-x-4":"translate-x-0.5"}`})})]}),L.length>0?(0,a.jsxs)(a.Fragment,{children:[L.map(e=>{let t=N(M[e.id]?.accountType)||N(e.accountType)||null;return(0,a.jsxs)("div",{className:`rounded-xl border border-border bg-surface-alt/30 px-3 py-2.5 transition-colors ${!1===e.isActive?"opacity-65":"hover:bg-surface-alt/50"}`,children:[(0,a.jsxs)("div",{className:"flex items-start justify-between gap-3",children:[(0,a.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2 min-w-0",children:[(0,a.jsx)("span",{className:`material-symbols-outlined text-[14px] shrink-0 ${!1===e.isActive?"text-text-muted":"text-green-500"}`,children:!1===e.isActive?"pause_circle":"check_circle"}),(0,a.jsx)("span",{className:"text-xs font-medium text-text-main truncate",children:e.email?f?w(e.email):e.email:e.name||e.id.slice(0,16)}),t&&(0,a.jsx)(l.Ex,{variant:"Ultra"===t?"warning":"Pro"===t?"primary":"Free"===t?"info":"default",size:"sm",children:t}),B===e.id&&!1!==e.isActive&&(0,a.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,a.jsx)(l.Ex,{variant:!1===e.isActive?"default":"success",size:"sm",children:!1===e.isActive?"disabled":"active"})]}),(0,a.jsxs)("div",{className:"mt-1 flex items-center gap-2 flex-wrap text-[10px] text-text-muted",children:[(0,a.jsxs)("span",{children:["Priority #",e.priority??"-"]}),(0,a.jsxs)("span",{children:["Streak ",e.consecutiveUseCount||0,"/",H]}),e.lastUsedAt&&(0,a.jsxs)("span",{children:["Last used ",new Date(e.lastUsedAt).toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit"})]})]})]}),(0,a.jsxs)("div",{className:"flex items-center gap-3 shrink-0",children:[(0,a.jsx)("button",{onClick:()=>Z(e.id),disabled:T||S===e.id||_===e.id,className:"text-[10px] text-text-muted hover:text-primary disabled:opacity-50 transition-colors",title:"Reset this account streak",children:_===e.id?"...":"Reset Streak"}),(0,a.jsx)(l.lM,{size:"sm",checked:!1!==e.isActive,disabled:T||_===e.id||S===e.id,onChange:t=>G(e.id,t)})]})]}),(0,a.jsx)("div",{className:"mt-2 pl-6",children:!1===e.isActive?(0,a.jsx)("div",{className:"text-[10px] text-text-muted",children:"Enable this account to include it in token rotation and load quota reset info."}):(e=>{let t=(e=>{let t=M[e];if(!t)return{state:"empty"};if(t.loading)return{state:"loading"};if(t.error)return{state:"error",error:t.error};if(!t.quotas||0===t.quotas.length)return{state:"no-data"};let s=t.quotas.find(e=>e.modelKey?.includes("claude-sonnet-4-6")||e.name?.toLowerCase().includes("opus"))||t.quotas[0];if(!s)return{state:"no-data"};let a=void 0!==s.remainingPercentage?Math.round(s.remainingPercentage):s.total>0?Math.round((s.total-s.used)/s.total*100):null,r=(s.resetAt&&new Date(s.resetAt).getTime()>Date.now()?s.resetAt:null)||[...t.quotas].map(e=>e.resetAt).filter(Boolean).filter(e=>new Date(e).getTime()>Date.now()).sort((e,t)=>new Date(e).getTime()-new Date(t).getTime())[0]||null;return{state:null===a?"no-data":"ready",highlight:s,accountType:t.accountType||null,pct:a,nextResetAt:r,resetCountdown:(0,v.mO)(r),resetDisplay:(0,v.sQ)(r)}})(e);if(!t||"empty"===t.state)return(0,a.jsx)("span",{className:"text-[10px] text-text-muted",children:"Enable to load quota data"});if("loading"===t.state)return(0,a.jsx)("span",{className:"text-[10px] text-text-muted animate-pulse",children:"Loading quota…"});if("error"===t.state)return(0,a.jsx)("span",{className:"text-[10px] text-red-400",title:t.error,children:"Quota unavailable"});if("no-data"===t.state)return(0,a.jsx)("span",{className:"text-[10px] text-text-muted",children:"No quota data"});let{highlight:s,pct:r,resetCountdown:l,resetDisplay:i}=t;return(0,a.jsxs)("div",{className:"flex flex-col gap-1.5 min-w-0",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2 min-w-0",children:[(0,a.jsx)("span",{className:"text-[10px] text-text-muted truncate",children:s.name}),(0,a.jsx)("div",{className:"flex-1 h-1.5 rounded-full bg-surface-alt overflow-hidden min-w-[56px]",children:(0,a.jsx)("div",{className:`h-full rounded-full ${r>70?"bg-green-500":r>=30?"bg-yellow-500":"bg-red-500"}`,style:{width:`${Math.min(r,100)}%`}})}),(0,a.jsxs)("span",{className:`text-[10px] font-medium shrink-0 ${r>70?"text-green-500":r>=30?"text-yellow-500":"text-red-500"}`,children:[r,"%"]})]}),"-"!==l&&i?(0,a.jsxs)("div",{className:"text-[10px] text-text-muted",children:["Reset in ",(0,a.jsx)("span",{className:"text-text-main",children:l}),(0,a.jsxs)("span",{className:"text-text-muted/70",children:[" • ",i]})]}):(0,a.jsx)("div",{className:"text-[10px] text-text-muted",children:"Reset time unavailable"})]})})(e.id)})]},e.id)}),(0,a.jsxs)(j(),{href:"/dashboard/providers",className:"text-[11px] text-primary hover:underline flex items-center gap-1 px-1 mt-1",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[12px]",children:"open_in_new"}),"Manage accounts"]})]}):(0,a.jsx)("div",{className:"px-1",children:(0,a.jsxs)("p",{className:"text-xs text-text-muted",children:["No active ",e.name," accounts in pool."," ",(0,a.jsx)(j(),{href:"/dashboard/providers",className:"text-primary hover:underline",children:"Add account →"})]})})]}),!J&&(0,a.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,a.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"warning"}),(0,a.jsx)("span",{children:"Start MITM server and enable DNS to activate token rotation"})]})]})]})}},3534:(e,t,s)=>{s.d(t,{dM:()=>r,wn:()=>a});let a={antigravity:{id:"antigravity",name:"Antigravity",image:"/providers/antigravity.png",color:"#4285F4",description:"Google Antigravity IDE with MITM",configType:"mitm",mitmDomain:"daily-cloudcode-pa.googleapis.com",supportsTokenSwap:!0,tokenSwapProvider:"antigravity",modelAliases:["claude-opus-4-6-thinking","claude-sonnet-4-6","gemini-3-flash","gpt-oss-120b-medium","gemini-3-pro-high","gemini-3-pro-low"],defaultModels:[{id:"gemini-3.1-pro-high",name:"Gemini 3.1 Pro High",alias:"gemini-3.1-pro-high"},{id:"gemini-3.1-pro-low",name:"Gemini 3.1 Pro Low",alias:"gemini-3.1-pro-low"},{id:"gemini-3-flash",name:"Gemini 3 Flash",alias:"gemini-3-flash"},{id:"claude-sonnet-4-6",name:"Claude Sonnet 4.6",alias:"claude-sonnet-4-6"},{id:"claude-opus-4-6-thinking",name:"Claude Opus 4.6 Thinking",alias:"claude-opus-4-6-thinking"},{id:"gpt-oss-120b-medium",name:"GPT OSS 120B Medium",alias:"gpt-oss-120b-medium"}]},copilot:{id:"copilot",name:"GitHub Copilot",image:"/providers/copilot.png",color:"#1F6FEB",description:"GitHub Copilot IDE with MITM",configType:"mitm",mitmDomain:"api.individual.githubcopilot.com",modelAliases:["gpt-4o-mini","claude-haiku-4.5","gpt-4o","gpt-5-mini"],defaultModels:[{id:"gpt-4o",name:"GPT-4o",alias:"gpt-4o"},{id:"gpt-4.1",name:"GPT-4.1",alias:"gpt-4.1"},{id:"claude-haiku-4.5",name:"Claude Haiku 4.5",alias:"claude-haiku-4.5"}]},kiro:{id:"kiro",name:"Kiro",image:"/providers/kiro.png",color:"#FF6B00",description:"Kiro IDE with MITM",configType:"mitm",mitmDomain:"q.us-east-1.amazonaws.com",defaultModels:[{id:"claude-sonnet-4.5",name:"Claude Sonnet 4.5",alias:"claude-sonnet-4.5"},{id:"claude-sonnet-4",name:"Claude Sonnet 4",alias:"claude-sonnet-4"},{id:"claude-haiku-4.5",name:"Claude Haiku 4.5",alias:"claude-haiku-4.5"},{id:"deepseek-3.2",name:"DeepSeek 3.2",alias:"deepseek-3.2"},{id:"minimax-m2.1",name:"MiniMax M2.1",alias:"minimax-m2.1"},{id:"simple-task",name:"Qwen3 Coder Next",alias:"simple-task"}]}},r={claude:{id:"claude",name:"Claude Code",icon:"terminal",color:"#D97757",description:"Anthropic Claude Code CLI",configType:"env",envVars:{baseUrl:"ANTHROPIC_BASE_URL",model:"ANTHROPIC_MODEL",opusModel:"ANTHROPIC_DEFAULT_OPUS_MODEL",sonnetModel:"ANTHROPIC_DEFAULT_SONNET_MODEL",haikuModel:"ANTHROPIC_DEFAULT_HAIKU_MODEL"},modelAliases:["default","sonnet","opus","haiku","opusplan"],settingsFile:"~/.claude/settings.json",defaultModels:[{id:"opus",name:"Claude Opus",alias:"opus",envKey:"ANTHROPIC_DEFAULT_OPUS_MODEL",defaultValue:"cc/claude-opus-4-6"},{id:"sonnet",name:"Claude Sonnet",alias:"sonnet",envKey:"ANTHROPIC_DEFAULT_SONNET_MODEL",defaultValue:"cc/claude-sonnet-4-6"},{id:"haiku",name:"Claude Haiku",alias:"haiku",envKey:"ANTHROPIC_DEFAULT_HAIKU_MODEL",defaultValue:"cc/claude-haiku-4-5-20251001"}]},openclaw:{id:"openclaw",name:"Open Claw",image:"/providers/openclaw.png",color:"#FF6B35",description:"Open Claw AI Assistant",configType:"custom"},codex:{id:"codex",name:"OpenAI Codex CLI",image:"/providers/codex.png",color:"#10A37F",description:"OpenAI Codex CLI",configType:"custom"},opencode:{id:"opencode",name:"OpenCode",image:"/providers/opencode.png",color:"#E87040",description:"OpenCode AI Terminal Assistant",configType:"custom"},droid:{id:"droid",name:"Factory Droid",image:"/providers/droid.png",color:"#00D4FF",description:"Factory Droid AI Assistant",configType:"custom"},cursor:{id:"cursor",name:"Cursor",image:"/providers/cursor.png",color:"#000000",description:"Cursor AI Code Editor",configType:"guide",requiresExternalUrl:!0,notes:[{type:"warning",text:"Requires Cursor Pro account to use this feature."},{type:"cloudCheck",text:"Cursor routes requests through its own server, so local endpoint is not supported. Please enable Tunnel or Cloud Endpoint in Settings."}],guideSteps:[{step:1,title:"Open Settings",desc:"Go to Settings → Models"},{step:2,title:"Enable OpenAI API",desc:'Enable "OpenAI API key" option'},{step:3,title:"Base URL",value:"{{baseUrl}}",copyable:!0},{step:4,title:"API Key",type:"apiKeySelector"},{step:5,title:"Add Custom Model",desc:'Click "View All Model" → "Add Custom Model"'},{step:6,title:"Select Model",type:"modelSelector"}]},cline:{id:"cline",name:"Cline",image:"/providers/cline.png",color:"#00D1B2",description:"Cline AI Coding Assistant",configType:"guide",guideSteps:[{step:1,title:"Open Settings",desc:"Go to Cline Settings panel"},{step:2,title:"Select Provider",desc:"Choose API Provider → OpenAI Compatible"},{step:3,title:"Base URL",value:"{{baseUrl}}/v1",copyable:!0},{step:4,title:"API Key",type:"apiKeySelector"},{step:5,title:"Select Model",type:"modelSelector"}]},kilo:{id:"kilo",name:"Kilo Code",image:"/providers/kilocode.png",color:"#FF6B6B",description:"Kilo Code AI Assistant",configType:"guide",guideSteps:[{step:1,title:"Open Settings",desc:"Go to Kilo Code Settings panel"},{step:2,title:"Select Provider",desc:"Choose API Provider → OpenAI Compatible"},{step:3,title:"Base URL",value:"{{baseUrl}}/v1",copyable:!0},{step:4,title:"API Key",type:"apiKeySelector"},{step:5,title:"Select Model",type:"modelSelector"}]},roo:{id:"roo",name:"Roo",image:"/providers/roo.png",color:"#FF6B6B",description:"Roo AI Assistant",configType:"guide",guideSteps:[{step:1,title:"Open Settings",desc:"Go to Roo Settings panel"},{step:2,title:"Select Provider",desc:"Choose API Provider → Ollama"},{step:3,title:"Base URL",value:"{{baseUrl}}",copyable:!0},{step:4,title:"API Key",type:"apiKeySelector"},{step:5,title:"Select Model",type:"modelSelector"}]},continue:{id:"continue",name:"Continue",image:"/providers/continue.png",color:"#7C3AED",description:"Continue AI Assistant",configType:"guide",guideSteps:[{step:1,title:"Open Config",desc:"Open Continue configuration file"},{step:2,title:"API Key",type:"apiKeySelector"},{step:3,title:"Select Model",type:"modelSelector"},{step:4,title:"Add Model Config",desc:"Add the following configuration to your models array:"}],codeBlock:{language:"json",code:`{
|
|
9
|
+
`},{filename:"~/.codex/auth.json",content:JSON.stringify({OPENAI_API_KEY:h},null,2)}])})]})}let c="https://9router.com";function x({tool:e,isExpanded:t,onToggle:s,baseUrl:n,hasActiveProviders:o,apiKeys:d,activeProviders:m,cloudEnabled:u,initialStatus:p}){let h,g,f,y,[b,j]=(0,r.useState)(p||null),[N,v]=(0,r.useState)(!1),[w,k]=(0,r.useState)(!1),[C,S]=(0,r.useState)(!1),[A,_]=(0,r.useState)(null),[E,T]=(0,r.useState)(""),[O,M]=(0,r.useState)(""),[P,$]=(0,r.useState)(!1),[I,R]=(0,r.useState)({}),[D,U]=(0,r.useState)(!1),[K,L]=(0,r.useState)(""),F=(0,r.useRef)(!1),z=(()=>{if(!b?.installed)return null;let e=b.settings?.customModels?.find(e=>"custom:9Router-0"===e.id);if(!e)return"not_configured";let t=e.baseUrl?.includes("localhost")||e.baseUrl?.includes("127.0.0.1"),s=u&&c&&e.baseUrl?.startsWith(c),a=n&&e.baseUrl?.startsWith(n);return t||s||a?"configured":"other"})();(0,r.useEffect)(()=>{d?.length>0&&!E&&T(d[0].key)},[d,E]),(0,r.useEffect)(()=>{p&&j(p)},[p]),(0,r.useEffect)(()=>{t&&!b&&(H(),q()),t&&q()},[t]);let q=async()=>{try{let e=await fetch("/api/models/alias"),t=await e.json();e.ok&&R(t.aliases||{})}catch(e){console.log("Error fetching model aliases:",e)}};(0,r.useEffect)(()=>{if(b?.installed&&!F.current){F.current=!0;let e=b.settings?.customModels?.find(e=>"custom:9Router-0"===e.id);e&&(e.model&&M(e.model),e.apiKey&&d?.some(t=>t.key===e.apiKey)&&T(e.apiKey))}},[b,d]);let H=async()=>{v(!0);try{let e=await fetch("/api/cli-tools/droid-settings"),t=await e.json();j(t)}catch(e){j({installed:!1,error:e.message})}finally{v(!1)}},B=()=>{let e=K||n;return e.endsWith("/v1")?e:`${e}/v1`},J=async()=>{k(!0),_(null);try{let e=E?.trim()||(d?.length>0?d[0].key:null)||(u?null:"sk_9router"),t=await fetch("/api/cli-tools/droid-settings",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({baseUrl:B(),apiKey:e,model:O})}),s=await t.json();t.ok?(_({type:"success",text:"Settings applied successfully!"}),H()):_({type:"error",text:s.error||"Failed to apply settings"})}catch(e){_({type:"error",text:e.message})}finally{k(!1)}},W=async()=>{S(!0),_(null);try{let e=await fetch("/api/cli-tools/droid-settings",{method:"DELETE"}),t=await e.json();e.ok?(_({type:"success",text:"Settings reset successfully!"}),M(""),T(""),H()):_({type:"error",text:t.error||"Failed to reset settings"})}catch(e){_({type:"error",text:e.message})}finally{S(!1)}};return(0,a.jsxs)(l.Zp,{padding:"xs",className:"overflow-hidden",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between hover:cursor-pointer",onClick:s,children:[(0,a.jsxs)("div",{className:"flex items-center gap-3",children:[(0,a.jsx)("div",{className:"size-8 flex items-center justify-center shrink-0",children:(0,a.jsx)(i.default,{src:"/providers/droid.png",alt:e.name,width:32,height:32,className:"size-8 object-contain rounded-lg",sizes:"32px",onError:e=>{e.target.style.display="none"}})}),(0,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("h3",{className:"font-medium text-sm",children:e.name}),"configured"===z&&(0,a.jsx)("span",{className:"px-1.5 py-0.5 text-[10px] font-medium bg-green-500/10 text-green-600 dark:text-green-400 rounded-full",children:"Connected"}),"not_configured"===z&&(0,a.jsx)("span",{className:"px-1.5 py-0.5 text-[10px] font-medium bg-yellow-500/10 text-yellow-600 dark:text-yellow-400 rounded-full",children:"Not configured"}),"other"===z&&(0,a.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,a.jsx)("p",{className:"text-xs text-text-muted truncate",children:e.description})]})]}),(0,a.jsx)("span",{className:`material-symbols-outlined text-text-muted text-[20px] transition-transform ${t?"rotate-180":""}`,children:"expand_more"})]}),t&&(0,a.jsxs)("div",{className:"mt-4 pt-4 border-t border-border flex flex-col gap-4",children:[N&&(0,a.jsxs)("div",{className:"flex items-center gap-2 text-text-muted",children:[(0,a.jsx)("span",{className:"material-symbols-outlined animate-spin",children:"progress_activity"}),(0,a.jsx)("span",{children:"Checking Factory Droid CLI..."})]}),!N&&b&&!b.installed&&(0,a.jsxs)("div",{className:"flex items-center gap-3 p-4 bg-yellow-500/10 border border-yellow-500/30 rounded-lg",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-yellow-500",children:"warning"}),(0,a.jsxs)("div",{className:"flex-1",children:[(0,a.jsx)("p",{className:"font-medium text-yellow-600 dark:text-yellow-400",children:"Factory Droid CLI not installed"}),(0,a.jsx)("p",{className:"text-sm text-text-muted",children:"Please install Factory Droid CLI to use this feature."})]})]}),!N&&b?.installed&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{className:"flex flex-col gap-2",children:[b?.settings?.customModels?.find(e=>"custom:9Router-0"===e.id)?.baseUrl&&(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("span",{className:"w-32 shrink-0 text-sm font-semibold text-text-main text-right",children:"Current"}),(0,a.jsx)("span",{className:"material-symbols-outlined text-text-muted text-[14px]",children:"arrow_forward"}),(0,a.jsx)("span",{className:"flex-1 px-2 py-1.5 text-xs text-text-muted truncate",children:b.settings.customModels.find(e=>"custom:9Router-0"===e.id).baseUrl})]}),(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("span",{className:"w-32 shrink-0 text-sm font-semibold text-text-main text-right",children:"Base URL"}),(0,a.jsx)("span",{className:"material-symbols-outlined text-text-muted text-[14px]",children:"arrow_forward"}),(0,a.jsx)("input",{type:"text",value:(h=K||n).endsWith("/v1")?h:`${h}/v1`,onChange:e=>L(e.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!==n&&(0,a.jsx)("button",{onClick:()=>L(""),className:"p-1 text-text-muted hover:text-primary rounded transition-colors",title:"Reset to default",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"restart_alt"})})]}),(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("span",{className:"w-32 shrink-0 text-sm font-semibold text-text-main text-right",children:"API Key"}),(0,a.jsx)("span",{className:"material-symbols-outlined text-text-muted text-[14px]",children:"arrow_forward"}),d.length>0?(0,a.jsx)("select",{value:E,onChange:e=>T(e.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:d.map(e=>(0,a.jsx)("option",{value:e.key,children:e.key},e.id))}):(0,a.jsx)("span",{className:"flex-1 text-xs text-text-muted px-2 py-1.5",children:u?"No API keys - Create one in Keys page":"sk_9router (default)"})]}),(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("span",{className:"w-32 shrink-0 text-sm font-semibold text-text-main text-right",children:"Model"}),(0,a.jsx)("span",{className:"material-symbols-outlined text-text-muted text-[14px]",children:"arrow_forward"}),(0,a.jsx)("input",{type:"text",value:O,onChange:e=>M(e.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,a.jsx)("button",{onClick:()=>$(!0),disabled:!o,className:`px-2 py-1.5 rounded border text-xs transition-colors shrink-0 whitespace-nowrap ${o?"bg-surface border-border text-text-main hover:border-primary cursor-pointer":"opacity-50 cursor-not-allowed border-border"}`,children:"Select Model"}),O&&(0,a.jsx)("button",{onClick:()=>M(""),className:"p-1 text-text-muted hover:text-red-500 rounded transition-colors",title:"Clear",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"close"})})]})]}),A&&(0,a.jsxs)("div",{className:`flex items-center gap-2 px-2 py-1.5 rounded text-xs ${"success"===A.type?"bg-green-500/10 text-green-600":"bg-red-500/10 text-red-600"}`,children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"success"===A.type?"check_circle":"error"}),(0,a.jsx)("span",{children:A.text})]}),(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsxs)(l.$n,{variant:"primary",size:"sm",onClick:J,disabled:!O,loading:w,children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px] mr-1",children:"save"}),"Apply"]}),(0,a.jsxs)(l.$n,{variant:"outline",size:"sm",onClick:W,disabled:!b?.has9Router,loading:C,children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px] mr-1",children:"restore"}),"Reset"]}),(0,a.jsxs)(l.$n,{variant:"ghost",size:"sm",onClick:()=>U(!0),children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px] mr-1",children:"content_copy"}),"Manual Config"]})]})]})]}),(0,a.jsx)(l.rq,{isOpen:P,onClose:()=>$(!1),onSelect:e=>{M(e.value),$(!1)},selectedModel:O,activeProviders:m,modelAliases:I,title:"Select Model for Factory Droid"}),(0,a.jsx)(l.uR,{isOpen:D,onClose:()=>U(!1),title:"Factory Droid - Manual Configuration",configs:(g=E&&E.trim()?E:u?"<API_KEY_FROM_DASHBOARD>":"sk_9router",f={customModels:[{model:O||"provider/model-id",id:"custom:9Router-0",index:0,baseUrl:B(),apiKey:g,displayName:O||"provider/model-id",maxOutputTokens:131072,noImageSupport:!1,provider:"openai"}]},y="u">typeof navigator&&navigator.platform,[{filename:y?.toLowerCase().includes("win")?"%USERPROFILE%\\.factory\\settings.json":"~/.factory/settings.json",content:JSON.stringify(f,null,2)}])})]})}function m({tool:e,isExpanded:t,onToggle:s,baseUrl:n,hasActiveProviders:o,apiKeys:d,activeProviders:c,cloudEnabled:x,initialStatus:u}){let p,h,[g,f]=(0,r.useState)(u||null),[y,b]=(0,r.useState)(!1),[j,N]=(0,r.useState)(!1),[v,w]=(0,r.useState)(!1),[k,C]=(0,r.useState)(null),[S,A]=(0,r.useState)(""),[_,E]=(0,r.useState)(""),[T,O]=(0,r.useState)({}),[M,P]=(0,r.useState)(null),[$,I]=(0,r.useState)(!1),[R,D]=(0,r.useState)({}),[U,K]=(0,r.useState)(!1),[L,F]=(0,r.useState)(""),z=(0,r.useRef)(!1),q=(()=>{if(!g?.installed)return null;let e=g.settings?.models?.providers?.["9router"];if(!e)return"not_configured";let t=e.baseUrl?.includes("localhost")||e.baseUrl?.includes("127.0.0.1")||e.baseUrl?.includes("0.0.0.0"),s=n&&e.baseUrl?.startsWith(n);return t||s?"configured":"other"})();(0,r.useEffect)(()=>{d?.length>0&&!S&&A(d[0].key)},[d,S]),(0,r.useEffect)(()=>{u&&f(u)},[u]),(0,r.useEffect)(()=>{t&&!g&&(B(),H()),t&&H()},[t]);let H=async()=>{try{let e=await fetch("/api/models/alias"),t=await e.json();e.ok&&D(t.aliases||{})}catch(e){console.log("Error fetching model aliases:",e)}};(0,r.useEffect)(()=>{if(g?.installed&&!z.current){z.current=!0;let e=g.settings?.models?.providers?.["9router"];if(e){let t=g.settings?.agents?.defaults?.model?.primary;t&&E(t.replace("9router/","")),e.apiKey&&d?.some(t=>t.key===e.apiKey)&&A(e.apiKey)}let t=g.agents||[],s={};t.forEach(e=>{e.currentModel&&(s[e.id]=e.currentModel)}),O(s)}},[g,d]);let B=async()=>{b(!0);try{let e=await fetch("/api/cli-tools/openclaw-settings"),t=await e.json();f(t)}catch(e){f({installed:!1,error:e.message})}finally{b(!1)}},J=()=>window.location.origin.replace("://localhost","://127.0.0.1"),W=()=>{let e=L||J();return e.endsWith("/v1")?e:`${e}/v1`},G=async()=>{N(!0),C(null);try{let e=S?.trim()||(d?.length>0?d[0].key:null)||(x?null:"sk_9router"),t=await fetch("/api/cli-tools/openclaw-settings",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({baseUrl:W(),apiKey:e,model:_,agentModels:T})}),s=await t.json();t.ok?(C({type:"success",text:"Settings applied successfully!"}),B()):C({type:"error",text:s.error||"Failed to apply settings"})}catch(e){C({type:"error",text:e.message})}finally{N(!1)}},Z=async()=>{w(!0),C(null);try{let e=await fetch("/api/cli-tools/openclaw-settings",{method:"DELETE"}),t=await e.json();e.ok?(C({type:"success",text:"Settings reset successfully!"}),E(""),A(""),B()):C({type:"error",text:t.error||"Failed to reset settings"})}catch(e){C({type:"error",text:e.message})}finally{w(!1)}};return(0,a.jsxs)(l.Zp,{padding:"xs",className:"overflow-hidden",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between hover:cursor-pointer",onClick:s,children:[(0,a.jsxs)("div",{className:"flex items-center gap-3",children:[(0,a.jsx)("div",{className:"size-8 flex items-center justify-center shrink-0",children:(0,a.jsx)(i.default,{src:"/providers/openclaw.png",alt:e.name,width:32,height:32,className:"size-8 object-contain rounded-lg",sizes:"32px",onError:e=>{e.target.style.display="none"}})}),(0,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("h3",{className:"font-medium text-sm",children:e.name}),"configured"===q&&(0,a.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,a.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,a.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,a.jsx)("p",{className:"text-xs text-text-muted truncate",children:e.description})]})]}),(0,a.jsx)("span",{className:`material-symbols-outlined text-text-muted text-[20px] transition-transform ${t?"rotate-180":""}`,children:"expand_more"})]}),t&&(0,a.jsxs)("div",{className:"mt-4 pt-4 border-t border-border flex flex-col gap-4",children:[y&&(0,a.jsxs)("div",{className:"flex items-center gap-2 text-text-muted",children:[(0,a.jsx)("span",{className:"material-symbols-outlined animate-spin",children:"progress_activity"}),(0,a.jsx)("span",{children:"Checking Open Claw CLI..."})]}),!y&&g&&!g.installed&&(0,a.jsxs)("div",{className:"flex items-center gap-3 p-4 bg-yellow-500/10 border border-yellow-500/30 rounded-lg",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-yellow-500",children:"warning"}),(0,a.jsxs)("div",{className:"flex-1",children:[(0,a.jsx)("p",{className:"font-medium text-yellow-600 dark:text-yellow-400",children:"Open Claw CLI not installed"}),(0,a.jsx)("p",{className:"text-sm text-text-muted",children:"Please install Open Claw CLI to use this feature."})]})]}),!y&&g?.installed&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{className:"flex flex-col gap-2",children:[g?.settings?.models?.providers?.["9router"]?.baseUrl&&(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("span",{className:"w-32 shrink-0 text-sm font-semibold text-text-main text-right",children:"Current"}),(0,a.jsx)("span",{className:"material-symbols-outlined text-text-muted text-[14px]",children:"arrow_forward"}),(0,a.jsx)("span",{className:"flex-1 px-2 py-1.5 text-xs text-text-muted truncate",children:g.settings.models.providers["9router"].baseUrl})]}),(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("span",{className:"w-32 shrink-0 text-sm font-semibold text-text-main text-right",children:"Base URL"}),(0,a.jsx)("span",{className:"material-symbols-outlined text-text-muted text-[14px]",children:"arrow_forward"}),(0,a.jsx)("input",{type:"text",value:(p=L||J()).endsWith("/v1")?p:`${p}/v1`,onChange:e=>F(e.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"}),L&&L!==n&&(0,a.jsx)("button",{onClick:()=>F(""),className:"p-1 text-text-muted hover:text-primary rounded transition-colors",title:"Reset to default",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"restart_alt"})})]}),(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("span",{className:"w-32 shrink-0 text-sm font-semibold text-text-main text-right",children:"API Key"}),(0,a.jsx)("span",{className:"material-symbols-outlined text-text-muted text-[14px]",children:"arrow_forward"}),d.length>0?(0,a.jsx)("select",{value:S,onChange:e=>A(e.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:d.map(e=>(0,a.jsx)("option",{value:e.key,children:e.key},e.id))}):(0,a.jsx)("span",{className:"flex-1 text-xs text-text-muted px-2 py-1.5",children:x?"No API keys - Create one in Keys page":"sk_9router (default)"})]}),(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("span",{className:"w-32 shrink-0 text-sm font-semibold text-text-main text-right",children:"Default Model"}),(0,a.jsx)("span",{className:"material-symbols-outlined text-text-muted text-[14px]",children:"arrow_forward"}),(0,a.jsx)("input",{type:"text",value:_,onChange:e=>E(e.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,a.jsx)("button",{onClick:()=>{P(null),I(!0)},disabled:!o,className:`px-2 py-1.5 rounded border text-xs transition-colors shrink-0 whitespace-nowrap ${o?"bg-surface border-border text-text-main hover:border-primary cursor-pointer":"opacity-50 cursor-not-allowed border-border"}`,children:"Select"}),_&&(0,a.jsx)("button",{onClick:()=>E(""),className:"p-1 text-text-muted hover:text-red-500 rounded transition-colors",title:"Clear",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"close"})})]}),(g.agents||[]).filter(e=>e.agentDir).map(e=>(0,a.jsxs)("div",{className:"flex items-center gap-2 pl-4",children:[(0,a.jsxs)("span",{className:"w-32 shrink-0 text-xs text-primary text-right truncate",title:e.name||e.id,children:["Agent ",e.name||e.id]}),(0,a.jsx)("span",{className:"material-symbols-outlined text-text-muted text-[14px]",children:"arrow_forward"}),(0,a.jsx)("input",{type:"text",value:T[e.id]||"",onChange:t=>O(s=>({...s,[e.id]:t.target.value})),placeholder:`default (${_||"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,a.jsx)("button",{onClick:()=>{P(e.id),I(!0)},disabled:!o,className:`px-2 py-1.5 rounded border text-xs transition-colors shrink-0 whitespace-nowrap ${o?"bg-surface border-border text-text-main hover:border-primary cursor-pointer":"opacity-50 cursor-not-allowed border-border"}`,children:"Select"}),T[e.id]&&(0,a.jsx)("button",{onClick:()=>O(t=>({...t,[e.id]:""})),className:"p-1 text-text-muted hover:text-red-500 rounded transition-colors",title:"Clear",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"close"})})]},e.id))]}),k&&(0,a.jsxs)("div",{className:`flex items-center gap-2 px-2 py-1.5 rounded text-xs ${"success"===k.type?"bg-green-500/10 text-green-600":"bg-red-500/10 text-red-600"}`,children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"success"===k.type?"check_circle":"error"}),(0,a.jsx)("span",{children:k.text})]}),(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsxs)(l.$n,{variant:"primary",size:"sm",onClick:G,disabled:!_,loading:j,children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px] mr-1",children:"save"}),"Apply"]}),(0,a.jsxs)(l.$n,{variant:"outline",size:"sm",onClick:Z,disabled:!g?.has9Router,loading:v,children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px] mr-1",children:"restore"}),"Reset"]}),(0,a.jsxs)(l.$n,{variant:"ghost",size:"sm",onClick:()=>K(!0),children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px] mr-1",children:"content_copy"}),"Manual Config"]})]})]})]}),(0,a.jsx)(l.rq,{isOpen:$,onClose:()=>I(!1),onSelect:e=>{M?(O(t=>({...t,[M]:e.value})),P(null)):E(e.value),I(!1)},selectedModel:_,activeProviders:c,modelAliases:R,title:"Select Model for Open Claw"}),(0,a.jsx)(l.uR,{isOpen:U,onClose:()=>K(!1),title:"Open Claw - Manual Configuration",configs:(h=S&&S.trim()?S:x?"<API_KEY_FROM_DASHBOARD>":"sk_9router",[{filename:"~/.openclaw/openclaw.json",content:JSON.stringify({agents:{defaults:{model:{primary:`9router/${_||"provider/model-id"}`}}},models:{providers:{"9router":{baseUrl:W(),apiKey:h,api:"openai-completions",models:[{id:_||"provider/model-id",name:(_||"provider/model-id").split("/").pop()}]}}}},null,2)}])})]})}function u({toolId:e,tool:t,isExpanded:s,onToggle:n,baseUrl:o,apiKeys:d,activeProviders:c=[],cloudEnabled:x=!1,tunnelEnabled:m=!1}){let[p,h]=(0,r.useState)(null),[g,f]=(0,r.useState)(!1),[y,b]=(0,r.useState)(""),[j,N]=(0,r.useState)(()=>d?.length>0?d[0].key:""),v=e=>{let t=j&&j.trim()?j:x?"your-api-key":"sk_9router",s=o||"http://localhost:20128",a=s.endsWith("/v1")?s:`${s}/v1`;return e.replace(/\{\{baseUrl\}\}/g,a).replace(/\{\{apiKey\}\}/g,t).replace(/\{\{model\}\}/g,y||"provider/model-id")},w=async(e,t)=>{await navigator.clipboard.writeText(v(e)),h(t),setTimeout(()=>h(null),2e3)},k=c.length>0,C=()=>(!t.requiresExternalUrl||!!x||!!m)&&(!t.requiresCloud||!!x);return(0,a.jsxs)(l.Zp,{padding:"xs",className:"overflow-hidden",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between hover:cursor-pointer",onClick:n,children:[(0,a.jsxs)("div",{className:"flex items-center gap-3",children:[(0,a.jsx)("div",{className:"size-8 rounded-lg flex items-center justify-center shrink-0",children:t.image?(0,a.jsx)(i.default,{src:t.image,alt:t.name,width:32,height:32,className:"size-8 object-contain rounded-lg",sizes:"32px",onError:e=>{e.target.style.display="none"}}):t.icon?(0,a.jsx)("span",{className:"material-symbols-outlined text-xl",style:{color:t.color},children:t.icon}):(0,a.jsx)(i.default,{src:`/providers/${e}.png`,alt:t.name,width:32,height:32,className:"size-8 object-contain rounded-lg",sizes:"32px",onError:e=>{e.target.style.display="none"}})}),(0,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsx)("h3",{className:"font-medium text-sm",children:t.name}),(0,a.jsx)("p",{className:"text-xs text-text-muted truncate",children:t.description})]})]}),(0,a.jsx)("span",{className:`material-symbols-outlined text-text-muted text-[20px] transition-transform ${s?"rotate-180":""}`,children:"expand_more"})]}),s&&(0,a.jsx)("div",{className:"mt-6 pt-6 border-t border-border",children:t.guideSteps?(0,a.jsxs)("div",{className:"flex flex-col gap-4",children:[t.notes&&0!==t.notes.length?(0,a.jsx)("div",{className:"flex flex-col gap-2 mb-4",children:t.notes.map((e,t)=>{if("cloudCheck"===e.type&&(x||m))return null;let s="warning"===e.type,r="cloudCheck"===e.type&&!x&&!m,l="bg-blue-500/10 border-blue-500/30",i="text-blue-600 dark:text-blue-400",n="text-blue-500",o="info";return s?(l="bg-yellow-500/10 border-yellow-500/30",i="text-yellow-600 dark:text-yellow-400",n="text-yellow-500",o="warning"):r&&(l="bg-red-500/10 border-red-500/30",i="text-red-600 dark:text-red-400",n="text-red-500",o="error"),(0,a.jsxs)("div",{className:`flex items-start gap-3 p-3 rounded-lg border ${l}`,children:[(0,a.jsx)("span",{className:`material-symbols-outlined text-lg ${n}`,children:o}),(0,a.jsx)("p",{className:`text-sm ${i}`,children:e.text})]},t)})}):null,C()&&t.guideSteps.map(e=>(0,a.jsxs)("div",{className:"flex items-start gap-4",children:[(0,a.jsx)("div",{className:"size-8 rounded-full flex items-center justify-center shrink-0 text-sm font-semibold text-white",style:{backgroundColor:t.color},children:e.step}),(0,a.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,a.jsx)("p",{className:"font-medium text-text",children:e.title}),e.desc&&(0,a.jsx)("p",{className:"text-sm text-text-muted mt-0.5",children:e.desc}),"apiKeySelector"===e.type&&(0,a.jsx)("div",{className:"mt-2 flex items-center gap-2",children:d&&d.length>0?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("select",{value:j,onChange:e=>N(e.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:d.map(e=>(0,a.jsx)("option",{value:e.key,children:e.key},e.id))}),(0,a.jsx)("button",{onClick:()=>w(j,"apiKey"),className:"shrink-0 px-3 py-2 bg-bg-secondary hover:bg-bg-tertiary rounded-lg border border-border transition-colors",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-lg",children:"apiKey"===p?"check":"content_copy"})})]}):(0,a.jsx)("span",{className:"text-sm text-text-muted",children:x?"No API keys - Create one in Keys page":"sk_9router"})}),"modelSelector"===e.type&&(0,a.jsxs)("div",{className:"mt-2 flex items-center gap-2",children:[(0,a.jsx)("input",{type:"text",value:y,onChange:e=>b(e.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,a.jsx)("button",{onClick:()=>f(!0),disabled:!k,className:`shrink-0 px-3 py-2 rounded-lg border text-sm transition-colors ${k?"bg-bg-secondary border-border text-text-main hover:border-primary cursor-pointer":"opacity-50 cursor-not-allowed border-border"}`,children:"Select Model"}),y&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("button",{onClick:()=>w(y,"model"),className:"shrink-0 px-3 py-2 bg-bg-secondary hover:bg-bg-tertiary rounded-lg border border-border transition-colors",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-lg",children:"model"===p?"check":"content_copy"})}),(0,a.jsx)("button",{onClick:()=>b(""),className:"p-2 text-text-muted hover:text-red-500 rounded transition-colors",title:"Clear",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-lg",children:"close"})})]})]}),e.value&&(0,a.jsxs)("div",{className:"mt-2 flex items-center gap-2",children:[(0,a.jsx)("code",{className:"flex-1 px-3 py-2 bg-bg-secondary rounded-lg text-sm font-mono border border-border truncate",children:v(e.value)}),e.copyable&&(0,a.jsx)("button",{onClick:()=>w(e.value,`${e.step}-${e.title}`),className:"shrink-0 px-3 py-2 bg-bg-secondary hover:bg-bg-tertiary rounded-lg border border-border transition-colors",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-lg",children:p===`${e.step}-${e.title}`?"check":"content_copy"})})]})]})]},e.step)),C()&&t.codeBlock&&(0,a.jsxs)("div",{className:"mt-2",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between mb-2",children:[(0,a.jsx)("span",{className:"text-xs text-text-muted uppercase tracking-wide",children:t.codeBlock.language}),(0,a.jsxs)("button",{onClick:()=>w(t.codeBlock.code,"codeblock"),className:"flex items-center gap-1 px-2 py-1 text-xs bg-bg-secondary hover:bg-bg-tertiary rounded border border-border transition-colors",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-sm",children:"codeblock"===p?"check":"content_copy"}),"codeblock"===p?"Copied!":"Copy"]})]}),(0,a.jsx)("pre",{className:"p-4 bg-bg-secondary rounded-lg border border-border overflow-x-auto",children:(0,a.jsx)("code",{className:"text-sm font-mono whitespace-pre",children:v(t.codeBlock.code)})})]})]}):(0,a.jsx)("p",{className:"text-text-muted text-sm",children:"Coming soon..."})}),(0,a.jsx)(l.rq,{isOpen:g,onClose:()=>f(!1),onSelect:e=>{b(e.value)},selectedModel:y,activeProviders:c,title:"Select Model"})]})}function p({tool:e,isExpanded:t,onToggle:s,baseUrl:n,apiKeys:o,activeProviders:d,cloudEnabled:c,initialStatus:x}){let m,[u,h]=(0,r.useState)(x||null),[g,f]=(0,r.useState)(!1),[y,b]=(0,r.useState)(!1),[j,N]=(0,r.useState)(!1),[v,w]=(0,r.useState)(null),[k,C]=(0,r.useState)(!1),[S,A]=(0,r.useState)(""),[_,E]=(0,r.useState)(""),[T,O]=(0,r.useState)(!1),[M,P]=(0,r.useState)({}),[$,I]=(0,r.useState)(!1),[R,D]=(0,r.useState)("");(0,r.useEffect)(()=>{o?.length>0&&!S&&A(o[0].key)},[o,S]),(0,r.useEffect)(()=>{x&&h(x)},[x]),(0,r.useEffect)(()=>{t&&!u&&(F(),U()),t&&U()},[t]),(0,r.useEffect)(()=>{u?.config?.model?.startsWith("9router/")&&E(u.config.model.replace("9router/",""))},[u]);let U=async()=>{try{let e=await fetch("/api/models/alias"),t=await e.json();e.ok&&P(t.aliases||{})}catch(e){console.log("Error fetching model aliases:",e)}},K=(()=>{if(!u?.installed)return null;if(!u.config)return"not_configured";let e=u.config?.provider?.["9router"]?.options?.baseURL||"",t=e.includes("localhost")||e.includes("127.0.0.1");return u.has9Router&&(t||e.includes(n))?"configured":u.has9Router?"other":"not_configured"})(),L=()=>{let e=R||n;return e.endsWith("/v1")?e:`${e}/v1`},F=async()=>{f(!0);try{let e=await fetch("/api/cli-tools/opencode-settings"),t=await e.json();h(t)}catch(e){h({installed:!1,error:e.message})}finally{f(!1)}},z=async()=>{b(!0),w(null);try{let e=S&&S.trim()||c?S:"sk_9router",t=await fetch("/api/cli-tools/opencode-settings",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({baseUrl:L(),apiKey:e,model:_})}),s=await t.json();t.ok?(w({type:"success",text:"Settings applied successfully!"}),F()):w({type:"error",text:s.error||"Failed to apply settings"})}catch(e){w({type:"error",text:e.message})}finally{b(!1)}},q=async()=>{N(!0),w(null);try{let e=await fetch("/api/cli-tools/opencode-settings",{method:"DELETE"}),t=await e.json();e.ok?(w({type:"success",text:"Settings reset successfully!"}),E(""),F()):w({type:"error",text:t.error||"Failed to reset settings"})}catch(e){w({type:"error",text:e.message})}finally{N(!1)}};return(0,a.jsxs)(l.Zp,{padding:"xs",className:"overflow-hidden",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between hover:cursor-pointer",onClick:s,children:[(0,a.jsxs)("div",{className:"flex items-center gap-3",children:[(0,a.jsx)("div",{className:"size-8 flex items-center justify-center shrink-0",children:(0,a.jsx)(i.default,{src:"/providers/opencode.png",alt:e.name,width:32,height:32,className:"size-8 object-contain rounded-lg",sizes:"32px",onError:e=>{e.target.style.display="none"}})}),(0,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("h3",{className:"font-medium text-sm",children:e.name}),"configured"===K&&(0,a.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"===K&&(0,a.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"===K&&(0,a.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,a.jsx)("p",{className:"text-xs text-text-muted truncate",children:e.description})]})]}),(0,a.jsx)("span",{className:`material-symbols-outlined text-text-muted text-[20px] transition-transform ${t?"rotate-180":""}`,children:"expand_more"})]}),t&&(0,a.jsxs)("div",{className:"mt-4 pt-4 border-t border-border flex flex-col gap-4",children:[g&&(0,a.jsxs)("div",{className:"flex items-center gap-2 text-text-muted",children:[(0,a.jsx)("span",{className:"material-symbols-outlined animate-spin",children:"progress_activity"}),(0,a.jsx)("span",{children:"Checking OpenCode CLI..."})]}),!g&&u&&!u.installed&&(0,a.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,a.jsxs)("div",{className:"flex items-center gap-3 p-4 bg-yellow-500/10 border border-yellow-500/30 rounded-lg",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-yellow-500",children:"warning"}),(0,a.jsxs)("div",{className:"flex-1",children:[(0,a.jsx)("p",{className:"font-medium text-yellow-600 dark:text-yellow-400",children:"OpenCode CLI not installed"}),(0,a.jsx)("p",{className:"text-sm text-text-muted",children:"Please install OpenCode CLI to use auto-apply feature."})]}),(0,a.jsxs)(l.$n,{variant:"outline",size:"sm",onClick:()=>C(!k),children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px] mr-1",children:k?"expand_less":"help"}),k?"Hide":"How to Install"]})]}),k&&(0,a.jsxs)("div",{className:"p-4 bg-surface border border-border rounded-lg",children:[(0,a.jsx)("h4",{className:"font-medium mb-3",children:"Installation Guide"}),(0,a.jsxs)("div",{className:"space-y-3 text-sm",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("p",{className:"text-text-muted mb-1",children:"macOS / Linux:"}),(0,a.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,a.jsxs)("p",{className:"text-text-muted",children:["After installation, run ",(0,a.jsx)("code",{className:"px-1 bg-black/5 dark:bg-white/5 rounded",children:"opencode"})," to verify."]})]})]})]}),!g&&u?.installed&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{className:"flex flex-col gap-2",children:[u?.config?.provider?.["9router"]?.options?.baseURL&&(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("span",{className:"w-32 shrink-0 text-sm font-semibold text-text-main text-right",children:"Current"}),(0,a.jsx)("span",{className:"material-symbols-outlined text-text-muted text-[14px]",children:"arrow_forward"}),(0,a.jsx)("span",{className:"flex-1 px-2 py-1.5 text-xs text-text-muted truncate",children:u.config.provider["9router"].options.baseURL})]}),(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("span",{className:"w-32 shrink-0 text-sm font-semibold text-text-main text-right",children:"Base URL"}),(0,a.jsx)("span",{className:"material-symbols-outlined text-text-muted text-[14px]",children:"arrow_forward"}),(0,a.jsx)("input",{type:"text",value:R||`${n}/v1`,onChange:e=>D(e.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"}),R&&R!==`${n}/v1`&&(0,a.jsx)("button",{onClick:()=>D(""),className:"p-1 text-text-muted hover:text-primary rounded transition-colors",title:"Reset to default",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"restart_alt"})})]}),(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("span",{className:"w-32 shrink-0 text-sm font-semibold text-text-main text-right",children:"API Key"}),(0,a.jsx)("span",{className:"material-symbols-outlined text-text-muted text-[14px]",children:"arrow_forward"}),o.length>0?(0,a.jsx)("select",{value:S,onChange:e=>A(e.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:o.map(e=>(0,a.jsx)("option",{value:e.key,children:e.key},e.id))}):(0,a.jsx)("span",{className:"flex-1 text-xs text-text-muted px-2 py-1.5",children:c?"No API keys - Create one in Keys page":"sk_9router (default)"})]}),(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("span",{className:"w-32 shrink-0 text-sm font-semibold text-text-main text-right",children:"Model"}),(0,a.jsx)("span",{className:"material-symbols-outlined text-text-muted text-[14px]",children:"arrow_forward"}),(0,a.jsx)("input",{type:"text",value:_,onChange:e=>E(e.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,a.jsx)("button",{onClick:()=>O(!0),disabled:!d?.length,className:`px-2 py-1.5 rounded border text-xs transition-colors shrink-0 whitespace-nowrap ${d?.length?"bg-surface border-border text-text-main hover:border-primary cursor-pointer":"opacity-50 cursor-not-allowed border-border"}`,children:"Select Model"}),_&&(0,a.jsx)("button",{onClick:()=>E(""),className:"p-1 text-text-muted hover:text-red-500 rounded transition-colors",title:"Clear",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"close"})})]})]}),v&&(0,a.jsxs)("div",{className:`flex items-center gap-2 px-2 py-1.5 rounded text-xs ${"success"===v.type?"bg-green-500/10 text-green-600":"bg-red-500/10 text-red-600"}`,children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"success"===v.type?"check_circle":"error"}),(0,a.jsx)("span",{children:v.text})]}),(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsxs)(l.$n,{variant:"primary",size:"sm",onClick:z,disabled:!_,loading:y,children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px] mr-1",children:"save"}),"Apply"]}),(0,a.jsxs)(l.$n,{variant:"outline",size:"sm",onClick:q,disabled:!u.has9Router,loading:j,children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px] mr-1",children:"restore"}),"Reset"]}),(0,a.jsxs)(l.$n,{variant:"ghost",size:"sm",onClick:()=>I(!0),children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px] mr-1",children:"content_copy"}),"Manual Config"]})]})]})]}),(0,a.jsx)(l.rq,{isOpen:T,onClose:()=>O(!1),onSelect:e=>{E(e.value),O(!1)},selectedModel:_,activeProviders:d,modelAliases:M,title:"Select Model for OpenCode"}),(0,a.jsx)(l.uR,{isOpen:$,onClose:()=>I(!1),title:"OpenCode - Manual Configuration",configs:(m=S&&S.trim()?S:c?"<API_KEY_FROM_DASHBOARD>":"sk_9router",[{filename:"~/.config/opencode/opencode.json",content:JSON.stringify({provider:{"9router":{npm:"@ai-sdk/openai-compatible",options:{baseURL:L(),apiKey:m},models:{[_||"provider/model-id"]:{name:_||"provider/model-id"}}}},model:`9router/${_||"provider/model-id"}`},null,2)}])})]})}let h="http://localhost:20128";function g({apiKeys:e,cloudEnabled:t,onStatusChange:s}){let[i,n]=(0,r.useState)(null),[o,d]=(0,r.useState)(!1),[c,x]=(0,r.useState)(!1),[m,u]=(0,r.useState)(""),[p,f]=(0,r.useState)(""),[y,b]=(0,r.useState)(null),[j,N]=(0,r.useState)(null),[v,w]=(0,r.useState)(null),[k,C]=(0,r.useState)(h),S="u">typeof navigator&&navigator.userAgent?.includes("Windows"),A=i?.isAdmin!==!1;(0,r.useEffect)(()=>{e?.length>0&&!p&&f(e[0].key)},[e,p]),(0,r.useEffect)(()=>{_()},[]);let _=async()=>{try{let e=await fetch("/api/cli-tools/antigravity-mitm");if(e.ok){let t=await e.json();n(t),t.mitmRouterBaseUrl&&C(t.mitmRouterBaseUrl),s?.(t)}}catch{n({running:!1,certExists:!1,dnsStatus:{}})}},E=e=>{S||i?.hasCachedPassword?T(e,""):(b(e),x(!0),N(null))},T=async(s,a)=>{d(!0),w(null);try{let r;if("trust-cert"===s)r=await fetch("/api/cli-tools/antigravity-mitm",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"trust-cert",sudoPassword:a})});else if("start"===s){let s=p?.trim()||(e?.length>0?e[0].key:null)||(t?null:"sk_9router");r=await fetch("/api/cli-tools/antigravity-mitm",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({apiKey:s,sudoPassword:a,mitmRouterBaseUrl:k.trim()||h})})}else r=await fetch("/api/cli-tools/antigravity-mitm",{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({sudoPassword:a})});let l=await r.json().catch(()=>({}));if(!r.ok)throw Error(l.error||"MITM action failed");x(!1),u(""),N(null),await _()}catch(t){let e=t?.message||"MITM action failed";w(e),c&&N(e)}finally{d(!1),b(null)}},O=()=>{m?T(y,m):N("Sudo password is required")},M=i?.running;return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(l.Zp,{padding:"sm",className:"border-primary/20 bg-primary/5",children:(0,a.jsxs)("div",{className:"flex flex-col gap-3",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-primary text-[20px]",children:"security"}),(0,a.jsx)("span",{className:"font-semibold text-sm text-text-main",children:"MITM Server"}),M?(0,a.jsx)(l.Ex,{variant:"success",size:"sm",children:"Running"}):(0,a.jsx)(l.Ex,{variant:"default",size:"sm",children:"Stopped"})]}),(0,a.jsx)("div",{className:"flex items-center gap-1 text-xs text-text-muted","data-i18n-skip":"true",children:[{label:"Cert",ok:i?.certExists},{label:"Trusted",ok:i?.certTrusted},{label:"Server",ok:M}].map(({label:e,ok:t})=>(0,a.jsxs)("span",{className:`flex items-center gap-0.5 px-1.5 py-0.5 rounded ${t?"text-green-600":"text-text-muted"}`,children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[12px]",children:t?"check_circle":"cancel"}),e]},e))})]}),(0,a.jsxs)("div",{className:"px-2 py-2 rounded-lg bg-surface/50 border border-border/50 flex flex-col gap-2",children:[(0,a.jsxs)("p",{className:"text-[11px] text-text-muted leading-relaxed",children:[(0,a.jsx)("span",{className:"font-medium text-text-main",children:"Purpose:"})," Use Antigravity IDE & GitHub Copilot → with ANY provider/model from 9Router"]}),(0,a.jsxs)("p",{className:"text-[11px] text-text-muted leading-relaxed",children:[(0,a.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,a.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("span",{className:"w-32 shrink-0 text-sm font-semibold text-text-main text-right",children:"9Router Base URL"}),(0,a.jsx)("span",{className:"material-symbols-outlined text-text-muted text-[14px]",children:"arrow_forward"}),(0,a.jsx)("input",{type:"text",value:k,onChange:e=>C(e.target.value),placeholder:h,disabled:M,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"})]}),!M&&(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("span",{className:"w-32 shrink-0 text-sm font-semibold text-text-main text-right",children:"API Key"}),(0,a.jsx)("span",{className:"material-symbols-outlined text-text-muted text-[14px]",children:"arrow_forward"}),e?.length>0?(0,a.jsx)("select",{value:p,onChange:e=>f(e.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:e.map(e=>(0,a.jsx)("option",{value:e.key,children:e.key},e.id))}):(0,a.jsx)("span",{className:"flex-1 px-2 py-1.5 text-xs text-text-muted",children:t?"No API keys — create one in Keys page":"sk_9router (default)"})]})]}),(0,a.jsxs)("div",{className:"flex items-center gap-2 flex-wrap","data-i18n-skip":"true",children:[i?.certExists&&!i?.certTrusted&&(0,a.jsxs)("button",{onClick:()=>E("trust-cert"),disabled:o,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,a.jsx)("span",{className:"material-symbols-outlined text-[16px]",children:"verified_user"}),"Trust Cert"]}),M?(0,a.jsxs)("button",{onClick:()=>E("stop"),disabled:o,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,a.jsx)("span",{className:"material-symbols-outlined text-[16px]",children:"stop_circle"}),"Stop Server"]}):(0,a.jsxs)("button",{onClick:()=>E("start"),disabled:o||S&&!A,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,a.jsx)("span",{className:"material-symbols-outlined text-[16px]",children:"play_circle"}),"Start Server"]}),M&&(0,a.jsx)("p",{className:"text-xs text-text-muted",children:"Enable DNS per tool below to activate interception"})]}),v&&(0,a.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,a.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"error"}),(0,a.jsx)("span",{children:v})]}),S&&!A&&(0,a.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,a.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"shield_lock"}),(0,a.jsx)("span",{children:"Administrator required — restart 9Router as Administrator to use MITM"})]})]})}),c&&(0,a.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50 backdrop-blur-sm",children:(0,a.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,a.jsx)("h3",{className:"font-semibold text-text-main",children:"Sudo Password Required"}),(0,a.jsxs)("div",{className:"flex items-start gap-3 p-3 bg-yellow-500/10 border border-yellow-500/30 rounded-lg",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-yellow-500 text-[20px]",children:"warning"}),(0,a.jsx)("p",{className:"text-xs text-text-muted",children:"Required for SSL certificate and server startup"})]}),(0,a.jsx)(l.pd,{type:"password",placeholder:"Enter sudo password",value:m,onChange:e=>u(e.target.value),onKeyDown:e=>{"Enter"!==e.key||o||O()}}),j&&(0,a.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,a.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"error"}),(0,a.jsx)("span",{children:j})]}),(0,a.jsxs)("div",{className:"flex items-center justify-end gap-2",children:[(0,a.jsx)(l.$n,{variant:"ghost",size:"sm",onClick:()=>{x(!1),u(""),N(null)},disabled:o,children:"Cancel"}),(0,a.jsx)(l.$n,{variant:"primary",size:"sm",onClick:O,loading:o,children:"Confirm"})]})]})})]})}function f({tool:e,isExpanded:t,onToggle:s,serverRunning:n,dnsActive:o,hasCachedPassword:d,apiKeys:c,activeProviders:x,hasActiveProviders:m,modelAliases:u={},cloudEnabled:p,onDnsChange:h,tokenSwapActive:g=!1}){let[b,j]=(0,r.useState)(!1),[N,v]=(0,r.useState)(null),[w,k]=(0,r.useState)(null),[C,S]=(0,r.useState)(!1),[A,_]=(0,r.useState)(""),[E,T]=(0,r.useState)(null),[O,M]=(0,r.useState)(null),[P,$]=(0,r.useState)({}),[I,R]=(0,r.useState)(!1),[D,U]=(0,r.useState)(null),K="u">typeof navigator&&navigator.userAgent?.includes("Windows"),L=(0,r.useCallback)(async()=>{try{let t=await fetch(`/api/cli-tools/antigravity-mitm/alias?tool=${e.id}`);if(t.ok){let e=await t.json();Object.keys(e.aliases||{}).length>0&&$(e.aliases)}}catch{}},[e.id]);(0,r.useEffect)(()=>{t&&L()},[t,L]);let F=(0,r.useCallback)(async t=>{try{await fetch("/api/cli-tools/antigravity-mitm/alias",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({tool:e.id,mappings:t})})}catch{}},[e.id]),z=(e,t)=>{$(s=>({...s,[e]:t}))},q=()=>{if(!n)return;let e=o?"disable":"enable";K||d?H(e,""):(T(e),S(!0),M(null))},H=async(t,s)=>{j(!0),v(null),k(null);try{let a=await fetch("/api/cli-tools/antigravity-mitm",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({tool:e.id,action:t,sudoPassword:s})}),r=await a.json().catch(()=>({}));if(!a.ok)throw Error(r.error||`Failed to ${t} DNS`);"enable"===t&&v(`Restart ${e.name} to apply changes`),S(!1),_(""),h?.(r)}catch(e){k(e.message||`Failed to ${t} DNS`)}finally{j(!1),T(null)}},B=()=>{A?H(E,A):M("Sudo password is required")};return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)(l.Zp,{padding:"xs",className:"overflow-hidden",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between hover:cursor-pointer",onClick:s,children:[(0,a.jsxs)("div",{className:"flex items-center gap-3",children:[(0,a.jsx)("div",{className:"size-8 flex items-center justify-center shrink-0",children:(0,a.jsx)(i.default,{src:e.image,alt:e.name,width:32,height:32,className:"size-8 object-contain rounded-lg",sizes:"32px",onError:e=>{e.target.style.display="none"}})}),(0,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("h3",{className:"font-medium text-sm",children:e.name}),e.supportsTokenSwap&&(0,a.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"}),n?g?(0,a.jsx)(l.Ex,{variant:"default",size:"sm",children:"Bypassed"}):o?(0,a.jsx)(l.Ex,{variant:"success",size:"sm",children:"Active"}):(0,a.jsx)(l.Ex,{variant:"warning",size:"sm",children:"DNS off"}):(0,a.jsx)(l.Ex,{variant:"default",size:"sm",children:"Server off"})]}),(0,a.jsx)("p",{className:"text-xs text-text-muted",children:"Model routing — remap model IDs in intercepted requests"})]})]}),(0,a.jsx)("span",{className:`material-symbols-outlined text-text-muted text-[20px] transition-transform ${t?"rotate-180":""}`,children:"expand_more"})]}),t&&(0,a.jsxs)("div",{className:"mt-4 pt-4 border-t border-border flex flex-col gap-4",children:[g&&(0,a.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,a.jsx)("span",{className:"material-symbols-outlined text-[14px] text-violet-400 mt-0.5 shrink-0",children:"info"}),(0,a.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"===e.id&&(0,a.jsx)(y,{}),(0,a.jsxs)("div",{className:"flex flex-col gap-0.5 text-[11px] text-text-muted px-1",children:[(0,a.jsxs)("p",{children:["Toggle DNS to redirect ",e.name," traffic through 9Router via MITM."]}),!o&&(0,a.jsx)("p",{className:"text-amber-600 text-[10px] mt-1",children:"⚠️ Enable DNS to edit model mappings"})]}),e.defaultModels?.length>0&&(0,a.jsx)("div",{className:"flex flex-col gap-2",children:e.defaultModels.map(e=>(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("span",{className:"w-36 shrink-0 text-xs font-semibold text-text-main text-right",children:e.name}),(0,a.jsx)("span",{className:"material-symbols-outlined text-text-muted text-[14px]",children:"arrow_forward"}),(0,a.jsx)("input",{type:"text",value:P[e.alias]||"",onChange:t=>z(e.alias,t.target.value),onBlur:t=>{var s,a;return s=e.alias,a=t.target.value,void F({...P,[s]:a})},placeholder:"provider/model-id",disabled:!o,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?"opacity-50 cursor-not-allowed":""}`}),(0,a.jsx)("button",{onClick:()=>{U(e.alias),R(!0)},disabled:!m||!o,className:`px-2 py-1.5 rounded border text-xs transition-colors shrink-0 ${m&&o?"bg-surface border-border hover:border-primary cursor-pointer":"opacity-50 cursor-not-allowed border-border"}`,children:"Select"}),P[e.alias]&&(0,a.jsx)("button",{onClick:()=>{z(e.alias,""),F({...P,[e.alias]:""})},className:"p-1 text-text-muted hover:text-red-500 rounded transition-colors",title:"Clear",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"close"})})]},e.alias))}),e.defaultModels?.length===0&&(0,a.jsx)("p",{className:"text-xs text-text-muted px-1",children:"Model mappings will be available soon."}),(0,a.jsxs)("div",{className:"flex flex-col gap-2 items-start",children:[o?(0,a.jsxs)("button",{onClick:q,disabled:!n||b,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,a.jsx)("span",{className:"material-symbols-outlined text-[16px]",children:"stop_circle"}),"Stop DNS"]}):(0,a.jsxs)("button",{onClick:q,disabled:!n||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 disabled:cursor-not-allowed",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[16px]",children:"play_circle"}),"Start DNS"]}),N&&(0,a.jsxs)("div",{className:"flex items-center gap-2 px-2 py-1.5 rounded text-xs text-amber-500",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"warning"}),(0,a.jsx)("span",{children:N})]}),w&&(0,a.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,a.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"error"}),(0,a.jsx)("span",{children:w})]})]})]})]}),C&&(0,a.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50 backdrop-blur-sm",children:(0,a.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,a.jsx)("h3",{className:"font-semibold text-text-main",children:"Sudo Password Required"}),(0,a.jsxs)("div",{className:"flex items-start gap-3 p-3 bg-yellow-500/10 border border-yellow-500/30 rounded-lg",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-yellow-500 text-[20px]",children:"warning"}),(0,a.jsx)("p",{className:"text-xs text-text-muted",children:"Required to modify /etc/hosts and flush DNS cache"})]}),(0,a.jsx)(l.pd,{type:"password",placeholder:"Enter sudo password",value:A,onChange:e=>_(e.target.value),onKeyDown:e=>{"Enter"!==e.key||b||B()}}),O&&(0,a.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,a.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"error"}),(0,a.jsx)("span",{children:O})]}),(0,a.jsxs)("div",{className:"flex items-center justify-end gap-2",children:[(0,a.jsx)(l.$n,{variant:"ghost",size:"sm",onClick:()=>{S(!1),_(""),M(null)},disabled:b,children:"Cancel"}),(0,a.jsx)(l.$n,{variant:"primary",size:"sm",onClick:B,loading:b,children:"Confirm"})]})]})}),(0,a.jsx)(l.rq,{isOpen:I,onClose:()=>R(!1),onSelect:e=>{if(!D||e.isPlaceholder)return;let t={...P,[D]:e.value};$(t),F(t)},selectedModel:D?P[D]:null,activeProviders:x,modelAliases:u,title:`Select model for ${D}`})]})}function y(){let[e,t]=(0,r.useState)(null),[s,l]=(0,r.useState)(!1),[i,n]=(0,r.useState)(null),o=(0,r.useCallback)(async()=>{try{let e=await fetch("/api/antigravity-ide");e.ok&&t(await e.json())}catch{}},[]);(0,r.useEffect)(()=>{let e=!0;return(async()=>{try{let s=await fetch("/api/antigravity-ide");s.ok&&e&&t(await s.json())}catch{}})(),()=>{e=!1}},[]);let d=async()=>{l(!0),n(null);try{let e=await fetch("/api/antigravity-ide",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"close"})}),t=await e.json();n(t),setTimeout(o,1e3)}catch(e){n({success:!1,error:e.message})}l(!1)};return(0,a.jsxs)("div",{className:"flex items-center gap-2 px-1",children:[(0,a.jsxs)("button",{onClick:d,disabled:s||!e?.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:e?.running?"Close all Antigravity IDE processes":"Antigravity IDE is not running",children:[(0,a.jsx)("span",{className:`material-symbols-outlined text-[14px] ${s?"animate-spin":""}`,children:s?"progress_activity":"close"}),s?"Closing…":"Close IDE"]}),e&&(0,a.jsxs)("span",{className:"flex items-center gap-1 text-[10px] text-text-muted",children:[(0,a.jsx)("span",{className:`inline-block w-1.5 h-1.5 rounded-full ${!e.installed?"bg-gray-400":e.running?"bg-green-500":"bg-red-400"}`}),e.installed?e.running?"Running":"Stopped":"Not installed"]}),i&&!s&&(0,a.jsxs)("span",{className:`text-[10px] ${i.success?"text-green-500":"text-red-400"}`,children:[i.success?"✓":"✗"," ",i.message||i.error]})]})}var b=s(98500),j=s.n(b);function N(e){if(null==e)return null;let t=String(e).trim();if(!t)return null;let s=t.toLowerCase();return s.includes("ultra")?"Ultra":s.includes("pro")?"Pro":s.includes("free")?"Free":null}["Free","Pro","Ultra"].map(e=>({value:e,label:e}));var v=s(57294);function w(e){if(!e||"string"!=typeof e)return e;let t=e.indexOf("@");if(t<=0||t===e.length-1)return e;let s=e.slice(0,t),a=e.slice(t+1);return 1===s.length?`${s[0]}**@${a}`:2===s.length?`${s[0]}**${s[1]}@${a}`:`${s[0]}**${s[s.length-1]}@${a}`}function k({tool:e,connections:t=[],serverRunning:s,dnsActive:i,onToggle:n,onRefreshConnections:o}){let[d,c]=(0,r.useState)(!1),[x,m]=(0,r.useState)(!1),[u,p]=(0,r.useState)("round-robin"),[h,g]=(0,r.useState)(!1),[f,y]=(0,r.useState)(!1),[b,C]=(0,r.useState)(!1),[S,A]=(0,r.useState)(null),[_,E]=(0,r.useState)(null),[T,O]=(0,r.useState)(!1),[M,P]=(0,r.useState)({}),$=(0,r.useRef)({}),I=(0,r.useCallback)(async()=>{try{let e=await fetch("/api/settings");if(e.ok){let t=await e.json();c(!!t.tokenSwapEnabled),p(t.tokenSwapStrategy||"round-robin"),y(!!t.tokenSwapMaskEmails)}}catch{}},[]);(0,r.useEffect)(()=>{I()},[I]);let R=(0,r.useCallback)(async(t,s=!1)=>{if(!t||0===t.length)return;let a=Date.now(),r=[],l={};if(t.forEach(e=>{let t=$.current[e.id];!s&&t&&a-t.ts<12e4?l[e.id]={quotas:t.data,error:t.error,loading:!1,accountType:t.accountType||null}:r.push(e)}),Object.keys(l).length>0&&P(e=>({...e,...l})),0===r.length)return;let i={};r.forEach(e=>{i[e.id]={quotas:[],error:null,loading:!0}}),P(e=>({...e,...i})),await Promise.all(r.map(async t=>{try{let s=await fetch(`/api/usage/${t.id}`);if(!s.ok){let e=(await s.json().catch(()=>({}))).error||`HTTP ${s.status}`;$.current[t.id]={data:[],error:e,ts:Date.now(),accountType:null},P(s=>({...s,[t.id]:{quotas:[],error:e,loading:!1,accountType:null}}));return}let a=await s.json(),r=(0,v.W_)(e.tokenSwapProvider||"antigravity",a),l=function(e){if(!e)return null;if("string"==typeof e)return N(e);for(let t of[e.accountType,e.plan,e.paidTier?.name,e.subscriptionTier,e.subscription_tier,e.currentTier?.name,e.subscriptionInfo?.paidTier?.name,e.quota?.subscription_tier,e.subscriptionInfo?.currentTier?.name]){let e=N(t);if(e)return e}return null}(a);$.current[t.id]={data:r,error:null,ts:Date.now(),accountType:l},P(e=>({...e,[t.id]:{quotas:r,error:null,loading:!1,accountType:l}}))}catch(s){let e=s.message||"Failed";$.current[t.id]={data:[],error:e,ts:Date.now(),accountType:null},P(s=>({...s,[t.id]:{quotas:[],error:e,loading:!1,accountType:null}}))}}))},[e.tokenSwapProvider]);if(!e?.supportsTokenSwap)return null;let D=async()=>{m(!0);let e=!d;try{(await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({tokenSwapEnabled:e})})).ok&&(c(e),n?.(e))}catch{}m(!1)},U=async e=>{if(e!==u&&!h){g(!0);try{(await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({tokenSwapStrategy:e})})).ok&&p(e)}catch{}g(!1)}},K=async()=>{if(b)return;C(!0);let e=!f;try{(await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({tokenSwapMaskEmails:e})})).ok&&y(e)}catch{}C(!1)},L=t.filter(t=>t.provider===e.tokenSwapProvider),F=L.filter(e=>!1!==e.isActive),z=F.length,q=F.map(e=>e.id).join("|"),H=function(e,t){if(!e||0===e.length)return null;if(1===e.length)return e[0].id;let s=[...e].sort((e,t)=>e.lastUsedAt||t.lastUsedAt?e.lastUsedAt?t.lastUsedAt?new Date(t.lastUsedAt)-new Date(e.lastUsedAt):-1:1:(e.priority||999)-(t.priority||999));if("sticky"===t)return s[0]?.id||null;let a=[...e].sort((e,t)=>e.lastUsedAt||t.lastUsedAt?e.lastUsedAt?t.lastUsedAt?new Date(e.lastUsedAt)-new Date(t.lastUsedAt):1:-1:(e.priority||999)-(t.priority||999));return a[0]?.id||null}(F,u);(0,r.useEffect)(()=>{d&&z>0&&R(F)},[d,z,q,R]);let B=s&&i,J=d&&B&&z>0,W=async(e,t)=>{if(e&&!S&&!T&&!_){A(e);try{(await fetch(`/api/providers/${e}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({isActive:t})})).ok&&await o?.()}catch{}A(null)}},G=async e=>{if(e&&!_&&!T&&!S){E(e);try{(await fetch(`/api/providers/${e}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({lastUsedAt:null})})).ok&&await o?.()}catch{}E(null)}},Z=async()=>{if(!T&&!_&&!S&&0!==L.length){O(!0);try{await Promise.all(L.map(e=>fetch(`/api/providers/${e.id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({lastUsedAt:null})}))),await o?.()}catch{}O(!1)}};return(0,a.jsxs)(l.Zp,{padding:"xs",className:"overflow-hidden",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between",children:[(0,a.jsxs)("div",{className:"flex items-center gap-3",children:[(0,a.jsx)("div",{className:"size-8 flex items-center justify-center shrink-0 rounded-lg bg-violet-500/10",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-violet-400 text-[18px]",children:"swap_horiz"})}),(0,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("h3",{className:"font-medium text-sm",children:"Token Rotation"}),(0,a.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"}),J?(0,a.jsx)(l.Ex,{variant:"success",size:"sm",children:"Active"}):d?(0,a.jsx)(l.Ex,{variant:"warning",size:"sm",children:"Enabled"}):(0,a.jsx)(l.Ex,{variant:"default",size:"sm",children:"Off"})]}),(0,a.jsx)("p",{className:"text-xs text-text-muted",children:"Rotate auth tokens across pool accounts to bypass per-account quota"})]})]}),(0,a.jsx)("button",{onClick:D,disabled:x,className:`relative inline-flex h-5 w-9 items-center rounded-full transition-colors shrink-0 ${d?"bg-violet-500":"bg-surface-alt border border-border"} ${x?"opacity-50":"cursor-pointer"}`,title:d?"Disable Token Rotation":"Enable Token Rotation",children:(0,a.jsx)("span",{className:`inline-block h-3.5 w-3.5 transform rounded-full bg-white transition-transform shadow-sm ${d?"translate-x-4":"translate-x-0.5"}`})})]}),d&&(0,a.jsxs)("div",{className:"mt-3 pt-3 border-t border-border/50 flex flex-col gap-3",children:[(0,a.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,a.jsx)("span",{className:"material-symbols-outlined text-[14px] text-violet-400 mt-0.5 shrink-0",children:"info"}),(0,a.jsxs)("div",{className:"text-[11px] text-text-muted leading-relaxed",children:[(0,a.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,a.jsx)("p",{className:"mt-1 text-violet-400/80 font-medium",children:"⚠ When active, Model Routing (Mode A) is bypassed."})]})]}),(0,a.jsxs)("div",{className:"flex flex-col gap-1.5 px-1",children:[(0,a.jsx)("p",{className:"text-[10px] uppercase tracking-wider text-text-muted font-semibold",children:"Rotation Strategy"}),(0,a.jsxs)("div",{className:"flex gap-1.5",children:[(0,a.jsxs)("button",{onClick:()=>U("round-robin"),disabled:h,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"===u?"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,a.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"autorenew"}),"Round Robin"]}),(0,a.jsxs)("button",{onClick:()=>U("sticky"),disabled:h,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"===u?"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,a.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"push_pin"}),"Sticky"]})]}),(0,a.jsx)("p",{className:"text-[10px] text-text-muted px-0.5",children:"sticky"===u?"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,a.jsxs)("div",{className:"flex flex-col gap-1 px-1",children:[(0,a.jsx)("p",{className:"text-[10px] uppercase tracking-wider text-text-muted font-semibold mb-0.5",children:"Prerequisites"}),(0,a.jsxs)("div",{className:"flex items-center gap-2 text-xs",children:[(0,a.jsx)("span",{className:`material-symbols-outlined text-[14px] ${s?"text-green-500":"text-red-400"}`,children:s?"check_circle":"cancel"}),(0,a.jsx)("span",{className:s?"text-text-main":"text-text-muted",children:"MITM Server"})]}),(0,a.jsxs)("div",{className:"flex items-center gap-2 text-xs",children:[(0,a.jsx)("span",{className:`material-symbols-outlined text-[14px] ${i?"text-green-500":"text-red-400"}`,children:i?"check_circle":"cancel"}),(0,a.jsxs)("span",{className:i?"text-text-main":"text-text-muted",children:["DNS redirect",!i&&(0,a.jsx)("span",{className:"text-[10px] text-text-muted ml-1",children:"— enable via Antigravity card above"})]})]})]}),(0,a.jsxs)("div",{className:"flex flex-col gap-1 px-1",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between mb-0.5",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("p",{className:"text-[10px] uppercase tracking-wider text-text-muted font-semibold",children:"Pool Accounts"}),(0,a.jsx)("span",{className:"text-[10px] text-text-muted",children:L.length>0?`${z}/${L.length} active`:"none"}),z>1&&(0,a.jsx)("span",{className:"text-[9px] text-text-muted bg-surface border border-border px-1 py-0.5 rounded",children:"round-robin"})]}),(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[z>0&&(0,a.jsx)("button",{onClick:()=>R(F,!0),className:"text-[10px] text-text-muted hover:text-primary flex items-center gap-0.5 transition-colors",title:"Refresh quotas",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[12px]",children:"refresh"})}),"round-robin"===u&&L.length>0&&(0,a.jsxs)("button",{onClick:Z,disabled:T||!!_,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,a.jsx)("span",{className:"material-symbols-outlined text-[12px]",children:"restart_alt"}),"Reset order"]})]})]}),(0,a.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,a.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,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsx)("p",{className:"text-[11px] font-medium text-text-main",children:"Mask account emails"}),(0,a.jsxs)("p",{className:"text-[10px] text-text-muted",children:["Hide pool account emails in token swap logs and this panel. Example: ",w("email@gmail.com")]})]}),(0,a.jsx)("button",{onClick:K,disabled:b,className:`relative inline-flex h-5 w-9 items-center rounded-full transition-colors shrink-0 ${f?"bg-violet-500":"bg-surface border border-border"} ${b?"opacity-50":"cursor-pointer"}`,title:f?"Disable email masking":"Enable email masking",children:(0,a.jsx)("span",{className:`inline-block h-3.5 w-3.5 transform rounded-full bg-white transition-transform shadow-sm ${f?"translate-x-4":"translate-x-0.5"}`})})]}),L.length>0?(0,a.jsxs)(a.Fragment,{children:[L.map(e=>{let t=N(M[e.id]?.accountType)||N(e.accountType)||null;return(0,a.jsxs)("div",{className:`rounded-xl border border-border bg-surface-alt/30 px-3 py-2.5 transition-colors ${!1===e.isActive?"opacity-65":"hover:bg-surface-alt/50"}`,children:[(0,a.jsxs)("div",{className:"flex items-start justify-between gap-3",children:[(0,a.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2 min-w-0",children:[(0,a.jsx)("span",{className:`material-symbols-outlined text-[14px] shrink-0 ${!1===e.isActive?"text-text-muted":"text-green-500"}`,children:!1===e.isActive?"pause_circle":"check_circle"}),(0,a.jsx)("span",{className:"text-xs font-medium text-text-main truncate",children:e.email?f?w(e.email):e.email:e.name||e.id.slice(0,16)}),t&&(0,a.jsx)(l.Ex,{variant:"Ultra"===t?"warning":"Pro"===t?"primary":"Free"===t?"info":"default",size:"sm",children:t}),H===e.id&&!1!==e.isActive&&(0,a.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,a.jsx)(l.Ex,{variant:!1===e.isActive?"default":"success",size:"sm",children:!1===e.isActive?"disabled":"active"})]}),(0,a.jsxs)("div",{className:"mt-1 flex items-center gap-2 flex-wrap text-[10px] text-text-muted",children:[(0,a.jsxs)("span",{children:["Priority #",e.priority??"-"]}),e.lastUsedAt&&(0,a.jsxs)("span",{children:["Last used ",new Date(e.lastUsedAt).toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit"})]})]})]}),(0,a.jsxs)("div",{className:"flex items-center gap-3 shrink-0",children:["round-robin"===u&&(0,a.jsxs)("button",{onClick:()=>G(e.id),disabled:T||S===e.id||_===e.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,a.jsx)("span",{className:"material-symbols-outlined text-[12px]",children:"restart_alt"}),_===e.id?"...":"Reset Order"]}),(0,a.jsx)(l.lM,{size:"sm",checked:!1!==e.isActive,disabled:T||_===e.id||S===e.id,onChange:t=>W(e.id,t)})]})]}),(0,a.jsx)("div",{className:"mt-2 pl-6",children:!1===e.isActive?(0,a.jsx)("div",{className:"text-[10px] text-text-muted",children:"Enable this account to include it in token rotation and load quota reset info."}):(e=>{let t=(e=>{let t=M[e];if(!t)return{state:"empty"};if(t.loading)return{state:"loading"};if(t.error)return{state:"error",error:t.error};if(!t.quotas||0===t.quotas.length)return{state:"no-data"};let s=t.quotas.find(e=>e.modelKey?.includes("claude-sonnet-4-6")||e.name?.toLowerCase().includes("opus"))||t.quotas[0];if(!s)return{state:"no-data"};let a=void 0!==s.remainingPercentage?Math.round(s.remainingPercentage):s.total>0?Math.round((s.total-s.used)/s.total*100):null,r=(s.resetAt&&new Date(s.resetAt).getTime()>Date.now()?s.resetAt:null)||[...t.quotas].map(e=>e.resetAt).filter(Boolean).filter(e=>new Date(e).getTime()>Date.now()).sort((e,t)=>new Date(e).getTime()-new Date(t).getTime())[0]||null;return{state:null===a?"no-data":"ready",highlight:s,accountType:t.accountType||null,pct:a,nextResetAt:r,resetCountdown:(0,v.mO)(r),resetDisplay:(0,v.sQ)(r)}})(e);if(!t||"empty"===t.state)return(0,a.jsx)("span",{className:"text-[10px] text-text-muted",children:"Enable to load quota data"});if("loading"===t.state)return(0,a.jsx)("span",{className:"text-[10px] text-text-muted animate-pulse",children:"Loading quota…"});if("error"===t.state)return(0,a.jsx)("span",{className:"text-[10px] text-red-400",title:t.error,children:"Quota unavailable"});if("no-data"===t.state)return(0,a.jsx)("span",{className:"text-[10px] text-text-muted",children:"No quota data"});let{highlight:s,pct:r,resetCountdown:l,resetDisplay:i}=t;return(0,a.jsxs)("div",{className:"flex flex-col gap-1.5 min-w-0",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2 min-w-0",children:[(0,a.jsx)("span",{className:"text-[10px] text-text-muted truncate",children:s.name}),(0,a.jsx)("div",{className:"flex-1 h-1.5 rounded-full bg-surface-alt overflow-hidden min-w-[56px]",children:(0,a.jsx)("div",{className:`h-full rounded-full ${r>70?"bg-green-500":r>=30?"bg-yellow-500":"bg-red-500"}`,style:{width:`${Math.min(r,100)}%`}})}),(0,a.jsxs)("span",{className:`text-[10px] font-medium shrink-0 ${r>70?"text-green-500":r>=30?"text-yellow-500":"text-red-500"}`,children:[r,"%"]})]}),"-"!==l&&i?(0,a.jsxs)("div",{className:"text-[10px] text-text-muted",children:["Reset in ",(0,a.jsx)("span",{className:"text-text-main",children:l}),(0,a.jsxs)("span",{className:"text-text-muted/70",children:[" • ",i]})]}):(0,a.jsx)("div",{className:"text-[10px] text-text-muted",children:"Reset time unavailable"})]})})(e.id)})]},e.id)}),(0,a.jsxs)(j(),{href:"/dashboard/providers",className:"text-[11px] text-primary hover:underline flex items-center gap-1 px-1 mt-1",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[12px]",children:"open_in_new"}),"Manage accounts"]})]}):(0,a.jsx)("div",{className:"px-1",children:(0,a.jsxs)("p",{className:"text-xs text-text-muted",children:["No active ",e.name," accounts in pool."," ",(0,a.jsx)(j(),{href:"/dashboard/providers",className:"text-primary hover:underline",children:"Add account →"})]})})]}),!B&&(0,a.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,a.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"warning"}),(0,a.jsx)("span",{children:"Start MITM server and enable DNS to activate token rotation"})]})]})]})}},3534:(e,t,s)=>{s.d(t,{dM:()=>r,wn:()=>a});let a={antigravity:{id:"antigravity",name:"Antigravity",image:"/providers/antigravity.png",color:"#4285F4",description:"Google Antigravity IDE with MITM",configType:"mitm",mitmDomain:"daily-cloudcode-pa.googleapis.com",supportsTokenSwap:!0,tokenSwapProvider:"antigravity",modelAliases:["claude-opus-4-6-thinking","claude-sonnet-4-6","gemini-3-flash","gpt-oss-120b-medium","gemini-3-pro-high","gemini-3-pro-low"],defaultModels:[{id:"gemini-3.1-pro-high",name:"Gemini 3.1 Pro High",alias:"gemini-3.1-pro-high"},{id:"gemini-3.1-pro-low",name:"Gemini 3.1 Pro Low",alias:"gemini-3.1-pro-low"},{id:"gemini-3-flash",name:"Gemini 3 Flash",alias:"gemini-3-flash"},{id:"claude-sonnet-4-6",name:"Claude Sonnet 4.6",alias:"claude-sonnet-4-6"},{id:"claude-opus-4-6-thinking",name:"Claude Opus 4.6 Thinking",alias:"claude-opus-4-6-thinking"},{id:"gpt-oss-120b-medium",name:"GPT OSS 120B Medium",alias:"gpt-oss-120b-medium"}]},copilot:{id:"copilot",name:"GitHub Copilot",image:"/providers/copilot.png",color:"#1F6FEB",description:"GitHub Copilot IDE with MITM",configType:"mitm",mitmDomain:"api.individual.githubcopilot.com",modelAliases:["gpt-4o-mini","claude-haiku-4.5","gpt-4o","gpt-5-mini"],defaultModels:[{id:"gpt-4o",name:"GPT-4o",alias:"gpt-4o"},{id:"gpt-4.1",name:"GPT-4.1",alias:"gpt-4.1"},{id:"claude-haiku-4.5",name:"Claude Haiku 4.5",alias:"claude-haiku-4.5"}]},kiro:{id:"kiro",name:"Kiro",image:"/providers/kiro.png",color:"#FF6B00",description:"Kiro IDE with MITM",configType:"mitm",mitmDomain:"q.us-east-1.amazonaws.com",defaultModels:[{id:"claude-sonnet-4.5",name:"Claude Sonnet 4.5",alias:"claude-sonnet-4.5"},{id:"claude-sonnet-4",name:"Claude Sonnet 4",alias:"claude-sonnet-4"},{id:"claude-haiku-4.5",name:"Claude Haiku 4.5",alias:"claude-haiku-4.5"},{id:"deepseek-3.2",name:"DeepSeek 3.2",alias:"deepseek-3.2"},{id:"minimax-m2.1",name:"MiniMax M2.1",alias:"minimax-m2.1"},{id:"simple-task",name:"Qwen3 Coder Next",alias:"simple-task"}]}},r={claude:{id:"claude",name:"Claude Code",icon:"terminal",color:"#D97757",description:"Anthropic Claude Code CLI",configType:"env",envVars:{baseUrl:"ANTHROPIC_BASE_URL",model:"ANTHROPIC_MODEL",opusModel:"ANTHROPIC_DEFAULT_OPUS_MODEL",sonnetModel:"ANTHROPIC_DEFAULT_SONNET_MODEL",haikuModel:"ANTHROPIC_DEFAULT_HAIKU_MODEL"},modelAliases:["default","sonnet","opus","haiku","opusplan"],settingsFile:"~/.claude/settings.json",defaultModels:[{id:"opus",name:"Claude Opus",alias:"opus",envKey:"ANTHROPIC_DEFAULT_OPUS_MODEL",defaultValue:"cc/claude-opus-4-6"},{id:"sonnet",name:"Claude Sonnet",alias:"sonnet",envKey:"ANTHROPIC_DEFAULT_SONNET_MODEL",defaultValue:"cc/claude-sonnet-4-6"},{id:"haiku",name:"Claude Haiku",alias:"haiku",envKey:"ANTHROPIC_DEFAULT_HAIKU_MODEL",defaultValue:"cc/claude-haiku-4-5-20251001"}]},openclaw:{id:"openclaw",name:"Open Claw",image:"/providers/openclaw.png",color:"#FF6B35",description:"Open Claw AI Assistant",configType:"custom"},codex:{id:"codex",name:"OpenAI Codex CLI",image:"/providers/codex.png",color:"#10A37F",description:"OpenAI Codex CLI",configType:"custom"},opencode:{id:"opencode",name:"OpenCode",image:"/providers/opencode.png",color:"#E87040",description:"OpenCode AI Terminal Assistant",configType:"custom"},droid:{id:"droid",name:"Factory Droid",image:"/providers/droid.png",color:"#00D4FF",description:"Factory Droid AI Assistant",configType:"custom"},cursor:{id:"cursor",name:"Cursor",image:"/providers/cursor.png",color:"#000000",description:"Cursor AI Code Editor",configType:"guide",requiresExternalUrl:!0,notes:[{type:"warning",text:"Requires Cursor Pro account to use this feature."},{type:"cloudCheck",text:"Cursor routes requests through its own server, so local endpoint is not supported. Please enable Tunnel or Cloud Endpoint in Settings."}],guideSteps:[{step:1,title:"Open Settings",desc:"Go to Settings → Models"},{step:2,title:"Enable OpenAI API",desc:'Enable "OpenAI API key" option'},{step:3,title:"Base URL",value:"{{baseUrl}}",copyable:!0},{step:4,title:"API Key",type:"apiKeySelector"},{step:5,title:"Add Custom Model",desc:'Click "View All Model" → "Add Custom Model"'},{step:6,title:"Select Model",type:"modelSelector"}]},cline:{id:"cline",name:"Cline",image:"/providers/cline.png",color:"#00D1B2",description:"Cline AI Coding Assistant",configType:"guide",guideSteps:[{step:1,title:"Open Settings",desc:"Go to Cline Settings panel"},{step:2,title:"Select Provider",desc:"Choose API Provider → OpenAI Compatible"},{step:3,title:"Base URL",value:"{{baseUrl}}/v1",copyable:!0},{step:4,title:"API Key",type:"apiKeySelector"},{step:5,title:"Select Model",type:"modelSelector"}]},kilo:{id:"kilo",name:"Kilo Code",image:"/providers/kilocode.png",color:"#FF6B6B",description:"Kilo Code AI Assistant",configType:"guide",guideSteps:[{step:1,title:"Open Settings",desc:"Go to Kilo Code Settings panel"},{step:2,title:"Select Provider",desc:"Choose API Provider → OpenAI Compatible"},{step:3,title:"Base URL",value:"{{baseUrl}}/v1",copyable:!0},{step:4,title:"API Key",type:"apiKeySelector"},{step:5,title:"Select Model",type:"modelSelector"}]},roo:{id:"roo",name:"Roo",image:"/providers/roo.png",color:"#FF6B6B",description:"Roo AI Assistant",configType:"guide",guideSteps:[{step:1,title:"Open Settings",desc:"Go to Roo Settings panel"},{step:2,title:"Select Provider",desc:"Choose API Provider → Ollama"},{step:3,title:"Base URL",value:"{{baseUrl}}",copyable:!0},{step:4,title:"API Key",type:"apiKeySelector"},{step:5,title:"Select Model",type:"modelSelector"}]},continue:{id:"continue",name:"Continue",image:"/providers/continue.png",color:"#7C3AED",description:"Continue AI Assistant",configType:"guide",guideSteps:[{step:1,title:"Open Config",desc:"Open Continue configuration file"},{step:2,title:"API Key",type:"apiKeySelector"},{step:3,title:"Select Model",type:"modelSelector"},{step:4,title:"Add Model Config",desc:"Add the following configuration to your models array:"}],codeBlock:{language:"json",code:`{
|
|
10
10
|
"apiBase": "{{baseUrl}}",
|
|
11
11
|
"title": "{{model}}",
|
|
12
12
|
"model": "{{model}}",
|