switchboard-router 0.9.70 → 0.9.72
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/static/chunks/1321-37ecf3f45c464e7e.js +1 -0
- package/app/.next/static/chunks/app/(dashboard)/dashboard/endpoint/{page-5503dc94b3b73efc.js → page-c49c2c45881644c2.js} +1 -1
- package/app/.next/static/chunks/app/(dashboard)/dashboard/providers/[id]/{page-6e36b61f4ae58378.js → page-15f9f168b6ba8411.js} +1 -1
- package/app/.next-cli-build/BUILD_ID +1 -1
- package/app/.next-cli-build/app-path-routes-manifest.json +17 -17
- package/app/.next-cli-build/build-manifest.json +2 -2
- package/app/.next-cli-build/prerender-manifest.json +3 -3
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/agent-library/page.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/agent-library/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/basic-chat/page.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/basic-chat/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/cli-tools/[toolId]/page.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/cli-tools/[toolId]/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/cli-tools/page.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/cli-tools/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/combos/page.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/combos/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/combos/routing/page.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/combos/routing/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/console-log/page.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/console-log/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/endpoint/page.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/endpoint/page.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/endpoint/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/media-providers/[kind]/[id]/page.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/media-providers/[kind]/[id]/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/media-providers/[kind]/page.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/media-providers/[kind]/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/media-providers/combo/[id]/page.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/media-providers/combo/[id]/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/media-providers/page.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/media-providers/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/media-providers/web/page.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/media-providers/web/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/mitm/page.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/mitm/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/page.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/profile/page.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/profile/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/providers/[id]/page.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/providers/[id]/page.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/providers/[id]/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/providers/new/page.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/providers/new/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/providers/page.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/providers/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/pxpipe/page.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/pxpipe/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/quota/page.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/quota/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/skills/[id]/page.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/skills/[id]/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/skills/page.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/skills/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/token-saver/page.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/token-saver/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/translator/page.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/translator/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/usage/page.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/usage/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/_global-error/page.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/_global-error/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/_global-error.html +1 -1
- package/app/.next-cli-build/server/app/_global-error.rsc +1 -1
- package/app/.next-cli-build/server/app/_global-error.segments/_full.segment.rsc +1 -1
- package/app/.next-cli-build/server/app/_global-error.segments/_global-error/__PAGE__.segment.rsc +1 -1
- package/app/.next-cli-build/server/app/_global-error.segments/_tree.segment.rsc +1 -1
- package/app/.next-cli-build/server/app/_not-found/page.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/_not-found/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/_not-found.html +1 -1
- package/app/.next-cli-build/server/app/_not-found.rsc +3 -3
- package/app/.next-cli-build/server/app/_not-found.segments/_full.segment.rsc +3 -3
- package/app/.next-cli-build/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +3 -3
- package/app/.next-cli-build/server/app/_not-found.segments/_tree.segment.rsc +1 -1
- package/app/.next-cli-build/server/app/api/agent-library/catalog/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/agent-library/doctor/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/agent-library/export/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/agent-library/mcp/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/agent-library/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/agent-library/skills/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/agent-library/sync/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/agent-library/updates/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/auth/login/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/auth/logout/route.js +1 -1
- package/app/.next-cli-build/server/app/api/auth/logout/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/auth/status/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/cli-tools/aider-settings/route.js +2 -2
- package/app/.next-cli-build/server/app/api/cli-tools/aider-settings/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/cli-tools/all-statuses/route.js +5 -5
- package/app/.next-cli-build/server/app/api/cli-tools/all-statuses/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/cli-tools/antigravity-mitm/alias/route.js +1 -1
- package/app/.next-cli-build/server/app/api/cli-tools/antigravity-mitm/alias/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/cli-tools/antigravity-mitm/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/cli-tools/claude-full-catalog/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/cli-tools/claude-picker-labels/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/cli-tools/claude-settings/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/cli-tools/cline-settings/route.js +2 -2
- package/app/.next-cli-build/server/app/api/cli-tools/cline-settings/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/cli-tools/codex-profiles/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/cli-tools/codex-settings/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/cli-tools/cowork-mcp-registry/route.js +2 -2
- package/app/.next-cli-build/server/app/api/cli-tools/cowork-mcp-registry/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/cli-tools/cowork-mcp-tools/route.js +2 -2
- package/app/.next-cli-build/server/app/api/cli-tools/cowork-mcp-tools/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/cli-tools/cowork-settings/route.js +1 -1
- package/app/.next-cli-build/server/app/api/cli-tools/cowork-settings/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/cli-tools/deepseek-tui-settings/route.js +2 -2
- package/app/.next-cli-build/server/app/api/cli-tools/deepseek-tui-settings/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/cli-tools/droid-settings/route.js +2 -2
- package/app/.next-cli-build/server/app/api/cli-tools/droid-settings/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/cli-tools/fx-settings/manual-configs/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/cli-tools/fx-settings/route.js +2 -2
- package/app/.next-cli-build/server/app/api/cli-tools/fx-settings/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/cli-tools/gemini-cli-settings/route.js +3 -3
- package/app/.next-cli-build/server/app/api/cli-tools/gemini-cli-settings/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/cli-tools/grok-settings/route.js +2 -2
- package/app/.next-cli-build/server/app/api/cli-tools/grok-settings/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/cli-tools/hermes-profiles/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/cli-tools/hermes-settings/route.js +1 -1
- package/app/.next-cli-build/server/app/api/cli-tools/hermes-settings/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/cli-tools/jcode-settings/route.js +2 -2
- package/app/.next-cli-build/server/app/api/cli-tools/jcode-settings/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/cli-tools/kilo-settings/route.js +2 -2
- package/app/.next-cli-build/server/app/api/cli-tools/kilo-settings/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/cli-tools/openclaw-settings/route.js +2 -2
- package/app/.next-cli-build/server/app/api/cli-tools/openclaw-settings/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/cli-tools/opencode-settings/route.js +2 -2
- package/app/.next-cli-build/server/app/api/cli-tools/opencode-settings/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/cli-tools/pi-settings/manual-configs/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/cli-tools/pi-settings/route.js +1 -1
- package/app/.next-cli-build/server/app/api/cli-tools/pi-settings/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/cli-tools/picker-labels/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/combos/[id]/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/combos/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/headroom/extras/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/headroom/proxy/[...path]/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/headroom/restart/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/headroom/start/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/headroom/status/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/headroom/stop/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/health/live/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/health/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/keys/[id]/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/keys/route.js +1 -1
- package/app/.next-cli-build/server/app/api/keys/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/locale/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/mcp/[plugin]/message/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/mcp/[plugin]/sse/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/media-providers/tts/deepgram/voices/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/media-providers/tts/elevenlabs/voices/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/media-providers/tts/inworld/voices/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/media-providers/tts/minimax/voices/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/media-providers/tts/voices/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/mgmt/v1/combos/[id]/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/mgmt/v1/combos/[id]/strategy/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/mgmt/v1/combos/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/mgmt/v1/health/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/mgmt/v1/metrics/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/mgmt/v1/providers/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/mgmt/v1/routing/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/mgmt/v1/usage/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/mgmt/v1/version/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/models/alias/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/models/availability/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/models/custom/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/models/disabled/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/models/routable/route.js +1 -1
- package/app/.next-cli-build/server/app/api/models/routable/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/models/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/models/test/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/oauth/[provider]/[action]/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/oauth/codex/bulk-import/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/oauth/codex/import-token/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/oauth/cursor/auto-import/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/oauth/cursor/import/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/oauth/gitlab/pat/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/oauth/grok-cli/bulk-import/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/oauth/iflow/cookie/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/oauth/kiro/api-key/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/oauth/kiro/auto-import/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/oauth/kiro/import/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/oauth/kiro/import-cli-proxy/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/oauth/kiro/social-authorize/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/oauth/kiro/social-exchange/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/pricing/defaults/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/pricing/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/provider-nodes/[id]/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/provider-nodes/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/provider-nodes/validate/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/providers/[id]/model-probes/batch/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/providers/[id]/model-probes/cache/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/providers/[id]/model-probes/prepare/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/providers/[id]/model-probes/remove-unavailable/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/providers/[id]/model-probes/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/providers/[id]/model-probes/verify/cancel/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/providers/[id]/model-probes/verify/start/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/providers/[id]/model-probes/verify/status/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/providers/[id]/models/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/providers/[id]/overrides/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/providers/[id]/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/providers/[id]/test/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/providers/[id]/test-models/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/providers/client/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/providers/kilo/free-models/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/providers/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/providers/suggested-models/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/providers/test-batch/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/providers/validate/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/pxpipe/health/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/pxpipe/install/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/pxpipe/logs/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/pxpipe/restart/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/pxpipe/start/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/pxpipe/stats/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/pxpipe/status/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/pxpipe/stop/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/routing/feedback/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/routing/insights/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/routing/learn/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/routing/stats/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/routing/versions/promote/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/routing/versions/rollback/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/settings/database/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/settings/proxy-test/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/settings/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/shutdown/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/skills/[id]/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/tags/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/token-saver/vault-stats/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/translator/console-logs/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/translator/console-logs/stream/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/translator/load/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/translator/save/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/translator/send/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/translator/translate/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/usage/[connectionId]/claude-reset/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/usage/[connectionId]/codex-reset-credits/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/usage/[connectionId]/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/usage/chart/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/usage/history/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/usage/logs/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/usage/providers/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/usage/request-details/[id]/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/usage/request-details/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/usage/request-logs/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/usage/stats/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/usage/stream/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/v1/api/chat/route.js +1 -1
- package/app/.next-cli-build/server/app/api/v1/api/chat/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/v1/audio/speech/route.js +1 -1
- package/app/.next-cli-build/server/app/api/v1/audio/speech/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/v1/audio/transcriptions/route.js +1 -1
- package/app/.next-cli-build/server/app/api/v1/audio/transcriptions/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/v1/audio/voices/route.js +1 -1
- package/app/.next-cli-build/server/app/api/v1/audio/voices/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/v1/chat/completions/route.js +1 -1
- package/app/.next-cli-build/server/app/api/v1/chat/completions/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/v1/embeddings/route.js +1 -1
- package/app/.next-cli-build/server/app/api/v1/embeddings/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/v1/images/generations/route.js +2 -2
- package/app/.next-cli-build/server/app/api/v1/images/generations/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/v1/messages/count_tokens/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/v1/messages/route.js +1 -1
- package/app/.next-cli-build/server/app/api/v1/messages/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/v1/models/[...model]/route.js +1 -1
- package/app/.next-cli-build/server/app/api/v1/models/[...model]/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/v1/models/info/route.js +1 -1
- package/app/.next-cli-build/server/app/api/v1/models/info/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/v1/models/route.js +1 -1
- package/app/.next-cli-build/server/app/api/v1/models/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/v1/responses/compact/route.js +1 -1
- package/app/.next-cli-build/server/app/api/v1/responses/compact/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/v1/responses/route.js +1 -1
- package/app/.next-cli-build/server/app/api/v1/responses/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/v1/route.js +1 -1
- package/app/.next-cli-build/server/app/api/v1/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/v1/search/route.js +1 -1
- package/app/.next-cli-build/server/app/api/v1/search/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/v1/systemone/route.js +1 -1
- package/app/.next-cli-build/server/app/api/v1/systemone/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/v1/videos/[id]/route.js +1 -1
- package/app/.next-cli-build/server/app/api/v1/videos/[id]/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/v1/videos/edits/route.js +1 -1
- package/app/.next-cli-build/server/app/api/v1/videos/edits/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/v1/videos/extensions/route.js +1 -1
- package/app/.next-cli-build/server/app/api/v1/videos/extensions/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/v1/videos/generations/route.js +1 -1
- package/app/.next-cli-build/server/app/api/v1/videos/generations/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/v1/web/fetch/route.js +1 -1
- package/app/.next-cli-build/server/app/api/v1/web/fetch/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/v1beta/models/[...path]/route.js +1 -1
- package/app/.next-cli-build/server/app/api/v1beta/models/[...path]/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/v1beta/models/route.js +1 -1
- package/app/.next-cli-build/server/app/api/v1beta/models/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/version/route.js +1 -1
- package/app/.next-cli-build/server/app/api/version/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/version/shutdown/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/version/update/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/callback/page.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/callback/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/callback.html +1 -1
- package/app/.next-cli-build/server/app/callback.rsc +3 -3
- package/app/.next-cli-build/server/app/callback.segments/_full.segment.rsc +3 -3
- package/app/.next-cli-build/server/app/callback.segments/_tree.segment.rsc +1 -1
- package/app/.next-cli-build/server/app/callback.segments/callback/__PAGE__.segment.rsc +3 -3
- package/app/.next-cli-build/server/app/dashboard/settings/pricing/page.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/dashboard/settings/pricing/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/dashboard/settings/pricing.html +1 -1
- package/app/.next-cli-build/server/app/dashboard/settings/pricing.rsc +3 -3
- package/app/.next-cli-build/server/app/dashboard/settings/pricing.segments/_full.segment.rsc +3 -3
- package/app/.next-cli-build/server/app/dashboard/settings/pricing.segments/_tree.segment.rsc +1 -1
- package/app/.next-cli-build/server/app/dashboard/settings/pricing.segments/dashboard/settings/pricing/__PAGE__.segment.rsc +3 -3
- package/app/.next-cli-build/server/app/favicon.ico/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/index.html +1 -1
- package/app/.next-cli-build/server/app/index.rsc +3 -3
- package/app/.next-cli-build/server/app/index.segments/__PAGE__.segment.rsc +3 -3
- package/app/.next-cli-build/server/app/index.segments/_full.segment.rsc +3 -3
- package/app/.next-cli-build/server/app/index.segments/_tree.segment.rsc +1 -1
- package/app/.next-cli-build/server/app/landing/page.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/landing/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/landing.html +1 -1
- package/app/.next-cli-build/server/app/landing.rsc +3 -3
- package/app/.next-cli-build/server/app/landing.segments/_full.segment.rsc +3 -3
- package/app/.next-cli-build/server/app/landing.segments/_tree.segment.rsc +1 -1
- package/app/.next-cli-build/server/app/landing.segments/landing/__PAGE__.segment.rsc +3 -3
- package/app/.next-cli-build/server/app/login/page.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/login/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/login.html +1 -1
- package/app/.next-cli-build/server/app/login.rsc +4 -4
- package/app/.next-cli-build/server/app/login.segments/_full.segment.rsc +4 -4
- package/app/.next-cli-build/server/app/login.segments/_tree.segment.rsc +1 -1
- package/app/.next-cli-build/server/app/login.segments/login/__PAGE__.segment.rsc +4 -4
- package/app/.next-cli-build/server/app/manifest.webmanifest/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/page.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app-paths-manifest.json +17 -17
- package/app/.next-cli-build/server/chunks/1350.js +1 -1
- package/app/.next-cli-build/server/chunks/1757.js +1 -1
- package/app/.next-cli-build/server/chunks/2348.js +1 -1
- package/app/.next-cli-build/server/chunks/2574.js +1 -1
- package/app/.next-cli-build/server/chunks/2766.js +1 -1
- package/app/.next-cli-build/server/chunks/2770.js +1 -1
- package/app/.next-cli-build/server/chunks/629.js +1 -1
- package/app/.next-cli-build/server/chunks/7730.js +1 -0
- package/app/.next-cli-build/server/chunks/8102.js +1 -0
- package/app/.next-cli-build/server/chunks/8400.js +1 -1
- package/app/.next-cli-build/server/chunks/869.js +1 -1
- package/app/.next-cli-build/server/chunks/8998.js +3 -3
- package/app/.next-cli-build/server/chunks/9264.js +1 -1
- package/app/.next-cli-build/server/chunks/9353.js +1 -1
- package/app/.next-cli-build/server/chunks/9662.js +1 -1
- package/app/.next-cli-build/server/middleware-build-manifest.js +1 -1
- package/app/.next-cli-build/server/middleware.js +1 -1
- package/app/.next-cli-build/server/pages/404.html +1 -1
- package/app/.next-cli-build/server/pages/500.html +1 -1
- package/app/.next-cli-build/server/server-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/server-reference-manifest.json +1 -1
- package/app/.next-cli-build/static/chunks/1321-37ecf3f45c464e7e.js +1 -0
- package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/endpoint/{page-5503dc94b3b73efc.js → page-c49c2c45881644c2.js} +1 -1
- package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/providers/[id]/{page-6e36b61f4ae58378.js → page-15f9f168b6ba8411.js} +1 -1
- package/app/config-writers.cjs +2 -1
- package/app/open-sse/identity/tls/bin/darwin/arm64/switchboard-claude-tls +0 -0
- package/app/open-sse/identity/tls/bin/darwin/x64/switchboard-claude-tls +0 -0
- package/app/open-sse/identity/tls/bin/linux/arm64/switchboard-claude-tls +0 -0
- package/app/open-sse/identity/tls/bin/linux/x64/switchboard-claude-tls +0 -0
- package/app/open-sse/identity/tls/bin/win32/arm64/switchboard-claude-tls.exe +0 -0
- package/app/open-sse/identity/tls/bin/win32/x64/switchboard-claude-tls.exe +0 -0
- package/app/package.json +1 -1
- package/app/public/providers/api-airforce.png +0 -0
- package/app/public/providers/grok-cli.png +0 -0
- package/app/public/providers/muse.png +0 -0
- package/app/public/providers/ollama-search.png +0 -0
- package/app/public/providers/opencode-zen.png +0 -0
- package/app/public/providers/venice.png +0 -0
- package/app/public/providers/vercel-ai-gateway.png +0 -0
- package/package.json +1 -1
- package/app/.next/static/chunks/1321-76df19b6a38e6fa9.js +0 -1
- package/app/.next-cli-build/server/chunks/6074.js +0 -1
- package/app/.next-cli-build/static/chunks/1321-76df19b6a38e6fa9.js +0 -1
- /package/app/.next/static/{5WtWAuXu4p-ILkKMsJE4i → mIIf1bKJ8KlrHk03nHIsh}/_buildManifest.js +0 -0
- /package/app/.next/static/{5WtWAuXu4p-ILkKMsJE4i → mIIf1bKJ8KlrHk03nHIsh}/_ssgManifest.js +0 -0
- /package/app/.next-cli-build/static/{5WtWAuXu4p-ILkKMsJE4i → mIIf1bKJ8KlrHk03nHIsh}/_buildManifest.js +0 -0
- /package/app/.next-cli-build/static/{5WtWAuXu4p-ILkKMsJE4i → mIIf1bKJ8KlrHk03nHIsh}/_ssgManifest.js +0 -0
|
@@ -11,6 +11,6 @@ client = OpenAI(
|
|
|
11
11
|
-d '{
|
|
12
12
|
"model": "claude-sonnet-4-6",
|
|
13
13
|
"messages": [{"role": "user", "content": "Hello"}]
|
|
14
|
-
}'`;return(0,a.jsxs)(x.Zp,{children:[(0,a.jsx)("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-4 mb-4",children:(0,a.jsxs)("div",{children:[(0,a.jsxs)("h2",{className:"text-lg font-semibold flex items-center gap-2",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-primary",children:"hub"}),"Protocol & Tool Endpoints"]}),(0,a.jsx)("p",{className:"text-sm text-text-muted mt-1",children:"Every route and protocol exposed by Switchboard with format translation."})]})}),(0,a.jsx)("div",{className:"mb-6 overflow-x-auto pb-1",children:(0,a.jsx)(x.Iz,{options:g,value:n,onChange:r,size:"sm"})}),"snippets"===n?(0,a.jsxs)("div",{className:"flex flex-col gap-6",children:[(0,a.jsxs)("div",{className:"rounded-[10px] bg-surface-2 p-4 border border-border",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between mb-2",children:[(0,a.jsxs)("span",{className:"text-sm font-semibold flex items-center gap-2",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-primary text-[18px]",children:"terminal"}),"Claude Code CLI Environment"]}),(0,a.jsxs)("button",{type:"button",onClick:()=>s(d,"snippet_claude"),className:"p-1.5 hover:bg-surface rounded text-text-muted hover:text-primary transition-colors text-xs flex items-center gap-1 border border-border/50",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[16px]",children:"snippet_claude"===t?"check":"content_copy"}),"snippet_claude"===t?"Copied":"Copy"]})]}),(0,a.jsx)("pre",{className:"text-xs font-mono bg-black/5 dark:bg-black/40 p-3 rounded-[6px] overflow-x-auto text-text-main",children:d})]}),(0,a.jsxs)("div",{className:"rounded-[10px] bg-surface-2 p-4 border border-border",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between mb-2",children:[(0,a.jsxs)("span",{className:"text-sm font-semibold flex items-center gap-2",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-primary text-[18px]",children:"code"}),"OpenAI Python SDK"]}),(0,a.jsxs)("button",{type:"button",onClick:()=>s(c,"snippet_python"),className:"p-1.5 hover:bg-surface rounded text-text-muted hover:text-primary transition-colors text-xs flex items-center gap-1 border border-border/50",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[16px]",children:"snippet_python"===t?"check":"content_copy"}),"snippet_python"===t?"Copied":"Copy"]})]}),(0,a.jsx)("pre",{className:"text-xs font-mono bg-black/5 dark:bg-black/40 p-3 rounded-[6px] overflow-x-auto text-text-main",children:c})]}),(0,a.jsxs)("div",{className:"rounded-[10px] bg-surface-2 p-4 border border-border",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between mb-2",children:[(0,a.jsxs)("span",{className:"text-sm font-semibold flex items-center gap-2",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-primary text-[18px]",children:"send"}),"Direct cURL"]}),(0,a.jsxs)("button",{type:"button",onClick:()=>s(u,"snippet_curl"),className:"p-1.5 hover:bg-surface rounded text-text-muted hover:text-primary transition-colors text-xs flex items-center gap-1 border border-border/50",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[16px]",children:"snippet_curl"===t?"check":"content_copy"}),"snippet_curl"===t?"Copied":"Copy"]})]}),(0,a.jsx)("pre",{className:"text-xs font-mono bg-black/5 dark:bg-black/40 p-3 rounded-[6px] overflow-x-auto text-text-main",children:u})]})]}):(0,a.jsx)("div",{className:"flex flex-col divide-y divide-border/60",children:l.map(e=>{let i=`${o}${e.path}`;return(0,a.jsxs)("div",{className:"py-3.5 first:pt-0 last:pb-0 flex flex-col gap-2",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2 min-w-0",children:[(0,a.jsx)("span",{className:`text-[11px] font-mono font-semibold px-2 py-0.5 rounded border shrink-0 ${function(e){switch(e){case"POST":return"bg-teal-500/10 text-teal-600 dark:text-teal-400 border-teal-500/20";case"GET":return"bg-sky-500/10 text-sky-600 dark:text-sky-400 border-sky-500/20";default:return"bg-primary/10 text-primary border-primary/25"}}(e.method)}`,children:e.method}),(0,a.jsx)("span",{className:"text-sm font-medium truncate",children:e.label})]}),e.headerHint&&(0,a.jsx)("span",{className:"text-[11px] font-mono text-text-muted hidden md:inline truncate max-w-[280px]",children:e.headerHint})]}),(0,a.jsxs)("div",{className:"flex items-center gap-2 min-w-0",children:[(0,a.jsx)(x.pd,{value:i,readOnly:!0,className:"flex-1 min-w-0",inputClassName:"font-mono text-xs bg-surface-2"}),(0,a.jsx)("button",{type:"button",onClick:()=>s(i,e.id),className:"p-2 hover:bg-surface-2 rounded text-text-muted hover:text-primary transition-colors shrink-0 border border-transparent hover:border-border",title:"Copy URL","aria-label":`Copy ${e.label} URL`,children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px] leading-none",children:t===e.id?"check":"content_copy"})})]}),(0,a.jsx)("p",{className:"text-xs text-text-muted",children:e.desc})]},e.id)})})]})}function j({message:e,action:t}){return(0,a.jsxs)("div",{className:"flex items-center gap-2 px-3 py-2 rounded-lg bg-brand-500/10 border border-brand-500/30 text-brand-400",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[16px] shrink-0 leading-none",children:"warning"}),(0,a.jsx)("p",{className:"text-xs flex-1 text-brand-300",children:e}),t&&(0,a.jsx)("a",{href:t.href,className:"text-xs font-medium underline shrink-0 hover:opacity-80",onClick:t.href.startsWith("#")?e=>{e.preventDefault(),document.getElementById(t.href.slice(1))?.scrollIntoView({behavior:"smooth"})}:void 0,children:t.label})]})}function k(e){return String(e||"").split("\n").map(e=>e.trim()).filter(Boolean)}function N(e){if(""===e||null==e)return null;let t=Number(e);return Number.isFinite(t)?t:null}function C({apiKey:e,isOpen:t,isSaving:s,onClose:n,onSave:r}){let[o,l]=(0,i.useState)(""),[d,c]=(0,i.useState)(!0),[u,m]=(0,i.useState)(""),[h,p]=(0,i.useState)(""),[y,b]=(0,i.useState)(""),[f,g]=(0,i.useState)(""),[v,j]=(0,i.useState)(""),[w,S]=(0,i.useState)(""),[A,P]=(0,i.useState)(""),[O,T]=(0,i.useState)(!1);return(0,i.useEffect)(()=>{t&&e&&(l(e.name||""),c(!1!==e.isActive),m((e.allowedModels||[]).join("\n")),p((e.allowedCombos||[]).join("\n")),b(function(e){if(!e)return"";let t=new Date(e);return Number.isNaN(t.getTime())?"":new Date(t.getTime()-6e4*t.getTimezoneOffset()).toISOString().slice(0,16)}(e.expiresAt)),g(e.rateLimitPerMinute??""),j(e.concurrencyLimit??""),S(e.spendLimitUsd??""),P(e.tokenLimit??""),T(!1))},[e,t]),(0,a.jsx)(x.aF,{isOpen:t,onClose:n,title:"Edit API Key Policy",size:"lg",children:(0,a.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,a.jsx)(x.pd,{label:"Key name",value:o,onChange:e=>l(e.target.value)}),(0,a.jsxs)("div",{className:"flex items-center justify-between rounded-lg border border-border p-3",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("p",{className:"text-sm font-medium",children:"Active"}),(0,a.jsx)("p",{className:"text-xs text-text-muted",children:"Paused keys cannot authenticate."})]}),(0,a.jsx)(x.lM,{checked:d,onChange:c})]}),(0,a.jsxs)("label",{className:"flex flex-col gap-1.5 text-sm font-medium",children:["Allowed model IDs",(0,a.jsx)("textarea",{className:"min-h-24 rounded-lg border border-border bg-surface-2 p-3 font-mono text-sm",value:u,onChange:e=>m(e.target.value),placeholder:"openai/gpt-5\noc/*\n*claude*\n!opus"}),(0,a.jsx)("span",{className:"text-xs font-normal text-text-muted",children:"One entry per line, matched on resolved identities. Wildcards (oc/*, *claude*, *) and deny entries (!opus, -haiku) are supported; a deny-only list allows everything except the denied. Empty allows all targets."})]}),(0,a.jsxs)("label",{className:"flex flex-col gap-1.5 text-sm font-medium",children:["Allowed combo names",(0,a.jsx)("textarea",{className:"min-h-20 rounded-lg border border-border bg-surface-2 p-3 font-mono text-sm",value:h,onChange:e=>p(e.target.value),placeholder:"fast\\nquality"}),(0,a.jsx)("span",{className:"text-xs font-normal text-text-muted",children:"One combo name per line (exact match)."})]}),(0,a.jsx)(x.pd,{label:"Expires at",type:"datetime-local",value:y,onChange:e=>b(e.target.value)}),(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-3",children:[(0,a.jsx)(x.pd,{label:"Requests / minute",type:"number",min:"1",step:"1",value:f,onChange:e=>g(e.target.value)}),(0,a.jsx)(x.pd,{label:"Concurrent requests",type:"number",min:"1",step:"1",value:v,onChange:e=>j(e.target.value)}),(0,a.jsx)(x.pd,{label:"Spend ceiling (USD)",type:"number",min:"0",step:"0.01",value:w,onChange:e=>S(e.target.value)})]}),(0,a.jsx)(x.pd,{label:"Token limit",type:"number",min:"0",step:"1",value:A,onChange:e=>P(e.target.value),placeholder:"Unlimited"}),(0,a.jsxs)("div",{className:"flex items-center justify-between rounded-lg border border-border p-3",children:[(0,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsx)("p",{className:"text-sm font-medium",children:"Token usage"}),(0,a.jsx)("p",{className:"text-xs text-text-muted",children:e?.tokenLimit>0?`${Number(e.usedTokens||0).toLocaleString()} / ${Number(e.tokenLimit).toLocaleString()} tokens (${Math.min(100,Math.round(Number(e.usedTokens||0)/e.tokenLimit*100))}%)`:`${Number(e.usedTokens||0).toLocaleString()} tokens used (no limit)`})]}),(0,a.jsx)(x.lM,{checked:O,onChange:T,title:"Reset the used-token counter to 0 on save"}),(0,a.jsx)("span",{className:"ml-3 whitespace-nowrap text-xs text-text-muted",children:"Reset counter"})]}),(0,a.jsxs)("p",{className:"text-sm text-text-muted",children:["Current spend: ",(0,a.jsxs)("span",{className:"font-mono text-text-main",children:["$",Number(e?.spentUsd||0).toFixed(4)]})]}),(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsx)(x.$n,{fullWidth:!0,loading:s,disabled:s||!o.trim(),onClick:()=>r({name:o,isActive:d,allowedModels:k(u),allowedCombos:k(h),expiresAt:y?new Date(y).toISOString():null,rateLimitPerMinute:N(f),concurrencyLimit:N(v),spendLimitUsd:N(w),tokenLimit:N(A),...O?{usedTokens:0}:{}}),children:"Save policy"}),(0,a.jsx)(x.$n,{fullWidth:!0,variant:"ghost",disabled:s,onClick:n,children:"Cancel"})]})]})})}v.propTypes={origin:r().string.isRequired,copied:r().string,onCopy:r().func.isRequired},C.propTypes={apiKey:r().object,isOpen:r().bool.isRequired,isSaving:r().bool.isRequired,onClose:r().func.isRequired,onSave:r().func.isRequired};let w=()=>["endpoint","keys"],S=()=>["endpoint","settings"];var A=s(48874),P=s(65921);function O(e){let t=Number(e||0);return t>=1e9?`${(t/1e9).toFixed(1)}B`:t>=1e6?`${(t/1e6).toFixed(1)}M`:t>=1e3?`${(t/1e3).toFixed(1)}k`:String(t)}function T(e){if(!e.tokenLimit||e.tokenLimit<=0)return Number(e.usedTokens||0)>0?{label:`${O(e.usedTokens)} tokens`,tone:"muted",percent:null}:null;let t=Number(e.usedTokens||0),s=Math.min(100,Math.round(t/e.tokenLimit*100)),a=t>=e.tokenLimit;return{label:`${O(t)} / ${O(e.tokenLimit)} tokens${a?" — limit reached":` (${s}%)`}`,tone:a?"danger":s>80?"warn":"muted",percent:s,exhausted:a}}function I({initialData:e}){let t=(0,o.jE)(),s=e?.machineId||"",n=(0,P.i)(e=>e.error),r=(0,l.I)({queryKey:w(),queryFn:async()=>{let e=async()=>(await (0,A.x)("/api/keys")).keys||[],t=await e();if(0===t.length){try{await (0,A.x)("/api/keys",{method:"POST",body:JSON.stringify({name:"Default Key",findOrCreate:!0})})}catch{}try{t=await e()}catch{}}return t},initialData:e?.keys||[]}),d=(0,l.I)({queryKey:S(),queryFn:()=>(0,A.x)("/api/settings"),initialData:e?.settings||{}}),c=r.data||[],u=d.data?.requireApiKey===!0,[m,h]=(0,i.useState)(!1),[f,g]=(0,i.useState)(""),[k,N]=(0,i.useState)(""),[O,R]=(0,i.useState)(null),[_,L]=(0,i.useState)(null),[E,M]=(0,i.useState)(null),[$,K]=(0,i.useState)("/v1"),[q,F]=(0,i.useState)("http://127.0.0.1:20128");(0,i.useEffect)(()=>{K(`${window.location.origin}/v1`),F(window.location.origin)},[]);let{copied:U,copy:D}=(0,y.C)(),H=p({mutationFn:e=>(0,A.x)("/api/settings",{method:"PATCH",body:JSON.stringify({requireApiKey:e})}),onSuccess:()=>{t.invalidateQueries({queryKey:S()})},onError:()=>n("Failed to update API key requirement")}),G=p({mutationFn:({name:e,tokenLimit:t})=>(0,A.x)("/api/keys",{method:"POST",body:JSON.stringify({name:e,...null!=t?{tokenLimit:t}:{}})}),onSuccess:e=>{R(e.key||null),g(""),N(""),h(!1),t.invalidateQueries({queryKey:w()})},onError:()=>n("Failed to create API key")}),B=p({mutationFn:e=>(0,A.x)(`/api/keys/${e}`,{method:"DELETE"}),onSuccess:()=>{t.invalidateQueries({queryKey:w()})},onError:()=>n("Failed to delete API key")}),z=p({mutationFn:({id:e,isActive:t})=>(0,A.x)(`/api/keys/${e}`,{method:"PUT",body:JSON.stringify({isActive:t})}),onSuccess:()=>{t.invalidateQueries({queryKey:w()})},onError:()=>n("Failed to toggle API key")}),Q=p({mutationFn:({id:e,patch:t})=>(0,A.x)(`/api/keys/${e}`,{method:"PUT",body:JSON.stringify(t)}),onSuccess:()=>{M(null),t.invalidateQueries({queryKey:w()})},onError:()=>n("Failed to update API key policy")});return(0,a.jsxs)("div",{className:"flex flex-col gap-8",children:[(0,a.jsxs)(x.Zp,{children:[(0,a.jsxs)("h2",{className:"text-lg font-semibold mb-4 flex items-center gap-2",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-primary",children:"api"}),"API Endpoint"]}),(0,a.jsx)("p",{className:"text-sm text-text-muted mb-4",children:"Local OpenAI-compatible base URL for coding agents and SDKs. Switchboard is local-only — no tunnels or remote exposure."}),(0,a.jsx)(b,{label:"Local",url:$,copyId:"local_url",copied:U,onCopy:D}),s?(0,a.jsxs)("p",{className:"mt-3 text-xs text-text-muted font-mono",children:["Machine: ",s]}):null]}),(0,a.jsx)(v,{origin:q,copied:U,onCopy:D}),(0,a.jsxs)(x.Zp,{id:"require-api-key",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between mb-4",children:[(0,a.jsxs)("h2",{className:"text-lg font-semibold flex items-center gap-2",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-primary",children:"vpn_key"}),"API Keys"]}),(0,a.jsx)(x.$n,{icon:"add",onClick:()=>h(!0),children:"Create Key"})]}),(0,a.jsxs)("div",{className:"flex items-center justify-between pb-4 mb-4 border-b border-border",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("p",{className:"font-medium",children:"Require API key"}),(0,a.jsx)("p",{className:"text-sm text-text-muted",children:"Requests without a valid key will be rejected"})]}),(0,a.jsx)(x.lM,{checked:u,onChange:()=>{u?L({title:"Disable API key protection?",message:"Any client that can reach this Switchboard endpoint will be able to use your provider accounts.",onConfirm:()=>{L(null),H.mutate(!1)}}):H.mutate(!0)},"aria-label":"Require API key"})]}),!u&&(0,a.jsx)("div",{className:"mb-4 -mt-2",children:(0,a.jsx)(j,{message:"API key is not required — any local client can call /v1."})}),0===c.length?(0,a.jsxs)("div",{className:"text-center py-12",children:[(0,a.jsx)("div",{className:"inline-flex items-center justify-center w-16 h-16 rounded-full bg-primary/10 text-primary mb-4",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[32px]",children:"vpn_key"})}),(0,a.jsx)("p",{className:"text-text-main font-medium mb-1",children:"No API keys yet"}),(0,a.jsx)("p",{className:"text-sm text-text-muted mb-4",children:"Create your first API key to get started"}),(0,a.jsx)(x.$n,{icon:"add",onClick:()=>h(!0),children:"Create Key"})]}):(0,a.jsx)("div",{className:"flex flex-col",children:c.map(e=>{let t,s,i=e.name?.trim()||e.id;return(0,a.jsxs)("div",{className:`group flex items-center justify-between py-3 border-b border-black/[0.03] dark:border-white/[0.03] last:border-b-0 ${!1===e.isActive?"opacity-60":""}`,children:[(0,a.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,a.jsx)("p",{className:"text-sm font-medium",children:e.name}),(0,a.jsxs)("div",{className:"flex flex-wrap items-center gap-2 mt-1",children:[(0,a.jsx)("code",{className:"text-xs text-text-muted font-mono",children:e.keyPrefix}),e.rotationRequired?(0,a.jsx)("span",{className:"rounded-full bg-orange-500/10 px-2 py-0.5 text-[11px] text-orange-600",title:"This legacy key remains usable through its compatibility verifier until you create a replacement.",children:"Rotation required"}):null,e.allowedModels?.length||e.allowedCombos?.length?(0,a.jsx)("span",{className:"rounded-full bg-primary/10 px-2 py-0.5 text-[11px] text-primary",children:"Restricted targets"}):(0,a.jsx)("span",{className:"rounded-full bg-black/5 px-2 py-0.5 text-[11px] text-text-muted dark:bg-white/5",children:"All targets"}),e.rateLimitPerMinute?(0,a.jsxs)("span",{className:"rounded-full bg-black/5 px-2 py-0.5 text-[11px] text-text-muted dark:bg-white/5",children:[e.rateLimitPerMinute,"/min"]}):null,e.concurrencyLimit?(0,a.jsxs)("span",{className:"rounded-full bg-black/5 px-2 py-0.5 text-[11px] text-text-muted dark:bg-white/5",children:[e.concurrencyLimit," concurrent"]}):null,null!=e.spendLimitUsd?(0,a.jsxs)("span",{className:"rounded-full bg-black/5 px-2 py-0.5 text-[11px] text-text-muted dark:bg-white/5",children:["$",Number(e.spentUsd||0).toFixed(2)," / $",Number(e.spendLimitUsd).toFixed(2)]}):null,(t=T(e))?(0,a.jsx)("span",{className:`rounded-full px-2 py-0.5 text-[11px] ${"danger"===t.tone?"bg-red-500/10 text-red-600":"warn"===t.tone?"bg-orange-500/10 text-orange-600":"bg-black/5 text-text-muted dark:bg-white/5"}`,children:t.label}):null]}),e.tokenLimit>0&&(s=T(e),s?.percent!=null?(0,a.jsx)("div",{className:"mt-2 h-1.5 w-full max-w-64 overflow-hidden rounded-full bg-black/5 dark:bg-white/10",role:"progressbar","aria-label":"Token quota usage","aria-valuenow":s.percent,"aria-valuemin":0,"aria-valuemax":100,children:(0,a.jsx)("div",{className:`h-full rounded-full transition-all ${s.exhausted?"bg-red-500":s.percent>80?"bg-orange-500":"bg-primary"}`,style:{width:`${s.percent}%`}})}):null),(0,a.jsxs)("p",{className:"text-xs text-text-muted mt-1",children:["Created ",new Date(e.createdAt).toLocaleDateString()]}),!1===e.isActive&&(0,a.jsx)("p",{className:"text-xs text-orange-500 mt-1",children:"Paused"})]}),(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)(x.lM,{size:"sm",checked:e.isActive??!0,onChange:t=>{e.isActive&&!t?L({title:"Pause API Key",message:`Pause API key "${i}"?
|
|
14
|
+
}'`;return(0,a.jsxs)(x.Zp,{children:[(0,a.jsx)("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-4 mb-4",children:(0,a.jsxs)("div",{children:[(0,a.jsxs)("h2",{className:"text-lg font-semibold flex items-center gap-2",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-primary",children:"hub"}),"Protocol & Tool Endpoints"]}),(0,a.jsx)("p",{className:"text-sm text-text-muted mt-1",children:"Every route and protocol exposed by Switchboard with format translation."})]})}),(0,a.jsx)("div",{className:"mb-6 overflow-x-auto pb-1",children:(0,a.jsx)(x.Iz,{options:g,value:n,onChange:r,size:"sm"})}),"snippets"===n?(0,a.jsxs)("div",{className:"flex flex-col gap-6",children:[(0,a.jsxs)("div",{className:"rounded-[10px] bg-surface-2 p-4 border border-border",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between mb-2",children:[(0,a.jsxs)("span",{className:"text-sm font-semibold flex items-center gap-2",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-primary text-[18px]",children:"terminal"}),"Claude Code CLI Environment"]}),(0,a.jsxs)("button",{type:"button",onClick:()=>s(d,"snippet_claude"),className:"p-1.5 hover:bg-surface rounded text-text-muted hover:text-primary transition-colors text-xs flex items-center gap-1 border border-border/50",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[16px]",children:"snippet_claude"===t?"check":"content_copy"}),"snippet_claude"===t?"Copied":"Copy"]})]}),(0,a.jsx)("pre",{className:"text-xs font-mono bg-black/5 dark:bg-black/40 p-3 rounded-[6px] overflow-x-auto text-text-main",children:d})]}),(0,a.jsxs)("div",{className:"rounded-[10px] bg-surface-2 p-4 border border-border",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between mb-2",children:[(0,a.jsxs)("span",{className:"text-sm font-semibold flex items-center gap-2",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-primary text-[18px]",children:"code"}),"OpenAI Python SDK"]}),(0,a.jsxs)("button",{type:"button",onClick:()=>s(c,"snippet_python"),className:"p-1.5 hover:bg-surface rounded text-text-muted hover:text-primary transition-colors text-xs flex items-center gap-1 border border-border/50",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[16px]",children:"snippet_python"===t?"check":"content_copy"}),"snippet_python"===t?"Copied":"Copy"]})]}),(0,a.jsx)("pre",{className:"text-xs font-mono bg-black/5 dark:bg-black/40 p-3 rounded-[6px] overflow-x-auto text-text-main",children:c})]}),(0,a.jsxs)("div",{className:"rounded-[10px] bg-surface-2 p-4 border border-border",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between mb-2",children:[(0,a.jsxs)("span",{className:"text-sm font-semibold flex items-center gap-2",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-primary text-[18px]",children:"send"}),"Direct cURL"]}),(0,a.jsxs)("button",{type:"button",onClick:()=>s(u,"snippet_curl"),className:"p-1.5 hover:bg-surface rounded text-text-muted hover:text-primary transition-colors text-xs flex items-center gap-1 border border-border/50",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[16px]",children:"snippet_curl"===t?"check":"content_copy"}),"snippet_curl"===t?"Copied":"Copy"]})]}),(0,a.jsx)("pre",{className:"text-xs font-mono bg-black/5 dark:bg-black/40 p-3 rounded-[6px] overflow-x-auto text-text-main",children:u})]})]}):(0,a.jsx)("div",{className:"flex flex-col divide-y divide-border/60",children:l.map(e=>{let i=`${o}${e.path}`;return(0,a.jsxs)("div",{className:"py-3.5 first:pt-0 last:pb-0 flex flex-col gap-2",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2 min-w-0",children:[(0,a.jsx)("span",{className:`text-[11px] font-mono font-semibold px-2 py-0.5 rounded border shrink-0 ${function(e){switch(e){case"POST":return"bg-teal-500/10 text-teal-600 dark:text-teal-400 border-teal-500/20";case"GET":return"bg-sky-500/10 text-sky-600 dark:text-sky-400 border-sky-500/20";default:return"bg-primary/10 text-primary border-primary/25"}}(e.method)}`,children:e.method}),(0,a.jsx)("span",{className:"text-sm font-medium truncate",children:e.label})]}),e.headerHint&&(0,a.jsx)("span",{className:"text-[11px] font-mono text-text-muted hidden md:inline truncate max-w-[280px]",children:e.headerHint})]}),(0,a.jsxs)("div",{className:"flex items-center gap-2 min-w-0",children:[(0,a.jsx)(x.pd,{value:i,readOnly:!0,className:"flex-1 min-w-0",inputClassName:"font-mono text-xs bg-surface-2"}),(0,a.jsx)("button",{type:"button",onClick:()=>s(i,e.id),className:"p-2 hover:bg-surface-2 rounded text-text-muted hover:text-primary transition-colors shrink-0 border border-transparent hover:border-border",title:"Copy URL","aria-label":`Copy ${e.label} URL`,children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px] leading-none",children:t===e.id?"check":"content_copy"})})]}),(0,a.jsx)("p",{className:"text-xs text-text-muted",children:e.desc})]},e.id)})})]})}function j({message:e,action:t}){return(0,a.jsxs)("div",{className:"flex items-center gap-2 px-3 py-2 rounded-lg bg-brand-500/10 border border-brand-500/30 text-brand-400",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[16px] shrink-0 leading-none",children:"warning"}),(0,a.jsx)("p",{className:"text-xs flex-1 text-brand-300",children:e}),t&&(0,a.jsx)("a",{href:t.href,className:"text-xs font-medium underline shrink-0 hover:opacity-80",onClick:t.href.startsWith("#")?e=>{e.preventDefault(),document.getElementById(t.href.slice(1))?.scrollIntoView({behavior:"smooth"})}:void 0,children:t.label})]})}function k(e){return String(e||"").split("\n").map(e=>e.trim()).filter(Boolean)}function N(e){if(""===e||null==e)return null;let t=Number(e);return Number.isFinite(t)?t:null}function C({apiKey:e,isOpen:t,isSaving:s,onClose:n,onSave:r}){let[o,l]=(0,i.useState)(""),[d,c]=(0,i.useState)(!0),[u,m]=(0,i.useState)(""),[h,p]=(0,i.useState)(""),[y,b]=(0,i.useState)(""),[f,g]=(0,i.useState)(""),[v,j]=(0,i.useState)(""),[w,S]=(0,i.useState)(""),[A,P]=(0,i.useState)(""),[O,T]=(0,i.useState)(!1);return(0,i.useEffect)(()=>{t&&e&&(l(e.name||""),c(!1!==e.isActive),m((e.allowedModels||[]).join("\n")),p((e.allowedCombos||[]).join("\n")),b(function(e){if(!e)return"";let t=new Date(e);return Number.isNaN(t.getTime())?"":new Date(t.getTime()-6e4*t.getTimezoneOffset()).toISOString().slice(0,16)}(e.expiresAt)),g(e.rateLimitPerMinute??""),j(e.concurrencyLimit??""),S(e.spendLimitUsd??""),P(e.tokenLimit??""),T(!1))},[e,t]),(0,a.jsx)(x.aF,{isOpen:t,onClose:n,title:"Edit API Key Policy",size:"lg",children:(0,a.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,a.jsx)(x.pd,{label:"Key name",value:o,onChange:e=>l(e.target.value)}),(0,a.jsxs)("div",{className:"flex items-center justify-between rounded-lg border border-border p-3",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("p",{className:"text-sm font-medium",children:"Active"}),(0,a.jsx)("p",{className:"text-xs text-text-muted",children:"Paused keys cannot authenticate."})]}),(0,a.jsx)(x.lM,{checked:d,onChange:c})]}),(0,a.jsxs)("label",{className:"flex flex-col gap-1.5 text-sm font-medium",children:["Allowed model IDs",(0,a.jsx)("textarea",{className:"min-h-24 rounded-lg border border-border bg-surface-2 p-3 font-mono text-sm",value:u,onChange:e=>m(e.target.value),placeholder:"openai/gpt-5\noc/*\n*claude*\n!opus"}),(0,a.jsx)("span",{className:"text-xs font-normal text-text-muted",children:"One entry per line, matched on resolved identities. Wildcards (oc/*, *claude*, *) and deny entries (!opus, -haiku) are supported; a deny-only list allows everything except the denied. Empty allows all targets."})]}),(0,a.jsxs)("label",{className:"flex flex-col gap-1.5 text-sm font-medium",children:["Allowed combo names",(0,a.jsx)("textarea",{className:"min-h-20 rounded-lg border border-border bg-surface-2 p-3 font-mono text-sm",value:h,onChange:e=>p(e.target.value),placeholder:"fast\\nquality"}),(0,a.jsx)("span",{className:"text-xs font-normal text-text-muted",children:"One combo name per line (exact match)."})]}),(0,a.jsx)(x.pd,{label:"Expires at",type:"datetime-local",value:y,onChange:e=>b(e.target.value)}),(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-3",children:[(0,a.jsx)(x.pd,{label:"Requests / minute",type:"number",min:"1",step:"1",value:f,onChange:e=>g(e.target.value)}),(0,a.jsx)(x.pd,{label:"Concurrent requests",type:"number",min:"1",step:"1",value:v,onChange:e=>j(e.target.value)}),(0,a.jsx)(x.pd,{label:"Spend ceiling (USD)",type:"number",min:"0",step:"0.01",value:w,onChange:e=>S(e.target.value)})]}),(0,a.jsx)(x.pd,{label:"Token limit",type:"number",min:"0",step:"1",value:A,onChange:e=>P(e.target.value),placeholder:"Unlimited"}),(0,a.jsxs)("div",{className:"flex items-center justify-between rounded-lg border border-border p-3",children:[(0,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsx)("p",{className:"text-sm font-medium",children:"Token usage"}),(0,a.jsx)("p",{className:"text-xs text-text-muted",children:e?.tokenLimit>0?`${Number(e.usedTokens||0).toLocaleString()} / ${Number(e.tokenLimit).toLocaleString()} tokens (${Math.min(100,Math.round(Number(e.usedTokens||0)/e.tokenLimit*100))}%)`:`${Number(e?.usedTokens||0).toLocaleString()} tokens used (no limit)`})]}),(0,a.jsx)(x.lM,{checked:O,onChange:T,title:"Reset the used-token counter to 0 on save"}),(0,a.jsx)("span",{className:"ml-3 whitespace-nowrap text-xs text-text-muted",children:"Reset counter"})]}),(0,a.jsxs)("p",{className:"text-sm text-text-muted",children:["Current spend: ",(0,a.jsxs)("span",{className:"font-mono text-text-main",children:["$",Number(e?.spentUsd||0).toFixed(4)]})]}),(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsx)(x.$n,{fullWidth:!0,loading:s,disabled:s||!o.trim(),onClick:()=>r({name:o,isActive:d,allowedModels:k(u),allowedCombos:k(h),expiresAt:y?new Date(y).toISOString():null,rateLimitPerMinute:N(f),concurrencyLimit:N(v),spendLimitUsd:N(w),tokenLimit:N(A),...O?{usedTokens:0}:{}}),children:"Save policy"}),(0,a.jsx)(x.$n,{fullWidth:!0,variant:"ghost",disabled:s,onClick:n,children:"Cancel"})]})]})})}v.propTypes={origin:r().string.isRequired,copied:r().string,onCopy:r().func.isRequired},C.propTypes={apiKey:r().object,isOpen:r().bool.isRequired,isSaving:r().bool.isRequired,onClose:r().func.isRequired,onSave:r().func.isRequired};let w=()=>["endpoint","keys"],S=()=>["endpoint","settings"];var A=s(48874),P=s(65921);function O(e){let t=Number(e||0);return t>=1e9?`${(t/1e9).toFixed(1)}B`:t>=1e6?`${(t/1e6).toFixed(1)}M`:t>=1e3?`${(t/1e3).toFixed(1)}k`:String(t)}function T(e){if(!e.tokenLimit||e.tokenLimit<=0)return Number(e.usedTokens||0)>0?{label:`${O(e.usedTokens)} tokens`,tone:"muted",percent:null}:null;let t=Number(e.usedTokens||0),s=Math.min(100,Math.round(t/e.tokenLimit*100)),a=t>=e.tokenLimit;return{label:`${O(t)} / ${O(e.tokenLimit)} tokens${a?" — limit reached":` (${s}%)`}`,tone:a?"danger":s>80?"warn":"muted",percent:s,exhausted:a}}function I({initialData:e}){let t=(0,o.jE)(),s=e?.machineId||"",n=(0,P.i)(e=>e.error),r=(0,l.I)({queryKey:w(),queryFn:async()=>{let e=async()=>(await (0,A.x)("/api/keys")).keys||[],t=await e();if(0===t.length){try{await (0,A.x)("/api/keys",{method:"POST",body:JSON.stringify({name:"Default Key",findOrCreate:!0})})}catch{}try{t=await e()}catch{}}return t},initialData:e?.keys||[]}),d=(0,l.I)({queryKey:S(),queryFn:()=>(0,A.x)("/api/settings"),initialData:e?.settings||{}}),c=r.data||[],u=d.data?.requireApiKey===!0,[m,h]=(0,i.useState)(!1),[f,g]=(0,i.useState)(""),[k,N]=(0,i.useState)(""),[O,R]=(0,i.useState)(null),[_,L]=(0,i.useState)(null),[E,M]=(0,i.useState)(null),[$,K]=(0,i.useState)("/v1"),[q,F]=(0,i.useState)("http://127.0.0.1:20128");(0,i.useEffect)(()=>{K(`${window.location.origin}/v1`),F(window.location.origin)},[]);let{copied:U,copy:D}=(0,y.C)(),H=p({mutationFn:e=>(0,A.x)("/api/settings",{method:"PATCH",body:JSON.stringify({requireApiKey:e})}),onSuccess:()=>{t.invalidateQueries({queryKey:S()})},onError:()=>n("Failed to update API key requirement")}),G=p({mutationFn:({name:e,tokenLimit:t})=>(0,A.x)("/api/keys",{method:"POST",body:JSON.stringify({name:e,...null!=t?{tokenLimit:t}:{}})}),onSuccess:e=>{R(e.key||null),g(""),N(""),h(!1),t.invalidateQueries({queryKey:w()})},onError:()=>n("Failed to create API key")}),B=p({mutationFn:e=>(0,A.x)(`/api/keys/${e}`,{method:"DELETE"}),onSuccess:()=>{t.invalidateQueries({queryKey:w()})},onError:()=>n("Failed to delete API key")}),z=p({mutationFn:({id:e,isActive:t})=>(0,A.x)(`/api/keys/${e}`,{method:"PUT",body:JSON.stringify({isActive:t})}),onSuccess:()=>{t.invalidateQueries({queryKey:w()})},onError:()=>n("Failed to toggle API key")}),Q=p({mutationFn:({id:e,patch:t})=>(0,A.x)(`/api/keys/${e}`,{method:"PUT",body:JSON.stringify(t)}),onSuccess:()=>{M(null),t.invalidateQueries({queryKey:w()})},onError:()=>n("Failed to update API key policy")});return(0,a.jsxs)("div",{className:"flex flex-col gap-8",children:[(0,a.jsxs)(x.Zp,{children:[(0,a.jsxs)("h2",{className:"text-lg font-semibold mb-4 flex items-center gap-2",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-primary",children:"api"}),"API Endpoint"]}),(0,a.jsx)("p",{className:"text-sm text-text-muted mb-4",children:"Local OpenAI-compatible base URL for coding agents and SDKs. Switchboard is local-only — no tunnels or remote exposure."}),(0,a.jsx)(b,{label:"Local",url:$,copyId:"local_url",copied:U,onCopy:D}),s?(0,a.jsxs)("p",{className:"mt-3 text-xs text-text-muted font-mono",children:["Machine: ",s]}):null]}),(0,a.jsx)(v,{origin:q,copied:U,onCopy:D}),(0,a.jsxs)(x.Zp,{id:"require-api-key",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between mb-4",children:[(0,a.jsxs)("h2",{className:"text-lg font-semibold flex items-center gap-2",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-primary",children:"vpn_key"}),"API Keys"]}),(0,a.jsx)(x.$n,{icon:"add",onClick:()=>h(!0),children:"Create Key"})]}),(0,a.jsxs)("div",{className:"flex items-center justify-between pb-4 mb-4 border-b border-border",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("p",{className:"font-medium",children:"Require API key"}),(0,a.jsx)("p",{className:"text-sm text-text-muted",children:"Requests without a valid key will be rejected"})]}),(0,a.jsx)(x.lM,{checked:u,onChange:()=>{u?L({title:"Disable API key protection?",message:"Any client that can reach this Switchboard endpoint will be able to use your provider accounts.",onConfirm:()=>{L(null),H.mutate(!1)}}):H.mutate(!0)},"aria-label":"Require API key"})]}),!u&&(0,a.jsx)("div",{className:"mb-4 -mt-2",children:(0,a.jsx)(j,{message:"API key is not required — any local client can call /v1."})}),0===c.length?(0,a.jsxs)("div",{className:"text-center py-12",children:[(0,a.jsx)("div",{className:"inline-flex items-center justify-center w-16 h-16 rounded-full bg-primary/10 text-primary mb-4",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[32px]",children:"vpn_key"})}),(0,a.jsx)("p",{className:"text-text-main font-medium mb-1",children:"No API keys yet"}),(0,a.jsx)("p",{className:"text-sm text-text-muted mb-4",children:"Create your first API key to get started"}),(0,a.jsx)(x.$n,{icon:"add",onClick:()=>h(!0),children:"Create Key"})]}):(0,a.jsx)("div",{className:"flex flex-col",children:c.map(e=>{let t,s,i=e.name?.trim()||e.id;return(0,a.jsxs)("div",{className:`group flex items-center justify-between py-3 border-b border-black/[0.03] dark:border-white/[0.03] last:border-b-0 ${!1===e.isActive?"opacity-60":""}`,children:[(0,a.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,a.jsx)("p",{className:"text-sm font-medium",children:e.name}),(0,a.jsxs)("div",{className:"flex flex-wrap items-center gap-2 mt-1",children:[(0,a.jsx)("code",{className:"text-xs text-text-muted font-mono",children:e.keyPrefix}),e.rotationRequired?(0,a.jsx)("span",{className:"rounded-full bg-orange-500/10 px-2 py-0.5 text-[11px] text-orange-600",title:"This legacy key remains usable through its compatibility verifier until you create a replacement.",children:"Rotation required"}):null,e.allowedModels?.length||e.allowedCombos?.length?(0,a.jsx)("span",{className:"rounded-full bg-primary/10 px-2 py-0.5 text-[11px] text-primary",children:"Restricted targets"}):(0,a.jsx)("span",{className:"rounded-full bg-black/5 px-2 py-0.5 text-[11px] text-text-muted dark:bg-white/5",children:"All targets"}),e.rateLimitPerMinute?(0,a.jsxs)("span",{className:"rounded-full bg-black/5 px-2 py-0.5 text-[11px] text-text-muted dark:bg-white/5",children:[e.rateLimitPerMinute,"/min"]}):null,e.concurrencyLimit?(0,a.jsxs)("span",{className:"rounded-full bg-black/5 px-2 py-0.5 text-[11px] text-text-muted dark:bg-white/5",children:[e.concurrencyLimit," concurrent"]}):null,null!=e.spendLimitUsd?(0,a.jsxs)("span",{className:"rounded-full bg-black/5 px-2 py-0.5 text-[11px] text-text-muted dark:bg-white/5",children:["$",Number(e.spentUsd||0).toFixed(2)," / $",Number(e.spendLimitUsd).toFixed(2)]}):null,(t=T(e))?(0,a.jsx)("span",{className:`rounded-full px-2 py-0.5 text-[11px] ${"danger"===t.tone?"bg-red-500/10 text-red-600":"warn"===t.tone?"bg-orange-500/10 text-orange-600":"bg-black/5 text-text-muted dark:bg-white/5"}`,children:t.label}):null]}),e.tokenLimit>0&&(s=T(e),s?.percent!=null?(0,a.jsx)("div",{className:"mt-2 h-1.5 w-full max-w-64 overflow-hidden rounded-full bg-black/5 dark:bg-white/10",role:"progressbar","aria-label":"Token quota usage","aria-valuenow":s.percent,"aria-valuemin":0,"aria-valuemax":100,children:(0,a.jsx)("div",{className:`h-full rounded-full transition-all ${s.exhausted?"bg-red-500":s.percent>80?"bg-orange-500":"bg-primary"}`,style:{width:`${s.percent}%`}})}):null),(0,a.jsxs)("p",{className:"text-xs text-text-muted mt-1",children:["Created ",new Date(e.createdAt).toLocaleDateString()]}),!1===e.isActive&&(0,a.jsx)("p",{className:"text-xs text-orange-500 mt-1",children:"Paused"})]}),(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)(x.lM,{size:"sm",checked:e.isActive??!0,onChange:t=>{e.isActive&&!t?L({title:"Pause API Key",message:`Pause API key "${i}"?
|
|
15
15
|
|
|
16
16
|
This key will stop working immediately but can be resumed later.`,onConfirm:async()=>{L(null),z.mutate({id:e.id,isActive:t})}}):z.mutate({id:e.id,isActive:t})},title:e.isActive?"Pause key":"Resume key","aria-label":e.isActive?`Pause API key ${i}`:`Resume API key ${i}`}),(0,a.jsx)("button",{type:"button",onClick:()=>M(e),className:"p-2 hover:bg-primary/10 rounded text-text-muted hover:text-primary opacity-100 sm:opacity-0 sm:group-hover:opacity-100 transition-all",title:"Edit key policy","aria-label":`Edit API key ${i} policy`,children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:"edit"})}),(0,a.jsx)("button",{type:"button",onClick:()=>L({title:"Delete API Key",message:`Delete API key "${i}"?`,onConfirm:async()=>{L(null),B.mutate(e.id)}}),className:"p-2 hover:bg-red-500/10 rounded text-red-500 opacity-100 sm:opacity-0 sm:group-hover:opacity-100 transition-all","aria-label":`Delete API key ${i}`,children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:"delete"})})]})]},e.id)})})]}),(0,a.jsx)(x.aF,{isOpen:m,title:"Create API Key",onClose:()=>{h(!1),g("")},children:(0,a.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,a.jsx)(x.pd,{label:"Key Name",value:f,onChange:e=>g(e.target.value),placeholder:"Production Key"}),(0,a.jsx)(x.pd,{label:"Token limit (optional)",type:"number",min:"0",step:"1",value:k,onChange:e=>N(e.target.value),placeholder:"Unlimited"}),(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsx)(x.$n,{onClick:()=>G.mutate({name:f.trim(),tokenLimit:""===k?null:Math.max(0,parseInt(k,10)||0)}),fullWidth:!0,disabled:!f.trim()||G.isPending,loading:G.isPending,children:"Create"}),(0,a.jsx)(x.$n,{onClick:()=>{h(!1),g(""),N("")},variant:"ghost",fullWidth:!0,children:"Cancel"})]})]})}),(0,a.jsx)(x.aF,{isOpen:!!O,title:"API Key Created",onClose:()=>R(null),children:(0,a.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,a.jsxs)("div",{className:"bg-yellow-50 dark:bg-yellow-900/20 border border-yellow-200 dark:border-yellow-800 rounded-lg p-4",children:[(0,a.jsx)("p",{className:"text-sm text-yellow-800 dark:text-yellow-200 mb-2 font-medium",children:"Save this key now!"}),(0,a.jsx)("p",{className:"text-sm text-yellow-700 dark:text-yellow-300",children:"This is the only time you will see this key. Store it securely."})]}),(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsx)(x.pd,{value:O||"",readOnly:!0,className:"flex-1 font-mono text-sm"}),(0,a.jsx)(x.$n,{variant:"secondary",icon:"created_key"===U?"check":"content_copy",onClick:()=>D(O,"created_key"),children:"created_key"===U?"Copied!":"Copy"})]}),(0,a.jsx)(x.$n,{onClick:()=>R(null),fullWidth:!0,children:"Done"})]})}),(0,a.jsx)(C,{apiKey:E,isOpen:!!E,isSaving:Q.isPending,onClose:()=>M(null),onSave:e=>Q.mutate({id:E.id,patch:e})}),(0,a.jsx)(x.uo,{isOpen:!!_,onClose:()=>L(null),onConfirm:_?.onConfirm,title:_?.title||"Confirm",message:_?.message,variant:"danger"})]})}I.propTypes={initialData:r().shape({machineId:r().string,keys:r().array,settings:r().object}).isRequired}}},e=>{e.O(0,[782,8500,7854,4601,1321,2410,8441,3794,7358],()=>e(e.s=53427)),_N_E=e.O()}]);
|
|
@@ -25,4 +25,4 @@ name2|sk-key2|def789012`:H,value:Z,onChange:e=>G(e.target.value)}),Q&&(0,a.jsxs)
|
|
|
25
25
|
"id_token": "eyJ0eXAiOiJKV1QiLCJhbGci...",
|
|
26
26
|
"email": "account2@example.com"
|
|
27
27
|
}
|
|
28
|
-
]`;function X(e){let t,s=e.trim();if(!s)return[];try{t=JSON.parse(s)}catch(e){try{let e=s;e.startsWith("[")||((e=e.replace(/\}\s*,\s*\{/g,"},{").replace(/\}\s*\{/g,"},{")).endsWith(",")&&(e=e.slice(0,-1)),e=`[${e}]`),t=JSON.parse(e)}catch{throw e}}if(Array.isArray(t))return t;if(t&&"object"==typeof t)return Array.isArray(t.accounts)?t.accounts:[t];throw Error("Input must be a JSON object or array of objects")}function Y({isOpen:e,onClose:t,onSuccess:s}){let[i,n]=(0,r.useState)(""),[l,o]=(0,r.useState)(!1),[c,m]=(0,r.useState)(""),[u,p]=(0,r.useState)(null),[x,h]=(0,r.useState)(!1),[f,g]=(0,r.useState)(null),b=(0,r.useRef)(null),y=()=>{l||(n(""),m(""),p(null),g(null),h(!1),t())},v=async e=>{if(!e||0===e.length)return;m("");let t=Array.from(e).filter(e=>e.name.endsWith(".json")||"application/json"===e.type||""===e.type);if(0===t.length)return void m((0,A.Tl)("Please select valid .json files"));try{let e=[];for(let s of t){let t=await s.text(),a=X(t);Array.isArray(a)?e.push(...a):a&&e.push(a)}if(0===e.length)return void m((0,A.Tl)("No accounts found in selected files"));n(JSON.stringify(e,null,2)),g({filesCount:t.length,accountsCount:e.length})}catch(e){m(`${(0,A.Tl)("Error reading files")}: ${e.message}`)}},j=async()=>{let e;m(""),p(null);try{e=X(i)}catch(e){m(`${(0,A.Tl)("Invalid JSON")}: ${e.message}`);return}if(!e||0===e.length)return void m((0,A.Tl)("No accounts found in input"));o(!0);try{let t=await fetch("/api/oauth/grok-cli/bulk-import",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({accounts:e})}),a=await t.json();if(!t.ok)return void m(a?.error||`Request failed: ${t.status}`);p(a),a.success>0&&"function"==typeof s&&s()}catch(e){m(e.message||(0,A.Tl)("Request failed"))}finally{o(!1)}},w=u?.results?.filter(e=>!e.ok)||[];return(0,a.jsx)(d.aF,{isOpen:e,title:(0,A.Tl)("Bulk Add Grok CLI Accounts"),onClose:y,children:(0,a.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,a.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[(0,a.jsx)("p",{className:"text-xs text-text-muted",children:(0,A.Tl)("Upload multiple .json files or paste JSON array / object.")}),(0,a.jsx)("input",{ref:b,type:"file",accept:".json,application/json",multiple:!0,className:"hidden",onChange:e=>{v(e.target.files),e.target&&(e.target.value="")}}),(0,a.jsx)(d.$n,{type:"button",size:"sm",variant:"secondary",icon:"upload_file",onClick:()=>b.current?.click(),disabled:l,children:(0,A.Tl)("Upload JSON Files")})]}),(0,a.jsxs)("div",{onDragOver:e=>{e.preventDefault(),h(!0)},onDragLeave:e=>{e.preventDefault(),h(!1)},onDrop:e=>{e.preventDefault(),h(!1),e.dataTransfer?.files?.length>0&&v(e.dataTransfer.files)},className:`relative rounded border transition-colors ${x?"border-primary bg-primary/10 ring-2 ring-primary/30":"border-accent/30 bg-sidebar"}`,children:[(0,a.jsx)("textarea",{className:"w-full rounded bg-transparent p-2.5 text-sm font-mono resize-y min-h-[240px] focus:outline-none focus:ring-1 focus:ring-primary",placeholder:Q,value:i,onChange:e=>{n(e.target.value),g(null)},disabled:l}),x&&(0,a.jsxs)("div",{className:"absolute inset-0 flex flex-col items-center justify-center bg-sidebar/90 rounded pointer-events-none backdrop-blur-xs",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-3xl text-primary mb-1",children:"upload_file"}),(0,a.jsx)("span",{className:"text-sm font-medium text-primary",children:(0,A.Tl)("Drop .json files here")})]})]}),f&&(0,a.jsxs)("div",{className:"flex items-center gap-1.5 text-xs text-green-400 font-medium bg-green-500/10 border border-green-500/20 px-2.5 py-1.5 rounded",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-sm",children:"check_circle"}),(0,a.jsxs)("span",{children:[(0,A.Tl)("Loaded")," ",f.accountsCount," ",(0,A.Tl)("account(s) from")," ",f.filesCount," ",(0,A.Tl)("file(s)")]})]}),c&&(0,a.jsx)("p",{className:"text-xs text-red-500 break-words",children:c}),u&&(0,a.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,a.jsxs)("div",{className:`text-sm font-medium ${u.failed>0?"text-yellow-400":"text-green-400"}`,children:["✓ ",u.success," ",(0,A.Tl)("added"),u.failed>0?`, ✗ ${u.failed} ${(0,A.Tl)("failed")}`:""]}),w.length>0&&(0,a.jsx)("ul",{className:"rounded border border-accent/20 bg-sidebar/50 p-2 text-xs font-mono max-h-40 overflow-y-auto",children:w.map(e=>(0,a.jsxs)("li",{className:"text-red-400",children:["[",e.index,"] ",e.error]},e.index))})]}),(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsx)(d.$n,{onClick:j,fullWidth:!0,disabled:l||!i.trim(),children:l?(0,A.Tl)("Importing..."):(0,A.Tl)("Import All")}),(0,a.jsx)(d.$n,{onClick:y,variant:"ghost",fullWidth:!0,disabled:l,children:(0,A.Tl)("Close")})]})]})})}Y.propTypes={isOpen:D().bool.isRequired,onClose:D().func.isRequired,onSuccess:D().func};var ee=s(77251);function et({connectionId:e,providerAlias:t,models:s,jobSnapshot:i,onComplete:n,onStarted:l,onClose:o}){let[c,m]=(0,r.useState)(4),[u,p]=(0,r.useState)(50),[x,h]=(0,r.useState)(Math.round(20)),[f,g]=(0,r.useState)(!1),[b,y]=(0,r.useState)(null),[v,j]=(0,r.useState)(null),[w,k]=(0,r.useState)(""),[N,C]=(0,r.useState)(""),[S,$]=(0,r.useState)(""),A=(0,r.useRef)({onComplete:n,onStarted:l}),T=(0,r.useRef)(null),O=(0,r.useRef)(e),R=(0,r.useRef)(null),E=s?.length||0,I=(0,r.useMemo)(()=>`max concurrency 16 \xb7 batch 200 \xb7 timeout ${60}s`,[]);function D(e){if(e){if("idle"===e.status){R.current=null,g(!1);return}if(y({done:e.done||0,total:e.total||0,ok:e.ok||0,dead:e.dead||0,retryable:e.retryable||0,skippedDead:e.skippedDead||0,skippedDup:e.skippedDup||0}),"running"===e.status&&(R.current=e.connectionId||O.current,T.current=null,g(!0)),e.currentRange&&C(`Probing ${e.currentRange.from}–${e.currentRange.to} of ${e.total}…`),e.error&&k(e.error),"done"===e.status||"cancelled"===e.status||"error"===e.status){R.current=null,g(!1);let t={ok:e.ok||0,dead:e.dead||0,retryable:e.retryable||0,tested:e.done||0,skippedDead:e.skippedDead||0,skippedDup:e.skippedDup||0,cancelled:"cancelled"===e.status,retryableAuthOnly:!0===e.retryableAuthOnly};j(t),C("cancelled"===e.status?"Cancelled (partial results saved).":"error"===e.status?"Stopped.":"Done.");let s=`${e.startedAt||"unknown"}:${e.status}`;T.current!==s&&(T.current=s,A.current.onComplete?.(t))}}}async function M(){if(f||!e||0===E)return;g(!0),k(""),j(null),C("Starting…");let a={concurrency:Math.max(1,Math.min(16,Number(c)||4)),batchSize:Math.max(1,Math.min(200,Number(u)||50)),timeoutMs:Math.max(1e3,Math.min(6e4,1e3*(Number(x)||20)))};R.current=e;try{let r=await fetch(`/api/providers/${e}/model-probes/verify/start`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({models:s,providerAlias:t,...a,timeoutMs:a.timeoutMs})}),i=await r.json().catch(()=>({}));if(O.current!==e){R.current=null,g(!1);return}if(!r.ok){R.current=null,k(i.error||"Failed to start"),g(!1);return}A.current.onStarted?.(i),D(i),"running"!==i.status&&g(!1)}catch(e){R.current=null,k(e?.message||"Verify failed"),g(!1)}}async function P(){let t=R.current||e;await fetch(`/api/providers/${t}/model-probes/verify/cancel`,{method:"POST"}).catch(()=>{})}async function z(s){if(!e)return;let a="retryable"===s,r=a?Number(v?.retryable||0):Number(v?.dead||0);if(!a||await (0,ee.l)({title:"Remove retry-failed models?",message:`Review ${r} retryable result(s) and remove the eligible models? Timeouts, rate limits, network failures, and provider errors may be temporary. Credential failures are kept. Removed models can be enabled or imported again later.`,confirmText:"Remove eligible"})){$(s),k(""),C(`Removing ${a?"retry-failed":"dead"} models…`);try{let r=await fetch(`/api/providers/${e}/model-probes/remove-unavailable`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({providerAlias:t,kind:"llm",status:s})}),i=await r.json().catch(()=>({}));if(!r.ok)return void k(i.error||"Remove failed");let n=Number(i.removed||0),l=Number(i.kept||0),o=v?{...v,[a?"retryable":"dead"]:l,...a?{retryableAuthOnly:l>0}:{}}:v;j(o),C(`Removed ${n} ${a?"retry-failed":"dead"} model(s).`+(l>0?` Kept ${l} credential failure(s).`:"")),A.current.onComplete?.({...o||{},removed:n,kept:l,removedStatus:s})}catch(e){k(e?.message||"Remove failed")}finally{$("")}}}async function U(){if(!e)return;let t=await fetch(`/api/providers/${e}/model-probes/cache`,{method:"DELETE"}),s=await t.json().catch(()=>({}));t.ok?(C(`Cleared probe cache (${s.cleared||0} rows). Next verify will re-test everything.`),j(null),y(null),A.current.onComplete?.({cacheCleared:!0,cleared:s.cleared||0})):k(s.error||"Clear cache failed")}(0,r.useEffect)(()=>{A.current={onComplete:n,onStarted:l},O.current=e}),(0,r.useEffect)(()=>{D(i)},[i]);let q=b?.total?Math.min(100,Math.round(b.done/b.total*100)):0;return(0,a.jsxs)("div",{className:"mb-4 rounded-lg border border-border bg-sidebar/40 p-3 space-y-3",children:[(0,a.jsxs)("div",{className:"flex items-start justify-between gap-2",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("h3",{className:"text-sm font-semibold text-text-main",children:"Verify models"}),(0,a.jsxs)("p",{className:"text-[11px] text-text-muted mt-0.5",children:["Batch-ping availability and latency. Dead = permanently unavailable (missing, blocked, or deprecated) and can be removed; retry = transient (timeout/429/5xx). Known-dead models are skipped until you Clear cache. Caps: ",I,"."]})]}),o&&(0,a.jsx)("button",{type:"button",onClick:o,className:"p-1 text-text-muted hover:text-text-main rounded",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:"close"})})]}),(0,a.jsxs)("div",{className:"flex flex-wrap gap-3 items-end",children:[(0,a.jsxs)("label",{className:"text-xs text-text-muted",children:["Concurrency",(0,a.jsx)("input",{type:"number",min:1,max:16,value:c,disabled:f,onChange:e=>m(e.target.value),className:"mt-1 block w-20 rounded-md border border-border bg-background px-2 py-1 text-xs"})]}),(0,a.jsxs)("label",{className:"text-xs text-text-muted",children:["Batch size",(0,a.jsx)("input",{type:"number",min:1,max:200,value:u,disabled:f,onChange:e=>p(e.target.value),className:"mt-1 block w-20 rounded-md border border-border bg-background px-2 py-1 text-xs"})]}),(0,a.jsxs)("label",{className:"text-xs text-text-muted",children:["Timeout (s)",(0,a.jsx)("input",{type:"number",min:1,max:60,value:x,disabled:f,onChange:e=>h(e.target.value),className:"mt-1 block w-20 rounded-md border border-border bg-background px-2 py-1 text-xs"})]}),(0,a.jsxs)("div",{className:"flex gap-2",children:[f?(0,a.jsx)(d.$n,{size:"sm",variant:"secondary",icon:"stop",onClick:P,children:"Cancel"}):(0,a.jsx)(d.$n,{size:"sm",icon:"science",onClick:M,disabled:!e||0===E,children:"Start"}),(0,a.jsx)(d.$n,{size:"sm",variant:"secondary",icon:"delete_sweep",onClick:U,disabled:f,children:"Clear cache"})]})]}),b&&(0,a.jsxs)("div",{className:"space-y-1",children:[(0,a.jsx)("div",{className:"h-1.5 w-full rounded-full bg-border overflow-hidden",children:(0,a.jsx)("div",{className:"h-full bg-primary transition-all",style:{width:`${q}%`}})}),(0,a.jsxs)("p",{className:"text-[11px] text-text-muted flex flex-wrap gap-x-2",children:[(0,a.jsxs)("span",{title:"Models probed this run",children:[b.done,"/",b.total," tested"]}),(0,a.jsxs)("span",{title:"Reachable",children:["\xb7 ok ",b.ok]}),(0,a.jsxs)("span",{title:"Permanently unavailable this run (missing, blocked, or deprecated)",children:["\xb7 dead ",b.dead]}),(0,a.jsxs)("span",{title:"Transient failure this run (timeout / 429 / 5xx / network); re-testable",children:["\xb7 retry ",b.retryable]}),b.skippedDead?(0,a.jsxs)("span",{title:"Not probed — cache already marks them dead. Clear cache to re-test.",children:["\xb7 skipped known-dead ",b.skippedDead]}):null,b.skippedDup?(0,a.jsxs)("span",{title:"Duplicate ids collapsed",children:["\xb7 dupes ",b.skippedDup]}):null]})]}),N&&(0,a.jsx)("p",{className:"text-xs text-text-muted",children:N}),w&&(0,a.jsx)("p",{className:"text-xs text-red-500 break-words",children:w}),v&&(0,a.jsxs)("div",{className:"flex flex-wrap items-center gap-2 pt-1",children:[(0,a.jsxs)("span",{className:"text-xs text-text-main",children:["Summary: ",v.ok," ok \xb7 ",v.dead," dead \xb7 ",v.retryable," retry",v.skippedDead?` \xb7 ${v.skippedDead} skipped known-dead`:"",v.cancelled?" \xb7 cancelled":""]}),v.dead>0&&(0,a.jsxs)(d.$n,{size:"sm",variant:"primary",icon:"delete_sweep",onClick:()=>z("dead"),disabled:f||!!S,loading:"dead"===S,children:["Remove ",v.dead," dead"]}),v.retryable>0&&!v.retryableAuthOnly&&(0,a.jsxs)(d.$n,{size:"sm",variant:"danger",icon:"delete_sweep",onClick:()=>z("retryable"),disabled:f||!!S,loading:"retryable"===S,children:["Remove ",v.retryable," retry failures"]})]})]})}et.propTypes={connectionId:D().string,providerAlias:D().string,models:D().arrayOf(D().object),jobSnapshot:D().object,onComplete:D().func,onStarted:D().func,onClose:D().func};var es=s(68875);let ea=["UTC","America/Los_Angeles","America/Denver","America/Chicago","America/New_York","America/Sao_Paulo","Europe/London","Europe/Berlin","Europe/Moscow","Asia/Kolkata","Asia/Shanghai","Asia/Tokyo","Asia/Singapore","Australia/Sydney"],er=(()=>{let e=[];try{e=Intl.supportedValuesOf?.("timeZone")||[]}catch{e=[]}try{let e=Intl.DateTimeFormat().resolvedOptions().timeZone;e&&!ea.includes(e)&&ea.unshift(e)}catch{}return[...new Set([...ea,...e.filter(e=>!ea.includes(e))])]})(),ei={mon:"Mo",tue:"Tu",wed:"We",thu:"Th",fri:"Fr",sat:"Sa",sun:"Su"};function en({providerId:e,scheduleKey:t}){let s=t||e,i=(0,r.useId)(),[n,l]=(0,r.useState)(!1),[o,c]=(0,r.useState)(!1),[m,u]=(0,r.useState)("UTC"),[p,x]=(0,r.useState)("offPeak"),[h,f]=(0,r.useState)([]),[g,b]=(0,r.useState)(!1),[y,v]=(0,r.useState)(""),[j,w]=(0,r.useState)(0),[,k]=(0,r.useState)(0),N=(0,r.useCallback)(e=>{let t=es.Z9.find(t=>t.id===e);t&&(u(t.config.timezone||"UTC"),x("peak"===t.config.defaultState?"peak":"offPeak"),f(t.config.windows.map(e=>({type:e.type,start:e.start,end:e.end,days:Array.isArray(e.days)&&e.days.length?[...e.days]:[...es.de]}))),w(0))},[]);(0,r.useEffect)(()=>{let e=!1;return c(!1),u("UTC"),x("offPeak"),f([]),w(0),v(""),fetch("/api/settings",{cache:"no-store"}).then(e=>e.ok?e.json():{}).then(t=>{if(e)return;let a=(t.providerSchedules||{})[s];a&&Array.isArray(a.windows)&&a.windows.length&&(c(!0),u(a.timezone||"UTC"),x("peak"===a.defaultState?"peak":"offPeak"),f(a.windows.map(e=>({type:"offPeak"===e.type?"offPeak":"peak",start:e.start||"09:00",end:e.end||"17:00",days:Array.isArray(e.days)&&e.days.length?[...e.days]:[...es.de]})))),l(!0)}).catch(()=>{e||l(!0)}),()=>{e=!0}},[s]),(0,r.useEffect)(()=>{let e=setInterval(()=>k(e=>e+1),3e4);return()=>clearInterval(e)},[]);let C=(0,r.useMemo)(()=>o?{timezone:m,defaultState:p,windows:h}:null,[o,m,p,h]),S=(0,es.yW)(C),$="unscheduled"===S?null:(0,es.bC)(C),A=(0,r.useCallback)((e,t)=>{f(s=>s.map((s,a)=>a===e?{...s,...t}:s)),w(0)},[]),T=(0,r.useCallback)((e,t)=>{f(s=>s.map((s,a)=>{if(a!==e)return s;let r=s.days.includes(t)?s.days.filter(e=>e!==t):[...s.days,t];return{...s,days:r.length?r:s.days}})),w(0)},[]),O=async()=>{v("");let t=o?(0,es.v2)({timezone:m,defaultState:p,windows:h},e):null;if(o&&t.error)return void v(t.error);b(!0);try{let e=await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({providerSchedules:{[s]:o?t.value:null}})});if(!e.ok){let t=await e.json().catch(()=>({}));v(t.error||`Failed to save peak hours (${e.status})`);return}w(Date.now())}catch{v("Failed to save peak hours")}finally{b(!1)}};return n?(0,a.jsxs)(d.Zp,{children:[(0,a.jsxs)("div",{className:"mb-3 flex flex-wrap items-center justify-between gap-2",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("h2",{className:"text-lg font-semibold",children:"Peak hours"}),"unscheduled"!==S&&(0,a.jsxs)("span",{className:`inline-flex items-center gap-1 rounded-full px-2 py-0.5 text-[11px] font-medium ${"peak"===S?"bg-red-500/10 text-red-600 dark:text-red-400":"bg-green-500/10 text-green-600 dark:text-green-400"}`,title:$?`Changes at ${function(e,t){try{return new Intl.DateTimeFormat("en-US",{timeZone:t,weekday:"short",hour:"2-digit",minute:"2-digit",hourCycle:"h23"}).format(new Date(e))}catch{return e}}(new Date($).toISOString(),m)}`:void 0,children:[(0,a.jsx)("span",{className:`size-1.5 rounded-full ${"peak"===S?"bg-red-500":"bg-green-500"}`}),"peak"===S?"Peak now":"Off-peak now",$?` \xb7 ${(0,es.zt)($-Date.now())} left`:""]})]}),(0,a.jsx)(d.lM,{checked:o,onChange:e=>{c(e),w(0),e&&!h.length&&(u("UTC"),x("offPeak"),f([{type:"peak",start:"09:00",end:"17:00",days:[...es.de]}]))},label:"Enable peak / off-peak hours",size:"sm"})]}),(0,a.jsx)("p",{className:"mb-3 text-xs text-text-muted leading-relaxed",children:"Optional. Some providers (e.g. DeepSeek) charge less outside peak hours. Define this provider's windows once, then mark models in a combo as peak-only or off-peak-only to skip them at the wrong hours."}),o&&(0,a.jsxs)("div",{className:"flex flex-col gap-3",children:[(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-2",children:[(0,a.jsxs)("div",{className:"flex flex-col gap-1.5",children:[(0,a.jsx)("label",{htmlFor:i,className:"text-sm font-medium text-text-main",children:"Timezone"}),(0,a.jsx)("input",{id:i,list:`${i}-zones`,value:m,onChange:e=>{u(e.target.value),w(0)},placeholder:"UTC — type to search IANA zones",className:"rounded-md border border-border bg-background px-3 py-2 text-sm text-text-main outline-none focus:border-primary",autoComplete:"off"}),(0,a.jsx)("datalist",{id:`${i}-zones`,children:er.map(e=>(0,a.jsx)("option",{value:e},e))}),(0,a.jsx)("p",{className:"text-[10px] text-text-muted",children:"Windows are wall-clock in this zone (provider docs usually quote UTC)"})]}),(0,a.jsx)(d.l6,{label:"Outside all windows is",options:[{value:"offPeak",label:"Off-peak (peak is the exception)"},{value:"peak",label:"Peak (off-peak discount is the exception)"}],value:p,onChange:e=>{x(e.target.value),w(0)}})]}),(0,a.jsx)(d.l6,{label:"Load a preset",options:es.Z9.map(e=>({value:e.id,label:e.label})),value:"",onChange:e=>N(e.target.value),placeholder:"Choose a known provider policy…",hint:"Fills the editor below — review the provider's current pricing page, then Save"}),(0,a.jsxs)("div",{className:"flex flex-col gap-2",children:[h.map((e,t)=>(0,a.jsxs)("div",{className:"flex flex-wrap items-center gap-2 rounded-md border border-border bg-black/[0.02] px-2 py-2 dark:bg-white/[0.02]",children:[(0,a.jsxs)("select",{value:e.type,onChange:e=>A(t,{type:e.target.value}),className:"rounded-md border border-border bg-background px-2 py-1 text-xs","aria-label":`Window ${t+1} type`,children:[(0,a.jsx)("option",{value:"peak",children:"Peak"}),(0,a.jsx)("option",{value:"offPeak",children:"Off-peak"})]}),(0,a.jsx)("input",{type:"time",value:e.start,onChange:e=>A(t,{start:e.target.value}),className:"rounded-md border border-border bg-background px-2 py-1 text-xs","aria-label":`Window ${t+1} start`}),(0,a.jsx)("span",{className:"text-xs text-text-muted",children:"→"}),(0,a.jsx)("input",{type:"time",value:e.end,onChange:e=>A(t,{end:e.target.value}),className:"rounded-md border border-border bg-background px-2 py-1 text-xs","aria-label":`Window ${t+1} end`}),(0,a.jsx)("div",{className:"flex items-center gap-1",children:es.de.map(s=>(0,a.jsx)("button",{type:"button",onClick:()=>T(t,s),className:`size-6 rounded text-[10px] font-medium transition-colors ${e.days.includes(s)?"bg-primary/15 text-primary":"text-text-muted hover:bg-black/5 dark:hover:bg-white/5"}`,title:s,children:ei[s]},s))}),(0,a.jsx)("button",{type:"button",onClick:()=>{f(e=>e.filter((e,s)=>s!==t)),w(0)},className:"ml-auto rounded p-1 text-text-muted transition-colors hover:bg-red-500/10 hover:text-red-500",title:"Remove window","aria-label":`Remove window ${t+1}`,children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"close"})})]},t)),(0,a.jsx)("div",{className:"flex flex-wrap items-center gap-2",children:(0,a.jsx)(d.$n,{size:"sm",variant:"secondary",icon:"add",onClick:()=>{f(e=>[...e,{type:"peak",start:"09:00",end:"17:00",days:[...es.de]}]),w(0)},children:"Add window"})})]})]}),y&&(0,a.jsx)("p",{className:"mt-2 text-xs text-red-500",children:y}),j>0&&!y&&(0,a.jsx)("p",{className:"mt-2 text-xs text-green-600 dark:text-green-400",children:"Saved"}),(0,a.jsx)("div",{className:"mt-3",children:(0,a.jsx)(d.$n,{size:"sm",onClick:O,disabled:g,children:g?"Saving...":o?"Save peak hours":"Save (disable schedule)"})})]}):null}var el=s(65921);let eo=["host","content-length","content-type","connection","transfer-encoding","authorization","cookie"],ed=/^[A-Za-z0-9-]+$/;function ec({providerId:e}){let t=(0,el.i)(),[s,i]=(0,r.useState)(!1),[n,l]=(0,r.useState)([{name:"",value:""}]),[o,c]=(0,r.useState)({}),[m,u]=(0,r.useState)(!1),[p,x]=(0,r.useState)(!1);(0,r.useEffect)(()=>{let t=!1;return fetch(`/api/providers/${e}/overrides`,{cache:"no-store"}).then(e=>e.ok?e.json():null).then(e=>{if(t||!e)return;let s=e.builtinHeaders||{},a=Object.entries({...s,...e.headers||{}}).map(([e,t])=>({name:e,value:t}));c(s),l(a.length?a:[{name:"",value:""}]),u(Object.keys(e.headers||{}).length>0)}).catch(()=>{}),()=>{t=!0}},[e]);let h=(e,t,s)=>{l(a=>a.map((a,r)=>r===e?{...a,[t]:s}:a))},f=(0,r.useCallback)(async()=>{let s={};for(let e of n.filter(e=>e.name.trim())){let a=e.name.trim();if(!ed.test(a))return void t.error(`Invalid header name: ${a}`);if(eo.includes(a.toLowerCase()))return void t.error(`Header ${a} cannot be overridden`);if(a in s)return void t.error(`Duplicate header name: ${a}`);e.value!==o[a]&&(s[a]=e.value)}x(!0);try{let a=await fetch(`/api/providers/${e}/overrides`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({headers:s})});if(!a.ok){let e=await a.json().catch(()=>({}));t.error(e.error||"Failed to save");return}u(Object.keys(s).length>0),t.success("Custom headers saved")}finally{x(!1)}},[n,o,e,t]);return 0!==Object.keys(o).length||m?(0,a.jsxs)(d.Zp,{padding:"xs",children:[(0,a.jsxs)("button",{type:"button",onClick:()=>i(e=>!e),className:"flex w-full items-center justify-between text-left",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-primary text-[20px]",children:"tune"}),(0,a.jsx)("span",{className:"text-sm font-semibold",children:"Custom Headers"}),m&&(0,a.jsx)(d.Ex,{variant:"success",size:"sm",children:"Active"})]}),(0,a.jsx)("span",{className:"material-symbols-outlined text-text-muted",children:s?"expand_less":"expand_more"})]}),s&&(0,a.jsxs)("div",{className:"mt-3 border-t border-border pt-3",children:[(0,a.jsx)("div",{className:"flex flex-col gap-2",children:n.map((e,t)=>{let s=e.name.trim()in o&&e.value!==o[e.name.trim()];return(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("input",{value:e.name,onChange:e=>h(t,"name",e.target.value),placeholder:"Header-Name",spellCheck:!1,className:"w-44 rounded-md border border-border bg-background px-2 py-1.5 text-sm focus:border-primary focus:outline-none"}),(0,a.jsx)("input",{value:e.value,onChange:e=>h(t,"value",e.target.value),placeholder:"Value",spellCheck:!1,title:s?"Overridden":e.name.trim()in o?"Registry default":"",className:`min-w-0 flex-1 rounded-md border bg-background px-2 py-1.5 text-sm focus:border-primary focus:outline-none ${s?"border-amber-400/60":"border-border"}`}),(0,a.jsx)("button",{type:"button",title:"Remove header",onClick:()=>l(e=>e.length>1?e.filter((e,s)=>s!==t):[{name:"",value:""}]),className:"shrink-0 text-text-muted hover:text-red-500",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:"delete"})})]},t)})}),(0,a.jsxs)("div",{className:"mt-3 flex items-center justify-between gap-2",children:[(0,a.jsxs)("button",{type:"button",onClick:()=>l(e=>[...e,{name:"",value:""}]),className:"flex items-center gap-1 text-xs text-primary hover:underline",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[16px]",children:"add"}),"Add header"]}),(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsx)("button",{type:"button",disabled:p,onClick:()=>{l(Object.entries(o).map(([e,t])=>({name:e,value:t})))},className:"rounded-md border border-border px-3 py-1.5 text-xs hover:bg-black/[0.03] dark:hover:bg-white/[0.03] disabled:opacity-50",children:"Reset"}),(0,a.jsx)("button",{type:"button",disabled:p,onClick:f,className:"rounded-md bg-primary px-3 py-1.5 text-xs font-medium text-white hover:opacity-90 disabled:opacity-50",children:p?"Saving...":"Save"})]})]})]})]}):null}ec.propTypes={providerId:D().string.isRequired};var em=s(97132),eu=s(93195),ep=s(36861),ex=s(48874),eh=s(53578);let ef=new Set(["minimax-code","minimax-code-global"]),eg={claude:"claudeAutoPing",codex:"codexAutoPing"};function eb(){let e,t,s,n=(0,i.useParams)(),u=(0,i.useRouter)(),p=n.id,{getCaps:x}=(0,$.y)(),[h,f]=(0,r.useState)([]),[g,b]=(0,r.useState)([]),[y,v]=(0,r.useState)(!0),[j,w]=(0,r.useState)(null),[k,N]=(0,r.useState)(!1),[T,I]=(0,r.useState)(!1),[D,z]=(0,r.useState)(!1),[U,F]=(0,r.useState)(""),[_,L]=(0,r.useState)(!1),[W,Z]=(0,r.useState)(!1),[Q,X]=(0,r.useState)(!1),[ee,es]=(0,r.useState)(!1),[ea,er]=(0,r.useState)(null),[ei,el]=(0,r.useState)({}),[eo,ed]=(0,r.useState)([]),[eb,ey]=(0,r.useState)(!1),[ev,ej]=(0,r.useState)({}),[ew,ek]=(0,r.useState)(""),[eN,eC]=(0,r.useState)(null),[eS,e$]=(0,r.useState)(()=>new Set),[eA,eT]=(0,r.useState)(!1),[eO,eR]=(0,r.useState)(null),[eE,eI]=(0,r.useState)(""),[eD,eM]=(0,r.useState)(!1),[eP,ez]=(0,r.useState)("30"),[eU,eq]=(0,r.useState)("auto"),[eF,e_]=(0,r.useState)({enabled:!1,connections:{},schedules:{}}),[eJ,eL]=(0,r.useState)(null),[eK,eB]=(0,r.useState)([]),[eH,eW]=(0,r.useState)([]),[eV,eZ]=(0,r.useState)([]),[eG,eQ]=(0,r.useState)([]),[eX,eY]=(0,r.useState)(null),[e0,e1]=(0,r.useState)(!1),[e2,e5]=(0,r.useState)(!1),[e3,e4]=(0,r.useState)(!1),[e6,e8]=(0,r.useState)(null),[e7,e9]=(0,r.useState)({}),[te,tt]=(0,r.useState)(null),ts=(0,r.useRef)(!1),ta=(0,r.useRef)(null),tr=(0,r.useRef)(0),ti=(0,r.useRef)(0),[tn,tl]=(0,r.useState)(!1),[to,td]=(0,r.useState)(""),[tc,tm]=(0,r.useState)(!1),[tu,tp]=(0,r.useState)(null),[tx,th]=(0,r.useState)({}),[tf,tg]=(0,r.useState)({}),[tb,ty]=(0,r.useState)("all"),{copied:tv,copy:tj}=(0,S.C)(),tw="ag_risk_confirmed",tk=j?{id:j.id,name:j.name||("anthropic-compatible"===j.type?"Anthropic Compatible":"OpenAI Compatible"),color:"anthropic-compatible"===j.type?"#D97757":"#10A37F",textIcon:"anthropic-compatible"===j.type?"AC":"OC",apiType:j.apiType,baseUrl:j.baseUrl,type:j.type}:c.zN[p]||c.fg[p]||c.IS[p]||c.nJ[p]||c.br[p],tN=tk?.authModes||[],tC=!!c.zN[p]||!!c.IS[p]||tN.includes("oauth"),tS=!!c.fg[p]||tN.includes("apikey"),t$=!!c.IS[p]?.noAuth,tA=(0,m.KC)(p),tT=(()=>{let e=new Map(tA.map(e=>[e.id,e]));for(let t of eH)t?.id&&e.set(t.id,{...e.get(t.id),...t});return[...e.values()]})(),tO=(0,c.wG)(p),tR=(0,c.mq)(p),tE=(0,c.gb)(p),tI=tR||tE,tD=h.some(e=>!1!==e.isActive),tM=function({isCompatible:e,hasActiveConnection:t}){let s=!e,a=!e;return{showToolbar:s||t||a,showImport:s,showVerify:t,showBulkControls:a}}({isCompatible:tI,hasActiveConnection:tD}),tP=!tI&&tC&&tS,tz="xai"===p?"Grok Build OAuth":"OAuth",tU="xai"===p?"xAI API Key":"qoder"===p||"qoder-cn"===p?"PAT":"API Key",tq=()=>{N(!0)},tF=()=>{"antigravity"===p&&"true"!==window.localStorage.getItem(tw)?e1(!0):tC?tq():(F(""),z(!0))},t_=()=>{F(""),z(!0)},tJ=()=>{tC?tF():t_()},tL=e=>{if(!eU||"auto"===eU)return null;let t=C(p,e);return t&&t.includes(eU)?eU:null},tK=(()=>{let e=new Set;for(let t of tT){let s=C(p,t.id);s&&s.forEach(t=>{"none"!==t&&e.add(t)})}return e.size?["auto",...e]:null})(),tB=tI?p:tO,tH=tI?j?.prefix||p:tO,tW=(0,R.Iz)(eG,tB),tV=e=>(0,R.uJ)(tW,e,tB),tZ=(0,r.useCallback)(async()=>{try{let e=await fetch(`/api/models/disabled?providerAlias=${encodeURIComponent(tB)}`,{cache:"no-store"}),t=await e.json();e.ok&&eQ(t.ids||[])}catch(e){(0,P.s)("Error fetching disabled models:",e)}},[tB]),tG=async e=>{try{await (0,ex.x)("/api/models/disabled",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({providerAlias:tB,ids:[e]})}),await tZ()}catch(e){(0,P.s)("Error disabling model:",e)}},tQ=async e=>{try{return await (0,ex.x)(`/api/models/disabled?providerAlias=${encodeURIComponent(tB)}&id=${encodeURIComponent(e)}`,{method:"DELETE"}),await tZ(),!0}catch(e){return(0,P.s)("Error enabling model:",e),!1}},tX=async e=>{e.length&&eY({title:"Disable All Models",message:`Disable all ${e.length} model(s)?`,onConfirm:async()=>{eY(null);try{await (0,ex.x)("/api/models/disabled",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({providerAlias:tB,ids:e})}),await tZ()}catch(e){(0,P.s)("Error disabling all models:",e)}}})},tY=async()=>{try{await (0,ex.x)(`/api/models/disabled?providerAlias=${encodeURIComponent(tB)}`,{method:"DELETE"}),await tZ()}catch(e){(0,P.s)("Error enabling all models:",e)}},t0=(0,r.useCallback)(async()=>{try{let e=await fetch("/api/models/alias"),t=await e.json();e.ok&&el(t.aliases||{})}catch(e){(0,P.s)("Error fetching aliases:",e)}},[]),t1=(0,r.useCallback)(async()=>{try{let e=await fetch("/api/models/custom",{cache:"no-store"}),t=await e.json();e.ok&&ed(t.models||[])}catch(e){(0,P.s)("Error fetching custom models:",e)}},[]);(0,r.useEffect)(()=>{"kilocode"===p&&fetch("/api/providers/kilo/free-models").then(e=>e.json()).then(e=>{e.models?.length&&eZ(e.models)}).catch(()=>{})},[p]);let t2=(0,r.useCallback)(async()=>{try{let[e,t,s]=await Promise.all([fetch("/api/providers",{cache:"no-store"}),fetch("/api/provider-nodes",{cache:"no-store"}),fetch("/api/settings",{cache:"no-store"})]),a=await e.json(),r=await t.json(),i=s.ok?await s.json():{};if(e.ok){let e=(a.connections||[]).filter(e=>e.provider===p);f(e)}let n=(i.providerStrategies||{})[p]||{};eR(n.fallbackStrategy||null),eI(null!=n.stickyRoundRobinLimit?String(n.stickyRoundRobinLimit):"1");let l=n.accountScheduler||{};eM(!0===l.enabled),ez(String(Math.max(1,Math.round((l.sessionAffinityTtlSeconds||1800)/60))));let o=(i.providerThinking||{})[p]||{};eq(o.mode||"auto");let d=eg[p],c=d&&i[d]||{};if(e_({enabled:!0===c.enabled,connections:c.connections||{},schedules:c.schedules||{}}),t.ok){let e=(r.nodes||[]).find(e=>e.id===p)||null;if(!e&&tI)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===p)||null))break}w(e)}}catch(e){(0,P.s)("Error fetching connections:",e)}finally{v(!1)}},[p,tI]),t5=(0,r.useCallback)(async(e=null)=>{let t=++ti.current,s=e?h.find(t=>t.id===e&&!1!==t.isActive):h.find(e=>g.includes(e.id)&&!1!==e.isActive)||h.find(e=>!1!==e.isActive);if(!s){tg({}),th({});return}try{let e=await fetch(`/api/providers/${s.id}/model-probes`,{cache:"no-store"});if(!e.ok)return;let a=await e.json().catch(()=>({})),r={},i={};for(let e of a.probes||[])r[e.modelId]="ok"===e.status?"ok":"dead"===e.status?"dead":"retry",null!=e.latencyMs&&(i[e.modelId]=e.latencyMs);if(t!==ti.current)return;tg(r),th(i)}catch{}},[h,g]),t3=async e=>{try{let t=await fetch(`/api/provider-nodes/${p}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}),s=await t.json();t.ok?(w(s.node),await t2(),es(!1)):(0,P.s)(s?.error||"Failed to update provider node")}catch(e){(0,P.s)("Error updating provider node:",e)}},t4=async(e,t)=>{try{return await (0,eh.T)(p,s=>{let a={...s};return e?a.fallbackStrategy=e:delete a.fallbackStrategy,"round-robin"===e&&""!==t?a.stickyRoundRobinLimit=Number(t)||3:e||delete a.stickyRoundRobinLimit,a}),!0}catch(e){return(0,P.s)("Error saving provider strategy:",e),!1}},t6=async(e,t)=>{let s=Math.min(1440,Math.max(1,Number.parseInt(t,10)||30));try{return await (0,eh.T)(p,t=>({...t,accountScheduler:{...t.accountScheduler||{},enabled:e,sessionAffinityTtlSeconds:60*s}})),!0}catch(e){return(0,P.s)("Error saving balanced scheduler:",e),!1}},t8=async e=>{let t=e?"round-robin":null,s=e?eE||"1":eE;await t4(t,s)&&(e&&!eE&&eI("1"),eR(t))},t7=async e=>{await t4("round-robin",e)&&eI(e)},t9=async e=>{await t6(e,eP)&&eM(e)},se=async e=>{await t6(eD,e)&&ez(e)},st=async e=>{try{let t=await fetch("/api/settings",{cache:"no-store"}),s={...(t.ok?await t.json():{}).providerThinking||{}};e&&"auto"!==e?s[p]={mode:e}:delete s[p],await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({providerThinking:s})})}catch(e){(0,P.s)("Error saving thinking config:",e)}},ss=async e=>{let t=eg[p];if(t){e_(e);try{await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({[t]:e})})}catch(e){(0,P.s)("Error saving auto-ping config:",e)}}};(0,r.useEffect)(()=>{t2(),t0(),t1(),tZ()},[t2,t0,t1,tZ]),(0,r.useEffect)(()=>{t5()},[t5]),(0,r.useEffect)(()=>{if(tI)return;let e=h.find(e=>!1!==e.isActive);if(!e){eW([]),"zed"===p&&eC(null);return}let t=!1;return"zed"===p&&eC(null),fetch(`/api/providers/${e.id}/models`,{cache:"no-store"}).then(e=>e.json().catch(()=>({}))).then(e=>{if(!t){if(Array.isArray(e.models)&&e.models.length>0){eW(e.models),"zed"===p&&e?.warning&&eC(e.warning);return}"zed"===p&&(eW([]),eC(e?.warning||e?.error||"Zed returned no live models."))}}).catch(()=>{t||"zed"!==p||(eW([]),eC("Failed to reach the Zed model catalog."))}),()=>{t=!0}},[h,tI,p]),(0,r.useEffect)(()=>{let e=(c.zN[p]||c.fg[p]||c.IS[p]||c.nJ[p])?.modelsFetcher;e&&O(e).then(eB)},[p]);let sa=(0,r.useCallback)(e=>{let t=++tr.current;ta.current&&(clearTimeout(ta.current),ta.current=null);let s=async()=>{try{let a=await fetch(`/api/providers/${e}/model-probes/verify/status`,{cache:"no-store"}),r=await a.json().catch(()=>null);if(t!==tr.current)return;if(!a.ok||!r?.status)throw Error("Verify status temporarily unavailable");tp(r&&r.status?r:null),r?.status==="running"?ta.current=setTimeout(s,1500):(ta.current=null,await t5(e))}catch{t===tr.current&&(ta.current=setTimeout(s,1500))}};ta.current=setTimeout(s,0)},[t5]);(0,r.useEffect)(()=>{let e=h.find(e=>g.includes(e.id)&&!1!==e.isActive)||h.find(e=>!1!==e.isActive);return e?(sa(e.id),()=>{tr.current+=1,ta.current&&(clearTimeout(ta.current),ta.current=null)}):void tp(null)},[h,g,sa]);let sr=async(e,t,s=tO)=>{let a=`${s}/${e}`;try{let e=await fetch("/api/models/alias",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({model:a,alias:t})});if(e.ok)await t0();else{let t=await e.json();(0,P.s)(t.error||"Failed to set alias")}}catch(e){(0,P.s)("Error setting alias:",e)}},si=async e=>{try{await (0,ex.x)(`/api/models/alias?alias=${encodeURIComponent(e)}`,{method:"DELETE"}),await t0()}catch(e){(0,P.s)("Error deleting alias:",e)}},sn=async(e,t="llm",s=tB,a,r)=>{try{let i=await fetch("/api/models/custom",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({providerAlias:s,id:e,type:t,...a?{caps:a}:{},...r?{transport:r}:{}})});if(i.ok)await t1(),window.dispatchEvent(new CustomEvent("customModelChanged"));else{let e=await i.json();(0,P.s)(e.error||"Failed to add custom model")}}catch(e){(0,P.s)("Error adding custom model:",e)}},sl=async(e,t="llm",s=tB)=>{try{let a=new URLSearchParams({providerAlias:s,id:e,type:t});await (0,ex.x)(`/api/models/custom?${a}`,{method:"DELETE"}),await t1(),window.dispatchEvent(new CustomEvent("customModelChanged"))}catch(e){(0,P.s)("Error deleting custom model:",e)}},so=async()=>{if(tn)return;let e=h.find(e=>g.includes(e.id)&&!1!==e.isActive)||h.find(e=>!1!==e.isActive);if(!e)return void(0,P.s)((0,A.Tl)("Add an active connection first"));tl(!0),td("");try{let t=await fetch(`/api/providers/${e.id}/models`),s=await t.json().catch(()=>({}));if(!t.ok)return void(0,P.s)(s.error||(0,A.Tl)("Failed to fetch models"));let a=s.models||[];if(0===a.length)return void(0,P.s)(s.warning||(0,A.Tl)("No models returned"));let r=new Set;try{let t=await fetch(`/api/providers/${e.id}/model-probes`,{cache:"no-store"});for(let e of(await t.json().catch(()=>({}))).probes||[])"dead"===e.status&&r.add(e.modelId)}catch{}let i=0,n=new Set(tT.map(e=>e.id)),l=[],o=[],d=new Set;for(let e of a){let t=(0,E.R2)(e,tB);if(!t)continue;let{id:s,name:a,type:c}=t;if(r.has((0,ep.v)(s,tB))){i+=1;continue}let m=`${c}|${s}`;if(d.has(m))continue;if(d.add(m),n.has(s)){tV(s)&&o.push(s);continue}if(eo.some(e=>e.providerAlias===tB&&e.id===s&&(0,E.ki)(e.kind||e.type||"llm")===c))continue;let u=`${tB}/${s}`;Object.values(ei).includes(u)||l.push({providerAlias:tB,id:s,type:c,name:a,...t.reasoning?{reasoning:t.reasoning}:{}})}let c=0;if(o.length>0)try{for(let e of o)(await fetch(`/api/models/disabled?providerAlias=${encodeURIComponent(tB)}&id=${encodeURIComponent(e)}`,{method:"DELETE"})).ok&&(c+=1);await tZ()}catch{}let m=0;if(l.length>0){let e=await fetch("/api/models/custom",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({models:l})}),t=await e.json().catch(()=>({}));if(!e.ok)return void(0,P.s)(t.error||(0,A.Tl)("Failed to save models"));m=t.added??l.length,await t1(),window.dispatchEvent(new CustomEvent("customModelChanged"))}let u=l.filter(e=>"llm"!==e.type).length,p=[];if(m>0&&p.push(`${m} new`),c>0&&p.push(`${c} re-enabled`),0===p.length)td((0,A.Tl)("All models already in list"));else{let e=`Imported ${p.join(" \xb7 ")} (${a.length} from provider)`;u>0&&(e+=" \xb7 non-chat types stored for media pages"),s.warning&&(e+=` \xb7 ${s.warning}`),td(e)}if(i>0&&td(e=>`${e} \xb7 ${i} skipped (known dead)`),m>0||c>0)try{let t=[...tT,...l.map(e=>({id:e.id,name:e.name,kind:e.type}))],s=await fetch(`/api/providers/${e.id}/model-probes/verify/start`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({models:t,providerAlias:tB})}),a=await s.json().catch(()=>({}));if(!s.ok)throw Error(a.error||"Failed to start auto-verify");tp(a&&a.status?a:null),sa(e.id)}catch(e){td(t=>`${t} \xb7 auto-verify failed: ${e?.message||e}`)}}catch(e){(0,P.s)("Error importing models:",e),(0,P.s)((0,A.Tl)("Error fetching models")+": "+(e?.message||e))}finally{tl(!1)}},sd=async()=>{if(e2||0===h.length)return;let e=Object.fromEntries(h.map(e=>[e.id,{state:"queued",error:null}]));ts.current=!1,e5(!0),e4(!1),e8(null),e9(e),tt({total:h.length,completed:0,passed:0,failed:0,stopped:!1});let t=0,s=0;try{for(let e=0;e<h.length;e+=1){if(ts.current){tt({total:h.length,completed:e,passed:t,failed:s,stopped:!0});break}let a=h[e];e8(a.id),e9(e=>({...e,[a.id]:{state:"testing",error:null}}));try{let e=await fetch(`/api/providers/${a.id}/test`,{method:"POST"}),r=await e.json(),i=!!r.valid;i?t+=1:s+=1,e9(e=>({...e,[a.id]:{state:i?"success":"failed",error:i?null:r.error||null}}))}catch(e){s+=1,e9(t=>({...t,[a.id]:{state:"failed",error:e.message||"Test failed"}}))}tt({total:h.length,completed:e+1,passed:t,failed:s,stopped:!1}),e<h.length-1&&await new Promise(e=>setTimeout(e,1e3))}}finally{e8(null),e5(!1),e4(!1),ts.current=!1}},sc=async e=>{let t=h.find(t=>t.id===e),s=t?.name?.trim()||t?.email?.trim()||e;eY({title:"Delete Connection",message:`Delete connection “${s}”?`,onConfirm:async()=>{eY(null);try{await (0,ex.x)(`/api/providers/${e}`,{method:"DELETE"}),f(t=>t.filter(t=>t.id!==e))}catch(e){(0,P.s)("Error deleting connection:",e)}}})},sm=()=>{t2(),N(!1)},su=async e=>{F("");try{let t=await fetch("/api/providers",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:p,...e})}),s=null;try{s=await t.json()}catch{s=null}if(t.ok){await t2(),z(!1);return}F(s?.error||"Failed to save connection")}catch(e){(0,P.s)("Error saving connection:",e),F("Failed to save connection")}},sp=async e=>{try{await (0,ex.x)(`/api/providers/${ea.id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}),await t2(),X(!1)}catch(e){(0,P.s)("Error updating connection:",e)}},sx=async(e,t)=>{try{await (0,ex.x)(`/api/providers/${e}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({isActive:t})}),f(s=>s.map(s=>s.id===e?{...s,isActive:t}:s))}catch(e){(0,P.s)("Error updating connection status:",e)}},sh=async e=>{let t,s=e?.providerSpecificData?.baseUrl;if(s){try{t=new URL(s).hostname.toLowerCase().replace(/^\[|\]$/g,"")}catch{(0,P.s)("Cannot allow-list: invalid base URL",s);return}try{let e=await fetch("/api/settings",{cache:"no-store"});if(!e.ok)throw Error(`Failed to load settings (${e.status})`);let s=await e.json(),a=[...new Set([...s.ssrfAllowHosts||[],t])],r=await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({ssrfAllowHosts:a})});if(!r.ok)throw Error(`Failed to update allow list (${r.status})`);await t2()}catch(e){(0,P.s)("Error adding host to allow list:",e)}}},sf=async(e,t)=>{let s=[...h];[s[e],s[t]]=[s[t],s[e]],f(s);try{if((await Promise.all([fetch(`/api/providers/${s[e].id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({priority:e})}),fetch(`/api/providers/${s[t].id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({priority:t})})])).some(e=>!e.ok))throw Error("Failed to reorder connections")}catch(e){(0,P.s)("Error swapping priority:",e),await t2()}},sg=h.length>0&&g.length===h.length,sb=(0,a.jsx)("div",{className:"flex min-w-0 flex-col divide-y divide-black/[0.03] dark:divide-white/[0.03] max-h-[500px] overflow-y-auto pr-1",children:h.map((e,t)=>(0,a.jsxs)("div",{className:"flex min-w-0 items-stretch",children:[(0,a.jsx)("div",{className:"flex shrink-0 items-center pl-1 sm:pl-2",children:(0,a.jsx)("input",{type:"checkbox",checked:g.includes(e.id),onChange:()=>{var t;return t=e.id,void b(e=>e.includes(t)?e.filter(e=>e!==t):[...e,t])},className:"h-4 w-4 rounded border-gray-300 text-primary focus:ring-primary"})}),(0,a.jsx)("div",{className:"flex-1 min-w-0",children:(0,a.jsx)(J,{connection:e,isOAuth:tC,isFirst:0===t,isLast:t===h.length-1,onMoveUp:()=>sf(t,t-1),onMoveDown:()=>sf(t,t+1),onToggleActive:t=>sx(e.id,t),autoPing:eg[p]&&"oauth"===e.authType?{isActive:!0===eF.connections[e.id]||eF.schedules?.[e.id]?.enabled===!0,reactiveOn:!0===eF.connections[e.id],provider:p,scheduleOn:eF.schedules?.[e.id]?.enabled===!0,scheduleSummary:(0,eu.JW)(eF.schedules?.[e.id]).join(" / "),onConfigure:()=>eL(e)}:null,onEdit:()=>{er(e),X(!0)},onDelete:()=>sc(e.id),onAllowlistHost:()=>sh(e),oneByOneStatus:e7[e.id]||null})})]},e.id))}),sy=async e=>{if(!eS.has(e)){e$(t=>new Set(t).add(e));try{let t=await fetch("/api/models/test",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({model:`${tB}/${e}`})}),s=await t.json();ej(t=>({...t,[e]:s.ok?"ok":"error"})),ek(s.ok?"":s.error||"Model not reachable")}catch{ej(t=>({...t,[e]:"error"})),ek("Network error")}finally{e$(t=>{let s=new Set(t);return s.delete(e),s})}}};return y?(0,a.jsxs)("div",{className:"flex flex-col gap-8",children:[(0,a.jsx)(d.Qv,{}),(0,a.jsx)(d.Qv,{})]}):tk?(0,a.jsxs)("div",{className:"flex min-w-0 flex-col gap-6 px-1 sm:gap-8 sm:px-0",children:[(0,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsxs)(l(),{href:"/dashboard/providers",className:"inline-flex items-center gap-1 text-sm text-text-muted hover:text-primary transition-colors mb-4",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-lg",children:"arrow_back"}),"Back to Providers"]}),(0,a.jsxs)("div",{className:"flex min-w-0 items-center gap-3 sm:gap-4",children:[(0,a.jsx)("div",{className:"flex size-12 shrink-0 items-center justify-center rounded-lg",style:{backgroundColor:`${tk.color}15`},children:eb?(0,a.jsx)("span",{className:"text-sm font-bold",style:{color:tk.color},children:tk.textIcon||tk.id.slice(0,2).toUpperCase()}):(0,a.jsx)(o.default,{src:tR&&tk.apiType?"responses"===tk.apiType?"/providers/oai-r.png":"/providers/oai-cc.png":tE?"/providers/anthropic-m.png":`/providers/${tk.id}.png`,alt:tk.name,width:48,height:48,className:"max-h-12 max-w-12 rounded-lg object-contain",sizes:"48px",onError:()=>ey(!0)})}),(0,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsxs)("div",{className:"flex items-center gap-3 flex-wrap",children:[(0,a.jsx)("h1",{className:"truncate text-2xl font-semibold tracking-tight sm:text-3xl",children:tk.name}),(tk.notice?.apiKeyUrl||tk.notice?.signupUrl||tk.website)&&(0,a.jsxs)("a",{href:tk.notice?.apiKeyUrl||tk.notice?.signupUrl||tk.website,target:"_blank",rel:"noopener noreferrer",className:"text-xs text-primary hover:underline inline-flex items-center gap-1",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-sm",children:"open_in_new"}),tk.notice?.apiKeyUrl?"Get API Key":"Sign up / Learn more"]})]}),(0,a.jsxs)("p",{className:"text-text-muted",children:[h.length," connection",1===h.length?"":"s"]})]})]})]}),tk.deprecated&&(0,a.jsxs)("div",{className:"flex items-start gap-3 rounded-xl border border-amber-500/25 bg-amber-500/8 px-4 py-3 text-xs text-amber-600 dark:text-amber-400",children:[(0,a.jsx)("span",{className:"material-symbols-outlined shrink-0 text-base text-amber-500 mt-0.5",children:"warning"}),(0,a.jsx)("p",{className:"leading-relaxed font-normal",children:String(tk.deprecationNotice).replace(/^⚠️\s*⚠️?\s*/,"")})]}),tk.notice?.text&&!tk.deprecated&&(0,a.jsxs)("div",{className:"flex flex-col gap-2 rounded-lg border border-blue-500/30 bg-blue-500/10 px-3 py-2 sm:flex-row sm:items-center",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[16px] text-blue-500 shrink-0",children:"info"}),(0,a.jsx)("p",{className:"min-w-0 flex-1 text-xs leading-relaxed text-blue-600 dark:text-blue-400",children:tk.notice.text}),tk.notice.apiKeyUrl&&(0,a.jsx)("a",{href:tk.notice.apiKeyUrl,target:"_blank",rel:"noopener noreferrer",className:"inline-flex justify-center rounded bg-blue-500 px-2 py-1 text-xs font-medium text-white transition-colors hover:bg-blue-600 sm:py-0.5",children:"Get API Key →"})]}),tI&&j&&(0,a.jsx)(d.Zp,{children:(0,a.jsxs)("div",{className:"mb-4 flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between",children:[(0,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsx)("h2",{className:"text-lg font-semibold",children:tE?"Anthropic Compatible Details":"OpenAI Compatible Details"}),(0,a.jsxs)("p",{className:"break-all text-sm text-text-muted",children:[tE?"Messages API":"responses"===j.apiType?"Responses API":"Chat Completions"," \xb7 ",(j.baseUrl||"").replace(/\/$/,""),"/",tE?"messages":"responses"===j.apiType?"responses":"chat/completions"]})]}),(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-2 sm:flex sm:items-center",children:[(0,a.jsx)(d.$n,{size:"sm",icon:"add",onClick:()=>{F(""),z(!0)},className:"w-full sm:w-auto",children:"Add API Key"}),(0,a.jsx)(d.$n,{size:"sm",variant:"secondary",icon:"edit",onClick:()=>es(!0),className:"w-full sm:w-auto",children:"Edit"}),(0,a.jsx)(d.$n,{size:"sm",variant:"secondary",icon:"delete",onClick:async()=>{eY({title:"Delete Compatible Node",message:`Delete this ${tE?"Anthropic":"OpenAI"} Compatible node?`,onConfirm:async()=>{eY(null);try{await (0,ex.x)(`/api/provider-nodes/${p}`,{method:"DELETE"}),u.push("/dashboard/providers")}catch(e){(0,P.s)("Error deleting provider node:",e)}}})},className:"w-full sm:w-auto",children:"Delete"})]})]})}),t$?(0,a.jsx)(d.gw,{providerId:p}):(0,a.jsxs)(d.Zp,{children:[(0,a.jsxs)("div",{className:"mb-4 flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[(0,a.jsx)("h2",{className:"text-lg font-semibold",children:"Connections"}),(0,a.jsxs)("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:gap-4",children:[h.length>0&&(0,a.jsxs)(a.Fragment,{children:[g.length>0&&(0,a.jsxs)(d.$n,{size:"sm",variant:"danger",icon:"delete",onClick:()=>{let e=g.length;0!==e&&eY({title:`Delete ${e} Connection${e>1?"s":""}`,message:`Delete ${e} connection${e>1?"s":""}? This cannot be undone.`,onConfirm:async()=>{eY(null);let e=0,t=[...g],s=[];for(let a of t)try{(await fetch(`/api/providers/${a}`,{method:"DELETE"})).ok?s.push(a):e+=1}catch(t){(0,P.s)("Error deleting connection:",t),e+=1}f(e=>e.filter(e=>!s.includes(e.id))),b([]),e>0&&(0,P.s)(`Deleted ${t.length-e} connection(s), ${e} failed.`)}})},children:["Delete Selected (",g.length,")"]}),(0,a.jsx)(d.$n,{size:"sm",variant:"secondary",icon:"sync",onClick:sd,disabled:e2,children:e2?"Testing Connection One-by-One...":"Test Connection One-by-One"}),e2&&(0,a.jsx)(d.$n,{size:"sm",variant:"ghost",icon:"stop",onClick:()=>{e2&&(ts.current=!0,e4(!0))},disabled:e3,children:e3?"Stopping...":"Stop"})]}),(0,a.jsxs)("div",{className:"flex flex-col gap-2 rounded-xl border border-border/60 bg-surface-2/40 p-3",children:[(0,a.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("span",{className:"text-xs font-medium text-text-main",children:"Balanced Scheduler"}),(0,a.jsx)(d.m_,{text:"Process-local least-inflight scheduling with fresh quota signals. Sessions stay on one account and rebind on failure, cooldown, or cap.",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[15px] text-text-muted cursor-help",children:"info"})})]}),(0,a.jsxs)("div",{className:"flex items-center gap-3",children:[eD&&(0,a.jsxs)("label",{className:"flex items-center gap-1.5 text-xs text-text-muted",children:["Affinity",(0,a.jsx)("input",{"aria-label":"Session affinity minutes",type:"number",min:1,max:1440,value:eP,onChange:e=>se(e.target.value),className:"w-14 px-2 py-0.5 text-xs border border-border rounded-md bg-background text-text-main focus:outline-none focus:border-primary"}),(0,a.jsx)("span",{className:"text-[11px]",children:"min"})]}),(0,a.jsx)(d.lM,{checked:eD,onChange:t9,"aria-label":"Balanced scheduler"})]})]}),(0,a.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-3 pt-2 border-t border-border/40",title:eD?"Saved and used again when balanced scheduling is off":void 0,children:[(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("span",{className:"text-xs font-medium text-text-main",children:"Round Robin"}),(0,a.jsx)(d.m_,{text:"Cycles through connections sequentially in round-robin fashion.",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[15px] text-text-muted cursor-help",children:"info"})})]}),(0,a.jsxs)("div",{className:"flex items-center gap-3",children:["round-robin"===eO&&(0,a.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,a.jsx)("span",{className:"text-xs text-text-muted",children:"Sticky:"}),(0,a.jsx)("input",{type:"number",min:1,value:eE,onChange:e=>t7(e.target.value),placeholder:"1",disabled:eD,title:eD?"Saved and used again when balanced scheduling is off":void 0,className:"w-14 px-2 py-0.5 text-xs border border-border rounded-md bg-background text-text-main focus:outline-none focus:border-primary disabled:cursor-not-allowed disabled:opacity-50"})]}),(0,a.jsx)(d.lM,{checked:"round-robin"===eO,onChange:t8,"aria-label":"Round Robin",disabled:eD,title:eD?"Saved and used again when balanced scheduling is off":void 0})]})]})]})]})]}),0===h.length?(0,a.jsxs)("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[(0,a.jsxs)("div",{className:"flex items-center gap-3",children:[(0,a.jsx)("div",{className:"inline-flex items-center justify-center w-9 h-9 rounded-full bg-primary/10 text-primary shrink-0",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:tC?"lock":"key"})}),(0,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsx)("p",{className:"text-sm text-text-muted",children:"No connections yet"}),tP&&(0,a.jsxs)("p",{className:"text-xs text-text-muted",children:["Choose ",tz," or ",tU,"."]})]})]}),(0,a.jsx)("div",{className:"flex gap-2",children:tP?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(d.$n,{size:"sm",icon:"lock",variant:"secondary",onClick:tF,children:tz}),(0,a.jsx)(d.$n,{size:"sm",icon:"key",onClick:t_,children:tU})]}):(0,a.jsxs)(a.Fragment,{children:[!tI&&ef.has(p)&&(0,a.jsx)(B,{providerId:p,onConnected:t2}),!tI&&"iflow"===p&&(0,a.jsx)(d.$n,{size:"sm",icon:"cookie",variant:"secondary",onClick:()=>I(!0),children:"Cookie"}),"codex"===p&&(0,a.jsx)(d.$n,{size:"sm",icon:"playlist_add",variant:"secondary",onClick:()=>L(!0),children:(0,A.Tl)("Bulk Add")}),"grok-cli"===p&&(0,a.jsx)(d.$n,{size:"sm",icon:"playlist_add",variant:"secondary",onClick:()=>Z(!0),children:(0,A.Tl)("Bulk Add")}),(0,a.jsx)(d.$n,{size:"sm",icon:"add",onClick:tJ,children:tI?"Add API Key":"iflow"===p?"OAuth":"Add Connection"})]})})]}):(0,a.jsxs)(a.Fragment,{children:[te&&(0,a.jsx)("div",{className:"mb-4 rounded-lg border border-black/10 bg-black/[0.02] px-3 py-2 text-xs text-text-muted dark:border-white/10 dark:bg-white/[0.03]",children:(0,a.jsxs)("div",{className:"flex flex-wrap items-center gap-3",children:[(0,a.jsxs)("span",{children:["Total: ",te.total]}),(0,a.jsxs)("span",{children:["Completed: ",te.completed]}),(0,a.jsxs)("span",{children:["Passed: ",te.passed]}),(0,a.jsxs)("span",{children:["Failed: ",te.failed]}),te.stopped&&(0,a.jsx)("span",{className:"text-amber-600 dark:text-amber-400",children:"Stopped"}),e2&&e6&&(0,a.jsxs)("span",{children:["Running: ",h.find(e=>e.id===e6)?.name||e6]})]})}),h.length>0&&(0,a.jsx)("div",{className:"mb-3 flex items-center gap-2 border-b border-black/[0.03] pb-2 dark:border-white/[0.03]",children:(0,a.jsxs)("label",{className:"flex cursor-pointer items-center gap-1.5 text-xs text-text-muted hover:text-primary",children:[(0,a.jsx)("input",{type:"checkbox",checked:sg,onChange:()=>{sg?b([]):b(h.map(e=>e.id))},className:"h-3.5 w-3.5 rounded border-gray-300 text-primary focus:ring-primary"}),"Select All"]})}),sb,!tI&&(0,a.jsxs)("div",{className:"mt-4 grid grid-cols-1 gap-2 sm:flex",children:["iflow"===p&&(0,a.jsx)(d.$n,{size:"sm",icon:"cookie",variant:"secondary",onClick:()=>I(!0),title:"Add connection using browser cookie",className:"w-full sm:w-auto",children:"Cookie"}),"codex"===p&&(0,a.jsx)(d.$n,{size:"sm",icon:"playlist_add",variant:"secondary",onClick:()=>L(!0),title:(0,A.Tl)("Bulk import codex accounts from JSON"),className:"w-full sm:w-auto",children:(0,A.Tl)("Bulk Add")}),"grok-cli"===p&&(0,a.jsx)(d.$n,{size:"sm",icon:"playlist_add",variant:"secondary",onClick:()=>Z(!0),title:(0,A.Tl)("Bulk import Grok CLI accounts from JSON"),className:"w-full sm:w-auto",children:(0,A.Tl)("Bulk Add")}),tP?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(d.$n,{size:"sm",icon:"lock",variant:"secondary",onClick:tF,className:"w-full sm:w-auto",children:tz}),(0,a.jsx)(d.$n,{size:"sm",icon:"key",onClick:t_,className:"w-full sm:w-auto",children:tU})]}):(0,a.jsxs)(a.Fragment,{children:[ef.has(p)&&(0,a.jsx)(B,{providerId:p,onConnected:t2}),(0,a.jsx)(d.$n,{size:"sm",icon:"add",onClick:tJ,className:"w-full sm:w-auto",children:"Add"})]})]})]})]}),(0,a.jsx)(en,{providerId:p,scheduleKey:tH},p),(0,a.jsx)(ec,{providerId:p}),(0,a.jsxs)(d.Zp,{children:[(0,a.jsxs)("div",{className:"mb-4 flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between",children:[(0,a.jsxs)("div",{className:"flex items-center gap-3",children:[(0,a.jsx)("h2",{className:"text-lg font-semibold",children:"Available Models"}),tK&&(0,a.jsx)("select",{value:eU,onChange:e=>{var t;eq(t=e.target.value),st(t)},title:"Appends (level) suffix to copied model names",className:"rounded-md border border-border bg-background px-2 py-1 text-xs focus:border-primary focus:outline-none",children:tK.map(e=>(0,a.jsx)("option",{value:e,children:`Thinking: ${e.charAt(0).toUpperCase()+e.slice(1)}`},e))})]}),tM.showToolbar&&(e=(tM.showBulkControls?[...tT,...eV.filter(e=>!tT.some(t=>t.id===e.id))].filter(e=>{let t=(0,m.CP)(e);return!t||"llm"===t}).map(e=>e.id):[]).filter(e=>!tV(e)),(0,a.jsxs)("div",{className:"flex flex-wrap gap-2",children:[tM.showImport&&(0,a.jsx)(d.$n,{size:"sm",variant:"secondary",icon:tn?"progress_activity":"cloud_download",onClick:so,disabled:tn||!tD,title:tD?"Import models from the active connection":"Add an active connection to import models",children:tn?"Importing...":"Import models"}),tM.showVerify&&(0,a.jsx)(d.$n,{size:"sm",variant:"secondary",icon:tu?.status==="running"?"progress_activity":"science",onClick:()=>tm(e=>!e),children:tu?.status==="running"?`Verifying ${tu.done}/${tu.total}`:tc?"Hide verify":"Verify models"}),tM.showBulkControls&&eG.length>0&&(0,a.jsx)(d.$n,{size:"sm",variant:"secondary",icon:"restart_alt",onClick:tY,children:"Active All"}),tM.showBulkControls&&e.length>0&&(0,a.jsx)(d.$n,{size:"sm",variant:"secondary",icon:"block",onClick:()=>tX(e),children:"Disable All"})]}))]}),!!ew&&(0,a.jsx)("p",{className:"text-xs text-red-500 mb-3 break-words",children:ew}),"zed"===p&&!!eN&&(0,a.jsx)("p",{className:"text-xs text-red-500 mb-3 break-words",children:eN}),to&&(0,a.jsxs)("div",{className:"mb-3 flex items-center justify-between gap-2 rounded-xl border border-primary/30 bg-primary/10 px-3.5 py-2 text-xs font-medium text-text-main",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[16px] text-primary",children:"info"}),(0,a.jsx)("span",{children:to})]}),(0,a.jsx)("button",{onClick:()=>td(""),className:"text-text-muted hover:text-text-main p-0.5 rounded",title:"Dismiss",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-sm",children:"close"})})]}),tc&&(t=h.find(e=>g.includes(e.id)&&!1!==e.isActive)||h.find(e=>!1!==e.isActive),s=[...(0,R.R3)({customModels:eo,modelAliases:ei,providerAlias:tB,builtInModels:tT,type:"llm"}).filter(e=>!tV(e.id)).map(e=>({id:e.id,name:e.name||e.id,kind:"llm"})),...tT.filter(e=>{let t=(0,m.CP)(e);return(!t||"llm"===t)&&!tV(e.id)}).map(e=>({id:e.id,name:e.name||e.id,kind:"llm"}))],(0,a.jsx)(et,{connectionId:t?.id,providerAlias:tB,models:s,jobSnapshot:tu,onClose:()=>tm(!1),onStarted:e=>{tp(e&&e.status?e:null);let s=e?.connectionId||t?.id;s&&sa(s)},onComplete:async e=>{e?.removedStatus&&tp(t=>t?{...t,dead:Number(e.dead??t.dead??0),retryable:Number(e.retryable??t.retryable??0),retryableAuthOnly:!0===e.retryableAuthOnly}:t),e?.removed>0&&await t1(),e?.removed>0&&await tZ(),(e?.removed>0||e?.cacheCleared)&&await t5(t?.id)}})),(()=>{let e,t,s;if(tI)return(0,a.jsx)(q,{providerStorageAlias:tB,providerDisplayAlias:tH,modelAliases:ei,customModels:eo,copied:tv,onCopy:tj,onSetAlias:sr,onDeleteAlias:si,onAddCustomModel:e=>sn(e,"llm",tB),onDeleteCustomModel:e=>sl(e,"llm",tB),onRefreshModels:t1,connections:h,isAnthropic:tE,disabledModelIds:eG,onEnableModel:tQ});let r=[...tT,...eV.filter(e=>!tT.some(t=>t.id===e.id))].filter(e=>{let t=(0,m.CP)(e);return!t||"llm"===t}),i=r.filter(e=>!tV(e.id)),n=r.filter(e=>tV(e.id)),l=(0,R.R3)({customModels:eo,modelAliases:ei,providerAlias:tB,builtInModels:tT,type:"llm"}),o=l.filter(e=>!tV(e.id)&&("all"===tb||(tf[(0,ep.v)(e.id,tB)]||null)===tb)),d=i.filter(e=>"all"===tb||(tf[(0,ep.v)(e.id,tB)]||null)===tb);return(0,a.jsxs)("div",{className:"flex flex-col gap-3",children:[(0,a.jsx)("div",{className:"mb-2 flex flex-wrap items-center gap-1.5 text-xs",children:[{id:"all",label:"All",count:i.length+l.filter(e=>!tV(e.id)).length},{id:"ok",label:"Reachable",count:[...i,...l].filter(e=>!tV(e.id)&&("ok"===tf[(0,ep.v)(e.id,tB)]||"ok"===ev[e.id])).length},{id:"dead",label:"Dead",count:[...i,...l].filter(e=>!tV(e.id)&&("dead"===tf[(0,ep.v)(e.id,tB)]||"error"===ev[e.id])).length},{id:"retry",label:"Retry",count:[...i,...l].filter(e=>!tV(e.id)&&"retry"===tf[(0,ep.v)(e.id,tB)]).length}].map(e=>(0,a.jsxs)("button",{onClick:()=>ty(e.id),className:`inline-flex items-center gap-1.5 rounded-lg px-2.5 py-1 text-xs font-medium transition-all ${tb===e.id?"bg-primary text-black font-semibold shadow-sm":"bg-surface-2/60 border border-border/40 text-text-muted hover:border-border hover:text-text-main"}`,children:[(0,a.jsx)("span",{children:e.label}),(0,a.jsx)("span",{className:`rounded-full px-1.5 py-0.2 text-[10px] tabular-nums ${tb===e.id?"bg-black/20 text-black font-bold":"bg-black/10 dark:bg-white/10 text-text-muted"}`,children:e.count})]},e.id))}),(0,a.jsxs)("div",{className:"flex flex-wrap gap-3",children:[o.map(e=>{let t=(0,ep.v)(e.id,tB);return(0,a.jsx)(M,{model:{id:e.id,name:e.name},fullModel:`${tH}/${e.id}`,alias:e.alias,copied:tv,onCopy:tj,onSetAlias:()=>{},onDeleteAlias:()=>{"custom"===e.source?sl(e.id,"llm",tB):si(e.alias)},testStatus:ev[e.id],onTest:h.length>0||t$?()=>sy(e.id):void 0,isTesting:eS.has(e.id),isCustom:!0,isFree:!1,caps:x(`${p}/${e.id}`),thinkingSuffix:tL(e.id),latencyMs:tx[e.id]??tx[t],probeState:tu?.status==="running"&&tu?.perModel?.[t]?tu.perModel[t]:tf[t]||null},`${e.source}-${e.fullModel}`)}),d.map(e=>{let t=`${tB}/${e.id}`,s=`${p}/${e.id}`,r=Object.entries(ei).find(([,e])=>e===t||e===s)?.[0],i=(0,ep.v)(e.id,tB);return(0,a.jsx)(M,{model:e,fullModel:`${tH}/${e.id}`,alias:r,copied:tv,onSetAlias:t=>sr(e.id,t,tB),onCopy:tj,onDeleteAlias:()=>si(r),testStatus:ev[e.id],onTest:h.length>0||t$?()=>sy(e.id):void 0,isTesting:eS.has(e.id),isFree:e.isFree,onDisable:()=>tG(e.id),caps:x(`${p}/${e.id}`),thinkingSuffix:tL(e.id),latencyMs:tx[e.id]??tx[i],probeState:tu?.status==="running"&&tu?.perModel?.[i]?tu.perModel[i]:tf[i]||null},e.id)}),(0,a.jsxs)("button",{onClick:()=>eT(!0),className:"flex min-h-[58px] min-w-[200px] flex-1 items-center justify-center gap-2 rounded-xl border border-dashed border-primary/40 bg-primary/5 px-4 py-3 text-xs font-medium text-primary transition-all hover:border-primary hover:bg-primary/10 hover:shadow-soft sm:flex-none",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:"add_circle"}),"Add Custom Model"]}),eK.length>0&&(e=new Set([...Object.values(ei),...l.map(e=>e.fullModel)]),t=new Set(tT.map(e=>e.id)),0===(s=eK.filter(s=>!e.has(`${tB}/${s.id}`)&&!t.has(s.id))).length?null:(0,a.jsxs)("div",{className:"w-full mt-2",children:[(0,a.jsx)("p",{className:"text-xs text-text-muted mb-2",children:"Suggested free models (≥200k context):"}),(0,a.jsx)("div",{className:"flex flex-wrap gap-2",children:s.map(e=>(0,a.jsxs)("button",{onClick:async()=>{await sn(e.id,"llm",tB)},className:"flex items-center gap-1 px-2.5 py-1.5 rounded-lg border border-black/10 dark:border-white/10 text-xs text-text-muted hover:text-primary hover:border-primary/40 hover:bg-primary/5 transition-colors",title:`${e.name} \xb7 ${(e.contextLength/1e3).toFixed(0)}k ctx`,children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[13px]",children:"add"}),e.id.split("/").pop()]},e.id))})]})),n.length>0&&(0,a.jsxs)("div",{className:"w-full mt-2",children:[(0,a.jsxs)("p",{className:"text-xs text-text-muted mb-2",children:["Disabled models (",n.length,"):"]}),(0,a.jsx)("div",{className:"flex flex-wrap gap-2",children:n.map(e=>(0,a.jsxs)("button",{onClick:()=>tQ(e.id),className:"flex items-center gap-1 px-2.5 py-1.5 rounded-lg border border-dashed border-black/10 dark:border-white/10 text-xs text-text-muted hover:text-primary hover:border-primary/40 hover:bg-primary/5 transition-colors",title:"Restore model",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[13px]",children:"add"}),e.id]},e.id))})]})]})]})})()]}),"kiro"===p?(0,a.jsx)(d.Mh,{isOpen:k,providerInfo:tk,onSuccess:sm,onClose:()=>N(!1)}):"cursor"===p?(0,a.jsx)(d.G9,{isOpen:k,onSuccess:sm,onClose:()=>N(!1)}):"zed"===p?(0,a.jsx)(d.TE,{isOpen:k,providerInfo:tk,onSuccess:sm,onClose:()=>N(!1)}):"gitlab"===p?(0,a.jsx)(d.vj,{isOpen:k,providerInfo:tk,onSuccess:sm,onClose:()=>N(!1)}):(0,a.jsx)(d.LF,{isOpen:k,provider:p,providerInfo:tk,onSuccess:sm,onClose:()=>N(!1)}),"iflow"===p&&(0,a.jsx)(d.vE,{isOpen:T,onSuccess:()=>{t2(),I(!1)},onClose:()=>I(!1)}),(0,a.jsx)(K,{isOpen:D,provider:p,providerName:tk.name,isCompatible:tI,isAnthropic:tE,authType:tk?.authType,authHint:tk?.authHint,website:tk?.website,error:U,onSave:su,onBulkDone:t2,onClose:()=>{F(""),z(!1)}}),(0,a.jsx)(d.wI,{isOpen:Q,connection:ea,onSave:sp,onClose:()=>X(!1)}),tI&&(0,a.jsx)(H,{isOpen:ee,node:j,onSave:t3,onClose:()=>es(!1),isAnthropic:tE}),!tI&&(0,a.jsx)(V,{isOpen:eA,providerAlias:tB,providerDisplayAlias:tH,onSave:async(e,t,s,a)=>{await sn(e,s||"llm",tB,t,a),eT(!1)},onClose:()=>eT(!1)}),"codex"===p&&(0,a.jsx)(G,{isOpen:_,onClose:()=>L(!1),onSuccess:t2}),"grok-cli"===p&&(0,a.jsx)(Y,{isOpen:W,onClose:()=>Z(!1),onSuccess:t2}),eJ&&(0,a.jsx)(em.A,{isOpen:!!eJ,onClose:()=>eL(null),connection:eJ,reactive:!0===eF.connections[eJ.id],schedule:eF.schedules?.[eJ.id]||null,onSave:e=>((e,{reactive:t,schedule:s})=>{ss({...eF,connections:{...eF.connections,[e]:t},schedules:{...eF.schedules,[e]:s}})})(eJ.id,e)}),(0,a.jsx)(d.uo,{isOpen:e0,onClose:()=>e1(!1),onConfirm:()=>{(window.localStorage.setItem(tw,"true"),e1(!1),tC)?tq():t_()},title:"Risk Notice",message:tk?.deprecationNotice,confirmText:"I Understand, Continue",cancelText:"Cancel",variant:"danger"}),(0,a.jsx)(d.uo,{isOpen:!!eX,onClose:()=>eY(null),onConfirm:eX?.onConfirm,title:eX?.title||"Confirm",message:eX?.message,variant:"danger"})]}):(0,a.jsxs)("div",{className:"text-center py-20",children:[(0,a.jsx)("p",{className:"text-text-muted",children:"Provider not found"}),(0,a.jsx)(l(),{href:"/dashboard/providers",className:"text-primary mt-4 inline-block",children:"Back to Providers"})]})}},93195:(e,t,s)=>{"use strict";function a(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone||"UTC"}catch{return"UTC"}}s.d(t,{JW:()=>o,Vm:()=>a,fB:()=>i,gy:()=>r,nz:()=>n});let r={anchor:"09:30",timezone:a(),windowHours:5,slotsPerDay:3};function i(e){let t=/^(\d{1,2}):(\d{2})$/.exec(String(e||"").trim());if(!t)return null;let s=Number(t[1]),a=Number(t[2]);return s>23||a>59?null:{hour:s,minute:a}}function n(e){return Math.max(1,Math.floor(24/e))}function l(e,t,s,a){let r="number"==typeof e?e:Number(e);return Number.isFinite(r)?Math.min(a,Math.max(s,r)):t}function o(e){let t=function(e){if(!e||!0!==e.enabled)return null;let t=i(e.anchor)||i(r.anchor),s=`${String(t.hour).padStart(2,"0")}:${String(t.minute).padStart(2,"0")}`,a=!function(e){if(!e||"string"!=typeof e)return!1;try{return new Intl.DateTimeFormat("en-US",{timeZone:e}),!0}catch{return!1}}(e.timezone)?r.timezone:e.timezone,o=l(e.windowHours,r.windowHours,.5,24),d=Math.round(l(e.slotsPerDay,r.slotsPerDay,1,n(o)));return{enabled:!0,anchor:s,timezone:a,windowHours:o,slotsPerDay:d}}(e);if(!t)return[];let{hour:s,minute:a}=i(t.anchor),o=60*s+a;return Array.from({length:t.slotsPerDay},(e,s)=>{let a=Math.round(o+s*t.windowHours*60)%1440;return`${String(Math.floor(a/60)).padStart(2,"0")}:${String(a%60).padStart(2,"0")}`})}},97132:(e,t,s)=>{"use strict";s.d(t,{A:()=>m});var a=s(95155),r=s(12115),i=s(14051),n=s.n(i),l=s(35497),o=s(31474),d=s(93195);let c=[{value:"off",label:"Off",icon:"block"},{value:"reset",label:"On reset",icon:"bolt"},{value:"schedule",label:"Schedule",icon:"schedule"}];function m({isOpen:e,onClose:t,onSave:s,connection:i,reactive:n=!1,schedule:u=null}){let[p,x]=(0,r.useState)(()=>({mode:u?.enabled===!0?"schedule":!0===n?"reset":"off",anchor:u?.anchor||d.gy.anchor,timezone:(0,d.Vm)(),windowHours:String(u?.windowHours??d.gy.windowHours),slotsPerDay:String(u?.slotsPerDay??d.gy.slotsPerDay)})),h=Number(p.windowHours),f=Number(p.slotsPerDay),g=!!(0,d.fB)(p.anchor),b=Number.isFinite(h)&&h>=.5&&h<=24,y=b?(0,d.nz)(h):24,v=Number.isInteger(f)&&f>=1&&f<=y,j=g&&b&&v,w="schedule"!==p.mode||j,k=j?(0,d.JW)({enabled:!0,...p,windowHours:h,slotsPerDay:f}):[],N=k.length&&b?(()=>{let{hour:e,minute:t}=(0,d.fB)(p.anchor),s=Math.round(60*e+t+f*h*60)%1440;return`${String(Math.floor(s/60)).padStart(2,"0")}:${String(s%60).padStart(2,"0")}`})():"",C=e=>x(t=>({...t,...e}));return(0,a.jsx)(l.aF,{isOpen:e,onClose:t,title:"Auto-ping settings",size:"lg",footer:(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(l.$n,{variant:"secondary",onClick:t,children:"Cancel"}),(0,a.jsx)(l.$n,{onClick:()=>{w&&(s({reactive:"reset"===p.mode,schedule:"schedule"===p.mode?{enabled:!0,anchor:p.anchor,timezone:p.timezone,windowHours:h,slotsPerDay:f}:{enabled:!1}}),t())},disabled:!w,children:"Save"})]}),children:(0,a.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,a.jsxs)("p",{className:"text-sm text-text-muted",children:["Configure automated quota pings",i?.name?` for ${i.name}`:""," — pick one mode."]}),(0,a.jsx)("div",{className:"grid grid-cols-3 gap-1 rounded-[10px] bg-surface-2 p-1",children:c.map(e=>{let t=p.mode===e.value;return(0,a.jsxs)("button",{type:"button",onClick:()=>C({mode:e.value}),className:(0,o.cn)("flex h-9 items-center justify-center gap-1.5 rounded-[8px] px-3 text-sm font-medium transition-all",t?"bg-surface text-text-main shadow-sm":"text-text-muted hover:text-text-main"),children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[15px] leading-none",children:e.icon}),(0,a.jsx)("span",{children:e.label})]},e.value)})}),"reset"===p.mode&&(0,a.jsx)("p",{className:"text-xs text-text-muted",children:"Pings right after the 5h quota window resets, so a new window starts immediately."}),"schedule"===p.mode&&(0,a.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,a.jsx)("p",{className:"text-xs text-text-muted",children:"Pings at fixed local times so the 5h windows align with your workday."}),(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-4 sm:grid-cols-3",children:[(0,a.jsx)(l.pd,{label:"Anchor time",type:"time",value:p.anchor,onChange:e=>C({anchor:e.target.value}),error:g?"":"Use HH:MM",inputClassName:"ring-1 ring-black/10 dark:ring-white/15"}),(0,a.jsx)(l.pd,{label:"Window (hours)",type:"number",min:"0.5",max:"24",step:"0.5",value:p.windowHours,onChange:e=>C({windowHours:e.target.value}),error:b?"":"0.5 – 24",inputClassName:"ring-1 ring-black/10 dark:ring-white/15"}),(0,a.jsx)(l.pd,{label:"Pings per day",type:"number",min:"1",max:String(y),step:"1",value:p.slotsPerDay,onChange:e=>C({slotsPerDay:e.target.value}),error:v?"":`1 – ${y}`,hint:v?`Max ${y}`:"",inputClassName:"ring-1 ring-black/10 dark:ring-white/15"})]}),k.length>0&&(0,a.jsxs)("div",{className:"rounded-[10px] bg-surface-2 px-3 py-2.5",children:[(0,a.jsxs)("p",{className:"text-xs font-medium uppercase tracking-wide text-text-muted",children:["Daily slots (",p.timezone,")"]}),(0,a.jsx)("p",{className:"mt-1 text-sm font-medium text-text-main",children:k.join(" → ")}),(0,a.jsxs)("p",{className:"mt-1 text-xs text-text-muted",children:["Covers ",k[0]," – ",N,", then pauses until ",k[0]," next day."]})]})]})]})})}m.propTypes={isOpen:n().bool.isRequired,onClose:n().func.isRequired,onSave:n().func.isRequired,connection:n().object,reactive:n().bool,schedule:n().object}}},e=>{e.O(0,[782,8500,7854,4601,1321,2410,979,8441,3794,7358],()=>e(e.s=7687)),_N_E=e.O()}]);
|
|
28
|
+
]`;function X(e){let t,s=e.trim();if(!s)return[];try{t=JSON.parse(s)}catch(e){try{let e=s;e.startsWith("[")||((e=e.replace(/\}\s*,\s*\{/g,"},{").replace(/\}\s*\{/g,"},{")).endsWith(",")&&(e=e.slice(0,-1)),e=`[${e}]`),t=JSON.parse(e)}catch{throw e}}if(Array.isArray(t))return t;if(t&&"object"==typeof t)return Array.isArray(t.accounts)?t.accounts:[t];throw Error("Input must be a JSON object or array of objects")}function Y({isOpen:e,onClose:t,onSuccess:s}){let[i,n]=(0,r.useState)(""),[l,o]=(0,r.useState)(!1),[c,m]=(0,r.useState)(""),[u,p]=(0,r.useState)(null),[x,h]=(0,r.useState)(!1),[f,g]=(0,r.useState)(null),b=(0,r.useRef)(null),y=()=>{l||(n(""),m(""),p(null),g(null),h(!1),t())},v=async e=>{if(!e||0===e.length)return;m("");let t=Array.from(e).filter(e=>e.name.endsWith(".json")||"application/json"===e.type||""===e.type);if(0===t.length)return void m((0,A.Tl)("Please select valid .json files"));try{let e=[];for(let s of t){let t=await s.text(),a=X(t);Array.isArray(a)?e.push(...a):a&&e.push(a)}if(0===e.length)return void m((0,A.Tl)("No accounts found in selected files"));n(JSON.stringify(e,null,2)),g({filesCount:t.length,accountsCount:e.length})}catch(e){m(`${(0,A.Tl)("Error reading files")}: ${e.message}`)}},j=async()=>{let e;m(""),p(null);try{e=X(i)}catch(e){m(`${(0,A.Tl)("Invalid JSON")}: ${e.message}`);return}if(!e||0===e.length)return void m((0,A.Tl)("No accounts found in input"));o(!0);try{let t=await fetch("/api/oauth/grok-cli/bulk-import",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({accounts:e})}),a=await t.json();if(!t.ok)return void m(a?.error||`Request failed: ${t.status}`);p(a),a.success>0&&"function"==typeof s&&s()}catch(e){m(e.message||(0,A.Tl)("Request failed"))}finally{o(!1)}},w=u?.results?.filter(e=>!e.ok)||[];return(0,a.jsx)(d.aF,{isOpen:e,title:(0,A.Tl)("Bulk Add Grok CLI Accounts"),onClose:y,children:(0,a.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,a.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[(0,a.jsx)("p",{className:"text-xs text-text-muted",children:(0,A.Tl)("Upload multiple .json files or paste JSON array / object.")}),(0,a.jsx)("input",{ref:b,type:"file",accept:".json,application/json",multiple:!0,className:"hidden",onChange:e=>{v(e.target.files),e.target&&(e.target.value="")}}),(0,a.jsx)(d.$n,{type:"button",size:"sm",variant:"secondary",icon:"upload_file",onClick:()=>b.current?.click(),disabled:l,children:(0,A.Tl)("Upload JSON Files")})]}),(0,a.jsxs)("div",{onDragOver:e=>{e.preventDefault(),h(!0)},onDragLeave:e=>{e.preventDefault(),h(!1)},onDrop:e=>{e.preventDefault(),h(!1),e.dataTransfer?.files?.length>0&&v(e.dataTransfer.files)},className:`relative rounded border transition-colors ${x?"border-primary bg-primary/10 ring-2 ring-primary/30":"border-accent/30 bg-sidebar"}`,children:[(0,a.jsx)("textarea",{className:"w-full rounded bg-transparent p-2.5 text-sm font-mono resize-y min-h-[240px] focus:outline-none focus:ring-1 focus:ring-primary",placeholder:Q,value:i,onChange:e=>{n(e.target.value),g(null)},disabled:l}),x&&(0,a.jsxs)("div",{className:"absolute inset-0 flex flex-col items-center justify-center bg-sidebar/90 rounded pointer-events-none backdrop-blur-xs",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-3xl text-primary mb-1",children:"upload_file"}),(0,a.jsx)("span",{className:"text-sm font-medium text-primary",children:(0,A.Tl)("Drop .json files here")})]})]}),f&&(0,a.jsxs)("div",{className:"flex items-center gap-1.5 text-xs text-green-400 font-medium bg-green-500/10 border border-green-500/20 px-2.5 py-1.5 rounded",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-sm",children:"check_circle"}),(0,a.jsxs)("span",{children:[(0,A.Tl)("Loaded")," ",f.accountsCount," ",(0,A.Tl)("account(s) from")," ",f.filesCount," ",(0,A.Tl)("file(s)")]})]}),c&&(0,a.jsx)("p",{className:"text-xs text-red-500 break-words",children:c}),u&&(0,a.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,a.jsxs)("div",{className:`text-sm font-medium ${u.failed>0?"text-yellow-400":"text-green-400"}`,children:["✓ ",u.success," ",(0,A.Tl)("added"),u.failed>0?`, ✗ ${u.failed} ${(0,A.Tl)("failed")}`:""]}),w.length>0&&(0,a.jsx)("ul",{className:"rounded border border-accent/20 bg-sidebar/50 p-2 text-xs font-mono max-h-40 overflow-y-auto",children:w.map(e=>(0,a.jsxs)("li",{className:"text-red-400",children:["[",e.index,"] ",e.error]},e.index))})]}),(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsx)(d.$n,{onClick:j,fullWidth:!0,disabled:l||!i.trim(),children:l?(0,A.Tl)("Importing..."):(0,A.Tl)("Import All")}),(0,a.jsx)(d.$n,{onClick:y,variant:"ghost",fullWidth:!0,disabled:l,children:(0,A.Tl)("Close")})]})]})})}Y.propTypes={isOpen:D().bool.isRequired,onClose:D().func.isRequired,onSuccess:D().func};var ee=s(77251);function et({connectionId:e,providerAlias:t,models:s,jobSnapshot:i,onComplete:n,onStarted:l,onClose:o}){let[c,m]=(0,r.useState)(4),[u,p]=(0,r.useState)(50),[x,h]=(0,r.useState)(Math.round(20)),[f,g]=(0,r.useState)(!1),[b,y]=(0,r.useState)(null),[v,j]=(0,r.useState)(null),[w,k]=(0,r.useState)(""),[N,C]=(0,r.useState)(""),[S,$]=(0,r.useState)(""),A=(0,r.useRef)({onComplete:n,onStarted:l}),T=(0,r.useRef)(null),O=(0,r.useRef)(e),R=(0,r.useRef)(null),E=s?.length||0,I=(0,r.useMemo)(()=>`max concurrency 16 \xb7 batch 200 \xb7 timeout ${60}s`,[]);function D(e){if(e){if("idle"===e.status){R.current=null,g(!1);return}if(y({done:e.done||0,total:e.total||0,ok:e.ok||0,dead:e.dead||0,retryable:e.retryable||0,skippedDead:e.skippedDead||0,skippedDup:e.skippedDup||0}),"running"===e.status&&(R.current=e.connectionId||O.current,T.current=null,g(!0)),e.currentRange&&C(`Probing ${e.currentRange.from}–${e.currentRange.to} of ${e.total}…`),e.error&&k(e.error),"done"===e.status||"cancelled"===e.status||"error"===e.status){R.current=null,g(!1);let t={ok:e.ok||0,dead:e.dead||0,retryable:e.retryable||0,tested:e.done||0,skippedDead:e.skippedDead||0,skippedDup:e.skippedDup||0,cancelled:"cancelled"===e.status,retryableAuthOnly:!0===e.retryableAuthOnly};j(t),C("cancelled"===e.status?"Cancelled (partial results saved).":"error"===e.status?"Stopped.":"Done.");let s=`${e.startedAt||"unknown"}:${e.status}`;T.current!==s&&(T.current=s,A.current.onComplete?.(t))}}}async function M(){if(f||!e||0===E)return;g(!0),k(""),j(null),C("Starting…");let a={concurrency:Math.max(1,Math.min(16,Number(c)||4)),batchSize:Math.max(1,Math.min(200,Number(u)||50)),timeoutMs:Math.max(1e3,Math.min(6e4,1e3*(Number(x)||20)))};R.current=e;try{let r=await fetch(`/api/providers/${e}/model-probes/verify/start`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({models:s,providerAlias:t,...a,timeoutMs:a.timeoutMs})}),i=await r.json().catch(()=>({}));if(O.current!==e){R.current=null,g(!1);return}if(!r.ok){R.current=null,k(i.error||"Failed to start"),g(!1);return}A.current.onStarted?.(i),D(i),"running"!==i.status&&g(!1)}catch(e){R.current=null,k(e?.message||"Verify failed"),g(!1)}}async function P(){let t=R.current||e;await fetch(`/api/providers/${t}/model-probes/verify/cancel`,{method:"POST"}).catch(()=>{})}async function z(s){if(!e)return;let a="retryable"===s,r=a?Number(v?.retryable||0):Number(v?.dead||0);if(!a||await (0,ee.l)({title:"Remove retry-failed models?",message:`Review ${r} retryable result(s) and remove the eligible models? Timeouts, rate limits, network failures, and provider errors may be temporary. Credential failures are kept. Removed models can be enabled or imported again later.`,confirmText:"Remove eligible"})){$(s),k(""),C(`Removing ${a?"retry-failed":"dead"} models…`);try{let r=await fetch(`/api/providers/${e}/model-probes/remove-unavailable`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({providerAlias:t,kind:"llm",status:s})}),i=await r.json().catch(()=>({}));if(!r.ok)return void k(i.error||"Remove failed");let n=Number(i.removed||0),l=Number(i.kept||0),o=v?{...v,[a?"retryable":"dead"]:l,...a?{retryableAuthOnly:l>0}:{}}:v;j(o),C(`Removed ${n} ${a?"retry-failed":"dead"} model(s).`+(l>0?` Kept ${l} credential failure(s).`:"")),A.current.onComplete?.({...o||{},removed:n,kept:l,removedStatus:s})}catch(e){k(e?.message||"Remove failed")}finally{$("")}}}async function U(){if(!e)return;let t=await fetch(`/api/providers/${e}/model-probes/cache`,{method:"DELETE"}),s=await t.json().catch(()=>({}));t.ok?(C(`Cleared probe cache (${s.cleared||0} rows). Next verify will re-test everything.`),j(null),y(null),A.current.onComplete?.({cacheCleared:!0,cleared:s.cleared||0})):k(s.error||"Clear cache failed")}(0,r.useEffect)(()=>{A.current={onComplete:n,onStarted:l},O.current=e}),(0,r.useEffect)(()=>{D(i)},[i]);let q=b?.total?Math.min(100,Math.round(b.done/b.total*100)):0;return(0,a.jsxs)("div",{className:"mb-4 rounded-lg border border-border bg-sidebar/40 p-3 space-y-3",children:[(0,a.jsxs)("div",{className:"flex items-start justify-between gap-2",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("h3",{className:"text-sm font-semibold text-text-main",children:"Verify models"}),(0,a.jsxs)("p",{className:"text-[11px] text-text-muted mt-0.5",children:["Batch-ping availability and latency. Dead = permanently unavailable (missing, blocked, or deprecated) and can be removed; retry = transient (timeout/429/5xx). Known-dead models are skipped until you Clear cache. Caps: ",I,"."]})]}),o&&(0,a.jsx)("button",{type:"button",onClick:o,className:"p-1 text-text-muted hover:text-text-main rounded",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:"close"})})]}),(0,a.jsxs)("div",{className:"flex flex-wrap gap-3 items-end",children:[(0,a.jsxs)("label",{className:"text-xs text-text-muted",children:["Concurrency",(0,a.jsx)("input",{type:"number",min:1,max:16,value:c,disabled:f,onChange:e=>m(e.target.value),className:"mt-1 block w-20 rounded-md border border-border bg-background px-2 py-1 text-xs"})]}),(0,a.jsxs)("label",{className:"text-xs text-text-muted",children:["Batch size",(0,a.jsx)("input",{type:"number",min:1,max:200,value:u,disabled:f,onChange:e=>p(e.target.value),className:"mt-1 block w-20 rounded-md border border-border bg-background px-2 py-1 text-xs"})]}),(0,a.jsxs)("label",{className:"text-xs text-text-muted",children:["Timeout (s)",(0,a.jsx)("input",{type:"number",min:1,max:60,value:x,disabled:f,onChange:e=>h(e.target.value),className:"mt-1 block w-20 rounded-md border border-border bg-background px-2 py-1 text-xs"})]}),(0,a.jsxs)("div",{className:"flex gap-2",children:[f?(0,a.jsx)(d.$n,{size:"sm",variant:"secondary",icon:"stop",onClick:P,children:"Cancel"}):(0,a.jsx)(d.$n,{size:"sm",icon:"science",onClick:M,disabled:!e||0===E,children:"Start"}),(0,a.jsx)(d.$n,{size:"sm",variant:"secondary",icon:"delete_sweep",onClick:U,disabled:f,children:"Clear cache"})]})]}),b&&(0,a.jsxs)("div",{className:"space-y-1",children:[(0,a.jsx)("div",{className:"h-1.5 w-full rounded-full bg-border overflow-hidden",children:(0,a.jsx)("div",{className:"h-full bg-primary transition-all",style:{width:`${q}%`}})}),(0,a.jsxs)("p",{className:"text-[11px] text-text-muted flex flex-wrap gap-x-2",children:[(0,a.jsxs)("span",{title:"Models probed this run",children:[b.done,"/",b.total," tested"]}),(0,a.jsxs)("span",{title:"Reachable",children:["\xb7 ok ",b.ok]}),(0,a.jsxs)("span",{title:"Permanently unavailable this run (missing, blocked, or deprecated)",children:["\xb7 dead ",b.dead]}),(0,a.jsxs)("span",{title:"Transient failure this run (timeout / 429 / 5xx / network); re-testable",children:["\xb7 retry ",b.retryable]}),b.skippedDead?(0,a.jsxs)("span",{title:"Not probed — cache already marks them dead. Clear cache to re-test.",children:["\xb7 skipped known-dead ",b.skippedDead]}):null,b.skippedDup?(0,a.jsxs)("span",{title:"Duplicate ids collapsed",children:["\xb7 dupes ",b.skippedDup]}):null]})]}),N&&(0,a.jsx)("p",{className:"text-xs text-text-muted",children:N}),w&&(0,a.jsx)("p",{className:"text-xs text-red-500 break-words",children:w}),v&&(0,a.jsxs)("div",{className:"flex flex-wrap items-center gap-2 pt-1",children:[(0,a.jsxs)("span",{className:"text-xs text-text-main",children:["Summary: ",v.ok," ok \xb7 ",v.dead," dead \xb7 ",v.retryable," retry",v.skippedDead?` \xb7 ${v.skippedDead} skipped known-dead`:"",v.cancelled?" \xb7 cancelled":""]}),v.dead>0&&(0,a.jsxs)(d.$n,{size:"sm",variant:"primary",icon:"delete_sweep",onClick:()=>z("dead"),disabled:f||!!S,loading:"dead"===S,children:["Remove ",v.dead," dead"]}),v.retryable>0&&!v.retryableAuthOnly&&(0,a.jsxs)(d.$n,{size:"sm",variant:"danger",icon:"delete_sweep",onClick:()=>z("retryable"),disabled:f||!!S,loading:"retryable"===S,children:["Remove ",v.retryable," retry failures"]})]})]})}et.propTypes={connectionId:D().string,providerAlias:D().string,models:D().arrayOf(D().object),jobSnapshot:D().object,onComplete:D().func,onStarted:D().func,onClose:D().func};var es=s(68875);let ea=["UTC","America/Los_Angeles","America/Denver","America/Chicago","America/New_York","America/Sao_Paulo","Europe/London","Europe/Berlin","Europe/Moscow","Asia/Kolkata","Asia/Shanghai","Asia/Tokyo","Asia/Singapore","Australia/Sydney"],er=(()=>{let e=[];try{e=Intl.supportedValuesOf?.("timeZone")||[]}catch{e=[]}try{let e=Intl.DateTimeFormat().resolvedOptions().timeZone;e&&!ea.includes(e)&&ea.unshift(e)}catch{}return[...new Set([...ea,...e.filter(e=>!ea.includes(e))])]})(),ei={mon:"Mo",tue:"Tu",wed:"We",thu:"Th",fri:"Fr",sat:"Sa",sun:"Su"};function en({providerId:e,scheduleKey:t}){let s=t||e,i=(0,r.useId)(),[n,l]=(0,r.useState)(!1),[o,c]=(0,r.useState)(!1),[m,u]=(0,r.useState)("UTC"),[p,x]=(0,r.useState)("offPeak"),[h,f]=(0,r.useState)([]),[g,b]=(0,r.useState)(!1),[y,v]=(0,r.useState)(""),[j,w]=(0,r.useState)(0),[,k]=(0,r.useState)(0),N=(0,r.useCallback)(e=>{let t=es.Z9.find(t=>t.id===e);t&&(u(t.config.timezone||"UTC"),x("peak"===t.config.defaultState?"peak":"offPeak"),f(t.config.windows.map(e=>({type:e.type,start:e.start,end:e.end,days:Array.isArray(e.days)&&e.days.length?[...e.days]:[...es.de]}))),w(0))},[]);(0,r.useEffect)(()=>{let e=!1;return c(!1),u("UTC"),x("offPeak"),f([]),w(0),v(""),fetch("/api/settings",{cache:"no-store"}).then(e=>e.ok?e.json():{}).then(t=>{if(e)return;let a=(t.providerSchedules||{})[s];a&&Array.isArray(a.windows)&&a.windows.length&&(c(!0),u(a.timezone||"UTC"),x("peak"===a.defaultState?"peak":"offPeak"),f(a.windows.map(e=>({type:"offPeak"===e.type?"offPeak":"peak",start:e.start||"09:00",end:e.end||"17:00",days:Array.isArray(e.days)&&e.days.length?[...e.days]:[...es.de]})))),l(!0)}).catch(()=>{e||l(!0)}),()=>{e=!0}},[s]),(0,r.useEffect)(()=>{let e=setInterval(()=>k(e=>e+1),3e4);return()=>clearInterval(e)},[]);let C=(0,r.useMemo)(()=>o?{timezone:m,defaultState:p,windows:h}:null,[o,m,p,h]),S=(0,es.yW)(C),$="unscheduled"===S?null:(0,es.bC)(C),A=(0,r.useCallback)((e,t)=>{f(s=>s.map((s,a)=>a===e?{...s,...t}:s)),w(0)},[]),T=(0,r.useCallback)((e,t)=>{f(s=>s.map((s,a)=>{if(a!==e)return s;let r=s.days.includes(t)?s.days.filter(e=>e!==t):[...s.days,t];return{...s,days:r.length?r:s.days}})),w(0)},[]),O=async()=>{v("");let t=o?(0,es.v2)({timezone:m,defaultState:p,windows:h},e):null;if(o&&t.error)return void v(t.error);b(!0);try{let e=await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({providerSchedules:{[s]:o?t.value:null}})});if(!e.ok){let t=await e.json().catch(()=>({}));v(t.error||`Failed to save peak hours (${e.status})`);return}w(Date.now())}catch{v("Failed to save peak hours")}finally{b(!1)}};return n?(0,a.jsxs)(d.Zp,{children:[(0,a.jsxs)("div",{className:"mb-3 flex flex-wrap items-center justify-between gap-2",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("h2",{className:"text-lg font-semibold",children:"Peak hours"}),"unscheduled"!==S&&(0,a.jsxs)("span",{className:`inline-flex items-center gap-1 rounded-full px-2 py-0.5 text-[11px] font-medium ${"peak"===S?"bg-red-500/10 text-red-600 dark:text-red-400":"bg-green-500/10 text-green-600 dark:text-green-400"}`,title:$?`Changes at ${function(e,t){try{return new Intl.DateTimeFormat("en-US",{timeZone:t,weekday:"short",hour:"2-digit",minute:"2-digit",hourCycle:"h23"}).format(new Date(e))}catch{return e}}(new Date($).toISOString(),m)}`:void 0,children:[(0,a.jsx)("span",{className:`size-1.5 rounded-full ${"peak"===S?"bg-red-500":"bg-green-500"}`}),"peak"===S?"Peak now":"Off-peak now",$?` \xb7 ${(0,es.zt)($-Date.now())} left`:""]})]}),(0,a.jsx)(d.lM,{checked:o,onChange:e=>{c(e),w(0),e&&!h.length&&(u("UTC"),x("offPeak"),f([{type:"peak",start:"09:00",end:"17:00",days:[...es.de]}]))},label:"Enable peak / off-peak hours",size:"sm"})]}),(0,a.jsx)("p",{className:"mb-3 text-xs text-text-muted leading-relaxed",children:"Optional. Some providers (e.g. DeepSeek) charge less outside peak hours. Define this provider's windows once, then mark models in a combo as peak-only or off-peak-only to skip them at the wrong hours."}),o&&(0,a.jsxs)("div",{className:"flex flex-col gap-3",children:[(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-2",children:[(0,a.jsxs)("div",{className:"flex flex-col gap-1.5",children:[(0,a.jsx)("label",{htmlFor:i,className:"text-sm font-medium text-text-main",children:"Timezone"}),(0,a.jsx)("input",{id:i,list:`${i}-zones`,value:m,onChange:e=>{u(e.target.value),w(0)},placeholder:"UTC — type to search IANA zones",className:"rounded-md border border-border bg-background px-3 py-2 text-sm text-text-main outline-none focus:border-primary",autoComplete:"off"}),(0,a.jsx)("datalist",{id:`${i}-zones`,children:er.map(e=>(0,a.jsx)("option",{value:e},e))}),(0,a.jsx)("p",{className:"text-[10px] text-text-muted",children:"Windows are wall-clock in this zone (provider docs usually quote UTC)"})]}),(0,a.jsx)(d.l6,{label:"Outside all windows is",options:[{value:"offPeak",label:"Off-peak (peak is the exception)"},{value:"peak",label:"Peak (off-peak discount is the exception)"}],value:p,onChange:e=>{x(e.target.value),w(0)}})]}),(0,a.jsx)(d.l6,{label:"Load a preset",options:es.Z9.map(e=>({value:e.id,label:e.label})),value:"",onChange:e=>N(e.target.value),placeholder:"Choose a known provider policy…",hint:"Fills the editor below — review the provider's current pricing page, then Save"}),(0,a.jsxs)("div",{className:"flex flex-col gap-2",children:[h.map((e,t)=>(0,a.jsxs)("div",{className:"flex flex-wrap items-center gap-2 rounded-md border border-border bg-black/[0.02] px-2 py-2 dark:bg-white/[0.02]",children:[(0,a.jsxs)("select",{value:e.type,onChange:e=>A(t,{type:e.target.value}),className:"rounded-md border border-border bg-background px-2 py-1 text-xs","aria-label":`Window ${t+1} type`,children:[(0,a.jsx)("option",{value:"peak",children:"Peak"}),(0,a.jsx)("option",{value:"offPeak",children:"Off-peak"})]}),(0,a.jsx)("input",{type:"time",value:e.start,onChange:e=>A(t,{start:e.target.value}),className:"rounded-md border border-border bg-background px-2 py-1 text-xs","aria-label":`Window ${t+1} start`}),(0,a.jsx)("span",{className:"text-xs text-text-muted",children:"→"}),(0,a.jsx)("input",{type:"time",value:e.end,onChange:e=>A(t,{end:e.target.value}),className:"rounded-md border border-border bg-background px-2 py-1 text-xs","aria-label":`Window ${t+1} end`}),(0,a.jsx)("div",{className:"flex items-center gap-1",children:es.de.map(s=>(0,a.jsx)("button",{type:"button",onClick:()=>T(t,s),className:`size-6 rounded text-[10px] font-medium transition-colors ${e.days.includes(s)?"bg-primary/15 text-primary":"text-text-muted hover:bg-black/5 dark:hover:bg-white/5"}`,title:s,children:ei[s]},s))}),(0,a.jsx)("button",{type:"button",onClick:()=>{f(e=>e.filter((e,s)=>s!==t)),w(0)},className:"ml-auto rounded p-1 text-text-muted transition-colors hover:bg-red-500/10 hover:text-red-500",title:"Remove window","aria-label":`Remove window ${t+1}`,children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"close"})})]},t)),(0,a.jsx)("div",{className:"flex flex-wrap items-center gap-2",children:(0,a.jsx)(d.$n,{size:"sm",variant:"secondary",icon:"add",onClick:()=>{f(e=>[...e,{type:"peak",start:"09:00",end:"17:00",days:[...es.de]}]),w(0)},children:"Add window"})})]})]}),y&&(0,a.jsx)("p",{className:"mt-2 text-xs text-red-500",children:y}),j>0&&!y&&(0,a.jsx)("p",{className:"mt-2 text-xs text-green-600 dark:text-green-400",children:"Saved"}),(0,a.jsx)("div",{className:"mt-3",children:(0,a.jsx)(d.$n,{size:"sm",onClick:O,disabled:g,children:g?"Saving...":o?"Save peak hours":"Save (disable schedule)"})})]}):null}var el=s(65921);let eo=["host","content-length","content-type","connection","transfer-encoding","authorization","cookie"],ed=/^[A-Za-z0-9-]+$/;function ec({providerId:e}){let t=(0,el.i)(),[s,i]=(0,r.useState)(!1),[n,l]=(0,r.useState)([{name:"",value:""}]),[o,c]=(0,r.useState)({}),[m,u]=(0,r.useState)(!1),[p,x]=(0,r.useState)(!1);(0,r.useEffect)(()=>{let t=!1;return fetch(`/api/providers/${e}/overrides`,{cache:"no-store"}).then(e=>e.ok?e.json():null).then(e=>{if(t||!e)return;let s=e.builtinHeaders||{},a=Object.entries({...s,...e.headers||{}}).map(([e,t])=>({name:e,value:t}));c(s),l(a.length?a:[{name:"",value:""}]),u(Object.keys(e.headers||{}).length>0)}).catch(()=>{}),()=>{t=!0}},[e]);let h=(e,t,s)=>{l(a=>a.map((a,r)=>r===e?{...a,[t]:s}:a))},f=(0,r.useCallback)(async()=>{let s={};for(let e of n.filter(e=>e.name.trim())){let a=e.name.trim();if(!ed.test(a))return void t.error(`Invalid header name: ${a}`);if(eo.includes(a.toLowerCase()))return void t.error(`Header ${a} cannot be overridden`);if(a in s)return void t.error(`Duplicate header name: ${a}`);e.value!==o[a]&&(s[a]=e.value)}x(!0);try{let a=await fetch(`/api/providers/${e}/overrides`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({headers:s})});if(!a.ok){let e=await a.json().catch(()=>({}));t.error(e.error||"Failed to save");return}u(Object.keys(s).length>0),t.success("Custom headers saved")}catch{t.error("Failed to save custom headers. Check your connection and try again.")}finally{x(!1)}},[n,o,e,t]);return 0!==Object.keys(o).length||m?(0,a.jsxs)(d.Zp,{padding:"xs",children:[(0,a.jsxs)("button",{type:"button",onClick:()=>i(e=>!e),className:"flex w-full items-center justify-between text-left",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-primary text-[20px]",children:"tune"}),(0,a.jsx)("span",{className:"text-sm font-semibold",children:"Custom Headers"}),m&&(0,a.jsx)(d.Ex,{variant:"success",size:"sm",children:"Active"})]}),(0,a.jsx)("span",{className:"material-symbols-outlined text-text-muted",children:s?"expand_less":"expand_more"})]}),s&&(0,a.jsxs)("div",{className:"mt-3 border-t border-border pt-3",children:[(0,a.jsx)("div",{className:"flex flex-col gap-2",children:n.map((e,t)=>{let s=e.name.trim()in o&&e.value!==o[e.name.trim()];return(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("input",{value:e.name,onChange:e=>h(t,"name",e.target.value),placeholder:"Header-Name",spellCheck:!1,className:"w-44 rounded-md border border-border bg-background px-2 py-1.5 text-sm focus:border-primary focus:outline-none"}),(0,a.jsx)("input",{value:e.value,onChange:e=>h(t,"value",e.target.value),placeholder:"Value",spellCheck:!1,title:s?"Overridden":e.name.trim()in o?"Registry default":"",className:`min-w-0 flex-1 rounded-md border bg-background px-2 py-1.5 text-sm focus:border-primary focus:outline-none ${s?"border-amber-400/60":"border-border"}`}),(0,a.jsx)("button",{type:"button",title:"Remove header",onClick:()=>l(e=>e.length>1?e.filter((e,s)=>s!==t):[{name:"",value:""}]),className:"shrink-0 text-text-muted hover:text-red-500",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:"delete"})})]},t)})}),(0,a.jsxs)("div",{className:"mt-3 flex items-center justify-between gap-2",children:[(0,a.jsxs)("button",{type:"button",onClick:()=>l(e=>[...e,{name:"",value:""}]),className:"flex items-center gap-1 text-xs text-primary hover:underline",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[16px]",children:"add"}),"Add header"]}),(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsx)("button",{type:"button",disabled:p,onClick:()=>{l(Object.entries(o).map(([e,t])=>({name:e,value:t})))},className:"rounded-md border border-border px-3 py-1.5 text-xs hover:bg-black/[0.03] dark:hover:bg-white/[0.03] disabled:opacity-50",children:"Reset"}),(0,a.jsx)("button",{type:"button",disabled:p,onClick:f,className:"rounded-md bg-primary px-3 py-1.5 text-xs font-medium text-white hover:opacity-90 disabled:opacity-50",children:p?"Saving...":"Save"})]})]})]})]}):null}ec.propTypes={providerId:D().string.isRequired};var em=s(97132),eu=s(93195),ep=s(36861),ex=s(48874),eh=s(53578);let ef=new Set(["minimax-code","minimax-code-global"]),eg={claude:"claudeAutoPing",codex:"codexAutoPing"};function eb(){let e,t,s,n=(0,i.useParams)(),u=(0,i.useRouter)(),p=n.id,{getCaps:x}=(0,$.y)(),[h,f]=(0,r.useState)([]),[g,b]=(0,r.useState)([]),[y,v]=(0,r.useState)(!0),[j,w]=(0,r.useState)(null),[k,N]=(0,r.useState)(!1),[T,I]=(0,r.useState)(!1),[D,z]=(0,r.useState)(!1),[U,F]=(0,r.useState)(""),[_,L]=(0,r.useState)(!1),[W,Z]=(0,r.useState)(!1),[Q,X]=(0,r.useState)(!1),[ee,es]=(0,r.useState)(!1),[ea,er]=(0,r.useState)(null),[ei,el]=(0,r.useState)({}),[eo,ed]=(0,r.useState)([]),[eb,ey]=(0,r.useState)(!1),[ev,ej]=(0,r.useState)({}),[ew,ek]=(0,r.useState)(""),[eN,eC]=(0,r.useState)(null),[eS,e$]=(0,r.useState)(()=>new Set),[eA,eT]=(0,r.useState)(!1),[eO,eR]=(0,r.useState)(null),[eE,eI]=(0,r.useState)(""),[eD,eM]=(0,r.useState)(!1),[eP,ez]=(0,r.useState)("30"),[eU,eq]=(0,r.useState)("auto"),[eF,e_]=(0,r.useState)({enabled:!1,connections:{},schedules:{}}),[eJ,eL]=(0,r.useState)(null),[eK,eB]=(0,r.useState)([]),[eH,eW]=(0,r.useState)([]),[eV,eZ]=(0,r.useState)([]),[eG,eQ]=(0,r.useState)([]),[eX,eY]=(0,r.useState)(null),[e0,e1]=(0,r.useState)(!1),[e2,e5]=(0,r.useState)(!1),[e3,e4]=(0,r.useState)(!1),[e6,e8]=(0,r.useState)(null),[e7,e9]=(0,r.useState)({}),[te,tt]=(0,r.useState)(null),ts=(0,r.useRef)(!1),ta=(0,r.useRef)(null),tr=(0,r.useRef)(0),ti=(0,r.useRef)(0),[tn,tl]=(0,r.useState)(!1),[to,td]=(0,r.useState)(""),[tc,tm]=(0,r.useState)(!1),[tu,tp]=(0,r.useState)(null),[tx,th]=(0,r.useState)({}),[tf,tg]=(0,r.useState)({}),[tb,ty]=(0,r.useState)("all"),{copied:tv,copy:tj}=(0,S.C)(),tw="ag_risk_confirmed",tk=j?{id:j.id,name:j.name||("anthropic-compatible"===j.type?"Anthropic Compatible":"OpenAI Compatible"),color:"anthropic-compatible"===j.type?"#D97757":"#10A37F",textIcon:"anthropic-compatible"===j.type?"AC":"OC",apiType:j.apiType,baseUrl:j.baseUrl,type:j.type}:c.zN[p]||c.fg[p]||c.IS[p]||c.nJ[p]||c.br[p],tN=tk?.authModes||[],tC=!!c.zN[p]||!!c.IS[p]||tN.includes("oauth"),tS=!!c.fg[p]||tN.includes("apikey"),t$=!!c.IS[p]?.noAuth,tA=(0,m.KC)(p),tT=(()=>{let e=new Map(tA.map(e=>[e.id,e]));for(let t of eH)t?.id&&e.set(t.id,{...e.get(t.id),...t});return[...e.values()]})(),tO=(0,c.wG)(p),tR=(0,c.mq)(p),tE=(0,c.gb)(p),tI=tR||tE,tD=h.some(e=>!1!==e.isActive),tM=function({isCompatible:e,hasActiveConnection:t}){let s=!e,a=!e;return{showToolbar:s||t||a,showImport:s,showVerify:t,showBulkControls:a}}({isCompatible:tI,hasActiveConnection:tD}),tP=!tI&&tC&&tS,tz="xai"===p?"Grok Build OAuth":"OAuth",tU="xai"===p?"xAI API Key":"qoder"===p||"qoder-cn"===p?"PAT":"API Key",tq=()=>{N(!0)},tF=()=>{"antigravity"===p&&"true"!==window.localStorage.getItem(tw)?e1(!0):tC?tq():(F(""),z(!0))},t_=()=>{F(""),z(!0)},tJ=()=>{tC?tF():t_()},tL=e=>{if(!eU||"auto"===eU)return null;let t=C(p,e);return t&&t.includes(eU)?eU:null},tK=(()=>{let e=new Set;for(let t of tT){let s=C(p,t.id);s&&s.forEach(t=>{"none"!==t&&e.add(t)})}return e.size?["auto",...e]:null})(),tB=tI?p:tO,tH=tI?j?.prefix||p:tO,tW=(0,R.Iz)(eG,tB),tV=e=>(0,R.uJ)(tW,e,tB),tZ=(0,r.useCallback)(async()=>{try{let e=await fetch(`/api/models/disabled?providerAlias=${encodeURIComponent(tB)}`,{cache:"no-store"}),t=await e.json();e.ok&&eQ(t.ids||[])}catch(e){(0,P.s)("Error fetching disabled models:",e)}},[tB]),tG=async e=>{try{await (0,ex.x)("/api/models/disabled",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({providerAlias:tB,ids:[e]})}),await tZ()}catch(e){(0,P.s)("Error disabling model:",e)}},tQ=async e=>{try{return await (0,ex.x)(`/api/models/disabled?providerAlias=${encodeURIComponent(tB)}&id=${encodeURIComponent(e)}`,{method:"DELETE"}),await tZ(),!0}catch(e){return(0,P.s)("Error enabling model:",e),!1}},tX=async e=>{e.length&&eY({title:"Disable All Models",message:`Disable all ${e.length} model(s)?`,onConfirm:async()=>{eY(null);try{await (0,ex.x)("/api/models/disabled",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({providerAlias:tB,ids:e})}),await tZ()}catch(e){(0,P.s)("Error disabling all models:",e)}}})},tY=async()=>{try{await (0,ex.x)(`/api/models/disabled?providerAlias=${encodeURIComponent(tB)}`,{method:"DELETE"}),await tZ()}catch(e){(0,P.s)("Error enabling all models:",e)}},t0=(0,r.useCallback)(async()=>{try{let e=await fetch("/api/models/alias"),t=await e.json();e.ok&&el(t.aliases||{})}catch(e){(0,P.s)("Error fetching aliases:",e)}},[]),t1=(0,r.useCallback)(async()=>{try{let e=await fetch("/api/models/custom",{cache:"no-store"}),t=await e.json();e.ok&&ed(t.models||[])}catch(e){(0,P.s)("Error fetching custom models:",e)}},[]);(0,r.useEffect)(()=>{"kilocode"===p&&fetch("/api/providers/kilo/free-models").then(e=>e.json()).then(e=>{e.models?.length&&eZ(e.models)}).catch(()=>{})},[p]);let t2=(0,r.useCallback)(async()=>{try{let[e,t,s]=await Promise.all([fetch("/api/providers",{cache:"no-store"}),fetch("/api/provider-nodes",{cache:"no-store"}),fetch("/api/settings",{cache:"no-store"})]),a=await e.json(),r=await t.json(),i=s.ok?await s.json():{};if(e.ok){let e=(a.connections||[]).filter(e=>e.provider===p);f(e)}let n=(i.providerStrategies||{})[p]||{};eR(n.fallbackStrategy||null),eI(null!=n.stickyRoundRobinLimit?String(n.stickyRoundRobinLimit):"1");let l=n.accountScheduler||{};eM(!0===l.enabled),ez(String(Math.max(1,Math.round((l.sessionAffinityTtlSeconds||1800)/60))));let o=(i.providerThinking||{})[p]||{};eq(o.mode||"auto");let d=eg[p],c=d&&i[d]||{};if(e_({enabled:!0===c.enabled,connections:c.connections||{},schedules:c.schedules||{}}),t.ok){let e=(r.nodes||[]).find(e=>e.id===p)||null;if(!e&&tI)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===p)||null))break}w(e)}}catch(e){(0,P.s)("Error fetching connections:",e)}finally{v(!1)}},[p,tI]),t5=(0,r.useCallback)(async(e=null)=>{let t=++ti.current,s=e?h.find(t=>t.id===e&&!1!==t.isActive):h.find(e=>g.includes(e.id)&&!1!==e.isActive)||h.find(e=>!1!==e.isActive);if(!s){tg({}),th({});return}try{let e=await fetch(`/api/providers/${s.id}/model-probes`,{cache:"no-store"});if(!e.ok)return;let a=await e.json().catch(()=>({})),r={},i={};for(let e of a.probes||[])r[e.modelId]="ok"===e.status?"ok":"dead"===e.status?"dead":"retry",null!=e.latencyMs&&(i[e.modelId]=e.latencyMs);if(t!==ti.current)return;tg(r),th(i)}catch{}},[h,g]),t3=async e=>{try{let t=await fetch(`/api/provider-nodes/${p}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}),s=await t.json();t.ok?(w(s.node),await t2(),es(!1)):(0,P.s)(s?.error||"Failed to update provider node")}catch(e){(0,P.s)("Error updating provider node:",e)}},t4=async(e,t)=>{try{return await (0,eh.T)(p,s=>{let a={...s};return e?a.fallbackStrategy=e:delete a.fallbackStrategy,"round-robin"===e&&""!==t?a.stickyRoundRobinLimit=Number(t)||3:e||delete a.stickyRoundRobinLimit,a}),!0}catch(e){return(0,P.s)("Error saving provider strategy:",e),!1}},t6=async(e,t)=>{let s=Math.min(1440,Math.max(1,Number.parseInt(t,10)||30));try{return await (0,eh.T)(p,t=>({...t,accountScheduler:{...t.accountScheduler||{},enabled:e,sessionAffinityTtlSeconds:60*s}})),!0}catch(e){return(0,P.s)("Error saving balanced scheduler:",e),!1}},t8=async e=>{let t=e?"round-robin":null,s=e?eE||"1":eE;await t4(t,s)&&(e&&!eE&&eI("1"),eR(t))},t7=async e=>{await t4("round-robin",e)&&eI(e)},t9=async e=>{await t6(e,eP)&&eM(e)},se=async e=>{await t6(eD,e)&&ez(e)},st=async e=>{try{let t=await fetch("/api/settings",{cache:"no-store"}),s={...(t.ok?await t.json():{}).providerThinking||{}};e&&"auto"!==e?s[p]={mode:e}:delete s[p],await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({providerThinking:s})})}catch(e){(0,P.s)("Error saving thinking config:",e)}},ss=async e=>{let t=eg[p];if(t){e_(e);try{await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({[t]:e})})}catch(e){(0,P.s)("Error saving auto-ping config:",e)}}};(0,r.useEffect)(()=>{t2(),t0(),t1(),tZ()},[t2,t0,t1,tZ]),(0,r.useEffect)(()=>{t5()},[t5]),(0,r.useEffect)(()=>{if(tI)return;let e=h.find(e=>!1!==e.isActive);if(!e){eW([]),"zed"===p&&eC(null);return}let t=!1;return"zed"===p&&eC(null),fetch(`/api/providers/${e.id}/models`,{cache:"no-store"}).then(e=>e.json().catch(()=>({}))).then(e=>{if(!t){if(Array.isArray(e.models)&&e.models.length>0){eW(e.models),"zed"===p&&e?.warning&&eC(e.warning);return}"zed"===p&&(eW([]),eC(e?.warning||e?.error||"Zed returned no live models."))}}).catch(()=>{t||"zed"!==p||(eW([]),eC("Failed to reach the Zed model catalog."))}),()=>{t=!0}},[h,tI,p]),(0,r.useEffect)(()=>{let e=(c.zN[p]||c.fg[p]||c.IS[p]||c.nJ[p])?.modelsFetcher;e&&O(e).then(eB)},[p]);let sa=(0,r.useCallback)(e=>{let t=++tr.current;ta.current&&(clearTimeout(ta.current),ta.current=null);let s=async()=>{try{let a=await fetch(`/api/providers/${e}/model-probes/verify/status`,{cache:"no-store"}),r=await a.json().catch(()=>null);if(t!==tr.current)return;if(!a.ok||!r?.status)throw Error("Verify status temporarily unavailable");tp(r&&r.status?r:null),r?.status==="running"?ta.current=setTimeout(s,1500):(ta.current=null,await t5(e))}catch{t===tr.current&&(ta.current=setTimeout(s,1500))}};ta.current=setTimeout(s,0)},[t5]);(0,r.useEffect)(()=>{let e=h.find(e=>g.includes(e.id)&&!1!==e.isActive)||h.find(e=>!1!==e.isActive);return e?(sa(e.id),()=>{tr.current+=1,ta.current&&(clearTimeout(ta.current),ta.current=null)}):void tp(null)},[h,g,sa]);let sr=async(e,t,s=tO)=>{let a=`${s}/${e}`;try{let e=await fetch("/api/models/alias",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({model:a,alias:t})});if(e.ok)await t0();else{let t=await e.json();(0,P.s)(t.error||"Failed to set alias")}}catch(e){(0,P.s)("Error setting alias:",e)}},si=async e=>{try{await (0,ex.x)(`/api/models/alias?alias=${encodeURIComponent(e)}`,{method:"DELETE"}),await t0()}catch(e){(0,P.s)("Error deleting alias:",e)}},sn=async(e,t="llm",s=tB,a,r)=>{try{let i=await fetch("/api/models/custom",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({providerAlias:s,id:e,type:t,...a?{caps:a}:{},...r?{transport:r}:{}})});if(i.ok)await t1(),window.dispatchEvent(new CustomEvent("customModelChanged"));else{let e=await i.json();(0,P.s)(e.error||"Failed to add custom model")}}catch(e){(0,P.s)("Error adding custom model:",e)}},sl=async(e,t="llm",s=tB)=>{try{let a=new URLSearchParams({providerAlias:s,id:e,type:t});await (0,ex.x)(`/api/models/custom?${a}`,{method:"DELETE"}),await t1(),window.dispatchEvent(new CustomEvent("customModelChanged"))}catch(e){(0,P.s)("Error deleting custom model:",e)}},so=async()=>{if(tn)return;let e=h.find(e=>g.includes(e.id)&&!1!==e.isActive)||h.find(e=>!1!==e.isActive);if(!e)return void(0,P.s)((0,A.Tl)("Add an active connection first"));tl(!0),td("");try{let t=await fetch(`/api/providers/${e.id}/models`),s=await t.json().catch(()=>({}));if(!t.ok)return void(0,P.s)(s.error||(0,A.Tl)("Failed to fetch models"));let a=s.models||[];if(0===a.length)return void(0,P.s)(s.warning||(0,A.Tl)("No models returned"));let r=new Set;try{let t=await fetch(`/api/providers/${e.id}/model-probes`,{cache:"no-store"});for(let e of(await t.json().catch(()=>({}))).probes||[])"dead"===e.status&&r.add(e.modelId)}catch{}let i=0,n=new Set(tT.map(e=>e.id)),l=[],o=[],d=new Set;for(let e of a){let t=(0,E.R2)(e,tB);if(!t)continue;let{id:s,name:a,type:c}=t;if(r.has((0,ep.v)(s,tB))){i+=1;continue}let m=`${c}|${s}`;if(d.has(m))continue;if(d.add(m),n.has(s)){tV(s)&&o.push(s);continue}if(eo.some(e=>e.providerAlias===tB&&e.id===s&&(0,E.ki)(e.kind||e.type||"llm")===c))continue;let u=`${tB}/${s}`;Object.values(ei).includes(u)||l.push({providerAlias:tB,id:s,type:c,name:a,...t.reasoning?{reasoning:t.reasoning}:{}})}let c=0;if(o.length>0)try{for(let e of o)(await fetch(`/api/models/disabled?providerAlias=${encodeURIComponent(tB)}&id=${encodeURIComponent(e)}`,{method:"DELETE"})).ok&&(c+=1);await tZ()}catch{}let m=0;if(l.length>0){let e=await fetch("/api/models/custom",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({models:l})}),t=await e.json().catch(()=>({}));if(!e.ok)return void(0,P.s)(t.error||(0,A.Tl)("Failed to save models"));m=t.added??l.length,await t1(),window.dispatchEvent(new CustomEvent("customModelChanged"))}let u=l.filter(e=>"llm"!==e.type).length,p=[];if(m>0&&p.push(`${m} new`),c>0&&p.push(`${c} re-enabled`),0===p.length)td((0,A.Tl)("All models already in list"));else{let e=`Imported ${p.join(" \xb7 ")} (${a.length} from provider)`;u>0&&(e+=" \xb7 non-chat types stored for media pages"),s.warning&&(e+=` \xb7 ${s.warning}`),td(e)}if(i>0&&td(e=>`${e} \xb7 ${i} skipped (known dead)`),m>0||c>0)try{let t=[...tT,...l.map(e=>({id:e.id,name:e.name,kind:e.type}))],s=await fetch(`/api/providers/${e.id}/model-probes/verify/start`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({models:t,providerAlias:tB})}),a=await s.json().catch(()=>({}));if(!s.ok)throw Error(a.error||"Failed to start auto-verify");tp(a&&a.status?a:null),sa(e.id)}catch(e){td(t=>`${t} \xb7 auto-verify failed: ${e?.message||e}`)}}catch(e){(0,P.s)("Error importing models:",e),(0,P.s)((0,A.Tl)("Error fetching models")+": "+(e?.message||e))}finally{tl(!1)}},sd=async()=>{if(e2||0===h.length)return;let e=Object.fromEntries(h.map(e=>[e.id,{state:"queued",error:null}]));ts.current=!1,e5(!0),e4(!1),e8(null),e9(e),tt({total:h.length,completed:0,passed:0,failed:0,stopped:!1});let t=0,s=0;try{for(let e=0;e<h.length;e+=1){if(ts.current){tt({total:h.length,completed:e,passed:t,failed:s,stopped:!0});break}let a=h[e];e8(a.id),e9(e=>({...e,[a.id]:{state:"testing",error:null}}));try{let e=await fetch(`/api/providers/${a.id}/test`,{method:"POST"}),r=await e.json(),i=!!r.valid;i?t+=1:s+=1,e9(e=>({...e,[a.id]:{state:i?"success":"failed",error:i?null:r.error||null}}))}catch(e){s+=1,e9(t=>({...t,[a.id]:{state:"failed",error:e.message||"Test failed"}}))}tt({total:h.length,completed:e+1,passed:t,failed:s,stopped:!1}),e<h.length-1&&await new Promise(e=>setTimeout(e,1e3))}}finally{e8(null),e5(!1),e4(!1),ts.current=!1}},sc=async e=>{let t=h.find(t=>t.id===e),s=t?.name?.trim()||t?.email?.trim()||e;eY({title:"Delete Connection",message:`Delete connection “${s}”?`,onConfirm:async()=>{eY(null);try{await (0,ex.x)(`/api/providers/${e}`,{method:"DELETE"}),f(t=>t.filter(t=>t.id!==e))}catch(e){(0,P.s)("Error deleting connection:",e)}}})},sm=()=>{t2(),N(!1)},su=async e=>{F("");try{let t=await fetch("/api/providers",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:p,...e})}),s=null;try{s=await t.json()}catch{s=null}if(t.ok){await t2(),z(!1);return}F(s?.error||"Failed to save connection")}catch(e){(0,P.s)("Error saving connection:",e),F("Failed to save connection")}},sp=async e=>{try{await (0,ex.x)(`/api/providers/${ea.id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}),await t2(),X(!1)}catch(e){(0,P.s)("Error updating connection:",e)}},sx=async(e,t)=>{try{await (0,ex.x)(`/api/providers/${e}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({isActive:t})}),f(s=>s.map(s=>s.id===e?{...s,isActive:t}:s))}catch(e){(0,P.s)("Error updating connection status:",e)}},sh=async e=>{let t,s=e?.providerSpecificData?.baseUrl;if(s){try{t=new URL(s).hostname.toLowerCase().replace(/^\[|\]$/g,"")}catch{(0,P.s)("Cannot allow-list: invalid base URL",s);return}try{let e=await fetch("/api/settings",{cache:"no-store"});if(!e.ok)throw Error(`Failed to load settings (${e.status})`);let s=await e.json(),a=[...new Set([...s.ssrfAllowHosts||[],t])],r=await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({ssrfAllowHosts:a})});if(!r.ok)throw Error(`Failed to update allow list (${r.status})`);await t2()}catch(e){(0,P.s)("Error adding host to allow list:",e)}}},sf=async(e,t)=>{let s=[...h];[s[e],s[t]]=[s[t],s[e]],f(s);try{if((await Promise.all([fetch(`/api/providers/${s[e].id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({priority:e})}),fetch(`/api/providers/${s[t].id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({priority:t})})])).some(e=>!e.ok))throw Error("Failed to reorder connections")}catch(e){(0,P.s)("Error swapping priority:",e),await t2()}},sg=h.length>0&&g.length===h.length,sb=(0,a.jsx)("div",{className:"flex min-w-0 flex-col divide-y divide-black/[0.03] dark:divide-white/[0.03] max-h-[500px] overflow-y-auto pr-1",children:h.map((e,t)=>(0,a.jsxs)("div",{className:"flex min-w-0 items-stretch",children:[(0,a.jsx)("div",{className:"flex shrink-0 items-center pl-1 sm:pl-2",children:(0,a.jsx)("input",{type:"checkbox",checked:g.includes(e.id),onChange:()=>{var t;return t=e.id,void b(e=>e.includes(t)?e.filter(e=>e!==t):[...e,t])},className:"h-4 w-4 rounded border-gray-300 text-primary focus:ring-primary"})}),(0,a.jsx)("div",{className:"flex-1 min-w-0",children:(0,a.jsx)(J,{connection:e,isOAuth:tC,isFirst:0===t,isLast:t===h.length-1,onMoveUp:()=>sf(t,t-1),onMoveDown:()=>sf(t,t+1),onToggleActive:t=>sx(e.id,t),autoPing:eg[p]&&"oauth"===e.authType?{isActive:!0===eF.connections[e.id]||eF.schedules?.[e.id]?.enabled===!0,reactiveOn:!0===eF.connections[e.id],provider:p,scheduleOn:eF.schedules?.[e.id]?.enabled===!0,scheduleSummary:(0,eu.JW)(eF.schedules?.[e.id]).join(" / "),onConfigure:()=>eL(e)}:null,onEdit:()=>{er(e),X(!0)},onDelete:()=>sc(e.id),onAllowlistHost:()=>sh(e),oneByOneStatus:e7[e.id]||null})})]},e.id))}),sy=async e=>{if(!eS.has(e)){e$(t=>new Set(t).add(e));try{let t=await fetch("/api/models/test",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({model:`${tB}/${e}`})}),s=await t.json();ej(t=>({...t,[e]:s.ok?"ok":"error"})),ek(s.ok?"":s.error||"Model not reachable")}catch{ej(t=>({...t,[e]:"error"})),ek("Network error")}finally{e$(t=>{let s=new Set(t);return s.delete(e),s})}}};return y?(0,a.jsxs)("div",{className:"flex flex-col gap-8",children:[(0,a.jsx)(d.Qv,{}),(0,a.jsx)(d.Qv,{})]}):tk?(0,a.jsxs)("div",{className:"flex min-w-0 flex-col gap-6 px-1 sm:gap-8 sm:px-0",children:[(0,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsxs)(l(),{href:"/dashboard/providers",className:"inline-flex items-center gap-1 text-sm text-text-muted hover:text-primary transition-colors mb-4",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-lg",children:"arrow_back"}),"Back to Providers"]}),(0,a.jsxs)("div",{className:"flex min-w-0 items-center gap-3 sm:gap-4",children:[(0,a.jsx)("div",{className:"flex size-12 shrink-0 items-center justify-center rounded-lg",style:{backgroundColor:`${tk.color}15`},children:eb?(0,a.jsx)("span",{className:"text-sm font-bold",style:{color:tk.color},children:tk.textIcon||tk.id.slice(0,2).toUpperCase()}):(0,a.jsx)(o.default,{src:tR&&tk.apiType?"responses"===tk.apiType?"/providers/oai-r.png":"/providers/oai-cc.png":tE?"/providers/anthropic-m.png":`/providers/${tk.id}.png`,alt:tk.name,width:48,height:48,className:"max-h-12 max-w-12 rounded-lg object-contain",sizes:"48px",onError:()=>ey(!0)})}),(0,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsxs)("div",{className:"flex items-center gap-3 flex-wrap",children:[(0,a.jsx)("h1",{className:"truncate text-2xl font-semibold tracking-tight sm:text-3xl",children:tk.name}),(tk.notice?.apiKeyUrl||tk.notice?.signupUrl||tk.website)&&(0,a.jsxs)("a",{href:tk.notice?.apiKeyUrl||tk.notice?.signupUrl||tk.website,target:"_blank",rel:"noopener noreferrer",className:"text-xs text-primary hover:underline inline-flex items-center gap-1",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-sm",children:"open_in_new"}),tk.notice?.apiKeyUrl?"Get API Key":"Sign up / Learn more"]})]}),(0,a.jsxs)("p",{className:"text-text-muted",children:[h.length," connection",1===h.length?"":"s"]})]})]})]}),tk.deprecated&&(0,a.jsxs)("div",{className:"flex items-start gap-3 rounded-xl border border-amber-500/25 bg-amber-500/8 px-4 py-3 text-xs text-amber-600 dark:text-amber-400",children:[(0,a.jsx)("span",{className:"material-symbols-outlined shrink-0 text-base text-amber-500 mt-0.5",children:"warning"}),(0,a.jsx)("p",{className:"leading-relaxed font-normal",children:String(tk.deprecationNotice).replace(/^⚠️\s*⚠️?\s*/,"")})]}),tk.notice?.text&&!tk.deprecated&&(0,a.jsxs)("div",{className:"flex flex-col gap-2 rounded-lg border border-blue-500/30 bg-blue-500/10 px-3 py-2 sm:flex-row sm:items-center",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[16px] text-blue-500 shrink-0",children:"info"}),(0,a.jsx)("p",{className:"min-w-0 flex-1 text-xs leading-relaxed text-blue-600 dark:text-blue-400",children:tk.notice.text}),tk.notice.apiKeyUrl&&(0,a.jsx)("a",{href:tk.notice.apiKeyUrl,target:"_blank",rel:"noopener noreferrer",className:"inline-flex justify-center rounded bg-blue-500 px-2 py-1 text-xs font-medium text-white transition-colors hover:bg-blue-600 sm:py-0.5",children:"Get API Key →"})]}),tI&&j&&(0,a.jsx)(d.Zp,{children:(0,a.jsxs)("div",{className:"mb-4 flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between",children:[(0,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsx)("h2",{className:"text-lg font-semibold",children:tE?"Anthropic Compatible Details":"OpenAI Compatible Details"}),(0,a.jsxs)("p",{className:"break-all text-sm text-text-muted",children:[tE?"Messages API":"responses"===j.apiType?"Responses API":"Chat Completions"," \xb7 ",(j.baseUrl||"").replace(/\/$/,""),"/",tE?"messages":"responses"===j.apiType?"responses":"chat/completions"]})]}),(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-2 sm:flex sm:items-center",children:[(0,a.jsx)(d.$n,{size:"sm",icon:"add",onClick:()=>{F(""),z(!0)},className:"w-full sm:w-auto",children:"Add API Key"}),(0,a.jsx)(d.$n,{size:"sm",variant:"secondary",icon:"edit",onClick:()=>es(!0),className:"w-full sm:w-auto",children:"Edit"}),(0,a.jsx)(d.$n,{size:"sm",variant:"secondary",icon:"delete",onClick:async()=>{eY({title:"Delete Compatible Node",message:`Delete this ${tE?"Anthropic":"OpenAI"} Compatible node?`,onConfirm:async()=>{eY(null);try{await (0,ex.x)(`/api/provider-nodes/${p}`,{method:"DELETE"}),u.push("/dashboard/providers")}catch(e){(0,P.s)("Error deleting provider node:",e)}}})},className:"w-full sm:w-auto",children:"Delete"})]})]})}),t$?(0,a.jsx)(d.gw,{providerId:p}):(0,a.jsxs)(d.Zp,{children:[(0,a.jsxs)("div",{className:"mb-4 flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[(0,a.jsx)("h2",{className:"text-lg font-semibold",children:"Connections"}),(0,a.jsxs)("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:gap-4",children:[h.length>0&&(0,a.jsxs)(a.Fragment,{children:[g.length>0&&(0,a.jsxs)(d.$n,{size:"sm",variant:"danger",icon:"delete",onClick:()=>{let e=g.length;0!==e&&eY({title:`Delete ${e} Connection${e>1?"s":""}`,message:`Delete ${e} connection${e>1?"s":""}? This cannot be undone.`,onConfirm:async()=>{eY(null);let e=0,t=[...g],s=[];for(let a of t)try{(await fetch(`/api/providers/${a}`,{method:"DELETE"})).ok?s.push(a):e+=1}catch(t){(0,P.s)("Error deleting connection:",t),e+=1}f(e=>e.filter(e=>!s.includes(e.id))),b([]),e>0&&(0,P.s)(`Deleted ${t.length-e} connection(s), ${e} failed.`)}})},children:["Delete Selected (",g.length,")"]}),(0,a.jsx)(d.$n,{size:"sm",variant:"secondary",icon:"sync",onClick:sd,disabled:e2,children:e2?"Testing Connection One-by-One...":"Test Connection One-by-One"}),e2&&(0,a.jsx)(d.$n,{size:"sm",variant:"ghost",icon:"stop",onClick:()=>{e2&&(ts.current=!0,e4(!0))},disabled:e3,children:e3?"Stopping...":"Stop"})]}),(0,a.jsxs)("div",{className:"flex flex-col gap-2 rounded-xl border border-border/60 bg-surface-2/40 p-3",children:[(0,a.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("span",{className:"text-xs font-medium text-text-main",children:"Balanced Scheduler"}),(0,a.jsx)(d.m_,{text:"Process-local least-inflight scheduling with fresh quota signals. Sessions stay on one account and rebind on failure, cooldown, or cap.",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[15px] text-text-muted cursor-help",children:"info"})})]}),(0,a.jsxs)("div",{className:"flex items-center gap-3",children:[eD&&(0,a.jsxs)("label",{className:"flex items-center gap-1.5 text-xs text-text-muted",children:["Affinity",(0,a.jsx)("input",{"aria-label":"Session affinity minutes",type:"number",min:1,max:1440,value:eP,onChange:e=>se(e.target.value),className:"w-14 px-2 py-0.5 text-xs border border-border rounded-md bg-background text-text-main focus:outline-none focus:border-primary"}),(0,a.jsx)("span",{className:"text-[11px]",children:"min"})]}),(0,a.jsx)(d.lM,{checked:eD,onChange:t9,"aria-label":"Balanced scheduler"})]})]}),(0,a.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-3 pt-2 border-t border-border/40",title:eD?"Saved and used again when balanced scheduling is off":void 0,children:[(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("span",{className:"text-xs font-medium text-text-main",children:"Round Robin"}),(0,a.jsx)(d.m_,{text:"Cycles through connections sequentially in round-robin fashion.",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[15px] text-text-muted cursor-help",children:"info"})})]}),(0,a.jsxs)("div",{className:"flex items-center gap-3",children:["round-robin"===eO&&(0,a.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,a.jsx)("span",{className:"text-xs text-text-muted",children:"Sticky:"}),(0,a.jsx)("input",{type:"number",min:1,value:eE,onChange:e=>t7(e.target.value),placeholder:"1",disabled:eD,title:eD?"Saved and used again when balanced scheduling is off":void 0,className:"w-14 px-2 py-0.5 text-xs border border-border rounded-md bg-background text-text-main focus:outline-none focus:border-primary disabled:cursor-not-allowed disabled:opacity-50"})]}),(0,a.jsx)(d.lM,{checked:"round-robin"===eO,onChange:t8,"aria-label":"Round Robin",disabled:eD,title:eD?"Saved and used again when balanced scheduling is off":void 0})]})]})]})]})]}),0===h.length?(0,a.jsxs)("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[(0,a.jsxs)("div",{className:"flex items-center gap-3",children:[(0,a.jsx)("div",{className:"inline-flex items-center justify-center w-9 h-9 rounded-full bg-primary/10 text-primary shrink-0",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:tC?"lock":"key"})}),(0,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsx)("p",{className:"text-sm text-text-muted",children:"No connections yet"}),tP&&(0,a.jsxs)("p",{className:"text-xs text-text-muted",children:["Choose ",tz," or ",tU,"."]})]})]}),(0,a.jsx)("div",{className:"flex gap-2",children:tP?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(d.$n,{size:"sm",icon:"lock",variant:"secondary",onClick:tF,children:tz}),(0,a.jsx)(d.$n,{size:"sm",icon:"key",onClick:t_,children:tU})]}):(0,a.jsxs)(a.Fragment,{children:[!tI&&ef.has(p)&&(0,a.jsx)(B,{providerId:p,onConnected:t2}),!tI&&"iflow"===p&&(0,a.jsx)(d.$n,{size:"sm",icon:"cookie",variant:"secondary",onClick:()=>I(!0),children:"Cookie"}),"codex"===p&&(0,a.jsx)(d.$n,{size:"sm",icon:"playlist_add",variant:"secondary",onClick:()=>L(!0),children:(0,A.Tl)("Bulk Add")}),"grok-cli"===p&&(0,a.jsx)(d.$n,{size:"sm",icon:"playlist_add",variant:"secondary",onClick:()=>Z(!0),children:(0,A.Tl)("Bulk Add")}),(0,a.jsx)(d.$n,{size:"sm",icon:"add",onClick:tJ,children:tI?"Add API Key":"iflow"===p?"OAuth":"Add Connection"})]})})]}):(0,a.jsxs)(a.Fragment,{children:[te&&(0,a.jsx)("div",{className:"mb-4 rounded-lg border border-black/10 bg-black/[0.02] px-3 py-2 text-xs text-text-muted dark:border-white/10 dark:bg-white/[0.03]",children:(0,a.jsxs)("div",{className:"flex flex-wrap items-center gap-3",children:[(0,a.jsxs)("span",{children:["Total: ",te.total]}),(0,a.jsxs)("span",{children:["Completed: ",te.completed]}),(0,a.jsxs)("span",{children:["Passed: ",te.passed]}),(0,a.jsxs)("span",{children:["Failed: ",te.failed]}),te.stopped&&(0,a.jsx)("span",{className:"text-amber-600 dark:text-amber-400",children:"Stopped"}),e2&&e6&&(0,a.jsxs)("span",{children:["Running: ",h.find(e=>e.id===e6)?.name||e6]})]})}),h.length>0&&(0,a.jsx)("div",{className:"mb-3 flex items-center gap-2 border-b border-black/[0.03] pb-2 dark:border-white/[0.03]",children:(0,a.jsxs)("label",{className:"flex cursor-pointer items-center gap-1.5 text-xs text-text-muted hover:text-primary",children:[(0,a.jsx)("input",{type:"checkbox",checked:sg,onChange:()=>{sg?b([]):b(h.map(e=>e.id))},className:"h-3.5 w-3.5 rounded border-gray-300 text-primary focus:ring-primary"}),"Select All"]})}),sb,!tI&&(0,a.jsxs)("div",{className:"mt-4 grid grid-cols-1 gap-2 sm:flex",children:["iflow"===p&&(0,a.jsx)(d.$n,{size:"sm",icon:"cookie",variant:"secondary",onClick:()=>I(!0),title:"Add connection using browser cookie",className:"w-full sm:w-auto",children:"Cookie"}),"codex"===p&&(0,a.jsx)(d.$n,{size:"sm",icon:"playlist_add",variant:"secondary",onClick:()=>L(!0),title:(0,A.Tl)("Bulk import codex accounts from JSON"),className:"w-full sm:w-auto",children:(0,A.Tl)("Bulk Add")}),"grok-cli"===p&&(0,a.jsx)(d.$n,{size:"sm",icon:"playlist_add",variant:"secondary",onClick:()=>Z(!0),title:(0,A.Tl)("Bulk import Grok CLI accounts from JSON"),className:"w-full sm:w-auto",children:(0,A.Tl)("Bulk Add")}),tP?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(d.$n,{size:"sm",icon:"lock",variant:"secondary",onClick:tF,className:"w-full sm:w-auto",children:tz}),(0,a.jsx)(d.$n,{size:"sm",icon:"key",onClick:t_,className:"w-full sm:w-auto",children:tU})]}):(0,a.jsxs)(a.Fragment,{children:[ef.has(p)&&(0,a.jsx)(B,{providerId:p,onConnected:t2}),(0,a.jsx)(d.$n,{size:"sm",icon:"add",onClick:tJ,className:"w-full sm:w-auto",children:"Add"})]})]})]})]}),(0,a.jsx)(en,{providerId:p,scheduleKey:tH},p),(0,a.jsx)(ec,{providerId:p}),(0,a.jsxs)(d.Zp,{children:[(0,a.jsxs)("div",{className:"mb-4 flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between",children:[(0,a.jsxs)("div",{className:"flex items-center gap-3",children:[(0,a.jsx)("h2",{className:"text-lg font-semibold",children:"Available Models"}),tK&&(0,a.jsx)("select",{value:eU,onChange:e=>{var t;eq(t=e.target.value),st(t)},title:"Appends (level) suffix to copied model names",className:"rounded-md border border-border bg-background px-2 py-1 text-xs focus:border-primary focus:outline-none",children:tK.map(e=>(0,a.jsx)("option",{value:e,children:`Thinking: ${e.charAt(0).toUpperCase()+e.slice(1)}`},e))})]}),tM.showToolbar&&(e=(tM.showBulkControls?[...tT,...eV.filter(e=>!tT.some(t=>t.id===e.id))].filter(e=>{let t=(0,m.CP)(e);return!t||"llm"===t}).map(e=>e.id):[]).filter(e=>!tV(e)),(0,a.jsxs)("div",{className:"flex flex-wrap gap-2",children:[tM.showImport&&(0,a.jsx)(d.$n,{size:"sm",variant:"secondary",icon:tn?"progress_activity":"cloud_download",onClick:so,disabled:tn||!tD,title:tD?"Import models from the active connection":"Add an active connection to import models",children:tn?"Importing...":"Import models"}),tM.showVerify&&(0,a.jsx)(d.$n,{size:"sm",variant:"secondary",icon:tu?.status==="running"?"progress_activity":"science",onClick:()=>tm(e=>!e),children:tu?.status==="running"?`Verifying ${tu.done}/${tu.total}`:tc?"Hide verify":"Verify models"}),tM.showBulkControls&&eG.length>0&&(0,a.jsx)(d.$n,{size:"sm",variant:"secondary",icon:"restart_alt",onClick:tY,children:"Active All"}),tM.showBulkControls&&e.length>0&&(0,a.jsx)(d.$n,{size:"sm",variant:"secondary",icon:"block",onClick:()=>tX(e),children:"Disable All"})]}))]}),!!ew&&(0,a.jsx)("p",{className:"text-xs text-red-500 mb-3 break-words",children:ew}),"zed"===p&&!!eN&&(0,a.jsx)("p",{className:"text-xs text-red-500 mb-3 break-words",children:eN}),to&&(0,a.jsxs)("div",{className:"mb-3 flex items-center justify-between gap-2 rounded-xl border border-primary/30 bg-primary/10 px-3.5 py-2 text-xs font-medium text-text-main",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[16px] text-primary",children:"info"}),(0,a.jsx)("span",{children:to})]}),(0,a.jsx)("button",{onClick:()=>td(""),className:"text-text-muted hover:text-text-main p-0.5 rounded",title:"Dismiss",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-sm",children:"close"})})]}),tc&&(t=h.find(e=>g.includes(e.id)&&!1!==e.isActive)||h.find(e=>!1!==e.isActive),s=[...(0,R.R3)({customModels:eo,modelAliases:ei,providerAlias:tB,builtInModels:tT,type:"llm"}).filter(e=>!tV(e.id)).map(e=>({id:e.id,name:e.name||e.id,kind:"llm"})),...tT.filter(e=>{let t=(0,m.CP)(e);return(!t||"llm"===t)&&!tV(e.id)}).map(e=>({id:e.id,name:e.name||e.id,kind:"llm"}))],(0,a.jsx)(et,{connectionId:t?.id,providerAlias:tB,models:s,jobSnapshot:tu,onClose:()=>tm(!1),onStarted:e=>{tp(e&&e.status?e:null);let s=e?.connectionId||t?.id;s&&sa(s)},onComplete:async e=>{e?.removedStatus&&tp(t=>t?{...t,dead:Number(e.dead??t.dead??0),retryable:Number(e.retryable??t.retryable??0),retryableAuthOnly:!0===e.retryableAuthOnly}:t),e?.removed>0&&await t1(),e?.removed>0&&await tZ(),(e?.removed>0||e?.cacheCleared)&&await t5(t?.id)}})),(()=>{let e,t,s;if(tI)return(0,a.jsx)(q,{providerStorageAlias:tB,providerDisplayAlias:tH,modelAliases:ei,customModels:eo,copied:tv,onCopy:tj,onSetAlias:sr,onDeleteAlias:si,onAddCustomModel:e=>sn(e,"llm",tB),onDeleteCustomModel:e=>sl(e,"llm",tB),onRefreshModels:t1,connections:h,isAnthropic:tE,disabledModelIds:eG,onEnableModel:tQ});let r=[...tT,...eV.filter(e=>!tT.some(t=>t.id===e.id))].filter(e=>{let t=(0,m.CP)(e);return!t||"llm"===t}),i=r.filter(e=>!tV(e.id)),n=r.filter(e=>tV(e.id)),l=(0,R.R3)({customModels:eo,modelAliases:ei,providerAlias:tB,builtInModels:tT,type:"llm"}),o=l.filter(e=>!tV(e.id)&&("all"===tb||(tf[(0,ep.v)(e.id,tB)]||null)===tb)),d=i.filter(e=>"all"===tb||(tf[(0,ep.v)(e.id,tB)]||null)===tb);return(0,a.jsxs)("div",{className:"flex flex-col gap-3",children:[(0,a.jsx)("div",{className:"mb-2 flex flex-wrap items-center gap-1.5 text-xs",children:[{id:"all",label:"All",count:i.length+l.filter(e=>!tV(e.id)).length},{id:"ok",label:"Reachable",count:[...i,...l].filter(e=>!tV(e.id)&&("ok"===tf[(0,ep.v)(e.id,tB)]||"ok"===ev[e.id])).length},{id:"dead",label:"Dead",count:[...i,...l].filter(e=>!tV(e.id)&&("dead"===tf[(0,ep.v)(e.id,tB)]||"error"===ev[e.id])).length},{id:"retry",label:"Retry",count:[...i,...l].filter(e=>!tV(e.id)&&"retry"===tf[(0,ep.v)(e.id,tB)]).length}].map(e=>(0,a.jsxs)("button",{onClick:()=>ty(e.id),className:`inline-flex items-center gap-1.5 rounded-lg px-2.5 py-1 text-xs font-medium transition-all ${tb===e.id?"bg-primary text-black font-semibold shadow-sm":"bg-surface-2/60 border border-border/40 text-text-muted hover:border-border hover:text-text-main"}`,children:[(0,a.jsx)("span",{children:e.label}),(0,a.jsx)("span",{className:`rounded-full px-1.5 py-0.2 text-[10px] tabular-nums ${tb===e.id?"bg-black/20 text-black font-bold":"bg-black/10 dark:bg-white/10 text-text-muted"}`,children:e.count})]},e.id))}),(0,a.jsxs)("div",{className:"flex flex-wrap gap-3",children:[o.map(e=>{let t=(0,ep.v)(e.id,tB);return(0,a.jsx)(M,{model:{id:e.id,name:e.name},fullModel:`${tH}/${e.id}`,alias:e.alias,copied:tv,onCopy:tj,onSetAlias:()=>{},onDeleteAlias:()=>{"custom"===e.source?sl(e.id,"llm",tB):si(e.alias)},testStatus:ev[e.id],onTest:h.length>0||t$?()=>sy(e.id):void 0,isTesting:eS.has(e.id),isCustom:!0,isFree:!1,caps:x(`${p}/${e.id}`),thinkingSuffix:tL(e.id),latencyMs:tx[e.id]??tx[t],probeState:tu?.status==="running"&&tu?.perModel?.[t]?tu.perModel[t]:tf[t]||null},`${e.source}-${e.fullModel}`)}),d.map(e=>{let t=`${tB}/${e.id}`,s=`${p}/${e.id}`,r=Object.entries(ei).find(([,e])=>e===t||e===s)?.[0],i=(0,ep.v)(e.id,tB);return(0,a.jsx)(M,{model:e,fullModel:`${tH}/${e.id}`,alias:r,copied:tv,onSetAlias:t=>sr(e.id,t,tB),onCopy:tj,onDeleteAlias:()=>si(r),testStatus:ev[e.id],onTest:h.length>0||t$?()=>sy(e.id):void 0,isTesting:eS.has(e.id),isFree:e.isFree,onDisable:()=>tG(e.id),caps:x(`${p}/${e.id}`),thinkingSuffix:tL(e.id),latencyMs:tx[e.id]??tx[i],probeState:tu?.status==="running"&&tu?.perModel?.[i]?tu.perModel[i]:tf[i]||null},e.id)}),(0,a.jsxs)("button",{onClick:()=>eT(!0),className:"flex min-h-[58px] min-w-[200px] flex-1 items-center justify-center gap-2 rounded-xl border border-dashed border-primary/40 bg-primary/5 px-4 py-3 text-xs font-medium text-primary transition-all hover:border-primary hover:bg-primary/10 hover:shadow-soft sm:flex-none",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:"add_circle"}),"Add Custom Model"]}),eK.length>0&&(e=new Set([...Object.values(ei),...l.map(e=>e.fullModel)]),t=new Set(tT.map(e=>e.id)),0===(s=eK.filter(s=>!e.has(`${tB}/${s.id}`)&&!t.has(s.id))).length?null:(0,a.jsxs)("div",{className:"w-full mt-2",children:[(0,a.jsx)("p",{className:"text-xs text-text-muted mb-2",children:"Suggested free models (≥200k context):"}),(0,a.jsx)("div",{className:"flex flex-wrap gap-2",children:s.map(e=>(0,a.jsxs)("button",{onClick:async()=>{await sn(e.id,"llm",tB)},className:"flex items-center gap-1 px-2.5 py-1.5 rounded-lg border border-black/10 dark:border-white/10 text-xs text-text-muted hover:text-primary hover:border-primary/40 hover:bg-primary/5 transition-colors",title:`${e.name} \xb7 ${(e.contextLength/1e3).toFixed(0)}k ctx`,children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[13px]",children:"add"}),e.id.split("/").pop()]},e.id))})]})),n.length>0&&(0,a.jsxs)("div",{className:"w-full mt-2",children:[(0,a.jsxs)("p",{className:"text-xs text-text-muted mb-2",children:["Disabled models (",n.length,"):"]}),(0,a.jsx)("div",{className:"flex flex-wrap gap-2",children:n.map(e=>(0,a.jsxs)("button",{onClick:()=>tQ(e.id),className:"flex items-center gap-1 px-2.5 py-1.5 rounded-lg border border-dashed border-black/10 dark:border-white/10 text-xs text-text-muted hover:text-primary hover:border-primary/40 hover:bg-primary/5 transition-colors",title:"Restore model",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[13px]",children:"add"}),e.id]},e.id))})]})]})]})})()]}),"kiro"===p?(0,a.jsx)(d.Mh,{isOpen:k,providerInfo:tk,onSuccess:sm,onClose:()=>N(!1)}):"cursor"===p?(0,a.jsx)(d.G9,{isOpen:k,onSuccess:sm,onClose:()=>N(!1)}):"zed"===p?(0,a.jsx)(d.TE,{isOpen:k,providerInfo:tk,onSuccess:sm,onClose:()=>N(!1)}):"gitlab"===p?(0,a.jsx)(d.vj,{isOpen:k,providerInfo:tk,onSuccess:sm,onClose:()=>N(!1)}):(0,a.jsx)(d.LF,{isOpen:k,provider:p,providerInfo:tk,onSuccess:sm,onClose:()=>N(!1)}),"iflow"===p&&(0,a.jsx)(d.vE,{isOpen:T,onSuccess:()=>{t2(),I(!1)},onClose:()=>I(!1)}),(0,a.jsx)(K,{isOpen:D,provider:p,providerName:tk.name,isCompatible:tI,isAnthropic:tE,authType:tk?.authType,authHint:tk?.authHint,website:tk?.website,error:U,onSave:su,onBulkDone:t2,onClose:()=>{F(""),z(!1)}}),(0,a.jsx)(d.wI,{isOpen:Q,connection:ea,onSave:sp,onClose:()=>X(!1)}),tI&&(0,a.jsx)(H,{isOpen:ee,node:j,onSave:t3,onClose:()=>es(!1),isAnthropic:tE}),!tI&&(0,a.jsx)(V,{isOpen:eA,providerAlias:tB,providerDisplayAlias:tH,onSave:async(e,t,s,a)=>{await sn(e,s||"llm",tB,t,a),eT(!1)},onClose:()=>eT(!1)}),"codex"===p&&(0,a.jsx)(G,{isOpen:_,onClose:()=>L(!1),onSuccess:t2}),"grok-cli"===p&&(0,a.jsx)(Y,{isOpen:W,onClose:()=>Z(!1),onSuccess:t2}),eJ&&(0,a.jsx)(em.A,{isOpen:!!eJ,onClose:()=>eL(null),connection:eJ,reactive:!0===eF.connections[eJ.id],schedule:eF.schedules?.[eJ.id]||null,onSave:e=>((e,{reactive:t,schedule:s})=>{ss({...eF,connections:{...eF.connections,[e]:t},schedules:{...eF.schedules,[e]:s}})})(eJ.id,e)}),(0,a.jsx)(d.uo,{isOpen:e0,onClose:()=>e1(!1),onConfirm:()=>{(window.localStorage.setItem(tw,"true"),e1(!1),tC)?tq():t_()},title:"Risk Notice",message:tk?.deprecationNotice,confirmText:"I Understand, Continue",cancelText:"Cancel",variant:"danger"}),(0,a.jsx)(d.uo,{isOpen:!!eX,onClose:()=>eY(null),onConfirm:eX?.onConfirm,title:eX?.title||"Confirm",message:eX?.message,variant:"danger"})]}):(0,a.jsxs)("div",{className:"text-center py-20",children:[(0,a.jsx)("p",{className:"text-text-muted",children:"Provider not found"}),(0,a.jsx)(l(),{href:"/dashboard/providers",className:"text-primary mt-4 inline-block",children:"Back to Providers"})]})}},93195:(e,t,s)=>{"use strict";function a(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone||"UTC"}catch{return"UTC"}}s.d(t,{JW:()=>o,Vm:()=>a,fB:()=>i,gy:()=>r,nz:()=>n});let r={anchor:"09:30",timezone:a(),windowHours:5,slotsPerDay:3};function i(e){let t=/^(\d{1,2}):(\d{2})$/.exec(String(e||"").trim());if(!t)return null;let s=Number(t[1]),a=Number(t[2]);return s>23||a>59?null:{hour:s,minute:a}}function n(e){return Math.max(1,Math.floor(24/e))}function l(e,t,s,a){let r="number"==typeof e?e:Number(e);return Number.isFinite(r)?Math.min(a,Math.max(s,r)):t}function o(e){let t=function(e){if(!e||!0!==e.enabled)return null;let t=i(e.anchor)||i(r.anchor),s=`${String(t.hour).padStart(2,"0")}:${String(t.minute).padStart(2,"0")}`,a=!function(e){if(!e||"string"!=typeof e)return!1;try{return new Intl.DateTimeFormat("en-US",{timeZone:e}),!0}catch{return!1}}(e.timezone)?r.timezone:e.timezone,o=l(e.windowHours,r.windowHours,.5,24),d=Math.round(l(e.slotsPerDay,r.slotsPerDay,1,n(o)));return{enabled:!0,anchor:s,timezone:a,windowHours:o,slotsPerDay:d}}(e);if(!t)return[];let{hour:s,minute:a}=i(t.anchor),o=60*s+a;return Array.from({length:t.slotsPerDay},(e,s)=>{let a=Math.round(o+s*t.windowHours*60)%1440;return`${String(Math.floor(a/60)).padStart(2,"0")}:${String(a%60).padStart(2,"0")}`})}},97132:(e,t,s)=>{"use strict";s.d(t,{A:()=>m});var a=s(95155),r=s(12115),i=s(14051),n=s.n(i),l=s(35497),o=s(31474),d=s(93195);let c=[{value:"off",label:"Off",icon:"block"},{value:"reset",label:"On reset",icon:"bolt"},{value:"schedule",label:"Schedule",icon:"schedule"}];function m({isOpen:e,onClose:t,onSave:s,connection:i,reactive:n=!1,schedule:u=null}){let[p,x]=(0,r.useState)(()=>({mode:u?.enabled===!0?"schedule":!0===n?"reset":"off",anchor:u?.anchor||d.gy.anchor,timezone:(0,d.Vm)(),windowHours:String(u?.windowHours??d.gy.windowHours),slotsPerDay:String(u?.slotsPerDay??d.gy.slotsPerDay)})),h=Number(p.windowHours),f=Number(p.slotsPerDay),g=!!(0,d.fB)(p.anchor),b=Number.isFinite(h)&&h>=.5&&h<=24,y=b?(0,d.nz)(h):24,v=Number.isInteger(f)&&f>=1&&f<=y,j=g&&b&&v,w="schedule"!==p.mode||j,k=j?(0,d.JW)({enabled:!0,...p,windowHours:h,slotsPerDay:f}):[],N=k.length&&b?(()=>{let{hour:e,minute:t}=(0,d.fB)(p.anchor),s=Math.round(60*e+t+f*h*60)%1440;return`${String(Math.floor(s/60)).padStart(2,"0")}:${String(s%60).padStart(2,"0")}`})():"",C=e=>x(t=>({...t,...e}));return(0,a.jsx)(l.aF,{isOpen:e,onClose:t,title:"Auto-ping settings",size:"lg",footer:(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(l.$n,{variant:"secondary",onClick:t,children:"Cancel"}),(0,a.jsx)(l.$n,{onClick:()=>{w&&(s({reactive:"reset"===p.mode,schedule:"schedule"===p.mode?{enabled:!0,anchor:p.anchor,timezone:p.timezone,windowHours:h,slotsPerDay:f}:{enabled:!1}}),t())},disabled:!w,children:"Save"})]}),children:(0,a.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,a.jsxs)("p",{className:"text-sm text-text-muted",children:["Configure automated quota pings",i?.name?` for ${i.name}`:""," — pick one mode."]}),(0,a.jsx)("div",{className:"grid grid-cols-3 gap-1 rounded-[10px] bg-surface-2 p-1",children:c.map(e=>{let t=p.mode===e.value;return(0,a.jsxs)("button",{type:"button",onClick:()=>C({mode:e.value}),className:(0,o.cn)("flex h-9 items-center justify-center gap-1.5 rounded-[8px] px-3 text-sm font-medium transition-all",t?"bg-surface text-text-main shadow-sm":"text-text-muted hover:text-text-main"),children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[15px] leading-none",children:e.icon}),(0,a.jsx)("span",{children:e.label})]},e.value)})}),"reset"===p.mode&&(0,a.jsx)("p",{className:"text-xs text-text-muted",children:"Pings right after the 5h quota window resets, so a new window starts immediately."}),"schedule"===p.mode&&(0,a.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,a.jsx)("p",{className:"text-xs text-text-muted",children:"Pings at fixed local times so the 5h windows align with your workday."}),(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-4 sm:grid-cols-3",children:[(0,a.jsx)(l.pd,{label:"Anchor time",type:"time",value:p.anchor,onChange:e=>C({anchor:e.target.value}),error:g?"":"Use HH:MM",inputClassName:"ring-1 ring-black/10 dark:ring-white/15"}),(0,a.jsx)(l.pd,{label:"Window (hours)",type:"number",min:"0.5",max:"24",step:"0.5",value:p.windowHours,onChange:e=>C({windowHours:e.target.value}),error:b?"":"0.5 – 24",inputClassName:"ring-1 ring-black/10 dark:ring-white/15"}),(0,a.jsx)(l.pd,{label:"Pings per day",type:"number",min:"1",max:String(y),step:"1",value:p.slotsPerDay,onChange:e=>C({slotsPerDay:e.target.value}),error:v?"":`1 – ${y}`,hint:v?`Max ${y}`:"",inputClassName:"ring-1 ring-black/10 dark:ring-white/15"})]}),k.length>0&&(0,a.jsxs)("div",{className:"rounded-[10px] bg-surface-2 px-3 py-2.5",children:[(0,a.jsxs)("p",{className:"text-xs font-medium uppercase tracking-wide text-text-muted",children:["Daily slots (",p.timezone,")"]}),(0,a.jsx)("p",{className:"mt-1 text-sm font-medium text-text-main",children:k.join(" → ")}),(0,a.jsxs)("p",{className:"mt-1 text-xs text-text-muted",children:["Covers ",k[0]," – ",N,", then pauses until ",k[0]," next day."]})]})]})]})})}m.propTypes={isOpen:n().bool.isRequired,onClose:n().func.isRequired,onSave:n().func.isRequired,connection:n().object,reactive:n().bool,schedule:n().object}}},e=>{e.O(0,[782,8500,7854,4601,1321,2410,979,8441,3794,7358],()=>e(e.s=7687)),_N_E=e.O()}]);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
mIIf1bKJ8KlrHk03nHIsh
|