zevairouter 1.0.178 → 1.0.180
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/CHANGELOG.md +11 -0
- package/cli/app/.next-cli-build/BUILD_ID +1 -1
- package/cli/app/.next-cli-build/app-path-routes-manifest.json +10 -10
- package/cli/app/.next-cli-build/build-manifest.json +2 -2
- package/cli/app/.next-cli-build/server/app/(dashboard)/dashboard/automation/page_client-reference-manifest.js +1 -1
- package/cli/app/.next-cli-build/server/app/(dashboard)/dashboard/basic-chat/page_client-reference-manifest.js +1 -1
- package/cli/app/.next-cli-build/server/app/(dashboard)/dashboard/cli-tools/[toolId]/page.js +1 -1
- package/cli/app/.next-cli-build/server/app/(dashboard)/dashboard/cli-tools/[toolId]/page_client-reference-manifest.js +1 -1
- package/cli/app/.next-cli-build/server/app/(dashboard)/dashboard/cli-tools/page.js +1 -1
- package/cli/app/.next-cli-build/server/app/(dashboard)/dashboard/cli-tools/page_client-reference-manifest.js +1 -1
- package/cli/app/.next-cli-build/server/app/(dashboard)/dashboard/combos/page_client-reference-manifest.js +1 -1
- package/cli/app/.next-cli-build/server/app/(dashboard)/dashboard/console-log/page_client-reference-manifest.js +1 -1
- package/cli/app/.next-cli-build/server/app/(dashboard)/dashboard/context/page_client-reference-manifest.js +1 -1
- package/cli/app/.next-cli-build/server/app/(dashboard)/dashboard/endpoint/page_client-reference-manifest.js +1 -1
- package/cli/app/.next-cli-build/server/app/(dashboard)/dashboard/media-providers/[kind]/[id]/page.js +9 -9
- package/cli/app/.next-cli-build/server/app/(dashboard)/dashboard/media-providers/[kind]/[id]/page_client-reference-manifest.js +1 -1
- package/cli/app/.next-cli-build/server/app/(dashboard)/dashboard/media-providers/[kind]/page.js +1 -1
- package/cli/app/.next-cli-build/server/app/(dashboard)/dashboard/media-providers/[kind]/page_client-reference-manifest.js +1 -1
- package/cli/app/.next-cli-build/server/app/(dashboard)/dashboard/media-providers/combo/[id]/page.js +2 -2
- package/cli/app/.next-cli-build/server/app/(dashboard)/dashboard/media-providers/combo/[id]/page_client-reference-manifest.js +1 -1
- package/cli/app/.next-cli-build/server/app/(dashboard)/dashboard/media-providers/web/page.js +1 -1
- package/cli/app/.next-cli-build/server/app/(dashboard)/dashboard/media-providers/web/page_client-reference-manifest.js +1 -1
- package/cli/app/.next-cli-build/server/app/(dashboard)/dashboard/mitm/page_client-reference-manifest.js +1 -1
- package/cli/app/.next-cli-build/server/app/(dashboard)/dashboard/page_client-reference-manifest.js +1 -1
- package/cli/app/.next-cli-build/server/app/(dashboard)/dashboard/playground/page_client-reference-manifest.js +1 -1
- package/cli/app/.next-cli-build/server/app/(dashboard)/dashboard/profile/page_client-reference-manifest.js +1 -1
- package/cli/app/.next-cli-build/server/app/(dashboard)/dashboard/providers/[id]/page.js +2 -2
- package/cli/app/.next-cli-build/server/app/(dashboard)/dashboard/providers/[id]/page_client-reference-manifest.js +1 -1
- package/cli/app/.next-cli-build/server/app/(dashboard)/dashboard/providers/new/page.js +1 -1
- package/cli/app/.next-cli-build/server/app/(dashboard)/dashboard/providers/new/page_client-reference-manifest.js +1 -1
- package/cli/app/.next-cli-build/server/app/(dashboard)/dashboard/providers/page.js +2 -2
- package/cli/app/.next-cli-build/server/app/(dashboard)/dashboard/providers/page_client-reference-manifest.js +1 -1
- package/cli/app/.next-cli-build/server/app/(dashboard)/dashboard/proxy-pools/page_client-reference-manifest.js +1 -1
- package/cli/app/.next-cli-build/server/app/(dashboard)/dashboard/pxpipe/page_client-reference-manifest.js +1 -1
- package/cli/app/.next-cli-build/server/app/(dashboard)/dashboard/quota/page.js +1 -1
- package/cli/app/.next-cli-build/server/app/(dashboard)/dashboard/quota/page_client-reference-manifest.js +1 -1
- package/cli/app/.next-cli-build/server/app/(dashboard)/dashboard/settings/pricing/page.js +1 -1
- package/cli/app/.next-cli-build/server/app/(dashboard)/dashboard/settings/pricing/page_client-reference-manifest.js +1 -1
- package/cli/app/.next-cli-build/server/app/(dashboard)/dashboard/terminal/page_client-reference-manifest.js +1 -1
- package/cli/app/.next-cli-build/server/app/(dashboard)/dashboard/token-saver/page_client-reference-manifest.js +1 -1
- package/cli/app/.next-cli-build/server/app/(dashboard)/dashboard/translator/page_client-reference-manifest.js +1 -1
- package/cli/app/.next-cli-build/server/app/(dashboard)/dashboard/usage/page.js +1 -1
- package/cli/app/.next-cli-build/server/app/(dashboard)/dashboard/usage/page_client-reference-manifest.js +1 -1
- package/cli/app/.next-cli-build/server/app/_global-error/page_client-reference-manifest.js +1 -1
- package/cli/app/.next-cli-build/server/app/_global-error.html +1 -1
- package/cli/app/.next-cli-build/server/app/_global-error.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/_global-error.segments/_full.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/_global-error.segments/_global-error/__PAGE__.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/_global-error.segments/_global-error.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/_global-error.segments/_head.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/_global-error.segments/_index.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/_global-error.segments/_tree.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/_not-found/page_client-reference-manifest.js +1 -1
- package/cli/app/.next-cli-build/server/app/_not-found.html +1 -1
- package/cli/app/.next-cli-build/server/app/_not-found.rsc +4 -4
- package/cli/app/.next-cli-build/server/app/_not-found.segments/_full.segment.rsc +4 -4
- package/cli/app/.next-cli-build/server/app/_not-found.segments/_head.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/_not-found.segments/_index.segment.rsc +4 -4
- package/cli/app/.next-cli-build/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/_not-found.segments/_not-found.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/_not-found.segments/_tree.segment.rsc +2 -2
- package/cli/app/.next-cli-build/server/app/api/cli-tools/cowork-settings/route.js +1 -1
- package/cli/app/.next-cli-build/server/app/api/models/route.js +1 -1
- package/cli/app/.next-cli-build/server/app/api/providers/route.js +1 -1
- package/cli/app/.next-cli-build/server/app/api/providers/validate/route.js +1 -1
- package/cli/app/.next-cli-build/server/app/api/translator/console-logs/route.js +1 -1
- package/cli/app/.next-cli-build/server/app/api/translator/console-logs/stream/route.js +1 -1
- package/cli/app/.next-cli-build/server/app/api/version/route.js +1 -1
- package/cli/app/.next-cli-build/server/app/api/version/shutdown/route.js +1 -1
- package/cli/app/.next-cli-build/server/app/api/version/update/route.js +1 -1
- package/cli/app/.next-cli-build/server/app/callback/page_client-reference-manifest.js +1 -1
- package/cli/app/.next-cli-build/server/app/callback.html +1 -1
- package/cli/app/.next-cli-build/server/app/callback.rsc +4 -4
- package/cli/app/.next-cli-build/server/app/callback.segments/_full.segment.rsc +4 -4
- package/cli/app/.next-cli-build/server/app/callback.segments/_head.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/callback.segments/_index.segment.rsc +4 -4
- package/cli/app/.next-cli-build/server/app/callback.segments/_tree.segment.rsc +2 -2
- package/cli/app/.next-cli-build/server/app/callback.segments/callback/__PAGE__.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/callback.segments/callback.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/automation.html +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/automation.rsc +6 -6
- package/cli/app/.next-cli-build/server/app/dashboard/automation.segments/!KGRhc2hib2FyZCk/dashboard/automation/__PAGE__.segment.rsc +2 -2
- package/cli/app/.next-cli-build/server/app/dashboard/automation.segments/!KGRhc2hib2FyZCk/dashboard/automation.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/automation.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/automation.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
- package/cli/app/.next-cli-build/server/app/dashboard/automation.segments/_full.segment.rsc +6 -6
- package/cli/app/.next-cli-build/server/app/dashboard/automation.segments/_head.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/automation.segments/_index.segment.rsc +4 -4
- package/cli/app/.next-cli-build/server/app/dashboard/automation.segments/_tree.segment.rsc +2 -2
- package/cli/app/.next-cli-build/server/app/dashboard/basic-chat.html +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/basic-chat.rsc +6 -6
- package/cli/app/.next-cli-build/server/app/dashboard/basic-chat.segments/!KGRhc2hib2FyZCk/dashboard/basic-chat/__PAGE__.segment.rsc +2 -2
- package/cli/app/.next-cli-build/server/app/dashboard/basic-chat.segments/!KGRhc2hib2FyZCk/dashboard/basic-chat.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/basic-chat.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/basic-chat.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
- package/cli/app/.next-cli-build/server/app/dashboard/basic-chat.segments/_full.segment.rsc +6 -6
- package/cli/app/.next-cli-build/server/app/dashboard/basic-chat.segments/_head.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/basic-chat.segments/_index.segment.rsc +4 -4
- package/cli/app/.next-cli-build/server/app/dashboard/basic-chat.segments/_tree.segment.rsc +2 -2
- package/cli/app/.next-cli-build/server/app/dashboard/cli-tools.html +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/cli-tools.rsc +6 -6
- package/cli/app/.next-cli-build/server/app/dashboard/cli-tools.segments/!KGRhc2hib2FyZCk/dashboard/cli-tools/__PAGE__.segment.rsc +2 -2
- package/cli/app/.next-cli-build/server/app/dashboard/cli-tools.segments/!KGRhc2hib2FyZCk/dashboard/cli-tools.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/cli-tools.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/cli-tools.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
- package/cli/app/.next-cli-build/server/app/dashboard/cli-tools.segments/_full.segment.rsc +6 -6
- package/cli/app/.next-cli-build/server/app/dashboard/cli-tools.segments/_head.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/cli-tools.segments/_index.segment.rsc +4 -4
- package/cli/app/.next-cli-build/server/app/dashboard/cli-tools.segments/_tree.segment.rsc +2 -2
- package/cli/app/.next-cli-build/server/app/dashboard/combos.html +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/combos.rsc +6 -6
- package/cli/app/.next-cli-build/server/app/dashboard/combos.segments/!KGRhc2hib2FyZCk/dashboard/combos/__PAGE__.segment.rsc +2 -2
- package/cli/app/.next-cli-build/server/app/dashboard/combos.segments/!KGRhc2hib2FyZCk/dashboard/combos.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/combos.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/combos.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
- package/cli/app/.next-cli-build/server/app/dashboard/combos.segments/_full.segment.rsc +6 -6
- package/cli/app/.next-cli-build/server/app/dashboard/combos.segments/_head.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/combos.segments/_index.segment.rsc +4 -4
- package/cli/app/.next-cli-build/server/app/dashboard/combos.segments/_tree.segment.rsc +2 -2
- package/cli/app/.next-cli-build/server/app/dashboard/context.html +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/context.rsc +6 -6
- package/cli/app/.next-cli-build/server/app/dashboard/context.segments/!KGRhc2hib2FyZCk/dashboard/context/__PAGE__.segment.rsc +2 -2
- package/cli/app/.next-cli-build/server/app/dashboard/context.segments/!KGRhc2hib2FyZCk/dashboard/context.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/context.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/context.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
- package/cli/app/.next-cli-build/server/app/dashboard/context.segments/_full.segment.rsc +6 -6
- package/cli/app/.next-cli-build/server/app/dashboard/context.segments/_head.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/context.segments/_index.segment.rsc +4 -4
- package/cli/app/.next-cli-build/server/app/dashboard/context.segments/_tree.segment.rsc +2 -2
- package/cli/app/.next-cli-build/server/app/dashboard/endpoint.html +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/endpoint.rsc +6 -6
- package/cli/app/.next-cli-build/server/app/dashboard/endpoint.segments/!KGRhc2hib2FyZCk/dashboard/endpoint/__PAGE__.segment.rsc +2 -2
- package/cli/app/.next-cli-build/server/app/dashboard/endpoint.segments/!KGRhc2hib2FyZCk/dashboard/endpoint.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/endpoint.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/endpoint.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
- package/cli/app/.next-cli-build/server/app/dashboard/endpoint.segments/_full.segment.rsc +6 -6
- package/cli/app/.next-cli-build/server/app/dashboard/endpoint.segments/_head.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/endpoint.segments/_index.segment.rsc +4 -4
- package/cli/app/.next-cli-build/server/app/dashboard/endpoint.segments/_tree.segment.rsc +2 -2
- package/cli/app/.next-cli-build/server/app/dashboard/media-providers/web.html +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/media-providers/web.rsc +6 -6
- package/cli/app/.next-cli-build/server/app/dashboard/media-providers/web.segments/!KGRhc2hib2FyZCk/dashboard/media-providers/web/__PAGE__.segment.rsc +2 -2
- package/cli/app/.next-cli-build/server/app/dashboard/media-providers/web.segments/!KGRhc2hib2FyZCk/dashboard/media-providers/web.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/media-providers/web.segments/!KGRhc2hib2FyZCk/dashboard/media-providers.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/media-providers/web.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/media-providers/web.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
- package/cli/app/.next-cli-build/server/app/dashboard/media-providers/web.segments/_full.segment.rsc +6 -6
- package/cli/app/.next-cli-build/server/app/dashboard/media-providers/web.segments/_head.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/media-providers/web.segments/_index.segment.rsc +4 -4
- package/cli/app/.next-cli-build/server/app/dashboard/media-providers/web.segments/_tree.segment.rsc +2 -2
- package/cli/app/.next-cli-build/server/app/dashboard/mitm.html +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/mitm.rsc +6 -6
- package/cli/app/.next-cli-build/server/app/dashboard/mitm.segments/!KGRhc2hib2FyZCk/dashboard/mitm/__PAGE__.segment.rsc +2 -2
- package/cli/app/.next-cli-build/server/app/dashboard/mitm.segments/!KGRhc2hib2FyZCk/dashboard/mitm.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/mitm.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/mitm.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
- package/cli/app/.next-cli-build/server/app/dashboard/mitm.segments/_full.segment.rsc +6 -6
- package/cli/app/.next-cli-build/server/app/dashboard/mitm.segments/_head.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/mitm.segments/_index.segment.rsc +4 -4
- package/cli/app/.next-cli-build/server/app/dashboard/mitm.segments/_tree.segment.rsc +2 -2
- package/cli/app/.next-cli-build/server/app/dashboard/playground.html +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/playground.rsc +6 -6
- package/cli/app/.next-cli-build/server/app/dashboard/playground.segments/!KGRhc2hib2FyZCk/dashboard/playground/__PAGE__.segment.rsc +2 -2
- package/cli/app/.next-cli-build/server/app/dashboard/playground.segments/!KGRhc2hib2FyZCk/dashboard/playground.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/playground.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/playground.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
- package/cli/app/.next-cli-build/server/app/dashboard/playground.segments/_full.segment.rsc +6 -6
- package/cli/app/.next-cli-build/server/app/dashboard/playground.segments/_head.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/playground.segments/_index.segment.rsc +4 -4
- package/cli/app/.next-cli-build/server/app/dashboard/playground.segments/_tree.segment.rsc +2 -2
- package/cli/app/.next-cli-build/server/app/dashboard/profile.html +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/profile.rsc +6 -6
- package/cli/app/.next-cli-build/server/app/dashboard/profile.segments/!KGRhc2hib2FyZCk/dashboard/profile/__PAGE__.segment.rsc +2 -2
- package/cli/app/.next-cli-build/server/app/dashboard/profile.segments/!KGRhc2hib2FyZCk/dashboard/profile.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/profile.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/profile.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
- package/cli/app/.next-cli-build/server/app/dashboard/profile.segments/_full.segment.rsc +6 -6
- package/cli/app/.next-cli-build/server/app/dashboard/profile.segments/_head.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/profile.segments/_index.segment.rsc +4 -4
- package/cli/app/.next-cli-build/server/app/dashboard/profile.segments/_tree.segment.rsc +2 -2
- package/cli/app/.next-cli-build/server/app/dashboard/providers/new.html +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/providers/new.rsc +6 -6
- package/cli/app/.next-cli-build/server/app/dashboard/providers/new.segments/!KGRhc2hib2FyZCk/dashboard/providers/new/__PAGE__.segment.rsc +2 -2
- package/cli/app/.next-cli-build/server/app/dashboard/providers/new.segments/!KGRhc2hib2FyZCk/dashboard/providers/new.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/providers/new.segments/!KGRhc2hib2FyZCk/dashboard/providers.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/providers/new.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/providers/new.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
- package/cli/app/.next-cli-build/server/app/dashboard/providers/new.segments/_full.segment.rsc +6 -6
- package/cli/app/.next-cli-build/server/app/dashboard/providers/new.segments/_head.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/providers/new.segments/_index.segment.rsc +4 -4
- package/cli/app/.next-cli-build/server/app/dashboard/providers/new.segments/_tree.segment.rsc +2 -2
- package/cli/app/.next-cli-build/server/app/dashboard/providers.html +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/providers.rsc +6 -6
- package/cli/app/.next-cli-build/server/app/dashboard/providers.segments/!KGRhc2hib2FyZCk/dashboard/providers/__PAGE__.segment.rsc +2 -2
- package/cli/app/.next-cli-build/server/app/dashboard/providers.segments/!KGRhc2hib2FyZCk/dashboard/providers.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/providers.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/providers.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
- package/cli/app/.next-cli-build/server/app/dashboard/providers.segments/_full.segment.rsc +6 -6
- package/cli/app/.next-cli-build/server/app/dashboard/providers.segments/_head.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/providers.segments/_index.segment.rsc +4 -4
- package/cli/app/.next-cli-build/server/app/dashboard/providers.segments/_tree.segment.rsc +2 -2
- package/cli/app/.next-cli-build/server/app/dashboard/proxy-pools.html +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/proxy-pools.rsc +6 -6
- package/cli/app/.next-cli-build/server/app/dashboard/proxy-pools.segments/!KGRhc2hib2FyZCk/dashboard/proxy-pools/__PAGE__.segment.rsc +2 -2
- package/cli/app/.next-cli-build/server/app/dashboard/proxy-pools.segments/!KGRhc2hib2FyZCk/dashboard/proxy-pools.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/proxy-pools.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/proxy-pools.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
- package/cli/app/.next-cli-build/server/app/dashboard/proxy-pools.segments/_full.segment.rsc +6 -6
- package/cli/app/.next-cli-build/server/app/dashboard/proxy-pools.segments/_head.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/proxy-pools.segments/_index.segment.rsc +4 -4
- package/cli/app/.next-cli-build/server/app/dashboard/proxy-pools.segments/_tree.segment.rsc +2 -2
- package/cli/app/.next-cli-build/server/app/dashboard/pxpipe.html +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/pxpipe.rsc +6 -6
- package/cli/app/.next-cli-build/server/app/dashboard/pxpipe.segments/!KGRhc2hib2FyZCk/dashboard/pxpipe/__PAGE__.segment.rsc +2 -2
- package/cli/app/.next-cli-build/server/app/dashboard/pxpipe.segments/!KGRhc2hib2FyZCk/dashboard/pxpipe.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/pxpipe.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/pxpipe.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
- package/cli/app/.next-cli-build/server/app/dashboard/pxpipe.segments/_full.segment.rsc +6 -6
- package/cli/app/.next-cli-build/server/app/dashboard/pxpipe.segments/_head.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/pxpipe.segments/_index.segment.rsc +4 -4
- package/cli/app/.next-cli-build/server/app/dashboard/pxpipe.segments/_tree.segment.rsc +2 -2
- package/cli/app/.next-cli-build/server/app/dashboard/quota.html +2 -2
- package/cli/app/.next-cli-build/server/app/dashboard/quota.rsc +7 -7
- package/cli/app/.next-cli-build/server/app/dashboard/quota.segments/!KGRhc2hib2FyZCk/dashboard/quota/__PAGE__.segment.rsc +3 -3
- package/cli/app/.next-cli-build/server/app/dashboard/quota.segments/!KGRhc2hib2FyZCk/dashboard/quota.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/quota.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/quota.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
- package/cli/app/.next-cli-build/server/app/dashboard/quota.segments/_full.segment.rsc +7 -7
- package/cli/app/.next-cli-build/server/app/dashboard/quota.segments/_head.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/quota.segments/_index.segment.rsc +4 -4
- package/cli/app/.next-cli-build/server/app/dashboard/quota.segments/_tree.segment.rsc +2 -2
- package/cli/app/.next-cli-build/server/app/dashboard/settings/pricing.html +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/settings/pricing.rsc +6 -6
- package/cli/app/.next-cli-build/server/app/dashboard/settings/pricing.segments/!KGRhc2hib2FyZCk/dashboard/settings/pricing/__PAGE__.segment.rsc +2 -2
- package/cli/app/.next-cli-build/server/app/dashboard/settings/pricing.segments/!KGRhc2hib2FyZCk/dashboard/settings/pricing.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/settings/pricing.segments/!KGRhc2hib2FyZCk/dashboard/settings.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/settings/pricing.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/settings/pricing.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
- package/cli/app/.next-cli-build/server/app/dashboard/settings/pricing.segments/_full.segment.rsc +6 -6
- package/cli/app/.next-cli-build/server/app/dashboard/settings/pricing.segments/_head.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/settings/pricing.segments/_index.segment.rsc +4 -4
- package/cli/app/.next-cli-build/server/app/dashboard/settings/pricing.segments/_tree.segment.rsc +2 -2
- package/cli/app/.next-cli-build/server/app/dashboard/token-saver.html +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/token-saver.rsc +6 -6
- package/cli/app/.next-cli-build/server/app/dashboard/token-saver.segments/!KGRhc2hib2FyZCk/dashboard/token-saver/__PAGE__.segment.rsc +2 -2
- package/cli/app/.next-cli-build/server/app/dashboard/token-saver.segments/!KGRhc2hib2FyZCk/dashboard/token-saver.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/token-saver.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/token-saver.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
- package/cli/app/.next-cli-build/server/app/dashboard/token-saver.segments/_full.segment.rsc +6 -6
- package/cli/app/.next-cli-build/server/app/dashboard/token-saver.segments/_head.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/token-saver.segments/_index.segment.rsc +4 -4
- package/cli/app/.next-cli-build/server/app/dashboard/token-saver.segments/_tree.segment.rsc +2 -2
- package/cli/app/.next-cli-build/server/app/dashboard/translator.html +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/translator.rsc +6 -6
- package/cli/app/.next-cli-build/server/app/dashboard/translator.segments/!KGRhc2hib2FyZCk/dashboard/translator/__PAGE__.segment.rsc +2 -2
- package/cli/app/.next-cli-build/server/app/dashboard/translator.segments/!KGRhc2hib2FyZCk/dashboard/translator.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/translator.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/translator.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
- package/cli/app/.next-cli-build/server/app/dashboard/translator.segments/_full.segment.rsc +6 -6
- package/cli/app/.next-cli-build/server/app/dashboard/translator.segments/_head.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/translator.segments/_index.segment.rsc +4 -4
- package/cli/app/.next-cli-build/server/app/dashboard/translator.segments/_tree.segment.rsc +2 -2
- package/cli/app/.next-cli-build/server/app/dashboard/usage.html +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/usage.rsc +6 -6
- package/cli/app/.next-cli-build/server/app/dashboard/usage.segments/!KGRhc2hib2FyZCk/dashboard/usage/__PAGE__.segment.rsc +2 -2
- package/cli/app/.next-cli-build/server/app/dashboard/usage.segments/!KGRhc2hib2FyZCk/dashboard/usage.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/usage.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/usage.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
- package/cli/app/.next-cli-build/server/app/dashboard/usage.segments/_full.segment.rsc +6 -6
- package/cli/app/.next-cli-build/server/app/dashboard/usage.segments/_head.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/usage.segments/_index.segment.rsc +4 -4
- package/cli/app/.next-cli-build/server/app/dashboard/usage.segments/_tree.segment.rsc +2 -2
- package/cli/app/.next-cli-build/server/app/dashboard.html +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard.rsc +6 -6
- package/cli/app/.next-cli-build/server/app/dashboard.segments/!KGRhc2hib2FyZCk/dashboard/__PAGE__.segment.rsc +2 -2
- package/cli/app/.next-cli-build/server/app/dashboard.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
- package/cli/app/.next-cli-build/server/app/dashboard.segments/_full.segment.rsc +6 -6
- package/cli/app/.next-cli-build/server/app/dashboard.segments/_head.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard.segments/_index.segment.rsc +4 -4
- package/cli/app/.next-cli-build/server/app/dashboard.segments/_tree.segment.rsc +2 -2
- package/cli/app/.next-cli-build/server/app/index.html +1 -1
- package/cli/app/.next-cli-build/server/app/index.rsc +4 -4
- package/cli/app/.next-cli-build/server/app/index.segments/__PAGE__.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/index.segments/_full.segment.rsc +4 -4
- package/cli/app/.next-cli-build/server/app/index.segments/_head.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/index.segments/_index.segment.rsc +4 -4
- package/cli/app/.next-cli-build/server/app/index.segments/_tree.segment.rsc +2 -2
- package/cli/app/.next-cli-build/server/app/landing/page_client-reference-manifest.js +1 -1
- package/cli/app/.next-cli-build/server/app/landing.html +1 -1
- package/cli/app/.next-cli-build/server/app/landing.rsc +5 -5
- package/cli/app/.next-cli-build/server/app/landing.segments/_full.segment.rsc +5 -5
- package/cli/app/.next-cli-build/server/app/landing.segments/_head.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/landing.segments/_index.segment.rsc +4 -4
- package/cli/app/.next-cli-build/server/app/landing.segments/_tree.segment.rsc +2 -2
- package/cli/app/.next-cli-build/server/app/landing.segments/landing/__PAGE__.segment.rsc +2 -2
- package/cli/app/.next-cli-build/server/app/landing.segments/landing.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/login/page_client-reference-manifest.js +1 -1
- package/cli/app/.next-cli-build/server/app/login.html +1 -1
- package/cli/app/.next-cli-build/server/app/login.rsc +5 -5
- package/cli/app/.next-cli-build/server/app/login.segments/_full.segment.rsc +5 -5
- package/cli/app/.next-cli-build/server/app/login.segments/_head.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/login.segments/_index.segment.rsc +4 -4
- package/cli/app/.next-cli-build/server/app/login.segments/_tree.segment.rsc +2 -2
- package/cli/app/.next-cli-build/server/app/login.segments/login/__PAGE__.segment.rsc +2 -2
- package/cli/app/.next-cli-build/server/app/login.segments/login.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/page_client-reference-manifest.js +1 -1
- package/cli/app/.next-cli-build/server/app-paths-manifest.json +10 -10
- package/cli/app/.next-cli-build/server/chunks/2607.js +10 -10
- package/cli/app/.next-cli-build/server/chunks/3110.js +1 -1
- package/cli/app/.next-cli-build/server/chunks/3155.js +1 -1
- package/cli/app/.next-cli-build/server/chunks/3949.js +1 -1
- package/cli/app/.next-cli-build/server/chunks/412.js +2 -2
- package/cli/app/.next-cli-build/server/chunks/5307.js +1 -1
- package/cli/app/.next-cli-build/server/chunks/5469.js +1 -1
- package/cli/app/.next-cli-build/server/chunks/8242.js +2 -2
- package/cli/app/.next-cli-build/server/chunks/8306.js +1 -1
- package/cli/app/.next-cli-build/server/chunks/8895.js +2 -2
- package/cli/app/.next-cli-build/server/chunks/9621.js +1 -1
- package/cli/app/.next-cli-build/server/middleware-build-manifest.js +1 -1
- package/cli/app/.next-cli-build/server/pages/404.html +1 -1
- package/cli/app/.next-cli-build/server/pages/500.html +1 -1
- package/cli/app/.next-cli-build/static/chunks/523-24d141baca2cf3ac.js +3 -0
- package/cli/app/.next-cli-build/static/chunks/5497-30373888abff3013.js +7 -0
- package/cli/app/.next-cli-build/static/chunks/{620-aa5d878e9ca8eac1.js → 620-cbb8c8ac230e6489.js} +1 -1
- package/cli/app/.next-cli-build/static/chunks/6617-24b58186724a353a.js +56 -0
- package/cli/app/.next-cli-build/static/chunks/9126-700ad9f1ec9210fb.js +1 -0
- package/cli/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/cli-tools/[toolId]/page-bd827e591cfc8125.js +1 -0
- package/cli/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/cli-tools/page-80ae115554408efe.js +1 -0
- package/cli/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/media-providers/[kind]/[id]/page-a17208b586055f9b.js +59 -0
- package/cli/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/media-providers/[kind]/page-0403dfd2234f0c80.js +1 -0
- package/cli/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/media-providers/combo/[id]/page-146309ef654004c5.js +4 -0
- package/cli/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/media-providers/web/{page-6a6d9f0fc6c0587d.js → page-1952e4c3364688ee.js} +1 -1
- package/cli/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/providers/[id]/page-ec166e9835cac316.js +3 -0
- package/cli/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/providers/new/page-9a9e09af961343c0.js +1 -0
- package/cli/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/providers/page-7abc7eb028939fe1.js +1 -0
- package/cli/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/quota/page-98cde94871a97a17.js +1 -0
- package/cli/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/settings/pricing/page-f47976ebed4de8c2.js +1 -0
- package/cli/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/usage/page-465deae43bb4635c.js +1 -0
- package/cli/app/.next-cli-build/static/css/{46b47c65b0eb8d0a.css → 3e50676a328eeb27.css} +1 -1
- package/cli/app/CHANGELOG.md +11 -0
- package/cli/app/package.json +1 -1
- package/cli/package.json +1 -1
- package/package.json +1 -1
- package/cli/app/.next-cli-build/static/chunks/523-176a0660a9383518.js +0 -3
- package/cli/app/.next-cli-build/static/chunks/5497-a4f1f8e10718edc0.js +0 -7
- package/cli/app/.next-cli-build/static/chunks/6617-a18c27f06c68d9a4.js +0 -56
- package/cli/app/.next-cli-build/static/chunks/9126-7d5476f17beddfb0.js +0 -1
- package/cli/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/cli-tools/[toolId]/page-4e5ba3d1c19bf9d9.js +0 -1
- package/cli/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/cli-tools/page-b67882cc21d5ac2e.js +0 -1
- package/cli/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/media-providers/[kind]/[id]/page-1ae6ca8eae912178.js +0 -59
- package/cli/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/media-providers/[kind]/page-03b4d5addd474977.js +0 -1
- package/cli/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/media-providers/combo/[id]/page-05d62a2714eab250.js +0 -4
- package/cli/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/providers/[id]/page-5d5fa8b4319dc8cf.js +0 -3
- package/cli/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/providers/new/page-84e5b58e1bc94fc3.js +0 -1
- package/cli/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/providers/page-9d2250c9ecfdeb7a.js +0 -1
- package/cli/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/quota/page-d60217faba1a8018.js +0 -1
- package/cli/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/settings/pricing/page-f2e034926e037cb9.js +0 -1
- package/cli/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/usage/page-46ad1923add78d75.js +0 -1
- /package/cli/app/.next-cli-build/static/{2GcXDLDxuvj6CKV-GA0Ft → IJRGkO8fMyjXMMNrPPjxN}/_buildManifest.js +0 -0
- /package/cli/app/.next-cli-build/static/{2GcXDLDxuvj6CKV-GA0Ft → IJRGkO8fMyjXMMNrPPjxN}/_ssgManifest.js +0 -0
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[2134],{20898:(e,t,s)=>{"use strict";s.r(t),s.d(t,{default:()=>M});var a=s(95155),i=s(12115),r=s(73321),l=s(98500),n=s.n(l),o=s(5772),d=s(35497),c=s(52679);let u=["kiro","codebuddy","codebuddy-cn","qoder","antigravity","cloudflare-ai"];function m(e){return u.includes(String(e||""))}function p(e){let t=String(e||"").trim();return t&&m(t)?`/dashboard/automation?provider=${encodeURIComponent(t)}`:"/dashboard/automation"}var x=s(28777),h=s(11059),f=s(73006);let g=new Map;async function b(e){if(!e?.url||!e?.type)return[];let t=g.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 g.set(e.url,{data:a,expiresAt:Date.now()+6e5}),a}catch{return[]}}var y=s(70217),v=s(51716),j=s(14051),k=s.n(j);function w({model:e,fullModel:t,alias:s,copied:i,onCopy:r,testStatus:l,isCustom:n,isFree:o,onDeleteAlias:d,onTest:c,isTesting:u,onDisable:m,thinkingSuffix:p}){let x="ok"===l?"#22c55e":"error"===l?"#ef4444":void 0,h=p?`${t}(${p})`:t;return(0,a.jsx)("div",{className:`group min-w-0 max-w-full rounded-lg border px-3 py-2 ${"ok"===l?"border-green-500/40":"error"===l?"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"===l?"check_circle":"error"===l?"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:h}),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:u,className:`rounded p-0.5 text-text-muted transition-opacity hover:bg-sidebar hover:text-primary ${u?"opacity-100":"opacity-100 sm:opacity-0 sm:group-hover:opacity-100"}`,children:(0,a.jsx)("span",{className:"material-symbols-outlined text-sm",style:u?{animation:"spin 1s linear infinite"}:void 0,children:u?"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:u?"Testing...":"Test"})]}),(0,a.jsxs)("div",{className:"relative shrink-0 group/btn",children:[(0,a.jsx)("button",{onClick:()=>r(h,`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"})}):m?(0,a.jsx)("button",{onClick:m,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 N({modelId:e,fullModel:t,copied:s,onCopy:i,onDeleteAlias:r,onTest:l,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"})]}),l&&(0,a.jsxs)("div",{className:"relative group/btn",children:[(0,a.jsx)("button",{onClick:l,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:r,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 C({providerStorageAlias:e,providerDisplayAlias:t,modelAliases:s,copied:r,onCopy:l,onSetAlias:n,onDeleteAlias:o,connections:c,isAnthropic:u}){let[m,p]=(0,i.useState)(""),[x,h]=(0,i.useState)(!1),[f,g]=(0,i.useState)(!1),[b,y]=(0,i.useState)(null),[v,j]=(0,i.useState)({}),k=async t=>{if(b)return;let s=`${e}/${t}`;y(t);try{let e=await fetch("/api/models/test",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({model:s})}),t=await e.json();j(e=>({...e,[s]:t.ok?"ok":"error"}))}catch{j(e=>({...e,[s]:"error"}))}finally{y(null)}},w=Object.entries(s).filter(([,t])=>t.startsWith(`${e}/`)).map(([t,s])=>({modelId:s.replace(`${e}/`,""),fullModel:s,alias:t})),S=a=>{let i,r=`${e}/${a}`;if(Object.values(s).includes(r))return null;let l=(i=a.split("/"))[i.length-1];if(!s[l])return l;let n=`${t}-${l}`;return s[n]?null:n},$=async()=>{if(!m.trim()||x)return;let t=m.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),p("")}catch(e){console.log("Error adding model:",e),alert(e?.message||`Failed to add model "${t}".`)}finally{h(!1)}},A=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 r=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),r+=1)}0===r&&alert("No new models were added.")}catch(e){console.log("Error importing models:",e),alert(e?.message||"Failed to import models from /models.")}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 ",u?"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:m,onChange:e=>p(e.target.value),onKeyDown:e=>"Enter"===e.key&&$(),placeholder:u?"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:$,disabled:!m.trim()||x,children:x?"Adding...":"Add"}),(0,a.jsx)(d.$n,{size:"sm",variant:"secondary",icon:"download",onClick:A,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."}),w.length>0&&(0,a.jsx)("div",{className:"flex flex-col gap-3",children:w.map(({modelId:s,fullModel:i,alias:n})=>(0,a.jsx)(N,{modelId:s,fullModel:`${t}/${s}`,copied:r,onCopy:l,onDeleteAlias:()=>o(n),onTest:c.length>0?()=>k(s):void 0,testStatus:v[`${e}/${s}`],isTesting:b===s},i))})]})}w.propTypes={model:k().shape({id:k().string.isRequired}).isRequired,fullModel:k().string.isRequired,alias:k().string,copied:k().string,onCopy:k().func.isRequired,testStatus:k().oneOf(["ok","error"]),isCustom:k().bool,isFree:k().bool,onDeleteAlias:k().func,onTest:k().func,isTesting:k().bool,onDisable:k().func,thinkingSuffix:k().string},k().string.isRequired,k().string.isRequired,k().string,k().func.isRequired,k().func.isRequired,k().func,k().oneOf(["ok","error"]),k().bool,k().string.isRequired,k().object.isRequired,k().string,k().func.isRequired,k().func.isRequired,k().func.isRequired,C.propTypes={providerStorageAlias:k().string.isRequired,providerDisplayAlias:k().string.isRequired,modelAliases:k().object.isRequired,copied:k().string,onCopy:k().func.isRequired,onSetAlias:k().func.isRequired,onDeleteAlias:k().func.isRequired,connections:k().arrayOf(k().shape({id:k().string,isActive:k().bool})).isRequired,isAnthropic:k().bool};var S=s(81277);function $({until:e}){let[t,s]=(0,i.useState)("");return((0,i.useEffect)(()=>{let t=()=>{let t=new Date(e).getTime();if(!Number.isFinite(t))return void s("");let a=t-Date.now();if(a<=0)return void s("");let i=Math.floor(a/1e3);if(i<60)s(`${i}s`);else if(i<3600)s(`${Math.floor(i/60)}m ${i%60}s`);else{let e=Math.floor(i/3600),t=Math.floor(i%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 A({connection:e,proxyPools:t,isOAuth:s,isFirst:r,isLast:l,onMoveUp:n,onMoveDown:o,onToggleActive:c,onUpdateProxy:u,onEdit:m,onDelete:p,oneByOneStatus:x=null}){let[h,f]=(0,i.useState)(!1),[g,b]=(0,i.useState)(!1),v=(0,i.useRef)(null),j=(0,i.useMemo)(()=>new Map((t||[]).map(e=>[e.id,e])),[t]),k=(0,i.useMemo)(()=>t||[],[t]),w=e.providerSpecificData?.proxyPoolId||null,N=w?j.get(w):null,C=e.providerSpecificData?.connectionProxyEnabled===!0&&!!e.providerSpecificData?.connectionProxyUrl,T=!!w||C,E=N?`Pool: ${N.name}`:w?`Pool: ${w} (inactive/missing)`:C?`Legacy: ${e.providerSpecificData?.connectionProxyUrl}`:"",I="";if(N?.proxyUrl||e.providerSpecificData?.connectionProxyUrl){let t=N?.proxyUrl||e.providerSpecificData?.connectionProxyUrl;try{let e=new URL(t);I=`${e.protocol}//${e.hostname}${e.port?`:${e.port}`:""}`}catch{I=t}}let P=N?.noProxy||e.providerSpecificData?.connectionNoProxy||"",R="default";N?.isActive===!0?R="success":(w||C)&&(R="error"),(0,i.useEffect)(()=>{if(!h)return;let e=e=>{v.current&&!v.current.contains(e.target)&&f(!1)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[h]);let _=async e=>{b(!0);try{await u("__none__"===e?null:e)}finally{b(!1),f(!1)}},O=e.authType||(s?"oauth":"apikey"),D="oauth"===O,q="cookie"===O,z=e=>"string"==typeof e&&/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e),U=D?z(e.email)?e.email:z(e.name)?e.name:e.name||e.email||e.displayName||"OAuth Account":e.name||e.email||e.displayName||"API Key",M=(0,S.c)(e),L=null!==M,F="unavailable"!==e.testStatus||L?e.testStatus:"active",K=(0,y.d4)(e),J=!!e.quarantinedAt,B={policy_suspended:"Policy suspension",credential_rejected:"Credential rejected",reauth_required:"Sign-in required",authentication:"Repeated authentication failure"}[e.failureClass]||e.quarantineReason||"Account quarantined",H=Number.isFinite(Date.parse(e.quarantinedAt))?new Date(e.quarantinedAt).toLocaleString():e.quarantinedAt||null,G=e.modelLockReason?.resetsAt,W=Number.isFinite(Date.parse(G))?new Date(G).toLocaleString():G||null,Q=()=>x?"queued"===x.state?"queued":"testing"===x.state?"testing":"success"===x.state?"success":"failed"===x.state?x.error?`failed: ${x.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&&!J?"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:n,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:o,disabled:l,className:`p-0.5 rounded ${l?"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:q?"cookie":D?"lock":"key"}),(0,a.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,a.jsx)("p",{className:"text-sm font-medium truncate",children:U}),(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:(()=>{if(!1===e.isActive)return"default";let t=(0,y.BU)(K);return"active"!==K.key?t:"active"===F||"success"===F?"success":"error"===F||"expired"===F||"unavailable"===F?"error":"default"})(),size:"sm",dot:!0,children:K.label||F||"unknown"}),(0,a.jsx)(d.Ex,{variant:"default",size:"sm",children:D?"OAuth":q?"Cookie":"API Key"}),J&&(0,a.jsx)(d.Ex,{variant:"error",size:"sm",children:"Quarantined"}),T&&(0,a.jsx)(d.Ex,{variant:R,size:"sm",children:"Proxy"}),e.autoDisabledAt&&!J&&(0,a.jsxs)("span",{className:"text-[10px] text-text-muted",children:["token_expired"===e.autoDisabledReason?"Token expired":"banned"===e.autoDisabledReason?"Banned":"quota_exhausted"===e.autoDisabledReason?"Quota exhausted":"Auto-disabled"," — ",new Date(e.autoDisabledAt).toLocaleDateString()]}),J&&(0,a.jsxs)("span",{className:"max-w-full truncate text-xs text-red-600 dark:text-red-400 sm:max-w-[420px]",title:`${e.quarantineReason||B}${H?` - ${H}`:""}`,children:[B,H?` - ${H}`:""]}),L&&!1!==e.isActive&&(0,a.jsx)($,{until:M}),L&&e.modelLockReason&&!1!==e.isActive&&(0,a.jsxs)("span",{className:"max-w-full truncate text-xs text-amber-600 dark:text-amber-400 sm:max-w-[360px]",title:`${e.modelLockReason.reason}${W?` — resets ${W}`:""}`,children:[e.modelLockReason.model,e.modelLockReason.providerErrorCode?` (${e.modelLockReason.providerErrorCode})`:"",W?` — resets ${W}`:""]}),e.lastError&&!1!==e.isActive&&(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]}),Q()&&(0,a.jsx)(d.Ex,{variant:x?"success"===x.state?"success":"failed"===x.state?"error":"testing"===x.state?"primary":"default":"default",size:"sm",children:Q()})]}),T&&(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:E,children:E}),I&&(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:I}),P&&(0,a.jsxs)("span",{className:"max-w-full truncate text-[11px] text-text-muted sm:max-w-[320px]",title:P,children:["no_proxy: ",P]})]}),J&&!1===e.isActive&&(0,a.jsx)("p",{className:"mt-1 text-[11px] leading-relaxed text-text-muted",children:"Re-enable only permits router requests again; it does not change the account's upstream status."})]})]}),(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:[k.length>0&&(0,a.jsxs)("div",{className:"relative",ref:v,children:[(0,a.jsxs)("button",{onClick:()=>f(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 ${T?"text-primary":"text-text-muted hover:text-primary"}`,disabled:g,children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:g?"progress_activity":"lan"}),(0,a.jsx)("span",{className:"text-[10px] leading-tight",children:"Proxy"})]}),h&&(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:()=>_("__none__"),className:`w-full text-left px-3 py-1.5 text-sm hover:bg-black/5 dark:hover:bg-white/5 ${!w?"text-primary font-medium":"text-text-main"}`,children:"None"}),k.map(e=>(0,a.jsx)("button",{onClick:()=>_(e.id),className:`w-full text-left px-3 py-1.5 text-sm hover:bg-black/5 dark:hover:bg-white/5 ${w===e.id?"text-primary font-medium":"text-text-main"}`,children:e.name},e.id))]})]}),(0,a.jsxs)("button",{onClick:m,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:p,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:c,title:e.isActive??!0?"Disable connection":J?"Re-enable routing only; upstream suspension or credential status is unchanged":"Enable connection"})]})]})}$.propTypes={until:k().string.isRequired},A.propTypes={connection:k().shape({id:k().string,name:k().string,email:k().string,displayName:k().string,modelLockUntil:k().string,testStatus:k().string,isActive:k().bool,lastError:k().string,failureClass:k().string,quarantinedAt:k().string,quarantineReason:k().string,priority:k().number,globalPriority:k().number}).isRequired,proxyPools:k().arrayOf(k().shape({id:k().string,name:k().string,proxyUrl:k().string,noProxy:k().string,isActive:k().bool})),isOAuth:k().bool.isRequired,isFirst:k().bool.isRequired,isLast:k().bool.isRequired,onMoveUp:k().func.isRequired,onMoveDown:k().func.isRequired,onToggleActive:k().func.isRequired,onUpdateProxy:k().func,onEdit:k().func.isRequired,onDelete:k().func.isRequired,oneByOneStatus:k().shape({state:k().string,error:k().string})};var T=s(28915);let E=`name1|sk-key1
|
|
2
|
+
name2|sk-key2
|
|
3
|
+
sk-key-only-auto-named`;function I({isOpen:e,provider:t,providerName:s,isCompatible:r,isAnthropic:l,authType:n,authHint:o,website:u,proxyPools:m,error:p,onSave:x,onBulkDone:h,onClose:f}){let g="__none__",b="ollama-local"===t,y="cookie"===n,v="xai"===t&&!y,j=y?"Cookie Value":"API Key",k=y?"grok-web"===t?"sso=xxxxx... or just the raw value":"eyJhbGciOi...":v?"xai-...":"",w="azure"===t,N="cloudflare-ai"===t,C=c.Q2?.[t]?.regions||null,S=c.Q2?.[t]?.defaultRegion||C?.[0]?.id||"",[$,A]=(0,i.useState)({name:"",apiKey:"",defaultModel:"",priority:1,proxyPoolId:g,ollamaHostUrl:""}),[P,R]=(0,i.useState)({azureEndpoint:"",apiVersion:"2024-10-01-preview",deployment:"",organization:""}),[_,O]=(0,i.useState)({accountId:""}),[D,q]=(0,i.useState)(S),[z,U]=(0,i.useState)(!1),[M,L]=(0,i.useState)(null),[F,K]=(0,i.useState)(!1),[J,B]=(0,i.useState)("single"),[H,G]=(0,i.useState)(""),[W,Q]=(0,i.useState)(null),V=(0,i.useRef)(!1);(0,i.useEffect)(()=>{e&&!V.current&&(A({name:"",apiKey:"",defaultModel:"",priority:1,proxyPoolId:g,ollamaHostUrl:""}),R({azureEndpoint:"",apiVersion:"2024-10-01-preview",deployment:"",organization:""}),O({accountId:""}),q(S),L(null),B("single"),G(""),Q(null)),V.current=e},[e]);let Z=()=>b&&$.ollamaHostUrl.trim()?{baseUrl:$.ollamaHostUrl.trim()}:w?{azureEndpoint:P.azureEndpoint,apiVersion:P.apiVersion,deployment:P.deployment,organization:P.organization}:N?{accountId:_.accountId}:C&&D?{region:D}:void 0,X=async()=>{U(!0);try{let e=await (0,T.x6)("/api/providers/validate",{method:"POST",body:{provider:t,apiKey:$.apiKey,providerSpecificData:Z()}});L(e.valid?"success":"failed")}catch{L("unknown")}finally{U(!1)}},Y=async()=>{if(t&&(b||$.apiKey)&&(b||$.name)&&(!r||$.defaultModel.trim())){K(!0);try{let e=!1;try{U(!0),L(null),e=!!(await (0,T.x6)("/api/providers/validate",{method:"POST",body:{provider:t,apiKey:$.apiKey,providerSpecificData:Z()}})).valid,L(e?"success":"failed")}catch{L("unknown")}finally{U(!1)}let s=Number.parseInt($.priority,10);await x({name:$.name||(b?"Ollama Local":""),apiKey:$.apiKey,defaultModel:r?$.defaultModel.trim():void 0,priority:Number.isFinite(s)?s:1,proxyPoolId:$.proxyPoolId===g?null:$.proxyPoolId,testStatus:e?"active":"unknown",providerSpecificData:Z()})}finally{K(!1)}}},ee=async()=>{let e=H.split("\n").map(e=>e.trim()).filter(Boolean);if(!e.length)return;K(!0),Q(null);let s=0,a=0,i=[],r=[];for(let l=0;l<e.length;l++){let n=e[l].split("|"),o=n.length>=2?n.slice(1).join("|").trim():n[0].trim(),d=n.length>=2?n[0].trim():"Key",c=`${d} ${l+1}`;try{await (0,T.x6)("/api/providers",{method:"POST",body:{provider:t,apiKey:o,name:c,priority:1,testStatus:"unknown"}}),s++}catch(t){a++,i.push({line:e[l],message:t?.message||"Request failed"}),r.push(e[l])}}K(!1),Q({success:s,failed:a,failedRows:i}),G(r.join("\n")),s>0&&h&&h()};return t?(0,a.jsx)(d.aF,{isOpen:e,title:`Add ${s||t} ${j}`,onClose:f,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"===J?"primary":"ghost",onClick:()=>{B("single"),Q(null)},children:"Single"}),(0,a.jsx)(d.$n,{size:"sm",variant:"bulk"===J?"primary":"ghost",onClick:()=>{B("bulk"),Q(null)},children:"Bulk Add"})]}),"bulk"===J&&(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:E,value:H,onChange:e=>G(e.target.value)}),W&&(0,a.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,a.jsxs)("div",{className:`text-sm font-medium ${W.failed>0?"text-yellow-400":"text-green-400"}`,children:["✓ ",W.success," added",W.failed>0?`, ✗ ${W.failed} failed`:""]}),W.failedRows?.length>0&&(0,a.jsx)("ul",{className:"text-xs text-red-500 flex flex-col gap-0.5",children:W.failedRows.map((e,t)=>(0,a.jsxs)("li",{className:"break-words",children:[(0,a.jsx)("span",{className:"font-mono",children:e.line.length>40?`${e.line.slice(0,40)}…`:e.line}),` — ${e.message}`]},t))})]}),(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsx)(d.$n,{onClick:ee,fullWidth:!0,disabled:F||!H.trim(),children:F?"Adding...":"Add All Keys"}),(0,a.jsx)(d.$n,{onClick:f,variant:"ghost",fullWidth:!0,children:"Cancel"})]})]}),"single"===J&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(d.pd,{label:"Name",value:$.name,onChange:e=>A({...$,name:e.target.value}),placeholder:b?"Ollama Local":"Production Key"}),b&&(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsx)(d.pd,{label:"Ollama Host URL",value:$.ollamaHostUrl,onChange:e=>A({...$,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:X,disabled:z||F,variant:"secondary",children:z?"Checking...":"Check"})})]}),!b&&(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsx)(d.pd,{label:j,type:y?"text":"password",value:$.apiKey,onChange:e=>A({...$,apiKey:e.target.value}),placeholder:k,className:"flex-1"}),(0,a.jsx)("div",{className:"pt-6",children:(0,a.jsx)(d.$n,{onClick:X,disabled:!$.apiKey||z||F,variant:"secondary",children:z?"Checking...":"Check"})})]}),v&&(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."}),y&&o&&(0,a.jsxs)("p",{className:"text-xs text-text-muted",children:[o,u&&(0,a.jsxs)(a.Fragment,{children:[" ",(0,a.jsxs)("a",{href:u,target:"_blank",rel:"noopener noreferrer",className:"text-primary underline",children:["Open ",u.replace(/^https?:\/\//,"")]})]})]}),C&&(0,a.jsx)(d.l6,{label:"Region",value:D,onChange:e=>q(e.target.value),options:C.map(e=>({value:e.id,label:e.label}))}),r&&(0,a.jsx)(d.pd,{label:"Default Model",value:$.defaultModel,onChange:e=>A({...$,defaultModel:e.target.value}),placeholder:l?"claude-3-5-sonnet-latest":"gpt-4o-mini"}),b&&(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":"failed"===M?"error":"default",children:"success"===M?"Valid":"failed"===M?"Invalid":"Could not validate"}),p&&(0,a.jsx)("p",{className:"text-xs text-red-500 break-words",children:p}),r&&(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."}),N&&(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:_.accountId,onChange:e=>O({..._,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"})]})]}),w&&(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:P.azureEndpoint,onChange:e=>R({...P,azureEndpoint:e.target.value}),placeholder:"https://your-resource.openai.azure.com"}),(0,a.jsx)(d.pd,{label:"Deployment Name",value:P.deployment,onChange:e=>R({...P,deployment:e.target.value}),placeholder:"gpt-4"}),(0,a.jsx)(d.pd,{label:"API Version",value:P.apiVersion,onChange:e=>R({...P,apiVersion:e.target.value}),placeholder:"2024-10-01-preview"}),(0,a.jsx)(d.pd,{label:"Organization",value:P.organization,onChange:e=>R({...P,organization:e.target.value}),placeholder:"Organization ID"})]})]}),(0,a.jsx)(d.pd,{label:"Priority",type:"number",value:$.priority,onChange:e=>A({...$,priority:e.target.value}),onBlur:e=>{let t=Number.parseInt(e.target.value,10);A(e=>({...e,priority:Number.isFinite(t)?t:1}))}}),(0,a.jsx)(d.l6,{label:"Proxy Pool",value:$.proxyPoolId,onChange:e=>A({...$,proxyPoolId:e.target.value}),options:[{value:g,label:"None"},...(m||[]).map(e=>({value:e.id,label:e.name}))],placeholder:"None"}),0===(m||[]).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:Y,fullWidth:!0,disabled:F||!b&&(!$.name||!$.apiKey)||r&&!$.defaultModel.trim()||w&&(!P.azureEndpoint||!P.deployment||!P.organization)||N&&!_.accountId,children:F?"Saving...":"Save"}),(0,a.jsx)(d.$n,{onClick:f,variant:"ghost",fullWidth:!0,children:"Cancel"})]})]})]})}):null}function P({isOpen:e,node:t,onSave:s,onClose:r,isAnthropic:l}){let[n,o]=(0,i.useState)({name:"",prefix:"",apiType:"chat",baseUrl:"https://api.openai.com/v1"}),[c,u]=(0,i.useState)(!1),[m,p]=(0,i.useState)(""),[x,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||(l?"https://api.anthropic.com/v1":"https://api.openai.com/v1")}),p(""),h(""),y(null))},[t,l]);let v=async()=>{if(n.name.trim()&&n.prefix.trim()&&n.baseUrl.trim()){u(!0);try{let e={name:n.name,prefix:n.prefix,baseUrl:n.baseUrl};l||(e.apiType=n.apiType),await s(e)}finally{u(!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:m,type:l?"anthropic-compatible":"openai-compatible",modelId:x.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 ${l?"Anthropic":"OpenAI"} Compatible`,onClose:r,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:`${l?"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:l?"ac-prod":"oc-prod",hint:"Required. Used as the provider prefix for model IDs."}),!l&&(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:l?"https://api.anthropic.com/v1":"https://api.openai.com/v1",hint:`Use the base URL (ending in /v1) for your ${l?"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:m,onChange:e=>p(e.target.value),className:"flex-1"}),(0,a.jsx)("div",{className:"pt-6",children:(0,a.jsx)(d.$n,{onClick:j,disabled:!m||f||!n.baseUrl.trim(),variant:"secondary",children:f?"Checking...":"Check"})})]}),(0,a.jsx)(d.pd,{label:"Model ID (optional)",value:x,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:r,variant:"ghost",fullWidth:!0,children:"Cancel"})]})]})}):null}function R({isOpen:e,providerAlias:t,providerDisplayAlias:s,onSave:r,onClose:l}){let[n,o]=(0,i.useState)(""),[c,u]=(0,i.useState)(null),[m,p]=(0,i.useState)(""),[x,h]=(0,i.useState)(!1);(0,i.useEffect)(()=>{e&&(o(""),u(null),p(""))},[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){u("testing"),p("");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();u(a.ok?"ok":"error"),p(a.error||"")}catch(e){u("error"),p(e.message)}}},b=async()=>{let e=f(n.trim());if(e&&!x){h(!0);try{await r(e)}finally{h(!1)}}};return(0,a.jsx)(d.aF,{isOpen:e,onClose:l,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),u(null),p("")},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:m||"Model not reachable"})]}),(0,a.jsxs)("div",{className:"flex gap-2 pt-1",children:[(0,a.jsx)(d.$n,{onClick:l,variant:"ghost",fullWidth:!0,size:"sm",children:"Cancel"}),(0,a.jsx)(d.$n,{onClick:b,fullWidth:!0,size:"sm",disabled:!n.trim()||x,children:x?"Adding...":"Add Model"})]})]})})}I.propTypes={isOpen:k().bool.isRequired,provider:k().string,providerName:k().string,isCompatible:k().bool,isAnthropic:k().bool,authType:k().string,authHint:k().string,website:k().string,proxyPools:k().arrayOf(k().shape({id:k().string,name:k().string})),error:k().string,onSave:k().func.isRequired,onBulkDone:k().func,onClose:k().func.isRequired},P.propTypes={isOpen:k().bool.isRequired,node:k().shape({id:k().string,name:k().string,prefix:k().string,apiType:k().string,baseUrl:k().string}),onSave:k().func.isRequired,onClose:k().func.isRequired,isAnthropic:k().bool},R.propTypes={isOpen:k().bool.isRequired,providerAlias:k().string.isRequired,providerDisplayAlias:k().string.isRequired,onSave:k().func.isRequired,onClose:k().func.isRequired};let _="kiro-bulk-import-active-job",O="Bulk import progress expired or was cleared.";function D(e){return["completed","cancelled","failed"].includes(e)}async function q(e){if(!e)return null;let t=await fetch(`/api/oauth/kiro/bulk-import/${e}`,{cache:"no-store"}),s=await t.json();return{res:t,data:s}}async function z(e="active"){let t=await fetch(`/api/oauth/kiro/bulk-import/latest?scope=${encodeURIComponent(e)}`,{cache:"no-store"}),s=await t.json();return{res:t,data:s}}async function U(e){let t=new AbortController,s=window.setTimeout(()=>t.abort(),8e3);try{let s=await fetch(e,{cache:"no-store",signal:t.signal}),a=null;try{a=await s.json()}catch{a=null}return{response:s,data:a}}finally{window.clearTimeout(s)}}function M(){let e,t=(0,r.useParams)(),s=(0,r.useRouter)(),l=t.id,[u,g]=(0,i.useState)([]),[j,k]=(0,i.useState)(!0),[N,S]=(0,i.useState)(""),[$,T]=(0,i.useState)(null),[E,M]=(0,i.useState)([]),[L,F]=(0,i.useState)(!1),[K,J]=(0,i.useState)(!1),[B,H]=(0,i.useState)(!1),[G,W]=(0,i.useState)(!1),[Q,V]=(0,i.useState)(""),[Z,X]=(0,i.useState)(!1),[Y,ee]=(0,i.useState)(!1),[et,es]=(0,i.useState)(!1),[ea,ei]=(0,i.useState)(null),[er,el]=(0,i.useState)({}),[en,eo]=(0,i.useState)(!1),[ed,ec]=(0,i.useState)({}),[eu,em]=(0,i.useState)({}),[ep,ex]=(0,i.useState)(null),[eh,ef]=(0,i.useState)(!1),[eg,eb]=(0,i.useState)([]),[ey,ev]=(0,i.useState)("__none__"),[ej,ek]=(0,i.useState)(!1),[ew,eN]=(0,i.useState)(!1),[eC,eS]=(0,i.useState)(null),[e$,eA]=(0,i.useState)(""),[eT,eE]=(0,i.useState)("auto"),[eI,eP]=(0,i.useState)([]),[eR,e_]=(0,i.useState)([]),[eO,eD]=(0,i.useState)([]),[eq,ez]=(0,i.useState)(null),[eU,eM]=(0,i.useState)(!1),[eL,eF]=(0,i.useState)(!1),[eK,eJ]=(0,i.useState)(!1),[eB,eH]=(0,i.useState)(null),[eG,eW]=(0,i.useState)({}),[eQ,eV]=(0,i.useState)(null),eZ=(0,i.useRef)(!1),eX=(0,i.useRef)(null),eY=(0,i.useRef)("1"),[e0,e1]=(0,i.useState)(!1),[e2,e5]=(0,i.useState)(null),[e4,e3]=(0,i.useState)(""),[e6,e7]=(0,i.useState)(1),[e8,e9]=(0,i.useState)(20),[te,tt]=(0,i.useState)("all"),[ts,ta]=(0,i.useState)(""),[ti,tr]=(0,i.useState)(1),[tl,tn]=(0,i.useState)(20),{copied:to,copy:td}=(0,h.C)(),tc=(0,i.useRef)(0),tu=(0,i.useRef)([]),tm=(0,i.useRef)(!0),tp="ag_risk_confirmed",tx=(0,i.useCallback)(()=>{e5(null),e3(""),tc.current=0,window.localStorage.removeItem(_)},[]),th=()=>{F(!0)},tf=()=>{"kiro"===l&&e2?.jobId&&D(e2.status)&&tx(),s.push(p(l))},tg=()=>{V(""),W(!0)},tb=()=>{tj?(()=>{if(m(l))return"antigravity"===l&&"true"!==window.localStorage.getItem(tp)?eM(!0):tf();if("antigravity"===l&&"true"!==window.localStorage.getItem(tp))return eM(!0);tj?th():(V(""),W(!0))})():tg()},ty=$?{id:$.id,name:$.name||("anthropic-compatible"===$.type?"Anthropic Compatible":"OpenAI Compatible"),color:"anthropic-compatible"===$.type?"#D97757":"#10A37F",textIcon:"anthropic-compatible"===$.type?"AC":"OC",apiType:$.apiType,baseUrl:$.baseUrl,type:$.type}:c.zN[l]||c.fg[l]||c.IS[l]||c.nJ[l]||c.br[l],tv=ty?.authModes||[],tj=!!c.zN[l]||!!c.IS[l]||tv.includes("oauth"),tk=!!c.fg[l]||tv.includes("apikey"),tw=!!c.IS[l]?.noAuth,tN=(0,x.KC)(l),tC=(0,c.wG)(l),tS=(0,c.mq)(l),t$=(0,c.gb)(l),tA=tS||t$,tT=!tA&&tj&&tk,tE=m(l),tI="xai"===l?"Grok Build OAuth":"OAuth",tP="xai"===l?"xAI API Key":"API Key",tR=c.Q2[l]?.thinkingConfig||c.s9.extended,t_=tA?l:tC,tO=tA?$?.prefix||l:tC,tD=(0,i.useCallback)(async()=>{try{let e=await fetch(`/api/models/disabled?providerAlias=${encodeURIComponent(t_)}`,{cache:"no-store"}),t=await e.json();e.ok&&eD(t.ids||[])}catch(e){console.log("Error fetching disabled models:",e)}},[t_]),tq=async e=>{try{(await fetch("/api/models/disabled",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({providerAlias:t_,ids:[e]})})).ok&&await tD()}catch(e){console.log("Error disabling model:",e)}},tz=async e=>{try{(await fetch(`/api/models/disabled?providerAlias=${encodeURIComponent(t_)}&id=${encodeURIComponent(e)}`,{method:"DELETE"})).ok&&await tD()}catch(e){console.log("Error enabling model:",e)}},tU=async e=>{e.length&&ez({title:"Disable All Models",message:`Disable all ${e.length} model(s)?`,onConfirm:async()=>{ez(null);try{(await fetch("/api/models/disabled",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({providerAlias:t_,ids:e})})).ok&&await tD()}catch(e){console.log("Error disabling all models:",e)}}})},tM=async()=>{try{(await fetch(`/api/models/disabled?providerAlias=${encodeURIComponent(t_)}`,{method:"DELETE"})).ok&&await tD()}catch(e){console.log("Error enabling all models:",e)}},tL=(0,i.useCallback)(async()=>{try{let e=await fetch("/api/models/alias"),t=await e.json();e.ok&&el(t.aliases||{})}catch(e){console.log("Error fetching aliases:",e)}},[]);(0,i.useEffect)(()=>{"kilocode"===l&&fetch("/api/providers/kilo/free-models").then(e=>e.json()).then(e=>{e.models?.length&&e_(e.models)}).catch(()=>{})},[l]);let tF=(0,i.useCallback)(async()=>{try{S("");let[e,t,s,a]=await Promise.allSettled([U("/api/providers"),U("/api/provider-nodes"),U("/api/proxy-pools?isActive=true"),U("/api/settings")]),i="fulfilled"===e.status?e.value.response:null,r="fulfilled"===e.status?e.value.data:{},n="fulfilled"===t.status?t.value.response:null,o="fulfilled"===t.status?t.value.data:{},d="fulfilled"===s.status?s.value.response:null,c="fulfilled"===s.status?s.value.data:{},u="fulfilled"===a.status?a.value.response:null,m=u?.ok&&a.value.data||{};if(i?.ok){let e=(r.connections||[]).filter(e=>e.provider===l);tu.current=e,g(e)}else S("Connections could not be loaded.");d?.ok&&M(c.proxyPools||[]);let p=(m.providerStrategies||{})[l]||{};eS(p.fallbackStrategy||null),eA(null!=p.stickyRoundRobinLimit?String(p.stickyRoundRobinLimit):"1"),eY.current=null!=p.stickyRoundRobinLimit?String(p.stickyRoundRobinLimit):"1";let x=(m.providerThinking||{})[l]||{};if(eE(x.mode||"auto"),n?.ok){let e=(o.nodes||[]).find(e=>e.id===l)||null;if(!e&&tA)for(let t=0;t<3;t+=1){if(await new Promise(e=>setTimeout(e,150)),!tm.current)return;let{response:t,data:s}=await U("/api/provider-nodes");if(!tm.current)return;if(t.ok&&(e=(s.nodes||[]).find(e=>e.id===l)||null))break}T(e)}}catch(e){console.log("Error fetching connections:",e),tm.current&&S("Connections could not be loaded.")}finally{tm.current&&k(!1)}},[l,tA]),tK=async e=>{try{let t=await fetch(`/api/provider-nodes/${l}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}),s=await t.json();t.ok&&(T(s.node),await tF(),ee(!1))}catch(e){console.log("Error updating provider node:",e)}},tJ=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 r={...a};0===Object.keys(i).length?delete r[l]:r[l]=i,await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({providerStrategies:r})})}catch(e){console.log("Error saving provider strategy:",e)}},tB=async e=>{try{let t=await fetch("/api/settings",{cache:"no-store"}),s={...(t.ok?await t.json():{}).providerThinking||{}};e&&"auto"!==e?s[l]={mode:e}:delete s[l],await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({providerThinking:s})})}catch(e){console.log("Error saving thinking config:",e)}};(0,i.useEffect)(()=>{tF(),tL(),tD()},[tF,tL,tD]),(0,i.useEffect)(()=>(tm.current=!0,()=>{tm.current=!1}),[]),(0,i.useEffect)(()=>{ez(null),ec({}),em({}),ex(null),eP([]),eW({}),eV(null),eH(null),eF(!1),eJ(!1),eZ.current=!0,e3("")},[l]),(0,i.useEffect)(()=>{e7(1),tr(1),tt("all"),ta("")},[l]),(0,i.useEffect)(()=>{e7(1)},[te,e8,ts]),(0,i.useEffect)(()=>{eo(!1)},[l]),(0,i.useEffect)(()=>{tr(1)},[tl,eO.length,tN.length,eR.length]),(0,i.useEffect)(()=>{if("kiro"!==l)return;let e=window.localStorage.getItem(_),t=!1;return(async()=>{try{if(e3(""),e2?.jobId)return;let a=await z();if(!t&&a.res.ok&&a.data?.job){e5(a.data.job),tc.current=a.data.job.summary?.success||0,window.localStorage.setItem(_,a.data.job.jobId);return}if(e){var s;let a=await q(e);if(!t&&a?.res.ok&&a.data?.job&&(s=a.data.job.status,["queued","running","needs_manual"].includes(s))){e5(a.data.job),tc.current=a.data.job.summary?.success||0;return}tx(),e3(O)}}catch{t||e3(O)}})(),()=>{t=!0}},[tx,e2?.jobId,l]),(0,i.useEffect)(()=>{if(!("kiro"!==l||!e2?.jobId||D(e2.status)))return(0,v.M)(async e=>{let t=await q(e2.jobId);if(!e()){if(t?.res.ok&&t.data?.job){let s=t.data.job.summary?.success||0;if(s>tc.current&&(tc.current=s,await tF(),e()))return;e3(""),e5(t.data.job);return}if(t?.res.status===404){let t=await z();if(e())return;if(t.res.ok&&t.data?.job){let s=t.data.job.summary?.success||0;if(s>tc.current&&(tc.current=s,await tF(),e()))return;e3(""),e5(t.data.job),window.localStorage.setItem(_,t.data.job.jobId);return}tx(),e3(O)}}},2e3)},[tx,tF,e2?.jobId,e2?.status,l]),(0,i.useEffect)(()=>{let e=(c.zN[l]||c.fg[l]||c.IS[l]||c.nJ[l])?.modelsFetcher;e&&b(e).then(eP)},[l]);let tH=async(e,t,s=tC)=>{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 tL();else{let t=await e.json();alert(t.error||"Failed to set alias")}}catch(e){console.log("Error setting alias:",e)}},tG=async e=>{try{(await fetch(`/api/models/alias?alias=${encodeURIComponent(e)}`,{method:"DELETE"})).ok&&await tL()}catch(e){console.log("Error deleting alias:",e)}},tW=async()=>{if(e0)return;let e=u.find(e=>!1!==e.isActive);if(!e)return void alert((0,f.Tl)("Please add an active Qoder connection first"));e1(!0);try{let t=await fetch(`/api/providers/${e.id}/models`),s=await t.json();if(!t.ok)return void alert(s.error||(0,f.Tl)("Failed to fetch models"));let a=s.models||[];if(0===a.length)return void alert((0,f.Tl)("No models returned"));let i={...er},r=0;for(let e of a){let t=e.id||e.name;if(!t)continue;let s=t.replace(/^qoder\//,""),a=`${t_}/${s}`;!Object.values(i).includes(a)&&(i[s]||(await tH(s,s,t_),i[s]=a,r+=1))}0===r?alert((0,f.Tl)("All models already exist, no new models added")):alert((0,f.Tl)("Successfully added")+` ${r} `+(0,f.Tl)("models"))}catch(e){console.log("Error importing Qoder models:",e),alert((0,f.Tl)("Error fetching models")+": "+e.message)}finally{e1(!1)}},tQ=async()=>{let e=[...u];if(eL||0===e.length)return;let t=Object.fromEntries(e.map(e=>[e.id,{state:"queued",error:null}]));eZ.current=!1,eF(!0),eJ(!1),eH(null),eW(t),eV({total:e.length,completed:0,passed:0,failed:0,stopped:!1});let s=0,a=0;try{for(let t=0;t<e.length;t+=1){if(eZ.current){eV({total:e.length,completed:t,passed:s,failed:a,stopped:!0});break}let i=e[t];if(!tu.current.some(e=>e.id===i.id)){eW(e=>({...e,[i.id]:{state:"skipped",error:null}})),eV({total:e.length,completed:t+1,passed:s,failed:a,stopped:!1});continue}eH(i.id),eW(e=>({...e,[i.id]:{state:"testing",error:null}}));try{let e=await fetch(`/api/providers/${i.id}/test`,{method:"POST"}),t=await e.json(),r=!!t.valid;r?s+=1:a+=1,eW(e=>({...e,[i.id]:{state:r?"success":"failed",error:r?null:t.error||null}}))}catch(e){a+=1,eW(t=>({...t,[i.id]:{state:"failed",error:e.message||"Test failed"}}))}eV({total:e.length,completed:t+1,passed:s,failed:a,stopped:!1}),t<e.length-1&&await new Promise(e=>setTimeout(e,1e3))}}finally{eH(null),eF(!1),eJ(!1),eZ.current=!1}},tV=async e=>{ez({title:"Delete Connection",message:"Delete this connection?",onConfirm:async()=>{ez(null);try{(await fetch(`/api/providers/${e}`,{method:"DELETE"})).ok&&g(u.filter(t=>t.id!==e))}catch(e){console.log("Error deleting connection:",e)}}})},tZ=()=>{tF(),F(!1)},tX=(0,i.useCallback)(e=>{(e5(e),e3(""),e?.jobId)?(window.localStorage.setItem(_,e.jobId),tc.current=Math.max(tc.current,e.summary?.success||0)):tx()},[tx]),tY=async e=>{V("");try{let t=await fetch("/api/providers",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:l,...e})}),s=null;try{s=await t.json()}catch{s=null}if(t.ok){await tF(),W(!1);return}V(s?.error||"Failed to save connection")}catch(e){console.log("Error saving connection:",e),V("Failed to save connection")}},t0=async e=>{try{(await fetch(`/api/providers/${ea.id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})).ok&&(await tF(),X(!1))}catch(e){console.log("Error updating connection:",e)}},t1=async(e,t)=>{try{let s=await fetch(`/api/providers/${e}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({isActive:t})});if(s.ok){let a=await s.json().catch(()=>null);g(s=>s.map(s=>s.id===e?{...s,isActive:t,...a?.connection||{}}:s))}}catch(e){console.log("Error updating connection status:",e)}},t2=async(e,t)=>{let s=[...u];[s[e],s[t]]=[s[t],s[e]],g(s);try{let[a,i]=await Promise.all([fetch(`/api/providers/${s[e].id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({priority:e+1})}),fetch(`/api/providers/${s[t].id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({priority:t+1})})]);a.ok&&i.ok||(console.log("Priority swap rejected:",a.status,i.status),await tF())}catch(e){console.log("Error swapping priority:",e),await tF()}},t5=(0,i.useMemo)(()=>{let e=ts.trim().toLowerCase();return u.filter(t=>!!(0,y.i2)(t,te)&&(!e||[t.name,t.email,t.id,t.account,t.username,t.label,t.authType,t.notes,t.proxyPoolId].filter(Boolean).join(" ").toLowerCase().includes(e)))},[u,te,ts]),t4=(0,i.useMemo)(()=>y.gJ.reduce((e,t)=>(e[t.id]="all"===t.id?u.length:u.filter(e=>(0,y.i2)(e,t.id)).length,e),{}),[u]),t3=eg.filter(e=>u.some(t=>t.id===e)),t6=u.filter(e=>t3.includes(e.id)),t7="codebuddy"===l?(t6.length>0?t6:u).map(e=>e.id):[],t8=t5.length>0&&t5.every(e=>t3.includes(e.id)),t9=(()=>{if(0===t6.length)return"";let e=new Set(t6.map(e=>e.providerSpecificData?.proxyPoolId||"__none__"));if(1===e.size){let t=[...e][0];if("__none__"===t)return"All selected currently unbound";let s=E.find(e=>e.id===t);return`All selected currently bound to ${s?.name||t}`}return"Selected connections have mixed proxy bindings"})(),se=()=>{ej||es(!1)},st=async e=>{ek(!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 tF(),es(!1)}finally{ek(!1)}},ss=e=>st(t6.map(t=>({connectionId:t.id,proxyPoolId:e}))),sa=e=>{let t="gsuite"===e?"GSuite (non-Gmail)":"Gmail (@gmail.com)";ez({title:`Delete ${t}`,message:`Delete ALL ${t} accounts for this provider? This cannot be undone.`,onConfirm:async()=>{ez(null);try{(await fetch("/api/providers/bulk-delete",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:ty?.id||l,emailFilter:e})})).ok&&(eb([]),await tF())}catch(e){console.error("bulk delete error:",e)}}})},si=Math.max(1,Math.ceil(t5.length/e8)),sr=Math.min(e6,si),sl=t5.slice((sr-1)*e8,sr*e8),sn=(0,a.jsx)("div",{className:"flex min-w-0 flex-col divide-y divide-black/[0.03] dark:divide-white/[0.03]",children:sl.map((e,t)=>{let s,i=u.findIndex(t=>t.id===e.id);return(0,a.jsxs)("div",{className:"flex min-w-0 items-stretch",children:[(0,a.jsx)("label",{className:"flex w-8 shrink-0 items-center justify-center",children:(0,a.jsx)("input",{type:"checkbox",checked:(s=e.id,t3.includes(s)),onChange:()=>{var t;return t=e.id,void eb(e=>e.includes(t)?e.filter(e=>e!==t):[...e,t])},className:"size-4 rounded border-black/20 dark:border-white/20","aria-label":`Select ${e.name||e.email||e.id}`})}),(0,a.jsx)("div",{className:"flex-1 min-w-0",children:(0,a.jsx)(A,{connection:e,proxyPools:E,isOAuth:tj,isFirst:0===i,isLast:i===u.length-1,onMoveUp:()=>t2(i,i-1),onMoveDown:()=>t2(i,i+1),onToggleActive:t=>t1(e.id,t),onUpdateProxy:async t=>{try{(await fetch(`/api/providers/${e.id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({proxyPoolId:t||null})})).ok&&g(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:()=>{ei(e),X(!0)},onDelete:()=>tV(e.id),oneByOneStatus:eG[e.id]||null})})]},e.id)})}),so=E.filter(e=>!0===e.isActive),sd=(0,a.jsx)(d.aF,{isOpen:et,onClose:se,title:`Apply Proxy (${t6.length} selected)`,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=E.filter(e=>!0===e.isActive);return 0===e.length?void alert("No active proxy pools available."):st(t6.map((t,s)=>({connectionId:t.id,proxyPoolId:e[s%e.length].id})))},disabled:ej||0===so.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:()=>ss(null),disabled:ej,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)"})]}),E.map(e=>(0,a.jsxs)("button",{onClick:()=>ss(e.id),disabled:ej||!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))]}),ej&&(0,a.jsx)("p",{className:"text-xs text-text-muted",children:"Applying..."}),(0,a.jsx)(d.$n,{onClick:se,variant:"ghost",fullWidth:!0,disabled:ej,children:"Cancel"})]})}),sc=async e=>{if(!ep){ex(e);try{let t=await fetch("/api/models/test",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({model:`${t_}/${e}`})}),s=await t.json();ec(t=>({...t,[e]:s.ok?"ok":"error"})),em(t=>({...t,[e]:s.ok?"":s.error||"Model not reachable"}))}catch{ec(t=>({...t,[e]:"error"})),em(t=>({...t,[e]:"Network error"}))}finally{ex(null)}}};return j?(0,a.jsxs)("div",{className:"flex flex-col gap-8",children:[(0,a.jsx)(d.Qv,{}),(0,a.jsx)(d.Qv,{})]}):ty?(0,a.jsxs)("div",{className:"flex min-w-0 flex-col gap-6 px-1 sm:gap-8 sm:px-0",children:[(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:`${ty.color}15`},children:en?(0,a.jsx)("span",{className:"text-sm font-bold",style:{color:ty.color},children:ty.textIcon||ty.id.slice(0,2).toUpperCase()}):(0,a.jsx)(o.default,{src:tS&&ty.apiType?"responses"===ty.apiType?"/providers/oai-r.png":"/providers/oai-cc.png":t$?"/providers/anthropic-m.png":`/providers/${ty.id}.png`,alt:ty.name,width:48,height:48,className:"max-h-12 max-w-12 rounded-lg object-contain",sizes:"48px",onError:()=>eo(!0)})}),(0,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsxs)("div",{className:"flex items-center gap-3 flex-wrap",children:[(0,a.jsx)("h1",{className:"truncate text-2xl font-semibold tracking-tight sm:text-3xl",children:ty.name}),(ty.notice?.apiKeyUrl||ty.notice?.signupUrl||ty.website)&&(0,a.jsxs)("a",{href:ty.notice?.apiKeyUrl||ty.notice?.signupUrl||ty.website,target:"_blank",rel:"noopener noreferrer",className:"text-xs text-primary hover:underline inline-flex items-center gap-1",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-sm",children:"open_in_new"}),ty.notice?.apiKeyUrl?"Get API Key":"Sign up / Learn more"]})]}),(0,a.jsxs)("p",{className:"text-text-muted",children:[u.length," connection",1===u.length?"":"s"]})]})]})]}),ty.deprecated&&(0,a.jsxs)("div",{className:"flex items-center gap-2 px-3 py-2 rounded-lg bg-yellow-500/10 border border-yellow-500/30",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[16px] text-yellow-500 mt-0.5 shrink-0",children:"warning"}),(0,a.jsx)("p",{className:"text-xs text-red-600 dark:text-yellow-400 leading-relaxed",children:ty.deprecationNotice})]}),ty.notice?.text&&!ty.deprecated&&(0,a.jsxs)("div",{className:"flex flex-col gap-2 rounded-lg border border-blue-500/30 bg-blue-500/10 px-3 py-2 sm:flex-row sm:items-center",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[16px] text-blue-500 shrink-0",children:"info"}),(0,a.jsx)("p",{className:"min-w-0 flex-1 text-xs leading-relaxed text-blue-600 dark:text-blue-400",children:ty.notice.text}),ty.notice.apiKeyUrl&&(0,a.jsx)("a",{href:ty.notice.apiKeyUrl,target:"_blank",rel:"noopener noreferrer",className:"inline-flex justify-center rounded bg-blue-500 px-2 py-1 text-xs font-medium text-white transition-colors hover:bg-blue-600 sm:py-0.5",children:"Get API Key →"})]}),tA&&$&&(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:t$?"Anthropic Compatible Details":"OpenAI Compatible Details"}),(0,a.jsxs)("p",{className:"break-all text-sm text-text-muted",children:[t$?"Messages API":"responses"===$.apiType?"Responses API":"Chat Completions"," \xb7 ",($.baseUrl||"").replace(/\/$/,""),"/",t$?"messages":"responses"===$.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:()=>{V(""),W(!0)},className:"w-full sm:w-auto",children:"Add API Key"}),(0,a.jsx)(d.$n,{size:"sm",variant:"secondary",icon:"edit",onClick:()=>ee(!0),className:"w-full sm:w-auto",children:"Edit"}),(0,a.jsx)(d.$n,{size:"sm",variant:"secondary",icon:"delete",onClick:async()=>{ez({title:"Delete Compatible Node",message:`Delete this ${t$?"Anthropic":"OpenAI"} Compatible node?`,onConfirm:async()=>{ez(null);try{(await fetch(`/api/provider-nodes/${l}`,{method:"DELETE"})).ok&&s.push("/dashboard/providers")}catch(e){console.log("Error deleting provider node:",e)}}})},className:"w-full sm:w-auto",children:"Delete"})]})]})}),tw?(0,a.jsx)(d.gw,{providerId:l}):(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&&E.length>0&&(0,a.jsx)(d.$n,{size:"sm",variant:"secondary",icon:"lan",onClick:()=>{if(0===t6.length)return;let e=[...new Set(t6.map(e=>e.providerSpecificData?.proxyPoolId||"__none__"))];ev(1===e.length?e[0]:"__none__"),es(!0)},disabled:0===t6.length,children:"Apply Proxy"}),u.length>0&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(d.$n,{size:"sm",variant:"secondary",icon:"sync",onClick:tQ,disabled:eL,children:eL?"Testing Connection One-by-One...":"Test Connection One-by-One"}),eL&&(0,a.jsx)(d.$n,{size:"sm",variant:"ghost",icon:"stop",onClick:()=>{eL&&(eZ.current=!0,eJ(!0))},disabled:eK,children:eK?"Stopping...":"Stop"})]}),(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("span",{className:"text-xs text-text-muted font-medium",children:"Thinking"}),(0,a.jsx)("select",{value:eT,onChange:e=>{var t;eE(t=e.target.value),tB(t)},className:"text-xs px-2 py-1 border border-border rounded-md bg-background focus:outline-none focus:border-primary",title:"Forces reasoning_effort on requests; model chips copy as alias/model(level)",children:(tR?.options||c.mt).map(e=>(0,a.jsx)("option",{value:e,children:e.charAt(0).toUpperCase()+e.slice(1)},e))})]}),(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"===eC,onChange:e=>{let t=e?"round-robin":null,s=e?e$||"1":e$;e&&!e$&&eA("1"),eY.current=s,eX.current&&(clearTimeout(eX.current),eX.current=null),eS(t),tJ(t,s)}}),"round-robin"===eC&&(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:e$,onChange:e=>{var t;eA(t=e.target.value),eY.current=t,eX.current&&clearTimeout(eX.current),eX.current=setTimeout(()=>{tJ("round-robin",eY.current)},500)},placeholder:"1",className:"w-14 px-2 py-1 text-xs border border-border rounded-md bg-background focus:outline-none focus:border-primary"})]})]})]})]}),u.length>0&&(0,a.jsxs)("div",{className:"mb-4 flex flex-col gap-3 rounded-lg border border-black/5 bg-black/[0.02] p-3 dark:border-white/5 dark:bg-white/[0.02]",children:[(0,a.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,a.jsxs)("label",{className:"flex items-center gap-1.5 text-xs text-text-muted",children:[(0,a.jsx)("input",{type:"checkbox",checked:t8,onChange:()=>{t8?eb(e=>e.filter(e=>!t5.some(t=>t.id===e))):eb(e=>Array.from(new Set([...e,...t5.map(e=>e.id)])))},className:"size-4 rounded border-black/20 dark:border-white/20"}),t8?"Unselect visible":"Select visible"]}),(0,a.jsxs)(d.Ex,{variant:"default",children:[t5.length," visible"]}),t6.length>0&&(0,a.jsxs)(d.Ex,{variant:"default",children:[t6.length," selected"]}),t9&&(0,a.jsx)("span",{className:"text-xs text-text-muted",children:t9}),t6.length>0&&(0,a.jsx)(d.$n,{size:"sm",variant:"ghost",onClick:()=>{eb([]),ev("__none__")},children:"Clear"}),t6.length>0&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)(d.$n,{size:"sm",variant:"secondary",icon:"delete",onClick:()=>{0!==t6.length&&ez({title:"Delete Selected Connections",message:`Delete ${t6.length} selected connection(s)? This permanently removes the selected accounts.`,onConfirm:async()=>{ez(null);let e=[],t=0;for(let s of t6)try{(await fetch(`/api/providers/${s.id}`,{method:"DELETE"})).ok?e.push(s.id):t+=1}catch(e){console.log("Error deleting selected connection:",e),t+=1}eb(t=>t.filter(t=>!e.includes(t))),t>0&&alert(`Deleted ${e.length} connection(s); ${t} failed.`),await tF()}})},children:["Delete Selected (",t6.length,")"]}),(0,a.jsx)(d.$n,{size:"sm",variant:"secondary",icon:"domain",onClick:()=>sa("gsuite"),children:"Delete GSuite"}),(0,a.jsx)(d.$n,{size:"sm",variant:"secondary",icon:"mail",onClick:()=>sa("gmail"),children:"Delete Gmail"})]})]}),(0,a.jsx)("div",{className:"flex flex-wrap gap-1.5",children:y.gJ.map(e=>(0,a.jsxs)("button",{type:"button",onClick:()=>tt(e.id),className:`rounded-full border px-2.5 py-1 text-xs transition-colors ${te===e.id?"border-primary/50 bg-primary/10 text-primary":"border-border text-text-muted hover:border-primary/30 hover:text-text-main"}`,children:[e.label,(0,a.jsx)("span",{className:"ml-1 text-[10px] opacity-70",children:t4[e.id]||0})]},e.id))}),u.length>=20&&(0,a.jsxs)("div",{className:"relative",children:[(0,a.jsx)("span",{className:"material-symbols-outlined pointer-events-none absolute left-2.5 top-1/2 -translate-y-1/2 text-[16px] text-text-subtle",children:"search"}),(0,a.jsx)("input",{type:"search",value:ts,onChange:e=>ta(e.target.value),placeholder:`Search ${u.length} connections (email, name, id)…`,className:"w-full rounded-lg border border-border bg-background py-2 pl-8 pr-3 text-xs text-text-main outline-none placeholder:text-text-subtle focus:border-primary/40"})]})]}),N?(0,a.jsxs)("div",{className:"flex items-center justify-between gap-3 rounded-lg border border-red-500/30 bg-red-500/10 px-4 py-3",children:[(0,a.jsxs)("div",{className:"flex items-center gap-3",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px] text-red-500",children:"error"}),(0,a.jsx)("p",{className:"text-sm text-red-600 dark:text-red-400",children:N})]}),(0,a.jsx)(d.$n,{size:"sm",variant:"secondary",icon:"refresh",onClick:()=>{k(!0),tF()},children:"Retry"})]}):0===u.length?(0,a.jsxs)(a.Fragment,{children:[(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:tj?"lock":"key"})}),(0,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsx)("p",{className:"text-sm text-text-muted",children:"No connections yet"}),tT&&(0,a.jsxs)("p",{className:"text-xs text-text-muted",children:["Choose ",tI," or ",tP,"."]})]})]}),(0,a.jsxs)("div",{className:"flex gap-2",children:[tE&&(0,a.jsx)(d.$n,{size:"sm",icon:"automation",onClick:tf,children:"Open Automation"}),tT?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(d.$n,{size:"sm",icon:"lock",variant:"secondary",onClick:th,children:tI}),(0,a.jsx)(d.$n,{size:"sm",icon:"key",onClick:tg,children:tP})]}):tE?null:(0,a.jsxs)(a.Fragment,{children:[!tA&&"iflow"===l&&(0,a.jsx)(d.$n,{size:"sm",icon:"cookie",variant:"secondary",onClick:()=>J(!0),children:"Cookie"}),(0,a.jsx)(d.$n,{size:"sm",icon:"add",onClick:tb,children:tA?"Add API Key":"iflow"===l?"OAuth":"Add Connection"})]})]})]}),"kiro"===l&&e2?.jobId&&(0,a.jsxs)("div",{className:"mt-4 flex flex-col gap-3 rounded-lg border border-primary/20 bg-primary/[0.06] px-4 py-3 sm:flex-row sm:items-center sm:justify-between",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("p",{className:"text-sm font-semibold text-text-main",children:"Bulk import progress is still available"}),(0,a.jsxs)("p",{className:"text-xs text-text-muted",children:["Status: ",e2.status," | Success: ",e2.summary?.success||0," | Running: ",e2.summary?.running||0," | Queued: ",e2.summary?.queued||0]})]}),(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsx)(d.$n,{size:"sm",icon:"monitoring",variant:"secondary",onClick:()=>s.push(p("kiro")),children:"Resume Bulk Progress"}),D(e2.status)&&(0,a.jsx)(d.$n,{size:"sm",variant:"ghost",icon:"close",onClick:tx,children:"Clear"})]})]}),"kiro"===l&&!e2?.jobId&&e4&&(0,a.jsx)("div",{className:"mt-4 rounded-lg border border-amber-200 bg-amber-50 px-4 py-3 text-sm text-amber-700 dark:border-amber-800 dark:bg-amber-900/20 dark:text-amber-300",children:e4})]}):(0,a.jsxs)(a.Fragment,{children:[eQ&&(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: ",eQ.total]}),(0,a.jsxs)("span",{children:["Completed: ",eQ.completed]}),(0,a.jsxs)("span",{children:["Passed: ",eQ.passed]}),(0,a.jsxs)("span",{children:["Failed: ",eQ.failed]}),eQ.stopped&&(0,a.jsx)("span",{className:"text-amber-600 dark:text-amber-400",children:"Stopped"}),eL&&eB&&(0,a.jsxs)("span",{children:["Running: ",u.find(e=>e.id===eB)?.name||eB]})]})}),"kiro"===l&&e2?.jobId&&(0,a.jsxs)("div",{className:"mb-4 flex flex-col gap-3 rounded-lg border border-primary/20 bg-primary/[0.06] px-4 py-3 sm:flex-row sm:items-center sm:justify-between",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("p",{className:"text-sm font-semibold text-text-main",children:"Bulk import progress is still available"}),(0,a.jsxs)("p",{className:"text-xs text-text-muted",children:["Status: ",e2.status," | Success: ",e2.summary?.success||0," | Running: ",e2.summary?.running||0," | Queued: ",e2.summary?.queued||0]})]}),(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsx)(d.$n,{size:"sm",icon:"monitoring",variant:"secondary",onClick:()=>s.push(p("kiro")),children:"Resume Bulk Progress"}),D(e2.status)&&(0,a.jsx)(d.$n,{size:"sm",variant:"ghost",icon:"close",onClick:tx,children:"Clear"})]})]}),"kiro"===l&&!e2?.jobId&&e4&&(0,a.jsx)("div",{className:"mb-4 rounded-lg border border-amber-200 bg-amber-50 px-4 py-3 text-sm text-amber-700 dark:border-amber-800 dark:bg-amber-900/20 dark:text-amber-300",children:e4}),sn,"kiro"===l&&si>1&&(0,a.jsxs)("div",{className:"mt-4 flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[(0,a.jsxs)("p",{className:"text-sm text-text-muted",children:["Page ",sr," of ",si," • Showing ",(sr-1)*e8+1,"-",Math.min(sr*e8,t5.length)," of ",t5.length," connections"]}),(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsx)(d.$n,{size:"sm",variant:"secondary",disabled:sr<=1,onClick:()=>e7(e=>Math.max(1,e-1)),children:"Previous"}),(0,a.jsx)(d.$n,{size:"sm",variant:"secondary",disabled:sr>=si,onClick:()=>e7(e=>Math.min(si,e+1)),children:"Next"})]})]}),"kiro"!==l&&t5.length>0&&(0,a.jsx)(d.dK,{currentPage:sr,pageSize:e8,totalItems:t5.length,onPageChange:e7,onPageSizeChange:e=>{e9(e),e7(1)},className:"mt-2"}),u.length>0&&0===t5.length&&(0,a.jsx)("div",{className:"py-8 text-center text-sm text-text-muted",children:"No connections match this status filter."}),!tA&&(0,a.jsxs)("div",{className:"mt-4 grid grid-cols-1 gap-2 sm:flex",children:["iflow"===l&&(0,a.jsx)(d.$n,{size:"sm",icon:"cookie",variant:"secondary",onClick:()=>J(!0),title:"Add connection using browser cookie",className:"w-full sm:w-auto",children:"Cookie"}),"codebuddy"===l&&(0,a.jsx)(d.$n,{size:"sm",icon:"cookie",variant:"secondary",onClick:()=>{u.length>1&&0===t6.length?alert("Select the CodeBuddy connection(s) that should use this quota cookie first."):H(!0)},title:"Attach CodeBuddy web cookie for quota tracking",className:"w-full sm:w-auto",children:"Quota Cookie"}),tE&&(0,a.jsx)(d.$n,{size:"sm",icon:"automation",onClick:tf,className:"w-full sm:w-auto",children:"Open Automation"}),tT?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(d.$n,{size:"sm",icon:"lock",variant:"secondary",onClick:th,className:"w-full sm:w-auto",children:tI}),(0,a.jsx)(d.$n,{size:"sm",icon:"key",onClick:tg,className:"w-full sm:w-auto",children:tP})]}):tE?null:(0,a.jsx)(d.$n,{size:"sm",icon:"add",onClick:tb,className:"w-full sm:w-auto",children:"Add"})]})]})]}),(0,a.jsxs)(d.Zp,{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"}),!tA&&(e=[...tN,...eR.filter(e=>!tN.some(t=>t.id===e.id))].filter(e=>!e.type||"llm"===e.type).map(e=>e.id).filter(e=>!eO.includes(e)),(0,a.jsxs)("div",{className:"flex gap-2",children:[eO.length>0&&(0,a.jsx)(d.$n,{size:"sm",variant:"secondary",icon:"restart_alt",onClick:tM,children:"Active All"}),e.length>0&&(0,a.jsx)(d.$n,{size:"sm",variant:"secondary",icon:"block",onClick:()=>tU(e),children:"Disable All"})]}))]}),Object.values(eu).some(Boolean)&&(0,a.jsx)("div",{className:"mb-3 flex flex-col gap-1",children:Object.entries(eu).filter(([,e])=>!!e).map(([e,t])=>(0,a.jsxs)("p",{className:"text-xs text-red-500 break-words",children:[e,": ",t]},e))}),(()=>{let e,t,s;if(tA)return(0,a.jsx)(C,{providerStorageAlias:t_,providerDisplayAlias:tO,modelAliases:er,copied:to,onCopy:td,onSetAlias:tH,onDeleteAlias:tG,connections:u,isAnthropic:t$});let i=[...tN,...eR.filter(e=>!tN.some(t=>t.id===e.id))].filter(e=>!e.type||"llm"===e.type),r=new Set(eO),n=i.filter(e=>!r.has(e.id)),o=i.filter(e=>r.has(e.id)),c=Object.entries(er).filter(([e,t])=>{let s=`${t_}/`;if(!t.startsWith(s))return!1;let a=t.slice(s.length);return ty.passthroughModels?!tN.some(e=>e.id===a):!tN.some(e=>e.id===a)&&e===a}).map(([e,t])=>({id:t.slice(`${t_}/`.length),alias:e,fullModel:t})),m=Math.min(ti,Math.max(1,Math.ceil(n.length/tl))),p=n.slice((m-1)*tl,m*tl);return(0,a.jsxs)("div",{className:"flex flex-wrap gap-3",children:[c.map(e=>(0,a.jsx)(w,{model:{id:e.id},fullModel:`${tO}/${e.id}`,alias:e.alias,copied:to,onCopy:td,onSetAlias:()=>{},onDeleteAlias:()=>tG(e.alias),testStatus:ed[e.id],onTest:u.length>0||tw?()=>sc(e.id):void 0,isTesting:ep===e.id,isCustom:!0,isFree:!1,thinkingSuffix:eT&&"auto"!==eT&&"off"!==eT&&"none"!==eT?eT:null},e.id)),p.map(e=>{let t=`${t_}/${e.id}`,s=`${l}/${e.id}`,i=Object.entries(er).find(([,e])=>e===t||e===s)?.[0];return(0,a.jsx)(w,{model:e,fullModel:`${tO}/${e.id}`,alias:i,copied:to,onCopy:td,onSetAlias:t=>tH(e.id,t,t_),onDeleteAlias:()=>tG(i),testStatus:ed[e.id],onTest:u.length>0||tw?()=>sc(e.id):void 0,isTesting:ep===e.id,isFree:e.isFree,onDisable:()=>tq(e.id),thinkingSuffix:eT&&"auto"!==eT&&"off"!==eT&&"none"!==eT?eT:null},e.id)}),n.length>tl&&(0,a.jsx)("div",{className:"w-full",children:(0,a.jsx)(d.dK,{currentPage:m,pageSize:tl,totalItems:n.length,onPageChange:tr,onPageSizeChange:e=>{tn(e),tr(1)}})}),(0,a.jsxs)("button",{onClick:()=>ef(!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"===l&&u.some(e=>!1!==e.isActive)&&(0,a.jsxs)("button",{onClick:tW,disabled:e0,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:e0?{animation:"spin 1s linear infinite"}:void 0,children:e0?"progress_activity":"download"}),e0?(0,f.Tl)("Fetching..."):(0,f.Tl)("Fetch Qoder Models")]}),eI.length>0&&(e=new Set(Object.values(er)),t=new Set(tN.map(e=>e.id)),0===(s=eI.filter(s=>!e.has(`${t_}/${s.id}`)&&!t.has(s.id))).length?null:(0,a.jsxs)("div",{className:"w-full mt-2",children:[(0,a.jsx)("p",{className:"text-xs text-text-muted mb-2",children:"Suggested free models (≥200k context):"}),(0,a.jsx)("div",{className:"flex flex-wrap gap-2",children:s.map(e=>(0,a.jsxs)("button",{onClick:async()=>{let t=e.id.split("/").pop();await tH(e.id,t,t_)},className:"flex items-center gap-1 px-2.5 py-1.5 rounded-lg border border-black/10 dark:border-white/10 text-xs text-text-muted hover:text-primary hover:border-primary/40 hover:bg-primary/5 transition-colors",title:`${e.name} \xb7 ${(e.contextLength/1e3).toFixed(0)}k ctx`,children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[13px]",children:"add"}),e.id.split("/").pop()]},e.id))})]})),o.length>0&&(0,a.jsxs)("div",{className:"w-full mt-2",children:[(0,a.jsxs)("p",{className:"text-xs text-text-muted mb-2",children:["Disabled models (",o.length,"):"]}),(0,a.jsx)("div",{className:"flex flex-wrap gap-2",children:o.map(e=>(0,a.jsxs)("button",{onClick:()=>tz(e.id),className:"flex items-center gap-1 px-2.5 py-1.5 rounded-lg border border-dashed border-black/10 dark:border-white/10 text-xs text-text-muted hover:text-primary hover:border-primary/40 hover:bg-primary/5 transition-colors",title:"Restore model",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[13px]",children:"add"}),e.id]},e.id))})]})]})})()]}),sd,"kiro"===l?(0,a.jsx)(d.Mh,{isOpen:L,providerInfo:ty,onSuccess:tZ,onRefresh:tF,initialBulkJobId:e2?.jobId||null,onBulkJobChange:tX,onClose:()=>F(!1)}):"cursor"===l?(0,a.jsx)(d.G9,{isOpen:L,onSuccess:tZ,onClose:()=>F(!1)}):"gitlab"===l?(0,a.jsx)(d.vj,{isOpen:L,providerInfo:ty,onSuccess:tZ,onClose:()=>F(!1)}):(0,a.jsx)(d.LF,{isOpen:L,provider:l,providerInfo:ty,onSuccess:tZ,onClose:()=>F(!1)}),"iflow"===l&&(0,a.jsx)(d.vE,{isOpen:K,onSuccess:()=>{tF(),J(!1)},onClose:()=>J(!1)}),"codebuddy"===l&&(0,a.jsx)(d.xl,{isOpen:B,connectionIds:t7,onSuccess:()=>{tF(),H(!1)},onClose:()=>H(!1)}),(0,a.jsx)(I,{isOpen:G,provider:l,providerName:ty.name,isCompatible:tA,isAnthropic:t$,authType:ty?.authType,authHint:ty?.authHint,website:ty?.website,proxyPools:E,error:Q,onSave:tY,onBulkDone:tF,onClose:()=>{V(""),W(!1)}}),(0,a.jsx)(d.wI,{isOpen:Z,connection:ea,proxyPools:E,onSave:t0,onClose:()=>X(!1)}),tA&&(0,a.jsx)(P,{isOpen:Y,node:$,onSave:tK,onClose:()=>ee(!1),isAnthropic:t$}),!tA&&(0,a.jsx)(R,{isOpen:eh,providerAlias:t_,providerDisplayAlias:tO,onSave:async e=>{let t=ty?.passthroughModels?e.split("/").pop():e;await tH(e,t,t_),ef(!1)},onClose:()=>ef(!1)}),(0,a.jsx)(d.uo,{isOpen:eU,onClose:()=>eM(!1),onConfirm:()=>{(window.localStorage.setItem(tp,"true"),eM(!1),m("antigravity"))?s.push(p("antigravity")):tj?th():tg()},title:"Risk Notice",message:ty?.deprecationNotice,confirmText:"I Understand, Continue",cancelText:"Cancel",variant:"danger"}),(0,a.jsx)(d.uo,{isOpen:!!eq,onClose:()=>{ew||ez(null)},onConfirm:async()=>{if(ew)return;let e=eq?.onConfirm;if(e){eN(!0);try{await e()}finally{eN(!1)}}},title:eq?.title||"Confirm",message:eq?.message,variant:"danger",loading:ew})]}):(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"})]})}},28915:(e,t,s)=>{"use strict";s.d(t,{x6:()=>a.fetchJson,E2:()=>i,gs:()=>r});var a=s(68211);function i(e){if(!e)return null;let t=e.match(/\b([45]\d{2})\b/);return t?t[1]:"ERR"}function r(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 a=Math.floor(s/24);return`${a}d ago`}},42911:(e,t,s)=>{Promise.resolve().then(s.bind(s,20898))},68211:(e,t,s)=>{"use strict";s.d(t,{fetchJson:()=>i});let a={"Content-Type":"application/json"};async function i(e,t={}){let{body:s,headers:r,...l}=t,n={...l,headers:{...a,...r}};void 0!==s&&"string"!=typeof s?n.body=JSON.stringify(s):void 0!==s&&(n.body=s);let o=await fetch(e,n),d=await o.text(),c=null;if(d)try{c=JSON.parse(d)}catch{let t=Error(`Non-JSON response from ${e} (HTTP ${o.status})`);throw t.status=o.status,t.rawBody=d.slice(0,300),t}if(!o.ok){let e=c&&(c.error?.message||c.error||c.message)||`Request failed (HTTP ${o.status})`,t=Error("string"==typeof e?e:`HTTP ${o.status}`);throw t.status=o.status,t.data=c,t}return c}i.get=(e,t)=>i(e,{...t,method:"GET"}),i.post=(e,t,s)=>i(e,{...s,method:"POST",body:t}),i.put=(e,t,s)=>i(e,{...s,method:"PUT",body:t}),i.patch=(e,t,s)=>i(e,{...s,method:"PATCH",body:t}),i.del=(e,t)=>i(e,{...t,method:"DELETE"})},70217:(e,t,s)=>{"use strict";s.d(t,{BU:()=>u,G9:()=>n,d4:()=>d,gJ:()=>a,i2:()=>c});let a=[{id:"all",label:"All"},{id:"active",label:"Active",keys:["active"]},{id:"errors",label:"Errors",keys:["connection_error","auth_error","quota_exhausted","rate_limited","banned","cooldown","unknown"]},{id:"connection",label:"Connection",keys:["connection_error"]},{id:"auth",label:"Auth",keys:["auth_error"]},{id:"limit",label:"Limit",keys:["rate_limited","cooldown"]},{id:"exhausted",label:"Exhausted",keys:["quota_exhausted"]},{id:"banned",label:"Banned",keys:["banned"]},{id:"disabled",label:"Disabled",keys:["disabled"]}],i={active:{label:"active",severity:"success",terminal:!1},disabled:{label:"disabled",severity:"default",terminal:!1},connection_error:{label:"connection error",severity:"error",terminal:!1},auth_error:{label:"auth error",severity:"error",terminal:!0},quota_exhausted:{label:"exhausted",severity:"error",terminal:!0},rate_limited:{label:"rate limited",severity:"warning",terminal:!1},banned:{label:"banned",severity:"error",terminal:!0},cooldown:{label:"cooldown",severity:"warning",terminal:!1},unknown:{label:"unknown",severity:"default",terminal:!1}},r={policy_suspended:"banned",credential_rejected:"auth_error",reauth_required:"auth_error",authentication:"auth_error",entitlement_or_quota:"quota_exhausted",rate_limited:"rate_limited",permission_denied:"auth_error",upstream_transient:"connection_error"};function l(e){if(!e)return"";if("string"==typeof e)return e.toLowerCase();try{return JSON.stringify(e).toLowerCase()}catch{return String(e).toLowerCase()}}function n(e={},t=Date.now()){let s=Object.entries(e).filter(([e])=>e.startsWith("modelLock_")).map(([,e])=>new Date(e).getTime()).filter(e=>Number.isFinite(e)&&e>t);return s.length>0?new Date(Math.min(...s)).toISOString():null}function o(e,t=""){let s=i[e]||i.unknown;return{key:e,...s,reason:t}}function d(e={}){var t;let s=(t=e).quarantinedAt?o(r[l(t.failureClass)]||"unknown",t.quarantineReason||t.lastError||"Connection is quarantined"):null;if(s)return s;if(!1===e.isActive)return o("disabled","Connection is disabled");if(function(e={}){return null!==n(e)}(e))return o("cooldown","Model cooldown is active");if(function(e){if(!e)return!1;let t=new Date(e).getTime();return Number.isFinite(t)&&t>Date.now()}(e.rateLimitedUntil))return o("rate_limited","Rate limit cooldown is active");let a=l(e.testStatus||e.status),i=l(e.lastErrorType||e.errorType),c=l(e.errorCode||e.statusCode),u=l(e.lastError||e.error),m=`${a} ${i} ${c} ${u}`.trim();return!m||["active","success","ok"].includes(a)?o("active",""):m.includes("ban")||m.includes("suspend")||m.includes("restricted")?o("banned",e.lastError||"Account appears restricted"):m.includes("exhaust")||m.includes("quota exceeded")||m.includes("insufficient_quota")||m.includes("payment required")||"402"===c?o("quota_exhausted",e.lastError||"Quota exhausted"):i.includes("rate_limited")||m.includes("rate limit")||m.includes("too many requests")||"429"===c?o("rate_limited",e.lastError||"Rate limited"):i.includes("auth")||i.includes("token")||m.includes("unauthorized")||m.includes("invalid api key")||m.includes("token invalid")||m.includes("token expired")||m.includes("revoked")||"401"===c||"403"===c?o("auth_error",e.lastError||"Authentication failed"):i.includes("network")||m.includes("network")||m.includes("timeout")||m.includes("fetch failed")||m.includes("econn")||m.includes("dns")||m.includes("proxy")?o("connection_error",e.lastError||"Connection failed"):["error","expired","unavailable","failed"].includes(a)?o("connection_error",e.lastError||e.testStatus||"Connection failed"):o("unknown",e.lastError||e.testStatus||"")}function c(e,t){if(!t||"all"===t)return!0;let s=a.find(e=>e.id===t);return!s||s.keys.includes(d(e).key)}function u(e){return e?.severity==="success"?"success":e?.severity==="error"?"error":"default"}},81277:(e,t,s)=>{"use strict";s.d(t,{c:()=>r});var a=s(12115),i=s(70217);function r(e={}){let[t,s]=(0,a.useState)(null),l=JSON.stringify(Object.entries(e).filter(([e])=>e.startsWith("modelLock_")).sort(([e],[t])=>e.localeCompare(t)));return(0,a.useEffect)(()=>(function(e,t,s={}){let a=s.now||Date.now,r=s.setTimer||globalThis.setTimeout,l=s.clearTimer||globalThis.clearTimeout,n=!1,o=null,d=()=>{if(o=null,n)return;let s=a(),l=(0,i.G9)(e,s);t(l),l&&(o=r(d,Math.min(Math.max(1,new Date(l).getTime()-s+1),0x7fffffff)))};return o=r(d,0),()=>{n=!0,null!==o&&l(o),o=null}})(Object.fromEntries(JSON.parse(l)),s),[l]),t}}},e=>{e.O(0,[2574,3862,3745,3339,620,5497,8441,3794,7358],()=>e(e.s=42911)),_N_E=e.O()}]);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[9089],{15615:(e,r,a)=>{"use strict";a.r(r),a.d(r,{default:()=>m});var t=a(95155),s=a(12115),i=a(73321),l=a(98500),d=a.n(l),o=a(35497),n=a(90620);let c=Object.values(n.Q2).map(e=>({value:e.id,label:e.name})),p=Object.values(n.MA).filter(e=>"apikey"===e.id).map(e=>({value:e.id,label:e.name}));function m(){let e=(0,i.useRouter)(),[r,a]=(0,s.useState)(!1),[l,m]=(0,s.useState)({provider:"",authMethod:"api_key",apiKey:"",displayName:"",isActive:!0}),[h,u]=(0,s.useState)({}),x=(e,r)=>{m(a=>({...a,[e]:r})),h[e]&&u(r=>({...r,[e]:null}))},v=async r=>{let t;if(r.preventDefault(),t={},l.provider||(t.provider="Please select a provider"),"api_key"!==l.authMethod||l.apiKey||(t.apiKey="API Key is required"),u(t),0===Object.keys(t).length){a(!0);try{let r=await fetch("/api/providers",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(l)});if(r.ok)e.push("/dashboard/providers");else{let e=await r.json();u({submit:e.error||"Failed to create provider"})}}catch(e){u({submit:"An error occurred. Please try again."})}finally{a(!1)}}},b=n.Q2[l.provider];return(0,t.jsxs)("div",{className:"max-w-2xl mx-auto",children:[(0,t.jsxs)("div",{className:"mb-8",children:[(0,t.jsxs)(d(),{href:"/dashboard/providers",className:"inline-flex items-center gap-1 text-sm text-text-muted hover:text-primary transition-colors mb-4",children:[(0,t.jsx)("span",{className:"material-symbols-outlined text-lg",children:"arrow_back"}),"Back to Providers"]}),(0,t.jsx)("h1",{className:"text-3xl font-semibold tracking-tight",children:"Add New Provider"}),(0,t.jsx)("p",{className:"text-text-muted mt-2",children:"Configure a new AI provider to use with your applications."})]}),(0,t.jsx)(o.Zp,{children:(0,t.jsxs)("form",{onSubmit:v,className:"flex flex-col gap-6",children:[(0,t.jsx)(o.l6,{label:"Provider",options:c,value:l.provider,onChange:e=>x("provider",e.target.value),placeholder:"Select a provider",error:h.provider,required:!0}),b&&(0,t.jsxs)(o.Zp.Section,{className:"flex items-center gap-3",children:[(0,t.jsx)("div",{className:"size-10 rounded-lg flex items-center justify-center bg-bg border border-border",children:(0,t.jsx)("span",{className:"material-symbols-outlined text-xl",style:{color:b.color},children:b.icon})}),(0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"font-medium",children:b.name}),(0,t.jsx)("p",{className:"text-sm text-text-muted",children:"Selected provider"})]})]}),(0,t.jsxs)("div",{className:"flex flex-col gap-3",children:[(0,t.jsxs)("label",{className:"text-sm font-medium",children:["Authentication Method ",(0,t.jsx)("span",{className:"text-red-500",children:"*"})]}),(0,t.jsx)("div",{className:"flex gap-3",children:p.map(e=>(0,t.jsxs)("button",{type:"button",onClick:()=>x("authMethod",e.value),className:`flex-1 flex items-center justify-center gap-2 p-4 rounded-lg border transition-all ${l.authMethod===e.value?"border-primary bg-primary/5 text-primary":"border-border hover:border-primary/50"}`,children:[(0,t.jsx)("span",{className:"material-symbols-outlined",children:"api_key"===e.value?"key":"lock"}),(0,t.jsx)("span",{className:"font-medium",children:e.label})]},e.value))})]}),"api_key"===l.authMethod&&(0,t.jsx)(o.pd,{label:"API Key",type:"password",placeholder:"Enter your API key",value:l.apiKey,onChange:e=>x("apiKey",e.target.value),error:h.apiKey,hint:"Your API key will be encrypted and stored securely.",required:!0}),"oauth2"===l.authMethod&&(0,t.jsx)(o.Zp.Section,{children:(0,t.jsx)("p",{className:"text-sm text-text-muted",children:"OAuth connections are created from each provider's detail page instead of this form."})}),(0,t.jsx)(o.pd,{label:"Display Name",placeholder:"e.g., Production API, Dev Environment",value:l.displayName,onChange:e=>x("displayName",e.target.value),hint:"Optional. A friendly name to identify this configuration."}),(0,t.jsx)(o.lM,{checked:l.isActive,onChange:e=>x("isActive",e),label:"Active",description:"Enable this provider for use in your applications"}),h.submit&&(0,t.jsx)("div",{className:"p-4 rounded-lg bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 text-red-600 dark:text-red-400 text-sm",children:h.submit}),(0,t.jsxs)("div",{className:"flex gap-3 pt-4 border-t border-border",children:[(0,t.jsx)(d(),{href:"/dashboard/providers",className:"flex-1",children:(0,t.jsx)(o.$n,{type:"button",variant:"ghost",fullWidth:!0,children:"Cancel"})}),(0,t.jsx)(o.$n,{type:"submit",loading:r,fullWidth:!0,className:"flex-1",children:"Create Provider"})]})]})})]})}},44584:(e,r,a)=>{Promise.resolve().then(a.bind(a,15615))}},e=>{e.O(0,[2574,3862,3745,3339,620,5497,8441,3794,7358],()=>e(e.s=44584)),_N_E=e.O()}]);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[8460],{20490:(e,t,s)=>{"use strict";s.r(t),s.d(t,{default:()=>j});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),x=s(28915),u=s(65921),h=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 b(){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,u.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 h=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 b=e?.models||[],g=e?.unavailableCount||b.filter(e=>"available"!==e.status).length,v=0===g,y={};return b.forEach(e=>{if("available"===e.status)return;let t=e.provider||"unknown";y[t]||(y[t]=[]),y[t].push(e)}),(0,r.jsxs)("div",{className:"relative",ref:m,children:[(0,r.jsxs)("button",{onClick:()=>o(!i),className:`inline-flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-xs font-medium border transition-all ${v?"bg-emerald-500/10 border-emerald-500/20 text-emerald-500 hover:bg-emerald-500/15":"bg-amber-500/10 border-amber-500/20 text-amber-500 hover:bg-amber-500/15"}`,children:[(0,r.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:v?"verified":"warning"}),v?"All models operational":`${g} model${1!==g?"s":""} with issues`]}),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:v?"#22c55e":"#f59e0b"},children:v?"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:v?(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(y).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:()=>h(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 g(e,t,s){if(e>0)return(0,r.jsxs)("span",{className:"inline-flex min-w-0 items-center gap-1.5 text-[11px] font-medium text-success",children:[(0,r.jsx)("span",{"aria-hidden":"true",className:"size-1.5 shrink-0 rounded-full bg-success"}),e," connected"]});if(t>0){let e=s?`${t} Error (${s})`:`${t} Error`;return(0,r.jsxs)("span",{className:"inline-flex min-w-0 items-center gap-1.5 text-[11px] font-medium text-error",children:[(0,r.jsx)("span",{"aria-hidden":"true",className:"size-1.5 shrink-0 rounded-full bg-error"}),e]})}return(0,r.jsx)("span",{className:"text-[11px] text-text-muted",children:"No connections"})}let v=[{value:"all",label:"All"},{value:"connected",label:"Connected"},{value:"ready",label:"Ready"},{value:"setup",label:"Needs setup"}];async function y(e){let t=new AbortController,s=window.setTimeout(()=>t.abort(),8e3);try{let s=await fetch(e,{cache:"no-store",signal:t.signal}),r=null;try{r=await s.json()}catch{r=null}return{response:s,data:r}}finally{window.clearTimeout(s)}}function j(){let e,t,[s,l]=(0,a.useState)([]),[i,o]=(0,a.useState)([]),[m,p]=(0,a.useState)(!0),[f,g]=(0,a.useState)(""),[j,$]=(0,a.useState)(1),[S,I]=(0,a.useState)(20),[R,E]=(0,a.useState)(!1),[P,O]=(0,a.useState)(!1),[U,_]=(0,a.useState)(null),[q,z]=(0,a.useState)(null),[M,D]=(0,a.useState)("all"),[F,J]=(0,a.useState)({custom:!1,oauth:!1,free:!0,apikey:!0}),H=(0,u.i)(),K=(0,h.C)(e=>e.query),L=(0,h.C)(e=>e.register),W=(0,h.C)(e=>e.unregister);(0,a.useEffect)(()=>(L("Search providers..."),()=>W()),[L,W]),(0,a.useEffect)(()=>{$(1)},[K,S,M]);let B=e=>!K.trim()||e.toLowerCase().includes(K.trim().toLowerCase());(0,a.useEffect)(()=>{(async()=>{try{g("");let[e,t]=await Promise.allSettled([y("/api/providers"),y("/api/provider-nodes")]);"fulfilled"===e.status&&e.value.response.ok?l(e.value.data?.connections||[]):(l([]),g("Provider connection stats could not be loaded. The provider catalog is still available.")),"fulfilled"===t.status&&t.value.response.ok?o(t.value.data?.nodes||[]):(o([]),g(e=>e||"Custom provider data could not be loaded. The provider catalog is still available."))}catch(e){console.log("Error fetching data:",e),g("Provider data could not be loaded. The provider catalog is still available.")}finally{p(!1)}})()},[]);let Q=(0,a.useMemo)(()=>{let e=new Map;for(let t of s){let s=t.provider||t.id;e.has(s)||e.set(s,[]),e.get(s).push(t)}return e},[s]),V=s.length,X=(0,a.useMemo)(()=>s.filter(e=>!1!==e.isActive).length,[s]),Z=Q.size,G=Math.max(0,V-X),Y=V>0?Math.round(X/V*100):0,ee=(e,t)=>{let s=Array.isArray(t)?t:[t],r=(Q.get(e)||[]).filter(e=>s.includes(e.authType)),a=r.filter(e=>{let t,s=(t=Object.entries(e).some(([e,t])=>e.startsWith("modelLock_")&&t&&new Date(t).getTime()>Date.now()),"unavailable"!==e.testStatus||t?e.testStatus:"active");return"error"===s||"expired"===s||"unavailable"===s}),l=r.length>0?r.length:0,i=r.length>0?0:a.length,n=r.length,o=n>0&&r.every(e=>!1===e.isActive),d=a.sort((e,t)=>new Date(t.lastErrorAt||0)-new Date(e.lastErrorAt||0))[0];return{connected:l,error:i,total:n,errorCode:d?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=(0,x.E2)(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"}(d):null,errorTime:d?.lastErrorAt?(0,x.gs)(d.lastErrorAt):null,allDisabled:o}},et=(e,t,s)=>{if("all"===M)return!0;let r=ee(e,s);return"connected"===M?r.connected>0:"ready"===M?0===r.connected&&!0===t.noAuth:0===r.connected&&!0!==t.noAuth},es=e=>{J(t=>({...t,[e]:!t[e]}))},er=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})}).then(async e=>{if(!e.ok)throw Error(`HTTP ${e.status}`);return e})))).filter(e=>"rejected"===e.status).length;i>0&&(l(s=>s.map(s=>s.provider===e&&s.authType===t?{...s,isActive:!r}:s)),H.error(`Failed to update ${i} connection${i>1?"s":""} — reverted`))},ea=async(e,t=null)=>{if(!U){_("provider"===e?t:e),z(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(z(r),r.summary){let{passed:e,failed:t,total:s}=r.summary;0===t?H.success(`All ${s} tests passed`):H.warning(`${e}/${s} passed, ${t} failed`)}}catch(e){z({error:"Test request failed"}),H.error("Provider test failed")}finally{_(null)}}},el=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=>B(e.name)&&et(e.id,e,"apikey")),ei=i.filter(e=>"anthropic-compatible"===e.type).map(e=>({id:e.id,name:e.name||"Anthropic Compatible",color:"#D97757",textIcon:"AC"})).filter(e=>B(e.name)&&et(e.id,e,"apikey")),en=Object.entries(d.zN).filter(([e,t])=>!t.hidden&&B(t.name)&&et(e,t,"oauth")),eo=Object.entries(c.IS).filter(([e,t])=>{let s=Array.isArray(t?.authModes)&&t.authModes.includes("apikey");return!t.hidden&&B(t.name)&&et(e,t,s?["oauth","apikey"]:"oauth")}),ed=Object.entries(c.nJ).filter(([e,t])=>!t.hidden&&B(t.name)&&et(e,t,"apikey")),ec=(e=Object.entries(d.fg).filter(([e,t])=>!t.hidden&&(t.serviceKinds??["llm"]).includes("llm")&&B(t.name)&&et(e,t,"apikey")),t="apikey",[...e].sort(([e,s],[r,a])=>{let l=ee(e,t),i=ee(r,t),n=+(l.connected>0),o=+(i.connected>0);return n!==o?o-n:(s.name||"").localeCompare(a.name||"")})),em=Math.min(j,Math.max(1,Math.ceil(ec.length/S))),ep=ec.slice((em-1)*S,em*S);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 ex=en.length>0||eo.length>0||ed.length>0||ec.length>0||el.length>0||ei.length>0,eu=el.length>0||ei.length>0||"all"===M&&!K.trim();return(0,r.jsxs)("div",{className:"flex min-w-0 flex-col gap-6 px-1 sm:px-0",children:[V>0&&(0,r.jsx)("div",{className:"overflow-hidden rounded-xl border border-border bg-surface/80 shadow-sm",children:(0,r.jsxs)("div",{className:"grid grid-cols-3 divide-x divide-y divide-border-subtle sm:grid-cols-4 sm:divide-y-0",children:[(0,r.jsxs)("div",{className:"col-span-3 flex items-center gap-3 px-4 py-3 sm:col-span-1",children:[(0,r.jsx)("span",{className:"flex size-9 shrink-0 items-center justify-center rounded-lg bg-primary/[0.08] text-primary",children:(0,r.jsx)("span",{"aria-hidden":"true",className:"material-symbols-outlined",style:{fontSize:18},children:"dns"})}),(0,r.jsxs)("div",{children:[(0,r.jsx)("p",{className:"text-[11px] font-medium text-text-muted",children:"Connection health"}),(0,r.jsxs)("p",{className:"mt-0.5 text-sm font-semibold tabular-nums text-text-main",children:[Y,"% active"]})]})]}),(0,r.jsxs)("div",{className:"px-4 py-3",children:[(0,r.jsx)("p",{className:"text-[11px] font-medium text-text-muted",children:"Connections"}),(0,r.jsx)("p",{className:"mt-0.5 text-lg font-semibold tabular-nums text-text-main",children:V})]}),(0,r.jsxs)("div",{className:"px-4 py-3",children:[(0,r.jsx)("p",{className:"text-[11px] font-medium text-text-muted",children:"Active"}),(0,r.jsxs)("div",{className:"mt-0.5 flex items-baseline gap-2",children:[(0,r.jsx)("p",{className:"text-lg font-semibold tabular-nums text-success",children:X}),G>0&&(0,r.jsxs)("span",{className:"text-[10px] text-text-muted",children:[G," paused"]})]})]}),(0,r.jsxs)("div",{className:"px-4 py-3",children:[(0,r.jsx)("p",{className:"text-[11px] font-medium text-text-muted",children:"Providers"}),(0,r.jsx)("p",{className:"mt-0.5 text-lg font-semibold tabular-nums text-info",children:Z})]})]})}),f&&(0,r.jsx)("div",{className:"rounded-lg border border-amber-200 bg-amber-50 px-4 py-3 text-sm text-amber-700 dark:border-amber-800 dark:bg-amber-900/20 dark:text-amber-300",children:f}),(0,r.jsx)("div",{className:"overflow-x-auto pb-0.5 [scrollbar-width:none] [&::-webkit-scrollbar]:hidden",children:(0,r.jsx)("div",{className:"inline-flex min-w-full items-center gap-1.5 rounded-xl border border-border-subtle bg-surface/70 p-1.5 sm:min-w-0",children:v.map(e=>(0,r.jsx)("button",{type:"button",onClick:()=>{D(e.value),$(1),J({custom:!1,oauth:!1,free:!1,apikey:!1})},"aria-pressed":M===e.value,className:`flex h-11 flex-1 items-center justify-center whitespace-nowrap rounded-lg px-3 text-xs font-medium transition-colors sm:h-8 sm:flex-none sm:px-3 ${M===e.value?"bg-primary text-white shadow-sm":"text-text-muted hover:bg-black/5 hover:text-text-main dark:hover:bg-white/5"}`,children:e.label},e.value))})}),!ex&&(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:K.trim()?"No providers match your search":"No providers match this filter"})]}),eu&&(0,r.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,r.jsx)(N,{icon:"extension",title:"Custom Providers",description:"OpenAI and Anthropic-compatible endpoints",count:el.length+ei.length,collapsed:F.custom&&!K.trim(),onToggle:()=>es("custom"),children:(0,r.jsxs)("div",{className:"grid grid-cols-1 gap-2 sm:flex sm:w-auto",children:[(0,r.jsx)(n.$n,{size:"sm",icon:"add",onClick:()=>O(!0),className:"min-h-11 w-full sm:min-h-0 sm:w-auto",children:"Add Anthropic Compatible"}),(0,r.jsx)(n.$n,{size:"sm",variant:"secondary",icon:"add",onClick:()=>E(!0),className:"min-h-11 w-full sm:min-h-0 sm:w-auto",children:"Add OpenAI Compatible"})]})}),(0,r.jsx)("div",{className:F.custom&&!K.trim()?"hidden sm:block":"",children:0===el.length&&0===ei.length?(0,r.jsxs)("div",{className:"flex items-center gap-3 rounded-xl border border-dashed border-border bg-surface/45 px-4 py-3 text-text-muted",children:[(0,r.jsx)("span",{"aria-hidden":"true",className:"material-symbols-outlined flex size-9 shrink-0 items-center justify-center rounded-lg bg-surface-2 text-[18px]",children:"add_link"}),(0,r.jsxs)("div",{children:[(0,r.jsx)("p",{className:"text-sm font-medium text-text-main",children:"No custom endpoints yet"}),(0,r.jsx)("p",{className:"mt-0.5 text-xs",children:"Add an OpenAI or Anthropic-compatible endpoint when you need one."})]})]}):(0,r.jsx)("div",{className:"grid grid-cols-1 gap-2.5 sm:grid-cols-2 sm:gap-3 lg:grid-cols-3 xl:grid-cols-4",children:[...el,...ei].map(e=>(0,r.jsx)(k,{providerId:e.id,provider:e,stats:ee(e.id,"apikey"),onToggle:t=>er(e.id,"apikey",t)},e.id))})})]}),en.length>0&&(0,r.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,r.jsx)(N,{icon:"passkey",title:"OAuth Providers",description:"Connect existing provider accounts securely",count:en.length,collapsed:F.oauth&&!K.trim(),onToggle:()=>es("oauth"),children:(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)(b,{}),(0,r.jsxs)("button",{onClick:()=>ea("oauth"),disabled:!!U,className:`flex h-11 w-full items-center justify-center gap-1.5 rounded-xl border px-3 text-xs font-medium transition-colors sm:h-8 sm:w-auto sm:rounded-lg ${"oauth"===U?"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"===U?" animate-spin":""}`,children:"play_arrow"}),"oauth"===U?"Testing...":"Test All"]})]})}),(0,r.jsx)("div",{className:`${F.oauth&&!K.trim()?"hidden sm:grid":"grid"} grid-cols-1 gap-2.5 sm:grid-cols-2 sm:gap-3 lg:grid-cols-3 xl:grid-cols-4`,children:en.map(([e,t])=>(0,r.jsx)(w,{providerId:e,provider:t,stats:ee(e,"oauth"),onToggle:t=>er(e,"oauth",t)},e))})]}),(eo.length>0||ed.length>0)&&(0,r.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,r.jsx)(N,{icon:"savings",title:"Free Tier Providers",description:"Ready-to-use and free-tier routing options",count:eo.length+ed.length,collapsed:F.free&&!K.trim(),onToggle:()=>es("free"),children:(0,r.jsxs)("button",{onClick:()=>ea("free"),disabled:!!U,className:`flex h-11 w-full items-center justify-center gap-1.5 rounded-xl border px-3 text-xs font-medium transition-colors sm:h-8 sm:w-auto sm:rounded-lg ${"free"===U?"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"===U?" animate-spin":""}`,children:"play_arrow"}),"free"===U?"Testing...":"Test All"]})}),(0,r.jsxs)("div",{className:`${F.free&&!K.trim()?"hidden sm:grid":"grid"} grid-cols-1 gap-2.5 sm:grid-cols-2 sm:gap-3 lg:grid-cols-3 xl:grid-cols-4`,children:[eo.map(([e,t])=>{let s=Array.isArray(t?.authModes)&&t.authModes.includes("apikey");return(0,r.jsx)(w,{providerId:e,provider:t,stats:ee(e,s?["oauth","apikey"]:"oauth"),onToggle:t=>er(e,s?"apikey":"oauth",t)},e)}),ed.map(([e,t])=>(0,r.jsx)(k,{providerId:e,provider:t,stats:ee(e,"apikey"),onToggle:t=>er(e,"apikey",t)},e))]})]}),ec.length>0&&(0,r.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,r.jsx)(N,{icon:"key",title:"API Key Providers",description:"Bring your own provider credentials",count:ec.length,collapsed:F.apikey&&!K.trim(),onToggle:()=>es("apikey"),children:(0,r.jsxs)("button",{onClick:()=>ea("apikey"),disabled:!!U,className:`flex h-11 w-full items-center justify-center gap-1.5 rounded-xl border px-3 text-xs font-medium transition-colors sm:h-8 sm:w-auto sm:rounded-lg ${"apikey"===U?"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"===U?" animate-spin":""}`,children:"play_arrow"}),"apikey"===U?"Testing...":"Test All"]})}),(0,r.jsx)("div",{className:`${F.apikey&&!K.trim()?"hidden sm:grid":"grid"} grid-cols-1 gap-2.5 sm:grid-cols-2 sm:gap-3 lg:grid-cols-3 xl:grid-cols-4`,children:ep.map(([e,t])=>(0,r.jsx)(k,{providerId:e,provider:t,stats:ee(e,"apikey"),onToggle:t=>er(e,"apikey",t)},e))}),ec.length>0&&(0,r.jsx)("div",{className:F.apikey&&!K.trim()?"hidden sm:block":"",children:(0,r.jsx)(n.dK,{currentPage:em,pageSize:S,totalItems:ec.length,onPageChange:$,onPageSizeChange:e=>{I(e),$(1)}})})]}),(0,r.jsx)(C,{isOpen:R,onClose:()=>E(!1),onCreated:e=>{o(t=>[...t,e]),E(!1)}}),(0,r.jsx)(T,{isOpen:P,onClose:()=>O(!1),onCreated:e=>{o(t=>[...t,e]),O(!1)}}),q&&(0,r.jsxs)("div",{className:"fixed inset-0 z-50 flex items-start justify-center px-3 pt-[6vh] sm:pt-[10vh]",onClick:()=>z(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:()=>z(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)(A,{results:q})})]})]})]})}function N({icon:e,title:t,description:s,count:a,collapsed:l,onToggle:i,children:n}){return(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:"flex w-full min-w-0 items-center gap-2.5 sm:w-auto",children:[(0,r.jsxs)("div",{className:"flex min-w-0 flex-1 items-center gap-2.5 sm:flex-none",children:[(0,r.jsx)("span",{"aria-hidden":"true",className:"material-symbols-outlined flex size-8 shrink-0 items-center justify-center rounded-lg bg-primary/[0.08] text-[17px] text-primary",children:e}),(0,r.jsxs)("div",{className:"min-w-0",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("h2",{className:"truncate text-lg font-semibold leading-tight",children:t}),(0,r.jsx)("span",{className:"rounded-full bg-surface-2 px-2 py-0.5 text-[10px] font-semibold tabular-nums text-text-muted",children:a})]}),(0,r.jsx)("p",{className:"mt-0.5 truncate text-[11px] text-text-muted sm:text-xs",children:s})]})]}),(0,r.jsx)("button",{type:"button",onClick:i,className:"flex size-11 shrink-0 items-center justify-center rounded-xl border border-border text-text-muted transition-colors hover:border-primary/30 hover:text-primary sm:hidden","aria-expanded":!l,"aria-label":`${l?"Expand":"Collapse"} ${t}`,children:(0,r.jsx)("span",{className:"material-symbols-outlined text-[20px]",children:l?"expand_more":"expand_less"})})]}),n&&(0,r.jsx)("div",{className:l?"hidden sm:block":"block",children:n})]})}function w({providerId:e,provider:t,stats:s,onToggle:a}){let{connected:l,error:i,errorCode:d,allDisabled:c}=s,m=!!t.noAuth;return(0,r.jsx)(p(),{href:`/dashboard/providers/${e}`,className:"group min-w-0",children:(0,r.jsx)(n.Zp,{padding:"none",className:`relative h-[76px] min-h-[76px] cursor-pointer overflow-hidden transition-[border-color,box-shadow,opacity] group-hover:border-primary/30 group-hover:shadow-[0_10px_26px_-22px_rgba(229,106,74,0.55)] sm:h-[78px] sm:min-h-[78px] ${c?"opacity-55":""}`,children:(0,r.jsxs)("div",{className:"flex h-full min-w-0 items-center justify-between gap-2.5 p-3",children:[(0,r.jsxs)("div",{className:"flex min-w-0 items-center gap-2.5",children:[(0,r.jsx)("div",{className:"flex size-9 shrink-0 items-center justify-center rounded-lg ring-1 ring-black/[0.04] dark:ring-white/[0.06]",style:{backgroundColor:`${t.color?.length>7?t.color:t.color+"15"}`},children:(0,r.jsx)(o.A,{src:`/providers/${t.id}.png`,alt:"",size:28,className:"max-h-7 max-w-7 rounded-md object-contain",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 text-sm font-semibold text-text-main",children:t.name}),(0,r.jsx)("div",{className:"mt-1 flex min-w-0 items-center overflow-hidden whitespace-nowrap",children:c?(0,r.jsxs)("span",{className:"inline-flex items-center gap-1 text-[11px] text-text-muted",children:[(0,r.jsx)("span",{"aria-hidden":"true",className:"material-symbols-outlined text-[13px]",children:"pause_circle"}),"Disabled"]}):m?(0,r.jsxs)("span",{className:"inline-flex items-center gap-1.5 text-[11px] font-medium text-success",children:[(0,r.jsx)("span",{"aria-hidden":"true",className:"size-1.5 rounded-full bg-success"}),"Ready"]}):g(l,i,d)})]})]}),(0,r.jsxs)("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(),a(!!c)},children:(0,r.jsx)(n.lM,{size:"sm",touchTarget:!0,checked:!c,onChange:()=>{},title:c?"Enable provider":"Disable provider"})}),(0,r.jsx)("span",{"aria-hidden":"true",className:"material-symbols-outlined text-[17px] text-text-subtle transition-[transform,color] group-hover:translate-x-0.5 group-hover:text-primary",children:"chevron_right"})]})]})})})}function k({providerId:e,provider:t,stats:s,onToggle:a}){let{connected:l,error:i,errorCode:d,allDisabled:m}=s,x=e.startsWith(c.JH),u=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:"none",className:`relative h-[76px] min-h-[76px] cursor-pointer overflow-hidden transition-[border-color,box-shadow,opacity] group-hover:border-primary/30 group-hover:shadow-[0_10px_26px_-22px_rgba(229,106,74,0.55)] sm:h-[78px] sm:min-h-[78px] ${m?"opacity-55":""}`,children:(0,r.jsxs)("div",{className:"flex h-full min-w-0 items-center justify-between gap-2.5 p-3",children:[(0,r.jsxs)("div",{className:"flex min-w-0 items-center gap-2.5",children:[(0,r.jsx)("div",{className:"flex size-9 shrink-0 items-center justify-center rounded-lg ring-1 ring-black/[0.04] dark:ring-white/[0.06]",style:{backgroundColor:`${t.color?.length>7?t.color:t.color+"15"}`},children:(0,r.jsx)(o.A,{src:"featherless"===t.id?null:x?"responses"===t.apiType?"/providers/oai-r.png":"/providers/oai-cc.png":u?"/providers/anthropic-m.png":`/providers/${t.id}.png`,alt:"",size:28,className:"max-h-7 max-w-7 rounded-md object-contain",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 text-sm font-semibold text-text-main",children:t.name}),(0,r.jsx)("div",{className:"mt-1 flex min-w-0 items-center gap-1.5 overflow-hidden whitespace-nowrap",children:m?(0,r.jsxs)("span",{className:"inline-flex items-center gap-1 text-[11px] text-text-muted",children:[(0,r.jsx)("span",{"aria-hidden":"true",className:"material-symbols-outlined text-[13px]",children:"pause_circle"}),"Disabled"]}):(0,r.jsxs)(r.Fragment,{children:[g(l,i,d),x&&(0,r.jsxs)("span",{className:"text-[10px] text-text-subtle",children:["\xb7 ","responses"===t.apiType?"Responses":"Chat"]}),u&&(0,r.jsx)("span",{className:"text-[10px] text-text-subtle",children:"\xb7 Messages"})]})})]})]}),(0,r.jsxs)("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(),a(!!m)},children:(0,r.jsx)(n.lM,{size:"sm",touchTarget:!0,checked:!m,onChange:()=>{},title:m?"Enable provider":"Disable provider"})}),(0,r.jsx)("span",{"aria-hidden":"true",className:"material-symbols-outlined text-[17px] text-text-subtle transition-[transform,color] group-hover:translate-x-0.5 group-hover:text-primary",children:"chevron_right"})]})]})})})}function C({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)(""),[u,h]=(0,a.useState)(!1),[f,b]=(0,a.useState)(null),[g,v]=(0,a.useState)("");(0,a.useEffect)(()=>{let e="https://api.openai.com/v1";i(t=>t.baseUrl&&t.baseUrl!==e?t:{...t,baseUrl:e})},[l.apiType]);let y=async()=>{if(l.name.trim()&&l.prefix.trim()&&l.baseUrl.trim()){d(!0),v("");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().catch(()=>({}));e.ok?(s(t.node),i({name:"",prefix:"",apiType:"chat",baseUrl:"https://api.openai.com/v1"}),m(""),b(null)):v(t?.error||`Failed to create node (HTTP ${e.status})`)}catch(e){console.log("Error creating OpenAI Compatible node:",e),v("Network error — could not create the node")}finally{d(!1)}}},j=async()=>{h(!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();b(t)}catch{b({valid:!1,error:"Network error"})}finally{h(!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."}),g&&(0,r.jsx)("p",{className:"text-sm text-red-500 break-words",children:g}),(0,r.jsxs)("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center",children:[(0,r.jsx)(n.$n,{onClick:j,disabled:!c||u||!l.baseUrl.trim(),variant:"secondary",className:"w-full sm:w-auto",children:u?"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:y,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 T({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)(""),[u,h]=(0,a.useState)(!1),[f,b]=(0,a.useState)(null),[g,v]=(0,a.useState)("");(0,a.useEffect)(()=>{e&&(b(null),m(""),x(""),v(""))},[e]);let y=async()=>{if(l.name.trim()&&l.prefix.trim()&&l.baseUrl.trim()){d(!0),v("");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().catch(()=>({}));e.ok?(s(t.node),i({name:"",prefix:"",baseUrl:"https://api.anthropic.com/v1"}),m(""),b(null)):v(t?.error||`Failed to create node (HTTP ${e.status})`)}catch(e){console.log("Error creating Anthropic Compatible node:",e),v("Network error — could not create the node")}finally{d(!1)}}},j=async()=>{h(!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();b(t)}catch{b({valid:!1,error:"Network error"})}finally{h(!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."}),g&&(0,r.jsx)("p",{className:"text-sm text-red-500 break-words",children:g}),(0,r.jsxs)("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center",children:[(0,r.jsx)(n.$n,{onClick:j,disabled:!c||u||!l.baseUrl.trim(),variant:"secondary",className:"w-full sm:w-auto",children:u?"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:y,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 A({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."})]})}N.propTypes={icon:i().string.isRequired,title:i().string.isRequired,description:i().string.isRequired,count:i().number.isRequired,collapsed:i().bool.isRequired,onToggle:i().func.isRequired,children:i().node},w.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,total:i().number,allDisabled:i().bool}).isRequired,onToggle:i().func},k.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,total:i().number,allDisabled:i().bool}).isRequired,onToggle:i().func},C.propTypes={isOpen:i().bool.isRequired,onClose:i().func.isRequired,onCreated:i().func.isRequired},T.propTypes={isOpen:i().bool.isRequired,onClose:i().func.isRequired,onCreated:i().func.isRequired},A.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}},28915:(e,t,s)=>{"use strict";s.d(t,{x6:()=>r.fetchJson,E2:()=>a,gs:()=>l});var r=s(68211);function a(e){if(!e)return null;let t=e.match(/\b([45]\d{2})\b/);return t?t[1]:"ERR"}function l(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`}},31703:(e,t,s)=>{Promise.resolve().then(s.bind(s,20490))},68211:(e,t,s)=>{"use strict";s.d(t,{fetchJson:()=>a});let r={"Content-Type":"application/json"};async function a(e,t={}){let{body:s,headers:l,...i}=t,n={...i,headers:{...r,...l}};void 0!==s&&"string"!=typeof s?n.body=JSON.stringify(s):void 0!==s&&(n.body=s);let o=await fetch(e,n),d=await o.text(),c=null;if(d)try{c=JSON.parse(d)}catch{let t=Error(`Non-JSON response from ${e} (HTTP ${o.status})`);throw t.status=o.status,t.rawBody=d.slice(0,300),t}if(!o.ok){let e=c&&(c.error?.message||c.error||c.message)||`Request failed (HTTP ${o.status})`,t=Error("string"==typeof e?e:`HTTP ${o.status}`);throw t.status=o.status,t.data=c,t}return c}a.get=(e,t)=>a(e,{...t,method:"GET"}),a.post=(e,t,s)=>a(e,{...s,method:"POST",body:t}),a.put=(e,t,s)=>a(e,{...s,method:"PUT",body:t}),a.patch=(e,t,s)=>a(e,{...s,method:"PATCH",body:t}),a.del=(e,t)=>a(e,{...t,method:"DELETE"})}},e=>{e.O(0,[2574,3862,3745,3339,620,5497,8441,3794,7358],()=>e(e.s=31703)),_N_E=e.O()}]);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[3826],{5498:(e,t,r)=>{Promise.resolve().then(r.bind(r,75095)),Promise.resolve().then(r.bind(r,25086))},75095:(e,t,r)=>{"use strict";r.d(t,{default:()=>$});var a=r(95155),s=r(12115),n=r(57250),l=r(42793);function i(e,t){return t&&0!==t?!e||e<0?100:e>=t?0:Math.round((t-e)/t*100):0}function o(e){if(e?.unlimited===!0)return e?.remainingPercentage!==void 0&&Number.isFinite(Number(e.remainingPercentage))?Math.max(0,Math.min(100,Math.round(Number(e.remainingPercentage)))):100;if(e?.remainingPercentage!==void 0&&Number.isFinite(Number(e.remainingPercentage)))return Math.max(0,Math.min(100,Math.round(Number(e.remainingPercentage))));if(e?.remaining!==void 0&&Number.isFinite(Number(e.remaining))){let t=Number(e.remaining);if(t>=0&&t<=100&&!(e.total>100&&t<=100&&null!=e.used))return e.total>0?i(e.used,e.total):Math.round(t)}return i(e?.used,e?.total)}function d(e,t){if(!t||"object"!=typeof t)return[];let r=[];try{switch(e.toLowerCase()){case"github":t.quotas&&Object.entries(t.quotas).forEach(([e,t])=>{r.push({name:e,used:t.used||0,total:t.total||0,resetAt:t.resetAt||null})});break;case"antigravity":t.quotas&&Object.entries(t.quotas).forEach(([e,t])=>{r.push({name:t.displayName||e,modelKey:e,used:t.used||0,total:t.total||0,resetAt:t.resetAt||null,remainingPercentage:t.remainingPercentage})});break;case"codex":t.quotas&&Object.entries(t.quotas).forEach(([e,t])=>{r.push({name:e,used:t.used||0,total:t.total||0,remaining:t.remaining,resetAt:t.resetAt||null})});break;case"kiro":t.quotas&&Object.entries(t.quotas).forEach(([e,t])=>{r.push({name:e,used:t.used||0,total:t.total||0,resetAt:t.resetAt||null})});break;case"qoder":t.quotas&&Object.entries(t.quotas).forEach(([e,t])=>{("organization"!==e||t&&0!==(Number(t.total)||0))&&r.push({name:"user"===e?"Personal":"organization"===e?"Organization":e,used:t.used||0,total:t.total||0,unit:t.unit,resetAt:t.resetAt||null})});break;case"autoclaw":t.quotas&&Object.entries(t.quotas).forEach(([e,t])=>{r.push({name:"points"===e?"Points":e,used:t.used||0,total:t.total||0,unit:t.unit,resetAt:t.resetAt||null})});break;case"claude":t.message&&!t.quotas?r.push({name:"error",isError:!0,used:0,total:0,resetAt:null,message:t.message}):t.quotas&&Object.entries(t.quotas).forEach(([e,t])=>{r.push({name:e,used:t.used||0,total:t.total||0,resetAt:t.resetAt||null})});break;case"grok-cli":t.quotas&&Object.entries(t.quotas).forEach(([e,t])=>{let a=!0===t.unlimited||!(t.total>0)&&t.remainingPercentage>0;r.push({name:e,used:t.used||0,total:a?0:t.total||0,resetAt:t.resetAt||null,remainingPercentage:null!=t.remainingPercentage?t.remainingPercentage:a?100:void 0,unlimited:a})});break;case"cloudflare-ai":t.quotas&&Object.entries(t.quotas).forEach(([e,t])=>{let a=!0===t.unlimited||!(t.total>0);r.push({name:e,used:t.used||0,total:a?0:t.total||0,resetAt:t.resetAt||null,remainingPercentage:null!=t.remainingPercentage?t.remainingPercentage:100*!!a,unlimited:a})});break;default:t.quotas&&Object.entries(t.quotas).forEach(([e,t])=>{r.push({name:e,used:t.used||0,total:t.total||0,resetAt:t.resetAt||null,...null!=t.remainingPercentage?{remainingPercentage:t.remainingPercentage}:{},...!0===t.unlimited?{unlimited:!0}:{}})})}}catch(t){return console.error(`Error parsing quota data for ${e}:`,t),[]}let a=(0,l.KC)(e);if(a.length>0){let e=new Map(a.map((e,t)=>[e.id,t]));r.sort((t,r)=>{let a=t.modelKey||t.name,s=r.modelKey||r.name;return(e.get(a)??999)-(e.get(s)??999)})}return r}let c=["name","used","total","resetAt","remaining","remainingPercentage","unlimited","message","isError","unit","modelKey"];function u({quotas:e=[],compact:t=!1,sortMode:r="default",showSortLabel:n=!1,paginate:l=!0,totalCount:i}){let[d,m]=(0,s.useState)(1),[x,h]=(0,s.useState)(e);x===e||Array.isArray(x)&&Array.isArray(e)&&x.length===e.length&&x.every((t,r)=>{let a=e[r];return t&&a?c.every(e=>String(t[e]??null)===String(a[e]??null)):t===a})||h(e);let b=(0,s.useMemo)(()=>x.map((e,t)=>({...e,index:t,remaining:o(e)})),[x]),p=(0,s.useMemo)(()=>"remaining-asc"===r?[...b].sort((e,t)=>e.remaining-t.remaining||e.name.localeCompare(t.name)):"remaining-desc"===r?[...b].sort((e,t)=>t.remaining-e.remaining||e.name.localeCompare(t.name)):b,[b,r]),g=l?Math.max(1,Math.ceil(p.length/10)):1;if((0,s.useEffect)(()=>{m(1)},[r,x]),(0,s.useEffect)(()=>{m(e=>Math.min(e,g))},[g]),!e||0===e.length)return null;let f=l?p.slice((d-1)*10,10*d):p,v=0===p.length?0:(d-1)*10+1,y=l?Math.min(10*d,p.length):p.length,k=Number.isFinite(i)?i:p.length,j=t?"py-1 px-1.5":"py-2 px-3",w=t?"text-[11px]":"text-sm",N=t?"text-[11px]":"text-sm",S=t?"text-[10px] leading-tight":"text-xs";return(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,a.jsxs)("div",{className:"text-[10px] text-text-muted",children:[k," quota",k>1?"s":""]}),n&&(0,a.jsx)("div",{className:"rounded-md border border-black/10 bg-black/[0.02] px-2 py-1 text-[10px] text-text-muted dark:border-white/10 dark:bg-white/[0.03]",children:"Sorted by account remaining"})]}),(0,a.jsx)("div",{className:"overflow-x-auto",children:(0,a.jsx)("table",{className:"w-full table-fixed text-left",children:(0,a.jsx)("tbody",{children:f.map(e=>{var r;if(e.isError)return(0,a.jsx)("tr",{className:"border-b border-black/5 dark:border-white/5",children:(0,a.jsx)("td",{colSpan:3,className:`${j}`,children:(0,a.jsxs)("div",{className:"flex items-center gap-1.5 min-w-0",children:[(0,a.jsx)("span",{className:"material-symbols-outlined shrink-0 text-[14px] text-red-500",children:"error"}),(0,a.jsx)("span",{className:`${w} text-red-600 dark:text-red-400 truncate`,children:e.message||"Failed to load quota"})]})})},`error-${e.index}`);let s=(r=e.remaining)>70?{text:"text-green-600 dark:text-green-400",bg:"bg-green-500",bgLight:"bg-green-500/10",emoji:"\uD83D\uDFE2"}:r>=30?{text:"text-yellow-600 dark:text-yellow-400",bg:"bg-yellow-500",bgLight:"bg-yellow-500/10",emoji:"\uD83D\uDFE1"}:{text:"text-red-600 dark:text-red-400",bg:"bg-red-500",bgLight:"bg-red-500/10",emoji:"\uD83D\uDD34"},n=function(e){if(!e)return"-";try{let t="string"==typeof e?new Date(e):e,r=new Date,a=t-r;if(a<=0)return"-";let s=Math.ceil(a/6e4);if(s<60)return`${s}m`;let n=Math.floor(s/60),l=s%60;if(n<24)return`${n}h ${l}m`;let i=Math.floor(n/24);return`${i}d ${n%24}h ${l}m`}catch(e){return"-"}}(e.resetAt),l=function(e){if(!e)return null;try{let t=new Date(e),r=new Date,a=new Date(r.getFullYear(),r.getMonth(),r.getDate()),s=new Date(a);s.setDate(s.getDate()+1);let n="";n=t>=a&&t<s?"Today":t>=s&&t<new Date(s.getTime()+864e5)?"Tomorrow":t.toLocaleDateString("en-US",{month:"short",day:"numeric"});let l=t.toLocaleTimeString("en-US",{hour:"numeric",minute:"2-digit",hour12:!0});return`${n}, ${l}`}catch{return null}}(e.resetAt);return(0,a.jsxs)("tr",{className:"border-b border-black/5 dark:border-white/5 hover:bg-black/[0.02] dark:hover:bg-white/[0.02] transition-colors",children:[(0,a.jsx)("td",{className:`${j} w-[30%]`,children:(0,a.jsxs)("div",{className:"flex items-center gap-1.5 min-w-0",children:[(0,a.jsx)("span",{className:"text-[10px] shrink-0",children:s.emoji}),(0,a.jsx)("span",{className:`${w} font-medium text-text-primary truncate`,children:e.name})]})}),(0,a.jsx)("td",{className:`${j} w-[45%]`,children:(0,a.jsxs)("div",{className:t?"space-y-1":"space-y-1.5",children:[(0,a.jsx)("div",{className:`${t?"h-1":"h-1.5"} rounded-full overflow-hidden border ${s.bgLight} ${0===e.remaining?"border-black/10 dark:border-white/10":"border-transparent"}`,children:(0,a.jsx)("div",{className:`h-full transition-all duration-300 ${s.bg}`,style:{width:`${Math.min(e.remaining,100)}%`}})}),(0,a.jsxs)("div",{className:`flex items-center justify-between ${t?"text-[10px]":"text-xs"}`,children:[(0,a.jsx)("span",{className:"text-text-muted",children:!0!==e.unlimited&&e.total>0?`${e.used.toLocaleString()} / ${e.total.toLocaleString()}`:!0===e.unlimited?"Included / ∞":`${e.used.toLocaleString()} / ∞`}),(0,a.jsx)("span",{className:`font-medium ${s.text}`,children:Number.isFinite(e.remaining)?`${e.remaining}%`:"—"})]})]})}),(0,a.jsx)("td",{className:`${j} w-[25%]`,children:"-"!==n||l?t?(0,a.jsx)("div",{className:`${N} text-text-primary font-medium truncate`,title:l||"",children:"-"!==n?`in ${n}`:l}):(0,a.jsxs)("div",{className:"space-y-0.5",children:["-"!==n&&(0,a.jsxs)("div",{className:`${N} text-text-primary font-medium`,children:["in ",n]}),l&&(0,a.jsx)("div",{className:`${S} text-text-muted`,children:l})]}):(0,a.jsx)("div",{className:`${N} text-text-muted italic`,children:"N/A"})})]},`${e.name}-${e.index}`)})})})}),g>1&&(0,a.jsxs)("div",{className:"rounded-md border border-black/10 bg-black/[0.02] px-2 py-1.5 dark:border-white/10 dark:bg-white/[0.03]",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between gap-2 text-[10px] text-text-muted",children:[(0,a.jsxs)("span",{children:["Showing ",v,"-",y," of ",p.length]}),(0,a.jsxs)("span",{children:["Page ",d," / ",g]})]}),(0,a.jsxs)("div",{className:"mt-1.5 flex items-center justify-end gap-1",children:[(0,a.jsx)("button",{type:"button",onClick:()=>m(e=>Math.max(1,e-1)),disabled:1===d,className:"flex h-11 items-center rounded-lg border border-black/10 px-3 text-xs text-text-primary transition-colors hover:bg-black/5 disabled:cursor-not-allowed disabled:opacity-40 dark:border-white/10 dark:hover:bg-white/5 sm:h-7 sm:rounded-md sm:px-2 sm:text-[10px]",children:"Prev"}),(0,a.jsx)("button",{type:"button",onClick:()=>m(e=>Math.min(g,e+1)),disabled:d===g,className:"flex h-11 items-center rounded-lg border border-black/10 px-3 text-xs text-text-primary transition-colors hover:bg-black/5 disabled:cursor-not-allowed disabled:opacity-40 dark:border-white/10 dark:hover:bg-white/5 sm:h-7 sm:rounded-md sm:px-2 sm:text-[10px]",children:"Next"})]})]})]})}var m=r(98542),x=r(84588),h=r(35497),b=r(52679);function p(e){let t=e=>"string"==typeof e&&/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e);return t(e.email)?e.email:(t(e.name),e.name)}function g(e,t){let r=t[e.id]?.quotas?.[0];return r&&"number"==typeof r.remaining?r.remaining:1/0}function f(e){return b.Q2[e]?.name||e}function v(e){let t={};return e.forEach(e=>{t[e.id]=!0}),t}function y(e,t){let r=new Set(t.map(e=>e.id));return Object.fromEntries(Object.entries(e).filter(([e])=>r.has(e)))}async function k(e,t){return await e(t)}let j="quotaAutoRefresh",w=[{value:"all",label:"All accounts"},{value:"active",label:"Active"},{value:"inactive",label:"Turned off"}],N=[{value:"single",label:"Satuan",icon:"account_circle"},{value:"bulk",label:"Bulk",icon:"stacks"}],S=[{value:"default",label:"Default quota order"},{value:"remaining-asc",label:"% quota: low to high"},{value:"remaining-desc",label:"% quota: high to low"}],C=[10,20,50,100];function $(){let[e,t]=(0,s.useState)([]),[r,l]=(0,s.useState)({}),[c,$]=(0,s.useState)({}),[A,P]=(0,s.useState)({}),[q,E]=(0,s.useState)(!0),[M,T]=(0,s.useState)(null),[F,z]=(0,s.useState)(!1),[D,_]=(0,s.useState)(!1),[O,L]=(0,s.useState)(60),[I,R]=(0,s.useState)(!0),[U,H]=(0,s.useState)(null),[K,B]=(0,s.useState)(null),[J,Q]=(0,s.useState)(null),[W,Y]=(0,s.useState)(null),[G,V]=(0,s.useState)(!1),[X,Z]=(0,s.useState)(null),[ee,et]=(0,s.useState)([]),[er,ea]=(0,s.useState)("all"),[es,en]=(0,s.useState)([]),[el,ei]=(0,s.useState)("single"),[eo,ed]=(0,s.useState)("all"),[ec,eu]=(0,s.useState)("default"),[em,ex]=(0,s.useState)(!1),[eh,eb]=(0,s.useState)(!1),[ep,eg]=(0,s.useState)(!1),[ef,ev]=(0,s.useState)({}),[ey,ek]=(0,s.useState)(!1),[ej,ew]=(0,s.useState)({}),[eN,eS]=(0,s.useState)({}),[eC,e$]=(0,s.useState)({}),[eA,eP]=(0,s.useState)(1),[eq,eE]=(0,s.useState)(20),[eM,eT]=(0,s.useState)(String(20)),[eF,ez]=(0,s.useState)({page:1,pageSize:20,total:0,totalPages:1}),[eD,e_]=(0,s.useState)({eligibleConnections:0,providerFilteredConnections:0}),eO=(0,s.useRef)(null),eL=(0,s.useRef)(null),eI=(0,s.useRef)(0),eR=(0,s.useCallback)(async(e=eA)=>{let r=++eI.current;try{var a,s;let n=new URLSearchParams({page:String(e),pageSize:String(eq),accountStatus:eo,sort:"priority"});"all"!==er&&n.set("provider",er);let l=await fetch(`/api/providers/client?${n.toString()}`);if(!l.ok){let e=await l.json().catch(()=>({}));throw Error(e.error||`Failed to fetch connections (HTTP ${l.status})`)}let i=await l.json();if(r!==eI.current)return[];let o=i.connections||[],d=(a=i.pagination,a||{page:1,pageSize:eq,total:0,totalPages:1}),c=function(e,t=0){return e||{eligibleConnections:t,providerFilteredConnections:t}}(i.totals,o.length);return t(o),en(i.providerOptions||[]),ez(d),e_(c),eP((s=i.pagination,s?.page||e)),H(null),o}catch(e){if(console.error("Error fetching connections:",e),r!==eI.current)return[];return t([]),en([]),ez({page:1,pageSize:eq,total:0,totalPages:1}),e_({eligibleConnections:0,providerFilteredConnections:0}),H(e.message||"Failed to fetch connections"),[]}},[eo,eA,eq,er]),eU=(0,s.useCallback)(async(e,t,r=!1)=>{$(t=>({...t,[e]:!0})),P(t=>({...t,[e]:null}));try{let a=await fetch(`/api/usage/${e}${r?"?refresh=1":""}`);if(!a.ok){let r=(await a.json().catch(()=>({}))).error||a.statusText;if(404===a.status)return void console.warn(`[ProviderLimits] Connection not found for ${t}, skipping`);if(401===a.status){console.warn(`[ProviderLimits] Auth error for ${t}:`,r);let a={quotas:[],message:r};l(t=>({...t,[e]:a}));return}throw Error(`HTTP ${a.status}: ${r}`)}let s=await a.json(),n={quotas:d(t,s),plan:s.plan||null,message:s.message||null,raw:s};l(t=>({...t,[e]:n}))}catch(r){console.error(`[ProviderLimits] Error fetching quota for ${t} (${e}):`,r),P(t=>({...t,[e]:r.message||"Failed to fetch quota"}))}finally{$(t=>({...t,[e]:!1}))}},[]),eH=(0,s.useCallback)(async(e,t)=>{await eU(e,t,!0),T(new Date)},[eU]),eK=(0,s.useCallback)(async(e,t=!1)=>{if(e&&"all"!==e){eS(t=>({...t,[e]:!0})),e$(t=>({...t,[e]:!1}));try{let r=`/api/usage/aggregate?provider=${encodeURIComponent(e)}${t?"&refresh=1":""}`,a=await fetch(r);if(!a.ok)throw Error("Failed to fetch aggregate");let s=await a.json(),n=d(e,s);ew(t=>({...t,[e]:{quotas:n,plan:s.plan||null,accountCount:s.accountCount||0,accountsWithQuota:s.accountsWithQuota||0,deadCount:s.deadCount||0}}))}catch(t){console.error(`[ProviderLimits] Aggregate fetch error for ${e}:`,t),e$(t=>({...t,[e]:!0}))}finally{eS(t=>({...t,[e]:!1}))}}},[]),eB=(0,s.useCallback)(async(e,t)=>{if("bulk"===el&&t){await eK(t,!0),T(new Date);return}e?.length&&($(t=>({...t,...Object.fromEntries(e.map(e=>[e,!0]))})),await Promise.all(e.map(e=>eU(e,t,!0))),T(new Date))},[eU,el,eK]),eJ=(0,s.useCallback)(async e=>{if(confirm("Delete this connection?")){Q(e),B(null);try{let t=await fetch(`/api/providers/${e}`,{method:"DELETE"});if(!t.ok){let e=await t.json().catch(()=>({}));throw Error(e.error||`HTTP ${t.status}`)}l(t=>{let r={...t};return delete r[e],r}),$(t=>{let r={...t};return delete r[e],r}),P(t=>{let r={...t};return delete r[e],r}),await k(eR,eA)}catch(e){console.error("Error deleting connection:",e),B({type:"error",message:e.message||"Failed to delete connection"})}finally{Q(null)}}},[eR,eA]),eQ=(0,s.useCallback)(async(e,t)=>{Y(e),B(null);try{let r=await fetch(`/api/providers/${e}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({isActive:t})});if(!r.ok){let e=await r.json().catch(()=>({}));throw Error(e.error||`HTTP ${r.status}`)}await k(eR,eA)}catch(e){console.error("Error updating connection status:",e),await k(eR,eA),B({type:"error",message:e.message||"Failed to update connection status"})}finally{Y(null)}},[eR,eA]),eW=(0,s.useCallback)(async e=>{if(!X?.id)return;let t=X.id,r=X.provider;B(null);try{let a=await fetch(`/api/providers/${t}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(!a.ok){let e=await a.json().catch(()=>({}));throw Error(e.error||`HTTP ${a.status}`)}await eR(),V(!1),Z(null),b.wb.includes(r)&&await eU(t,r)}catch(e){console.error("Error saving connection:",e),B({type:"error",message:e.message||"Failed to save connection"})}},[X,eR,eU]);(0,s.useEffect)(()=>{let e=!1;return fetch("/api/proxy-pools?isActive=true",{cache:"no-store"}).then(e=>e.json()).then(t=>{!e&&t?.proxyPools&&et(t.proxyPools)}).catch(()=>{}),()=>{e=!0}},[]);let eY=(0,s.useCallback)(async()=>{if(!D){_(!0),L(60);try{let e=await eR(eA);if($(v(e)),P(t=>y(t,e)),l(t=>y(t,e)),await Promise.all(e.map(e=>eU(e.id,e.provider,!0))),"bulk"===el){let e="all"!==er?[er]:es.map(e=>e.value||e).filter(e=>"all"!==e);await Promise.all(e.map(e=>eK(e,!0)))}T(new Date)}catch(e){console.error("Error refreshing all providers:",e)}finally{_(!1)}}},[D,eR,eU,eA,el,er,es,eK]);(0,s.useEffect)(()=>{(async()=>{R(!0);let e=await eR(eA);R(!1),$(v(e)),P(t=>y(t,e)),l(t=>y(t,e)),await Promise.all(e.map(e=>eU(e.id,e.provider))),T(new Date)})()},[eR,eU,eA]),(0,s.useEffect)(()=>{"bulk"!==el||("all"!==er?[er]:es.map(e=>e.value||e).filter(e=>"all"!==e)).forEach(e=>eK(e))},[el,er,es,eK]),(0,s.useEffect)(()=>{let e=window.localStorage.getItem(j);E(null===e||"true"===e),z(!0)},[]),(0,s.useEffect)(()=>{F&&window.localStorage.setItem(j,String(q))},[q,F]),(0,s.useEffect)(()=>{if(!F||!q){eO.current&&(clearInterval(eO.current),eO.current=null),eL.current&&(clearInterval(eL.current),eL.current=null);return}if(!document.hidden)return eO.current=setInterval(()=>{eY()},6e4),eL.current=setInterval(()=>{L(e=>e<=1?60:e-1)},1e3),()=>{eO.current&&(clearInterval(eO.current),eO.current=null),eL.current&&(clearInterval(eL.current),eL.current=null)}},[q,eY,F]),(0,s.useEffect)(()=>{let e=()=>{document.hidden?(eO.current&&(clearInterval(eO.current),eO.current=null),eL.current&&(clearInterval(eL.current),eL.current=null)):q&&F&&!eO.current&&(eO.current=setInterval(eY,6e4),eL.current=setInterval(()=>{L(e=>e<=1?60:e-1)},1e3))};return document.addEventListener("visibilitychange",e),()=>{document.removeEventListener("visibilitychange",e)}},[q,eY,F]);let eG=(0,s.useMemo)(()=>(function(e,t,r,a,s){if("codex"===a&&"default"!==s)return[...e].sort((e,r)=>{let a=g(e,t),n=g(r,t),l="remaining-asc"===s?a-n:n-a;return 0!==l?l:(p(e)||"").localeCompare(p(r)||"")});if(!r)return e;let n=e=>{let r=(t[e.id]?.quotas||[]).map(e=>e.resetAt?new Date(e.resetAt).getTime():1/0).filter(e=>Number.isFinite(e));return r.length>0?Math.min(...r):1/0};return[...e].sort((e,t)=>{let r=n(e)-n(t);return 0!==r?r:(e.provider||"").localeCompare(t.provider||"")||(p(e)||"").localeCompare(p(t)||"")})})(e,r,em,er,ec),[e,r,em,er,ec]),eV=(0,s.useMemo)(()=>{let e;return e=new Map,eG.forEach(t=>{t.provider&&(e.has(t.provider)||e.set(t.provider,[]),e.get(t.provider).push(t))}),[...e.entries()].map(([e,t])=>(function(e,t,r,a,s){if(!t.length)return null;let n=[],l=[],i=null,o=!1;return t.forEach(e=>{let t=r[e.id];Array.isArray(t?.quotas)&&n.push(...t.quotas),t?.message&&!i&&(i=t.message),s[e.id]&&l.push(s[e.id]),a[e.id]&&(o=!0)}),{id:`${e}-aggregate`,provider:e,name:f(e),email:`${t.length} accounts`,isActive:t.some(e=>e.isActive??!0),isAggregate:!0,quota:{quotas:function(e=[]){let t=new Map;return e.forEach(e=>{if(!e?.name)return;let r=t.get(e.name)||{name:e.name,used:0,total:0,resetAt:e.resetAt||null,remainingPercentage:null,unlimited:!1,_pctSum:0,_pctCount:0};r.used+=Number(e.used)||0,r.total+=Number(e.total)||0,!0===e.unlimited&&(r.unlimited=!0),null!=e.remainingPercentage&&Number.isFinite(Number(e.remainingPercentage))&&(r._pctSum+=Number(e.remainingPercentage),r._pctCount+=1),e.resetAt&&(!r.resetAt||new Date(e.resetAt).getTime()<new Date(r.resetAt).getTime())&&(r.resetAt=e.resetAt),t.set(e.name,r)}),[...t.values()].map(e=>{let{_pctSum:t,_pctCount:r,...a}=e;return a.unlimited?(a.remainingPercentage=100,a.total=0):a.total>0?a.remainingPercentage=(a.total-a.used)/a.total*100:r>0?a.remainingPercentage=t/r:a.remainingPercentage=0,a})}(n),message:0===n.length&&i||null},isLoading:o,error:!n.length&&l.length>0?l[0]:null,connectionIds:t.map(e=>e.id)}})(e,t,r,c,A)).filter(Boolean)},[eG,r,c,A]),eX=(0,s.useMemo)(()=>Object.keys(ej).length?eV.map(e=>{let t=ej[e.provider];return t&&t.quotas?.length?{...e,email:`${t.accountCount||e.connectionIds?.length||0} accounts`,quota:{...e.quota,quotas:t.quotas,message:null},isLoading:eN[e.provider]||!1}:e}):eV,[eV,ej,eN]),eZ=(0,s.useMemo)(()=>"bulk"===el?eX:eG,[el,eX,eG]),e0=e=>{let t=r[e.id]?.quotas;return!!t?.length&&t.some(e=>!!e.total&&!(e.total<=0)&&5>=i(e.used,e.total))},e1=(0,s.useCallback)(async(e,t)=>{if(e.length&&!ey){ek(!0),B(null);try{let r=(await Promise.all(e.map(e=>fetch(`/api/providers/${e}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({isActive:t})})))).filter(e=>!e.ok).length;await k(eR,eA),r>0&&B({type:"error",message:`Failed to update ${r} of ${e.length} connections`})}catch(e){console.error("Error bulk toggling connections:",e),await k(eR,eA),B({type:"error",message:e.message||"Failed to update connections"})}finally{ek(!1)}}},[ey,eR,eA]),e5="all"===er?"All providers":er,e2=eD.eligibleConnections>0,e3=(0,s.useCallback)(async()=>{R(!0);let e=await eR(eA);R(!1),e.length&&($(v(e)),l(t=>y(t,e)),await Promise.all(e.map(e=>eU(e.id,e.provider))),T(new Date))},[eR,eU,eA]),e4=eZ.length>0,e8=eD.eligibleConnections?eD.providerFilteredConnections?{icon:"filter_alt_off",title:"No Accounts On This Page",description:"Try moving to another page or refreshing the current filters."}:{icon:"filter_alt_off",title:"No Accounts Match Current Filters",description:"all"===er?"Try changing the account status filter to see more quota trackers.":`No ${"inactive"===eo?"turned off":"active"===eo?"active":"matching"} accounts found for ${er}.`}:{icon:"cloud_off",title:"No Providers Connected",description:"Connect to providers with OAuth to track your API quota limits and usage."},e6=function(e){var t;let{start:r,end:a}=(t=e).total?{start:(t.page-1)*t.pageSize+1,end:Math.min(t.page*t.pageSize,t.total)}:{start:0,end:0};return`Showing ${r}-${a} of ${e.total}`}(eF),e7=!C.includes(eq);return I||e2?(0,a.jsxs)("div",{className:"space-y-6",children:[(0,a.jsx)("div",{className:"flex justify-end",children:(0,a.jsxs)("div",{className:"grid w-full grid-cols-[minmax(0,1fr)_minmax(0,1fr)_2.75rem] gap-2 sm:flex sm:w-auto sm:flex-wrap sm:items-center sm:gap-1.5",children:[(0,a.jsxs)("div",{className:"relative min-w-0",children:[(0,a.jsxs)("button",{type:"button",onClick:()=>eb(e=>!e),className:"flex h-11 w-full min-w-0 items-center justify-between gap-1 rounded-xl border border-black/10 bg-black/[0.02] px-3 text-xs text-text-primary transition-colors hover:bg-black/5 dark:border-white/10 dark:bg-white/[0.03] dark:hover:bg-white/10 sm:h-8 sm:w-auto sm:rounded-lg sm:px-2","aria-haspopup":"menu","aria-expanded":eh,title:"Filter quota providers",children:[(0,a.jsxs)("span",{className:"flex min-w-0 items-center gap-1.5",children:["all"===er?(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px] text-text-muted",children:"apps"}):(0,a.jsx)(n.A,{src:`/providers/${er}.png`,alt:er,size:18,className:"size-[18px] rounded object-contain",fallbackText:er.slice(0,2).toUpperCase()}),(0,a.jsx)("span",{className:"truncate capitalize",children:e5})]}),(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px] text-text-muted",children:"expand_more"})]}),eh&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("button",{type:"button",className:"fixed inset-0 z-30 bg-transparent","aria-label":"Close provider filter",onClick:()=>eb(!1)}),(0,a.jsxs)("div",{className:"absolute left-0 z-40 mt-2 w-64 overflow-hidden rounded-2xl border border-black/10 bg-surface/95 p-1.5 shadow-xl shadow-black/10 backdrop-blur dark:border-white/10 dark:bg-surface/95 sm:w-72",children:[(0,a.jsxs)("button",{type:"button",onClick:()=>{"all"!==er&&eP(1),ea("all"),eb(!1)},className:`flex w-full items-center gap-3 rounded-xl px-3 py-2.5 text-left text-sm transition-colors ${"all"===er?"bg-primary/10 text-primary":"text-text-primary hover:bg-black/5 dark:hover:bg-white/10"}`,children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[22px]",children:"apps"}),(0,a.jsx)("span",{className:"font-medium",children:"All providers"}),"all"===er&&(0,a.jsx)("span",{className:"material-symbols-outlined ml-auto text-[20px]",children:"check"})]}),(0,a.jsx)("div",{className:"my-1 h-px bg-black/10 dark:bg-white/10"}),(0,a.jsx)("div",{className:"max-h-72 overflow-y-auto pr-1",children:es.map(e=>(0,a.jsxs)("button",{type:"button",onClick:()=>{er!==e&&eP(1),ea(e),eb(!1)},className:`flex w-full items-center gap-3 rounded-xl px-3 py-2.5 text-left text-sm transition-colors ${er===e?"bg-primary/10 text-primary":"text-text-primary hover:bg-black/5 dark:hover:bg-white/10"}`,children:[(0,a.jsx)(n.A,{src:`/providers/${e}.png`,alt:e,size:24,className:"size-6 rounded-md object-contain",fallbackText:e.slice(0,2).toUpperCase()}),(0,a.jsx)("span",{className:"font-medium capitalize",children:e}),er===e&&(0,a.jsx)("span",{className:"material-symbols-outlined ml-auto text-[20px]",children:"check"})]},e))})]})]})]}),(0,a.jsx)("select",{value:eo,onChange:e=>{let t=e.target.value;eo!==t&&eP(1),ed(t)},className:"h-11 min-w-0 rounded-xl border border-black/10 bg-black/[0.02] px-3 text-xs text-text-primary outline-none transition-colors hover:bg-black/5 dark:border-white/10 dark:bg-white/[0.03] dark:hover:bg-white/10 sm:h-8 sm:rounded-lg sm:px-2","aria-label":"Filter accounts by status",children:w.map(e=>(0,a.jsx)("option",{value:e.value,children:e.label},e.value))}),(0,a.jsx)("button",{type:"button",onClick:eY,disabled:D,className:"flex size-11 shrink-0 items-center justify-center rounded-xl border border-black/10 text-xs text-text-primary transition-colors hover:bg-black/5 disabled:opacity-50 dark:border-white/10 dark:hover:bg-white/5 sm:size-8 sm:rounded-lg",title:"Refresh all","aria-label":"Refresh all quotas",children:(0,a.jsx)("span",{className:`material-symbols-outlined text-[18px] sm:text-[14px] ${D?"animate-spin":""}`,children:"refresh"})}),(0,a.jsx)("div",{className:"col-span-2 inline-flex min-h-11 min-w-0 overflow-hidden rounded-xl border border-black/10 bg-black/[0.02] dark:border-white/10 dark:bg-white/[0.03] sm:h-8 sm:min-h-0 sm:rounded-lg",children:N.map(e=>(0,a.jsxs)("button",{type:"button",onClick:()=>ei(e.value),"aria-pressed":el===e.value,className:`flex min-h-11 flex-1 items-center justify-center gap-1.5 px-3 text-xs font-medium transition-colors sm:min-h-0 sm:flex-none sm:justify-start sm:px-2 sm:font-normal ${el===e.value?"bg-primary text-white":"text-text-primary hover:bg-black/5 dark:hover:bg-white/10"}`,title:`Show quota in ${e.label} mode`,children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[17px] sm:text-[14px]",children:e.icon}),(0,a.jsx)("span",{children:e.label})]},e.value))}),(0,a.jsx)("button",{type:"button",onClick:()=>eg(e=>!e),"aria-expanded":ep,className:`flex size-11 items-center justify-center rounded-xl border text-text-primary transition-colors sm:hidden ${ep?"border-primary/30 bg-primary/10 text-primary":"border-black/10 hover:bg-black/5 dark:border-white/10 dark:hover:bg-white/5"}`,"aria-label":ep?"Hide more actions":"Show more actions",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[20px]",children:"tune"})}),(0,a.jsxs)("div",{className:`${ep?"flex":"hidden"} col-span-3 flex-col gap-2 rounded-2xl border border-black/10 bg-black/[0.02] p-3 dark:border-white/10 dark:bg-white/[0.03] sm:contents`,children:["codex"===er&&(0,a.jsx)("select",{value:ec,onChange:e=>eu(e.target.value),className:"h-11 w-full rounded-xl border border-black/10 bg-surface px-3 text-xs text-text-primary outline-none transition-colors hover:bg-black/5 dark:border-white/10 dark:hover:bg-white/10 sm:h-8 sm:w-auto sm:rounded-lg sm:bg-black/[0.02] sm:px-2 dark:sm:bg-white/[0.03]","aria-label":"Sort Codex quotas by remaining",children:S.map(e=>(0,a.jsx)("option",{value:e.value,children:e.label},e.value))}),(0,a.jsxs)("button",{type:"button",onClick:()=>ex(e=>!e),"aria-pressed":em,className:`flex h-11 w-full shrink-0 items-center justify-between gap-2 rounded-xl border px-3 text-xs transition-colors sm:h-8 sm:w-auto sm:justify-start sm:rounded-lg sm:px-2 ${em?"border-amber-500/40 bg-amber-500/10 text-amber-600 dark:text-amber-400":"border-black/10 bg-surface text-text-primary hover:bg-black/5 dark:border-white/10 dark:bg-transparent dark:hover:bg-white/5"}`,title:"Sort accounts by earliest quota reset time",children:[(0,a.jsxs)("span",{className:"flex items-center gap-2",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px] sm:text-[14px]",children:"hourglass_top"}),(0,a.jsx)("span",{children:"Expiring first"})]}),(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px] sm:hidden",children:em?"check_circle":"circle"})]}),(0,a.jsxs)("button",{type:"button",onClick:()=>{e1(eG.filter(e=>(e.isActive??!0)&&e0(e)).map(e=>e.id),!1)},disabled:ey,className:"flex h-11 w-full shrink-0 items-center gap-2 rounded-xl border border-red-500/30 bg-surface px-3 text-xs text-red-500 transition-colors hover:bg-red-500/10 disabled:opacity-50 dark:bg-transparent sm:h-8 sm:w-auto sm:rounded-lg sm:px-2",title:"Disable connections with depleted quota on the current page",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px] sm:text-[14px]",children:"block"}),(0,a.jsx)("span",{children:"Turn off Empty"})]}),(0,a.jsxs)("button",{type:"button",onClick:()=>{e1(eG.filter(e=>!(e.isActive??!0)&&!e0(e)).map(e=>e.id),!0)},disabled:ey,className:"flex h-11 w-full shrink-0 items-center gap-2 rounded-xl border border-emerald-500/30 bg-surface px-3 text-xs text-emerald-600 transition-colors hover:bg-emerald-500/10 disabled:opacity-50 dark:bg-transparent dark:text-emerald-400 sm:h-8 sm:w-auto sm:rounded-lg sm:px-2",title:"Enable connections that still have quota on the current page",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px] sm:text-[14px]",children:"check_circle"}),(0,a.jsx)("span",{children:"Turn on Available"})]}),(0,a.jsxs)("button",{type:"button",onClick:()=>E(e=>!e),className:"flex h-11 w-full shrink-0 items-center justify-between gap-2 rounded-xl border border-black/10 bg-surface px-3 text-xs transition-colors hover:bg-black/5 dark:border-white/10 dark:bg-transparent dark:hover:bg-white/5 sm:h-8 sm:w-auto sm:justify-start sm:rounded-lg sm:px-2",title:q?"Disable auto-refresh":"Enable auto-refresh",children:[(0,a.jsxs)("span",{className:"flex items-center gap-2 text-text-primary",children:[(0,a.jsx)("span",{className:`material-symbols-outlined text-[18px] sm:text-[14px] ${q?"text-primary":"text-text-muted"}`,children:q?"toggle_on":"toggle_off"}),(0,a.jsx)("span",{children:"Auto-refresh"})]}),q&&(0,a.jsxs)("span",{className:"text-[10px] text-text-muted tabular-nums",children:["(",O,"s)"]})]})]})]})}),K&&(0,a.jsxs)("div",{className:"flex items-center justify-between gap-2 rounded-xl border border-red-500/20 bg-red-500/10 px-3 py-2 text-xs text-red-700 dark:text-red-300",role:"alert",children:[(0,a.jsx)("span",{children:K.message}),(0,a.jsx)("button",{type:"button",onClick:()=>B(null),"aria-label":"Dismiss",className:"shrink-0 text-red-500 hover:text-red-700 dark:hover:text-red-200",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[16px]",children:"close"})})]}),!I&&U&&(0,a.jsxs)("div",{className:"flex items-center justify-between gap-2 rounded-xl border border-red-500/20 bg-red-500/10 px-3 py-2 text-xs text-red-700 dark:text-red-300",role:"alert",children:[(0,a.jsxs)("span",{children:["Failed to refresh providers: ",U]}),(0,a.jsx)("button",{type:"button",onClick:e3,className:"shrink-0 font-medium underline hover:no-underline",children:"Retry"})]}),"bulk"===el&&Object.values(eC).some(Boolean)&&(0,a.jsx)("div",{className:"rounded-xl border border-amber-500/20 bg-amber-500/10 px-3 py-2 text-xs text-amber-700 dark:text-amber-300",role:"status",children:"Couldn't load server-side totals for some providers — bulk cards show data for the current page only."}),e4?(0,a.jsxs)(a.Fragment,{children:[em&&(0,a.jsx)("div",{className:"rounded-xl border border-amber-500/20 bg-amber-500/10 px-3 py-2 text-xs text-amber-700 dark:text-amber-300",children:"Expiring-first currently reorders accounts inside the current page. Cross-page ordering still follows backend pagination."}),(0,a.jsx)("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:eZ.map(e=>{let t=!0===e.isAggregate,s=t?e.quota:r[e.id],l=t?e.isLoading:c[e.id],i=t?e.error:A[e.id],d=s?.quotas||[],h=!0===ef[e.id],b=h?d:function(e,t=3){return e.map((e,t)=>({quota:e,index:t})).sort((e,t)=>{let r=o(e.quota)-o(t.quota);if(0!==r)return r;let a=e.quota.resetAt?new Date(e.quota.resetAt).getTime():1/0,s=t.quota.resetAt?new Date(t.quota.resetAt).getTime():1/0;return a!==s?a-s:e.index-t.index}).slice(0,t).map(({quota:e})=>e)}(d),g=!1===e.isActive,v=!t&&(J===e.id||W===e.id);return(0,a.jsxs)(x.default,{padding:"none",className:`min-w-0 ${g?"opacity-60":""}`,children:[(0,a.jsx)("div",{className:"border-b border-black/10 px-3 py-2 dark:border-white/10",children:(0,a.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2 min-w-0",children:[(0,a.jsx)("div",{className:"w-8 h-8 shrink-0 rounded-md flex items-center justify-center overflow-hidden",children:(0,a.jsx)(n.A,{src:`/providers/${e.provider}.png`,alt:e.provider,size:32,className:"object-contain",fallbackText:e.provider?.slice(0,2).toUpperCase()||"PR"})}),(0,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsx)("h3",{className:"text-sm font-semibold text-text-primary capitalize truncate",children:e.name||f(e.provider)}),p(e)?(0,a.jsx)("p",{className:"text-xs text-text-muted truncate",children:p(e)}):null]})]}),(0,a.jsxs)("div",{className:"flex shrink-0 items-center gap-0.5 sm:gap-1",children:[(0,a.jsx)("button",{type:"button",onClick:()=>t?eB(e.connectionIds,e.provider):eH(e.id,e.provider),disabled:l||v,"aria-label":"Refresh quota",className:"flex size-11 items-center justify-center rounded-xl transition-colors hover:bg-black/5 disabled:opacity-50 dark:hover:bg-white/5 sm:size-8 sm:rounded-lg",title:"Refresh quota",children:(0,a.jsx)("span",{className:`material-symbols-outlined text-[18px] text-text-muted ${l?"animate-spin":""}`,children:"refresh"})}),!t&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("button",{type:"button",onClick:()=>{Z(e),V(!0)},disabled:v,"aria-label":"Edit connection",className:"flex size-11 items-center justify-center rounded-xl text-text-muted transition-colors hover:bg-black/5 hover:text-primary disabled:opacity-50 dark:hover:bg-white/5 sm:size-8 sm:rounded-lg",title:"Edit connection",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:"edit"})}),(0,a.jsx)("button",{type:"button",onClick:()=>eJ(e.id),disabled:v,"aria-label":"Delete connection",className:"flex size-11 items-center justify-center rounded-xl text-red-500 transition-colors hover:bg-red-500/10 disabled:opacity-50 sm:size-8 sm:rounded-lg",title:"Delete connection",children:(0,a.jsx)("span",{className:`material-symbols-outlined text-[18px] ${J===e.id?"animate-pulse":""}`,children:"delete"})}),(0,a.jsx)("div",{className:"inline-flex size-11 items-center justify-center sm:h-8 sm:w-auto sm:pl-0.5",title:e.isActive??!0?"Disable connection":"Enable connection",children:(0,a.jsx)(m.default,{size:"sm",touchTarget:!0,checked:e.isActive??!0,disabled:v,onChange:t=>eQ(e.id,t)})})]})]})]})}),(0,a.jsx)("div",{className:"px-2 py-1.5",children:l?(0,a.jsx)("div",{className:"text-center py-5 text-text-muted",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[28px] animate-spin",children:"progress_activity"})}):i?(0,a.jsxs)("div",{className:"text-center py-5",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[28px] text-red-500",children:"error"}),(0,a.jsx)("p",{className:"mt-1.5 text-xs text-text-muted",children:i})]}):d.length>0?(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsxs)("div",{className:"sm:hidden",children:[(0,a.jsx)(u,{quotas:b,totalCount:d.length,paginate:!1,compact:!0,sortMode:"default",showSortLabel:"codex"===e.provider&&"default"!==ec}),d.length>3&&(0,a.jsxs)("button",{type:"button",onClick:()=>ev(t=>({...t,[e.id]:!h})),className:"mt-2 flex h-11 w-full items-center justify-center gap-1.5 rounded-xl border border-black/10 bg-black/[0.02] text-xs font-medium text-text-primary transition-colors hover:bg-black/5 dark:border-white/10 dark:bg-white/[0.03] dark:hover:bg-white/5","aria-expanded":h,children:[(0,a.jsx)("span",{children:h?"Show less":`Show ${d.length-b.length} more`}),(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:h?"expand_less":"expand_more"})]})]}),(0,a.jsx)("div",{className:"hidden sm:block",children:(0,a.jsx)(u,{quotas:d,compact:!0,sortMode:"default",showSortLabel:"codex"===e.provider&&"default"!==ec})}),s?.message?(0,a.jsx)("p",{className:"px-1 text-[10px] text-text-muted",children:s.message}):null]}):s?.message?(0,a.jsx)("div",{className:"text-center py-5",children:(0,a.jsx)("p",{className:"text-xs text-text-muted",children:s.message})}):(0,a.jsx)("div",{className:"text-center py-5 text-text-muted",children:(0,a.jsx)("p",{className:"text-xs",children:"No quota data available"})})})]},e.id)})}),(0,a.jsx)("div",{className:"rounded-xl border border-black/10 bg-black/[0.02] px-3 py-2 dark:border-white/10 dark:bg-white/[0.03]",children:(0,a.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[(0,a.jsx)("span",{className:"text-xs text-text-muted",children:e6}),(0,a.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,a.jsxs)("select",{value:e7?"custom":String(eq),onChange:e=>{let t=e.target.value;if("custom"===t)return;let r=Number.parseInt(t,10);Number.isFinite(r)&&(eP(1),eE(r),eT(String(r)))},className:"h-11 rounded-xl border border-black/10 bg-black/[0.02] px-3 text-xs text-text-primary outline-none transition-colors hover:bg-black/5 dark:border-white/10 dark:bg-white/[0.03] dark:hover:bg-white/10 sm:h-8 sm:rounded-lg sm:px-2","aria-label":"Accounts per page",children:[C.map(e=>(0,a.jsxs)("option",{value:String(e),children:[e," / page"]},e)),(0,a.jsx)("option",{value:"custom",children:"Custom"})]}),(0,a.jsx)("input",{type:"number",min:"1",max:String(500),inputMode:"numeric",value:eM,onChange:e=>eT(e.target.value),onBlur:()=>{let e=Number.parseInt(eM,10);if(!Number.isFinite(e))return void eT(String(eq));let t=Math.min(500,Math.max(1,e));eP(1),eE(t),eT(String(t))},onKeyDown:e=>{if("Enter"!==e.key)return;let t=Number.parseInt(eM,10);if(!Number.isFinite(t))return void eT(String(eq));let r=Math.min(500,Math.max(1,t));eP(1),eE(r),eT(String(r))},className:"h-11 w-24 rounded-xl border border-black/10 bg-black/[0.02] px-3 text-xs text-text-primary outline-none transition-colors hover:bg-black/5 dark:border-white/10 dark:bg-white/[0.03] dark:hover:bg-white/10 sm:h-8 sm:w-20 sm:rounded-lg sm:px-2","aria-label":"Custom accounts per page",placeholder:"Custom"}),(0,a.jsxs)("span",{className:"text-xs text-text-muted",children:["Page ",eF.page," / ",eF.totalPages]})]}),(0,a.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,a.jsx)("button",{type:"button",onClick:()=>eP(1),disabled:eF.page<=1||I||D,className:"flex h-11 items-center rounded-xl border border-black/10 px-3 text-xs text-text-primary transition-colors hover:bg-black/5 disabled:cursor-not-allowed disabled:opacity-40 dark:border-white/10 dark:hover:bg-white/5 sm:h-8 sm:rounded-lg",children:"First Page"}),(0,a.jsx)("button",{type:"button",onClick:()=>eP(e=>Math.max(1,e-1)),disabled:eF.page<=1||I||D,className:"flex size-11 items-center justify-center rounded-xl border border-black/10 text-text-primary transition-colors hover:bg-black/5 disabled:cursor-not-allowed disabled:opacity-40 dark:border-white/10 dark:hover:bg-white/5 sm:size-8 sm:rounded-lg","aria-label":"Previous accounts page",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[16px]",children:"chevron_left"})}),(0,a.jsx)("button",{type:"button",onClick:()=>eP(e=>Math.min(eF.totalPages,e+1)),disabled:eF.page>=eF.totalPages||I||D,className:"flex size-11 items-center justify-center rounded-xl border border-black/10 text-text-primary transition-colors hover:bg-black/5 disabled:cursor-not-allowed disabled:opacity-40 dark:border-white/10 dark:hover:bg-white/5 sm:size-8 sm:rounded-lg","aria-label":"Next accounts page",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[16px]",children:"chevron_right"})}),(0,a.jsx)("button",{type:"button",onClick:()=>eP(eF.totalPages),disabled:eF.page>=eF.totalPages||I||D,className:"flex h-11 items-center rounded-xl border border-black/10 px-3 text-xs text-text-primary transition-colors hover:bg-black/5 disabled:cursor-not-allowed disabled:opacity-40 dark:border-white/10 dark:hover:bg-white/5 sm:h-8 sm:rounded-lg",children:"Last Page"})]})]})})]}):(0,a.jsx)(x.default,{padding:"lg",children:(0,a.jsxs)("div",{className:"text-center py-12",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[64px] text-text-muted opacity-20",children:e8.icon}),(0,a.jsx)("h3",{className:"mt-4 text-lg font-semibold text-text-primary",children:e8.title}),(0,a.jsx)("p",{className:"mt-2 text-sm text-text-muted max-w-md mx-auto",children:e8.description})]})}),(0,a.jsx)(h.wI,{isOpen:G,connection:X,proxyPools:ee,onSave:eW,onClose:()=>{V(!1),Z(null)}})]}):U?(0,a.jsx)(x.default,{padding:"lg",children:(0,a.jsxs)("div",{className:"text-center py-12",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[64px] text-red-500 opacity-30",children:"error"}),(0,a.jsx)("h3",{className:"mt-4 text-lg font-semibold text-text-primary",children:"Failed to Load Providers"}),(0,a.jsx)("p",{className:"mt-2 text-sm text-text-muted max-w-md mx-auto",children:U}),(0,a.jsxs)("button",{type:"button",onClick:e3,className:"mt-4 inline-flex items-center gap-2 rounded-xl border border-black/10 px-4 py-2 text-sm text-text-primary transition-colors hover:bg-black/5 dark:border-white/10 dark:hover:bg-white/5",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:"refresh"}),"Retry"]})]})}):(0,a.jsx)(x.default,{padding:"lg",children:(0,a.jsxs)("div",{className:"text-center py-12",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[64px] text-text-muted opacity-20",children:"cloud_off"}),(0,a.jsx)("h3",{className:"mt-4 text-lg font-semibold text-text-primary",children:"No Providers Connected"}),(0,a.jsx)("p",{className:"mt-2 text-sm text-text-muted max-w-md mx-auto",children:"Connect to providers with OAuth to track your API quota limits and usage."})]})})}}},e=>{e.O(0,[2574,3862,3745,3339,620,5497,8441,3794,7358],()=>e(e.s=5498)),_N_E=e.O()}]);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[410],{13092:(e,t,s)=>{"use strict";s.r(t),s.d(t,{default:()=>d});var r=s(95155),a=s(12115),n=s(73321),i=s(84588);let l={gh:{"gpt-5.3-codex":{input:1.75,output:14,cached:.175,reasoning:14,cache_creation:1.75}}};function c({isOpen:e,onClose:t,onSave:s}){let[n,i]=(0,a.useState)({}),[d,o]=(0,a.useState)(!0),[x,m]=(0,a.useState)(!1);(0,a.useEffect)(()=>{e&&u()},[e]);let u=async()=>{o(!0);try{let e=await fetch("/api/pricing");if(e.ok){let t=await e.json();i(t)}else i(l)}catch(e){console.error("Failed to load pricing:",e),i(l)}finally{o(!1)}},h=async()=>{m(!0);try{let e=await fetch("/api/pricing",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});if(e.ok)s?.(),t();else{let t=await e.json().catch(()=>({}));alert(`Failed to save pricing: ${t?.error||`Server error (${e.status})`}`)}}catch(e){console.error("Failed to save pricing:",e),alert("Failed to save pricing")}finally{m(!1)}},p=async()=>{if(confirm("Reset all pricing to defaults? This cannot be undone."))try{(await fetch("/api/pricing",{method:"DELETE"})).ok&&i(l)}catch(e){console.error("Failed to reset pricing:",e),alert("Failed to reset pricing")}};if(!e)return null;let b=Object.keys(n).sort(),j=["input","output","cached","reasoning","cache_creation"];return(0,r.jsx)("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:(0,r.jsxs)("div",{className:"bg-bg-base border border-border rounded-lg shadow-xl max-w-6xl w-full max-h-[90vh] overflow-hidden flex flex-col",children:[(0,r.jsxs)("div",{className:"p-4 border-b border-border flex items-center justify-between",children:[(0,r.jsx)("h2",{className:"text-xl font-semibold",children:"Pricing Configuration"}),(0,r.jsx)("button",{onClick:t,className:"text-text-muted hover:text-text text-2xl leading-none",children:"\xd7"})]}),(0,r.jsx)("div",{className:"flex-1 overflow-auto p-4",children:d?(0,r.jsx)("div",{className:"text-center py-8 text-text-muted",children:"Loading pricing data..."}):(0,r.jsxs)("div",{className:"space-y-6",children:[(0,r.jsxs)("div",{className:"bg-bg-subtle border border-border rounded-lg p-3 text-sm",children:[(0,r.jsx)("p",{className:"font-medium mb-1",children:"Pricing Rates Format"}),(0,r.jsxs)("p",{className:"text-text-muted",children:["All rates are in ",(0,r.jsx)("strong",{children:"dollars per million tokens"})," ($/1M tokens). Example: Input rate of 2.50 means $2.50 per 1,000,000 input tokens."]})]}),b.map(e=>{let t=Object.keys(n[e]).sort();return(0,r.jsxs)("div",{className:"border border-border rounded-lg overflow-hidden",children:[(0,r.jsx)("div",{className:"bg-bg-subtle px-4 py-2 font-semibold text-sm",children:e.toUpperCase()}),(0,r.jsx)("div",{className:"overflow-x-auto",children:(0,r.jsxs)("table",{className:"w-full text-sm",children:[(0,r.jsx)("thead",{className:"bg-bg-hover text-text-muted uppercase text-xs",children:(0,r.jsxs)("tr",{children:[(0,r.jsx)("th",{className:"px-3 py-2 text-left",children:"Model"}),(0,r.jsx)("th",{className:"px-3 py-2 text-right",children:"Input"}),(0,r.jsx)("th",{className:"px-3 py-2 text-right",children:"Output"}),(0,r.jsx)("th",{className:"px-3 py-2 text-right",children:"Cached"}),(0,r.jsx)("th",{className:"px-3 py-2 text-right",children:"Reasoning"}),(0,r.jsx)("th",{className:"px-3 py-2 text-right",children:"Cache Creation"})]})}),(0,r.jsx)("tbody",{className:"divide-y divide-border",children:t.map(t=>(0,r.jsxs)("tr",{className:"hover:bg-bg-subtle/50",children:[(0,r.jsx)("td",{className:"px-3 py-2 font-medium",children:t}),j.map(s=>(0,r.jsx)("td",{className:"px-3 py-2",children:(0,r.jsx)("input",{type:"number",step:"0.01",min:"0",value:n[e][t][s]||0,onChange:r=>{let a;!isNaN(a=parseFloat(r.target.value))&&!(a<0)&&i(r=>{let n={...r};return n[e]||(n[e]={}),n[e][t]||(n[e][t]={}),n[e][t][s]=a,n})},className:"w-20 px-2 py-1 text-right bg-bg-base border border-border rounded focus:outline-none focus:border-primary"})},s))]},t))})]})})]},e)}),0===b.length&&(0,r.jsx)("div",{className:"text-center py-8 text-text-muted",children:"No pricing data available"})]})}),(0,r.jsxs)("div",{className:"p-4 border-t border-border flex items-center justify-between gap-2",children:[(0,r.jsx)("button",{onClick:p,className:"px-4 py-2 text-sm text-red-500 hover:bg-red-500/10 rounded border border-red-500/20 transition-colors",disabled:x,children:"Reset to Defaults"}),(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsx)("button",{onClick:t,className:"px-4 py-2 text-sm text-text-muted hover:text-text border border-border rounded transition-colors",disabled:x,children:"Cancel"}),(0,r.jsx)("button",{onClick:h,className:"px-4 py-2 text-sm bg-primary text-white rounded hover:bg-primary/90 transition-colors disabled:opacity-50",disabled:x,children:x?"Saving...":"Save Changes"})]})]})]})})}function d(){(0,n.useRouter)();let[e,t]=(0,a.useState)(!1),[s,l]=(0,a.useState)(null),[d,o]=(0,a.useState)(!0);(0,a.useEffect)(()=>{x()},[]);let x=async()=>{o(!0);try{let e=await fetch("/api/pricing");if(e.ok){let t=await e.json();l(t)}}catch(e){console.error("Failed to load pricing:",e)}finally{o(!1)}};return(0,r.jsxs)("div",{className:"max-w-6xl mx-auto p-6 space-y-6",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("h1",{className:"text-3xl font-bold",children:"Pricing Settings"}),(0,r.jsx)("p",{className:"text-text-muted mt-1",children:"Configure pricing rates for cost tracking and calculations"})]}),(0,r.jsx)("button",{onClick:()=>t(!0),className:"px-4 py-2 bg-primary text-white rounded hover:bg-primary/90 transition-colors",children:"Edit Pricing"})]}),(0,r.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[(0,r.jsxs)(i.default,{className:"p-4",children:[(0,r.jsx)("div",{className:"text-text-muted text-sm uppercase font-semibold",children:"Total Models"}),(0,r.jsx)("div",{className:"text-2xl font-bold mt-1",children:d?"...":(()=>{if(!s)return 0;let e=0;for(let t in s)e+=Object.keys(s[t]).length;return e})()})]}),(0,r.jsxs)(i.default,{className:"p-4",children:[(0,r.jsx)("div",{className:"text-text-muted text-sm uppercase font-semibold",children:"Providers"}),(0,r.jsx)("div",{className:"text-2xl font-bold mt-1",children:d?"...":(!s?[]:Object.keys(s).sort()).length})]}),(0,r.jsxs)(i.default,{className:"p-4",children:[(0,r.jsx)("div",{className:"text-text-muted text-sm uppercase font-semibold",children:"Status"}),(0,r.jsx)("div",{className:"text-2xl font-bold mt-1 text-success",children:d?"...":"Active"})]})]}),(0,r.jsxs)(i.default,{className:"p-6",children:[(0,r.jsx)("h2",{className:"text-xl font-semibold mb-4",children:"How Pricing Works"}),(0,r.jsxs)("div",{className:"space-y-3 text-sm text-text-muted",children:[(0,r.jsxs)("p",{children:[(0,r.jsx)("strong",{children:"Cost Calculation:"}),"Costs are calculated based on token usage and pricing rates. Each request's cost is determined by: (input_tokens \xd7 input_rate) + (output_tokens \xd7 output_rate) + (cached_tokens \xd7 cached_rate)"]}),(0,r.jsxs)("p",{children:[(0,r.jsx)("strong",{children:"Pricing Format:"})," All rates are in ",(0,r.jsx)("strong",{children:"dollars per million tokens"})," ($/1M tokens). Example: An input rate of 2.50 means $2.50 per 1,000,000 input tokens."]}),(0,r.jsx)("p",{children:(0,r.jsx)("strong",{children:"Token Types:"})}),(0,r.jsxs)("ul",{className:"list-disc list-inside ml-4 space-y-1",children:[(0,r.jsxs)("li",{children:[(0,r.jsx)("strong",{children:"Input:"})," Standard prompt tokens"]}),(0,r.jsxs)("li",{children:[(0,r.jsx)("strong",{children:"Output:"})," Completion/response tokens"]}),(0,r.jsxs)("li",{children:[(0,r.jsx)("strong",{children:"Cached:"})," Cached input tokens (typically 50% of input rate)"]}),(0,r.jsxs)("li",{children:[(0,r.jsx)("strong",{children:"Reasoning:"})," Special reasoning/thinking tokens (fallback to output rate)"]}),(0,r.jsxs)("li",{children:[(0,r.jsx)("strong",{children:"Cache Creation:"})," Tokens used to create cache entries (fallback to input rate)"]})]}),(0,r.jsxs)("p",{children:[(0,r.jsx)("strong",{children:"Custom Pricing:"})," You can override default pricing for specific models. Reset to defaults anytime to restore standard rates."]})]})]}),(0,r.jsxs)(i.default,{className:"p-6",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between mb-4",children:[(0,r.jsx)("h2",{className:"text-xl font-semibold",children:"Current Pricing Overview"}),(0,r.jsx)("button",{onClick:()=>t(!0),className:"text-primary hover:underline text-sm",children:"View Full Details"})]}),d?(0,r.jsx)("div",{className:"text-center py-4 text-text-muted",children:"Loading pricing data..."}):s?(0,r.jsxs)("div",{className:"space-y-3",children:[Object.keys(s).slice(0,5).map(e=>(0,r.jsxs)("div",{className:"text-sm",children:[(0,r.jsxs)("span",{className:"font-semibold",children:[e.toUpperCase(),":"]})," ",(0,r.jsxs)("span",{className:"text-text-muted",children:[Object.keys(s[e]).length," models"]})]},e)),Object.keys(s).length>5&&(0,r.jsxs)("div",{className:"text-sm text-text-muted",children:["+ ",Object.keys(s).length-5," more providers"]})]}):(0,r.jsx)("div",{className:"text-text-muted",children:"No pricing data available"})]}),e&&(0,r.jsx)(c,{isOpen:e,onClose:()=>t(!1),onSave:()=>{x()}})]})}},31474:(e,t,s)=>{"use strict";function r(...e){return e.filter(Boolean).join(" ").replace(/\s+/g," ").trim()}s.d(t,{cn:()=>r})},73321:(e,t,s)=>{"use strict";var r=s(74645);s.o(r,"notFound")&&s.d(t,{notFound:function(){return r.notFound}}),s.o(r,"useParams")&&s.d(t,{useParams:function(){return r.useParams}}),s.o(r,"usePathname")&&s.d(t,{usePathname:function(){return r.usePathname}}),s.o(r,"useRouter")&&s.d(t,{useRouter:function(){return r.useRouter}}),s.o(r,"useSearchParams")&&s.d(t,{useSearchParams:function(){return r.useSearchParams}})},80477:(e,t,s)=>{Promise.resolve().then(s.bind(s,13092))},84588:(e,t,s)=>{"use strict";s.d(t,{default:()=>n});var r=s(95155),a=s(31474);function n({children:e,title:t,subtitle:s,icon:i,action:l,padding:c="md",hover:d=!1,elev:o=!1,className:x,...m}){return(0,r.jsxs)("div",{className:(0,a.cn)("card-3d border border-border-subtle rounded-[14px] transition-[border-color,box-shadow,transform] duration-200",o&&"card-3d-elev",d&&"hover:-translate-y-0.5 hover:border-brand-500/30 hover:shadow-[var(--shadow-warm)] cursor-pointer",{none:"",xs:"p-3",sm:"p-4",md:"p-6",lg:"p-8"}[c],x),...m,children:[(t||l)&&(0,r.jsxs)("div",{className:"flex items-center justify-between mb-4",children:[(0,r.jsxs)("div",{className:"flex items-center gap-3",children:[i&&(0,r.jsx)("div",{className:"p-2 rounded-[10px] bg-bg text-text-muted",children:(0,r.jsx)("span",{className:"material-symbols-outlined text-[20px]",children:i})}),(0,r.jsxs)("div",{children:[t&&(0,r.jsx)("h3",{className:"text-text-main font-semibold",children:t}),s&&(0,r.jsx)("p",{className:"text-sm text-text-muted",children:s})]})]}),l]}),e]})}n.Section=function({children:e,className:t,...s}){return(0,r.jsx)("div",{className:(0,a.cn)("p-4 rounded-[10px]","bg-bg border border-border-subtle",t),...s,children:e})},n.Row=function({children:e,className:t,...s}){return(0,r.jsx)("div",{className:(0,a.cn)("p-3 -mx-3 px-3 transition-colors","border-b border-border-subtle last:border-b-0","hover:bg-surface-2/50",t),...s,children:e})},n.ListItem=function({children:e,actions:t,className:s,...n}){return(0,r.jsxs)("div",{className:(0,a.cn)("group flex items-center justify-between p-3 -mx-3 px-3","border-b border-border-subtle last:border-b-0","hover:bg-surface-2/50 transition-colors",s),...n,children:[(0,r.jsx)("div",{className:"flex-1 min-w-0",children:e}),t&&(0,r.jsx)("div",{className:"flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity",children:t})]})}}},e=>{e.O(0,[8441,3794,7358],()=>e(e.s=80477)),_N_E=e.O()}]);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[2825],{30906:(e,t,s)=>{Promise.resolve().then(s.bind(s,73314))},73314:(e,t,s)=>{"use strict";s.r(t),s.d(t,{default:()=>N});var a=s(95155),r=s(12115),l=s(73321),n=s(35497),i=s(84588),o=s(92542),d=s(31474);function c({isOpen:e,onClose:t,title:s,children:l,width:n="md",className:i}){let o={sm:"w-[400px]",md:"w-[500px]",lg:"w-[600px]",xl:"w-[800px]",full:"w-full"};return((0,r.useEffect)(()=>{if(!e)return;let t=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{document.body.style.overflow=t}},[e]),(0,r.useEffect)(()=>{let s=s=>{"Escape"===s.key&&e&&t()};return document.addEventListener("keydown",s),()=>document.removeEventListener("keydown",s)},[e,t]),e)?(0,a.jsxs)("div",{className:"fixed inset-0 z-50",children:[(0,a.jsx)("div",{className:"absolute inset-0 bg-black/50 backdrop-blur-[2px] fade-in cursor-pointer",onClick:t,"aria-hidden":"true"}),(0,a.jsxs)("div",{className:(0,d.cn)("absolute right-0 top-0 h-full bg-surface flex flex-col","shadow-[var(--shadow-elev)]","slide-in-right","border-l border-border-subtle",o[n]||o.md,i),children:[(0,a.jsxs)("div",{className:"flex items-center justify-between p-6 border-b border-border-subtle flex-shrink-0",children:[(0,a.jsx)("div",{className:"flex items-center gap-3",children:s&&(0,a.jsx)("h2",{className:"text-lg font-semibold text-text-main",children:s})}),(0,a.jsx)("button",{type:"button",onClick:t,className:"p-1.5 rounded-[10px] text-text-muted hover:bg-surface-2 hover:text-text-main transition-colors",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[20px]",children:"close"})})]}),(0,a.jsx)("div",{className:"flex-1 overflow-y-auto p-6 custom-scrollbar",children:l})]})]}):null}var x=s(50378),m=s(52679);let u=null,p=null;async function h(){if(u&&p)return{providerNameCache:u,providerNodesCache:p};let e=await fetch("/api/provider-nodes"),t=(await e.json()).nodes||[];for(let e of(p={},t))p[e.id]=e.name;return{providerNameCache:u={...m.Q2,...p},providerNodesCache:p}}function f(e,t){if(!e||!t)return e;let s=t[e];if("string"==typeof s)return s;if(s?.name)return s.name;let a=(0,m.zt)(e)||m.Q2[e];return a?.name||e}function b({title:e,children:t,defaultOpen:s=!1,icon:l=null}){let[n,i]=(0,r.useState)(s);return(0,a.jsxs)("div",{className:"border border-black/5 dark:border-white/5 rounded-lg overflow-hidden",children:[(0,a.jsxs)("button",{type:"button",onClick:()=>i(!n),className:"w-full flex items-center justify-between p-3 bg-black/[0.02] dark:bg-white/[0.02] hover:bg-black/[0.04] dark:hover:bg-white/[0.04] transition-colors",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[l&&(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px] text-text-muted",children:l}),(0,a.jsx)("span",{className:"font-semibold text-sm text-text-main",children:e})]}),(0,a.jsx)("span",{className:(0,d.cn)("material-symbols-outlined text-[20px] text-text-muted transition-transform duration-200",n?"rotate-90":""),children:"chevron_right"})]}),n&&(0,a.jsx)("div",{className:"p-4 border-t border-black/5 dark:border-white/5",children:t})]})}function g(e){let t=e?.prompt_tokens||e?.input_tokens||0,s=e?.cached_tokens||e?.cache_read_input_tokens||0;return t<s?s:t}function j(){let[e,t]=(0,r.useState)([]),[s,l]=(0,r.useState)({page:1,pageSize:20,totalItems:0,totalPages:0}),[n,m]=(0,r.useState)(!1),[u,p]=(0,r.useState)(null),[j,v]=(0,r.useState)(!1),[N,w]=(0,r.useState)([]),[k,y]=(0,r.useState)(null),[S,D]=(0,r.useState)({provider:"",startDate:"",endDate:""}),C=(0,r.useRef)({sequence:0,controller:null}),P=(0,r.useCallback)(async()=>{try{let e=await fetch("/api/usage/providers"),t=await e.json();w(t.providers||[]);let s=await h();y(s.providerNameCache)}catch(e){console.error("Failed to fetch providers:",e)}},[]),T=(0,r.useCallback)(async()=>{C.current.controller?.abort();let e=new AbortController,a=C.current.sequence+1;C.current={sequence:a,controller:e},m(!0);try{let r=new URLSearchParams({page:s.page.toString(),pageSize:s.pageSize.toString()});S.provider&&r.append("provider",S.provider),S.startDate&&r.append("startDate",S.startDate),S.endDate&&r.append("endDate",S.endDate);let n=await fetch(`/api/usage/request-details?${r}`,{signal:e.signal}),i=await n.json();if(a!==C.current.sequence)return;t(i.details||[]),l(e=>({...e,...i.pagination}))}catch(e){if(e?.name==="AbortError")return;console.error("Failed to fetch request details:",e)}finally{a===C.current.sequence&&m(!1)}},[s.page,s.pageSize,S]);(0,r.useEffect)(()=>{P()},[P]),(0,r.useEffect)(()=>(T(),()=>{C.current.controller?.abort(),C.current.sequence+=1}),[T]);let _=(e,t)=>{D(s=>({...s,[e]:t})),l(e=>({...e,page:1}))};return(0,a.jsxs)("div",{className:"flex min-w-0 flex-col gap-6",children:[(0,a.jsx)(i.default,{padding:"md",children:(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-4",children:[(0,a.jsxs)("div",{className:"flex min-w-0 flex-col gap-2",children:[(0,a.jsx)("label",{htmlFor:"provider-filter",className:"text-sm font-medium text-text-main",children:"Provider"}),(0,a.jsxs)("select",{id:"provider-filter",value:S.provider,onChange:e=>_("provider",e.target.value),className:(0,d.cn)("h-9 px-3 rounded-lg border border-black/10 dark:border-white/10 bg-surface","text-sm text-text-main focus:outline-none focus:ring-2 focus:ring-primary/20","w-full min-w-0 cursor-pointer"),style:{colorScheme:"auto"},children:[(0,a.jsx)("option",{value:"",children:"All Providers"}),N.map(e=>(0,a.jsx)("option",{value:e.id,children:e.name},e.id))]})]}),(0,a.jsxs)("div",{className:"flex min-w-0 flex-col gap-2",children:[(0,a.jsx)("label",{htmlFor:"start-date-filter",className:"text-sm font-medium text-text-main",children:"Start Date"}),(0,a.jsx)("input",{id:"start-date-filter",type:"datetime-local",value:S.startDate,onChange:e=>_("startDate",e.target.value),className:(0,d.cn)("h-9 px-3 rounded-lg border border-black/10 dark:border-white/10 bg-surface","w-full min-w-0 text-sm text-text-main focus:outline-none focus:ring-2 focus:ring-primary/20")})]}),(0,a.jsxs)("div",{className:"flex min-w-0 flex-col gap-2",children:[(0,a.jsx)("label",{htmlFor:"end-date-filter",className:"text-sm font-medium text-text-main",children:"End Date"}),(0,a.jsx)("input",{id:"end-date-filter",type:"datetime-local",value:S.endDate,onChange:e=>_("endDate",e.target.value),className:(0,d.cn)("h-9 px-3 rounded-lg border border-black/10 dark:border-white/10 bg-surface","w-full min-w-0 text-sm text-text-main focus:outline-none focus:ring-2 focus:ring-primary/20")})]}),(0,a.jsxs)("div",{className:"flex min-w-0 flex-col gap-2 sm:col-span-2 lg:col-span-1",children:[(0,a.jsx)("span",{className:"hidden text-sm font-medium text-text-main opacity-0 lg:block","aria-hidden":"true",children:"Clear"}),(0,a.jsx)(o.default,{variant:"ghost",onClick:()=>{D({provider:"",startDate:"",endDate:""}),l(e=>({...e,page:1}))},disabled:!S.provider&&!S.startDate&&!S.endDate,className:"w-full",children:"Clear Filters"})]})]})}),(0,a.jsxs)(i.default,{padding:"none",children:[(0,a.jsx)("div",{className:"overflow-x-auto",children:(0,a.jsxs)("table",{className:"w-full min-w-[880px]",children:[(0,a.jsx)("thead",{children:(0,a.jsxs)("tr",{className:"border-b border-black/5 dark:border-white/5",children:[(0,a.jsx)("th",{className:"text-left p-4 text-sm font-semibold text-text-main",children:"Timestamp"}),(0,a.jsx)("th",{className:"text-left p-4 text-sm font-semibold text-text-main",children:"Model"}),(0,a.jsx)("th",{className:"text-left p-4 text-sm font-semibold text-text-main",children:"Provider"}),(0,a.jsx)("th",{className:"text-right p-4 text-sm font-semibold text-text-main",children:"Input Tokens"}),(0,a.jsx)("th",{className:"text-right p-4 text-sm font-semibold text-text-main",children:"Output Tokens"}),(0,a.jsx)("th",{className:"text-left p-4 text-sm font-semibold text-text-main",children:"Latency"}),(0,a.jsx)("th",{className:"text-center p-4 text-sm font-semibold text-text-main",children:"Action"})]})}),(0,a.jsx)("tbody",{children:n?(0,a.jsx)("tr",{children:(0,a.jsx)("td",{colSpan:"7",className:"p-8 text-center text-text-muted",children:(0,a.jsxs)("div",{className:"flex items-center justify-center gap-2",children:[(0,a.jsx)("span",{className:"material-symbols-outlined animate-spin text-[20px]",children:"progress_activity"}),"Loading..."]})})}):0===e.length?(0,a.jsx)("tr",{children:(0,a.jsx)("td",{colSpan:"7",className:"p-8 text-center text-text-muted",children:"No request details found"})}):e.map(e=>(0,a.jsxs)("tr",{className:"border-b border-black/5 dark:border-white/5 last:border-b-0 hover:bg-black/[0.02] dark:hover:bg-white/[0.02] transition-colors",children:[(0,a.jsx)("td",{className:"whitespace-nowrap p-4 text-sm text-text-main",children:new Date(e.timestamp).toLocaleString()}),(0,a.jsx)("td",{className:"max-w-[260px] truncate p-4 font-mono text-sm text-text-main",children:e.model}),(0,a.jsx)("td",{className:"max-w-[180px] truncate p-4 text-sm text-text-main",children:(0,a.jsx)("span",{className:"font-medium",children:f(e.provider,k)})}),(0,a.jsx)("td",{className:"p-4 text-sm text-text-main text-right font-mono",children:g(e.tokens).toLocaleString()}),(0,a.jsx)("td",{className:"p-4 text-sm text-text-main text-right font-mono",children:e.tokens?.completion_tokens?.toLocaleString()||0}),(0,a.jsx)("td",{className:"p-4 text-sm text-text-muted",children:(0,a.jsxs)("div",{className:"flex flex-col gap-0.5",children:[(0,a.jsxs)("div",{children:["TTFT: ",(0,a.jsxs)("span",{className:"font-mono",children:[e.latency?.ttft||0,"ms"]})]}),(0,a.jsxs)("div",{children:["Total: ",(0,a.jsxs)("span",{className:"font-mono",children:[e.latency?.total||0,"ms"]})]})]})}),(0,a.jsx)("td",{className:"p-4 text-center",children:(0,a.jsx)(o.default,{variant:"outline",size:"sm",onClick:()=>{p(e),v(!0)},children:"Detail"})})]},e.id))})]})}),!n&&e.length>0&&(0,a.jsx)("div",{className:"border-t border-black/5 dark:border-white/5",children:(0,a.jsx)(x.default,{currentPage:s.page,pageSize:s.pageSize,totalItems:s.totalItems,onPageChange:e=>{l(t=>({...t,page:e}))},onPageSizeChange:e=>{l(t=>({...t,pageSize:e,page:1}))}})})]}),(0,a.jsx)(c,{isOpen:j,onClose:()=>v(!1),title:"Request Details",width:"lg",children:u&&(0,a.jsxs)("div",{className:"space-y-6",children:[(0,a.jsxs)("div",{className:"grid min-w-0 grid-cols-1 gap-4 text-sm sm:grid-cols-2",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("span",{className:"text-text-muted",children:"ID:"})," ",(0,a.jsx)("span",{className:"break-all font-mono text-text-main",children:u.id})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("span",{className:"text-text-muted",children:"Timestamp:"})," ",(0,a.jsx)("span",{className:"text-text-main",children:new Date(u.timestamp).toLocaleString()})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("span",{className:"text-text-muted",children:"Provider:"})," ",(0,a.jsx)("span",{className:"text-text-main font-medium",children:f(u.provider,k)})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("span",{className:"text-text-muted",children:"Model:"})," ",(0,a.jsx)("span",{className:"text-text-main font-mono",children:u.model})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("span",{className:"text-text-muted",children:"Status:"})," ",(0,a.jsx)("span",{className:(0,d.cn)("font-medium","success"===u.status?"text-green-600":"text-red-600"),children:u.status})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("span",{className:"text-text-muted",children:"Latency:"})," ",(0,a.jsxs)("span",{className:"text-text-main font-mono",children:["TTFT ",u.latency?.ttft||0,"ms / Total ",u.latency?.total||0,"ms"]})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("span",{className:"text-text-muted",children:"Input Tokens:"})," ",(0,a.jsx)("span",{className:"text-text-main font-mono",children:g(u.tokens).toLocaleString()})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("span",{className:"text-text-muted",children:"Output Tokens:"})," ",(0,a.jsx)("span",{className:"text-text-main font-mono",children:u.tokens?.completion_tokens?.toLocaleString()||0})]})]}),(0,a.jsxs)("div",{className:"space-y-4",children:[(0,a.jsx)(b,{title:"1. Client Request (Input)",defaultOpen:!0,icon:"input",children:(0,a.jsx)("pre",{className:"max-h-[300px] max-w-full overflow-auto rounded-lg border border-black/5 bg-black/5 p-3 font-mono text-xs text-text-main dark:border-white/5 dark:bg-white/5 sm:p-4",children:JSON.stringify(u.request,null,2)})}),u.providerRequest&&(0,a.jsx)(b,{title:"2. Provider Request (Translated)",icon:"translate",children:(0,a.jsx)("pre",{className:"max-h-[300px] max-w-full overflow-auto rounded-lg border border-black/5 bg-black/5 p-3 font-mono text-xs text-text-main dark:border-white/5 dark:bg-white/5 sm:p-4",children:JSON.stringify(u.providerRequest,null,2)})}),u.providerResponse&&(0,a.jsx)(b,{title:"3. Provider Response (Raw)",icon:"data_object",children:(0,a.jsx)("pre",{className:"max-h-[300px] max-w-full overflow-auto rounded-lg border border-black/5 bg-black/5 p-3 font-mono text-xs text-text-main dark:border-white/5 dark:bg-white/5 sm:p-4",children:"object"==typeof u.providerResponse?JSON.stringify(u.providerResponse,null,2):u.providerResponse})}),(0,a.jsxs)(b,{title:"4. Client Response (Final)",defaultOpen:!0,icon:"output",children:[u.response?.thinking&&(0,a.jsxs)("div",{className:"mb-4",children:[(0,a.jsxs)("h4",{className:"font-semibold text-text-main mb-2 flex items-center gap-2 text-xs uppercase tracking-wide opacity-70",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[16px]",children:"psychology"}),"Thinking Process"]}),(0,a.jsx)("pre",{className:"max-h-[200px] max-w-full overflow-auto rounded-lg border border-amber-200 bg-amber-50 p-3 font-mono text-xs text-amber-900 dark:border-amber-800 dark:bg-amber-950/30 dark:text-amber-100 sm:p-4",children:u.response.thinking})]}),(0,a.jsx)("h4",{className:"font-semibold text-text-main mb-2 text-xs uppercase tracking-wide opacity-70",children:"Content"}),(0,a.jsx)("pre",{className:"max-h-[300px] max-w-full overflow-auto rounded-lg border border-black/5 bg-black/5 p-3 font-mono text-xs text-text-main dark:border-white/5 dark:bg-white/5 sm:p-4",children:u.response?.content||"[No content]"})]})]})]})})]})}let v=[{value:"today",label:"Today"},{value:"24h",label:"24h"},{value:"7d",label:"7D"},{value:"30d",label:"30D"},{value:"60d",label:"60D"}];function N(){return(0,a.jsx)(r.Suspense,{fallback:(0,a.jsx)(n.Qv,{}),children:(0,a.jsx)(w,{})})}function w(){let e=(0,l.useSearchParams)(),t=(0,l.useRouter)(),[s,i]=(0,r.useState)("today"),o=e.get("tab"),d=o&&["overview","logs","details"].includes(o)?o:"overview";return(0,a.jsxs)("div",{className:"flex min-w-0 flex-col gap-6 px-1 sm:px-0 lg:gap-7",children:[(0,a.jsxs)("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between",children:[(0,a.jsx)(n.Iz,{options:[{value:"overview",label:"Overview"},{value:"details",label:"Details"}],value:d,onChange:s=>{if(s===d)return;let a=new URLSearchParams(e);a.set("tab",s),t.push(`/dashboard/usage?${a.toString()}`,{scroll:!1})},className:"w-full sm:w-auto"}),"overview"===d&&(0,a.jsx)(n.Iz,{options:v,value:s,onChange:i,size:"sm",className:"w-full sm:w-auto"})]}),"overview"===d&&(0,a.jsx)(r.Suspense,{fallback:(0,a.jsx)(n.Qv,{}),children:(0,a.jsx)(n.jK,{period:s,setPeriod:i,hidePeriodSelector:!0})}),"logs"===d&&(0,a.jsx)(n.gM,{}),"details"===d&&(0,a.jsx)(j,{})]})}}},e=>{e.O(0,[2574,3862,3745,3339,620,5497,8441,3794,7358],()=>e(e.s=30906)),_N_E=e.O()}]);
|