omniroute 2.0.0 → 2.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.ar.md +4 -3
- package/README.bg.md +4 -3
- package/README.da.md +4 -2
- package/README.de.md +3 -2
- package/README.es.md +1 -0
- package/README.fi.md +1 -0
- package/README.fr.md +1 -0
- package/README.he.md +9 -8
- package/README.hu.md +1 -0
- package/README.id.md +1 -0
- package/README.in.md +9 -8
- package/README.it.md +1 -0
- package/README.ja.md +3 -0
- package/README.ko.md +9 -8
- package/README.md +17 -16
- package/README.ms.md +9 -8
- package/README.nl.md +9 -8
- package/README.no.md +1 -0
- package/README.phi.md +2 -1
- package/README.pl.md +9 -8
- package/README.pt-BR.md +3 -2
- package/README.pt.md +1 -0
- package/README.ro.md +2 -0
- package/README.ru.md +1 -0
- package/README.sk.md +1 -0
- package/README.sv.md +1 -0
- package/README.th.md +1 -0
- package/README.uk-UA.md +1 -0
- package/README.vi.md +1 -0
- package/README.zh-CN.md +10 -9
- package/app/.env +122 -0
- package/app/.next/BUILD_ID +1 -1
- package/app/.next/app-path-routes-manifest.json +54 -54
- package/app/.next/build-manifest.json +3 -3
- package/app/.next/prerender-manifest.json +3 -3
- package/app/.next/required-server-files.json +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/a2a/page.js +2 -2
- package/app/.next/server/app/(dashboard)/dashboard/a2a/page.js.nft.json +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/a2a/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/analytics/page.js +2 -2
- package/app/.next/server/app/(dashboard)/dashboard/analytics/page.js.nft.json +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/analytics/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/api-manager/page.js +2 -2
- package/app/.next/server/app/(dashboard)/dashboard/api-manager/page.js.nft.json +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/api-manager/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/audit-log/page.js +2 -2
- package/app/.next/server/app/(dashboard)/dashboard/audit-log/page.js.nft.json +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/audit-log/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/auto-combo/page.js +2 -2
- package/app/.next/server/app/(dashboard)/dashboard/auto-combo/page.js.nft.json +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/auto-combo/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/cli-tools/page.js +3 -3
- package/app/.next/server/app/(dashboard)/dashboard/cli-tools/page.js.nft.json +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/cli-tools/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/combos/page.js +2 -2
- package/app/.next/server/app/(dashboard)/dashboard/combos/page.js.nft.json +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/combos/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/costs/page.js +2 -2
- package/app/.next/server/app/(dashboard)/dashboard/costs/page.js.nft.json +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/costs/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/endpoint/page.js +2 -2
- package/app/.next/server/app/(dashboard)/dashboard/endpoint/page.js.nft.json +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/endpoint/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/health/page.js +2 -2
- package/app/.next/server/app/(dashboard)/dashboard/health/page.js.nft.json +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/health/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/limits/page.js +2 -2
- package/app/.next/server/app/(dashboard)/dashboard/limits/page.js.nft.json +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/limits/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/logs/page.js +2 -2
- package/app/.next/server/app/(dashboard)/dashboard/logs/page.js.nft.json +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/logs/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/mcp/page.js +2 -2
- package/app/.next/server/app/(dashboard)/dashboard/mcp/page.js.nft.json +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/mcp/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/media/page.js +2 -2
- package/app/.next/server/app/(dashboard)/dashboard/media/page.js.nft.json +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/media/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/onboarding/page.js +2 -2
- package/app/.next/server/app/(dashboard)/dashboard/onboarding/page.js.nft.json +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/onboarding/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/page.js +2 -2
- package/app/.next/server/app/(dashboard)/dashboard/page.js.nft.json +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/profile/page.js +2 -2
- package/app/.next/server/app/(dashboard)/dashboard/profile/page.js.nft.json +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/profile/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/providers/[id]/page.js +2 -2
- package/app/.next/server/app/(dashboard)/dashboard/providers/[id]/page.js.nft.json +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/providers/[id]/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/providers/new/page.js +2 -2
- package/app/.next/server/app/(dashboard)/dashboard/providers/new/page.js.nft.json +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/providers/new/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/providers/page.js +2 -2
- package/app/.next/server/app/(dashboard)/dashboard/providers/page.js.nft.json +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/providers/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/settings/page.js +2 -2
- package/app/.next/server/app/(dashboard)/dashboard/settings/page.js.nft.json +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/settings/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/settings/pricing/page.js +2 -2
- package/app/.next/server/app/(dashboard)/dashboard/settings/pricing/page.js.nft.json +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/settings/pricing/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/translator/page.js +3 -3
- package/app/.next/server/app/(dashboard)/dashboard/translator/page.js.nft.json +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/translator/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/usage/page.js +2 -2
- package/app/.next/server/app/(dashboard)/dashboard/usage/page.js.nft.json +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/usage/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/.well-known/agent.json/route.js +1 -1
- package/app/.next/server/app/.well-known/agent.json/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/400/page.js +2 -2
- package/app/.next/server/app/400/page.js.nft.json +1 -1
- package/app/.next/server/app/400/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/401/page.js +2 -2
- package/app/.next/server/app/401/page.js.nft.json +1 -1
- package/app/.next/server/app/401/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/403/page.js +2 -2
- package/app/.next/server/app/403/page.js.nft.json +1 -1
- package/app/.next/server/app/403/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/408/page.js +2 -2
- package/app/.next/server/app/408/page.js.nft.json +1 -1
- package/app/.next/server/app/408/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/429/page.js +2 -2
- package/app/.next/server/app/429/page.js.nft.json +1 -1
- package/app/.next/server/app/429/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/500/page.js +2 -2
- package/app/.next/server/app/500/page.js.nft.json +1 -1
- package/app/.next/server/app/500/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/502/page.js +2 -2
- package/app/.next/server/app/502/page.js.nft.json +1 -1
- package/app/.next/server/app/502/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/503/page.js +2 -2
- package/app/.next/server/app/503/page.js.nft.json +1 -1
- package/app/.next/server/app/503/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/_global-error/page.js +3 -3
- package/app/.next/server/app/_global-error/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/_global-error.html +2 -2
- package/app/.next/server/app/_global-error.rsc +5 -5
- package/app/.next/server/app/_global-error.segments/_full.segment.rsc +5 -5
- package/app/.next/server/app/_global-error.segments/_global-error/__PAGE__.segment.rsc +1 -1
- package/app/.next/server/app/_global-error.segments/_global-error.segment.rsc +1 -1
- package/app/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
- package/app/.next/server/app/_global-error.segments/_index.segment.rsc +4 -4
- package/app/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
- package/app/.next/server/app/_not-found/page.js +2 -2
- package/app/.next/server/app/_not-found/page.js.nft.json +1 -1
- package/app/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/a2a/route.js +2 -2
- package/app/.next/server/app/a2a/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/a2a/status/route.js +1 -1
- package/app/.next/server/app/api/a2a/status/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/a2a/tasks/[id]/cancel/route.js +1 -1
- package/app/.next/server/app/api/a2a/tasks/[id]/cancel/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/a2a/tasks/[id]/route.js +1 -1
- package/app/.next/server/app/api/a2a/tasks/[id]/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/a2a/tasks/route.js +1 -1
- package/app/.next/server/app/api/a2a/tasks/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/auth/login/route.js +1 -1
- package/app/.next/server/app/api/auth/login/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/auth/logout/route.js +1 -1
- package/app/.next/server/app/api/auth/logout/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/auth/status/route.js +1 -1
- package/app/.next/server/app/api/auth/status/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/cache/route.js +1 -1
- package/app/.next/server/app/api/cache/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/cache/stats/route.js +1 -1
- package/app/.next/server/app/api/cache/stats/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/cli-tools/antigravity-mitm/alias/route.js +2 -2
- package/app/.next/server/app/api/cli-tools/antigravity-mitm/alias/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/cli-tools/antigravity-mitm/route.js +3 -3
- package/app/.next/server/app/api/cli-tools/antigravity-mitm/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/cli-tools/backups/route.js +2 -2
- package/app/.next/server/app/api/cli-tools/backups/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/cli-tools/claude-settings/route.js +2 -2
- package/app/.next/server/app/api/cli-tools/claude-settings/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/cli-tools/cline-settings/route.js +2 -2
- package/app/.next/server/app/api/cli-tools/cline-settings/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/cli-tools/codex-profiles/route.js +2 -2
- package/app/.next/server/app/api/cli-tools/codex-profiles/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/cli-tools/codex-settings/route.js +1 -1
- package/app/.next/server/app/api/cli-tools/codex-settings/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/cli-tools/droid-settings/route.js +2 -2
- package/app/.next/server/app/api/cli-tools/droid-settings/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/cli-tools/guide-settings/[toolId]/route.js +1 -1
- package/app/.next/server/app/api/cli-tools/guide-settings/[toolId]/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/cli-tools/kilo-settings/route.js +2 -2
- package/app/.next/server/app/api/cli-tools/kilo-settings/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/cli-tools/openclaw/auto-order/route.js +1 -1
- package/app/.next/server/app/api/cli-tools/openclaw/auto-order/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/cli-tools/openclaw-settings/route.js +1 -1
- package/app/.next/server/app/api/cli-tools/openclaw-settings/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/cli-tools/runtime/[toolId]/route.js +2 -2
- package/app/.next/server/app/api/cli-tools/runtime/[toolId]/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/cli-tools/status/route.js +2 -2
- package/app/.next/server/app/api/cli-tools/status/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/cloud/auth/route.js +1 -1
- package/app/.next/server/app/api/cloud/auth/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/cloud/credentials/update/route.js +1 -1
- package/app/.next/server/app/api/cloud/credentials/update/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/cloud/model/resolve/route.js +1 -1
- package/app/.next/server/app/api/cloud/model/resolve/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/cloud/models/alias/route.js +1 -1
- package/app/.next/server/app/api/cloud/models/alias/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/combos/[id]/route.js +1 -1
- package/app/.next/server/app/api/combos/[id]/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/combos/auto/route.js +1 -1
- package/app/.next/server/app/api/combos/auto/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/combos/metrics/route.js +1 -1
- package/app/.next/server/app/api/combos/metrics/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/combos/route.js +1 -1
- package/app/.next/server/app/api/combos/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/combos/test/route.js +1 -1
- package/app/.next/server/app/api/combos/test/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/compliance/audit-log/route.js +1 -1
- package/app/.next/server/app/api/compliance/audit-log/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/db-backups/export/route.js +1 -1
- package/app/.next/server/app/api/db-backups/export/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/db-backups/exportAll/route.js +1 -1
- package/app/.next/server/app/api/db-backups/exportAll/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/db-backups/import/route.js +1 -1
- package/app/.next/server/app/api/db-backups/import/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/db-backups/route.js +1 -1
- package/app/.next/server/app/api/db-backups/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/evals/[suiteId]/route.js +1 -1
- package/app/.next/server/app/api/evals/[suiteId]/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/evals/route.js +1 -1
- package/app/.next/server/app/api/evals/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/fallback/chains/route.js +2 -2
- package/app/.next/server/app/api/fallback/chains/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/init/route.js +1 -1
- package/app/.next/server/app/api/init/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/keys/[id]/route.js +1 -1
- package/app/.next/server/app/api/keys/[id]/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/keys/route.js +1 -1
- package/app/.next/server/app/api/keys/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/logs/console/route.js +1 -1
- package/app/.next/server/app/api/logs/console/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/mcp/audit/route.js +2 -2
- package/app/.next/server/app/api/mcp/audit/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/mcp/audit/stats/route.js +2 -2
- package/app/.next/server/app/api/mcp/audit/stats/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/mcp/sse/route.js +1 -1
- package/app/.next/server/app/api/mcp/sse/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/mcp/status/route.js +1 -1
- package/app/.next/server/app/api/mcp/status/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/mcp/stream/route.js +1 -1
- package/app/.next/server/app/api/mcp/stream/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/mcp/tools/route.js +1 -1
- package/app/.next/server/app/api/mcp/tools/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/models/alias/route.js +1 -1
- package/app/.next/server/app/api/models/alias/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/models/availability/route.js +1 -1
- package/app/.next/server/app/api/models/availability/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/models/catalog/route.js +2 -2
- package/app/.next/server/app/api/models/catalog/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/models/route.js +2 -2
- package/app/.next/server/app/api/models/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/monitoring/health/route.js +2 -2
- package/app/.next/server/app/api/monitoring/health/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/oauth/[provider]/[action]/route.js +2 -2
- package/app/.next/server/app/api/oauth/[provider]/[action]/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/oauth/cursor/auto-import/route.js +1 -1
- package/app/.next/server/app/api/oauth/cursor/auto-import/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/oauth/cursor/import/route.js +1 -1
- package/app/.next/server/app/api/oauth/cursor/import/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/oauth/kiro/auto-import/route.js +1 -1
- package/app/.next/server/app/api/oauth/kiro/auto-import/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/oauth/kiro/import/route.js +1 -1
- package/app/.next/server/app/api/oauth/kiro/import/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/oauth/kiro/social-authorize/route.js +1 -1
- package/app/.next/server/app/api/oauth/kiro/social-authorize/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/oauth/kiro/social-exchange/route.js +1 -1
- package/app/.next/server/app/api/oauth/kiro/social-exchange/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/policies/route.js +2 -2
- package/app/.next/server/app/api/policies/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/pricing/defaults/route.js +1 -1
- package/app/.next/server/app/api/pricing/defaults/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/pricing/models/route.js +1 -1
- package/app/.next/server/app/api/pricing/models/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/pricing/route.js +1 -1
- package/app/.next/server/app/api/pricing/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/provider-metrics/route.js +2 -2
- package/app/.next/server/app/api/provider-metrics/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/provider-models/route.js +1 -1
- package/app/.next/server/app/api/provider-models/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/provider-nodes/[id]/route.js +1 -1
- package/app/.next/server/app/api/provider-nodes/[id]/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/provider-nodes/route.js +2 -2
- package/app/.next/server/app/api/provider-nodes/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/provider-nodes/validate/route.js +1 -1
- package/app/.next/server/app/api/provider-nodes/validate/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/providers/[id]/models/route.js +2 -2
- package/app/.next/server/app/api/providers/[id]/models/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/providers/[id]/route.js +1 -1
- package/app/.next/server/app/api/providers/[id]/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/providers/[id]/test/route.js +1 -1
- package/app/.next/server/app/api/providers/[id]/test/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/providers/client/route.js +1 -1
- package/app/.next/server/app/api/providers/client/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/providers/route.js +2 -2
- package/app/.next/server/app/api/providers/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/providers/test-batch/route.js +1 -1
- package/app/.next/server/app/api/providers/test-batch/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/providers/validate/route.js +1 -1
- package/app/.next/server/app/api/providers/validate/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/rate-limit/route.js +1 -1
- package/app/.next/server/app/api/rate-limit/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/rate-limits/route.js +1 -1
- package/app/.next/server/app/api/rate-limits/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/resilience/reset/route.js +1 -1
- package/app/.next/server/app/api/resilience/reset/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/resilience/route.js +1 -1
- package/app/.next/server/app/api/resilience/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/restart/route.js +1 -1
- package/app/.next/server/app/api/restart/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/sessions/route.js +1 -1
- package/app/.next/server/app/api/sessions/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/settings/background-degradation/route.js +1 -1
- package/app/.next/server/app/api/settings/background-degradation/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/settings/combo-defaults/route.js +1 -1
- package/app/.next/server/app/api/settings/combo-defaults/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/settings/ip-filter/route.js +1 -1
- package/app/.next/server/app/api/settings/ip-filter/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/settings/model-aliases/route.js +1 -1
- package/app/.next/server/app/api/settings/model-aliases/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/settings/proxy/route.js +1 -1
- package/app/.next/server/app/api/settings/proxy/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/settings/proxy/test/route.js +1 -1
- package/app/.next/server/app/api/settings/proxy/test/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/settings/require-login/route.js +1 -1
- package/app/.next/server/app/api/settings/require-login/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/settings/route.js +1 -1
- package/app/.next/server/app/api/settings/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/settings/system-prompt/route.js +1 -1
- package/app/.next/server/app/api/settings/system-prompt/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/settings/thinking-budget/route.js +1 -1
- package/app/.next/server/app/api/settings/thinking-budget/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/shutdown/route.js +1 -1
- package/app/.next/server/app/api/shutdown/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/storage/health/route.js +1 -1
- package/app/.next/server/app/api/storage/health/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/sync/cloud/route.js +1 -1
- package/app/.next/server/app/api/sync/cloud/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/sync/initialize/route.js +1 -1
- package/app/.next/server/app/api/sync/initialize/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/tags/route.js +1 -1
- package/app/.next/server/app/api/tags/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/telemetry/summary/route.js +1 -1
- package/app/.next/server/app/api/telemetry/summary/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/token-health/route.js +1 -1
- package/app/.next/server/app/api/token-health/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/translator/detect/route.js +1 -1
- package/app/.next/server/app/api/translator/detect/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/translator/history/route.js +1 -1
- package/app/.next/server/app/api/translator/history/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/translator/load/route.js +1 -1
- package/app/.next/server/app/api/translator/load/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/translator/save/route.js +1 -1
- package/app/.next/server/app/api/translator/save/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/translator/send/route.js +1 -1
- package/app/.next/server/app/api/translator/send/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/translator/translate/route.js +1 -1
- package/app/.next/server/app/api/translator/translate/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/usage/[connectionId]/route.js +2 -2
- package/app/.next/server/app/api/usage/[connectionId]/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/usage/analytics/route.js +1 -1
- package/app/.next/server/app/api/usage/analytics/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/usage/budget/route.js +2 -2
- package/app/.next/server/app/api/usage/budget/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/usage/call-logs/[id]/route.js +1 -1
- package/app/.next/server/app/api/usage/call-logs/[id]/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/usage/call-logs/route.js +1 -1
- package/app/.next/server/app/api/usage/call-logs/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/usage/history/route.js +1 -1
- package/app/.next/server/app/api/usage/history/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/usage/logs/route.js +1 -1
- package/app/.next/server/app/api/usage/logs/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/usage/proxy-logs/route.js +1 -1
- package/app/.next/server/app/api/usage/proxy-logs/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/usage/quota/route.js +1 -1
- package/app/.next/server/app/api/usage/quota/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/usage/request-logs/route.js +1 -1
- package/app/.next/server/app/api/usage/request-logs/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/v1/api/chat/route.js +1 -1
- package/app/.next/server/app/api/v1/api/chat/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/v1/audio/speech/route.js +1 -1
- package/app/.next/server/app/api/v1/audio/speech/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/v1/audio/transcriptions/route.js +1 -1
- package/app/.next/server/app/api/v1/audio/transcriptions/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/v1/chat/completions/route.js +1 -1
- package/app/.next/server/app/api/v1/chat/completions/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/v1/embeddings/route.js +1 -1
- package/app/.next/server/app/api/v1/embeddings/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/v1/images/generations/route.js +1 -1
- package/app/.next/server/app/api/v1/images/generations/route.js.nft.json +1 -1
- package/app/.next/server/app/api/v1/images/generations/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/v1/messages/count_tokens/route.js +1 -1
- package/app/.next/server/app/api/v1/messages/count_tokens/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/v1/messages/route.js +1 -1
- package/app/.next/server/app/api/v1/messages/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/v1/models/route.js +1 -1
- package/app/.next/server/app/api/v1/models/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/v1/moderations/route.js +1 -1
- package/app/.next/server/app/api/v1/moderations/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/v1/music/generations/route.js +1 -1
- package/app/.next/server/app/api/v1/music/generations/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/v1/providers/[provider]/chat/completions/route.js +1 -1
- package/app/.next/server/app/api/v1/providers/[provider]/chat/completions/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/v1/providers/[provider]/embeddings/route.js +1 -1
- package/app/.next/server/app/api/v1/providers/[provider]/embeddings/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/v1/providers/[provider]/images/generations/route.js +1 -1
- package/app/.next/server/app/api/v1/providers/[provider]/images/generations/route.js.nft.json +1 -1
- package/app/.next/server/app/api/v1/providers/[provider]/images/generations/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/v1/rerank/route.js +1 -1
- package/app/.next/server/app/api/v1/rerank/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/v1/responses/route.js +1 -1
- package/app/.next/server/app/api/v1/responses/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/v1/route.js +1 -1
- package/app/.next/server/app/api/v1/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/v1/videos/generations/route.js +1 -1
- package/app/.next/server/app/api/v1/videos/generations/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/v1beta/models/[...path]/route.js +1 -1
- package/app/.next/server/app/api/v1beta/models/[...path]/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/v1beta/models/route.js +2 -2
- package/app/.next/server/app/api/v1beta/models/route_client-reference-manifest.js +1 -1
- package/app/.next/server/app/callback/page.js +2 -2
- package/app/.next/server/app/callback/page.js.nft.json +1 -1
- package/app/.next/server/app/callback/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/docs/page.js +4 -4
- package/app/.next/server/app/docs/page.js.nft.json +1 -1
- package/app/.next/server/app/docs/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/forbidden/page.js +2 -2
- package/app/.next/server/app/forbidden/page.js.nft.json +1 -1
- package/app/.next/server/app/forbidden/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/forgot-password/page.js +2 -2
- package/app/.next/server/app/forgot-password/page.js.nft.json +1 -1
- package/app/.next/server/app/forgot-password/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/landing/page.js +2 -2
- package/app/.next/server/app/landing/page.js.nft.json +1 -1
- package/app/.next/server/app/landing/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/login/page.js +2 -2
- package/app/.next/server/app/login/page.js.nft.json +1 -1
- package/app/.next/server/app/login/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/maintenance/page.js +2 -2
- package/app/.next/server/app/maintenance/page.js.nft.json +1 -1
- package/app/.next/server/app/maintenance/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/offline/page.js +2 -2
- package/app/.next/server/app/offline/page.js.nft.json +1 -1
- package/app/.next/server/app/offline/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/page.js +2 -2
- package/app/.next/server/app/page.js.nft.json +1 -1
- package/app/.next/server/app/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/privacy/page.js +2 -2
- package/app/.next/server/app/privacy/page.js.nft.json +1 -1
- package/app/.next/server/app/privacy/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/status/page.js +2 -2
- package/app/.next/server/app/status/page.js.nft.json +1 -1
- package/app/.next/server/app/status/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/terms/page.js +2 -2
- package/app/.next/server/app/terms/page.js.nft.json +1 -1
- package/app/.next/server/app/terms/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app-paths-manifest.json +54 -54
- package/app/.next/server/chunks/1033.js +1 -1
- package/app/.next/server/chunks/1909.js +2 -0
- package/app/.next/server/chunks/2180.js +1 -1
- package/app/.next/server/chunks/2901.js +1 -1
- package/app/.next/server/chunks/2910.js +1 -1
- package/app/.next/server/chunks/3498.js +1 -1
- package/app/.next/server/chunks/3969.js +1 -1
- package/app/.next/server/chunks/4488.js +1 -1
- package/app/.next/server/chunks/4631.js +2 -2
- package/app/.next/server/chunks/7109.js +1 -1
- package/app/.next/server/chunks/7167.js +1 -0
- package/app/.next/server/chunks/7669.js +1 -1
- package/app/.next/server/chunks/8020.js +3 -3
- package/app/.next/server/chunks/8369.js +1 -1
- package/app/.next/server/chunks/9548.js +1 -1
- package/app/.next/server/instrumentation.js +1 -1
- package/app/.next/server/middleware-build-manifest.js +1 -1
- package/app/.next/server/middleware.js +3 -3
- package/app/.next/server/next-font-manifest.js +1 -1
- package/app/.next/server/next-font-manifest.json +1 -1
- package/app/.next/server/pages/500.html +2 -2
- package/app/.next/server/server-reference-manifest.js +1 -1
- package/app/.next/server/server-reference-manifest.json +1 -1
- package/app/.next/static/chunks/{5846-c2071f4db5ecc3da.js → 5846-014698d5430bb218.js} +1 -1
- package/app/.next/static/chunks/{647-f42f77310d9d9936.js → 647-52d3e2e64d7de62e.js} +2 -2
- package/app/.next/static/chunks/app/(dashboard)/dashboard/a2a/page-ed1f5b1ae0e01c02.js +1 -0
- package/app/.next/static/chunks/app/(dashboard)/dashboard/analytics/loading-6a2bb3ad980b05b9.js +1 -0
- package/app/.next/static/chunks/app/(dashboard)/dashboard/analytics/{page-bef5c045e7eae657.js → page-6ab7701da3357bb9.js} +1 -1
- package/app/.next/static/chunks/app/(dashboard)/dashboard/api-manager/page-027b3eb09d2d46e0.js +1 -0
- package/app/.next/static/chunks/app/(dashboard)/dashboard/audit-log/page-c9b98846b8479f3f.js +1 -0
- package/app/.next/static/chunks/app/(dashboard)/dashboard/auto-combo/{page-8e609f4c9b26a901.js → page-851063ded34ab7a6.js} +1 -1
- package/app/.next/static/chunks/app/(dashboard)/dashboard/cli-tools/page-86acc32f9984a4e2.js +15 -0
- package/app/.next/static/chunks/app/(dashboard)/dashboard/combos/page-ac5dcffbe54f77f9.js +1 -0
- package/app/.next/static/chunks/app/(dashboard)/dashboard/costs/{page-7a233357dfbd2e05.js → page-8f6233f59f5277e9.js} +1 -1
- package/app/.next/static/chunks/app/(dashboard)/dashboard/endpoint/page-36f33de29eb978a1.js +1 -0
- package/app/.next/static/chunks/app/(dashboard)/dashboard/health/{page-66ee4e631429e0d8.js → page-1e1eb2f79d606ab2.js} +1 -1
- package/app/.next/static/chunks/app/(dashboard)/dashboard/limits/page-e8a28e4cf62889bd.js +1 -0
- package/app/.next/static/chunks/app/(dashboard)/dashboard/logs/{page-6e4bcb48b8731915.js → page-95e4b5e0bf023d76.js} +1 -1
- package/app/.next/static/chunks/app/(dashboard)/dashboard/mcp/page-d9b5c3282ec5d809.js +1 -0
- package/app/.next/static/chunks/app/(dashboard)/dashboard/media/page-72b768421394b42c.js +1 -0
- package/app/.next/static/chunks/app/(dashboard)/dashboard/onboarding/{page-d424641c7e428be9.js → page-5378e9473a20cd6a.js} +1 -1
- package/app/.next/static/chunks/app/(dashboard)/dashboard/page-40d20c1273f57206.js +1 -0
- package/app/.next/static/chunks/app/(dashboard)/dashboard/providers/[id]/page-350aed2e86512c23.js +1 -0
- package/app/.next/static/chunks/app/(dashboard)/dashboard/providers/{error-0400f175dd1372fa.js → error-a5ae03ba05400b04.js} +1 -1
- package/app/.next/static/chunks/app/(dashboard)/dashboard/providers/loading-7deaa9f550841465.js +1 -0
- package/app/.next/static/chunks/app/(dashboard)/dashboard/providers/new/page-3ef302da4b756e50.js +1 -0
- package/app/.next/static/chunks/app/(dashboard)/dashboard/providers/{page-87f0d43ce6cca0cb.js → page-cd0feb6c545b8a49.js} +1 -1
- package/app/.next/static/chunks/app/(dashboard)/dashboard/settings/{error-c39d18f10fb7d3f6.js → error-ec9643134a96bbcd.js} +1 -1
- package/app/.next/static/chunks/app/(dashboard)/dashboard/settings/{loading-b5faf05c78a2cc54.js → loading-3519a633b514f31a.js} +1 -1
- package/app/.next/static/chunks/app/(dashboard)/dashboard/settings/{page-6b38a30bfddf3b89.js → page-cbaa4b638a583fe9.js} +1 -1
- package/app/.next/static/chunks/app/(dashboard)/dashboard/settings/pricing/{page-a4b8b03ffb39da1d.js → page-69eb8b0eb0e9de00.js} +1 -1
- package/app/.next/static/chunks/app/(dashboard)/dashboard/translator/{page-b29f17c4dc7d449f.js → page-8cc93e616925f0a0.js} +1 -1
- package/app/.next/static/chunks/app/(dashboard)/dashboard/usage/page-8c8f2d59d0cbb516.js +1 -0
- package/app/.next/static/chunks/app/(dashboard)/{layout-6d0afc53f5f2a538.js → layout-7ae0c66c22bee8a1.js} +1 -1
- package/app/.next/static/chunks/app/400/{page-3b77bf358909019a.js → page-3b9079ea400ca287.js} +1 -1
- package/app/.next/static/chunks/app/401/{page-3b77bf358909019a.js → page-3b9079ea400ca287.js} +1 -1
- package/app/.next/static/chunks/app/403/{page-3b77bf358909019a.js → page-3b9079ea400ca287.js} +1 -1
- package/app/.next/static/chunks/app/408/{page-3b77bf358909019a.js → page-3b9079ea400ca287.js} +1 -1
- package/app/.next/static/chunks/app/429/page-3b9079ea400ca287.js +1 -0
- package/app/.next/static/chunks/app/500/page-3b9079ea400ca287.js +1 -0
- package/app/.next/static/chunks/app/502/page-3b9079ea400ca287.js +1 -0
- package/app/.next/static/chunks/app/503/page-3b9079ea400ca287.js +1 -0
- package/app/.next/static/chunks/app/callback/{page-585a53f7dc6a30f1.js → page-0f0ebc0820dd18a5.js} +1 -1
- package/app/.next/static/chunks/app/docs/{page-9624e5fb8cabf7d8.js → page-dc88e0a01d291518.js} +1 -1
- package/app/.next/static/chunks/app/{error-f7f595c541537e63.js → error-32c03f14529d3920.js} +1 -1
- package/app/.next/static/chunks/app/forbidden/page-8d8e1709a1e32585.js +1 -0
- package/app/.next/static/chunks/app/forgot-password/page-d5c9b77748aa9deb.js +1 -0
- package/app/.next/static/chunks/app/global-error-5840b1caa830f2ec.js +1 -0
- package/app/.next/static/chunks/app/landing/page-75b0c988db383cfc.js +1 -0
- package/app/.next/static/chunks/app/{layout-108592eafb959363.js → layout-070972eb026af319.js} +1 -1
- package/app/.next/static/chunks/app/{loading-e063375d5b12a2f7.js → loading-da2f6e1471afc070.js} +1 -1
- package/app/.next/static/chunks/app/login/{page-cf6b82187b09a701.js → page-26d717c652d56032.js} +1 -1
- package/app/.next/static/chunks/app/maintenance/page-3b9079ea400ca287.js +1 -0
- package/app/.next/static/chunks/app/not-found-faf36d2a9a452506.js +1 -0
- package/app/.next/static/chunks/app/offline/page-bf68bf461af876a3.js +1 -0
- package/app/.next/static/chunks/app/privacy/{page-9624e5fb8cabf7d8.js → page-dc88e0a01d291518.js} +1 -1
- package/app/.next/static/chunks/app/status/page-29a433b40631ce12.js +1 -0
- package/app/.next/static/chunks/app/terms/{page-9624e5fb8cabf7d8.js → page-dc88e0a01d291518.js} +1 -1
- package/app/.next/static/chunks/{main-app-c9da11a8061df107.js → main-app-ae230f6bf51a5edb.js} +1 -1
- package/app/logs/application/app.log +1 -0
- package/app/package.json +1 -1
- package/app/server.js +1 -1
- package/package.json +1 -1
- package/app/.next/server/chunks/5248.js +0 -1
- package/app/.next/server/chunks/7889.js +0 -2
- package/app/.next/static/chunks/app/(dashboard)/dashboard/a2a/page-43d6fa6b75cca497.js +0 -1
- package/app/.next/static/chunks/app/(dashboard)/dashboard/analytics/loading-49ae846d72948391.js +0 -1
- package/app/.next/static/chunks/app/(dashboard)/dashboard/api-manager/page-16f886b3711a6a50.js +0 -1
- package/app/.next/static/chunks/app/(dashboard)/dashboard/audit-log/page-e5bf8955e7b9a4f5.js +0 -1
- package/app/.next/static/chunks/app/(dashboard)/dashboard/cli-tools/page-d1e5ed188e14c618.js +0 -15
- package/app/.next/static/chunks/app/(dashboard)/dashboard/combos/page-8d4d2f071d114b90.js +0 -1
- package/app/.next/static/chunks/app/(dashboard)/dashboard/endpoint/page-7b1037d65eef97a8.js +0 -1
- package/app/.next/static/chunks/app/(dashboard)/dashboard/limits/page-d5e0c556e2b32478.js +0 -1
- package/app/.next/static/chunks/app/(dashboard)/dashboard/mcp/page-8e35334b9f393139.js +0 -1
- package/app/.next/static/chunks/app/(dashboard)/dashboard/media/page-1d0ca9b5d3eaf7cd.js +0 -1
- package/app/.next/static/chunks/app/(dashboard)/dashboard/page-d75ccdb976b36258.js +0 -1
- package/app/.next/static/chunks/app/(dashboard)/dashboard/providers/[id]/page-1abb3ea768844f2b.js +0 -1
- package/app/.next/static/chunks/app/(dashboard)/dashboard/providers/loading-9552383fd2e11282.js +0 -1
- package/app/.next/static/chunks/app/(dashboard)/dashboard/providers/new/page-d57908b59d4b482c.js +0 -1
- package/app/.next/static/chunks/app/(dashboard)/dashboard/usage/page-9e20463252daf023.js +0 -1
- package/app/.next/static/chunks/app/429/page-3b77bf358909019a.js +0 -1
- package/app/.next/static/chunks/app/500/page-3b77bf358909019a.js +0 -1
- package/app/.next/static/chunks/app/502/page-3b77bf358909019a.js +0 -1
- package/app/.next/static/chunks/app/503/page-3b77bf358909019a.js +0 -1
- package/app/.next/static/chunks/app/forbidden/page-b33079c1573b0bfa.js +0 -1
- package/app/.next/static/chunks/app/forgot-password/page-90cd6259c75badfc.js +0 -1
- package/app/.next/static/chunks/app/global-error-1dfd1c91ad5199fe.js +0 -1
- package/app/.next/static/chunks/app/landing/page-9d540ab1716f8e3e.js +0 -1
- package/app/.next/static/chunks/app/maintenance/page-3b77bf358909019a.js +0 -1
- package/app/.next/static/chunks/app/not-found-511518956bcae7bc.js +0 -1
- package/app/.next/static/chunks/app/offline/page-9d6ea493783a0219.js +0 -1
- package/app/.next/static/chunks/app/status/page-4e5e9b5a513aa474.js +0 -1
- /package/app/.next/static/{i4hXorUJfOXsVFs23YXiR → GDoUzLvy4YDqhnGqUCiZ0}/_buildManifest.js +0 -0
- /package/app/.next/static/{i4hXorUJfOXsVFs23YXiR → GDoUzLvy4YDqhnGqUCiZ0}/_ssgManifest.js +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[647],{1652:(e,t,s)=>{s.d(t,{default:()=>d});var r=s(95155),a=s(12115),l=s(14051),n=s.n(l),i=s(71361),o=s(35806),c=s(34422);function d({isOpen:e,onMethodSelect:t,onClose:s}){let[l,n]=(0,a.useState)(null),[d,x]=(0,a.useState)(""),[m,u]=(0,a.useState)("us-east-1"),[p,h]=(0,a.useState)(""),[b,f]=(0,a.useState)(null),[g,y]=(0,a.useState)(!1),[j,v]=(0,a.useState)(!1),[N,k]=(0,a.useState)(!1);(0,a.useEffect)(()=>{"import"===l&&e&&(async()=>{v(!0),f(null),k(!1);try{let e=await fetch("/api/oauth/kiro/auto-import"),t=await e.json();t.found?(h(t.refreshToken),k(!0)):f(t.error||"Could not auto-detect token")}catch(e){f("Failed to auto-detect token")}finally{v(!1)}})()},[l,e]);let w=e=>{n(e),f(null)},C=()=>{n(null),f(null)},S=async()=>{if(!p.trim())return void f("Please enter a refresh token");y(!0),f(null);try{let e=await fetch("/api/oauth/kiro/import",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({refreshToken:p.trim()})}),t=await e.json();if(!e.ok)throw Error(t.error||"Import failed");s()}catch(e){f(e.message)}finally{y(!1)}},T=e=>{t("social",{provider:e})};return(0,r.jsx)(i.default,{isOpen:e,title:"Connect Kiro",onClose:s,size:"lg",children:(0,r.jsxs)("div",{className:"flex flex-col gap-4",children:[!l&&(0,r.jsxs)("div",{className:"space-y-3",children:[(0,r.jsx)("p",{className:"text-sm text-text-muted mb-4",children:"Choose your authentication method:"}),(0,r.jsx)("button",{onClick:()=>t("builder-id"),className:"w-full p-4 text-left border border-border rounded-lg hover:bg-sidebar transition-colors",children:(0,r.jsxs)("div",{className:"flex items-start gap-3",children:[(0,r.jsx)("span",{className:"material-symbols-outlined text-primary mt-0.5",children:"shield"}),(0,r.jsxs)("div",{className:"flex-1",children:[(0,r.jsx)("h3",{className:"font-semibold mb-1",children:"AWS Builder ID"}),(0,r.jsx)("p",{className:"text-sm text-text-muted",children:"Recommended for most users. Free AWS account required."})]})]})}),(0,r.jsx)("button",{onClick:()=>w("idc"),className:"hidden w-full p-4 text-left border border-border rounded-lg hover:bg-sidebar transition-colors",children:(0,r.jsxs)("div",{className:"flex items-start gap-3",children:[(0,r.jsx)("span",{className:"material-symbols-outlined text-primary mt-0.5",children:"business"}),(0,r.jsxs)("div",{className:"flex-1",children:[(0,r.jsx)("h3",{className:"font-semibold mb-1",children:"AWS IAM Identity Center"}),(0,r.jsx)("p",{className:"text-sm text-text-muted",children:"For enterprise users with custom AWS IAM Identity Center."})]})]})}),(0,r.jsx)("button",{onClick:()=>w("social-google"),className:"hidden w-full p-4 text-left border border-border rounded-lg hover:bg-sidebar transition-colors",children:(0,r.jsxs)("div",{className:"flex items-start gap-3",children:[(0,r.jsx)("span",{className:"material-symbols-outlined text-primary mt-0.5",children:"account_circle"}),(0,r.jsxs)("div",{className:"flex-1",children:[(0,r.jsx)("h3",{className:"font-semibold mb-1",children:"Google Account"}),(0,r.jsx)("p",{className:"text-sm text-text-muted",children:"Login with your Google account (manual callback)."})]})]})}),(0,r.jsx)("button",{onClick:()=>w("social-github"),className:"hidden w-full p-4 text-left border border-border rounded-lg hover:bg-sidebar transition-colors",children:(0,r.jsxs)("div",{className:"flex items-start gap-3",children:[(0,r.jsx)("span",{className:"material-symbols-outlined text-primary mt-0.5",children:"code"}),(0,r.jsxs)("div",{className:"flex-1",children:[(0,r.jsx)("h3",{className:"font-semibold mb-1",children:"GitHub Account"}),(0,r.jsx)("p",{className:"text-sm text-text-muted",children:"Login with your GitHub account (manual callback)."})]})]})}),(0,r.jsx)("button",{onClick:()=>w("import"),className:"w-full p-4 text-left border border-border rounded-lg hover:bg-sidebar transition-colors",children:(0,r.jsxs)("div",{className:"flex items-start gap-3",children:[(0,r.jsx)("span",{className:"material-symbols-outlined text-primary mt-0.5",children:"file_upload"}),(0,r.jsxs)("div",{className:"flex-1",children:[(0,r.jsx)("h3",{className:"font-semibold mb-1",children:"Import Token"}),(0,r.jsx)("p",{className:"text-sm text-text-muted",children:"Paste refresh token from Kiro IDE."})]})]})})]}),"idc"===l&&(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsxs)("div",{children:[(0,r.jsxs)("label",{className:"block text-sm font-medium mb-2",children:["IDC Start URL ",(0,r.jsx)("span",{className:"text-red-500",children:"*"})]}),(0,r.jsx)(c.default,{value:d,onChange:e=>x(e.target.value),placeholder:"https://your-org.awsapps.com/start",className:"font-mono text-sm"}),(0,r.jsx)("p",{className:"text-xs text-text-muted mt-1",children:"Your organization's AWS IAM Identity Center URL"})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:"block text-sm font-medium mb-2",children:"AWS Region"}),(0,r.jsx)(c.default,{value:m,onChange:e=>u(e.target.value),placeholder:"us-east-1",className:"font-mono text-sm"}),(0,r.jsx)("p",{className:"text-xs text-text-muted mt-1",children:"AWS region for your Identity Center (default: us-east-1)"})]}),b&&(0,r.jsx)("p",{className:"text-sm text-red-600",children:b}),(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsx)(o.default,{onClick:()=>{d.trim()?t("idc",{startUrl:d.trim(),region:m}):f("Please enter your IDC start URL")},fullWidth:!0,children:"Continue"}),(0,r.jsx)(o.default,{onClick:C,variant:"ghost",fullWidth:!0,children:"Back"})]})]}),"social-google"===l&&(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsx)("div",{className:"bg-amber-50 dark:bg-amber-900/20 p-4 rounded-lg border border-amber-200 dark:border-amber-800",children:(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsx)("span",{className:"material-symbols-outlined text-amber-600 dark:text-amber-400",children:"info"}),(0,r.jsxs)("div",{className:"flex-1 text-sm",children:[(0,r.jsx)("p",{className:"font-medium text-amber-900 dark:text-amber-100 mb-1",children:"Manual Callback Required"}),(0,r.jsx)("p",{className:"text-amber-800 dark:text-amber-200",children:"After login, you'll need to copy the callback URL from your browser and paste it back here."})]})]})}),(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsx)(o.default,{onClick:()=>T("google"),fullWidth:!0,children:"Continue with Google"}),(0,r.jsx)(o.default,{onClick:C,variant:"ghost",fullWidth:!0,children:"Back"})]})]}),"social-github"===l&&(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsx)("div",{className:"bg-amber-50 dark:bg-amber-900/20 p-4 rounded-lg border border-amber-200 dark:border-amber-800",children:(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsx)("span",{className:"material-symbols-outlined text-amber-600 dark:text-amber-400",children:"info"}),(0,r.jsxs)("div",{className:"flex-1 text-sm",children:[(0,r.jsx)("p",{className:"font-medium text-amber-900 dark:text-amber-100 mb-1",children:"Manual Callback Required"}),(0,r.jsx)("p",{className:"text-amber-800 dark:text-amber-200",children:"After login, you'll need to copy the callback URL from your browser and paste it back here."})]})]})}),(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsx)(o.default,{onClick:()=>T("github"),fullWidth:!0,children:"Continue with GitHub"}),(0,r.jsx)(o.default,{onClick:C,variant:"ghost",fullWidth:!0,children:"Back"})]})]}),"import"===l&&(0,r.jsxs)("div",{className:"space-y-4",children:[j&&(0,r.jsxs)("div",{className:"text-center py-6",children:[(0,r.jsx)("div",{className:"size-16 mx-auto mb-4 rounded-full bg-primary/10 flex items-center justify-center",children:(0,r.jsx)("span",{className:"material-symbols-outlined text-3xl text-primary animate-spin",children:"progress_activity"})}),(0,r.jsx)("h3",{className:"text-lg font-semibold mb-2",children:"Auto-detecting token..."}),(0,r.jsx)("p",{className:"text-sm text-text-muted",children:"Reading from AWS SSO cache"})]}),!j&&(0,r.jsxs)(r.Fragment,{children:[N&&(0,r.jsx)("div",{className:"bg-green-50 dark:bg-green-900/20 p-3 rounded-lg border border-green-200 dark:border-green-800",children:(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsx)("span",{className:"material-symbols-outlined text-green-600 dark:text-green-400",children:"check_circle"}),(0,r.jsx)("p",{className:"text-sm text-green-800 dark:text-green-200",children:"Token auto-detected from Kiro IDE successfully!"})]})}),!N&&!b&&(0,r.jsx)("div",{className:"bg-blue-50 dark:bg-blue-900/20 p-3 rounded-lg border border-blue-200 dark:border-blue-800",children:(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsx)("span",{className:"material-symbols-outlined text-blue-600 dark:text-blue-400",children:"info"}),(0,r.jsx)("p",{className:"text-sm text-blue-800 dark:text-blue-200",children:"Kiro IDE not detected. Please paste your refresh token manually."})]})}),(0,r.jsxs)("div",{children:[(0,r.jsxs)("label",{className:"block text-sm font-medium mb-2",children:["Refresh Token ",(0,r.jsx)("span",{className:"text-red-500",children:"*"})]}),(0,r.jsx)(c.default,{value:p,onChange:e=>h(e.target.value),placeholder:"Token will be auto-filled...",className:"font-mono text-sm"})]}),b&&(0,r.jsx)("div",{className:"bg-red-50 dark:bg-red-900/20 p-3 rounded-lg border border-red-200 dark:border-red-800",children:(0,r.jsx)("p",{className:"text-sm text-red-600 dark:text-red-400",children:b})}),(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsx)(o.default,{onClick:S,fullWidth:!0,disabled:g||!p.trim(),children:g?"Importing...":"Import Token"}),(0,r.jsx)(o.default,{onClick:C,variant:"ghost",fullWidth:!0,children:"Back"})]})]})]})]})})}d.propTypes={isOpen:n().bool.isRequired,onMethodSelect:n().func.isRequired,onClose:n().func.isRequired}},6261:(e,t,s)=>{s.d(t,{default:()=>n});var r=s(95155),a=s(97550),l=s(67040);function n({className:e,variant:t="default"}){let{theme:s,toggleTheme:n,isDark:i}=(0,a.D)(),o={default:(0,l.cn)("flex items-center justify-center size-10 rounded-full","text-text-muted","hover:bg-black/5","hover:text-text-main","transition-colors"),card:(0,l.cn)("flex items-center justify-center size-11 rounded-full","bg-surface/60","hover:bg-surface","border border-border","backdrop-blur-md shadow-sm hover:shadow-md","text-text-muted-light hover:text-primary","hover:text-primary","transition-all group")};return(0,r.jsx)("button",{onClick:n,className:(0,l.cn)(o[t],e),"aria-label":`Switch to ${i?"light":"dark"} mode`,title:`Switch to ${i?"light":"dark"} mode`,children:(0,r.jsx)("span",{className:(0,l.cn)("material-symbols-outlined text-[22px]","card"===t&&"transition-transform duration-300 group-hover:rotate-12"),children:i?"light_mode":"dark_mode"})})}},8287:(e,t,s)=>{s.d(t,{default:()=>m});var r=s(95155),a=s(12115),l=s(81060),n=s(99333),i=s(8898);function o({log:e,onClose:t}){(0,a.useEffect)(()=>{let e=e=>{"Escape"===e.key&&t()};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[t]);let s=(0,n.Yh)(e.status),l=n.Gp[e.proxy?.type]||{bg:"#6B7280",text:"#fff",label:e.proxy?.type||"-"},o=n.Ie[e.level]||n.Ie.direct,c=n.RY[e.provider]||{bg:"#374151",text:"#fff",label:(e.provider||"-").toUpperCase()};return(0,r.jsxs)("div",{className:"fixed inset-0 z-50 flex items-start justify-center pt-[5vh]",onClick:t,role:"dialog","aria-modal":"true","aria-label":"Proxy log detail",children:[(0,r.jsx)("div",{className:"absolute inset-0 bg-black/60 backdrop-blur-sm"}),(0,r.jsxs)("div",{className:"relative bg-bg-primary border border-border rounded-xl w-full max-w-[700px] max-h-[90vh] 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-6 py-4 border-b border-border bg-bg-primary/95 backdrop-blur-sm rounded-t-xl",children:[(0,r.jsxs)("div",{className:"flex items-center gap-3",children:[(0,r.jsx)("span",{className:"inline-block px-2.5 py-1 rounded text-xs font-bold uppercase",style:{backgroundColor:s.bg,color:s.text},children:e.status}),(0,r.jsx)("span",{className:"font-bold text-lg",children:"Proxy Event"})]}),(0,r.jsx)("button",{onClick:t,className:"p-1.5 rounded-lg hover:bg-bg-subtle text-text-muted hover:text-text-primary transition-colors","aria-label":"Close proxy detail modal",children:(0,r.jsx)("span",{className:"material-symbols-outlined",children:"close"})})]}),(0,r.jsxs)("div",{className:"p-6 flex flex-col gap-6",children:[(0,r.jsxs)("div",{className:"grid grid-cols-2 md:grid-cols-3 gap-4 p-4 bg-bg-subtle rounded-xl border border-border",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("div",{className:"text-[10px] text-text-muted uppercase tracking-wider mb-1",children:"Time"}),(0,r.jsx)("div",{className:"text-sm font-medium",children:(e=>{try{let t=new Date(e);return t.toLocaleDateString("pt-BR")+", "+t.toLocaleTimeString("en-US",{hour12:!1})}catch{return e}})(e.timestamp)})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("div",{className:"text-[10px] text-text-muted uppercase tracking-wider mb-1",children:"Latency"}),(0,r.jsx)("div",{className:"text-sm font-medium",children:(0,i.a3)(e.latencyMs)})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("div",{className:"text-[10px] text-text-muted uppercase tracking-wider mb-1",children:"Public IP"}),(0,r.jsx)("div",{className:"text-sm font-medium font-mono text-emerald-400",children:e.publicIp||"—"})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("div",{className:"text-[10px] text-text-muted uppercase tracking-wider mb-1",children:"Proxy"}),(0,r.jsx)("div",{className:"text-sm font-medium font-mono text-primary",children:e.proxy?`${e.proxy.type}://${e.proxy.host}:${e.proxy.port}`:"Direct"})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("div",{className:"text-[10px] text-text-muted uppercase tracking-wider mb-1",children:"Type"}),(0,r.jsx)("span",{className:"inline-block px-2.5 py-1 rounded text-[10px] font-bold uppercase",style:{backgroundColor:l.bg,color:l.text},children:l.label})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("div",{className:"text-[10px] text-text-muted uppercase tracking-wider mb-1",children:"Level"}),(0,r.jsx)("span",{className:"inline-block px-2.5 py-1 rounded text-[10px] font-bold uppercase",style:{backgroundColor:o.bg,color:o.text},children:o.label})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("div",{className:"text-[10px] text-text-muted uppercase tracking-wider mb-1",children:"Provider"}),e.provider?(0,r.jsx)("span",{className:"inline-block px-2.5 py-1 rounded text-[10px] font-bold uppercase",style:{backgroundColor:c.bg,color:c.text},children:c.label}):(0,r.jsx)("div",{className:"text-sm text-text-muted",children:"—"})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("div",{className:"text-[10px] text-text-muted uppercase tracking-wider mb-1",children:"TLS Fingerprint"}),e.tlsFingerprint?(0,r.jsxs)("span",{className:"inline-flex items-center gap-1 px-2.5 py-1 rounded text-[10px] font-bold uppercase",style:{backgroundColor:"rgba(6, 182, 212, 0.15)",color:"#22d3ee"},children:[(0,r.jsx)("span",{style:{fontSize:"12px"},children:"\uD83D\uDD12"})," Chrome 124"]}):(0,r.jsx)("div",{className:"text-sm text-text-muted",children:"Direct (native)"})]}),(0,r.jsxs)("div",{className:"col-span-2",children:[(0,r.jsx)("div",{className:"text-[10px] text-text-muted uppercase tracking-wider mb-1",children:"Target URL"}),(0,r.jsx)("div",{className:"text-sm font-medium font-mono text-text-muted break-all",children:e.targetUrl||"—"})]})]}),e.error&&(0,r.jsxs)("div",{className:"p-4 rounded-xl bg-red-500/10 border border-red-500/30",children:[(0,r.jsx)("div",{className:"text-[10px] text-red-400 uppercase tracking-wider mb-1 font-bold",children:"Error"}),(0,r.jsx)("div",{className:"text-sm text-red-300 font-mono",children:e.error})]}),e.proxy&&(0,r.jsxs)("div",{className:"p-4 rounded-xl bg-bg-subtle border border-border",children:[(0,r.jsx)("div",{className:"text-[10px] text-text-muted uppercase tracking-wider mb-2 font-bold",children:"Proxy Configuration"}),(0,r.jsx)("pre",{className:"text-xs font-mono text-text-primary bg-black/20 rounded-lg p-3 overflow-x-auto",children:JSON.stringify(e.proxy,null,2)})]})]})]})]})}let c=[{key:"all",label:"All"},{key:"error",label:"Errors",icon:"error"},{key:"ok",label:"Success",icon:"check_circle"},{key:"timeout",label:"Timeout",icon:"timer_off"}],d=[{key:"status",label:"Status"},{key:"proxy",label:"Proxy"},{key:"tls",label:"TLS"},{key:"type",label:"Type"},{key:"level",label:"Level"},{key:"provider",label:"Provider"},{key:"target",label:"Target"},{key:"latency",label:"Latency"},{key:"ip",label:"Public IP"},{key:"time",label:"Time"}],x=Object.fromEntries(d.map(e=>[e.key,!0]));function m(){let[e,t]=(0,a.useState)([]),[s,m]=(0,a.useState)(!0),[u,p]=(0,a.useState)(!0),[h,b]=(0,a.useState)(""),[f,g]=(0,a.useState)("all"),[y,j]=(0,a.useState)(""),[v,N]=(0,a.useState)(""),[k,w]=(0,a.useState)(""),[C,S]=(0,a.useState)("newest"),[T,I]=(0,a.useState)(null),O=(0,a.useRef)(null),R=(0,a.useRef)(!1),[E,L]=(0,a.useState)(()=>{try{let e=localStorage.getItem("proxyLoggerVisibleColumns");return e?{...x,...JSON.parse(e)}:x}catch{return x}}),A=(0,a.useCallback)(e=>{L(t=>{let s={...t,[e]:!t[e]};try{localStorage.setItem("proxyLoggerVisibleColumns",JSON.stringify(s))}catch{}return s})},[]),_=(0,a.useCallback)(async(e=!1)=>{e&&m(!0);try{let e=new URLSearchParams;h&&e.set("search",h),"error"===f&&e.set("status","error"),"ok"===f&&e.set("status","ok"),"timeout"===f&&e.set("status","timeout"),y&&e.set("type",y),v&&e.set("provider",v),k&&e.set("level",k),e.set("limit","300");let s=await fetch(`/api/usage/proxy-logs?${e}`);if(s.ok){let e=await s.json();t(e)}}catch(e){console.error("Failed to fetch proxy logs:",e)}finally{e&&m(!1)}},[h,f,y,v,k]);(0,a.useEffect)(()=>{let e=!R.current;R.current=!0,_(e)},[_]),(0,a.useEffect)(()=>(O.current&&clearInterval(O.current),u&&(O.current=setInterval(()=>_(!1),3e3)),()=>{O.current&&clearInterval(O.current)}),[u,_]);let M=(0,a.useMemo)(()=>{let t=[...e];return t.sort((e,t)=>{switch(C){case"oldest":return new Date(e.timestamp).getTime()-new Date(t.timestamp).getTime();case"latency_desc":return(t.latencyMs||0)-(e.latencyMs||0);case"latency_asc":return(e.latencyMs||0)-(t.latencyMs||0);default:return new Date(t.timestamp).getTime()-new Date(e.timestamp).getTime()}}),t},[e,C]),$=[...new Set(e.map(e=>e.provider).filter(Boolean))].sort(),P=[...new Set(e.map(e=>e.proxy?.type).filter(Boolean))].sort(),D=[...new Set(e.map(e=>e.level).filter(Boolean))].sort(),F=e.length,z=e.filter(e=>"success"===e.status).length,K=e.filter(e=>"error"===e.status).length,U=e.filter(e=>"timeout"===e.status).length,B=e.filter(e=>"direct"===e.level).length,q=e.filter(e=>e.tlsFingerprint).length;return(0,r.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,r.jsxs)("div",{className:"flex flex-wrap items-center gap-3",children:[(0,r.jsxs)("button",{onClick:()=>p(!u),className:`flex items-center gap-2 px-3 py-1.5 rounded-full text-sm font-medium border transition-colors ${u?"bg-red-500/10 border-red-500/30 text-red-400":"bg-bg-subtle border-border text-text-muted"}`,children:[(0,r.jsx)("span",{className:`w-2 h-2 rounded-full ${u?"bg-red-500 animate-pulse":"bg-text-muted"}`}),u?"Recording":"Paused"]}),(0,r.jsxs)("div",{className:"flex-1 min-w-[200px] relative",children:[(0,r.jsx)("span",{className:"material-symbols-outlined absolute left-3 top-1/2 -translate-y-1/2 text-text-muted text-[18px]",children:"search"}),(0,r.jsx)("input",{type:"text",placeholder:"Search host, provider, target, IP...",value:h,onChange:e=>b(e.target.value),className:"w-full pl-10 pr-4 py-2 rounded-lg bg-bg-subtle border border-border text-sm text-text-primary placeholder:text-text-muted focus:outline-none focus:border-primary"})]}),(0,r.jsxs)("select",{value:y,onChange:e=>j(e.target.value),className:"px-3 py-2 rounded-lg bg-bg-subtle border border-border text-sm text-text-primary focus:outline-none focus:border-primary appearance-none cursor-pointer min-w-[120px]",children:[(0,r.jsx)("option",{value:"",children:"All Types"}),P.map(e=>(0,r.jsx)("option",{value:e,children:(n.Gp[e]?.label||e).toUpperCase()},e))]}),(0,r.jsxs)("select",{value:k,onChange:e=>w(e.target.value),className:"px-3 py-2 rounded-lg bg-bg-subtle border border-border text-sm text-text-primary focus:outline-none focus:border-primary appearance-none cursor-pointer min-w-[120px]",children:[(0,r.jsx)("option",{value:"",children:"All Levels"}),D.map(e=>(0,r.jsx)("option",{value:e,children:n.Ie[e]?.label||e},e))]}),(0,r.jsxs)("select",{value:v,onChange:e=>N(e.target.value),className:"px-3 py-2 rounded-lg bg-bg-subtle border border-border text-sm text-text-primary focus:outline-none focus:border-primary appearance-none cursor-pointer min-w-[140px]",children:[(0,r.jsx)("option",{value:"",children:"All Providers"}),$.map(e=>{let t=n.RY[e];return(0,r.jsx)("option",{value:e,children:t?.label||e.toUpperCase()},e)})]}),(0,r.jsxs)("div",{className:"flex items-center gap-2 text-xs text-text-muted",children:[(0,r.jsxs)("span",{className:"px-2 py-1 rounded bg-bg-subtle border border-border font-mono",children:[F," total"]}),(0,r.jsxs)("span",{className:"px-2 py-1 rounded bg-emerald-500/10 text-emerald-400 font-mono",children:[z," OK"]}),K>0&&(0,r.jsxs)("span",{className:"px-2 py-1 rounded bg-red-500/10 text-red-400 font-mono",children:[K," ERR"]}),U>0&&(0,r.jsxs)("span",{className:"px-2 py-1 rounded bg-amber-500/10 text-amber-400 font-mono",children:[U," TMO"]}),B>0&&(0,r.jsxs)("span",{className:"px-2 py-1 rounded bg-gray-500/10 text-gray-400 font-mono",children:[B," direct"]}),q>0&&(0,r.jsxs)("span",{className:"px-2 py-1 rounded bg-cyan-500/10 text-cyan-400 font-mono",children:["\uD83D\uDD12 ",q," TLS"]})]}),(0,r.jsxs)("select",{value:C,onChange:e=>S(e.target.value),className:"px-3 py-2 rounded-lg bg-bg-subtle border border-border text-sm text-text-primary focus:outline-none focus:border-primary appearance-none cursor-pointer min-w-[140px]",children:[(0,r.jsx)("option",{value:"newest",children:"Newest"}),(0,r.jsx)("option",{value:"oldest",children:"Oldest"}),(0,r.jsx)("option",{value:"latency_desc",children:"Latency ↓"}),(0,r.jsx)("option",{value:"latency_asc",children:"Latency ↑"})]}),(0,r.jsx)("button",{onClick:()=>_(!1),className:"p-2 rounded-lg hover:bg-bg-subtle text-text-muted hover:text-text-primary transition-colors",title:"Refresh",children:(0,r.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:"refresh"})})]}),(0,r.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[c.map(e=>(0,r.jsxs)("button",{onClick:()=>g(f===e.key?"all":e.key),className:`flex items-center gap-1.5 px-3 py-1 rounded-full text-xs font-medium border transition-all ${f===e.key?"error"===e.key?"bg-red-500/20 text-red-400 border-red-500/40":"ok"===e.key?"bg-emerald-500/20 text-emerald-400 border-emerald-500/40":"timeout"===e.key?"bg-amber-500/20 text-amber-400 border-amber-500/40":"bg-primary text-white border-primary":"bg-bg-subtle border-border text-text-muted hover:border-text-muted"}`,children:[e.icon&&(0,r.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:e.icon}),e.label]},e.key)),$.length>0&&(0,r.jsx)("span",{className:"w-px h-5 bg-border mx-1"}),$.map(e=>{let t=n.RY[e]||{bg:"#374151",text:"#fff",label:e.toUpperCase()},s=v===e;return(0,r.jsx)("button",{onClick:()=>N(s?"":e),className:`px-3 py-1 rounded-full text-xs font-bold uppercase border transition-all ${s?"border-white/40 ring-1 ring-white/20":"border-transparent opacity-70 hover:opacity-100"}`,style:{backgroundColor:s?t.bg:`${t.bg}33`,color:s?t.text:t.bg},children:t.label},e)})]}),(0,r.jsxs)("div",{className:"flex flex-wrap items-center gap-1.5",children:[(0,r.jsx)("span",{className:"text-[10px] text-text-muted uppercase tracking-wider mr-1",children:"Columns"}),d.map(e=>(0,r.jsx)("button",{onClick:()=>A(e.key),className:`px-2 py-0.5 rounded text-[10px] font-medium border transition-all ${E[e.key]?"bg-primary/15 text-primary border-primary/30":"bg-bg-subtle text-text-muted border-border opacity-50 hover:opacity-80"}`,children:e.label},e.key))]}),(0,r.jsx)(l.default,{className:"overflow-hidden bg-black/5 dark:bg-black/20",children:(0,r.jsx)("div",{className:"p-0 overflow-x-auto max-h-[calc(100vh-320px)] overflow-y-auto",children:s&&0===e.length?(0,r.jsx)("div",{className:"p-8 text-center text-text-muted",children:"Loading proxy logs..."}):0===e.length?(0,r.jsxs)("div",{className:"p-8 text-center text-text-muted",children:[(0,r.jsx)("span",{className:"material-symbols-outlined text-[48px] mb-2 block opacity-40",children:"vpn_lock"}),"No proxy logs yet. Configure proxies and make API calls to see them here."]}):0===M.length?(0,r.jsx)("div",{className:"p-8 text-center text-text-muted",children:"No logs match the current filters."}):(0,r.jsxs)("table",{className:"w-full text-left border-collapse text-xs",children:[(0,r.jsx)("thead",{className:"sticky top-0 z-10",style:{backgroundColor:"var(--bg-primary, #0f1117)"},children:(0,r.jsxs)("tr",{className:"border-b border-border",style:{backgroundColor:"var(--bg-primary, #0f1117)"},children:[E.status&&(0,r.jsx)("th",{className:"px-3 py-2.5 font-semibold text-text-muted uppercase tracking-wider text-[10px]",children:"Status"}),E.proxy&&(0,r.jsx)("th",{className:"px-3 py-2.5 font-semibold text-text-muted uppercase tracking-wider text-[10px]",children:"Proxy"}),E.tls&&(0,r.jsx)("th",{className:"px-3 py-2.5 font-semibold text-text-muted uppercase tracking-wider text-[10px]",children:"TLS"}),E.type&&(0,r.jsx)("th",{className:"px-3 py-2.5 font-semibold text-text-muted uppercase tracking-wider text-[10px]",children:"Type"}),E.level&&(0,r.jsx)("th",{className:"px-3 py-2.5 font-semibold text-text-muted uppercase tracking-wider text-[10px]",children:"Level"}),E.provider&&(0,r.jsx)("th",{className:"px-3 py-2.5 font-semibold text-text-muted uppercase tracking-wider text-[10px]",children:"Provider"}),E.target&&(0,r.jsx)("th",{className:"px-3 py-2.5 font-semibold text-text-muted uppercase tracking-wider text-[10px]",children:"Target"}),E.latency&&(0,r.jsx)("th",{className:"px-3 py-2.5 font-semibold text-text-muted uppercase tracking-wider text-[10px] text-right",children:"Latency"}),E.ip&&(0,r.jsx)("th",{className:"px-3 py-2.5 font-semibold text-text-muted uppercase tracking-wider text-[10px]",children:"Public IP"}),E.time&&(0,r.jsx)("th",{className:"px-3 py-2.5 font-semibold text-text-muted uppercase tracking-wider text-[10px] text-right",children:"Time"})]})}),(0,r.jsx)("tbody",{className:"divide-y divide-border/30",children:M.map(e=>{let t=(0,n.Yh)(e.status),s=n.Gp[e.proxy?.type]||{bg:"#6B7280",text:"#fff",label:e.proxy?.type||"-"},a=n.Ie[e.level]||n.Ie.direct,l=n.RY[e.provider]||{bg:"#374151",text:"#fff",label:(e.provider||"-").toUpperCase()},o="error"===e.status||"timeout"===e.status;return(0,r.jsxs)("tr",{onClick:()=>I(T?.id===e.id?null:e),className:`cursor-pointer hover:bg-primary/5 transition-colors ${o?"bg-red-500/5":""}`,children:[E.status&&(0,r.jsx)("td",{className:"px-3 py-2",children:(0,r.jsx)("span",{className:"inline-block px-2 py-0.5 rounded text-[10px] font-bold min-w-[50px] text-center uppercase",style:{backgroundColor:t.bg,color:t.text},children:e.status})}),E.proxy&&(0,r.jsx)("td",{className:"px-3 py-2 font-mono text-[11px] text-primary",children:e.proxy?`${e.proxy.host}:${e.proxy.port}`:"—"}),E.tls&&(0,r.jsx)("td",{className:"px-3 py-2",children:e.tlsFingerprint?(0,r.jsxs)("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 rounded text-[9px] font-bold uppercase",style:{backgroundColor:"rgba(6, 182, 212, 0.15)",color:"#22d3ee"},title:"Chrome 124 TLS Fingerprint",children:[(0,r.jsx)("span",{style:{fontSize:"10px"},children:"\uD83D\uDD12"})," TLS"]}):(0,r.jsx)("span",{className:"text-text-muted text-[10px]",children:"—"})}),E.type&&(0,r.jsx)("td",{className:"px-3 py-2",children:(0,r.jsx)("span",{className:"inline-block px-2 py-0.5 rounded text-[9px] font-bold uppercase",style:{backgroundColor:s.bg,color:s.text},children:s.label})}),E.level&&(0,r.jsx)("td",{className:"px-3 py-2",children:(0,r.jsx)("span",{className:"inline-block px-2 py-0.5 rounded text-[9px] font-bold uppercase",style:{backgroundColor:a.bg,color:a.text},children:a.label})}),E.provider&&(0,r.jsx)("td",{className:"px-3 py-2",children:e.provider?(0,r.jsx)("span",{className:"inline-block px-2 py-0.5 rounded text-[9px] font-bold uppercase",style:{backgroundColor:l.bg,color:l.text},children:l.label}):(0,r.jsx)("span",{className:"text-text-muted text-[10px]",children:"—"})}),E.target&&(0,r.jsx)("td",{className:"px-3 py-2 text-text-muted truncate max-w-[200px] font-mono text-[10px]",title:e.targetUrl,children:(0,i.Y1)(e.targetUrl)}),E.latency&&(0,r.jsx)("td",{className:"px-3 py-2 text-right text-text-muted font-mono",children:(0,i.a3)(e.latencyMs)}),E.ip&&(0,r.jsx)("td",{className:"px-3 py-2 font-mono text-[11px] text-emerald-400",children:e.publicIp||"—"}),E.time&&(0,r.jsx)("td",{className:"px-3 py-2 text-right text-text-muted",children:(0,i.fU)(e.timestamp)})]},e.id)})})]})})}),T&&(0,r.jsx)(o,{log:T,onClose:()=>I(null)})]})}},8898:(e,t,s)=>{function r(e){try{return new Date(e).toLocaleTimeString("en-US",{hour12:!1,hour:"2-digit",minute:"2-digit",second:"2-digit"})}catch{return"-"}}function a(e){return e?e<1e3?`${e}ms`:`${(e/1e3).toFixed(1)}s`:"-"}function l(e){if(!e||"-"===e)return"-";let t=e.indexOf("@");return t>3?e.slice(0,3)+"***"+e.slice(t):e.length>8?e.slice(0,5)+"***":e}function n(e,t){if(!e&&!t)return"—";let s=e||"key";return t?`${s} (${function(e,t=2,s=2){return e?e.length<=t+s?`${e.slice(0,1)}***`:`${e.slice(0,t)}***${e.slice(-s)}`:""}(t,4,4)})`:s}function i(e){return e>=1e9?`${(e/1e9).toFixed(1)}B`:e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}K`:new Intl.NumberFormat().format(e||0)}function o(e){return new Intl.NumberFormat().format(e||0)}function c(e){return`$${(e||0).toFixed(2)}`}function d(e,t=50){if(!e)return"-";try{let s=new URL(e),r=s.hostname+s.pathname;return r.length>t?r.slice(0,t)+"…":r}catch{return e.length>t?e.slice(0,t)+"…":e}}s.d(t,{F0:()=>c,Ib:()=>l,VK:()=>i,VO:()=>n,Y1:()=>d,a3:()=>a,fU:()=>r,xW:()=>o})},17705:(e,t,s)=>{s.d(t,{default:()=>l});var r=s(95155),a=s(67040);function l({src:e,alt:t="Avatar",name:s,size:l="md",className:n}){let i={xs:"size-6 text-xs",sm:"size-8 text-sm",md:"size-10 text-base",lg:"size-12 text-lg",xl:"size-16 text-xl"};return e?(0,r.jsx)("div",{className:(0,a.cn)("rounded-full bg-cover bg-center bg-no-repeat","ring-2 ring-white dark:ring-surface-dark shadow-sm",i[l],n),style:{backgroundImage:`url(${e})`},role:"img","aria-label":t}):(0,r.jsx)("div",{className:(0,a.cn)("rounded-full flex items-center justify-center font-semibold text-white","ring-2 ring-white dark:ring-surface-dark shadow-sm",i[l],(e=>{if(!e)return"bg-primary";let t=["bg-red-500","bg-orange-500","bg-amber-500","bg-yellow-500","bg-lime-500","bg-green-500","bg-emerald-500","bg-teal-500","bg-cyan-500","bg-sky-500","bg-blue-500","bg-indigo-500","bg-violet-500","bg-purple-500","bg-fuchsia-500","bg-pink-500","bg-rose-500"],s=e.charCodeAt(0)%t.length;return t[s]})(s),n),role:"img","aria-label":t,children:(e=>{if(!e)return"?";let t=e.split(" ");return t.length>=2?`${t[0][0]}${t[1][0]}`.toUpperCase():e.substring(0,2).toUpperCase()})(s)})}},18150:(e,t,s)=>{s.d(t,{default:()=>x});var r=s(95155),a=s(12115),l=s(14051),n=s.n(l),i=s(71361),o=s(35806),c=s(34422),d=s(30949);function x({isOpen:e,provider:t,onSuccess:s,onClose:l}){let[n,x]=(0,a.useState)("loading"),[m,u]=(0,a.useState)(""),[p,h]=(0,a.useState)(null),[b,f]=(0,a.useState)(""),[g,y]=(0,a.useState)(null),{copied:j,copy:v}=(0,d.C)();(0,a.useEffect)(()=>{e&&t&&(async()=>{try{y(null),x("loading");let e=await fetch(`/api/oauth/kiro/social-authorize?provider=${t}`),s=await e.json();if(!e.ok)throw Error(s.error);h(s),u(s.authUrl),x("input"),window.open(s.authUrl,"kiro_social_auth")}catch(e){y(e.message),x("error")}})()},[e,t]);let N=async()=>{try{let e;y(null);try{e=new URL(b)}catch(e){throw Error("Invalid callback URL format")}let r=e.searchParams.get("code");e.searchParams.get("state");let a=e.searchParams.get("error");if(a)throw Error(e.searchParams.get("error_description")||a);if(!r)throw Error("No authorization code found in URL");let l=await fetch("/api/oauth/kiro/social-exchange",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({code:r,codeVerifier:p.codeVerifier,provider:t})}),n=await l.json();if(!l.ok)throw Error(n.error);x("success"),s?.()}catch(e){y(e.message),x("error")}},k="google"===t?"Google":"GitHub";return(0,r.jsx)(i.default,{isOpen:e,title:`Connect Kiro via ${k}`,onClose:l,size:"lg",children:(0,r.jsxs)("div",{className:"flex flex-col gap-4",children:["loading"===n&&(0,r.jsxs)("div",{className:"text-center py-6",children:[(0,r.jsx)("div",{className:"size-16 mx-auto mb-4 rounded-full bg-primary/10 flex items-center justify-center",children:(0,r.jsx)("span",{className:"material-symbols-outlined text-3xl text-primary animate-spin",children:"progress_activity"})}),(0,r.jsx)("h3",{className:"text-lg font-semibold mb-2",children:"Initializing..."}),(0,r.jsxs)("p",{className:"text-sm text-text-muted",children:["Setting up ",k," authentication"]})]}),"input"===n&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("p",{className:"text-sm font-medium mb-2",children:"Step 1: Open this URL in your browser"}),(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsx)(c.default,{value:m,readOnly:!0,className:"flex-1 font-mono text-xs"}),(0,r.jsx)(o.default,{variant:"secondary",icon:"auth_url"===j?"check":"content_copy",onClick:()=>v(m,"auth_url"),children:"Copy"})]})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("p",{className:"text-sm font-medium mb-2",children:"Step 2: Paste the callback URL here"}),(0,r.jsx)("p",{className:"text-xs text-text-muted mb-2",children:"After authorization, copy the full URL from your browser address bar."}),(0,r.jsx)(c.default,{value:b,onChange:e=>f(e.target.value),placeholder:"kiro://kiro.kiroAgent/authenticate-success?code=...",className:"font-mono text-xs"})]})]}),(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsx)(o.default,{onClick:N,fullWidth:!0,disabled:!b,children:"Connect"}),(0,r.jsx)(o.default,{onClick:l,variant:"ghost",fullWidth:!0,children:"Cancel"})]})]}),"success"===n&&(0,r.jsxs)("div",{className:"text-center py-6",children:[(0,r.jsx)("div",{className:"size-16 mx-auto mb-4 rounded-full bg-green-100 dark:bg-green-900/30 flex items-center justify-center",children:(0,r.jsx)("span",{className:"material-symbols-outlined text-3xl text-green-600",children:"check_circle"})}),(0,r.jsx)("h3",{className:"text-lg font-semibold mb-2",children:"Connected Successfully!"}),(0,r.jsxs)("p",{className:"text-sm text-text-muted mb-4",children:["Your Kiro account via ",k," has been connected."]}),(0,r.jsx)(o.default,{onClick:l,fullWidth:!0,children:"Done"})]}),"error"===n&&(0,r.jsxs)("div",{className:"text-center py-6",children:[(0,r.jsx)("div",{className:"size-16 mx-auto mb-4 rounded-full bg-red-100 dark:bg-red-900/30 flex items-center justify-center",children:(0,r.jsx)("span",{className:"material-symbols-outlined text-3xl text-red-600",children:"error"})}),(0,r.jsx)("h3",{className:"text-lg font-semibold mb-2",children:"Connection Failed"}),(0,r.jsx)("p",{className:"text-sm text-red-600 mb-4",children:g}),(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsx)(o.default,{onClick:()=>x("input"),variant:"secondary",fullWidth:!0,children:"Try Again"}),(0,r.jsx)(o.default,{onClick:l,variant:"ghost",fullWidth:!0,children:"Cancel"})]})]})]})})}x.propTypes={isOpen:n().bool.isRequired,provider:n().oneOf(["google","github"]).isRequired,onSuccess:n().func,onClose:n().func.isRequired}},19790:(e,t,s)=>{s.d(t,{default:()=>l});var r=s(95155),a=s(67040);function l({checked:e=!1,onChange:t,label:s,description:l,disabled:n=!1,size:i="md",className:o}){let c={sm:{track:"w-8 h-4",thumb:"size-3",translate:"translate-x-4"},md:{track:"w-11 h-6",thumb:"size-5",translate:"translate-x-5"},lg:{track:"w-14 h-7",thumb:"size-6",translate:"translate-x-7"}};return(0,r.jsxs)("div",{className:(0,a.cn)("flex items-center gap-3",n&&"opacity-50 cursor-not-allowed",o),children:[(0,r.jsx)("button",{type:"button",role:"switch","aria-checked":e,"aria-label":s?void 0:l||"Toggle",disabled:n,onClick:()=>{!n&&t&&t(!e)},className:(0,a.cn)("relative inline-flex shrink-0 cursor-pointer rounded-full","transition-colors duration-200 ease-in-out","focus:outline-none focus:ring-1 focus:ring-primary/30",e?"bg-primary":"bg-black/10 dark:bg-white/20",c[i].track,n&&"cursor-not-allowed"),children:(0,r.jsx)("span",{"aria-hidden":"true",className:(0,a.cn)("pointer-events-none inline-block rounded-full bg-white shadow-sm","transform transition duration-200 ease-in-out",e?c[i].translate:"translate-x-0.5",c[i].thumb,"mt-0.5")})}),(s||l)&&(0,r.jsxs)("div",{className:"flex flex-col",children:[s&&(0,r.jsx)("span",{className:"text-sm font-medium text-text-main",children:s}),l&&(0,r.jsx)("span",{className:"text-xs text-text-muted",children:l})]})]})}},21720:(e,t,s)=>{s.d(t,{default:()=>x});var r=s(95155),a=s(12115),l=s(34243),n=s(89938),i=s(76332),o=s(61580);function c(){let[e,t]=(0,a.useState)(!1),[s,l]=(0,a.useState)(""),n=(0,a.useCallback)(async()=>{try{(await fetch("/api/monitoring/health",{signal:AbortSignal.timeout(3e3)})).ok?e&&(t(!1),l("")):(t(!0),l("Server is experiencing issues. Some features may be unavailable."))}catch{t(!0),l("Server is unreachable. Reconnecting...")}},[e]);return((0,a.useEffect)(()=>{let e=setInterval(n,1e4);return()=>clearInterval(e)},[n]),e)?(0,r.jsxs)("div",{className:"bg-amber-500/10 border-b border-amber-500/20 px-4 py-2.5 flex items-center justify-between gap-3 animate-in slide-in-from-top",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2.5",children:[(0,r.jsx)("span",{className:"material-symbols-outlined text-amber-500 text-[18px] animate-pulse",children:"warning"}),(0,r.jsx)("span",{className:"text-sm text-amber-200",children:s})]}),(0,r.jsx)("button",{onClick:()=>t(!1),className:"p-1 rounded hover:bg-white/5 text-text-muted hover:text-text-main transition-colors","aria-label":"Dismiss",children:(0,r.jsx)("span",{className:"material-symbols-outlined text-[16px]",children:"close"})})]}):null}let d="sidebar-collapsed";function x({children:e}){let[t,s]=(0,a.useState)(!1),[x,m]=(0,a.useState)(()=>{try{return"true"===localStorage.getItem(d)}catch{return!1}});return(0,r.jsxs)("div",{className:"flex h-screen w-full overflow-hidden bg-bg",children:[t&&(0,r.jsx)("div",{className:"fixed inset-0 z-40 bg-black/20 lg:hidden",onClick:()=>s(!1)}),(0,r.jsx)("div",{className:"hidden lg:flex",children:(0,r.jsx)(l.default,{collapsed:x,onToggleCollapse:()=>{let e=!x;m(e),localStorage.setItem(d,String(e))}})}),(0,r.jsx)("div",{className:`fixed inset-y-0 left-0 z-50 transform lg:hidden transition-transform duration-300 ease-in-out ${t?"translate-x-0":"-translate-x-full"}`,children:(0,r.jsx)(l.default,{onClose:()=>s(!1)})}),(0,r.jsxs)("main",{id:"main-content",className:"flex flex-col flex-1 h-full min-w-0 relative transition-colors duration-300",children:[(0,r.jsx)(n.default,{onMenuClick:()=>s(!0)}),(0,r.jsx)(c,{}),(0,r.jsx)("div",{className:"flex-1 overflow-y-auto custom-scrollbar p-6 lg:p-10",children:(0,r.jsxs)("div",{className:"max-w-7xl mx-auto",children:[(0,r.jsx)(i.default,{}),e]})})]}),(0,r.jsx)(o.default,{})]})}},25112:(e,t,s)=>{s.d(t,{default:()=>h});var r=s(95155),a=s(50910),l=s(12115),n=s(14051),i=s.n(n),o=s(73321),c=s(81060),d=s(80927),x=s(92542),m=s(8898);function u({field:e,currentSort:t,currentOrder:s}){return t!==e?(0,r.jsx)("span",{className:"ml-1 opacity-20",children:"↕"}):(0,r.jsx)("span",{className:"ml-1",children:"asc"===s?"↑":"↓"})}function p({data:e,colorClass:t="bg-primary"}){let s=Math.max(...e,1);return(0,r.jsx)("div",{className:"flex items-end gap-1 h-8 w-24",children:e.slice(-9).map((e,a)=>(0,r.jsx)("div",{className:`flex-1 rounded-t-sm transition-all duration-500 ${t}`,style:{height:`${Math.max(e/s*100,5)}%`},title:String(e)},`bar-${a}-${e}`))})}function h(){let e=(0,a.c)("stats"),t=(0,o.useRouter)(),s=(0,o.useSearchParams)(),n=s.get("sortBy")||"rawModel",i=s.get("sortOrder")||"asc",[h,b]=(0,l.useState)(null),[f,g]=(0,l.useState)(!0),[y,j]=(0,l.useState)(!0),[v,N]=(0,l.useState)("tokens"),[k,w]=(0,l.useState)(5e3),C=(0,l.useRef)(0),S=e=>{let r=new URLSearchParams(s.toString());n===e?r.set("sortOrder","asc"===i?"desc":"asc"):(r.set("sortBy",e),r.set("sortOrder","asc")),t.replace(`?${r.toString()}`,{scroll:!1})},T=(0,l.useCallback)((e,t={})=>Object.entries(e||{}).map(([e,s])=>{let r=(s.promptTokens||0)+(s.completionTokens||0),a=s.cost||0,l=r>0?(s.promptTokens||0)*(a/r):0,n=r>0?(s.completionTokens||0)*(a/r):0;return{...s,key:e,totalTokens:r,totalCost:a,inputCost:l,outputCost:n,pending:t[e]||0}}).sort((e,t)=>{let s=e[n],r=t[n];return("string"==typeof s&&(s=s.toLowerCase()),"string"==typeof r&&(r=r.toLowerCase()),s<r)?"asc"===i?-1:1:s>r?"asc"===i?1:-1:0}),[n,i]),I=(0,l.useMemo)(()=>T(h?.byModel,h?.pending?.byModel),[h?.byModel,h?.pending?.byModel,T]),O=(0,l.useMemo)(()=>{let e={};return h?.pending?.byAccount&&Object.entries(h.byAccount||{}).forEach(([t,s])=>{let r=h.pending.byAccount[s.connectionId];if(r){let a=s.provider?`${s.rawModel} (${s.provider})`:s.rawModel;e[t]=r[a]||0}}),T(h?.byAccount,e)},[h?.byAccount,h?.pending?.byAccount,T]),R=(0,l.useCallback)(async(e=!0)=>{e&&g(!0);try{let e=await fetch("/api/usage/history");if(e.ok){let t=await e.json();b(t);let s=t.totalRequests||0;s>C.current?w(5e3):w(e=>Math.min(2*e,6e4)),C.current=s}}catch(e){console.error("Failed to fetch usage stats:",e)}finally{e&&g(!1)}},[]);if((0,l.useEffect)(()=>{R()},[R]),(0,l.useEffect)(()=>{let e,t=!0,s=()=>{(t=!document.hidden)&&y&&R(!1)};return document.addEventListener("visibilitychange",s),y&&(e&&clearInterval(e),e=setInterval(()=>{t&&R(!1)},k)),()=>{e&&clearInterval(e),document.removeEventListener("visibilitychange",s)}},[y,k,R]),f)return(0,r.jsx)(x.CardSkeleton,{});if(!h)return(0,r.jsx)("div",{className:"text-text-muted",children:e("failedToLoad")});let E=e=>(0,m.xW)(e),L=e=>{if(!e)return"Never";let t=new Date(e),s=Math.floor((new Date().getTime()-t.getTime())/6e4);return s<1?"Just now":s<60?`${s}m ago`:s<1440?`${Math.floor(s/60)}h ago`:t.toLocaleDateString()};return(0,r.jsxs)("div",{className:"flex flex-col gap-6",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between",children:[(0,r.jsx)("h2",{className:"text-xl font-semibold",children:e("usageOverview")}),(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsxs)("div",{className:"flex items-center gap-1 bg-bg-subtle rounded-lg p-1 border border-border",children:[(0,r.jsx)("button",{onClick:()=>N("tokens"),className:`px-3 py-1 rounded-md text-sm font-medium transition-colors ${"tokens"===v?"bg-primary text-white shadow-sm":"text-text-muted hover:text-text hover:bg-bg-hover"}`,children:"Tokens"}),(0,r.jsx)("button",{onClick:()=>N("costs"),className:`px-3 py-1 rounded-md text-sm font-medium transition-colors ${"costs"===v?"bg-primary text-white shadow-sm":"text-text-muted hover:text-text hover:bg-bg-hover"}`,children:"Costs"})]}),(0,r.jsxs)("div",{className:"text-sm font-medium text-text-muted flex items-center gap-2",children:[(0,r.jsxs)("span",{children:["Auto Refresh (",k/1e3,"s)"]}),(0,r.jsx)("button",{type:"button",onClick:()=>j(!y),role:"switch","aria-checked":y,"aria-label":"Toggle auto refresh",className:`relative inline-flex h-5 w-9 items-center rounded-full transition-colors focus:outline-none focus:ring-2 focus:ring-primary/50 ${y?"bg-primary":"bg-bg-subtle border border-border"}`,children:(0,r.jsx)("span",{className:`inline-block h-3 w-3 transform rounded-full bg-white transition-transform ${y?"translate-x-5":"translate-x-1"}`})})]})]})]}),(h.activeRequests||[]).length>0&&(0,r.jsx)(c.default,{className:"p-3 border-primary/20 bg-primary/5",children:(0,r.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2 text-primary font-semibold text-sm uppercase tracking-wider",children:[(0,r.jsxs)("span",{className:"relative flex h-2 w-2",children:[(0,r.jsx)("span",{className:"animate-ping absolute inline-flex h-full w-full rounded-full bg-primary opacity-75"}),(0,r.jsx)("span",{className:"relative inline-flex rounded-full h-2 w-2 bg-primary"})]}),"Active Requests"]}),(0,r.jsx)("div",{className:"flex flex-wrap gap-3",children:h.activeRequests.map(e=>(0,r.jsxs)("div",{className:"px-3 py-1.5 rounded-md bg-bg-subtle border border-primary/20 text-xs font-mono shadow-sm",children:[(0,r.jsx)("span",{className:"text-primary font-bold",children:e.model}),(0,r.jsx)("span",{className:"mx-1 text-text-muted",children:"|"}),(0,r.jsx)("span",{className:"text-text",children:e.provider}),(0,r.jsx)("span",{className:"mx-1 text-text-muted",children:"|"}),(0,r.jsx)("span",{className:"text-text font-medium",children:e.account}),e.count>1&&(0,r.jsxs)("span",{className:"ml-2 px-1.5 py-0.5 rounded bg-primary text-white font-bold",children:["x",e.count]})]},`${e.model}-${e.provider}-${e.account}`))})]})}),(0,r.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[(0,r.jsx)(c.default,{className:"px-4 py-3 flex flex-col gap-1",children:(0,r.jsxs)("div",{className:"flex justify-between items-start",children:[(0,r.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,r.jsx)("span",{className:"text-text-muted text-sm uppercase font-semibold",children:"Total Requests"}),(0,r.jsx)("span",{className:"text-2xl font-bold",children:E(h.totalRequests)})]}),(0,r.jsx)(p,{data:(h.last10Minutes||[]).map(e=>e.requests),colorClass:"bg-text-muted/30"})]})}),(0,r.jsx)(c.default,{className:"px-4 py-3 flex flex-col gap-1",children:(0,r.jsxs)("div",{className:"flex justify-between items-start",children:[(0,r.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,r.jsx)("span",{className:"text-text-muted text-sm uppercase font-semibold",children:"Total Input Tokens"}),(0,r.jsx)("span",{className:"text-2xl font-bold text-primary",children:E(h.totalPromptTokens)})]}),(0,r.jsx)(p,{data:(h.last10Minutes||[]).map(e=>e.promptTokens),colorClass:"bg-primary/50"})]})}),(0,r.jsx)(c.default,{className:"px-4 py-2 flex flex-col gap-1",children:(0,r.jsxs)("div",{className:"flex justify-between items-start gap-4",children:[(0,r.jsxs)("div",{className:"flex flex-col gap-1 flex-1",children:[(0,r.jsx)("span",{className:"text-text-muted text-sm uppercase font-semibold",children:e("outputTokens")}),(0,r.jsx)("span",{className:"text-2xl font-bold text-success",children:E(h.totalCompletionTokens)})]}),(0,r.jsx)("div",{className:"w-px bg-border self-stretch mx-2"}),(0,r.jsxs)("div",{className:"flex flex-col gap-1 flex-1",children:[(0,r.jsx)("span",{className:"text-text-muted text-sm uppercase font-semibold",children:e("totalCost")}),(0,r.jsx)("span",{className:"text-2xl font-bold text-warning",children:(0,m.F0)(h.totalCost)})]})]})})]}),(0,r.jsxs)(c.default,{className:"overflow-hidden",children:[(0,r.jsx)("div",{className:"p-4 border-b border-border bg-bg-subtle/50",children:(0,r.jsx)("h3",{className:"font-semibold",children:"Usage by Model"})}),(0,r.jsx)("div",{className:"overflow-x-auto",children:(0,r.jsxs)("table",{className:"w-full text-sm text-left",children:[(0,r.jsx)("thead",{className:"bg-bg-subtle/30 text-text-muted uppercase text-xs",children:(0,r.jsxs)("tr",{children:[(0,r.jsxs)("th",{className:"px-6 py-3 cursor-pointer hover:bg-bg-subtle/50",onClick:()=>S("rawModel"),children:["Model ",(0,r.jsx)(u,{field:"rawModel",currentSort:n,currentOrder:i})]}),(0,r.jsxs)("th",{className:"px-6 py-3 cursor-pointer hover:bg-bg-subtle/50",onClick:()=>S("provider"),children:["Provider"," ",(0,r.jsx)(u,{field:"provider",currentSort:n,currentOrder:i})]}),(0,r.jsxs)("th",{className:"px-6 py-3 text-right cursor-pointer hover:bg-bg-subtle/50",onClick:()=>S("requests"),children:["Requests"," ",(0,r.jsx)(u,{field:"requests",currentSort:n,currentOrder:i})]}),(0,r.jsxs)("th",{className:"px-6 py-3 text-right cursor-pointer hover:bg-bg-subtle/50",onClick:()=>S("lastUsed"),children:["Last Used"," ",(0,r.jsx)(u,{field:"lastUsed",currentSort:n,currentOrder:i})]}),"tokens"===v?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("th",{className:"px-6 py-3 text-right cursor-pointer hover:bg-bg-subtle/50",onClick:()=>S("promptTokens"),children:["Input Tokens"," ",(0,r.jsx)(u,{field:"promptTokens",currentSort:n,currentOrder:i})]}),(0,r.jsxs)("th",{className:"px-6 py-3 text-right cursor-pointer hover:bg-bg-subtle/50",onClick:()=>S("completionTokens"),children:["Output Tokens"," ",(0,r.jsx)(u,{field:"completionTokens",currentSort:n,currentOrder:i})]}),(0,r.jsxs)("th",{className:"px-6 py-3 text-right cursor-pointer hover:bg-bg-subtle/50",onClick:()=>S("totalTokens"),children:["Total Tokens"," ",(0,r.jsx)(u,{field:"totalTokens",currentSort:n,currentOrder:i})]})]}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("th",{className:"px-6 py-3 text-right cursor-pointer hover:bg-bg-subtle/50",onClick:()=>S("promptTokens"),children:["Input Cost"," ",(0,r.jsx)(u,{field:"promptTokens",currentSort:n,currentOrder:i})]}),(0,r.jsxs)("th",{className:"px-6 py-3 text-right cursor-pointer hover:bg-bg-subtle/50",onClick:()=>S("completionTokens"),children:["Output Cost"," ",(0,r.jsx)(u,{field:"completionTokens",currentSort:n,currentOrder:i})]}),(0,r.jsxs)("th",{className:"px-6 py-3 text-right cursor-pointer hover:bg-bg-subtle/50",onClick:()=>S("cost"),children:["Total Cost"," ",(0,r.jsx)(u,{field:"cost",currentSort:n,currentOrder:i})]})]})]})}),(0,r.jsxs)("tbody",{className:"divide-y divide-border",children:[I.map(e=>(0,r.jsxs)("tr",{className:"hover:bg-bg-subtle/20",children:[(0,r.jsx)("td",{className:`px-6 py-3 font-medium transition-colors ${e.pending>0?"text-primary":""}`,children:e.rawModel}),(0,r.jsx)("td",{className:"px-6 py-3",children:(0,r.jsx)(d.default,{variant:e.pending>0?"primary":"default",size:"sm",children:e.provider})}),(0,r.jsx)("td",{className:"px-6 py-3 text-right",children:E(e.requests)}),(0,r.jsx)("td",{className:"px-6 py-3 text-right text-text-muted whitespace-nowrap",children:L(e.lastUsed)}),"tokens"===v?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("td",{className:"px-6 py-3 text-right text-text-muted",children:E(e.promptTokens)}),(0,r.jsx)("td",{className:"px-6 py-3 text-right text-text-muted",children:E(e.completionTokens)}),(0,r.jsx)("td",{className:"px-6 py-3 text-right font-medium",children:E(e.totalTokens)})]}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("td",{className:"px-6 py-3 text-right text-text-muted",children:(0,m.F0)(e.inputCost)}),(0,r.jsx)("td",{className:"px-6 py-3 text-right text-text-muted",children:(0,m.F0)(e.outputCost)}),(0,r.jsx)("td",{className:"px-6 py-3 text-right font-medium text-warning",children:(0,m.F0)(e.totalCost)})]})]},e.key)),0===I.length&&(0,r.jsx)("tr",{children:(0,r.jsx)("td",{colSpan:8,className:"px-6 py-8 text-center text-text-muted",children:"No usage recorded yet. Make some requests to see data here."})})]})]})})]}),(0,r.jsxs)(c.default,{className:"overflow-hidden",children:[(0,r.jsx)("div",{className:"p-4 border-b border-border bg-bg-subtle/50",children:(0,r.jsx)("h3",{className:"font-semibold",children:"Usage by Account"})}),(0,r.jsx)("div",{className:"overflow-x-auto",children:(0,r.jsxs)("table",{className:"w-full text-sm text-left",children:[(0,r.jsx)("thead",{className:"bg-bg-subtle/30 text-text-muted uppercase text-xs",children:(0,r.jsxs)("tr",{children:[(0,r.jsxs)("th",{className:"px-6 py-3 cursor-pointer hover:bg-bg-subtle/50",onClick:()=>S("rawModel"),children:["Model ",(0,r.jsx)(u,{field:"rawModel",currentSort:n,currentOrder:i})]}),(0,r.jsxs)("th",{className:"px-6 py-3 cursor-pointer hover:bg-bg-subtle/50",onClick:()=>S("provider"),children:["Provider"," ",(0,r.jsx)(u,{field:"provider",currentSort:n,currentOrder:i})]}),(0,r.jsxs)("th",{className:"px-6 py-3 cursor-pointer hover:bg-bg-subtle/50",onClick:()=>S("accountName"),children:["Account"," ",(0,r.jsx)(u,{field:"accountName",currentSort:n,currentOrder:i})]}),(0,r.jsxs)("th",{className:"px-6 py-3 text-right cursor-pointer hover:bg-bg-subtle/50",onClick:()=>S("requests"),children:["Requests"," ",(0,r.jsx)(u,{field:"requests",currentSort:n,currentOrder:i})]}),(0,r.jsxs)("th",{className:"px-6 py-3 text-right cursor-pointer hover:bg-bg-subtle/50",onClick:()=>S("lastUsed"),children:["Last Used"," ",(0,r.jsx)(u,{field:"lastUsed",currentSort:n,currentOrder:i})]}),"tokens"===v?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("th",{className:"px-6 py-3 text-right cursor-pointer hover:bg-bg-subtle/50",onClick:()=>S("promptTokens"),children:["Input Tokens"," ",(0,r.jsx)(u,{field:"promptTokens",currentSort:n,currentOrder:i})]}),(0,r.jsxs)("th",{className:"px-6 py-3 text-right cursor-pointer hover:bg-bg-subtle/50",onClick:()=>S("completionTokens"),children:["Output Tokens"," ",(0,r.jsx)(u,{field:"completionTokens",currentSort:n,currentOrder:i})]}),(0,r.jsxs)("th",{className:"px-6 py-3 text-right cursor-pointer hover:bg-bg-subtle/50",onClick:()=>S("totalTokens"),children:["Total Tokens"," ",(0,r.jsx)(u,{field:"totalTokens",currentSort:n,currentOrder:i})]})]}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("th",{className:"px-6 py-3 text-right cursor-pointer hover:bg-bg-subtle/50",onClick:()=>S("promptTokens"),children:["Input Cost"," ",(0,r.jsx)(u,{field:"promptTokens",currentSort:n,currentOrder:i})]}),(0,r.jsxs)("th",{className:"px-6 py-3 text-right cursor-pointer hover:bg-bg-subtle/50",onClick:()=>S("completionTokens"),children:["Output Cost"," ",(0,r.jsx)(u,{field:"completionTokens",currentSort:n,currentOrder:i})]}),(0,r.jsxs)("th",{className:"px-6 py-3 text-right cursor-pointer hover:bg-bg-subtle/50",onClick:()=>S("cost"),children:["Total Cost"," ",(0,r.jsx)(u,{field:"cost",currentSort:n,currentOrder:i})]})]})]})}),(0,r.jsxs)("tbody",{className:"divide-y divide-border",children:[O.map(e=>(0,r.jsxs)("tr",{className:"hover:bg-bg-subtle/20",children:[(0,r.jsx)("td",{className:`px-6 py-3 font-medium transition-colors ${e.pending>0?"text-primary":""}`,children:e.rawModel}),(0,r.jsx)("td",{className:"px-6 py-3",children:(0,r.jsx)(d.default,{variant:e.pending>0?"primary":"default",size:"sm",children:e.provider})}),(0,r.jsx)("td",{className:"px-6 py-3",children:(0,r.jsx)("span",{className:`font-medium transition-colors ${e.pending>0?"text-primary":""}`,children:e.accountName||`Account ${e.connectionId?.slice(0,8)}...`})}),(0,r.jsx)("td",{className:"px-6 py-3 text-right",children:E(e.requests)}),(0,r.jsx)("td",{className:"px-6 py-3 text-right text-text-muted whitespace-nowrap",children:L(e.lastUsed)}),"tokens"===v?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("td",{className:"px-6 py-3 text-right text-text-muted",children:E(e.promptTokens)}),(0,r.jsx)("td",{className:"px-6 py-3 text-right text-text-muted",children:E(e.completionTokens)}),(0,r.jsx)("td",{className:"px-6 py-3 text-right font-medium",children:E(e.totalTokens)})]}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("td",{className:"px-6 py-3 text-right text-text-muted",children:(0,m.F0)(e.inputCost)}),(0,r.jsx)("td",{className:"px-6 py-3 text-right text-text-muted",children:(0,m.F0)(e.outputCost)}),(0,r.jsx)("td",{className:"px-6 py-3 text-right font-medium text-warning",children:(0,m.F0)(e.totalCost)})]})]},e.key)),0===O.length&&(0,r.jsx)("tr",{children:(0,r.jsx)("td",{colSpan:9,className:"px-6 py-8 text-center text-text-muted",children:"No account-specific usage recorded yet. Make requests using OAuth accounts to see data here."})})]})]})})]})]})}u.propTypes={field:i().string.isRequired,currentSort:i().string.isRequired,currentOrder:i().string.isRequired},p.propTypes={data:i().arrayOf(i().number).isRequired,colorClass:i().string}},30949:(e,t,s)=>{s.d(t,{C:()=>l});var r=s(12115);function a(e){let t=document.createElement("textarea");t.value=e,t.style.position="fixed",t.style.left="-9999px",t.style.top="-9999px",t.style.opacity="0",document.body.appendChild(t),t.focus(),t.select();try{document.execCommand("copy")}catch{}document.body.removeChild(t)}function l(e=2e3){let[t,s]=(0,r.useState)(null),n=(0,r.useRef)(null);return{copied:t,copy:(0,r.useCallback)(async(t,r="default")=>{try{navigator.clipboard&&window.isSecureContext?await navigator.clipboard.writeText(t):a(t)}catch{a(t)}s(r),n.current&&clearTimeout(n.current),n.current=setTimeout(()=>{s(null)},e)},[e])}}},33637:(e,t,s)=>{s.d(t,{A:()=>n});var r=s(95155),a=s(14051),l=s.n(a);function n({size:e=20,className:t=""}){return(0,r.jsxs)("svg",{width:e,height:e,viewBox:"0 0 32 32",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:t,children:[(0,r.jsx)("circle",{cx:"16",cy:"16",r:"3",fill:"currentColor"}),(0,r.jsx)("circle",{cx:"8",cy:"8",r:"2",fill:"currentColor"}),(0,r.jsx)("circle",{cx:"24",cy:"8",r:"2",fill:"currentColor"}),(0,r.jsx)("circle",{cx:"8",cy:"24",r:"2",fill:"currentColor"}),(0,r.jsx)("circle",{cx:"24",cy:"24",r:"2",fill:"currentColor"}),(0,r.jsx)("circle",{cx:"16",cy:"5",r:"1.5",fill:"currentColor"}),(0,r.jsx)("circle",{cx:"16",cy:"27",r:"1.5",fill:"currentColor"}),(0,r.jsx)("line",{x1:"16",y1:"13",x2:"8",y2:"8",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round"}),(0,r.jsx)("line",{x1:"16",y1:"13",x2:"24",y2:"8",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round"}),(0,r.jsx)("line",{x1:"16",y1:"19",x2:"8",y2:"24",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round"}),(0,r.jsx)("line",{x1:"16",y1:"19",x2:"24",y2:"24",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round"}),(0,r.jsx)("line",{x1:"16",y1:"13",x2:"16",y2:"5",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round"}),(0,r.jsx)("line",{x1:"16",y1:"19",x2:"16",y2:"27",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round"})]})}n.propTypes={size:l().number,className:l().string}},33709:(e,t,s)=>{s.d(t,{default:()=>l});var r=s(95155),a=s(67040);function l({options:e=[],value:t,onChange:s,size:l="md",className:n,"aria-label":i}){let o={sm:"h-7 text-xs",md:"h-9 text-sm",lg:"h-11 text-base"};return(0,r.jsx)("div",{role:"tablist","aria-label":i,className:(0,a.cn)("inline-flex items-center p-1 rounded-lg","bg-black/5 dark:bg-white/5",n),children:e.map(e=>(0,r.jsxs)("button",{role:"tab","aria-selected":t===e.value,tabIndex:t===e.value?0:-1,onClick:()=>s(e.value),className:(0,a.cn)("px-4 rounded-md font-medium transition-all",o[l],t===e.value?"bg-white dark:bg-white/10 text-text-main shadow-sm":"text-text-muted hover:text-text-main"),children:[e.icon&&(0,r.jsx)("span",{className:"material-symbols-outlined text-[16px] mr-1.5","aria-hidden":"true",children:e.icon}),e.label]},e.value))})}},34243:(e,t,s)=>{s.d(t,{default:()=>N});var r=s(95155),a=s(12115),l=s(14051),n=s.n(l),i=s(98500),o=s.n(i),c=s(73321),d=s(67040),x=s(52529),m=s(33637),u=s(35806),p=s(71361);let h={connected:{icon:"cloud_done",color:"text-green-500",label:"Cloud"},syncing:{icon:"cloud_sync",color:"text-blue-400 animate-pulse",label:"Syncing..."},disconnected:{icon:"cloud_off",color:"text-amber-500",label:"Cloud Off"},error:{icon:"cloud_off",color:"text-red-400",label:"Cloud Error"},disabled:{icon:"cloud_off",color:"text-text-muted/50",label:"Disabled"}};function b({collapsed:e=!1}){let[t,s]=(0,a.useState)("disabled"),[l,n]=(0,a.useState)(null),i=(0,a.useRef)(!0),o=(0,c.useRouter)(),d=(0,a.useCallback)(async()=>{try{let e=await fetch("/api/sync/cloud");if(!i.current)return;if(!e.ok)return void s("disconnected");let t=await e.json();if(!i.current)return;t.enabled?t.syncing?s("syncing"):t.connected?(s("connected"),t.lastSync&&n(new Date(t.lastSync))):s("disconnected"):s("disabled")}catch{i.current&&s("disconnected")}},[]);if((0,a.useEffect)(()=>{i.current=!0,queueMicrotask(d);let e=setInterval(d,3e4),t=()=>{setTimeout(d,500)};return globalThis.addEventListener("cloud-status-changed",t),()=>{i.current=!1,clearInterval(e),globalThis.removeEventListener("cloud-status-changed",t)}},[d]),"disabled"===t)return null;let x=h[t];return(0,r.jsxs)("button",{onClick:()=>o.push("/dashboard/endpoint"),className:"flex items-center gap-2 px-3 py-1.5 text-xs rounded-lg hover:bg-white/5 transition-colors cursor-pointer w-full",title:l?`Cloud ${"connected"===t?"connected":"disconnected"} — Last sync: ${l.toLocaleTimeString()}`:x.label,"aria-label":`Cloud sync status: ${x.label}`,children:[(0,r.jsx)("span",{className:`material-symbols-outlined text-[16px] ${x.color}`,"aria-hidden":"true",children:x.icon}),!e&&(0,r.jsx)("span",{className:`truncate ${"connected"===t?"text-green-500":"text-text-muted"}`,children:x.label})]})}var f=s(50910);let g=[{href:"/dashboard",i18nKey:"home",icon:"home",exact:!0},{href:"/dashboard/endpoint",i18nKey:"endpoints",icon:"api"},{href:"/dashboard/api-manager",i18nKey:"apiManager",icon:"vpn_key"},{href:"/dashboard/providers",i18nKey:"providers",icon:"dns"},{href:"/dashboard/combos",i18nKey:"combos",icon:"layers"},{href:"/dashboard/logs",i18nKey:"logs",icon:"description"},{href:"/dashboard/costs",i18nKey:"costs",icon:"account_balance_wallet"},{href:"/dashboard/analytics",i18nKey:"analytics",icon:"analytics"},{href:"/dashboard/limits",i18nKey:"limits",icon:"tune"},{href:"/dashboard/health",i18nKey:"health",icon:"health_and_safety"},{href:"/dashboard/cli-tools",i18nKey:"cliTools",icon:"terminal"},{href:"/dashboard/media",i18nKey:"media",icon:"auto_awesome"}],y=[{href:"/dashboard/translator",i18nKey:"translator",icon:"translate"}],j=[{href:"/dashboard/settings",i18nKey:"settings",icon:"settings"}],v=[{href:"/docs",i18nKey:"docs",icon:"menu_book"},{href:"https://github.com/diegosouzapw/OmniRoute/issues",i18nKey:"issues",icon:"bug_report",external:!0}];function N({onClose:e,collapsed:t=!1,onToggleCollapse:s}){let l=(0,c.usePathname)(),n=(0,f.c)("sidebar"),i=(0,f.c)("common"),[h,N]=(0,a.useState)(!1),[k,w]=(0,a.useState)(!1),[C,S]=(0,a.useState)(!1),[T,I]=(0,a.useState)(!1),[O,R]=(0,a.useState)(!1),[E,L]=(0,a.useState)(!1);(0,a.useEffect)(()=>{fetch("/api/settings").then(e=>e.json()).then(e=>L(e?.enableRequestLogs===!0)).catch(()=>{})},[]);let A=async()=>{S(!0);try{await fetch("/api/shutdown",{method:"POST"})}catch(e){}S(!1),N(!1),R(!0)},_=async()=>{I(!0);try{await fetch("/api/restart",{method:"POST"})}catch(e){}I(!1),w(!1),R(!0),setTimeout(()=>{globalThis.location.reload()},3e3)},M=e=>e.map(e=>({...e,label:n(e.i18nKey)})),$=M(g),P=M(y),D=M(j),F=M(v),z=s=>{var a;let n=!s.external&&(a=s.href,s.exact?l===a:l.startsWith(a)),i=(0,d.cn)("flex items-center gap-3 rounded-lg transition-all group",t?"justify-center px-2 py-2.5":"px-4 py-2",n?"bg-primary/10 text-primary":"text-text-muted hover:bg-surface/50 hover:text-text-main"),c=(0,d.cn)("material-symbols-outlined text-[18px]",n?"fill-1":"group-hover:text-primary transition-colors"),x=(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("span",{className:c,children:s.icon}),!t&&(0,r.jsx)("span",{className:"text-sm font-medium",children:s.label})]});return s.external?(0,r.jsx)("a",{href:s.href,target:"_blank",rel:"noopener noreferrer",onClick:e,title:t?s.label:void 0,className:i,children:x},s.href):(0,r.jsx)(o(),{href:s.href,onClick:e,title:t?s.label:void 0,className:i,children:x},s.href)};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("aside",{className:(0,d.cn)("flex flex-col border-r border-black/5 dark:border-white/5 bg-vibrancy backdrop-blur-xl transition-all duration-300 ease-in-out",t?"w-16":"w-72"),children:[(0,r.jsx)("a",{href:"#main-content",className:"sr-only focus:not-sr-only focus:absolute focus:z-50 focus:p-3 focus:bg-primary focus:text-white focus:rounded-md focus:m-2",children:"Skip to content"}),(0,r.jsxs)("div",{className:(0,d.cn)("flex items-center gap-2 pt-5 pb-2",t?"px-3 justify-center":"px-6"),"aria-hidden":"true",children:[(0,r.jsx)("div",{className:"w-3 h-3 rounded-full bg-[#FF5F56]"}),(0,r.jsx)("div",{className:"w-3 h-3 rounded-full bg-[#FFBD2E]"}),(0,r.jsx)("div",{className:"w-3 h-3 rounded-full bg-[#27C93F]"}),!t&&(0,r.jsx)("div",{className:"flex-1"}),s&&(0,r.jsx)("button",{onClick:s,title:t?"Expand sidebar":"Collapse sidebar","aria-expanded":!t,"aria-label":t?"Expand sidebar":"Collapse sidebar",className:(0,d.cn)("p-1 rounded-md text-text-muted/50 hover:text-text-muted hover:bg-black/5 dark:hover:bg-white/5 transition-colors",t&&"mt-2"),children:(0,r.jsx)("span",{className:"material-symbols-outlined text-[16px]","aria-hidden":"true",children:t?"chevron_right":"chevron_left"})})]}),(0,r.jsx)("div",{className:(0,d.cn)("py-4",t?"px-2":"px-6"),children:(0,r.jsxs)(o(),{href:"/dashboard",className:(0,d.cn)("flex items-center",t?"justify-center":"gap-3"),children:[(0,r.jsx)("div",{className:"flex items-center justify-center size-9 rounded bg-linear-to-br from-[#E54D5E] to-[#C93D4E] shrink-0",children:(0,r.jsx)(m.A,{size:20,className:"text-white"})}),!t&&(0,r.jsxs)("div",{className:"flex flex-col",children:[(0,r.jsx)("h1",{className:"text-lg font-semibold tracking-tight text-text-main",children:x.vQ.name}),(0,r.jsxs)("span",{className:"text-xs text-text-muted",children:["v",x.vQ.version]})]})]})}),(0,r.jsxs)("nav",{"aria-label":"Main navigation",className:(0,d.cn)("flex-1 py-2 space-y-1 overflow-y-auto custom-scrollbar",t?"px-2":"px-4"),children:[$.map(z),E&&(0,r.jsxs)("div",{className:"pt-4 mt-2",children:[!t&&(0,r.jsx)("p",{className:"px-4 text-xs font-semibold text-text-muted/60 uppercase tracking-wider mb-2",children:"Debug"}),t&&(0,r.jsx)("div",{className:"border-t border-black/5 dark:border-white/5 mb-2"}),P.map(z)]}),(0,r.jsxs)("div",{className:"pt-4 mt-2",children:[!t&&(0,r.jsx)("p",{className:"px-4 text-xs font-semibold text-text-muted/60 uppercase tracking-wider mb-2",children:"System"}),t&&(0,r.jsx)("div",{className:"border-t border-black/5 dark:border-white/5 mb-2"}),D.map(z)]}),(0,r.jsxs)("div",{className:"pt-4 mt-2",children:[!t&&(0,r.jsx)("p",{className:"px-4 text-xs font-semibold text-text-muted/60 uppercase tracking-wider mb-2",children:"Help"}),t&&(0,r.jsx)("div",{className:"border-t border-black/5 dark:border-white/5 mb-2"}),F.map(z)]})]}),(0,r.jsx)(b,{collapsed:t}),(0,r.jsxs)("div",{className:(0,d.cn)("border-t border-black/5 dark:border-white/5",t?"p-2 flex flex-col gap-1":"p-3 flex gap-2"),children:[(0,r.jsxs)("button",{onClick:()=>w(!0),title:n("restart"),className:(0,d.cn)("flex items-center justify-center gap-2 rounded-lg font-medium transition-all","text-amber-500 hover:bg-amber-500/10 border border-amber-500/20 hover:border-amber-500/40",t?"p-2":"flex-1 px-3 py-2 text-sm"),children:[(0,r.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:"restart_alt"}),!t&&n("restart")]}),(0,r.jsxs)("button",{onClick:()=>N(!0),title:n("shutdown"),className:(0,d.cn)("flex items-center justify-center gap-2 rounded-lg font-medium transition-all","text-red-500 hover:bg-red-500/10 border border-red-500/20 hover:border-red-500/40",t?"p-2":"flex-1 px-3 py-2 text-sm"),children:[(0,r.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:"power_settings_new"}),!t&&n("shutdown")]})]})]}),(0,r.jsx)(p.ConfirmModal,{isOpen:h,onClose:()=>N(!1),onConfirm:A,title:n("shutdown"),message:n("shutdownConfirm"),confirmText:n("shutdown"),cancelText:i("cancel"),variant:"danger",loading:C}),(0,r.jsx)(p.ConfirmModal,{isOpen:k,onClose:()=>w(!1),onConfirm:_,title:n("restart"),message:n("restartConfirm"),confirmText:n("restart"),cancelText:i("cancel"),variant:"warning",loading:T}),O&&(0,r.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/80 backdrop-blur-sm",children:(0,r.jsxs)("div",{className:"text-center p-8",children:[(0,r.jsx)("div",{className:"flex items-center justify-center size-16 rounded-full bg-red-500/20 text-red-500 mx-auto mb-4",children:(0,r.jsx)("span",{className:"material-symbols-outlined text-[32px]",children:"power_off"})}),(0,r.jsx)("h2",{className:"text-xl font-semibold text-white mb-2",children:"Server Disconnected"}),(0,r.jsx)("p",{className:"text-text-muted mb-6",children:"The proxy server has been stopped or is restarting."}),(0,r.jsx)(u.default,{variant:"secondary",onClick:()=>globalThis.location.reload(),children:"Reload Page"})]})})]})}N.propTypes={onClose:n().func,collapsed:n().bool,onToggleCollapse:n().func}},34422:(e,t,s)=>{s.d(t,{default:()=>n});var r=s(95155),a=s(12115),l=s(67040);function n({label:e,type:t="text",placeholder:s,value:n,onChange:i,error:o,hint:c,icon:d,disabled:x=!1,required:m=!1,className:u,inputClassName:p,id:h,...b}){let f=(0,a.useId)(),g=h||f,y=o?`${g}-error`:void 0,j=c&&!o?`${g}-hint`:void 0,v=[y,j].filter(Boolean).join(" ")||void 0;return(0,r.jsxs)("div",{className:(0,l.cn)("flex flex-col gap-1.5",u),children:[e&&(0,r.jsxs)("label",{htmlFor:g,className:"text-sm font-medium text-text-main",children:[e,m&&(0,r.jsx)("span",{className:"text-red-500 ml-1","aria-hidden":"true",children:"*"})]}),(0,r.jsxs)("div",{className:"relative",children:[d&&(0,r.jsx)("div",{className:"absolute inset-y-0 left-0 flex items-center pl-3 pointer-events-none text-text-muted",children:(0,r.jsx)("span",{className:"material-symbols-outlined text-[20px]","aria-hidden":"true",children:d})}),(0,r.jsx)("input",{id:g,type:t,placeholder:s,value:n,onChange:i,disabled:x,required:m,"aria-required":m||void 0,"aria-invalid":!!o||void 0,"aria-describedby":v,className:(0,l.cn)("w-full py-2 px-3 text-sm text-text-main","bg-white dark:bg-white/5 border border-black/10 dark:border-white/10 rounded-md","placeholder-text-muted/60","focus:ring-1 focus:ring-primary/30 focus:border-primary/50 focus:outline-none","transition-all shadow-inner disabled:opacity-50 disabled:cursor-not-allowed","text-[16px] sm:text-sm",d&&"pl-10",o?"border-red-500 focus:border-red-500 focus:ring-red-500/20":"",p),...b})]}),o&&(0,r.jsxs)("p",{id:y,className:"text-xs text-red-500 flex items-center gap-1",role:"alert",children:[(0,r.jsx)("span",{className:"material-symbols-outlined text-[14px]","aria-hidden":"true",children:"error"}),o]}),c&&!o&&(0,r.jsx)("p",{id:j,className:"text-xs text-text-muted",children:c})]})}},35806:(e,t,s)=>{s.d(t,{default:()=>i});var r=s(95155),a=s(67040);let l={primary:"bg-gradient-to-b from-primary to-primary-hover text-white shadow-sm",secondary:"bg-white dark:bg-white/10 border border-black/10 dark:border-white/10 text-text-main hover:bg-black/5 dark:hover:bg-white/5",outline:"border border-black/15 dark:border-white/15 text-text-main hover:bg-black/5",ghost:"text-text-muted hover:bg-black/5 dark:hover:bg-white/5 hover:text-text-main",danger:"bg-red-500 text-white hover:bg-red-600 shadow-sm"},n={sm:"h-7 px-3 text-xs rounded-md",md:"h-9 px-4 text-sm rounded-lg",lg:"h-11 px-6 text-sm rounded-lg"};function i({children:e,variant:t="primary",size:s="md",icon:i,iconRight:o,disabled:c=!1,loading:d=!1,fullWidth:x=!1,className:m,...u}){return(0,r.jsxs)("button",{type:"button",className:(0,a.cn)("inline-flex items-center justify-center gap-2 font-medium transition-all duration-200 cursor-pointer","active:scale-[0.99] disabled:opacity-50 disabled:cursor-not-allowed disabled:active:scale-100",l[t],n[s],x&&"w-full",m),disabled:c||d,"aria-busy":d||void 0,...u,children:[d?(0,r.jsx)("span",{className:"material-symbols-outlined animate-spin text-[18px] pointer-events-none","aria-hidden":"true",children:"progress_activity"}):i?(0,r.jsx)("span",{className:"material-symbols-outlined text-[18px] pointer-events-none","aria-hidden":"true",children:i}):null,e,o&&!d&&(0,r.jsx)("span",{className:"material-symbols-outlined text-[18px] pointer-events-none","aria-hidden":"true",children:o})]})}},37415:(e,t,s)=>{s.d(t,{default:()=>h});var r=s(95155),a=s(12115),l=s(81060),n=s(99333),i=s(8898);function o({title:e,json:t,onCopy:s}){let[l,n]=(0,a.useState)(!1),i=async()=>{!1!==await s()&&(n(!0),setTimeout(()=>n(!1),2e3))};return(0,r.jsxs)("div",{children:[(0,r.jsxs)("div",{className:"flex items-center justify-between mb-2",children:[(0,r.jsx)("h3",{className:"text-[11px] text-text-muted uppercase tracking-wider font-bold",children:e}),(0,r.jsxs)("button",{onClick:i,className:"flex items-center gap-1 px-2 py-1 text-xs text-text-muted hover:text-text-primary transition-colors","aria-label":`Copy ${e}`,children:[(0,r.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:l?"check":"content_copy"}),l?"Copied!":"Copy"]})]}),(0,r.jsx)("pre",{className:"p-4 rounded-xl bg-black/30 border border-border overflow-x-auto text-xs font-mono text-text-primary max-h-[600px] overflow-y-auto leading-relaxed whitespace-pre-wrap break-words",children:t})]})}function c({log:e,detail:t,loading:s,onClose:l,onCopy:c}){(0,a.useEffect)(()=>{let e=e=>{"Escape"===e.key&&l()};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[l]);let d=(0,n._Z)(e.status),x=e.sourceFormat||e.provider,m=n.Kf[x]||n.Kf[e.provider]||{bg:"#6B7280",text:"#fff",label:(x||e.provider||"-").toUpperCase()},u=n.RY[e.provider]||{bg:"#374151",text:"#fff",label:(e.provider||"-").toUpperCase()},p=t?.requestBody?JSON.stringify(t.requestBody,null,2):null,h=t?.responseBody?JSON.stringify(t.responseBody,null,2):null;return(0,r.jsxs)("div",{className:"fixed inset-0 z-50 flex items-start justify-center pt-[5vh]",onClick:l,role:"dialog","aria-modal":"true","aria-label":"Request log detail",children:[(0,r.jsx)("div",{className:"absolute inset-0 bg-black/60 backdrop-blur-sm"}),(0,r.jsxs)("div",{className:"relative bg-bg-primary border border-border rounded-xl w-full max-w-[900px] max-h-[90vh] 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-6 py-4 border-b border-border bg-bg-primary/95 backdrop-blur-sm rounded-t-xl",children:[(0,r.jsxs)("div",{className:"flex items-center gap-3",children:[(0,r.jsx)("span",{className:"inline-block px-2.5 py-1 rounded text-xs font-bold",style:{backgroundColor:d.bg,color:d.text},children:e.status}),(0,r.jsx)("span",{className:"font-bold text-lg",children:e.method}),(0,r.jsx)("span",{className:"text-text-muted font-mono text-sm",children:e.path})]}),(0,r.jsx)("button",{onClick:l,className:"p-1.5 rounded-lg hover:bg-bg-subtle text-text-muted hover:text-text-primary transition-colors","aria-label":"Close detail modal",children:(0,r.jsx)("span",{className:"material-symbols-outlined",children:"close"})})]}),(0,r.jsxs)("div",{className:"p-6 flex flex-col gap-6",children:[(0,r.jsxs)("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4 p-4 bg-bg-subtle rounded-xl border border-border",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("div",{className:"text-[10px] text-text-muted uppercase tracking-wider mb-1",children:"Time"}),(0,r.jsx)("div",{className:"text-sm font-medium",children:(e=>{try{let t=new Date(e);return t.toLocaleDateString("pt-BR")+", "+t.toLocaleTimeString("en-US",{hour12:!1})}catch{return e}})(e.timestamp)})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("div",{className:"text-[10px] text-text-muted uppercase tracking-wider mb-1",children:"Duration"}),(0,r.jsx)("div",{className:"text-sm font-medium",children:(0,i.a3)(e.duration)})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("div",{className:"text-[10px] text-text-muted uppercase tracking-wider mb-1",children:"Tokens (I/O)"}),(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsxs)("span",{className:"px-2 py-0.5 rounded bg-primary/20 text-primary text-xs font-bold",children:["In: ",(t?.tokens?.in||e.tokens?.in||0).toLocaleString()]}),(0,r.jsxs)("span",{className:"px-2 py-0.5 rounded bg-emerald-500/20 text-emerald-400 text-xs font-bold",children:["Out: ",(t?.tokens?.out||e.tokens?.out||0).toLocaleString()]})]})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("div",{className:"text-[10px] text-text-muted uppercase tracking-wider mb-1",children:"Model"}),(0,r.jsx)("div",{className:"text-sm font-medium text-primary font-mono",children:e.model})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("div",{className:"text-[10px] text-text-muted uppercase tracking-wider mb-1",children:"Provider"}),(0,r.jsx)("span",{className:"inline-block px-2.5 py-1 rounded text-[10px] font-bold uppercase",style:{backgroundColor:u.bg,color:u.text},children:u.label})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("div",{className:"text-[10px] text-text-muted uppercase tracking-wider mb-1",children:"Protocol"}),(0,r.jsx)("span",{className:"inline-block px-2.5 py-1 rounded text-[10px] font-bold uppercase",style:{backgroundColor:m.bg,color:m.text},children:m.label})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("div",{className:"text-[10px] text-text-muted uppercase tracking-wider mb-1",children:"Account"}),(0,r.jsx)("div",{className:"text-sm font-medium",children:t?.account||e.account||"-"})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("div",{className:"text-[10px] text-text-muted uppercase tracking-wider mb-1",children:"API Key"}),(0,r.jsx)("div",{className:"text-sm font-medium",title:t?.apiKeyName||t?.apiKeyId||e.apiKeyName||e.apiKeyId||"No API key",children:(0,i.VO)(t?.apiKeyName||e.apiKeyName,t?.apiKeyId||e.apiKeyId)})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("div",{className:"text-[10px] text-text-muted uppercase tracking-wider mb-1",children:"Combo"}),t?.comboName||e.comboName?(0,r.jsx)("span",{className:"inline-block px-2.5 py-1 rounded-full text-[10px] font-bold bg-violet-500/20 text-violet-300 border border-violet-500/30",children:t?.comboName||e.comboName}):(0,r.jsx)("div",{className:"text-sm text-text-muted",children:"—"})]})]}),(t?.error||e.error)&&(0,r.jsxs)("div",{className:"p-4 rounded-xl bg-red-500/10 border border-red-500/30",children:[(0,r.jsx)("div",{className:"text-[10px] text-red-400 uppercase tracking-wider mb-1 font-bold",children:"Error"}),(0,r.jsx)("div",{className:"text-sm text-red-300 font-mono",children:t?.error||e.error})]}),s?(0,r.jsx)("div",{className:"p-8 text-center text-text-muted animate-pulse",children:"Loading request details..."}):(0,r.jsxs)(r.Fragment,{children:[p&&(0,r.jsx)(o,{title:"Request Payload",json:p,onCopy:()=>c(p)}),h&&(0,r.jsx)(o,{title:"Response Payload",json:h,onCopy:()=>c(h)}),!p&&!h&&!s&&(0,r.jsxs)("div",{className:"p-6 text-center text-text-muted",children:[(0,r.jsx)("span",{className:"material-symbols-outlined text-[32px] mb-2 block opacity-40",children:"info"}),(0,r.jsx)("p",{className:"text-sm",children:"No payload data available for this log entry."}),(0,r.jsx)("p",{className:"text-xs mt-1",children:"Request/response bodies are only captured for non-streaming calls or when streaming completes normally."})]})]})]})]})]})}let d=[{key:"all",label:"All"},{key:"error",label:"Errors",icon:"error"},{key:"ok",label:"Success",icon:"check_circle"},{key:"combo",label:"Combo",icon:"hub"}],x=[{key:"status",label:"Status"},{key:"model",label:"Model"},{key:"provider",label:"Provider"},{key:"protocol",label:"Protocol"},{key:"account",label:"Account"},{key:"apiKey",label:"API Key"},{key:"combo",label:"Combo"},{key:"tokens",label:"Tokens"},{key:"duration",label:"Duration"},{key:"time",label:"Time"}],m=Object.fromEntries(x.map(e=>[e.key,!0]));function u(e,t){if(!e)return"-";if(e.startsWith("openai-compatible-")||e.startsWith("anthropic-compatible-")){if(t?.length){let s=t.find(t=>t.id===e||t.prefix===e);if(s?.name)return s.name}if(e.startsWith("openai-compatible-")){let t=e.replace("openai-compatible-",""),s=t.split("-");return s.length>1&&s[1]?.length>=8?"OAI-COMPAT":`OAI: ${t.slice(0,16).toUpperCase()}`}if(e.startsWith("anthropic-compatible-")){let t=e.replace("anthropic-compatible-",""),s=t.split("-");return s.length>1&&s[1]?.length>=8?"ANT-COMPAT":`ANT: ${t.slice(0,16).toUpperCase()}`}}return null}function p(e){return(e?.tokens?.in||0)+(e?.tokens?.out||0)}function h(){let[e,t]=(0,a.useState)([]),[s,o]=(0,a.useState)(!0),[h,b]=(0,a.useState)(!0),[f,g]=(0,a.useState)(""),[y,j]=(0,a.useState)("all"),[v,N]=(0,a.useState)(""),[k,w]=(0,a.useState)(""),[C,S]=(0,a.useState)(""),[T,I]=(0,a.useState)(""),[O,R]=(0,a.useState)("newest"),[E,L]=(0,a.useState)(null),[A,_]=(0,a.useState)(!1),[M,$]=(0,a.useState)(null),P=(0,a.useRef)(null),D=(0,a.useRef)(!1),[F,z]=(0,a.useState)([]),[K,U]=(0,a.useState)(()=>{try{let e=localStorage.getItem("loggerVisibleColumns");return e?{...m,...JSON.parse(e)}:m}catch{return m}}),B=(0,a.useCallback)(e=>{U(t=>{let s={...t,[e]:!t[e]};try{localStorage.setItem("loggerVisibleColumns",JSON.stringify(s))}catch{}return s})},[]),q=(0,a.useCallback)(async(e=!1)=>{e&&o(!0);try{let e=new URLSearchParams;f&&e.set("search",f),"error"===y&&e.set("status","error"),"ok"===y&&e.set("status","ok"),"combo"===y&&e.set("combo","1"),v&&e.set("model",v),C&&e.set("provider",C),k&&e.set("account",k),T&&e.set("apiKey",T),e.set("limit","300");let s=await fetch(`/api/usage/call-logs?${e}`);if(s.ok){let e=await s.json();t(e)}}catch(e){console.error("Failed to fetch call logs:",e)}finally{e&&o(!1)}},[f,y,v,k,C,T]);(0,a.useEffect)(()=>{let e=!D.current;D.current=!0,q(e)},[q]),(0,a.useEffect)(()=>{fetch("/api/provider-nodes").then(e=>e.ok?e.json():{nodes:[]}).then(e=>z(e.nodes||[])).catch(()=>{})},[]),(0,a.useEffect)(()=>(P.current&&clearInterval(P.current),h&&(P.current=setInterval(()=>q(!1),3e3)),()=>{P.current&&clearInterval(P.current)}),[h,q]);let W=(0,a.useMemo)(()=>"combo"===y?e.filter(e=>e.comboName):e,[y,e]),V=(0,a.useMemo)(()=>{let e=[...W];return e.sort((e,t)=>{switch(O){case"oldest":return new Date(e.timestamp).getTime()-new Date(t.timestamp).getTime();case"tokens_desc":return p(t)-p(e);case"tokens_asc":return p(e)-p(t);case"duration_desc":return(t.duration||0)-(e.duration||0);case"duration_asc":return(e.duration||0)-(t.duration||0);case"status_desc":return(t.status||0)-(e.status||0);case"status_asc":return(e.status||0)-(t.status||0);case"model_asc":return(e.model||"").localeCompare(t.model||"");case"model_desc":return(t.model||"").localeCompare(e.model||"");default:return new Date(t.timestamp).getTime()-new Date(e.timestamp).getTime()}}),e},[W,O]),H=async e=>{L(e),_(!0),$(null);try{let t=await fetch(`/api/usage/call-logs/${e.id}`);if(t.ok){let e=await t.json();$(e)}}catch(e){console.error("Failed to fetch log detail:",e)}finally{_(!1)}},Y=async e=>{try{return await navigator.clipboard.writeText(e),!0}catch{try{let t=document.createElement("textarea");return t.value=e,t.style.position="fixed",t.style.left="-9999px",document.body.appendChild(t),t.select(),document.execCommand("copy"),document.body.removeChild(t),!0}catch{return!1}}},G=[...new Set(e.map(e=>e.account).filter(e=>e&&"-"!==e))],J=[...new Set(e.map(e=>e.model).filter(Boolean))].sort(),X=[...new Set(e.map(e=>e.provider).filter(e=>e&&"-"!==e))].sort(),Q=[...new Set(e.map(e=>e.apiKeyId||e.apiKeyName).filter(Boolean))].sort(),Z=W.length,ee=W.filter(e=>e.status>=200&&e.status<300).length,et=W.filter(e=>e.status>=400).length,es=e.filter(e=>e.comboName).length,er=Q.length;return(0,r.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,r.jsxs)("div",{className:"flex flex-wrap items-center gap-3",children:[(0,r.jsxs)("button",{onClick:()=>b(!h),className:`flex items-center gap-2 px-3 py-1.5 rounded-full text-sm font-medium border transition-colors ${h?"bg-red-500/10 border-red-500/30 text-red-400":"bg-bg-subtle border-border text-text-muted"}`,children:[(0,r.jsx)("span",{className:`w-2 h-2 rounded-full ${h?"bg-red-500 animate-pulse":"bg-text-muted"}`}),h?"Recording":"Paused"]}),(0,r.jsxs)("div",{className:"flex-1 min-w-[200px] relative",children:[(0,r.jsx)("span",{className:"material-symbols-outlined absolute left-3 top-1/2 -translate-y-1/2 text-text-muted text-[18px]",children:"search"}),(0,r.jsx)("input",{type:"text",placeholder:"Search model, provider, account, API key, combo...",value:f,onChange:e=>g(e.target.value),className:"w-full pl-10 pr-4 py-2 rounded-lg bg-bg-subtle border border-border text-sm text-text-primary placeholder:text-text-muted focus:outline-none focus:border-primary"})]}),(0,r.jsxs)("select",{value:C,onChange:e=>S(e.target.value),className:"px-3 py-2 rounded-lg bg-bg-subtle border border-border text-sm text-text-primary focus:outline-none focus:border-primary appearance-none cursor-pointer min-w-[140px]",children:[(0,r.jsx)("option",{value:"",children:"All Providers"}),X.map(e=>{let t=u(e,F),s=n.RY[e];return(0,r.jsx)("option",{value:e,children:t||s?.label||e.toUpperCase()},e)})]}),(0,r.jsxs)("select",{value:v,onChange:e=>N(e.target.value),className:"px-3 py-2 rounded-lg bg-bg-subtle border border-border text-sm text-text-primary focus:outline-none focus:border-primary appearance-none cursor-pointer min-w-[180px]",children:[(0,r.jsx)("option",{value:"",children:"All Models"}),J.map(e=>(0,r.jsx)("option",{value:e,children:e},e))]}),(0,r.jsxs)("select",{value:k,onChange:e=>w(e.target.value),className:"px-3 py-2 rounded-lg bg-bg-subtle border border-border text-sm text-text-primary focus:outline-none focus:border-primary appearance-none cursor-pointer min-w-[140px]",children:[(0,r.jsx)("option",{value:"",children:"All Accounts"}),G.map(e=>(0,r.jsx)("option",{value:e,children:e},e))]}),(0,r.jsxs)("select",{value:T,onChange:e=>I(e.target.value),className:"px-3 py-2 rounded-lg bg-bg-subtle border border-border text-sm text-text-primary focus:outline-none focus:border-primary appearance-none cursor-pointer min-w-[160px]",children:[(0,r.jsx)("option",{value:"",children:"All API Keys"}),Q.map(t=>{let s=e.find(e=>(e.apiKeyId||e.apiKeyName)===t),a=(0,i.VO)(s?.apiKeyName,s?.apiKeyId);return(0,r.jsx)("option",{value:t,children:a},t)})]}),(0,r.jsxs)("div",{className:"flex items-center gap-2 text-xs text-text-muted",children:[(0,r.jsxs)("span",{className:"px-2 py-1 rounded bg-bg-subtle border border-border font-mono",children:[Z," total"]}),(0,r.jsxs)("span",{className:"px-2 py-1 rounded bg-emerald-500/10 text-emerald-400 font-mono",children:[ee," OK"]}),et>0&&(0,r.jsxs)("span",{className:"px-2 py-1 rounded bg-red-500/10 text-red-400 font-mono",children:[et," ERR"]}),es>0&&(0,r.jsxs)("span",{className:"px-2 py-1 rounded bg-violet-500/10 text-violet-300 font-mono",children:[es," combo"]}),er>0&&(0,r.jsxs)("span",{className:"px-2 py-1 rounded bg-primary/10 text-primary font-mono",children:[er," keys"]}),(0,r.jsxs)("span",{className:"px-2 py-1 rounded bg-bg-subtle border border-border font-mono",children:[V.length," shown"]})]}),(0,r.jsxs)("select",{value:O,onChange:e=>R(e.target.value),className:"px-3 py-2 rounded-lg bg-bg-subtle border border-border text-sm text-text-primary focus:outline-none focus:border-primary appearance-none cursor-pointer min-w-[150px]",title:"Sort logs",children:[(0,r.jsx)("option",{value:"newest",children:"Newest"}),(0,r.jsx)("option",{value:"oldest",children:"Oldest"}),(0,r.jsx)("option",{value:"tokens_desc",children:"Tokens ↓"}),(0,r.jsx)("option",{value:"tokens_asc",children:"Tokens ↑"}),(0,r.jsx)("option",{value:"duration_desc",children:"Duration ↓"}),(0,r.jsx)("option",{value:"duration_asc",children:"Duration ↑"}),(0,r.jsx)("option",{value:"status_desc",children:"Status ↓"}),(0,r.jsx)("option",{value:"status_asc",children:"Status ↑"}),(0,r.jsx)("option",{value:"model_asc",children:"Model A-Z"}),(0,r.jsx)("option",{value:"model_desc",children:"Model Z-A"})]}),(0,r.jsx)("button",{onClick:()=>q(!1),className:"p-2 rounded-lg hover:bg-bg-subtle text-text-muted hover:text-text-primary transition-colors",title:"Refresh",children:(0,r.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:"refresh"})})]}),(0,r.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[d.map(e=>(0,r.jsxs)("button",{onClick:()=>j(y===e.key?"all":e.key),className:`flex items-center gap-1.5 px-3 py-1 rounded-full text-xs font-medium border transition-all ${y===e.key?"error"===e.key?"bg-red-500/20 text-red-400 border-red-500/40":"ok"===e.key?"bg-emerald-500/20 text-emerald-400 border-emerald-500/40":"combo"===e.key?"bg-violet-500/20 text-violet-300 border-violet-500/40":"bg-primary text-white border-primary":"bg-bg-subtle border-border text-text-muted hover:border-text-muted"}`,children:[e.icon&&(0,r.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:e.icon}),e.label]},e.key)),X.length>0&&(0,r.jsx)("span",{className:"w-px h-5 bg-border mx-1"}),X.map(e=>{let t=u(e,F),s=n.RY[e]||{bg:"#374151",text:"#fff",label:t||e.toUpperCase()},a=t||s.label,l=C===e;return(0,r.jsx)("button",{onClick:()=>S(l?"":e),className:`px-3 py-1 rounded-full text-xs font-bold uppercase border transition-all ${l?"border-white/40 ring-1 ring-white/20":"border-transparent opacity-70 hover:opacity-100"}`,style:{backgroundColor:l?s.bg:`${s.bg}33`,color:l?s.text:s.bg},children:a},e)})]}),(0,r.jsxs)("div",{className:"flex flex-wrap items-center gap-1.5",children:[(0,r.jsx)("span",{className:"text-[10px] text-text-muted uppercase tracking-wider mr-1",children:"Columns"}),x.map(e=>(0,r.jsx)("button",{onClick:()=>B(e.key),className:`px-2 py-0.5 rounded text-[10px] font-medium border transition-all ${K[e.key]?"bg-primary/15 text-primary border-primary/30":"bg-bg-subtle text-text-muted border-border opacity-50 hover:opacity-80"}`,children:e.label},e.key))]}),(0,r.jsx)(l.default,{className:"overflow-hidden bg-black/5 dark:bg-black/20",children:(0,r.jsx)("div",{className:"p-0 overflow-x-auto max-h-[calc(100vh-320px)] overflow-y-auto",children:s&&0===e.length?(0,r.jsx)("div",{className:"p-8 text-center text-text-muted",children:"Loading logs..."}):0===e.length?(0,r.jsxs)("div",{className:"p-8 text-center text-text-muted",children:[(0,r.jsx)("span",{className:"material-symbols-outlined text-[48px] mb-2 block opacity-40",children:"receipt_long"}),"No logs recorded yet. Make some API calls to see them here."]}):0===V.length?(0,r.jsx)("div",{className:"p-8 text-center text-text-muted",children:"No logs match the current filters."}):(0,r.jsxs)("table",{className:"w-full text-left border-collapse text-xs",children:[(0,r.jsx)("thead",{className:"sticky top-0 z-10",style:{backgroundColor:"var(--bg-primary, #0f1117)"},children:(0,r.jsxs)("tr",{className:"border-b border-border",style:{backgroundColor:"var(--bg-primary, #0f1117)"},children:[K.status&&(0,r.jsx)("th",{className:"px-3 py-2.5 font-semibold text-text-muted uppercase tracking-wider text-[10px]",children:"Status"}),K.model&&(0,r.jsx)("th",{className:"px-3 py-2.5 font-semibold text-text-muted uppercase tracking-wider text-[10px]",children:"Model"}),K.provider&&(0,r.jsx)("th",{className:"px-3 py-2.5 font-semibold text-text-muted uppercase tracking-wider text-[10px]",children:"Provider"}),K.protocol&&(0,r.jsx)("th",{className:"px-3 py-2.5 font-semibold text-text-muted uppercase tracking-wider text-[10px]",children:"Protocol"}),K.account&&(0,r.jsx)("th",{className:"px-3 py-2.5 font-semibold text-text-muted uppercase tracking-wider text-[10px]",children:"Account"}),K.apiKey&&(0,r.jsx)("th",{className:"px-3 py-2.5 font-semibold text-text-muted uppercase tracking-wider text-[10px]",children:"API Key"}),K.combo&&(0,r.jsx)("th",{className:"px-3 py-2.5 font-semibold text-text-muted uppercase tracking-wider text-[10px]",children:"Combo"}),K.tokens&&(0,r.jsx)("th",{className:"px-3 py-2.5 font-semibold text-text-muted uppercase tracking-wider text-[10px] text-right",children:"Tokens"}),K.duration&&(0,r.jsx)("th",{className:"px-3 py-2.5 font-semibold text-text-muted uppercase tracking-wider text-[10px] text-right",children:"Duration"}),K.time&&(0,r.jsx)("th",{className:"px-3 py-2.5 font-semibold text-text-muted uppercase tracking-wider text-[10px] text-right",children:"Time"})]})}),(0,r.jsx)("tbody",{className:"divide-y divide-border/30",children:V.map(e=>{let t=(0,n._Z)(e.status),s=e.sourceFormat||e.provider,a=n.Kf[s]||n.Kf[e.provider]||{bg:"#6B7280",text:"#fff",label:(s||e.provider||"-").toUpperCase()},l=u(e.provider,F),o=n.RY[e.provider]||{bg:"#374151",text:"#fff",label:l||(e.provider||"-").toUpperCase()},c=l||o.label,d=e.status>=400;return(0,r.jsxs)("tr",{onClick:()=>H(e),className:`cursor-pointer hover:bg-primary/5 transition-colors ${d?"bg-red-500/5":""}`,children:[K.status&&(0,r.jsx)("td",{className:"px-3 py-2",children:(0,r.jsx)("span",{className:"inline-block px-2 py-0.5 rounded text-[10px] font-bold min-w-[36px] text-center",style:{backgroundColor:t.bg,color:t.text},children:e.status||"..."})}),K.model&&(0,r.jsx)("td",{className:"px-3 py-2 font-medium text-primary font-mono text-[11px]",children:e.model}),K.provider&&(0,r.jsx)("td",{className:"px-3 py-2",children:(0,r.jsx)("span",{className:"inline-block px-2 py-0.5 rounded text-[9px] font-bold uppercase",style:{backgroundColor:o.bg,color:o.text},children:c})}),K.protocol&&(0,r.jsx)("td",{className:"px-3 py-2",children:(0,r.jsx)("span",{className:"inline-block px-2 py-0.5 rounded text-[9px] font-bold uppercase",style:{backgroundColor:a.bg,color:a.text},children:a.label})}),K.account&&(0,r.jsx)("td",{className:"px-3 py-2 text-text-muted truncate max-w-[120px]",title:e.account,children:(0,i.Ib)(e.account)}),K.apiKey&&(0,r.jsx)("td",{className:"px-3 py-2 text-text-muted truncate max-w-[140px]",title:e.apiKeyName||e.apiKeyId||"No API key",children:(0,i.VO)(e.apiKeyName,e.apiKeyId)}),K.combo&&(0,r.jsx)("td",{className:"px-3 py-2",children:e.comboName?(0,r.jsx)("span",{className:"inline-block px-2 py-0.5 rounded-full text-[9px] font-bold bg-violet-500/20 text-violet-300 border border-violet-500/30",children:e.comboName}):(0,r.jsx)("span",{className:"text-text-muted text-[10px]",children:"—"})}),K.tokens&&(0,r.jsxs)("td",{className:"px-3 py-2 text-right whitespace-nowrap",children:[(0,r.jsx)("span",{className:"text-text-muted",children:"I:"})," ",(0,r.jsx)("span",{className:"text-primary",children:e.tokens?.in?.toLocaleString()||0}),(0,r.jsx)("span",{className:"mx-1 text-border",children:"|"}),(0,r.jsx)("span",{className:"text-text-muted",children:"O:"})," ",(0,r.jsx)("span",{className:"text-emerald-400",children:e.tokens?.out?.toLocaleString()||0})]}),K.duration&&(0,r.jsx)("td",{className:"px-3 py-2 text-right text-text-muted font-mono",children:(0,i.a3)(e.duration)}),K.time&&(0,r.jsx)("td",{className:"px-3 py-2 text-right text-text-muted",children:(0,i.fU)(e.timestamp)})]},e.id)})})]})})}),(0,r.jsxs)("div",{className:"text-[10px] text-text-muted italic",children:["Call logs are also saved as JSON files to ",(0,r.jsx)("code",{children:"{DATA_DIR}/call_logs/"})," with 7-day rotation."]}),E&&(0,r.jsx)(c,{log:E,detail:M,loading:A,onClose:()=>{L(null),$(null)},onCopy:Y})]})}},42994:(e,t,s)=>{s.d(t,{default:()=>n});var r=s(95155),a=s(12115),l=s(67040);function n({label:e,options:t=[],value:s,onChange:n,placeholder:i="Select an option",error:o,hint:c,disabled:d=!1,required:x=!1,className:m,selectClassName:u,id:p,...h}){let b=(0,a.useId)(),f=p||b,g=o?`${f}-error`:void 0,y=c&&!o?`${f}-hint`:void 0,j=[g,y].filter(Boolean).join(" ")||void 0;return(0,r.jsxs)("div",{className:(0,l.cn)("flex flex-col gap-1.5",m),children:[e&&(0,r.jsxs)("label",{htmlFor:f,className:"text-sm font-medium text-text-main",children:[e,x&&(0,r.jsx)("span",{className:"text-red-500 ml-1","aria-hidden":"true",children:"*"})]}),(0,r.jsxs)("div",{className:"relative",children:[(0,r.jsxs)("select",{id:f,value:s,onChange:n,disabled:d,required:x,"aria-required":x||void 0,"aria-invalid":!!o||void 0,"aria-describedby":j,className:(0,l.cn)("w-full py-2 px-3 pr-10 text-sm text-text-main","bg-surface border border-black/10 dark:border-white/10 rounded-md appearance-none","focus:ring-1 focus:ring-primary/30 focus:border-primary/50 focus:outline-none","transition-all disabled:opacity-50 disabled:cursor-not-allowed","text-[16px] sm:text-sm",o?"border-red-500 focus:border-red-500 focus:ring-red-500/20":"",u),...h,children:[(0,r.jsx)("option",{value:"",disabled:!0,className:"bg-surface text-text-muted",children:i}),t.map(e=>(0,r.jsx)("option",{value:e.value,className:"bg-surface text-text-main",children:e.label},e.value))]}),(0,r.jsx)("div",{className:"absolute inset-y-0 right-0 flex items-center pr-3 pointer-events-none text-text-muted","aria-hidden":"true",children:(0,r.jsx)("span",{className:"material-symbols-outlined text-[20px]",children:"expand_more"})})]}),o&&(0,r.jsxs)("p",{id:g,className:"text-xs text-red-500 flex items-center gap-1",role:"alert",children:[(0,r.jsx)("span",{className:"material-symbols-outlined text-[14px]","aria-hidden":"true",children:"error"}),o]}),c&&!o&&(0,r.jsx)("p",{id:y,className:"text-xs text-text-muted",children:c})]})}},44638:(e,t,s)=>{s.d(t,{default:()=>a});var r=s(95155);function a({columns:e=[],data:t=[],renderCell:s,renderHeader:a,onRowClick:l,selectedId:n,loading:i=!1,maxHeight:o="calc(100vh - 320px)",emptyIcon:c="\uD83D\uDCED",emptyMessage:d="No data found"}){return i?(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",padding:"48px 24px",color:"var(--text-secondary, #888)",fontSize:"14px"},children:[(0,r.jsx)("span",{style:{animation:"spin 1s linear infinite",marginRight:"8px"},children:"⏳"}),"Loading...",(0,r.jsx)("style",{children:"@keyframes spin { to { transform: rotate(360deg); } }"})]}):0===t.length?(0,r.jsxs)("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",padding:"48px 24px",color:"var(--text-secondary, #888)",fontSize:"14px"},children:[(0,r.jsx)("span",{style:{fontSize:"32px",marginBottom:"8px",opacity:.6},children:c}),d]}):(0,r.jsx)("div",{style:{overflow:"auto",maxHeight:o,borderRadius:"8px"},children:(0,r.jsxs)("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:"12px",tableLayout:"auto"},children:[(0,r.jsx)("thead",{children:(0,r.jsx)("tr",{children:e.map(e=>(0,r.jsx)("th",{style:{padding:"8px 10px",textAlign:"left",fontWeight:600,color:"var(--text-secondary, #888)",borderBottom:"1px solid rgba(255,255,255,0.08)",position:"sticky",top:0,background:"var(--bg-table-header, rgba(15,15,25,0.95))",zIndex:1,whiteSpace:"nowrap",fontSize:"11px",textTransform:"uppercase",letterSpacing:"0.5px"},children:a?a(e):e.label},e.key))})}),(0,r.jsx)("tbody",{children:t.map((t,a)=>(0,r.jsx)("tr",{onClick:()=>l?.(t),style:{cursor:l?"pointer":"default",background:t.id===n?"rgba(99,102,241,0.1)":a%2==0?"transparent":"rgba(255,255,255,0.02)",transition:"background 0.15s"},onMouseEnter:e=>{t.id!==n&&(e.currentTarget.style.background="rgba(255,255,255,0.04)")},onMouseLeave:e=>{t.id!==n&&(e.currentTarget.style.background=a%2==0?"transparent":"rgba(255,255,255,0.02)")},children:e.map(e=>(0,r.jsx)("td",{style:{padding:"6px 10px",borderBottom:"1px solid rgba(255,255,255,0.04)",whiteSpace:"nowrap",maxWidth:e.maxWidth||"200px",overflow:"hidden",textOverflow:"ellipsis"},children:s(t,e)},e.key))},t.id||a))})]})})}},45624:(e,t,s)=>{s.d(t,{default:()=>P});var r=s(95155),a=s(12115),l=s(81060),n=s(92542),i=s(8898),o=s(99333),c=s(80662),d=s(68444),x=s(32539),m=s(59656),u=s(58021),p=s(54945),h=s(75319),b=s(80865),f=s(53201),g=s(67389),y=s(90639),j=s(53459);function v({active:e,payload:t,label:s,formatter:a}){return e&&t?.length?(0,r.jsxs)("div",{className:"rounded-lg border border-white/10 bg-surface px-3 py-2 text-xs shadow-lg",children:[s&&(0,r.jsx)("div",{className:"font-semibold text-text-main mb-1",children:s}),t.map((e,t)=>(0,r.jsxs)("div",{className:"flex items-center gap-1.5 text-text-muted",children:[(0,r.jsx)("span",{className:"w-2 h-2 rounded-full shrink-0",style:{backgroundColor:e.color}}),(0,r.jsxs)("span",{children:[e.name,":"]}),(0,r.jsx)("span",{className:"font-mono font-medium text-text-main",children:a?a(e.value):e.value})]},t))]}):null}function N({active:e,sortOrder:t}){return e?(0,r.jsx)("span",{className:"material-symbols-outlined text-[12px] text-primary",children:"asc"===t?"expand_less":"expand_more"}):(0,r.jsx)("span",{className:"material-symbols-outlined text-[12px] opacity-0 group-hover:opacity-30",children:"unfold_more"})}function k({icon:e,label:t,value:s,subValue:a,color:n="text-text-main"}){return(0,r.jsxs)(l.default,{className:"px-4 py-3 flex flex-col gap-1",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2 text-text-muted text-xs uppercase font-semibold tracking-wider",children:[(0,r.jsx)("span",{className:"material-symbols-outlined text-[16px]",children:e}),t]}),(0,r.jsx)("span",{className:`text-2xl font-bold ${n}`,children:s}),a&&(0,r.jsx)("span",{className:"text-xs text-text-muted",children:a})]})}function w({activityMap:e}){let t=(0,a.useMemo)(()=>{let t=new Date,s=[],r=0;for(let a=364;a>=0;a--){let l=new Date(t);l.setDate(l.getDate()-a);let n=`${l.getFullYear()}-${String(l.getMonth()+1).padStart(2,"0")}-${String(l.getDate()).padStart(2,"0")}`,i=e?.[n]||0;i>r&&(r=i),s.push({date:n,value:i,dayOfWeek:l.getDay()})}return{days:s,maxVal:r}},[e]),s=(0,a.useMemo)(()=>{let e=[],s=[],r=t.days[0]?.dayOfWeek||0;for(let e=0;e<r;e++)s.push(null);for(let r of t.days)s.push(r),7===s.length&&(e.push(s),s=[]);return s.length>0&&e.push(s),e},[t]),n=(0,a.useMemo)(()=>{let e=[],t=-1;return s.forEach((s,r)=>{let a=s.find(e=>null!==e);if(a){let s=new Date(a.date).getMonth();s!==t&&(e.push({weekIdx:r,label:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"][s]}),t=s)}}),e},[s]);return(0,r.jsxs)(l.default,{className:"p-4 h-full",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between mb-3",children:[(0,r.jsx)("h3",{className:"text-sm font-semibold text-text-muted uppercase tracking-wider",children:"Activity"}),(0,r.jsxs)("span",{className:"text-xs text-text-muted",children:[Object.keys(e||{}).length," active days \xb7"," ",(0,i.VK)(Object.values(e||{}).reduce((e,t)=>e+t,0))," tokens \xb7 365 days"]})]}),(0,r.jsx)("div",{className:"flex gap-[3px] mb-1 ml-6",style:{fontSize:"10px"},children:n.map((e,t)=>(0,r.jsx)("span",{className:"text-text-muted",style:{position:"relative",left:`${13*e.weekIdx}px`,marginLeft:0===t?0:"-20px"},children:e.label},t))}),(0,r.jsxs)("div",{className:"flex gap-[3px] overflow-x-auto",children:[(0,r.jsxs)("div",{className:"flex flex-col gap-[3px] shrink-0 text-[10px] text-text-muted pr-1",children:[(0,r.jsx)("span",{className:"h-[10px]"}),(0,r.jsx)("span",{className:"h-[10px] leading-[10px]",children:"Mon"}),(0,r.jsx)("span",{className:"h-[10px]"}),(0,r.jsx)("span",{className:"h-[10px] leading-[10px]",children:"Wed"}),(0,r.jsx)("span",{className:"h-[10px]"}),(0,r.jsx)("span",{className:"h-[10px] leading-[10px]",children:"Fri"}),(0,r.jsx)("span",{className:"h-[10px]"})]}),s.map((e,s)=>(0,r.jsx)("div",{className:"flex flex-col gap-[3px]",children:e.map((e,s)=>(0,r.jsx)("div",{title:e?`${e.date}: ${(0,i.xW)(e.value)} tokens`:"",className:`w-[10px] h-[10px] rounded-[2px] ${e?function(e){if(!e||0===e)return"bg-white/[0.04]";let s=Math.min(e/(t.maxVal||1),1);return s<.25?"bg-primary/20":s<.5?"bg-primary/40":s<.75?"bg-primary/60":"bg-primary/90"}(e.value):"bg-transparent"}`},s))},s))]}),(0,r.jsxs)("div",{className:"flex items-center gap-1 mt-2 ml-6 text-[10px] text-text-muted",children:[(0,r.jsx)("span",{children:"Less"}),(0,r.jsx)("div",{className:"w-[10px] h-[10px] rounded-[2px] bg-white/[0.04]"}),(0,r.jsx)("div",{className:"w-[10px] h-[10px] rounded-[2px] bg-primary/20"}),(0,r.jsx)("div",{className:"w-[10px] h-[10px] rounded-[2px] bg-primary/40"}),(0,r.jsx)("div",{className:"w-[10px] h-[10px] rounded-[2px] bg-primary/60"}),(0,r.jsx)("div",{className:"w-[10px] h-[10px] rounded-[2px] bg-primary/90"}),(0,r.jsx)("span",{children:"More"})]})]})}function C({dailyTrend:e}){let t=(0,a.useMemo)(()=>(e||[]).map(e=>({date:e.date.slice(5),Input:e.promptTokens,Output:e.completionTokens,Cost:e.cost||0})),[e]),s=(0,a.useMemo)(()=>t.some(e=>e.Cost>0),[t]);return t.length?(0,r.jsxs)(l.default,{className:"p-4 flex-1",children:[(0,r.jsx)("h3",{className:"text-sm font-semibold text-text-muted uppercase tracking-wider mb-3",children:"Token & Cost Trend"}),(0,r.jsx)(c.u,{width:"100%",height:140,children:(0,r.jsxs)(d.X,{data:t,margin:{top:0,right:40*!!s,left:0,bottom:0},children:[(0,r.jsx)(x.W,{dataKey:"date",tick:{fontSize:9,fill:"var(--text-muted)"},axisLine:!1,tickLine:!1,interval:Math.max(Math.floor(t.length/6),0)}),s&&(0,r.jsx)(m.h,{yAxisId:"cost",orientation:"right",tick:{fontSize:8,fill:"#f59e0b"},axisLine:!1,tickLine:!1,tickFormatter:e=>`$${e.toFixed(2)}`,width:36}),(0,r.jsx)(u.m,{content:(0,r.jsx)(S,{}),cursor:{fill:"rgba(255,255,255,0.04)"}}),(0,r.jsx)(p.yP,{dataKey:"Input",stackId:"a",fill:"var(--primary)",opacity:.7,radius:[0,0,0,0],animationDuration:600}),(0,r.jsx)(p.yP,{dataKey:"Output",stackId:"a",fill:"#10b981",opacity:.7,radius:[3,3,0,0],animationDuration:600}),s&&(0,r.jsx)(h.N1,{yAxisId:"cost",type:"monotone",dataKey:"Cost",stroke:"#f59e0b",strokeWidth:2,dot:!1,animationDuration:600})]})}),(0,r.jsxs)("div",{className:"flex items-center gap-4 mt-2 text-[10px] text-text-muted",children:[(0,r.jsxs)("span",{className:"flex items-center gap-1",children:[(0,r.jsx)("span",{className:"w-2 h-2 rounded-full bg-primary/70"})," Input"]}),(0,r.jsxs)("span",{className:"flex items-center gap-1",children:[(0,r.jsx)("span",{className:"w-2 h-2 rounded-full bg-emerald-500/70"})," Output"]}),s&&(0,r.jsxs)("span",{className:"flex items-center gap-1",children:[(0,r.jsx)("span",{className:"w-2 h-2 rounded-full bg-amber-500/70"})," Cost ($)"]})]})]}):(0,r.jsxs)(l.default,{className:"p-4",children:[(0,r.jsx)("h3",{className:"text-sm font-semibold text-text-muted uppercase tracking-wider mb-3",children:"Token Trend"}),(0,r.jsx)("div",{className:"text-center text-text-muted text-sm py-8",children:"No data"})]})}function S({active:e,payload:t,label:s}){return e&&t?.length?(0,r.jsxs)("div",{className:"rounded-lg border border-white/10 bg-surface px-3 py-2 text-xs shadow-lg",children:[s&&(0,r.jsx)("div",{className:"font-semibold text-text-main mb-1",children:s}),t.map((e,t)=>(0,r.jsxs)("div",{className:"flex items-center gap-1.5 text-text-muted",children:[(0,r.jsx)("span",{className:"w-2 h-2 rounded-full shrink-0",style:{backgroundColor:e.color}}),(0,r.jsxs)("span",{children:[e.name,":"]}),(0,r.jsx)("span",{className:"font-mono font-medium text-text-main",children:"Cost"===e.name?(0,i.F0)(e.value):(0,i.VK)(e.value)})]},t))]}):null}function T({byAccount:e}){let t=(0,a.useMemo)(()=>e||[],[e]),s=t.length>0,n=(0,a.useMemo)(()=>t.slice(0,8).map((e,t)=>({name:e.account,value:e.totalTokens,fill:(0,o.ng)(t)})),[t]);return s?(0,r.jsxs)(l.default,{className:"p-4 flex-1",children:[(0,r.jsx)("h3",{className:"text-sm font-semibold text-text-muted uppercase tracking-wider mb-3",children:"By Account"}),(0,r.jsxs)("div",{className:"flex items-center gap-4",children:[(0,r.jsx)(c.u,{width:120,height:120,children:(0,r.jsxs)(b.r,{children:[(0,r.jsx)(f.Fq,{data:n,dataKey:"value",nameKey:"name",cx:"50%",cy:"50%",innerRadius:28,outerRadius:55,paddingAngle:1,animationDuration:600,children:n.map((e,t)=>(0,r.jsx)(g.f,{fill:e.fill,stroke:"none"},t))}),(0,r.jsx)(u.m,{content:(0,r.jsx)(v,{formatter:i.VK})})]})}),(0,r.jsx)("div",{className:"flex flex-col gap-1 min-w-0 flex-1",children:n.map((e,t)=>(0,r.jsxs)("div",{className:"flex items-center justify-between gap-2 text-xs",children:[(0,r.jsxs)("div",{className:"flex items-center gap-1.5 min-w-0",children:[(0,r.jsx)("span",{className:"w-2 h-2 rounded-full shrink-0",style:{backgroundColor:e.fill}}),(0,r.jsx)("span",{className:"truncate text-text-main",children:e.name})]}),(0,r.jsx)("span",{className:"font-mono font-medium text-text-muted shrink-0",children:(0,i.VK)(e.value)})]},t))})]})]}):(0,r.jsxs)(l.default,{className:"p-4 flex-1",children:[(0,r.jsx)("h3",{className:"text-sm font-semibold text-text-muted uppercase tracking-wider mb-3",children:"By Account"}),(0,r.jsx)("div",{className:"text-center text-text-muted text-sm py-8",children:"No data"})]})}function I({byApiKey:e}){let t=(0,a.useMemo)(()=>e||[],[e]),s=t.length>0,n=(0,a.useMemo)(()=>t.slice(0,8).map((e,t)=>({name:(0,i.VO)(e.apiKeyName,e.apiKeyId),fullName:e.apiKeyName||e.apiKeyId||"unknown",value:e.totalTokens,fill:(0,o.ng)(t)})),[t]);return s?(0,r.jsxs)(l.default,{className:"p-4 flex-1",children:[(0,r.jsx)("h3",{className:"text-sm font-semibold text-text-muted uppercase tracking-wider mb-3",children:"By API Key"}),(0,r.jsxs)("div",{className:"flex items-center gap-4",children:[(0,r.jsx)(c.u,{width:120,height:120,children:(0,r.jsxs)(b.r,{children:[(0,r.jsx)(f.Fq,{data:n,dataKey:"value",nameKey:"name",cx:"50%",cy:"50%",innerRadius:28,outerRadius:55,paddingAngle:1,animationDuration:600,children:n.map((e,t)=>(0,r.jsx)(g.f,{fill:e.fill,stroke:"none"},t))}),(0,r.jsx)(u.m,{content:(0,r.jsx)(v,{formatter:i.VK})})]})}),(0,r.jsx)("div",{className:"flex flex-col gap-1 min-w-0 flex-1",children:n.map((e,t)=>(0,r.jsxs)("div",{className:"flex items-center justify-between gap-2 text-xs",children:[(0,r.jsxs)("div",{className:"flex items-center gap-1.5 min-w-0",children:[(0,r.jsx)("span",{className:"w-2 h-2 rounded-full shrink-0",style:{backgroundColor:e.fill}}),(0,r.jsx)("span",{className:"truncate text-text-main",title:e.fullName,children:e.name})]}),(0,r.jsx)("span",{className:"font-mono font-medium text-text-muted shrink-0",children:(0,i.VK)(e.value)})]},`${e.fullName}-${t}`))})]})]}):(0,r.jsxs)(l.default,{className:"p-4 flex-1",children:[(0,r.jsx)("h3",{className:"text-sm font-semibold text-text-muted uppercase tracking-wider mb-3",children:"By API Key"}),(0,r.jsx)("div",{className:"text-center text-text-muted text-sm py-8",children:"No data"})]})}function O({byApiKey:e}){let[t,s]=(0,a.useState)(""),[n,o]=(0,a.useState)("totalTokens"),[c,d]=(0,a.useState)("desc"),x=(0,a.useMemo)(()=>e||[],[e]),m=(0,a.useMemo)(()=>{let e=t.trim().toLowerCase();return e?x.filter(t=>(t.apiKeyName||"").toLowerCase().includes(e)||(t.apiKeyId||"").toLowerCase().includes(e)):x},[x,t]),u=(0,a.useMemo)(()=>{let e=[...m];return e.sort((e,t)=>{let s=e[n]??0,r=t[n]??0;return"string"==typeof s?"asc"===c?s.localeCompare(r):r.localeCompare(s):"asc"===c?s-r:r-s}),e},[m,n,c]),p=(0,a.useCallback)(e=>{n===e?d(e=>"asc"===e?"desc":"asc"):(o(e),d("desc"))},[n]);return x.length>0?(0,r.jsxs)(l.default,{className:"overflow-hidden",children:[(0,r.jsxs)("div",{className:"p-4 border-b border-border flex items-center justify-between gap-3",children:[(0,r.jsx)("h3",{className:"text-sm font-semibold text-text-muted uppercase tracking-wider",children:"API Key Breakdown"}),(0,r.jsx)("input",{type:"text",value:t,onChange:e=>s(e.target.value),placeholder:"Filter API key...",className:"w-full max-w-[220px] px-3 py-1.5 rounded-lg bg-bg-subtle border border-border text-xs text-text-primary placeholder:text-text-muted focus:outline-none focus:border-primary"})]}),(0,r.jsx)("div",{className:"overflow-x-auto",children:(0,r.jsxs)("table",{className:"w-full text-sm",children:[(0,r.jsx)("thead",{className:"text-xs text-text-muted uppercase bg-black/[0.02] dark:bg-white/[0.02]",children:(0,r.jsxs)("tr",{children:[(0,r.jsxs)("th",{className:"px-4 py-2.5 text-left cursor-pointer group",onClick:()=>p("apiKeyName"),children:["API Key ",(0,r.jsx)(N,{active:"apiKeyName"===n,sortOrder:c})]}),(0,r.jsxs)("th",{className:"px-4 py-2.5 text-right cursor-pointer group",onClick:()=>p("requests"),children:["Requests ",(0,r.jsx)(N,{active:"requests"===n,sortOrder:c})]}),(0,r.jsxs)("th",{className:"px-4 py-2.5 text-right cursor-pointer group",onClick:()=>p("promptTokens"),children:["Input ",(0,r.jsx)(N,{active:"promptTokens"===n,sortOrder:c})]}),(0,r.jsxs)("th",{className:"px-4 py-2.5 text-right cursor-pointer group",onClick:()=>p("completionTokens"),children:["Output"," ",(0,r.jsx)(N,{active:"completionTokens"===n,sortOrder:c})]}),(0,r.jsxs)("th",{className:"px-4 py-2.5 text-right cursor-pointer group",onClick:()=>p("totalTokens"),children:["Total Tokens"," ",(0,r.jsx)(N,{active:"totalTokens"===n,sortOrder:c})]}),(0,r.jsxs)("th",{className:"px-4 py-2.5 text-right cursor-pointer group",onClick:()=>p("cost"),children:["Cost ",(0,r.jsx)(N,{active:"cost"===n,sortOrder:c})]})]})}),(0,r.jsxs)("tbody",{className:"divide-y divide-border",children:[u.map((e,t)=>(0,r.jsxs)("tr",{className:"hover:bg-black/[0.02] dark:hover:bg-white/[0.02] transition-colors",children:[(0,r.jsx)("td",{className:"px-4 py-2.5",children:(0,r.jsx)("span",{className:"font-medium",title:e.apiKeyName||e.apiKeyId||"unknown",children:(0,i.VO)(e.apiKeyName,e.apiKeyId)})}),(0,r.jsx)("td",{className:"px-4 py-2.5 text-right font-mono text-text-muted",children:(0,i.xW)(e.requests)}),(0,r.jsx)("td",{className:"px-4 py-2.5 text-right font-mono text-primary",children:(0,i.VK)(e.promptTokens)}),(0,r.jsx)("td",{className:"px-4 py-2.5 text-right font-mono text-emerald-500",children:(0,i.VK)(e.completionTokens)}),(0,r.jsx)("td",{className:"px-4 py-2.5 text-right font-mono font-semibold",children:(0,i.VK)(e.totalTokens)}),(0,r.jsx)("td",{className:"px-4 py-2.5 text-right font-mono text-amber-500",children:(0,i.F0)(e.cost)})]},`${e.apiKeyId||e.apiKeyName||"key"}-${t}`)),0===u.length&&(0,r.jsx)("tr",{children:(0,r.jsx)("td",{colSpan:6,className:"px-4 py-8 text-center text-text-muted",children:"No API key matches this filter."})})]})]})})]}):(0,r.jsxs)(l.default,{className:"p-4 flex-1",children:[(0,r.jsx)("h3",{className:"text-sm font-semibold text-text-muted uppercase tracking-wider mb-3",children:"API Key Breakdown"}),(0,r.jsx)("div",{className:"text-center text-text-muted text-sm py-8",children:"No data"})]})}function R({activityMap:e}){let t=(0,a.useMemo)(()=>{if(!e)return null;let t=new Date,s=null,r=0;for(let a=0;a<7;a++){let l=new Date(t);l.setDate(l.getDate()-a);let n=`${l.getFullYear()}-${String(l.getMonth()+1).padStart(2,"0")}-${String(l.getDate()).padStart(2,"0")}`,i=e[n]||0;i>r&&(r=i,s=n)}if(!s||0===r)return null;let a=new Date(s+"T12:00:00");return{weekday:["domingo","segunda","ter\xe7a","quarta","quinta","sexta","s\xe1bado"][a.getDay()],label:`${a.getDate()} de ${["jan","fev","mar","abr","mai","jun","jul","ago","set","out","nov","dez"][a.getMonth()]}`,tokens:r}},[e]);return(0,r.jsxs)(l.default,{className:"p-4 flex flex-col justify-center",style:{flex:1,minHeight:0},children:[(0,r.jsx)("h3",{className:"text-xs font-semibold uppercase tracking-wider mb-2",style:{color:"var(--text-muted)"},children:"Most Active Day"}),t?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("span",{className:"text-xl font-bold capitalize",style:{lineHeight:1.2},children:t.weekday}),(0,r.jsxs)("span",{className:"text-xs mt-1",style:{color:"var(--text-muted)"},children:[t.label," \xb7 ",(0,i.VK)(t.tokens)," tokens"]})]}):(0,r.jsx)("span",{className:"text-xs",style:{color:"var(--text-muted)"},children:"Sem dados nos \xfaltimos 7 dias"})]})}function E({activityMap:e}){let t=(0,a.useMemo)(()=>{if(!e)return[];let t=new Date,s=[],r=0;for(let a=6;a>=0;a--){let l=new Date(t);l.setDate(l.getDate()-a);let n=`${l.getFullYear()}-${String(l.getMonth()+1).padStart(2,"0")}-${String(l.getDate()).padStart(2,"0")}`,i=e[n]||0;i>r&&(r=i);let o=["DOM","SEG","TER","QUA","QUI","SEX","S\xc1B"];s.push({key:n,val:i,label:o[l.getDay()]})}return s.map(e=>({...e,intensity:r>0?e.val/r:0}))},[e]);return(0,r.jsxs)(l.default,{className:"p-4 flex flex-col justify-center",style:{flex:1,minHeight:0},children:[(0,r.jsx)("h3",{className:"text-xs font-semibold uppercase tracking-wider mb-3",style:{color:"var(--text-muted)"},children:"Weekly"}),(0,r.jsx)("div",{style:{display:"flex",alignItems:"flex-end",gap:6,justifyContent:"center"},children:t.map((e,t)=>{var s;return(0,r.jsxs)("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",gap:4},children:[(0,r.jsx)("div",{title:`${e.key}: ${(0,i.xW)(e.val)} tokens`,style:{width:36,height:36,borderRadius:8,...0===(s=e.intensity)?{background:"rgba(255,255,255,0.04)"}:{background:`rgba(229, 77, 94, ${(.15+.75*s).toFixed(2)})`},transition:"all 0.2s",cursor:"default"}}),(0,r.jsx)("span",{style:{fontSize:9,fontWeight:600,color:"var(--text-muted)",letterSpacing:"0.03em"},children:e.label})]},t)})})]})}function L({byModel:e,summary:t}){let[s,n]=(0,a.useState)("totalTokens"),[c,d]=(0,a.useState)("desc"),x=(0,a.useCallback)(e=>{s===e?d(e=>"asc"===e?"desc":"asc"):(n(e),d("desc"))},[s]),m=(0,a.useMemo)(()=>{let t=[...e||[]];return t.sort((e,t)=>{let r=e[s]??0,a=t[s]??0;return"string"==typeof r?"asc"===c?r.localeCompare(a):a.localeCompare(r):"asc"===c?r-a:a-r}),t},[e,s,c]);return(0,r.jsxs)(l.default,{className:"overflow-hidden",children:[(0,r.jsx)("div",{className:"p-4 border-b border-border",children:(0,r.jsx)("h3",{className:"text-sm font-semibold text-text-muted uppercase tracking-wider",children:"Model Breakdown"})}),(0,r.jsx)("div",{className:"overflow-x-auto",children:(0,r.jsxs)("table",{className:"w-full text-sm",children:[(0,r.jsx)("thead",{className:"text-xs text-text-muted uppercase bg-black/[0.02] dark:bg-white/[0.02]",children:(0,r.jsxs)("tr",{children:[(0,r.jsxs)("th",{className:"px-4 py-2.5 text-left cursor-pointer group",onClick:()=>x("model"),children:["Model ",(0,r.jsx)(N,{active:"model"===s,sortOrder:c})]}),(0,r.jsxs)("th",{className:"px-4 py-2.5 text-right cursor-pointer group",onClick:()=>x("requests"),children:["Requests ",(0,r.jsx)(N,{active:"requests"===s,sortOrder:c})]}),(0,r.jsxs)("th",{className:"px-4 py-2.5 text-right cursor-pointer group",onClick:()=>x("promptTokens"),children:["Input ",(0,r.jsx)(N,{active:"promptTokens"===s,sortOrder:c})]}),(0,r.jsxs)("th",{className:"px-4 py-2.5 text-right cursor-pointer group",onClick:()=>x("completionTokens"),children:["Output"," ",(0,r.jsx)(N,{active:"completionTokens"===s,sortOrder:c})]}),(0,r.jsxs)("th",{className:"px-4 py-2.5 text-right cursor-pointer group",onClick:()=>x("totalTokens"),children:["Total ",(0,r.jsx)(N,{active:"totalTokens"===s,sortOrder:c})]}),(0,r.jsxs)("th",{className:"px-4 py-2.5 text-right cursor-pointer group",onClick:()=>x("cost"),children:["Cost ",(0,r.jsx)(N,{active:"cost"===s,sortOrder:c})]}),(0,r.jsx)("th",{className:"px-4 py-2.5 text-right w-36",children:"Share"})]})}),(0,r.jsx)("tbody",{className:"divide-y divide-border",children:m.map((e,t)=>(0,r.jsxs)("tr",{className:"hover:bg-black/[0.02] dark:hover:bg-white/[0.02] transition-colors",children:[(0,r.jsx)("td",{className:"px-4 py-2.5",children:(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("span",{className:"w-2 h-2 rounded-full shrink-0",style:{backgroundColor:(0,o.ng)(t)}}),(0,r.jsx)("span",{className:"font-medium",children:e.model})]})}),(0,r.jsx)("td",{className:"px-4 py-2.5 text-right font-mono text-text-muted",children:(0,i.xW)(e.requests)}),(0,r.jsx)("td",{className:"px-4 py-2.5 text-right font-mono text-primary",children:(0,i.VK)(e.promptTokens)}),(0,r.jsx)("td",{className:"px-4 py-2.5 text-right font-mono text-emerald-500",children:(0,i.VK)(e.completionTokens)}),(0,r.jsx)("td",{className:"px-4 py-2.5 text-right font-mono font-semibold",children:(0,i.VK)(e.totalTokens)}),(0,r.jsx)("td",{className:"px-4 py-2.5 text-right font-mono text-amber-500",children:(0,i.F0)(e.cost)}),(0,r.jsx)("td",{className:"px-4 py-2.5 text-right",children:(0,r.jsxs)("div",{className:"flex items-center gap-2 justify-end",children:[(0,r.jsx)("div",{className:"w-16 h-1.5 rounded-full bg-white/[0.06] overflow-hidden",children:(0,r.jsx)("div",{className:"h-full rounded-full transition-all",style:{width:`${e.pct}%`,backgroundColor:(0,o.ng)(t)}})}),(0,r.jsxs)("span",{className:"text-xs font-mono text-text-muted w-10 text-right",children:[e.pct,"%"]})]})})]},e.model))})]})})]})}let A=["#f59e0b","#ef4444","#8b5cf6","#10b981","#06b6d4","#ec4899","#f97316","#6366f1","#14b8a6","#a855f7"];function _({byProvider:e}){let t=(0,a.useMemo)(()=>e||[],[e]),s=t.length>0&&t.some(e=>e.cost>0),n=(0,a.useMemo)(()=>t.filter(e=>e.cost>0).sort((e,t)=>t.cost-e.cost).slice(0,8).map((e,t)=>({name:e.provider,value:e.cost,fill:A[t%A.length]})),[t]);return s?(0,r.jsxs)(l.default,{className:"p-4 flex-1",children:[(0,r.jsx)("h3",{className:"text-sm font-semibold text-text-muted uppercase tracking-wider mb-3",children:"Cost by Provider"}),(0,r.jsxs)("div",{className:"flex items-center gap-4",children:[(0,r.jsx)(c.u,{width:120,height:120,children:(0,r.jsxs)(b.r,{children:[(0,r.jsx)(f.Fq,{data:n,dataKey:"value",nameKey:"name",cx:"50%",cy:"50%",innerRadius:28,outerRadius:55,paddingAngle:1,animationDuration:600,children:n.map((e,t)=>(0,r.jsx)(g.f,{fill:e.fill,stroke:"none"},t))}),(0,r.jsx)(u.m,{content:(0,r.jsx)(v,{formatter:i.F0})})]})}),(0,r.jsx)("div",{className:"flex flex-col gap-1 min-w-0 flex-1",children:n.map((e,t)=>(0,r.jsxs)("div",{className:"flex items-center justify-between gap-2 text-xs",children:[(0,r.jsxs)("div",{className:"flex items-center gap-1.5 min-w-0",children:[(0,r.jsx)("span",{className:"w-2 h-2 rounded-full shrink-0",style:{backgroundColor:e.fill}}),(0,r.jsx)("span",{className:"truncate text-text-main capitalize",children:e.name})]}),(0,r.jsx)("span",{className:"font-mono font-medium text-amber-500 shrink-0",children:(0,i.F0)(e.value)})]},t))})]})]}):(0,r.jsxs)(l.default,{className:"p-4 flex-1",children:[(0,r.jsx)("h3",{className:"text-sm font-semibold text-text-muted uppercase tracking-wider mb-3",children:"Cost by Provider"}),(0,r.jsx)("div",{className:"text-center text-text-muted text-sm py-8",children:"No cost data"})]})}function M({dailyByModel:e,modelNames:t}){let s=(0,a.useMemo)(()=>e||[],[e]),n=(0,a.useMemo)(()=>t||[],[t]),d=(0,a.useMemo)(()=>s.map(e=>{let t={...e};if(e.date){let s=e.date.split("-");t.dateLabel=`${s[1]}/${s[2]}`}return t}),[s]);return s.length&&n.length?(0,r.jsxs)(l.default,{className:"p-4",children:[(0,r.jsx)("h3",{className:"text-sm font-semibold text-text-muted uppercase tracking-wider mb-3",children:"Model Usage Over Time"}),(0,r.jsx)(c.u,{width:"100%",height:240,children:(0,r.jsxs)(y.Q,{data:d,margin:{top:4,right:4,left:0,bottom:0},children:[(0,r.jsx)(x.W,{dataKey:"dateLabel",tick:{fontSize:10,fill:"var(--text-muted)"},axisLine:!1,tickLine:!1,interval:"preserveStartEnd"}),(0,r.jsx)(m.h,{tick:{fontSize:10,fill:"var(--text-muted)"},tickFormatter:e=>(0,i.VK)(e),axisLine:!1,tickLine:!1,width:50}),(0,r.jsx)(u.m,{content:(0,r.jsx)(v,{formatter:i.VK})}),n.map((e,t)=>(0,r.jsx)(j.Gk,{type:"monotone",dataKey:e,stackId:"1",stroke:(0,o.ng)(t),fill:(0,o.ng)(t),fillOpacity:.4,strokeWidth:1.5,animationDuration:600},e))]})}),(0,r.jsx)("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1 mt-2 text-[10px] text-text-muted",children:n.map((e,t)=>(0,r.jsxs)("span",{className:"flex items-center gap-1",children:[(0,r.jsx)("span",{className:"w-2 h-2 rounded-full shrink-0",style:{backgroundColor:(0,o.ng)(t)}}),e]},e))})]}):(0,r.jsxs)(l.default,{className:"p-4",children:[(0,r.jsx)("h3",{className:"text-sm font-semibold text-text-muted uppercase tracking-wider mb-3",children:"Model Usage Over Time"}),(0,r.jsx)("div",{className:"text-center text-text-muted text-sm py-8",children:"No data"})]})}function $({byProvider:e}){let[t,s]=(0,a.useState)("totalTokens"),[n,o]=(0,a.useState)("desc"),c=(0,a.useMemo)(()=>e||[],[e]),d=(0,a.useMemo)(()=>c.reduce((e,t)=>e+t.totalTokens,0),[c]),x=(0,a.useCallback)(e=>{t===e?o(e=>"asc"===e?"desc":"asc"):(s(e),o("desc"))},[t]),m=(0,a.useMemo)(()=>{let e=[...c];return e.sort((e,s)=>{let r=e[t]??0,a=s[t]??0;return"string"==typeof r?"asc"===n?r.localeCompare(a):a.localeCompare(r):"asc"===n?r-a:a-r}),e},[c,t,n]);return c.length?(0,r.jsxs)(l.default,{className:"overflow-hidden",children:[(0,r.jsx)("div",{className:"p-4 border-b border-border",children:(0,r.jsx)("h3",{className:"text-sm font-semibold text-text-muted uppercase tracking-wider",children:"Provider Breakdown"})}),(0,r.jsx)("div",{className:"overflow-x-auto",children:(0,r.jsxs)("table",{className:"w-full text-sm",children:[(0,r.jsx)("thead",{className:"text-xs text-text-muted uppercase bg-black/[0.02] dark:bg-white/[0.02]",children:(0,r.jsxs)("tr",{children:[(0,r.jsxs)("th",{className:"px-4 py-2.5 text-left cursor-pointer group",onClick:()=>x("provider"),children:["Provider ",(0,r.jsx)(N,{active:"provider"===t,sortOrder:n})]}),(0,r.jsxs)("th",{className:"px-4 py-2.5 text-right cursor-pointer group",onClick:()=>x("requests"),children:["Requests ",(0,r.jsx)(N,{active:"requests"===t,sortOrder:n})]}),(0,r.jsxs)("th",{className:"px-4 py-2.5 text-right cursor-pointer group",onClick:()=>x("promptTokens"),children:["Input ",(0,r.jsx)(N,{active:"promptTokens"===t,sortOrder:n})]}),(0,r.jsxs)("th",{className:"px-4 py-2.5 text-right cursor-pointer group",onClick:()=>x("completionTokens"),children:["Output"," ",(0,r.jsx)(N,{active:"completionTokens"===t,sortOrder:n})]}),(0,r.jsxs)("th",{className:"px-4 py-2.5 text-right cursor-pointer group",onClick:()=>x("totalTokens"),children:["Total ",(0,r.jsx)(N,{active:"totalTokens"===t,sortOrder:n})]}),(0,r.jsxs)("th",{className:"px-4 py-2.5 text-right cursor-pointer group",onClick:()=>x("cost"),children:["Cost ",(0,r.jsx)(N,{active:"cost"===t,sortOrder:n})]}),(0,r.jsx)("th",{className:"px-4 py-2.5 text-right w-36",children:"Share"})]})}),(0,r.jsx)("tbody",{className:"divide-y divide-border",children:m.map((e,t)=>{let s=d>0?(e.totalTokens/d*100).toFixed(1):"0";return(0,r.jsxs)("tr",{className:"hover:bg-black/[0.02] dark:hover:bg-white/[0.02] transition-colors",children:[(0,r.jsx)("td",{className:"px-4 py-2.5",children:(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("span",{className:"w-2 h-2 rounded-full shrink-0",style:{backgroundColor:A[t%A.length]}}),(0,r.jsx)("span",{className:"font-medium capitalize",children:e.provider})]})}),(0,r.jsx)("td",{className:"px-4 py-2.5 text-right font-mono text-text-muted",children:(0,i.xW)(e.requests)}),(0,r.jsx)("td",{className:"px-4 py-2.5 text-right font-mono text-primary",children:(0,i.VK)(e.promptTokens)}),(0,r.jsx)("td",{className:"px-4 py-2.5 text-right font-mono text-emerald-500",children:(0,i.VK)(e.completionTokens)}),(0,r.jsx)("td",{className:"px-4 py-2.5 text-right font-mono font-semibold",children:(0,i.VK)(e.totalTokens)}),(0,r.jsx)("td",{className:"px-4 py-2.5 text-right font-mono text-amber-500",children:(0,i.F0)(e.cost)}),(0,r.jsx)("td",{className:"px-4 py-2.5 text-right",children:(0,r.jsxs)("div",{className:"flex items-center gap-2 justify-end",children:[(0,r.jsx)("div",{className:"w-16 h-1.5 rounded-full bg-white/[0.06] overflow-hidden",children:(0,r.jsx)("div",{className:"h-full rounded-full transition-all",style:{width:`${s}%`,backgroundColor:A[t%A.length]}})}),(0,r.jsxs)("span",{className:"text-xs font-mono text-text-muted w-10 text-right",children:[s,"%"]})]})})]},e.provider)})})]})})]}):(0,r.jsxs)(l.default,{className:"p-4",children:[(0,r.jsx)("h3",{className:"text-sm font-semibold text-text-muted uppercase tracking-wider mb-3",children:"Provider Breakdown"}),(0,r.jsx)("div",{className:"text-center text-text-muted text-sm py-8",children:"No data"})]})}function P(){let[e,t]=(0,a.useState)("30d"),[s,o]=(0,a.useState)(null),[c,d]=(0,a.useState)(!0),[x,m]=(0,a.useState)(null),u=(0,a.useCallback)(async()=>{try{d(!0);let t=await fetch(`/api/usage/analytics?range=${e}`);if(!t.ok)throw Error("Failed to fetch");let s=await t.json();o(s),m(null)}catch(e){m(e.message)}finally{d(!1)}},[e]);(0,a.useEffect)(()=>{u()},[u]);let p=(0,a.useMemo)(()=>{let e=s?.byModel||[];return e.length>0?e[0].model:"—"},[s]),h=(0,a.useMemo)(()=>{let e=s?.byProvider||[];return e.length>0?e[0].provider:"—"},[s]),b=(0,a.useMemo)(()=>{let e=s?.weeklyPattern||[];if(!e.length)return"—";let t=e.reduce((e,t)=>e.avgTokens>t.avgTokens?e:t,e[0]);return t.avgTokens>0?t.day:"—"},[s]),f=(0,a.useMemo)(()=>(s?.byProvider||[]).length,[s]);if(c&&!s)return(0,r.jsx)(n.CardSkeleton,{});if(x)return(0,r.jsxs)(l.default,{className:"p-6 text-center text-red-500",children:["Error: ",x]});let g=s?.summary||{},y=g.totalRequests>0?Math.round(g.totalTokens/g.totalRequests):0,j=g.totalRequests>0?g.totalCost/g.totalRequests:0,v=g.completionTokens>0?(g.promptTokens/g.completionTokens).toFixed(1):"—";return(0,r.jsxs)("div",{className:"flex flex-col gap-5",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between",children:[(0,r.jsxs)("h2",{className:"text-xl font-semibold flex items-center gap-2",children:[(0,r.jsx)("span",{className:"material-symbols-outlined text-primary text-[22px]",children:"analytics"}),"Usage Analytics"]}),(0,r.jsx)("div",{className:"flex items-center gap-1 bg-black/[0.03] dark:bg-white/[0.03] rounded-lg p-1 border border-black/5 dark:border-white/5",children:[{value:"1d",label:"1D"},{value:"7d",label:"7D"},{value:"30d",label:"30D"},{value:"90d",label:"90D"},{value:"ytd",label:"YTD"},{value:"all",label:"All"}].map(s=>(0,r.jsx)("button",{onClick:()=>t(s.value),className:`px-3 py-1 rounded-md text-xs font-semibold transition-all ${e===s.value?"bg-primary text-white shadow-sm":"text-text-muted hover:text-text-main hover:bg-black/5 dark:hover:bg-white/5"}`,children:s.label},s.value))})]}),(0,r.jsxs)("div",{className:"grid grid-cols-2 md:grid-cols-7 gap-3",children:[(0,r.jsx)(k,{icon:"generating_tokens",label:"Total Tokens",value:(0,i.VK)(g.totalTokens),subValue:`${(0,i.xW)(g.totalRequests)} requests`}),(0,r.jsx)(k,{icon:"input",label:"Input Tokens",value:(0,i.VK)(g.promptTokens),color:"text-primary"}),(0,r.jsx)(k,{icon:"output",label:"Output Tokens",value:(0,i.VK)(g.completionTokens),color:"text-emerald-500"}),(0,r.jsx)(k,{icon:"payments",label:"Est. Cost",value:(0,i.F0)(g.totalCost),color:"text-amber-500"}),(0,r.jsx)(k,{icon:"group",label:"Accounts",value:g.uniqueAccounts||0}),(0,r.jsx)(k,{icon:"vpn_key",label:"API Keys",value:g.uniqueApiKeys||0}),(0,r.jsx)(k,{icon:"model_training",label:"Models",value:g.uniqueModels||0})]}),(0,r.jsxs)("div",{className:"grid grid-cols-2 md:grid-cols-7 gap-3",children:[(0,r.jsx)(k,{icon:"speed",label:"Avg Tokens/Req",value:(0,i.VK)(y),color:"text-cyan-500"}),(0,r.jsx)(k,{icon:"request_quote",label:"Cost/Request",value:(0,i.F0)(j),color:"text-orange-500"}),(0,r.jsx)(k,{icon:"compare_arrows",label:"I/O Ratio",value:`${v}x`,color:"text-violet-500"}),(0,r.jsx)(k,{icon:"star",label:"Top Model",value:p,color:"text-pink-500"}),(0,r.jsx)(k,{icon:"cloud",label:"Top Provider",value:h,color:"text-teal-500"}),(0,r.jsx)(k,{icon:"today",label:"Busiest Day",value:b,color:"text-rose-500"}),(0,r.jsx)(k,{icon:"dns",label:"Providers",value:f,color:"text-indigo-500"})]}),(0,r.jsxs)("div",{style:{display:"grid",gridTemplateColumns:"2fr 1fr",gap:16,alignItems:"stretch"},children:[(0,r.jsx)(w,{activityMap:s?.activityMap}),(0,r.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:16},children:[(0,r.jsx)(R,{activityMap:s?.activityMap}),(0,r.jsx)(E,{activityMap:s?.activityMap})]})]}),(0,r.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[(0,r.jsx)(C,{dailyTrend:s?.dailyTrend}),(0,r.jsx)(_,{byProvider:s?.byProvider})]}),(0,r.jsx)(M,{dailyByModel:s?.dailyByModel,modelNames:s?.modelNames}),(0,r.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[(0,r.jsx)(T,{byAccount:s?.byAccount}),(0,r.jsx)(I,{byApiKey:s?.byApiKey})]}),(0,r.jsx)($,{byProvider:s?.byProvider}),(0,r.jsx)(O,{byApiKey:s?.byApiKey}),(0,r.jsx)(L,{byModel:s?.byModel,summary:g})]})}},48643:(e,t,s)=>{s.d(t,{default:()=>p});var r=s(95155),a=s(12115),l=s(14051),n=s.n(l),i=s(71361),o=s(35806),c=s(41463);let d=[{value:"http",label:"HTTP"},{value:"https",label:"HTTPS"},{value:"socks5",label:"SOCKS5"}],x="true"===c.env.NEXT_PUBLIC_ENABLE_SOCKS5_PROXY,m=x?d:d.filter(e=>"socks5"!==e.value),u={global:"Global",provider:"Provider",combo:"Combo",key:"Key",direct:"Direct (none)"};function p({isOpen:e,onClose:t,level:s,levelId:l,levelLabel:n,onSaved:c}){let[d,p]=(0,a.useState)(m[0]?.value||"http"),[h,b]=(0,a.useState)(""),[f,g]=(0,a.useState)(""),[y,j]=(0,a.useState)(""),[v,N]=(0,a.useState)(""),[k,w]=(0,a.useState)(!1),[C,S]=(0,a.useState)(!1),[T,I]=(0,a.useState)(!1),[O,R]=(0,a.useState)(null),[E,L]=(0,a.useState)(!0),[A,_]=(0,a.useState)(null),[M,$]=(0,a.useState)(!1),[P,D]=(0,a.useState)(null),F=e=>"socks5"===e?"1080":"https"===e?"443":"8080";(0,a.useEffect)(()=>{e&&(R(null),D(null),L(!0),(async()=>{try{let e=new URLSearchParams({level:s});l&&e.set("id",l);let t=await fetch(`/api/settings/proxy?${e}`);if(t.ok){let e=(await t.json()).proxy;if(e&&e.host){let t=String(e.type||"http").toLowerCase(),s=m.some(e=>e.value===t);p(s?t:m[0]?.value||"http"),b(e.host||""),g(e.port||""),j(e.username||""),N(e.password||""),w(!!(e.username||e.password)),$(!0),"socks5"!==t||x||D("SOCKS5 is configured but hidden because NEXT_PUBLIC_ENABLE_SOCKS5_PROXY=false.")}else z(),$(!1)}if("global"!==s&&l){let e=await fetch("/api/settings/proxy");if(e.ok){let t=await e.json();"key"===s||"combo"===s?t.global&&_({level:"Global",proxy:t.global}):"provider"===s&&t.global&&_({level:"Global",proxy:t.global})}}}catch(e){console.error("Error loading proxy config:",e)}finally{L(!1)}})())},[e,s,l]);let z=()=>{p(m[0]?.value||"http"),b(""),g(""),j(""),N(""),w(!1),D(null)},K=async()=>{if(h.trim()){D(null),S(!0);try{let e={type:d,host:h.trim(),port:f.trim()||F(d),username:y.trim(),password:v.trim()},t=await fetch("/api/settings/proxy",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({level:s,id:l,proxy:e})}),r=await t.json().catch(()=>({}));if(!t.ok)return void D(r?.error?.message||"Failed to save proxy configuration");$(!0),c?.()}catch(e){console.error("Error saving proxy:",e),D(e.message||"Failed to save proxy configuration")}finally{S(!1)}}},U=async()=>{D(null),S(!0);try{let e=new URLSearchParams({level:s});l&&e.set("id",l);let t=await fetch(`/api/settings/proxy?${e}`,{method:"DELETE"}),r=await t.json().catch(()=>({}));if(!t.ok)return void D(r?.error?.message||"Failed to clear proxy configuration");z(),$(!1),R(null),c?.()}catch(e){console.error("Error clearing proxy:",e),D(e.message||"Failed to clear proxy configuration")}finally{S(!1)}},B=async()=>{if(h.trim()){D(null),I(!0),R(null);try{let e={type:d,host:h.trim(),port:f.trim()||F(d),username:y.trim(),password:v.trim()},t=await fetch("/api/settings/proxy/test",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({proxy:e})}),s=await t.json().catch(()=>({}));if(!t.ok){let e=s?.error?.message||"Connection failed";R({success:!1,error:e}),D(e);return}R(s)}catch(e){R({success:!1,error:e.message}),D(e.message||"Connection failed")}finally{I(!1)}}},q="global"===s?"Global Proxy Configuration":`${u[s]} Proxy — ${n||l||""}`;return(0,r.jsx)(i.default,{isOpen:e,onClose:t,title:q,maxWidth:"lg",children:E?(0,r.jsx)("div",{className:"py-8 text-center text-text-muted animate-pulse",children:"Loading proxy configuration..."}):(0,r.jsxs)("div",{className:"flex flex-col gap-5",children:["global"!==s&&!M&&A&&(0,r.jsxs)("div",{className:"flex items-center gap-2 px-3 py-2 rounded-lg bg-blue-500/10 border border-blue-500/20 text-sm",children:[(0,r.jsx)("span",{className:"material-symbols-outlined text-blue-400 text-base",children:"subdirectory_arrow_right"}),(0,r.jsxs)("span",{className:"text-blue-300",children:["Inheriting from ",(0,r.jsx)("strong",{children:A.level}),": ",A.proxy?.type,"://",A.proxy?.host,":",A.proxy?.port]})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:"text-xs text-text-muted mb-1.5 block uppercase tracking-wider font-medium",children:"Proxy Type"}),(0,r.jsx)("div",{className:"flex gap-1 bg-bg-subtle rounded-lg p-1 border border-border",children:m.map(e=>(0,r.jsx)("button",{onClick:()=>p(e.value),className:`flex-1 px-4 py-2 rounded-md text-sm font-medium transition-all ${d===e.value?"bg-primary text-white shadow-sm":"text-text-muted hover:text-text-primary hover:bg-black/5 dark:hover:bg-white/5"}`,children:e.label},e.value))})]}),(0,r.jsxs)("div",{className:"grid grid-cols-3 gap-3",children:[(0,r.jsxs)("div",{className:"col-span-2",children:[(0,r.jsx)("label",{className:"text-xs text-text-muted mb-1.5 block uppercase tracking-wider font-medium",children:"Host"}),(0,r.jsx)("input",{type:"text",value:h,onChange:e=>b(e.target.value),placeholder:"1.2.3.4 or proxy.example.com",className:"w-full px-3 py-2.5 rounded-lg bg-bg-subtle border border-border text-sm text-text-primary placeholder:text-text-muted/50 focus:outline-none focus:border-primary transition-colors"})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:"text-xs text-text-muted mb-1.5 block uppercase tracking-wider font-medium",children:"Port"}),(0,r.jsx)("input",{type:"text",value:f,onChange:e=>g(e.target.value),placeholder:F(d),className:"w-full px-3 py-2.5 rounded-lg bg-bg-subtle border border-border text-sm text-text-primary placeholder:text-text-muted/50 focus:outline-none focus:border-primary transition-colors"})]})]}),(0,r.jsxs)("div",{children:[(0,r.jsxs)("button",{onClick:()=>w(!k),className:"flex items-center gap-2 text-sm text-text-muted hover:text-text-primary transition-colors",children:[(0,r.jsx)("span",{className:"material-symbols-outlined text-base",children:k?"expand_less":"expand_more"}),"Authentication (optional)"]}),k&&(0,r.jsxs)("div",{className:"grid grid-cols-2 gap-3 mt-3",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:"text-xs text-text-muted mb-1.5 block uppercase tracking-wider font-medium",children:"Username"}),(0,r.jsx)("input",{type:"text",value:y,onChange:e=>j(e.target.value),placeholder:"Username",className:"w-full px-3 py-2.5 rounded-lg bg-bg-subtle border border-border text-sm text-text-primary placeholder:text-text-muted/50 focus:outline-none focus:border-primary transition-colors"})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:"text-xs text-text-muted mb-1.5 block uppercase tracking-wider font-medium",children:"Password"}),(0,r.jsx)("input",{type:"password",value:v,onChange:e=>N(e.target.value),placeholder:"Password",className:"w-full px-3 py-2.5 rounded-lg bg-bg-subtle border border-border text-sm text-text-primary placeholder:text-text-muted/50 focus:outline-none focus:border-primary transition-colors"})]})]})]}),P&&(0,r.jsx)("div",{className:"px-4 py-3 rounded-lg border border-red-500/30 bg-red-500/10 text-sm text-red-400",children:P}),O&&(0,r.jsxs)("div",{className:`flex items-center gap-3 px-4 py-3 rounded-lg border ${O.success?"bg-emerald-500/10 border-emerald-500/30":"bg-red-500/10 border-red-500/30"}`,children:[(0,r.jsx)("span",{className:`material-symbols-outlined text-xl ${O.success?"text-emerald-400":"text-red-400"}`,children:O.success?"check_circle":"error"}),(0,r.jsx)("div",{className:"flex-1",children:O.success?(0,r.jsxs)("div",{children:[(0,r.jsx)("span",{className:"text-sm font-medium text-emerald-400",children:"Connected"}),(0,r.jsxs)("span",{className:"text-text-muted text-xs ml-2",children:["IP: ",(0,r.jsx)("span",{className:"font-mono text-emerald-300",children:O.publicIp}),O.latencyMs&&` \xb7 ${O.latencyMs}ms`]})]}):(0,r.jsxs)("div",{className:"text-sm text-red-400",children:[O.error||"Connection failed",O.latencyMs&&(0,r.jsxs)("span",{className:"text-text-muted text-xs ml-2",children:["(",O.latencyMs,"ms)"]})]})})]}),(0,r.jsxs)("div",{className:"flex items-center justify-between pt-2 border-t border-border",children:[(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsx)(o.default,{size:"sm",variant:"secondary",icon:"speed",onClick:B,loading:T,disabled:!h.trim(),children:"Test Connection"}),M&&(0,r.jsx)(o.default,{size:"sm",variant:"ghost",icon:"delete",onClick:U,disabled:C,className:"!text-red-400 hover:!bg-red-500/10",children:"Clear"})]}),(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsx)(o.default,{size:"sm",variant:"secondary",onClick:t,children:"Cancel"}),(0,r.jsx)(o.default,{size:"sm",icon:"save",onClick:K,loading:C,disabled:!h.trim(),children:"Save"})]})]})]})})}p.propTypes={isOpen:n().bool.isRequired,onClose:n().func.isRequired,level:n().oneOf(["global","provider","combo","key"]).isRequired,levelId:n().string,levelLabel:n().string,onSaved:n().func}},51503:(e,t,s)=>{s.d(t,{default:()=>l});var r=s(95155),a=s(12115);function l({searchValue:e="",onSearchChange:t,placeholder:s="Search...",filters:l=[],activeFilters:n={},onFilterChange:i,children:o}){let[c,d]=(0,a.useState)(null),x=(0,a.useCallback)(()=>{t(""),l.forEach(e=>i(e.key,"")),d(null)},[t,l,i]),m=e||Object.values(n).some(e=>e&&""!==e);return(0,r.jsxs)("div",{style:{display:"flex",flexWrap:"wrap",gap:"8px",alignItems:"center",padding:"8px 0"},children:[(0,r.jsxs)("div",{style:{position:"relative",flex:"1 1 200px",minWidth:"200px"},children:[(0,r.jsx)("input",{type:"text",value:e,onChange:e=>t(e.target.value),placeholder:s,style:{width:"100%",padding:"8px 12px 8px 32px",borderRadius:"6px",border:"1px solid rgba(255,255,255,0.1)",background:"rgba(255,255,255,0.05)",color:"var(--text-primary, #e0e0e0)",fontSize:"13px",outline:"none"}}),(0,r.jsx)("span",{style:{position:"absolute",left:"10px",top:"50%",transform:"translateY(-50%)",opacity:.4,fontSize:"14px",pointerEvents:"none"},children:"\uD83D\uDD0D"})]}),l.map(e=>(0,r.jsxs)("div",{style:{position:"relative"},children:[(0,r.jsxs)("button",{onClick:()=>d(c===e.key?null:e.key),style:{padding:"6px 12px",borderRadius:"6px",border:`1px solid ${n[e.key]?"rgba(99,102,241,0.5)":"rgba(255,255,255,0.1)"}`,background:n[e.key]?"rgba(99,102,241,0.15)":"rgba(255,255,255,0.05)",color:n[e.key]?"#818cf8":"var(--text-secondary, #888)",fontSize:"12px",cursor:"pointer",whiteSpace:"nowrap"},children:[e.label,n[e.key]?` \xb7 ${n[e.key]}`:""]}),c===e.key&&(0,r.jsxs)("div",{style:{position:"absolute",top:"100%",left:0,marginTop:"4px",background:"rgba(20,20,30,0.95)",border:"1px solid rgba(255,255,255,0.1)",borderRadius:"8px",padding:"4px",zIndex:50,minWidth:"120px",backdropFilter:"blur(12px)"},children:[(0,r.jsx)("button",{onClick:()=>{i(e.key,""),d(null)},style:{display:"block",width:"100%",padding:"6px 12px",textAlign:"left",background:"none",border:"none",color:"#888",fontSize:"12px",cursor:"pointer",borderRadius:"4px"},children:"All"}),(e.options||[]).map(t=>(0,r.jsx)("button",{onClick:()=>{i(e.key,t),d(null)},style:{display:"block",width:"100%",padding:"6px 12px",textAlign:"left",background:n[e.key]===t?"rgba(99,102,241,0.2)":"none",border:"none",color:n[e.key]===t?"#818cf8":"var(--text-primary, #e0e0e0)",fontSize:"12px",cursor:"pointer",borderRadius:"4px"},children:t},t))]})]},e.key)),m&&(0,r.jsx)("button",{onClick:x,style:{padding:"6px 12px",borderRadius:"6px",border:"1px solid rgba(239,68,68,0.3)",background:"rgba(239,68,68,0.1)",color:"#ef4444",fontSize:"12px",cursor:"pointer"},children:"Clear"}),o]})}},54128:(e,t,s)=>{s.d(t,{default:()=>l});var r=s(95155),a=s(12115);function l({columns:e=[],visible:t={},onToggle:s}){let[l,n]=(0,a.useState)(!1),i=(0,a.useRef)(null);return(0,a.useEffect)(()=>{if(!l)return;let e=e=>{i.current&&!i.current.contains(e.target)&&n(!1)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[l]),(0,r.jsxs)("div",{ref:i,style:{position:"relative"},children:[(0,r.jsxs)("button",{onClick:()=>n(!l),title:"Toggle columns",style:{padding:"6px 10px",borderRadius:"6px",border:"1px solid rgba(255,255,255,0.1)",background:"rgba(255,255,255,0.05)",color:"var(--text-secondary, #888)",fontSize:"13px",cursor:"pointer",display:"flex",alignItems:"center",gap:"4px"},children:[(0,r.jsx)("span",{style:{fontSize:"14px"},children:"⚙️"}),"Columns"]}),l&&(0,r.jsx)("div",{style:{position:"absolute",top:"100%",right:0,marginTop:"4px",background:"rgba(20,20,30,0.95)",border:"1px solid rgba(255,255,255,0.1)",borderRadius:"8px",padding:"8px",zIndex:50,minWidth:"160px",backdropFilter:"blur(12px)"},children:e.map(e=>(0,r.jsxs)("label",{style:{display:"flex",alignItems:"center",gap:"8px",padding:"4px 8px",cursor:"pointer",fontSize:"12px",color:t[e.key]?"var(--text-primary, #e0e0e0)":"var(--text-secondary, #888)",borderRadius:"4px"},children:[(0,r.jsx)("input",{type:"checkbox",checked:t[e.key]??!0,onChange:()=>s(e.key),style:{accentColor:"#6366f1"}}),e.label]},e.key))})]})}},61580:(e,t,s)=>{s.d(t,{default:()=>c});var r=s(95155),a=s(67671),l=s(12115);let n={success:"✓",error:"✕",warning:"⚠",info:"ℹ"},i={success:{bg:"rgba(16, 185, 129, 0.15)",border:"rgba(16, 185, 129, 0.4)",icon:"#10b981"},error:{bg:"rgba(239, 68, 68, 0.15)",border:"rgba(239, 68, 68, 0.4)",icon:"#ef4444"},warning:{bg:"rgba(245, 158, 11, 0.15)",border:"rgba(245, 158, 11, 0.4)",icon:"#f59e0b"},info:{bg:"rgba(59, 130, 246, 0.15)",border:"rgba(59, 130, 246, 0.4)",icon:"#3b82f6"}};function o({notification:e,onDismiss:t}){let[s,a]=(0,l.useState)(!1),o=i[e.type]||i.info;return(0,r.jsxs)("div",{role:"alert","aria-live":"polite",style:{display:"flex",alignItems:"flex-start",gap:"12px",padding:"14px 16px",borderRadius:"10px",backgroundColor:o.bg,border:`1px solid ${o.border}`,backdropFilter:"blur(12px)",boxShadow:"0 8px 32px rgba(0,0,0,0.2)",minWidth:"320px",maxWidth:"420px",animation:s?"toastOut 0.2s ease-in forwards":"toastIn 0.3s ease-out forwards",transition:"all 0.2s ease"},children:[(0,r.jsx)("span",{style:{fontSize:"18px",color:o.icon,fontWeight:"bold",lineHeight:1,marginTop:"2px"},children:n[e.type]}),(0,r.jsxs)("div",{style:{flex:1,minWidth:0},children:[e.title&&(0,r.jsx)("div",{style:{fontWeight:600,fontSize:"14px",color:"var(--text-primary, #fff)",marginBottom:"2px"},children:e.title}),(0,r.jsx)("div",{style:{fontSize:"13px",color:"var(--text-secondary, #ccc)",lineHeight:1.4},children:e.message})]}),e.dismissible&&(0,r.jsx)("button",{onClick:()=>{a(!0),setTimeout(()=>t(e.id),200)},"aria-label":"Dismiss notification",style:{background:"none",border:"none",cursor:"pointer",color:"var(--text-secondary, #999)",fontSize:"16px",padding:"0 2px",lineHeight:1,opacity:.6,transition:"opacity 0.15s"},onMouseEnter:e=>e.currentTarget.style.opacity="1",onMouseLeave:e=>e.currentTarget.style.opacity="0.6",children:"\xd7"})]})}function c(){let{notifications:e,removeNotification:t}=(0,a.i)();return 0===e.length?null:(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("style",{children:`
|
|
1
|
+
"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[647],{1652:(e,t,s)=>{s.d(t,{default:()=>d});var r=s(95155),a=s(12115),l=s(14051),n=s.n(l),i=s(71361),o=s(35806),c=s(34422);function d({isOpen:e,onMethodSelect:t,onClose:s}){let[l,n]=(0,a.useState)(null),[d,x]=(0,a.useState)(""),[m,u]=(0,a.useState)("us-east-1"),[p,h]=(0,a.useState)(""),[b,f]=(0,a.useState)(null),[g,y]=(0,a.useState)(!1),[j,v]=(0,a.useState)(!1),[N,k]=(0,a.useState)(!1);(0,a.useEffect)(()=>{"import"===l&&e&&(async()=>{v(!0),f(null),k(!1);try{let e=await fetch("/api/oauth/kiro/auto-import"),t=await e.json();t.found?(h(t.refreshToken),k(!0)):f(t.error||"Could not auto-detect token")}catch(e){f("Failed to auto-detect token")}finally{v(!1)}})()},[l,e]);let w=e=>{n(e),f(null)},C=()=>{n(null),f(null)},S=async()=>{if(!p.trim())return void f("Please enter a refresh token");y(!0),f(null);try{let e=await fetch("/api/oauth/kiro/import",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({refreshToken:p.trim()})}),t=await e.json();if(!e.ok)throw Error(t.error||"Import failed");s()}catch(e){f(e.message)}finally{y(!1)}},T=e=>{t("social",{provider:e})};return(0,r.jsx)(i.default,{isOpen:e,title:"Connect Kiro",onClose:s,size:"lg",children:(0,r.jsxs)("div",{className:"flex flex-col gap-4",children:[!l&&(0,r.jsxs)("div",{className:"space-y-3",children:[(0,r.jsx)("p",{className:"text-sm text-text-muted mb-4",children:"Choose your authentication method:"}),(0,r.jsx)("button",{onClick:()=>t("builder-id"),className:"w-full p-4 text-left border border-border rounded-lg hover:bg-sidebar transition-colors",children:(0,r.jsxs)("div",{className:"flex items-start gap-3",children:[(0,r.jsx)("span",{className:"material-symbols-outlined text-primary mt-0.5",children:"shield"}),(0,r.jsxs)("div",{className:"flex-1",children:[(0,r.jsx)("h3",{className:"font-semibold mb-1",children:"AWS Builder ID"}),(0,r.jsx)("p",{className:"text-sm text-text-muted",children:"Recommended for most users. Free AWS account required."})]})]})}),(0,r.jsx)("button",{onClick:()=>w("idc"),className:"hidden w-full p-4 text-left border border-border rounded-lg hover:bg-sidebar transition-colors",children:(0,r.jsxs)("div",{className:"flex items-start gap-3",children:[(0,r.jsx)("span",{className:"material-symbols-outlined text-primary mt-0.5",children:"business"}),(0,r.jsxs)("div",{className:"flex-1",children:[(0,r.jsx)("h3",{className:"font-semibold mb-1",children:"AWS IAM Identity Center"}),(0,r.jsx)("p",{className:"text-sm text-text-muted",children:"For enterprise users with custom AWS IAM Identity Center."})]})]})}),(0,r.jsx)("button",{onClick:()=>w("social-google"),className:"hidden w-full p-4 text-left border border-border rounded-lg hover:bg-sidebar transition-colors",children:(0,r.jsxs)("div",{className:"flex items-start gap-3",children:[(0,r.jsx)("span",{className:"material-symbols-outlined text-primary mt-0.5",children:"account_circle"}),(0,r.jsxs)("div",{className:"flex-1",children:[(0,r.jsx)("h3",{className:"font-semibold mb-1",children:"Google Account"}),(0,r.jsx)("p",{className:"text-sm text-text-muted",children:"Login with your Google account (manual callback)."})]})]})}),(0,r.jsx)("button",{onClick:()=>w("social-github"),className:"hidden w-full p-4 text-left border border-border rounded-lg hover:bg-sidebar transition-colors",children:(0,r.jsxs)("div",{className:"flex items-start gap-3",children:[(0,r.jsx)("span",{className:"material-symbols-outlined text-primary mt-0.5",children:"code"}),(0,r.jsxs)("div",{className:"flex-1",children:[(0,r.jsx)("h3",{className:"font-semibold mb-1",children:"GitHub Account"}),(0,r.jsx)("p",{className:"text-sm text-text-muted",children:"Login with your GitHub account (manual callback)."})]})]})}),(0,r.jsx)("button",{onClick:()=>w("import"),className:"w-full p-4 text-left border border-border rounded-lg hover:bg-sidebar transition-colors",children:(0,r.jsxs)("div",{className:"flex items-start gap-3",children:[(0,r.jsx)("span",{className:"material-symbols-outlined text-primary mt-0.5",children:"file_upload"}),(0,r.jsxs)("div",{className:"flex-1",children:[(0,r.jsx)("h3",{className:"font-semibold mb-1",children:"Import Token"}),(0,r.jsx)("p",{className:"text-sm text-text-muted",children:"Paste refresh token from Kiro IDE."})]})]})})]}),"idc"===l&&(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsxs)("div",{children:[(0,r.jsxs)("label",{className:"block text-sm font-medium mb-2",children:["IDC Start URL ",(0,r.jsx)("span",{className:"text-red-500",children:"*"})]}),(0,r.jsx)(c.default,{value:d,onChange:e=>x(e.target.value),placeholder:"https://your-org.awsapps.com/start",className:"font-mono text-sm"}),(0,r.jsx)("p",{className:"text-xs text-text-muted mt-1",children:"Your organization's AWS IAM Identity Center URL"})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:"block text-sm font-medium mb-2",children:"AWS Region"}),(0,r.jsx)(c.default,{value:m,onChange:e=>u(e.target.value),placeholder:"us-east-1",className:"font-mono text-sm"}),(0,r.jsx)("p",{className:"text-xs text-text-muted mt-1",children:"AWS region for your Identity Center (default: us-east-1)"})]}),b&&(0,r.jsx)("p",{className:"text-sm text-red-600",children:b}),(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsx)(o.default,{onClick:()=>{d.trim()?t("idc",{startUrl:d.trim(),region:m}):f("Please enter your IDC start URL")},fullWidth:!0,children:"Continue"}),(0,r.jsx)(o.default,{onClick:C,variant:"ghost",fullWidth:!0,children:"Back"})]})]}),"social-google"===l&&(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsx)("div",{className:"bg-amber-50 dark:bg-amber-900/20 p-4 rounded-lg border border-amber-200 dark:border-amber-800",children:(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsx)("span",{className:"material-symbols-outlined text-amber-600 dark:text-amber-400",children:"info"}),(0,r.jsxs)("div",{className:"flex-1 text-sm",children:[(0,r.jsx)("p",{className:"font-medium text-amber-900 dark:text-amber-100 mb-1",children:"Manual Callback Required"}),(0,r.jsx)("p",{className:"text-amber-800 dark:text-amber-200",children:"After login, you'll need to copy the callback URL from your browser and paste it back here."})]})]})}),(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsx)(o.default,{onClick:()=>T("google"),fullWidth:!0,children:"Continue with Google"}),(0,r.jsx)(o.default,{onClick:C,variant:"ghost",fullWidth:!0,children:"Back"})]})]}),"social-github"===l&&(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsx)("div",{className:"bg-amber-50 dark:bg-amber-900/20 p-4 rounded-lg border border-amber-200 dark:border-amber-800",children:(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsx)("span",{className:"material-symbols-outlined text-amber-600 dark:text-amber-400",children:"info"}),(0,r.jsxs)("div",{className:"flex-1 text-sm",children:[(0,r.jsx)("p",{className:"font-medium text-amber-900 dark:text-amber-100 mb-1",children:"Manual Callback Required"}),(0,r.jsx)("p",{className:"text-amber-800 dark:text-amber-200",children:"After login, you'll need to copy the callback URL from your browser and paste it back here."})]})]})}),(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsx)(o.default,{onClick:()=>T("github"),fullWidth:!0,children:"Continue with GitHub"}),(0,r.jsx)(o.default,{onClick:C,variant:"ghost",fullWidth:!0,children:"Back"})]})]}),"import"===l&&(0,r.jsxs)("div",{className:"space-y-4",children:[j&&(0,r.jsxs)("div",{className:"text-center py-6",children:[(0,r.jsx)("div",{className:"size-16 mx-auto mb-4 rounded-full bg-primary/10 flex items-center justify-center",children:(0,r.jsx)("span",{className:"material-symbols-outlined text-3xl text-primary animate-spin",children:"progress_activity"})}),(0,r.jsx)("h3",{className:"text-lg font-semibold mb-2",children:"Auto-detecting token..."}),(0,r.jsx)("p",{className:"text-sm text-text-muted",children:"Reading from AWS SSO cache"})]}),!j&&(0,r.jsxs)(r.Fragment,{children:[N&&(0,r.jsx)("div",{className:"bg-green-50 dark:bg-green-900/20 p-3 rounded-lg border border-green-200 dark:border-green-800",children:(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsx)("span",{className:"material-symbols-outlined text-green-600 dark:text-green-400",children:"check_circle"}),(0,r.jsx)("p",{className:"text-sm text-green-800 dark:text-green-200",children:"Token auto-detected from Kiro IDE successfully!"})]})}),!N&&!b&&(0,r.jsx)("div",{className:"bg-blue-50 dark:bg-blue-900/20 p-3 rounded-lg border border-blue-200 dark:border-blue-800",children:(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsx)("span",{className:"material-symbols-outlined text-blue-600 dark:text-blue-400",children:"info"}),(0,r.jsx)("p",{className:"text-sm text-blue-800 dark:text-blue-200",children:"Kiro IDE not detected. Please paste your refresh token manually."})]})}),(0,r.jsxs)("div",{children:[(0,r.jsxs)("label",{className:"block text-sm font-medium mb-2",children:["Refresh Token ",(0,r.jsx)("span",{className:"text-red-500",children:"*"})]}),(0,r.jsx)(c.default,{value:p,onChange:e=>h(e.target.value),placeholder:"Token will be auto-filled...",className:"font-mono text-sm"})]}),b&&(0,r.jsx)("div",{className:"bg-red-50 dark:bg-red-900/20 p-3 rounded-lg border border-red-200 dark:border-red-800",children:(0,r.jsx)("p",{className:"text-sm text-red-600 dark:text-red-400",children:b})}),(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsx)(o.default,{onClick:S,fullWidth:!0,disabled:g||!p.trim(),children:g?"Importing...":"Import Token"}),(0,r.jsx)(o.default,{onClick:C,variant:"ghost",fullWidth:!0,children:"Back"})]})]})]})]})})}d.propTypes={isOpen:n().bool.isRequired,onMethodSelect:n().func.isRequired,onClose:n().func.isRequired}},6261:(e,t,s)=>{s.d(t,{default:()=>n});var r=s(95155),a=s(97550),l=s(67040);function n({className:e,variant:t="default"}){let{theme:s,toggleTheme:n,isDark:i}=(0,a.D)(),o={default:(0,l.cn)("flex items-center justify-center size-10 rounded-full","text-text-muted","hover:bg-black/5","hover:text-text-main","transition-colors"),card:(0,l.cn)("flex items-center justify-center size-11 rounded-full","bg-surface/60","hover:bg-surface","border border-border","backdrop-blur-md shadow-sm hover:shadow-md","text-text-muted-light hover:text-primary","hover:text-primary","transition-all group")};return(0,r.jsx)("button",{onClick:n,className:(0,l.cn)(o[t],e),"aria-label":`Switch to ${i?"light":"dark"} mode`,title:`Switch to ${i?"light":"dark"} mode`,children:(0,r.jsx)("span",{className:(0,l.cn)("material-symbols-outlined text-[22px]","card"===t&&"transition-transform duration-300 group-hover:rotate-12"),children:i?"light_mode":"dark_mode"})})}},8287:(e,t,s)=>{s.d(t,{default:()=>m});var r=s(95155),a=s(12115),l=s(81060),n=s(99333),i=s(8898);function o({log:e,onClose:t}){(0,a.useEffect)(()=>{let e=e=>{"Escape"===e.key&&t()};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[t]);let s=(0,n.Yh)(e.status),l=n.Gp[e.proxy?.type]||{bg:"#6B7280",text:"#fff",label:e.proxy?.type||"-"},o=n.Ie[e.level]||n.Ie.direct,c=n.RY[e.provider]||{bg:"#374151",text:"#fff",label:(e.provider||"-").toUpperCase()};return(0,r.jsxs)("div",{className:"fixed inset-0 z-50 flex items-start justify-center pt-[5vh]",onClick:t,role:"dialog","aria-modal":"true","aria-label":"Proxy log detail",children:[(0,r.jsx)("div",{className:"absolute inset-0 bg-black/60 backdrop-blur-sm"}),(0,r.jsxs)("div",{className:"relative bg-bg-primary border border-border rounded-xl w-full max-w-[700px] max-h-[90vh] 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-6 py-4 border-b border-border bg-bg-primary/95 backdrop-blur-sm rounded-t-xl",children:[(0,r.jsxs)("div",{className:"flex items-center gap-3",children:[(0,r.jsx)("span",{className:"inline-block px-2.5 py-1 rounded text-xs font-bold uppercase",style:{backgroundColor:s.bg,color:s.text},children:e.status}),(0,r.jsx)("span",{className:"font-bold text-lg",children:"Proxy Event"})]}),(0,r.jsx)("button",{onClick:t,className:"p-1.5 rounded-lg hover:bg-bg-subtle text-text-muted hover:text-text-primary transition-colors","aria-label":"Close proxy detail modal",children:(0,r.jsx)("span",{className:"material-symbols-outlined",children:"close"})})]}),(0,r.jsxs)("div",{className:"p-6 flex flex-col gap-6",children:[(0,r.jsxs)("div",{className:"grid grid-cols-2 md:grid-cols-3 gap-4 p-4 bg-bg-subtle rounded-xl border border-border",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("div",{className:"text-[10px] text-text-muted uppercase tracking-wider mb-1",children:"Time"}),(0,r.jsx)("div",{className:"text-sm font-medium",children:(e=>{try{let t=new Date(e);return t.toLocaleDateString("pt-BR")+", "+t.toLocaleTimeString("en-US",{hour12:!1})}catch{return e}})(e.timestamp)})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("div",{className:"text-[10px] text-text-muted uppercase tracking-wider mb-1",children:"Latency"}),(0,r.jsx)("div",{className:"text-sm font-medium",children:(0,i.a3)(e.latencyMs)})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("div",{className:"text-[10px] text-text-muted uppercase tracking-wider mb-1",children:"Public IP"}),(0,r.jsx)("div",{className:"text-sm font-medium font-mono text-emerald-400",children:e.publicIp||"—"})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("div",{className:"text-[10px] text-text-muted uppercase tracking-wider mb-1",children:"Proxy"}),(0,r.jsx)("div",{className:"text-sm font-medium font-mono text-primary",children:e.proxy?`${e.proxy.type}://${e.proxy.host}:${e.proxy.port}`:"Direct"})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("div",{className:"text-[10px] text-text-muted uppercase tracking-wider mb-1",children:"Type"}),(0,r.jsx)("span",{className:"inline-block px-2.5 py-1 rounded text-[10px] font-bold uppercase",style:{backgroundColor:l.bg,color:l.text},children:l.label})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("div",{className:"text-[10px] text-text-muted uppercase tracking-wider mb-1",children:"Level"}),(0,r.jsx)("span",{className:"inline-block px-2.5 py-1 rounded text-[10px] font-bold uppercase",style:{backgroundColor:o.bg,color:o.text},children:o.label})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("div",{className:"text-[10px] text-text-muted uppercase tracking-wider mb-1",children:"Provider"}),e.provider?(0,r.jsx)("span",{className:"inline-block px-2.5 py-1 rounded text-[10px] font-bold uppercase",style:{backgroundColor:c.bg,color:c.text},children:c.label}):(0,r.jsx)("div",{className:"text-sm text-text-muted",children:"—"})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("div",{className:"text-[10px] text-text-muted uppercase tracking-wider mb-1",children:"TLS Fingerprint"}),e.tlsFingerprint?(0,r.jsxs)("span",{className:"inline-flex items-center gap-1 px-2.5 py-1 rounded text-[10px] font-bold uppercase",style:{backgroundColor:"rgba(6, 182, 212, 0.15)",color:"#22d3ee"},children:[(0,r.jsx)("span",{style:{fontSize:"12px"},children:"\uD83D\uDD12"})," Chrome 124"]}):(0,r.jsx)("div",{className:"text-sm text-text-muted",children:"Direct (native)"})]}),(0,r.jsxs)("div",{className:"col-span-2",children:[(0,r.jsx)("div",{className:"text-[10px] text-text-muted uppercase tracking-wider mb-1",children:"Target URL"}),(0,r.jsx)("div",{className:"text-sm font-medium font-mono text-text-muted break-all",children:e.targetUrl||"—"})]})]}),e.error&&(0,r.jsxs)("div",{className:"p-4 rounded-xl bg-red-500/10 border border-red-500/30",children:[(0,r.jsx)("div",{className:"text-[10px] text-red-400 uppercase tracking-wider mb-1 font-bold",children:"Error"}),(0,r.jsx)("div",{className:"text-sm text-red-300 font-mono",children:e.error})]}),e.proxy&&(0,r.jsxs)("div",{className:"p-4 rounded-xl bg-bg-subtle border border-border",children:[(0,r.jsx)("div",{className:"text-[10px] text-text-muted uppercase tracking-wider mb-2 font-bold",children:"Proxy Configuration"}),(0,r.jsx)("pre",{className:"text-xs font-mono text-text-primary bg-black/20 rounded-lg p-3 overflow-x-auto",children:JSON.stringify(e.proxy,null,2)})]})]})]})]})}let c=[{key:"all",label:"All"},{key:"error",label:"Errors",icon:"error"},{key:"ok",label:"Success",icon:"check_circle"},{key:"timeout",label:"Timeout",icon:"timer_off"}],d=[{key:"status",label:"Status"},{key:"proxy",label:"Proxy"},{key:"tls",label:"TLS"},{key:"type",label:"Type"},{key:"level",label:"Level"},{key:"provider",label:"Provider"},{key:"target",label:"Target"},{key:"latency",label:"Latency"},{key:"ip",label:"Public IP"},{key:"time",label:"Time"}],x=Object.fromEntries(d.map(e=>[e.key,!0]));function m(){let[e,t]=(0,a.useState)([]),[s,m]=(0,a.useState)(!0),[u,p]=(0,a.useState)(!0),[h,b]=(0,a.useState)(""),[f,g]=(0,a.useState)("all"),[y,j]=(0,a.useState)(""),[v,N]=(0,a.useState)(""),[k,w]=(0,a.useState)(""),[C,S]=(0,a.useState)("newest"),[T,I]=(0,a.useState)(null),O=(0,a.useRef)(null),R=(0,a.useRef)(!1),[A,E]=(0,a.useState)(()=>{try{let e=localStorage.getItem("proxyLoggerVisibleColumns");return e?{...x,...JSON.parse(e)}:x}catch{return x}}),L=(0,a.useCallback)(e=>{E(t=>{let s={...t,[e]:!t[e]};try{localStorage.setItem("proxyLoggerVisibleColumns",JSON.stringify(s))}catch{}return s})},[]),M=(0,a.useCallback)(async(e=!1)=>{e&&m(!0);try{let e=new URLSearchParams;h&&e.set("search",h),"error"===f&&e.set("status","error"),"ok"===f&&e.set("status","ok"),"timeout"===f&&e.set("status","timeout"),y&&e.set("type",y),v&&e.set("provider",v),k&&e.set("level",k),e.set("limit","300");let s=await fetch(`/api/usage/proxy-logs?${e}`);if(s.ok){let e=await s.json();t(e)}}catch(e){console.error("Failed to fetch proxy logs:",e)}finally{e&&m(!1)}},[h,f,y,v,k]);(0,a.useEffect)(()=>{let e=!R.current;R.current=!0,M(e)},[M]),(0,a.useEffect)(()=>(O.current&&clearInterval(O.current),u&&(O.current=setInterval(()=>M(!1),3e3)),()=>{O.current&&clearInterval(O.current)}),[u,M]);let $=(0,a.useMemo)(()=>{let t=[...e];return t.sort((e,t)=>{switch(C){case"oldest":return new Date(e.timestamp).getTime()-new Date(t.timestamp).getTime();case"latency_desc":return(t.latencyMs||0)-(e.latencyMs||0);case"latency_asc":return(e.latencyMs||0)-(t.latencyMs||0);default:return new Date(t.timestamp).getTime()-new Date(e.timestamp).getTime()}}),t},[e,C]),_=[...new Set(e.map(e=>e.provider).filter(Boolean))].sort(),D=[...new Set(e.map(e=>e.proxy?.type).filter(Boolean))].sort(),P=[...new Set(e.map(e=>e.level).filter(Boolean))].sort(),F=e.length,z=e.filter(e=>"success"===e.status).length,K=e.filter(e=>"error"===e.status).length,U=e.filter(e=>"timeout"===e.status).length,q=e.filter(e=>"direct"===e.level).length,B=e.filter(e=>e.tlsFingerprint).length;return(0,r.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,r.jsxs)("div",{className:"flex flex-wrap items-center gap-3",children:[(0,r.jsxs)("button",{onClick:()=>p(!u),className:`flex items-center gap-2 px-3 py-1.5 rounded-full text-sm font-medium border transition-colors ${u?"bg-red-500/10 border-red-500/30 text-red-400":"bg-bg-subtle border-border text-text-muted"}`,children:[(0,r.jsx)("span",{className:`w-2 h-2 rounded-full ${u?"bg-red-500 animate-pulse":"bg-text-muted"}`}),u?"Recording":"Paused"]}),(0,r.jsxs)("div",{className:"flex-1 min-w-[200px] relative",children:[(0,r.jsx)("span",{className:"material-symbols-outlined absolute left-3 top-1/2 -translate-y-1/2 text-text-muted text-[18px]",children:"search"}),(0,r.jsx)("input",{type:"text",placeholder:"Search host, provider, target, IP...",value:h,onChange:e=>b(e.target.value),className:"w-full pl-10 pr-4 py-2 rounded-lg bg-bg-subtle border border-border text-sm text-text-primary placeholder:text-text-muted focus:outline-none focus:border-primary"})]}),(0,r.jsxs)("select",{value:y,onChange:e=>j(e.target.value),className:"px-3 py-2 rounded-lg bg-bg-subtle border border-border text-sm text-text-primary focus:outline-none focus:border-primary appearance-none cursor-pointer min-w-[120px]",children:[(0,r.jsx)("option",{value:"",children:"All Types"}),D.map(e=>(0,r.jsx)("option",{value:e,children:(n.Gp[e]?.label||e).toUpperCase()},e))]}),(0,r.jsxs)("select",{value:k,onChange:e=>w(e.target.value),className:"px-3 py-2 rounded-lg bg-bg-subtle border border-border text-sm text-text-primary focus:outline-none focus:border-primary appearance-none cursor-pointer min-w-[120px]",children:[(0,r.jsx)("option",{value:"",children:"All Levels"}),P.map(e=>(0,r.jsx)("option",{value:e,children:n.Ie[e]?.label||e},e))]}),(0,r.jsxs)("select",{value:v,onChange:e=>N(e.target.value),className:"px-3 py-2 rounded-lg bg-bg-subtle border border-border text-sm text-text-primary focus:outline-none focus:border-primary appearance-none cursor-pointer min-w-[140px]",children:[(0,r.jsx)("option",{value:"",children:"All Providers"}),_.map(e=>{let t=n.RY[e];return(0,r.jsx)("option",{value:e,children:t?.label||e.toUpperCase()},e)})]}),(0,r.jsxs)("div",{className:"flex items-center gap-2 text-xs text-text-muted",children:[(0,r.jsxs)("span",{className:"px-2 py-1 rounded bg-bg-subtle border border-border font-mono",children:[F," total"]}),(0,r.jsxs)("span",{className:"px-2 py-1 rounded bg-emerald-500/10 text-emerald-400 font-mono",children:[z," OK"]}),K>0&&(0,r.jsxs)("span",{className:"px-2 py-1 rounded bg-red-500/10 text-red-400 font-mono",children:[K," ERR"]}),U>0&&(0,r.jsxs)("span",{className:"px-2 py-1 rounded bg-amber-500/10 text-amber-400 font-mono",children:[U," TMO"]}),q>0&&(0,r.jsxs)("span",{className:"px-2 py-1 rounded bg-gray-500/10 text-gray-400 font-mono",children:[q," direct"]}),B>0&&(0,r.jsxs)("span",{className:"px-2 py-1 rounded bg-cyan-500/10 text-cyan-400 font-mono",children:["\uD83D\uDD12 ",B," TLS"]})]}),(0,r.jsxs)("select",{value:C,onChange:e=>S(e.target.value),className:"px-3 py-2 rounded-lg bg-bg-subtle border border-border text-sm text-text-primary focus:outline-none focus:border-primary appearance-none cursor-pointer min-w-[140px]",children:[(0,r.jsx)("option",{value:"newest",children:"Newest"}),(0,r.jsx)("option",{value:"oldest",children:"Oldest"}),(0,r.jsx)("option",{value:"latency_desc",children:"Latency ↓"}),(0,r.jsx)("option",{value:"latency_asc",children:"Latency ↑"})]}),(0,r.jsx)("button",{onClick:()=>M(!1),className:"p-2 rounded-lg hover:bg-bg-subtle text-text-muted hover:text-text-primary transition-colors",title:"Refresh",children:(0,r.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:"refresh"})})]}),(0,r.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[c.map(e=>(0,r.jsxs)("button",{onClick:()=>g(f===e.key?"all":e.key),className:`flex items-center gap-1.5 px-3 py-1 rounded-full text-xs font-medium border transition-all ${f===e.key?"error"===e.key?"bg-red-500/20 text-red-400 border-red-500/40":"ok"===e.key?"bg-emerald-500/20 text-emerald-400 border-emerald-500/40":"timeout"===e.key?"bg-amber-500/20 text-amber-400 border-amber-500/40":"bg-primary text-white border-primary":"bg-bg-subtle border-border text-text-muted hover:border-text-muted"}`,children:[e.icon&&(0,r.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:e.icon}),e.label]},e.key)),_.length>0&&(0,r.jsx)("span",{className:"w-px h-5 bg-border mx-1"}),_.map(e=>{let t=n.RY[e]||{bg:"#374151",text:"#fff",label:e.toUpperCase()},s=v===e;return(0,r.jsx)("button",{onClick:()=>N(s?"":e),className:`px-3 py-1 rounded-full text-xs font-bold uppercase border transition-all ${s?"border-white/40 ring-1 ring-white/20":"border-transparent opacity-70 hover:opacity-100"}`,style:{backgroundColor:s?t.bg:`${t.bg}33`,color:s?t.text:t.bg},children:t.label},e)})]}),(0,r.jsxs)("div",{className:"flex flex-wrap items-center gap-1.5",children:[(0,r.jsx)("span",{className:"text-[10px] text-text-muted uppercase tracking-wider mr-1",children:"Columns"}),d.map(e=>(0,r.jsx)("button",{onClick:()=>L(e.key),className:`px-2 py-0.5 rounded text-[10px] font-medium border transition-all ${A[e.key]?"bg-primary/15 text-primary border-primary/30":"bg-bg-subtle text-text-muted border-border opacity-50 hover:opacity-80"}`,children:e.label},e.key))]}),(0,r.jsx)(l.default,{className:"overflow-hidden bg-black/5 dark:bg-black/20",children:(0,r.jsx)("div",{className:"p-0 overflow-x-auto max-h-[calc(100vh-320px)] overflow-y-auto",children:s&&0===e.length?(0,r.jsx)("div",{className:"p-8 text-center text-text-muted",children:"Loading proxy logs..."}):0===e.length?(0,r.jsxs)("div",{className:"p-8 text-center text-text-muted",children:[(0,r.jsx)("span",{className:"material-symbols-outlined text-[48px] mb-2 block opacity-40",children:"vpn_lock"}),"No proxy logs yet. Configure proxies and make API calls to see them here."]}):0===$.length?(0,r.jsx)("div",{className:"p-8 text-center text-text-muted",children:"No logs match the current filters."}):(0,r.jsxs)("table",{className:"w-full text-left border-collapse text-xs",children:[(0,r.jsx)("thead",{className:"sticky top-0 z-10",style:{backgroundColor:"var(--bg-primary, #0f1117)"},children:(0,r.jsxs)("tr",{className:"border-b border-border",style:{backgroundColor:"var(--bg-primary, #0f1117)"},children:[A.status&&(0,r.jsx)("th",{className:"px-3 py-2.5 font-semibold text-text-muted uppercase tracking-wider text-[10px]",children:"Status"}),A.proxy&&(0,r.jsx)("th",{className:"px-3 py-2.5 font-semibold text-text-muted uppercase tracking-wider text-[10px]",children:"Proxy"}),A.tls&&(0,r.jsx)("th",{className:"px-3 py-2.5 font-semibold text-text-muted uppercase tracking-wider text-[10px]",children:"TLS"}),A.type&&(0,r.jsx)("th",{className:"px-3 py-2.5 font-semibold text-text-muted uppercase tracking-wider text-[10px]",children:"Type"}),A.level&&(0,r.jsx)("th",{className:"px-3 py-2.5 font-semibold text-text-muted uppercase tracking-wider text-[10px]",children:"Level"}),A.provider&&(0,r.jsx)("th",{className:"px-3 py-2.5 font-semibold text-text-muted uppercase tracking-wider text-[10px]",children:"Provider"}),A.target&&(0,r.jsx)("th",{className:"px-3 py-2.5 font-semibold text-text-muted uppercase tracking-wider text-[10px]",children:"Target"}),A.latency&&(0,r.jsx)("th",{className:"px-3 py-2.5 font-semibold text-text-muted uppercase tracking-wider text-[10px] text-right",children:"Latency"}),A.ip&&(0,r.jsx)("th",{className:"px-3 py-2.5 font-semibold text-text-muted uppercase tracking-wider text-[10px]",children:"Public IP"}),A.time&&(0,r.jsx)("th",{className:"px-3 py-2.5 font-semibold text-text-muted uppercase tracking-wider text-[10px] text-right",children:"Time"})]})}),(0,r.jsx)("tbody",{className:"divide-y divide-border/30",children:$.map(e=>{let t=(0,n.Yh)(e.status),s=n.Gp[e.proxy?.type]||{bg:"#6B7280",text:"#fff",label:e.proxy?.type||"-"},a=n.Ie[e.level]||n.Ie.direct,l=n.RY[e.provider]||{bg:"#374151",text:"#fff",label:(e.provider||"-").toUpperCase()},o="error"===e.status||"timeout"===e.status;return(0,r.jsxs)("tr",{onClick:()=>I(T?.id===e.id?null:e),className:`cursor-pointer hover:bg-primary/5 transition-colors ${o?"bg-red-500/5":""}`,children:[A.status&&(0,r.jsx)("td",{className:"px-3 py-2",children:(0,r.jsx)("span",{className:"inline-block px-2 py-0.5 rounded text-[10px] font-bold min-w-[50px] text-center uppercase",style:{backgroundColor:t.bg,color:t.text},children:e.status})}),A.proxy&&(0,r.jsx)("td",{className:"px-3 py-2 font-mono text-[11px] text-primary",children:e.proxy?`${e.proxy.host}:${e.proxy.port}`:"—"}),A.tls&&(0,r.jsx)("td",{className:"px-3 py-2",children:e.tlsFingerprint?(0,r.jsxs)("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 rounded text-[9px] font-bold uppercase",style:{backgroundColor:"rgba(6, 182, 212, 0.15)",color:"#22d3ee"},title:"Chrome 124 TLS Fingerprint",children:[(0,r.jsx)("span",{style:{fontSize:"10px"},children:"\uD83D\uDD12"})," TLS"]}):(0,r.jsx)("span",{className:"text-text-muted text-[10px]",children:"—"})}),A.type&&(0,r.jsx)("td",{className:"px-3 py-2",children:(0,r.jsx)("span",{className:"inline-block px-2 py-0.5 rounded text-[9px] font-bold uppercase",style:{backgroundColor:s.bg,color:s.text},children:s.label})}),A.level&&(0,r.jsx)("td",{className:"px-3 py-2",children:(0,r.jsx)("span",{className:"inline-block px-2 py-0.5 rounded text-[9px] font-bold uppercase",style:{backgroundColor:a.bg,color:a.text},children:a.label})}),A.provider&&(0,r.jsx)("td",{className:"px-3 py-2",children:e.provider?(0,r.jsx)("span",{className:"inline-block px-2 py-0.5 rounded text-[9px] font-bold uppercase",style:{backgroundColor:l.bg,color:l.text},children:l.label}):(0,r.jsx)("span",{className:"text-text-muted text-[10px]",children:"—"})}),A.target&&(0,r.jsx)("td",{className:"px-3 py-2 text-text-muted truncate max-w-[200px] font-mono text-[10px]",title:e.targetUrl,children:(0,i.Y1)(e.targetUrl)}),A.latency&&(0,r.jsx)("td",{className:"px-3 py-2 text-right text-text-muted font-mono",children:(0,i.a3)(e.latencyMs)}),A.ip&&(0,r.jsx)("td",{className:"px-3 py-2 font-mono text-[11px] text-emerald-400",children:e.publicIp||"—"}),A.time&&(0,r.jsx)("td",{className:"px-3 py-2 text-right text-text-muted",children:(0,i.fU)(e.timestamp)})]},e.id)})})]})})}),T&&(0,r.jsx)(o,{log:T,onClose:()=>I(null)})]})}},8898:(e,t,s)=>{function r(e){try{return new Date(e).toLocaleTimeString("en-US",{hour12:!1,hour:"2-digit",minute:"2-digit",second:"2-digit"})}catch{return"-"}}function a(e){return e?e<1e3?`${e}ms`:`${(e/1e3).toFixed(1)}s`:"-"}function l(e){if(!e||"-"===e)return"-";let t=e.indexOf("@");return t>3?e.slice(0,3)+"***"+e.slice(t):e.length>8?e.slice(0,5)+"***":e}function n(e,t){if(!e&&!t)return"—";let s=e||"key";return t?`${s} (${function(e,t=2,s=2){return e?e.length<=t+s?`${e.slice(0,1)}***`:`${e.slice(0,t)}***${e.slice(-s)}`:""}(t,4,4)})`:s}function i(e){return e>=1e9?`${(e/1e9).toFixed(1)}B`:e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}K`:new Intl.NumberFormat().format(e||0)}function o(e){return new Intl.NumberFormat().format(e||0)}function c(e){return`$${(e||0).toFixed(2)}`}function d(e,t=50){if(!e)return"-";try{let s=new URL(e),r=s.hostname+s.pathname;return r.length>t?r.slice(0,t)+"…":r}catch{return e.length>t?e.slice(0,t)+"…":e}}s.d(t,{F0:()=>c,Ib:()=>l,VK:()=>i,VO:()=>n,Y1:()=>d,a3:()=>a,fU:()=>r,xW:()=>o})},17705:(e,t,s)=>{s.d(t,{default:()=>l});var r=s(95155),a=s(67040);function l({src:e,alt:t="Avatar",name:s,size:l="md",className:n}){let i={xs:"size-6 text-xs",sm:"size-8 text-sm",md:"size-10 text-base",lg:"size-12 text-lg",xl:"size-16 text-xl"};return e?(0,r.jsx)("div",{className:(0,a.cn)("rounded-full bg-cover bg-center bg-no-repeat","ring-2 ring-white dark:ring-surface-dark shadow-sm",i[l],n),style:{backgroundImage:`url(${e})`},role:"img","aria-label":t}):(0,r.jsx)("div",{className:(0,a.cn)("rounded-full flex items-center justify-center font-semibold text-white","ring-2 ring-white dark:ring-surface-dark shadow-sm",i[l],(e=>{if(!e)return"bg-primary";let t=["bg-red-500","bg-orange-500","bg-amber-500","bg-yellow-500","bg-lime-500","bg-green-500","bg-emerald-500","bg-teal-500","bg-cyan-500","bg-sky-500","bg-blue-500","bg-indigo-500","bg-violet-500","bg-purple-500","bg-fuchsia-500","bg-pink-500","bg-rose-500"],s=e.charCodeAt(0)%t.length;return t[s]})(s),n),role:"img","aria-label":t,children:(e=>{if(!e)return"?";let t=e.split(" ");return t.length>=2?`${t[0][0]}${t[1][0]}`.toUpperCase():e.substring(0,2).toUpperCase()})(s)})}},18150:(e,t,s)=>{s.d(t,{default:()=>x});var r=s(95155),a=s(12115),l=s(14051),n=s.n(l),i=s(71361),o=s(35806),c=s(34422),d=s(30949);function x({isOpen:e,provider:t,onSuccess:s,onClose:l}){let[n,x]=(0,a.useState)("loading"),[m,u]=(0,a.useState)(""),[p,h]=(0,a.useState)(null),[b,f]=(0,a.useState)(""),[g,y]=(0,a.useState)(null),{copied:j,copy:v}=(0,d.C)();(0,a.useEffect)(()=>{e&&t&&(async()=>{try{y(null),x("loading");let e=await fetch(`/api/oauth/kiro/social-authorize?provider=${t}`),s=await e.json();if(!e.ok)throw Error(s.error);h(s),u(s.authUrl),x("input"),window.open(s.authUrl,"kiro_social_auth")}catch(e){y(e.message),x("error")}})()},[e,t]);let N=async()=>{try{let e;y(null);try{e=new URL(b)}catch(e){throw Error("Invalid callback URL format")}let r=e.searchParams.get("code");e.searchParams.get("state");let a=e.searchParams.get("error");if(a)throw Error(e.searchParams.get("error_description")||a);if(!r)throw Error("No authorization code found in URL");let l=await fetch("/api/oauth/kiro/social-exchange",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({code:r,codeVerifier:p.codeVerifier,provider:t})}),n=await l.json();if(!l.ok)throw Error(n.error);x("success"),s?.()}catch(e){y(e.message),x("error")}},k="google"===t?"Google":"GitHub";return(0,r.jsx)(i.default,{isOpen:e,title:`Connect Kiro via ${k}`,onClose:l,size:"lg",children:(0,r.jsxs)("div",{className:"flex flex-col gap-4",children:["loading"===n&&(0,r.jsxs)("div",{className:"text-center py-6",children:[(0,r.jsx)("div",{className:"size-16 mx-auto mb-4 rounded-full bg-primary/10 flex items-center justify-center",children:(0,r.jsx)("span",{className:"material-symbols-outlined text-3xl text-primary animate-spin",children:"progress_activity"})}),(0,r.jsx)("h3",{className:"text-lg font-semibold mb-2",children:"Initializing..."}),(0,r.jsxs)("p",{className:"text-sm text-text-muted",children:["Setting up ",k," authentication"]})]}),"input"===n&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("p",{className:"text-sm font-medium mb-2",children:"Step 1: Open this URL in your browser"}),(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsx)(c.default,{value:m,readOnly:!0,className:"flex-1 font-mono text-xs"}),(0,r.jsx)(o.default,{variant:"secondary",icon:"auth_url"===j?"check":"content_copy",onClick:()=>v(m,"auth_url"),children:"Copy"})]})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("p",{className:"text-sm font-medium mb-2",children:"Step 2: Paste the callback URL here"}),(0,r.jsx)("p",{className:"text-xs text-text-muted mb-2",children:"After authorization, copy the full URL from your browser address bar."}),(0,r.jsx)(c.default,{value:b,onChange:e=>f(e.target.value),placeholder:"kiro://kiro.kiroAgent/authenticate-success?code=...",className:"font-mono text-xs"})]})]}),(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsx)(o.default,{onClick:N,fullWidth:!0,disabled:!b,children:"Connect"}),(0,r.jsx)(o.default,{onClick:l,variant:"ghost",fullWidth:!0,children:"Cancel"})]})]}),"success"===n&&(0,r.jsxs)("div",{className:"text-center py-6",children:[(0,r.jsx)("div",{className:"size-16 mx-auto mb-4 rounded-full bg-green-100 dark:bg-green-900/30 flex items-center justify-center",children:(0,r.jsx)("span",{className:"material-symbols-outlined text-3xl text-green-600",children:"check_circle"})}),(0,r.jsx)("h3",{className:"text-lg font-semibold mb-2",children:"Connected Successfully!"}),(0,r.jsxs)("p",{className:"text-sm text-text-muted mb-4",children:["Your Kiro account via ",k," has been connected."]}),(0,r.jsx)(o.default,{onClick:l,fullWidth:!0,children:"Done"})]}),"error"===n&&(0,r.jsxs)("div",{className:"text-center py-6",children:[(0,r.jsx)("div",{className:"size-16 mx-auto mb-4 rounded-full bg-red-100 dark:bg-red-900/30 flex items-center justify-center",children:(0,r.jsx)("span",{className:"material-symbols-outlined text-3xl text-red-600",children:"error"})}),(0,r.jsx)("h3",{className:"text-lg font-semibold mb-2",children:"Connection Failed"}),(0,r.jsx)("p",{className:"text-sm text-red-600 mb-4",children:g}),(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsx)(o.default,{onClick:()=>x("input"),variant:"secondary",fullWidth:!0,children:"Try Again"}),(0,r.jsx)(o.default,{onClick:l,variant:"ghost",fullWidth:!0,children:"Cancel"})]})]})]})})}x.propTypes={isOpen:n().bool.isRequired,provider:n().oneOf(["google","github"]).isRequired,onSuccess:n().func,onClose:n().func.isRequired}},19790:(e,t,s)=>{s.d(t,{default:()=>l});var r=s(95155),a=s(67040);function l({checked:e=!1,onChange:t,label:s,description:l,disabled:n=!1,size:i="md",className:o}){let c={sm:{track:"w-8 h-4",thumb:"size-3",translate:"translate-x-4"},md:{track:"w-11 h-6",thumb:"size-5",translate:"translate-x-5"},lg:{track:"w-14 h-7",thumb:"size-6",translate:"translate-x-7"}};return(0,r.jsxs)("div",{className:(0,a.cn)("flex items-center gap-3",n&&"opacity-50 cursor-not-allowed",o),children:[(0,r.jsx)("button",{type:"button",role:"switch","aria-checked":e,"aria-label":s?void 0:l||"Toggle",disabled:n,onClick:()=>{!n&&t&&t(!e)},className:(0,a.cn)("relative inline-flex shrink-0 cursor-pointer rounded-full","transition-colors duration-200 ease-in-out","focus:outline-none focus:ring-1 focus:ring-primary/30",e?"bg-primary":"bg-black/10 dark:bg-white/20",c[i].track,n&&"cursor-not-allowed"),children:(0,r.jsx)("span",{"aria-hidden":"true",className:(0,a.cn)("pointer-events-none inline-block rounded-full bg-white shadow-sm","transform transition duration-200 ease-in-out",e?c[i].translate:"translate-x-0.5",c[i].thumb,"mt-0.5")})}),(s||l)&&(0,r.jsxs)("div",{className:"flex flex-col",children:[s&&(0,r.jsx)("span",{className:"text-sm font-medium text-text-main",children:s}),l&&(0,r.jsx)("span",{className:"text-xs text-text-muted",children:l})]})]})}},21720:(e,t,s)=>{s.d(t,{default:()=>x});var r=s(95155),a=s(12115),l=s(34243),n=s(89938),i=s(76332),o=s(61580);function c(){let[e,t]=(0,a.useState)(!1),[s,l]=(0,a.useState)(""),n=(0,a.useCallback)(async()=>{try{(await fetch("/api/monitoring/health",{signal:AbortSignal.timeout(3e3)})).ok?e&&(t(!1),l("")):(t(!0),l("Server is experiencing issues. Some features may be unavailable."))}catch{t(!0),l("Server is unreachable. Reconnecting...")}},[e]);return((0,a.useEffect)(()=>{let e=setInterval(n,1e4);return()=>clearInterval(e)},[n]),e)?(0,r.jsxs)("div",{className:"bg-amber-500/10 border-b border-amber-500/20 px-4 py-2.5 flex items-center justify-between gap-3 animate-in slide-in-from-top",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2.5",children:[(0,r.jsx)("span",{className:"material-symbols-outlined text-amber-500 text-[18px] animate-pulse",children:"warning"}),(0,r.jsx)("span",{className:"text-sm text-amber-200",children:s})]}),(0,r.jsx)("button",{onClick:()=>t(!1),className:"p-1 rounded hover:bg-white/5 text-text-muted hover:text-text-main transition-colors","aria-label":"Dismiss",children:(0,r.jsx)("span",{className:"material-symbols-outlined text-[16px]",children:"close"})})]}):null}let d="sidebar-collapsed";function x({children:e}){let[t,s]=(0,a.useState)(!1),[x,m]=(0,a.useState)(()=>{try{return"true"===localStorage.getItem(d)}catch{return!1}});return(0,r.jsxs)("div",{className:"flex h-screen w-full overflow-hidden bg-bg",children:[t&&(0,r.jsx)("div",{className:"fixed inset-0 z-40 bg-black/20 lg:hidden",onClick:()=>s(!1)}),(0,r.jsx)("div",{className:"hidden lg:flex",children:(0,r.jsx)(l.default,{collapsed:x,onToggleCollapse:()=>{let e=!x;m(e),localStorage.setItem(d,String(e))}})}),(0,r.jsx)("div",{className:`fixed inset-y-0 left-0 z-50 transform lg:hidden transition-transform duration-300 ease-in-out ${t?"translate-x-0":"-translate-x-full"}`,children:(0,r.jsx)(l.default,{onClose:()=>s(!1)})}),(0,r.jsxs)("main",{id:"main-content",className:"flex flex-col flex-1 h-full min-w-0 relative transition-colors duration-300",children:[(0,r.jsx)(n.default,{onMenuClick:()=>s(!0)}),(0,r.jsx)(c,{}),(0,r.jsx)("div",{className:"flex-1 overflow-y-auto custom-scrollbar p-6 lg:p-10",children:(0,r.jsxs)("div",{className:"max-w-7xl mx-auto",children:[(0,r.jsx)(i.default,{}),e]})})]}),(0,r.jsx)(o.default,{})]})}},25112:(e,t,s)=>{s.d(t,{default:()=>h});var r=s(95155),a=s(50910),l=s(12115),n=s(14051),i=s.n(n),o=s(73321),c=s(81060),d=s(80927),x=s(92542),m=s(8898);function u({field:e,currentSort:t,currentOrder:s}){return t!==e?(0,r.jsx)("span",{className:"ml-1 opacity-20",children:"↕"}):(0,r.jsx)("span",{className:"ml-1",children:"asc"===s?"↑":"↓"})}function p({data:e,colorClass:t="bg-primary"}){let s=Math.max(...e,1);return(0,r.jsx)("div",{className:"flex items-end gap-1 h-8 w-24",children:e.slice(-9).map((e,a)=>(0,r.jsx)("div",{className:`flex-1 rounded-t-sm transition-all duration-500 ${t}`,style:{height:`${Math.max(e/s*100,5)}%`},title:String(e)},`bar-${a}-${e}`))})}function h(){let e=(0,a.c)("stats"),t=(0,o.useRouter)(),s=(0,o.useSearchParams)(),n=s.get("sortBy")||"rawModel",i=s.get("sortOrder")||"asc",[h,b]=(0,l.useState)(null),[f,g]=(0,l.useState)(!0),[y,j]=(0,l.useState)(!0),[v,N]=(0,l.useState)("tokens"),[k,w]=(0,l.useState)(5e3),C=(0,l.useRef)(0),S=e=>{let r=new URLSearchParams(s.toString());n===e?r.set("sortOrder","asc"===i?"desc":"asc"):(r.set("sortBy",e),r.set("sortOrder","asc")),t.replace(`?${r.toString()}`,{scroll:!1})},T=(0,l.useCallback)((e,t={})=>Object.entries(e||{}).map(([e,s])=>{let r=(s.promptTokens||0)+(s.completionTokens||0),a=s.cost||0,l=r>0?(s.promptTokens||0)*(a/r):0,n=r>0?(s.completionTokens||0)*(a/r):0;return{...s,key:e,totalTokens:r,totalCost:a,inputCost:l,outputCost:n,pending:t[e]||0}}).sort((e,t)=>{let s=e[n],r=t[n];return("string"==typeof s&&(s=s.toLowerCase()),"string"==typeof r&&(r=r.toLowerCase()),s<r)?"asc"===i?-1:1:s>r?"asc"===i?1:-1:0}),[n,i]),I=(0,l.useMemo)(()=>T(h?.byModel,h?.pending?.byModel),[h?.byModel,h?.pending?.byModel,T]),O=(0,l.useMemo)(()=>{let e={};return h?.pending?.byAccount&&Object.entries(h.byAccount||{}).forEach(([t,s])=>{let r=h.pending.byAccount[s.connectionId];if(r){let a=s.provider?`${s.rawModel} (${s.provider})`:s.rawModel;e[t]=r[a]||0}}),T(h?.byAccount,e)},[h?.byAccount,h?.pending?.byAccount,T]),R=(0,l.useCallback)(async(e=!0)=>{e&&g(!0);try{let e=await fetch("/api/usage/history");if(e.ok){let t=await e.json();b(t);let s=t.totalRequests||0;s>C.current?w(5e3):w(e=>Math.min(2*e,6e4)),C.current=s}}catch(e){console.error("Failed to fetch usage stats:",e)}finally{e&&g(!1)}},[]);if((0,l.useEffect)(()=>{R()},[R]),(0,l.useEffect)(()=>{let e,t=!0,s=()=>{(t=!document.hidden)&&y&&R(!1)};return document.addEventListener("visibilitychange",s),y&&(e&&clearInterval(e),e=setInterval(()=>{t&&R(!1)},k)),()=>{e&&clearInterval(e),document.removeEventListener("visibilitychange",s)}},[y,k,R]),f)return(0,r.jsx)(x.CardSkeleton,{});if(!h)return(0,r.jsx)("div",{className:"text-text-muted",children:e("failedToLoad")});let A=e=>(0,m.xW)(e),E=e=>{if(!e)return"Never";let t=new Date(e),s=Math.floor((new Date().getTime()-t.getTime())/6e4);return s<1?"Just now":s<60?`${s}m ago`:s<1440?`${Math.floor(s/60)}h ago`:t.toLocaleDateString()};return(0,r.jsxs)("div",{className:"flex flex-col gap-6",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between",children:[(0,r.jsx)("h2",{className:"text-xl font-semibold",children:e("usageOverview")}),(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsxs)("div",{className:"flex items-center gap-1 bg-bg-subtle rounded-lg p-1 border border-border",children:[(0,r.jsx)("button",{onClick:()=>N("tokens"),className:`px-3 py-1 rounded-md text-sm font-medium transition-colors ${"tokens"===v?"bg-primary text-white shadow-sm":"text-text-muted hover:text-text hover:bg-bg-hover"}`,children:"Tokens"}),(0,r.jsx)("button",{onClick:()=>N("costs"),className:`px-3 py-1 rounded-md text-sm font-medium transition-colors ${"costs"===v?"bg-primary text-white shadow-sm":"text-text-muted hover:text-text hover:bg-bg-hover"}`,children:"Costs"})]}),(0,r.jsxs)("div",{className:"text-sm font-medium text-text-muted flex items-center gap-2",children:[(0,r.jsxs)("span",{children:["Auto Refresh (",k/1e3,"s)"]}),(0,r.jsx)("button",{type:"button",onClick:()=>j(!y),role:"switch","aria-checked":y,"aria-label":"Toggle auto refresh",className:`relative inline-flex h-5 w-9 items-center rounded-full transition-colors focus:outline-none focus:ring-2 focus:ring-primary/50 ${y?"bg-primary":"bg-bg-subtle border border-border"}`,children:(0,r.jsx)("span",{className:`inline-block h-3 w-3 transform rounded-full bg-white transition-transform ${y?"translate-x-5":"translate-x-1"}`})})]})]})]}),(h.activeRequests||[]).length>0&&(0,r.jsx)(c.default,{className:"p-3 border-primary/20 bg-primary/5",children:(0,r.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2 text-primary font-semibold text-sm uppercase tracking-wider",children:[(0,r.jsxs)("span",{className:"relative flex h-2 w-2",children:[(0,r.jsx)("span",{className:"animate-ping absolute inline-flex h-full w-full rounded-full bg-primary opacity-75"}),(0,r.jsx)("span",{className:"relative inline-flex rounded-full h-2 w-2 bg-primary"})]}),"Active Requests"]}),(0,r.jsx)("div",{className:"flex flex-wrap gap-3",children:h.activeRequests.map(e=>(0,r.jsxs)("div",{className:"px-3 py-1.5 rounded-md bg-bg-subtle border border-primary/20 text-xs font-mono shadow-sm",children:[(0,r.jsx)("span",{className:"text-primary font-bold",children:e.model}),(0,r.jsx)("span",{className:"mx-1 text-text-muted",children:"|"}),(0,r.jsx)("span",{className:"text-text",children:e.provider}),(0,r.jsx)("span",{className:"mx-1 text-text-muted",children:"|"}),(0,r.jsx)("span",{className:"text-text font-medium",children:e.account}),e.count>1&&(0,r.jsxs)("span",{className:"ml-2 px-1.5 py-0.5 rounded bg-primary text-white font-bold",children:["x",e.count]})]},`${e.model}-${e.provider}-${e.account}`))})]})}),(0,r.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[(0,r.jsx)(c.default,{className:"px-4 py-3 flex flex-col gap-1",children:(0,r.jsxs)("div",{className:"flex justify-between items-start",children:[(0,r.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,r.jsx)("span",{className:"text-text-muted text-sm uppercase font-semibold",children:"Total Requests"}),(0,r.jsx)("span",{className:"text-2xl font-bold",children:A(h.totalRequests)})]}),(0,r.jsx)(p,{data:(h.last10Minutes||[]).map(e=>e.requests),colorClass:"bg-text-muted/30"})]})}),(0,r.jsx)(c.default,{className:"px-4 py-3 flex flex-col gap-1",children:(0,r.jsxs)("div",{className:"flex justify-between items-start",children:[(0,r.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,r.jsx)("span",{className:"text-text-muted text-sm uppercase font-semibold",children:"Total Input Tokens"}),(0,r.jsx)("span",{className:"text-2xl font-bold text-primary",children:A(h.totalPromptTokens)})]}),(0,r.jsx)(p,{data:(h.last10Minutes||[]).map(e=>e.promptTokens),colorClass:"bg-primary/50"})]})}),(0,r.jsx)(c.default,{className:"px-4 py-2 flex flex-col gap-1",children:(0,r.jsxs)("div",{className:"flex justify-between items-start gap-4",children:[(0,r.jsxs)("div",{className:"flex flex-col gap-1 flex-1",children:[(0,r.jsx)("span",{className:"text-text-muted text-sm uppercase font-semibold",children:e("outputTokens")}),(0,r.jsx)("span",{className:"text-2xl font-bold text-success",children:A(h.totalCompletionTokens)})]}),(0,r.jsx)("div",{className:"w-px bg-border self-stretch mx-2"}),(0,r.jsxs)("div",{className:"flex flex-col gap-1 flex-1",children:[(0,r.jsx)("span",{className:"text-text-muted text-sm uppercase font-semibold",children:e("totalCost")}),(0,r.jsx)("span",{className:"text-2xl font-bold text-warning",children:(0,m.F0)(h.totalCost)})]})]})})]}),(0,r.jsxs)(c.default,{className:"overflow-hidden",children:[(0,r.jsx)("div",{className:"p-4 border-b border-border bg-bg-subtle/50",children:(0,r.jsx)("h3",{className:"font-semibold",children:"Usage by Model"})}),(0,r.jsx)("div",{className:"overflow-x-auto",children:(0,r.jsxs)("table",{className:"w-full text-sm text-left",children:[(0,r.jsx)("thead",{className:"bg-bg-subtle/30 text-text-muted uppercase text-xs",children:(0,r.jsxs)("tr",{children:[(0,r.jsxs)("th",{className:"px-6 py-3 cursor-pointer hover:bg-bg-subtle/50",onClick:()=>S("rawModel"),children:["Model ",(0,r.jsx)(u,{field:"rawModel",currentSort:n,currentOrder:i})]}),(0,r.jsxs)("th",{className:"px-6 py-3 cursor-pointer hover:bg-bg-subtle/50",onClick:()=>S("provider"),children:["Provider"," ",(0,r.jsx)(u,{field:"provider",currentSort:n,currentOrder:i})]}),(0,r.jsxs)("th",{className:"px-6 py-3 text-right cursor-pointer hover:bg-bg-subtle/50",onClick:()=>S("requests"),children:["Requests"," ",(0,r.jsx)(u,{field:"requests",currentSort:n,currentOrder:i})]}),(0,r.jsxs)("th",{className:"px-6 py-3 text-right cursor-pointer hover:bg-bg-subtle/50",onClick:()=>S("lastUsed"),children:["Last Used"," ",(0,r.jsx)(u,{field:"lastUsed",currentSort:n,currentOrder:i})]}),"tokens"===v?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("th",{className:"px-6 py-3 text-right cursor-pointer hover:bg-bg-subtle/50",onClick:()=>S("promptTokens"),children:["Input Tokens"," ",(0,r.jsx)(u,{field:"promptTokens",currentSort:n,currentOrder:i})]}),(0,r.jsxs)("th",{className:"px-6 py-3 text-right cursor-pointer hover:bg-bg-subtle/50",onClick:()=>S("completionTokens"),children:["Output Tokens"," ",(0,r.jsx)(u,{field:"completionTokens",currentSort:n,currentOrder:i})]}),(0,r.jsxs)("th",{className:"px-6 py-3 text-right cursor-pointer hover:bg-bg-subtle/50",onClick:()=>S("totalTokens"),children:["Total Tokens"," ",(0,r.jsx)(u,{field:"totalTokens",currentSort:n,currentOrder:i})]})]}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("th",{className:"px-6 py-3 text-right cursor-pointer hover:bg-bg-subtle/50",onClick:()=>S("promptTokens"),children:["Input Cost"," ",(0,r.jsx)(u,{field:"promptTokens",currentSort:n,currentOrder:i})]}),(0,r.jsxs)("th",{className:"px-6 py-3 text-right cursor-pointer hover:bg-bg-subtle/50",onClick:()=>S("completionTokens"),children:["Output Cost"," ",(0,r.jsx)(u,{field:"completionTokens",currentSort:n,currentOrder:i})]}),(0,r.jsxs)("th",{className:"px-6 py-3 text-right cursor-pointer hover:bg-bg-subtle/50",onClick:()=>S("cost"),children:["Total Cost"," ",(0,r.jsx)(u,{field:"cost",currentSort:n,currentOrder:i})]})]})]})}),(0,r.jsxs)("tbody",{className:"divide-y divide-border",children:[I.map(e=>(0,r.jsxs)("tr",{className:"hover:bg-bg-subtle/20",children:[(0,r.jsx)("td",{className:`px-6 py-3 font-medium transition-colors ${e.pending>0?"text-primary":""}`,children:e.rawModel}),(0,r.jsx)("td",{className:"px-6 py-3",children:(0,r.jsx)(d.default,{variant:e.pending>0?"primary":"default",size:"sm",children:e.provider})}),(0,r.jsx)("td",{className:"px-6 py-3 text-right",children:A(e.requests)}),(0,r.jsx)("td",{className:"px-6 py-3 text-right text-text-muted whitespace-nowrap",children:E(e.lastUsed)}),"tokens"===v?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("td",{className:"px-6 py-3 text-right text-text-muted",children:A(e.promptTokens)}),(0,r.jsx)("td",{className:"px-6 py-3 text-right text-text-muted",children:A(e.completionTokens)}),(0,r.jsx)("td",{className:"px-6 py-3 text-right font-medium",children:A(e.totalTokens)})]}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("td",{className:"px-6 py-3 text-right text-text-muted",children:(0,m.F0)(e.inputCost)}),(0,r.jsx)("td",{className:"px-6 py-3 text-right text-text-muted",children:(0,m.F0)(e.outputCost)}),(0,r.jsx)("td",{className:"px-6 py-3 text-right font-medium text-warning",children:(0,m.F0)(e.totalCost)})]})]},e.key)),0===I.length&&(0,r.jsx)("tr",{children:(0,r.jsx)("td",{colSpan:8,className:"px-6 py-8 text-center text-text-muted",children:"No usage recorded yet. Make some requests to see data here."})})]})]})})]}),(0,r.jsxs)(c.default,{className:"overflow-hidden",children:[(0,r.jsx)("div",{className:"p-4 border-b border-border bg-bg-subtle/50",children:(0,r.jsx)("h3",{className:"font-semibold",children:"Usage by Account"})}),(0,r.jsx)("div",{className:"overflow-x-auto",children:(0,r.jsxs)("table",{className:"w-full text-sm text-left",children:[(0,r.jsx)("thead",{className:"bg-bg-subtle/30 text-text-muted uppercase text-xs",children:(0,r.jsxs)("tr",{children:[(0,r.jsxs)("th",{className:"px-6 py-3 cursor-pointer hover:bg-bg-subtle/50",onClick:()=>S("rawModel"),children:["Model ",(0,r.jsx)(u,{field:"rawModel",currentSort:n,currentOrder:i})]}),(0,r.jsxs)("th",{className:"px-6 py-3 cursor-pointer hover:bg-bg-subtle/50",onClick:()=>S("provider"),children:["Provider"," ",(0,r.jsx)(u,{field:"provider",currentSort:n,currentOrder:i})]}),(0,r.jsxs)("th",{className:"px-6 py-3 cursor-pointer hover:bg-bg-subtle/50",onClick:()=>S("accountName"),children:["Account"," ",(0,r.jsx)(u,{field:"accountName",currentSort:n,currentOrder:i})]}),(0,r.jsxs)("th",{className:"px-6 py-3 text-right cursor-pointer hover:bg-bg-subtle/50",onClick:()=>S("requests"),children:["Requests"," ",(0,r.jsx)(u,{field:"requests",currentSort:n,currentOrder:i})]}),(0,r.jsxs)("th",{className:"px-6 py-3 text-right cursor-pointer hover:bg-bg-subtle/50",onClick:()=>S("lastUsed"),children:["Last Used"," ",(0,r.jsx)(u,{field:"lastUsed",currentSort:n,currentOrder:i})]}),"tokens"===v?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("th",{className:"px-6 py-3 text-right cursor-pointer hover:bg-bg-subtle/50",onClick:()=>S("promptTokens"),children:["Input Tokens"," ",(0,r.jsx)(u,{field:"promptTokens",currentSort:n,currentOrder:i})]}),(0,r.jsxs)("th",{className:"px-6 py-3 text-right cursor-pointer hover:bg-bg-subtle/50",onClick:()=>S("completionTokens"),children:["Output Tokens"," ",(0,r.jsx)(u,{field:"completionTokens",currentSort:n,currentOrder:i})]}),(0,r.jsxs)("th",{className:"px-6 py-3 text-right cursor-pointer hover:bg-bg-subtle/50",onClick:()=>S("totalTokens"),children:["Total Tokens"," ",(0,r.jsx)(u,{field:"totalTokens",currentSort:n,currentOrder:i})]})]}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("th",{className:"px-6 py-3 text-right cursor-pointer hover:bg-bg-subtle/50",onClick:()=>S("promptTokens"),children:["Input Cost"," ",(0,r.jsx)(u,{field:"promptTokens",currentSort:n,currentOrder:i})]}),(0,r.jsxs)("th",{className:"px-6 py-3 text-right cursor-pointer hover:bg-bg-subtle/50",onClick:()=>S("completionTokens"),children:["Output Cost"," ",(0,r.jsx)(u,{field:"completionTokens",currentSort:n,currentOrder:i})]}),(0,r.jsxs)("th",{className:"px-6 py-3 text-right cursor-pointer hover:bg-bg-subtle/50",onClick:()=>S("cost"),children:["Total Cost"," ",(0,r.jsx)(u,{field:"cost",currentSort:n,currentOrder:i})]})]})]})}),(0,r.jsxs)("tbody",{className:"divide-y divide-border",children:[O.map(e=>(0,r.jsxs)("tr",{className:"hover:bg-bg-subtle/20",children:[(0,r.jsx)("td",{className:`px-6 py-3 font-medium transition-colors ${e.pending>0?"text-primary":""}`,children:e.rawModel}),(0,r.jsx)("td",{className:"px-6 py-3",children:(0,r.jsx)(d.default,{variant:e.pending>0?"primary":"default",size:"sm",children:e.provider})}),(0,r.jsx)("td",{className:"px-6 py-3",children:(0,r.jsx)("span",{className:`font-medium transition-colors ${e.pending>0?"text-primary":""}`,children:e.accountName||`Account ${e.connectionId?.slice(0,8)}...`})}),(0,r.jsx)("td",{className:"px-6 py-3 text-right",children:A(e.requests)}),(0,r.jsx)("td",{className:"px-6 py-3 text-right text-text-muted whitespace-nowrap",children:E(e.lastUsed)}),"tokens"===v?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("td",{className:"px-6 py-3 text-right text-text-muted",children:A(e.promptTokens)}),(0,r.jsx)("td",{className:"px-6 py-3 text-right text-text-muted",children:A(e.completionTokens)}),(0,r.jsx)("td",{className:"px-6 py-3 text-right font-medium",children:A(e.totalTokens)})]}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("td",{className:"px-6 py-3 text-right text-text-muted",children:(0,m.F0)(e.inputCost)}),(0,r.jsx)("td",{className:"px-6 py-3 text-right text-text-muted",children:(0,m.F0)(e.outputCost)}),(0,r.jsx)("td",{className:"px-6 py-3 text-right font-medium text-warning",children:(0,m.F0)(e.totalCost)})]})]},e.key)),0===O.length&&(0,r.jsx)("tr",{children:(0,r.jsx)("td",{colSpan:9,className:"px-6 py-8 text-center text-text-muted",children:"No account-specific usage recorded yet. Make requests using OAuth accounts to see data here."})})]})]})})]})]})}u.propTypes={field:i().string.isRequired,currentSort:i().string.isRequired,currentOrder:i().string.isRequired},p.propTypes={data:i().arrayOf(i().number).isRequired,colorClass:i().string}},30949:(e,t,s)=>{s.d(t,{C:()=>l});var r=s(12115);function a(e){let t=document.createElement("textarea");t.value=e,t.style.position="fixed",t.style.left="-9999px",t.style.top="-9999px",t.style.opacity="0",document.body.appendChild(t),t.focus(),t.select();try{document.execCommand("copy")}catch{}document.body.removeChild(t)}function l(e=2e3){let[t,s]=(0,r.useState)(null),n=(0,r.useRef)(null);return{copied:t,copy:(0,r.useCallback)(async(t,r="default")=>{try{navigator.clipboard&&window.isSecureContext?await navigator.clipboard.writeText(t):a(t)}catch{a(t)}s(r),n.current&&clearTimeout(n.current),n.current=setTimeout(()=>{s(null)},e)},[e])}}},33637:(e,t,s)=>{s.d(t,{A:()=>n});var r=s(95155),a=s(14051),l=s.n(a);function n({size:e=20,className:t=""}){return(0,r.jsxs)("svg",{width:e,height:e,viewBox:"0 0 32 32",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:t,children:[(0,r.jsx)("circle",{cx:"16",cy:"16",r:"3",fill:"currentColor"}),(0,r.jsx)("circle",{cx:"8",cy:"8",r:"2",fill:"currentColor"}),(0,r.jsx)("circle",{cx:"24",cy:"8",r:"2",fill:"currentColor"}),(0,r.jsx)("circle",{cx:"8",cy:"24",r:"2",fill:"currentColor"}),(0,r.jsx)("circle",{cx:"24",cy:"24",r:"2",fill:"currentColor"}),(0,r.jsx)("circle",{cx:"16",cy:"5",r:"1.5",fill:"currentColor"}),(0,r.jsx)("circle",{cx:"16",cy:"27",r:"1.5",fill:"currentColor"}),(0,r.jsx)("line",{x1:"16",y1:"13",x2:"8",y2:"8",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round"}),(0,r.jsx)("line",{x1:"16",y1:"13",x2:"24",y2:"8",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round"}),(0,r.jsx)("line",{x1:"16",y1:"19",x2:"8",y2:"24",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round"}),(0,r.jsx)("line",{x1:"16",y1:"19",x2:"24",y2:"24",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round"}),(0,r.jsx)("line",{x1:"16",y1:"13",x2:"16",y2:"5",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round"}),(0,r.jsx)("line",{x1:"16",y1:"19",x2:"16",y2:"27",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round"})]})}n.propTypes={size:l().number,className:l().string}},33709:(e,t,s)=>{s.d(t,{default:()=>l});var r=s(95155),a=s(67040);function l({options:e=[],value:t,onChange:s,size:l="md",className:n,"aria-label":i}){let o={sm:"h-7 text-xs",md:"h-9 text-sm",lg:"h-11 text-base"};return(0,r.jsx)("div",{role:"tablist","aria-label":i,className:(0,a.cn)("inline-flex items-center p-1 rounded-lg","bg-black/5 dark:bg-white/5",n),children:e.map(e=>(0,r.jsxs)("button",{role:"tab","aria-selected":t===e.value,tabIndex:t===e.value?0:-1,onClick:()=>s(e.value),className:(0,a.cn)("px-4 rounded-md font-medium transition-all",o[l],t===e.value?"bg-white dark:bg-white/10 text-text-main shadow-sm":"text-text-muted hover:text-text-main"),children:[e.icon&&(0,r.jsx)("span",{className:"material-symbols-outlined text-[16px] mr-1.5","aria-hidden":"true",children:e.icon}),e.label]},e.value))})}},34243:(e,t,s)=>{s.d(t,{default:()=>N});var r=s(95155),a=s(12115),l=s(14051),n=s.n(l),i=s(98500),o=s.n(i),c=s(73321),d=s(67040),x=s(52529),m=s(33637),u=s(35806),p=s(71361);let h={connected:{icon:"cloud_done",color:"text-green-500",label:"Cloud"},syncing:{icon:"cloud_sync",color:"text-blue-400 animate-pulse",label:"Syncing..."},disconnected:{icon:"cloud_off",color:"text-amber-500",label:"Cloud Off"},error:{icon:"cloud_off",color:"text-red-400",label:"Cloud Error"},disabled:{icon:"cloud_off",color:"text-text-muted/50",label:"Disabled"}};function b({collapsed:e=!1}){let[t,s]=(0,a.useState)("disabled"),[l,n]=(0,a.useState)(null),i=(0,a.useRef)(!0),o=(0,c.useRouter)(),d=(0,a.useCallback)(async()=>{try{let e=await fetch("/api/sync/cloud");if(!i.current)return;if(!e.ok)return void s("disconnected");let t=await e.json();if(!i.current)return;t.enabled?t.syncing?s("syncing"):t.connected?(s("connected"),t.lastSync&&n(new Date(t.lastSync))):s("disconnected"):s("disabled")}catch{i.current&&s("disconnected")}},[]);if((0,a.useEffect)(()=>{i.current=!0,queueMicrotask(d);let e=setInterval(d,3e4),t=()=>{setTimeout(d,500)};return globalThis.addEventListener("cloud-status-changed",t),()=>{i.current=!1,clearInterval(e),globalThis.removeEventListener("cloud-status-changed",t)}},[d]),"disabled"===t)return null;let x=h[t];return(0,r.jsxs)("button",{onClick:()=>o.push("/dashboard/endpoint"),className:"flex items-center gap-2 px-3 py-1.5 text-xs rounded-lg hover:bg-white/5 transition-colors cursor-pointer w-full",title:l?`Cloud ${"connected"===t?"connected":"disconnected"} — Last sync: ${l.toLocaleTimeString()}`:x.label,"aria-label":`Cloud sync status: ${x.label}`,children:[(0,r.jsx)("span",{className:`material-symbols-outlined text-[16px] ${x.color}`,"aria-hidden":"true",children:x.icon}),!e&&(0,r.jsx)("span",{className:`truncate ${"connected"===t?"text-green-500":"text-text-muted"}`,children:x.label})]})}var f=s(50910);let g=[{href:"/dashboard",i18nKey:"home",icon:"home",exact:!0},{href:"/dashboard/endpoint",i18nKey:"endpoints",icon:"api"},{href:"/dashboard/api-manager",i18nKey:"apiManager",icon:"vpn_key"},{href:"/dashboard/providers",i18nKey:"providers",icon:"dns"},{href:"/dashboard/combos",i18nKey:"combos",icon:"layers"},{href:"/dashboard/logs",i18nKey:"logs",icon:"description"},{href:"/dashboard/costs",i18nKey:"costs",icon:"account_balance_wallet"},{href:"/dashboard/analytics",i18nKey:"analytics",icon:"analytics"},{href:"/dashboard/limits",i18nKey:"limits",icon:"tune"},{href:"/dashboard/health",i18nKey:"health",icon:"health_and_safety"},{href:"/dashboard/cli-tools",i18nKey:"cliTools",icon:"terminal"},{href:"/dashboard/media",i18nKey:"media",icon:"auto_awesome"}],y=[{href:"/dashboard/translator",i18nKey:"translator",icon:"translate"}],j=[{href:"/dashboard/settings",i18nKey:"settings",icon:"settings"}],v=[{href:"/docs",i18nKey:"docs",icon:"menu_book"},{href:"https://github.com/diegosouzapw/OmniRoute/issues",i18nKey:"issues",icon:"bug_report",external:!0}];function N({onClose:e,collapsed:t=!1,onToggleCollapse:s}){let l=(0,c.usePathname)(),n=(0,f.c)("sidebar"),i=(0,f.c)("common"),[h,N]=(0,a.useState)(!1),[k,w]=(0,a.useState)(!1),[C,S]=(0,a.useState)(!1),[T,I]=(0,a.useState)(!1),[O,R]=(0,a.useState)(!1),[A,E]=(0,a.useState)(!1);(0,a.useEffect)(()=>{fetch("/api/settings").then(e=>e.json()).then(e=>E(e?.enableRequestLogs===!0)).catch(()=>{})},[]);let L=async()=>{S(!0);try{await fetch("/api/shutdown",{method:"POST"})}catch(e){}S(!1),N(!1),R(!0)},M=async()=>{I(!0);try{await fetch("/api/restart",{method:"POST"})}catch(e){}I(!1),w(!1),R(!0),setTimeout(()=>{globalThis.location.reload()},3e3)},$=e=>e.map(e=>({...e,label:n(e.i18nKey)})),_=$(g),D=$(y),P=$(j),F=$(v),z=s=>{var a;let n=!s.external&&(a=s.href,s.exact?l===a:l.startsWith(a)),i=(0,d.cn)("flex items-center gap-3 rounded-lg transition-all group",t?"justify-center px-2 py-2.5":"px-4 py-2",n?"bg-primary/10 text-primary":"text-text-muted hover:bg-surface/50 hover:text-text-main"),c=(0,d.cn)("material-symbols-outlined text-[18px]",n?"fill-1":"group-hover:text-primary transition-colors"),x=(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("span",{className:c,children:s.icon}),!t&&(0,r.jsx)("span",{className:"text-sm font-medium",children:s.label})]});return s.external?(0,r.jsx)("a",{href:s.href,target:"_blank",rel:"noopener noreferrer",onClick:e,title:t?s.label:void 0,className:i,children:x},s.href):(0,r.jsx)(o(),{href:s.href,onClick:e,title:t?s.label:void 0,className:i,children:x},s.href)};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("aside",{className:(0,d.cn)("flex flex-col border-r border-black/5 dark:border-white/5 bg-vibrancy backdrop-blur-xl transition-all duration-300 ease-in-out",t?"w-16":"w-72"),children:[(0,r.jsx)("a",{href:"#main-content",className:"sr-only focus:not-sr-only focus:absolute focus:z-50 focus:p-3 focus:bg-primary focus:text-white focus:rounded-md focus:m-2",children:"Skip to content"}),(0,r.jsxs)("div",{className:(0,d.cn)("flex items-center gap-2 pt-5 pb-2",t?"px-3 justify-center":"px-6"),"aria-hidden":"true",children:[(0,r.jsx)("div",{className:"w-3 h-3 rounded-full bg-[#FF5F56]"}),(0,r.jsx)("div",{className:"w-3 h-3 rounded-full bg-[#FFBD2E]"}),(0,r.jsx)("div",{className:"w-3 h-3 rounded-full bg-[#27C93F]"}),!t&&(0,r.jsx)("div",{className:"flex-1"}),s&&(0,r.jsx)("button",{onClick:s,title:t?"Expand sidebar":"Collapse sidebar","aria-expanded":!t,"aria-label":t?"Expand sidebar":"Collapse sidebar",className:(0,d.cn)("p-1 rounded-md text-text-muted/50 hover:text-text-muted hover:bg-black/5 dark:hover:bg-white/5 transition-colors",t&&"mt-2"),children:(0,r.jsx)("span",{className:"material-symbols-outlined text-[16px]","aria-hidden":"true",children:t?"chevron_right":"chevron_left"})})]}),(0,r.jsx)("div",{className:(0,d.cn)("py-4",t?"px-2":"px-6"),children:(0,r.jsxs)(o(),{href:"/dashboard",className:(0,d.cn)("flex items-center",t?"justify-center":"gap-3"),children:[(0,r.jsx)("div",{className:"flex items-center justify-center size-9 rounded bg-linear-to-br from-[#E54D5E] to-[#C93D4E] shrink-0",children:(0,r.jsx)(m.A,{size:20,className:"text-white"})}),!t&&(0,r.jsxs)("div",{className:"flex flex-col",children:[(0,r.jsx)("h1",{className:"text-lg font-semibold tracking-tight text-text-main",children:x.vQ.name}),(0,r.jsxs)("span",{className:"text-xs text-text-muted",children:["v",x.vQ.version]})]})]})}),(0,r.jsxs)("nav",{"aria-label":"Main navigation",className:(0,d.cn)("flex-1 py-2 space-y-1 overflow-y-auto custom-scrollbar",t?"px-2":"px-4"),children:[_.map(z),A&&(0,r.jsxs)("div",{className:"pt-4 mt-2",children:[!t&&(0,r.jsx)("p",{className:"px-4 text-xs font-semibold text-text-muted/60 uppercase tracking-wider mb-2",children:"Debug"}),t&&(0,r.jsx)("div",{className:"border-t border-black/5 dark:border-white/5 mb-2"}),D.map(z)]}),(0,r.jsxs)("div",{className:"pt-4 mt-2",children:[!t&&(0,r.jsx)("p",{className:"px-4 text-xs font-semibold text-text-muted/60 uppercase tracking-wider mb-2",children:"System"}),t&&(0,r.jsx)("div",{className:"border-t border-black/5 dark:border-white/5 mb-2"}),P.map(z)]}),(0,r.jsxs)("div",{className:"pt-4 mt-2",children:[!t&&(0,r.jsx)("p",{className:"px-4 text-xs font-semibold text-text-muted/60 uppercase tracking-wider mb-2",children:"Help"}),t&&(0,r.jsx)("div",{className:"border-t border-black/5 dark:border-white/5 mb-2"}),F.map(z)]})]}),(0,r.jsx)(b,{collapsed:t}),(0,r.jsxs)("div",{className:(0,d.cn)("border-t border-black/5 dark:border-white/5",t?"p-2 flex flex-col gap-1":"p-3 flex gap-2"),children:[(0,r.jsxs)("button",{onClick:()=>w(!0),title:n("restart"),className:(0,d.cn)("flex items-center justify-center gap-2 rounded-lg font-medium transition-all","text-amber-500 hover:bg-amber-500/10 border border-amber-500/20 hover:border-amber-500/40",t?"p-2":"flex-1 px-3 py-2 text-sm"),children:[(0,r.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:"restart_alt"}),!t&&n("restart")]}),(0,r.jsxs)("button",{onClick:()=>N(!0),title:n("shutdown"),className:(0,d.cn)("flex items-center justify-center gap-2 rounded-lg font-medium transition-all","text-red-500 hover:bg-red-500/10 border border-red-500/20 hover:border-red-500/40",t?"p-2":"flex-1 px-3 py-2 text-sm"),children:[(0,r.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:"power_settings_new"}),!t&&n("shutdown")]})]})]}),(0,r.jsx)(p.ConfirmModal,{isOpen:h,onClose:()=>N(!1),onConfirm:L,title:n("shutdown"),message:n("shutdownConfirm"),confirmText:n("shutdown"),cancelText:i("cancel"),variant:"danger",loading:C}),(0,r.jsx)(p.ConfirmModal,{isOpen:k,onClose:()=>w(!1),onConfirm:M,title:n("restart"),message:n("restartConfirm"),confirmText:n("restart"),cancelText:i("cancel"),variant:"warning",loading:T}),O&&(0,r.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/80 backdrop-blur-sm",children:(0,r.jsxs)("div",{className:"text-center p-8",children:[(0,r.jsx)("div",{className:"flex items-center justify-center size-16 rounded-full bg-red-500/20 text-red-500 mx-auto mb-4",children:(0,r.jsx)("span",{className:"material-symbols-outlined text-[32px]",children:"power_off"})}),(0,r.jsx)("h2",{className:"text-xl font-semibold text-white mb-2",children:"Server Disconnected"}),(0,r.jsx)("p",{className:"text-text-muted mb-6",children:"The proxy server has been stopped or is restarting."}),(0,r.jsx)(u.default,{variant:"secondary",onClick:()=>globalThis.location.reload(),children:"Reload Page"})]})})]})}N.propTypes={onClose:n().func,collapsed:n().bool,onToggleCollapse:n().func}},34422:(e,t,s)=>{s.d(t,{default:()=>n});var r=s(95155),a=s(12115),l=s(67040);function n({label:e,type:t="text",placeholder:s,value:n,onChange:i,error:o,hint:c,icon:d,disabled:x=!1,required:m=!1,className:u,inputClassName:p,id:h,...b}){let f=(0,a.useId)(),g=h||f,y=o?`${g}-error`:void 0,j=c&&!o?`${g}-hint`:void 0,v=[y,j].filter(Boolean).join(" ")||void 0;return(0,r.jsxs)("div",{className:(0,l.cn)("flex flex-col gap-1.5",u),children:[e&&(0,r.jsxs)("label",{htmlFor:g,className:"text-sm font-medium text-text-main",children:[e,m&&(0,r.jsx)("span",{className:"text-red-500 ml-1","aria-hidden":"true",children:"*"})]}),(0,r.jsxs)("div",{className:"relative",children:[d&&(0,r.jsx)("div",{className:"absolute inset-y-0 left-0 flex items-center pl-3 pointer-events-none text-text-muted",children:(0,r.jsx)("span",{className:"material-symbols-outlined text-[20px]","aria-hidden":"true",children:d})}),(0,r.jsx)("input",{id:g,type:t,placeholder:s,value:n,onChange:i,disabled:x,required:m,"aria-required":m||void 0,"aria-invalid":!!o||void 0,"aria-describedby":v,className:(0,l.cn)("w-full py-2 px-3 text-sm text-text-main","bg-white dark:bg-white/5 border border-black/10 dark:border-white/10 rounded-md","placeholder-text-muted/60","focus:ring-1 focus:ring-primary/30 focus:border-primary/50 focus:outline-none","transition-all shadow-inner disabled:opacity-50 disabled:cursor-not-allowed","text-[16px] sm:text-sm",d&&"pl-10",o?"border-red-500 focus:border-red-500 focus:ring-red-500/20":"",p),...b})]}),o&&(0,r.jsxs)("p",{id:y,className:"text-xs text-red-500 flex items-center gap-1",role:"alert",children:[(0,r.jsx)("span",{className:"material-symbols-outlined text-[14px]","aria-hidden":"true",children:"error"}),o]}),c&&!o&&(0,r.jsx)("p",{id:j,className:"text-xs text-text-muted",children:c})]})}},35806:(e,t,s)=>{s.d(t,{default:()=>i});var r=s(95155),a=s(67040);let l={primary:"bg-gradient-to-b from-primary to-primary-hover text-white shadow-sm",secondary:"bg-white dark:bg-white/10 border border-black/10 dark:border-white/10 text-text-main hover:bg-black/5 dark:hover:bg-white/5",outline:"border border-black/15 dark:border-white/15 text-text-main hover:bg-black/5",ghost:"text-text-muted hover:bg-black/5 dark:hover:bg-white/5 hover:text-text-main",danger:"bg-red-500 text-white hover:bg-red-600 shadow-sm"},n={sm:"h-7 px-3 text-xs rounded-md",md:"h-9 px-4 text-sm rounded-lg",lg:"h-11 px-6 text-sm rounded-lg"};function i({children:e,variant:t="primary",size:s="md",icon:i,iconRight:o,disabled:c=!1,loading:d=!1,fullWidth:x=!1,className:m,...u}){return(0,r.jsxs)("button",{type:"button",className:(0,a.cn)("inline-flex items-center justify-center gap-2 font-medium transition-all duration-200 cursor-pointer","active:scale-[0.99] disabled:opacity-50 disabled:cursor-not-allowed disabled:active:scale-100",l[t],n[s],x&&"w-full",m),disabled:c||d,"aria-busy":d||void 0,...u,children:[d?(0,r.jsx)("span",{className:"material-symbols-outlined animate-spin text-[18px] pointer-events-none","aria-hidden":"true",children:"progress_activity"}):i?(0,r.jsx)("span",{className:"material-symbols-outlined text-[18px] pointer-events-none","aria-hidden":"true",children:i}):null,e,o&&!d&&(0,r.jsx)("span",{className:"material-symbols-outlined text-[18px] pointer-events-none","aria-hidden":"true",children:o})]})}},37415:(e,t,s)=>{s.d(t,{default:()=>h});var r=s(95155),a=s(12115),l=s(81060),n=s(99333),i=s(8898);function o({title:e,json:t,onCopy:s}){let[l,n]=(0,a.useState)(!1),i=async()=>{!1!==await s()&&(n(!0),setTimeout(()=>n(!1),2e3))};return(0,r.jsxs)("div",{children:[(0,r.jsxs)("div",{className:"flex items-center justify-between mb-2",children:[(0,r.jsx)("h3",{className:"text-[11px] text-text-muted uppercase tracking-wider font-bold",children:e}),(0,r.jsxs)("button",{onClick:i,className:"flex items-center gap-1 px-2 py-1 text-xs text-text-muted hover:text-text-primary transition-colors","aria-label":`Copy ${e}`,children:[(0,r.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:l?"check":"content_copy"}),l?"Copied!":"Copy"]})]}),(0,r.jsx)("pre",{className:"p-4 rounded-xl bg-black/30 border border-border overflow-x-auto text-xs font-mono text-text-primary max-h-[600px] overflow-y-auto leading-relaxed whitespace-pre-wrap break-words",children:t})]})}function c({log:e,detail:t,loading:s,onClose:l,onCopy:c}){(0,a.useEffect)(()=>{let e=e=>{"Escape"===e.key&&l()};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[l]);let d=(0,n._Z)(e.status),x=e.sourceFormat||e.provider,m=n.Kf[x]||n.Kf[e.provider]||{bg:"#6B7280",text:"#fff",label:(x||e.provider||"-").toUpperCase()},u=n.RY[e.provider]||{bg:"#374151",text:"#fff",label:(e.provider||"-").toUpperCase()},p=t?.requestBody?JSON.stringify(t.requestBody,null,2):null,h=t?.responseBody?JSON.stringify(t.responseBody,null,2):null;return(0,r.jsxs)("div",{className:"fixed inset-0 z-50 flex items-start justify-center pt-[5vh]",onClick:l,role:"dialog","aria-modal":"true","aria-label":"Request log detail",children:[(0,r.jsx)("div",{className:"absolute inset-0 bg-black/60 backdrop-blur-sm"}),(0,r.jsxs)("div",{className:"relative bg-bg-primary border border-border rounded-xl w-full max-w-[900px] max-h-[90vh] 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-6 py-4 border-b border-border bg-bg-primary/95 backdrop-blur-sm rounded-t-xl",children:[(0,r.jsxs)("div",{className:"flex items-center gap-3",children:[(0,r.jsx)("span",{className:"inline-block px-2.5 py-1 rounded text-xs font-bold",style:{backgroundColor:d.bg,color:d.text},children:e.status}),(0,r.jsx)("span",{className:"font-bold text-lg",children:e.method}),(0,r.jsx)("span",{className:"text-text-muted font-mono text-sm",children:e.path})]}),(0,r.jsx)("button",{onClick:l,className:"p-1.5 rounded-lg hover:bg-bg-subtle text-text-muted hover:text-text-primary transition-colors","aria-label":"Close detail modal",children:(0,r.jsx)("span",{className:"material-symbols-outlined",children:"close"})})]}),(0,r.jsxs)("div",{className:"p-6 flex flex-col gap-6",children:[(0,r.jsxs)("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4 p-4 bg-bg-subtle rounded-xl border border-border",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("div",{className:"text-[10px] text-text-muted uppercase tracking-wider mb-1",children:"Time"}),(0,r.jsx)("div",{className:"text-sm font-medium",children:(e=>{try{let t=new Date(e);return t.toLocaleDateString("pt-BR")+", "+t.toLocaleTimeString("en-US",{hour12:!1})}catch{return e}})(e.timestamp)})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("div",{className:"text-[10px] text-text-muted uppercase tracking-wider mb-1",children:"Duration"}),(0,r.jsx)("div",{className:"text-sm font-medium",children:(0,i.a3)(e.duration)})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("div",{className:"text-[10px] text-text-muted uppercase tracking-wider mb-1",children:"Tokens (I/O)"}),(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsxs)("span",{className:"px-2 py-0.5 rounded bg-primary/20 text-primary text-xs font-bold",children:["In: ",(t?.tokens?.in||e.tokens?.in||0).toLocaleString()]}),(0,r.jsxs)("span",{className:"px-2 py-0.5 rounded bg-emerald-500/20 text-emerald-400 text-xs font-bold",children:["Out: ",(t?.tokens?.out||e.tokens?.out||0).toLocaleString()]})]})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("div",{className:"text-[10px] text-text-muted uppercase tracking-wider mb-1",children:"Model"}),(0,r.jsx)("div",{className:"text-sm font-medium text-primary font-mono",children:e.model})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("div",{className:"text-[10px] text-text-muted uppercase tracking-wider mb-1",children:"Provider"}),(0,r.jsx)("span",{className:"inline-block px-2.5 py-1 rounded text-[10px] font-bold uppercase",style:{backgroundColor:u.bg,color:u.text},children:u.label})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("div",{className:"text-[10px] text-text-muted uppercase tracking-wider mb-1",children:"Protocol"}),(0,r.jsx)("span",{className:"inline-block px-2.5 py-1 rounded text-[10px] font-bold uppercase",style:{backgroundColor:m.bg,color:m.text},children:m.label})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("div",{className:"text-[10px] text-text-muted uppercase tracking-wider mb-1",children:"Account"}),(0,r.jsx)("div",{className:"text-sm font-medium",children:t?.account||e.account||"-"})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("div",{className:"text-[10px] text-text-muted uppercase tracking-wider mb-1",children:"API Key"}),(0,r.jsx)("div",{className:"text-sm font-medium",title:t?.apiKeyName||t?.apiKeyId||e.apiKeyName||e.apiKeyId||"No API key",children:(0,i.VO)(t?.apiKeyName||e.apiKeyName,t?.apiKeyId||e.apiKeyId)})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("div",{className:"text-[10px] text-text-muted uppercase tracking-wider mb-1",children:"Combo"}),t?.comboName||e.comboName?(0,r.jsx)("span",{className:"inline-block px-2.5 py-1 rounded-full text-[10px] font-bold bg-violet-500/20 text-violet-300 border border-violet-500/30",children:t?.comboName||e.comboName}):(0,r.jsx)("div",{className:"text-sm text-text-muted",children:"—"})]})]}),(t?.error||e.error)&&(0,r.jsxs)("div",{className:"p-4 rounded-xl bg-red-500/10 border border-red-500/30",children:[(0,r.jsx)("div",{className:"text-[10px] text-red-400 uppercase tracking-wider mb-1 font-bold",children:"Error"}),(0,r.jsx)("div",{className:"text-sm text-red-300 font-mono",children:t?.error||e.error})]}),s?(0,r.jsx)("div",{className:"p-8 text-center text-text-muted animate-pulse",children:"Loading request details..."}):(0,r.jsxs)(r.Fragment,{children:[p&&(0,r.jsx)(o,{title:"Request Payload",json:p,onCopy:()=>c(p)}),h&&(0,r.jsx)(o,{title:"Response Payload",json:h,onCopy:()=>c(h)}),!p&&!h&&!s&&(0,r.jsxs)("div",{className:"p-6 text-center text-text-muted",children:[(0,r.jsx)("span",{className:"material-symbols-outlined text-[32px] mb-2 block opacity-40",children:"info"}),(0,r.jsx)("p",{className:"text-sm",children:"No payload data available for this log entry."}),(0,r.jsx)("p",{className:"text-xs mt-1",children:"Request/response bodies are only captured for non-streaming calls or when streaming completes normally."})]})]})]})]})]})}let d=[{key:"all",label:"All"},{key:"error",label:"Errors",icon:"error"},{key:"ok",label:"Success",icon:"check_circle"},{key:"combo",label:"Combo",icon:"hub"}],x=[{key:"status",label:"Status"},{key:"model",label:"Model"},{key:"provider",label:"Provider"},{key:"protocol",label:"Protocol"},{key:"account",label:"Account"},{key:"apiKey",label:"API Key"},{key:"combo",label:"Combo"},{key:"tokens",label:"Tokens"},{key:"duration",label:"Duration"},{key:"time",label:"Time"}],m=Object.fromEntries(x.map(e=>[e.key,!0]));function u(e,t){if(!e)return"-";if(e.startsWith("openai-compatible-")||e.startsWith("anthropic-compatible-")){if(t?.length){let s=t.find(t=>t.id===e||t.prefix===e);if(s?.name)return s.name}if(e.startsWith("openai-compatible-")){let t=e.replace("openai-compatible-",""),s=t.split("-");return s.length>1&&s[1]?.length>=8?"OAI-COMPAT":`OAI: ${t.slice(0,16).toUpperCase()}`}if(e.startsWith("anthropic-compatible-")){let t=e.replace("anthropic-compatible-",""),s=t.split("-");return s.length>1&&s[1]?.length>=8?"ANT-COMPAT":`ANT: ${t.slice(0,16).toUpperCase()}`}}return null}function p(e){return(e?.tokens?.in||0)+(e?.tokens?.out||0)}function h(){let[e,t]=(0,a.useState)([]),[s,o]=(0,a.useState)(!0),[h,b]=(0,a.useState)(!0),[f,g]=(0,a.useState)(""),[y,j]=(0,a.useState)("all"),[v,N]=(0,a.useState)(""),[k,w]=(0,a.useState)(""),[C,S]=(0,a.useState)(""),[T,I]=(0,a.useState)(""),[O,R]=(0,a.useState)("newest"),[A,E]=(0,a.useState)(null),[L,M]=(0,a.useState)(!1),[$,_]=(0,a.useState)(null),D=(0,a.useRef)(null),P=(0,a.useRef)(!1),[F,z]=(0,a.useState)([]),[K,U]=(0,a.useState)(()=>{try{let e=localStorage.getItem("loggerVisibleColumns");return e?{...m,...JSON.parse(e)}:m}catch{return m}}),q=(0,a.useCallback)(e=>{U(t=>{let s={...t,[e]:!t[e]};try{localStorage.setItem("loggerVisibleColumns",JSON.stringify(s))}catch{}return s})},[]),B=(0,a.useCallback)(async(e=!1)=>{e&&o(!0);try{let e=new URLSearchParams;f&&e.set("search",f),"error"===y&&e.set("status","error"),"ok"===y&&e.set("status","ok"),"combo"===y&&e.set("combo","1"),v&&e.set("model",v),C&&e.set("provider",C),k&&e.set("account",k),T&&e.set("apiKey",T),e.set("limit","300");let s=await fetch(`/api/usage/call-logs?${e}`);if(s.ok){let e=await s.json();t(e)}}catch(e){console.error("Failed to fetch call logs:",e)}finally{e&&o(!1)}},[f,y,v,k,C,T]);(0,a.useEffect)(()=>{let e=!P.current;P.current=!0,B(e)},[B]),(0,a.useEffect)(()=>{fetch("/api/provider-nodes").then(e=>e.ok?e.json():{nodes:[]}).then(e=>z(e.nodes||[])).catch(()=>{})},[]),(0,a.useEffect)(()=>(D.current&&clearInterval(D.current),h&&(D.current=setInterval(()=>B(!1),3e3)),()=>{D.current&&clearInterval(D.current)}),[h,B]);let W=(0,a.useMemo)(()=>"combo"===y?e.filter(e=>e.comboName):e,[y,e]),V=(0,a.useMemo)(()=>{let e=[...W];return e.sort((e,t)=>{switch(O){case"oldest":return new Date(e.timestamp).getTime()-new Date(t.timestamp).getTime();case"tokens_desc":return p(t)-p(e);case"tokens_asc":return p(e)-p(t);case"duration_desc":return(t.duration||0)-(e.duration||0);case"duration_asc":return(e.duration||0)-(t.duration||0);case"status_desc":return(t.status||0)-(e.status||0);case"status_asc":return(e.status||0)-(t.status||0);case"model_asc":return(e.model||"").localeCompare(t.model||"");case"model_desc":return(t.model||"").localeCompare(e.model||"");default:return new Date(t.timestamp).getTime()-new Date(e.timestamp).getTime()}}),e},[W,O]),H=async e=>{E(e),M(!0),_(null);try{let t=await fetch(`/api/usage/call-logs/${e.id}`);if(t.ok){let e=await t.json();_(e)}}catch(e){console.error("Failed to fetch log detail:",e)}finally{M(!1)}},G=async e=>{try{return await navigator.clipboard.writeText(e),!0}catch{try{let t=document.createElement("textarea");return t.value=e,t.style.position="fixed",t.style.left="-9999px",document.body.appendChild(t),t.select(),document.execCommand("copy"),document.body.removeChild(t),!0}catch{return!1}}},Y=[...new Set(e.map(e=>e.account).filter(e=>e&&"-"!==e))],J=[...new Set(e.map(e=>e.model).filter(Boolean))].sort(),Q=[...new Set(e.map(e=>e.provider).filter(e=>e&&"-"!==e))].sort(),X=[...new Set(e.map(e=>e.apiKeyId||e.apiKeyName).filter(Boolean))].sort(),Z=W.length,ee=W.filter(e=>e.status>=200&&e.status<300).length,et=W.filter(e=>e.status>=400).length,es=e.filter(e=>e.comboName).length,er=X.length;return(0,r.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,r.jsxs)("div",{className:"flex flex-wrap items-center gap-3",children:[(0,r.jsxs)("button",{onClick:()=>b(!h),className:`flex items-center gap-2 px-3 py-1.5 rounded-full text-sm font-medium border transition-colors ${h?"bg-red-500/10 border-red-500/30 text-red-400":"bg-bg-subtle border-border text-text-muted"}`,children:[(0,r.jsx)("span",{className:`w-2 h-2 rounded-full ${h?"bg-red-500 animate-pulse":"bg-text-muted"}`}),h?"Recording":"Paused"]}),(0,r.jsxs)("div",{className:"flex-1 min-w-[200px] relative",children:[(0,r.jsx)("span",{className:"material-symbols-outlined absolute left-3 top-1/2 -translate-y-1/2 text-text-muted text-[18px]",children:"search"}),(0,r.jsx)("input",{type:"text",placeholder:"Search model, provider, account, API key, combo...",value:f,onChange:e=>g(e.target.value),className:"w-full pl-10 pr-4 py-2 rounded-lg bg-bg-subtle border border-border text-sm text-text-primary placeholder:text-text-muted focus:outline-none focus:border-primary"})]}),(0,r.jsxs)("select",{value:C,onChange:e=>S(e.target.value),className:"px-3 py-2 rounded-lg bg-bg-subtle border border-border text-sm text-text-primary focus:outline-none focus:border-primary appearance-none cursor-pointer min-w-[140px]",children:[(0,r.jsx)("option",{value:"",children:"All Providers"}),Q.map(e=>{let t=u(e,F),s=n.RY[e];return(0,r.jsx)("option",{value:e,children:t||s?.label||e.toUpperCase()},e)})]}),(0,r.jsxs)("select",{value:v,onChange:e=>N(e.target.value),className:"px-3 py-2 rounded-lg bg-bg-subtle border border-border text-sm text-text-primary focus:outline-none focus:border-primary appearance-none cursor-pointer min-w-[180px]",children:[(0,r.jsx)("option",{value:"",children:"All Models"}),J.map(e=>(0,r.jsx)("option",{value:e,children:e},e))]}),(0,r.jsxs)("select",{value:k,onChange:e=>w(e.target.value),className:"px-3 py-2 rounded-lg bg-bg-subtle border border-border text-sm text-text-primary focus:outline-none focus:border-primary appearance-none cursor-pointer min-w-[140px]",children:[(0,r.jsx)("option",{value:"",children:"All Accounts"}),Y.map(e=>(0,r.jsx)("option",{value:e,children:e},e))]}),(0,r.jsxs)("select",{value:T,onChange:e=>I(e.target.value),className:"px-3 py-2 rounded-lg bg-bg-subtle border border-border text-sm text-text-primary focus:outline-none focus:border-primary appearance-none cursor-pointer min-w-[160px]",children:[(0,r.jsx)("option",{value:"",children:"All API Keys"}),X.map(t=>{let s=e.find(e=>(e.apiKeyId||e.apiKeyName)===t),a=(0,i.VO)(s?.apiKeyName,s?.apiKeyId);return(0,r.jsx)("option",{value:t,children:a},t)})]}),(0,r.jsxs)("div",{className:"flex items-center gap-2 text-xs text-text-muted",children:[(0,r.jsxs)("span",{className:"px-2 py-1 rounded bg-bg-subtle border border-border font-mono",children:[Z," total"]}),(0,r.jsxs)("span",{className:"px-2 py-1 rounded bg-emerald-500/10 text-emerald-400 font-mono",children:[ee," OK"]}),et>0&&(0,r.jsxs)("span",{className:"px-2 py-1 rounded bg-red-500/10 text-red-400 font-mono",children:[et," ERR"]}),es>0&&(0,r.jsxs)("span",{className:"px-2 py-1 rounded bg-violet-500/10 text-violet-300 font-mono",children:[es," combo"]}),er>0&&(0,r.jsxs)("span",{className:"px-2 py-1 rounded bg-primary/10 text-primary font-mono",children:[er," keys"]}),(0,r.jsxs)("span",{className:"px-2 py-1 rounded bg-bg-subtle border border-border font-mono",children:[V.length," shown"]})]}),(0,r.jsxs)("select",{value:O,onChange:e=>R(e.target.value),className:"px-3 py-2 rounded-lg bg-bg-subtle border border-border text-sm text-text-primary focus:outline-none focus:border-primary appearance-none cursor-pointer min-w-[150px]",title:"Sort logs",children:[(0,r.jsx)("option",{value:"newest",children:"Newest"}),(0,r.jsx)("option",{value:"oldest",children:"Oldest"}),(0,r.jsx)("option",{value:"tokens_desc",children:"Tokens ↓"}),(0,r.jsx)("option",{value:"tokens_asc",children:"Tokens ↑"}),(0,r.jsx)("option",{value:"duration_desc",children:"Duration ↓"}),(0,r.jsx)("option",{value:"duration_asc",children:"Duration ↑"}),(0,r.jsx)("option",{value:"status_desc",children:"Status ↓"}),(0,r.jsx)("option",{value:"status_asc",children:"Status ↑"}),(0,r.jsx)("option",{value:"model_asc",children:"Model A-Z"}),(0,r.jsx)("option",{value:"model_desc",children:"Model Z-A"})]}),(0,r.jsx)("button",{onClick:()=>B(!1),className:"p-2 rounded-lg hover:bg-bg-subtle text-text-muted hover:text-text-primary transition-colors",title:"Refresh",children:(0,r.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:"refresh"})})]}),(0,r.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[d.map(e=>(0,r.jsxs)("button",{onClick:()=>j(y===e.key?"all":e.key),className:`flex items-center gap-1.5 px-3 py-1 rounded-full text-xs font-medium border transition-all ${y===e.key?"error"===e.key?"bg-red-500/20 text-red-400 border-red-500/40":"ok"===e.key?"bg-emerald-500/20 text-emerald-400 border-emerald-500/40":"combo"===e.key?"bg-violet-500/20 text-violet-300 border-violet-500/40":"bg-primary text-white border-primary":"bg-bg-subtle border-border text-text-muted hover:border-text-muted"}`,children:[e.icon&&(0,r.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:e.icon}),e.label]},e.key)),Q.length>0&&(0,r.jsx)("span",{className:"w-px h-5 bg-border mx-1"}),Q.map(e=>{let t=u(e,F),s=n.RY[e]||{bg:"#374151",text:"#fff",label:t||e.toUpperCase()},a=t||s.label,l=C===e;return(0,r.jsx)("button",{onClick:()=>S(l?"":e),className:`px-3 py-1 rounded-full text-xs font-bold uppercase border transition-all ${l?"border-white/40 ring-1 ring-white/20":"border-transparent opacity-70 hover:opacity-100"}`,style:{backgroundColor:l?s.bg:`${s.bg}33`,color:l?s.text:s.bg},children:a},e)})]}),(0,r.jsxs)("div",{className:"flex flex-wrap items-center gap-1.5",children:[(0,r.jsx)("span",{className:"text-[10px] text-text-muted uppercase tracking-wider mr-1",children:"Columns"}),x.map(e=>(0,r.jsx)("button",{onClick:()=>q(e.key),className:`px-2 py-0.5 rounded text-[10px] font-medium border transition-all ${K[e.key]?"bg-primary/15 text-primary border-primary/30":"bg-bg-subtle text-text-muted border-border opacity-50 hover:opacity-80"}`,children:e.label},e.key))]}),(0,r.jsx)(l.default,{className:"overflow-hidden bg-black/5 dark:bg-black/20",children:(0,r.jsx)("div",{className:"p-0 overflow-x-auto max-h-[calc(100vh-320px)] overflow-y-auto",children:s&&0===e.length?(0,r.jsx)("div",{className:"p-8 text-center text-text-muted",children:"Loading logs..."}):0===e.length?(0,r.jsxs)("div",{className:"p-8 text-center text-text-muted",children:[(0,r.jsx)("span",{className:"material-symbols-outlined text-[48px] mb-2 block opacity-40",children:"receipt_long"}),"No logs recorded yet. Make some API calls to see them here."]}):0===V.length?(0,r.jsx)("div",{className:"p-8 text-center text-text-muted",children:"No logs match the current filters."}):(0,r.jsxs)("table",{className:"w-full text-left border-collapse text-xs",children:[(0,r.jsx)("thead",{className:"sticky top-0 z-10",style:{backgroundColor:"var(--bg-primary, #0f1117)"},children:(0,r.jsxs)("tr",{className:"border-b border-border",style:{backgroundColor:"var(--bg-primary, #0f1117)"},children:[K.status&&(0,r.jsx)("th",{className:"px-3 py-2.5 font-semibold text-text-muted uppercase tracking-wider text-[10px]",children:"Status"}),K.model&&(0,r.jsx)("th",{className:"px-3 py-2.5 font-semibold text-text-muted uppercase tracking-wider text-[10px]",children:"Model"}),K.provider&&(0,r.jsx)("th",{className:"px-3 py-2.5 font-semibold text-text-muted uppercase tracking-wider text-[10px]",children:"Provider"}),K.protocol&&(0,r.jsx)("th",{className:"px-3 py-2.5 font-semibold text-text-muted uppercase tracking-wider text-[10px]",children:"Protocol"}),K.account&&(0,r.jsx)("th",{className:"px-3 py-2.5 font-semibold text-text-muted uppercase tracking-wider text-[10px]",children:"Account"}),K.apiKey&&(0,r.jsx)("th",{className:"px-3 py-2.5 font-semibold text-text-muted uppercase tracking-wider text-[10px]",children:"API Key"}),K.combo&&(0,r.jsx)("th",{className:"px-3 py-2.5 font-semibold text-text-muted uppercase tracking-wider text-[10px]",children:"Combo"}),K.tokens&&(0,r.jsx)("th",{className:"px-3 py-2.5 font-semibold text-text-muted uppercase tracking-wider text-[10px] text-right",children:"Tokens"}),K.duration&&(0,r.jsx)("th",{className:"px-3 py-2.5 font-semibold text-text-muted uppercase tracking-wider text-[10px] text-right",children:"Duration"}),K.time&&(0,r.jsx)("th",{className:"px-3 py-2.5 font-semibold text-text-muted uppercase tracking-wider text-[10px] text-right",children:"Time"})]})}),(0,r.jsx)("tbody",{className:"divide-y divide-border/30",children:V.map(e=>{let t=(0,n._Z)(e.status),s=e.sourceFormat||e.provider,a=n.Kf[s]||n.Kf[e.provider]||{bg:"#6B7280",text:"#fff",label:(s||e.provider||"-").toUpperCase()},l=u(e.provider,F),o=n.RY[e.provider]||{bg:"#374151",text:"#fff",label:l||(e.provider||"-").toUpperCase()},c=l||o.label,d=e.status>=400;return(0,r.jsxs)("tr",{onClick:()=>H(e),className:`cursor-pointer hover:bg-primary/5 transition-colors ${d?"bg-red-500/5":""}`,children:[K.status&&(0,r.jsx)("td",{className:"px-3 py-2",children:(0,r.jsx)("span",{className:"inline-block px-2 py-0.5 rounded text-[10px] font-bold min-w-[36px] text-center",style:{backgroundColor:t.bg,color:t.text},children:e.status||"..."})}),K.model&&(0,r.jsx)("td",{className:"px-3 py-2 font-medium text-primary font-mono text-[11px]",children:e.model}),K.provider&&(0,r.jsx)("td",{className:"px-3 py-2",children:(0,r.jsx)("span",{className:"inline-block px-2 py-0.5 rounded text-[9px] font-bold uppercase",style:{backgroundColor:o.bg,color:o.text},children:c})}),K.protocol&&(0,r.jsx)("td",{className:"px-3 py-2",children:(0,r.jsx)("span",{className:"inline-block px-2 py-0.5 rounded text-[9px] font-bold uppercase",style:{backgroundColor:a.bg,color:a.text},children:a.label})}),K.account&&(0,r.jsx)("td",{className:"px-3 py-2 text-text-muted truncate max-w-[120px]",title:e.account,children:(0,i.Ib)(e.account)}),K.apiKey&&(0,r.jsx)("td",{className:"px-3 py-2 text-text-muted truncate max-w-[140px]",title:e.apiKeyName||e.apiKeyId||"No API key",children:(0,i.VO)(e.apiKeyName,e.apiKeyId)}),K.combo&&(0,r.jsx)("td",{className:"px-3 py-2",children:e.comboName?(0,r.jsx)("span",{className:"inline-block px-2 py-0.5 rounded-full text-[9px] font-bold bg-violet-500/20 text-violet-300 border border-violet-500/30",children:e.comboName}):(0,r.jsx)("span",{className:"text-text-muted text-[10px]",children:"—"})}),K.tokens&&(0,r.jsxs)("td",{className:"px-3 py-2 text-right whitespace-nowrap",children:[(0,r.jsx)("span",{className:"text-text-muted",children:"I:"})," ",(0,r.jsx)("span",{className:"text-primary",children:e.tokens?.in?.toLocaleString()||0}),(0,r.jsx)("span",{className:"mx-1 text-border",children:"|"}),(0,r.jsx)("span",{className:"text-text-muted",children:"O:"})," ",(0,r.jsx)("span",{className:"text-emerald-400",children:e.tokens?.out?.toLocaleString()||0})]}),K.duration&&(0,r.jsx)("td",{className:"px-3 py-2 text-right text-text-muted font-mono",children:(0,i.a3)(e.duration)}),K.time&&(0,r.jsx)("td",{className:"px-3 py-2 text-right text-text-muted",children:(0,i.fU)(e.timestamp)})]},e.id)})})]})})}),(0,r.jsxs)("div",{className:"text-[10px] text-text-muted italic",children:["Call logs are also saved as JSON files to ",(0,r.jsx)("code",{children:"{DATA_DIR}/call_logs/"})," with 7-day rotation."]}),A&&(0,r.jsx)(c,{log:A,detail:$,loading:L,onClose:()=>{E(null),_(null)},onCopy:G})]})}},42994:(e,t,s)=>{s.d(t,{default:()=>n});var r=s(95155),a=s(12115),l=s(67040);function n({label:e,options:t=[],value:s,onChange:n,placeholder:i="Select an option",error:o,hint:c,disabled:d=!1,required:x=!1,className:m,selectClassName:u,id:p,...h}){let b=(0,a.useId)(),f=p||b,g=o?`${f}-error`:void 0,y=c&&!o?`${f}-hint`:void 0,j=[g,y].filter(Boolean).join(" ")||void 0;return(0,r.jsxs)("div",{className:(0,l.cn)("flex flex-col gap-1.5",m),children:[e&&(0,r.jsxs)("label",{htmlFor:f,className:"text-sm font-medium text-text-main",children:[e,x&&(0,r.jsx)("span",{className:"text-red-500 ml-1","aria-hidden":"true",children:"*"})]}),(0,r.jsxs)("div",{className:"relative",children:[(0,r.jsxs)("select",{id:f,value:s,onChange:n,disabled:d,required:x,"aria-required":x||void 0,"aria-invalid":!!o||void 0,"aria-describedby":j,className:(0,l.cn)("w-full py-2 px-3 pr-10 text-sm text-text-main","bg-surface border border-black/10 dark:border-white/10 rounded-md appearance-none","focus:ring-1 focus:ring-primary/30 focus:border-primary/50 focus:outline-none","transition-all disabled:opacity-50 disabled:cursor-not-allowed","text-[16px] sm:text-sm",o?"border-red-500 focus:border-red-500 focus:ring-red-500/20":"",u),...h,children:[(0,r.jsx)("option",{value:"",disabled:!0,className:"bg-surface text-text-muted",children:i}),t.map(e=>(0,r.jsx)("option",{value:e.value,className:"bg-surface text-text-main",children:e.label},e.value))]}),(0,r.jsx)("div",{className:"absolute inset-y-0 right-0 flex items-center pr-3 pointer-events-none text-text-muted","aria-hidden":"true",children:(0,r.jsx)("span",{className:"material-symbols-outlined text-[20px]",children:"expand_more"})})]}),o&&(0,r.jsxs)("p",{id:g,className:"text-xs text-red-500 flex items-center gap-1",role:"alert",children:[(0,r.jsx)("span",{className:"material-symbols-outlined text-[14px]","aria-hidden":"true",children:"error"}),o]}),c&&!o&&(0,r.jsx)("p",{id:y,className:"text-xs text-text-muted",children:c})]})}},44638:(e,t,s)=>{s.d(t,{default:()=>a});var r=s(95155);function a({columns:e=[],data:t=[],renderCell:s,renderHeader:a,onRowClick:l,selectedId:n,loading:i=!1,maxHeight:o="calc(100vh - 320px)",emptyIcon:c="\uD83D\uDCED",emptyMessage:d="No data found"}){return i?(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",padding:"48px 24px",color:"var(--text-secondary, #888)",fontSize:"14px"},children:[(0,r.jsx)("span",{style:{animation:"spin 1s linear infinite",marginRight:"8px"},children:"⏳"}),"Loading...",(0,r.jsx)("style",{children:"@keyframes spin { to { transform: rotate(360deg); } }"})]}):0===t.length?(0,r.jsxs)("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",padding:"48px 24px",color:"var(--text-secondary, #888)",fontSize:"14px"},children:[(0,r.jsx)("span",{style:{fontSize:"32px",marginBottom:"8px",opacity:.6},children:c}),d]}):(0,r.jsx)("div",{style:{overflow:"auto",maxHeight:o,borderRadius:"8px"},children:(0,r.jsxs)("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:"12px",tableLayout:"auto"},children:[(0,r.jsx)("thead",{children:(0,r.jsx)("tr",{children:e.map(e=>(0,r.jsx)("th",{style:{padding:"8px 10px",textAlign:"left",fontWeight:600,color:"var(--text-secondary, #888)",borderBottom:"1px solid rgba(255,255,255,0.08)",position:"sticky",top:0,background:"var(--bg-table-header, rgba(15,15,25,0.95))",zIndex:1,whiteSpace:"nowrap",fontSize:"11px",textTransform:"uppercase",letterSpacing:"0.5px"},children:a?a(e):e.label},e.key))})}),(0,r.jsx)("tbody",{children:t.map((t,a)=>(0,r.jsx)("tr",{onClick:()=>l?.(t),style:{cursor:l?"pointer":"default",background:t.id===n?"rgba(99,102,241,0.1)":a%2==0?"transparent":"rgba(255,255,255,0.02)",transition:"background 0.15s"},onMouseEnter:e=>{t.id!==n&&(e.currentTarget.style.background="rgba(255,255,255,0.04)")},onMouseLeave:e=>{t.id!==n&&(e.currentTarget.style.background=a%2==0?"transparent":"rgba(255,255,255,0.02)")},children:e.map(e=>(0,r.jsx)("td",{style:{padding:"6px 10px",borderBottom:"1px solid rgba(255,255,255,0.04)",whiteSpace:"nowrap",maxWidth:e.maxWidth||"200px",overflow:"hidden",textOverflow:"ellipsis"},children:s(t,e)},e.key))},t.id||a))})]})})}},45624:(e,t,s)=>{s.d(t,{default:()=>D});var r=s(95155),a=s(12115),l=s(81060),n=s(92542),i=s(8898),o=s(99333),c=s(80662),d=s(68444),x=s(32539),m=s(59656),u=s(58021),p=s(54945),h=s(75319),b=s(80865),f=s(53201),g=s(67389),y=s(90639),j=s(53459);function v({active:e,payload:t,label:s,formatter:a}){return e&&t?.length?(0,r.jsxs)("div",{className:"rounded-lg border border-white/10 bg-surface px-3 py-2 text-xs shadow-lg",children:[s&&(0,r.jsx)("div",{className:"font-semibold text-text-main mb-1",children:s}),t.map((e,t)=>(0,r.jsxs)("div",{className:"flex items-center gap-1.5 text-text-muted",children:[(0,r.jsx)("span",{className:"w-2 h-2 rounded-full shrink-0",style:{backgroundColor:e.color}}),(0,r.jsxs)("span",{children:[e.name,":"]}),(0,r.jsx)("span",{className:"font-mono font-medium text-text-main",children:a?a(e.value):e.value})]},t))]}):null}function N({active:e,sortOrder:t}){return e?(0,r.jsx)("span",{className:"material-symbols-outlined text-[12px] text-primary",children:"asc"===t?"expand_less":"expand_more"}):(0,r.jsx)("span",{className:"material-symbols-outlined text-[12px] opacity-0 group-hover:opacity-30",children:"unfold_more"})}function k({icon:e,label:t,value:s,subValue:a,color:n="text-text-main"}){return(0,r.jsxs)(l.default,{className:"px-4 py-3 flex flex-col gap-1",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2 text-text-muted text-xs uppercase font-semibold tracking-wider",children:[(0,r.jsx)("span",{className:"material-symbols-outlined text-[16px]",children:e}),t]}),(0,r.jsx)("span",{className:`text-2xl font-bold ${n}`,children:s}),a&&(0,r.jsx)("span",{className:"text-xs text-text-muted",children:a})]})}function w({activityMap:e}){let t=(0,a.useMemo)(()=>{let t=new Date,s=[],r=0;for(let a=364;a>=0;a--){let l=new Date(t);l.setDate(l.getDate()-a);let n=`${l.getFullYear()}-${String(l.getMonth()+1).padStart(2,"0")}-${String(l.getDate()).padStart(2,"0")}`,i=e?.[n]||0;i>r&&(r=i),s.push({date:n,value:i,dayOfWeek:l.getDay()})}return{days:s,maxVal:r}},[e]),s=(0,a.useMemo)(()=>{let e=[],s=[],r=t.days[0]?.dayOfWeek||0;for(let e=0;e<r;e++)s.push(null);for(let r of t.days)s.push(r),7===s.length&&(e.push(s),s=[]);return s.length>0&&e.push(s),e},[t]),n=(0,a.useMemo)(()=>{let e=[],t=-1;return s.forEach((s,r)=>{let a=s.find(e=>null!==e);if(a){let s=new Date(a.date).getMonth();s!==t&&(e.push({weekIdx:r,label:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"][s]}),t=s)}}),e},[s]);return(0,r.jsxs)(l.default,{className:"p-4 h-full",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between mb-3",children:[(0,r.jsx)("h3",{className:"text-sm font-semibold text-text-muted uppercase tracking-wider",children:"Activity"}),(0,r.jsxs)("span",{className:"text-xs text-text-muted",children:[Object.keys(e||{}).length," active days \xb7"," ",(0,i.VK)(Object.values(e||{}).reduce((e,t)=>e+t,0))," tokens \xb7 365 days"]})]}),(0,r.jsx)("div",{className:"flex gap-[3px] mb-1 ml-6",style:{fontSize:"10px"},children:n.map((e,t)=>(0,r.jsx)("span",{className:"text-text-muted",style:{position:"relative",left:`${13*e.weekIdx}px`,marginLeft:0===t?0:"-20px"},children:e.label},t))}),(0,r.jsxs)("div",{className:"flex gap-[3px] overflow-x-auto",children:[(0,r.jsxs)("div",{className:"flex flex-col gap-[3px] shrink-0 text-[10px] text-text-muted pr-1",children:[(0,r.jsx)("span",{className:"h-[10px]"}),(0,r.jsx)("span",{className:"h-[10px] leading-[10px]",children:"Mon"}),(0,r.jsx)("span",{className:"h-[10px]"}),(0,r.jsx)("span",{className:"h-[10px] leading-[10px]",children:"Wed"}),(0,r.jsx)("span",{className:"h-[10px]"}),(0,r.jsx)("span",{className:"h-[10px] leading-[10px]",children:"Fri"}),(0,r.jsx)("span",{className:"h-[10px]"})]}),s.map((e,s)=>(0,r.jsx)("div",{className:"flex flex-col gap-[3px]",children:e.map((e,s)=>(0,r.jsx)("div",{title:e?`${e.date}: ${(0,i.xW)(e.value)} tokens`:"",className:`w-[10px] h-[10px] rounded-[2px] ${e?function(e){if(!e||0===e)return"bg-white/[0.04]";let s=Math.min(e/(t.maxVal||1),1);return s<.25?"bg-primary/20":s<.5?"bg-primary/40":s<.75?"bg-primary/60":"bg-primary/90"}(e.value):"bg-transparent"}`},s))},s))]}),(0,r.jsxs)("div",{className:"flex items-center gap-1 mt-2 ml-6 text-[10px] text-text-muted",children:[(0,r.jsx)("span",{children:"Less"}),(0,r.jsx)("div",{className:"w-[10px] h-[10px] rounded-[2px] bg-white/[0.04]"}),(0,r.jsx)("div",{className:"w-[10px] h-[10px] rounded-[2px] bg-primary/20"}),(0,r.jsx)("div",{className:"w-[10px] h-[10px] rounded-[2px] bg-primary/40"}),(0,r.jsx)("div",{className:"w-[10px] h-[10px] rounded-[2px] bg-primary/60"}),(0,r.jsx)("div",{className:"w-[10px] h-[10px] rounded-[2px] bg-primary/90"}),(0,r.jsx)("span",{children:"More"})]})]})}function C({dailyTrend:e}){let t=(0,a.useMemo)(()=>(e||[]).map(e=>({date:e.date.slice(5),Input:e.promptTokens,Output:e.completionTokens,Cost:e.cost||0})),[e]),s=(0,a.useMemo)(()=>t.some(e=>e.Cost>0),[t]);return t.length?(0,r.jsxs)(l.default,{className:"p-4 flex-1",children:[(0,r.jsx)("h3",{className:"text-sm font-semibold text-text-muted uppercase tracking-wider mb-3",children:"Token & Cost Trend"}),(0,r.jsx)(c.u,{width:"100%",height:140,children:(0,r.jsxs)(d.X,{data:t,margin:{top:0,right:40*!!s,left:0,bottom:0},children:[(0,r.jsx)(x.W,{dataKey:"date",tick:{fontSize:9,fill:"var(--text-muted)"},axisLine:!1,tickLine:!1,interval:Math.max(Math.floor(t.length/6),0)}),s&&(0,r.jsx)(m.h,{yAxisId:"cost",orientation:"right",tick:{fontSize:8,fill:"#f59e0b"},axisLine:!1,tickLine:!1,tickFormatter:e=>`$${e.toFixed(2)}`,width:36}),(0,r.jsx)(u.m,{content:(0,r.jsx)(S,{}),cursor:{fill:"rgba(255,255,255,0.04)"}}),(0,r.jsx)(p.yP,{dataKey:"Input",stackId:"a",fill:"var(--primary)",opacity:.7,radius:[0,0,0,0],animationDuration:600}),(0,r.jsx)(p.yP,{dataKey:"Output",stackId:"a",fill:"#10b981",opacity:.7,radius:[3,3,0,0],animationDuration:600}),s&&(0,r.jsx)(h.N1,{yAxisId:"cost",type:"monotone",dataKey:"Cost",stroke:"#f59e0b",strokeWidth:2,dot:!1,animationDuration:600})]})}),(0,r.jsxs)("div",{className:"flex items-center gap-4 mt-2 text-[10px] text-text-muted",children:[(0,r.jsxs)("span",{className:"flex items-center gap-1",children:[(0,r.jsx)("span",{className:"w-2 h-2 rounded-full bg-primary/70"})," Input"]}),(0,r.jsxs)("span",{className:"flex items-center gap-1",children:[(0,r.jsx)("span",{className:"w-2 h-2 rounded-full bg-emerald-500/70"})," Output"]}),s&&(0,r.jsxs)("span",{className:"flex items-center gap-1",children:[(0,r.jsx)("span",{className:"w-2 h-2 rounded-full bg-amber-500/70"})," Cost ($)"]})]})]}):(0,r.jsxs)(l.default,{className:"p-4",children:[(0,r.jsx)("h3",{className:"text-sm font-semibold text-text-muted uppercase tracking-wider mb-3",children:"Token Trend"}),(0,r.jsx)("div",{className:"text-center text-text-muted text-sm py-8",children:"No data"})]})}function S({active:e,payload:t,label:s}){return e&&t?.length?(0,r.jsxs)("div",{className:"rounded-lg border border-white/10 bg-surface px-3 py-2 text-xs shadow-lg",children:[s&&(0,r.jsx)("div",{className:"font-semibold text-text-main mb-1",children:s}),t.map((e,t)=>(0,r.jsxs)("div",{className:"flex items-center gap-1.5 text-text-muted",children:[(0,r.jsx)("span",{className:"w-2 h-2 rounded-full shrink-0",style:{backgroundColor:e.color}}),(0,r.jsxs)("span",{children:[e.name,":"]}),(0,r.jsx)("span",{className:"font-mono font-medium text-text-main",children:"Cost"===e.name?(0,i.F0)(e.value):(0,i.VK)(e.value)})]},t))]}):null}function T({byAccount:e}){let t=(0,a.useMemo)(()=>e||[],[e]),s=t.length>0,n=(0,a.useMemo)(()=>t.slice(0,8).map((e,t)=>({name:e.account,value:e.totalTokens,fill:(0,o.ng)(t)})),[t]);return s?(0,r.jsxs)(l.default,{className:"p-4 flex-1",children:[(0,r.jsx)("h3",{className:"text-sm font-semibold text-text-muted uppercase tracking-wider mb-3",children:"By Account"}),(0,r.jsxs)("div",{className:"flex items-center gap-4",children:[(0,r.jsx)(c.u,{width:120,height:120,children:(0,r.jsxs)(b.r,{children:[(0,r.jsx)(f.Fq,{data:n,dataKey:"value",nameKey:"name",cx:"50%",cy:"50%",innerRadius:28,outerRadius:55,paddingAngle:1,animationDuration:600,children:n.map((e,t)=>(0,r.jsx)(g.f,{fill:e.fill,stroke:"none"},t))}),(0,r.jsx)(u.m,{content:(0,r.jsx)(v,{formatter:i.VK})})]})}),(0,r.jsx)("div",{className:"flex flex-col gap-1 min-w-0 flex-1",children:n.map((e,t)=>(0,r.jsxs)("div",{className:"flex items-center justify-between gap-2 text-xs",children:[(0,r.jsxs)("div",{className:"flex items-center gap-1.5 min-w-0",children:[(0,r.jsx)("span",{className:"w-2 h-2 rounded-full shrink-0",style:{backgroundColor:e.fill}}),(0,r.jsx)("span",{className:"truncate text-text-main",children:e.name})]}),(0,r.jsx)("span",{className:"font-mono font-medium text-text-muted shrink-0",children:(0,i.VK)(e.value)})]},t))})]})]}):(0,r.jsxs)(l.default,{className:"p-4 flex-1",children:[(0,r.jsx)("h3",{className:"text-sm font-semibold text-text-muted uppercase tracking-wider mb-3",children:"By Account"}),(0,r.jsx)("div",{className:"text-center text-text-muted text-sm py-8",children:"No data"})]})}function I({byApiKey:e}){let t=(0,a.useMemo)(()=>e||[],[e]),s=t.length>0,n=(0,a.useMemo)(()=>t.slice(0,8).map((e,t)=>({name:(0,i.VO)(e.apiKeyName,e.apiKeyId),fullName:e.apiKeyName||e.apiKeyId||"unknown",value:e.totalTokens,fill:(0,o.ng)(t)})),[t]);return s?(0,r.jsxs)(l.default,{className:"p-4 flex-1",children:[(0,r.jsx)("h3",{className:"text-sm font-semibold text-text-muted uppercase tracking-wider mb-3",children:"By API Key"}),(0,r.jsxs)("div",{className:"flex items-center gap-4",children:[(0,r.jsx)(c.u,{width:120,height:120,children:(0,r.jsxs)(b.r,{children:[(0,r.jsx)(f.Fq,{data:n,dataKey:"value",nameKey:"name",cx:"50%",cy:"50%",innerRadius:28,outerRadius:55,paddingAngle:1,animationDuration:600,children:n.map((e,t)=>(0,r.jsx)(g.f,{fill:e.fill,stroke:"none"},t))}),(0,r.jsx)(u.m,{content:(0,r.jsx)(v,{formatter:i.VK})})]})}),(0,r.jsx)("div",{className:"flex flex-col gap-1 min-w-0 flex-1",children:n.map((e,t)=>(0,r.jsxs)("div",{className:"flex items-center justify-between gap-2 text-xs",children:[(0,r.jsxs)("div",{className:"flex items-center gap-1.5 min-w-0",children:[(0,r.jsx)("span",{className:"w-2 h-2 rounded-full shrink-0",style:{backgroundColor:e.fill}}),(0,r.jsx)("span",{className:"truncate text-text-main",title:e.fullName,children:e.name})]}),(0,r.jsx)("span",{className:"font-mono font-medium text-text-muted shrink-0",children:(0,i.VK)(e.value)})]},`${e.fullName}-${t}`))})]})]}):(0,r.jsxs)(l.default,{className:"p-4 flex-1",children:[(0,r.jsx)("h3",{className:"text-sm font-semibold text-text-muted uppercase tracking-wider mb-3",children:"By API Key"}),(0,r.jsx)("div",{className:"text-center text-text-muted text-sm py-8",children:"No data"})]})}function O({byApiKey:e}){let[t,s]=(0,a.useState)(""),[n,o]=(0,a.useState)("totalTokens"),[c,d]=(0,a.useState)("desc"),x=(0,a.useMemo)(()=>e||[],[e]),m=(0,a.useMemo)(()=>{let e=t.trim().toLowerCase();return e?x.filter(t=>(t.apiKeyName||"").toLowerCase().includes(e)||(t.apiKeyId||"").toLowerCase().includes(e)):x},[x,t]),u=(0,a.useMemo)(()=>{let e=[...m];return e.sort((e,t)=>{let s=e[n]??0,r=t[n]??0;return"string"==typeof s?"asc"===c?s.localeCompare(r):r.localeCompare(s):"asc"===c?s-r:r-s}),e},[m,n,c]),p=(0,a.useCallback)(e=>{n===e?d(e=>"asc"===e?"desc":"asc"):(o(e),d("desc"))},[n]);return x.length>0?(0,r.jsxs)(l.default,{className:"overflow-hidden",children:[(0,r.jsxs)("div",{className:"p-4 border-b border-border flex items-center justify-between gap-3",children:[(0,r.jsx)("h3",{className:"text-sm font-semibold text-text-muted uppercase tracking-wider",children:"API Key Breakdown"}),(0,r.jsx)("input",{type:"text",value:t,onChange:e=>s(e.target.value),placeholder:"Filter API key...",className:"w-full max-w-[220px] px-3 py-1.5 rounded-lg bg-bg-subtle border border-border text-xs text-text-primary placeholder:text-text-muted focus:outline-none focus:border-primary"})]}),(0,r.jsx)("div",{className:"overflow-x-auto",children:(0,r.jsxs)("table",{className:"w-full text-sm",children:[(0,r.jsx)("thead",{className:"text-xs text-text-muted uppercase bg-black/[0.02] dark:bg-white/[0.02]",children:(0,r.jsxs)("tr",{children:[(0,r.jsxs)("th",{className:"px-4 py-2.5 text-left cursor-pointer group",onClick:()=>p("apiKeyName"),children:["API Key ",(0,r.jsx)(N,{active:"apiKeyName"===n,sortOrder:c})]}),(0,r.jsxs)("th",{className:"px-4 py-2.5 text-right cursor-pointer group",onClick:()=>p("requests"),children:["Requests ",(0,r.jsx)(N,{active:"requests"===n,sortOrder:c})]}),(0,r.jsxs)("th",{className:"px-4 py-2.5 text-right cursor-pointer group",onClick:()=>p("promptTokens"),children:["Input ",(0,r.jsx)(N,{active:"promptTokens"===n,sortOrder:c})]}),(0,r.jsxs)("th",{className:"px-4 py-2.5 text-right cursor-pointer group",onClick:()=>p("completionTokens"),children:["Output"," ",(0,r.jsx)(N,{active:"completionTokens"===n,sortOrder:c})]}),(0,r.jsxs)("th",{className:"px-4 py-2.5 text-right cursor-pointer group",onClick:()=>p("totalTokens"),children:["Total Tokens"," ",(0,r.jsx)(N,{active:"totalTokens"===n,sortOrder:c})]}),(0,r.jsxs)("th",{className:"px-4 py-2.5 text-right cursor-pointer group",onClick:()=>p("cost"),children:["Cost ",(0,r.jsx)(N,{active:"cost"===n,sortOrder:c})]})]})}),(0,r.jsxs)("tbody",{className:"divide-y divide-border",children:[u.map((e,t)=>(0,r.jsxs)("tr",{className:"hover:bg-black/[0.02] dark:hover:bg-white/[0.02] transition-colors",children:[(0,r.jsx)("td",{className:"px-4 py-2.5",children:(0,r.jsx)("span",{className:"font-medium",title:e.apiKeyName||e.apiKeyId||"unknown",children:(0,i.VO)(e.apiKeyName,e.apiKeyId)})}),(0,r.jsx)("td",{className:"px-4 py-2.5 text-right font-mono text-text-muted",children:(0,i.xW)(e.requests)}),(0,r.jsx)("td",{className:"px-4 py-2.5 text-right font-mono text-primary",children:(0,i.VK)(e.promptTokens)}),(0,r.jsx)("td",{className:"px-4 py-2.5 text-right font-mono text-emerald-500",children:(0,i.VK)(e.completionTokens)}),(0,r.jsx)("td",{className:"px-4 py-2.5 text-right font-mono font-semibold",children:(0,i.VK)(e.totalTokens)}),(0,r.jsx)("td",{className:"px-4 py-2.5 text-right font-mono text-amber-500",children:(0,i.F0)(e.cost)})]},`${e.apiKeyId||e.apiKeyName||"key"}-${t}`)),0===u.length&&(0,r.jsx)("tr",{children:(0,r.jsx)("td",{colSpan:6,className:"px-4 py-8 text-center text-text-muted",children:"No API key matches this filter."})})]})]})})]}):(0,r.jsxs)(l.default,{className:"p-4 flex-1",children:[(0,r.jsx)("h3",{className:"text-sm font-semibold text-text-muted uppercase tracking-wider mb-3",children:"API Key Breakdown"}),(0,r.jsx)("div",{className:"text-center text-text-muted text-sm py-8",children:"No data"})]})}function R({activityMap:e}){let t=(0,a.useMemo)(()=>{if(!e)return null;let t=new Date,s=null,r=0;for(let a=0;a<7;a++){let l=new Date(t);l.setDate(l.getDate()-a);let n=`${l.getFullYear()}-${String(l.getMonth()+1).padStart(2,"0")}-${String(l.getDate()).padStart(2,"0")}`,i=e[n]||0;i>r&&(r=i,s=n)}if(!s||0===r)return null;let a=new Date(s+"T12:00:00");return{weekday:["domingo","segunda","ter\xe7a","quarta","quinta","sexta","s\xe1bado"][a.getDay()],label:`${a.getDate()} de ${["jan","fev","mar","abr","mai","jun","jul","ago","set","out","nov","dez"][a.getMonth()]}`,tokens:r}},[e]);return(0,r.jsxs)(l.default,{className:"p-4 flex flex-col justify-center",style:{flex:1,minHeight:0},children:[(0,r.jsx)("h3",{className:"text-xs font-semibold uppercase tracking-wider mb-2",style:{color:"var(--text-muted)"},children:"Most Active Day"}),t?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("span",{className:"text-xl font-bold capitalize",style:{lineHeight:1.2},children:t.weekday}),(0,r.jsxs)("span",{className:"text-xs mt-1",style:{color:"var(--text-muted)"},children:[t.label," \xb7 ",(0,i.VK)(t.tokens)," tokens"]})]}):(0,r.jsx)("span",{className:"text-xs",style:{color:"var(--text-muted)"},children:"Sem dados nos \xfaltimos 7 dias"})]})}function A({activityMap:e}){let t=(0,a.useMemo)(()=>{if(!e)return[];let t=new Date,s=[],r=0;for(let a=6;a>=0;a--){let l=new Date(t);l.setDate(l.getDate()-a);let n=`${l.getFullYear()}-${String(l.getMonth()+1).padStart(2,"0")}-${String(l.getDate()).padStart(2,"0")}`,i=e[n]||0;i>r&&(r=i);let o=["DOM","SEG","TER","QUA","QUI","SEX","S\xc1B"];s.push({key:n,val:i,label:o[l.getDay()]})}return s.map(e=>({...e,intensity:r>0?e.val/r:0}))},[e]);return(0,r.jsxs)(l.default,{className:"p-4 flex flex-col justify-center",style:{flex:1,minHeight:0},children:[(0,r.jsx)("h3",{className:"text-xs font-semibold uppercase tracking-wider mb-3",style:{color:"var(--text-muted)"},children:"Weekly"}),(0,r.jsx)("div",{style:{display:"flex",alignItems:"flex-end",gap:6,justifyContent:"center"},children:t.map((e,t)=>{var s;return(0,r.jsxs)("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",gap:4},children:[(0,r.jsx)("div",{title:`${e.key}: ${(0,i.xW)(e.val)} tokens`,style:{width:36,height:36,borderRadius:8,...0===(s=e.intensity)?{background:"rgba(255,255,255,0.04)"}:{background:`rgba(229, 77, 94, ${(.15+.75*s).toFixed(2)})`},transition:"all 0.2s",cursor:"default"}}),(0,r.jsx)("span",{style:{fontSize:9,fontWeight:600,color:"var(--text-muted)",letterSpacing:"0.03em"},children:e.label})]},t)})})]})}function E({byModel:e,summary:t}){let[s,n]=(0,a.useState)("totalTokens"),[c,d]=(0,a.useState)("desc"),x=(0,a.useCallback)(e=>{s===e?d(e=>"asc"===e?"desc":"asc"):(n(e),d("desc"))},[s]),m=(0,a.useMemo)(()=>{let t=[...e||[]];return t.sort((e,t)=>{let r=e[s]??0,a=t[s]??0;return"string"==typeof r?"asc"===c?r.localeCompare(a):a.localeCompare(r):"asc"===c?r-a:a-r}),t},[e,s,c]);return(0,r.jsxs)(l.default,{className:"overflow-hidden",children:[(0,r.jsx)("div",{className:"p-4 border-b border-border",children:(0,r.jsx)("h3",{className:"text-sm font-semibold text-text-muted uppercase tracking-wider",children:"Model Breakdown"})}),(0,r.jsx)("div",{className:"overflow-x-auto",children:(0,r.jsxs)("table",{className:"w-full text-sm",children:[(0,r.jsx)("thead",{className:"text-xs text-text-muted uppercase bg-black/[0.02] dark:bg-white/[0.02]",children:(0,r.jsxs)("tr",{children:[(0,r.jsxs)("th",{className:"px-4 py-2.5 text-left cursor-pointer group",onClick:()=>x("model"),children:["Model ",(0,r.jsx)(N,{active:"model"===s,sortOrder:c})]}),(0,r.jsxs)("th",{className:"px-4 py-2.5 text-right cursor-pointer group",onClick:()=>x("requests"),children:["Requests ",(0,r.jsx)(N,{active:"requests"===s,sortOrder:c})]}),(0,r.jsxs)("th",{className:"px-4 py-2.5 text-right cursor-pointer group",onClick:()=>x("promptTokens"),children:["Input ",(0,r.jsx)(N,{active:"promptTokens"===s,sortOrder:c})]}),(0,r.jsxs)("th",{className:"px-4 py-2.5 text-right cursor-pointer group",onClick:()=>x("completionTokens"),children:["Output"," ",(0,r.jsx)(N,{active:"completionTokens"===s,sortOrder:c})]}),(0,r.jsxs)("th",{className:"px-4 py-2.5 text-right cursor-pointer group",onClick:()=>x("totalTokens"),children:["Total ",(0,r.jsx)(N,{active:"totalTokens"===s,sortOrder:c})]}),(0,r.jsxs)("th",{className:"px-4 py-2.5 text-right cursor-pointer group",onClick:()=>x("cost"),children:["Cost ",(0,r.jsx)(N,{active:"cost"===s,sortOrder:c})]}),(0,r.jsx)("th",{className:"px-4 py-2.5 text-right w-36",children:"Share"})]})}),(0,r.jsx)("tbody",{className:"divide-y divide-border",children:m.map((e,t)=>(0,r.jsxs)("tr",{className:"hover:bg-black/[0.02] dark:hover:bg-white/[0.02] transition-colors",children:[(0,r.jsx)("td",{className:"px-4 py-2.5",children:(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("span",{className:"w-2 h-2 rounded-full shrink-0",style:{backgroundColor:(0,o.ng)(t)}}),(0,r.jsx)("span",{className:"font-medium",children:e.model})]})}),(0,r.jsx)("td",{className:"px-4 py-2.5 text-right font-mono text-text-muted",children:(0,i.xW)(e.requests)}),(0,r.jsx)("td",{className:"px-4 py-2.5 text-right font-mono text-primary",children:(0,i.VK)(e.promptTokens)}),(0,r.jsx)("td",{className:"px-4 py-2.5 text-right font-mono text-emerald-500",children:(0,i.VK)(e.completionTokens)}),(0,r.jsx)("td",{className:"px-4 py-2.5 text-right font-mono font-semibold",children:(0,i.VK)(e.totalTokens)}),(0,r.jsx)("td",{className:"px-4 py-2.5 text-right font-mono text-amber-500",children:(0,i.F0)(e.cost)}),(0,r.jsx)("td",{className:"px-4 py-2.5 text-right",children:(0,r.jsxs)("div",{className:"flex items-center gap-2 justify-end",children:[(0,r.jsx)("div",{className:"w-16 h-1.5 rounded-full bg-white/[0.06] overflow-hidden",children:(0,r.jsx)("div",{className:"h-full rounded-full transition-all",style:{width:`${e.pct}%`,backgroundColor:(0,o.ng)(t)}})}),(0,r.jsxs)("span",{className:"text-xs font-mono text-text-muted w-10 text-right",children:[e.pct,"%"]})]})})]},e.model))})]})})]})}let L=["#f59e0b","#ef4444","#8b5cf6","#10b981","#06b6d4","#ec4899","#f97316","#6366f1","#14b8a6","#a855f7"];function M({byProvider:e}){let t=(0,a.useMemo)(()=>e||[],[e]),s=t.length>0&&t.some(e=>e.cost>0),n=(0,a.useMemo)(()=>t.filter(e=>e.cost>0).sort((e,t)=>t.cost-e.cost).slice(0,8).map((e,t)=>({name:e.provider,value:e.cost,fill:L[t%L.length]})),[t]);return s?(0,r.jsxs)(l.default,{className:"p-4 flex-1",children:[(0,r.jsx)("h3",{className:"text-sm font-semibold text-text-muted uppercase tracking-wider mb-3",children:"Cost by Provider"}),(0,r.jsxs)("div",{className:"flex items-center gap-4",children:[(0,r.jsx)(c.u,{width:120,height:120,children:(0,r.jsxs)(b.r,{children:[(0,r.jsx)(f.Fq,{data:n,dataKey:"value",nameKey:"name",cx:"50%",cy:"50%",innerRadius:28,outerRadius:55,paddingAngle:1,animationDuration:600,children:n.map((e,t)=>(0,r.jsx)(g.f,{fill:e.fill,stroke:"none"},t))}),(0,r.jsx)(u.m,{content:(0,r.jsx)(v,{formatter:i.F0})})]})}),(0,r.jsx)("div",{className:"flex flex-col gap-1 min-w-0 flex-1",children:n.map((e,t)=>(0,r.jsxs)("div",{className:"flex items-center justify-between gap-2 text-xs",children:[(0,r.jsxs)("div",{className:"flex items-center gap-1.5 min-w-0",children:[(0,r.jsx)("span",{className:"w-2 h-2 rounded-full shrink-0",style:{backgroundColor:e.fill}}),(0,r.jsx)("span",{className:"truncate text-text-main capitalize",children:e.name})]}),(0,r.jsx)("span",{className:"font-mono font-medium text-amber-500 shrink-0",children:(0,i.F0)(e.value)})]},t))})]})]}):(0,r.jsxs)(l.default,{className:"p-4 flex-1",children:[(0,r.jsx)("h3",{className:"text-sm font-semibold text-text-muted uppercase tracking-wider mb-3",children:"Cost by Provider"}),(0,r.jsx)("div",{className:"text-center text-text-muted text-sm py-8",children:"No cost data"})]})}function $({dailyByModel:e,modelNames:t}){let s=(0,a.useMemo)(()=>e||[],[e]),n=(0,a.useMemo)(()=>t||[],[t]),d=(0,a.useMemo)(()=>s.map(e=>{let t={...e};if(e.date){let s=e.date.split("-");t.dateLabel=`${s[1]}/${s[2]}`}return t}),[s]);return s.length&&n.length?(0,r.jsxs)(l.default,{className:"p-4",children:[(0,r.jsx)("h3",{className:"text-sm font-semibold text-text-muted uppercase tracking-wider mb-3",children:"Model Usage Over Time"}),(0,r.jsx)(c.u,{width:"100%",height:240,children:(0,r.jsxs)(y.Q,{data:d,margin:{top:4,right:4,left:0,bottom:0},children:[(0,r.jsx)(x.W,{dataKey:"dateLabel",tick:{fontSize:10,fill:"var(--text-muted)"},axisLine:!1,tickLine:!1,interval:"preserveStartEnd"}),(0,r.jsx)(m.h,{tick:{fontSize:10,fill:"var(--text-muted)"},tickFormatter:e=>(0,i.VK)(e),axisLine:!1,tickLine:!1,width:50}),(0,r.jsx)(u.m,{content:(0,r.jsx)(v,{formatter:i.VK})}),n.map((e,t)=>(0,r.jsx)(j.Gk,{type:"monotone",dataKey:e,stackId:"1",stroke:(0,o.ng)(t),fill:(0,o.ng)(t),fillOpacity:.4,strokeWidth:1.5,animationDuration:600},e))]})}),(0,r.jsx)("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1 mt-2 text-[10px] text-text-muted",children:n.map((e,t)=>(0,r.jsxs)("span",{className:"flex items-center gap-1",children:[(0,r.jsx)("span",{className:"w-2 h-2 rounded-full shrink-0",style:{backgroundColor:(0,o.ng)(t)}}),e]},e))})]}):(0,r.jsxs)(l.default,{className:"p-4",children:[(0,r.jsx)("h3",{className:"text-sm font-semibold text-text-muted uppercase tracking-wider mb-3",children:"Model Usage Over Time"}),(0,r.jsx)("div",{className:"text-center text-text-muted text-sm py-8",children:"No data"})]})}function _({byProvider:e}){let[t,s]=(0,a.useState)("totalTokens"),[n,o]=(0,a.useState)("desc"),c=(0,a.useMemo)(()=>e||[],[e]),d=(0,a.useMemo)(()=>c.reduce((e,t)=>e+t.totalTokens,0),[c]),x=(0,a.useCallback)(e=>{t===e?o(e=>"asc"===e?"desc":"asc"):(s(e),o("desc"))},[t]),m=(0,a.useMemo)(()=>{let e=[...c];return e.sort((e,s)=>{let r=e[t]??0,a=s[t]??0;return"string"==typeof r?"asc"===n?r.localeCompare(a):a.localeCompare(r):"asc"===n?r-a:a-r}),e},[c,t,n]);return c.length?(0,r.jsxs)(l.default,{className:"overflow-hidden",children:[(0,r.jsx)("div",{className:"p-4 border-b border-border",children:(0,r.jsx)("h3",{className:"text-sm font-semibold text-text-muted uppercase tracking-wider",children:"Provider Breakdown"})}),(0,r.jsx)("div",{className:"overflow-x-auto",children:(0,r.jsxs)("table",{className:"w-full text-sm",children:[(0,r.jsx)("thead",{className:"text-xs text-text-muted uppercase bg-black/[0.02] dark:bg-white/[0.02]",children:(0,r.jsxs)("tr",{children:[(0,r.jsxs)("th",{className:"px-4 py-2.5 text-left cursor-pointer group",onClick:()=>x("provider"),children:["Provider ",(0,r.jsx)(N,{active:"provider"===t,sortOrder:n})]}),(0,r.jsxs)("th",{className:"px-4 py-2.5 text-right cursor-pointer group",onClick:()=>x("requests"),children:["Requests ",(0,r.jsx)(N,{active:"requests"===t,sortOrder:n})]}),(0,r.jsxs)("th",{className:"px-4 py-2.5 text-right cursor-pointer group",onClick:()=>x("promptTokens"),children:["Input ",(0,r.jsx)(N,{active:"promptTokens"===t,sortOrder:n})]}),(0,r.jsxs)("th",{className:"px-4 py-2.5 text-right cursor-pointer group",onClick:()=>x("completionTokens"),children:["Output"," ",(0,r.jsx)(N,{active:"completionTokens"===t,sortOrder:n})]}),(0,r.jsxs)("th",{className:"px-4 py-2.5 text-right cursor-pointer group",onClick:()=>x("totalTokens"),children:["Total ",(0,r.jsx)(N,{active:"totalTokens"===t,sortOrder:n})]}),(0,r.jsxs)("th",{className:"px-4 py-2.5 text-right cursor-pointer group",onClick:()=>x("cost"),children:["Cost ",(0,r.jsx)(N,{active:"cost"===t,sortOrder:n})]}),(0,r.jsx)("th",{className:"px-4 py-2.5 text-right w-36",children:"Share"})]})}),(0,r.jsx)("tbody",{className:"divide-y divide-border",children:m.map((e,t)=>{let s=d>0?(e.totalTokens/d*100).toFixed(1):"0";return(0,r.jsxs)("tr",{className:"hover:bg-black/[0.02] dark:hover:bg-white/[0.02] transition-colors",children:[(0,r.jsx)("td",{className:"px-4 py-2.5",children:(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("span",{className:"w-2 h-2 rounded-full shrink-0",style:{backgroundColor:L[t%L.length]}}),(0,r.jsx)("span",{className:"font-medium capitalize",children:e.provider})]})}),(0,r.jsx)("td",{className:"px-4 py-2.5 text-right font-mono text-text-muted",children:(0,i.xW)(e.requests)}),(0,r.jsx)("td",{className:"px-4 py-2.5 text-right font-mono text-primary",children:(0,i.VK)(e.promptTokens)}),(0,r.jsx)("td",{className:"px-4 py-2.5 text-right font-mono text-emerald-500",children:(0,i.VK)(e.completionTokens)}),(0,r.jsx)("td",{className:"px-4 py-2.5 text-right font-mono font-semibold",children:(0,i.VK)(e.totalTokens)}),(0,r.jsx)("td",{className:"px-4 py-2.5 text-right font-mono text-amber-500",children:(0,i.F0)(e.cost)}),(0,r.jsx)("td",{className:"px-4 py-2.5 text-right",children:(0,r.jsxs)("div",{className:"flex items-center gap-2 justify-end",children:[(0,r.jsx)("div",{className:"w-16 h-1.5 rounded-full bg-white/[0.06] overflow-hidden",children:(0,r.jsx)("div",{className:"h-full rounded-full transition-all",style:{width:`${s}%`,backgroundColor:L[t%L.length]}})}),(0,r.jsxs)("span",{className:"text-xs font-mono text-text-muted w-10 text-right",children:[s,"%"]})]})})]},e.provider)})})]})})]}):(0,r.jsxs)(l.default,{className:"p-4",children:[(0,r.jsx)("h3",{className:"text-sm font-semibold text-text-muted uppercase tracking-wider mb-3",children:"Provider Breakdown"}),(0,r.jsx)("div",{className:"text-center text-text-muted text-sm py-8",children:"No data"})]})}function D(){let[e,t]=(0,a.useState)("30d"),[s,o]=(0,a.useState)(null),[c,d]=(0,a.useState)(!0),[x,m]=(0,a.useState)(null),u=(0,a.useCallback)(async()=>{try{d(!0);let t=await fetch(`/api/usage/analytics?range=${e}`);if(!t.ok)throw Error("Failed to fetch");let s=await t.json();o(s),m(null)}catch(e){m(e.message)}finally{d(!1)}},[e]);(0,a.useEffect)(()=>{u()},[u]);let p=(0,a.useMemo)(()=>{let e=s?.byModel||[];return e.length>0?e[0].model:"—"},[s]),h=(0,a.useMemo)(()=>{let e=s?.byProvider||[];return e.length>0?e[0].provider:"—"},[s]),b=(0,a.useMemo)(()=>{let e=s?.weeklyPattern||[];if(!e.length)return"—";let t=e.reduce((e,t)=>e.avgTokens>t.avgTokens?e:t,e[0]);return t.avgTokens>0?t.day:"—"},[s]),f=(0,a.useMemo)(()=>(s?.byProvider||[]).length,[s]);if(c&&!s)return(0,r.jsx)(n.CardSkeleton,{});if(x)return(0,r.jsxs)(l.default,{className:"p-6 text-center text-red-500",children:["Error: ",x]});let g=s?.summary||{},y=g.totalRequests>0?Math.round(g.totalTokens/g.totalRequests):0,j=g.totalRequests>0?g.totalCost/g.totalRequests:0,v=g.completionTokens>0?(g.promptTokens/g.completionTokens).toFixed(1):"—";return(0,r.jsxs)("div",{className:"flex flex-col gap-5",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between",children:[(0,r.jsxs)("h2",{className:"text-xl font-semibold flex items-center gap-2",children:[(0,r.jsx)("span",{className:"material-symbols-outlined text-primary text-[22px]",children:"analytics"}),"Usage Analytics"]}),(0,r.jsx)("div",{className:"flex items-center gap-1 bg-black/[0.03] dark:bg-white/[0.03] rounded-lg p-1 border border-black/5 dark:border-white/5",children:[{value:"1d",label:"1D"},{value:"7d",label:"7D"},{value:"30d",label:"30D"},{value:"90d",label:"90D"},{value:"ytd",label:"YTD"},{value:"all",label:"All"}].map(s=>(0,r.jsx)("button",{onClick:()=>t(s.value),className:`px-3 py-1 rounded-md text-xs font-semibold transition-all ${e===s.value?"bg-primary text-white shadow-sm":"text-text-muted hover:text-text-main hover:bg-black/5 dark:hover:bg-white/5"}`,children:s.label},s.value))})]}),(0,r.jsxs)("div",{className:"grid grid-cols-2 md:grid-cols-7 gap-3",children:[(0,r.jsx)(k,{icon:"generating_tokens",label:"Total Tokens",value:(0,i.VK)(g.totalTokens),subValue:`${(0,i.xW)(g.totalRequests)} requests`}),(0,r.jsx)(k,{icon:"input",label:"Input Tokens",value:(0,i.VK)(g.promptTokens),color:"text-primary"}),(0,r.jsx)(k,{icon:"output",label:"Output Tokens",value:(0,i.VK)(g.completionTokens),color:"text-emerald-500"}),(0,r.jsx)(k,{icon:"payments",label:"Est. Cost",value:(0,i.F0)(g.totalCost),color:"text-amber-500"}),(0,r.jsx)(k,{icon:"group",label:"Accounts",value:g.uniqueAccounts||0}),(0,r.jsx)(k,{icon:"vpn_key",label:"API Keys",value:g.uniqueApiKeys||0}),(0,r.jsx)(k,{icon:"model_training",label:"Models",value:g.uniqueModels||0})]}),(0,r.jsxs)("div",{className:"grid grid-cols-2 md:grid-cols-7 gap-3",children:[(0,r.jsx)(k,{icon:"speed",label:"Avg Tokens/Req",value:(0,i.VK)(y),color:"text-cyan-500"}),(0,r.jsx)(k,{icon:"request_quote",label:"Cost/Request",value:(0,i.F0)(j),color:"text-orange-500"}),(0,r.jsx)(k,{icon:"compare_arrows",label:"I/O Ratio",value:`${v}x`,color:"text-violet-500"}),(0,r.jsx)(k,{icon:"star",label:"Top Model",value:p,color:"text-pink-500"}),(0,r.jsx)(k,{icon:"cloud",label:"Top Provider",value:h,color:"text-teal-500"}),(0,r.jsx)(k,{icon:"today",label:"Busiest Day",value:b,color:"text-rose-500"}),(0,r.jsx)(k,{icon:"dns",label:"Providers",value:f,color:"text-indigo-500"})]}),(0,r.jsxs)("div",{style:{display:"grid",gridTemplateColumns:"2fr 1fr",gap:16,alignItems:"stretch"},children:[(0,r.jsx)(w,{activityMap:s?.activityMap}),(0,r.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:16},children:[(0,r.jsx)(R,{activityMap:s?.activityMap}),(0,r.jsx)(A,{activityMap:s?.activityMap})]})]}),(0,r.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[(0,r.jsx)(C,{dailyTrend:s?.dailyTrend}),(0,r.jsx)(M,{byProvider:s?.byProvider})]}),(0,r.jsx)($,{dailyByModel:s?.dailyByModel,modelNames:s?.modelNames}),(0,r.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[(0,r.jsx)(T,{byAccount:s?.byAccount}),(0,r.jsx)(I,{byApiKey:s?.byApiKey})]}),(0,r.jsx)(_,{byProvider:s?.byProvider}),(0,r.jsx)(O,{byApiKey:s?.byApiKey}),(0,r.jsx)(E,{byModel:s?.byModel,summary:g})]})}},48643:(e,t,s)=>{s.d(t,{default:()=>x});var r=s(95155),a=s(12115),l=s(14051),n=s.n(l),i=s(71361),o=s(35806);let c=[{value:"http",label:"HTTP"},{value:"https",label:"HTTPS"},{value:"socks5",label:"SOCKS5"}],d={global:"Global",provider:"Provider",combo:"Combo",key:"Key",direct:"Direct (none)"};function x({isOpen:e,onClose:t,level:s,levelId:l,levelLabel:n,onSaved:x}){let[m,u]=(0,a.useState)(c[0]?.value||"http"),[p,h]=(0,a.useState)(""),[b,f]=(0,a.useState)(""),[g,y]=(0,a.useState)(""),[j,v]=(0,a.useState)(""),[N,k]=(0,a.useState)(!1),[w,C]=(0,a.useState)(!1),[S,T]=(0,a.useState)(!1),[I,O]=(0,a.useState)(null),[R,A]=(0,a.useState)(!0),[E,L]=(0,a.useState)(null),[M,$]=(0,a.useState)(!1),[_,D]=(0,a.useState)(null),P=e=>"socks5"===e?"1080":"https"===e?"443":"8080";(0,a.useEffect)(()=>{e&&(O(null),D(null),A(!0),(async()=>{try{let e=new URLSearchParams({level:s});l&&e.set("id",l);let t=await fetch(`/api/settings/proxy?${e}`);if(t.ok){let e=(await t.json()).proxy;if(e&&e.host){let t=String(e.type||"http").toLowerCase(),s=c.some(e=>e.value===t);u(s?t:c[0]?.value||"http"),h(e.host||""),f(e.port||""),y(e.username||""),v(e.password||""),k(!!(e.username||e.password)),$(!0)}else F(),$(!1)}if("global"!==s&&l){let e=await fetch("/api/settings/proxy");if(e.ok){let t=await e.json();"key"===s||"combo"===s?t.global&&L({level:"Global",proxy:t.global}):"provider"===s&&t.global&&L({level:"Global",proxy:t.global})}}}catch(e){console.error("Error loading proxy config:",e)}finally{A(!1)}})())},[e,s,l]);let F=()=>{u(c[0]?.value||"http"),h(""),f(""),y(""),v(""),k(!1),D(null)},z=async()=>{if(p.trim()){D(null),C(!0);try{let e={type:m,host:p.trim(),port:b.trim()||P(m),username:g.trim(),password:j.trim()},t=await fetch("/api/settings/proxy",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({level:s,id:l,proxy:e})}),r=await t.json().catch(()=>({}));if(!t.ok)return void D(r?.error?.message||"Failed to save proxy configuration");$(!0),x?.()}catch(e){console.error("Error saving proxy:",e),D(e.message||"Failed to save proxy configuration")}finally{C(!1)}}},K=async()=>{D(null),C(!0);try{let e=new URLSearchParams({level:s});l&&e.set("id",l);let t=await fetch(`/api/settings/proxy?${e}`,{method:"DELETE"}),r=await t.json().catch(()=>({}));if(!t.ok)return void D(r?.error?.message||"Failed to clear proxy configuration");F(),$(!1),O(null),x?.()}catch(e){console.error("Error clearing proxy:",e),D(e.message||"Failed to clear proxy configuration")}finally{C(!1)}},U=async()=>{if(p.trim()){D(null),T(!0),O(null);try{let e={type:m,host:p.trim(),port:b.trim()||P(m),username:g.trim(),password:j.trim()},t=await fetch("/api/settings/proxy/test",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({proxy:e})}),s=await t.json().catch(()=>({}));if(!t.ok){let e=s?.error?.message||"Connection failed";O({success:!1,error:e}),D(e);return}O(s)}catch(e){O({success:!1,error:e.message}),D(e.message||"Connection failed")}finally{T(!1)}}},q="global"===s?"Global Proxy Configuration":`${d[s]} Proxy — ${n||l||""}`;return(0,r.jsx)(i.default,{isOpen:e,onClose:t,title:q,maxWidth:"lg",children:R?(0,r.jsx)("div",{className:"py-8 text-center text-text-muted animate-pulse",children:"Loading proxy configuration..."}):(0,r.jsxs)("div",{className:"flex flex-col gap-5",children:["global"!==s&&!M&&E&&(0,r.jsxs)("div",{className:"flex items-center gap-2 px-3 py-2 rounded-lg bg-blue-500/10 border border-blue-500/20 text-sm",children:[(0,r.jsx)("span",{className:"material-symbols-outlined text-blue-400 text-base",children:"subdirectory_arrow_right"}),(0,r.jsxs)("span",{className:"text-blue-300",children:["Inheriting from ",(0,r.jsx)("strong",{children:E.level}),": ",E.proxy?.type,"://",E.proxy?.host,":",E.proxy?.port]})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:"text-xs text-text-muted mb-1.5 block uppercase tracking-wider font-medium",children:"Proxy Type"}),(0,r.jsx)("div",{className:"flex gap-1 bg-bg-subtle rounded-lg p-1 border border-border",children:c.map(e=>(0,r.jsx)("button",{onClick:()=>u(e.value),className:`flex-1 px-4 py-2 rounded-md text-sm font-medium transition-all ${m===e.value?"bg-primary text-white shadow-sm":"text-text-muted hover:text-text-primary hover:bg-black/5 dark:hover:bg-white/5"}`,children:e.label},e.value))})]}),(0,r.jsxs)("div",{className:"grid grid-cols-3 gap-3",children:[(0,r.jsxs)("div",{className:"col-span-2",children:[(0,r.jsx)("label",{className:"text-xs text-text-muted mb-1.5 block uppercase tracking-wider font-medium",children:"Host"}),(0,r.jsx)("input",{type:"text",value:p,onChange:e=>h(e.target.value),placeholder:"1.2.3.4 or proxy.example.com",className:"w-full px-3 py-2.5 rounded-lg bg-bg-subtle border border-border text-sm text-text-primary placeholder:text-text-muted/50 focus:outline-none focus:border-primary transition-colors"})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:"text-xs text-text-muted mb-1.5 block uppercase tracking-wider font-medium",children:"Port"}),(0,r.jsx)("input",{type:"text",value:b,onChange:e=>f(e.target.value),placeholder:P(m),className:"w-full px-3 py-2.5 rounded-lg bg-bg-subtle border border-border text-sm text-text-primary placeholder:text-text-muted/50 focus:outline-none focus:border-primary transition-colors"})]})]}),(0,r.jsxs)("div",{children:[(0,r.jsxs)("button",{onClick:()=>k(!N),className:"flex items-center gap-2 text-sm text-text-muted hover:text-text-primary transition-colors",children:[(0,r.jsx)("span",{className:"material-symbols-outlined text-base",children:N?"expand_less":"expand_more"}),"Authentication (optional)"]}),N&&(0,r.jsxs)("div",{className:"grid grid-cols-2 gap-3 mt-3",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:"text-xs text-text-muted mb-1.5 block uppercase tracking-wider font-medium",children:"Username"}),(0,r.jsx)("input",{type:"text",value:g,onChange:e=>y(e.target.value),placeholder:"Username",className:"w-full px-3 py-2.5 rounded-lg bg-bg-subtle border border-border text-sm text-text-primary placeholder:text-text-muted/50 focus:outline-none focus:border-primary transition-colors"})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:"text-xs text-text-muted mb-1.5 block uppercase tracking-wider font-medium",children:"Password"}),(0,r.jsx)("input",{type:"password",value:j,onChange:e=>v(e.target.value),placeholder:"Password",className:"w-full px-3 py-2.5 rounded-lg bg-bg-subtle border border-border text-sm text-text-primary placeholder:text-text-muted/50 focus:outline-none focus:border-primary transition-colors"})]})]})]}),_&&(0,r.jsx)("div",{className:"px-4 py-3 rounded-lg border border-red-500/30 bg-red-500/10 text-sm text-red-400",children:_}),I&&(0,r.jsxs)("div",{className:`flex items-center gap-3 px-4 py-3 rounded-lg border ${I.success?"bg-emerald-500/10 border-emerald-500/30":"bg-red-500/10 border-red-500/30"}`,children:[(0,r.jsx)("span",{className:`material-symbols-outlined text-xl ${I.success?"text-emerald-400":"text-red-400"}`,children:I.success?"check_circle":"error"}),(0,r.jsx)("div",{className:"flex-1",children:I.success?(0,r.jsxs)("div",{children:[(0,r.jsx)("span",{className:"text-sm font-medium text-emerald-400",children:"Connected"}),(0,r.jsxs)("span",{className:"text-text-muted text-xs ml-2",children:["IP: ",(0,r.jsx)("span",{className:"font-mono text-emerald-300",children:I.publicIp}),I.latencyMs&&` \xb7 ${I.latencyMs}ms`]})]}):(0,r.jsxs)("div",{className:"text-sm text-red-400",children:[I.error||"Connection failed",I.latencyMs&&(0,r.jsxs)("span",{className:"text-text-muted text-xs ml-2",children:["(",I.latencyMs,"ms)"]})]})})]}),(0,r.jsxs)("div",{className:"flex items-center justify-between pt-2 border-t border-border",children:[(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsx)(o.default,{size:"sm",variant:"secondary",icon:"speed",onClick:U,loading:S,disabled:!p.trim(),children:"Test Connection"}),M&&(0,r.jsx)(o.default,{size:"sm",variant:"ghost",icon:"delete",onClick:K,disabled:w,className:"!text-red-400 hover:!bg-red-500/10",children:"Clear"})]}),(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsx)(o.default,{size:"sm",variant:"secondary",onClick:t,children:"Cancel"}),(0,r.jsx)(o.default,{size:"sm",icon:"save",onClick:z,loading:w,disabled:!p.trim(),children:"Save"})]})]})]})})}x.propTypes={isOpen:n().bool.isRequired,onClose:n().func.isRequired,level:n().oneOf(["global","provider","combo","key"]).isRequired,levelId:n().string,levelLabel:n().string,onSaved:n().func}},51503:(e,t,s)=>{s.d(t,{default:()=>l});var r=s(95155),a=s(12115);function l({searchValue:e="",onSearchChange:t,placeholder:s="Search...",filters:l=[],activeFilters:n={},onFilterChange:i,children:o}){let[c,d]=(0,a.useState)(null),x=(0,a.useCallback)(()=>{t(""),l.forEach(e=>i(e.key,"")),d(null)},[t,l,i]),m=e||Object.values(n).some(e=>e&&""!==e);return(0,r.jsxs)("div",{style:{display:"flex",flexWrap:"wrap",gap:"8px",alignItems:"center",padding:"8px 0"},children:[(0,r.jsxs)("div",{style:{position:"relative",flex:"1 1 200px",minWidth:"200px"},children:[(0,r.jsx)("input",{type:"text",value:e,onChange:e=>t(e.target.value),placeholder:s,style:{width:"100%",padding:"8px 12px 8px 32px",borderRadius:"6px",border:"1px solid rgba(255,255,255,0.1)",background:"rgba(255,255,255,0.05)",color:"var(--text-primary, #e0e0e0)",fontSize:"13px",outline:"none"}}),(0,r.jsx)("span",{style:{position:"absolute",left:"10px",top:"50%",transform:"translateY(-50%)",opacity:.4,fontSize:"14px",pointerEvents:"none"},children:"\uD83D\uDD0D"})]}),l.map(e=>(0,r.jsxs)("div",{style:{position:"relative"},children:[(0,r.jsxs)("button",{onClick:()=>d(c===e.key?null:e.key),style:{padding:"6px 12px",borderRadius:"6px",border:`1px solid ${n[e.key]?"rgba(99,102,241,0.5)":"rgba(255,255,255,0.1)"}`,background:n[e.key]?"rgba(99,102,241,0.15)":"rgba(255,255,255,0.05)",color:n[e.key]?"#818cf8":"var(--text-secondary, #888)",fontSize:"12px",cursor:"pointer",whiteSpace:"nowrap"},children:[e.label,n[e.key]?` \xb7 ${n[e.key]}`:""]}),c===e.key&&(0,r.jsxs)("div",{style:{position:"absolute",top:"100%",left:0,marginTop:"4px",background:"rgba(20,20,30,0.95)",border:"1px solid rgba(255,255,255,0.1)",borderRadius:"8px",padding:"4px",zIndex:50,minWidth:"120px",backdropFilter:"blur(12px)"},children:[(0,r.jsx)("button",{onClick:()=>{i(e.key,""),d(null)},style:{display:"block",width:"100%",padding:"6px 12px",textAlign:"left",background:"none",border:"none",color:"#888",fontSize:"12px",cursor:"pointer",borderRadius:"4px"},children:"All"}),(e.options||[]).map(t=>(0,r.jsx)("button",{onClick:()=>{i(e.key,t),d(null)},style:{display:"block",width:"100%",padding:"6px 12px",textAlign:"left",background:n[e.key]===t?"rgba(99,102,241,0.2)":"none",border:"none",color:n[e.key]===t?"#818cf8":"var(--text-primary, #e0e0e0)",fontSize:"12px",cursor:"pointer",borderRadius:"4px"},children:t},t))]})]},e.key)),m&&(0,r.jsx)("button",{onClick:x,style:{padding:"6px 12px",borderRadius:"6px",border:"1px solid rgba(239,68,68,0.3)",background:"rgba(239,68,68,0.1)",color:"#ef4444",fontSize:"12px",cursor:"pointer"},children:"Clear"}),o]})}},54128:(e,t,s)=>{s.d(t,{default:()=>l});var r=s(95155),a=s(12115);function l({columns:e=[],visible:t={},onToggle:s}){let[l,n]=(0,a.useState)(!1),i=(0,a.useRef)(null);return(0,a.useEffect)(()=>{if(!l)return;let e=e=>{i.current&&!i.current.contains(e.target)&&n(!1)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[l]),(0,r.jsxs)("div",{ref:i,style:{position:"relative"},children:[(0,r.jsxs)("button",{onClick:()=>n(!l),title:"Toggle columns",style:{padding:"6px 10px",borderRadius:"6px",border:"1px solid rgba(255,255,255,0.1)",background:"rgba(255,255,255,0.05)",color:"var(--text-secondary, #888)",fontSize:"13px",cursor:"pointer",display:"flex",alignItems:"center",gap:"4px"},children:[(0,r.jsx)("span",{style:{fontSize:"14px"},children:"⚙️"}),"Columns"]}),l&&(0,r.jsx)("div",{style:{position:"absolute",top:"100%",right:0,marginTop:"4px",background:"rgba(20,20,30,0.95)",border:"1px solid rgba(255,255,255,0.1)",borderRadius:"8px",padding:"8px",zIndex:50,minWidth:"160px",backdropFilter:"blur(12px)"},children:e.map(e=>(0,r.jsxs)("label",{style:{display:"flex",alignItems:"center",gap:"8px",padding:"4px 8px",cursor:"pointer",fontSize:"12px",color:t[e.key]?"var(--text-primary, #e0e0e0)":"var(--text-secondary, #888)",borderRadius:"4px"},children:[(0,r.jsx)("input",{type:"checkbox",checked:t[e.key]??!0,onChange:()=>s(e.key),style:{accentColor:"#6366f1"}}),e.label]},e.key))})]})}},61580:(e,t,s)=>{s.d(t,{default:()=>c});var r=s(95155),a=s(67671),l=s(12115);let n={success:"✓",error:"✕",warning:"⚠",info:"ℹ"},i={success:{bg:"rgba(16, 185, 129, 0.15)",border:"rgba(16, 185, 129, 0.4)",icon:"#10b981"},error:{bg:"rgba(239, 68, 68, 0.15)",border:"rgba(239, 68, 68, 0.4)",icon:"#ef4444"},warning:{bg:"rgba(245, 158, 11, 0.15)",border:"rgba(245, 158, 11, 0.4)",icon:"#f59e0b"},info:{bg:"rgba(59, 130, 246, 0.15)",border:"rgba(59, 130, 246, 0.4)",icon:"#3b82f6"}};function o({notification:e,onDismiss:t}){let[s,a]=(0,l.useState)(!1),o=i[e.type]||i.info;return(0,r.jsxs)("div",{role:"alert","aria-live":"polite",style:{display:"flex",alignItems:"flex-start",gap:"12px",padding:"14px 16px",borderRadius:"10px",backgroundColor:o.bg,border:`1px solid ${o.border}`,backdropFilter:"blur(12px)",boxShadow:"0 8px 32px rgba(0,0,0,0.2)",minWidth:"320px",maxWidth:"420px",animation:s?"toastOut 0.2s ease-in forwards":"toastIn 0.3s ease-out forwards",transition:"all 0.2s ease"},children:[(0,r.jsx)("span",{style:{fontSize:"18px",color:o.icon,fontWeight:"bold",lineHeight:1,marginTop:"2px"},children:n[e.type]}),(0,r.jsxs)("div",{style:{flex:1,minWidth:0},children:[e.title&&(0,r.jsx)("div",{style:{fontWeight:600,fontSize:"14px",color:"var(--text-primary, #fff)",marginBottom:"2px"},children:e.title}),(0,r.jsx)("div",{style:{fontSize:"13px",color:"var(--text-secondary, #ccc)",lineHeight:1.4},children:e.message})]}),e.dismissible&&(0,r.jsx)("button",{onClick:()=>{a(!0),setTimeout(()=>t(e.id),200)},"aria-label":"Dismiss notification",style:{background:"none",border:"none",cursor:"pointer",color:"var(--text-secondary, #999)",fontSize:"16px",padding:"0 2px",lineHeight:1,opacity:.6,transition:"opacity 0.15s"},onMouseEnter:e=>e.currentTarget.style.opacity="1",onMouseLeave:e=>e.currentTarget.style.opacity="0.6",children:"\xd7"})]})}function c(){let{notifications:e,removeNotification:t}=(0,a.i)();return 0===e.length?null:(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("style",{children:`
|
|
2
2
|
@keyframes toastIn {
|
|
3
3
|
from { opacity: 0; transform: translateX(100%) scale(0.95); }
|
|
4
4
|
to { opacity: 1; transform: translateX(0) scale(1); }
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
0%, 100% { transform: translateY(0); }
|
|
13
13
|
50% { transform: translateY(-8px); }
|
|
14
14
|
}
|
|
15
|
-
`})]})}},67040:(e,t,s)=>{s.d(t,{cn:()=>r});function r(...e){return e.filter(Boolean).join(" ").replace(/\s+/g," ").trim()}},67671:(e,t,s)=>{s.d(t,{i:()=>l});var r=s(1934);let a=0,l=(0,r.v)((e,t)=>({notifications:[],addNotification:s=>{let r=++a,l={id:r,type:s.type||"info",message:s.message,title:s.title||null,duration:s.duration??5e3,dismissible:s.dismissible??!0,createdAt:Date.now()};return e(e=>({notifications:[...e.notifications,l]})),l.duration>0&&setTimeout(()=>{t().removeNotification(r)},l.duration),r},removeNotification:t=>{e(e=>({notifications:e.notifications.filter(e=>e.id!==t)}))},clearAll:()=>e({notifications:[]}),success:(e,s)=>t().addNotification({type:"success",message:e,title:s}),error:(e,s)=>t().addNotification({type:"error",message:e,title:s,duration:8e3}),warning:(e,s)=>t().addNotification({type:"warning",message:e,title:s}),info:(e,s)=>t().addNotification({type:"info",message:e,title:s})}))},71361:(e,t,s)=>{s.d(t,{ConfirmModal:()=>o,default:()=>i});var r=s(95155),a=s(12115),l=s(67040),n=s(35806);function i({isOpen:e,onClose:t,title:s,children:n,footer:i,size:o="md",closeOnOverlay:c=!0,showCloseButton:d=!0,className:x}){let m=(0,a.useId)(),u=(0,a.useRef)(null);return((0,a.useEffect)(()=>(e?document.body.style.overflow="hidden":document.body.style.overflow="",()=>{document.body.style.overflow=""}),[e]),(0,a.useEffect)(()=>{let s=s=>{"Escape"===s.key&&e&&t()};return document.addEventListener("keydown",s),()=>document.removeEventListener("keydown",s)},[e,t]),(0,a.useEffect)(()=>{if(!e||!u.current)return;let t=u.current,s='button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])',r=t.querySelector(s);r&&setTimeout(()=>r.focus(),50);let a=e=>{if("Tab"!==e.key)return;let r=[...t.querySelectorAll(s)];if(0===r.length)return;let a=r[0],l=r[r.length-1];e.shiftKey&&document.activeElement===a?(e.preventDefault(),l.focus()):e.shiftKey||document.activeElement!==l||(e.preventDefault(),a.focus())};return t.addEventListener("keydown",a),()=>t.removeEventListener("keydown",a)},[e]),e)?(0,r.jsxs)("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4",children:[(0,r.jsx)("div",{className:"absolute inset-0 bg-black/30 backdrop-blur-sm",onClick:c?t:void 0,"aria-hidden":"true"}),(0,r.jsxs)("div",{ref:u,role:"dialog","aria-modal":"true","aria-labelledby":s?m:void 0,className:(0,l.cn)("relative w-full bg-surface","border border-black/10 dark:border-white/10","rounded-xl shadow-2xl","animate-in fade-in zoom-in-95 duration-200",{sm:"max-w-sm",md:"max-w-md",lg:"max-w-lg",xl:"max-w-xl",full:"max-w-4xl"}[o],x),children:[(s||d)&&(0,r.jsxs)("div",{className:"flex items-center justify-between p-6 border-b border-black/5 dark:border-white/5",children:[(0,r.jsxs)("div",{className:"flex items-center",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2 mr-4","aria-hidden":"true",children:[(0,r.jsx)("div",{className:"w-3 h-3 rounded-full bg-[#FF5F56]"}),(0,r.jsx)("div",{className:"w-3 h-3 rounded-full bg-[#FFBD2E]"}),(0,r.jsx)("div",{className:"w-3 h-3 rounded-full bg-[#27C93F]"})]}),s&&(0,r.jsx)("h2",{id:m,className:"text-lg font-semibold text-text-main",children:s})]}),d&&(0,r.jsx)("button",{onClick:t,"aria-label":"Close",className:"p-1.5 rounded-lg text-text-muted hover:bg-black/5 dark:hover:bg-white/5 transition-colors",children:(0,r.jsx)("span",{className:"material-symbols-outlined text-[20px]","aria-hidden":"true",children:"close"})})]}),(0,r.jsx)("div",{className:"p-6 max-h-[calc(80vh-140px)] overflow-y-auto",children:n}),i&&(0,r.jsx)("div",{className:"flex items-center justify-end gap-3 p-6 border-t border-black/5 dark:border-white/5",children:i})]})]}):null}function o({isOpen:e,onClose:t,onConfirm:s,title:a="Confirm",message:l,confirmText:o="Confirm",cancelText:c="Cancel",variant:d="danger",loading:x=!1}){return(0,r.jsx)(i,{isOpen:e,onClose:t,title:a,size:"sm",footer:(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(n.default,{variant:"ghost",onClick:t,disabled:x,children:c}),(0,r.jsx)(n.default,{variant:d,onClick:s,loading:x,children:o})]}),children:(0,r.jsx)("p",{className:"text-text-muted",children:l})})}},71689:(e,t,s)=>{s.d(t,{default:()=>d});var r=s(95155),a=s(12115),l=s(14051),n=s.n(l),i=s(71361),o=s(35806),c=s(34422);function d({isOpen:e,onSuccess:t,onClose:s}){let[l,n]=(0,a.useState)(""),[d,x]=(0,a.useState)(""),[m,u]=(0,a.useState)(null),[p,h]=(0,a.useState)(!1),[b,f]=(0,a.useState)(!1),[g,y]=(0,a.useState)(!1);(0,a.useEffect)(()=>{e&&(async()=>{f(!0),u(null),y(!1);try{let e=await fetch("/api/oauth/cursor/auto-import"),t=await e.json();t.found?(n(t.accessToken),x(t.machineId),y(!0)):u(t.error||"Could not auto-detect tokens")}catch(e){u("Failed to auto-detect tokens")}finally{f(!1)}})()},[e]);let j=async()=>{if(!l.trim())return void u("Please enter an access token");if(!d.trim())return void u("Please enter a machine ID");h(!0),u(null);try{let e=await fetch("/api/oauth/cursor/import",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({accessToken:l.trim(),machineId:d.trim()})}),r=await e.json();if(!e.ok)throw Error(r.error||"Import failed");t?.(),s()}catch(e){u(e.message)}finally{h(!1)}};return(0,r.jsx)(i.default,{isOpen:e,title:"Connect Cursor IDE",onClose:s,children:(0,r.jsxs)("div",{className:"flex flex-col gap-4",children:[b&&(0,r.jsxs)("div",{className:"text-center py-6",children:[(0,r.jsx)("div",{className:"size-16 mx-auto mb-4 rounded-full bg-primary/10 flex items-center justify-center",children:(0,r.jsx)("span",{className:"material-symbols-outlined text-3xl text-primary animate-spin",children:"progress_activity"})}),(0,r.jsx)("h3",{className:"text-lg font-semibold mb-2",children:"Auto-detecting tokens..."}),(0,r.jsx)("p",{className:"text-sm text-text-muted",children:"Reading from Cursor IDE database"})]}),!b&&(0,r.jsxs)(r.Fragment,{children:[g&&(0,r.jsx)("div",{className:"bg-green-50 dark:bg-green-900/20 p-3 rounded-lg border border-green-200 dark:border-green-800",children:(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsx)("span",{className:"material-symbols-outlined text-green-600 dark:text-green-400",children:"check_circle"}),(0,r.jsx)("p",{className:"text-sm text-green-800 dark:text-green-200",children:"Tokens auto-detected from Cursor IDE successfully!"})]})}),!g&&!m&&(0,r.jsx)("div",{className:"bg-blue-50 dark:bg-blue-900/20 p-3 rounded-lg border border-blue-200 dark:border-blue-800",children:(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsx)("span",{className:"material-symbols-outlined text-blue-600 dark:text-blue-400",children:"info"}),(0,r.jsx)("p",{className:"text-sm text-blue-800 dark:text-blue-200",children:"Cursor IDE not detected. Please paste your tokens manually."})]})}),(0,r.jsxs)("div",{children:[(0,r.jsxs)("label",{className:"block text-sm font-medium mb-2",children:["Access Token ",(0,r.jsx)("span",{className:"text-red-500",children:"*"})]}),(0,r.jsx)("textarea",{value:l,onChange:e=>n(e.target.value),placeholder:"Access token will be auto-filled...",rows:3,className:"w-full px-3 py-2 text-sm font-mono border border-border rounded-lg bg-background focus:outline-none focus:border-primary resize-none"})]}),(0,r.jsxs)("div",{children:[(0,r.jsxs)("label",{className:"block text-sm font-medium mb-2",children:["Machine ID ",(0,r.jsx)("span",{className:"text-red-500",children:"*"})]}),(0,r.jsx)(c.default,{value:d,onChange:e=>x(e.target.value),placeholder:"Machine ID will be auto-filled...",className:"font-mono text-sm"})]}),m&&(0,r.jsx)("div",{className:"bg-red-50 dark:bg-red-900/20 p-3 rounded-lg border border-red-200 dark:border-red-800",children:(0,r.jsx)("p",{className:"text-sm text-red-600 dark:text-red-400",children:m})}),(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsx)(o.default,{onClick:j,fullWidth:!0,disabled:p||!l.trim()||!d.trim(),children:p?"Importing...":"Import Token"}),(0,r.jsx)(o.default,{onClick:s,variant:"ghost",fullWidth:!0,children:"Cancel"})]})]})]})})}d.propTypes={isOpen:n().bool.isRequired,onSuccess:n().func,onClose:n().func.isRequired}},76332:(e,t,s)=>{s.d(t,{default:()=>o});var r=s(95155),a=s(73321),l=s(98500),n=s.n(l);let i={dashboard:"Dashboard",providers:"Providers",combos:"Combos",settings:"Settings",logs:"Logs","audit-log":"Audit Log",console:"Console",logger:"Logger",translator:"Translator",playground:"Playground",add:"Add",edit:"Edit",keys:"API Keys",models:"Models"};function o(){let e=(0,a.usePathname)();if(!e||"/dashboard"===e)return null;let t=e.split("/").filter(Boolean),s=t.map((e,s)=>({label:i[e]||e.charAt(0).toUpperCase()+e.slice(1),href:"/"+t.slice(0,s+1).join("/"),isLast:s===t.length-1}));return(0,r.jsx)("nav",{"aria-label":"Breadcrumb",style:{display:"flex",alignItems:"center",gap:"6px",fontSize:"13px",color:"var(--text-secondary, #888)",padding:"8px 0",marginBottom:"8px"},children:s.map((e,t)=>(0,r.jsxs)("span",{style:{display:"flex",alignItems:"center",gap:"6px"},children:[t>0&&(0,r.jsx)("span",{style:{opacity:.4,fontSize:"11px"},"aria-hidden":"true",children:"›"}),e.isLast?(0,r.jsx)("span",{"aria-current":"page",style:{color:"var(--text-primary, #e0e0e0)",fontWeight:500},children:e.label}):(0,r.jsx)(n(),{href:e.href,style:{color:"var(--text-secondary, #888)",textDecoration:"none",transition:"color 0.15s"},onMouseEnter:e=>e.currentTarget.style.color="var(--accent, #818cf8)",onMouseLeave:e=>e.currentTarget.style.color="var(--text-secondary, #888)",children:e.label})]},e.href))})}},80178:(e,t,s)=>{s.d(t,{default:()=>u});var r=s(95155),a=s(12115),l=s(14051),n=s.n(l),i=s(71361),o=s(35806),c=s(34422),d=s(30949),x=s(41463);let m=new Set(["antigravity","gemini-cli"]);function u({isOpen:e,provider:t,providerInfo:s,onSuccess:l,onClose:n,idcConfig:u}){let[p,h]=(0,a.useState)("waiting"),[b,f]=(0,a.useState)(null),[g,y]=(0,a.useState)(""),[j,v]=(0,a.useState)(null),[N,k]=(0,a.useState)(!1),[w,C]=(0,a.useState)(null),[S,T]=(0,a.useState)(!1),I=(0,a.useRef)(null),{copied:O,copy:R}=(0,d.C)(),[E,L]=(0,a.useState)(!1),[A,_]=(0,a.useState)("/callback?code=..."),M=(0,a.useRef)(!1),$=(0,a.useRef)(!1),[P,D]=(0,a.useState)(!1);(0,a.useEffect)(()=>{{let e=window.location.hostname,t="localhost"===e||"127.0.0.1"===e||e.startsWith("192.168.")||e.startsWith("10.")||/^172\.(1[6-9]|2\d|3[01])\./.test(e),s="localhost"===e||"127.0.0.1"===e;L(t),D(s),_(`${window.location.origin}/callback?code=...`)}},[]);let F=(0,a.useCallback)(async(e,s)=>{if(b)try{let r=await fetch(`/api/oauth/${t}/exchange`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({code:e,redirectUri:b.redirectUri,codeVerifier:b.codeVerifier,state:s})}),a=await r.json();if(!r.ok)throw Error(a.error);h("success"),l?.()}catch(e){e.message?.toLowerCase().includes("redirect_uri_mismatch")&&m.has(t)?v("redirect_uri_mismatch: As credenciais padr\xe3o do Google OAuth s\xf3 funcionam em localhost. Para uso remoto, configure suas pr\xf3prias credenciais OAuth nas vari\xe1veis de ambiente: "+("antigravity"===t?"ANTIGRAVITY_OAUTH_CLIENT_ID e ANTIGRAVITY_OAUTH_CLIENT_SECRET":"GEMINI_OAUTH_CLIENT_ID e GEMINI_OAUTH_CLIENT_SECRET")+". Veja o README, se\xe7\xe3o 'OAuth em Servidor Remoto'."):v(e.message),h("error")}},[b,t,l]),z=(0,a.useCallback)(async(e,s,r,a)=>{T(!0);for(let n=0;n<60;n++){await new Promise(e=>setTimeout(e,1e3*r));try{let n=await fetch(`/api/oauth/${t}/poll`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({deviceCode:e,codeVerifier:s,extraData:a})}),i=await n.json();if(i.success){h("success"),T(!1),l?.();return}if("expired_token"===i.error||"access_denied"===i.error)throw Error(i.errorDescription||i.error);"slow_down"===i.error&&(r=Math.min(r+5,30))}catch(e){v(e.message),h("error"),T(!1);return}}v("Authorization timeout"),h("error"),T(!1)},[t,l]),K=(0,a.useCallback)(async()=>{if(t)try{let e;if(v(null),"github"===t||"qwen"===t||"kiro"===t||"kimi-coding"===t||"kilocode"===t){k(!0),h("waiting");let e=await fetch(`/api/oauth/${t}/device-code`),s=await e.json();if(!e.ok)throw Error(s.error);C(s);let r=s.verification_uri_complete||s.verification_uri;r&&window.open(r,"oauth_verify");let a="kiro"===t?{_clientId:s._clientId,_clientSecret:s._clientSecret}:null;z(s.device_code,s.codeVerifier,s.interval||5,a);return}if("codex"===t&&E){try{let e=await fetch("/api/oauth/codex/start-callback-server"),t=await e.json();if(!e.ok)throw Error(t.error);f({...t,redirectUri:t.redirectUri}),h("waiting"),window.open(t.authUrl,"oauth_auth"),T(!0);for(let e=0;e<150;e++){await new Promise(e=>setTimeout(e,2e3));let e=await fetch("/api/oauth/codex/poll-callback",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({})}),t=await e.json();if(t.success){h("success"),T(!1),l?.();return}if(t.error&&!t.pending)throw Error(t.errorDescription||t.error)}throw T(!1),Error("Authorization timeout")}catch(e){T(!1),h("input"),v(e.message+" — You can paste the callback URL manually below.")}return}if("codex"===t||"openai"===t)e="http://localhost:1455/auth/callback";else if(m.has(t)){let t=window.location.port||"20128";e=`http://localhost:${t}/callback`}else if(E){let t=window.location.port||("https:"===window.location.protocol?"443":"80");e=`http://localhost:${t}/callback`}else{let t=x.env.NEXT_PUBLIC_BASE_URL,s=t&&"http://localhost:20128"!==t?t.replace(/\/$/,""):window.location.origin;e=`${s}/callback`}let s=await fetch(`/api/oauth/${t}/authorize?redirect_uri=${encodeURIComponent(e)}`),r=await s.json();if(!s.ok)throw Error(r.error);f({...r,redirectUri:e}),P?(h("waiting"),I.current=window.open(r.authUrl,"oauth_popup","width=600,height=700"),I.current||h("input")):(h("input"),window.open(r.authUrl,"oauth_auth"))}catch(e){v(e.message),h("error")}},[t,E,P,z,l]);(0,a.useEffect)(()=>{e||($.current=!1)},[e]),(0,a.useEffect)(()=>{e&&t&&($.current||($.current=!0,f(null),y(""),v(null),k(!1),C(null),T(!1),K()))},[e,t,K]),(0,a.useEffect)(()=>{let e;if(!b)return;M.current=!1;let t=async e=>{if(M.current)return;let{code:t,state:s,error:r,errorDescription:a}=e;if(r){M.current=!0,v(a||r),h("error");return}t&&(M.current=!0,await F(t,s))},s=e=>{let s=window.location.port,r=e.origin.match(/^https?:\/\/(localhost|127\.0\.0\.1)(:\d+)?$/)&&new URL(e.origin).port===s;(e.origin===window.location.origin||r)&&e.data?.type==="oauth_callback"&&t(e.data.data)};window.addEventListener("message",s);try{(e=new BroadcastChannel("oauth_callback")).onmessage=e=>t(e.data)}catch(e){console.log("BroadcastChannel not supported")}let r=e=>{if("oauth_callback"===e.key&&e.newValue)try{let s=JSON.parse(e.newValue);t(s),localStorage.removeItem("oauth_callback")}catch(e){console.log("Failed to parse localStorage data")}};window.addEventListener("storage",r);try{let e=localStorage.getItem("oauth_callback");if(e){let s=JSON.parse(e);s.timestamp&&Date.now()-s.timestamp<3e4&&(t(s),localStorage.removeItem("oauth_callback"))}}catch{}return()=>{window.removeEventListener("message",s),window.removeEventListener("storage",r),e&&e.close()}},[b,F]);let U=async()=>{try{v(null);let e=new URL(g),t=e.searchParams.get("code"),s=e.searchParams.get("state"),r=e.searchParams.get("error");if(r)throw Error(e.searchParams.get("error_description")||r);if(!t)throw Error("No authorization code found in URL");await F(t,s)}catch(e){v(e.message),h("error")}};return t&&s?(0,r.jsx)(i.default,{isOpen:e,title:`Connect ${s.name}`,onClose:n,size:"lg",children:(0,r.jsxs)("div",{className:"flex flex-col gap-4",children:["waiting"===p&&!N&&(0,r.jsxs)("div",{className:"text-center py-6",children:[(0,r.jsx)("div",{className:"size-16 mx-auto mb-4 rounded-full bg-primary/10 flex items-center justify-center",children:(0,r.jsx)("span",{className:"material-symbols-outlined text-3xl text-primary animate-spin",children:"progress_activity"})}),(0,r.jsx)("h3",{className:"text-lg font-semibold mb-2",children:"Waiting for Authorization"}),(0,r.jsx)("p",{className:"text-sm text-text-muted mb-4",children:"Complete the authorization in the popup window."}),(0,r.jsx)(o.default,{variant:"ghost",onClick:()=>h("input"),children:"Popup blocked? Enter URL manually"})]}),"waiting"===p&&N&&w&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"text-center py-4",children:[(0,r.jsx)("p",{className:"text-sm text-text-muted mb-4",children:"Visit the URL below and enter the code:"}),(0,r.jsxs)("div",{className:"bg-sidebar p-4 rounded-lg mb-4",children:[(0,r.jsx)("p",{className:"text-xs text-text-muted mb-1",children:"Verification URL"}),(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("code",{className:"flex-1 text-sm break-all",children:w.verification_uri}),(0,r.jsx)(o.default,{size:"sm",variant:"ghost",icon:"verify_url"===O?"check":"content_copy",onClick:()=>R(w.verification_uri,"verify_url")})]})]}),(0,r.jsxs)("div",{className:"bg-primary/10 p-4 rounded-lg",children:[(0,r.jsx)("p",{className:"text-xs text-text-muted mb-1",children:"Your Code"}),(0,r.jsxs)("div",{className:"flex items-center justify-center gap-2",children:[(0,r.jsx)("p",{className:"text-2xl font-mono font-bold text-primary",children:w.user_code}),(0,r.jsx)(o.default,{size:"sm",variant:"ghost",icon:"user_code"===O?"check":"content_copy",onClick:()=>R(w.user_code,"user_code")})]})]})]}),S&&(0,r.jsxs)("div",{className:"flex items-center justify-center gap-2 text-sm text-text-muted",children:[(0,r.jsx)("span",{className:"material-symbols-outlined animate-spin",children:"progress_activity"}),"Waiting for authorization..."]})]}),"input"===p&&!N&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"space-y-4",children:[!P&&m.has(t)&&(0,r.jsxs)("div",{className:"rounded-lg border border-amber-500/30 bg-amber-500/10 p-3 text-xs text-amber-200",children:[(0,r.jsx)("span",{className:"material-symbols-outlined text-sm align-middle mr-1",children:"warning"}),(0,r.jsx)("strong",{children:"Acesso remoto + Google OAuth:"})," As credenciais padr\xe3o s\xf3 aceitam redirect para ",(0,r.jsx)("code",{children:"localhost"}),". Ap\xf3s autorizar, o browser tentar\xe1 abrir",(0,r.jsx)("code",{children:"localhost"})," — copie essa URL completa e cole abaixo. Para uso totalmente remoto sem esse passo manual,"," ",(0,r.jsx)("a",{href:"https://github.com/diegosouzapw/OmniRoute#oauth-em-servidor-remoto",target:"_blank",rel:"noreferrer",className:"underline",children:"configure suas pr\xf3prias credenciais OAuth"}),"."]}),!P&&!m.has(t)&&(0,r.jsxs)("div",{className:"rounded-lg border border-blue-500/30 bg-blue-500/10 p-3 text-xs text-blue-200",children:[(0,r.jsx)("span",{className:"material-symbols-outlined text-sm align-middle mr-1",children:"info"}),(0,r.jsx)("strong",{children:"Remote access:"})," Since you're accessing OmniRoute remotely, after authorizing you'll see an error page (localhost not found). That's expected — just copy the full URL from your browser's address bar and paste it below."]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("p",{className:"text-sm font-medium mb-2",children:"Step 1: Open this URL in your browser"}),(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsx)(c.default,{value:b?.authUrl||"",readOnly:!0,className:"flex-1 font-mono text-xs"}),(0,r.jsx)(o.default,{variant:"secondary",icon:"auth_url"===O?"check":"content_copy",onClick:()=>R(b?.authUrl,"auth_url"),children:"Copy"})]})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("p",{className:"text-sm font-medium mb-2",children:"Step 2: Paste the callback URL here"}),(0,r.jsx)("p",{className:"text-xs text-text-muted mb-2",children:"After authorization, copy the full URL from your browser."}),(0,r.jsx)(c.default,{value:g,onChange:e=>y(e.target.value),placeholder:A,className:"font-mono text-xs"})]})]}),(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsx)(o.default,{onClick:U,fullWidth:!0,disabled:!g,children:"Connect"}),(0,r.jsx)(o.default,{onClick:n,variant:"ghost",fullWidth:!0,children:"Cancel"})]})]}),"success"===p&&(0,r.jsxs)("div",{className:"text-center py-6",children:[(0,r.jsx)("div",{className:"size-16 mx-auto mb-4 rounded-full bg-green-100 dark:bg-green-900/30 flex items-center justify-center",children:(0,r.jsx)("span",{className:"material-symbols-outlined text-3xl text-green-600",children:"check_circle"})}),(0,r.jsx)("h3",{className:"text-lg font-semibold mb-2",children:"Connected Successfully!"}),(0,r.jsxs)("p",{className:"text-sm text-text-muted mb-4",children:["Your ",s.name," account has been connected."]}),(0,r.jsx)(o.default,{onClick:n,fullWidth:!0,children:"Done"})]}),"error"===p&&(0,r.jsxs)("div",{className:"text-center py-6",children:[(0,r.jsx)("div",{className:"size-16 mx-auto mb-4 rounded-full bg-red-100 dark:bg-red-900/30 flex items-center justify-center",children:(0,r.jsx)("span",{className:"material-symbols-outlined text-3xl text-red-600",children:"error"})}),(0,r.jsx)("h3",{className:"text-lg font-semibold mb-2",children:"Connection Failed"}),(0,r.jsx)("p",{className:"text-sm text-red-600 mb-4",children:j}),(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsx)(o.default,{onClick:K,variant:"secondary",fullWidth:!0,children:"Try Again"}),(0,r.jsx)(o.default,{onClick:n,variant:"ghost",fullWidth:!0,children:"Cancel"})]})]})]})}):null}u.propTypes={isOpen:n().bool.isRequired,provider:n().string,providerInfo:n().shape({name:n().string}),onSuccess:n().func,onClose:n().func.isRequired}},80927:(e,t,s)=>{s.d(t,{default:()=>i});var r=s(95155),a=s(67040);let l={default:"bg-black/5 dark:bg-white/10 text-text-muted",primary:"bg-primary/10 text-primary",success:"bg-green-500/10 text-green-600 dark:text-green-400",warning:"bg-yellow-500/10 text-yellow-600 dark:text-yellow-400",error:"bg-red-500/10 text-red-600 dark:text-red-400",info:"bg-blue-500/10 text-blue-600 dark:text-blue-400"},n={sm:"px-2 py-0.5 text-[10px]",md:"px-2.5 py-1 text-xs",lg:"px-3 py-1.5 text-sm"};function i({children:e,variant:t="default",size:s="md",dot:i=!1,icon:o,className:c}){return(0,r.jsxs)("span",{className:(0,a.cn)("inline-flex items-center gap-1.5 rounded-full font-semibold",l[t],n[s],c),children:[i&&(0,r.jsx)("span",{"aria-hidden":"true",className:(0,a.cn)("size-1.5 rounded-full","success"===t&&"bg-green-500","warning"===t&&"bg-yellow-500","error"===t&&"bg-red-500","info"===t&&"bg-blue-500","primary"===t&&"bg-primary","default"===t&&"bg-gray-500")}),o&&(0,r.jsx)("span",{className:"material-symbols-outlined text-[14px]","aria-hidden":"true",children:o}),e]})}},81060:(e,t,s)=>{s.d(t,{default:()=>l});var r=s(95155),a=s(67040);function l({children:e,title:t,subtitle:s,icon:l,action:n,padding:i="md",hover:o=!1,className:c,...d}){return(0,r.jsxs)("div",{className:(0,a.cn)("bg-surface","border border-black/5 dark:border-white/5","rounded-lg shadow-sm",o&&"hover:shadow-md hover:border-primary/30 transition-all cursor-pointer",{none:"",xs:"p-3",sm:"p-4",md:"p-6",lg:"p-8"}[i],c),...d,children:[(t||n)&&(0,r.jsxs)("div",{className:"flex items-center justify-between mb-4",children:[(0,r.jsxs)("div",{className:"flex items-center gap-3",children:[l&&(0,r.jsx)("div",{className:"p-2 rounded-lg bg-bg text-text-muted",children:(0,r.jsx)("span",{className:"material-symbols-outlined text-[20px]",children:l})}),(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})]})]}),n]}),e]})}l.Section=function({children:e,className:t,...s}){return(0,r.jsx)("div",{className:(0,a.cn)("p-4 rounded-lg","bg-black/[0.02] dark:bg-white/[0.02]","border border-black/5 dark:border-white/5",t),...s,children:e})},l.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-black/5 dark:border-white/5 last:border-b-0","hover:bg-black/[0.02] dark:hover:bg-white/[0.02]",t),...s,children:e})},l.ListItem=function({children:e,actions:t,className:s,...l}){return(0,r.jsxs)("div",{className:(0,a.cn)("group flex items-center justify-between p-3 -mx-3 px-3","border-b border-black/[0.03] dark:border-white/[0.03] last:border-b-0","hover:bg-black/[0.02] dark:hover:bg-white/[0.02]","transition-colors",s),...l,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 focus-within:opacity-100 transition-opacity",children:t})]})}},85444:(e,t,s)=>{s.d(t,{default:()=>x});var r=s(95155),a=s(12115),l=s(14051),n=s.n(l),i=s(71361),o=s(81135),c=s(20909);let d=[...Object.keys(c.zN),...Object.keys(c.IS),...Object.keys(c.fg)];function x({isOpen:e,onClose:t,onSelect:s,selectedModel:l,activeProviders:n=[],title:x="Select Model",modelAliases:m={}}){let[u,p]=(0,a.useState)(""),[h,b]=(0,a.useState)([]),[f,g]=(0,a.useState)([]),[y,j]=(0,a.useState)({}),v=async()=>{try{let e=await fetch("/api/combos");if(!e.ok)throw Error(`Failed to fetch combos: ${e.status}`);let t=await e.json();b(t.combos||[])}catch(e){console.error("Error fetching combos:",e),b([])}};(0,a.useEffect)(()=>{e&&v()},[e]);let N=async()=>{try{let e=await fetch("/api/provider-nodes");if(!e.ok)throw Error(`Failed to fetch provider nodes: ${e.status}`);let t=await e.json();g(t.nodes||[])}catch(e){console.error("Error fetching provider nodes:",e),g([])}};(0,a.useEffect)(()=>{e&&N()},[e]);let k=async()=>{try{let e=await fetch("/api/provider-models");if(!e.ok)throw Error(`Failed to fetch custom models: ${e.status}`);let t=await e.json();j(t.models||{})}catch(e){console.error("Error fetching custom models:",e),j({})}};(0,a.useEffect)(()=>{e&&k()},[e]);let w=(0,a.useMemo)(()=>({...c.zN,...c.IS,...c.fg}),[]),C=(0,a.useMemo)(()=>{let e={};return[...new Set([...n.map(e=>e.provider)])].sort((e,t)=>{let s=d.indexOf(e),r=d.indexOf(t);return(-1===s?999:s)-(-1===r?999:r)}).forEach(t=>{let s=o.Xg[t]||t,r=w[t]||{name:t,color:"#666"},a=(0,c.mq)(t)||(0,c.gb)(t),l=y[t]||[];if(r.passthroughModels){let a=Object.entries(m).filter(([,e])=>e.startsWith(`${s}/`)).map(([e,t])=>({id:t.replace(`${s}/`,""),name:e,value:t})),n=l.filter(e=>!a.some(t=>t.id===e.id)).map(e=>({id:e.id,name:e.name||e.id,value:`${s}/${e.id}`,isCustom:!0})),i=[...a,...n];if(i.length>0){let a=f.find(e=>e.id===t),l=a?.name||r.name;e[t]={name:l,alias:s,color:r.color,models:i}}}else if(a){let s=f.find(e=>e.id===t),a=s?.name||r.name,n=s?.prefix||t,i=Object.entries(m).filter(([,e])=>e.startsWith(`${t}/`)).map(([e,s])=>({id:s.replace(`${t}/`,""),name:e,value:`${n}/${s.replace(`${t}/`,"")}`})),o=l.filter(e=>!i.some(t=>t.id===e.id)).map(e=>({id:e.id,name:e.name||e.id,value:`${n}/${e.id}`,isCustom:!0})),c=[...i,...o];c.length>0&&(e[t]={name:a,alias:n,color:r.color,models:c,isCustom:!0,hasModels:!0})}else{let a=(0,o.KC)(t),n=[...a.map(e=>({id:e.id,name:e.name,value:`${s}/${e.id}`})),...l.filter(e=>!a.some(t=>t.id===e.id)).map(e=>({id:e.id,name:e.name||e.id,value:`${s}/${e.id}`,isCustom:!0}))];n.length>0&&(e[t]={name:r.name,alias:s,color:r.color,models:n})}}),e},[n,m,w,f,y]),S=(0,a.useMemo)(()=>{if(!u.trim())return h;let e=u.toLowerCase();return h.filter(t=>t.name.toLowerCase().includes(e))},[h,u]),T=(0,a.useMemo)(()=>{if(!u.trim())return C;let e=u.toLowerCase(),t={};return Object.entries(C).forEach(([s,r])=>{let a=r.models.filter(t=>t.name.toLowerCase().includes(e)||t.id.toLowerCase().includes(e)),l=r.name.toLowerCase().includes(e);(a.length>0||l)&&(t[s]={...r,models:a})}),t},[C,u]),I=e=>{s(e),t(),p("")};return(0,r.jsxs)(i.default,{isOpen:e,onClose:()=>{t(),p("")},title:x,size:"md",className:"p-4!",children:[(0,r.jsx)("div",{className:"mb-3",children:(0,r.jsxs)("div",{className:"relative",children:[(0,r.jsx)("span",{className:"material-symbols-outlined absolute left-2.5 top-1/2 -translate-y-1/2 text-text-muted text-[16px]",children:"search"}),(0,r.jsx)("input",{type:"text",placeholder:"Search...",value:u,onChange:e=>p(e.target.value),className:"w-full pl-8 pr-3 py-1.5 bg-surface border border-border rounded text-xs focus:outline-none focus:ring-1 focus:ring-primary/50"})]})}),(0,r.jsxs)("div",{className:"max-h-[300px] overflow-y-auto space-y-3",children:[S.length>0&&(0,r.jsxs)("div",{children:[(0,r.jsxs)("div",{className:"flex items-center gap-1.5 mb-1.5 sticky top-0 bg-surface py-0.5",children:[(0,r.jsx)("span",{className:"material-symbols-outlined text-primary text-[14px]",children:"layers"}),(0,r.jsx)("span",{className:"text-xs font-medium text-primary",children:"Combos"}),(0,r.jsxs)("span",{className:"text-[10px] text-text-muted",children:["(",S.length,")"]})]}),(0,r.jsx)("div",{className:"flex flex-wrap gap-1.5",children:S.map(e=>{let t=l===e.name;return(0,r.jsx)("button",{onClick:()=>I({id:e.name,name:e.name,value:e.name}),className:`
|
|
15
|
+
`})]})}},67040:(e,t,s)=>{s.d(t,{cn:()=>r});function r(...e){return e.filter(Boolean).join(" ").replace(/\s+/g," ").trim()}},67671:(e,t,s)=>{s.d(t,{i:()=>l});var r=s(1934);let a=0,l=(0,r.v)((e,t)=>({notifications:[],addNotification:s=>{let r=++a,l={id:r,type:s.type||"info",message:s.message,title:s.title||null,duration:s.duration??5e3,dismissible:s.dismissible??!0,createdAt:Date.now()};return e(e=>({notifications:[...e.notifications,l]})),l.duration>0&&setTimeout(()=>{t().removeNotification(r)},l.duration),r},removeNotification:t=>{e(e=>({notifications:e.notifications.filter(e=>e.id!==t)}))},clearAll:()=>e({notifications:[]}),success:(e,s)=>t().addNotification({type:"success",message:e,title:s}),error:(e,s)=>t().addNotification({type:"error",message:e,title:s,duration:8e3}),warning:(e,s)=>t().addNotification({type:"warning",message:e,title:s}),info:(e,s)=>t().addNotification({type:"info",message:e,title:s})}))},71361:(e,t,s)=>{s.d(t,{ConfirmModal:()=>o,default:()=>i});var r=s(95155),a=s(12115),l=s(67040),n=s(35806);function i({isOpen:e,onClose:t,title:s,children:n,footer:i,size:o="md",closeOnOverlay:c=!0,showCloseButton:d=!0,className:x}){let m=(0,a.useId)(),u=(0,a.useRef)(null);return((0,a.useEffect)(()=>(e?document.body.style.overflow="hidden":document.body.style.overflow="",()=>{document.body.style.overflow=""}),[e]),(0,a.useEffect)(()=>{let s=s=>{"Escape"===s.key&&e&&t()};return document.addEventListener("keydown",s),()=>document.removeEventListener("keydown",s)},[e,t]),(0,a.useEffect)(()=>{if(!e||!u.current)return;let t=u.current,s='button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])',r=t.querySelector(s);r&&setTimeout(()=>r.focus(),50);let a=e=>{if("Tab"!==e.key)return;let r=[...t.querySelectorAll(s)];if(0===r.length)return;let a=r[0],l=r[r.length-1];e.shiftKey&&document.activeElement===a?(e.preventDefault(),l.focus()):e.shiftKey||document.activeElement!==l||(e.preventDefault(),a.focus())};return t.addEventListener("keydown",a),()=>t.removeEventListener("keydown",a)},[e]),e)?(0,r.jsxs)("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4",children:[(0,r.jsx)("div",{className:"absolute inset-0 bg-black/30 backdrop-blur-sm",onClick:c?t:void 0,"aria-hidden":"true"}),(0,r.jsxs)("div",{ref:u,role:"dialog","aria-modal":"true","aria-labelledby":s?m:void 0,className:(0,l.cn)("relative w-full bg-surface","border border-black/10 dark:border-white/10","rounded-xl shadow-2xl","animate-in fade-in zoom-in-95 duration-200",{sm:"max-w-sm",md:"max-w-md",lg:"max-w-lg",xl:"max-w-xl",full:"max-w-4xl"}[o],x),children:[(s||d)&&(0,r.jsxs)("div",{className:"flex items-center justify-between p-6 border-b border-black/5 dark:border-white/5",children:[(0,r.jsxs)("div",{className:"flex items-center",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2 mr-4","aria-hidden":"true",children:[(0,r.jsx)("div",{className:"w-3 h-3 rounded-full bg-[#FF5F56]"}),(0,r.jsx)("div",{className:"w-3 h-3 rounded-full bg-[#FFBD2E]"}),(0,r.jsx)("div",{className:"w-3 h-3 rounded-full bg-[#27C93F]"})]}),s&&(0,r.jsx)("h2",{id:m,className:"text-lg font-semibold text-text-main",children:s})]}),d&&(0,r.jsx)("button",{onClick:t,"aria-label":"Close",className:"p-1.5 rounded-lg text-text-muted hover:bg-black/5 dark:hover:bg-white/5 transition-colors",children:(0,r.jsx)("span",{className:"material-symbols-outlined text-[20px]","aria-hidden":"true",children:"close"})})]}),(0,r.jsx)("div",{className:"p-6 max-h-[calc(80vh-140px)] overflow-y-auto",children:n}),i&&(0,r.jsx)("div",{className:"flex items-center justify-end gap-3 p-6 border-t border-black/5 dark:border-white/5",children:i})]})]}):null}function o({isOpen:e,onClose:t,onConfirm:s,title:a="Confirm",message:l,confirmText:o="Confirm",cancelText:c="Cancel",variant:d="danger",loading:x=!1}){return(0,r.jsx)(i,{isOpen:e,onClose:t,title:a,size:"sm",footer:(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(n.default,{variant:"ghost",onClick:t,disabled:x,children:c}),(0,r.jsx)(n.default,{variant:d,onClick:s,loading:x,children:o})]}),children:(0,r.jsx)("p",{className:"text-text-muted",children:l})})}},71689:(e,t,s)=>{s.d(t,{default:()=>d});var r=s(95155),a=s(12115),l=s(14051),n=s.n(l),i=s(71361),o=s(35806),c=s(34422);function d({isOpen:e,onSuccess:t,onClose:s}){let[l,n]=(0,a.useState)(""),[d,x]=(0,a.useState)(""),[m,u]=(0,a.useState)(null),[p,h]=(0,a.useState)(!1),[b,f]=(0,a.useState)(!1),[g,y]=(0,a.useState)(!1);(0,a.useEffect)(()=>{e&&(async()=>{f(!0),u(null),y(!1);try{let e=await fetch("/api/oauth/cursor/auto-import"),t=await e.json();t.found?(n(t.accessToken),x(t.machineId),y(!0)):u(t.error||"Could not auto-detect tokens")}catch(e){u("Failed to auto-detect tokens")}finally{f(!1)}})()},[e]);let j=async()=>{if(!l.trim())return void u("Please enter an access token");if(!d.trim())return void u("Please enter a machine ID");h(!0),u(null);try{let e=await fetch("/api/oauth/cursor/import",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({accessToken:l.trim(),machineId:d.trim()})}),r=await e.json();if(!e.ok)throw Error(r.error||"Import failed");t?.(),s()}catch(e){u(e.message)}finally{h(!1)}};return(0,r.jsx)(i.default,{isOpen:e,title:"Connect Cursor IDE",onClose:s,children:(0,r.jsxs)("div",{className:"flex flex-col gap-4",children:[b&&(0,r.jsxs)("div",{className:"text-center py-6",children:[(0,r.jsx)("div",{className:"size-16 mx-auto mb-4 rounded-full bg-primary/10 flex items-center justify-center",children:(0,r.jsx)("span",{className:"material-symbols-outlined text-3xl text-primary animate-spin",children:"progress_activity"})}),(0,r.jsx)("h3",{className:"text-lg font-semibold mb-2",children:"Auto-detecting tokens..."}),(0,r.jsx)("p",{className:"text-sm text-text-muted",children:"Reading from Cursor IDE database"})]}),!b&&(0,r.jsxs)(r.Fragment,{children:[g&&(0,r.jsx)("div",{className:"bg-green-50 dark:bg-green-900/20 p-3 rounded-lg border border-green-200 dark:border-green-800",children:(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsx)("span",{className:"material-symbols-outlined text-green-600 dark:text-green-400",children:"check_circle"}),(0,r.jsx)("p",{className:"text-sm text-green-800 dark:text-green-200",children:"Tokens auto-detected from Cursor IDE successfully!"})]})}),!g&&!m&&(0,r.jsx)("div",{className:"bg-blue-50 dark:bg-blue-900/20 p-3 rounded-lg border border-blue-200 dark:border-blue-800",children:(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsx)("span",{className:"material-symbols-outlined text-blue-600 dark:text-blue-400",children:"info"}),(0,r.jsx)("p",{className:"text-sm text-blue-800 dark:text-blue-200",children:"Cursor IDE not detected. Please paste your tokens manually."})]})}),(0,r.jsxs)("div",{children:[(0,r.jsxs)("label",{className:"block text-sm font-medium mb-2",children:["Access Token ",(0,r.jsx)("span",{className:"text-red-500",children:"*"})]}),(0,r.jsx)("textarea",{value:l,onChange:e=>n(e.target.value),placeholder:"Access token will be auto-filled...",rows:3,className:"w-full px-3 py-2 text-sm font-mono border border-border rounded-lg bg-background focus:outline-none focus:border-primary resize-none"})]}),(0,r.jsxs)("div",{children:[(0,r.jsxs)("label",{className:"block text-sm font-medium mb-2",children:["Machine ID ",(0,r.jsx)("span",{className:"text-red-500",children:"*"})]}),(0,r.jsx)(c.default,{value:d,onChange:e=>x(e.target.value),placeholder:"Machine ID will be auto-filled...",className:"font-mono text-sm"})]}),m&&(0,r.jsx)("div",{className:"bg-red-50 dark:bg-red-900/20 p-3 rounded-lg border border-red-200 dark:border-red-800",children:(0,r.jsx)("p",{className:"text-sm text-red-600 dark:text-red-400",children:m})}),(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsx)(o.default,{onClick:j,fullWidth:!0,disabled:p||!l.trim()||!d.trim(),children:p?"Importing...":"Import Token"}),(0,r.jsx)(o.default,{onClick:s,variant:"ghost",fullWidth:!0,children:"Cancel"})]})]})]})})}d.propTypes={isOpen:n().bool.isRequired,onSuccess:n().func,onClose:n().func.isRequired}},76332:(e,t,s)=>{s.d(t,{default:()=>o});var r=s(95155),a=s(73321),l=s(98500),n=s.n(l);let i={dashboard:"Dashboard",providers:"Providers",combos:"Combos",settings:"Settings",logs:"Logs","audit-log":"Audit Log",console:"Console",logger:"Logger",translator:"Translator",playground:"Playground",add:"Add",edit:"Edit",keys:"API Keys",models:"Models"};function o(){let e=(0,a.usePathname)();if(!e||"/dashboard"===e)return null;let t=e.split("/").filter(Boolean),s=t.map((e,s)=>({label:i[e]||e.charAt(0).toUpperCase()+e.slice(1),href:"/"+t.slice(0,s+1).join("/"),isLast:s===t.length-1}));return(0,r.jsx)("nav",{"aria-label":"Breadcrumb",style:{display:"flex",alignItems:"center",gap:"6px",fontSize:"13px",color:"var(--text-secondary, #888)",padding:"8px 0",marginBottom:"8px"},children:s.map((e,t)=>(0,r.jsxs)("span",{style:{display:"flex",alignItems:"center",gap:"6px"},children:[t>0&&(0,r.jsx)("span",{style:{opacity:.4,fontSize:"11px"},"aria-hidden":"true",children:"›"}),e.isLast?(0,r.jsx)("span",{"aria-current":"page",style:{color:"var(--text-primary, #e0e0e0)",fontWeight:500},children:e.label}):(0,r.jsx)(n(),{href:e.href,style:{color:"var(--text-secondary, #888)",textDecoration:"none",transition:"color 0.15s"},onMouseEnter:e=>e.currentTarget.style.color="var(--accent, #818cf8)",onMouseLeave:e=>e.currentTarget.style.color="var(--text-secondary, #888)",children:e.label})]},e.href))})}},80178:(e,t,s)=>{s.d(t,{default:()=>m});var r=s(95155),a=s(12115),l=s(14051),n=s.n(l),i=s(71361),o=s(35806),c=s(34422),d=s(30949);let x=new Set(["antigravity","gemini-cli"]);function m({isOpen:e,provider:t,providerInfo:s,onSuccess:l,onClose:n,idcConfig:m}){let[u,p]=(0,a.useState)("waiting"),[h,b]=(0,a.useState)(null),[f,g]=(0,a.useState)(""),[y,j]=(0,a.useState)(null),[v,N]=(0,a.useState)(!1),[k,w]=(0,a.useState)(null),[C,S]=(0,a.useState)(!1),T=(0,a.useRef)(null),{copied:I,copy:O}=(0,d.C)(),[R,A]=(0,a.useState)(!1),[E,L]=(0,a.useState)("/callback?code=..."),M=(0,a.useRef)(!1),$=(0,a.useRef)(!1),[_,D]=(0,a.useState)(!1);(0,a.useEffect)(()=>{{let e=window.location.hostname,t="localhost"===e||"127.0.0.1"===e||e.startsWith("192.168.")||e.startsWith("10.")||/^172\.(1[6-9]|2\d|3[01])\./.test(e),s="localhost"===e||"127.0.0.1"===e;A(t),D(s),L(`${window.location.origin}/callback?code=...`)}},[]);let P=(0,a.useCallback)(async(e,s)=>{if(h)try{let r=await fetch(`/api/oauth/${t}/exchange`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({code:e,redirectUri:h.redirectUri,codeVerifier:h.codeVerifier,state:s})}),a=await r.json();if(!r.ok)throw Error(a.error);p("success"),l?.()}catch(e){e.message?.toLowerCase().includes("redirect_uri_mismatch")&&x.has(t)?j("redirect_uri_mismatch: As credenciais padr\xe3o do Google OAuth s\xf3 funcionam em localhost. Para uso remoto, configure suas pr\xf3prias credenciais OAuth nas vari\xe1veis de ambiente: "+("antigravity"===t?"ANTIGRAVITY_OAUTH_CLIENT_ID e ANTIGRAVITY_OAUTH_CLIENT_SECRET":"GEMINI_OAUTH_CLIENT_ID e GEMINI_OAUTH_CLIENT_SECRET")+". Veja o README, se\xe7\xe3o 'OAuth em Servidor Remoto'."):j(e.message),p("error")}},[h,t,l]),F=(0,a.useCallback)(async(e,s,r,a)=>{S(!0);for(let n=0;n<60;n++){await new Promise(e=>setTimeout(e,1e3*r));try{let n=await fetch(`/api/oauth/${t}/poll`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({deviceCode:e,codeVerifier:s,extraData:a})}),i=await n.json();if(i.success){p("success"),S(!1),l?.();return}if("expired_token"===i.error||"access_denied"===i.error)throw Error(i.errorDescription||i.error);"slow_down"===i.error&&(r=Math.min(r+5,30))}catch(e){j(e.message),p("error"),S(!1);return}}j("Authorization timeout"),p("error"),S(!1)},[t,l]),z=(0,a.useCallback)(async()=>{if(t)try{let e;if(j(null),"github"===t||"qwen"===t||"kiro"===t||"kimi-coding"===t||"kilocode"===t){N(!0),p("waiting");let e=await fetch(`/api/oauth/${t}/device-code`),s=await e.json();if(!e.ok)throw Error(s.error);w(s);let r=s.verification_uri_complete||s.verification_uri;r&&window.open(r,"oauth_verify");let a="kiro"===t?{_clientId:s._clientId,_clientSecret:s._clientSecret}:null;F(s.device_code,s.codeVerifier,s.interval||5,a);return}if("codex"===t&&R){try{let e=await fetch("/api/oauth/codex/start-callback-server"),t=await e.json();if(!e.ok)throw Error(t.error);b({...t,redirectUri:t.redirectUri}),p("waiting"),window.open(t.authUrl,"oauth_auth"),S(!0);for(let e=0;e<150;e++){await new Promise(e=>setTimeout(e,2e3));let e=await fetch("/api/oauth/codex/poll-callback",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({})}),t=await e.json();if(t.success){p("success"),S(!1),l?.();return}if(t.error&&!t.pending)throw Error(t.errorDescription||t.error)}throw S(!1),Error("Authorization timeout")}catch(e){S(!1),p("input"),j(e.message+" — You can paste the callback URL manually below.")}return}if("codex"===t||"openai"===t)e="http://localhost:1455/auth/callback";else if(x.has(t)){let t=window.location.port||"20128";e=`http://localhost:${t}/callback`}else if(R){let t=window.location.port||("https:"===window.location.protocol?"443":"80");e=`http://localhost:${t}/callback`}else{let t=window.location.origin;e=`${t}/callback`}let s=await fetch(`/api/oauth/${t}/authorize?redirect_uri=${encodeURIComponent(e)}`),r=await s.json();if(!s.ok)throw Error(r.error);b({...r,redirectUri:e}),_?(p("waiting"),T.current=window.open(r.authUrl,"oauth_popup","width=600,height=700"),T.current||p("input")):(p("input"),window.open(r.authUrl,"oauth_auth"))}catch(e){j(e.message),p("error")}},[t,R,_,F,l]);(0,a.useEffect)(()=>{e||($.current=!1)},[e]),(0,a.useEffect)(()=>{e&&t&&($.current||($.current=!0,b(null),g(""),j(null),N(!1),w(null),S(!1),z()))},[e,t,z]),(0,a.useEffect)(()=>{let e;if(!h)return;M.current=!1;let t=async e=>{if(M.current)return;let{code:t,state:s,error:r,errorDescription:a}=e;if(r){M.current=!0,j(a||r),p("error");return}t&&(M.current=!0,await P(t,s))},s=e=>{let s=window.location.port,r=e.origin.match(/^https?:\/\/(localhost|127\.0\.0\.1)(:\d+)?$/)&&new URL(e.origin).port===s;(e.origin===window.location.origin||r)&&e.data?.type==="oauth_callback"&&t(e.data.data)};window.addEventListener("message",s);try{(e=new BroadcastChannel("oauth_callback")).onmessage=e=>t(e.data)}catch(e){console.log("BroadcastChannel not supported")}let r=e=>{if("oauth_callback"===e.key&&e.newValue)try{let s=JSON.parse(e.newValue);t(s),localStorage.removeItem("oauth_callback")}catch(e){console.log("Failed to parse localStorage data")}};window.addEventListener("storage",r);try{let e=localStorage.getItem("oauth_callback");if(e){let s=JSON.parse(e);s.timestamp&&Date.now()-s.timestamp<3e4&&(t(s),localStorage.removeItem("oauth_callback"))}}catch{}return()=>{window.removeEventListener("message",s),window.removeEventListener("storage",r),e&&e.close()}},[h,P]);let K=async()=>{try{j(null);let e=new URL(f),t=e.searchParams.get("code"),s=e.searchParams.get("state"),r=e.searchParams.get("error");if(r)throw Error(e.searchParams.get("error_description")||r);if(!t)throw Error("No authorization code found in URL");await P(t,s)}catch(e){j(e.message),p("error")}};return t&&s?(0,r.jsx)(i.default,{isOpen:e,title:`Connect ${s.name}`,onClose:n,size:"lg",children:(0,r.jsxs)("div",{className:"flex flex-col gap-4",children:["waiting"===u&&!v&&(0,r.jsxs)("div",{className:"text-center py-6",children:[(0,r.jsx)("div",{className:"size-16 mx-auto mb-4 rounded-full bg-primary/10 flex items-center justify-center",children:(0,r.jsx)("span",{className:"material-symbols-outlined text-3xl text-primary animate-spin",children:"progress_activity"})}),(0,r.jsx)("h3",{className:"text-lg font-semibold mb-2",children:"Waiting for Authorization"}),(0,r.jsx)("p",{className:"text-sm text-text-muted mb-4",children:"Complete the authorization in the popup window."}),(0,r.jsx)(o.default,{variant:"ghost",onClick:()=>p("input"),children:"Popup blocked? Enter URL manually"})]}),"waiting"===u&&v&&k&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"text-center py-4",children:[(0,r.jsx)("p",{className:"text-sm text-text-muted mb-4",children:"Visit the URL below and enter the code:"}),(0,r.jsxs)("div",{className:"bg-sidebar p-4 rounded-lg mb-4",children:[(0,r.jsx)("p",{className:"text-xs text-text-muted mb-1",children:"Verification URL"}),(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("code",{className:"flex-1 text-sm break-all",children:k.verification_uri}),(0,r.jsx)(o.default,{size:"sm",variant:"ghost",icon:"verify_url"===I?"check":"content_copy",onClick:()=>O(k.verification_uri,"verify_url")})]})]}),(0,r.jsxs)("div",{className:"bg-primary/10 p-4 rounded-lg",children:[(0,r.jsx)("p",{className:"text-xs text-text-muted mb-1",children:"Your Code"}),(0,r.jsxs)("div",{className:"flex items-center justify-center gap-2",children:[(0,r.jsx)("p",{className:"text-2xl font-mono font-bold text-primary",children:k.user_code}),(0,r.jsx)(o.default,{size:"sm",variant:"ghost",icon:"user_code"===I?"check":"content_copy",onClick:()=>O(k.user_code,"user_code")})]})]})]}),C&&(0,r.jsxs)("div",{className:"flex items-center justify-center gap-2 text-sm text-text-muted",children:[(0,r.jsx)("span",{className:"material-symbols-outlined animate-spin",children:"progress_activity"}),"Waiting for authorization..."]})]}),"input"===u&&!v&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"space-y-4",children:[!_&&x.has(t)&&(0,r.jsxs)("div",{className:"rounded-lg border border-amber-500/30 bg-amber-500/10 p-3 text-xs text-amber-200",children:[(0,r.jsx)("span",{className:"material-symbols-outlined text-sm align-middle mr-1",children:"warning"}),(0,r.jsx)("strong",{children:"Acesso remoto + Google OAuth:"})," As credenciais padr\xe3o s\xf3 aceitam redirect para ",(0,r.jsx)("code",{children:"localhost"}),". Ap\xf3s autorizar, o browser tentar\xe1 abrir",(0,r.jsx)("code",{children:"localhost"})," — copie essa URL completa e cole abaixo. Para uso totalmente remoto sem esse passo manual,"," ",(0,r.jsx)("a",{href:"https://github.com/diegosouzapw/OmniRoute#oauth-em-servidor-remoto",target:"_blank",rel:"noreferrer",className:"underline",children:"configure suas pr\xf3prias credenciais OAuth"}),"."]}),!_&&!x.has(t)&&(0,r.jsxs)("div",{className:"rounded-lg border border-blue-500/30 bg-blue-500/10 p-3 text-xs text-blue-200",children:[(0,r.jsx)("span",{className:"material-symbols-outlined text-sm align-middle mr-1",children:"info"}),(0,r.jsx)("strong",{children:"Remote access:"})," Since you're accessing OmniRoute remotely, after authorizing you'll see an error page (localhost not found). That's expected — just copy the full URL from your browser's address bar and paste it below."]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("p",{className:"text-sm font-medium mb-2",children:"Step 1: Open this URL in your browser"}),(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsx)(c.default,{value:h?.authUrl||"",readOnly:!0,className:"flex-1 font-mono text-xs"}),(0,r.jsx)(o.default,{variant:"secondary",icon:"auth_url"===I?"check":"content_copy",onClick:()=>O(h?.authUrl,"auth_url"),children:"Copy"})]})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("p",{className:"text-sm font-medium mb-2",children:"Step 2: Paste the callback URL here"}),(0,r.jsx)("p",{className:"text-xs text-text-muted mb-2",children:"After authorization, copy the full URL from your browser."}),(0,r.jsx)(c.default,{value:f,onChange:e=>g(e.target.value),placeholder:E,className:"font-mono text-xs"})]})]}),(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsx)(o.default,{onClick:K,fullWidth:!0,disabled:!f,children:"Connect"}),(0,r.jsx)(o.default,{onClick:n,variant:"ghost",fullWidth:!0,children:"Cancel"})]})]}),"success"===u&&(0,r.jsxs)("div",{className:"text-center py-6",children:[(0,r.jsx)("div",{className:"size-16 mx-auto mb-4 rounded-full bg-green-100 dark:bg-green-900/30 flex items-center justify-center",children:(0,r.jsx)("span",{className:"material-symbols-outlined text-3xl text-green-600",children:"check_circle"})}),(0,r.jsx)("h3",{className:"text-lg font-semibold mb-2",children:"Connected Successfully!"}),(0,r.jsxs)("p",{className:"text-sm text-text-muted mb-4",children:["Your ",s.name," account has been connected."]}),(0,r.jsx)(o.default,{onClick:n,fullWidth:!0,children:"Done"})]}),"error"===u&&(0,r.jsxs)("div",{className:"text-center py-6",children:[(0,r.jsx)("div",{className:"size-16 mx-auto mb-4 rounded-full bg-red-100 dark:bg-red-900/30 flex items-center justify-center",children:(0,r.jsx)("span",{className:"material-symbols-outlined text-3xl text-red-600",children:"error"})}),(0,r.jsx)("h3",{className:"text-lg font-semibold mb-2",children:"Connection Failed"}),(0,r.jsx)("p",{className:"text-sm text-red-600 mb-4",children:y}),(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsx)(o.default,{onClick:z,variant:"secondary",fullWidth:!0,children:"Try Again"}),(0,r.jsx)(o.default,{onClick:n,variant:"ghost",fullWidth:!0,children:"Cancel"})]})]})]})}):null}m.propTypes={isOpen:n().bool.isRequired,provider:n().string,providerInfo:n().shape({name:n().string}),onSuccess:n().func,onClose:n().func.isRequired}},80927:(e,t,s)=>{s.d(t,{default:()=>i});var r=s(95155),a=s(67040);let l={default:"bg-black/5 dark:bg-white/10 text-text-muted",primary:"bg-primary/10 text-primary",success:"bg-green-500/10 text-green-600 dark:text-green-400",warning:"bg-yellow-500/10 text-yellow-600 dark:text-yellow-400",error:"bg-red-500/10 text-red-600 dark:text-red-400",info:"bg-blue-500/10 text-blue-600 dark:text-blue-400"},n={sm:"px-2 py-0.5 text-[10px]",md:"px-2.5 py-1 text-xs",lg:"px-3 py-1.5 text-sm"};function i({children:e,variant:t="default",size:s="md",dot:i=!1,icon:o,className:c}){return(0,r.jsxs)("span",{className:(0,a.cn)("inline-flex items-center gap-1.5 rounded-full font-semibold",l[t],n[s],c),children:[i&&(0,r.jsx)("span",{"aria-hidden":"true",className:(0,a.cn)("size-1.5 rounded-full","success"===t&&"bg-green-500","warning"===t&&"bg-yellow-500","error"===t&&"bg-red-500","info"===t&&"bg-blue-500","primary"===t&&"bg-primary","default"===t&&"bg-gray-500")}),o&&(0,r.jsx)("span",{className:"material-symbols-outlined text-[14px]","aria-hidden":"true",children:o}),e]})}},81060:(e,t,s)=>{s.d(t,{default:()=>l});var r=s(95155),a=s(67040);function l({children:e,title:t,subtitle:s,icon:l,action:n,padding:i="md",hover:o=!1,className:c,...d}){return(0,r.jsxs)("div",{className:(0,a.cn)("bg-surface","border border-black/5 dark:border-white/5","rounded-lg shadow-sm",o&&"hover:shadow-md hover:border-primary/30 transition-all cursor-pointer",{none:"",xs:"p-3",sm:"p-4",md:"p-6",lg:"p-8"}[i],c),...d,children:[(t||n)&&(0,r.jsxs)("div",{className:"flex items-center justify-between mb-4",children:[(0,r.jsxs)("div",{className:"flex items-center gap-3",children:[l&&(0,r.jsx)("div",{className:"p-2 rounded-lg bg-bg text-text-muted",children:(0,r.jsx)("span",{className:"material-symbols-outlined text-[20px]",children:l})}),(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})]})]}),n]}),e]})}l.Section=function({children:e,className:t,...s}){return(0,r.jsx)("div",{className:(0,a.cn)("p-4 rounded-lg","bg-black/[0.02] dark:bg-white/[0.02]","border border-black/5 dark:border-white/5",t),...s,children:e})},l.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-black/5 dark:border-white/5 last:border-b-0","hover:bg-black/[0.02] dark:hover:bg-white/[0.02]",t),...s,children:e})},l.ListItem=function({children:e,actions:t,className:s,...l}){return(0,r.jsxs)("div",{className:(0,a.cn)("group flex items-center justify-between p-3 -mx-3 px-3","border-b border-black/[0.03] dark:border-white/[0.03] last:border-b-0","hover:bg-black/[0.02] dark:hover:bg-white/[0.02]","transition-colors",s),...l,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 focus-within:opacity-100 transition-opacity",children:t})]})}},85444:(e,t,s)=>{s.d(t,{default:()=>x});var r=s(95155),a=s(12115),l=s(14051),n=s.n(l),i=s(71361),o=s(81135),c=s(20909);let d=[...Object.keys(c.zN),...Object.keys(c.IS),...Object.keys(c.fg)];function x({isOpen:e,onClose:t,onSelect:s,selectedModel:l,activeProviders:n=[],title:x="Select Model",modelAliases:m={}}){let[u,p]=(0,a.useState)(""),[h,b]=(0,a.useState)([]),[f,g]=(0,a.useState)([]),[y,j]=(0,a.useState)({}),v=async()=>{try{let e=await fetch("/api/combos");if(!e.ok)throw Error(`Failed to fetch combos: ${e.status}`);let t=await e.json();b(t.combos||[])}catch(e){console.error("Error fetching combos:",e),b([])}};(0,a.useEffect)(()=>{e&&v()},[e]);let N=async()=>{try{let e=await fetch("/api/provider-nodes");if(!e.ok)throw Error(`Failed to fetch provider nodes: ${e.status}`);let t=await e.json();g(t.nodes||[])}catch(e){console.error("Error fetching provider nodes:",e),g([])}};(0,a.useEffect)(()=>{e&&N()},[e]);let k=async()=>{try{let e=await fetch("/api/provider-models");if(!e.ok)throw Error(`Failed to fetch custom models: ${e.status}`);let t=await e.json();j(t.models||{})}catch(e){console.error("Error fetching custom models:",e),j({})}};(0,a.useEffect)(()=>{e&&k()},[e]);let w=(0,a.useMemo)(()=>({...c.zN,...c.IS,...c.fg}),[]),C=(0,a.useMemo)(()=>{let e={};return[...new Set([...n.map(e=>e.provider)])].sort((e,t)=>{let s=d.indexOf(e),r=d.indexOf(t);return(-1===s?999:s)-(-1===r?999:r)}).forEach(t=>{let s=o.Xg[t]||t,r=w[t]||{name:t,color:"#666"},a=(0,c.mq)(t)||(0,c.gb)(t),l=y[t]||[];if(r.passthroughModels){let a=Object.entries(m).filter(([,e])=>e.startsWith(`${s}/`)).map(([e,t])=>({id:t.replace(`${s}/`,""),name:e,value:t})),n=l.filter(e=>!a.some(t=>t.id===e.id)).map(e=>({id:e.id,name:e.name||e.id,value:`${s}/${e.id}`,isCustom:!0})),i=[...a,...n];if(i.length>0){let a=f.find(e=>e.id===t),l=a?.name||r.name;e[t]={name:l,alias:s,color:r.color,models:i}}}else if(a){let s=f.find(e=>e.id===t),a=s?.name||r.name,n=s?.prefix||t,i=Object.entries(m).filter(([,e])=>e.startsWith(`${t}/`)).map(([e,s])=>({id:s.replace(`${t}/`,""),name:e,value:`${n}/${s.replace(`${t}/`,"")}`})),o=l.filter(e=>!i.some(t=>t.id===e.id)).map(e=>({id:e.id,name:e.name||e.id,value:`${n}/${e.id}`,isCustom:!0})),c=[...i,...o];c.length>0&&(e[t]={name:a,alias:n,color:r.color,models:c,isCustom:!0,hasModels:!0})}else{let a=(0,o.KC)(t),n=[...a.map(e=>({id:e.id,name:e.name,value:`${s}/${e.id}`})),...l.filter(e=>!a.some(t=>t.id===e.id)).map(e=>({id:e.id,name:e.name||e.id,value:`${s}/${e.id}`,isCustom:!0}))];n.length>0&&(e[t]={name:r.name,alias:s,color:r.color,models:n})}}),e},[n,m,w,f,y]),S=(0,a.useMemo)(()=>{if(!u.trim())return h;let e=u.toLowerCase();return h.filter(t=>t.name.toLowerCase().includes(e))},[h,u]),T=(0,a.useMemo)(()=>{if(!u.trim())return C;let e=u.toLowerCase(),t={};return Object.entries(C).forEach(([s,r])=>{let a=r.models.filter(t=>t.name.toLowerCase().includes(e)||t.id.toLowerCase().includes(e)),l=r.name.toLowerCase().includes(e);(a.length>0||l)&&(t[s]={...r,models:a})}),t},[C,u]),I=e=>{s(e),t(),p("")};return(0,r.jsxs)(i.default,{isOpen:e,onClose:()=>{t(),p("")},title:x,size:"md",className:"p-4!",children:[(0,r.jsx)("div",{className:"mb-3",children:(0,r.jsxs)("div",{className:"relative",children:[(0,r.jsx)("span",{className:"material-symbols-outlined absolute left-2.5 top-1/2 -translate-y-1/2 text-text-muted text-[16px]",children:"search"}),(0,r.jsx)("input",{type:"text",placeholder:"Search...",value:u,onChange:e=>p(e.target.value),className:"w-full pl-8 pr-3 py-1.5 bg-surface border border-border rounded text-xs focus:outline-none focus:ring-1 focus:ring-primary/50"})]})}),(0,r.jsxs)("div",{className:"max-h-[300px] overflow-y-auto space-y-3",children:[S.length>0&&(0,r.jsxs)("div",{children:[(0,r.jsxs)("div",{className:"flex items-center gap-1.5 mb-1.5 sticky top-0 bg-surface py-0.5",children:[(0,r.jsx)("span",{className:"material-symbols-outlined text-primary text-[14px]",children:"layers"}),(0,r.jsx)("span",{className:"text-xs font-medium text-primary",children:"Combos"}),(0,r.jsxs)("span",{className:"text-[10px] text-text-muted",children:["(",S.length,")"]})]}),(0,r.jsx)("div",{className:"flex flex-wrap gap-1.5",children:S.map(e=>{let t=l===e.name;return(0,r.jsx)("button",{onClick:()=>I({id:e.name,name:e.name,value:e.name}),className:`
|
|
16
16
|
px-2 py-1 rounded-xl text-xs font-medium transition-all border hover:cursor-pointer
|
|
17
17
|
${t?"bg-primary text-white border-primary":"bg-surface border-border text-text-main hover:border-primary/50 hover:bg-primary/5"}
|
|
18
18
|
`,children:e.name},e.id)})})]}),Object.entries(T).map(([e,t])=>(0,r.jsxs)("div",{children:[(0,r.jsxs)("div",{className:"flex items-center gap-1.5 mb-1.5 sticky top-0 bg-surface py-0.5",children:[(0,r.jsx)("div",{className:"w-2 h-2 rounded-full",style:{backgroundColor:t.color}}),(0,r.jsx)("span",{className:"text-xs font-medium text-primary",children:t.name}),(0,r.jsxs)("span",{className:"text-[10px] text-text-muted",children:["(",t.models.length,")"]})]}),(0,r.jsx)("div",{className:"flex flex-wrap gap-1.5",children:t.models.map(e=>{let t=l===e.value;return(0,r.jsxs)("button",{onClick:()=>I(e),className:`
|