@sifxprime/krouter 0.5.145 → 0.5.147
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/README.md +4 -4
- package/app/.next-cli-build/BUILD_ID +1 -1
- package/app/.next-cli-build/app-path-routes-manifest.json +12 -12
- package/app/.next-cli-build/build-manifest.json +2 -2
- package/app/.next-cli-build/prerender-manifest.json +19 -19
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/basic-chat/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/cli-tools/[toolId]/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/cli-tools/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/combos/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/console-log/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/endpoint/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/environment/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/media-providers/[kind]/[id]/page.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/media-providers/[kind]/[id]/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/media-providers/[kind]/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/media-providers/combo/[id]/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/media-providers/web/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/mitm/page.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/mitm/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/presidio/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/profile/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/providers/[id]/page.js +2 -2
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/providers/[id]/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/providers/new/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/providers/page.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/providers/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/proxy-pools/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/pxpipe/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/quota/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/skills/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/token-saver/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/translator/page.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/translator/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/usage/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/_global-error/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/_global-error.html +1 -1
- package/app/.next-cli-build/server/app/_global-error.rsc +1 -1
- package/app/.next-cli-build/server/app/_global-error.segments/_full.segment.rsc +1 -1
- package/app/.next-cli-build/server/app/_global-error.segments/_global-error/__PAGE__.segment.rsc +1 -1
- package/app/.next-cli-build/server/app/_global-error.segments/_tree.segment.rsc +1 -1
- package/app/.next-cli-build/server/app/_not-found/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/_not-found.html +1 -1
- package/app/.next-cli-build/server/app/_not-found.rsc +4 -4
- package/app/.next-cli-build/server/app/_not-found.segments/_full.segment.rsc +4 -4
- package/app/.next-cli-build/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +4 -4
- package/app/.next-cli-build/server/app/_not-found.segments/_tree.segment.rsc +2 -2
- package/app/.next-cli-build/server/app/api/cli-tools/all-statuses/route.js +1 -1
- package/app/.next-cli-build/server/app/api/cli-tools/antigravity-mitm/route.js +1 -1
- package/app/.next-cli-build/server/app/api/cli-tools/kilo-settings/route.js +1 -1
- package/app/.next-cli-build/server/app/api/import/route.js +1 -1
- package/app/.next-cli-build/server/app/api/models/route.js +1 -1
- package/app/.next-cli-build/server/app/api/providers/route.js +1 -1
- package/app/.next-cli-build/server/app/api/providers/validate/route.js +1 -1
- package/app/.next-cli-build/server/app/api/pxpipe/health/route.js +2 -2
- package/app/.next-cli-build/server/app/api/pxpipe/install/route.js +2 -2
- package/app/.next-cli-build/server/app/api/pxpipe/restart/route.js +2 -2
- package/app/.next-cli-build/server/app/api/pxpipe/start/route.js +2 -2
- package/app/.next-cli-build/server/app/api/pxpipe/stats/route.js +2 -2
- package/app/.next-cli-build/server/app/api/pxpipe/status/route.js +2 -2
- package/app/.next-cli-build/server/app/api/pxpipe/stop/route.js +2 -2
- package/app/.next-cli-build/server/app/api/settings/environment/route.js +1 -1
- package/app/.next-cli-build/server/app/api/settings/presidio/route.js +1 -1
- package/app/.next-cli-build/server/app/api/translator/console-logs/route.js +1 -1
- package/app/.next-cli-build/server/app/api/translator/console-logs/stream/route.js +1 -1
- package/app/.next-cli-build/server/app/api/tunnel/enable/route.js +1 -1
- package/app/.next-cli-build/server/app/api/tunnel/tailscale-enable/route.js +1 -1
- package/app/.next-cli-build/server/app/api/version/route.js +1 -1
- package/app/.next-cli-build/server/app/api/version/shutdown/route.js +1 -1
- package/app/.next-cli-build/server/app/api/version/update/route.js +1 -1
- package/app/.next-cli-build/server/app/callback/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/callback.html +1 -1
- package/app/.next-cli-build/server/app/callback.rsc +4 -4
- package/app/.next-cli-build/server/app/callback.segments/_full.segment.rsc +4 -4
- package/app/.next-cli-build/server/app/callback.segments/_tree.segment.rsc +2 -2
- package/app/.next-cli-build/server/app/callback.segments/callback/__PAGE__.segment.rsc +4 -4
- package/app/.next-cli-build/server/app/dashboard/basic-chat.html +1 -1
- package/app/.next-cli-build/server/app/dashboard/basic-chat.rsc +6 -6
- package/app/.next-cli-build/server/app/dashboard/basic-chat.segments/!KGRhc2hib2FyZCk/dashboard/basic-chat/__PAGE__.segment.rsc +6 -6
- package/app/.next-cli-build/server/app/dashboard/basic-chat.segments/_full.segment.rsc +6 -6
- package/app/.next-cli-build/server/app/dashboard/basic-chat.segments/_tree.segment.rsc +2 -2
- package/app/.next-cli-build/server/app/dashboard/cli-tools.html +1 -1
- package/app/.next-cli-build/server/app/dashboard/cli-tools.rsc +6 -6
- package/app/.next-cli-build/server/app/dashboard/cli-tools.segments/!KGRhc2hib2FyZCk/dashboard/cli-tools/__PAGE__.segment.rsc +6 -6
- package/app/.next-cli-build/server/app/dashboard/cli-tools.segments/_full.segment.rsc +6 -6
- package/app/.next-cli-build/server/app/dashboard/cli-tools.segments/_tree.segment.rsc +2 -2
- package/app/.next-cli-build/server/app/dashboard/combos.html +1 -1
- package/app/.next-cli-build/server/app/dashboard/combos.rsc +6 -6
- package/app/.next-cli-build/server/app/dashboard/combos.segments/!KGRhc2hib2FyZCk/dashboard/combos/__PAGE__.segment.rsc +6 -6
- package/app/.next-cli-build/server/app/dashboard/combos.segments/_full.segment.rsc +6 -6
- package/app/.next-cli-build/server/app/dashboard/combos.segments/_tree.segment.rsc +2 -2
- package/app/.next-cli-build/server/app/dashboard/endpoint.html +1 -1
- package/app/.next-cli-build/server/app/dashboard/endpoint.rsc +6 -6
- package/app/.next-cli-build/server/app/dashboard/endpoint.segments/!KGRhc2hib2FyZCk/dashboard/endpoint/__PAGE__.segment.rsc +6 -6
- package/app/.next-cli-build/server/app/dashboard/endpoint.segments/_full.segment.rsc +6 -6
- package/app/.next-cli-build/server/app/dashboard/endpoint.segments/_tree.segment.rsc +2 -2
- package/app/.next-cli-build/server/app/dashboard/environment.html +1 -1
- package/app/.next-cli-build/server/app/dashboard/environment.rsc +6 -6
- package/app/.next-cli-build/server/app/dashboard/environment.segments/!KGRhc2hib2FyZCk/dashboard/environment/__PAGE__.segment.rsc +6 -6
- package/app/.next-cli-build/server/app/dashboard/environment.segments/_full.segment.rsc +6 -6
- package/app/.next-cli-build/server/app/dashboard/environment.segments/_tree.segment.rsc +2 -2
- package/app/.next-cli-build/server/app/dashboard/media-providers/web.html +1 -1
- package/app/.next-cli-build/server/app/dashboard/media-providers/web.rsc +6 -6
- package/app/.next-cli-build/server/app/dashboard/media-providers/web.segments/!KGRhc2hib2FyZCk/dashboard/media-providers/web/__PAGE__.segment.rsc +6 -6
- package/app/.next-cli-build/server/app/dashboard/media-providers/web.segments/_full.segment.rsc +6 -6
- package/app/.next-cli-build/server/app/dashboard/media-providers/web.segments/_tree.segment.rsc +2 -2
- package/app/.next-cli-build/server/app/dashboard/mitm.html +1 -1
- package/app/.next-cli-build/server/app/dashboard/mitm.rsc +6 -6
- package/app/.next-cli-build/server/app/dashboard/mitm.segments/!KGRhc2hib2FyZCk/dashboard/mitm/__PAGE__.segment.rsc +6 -6
- package/app/.next-cli-build/server/app/dashboard/mitm.segments/_full.segment.rsc +6 -6
- package/app/.next-cli-build/server/app/dashboard/mitm.segments/_tree.segment.rsc +2 -2
- package/app/.next-cli-build/server/app/dashboard/presidio.html +1 -1
- package/app/.next-cli-build/server/app/dashboard/presidio.rsc +6 -6
- package/app/.next-cli-build/server/app/dashboard/presidio.segments/!KGRhc2hib2FyZCk/dashboard/presidio/__PAGE__.segment.rsc +6 -6
- package/app/.next-cli-build/server/app/dashboard/presidio.segments/_full.segment.rsc +6 -6
- package/app/.next-cli-build/server/app/dashboard/presidio.segments/_tree.segment.rsc +2 -2
- package/app/.next-cli-build/server/app/dashboard/profile.html +1 -1
- package/app/.next-cli-build/server/app/dashboard/profile.rsc +6 -6
- package/app/.next-cli-build/server/app/dashboard/profile.segments/!KGRhc2hib2FyZCk/dashboard/profile/__PAGE__.segment.rsc +6 -6
- package/app/.next-cli-build/server/app/dashboard/profile.segments/_full.segment.rsc +6 -6
- package/app/.next-cli-build/server/app/dashboard/profile.segments/_tree.segment.rsc +2 -2
- package/app/.next-cli-build/server/app/dashboard/providers/new.html +1 -1
- package/app/.next-cli-build/server/app/dashboard/providers/new.rsc +6 -6
- package/app/.next-cli-build/server/app/dashboard/providers/new.segments/!KGRhc2hib2FyZCk/dashboard/providers/new/__PAGE__.segment.rsc +6 -6
- package/app/.next-cli-build/server/app/dashboard/providers/new.segments/_full.segment.rsc +6 -6
- package/app/.next-cli-build/server/app/dashboard/providers/new.segments/_tree.segment.rsc +2 -2
- package/app/.next-cli-build/server/app/dashboard/providers.html +1 -1
- package/app/.next-cli-build/server/app/dashboard/providers.rsc +6 -6
- package/app/.next-cli-build/server/app/dashboard/providers.segments/!KGRhc2hib2FyZCk/dashboard/providers/__PAGE__.segment.rsc +6 -6
- package/app/.next-cli-build/server/app/dashboard/providers.segments/_full.segment.rsc +6 -6
- package/app/.next-cli-build/server/app/dashboard/providers.segments/_tree.segment.rsc +2 -2
- package/app/.next-cli-build/server/app/dashboard/proxy-pools.html +1 -1
- package/app/.next-cli-build/server/app/dashboard/proxy-pools.rsc +6 -6
- package/app/.next-cli-build/server/app/dashboard/proxy-pools.segments/!KGRhc2hib2FyZCk/dashboard/proxy-pools/__PAGE__.segment.rsc +6 -6
- package/app/.next-cli-build/server/app/dashboard/proxy-pools.segments/_full.segment.rsc +6 -6
- package/app/.next-cli-build/server/app/dashboard/proxy-pools.segments/_tree.segment.rsc +2 -2
- package/app/.next-cli-build/server/app/dashboard/pxpipe.html +1 -1
- package/app/.next-cli-build/server/app/dashboard/pxpipe.rsc +6 -6
- package/app/.next-cli-build/server/app/dashboard/pxpipe.segments/!KGRhc2hib2FyZCk/dashboard/pxpipe/__PAGE__.segment.rsc +6 -6
- package/app/.next-cli-build/server/app/dashboard/pxpipe.segments/_full.segment.rsc +6 -6
- package/app/.next-cli-build/server/app/dashboard/pxpipe.segments/_tree.segment.rsc +2 -2
- package/app/.next-cli-build/server/app/dashboard/quota.html +2 -2
- package/app/.next-cli-build/server/app/dashboard/quota.rsc +7 -7
- package/app/.next-cli-build/server/app/dashboard/quota.segments/!KGRhc2hib2FyZCk/dashboard/quota/__PAGE__.segment.rsc +7 -7
- package/app/.next-cli-build/server/app/dashboard/quota.segments/_full.segment.rsc +7 -7
- package/app/.next-cli-build/server/app/dashboard/quota.segments/_tree.segment.rsc +2 -2
- package/app/.next-cli-build/server/app/dashboard/settings/pricing/page.js +1 -1
- package/app/.next-cli-build/server/app/dashboard/settings/pricing/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/dashboard/settings/pricing.html +1 -1
- package/app/.next-cli-build/server/app/dashboard/settings/pricing.rsc +5 -5
- package/app/.next-cli-build/server/app/dashboard/settings/pricing.segments/_full.segment.rsc +5 -5
- package/app/.next-cli-build/server/app/dashboard/settings/pricing.segments/_tree.segment.rsc +2 -2
- package/app/.next-cli-build/server/app/dashboard/settings/pricing.segments/dashboard/settings/pricing/__PAGE__.segment.rsc +5 -5
- package/app/.next-cli-build/server/app/dashboard/skills.html +1 -1
- package/app/.next-cli-build/server/app/dashboard/skills.rsc +6 -6
- package/app/.next-cli-build/server/app/dashboard/skills.segments/!KGRhc2hib2FyZCk/dashboard/skills/__PAGE__.segment.rsc +6 -6
- package/app/.next-cli-build/server/app/dashboard/skills.segments/_full.segment.rsc +6 -6
- package/app/.next-cli-build/server/app/dashboard/skills.segments/_tree.segment.rsc +2 -2
- package/app/.next-cli-build/server/app/dashboard/token-saver.html +1 -1
- package/app/.next-cli-build/server/app/dashboard/token-saver.rsc +6 -6
- package/app/.next-cli-build/server/app/dashboard/token-saver.segments/!KGRhc2hib2FyZCk/dashboard/token-saver/__PAGE__.segment.rsc +6 -6
- package/app/.next-cli-build/server/app/dashboard/token-saver.segments/_full.segment.rsc +6 -6
- package/app/.next-cli-build/server/app/dashboard/token-saver.segments/_tree.segment.rsc +2 -2
- package/app/.next-cli-build/server/app/dashboard/translator.html +1 -1
- package/app/.next-cli-build/server/app/dashboard/translator.rsc +6 -6
- package/app/.next-cli-build/server/app/dashboard/translator.segments/!KGRhc2hib2FyZCk/dashboard/translator/__PAGE__.segment.rsc +6 -6
- package/app/.next-cli-build/server/app/dashboard/translator.segments/_full.segment.rsc +6 -6
- package/app/.next-cli-build/server/app/dashboard/translator.segments/_tree.segment.rsc +2 -2
- package/app/.next-cli-build/server/app/dashboard/usage.html +1 -1
- package/app/.next-cli-build/server/app/dashboard/usage.rsc +6 -6
- package/app/.next-cli-build/server/app/dashboard/usage.segments/!KGRhc2hib2FyZCk/dashboard/usage/__PAGE__.segment.rsc +6 -6
- package/app/.next-cli-build/server/app/dashboard/usage.segments/_full.segment.rsc +6 -6
- package/app/.next-cli-build/server/app/dashboard/usage.segments/_tree.segment.rsc +2 -2
- package/app/.next-cli-build/server/app/dashboard.html +1 -1
- package/app/.next-cli-build/server/app/dashboard.rsc +6 -6
- package/app/.next-cli-build/server/app/dashboard.segments/!KGRhc2hib2FyZCk/dashboard/__PAGE__.segment.rsc +6 -6
- package/app/.next-cli-build/server/app/dashboard.segments/_full.segment.rsc +6 -6
- package/app/.next-cli-build/server/app/dashboard.segments/_tree.segment.rsc +2 -2
- package/app/.next-cli-build/server/app/index.html +1 -1
- package/app/.next-cli-build/server/app/index.rsc +4 -4
- package/app/.next-cli-build/server/app/index.segments/__PAGE__.segment.rsc +4 -4
- package/app/.next-cli-build/server/app/index.segments/_full.segment.rsc +4 -4
- package/app/.next-cli-build/server/app/index.segments/_tree.segment.rsc +2 -2
- package/app/.next-cli-build/server/app/landing/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/landing.html +1 -1
- package/app/.next-cli-build/server/app/landing.rsc +4 -4
- package/app/.next-cli-build/server/app/landing.segments/_full.segment.rsc +4 -4
- package/app/.next-cli-build/server/app/landing.segments/_tree.segment.rsc +2 -2
- package/app/.next-cli-build/server/app/landing.segments/landing/__PAGE__.segment.rsc +4 -4
- package/app/.next-cli-build/server/app/login/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/login.html +1 -1
- package/app/.next-cli-build/server/app/login.rsc +5 -5
- package/app/.next-cli-build/server/app/login.segments/_full.segment.rsc +5 -5
- package/app/.next-cli-build/server/app/login.segments/_tree.segment.rsc +2 -2
- package/app/.next-cli-build/server/app/login.segments/login/__PAGE__.segment.rsc +5 -5
- package/app/.next-cli-build/server/app/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app-paths-manifest.json +12 -12
- package/app/.next-cli-build/server/chunks/192.js +9 -0
- package/app/.next-cli-build/server/chunks/2365.js +1 -1
- package/app/.next-cli-build/server/chunks/2722.js +1 -1
- package/app/.next-cli-build/server/chunks/412.js +2 -2
- package/app/.next-cli-build/server/chunks/4884.js +2 -2
- package/app/.next-cli-build/server/chunks/523.js +1 -0
- package/app/.next-cli-build/server/chunks/5330.js +11 -11
- package/app/.next-cli-build/server/chunks/5718.js +1 -1
- package/app/.next-cli-build/server/chunks/6182.js +4 -4
- package/app/.next-cli-build/server/chunks/6200.js +2 -2
- package/app/.next-cli-build/server/chunks/706.js +4 -3
- package/app/.next-cli-build/server/chunks/7153.js +1 -1
- package/app/.next-cli-build/server/chunks/7276.js +1 -1
- package/app/.next-cli-build/server/chunks/7833.js +9 -0
- package/app/.next-cli-build/server/chunks/8238.js +1 -1
- package/app/.next-cli-build/server/chunks/8361.js +1 -1
- package/app/.next-cli-build/server/chunks/8782.js +1 -0
- package/app/.next-cli-build/server/chunks/8895.js +2 -2
- package/app/.next-cli-build/server/middleware-build-manifest.js +1 -1
- package/app/.next-cli-build/server/middleware.js +2 -2
- package/app/.next-cli-build/server/pages/404.html +1 -1
- package/app/.next-cli-build/server/pages/500.html +1 -1
- package/app/.next-cli-build/static/chunks/{1321-2a89b5e3ef834ad0.js → 1321-59a8def10db84b86.js} +1 -1
- package/app/.next-cli-build/static/chunks/5497-d4a2fb8d25696366.js +7 -0
- package/app/.next-cli-build/static/chunks/{6069-dd3d88032deffd6b.js → 6069-db27e074bc47d5fe.js} +1 -1
- package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/media-providers/[kind]/[id]/{page-783b478197298c31.js → page-1c13f46a5c077d38.js} +1 -1
- package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/mitm/page-81f0e1ae55f87925.js +1 -0
- package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/presidio/{page-ec483054834f55b3.js → page-99353b884e6df533.js} +4 -4
- package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/providers/[id]/{page-f52892e5e4b5f25b.js → page-b92667a32e2aeffa.js} +2 -2
- package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/providers/page-69f5c1cd75191fc4.js +1 -0
- package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/translator/{page-97596f6b0ed5c791.js → page-719a6bedc7b221df.js} +1 -1
- package/app/.next-cli-build/static/chunks/app/dashboard/settings/pricing/page-625fde09367a7c35.js +1 -0
- package/app/.next-cli-build/static/css/{8395659349879673.css → 8e737cade791a545.css} +1 -1
- package/app/cli/package.json +1 -1
- package/app/package.json +1 -1
- package/app/src/lib/db/backup.js +35 -0
- package/app/src/mitm/server.js +1 -1
- package/cli.js +211 -106
- package/package.json +1 -1
- package/src/cli/tray/tray.ps1 +38 -14
- package/src/cli/utils/input.js +13 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/basic-chat/page.js.nft.json +0 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/cli-tools/[toolId]/page.js.nft.json +0 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/cli-tools/page.js.nft.json +0 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/combos/page.js.nft.json +0 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/console-log/page.js.nft.json +0 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/endpoint/page.js.nft.json +0 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/environment/page.js.nft.json +0 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/media-providers/[kind]/[id]/page.js.nft.json +0 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/media-providers/[kind]/page.js.nft.json +0 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/media-providers/combo/[id]/page.js.nft.json +0 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/media-providers/web/page.js.nft.json +0 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/mitm/page.js.nft.json +0 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/page.js.nft.json +0 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/presidio/page.js.nft.json +0 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/profile/page.js.nft.json +0 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/providers/[id]/page.js.nft.json +0 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/providers/new/page.js.nft.json +0 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/providers/page.js.nft.json +0 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/proxy-pools/page.js.nft.json +0 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/pxpipe/page.js.nft.json +0 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/quota/page.js.nft.json +0 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/skills/page.js.nft.json +0 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/token-saver/page.js.nft.json +0 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/translator/page.js.nft.json +0 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/usage/page.js.nft.json +0 -1
- package/app/.next-cli-build/server/app/_global-error/page.js.nft.json +0 -1
- package/app/.next-cli-build/server/app/_not-found/page.js.nft.json +0 -1
- package/app/.next-cli-build/server/app/api/auth/login/route.js.nft.json +0 -1
- package/app/.next-cli-build/server/app/api/auth/logout/route.js.nft.json +0 -1
- package/app/.next-cli-build/server/app/api/auth/oidc/callback/route.js.nft.json +0 -1
- package/app/.next-cli-build/server/app/api/auth/oidc/start/route.js.nft.json +0 -1
- package/app/.next-cli-build/server/app/api/auth/oidc/test/route.js.nft.json +0 -1
- package/app/.next-cli-build/server/app/api/auth/reset-password/route.js.nft.json +0 -1
- package/app/.next-cli-build/server/app/api/auth/status/route.js.nft.json +0 -1
- package/app/.next-cli-build/server/app/api/cache/route.js.nft.json +0 -1
- package/app/.next-cli-build/server/app/api/cli-tools/all-statuses/route.js.nft.json +0 -1
- package/app/.next-cli-build/server/app/api/cli-tools/antigravity-mitm/alias/route.js.nft.json +0 -1
- package/app/.next-cli-build/server/app/api/cli-tools/antigravity-mitm/route.js.nft.json +0 -1
- package/app/.next-cli-build/server/app/api/cli-tools/claude-settings/route.js.nft.json +0 -1
- package/app/.next-cli-build/server/app/api/cli-tools/cline-settings/route.js.nft.json +0 -1
- package/app/.next-cli-build/server/app/api/cli-tools/codex-settings/route.js.nft.json +0 -1
- package/app/.next-cli-build/server/app/api/cli-tools/copilot-settings/route.js.nft.json +0 -1
- package/app/.next-cli-build/server/app/api/cli-tools/cowork-mcp-registry/route.js.nft.json +0 -1
- package/app/.next-cli-build/server/app/api/cli-tools/cowork-mcp-tools/route.js.nft.json +0 -1
- package/app/.next-cli-build/server/app/api/cli-tools/cowork-settings/route.js.nft.json +0 -1
- package/app/.next-cli-build/server/app/api/cli-tools/deepseek-tui-settings/route.js.nft.json +0 -1
- package/app/.next-cli-build/server/app/api/cli-tools/droid-settings/route.js.nft.json +0 -1
- package/app/.next-cli-build/server/app/api/cli-tools/hermes-settings/route.js.nft.json +0 -1
- package/app/.next-cli-build/server/app/api/cli-tools/jcode-settings/route.js.nft.json +0 -1
- package/app/.next-cli-build/server/app/api/cli-tools/kilo-settings/route.js.nft.json +0 -1
- package/app/.next-cli-build/server/app/api/cli-tools/openclaw-settings/route.js.nft.json +0 -1
- package/app/.next-cli-build/server/app/api/cli-tools/opencode-settings/route.js.nft.json +0 -1
- package/app/.next-cli-build/server/app/api/combos/[id]/route.js.nft.json +0 -1
- package/app/.next-cli-build/server/app/api/combos/route.js.nft.json +0 -1
- package/app/.next-cli-build/server/app/api/headroom/extras/route.js.nft.json +0 -1
- package/app/.next-cli-build/server/app/api/headroom/proxy/[...path]/route.js.nft.json +0 -1
- package/app/.next-cli-build/server/app/api/headroom/restart/route.js.nft.json +0 -1
- package/app/.next-cli-build/server/app/api/headroom/start/route.js.nft.json +0 -1
- package/app/.next-cli-build/server/app/api/headroom/status/route.js.nft.json +0 -1
- package/app/.next-cli-build/server/app/api/headroom/stop/route.js.nft.json +0 -1
- package/app/.next-cli-build/server/app/api/health/route.js.nft.json +0 -1
- package/app/.next-cli-build/server/app/api/import/route.js.nft.json +0 -1
- package/app/.next-cli-build/server/app/api/init/route.js.nft.json +0 -1
- package/app/.next-cli-build/server/app/api/keys/[id]/route.js.nft.json +0 -1
- package/app/.next-cli-build/server/app/api/keys/route.js.nft.json +0 -1
- package/app/.next-cli-build/server/app/api/locale/route.js.nft.json +0 -1
- package/app/.next-cli-build/server/app/api/mcp/[plugin]/message/route.js.nft.json +0 -1
- package/app/.next-cli-build/server/app/api/mcp/[plugin]/sse/route.js.nft.json +0 -1
- package/app/.next-cli-build/server/app/api/media-providers/tts/deepgram/voices/route.js.nft.json +0 -1
- package/app/.next-cli-build/server/app/api/media-providers/tts/elevenlabs/voices/route.js.nft.json +0 -1
- package/app/.next-cli-build/server/app/api/media-providers/tts/inworld/voices/route.js.nft.json +0 -1
- package/app/.next-cli-build/server/app/api/media-providers/tts/minimax/voices/route.js.nft.json +0 -1
- package/app/.next-cli-build/server/app/api/media-providers/tts/voices/route.js.nft.json +0 -1
- package/app/.next-cli-build/server/app/api/mitm/cert/route.js.nft.json +0 -1
- package/app/.next-cli-build/server/app/api/models/alias/route.js.nft.json +0 -1
- package/app/.next-cli-build/server/app/api/models/availability/route.js.nft.json +0 -1
- package/app/.next-cli-build/server/app/api/models/custom/route.js.nft.json +0 -1
- package/app/.next-cli-build/server/app/api/models/disabled/route.js.nft.json +0 -1
- package/app/.next-cli-build/server/app/api/models/live/route.js.nft.json +0 -1
- package/app/.next-cli-build/server/app/api/models/live-by-connection/route.js.nft.json +0 -1
- package/app/.next-cli-build/server/app/api/models/preview/route.js.nft.json +0 -1
- package/app/.next-cli-build/server/app/api/models/route.js.nft.json +0 -1
- package/app/.next-cli-build/server/app/api/models/test/route.js.nft.json +0 -1
- package/app/.next-cli-build/server/app/api/oauth/[provider]/[action]/route.js.nft.json +0 -1
- package/app/.next-cli-build/server/app/api/oauth/codex/bulk-import/route.js.nft.json +0 -1
- package/app/.next-cli-build/server/app/api/oauth/codex/import-token/route.js.nft.json +0 -1
- package/app/.next-cli-build/server/app/api/oauth/cursor/auto-import/route.js.nft.json +0 -1
- package/app/.next-cli-build/server/app/api/oauth/cursor/import/route.js.nft.json +0 -1
- package/app/.next-cli-build/server/app/api/oauth/gitlab/pat/route.js.nft.json +0 -1
- package/app/.next-cli-build/server/app/api/oauth/iflow/cookie/route.js.nft.json +0 -1
- package/app/.next-cli-build/server/app/api/oauth/kiro/api-key/route.js.nft.json +0 -1
- package/app/.next-cli-build/server/app/api/oauth/kiro/auto-import/route.js.nft.json +0 -1
- package/app/.next-cli-build/server/app/api/oauth/kiro/import/route.js.nft.json +0 -1
- package/app/.next-cli-build/server/app/api/oauth/kiro/social-authorize/route.js.nft.json +0 -1
- package/app/.next-cli-build/server/app/api/oauth/kiro/social-exchange/route.js.nft.json +0 -1
- package/app/.next-cli-build/server/app/api/pricing/route.js.nft.json +0 -1
- package/app/.next-cli-build/server/app/api/provider-nodes/[id]/route.js.nft.json +0 -1
- package/app/.next-cli-build/server/app/api/provider-nodes/route.js.nft.json +0 -1
- package/app/.next-cli-build/server/app/api/provider-nodes/validate/route.js.nft.json +0 -1
- package/app/.next-cli-build/server/app/api/providers/[id]/models/route.js.nft.json +0 -1
- package/app/.next-cli-build/server/app/api/providers/[id]/route.js.nft.json +0 -1
- package/app/.next-cli-build/server/app/api/providers/[id]/test/route.js.nft.json +0 -1
- package/app/.next-cli-build/server/app/api/providers/[id]/test-models/route.js.nft.json +0 -1
- package/app/.next-cli-build/server/app/api/providers/client/route.js.nft.json +0 -1
- package/app/.next-cli-build/server/app/api/providers/health/route.js.nft.json +0 -1
- package/app/.next-cli-build/server/app/api/providers/kilo/free-models/route.js.nft.json +0 -1
- package/app/.next-cli-build/server/app/api/providers/route.js.nft.json +0 -1
- package/app/.next-cli-build/server/app/api/providers/suggested-models/route.js.nft.json +0 -1
- package/app/.next-cli-build/server/app/api/providers/test-batch/route.js.nft.json +0 -1
- package/app/.next-cli-build/server/app/api/providers/validate/route.js.nft.json +0 -1
- package/app/.next-cli-build/server/app/api/providers/zenith/log/route.js.nft.json +0 -1
- package/app/.next-cli-build/server/app/api/providers/zenith/route.js.nft.json +0 -1
- package/app/.next-cli-build/server/app/api/proxy-pools/[id]/route.js.nft.json +0 -1
- package/app/.next-cli-build/server/app/api/proxy-pools/[id]/test/route.js.nft.json +0 -1
- package/app/.next-cli-build/server/app/api/proxy-pools/cloudflare-deploy/route.js.nft.json +0 -1
- package/app/.next-cli-build/server/app/api/proxy-pools/deno-deploy/route.js.nft.json +0 -1
- package/app/.next-cli-build/server/app/api/proxy-pools/route.js.nft.json +0 -1
- package/app/.next-cli-build/server/app/api/proxy-pools/vercel-deploy/route.js.nft.json +0 -1
- package/app/.next-cli-build/server/app/api/pxpipe/health/route.js.nft.json +0 -1
- package/app/.next-cli-build/server/app/api/pxpipe/install/route.js.nft.json +0 -1
- package/app/.next-cli-build/server/app/api/pxpipe/restart/route.js.nft.json +0 -1
- package/app/.next-cli-build/server/app/api/pxpipe/start/route.js.nft.json +0 -1
- package/app/.next-cli-build/server/app/api/pxpipe/stats/route.js.nft.json +0 -1
- package/app/.next-cli-build/server/app/api/pxpipe/status/route.js.nft.json +0 -1
- package/app/.next-cli-build/server/app/api/pxpipe/stop/route.js.nft.json +0 -1
- package/app/.next-cli-build/server/app/api/settings/database/route.js.nft.json +0 -1
- package/app/.next-cli-build/server/app/api/settings/environment/route.js.nft.json +0 -1
- package/app/.next-cli-build/server/app/api/settings/presidio/route.js.nft.json +0 -1
- package/app/.next-cli-build/server/app/api/settings/proxy-test/route.js.nft.json +0 -1
- package/app/.next-cli-build/server/app/api/settings/require-login/route.js.nft.json +0 -1
- package/app/.next-cli-build/server/app/api/settings/route.js.nft.json +0 -1
- package/app/.next-cli-build/server/app/api/shutdown/route.js.nft.json +0 -1
- package/app/.next-cli-build/server/app/api/tags/route.js.nft.json +0 -1
- package/app/.next-cli-build/server/app/api/translator/console-logs/route.js.nft.json +0 -1
- package/app/.next-cli-build/server/app/api/translator/console-logs/stream/route.js.nft.json +0 -1
- package/app/.next-cli-build/server/app/api/translator/load/route.js.nft.json +0 -1
- package/app/.next-cli-build/server/app/api/translator/save/route.js.nft.json +0 -1
- package/app/.next-cli-build/server/app/api/translator/send/route.js.nft.json +0 -1
- package/app/.next-cli-build/server/app/api/translator/translate/route.js.nft.json +0 -1
- package/app/.next-cli-build/server/app/api/tunnel/disable/route.js.nft.json +0 -1
- package/app/.next-cli-build/server/app/api/tunnel/enable/route.js.nft.json +0 -1
- package/app/.next-cli-build/server/app/api/tunnel/status/route.js.nft.json +0 -1
- package/app/.next-cli-build/server/app/api/tunnel/tailscale-check/route.js.nft.json +0 -1
- package/app/.next-cli-build/server/app/api/tunnel/tailscale-disable/route.js.nft.json +0 -1
- package/app/.next-cli-build/server/app/api/tunnel/tailscale-enable/route.js.nft.json +0 -1
- package/app/.next-cli-build/server/app/api/tunnel/tailscale-install/route.js.nft.json +0 -1
- package/app/.next-cli-build/server/app/api/usage/[connectionId]/route.js.nft.json +0 -1
- package/app/.next-cli-build/server/app/api/usage/chart/route.js.nft.json +0 -1
- package/app/.next-cli-build/server/app/api/usage/history/route.js.nft.json +0 -1
- package/app/.next-cli-build/server/app/api/usage/providers/route.js.nft.json +0 -1
- package/app/.next-cli-build/server/app/api/usage/request-details/route.js.nft.json +0 -1
- package/app/.next-cli-build/server/app/api/usage/request-logs/route.js.nft.json +0 -1
- package/app/.next-cli-build/server/app/api/usage/stats/route.js.nft.json +0 -1
- package/app/.next-cli-build/server/app/api/usage/stream/route.js.nft.json +0 -1
- package/app/.next-cli-build/server/app/api/v1/api/chat/route.js.nft.json +0 -1
- package/app/.next-cli-build/server/app/api/v1/audio/speech/route.js.nft.json +0 -1
- package/app/.next-cli-build/server/app/api/v1/audio/transcriptions/route.js.nft.json +0 -1
- package/app/.next-cli-build/server/app/api/v1/audio/voices/route.js.nft.json +0 -1
- package/app/.next-cli-build/server/app/api/v1/chat/completions/route.js.nft.json +0 -1
- package/app/.next-cli-build/server/app/api/v1/embeddings/route.js.nft.json +0 -1
- package/app/.next-cli-build/server/app/api/v1/images/generations/route.js.nft.json +0 -1
- package/app/.next-cli-build/server/app/api/v1/messages/count_tokens/route.js.nft.json +0 -1
- package/app/.next-cli-build/server/app/api/v1/messages/route.js.nft.json +0 -1
- package/app/.next-cli-build/server/app/api/v1/models/[kind]/route.js.nft.json +0 -1
- package/app/.next-cli-build/server/app/api/v1/models/info/route.js.nft.json +0 -1
- package/app/.next-cli-build/server/app/api/v1/models/route.js.nft.json +0 -1
- package/app/.next-cli-build/server/app/api/v1/responses/compact/route.js.nft.json +0 -1
- package/app/.next-cli-build/server/app/api/v1/responses/route.js.nft.json +0 -1
- package/app/.next-cli-build/server/app/api/v1/route.js.nft.json +0 -1
- package/app/.next-cli-build/server/app/api/v1/search/route.js.nft.json +0 -1
- package/app/.next-cli-build/server/app/api/v1/videos/[id]/route.js.nft.json +0 -1
- package/app/.next-cli-build/server/app/api/v1/videos/edits/route.js.nft.json +0 -1
- package/app/.next-cli-build/server/app/api/v1/videos/extensions/route.js.nft.json +0 -1
- package/app/.next-cli-build/server/app/api/v1/videos/generations/route.js.nft.json +0 -1
- package/app/.next-cli-build/server/app/api/v1/web/fetch/route.js.nft.json +0 -1
- package/app/.next-cli-build/server/app/api/v1beta/models/[...path]/route.js.nft.json +0 -1
- package/app/.next-cli-build/server/app/api/v1beta/models/route.js.nft.json +0 -1
- package/app/.next-cli-build/server/app/api/version/route.js.nft.json +0 -1
- package/app/.next-cli-build/server/app/api/version/shutdown/route.js.nft.json +0 -1
- package/app/.next-cli-build/server/app/api/version/update/route.js.nft.json +0 -1
- package/app/.next-cli-build/server/app/callback/page.js.nft.json +0 -1
- package/app/.next-cli-build/server/app/dashboard/settings/pricing/page.js.nft.json +0 -1
- package/app/.next-cli-build/server/app/favicon.ico/route.js.nft.json +0 -1
- package/app/.next-cli-build/server/app/landing/page.js.nft.json +0 -1
- package/app/.next-cli-build/server/app/login/page.js.nft.json +0 -1
- package/app/.next-cli-build/server/app/manifest.webmanifest/route.js.nft.json +0 -1
- package/app/.next-cli-build/server/app/page.js.nft.json +0 -1
- package/app/.next-cli-build/server/chunks/4055.js +0 -9
- package/app/.next-cli-build/server/chunks/5217.js +0 -9
- package/app/.next-cli-build/static/chunks/5497-4e4fd7c69a4beed2.js +0 -7
- package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/mitm/page-6c89f0a1ddd99c41.js +0 -1
- package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/providers/page-64fc5c6c998f5551.js +0 -1
- package/app/.next-cli-build/static/chunks/app/dashboard/settings/pricing/page-016fc417daafa8c4.js +0 -1
- package/app/cli/.build-home/.krouter/db/backups/upgrade-0.5.116-to-0.5.117-0.5.117-20260718-032541/data.sqlite +0 -0
- package/app/cli/.build-home/.krouter/db/backups/upgrade-0.5.117-to-0.5.118-0.5.118-20260718-064958/data.sqlite +0 -0
- package/app/cli/.build-home/.krouter/db/backups/upgrade-0.5.118-to-0.5.143-0.5.143-20260822-000036/data.sqlite +0 -0
- package/app/cli/.build-home/.krouter/db/backups/upgrade-0.5.143-to-0.5.144-0.5.144-20260823-041706/data.sqlite +0 -0
- package/app/cli/.build-home/.krouter/db/data.sqlite +0 -0
- package/app/cli/.build-home/.krouter/jwt-secret +0 -1
- package/app/cli/.build-home/.krouter/machine-id +0 -1
- package/app/cli/.build-home/Library/Preferences/nextjs-nodejs/config.json +0 -7
- /package/app/.next-cli-build/static/{6R5ug8WrSzU_3DNeV0Nhi → hKWRNoH4_Oex2Thy4DZQc}/_buildManifest.js +0 -0
- /package/app/.next-cli-build/static/{6R5ug8WrSzU_3DNeV0Nhi → hKWRNoH4_Oex2Thy4DZQc}/_ssgManifest.js +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[2134],{76487:(e,t,s)=>{Promise.resolve().then(s.bind(s,77241))},77241:(e,t,s)=>{"use strict";s.r(t),s.d(t,{default:()=>z});var a=s(95155),i=s(12115),l=s(73321),r=s(98500),n=s.n(r),o=s(5772),d=s(35497),c=s(52679),m=s(28777),p=s(11059),x=s(73006);let u=new Map;async function h(e){if(!e?.url||!e?.type)return[];let t=u.get(e.url);if(t&&Date.now()<t.expiresAt)return t.data;try{let t=new URLSearchParams({url:e.url,type:e.type}),s=await fetch(`/api/providers/suggested-models?${t}`);if(!s.ok)return[];let a=(await s.json()).data??[];return u.set(e.url,{data:a,expiresAt:Date.now()+6e5}),a}catch{return[]}}var f=s(14051),g=s.n(f);function b({model:e,fullModel:t,alias:s,copied:i,onCopy:l,testStatus:r,isCustom:n,isFree:o,onDeleteAlias:d,onTest:c,isTesting:m,onDisable:p}){let x="ok"===r?"#22c55e":"error"===r?"#ef4444":void 0;return(0,a.jsx)("div",{className:`group min-w-0 max-w-full rounded-lg border px-3 py-2 ${"ok"===r?"border-green-500/40":"error"===r?"border-red-500/40":"border-border"} hover:bg-sidebar/50`,children:(0,a.jsxs)("div",{className:"flex min-w-0 items-start gap-2 sm:items-center",children:[(0,a.jsx)("span",{className:"material-symbols-outlined shrink-0 text-base",style:x?{color:x}:void 0,children:"ok"===r?"check_circle":"error"===r?"cancel":"smart_toy"}),(0,a.jsxs)("div",{className:"flex min-w-0 flex-1 flex-col gap-1",children:[(0,a.jsx)("code",{className:"max-w-[72vw] truncate rounded bg-sidebar px-1.5 py-0.5 font-mono text-xs text-text-muted sm:max-w-[360px]",children:t}),e.name&&(0,a.jsx)("span",{className:"truncate pl-1 text-[9px] italic text-text-muted/70",children:e.name})]}),c&&(0,a.jsxs)("div",{className:"relative shrink-0 group/btn",children:[(0,a.jsx)("button",{onClick:c,disabled:m,className:`rounded p-0.5 text-text-muted transition-opacity hover:bg-sidebar hover:text-primary ${m?"opacity-100":"opacity-100 sm:opacity-0 sm:group-hover:opacity-100"}`,children:(0,a.jsx)("span",{className:"material-symbols-outlined text-sm",style:m?{animation:"spin 1s linear infinite"}:void 0,children:m?"progress_activity":"science"})}),(0,a.jsx)("span",{className:"pointer-events-none absolute mt-1 top-5 left-1/2 -translate-x-1/2 text-[10px] text-text-muted whitespace-nowrap opacity-0 group-hover/btn:opacity-100 transition-opacity",children:m?"Testing...":"Test"})]}),(0,a.jsxs)("div",{className:"relative shrink-0 group/btn",children:[(0,a.jsx)("button",{onClick:()=>l(t,`model-${e.id}`),className:"rounded p-0.5 text-text-muted hover:bg-sidebar hover:text-primary",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-sm",children:i===`model-${e.id}`?"check":"content_copy"})}),(0,a.jsx)("span",{className:"pointer-events-none absolute mt-1 top-5 left-1/2 -translate-x-1/2 text-[10px] text-text-muted whitespace-nowrap opacity-0 group-hover/btn:opacity-100 transition-opacity",children:i===`model-${e.id}`?"Copied!":"Copy"})]}),n?(0,a.jsx)("button",{onClick:d,className:"ml-auto rounded p-0.5 text-text-muted opacity-100 transition-opacity hover:bg-red-500/10 hover:text-red-500 sm:opacity-0 sm:group-hover:opacity-100",title:"Remove custom model",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-sm",children:"close"})}):p?(0,a.jsx)("button",{onClick:p,className:"ml-auto rounded p-0.5 text-text-muted opacity-100 transition-opacity hover:bg-red-500/10 hover:text-red-500 sm:opacity-0 sm:group-hover:opacity-100",title:"Disable this model",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-sm",children:"close"})}):null]})})}function y({modelId:e,fullModel:t,copied:s,onCopy:i,onDeleteAlias:l,onTest:r,testStatus:n,isTesting:o}){let d="ok"===n?"#22c55e":"error"===n?"#ef4444":void 0;return(0,a.jsxs)("div",{className:`flex items-center gap-3 p-3 rounded-lg border ${"ok"===n?"border-green-500/40":"error"===n?"border-red-500/40":"border-border"} hover:bg-sidebar/50`,children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-base text-text-muted",style:d?{color:d}:void 0,children:"ok"===n?"check_circle":"error"===n?"cancel":"smart_toy"}),(0,a.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,a.jsx)("p",{className:"text-sm font-medium truncate",children:e}),(0,a.jsxs)("div",{className:"flex items-center gap-1 mt-1",children:[(0,a.jsx)("code",{className:"text-xs text-text-muted font-mono bg-sidebar px-1.5 py-0.5 rounded",children:t}),(0,a.jsxs)("div",{className:"relative group/btn",children:[(0,a.jsx)("button",{onClick:()=>i(t,`model-${e}`),className:"p-0.5 hover:bg-sidebar rounded text-text-muted hover:text-primary",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-sm",children:s===`model-${e}`?"check":"content_copy"})}),(0,a.jsx)("span",{className:"pointer-events-none absolute top-5 left-1/2 -translate-x-1/2 text-[10px] text-text-muted whitespace-nowrap opacity-0 group-hover/btn:opacity-100 transition-opacity",children:s===`model-${e}`?"Copied!":"Copy"})]}),r&&(0,a.jsxs)("div",{className:"relative group/btn",children:[(0,a.jsx)("button",{onClick:r,disabled:o,className:"p-0.5 hover:bg-sidebar rounded text-text-muted hover:text-primary transition-colors",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-sm",style:o?{animation:"spin 1s linear infinite"}:void 0,children:o?"progress_activity":"science"})}),(0,a.jsx)("span",{className:"pointer-events-none absolute top-5 left-1/2 -translate-x-1/2 text-[10px] text-text-muted whitespace-nowrap opacity-0 group-hover/btn:opacity-100 transition-opacity",children:o?"Testing...":"Test"})]})]})]}),(0,a.jsx)("button",{onClick:l,className:"p-1 hover:bg-red-50 rounded text-red-500",title:"Remove model",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-sm",children:"delete"})})]})}function v({providerStorageAlias:e,providerDisplayAlias:t,modelAliases:s,copied:l,onCopy:r,onSetAlias:n,onDeleteAlias:o,connections:c,isAnthropic:m}){let[p,x]=(0,i.useState)(""),[u,h]=(0,i.useState)(!1),[f,g]=(0,i.useState)(!1),[b,j]=(0,i.useState)(null),[N,w]=(0,i.useState)({}),k=async t=>{if(!b){j(t);try{let s=await fetch("/api/models/test",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({model:`${e}/${t}`})}),a=await s.json();w(e=>({...e,[t]:a.ok?"ok":"error"}))}catch{w(e=>({...e,[t]:"error"}))}finally{j(null)}}},C=Object.entries(s).filter(([,t])=>t.startsWith(`${e}/`)).map(([t,s])=>({modelId:s.replace(`${e}/`,""),fullModel:s,alias:t})),S=a=>{let i,l=`${e}/${a}`;if(Object.values(s).includes(l))return null;let r=(i=a.split("/"))[i.length-1];if(!s[r])return r;let n=`${t}-${r}`;return s[n]?null:n},A=async()=>{if(!p.trim()||u)return;let t=p.trim(),s=S(t);if(!s)return void alert("All suggested aliases already exist. Please choose a different model or remove conflicting aliases.");h(!0);try{await n(t,s,e),x("")}catch(e){console.log("Error adding model:",e)}finally{h(!1)}},$=async()=>{if(f)return;let t=c.find(e=>!1!==e.isActive);if(t){g(!0);try{let s=await fetch(`/api/providers/${t.id}/models`),a=await s.json();if(!s.ok)return void alert(a.error||"Failed to import models");let i=a.models||[];if(0===i.length)return void alert("No models returned from /models.");let l=0;for(let t of i){let s=t.id||t.name||t.model;if(!s)continue;let a=S(s);a&&(await n(s,a,e),l+=1)}0===l&&alert("No new models were added.")}catch(e){console.log("Error importing models:",e)}finally{g(!1)}}},T=c.some(e=>!1!==e.isActive);return(0,a.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,a.jsxs)("p",{className:"text-sm text-text-muted",children:["Add ",m?"Anthropic":"OpenAI","-compatible models manually or import them from the /models endpoint."]}),(0,a.jsxs)("div",{className:"flex items-end gap-2 flex-wrap",children:[(0,a.jsxs)("div",{className:"flex-1 min-w-[240px]",children:[(0,a.jsx)("label",{htmlFor:"new-compatible-model-input",className:"text-xs text-text-muted mb-1 block",children:"Model ID"}),(0,a.jsx)("input",{id:"new-compatible-model-input",type:"text",value:p,onChange:e=>x(e.target.value),onKeyDown:e=>"Enter"===e.key&&A(),placeholder:m?"claude-3-opus-20240229":"gpt-4o",className:"w-full px-3 py-2 text-sm border border-border rounded-lg bg-background focus:outline-none focus:border-primary"})]}),(0,a.jsx)(d.$n,{size:"sm",icon:"add",onClick:A,disabled:!p.trim()||u,children:u?"Adding...":"Add"}),(0,a.jsx)(d.$n,{size:"sm",variant:"secondary",icon:"download",onClick:$,disabled:!T||f,children:f?"Importing...":"Import from /models"})]}),!T&&(0,a.jsx)("p",{className:"text-xs text-text-muted",children:"Add a connection to enable importing models."}),C.length>0&&(0,a.jsx)("div",{className:"flex flex-col gap-3",children:C.map(({modelId:e,fullModel:s,alias:i})=>(0,a.jsx)(y,{modelId:e,fullModel:`${t}/${e}`,copied:l,onCopy:r,onDeleteAlias:()=>o(i),onTest:c.length>0?()=>k(e):void 0,testStatus:N[e],isTesting:b===e},s))})]})}function j({until:e}){let[t,s]=(0,i.useState)("");return((0,i.useEffect)(()=>{let t=()=>{let t=new Date(e).getTime()-Date.now();if(t<=0)return void s("");let a=Math.floor(t/1e3);if(a<60)s(`${a}s`);else if(a<3600)s(`${Math.floor(a/60)}m ${a%60}s`);else{let e=Math.floor(a/3600),t=Math.floor(a%3600/60);s(`${e}h ${t}m`)}};t();let a=setInterval(t,1e3);return()=>clearInterval(a)},[e]),t)?(0,a.jsxs)("span",{className:"text-xs text-orange-500 font-mono",children:["⏱ ",t]}):null}function N({connection:e,proxyPools:t,health:s=null,isOAuth:l,isFirst:r,isLast:n,onMoveUp:o,onMoveDown:c,onToggleActive:m,onUpdateProxy:p,onEdit:x,onDelete:u,oneByOneStatus:h=null,autoPing:f=null}){let g,b,y,v,w,[k,C]=(0,i.useState)(!1),[S,A]=(0,i.useState)(!1),$=(0,i.useRef)(null),T=new Map((t||[]).map(e=>[e.id,e])),I=e.providerSpecificData?.proxyPoolId||null,P=I?T.get(I):null,O=e.providerSpecificData?.connectionProxyEnabled===!0&&!!e.providerSpecificData?.connectionProxyUrl,E=!!I||O,R=P?`Pool: ${P.name}`:I?`Pool: ${I} (inactive/missing)`:O?`Legacy: ${e.providerSpecificData?.connectionProxyUrl}`:"",D="";if(P?.proxyUrl||e.providerSpecificData?.connectionProxyUrl){let t=P?.proxyUrl||e.providerSpecificData?.connectionProxyUrl;try{let e=new URL(t);D=`${e.protocol}//${e.hostname}${e.port?`:${e.port}`:""}`}catch{D=t}}let _=P?.noProxy||e.providerSpecificData?.connectionNoProxy||"",z="default";P?.isActive===!0?z="success":(I||O)&&(z="error"),(0,i.useEffect)(()=>{if(!k)return;let e=e=>{$.current&&!$.current.contains(e.target)&&C(!1)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[k]);let U=async e=>{A(!0);try{await p("__none__"===e?null:e)}finally{A(!1),C(!1)}},q=e.authType||(l?"oauth":"apikey"),M="oauth"===q,K="cookie"===q,L=e=>"string"==typeof e&&/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e),F=M?L(e.email)?e.email:L(e.name)?e.name:e.name||e.email||e.displayName||"OAuth Account":e.name||e.email||e.displayName||"API Key",[J,B]=(0,i.useState)(!1),W=Object.entries(e).filter(([e])=>e.startsWith("modelLock_")).map(([,e])=>e).filter(e=>!!e).sort()[0]||null;(0,i.useEffect)(()=>{let t=()=>{B(!!Object.entries(e).filter(([e])=>e.startsWith("modelLock_")).map(([,e])=>e).filter(e=>e&&new Date(e).getTime()>Date.now()).sort()[0])};t();let s=W?setInterval(t,1e3):null;return()=>{s&&clearInterval(s)}},[W]);let V="unavailable"!==e.testStatus||J?e.testStatus:"active",H=()=>h?"queued"===h.state?"queued":"testing"===h.state?"testing":"success"===h.state?"success":"failed"===h.state?h.error?`failed: ${h.error}`:"failed":null:null;return(0,a.jsxs)("div",{className:`group flex min-w-0 flex-col gap-3 rounded-lg p-2 transition-colors hover:bg-black/[0.02] dark:hover:bg-white/[0.02] sm:flex-row sm:items-center sm:justify-between ${!1===e.isActive?"opacity-60":""}`,children:[(0,a.jsxs)("div",{className:"flex min-w-0 flex-1 items-start gap-2 sm:items-center sm:gap-3",children:[(0,a.jsxs)("div",{className:"flex shrink-0 flex-col",children:[(0,a.jsx)("button",{onClick:o,disabled:r,className:`p-0.5 rounded ${r?"text-text-muted/30 cursor-not-allowed":"hover:bg-sidebar text-text-muted hover:text-primary"}`,children:(0,a.jsx)("span",{className:"material-symbols-outlined text-sm",children:"keyboard_arrow_up"})}),(0,a.jsx)("button",{onClick:c,disabled:n,className:`p-0.5 rounded ${n?"text-text-muted/30 cursor-not-allowed":"hover:bg-sidebar text-text-muted hover:text-primary"}`,children:(0,a.jsx)("span",{className:"material-symbols-outlined text-sm",children:"keyboard_arrow_down"})})]}),(0,a.jsx)("span",{className:"material-symbols-outlined shrink-0 text-base text-text-muted",children:K?"cookie":M?"lock":"key"}),s&&(b=(g=Math.round(s.score??500))>=750?"bg-green-500/10 text-green-700 dark:text-green-400 border-green-500/30":g>=400?"bg-amber-500/10 text-amber-700 dark:text-amber-400 border-amber-500/30":"bg-red-500/10 text-red-700 dark:text-red-400 border-red-500/30",y=null!=s.successRate?`${s.successRate}%`:"n/a",v=`${s.ewmaLatencyMs}ms`,w=`Zenith health ${g}
|
|
1
|
+
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[2134],{76487:(e,t,s)=>{Promise.resolve().then(s.bind(s,77241))},77241:(e,t,s)=>{"use strict";s.r(t),s.d(t,{default:()=>z});var a=s(95155),i=s(12115),l=s(73321),r=s(98500),n=s.n(r),o=s(5772),d=s(35497),c=s(52679),m=s(28777),p=s(11059),x=s(73006);let u=new Map;async function h(e){if(!e?.url||!e?.type)return[];let t=u.get(e.url);if(t&&Date.now()<t.expiresAt)return t.data;try{let t=new URLSearchParams({url:e.url,type:e.type}),s=await fetch(`/api/providers/suggested-models?${t}`);if(!s.ok)return[];let a=(await s.json()).data??[];return u.set(e.url,{data:a,expiresAt:Date.now()+6e5}),a}catch{return[]}}var f=s(14051),g=s.n(f);function b({model:e,fullModel:t,alias:s,copied:i,onCopy:l,testStatus:r,isCustom:n,isFree:o,onDeleteAlias:d,onTest:c,isTesting:m,onDisable:p}){let x="ok"===r?"#22c55e":"error"===r?"#ef4444":void 0;return(0,a.jsx)("div",{className:`group min-w-0 max-w-full rounded-lg border px-3 py-2 ${"ok"===r?"border-green-500/40":"error"===r?"border-red-500/40":"border-border"} hover:bg-sidebar/50`,children:(0,a.jsxs)("div",{className:"flex min-w-0 items-start gap-2 sm:items-center",children:[(0,a.jsx)("span",{className:"material-symbols-outlined shrink-0 text-base",style:x?{color:x}:void 0,children:"ok"===r?"check_circle":"error"===r?"cancel":"smart_toy"}),(0,a.jsxs)("div",{className:"flex min-w-0 flex-1 flex-col gap-1",children:[(0,a.jsx)("code",{className:"max-w-[72vw] truncate rounded bg-sidebar px-1.5 py-0.5 font-mono text-xs text-text-muted sm:max-w-[360px]",children:t}),e.name&&(0,a.jsx)("span",{className:"truncate pl-1 text-[9px] italic text-text-muted",children:e.name})]}),c&&(0,a.jsxs)("div",{className:"relative shrink-0 group/btn",children:[(0,a.jsx)("button",{onClick:c,disabled:m,className:`rounded p-0.5 text-text-muted transition-opacity hover:bg-sidebar hover:text-primary ${m?"opacity-100":"opacity-100 sm:opacity-0 sm:group-hover:opacity-100"}`,children:(0,a.jsx)("span",{className:"material-symbols-outlined text-sm",style:m?{animation:"spin 1s linear infinite"}:void 0,children:m?"progress_activity":"science"})}),(0,a.jsx)("span",{className:"pointer-events-none absolute mt-1 top-5 left-1/2 -translate-x-1/2 text-[10px] text-text-muted whitespace-nowrap opacity-0 group-hover/btn:opacity-100 transition-opacity",children:m?"Testing...":"Test"})]}),(0,a.jsxs)("div",{className:"relative shrink-0 group/btn",children:[(0,a.jsx)("button",{onClick:()=>l(t,`model-${e.id}`),className:"rounded p-0.5 text-text-muted hover:bg-sidebar hover:text-primary",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-sm",children:i===`model-${e.id}`?"check":"content_copy"})}),(0,a.jsx)("span",{className:"pointer-events-none absolute mt-1 top-5 left-1/2 -translate-x-1/2 text-[10px] text-text-muted whitespace-nowrap opacity-0 group-hover/btn:opacity-100 transition-opacity",children:i===`model-${e.id}`?"Copied!":"Copy"})]}),n?(0,a.jsx)("button",{onClick:d,className:"ml-auto rounded p-0.5 text-text-muted opacity-100 transition-opacity hover:bg-red-500/10 hover:text-red-500 sm:opacity-0 sm:group-hover:opacity-100",title:"Remove custom model",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-sm",children:"close"})}):p?(0,a.jsx)("button",{onClick:p,className:"ml-auto rounded p-0.5 text-text-muted opacity-100 transition-opacity hover:bg-red-500/10 hover:text-red-500 sm:opacity-0 sm:group-hover:opacity-100",title:"Disable this model",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-sm",children:"close"})}):null]})})}function y({modelId:e,fullModel:t,copied:s,onCopy:i,onDeleteAlias:l,onTest:r,testStatus:n,isTesting:o}){let d="ok"===n?"#22c55e":"error"===n?"#ef4444":void 0;return(0,a.jsxs)("div",{className:`flex items-center gap-3 p-3 rounded-lg border ${"ok"===n?"border-green-500/40":"error"===n?"border-red-500/40":"border-border"} hover:bg-sidebar/50`,children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-base text-text-muted",style:d?{color:d}:void 0,children:"ok"===n?"check_circle":"error"===n?"cancel":"smart_toy"}),(0,a.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,a.jsx)("p",{className:"text-sm font-medium truncate",children:e}),(0,a.jsxs)("div",{className:"flex items-center gap-1 mt-1",children:[(0,a.jsx)("code",{className:"text-xs text-text-muted font-mono bg-sidebar px-1.5 py-0.5 rounded",children:t}),(0,a.jsxs)("div",{className:"relative group/btn",children:[(0,a.jsx)("button",{onClick:()=>i(t,`model-${e}`),className:"p-0.5 hover:bg-sidebar rounded text-text-muted hover:text-primary",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-sm",children:s===`model-${e}`?"check":"content_copy"})}),(0,a.jsx)("span",{className:"pointer-events-none absolute top-5 left-1/2 -translate-x-1/2 text-[10px] text-text-muted whitespace-nowrap opacity-0 group-hover/btn:opacity-100 transition-opacity",children:s===`model-${e}`?"Copied!":"Copy"})]}),r&&(0,a.jsxs)("div",{className:"relative group/btn",children:[(0,a.jsx)("button",{onClick:r,disabled:o,className:"p-0.5 hover:bg-sidebar rounded text-text-muted hover:text-primary transition-colors",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-sm",style:o?{animation:"spin 1s linear infinite"}:void 0,children:o?"progress_activity":"science"})}),(0,a.jsx)("span",{className:"pointer-events-none absolute top-5 left-1/2 -translate-x-1/2 text-[10px] text-text-muted whitespace-nowrap opacity-0 group-hover/btn:opacity-100 transition-opacity",children:o?"Testing...":"Test"})]})]})]}),(0,a.jsx)("button",{onClick:l,className:"p-1 hover:bg-red-50 rounded text-red-500",title:"Remove model",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-sm",children:"delete"})})]})}function v({providerStorageAlias:e,providerDisplayAlias:t,modelAliases:s,copied:l,onCopy:r,onSetAlias:n,onDeleteAlias:o,connections:c,isAnthropic:m}){let[p,x]=(0,i.useState)(""),[u,h]=(0,i.useState)(!1),[f,g]=(0,i.useState)(!1),[b,j]=(0,i.useState)(null),[N,w]=(0,i.useState)({}),k=async t=>{if(!b){j(t);try{let s=await fetch("/api/models/test",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({model:`${e}/${t}`})}),a=await s.json();w(e=>({...e,[t]:a.ok?"ok":"error"}))}catch{w(e=>({...e,[t]:"error"}))}finally{j(null)}}},C=Object.entries(s).filter(([,t])=>t.startsWith(`${e}/`)).map(([t,s])=>({modelId:s.replace(`${e}/`,""),fullModel:s,alias:t})),S=a=>{let i,l=`${e}/${a}`;if(Object.values(s).includes(l))return null;let r=(i=a.split("/"))[i.length-1];if(!s[r])return r;let n=`${t}-${r}`;return s[n]?null:n},A=async()=>{if(!p.trim()||u)return;let t=p.trim(),s=S(t);if(!s)return void alert("All suggested aliases already exist. Please choose a different model or remove conflicting aliases.");h(!0);try{await n(t,s,e),x("")}catch(e){console.log("Error adding model:",e)}finally{h(!1)}},$=async()=>{if(f)return;let t=c.find(e=>!1!==e.isActive);if(t){g(!0);try{let s=await fetch(`/api/providers/${t.id}/models`),a=await s.json();if(!s.ok)return void alert(a.error||"Failed to import models");let i=a.models||[];if(0===i.length)return void alert("No models returned from /models.");let l=0;for(let t of i){let s=t.id||t.name||t.model;if(!s)continue;let a=S(s);a&&(await n(s,a,e),l+=1)}0===l&&alert("No new models were added.")}catch(e){console.log("Error importing models:",e)}finally{g(!1)}}},T=c.some(e=>!1!==e.isActive);return(0,a.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,a.jsxs)("p",{className:"text-sm text-text-muted",children:["Add ",m?"Anthropic":"OpenAI","-compatible models manually or import them from the /models endpoint."]}),(0,a.jsxs)("div",{className:"flex items-end gap-2 flex-wrap",children:[(0,a.jsxs)("div",{className:"flex-1 min-w-[240px]",children:[(0,a.jsx)("label",{htmlFor:"new-compatible-model-input",className:"text-xs text-text-muted mb-1 block",children:"Model ID"}),(0,a.jsx)("input",{id:"new-compatible-model-input",type:"text",value:p,onChange:e=>x(e.target.value),onKeyDown:e=>"Enter"===e.key&&A(),placeholder:m?"claude-3-opus-20240229":"gpt-4o",className:"w-full px-3 py-2 text-sm border border-border rounded-lg bg-background focus:outline-none focus:border-primary"})]}),(0,a.jsx)(d.$n,{size:"sm",icon:"add",onClick:A,disabled:!p.trim()||u,children:u?"Adding...":"Add"}),(0,a.jsx)(d.$n,{size:"sm",variant:"secondary",icon:"download",onClick:$,disabled:!T||f,children:f?"Importing...":"Import from /models"})]}),!T&&(0,a.jsx)("p",{className:"text-xs text-text-muted",children:"Add a connection to enable importing models."}),C.length>0&&(0,a.jsx)("div",{className:"flex flex-col gap-3",children:C.map(({modelId:e,fullModel:s,alias:i})=>(0,a.jsx)(y,{modelId:e,fullModel:`${t}/${e}`,copied:l,onCopy:r,onDeleteAlias:()=>o(i),onTest:c.length>0?()=>k(e):void 0,testStatus:N[e],isTesting:b===e},s))})]})}function j({until:e}){let[t,s]=(0,i.useState)("");return((0,i.useEffect)(()=>{let t=()=>{let t=new Date(e).getTime()-Date.now();if(t<=0)return void s("");let a=Math.floor(t/1e3);if(a<60)s(`${a}s`);else if(a<3600)s(`${Math.floor(a/60)}m ${a%60}s`);else{let e=Math.floor(a/3600),t=Math.floor(a%3600/60);s(`${e}h ${t}m`)}};t();let a=setInterval(t,1e3);return()=>clearInterval(a)},[e]),t)?(0,a.jsxs)("span",{className:"text-xs text-orange-500 font-mono",children:["⏱ ",t]}):null}function N({connection:e,proxyPools:t,health:s=null,isOAuth:l,isFirst:r,isLast:n,onMoveUp:o,onMoveDown:c,onToggleActive:m,onUpdateProxy:p,onEdit:x,onDelete:u,oneByOneStatus:h=null,autoPing:f=null}){let g,b,y,v,w,[k,C]=(0,i.useState)(!1),[S,A]=(0,i.useState)(!1),$=(0,i.useRef)(null),T=new Map((t||[]).map(e=>[e.id,e])),I=e.providerSpecificData?.proxyPoolId||null,P=I?T.get(I):null,O=e.providerSpecificData?.connectionProxyEnabled===!0&&!!e.providerSpecificData?.connectionProxyUrl,E=!!I||O,R=P?`Pool: ${P.name}`:I?`Pool: ${I} (inactive/missing)`:O?`Legacy: ${e.providerSpecificData?.connectionProxyUrl}`:"",D="";if(P?.proxyUrl||e.providerSpecificData?.connectionProxyUrl){let t=P?.proxyUrl||e.providerSpecificData?.connectionProxyUrl;try{let e=new URL(t);D=`${e.protocol}//${e.hostname}${e.port?`:${e.port}`:""}`}catch{D=t}}let _=P?.noProxy||e.providerSpecificData?.connectionNoProxy||"",z="default";P?.isActive===!0?z="success":(I||O)&&(z="error"),(0,i.useEffect)(()=>{if(!k)return;let e=e=>{$.current&&!$.current.contains(e.target)&&C(!1)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[k]);let U=async e=>{A(!0);try{await p("__none__"===e?null:e)}finally{A(!1),C(!1)}},q=e.authType||(l?"oauth":"apikey"),M="oauth"===q,K="cookie"===q,L=e=>"string"==typeof e&&/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e),F=M?L(e.email)?e.email:L(e.name)?e.name:e.name||e.email||e.displayName||"OAuth Account":e.name||e.email||e.displayName||"API Key",[J,B]=(0,i.useState)(!1),W=Object.entries(e).filter(([e])=>e.startsWith("modelLock_")).map(([,e])=>e).filter(e=>!!e).sort()[0]||null;(0,i.useEffect)(()=>{let t=()=>{B(!!Object.entries(e).filter(([e])=>e.startsWith("modelLock_")).map(([,e])=>e).filter(e=>e&&new Date(e).getTime()>Date.now()).sort()[0])};t();let s=W?setInterval(t,1e3):null;return()=>{s&&clearInterval(s)}},[W]);let V="unavailable"!==e.testStatus||J?e.testStatus:"active",H=()=>h?"queued"===h.state?"queued":"testing"===h.state?"testing":"success"===h.state?"success":"failed"===h.state?h.error?`failed: ${h.error}`:"failed":null:null;return(0,a.jsxs)("div",{className:`group flex min-w-0 flex-col gap-3 rounded-lg p-2 transition-colors hover:bg-black/[0.02] dark:hover:bg-white/[0.02] sm:flex-row sm:items-center sm:justify-between ${!1===e.isActive?"opacity-60":""}`,children:[(0,a.jsxs)("div",{className:"flex min-w-0 flex-1 items-start gap-2 sm:items-center sm:gap-3",children:[(0,a.jsxs)("div",{className:"flex shrink-0 flex-col",children:[(0,a.jsx)("button",{onClick:o,disabled:r,className:`p-0.5 rounded ${r?"text-text-muted/30 cursor-not-allowed":"hover:bg-sidebar text-text-muted hover:text-primary"}`,children:(0,a.jsx)("span",{className:"material-symbols-outlined text-sm",children:"keyboard_arrow_up"})}),(0,a.jsx)("button",{onClick:c,disabled:n,className:`p-0.5 rounded ${n?"text-text-muted/30 cursor-not-allowed":"hover:bg-sidebar text-text-muted hover:text-primary"}`,children:(0,a.jsx)("span",{className:"material-symbols-outlined text-sm",children:"keyboard_arrow_down"})})]}),(0,a.jsx)("span",{className:"material-symbols-outlined shrink-0 text-base text-text-muted",children:K?"cookie":M?"lock":"key"}),s&&(b=(g=Math.round(s.score??500))>=750?"bg-green-500/10 text-green-700 dark:text-green-400 border-green-500/30":g>=400?"bg-amber-500/10 text-amber-700 dark:text-amber-400 border-amber-500/30":"bg-red-500/10 text-red-700 dark:text-red-400 border-red-500/30",y=null!=s.successRate?`${s.successRate}%`:"n/a",v=`${s.ewmaLatencyMs}ms`,w=`Zenith health ${g}
|
|
2
2
|
success ${y} \xb7 latency ${v} \xb7 n=${s.observed}`,(0,a.jsxs)("span",{className:`shrink-0 inline-flex items-center gap-1 rounded-md border px-1.5 py-0.5 font-mono text-[10px] leading-none ${b}`,title:w,"aria-label":w,children:["Z:",g]})),(0,a.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,a.jsx)("p",{className:"text-sm font-medium truncate",children:F}),(0,a.jsxs)("div",{className:"mt-1 flex min-w-0 flex-wrap items-center gap-1.5 sm:gap-2",children:[(0,a.jsx)(d.Ex,{variant:!1===e.isActive?"default":"active"===V||"success"===V?"success":"error"===V||"expired"===V||"unavailable"===V?"error":"default",size:"sm",dot:!0,children:!1===e.isActive?"disabled":V||"Unknown"}),e.chronicallyBanned&&!1!==e.isActive&&(0,a.jsxs)(d.Ex,{variant:"error",size:"sm",title:`Banned ${e.banCount||3}\xd7 in a row. Verify manually.`,children:["chronic ban \xd7",e.banCount||3]}),(0,a.jsx)(d.Ex,{variant:"default",size:"sm",children:M?"OAuth":K?"Cookie":"API Key"}),E&&(0,a.jsx)(d.Ex,{variant:z,size:"sm",children:"Proxy"}),J&&!1!==e.isActive&&(0,a.jsx)(j,{until:W}),e.lastError&&!1!==e.isActive&&"active"!==V&&"success"!==V&&(0,a.jsx)("span",{className:"max-w-full truncate text-xs text-red-500 sm:max-w-[300px]",title:e.lastError,children:e.lastError}),(0,a.jsxs)("span",{className:"text-xs text-text-muted",children:["#",e.priority]}),e.globalPriority&&(0,a.jsxs)("span",{className:"text-xs text-text-muted",children:["Auto: ",e.globalPriority]}),H()&&(0,a.jsx)(d.Ex,{variant:h?"success"===h.state?"success":"failed"===h.state?"error":"testing"===h.state?"primary":"default":"default",size:"sm",children:H()})]}),E&&(0,a.jsxs)("div",{className:"mt-1 flex items-center gap-2 flex-wrap",children:[(0,a.jsx)("span",{className:"max-w-full truncate text-[11px] text-text-muted sm:max-w-[420px]",title:R,children:R}),D&&(0,a.jsx)("code",{className:"max-w-full truncate rounded bg-black/5 px-1 py-0.5 font-mono text-[10px] text-text-muted dark:bg-white/5 sm:max-w-[260px]",children:D}),_&&(0,a.jsxs)("span",{className:"max-w-full truncate text-[11px] text-text-muted sm:max-w-[320px]",title:_,children:["no_proxy: ",_]})]})]})]}),(0,a.jsxs)("div",{className:"flex w-full items-center justify-between gap-2 sm:w-auto sm:justify-end",children:[(0,a.jsxs)("div",{className:"grid flex-1 grid-cols-3 gap-1 sm:flex sm:flex-none",children:[(t||[]).length>0&&(0,a.jsxs)("div",{className:"relative",ref:$,children:[(0,a.jsxs)("button",{onClick:()=>C(e=>!e),className:`flex w-full flex-col items-center rounded px-2 py-1 transition-colors hover:bg-black/5 dark:hover:bg-white/5 ${E?"text-primary":"text-text-muted hover:text-primary"}`,disabled:S,children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:S?"progress_activity":"lan"}),(0,a.jsx)("span",{className:"text-[10px] leading-tight",children:"Proxy"})]}),k&&(0,a.jsxs)("div",{className:"absolute right-0 top-full z-50 mt-1 max-w-[78vw] min-w-[160px] rounded-lg border border-border bg-bg py-1 shadow-lg",children:[(0,a.jsx)("button",{onClick:()=>U("__none__"),className:`w-full text-left px-3 py-1.5 text-sm hover:bg-black/5 dark:hover:bg-white/5 ${!I?"text-primary font-medium":"text-text-main"}`,children:"None"}),(t||[]).map(e=>(0,a.jsx)("button",{onClick:()=>U(e.id),className:`w-full text-left px-3 py-1.5 text-sm hover:bg-black/5 dark:hover:bg-white/5 ${I===e.id?"text-primary font-medium":"text-text-main"}`,children:e.name},e.id))]})]}),f&&(0,a.jsx)(d.m_,{text:"When your 5h quota runs out, auto-sends a request the moment it resets so a new window starts right away.",children:(0,a.jsxs)("button",{onClick:()=>f.onToggle(!f.on),className:`flex w-full flex-col items-center rounded px-2 py-1 transition-colors hover:bg-black/5 dark:hover:bg-white/5 ${f.on?"text-primary":"text-text-muted hover:text-primary"}`,children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:"bolt"}),(0,a.jsx)("span",{className:"text-[10px] leading-tight",children:"Auto-ping"})]})}),(0,a.jsxs)("button",{onClick:x,className:"flex flex-col items-center rounded px-2 py-1 text-text-muted hover:bg-black/5 hover:text-primary dark:hover:bg-white/5",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:"edit"}),(0,a.jsx)("span",{className:"text-[10px] leading-tight",children:"Edit"})]}),(0,a.jsxs)("button",{onClick:u,className:"flex flex-col items-center rounded px-2 py-1 text-red-500 hover:bg-red-500/10",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:"delete"}),(0,a.jsx)("span",{className:"text-[10px] leading-tight",children:"Delete"})]})]}),(0,a.jsx)(d.lM,{size:"sm",checked:e.isActive??!0,onChange:m,title:e.isActive??!0?"Disable connection":"Enable connection"})]})]})}b.propTypes={model:g().shape({id:g().string.isRequired}).isRequired,fullModel:g().string.isRequired,alias:g().string,copied:g().string,onCopy:g().func.isRequired,testStatus:g().oneOf(["ok","error"]),isCustom:g().bool,isFree:g().bool,onDeleteAlias:g().func,onTest:g().func,isTesting:g().bool,onDisable:g().func},g().string.isRequired,g().string.isRequired,g().string,g().func.isRequired,g().func.isRequired,g().func,g().oneOf(["ok","error"]),g().bool,g().string.isRequired,g().object.isRequired,g().string,g().func.isRequired,g().func.isRequired,g().func.isRequired,v.propTypes={providerStorageAlias:g().string.isRequired,providerDisplayAlias:g().string.isRequired,modelAliases:g().object.isRequired,copied:g().string,onCopy:g().func.isRequired,onSetAlias:g().func.isRequired,onDeleteAlias:g().func.isRequired,connections:g().arrayOf(g().shape({id:g().string,isActive:g().bool})).isRequired,isAnthropic:g().bool},j.propTypes={until:g().string.isRequired},N.propTypes={connection:g().shape({id:g().string,name:g().string,email:g().string,displayName:g().string,modelLockUntil:g().string,testStatus:g().string,isActive:g().bool,lastError:g().string,banCount:g().number,chronicallyBanned:g().bool,priority:g().number,globalPriority:g().number}).isRequired,health:g().shape({score:g().number,ewmaLatencyMs:g().number,successRate:g().number,observed:g().number,lastUpdate:g().number}),proxyPools:g().arrayOf(g().shape({id:g().string,name:g().string,proxyUrl:g().string,noProxy:g().string,isActive:g().bool})),isOAuth:g().bool.isRequired,isFirst:g().bool.isRequired,isLast:g().bool.isRequired,onMoveUp:g().func.isRequired,onMoveDown:g().func.isRequired,onToggleActive:g().func.isRequired,onUpdateProxy:g().func,onEdit:g().func.isRequired,onDelete:g().func.isRequired,oneByOneStatus:g().shape({state:g().string,error:g().string}),autoPing:g().shape({on:g().bool,onToggle:g().func})};let w=`name1|sk-key1
|
|
3
3
|
name2|sk-key2
|
|
4
4
|
sk-key-only-auto-named`;function k({isOpen:e,provider:t,providerName:s,isCompatible:l,isAnthropic:r,authType:n,authHint:o,website:m,proxyPools:p,error:x,existingNames:u,onSave:h,onBulkDone:f,onClose:g}){let b="__none__",y="ollama-local"===t,v="cookie"===n,j="xai"===t&&!v,N=v?"Cookie Value":"API Key",C=v?"grok-web"===t?"sso=xxxxx... or just the raw value":"eyJhbGciOi...":j?"xai-...":"",S="azure"===t,A="cloudflare-ai"===t,$=c.Q2?.[t]?.regions||null,T=c.Q2?.[t]?.defaultRegion||$?.[0]?.id||"",[I,P]=(0,i.useState)({name:"",apiKey:"",defaultModel:"",priority:1,proxyPoolId:b,ollamaHostUrl:""}),[O,E]=(0,i.useState)({azureEndpoint:"",apiVersion:"2024-10-01-preview",deployment:"",organization:""}),[R,D]=(0,i.useState)({accountId:""}),[_,z]=(0,i.useState)(T),[U,q]=(0,i.useState)(!1),[M,K]=(0,i.useState)(null),[L,F]=(0,i.useState)(!1),[J,B]=(0,i.useState)({status:"idle"}),W=(0,i.useRef)(null),[V,H]=(0,i.useState)("single"),[G,Q]=(0,i.useState)(""),[Z,Y]=(0,i.useState)(null),X=()=>y&&I.ollamaHostUrl.trim()?{baseUrl:I.ollamaHostUrl.trim()}:S?{azureEndpoint:O.azureEndpoint,apiVersion:O.apiVersion,deployment:O.deployment,organization:O.organization}:A?{accountId:R.accountId}:$&&_?{region:_}:void 0;(0,i.useEffect)(()=>{W.current&&clearTimeout(W.current);let e=I.apiKey?.trim();return!e||e.length<6||v||y?void B({status:"idle"}):(B({status:"loading"}),W.current=setTimeout(async()=>{try{let s=await fetch("/api/models/preview",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({providerId:t,apiKey:e})}),a=await s.json();"no_fetcher"===a.code?B({status:"unsupported"}):a.success?B({status:"ok",count:a.count,cached:!!a.cached}):B({status:"error",error:a.error||"Fetch failed"})}catch{B({status:"error",error:"Network error"})}},600),()=>{W.current&&clearTimeout(W.current)})},[I.apiKey,t,v,y]);let ee=async()=>{q(!0);try{let e=await fetch("/api/providers/validate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:t,apiKey:I.apiKey,providerSpecificData:X()})}),s=await e.json();K(s.valid?"success":"failed")}catch{K("failed")}finally{q(!1)}},et=async()=>{if(t&&(y||I.apiKey)&&(y||I.name)&&(!l||I.defaultModel.trim())){F(!0);try{let e=!1;try{q(!0),K(null);let s=await fetch("/api/providers/validate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:t,apiKey:I.apiKey,providerSpecificData:X()})});e=!!(await s.json()).valid,K(e?"success":"failed")}catch{K("failed")}finally{q(!1)}await h({name:I.name||(y?"Ollama Local":""),apiKey:I.apiKey,defaultModel:l?I.defaultModel.trim():void 0,priority:I.priority,proxyPoolId:I.proxyPoolId===b?null:I.proxyPoolId,testStatus:e?"active":"unknown",providerSpecificData:X()})}finally{F(!1)}}},es=async()=>{let e=function(e,t,s={}){let{isCloudflareAi:a=!1}=s,i=new Set((Array.isArray(t)?t:[]).map(e=>"string"==typeof e?e.toLowerCase():"")),l=[];for(let t of e){let e,s="string"==typeof t?t.trim():"";if(!s)continue;let r=function(e,t={}){let{isCloudflareAi:s=!1}=t,a=e.split("|");if(s&&a.length>=3){let e=a[0].trim();return{baseName:e||"Key",apiKey:a.slice(1,-1).join("|").trim(),providerSpecificData:{accountId:a[a.length-1].trim()}}}return a.length>=2?{baseName:a[0].trim()||"Key",apiKey:a.slice(1).join("|").trim()}:{baseName:"Key",apiKey:a[0].trim()}}(s,{isCloudflareAi:a});if(!r||!r.apiKey)continue;let n=r.baseName,o=1;for(;e=`${n} ${o}`,i.has(e.toLowerCase());)o+=1;i.add(e.toLowerCase());let d={name:e,apiKey:r.apiKey,skipped:!1};r.providerSpecificData&&(d.providerSpecificData=r.providerSpecificData),l.push(d)}return l}(G.split("\n"),u,{isCloudflareAi:A});if(!e.length)return;F(!0),Y(null);let s=0,a=0;for(let i of e)try{(await fetch("/api/providers",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:t,apiKey:i.apiKey,name:i.name,priority:1,testStatus:"unknown",...i.providerSpecificData?{providerSpecificData:i.providerSpecificData}:{}})})).ok?s++:a++}catch{a++}F(!1),Y({success:s,failed:a}),s>0&&f&&f()};return t?(0,a.jsx)(d.aF,{isOpen:e,title:`Add ${s||t} ${N}`,onClose:g,children:(0,a.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsx)(d.$n,{size:"sm",variant:"single"===V?"primary":"ghost",onClick:()=>{H("single"),Y(null)},children:"Single"}),(0,a.jsx)(d.$n,{size:"sm",variant:"bulk"===V?"primary":"ghost",onClick:()=>{H("bulk"),Y(null)},children:"Bulk Add"})]}),"bulk"===V&&(0,a.jsxs)("div",{className:"flex flex-col gap-3",children:[(0,a.jsxs)("p",{className:"text-xs text-text-muted",children:["One key per line. Format: ",(0,a.jsx)("code",{children:"name|apiKey"})," or just ",(0,a.jsx)("code",{children:"apiKey"})," (auto-named by index)."]}),(0,a.jsx)("textarea",{className:"w-full rounded border border-accent/30 bg-sidebar p-2 text-sm font-mono resize-y min-h-[140px] focus:outline-none focus:ring-1 focus:ring-primary",placeholder:w,value:G,onChange:e=>Q(e.target.value)}),Z&&(0,a.jsxs)("div",{className:`text-sm font-medium ${Z.failed>0?"text-yellow-400":"text-green-400"}`,children:["✓ ",Z.success," added",Z.failed>0?`, ✗ ${Z.failed} failed`:""]}),(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsx)(d.$n,{onClick:es,fullWidth:!0,disabled:L||!G.trim(),children:L?"Adding...":"Add All Keys"}),(0,a.jsx)(d.$n,{onClick:g,variant:"ghost",fullWidth:!0,children:"Cancel"})]})]}),"single"===V&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(d.pd,{label:"Name",value:I.name,onChange:e=>P({...I,name:e.target.value}),placeholder:y?"Ollama Local":"Production Key"}),y&&(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsx)(d.pd,{label:"Ollama Host URL",value:I.ollamaHostUrl,onChange:e=>P({...I,ollamaHostUrl:e.target.value}),placeholder:"http://localhost:11434",className:"flex-1"}),(0,a.jsx)("div",{className:"pt-6",children:(0,a.jsx)(d.$n,{onClick:ee,disabled:U||L,variant:"secondary",children:U?"Checking...":"Check"})})]}),!y&&(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsx)(d.pd,{label:N,type:v?"text":"password",value:I.apiKey,onChange:e=>P({...I,apiKey:e.target.value}),placeholder:C,className:"flex-1"}),(0,a.jsx)("div",{className:"pt-6",children:(0,a.jsx)(d.$n,{onClick:ee,disabled:!I.apiKey||U||L,variant:"secondary",children:U?"Checking...":"Check"})})]}),"idle"!==J.status&&!v&&!y&&(0,a.jsxs)("div",{className:"flex flex-wrap items-center gap-2 text-xs",children:["loading"===J.status&&(0,a.jsxs)("span",{className:"inline-flex items-center gap-1.5 text-text-muted",children:[(0,a.jsx)("span",{className:"material-symbols-outlined animate-spin text-sm",children:"progress_activity"}),"Checking key + fetching catalog…"]}),"ok"===J.status&&(0,a.jsxs)("span",{className:"inline-flex items-center gap-1.5 text-green-500",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-sm",children:"check_circle"}),"Fetched ",J.count," model",1===J.count?"":"s"," from ",s||t,J.cached&&(0,a.jsx)("span",{className:"text-text-muted",children:"\xb7 cached"})]}),"error"===J.status&&(0,a.jsxs)("span",{className:"inline-flex items-center gap-1.5 text-red-500",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-sm",children:"error"}),J.error]}),"unsupported"===J.status&&(0,a.jsxs)("span",{className:"inline-flex items-center gap-1.5 text-text-muted",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-sm",children:"info"}),"No live catalog for this provider — you can still save the key."]})]}),j&&(0,a.jsx)("p",{className:"text-xs text-text-muted",children:"Use a direct xAI API key from console.x.ai. This is separate from Grok Build OAuth."}),v&&o&&(0,a.jsxs)("p",{className:"text-xs text-text-muted",children:[o,m&&(0,a.jsxs)(a.Fragment,{children:[" ",(0,a.jsxs)("a",{href:m,target:"_blank",rel:"noopener noreferrer",className:"text-primary underline",children:["Open ",m.replace(/^https?:\/\//,"")]})]})]}),$&&(0,a.jsx)(d.l6,{label:"Region",value:_,onChange:e=>z(e.target.value),options:$.map(e=>({value:e.id,label:e.label}))}),l&&(0,a.jsx)(d.pd,{label:"Default Model",value:I.defaultModel,onChange:e=>P({...I,defaultModel:e.target.value}),placeholder:r?"claude-3-5-sonnet-latest":"gpt-4o-mini"}),y&&(0,a.jsxs)("p",{className:"text-xs text-text-muted",children:["Leave blank to use ",(0,a.jsx)("code",{children:"http://localhost:11434"}),". For remote Ollama, enter the full host URL (e.g. ",(0,a.jsx)("code",{children:"http://192.168.1.10:11434"}),")."]}),M&&(0,a.jsx)(d.Ex,{variant:"success"===M?"success":"error",children:"success"===M?"Valid":"Invalid"}),x&&(0,a.jsx)("p",{className:"text-xs text-red-500 break-words",children:x}),l&&(0,a.jsx)("p",{className:"text-xs text-text-muted",children:"Enter the model ID exactly as your compatible endpoint expects it. This model will be saved as the connection default."}),A&&(0,a.jsxs)("div",{className:"bg-sidebar/50 p-4 rounded-lg border border-accent/20",children:[(0,a.jsx)("h3",{className:"font-semibold mb-3 text-sm",children:"Cloudflare Workers AI"}),(0,a.jsx)(d.pd,{label:"Account ID",value:R.accountId,onChange:e=>D({...R,accountId:e.target.value}),placeholder:"abc123def456..."}),(0,a.jsxs)("p",{className:"text-xs text-text-muted mt-2",children:["Find your Account ID in the right sidebar of ",(0,a.jsx)("a",{href:"https://dash.cloudflare.com",target:"_blank",rel:"noopener noreferrer",className:"text-primary underline",children:"dash.cloudflare.com"})]})]}),S&&(0,a.jsxs)("div",{className:"bg-sidebar/50 p-4 rounded-lg border border-accent/20",children:[(0,a.jsx)("h3",{className:"font-semibold mb-3 text-sm",children:"Azure OpenAI Configuration"}),(0,a.jsxs)("div",{className:"flex flex-col gap-3",children:[(0,a.jsx)(d.pd,{label:"Azure Endpoint",value:O.azureEndpoint,onChange:e=>E({...O,azureEndpoint:e.target.value}),placeholder:"https://your-resource.openai.azure.com"}),(0,a.jsx)(d.pd,{label:"Deployment Name",value:O.deployment,onChange:e=>E({...O,deployment:e.target.value}),placeholder:"gpt-4"}),(0,a.jsx)(d.pd,{label:"API Version",value:O.apiVersion,onChange:e=>E({...O,apiVersion:e.target.value}),placeholder:"2024-10-01-preview"}),(0,a.jsx)(d.pd,{label:"Organization",value:O.organization,onChange:e=>E({...O,organization:e.target.value}),placeholder:"Organization ID"})]})]}),(0,a.jsx)(d.pd,{label:"Priority",type:"number",value:I.priority,onChange:e=>P({...I,priority:Number.parseInt(e.target.value)||1})}),(0,a.jsx)(d.l6,{label:"Proxy Pool",value:I.proxyPoolId,onChange:e=>P({...I,proxyPoolId:e.target.value}),options:[{value:b,label:"None"},...(p||[]).map(e=>({value:e.id,label:e.name}))],placeholder:"None"}),0===(p||[]).length&&(0,a.jsx)("p",{className:"text-xs text-text-muted",children:"No active proxy pools available. Create one in Proxy Pools page first."}),(0,a.jsx)("p",{className:"text-xs text-text-muted",children:"Legacy manual proxy fields are still accepted by API for backward compatibility."}),(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsx)(d.$n,{onClick:et,fullWidth:!0,disabled:L||!y&&(!I.name||!I.apiKey)||l&&!I.defaultModel.trim()||S&&(!O.azureEndpoint||!O.deployment||!O.organization)||A&&!R.accountId,children:L?"Saving...":"Save"}),(0,a.jsx)(d.$n,{onClick:g,variant:"ghost",fullWidth:!0,children:"Cancel"})]})]})]})}):null}function C({isOpen:e,node:t,onSave:s,onClose:l,isAnthropic:r}){let[n,o]=(0,i.useState)({name:"",prefix:"",apiType:"chat",baseUrl:"https://api.openai.com/v1"}),[c,m]=(0,i.useState)(!1),[p,x]=(0,i.useState)(""),[u,h]=(0,i.useState)(""),[f,g]=(0,i.useState)(!1),[b,y]=(0,i.useState)(null);(0,i.useEffect)(()=>{t&&o({name:t.name||"",prefix:t.prefix||"",apiType:t.apiType||"chat",baseUrl:t.baseUrl||(r?"https://api.anthropic.com/v1":"https://api.openai.com/v1")})},[t,r]);let v=async()=>{if(n.name.trim()&&n.prefix.trim()&&n.baseUrl.trim()){m(!0);try{let e={name:n.name,prefix:n.prefix,baseUrl:n.baseUrl};r||(e.apiType=n.apiType),await s(e)}finally{m(!1)}}},j=async()=>{g(!0);try{let e=await fetch("/api/provider-nodes/validate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({baseUrl:n.baseUrl,apiKey:p,type:r?"anthropic-compatible":"openai-compatible",modelId:u.trim()||void 0})}),t=await e.json();y(t.valid?"success":"failed")}catch{y("failed")}finally{g(!1)}};return t?(0,a.jsx)(d.aF,{isOpen:e,title:`Edit ${r?"Anthropic":"OpenAI"} Compatible`,onClose:l,children:(0,a.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,a.jsx)(d.pd,{label:"Name",value:n.name,onChange:e=>o({...n,name:e.target.value}),placeholder:`${r?"Anthropic":"OpenAI"} Compatible (Prod)`,hint:"Required. A friendly label for this node."}),(0,a.jsx)(d.pd,{label:"Prefix",value:n.prefix,onChange:e=>o({...n,prefix:e.target.value}),placeholder:r?"ac-prod":"oc-prod",hint:"Required. Used as the provider prefix for model IDs."}),!r&&(0,a.jsx)(d.l6,{label:"API Type",options:[{value:"chat",label:"Chat Completions"},{value:"responses",label:"Responses API"}],value:n.apiType,onChange:e=>o({...n,apiType:e.target.value})}),(0,a.jsx)(d.pd,{label:"Base URL",value:n.baseUrl,onChange:e=>o({...n,baseUrl:e.target.value}),placeholder:r?"https://api.anthropic.com/v1":"https://api.openai.com/v1",hint:`Use the base URL (ending in /v1) for your ${r?"Anthropic":"OpenAI"}-compatible API.`}),(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsx)(d.pd,{label:"API Key (for Check)",type:"password",value:p,onChange:e=>x(e.target.value),className:"flex-1"}),(0,a.jsx)("div",{className:"pt-6",children:(0,a.jsx)(d.$n,{onClick:j,disabled:!p||f||!n.baseUrl.trim(),variant:"secondary",children:f?"Checking...":"Check"})})]}),(0,a.jsx)(d.pd,{label:"Model ID (optional)",value:u,onChange:e=>h(e.target.value),placeholder:"e.g. my-model-id",hint:"If provider lacks /models endpoint, enter a model ID to validate via chat/completions instead."}),b&&(0,a.jsx)(d.Ex,{variant:"success"===b?"success":"error",children:"success"===b?"Valid":"Invalid"}),(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsx)(d.$n,{onClick:v,fullWidth:!0,disabled:!n.name.trim()||!n.prefix.trim()||!n.baseUrl.trim()||c,children:c?"Saving...":"Save"}),(0,a.jsx)(d.$n,{onClick:l,variant:"ghost",fullWidth:!0,children:"Cancel"})]})]})}):null}function S({isOpen:e,providerAlias:t,providerDisplayAlias:s,onSave:l,onClose:r}){let[n,o]=(0,i.useState)(""),[c,m]=(0,i.useState)(null),[p,x]=(0,i.useState)(""),[u,h]=(0,i.useState)(!1);(0,i.useEffect)(()=>{e&&(o(""),m(null),x(""))},[e]);let f=e=>{let s=`${t}/`;return e.startsWith(s)?e.slice(s.length):e},g=async()=>{let e=f(n.trim());if(e){m("testing"),x("");try{let s=await fetch("/api/models/test",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({model:`${t}/${e}`})}),a=await s.json();m(a.ok?"ok":"error"),x(a.error||"")}catch(e){m("error"),x(e.message)}}},b=async()=>{let e=f(n.trim());if(e&&!u){h(!0);try{await l(e)}finally{h(!1)}}};return(0,a.jsx)(d.aF,{isOpen:e,onClose:r,title:"Add Custom Model",children:(0,a.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("label",{className:"text-sm font-medium mb-1.5 block",children:"Model ID"}),(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsx)("input",{type:"text",value:n,onChange:e=>{o(e.target.value),m(null),x("")},onKeyDown:e=>{"Enter"===e.key&&g()},placeholder:"e.g. claude-opus-4-5",className:"flex-1 px-3 py-2 text-sm border border-border rounded-lg bg-background focus:outline-none focus:border-primary",autoFocus:!0}),(0,a.jsx)(d.$n,{variant:"secondary",icon:"science",loading:"testing"===c,onClick:g,disabled:!n.trim()||"testing"===c,children:"testing"===c?"Testing...":"Test"})]}),(0,a.jsxs)("p",{className:"text-xs text-text-muted mt-1",children:["Sent to provider as: ",(0,a.jsx)("code",{className:"font-mono bg-sidebar px-1 rounded",children:f(n.trim())||"model-id"})]})]}),"ok"===c&&(0,a.jsxs)("div",{className:"flex items-center gap-2 text-sm text-green-600",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-base",children:"check_circle"}),"Model is reachable"]}),"error"===c&&(0,a.jsxs)("div",{className:"flex items-start gap-2 text-sm text-red-500",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-base shrink-0",children:"cancel"}),(0,a.jsx)("span",{children:p||"Model not reachable"})]}),(0,a.jsxs)("div",{className:"flex gap-2 pt-1",children:[(0,a.jsx)(d.$n,{onClick:r,variant:"ghost",fullWidth:!0,size:"sm",children:"Cancel"}),(0,a.jsx)(d.$n,{onClick:b,fullWidth:!0,size:"sm",disabled:!n.trim()||u,children:u?"Adding...":"Add Model"})]})]})})}k.propTypes={isOpen:g().bool.isRequired,provider:g().string,providerName:g().string,isCompatible:g().bool,isAnthropic:g().bool,authType:g().string,authHint:g().string,website:g().string,proxyPools:g().arrayOf(g().shape({id:g().string,name:g().string})),error:g().string,existingNames:g().arrayOf(g().string),onSave:g().func.isRequired,onBulkDone:g().func,onClose:g().func.isRequired},C.propTypes={isOpen:g().bool.isRequired,node:g().shape({id:g().string,name:g().string,prefix:g().string,apiType:g().string,baseUrl:g().string}),onSave:g().func.isRequired,onClose:g().func.isRequired,isAnthropic:g().bool},S.propTypes={isOpen:g().bool.isRequired,providerAlias:g().string.isRequired,providerDisplayAlias:g().string.isRequired,onSave:g().func.isRequired,onClose:g().func.isRequired};let A=`[
|
|
@@ -8,4 +8,4 @@ sk-key-only-auto-named`;function k({isOpen:e,provider:t,providerName:s,isCompati
|
|
|
8
8
|
"idToken": "eyJhbGc...",
|
|
9
9
|
"email": "user@example.com"
|
|
10
10
|
}
|
|
11
|
-
]`;function $({isOpen:e,onClose:t,onSuccess:s}){let[l,r]=(0,i.useState)(""),[n,o]=(0,i.useState)(!1),[c,m]=(0,i.useState)(""),[p,u]=(0,i.useState)(null),h=()=>{n||(r(""),m(""),u(null),t())},f=async()=>{var e;let t;m(""),u(null);let a=l.trim();if(!a)return;try{t=JSON.parse(a)}catch(e){m(`${(0,x.Tl)("Invalid JSON")}: ${e.message}`);return}let i=Array.isArray(e=t)?e:e&&"object"==typeof e?Array.isArray(e.accounts)?e.accounts:[e]:null;if(!i||0===i.length)return void m((0,x.Tl)("No accounts found in input"));o(!0);try{let e=await fetch("/api/oauth/codex/bulk-import",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({accounts:i})}),t=await e.json();if(!e.ok)return void m(t?.error||`Request failed: ${e.status}`);u(t),t.success>0&&"function"==typeof s&&s()}catch(e){m(e.message||(0,x.Tl)("Request failed"))}finally{o(!1)}},g=p?.results?.filter(e=>!e.ok)||[];return(0,a.jsx)(d.aF,{isOpen:e,title:(0,x.Tl)("Bulk Add Codex Accounts"),onClose:h,children:(0,a.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,a.jsx)("p",{className:"text-xs text-text-muted",children:(0,x.Tl)("Paste an array of codex account JSON objects. Each must include accessToken (and ideally refreshToken, idToken).")}),(0,a.jsx)("textarea",{className:"w-full rounded border border-accent/30 bg-sidebar p-2 text-sm font-mono resize-y min-h-[240px] focus:outline-none focus:ring-1 focus:ring-primary",placeholder:A,value:l,onChange:e=>r(e.target.value),disabled:n}),c&&(0,a.jsx)("p",{className:"text-xs text-red-500 break-words",children:c}),p&&(0,a.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,a.jsxs)("div",{className:`text-sm font-medium ${p.failed>0?"text-yellow-400":"text-green-400"}`,children:["✓ ",p.success," ",(0,x.Tl)("added"),p.failed>0?`, ✗ ${p.failed} ${(0,x.Tl)("failed")}`:""]}),g.length>0&&(0,a.jsx)("ul",{className:"rounded border border-accent/20 bg-sidebar/50 p-2 text-xs font-mono max-h-40 overflow-y-auto",children:g.map(e=>(0,a.jsxs)("li",{className:"text-red-400",children:["[",e.index,"] ",e.error]},e.index))})]}),(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsx)(d.$n,{onClick:f,fullWidth:!0,disabled:n||!l.trim(),children:n?(0,x.Tl)("Importing..."):(0,x.Tl)("Import All")}),(0,a.jsx)(d.$n,{onClick:h,variant:"ghost",fullWidth:!0,disabled:n,children:(0,x.Tl)("Close")})]})]})})}$.propTypes={isOpen:g().bool.isRequired,onClose:g().func.isRequired,onSuccess:g().func};let T={free:{label:"Free",variant:"success",accent:"green"},freetier:{label:"Free tier",variant:"success",accent:"emerald"},oauth:{label:"OAuth",variant:"primary",accent:"primary"},paid:{label:"API key",variant:"default",accent:"neutral"},webcookie:{label:"Cookie",variant:"warning",accent:"amber"}};function I({capabilities:e,connectionCount:t=0,headerIconPath:s}){let[l,r]=(0,i.useState)(!1);if(!e)return null;let c=T[e.tier]||T.paid,m=e.color?`${e.color}10`:"rgba(148,163,184,0.08)",p=e.color?`${e.color}30`:"rgba(148,163,184,0.20)",x=[];return e.links.apiKey&&x.push({href:e.links.apiKey,icon:"key",label:"Get API key"}),e.links.signup&&!e.links.apiKey&&x.push({href:e.links.signup,icon:"person_add",label:"Sign up"}),e.links.homepage&&x.push({href:e.links.homepage,icon:"language",label:"Homepage"}),e.links.docs&&x.push({href:e.links.docs,icon:"menu_book",label:"Docs"}),e.links.pricing&&x.push({href:e.links.pricing,icon:"sell",label:"Pricing"}),(0,a.jsxs)("div",{className:"flex min-w-0 flex-col gap-4",children:[(0,a.jsxs)(n(),{href:"/dashboard/providers",className:"inline-flex items-center gap-1 text-sm text-text-muted hover:text-primary transition-colors",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-lg",children:"arrow_back"}),"Back to Providers"]}),(0,a.jsxs)("div",{className:"relative overflow-hidden rounded-2xl border p-5 sm:p-7",style:{borderColor:p,background:`linear-gradient(140deg, ${m} 0%, transparent 55%)`},children:[(0,a.jsxs)("div",{className:"flex min-w-0 flex-col gap-5 sm:flex-row sm:items-start sm:justify-between",children:[(0,a.jsxs)("div",{className:"flex min-w-0 items-start gap-4",children:[(0,a.jsx)("div",{className:"flex size-14 shrink-0 items-center justify-center rounded-xl shadow-sm",style:{backgroundColor:e.color?`${e.color}20`:"rgba(148,163,184,0.15)"},children:l||!s?(0,a.jsx)("span",{className:"text-base font-bold",style:{color:e.color||"inherit"},children:e.textIcon||e.id.slice(0,2).toUpperCase()}):(0,a.jsx)(o.default,{src:s,alt:e.name,width:56,height:56,className:"max-h-14 max-w-14 rounded-xl object-contain",sizes:"56px",onError:()=>r(!0)})}),(0,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,a.jsx)("h1",{className:"truncate text-2xl font-semibold tracking-tight sm:text-3xl",children:e.name}),(0,a.jsx)(d.Ex,{variant:c.variant,size:"sm",children:c.label}),e.deprecated&&(0,a.jsx)(d.Ex,{variant:"warning",size:"sm",children:"deprecated"})]}),(0,a.jsxs)("p",{className:"mt-1 text-sm text-text-muted",children:[t," connection",1===t?"":"s",e.serviceKinds.length>1&&(0,a.jsxs)(a.Fragment,{children:[" \xb7 ",e.serviceKinds.join(" \xb7 ")]})]})]})]}),x.length>0&&(0,a.jsx)("div",{className:"flex flex-wrap gap-1.5 sm:justify-end",children:x.map(e=>(0,a.jsxs)("a",{href:e.href,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 rounded-full border border-border bg-bg/60 px-2.5 py-1 text-xs text-text-main hover:border-primary hover:text-primary transition-colors backdrop-blur",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-sm",children:e.icon}),e.label]},e.label))})]}),e.notices.body&&!e.deprecated&&(0,a.jsx)("p",{className:"mt-4 max-w-3xl text-sm leading-relaxed text-text-muted",children:e.notices.body})]}),e.deprecated&&e.notices.warning&&(0,a.jsxs)("div",{className:"flex items-start gap-2 rounded-lg border border-yellow-500/30 bg-yellow-500/10 px-3 py-2",children:[(0,a.jsx)("span",{className:"material-symbols-outlined mt-0.5 shrink-0 text-[16px] text-yellow-500",children:"warning"}),(0,a.jsx)("p",{className:"text-xs leading-relaxed text-red-600 dark:text-yellow-400",children:e.notices.warning})]})]})}I.propTypes={capabilities:g().object,connectionCount:g().number,headerIconPath:g().string};let P={oauth:{icon:"lock",label:"Sign in with OAuth",tabLabel:"OAuth"},apikey:{icon:"key",label:"Add API key",tabLabel:"API key"},free:{icon:"bolt",label:"Connect for free",tabLabel:"Free"},cookie:{icon:"cookie",label:"Paste session cookie",tabLabel:"Cookie"},compatible:{icon:"developer_board",label:"Configure endpoint",tabLabel:"Compatible"}};function O({children:e,accentColor:t}){return(0,a.jsx)("div",{className:"rounded-xl border p-5 sm:p-6",style:{borderColor:t?`${t}25`:void 0,background:t?`linear-gradient(160deg, ${t}08, transparent 70%)`:void 0},children:e})}let E={oauth:function({capabilities:e,onOAuth:t,onBulkImport:s}){return(0,a.jsx)(O,{accentColor:e.color,children:(0,a.jsxs)("div",{className:"flex flex-col gap-4 sm:flex-row sm:items-center sm:justify-between",children:[(0,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsxs)("h3",{className:"text-base font-semibold",children:["Sign in with ",e.name]}),(0,a.jsx)("p",{className:"mt-0.5 text-sm text-text-muted",children:"One click. We handle the OAuth callback and store your session locally. You can add multiple accounts."})]}),(0,a.jsxs)("div",{className:"flex flex-wrap gap-2 sm:flex-nowrap",children:[e.features.bulkImport&&s&&(0,a.jsx)(d.$n,{size:"md",icon:"playlist_add",variant:"secondary",onClick:s,children:"Bulk import"}),(0,a.jsxs)(d.$n,{size:"md",icon:"lock",onClick:t,children:["Sign in with ",e.name]})]})]})})},apikey:function({capabilities:e,onApiKey:t}){return(0,a.jsx)(O,{accentColor:e.color,children:(0,a.jsxs)("div",{className:"flex flex-col gap-4 sm:flex-row sm:items-center sm:justify-between",children:[(0,a.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,a.jsxs)("h3",{className:"text-base font-semibold",children:["Paste your ",e.name," API key"]}),(0,a.jsxs)("p",{className:"mt-0.5 text-sm text-text-muted",children:[e.links.apiKey?(0,a.jsxs)(a.Fragment,{children:["Grab a key from"," ",(0,a.jsx)("a",{href:e.links.apiKey,target:"_blank",rel:"noopener noreferrer",className:"text-primary underline decoration-primary/40 underline-offset-4 hover:decoration-primary",children:new URL(e.links.apiKey).hostname})," ","and paste it in."]}):(0,a.jsx)(a.Fragment,{children:"Paste your API key to connect."})," ","Stored locally, never sent anywhere except ",e.name,"."]})]}),(0,a.jsx)(d.$n,{size:"md",icon:"key",onClick:t,children:"Add API key"})]})})},free:function({capabilities:e,onFree:t}){return(0,a.jsx)(O,{accentColor:e.color||"#10B981",children:(0,a.jsxs)("div",{className:"flex flex-col gap-4 sm:flex-row sm:items-center sm:justify-between",children:[(0,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsxs)("div",{className:"mb-1 flex items-center gap-2",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px] text-green-500",children:"bolt"}),(0,a.jsxs)("h3",{className:"text-base font-semibold",children:[e.name," is free — one click to connect"]})]}),(0,a.jsx)("p",{className:"text-sm text-text-muted",children:"No key, no signup, no card. Just click connect and start using it."})]}),(0,a.jsx)(d.$n,{size:"md",icon:"add",onClick:t,children:"Connect"})]})})},cookie:function({capabilities:e,onCookie:t}){let[s,l]=(0,i.useState)(!1);return(0,a.jsx)(O,{accentColor:e.color||"#F59E0B",children:(0,a.jsxs)("div",{className:"flex flex-col gap-3",children:[(0,a.jsxs)("div",{className:"flex items-start justify-between gap-3",children:[(0,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsx)("h3",{className:"text-base font-semibold",children:"Advanced: connect with session cookie"}),(0,a.jsxs)("p",{className:"mt-0.5 text-sm text-text-muted",children:["For power users. Extract the ",e.name," cookie from your browser and paste it here."]})]}),(0,a.jsx)("button",{type:"button",onClick:()=>l(e=>!e),className:"text-xs text-text-muted hover:text-primary",children:s?"hide":"show"})]}),s&&(0,a.jsxs)("div",{className:"rounded-lg border border-border bg-bg/70 p-3",children:[(0,a.jsxs)("ol",{className:"mb-3 list-decimal space-y-1 pl-4 text-xs text-text-muted",children:[(0,a.jsxs)("li",{children:["Open ",e.name," in your browser and sign in."]}),(0,a.jsx)("li",{children:"Open DevTools → Application → Cookies."}),(0,a.jsx)("li",{children:"Copy the session cookie value."}),(0,a.jsx)("li",{children:"Paste it in the modal."})]}),(0,a.jsx)(d.$n,{size:"sm",icon:"cookie",onClick:t,children:"Paste cookie"})]})]})})},compatible:function({capabilities:e,onCompatible:t}){return(0,a.jsx)(O,{accentColor:e.color,children:(0,a.jsxs)("div",{className:"flex flex-col gap-4 sm:flex-row sm:items-center sm:justify-between",children:[(0,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsx)("h3",{className:"text-base font-semibold",children:"Use as OpenAI-compatible endpoint"}),(0,a.jsx)("p",{className:"mt-0.5 text-sm text-text-muted",children:"Point at any OpenAI-shaped base URL (self-hosted, LiteLLM, custom proxy). Fetches the live model list after you connect."})]}),(0,a.jsx)(d.$n,{size:"md",icon:"developer_board",onClick:t,children:"Configure endpoint"})]})})}};function R({capabilities:e,onOAuth:t,onApiKey:s,onFree:l,onCookie:r,onCompatible:n,onBulkImport:o}){let d=e?.authModes||[],[c,m]=(0,i.useState)(d[0]||"apikey");if(!e||0===d.length)return null;let p=E[c]||E.apikey,x=d.length>1;return(0,a.jsxs)("div",{className:"flex min-w-0 flex-col gap-3",children:[x&&(0,a.jsx)("div",{className:"flex flex-wrap gap-1 rounded-lg border border-border bg-sidebar/40 p-1",children:d.map(e=>{let t=P[e]||{icon:"add",tabLabel:e},s=e===c;return(0,a.jsxs)("button",{type:"button",onClick:()=>m(e),className:`inline-flex items-center gap-1.5 rounded-md px-3 py-1.5 text-xs font-medium transition-colors ${s?"bg-bg text-text-main shadow-sm":"text-text-muted hover:text-text-main"}`,children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-sm",children:t.icon}),t.tabLabel]},e)})}),(0,a.jsx)(p,{capabilities:e,onOAuth:t,onApiKey:s,onFree:l,onCookie:r,onCompatible:n,onBulkImport:o})]})}function D({providerId:e,models:t=[]}){let[s,l]=(0,i.useState)(""),[r,n]=(0,i.useState)({status:"idle"}),o=(0,i.useCallback)(async()=>{if(e){n(e=>({...e,status:"ok"===e.status?"refreshing":"loading"}));try{let t=new URLSearchParams({providerId:e});s&&t.set("model",s);let a=await fetch(`/api/providers/zenith?${t.toString()}`,{cache:"no-store"}),i=await a.json();i.success?n({status:"ok",winner:i.winner,count:i.count,leaderboard:i.leaderboard}):n({status:"error",error:i.error||"Zenith read failed"})}catch(e){n({status:"error",error:e?.message||"Network error"})}}},[e,s]);if((0,i.useEffect)(()=>{o();let e=setInterval(o,1e4);return()=>clearInterval(e)},[o]),"idle"===r.status||"loading"===r.status||"error"===r.status||!r.winner||(r.count??0)<2)return null;let d=r.winner;return(0,a.jsxs)("div",{className:"mb-3 flex flex-wrap items-center gap-2 rounded-lg border border-primary/20 bg-primary/[0.04] px-3 py-2 text-xs",children:[(0,a.jsxs)("span",{className:"inline-flex items-center gap-1 text-primary font-medium",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-sm",children:"route"}),"Next request →"]}),(0,a.jsx)("span",{className:"font-medium text-text-main",children:d.name}),(0,a.jsxs)("span",{className:"rounded-md border border-primary/30 bg-primary/10 px-1.5 py-0.5 font-mono text-[10px] text-primary",children:["Z:",d.finalScore]}),(0,a.jsxs)("span",{className:"text-text-muted",children:["health ",d.healthScore," \xb7 quota \xd7",d.quotaFactor," \xb7 priority +",d.priorityBonus]}),t.length>0&&(0,a.jsxs)("div",{className:"ml-auto flex items-center gap-1.5",children:[(0,a.jsx)("span",{className:"text-text-muted",children:"Model:"}),(0,a.jsxs)("select",{value:s,onChange:e=>l(e.target.value),className:"rounded-md border border-border bg-bg px-1.5 py-0.5 text-[11px] focus:outline-none focus:border-primary",children:[(0,a.jsx)("option",{value:"",children:"(any)"}),t.map(e=>(0,a.jsx)("option",{value:e.id,children:e.id},e.id))]})]})]})}function _({providerId:e}){let[t,s]=(0,i.useState)(!1),[l,r]=(0,i.useState)([]),[n,o]=(0,i.useState)(!1),d=(0,i.useCallback)(async()=>{if(e){o(!0);try{let t=await fetch(`/api/providers/zenith/log?providerId=${e}&limit=50`,{cache:"no-store"}),s=await t.json();s.success&&r(s.entries||[])}catch{}finally{o(!1)}}},[e]);return(0,i.useEffect)(()=>{if(!t)return;d();let e=setInterval(d,5e3);return()=>clearInterval(e)},[t,d]),(0,a.jsxs)("div",{className:"mt-4 rounded-lg border border-border",children:[(0,a.jsxs)("button",{type:"button",onClick:()=>s(e=>!e),className:"flex w-full items-center justify-between px-3 py-2 text-xs text-text-muted hover:text-text-main",children:[(0,a.jsxs)("span",{className:"inline-flex items-center gap-1.5",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-sm",children:"history"}),"Routing decisions",l.length>0&&(0,a.jsxs)("span",{className:"text-text-muted",children:["(",l.length,")"]})]}),(0,a.jsx)("span",{className:"material-symbols-outlined text-sm",children:t?"expand_less":"expand_more"})]}),t&&(0,a.jsxs)("div",{className:"max-h-64 overflow-y-auto border-t border-border/50 px-3 py-2",children:[n&&0===l.length&&(0,a.jsx)("p",{className:"text-xs text-text-muted",children:"Loading…"}),!n&&0===l.length&&(0,a.jsx)("p",{className:"text-xs text-text-muted",children:"No decisions recorded yet. Fire a request through kRouter to populate."}),(0,a.jsx)("ul",{className:"space-y-1",children:l.map((e,t)=>(0,a.jsxs)("li",{className:"flex flex-wrap items-center gap-2 border-b border-border/30 py-1 text-[11px] font-mono last:border-0",children:[(0,a.jsx)("span",{className:"text-text-muted",children:function(e){let t=Math.floor((Date.now()-e)/1e3);if(t<5)return"just now";if(t<60)return`${t}s ago`;let s=Math.floor(t/60);return s<60?`${s}m ago`:`${Math.floor(s/60)}h ago`}(e.at)}),e.model&&(0,a.jsx)("span",{className:"text-text-main",children:e.model}),(0,a.jsx)("span",{className:"text-text-muted",children:"→"}),(0,a.jsx)("span",{className:"text-text-main",children:e.connectionId.slice(0,8)}),null!=e.score&&(0,a.jsxs)("span",{className:"text-primary",children:["Z:",e.score]}),null!=e.latencyMs&&(0,a.jsxs)("span",{className:"text-text-muted",children:[e.latencyMs,"ms"]}),(0,a.jsx)("span",{className:e.success?"text-green-500":"text-red-500",children:e.success?"✓":"✗"})]},`${e.at}-${t}`))})]})]})}function z(){let e,t=(0,l.useParams)(),s=(0,l.useRouter)(),r=t.id,[u,f]=(0,i.useState)([]),[g,y]=(0,i.useState)(!0),[j,w]=(0,i.useState)(null),[A,T]=(0,i.useState)([]),[P,O]=(0,i.useState)(!1),[E,z]=(0,i.useState)(!1),[U,q]=(0,i.useState)(!1),[M,K]=(0,i.useState)(""),[L,F]=(0,i.useState)(!1),[J,B]=(0,i.useState)(!1),[W,V]=(0,i.useState)(!1),[H,G]=(0,i.useState)(!1),[Q,Z]=(0,i.useState)(null),[Y,X]=(0,i.useState)({}),[ee,et]=(0,i.useState)(!1),[es,ea]=(0,i.useState)({}),[ei,el]=(0,i.useState)(""),[er,en]=(0,i.useState)(new Set),[eo,ed]=(0,i.useState)(!1),[ec,em]=(0,i.useState)(!1),[ep,ex]=(0,i.useState)([]),[eu,eh]=(0,i.useState)("__none__"),[ef,eg]=(0,i.useState)(!1),[eb,ey]=(0,i.useState)(null),[ev,ej]=(0,i.useState)(""),[eN,ew]=(0,i.useState)("auto"),[ek,eC]=(0,i.useState)({enabled:!1,connections:{}}),[eS,eA]=(0,i.useState)([]),[e$,eT]=(0,i.useState)([]),[eI,eP]=(0,i.useState)(!1),[eO,eE]=(0,i.useState)(""),[eR,eD]=(0,i.useState)(new Set),[e_,ez]=(0,i.useState)([]),[eU,eq]=(0,i.useState)([]),[eM,eK]=(0,i.useState)(null),[eL,eF]=(0,i.useState)(!1),[eJ,eB]=(0,i.useState)(!1),[eW,eV]=(0,i.useState)(!1),[eH,eG]=(0,i.useState)(null),[eQ,eZ]=(0,i.useState)({}),[eY,eX]=(0,i.useState)(null),e0=(0,i.useRef)(!1),[e1,e5]=(0,i.useState)(!1),{copied:e2,copy:e4}=(0,p.C)(),e3="ag_risk_confirmed",e6=()=>{O(!0)},e7=()=>{"antigravity"===r&&"true"!==window.localStorage.getItem(e3)?eF(!0):tl?e6():(K(""),q(!0))},e8=()=>{K(""),q(!0)},e9=()=>{tl?e7():e8()},te=j?{id:j.id,name:j.name||("anthropic-compatible"===j.type?"Anthropic Compatible":"OpenAI Compatible"),color:"anthropic-compatible"===j.type?"#D97757":"#10A37F",textIcon:"anthropic-compatible"===j.type?"AC":"OC",apiType:j.apiType,baseUrl:j.baseUrl,type:j.type}:c.zN[r]||c.fg[r]||c.IS[r]||c.nJ[r]||c.br[r],tt=j?null:function(e){let t=c.zN[e]?c.zN:c.fg[e]?c.fg:c.IS[e]?c.IS:c.nJ[e]?c.nJ:c.br[e]?c.br:null;if(!t)return null;let s=t[e],a=t===c.IS&&s?.noAuth?"free":t===c.IS||t===c.zN?"oauth":t===c.br?"cookie":t===c.fg&&s?.noAuth?"free":(t===c.fg||c.nJ,"apikey"),i=Array.isArray(s.authModes)?s.authModes.filter(e=>e!==a):[],l=[a,...i],r=(0,c.mq)(e)||(0,c.gb)(e);r&&!l.includes("compatible")&&l.push("compatible");let n=s.notice||{};return{id:e,name:s.name||e,icon:s.icon,image:s.image,textIcon:s.textIcon,color:s.color,tier:t===c.IS?"free":t===c.nJ?"freetier":t===c.zN?"oauth":t===c.br?"webcookie":s?.noAuth?"free":"paid",authModes:l,links:{homepage:s.website,apiKey:n.apiKeyUrl,signup:n.signupUrl,pricing:s.searchViaChat?.pricingUrl,docs:s.docsUrl},features:{autoPing:"claude"===e&&"oauth"===a,bulkImport:"codex"===e,compatibleModels:r,customModels:!s.passthroughModels,passthroughModels:!!s.passthroughModels,hasRegions:Array.isArray(s.regions)&&s.regions.length>0,hasProviderSpecificData:!!s.hasProviderSpecificData},serviceKinds:s.serviceKinds||["llm"],thinking:s.thinkingConfig||null,notices:{body:n.text,warning:s.deprecationNotice},deprecated:!!s.deprecated,regions:s.regions,defaultRegion:s.defaultRegion,noAuth:!!s.noAuth,_raw:s}}(r),ts="codex"===r?"codexAutoPing":"claudeAutoPing",ta="claude"===r||"codex"===r,ti=te?.authModes||[],tl=!!c.zN[r]||!!c.IS[r]||ti.includes("oauth"),tr=!!c.fg[r]||ti.includes("apikey"),tn=!!c.IS[r]?.noAuth,to=(0,m.KC)(r),td=(0,c.wG)(r),tc=(0,c.mq)(r),tm=(0,c.gb)(r),tp=tc||tm,tx=!tp&&tl&&tr,tu="xai"===r?"Grok Build OAuth":"OAuth",th="xai"===r?"xAI API Key":"API Key";c.Q2[r]?.thinkingConfig||c.s9.extended;let tf=tp?r:td,tg=tp?j?.prefix||r:td,tb=(0,i.useCallback)(async()=>{try{let e=await fetch(`/api/models/disabled?providerAlias=${encodeURIComponent(tf)}`,{cache:"no-store"}),t=await e.json();e.ok&&eq(t.ids||[])}catch(e){console.log("Error fetching disabled models:",e)}},[tf]),ty=async e=>{try{(await fetch("/api/models/disabled",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({providerAlias:tf,ids:[e]})})).ok&&await tb()}catch(e){console.log("Error disabling model:",e)}},tv=async e=>{try{(await fetch(`/api/models/disabled?providerAlias=${encodeURIComponent(tf)}&id=${encodeURIComponent(e)}`,{method:"DELETE"})).ok&&await tb()}catch(e){console.log("Error enabling model:",e)}},tj=async e=>{e.length&&eK({title:"Disable All Models",message:`Disable all ${e.length} model(s)?`,onConfirm:async()=>{eK(null);try{(await fetch("/api/models/disabled",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({providerAlias:tf,ids:e})})).ok&&await tb()}catch(e){console.log("Error disabling all models:",e)}}})},tN=async()=>{try{(await fetch(`/api/models/disabled?providerAlias=${encodeURIComponent(tf)}`,{method:"DELETE"})).ok&&await tb()}catch(e){console.log("Error enabling all models:",e)}},tw=(0,i.useCallback)(async()=>{try{let e=await fetch("/api/models/alias"),t=await e.json();e.ok&&X(t.aliases||{})}catch(e){console.log("Error fetching aliases:",e)}},[]);(0,i.useEffect)(()=>{"kilocode"===r&&fetch("/api/providers/kilo/free-models").then(e=>e.json()).then(e=>{e.models?.length&&ez(e.models)}).catch(()=>{})},[r]);let tk=(0,i.useCallback)(async()=>{try{let[e,t,s,a]=await Promise.all([fetch("/api/providers",{cache:"no-store"}),fetch("/api/provider-nodes",{cache:"no-store"}),fetch("/api/proxy-pools?isActive=true",{cache:"no-store"}),fetch("/api/settings",{cache:"no-store"})]),i=await e.json(),l=await t.json(),n=await s.json(),o=a.ok?await a.json():{};if(e.ok){let e=(i.connections||[]).filter(e=>e.provider===r);f(e)}s.ok&&T(n.proxyPools||[]);let d=(o.providerStrategies||{})[r]||{};ey(d.fallbackStrategy||null),ej(null!=d.stickyRoundRobinLimit?String(d.stickyRoundRobinLimit):"1");let c=(o.providerThinking||{})[r]||{};ew(c.mode||"auto");let m=o[ts]||{};if(eC({enabled:!0===m.enabled,connections:m.connections||{}}),t.ok){let e=(l.nodes||[]).find(e=>e.id===r)||null;if(!e&&tp)for(let t=0;t<3;t+=1){await new Promise(e=>setTimeout(e,150));let t=await fetch("/api/provider-nodes",{cache:"no-store"});if(t.ok&&(e=((await t.json()).nodes||[]).find(e=>e.id===r)||null))break}w(e)}}catch(e){console.log("Error fetching connections:",e)}finally{y(!1)}},[r,tp]),tC=async e=>{try{let t=await fetch(`/api/provider-nodes/${r}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}),s=await t.json();t.ok&&(w(s.node),await tk(),V(!1))}catch(e){console.log("Error updating provider node:",e)}},tS=async(e,t)=>{try{let s=await fetch("/api/settings",{cache:"no-store"}),a=(s.ok?await s.json():{}).providerStrategies||{},i={};e&&(i.fallbackStrategy=e),"round-robin"===e&&""!==t&&(i.stickyRoundRobinLimit=Number(t)||3);let l={...a};0===Object.keys(i).length?delete l[r]:l[r]=i,await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({providerStrategies:l})})}catch(e){console.log("Error saving provider strategy:",e)}},tA=async(e,t)=>{eC({...ek,connections:{...ek.connections,[e]:t}});try{let s=await fetch("/api/settings",{cache:"no-store"}),a=(s.ok?await s.json():{})[ts]||{},i={...a,connections:{...a.connections||{},[e]:t}};await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({[ts]:i})}),eC({enabled:!0===i.enabled,connections:i.connections})}catch(e){console.log("Error saving auto-ping config:",e),eC(ek)}};(0,i.useEffect)(()=>{tk(),tw(),tb()},[tk,tw,tb]);let[t$,tT]=(0,i.useState)({});(0,i.useEffect)(()=>{let e=!1,t=async()=>{try{let t=await fetch("/api/providers/health",{cache:"no-store"});if(!t.ok)return;let s=await t.json();!e&&s?.success&&s.snapshot&&tT(s.snapshot)}catch{}};t();let s=setInterval(t,1e4);return()=>{e=!0,clearInterval(s)}},[]),(0,i.useEffect)(()=>{let e=(c.zN[r]||c.fg[r]||c.IS[r]||c.nJ[r])?.modelsFetcher;e&&h(e).then(eA)},[r]);let tI=(0,i.useCallback)(async()=>{if(0===u.length)return;let e=u.find(e=>!1!==e.isActive)||u[0];if(e){eP(!0);try{let t=null;try{let s=await fetch(`/api/models/live-by-connection?connectionId=${e.id}`),a=s.ok?await s.json():null;a?.success&&a?.models?.length?t={models:a.models}:a?.code==="no_fetcher"&&(t=null)}catch{}if(!t){let s=await fetch(`/api/providers/${e.id}/models`);t=s.ok?await s.json():null}t?.models?.length&&(eT(t.models),eD(e=>{if(e.size>0)return e;let s=t.models[0]?.id||"",a=s.includes("/")?s.split("/")[0]:"other";return new Set([a])}))}catch{}finally{eP(!1)}}},[r,u]);(0,i.useEffect)(()=>{tI()},[tI]);let tP=async(e,t,s=td)=>{let a=`${s}/${e}`;try{let e=await fetch("/api/models/alias",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({model:a,alias:t})});if(e.ok)await tw();else{let t=await e.json();alert(t.error||"Failed to set alias")}}catch(e){console.log("Error setting alias:",e)}},tO=async e=>{try{(await fetch(`/api/models/alias?alias=${encodeURIComponent(e)}`,{method:"DELETE"})).ok&&await tw()}catch(e){console.log("Error deleting alias:",e)}},tE=async()=>{if(e1)return;let e=u.find(e=>!1!==e.isActive);if(!e)return void alert((0,x.Tl)("Please add an active Qoder connection first"));e5(!0);try{let t=await fetch(`/api/providers/${e.id}/models`),s=await t.json();if(!t.ok)return void alert(s.error||(0,x.Tl)("Failed to fetch models"));let a=s.models||[];if(0===a.length)return void alert((0,x.Tl)("No models returned"));let i=0;for(let e of a){let t=e.id||e.name;if(!t)continue;let s=t.replace(/^qoder\//,""),a=`${tf}/${s}`;!Object.values(Y).includes(a)&&(Y[s]||(await tP(s,s,tf),i+=1))}0===i?alert((0,x.Tl)("All models already exist, no new models added")):alert((0,x.Tl)("Successfully added")+` ${i} `+(0,x.Tl)("models"))}catch(e){console.log("Error importing Qoder models:",e),alert((0,x.Tl)("Error fetching models")+": "+e.message)}finally{e5(!1)}},tR=async()=>{if(eJ||0===u.length)return;let e=Object.fromEntries(u.map(e=>[e.id,{state:"queued",error:null}]));e0.current=!1,eB(!0),eV(!1),eG(null),eZ(e),eX({total:u.length,completed:0,passed:0,failed:0,stopped:!1});let t=0,s=0;try{for(let e=0;e<u.length;e+=1){if(e0.current){eX({total:u.length,completed:e,passed:t,failed:s,stopped:!0});break}let a=u[e];eG(a.id),eZ(e=>({...e,[a.id]:{state:"testing",error:null}}));try{let e=await fetch(`/api/providers/${a.id}/test`,{method:"POST"}),i=await e.json(),l=!!i.valid;l?t+=1:s+=1,eZ(e=>({...e,[a.id]:{state:l?"success":"failed",error:l?null:i.error||null}}))}catch(e){s+=1,eZ(t=>({...t,[a.id]:{state:"failed",error:e.message||"Test failed"}}))}eX({total:u.length,completed:e+1,passed:t,failed:s,stopped:!1}),e<u.length-1&&await new Promise(e=>setTimeout(e,1e3))}}finally{eG(null),eB(!1),eV(!1),e0.current=!1}},tD=async e=>{eK({title:"Delete Connection",message:"Delete this connection?",onConfirm:async()=>{eK(null);try{(await fetch(`/api/providers/${e}`,{method:"DELETE"})).ok&&f(t=>t.filter(t=>t.id!==e))}catch(e){console.log("Error deleting connection:",e)}}})},t_=()=>{tk(),O(!1)},tz=async e=>{K("");try{let t=await fetch("/api/providers",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:r,...e})}),s=null;try{s=await t.json()}catch{s=null}if(t.ok){await tk(),q(!1);return}K(s?.error||"Failed to save connection")}catch(e){console.log("Error saving connection:",e),K("Failed to save connection")}},tU=async e=>{try{(await fetch(`/api/providers/${Q.id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})).ok&&(await tk(),B(!1))}catch(e){console.log("Error updating connection:",e)}},tq=async(e,t)=>{try{(await fetch(`/api/providers/${e}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({isActive:t})})).ok&&f(s=>s.map(s=>s.id===e?{...s,isActive:t}:s))}catch(e){console.log("Error updating connection status:",e)}},tM=async(e,t)=>{let s=[...u];[s[e],s[t]]=[s[t],s[e]],f(s);try{await Promise.all([fetch(`/api/providers/${s[e].id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({priority:e})}),fetch(`/api/providers/${s[t].id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({priority:t})})])}catch(e){console.log("Error swapping priority:",e),await tk()}},tK=u.filter(e=>ep.includes(e.id));u.length>0&&(ep.length,u.length),(0,i.useEffect)(()=>{ex(e=>e.filter(e=>u.some(t=>t.id===e)))},[u]),(()=>{if(0===tK.length)return;let e=new Set(tK.map(e=>e.providerSpecificData?.proxyPoolId||"__none__"));if(1===e.size){let t=[...e][0];if("__none__"===t)return;let s=A.find(e=>e.id===t);return s?.name}})();let tL=()=>{ef||G(!1)},tF=async e=>{eg(!0);try{let t=0;for(let{connectionId:s,proxyPoolId:a}of e)try{(await fetch(`/api/providers/${s}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({proxyPoolId:a})})).ok||(t+=1)}catch(e){console.log("Error applying proxy for",s,e),t+=1}t>0&&alert(`Updated with ${t} failed request(s).`),await tk(),G(!1)}finally{eg(!1)}},tJ=e=>tF(u.map(t=>({connectionId:t.id,proxyPoolId:e}))),tB=(0,a.jsx)("div",{className:"flex min-w-0 flex-col divide-y divide-black/[0.03] dark:divide-white/[0.03]",children:u.map((e,t)=>(0,a.jsx)("div",{className:"flex min-w-0 items-stretch",children:(0,a.jsx)("div",{className:"flex-1 min-w-0",children:(0,a.jsx)(N,{connection:e,proxyPools:A,health:t$[e.id],isOAuth:tl,isFirst:0===t,isLast:t===u.length-1,onMoveUp:()=>tM(t,t-1),onMoveDown:()=>tM(t,t+1),onToggleActive:t=>tq(e.id,t),autoPing:ta&&"oauth"===e.authType?{on:!0===ek.connections[e.id],onToggle:t=>tA(e.id,t)}:null,onUpdateProxy:async t=>{try{(await fetch(`/api/providers/${e.id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({proxyPoolId:t||null})})).ok&&f(s=>s.map(s=>s.id===e.id?{...s,providerSpecificData:{...s.providerSpecificData,proxyPoolId:t||null}}:s))}catch(e){console.log("Error updating proxy:",e)}},onEdit:()=>{Z(e),B(!0)},onDelete:()=>tD(e.id),oneByOneStatus:eQ[e.id]||null})})},e.id))}),tW=A.filter(e=>!0===e.isActive),tV=(0,a.jsx)(d.aF,{isOpen:H,onClose:tL,title:`Apply Proxy (${u.length} connections)`,children:(0,a.jsxs)("div",{className:"flex flex-col gap-3",children:[(0,a.jsxs)("div",{className:"flex flex-col",children:[(0,a.jsxs)("button",{onClick:()=>{let e=A.filter(e=>!0===e.isActive);return 0===e.length?void alert("No active proxy pools available."):tF(u.map((t,s)=>({connectionId:t.id,proxyPoolId:e[s%e.length].id})))},disabled:ef||0===tW.length,className:"flex items-center gap-2 rounded-lg px-3 py-2 text-left transition-colors hover:bg-black/[0.04] dark:hover:bg-white/[0.04] disabled:cursor-not-allowed disabled:opacity-50",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-text-muted text-[18px]",children:"sync_alt"}),(0,a.jsx)("span",{className:"text-sm text-text-main",children:"One-to-one (rotate)"})]}),(0,a.jsxs)("button",{onClick:()=>tJ(null),disabled:ef,className:"flex items-center gap-2 rounded-lg px-3 py-2 text-left transition-colors hover:bg-black/[0.04] dark:hover:bg-white/[0.04] disabled:cursor-not-allowed disabled:opacity-50",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-text-muted text-[18px]",children:"link_off"}),(0,a.jsx)("span",{className:"text-sm text-text-main",children:"None (unbind all)"})]}),A.map(e=>(0,a.jsxs)("button",{onClick:()=>tJ(e.id),disabled:ef||!0!==e.isActive,className:"flex items-center gap-2 rounded-lg px-3 py-2 text-left transition-colors hover:bg-black/[0.04] dark:hover:bg-white/[0.04] disabled:cursor-not-allowed disabled:opacity-50",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-text-muted text-[18px]",children:"lan"}),(0,a.jsx)("span",{className:"truncate text-sm text-text-main",children:e.name}),!0!==e.isActive&&(0,a.jsx)("span",{className:"text-[10px] text-text-muted",children:"(inactive)"})]},e.id))]}),ef&&(0,a.jsx)("p",{className:"text-xs text-text-muted",children:"Applying..."}),(0,a.jsx)(d.$n,{onClick:tL,variant:"ghost",fullWidth:!0,disabled:ef,children:"Cancel"})]})}),tH=async e=>{if(!er.has(e)){en(t=>new Set([...t,e]));try{let t=await fetch("/api/models/test",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({model:`${tf}/${e}`})}),s=await t.json();ea(t=>({...t,[e]:s.ok?"ok":"error"})),s.ok||el(s.error||"Model not reachable")}catch{ea(t=>({...t,[e]:"error"}))}finally{en(t=>{let s=new Set(t);return s.delete(e),s})}}},tG=async e=>{if(eo)return;ed(!0);let t=[];try{for(let s=0;s<e.length;s+=5){let a=e.slice(s,s+5);await Promise.all(a.map(async e=>{en(t=>new Set([...t,e.id]));try{let s=await fetch("/api/models/test",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({model:`${tf}/${e.id}`})}),a=await s.json(),i=a.ok?"ok":"error";ea(t=>({...t,[e.id]:i})),a.ok&&t.push(e)}catch{ea(t=>({...t,[e.id]:"error"}))}finally{en(t=>{let s=new Set(t);return s.delete(e.id),s})}}))}for(let e of t)await tP(e.id,e.id,tf);t.length>0&&document.getElementById("available-models-section")?.scrollIntoView({behavior:"smooth"})}finally{ed(!1)}};if(g)return(0,a.jsxs)("div",{className:"flex flex-col gap-8",children:[(0,a.jsx)(d.Qv,{}),(0,a.jsx)(d.Qv,{})]});if(!te)return(0,a.jsxs)("div",{className:"text-center py-20",children:[(0,a.jsx)("p",{className:"text-text-muted",children:"Provider not found"}),(0,a.jsx)(n(),{href:"/dashboard/providers",className:"text-primary mt-4 inline-block",children:"Back to Providers"})]});let tQ=()=>tc&&te.apiType?"responses"===te.apiType?"/providers/oai-r.png":"/providers/oai-cc.png":tm?"/providers/anthropic-m.png":`/providers/${te.id}.png`;return(0,a.jsxs)("div",{className:"flex min-w-0 flex-col gap-6 px-1 sm:gap-8 sm:px-0",children:[tt?(0,a.jsx)(I,{capabilities:tt,connectionCount:u.length,headerIconPath:ee?null:tQ()}):(0,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsxs)(n(),{href:"/dashboard/providers",className:"inline-flex items-center gap-1 text-sm text-text-muted hover:text-primary transition-colors mb-4",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-lg",children:"arrow_back"}),"Back to Providers"]}),(0,a.jsxs)("div",{className:"flex min-w-0 items-center gap-3 sm:gap-4",children:[(0,a.jsx)("div",{className:"flex size-12 shrink-0 items-center justify-center rounded-lg",style:{backgroundColor:`${te.color}15`},children:ee?(0,a.jsx)("span",{className:"text-sm font-bold",style:{color:te.color},children:te.textIcon||te.id.slice(0,2).toUpperCase()}):(0,a.jsx)(o.default,{src:tQ(),alt:te.name,width:48,height:48,className:"max-h-12 max-w-12 rounded-lg object-contain",sizes:"48px",onError:()=>et(!0)})}),(0,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsx)("h1",{className:"truncate text-2xl font-semibold tracking-tight sm:text-3xl",children:te.name}),(0,a.jsxs)("p",{className:"text-text-muted",children:[u.length," connection",1===u.length?"":"s"]})]})]})]}),tp&&j&&(0,a.jsx)(d.Zp,{children:(0,a.jsxs)("div",{className:"mb-4 flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between",children:[(0,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsx)("h2",{className:"text-lg font-semibold",children:tm?"Anthropic Compatible Details":"OpenAI Compatible Details"}),(0,a.jsxs)("p",{className:"break-all text-sm text-text-muted",children:[tm?"Messages API":"responses"===j.apiType?"Responses API":"Chat Completions"," \xb7 ",(j.baseUrl||"").replace(/\/$/,""),"/",tm?"messages":"responses"===j.apiType?"responses":"chat/completions"]})]}),(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-2 sm:flex sm:items-center",children:[(0,a.jsx)(d.$n,{size:"sm",icon:"add",onClick:()=>{K(""),q(!0)},className:"w-full sm:w-auto",children:"Add API Key"}),(0,a.jsx)(d.$n,{size:"sm",variant:"secondary",icon:"edit",onClick:()=>V(!0),className:"w-full sm:w-auto",children:"Edit"}),(0,a.jsx)(d.$n,{size:"sm",variant:"secondary",icon:"delete",onClick:async()=>{eK({title:"Delete Compatible Node",message:`Delete this ${tm?"Anthropic":"OpenAI"} Compatible node?`,onConfirm:async()=>{eK(null);try{(await fetch(`/api/provider-nodes/${r}`,{method:"DELETE"})).ok&&s.push("/dashboard/providers")}catch(e){console.log("Error deleting provider node:",e)}}})},className:"w-full sm:w-auto",children:"Delete"})]})]})}),tn?(0,a.jsx)(d.gw,{providerId:r}):(0,a.jsxs)(d.Zp,{children:[(0,a.jsxs)("div",{className:"mb-4 flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[(0,a.jsx)("h2",{className:"text-lg font-semibold",children:"Connections"}),(0,a.jsxs)("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:gap-4",children:[u.length>0&&A.length>0&&(0,a.jsx)(d.$n,{size:"sm",variant:"secondary",icon:"lan",onClick:()=>G(!0),children:"Apply Proxy"}),ep.length>0&&(0,a.jsxs)(d.$n,{size:"sm",variant:"danger",icon:"delete",onClick:()=>{let e=ep.length;0!==e&&eK({title:`Delete ${e} Connection${e>1?"s":""}`,message:`Delete ${e} connection${e>1?"s":""}? This cannot be undone.`,onConfirm:async()=>{eK(null);let e=0,t=[...ep];for(let s of t)try{(await fetch(`/api/providers/${s}`,{method:"DELETE"})).ok||(e+=1)}catch(t){console.log("Error deleting connection:",t),e+=1}f(e=>e.filter(e=>!t.includes(e.id))),ex([]),e>0&&alert(`Deleted ${t.length-e} connection(s), ${e} failed.`)}})},children:["Delete Selected (",ep.length,")"]}),u.length>0&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(d.$n,{size:"sm",variant:"secondary",icon:"sync",onClick:tR,disabled:eJ,children:eJ?"Testing Connection One-by-One...":"Test Connection One-by-One"}),eJ&&(0,a.jsx)(d.$n,{size:"sm",variant:"ghost",icon:"stop",onClick:()=>{eJ&&(e0.current=!0,eV(!0))},disabled:eW,children:eW?"Stopping...":"Stop"})]}),(0,a.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,a.jsx)("span",{className:"text-xs text-text-muted font-medium",children:"Round Robin"}),(0,a.jsx)(d.lM,{checked:"round-robin"===eb,onChange:e=>{let t=e?"round-robin":null,s=e?ev||"1":ev;e&&!ev&&ej("1"),ey(t),tS(t,s)}}),"round-robin"===eb&&(0,a.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,a.jsx)("span",{className:"text-xs text-text-muted",children:"Sticky:"}),(0,a.jsx)("input",{type:"number",min:1,value:ev,onChange:e=>{var t;ej(t=e.target.value),tS("round-robin",t)},placeholder:"1",className:"w-14 px-2 py-1 text-xs border border-border rounded-md bg-background focus:outline-none focus:border-primary"})]})]})]})]}),0===u.length?tt?(0,a.jsx)(R,{capabilities:tt,onOAuth:e7,onApiKey:e8,onFree:e9,onCookie:()=>z(!0),onCompatible:e8,onBulkImport:()=>F(!0)}):(0,a.jsxs)("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[(0,a.jsxs)("div",{className:"flex items-center gap-3",children:[(0,a.jsx)("div",{className:"inline-flex items-center justify-center w-9 h-9 rounded-full bg-primary/10 text-primary shrink-0",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:"key"})}),(0,a.jsx)("p",{className:"text-sm text-text-muted",children:"No connections yet"})]}),(0,a.jsx)(d.$n,{size:"sm",icon:"add",onClick:e9,children:"Add API Key"})]}):(0,a.jsxs)(a.Fragment,{children:[eY&&(0,a.jsx)("div",{className:"mb-4 rounded-lg border border-black/10 bg-black/[0.02] px-3 py-2 text-xs text-text-muted dark:border-white/10 dark:bg-white/[0.03]",children:(0,a.jsxs)("div",{className:"flex flex-wrap items-center gap-3",children:[(0,a.jsxs)("span",{children:["Total: ",eY.total]}),(0,a.jsxs)("span",{children:["Completed: ",eY.completed]}),(0,a.jsxs)("span",{children:["Passed: ",eY.passed]}),(0,a.jsxs)("span",{children:["Failed: ",eY.failed]}),eY.stopped&&(0,a.jsx)("span",{className:"text-amber-600 dark:text-amber-400",children:"Stopped"}),eJ&&eH&&(0,a.jsxs)("span",{children:["Running: ",u.find(e=>e.id===eH)?.name||eH]})]})}),!tp&&tt&&(0,a.jsx)(D,{providerId:r,models:e$}),tB,!tp&&tt&&(0,a.jsx)(_,{providerId:r}),!tp&&(0,a.jsxs)("div",{className:"mt-4 grid grid-cols-1 gap-2 sm:flex",children:["iflow"===r&&(0,a.jsx)(d.$n,{size:"sm",icon:"cookie",variant:"secondary",onClick:()=>z(!0),title:"Add connection using browser cookie",className:"w-full sm:w-auto",children:"Cookie"}),"codex"===r&&(0,a.jsx)(d.$n,{size:"sm",icon:"playlist_add",variant:"secondary",onClick:()=>F(!0),title:(0,x.Tl)("Bulk import codex accounts from JSON"),className:"w-full sm:w-auto",children:(0,x.Tl)("Bulk Add")}),tx?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(d.$n,{size:"sm",icon:"lock",variant:"secondary",onClick:e7,className:"w-full sm:w-auto",children:tu}),(0,a.jsx)(d.$n,{size:"sm",icon:"key",onClick:e8,className:"w-full sm:w-auto",children:th})]}):(0,a.jsx)(d.$n,{size:"sm",icon:"add",onClick:e9,className:"w-full sm:w-auto",children:"Add"})]})]})]}),(0,a.jsxs)(d.Zp,{id:"available-models-section",children:[(0,a.jsxs)("div",{className:"mb-4 flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between",children:[(0,a.jsx)("h2",{className:"text-lg font-semibold",children:"Available Models"}),!tp&&(e=[...to,...e_.filter(e=>!to.some(t=>t.id===e.id))].filter(e=>!e.type||"llm"===e.type).map(e=>e.id).filter(e=>!eU.includes(e)),(0,a.jsxs)("div",{className:"flex gap-2",children:[eU.length>0&&(0,a.jsx)(d.$n,{size:"sm",variant:"secondary",icon:"restart_alt",onClick:tN,children:"Active All"}),e.length>0&&(0,a.jsx)(d.$n,{size:"sm",variant:"secondary",icon:"block",onClick:()=>tj(e),children:"Disable All"})]}))]}),!!ei&&(0,a.jsx)("p",{className:"text-xs text-red-500 mb-3 break-words",children:ei}),(()=>{if(tp)return(0,a.jsx)(v,{providerStorageAlias:tf,providerDisplayAlias:tg,modelAliases:Y,copied:e2,onCopy:e4,onSetAlias:tP,onDeleteAlias:tO,connections:u,isAnthropic:tm});let e=[...to,...e_.filter(e=>!to.some(t=>t.id===e.id))].filter(e=>!e.type||"llm"===e.type),t=new Set(eU),s=e.filter(e=>!t.has(e.id)),i=e.filter(e=>t.has(e.id)),l=Object.entries(Y).filter(([e,t])=>{let s=`${tf}/`;if(!t.startsWith(s))return!1;let a=t.slice(s.length);return te.passthroughModels?!to.some(e=>e.id===a):!to.some(e=>e.id===a)&&e===a}).map(([e,t])=>({id:t.slice(`${tf}/`.length),alias:e,fullModel:t}));return(0,a.jsxs)("div",{className:"flex flex-wrap gap-3",children:[l.map(e=>(0,a.jsx)(b,{model:{id:e.id},fullModel:`${tg}/${e.id}`,alias:e.alias,copied:e2,onCopy:e4,onSetAlias:()=>{},onDeleteAlias:()=>tO(e.alias),testStatus:es[e.id],onTest:u.length>0||tn?()=>tH(e.id):void 0,isTesting:er.has(e.id),isCustom:!0,isFree:!1},e.id)),s.map(e=>{let t=`${tf}/${e.id}`,s=`${r}/${e.id}`,i=Object.entries(Y).find(([,e])=>e===t||e===s)?.[0];return(0,a.jsx)(b,{model:e,fullModel:`${tg}/${e.id}`,alias:i,copied:e2,onCopy:e4,onSetAlias:t=>tP(e.id,t,tf),onDeleteAlias:()=>tO(i),testStatus:es[e.id],onTest:u.length>0||tn?()=>tH(e.id):void 0,isTesting:er.has(e.id),isFree:e.isFree,onDisable:()=>ty(e.id)},e.id)}),(0,a.jsxs)("button",{onClick:()=>em(!0),className:"flex w-full items-center justify-center gap-1.5 rounded-lg border border-dashed border-primary/40 px-3 py-2 text-xs text-primary transition-colors hover:border-primary hover:bg-primary/5 sm:w-auto",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-sm",children:"add"}),"Add Model"]}),"qoder"===r&&u.some(e=>!1!==e.isActive)&&(0,a.jsxs)("button",{onClick:tE,disabled:e1,className:"flex w-full items-center justify-center gap-1.5 rounded-lg border border-dashed border-blue-500/40 px-3 py-2 text-xs text-blue-600 dark:text-blue-400 transition-colors hover:border-blue-500 hover:bg-blue-500/5 sm:w-auto disabled:opacity-50 disabled:cursor-not-allowed",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-sm",style:e1?{animation:"spin 1s linear infinite"}:void 0,children:e1?"progress_activity":"download"}),e1?(0,x.Tl)("Fetching..."):(0,x.Tl)("Fetch Qoder Models")]}),(()=>{let e=new Set([...s.map(e=>e.id),...l.map(e=>e.id)]),t=e$.length>0?e$:eS,r=e$.length>0,n=t.filter(t=>t.id&&!e.has(t.id)),o=new Set(e$.map(e=>e.id).filter(Boolean)),d=i.filter(e=>e.id&&!o.has(e.id)).map(e=>({...e,dropped:!0})),c=new Set(d.map(e=>e.id)),m=[...n.filter(e=>!c.has(e.id)),...d];if(!eI&&0===m.length&&0===t.length)return null;let p=eO.trim().toLowerCase(),x=p?m.filter(e=>e.id.toLowerCase().includes(p)||e.name&&e.name.toLowerCase().includes(p)):m,u={};x.forEach(e=>{if(!e.id)return;let t=e.id.includes("/")?e.id.split("/")[0]:"models";u[t]||(u[t]=[]),u[t].push(e)});let h=Object.entries(u).sort((e,t)=>t[1].length-e[1].length),f=x.filter(e=>!e.dropped).slice(0,50);return(0,a.jsxs)("div",{className:"w-full mt-4 space-y-2",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("span",{className:"text-xs font-medium text-text-muted shrink-0",children:eI?"Loading...":`${r?"From API":"Suggested"} (${n.length})${d.length>0?` \xb7 ${d.length} dropped`:""}`}),(0,a.jsxs)("div",{className:"relative flex-1 min-w-0",children:[(0,a.jsx)("span",{className:"material-symbols-outlined absolute left-2.5 top-1/2 -translate-y-1/2 text-[13px] text-text-muted/60 pointer-events-none select-none",children:"search"}),(0,a.jsx)("input",{type:"text",value:eO,onChange:e=>eE(e.target.value),placeholder:"Search models...",className:"w-full h-7 pl-7 pr-7 text-xs rounded-lg bg-bg border border-border-subtle text-text-main placeholder:text-text-muted/50 focus:outline-none focus:ring-1 focus:ring-primary/30 focus:border-primary/40 transition-colors"}),eO&&(0,a.jsx)("button",{onClick:()=>eE(""),className:"absolute right-2 top-1/2 -translate-y-1/2 text-text-muted/50 hover:text-text-muted transition-colors",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[13px]",children:"close"})})]}),(0,a.jsx)("button",{onClick:tI,disabled:eI,title:"Refresh",className:"shrink-0 h-7 w-7 flex items-center justify-center rounded-lg border border-border-subtle text-text-muted hover:text-primary hover:border-primary/40 hover:bg-primary/5 transition-colors disabled:opacity-40",children:(0,a.jsx)("span",{className:`material-symbols-outlined text-[14px] ${eI?"animate-spin":""}`,children:"refresh"})}),!eI&&f.length>0&&(0,a.jsxs)("button",{onClick:()=>tG(f),disabled:eo,title:`Test up to ${f.length} models and auto-add passing ones`,className:"shrink-0 h-7 flex items-center gap-1 px-2.5 rounded-lg border border-border-subtle text-xs text-text-muted hover:text-green-600 hover:border-green-500/40 hover:bg-green-500/5 transition-colors disabled:opacity-40",children:[(0,a.jsx)("span",{className:`material-symbols-outlined text-[13px] ${eo?"animate-spin":""}`,children:eo?"progress_activity":"play_circle"}),eo?"Testing...":"Test All"]})]}),p&&(0,a.jsxs)("p",{className:"text-xs text-text-muted",children:[x.length," result",1!==x.length?"s":""]}),eI?(0,a.jsxs)("div",{className:"flex items-center gap-2 py-4 text-xs text-text-muted",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[15px] animate-spin",children:"progress_activity"}),"Fetching models from provider API..."]}):0===h.length?p?(0,a.jsxs)("p",{className:"text-xs text-text-muted py-2",children:['No models match "',eO,'"']}):null:(0,a.jsx)("div",{className:"space-y-1",children:h.map(([e,t])=>{let s=eR.has(e),i=t.filter(e=>!e.dropped&&"ok"===es[e.id]).length,l=t.filter(e=>!e.dropped&&"error"===es[e.id]).length,r=t.filter(e=>e.dropped).length;return(0,a.jsxs)("div",{className:"rounded-xl border border-border-subtle overflow-hidden",children:[(0,a.jsxs)("button",{onClick:()=>eD(t=>{let s=new Set(t);return s.has(e)?s.delete(e):s.add(e),s}),className:"w-full flex items-center gap-2 px-3 py-2 text-xs bg-bg hover:bg-surface-2/60 transition-colors text-left",children:[(0,a.jsx)("span",{className:"font-semibold text-text-main flex-1",children:e}),i>0&&(0,a.jsxs)("span",{className:"text-green-600 dark:text-green-400 font-medium",children:[i," ✓"]}),l>0&&(0,a.jsxs)("span",{className:"text-red-500 font-medium",children:[l," ✗"]}),r>0&&(0,a.jsxs)("span",{className:"px-1.5 py-0.5 rounded-md bg-amber-500/10 text-amber-600 dark:text-amber-400 text-[10px] font-medium",children:[r," dropped"]}),(0,a.jsx)("span",{className:"px-1.5 py-0.5 rounded-md bg-black/[0.06] dark:bg-white/[0.06] text-text-muted tabular-nums font-medium",children:t.length}),(0,a.jsx)("span",{className:"material-symbols-outlined text-[15px] text-text-muted/60",children:s?"expand_less":"expand_more"})]}),s&&(0,a.jsx)("div",{className:"px-3 pt-2 pb-3 flex flex-wrap gap-1.5 border-t border-border-subtle bg-surface/50",children:t.map(e=>{let t=e.id.includes("/")?e.id.split("/").slice(1).join("/"):e.id,s=es[e.id],i=er.has(e.id);return e.dropped?(0,a.jsxs)("button",{onClick:async()=>{await tv(e.id),document.getElementById("available-models-section")?.scrollIntoView({behavior:"smooth"})},title:`Recently Dropped — click to restore: ${e.id}`,className:"group flex items-center gap-1 px-2.5 py-1.5 rounded-lg border border-amber-400/40 bg-amber-500/5 text-amber-700 dark:text-amber-400 text-xs hover:bg-amber-500/10 hover:border-amber-400/60 transition-colors",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[12px]",children:"history"}),(0,a.jsx)("span",{children:t}),e.contextLength>0&&(0,a.jsxs)("span",{className:"opacity-50 text-[10px] ml-0.5",children:[(e.contextLength/1e3).toFixed(0),"k"]})]},e.id):(0,a.jsxs)("button",{onClick:async()=>{await tP(e.id,e.id,tf),document.getElementById("available-models-section")?.scrollIntoView({behavior:"smooth"})},title:`Add: ${e.name||e.id}`,className:["group flex items-center gap-1 px-2.5 py-1.5 rounded-lg border text-xs transition-colors","ok"===s?"border-green-500/30 bg-green-500/5 text-green-700 dark:text-green-400 hover:bg-green-500/10":"error"===s?"border-red-400/30 bg-red-500/5 text-red-600 dark:text-red-400 hover:bg-red-500/10":"border-border-subtle text-text-muted hover:text-primary hover:border-primary/40 hover:bg-primary/5"].join(" "),children:[i?(0,a.jsx)("span",{className:"material-symbols-outlined text-[12px] animate-spin",children:"progress_activity"}):"ok"===s?(0,a.jsx)("span",{className:"material-symbols-outlined text-[12px]",children:"check"}):"error"===s?(0,a.jsx)("span",{className:"material-symbols-outlined text-[12px]",children:"close"}):(0,a.jsx)("span",{className:"material-symbols-outlined text-[12px] opacity-50 group-hover:opacity-100",children:"add"}),(0,a.jsx)("span",{children:t}),e.contextLength>0&&(0,a.jsxs)("span",{className:"opacity-40 text-[10px] ml-0.5",children:[(e.contextLength/1e3).toFixed(0),"k"]})]},e.id)})})]},e)})})]})})()]})})()]}),tV,"kiro"===r?(0,a.jsx)(d.Mh,{isOpen:P,providerInfo:te,onSuccess:t_,onClose:()=>O(!1)}):"cursor"===r?(0,a.jsx)(d.G9,{isOpen:P,onSuccess:t_,onClose:()=>O(!1)}):"gitlab"===r?(0,a.jsx)(d.vj,{isOpen:P,providerInfo:te,onSuccess:t_,onClose:()=>O(!1)}):(0,a.jsx)(d.LF,{isOpen:P,provider:r,providerInfo:te,onSuccess:t_,onClose:()=>O(!1)}),"iflow"===r&&(0,a.jsx)(d.vE,{isOpen:E,onSuccess:()=>{tk(),z(!1)},onClose:()=>z(!1)}),(0,a.jsx)(k,{isOpen:U,provider:r,providerName:te.name,isCompatible:tp,isAnthropic:tm,authType:te?.authType,authHint:te?.authHint,website:te?.website,proxyPools:A,error:M,existingNames:u.map(e=>e.name).filter(Boolean),onSave:tz,onBulkDone:tk,onClose:()=>{K(""),q(!1)}}),(0,a.jsx)(d.wI,{isOpen:J,connection:Q,proxyPools:A,onSave:tU,onClose:()=>B(!1)}),tp&&(0,a.jsx)(C,{isOpen:W,node:j,onSave:tC,onClose:()=>V(!1),isAnthropic:tm}),!tp&&(0,a.jsx)(S,{isOpen:ec,providerAlias:tf,providerDisplayAlias:tg,onSave:async e=>{let t=te?.passthroughModels?e.split("/").pop():e;await tP(e,t,tf),em(!1)},onClose:()=>em(!1)}),"codex"===r&&(0,a.jsx)($,{isOpen:L,onClose:()=>F(!1),onSuccess:tk}),(0,a.jsx)(d.uo,{isOpen:eL,onClose:()=>eF(!1),onConfirm:()=>{(window.localStorage.setItem(e3,"true"),eF(!1),tl)?e6():e8()},title:"Risk Notice",message:te?.deprecationNotice,confirmText:"I Understand, Continue",cancelText:"Cancel",variant:"danger"}),(0,a.jsx)(d.uo,{isOpen:!!eM,onClose:()=>eK(null),onConfirm:eM?.onConfirm,title:eM?.title||"Confirm",message:eM?.message,variant:"danger"})]})}R.propTypes={capabilities:g().object,onOAuth:g().func,onApiKey:g().func,onFree:g().func,onCookie:g().func,onCompatible:g().func,onBulkImport:g().func},D.propTypes={providerId:g().string.isRequired,models:g().array},_.propTypes={providerId:g().string.isRequired}}},e=>{e.O(0,[7504,5772,1321,5497,8441,3794,7358],()=>e(e.s=76487)),_N_E=e.O()}]);
|
|
11
|
+
]`;function $({isOpen:e,onClose:t,onSuccess:s}){let[l,r]=(0,i.useState)(""),[n,o]=(0,i.useState)(!1),[c,m]=(0,i.useState)(""),[p,u]=(0,i.useState)(null),h=()=>{n||(r(""),m(""),u(null),t())},f=async()=>{var e;let t;m(""),u(null);let a=l.trim();if(!a)return;try{t=JSON.parse(a)}catch(e){m(`${(0,x.Tl)("Invalid JSON")}: ${e.message}`);return}let i=Array.isArray(e=t)?e:e&&"object"==typeof e?Array.isArray(e.accounts)?e.accounts:[e]:null;if(!i||0===i.length)return void m((0,x.Tl)("No accounts found in input"));o(!0);try{let e=await fetch("/api/oauth/codex/bulk-import",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({accounts:i})}),t=await e.json();if(!e.ok)return void m(t?.error||`Request failed: ${e.status}`);u(t),t.success>0&&"function"==typeof s&&s()}catch(e){m(e.message||(0,x.Tl)("Request failed"))}finally{o(!1)}},g=p?.results?.filter(e=>!e.ok)||[];return(0,a.jsx)(d.aF,{isOpen:e,title:(0,x.Tl)("Bulk Add Codex Accounts"),onClose:h,children:(0,a.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,a.jsx)("p",{className:"text-xs text-text-muted",children:(0,x.Tl)("Paste an array of codex account JSON objects. Each must include accessToken (and ideally refreshToken, idToken).")}),(0,a.jsx)("textarea",{className:"w-full rounded border border-accent/30 bg-sidebar p-2 text-sm font-mono resize-y min-h-[240px] focus:outline-none focus:ring-1 focus:ring-primary",placeholder:A,value:l,onChange:e=>r(e.target.value),disabled:n}),c&&(0,a.jsx)("p",{className:"text-xs text-red-500 break-words",children:c}),p&&(0,a.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,a.jsxs)("div",{className:`text-sm font-medium ${p.failed>0?"text-yellow-400":"text-green-400"}`,children:["✓ ",p.success," ",(0,x.Tl)("added"),p.failed>0?`, ✗ ${p.failed} ${(0,x.Tl)("failed")}`:""]}),g.length>0&&(0,a.jsx)("ul",{className:"rounded border border-accent/20 bg-sidebar/50 p-2 text-xs font-mono max-h-40 overflow-y-auto",children:g.map(e=>(0,a.jsxs)("li",{className:"text-red-400",children:["[",e.index,"] ",e.error]},e.index))})]}),(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsx)(d.$n,{onClick:f,fullWidth:!0,disabled:n||!l.trim(),children:n?(0,x.Tl)("Importing..."):(0,x.Tl)("Import All")}),(0,a.jsx)(d.$n,{onClick:h,variant:"ghost",fullWidth:!0,disabled:n,children:(0,x.Tl)("Close")})]})]})})}$.propTypes={isOpen:g().bool.isRequired,onClose:g().func.isRequired,onSuccess:g().func};let T={free:{label:"Free",variant:"success",accent:"green"},freetier:{label:"Free tier",variant:"success",accent:"emerald"},oauth:{label:"OAuth",variant:"primary",accent:"primary"},paid:{label:"API key",variant:"default",accent:"neutral"},webcookie:{label:"Cookie",variant:"warning",accent:"amber"}};function I({capabilities:e,connectionCount:t=0,headerIconPath:s}){let[l,r]=(0,i.useState)(!1);if(!e)return null;let c=T[e.tier]||T.paid,m=e.color?`${e.color}10`:"rgba(148,163,184,0.08)",p=e.color?`${e.color}30`:"rgba(148,163,184,0.20)",x=[];return e.links.apiKey&&x.push({href:e.links.apiKey,icon:"key",label:"Get API key"}),e.links.signup&&!e.links.apiKey&&x.push({href:e.links.signup,icon:"person_add",label:"Sign up"}),e.links.homepage&&x.push({href:e.links.homepage,icon:"language",label:"Homepage"}),e.links.docs&&x.push({href:e.links.docs,icon:"menu_book",label:"Docs"}),e.links.pricing&&x.push({href:e.links.pricing,icon:"sell",label:"Pricing"}),(0,a.jsxs)("div",{className:"flex min-w-0 flex-col gap-4",children:[(0,a.jsxs)(n(),{href:"/dashboard/providers",className:"inline-flex items-center gap-1 text-sm text-text-muted hover:text-primary transition-colors",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-lg",children:"arrow_back"}),"Back to Providers"]}),(0,a.jsxs)("div",{className:"relative overflow-hidden rounded-2xl border p-5 sm:p-7",style:{borderColor:p,background:`linear-gradient(140deg, ${m} 0%, transparent 55%)`},children:[(0,a.jsxs)("div",{className:"flex min-w-0 flex-col gap-5 sm:flex-row sm:items-start sm:justify-between",children:[(0,a.jsxs)("div",{className:"flex min-w-0 items-start gap-4",children:[(0,a.jsx)("div",{className:"flex size-14 shrink-0 items-center justify-center rounded-xl shadow-sm",style:{backgroundColor:e.color?`${e.color}20`:"rgba(148,163,184,0.15)"},children:l||!s?(0,a.jsx)("span",{className:"text-base font-bold",style:{color:e.color||"inherit"},children:e.textIcon||e.id.slice(0,2).toUpperCase()}):(0,a.jsx)(o.default,{src:s,alt:e.name,width:56,height:56,className:"max-h-14 max-w-14 rounded-xl object-contain",sizes:"56px",onError:()=>r(!0)})}),(0,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,a.jsx)("h1",{className:"truncate text-2xl font-semibold tracking-tight sm:text-3xl",children:e.name}),(0,a.jsx)(d.Ex,{variant:c.variant,size:"sm",children:c.label}),e.deprecated&&(0,a.jsx)(d.Ex,{variant:"warning",size:"sm",children:"deprecated"})]}),(0,a.jsxs)("p",{className:"mt-1 text-sm text-text-muted",children:[t," connection",1===t?"":"s",e.serviceKinds.length>1&&(0,a.jsxs)(a.Fragment,{children:[" \xb7 ",e.serviceKinds.join(" \xb7 ")]})]})]})]}),x.length>0&&(0,a.jsx)("div",{className:"flex flex-wrap gap-1.5 sm:justify-end",children:x.map(e=>(0,a.jsxs)("a",{href:e.href,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 rounded-full border border-border bg-bg/60 px-2.5 py-1 text-xs text-text-main hover:border-primary hover:text-primary transition-colors backdrop-blur",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-sm",children:e.icon}),e.label]},e.label))})]}),e.notices.body&&!e.deprecated&&(0,a.jsx)("p",{className:"mt-4 max-w-3xl text-sm leading-relaxed text-text-muted",children:e.notices.body})]}),e.deprecated&&e.notices.warning&&(0,a.jsxs)("div",{className:"flex items-start gap-2 rounded-lg border border-yellow-500/30 bg-yellow-500/10 px-3 py-2",children:[(0,a.jsx)("span",{className:"material-symbols-outlined mt-0.5 shrink-0 text-[16px] text-yellow-500",children:"warning"}),(0,a.jsx)("p",{className:"text-xs leading-relaxed text-red-600 dark:text-yellow-400",children:e.notices.warning})]})]})}I.propTypes={capabilities:g().object,connectionCount:g().number,headerIconPath:g().string};let P={oauth:{icon:"lock",label:"Sign in with OAuth",tabLabel:"OAuth"},apikey:{icon:"key",label:"Add API key",tabLabel:"API key"},free:{icon:"bolt",label:"Connect for free",tabLabel:"Free"},cookie:{icon:"cookie",label:"Paste session cookie",tabLabel:"Cookie"},compatible:{icon:"developer_board",label:"Configure endpoint",tabLabel:"Compatible"}};function O({children:e,accentColor:t}){return(0,a.jsx)("div",{className:"rounded-xl border p-5 sm:p-6",style:{borderColor:t?`${t}25`:void 0,background:t?`linear-gradient(160deg, ${t}08, transparent 70%)`:void 0},children:e})}let E={oauth:function({capabilities:e,onOAuth:t,onBulkImport:s}){return(0,a.jsx)(O,{accentColor:e.color,children:(0,a.jsxs)("div",{className:"flex flex-col gap-4 sm:flex-row sm:items-center sm:justify-between",children:[(0,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsxs)("h3",{className:"text-base font-semibold",children:["Sign in with ",e.name]}),(0,a.jsx)("p",{className:"mt-0.5 text-sm text-text-muted",children:"One click. We handle the OAuth callback and store your session locally. You can add multiple accounts."})]}),(0,a.jsxs)("div",{className:"flex flex-wrap gap-2 sm:flex-nowrap",children:[e.features.bulkImport&&s&&(0,a.jsx)(d.$n,{size:"md",icon:"playlist_add",variant:"secondary",onClick:s,children:"Bulk import"}),(0,a.jsxs)(d.$n,{size:"md",icon:"lock",onClick:t,children:["Sign in with ",e.name]})]})]})})},apikey:function({capabilities:e,onApiKey:t}){return(0,a.jsx)(O,{accentColor:e.color,children:(0,a.jsxs)("div",{className:"flex flex-col gap-4 sm:flex-row sm:items-center sm:justify-between",children:[(0,a.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,a.jsxs)("h3",{className:"text-base font-semibold",children:["Paste your ",e.name," API key"]}),(0,a.jsxs)("p",{className:"mt-0.5 text-sm text-text-muted",children:[e.links.apiKey?(0,a.jsxs)(a.Fragment,{children:["Grab a key from"," ",(0,a.jsx)("a",{href:e.links.apiKey,target:"_blank",rel:"noopener noreferrer",className:"text-primary underline decoration-primary/40 underline-offset-4 hover:decoration-primary",children:new URL(e.links.apiKey).hostname})," ","and paste it in."]}):(0,a.jsx)(a.Fragment,{children:"Paste your API key to connect."})," ","Stored locally, never sent anywhere except ",e.name,"."]})]}),(0,a.jsx)(d.$n,{size:"md",icon:"key",onClick:t,children:"Add API key"})]})})},free:function({capabilities:e,onFree:t}){return(0,a.jsx)(O,{accentColor:e.color||"#10B981",children:(0,a.jsxs)("div",{className:"flex flex-col gap-4 sm:flex-row sm:items-center sm:justify-between",children:[(0,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsxs)("div",{className:"mb-1 flex items-center gap-2",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px] text-green-500",children:"bolt"}),(0,a.jsxs)("h3",{className:"text-base font-semibold",children:[e.name," is free — one click to connect"]})]}),(0,a.jsx)("p",{className:"text-sm text-text-muted",children:"No key, no signup, no card. Just click connect and start using it."})]}),(0,a.jsx)(d.$n,{size:"md",icon:"add",onClick:t,children:"Connect"})]})})},cookie:function({capabilities:e,onCookie:t}){let[s,l]=(0,i.useState)(!1);return(0,a.jsx)(O,{accentColor:e.color||"#F59E0B",children:(0,a.jsxs)("div",{className:"flex flex-col gap-3",children:[(0,a.jsxs)("div",{className:"flex items-start justify-between gap-3",children:[(0,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsx)("h3",{className:"text-base font-semibold",children:"Advanced: connect with session cookie"}),(0,a.jsxs)("p",{className:"mt-0.5 text-sm text-text-muted",children:["For power users. Extract the ",e.name," cookie from your browser and paste it here."]})]}),(0,a.jsx)("button",{type:"button",onClick:()=>l(e=>!e),className:"text-xs text-text-muted hover:text-primary",children:s?"hide":"show"})]}),s&&(0,a.jsxs)("div",{className:"rounded-lg border border-border bg-bg/70 p-3",children:[(0,a.jsxs)("ol",{className:"mb-3 list-decimal space-y-1 pl-4 text-xs text-text-muted",children:[(0,a.jsxs)("li",{children:["Open ",e.name," in your browser and sign in."]}),(0,a.jsx)("li",{children:"Open DevTools → Application → Cookies."}),(0,a.jsx)("li",{children:"Copy the session cookie value."}),(0,a.jsx)("li",{children:"Paste it in the modal."})]}),(0,a.jsx)(d.$n,{size:"sm",icon:"cookie",onClick:t,children:"Paste cookie"})]})]})})},compatible:function({capabilities:e,onCompatible:t}){return(0,a.jsx)(O,{accentColor:e.color,children:(0,a.jsxs)("div",{className:"flex flex-col gap-4 sm:flex-row sm:items-center sm:justify-between",children:[(0,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsx)("h3",{className:"text-base font-semibold",children:"Use as OpenAI-compatible endpoint"}),(0,a.jsx)("p",{className:"mt-0.5 text-sm text-text-muted",children:"Point at any OpenAI-shaped base URL (self-hosted, LiteLLM, custom proxy). Fetches the live model list after you connect."})]}),(0,a.jsx)(d.$n,{size:"md",icon:"developer_board",onClick:t,children:"Configure endpoint"})]})})}};function R({capabilities:e,onOAuth:t,onApiKey:s,onFree:l,onCookie:r,onCompatible:n,onBulkImport:o}){let d=e?.authModes||[],[c,m]=(0,i.useState)(d[0]||"apikey");if(!e||0===d.length)return null;let p=E[c]||E.apikey,x=d.length>1;return(0,a.jsxs)("div",{className:"flex min-w-0 flex-col gap-3",children:[x&&(0,a.jsx)("div",{className:"flex flex-wrap gap-1 rounded-lg border border-border bg-sidebar/40 p-1",children:d.map(e=>{let t=P[e]||{icon:"add",tabLabel:e},s=e===c;return(0,a.jsxs)("button",{type:"button",onClick:()=>m(e),className:`inline-flex items-center gap-1.5 rounded-md px-3 py-1.5 text-xs font-medium transition-colors ${s?"bg-bg text-text-main shadow-sm":"text-text-muted hover:text-text-main"}`,children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-sm",children:t.icon}),t.tabLabel]},e)})}),(0,a.jsx)(p,{capabilities:e,onOAuth:t,onApiKey:s,onFree:l,onCookie:r,onCompatible:n,onBulkImport:o})]})}function D({providerId:e,models:t=[]}){let[s,l]=(0,i.useState)(""),[r,n]=(0,i.useState)({status:"idle"}),o=(0,i.useCallback)(async()=>{if(e){n(e=>({...e,status:"ok"===e.status?"refreshing":"loading"}));try{let t=new URLSearchParams({providerId:e});s&&t.set("model",s);let a=await fetch(`/api/providers/zenith?${t.toString()}`,{cache:"no-store"}),i=await a.json();i.success?n({status:"ok",winner:i.winner,count:i.count,leaderboard:i.leaderboard}):n({status:"error",error:i.error||"Zenith read failed"})}catch(e){n({status:"error",error:e?.message||"Network error"})}}},[e,s]);if((0,i.useEffect)(()=>{o();let e=setInterval(o,1e4);return()=>clearInterval(e)},[o]),"idle"===r.status||"loading"===r.status||"error"===r.status||!r.winner||(r.count??0)<2)return null;let d=r.winner;return(0,a.jsxs)("div",{className:"mb-3 flex flex-wrap items-center gap-2 rounded-lg border border-primary/20 bg-primary/[0.04] px-3 py-2 text-xs",children:[(0,a.jsxs)("span",{className:"inline-flex items-center gap-1 text-primary font-medium",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-sm",children:"route"}),"Next request →"]}),(0,a.jsx)("span",{className:"font-medium text-text-main",children:d.name}),(0,a.jsxs)("span",{className:"rounded-md border border-primary/30 bg-primary/10 px-1.5 py-0.5 font-mono text-[10px] text-primary",children:["Z:",d.finalScore]}),(0,a.jsxs)("span",{className:"text-text-muted",children:["health ",d.healthScore," \xb7 quota \xd7",d.quotaFactor," \xb7 priority +",d.priorityBonus]}),t.length>0&&(0,a.jsxs)("div",{className:"ml-auto flex items-center gap-1.5",children:[(0,a.jsx)("span",{className:"text-text-muted",children:"Model:"}),(0,a.jsxs)("select",{value:s,onChange:e=>l(e.target.value),className:"rounded-md border border-border bg-bg px-1.5 py-0.5 text-[11px] focus:outline-none focus:border-primary",children:[(0,a.jsx)("option",{value:"",children:"(any)"}),t.map(e=>(0,a.jsx)("option",{value:e.id,children:e.id},e.id))]})]})]})}function _({providerId:e}){let[t,s]=(0,i.useState)(!1),[l,r]=(0,i.useState)([]),[n,o]=(0,i.useState)(!1),d=(0,i.useCallback)(async()=>{if(e){o(!0);try{let t=await fetch(`/api/providers/zenith/log?providerId=${e}&limit=50`,{cache:"no-store"}),s=await t.json();s.success&&r(s.entries||[])}catch{}finally{o(!1)}}},[e]);return(0,i.useEffect)(()=>{if(!t)return;d();let e=setInterval(d,5e3);return()=>clearInterval(e)},[t,d]),(0,a.jsxs)("div",{className:"mt-4 rounded-lg border border-border",children:[(0,a.jsxs)("button",{type:"button",onClick:()=>s(e=>!e),className:"flex w-full items-center justify-between px-3 py-2 text-xs text-text-muted hover:text-text-main",children:[(0,a.jsxs)("span",{className:"inline-flex items-center gap-1.5",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-sm",children:"history"}),"Routing decisions",l.length>0&&(0,a.jsxs)("span",{className:"text-text-muted",children:["(",l.length,")"]})]}),(0,a.jsx)("span",{className:"material-symbols-outlined text-sm",children:t?"expand_less":"expand_more"})]}),t&&(0,a.jsxs)("div",{className:"max-h-64 overflow-y-auto border-t border-border/50 px-3 py-2",children:[n&&0===l.length&&(0,a.jsx)("p",{className:"text-xs text-text-muted",children:"Loading…"}),!n&&0===l.length&&(0,a.jsx)("p",{className:"text-xs text-text-muted",children:"No decisions recorded yet. Fire a request through kRouter to populate."}),(0,a.jsx)("ul",{className:"space-y-1",children:l.map((e,t)=>(0,a.jsxs)("li",{className:"flex flex-wrap items-center gap-2 border-b border-border/30 py-1 text-[11px] font-mono last:border-0",children:[(0,a.jsx)("span",{className:"text-text-muted",children:function(e){let t=Math.floor((Date.now()-e)/1e3);if(t<5)return"just now";if(t<60)return`${t}s ago`;let s=Math.floor(t/60);return s<60?`${s}m ago`:`${Math.floor(s/60)}h ago`}(e.at)}),e.model&&(0,a.jsx)("span",{className:"text-text-main",children:e.model}),(0,a.jsx)("span",{className:"text-text-muted",children:"→"}),(0,a.jsx)("span",{className:"text-text-main",children:e.connectionId.slice(0,8)}),null!=e.score&&(0,a.jsxs)("span",{className:"text-primary",children:["Z:",e.score]}),null!=e.latencyMs&&(0,a.jsxs)("span",{className:"text-text-muted",children:[e.latencyMs,"ms"]}),(0,a.jsx)("span",{className:e.success?"text-green-500":"text-red-500",children:e.success?"✓":"✗"})]},`${e.at}-${t}`))})]})]})}function z(){let e,t=(0,l.useParams)(),s=(0,l.useRouter)(),r=t.id,[u,f]=(0,i.useState)([]),[g,y]=(0,i.useState)(!0),[j,w]=(0,i.useState)(null),[A,T]=(0,i.useState)([]),[P,O]=(0,i.useState)(!1),[E,z]=(0,i.useState)(!1),[U,q]=(0,i.useState)(!1),[M,K]=(0,i.useState)(""),[L,F]=(0,i.useState)(!1),[J,B]=(0,i.useState)(!1),[W,V]=(0,i.useState)(!1),[H,G]=(0,i.useState)(!1),[Q,Z]=(0,i.useState)(null),[Y,X]=(0,i.useState)({}),[ee,et]=(0,i.useState)(!1),[es,ea]=(0,i.useState)({}),[ei,el]=(0,i.useState)(""),[er,en]=(0,i.useState)(new Set),[eo,ed]=(0,i.useState)(!1),[ec,em]=(0,i.useState)(!1),[ep,ex]=(0,i.useState)([]),[eu,eh]=(0,i.useState)("__none__"),[ef,eg]=(0,i.useState)(!1),[eb,ey]=(0,i.useState)(null),[ev,ej]=(0,i.useState)(""),[eN,ew]=(0,i.useState)("auto"),[ek,eC]=(0,i.useState)({enabled:!1,connections:{}}),[eS,eA]=(0,i.useState)([]),[e$,eT]=(0,i.useState)([]),[eI,eP]=(0,i.useState)(!1),[eO,eE]=(0,i.useState)(""),[eR,eD]=(0,i.useState)(new Set),[e_,ez]=(0,i.useState)([]),[eU,eq]=(0,i.useState)([]),[eM,eK]=(0,i.useState)(null),[eL,eF]=(0,i.useState)(!1),[eJ,eB]=(0,i.useState)(!1),[eW,eV]=(0,i.useState)(!1),[eH,eG]=(0,i.useState)(null),[eQ,eZ]=(0,i.useState)({}),[eY,eX]=(0,i.useState)(null),e0=(0,i.useRef)(!1),[e1,e5]=(0,i.useState)(!1),{copied:e2,copy:e4}=(0,p.C)(),e3="ag_risk_confirmed",e6=()=>{O(!0)},e7=()=>{"antigravity"===r&&"true"!==window.localStorage.getItem(e3)?eF(!0):tl?e6():(K(""),q(!0))},e8=()=>{K(""),q(!0)},e9=()=>{tl?e7():e8()},te=j?{id:j.id,name:j.name||("anthropic-compatible"===j.type?"Anthropic Compatible":"OpenAI Compatible"),color:"anthropic-compatible"===j.type?"#D97757":"#10A37F",textIcon:"anthropic-compatible"===j.type?"AC":"OC",apiType:j.apiType,baseUrl:j.baseUrl,type:j.type}:c.zN[r]||c.fg[r]||c.IS[r]||c.nJ[r]||c.br[r],tt=j?null:function(e){let t=c.zN[e]?c.zN:c.fg[e]?c.fg:c.IS[e]?c.IS:c.nJ[e]?c.nJ:c.br[e]?c.br:null;if(!t)return null;let s=t[e],a=t===c.IS&&s?.noAuth?"free":t===c.IS||t===c.zN?"oauth":t===c.br?"cookie":t===c.fg&&s?.noAuth?"free":(t===c.fg||c.nJ,"apikey"),i=Array.isArray(s.authModes)?s.authModes.filter(e=>e!==a):[],l=[a,...i],r=(0,c.mq)(e)||(0,c.gb)(e);r&&!l.includes("compatible")&&l.push("compatible");let n=s.notice||{};return{id:e,name:s.name||e,icon:s.icon,image:s.image,textIcon:s.textIcon,color:s.color,tier:t===c.IS?"free":t===c.nJ?"freetier":t===c.zN?"oauth":t===c.br?"webcookie":s?.noAuth?"free":"paid",authModes:l,links:{homepage:s.website,apiKey:n.apiKeyUrl,signup:n.signupUrl,pricing:s.searchViaChat?.pricingUrl,docs:s.docsUrl},features:{autoPing:"claude"===e&&"oauth"===a,bulkImport:"codex"===e,compatibleModels:r,customModels:!s.passthroughModels,passthroughModels:!!s.passthroughModels,hasRegions:Array.isArray(s.regions)&&s.regions.length>0,hasProviderSpecificData:!!s.hasProviderSpecificData},serviceKinds:s.serviceKinds||["llm"],thinking:s.thinkingConfig||null,notices:{body:n.text,warning:s.deprecationNotice},deprecated:!!s.deprecated,regions:s.regions,defaultRegion:s.defaultRegion,noAuth:!!s.noAuth,_raw:s}}(r),ts="codex"===r?"codexAutoPing":"claudeAutoPing",ta="claude"===r||"codex"===r,ti=te?.authModes||[],tl=!!c.zN[r]||!!c.IS[r]||ti.includes("oauth"),tr=!!c.fg[r]||ti.includes("apikey"),tn=!!c.IS[r]?.noAuth,to=(0,m.KC)(r),td=(0,c.wG)(r),tc=(0,c.mq)(r),tm=(0,c.gb)(r),tp=tc||tm,tx=!tp&&tl&&tr,tu="xai"===r?"Grok Build OAuth":"OAuth",th="xai"===r?"xAI API Key":"API Key";c.Q2[r]?.thinkingConfig||c.s9.extended;let tf=tp?r:td,tg=tp?j?.prefix||r:td,tb=(0,i.useCallback)(async()=>{try{let e=await fetch(`/api/models/disabled?providerAlias=${encodeURIComponent(tf)}`,{cache:"no-store"}),t=await e.json();e.ok&&eq(t.ids||[])}catch(e){console.log("Error fetching disabled models:",e)}},[tf]),ty=async e=>{try{(await fetch("/api/models/disabled",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({providerAlias:tf,ids:[e]})})).ok&&await tb()}catch(e){console.log("Error disabling model:",e)}},tv=async e=>{try{(await fetch(`/api/models/disabled?providerAlias=${encodeURIComponent(tf)}&id=${encodeURIComponent(e)}`,{method:"DELETE"})).ok&&await tb()}catch(e){console.log("Error enabling model:",e)}},tj=async e=>{e.length&&eK({title:"Disable All Models",message:`Disable all ${e.length} model(s)?`,onConfirm:async()=>{eK(null);try{(await fetch("/api/models/disabled",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({providerAlias:tf,ids:e})})).ok&&await tb()}catch(e){console.log("Error disabling all models:",e)}}})},tN=async()=>{try{(await fetch(`/api/models/disabled?providerAlias=${encodeURIComponent(tf)}`,{method:"DELETE"})).ok&&await tb()}catch(e){console.log("Error enabling all models:",e)}},tw=(0,i.useCallback)(async()=>{try{let e=await fetch("/api/models/alias"),t=await e.json();e.ok&&X(t.aliases||{})}catch(e){console.log("Error fetching aliases:",e)}},[]);(0,i.useEffect)(()=>{"kilocode"===r&&fetch("/api/providers/kilo/free-models").then(e=>e.json()).then(e=>{e.models?.length&&ez(e.models)}).catch(()=>{})},[r]);let tk=(0,i.useCallback)(async()=>{try{let[e,t,s,a]=await Promise.all([fetch("/api/providers",{cache:"no-store"}),fetch("/api/provider-nodes",{cache:"no-store"}),fetch("/api/proxy-pools?isActive=true",{cache:"no-store"}),fetch("/api/settings",{cache:"no-store"})]),i=await e.json(),l=await t.json(),n=await s.json(),o=a.ok?await a.json():{};if(e.ok){let e=(i.connections||[]).filter(e=>e.provider===r);f(e)}s.ok&&T(n.proxyPools||[]);let d=(o.providerStrategies||{})[r]||{};ey(d.fallbackStrategy||null),ej(null!=d.stickyRoundRobinLimit?String(d.stickyRoundRobinLimit):"1");let c=(o.providerThinking||{})[r]||{};ew(c.mode||"auto");let m=o[ts]||{};if(eC({enabled:!0===m.enabled,connections:m.connections||{}}),t.ok){let e=(l.nodes||[]).find(e=>e.id===r)||null;if(!e&&tp)for(let t=0;t<3;t+=1){await new Promise(e=>setTimeout(e,150));let t=await fetch("/api/provider-nodes",{cache:"no-store"});if(t.ok&&(e=((await t.json()).nodes||[]).find(e=>e.id===r)||null))break}w(e)}}catch(e){console.log("Error fetching connections:",e)}finally{y(!1)}},[r,tp]),tC=async e=>{try{let t=await fetch(`/api/provider-nodes/${r}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}),s=await t.json();t.ok&&(w(s.node),await tk(),V(!1))}catch(e){console.log("Error updating provider node:",e)}},tS=async(e,t)=>{try{let s=await fetch("/api/settings",{cache:"no-store"}),a=(s.ok?await s.json():{}).providerStrategies||{},i={};e&&(i.fallbackStrategy=e),"round-robin"===e&&""!==t&&(i.stickyRoundRobinLimit=Number(t)||3);let l={...a};0===Object.keys(i).length?delete l[r]:l[r]=i,await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({providerStrategies:l})})}catch(e){console.log("Error saving provider strategy:",e)}},tA=async(e,t)=>{eC({...ek,connections:{...ek.connections,[e]:t}});try{let s=await fetch("/api/settings",{cache:"no-store"}),a=(s.ok?await s.json():{})[ts]||{},i={...a,connections:{...a.connections||{},[e]:t}};await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({[ts]:i})}),eC({enabled:!0===i.enabled,connections:i.connections})}catch(e){console.log("Error saving auto-ping config:",e),eC(ek)}};(0,i.useEffect)(()=>{tk(),tw(),tb()},[tk,tw,tb]);let[t$,tT]=(0,i.useState)({});(0,i.useEffect)(()=>{let e=!1,t=async()=>{try{let t=await fetch("/api/providers/health",{cache:"no-store"});if(!t.ok)return;let s=await t.json();!e&&s?.success&&s.snapshot&&tT(s.snapshot)}catch{}};t();let s=setInterval(t,1e4);return()=>{e=!0,clearInterval(s)}},[]),(0,i.useEffect)(()=>{let e=(c.zN[r]||c.fg[r]||c.IS[r]||c.nJ[r])?.modelsFetcher;e&&h(e).then(eA)},[r]);let tI=(0,i.useCallback)(async()=>{if(0===u.length)return;let e=u.find(e=>!1!==e.isActive)||u[0];if(e){eP(!0);try{let t=null;try{let s=await fetch(`/api/models/live-by-connection?connectionId=${e.id}`),a=s.ok?await s.json():null;a?.success&&a?.models?.length?t={models:a.models}:a?.code==="no_fetcher"&&(t=null)}catch{}if(!t){let s=await fetch(`/api/providers/${e.id}/models`);t=s.ok?await s.json():null}t?.models?.length&&(eT(t.models),eD(e=>{if(e.size>0)return e;let s=t.models[0]?.id||"",a=s.includes("/")?s.split("/")[0]:"other";return new Set([a])}))}catch{}finally{eP(!1)}}},[r,u]);(0,i.useEffect)(()=>{tI()},[tI]);let tP=async(e,t,s=td)=>{let a=`${s}/${e}`;try{let e=await fetch("/api/models/alias",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({model:a,alias:t})});if(e.ok)await tw();else{let t=await e.json();alert(t.error||"Failed to set alias")}}catch(e){console.log("Error setting alias:",e)}},tO=async e=>{try{(await fetch(`/api/models/alias?alias=${encodeURIComponent(e)}`,{method:"DELETE"})).ok&&await tw()}catch(e){console.log("Error deleting alias:",e)}},tE=async()=>{if(e1)return;let e=u.find(e=>!1!==e.isActive);if(!e)return void alert((0,x.Tl)("Please add an active Qoder connection first"));e5(!0);try{let t=await fetch(`/api/providers/${e.id}/models`),s=await t.json();if(!t.ok)return void alert(s.error||(0,x.Tl)("Failed to fetch models"));let a=s.models||[];if(0===a.length)return void alert((0,x.Tl)("No models returned"));let i=0;for(let e of a){let t=e.id||e.name;if(!t)continue;let s=t.replace(/^qoder\//,""),a=`${tf}/${s}`;!Object.values(Y).includes(a)&&(Y[s]||(await tP(s,s,tf),i+=1))}0===i?alert((0,x.Tl)("All models already exist, no new models added")):alert((0,x.Tl)("Successfully added")+` ${i} `+(0,x.Tl)("models"))}catch(e){console.log("Error importing Qoder models:",e),alert((0,x.Tl)("Error fetching models")+": "+e.message)}finally{e5(!1)}},tR=async()=>{if(eJ||0===u.length)return;let e=Object.fromEntries(u.map(e=>[e.id,{state:"queued",error:null}]));e0.current=!1,eB(!0),eV(!1),eG(null),eZ(e),eX({total:u.length,completed:0,passed:0,failed:0,stopped:!1});let t=0,s=0;try{for(let e=0;e<u.length;e+=1){if(e0.current){eX({total:u.length,completed:e,passed:t,failed:s,stopped:!0});break}let a=u[e];eG(a.id),eZ(e=>({...e,[a.id]:{state:"testing",error:null}}));try{let e=await fetch(`/api/providers/${a.id}/test`,{method:"POST"}),i=await e.json(),l=!!i.valid;l?t+=1:s+=1,eZ(e=>({...e,[a.id]:{state:l?"success":"failed",error:l?null:i.error||null}}))}catch(e){s+=1,eZ(t=>({...t,[a.id]:{state:"failed",error:e.message||"Test failed"}}))}eX({total:u.length,completed:e+1,passed:t,failed:s,stopped:!1}),e<u.length-1&&await new Promise(e=>setTimeout(e,1e3))}}finally{eG(null),eB(!1),eV(!1),e0.current=!1}},tD=async e=>{eK({title:"Delete Connection",message:"Delete this connection?",onConfirm:async()=>{eK(null);try{(await fetch(`/api/providers/${e}`,{method:"DELETE"})).ok&&f(t=>t.filter(t=>t.id!==e))}catch(e){console.log("Error deleting connection:",e)}}})},t_=()=>{tk(),O(!1)},tz=async e=>{K("");try{let t=await fetch("/api/providers",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:r,...e})}),s=null;try{s=await t.json()}catch{s=null}if(t.ok){await tk(),q(!1);return}K(s?.error||"Failed to save connection")}catch(e){console.log("Error saving connection:",e),K("Failed to save connection")}},tU=async e=>{try{(await fetch(`/api/providers/${Q.id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})).ok&&(await tk(),B(!1))}catch(e){console.log("Error updating connection:",e)}},tq=async(e,t)=>{try{(await fetch(`/api/providers/${e}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({isActive:t})})).ok&&f(s=>s.map(s=>s.id===e?{...s,isActive:t}:s))}catch(e){console.log("Error updating connection status:",e)}},tM=async(e,t)=>{let s=[...u];[s[e],s[t]]=[s[t],s[e]],f(s);try{await Promise.all([fetch(`/api/providers/${s[e].id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({priority:e})}),fetch(`/api/providers/${s[t].id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({priority:t})})])}catch(e){console.log("Error swapping priority:",e),await tk()}},tK=u.filter(e=>ep.includes(e.id));u.length>0&&(ep.length,u.length),(0,i.useEffect)(()=>{ex(e=>e.filter(e=>u.some(t=>t.id===e)))},[u]),(()=>{if(0===tK.length)return;let e=new Set(tK.map(e=>e.providerSpecificData?.proxyPoolId||"__none__"));if(1===e.size){let t=[...e][0];if("__none__"===t)return;let s=A.find(e=>e.id===t);return s?.name}})();let tL=()=>{ef||G(!1)},tF=async e=>{eg(!0);try{let t=0;for(let{connectionId:s,proxyPoolId:a}of e)try{(await fetch(`/api/providers/${s}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({proxyPoolId:a})})).ok||(t+=1)}catch(e){console.log("Error applying proxy for",s,e),t+=1}t>0&&alert(`Updated with ${t} failed request(s).`),await tk(),G(!1)}finally{eg(!1)}},tJ=e=>tF(u.map(t=>({connectionId:t.id,proxyPoolId:e}))),tB=(0,a.jsx)("div",{className:"flex min-w-0 flex-col divide-y divide-black/[0.03] dark:divide-white/[0.03]",children:u.map((e,t)=>(0,a.jsx)("div",{className:"flex min-w-0 items-stretch",children:(0,a.jsx)("div",{className:"flex-1 min-w-0",children:(0,a.jsx)(N,{connection:e,proxyPools:A,health:t$[e.id],isOAuth:tl,isFirst:0===t,isLast:t===u.length-1,onMoveUp:()=>tM(t,t-1),onMoveDown:()=>tM(t,t+1),onToggleActive:t=>tq(e.id,t),autoPing:ta&&"oauth"===e.authType?{on:!0===ek.connections[e.id],onToggle:t=>tA(e.id,t)}:null,onUpdateProxy:async t=>{try{(await fetch(`/api/providers/${e.id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({proxyPoolId:t||null})})).ok&&f(s=>s.map(s=>s.id===e.id?{...s,providerSpecificData:{...s.providerSpecificData,proxyPoolId:t||null}}:s))}catch(e){console.log("Error updating proxy:",e)}},onEdit:()=>{Z(e),B(!0)},onDelete:()=>tD(e.id),oneByOneStatus:eQ[e.id]||null})})},e.id))}),tW=A.filter(e=>!0===e.isActive),tV=(0,a.jsx)(d.aF,{isOpen:H,onClose:tL,title:`Apply Proxy (${u.length} connections)`,children:(0,a.jsxs)("div",{className:"flex flex-col gap-3",children:[(0,a.jsxs)("div",{className:"flex flex-col",children:[(0,a.jsxs)("button",{onClick:()=>{let e=A.filter(e=>!0===e.isActive);return 0===e.length?void alert("No active proxy pools available."):tF(u.map((t,s)=>({connectionId:t.id,proxyPoolId:e[s%e.length].id})))},disabled:ef||0===tW.length,className:"flex items-center gap-2 rounded-lg px-3 py-2 text-left transition-colors hover:bg-black/[0.04] dark:hover:bg-white/[0.04] disabled:cursor-not-allowed disabled:opacity-50",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-text-muted text-[18px]",children:"sync_alt"}),(0,a.jsx)("span",{className:"text-sm text-text-main",children:"One-to-one (rotate)"})]}),(0,a.jsxs)("button",{onClick:()=>tJ(null),disabled:ef,className:"flex items-center gap-2 rounded-lg px-3 py-2 text-left transition-colors hover:bg-black/[0.04] dark:hover:bg-white/[0.04] disabled:cursor-not-allowed disabled:opacity-50",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-text-muted text-[18px]",children:"link_off"}),(0,a.jsx)("span",{className:"text-sm text-text-main",children:"None (unbind all)"})]}),A.map(e=>(0,a.jsxs)("button",{onClick:()=>tJ(e.id),disabled:ef||!0!==e.isActive,className:"flex items-center gap-2 rounded-lg px-3 py-2 text-left transition-colors hover:bg-black/[0.04] dark:hover:bg-white/[0.04] disabled:cursor-not-allowed disabled:opacity-50",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-text-muted text-[18px]",children:"lan"}),(0,a.jsx)("span",{className:"truncate text-sm text-text-main",children:e.name}),!0!==e.isActive&&(0,a.jsx)("span",{className:"text-[10px] text-text-muted",children:"(inactive)"})]},e.id))]}),ef&&(0,a.jsx)("p",{className:"text-xs text-text-muted",children:"Applying..."}),(0,a.jsx)(d.$n,{onClick:tL,variant:"ghost",fullWidth:!0,disabled:ef,children:"Cancel"})]})}),tH=async e=>{if(!er.has(e)){en(t=>new Set([...t,e]));try{let t=await fetch("/api/models/test",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({model:`${tf}/${e}`})}),s=await t.json();ea(t=>({...t,[e]:s.ok?"ok":"error"})),s.ok||el(s.error||"Model not reachable")}catch{ea(t=>({...t,[e]:"error"}))}finally{en(t=>{let s=new Set(t);return s.delete(e),s})}}},tG=async e=>{if(eo)return;ed(!0);let t=[];try{for(let s=0;s<e.length;s+=5){let a=e.slice(s,s+5);await Promise.all(a.map(async e=>{en(t=>new Set([...t,e.id]));try{let s=await fetch("/api/models/test",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({model:`${tf}/${e.id}`})}),a=await s.json(),i=a.ok?"ok":"error";ea(t=>({...t,[e.id]:i})),a.ok&&t.push(e)}catch{ea(t=>({...t,[e.id]:"error"}))}finally{en(t=>{let s=new Set(t);return s.delete(e.id),s})}}))}for(let e of t)await tP(e.id,e.id,tf);t.length>0&&document.getElementById("available-models-section")?.scrollIntoView({behavior:"smooth"})}finally{ed(!1)}};if(g)return(0,a.jsxs)("div",{className:"flex flex-col gap-8",children:[(0,a.jsx)(d.Qv,{}),(0,a.jsx)(d.Qv,{})]});if(!te)return(0,a.jsxs)("div",{className:"text-center py-20",children:[(0,a.jsx)("p",{className:"text-text-muted",children:"Provider not found"}),(0,a.jsx)(n(),{href:"/dashboard/providers",className:"text-primary mt-4 inline-block",children:"Back to Providers"})]});let tQ=()=>tc&&te.apiType?"responses"===te.apiType?"/providers/oai-r.png":"/providers/oai-cc.png":tm?"/providers/anthropic-m.png":`/providers/${te.id}.png`;return(0,a.jsxs)("div",{className:"flex min-w-0 flex-col gap-6 px-1 sm:gap-8 sm:px-0",children:[tt?(0,a.jsx)(I,{capabilities:tt,connectionCount:u.length,headerIconPath:ee?null:tQ()}):(0,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsxs)(n(),{href:"/dashboard/providers",className:"inline-flex items-center gap-1 text-sm text-text-muted hover:text-primary transition-colors mb-4",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-lg",children:"arrow_back"}),"Back to Providers"]}),(0,a.jsxs)("div",{className:"flex min-w-0 items-center gap-3 sm:gap-4",children:[(0,a.jsx)("div",{className:"flex size-12 shrink-0 items-center justify-center rounded-lg",style:{backgroundColor:`${te.color}15`},children:ee?(0,a.jsx)("span",{className:"text-sm font-bold",style:{color:te.color},children:te.textIcon||te.id.slice(0,2).toUpperCase()}):(0,a.jsx)(o.default,{src:tQ(),alt:te.name,width:48,height:48,className:"max-h-12 max-w-12 rounded-lg object-contain",sizes:"48px",onError:()=>et(!0)})}),(0,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsx)("h1",{className:"truncate text-2xl font-semibold tracking-tight sm:text-3xl",children:te.name}),(0,a.jsxs)("p",{className:"text-text-muted",children:[u.length," connection",1===u.length?"":"s"]})]})]})]}),tp&&j&&(0,a.jsx)(d.Zp,{children:(0,a.jsxs)("div",{className:"mb-4 flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between",children:[(0,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsx)("h2",{className:"text-lg font-semibold",children:tm?"Anthropic Compatible Details":"OpenAI Compatible Details"}),(0,a.jsxs)("p",{className:"break-all text-sm text-text-muted",children:[tm?"Messages API":"responses"===j.apiType?"Responses API":"Chat Completions"," \xb7 ",(j.baseUrl||"").replace(/\/$/,""),"/",tm?"messages":"responses"===j.apiType?"responses":"chat/completions"]})]}),(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-2 sm:flex sm:items-center",children:[(0,a.jsx)(d.$n,{size:"sm",icon:"add",onClick:()=>{K(""),q(!0)},className:"w-full sm:w-auto",children:"Add API Key"}),(0,a.jsx)(d.$n,{size:"sm",variant:"secondary",icon:"edit",onClick:()=>V(!0),className:"w-full sm:w-auto",children:"Edit"}),(0,a.jsx)(d.$n,{size:"sm",variant:"secondary",icon:"delete",onClick:async()=>{eK({title:"Delete Compatible Node",message:`Delete this ${tm?"Anthropic":"OpenAI"} Compatible node?`,onConfirm:async()=>{eK(null);try{(await fetch(`/api/provider-nodes/${r}`,{method:"DELETE"})).ok&&s.push("/dashboard/providers")}catch(e){console.log("Error deleting provider node:",e)}}})},className:"w-full sm:w-auto",children:"Delete"})]})]})}),tn?(0,a.jsx)(d.gw,{providerId:r}):(0,a.jsxs)(d.Zp,{children:[(0,a.jsxs)("div",{className:"mb-4 flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[(0,a.jsx)("h2",{className:"text-lg font-semibold",children:"Connections"}),(0,a.jsxs)("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:gap-4",children:[u.length>0&&A.length>0&&(0,a.jsx)(d.$n,{size:"sm",variant:"secondary",icon:"lan",onClick:()=>G(!0),children:"Apply Proxy"}),ep.length>0&&(0,a.jsxs)(d.$n,{size:"sm",variant:"danger",icon:"delete",onClick:()=>{let e=ep.length;0!==e&&eK({title:`Delete ${e} Connection${e>1?"s":""}`,message:`Delete ${e} connection${e>1?"s":""}? This cannot be undone.`,onConfirm:async()=>{eK(null);let e=0,t=[...ep],s=[];for(let a of t)try{(await fetch(`/api/providers/${a}`,{method:"DELETE"})).ok?s.push(a):e+=1}catch(t){console.log("Error deleting connection:",t),e+=1}f(e=>e.filter(e=>!s.includes(e.id))),ex(t.filter(e=>!s.includes(e))),e>0&&alert(`Deleted ${s.length} connection(s), ${e} failed and are still selected.`)}})},children:["Delete Selected (",ep.length,")"]}),u.length>0&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(d.$n,{size:"sm",variant:"secondary",icon:"sync",onClick:tR,disabled:eJ,children:eJ?"Testing Connection One-by-One...":"Test Connection One-by-One"}),eJ&&(0,a.jsx)(d.$n,{size:"sm",variant:"ghost",icon:"stop",onClick:()=>{eJ&&(e0.current=!0,eV(!0))},disabled:eW,children:eW?"Stopping...":"Stop"})]}),(0,a.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,a.jsx)("span",{className:"text-xs text-text-muted font-medium",children:"Round Robin"}),(0,a.jsx)(d.lM,{checked:"round-robin"===eb,onChange:e=>{let t=e?"round-robin":null,s=e?ev||"1":ev;e&&!ev&&ej("1"),ey(t),tS(t,s)}}),"round-robin"===eb&&(0,a.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,a.jsx)("span",{className:"text-xs text-text-muted",children:"Sticky:"}),(0,a.jsx)("input",{type:"number",min:1,value:ev,onChange:e=>{var t;ej(t=e.target.value),tS("round-robin",t)},placeholder:"1",className:"w-14 px-2 py-1 text-xs border border-border rounded-md bg-background focus:outline-none focus:border-primary"})]})]})]})]}),0===u.length?tt?(0,a.jsx)(R,{capabilities:tt,onOAuth:e7,onApiKey:e8,onFree:e9,onCookie:()=>z(!0),onCompatible:e8,onBulkImport:()=>F(!0)}):(0,a.jsxs)("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[(0,a.jsxs)("div",{className:"flex items-center gap-3",children:[(0,a.jsx)("div",{className:"inline-flex items-center justify-center w-9 h-9 rounded-full bg-primary/10 text-primary shrink-0",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:"key"})}),(0,a.jsx)("p",{className:"text-sm text-text-muted",children:"No connections yet"})]}),(0,a.jsx)(d.$n,{size:"sm",icon:"add",onClick:e9,children:"Add API Key"})]}):(0,a.jsxs)(a.Fragment,{children:[eY&&(0,a.jsx)("div",{className:"mb-4 rounded-lg border border-black/10 bg-black/[0.02] px-3 py-2 text-xs text-text-muted dark:border-white/10 dark:bg-white/[0.03]",children:(0,a.jsxs)("div",{className:"flex flex-wrap items-center gap-3",children:[(0,a.jsxs)("span",{children:["Total: ",eY.total]}),(0,a.jsxs)("span",{children:["Completed: ",eY.completed]}),(0,a.jsxs)("span",{children:["Passed: ",eY.passed]}),(0,a.jsxs)("span",{children:["Failed: ",eY.failed]}),eY.stopped&&(0,a.jsx)("span",{className:"text-amber-600 dark:text-amber-400",children:"Stopped"}),eJ&&eH&&(0,a.jsxs)("span",{children:["Running: ",u.find(e=>e.id===eH)?.name||eH]})]})}),!tp&&tt&&(0,a.jsx)(D,{providerId:r,models:e$}),tB,!tp&&tt&&(0,a.jsx)(_,{providerId:r}),!tp&&(0,a.jsxs)("div",{className:"mt-4 grid grid-cols-1 gap-2 sm:flex",children:["iflow"===r&&(0,a.jsx)(d.$n,{size:"sm",icon:"cookie",variant:"secondary",onClick:()=>z(!0),title:"Add connection using browser cookie",className:"w-full sm:w-auto",children:"Cookie"}),"codex"===r&&(0,a.jsx)(d.$n,{size:"sm",icon:"playlist_add",variant:"secondary",onClick:()=>F(!0),title:(0,x.Tl)("Bulk import codex accounts from JSON"),className:"w-full sm:w-auto",children:(0,x.Tl)("Bulk Add")}),tx?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(d.$n,{size:"sm",icon:"lock",variant:"secondary",onClick:e7,className:"w-full sm:w-auto",children:tu}),(0,a.jsx)(d.$n,{size:"sm",icon:"key",onClick:e8,className:"w-full sm:w-auto",children:th})]}):(0,a.jsx)(d.$n,{size:"sm",icon:"add",onClick:e9,className:"w-full sm:w-auto",children:"Add"})]})]})]}),(0,a.jsxs)(d.Zp,{id:"available-models-section",children:[(0,a.jsxs)("div",{className:"mb-4 flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between",children:[(0,a.jsx)("h2",{className:"text-lg font-semibold",children:"Available Models"}),!tp&&(e=[...to,...e_.filter(e=>!to.some(t=>t.id===e.id))].filter(e=>!e.type||"llm"===e.type).map(e=>e.id).filter(e=>!eU.includes(e)),(0,a.jsxs)("div",{className:"flex gap-2",children:[eU.length>0&&(0,a.jsx)(d.$n,{size:"sm",variant:"secondary",icon:"restart_alt",onClick:tN,children:"Active All"}),e.length>0&&(0,a.jsx)(d.$n,{size:"sm",variant:"secondary",icon:"block",onClick:()=>tj(e),children:"Disable All"})]}))]}),!!ei&&(0,a.jsx)("p",{className:"text-xs text-red-500 mb-3 break-words",children:ei}),(()=>{if(tp)return(0,a.jsx)(v,{providerStorageAlias:tf,providerDisplayAlias:tg,modelAliases:Y,copied:e2,onCopy:e4,onSetAlias:tP,onDeleteAlias:tO,connections:u,isAnthropic:tm});let e=[...to,...e_.filter(e=>!to.some(t=>t.id===e.id))].filter(e=>!e.type||"llm"===e.type),t=new Set(eU),s=e.filter(e=>!t.has(e.id)),i=e.filter(e=>t.has(e.id)),l=Object.entries(Y).filter(([e,t])=>{let s=`${tf}/`;if(!t.startsWith(s))return!1;let a=t.slice(s.length);return te.passthroughModels?!to.some(e=>e.id===a):!to.some(e=>e.id===a)&&e===a}).map(([e,t])=>({id:t.slice(`${tf}/`.length),alias:e,fullModel:t}));return(0,a.jsxs)("div",{className:"flex flex-wrap gap-3",children:[l.map(e=>(0,a.jsx)(b,{model:{id:e.id},fullModel:`${tg}/${e.id}`,alias:e.alias,copied:e2,onCopy:e4,onSetAlias:()=>{},onDeleteAlias:()=>tO(e.alias),testStatus:es[e.id],onTest:u.length>0||tn?()=>tH(e.id):void 0,isTesting:er.has(e.id),isCustom:!0,isFree:!1},e.id)),s.map(e=>{let t=`${tf}/${e.id}`,s=`${r}/${e.id}`,i=Object.entries(Y).find(([,e])=>e===t||e===s)?.[0];return(0,a.jsx)(b,{model:e,fullModel:`${tg}/${e.id}`,alias:i,copied:e2,onCopy:e4,onSetAlias:t=>tP(e.id,t,tf),onDeleteAlias:()=>tO(i),testStatus:es[e.id],onTest:u.length>0||tn?()=>tH(e.id):void 0,isTesting:er.has(e.id),isFree:e.isFree,onDisable:()=>ty(e.id)},e.id)}),(0,a.jsxs)("button",{onClick:()=>em(!0),className:"flex w-full items-center justify-center gap-1.5 rounded-lg border border-dashed border-primary/40 px-3 py-2 text-xs text-primary transition-colors hover:border-primary hover:bg-primary/5 sm:w-auto",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-sm",children:"add"}),"Add Model"]}),"qoder"===r&&u.some(e=>!1!==e.isActive)&&(0,a.jsxs)("button",{onClick:tE,disabled:e1,className:"flex w-full items-center justify-center gap-1.5 rounded-lg border border-dashed border-blue-500/40 px-3 py-2 text-xs text-blue-600 dark:text-blue-400 transition-colors hover:border-blue-500 hover:bg-blue-500/5 sm:w-auto disabled:opacity-50 disabled:cursor-not-allowed",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-sm",style:e1?{animation:"spin 1s linear infinite"}:void 0,children:e1?"progress_activity":"download"}),e1?(0,x.Tl)("Fetching..."):(0,x.Tl)("Fetch Qoder Models")]}),(()=>{let e=new Set([...s.map(e=>e.id),...l.map(e=>e.id)]),t=e$.length>0?e$:eS,r=e$.length>0,n=t.filter(t=>t.id&&!e.has(t.id)),o=new Set(e$.map(e=>e.id).filter(Boolean)),d=i.filter(e=>e.id&&!o.has(e.id)).map(e=>({...e,dropped:!0})),c=new Set(d.map(e=>e.id)),m=[...n.filter(e=>!c.has(e.id)),...d];if(!eI&&0===m.length&&0===t.length)return null;let p=eO.trim().toLowerCase(),x=p?m.filter(e=>e.id.toLowerCase().includes(p)||e.name&&e.name.toLowerCase().includes(p)):m,u={};x.forEach(e=>{if(!e.id)return;let t=e.id.includes("/")?e.id.split("/")[0]:"models";u[t]||(u[t]=[]),u[t].push(e)});let h=Object.entries(u).sort((e,t)=>t[1].length-e[1].length),f=x.filter(e=>!e.dropped).slice(0,50);return(0,a.jsxs)("div",{className:"w-full mt-4 space-y-2",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("span",{className:"text-xs font-medium text-text-muted shrink-0",children:eI?"Loading...":`${r?"From API":"Suggested"} (${n.length})${d.length>0?` \xb7 ${d.length} dropped`:""}`}),(0,a.jsxs)("div",{className:"relative flex-1 min-w-0",children:[(0,a.jsx)("span",{className:"material-symbols-outlined absolute left-2.5 top-1/2 -translate-y-1/2 text-[13px] text-text-muted pointer-events-none select-none",children:"search"}),(0,a.jsx)("input",{type:"text",value:eO,onChange:e=>eE(e.target.value),placeholder:"Search models...",className:"w-full h-7 pl-7 pr-7 text-xs rounded-lg bg-bg border border-border-subtle text-text-main placeholder:text-text-muted focus:outline-none focus:ring-1 focus:ring-primary/30 focus:border-primary/40 transition-colors"}),eO&&(0,a.jsx)("button",{onClick:()=>eE(""),className:"absolute right-2 top-1/2 -translate-y-1/2 text-text-muted hover:text-text-muted transition-colors",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[13px]",children:"close"})})]}),(0,a.jsx)("button",{onClick:tI,disabled:eI,title:"Refresh",className:"shrink-0 h-7 w-7 flex items-center justify-center rounded-lg border border-border-subtle text-text-muted hover:text-primary hover:border-primary/40 hover:bg-primary/5 transition-colors disabled:opacity-40",children:(0,a.jsx)("span",{className:`material-symbols-outlined text-[14px] ${eI?"animate-spin":""}`,children:"refresh"})}),!eI&&f.length>0&&(0,a.jsxs)("button",{onClick:()=>tG(f),disabled:eo,title:`Test up to ${f.length} models and auto-add passing ones`,className:"shrink-0 h-7 flex items-center gap-1 px-2.5 rounded-lg border border-border-subtle text-xs text-text-muted hover:text-green-600 hover:border-green-500/40 hover:bg-green-500/5 transition-colors disabled:opacity-40",children:[(0,a.jsx)("span",{className:`material-symbols-outlined text-[13px] ${eo?"animate-spin":""}`,children:eo?"progress_activity":"play_circle"}),eo?"Testing...":"Test All"]})]}),p&&(0,a.jsxs)("p",{className:"text-xs text-text-muted",children:[x.length," result",1!==x.length?"s":""]}),eI?(0,a.jsxs)("div",{className:"flex items-center gap-2 py-4 text-xs text-text-muted",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[15px] animate-spin",children:"progress_activity"}),"Fetching models from provider API..."]}):0===h.length?p?(0,a.jsxs)("p",{className:"text-xs text-text-muted py-2",children:['No models match "',eO,'"']}):null:(0,a.jsx)("div",{className:"space-y-1",children:h.map(([e,t])=>{let s=eR.has(e),i=t.filter(e=>!e.dropped&&"ok"===es[e.id]).length,l=t.filter(e=>!e.dropped&&"error"===es[e.id]).length,r=t.filter(e=>e.dropped).length;return(0,a.jsxs)("div",{className:"rounded-xl border border-border-subtle overflow-hidden",children:[(0,a.jsxs)("button",{onClick:()=>eD(t=>{let s=new Set(t);return s.has(e)?s.delete(e):s.add(e),s}),className:"w-full flex items-center gap-2 px-3 py-2 text-xs bg-bg hover:bg-surface-2/60 transition-colors text-left",children:[(0,a.jsx)("span",{className:"font-semibold text-text-main flex-1",children:e}),i>0&&(0,a.jsxs)("span",{className:"text-green-600 dark:text-green-400 font-medium",children:[i," ✓"]}),l>0&&(0,a.jsxs)("span",{className:"text-red-500 font-medium",children:[l," ✗"]}),r>0&&(0,a.jsxs)("span",{className:"px-1.5 py-0.5 rounded-md bg-amber-500/10 text-amber-600 dark:text-amber-400 text-[10px] font-medium",children:[r," dropped"]}),(0,a.jsx)("span",{className:"px-1.5 py-0.5 rounded-md bg-black/[0.06] dark:bg-white/[0.06] text-text-muted tabular-nums font-medium",children:t.length}),(0,a.jsx)("span",{className:"material-symbols-outlined text-[15px] text-text-muted",children:s?"expand_less":"expand_more"})]}),s&&(0,a.jsx)("div",{className:"px-3 pt-2 pb-3 flex flex-wrap gap-1.5 border-t border-border-subtle bg-surface/50",children:t.map(e=>{let t=e.id.includes("/")?e.id.split("/").slice(1).join("/"):e.id,s=es[e.id],i=er.has(e.id);return e.dropped?(0,a.jsxs)("button",{onClick:async()=>{await tv(e.id),document.getElementById("available-models-section")?.scrollIntoView({behavior:"smooth"})},title:`Recently Dropped — click to restore: ${e.id}`,className:"group flex items-center gap-1 px-2.5 py-1.5 rounded-lg border border-amber-400/40 bg-amber-500/5 text-amber-700 dark:text-amber-400 text-xs hover:bg-amber-500/10 hover:border-amber-400/60 transition-colors",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[12px]",children:"history"}),(0,a.jsx)("span",{children:t}),e.contextLength>0&&(0,a.jsxs)("span",{className:"opacity-50 text-[10px] ml-0.5",children:[(e.contextLength/1e3).toFixed(0),"k"]})]},e.id):(0,a.jsxs)("button",{onClick:async()=>{await tP(e.id,e.id,tf),document.getElementById("available-models-section")?.scrollIntoView({behavior:"smooth"})},title:`Add: ${e.name||e.id}`,className:["group flex items-center gap-1 px-2.5 py-1.5 rounded-lg border text-xs transition-colors","ok"===s?"border-green-500/30 bg-green-500/5 text-green-700 dark:text-green-400 hover:bg-green-500/10":"error"===s?"border-red-400/30 bg-red-500/5 text-red-600 dark:text-red-400 hover:bg-red-500/10":"border-border-subtle text-text-muted hover:text-primary hover:border-primary/40 hover:bg-primary/5"].join(" "),children:[i?(0,a.jsx)("span",{className:"material-symbols-outlined text-[12px] animate-spin",children:"progress_activity"}):"ok"===s?(0,a.jsx)("span",{className:"material-symbols-outlined text-[12px]",children:"check"}):"error"===s?(0,a.jsx)("span",{className:"material-symbols-outlined text-[12px]",children:"close"}):(0,a.jsx)("span",{className:"material-symbols-outlined text-[12px] opacity-50 group-hover:opacity-100",children:"add"}),(0,a.jsx)("span",{children:t}),e.contextLength>0&&(0,a.jsxs)("span",{className:"opacity-40 text-[10px] ml-0.5",children:[(e.contextLength/1e3).toFixed(0),"k"]})]},e.id)})})]},e)})})]})})()]})})()]}),tV,"kiro"===r?(0,a.jsx)(d.Mh,{isOpen:P,providerInfo:te,onSuccess:t_,onClose:()=>O(!1)}):"cursor"===r?(0,a.jsx)(d.G9,{isOpen:P,onSuccess:t_,onClose:()=>O(!1)}):"gitlab"===r?(0,a.jsx)(d.vj,{isOpen:P,providerInfo:te,onSuccess:t_,onClose:()=>O(!1)}):(0,a.jsx)(d.LF,{isOpen:P,provider:r,providerInfo:te,onSuccess:t_,onClose:()=>O(!1)}),"iflow"===r&&(0,a.jsx)(d.vE,{isOpen:E,onSuccess:()=>{tk(),z(!1)},onClose:()=>z(!1)}),(0,a.jsx)(k,{isOpen:U,provider:r,providerName:te.name,isCompatible:tp,isAnthropic:tm,authType:te?.authType,authHint:te?.authHint,website:te?.website,proxyPools:A,error:M,existingNames:u.map(e=>e.name).filter(Boolean),onSave:tz,onBulkDone:tk,onClose:()=>{K(""),q(!1)}}),(0,a.jsx)(d.wI,{isOpen:J,connection:Q,proxyPools:A,onSave:tU,onClose:()=>B(!1)}),tp&&(0,a.jsx)(C,{isOpen:W,node:j,onSave:tC,onClose:()=>V(!1),isAnthropic:tm}),!tp&&(0,a.jsx)(S,{isOpen:ec,providerAlias:tf,providerDisplayAlias:tg,onSave:async e=>{let t=te?.passthroughModels?e.split("/").pop():e;await tP(e,t,tf),em(!1)},onClose:()=>em(!1)}),"codex"===r&&(0,a.jsx)($,{isOpen:L,onClose:()=>F(!1),onSuccess:tk}),(0,a.jsx)(d.uo,{isOpen:eL,onClose:()=>eF(!1),onConfirm:()=>{(window.localStorage.setItem(e3,"true"),eF(!1),tl)?e6():e8()},title:"Risk Notice",message:te?.deprecationNotice,confirmText:"I Understand, Continue",cancelText:"Cancel",variant:"danger"}),(0,a.jsx)(d.uo,{isOpen:!!eM,onClose:()=>eK(null),onConfirm:eM?.onConfirm,title:eM?.title||"Confirm",message:eM?.message,variant:"danger"})]})}R.propTypes={capabilities:g().object,onOAuth:g().func,onApiKey:g().func,onFree:g().func,onCookie:g().func,onCompatible:g().func,onBulkImport:g().func},D.propTypes={providerId:g().string.isRequired,models:g().array},_.propTypes={providerId:g().string.isRequired}}},e=>{e.O(0,[7504,5772,1321,5497,8441,3794,7358],()=>e(e.s=76487)),_N_E=e.O()}]);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[8460],{18160:(e,t,s)=>{"use strict";s.r(t),s.d(t,{default:()=>v});var r=s(95155),a=s(12115),l=s(14051),i=s.n(l),n=s(35497),o=s(57250),d=s(90620),c=s(52679),m=s(98500),p=s.n(m);function x(){let[e,t]=(0,a.useState)({status:"idle"}),[s,l]=(0,a.useState)(!1),i=(0,a.useCallback)(async()=>{try{let e=await fetch("/api/providers/zenith",{cache:"no-store"}),s=await e.json();s.success?t({status:"ok",count:s.count,leaderboard:s.leaderboard,winner:s.winner}):t({status:"error",error:s.error})}catch{t({status:"error",error:"network"})}},[]);if((0,a.useEffect)(()=>{i();let e=setInterval(i,15e3);return()=>clearInterval(e)},[i]),"ok"!==e.status||!e.leaderboard?.length)return null;let o=e.leaderboard[0],d=e.leaderboard[e.leaderboard.length-1];return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"mb-4 flex flex-wrap items-center gap-2 rounded-xl border border-primary/20 bg-gradient-to-r from-primary/[0.06] via-primary/[0.02] to-transparent px-4 py-2.5 text-sm",children:[(0,r.jsxs)("span",{className:"inline-flex items-center gap-1.5 font-medium text-primary",children:[(0,r.jsx)("span",{className:"material-symbols-outlined text-base",children:"bolt"}),"Zenith"]}),(0,r.jsx)("span",{className:"text-text-muted",children:"\xb7"}),(0,r.jsxs)("span",{className:"text-text-main",children:[e.count," active"]}),(0,r.jsx)("span",{className:"text-text-muted",children:"\xb7"}),(0,r.jsxs)("span",{className:"text-text-main",children:["best ",(0,r.jsx)("span",{className:"font-mono text-green-600 dark:text-green-400",children:o.finalScore})," (",o.name,")"]}),e.count>1&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("span",{className:"text-text-muted",children:"\xb7"}),(0,r.jsxs)("span",{className:"text-text-main",children:["worst ",(0,r.jsx)("span",{className:`font-mono ${d.finalScore<400?"text-red-500":"text-amber-500"}`,children:d.finalScore})," (",d.name,")"]})]}),(0,r.jsx)("div",{className:"ml-auto",children:(0,r.jsx)(n.$n,{size:"sm",variant:"ghost",onClick:()=>l(!0),children:"Leaderboard"})})]}),(0,r.jsx)(n.aF,{isOpen:s,title:"Zenith Leaderboard",onClose:()=>l(!1),children:(0,r.jsx)("div",{className:"max-h-[60vh] overflow-y-auto",children:(0,r.jsxs)("table",{className:"w-full text-sm",children:[(0,r.jsx)("thead",{className:"sticky top-0 bg-bg text-text-muted",children:(0,r.jsxs)("tr",{className:"text-left text-xs",children:[(0,r.jsx)("th",{className:"py-2 pr-2",children:"#"}),(0,r.jsx)("th",{className:"py-2 pr-2",children:"Connection"}),(0,r.jsx)("th",{className:"py-2 pr-2 text-right",children:"Health"}),(0,r.jsx)("th",{className:"py-2 pr-2 text-right",children:"Quota"}),(0,r.jsx)("th",{className:"py-2 pr-2 text-right",children:"Priority"}),(0,r.jsx)("th",{className:"py-2 pl-2 text-right",children:"Zenith"})]})}),(0,r.jsx)("tbody",{children:e.leaderboard.map(e=>(0,r.jsxs)("tr",{className:"border-t border-border/50",children:[(0,r.jsx)("td",{className:"py-1.5 pr-2 text-text-muted",children:e.rank}),(0,r.jsxs)("td",{className:"py-1.5 pr-2",children:[(0,r.jsx)("div",{className:"font-medium",children:e.name}),(0,r.jsx)("div",{className:"text-[10px] text-text-muted",children:e.provider})]}),(0,r.jsx)("td",{className:"py-1.5 pr-2 text-right font-mono text-xs",children:e.healthScore}),(0,r.jsxs)("td",{className:"py-1.5 pr-2 text-right font-mono text-xs",children:["\xd7",e.quotaFactor,null!=e.quotaRemainingPct&&(0,r.jsxs)("span",{className:"ml-1 text-text-muted",children:["(",e.quotaRemainingPct,"%)"]})]}),(0,r.jsxs)("td",{className:"py-1.5 pr-2 text-right font-mono text-xs",children:["+",e.priorityBonus]}),(0,r.jsx)("td",{className:"py-1.5 pl-2 text-right",children:(0,r.jsx)("span",{className:`inline-flex items-center rounded-md border px-1.5 py-0.5 font-mono text-[11px] ${e.finalScore>=750?"bg-green-500/10 text-green-700 dark:text-green-400 border-green-500/30":e.finalScore>=400?"bg-amber-500/10 text-amber-700 dark:text-amber-400 border-amber-500/30":"bg-red-500/10 text-red-700 dark:text-red-400 border-red-500/30"}`,children:e.finalScore})})]},e.connectionId))})]})})})]})}var h=s(65921),u=s(38003);let f={available:{icon:"check_circle",color:"#22c55e",label:"Available"},cooldown:{icon:"schedule",color:"#f59e0b",label:"Cooldown"},unavailable:{icon:"error",color:"#ef4444",label:"Unavailable"},unknown:{icon:"help",color:"#6b7280",label:"Unknown"}};function g(){let[e,t]=(0,a.useState)(null),[s,l]=(0,a.useState)(!0),[i,o]=(0,a.useState)(!1),[d,c]=(0,a.useState)(null),m=(0,a.useRef)(null),p=(0,h.i)(),x=(0,a.useCallback)(async()=>{try{let e=await fetch("/api/models/availability");if(e.ok){let s=await e.json();t(s)}}catch{}finally{l(!1)}},[]);(0,a.useEffect)(()=>{x();let e=setInterval(x,3e4);return()=>clearInterval(e)},[x]),(0,a.useEffect)(()=>{let e=e=>{m.current&&!m.current.contains(e.target)&&o(!1)};return i&&document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[i]);let u=async(e,t)=>{c(`${e}:${t}`);try{(await fetch("/api/models/availability",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"clearCooldown",provider:e,model:t})})).ok?(p.success(`Cooldown cleared for ${t}`),await x()):p.error("Failed to clear cooldown")}catch{p.error("Failed to clear cooldown")}finally{c(null)}};if(s)return null;let g=e?.models||[],b=0===(e?.unavailableCount||g.filter(e=>"available"!==e.status).length),v={};return g.forEach(e=>{if("available"===e.status)return;let t=e.provider||"unknown";v[t]||(v[t]=[]),v[t].push(e)}),(0,r.jsx)("div",{className:"relative",ref:m,children:i&&(0,r.jsxs)("div",{className:"absolute top-full right-0 mt-2 w-80 bg-surface border border-border rounded-xl shadow-2xl z-50 overflow-hidden",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border bg-bg",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("span",{className:"material-symbols-outlined text-[16px]",style:{color:b?"#22c55e":"#f59e0b"},children:b?"verified":"warning"}),(0,r.jsx)("span",{className:"text-sm font-semibold text-text-main",children:"Model Status"})]}),(0,r.jsx)("button",{onClick:x,className:"p-1 rounded-lg hover:bg-surface text-text-muted hover:text-text-main transition-colors",title:"Refresh",children:(0,r.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"refresh"})})]}),(0,r.jsx)("div",{className:"px-4 py-3 max-h-60 overflow-y-auto",children:b?(0,r.jsx)("p",{className:"text-sm text-text-muted text-center py-2",children:"All models are responding normally."}):(0,r.jsx)("div",{className:"flex flex-col gap-2.5",children:Object.entries(v).map(([e,t])=>(0,r.jsxs)("div",{children:[(0,r.jsx)("p",{className:"text-xs font-semibold text-text-main mb-1.5 capitalize",children:e}),(0,r.jsx)("div",{className:"flex flex-col gap-1",children:t.map(e=>{let t=f[e.status]||f.unknown,s=d===`${e.provider}:${e.model}`;return(0,r.jsxs)("div",{className:"flex items-center justify-between px-2.5 py-1.5 rounded-lg bg-surface/30",children:[(0,r.jsxs)("div",{className:"flex items-center gap-1.5 min-w-0",children:[(0,r.jsx)("span",{className:"material-symbols-outlined text-[14px] shrink-0",style:{color:t.color},children:t.icon}),(0,r.jsx)("span",{className:"font-mono text-xs text-text-main truncate",children:e.model})]}),"cooldown"===e.status&&(0,r.jsx)(n.$n,{size:"sm",variant:"ghost",onClick:()=>u(e.provider,e.model),disabled:s,className:"text-[10px] px-1.5! py-0.5! ml-2",children:s?"...":"Clear"})]},`${e.provider}-${e.model}`)})})]},e))})})]})})}function b(e,t,s){let a=[];if(e>0&&a.push((0,r.jsxs)(n.Ex,{variant:"success",size:"sm",dot:!0,children:[e," Connected"]},"connected")),t>0){let e=s?`${t} Error (${s})`:`${t} Error`;a.push((0,r.jsx)(n.Ex,{variant:"error",size:"sm",dot:!0,children:e},"error"))}return 0===a.length?(0,r.jsx)("span",{className:"text-text-muted",children:"No connections"}):a}function v(){let e,t,[s,l]=(0,a.useState)([]),[i,o]=(0,a.useState)([]),[m,p]=(0,a.useState)(!0),[f,b]=(0,a.useState)(!1),[v,C]=(0,a.useState)(!1),[T,A]=(0,a.useState)(!1),[S,I]=(0,a.useState)(null),[$,E]=(0,a.useState)(null),R=(0,h.i)(),O=(0,u.C)(e=>e.query),U=(0,u.C)(e=>e.register),P=(0,u.C)(e=>e.unregister);(0,a.useEffect)(()=>(U("Search providers..."),()=>P()),[U,P]);let _=e=>!O.trim()||e.toLowerCase().includes(O.trim().toLowerCase());(0,a.useEffect)(()=>{(async()=>{try{let[e,t]=await Promise.all([fetch("/api/providers"),fetch("/api/provider-nodes")]),s=await e.json(),r=await t.json();e.ok&&l(s.connections||[]),t.ok&&o(r.nodes||[])}catch(e){console.log("Error fetching data:",e)}finally{p(!1)}})()},[]);let q=(e,t)=>{let r=s.filter(s=>s.provider===e&&s.authType===t),a=e=>{let t=Object.entries(e).some(([e,t])=>e.startsWith("modelLock_")&&t&&new Date(t).getTime()>Date.now());return"unavailable"!==e.testStatus||t?e.testStatus:"active"},l=r.filter(e=>{let t=a(e);return"active"===t||"success"===t}).length,i=r.filter(e=>{let t=a(e);return"error"===t||"expired"===t||"unavailable"===t}),n=i.length,o=r.length,d=o>0&&r.every(e=>!1===e.isActive),c=i.sort((e,t)=>new Date(t.lastErrorAt||0)-new Date(e.lastErrorAt||0))[0];return{connected:l,error:n,total:o,errorCode:c?function(e){if(!e)return null;let t=e.lastErrorType;if("runtime_error"===t)return"RUNTIME";if("upstream_auth_error"===t||"auth_missing"===t||"token_refresh_failed"===t||"token_expired"===t)return"AUTH";if("upstream_rate_limited"===t)return"429";if("upstream_unavailable"===t)return"5XX";if("network_error"===t)return"NET";let s=Number(e.errorCode);if(Number.isFinite(s)&&s>=400)return String(s);let r=function(e){if(!e)return null;let t=e.match(/\b([45]\d{2})\b/);return t?t[1]:"ERR"}(e.lastError);if("401"===r||"403"===r)return"AUTH";if(r&&"ERR"!==r)return r;let a=(e.lastError||"").toLowerCase();return a.includes("runtime")||a.includes("not runnable")||a.includes("not installed")?"RUNTIME":a.includes("invalid api key")||a.includes("token invalid")||a.includes("revoked")||a.includes("unauthorized")?"AUTH":"ERR"}(c):null,errorTime:c?.lastErrorAt?function(e){if(!e)return"";let t=Math.floor((Date.now()-new Date(e).getTime())/6e4);if(t<1)return"just now";if(t<60)return`${t}m ago`;let s=Math.floor(t/60);if(s<24)return`${s}h ago`;let r=Math.floor(s/24);return`${r}d ago`}(c.lastErrorAt):null,allDisabled:d}},z=async(e,t,r)=>{let a=s.filter(s=>s.provider===e&&s.authType===t);l(s=>s.map(s=>s.provider===e&&s.authType===t?{...s,isActive:r}:s));let i=(await Promise.allSettled(a.map(e=>fetch(`/api/providers/${e.id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({isActive:r})})))).filter(e=>"fulfilled"!==e.status||!e.value?.ok).length;i>0&&(l(s),R.error(i===a.length?`Could not ${r?"enable":"disable"} ${e} — no changes were saved`:`${i} of ${a.length} ${e} connections could not be updated — reverted`))},D=async(e,t=null)=>{if(!S){I("provider"===e?t:e),E(null);try{let s=await fetch("/api/providers/test-batch",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mode:e,providerId:t})}),r=await s.json();if(E(r),r.summary){let{passed:e,failed:t,total:s}=r.summary;0===t?R.success(`All ${s} tests passed`):R.warning(`${e}/${s} passed, ${t} failed`)}}catch(e){E({error:"Test request failed"}),R.error("Provider test failed")}finally{I(null)}}},F=i.filter(e=>"openai-compatible"===e.type).map(e=>({id:e.id,name:e.name||"OpenAI Compatible",color:"#10A37F",textIcon:"OC",apiType:e.apiType})).filter(e=>_(e.name)),M=i.filter(e=>"anthropic-compatible"===e.type).map(e=>({id:e.id,name:e.name||"Anthropic Compatible",color:"#D97757",textIcon:"AC"})).filter(e=>_(e.name)),L=Object.entries(d.zN).filter(([,e])=>!e.hidden&&_(e.name)),K=Object.entries(c.IS).filter(([,e])=>!e.hidden&&_(e.name)),J=Object.entries(c.nJ).filter(([,e])=>!e.hidden&&_(e.name)),W=(e=Object.entries(d.fg).filter(([,e])=>!e.hidden&&(e.serviceKinds??["llm"]).includes("llm")&&_(e.name)),t="apikey",[...e].sort(([e,s],[r,a])=>{let l=q(e,t),i=q(r,t),n=+(l.connected>0),o=+(i.connected>0);return n!==o?o-n:(s.name||"").localeCompare(a.name||"")})),H=!!O.trim(),Z=H||f?W:W.slice(0,20),B=W.length-20;if(m)return(0,r.jsxs)("div",{className:"flex flex-col gap-8",children:[(0,r.jsx)(n.Qv,{}),(0,r.jsx)(n.Qv,{})]});let Q=L.length>0||K.length>0||J.length>0||W.length>0||F.length>0||M.length>0;return(0,r.jsxs)("div",{className:"flex min-w-0 flex-col gap-6 px-1 sm:px-0",children:[(0,r.jsx)(x,{}),!Q&&(0,r.jsxs)("div",{className:"text-center py-8 border border-dashed border-border rounded-xl",children:[(0,r.jsx)("span",{className:"material-symbols-outlined text-[32px] text-text-muted mb-2",children:"search_off"}),(0,r.jsx)("p",{className:"text-text-muted text-sm",children:"No providers match your search"})]}),(0,r.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,r.jsxs)("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[(0,r.jsxs)("div",{className:"min-w-0",children:[(0,r.jsx)("h2",{className:"text-[17px] sm:text-lg font-semibold leading-tight tracking-[-0.01em]",children:"Custom Providers"}),(0,r.jsx)("p",{className:"text-[13px] leading-5 text-text-muted mt-0.5",children:"OpenAI or Anthropic compatible endpoints"})]}),(0,r.jsxs)("div",{className:"grid grid-cols-1 gap-2 sm:flex sm:w-auto sm:shrink-0",children:[(0,r.jsx)(n.$n,{size:"sm",icon:"add",onClick:()=>A(!0),className:"w-full sm:w-auto whitespace-nowrap",children:"Add Anthropic Compatible"}),(0,r.jsx)(n.$n,{size:"sm",variant:"secondary",icon:"add",onClick:()=>C(!0),className:"w-full sm:w-auto whitespace-nowrap",children:"Add OpenAI Compatible"})]})]}),0===F.length&&0===M.length?(0,r.jsxs)("div",{className:"flex items-center justify-center gap-2 py-2 border border-dashed border-border rounded-xl text-text-muted text-sm",children:[(0,r.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:"extension"}),(0,r.jsx)("span",{children:"No custom providers — use buttons above to add OpenAI/Anthropic compatible endpoints"})]}):(0,r.jsx)("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-2 sm:gap-4 lg:grid-cols-3 xl:grid-cols-4",children:[...F,...M].map(e=>(0,r.jsx)(y,{providerId:e.id,provider:e,stats:q(e.id,"apikey"),authType:"compatible",onToggle:t=>z(e.id,"apikey",t)},e.id))})]}),L.length>0&&(0,r.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,r.jsxs)("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[(0,r.jsx)("h2",{className:"text-lg sm:text-xl font-semibold flex items-center gap-2 leading-tight",children:"OAuth Providers"}),(0,r.jsxs)("div",{className:"flex w-full flex-col gap-2 sm:w-auto sm:flex-row sm:items-center",children:[(0,r.jsx)(g,{}),(0,r.jsxs)("button",{onClick:()=>D("oauth"),disabled:!!S,className:`flex w-full items-center justify-center gap-1.5 rounded-lg border px-3 py-2 text-xs font-medium transition-colors sm:w-auto sm:py-1.5 ${"oauth"===S?"bg-primary/20 border-primary/40 text-primary animate-pulse":"bg-bg border-border text-text-muted hover:text-text-main hover:border-primary/40"}`,title:"Test all OAuth connections","aria-label":"Test all OAuth connections",children:[(0,r.jsx)("span",{className:`material-symbols-outlined text-[14px]${"oauth"===S?" animate-spin":""}`,children:"play_arrow"}),"oauth"===S?"Testing...":"Test All"]})]})]}),(0,r.jsx)("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-2 sm:gap-4 lg:grid-cols-3 xl:grid-cols-4",children:L.map(([e,t])=>(0,r.jsx)(j,{providerId:e,provider:t,stats:q(e,"oauth"),authType:"oauth",onToggle:t=>z(e,"oauth",t)},e))})]}),(K.length>0||J.length>0)&&(0,r.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,r.jsxs)("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[(0,r.jsx)("h2",{className:"text-lg sm:text-xl font-semibold flex items-center gap-2 leading-tight",children:"Free Tier Providers"}),(0,r.jsxs)("button",{onClick:()=>D("free"),disabled:!!S,className:`flex w-full items-center justify-center gap-1.5 rounded-lg border px-3 py-2 text-xs font-medium transition-colors sm:w-auto sm:py-1.5 ${"free"===S?"bg-primary/20 border-primary/40 text-primary animate-pulse":"bg-bg border-border text-text-muted hover:text-text-main hover:border-primary/40"}`,title:"Test all Free connections","aria-label":"Test all Free provider connections",children:[(0,r.jsx)("span",{className:`material-symbols-outlined text-[14px]${"free"===S?" animate-spin":""}`,children:"play_arrow"}),"free"===S?"Testing...":"Test All"]})]}),(0,r.jsxs)("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-2 sm:gap-4 lg:grid-cols-3 xl:grid-cols-4",children:[K.map(([e,t])=>(0,r.jsx)(j,{providerId:e,provider:t,stats:q(e,"oauth"),authType:"free",onToggle:t=>z(e,"oauth",t)},e)),J.map(([e,t])=>(0,r.jsx)(y,{providerId:e,provider:t,stats:q(e,"apikey"),authType:"apikey",onToggle:t=>z(e,"apikey",t)},e))]})]}),W.length>0&&(0,r.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,r.jsxs)("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[(0,r.jsxs)("h2",{className:"text-lg sm:text-xl font-semibold flex items-center gap-2 leading-tight",children:["API Key Providers"," "]}),(0,r.jsxs)("button",{onClick:()=>D("apikey"),disabled:!!S,className:`flex w-full items-center justify-center gap-1.5 rounded-lg border px-3 py-2 text-xs font-medium transition-colors sm:w-auto sm:py-1.5 ${"apikey"===S?"bg-primary/20 border-primary/40 text-primary animate-pulse":"bg-bg border-border text-text-muted hover:text-text-main hover:border-primary/40"}`,title:"Test all API Key connections","aria-label":"Test all API Key connections",children:[(0,r.jsx)("span",{className:`material-symbols-outlined text-[14px]${"apikey"===S?" animate-spin":""}`,children:"play_arrow"}),"apikey"===S?"Testing...":"Test All"]})]}),(0,r.jsx)("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-2 sm:gap-4 lg:grid-cols-3 xl:grid-cols-4",children:Z.map(([e,t])=>(0,r.jsx)(y,{providerId:e,provider:t,stats:q(e,"apikey"),authType:"apikey",onToggle:t=>z(e,"apikey",t)},e))}),!H&&!f&&B>0&&(0,r.jsxs)("button",{onClick:()=>b(!0),className:"flex w-full items-center justify-center gap-1.5 rounded-lg border border-dashed border-primary/40 px-3 py-2.5 text-sm font-medium text-primary transition-colors hover:border-primary hover:bg-primary/5",children:[(0,r.jsx)("span",{className:"material-symbols-outlined text-[16px]",children:"expand_more"}),"Show all ",W.length," providers"]})]}),(0,r.jsx)(N,{isOpen:v,onClose:()=>C(!1),onCreated:e=>{o(t=>[...t,e]),C(!1)}}),(0,r.jsx)(w,{isOpen:T,onClose:()=>A(!1),onCreated:e=>{o(t=>[...t,e]),A(!1)}}),$&&(0,r.jsxs)("div",{className:"fixed inset-0 z-50 flex items-start justify-center px-3 pt-[6vh] sm:pt-[10vh]",onClick:()=>E(null),children:[(0,r.jsx)("div",{className:"absolute inset-0 bg-black/60 backdrop-blur-sm"}),(0,r.jsxs)("div",{className:"relative bg-surface border border-border rounded-xl w-full max-w-[600px] max-h-[86vh] sm:max-h-[80vh] overflow-y-auto shadow-2xl",onClick:e=>e.stopPropagation(),children:[(0,r.jsxs)("div",{className:"sticky top-0 z-10 flex items-center justify-between px-5 py-3 border-b border-border bg-surface/95 backdrop-blur-sm rounded-t-xl",children:[(0,r.jsx)("h3",{className:"font-semibold",children:"Test Results"}),(0,r.jsx)("button",{onClick:()=>E(null),className:"p-1 rounded-lg hover:bg-bg text-text-muted hover:text-text-main transition-colors","aria-label":"Close test results",children:(0,r.jsx)("span",{className:"material-symbols-outlined text-lg",children:"close"})})]}),(0,r.jsx)("div",{className:"p-5",children:(0,r.jsx)(k,{results:$})})]})]})]})}function j({providerId:e,provider:t,stats:s,authType:a,onToggle:l}){let{connected:i,error:d,errorCode:c,errorTime:m,allDisabled:x}=s,h=!!t.noAuth;return(0,r.jsx)(p(),{href:`/dashboard/providers/${e}`,className:"group min-w-0",children:(0,r.jsx)(n.Zp,{padding:"xs",className:`h-full hover:bg-black/[0.01] dark:hover:bg-white/[0.01] transition-colors cursor-pointer ${x?"opacity-50":""}`,children:(0,r.jsxs)("div",{className:"flex min-w-0 items-center justify-between gap-3",children:[(0,r.jsxs)("div",{className:"flex min-w-0 items-center gap-3",children:[(0,r.jsx)("div",{className:"size-8 shrink-0 rounded-lg flex items-center justify-center",style:{backgroundColor:`${t.color?.length>7?t.color:t.color+"15"}`},children:(0,r.jsx)(o.A,{src:`/providers/${t.id}.png`,alt:t.name,size:30,className:"object-contain rounded-lg max-w-[32px] max-h-[32px]",fallbackText:t.textIcon||t.id.slice(0,2).toUpperCase(),fallbackColor:t.color})}),(0,r.jsxs)("div",{className:"min-w-0",children:[(0,r.jsx)("h3",{className:"truncate font-semibold",children:t.name}),(0,r.jsx)("div",{className:"flex min-w-0 items-center gap-1.5 text-xs flex-wrap",children:x?(0,r.jsx)(n.Ex,{variant:"default",size:"sm",children:(0,r.jsxs)("span",{className:"flex items-center gap-1",children:[(0,r.jsx)("span",{className:"material-symbols-outlined text-[12px]",children:"pause_circle"}),"Disabled"]})}):h?(0,r.jsx)(n.Ex,{variant:"success",size:"sm",dot:!0,children:"Ready"}):(0,r.jsxs)(r.Fragment,{children:[b(i,d,c),m&&(0,r.jsx)("span",{className:"text-text-muted",children:m})]})})]})]}),(0,r.jsx)("div",{className:"flex shrink-0 items-center gap-2",children:s.total>0&&(0,r.jsx)("div",{className:"opacity-100 transition-opacity sm:opacity-0 sm:group-hover:opacity-100",onClick:e=>{e.preventDefault(),e.stopPropagation(),l(!!x)},children:(0,r.jsx)(n.lM,{size:"sm",checked:!x,onChange:()=>{},title:x?"Enable provider":"Disable provider"})})})]})})})}function y({providerId:e,provider:t,stats:s,authType:a,onToggle:l}){let{connected:i,error:d,errorCode:m,errorTime:x,allDisabled:h}=s,u=e.startsWith(c.JH),f=e.startsWith(c.DI);return(0,r.jsx)(p(),{href:`/dashboard/providers/${e}`,className:"group min-w-0",children:(0,r.jsx)(n.Zp,{padding:"xs",className:`h-full hover:bg-black/[0.01] dark:hover:bg-white/[0.01] transition-colors cursor-pointer ${h?"opacity-50":""}`,children:(0,r.jsxs)("div",{className:"flex min-w-0 items-center justify-between gap-3",children:[(0,r.jsxs)("div",{className:"flex min-w-0 items-center gap-3",children:[(0,r.jsx)("div",{className:"size-8 shrink-0 rounded-lg flex items-center justify-center",style:{backgroundColor:`${t.color?.length>7?t.color:t.color+"15"}`},children:(0,r.jsx)(o.A,{src:u?"responses"===t.apiType?"/providers/oai-r.png":"/providers/oai-cc.png":f?"/providers/anthropic-m.png":`/providers/${t.id}.png`,alt:t.name,size:30,className:"object-contain rounded-lg max-w-[30px] max-h-[30px]",fallbackText:t.textIcon||t.id.slice(0,2).toUpperCase(),fallbackColor:t.color})}),(0,r.jsxs)("div",{className:"min-w-0",children:[(0,r.jsx)("h3",{className:"truncate font-semibold",children:t.name}),(0,r.jsx)("div",{className:"flex min-w-0 items-center gap-1.5 text-xs flex-wrap",children:h?(0,r.jsx)(n.Ex,{variant:"default",size:"sm",children:(0,r.jsxs)("span",{className:"flex items-center gap-1",children:[(0,r.jsx)("span",{className:"material-symbols-outlined text-[12px]",children:"pause_circle"}),"Disabled"]})}):(0,r.jsxs)(r.Fragment,{children:[b(i,d,m),u&&(0,r.jsx)(n.Ex,{variant:"default",size:"sm",children:"responses"===t.apiType?"Responses":"Chat"}),f&&(0,r.jsx)(n.Ex,{variant:"default",size:"sm",children:"Messages"}),x&&(0,r.jsx)("span",{className:"text-text-muted",children:x})]})})]})]}),(0,r.jsx)("div",{className:"flex shrink-0 items-center gap-2",children:s.total>0&&(0,r.jsx)("div",{className:"opacity-100 transition-opacity sm:opacity-0 sm:group-hover:opacity-100",onClick:e=>{e.preventDefault(),e.stopPropagation(),l(!!h)},children:(0,r.jsx)(n.lM,{size:"sm",checked:!h,onChange:()=>{},title:h?"Enable provider":"Disable provider"})})})]})})})}function N({isOpen:e,onClose:t,onCreated:s}){let[l,i]=(0,a.useState)({name:"",prefix:"",apiType:"chat",baseUrl:"https://api.openai.com/v1"}),[o,d]=(0,a.useState)(!1),[c,m]=(0,a.useState)(""),[p,x]=(0,a.useState)(""),[h,u]=(0,a.useState)(!1),[f,g]=(0,a.useState)(null);(0,a.useEffect)(()=>{i(e=>({...e,baseUrl:"https://api.openai.com/v1"}))},[l.apiType]);let b=async()=>{if(l.name.trim()&&l.prefix.trim()&&l.baseUrl.trim()){d(!0);try{let e=await fetch("/api/provider-nodes",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:l.name,prefix:l.prefix,apiType:l.apiType,baseUrl:l.baseUrl,type:"openai-compatible"})}),t=await e.json();e.ok&&(s(t.node),i({name:"",prefix:"",apiType:"chat",baseUrl:"https://api.openai.com/v1"}),m(""),g(null))}catch(e){console.log("Error creating OpenAI Compatible node:",e)}finally{d(!1)}}},v=async()=>{u(!0);try{let e=await fetch("/api/provider-nodes/validate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({baseUrl:l.baseUrl,apiKey:c,type:"openai-compatible",modelId:p.trim()||void 0})}),t=await e.json();g(t)}catch{g({valid:!1,error:"Network error"})}finally{u(!1)}};return(0,r.jsx)(n.aF,{isOpen:e,title:"Add OpenAI Compatible",onClose:t,children:(0,r.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,r.jsx)(n.pd,{label:"Name",value:l.name,onChange:e=>i({...l,name:e.target.value}),placeholder:"OpenAI Compatible (Prod)",hint:"Required. A friendly label for this node."}),(0,r.jsx)(n.pd,{label:"Prefix",value:l.prefix,onChange:e=>i({...l,prefix:e.target.value}),placeholder:"oc-prod",hint:"Required. Used as the provider prefix for model IDs."}),(0,r.jsx)(n.l6,{label:"API Type",options:[{value:"chat",label:"Chat Completions"},{value:"responses",label:"Responses API"}],value:l.apiType,onChange:e=>i({...l,apiType:e.target.value})}),(0,r.jsx)(n.pd,{label:"Base URL",value:l.baseUrl,onChange:e=>i({...l,baseUrl:e.target.value}),placeholder:"https://api.openai.com/v1",hint:"Use the base URL (ending in /v1) for your OpenAI-compatible API."}),(0,r.jsx)(n.pd,{label:"API Key (for Check)",type:"password",value:c,onChange:e=>m(e.target.value)}),(0,r.jsx)(n.pd,{label:"Model ID (optional)",value:p,onChange:e=>x(e.target.value),placeholder:"e.g. gpt-4, claude-3-opus",hint:"If provider lacks /models endpoint, enter a model ID to validate via chat/completions instead."}),(0,r.jsxs)("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center",children:[(0,r.jsx)(n.$n,{onClick:v,disabled:!c||h||!l.baseUrl.trim(),variant:"secondary",className:"w-full sm:w-auto",children:h?"Checking...":"Check"}),(()=>{if(!f)return null;let{valid:e,error:t,method:s}=f;return e?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(n.Ex,{variant:"success",children:"Valid"}),"chat"===s&&(0,r.jsx)("span",{className:"text-sm text-text-muted",children:"(via inference test)"})]}):(0,r.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,r.jsx)(n.Ex,{variant:"error",children:"Invalid"}),t&&(0,r.jsx)("span",{className:"text-sm text-red-500",children:t})]})})()]}),(0,r.jsxs)("div",{className:"flex flex-col gap-2 sm:flex-row",children:[(0,r.jsx)(n.$n,{onClick:b,fullWidth:!0,disabled:!l.name.trim()||!l.prefix.trim()||!l.baseUrl.trim()||o,children:o?"Creating...":"Create"}),(0,r.jsx)(n.$n,{onClick:t,variant:"ghost",fullWidth:!0,children:"Cancel"})]})]})})}function w({isOpen:e,onClose:t,onCreated:s}){let[l,i]=(0,a.useState)({name:"",prefix:"",baseUrl:"https://api.anthropic.com/v1"}),[o,d]=(0,a.useState)(!1),[c,m]=(0,a.useState)(""),[p,x]=(0,a.useState)(""),[h,u]=(0,a.useState)(!1),[f,g]=(0,a.useState)(null);(0,a.useEffect)(()=>{e&&(g(null),m(""),x(""))},[e]);let b=async()=>{if(l.name.trim()&&l.prefix.trim()&&l.baseUrl.trim()){d(!0);try{let e=await fetch("/api/provider-nodes",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:l.name,prefix:l.prefix,baseUrl:l.baseUrl,type:"anthropic-compatible"})}),t=await e.json();e.ok&&(s(t.node),i({name:"",prefix:"",baseUrl:"https://api.anthropic.com/v1"}),m(""),g(null))}catch(e){console.log("Error creating Anthropic Compatible node:",e)}finally{d(!1)}}},v=async()=>{u(!0);try{let e=await fetch("/api/provider-nodes/validate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({baseUrl:l.baseUrl,apiKey:c,type:"anthropic-compatible",modelId:p.trim()||void 0})}),t=await e.json();g(t)}catch{g({valid:!1,error:"Network error"})}finally{u(!1)}};return(0,r.jsx)(n.aF,{isOpen:e,title:"Add Anthropic Compatible",onClose:t,children:(0,r.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,r.jsx)(n.pd,{label:"Name",value:l.name,onChange:e=>i({...l,name:e.target.value}),placeholder:"Anthropic Compatible (Prod)",hint:"Required. A friendly label for this node."}),(0,r.jsx)(n.pd,{label:"Prefix",value:l.prefix,onChange:e=>i({...l,prefix:e.target.value}),placeholder:"ac-prod",hint:"Required. Used as the provider prefix for model IDs."}),(0,r.jsx)(n.pd,{label:"Base URL",value:l.baseUrl,onChange:e=>i({...l,baseUrl:e.target.value}),placeholder:"https://api.anthropic.com/v1",hint:"Use the base URL (ending in /v1) for your Anthropic-compatible API. The system will append /messages."}),(0,r.jsx)(n.pd,{label:"API Key (for Check)",type:"password",value:c,onChange:e=>m(e.target.value)}),(0,r.jsx)(n.pd,{label:"Model ID (optional)",value:p,onChange:e=>x(e.target.value),placeholder:"e.g. claude-3-opus",hint:"If provider lacks /models endpoint, enter a model ID to validate via chat/completions instead."}),(0,r.jsxs)("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center",children:[(0,r.jsx)(n.$n,{onClick:v,disabled:!c||h||!l.baseUrl.trim(),variant:"secondary",className:"w-full sm:w-auto",children:h?"Checking...":"Check"}),(()=>{if(!f)return null;let{valid:e,error:t,method:s}=f;return e?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(n.Ex,{variant:"success",children:"Valid"}),"chat"===s&&(0,r.jsx)("span",{className:"text-sm text-text-muted",children:"(via inference test)"})]}):(0,r.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,r.jsx)(n.Ex,{variant:"error",children:"Invalid"}),t&&(0,r.jsx)("span",{className:"text-sm text-red-500",children:t})]})})()]}),(0,r.jsxs)("div",{className:"flex flex-col gap-2 sm:flex-row",children:[(0,r.jsx)(n.$n,{onClick:b,fullWidth:!0,disabled:!l.name.trim()||!l.prefix.trim()||!l.baseUrl.trim()||o,children:o?"Creating...":"Create"}),(0,r.jsx)(n.$n,{onClick:t,variant:"ghost",fullWidth:!0,children:"Cancel"})]})]})})}function k({results:e}){if(e.error&&!e.results)return(0,r.jsxs)("div",{className:"text-center py-6",children:[(0,r.jsx)("span",{className:"material-symbols-outlined text-red-500 text-[32px] mb-2 block",children:"error"}),(0,r.jsx)("p",{className:"text-sm text-red-400",children:e.error})]});let{summary:t,mode:s}=e,a=e.results||[];return(0,r.jsxs)("div",{className:"flex min-w-0 flex-col gap-3",children:[t&&(0,r.jsxs)("div",{className:"flex flex-wrap items-center gap-2 text-xs mb-1 sm:gap-3",children:[(0,r.jsxs)("span",{className:"text-text-muted",children:[{oauth:"OAuth",free:"Free",apikey:"API Key",provider:"Provider",all:"All"}[s]||s," Test"]}),(0,r.jsxs)("span",{className:"px-2 py-0.5 rounded bg-emerald-500/15 text-emerald-400 font-medium",children:[t.passed," passed"]}),t.failed>0&&(0,r.jsxs)("span",{className:"px-2 py-0.5 rounded bg-red-500/15 text-red-400 font-medium",children:[t.failed," failed"]}),(0,r.jsxs)("span",{className:"text-text-muted sm:ml-auto",children:[t.total," tested"]})]}),a.map((e,t)=>(0,r.jsxs)("div",{className:"flex min-w-0 flex-wrap items-center gap-2 rounded-lg bg-black/[0.03] px-3 py-2 text-xs dark:bg-white/[0.03] sm:flex-nowrap",children:[(0,r.jsx)("span",{className:`material-symbols-outlined text-[16px] ${e.valid?"text-emerald-500":"text-red-500"}`,children:e.valid?"check_circle":"error"}),(0,r.jsxs)("div",{className:"min-w-0 flex-[1_1_160px]",children:[(0,r.jsx)("span",{className:"block truncate font-medium sm:inline",children:e.connectionName}),(0,r.jsxs)("span",{className:"block truncate text-text-muted sm:ml-1.5 sm:inline",children:["(",e.provider,")"]})]}),void 0!==e.latencyMs&&(0,r.jsxs)("span",{className:"shrink-0 text-text-muted font-mono tabular-nums",children:[e.latencyMs,"ms"]}),(0,r.jsx)("span",{className:`shrink-0 text-[10px] uppercase font-bold px-1.5 py-0.5 rounded ${e.valid?"bg-emerald-500/15 text-emerald-400":"bg-red-500/15 text-red-400"}`,children:e.valid?"OK":e.diagnosis?.type||"ERROR"})]},e.connectionId||t)),0===a.length&&(0,r.jsx)("div",{className:"text-center py-4 text-text-muted text-sm",children:"No active connections found for this group."})]})}j.propTypes={providerId:i().string.isRequired,provider:i().shape({id:i().string.isRequired,name:i().string.isRequired,color:i().string,textIcon:i().string}).isRequired,stats:i().shape({connected:i().number,error:i().number,errorCode:i().string,errorTime:i().string}).isRequired,authType:i().string,onToggle:i().func},y.propTypes={providerId:i().string.isRequired,provider:i().shape({id:i().string.isRequired,name:i().string.isRequired,color:i().string,textIcon:i().string,apiType:i().string}).isRequired,stats:i().shape({connected:i().number,error:i().number,errorCode:i().string,errorTime:i().string}).isRequired,authType:i().string,onToggle:i().func},N.propTypes={isOpen:i().bool.isRequired,onClose:i().func.isRequired,onCreated:i().func.isRequired},w.propTypes={isOpen:i().bool.isRequired,onClose:i().func.isRequired,onCreated:i().func.isRequired},k.propTypes={results:i().shape({mode:i().string,results:i().array,summary:i().shape({total:i().number,passed:i().number,failed:i().number}),error:i().string}).isRequired}},69343:(e,t,s)=>{Promise.resolve().then(s.bind(s,18160))}},e=>{e.O(0,[7504,1321,5497,8441,3794,7358],()=>e(e.s=69343)),_N_E=e.O()}]);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[3528],{10097:(e,t,a)=>{Promise.resolve().then(a.bind(a,76084))},76084:(e,t,a)=>{"use strict";a.r(t),a.d(t,{default:()=>c});var s=a(95155),n=a(12115),r=a(35497),l=a(11059);let o=(0,a(37206).default)(()=>a.e(8202).then(a.bind(a,28202)),{loadableGenerated:{webpack:()=>[28202]},ssr:!1}),i=[{id:1,label:"Client Request",file:"1_req_client.json",lang:"json",desc:"Raw request from client"},{id:2,label:"Source Body",file:"2_req_source.json",lang:"json",desc:"After initial conversion"},{id:3,label:"OpenAI Intermediate",file:"3_req_openai.json",lang:"json",desc:"source → openai"},{id:4,label:"Target Request",file:"4_req_target.json",lang:"json",desc:"openai → target + URL + headers"},{id:5,label:"Provider Response",file:"5_res_provider.txt",lang:"text",desc:"Raw SSE from provider"},{id:6,label:"OpenAI Response",file:"6_res_openai.txt",lang:"text",desc:"target → openai (response)"},{id:7,label:"Client Response",file:"7_res_client.txt",lang:"text",desc:"Final response to client"}],d={minimap:{enabled:!1},fontSize:12,lineNumbers:"on",scrollBeyondLastLine:!1,wordWrap:"on",automaticLayout:!0};function c(){let[e,t]=(0,n.useState)({}),[a,c]=(0,n.useState)({1:!0}),[x,m]=(0,n.useState)({}),[u,f]=(0,n.useState)(null),h=(e,t)=>m(a=>({...a,[e]:t})),g=(e,a)=>t(t=>({...t,[e]:a})),j=e=>c(t=>{let a={};return i.forEach(e=>{a[e.id]=!1}),a[e]=!0,a}),y=async e=>{let t=i.find(t=>t.id===e);h(`load-${e}`,!0);try{let a=await fetch(`/api/translator/load?file=${t.file}`),s=await a.json();s.success?(g(e,s.content),1===e&&await b(s.content)):alert(s.error||"File not found")}catch(e){alert(e.message)}h(`load-${e}`,!1)},b=async e=>{try{let t="string"==typeof e?JSON.parse(e):e,a=await fetch("/api/translator/translate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({step:1,body:t})}),s=await a.json();s.success&&f(s.result)}catch{}},v=(e,t)=>fetch("/api/translator/save",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({file:e,content:t})}).catch(()=>{}),_=async()=>{h("toOpenAI",!0);try{let t=e[1],a=JSON.parse(t);v("1_req_client.json",t),v("2_req_source.json",JSON.stringify({timestamp:new Date().toISOString(),headers:{},body:a.body||a},null,2));let s=await fetch("/api/translator/translate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({step:2,body:a})}),n=await s.json();if(!n.success)return void alert(n.error);let r=JSON.stringify(n.result.body,null,2);g(3,r),j(3)}catch(e){alert(e.message)}h("toOpenAI",!1)},N=async()=>{h("toTarget",!0);try{let t=e[3],a=JSON.parse(t);v("3_req_openai.json",t);let s=await fetch("/api/translator/translate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({step:3,body:{...a,provider:u?.provider,model:u?.model}})}),n=await s.json();if(!n.success)return void alert(n.error);let r={...n.result,provider:u?.provider,model:u?.model};g(4,JSON.stringify(r,null,2)),j(4)}catch(e){alert(e.message)}h("toTarget",!1)},w=async()=>{h("send",!0);try{let t=e[4],a=JSON.parse(t);v("4_req_target.json",t);let s=a.provider||u?.provider,n=a.model||u?.model;if(!s||!n)return void alert("Missing provider or model. Please run step 1 first to detect them.");let r=await fetch("/api/translator/send",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:s,model:n,body:a.body||a})});if(!r.ok){let e=await r.json().catch(()=>({error:r.statusText}));alert(e.error||"Send failed");return}let l=r.body.getReader(),o=new TextDecoder,i="";for(;;){let{done:e,value:t}=await l.read();if(e)break;i+=o.decode(t,{stream:!0})}g(5,i),j(5),await fetch("/api/translator/save",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({file:"5_res_provider.txt",content:i})})}catch(e){alert(e.message)}finally{h("send",!1)}},{copy:S}=(0,l.C)(),O=async t=>{e[t]&&S(e[t],`translator-step-${t}`)};return(0,s.jsxs)("div",{className:"p-8 space-y-3",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between mb-2",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("h1",{className:"text-2xl font-bold text-text-main",children:"Translator Debug"}),(0,s.jsx)("p",{className:"text-sm text-text-muted mt-1",children:"Replay request flow — matches log files"})]}),u&&(0,s.jsxs)("div",{className:"flex items-center gap-2 flex-wrap justify-end",children:[(0,s.jsx)(p,{label:"src",value:u.sourceFormat,color:"blue"}),(0,s.jsx)("span",{className:"material-symbols-outlined text-text-muted text-[14px]",children:"arrow_forward"}),(0,s.jsx)(p,{label:"dst",value:u.targetFormat,color:"orange"}),(0,s.jsx)(p,{label:"provider",value:u.provider,color:"green"}),(0,s.jsx)(p,{label:"model",value:u.model,color:"purple"})]})]}),i.map(t=>{var n;let l=1===(n=t.id)?(0,s.jsx)(r.$n,{size:"sm",icon:"arrow_forward",loading:x.toOpenAI,onClick:_,children:"→ OpenAI"}):3===n?(0,s.jsx)(r.$n,{size:"sm",icon:"arrow_forward",loading:x.toTarget,onClick:N,children:"→ Target"}):4===n?(0,s.jsx)(r.$n,{size:"sm",icon:"send",loading:x.send,onClick:w,children:"Send"}):null,i=!!a[t.id],p=e[t.id]||"";return(0,s.jsx)(r.Zp,{children:(0,s.jsxs)("div",{className:"p-4 space-y-3",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between",children:[(0,s.jsxs)("button",{onClick:()=>{let e;return e=t.id,c(t=>({...t,[e]:!t[e]}))},className:"flex items-center gap-2 flex-1 text-left group",children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-[20px] text-text-muted group-hover:text-primary transition-colors",children:i?"expand_more":"chevron_right"}),(0,s.jsx)("span",{className:"text-xs font-mono text-text-muted
|
|
1
|
+
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[3528],{10097:(e,t,a)=>{Promise.resolve().then(a.bind(a,76084))},76084:(e,t,a)=>{"use strict";a.r(t),a.d(t,{default:()=>c});var s=a(95155),n=a(12115),r=a(35497),l=a(11059);let o=(0,a(37206).default)(()=>a.e(8202).then(a.bind(a,28202)),{loadableGenerated:{webpack:()=>[28202]},ssr:!1}),i=[{id:1,label:"Client Request",file:"1_req_client.json",lang:"json",desc:"Raw request from client"},{id:2,label:"Source Body",file:"2_req_source.json",lang:"json",desc:"After initial conversion"},{id:3,label:"OpenAI Intermediate",file:"3_req_openai.json",lang:"json",desc:"source → openai"},{id:4,label:"Target Request",file:"4_req_target.json",lang:"json",desc:"openai → target + URL + headers"},{id:5,label:"Provider Response",file:"5_res_provider.txt",lang:"text",desc:"Raw SSE from provider"},{id:6,label:"OpenAI Response",file:"6_res_openai.txt",lang:"text",desc:"target → openai (response)"},{id:7,label:"Client Response",file:"7_res_client.txt",lang:"text",desc:"Final response to client"}],d={minimap:{enabled:!1},fontSize:12,lineNumbers:"on",scrollBeyondLastLine:!1,wordWrap:"on",automaticLayout:!0};function c(){let[e,t]=(0,n.useState)({}),[a,c]=(0,n.useState)({1:!0}),[x,m]=(0,n.useState)({}),[u,f]=(0,n.useState)(null),h=(e,t)=>m(a=>({...a,[e]:t})),g=(e,a)=>t(t=>({...t,[e]:a})),j=e=>c(t=>{let a={};return i.forEach(e=>{a[e.id]=!1}),a[e]=!0,a}),y=async e=>{let t=i.find(t=>t.id===e);h(`load-${e}`,!0);try{let a=await fetch(`/api/translator/load?file=${t.file}`),s=await a.json();s.success?(g(e,s.content),1===e&&await b(s.content)):alert(s.error||"File not found")}catch(e){alert(e.message)}h(`load-${e}`,!1)},b=async e=>{try{let t="string"==typeof e?JSON.parse(e):e,a=await fetch("/api/translator/translate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({step:1,body:t})}),s=await a.json();s.success&&f(s.result)}catch{}},v=(e,t)=>fetch("/api/translator/save",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({file:e,content:t})}).catch(()=>{}),_=async()=>{h("toOpenAI",!0);try{let t=e[1],a=JSON.parse(t);v("1_req_client.json",t),v("2_req_source.json",JSON.stringify({timestamp:new Date().toISOString(),headers:{},body:a.body||a},null,2));let s=await fetch("/api/translator/translate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({step:2,body:a})}),n=await s.json();if(!n.success)return void alert(n.error);let r=JSON.stringify(n.result.body,null,2);g(3,r),j(3)}catch(e){alert(e.message)}h("toOpenAI",!1)},N=async()=>{h("toTarget",!0);try{let t=e[3],a=JSON.parse(t);v("3_req_openai.json",t);let s=await fetch("/api/translator/translate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({step:3,body:{...a,provider:u?.provider,model:u?.model}})}),n=await s.json();if(!n.success)return void alert(n.error);let r={...n.result,provider:u?.provider,model:u?.model};g(4,JSON.stringify(r,null,2)),j(4)}catch(e){alert(e.message)}h("toTarget",!1)},w=async()=>{h("send",!0);try{let t=e[4],a=JSON.parse(t);v("4_req_target.json",t);let s=a.provider||u?.provider,n=a.model||u?.model;if(!s||!n)return void alert("Missing provider or model. Please run step 1 first to detect them.");let r=await fetch("/api/translator/send",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:s,model:n,body:a.body||a})});if(!r.ok){let e=await r.json().catch(()=>({error:r.statusText}));alert(e.error||"Send failed");return}let l=r.body.getReader(),o=new TextDecoder,i="";for(;;){let{done:e,value:t}=await l.read();if(e)break;i+=o.decode(t,{stream:!0})}g(5,i),j(5),await fetch("/api/translator/save",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({file:"5_res_provider.txt",content:i})})}catch(e){alert(e.message)}finally{h("send",!1)}},{copy:S}=(0,l.C)(),O=async t=>{e[t]&&S(e[t],`translator-step-${t}`)};return(0,s.jsxs)("div",{className:"p-8 space-y-3",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between mb-2",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("h1",{className:"text-2xl font-bold text-text-main",children:"Translator Debug"}),(0,s.jsx)("p",{className:"text-sm text-text-muted mt-1",children:"Replay request flow — matches log files"})]}),u&&(0,s.jsxs)("div",{className:"flex items-center gap-2 flex-wrap justify-end",children:[(0,s.jsx)(p,{label:"src",value:u.sourceFormat,color:"blue"}),(0,s.jsx)("span",{className:"material-symbols-outlined text-text-muted text-[14px]",children:"arrow_forward"}),(0,s.jsx)(p,{label:"dst",value:u.targetFormat,color:"orange"}),(0,s.jsx)(p,{label:"provider",value:u.provider,color:"green"}),(0,s.jsx)(p,{label:"model",value:u.model,color:"purple"})]})]}),i.map(t=>{var n;let l=1===(n=t.id)?(0,s.jsx)(r.$n,{size:"sm",icon:"arrow_forward",loading:x.toOpenAI,onClick:_,children:"→ OpenAI"}):3===n?(0,s.jsx)(r.$n,{size:"sm",icon:"arrow_forward",loading:x.toTarget,onClick:N,children:"→ Target"}):4===n?(0,s.jsx)(r.$n,{size:"sm",icon:"send",loading:x.send,onClick:w,children:"Send"}):null,i=!!a[t.id],p=e[t.id]||"";return(0,s.jsx)(r.Zp,{children:(0,s.jsxs)("div",{className:"p-4 space-y-3",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between",children:[(0,s.jsxs)("button",{onClick:()=>{let e;return e=t.id,c(t=>({...t,[e]:!t[e]}))},className:"flex items-center gap-2 flex-1 text-left group",children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-[20px] text-text-muted group-hover:text-primary transition-colors",children:i?"expand_more":"chevron_right"}),(0,s.jsx)("span",{className:"text-xs font-mono text-text-muted w-4",children:t.id}),(0,s.jsx)("h3",{className:"text-sm font-semibold text-text-main",children:t.label}),(0,s.jsx)("span",{className:"text-xs text-text-muted font-mono",children:t.file}),p&&(0,s.jsxs)("span",{className:"text-xs text-green-500",children:["(",p.length," chars)"]})]}),!i&&(0,s.jsxs)("div",{className:"flex gap-1 shrink-0",children:[(0,s.jsx)(r.$n,{size:"sm",variant:"ghost",icon:"folder_open",loading:x[`load-${t.id}`],onClick:()=>y(t.id)}),l]})]}),i&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("div",{className:"border border-border rounded-lg overflow-hidden",children:(0,s.jsx)(o,{height:"400px",defaultLanguage:"text"===t.lang?"plaintext":"json",value:p,onChange:e=>{g(t.id,e||""),1===t.id&&b(e||"")},theme:"vs-dark",options:d})}),(0,s.jsxs)("div",{className:"flex gap-2 flex-wrap",children:[(0,s.jsx)(r.$n,{size:"sm",variant:"outline",icon:"folder_open",loading:x[`load-${t.id}`],onClick:()=>y(t.id),children:"Load"}),(0,s.jsx)(r.$n,{size:"sm",variant:"outline",icon:"data_object",onClick:()=>(t=>{try{let a=JSON.parse(e[t]);g(t,JSON.stringify(a,null,2))}catch{}})(t.id),children:"Format"}),(0,s.jsx)(r.$n,{size:"sm",variant:"outline",icon:"content_copy",onClick:()=>O(t.id),children:"Copy"}),l]})]})]})},t.id)})]})}function p({label:e,value:t,color:a}){return(0,s.jsxs)("span",{className:`inline-flex items-center gap-1 px-2 py-0.5 rounded text-xs font-mono ${{blue:"bg-blue-500/10 text-blue-500",orange:"bg-orange-500/10 text-orange-500",green:"bg-green-500/10 text-green-500",purple:"bg-purple-500/10 text-purple-500"}[a]}`,children:[(0,s.jsxs)("span",{className:"text-text-muted font-sans text-[10px]",children:[e,":"]}),t]})}}},e=>{e.O(0,[7504,1321,5497,8441,3794,7358],()=>e(e.s=10097)),_N_E=e.O()}]);
|