omniroute 3.4.7 → 3.4.8
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/app/.next/BUILD_ID +1 -1
- package/app/.next/build-manifest.json +3 -3
- package/app/.next/prerender-manifest.json +3 -3
- package/app/.next/server/app/(dashboard)/dashboard/agents/page_client-reference-manifest.js +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_client-reference-manifest.js +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/audit/page_client-reference-manifest.js +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/cache/page_client-reference-manifest.js +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_client-reference-manifest.js +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_client-reference-manifest.js +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_client-reference-manifest.js +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/logs/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/media/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/memory/page_client-reference-manifest.js +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_client-reference-manifest.js +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/playground/page_client-reference-manifest.js +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_client-reference-manifest.js +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/providers/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/search-tools/page_client-reference-manifest.js +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_client-reference-manifest.js +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/skills/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/translator/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/400/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/401/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/403/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/408/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/429/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/500/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/502/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/503/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/_global-error.html +1 -1
- package/app/.next/server/app/_global-error.rsc +1 -1
- package/app/.next/server/app/_global-error.segments/__PAGE__.segment.rsc +1 -1
- package/app/.next/server/app/_global-error.segments/_full.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 +1 -1
- package/app/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
- package/app/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/system/version/route.js.nft.json +1 -1
- package/app/.next/server/app/api/v1/api/chat/route.js +15 -15
- package/app/.next/server/app/api/v1/api/chat/route.js.nft.json +1 -1
- package/app/.next/server/app/api/v1/audio/speech/route.js +11 -11
- package/app/.next/server/app/api/v1/audio/speech/route.js.nft.json +1 -1
- package/app/.next/server/app/api/v1/audio/transcriptions/route.js +5 -5
- package/app/.next/server/app/api/v1/audio/transcriptions/route.js.nft.json +1 -1
- package/app/.next/server/app/api/v1/chat/completions/route.js +14 -14
- package/app/.next/server/app/api/v1/chat/completions/route.js.nft.json +1 -1
- package/app/.next/server/app/api/v1/completions/route.js +14 -14
- package/app/.next/server/app/api/v1/completions/route.js.nft.json +1 -1
- package/app/.next/server/app/api/v1/images/generations/route.js +10 -10
- package/app/.next/server/app/api/v1/images/generations/route.js.nft.json +1 -1
- package/app/.next/server/app/api/v1/messages/route.js +16 -16
- package/app/.next/server/app/api/v1/messages/route.js.nft.json +1 -1
- package/app/.next/server/app/api/v1/models/route.js +5 -5
- package/app/.next/server/app/api/v1/models/route.js.nft.json +1 -1
- package/app/.next/server/app/api/v1/moderations/route.js +9 -9
- package/app/.next/server/app/api/v1/moderations/route.js.nft.json +1 -1
- package/app/.next/server/app/api/v1/music/generations/route.js +10 -10
- package/app/.next/server/app/api/v1/providers/[provider]/chat/completions/route.js +16 -16
- package/app/.next/server/app/api/v1/providers/[provider]/chat/completions/route.js.nft.json +1 -1
- package/app/.next/server/app/api/v1/providers/[provider]/embeddings/route.js +7 -7
- package/app/.next/server/app/api/v1/providers/[provider]/embeddings/route.js.nft.json +1 -1
- package/app/.next/server/app/api/v1/providers/[provider]/images/generations/route.js +10 -10
- package/app/.next/server/app/api/v1/providers/[provider]/images/generations/route.js.nft.json +1 -1
- package/app/.next/server/app/api/v1/rerank/route.js +9 -9
- package/app/.next/server/app/api/v1/rerank/route.js.nft.json +1 -1
- package/app/.next/server/app/api/v1/responses/[...path]/route.js +16 -16
- package/app/.next/server/app/api/v1/responses/[...path]/route.js.nft.json +1 -1
- package/app/.next/server/app/api/v1/responses/route.js +16 -16
- package/app/.next/server/app/api/v1/responses/route.js.nft.json +1 -1
- package/app/.next/server/app/api/v1/route.js +5 -5
- package/app/.next/server/app/api/v1/route.js.nft.json +1 -1
- package/app/.next/server/app/api/v1/search/analytics/route.js +7 -7
- package/app/.next/server/app/api/v1/search/analytics/route.js.nft.json +1 -1
- package/app/.next/server/app/api/v1/videos/generations/route.js +10 -10
- package/app/.next/server/app/api/v1beta/models/[...path]/route.js +14 -14
- package/app/.next/server/app/api/v1beta/models/[...path]/route.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_client-reference-manifest.js +1 -1
- package/app/.next/server/app/forbidden/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/forgot-password/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/landing/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/login/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/maintenance/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/offline/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/privacy/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/status/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/terms/page_client-reference-manifest.js +1 -1
- package/app/.next/server/chunks/{[root-of-the-server]__0nxyldc._.js → [root-of-the-server]__0-zca2p._.js} +1 -1
- package/app/.next/server/chunks/{[root-of-the-server]__0urvs3.._.js → [root-of-the-server]__01hbf~_._.js} +1 -1
- package/app/.next/server/chunks/[root-of-the-server]__01ojood._.js +1 -1
- package/app/.next/server/chunks/[root-of-the-server]__030_-af._.js +1 -1
- package/app/.next/server/chunks/{[root-of-the-server]__0j~-yu1._.js → [root-of-the-server]__03l6k3k._.js} +1 -1
- package/app/.next/server/chunks/{[root-of-the-server]__01b8762._.js → [root-of-the-server]__05~jdzu._.js} +1 -1
- package/app/.next/server/chunks/{[root-of-the-server]__07eee_s._.js → [root-of-the-server]__08~6j3q._.js} +1 -1
- package/app/.next/server/chunks/[root-of-the-server]__0a8ozdb._.js +1 -1
- package/app/.next/server/chunks/[root-of-the-server]__0bd4ccn._.js +2 -2
- package/app/.next/server/chunks/{[root-of-the-server]__0_a98vk._.js → [root-of-the-server]__0d6bqbw._.js} +1 -1
- package/app/.next/server/chunks/{[root-of-the-server]__0_c_.ye._.js → [root-of-the-server]__0f2rz58._.js} +1 -1
- package/app/.next/server/chunks/[root-of-the-server]__0jp3yj4._.js +1 -1
- package/app/.next/server/chunks/{[root-of-the-server]__06stuoz._.js → [root-of-the-server]__0jvnjwl._.js} +1 -1
- package/app/.next/server/chunks/[root-of-the-server]__0mj7x5~._.js +1 -1
- package/app/.next/server/chunks/[root-of-the-server]__0n-~kvf._.js +1 -1
- package/app/.next/server/chunks/{[root-of-the-server]__0-y3k-t._.js → [root-of-the-server]__0nzi7ym._.js} +1 -1
- package/app/.next/server/chunks/[root-of-the-server]__0ofxxzh._.js +2 -2
- package/app/.next/server/chunks/{[root-of-the-server]__0uu3t5x._.js → [root-of-the-server]__0pd~24c._.js} +2 -2
- package/app/.next/server/chunks/[root-of-the-server]__0s1dq3.._.js +1 -1
- package/app/.next/server/chunks/[root-of-the-server]__0tsl88m._.js +1 -1
- package/app/.next/server/chunks/[root-of-the-server]__0u5-mph._.js +1 -1
- package/app/.next/server/chunks/{[root-of-the-server]__0vi3.0k._.js → [root-of-the-server]__0uryxsh._.js} +1 -1
- package/app/.next/server/chunks/{[root-of-the-server]__0lwc40h._.js → [root-of-the-server]__0v1kwmx._.js} +1 -1
- package/app/.next/server/chunks/{[root-of-the-server]__04y3b4q._.js → [root-of-the-server]__0vt49c9._.js} +1 -1
- package/app/.next/server/chunks/{[root-of-the-server]__0pylsu2._.js → [root-of-the-server]__0vy97gy._.js} +2 -2
- package/app/.next/server/chunks/{[root-of-the-server]__0~s45~f._.js → [root-of-the-server]__0wd~o5b._.js} +1 -1
- package/app/.next/server/chunks/[root-of-the-server]__0x5yxjy._.js +2 -2
- package/app/.next/server/chunks/{[root-of-the-server]__0vmajf6._.js → [root-of-the-server]__0x_hqjb._.js} +1 -1
- package/app/.next/server/chunks/[root-of-the-server]__0~0hd.s._.js +2 -2
- package/app/.next/server/chunks/{[root-of-the-server]__10~-ypp._.js → [root-of-the-server]__11ptf~3._.js} +1 -1
- package/app/.next/server/chunks/_00.pgsp._.js +1 -1
- package/app/.next/server/chunks/_013gowh._.js +1 -1
- package/app/.next/server/chunks/{_0ucpa5q._.js → _02._8wx._.js} +1 -1
- package/app/.next/server/chunks/_036lxbr._.js +1 -1
- package/app/.next/server/chunks/_05reh6o._.js +1 -1
- package/app/.next/server/chunks/{_0-~thzo._.js → _083_x9z._.js} +2 -2
- package/app/.next/server/chunks/_083a5zg._.js +1 -1
- package/app/.next/server/chunks/{_004r3br._.js → _08cwbl2._.js} +2 -2
- package/app/.next/server/chunks/_0a3.3sc._.js +1 -1
- package/app/.next/server/chunks/_0c.abwr._.js +1 -1
- package/app/.next/server/chunks/_0dfpto1._.js +1 -1
- package/app/.next/server/chunks/_0due8oe._.js +1 -1
- package/app/.next/server/chunks/_0h-j8c2._.js +1 -1
- package/app/.next/server/chunks/_0vx-r0i._.js +2 -2
- package/app/.next/server/chunks/_0w4f3bm._.js +1 -1
- package/app/.next/server/chunks/_10.rw9f._.js +1 -1
- package/app/.next/server/chunks/open-sse_0dawtxk._.js +2 -2
- package/app/.next/server/chunks/open-sse_0p~.88y._.js +1 -1
- package/app/.next/server/chunks/open-sse_0sthby3._.js +1 -1
- package/app/.next/server/chunks/src_0cbm0~g._.js +1 -1
- package/app/.next/server/chunks/src_shared_utils_apiKey_ts_0gzf59_._.js +1 -1
- package/app/.next/server/chunks/src_shared_utils_apiKey_ts_12~h.oz._.js +1 -1
- package/app/.next/server/chunks/ssr/_008ht2n._.js +1 -1
- package/app/.next/server/chunks/ssr/_0oo1f90._.js +1 -1
- package/app/.next/server/chunks/ssr/src_04s-8a5._.js +1 -1
- package/app/.next/server/chunks/ssr/src_0vjsxxr._.js +1 -1
- package/app/.next/server/chunks/ssr/src_shared_utils_apiKey_ts_0l8g1z8._.js +1 -1
- package/app/.next/server/middleware-build-manifest.js +3 -3
- package/app/.next/server/pages/500.html +1 -1
- 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/0ipwpwjb2g0uv.js +1 -0
- package/app/.next/static/chunks/0~c--kcvaumm~.js +1 -0
- package/app/.next/static/chunks/{02q7h~xz7j6i3.js → 0~v1trn07bitv.js} +1 -1
- package/app/CHANGELOG.md +12 -0
- package/app/bin/reset-password.mjs +3 -1
- package/app/docs/openapi.yaml +1 -1
- package/app/open-sse/config/registryUtils.ts +1 -0
- package/app/open-sse/config/videoRegistry.ts +1 -3
- package/app/open-sse/executors/antigravity.ts +22 -12
- package/app/open-sse/executors/gemini-cli.ts +3 -1
- package/app/open-sse/executors/qoder.ts +1 -8
- package/app/open-sse/handlers/audioSpeech.ts +1 -0
- package/app/open-sse/handlers/chatCore.ts +2 -1
- package/app/open-sse/handlers/embeddings.ts +1 -0
- package/app/open-sse/handlers/imageGeneration.ts +6 -2
- package/app/open-sse/handlers/musicGeneration.ts +9 -2
- package/app/open-sse/handlers/search.ts +1 -0
- package/app/open-sse/handlers/videoGeneration.ts +11 -3
- package/app/open-sse/mcp-server/index.ts +0 -1
- package/app/open-sse/package.json +1 -1
- package/app/open-sse/services/claudeCodeCompatible.ts +2 -2
- package/app/open-sse/services/modelCapabilities.ts +3 -4
- package/app/open-sse/services/qoderCli.ts +5 -2
- package/app/open-sse/services/tokenRefresh.ts +3 -1
- package/app/open-sse/services/usage.ts +13 -9
- package/app/open-sse/services/workflowFSM.ts +298 -61
- package/app/open-sse/translator/index.ts +5 -1
- package/app/open-sse/translator/response/gemini-to-openai.ts +5 -1
- package/app/open-sse/utils/progressTracker.ts +4 -1
- package/app/open-sse/utils/stream.ts +7 -1
- package/app/open-sse/utils/streamPayloadCollector.ts +5 -1
- package/app/package-lock.json +3 -3
- package/app/package.json +1 -1
- package/app/scripts/check-route-validation.mjs +3 -1
- package/app/scripts/i18n/apply-priority-overrides.mjs +7 -1
- package/app/scripts/prepublish.mjs +2 -2
- package/app/scripts/run-protocol-clients-tests.mjs +7 -1
- package/app/src/app/(dashboard)/dashboard/analytics/components/DiversityScoreCard.tsx +1 -1
- package/app/src/app/(dashboard)/dashboard/auto-combo/page.tsx +0 -1
- package/app/src/app/(dashboard)/dashboard/media/MediaPageClient.tsx +9 -3
- package/app/src/app/(dashboard)/dashboard/providers/[id]/page.tsx +25 -23
- package/app/src/app/(dashboard)/dashboard/search-tools/components/SearchHistory.tsx +3 -1
- package/app/src/app/api/auth/status/route.ts +1 -3
- package/app/src/app/api/mcp/sse/route.ts +2 -2
- package/app/src/app/api/mcp/status/route.ts +1 -2
- package/app/src/app/api/mcp/stream/route.ts +5 -3
- package/app/src/app/api/openapi/spec/route.ts +4 -1
- package/app/src/app/api/openapi/try/route.ts +4 -1
- package/app/src/app/api/providers/[id]/models/route.ts +4 -4
- package/app/src/app/api/providers/[id]/sync-models/route.ts +9 -3
- package/app/src/app/api/settings/auto-disable-accounts/route.ts +6 -1
- package/app/src/app/api/skills/[id]/route.ts +4 -1
- package/app/src/app/api/v1/issues/report/route.ts +9 -1
- package/app/src/app/api/v1beta/models/route.ts +8 -6
- package/app/src/app/api/webhooks/[id]/route.ts +9 -7
- package/app/src/domain/fallbackPolicy.ts +0 -1
- package/app/src/domain/modelAvailability.ts +0 -1
- package/app/src/domain/providerExpiration.ts +2 -6
- package/app/src/lib/db/models.ts +23 -13
- package/app/src/lib/evals/evalRunner.ts +0 -1
- package/app/src/lib/evals/scheduler.ts +2 -6
- package/app/src/lib/oauth/services/antigravity.ts +6 -1
- package/app/src/lib/oauth/services/kiro.ts +12 -2
- package/app/src/lib/oauth/services/oauth.ts +10 -2
- package/app/src/lib/oauth/utils/server.ts +4 -1
- package/app/src/lib/plugins/index.ts +2 -8
- package/app/src/lib/usageAnalytics.ts +5 -1
- package/app/src/mitm/manager.js +1 -1
- package/app/src/mitm/manager.ts +1 -1
- package/app/src/shared/components/Button.tsx +0 -1
- package/app/src/shared/components/Card.tsx +0 -2
- package/app/src/shared/components/FilterBar.tsx +4 -12
- package/app/src/shared/components/Input.tsx +1 -1
- package/app/src/shared/components/Modal.tsx +0 -1
- package/app/src/shared/components/NotificationToast.tsx +1 -3
- package/app/src/shared/components/Select.tsx +1 -1
- package/app/src/shared/components/Sidebar.tsx +3 -3
- package/app/src/shared/components/ThemeToggle.tsx +7 -1
- package/app/src/shared/constants/cliCompatProviders.ts +0 -1
- package/app/src/shared/constants/errorCodes.ts +114 -19
- package/app/src/shared/utils/apiKey.ts +2 -4
- package/app/src/shared/utils/fetchTimeout.ts +0 -1
- package/app/src/shared/utils/inputSanitizer.ts +8 -4
- package/app/src/shared/utils/requestTimeout.ts +5 -1
- package/app/src/sse/handlers/chat.ts +1 -0
- package/app/src/sse/services/auth.ts +8 -3
- package/app/src/sse/services/streamState.ts +5 -1
- package/app/src/store/notificationStore.ts +3 -7
- package/app/tests/unit/t20-t22-provider-headers.test.mjs +3 -1
- package/bin/reset-password.mjs +3 -1
- package/open-sse/mcp-server/__tests__/glmCodingProviderConfig.test.ts +5 -1
- package/open-sse/mcp-server/index.ts +0 -1
- package/package.json +1 -1
- package/app/.next/server/chunks/_0-jnvci._.js +0 -19
- package/app/.next/static/chunks/0l88mho31mflv.js +0 -1
- package/app/.next/static/chunks/0wt-4zl7_gil8.js +0 -1
- /package/app/.next/static/{ri1SkwBU-ygQ2qIDe8jf2 → 1dZBzAZ8QsddVCQRQtqjg}/_buildManifest.js +0 -0
- /package/app/.next/static/{ri1SkwBU-ygQ2qIDe8jf2 → 1dZBzAZ8QsddVCQRQtqjg}/_clientMiddlewareManifest.js +0 -0
- /package/app/.next/static/{ri1SkwBU-ygQ2qIDe8jf2 → 1dZBzAZ8QsddVCQRQtqjg}/_ssgManifest.js +0 -0
|
@@ -7,9 +7,9 @@ globalThis.__BUILD_MANIFEST = {
|
|
|
7
7
|
"static/chunks/03~yq9q893hmn.js"
|
|
8
8
|
],
|
|
9
9
|
"lowPriorityFiles": [
|
|
10
|
-
"static/
|
|
11
|
-
"static/
|
|
12
|
-
"static/
|
|
10
|
+
"static/1dZBzAZ8QsddVCQRQtqjg/_buildManifest.js",
|
|
11
|
+
"static/1dZBzAZ8QsddVCQRQtqjg/_ssgManifest.js",
|
|
12
|
+
"static/1dZBzAZ8QsddVCQRQtqjg/_clientMiddlewareManifest.js"
|
|
13
13
|
],
|
|
14
14
|
"rootMainFiles": [
|
|
15
15
|
"static/chunks/07lylitgaz596.js",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
<!DOCTYPE html><html id="__next_error__"><head><meta charSet="utf-8"/><meta name="viewport" content="width=device-width, initial-scale=1"/><link rel="preload" as="script" fetchPriority="low" href="/_next/static/chunks/07lylitgaz596.js"/><script src="/_next/static/chunks/0g_yb3-pl~ns..js" async=""></script><script src="/_next/static/chunks/0nruvzde59sj5.js" async=""></script><script src="/_next/static/chunks/0rwwge57xnfls.js" async=""></script><script src="/_next/static/chunks/0o2pg6lyby.wf.js" async=""></script><script src="/_next/static/chunks/0tfxau8c~fd3q.js" async=""></script><script src="/_next/static/chunks/turbopack-0333xpy5f4avs.js" async=""></script><script src="/_next/static/chunks/0as7t_2a3t3mc.js" async=""></script><script src="/_next/static/chunks/0h8ea52.j.8fg.js" async=""></script><meta name="next-size-adjust" content=""/><title>500: This page couldn’t load</title><style>:root {--next-error-bg: #fff;--next-error-text: #171717;--next-error-title: #171717;--next-error-message: #171717;--next-error-digest: #666666;--next-error-btn-text: #fff;--next-error-btn-bg: #171717;--next-error-btn-border: none;--next-error-btn-secondary-text: #171717;--next-error-btn-secondary-bg: transparent;--next-error-btn-secondary-border: 1px solid rgba(0,0,0,0.08);}@media (prefers-color-scheme: dark) {:root {--next-error-bg: #0a0a0a;--next-error-text: #ededed;--next-error-title: #ededed;--next-error-message: #ededed;--next-error-digest: #a0a0a0;--next-error-btn-text: #0a0a0a;--next-error-btn-bg: #ededed;--next-error-btn-border: none;--next-error-btn-secondary-text: #ededed;--next-error-btn-secondary-bg: transparent;--next-error-btn-secondary-border: 1px solid rgba(255,255,255,0.14);}}body { margin: 0; color: var(--next-error-text); background: var(--next-error-bg); }</style><script src="/_next/static/chunks/03~yq9q893hmn.js" noModule=""></script></head><body><div hidden=""><!--$--><!--/$--></div><div style="font-family:system-ui,"Segoe UI",Roboto,Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji";height:100vh;display:flex;align-items:center;justify-content:center"><div style="margin-top:-32px;max-width:325px;padding:32px 28px;text-align:left"><svg width="32" height="32" viewBox="-0.2 -1.5 32 32" fill="none" style="margin-bottom:24px"><path d="M16.9328 0C18.0839 0.000116771 19.1334 0.658832 19.634 1.69531L31.4299 26.1309C32.0708 27.4588 31.1036 28.9999 29.6291 29H2.00215C0.527541 29 -0.439628 27.4588 0.201371 26.1309L11.9973 1.69531C12.4979 0.658823 13.5474 7.75066e-05 14.6984 0H16.9328ZM3.59493 26H28.0363L16.9328 3H14.6984L3.59493 26ZM15.8156 19C16.9202 19.0001 17.8156 19.8955 17.8156 21C17.8156 22.1045 16.9202 22.9999 15.8156 23C14.7111 23 13.8156 22.1046 13.8156 21C13.8156 19.8954 14.7111 19 15.8156 19ZM17.3156 16.5H14.3156V8.5H17.3156V16.5Z" fill="var(--next-error-title)"></path></svg><h1 style="font-size:24px;font-weight:500;letter-spacing:-0.02em;line-height:32px;margin:0 0 12px 0;color:var(--next-error-title)">This page couldn’t load</h1><p style="font-size:14px;font-weight:400;line-height:21px;margin:0 0 20px 0;color:var(--next-error-message)">A server error occurred. Reload to try again.</p><form style="margin:0"><button type="submit" style="display:inline-flex;align-items:center;justify-content:center;height:32px;padding:0 12px;font-size:14px;font-weight:500;line-height:20px;border-radius:6px;cursor:pointer;color:var(--next-error-btn-text);background:var(--next-error-btn-bg);border:var(--next-error-btn-border)">Reload</button></form></div></div><!--$--><!--/$--><script src="/_next/static/chunks/07lylitgaz596.js" id="_R_" async=""></script><script>(self.__next_f=self.__next_f||[]).push([0])</script><script>self.__next_f.push([1,"1:\"$Sreact.fragment\"\n2:I[339756,[\"/_next/static/chunks/0as7t_2a3t3mc.js\",\"/_next/static/chunks/0h8ea52.j.8fg.js\"],\"default\"]\n3:I[837457,[\"/_next/static/chunks/0as7t_2a3t3mc.js\",\"/_next/static/chunks/0h8ea52.j.8fg.js\"],\"default\"]\n4:I[897367,[\"/_next/static/chunks/0as7t_2a3t3mc.js\",\"/_next/static/chunks/0h8ea52.j.8fg.js\"],\"OutletBoundary\"]\n5:\"$Sreact.suspense\"\n8:I[897367,[\"/_next/static/chunks/0as7t_2a3t3mc.js\",\"/_next/static/chunks/0h8ea52.j.8fg.js\"],\"ViewportBoundary\"]\na:I[897367,[\"/_next/static/chunks/0as7t_2a3t3mc.js\",\"/_next/static/chunks/0h8ea52.j.8fg.js\"],\"MetadataBoundary\"]\nc:I[563491,[\"/_next/static/chunks/0as7t_2a3t3mc.js\",\"/_next/static/chunks/0h8ea52.j.8fg.js\"],\"default\"]\n"])</script><script>self.__next_f.push([1,"0:{\"P\":null,\"c\":[\"\",\"_global-error\"],\"q\":\"\",\"i\":false,\"f\":[[[\"\",{\"children\":[\"__PAGE__\",{}]}],[[\"$\",\"$1\",\"c\",{\"children\":[null,[\"$\",\"$L2\",null,{\"parallelRouterKey\":\"children\",\"error\":\"$undefined\",\"errorStyles\":\"$undefined\",\"errorScripts\":\"$undefined\",\"template\":[\"$\",\"$L3\",null,{}],\"templateStyles\":\"$undefined\",\"templateScripts\":\"$undefined\",\"notFound\":\"$undefined\",\"forbidden\":\"$undefined\",\"unauthorized\":\"$undefined\"}]]}],{\"children\":[[\"$\",\"$1\",\"c\",{\"children\":[[\"$\",\"html\",null,{\"id\":\"__next_error__\",\"children\":[[\"$\",\"head\",null,{\"children\":[[\"$\",\"title\",null,{\"children\":\"500: This page couldn’t load\"}],[\"$\",\"style\",null,{\"dangerouslySetInnerHTML\":{\"__html\":\":root {--next-error-bg: #fff;--next-error-text: #171717;--next-error-title: #171717;--next-error-message: #171717;--next-error-digest: #666666;--next-error-btn-text: #fff;--next-error-btn-bg: #171717;--next-error-btn-border: none;--next-error-btn-secondary-text: #171717;--next-error-btn-secondary-bg: transparent;--next-error-btn-secondary-border: 1px solid rgba(0,0,0,0.08);}@media (prefers-color-scheme: dark) {:root {--next-error-bg: #0a0a0a;--next-error-text: #ededed;--next-error-title: #ededed;--next-error-message: #ededed;--next-error-digest: #a0a0a0;--next-error-btn-text: #0a0a0a;--next-error-btn-bg: #ededed;--next-error-btn-border: none;--next-error-btn-secondary-text: #ededed;--next-error-btn-secondary-bg: transparent;--next-error-btn-secondary-border: 1px solid rgba(255,255,255,0.14);}}body { margin: 0; color: var(--next-error-text); background: var(--next-error-bg); }\"}}]]}],[\"$\",\"body\",null,{\"children\":[\"$\",\"div\",null,{\"style\":{\"fontFamily\":\"system-ui,\\\"Segoe UI\\\",Roboto,Helvetica,Arial,sans-serif,\\\"Apple Color Emoji\\\",\\\"Segoe UI Emoji\\\"\",\"height\":\"100vh\",\"display\":\"flex\",\"alignItems\":\"center\",\"justifyContent\":\"center\"},\"children\":[\"$\",\"div\",null,{\"style\":{\"marginTop\":\"-32px\",\"maxWidth\":\"325px\",\"padding\":\"32px 28px\",\"textAlign\":\"left\"},\"children\":[[\"$\",\"svg\",null,{\"width\":\"32\",\"height\":\"32\",\"viewBox\":\"-0.2 -1.5 32 32\",\"fill\":\"none\",\"style\":{\"marginBottom\":\"24px\"},\"children\":[\"$\",\"path\",null,{\"d\":\"M16.9328 0C18.0839 0.000116771 19.1334 0.658832 19.634 1.69531L31.4299 26.1309C32.0708 27.4588 31.1036 28.9999 29.6291 29H2.00215C0.527541 29 -0.439628 27.4588 0.201371 26.1309L11.9973 1.69531C12.4979 0.658823 13.5474 7.75066e-05 14.6984 0H16.9328ZM3.59493 26H28.0363L16.9328 3H14.6984L3.59493 26ZM15.8156 19C16.9202 19.0001 17.8156 19.8955 17.8156 21C17.8156 22.1045 16.9202 22.9999 15.8156 23C14.7111 23 13.8156 22.1046 13.8156 21C13.8156 19.8954 14.7111 19 15.8156 19ZM17.3156 16.5H14.3156V8.5H17.3156V16.5Z\",\"fill\":\"var(--next-error-title)\"}]}],[\"$\",\"h1\",null,{\"style\":{\"fontSize\":\"24px\",\"fontWeight\":500,\"letterSpacing\":\"-0.02em\",\"lineHeight\":\"32px\",\"margin\":\"0 0 12px 0\",\"color\":\"var(--next-error-title)\"},\"children\":\"This page couldn’t load\"}],[\"$\",\"p\",null,{\"style\":{\"fontSize\":\"14px\",\"fontWeight\":400,\"lineHeight\":\"21px\",\"margin\":\"0 0 20px 0\",\"color\":\"var(--next-error-message)\"},\"children\":\"A server error occurred. Reload to try again.\"}],[\"$\",\"form\",null,{\"style\":{\"margin\":0},\"children\":[\"$\",\"button\",null,{\"type\":\"submit\",\"style\":{\"display\":\"inline-flex\",\"alignItems\":\"center\",\"justifyContent\":\"center\",\"height\":\"32px\",\"padding\":\"0 12px\",\"fontSize\":\"14px\",\"fontWeight\":500,\"lineHeight\":\"20px\",\"borderRadius\":\"6px\",\"cursor\":\"pointer\",\"color\":\"var(--next-error-btn-text)\",\"background\":\"var(--next-error-btn-bg)\",\"border\":\"var(--next-error-btn-border)\"},\"children\":\"Reload\"}]}]]}]}]}]]}],null,[\"$\",\"$L4\",null,{\"children\":[\"$\",\"$5\",null,{\"name\":\"Next.MetadataOutlet\",\"children\":\"$@6\"}]}]]}],{},null,false,null]},null,false,\"$@7\"],[\"$\",\"$1\",\"h\",{\"children\":[null,[\"$\",\"$L8\",null,{\"children\":\"$L9\"}],[\"$\",\"div\",null,{\"hidden\":true,\"children\":[\"$\",\"$La\",null,{\"children\":[\"$\",\"$5\",null,{\"name\":\"Next.Metadata\",\"children\":\"$Lb\"}]}]}],[\"$\",\"meta\",null,{\"name\":\"next-size-adjust\",\"content\":\"\"}]]}],false]],\"m\":\"$undefined\",\"G\":[\"$c\",[]],\"S\":true,\"h\":null,\"s\":\"$undefined\",\"l\":\"$undefined\",\"p\":\"$undefined\",\"d\":\"$undefined\",\"b\":\"
|
|
1
|
+
<!DOCTYPE html><html id="__next_error__"><head><meta charSet="utf-8"/><meta name="viewport" content="width=device-width, initial-scale=1"/><link rel="preload" as="script" fetchPriority="low" href="/_next/static/chunks/07lylitgaz596.js"/><script src="/_next/static/chunks/0g_yb3-pl~ns..js" async=""></script><script src="/_next/static/chunks/0nruvzde59sj5.js" async=""></script><script src="/_next/static/chunks/0rwwge57xnfls.js" async=""></script><script src="/_next/static/chunks/0o2pg6lyby.wf.js" async=""></script><script src="/_next/static/chunks/0tfxau8c~fd3q.js" async=""></script><script src="/_next/static/chunks/turbopack-0333xpy5f4avs.js" async=""></script><script src="/_next/static/chunks/0as7t_2a3t3mc.js" async=""></script><script src="/_next/static/chunks/0h8ea52.j.8fg.js" async=""></script><meta name="next-size-adjust" content=""/><title>500: This page couldn’t load</title><style>:root {--next-error-bg: #fff;--next-error-text: #171717;--next-error-title: #171717;--next-error-message: #171717;--next-error-digest: #666666;--next-error-btn-text: #fff;--next-error-btn-bg: #171717;--next-error-btn-border: none;--next-error-btn-secondary-text: #171717;--next-error-btn-secondary-bg: transparent;--next-error-btn-secondary-border: 1px solid rgba(0,0,0,0.08);}@media (prefers-color-scheme: dark) {:root {--next-error-bg: #0a0a0a;--next-error-text: #ededed;--next-error-title: #ededed;--next-error-message: #ededed;--next-error-digest: #a0a0a0;--next-error-btn-text: #0a0a0a;--next-error-btn-bg: #ededed;--next-error-btn-border: none;--next-error-btn-secondary-text: #ededed;--next-error-btn-secondary-bg: transparent;--next-error-btn-secondary-border: 1px solid rgba(255,255,255,0.14);}}body { margin: 0; color: var(--next-error-text); background: var(--next-error-bg); }</style><script src="/_next/static/chunks/03~yq9q893hmn.js" noModule=""></script></head><body><div hidden=""><!--$--><!--/$--></div><div style="font-family:system-ui,"Segoe UI",Roboto,Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji";height:100vh;display:flex;align-items:center;justify-content:center"><div style="margin-top:-32px;max-width:325px;padding:32px 28px;text-align:left"><svg width="32" height="32" viewBox="-0.2 -1.5 32 32" fill="none" style="margin-bottom:24px"><path d="M16.9328 0C18.0839 0.000116771 19.1334 0.658832 19.634 1.69531L31.4299 26.1309C32.0708 27.4588 31.1036 28.9999 29.6291 29H2.00215C0.527541 29 -0.439628 27.4588 0.201371 26.1309L11.9973 1.69531C12.4979 0.658823 13.5474 7.75066e-05 14.6984 0H16.9328ZM3.59493 26H28.0363L16.9328 3H14.6984L3.59493 26ZM15.8156 19C16.9202 19.0001 17.8156 19.8955 17.8156 21C17.8156 22.1045 16.9202 22.9999 15.8156 23C14.7111 23 13.8156 22.1046 13.8156 21C13.8156 19.8954 14.7111 19 15.8156 19ZM17.3156 16.5H14.3156V8.5H17.3156V16.5Z" fill="var(--next-error-title)"></path></svg><h1 style="font-size:24px;font-weight:500;letter-spacing:-0.02em;line-height:32px;margin:0 0 12px 0;color:var(--next-error-title)">This page couldn’t load</h1><p style="font-size:14px;font-weight:400;line-height:21px;margin:0 0 20px 0;color:var(--next-error-message)">A server error occurred. Reload to try again.</p><form style="margin:0"><button type="submit" style="display:inline-flex;align-items:center;justify-content:center;height:32px;padding:0 12px;font-size:14px;font-weight:500;line-height:20px;border-radius:6px;cursor:pointer;color:var(--next-error-btn-text);background:var(--next-error-btn-bg);border:var(--next-error-btn-border)">Reload</button></form></div></div><!--$--><!--/$--><script src="/_next/static/chunks/07lylitgaz596.js" id="_R_" async=""></script><script>(self.__next_f=self.__next_f||[]).push([0])</script><script>self.__next_f.push([1,"1:\"$Sreact.fragment\"\n2:I[339756,[\"/_next/static/chunks/0as7t_2a3t3mc.js\",\"/_next/static/chunks/0h8ea52.j.8fg.js\"],\"default\"]\n3:I[837457,[\"/_next/static/chunks/0as7t_2a3t3mc.js\",\"/_next/static/chunks/0h8ea52.j.8fg.js\"],\"default\"]\n4:I[897367,[\"/_next/static/chunks/0as7t_2a3t3mc.js\",\"/_next/static/chunks/0h8ea52.j.8fg.js\"],\"OutletBoundary\"]\n5:\"$Sreact.suspense\"\n8:I[897367,[\"/_next/static/chunks/0as7t_2a3t3mc.js\",\"/_next/static/chunks/0h8ea52.j.8fg.js\"],\"ViewportBoundary\"]\na:I[897367,[\"/_next/static/chunks/0as7t_2a3t3mc.js\",\"/_next/static/chunks/0h8ea52.j.8fg.js\"],\"MetadataBoundary\"]\nc:I[563491,[\"/_next/static/chunks/0as7t_2a3t3mc.js\",\"/_next/static/chunks/0h8ea52.j.8fg.js\"],\"default\"]\n"])</script><script>self.__next_f.push([1,"0:{\"P\":null,\"c\":[\"\",\"_global-error\"],\"q\":\"\",\"i\":false,\"f\":[[[\"\",{\"children\":[\"__PAGE__\",{}]}],[[\"$\",\"$1\",\"c\",{\"children\":[null,[\"$\",\"$L2\",null,{\"parallelRouterKey\":\"children\",\"error\":\"$undefined\",\"errorStyles\":\"$undefined\",\"errorScripts\":\"$undefined\",\"template\":[\"$\",\"$L3\",null,{}],\"templateStyles\":\"$undefined\",\"templateScripts\":\"$undefined\",\"notFound\":\"$undefined\",\"forbidden\":\"$undefined\",\"unauthorized\":\"$undefined\"}]]}],{\"children\":[[\"$\",\"$1\",\"c\",{\"children\":[[\"$\",\"html\",null,{\"id\":\"__next_error__\",\"children\":[[\"$\",\"head\",null,{\"children\":[[\"$\",\"title\",null,{\"children\":\"500: This page couldn’t load\"}],[\"$\",\"style\",null,{\"dangerouslySetInnerHTML\":{\"__html\":\":root {--next-error-bg: #fff;--next-error-text: #171717;--next-error-title: #171717;--next-error-message: #171717;--next-error-digest: #666666;--next-error-btn-text: #fff;--next-error-btn-bg: #171717;--next-error-btn-border: none;--next-error-btn-secondary-text: #171717;--next-error-btn-secondary-bg: transparent;--next-error-btn-secondary-border: 1px solid rgba(0,0,0,0.08);}@media (prefers-color-scheme: dark) {:root {--next-error-bg: #0a0a0a;--next-error-text: #ededed;--next-error-title: #ededed;--next-error-message: #ededed;--next-error-digest: #a0a0a0;--next-error-btn-text: #0a0a0a;--next-error-btn-bg: #ededed;--next-error-btn-border: none;--next-error-btn-secondary-text: #ededed;--next-error-btn-secondary-bg: transparent;--next-error-btn-secondary-border: 1px solid rgba(255,255,255,0.14);}}body { margin: 0; color: var(--next-error-text); background: var(--next-error-bg); }\"}}]]}],[\"$\",\"body\",null,{\"children\":[\"$\",\"div\",null,{\"style\":{\"fontFamily\":\"system-ui,\\\"Segoe UI\\\",Roboto,Helvetica,Arial,sans-serif,\\\"Apple Color Emoji\\\",\\\"Segoe UI Emoji\\\"\",\"height\":\"100vh\",\"display\":\"flex\",\"alignItems\":\"center\",\"justifyContent\":\"center\"},\"children\":[\"$\",\"div\",null,{\"style\":{\"marginTop\":\"-32px\",\"maxWidth\":\"325px\",\"padding\":\"32px 28px\",\"textAlign\":\"left\"},\"children\":[[\"$\",\"svg\",null,{\"width\":\"32\",\"height\":\"32\",\"viewBox\":\"-0.2 -1.5 32 32\",\"fill\":\"none\",\"style\":{\"marginBottom\":\"24px\"},\"children\":[\"$\",\"path\",null,{\"d\":\"M16.9328 0C18.0839 0.000116771 19.1334 0.658832 19.634 1.69531L31.4299 26.1309C32.0708 27.4588 31.1036 28.9999 29.6291 29H2.00215C0.527541 29 -0.439628 27.4588 0.201371 26.1309L11.9973 1.69531C12.4979 0.658823 13.5474 7.75066e-05 14.6984 0H16.9328ZM3.59493 26H28.0363L16.9328 3H14.6984L3.59493 26ZM15.8156 19C16.9202 19.0001 17.8156 19.8955 17.8156 21C17.8156 22.1045 16.9202 22.9999 15.8156 23C14.7111 23 13.8156 22.1046 13.8156 21C13.8156 19.8954 14.7111 19 15.8156 19ZM17.3156 16.5H14.3156V8.5H17.3156V16.5Z\",\"fill\":\"var(--next-error-title)\"}]}],[\"$\",\"h1\",null,{\"style\":{\"fontSize\":\"24px\",\"fontWeight\":500,\"letterSpacing\":\"-0.02em\",\"lineHeight\":\"32px\",\"margin\":\"0 0 12px 0\",\"color\":\"var(--next-error-title)\"},\"children\":\"This page couldn’t load\"}],[\"$\",\"p\",null,{\"style\":{\"fontSize\":\"14px\",\"fontWeight\":400,\"lineHeight\":\"21px\",\"margin\":\"0 0 20px 0\",\"color\":\"var(--next-error-message)\"},\"children\":\"A server error occurred. Reload to try again.\"}],[\"$\",\"form\",null,{\"style\":{\"margin\":0},\"children\":[\"$\",\"button\",null,{\"type\":\"submit\",\"style\":{\"display\":\"inline-flex\",\"alignItems\":\"center\",\"justifyContent\":\"center\",\"height\":\"32px\",\"padding\":\"0 12px\",\"fontSize\":\"14px\",\"fontWeight\":500,\"lineHeight\":\"20px\",\"borderRadius\":\"6px\",\"cursor\":\"pointer\",\"color\":\"var(--next-error-btn-text)\",\"background\":\"var(--next-error-btn-bg)\",\"border\":\"var(--next-error-btn-border)\"},\"children\":\"Reload\"}]}]]}]}]}]]}],null,[\"$\",\"$L4\",null,{\"children\":[\"$\",\"$5\",null,{\"name\":\"Next.MetadataOutlet\",\"children\":\"$@6\"}]}]]}],{},null,false,null]},null,false,\"$@7\"],[\"$\",\"$1\",\"h\",{\"children\":[null,[\"$\",\"$L8\",null,{\"children\":\"$L9\"}],[\"$\",\"div\",null,{\"hidden\":true,\"children\":[\"$\",\"$La\",null,{\"children\":[\"$\",\"$5\",null,{\"name\":\"Next.Metadata\",\"children\":\"$Lb\"}]}]}],[\"$\",\"meta\",null,{\"name\":\"next-size-adjust\",\"content\":\"\"}]]}],false]],\"m\":\"$undefined\",\"G\":[\"$c\",[]],\"S\":true,\"h\":null,\"s\":\"$undefined\",\"l\":\"$undefined\",\"p\":\"$undefined\",\"d\":\"$undefined\",\"b\":\"1dZBzAZ8QsddVCQRQtqjg\"}\n"])</script><script>self.__next_f.push([1,"d:[]\n7:\"$Wd\"\n"])</script><script>self.__next_f.push([1,"9:[[\"$\",\"meta\",\"0\",{\"charSet\":\"utf-8\"}],[\"$\",\"meta\",\"1\",{\"name\":\"viewport\",\"content\":\"width=device-width, initial-scale=1\"}]]\n"])</script><script>self.__next_f.push([1,"6:null\nb:[]\n"])</script></body></html>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
self.__RSC_SERVER_MANIFEST="{\n \"node\": {},\n \"edge\": {},\n \"encryptionKey\": \"
|
|
1
|
+
self.__RSC_SERVER_MANIFEST="{\n \"node\": {},\n \"edge\": {},\n \"encryptionKey\": \"wkGRa/JYZoIxXv+T6B1HOHC4VJAAtFU/2vsv7wxCctE=\"\n}"
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,463082,e=>{"use strict";var t=e.i(843476),a=e.i(271645);e.i(565650);var s=e.i(566770),s=s,r=e.i(454149),l=e.i(643953),i=e.i(948148),n=e.i(11477),c=e.i(474078),o=e.i(11131),d=e.i(115243),d=d,m=e.i(690777),m=m,x=e.i(627949);let u=[{name:"contains",labelKey:"evalsStrategyContainsLabel",icon:"search",color:"text-sky-400",bg:"bg-sky-500/10",descriptionKey:"evalsStrategyContainsDescription"},{name:"exact",labelKey:"evalsStrategyExactLabel",icon:"check_circle",color:"text-emerald-400",bg:"bg-emerald-500/10",descriptionKey:"evalsStrategyExactDescription"},{name:"regex",labelKey:"evalsStrategyRegexLabel",icon:"code",color:"text-amber-400",bg:"bg-amber-500/10",descriptionKey:"evalsStrategyRegexDescription"},{name:"custom",labelKey:"evalsStrategyCustomLabel",icon:"tune",color:"text-violet-400",bg:"bg-violet-500/10",descriptionKey:"evalsStrategyCustomDescription"}];function h(){let e=(0,i.useTranslations)("usage"),[s,r]=(0,a.useState)([]),[l,h]=(0,a.useState)(null),[f,g]=(0,a.useState)(!0),[b,v]=(0,a.useState)(null),[j,y]=(0,a.useState)({current:0,total:0}),[N,w]=(0,a.useState)({}),[k,S]=(0,a.useState)(""),[C,E]=(0,a.useState)(null),[O,P]=(0,a.useState)(!1),A=(0,x.useNotificationStore)(),D=(0,a.useCallback)(async()=>{try{let e=await fetch("/api/evals");if(e.ok){let t=await e.json();r(Array.isArray(t)?t:t.suites||[])}}catch{}finally{g(!1)}},[]),T=(0,a.useCallback)(async()=>{try{let e=await fetch("/api/keys");if(!e.ok)return;let t=await e.json(),a=t?.keys?.[0]?.key||null;h(a)}catch{}},[]);(0,a.useEffect)(()=>{D(),T()},[D,T]);let z=async e=>{try{let t={"Content-Type":"application/json"};l&&(t.Authorization=`Bearer ${l}`);let a=await fetch("/v1/chat/completions",{method:"POST",headers:t,body:JSON.stringify({model:e.model||"gpt-4o",messages:e.input?.messages||[],max_tokens:512,stream:!1})});if(!a.ok)return`[ERROR: HTTP ${a.status}]`;let s=await a.json();return s.choices?.[0]?.message?.content||"[No content returned]"}catch(e){return`[ERROR: ${e.message}]`}},R=async t=>{let a=t.cases||[];if(0===a.length)return void A.warning(e("notifyNoTestCases"));v(t.id),y({current:0,total:a.length});try{let s={};for(let e=0;e<a.length;e++){y({current:e+1,total:a.length});let t=await z(a[e]);s[a[e].id]=t}let r=await fetch("/api/evals",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({suiteId:t.id,outputs:s})}),l=await r.json();if(w(e=>({...e,[t.id]:l})),l.summary){let{passed:a,failed:s,total:r}=l.summary;0===s?A.success(e("notifyAllCasesPassed",{total:r}),e("notifyEvalTitle",{name:t.name||t.id})):A.warning(e("notifySomeCasesFailed",{passed:a,total:r,failed:s}),e("notifyEvalTitle",{name:t.name||t.id}))}E(t.id)}catch{A.error(e("notifyEvalRunFailed"))}finally{v(null),y({current:0,total:0})}},L=s.filter(e=>!k||e.name?.toLowerCase().includes(k.toLowerCase())||e.id?.toLowerCase().includes(k.toLowerCase())),M=s.reduce((e,t)=>e+(t.cases?.length||t.caseCount||0),0),$=[...new Set(s.flatMap(e=>(e.cases||[]).map(e=>e.model)).filter(Boolean))];if(f)return(0,t.jsxs)("div",{className:"flex items-center gap-2 text-text-muted p-8 animate-pulse",children:[(0,t.jsx)("span",{className:"material-symbols-outlined text-[20px]",children:"science"}),e("evalsLoading")]});if(0===s.length)return(0,t.jsxs)("div",{className:"flex flex-col gap-6",children:[(0,t.jsx)(p,{t:e}),(0,t.jsx)(o.EmptyState,{icon:"science",title:e("noEvalSuitesFound"),description:e("noEvalSuitesDescription")})]});let q=[{key:"caseName",label:e("columnCase")},{key:"status",label:e("columnStatus")},{key:"durationMs",label:e("columnLatency")},{key:"details",label:e("columnDetails")}];return(0,t.jsxs)("div",{className:"flex flex-col gap-6",children:[(0,t.jsx)(p,{t:e}),(0,t.jsxs)("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-3",children:[(0,t.jsxs)(n.Card,{className:"px-4 py-3 text-center",children:[(0,t.jsx)("span",{className:"text-xs text-text-muted uppercase font-semibold tracking-wide",children:e("statsSuites")}),(0,t.jsx)("div",{className:"text-2xl font-bold mt-1 text-violet-400",children:s.length})]}),(0,t.jsxs)(n.Card,{className:"px-4 py-3 text-center",children:[(0,t.jsx)("span",{className:"text-xs text-text-muted uppercase font-semibold tracking-wide",children:e("statsTestCases")}),(0,t.jsx)("div",{className:"text-2xl font-bold mt-1 text-sky-400",children:M})]}),(0,t.jsxs)(n.Card,{className:"px-4 py-3 text-center",children:[(0,t.jsx)("span",{className:"text-xs text-text-muted uppercase font-semibold tracking-wide",children:e("statsModels")}),(0,t.jsx)("div",{className:"text-2xl font-bold mt-1 text-emerald-400",children:$.length})]}),(0,t.jsxs)(n.Card,{className:"px-4 py-3 text-center",children:[(0,t.jsx)("span",{className:"text-xs text-text-muted uppercase font-semibold tracking-wide",children:e("statsCoverage")}),(0,t.jsx)("div",{className:"text-2xl font-bold mt-1 text-amber-400",children:e("statsStrategiesCount",{count:u.length})})]})]}),(0,t.jsxs)(n.Card,{className:"p-0 overflow-hidden",children:[(0,t.jsxs)("button",{onClick:()=>P(!O),className:"w-full flex items-center justify-between px-6 py-4 hover:bg-surface/30 transition-colors text-left",children:[(0,t.jsxs)("div",{className:"flex items-center gap-3",children:[(0,t.jsx)("div",{className:"p-2 rounded-lg bg-primary/10 text-primary",children:(0,t.jsx)("span",{className:"material-symbols-outlined text-[20px]",children:"help"})}),(0,t.jsxs)("div",{children:[(0,t.jsx)("h3",{className:"text-sm font-semibold text-text-main",children:e("howItWorks")}),(0,t.jsx)("p",{className:"text-xs text-text-muted",children:e("howItWorksSubtitle")})]})]}),(0,t.jsx)("span",{className:`material-symbols-outlined text-text-muted transition-transform duration-200 ${O?"rotate-180":""}`,children:"expand_more"})]}),O&&(0,t.jsxs)("div",{className:"px-6 pb-6 border-t border-border/10",children:[(0,t.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4 mt-4",children:[(0,t.jsxs)("div",{className:"flex flex-col items-center text-center p-4 rounded-lg bg-violet-500/5 border border-violet-500/10",children:[(0,t.jsx)("div",{className:"w-10 h-10 rounded-full bg-violet-500/20 flex items-center justify-center mb-3",children:(0,t.jsx)("span",{className:"text-lg font-bold text-violet-400",children:"1"})}),(0,t.jsx)("h4",{className:"text-sm font-semibold text-text-main mb-1",children:e("define")}),(0,t.jsx)("p",{className:"text-xs text-text-muted",children:e("defineStepDescription")})]}),(0,t.jsxs)("div",{className:"flex flex-col items-center text-center p-4 rounded-lg bg-sky-500/5 border border-sky-500/10",children:[(0,t.jsx)("div",{className:"w-10 h-10 rounded-full bg-sky-500/20 flex items-center justify-center mb-3",children:(0,t.jsx)("span",{className:"text-lg font-bold text-sky-400",children:"2"})}),(0,t.jsx)("h4",{className:"text-sm font-semibold text-text-main mb-1",children:e("run")}),(0,t.jsx)("p",{className:"text-xs text-text-muted",children:e("runStepDescription")})]}),(0,t.jsxs)("div",{className:"flex flex-col items-center text-center p-4 rounded-lg bg-emerald-500/5 border border-emerald-500/10",children:[(0,t.jsx)("div",{className:"w-10 h-10 rounded-full bg-emerald-500/20 flex items-center justify-center mb-3",children:(0,t.jsx)("span",{className:"text-lg font-bold text-emerald-400",children:"3"})}),(0,t.jsx)("h4",{className:"text-sm font-semibold text-text-main mb-1",children:e("evaluate")}),(0,t.jsx)("p",{className:"text-xs text-text-muted",children:e("evaluateStepDescription")})]})]}),(0,t.jsxs)("div",{className:"mt-6",children:[(0,t.jsx)("h4",{className:"text-xs font-semibold text-text-muted uppercase tracking-wide mb-3",children:e("evaluationStrategies")}),(0,t.jsx)("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-2",children:u.map(a=>(0,t.jsxs)("div",{className:`flex items-center gap-3 p-3 rounded-lg ${a.bg} border border-transparent`,children:[(0,t.jsx)("span",{className:`material-symbols-outlined text-[18px] ${a.color}`,children:a.icon}),(0,t.jsxs)("div",{children:[(0,t.jsx)("span",{className:`text-xs font-mono font-semibold ${a.color}`,children:e(a.labelKey)}),(0,t.jsx)("p",{className:"text-xs text-text-muted mt-0.5",children:e(a.descriptionKey)})]})]},a.name))})]}),$.length>0&&(0,t.jsxs)("div",{className:"mt-6",children:[(0,t.jsx)("h4",{className:"text-xs font-semibold text-text-muted uppercase tracking-wide mb-3",children:e("modelsUnderTest")}),(0,t.jsx)("div",{className:"flex flex-wrap gap-2",children:$.map(e=>(0,t.jsx)("span",{className:"px-3 py-1.5 rounded-full text-xs font-mono font-medium bg-primary/10 text-primary border border-primary/20",children:e},e))})]})]})]}),(0,t.jsxs)(n.Card,{className:"p-6",children:[(0,t.jsxs)("div",{className:"flex items-center gap-3 mb-4",children:[(0,t.jsx)("div",{className:"p-2 rounded-lg bg-violet-500/10 text-violet-500",children:(0,t.jsx)("span",{className:"material-symbols-outlined text-[20px]",children:"science"})}),(0,t.jsxs)("div",{children:[(0,t.jsx)("h3",{className:"text-lg font-semibold",children:e("evalSuites")}),(0,t.jsx)("p",{className:"text-xs text-text-muted",children:e("evalSuitesHint")})]})]}),(0,t.jsx)(m.default,{searchValue:k,onSearchChange:S,placeholder:e("searchSuitesPlaceholder"),filters:[],activeFilters:{},onFilterChange:()=>{},children:null}),(0,t.jsx)("div",{className:"flex flex-col gap-3 mt-4",children:L.map(a=>{let s=N[a.id],r=b===a.id,l=C===a.id,i=a.cases?.length||a.caseCount||0,n=[...new Set((a.cases||[]).map(e=>e.model).filter(Boolean))];return(0,t.jsxs)("div",{className:"border border-border/30 rounded-lg overflow-hidden",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 cursor-pointer hover:bg-surface/30 transition-colors",onClick:()=>E(l?null:a.id),children:[(0,t.jsxs)("div",{className:"flex items-center gap-3",children:[(0,t.jsx)("span",{className:"material-symbols-outlined text-[16px] text-text-muted",children:l?"expand_more":"chevron_right"}),(0,t.jsxs)("div",{children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)("p",{className:"text-sm font-medium text-text-main",children:a.name||a.id}),s?.summary&&(0,t.jsxs)("span",{className:`px-2 py-0.5 rounded-full text-xs font-semibold ${100===s.summary.passRate?"bg-emerald-500/10 text-emerald-400":s.summary.passRate>=80?"bg-amber-500/10 text-amber-400":"bg-red-500/10 text-red-400"}`,children:[s.summary.passRate,"% ",e("passSuffix")]})]}),(0,t.jsxs)("p",{className:"text-xs text-text-muted",children:[e("casesCount",{count:i}),a.description&&(0,t.jsxs)("span",{className:"ml-1",children:["— ",a.description]})]}),n.length>0&&(0,t.jsx)("div",{className:"flex flex-wrap gap-1 mt-1",children:n.map(e=>(0,t.jsx)("span",{className:"px-1.5 py-0.5 rounded text-[10px] font-mono text-text-muted bg-black/5 dark:bg-white/5",children:e},e))})]})]}),(0,t.jsxs)("div",{className:"flex items-center gap-3",children:[r&&j.total>0&&(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)("div",{className:"w-24 h-1.5 bg-black/10 dark:bg-white/10 rounded-full overflow-hidden",children:(0,t.jsx)("div",{className:"h-full bg-violet-500 rounded-full transition-all duration-300",style:{width:`${j.current/j.total*100}%`}})}),(0,t.jsxs)("span",{className:"text-xs text-text-muted font-mono tabular-nums",children:[j.current,"/",j.total]})]}),(0,t.jsx)(c.Button,{size:"sm",variant:"primary",onClick:e=>{e.stopPropagation(),R(a)},loading:r,disabled:r,children:r?e("runningProgress",{current:j.current,total:j.total}):e("runEval")})]})]}),l&&(0,t.jsx)("div",{className:"border-t border-border/20 p-4",children:s?.results?(0,t.jsxs)(t.Fragment,{children:[s.summary&&(0,t.jsxs)("div",{className:"flex items-center gap-4 mb-4 p-3 rounded-lg bg-surface/30 border border-border/20",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsxs)("span",{className:`text-lg font-bold ${100===s.summary.passRate?"text-emerald-400":s.summary.passRate>=80?"text-amber-400":"text-red-400"}`,children:[s.summary.passRate,"%"]}),(0,t.jsx)("span",{className:"text-xs text-text-muted",children:e("passRate")})]}),(0,t.jsx)("div",{className:"text-xs text-text-muted",children:e("summaryBreakdown",{passed:s.summary.passed,failed:s.summary.failed,total:s.summary.total})}),(0,t.jsx)("div",{className:"flex-1 h-2 bg-black/10 dark:bg-white/10 rounded-full overflow-hidden",children:(0,t.jsx)("div",{className:"h-full rounded-full transition-all duration-500",style:{width:`${s.summary.passRate}%`,background:100===s.summary.passRate?"linear-gradient(90deg, #22c55e, #16a34a)":s.summary.passRate>=80?"linear-gradient(90deg, #f59e0b, #d97706)":"linear-gradient(90deg, #ef4444, #dc2626)"}})})]}),(0,t.jsx)(d.default,{columns:q,data:s.results.map((e,t)=>({...e,id:e.caseId||t})),renderCell:(a,s)=>{if("status"===s.key)return a.passed?(0,t.jsx)("span",{className:"text-emerald-400",children:e("passedIconLabel")}):(0,t.jsx)("span",{className:"text-red-400",children:e("failedIconLabel")});if("durationMs"===s.key)return(0,t.jsx)("span",{className:"text-text-muted text-xs font-mono",children:null!=a.durationMs?`${a.durationMs}ms`:"—"});if("details"===s.key){let s=a.details||{};return(0,t.jsx)("span",{className:"text-text-muted text-xs truncate max-w-[300px] block",children:String(s.searchTerm?e("detailsContains",{term:s.searchTerm}):s.pattern?e("detailsRegex",{pattern:s.pattern}):s.expected?e("detailsExpected",{expected:String(s.expected).slice(0,50)}):a.error||"—")})}return(0,t.jsx)("span",{className:"text-sm text-text-main",children:a[s.key]||"—"})},maxHeight:"400px",emptyMessage:e("noResultsYet")})]}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("div",{className:"flex items-center gap-2 mb-3",children:[(0,t.jsx)("span",{className:"material-symbols-outlined text-[16px] text-text-muted",children:"checklist"}),(0,t.jsx)("span",{className:"text-xs text-text-muted font-medium",children:e("testCasesCount",{count:(a.cases||[]).length})})]}),(0,t.jsx)(d.default,{columns:[{key:"name",label:e("columnCase")},{key:"model",label:e("columnModel")},{key:"strategy",label:e("columnStrategy")},{key:"expected",label:e("columnExpected")}],data:(a.cases||[]).map((e,t)=>({id:e.id||t,name:e.name,model:e.model||"—",strategy:e.expected?.strategy||"—",expected:e.expected?.value?String(e.expected.value).slice(0,80):"—"})),renderCell:(e,a)=>{if("strategy"===a.key){let a=u.find(t=>t.name===e.strategy);return(0,t.jsx)("span",{className:`text-xs font-mono font-semibold ${a?.color||"text-text-muted"}`,children:e.strategy})}return"model"===a.key?(0,t.jsx)("span",{className:"text-xs font-mono text-primary/80",children:e.model}):"expected"===a.key?(0,t.jsx)("span",{className:"text-text-muted text-xs font-mono truncate max-w-[300px] block",children:e.expected}):(0,t.jsx)("span",{className:"text-sm text-text-main",children:e[a.key]||"—"})},maxHeight:"400px",emptyMessage:e("noTestCasesDefined")}),(0,t.jsxs)("p",{className:"text-xs text-text-muted mt-3 flex items-center gap-1.5",children:[(0,t.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"info"}),e("runEvalHint")]})]})})]},a.id)})})]})]})}function p({t:e}){return(0,t.jsx)(n.Card,{className:"p-0 overflow-hidden",children:(0,t.jsx)("div",{className:"p-6",style:{background:"linear-gradient(135deg, rgba(139, 92, 246, 0.05) 0%, rgba(59, 130, 246, 0.05) 50%, rgba(16, 185, 129, 0.05) 100%)"},children:(0,t.jsxs)("div",{className:"flex items-start gap-4",children:[(0,t.jsx)("div",{className:"p-3 rounded-xl bg-violet-500/10 text-violet-500",children:(0,t.jsx)("span",{className:"material-symbols-outlined text-[28px]",children:"science"})}),(0,t.jsxs)("div",{className:"flex-1",children:[(0,t.jsx)("h2",{className:"text-xl font-bold text-text-main mb-1",children:e("modelEvals")}),(0,t.jsx)("p",{className:"text-sm text-text-muted leading-relaxed max-w-2xl",children:e("evalsHeroDescription")}),(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-4 mt-4",children:[(0,t.jsxs)("div",{className:"flex items-center gap-1.5 text-xs text-text-muted",children:[(0,t.jsx)("span",{className:"material-symbols-outlined text-[16px] text-emerald-400",children:"verified"}),e("qualityValidation")]}),(0,t.jsxs)("div",{className:"flex items-center gap-1.5 text-xs text-text-muted",children:[(0,t.jsx)("span",{className:"material-symbols-outlined text-[16px] text-sky-400",children:"compare"}),e("modelComparison")]}),(0,t.jsxs)("div",{className:"flex items-center gap-1.5 text-xs text-text-muted",children:[(0,t.jsx)("span",{className:"material-symbols-outlined text-[16px] text-amber-400",children:"bug_report"}),e("regressionDetection")]}),(0,t.jsxs)("div",{className:"flex items-center gap-1.5 text-xs text-text-muted",children:[(0,t.jsx)("span",{className:"material-symbols-outlined text-[16px] text-violet-400",children:"speed"}),e("latencyBenchmarks")]})]})]})]})})})}function f({icon:e,label:a,value:s,sub:r}){return(0,t.jsxs)("div",{className:"card p-4 flex flex-col gap-1",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2 text-text-muted text-sm",children:[(0,t.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:e}),a]}),(0,t.jsx)("div",{className:"text-2xl font-bold text-text",children:s}),r&&(0,t.jsx)("div",{className:"text-xs text-text-muted",children:r})]})}function g({provider:e,count:a,total:s,costUsd:r}){let l=s>0?Math.round(a/s*100):0;return(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,t.jsxs)("div",{className:"flex justify-between text-sm",children:[(0,t.jsx)("span",{className:"font-medium text-text",children:e}),(0,t.jsxs)("span",{className:"text-text-muted",children:[a," queries · $",r.toFixed(4)]})]}),(0,t.jsx)("div",{className:"h-2 rounded-full bg-bg-muted overflow-hidden",children:(0,t.jsx)("div",{className:"h-full rounded-full bg-primary transition-all",style:{width:`${l}%`}})}),(0,t.jsxs)("div",{className:"text-xs text-text-muted text-right",children:[l,"%"]})]})}function b(){let[e,s]=(0,a.useState)(null),[r,l]=(0,a.useState)(!0),[i,n]=(0,a.useState)(null);if((0,a.useEffect)(()=>{fetch("/api/v1/search/analytics").then(e=>e.json()).then(e=>{s(e),l(!1)}).catch(e=>{n(e.message),l(!1)})},[]),r)return(0,t.jsxs)("div",{className:"flex items-center justify-center py-16 text-text-muted",children:[(0,t.jsx)("span",{className:"material-symbols-outlined animate-spin mr-2",children:"progress_activity"}),"Loading search analytics…"]});if(i||!e)return(0,t.jsxs)("div",{className:"card p-6 text-center text-text-muted",children:[(0,t.jsx)("span",{className:"material-symbols-outlined text-[32px] mb-2 block",children:"search_off"}),i||"No search data available yet.",(0,t.jsx)("p",{className:"text-xs mt-2",children:"Search requests will appear here after the first search via /v1/search."})]});let c=Object.entries(e.byProvider).sort(([,e],[,t])=>t.count-e.count);return(0,t.jsxs)("div",{className:"flex flex-col gap-6",children:[(0,t.jsxs)("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[(0,t.jsx)(f,{icon:"manage_search",label:"Total Searches",value:e.total.toLocaleString(),sub:`${e.today} today`}),(0,t.jsx)(f,{icon:"cached",label:"Cache Hit Rate",value:`${e.cacheHitRate}%`,sub:`${e.cached} cached requests`}),(0,t.jsx)(f,{icon:"attach_money",label:"Total Cost",value:`$${e.totalCostUsd.toFixed(4)}`,sub:"search API costs"}),(0,t.jsx)(f,{icon:"timer",label:"Avg Response",value:`${e.avgDurationMs}ms`,sub:e.errors>0?`${e.errors} errors`:"No errors"})]}),c.length>0&&(0,t.jsxs)("div",{className:"card p-5",children:[(0,t.jsxs)("h3",{className:"font-semibold text-text mb-4 flex items-center gap-2",children:[(0,t.jsx)("span",{className:"material-symbols-outlined text-primary text-[20px]",children:"hub"}),"Provider Breakdown"]}),(0,t.jsx)("div",{className:"flex flex-col gap-4",children:c.map(([a,s])=>(0,t.jsx)(g,{provider:a,count:s.count,total:e.total,costUsd:s.costUsd},a))})]}),0===e.total&&(0,t.jsxs)("div",{className:"card p-8 text-center text-text-muted",children:[(0,t.jsx)("span",{className:"material-symbols-outlined text-[48px] mb-3 block text-primary opacity-50",children:"travel_explore"}),(0,t.jsx)("p",{className:"font-medium text-text",children:"No searches yet"}),(0,t.jsxs)("p",{className:"text-sm mt-1",children:["Use ",(0,t.jsx)("code",{className:"bg-bg-muted px-1 rounded",children:"POST /v1/search"})," to start routing web searches."]})]}),(0,t.jsxs)("div",{className:"text-xs text-text-muted border border-border rounded-lg p-3 flex items-start gap-2",children:[(0,t.jsx)("span",{className:"material-symbols-outlined text-[16px] text-green-500 mt-0.5",children:"check_circle"}),(0,t.jsxs)("span",{children:[(0,t.jsx)("strong",{children:"Free tier available:"})," Serper (2,500/mo), Brave (2,000/mo), Exa (1,000/mo), Tavily (1,000/mo) — total 6,500+ free searches/month with automatic failover."]})]})]})}function v(){let[e,s]=(0,a.useState)(null),[r,l]=(0,a.useState)(!0);if((0,i.useTranslations)("analytics"),(0,a.useEffect)(()=>{fetch("/api/analytics/diversity").then(e=>e.json()).then(e=>{s(e),l(!1)}).catch(e=>{console.error(e),l(!1)})},[]),r||!e)return(0,t.jsx)(n.Card,{className:"p-5 flex flex-col justify-center items-center h-full min-h-[200px]",children:(0,t.jsx)("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary"})});let c=Math.round(100*(e.score||0)),o="text-green-500",d="bg-green-500",m="Healthy Distribution";return c<40?(o="text-red-500",d="bg-red-500",m="High Vendor Lock-in Risk"):c<70&&(o="text-amber-500",d="bg-amber-500",m="Moderate Distribution"),(0,t.jsxs)(n.Card,{className:"p-5 flex flex-col h-full bg-[var(--card-bg,#1e1e2e)] relative overflow-hidden group",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2 mb-4",children:[(0,t.jsx)("span",{className:"material-symbols-outlined text-[20px] text-cyan-400",children:"pie_chart"}),(0,t.jsx)("h3",{className:"font-semibold text-[var(--text-primary,#fff)] flex-1",children:"Provider Diversity Score"}),(0,t.jsx)("span",{className:`text-xs px-2 py-0.5 rounded-md border ${d.replace("bg-","border-").replace("500","500/20")} ${d.replace("500","500/10")} ${o}`,children:"Shannon Entropy"})]}),(0,t.jsxs)("div",{className:"flex items-center justify-between mt-2 mb-6",children:[(0,t.jsxs)("div",{className:"flex flex-col",children:[(0,t.jsxs)("span",{className:`text-4xl font-bold tabular-nums tracking-tight ${o}`,children:[c,"%"]}),(0,t.jsx)("span",{className:"text-sm text-[var(--text-muted,#aaaaaa)] mt-1",children:m})]}),(0,t.jsx)("div",{className:"relative w-20 h-20 flex-shrink-0",children:(0,t.jsxs)("svg",{className:"w-full h-full transform -rotate-90",viewBox:"0 0 36 36",children:[(0,t.jsx)("path",{className:"text-[var(--border,#333)]",strokeWidth:"4",stroke:"currentColor",fill:"none",d:"M18 2.0845 a 15.9155 15.9155 0 0 1 0 31.831 a 15.9155 15.9155 0 0 1 0 -31.831"}),(0,t.jsx)("path",{className:o,strokeWidth:"4",strokeDasharray:`${c}, 100`,stroke:"currentColor",fill:"none",strokeLinecap:"round",d:"M18 2.0845 a 15.9155 15.9155 0 0 1 0 31.831 a 15.9155 15.9155 0 0 1 0 -31.831"})]})})]}),(0,t.jsxs)("div",{className:"space-y-4 flex-1",children:[(0,t.jsx)("p",{className:"text-xs uppercase tracking-wider font-semibold text-[var(--text-muted,#888)]",children:"Provider Share"}),0===Object.keys(e.providers||{}).length?(0,t.jsx)("div",{className:"text-sm text-[var(--text-secondary,#666)] py-2",children:"No recent usage data available."}):(0,t.jsx)("div",{className:"space-y-3",children:Object.entries(e.providers).sort(([,e],[,t])=>t.share-e.share).slice(0,4).map(([e,a])=>(0,t.jsxs)("div",{className:"flex flex-col gap-1.5",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between text-sm",children:[(0,t.jsx)("span",{className:"font-medium text-[var(--text-primary,#ddd)] capitalize",children:e}),(0,t.jsxs)("span",{className:"font-mono text-[var(--text-muted,#aaa)]",children:[Math.round(100*a.share),"%"]})]}),(0,t.jsx)("div",{className:"w-full h-1.5 bg-[var(--surface,#333)] rounded-full overflow-hidden",children:(0,t.jsx)("div",{className:`h-full ${d} rounded-full`,style:{width:`${Math.round(100*a.share)}%`}})})]},e))})]}),(0,t.jsxs)("div",{className:"mt-4 pt-4 border-t border-[var(--border,#333)] flex justify-between text-[11px] text-[var(--text-muted,#777)]",children:[(0,t.jsxs)("span",{children:["Window: ",e.windowSize," reqs"]}),(0,t.jsxs)("span",{children:["Based on Last ",Math.round(e.ttlMs/6e4)," mins"]})]})]})}var j=e.i(129071),y=e.i(794395),N=e.i(779812),w=e.i(228108),k=e.i(909928),S=e.i(846710),C=e.i(661764),E=e.i(127241),O=e.i(375337),P=e.i(51883),A=e.i(257999),D=e.i(822075),T=e.i(629601),z=e.i(318457),R=["x1","y1","x2","y2","key"],L=["offset"],M=["xAxisId","yAxisId"],$=["xAxisId","yAxisId"];function q(e,t){var a=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);t&&(s=s.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),a.push.apply(a,s)}return a}function I(e){for(var t=1;t<arguments.length;t++){var a=null!=arguments[t]?arguments[t]:{};t%2?q(Object(a),!0).forEach(function(t){var s,r,l;s=e,r=t,l=a[t],(r=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var a=e[Symbol.toPrimitive];if(void 0!==a){var s=a.call(e,t||"default");if("object"!=typeof s)return s;throw TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(r))in s?Object.defineProperty(s,r,{value:l,enumerable:!0,configurable:!0,writable:!0}):s[r]=l}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(a)):q(Object(a)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(a,t))})}return e}function _(){return(_=Object.assign.bind()).apply(null,arguments)}function F(e,t){if(null==e)return{};var a,s,r=function(e,t){if(null==e)return{};var a={};for(var s in e)if(({}).hasOwnProperty.call(e,s)){if(-1!==t.indexOf(s))continue;a[s]=e[s]}return a}(e,t);if(Object.getOwnPropertySymbols){var l=Object.getOwnPropertySymbols(e);for(s=0;s<l.length;s++)a=l[s],-1===t.indexOf(a)&&({}).propertyIsEnumerable.call(e,a)&&(r[a]=e[a])}return r}var H=e=>{var{fill:t}=e;if(!t||"none"===t)return null;var{fillOpacity:s,x:r,y:l,width:i,height:n,ry:c}=e;return a.createElement("rect",{x:r,y:l,ry:c,width:i,height:n,stroke:"none",fill:t,fillOpacity:s,className:"recharts-cartesian-grid-bg"})};function B(e){var{option:t,lineItemProps:s}=e;if(a.isValidElement(t))r=a.cloneElement(t,s);else if("function"==typeof t)r=t(s);else{var r,l,{x1:i,y1:n,x2:c,y2:o,key:d}=s,m=F(s,R),x=null!=(l=(0,A.svgPropertiesNoEvents)(m))?l:{},{offset:u}=x,h=F(x,L);r=a.createElement("line",_({},h,{x1:i,y1:n,x2:c,y2:o,fill:"none",key:d}))}return r}function G(e){var{x:t,width:s,horizontal:r=!0,horizontalPoints:l}=e;if(!r||!l||!l.length)return null;var{xAxisId:i,yAxisId:n}=e,c=F(e,M),o=l.map((e,l)=>{var i=I(I({},c),{},{x1:t,y1:e,x2:t+s,y2:e,key:"line-".concat(l),index:l});return a.createElement(B,{key:"line-".concat(l),option:r,lineItemProps:i})});return a.createElement("g",{className:"recharts-cartesian-grid-horizontal"},o)}function K(e){var{y:t,height:s,vertical:r=!0,verticalPoints:l}=e;if(!r||!l||!l.length)return null;var{xAxisId:i,yAxisId:n}=e,c=F(e,$),o=l.map((e,l)=>{var i=I(I({},c),{},{x1:e,y1:t,x2:e,y2:t+s,key:"line-".concat(l),index:l});return a.createElement(B,{option:r,lineItemProps:i,key:"line-".concat(l)})});return a.createElement("g",{className:"recharts-cartesian-grid-vertical"},o)}function W(e){var{horizontalFill:t,fillOpacity:s,x:r,y:l,width:i,height:n,horizontalPoints:c,horizontal:o=!0}=e;if(!o||!t||!t.length||null==c)return null;var d=c.map(e=>Math.round(e+l-l)).sort((e,t)=>e-t);l!==d[0]&&d.unshift(0);var m=d.map((e,c)=>{var o=d[c+1],m=null==o?l+n-e:o-e;if(m<=0)return null;var x=c%t.length;return a.createElement("rect",{key:"react-".concat(c),y:e,x:r,height:m,width:i,stroke:"none",fill:t[x],fillOpacity:s,className:"recharts-cartesian-grid-bg"})});return a.createElement("g",{className:"recharts-cartesian-gridstripes-horizontal"},m)}function U(e){var{vertical:t=!0,verticalFill:s,fillOpacity:r,x:l,y:i,width:n,height:c,verticalPoints:o}=e;if(!t||!s||!s.length)return null;var d=o.map(e=>Math.round(e+l-l)).sort((e,t)=>e-t);l!==d[0]&&d.unshift(0);var m=d.map((e,t)=>{var o=d[t+1],m=null==o?l+n-e:o-e;if(m<=0)return null;var x=t%s.length;return a.createElement("rect",{key:"react-".concat(t),x:e,y:i,width:m,height:c,stroke:"none",fill:s[x],fillOpacity:r,className:"recharts-cartesian-grid-bg"})});return a.createElement("g",{className:"recharts-cartesian-gridstripes-vertical"},m)}var V=(e,t)=>{var{xAxis:a,width:s,height:r,offset:l}=e;return(0,N.getCoordinatesOfGrid)((0,w.getTicks)(I(I(I({},k.defaultCartesianAxisProps),a),{},{ticks:(0,N.getTicksOfAxis)(a,!0),viewBox:{x:0,y:0,width:s,height:r}})),l.left,l.left+l.width,t)},J=(e,t)=>{var{yAxis:a,width:s,height:r,offset:l}=e;return(0,N.getCoordinatesOfGrid)((0,w.getTicks)(I(I(I({},k.defaultCartesianAxisProps),a),{},{ticks:(0,N.getTicksOfAxis)(a,!0),viewBox:{x:0,y:0,width:s,height:r}})),l.top,l.top+l.height,t)},Y={horizontal:!0,vertical:!0,horizontalPoints:[],verticalPoints:[],stroke:"#ccc",fill:"none",verticalFill:[],horizontalFill:[],xAxisId:0,yAxisId:0,syncWithTicks:!1,zIndex:z.DefaultZIndexes.grid};function Z(e){var t=(0,S.useChartWidth)(),s=(0,S.useChartHeight)(),r=(0,S.useOffsetInternal)(),l=I(I({},(0,P.resolveDefaultProps)(e,Y)),{},{x:(0,y.isNumber)(e.x)?e.x:r.left,y:(0,y.isNumber)(e.y)?e.y:r.top,width:(0,y.isNumber)(e.width)?e.width:r.width,height:(0,y.isNumber)(e.height)?e.height:r.height}),{xAxisId:i,yAxisId:n,x:c,y:o,width:d,height:m,syncWithTicks:x,horizontalValues:u,verticalValues:h}=l,p=(0,O.useIsPanorama)(),f=(0,E.useAppSelector)(e=>(0,C.selectAxisPropsNeededForCartesianGridTicksGenerator)(e,"xAxis",i,p)),g=(0,E.useAppSelector)(e=>(0,C.selectAxisPropsNeededForCartesianGridTicksGenerator)(e,"yAxis",n,p));if(!(0,D.isPositiveNumber)(d)||!(0,D.isPositiveNumber)(m)||!(0,y.isNumber)(c)||!(0,y.isNumber)(o))return null;var b=l.verticalCoordinatesGenerator||V,v=l.horizontalCoordinatesGenerator||J,{horizontalPoints:N,verticalPoints:w}=l;if((!N||!N.length)&&"function"==typeof v){var k=u&&u.length,A=v({yAxis:g?I(I({},g),{},{ticks:k?u:g.ticks}):void 0,width:null!=t?t:d,height:null!=s?s:m,offset:r},!!k||x);(0,j.warn)(Array.isArray(A),"horizontalCoordinatesGenerator should return Array but instead it returned [".concat(typeof A,"]")),Array.isArray(A)&&(N=A)}if((!w||!w.length)&&"function"==typeof b){var z=h&&h.length,R=b({xAxis:f?I(I({},f),{},{ticks:z?h:f.ticks}):void 0,width:null!=t?t:d,height:null!=s?s:m,offset:r},!!z||x);(0,j.warn)(Array.isArray(R),"verticalCoordinatesGenerator should return Array but instead it returned [".concat(typeof R,"]")),Array.isArray(R)&&(w=R)}return a.createElement(T.ZIndexLayer,{zIndex:l.zIndex},a.createElement("g",{className:"recharts-cartesian-grid"},a.createElement(H,{fill:l.fill,fillOpacity:l.fillOpacity,x:l.x,y:l.y,width:l.width,height:l.height,ry:l.ry}),a.createElement(W,_({},l,{horizontalPoints:N})),a.createElement(U,_({},l,{verticalPoints:w})),a.createElement(G,_({},l,{offset:r,horizontalPoints:N,xAxis:f,yAxis:g})),a.createElement(K,_({},l,{offset:r,verticalPoints:w,xAxis:f,yAxis:g}))))}Z.displayName="CartesianGrid";var Q=e.i(174080),X=e.i(988860),ee=e.i(207670),et=e.i(148337),ea=e.i(913659),es=e.i(373393);function er(){return(er=Object.assign.bind()).apply(null,arguments)}function el(e,t){var a=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);t&&(s=s.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),a.push.apply(a,s)}return a}function ei(e){for(var t=1;t<arguments.length;t++){var a=null!=arguments[t]?arguments[t]:{};t%2?el(Object(a),!0).forEach(function(t){var s,r,l;s=e,r=t,l=a[t],(r=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var a=e[Symbol.toPrimitive];if(void 0!==a){var s=a.call(e,t||"default");if("object"!=typeof s)return s;throw TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(r))in s?Object.defineProperty(s,r,{value:l,enumerable:!0,configurable:!0,writable:!0}):s[r]=l}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(a)):el(Object(a)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(a,t))})}return e}var en={align:"center",iconSize:14,inactiveColor:"#ccc",layout:"horizontal",verticalAlign:"middle",labelStyle:{}};function ec(e){var{data:t,iconType:s,inactiveColor:r}=e,l=32/6,i=32/3,n=t.inactive?r:t.color,c=null!=s?s:t.type;if("none"===c)return null;if("plainline"===c)return a.createElement("line",{strokeWidth:4,fill:"none",stroke:n,strokeDasharray:function(e){if("object"==typeof e&&null!==e&&"strokeDasharray"in e)return String(e.strokeDasharray)}(t.payload),x1:0,y1:16,x2:32,y2:16,className:"recharts-legend-icon"});if("line"===c)return a.createElement("path",{strokeWidth:4,fill:"none",stroke:n,d:"M0,".concat(16,"h").concat(i,"\n A").concat(l,",").concat(l,",0,1,1,").concat(2*i,",").concat(16,"\n H").concat(32,"M").concat(2*i,",").concat(16,"\n A").concat(l,",").concat(l,",0,1,1,").concat(i,",").concat(16),className:"recharts-legend-icon"});if("rect"===c)return a.createElement("path",{stroke:"none",fill:n,d:"M0,".concat(4,"h").concat(32,"v").concat(24,"h").concat(-32,"z"),className:"recharts-legend-icon"});if(a.isValidElement(t.legendIcon)){var o=ei({},t);return delete o.legendIcon,a.cloneElement(t.legendIcon,o)}return a.createElement(ea.Symbols,{fill:n,cx:16,cy:16,size:32,sizeType:"diameter",type:c})}function eo(e){var{payload:t,iconSize:s,layout:r,formatter:l,inactiveColor:i,iconType:n,labelStyle:c}=e,o={x:0,y:0,width:32,height:32},d={display:"horizontal"===r?"inline-block":"block",marginRight:10},m={display:"inline-block",verticalAlign:"middle",marginRight:4};return t.map((t,r)=>{var x=t.formatter||l,u=(0,ee.clsx)({"recharts-legend-item":!0,["legend-item-".concat(r)]:!0,inactive:t.inactive});if("none"===t.type)return null;var h="object"==typeof c?ei({},c):{};h.color=t.inactive?i:h.color||t.color;var p=x?x(t.value,t,r):t.value;return a.createElement("li",er({className:u,style:d,key:"legend-item-".concat(r)},(0,es.adaptEventsOfChild)(e,t,r)),a.createElement(et.Surface,{width:s,height:s,viewBox:o,style:m,"aria-label":"".concat(t.value," legend icon")},a.createElement(ec,{data:t,iconType:n,inactiveColor:i})),a.createElement("span",{className:"recharts-legend-item-text",style:h},p))})}var ed=e=>{var t=(0,P.resolveDefaultProps)(e,en),{payload:s,layout:r,align:l}=t;return s&&s.length?a.createElement("ul",{className:"recharts-default-legend",style:{padding:0,margin:0,textAlign:"horizontal"===r?l:"left"}},a.createElement(eo,er({},t,{payload:s}))):null},em=e.i(251587),ex=e.i(721307),eu=e.i(835709),eh=e.i(893882),ep=e.i(920135),ef=["contextPayload"];function eg(){return(eg=Object.assign.bind()).apply(null,arguments)}function eb(e,t){var a=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);t&&(s=s.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),a.push.apply(a,s)}return a}function ev(e){for(var t=1;t<arguments.length;t++){var a=null!=arguments[t]?arguments[t]:{};t%2?eb(Object(a),!0).forEach(function(t){var s,r,l;s=e,r=t,l=a[t],(r=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var a=e[Symbol.toPrimitive];if(void 0!==a){var s=a.call(e,t||"default");if("object"!=typeof s)return s;throw TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(r))in s?Object.defineProperty(s,r,{value:l,enumerable:!0,configurable:!0,writable:!0}):s[r]=l}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(a)):eb(Object(a)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(a,t))})}return e}function ej(e){return e.value}function ey(e){var{contextPayload:t}=e,s=function(e,t){if(null==e)return{};var a,s,r=function(e,t){if(null==e)return{};var a={};for(var s in e)if(({}).hasOwnProperty.call(e,s)){if(-1!==t.indexOf(s))continue;a[s]=e[s]}return a}(e,t);if(Object.getOwnPropertySymbols){var l=Object.getOwnPropertySymbols(e);for(s=0;s<l.length;s++)a=l[s],-1===t.indexOf(a)&&({}).propertyIsEnumerable.call(e,a)&&(r[a]=e[a])}return r}(e,ef),r=(0,em.getUniqPayload)(t,e.payloadUniqBy,ej),l=ev(ev({},s),{},{payload:r});return a.isValidElement(e.content)?a.cloneElement(e.content,l):"function"==typeof e.content?a.createElement(e.content,l):a.createElement(ed,l)}function eN(e){var t=(0,E.useAppDispatch)();return(0,a.useEffect)(()=>{t((0,eh.setLegendSettings)(e))},[t,e]),null}function ew(e){var t=(0,E.useAppDispatch)();return(0,a.useEffect)(()=>(t((0,eh.setLegendSize)(e)),()=>{t((0,eh.setLegendSize)({width:0,height:0}))}),[t,e]),null}var ek={align:"center",iconSize:14,inactiveColor:"#ccc",itemSorter:"value",layout:"horizontal",verticalAlign:"bottom"},eS=a.memo(function(e){var t,s=(0,P.resolveDefaultProps)(e,ek),r=(0,E.useAppSelector)(ex.selectLegendPayload),l=(0,X.useLegendPortal)(),i=(0,S.useMargin)(),{width:n,height:c,wrapperStyle:o,portal:d}=s,[m,x]=(0,eu.useElementOffset)([r]),u=(0,S.useChartWidth)(),h=(0,S.useChartHeight)();if(null==u||null==h)return null;var p=u-((null==i?void 0:i.left)||0)-((null==i?void 0:i.right)||0),f=(t=s.layout,"vertical"===t&&null!=c?{height:c}:"horizontal"===t?{width:n||p}:null),g=d?o:ev(ev({position:"absolute",width:(null==f?void 0:f.width)||n||"auto",height:(null==f?void 0:f.height)||c||"auto"},function(e,t,a,s,r,l){var i,n,{layout:c,align:o,verticalAlign:d}=t;return e&&(void 0!==e.left&&null!==e.left||void 0!==e.right&&null!==e.right)||(i="center"===o&&"vertical"===c?{left:((s||0)-l.width)/2}:"right"===o?{right:a&&a.right||0}:{left:a&&a.left||0}),e&&(void 0!==e.top&&null!==e.top||void 0!==e.bottom&&null!==e.bottom)||(n="middle"===d?{top:((r||0)-l.height)/2}:"bottom"===d?{bottom:a&&a.bottom||0}:{top:a&&a.top||0}),ev(ev({},i),n)}(o,s,i,u,h,m)),o),b=null!=d?d:l;if(null==b||null==r)return null;var v=a.createElement("div",{className:"recharts-legend-wrapper",style:g,ref:x},a.createElement(eN,{layout:s.layout,align:s.align,verticalAlign:s.verticalAlign,itemSorter:s.itemSorter}),!d&&a.createElement(ew,{width:m.width,height:m.height}),a.createElement(ey,eg({},s,f,{margin:i,chartWidth:u,chartHeight:h,contextPayload:r})));return(0,Q.createPortal)(v,b)},ep.propsAreEqual);eS.displayName="Legend";var eC=e.i(555706),eE=e.i(925949),eO=e.i(433369),eP=["axis"],eA=(0,a.forwardRef)((e,t)=>a.createElement(eO.CartesianChart,{chartName:"LineChart",defaultTooltipEventType:"axis",validateTooltipEventTypes:eP,tooltipPayloadSearcher:eE.arrayTooltipSearcher,categoricalChartProps:e,ref:t})),eD=e.i(731195),eT=e.i(234239),ez=e.i(785183),eR=e.i(93230),eL=e.i(393718),eM=e.i(393162),e$=e.i(156132);let eq=[{value:"1h",label:"1h"},{value:"24h",label:"24h"},{value:"7d",label:"7d"},{value:"30d",label:"30d"}];function eI({value:e,onChange:a}){return(0,t.jsx)("div",{role:"tablist","aria-label":"Select time range",className:"inline-flex items-center gap-1 rounded-lg bg-black/5 p-1 dark:bg-white/5",children:eq.map(s=>{let r=e===s.value;return(0,t.jsx)("button",{type:"button",role:"tab","aria-selected":r,tabIndex:r?0:-1,onClick:()=>a(s.value),className:(0,e$.cn)("focus-ring h-9 rounded-md px-4 text-sm font-medium transition-all",r?"bg-primary text-white shadow-sm hover:bg-primary-hover":"text-text-muted hover:bg-black/5 hover:text-text-main dark:hover:bg-white/5"),children:s.label},s.value)})})}let e_={"1h":"Last hour","24h":"Last 24 hours","7d":"Last 7 days","30d":"Last 30 days"},eF=["var(--color-primary)","var(--color-accent)","var(--color-success)","var(--color-warning)","var(--color-error)","var(--color-text-muted)"];function eH(e,t){let a=new Date(e);return Number.isNaN(a.getTime())?e:"1h"===t||"24h"===t?new Intl.DateTimeFormat(void 0,{hour:"2-digit",minute:"2-digit"}).format(a):new Intl.DateTimeFormat(void 0,{month:"short",day:"numeric"}).format(a)}function eB(e,t){let a=new Date(e);return Number.isNaN(a.getTime())?e:new Intl.DateTimeFormat(void 0,{month:"short",day:"numeric",hour:"1h"===t||"24h"===t?"2-digit":void 0,minute:"1h"===t||"24h"===t?"2-digit":void 0}).format(a)}function eG(e){return`${Math.round(e)}%`}function eK(){let[e,s]=(0,a.useState)("24h"),[r,l]=(0,a.useState)(null),[i,n]=(0,a.useState)(!0),[c,o]=(0,a.useState)(null),d=(0,a.useCallback)(async(e,t)=>{n(!0);try{let a=await fetch(`/api/usage/utilization?range=${e}`,{signal:t,cache:"no-store"});if(!a.ok)throw Error("Failed to fetch utilization data");let s=await a.json();l(s),o(null)}catch(e){if(e instanceof DOMException&&"AbortError"===e.name)return;o(e instanceof Error?e.message:"Failed to fetch utilization data"),l(null)}finally{t?.aborted||n(!1)}},[]);(0,a.useEffect)(()=>{let t=new AbortController;return d(e,t.signal),()=>t.abort()},[d,e]);let m=(0,a.useMemo)(()=>{let e=new Map;for(let[t,a]of(r?.providers??[]).entries())e.set(a,eF[t%eF.length]);return e},[r?.providers]),x=(0,a.useMemo)(()=>{if(!r?.data.length)return[];let e=new Map;for(let t of r.data){let a=e.get(t.timestamp)??{timestamp:t.timestamp,label:eH(t.timestamp,r.timeRange)};a[t.provider]=Number(t.remainingPct.toFixed(2)),e.set(t.timestamp,a)}return Array.from(e.entries()).sort(([e],[t])=>new Date(e).getTime()-new Date(t).getTime()).map(([,e])=>e)},[r]),u=(0,a.useMemo)(()=>(function(e){let t=new Map;for(let a of e){let e=t.get(a.provider);(!e||new Date(a.timestamp).getTime()>new Date(e.timestamp).getTime())&&t.set(a.provider,a)}return Array.from(t.values()).sort((e,t)=>t.remainingPct-e.remainingPct)})(r?.data??[]),[r?.data]),h=!!r?.data.length,[p,f]=(0,a.useState)(!1),g=(0,a.useCallback)(()=>{f(!0),o(null),d(e).finally(()=>f(!1))},[e,d]);return(0,t.jsx)("div",{className:"flex flex-col gap-6",children:(0,t.jsx)(eL.default,{title:"Provider utilization",subtitle:e_[e],icon:"monitoring",action:(0,t.jsx)(eI,{value:e,onChange:s}),className:"overflow-hidden",children:i&&!h?(0,t.jsxs)("div",{className:"flex min-h-80 items-center justify-center text-sm text-text-muted",children:[(0,t.jsx)("span",{className:"material-symbols-outlined mr-2 animate-spin text-[18px]",children:"progress_activity"}),"Loading utilization data…"]}):c?(0,t.jsxs)("div",{className:"flex min-h-80 flex-col items-center justify-center gap-4 text-center",children:[(0,t.jsx)("span",{className:"material-symbols-outlined text-[32px] text-error",children:"error"}),(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,t.jsx)("p",{className:"text-sm font-medium text-text-main",children:"Failed to load utilization data"}),(0,t.jsx)("p",{className:"text-sm text-text-muted",children:c})]}),(0,t.jsx)("button",{type:"button",onClick:g,disabled:p,className:"inline-flex items-center gap-2 rounded-lg bg-primary px-4 py-2 text-sm font-medium text-white hover:bg-primary-hover disabled:opacity-50 disabled:cursor-not-allowed",children:p?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("span",{className:"material-symbols-outlined animate-spin text-[18px]",children:"progress_activity"}),"Retrying…"]}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:"refresh"}),"Retry"]})})]}):h?(0,t.jsxs)("div",{className:"flex flex-col gap-5",children:[(0,t.jsx)("div",{className:"h-80 w-full rounded-xl border border-black/5 bg-black/[0.02] px-3 py-4 dark:border-white/5 dark:bg-white/[0.02]",children:(0,t.jsx)(eD.ResponsiveContainer,{width:"100%",height:"100%",children:(0,t.jsxs)(eA,{data:x,margin:{top:8,right:16,bottom:0,left:0},children:[(0,t.jsx)(Z,{stroke:"var(--color-border)",strokeDasharray:"3 3",vertical:!1}),(0,t.jsx)(ez.XAxis,{dataKey:"timestamp",tickFormatter:t=>eH(String(t),e),tick:{fill:"var(--color-text-muted)",fontSize:12},axisLine:{stroke:"var(--color-border)"},tickLine:{stroke:"var(--color-border)"},minTickGap:24}),(0,t.jsx)(eR.YAxis,{domain:[0,100],tickFormatter:eG,tick:{fill:"var(--color-text-muted)",fontSize:12},axisLine:{stroke:"var(--color-border)"},tickLine:{stroke:"var(--color-border)"},width:44}),(0,t.jsx)(eT.Tooltip,{labelFormatter:t=>eB(String(t),e),formatter:(e,t)=>[eG(e),t],contentStyle:{backgroundColor:"var(--color-surface)",borderColor:"var(--color-border)",borderRadius:12,color:"var(--color-text-main)",boxShadow:"var(--shadow-soft)"},itemStyle:{color:"var(--color-text-main)"},labelStyle:{color:"var(--color-text-main)",fontWeight:600}}),(0,t.jsx)(eS,{}),r?.providers.map(e=>(0,t.jsx)(eC.Line,{type:"monotone",dataKey:e,name:e,stroke:m.get(e)??"var(--color-primary)",strokeWidth:2.5,dot:!1,activeDot:{r:4,strokeWidth:0},connectNulls:!0},e))]})})}),(0,t.jsx)("div",{className:"grid grid-cols-1 gap-4 md:grid-cols-2 xl:grid-cols-3",children:u.map(a=>{let s=a.remainingPct<=20;return(0,t.jsxs)(eL.default.Section,{className:"flex h-full flex-col gap-4",children:[(0,t.jsxs)("div",{className:"flex items-start justify-between gap-3",children:[(0,t.jsxs)("div",{className:"flex items-center gap-3",children:[(0,t.jsx)("div",{className:"flex h-11 w-11 items-center justify-center rounded-xl border border-black/5 bg-surface text-text-main dark:border-white/5",children:(0,t.jsx)(eM.default,{providerId:a.provider,size:22})}),(0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"text-sm font-semibold text-text-main",children:a.provider}),(0,t.jsx)("p",{className:"text-xs text-text-muted",children:"Latest quota snapshot"})]})]}),(0,t.jsx)("span",{className:`inline-flex items-center rounded-full px-2.5 py-1 text-xs font-medium ${a.isExhausted?"bg-error/10 text-error":s?"bg-warning/10 text-warning":"bg-success/10 text-success"}`,children:a.isExhausted?"Exhausted":s?"Low":"Healthy"})]}),(0,t.jsxs)("div",{className:"flex items-end justify-between gap-3",children:[(0,t.jsxs)("div",{children:[(0,t.jsxs)("p",{className:"text-3xl font-bold text-text-main",children:[a.remainingPct.toFixed(+(a.remainingPct<10)),"%"]}),(0,t.jsx)("p",{className:"mt-1 text-xs text-text-muted",children:"Remaining capacity"})]}),(0,t.jsxs)("div",{className:"text-right text-xs text-text-muted",children:[(0,t.jsx)("p",{children:eB(a.timestamp,e)}),(0,t.jsx)("p",{className:"mt-1 uppercase tracking-[0.14em]",children:a.windowKey})]})]}),(0,t.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,t.jsx)("div",{className:"h-2 overflow-hidden rounded-full bg-black/5 dark:bg-white/5",children:(0,t.jsx)("div",{className:`h-full rounded-full transition-all ${a.isExhausted?"bg-error":s?"bg-warning":"bg-primary"}`,style:{width:`${Math.max(a.remainingPct,0)}%`}})}),(0,t.jsxs)("div",{className:"flex items-center justify-between text-xs text-text-muted",children:[(0,t.jsx)("span",{children:"0%"}),(0,t.jsx)("span",{children:"Remaining quota"}),(0,t.jsx)("span",{children:"100%"})]})]})]},a.provider)})})]}):(0,t.jsxs)("div",{className:"flex min-h-80 flex-col items-center justify-center gap-4 text-center",children:[(0,t.jsx)("span",{className:"material-symbols-outlined text-[40px] text-text-muted/70",children:"timeline"}),(0,t.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,t.jsx)("p",{className:"text-sm font-medium text-text-main",children:"No utilization data available"}),(0,t.jsx)("p",{className:"max-w-md text-sm text-text-muted",children:"Provider quota snapshots will appear here after utilization data is collected."})]}),(0,t.jsxs)("div",{className:"rounded-lg border border-black/5 bg-black/[0.02] p-4 dark:border-white/5 dark:bg-white/[0.02]",children:[(0,t.jsx)("p",{className:"text-xs font-medium text-text-main",children:"Getting started"}),(0,t.jsxs)("ul",{className:"mt-2 text-left text-xs text-text-muted",children:[(0,t.jsxs)("li",{className:"flex items-start gap-2",children:[(0,t.jsx)("span",{className:"material-symbols-outlined text-[14px] text-primary",children:"check_circle"}),(0,t.jsxs)("span",{children:["Connect providers via OAuth or API keys in ",(0,t.jsx)("strong",{children:"Providers"})]})]}),(0,t.jsxs)("li",{className:"mt-1 flex items-start gap-2",children:[(0,t.jsx)("span",{className:"material-symbols-outlined text-[14px] text-primary",children:"check_circle"}),(0,t.jsx)("span",{children:"Enable quota tracking by using the provider in a combo or direct request"})]}),(0,t.jsxs)("li",{className:"mt-1 flex items-start gap-2",children:[(0,t.jsx)("span",{className:"material-symbols-outlined text-[14px] text-primary",children:"check_circle"}),(0,t.jsx)("span",{children:"Data will appear automatically as quota snapshots are collected"})]})]})]})]})})})}var eW=e.i(969353);function eU(e,t=0){return`${e.toFixed(t)}%`}function eV(e){return eU(100*e,1)}function eJ({icon:e,label:a,value:s,subValue:r}){return(0,t.jsxs)("div",{className:"rounded-lg border border-black/5 bg-black/[0.02] p-4 dark:border-white/5 dark:bg-white/[0.02]",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2 text-xs font-semibold uppercase tracking-wider text-text-muted",children:[(0,t.jsx)("span",{className:"material-symbols-outlined text-[16px]",children:e}),a]}),(0,t.jsx)("div",{className:"mt-2 text-2xl font-semibold text-text-main",children:s}),r?(0,t.jsx)("div",{className:"mt-1 text-xs text-text-muted",children:r}):null]})}function eY({label:e,value:a,meta:s}){let r=`${Math.max(100*a,6*(a>0))}%`;return(0,t.jsxs)("div",{className:"flex flex-col gap-2 rounded-lg border border-black/5 bg-black/[0.02] p-3 dark:border-white/5 dark:bg-white/[0.02]",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between gap-3 text-sm",children:[(0,t.jsx)("span",{className:"truncate font-medium text-text-main",children:e}),(0,t.jsx)("span",{className:"shrink-0 text-xs text-text-muted",children:s})]}),(0,t.jsx)("div",{className:"h-2 overflow-hidden rounded-full bg-black/5 dark:bg-white/5",children:(0,t.jsx)("div",{className:"h-full rounded-full bg-primary transition-all",style:{width:r}})})]})}function eZ({combo:e}){var s;let r=(0,a.useMemo)(()=>[...e.usageSkew.modelDistribution].sort((e,t)=>t.requestShare-e.requestShare),[e.usageSkew.modelDistribution]);return(0,t.jsxs)(eL.default,{className:"overflow-hidden p-0",children:[(0,t.jsx)("div",{className:"border-b border-black/5 px-6 py-5 dark:border-white/5",children:(0,t.jsxs)("div",{className:"flex flex-col gap-4 lg:flex-row lg:items-start lg:justify-between",children:[(0,t.jsxs)("div",{className:"min-w-0",children:[(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,t.jsx)("h3",{className:"text-lg font-semibold text-text-main",children:e.comboName}),(0,t.jsx)(eW.default,{variant:"primary",size:"sm",children:e.strategy})]}),(0,t.jsxs)("p",{className:"mt-2 text-sm text-text-muted",children:[e.models.length," models across ",e.quotaHealth.providers.length," providers"]})]}),(0,t.jsxs)("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-3 lg:min-w-[420px]",children:[(0,t.jsx)(eJ,{icon:"battery_status_good",label:"Worst quota left",value:eU(e.quotaHealth.worstRemainingPct)}),(0,t.jsx)(eJ,{icon:"balance",label:"Usage skew",value:e.usageSkew.giniCoefficient.toFixed(2),subValue:"Gini coefficient"}),(0,t.jsx)(eJ,{icon:"bolt",label:"Success rate",value:eU(100*e.performance.successRate,1),subValue:`${e.performance.totalRequests.toLocaleString()} requests`})]})]})}),(0,t.jsxs)("div",{className:"grid gap-6 px-6 py-5 xl:grid-cols-[1.1fr_1fr_0.95fr]",children:[(0,t.jsxs)("section",{className:"flex flex-col gap-4",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("div",{className:"text-sm font-semibold text-text-main",children:"Quota health"}),(0,t.jsx)("div",{className:"mt-1 text-xs text-text-muted",children:"Lowest remaining quota across providers with short trend signals."})]}),(0,t.jsx)("div",{className:"flex flex-col gap-3",children:e.quotaHealth.providers.map(e=>{var a;let s="improving"===(a=e.trend)?{icon:"trending_up",label:"Improving",variant:"success"}:"declining"===a?{icon:"trending_down",label:"Declining",variant:"warning"}:{icon:"trending_flat",label:"Stable",variant:"default"},r=`${Math.max(e.remainingPct,6*(e.remainingPct>0))}%`;return(0,t.jsxs)("div",{className:"rounded-lg border border-black/5 bg-black/[0.02] p-4 dark:border-white/5 dark:bg-white/[0.02]",children:[(0,t.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("div",{className:"text-sm font-medium text-text-main",children:e.provider}),(0,t.jsxs)("div",{className:"mt-1 text-xs text-text-muted",children:["Remaining quota ",eU(e.remainingPct,1)]})]}),(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)(eW.default,{variant:s.variant,size:"sm",icon:s.icon,children:s.label}),e.isExhausted?(0,t.jsx)(eW.default,{variant:"error",size:"sm",children:"Exhausted"}):null]})]}),(0,t.jsx)("div",{className:"mt-3 h-2 overflow-hidden rounded-full bg-black/5 dark:bg-white/5",children:(0,t.jsx)("div",{className:"h-full rounded-full bg-primary transition-all",style:{width:r}})})]},e.provider)})})]}),(0,t.jsxs)("section",{className:"flex flex-col gap-4",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("div",{className:"text-sm font-semibold text-text-main",children:"Usage skew"}),(0,t.jsx)("div",{className:"mt-1 text-xs text-text-muted",children:"Model request share and token share within this combo."})]}),(0,t.jsx)("div",{className:"flex flex-col gap-3",children:r.map(e=>(0,t.jsxs)("div",{className:"rounded-lg border border-black/5 bg-black/[0.02] p-4 dark:border-white/5 dark:bg-white/[0.02]",children:[(0,t.jsxs)("div",{className:"flex items-start justify-between gap-3",children:[(0,t.jsxs)("div",{className:"min-w-0",children:[(0,t.jsx)("div",{className:"truncate text-sm font-medium text-text-main",children:e.model}),(0,t.jsxs)("div",{className:"mt-1 text-xs text-text-muted",children:["Request share ",eV(e.requestShare)," · Token share"," ",eV(e.tokenShare)]})]}),(0,t.jsx)(eW.default,{size:"sm",children:eV(e.requestShare)})]}),(0,t.jsxs)("div",{className:"mt-3 grid gap-2",children:[(0,t.jsx)(eY,{label:"Requests",value:e.requestShare,meta:eV(e.requestShare)}),(0,t.jsx)(eY,{label:"Tokens",value:e.tokenShare,meta:eV(e.tokenShare)})]})]},e.model))})]}),(0,t.jsxs)("section",{className:"flex flex-col gap-4",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("div",{className:"text-sm font-semibold text-text-main",children:"Performance"}),(0,t.jsx)("div",{className:"mt-1 text-xs text-text-muted",children:"Reliability and throughput for routed combo traffic."})]}),(0,t.jsxs)("div",{className:"grid gap-3 sm:grid-cols-3 xl:grid-cols-1",children:[(0,t.jsx)(eJ,{icon:"timer",label:"Avg latency",value:(s=e.performance.avgLatencyMs,`${Math.round(s).toLocaleString()}ms`)}),(0,t.jsx)(eJ,{icon:"task_alt",label:"Success rate",value:eU(100*e.performance.successRate,1)}),(0,t.jsx)(eJ,{icon:"stacked_line_chart",label:"Total requests",value:e.performance.totalRequests.toLocaleString()})]})]})]})]})}function eQ(){return(0,t.jsx)("div",{className:"flex flex-col gap-4",children:[0,1].map(e=>(0,t.jsx)(eL.default,{className:"p-6",children:(0,t.jsxs)("div",{className:"flex flex-col gap-6",children:[(0,t.jsxs)("div",{className:"flex flex-col gap-4 xl:flex-row xl:items-center xl:justify-between",children:[(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)(r.Skeleton,{className:"h-6 w-40"}),(0,t.jsx)(r.Skeleton,{className:"h-4 w-52"})]}),(0,t.jsx)("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-3 xl:min-w-[420px]",children:[0,1,2].map(e=>(0,t.jsx)(r.Skeleton,{className:"h-24 rounded-lg"},e))})]}),(0,t.jsx)("div",{className:"grid gap-4 xl:grid-cols-3",children:[0,1,2].map(e=>(0,t.jsxs)("div",{className:"space-y-3",children:[(0,t.jsx)(r.Skeleton,{className:"h-5 w-28"}),(0,t.jsx)(r.Skeleton,{className:"h-24 rounded-lg"}),(0,t.jsx)(r.Skeleton,{className:"h-24 rounded-lg"})]},e))})]})},e))})}function eX(){let[e,s]=(0,a.useState)("24h"),[l,i]=(0,a.useState)(null),[n,c]=(0,a.useState)(!0),[o,d]=(0,a.useState)(null),[m,x]=(0,a.useState)(!1),u=(0,a.useCallback)(async(t,a=!1)=>{a?x(!0):c(!0),d(null);try{let a=await fetch(`/api/usage/combo-health?range=${e}`,{signal:t.signal});if(!a.ok)throw Error("Failed to fetch combo health data");let s=await a.json();i(s),d(null)}catch(e){if("AbortError"===e.name)return;d(e instanceof Error?e.message:"Unknown error"),a||i(null)}finally{!t.signal.aborted&&(c(!1),a&&x(!1))}},[e]);(0,a.useEffect)(()=>{let e=new AbortController;return u(e,!1),()=>e.abort()},[u]);let h=l?.combos??[],p=(0,a.useCallback)(()=>{u(new AbortController,!0)},[u]);return(0,t.jsxs)("div",{className:"flex flex-col gap-6",children:[(0,t.jsxs)("div",{className:"flex flex-col gap-4 rounded-xl border border-black/5 bg-surface p-5 shadow-sm dark:border-white/5 md:flex-row md:items-center md:justify-between",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("h2",{className:"text-lg font-semibold text-text-main",children:"Combo health"}),(0,t.jsx)("p",{className:"mt-1 text-sm text-text-muted",children:"Monitor quota pressure, skewed model usage, and delivery performance by combo."})]}),(0,t.jsx)(eI,{value:e,onChange:s})]}),n?(0,t.jsx)(eQ,{}):null,!n&&o?(0,t.jsx)(eL.default,{className:"p-8",children:(0,t.jsxs)("div",{className:"flex flex-col items-center justify-center gap-4 text-center",children:[(0,t.jsx)("span",{className:"material-symbols-outlined text-[40px] text-error",children:"sync_problem"}),(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,t.jsx)("div",{className:"font-medium text-text-main",children:"Unable to load combo health"}),(0,t.jsx)("div",{className:"text-sm text-text-muted",children:o})]}),(0,t.jsx)("button",{type:"button",onClick:p,disabled:m,className:"inline-flex items-center gap-2 rounded-lg bg-primary px-4 py-2 text-sm font-medium text-white hover:bg-primary-hover disabled:opacity-50 disabled:cursor-not-allowed",children:m?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("span",{className:"material-symbols-outlined animate-spin text-[18px]",children:"progress_activity"}),"Retrying…"]}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:"refresh"}),"Retry"]})})]})}):null,n||o||0!==h.length?null:(0,t.jsx)(eL.default,{className:"p-10",children:(0,t.jsxs)("div",{className:"flex flex-col items-center justify-center gap-4 text-center",children:[(0,t.jsx)("span",{className:"material-symbols-outlined text-[40px] text-text-muted/70",children:"monitor_heart"}),(0,t.jsx)("div",{className:"text-base font-medium text-text-main",children:"No combo health data available"}),(0,t.jsx)("div",{className:"max-w-md text-sm text-text-muted",children:"Combo quota snapshots and routed requests will appear here after traffic starts flowing."}),(0,t.jsxs)("div",{className:"rounded-lg border border-black/5 bg-black/[0.02] p-4 dark:border-white/5 dark:bg-white/[0.02]",children:[(0,t.jsx)("p",{className:"text-xs font-medium text-text-main",children:"Getting started"}),(0,t.jsxs)("ul",{className:"mt-2 text-left text-xs text-text-muted",children:[(0,t.jsxs)("li",{className:"flex items-start gap-2",children:[(0,t.jsx)("span",{className:"material-symbols-outlined text-[14px] text-primary",children:"check_circle"}),(0,t.jsxs)("span",{children:["Create combos in ",(0,t.jsx)("strong",{children:"Combos"})," with multiple providers"]})]}),(0,t.jsxs)("li",{className:"mt-1 flex items-start gap-2",children:[(0,t.jsx)("span",{className:"material-symbols-outlined text-[14px] text-primary",children:"check_circle"}),(0,t.jsx)("span",{children:"Send requests to combo endpoints to generate traffic data"})]}),(0,t.jsxs)("li",{className:"mt-1 flex items-start gap-2",children:[(0,t.jsx)("span",{className:"material-symbols-outlined text-[14px] text-primary",children:"check_circle"}),(0,t.jsx)("span",{children:"Health metrics will appear automatically as requests are routed"})]})]})]})]})}),n||o||!(h.length>0)?null:(0,t.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2 text-sm text-text-muted",children:[(0,t.jsx)(r.Spinner,{size:"sm",className:(0,e$.cn)("text-primary","[&_.material-symbols-outlined]:text-[16px]")}),"Tracking ",h.length," combos for ",e]}),h.map(e=>(0,t.jsx)(eZ,{combo:e},e.comboId))]})]})}e.s(["default",0,function(){let[e,n]=(0,a.useState)("overview"),c=(0,i.useTranslations)("analytics"),o={overview:c("overviewDescription"),evals:c("evalsDescription"),search:"Search request analytics — provider breakdown, cache hit rate, and cost tracking.",utilization:c("utilizationDescription"),comboHealth:c("comboHealthDescription")};return(0,t.jsxs)("div",{className:"flex flex-col gap-6",children:[(0,t.jsxs)("div",{children:[(0,t.jsxs)("h1",{className:"text-2xl font-bold flex items-center gap-2",children:[(0,t.jsx)("span",{className:"material-symbols-outlined text-primary text-[28px]",children:"analytics"}),c("title")]}),(0,t.jsx)("p",{className:"text-sm text-text-muted mt-1",children:o[e]})]}),(0,t.jsx)(l.SegmentedControl,{options:[{value:"overview",label:c("overview")},{value:"evals",label:c("evals")},{value:"search",label:"Search"},{value:"utilization",label:c("utilization")},{value:"comboHealth",label:c("comboHealth")}],value:e,onChange:n}),"overview"===e&&(0,t.jsxs)("div",{className:"flex flex-col gap-6",children:[(0,t.jsx)("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-6",children:(0,t.jsx)(v,{})}),(0,t.jsx)(a.Suspense,{fallback:(0,t.jsx)(r.CardSkeleton,{}),children:(0,t.jsx)(s.default,{})})]}),"evals"===e&&(0,t.jsx)(h,{}),"search"===e&&(0,t.jsx)(b,{}),"utilization"===e&&(0,t.jsx)(eK,{}),"comboHealth"===e&&(0,t.jsx)(eX,{})]})}],463082)}]);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,710864,e=>{"use strict";var t=e.i(843476),a=e.i(271645),r=e.i(174080),o=e.i(627949),l=e.i(745009),i=e.i(618566),s=e.i(522016),n=e.i(657688),d=e.i(948148);e.i(565650);var c=e.i(11477),p=e.i(474078),u=e.i(628029),m=e.i(339971),x=e.i(87855),h=e.i(454149),f=e.i(116016),f=f,g=e.i(567955),g=g,v=e.i(419947),v=v,b=e.i(148943),y=e.i(961430),j=e.i(105370),C=e.i(623249);e.i(313705);var N=e.i(25230),w=e.i(753557),k=e.i(556938);let S=["openai","openai-responses","claude"];function T(e){let t=new Map;for(let a of e)a.id&&t.set(a.id,a);return t}function A(e,t,a){return e?.compatByProtocol?.[a]??t?.compatByProtocol?.[a]}function P(e,t,a,r){let o=a.get(e),l=r.get(e),i=A(o,l,t);return i&&Object.prototype.hasOwnProperty.call(i,"normalizeToolCallId")?!!i.normalizeToolCallId:!!o?.normalizeToolCallId||!!l?.normalizeToolCallId}function R(e,t,a,r){let o=a.get(e),l=r.get(e),i=A(o,l,t);return i&&Object.prototype.hasOwnProperty.call(i,"preserveOpenAIDeveloperRole")?!!i.preserveOpenAIDeveloperRole:o&&Object.prototype.hasOwnProperty.call(o,"preserveOpenAIDeveloperRole")?!!o.preserveOpenAIDeveloperRole:!(l&&Object.prototype.hasOwnProperty.call(l,"preserveOpenAIDeveloperRole"))||!!l.preserveOpenAIDeveloperRole}async function M(e){try{let t=await e.json(),a=t?.error;if(Array.isArray(a?.details)&&a.details.length>0)return a.details.map(e=>{let t="string"==typeof e.field&&e.field?e.field:"?",a="string"==typeof e.message?e.message:"";return a?`${t}: ${a}`:t}).join("; ");if("string"==typeof a?.message&&a.message.trim())return a.message.trim()}catch{}return e.statusText?.trim()||`HTTP ${e.status}`}function I(e,t,a,r){let o=a.get(e),l=r.get(e),i={};o?.upstreamHeaders&&"object"==typeof o.upstreamHeaders?Object.assign(i,o.upstreamHeaders):l?.upstreamHeaders&&"object"==typeof l.upstreamHeaders&&Object.assign(i,l.upstreamHeaders);let s=A(o,l,t);return s?.upstreamHeaders&&"object"==typeof s.upstreamHeaders&&Object.assign(i,s.upstreamHeaders),i}let E="CC Compatible",O="CC Compatible Details",D="/v1/messages?beta=true";function U(e){let t=e&&"object"==typeof e&&!Array.isArray(e)?e:{};return{use5h:"boolean"!=typeof t.use5h||t.use5h,useWeekly:"boolean"!=typeof t.useWeekly||t.useWeekly}}function L({t:e,effectiveModelNormalize:o,effectiveModelPreserveDeveloper:l,getUpstreamHeadersRecord:i,onCompatPatch:s,showDeveloperToggle:n=!0,disabled:d}){let[c,p]=(0,a.useState)(!1),[u,x]=(0,a.useState)(S[0]),[h,f]=(0,a.useState)([]),[g,v]=(0,a.useState)(null),[y,j]=(0,a.useState)(null),C=(0,a.useRef)(null),N=(0,a.useRef)(null),[w,k]=(0,a.useState)(null),T=(0,a.useRef)(0),A=(0,a.useRef)([]);A.current=h;let P=()=>(T.current+=1,`uh-${T.current}`),R=o(u),M=l(u),I=n&&"claude"!==u,E=(0,a.useCallback)(e=>{let t,a,r=function(e){let t={};for(let a of e){let e=a.name.trim();e&&(t[e]=a.value)}return t}(e),o=i(u);t=Object.keys(r).sort(),a=Object.keys(o).sort(),t.length===a.length&&t.every((e,t)=>e===a[t]&&r[e]===o[e])||s(u,{upstreamHeaders:r})},[i,s,u]),O=(0,a.useCallback)(()=>{queueMicrotask(()=>E(A.current))},[E]);(0,a.useEffect)(()=>{if(c)return()=>{E(A.current)}},[c,E]),(0,a.useEffect)(()=>{var e;let t;c&&f((e=i(u),0===(t=Object.entries(e).filter(([e])=>e.trim())).length?[{id:P(),name:"",value:""}]:t.map(([e,t])=>({id:P(),name:e,value:t}))))},[c,u]),(0,a.useEffect)(()=>{v(null),j(null)},[c,u]);let D=h.filter(e=>e.name.trim()).length<16,U=(e,t)=>{f(a=>a.map(a=>a.id===e?{...a,...t}:a))};(0,a.useEffect)(()=>{if(!c)return;let e=e=>{let t=e.target,a=C.current?.contains(t),r=N.current?.contains(t);a||r||p(!1)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[c]);let $=(0,a.useCallback)(()=>{if(!c||!C.current)return;let e=C.current.getBoundingClientRect(),t=Math.min(window.innerWidth-20,384),a=e.right-t;a=Math.max(10,Math.min(a,window.innerWidth-t-10)),k({top:e.bottom+8,left:a,width:t})},[c]);return(0,a.useLayoutEffect)(()=>c?($(),window.addEventListener("resize",$),window.addEventListener("scroll",$,!0),()=>{window.removeEventListener("resize",$),window.removeEventListener("scroll",$,!0)}):void k(null),[c,$]),(0,t.jsxs)("div",{className:"relative inline-flex",ref:C,children:[(0,t.jsxs)("button",{type:"button",onClick:()=>p(e=>!e),disabled:d,className:"inline-flex items-center gap-1.5 px-2.5 py-1.5 text-xs font-medium rounded-lg border border-border bg-background text-text-muted hover:bg-muted hover:text-text-main disabled:opacity-50 transition-colors",title:e("compatAdjustmentsTitle"),children:[(0,t.jsx)("span",{className:"material-symbols-outlined text-base leading-none",children:"tune"}),e("compatButtonLabel")]}),c&&"u">typeof document&&w&&(0,r.createPortal)((0,t.jsxs)("div",{ref:N,className:"flex max-h-[min(82vh,42rem)] flex-col overflow-hidden rounded-xl border-2 border-zinc-200 bg-white shadow-2xl dark:border-zinc-600 dark:bg-zinc-950",style:{position:"fixed",top:w.top,left:w.left,width:w.width,zIndex:10040},children:[(0,t.jsxs)("div",{className:"shrink-0 border-b-2 border-zinc-200 bg-zinc-100 px-3 py-2.5 dark:border-zinc-600 dark:bg-zinc-900",children:[(0,t.jsx)("p",{className:"text-xs font-semibold text-text-main",children:e("compatAdjustmentsTitle")}),(0,t.jsx)("p",{className:"text-[11px] text-text-muted mt-1 leading-relaxed",children:e("compatProtocolHint")})]}),(0,t.jsxs)("div",{className:"min-h-0 flex-1 overflow-x-hidden overflow-y-auto bg-white p-3 [scrollbar-gutter:stable] [scrollbar-width:thin] dark:bg-zinc-950",children:[(0,t.jsx)("label",{className:"block text-[11px] font-medium text-text-muted mb-1.5",children:e("compatProtocolLabel")}),(0,t.jsx)("select",{value:u,onChange:e=>x(e.target.value),disabled:d,className:"mb-4 w-full rounded-lg border border-zinc-200 bg-white px-2.5 py-2 text-xs text-text-main focus:border-primary focus:outline-none focus:ring-2 focus:ring-primary/30 dark:border-zinc-600 dark:bg-zinc-900",children:S.map(a=>(0,t.jsx)("option",{value:a,children:e("openai"===a?"compatProtocolOpenAI":"openai-responses"===a?"compatProtocolOpenAIResponses":"claude"===a?"compatProtocolClaude":"compatProtocolOpenAI")},a))}),(0,t.jsxs)("div",{className:"flex flex-col gap-3.5",children:[(0,t.jsx)(b.Toggle,{size:"sm",label:e("compatToolIdShort"),title:e("normalizeToolCallIdLabel"),checked:R,onChange:e=>s(u,{normalizeToolCallId:e}),disabled:d}),I&&(0,t.jsx)(b.Toggle,{size:"sm",label:e("compatDoNotPreserveDeveloper"),title:e("preserveDeveloperRoleLabel"),checked:!1===M,onChange:e=>s(u,{preserveOpenAIDeveloperRole:!e}),disabled:d})]}),(0,t.jsxs)("div",{className:"mt-4 rounded-lg border-2 border-zinc-200 bg-zinc-100 p-3 dark:border-zinc-600 dark:bg-zinc-900",children:[(0,t.jsx)("label",{className:"block text-[11px] font-semibold text-text-main mb-1",children:e("compatUpstreamHeadersLabel")}),(0,t.jsx)("p",{className:"text-[11px] text-text-muted mb-3 leading-relaxed",children:e("compatUpstreamHeadersHint")}),(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsxs)("div",{className:"grid grid-cols-[minmax(0,1fr)_minmax(0,1fr)_auto] gap-1.5 items-end text-[10px] font-medium uppercase tracking-wide text-text-muted px-0.5",children:[(0,t.jsx)("span",{children:e("compatUpstreamHeaderName")}),(0,t.jsx)("span",{className:"col-span-1",children:e("compatUpstreamHeaderValue")}),(0,t.jsx)("span",{className:"w-8 shrink-0","aria-hidden":!0})]}),h.map(a=>(0,t.jsxs)("div",{className:"grid grid-cols-[minmax(0,1fr)_minmax(0,1fr)_auto] gap-1.5 items-center",children:[(0,t.jsx)(m.Input,{value:a.name,onChange:e=>U(a.id,{name:e.target.value}),onBlur:O,disabled:d,placeholder:"Authentication",className:"gap-0 min-w-0",inputClassName:"h-9 bg-white py-1.5 px-2 text-xs font-mono dark:bg-zinc-900",autoComplete:"off"}),(0,t.jsx)("div",{className:"min-w-0",onMouseEnter:()=>v(a.id),onMouseLeave:()=>v(e=>e===a.id?null:e),children:(0,t.jsx)(m.Input,{type:g===a.id||y===a.id?"text":"password",value:a.value,onChange:e=>U(a.id,{value:e.target.value}),onFocus:()=>j(a.id),onBlur:()=>{j(e=>e===a.id?null:e),O()},disabled:d,placeholder:"•••",className:"gap-0 min-w-0",inputClassName:"h-9 bg-white py-1.5 px-2 text-xs dark:bg-zinc-900",autoComplete:"off",spellCheck:!1})}),(0,t.jsx)("button",{type:"button",disabled:d||h.length<=1,onClick:()=>{var e;return e=a.id,void f(t=>{let a=t.filter(t=>t.id!==e),r=0===a.length?[{id:P(),name:"",value:""}]:a;return queueMicrotask(()=>E(r)),r})},title:e("compatUpstreamRemoveRow"),className:"flex h-9 w-9 shrink-0 items-center justify-center rounded-lg border border-border/80 text-text-muted hover:bg-red-500/10 hover:text-red-600 dark:hover:text-red-400 disabled:opacity-30 disabled:hover:bg-transparent disabled:hover:text-text-muted transition-colors",children:(0,t.jsx)("span",{className:"material-symbols-outlined text-lg leading-none",children:"close"})})]},a.id))]}),(0,t.jsxs)("button",{type:"button",disabled:d||!D,onClick:()=>{D&&f(e=>[...e,{id:P(),name:"",value:""}])},className:"mt-3 flex w-full items-center justify-center gap-1.5 rounded-lg border border-dashed border-border py-2 text-xs font-medium text-primary hover:bg-primary/5 disabled:opacity-40 disabled:hover:bg-transparent transition-colors",children:[(0,t.jsx)("span",{className:"material-symbols-outlined text-base leading-none",children:"add"}),e("compatUpstreamAddRow")]})]})]})]}),document.body)]})}function $({model:e,fullModel:a,copied:r,onCopy:o,t:l,showDeveloperToggle:i=!0,effectiveModelNormalize:s,effectiveModelPreserveDeveloper:n,getUpstreamHeadersRecord:d,saveModelCompatFlags:c,compatDisabled:p}){return(0,t.jsxs)("div",{className:"flex min-w-[220px] max-w-md items-center gap-2 rounded-lg border border-border px-3 py-2 hover:bg-sidebar/50",children:[(0,t.jsxs)("div",{className:"flex min-w-0 flex-1 flex-wrap items-center gap-2",children:[(0,t.jsx)("span",{className:"material-symbols-outlined shrink-0 text-base text-text-muted",children:"smart_toy"}),(0,t.jsx)("code",{className:"rounded bg-sidebar px-1.5 py-0.5 font-mono text-xs text-text-muted",children:a}),(0,t.jsx)("button",{onClick:()=>o(a,`model-${e.id}`),className:"rounded p-0.5 text-text-muted hover:bg-sidebar hover:text-primary",title:l("copyModel"),children:(0,t.jsx)("span",{className:"material-symbols-outlined text-sm",children:r===`model-${e.id}`?"check":"content_copy"})})]}),(0,t.jsx)("div",{className:"shrink-0",children:(0,t.jsx)(L,{t:l,effectiveModelNormalize:t=>s(e.id,t),effectiveModelPreserveDeveloper:t=>n(e.id,t),getUpstreamHeadersRecord:d,onCompatPatch:(t,a)=>c(e.id,{compatByProtocol:{[t]:a}}),showDeveloperToggle:i,disabled:p})})]})}function F({providerAlias:e,modelAliases:r,copied:o,onCopy:l,onSetAlias:i,onDeleteAlias:s,t:n,effectiveModelNormalize:d,effectiveModelPreserveDeveloper:c,getUpstreamHeadersRecord:u,saveModelCompatFlags:m,compatSavingModelId:x}){let[h,f]=(0,a.useState)(""),[g,v]=(0,a.useState)(!1),b=Object.entries(r).filter(([,t])=>t.startsWith(`${e}/`)).map(([t,a])=>({modelId:a.replace(`${e}/`,""),fullModel:a,alias:t})),y=async()=>{let e;if(!h.trim()||g)return;let t=h.trim(),a=(e=t.split("/"))[e.length-1];if(r[a])return void alert(n("aliasExistsAlert",{alias:a}));v(!0);try{await i(t,a),f("")}catch(e){console.log("Error adding model:",e)}finally{v(!1)}};return(0,t.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,t.jsx)("p",{className:"text-sm text-text-muted",children:n("openRouterAnyModelHint")}),(0,t.jsxs)("div",{className:"flex items-end gap-2",children:[(0,t.jsxs)("div",{className:"flex-1",children:[(0,t.jsx)("label",{htmlFor:"new-model-input",className:"text-xs text-text-muted mb-1 block",children:n("modelIdFromOpenRouter")}),(0,t.jsx)("input",{id:"new-model-input",type:"text",value:h,onChange:e=>f(e.target.value),onKeyDown:e=>"Enter"===e.key&&y(),placeholder:n("openRouterModelPlaceholder"),className:"w-full px-3 py-2 text-sm border border-border rounded-lg bg-background focus:outline-none focus:border-primary"})]}),(0,t.jsx)(p.Button,{size:"sm",icon:"add",onClick:y,disabled:!h.trim()||g,children:g?n("adding"):n("add")})]}),b.length>0&&(0,t.jsx)("div",{className:"flex flex-col gap-3",children:b.map(({modelId:e,fullModel:a,alias:r})=>(0,t.jsx)(_,{modelId:e,fullModel:a,copied:o,onCopy:l,onDeleteAlias:()=>s(r),t:n,showDeveloperToggle:!0,effectiveModelNormalize:d,effectiveModelPreserveDeveloper:c,getUpstreamHeadersRecord:t=>u(e,t),saveModelCompatFlags:m,compatDisabled:x===e},a))})]})}function _({modelId:e,fullModel:a,copied:r,onCopy:o,onDeleteAlias:l,t:i,showDeveloperToggle:s=!0,effectiveModelNormalize:n,effectiveModelPreserveDeveloper:d,getUpstreamHeadersRecord:c,saveModelCompatFlags:p,compatDisabled:u}){return(0,t.jsxs)("div",{className:"flex gap-0 rounded-lg border border-border p-3 hover:bg-sidebar/50",children:[(0,t.jsxs)("div",{className:"flex min-w-0 flex-1 items-start gap-3",children:[(0,t.jsx)("span",{className:"material-symbols-outlined shrink-0 text-base text-text-muted",children:"smart_toy"}),(0,t.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,t.jsx)("p",{className:"truncate text-sm font-medium",children:e}),(0,t.jsxs)("div",{className:"mt-1 flex flex-wrap items-center gap-1",children:[(0,t.jsx)("code",{className:"rounded bg-sidebar px-1.5 py-0.5 font-mono text-xs text-text-muted",children:a}),(0,t.jsx)("button",{onClick:()=>o(a,`model-${e}`),className:"rounded p-0.5 text-text-muted hover:bg-sidebar hover:text-primary",title:i("copyModel"),children:(0,t.jsx)("span",{className:"material-symbols-outlined text-sm",children:r===`model-${e}`?"check":"content_copy"})})]})]})]}),(0,t.jsxs)("div",{className:"flex shrink-0 items-center gap-1 self-start",children:[(0,t.jsx)(L,{t:i,effectiveModelNormalize:t=>n(e,t),effectiveModelPreserveDeveloper:t=>d(e,t),getUpstreamHeadersRecord:c,onCompatPatch:(t,a)=>p(e,{compatByProtocol:{[t]:a}}),showDeveloperToggle:s,disabled:u}),(0,t.jsx)("button",{onClick:l,className:"rounded p-1 text-red-500 hover:bg-red-50",title:i("removeModel"),children:(0,t.jsx)("span",{className:"material-symbols-outlined text-sm",children:"delete"})})]})]})}function B({providerId:e,providerAlias:r,copied:l,onCopy:i,onModelsChanged:s}){let n=(0,d.useTranslations)("providers"),c=(0,o.useNotificationStore)(),[u,m]=(0,a.useState)([]),[x,h]=(0,a.useState)([]),[f,g]=(0,a.useState)(""),[v,b]=(0,a.useState)(""),[y,j]=(0,a.useState)("chat-completions"),[C,N]=(0,a.useState)(["chat"]),[w,k]=(0,a.useState)(!1),[E,O]=(0,a.useState)(!0),[D,U]=(0,a.useState)(null),[$,F]=(0,a.useState)("chat-completions"),[_,q]=(0,a.useState)(["chat"]),[z,K]=(0,a.useState)(null),H=(0,a.useMemo)(()=>T(u),[u]),J=(0,a.useMemo)(()=>T(x),[x]),W=(0,a.useCallback)(async()=>{try{let t=await fetch(`/api/provider-models?provider=${encodeURIComponent(e)}`);if(t.ok){let e=await t.json();m(e.models||[]),h(e.modelCompatOverrides||[])}}catch(e){console.error("Failed to fetch custom models:",e)}finally{O(!1)}},[e]);(0,a.useEffect)(()=>{W()},[W]);let V=async()=>{if(f.trim()&&!w){k(!0);try{(await fetch("/api/provider-models",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:e,modelId:f.trim(),modelName:v.trim()||void 0,apiFormat:y,supportedEndpoints:C})})).ok&&(g(""),b(""),j("chat-completions"),N(["chat"]),await W(),s?.())}catch(e){console.error("Failed to add custom model:",e)}finally{k(!1)}}},G=async t=>{try{await fetch(`/api/provider-models?provider=${encodeURIComponent(e)}&model=${encodeURIComponent(t)}`,{method:"DELETE"}),await W(),s?.()}catch(e){console.error("Failed to remove custom model:",e)}},Q=()=>{U(null),F("chat-completions"),q(["chat"]),K(null)},Y=async(t,a)=>{K(t);try{let r=await fetch("/api/provider-models",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:e,modelId:t,...a})});if(!r.ok){let e=await M(r);c.error(e?`${n("failedSaveCustomModel")} — ${e}`:n("failedSaveCustomModel"));return}}catch{c.error(n("failedSaveCustomModel"));return}finally{K(null)}try{await W(),s?.()}catch{}},X=async t=>{if(D&&D===t){if(!_.length)return void c.error("Select at least one supported endpoint");K(t);try{let a=u.find(e=>e.id===t),r=await fetch("/api/provider-models",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:e,modelId:t,modelName:a?.name||t,source:a?.source||"manual",apiFormat:$,supportedEndpoints:_})});if(!r.ok){let e=await M(r);throw Error(e||"Failed to save model endpoint settings")}await W(),s?.(),c.success("Saved model endpoint settings"),Q()}catch(e){console.error("Failed to save custom model:",e),c.error(e instanceof Error&&e.message?e.message:"Failed to save model endpoint settings")}finally{K(null)}}};return(0,t.jsxs)("div",{className:"mt-6 pt-6 border-t border-border",children:[(0,t.jsxs)("h3",{className:"text-sm font-semibold mb-3 flex items-center gap-2",children:[(0,t.jsx)("span",{className:"material-symbols-outlined text-base text-primary",children:"tune"}),n("customModels")]}),(0,t.jsx)("p",{className:"text-xs text-text-muted mb-3",children:n("customModelsHint")}),(0,t.jsxs)("div",{className:"flex flex-col gap-3 mb-3",children:[(0,t.jsxs)("div",{className:"flex items-end gap-2",children:[(0,t.jsxs)("div",{className:"flex-1",children:[(0,t.jsx)("label",{htmlFor:"custom-model-id",className:"text-xs text-text-muted mb-1 block",children:n("modelId")}),(0,t.jsx)("input",{id:"custom-model-id",type:"text",value:f,onChange:e=>g(e.target.value),onKeyDown:e=>"Enter"===e.key&&V(),placeholder:n("customModelPlaceholder"),className:"w-full px-3 py-2 text-sm border border-border rounded-lg bg-background focus:outline-none focus:border-primary"})]}),(0,t.jsxs)("div",{className:"w-40",children:[(0,t.jsx)("label",{htmlFor:"custom-model-name",className:"text-xs text-text-muted mb-1 block",children:n("displayName")}),(0,t.jsx)("input",{id:"custom-model-name",type:"text",value:v,onChange:e=>b(e.target.value),onKeyDown:e=>"Enter"===e.key&&V(),placeholder:n("optional"),className:"w-full px-3 py-2 text-sm border border-border rounded-lg bg-background focus:outline-none focus:border-primary"})]}),(0,t.jsx)(p.Button,{size:"sm",icon:"add",onClick:V,disabled:!f.trim()||w,children:w?n("adding"):n("add")})]}),(0,t.jsxs)("div",{className:"flex items-end gap-4 flex-wrap",children:[(0,t.jsxs)("div",{className:"w-48",children:[(0,t.jsx)("label",{htmlFor:"custom-api-format",className:"text-xs text-text-muted mb-1 block",children:"API Format"}),(0,t.jsxs)("select",{id:"custom-api-format",value:y,onChange:e=>j(e.target.value),className:"w-full px-3 py-2 text-sm border border-border rounded-lg bg-background focus:outline-none focus:border-primary",children:[(0,t.jsx)("option",{value:"chat-completions",children:"Chat Completions"}),(0,t.jsx)("option",{value:"responses",children:"Responses API"})]})]}),(0,t.jsxs)("div",{className:"flex-1",children:[(0,t.jsx)("span",{className:"text-xs text-text-muted mb-1 block",children:"Supported Endpoints"}),(0,t.jsx)("div",{className:"flex items-center gap-3",children:["chat","embeddings","images","audio"].map(e=>(0,t.jsxs)("label",{className:"flex items-center gap-1.5 text-xs text-text-main cursor-pointer",children:[(0,t.jsx)("input",{type:"checkbox",checked:C.includes(e),onChange:t=>{t.target.checked?N(t=>[...t,e]):N(t=>t.filter(t=>t!==e))},className:"rounded border-border"}),"chat"===e?"💬 Chat":"embeddings"===e?"📐 Embeddings":"images"===e?"🖼️ Images":"🔊 Audio"]},e))})]})]})]}),E?(0,t.jsx)("p",{className:"text-xs text-text-muted",children:n("loading")}):u.length>0?(0,t.jsx)("div",{className:"flex flex-col gap-2",children:u.map(e=>{let a=`${r}/${e.id}`,o=`custom-${e.id}`;return(0,t.jsxs)("div",{className:"flex items-center gap-3 rounded-lg border border-border p-3 hover:bg-sidebar/50",children:[D!==e.id&&(0,t.jsx)("span",{className:"material-symbols-outlined text-base text-primary shrink-0",children:"tune"}),(0,t.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,t.jsx)("p",{className:"text-sm font-medium truncate",children:e.name||e.id}),(0,t.jsxs)("div",{className:"flex items-center gap-1 mt-1 flex-wrap",children:[(0,t.jsx)("code",{className:"text-xs text-text-muted font-mono bg-sidebar px-1.5 py-0.5 rounded",children:a}),(0,t.jsx)("button",{onClick:()=>i(a,o),className:"p-0.5 hover:bg-sidebar rounded text-text-muted hover:text-primary",title:n("copyModel"),children:(0,t.jsx)("span",{className:"material-symbols-outlined text-sm",children:l===o?"check":"content_copy"})}),"responses"===e.apiFormat&&(0,t.jsx)("span",{className:"text-[10px] px-1.5 py-0.5 rounded-full bg-blue-500/15 text-blue-400 font-medium",children:"Responses"}),e.supportedEndpoints?.includes("embeddings")&&(0,t.jsx)("span",{className:"text-[10px] px-1.5 py-0.5 rounded-full bg-purple-500/15 text-purple-400 font-medium",children:"📐 Embed"}),e.supportedEndpoints?.includes("images")&&(0,t.jsx)("span",{className:"text-[10px] px-1.5 py-0.5 rounded-full bg-amber-500/15 text-amber-400 font-medium",children:"🖼️ Images"}),e.supportedEndpoints?.includes("audio")&&(0,t.jsx)("span",{className:"text-[10px] px-1.5 py-0.5 rounded-full bg-green-500/15 text-green-400 font-medium",children:"🔊 Audio"}),function(e,t,a){let r=t.get(e),o=a.get(e);if(r?.normalizeToolCallId||o?.normalizeToolCallId)return!0;for(let e of S){let t=A(r,o,e);if(t?.normalizeToolCallId)return!0}return!1}(e.id,H,J)&&(0,t.jsx)("span",{className:"text-[10px] px-1.5 py-0.5 rounded-full bg-slate-500/15 text-slate-400 font-medium",title:n("normalizeToolCallIdLabel"),children:"ID×9"}),function(e,t,a){let r=t.get(e),o=a.get(e);if(r&&Object.prototype.hasOwnProperty.call(r,"preserveOpenAIDeveloperRole")&&!1===r.preserveOpenAIDeveloperRole||o&&Object.prototype.hasOwnProperty.call(o,"preserveOpenAIDeveloperRole")&&!1===o.preserveOpenAIDeveloperRole)return!0;for(let e of S){let t=A(r,o,e);if(t&&Object.prototype.hasOwnProperty.call(t,"preserveOpenAIDeveloperRole")&&!1===t.preserveOpenAIDeveloperRole)return!0}return!1}(e.id,H,J)&&(0,t.jsx)("span",{className:"text-[10px] px-1.5 py-0.5 rounded-full bg-cyan-500/15 text-cyan-400 font-medium",title:n("compatDoNotPreserveDeveloper"),children:n("compatBadgeNoPreserve")}),function(e,t,a){let r=t.get(e),o=a.get(e),l=e=>e&&"object"==typeof e&&!Array.isArray(e)&&Object.keys(e).length>0;if(l(r?.upstreamHeaders)||l(o?.upstreamHeaders))return!0;for(let e of S){let t=A(r,o,e);if(l(t?.upstreamHeaders))return!0}return!1}(e.id,H,J)&&(0,t.jsx)("span",{className:"text-[10px] px-1.5 py-0.5 rounded-full bg-violet-500/15 text-violet-400 font-medium",title:n("compatUpstreamHeadersLabel"),children:n("compatBadgeUpstreamHeaders")})]}),D===e.id&&(0,t.jsx)("div",{className:"mt-3 min-w-0 max-w-full rounded-lg border border-border bg-muted p-3 dark:bg-zinc-900",children:(0,t.jsxs)("div",{className:"flex min-w-0 flex-wrap items-end gap-x-3 gap-y-2",children:[(0,t.jsxs)("div",{className:"w-[11rem] shrink-0 min-w-0",children:[(0,t.jsx)("label",{className:"text-xs text-text-muted mb-1 block",children:"API Format"}),(0,t.jsxs)("select",{value:$,onChange:e=>F(e.target.value),className:"w-full px-2.5 py-2 text-xs border border-border rounded-lg bg-background text-text-main focus:outline-none focus:border-primary",children:[(0,t.jsx)("option",{value:"chat-completions",children:"Chat Completions"}),(0,t.jsx)("option",{value:"responses",children:"Responses API"})]})]}),(0,t.jsxs)("div",{className:"flex min-w-0 flex-1 flex-wrap items-center gap-x-3 gap-y-1 overflow-x-auto overflow-y-visible [scrollbar-width:thin]",children:[(0,t.jsx)("span",{className:"text-xs text-text-muted shrink-0",children:"Supported Endpoints"}),(0,t.jsx)("div",{className:"flex flex-wrap items-center gap-x-2 sm:gap-x-3 gap-y-1 min-w-0",children:["chat","embeddings","images","audio"].map(e=>(0,t.jsxs)("label",{className:"flex items-center gap-1.5 text-xs text-text-main cursor-pointer whitespace-nowrap",children:[(0,t.jsx)("input",{type:"checkbox",checked:_.includes(e),onChange:t=>{t.target.checked?q(t=>t.includes(e)?t:[...t,e]):q(t=>t.filter(t=>t!==e))},className:"rounded border-border"}),"chat"===e?"💬 Chat":"embeddings"===e?"📐 Embeddings":"images"===e?"🖼️ Images":"🔊 Audio"]},e))})]}),(0,t.jsxs)("div",{className:"flex shrink-0 flex-wrap items-center gap-2 pb-0.5",children:[(0,t.jsx)(p.Button,{size:"sm",onClick:()=>X(e.id),disabled:z===e.id,children:z===e.id?n("saving"):n("save")}),(0,t.jsx)(p.Button,{size:"sm",variant:"ghost",onClick:Q,children:n("cancel")})]})]})})]}),(0,t.jsxs)("div",{className:"flex shrink-0 items-center gap-1",children:[(0,t.jsx)("button",{onClick:()=>{U(e.id),F(e.apiFormat||"chat-completions"),q(Array.isArray(e.supportedEndpoints)&&e.supportedEndpoints.length?e.supportedEndpoints:["chat"])},className:"rounded p-1 text-text-muted hover:bg-sidebar hover:text-primary",title:n("edit"),children:(0,t.jsx)("span",{className:"material-symbols-outlined text-sm",children:"edit"})}),(0,t.jsx)(L,{t:n,effectiveModelNormalize:t=>P(e.id,t,H,J),effectiveModelPreserveDeveloper:t=>R(e.id,t,H,J),getUpstreamHeadersRecord:t=>I(e.id,t,H,J),onCompatPatch:(t,a)=>Y(e.id,{compatByProtocol:{[t]:a}}),showDeveloperToggle:!0,disabled:z===e.id}),(0,t.jsx)("button",{onClick:()=>G(e.id),className:"rounded p-1 text-red-500 hover:bg-red-50",title:n("removeCustomModel"),children:(0,t.jsx)("span",{className:"material-symbols-outlined text-sm",children:"delete"})})]})]},e.id)})}):(0,t.jsx)("p",{className:"text-xs text-text-muted",children:n("noCustomModels")})]})}function q({providerStorageAlias:e,providerDisplayAlias:r,modelAliases:l,fallbackModels:i=[],description:s,inputLabel:n,inputPlaceholder:d,copied:c,onCopy:u,onSetAlias:m,onDeleteAlias:x,connections:h,isAnthropic:f,onImportWithProgress:g,t:v,effectiveModelNormalize:b,effectiveModelPreserveDeveloper:y,getUpstreamHeadersRecord:j,saveModelCompatFlags:C,compatSavingModelId:N,onModelsChanged:w,allowImport:k}){let[S,T]=(0,a.useState)(""),[A,P]=(0,a.useState)(!1),[R,M]=(0,a.useState)(!1),I=(0,o.useNotificationStore)(),E=(0,a.useMemo)(()=>Object.entries(l).filter(([,t])=>t.startsWith(`${e}/`)),[l,e]),O=(0,a.useMemo)(()=>{let t=E.map(([t,a])=>({modelId:a.replace(`${e}/`,""),alias:t})),a=new Set(t.map(e=>e.modelId));for(let e of i)!e?.id||a.has(e.id)||(t.push({modelId:e.id,alias:null}),a.add(e.id));return t},[i,E,e]),D=(0,a.useCallback)((t,a)=>(function({modelId:e,fullModel:t,providerDisplayAlias:a,existingAliases:r}){let o=function(e){let t=e.trim();if(!t)return"";let a=t.split("/").map(e=>e.trim()).filter(Boolean);return a[a.length-1]||t}(e);if(!o)return null;for(let[e,a]of Object.entries(r))if(a===t)return e;let l=a.trim(),i=[],s=new Set,n=e=>{let t=e.trim();!t||s.has(t)||(s.add(t),i.push(t))};for(let e of(n(o),l&&n(`${l}-${o}`),i))if(!(e in r)||r[e]===t)return e;for(let e=2;e<=5e3;e+=1){if(l){let a=`${l}-${o}-${e}`;if(!(a in r)||r[a]===t)return a}let a=`${o}-${e}`;if(!(a in r)||r[a]===t)return a}return null})({modelId:t,fullModel:`${e}/${t}`,providerDisplayAlias:r,existingAliases:a}),[r,e]),U=async()=>{if(!S.trim()||A)return;let t=S.trim(),a=D(t,l);if(!a)return void I.error(v("allSuggestedAliasesExist"));P(!0);try{let r=await fetch("/api/provider-models",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:e,modelId:t,modelName:t,source:"manual"})});if(!r.ok){let e={};try{e=await r.json()}catch(e){console.error("Failed to parse error response from custom model API:",e)}throw Error(e.error?.message||v("failedSaveCustomModel"))}await m(t,a,e),T(""),I.success(v("modelAddedSuccess",{modelId:t})),w?.()}catch(e){console.error("Error adding model:",e),I.error(e instanceof Error?e.message:v("failedAddModelTryAgain"))}finally{P(!1)}},L=async()=>{if(!k||R)return;let t=h.find(e=>!1!==e.isActive);if(t){M(!0);try{let a={...l};await g(async()=>{let e=await fetch(`/api/providers/${t.id}/models`),a=await e.json();if(!e.ok)throw Error(a.error||v("failedImportModels"));return a},async t=>{let r=t.id||t.name||t.model;if(!r)return!1;let o=D(r,a);return!!o&&((await fetch("/api/provider-models",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:e,modelId:r,modelName:t.name||r,source:"imported"})})).ok?(await m(r,o,e),a[o]=`${e}/${r}`,!0):(I.error(v("failedSaveImportedModel")),!1))})}catch(e){console.error("Error importing models:",e),I.error(v("failedImportModelsTryAgain"))}finally{M(!1)}}},$=h.some(e=>!1!==e.isActive),F=async(t,a)=>{try{if(!(await fetch(`/api/provider-models?provider=${encodeURIComponent(e)}&model=${encodeURIComponent(t)}`,{method:"DELETE"})).ok)throw Error(v("failedRemoveModelFromDatabase"));a&&await x(a),I.success(v("modelRemovedSuccess")),w?.()}catch(e){console.error("Error deleting model:",e),I.error(e instanceof Error?e.message:v("failedDeleteModelTryAgain"))}};return(0,t.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,t.jsx)("p",{className:"text-sm text-text-muted",children:s}),(0,t.jsxs)("div",{className:"flex items-end gap-2 flex-wrap",children:[(0,t.jsxs)("div",{className:"flex-1 min-w-[240px]",children:[(0,t.jsx)("label",{htmlFor:"new-compatible-model-input",className:"text-xs text-text-muted mb-1 block",children:n}),(0,t.jsx)("input",{id:"new-compatible-model-input",type:"text",value:S,onChange:e=>T(e.target.value),onKeyDown:e=>"Enter"===e.key&&U(),placeholder:d,className:"w-full px-3 py-2 text-sm border border-border rounded-lg bg-background focus:outline-none focus:border-primary"})]}),(0,t.jsx)(p.Button,{size:"sm",icon:"add",onClick:U,disabled:!S.trim()||A,children:A?v("adding"):v("add")}),k&&(0,t.jsx)(p.Button,{size:"sm",variant:"secondary",icon:"download",onClick:L,disabled:!$||R,children:R?v("importingModels"):v("importFromModels")})]}),k&&!$&&(0,t.jsx)("p",{className:"text-xs text-text-muted",children:v("addConnectionToImport")}),O.length>0&&(0,t.jsx)("div",{className:"flex flex-col gap-3",children:O.map(({modelId:a,alias:o})=>(0,t.jsx)(_,{modelId:a,fullModel:`${r}/${a}`,copied:c,onCopy:u,onDeleteAlias:()=>F(a,o),t:v,showDeveloperToggle:!f,effectiveModelNormalize:b,effectiveModelPreserveDeveloper:y,getUpstreamHeadersRecord:e=>j(a,e),saveModelCompatFlags:C,compatDisabled:N===a},`${e}:${a}`))})]})}function z({until:e}){let[r,o]=(0,a.useState)("");return((0,a.useEffect)(()=>{let t=()=>{let t=new Date(e).getTime()-Date.now();if(t<=0)return void o("");let a=Math.floor(t/1e3);if(a<60)o(`${a}s`);else if(a<3600)o(`${Math.floor(a/60)}m ${a%60}s`);else{let e=Math.floor(a/3600),t=Math.floor(a%3600/60);o(`${e}h ${t}m`)}};t();let a=setInterval(t,1e3);return()=>clearInterval(a)},[e]),r)?(0,t.jsxs)("span",{className:"text-xs text-orange-500 font-mono",children:["⏱ ",r]}):null}$.propTypes={model:l.default.shape({id:l.default.string.isRequired}).isRequired,fullModel:l.default.string.isRequired,copied:l.default.string,onCopy:l.default.func.isRequired,t:l.default.func,showDeveloperToggle:l.default.bool,effectiveModelNormalize:l.default.func.isRequired,effectiveModelPreserveDeveloper:l.default.func.isRequired,getUpstreamHeadersRecord:l.default.func.isRequired,saveModelCompatFlags:l.default.func.isRequired,compatDisabled:l.default.bool},F.propTypes={providerAlias:l.default.string.isRequired,modelAliases:l.default.object.isRequired,copied:l.default.string,onCopy:l.default.func.isRequired,onSetAlias:l.default.func.isRequired,onDeleteAlias:l.default.func.isRequired,t:l.default.func.isRequired,effectiveModelNormalize:l.default.func.isRequired,effectiveModelPreserveDeveloper:l.default.func.isRequired,getUpstreamHeadersRecord:l.default.func.isRequired,saveModelCompatFlags:l.default.func.isRequired,compatSavingModelId:l.default.string},_.propTypes={modelId:l.default.string.isRequired,fullModel:l.default.string.isRequired,copied:l.default.string,onCopy:l.default.func.isRequired,onDeleteAlias:l.default.func.isRequired,t:l.default.func,showDeveloperToggle:l.default.bool,effectiveModelNormalize:l.default.func.isRequired,effectiveModelPreserveDeveloper:l.default.func.isRequired,getUpstreamHeadersRecord:l.default.func.isRequired,saveModelCompatFlags:l.default.func.isRequired,compatDisabled:l.default.bool},B.propTypes={providerId:l.default.string.isRequired,providerAlias:l.default.string.isRequired,copied:l.default.string,onCopy:l.default.func.isRequired,onModelsChanged:l.default.func},q.propTypes={providerStorageAlias:l.default.string.isRequired,providerDisplayAlias:l.default.string.isRequired,modelAliases:l.default.object.isRequired,fallbackModels:l.default.array,description:l.default.string.isRequired,inputLabel:l.default.string.isRequired,inputPlaceholder:l.default.string.isRequired,copied:l.default.string,onCopy:l.default.func.isRequired,onSetAlias:l.default.func.isRequired,onDeleteAlias:l.default.func.isRequired,connections:l.default.arrayOf(l.default.shape({id:l.default.string,isActive:l.default.bool})).isRequired,isAnthropic:l.default.bool,onImportWithProgress:l.default.func.isRequired,t:l.default.func.isRequired,effectiveModelNormalize:l.default.func.isRequired,effectiveModelPreserveDeveloper:l.default.func.isRequired,getUpstreamHeadersRecord:l.default.func.isRequired,saveModelCompatFlags:l.default.func.isRequired,compatSavingModelId:l.default.string,onModelsChanged:l.default.func,allowImport:l.default.bool.isRequired},z.propTypes={until:l.default.string.isRequired};let K={runtime_error:{labelKey:"errorTypeRuntime",variant:"warning"},upstream_auth_error:{labelKey:"errorTypeUpstreamAuth",variant:"error"},account_deactivated:{labelKey:"Account Deactivated",variant:"error"},auth_missing:{labelKey:"errorTypeMissingCredential",variant:"warning"},token_refresh_failed:{labelKey:"errorTypeRefreshFailed",variant:"warning"},token_expired:{labelKey:"errorTypeTokenExpired",variant:"warning"},upstream_rate_limited:{labelKey:"errorTypeRateLimited",variant:"warning"},upstream_unavailable:{labelKey:"errorTypeUpstreamUnavailable",variant:"error"},network_error:{labelKey:"errorTypeNetworkError",variant:"warning"},unsupported:{labelKey:"errorTypeTestUnsupported",variant:"default"},upstream_error:{labelKey:"errorTypeUpstreamError",variant:"error"},banned:{labelKey:"403 Banned",variant:"error"},credits_exhausted:{labelKey:"No Credits",variant:"warning"}};function H({connection:e,isOAuth:r,isCodex:o,isFirst:l,isLast:i,onMoveUp:s,onMoveDown:n,onToggleActive:c,onToggleRateLimit:m,onToggleCodex5h:x,onToggleCodexWeekly:h,onRetest:f,isRetesting:g,onEdit:v,onDelete:y,onReauth:j,onProxy:C,hasProxy:N,proxySource:w,proxyHost:k,onRefreshToken:S,isRefreshing:T,onApplyCodexAuthLocal:A,isApplyingCodexAuthLocal:P,onExportCodexAuthFile:R,isExportingCodexAuthFile:M}){let I,E=(0,d.useTranslations)("providers"),O=r?e.name||e.email||e.displayName||E("oauthAccount"):e.name,D="function"==typeof E.has&&E.has("applyCodexAuthLocal")?E("applyCodexAuthLocal"):"Apply auth",L="function"==typeof E.has&&E.has("exportCodexAuthFile")?E("exportCodexAuthFile"):"Export auth",[$,F]=(0,a.useState)(!1),[_,B]=(0,a.useState)(()=>r&&e.expiresAt?Math.floor((new Date(e.expiresAt).getTime()-Date.now())/6e4):null);(0,a.useEffect)(()=>{if(!r||!e.expiresAt)return;let t=setInterval(()=>{B(Math.floor((new Date(e.expiresAt).getTime()-Date.now())/6e4))},3e4);return()=>clearInterval(t)},[r,e.expiresAt]),(0,a.useEffect)(()=>{let t=()=>{F(e.rateLimitedUntil&&new Date(e.rateLimitedUntil).getTime()>Date.now())};t();let a=e.rateLimitedUntil?setInterval(t,1e3):null;return()=>{a&&clearInterval(a)}},[e.rateLimitedUntil]);let q="unavailable"!==e.testStatus||$?e.testStatus:"active",J=function(e,t,a,r){if(!1===e.isActive)return{statusVariant:"default",statusLabel:r("statusDisabled"),errorType:null,errorBadge:null,errorTextClass:"text-text-muted"};if("active"===t||"success"===t)return{statusVariant:"success",statusLabel:r("statusConnected"),errorType:null,errorBadge:null,errorTextClass:"text-text-muted"};let o=function(e,t){if(t)return"upstream_rate_limited";if("banned"===e.testStatus)return"banned";if("credits_exhausted"===e.testStatus)return"credits_exhausted";if(e.lastErrorType)return e.lastErrorType;let a=Number(e.errorCode);if(401===a||403===a)return"upstream_auth_error";if(429===a)return"upstream_rate_limited";if(a>=500)return"upstream_unavailable";let r=(e.lastError||"").toLowerCase();return r?r.includes("runtime")||r.includes("not runnable")||r.includes("not installed")||r.includes("healthcheck")?"runtime_error":r.includes("refresh failed")?"token_refresh_failed":r.includes("token expired")||r.includes("expired")?"token_expired":r.includes("invalid api key")||r.includes("token invalid")||r.includes("revoked")||r.includes("access denied")||r.includes("unauthorized")?"upstream_auth_error":r.includes("rate limit")||r.includes("quota")||r.includes("too many requests")||r.includes("429")?"upstream_rate_limited":r.includes("fetch failed")||r.includes("network")||r.includes("timeout")||r.includes("econn")||r.includes("enotfound")?"network_error":r.includes("not supported")?"unsupported":"upstream_error":null}(e,a),l=o&&K[o]||null;return"runtime_error"===o?{statusVariant:"warning",statusLabel:r("statusRuntimeIssue"),errorType:o,errorBadge:l,errorTextClass:"text-yellow-600 dark:text-yellow-400"}:"account_deactivated"===o?{statusVariant:"error",statusLabel:r("statusDeactivated","Deactivated"),errorType:o,errorBadge:l,errorTextClass:"text-red-600 font-bold"}:"upstream_auth_error"===o||"auth_missing"===o||"token_refresh_failed"===o||"token_expired"===o?{statusVariant:"error",statusLabel:r("statusAuthFailed"),errorType:o,errorBadge:l,errorTextClass:"text-red-500"}:"upstream_rate_limited"===o?{statusVariant:"warning",statusLabel:r("statusRateLimited"),errorType:o,errorBadge:l,errorTextClass:"text-yellow-600 dark:text-yellow-400"}:"network_error"===o?{statusVariant:"warning",statusLabel:r("statusNetworkIssue"),errorType:o,errorBadge:l,errorTextClass:"text-yellow-600 dark:text-yellow-400"}:"unsupported"===o?{statusVariant:"default",statusLabel:r("statusTestUnsupported"),errorType:o,errorBadge:l,errorTextClass:"text-text-muted"}:"banned"===o?{statusVariant:"error",statusLabel:r("statusBanned","Banned (403)"),errorType:o,errorBadge:l,errorTextClass:"text-red-600 font-bold"}:"credits_exhausted"===o?{statusVariant:"warning",statusLabel:r("statusCreditsExhausted","Out of Credits"),errorType:o,errorBadge:l,errorTextClass:"text-amber-500"}:{statusVariant:"error",statusLabel:({unavailable:r("statusUnavailable"),failed:r("statusFailed"),error:r("statusError")})[t]||t||r("statusError"),errorType:o,errorBadge:l,errorTextClass:"text-red-500"}}(e,q,$,E),W=!!e.rateLimitProtection,V=U(e.providerSpecificData&&"object"==typeof e.providerSpecificData&&e.providerSpecificData.codexLimitPolicy&&"object"==typeof e.providerSpecificData.codexLimitPolicy?e.providerSpecificData.codexLimitPolicy:{}),G=V.use5h,Q=V.useWeekly;return(0,t.jsxs)("div",{className:`group flex items-center justify-between p-3 rounded-lg hover:bg-black/[0.02] dark:hover:bg-white/[0.02] transition-colors ${!1===e.isActive?"opacity-60":""}`,children:[(0,t.jsxs)("div",{className:"flex items-center gap-3 flex-1 min-w-0",children:[(0,t.jsxs)("div",{className:"flex flex-col",children:[(0,t.jsx)("button",{onClick:s,disabled:l,className:`p-0.5 rounded ${l?"text-text-muted/30 cursor-not-allowed":"hover:bg-sidebar text-text-muted hover:text-primary"}`,children:(0,t.jsx)("span",{className:"material-symbols-outlined text-sm",children:"keyboard_arrow_up"})}),(0,t.jsx)("button",{onClick:n,disabled:i,className:`p-0.5 rounded ${i?"text-text-muted/30 cursor-not-allowed":"hover:bg-sidebar text-text-muted hover:text-primary"}`,children:(0,t.jsx)("span",{className:"material-symbols-outlined text-sm",children:"keyboard_arrow_down"})})]}),(0,t.jsx)("span",{className:"material-symbols-outlined text-base text-text-muted",children:r?"lock":"key"}),(0,t.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,t.jsx)("p",{className:"text-sm font-medium truncate",children:O}),(0,t.jsxs)("div",{className:"flex items-center gap-2 mt-1 flex-wrap",children:[(0,t.jsx)(u.Badge,{variant:J.statusVariant,size:"sm",dot:!0,children:J.statusLabel}),null!==_&&(_<0?(0,t.jsxs)("span",{className:"inline-flex items-center gap-0.5 px-1.5 py-0.5 rounded text-xs font-medium bg-red-500/15 text-red-500",title:`Token expired: ${e.expiresAt}`,children:[(0,t.jsx)("span",{className:"material-symbols-outlined text-[11px]",children:"error"}),"expired"]}):_<30?(0,t.jsxs)("span",{className:"inline-flex items-center gap-0.5 px-1.5 py-0.5 rounded text-xs font-medium bg-amber-500/15 text-amber-500",title:`Token expires in ${_}m`,children:[(0,t.jsx)("span",{className:"material-symbols-outlined text-[11px]",children:"warning"}),`~${_}m`]}):null),$&&!1!==e.isActive&&(0,t.jsx)(z,{until:e.rateLimitedUntil}),J.errorBadge&&!1!==e.isActive&&(0,t.jsx)(u.Badge,{variant:J.errorBadge.variant,size:"sm",children:E(J.errorBadge.labelKey)}),e.lastError&&!1!==e.isActive&&(0,t.jsx)("span",{className:`text-xs truncate max-w-[300px] ${J.errorTextClass}`,title:e.lastError.replace(/<[^>]*>?/gm,""),children:e.lastError.replace(/<[^>]*>?/gm,"")}),(0,t.jsxs)("span",{className:"text-xs text-text-muted",children:["#",e.priority]}),e.globalPriority&&(0,t.jsx)("span",{className:"text-xs text-text-muted",children:E("autoPriority",{priority:e.globalPriority})}),(0,t.jsx)("span",{className:"text-text-muted/30 select-none",children:"|"}),(0,t.jsxs)("button",{onClick:()=>m(!W),className:`inline-flex items-center gap-1 px-1.5 py-0.5 rounded text-xs font-medium transition-all cursor-pointer ${W?"bg-emerald-500/15 text-emerald-500 hover:bg-emerald-500/25":"bg-black/[0.03] dark:bg-white/[0.03] text-text-muted/50 hover:text-text-muted hover:bg-black/[0.06] dark:hover:bg-white/[0.06]"}`,title:E(W?"disableRateLimitProtection":"enableRateLimitProtection"),children:[(0,t.jsx)("span",{className:"material-symbols-outlined text-[13px]",children:"shield"}),E(W?"rateLimitProtected":"rateLimitUnprotected")]}),o&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("span",{className:"text-text-muted/30 select-none",children:"|"}),(0,t.jsxs)("button",{onClick:()=>x?.(!G),className:`inline-flex items-center gap-1 px-1.5 py-0.5 rounded text-xs font-medium transition-all cursor-pointer ${G?"bg-blue-500/15 text-blue-500 hover:bg-blue-500/25":"bg-black/[0.03] dark:bg-white/[0.03] text-text-muted/50 hover:text-text-muted hover:bg-black/[0.06] dark:hover:bg-white/[0.06]"}`,title:"Toggle Codex 5h limit policy",children:[(0,t.jsx)("span",{className:"material-symbols-outlined text-[13px]",children:"timer"}),"5h ",G?"ON":"OFF"]}),(0,t.jsxs)("button",{onClick:()=>h?.(!Q),className:`inline-flex items-center gap-1 px-1.5 py-0.5 rounded text-xs font-medium transition-all cursor-pointer ${Q?"bg-violet-500/15 text-violet-500 hover:bg-violet-500/25":"bg-black/[0.03] dark:bg-white/[0.03] text-text-muted/50 hover:text-text-muted hover:bg-black/[0.06] dark:hover:bg-white/[0.06]"}`,title:"Toggle Codex weekly limit policy",children:[(0,t.jsx)("span",{className:"material-symbols-outlined text-[13px]",children:"date_range"}),"Weekly ",Q?"ON":"OFF"]})]}),N&&(I=E("global"===w?"proxySourceGlobal":"provider"===w?"proxySourceProvider":"proxySourceKey"),(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("span",{className:"text-text-muted/30 select-none",children:"|"}),(0,t.jsxs)("span",{className:`inline-flex items-center gap-0.5 px-1.5 py-0.5 rounded text-xs font-medium ${"global"===w?"bg-emerald-500/15 text-emerald-500":"provider"===w?"bg-amber-500/15 text-amber-500":"bg-blue-500/15 text-blue-500"}`,title:E("proxyConfiguredBySource",{source:I,host:k||E("configured")}),children:[(0,t.jsx)("span",{className:"material-symbols-outlined text-[13px]",children:"vpn_lock"}),k||E("proxy")]})]}))]})]})]}),(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)(p.Button,{size:"sm",variant:"ghost",icon:"refresh",loading:g,disabled:!1===e.isActive,onClick:f,className:"!h-7 !px-2 text-xs",title:E("retestAuthentication"),children:E("retest")}),S&&(0,t.jsx)(p.Button,{size:"sm",variant:"ghost",icon:"token",loading:T,disabled:!1===e.isActive||T,onClick:S,className:"!h-7 !px-2 text-xs text-amber-500 hover:text-amber-400",title:"Refresh OAuth token manually",children:"Token"}),o&&A&&(0,t.jsx)(p.Button,{size:"sm",variant:"ghost",icon:"download_done",loading:P,disabled:P,onClick:A,className:"!h-7 !px-2 text-xs text-emerald-500 hover:text-emerald-400",title:D,children:D}),o&&R&&(0,t.jsx)(p.Button,{size:"sm",variant:"ghost",icon:"download",loading:M,disabled:M,onClick:R,className:"!h-7 !px-2 text-xs text-sky-500 hover:text-sky-400",title:L,children:L}),(0,t.jsx)(b.Toggle,{size:"sm",checked:e.isActive??!0,onChange:c,title:E(e.isActive??!0?"disableConnection":"enableConnection")}),(0,t.jsxs)("div",{className:"flex gap-1 ml-1 transition-opacity",children:[j&&(0,t.jsx)("button",{onClick:j,className:"p-2 hover:bg-amber-500/10 rounded text-amber-600 hover:text-amber-500",title:E("reauthenticateConnection"),children:(0,t.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:"passkey"})}),(0,t.jsx)("button",{onClick:v,className:"p-2 hover:bg-black/5 dark:hover:bg-white/5 rounded text-text-muted hover:text-primary",title:E("edit"),children:(0,t.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:"edit"})}),(0,t.jsx)("button",{onClick:C,className:"p-2 hover:bg-black/5 dark:hover:bg-white/5 rounded text-text-muted hover:text-primary",title:E("proxyConfig"),children:(0,t.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:"vpn_lock"})}),(0,t.jsx)("button",{onClick:y,className:"p-2 hover:bg-red-500/10 rounded text-red-500",title:E("delete"),children:(0,t.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:"delete"})})]})]})]})}function J({isOpen:e,provider:r,providerName:o,isCompatible:l,isAnthropic:i,isCcCompatible:s,onSave:n,onClose:c}){let h=(0,d.useTranslations)("providers"),f="bailian-coding-plan"===r,g="https://coding-intl.dashscope.aliyuncs.com/apps/anthropic/v1",v="vertex"===r,b="us-central1",y="glm"===r,j="qoder"===r,[C,N]=(0,a.useState)({name:"",apiKey:"",priority:1,baseUrl:f?g:"",region:v?b:"",apiRegion:"international",validationModelId:""}),[w,k]=(0,a.useState)(!1),[S,T]=(0,a.useState)(null),[A,P]=(0,a.useState)(!1),[R,M]=(0,a.useState)(null),I=async()=>{k(!0),M(null);try{let e=await fetch("/api/providers/validate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:r,apiKey:C.apiKey,validationModelId:C.validationModelId||void 0})}),t=await e.json();T(t.valid?"success":"failed")}catch{T("failed")}finally{k(!1)}},E=async()=>{if(r&&C.apiKey){P(!0),M(null);try{let e=null;if(f){let t=W(C.baseUrl,g);if(t.error)return void M(t.error);e=t.value}let t=!1;try{k(!0),T(null);let e=await fetch("/api/providers/validate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:r,apiKey:C.apiKey,validationModelId:C.validationModelId||void 0})});t=!!(await e.json()).valid,T(t?"success":"failed")}catch{T("failed")}finally{k(!1)}if(!t)return void M(h("apiKeyValidationFailed"));let a={name:C.name,apiKey:C.apiKey,priority:C.priority,testStatus:"active",providerSpecificData:void 0};f?a.providerSpecificData={baseUrl:e}:v?a.providerSpecificData={region:C.region}:y&&(a.providerSpecificData={apiRegion:C.apiRegion});let o=await n(a);o&&M("string"==typeof o?o:h("failedSaveConnection"))}finally{P(!1)}}};return r?(0,t.jsx)(x.Modal,{isOpen:e,title:h("addProviderApiKeyTitle",{provider:o||r}),onClose:c,children:(0,t.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,t.jsx)(m.Input,{label:h("nameLabel"),value:C.name,onChange:e=>N({...C,name:e.target.value}),placeholder:j?"Qoder PAT":h("productionKey")}),(0,t.jsxs)("div",{className:"flex gap-2",children:[(0,t.jsx)(m.Input,{label:j?"Personal Access Token":h("apiKeyLabel"),type:"password",value:C.apiKey,onChange:e=>N({...C,apiKey:e.target.value}),className:"flex-1",placeholder:v?"Cole o Service Account JSON aqui":j?"Paste your Qoder Personal Access Token":void 0,hint:j?"Supported path: PAT via qodercli. Browser OAuth remains experimental.":void 0}),(0,t.jsx)("div",{className:"pt-6",children:(0,t.jsx)(p.Button,{onClick:I,disabled:!C.apiKey||w||A,variant:"secondary",children:w?h("checking"):h("check")})})]}),S&&(0,t.jsx)(u.Badge,{variant:"success"===S?"success":"error",children:"success"===S?h("valid"):h("invalid")}),R&&(0,t.jsx)("div",{className:"text-sm text-red-500 bg-red-500/10 border border-red-500/20 rounded-lg px-3 py-2",children:R}),l&&(0,t.jsx)("p",{className:"text-xs text-text-muted",children:s?"Validation uses the strict Claude Code-compatible bridge request for this provider.":i?h("validationChecksAnthropicCompatible",{provider:o||h("anthropicCompatibleName")}):h("validationChecksOpenAiCompatible",{provider:o||h("openaiCompatibleName")})}),(0,t.jsx)(m.Input,{label:"Model ID (opcional)",placeholder:"ex: grok-3 ou meta-llama/Llama-3.1-8B-Instruct",value:C.validationModelId,onChange:e=>N({...C,validationModelId:e.target.value}),hint:"Usado como fallback se a listagem de models não estiver disponível"}),(0,t.jsx)(m.Input,{label:h("priorityLabel"),type:"number",value:C.priority,onChange:e=>N({...C,priority:Number.parseInt(e.target.value)||1})}),f&&(0,t.jsx)(m.Input,{label:"Base URL",value:C.baseUrl,onChange:e=>N({...C,baseUrl:e.target.value}),placeholder:g,hint:"Optional: Custom base URL for bailian-coding-plan provider"}),v&&(0,t.jsx)(m.Input,{label:"Região (Region)",value:C.region,onChange:e=>N({...C,region:e.target.value}),placeholder:b,hint:"ex: us-central1 ou europe-west4. Partner models usam a região global automaticamente."}),y&&(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{className:"text-sm font-medium text-text-main mb-1 block",children:"API Region"}),(0,t.jsxs)("select",{value:C.apiRegion,onChange:e=>N({...C,apiRegion:e.target.value}),className:"w-full px-3 py-2 text-sm border border-border rounded-lg bg-background focus:outline-none focus:border-primary",children:[(0,t.jsx)("option",{value:"international",children:"International (api.z.ai)"}),(0,t.jsx)("option",{value:"china",children:"China Mainland (open.bigmodel.cn)"})]}),(0,t.jsx)("p",{className:"text-xs text-text-muted mt-1",children:"Select the endpoint region for API access and quota tracking."})]}),(0,t.jsxs)("div",{className:"flex gap-2",children:[(0,t.jsx)(p.Button,{onClick:E,fullWidth:!0,disabled:!C.name||!C.apiKey||A,children:A?h("saving"):h("save")}),(0,t.jsx)(p.Button,{onClick:c,variant:"ghost",fullWidth:!0,children:h("cancel")})]})]})}):null}function W(e,t){let a=("string"==typeof e?e.trim():"")||t;try{let e=new URL(a);if("http:"!==e.protocol&&"https:"!==e.protocol)return{value:null,error:"Base URL must use http or https"};return{value:a,error:null}}catch{return{value:null,error:"Base URL must be a valid URL"}}}function V({isOpen:e,connection:r,onSave:o,onClose:l}){let i=(0,d.useTranslations)("providers"),[s,n]=(0,a.useState)({name:"",priority:1,apiKey:"",healthCheckInterval:60,baseUrl:"",region:"",apiRegion:"international",validationModelId:"",tag:""}),[c,h]=(0,a.useState)(!1),[f,g]=(0,a.useState)(null),[v,b]=(0,a.useState)(!1),[y,j]=(0,a.useState)(null),[N,w]=(0,a.useState)(!1),[k,S]=(0,a.useState)(null),[T,A]=(0,a.useState)([]),[P,R]=(0,a.useState)(""),M=r?.provider==="bailian-coding-plan",I="https://coding-intl.dashscope.aliyuncs.com/apps/anthropic/v1",E=r?.provider==="vertex",O=r?.provider==="glm",D="us-central1";(0,a.useEffect)(()=>{if(r){let e=r.providerSpecificData?.baseUrl,t=r.providerSpecificData?.region;n({name:r.name||"",priority:r.priority||1,apiKey:"",healthCheckInterval:r.healthCheckInterval??60,baseUrl:("string"==typeof e?e:"")||(M?I:""),region:("string"==typeof t?t:"")||(E?D:""),apiRegion:r.providerSpecificData?.apiRegion||"international",validationModelId:r.providerSpecificData?.validationModelId||"",tag:r.providerSpecificData?.tag||""});let a=r.providerSpecificData?.extraApiKeys;A(Array.isArray(a)?a:[]),R(""),g(null),j(null),S(null)}},[r,M,E]);let U=async()=>{if(r?.provider){h(!0),g(null);try{let e=await fetch(`/api/providers/${r.id}/test`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({validationModelId:s.validationModelId||void 0})}),t=await e.json();g({valid:!!t.valid,diagnosis:t.diagnosis||null,message:t.error||null})}catch{g({valid:!1,diagnosis:{type:"network_error"},message:i("failedTestConnection")})}finally{h(!1)}}},L=async()=>{if(r?.provider&&s.apiKey){b(!0),j(null);try{let e=await fetch("/api/providers/validate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:r.provider,apiKey:s.apiKey,validationModelId:s.validationModelId||void 0})}),t=await e.json();j(t.valid?"success":"failed")}catch{j("failed")}finally{b(!1)}}},$=async()=>{w(!0),S(null);try{let e={name:s.name,priority:s.priority,healthCheckInterval:s.healthCheckInterval},t=null;if(M){let e=W(s.baseUrl,I);if(e.error)return void S(e.error);t=e.value}if(!F&&s.apiKey){e.apiKey=s.apiKey;let t="success"===y;if(!t)try{b(!0),j(null);let e=await fetch("/api/providers/validate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:r.provider,apiKey:s.apiKey,validationModelId:s.validationModelId||void 0})});t=!!(await e.json()).valid,j(t?"success":"failed")}catch{j("failed")}finally{b(!1)}t&&(e.testStatus="active",e.lastError=null,e.lastErrorAt=null,e.lastErrorType=null,e.lastErrorSource=null,e.errorCode=null,e.rateLimitedUntil=null)}F?e.providerSpecificData={...r.providerSpecificData||{},tag:s.tag.trim()||void 0}:(e.providerSpecificData={...r.providerSpecificData||{},extraApiKeys:T.filter(e=>e.trim().length>0),tag:s.tag.trim()||void 0},s.validationModelId&&(e.providerSpecificData.validationModelId=s.validationModelId),M?e.providerSpecificData.baseUrl=t:E?e.providerSpecificData.region=s.region:O&&(e.providerSpecificData.apiRegion=s.apiRegion));let a=await o(e);a&&S("string"==typeof a?a:i("failedSaveConnection"))}finally{w(!1)}};if(!r)return null;let F="oauth"===r.authType,_=(0,C.isOpenAICompatibleProvider)(r.provider)||(0,C.isAnthropicCompatibleProvider)(r.provider),B=!f?.valid&&f?.diagnosis?.type&&K[f.diagnosis.type]||null;return(0,t.jsx)(x.Modal,{isOpen:e,title:i("editConnection"),onClose:l,children:(0,t.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,t.jsx)(m.Input,{label:i("nameLabel"),value:s.name,onChange:e=>n({...s,name:e.target.value}),placeholder:F?i("accountName"):i("productionKey")}),(0,t.jsx)(m.Input,{label:"Tag / Group",value:s.tag,onChange:e=>n({...s,tag:e.target.value}),placeholder:"e.g. personal, work, team-a",hint:"Used to group accounts in the provider view"}),F&&r.email&&(0,t.jsxs)("div",{className:"bg-sidebar/50 p-3 rounded-lg",children:[(0,t.jsx)("p",{className:"text-sm text-text-muted mb-1",children:i("email")}),(0,t.jsx)("p",{className:"font-medium",children:r.email})]}),F&&(0,t.jsx)(m.Input,{label:i("healthCheckMinutes"),type:"number",value:s.healthCheckInterval,onChange:e=>n({...s,healthCheckInterval:Math.max(0,Number.parseInt(e.target.value)||0)}),hint:i("healthCheckHint")}),(0,t.jsx)(m.Input,{label:i("priorityLabel"),type:"number",value:s.priority,onChange:e=>n({...s,priority:Number.parseInt(e.target.value)||1})}),!F&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("div",{className:"flex gap-2",children:[(0,t.jsx)(m.Input,{label:i("apiKeyLabel"),type:"password",value:s.apiKey,onChange:e=>n({...s,apiKey:e.target.value}),placeholder:E?"Cole o Service Account JSON aqui":i("enterNewApiKey"),hint:i("leaveBlankKeepCurrentApiKey"),className:"flex-1"}),(0,t.jsx)("div",{className:"pt-6",children:(0,t.jsx)(p.Button,{onClick:L,disabled:!s.apiKey||v||N,variant:"secondary",children:v?i("checking"):i("check")})})]}),y&&(0,t.jsx)(u.Badge,{variant:"success"===y?"success":"error",children:"success"===y?i("valid"):i("invalid")}),k&&(0,t.jsx)("div",{className:"text-sm text-red-500 bg-red-500/10 border border-red-500/20 rounded-lg px-3 py-2",children:k}),(0,t.jsx)(m.Input,{label:"Model ID (opcional)",placeholder:"ex: grok-3 ou meta-llama/Llama-3.1-8B-Instruct",value:s.validationModelId,onChange:e=>n({...s,validationModelId:e.target.value}),hint:"Usado como fallback se a listagem de models não estiver disponível"})]}),M&&(0,t.jsx)(m.Input,{label:"Base URL",value:s.baseUrl,onChange:e=>n({...s,baseUrl:e.target.value}),placeholder:I,hint:"Custom base URL for bailian-coding-plan provider"}),E&&(0,t.jsx)(m.Input,{label:"Região (Region)",value:s.region,onChange:e=>n({...s,region:e.target.value}),placeholder:D,hint:"ex: us-central1 ou europe-west4. Partner models usam a região global automaticamente."}),O&&(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{className:"text-sm font-medium text-text-main mb-1 block",children:"API Region"}),(0,t.jsxs)("select",{value:s.apiRegion,onChange:e=>n({...s,apiRegion:e.target.value}),className:"w-full px-3 py-2 text-sm border border-border rounded-lg bg-background focus:outline-none focus:border-primary",children:[(0,t.jsx)("option",{value:"international",children:"International (api.z.ai)"}),(0,t.jsx)("option",{value:"china",children:"China Mainland (open.bigmodel.cn)"})]}),(0,t.jsx)("p",{className:"text-xs text-text-muted mt-1",children:"Select the endpoint region for API access and quota tracking."})]}),!F&&(0,t.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,t.jsxs)("label",{className:"text-sm font-medium text-text-main",children:["Extra API Keys",(0,t.jsx)("span",{className:"ml-2 text-[11px] font-normal text-text-muted",children:"(round-robin rotation — optional)"})]}),T.length>0&&(0,t.jsx)("div",{className:"flex flex-col gap-1.5",children:T.map((e,a)=>(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)("span",{className:"flex-1 font-mono text-xs bg-sidebar/50 px-3 py-2 rounded border border-border text-text-muted truncate",children:`Key #${a+2}: ${e.slice(0,6)}...${e.slice(-4)}`}),(0,t.jsx)("button",{onClick:()=>A(T.filter((e,t)=>t!==a)),className:"p-1.5 rounded hover:bg-red-500/10 text-red-400 hover:text-red-500",title:"Remove this key",children:(0,t.jsx)("span",{className:"material-symbols-outlined text-[16px]",children:"close"})})]},a))}),(0,t.jsxs)("div",{className:"flex gap-2",children:[(0,t.jsx)("input",{type:"password",value:P,onChange:e=>R(e.target.value),placeholder:"Add another API key...",className:"flex-1 text-sm bg-sidebar/50 border border-border rounded px-3 py-2 text-text-main placeholder:text-text-muted focus:ring-1 focus:ring-primary outline-none",onKeyDown:e=>{"Enter"===e.key&&P.trim()&&(A([...T,P.trim()]),R(""))}}),(0,t.jsx)("button",{onClick:()=>{P.trim()&&(A([...T,P.trim()]),R(""))},disabled:!P.trim(),className:"px-3 py-2 rounded bg-primary/10 text-primary hover:bg-primary/20 disabled:opacity-40 text-sm font-medium",children:"Add"})]}),T.length>0&&(0,t.jsxs)("p",{className:"text-[11px] text-text-muted",children:[T.length+1," keys total — rotating round-robin on each request."]})]}),!_&&(0,t.jsxs)("div",{className:"flex items-center gap-3",children:[(0,t.jsx)(p.Button,{onClick:U,variant:"secondary",disabled:c,children:c?i("testing"):i("testConnection")}),f&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(u.Badge,{variant:f.valid?"success":"error",children:f.valid?i("valid"):i("failed")}),B&&(0,t.jsx)(u.Badge,{variant:B.variant,children:i(B.labelKey)})]})]}),(0,t.jsxs)("div",{className:"flex gap-2",children:[(0,t.jsx)(p.Button,{onClick:$,fullWidth:!0,disabled:N,children:N?i("saving"):i("save")}),(0,t.jsx)(p.Button,{onClick:l,variant:"ghost",fullWidth:!0,children:i("cancel")})]})]})})}function G({isOpen:e,node:r,onSave:o,onClose:l,isAnthropic:i,isCcCompatible:s}){let n=(0,d.useTranslations)("providers"),[c,h]=(0,a.useState)({name:"",prefix:"",apiType:"chat",baseUrl:"https://api.openai.com/v1",chatPath:"",modelsPath:""}),[f,g]=(0,a.useState)(!1),[v,b]=(0,a.useState)(""),[j,C]=(0,a.useState)(!1),[N,w]=(0,a.useState)(null),[k,S]=(0,a.useState)(!1);(0,a.useEffect)(()=>{r&&(h({name:r.name||"",prefix:r.prefix||"",apiType:r.apiType||"chat",baseUrl:r.baseUrl||(s?"https://api.anthropic.com":i?"https://api.anthropic.com/v1":"https://api.openai.com/v1"),chatPath:r.chatPath||(s?D:""),modelsPath:s?"":r.modelsPath||""}),S(!!(r.chatPath||!s&&r.modelsPath||s&&!r.chatPath)))},[r,i,s]);let T=[{value:"chat",label:n("chatCompletions")},{value:"responses",label:n("responsesApi")}],A=async()=>{if(c.name.trim()&&c.prefix.trim()&&c.baseUrl.trim()){g(!0);try{let e={name:c.name,prefix:c.prefix,baseUrl:c.baseUrl,chatPath:c.chatPath||(s?D:""),modelsPath:s?"":c.modelsPath};i||(e.apiType=c.apiType),await o(e)}finally{g(!1)}}},P=async()=>{C(!0);try{let e=await fetch("/api/provider-nodes/validate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({baseUrl:c.baseUrl,apiKey:v,type:i?"anthropic-compatible":"openai-compatible",compatMode:s?"cc":void 0,chatPath:c.chatPath||(s?D:""),modelsPath:s?"":c.modelsPath})}),t=await e.json();w(t.valid?"success":"failed")}catch{w("failed")}finally{C(!1)}};return r?(0,t.jsx)(x.Modal,{isOpen:e,title:s?O:n("editCompatibleTitle",{type:n(i?"anthropic":"openai")}),onClose:l,children:(0,t.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,t.jsx)(m.Input,{label:s?"Name":n("nameLabel"),value:c.name,onChange:e=>h({...c,name:e.target.value}),placeholder:s?"CC Compatible Production":n("compatibleProdPlaceholder",{type:n(i?"anthropic":"openai")}),hint:s?"Display name for this provider":n("nameHint")}),(0,t.jsx)(m.Input,{label:s?"Prefix":n("prefixLabel"),value:c.prefix,onChange:e=>h({...c,prefix:e.target.value}),placeholder:s?"cc":n(i?"anthropicPrefixPlaceholder":"openaiPrefixPlaceholder"),hint:s?"Used for aliases such as prefix/model-id":n("prefixHint")}),!i&&(0,t.jsx)(y.Select,{label:n("apiTypeLabel"),options:T,value:c.apiType,onChange:e=>h({...c,apiType:e.target.value})}),(0,t.jsx)(m.Input,{label:s?"Base URL":n("baseUrlLabel"),value:c.baseUrl,onChange:e=>h({...c,baseUrl:e.target.value}),placeholder:s?"https://example.com/v1":n(i?"anthropicBaseUrlPlaceholder":"openaiBaseUrlPlaceholder"),hint:s?"Base URL for the CC-compatible site. Do not include /messages.":n("compatibleBaseUrlHint",{type:n(i?"anthropic":"openai")})}),(0,t.jsxs)("button",{type:"button",className:"text-sm text-text-muted hover:text-text-primary flex items-center gap-1",onClick:()=>S(!k),"aria-expanded":k,"aria-controls":"advanced-settings",children:[(0,t.jsx)("span",{className:`transition-transform ${k?"rotate-90":""}`,"aria-hidden":"true",children:"▶"}),n("advancedSettings")]}),k&&(0,t.jsxs)("div",{id:"advanced-settings",className:"flex flex-col gap-3 pl-2 border-l-2 border-border",children:[(0,t.jsx)(m.Input,{label:s?"Chat Path":n("chatPathLabel"),value:c.chatPath,onChange:e=>h({...c,chatPath:e.target.value}),placeholder:s?D:i?"/messages":n("chatPathPlaceholder"),hint:s?"Defaults to the strict Claude Code-compatible messages path":n("chatPathHint")}),!s&&(0,t.jsx)(m.Input,{label:n("modelsPathLabel"),value:c.modelsPath,onChange:e=>h({...c,modelsPath:e.target.value}),placeholder:n("modelsPathPlaceholder"),hint:n("modelsPathHint")})]}),(0,t.jsxs)("div",{className:"flex gap-2",children:[(0,t.jsx)(m.Input,{label:n("apiKeyForCheck"),type:"password",value:v,onChange:e=>b(e.target.value),className:"flex-1"}),(0,t.jsx)("div",{className:"pt-6",children:(0,t.jsx)(p.Button,{onClick:P,disabled:!v||j||!c.baseUrl.trim(),variant:"secondary",children:n(j?"checking":"check")})})]}),N&&(0,t.jsx)(u.Badge,{variant:"success"===N?"success":"error",children:n("success"===N?"valid":"invalid")}),(0,t.jsxs)("div",{className:"flex gap-2",children:[(0,t.jsx)(p.Button,{onClick:A,fullWidth:!0,disabled:!c.name.trim()||!c.prefix.trim()||!c.baseUrl.trim()||f,children:n(f?"saving":"save")}),(0,t.jsx)(p.Button,{onClick:l,variant:"ghost",fullWidth:!0,children:n("cancel")})]})]})}):null}H.propTypes={connection:l.default.shape({id:l.default.string,name:l.default.string,email:l.default.string,displayName:l.default.string,rateLimitedUntil:l.default.string,rateLimitProtection:l.default.bool,testStatus:l.default.string,isActive:l.default.bool,priority:l.default.number,lastError:l.default.string,lastErrorType:l.default.string,lastErrorSource:l.default.string,errorCode:l.default.oneOfType([l.default.string,l.default.number]),globalPriority:l.default.number,providerSpecificData:l.default.object}).isRequired,isOAuth:l.default.bool.isRequired,isCodex:l.default.bool,isFirst:l.default.bool.isRequired,isLast:l.default.bool.isRequired,onMoveUp:l.default.func.isRequired,onMoveDown:l.default.func.isRequired,onToggleActive:l.default.func.isRequired,onToggleRateLimit:l.default.func.isRequired,onToggleCodex5h:l.default.func,onToggleCodexWeekly:l.default.func,onRetest:l.default.func.isRequired,isRetesting:l.default.bool,onEdit:l.default.func.isRequired,onDelete:l.default.func.isRequired,onReauth:l.default.func,onApplyCodexAuthLocal:l.default.func,isApplyingCodexAuthLocal:l.default.bool,onExportCodexAuthFile:l.default.func,isExportingCodexAuthFile:l.default.bool},J.propTypes={isOpen:l.default.bool.isRequired,provider:l.default.string,providerName:l.default.string,isCompatible:l.default.bool,isAnthropic:l.default.bool,isCcCompatible:l.default.bool,onSave:l.default.func.isRequired,onClose:l.default.func.isRequired},V.propTypes={isOpen:l.default.bool.isRequired,connection:l.default.shape({id:l.default.string,name:l.default.string,email:l.default.string,priority:l.default.number,authType:l.default.string,provider:l.default.string}),onSave:l.default.func.isRequired,onClose:l.default.func.isRequired},G.propTypes={isOpen:l.default.bool.isRequired,node:l.default.shape({id:l.default.string,name:l.default.string,prefix:l.default.string,apiType:l.default.string,baseUrl:l.default.string,chatPath:l.default.string,modelsPath:l.default.string}),onSave:l.default.func.isRequired,onClose:l.default.func.isRequired,isAnthropic:l.default.bool,isCcCompatible:l.default.bool},e.s(["default",0,function(){let e=(0,i.useParams)(),r=(0,i.useRouter)(),l=e.id,[u,m]=(0,a.useState)([]),[b,y]=(0,a.useState)(!0),[A,L]=(0,a.useState)(null),[_,z]=(0,a.useState)(!1),[K,W]=(0,a.useState)(!1),[Q,Y]=(0,a.useState)(!1),[X,Z]=(0,a.useState)(!1),[ee,et]=(0,a.useState)(null),[ea,er]=(0,a.useState)(null),[eo,el]=(0,a.useState)(!1),[ei,es]=(0,a.useState)(null),[en,ed]=(0,a.useState)({}),[ec,ep]=(0,a.useState)(!1),{copied:eu,copy:em}=(0,k.useCopyToClipboard)(),ex=(0,d.useTranslations)("providers"),eh=(0,o.useNotificationStore)(),[ef,eg]=(0,a.useState)(null),[ev,eb]=(0,a.useState)(null),[ey,ej]=(0,a.useState)({}),[eC,eN]=(0,a.useState)(!1),[ew,ek]=(0,a.useState)(!1),[eS,eT]=(0,a.useState)({current:0,total:0,phase:"idle",status:"",logs:[],error:"",importedCount:0}),[eA,eP]=(0,a.useState)({customModels:[],modelCompatOverrides:[]}),[eR,eM]=(0,a.useState)([]),[eI,eE]=(0,a.useState)(null),[eO,eD]=(0,a.useState)(null),[eU,eL]=(0,a.useState)(null),e$=(0,C.isOpenAICompatibleProvider)(l),eF=(0,C.isClaudeCodeCompatibleProvider)(l),e_=(0,C.isAnthropicCompatibleProvider)(l)&&!(0,C.isClaudeCodeCompatibleProvider)(l),eB=e$||e_||eF,eq=e_||eF,ez=A?{id:A.id,name:A.name||(eF?E:"anthropic-compatible"===A.type?ex("anthropicCompatibleName"):ex("openaiCompatibleName")),color:eF?"#B45309":"anthropic-compatible"===A.type?"#D97757":"#10A37F",textIcon:eF?"CC":"anthropic-compatible"===A.type?"AC":"OC",apiType:A.apiType,baseUrl:A.baseUrl,type:A.type}:C.FREE_PROVIDERS[l]||C.OAUTH_PROVIDERS[l]||C.APIKEY_PROVIDERS[l],eK=!!C.FREE_PROVIDERS[l]||!!C.OAUTH_PROVIDERS[l],eH=(0,C.supportsApiKeyOnFreeProvider)(l),eJ=eK&&!eH,eW=(0,N.getModelsByProviderId)(l),eV="gemini"===l?eR:eW,eG=(0,C.getProviderAlias)(l),eQ=eB||"openrouter"===l,eY=l.endsWith("-search"),eX=(0,w.compatibleProviderSupportsModelImport)(l),eZ=eB?l:eG,e0=eB?A?.prefix||l:eG,e1=(0,a.useCallback)(async()=>{try{let e=await fetch("/api/models/alias"),t=await e.json();e.ok&&ed(t.aliases||{})}catch(e){console.log("Error fetching aliases:",e)}},[]),e5=(0,a.useCallback)(async()=>{if(!eY)try{let e=await fetch(`/api/provider-models?provider=${encodeURIComponent(l)}`,{cache:"no-store"});if(!e.ok)return;let t=await e.json();if(eP({customModels:t.models||[],modelCompatOverrides:t.modelCompatOverrides||[]}),"gemini"===l)try{let e=await fetch("/api/synced-available-models?provider=gemini",{cache:"no-store"});if(e.ok){let t=await e.json();eM(t.models||[])}}catch{}}catch(e){console.error("fetchProviderModelMeta",e)}},[l,eY]),e2=(0,a.useCallback)(async()=>{try{let[e,t]=await Promise.all([fetch("/api/providers",{cache:"no-store"}),fetch("/api/provider-nodes",{cache:"no-store"})]),a=await e.json(),r=await t.json();if(e.ok){let e=(a.connections||[]).filter(e=>e.provider===l);m(e)}if(t.ok){let e=(r.nodes||[]).find(e=>e.id===l)||null;if(!e&&eB)for(let t=0;t<3;t+=1){await new Promise(e=>setTimeout(e,150));let t=await fetch("/api/provider-nodes",{cache:"no-store"});if(t.ok&&(e=((await t.json()).nodes||[]).find(e=>e.id===l)||null))break}L(e)}}catch(e){console.log("Error fetching connections:",e)}finally{y(!1)}},[l,eB]),e3=async e=>{try{let t=await fetch(`/api/provider-nodes/${l}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}),a=await t.json();t.ok&&(L(a.node),await e2(),Z(!1))}catch(e){console.log("Error updating provider node:",e)}};(0,a.useEffect)(()=>{e2(),e1(),fetch("/api/settings/proxy").then(e=>e.ok?e.json():null).then(e=>eb(e)).catch(()=>{})},[e2,e1]);let e4=(0,a.useCallback)(async e=>{if(e.length)try{let t=await Promise.all(e.filter(e=>e.id).map(e=>fetch(`/api/settings/proxy?resolve=${encodeURIComponent(e.id)}`,{cache:"no-store"}).then(e=>e.ok?e.json():null).then(t=>[e.id,t]).catch(()=>[e.id,null]))),a={};for(let[e,r]of t)a[e]=r?.proxy?r:null;ej(a)}catch{}},[]);(0,a.useEffect)(()=>{b||eY||e5()},[b,eY,e5]),(0,a.useEffect)(()=>{!b&&u.length>0&&e4(u)},[b,u,e4]);let e6=async(e,t,a=eG)=>{let r=`${a}/${e}`;try{let e=await fetch("/api/models/alias",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({model:r,alias:t})});if(e.ok)await e1();else{let t=await e.json();alert(t.error||ex("failedSetAlias"))}}catch(e){console.log("Error setting alias:",e)}},e9=async e=>{try{(await fetch(`/api/models/alias?alias=${encodeURIComponent(e)}`,{method:"DELETE"})).ok&&await e1()}catch(e){console.log("Error deleting alias:",e)}},e8=async e=>{if(confirm(ex("deleteConnectionConfirm")))try{(await fetch(`/api/providers/${e}`,{method:"DELETE"})).ok&&(m(u.filter(t=>t.id!==e)),"gemini"===l&&await e5())}catch(e){console.log("Error deleting connection:",e)}},e7=(0,a.useCallback)(()=>{e2(),z(!1)},[e2]),te=(0,a.useCallback)(()=>{eJ?z(!0):W(!0)},[eJ]),tt=async e=>{try{let t=await fetch("/api/providers",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:l,...e})});if(t.ok){let e=await t.json(),a=e?.connection;if(await e2(),W(!1),"gemini"===l&&a?.id){ek(!0),eT({current:0,total:0,phase:"fetching",status:ex("fetchingModels"),logs:[],error:"",importedCount:0});try{let e=await fetch(`/api/providers/${a.id}/sync-models`,{method:"POST",signal:AbortSignal.timeout(3e4)}),t=await e.json();if(!e.ok||t.error)return eT(e=>({...e,phase:"error",status:ex("failedFetchModels"),error:t.error?.message||t.error||ex("failedImportModels")})),null;let r=t.syncedModels||0,o=t.models||[],l=[];if(o.length>0)for(let e of(l.push(`✓ ${r} models available`),l.push(""),o))l.push(` ${e.name||e.id}`);eT(e=>({...e,phase:"done",status:ex("modelsImported",{count:r}),total:r,current:r,importedCount:r,logs:l})),await e5()}catch(e){eT(t=>({...t,phase:"error",status:ex("failedFetchModels"),error:String(e)}))}}return null}let a=await t.json().catch(()=>({}));return a.error?.message||a.error||ex("failedSaveConnection")}catch(e){return console.log("Error saving connection:",e),ex("failedSaveConnectionRetry")}},ta=async e=>{try{let t=await fetch(`/api/providers/${ee.id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(t.ok)return await e2(),Y(!1),null;let a=await t.json().catch(()=>({}));return a.error?.message||a.error||ex("failedSaveConnection")}catch(e){return console.log("Error updating connection:",e),ex("failedSaveConnectionRetry")}},tr=async(e,t)=>{try{(await fetch(`/api/providers/${e}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({isActive:t})})).ok&&m(a=>a.map(a=>a.id===e?{...a,isActive:t}:a))}catch(e){console.log("Error updating connection status:",e)}},to=async(e,t)=>{try{(await fetch("/api/rate-limits",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({connectionId:e,enabled:t})})).ok&&m(a=>a.map(a=>a.id===e?{...a,rateLimitProtection:t}:a))}catch(e){console.error("Error toggling rate limit:",e)}},tl=async(e,t,a)=>{try{let r=u.find(t=>t.id===e);if(!r)return;let o=r.providerSpecificData&&"object"==typeof r.providerSpecificData?r.providerSpecificData:{},l=o.codexLimitPolicy&&"object"==typeof o.codexLimitPolicy?o.codexLimitPolicy:{},i={...U(l),[t]:a},s=await fetch(`/api/providers/${e}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({providerSpecificData:{...o,codexLimitPolicy:i}})});if(!s.ok){let e=await s.json().catch(()=>({}));eh.error(e.error||"Failed to update Codex limit policy");return}m(t=>t.map(t=>t.id===e?{...t,providerSpecificData:{...t.providerSpecificData||{},codexLimitPolicy:i}}:t)),eh.success("Codex limit policy updated")}catch(e){console.error("Error toggling Codex quota policy:",e),eh.error("Failed to update Codex limit policy")}},ti=async e=>{if(e&&!ea){er(e);try{let t=await fetch(`/api/providers/${e}/test`,{method:"POST"});if(!t.ok){let e=await t.json().catch(()=>({}));alert(e.error||ex("failedRetestConnection"));return}await e2()}catch(e){console.error("Error retesting connection:",e)}finally{er(null)}}},ts=async()=>{if(eo||0===u.length)return;el(!0),es(null);let e=new AbortController,t=setTimeout(()=>e.abort(),12e4);try{let t,a=await fetch("/api/providers/test-batch",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mode:"provider",providerId:l}),signal:e.signal});try{t=await a.json()}catch{t={error:ex("providerTestFailed"),results:[],summary:null}}if(es({...t,error:t.error?"object"==typeof t.error?t.error.message||t.error.error||JSON.stringify(t.error):String(t.error):null}),t?.summary){let{passed:e,failed:a,total:r}=t.summary;0===a?eh.success(ex("allTestsPassed",{total:r})):eh.warning(ex("testSummary",{passed:e,failed:a,total:r}))}await e2()}catch(t){let e=t?.name==="AbortError"?ex("providerTestTimeout"):ex("providerTestFailed");es({error:e,results:[],summary:null}),eh.error(e)}finally{clearTimeout(t),el(!1)}},[tn,td]=(0,a.useState)(null),tc=async(e,t)=>{if((e.headers.get("content-type")||"").includes("application/json")){let t=await e.json().catch(()=>({}));if("string"==typeof t?.error&&t.error.trim())return t.error;if(t?.error?.message)return t.error.message}return(await e.text().catch(()=>"")).trim()||t},tp=async e=>{if(!tn){td(e);try{let t=await fetch(`/api/providers/${e}/refresh`,{method:"POST"}),a=await t.json().catch(()=>({}));t.ok&&a.success?(eh.success(ex("tokenRefreshed")),await e2()):eh.error(a.error||ex("tokenRefreshFailed"))}catch(e){console.error("Error refreshing token:",e),eh.error(ex("tokenRefreshFailed"))}finally{td(null)}}},tu=async e=>{if(eO)return;eD(e);let t="function"==typeof ex.has&&ex.has("codexAuthAppliedLocal")?ex("codexAuthAppliedLocal"):"Codex auth.json applied locally",a="function"==typeof ex.has&&ex.has("codexAuthApplyFailed")?ex("codexAuthApplyFailed"):"Failed to apply Codex auth.json locally";try{let r=await fetch(`/api/providers/${e}/codex-auth/apply-local`,{method:"POST"});if(!r.ok)return void eh.error(await tc(r,a));eh.success(t)}catch(e){console.error("Error applying Codex auth locally:",e),eh.error(a)}finally{eD(null)}},tm=async e=>{if(eU)return;eL(e);let t="function"==typeof ex.has&&ex.has("codexAuthExported")?ex("codexAuthExported"):"Codex auth.json exported",a="function"==typeof ex.has&&ex.has("codexAuthExportFailed")?ex("codexAuthExportFailed"):"Failed to export Codex auth.json";try{let r=await fetch(`/api/providers/${e}/codex-auth/export`,{method:"POST"});if(!r.ok)return void eh.error(await tc(r,a));let o=await r.blob(),l=((e,t)=>{let a=e.headers.get("content-disposition")||"",r=a.match(/filename\*=UTF-8''([^;]+)/i);if(r?.[1])return decodeURIComponent(r[1]);let o=a.match(/filename="([^"]+)"/i);return o?.[1]?o[1]:t})(r,"codex-auth.json"),i=window.URL.createObjectURL(o),s=document.createElement("a");s.href=i,s.download=l,document.body.appendChild(s),s.click(),document.body.removeChild(s),window.setTimeout(()=>window.URL.revokeObjectURL(i),1e3),eh.success(t)}catch(e){console.error("Error exporting Codex auth file:",e),eh.error(a)}finally{eL(null)}},tx=async(e,t)=>{if(e&&t)try{let a=t.priority,r=e.priority;a===r&&(a=u.indexOf(e)>u.indexOf(t)?t.priority-.5:t.priority+.5),await Promise.all([fetch(`/api/providers/${e.id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({priority:a})}),fetch(`/api/providers/${t.id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({priority:r})})]),await e2()}catch(e){console.log("Error swapping priority:",e)}},th=async()=>{if(eC)return;let e=u.find(e=>!1!==e.isActive);if(e){eN(!0),ek(!0),eT({current:0,total:0,phase:"fetching",status:ex("fetchingModels"),logs:[],error:"",importedCount:0});try{let t=await fetch(`/api/providers/${e.id}/models`),a=await t.json();if(!t.ok)return void eT(e=>({...e,phase:"error",status:ex("failedFetchModels"),error:a.error||ex("failedImportModels")}));let r=a.models||[];if(0===r.length)return void eT(e=>({...e,phase:"done",status:ex("noModelsFound"),logs:[ex("noModelsReturnedFromEndpoint")]}));let o=new Set([...(eA.customModels||[]).map(e=>e.id),...eV.map(e=>e.id)]),i=r.filter(e=>!o.has(e.id||e.name||e.model));if(0===i.length)return void eT(e=>({...e,phase:"done",status:ex("allModelsAlreadyImported")||"All models already imported",logs:[ex("noNewModelsToImport")||"No new models to import"],importedCount:0,total:0,current:0}));eT(e=>({...e,phase:"importing",total:i.length,current:0,status:ex("importingModelsProgress",{current:0,total:i.length}),logs:[ex("foundModelsStartingImport",{count:i.length}),...i.length<r.length?[ex("skippingExistingModels",{count:r.length-i.length})||`Skipping ${r.length-i.length} existing models`]:[]]}));let s=0;for(let e=0;e<i.length;e++){let t=i[e],a=t.id||t.name||t.model;if(!a)continue;let r=a.split("/"),o=r[r.length-1];eT(t=>({...t,current:e+1,status:ex("importingModelsProgress",{current:e+1,total:i.length}),logs:[...t.logs,ex("importingModelById",{modelId:a})]})),await fetch("/api/provider-models",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:l,modelId:a,modelName:t.name||a,source:"imported"})}),en[o]||await e6(a,o,eZ),s+=1}await e1(),eT(e=>({...e,phase:"done",current:i.length,status:s>0?ex("importSuccessCount",{count:s}):ex("noNewModelsAddedExisting"),logs:[...e.logs,s>0?ex("importDoneCount",{count:s}):ex("noNewModelsAdded")],importedCount:s})),s>0&&setTimeout(()=>{window.location.reload()},2e3)}catch(e){console.log("Error importing models:",e),eT(t=>({...t,phase:"error",status:ex("importFailed"),error:e instanceof Error?e.message:ex("unexpectedErrorOccurred")}))}finally{eN(!1)}}},tf=async(e,t)=>{ek(!0),eT({current:0,total:0,phase:"fetching",status:ex("fetchingModels"),logs:[],error:"",importedCount:0});try{let a=(await e()).models||[];if(0===a.length)return void eT(e=>({...e,phase:"done",status:ex("noModelsFound"),logs:[ex("noModelsReturnedFromEndpoint")]}));eT(e=>({...e,phase:"importing",total:a.length,status:ex("importingModelsProgress",{current:0,total:a.length}),logs:[ex("foundModelsStartingImport",{count:a.length})]}));let r=0;for(let e=0;e<a.length;e++){let o=a[e],l=o.id||o.name||o.model;l&&(eT(t=>({...t,current:e+1,status:ex("importingModelsProgress",{current:e+1,total:a.length}),logs:[...t.logs,ex("importingModelById",{modelId:l})]})),await t(o)&&(r+=1))}eT(e=>({...e,phase:"done",current:a.length,status:r>0?ex("importSuccessCount",{count:r}):ex("noNewModelsAdded"),logs:[...e.logs,r>0?ex("importDoneCount",{count:r}):ex("noNewModelsAdded")],importedCount:r})),r>0&&setTimeout(()=>{window.location.reload()},2e3)}catch(e){console.log("Error importing models:",e),eT(t=>({...t,phase:"error",status:ex("importFailed"),error:e instanceof Error?e.message:ex("unexpectedErrorOccurred")}))}},tg=u.some(e=>!1!==e.isActive),tv=u.find(e=>!1!==e.isActive),tb=!!tv?.providerSpecificData?.autoSync,[ty,tj]=(0,a.useState)(!1),tC=async()=>{if(tv&&!ty){tj(!0);try{let e=!tb;await fetch(`/api/providers/${tv.id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({providerSpecificData:{autoSync:e}})}),await e2(),eh[e?"success":"info"](e?ex("autoSyncEnabled"):ex("autoSyncDisabled"))}catch(e){console.log("Error toggling auto-sync:",e),eh.error(ex("autoSyncToggleFailed"))}finally{tj(!1)}}},[tN,tw]=(0,a.useState)(!1),tk=(0,a.useMemo)(()=>Object.entries(en).filter(([,e])=>e.startsWith(`${eZ}/`)),[en,eZ]),tS=async()=>{if(!tN&&confirm(ex("clearAllModelsConfirm"))){tw(!0);try{(await fetch(`/api/provider-models?provider=${encodeURIComponent(eZ)}&all=true`,{method:"DELETE"})).ok?(await Promise.all(tk.map(([e])=>fetch(`/api/models/alias?alias=${encodeURIComponent(e)}`,{method:"DELETE"}).catch(()=>{}))),await e5(),await e1(),eh.success(ex("clearAllModelsSuccess"))):eh.error(ex("clearAllModelsFailed"))}catch{eh.error(ex("clearAllModelsFailed"))}finally{tw(!1)}}},tT=(0,a.useMemo)(()=>T(eA.customModels),[eA.customModels]),tA=(0,a.useMemo)(()=>T(eA.modelCompatOverrides),[eA.modelCompatOverrides]),tP=(0,a.useMemo)(()=>(0,w.getCompatibleFallbackModels)(l,eA.customModels),[l,eA.customModels]),tR=(e,t=S[0])=>P(e,t,tT,tA),tM=(e,t=S[0])=>R(e,t,tT,tA),tI=(0,a.useCallback)((e,t)=>I(e,t,tT,tA),[tT,tA]),tE=async(e,t)=>{eE(e);try{let a,r=tT.get(e),o=t.compatByProtocol&&void 0===t.normalizeToolCallId&&void 0===t.preserveOpenAIDeveloperRole&&!("upstreamHeaders"in t);r?o?a={provider:l,modelId:e,compatByProtocol:t.compatByProtocol}:(a={provider:l,modelId:e,modelName:r.name||e,source:r.source||"manual",apiFormat:r.apiFormat||"chat-completions",supportedEndpoints:Array.isArray(r.supportedEndpoints)&&r.supportedEndpoints.length?r.supportedEndpoints:["chat"],normalizeToolCallId:void 0!==t.normalizeToolCallId?t.normalizeToolCallId:!!r.normalizeToolCallId,preserveOpenAIDeveloperRole:void 0!==t.preserveOpenAIDeveloperRole?t.preserveOpenAIDeveloperRole:!Object.prototype.hasOwnProperty.call(r,"preserveOpenAIDeveloperRole")||!!r.preserveOpenAIDeveloperRole},t.compatByProtocol&&(a.compatByProtocol=t.compatByProtocol)):a={provider:l,modelId:e,...t};let i=await fetch("/api/provider-models",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)});if(!i.ok){let e=await M(i);eh.error(e?`${ex("failedSaveCustomModel")} — ${e}`:ex("failedSaveCustomModel"));return}}catch{eh.error(ex("failedSaveCustomModel"));return}finally{eE(null)}try{await e5()}catch{}};return b?(0,t.jsxs)("div",{className:"flex flex-col gap-8",children:[(0,t.jsx)(h.CardSkeleton,{}),(0,t.jsx)(h.CardSkeleton,{})]}):ez?(0,t.jsxs)("div",{className:"flex flex-col gap-8",children:[(0,t.jsxs)("div",{children:[(0,t.jsxs)(s.default,{href:"/dashboard/providers",className:"inline-flex items-center gap-1 text-sm text-text-muted hover:text-primary transition-colors mb-4",children:[(0,t.jsx)("span",{className:"material-symbols-outlined text-lg",children:"arrow_back"}),ex("backToProviders")]}),(0,t.jsxs)("div",{className:"flex items-center gap-4",children:[(0,t.jsx)("div",{className:"rounded-lg flex items-center justify-center",style:{backgroundColor:`${ez.color}15`},children:ec?(0,t.jsx)("span",{className:"text-sm font-bold",style:{color:ez.color},children:ez.textIcon||ez.id.slice(0,2).toUpperCase()}):(0,t.jsx)(n.default,{src:e$&&ez.apiType?"responses"===ez.apiType?"/providers/oai-r.png":"/providers/oai-cc.png":eq?"/providers/anthropic-m.png":`/providers/${ez.id}.png`,alt:ez.name,width:48,height:48,className:"object-contain rounded-lg max-w-[48px] max-h-[48px]",sizes:"48px",onError:()=>ep(!0)})}),(0,t.jsxs)("div",{children:[ez.website?(0,t.jsxs)("a",{href:ez.website,target:"_blank",rel:"noopener noreferrer",className:"text-3xl font-semibold tracking-tight hover:underline inline-flex items-center gap-2",style:{color:ez.color},children:[ez.name,(0,t.jsx)("span",{className:"material-symbols-outlined text-lg opacity-60",children:"open_in_new"})]}):(0,t.jsx)("h1",{className:"text-3xl font-semibold tracking-tight",children:ez.name}),(0,t.jsx)("p",{className:"text-text-muted",children:ex("connectionCountLabel",{count:u.length})})]})]})]}),eB&&A&&(0,t.jsxs)(c.Card,{children:[(0,t.jsxs)("div",{className:"flex items-center justify-between mb-4",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("h2",{className:"text-lg font-semibold",children:eF?O:e_?ex("anthropicCompatibleDetails"):ex("openaiCompatibleDetails")}),(0,t.jsxs)("p",{className:"text-sm text-text-muted",children:[eq?ex("messagesApi"):"responses"===A.apiType?ex("responsesApi"):ex("chatCompletions")," ","· ",(A.baseUrl||"").replace(/\/$/,""),"/",eF?(A.chatPath||D).replace(/^\//,""):e_?(A.chatPath||"/messages").replace(/^\//,""):"responses"===A.apiType?(A.chatPath||"/responses").replace(/^\//,""):(A.chatPath||"/chat/completions").replace(/^\//,"")]})]}),(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)(p.Button,{size:"sm",icon:"add",onClick:()=>W(!0),disabled:u.length>0,children:ex("add")}),(0,t.jsx)(p.Button,{size:"sm",variant:"secondary",icon:"edit",onClick:()=>Z(!0),children:ex("edit")}),(0,t.jsx)(p.Button,{size:"sm",variant:"secondary",icon:"delete",onClick:async()=>{if(confirm(ex("deleteCompatibleNodeConfirm",{type:eF?E:e_?ex("anthropic"):ex("openai")})))try{(await fetch(`/api/provider-nodes/${l}`,{method:"DELETE"})).ok&&r.push("/dashboard/providers")}catch(e){console.log("Error deleting provider node:",e)}},children:ex("delete")})]})]}),u.length>0&&(0,t.jsx)("p",{className:"text-sm text-text-muted",children:ex("singleConnectionPerCompatible")})]}),(0,t.jsxs)(c.Card,{children:[(0,t.jsxs)("div",{className:"flex items-center justify-between mb-4",children:[(0,t.jsxs)("div",{className:"flex items-center gap-3",children:[(0,t.jsx)("h2",{className:"text-lg font-semibold",children:ex("connections")}),(0,t.jsxs)("button",{onClick:()=>eg({level:"provider",id:l,label:ez?.name||l}),className:`inline-flex items-center gap-1 px-2 py-1 rounded text-xs font-medium transition-all ${ev?.providers?.[l]?"bg-amber-500/15 text-amber-500 hover:bg-amber-500/25":"bg-black/[0.03] dark:bg-white/[0.03] text-text-muted/50 hover:text-text-muted hover:bg-black/[0.06] dark:hover:bg-white/[0.06]"}`,title:ev?.providers?.[l]?ex("providerProxyTitleConfigured",{host:ev.providers[l].host||ex("configured")}):ex("providerProxyConfigureHint"),children:[(0,t.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"vpn_lock"}),ev?.providers?.[l]&&ev.providers[l].host||ex("providerProxy")]})]}),u.length>1&&(0,t.jsxs)("button",{onClick:ts,disabled:eo||!!ea,className:`flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-xs font-medium border transition-colors ${eo?"bg-primary/20 border-primary/40 text-primary animate-pulse":"bg-bg-subtle border-border text-text-muted hover:text-text-primary hover:border-primary/40"}`,title:ex("testAll"),"aria-label":ex("testAll"),children:[(0,t.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:eo?"sync":"play_arrow"}),eo?ex("testing"):ex("testAll")]}),eB?0===u.length&&(0,t.jsx)(p.Button,{size:"sm",icon:"add",onClick:()=>W(!0),children:ex("add")}):(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)(p.Button,{size:"sm",icon:"add",onClick:te,children:eH?"Add PAT":ex("add")}),"qoder"===l&&(0,t.jsx)(p.Button,{size:"sm",variant:"secondary",onClick:()=>z(!0),children:"Experimental OAuth"})]})]}),0===u.length?(0,t.jsxs)("div",{className:"text-center py-12",children:[(0,t.jsx)("div",{className:"inline-flex items-center justify-center w-16 h-16 rounded-full bg-primary/10 text-primary mb-4",children:(0,t.jsx)("span",{className:"material-symbols-outlined text-[32px]",children:eJ?"lock":"key"})}),(0,t.jsx)("p",{className:"text-text-main font-medium mb-1",children:ex("noConnectionsYet")}),(0,t.jsx)("p",{className:"text-sm text-text-muted mb-4",children:ex("addFirstConnectionHint")}),!eB&&(0,t.jsxs)("div",{className:"flex items-center justify-center gap-2",children:[(0,t.jsx)(p.Button,{icon:"add",onClick:te,children:eH?"Add PAT":ex("addConnection")}),"qoder"===l&&(0,t.jsx)(p.Button,{variant:"secondary",onClick:()=>z(!0),children:"Experimental OAuth"})]})]}):(()=>{let e=[...u].sort((e,t)=>(e.priority||0)-(t.priority||0));if(!e.some(e=>e.providerSpecificData?.tag))return(0,t.jsx)("div",{className:"flex flex-col divide-y divide-black/[0.03] dark:divide-white/[0.03]",children:e.map((a,r)=>(0,t.jsx)(H,{connection:a,isOAuth:"oauth"===a.authType,isFirst:0===r,isLast:r===e.length-1,onMoveUp:()=>tx(a,e[r-1]),onMoveDown:()=>tx(a,e[r+1]),onToggleActive:e=>tr(a.id,e),onToggleRateLimit:e=>to(a.id,e),isCodex:"codex"===l,onToggleCodex5h:e=>tl(a.id,"use5h",e),onToggleCodexWeekly:e=>tl(a.id,"useWeekly",e),onRetest:()=>ti(a.id),isRetesting:ea===a.id,onEdit:()=>{et(a),Y(!0)},onDelete:()=>e8(a.id),onReauth:"oauth"===a.authType?()=>z(!0):void 0,onRefreshToken:"oauth"===a.authType?()=>tp(a.id):void 0,isRefreshing:tn===a.id,onApplyCodexAuthLocal:"codex"===l?()=>tu(a.id):void 0,isApplyingCodexAuthLocal:eO===a.id,onExportCodexAuthFile:"codex"===l?()=>tm(a.id):void 0,isExportingCodexAuthFile:eU===a.id,onProxy:()=>eg({level:"key",id:a.id,label:a.name||a.email||a.id}),hasProxy:!!ey[a.id]?.proxy,proxySource:ey[a.id]?.level||null,proxyHost:ey[a.id]?.proxy?.host||null},a.id))});let a=new Map;for(let t of e){let e=t.providerSpecificData?.tag?.trim()||"";a.has(e)||a.set(e,[]),a.get(e).push(t)}let r=Array.from(a.keys()).sort((e,t)=>""===e?-1:""===t?1:e.localeCompare(t));return(0,t.jsx)("div",{className:"flex flex-col gap-0",children:r.map((o,i)=>{let s=a.get(o);return(0,t.jsxs)("div",{className:i>0?"border-t border-black/[0.06] dark:border-white/[0.06] mt-1 pt-1":"",children:[o&&(0,t.jsxs)("div",{className:"flex items-center gap-2 px-3 pt-2 pb-1",children:[(0,t.jsx)("span",{className:"material-symbols-outlined text-[13px] text-text-muted/50",children:"label"}),(0,t.jsx)("span",{className:"text-[11px] font-semibold uppercase tracking-widest text-text-muted/60 select-none",children:o}),(0,t.jsx)("div",{className:"flex-1 h-px bg-black/[0.04] dark:bg-white/[0.04]"}),(0,t.jsx)("span",{className:"text-[10px] text-text-muted/40",children:s.length})]}),(0,t.jsx)("div",{className:"flex flex-col divide-y divide-black/[0.03] dark:divide-white/[0.03]",children:s.map((a,o)=>(0,t.jsx)(H,{connection:a,isOAuth:"oauth"===a.authType,isFirst:0===i&&0===o,isLast:i===r.length-1&&o===s.length-1,onMoveUp:()=>tx(a,e[e.indexOf(a)-1]),onMoveDown:()=>tx(a,e[e.indexOf(a)+1]),onToggleActive:e=>tr(a.id,e),onToggleRateLimit:e=>to(a.id,e),isCodex:"codex"===l,onToggleCodex5h:e=>tl(a.id,"use5h",e),onToggleCodexWeekly:e=>tl(a.id,"useWeekly",e),onRetest:()=>ti(a.id),isRetesting:ea===a.id,onEdit:()=>{et(a),Y(!0)},onDelete:()=>e8(a.id),onReauth:"oauth"===a.authType?()=>z(!0):void 0,onRefreshToken:"oauth"===a.authType?()=>tp(a.id):void 0,isRefreshing:tn===a.id,onApplyCodexAuthLocal:"codex"===l?()=>tu(a.id):void 0,isApplyingCodexAuthLocal:eO===a.id,onExportCodexAuthFile:"codex"===l?()=>tm(a.id):void 0,isExportingCodexAuthFile:eU===a.id,onProxy:()=>eg({level:"key",id:a.id,label:a.name||a.email||a.id}),hasProxy:!!ey[a.id]?.proxy,proxySource:ey[a.id]?.level||null,proxyHost:ey[a.id]?.proxy?.host||null},a.id))})]},o||"__untagged__")})})})()]}),!eY&&(0,t.jsxs)(c.Card,{children:[(0,t.jsx)("h2",{className:"text-lg font-semibold mb-4",children:ex("availableModels")}),(()=>{let e=eX&&tg&&(0,t.jsxs)("button",{onClick:tC,disabled:ty,className:"flex items-center gap-1.5 px-2.5 py-1 rounded-lg border border-border bg-transparent cursor-pointer text-[12px] disabled:opacity-50 disabled:cursor-not-allowed",title:ex("autoSyncTooltip"),children:[(0,t.jsx)("span",{className:"material-symbols-outlined text-[16px]",style:{color:tb?"#22c55e":"var(--color-text-muted)"},children:tb?"toggle_on":"toggle_off"}),(0,t.jsx)("span",{className:"text-text-main",children:ex("autoSync")})]}),a=(eA.customModels.length>0||tk.length>0)&&(0,t.jsxs)("button",{onClick:tS,disabled:tN,className:"flex items-center gap-1.5 px-2.5 py-1 rounded-lg border border-red-300 dark:border-red-800 bg-transparent cursor-pointer text-[12px] text-red-600 dark:text-red-400 hover:bg-red-50 dark:hover:bg-red-900/20 disabled:opacity-50 disabled:cursor-not-allowed",title:ex("clearAllModels"),children:[(0,t.jsx)("span",{className:"material-symbols-outlined text-[16px]",children:"delete_sweep"}),(0,t.jsx)("span",{children:ex("clearAllModels")})]});if(eQ){let r="openrouter"===l?ex("openRouterAnyModelHint"):eF?"CC Compatible available models mirror the OAuth Claude Code provider list.":ex("compatibleModelsDescription",{type:e_?ex("anthropic"):ex("openai")}),o="openrouter"===l?ex("modelIdFromOpenRouter"):ex("modelId"),i="openrouter"===l?ex("openRouterModelPlaceholder"):eF?"claude-sonnet-4-6":e_?ex("anthropicCompatibleModelPlaceholder"):ex("openaiCompatibleModelPlaceholder");return(0,t.jsxs)("div",{children:[(0,t.jsxs)("div",{className:"flex items-center gap-2 mb-4",children:[e,a]}),(0,t.jsx)(q,{providerStorageAlias:eZ,providerDisplayAlias:e0,modelAliases:en,fallbackModels:tP,description:r,inputLabel:o,inputPlaceholder:i,copied:eu,onCopy:em,onSetAlias:e6,onDeleteAlias:e9,connections:u,isAnthropic:eq,onImportWithProgress:tf,t:ex,effectiveModelNormalize:tR,effectiveModelPreserveDeveloper:tM,getUpstreamHeadersRecord:tI,saveModelCompatFlags:tE,compatSavingModelId:eI,onModelsChanged:e5,allowImport:eX})]})}if(ez.passthroughModels)return(0,t.jsxs)("div",{children:[(0,t.jsxs)("div",{className:"flex items-center gap-2 mb-4",children:[(0,t.jsx)(p.Button,{size:"sm",variant:"secondary",icon:"download",onClick:th,disabled:!tg||eC,children:eC?ex("importingModels"):ex("importFromModels")}),e,a,!tg&&(0,t.jsx)("span",{className:"text-xs text-text-muted",children:ex("addConnectionToImport")})]}),(0,t.jsx)(F,{providerAlias:eG,modelAliases:en,copied:eu,onCopy:em,onSetAlias:e6,onDeleteAlias:e9,t:ex,effectiveModelNormalize:tR,effectiveModelPreserveDeveloper:tM,getUpstreamHeadersRecord:tI,saveModelCompatFlags:tE,compatSavingModelId:eI})]});let r="gemini"===l?null:(0,t.jsxs)("div",{className:"flex items-center gap-2 mb-4",children:[(0,t.jsx)(p.Button,{size:"sm",variant:"secondary",icon:"download",onClick:th,disabled:!tg||eC,children:eC?ex("importingModels"):ex("importFromModels")}),e,!tg&&(0,t.jsx)("span",{className:"text-xs text-text-muted",children:ex("addConnectionToImport")})]});return 0===eV.length?(0,t.jsxs)("div",{children:[r,(0,t.jsx)("p",{className:"text-sm text-text-muted",children:ex("noModelsConfigured")})]}):(0,t.jsxs)("div",{children:[r,(0,t.jsx)("div",{className:"flex flex-wrap gap-3",children:eV.map(e=>(0,t.jsx)($,{model:e,fullModel:`${e0}/${e.id}`,copied:eu,onCopy:em,t:ex,showDeveloperToggle:!0,effectiveModelNormalize:tR,effectiveModelPreserveDeveloper:tM,getUpstreamHeadersRecord:t=>tI(e.id,t),saveModelCompatFlags:tE,compatDisabled:eI===e.id},e.id))})]})})(),!eQ&&"gemini"!==l&&(0,t.jsx)(B,{providerId:l,providerAlias:e0,copied:eu,onCopy:em,onModelsChanged:e5})]}),eY&&(0,t.jsxs)(c.Card,{children:[(0,t.jsx)("h2",{className:"text-lg font-semibold mb-4",children:ex("searchProvider")||"Search Provider"}),(0,t.jsx)("p",{className:"text-sm text-text-muted",children:ex("searchProviderDesc")||"This provider is used for web search via POST /v1/search. No model configuration needed — search providers are ready to use once an API key is connected."}),"perplexity-search"===l&&(0,t.jsxs)("div",{className:"mt-3 flex items-center gap-2 px-3 py-2 rounded-lg bg-blue-500/10 border border-blue-500/20",children:[(0,t.jsx)("span",{className:"material-symbols-outlined text-sm text-blue-400",children:"link"}),(0,t.jsxs)("p",{className:"text-xs text-blue-300",children:["Uses the same API key as ",(0,t.jsx)("strong",{children:"Perplexity"})," (chat provider). If you already have Perplexity configured, no additional setup is needed."]})]})]}),"kiro"===l?(0,t.jsx)(g.default,{isOpen:_,providerInfo:ez,onSuccess:e7,onClose:()=>{z(!1)}}):"cursor"===l?(0,t.jsx)(v.default,{isOpen:_,onSuccess:e7,onClose:()=>{z(!1)}}):(0,t.jsx)(f.default,{isOpen:_,provider:l,providerInfo:ez,onSuccess:e7,onClose:()=>{z(!1)}}),(0,t.jsx)(J,{isOpen:K,provider:l,providerName:ez.name,isCompatible:eB,isAnthropic:eq,isCcCompatible:eF,onSave:tt,onClose:()=>W(!1)}),(0,t.jsx)(V,{isOpen:Q,connection:ee,onSave:ta,onClose:()=>Y(!1)}),eB&&(0,t.jsx)(G,{isOpen:X,node:A,onSave:e3,onClose:()=>Z(!1),isAnthropic:eq,isCcCompatible:eF}),ei&&(0,t.jsxs)("div",{className:"fixed inset-0 z-50 flex items-start justify-center pt-[10vh]",onClick:()=>es(null),children:[(0,t.jsx)("div",{className:"absolute inset-0 bg-black/60 backdrop-blur-sm"}),(0,t.jsxs)("div",{className:"relative bg-bg-primary border border-border rounded-xl w-full max-w-[600px] max-h-[80vh] overflow-y-auto shadow-2xl",onClick:e=>e.stopPropagation(),children:[(0,t.jsxs)("div",{className:"sticky top-0 z-10 flex items-center justify-between px-5 py-3 border-b border-border bg-bg-primary/95 backdrop-blur-sm rounded-t-xl",children:[(0,t.jsx)("h3",{className:"font-semibold",children:ex("testResults")}),(0,t.jsx)("button",{onClick:()=>es(null),className:"p-1 rounded-lg hover:bg-bg-subtle text-text-muted hover:text-text-primary transition-colors","aria-label":"Close",children:(0,t.jsx)("span",{className:"material-symbols-outlined text-lg",children:"close"})})]}),(0,t.jsx)("div",{className:"p-5",children:ei.error&&(!ei.results||0===ei.results.length)?(0,t.jsxs)("div",{className:"text-center py-6",children:[(0,t.jsx)("span",{className:"material-symbols-outlined text-red-500 text-[32px] mb-2 block",children:"error"}),(0,t.jsx)("p",{className:"text-sm text-red-400",children:String(ei.error)})]}):(0,t.jsxs)("div",{className:"flex flex-col gap-3",children:[ei.summary&&(0,t.jsxs)("div",{className:"flex items-center gap-3 text-xs mb-1",children:[(0,t.jsx)("span",{className:"text-text-muted",children:ez?.name||l}),(0,t.jsx)("span",{className:"px-2 py-0.5 rounded bg-emerald-500/15 text-emerald-400 font-medium",children:ex("passedCount",{count:ei.summary.passed})}),ei.summary.failed>0&&(0,t.jsx)("span",{className:"px-2 py-0.5 rounded bg-red-500/15 text-red-400 font-medium",children:ex("failedCount",{count:ei.summary.failed})}),(0,t.jsx)("span",{className:"text-text-muted ml-auto",children:ex("testedCount",{count:ei.summary.total})})]}),(ei.results||[]).map((e,a)=>(0,t.jsxs)("div",{className:"flex items-center gap-2 text-xs px-3 py-2 rounded-lg bg-black/[0.03] dark:bg-white/[0.03]",children:[(0,t.jsx)("span",{className:`material-symbols-outlined text-[16px] ${e.valid?"text-emerald-500":"text-red-500"}`,children:e.valid?"check_circle":"error"}),(0,t.jsx)("div",{className:"flex-1 min-w-0",children:(0,t.jsx)("span",{className:"font-medium",children:e.connectionName})}),void 0!==e.latencyMs&&(0,t.jsx)("span",{className:"text-text-muted font-mono tabular-nums",children:ex("millisecondsAbbr",{value:e.latencyMs})}),(0,t.jsx)("span",{className:`text-[10px] uppercase font-bold px-1.5 py-0.5 rounded ${e.valid?"bg-emerald-500/15 text-emerald-400":"bg-red-500/15 text-red-400"}`,children:e.valid?ex("okShort"):e.diagnosis?.type||ex("errorShort")})]},e.connectionId||a)),(!ei.results||0===ei.results.length)&&(0,t.jsx)("div",{className:"text-center py-4 text-text-muted text-sm",children:ex("noActiveConnectionsInGroup")})]})})]})]}),ef&&(0,t.jsx)(j.ProxyConfigModal,{isOpen:!!ef,onClose:()=>eg(null),level:ef.level,levelId:ef.id,levelLabel:ef.label,onSaved:()=>void e4(u)}),(0,t.jsx)(x.Modal,{isOpen:ew,onClose:()=>{("done"===eS.phase||"error"===eS.phase)&&ek(!1)},title:ex("importingModelsTitle"),size:"md",closeOnOverlay:!1,showCloseButton:"done"===eS.phase||"error"===eS.phase,children:(0,t.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,t.jsxs)("div",{className:"flex items-center gap-3",children:["fetching"===eS.phase&&(0,t.jsx)("span",{className:"material-symbols-outlined text-primary animate-spin",children:"progress_activity"}),"importing"===eS.phase&&(0,t.jsx)("span",{className:"material-symbols-outlined text-primary animate-spin",children:"progress_activity"}),"done"===eS.phase&&(0,t.jsx)("span",{className:"material-symbols-outlined text-green-500",children:"check_circle"}),"error"===eS.phase&&(0,t.jsx)("span",{className:"material-symbols-outlined text-red-500",children:"error"}),(0,t.jsx)("span",{className:"text-sm font-medium text-text-main",children:eS.status})]}),("importing"===eS.phase||"done"===eS.phase)&&eS.total>0&&(0,t.jsxs)("div",{className:"w-full",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between mb-1",children:[(0,t.jsxs)("span",{className:"text-xs text-text-muted",children:[eS.current," / ",eS.total]}),(0,t.jsxs)("span",{className:"text-xs text-text-muted",children:[Math.round(eS.current/eS.total*100),"%"]})]}),(0,t.jsx)("div",{className:"w-full h-2.5 bg-black/10 dark:bg-white/10 rounded-full overflow-hidden",children:(0,t.jsx)("div",{className:"h-full rounded-full transition-all duration-300 ease-out",style:{width:`${eS.current/eS.total*100}%`,background:"done"===eS.phase?"linear-gradient(90deg, #22c55e, #16a34a)":"linear-gradient(90deg, var(--color-primary), var(--color-primary-hover, var(--color-primary)))"}})})]}),"fetching"===eS.phase&&(0,t.jsx)("div",{className:"w-full h-2.5 bg-black/10 dark:bg-white/10 rounded-full overflow-hidden",children:(0,t.jsx)("div",{className:"h-full rounded-full animate-pulse",style:{width:"60%",background:"linear-gradient(90deg, var(--color-primary), var(--color-primary-hover, var(--color-primary)))"}})}),"error"===eS.phase&&eS.error&&(0,t.jsx)("div",{className:"p-3 rounded-lg bg-red-500/10 border border-red-500/20",children:(0,t.jsx)("p",{className:"text-sm text-red-400",children:eS.error})}),eS.logs.length>0&&(0,t.jsx)("div",{className:"max-h-48 overflow-y-auto rounded-lg bg-black/5 dark:bg-white/5 p-3 border border-black/5 dark:border-white/5",children:(0,t.jsx)("div",{className:"flex flex-col gap-1",children:eS.logs.map((e,a)=>(0,t.jsx)("p",{className:`text-xs font-mono ${e.startsWith("✓")?"text-green-500 font-semibold":"text-text-muted"}`,children:e},a))})}),"done"===eS.phase&&(0,t.jsx)("div",{className:"flex justify-center",children:(0,t.jsx)("button",{onClick:()=>ek(!1),className:"px-4 py-2 text-sm font-medium rounded-lg bg-primary text-white hover:opacity-90 transition-opacity",children:ex("close")||"Close"})})]})})]}):(0,t.jsxs)("div",{className:"text-center py-20",children:[(0,t.jsx)("p",{className:"text-text-muted",children:ex("providerNotFound")}),(0,t.jsx)(s.default,{href:"/dashboard/providers",className:"text-primary mt-4 inline-block",children:ex("backToProviders")})]})}],710864)}]);
|