diff --git a/.circleci/config.yml b/.circleci/config.yml index 8672561f654..6c7bbddb9f1 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -112,6 +112,24 @@ jobs: python -m mypy . cd .. no_output_timeout: 10m + + semgrep: + docker: + - image: cimg/python:3.12 + auth: + username: ${DOCKERHUB_USERNAME} + password: ${DOCKERHUB_PASSWORD} + working_directory: ~/project + steps: + - checkout + - setup_google_dns + - run: + name: Install Semgrep + command: pip install semgrep + - run: + name: Run Semgrep (custom rules only) + command: semgrep scan --config .semgrep/rules . --error + local_testing_part1: docker: - image: cimg/python:3.12 @@ -1372,6 +1390,51 @@ jobs: paths: - mcp_coverage.xml - mcp_coverage + agent_testing: + docker: + - image: cimg/python:3.11 + auth: + username: ${DOCKERHUB_USERNAME} + password: ${DOCKERHUB_PASSWORD} + working_directory: ~/project + + steps: + - checkout + - setup_google_dns + - run: + name: Install Dependencies + command: | + python -m pip install --upgrade pip + python -m pip install -r requirements.txt + pip install "pytest==7.3.1" + pip install "pytest-retry==1.6.3" + pip install "pytest-cov==5.0.0" + pip install "pytest-asyncio==0.21.1" + pip install "respx==0.22.0" + pip install "pydantic==2.11.0" + pip install "a2a-sdk" + # Run pytest and generate JUnit XML report + - run: + name: Run tests + command: | + pwd + ls + python -m pytest -vv tests/agent_tests --ignore=tests/agent_tests/local_only_agent_tests --cov=litellm --cov-report=xml -x -s -v --junitxml=test-results/junit.xml --durations=5 + no_output_timeout: 120m + - run: + name: Rename the coverage files + command: | + mv coverage.xml agent_coverage.xml + mv .coverage agent_coverage + + # Store test results + - store_test_results: + path: test-results + - persist_to_workspace: + root: . + paths: + - agent_coverage.xml + - agent_coverage guardrails_testing: docker: - image: cimg/python:3.11 @@ -2232,6 +2295,7 @@ jobs: - run: python ./tests/code_coverage_tests/router_code_coverage.py - run: python ./tests/code_coverage_tests/test_chat_completion_imports.py - run: python ./tests/code_coverage_tests/info_log_check.py + - run: python ./tests/code_coverage_tests/check_guardrail_apply_decorator.py - run: python ./tests/code_coverage_tests/test_ban_set_verbose.py - run: python ./tests/code_coverage_tests/code_qa_check_tests.py - run: python ./tests/code_coverage_tests/check_get_model_cost_key_performance.py @@ -3756,7 +3820,6 @@ jobs: - run: name: Get new version command: | - cd litellm-proxy-extras NEW_VERSION=$(python -c "import toml; print(toml.load('pyproject.toml')['tool']['poetry']['version'])") echo "export NEW_VERSION=$NEW_VERSION" >> $BASH_ENV @@ -3781,7 +3844,6 @@ jobs: - run: name: Publish to PyPI command: | - cd litellm-proxy-extras echo -e "[pypi]\nusername = $PYPI_PUBLISH_USERNAME\npassword = $PYPI_PUBLISH_PASSWORD" > ~/.pypirc python -m pip install --upgrade pip build twine setuptools wheel rm -rf build dist @@ -3888,6 +3950,9 @@ jobs: image: ubuntu-2204:2023.10.1 resource_class: xlarge working_directory: ~/project + parameters: + browser: + type: string steps: - checkout - setup_google_dns @@ -3917,7 +3982,7 @@ jobs: echo "Expires at: $EXPIRES_AT" neon branches create \ --project-id $NEON_PROJECT_ID \ - --name preview/commit-${CIRCLE_SHA1:0:7} \ + --name preview/commit-${CIRCLE_SHA1:0:7}-<< parameters.browser >> \ --expires-at $EXPIRES_AT \ --parent br-fancy-paper-ad1olsb3 \ --api-key $NEON_API_KEY || true @@ -3927,7 +3992,7 @@ jobs: E2E_UI_TEST_DATABASE_URL=$(neon connection-string \ --project-id $NEON_PROJECT_ID \ --api-key $NEON_API_KEY \ - --branch preview/commit-${CIRCLE_SHA1:0:7} \ + --branch preview/commit-${CIRCLE_SHA1:0:7}-<< parameters.browser >> \ --database-name yuneng-trial-db \ --role neondb_owner) echo $E2E_UI_TEST_DATABASE_URL @@ -3939,7 +4004,7 @@ jobs: -e UI_USERNAME="admin" \ -e UI_PASSWORD="gm" \ -e LITELLM_LICENSE=$LITELLM_LICENSE \ - --name litellm-docker-database \ + --name litellm-docker-database-<< parameters.browser >> \ -v $(pwd)/litellm/proxy/example_config_yaml/simple_config.yaml:/app/config.yaml \ litellm-docker-database:ci \ --config /app/config.yaml \ @@ -3955,7 +4020,7 @@ jobs: sudo rm dockerize-linux-amd64-v0.6.1.tar.gz - run: name: Start outputting logs - command: docker logs -f litellm-docker-database + command: docker logs -f litellm-docker-database-<< parameters.browser >> background: true - run: name: Wait for app to be ready @@ -3964,6 +4029,7 @@ jobs: name: Run Playwright Tests command: | npx playwright test \ + --project << parameters.browser >> \ --config ui/litellm-dashboard/e2e_tests/playwright.config.ts \ --reporter=html \ --output=test-results @@ -4070,6 +4136,12 @@ workflows: only: - main - /litellm_.*/ + - semgrep: + filters: + branches: + only: + - main + - /litellm_.*/ - local_testing_part1: filters: branches: @@ -4169,6 +4241,20 @@ workflows: - main - /litellm_.*/ - e2e_ui_testing: + name: e2e_ui_testing_chromium + browser: chromium + context: e2e_ui_tests + requires: + - ui_build + - build_docker_database_image + filters: + branches: + only: + - main + - /litellm_.*/ + - e2e_ui_testing: + name: e2e_ui_testing_firefox + browser: firefox context: e2e_ui_tests requires: - ui_build @@ -4264,6 +4350,12 @@ workflows: only: - main - /litellm_.*/ + - agent_testing: + filters: + branches: + only: + - main + - /litellm_.*/ - guardrails_testing: filters: branches: @@ -4371,6 +4463,7 @@ workflows: - llm_translation_testing - realtime_translation_testing - mcp_testing + - agent_testing - google_generate_content_endpoint_testing - guardrails_testing - llm_responses_api_testing @@ -4441,6 +4534,7 @@ workflows: - publish_to_pypi: requires: - mypy_linting + - semgrep - local_testing_part1 - local_testing_part2 - build_and_test @@ -4449,6 +4543,7 @@ workflows: - llm_translation_testing - realtime_translation_testing - mcp_testing + - agent_testing - google_generate_content_endpoint_testing - llm_responses_api_testing - ocr_testing @@ -4472,7 +4567,8 @@ workflows: - litellm_assistants_api_testing - auth_ui_unit_tests - db_migration_disable_update_check - - e2e_ui_testing + - e2e_ui_testing_chromium + - e2e_ui_testing_firefox - litellm_proxy_unit_testing_key_generation - litellm_proxy_unit_testing_part1 - litellm_proxy_unit_testing_part2 diff --git a/.dockerignore b/.dockerignore index 76e31546c2f..a487d2a859a 100644 --- a/.dockerignore +++ b/.dockerignore @@ -48,7 +48,7 @@ dist/ build/ *.egg-info/ .DS_Store -node_modules/ +**/node_modules *.log .env .env.local diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md index b91b16c955c..f13039f4516 100644 --- a/.github/pull_request_template.md +++ b/.github/pull_request_template.md @@ -9,6 +9,7 @@ - [ ] I have Added testing in the [`tests/litellm/`](https://github.com/BerriAI/litellm/tree/main/tests/litellm) directory, **Adding at least 1 test is a hard requirement** - [see details](https://docs.litellm.ai/docs/extras/contributing_code) - [ ] My PR passes all unit tests on [`make test-unit`](https://docs.litellm.ai/docs/extras/contributing_code) - [ ] My PR's scope is as isolated as possible, it only solves 1 specific problem +- [ ] I have requested a Greptile review by commenting `@greptileai` and received a **Confidence Score of at least 4/5** before requesting a maintainer review ## CI (LiteLLM team) diff --git a/.semgrep/rules/README.md b/.semgrep/rules/README.md new file mode 100644 index 00000000000..6cffcc32963 --- /dev/null +++ b/.semgrep/rules/README.md @@ -0,0 +1,52 @@ +# Custom Semgrep Rules + +All `.yml` files under `.semgrep/rules/` run in CI (CircleCI `semgrep` job). + +## Add a Rule + +* Add a `.yml` file under `.semgrep/rules///` + + +[Rule syntax →](https://semgrep.dev/docs/writing-rules/rule-syntax/) + +## Organizing Rules + +### Structure: language → domain + +``` +.semgrep/rules///.yml +``` + +Examples: + +- `python/security/unsafe-yaml-load.yml` +- `python/reliability/missing-timeout-http.yml` +- `python/performance/blocking-io-in-async.yml` + +### Rule metadata + +Match tags to the folder for consistent filtering: + +```yaml +metadata: + tags: [python, security] +``` + +### Severity expectations + +All rules must fail CI on findings. No warn-only rules. + +- Use `severity: ERROR` in rule metadata +- If a rule is noisy → refine until low false positives before adding + +## Run Locally + +```bash +semgrep scan --config .semgrep/rules . --error +``` + +With Semgrep registry: + +```bash +semgrep scan --config auto --config .semgrep/rules . +``` diff --git a/.semgrep/rules/python/reliability/unbounded-memory.yml b/.semgrep/rules/python/reliability/unbounded-memory.yml new file mode 100644 index 00000000000..f13c38471fb --- /dev/null +++ b/.semgrep/rules/python/reliability/unbounded-memory.yml @@ -0,0 +1,17 @@ +# Unbounded memory growth – data structures without a clear max limit +# Can lead to OOM under load. + +rules: + - id: unbounded-asyncio-queue + message: asyncio.Queue() with no maxsize can grow unbounded. Use asyncio.Queue(maxsize=N) for integrations (e.g. log queues). + severity: ERROR + languages: [python] + pattern-either: + - pattern: asyncio.Queue() + - pattern: asyncio.Queue(maxsize=0) + metadata: + category: reliability + cwe: "CWE-400: Uncontrolled Resource Consumption" + tags: [python, reliability] + confidence: HIGH + source: https://docs.python.org/3/library/asyncio-queue.html diff --git a/CLAUDE.md b/CLAUDE.md index 23a0e97eaee..3cb67908076 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -90,6 +90,7 @@ LiteLLM is a unified interface for 100+ LLM providers with two main components: - Pydantic v2 for data validation - Async/await patterns throughout - Type hints required for all public APIs +- **Avoid imports within methods** — place all imports at the top of the file (module-level). Inline imports inside functions/methods make dependencies harder to trace and hurt readability. The only exception is avoiding circular imports where absolutely necessary. ### Testing Strategy - Unit tests in `tests/test_litellm/` diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index a418c8c57af..77bc15ff50b 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -7,11 +7,20 @@ Thank you for your interest in contributing to LiteLLM! We welcome contributions Here are the core requirements for any PR submitted to LiteLLM: - [ ] **Sign the Contributor License Agreement (CLA)** - [see details](#contributor-license-agreement-cla) +- [ ] **Keep scope isolated** - Your changes should address 1 specific problem at a time + +#### Proxy (Backend) PRs + - [ ] **Add testing** - Adding at least 1 test is a hard requirement - [see details](#adding-testing) - [ ] **Ensure your PR passes all checks**: - [ ] [Unit Tests](#running-unit-tests) - `make test-unit` - [ ] [Linting / Formatting](#running-linting-and-formatting-checks) - `make lint` -- [ ] **Keep scope isolated** - Your changes should address 1 specific problem at a time + +#### UI PRs + +- [ ] **Ensure the UI builds successfully** - `npm run build` +- [ ] **Ensure all UI unit tests pass** - `npm run test` +- [ ] **Add tests for new components or logic** - If you are adding a new component or new logic, add corresponding tests ## **Contributor License Agreement (CLA)** @@ -245,6 +254,43 @@ docker run \ --config /app/config.yaml --detailed_debug ``` +## UI Development + +### 1. Setup Your Local UI Development Environment + +```bash +# Clone the repo (if you haven't already) +git clone https://github.com/YOUR_USERNAME/litellm.git +cd litellm + +# Navigate to the UI dashboard directory +cd ui/litellm-dashboard + +# Install dependencies +npm install + +# Start the development server +npm run dev +``` + +### 2. Adding UI Tests + +If you are adding a **new component** or **new logic**, you must add corresponding tests. + +### 3. Running UI Unit Tests + +```bash +npm run test +``` + +### 4. Building the UI + +Ensure the UI builds successfully before submitting your PR: + +```bash +npm run build +``` + ## Submitting Your PR 1. **Push your branch**: `git push origin your-feature-branch` diff --git a/Dockerfile b/Dockerfile index 4bfda939110..5e93a0c627e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,6 +3,7 @@ ARG LITELLM_BUILD_IMAGE=cgr.dev/chainguard/wolfi-base # Runtime image ARG LITELLM_RUNTIME_IMAGE=cgr.dev/chainguard/wolfi-base + # Builder stage FROM $LITELLM_BUILD_IMAGE AS builder @@ -48,7 +49,22 @@ USER root # Install runtime dependencies (libsndfile needed for audio processing on ARM64) RUN apk add --no-cache bash openssl tzdata nodejs npm python3 py3-pip libsndfile && \ - npm install -g npm@latest tar@latest + npm install -g npm@latest tar@7.5.7 glob@11.1.0 @isaacs/brace-expansion@5.0.1 && \ + # SECURITY FIX: npm bundles tar, glob, and brace-expansion at multiple nested + # levels inside its dependency tree. `npm install -g ` only creates a + # SEPARATE global package, it does NOT replace npm's internal copies. + # We must find and replace EVERY copy inside npm's directory. + GLOBAL="$(npm root -g)" && \ + find "$GLOBAL/npm" -type d -name "tar" -path "*/node_modules/tar" | while read d; do \ + rm -rf "$d" && cp -rL "$GLOBAL/tar" "$d"; \ + done && \ + find "$GLOBAL/npm" -type d -name "glob" -path "*/node_modules/glob" | while read d; do \ + rm -rf "$d" && cp -rL "$GLOBAL/glob" "$d"; \ + done && \ + find "$GLOBAL/npm" -type d -name "brace-expansion" -path "*/node_modules/@isaacs/brace-expansion" | while read d; do \ + rm -rf "$d" && cp -rL "$GLOBAL/@isaacs/brace-expansion" "$d"; \ + done && \ + npm cache clean --force WORKDIR /app # Copy the current directory contents into the container at /app @@ -62,10 +78,28 @@ COPY --from=builder /wheels/ /wheels/ # Install the built wheel using pip; again using a wildcard if it's the only file RUN pip install *.whl /wheels/* --no-index --find-links=/wheels/ && rm -f *.whl && rm -rf /wheels +# Replace the nodejs-wheel-binaries bundled node with the system node (fixes CVE-2025-55130) +RUN NODEJS_WHEEL_NODE=$(find /usr/lib -path "*/nodejs_wheel/bin/node" 2>/dev/null) && \ + if [ -n "$NODEJS_WHEEL_NODE" ]; then cp /usr/bin/node "$NODEJS_WHEEL_NODE"; fi + # Remove test files and keys from dependencies RUN find /usr/lib -type f -path "*/tornado/test/*" -delete && \ find /usr/lib -type d -path "*/tornado/test" -delete +# SECURITY FIX: nodejs-wheel-binaries (pip package used by Prisma) bundles a complete +# npm with old vulnerable deps at /usr/lib/python3.*/site-packages/nodejs_wheel/. +# Patch every copy of tar, glob, and brace-expansion inside that tree. +RUN GLOBAL="$(npm root -g)" && \ + find /usr/lib -path "*/nodejs_wheel/*/node_modules/tar" -type d | while read d; do \ + rm -rf "$d" && cp -rL "$GLOBAL/tar" "$d"; \ + done && \ + find /usr/lib -path "*/nodejs_wheel/*/node_modules/glob" -type d | while read d; do \ + rm -rf "$d" && cp -rL "$GLOBAL/glob" "$d"; \ + done && \ + find /usr/lib -path "*/nodejs_wheel/*/node_modules/@isaacs/brace-expansion" -type d | while read d; do \ + rm -rf "$d" && cp -rL "$GLOBAL/@isaacs/brace-expansion" "$d"; \ + done + # Install semantic_router and aurelio-sdk using script # Convert Windows line endings to Unix and make executable RUN sed -i 's/\r$//' docker/install_auto_router.sh && chmod +x docker/install_auto_router.sh && ./docker/install_auto_router.sh diff --git a/README.md b/README.md index 77adddf8978..7790c67afd5 100644 --- a/README.md +++ b/README.md @@ -309,7 +309,7 @@ Support for more providers. Missing a provider or LLM Platform, raise a [feature | [Deepgram (`deepgram`)](https://docs.litellm.ai/docs/providers/deepgram) | ✅ | ✅ | ✅ | | | ✅ | | | | | | [DeepInfra (`deepinfra`)](https://docs.litellm.ai/docs/providers/deepinfra) | ✅ | ✅ | ✅ | | | | | | | | | [Deepseek (`deepseek`)](https://docs.litellm.ai/docs/providers/deepseek) | ✅ | ✅ | ✅ | | | | | | | | -| [ElevenLabs (`elevenlabs`)](https://docs.litellm.ai/docs/providers/elevenlabs) | ✅ | ✅ | ✅ | | | | ✅ | | | | +| [ElevenLabs (`elevenlabs`)](https://docs.litellm.ai/docs/providers/elevenlabs) | ✅ | ✅ | ✅ | | | ✅ | ✅ | | | | | [Empower (`empower`)](https://docs.litellm.ai/docs/providers/empower) | ✅ | ✅ | ✅ | | | | | | | | | [Fal AI (`fal_ai`)](https://docs.litellm.ai/docs/providers/fal_ai) | ✅ | ✅ | ✅ | | ✅ | | | | | | | [Featherless AI (`featherless_ai`)](https://docs.litellm.ai/docs/providers/featherless_ai) | ✅ | ✅ | ✅ | | | | | | | | diff --git a/ci_cd/.grype.yaml b/ci_cd/.grype.yaml index 642e2dd9d03..b9bc9db58f5 100644 --- a/ci_cd/.grype.yaml +++ b/ci_cd/.grype.yaml @@ -1,3 +1,36 @@ ignore: - vulnerability: CVE-2026-22184 reason: no fixed zlib package is available yet in the Wolfi repositories, so this is ignored temporarily until an upstream release exists + # Wolfi base image: Python 3.13 and Node from apk have no fixed builds in Wolfi yet / not applicable + - vulnerability: CVE-2025-55130 + reason: Node in Wolfi apk; only used for Admin UI build/prisma + - vulnerability: CVE-2025-59465 + reason: Node in Wolfi apk; only used for Admin UI build/prisma + - vulnerability: CVE-2025-55131 + reason: Node in Wolfi apk; only used for Admin UI build/prisma + - vulnerability: CVE-2025-59466 + reason: Node in Wolfi apk; only used for Admin UI build/prisma + - vulnerability: CVE-2026-21637 + reason: Node in Wolfi apk; only used for Admin UI build/prisma + - vulnerability: CVE-2025-55132 + reason: Node in Wolfi apk; only used for Admin UI build/prisma + - vulnerability: GHSA-hx9q-6w63-j58v + reason: orjson dumps recursion; allowlisted + - vulnerability: GHSA-73rr-hh4g-fpgx + reason: diff npm transitive dep; override in package.json, allowlisted + - vulnerability: CVE-2026-0865 + reason: Python 3.13 in Wolfi base; no fixed apk build yet + - vulnerability: CVE-2025-15282 + reason: Python 3.13 in Wolfi base; no fixed apk build yet + - vulnerability: CVE-2026-0672 + reason: Python 3.13 in Wolfi base; no fixed apk build yet + - vulnerability: CVE-2025-15366 + reason: Python 3.13 in Wolfi base; no fixed apk build yet + - vulnerability: CVE-2025-15367 + reason: Python 3.13 in Wolfi base; no fixed apk build yet + - vulnerability: CVE-2025-11468 + reason: Python 3.13 in Wolfi base; no fixed apk build yet + - vulnerability: CVE-2025-12781 + reason: Python 3.13 in Wolfi base; no fixed apk build yet + - vulnerability: CVE-2026-1299 + reason: Python 3.13 in Wolfi base; no fixed apk build yet diff --git a/ci_cd/security_scans.sh b/ci_cd/security_scans.sh index 340f8e96063..2db72ae5c69 100755 --- a/ci_cd/security_scans.sh +++ b/ci_cd/security_scans.sh @@ -140,12 +140,14 @@ run_grype_scans() { "GHSA-34x7-hfp2-rc4v" # node-tar hardlink path traversal - not applicable, tar CLI not exposed in application code "GHSA-r6q2-hw4h-h46w" # node-tar not used by application runtime, Linux-only container, not affect by macOS APFS-specific exploit "GHSA-8rrh-rw8j-w5fx" # wheel is from chainguard and will be handled by then TODO: Remove this after Chainguard updates the wheel - "CVE-2025-59465" # We do not use Node in application runtime, only used for building Admin UI - "CVE-2025-55131" # We do not use Node in application runtime, only used for building Admin UI - "CVE-2025-59466" # We do not use Node in application runtime, only used for building Admin UI - "CVE-2025-55130" # We do not use Node in application runtime, only used for building Admin UI - "CVE-2025-59467" # We do not use Node in application runtime, only used for building Admin UI - "CVE-2026-21637" # We do not use Node in application runtime, only used for building Admin UI + "CVE-2025-59465" # Node only used for Admin UI build/prisma + "CVE-2025-55131" # Node only used for Admin UI build/prisma + "CVE-2025-59466" # Node only used for Admin UI build/prisma + "CVE-2025-55130" # Node only used for Admin UI build/prisma + "CVE-2025-59467" # Node only used for Admin UI build/prisma + "CVE-2026-21637" # Node only used for Admin UI build/prisma + "CVE-2025-55132" # Node only used for Admin UI build/prisma + "GHSA-hx9q-6w63-j58v" # orjson dumps recursion; allowlisted "CVE-2025-15281" # No fix available yet "CVE-2026-0865" # No fix available yet "CVE-2025-15282" # No fix available yet @@ -155,6 +157,7 @@ run_grype_scans() { "CVE-2025-12781" # No fix available yet "CVE-2025-11468" # No fix available yet "CVE-2026-1299" # Python 3.13 email module header injection - not applicable, LiteLLM doesn't use BytesGenerator for email serialization + "CVE-2026-0775" # npm cli incorrect permission assignment - no fix available yet, npm is only used at build/prisma-generate time ) # Build JSON array of allowlisted CVE IDs for jq diff --git a/cookbook/nova_sonic_realtime.py b/cookbook/nova_sonic_realtime.py index 0ea0badfb01..c7a73c1d00f 100644 --- a/cookbook/nova_sonic_realtime.py +++ b/cookbook/nova_sonic_realtime.py @@ -16,10 +16,14 @@ Usage: import asyncio import base64 import json +import os import pyaudio import websockets from typing import Optional +# Bounded queue size for audio chunks (configurable via env to avoid unbounded memory) +AUDIO_QUEUE_MAXSIZE = int(os.getenv("LITELLM_ASYNCIO_QUEUE_MAXSIZE", 10_000)) + # Audio configuration (matching Nova Sonic requirements) INPUT_SAMPLE_RATE = 16000 # Nova Sonic expects 16kHz input OUTPUT_SAMPLE_RATE = 24000 # Nova Sonic outputs 24kHz @@ -40,7 +44,7 @@ class RealtimeClient: self.api_key = api_key self.ws: Optional[websockets.WebSocketClientProtocol] = None self.is_active = False - self.audio_queue = asyncio.Queue() + self.audio_queue = asyncio.Queue(maxsize=AUDIO_QUEUE_MAXSIZE) self.pyaudio = pyaudio.PyAudio() self.input_stream = None self.output_stream = None diff --git a/docker/Dockerfile.custom_ui b/docker/Dockerfile.custom_ui index 57926bcd170..177d7b7b12a 100644 --- a/docker/Dockerfile.custom_ui +++ b/docker/Dockerfile.custom_ui @@ -6,7 +6,18 @@ WORKDIR /app # Install Node.js and npm (adjust version as needed) RUN apt-get update && apt-get install -y nodejs npm && \ - npm install -g npm@latest tar@latest + npm install -g npm@latest tar@7.5.7 glob@11.1.0 @isaacs/brace-expansion@5.0.1 && \ + GLOBAL="$(npm root -g)" && \ + find "$GLOBAL/npm" -type d -name "tar" -path "*/node_modules/tar" | while read d; do \ + rm -rf "$d" && cp -rL "$GLOBAL/tar" "$d"; \ + done && \ + find "$GLOBAL/npm" -type d -name "glob" -path "*/node_modules/glob" | while read d; do \ + rm -rf "$d" && cp -rL "$GLOBAL/glob" "$d"; \ + done && \ + find "$GLOBAL/npm" -type d -name "brace-expansion" -path "*/node_modules/@isaacs/brace-expansion" | while read d; do \ + rm -rf "$d" && cp -rL "$GLOBAL/@isaacs/brace-expansion" "$d"; \ + done && \ + npm cache clean --force # Copy the UI source into the container COPY ./ui/litellm-dashboard /app/ui/litellm-dashboard diff --git a/docker/Dockerfile.database b/docker/Dockerfile.database index 24bf706434d..a6fcd98ab6d 100644 --- a/docker/Dockerfile.database +++ b/docker/Dockerfile.database @@ -50,7 +50,18 @@ USER root # Install runtime dependencies RUN apk add --no-cache bash openssl tzdata nodejs npm python3 py3-pip libsndfile && \ - npm install -g npm@latest tar@latest + npm install -g npm@latest tar@7.5.7 glob@11.1.0 @isaacs/brace-expansion@5.0.1 && \ + GLOBAL="$(npm root -g)" && \ + find "$GLOBAL/npm" -type d -name "tar" -path "*/node_modules/tar" | while read d; do \ + rm -rf "$d" && cp -rL "$GLOBAL/tar" "$d"; \ + done && \ + find "$GLOBAL/npm" -type d -name "glob" -path "*/node_modules/glob" | while read d; do \ + rm -rf "$d" && cp -rL "$GLOBAL/glob" "$d"; \ + done && \ + find "$GLOBAL/npm" -type d -name "brace-expansion" -path "*/node_modules/@isaacs/brace-expansion" | while read d; do \ + rm -rf "$d" && cp -rL "$GLOBAL/@isaacs/brace-expansion" "$d"; \ + done && \ + npm cache clean --force WORKDIR /app # Copy the current directory contents into the container at /app @@ -64,6 +75,20 @@ COPY --from=builder /wheels/ /wheels/ # Install the built wheel using pip; again using a wildcard if it's the only file RUN pip install *.whl /wheels/* --no-index --find-links=/wheels/ && rm -f *.whl && rm -rf /wheels +# SECURITY FIX: nodejs-wheel-binaries (pip package used by Prisma) bundles a complete +# npm with old vulnerable deps at /usr/lib/python3.*/site-packages/nodejs_wheel/. +# Patch every copy of tar, glob, and brace-expansion inside that tree. +RUN GLOBAL="$(npm root -g)" && \ + find /usr/lib -path "*/nodejs_wheel/*/node_modules/tar" -type d | while read d; do \ + rm -rf "$d" && cp -rL "$GLOBAL/tar" "$d"; \ + done && \ + find /usr/lib -path "*/nodejs_wheel/*/node_modules/glob" -type d | while read d; do \ + rm -rf "$d" && cp -rL "$GLOBAL/glob" "$d"; \ + done && \ + find /usr/lib -path "*/nodejs_wheel/*/node_modules/@isaacs/brace-expansion" -type d | while read d; do \ + rm -rf "$d" && cp -rL "$GLOBAL/@isaacs/brace-expansion" "$d"; \ + done + # Install semantic_router and aurelio-sdk using script # Convert Windows line endings to Unix and make executable RUN sed -i 's/\r$//' docker/install_auto_router.sh && chmod +x docker/install_auto_router.sh && ./docker/install_auto_router.sh diff --git a/docker/Dockerfile.dev b/docker/Dockerfile.dev index ae557d4647f..bc1d22d5e05 100644 --- a/docker/Dockerfile.dev +++ b/docker/Dockerfile.dev @@ -62,7 +62,18 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ nodejs \ npm \ && rm -rf /var/lib/apt/lists/* \ - && npm install -g npm@latest tar@latest + && npm install -g npm@latest tar@7.5.7 glob@11.1.0 @isaacs/brace-expansion@5.0.1 \ + && GLOBAL="$(npm root -g)" \ + && find "$GLOBAL/npm" -type d -name "tar" -path "*/node_modules/tar" | while read d; do \ + rm -rf "$d" && cp -rL "$GLOBAL/tar" "$d"; \ + done \ + && find "$GLOBAL/npm" -type d -name "glob" -path "*/node_modules/glob" | while read d; do \ + rm -rf "$d" && cp -rL "$GLOBAL/glob" "$d"; \ + done \ + && find "$GLOBAL/npm" -type d -name "brace-expansion" -path "*/node_modules/@isaacs/brace-expansion" | while read d; do \ + rm -rf "$d" && cp -rL "$GLOBAL/@isaacs/brace-expansion" "$d"; \ + done \ + && npm cache clean --force WORKDIR /app @@ -80,6 +91,20 @@ RUN pip install --no-cache-dir *.whl /wheels/* --no-index --find-links=/wheels/ rm -f *.whl && \ rm -rf /wheels +# SECURITY FIX: nodejs-wheel-binaries (pip package used by Prisma) bundles a complete +# npm with old vulnerable deps at /usr/lib/python3.*/site-packages/nodejs_wheel/. +# Patch every copy of tar, glob, and brace-expansion inside that tree. +RUN GLOBAL="$(npm root -g)" && \ + find /usr/lib -path "*/nodejs_wheel/*/node_modules/tar" -type d | while read d; do \ + rm -rf "$d" && cp -rL "$GLOBAL/tar" "$d"; \ + done && \ + find /usr/lib -path "*/nodejs_wheel/*/node_modules/glob" -type d | while read d; do \ + rm -rf "$d" && cp -rL "$GLOBAL/glob" "$d"; \ + done && \ + find /usr/lib -path "*/nodejs_wheel/*/node_modules/@isaacs/brace-expansion" -type d | while read d; do \ + rm -rf "$d" && cp -rL "$GLOBAL/@isaacs/brace-expansion" "$d"; \ + done + # Generate prisma client and set permissions # Convert Windows line endings to Unix for entrypoint scripts RUN prisma generate && \ diff --git a/docker/Dockerfile.non_root b/docker/Dockerfile.non_root index 3ef47607fca..64126bb0292 100644 --- a/docker/Dockerfile.non_root +++ b/docker/Dockerfile.non_root @@ -104,7 +104,18 @@ RUN for i in 1 2 3; do \ && for i in 1 2 3; do \ apk add --no-cache python3 py3-pip bash openssl tzdata nodejs npm supervisor && break || sleep 5; \ done \ - && npm install -g npm@latest tar@latest + && npm install -g npm@latest tar@7.5.7 glob@11.1.0 @isaacs/brace-expansion@5.0.1 \ + && GLOBAL="$(npm root -g)" \ + && find "$GLOBAL/npm" -type d -name "tar" -path "*/node_modules/tar" | while read d; do \ + rm -rf "$d" && cp -rL "$GLOBAL/tar" "$d"; \ + done \ + && find "$GLOBAL/npm" -type d -name "glob" -path "*/node_modules/glob" | while read d; do \ + rm -rf "$d" && cp -rL "$GLOBAL/glob" "$d"; \ + done \ + && find "$GLOBAL/npm" -type d -name "brace-expansion" -path "*/node_modules/@isaacs/brace-expansion" | while read d; do \ + rm -rf "$d" && cp -rL "$GLOBAL/@isaacs/brace-expansion" "$d"; \ + done \ + && npm cache clean --force # Copy artifacts from builder COPY --from=builder /app/requirements.txt /app/requirements.txt @@ -146,6 +157,20 @@ RUN pip install --no-index --find-links=/wheels/ -r requirements.txt && \ fi; \ fi +# SECURITY FIX: nodejs-wheel-binaries (pip package used by Prisma) bundles a complete +# npm with old vulnerable deps at /usr/lib/python3.*/site-packages/nodejs_wheel/. +# Patch every copy of tar, glob, and brace-expansion inside that tree. +RUN GLOBAL="$(npm root -g)" && \ + find /usr/lib -path "*/nodejs_wheel/*/node_modules/tar" -type d | while read d; do \ + rm -rf "$d" && cp -rL "$GLOBAL/tar" "$d"; \ + done && \ + find /usr/lib -path "*/nodejs_wheel/*/node_modules/glob" -type d | while read d; do \ + rm -rf "$d" && cp -rL "$GLOBAL/glob" "$d"; \ + done && \ + find /usr/lib -path "*/nodejs_wheel/*/node_modules/@isaacs/brace-expansion" -type d | while read d; do \ + rm -rf "$d" && cp -rL "$GLOBAL/@isaacs/brace-expansion" "$d"; \ + done + # Permissions, cleanup, and Prisma prep # Convert Windows line endings to Unix for entrypoint scripts RUN sed -i 's/\r$//' docker/entrypoint.sh && \ diff --git a/docs/my-website/blog/claude_opus_4_6/index.md b/docs/my-website/blog/claude_opus_4_6/index.md index b1836cfaef5..3fd70661543 100644 --- a/docs/my-website/blog/claude_opus_4_6/index.md +++ b/docs/my-website/blog/claude_opus_4_6/index.md @@ -3,6 +3,10 @@ slug: claude_opus_4_6 title: "Day 0 Support: Claude Opus 4.6" date: 2026-02-05T10:00:00 authors: + - name: Sameer Kankute + title: SWE @ LiteLLM (LLM Translation) + url: https://www.linkedin.com/in/sameer-kankute/ + image_url: https://pbs.twimg.com/profile_images/2001352686994907136/ONgNuSk5_400x400.jpg - name: Ishaan Jaff title: "CTO, LiteLLM" url: https://www.linkedin.com/in/reffajnaahsi/ @@ -219,6 +223,489 @@ curl --location 'http://0.0.0.0:4000/chat/completions' \ -## More Features Coming Soon +## Advanced Features -We're actively working on supporting new features for Claude Opus 4.6. Stay tuned for updates! +### Compaction + + + + +Litellm supports enabling compaction for the new claude-opus-4-6. + +**Enabling Compaction** + +To enable compaction, add the `context_management` parameter with the `compact_20260112` edit type: + +```bash +curl --location 'http://0.0.0.0:4000/chat/completions' \ +--header 'Content-Type: application/json' \ +--header 'Authorization: Bearer $LITELLM_KEY' \ +--data '{ + "model": "claude-opus-4-6", + "messages": [ + { + "role": "user", + "content": "What is the weather in San Francisco?" + } + ], + "context_management": { + "edits": [ + { + "type": "compact_20260112" + } + ] + }, + "max_tokens": 100 +}' +``` +All the parameters supported for context_management by anthropic are supported and can be directly added. Litellm automatically adds the `compact-2026-01-12` beta header in the request. + + + + +Enable compaction to reduce context size while preserving key information. LiteLLM automatically adds the `compact-2026-01-12` beta header when compaction is enabled. + +:::info +**Provider Support:** Compaction is supported on Anthropic, Azure AI, and Vertex AI. It is **not supported** on Bedrock (Invoke or Converse APIs). +::: + +```bash +curl --location 'http://0.0.0.0:4000/v1/messages' \ +--header 'x-api-key: sk-12345' \ +--header 'content-type: application/json' \ +--data '{ + "model": "claude-opus-4-6", + "max_tokens": 4096, + "messages": [ + { + "role": "user", + "content": "Hi" + } + ], + "context_management": { + "edits": [ + { + "type": "compact_20260112" + } + ] + } +}' +``` + + + + + +**Response with Compaction Block** + +The response will include the compaction summary in `provider_specific_fields.compaction_blocks`: + +```json +{ + "id": "chatcmpl-a6c105a3-4b25-419e-9551-c800633b6cb2", + "created": 1770357619, + "model": "claude-opus-4-6", + "object": "chat.completion", + "choices": [ + { + "finish_reason": "length", + "index": 0, + "message": { + "content": "I don't have access to real-time data, so I can't provide the current weather in San Francisco. To get up-to-date weather information, I'd recommend checking:\n\n- **Weather websites** like weather.com, accuweather.com, or wunderground.com\n- **Search engines** – just Google \"San Francisco weather\"\n- **Weather apps** on your phone (e.g., Apple Weather, Google Weather)\n- **National", + "role": "assistant", + "provider_specific_fields": { + "compaction_blocks": [ + { + "type": "compaction", + "content": "Summary of the conversation: The user requested help building a web scraper..." + } + ] + } + } + } + ], + "usage": { + "completion_tokens": 100, + "prompt_tokens": 86, + "total_tokens": 186 + } +} +``` + +**Using Compaction Blocks in Follow-up Requests** + +To continue the conversation with compaction, include the compaction block in the assistant message's `provider_specific_fields`: + +```bash +curl --location 'http://0.0.0.0:4000/chat/completions' \ +--header 'Content-Type: application/json' \ +--header 'Authorization: Bearer $LITELLM_KEY' \ +--data '{ + "model": "claude-opus-4-6", + "messages": [ + { + "role": "user", + "content": "How can I build a web scraper?" + }, + { + "role": "assistant", + "content": [ + { + "type": "text", + "text": "Certainly! To build a basic web scraper, you'll typically use a programming language like Python along with libraries such as `requests` (for fetching web pages) and `BeautifulSoup` (for parsing HTML). Here's a basic example:\n\n```python\nimport requests\nfrom bs4 import BeautifulSoup\n\nurl = 'https://example.com'\nresponse = requests.get(url)\nsoup = BeautifulSoup(response.text, 'html.parser')\n\n# Extract and print all text\ntext = soup.get_text()\nprint(text)\n```\n\nLet me know what you're interested in scraping or if you need help with a specific website!" + } + ], + "provider_specific_fields": { + "compaction_blocks": [ + { + "type": "compaction", + "content": "Summary of the conversation: The user asked how to build a web scraper, and the assistant gave an overview using Python with requests and BeautifulSoup." + } + ] + } + }, + { + "role": "user", + "content": "How do I use it to scrape product prices?" + } + ], + "context_management": { + "edits": [ + { + "type": "compact_20260112" + } + ] + }, + "max_tokens": 100 +}' +``` + +**Streaming Support** + +Compaction blocks are also supported in streaming mode. You'll receive: +- `compaction_start` event when a compaction block begins +- `compaction_delta` events with the compaction content +- The accumulated `compaction_blocks` in `provider_specific_fields` + +### Adaptive Thinking + + + + +LiteLLM supports adaptive thinking through the `reasoning_effort` parameter: + +```bash +curl --location 'http://0.0.0.0:4000/chat/completions' \ +--header 'Content-Type: application/json' \ +--header 'Authorization: Bearer $LITELLM_KEY' \ +--data '{ + "model": "claude-opus-4-6", + "messages": [ + { + "role": "user", + "content": "Solve this complex problem: What is the optimal strategy for..." + } + ], + "reasoning_effort": "high" +}' +``` + + + + +Use the `thinking` parameter with `type: "adaptive"` to enable adaptive thinking mode: + +```bash +curl --location 'http://0.0.0.0:4000/v1/messages' \ +--header 'x-api-key: sk-12345' \ +--header 'content-type: application/json' \ +--data '{ + "model": "claude-opus-4-6", + "max_tokens": 16000, + "thinking": { + "type": "adaptive" + }, + "messages": [ + { + "role": "user", + "content": "Explain why the sum of two even numbers is always even." + } + ] +}' +``` + + + + +### Effort Levels + + + + +Four effort levels available: `low`, `medium`, `high` (default), and `max`. Pass directly via the `output_config` parameter: + +```bash +curl --location 'http://0.0.0.0:4000/chat/completions' \ +--header 'Content-Type: application/json' \ +--header 'Authorization: Bearer $LITELLM_KEY' \ +--data '{ + "model": "claude-opus-4-6", + "messages": [ + { + "role": "user", + "content": "Explain quantum computing" + } + ], + "output_config": { + "effort": "medium" + } +}' +``` + +You can use reasoning effort plus output_config to have more control on the model. + + + + +Four effort levels available: `low`, `medium`, `high` (default), and `max`. Pass directly via the `output_config` parameter: + +```bash +curl --location 'http://0.0.0.0:4000/v1/messages' \ +--header 'x-api-key: sk-12345' \ +--header 'content-type: application/json' \ +--data '{ + "model": "claude-opus-4-6", + "max_tokens": 4096, + "messages": [ + { + "role": "user", + "content": "Explain quantum computing" + } + ], + "output_config": { + "effort": "medium" + } +}' +``` + + + + +### 1M Token Context (Beta) + +Opus 4.6 supports 1M token context. Premium pricing applies for prompts exceeding 200k tokens ($10/$37.50 per million input/output tokens). LiteLLM supports cost calculations for 1M token contexts. + + + + +To use the 1M token context window, you need to forward the `anthropic-beta` header from your client to the LLM provider. + +**Step 1: Enable header forwarding in your config** + +```yaml +general_settings: + forward_client_headers_to_llm_api: true +``` + +**Step 2: Send requests with the beta header** + +```bash +curl --location 'http://0.0.0.0:4000/chat/completions' \ +--header 'Content-Type: application/json' \ +--header 'Authorization: Bearer $LITELLM_KEY' \ +--header 'anthropic-beta: context-1m-2025-08-07' \ +--data '{ + "model": "claude-opus-4-6", + "messages": [ + { + "role": "user", + "content": "Analyze this large document..." + } + ] +}' +``` + + + + +To use the 1M token context window, you need to forward the `anthropic-beta` header from your client to the LLM provider. + +**Step 1: Enable header forwarding in your config** + +```yaml +general_settings: + forward_client_headers_to_llm_api: true +``` + +**Step 2: Send requests with the beta header** + +```bash +curl --location 'http://0.0.0.0:4000/v1/messages' \ +--header 'x-api-key: sk-12345' \ +--header 'anthropic-beta: context-1m-2025-08-07' \ +--header 'content-type: application/json' \ +--data '{ + "model": "claude-opus-4-6", + "max_tokens": 16000, + "messages": [ + { + "role": "user", + "content": "Analyze this large document..." + } + ] +}' +``` + +:::tip +You can combine multiple beta headers by separating them with commas: +```bash +--header 'anthropic-beta: context-1m-2025-08-07,compact-2026-01-12' +``` +::: + + + + +### US-Only Inference + +Available at 1.1× token pricing. LiteLLM automatically tracks costs for US-only inference. + + + + +Use the `inference_geo` parameter to specify US-only inference: + +```bash +curl --location 'http://0.0.0.0:4000/chat/completions' \ +--header 'Content-Type: application/json' \ +--header 'Authorization: Bearer $LITELLM_KEY' \ +--data '{ + "model": "claude-opus-4-6", + "messages": [ + { + "role": "user", + "content": "What is the capital of France?" + } + ], + "inference_geo": "us" +}' +``` + +LiteLLM will automatically apply the 1.1× pricing multiplier for US-only inference in cost tracking. + + + + +Use the `inference_geo` parameter to specify US-only inference: + +```bash +curl --location 'http://0.0.0.0:4000/v1/messages' \ +--header 'x-api-key: sk-12345' \ +--header 'content-type: application/json' \ +--data '{ + "model": "claude-opus-4-6", + "max_tokens": 4096, + "messages": [ + { + "role": "user", + "content": "What is the capital of France?" + } + ], + "inference_geo": "us" +}' +``` + +LiteLLM will automatically apply the 1.1× pricing multiplier for US-only inference in cost tracking. + + + + +### Fast Mode + +:::info +Fast mode is **only supported on the Anthropic provider** (`anthropic/claude-opus-4-6`). It is not available on Azure AI, Vertex AI, or Bedrock. +::: + +**Pricing:** +- Standard: $5 input / $25 output per MTok +- Fast: $30 input / $150 output per MTok (6× premium) + + + + +```bash +curl --location 'http://0.0.0.0:4000/chat/completions' \ +--header 'Content-Type: application/json' \ +--header 'Authorization: Bearer $LITELLM_KEY' \ +--data '{ + "model": "claude-opus-4-6", + "messages": [ + { + "role": "user", + "content": "Refactor this module..." + } + ], + "max_tokens": 4096, + "speed": "fast" +}' +``` + +**Using OpenAI SDK:** + +```python +import openai + +client = openai.OpenAI( + api_key="your-litellm-key", + base_url="http://0.0.0.0:4000" +) + +response = client.chat.completions.create( + model="claude-opus-4-6", + messages=[{"role": "user", "content": "Refactor this module..."}], + max_tokens=4096, + extra_body={"speed": "fast"} +) +``` + +**Using LiteLLM SDK:** + +```python +from litellm import completion + +response = completion( + model="anthropic/claude-opus-4-6", + messages=[{"role": "user", "content": "Refactor this module..."}], + max_tokens=4096, + speed="fast" +) +``` + +LiteLLM automatically tracks the higher costs for fast mode in usage and cost calculations. + + + + +```bash +curl --location 'http://0.0.0.0:4000/v1/messages' \ +--header 'x-api-key: sk-12345' \ +--header 'content-type: application/json' \ +--data '{ + "model": "claude-opus-4-6", + "max_tokens": 4096, + "speed": "fast", + "messages": [ + { + "role": "user", + "content": "Refactor this module..." + } + ] +}' +``` + +LiteLLM automatically: +- Adds the `fast-mode-2026-02-01` beta header +- Tracks the 6× premium pricing in cost calculations + + + diff --git a/docs/my-website/blog/fastapi_middleware_performance/index.mdx b/docs/my-website/blog/fastapi_middleware_performance/index.mdx new file mode 100644 index 00000000000..b0c5ba13634 --- /dev/null +++ b/docs/my-website/blog/fastapi_middleware_performance/index.mdx @@ -0,0 +1,220 @@ +--- +slug: fastapi-middleware-performance +title: "Your Middleware Could Be a Bottleneck" +date: 2026-02-07T10:00:00 +authors: + - name: Krrish Dholakia + title: "CEO, LiteLLM" + url: https://www.linkedin.com/in/krish-d/ + image_url: https://pbs.twimg.com/profile_images/1298587542745358340/DZv3Oj-h_400x400.jpg + - name: Ishaan Jaff + title: "CTO, LiteLLM" + url: https://www.linkedin.com/in/reffajnaahsi/ + image_url: https://pbs.twimg.com/profile_images/1613813310264340481/lz54oEiB_400x400.jpg + - name: Ryan Crabbe + title: "Performance Engineer, LiteLLM" + url: https://www.linkedin.com/in/ryan-crabbe-0b9687214 + image_url: https://media.licdn.com/dms/image/v2/D5603AQHt1t9Z4BJ6Gw/profile-displayphoto-shrink_400_400/profile-displayphoto-shrink_400_400/0/1724453682340?e=1772064000&v=beta&t=VXdmr13rsNB05wyA2F1TENOB5UuDHUZ0FCHTolNyR5M +description: "How we improved LiteLLM proxy latency and throughput by replacing a single middleware base class" +tags: [performance, fastapi, middleware] +hide_table_of_contents: false +--- + +import { BaseHTTPMiddlewareAnimation, PureASGIAnimation, BenchmarkVisualization } from '@site/src/components/MiddlewareDiagrams'; + +> How we improved LiteLLM proxy latency and throughput by replacing a single, simple middleware base class + +--- + +## Our Setup + +The LiteLLM proxy server has two middleware layers. The first is Starlette's `CORSMiddleware` (re-exported by FastAPI), which is a pure ASGI middleware. Then we have a simple BaseHTTPMiddleware called PrometheusAuthMiddleware. + +The job of `PrometheusAuthMiddleware` is to authenticate requests to the `/metrics` endpoint. It's not on by default, you enable it with a flag in your proxy config: + +
+Proxy config flag + +```yaml +litellm_settings: + require_auth_for_metrics_endpoint: true +``` + +
+ +The middleware checks two things: is the request hitting `/metrics`, and is auth even enabled? If both checks fail, which they do for the vast majority of requests, it just passes the request through unchanged. + +
+PrometheusAuthMiddleware source + +```python +class PrometheusAuthMiddleware(BaseHTTPMiddleware): + async def dispatch(self, request: Request, call_next): + if self._is_prometheus_metrics_endpoint(request): + if self._should_run_auth_on_metrics_endpoint() is True: + try: + await user_api_key_auth(request=request, api_key=...) + except Exception as e: + return JSONResponse(status_code=401, content=...) + response = await call_next(request) + return response + + @staticmethod + def _is_prometheus_metrics_endpoint(request: Request): + if "/metrics" in request.url.path: + return True + return False +``` + +
+ +Looks harmless. Subclass `BaseHTTPMiddleware`, implement `dispatch()`, done. This is what you will see in Starlette's documentation[1](#footnote-1). + +{/* truncate */} + +--- + +## What BaseHTTPMiddleware Actually Does + +When you write a `dispatch()` method, you'd expect the request to flow straight through your function and out the other side. What actually happens is much more involved. + +On every request, even a pure passthrough (meaning nothing happens), `BaseHTTPMiddleware` creates **7 intermediate objects and tasks**: + + + +It wraps the request in a new object to track body state, creates a synchronization event, allocates an in-memory channel to pass messages between your middleware and the inner app, sets up a task group to manage the lifecycle, and then runs your actual route handler in a *separate background task* when you call `call_next()`. The response body then flows back through that in-memory channel, gets re-wrapped in a streaming response object, and finally reaches the caller. That's a lot. + +For a middleware that for us, does nothing on 99.9% of requests, paying this cost doesn't make sense. + +Compare that to a pure ASGI middleware, which we can have just check the request path and continue along. + + + +Our middleware is doing something really simple. For the vast majority of requests it doesn't need to do anything at all but just let the request pass through. It doesn't need task groups, memory streams, or cancel scopes. It needs a function call. + +--- + +## Comparing Both + +We replaced the `BaseHTTPMiddleware` subclass with a pure ASGI middleware. To benchmark the difference, we used Apache Bench[2](#footnote-2) to compare both configurations of LiteLLM's middleware stack: the old setup (1 pure ASGI + 1 `BaseHTTPMiddleware`) against the new setup (2 pure ASGI). + +A minimal FastAPI app serves `GET /health` → `PlainTextResponse("ok")`. The endpoint does zero work to isolate the middleware overhead: any difference between configs is purely the cost of the middleware plumbing itself. Both middlewares are just calling the next layer. Same work, different base class. + +Apache Bench (`ab`) fires requests at the server with 1,000 concurrent connections and a single uvicorn worker. One worker means one event loop, so the benchmark directly measures how each middleware design handles concurrent load on a single thread. + + + +
+Try it yourself + +Save the script below as `benchmark_middleware.py`, then run: + +```bash +# Terminal 1 — start the "before" server (1 ASGI + 1 BaseHTTPMiddleware) +python benchmark_middleware.py --middleware mixed + +# Terminal 2 — benchmark it +ab -n 50000 -c 1000 http://localhost:8000/health + +# Stop the server, then start the "after" server (2x pure ASGI) +python benchmark_middleware.py --middleware asgi + +# Terminal 2 — benchmark again +ab -n 50000 -c 1000 http://localhost:8000/health +``` + +```python +import argparse +import uvicorn +from fastapi import FastAPI +from fastapi.responses import PlainTextResponse +from starlette.middleware.base import BaseHTTPMiddleware +from starlette.requests import Request +from starlette.types import ASGIApp, Receive, Scope, Send + + +class NoOpBaseHTTPMiddleware(BaseHTTPMiddleware): + async def dispatch(self, request: Request, call_next): + return await call_next(request) + + +class NoOpPureASGIMiddleware: + def __init__(self, app: ASGIApp) -> None: + self.app = app + + async def __call__(self, scope: Scope, receive: Receive, send: Send) -> None: + await self.app(scope, receive, send) + + +def create_app(middleware_type: str | None = None, layers: int = 2) -> FastAPI: + app = FastAPI() + + @app.get("/health") + async def health(): + return PlainTextResponse("ok") + + if middleware_type == "mixed": + app.add_middleware(NoOpBaseHTTPMiddleware) + app.add_middleware(NoOpPureASGIMiddleware) + elif middleware_type == "asgi": + for _ in range(layers): + app.add_middleware(NoOpPureASGIMiddleware) + + return app + + +if __name__ == "__main__": + parser = argparse.ArgumentParser() + parser.add_argument("--middleware", choices=["asgi", "mixed"], default=None) + parser.add_argument("--layers", type=int, default=2) + parser.add_argument("--port", type=int, default=8000) + args = parser.parse_args() + + app = create_app(middleware_type=args.middleware, layers=args.layers) + uvicorn.run(app, host="0.0.0.0", port=args.port, workers=1, log_level="warning") +``` + +
+ +--- + +## Our Change + +Here's what we replaced it with: + +```python +class PrometheusAuthMiddleware: + def __init__(self, app: ASGIApp) -> None: + self.app = app + + async def __call__(self, scope: Scope, receive: Receive, send: Send) -> None: + if scope["type"] != "http" or "/metrics" not in scope.get("path", ""): + await self.app(scope, receive, send) + return + + if litellm.require_auth_for_metrics_endpoint is True: + request = Request(scope, receive) + api_key = request.headers.get("Authorization") or "" + try: + await user_api_key_auth(request=request, api_key=api_key) + except Exception as e: + # send 401 directly via ASGI protocol + ... + return + + await self.app(scope, receive, send) +``` + +For the 99.9% of requests that aren't hitting `/metrics`, the middleware is now one dict lookup, one string check, and one function call. No objects allocated, no tasks spawned. + +It's important to evaluate if the tools you're using are the right fit for the job as your software grows and handles more responsiblity. We're now putting in a static analysis check to prevent this from happening again with any newly introduced middlewares. If we find the use case is necessary then that's okay and we'll reevalute but for everything LiteLLM needs to do at the moment it's not. + +This middleware change was one part of a broader optimization effort on the LiteLLM proxy. Across all optimizations combined, we've measured about a **30% reduction in proxy overhead** over the past two weeks. + +--- + + +1 [Starlette Middleware — BaseHTTPMiddleware](https://starlette.dev/middleware/#basehttpmiddleware) + + +2 [Apache HTTP server benchmarking tool (`ab`)](https://httpd.apache.org/docs/2.4/programs/ab.html) diff --git a/docs/my-website/blog/litellm_observatory/index.md b/docs/my-website/blog/litellm_observatory/index.md new file mode 100644 index 00000000000..4554f77fb85 --- /dev/null +++ b/docs/my-website/blog/litellm_observatory/index.md @@ -0,0 +1,136 @@ +--- +slug: litellm-observatory +title: "Improve release stability with 24 hour load tests" +date: 2026-02-06T10:00:00 +authors: + - name: Alexsander Hamir + title: "Performance Engineer, LiteLLM" + url: https://www.linkedin.com/in/alexsander-baptista/ + image_url: https://github.com/AlexsanderHamir.png + - name: Krrish Dholakia + title: "CEO, LiteLLM" + url: https://www.linkedin.com/in/krish-d/ + image_url: https://pbs.twimg.com/profile_images/1298587542745358340/DZv3Oj-h_400x400.jpg + - name: Ishaan Jaff + title: "CTO, LiteLLM" + url: https://www.linkedin.com/in/reffajnaahsi/ + image_url: https://pbs.twimg.com/profile_images/1613813310264340481/lz54oEiB_400x400.jpg +description: "How we built a long-running, release-validation system to catch regressions before they reach users." +tags: [testing, observability, reliability, releases] +hide_table_of_contents: false +--- + +![LiteLLM Observatory](https://raw.githubusercontent.com/AlexsanderHamir/assets/main/Screenshot%202026-01-31%20175355.png) + +# Improve release stability with 24 hour load tests + +As LiteLLM adoption has grown, so have expectations around reliability, performance, and operational safety. Meeting those expectations requires more than correctness-focused tests, it requires validating how the system behaves over time, under real-world conditions. + +This post introduces **LiteLLM Observatory**, a long-running release-validation system we built to catch regressions before they reach users. + +--- + +## Why We Built the Observatory + +LiteLLM operates at the intersection of external providers, long-lived network connections, and high-throughput workloads. While our unit and integration tests do an excellent job validating correctness, they are not designed to surface issues that only appear after extended operation. + +A subtle lifecycle edge case discovered in v1.81.3 reinforced the need for stronger release validation in this area. + +--- + +## A Real-World Lifecycle Edge Case + +In v1.81.3, we shipped a fix for an HTTP client memory leak. The change passed unit and integration tests and behaved correctly in short-lived runs. + +The issue that surfaced was not caused by a single incorrect line of logic, but by how multiple components interacted over time: + +- A cached `httpx` client was configured with a 1-hour TTL +- When the cache expired, the underlying HTTP connection was closed as expected +- A higher-level client continued to hold a reference to that connection +- Subsequent requests failed with: + +``` +Cannot send a request, as the client has been closed +``` + +**Before (with bug):** + +| Provider | Requests | Success | Failures | Fail % | +|----------|----------|---------|----------|--------| +| OpenAI | 720,000 | 432,000 | 288,000 | 40% | +| Azure | 692,000 | 415,200 | 276,800 | 40% | + +**After (fixed):** + +| Provider | Requests | Success | Failures | Fail % | +|----------|------------|-----------|----------|---------| +| OpenAI | 1,200,000 | 1,199,988 | 12 | 0.001% | +| Azure | 1,150,000 | 1,149,982 | 18 | 0.002% | + +Our focus moving forward is on being the first to detect issues, even when they aren’t covered by unit tests. LiteLLM Observatory is designed to surface latency regressions, OOMs, and failure modes that only appear under real traffic patterns in **our own production deployments** during release validation. + + +--- + +### How the Observatory Works + +[LiteLLM Observatory](https://github.com/BerriAI/litellm-observatory) is a testing service that runs long-running tests against our LiteLLM deployments. We trigger tests by sending API requests, and results are automatically sent to Slack when tests complete. + +#### How Tests Run + +1. **Start a Test**: We send a request to the Observatory API with: + - Which LiteLLM deployment to test (URL and API key) + - Which test to run (e.g., `TestOAIAzureRelease`) + - Test settings (which models to test, how long to run, failure thresholds) + +2. **Smart Queueing**: + - The system checks whether we are attempting to run the exact same test more than once + - If a duplicate test is already running or queued, we receive an error to avoid wasting resources + - Otherwise, the test is added to a queue and runs when capacity is available (up to 5 tests can run concurrently by default) + +3. **Instant Response**: The API responds immediately—we do not wait for the test to finish. Tests may run for hours, but the request itself completes in milliseconds. + +4. **Background Execution**: + - The test runs in the background, issuing requests against our LiteLLM deployment + - It tracks request success and failure rates over time + - When the test completes, results are automatically posted to our Slack channel + +#### Example: The OpenAI / Azure Reliability Test + +The `TestOAIAzureRelease` test is designed to catch a class of bugs that only surface after sustained runtime: + +- **Duration**: Runs continuously for 3 hours +- **Behavior**: Cycles through specified models (such as `gpt-4` and `gpt-3.5-turbo`), issuing requests continuously +- **Why 3 Hours**: This helps catch issues where HTTP clients degrade or fail after extended use (for example, a bug observed in LiteLLM v1.81.3) +- **Pass / Fail Criteria**: The test passes if fewer than 1% of requests fail. If the failure rate exceeds 1%, the test fails and we are notified in Slack +- **Key Detail**: The same HTTP client is reused for the entire run, allowing us to detect lifecycle-related bugs that only appear under prolonged reuse + +#### When We Use It + +- **Before Deployments**: Run tests before promoting a new LiteLLM version to production +- **Routine Validation**: Schedule regular runs (daily or weekly) to catch regressions early +- **Issue Investigation**: Run tests on demand when we suspect a deployment issue +- **Long-Running Failure Detection**: Identify bugs that only appear under sustained load, beyond what short smoke tests can reveal + + +### Complementing Unit Tests + +Unit tests remain a foundational part of our development process. They are fast and precise, but they don’t cover: + +- Real provider behavior +- Long-lived network interactions +- Resource lifecycle edge cases +- Time-dependent regressions + +LiteLLM Observatory complements unit tests by validating the system as it actually runs in production-like environments. + +--- + +### Looking Ahead + +Reliability is an ongoing investment. + +LiteLLM Observatory is one of several systems we’re building to continuously raise the bar on release quality and operational safety. As LiteLLM evolves, so will our validation tooling, informed by real-world usage and lessons learned. + +We’ll continue to share those improvements openly as we go. + diff --git a/docs/my-website/blog/model_cost_map_incident/index.md b/docs/my-website/blog/model_cost_map_incident/index.md new file mode 100644 index 00000000000..b9ff20e4128 --- /dev/null +++ b/docs/my-website/blog/model_cost_map_incident/index.md @@ -0,0 +1,95 @@ +--- +slug: model-cost-map-incident +title: "Incident Report: Invalid model cost map on main" +date: 2026-02-10T10:00:00 +authors: + - name: Ishaan Jaffer + title: "CTO, LiteLLM" + url: https://www.linkedin.com/in/ishaanjaffer/ + image_url: https://pbs.twimg.com/profile_images/1613813310264340481/lz54oEiB_400x400.jpg +tags: [incident-report, stability] +hide_table_of_contents: false +--- + +**Date:** January 27, 2026 +**Duration:** ~20 minutes +**Severity:** Low +**Status:** Resolved + +## Summary + +A malformed JSON entry in `model_prices_and_context_window.json` was merged to `main` ([`562f0a0`](https://github.com/BerriAI/litellm/commit/562f0a028251750e3d75386bee0e630d9796d0df)). This caused LiteLLM to silently fall back to a stale local copy of the model cost map. Users on older package versions lost cost tracking for newer models only (e.g. `azure/gpt-5.2`). No LLM calls were blocked. + +- **LLM calls and proxy routing:** No impact. +- **Cost tracking:** Impacted for newer models not present in the local backup. Older models were unaffected. The incident lasted ~20 minutes until the commit was reverted. + +{/* truncate */} + +--- + +## Background + +The model cost map is not in the request path. It is used after the LLM response comes back, inside a try/catch, to calculate spend. A missing entry never blocks a call. + +```mermaid +flowchart TD + A["1. litellm.completion() receives request + litellm/main.py"] --> B["2. Route to provider + litellm/litellm_core_utils/get_llm_provider_logic.py"] + B --> C["3. LLM returns response + litellm/main.py"] + C --> D["4. Post-call: look up model in cost map + litellm/cost_calculator.py"] + D -->|"found"| E["5a. Attach cost to response"] + D -->|"not found (try/catch)"| F["5b. Log warning, set cost=0"] + E --> G["6. Return response to caller"] + F --> G + + style D fill:#fff3cd,stroke:#ffc107 + style F fill:#fff3cd,stroke:#ffc107 + style E fill:#d4edda,stroke:#28a745 + style G fill:#d4edda,stroke:#28a745 +``` + +Both paths return a response to the caller. When the cost map lookup fails, the only difference is `cost=0` on that request. + +--- + +## Root cause + +LiteLLM fetches the model cost map from GitHub `main` at import time. If the fetch fails, it falls back to a local backup bundled with the package. Before this incident, the fallback was completely silent -- no warning was logged. + +A contributor PR introduced an extra `{` bracket, producing invalid JSON. The remote fetch failed with `JSONDecodeError`, triggering the silent fallback. Users on older package versions had backup files missing newer models. + +**Timeline:** + +1. Malformed JSON merged to `main` +2. LiteLLM installations fall back to local backup on next import +3. Users report `"This model isn't mapped yet"` for newer models +4. Bad commit identified and reverted (~20 minutes) + +--- + +## Remediation + +| # | Action | Status | Code | +|---|---|---|---| +| 1 | CI validation on `model_prices_and_context_window.json` | ✅ Done | [`test-model-map.yaml`](https://github.com/BerriAI/litellm/blob/main/.github/workflows/test-model-map.yaml) | +| 2 | Warning log on fallback to local backup | ✅ Done | [`get_model_cost_map.py#L57-L68`](https://github.com/BerriAI/litellm/blob/main/litellm/litellm_core_utils/get_model_cost_map.py#L57-L68) | +| 3 | `GetModelCostMap` class with integrity validation helpers | ✅ Done | [`get_model_cost_map.py#L24-L149`](https://github.com/BerriAI/litellm/blob/main/litellm/litellm_core_utils/get_model_cost_map.py#L24-L149) | +| 4 | Resilience test suite (bad hosted map, fallback, completion) | ✅ Done | [`test_model_cost_map_resilience.py#L150-L291`](https://github.com/BerriAI/litellm/blob/main/tests/llm_translation/test_model_cost_map_resilience.py#L150-L291) | +| 5 | Test that backup model cost map always exists and contains common models | ✅ Done | [`test_model_cost_map_resilience.py#L213-L228`](https://github.com/BerriAI/litellm/blob/main/tests/llm_translation/test_model_cost_map_resilience.py#L213-L228) | + +Enterprises that require zero external dependencies at import time can set `LITELLM_LOCAL_MODEL_COST_MAP=True` to skip the GitHub fetch entirely. + +--- + +## Other dependencies on external resources + +| Dependency | Impact if unavailable | Fallback | +|---|---|---| +| Model cost map (GitHub) | Cost tracking for newer models | Local backup (now with warning) | +| JWT public keys (IDP/SSO) | Auth fails | None | +| OIDC UserInfo (IDP/SSO) | Auth fails | None | +| HuggingFace model API | HF provider calls fail | None | +| Ollama tags (localhost) | Ollama model list stale | Static list | diff --git a/docs/my-website/docs/benchmarks.md b/docs/my-website/docs/benchmarks.md index a1489081b4c..1f818cef498 100644 --- a/docs/my-website/docs/benchmarks.md +++ b/docs/my-website/docs/benchmarks.md @@ -5,6 +5,13 @@ import Image from '@theme/IdealImage'; Benchmarks for LiteLLM Gateway (Proxy Server) tested against a fake OpenAI endpoint. +## Setting Up a Fake OpenAI Endpoint + +For load testing and benchmarking, you can use a fake OpenAI proxy server. LiteLLM provides: + +1. **Hosted endpoint**: Use our free hosted fake endpoint at `https://exampleopenaiendpoint-production.up.railway.app/` +2. **Self-hosted**: Set up your own fake OpenAI proxy server using [github.com/BerriAI/example_openai_endpoint](https://github.com/BerriAI/example_openai_endpoint) + Use this config for testing: ```yaml @@ -12,7 +19,7 @@ model_list: - model_name: "fake-openai-endpoint" litellm_params: model: openai/any - api_base: https://your-fake-openai-endpoint.com/chat/completions + api_base: https://exampleopenaiendpoint-production.up.railway.app/ # or your self-hosted endpoint api_key: "test" ``` diff --git a/docs/my-website/docs/extras/contributing_code.md b/docs/my-website/docs/extras/contributing_code.md index 930a47eec7e..673a83aca05 100644 --- a/docs/my-website/docs/extras/contributing_code.md +++ b/docs/my-website/docs/extras/contributing_code.md @@ -1,27 +1,36 @@ # Contributing Code -## **Checklist before submitting a PR** +## Checklist before submitting a PR -Here are the core requirements for any PR submitted to LiteLLM +Here are the core requirements for any PR submitted to LiteLLM: -- [ ] Sign the Contributor License Agreement (CLA) - [see details](#contributor-license-agreement-cla) -- [ ] Add testing, **Adding at least 1 test is a hard requirement** - [see details](#2-adding-testing-to-your-pr) -- [ ] Ensure your PR passes the following tests: - - [ ] [Unit Tests](#3-running-unit-tests) - - [ ] [Formatting / Linting Tests](#35-running-linting-tests) -- [ ] Keep scope as isolated as possible. As a general rule, your changes should address 1 specific problem at a time +- [ ] Sign the [Contributor License Agreement (CLA)](#contributor-license-agreement-cla) +- [ ] Keep scope as isolated as possible — your changes should address **one specific problem** at a time -## **Contributor License Agreement (CLA)** +### Proxy (Backend) PRs + +- [ ] Add testing — **at least 1 test is a hard requirement** ([details](#2-adding-tests)) +- [ ] Ensure your PR passes: + - [ ] [Unit Tests](#3-running-unit-tests) — `make test-unit` + - [ ] [Formatting / Linting Tests](#4-running-linting-tests) — `make lint` + +### UI PRs + +- [ ] Ensure the UI builds successfully — `npm run build` +- [ ] Ensure all UI unit tests pass — `npm run test` +- [ ] If you are adding a **new component** or **new logic**, add corresponding tests + +## Contributor License Agreement (CLA) Before contributing code to LiteLLM, you must sign our [Contributor License Agreement (CLA)](https://cla-assistant.io/BerriAI/litellm). This is a legal requirement for all contributions to be merged into the main repository. The CLA helps protect both you and the project by clearly defining the terms under which your contributions are made. -**Important:** We strongly recommend reviewing and signing the CLA before starting work on your contribution to avoid any delays in the PR process. You can find the CLA [here](https://cla-assistant.io/BerriAI/litellm) and sign it through our CLA management system when you submit your first PR. +**Important:** We strongly recommend signing the CLA **before** starting work on your contribution to avoid delays in the review process. You can find and sign the CLA [here](https://cla-assistant.io/BerriAI/litellm). -## Quick start +--- -## 1. Setup your local dev environment +## Proxy (Backend) -Here's how to modify the repo locally: +### 1. Setting up your local dev environment Step 1: Clone the repo @@ -29,56 +38,53 @@ Step 1: Clone the repo git clone https://github.com/BerriAI/litellm.git ``` -Step 2: Install dev dependencies: +Step 2: Install dev dependencies ```shell poetry install --with dev --extras proxy ``` -That's it, your local dev environment is ready! +### 2. Adding tests -## 2. Adding Testing to your PR +- Add your tests to the [`tests/test_litellm/` directory](https://github.com/BerriAI/litellm/tree/main/tests/litellm). +- This directory mirrors the `litellm/` directory 1:1 and should **only** contain mocked tests. +- **Do not** add real LLM API calls to this directory. -- Add your test to the [`tests/test_litellm/` directory](https://github.com/BerriAI/litellm/tree/main/tests/litellm) +#### File naming convention for `tests/test_litellm/` -- This directory 1:1 maps the the `litellm/` directory, and can only contain mocked tests. -- Do not add real llm api calls to this directory. +The test directory follows the same structure as `litellm/`: -### 2.1 File Naming Convention for `tests/test_litellm/` - -The `tests/test_litellm/` directory follows the same directory structure as `litellm/`. - -- `litellm/proxy/test_caching_routes.py` maps to `litellm/proxy/caching_routes.py` - `test_{filename}.py` maps to `litellm/{filename}.py` +- `litellm/proxy/test_caching_routes.py` maps to `litellm/proxy/caching_routes.py` -## 3. Running Unit Tests +### 3. Running unit tests -run the following command on the root of the litellm directory +Run the following command from the root of the `litellm` directory: ```shell make test-unit ``` -## 3.5 Running Linting Tests +### 4. Running linting tests -run the following command on the root of the litellm directory +Run the following command from the root of the `litellm` directory: ```shell make lint ``` -LiteLLM uses mypy for linting. On ci/cd we also run `black` for formatting. +LiteLLM uses `mypy` for type checking. CI/CD also runs `black` for formatting. -## 4. Submit a PR with your changes! +### 5. Submit a PR -- push your fork to your GitHub repo -- submit a PR from there +- Push your changes to your fork on GitHub +- Open a Pull Request from your fork -## Advanced +--- -### Building LiteLLM Docker Image +## UI -Some people might want to build the LiteLLM docker image themselves. Follow these instructions if you want to build / run the LiteLLM Docker Image yourself. +### 1. Setting up your local dev environment Step 1: Clone the repo @@ -86,17 +92,72 @@ Step 1: Clone the repo git clone https://github.com/BerriAI/litellm.git ``` -Step 2: Build the Docker Image +Step 2: Navigate to the UI dashboard directory -Build using Dockerfile.non_root +```shell +cd ui/litellm-dashboard +``` + +Step 3: Install dependencies + +```shell +npm install +``` + +Step 4: Start the development server + +```shell +npm run dev +``` + +### 2. Adding tests + +If you are adding a **new component** or **new logic**, you must add corresponding tests. + +### 3. Running UI unit tests + +```shell +npm run test +``` + +### 4. Building the UI + +Ensure the UI builds successfully before submitting your PR: + +```shell +npm run build +``` + +### 5. Submit a PR + +- Push your changes to your fork on GitHub +- Open a Pull Request from your fork + +--- + +## Advanced + +### Building the LiteLLM Docker Image + +Follow these instructions if you want to build and run the LiteLLM Docker image yourself. + +Step 1: Clone the repo + +```shell +git clone https://github.com/BerriAI/litellm.git +``` + +Step 2: Build the Docker image + +Build using `Dockerfile.non_root`: ```shell docker build -f docker/Dockerfile.non_root -t litellm_test_image . ``` -Step 3: Run the Docker Image +Step 3: Run the Docker image -Make sure config.yaml is present in the root directory. This is your litellm proxy config file. +Make sure `config.yaml` is present in the root directory. This is your LiteLLM proxy config file. ```shell docker run \ @@ -107,18 +168,19 @@ docker run \ litellm_test_image \ --config /app/config.yaml --detailed_debug ``` -### Running LiteLLM Proxy Locally -1. cd into the `proxy/` directory +### Running the LiteLLM Proxy Locally -``` +1. Navigate to the `proxy/` directory: + +```shell cd litellm/litellm/proxy ``` -2. Run the proxy +2. Run the proxy: ```shell python3 proxy_cli.py --config /path/to/config.yaml # RUNNING on http://0.0.0.0:4000 -``` \ No newline at end of file +``` diff --git a/docs/my-website/docs/integrations/websearch_interception.md b/docs/my-website/docs/integrations/websearch_interception.md new file mode 100644 index 00000000000..0c5d8927013 --- /dev/null +++ b/docs/my-website/docs/integrations/websearch_interception.md @@ -0,0 +1,411 @@ +# Web Search Integration + +Enable transparent server-side web search execution for any LLM provider. LiteLLM automatically intercepts web search tool calls and executes them using your configured search provider (Perplexity, Tavily, etc.). + +## Quick Start + +### 1. Configure Web Search Interception + +Add to your `config.yaml`: + +```yaml +model_list: + - model_name: gpt-4o + litellm_params: + model: openai/gpt-4o + api_key: os.environ/OPENAI_API_KEY + +litellm_settings: + callbacks: + - websearch_interception: + enabled_providers: + - openai + - minimax + - anthropic + search_tool_name: perplexity-search # Optional + +search_tools: + - search_tool_name: perplexity-search + litellm_params: + search_provider: perplexity + api_key: os.environ/PERPLEXITY_API_KEY +``` + +### 2. Use with Any Provider + +```python +import litellm + +response = await litellm.acompletion( + model="gpt-4o", + messages=[ + {"role": "user", "content": "What's the weather in San Francisco today?"} + ], + tools=[ + { + "type": "function", + "function": { + "name": "litellm_web_search", + "description": "Search the web for information", + "parameters": { + "type": "object", + "properties": { + "query": {"type": "string", "description": "Search query"} + }, + "required": ["query"] + } + } + } + ] +) + +# Response includes search results automatically! +print(response.choices[0].message.content) +``` + +## How It Works + +When a model makes a web search tool call, LiteLLM: + +1. **Detects** the `litellm_web_search` tool call in the response +2. **Executes** the search using your configured search provider +3. **Makes a follow-up request** with the search results +4. **Returns** the final answer to the user + +```mermaid +sequenceDiagram + participant User + participant LiteLLM + participant LLM as LLM Provider + participant Search as Search Provider + + User->>LiteLLM: Request with web_search tool + LiteLLM->>LLM: Forward request + LLM-->>LiteLLM: Response with tool_call + Note over LiteLLM: Detect web search
tool call + LiteLLM->>Search: Execute search + Search-->>LiteLLM: Search results + LiteLLM->>LLM: Follow-up with results + LLM-->>LiteLLM: Final answer + LiteLLM-->>User: Final answer with search results +``` + +**Result**: One API call from user → Complete answer with search results + +## Supported Providers + +Web search integration works with **all providers** that use: +- ✅ **Base HTTP Handler** (`BaseLLMHTTPHandler`) +- ✅ **OpenAI Completion Handler** (`OpenAIChatCompletion`) + +### Providers Using Base HTTP Handler + +| Provider | Status | Notes | +|----------|--------|-------| +| **OpenAI** | ✅ Supported | GPT-4, GPT-3.5, etc. | +| **Anthropic** | ✅ Supported | Claude models via HTTP handler | +| **MiniMax** | ✅ Supported | All MiniMax models | +| **Mistral** | ✅ Supported | Mistral AI models | +| **Cohere** | ✅ Supported | Command models | +| **Fireworks AI** | ✅ Supported | All Fireworks models | +| **Together AI** | ✅ Supported | All Together AI models | +| **Groq** | ✅ Supported | All Groq models | +| **Perplexity** | ✅ Supported | Perplexity models | +| **DeepSeek** | ✅ Supported | DeepSeek models | +| **xAI** | ✅ Supported | Grok models | +| **Hugging Face** | ✅ Supported | Inference API models | +| **OCI** | ✅ Supported | Oracle Cloud models | +| **Vertex AI** | ✅ Supported | Google Vertex AI models | +| **Bedrock** | ✅ Supported | AWS Bedrock models (converse_like route) | +| **Azure OpenAI** | ✅ Supported | Azure-hosted OpenAI models | +| **Sagemaker** | ✅ Supported | AWS Sagemaker models | +| **Databricks** | ✅ Supported | Databricks models | +| **DataRobot** | ✅ Supported | DataRobot models | +| **Hosted VLLM** | ✅ Supported | Self-hosted VLLM | +| **Heroku** | ✅ Supported | Heroku-hosted models | +| **RAGFlow** | ✅ Supported | RAGFlow models | +| **Compactif** | ✅ Supported | Compactif models | +| **Cometapi** | ✅ Supported | Comet API models | +| **A2A** | ✅ Supported | Agent-to-Agent models | +| **Bytez** | ✅ Supported | Bytez models | + +### Providers Using OpenAI Handler + +| Provider | Status | Notes | +|----------|--------|-------| +| **OpenAI** | ✅ Supported | Native OpenAI API | +| **Azure OpenAI** | ✅ Supported | Azure-hosted OpenAI | +| **OpenAI-Compatible** | ✅ Supported | Any OpenAI-compatible API | + +## Configuration + +### WebSearch Interception Parameters + +| Parameter | Type | Required | Description | Example | +|-----------|------|----------|-------------|---------| +| `enabled_providers` | List[String] | Yes | List of providers to enable web search for | `[openai, minimax, anthropic]` | +| `search_tool_name` | String | No | Specific search tool from `search_tools` config. If not set, uses first available. | `perplexity-search` | + +### Provider Values + +Use these values in `enabled_providers`: + +| Provider | Value | Provider | Value | +|----------|-------|----------|-------| +| OpenAI | `openai` | Anthropic | `anthropic` | +| MiniMax | `minimax` | Mistral | `mistral` | +| Cohere | `cohere` | Fireworks AI | `fireworks_ai` | +| Together AI | `together_ai` | Groq | `groq` | +| Perplexity | `perplexity` | DeepSeek | `deepseek` | +| xAI | `xai` | Hugging Face | `huggingface` | +| OCI | `oci` | Vertex AI | `vertex_ai` | +| Bedrock | `bedrock` | Azure | `azure` | +| Sagemaker | `sagemaker_chat` | Databricks | `databricks` | +| DataRobot | `datarobot` | VLLM | `hosted_vllm` | +| Heroku | `heroku` | RAGFlow | `ragflow` | +| Compactif | `compactif` | Cometapi | `cometapi` | +| A2A | `a2a` | Bytez | `bytez` | + +## Search Providers + +Configure which search provider to use. LiteLLM supports multiple search providers: + +| Provider | `search_provider` Value | Environment Variable | +|----------|------------------------|----------------------| +| **Perplexity AI** | `perplexity` | `PERPLEXITYAI_API_KEY` | +| **Tavily** | `tavily` | `TAVILY_API_KEY` | +| **Exa AI** | `exa_ai` | `EXA_API_KEY` | +| **Parallel AI** | `parallel_ai` | `PARALLEL_AI_API_KEY` | +| **Google PSE** | `google_pse` | `GOOGLE_PSE_API_KEY`, `GOOGLE_PSE_ENGINE_ID` | +| **DataForSEO** | `dataforseo` | `DATAFORSEO_LOGIN`, `DATAFORSEO_PASSWORD` | +| **Firecrawl** | `firecrawl` | `FIRECRAWL_API_KEY` | +| **SearXNG** | `searxng` | `SEARXNG_API_BASE` (required) | +| **Linkup** | `linkup` | `LINKUP_API_KEY` | + +See [Search Providers Documentation](../search/index.md) for detailed setup instructions. + +## Complete Configuration Example + +```yaml +model_list: + # OpenAI + - model_name: gpt-4o + litellm_params: + model: openai/gpt-4o + api_key: os.environ/OPENAI_API_KEY + + # MiniMax + - model_name: minimax + litellm_params: + model: minimax/MiniMax-M2.1 + api_key: os.environ/MINIMAX_API_KEY + + # Anthropic + - model_name: claude + litellm_params: + model: anthropic/claude-sonnet-4-5 + api_key: os.environ/ANTHROPIC_API_KEY + + # Azure OpenAI + - model_name: azure-gpt4 + litellm_params: + model: azure/gpt-4 + api_base: https://my-azure.openai.azure.com + api_key: os.environ/AZURE_API_KEY + +litellm_settings: + callbacks: + - websearch_interception: + enabled_providers: + - openai + - minimax + - anthropic + - azure + search_tool_name: perplexity-search + +search_tools: + - search_tool_name: perplexity-search + litellm_params: + search_provider: perplexity + api_key: os.environ/PERPLEXITY_API_KEY + + - search_tool_name: tavily-search + litellm_params: + search_provider: tavily + api_key: os.environ/TAVILY_API_KEY +``` + +## Usage Examples + +### Python SDK + +```python +import litellm + +# Configure callbacks +litellm.callbacks = ["websearch_interception"] + +# Make completion with web search tool +response = await litellm.acompletion( + model="gpt-4o", + messages=[ + {"role": "user", "content": "What are the latest AI news?"} + ], + tools=[ + { + "type": "function", + "function": { + "name": "litellm_web_search", + "description": "Search the web for current information", + "parameters": { + "type": "object", + "properties": { + "query": { + "type": "string", + "description": "Search query" + } + }, + "required": ["query"] + } + } + } + ] +) + +print(response.choices[0].message.content) +``` + +### Proxy Server + +```bash +# Start proxy with config +litellm --config config.yaml + +# Make request +curl http://localhost:4000/v1/chat/completions \ + -H "Content-Type: application/json" \ + -H "Authorization: Bearer sk-1234" \ + -d '{ + "model": "gpt-4o", + "messages": [ + {"role": "user", "content": "What is the weather in San Francisco?"} + ], + "tools": [ + { + "type": "function", + "function": { + "name": "litellm_web_search", + "description": "Search the web", + "parameters": { + "type": "object", + "properties": { + "query": {"type": "string"} + }, + "required": ["query"] + } + } + } + ] + }' +``` + +## How Search Tool Selection Works + +1. **If `search_tool_name` is specified** → Uses that specific search tool +2. **If `search_tool_name` is not specified** → Uses first search tool in `search_tools` list + +```yaml +search_tools: + - search_tool_name: perplexity-search # ← This will be used if no search_tool_name specified + litellm_params: + search_provider: perplexity + api_key: os.environ/PERPLEXITY_API_KEY + + - search_tool_name: tavily-search + litellm_params: + search_provider: tavily + api_key: os.environ/TAVILY_API_KEY +``` + +## Troubleshooting + +### Web Search Not Working + +1. **Check provider is enabled**: + ```yaml + enabled_providers: + - openai # Make sure your provider is in this list + ``` + +2. **Verify search tool is configured**: + ```yaml + search_tools: + - search_tool_name: perplexity-search + litellm_params: + search_provider: perplexity + api_key: os.environ/PERPLEXITY_API_KEY + ``` + +3. **Check API keys are set**: + ```bash + export PERPLEXITY_API_KEY=your-key + ``` + +4. **Enable debug logging**: + ```python + litellm.set_verbose = True + ``` + +### Common Issues + +**Issue**: Model returns tool_calls instead of final answer +- **Cause**: Provider not in `enabled_providers` list +- **Solution**: Add provider to `enabled_providers` + +**Issue**: "No search tool configured" error +- **Cause**: No search tools in `search_tools` config +- **Solution**: Add at least one search tool configuration + +**Issue**: "Invalid function arguments json string" error (MiniMax) +- **Cause**: Fixed in latest version - arguments weren't properly JSON serialized +- **Solution**: Update to latest LiteLLM version + +## Related Documentation + +- [Search Providers](../search/index.md) - Detailed search provider setup +- [Claude Code WebSearch](../tutorials/claude_code_websearch.md) - Using with Claude Code +- [Tool Calling](../completion/function_call.md) - General tool calling documentation +- [Callbacks](./custom_callback.md) - Custom callback documentation + +## Technical Details + +### Architecture + +Web search integration is implemented as a custom callback (`WebSearchInterceptionLogger`) that: + +1. **Pre-request Hook**: Converts native web search tools to LiteLLM standard format +2. **Post-response Hook**: Detects web search tool calls in responses +3. **Agentic Loop**: Executes searches and makes follow-up requests automatically + +### Supported APIs + +- ✅ **Chat Completions API** (OpenAI format) +- ✅ **Anthropic Messages API** (Anthropic format) +- ✅ **Streaming** (automatically converted) +- ✅ **Non-streaming** + +### Response Format Detection + +The handler automatically detects response format: +- **OpenAI format**: `tool_calls` in assistant message +- **Anthropic format**: `tool_use` blocks in content + +### Performance + +- **Latency**: Adds one additional LLM call (follow-up request with search results) +- **Caching**: Search results can be cached (depends on search provider) +- **Parallel Searches**: Multiple search queries executed in parallel + +## Contributing + +Found a bug or want to add support for a new provider? See our [Contributing Guide](https://github.com/BerriAI/litellm/blob/main/CONTRIBUTING.md). diff --git a/docs/my-website/docs/load_test.md b/docs/my-website/docs/load_test.md index 4641a70366c..071b097904b 100644 --- a/docs/my-website/docs/load_test.md +++ b/docs/my-website/docs/load_test.md @@ -4,8 +4,9 @@ import Image from '@theme/IdealImage'; ## Locust Load Test LiteLLM Proxy -1. Add `fake-openai-endpoint` to your proxy config.yaml and start your litellm proxy -litellm provides a free hosted `fake-openai-endpoint` you can load test against +1. Add `fake-openai-endpoint` to your proxy config.yaml and start your litellm proxy. + +LiteLLM provides a free hosted `fake-openai-endpoint` you can load test against. You can also self-host your own fake OpenAI proxy server using [github.com/BerriAI/example_openai_endpoint](https://github.com/BerriAI/example_openai_endpoint). ```yaml model_list: diff --git a/docs/my-website/docs/load_test_advanced.md b/docs/my-website/docs/load_test_advanced.md index 3171bc33594..d35b5f74784 100644 --- a/docs/my-website/docs/load_test_advanced.md +++ b/docs/my-website/docs/load_test_advanced.md @@ -29,12 +29,16 @@ Tutorial on how to get to 1K+ RPS with LiteLLM Proxy on locust **Note:** we're currently migrating to aiohttp which has 10x higher throughput. We recommend using the `openai/` provider for load testing. +:::tip Setting Up a Fake OpenAI Endpoint +You can use our hosted fake endpoint or self-host your own using [github.com/BerriAI/example_openai_endpoint](https://github.com/BerriAI/example_openai_endpoint). +::: + ```yaml model_list: - model_name: "fake-openai-endpoint" litellm_params: model: openai/any - api_base: https://your-fake-openai-endpoint.com/chat/completions + api_base: https://exampleopenaiendpoint-production.up.railway.app/ # or your self-hosted endpoint api_key: "test" ``` diff --git a/docs/my-website/docs/mcp.md b/docs/my-website/docs/mcp.md index d63b55ee29e..84d10c25931 100644 --- a/docs/my-website/docs/mcp.md +++ b/docs/my-website/docs/mcp.md @@ -506,7 +506,14 @@ Your OpenAPI specification should follow standard OpenAPI/Swagger conventions: - **Operation IDs**: Each operation should have a unique `operationId` (this becomes the tool name) - **Parameters**: Request parameters should be properly documented with types and descriptions -## MCP Oauth +## MCP OAuth + +LiteLLM supports OAuth 2.0 for MCP servers -- both interactive (PKCE) flows for user-facing clients and machine-to-machine (M2M) `client_credentials` for backend services. + +See the **[MCP OAuth guide](./mcp_oauth.md)** for setup instructions, sequence diagrams, and a test server. + +
+Detailed OAuth reference (click to expand) LiteLLM v 1.77.6 added support for OAuth 2.0 Client Credentials for MCP servers. @@ -588,6 +595,8 @@ sequenceDiagram See the official [MCP Authorization Flow](https://modelcontextprotocol.io/specification/2025-06-18/basic/authorization#authorization-flow-steps) for additional reference. +
+ ## Forwarding Custom Headers to MCP Servers @@ -1486,7 +1495,7 @@ async with stdio_client(server_params) as (read, write): **Q: How do I use OAuth2 client_credentials (machine-to-machine) with MCP servers behind LiteLLM?** -At the moment LiteLLM only forwards whatever `Authorization` header/value you configure for the MCP server; it does not issue OAuth2 tokens by itself. If your MCP requires the Client Credentials grant, obtain the access token directly from the authorization server and set that bearer token as the MCP server’s Authorization header value. LiteLLM does not yet fetch or refresh those machine-to-machine tokens on your behalf, but we plan to add first-class client_credentials support in a future release so the proxy can manage those tokens automatically. +LiteLLM supports automatic token management for the `client_credentials` grant. Configure `client_id`, `client_secret`, and `token_url` on your MCP server and LiteLLM will fetch, cache, and refresh tokens automatically. See the [MCP OAuth M2M guide](./mcp_oauth.md#machine-to-machine-m2m-auth) for setup instructions. **Q: When I fetch an OAuth token from the LiteLLM UI, where is it stored?** diff --git a/docs/my-website/docs/mcp_oauth.md b/docs/my-website/docs/mcp_oauth.md new file mode 100644 index 00000000000..9cd7b1e77be --- /dev/null +++ b/docs/my-website/docs/mcp_oauth.md @@ -0,0 +1,244 @@ +# MCP OAuth + +LiteLLM supports two OAuth 2.0 flows for MCP servers: + +| Flow | Use Case | How It Works | +|------|----------|--------------| +| **Interactive (PKCE)** | User-facing apps (Claude Code, Cursor) | Browser-based consent, per-user tokens | +| **Machine-to-Machine (M2M)** | Backend services, CI/CD, automated agents | `client_credentials` grant, proxy-managed tokens | + +## Interactive OAuth (PKCE) + +For user-facing MCP clients (Claude Code, Cursor), LiteLLM supports the full OAuth 2.0 authorization code flow with PKCE. + +### Setup + +```yaml title="config.yaml" showLineNumbers +mcp_servers: + github_mcp: + url: "https://api.githubcopilot.com/mcp" + auth_type: oauth2 + client_id: os.environ/GITHUB_OAUTH_CLIENT_ID + client_secret: os.environ/GITHUB_OAUTH_CLIENT_SECRET +``` + +[**See Claude Code Tutorial**](./tutorials/claude_responses_api#connecting-mcp-servers) + +### How It Works + +```mermaid +sequenceDiagram + participant Browser as User-Agent (Browser) + participant Client as Client + participant LiteLLM as LiteLLM Proxy + participant MCP as MCP Server (Resource Server) + participant Auth as Authorization Server + + Note over Client,LiteLLM: Step 1 – Resource discovery + Client->>LiteLLM: GET /.well-known/oauth-protected-resource/{mcp_server_name}/mcp + LiteLLM->>Client: Return resource metadata + + Note over Client,LiteLLM: Step 2 – Authorization server discovery + Client->>LiteLLM: GET /.well-known/oauth-authorization-server/{mcp_server_name} + LiteLLM->>Client: Return authorization server metadata + + Note over Client,Auth: Step 3 – Dynamic client registration + Client->>LiteLLM: POST /{mcp_server_name}/register + LiteLLM->>Auth: Forward registration request + Auth->>LiteLLM: Issue client credentials + LiteLLM->>Client: Return client credentials + + Note over Client,Browser: Step 4 – User authorization (PKCE) + Client->>Browser: Open authorization URL + code_challenge + resource + Browser->>Auth: Authorization request + Note over Auth: User authorizes + Auth->>Browser: Redirect with authorization code + Browser->>LiteLLM: Callback to LiteLLM with code + LiteLLM->>Browser: Redirect back with authorization code + Browser->>Client: Callback with authorization code + + Note over Client,Auth: Step 5 – Token exchange + Client->>LiteLLM: Token request + code_verifier + resource + LiteLLM->>Auth: Forward token request + Auth->>LiteLLM: Access (and refresh) token + LiteLLM->>Client: Return tokens + + Note over Client,MCP: Step 6 – Authenticated MCP call + Client->>LiteLLM: MCP request with access token + LiteLLM API key + LiteLLM->>MCP: MCP request with Bearer token + MCP-->>LiteLLM: MCP response + LiteLLM-->>Client: Return MCP response +``` + +**Participants** + +- **Client** -- The MCP-capable AI agent (e.g., Claude Code, Cursor, or another IDE/agent) that initiates OAuth discovery, authorization, and tool invocations on behalf of the user. +- **LiteLLM Proxy** -- Mediates all OAuth discovery, registration, token exchange, and MCP traffic while protecting stored credentials. +- **Authorization Server** -- Issues OAuth 2.0 tokens via dynamic client registration, PKCE authorization, and token endpoints. +- **MCP Server (Resource Server)** -- The protected MCP endpoint that receives LiteLLM's authenticated JSON-RPC requests. +- **User-Agent (Browser)** -- Temporarily involved so the end user can grant consent during the authorization step. + +**Flow Steps** + +1. **Resource Discovery**: The client fetches MCP resource metadata from LiteLLM's `.well-known/oauth-protected-resource` endpoint to understand scopes and capabilities. +2. **Authorization Server Discovery**: The client retrieves the OAuth server metadata (token endpoint, authorization endpoint, supported PKCE methods) through LiteLLM's `.well-known/oauth-authorization-server` endpoint. +3. **Dynamic Client Registration**: The client registers through LiteLLM, which forwards the request to the authorization server (RFC 7591). If the provider doesn't support dynamic registration, you can pre-store `client_id`/`client_secret` in LiteLLM (e.g., GitHub MCP) and the flow proceeds the same way. +4. **User Authorization**: The client launches a browser session (with code challenge and resource hints). The user approves access, the authorization server sends the code through LiteLLM back to the client. +5. **Token Exchange**: The client calls LiteLLM with the authorization code, code verifier, and resource. LiteLLM exchanges them with the authorization server and returns the issued access/refresh tokens. +6. **MCP Invocation**: With a valid token, the client sends the MCP JSON-RPC request (plus LiteLLM API key) to LiteLLM, which forwards it to the MCP server and relays the tool response. + +See the official [MCP Authorization Flow](https://modelcontextprotocol.io/specification/2025-06-18/basic/authorization#authorization-flow-steps) for additional reference. + +## Machine-to-Machine (M2M) Auth + +LiteLLM automatically fetches, caches, and refreshes OAuth2 tokens using the `client_credentials` grant. No manual token management required. + +### Setup + +You can configure M2M OAuth via the LiteLLM UI or `config.yaml`. + +### UI Setup + +Navigate to the **MCP Servers** page and click **+ Add New MCP Server**. + +![](https://colony-recorder.s3.amazonaws.com/files/2026-02-10/d1f1e89c-a789-4975-8846-b15d9821984a/ascreenshot_630800e00a2e4b598baabfc25efbabd3_text_export.jpeg) + +Enter a name for your server and select **HTTP** as the transport type. + +![](https://colony-recorder.s3.amazonaws.com/files/2026-02-10/2008c9d6-6093-4121-beab-1e52c71376aa/ascreenshot_516ffd6c7b524465a253a56048c3d228_text_export.jpeg) + +Paste the MCP server URL. + +![](https://colony-recorder.s3.amazonaws.com/files/2026-02-10/b0ee8b7d-6de8-492b-8962-287987feec29/ascreenshot_b3efca82078a4c6bb1453c58161909f9_text_export.jpeg) + +Under **Authentication**, select **OAuth**. + +![](https://colony-recorder.s3.amazonaws.com/files/2026-02-10/e1597814-ff8e-40b9-9d7b-864dcdbe0910/ascreenshot_2097612712264d8f9e553f7ca9175fb0_text_export.jpeg) + +![](https://colony-recorder.s3.amazonaws.com/files/2026-02-10/f6ea5694-f28a-4bc3-9c9a-bb79f199bd65/ascreenshot_9be839f55b1b4f96bfe24030ba2c7f8d_text_export.jpeg) + +Choose **Machine-to-Machine (M2M)** as the OAuth flow type. This is for server-to-server authentication using the `client_credentials` grant — no browser interaction required. + +![](https://colony-recorder.s3.amazonaws.com/files/2026-02-10/9853310c-1d86-4628-bad1-7a391eca0e4d/ascreenshot_f302a286fa264fdd8d56db53b8f9395c_text_export.jpeg) + +![](https://colony-recorder.s3.amazonaws.com/files/2026-02-10/df64dc65-ef86-475d-adaf-12e227d5e873/ascreenshot_9e2f41d43a76435f918a00b52ffcc639_text_export.jpeg) + +Fill in the **Client ID** and **Client Secret** provided by your OAuth provider. + +![](https://colony-recorder.s3.amazonaws.com/files/2026-02-10/0de5a7bd-9898-4fc7-8843-b23dd5aac47f/ascreenshot_b9087aaa81a14b5b9c199929efc4a563_text_export.jpeg) + +Enter the **Token URL** — this is the endpoint LiteLLM will call to fetch access tokens using `client_credentials`. + +![](https://colony-recorder.s3.amazonaws.com/files/2026-02-10/0aea70f1-558c-4dca-91bc-1175fe1ddc89/ascreenshot_b3fcf8a1287e4e2d9a3d67c4a29f7bff_text_export.jpeg) + +![](https://colony-recorder.s3.amazonaws.com/files/2026-02-10/e842ef09-1fd7-47a6-909b-252d389f0abc/ascreenshot_2a87dad3624847e7ac370591d1d1aedd_text_export.jpeg) + +Scroll down and review the server URL and all fields, then click **Create MCP Server**. + +![](https://colony-recorder.s3.amazonaws.com/files/2026-02-10/0857712b-4b53-40f8-8c1f-a4c72edaa644/ascreenshot_47be3fcd5de64ed391f70c1fb74a8bfc_text_export.jpeg) + +![](https://colony-recorder.s3.amazonaws.com/files/2026-02-10/9d961765-955f-4905-a3dc-1a446aa3b2cc/ascreenshot_43fd39d014224564bc6b35aced1fb6d3_text_export.jpeg) + +![](https://colony-recorder.s3.amazonaws.com/files/2026-02-10/3825d5fa-8fd1-4e71-b090-77ff0259c3f6/ascreenshot_2509a7ebd9bf421eb0e82f2553566745_text_export.jpeg) + +Once created, open the server and navigate to the **MCP Tools** tab to verify that LiteLLM can connect and list available tools. + +![](https://colony-recorder.s3.amazonaws.com/files/2026-02-10/8107e27b-5072-4675-8fd6-89b47692b1bd/ascreenshot_f774bc76138f430d808fb4482ebfcdca_text_export.jpeg) + +![](https://colony-recorder.s3.amazonaws.com/files/2026-02-10/ce94bb7b-c81b-4396-9939-178efb2cdfce/ascreenshot_28b838ab6ae34c76858454555c4c1d79_text_export.jpeg) + +Select a tool (e.g. **echo**) to test it. Fill in the required parameters and click **Call Tool**. + +![](https://colony-recorder.s3.amazonaws.com/files/2026-02-10/c459c1d3-ec29-4211-9c28-37fbe7783bbc/ascreenshot_e9b138b3c2cc4440bb1a6f42ac7ae861_text_export.jpeg) + +![](https://colony-recorder.s3.amazonaws.com/files/2026-02-10/5438ac60-e0ac-4a79-bf6f-5594f160d3b5/ascreenshot_9133a17d26204c46bce497e74685c483_text_export.jpeg) + +![](https://colony-recorder.s3.amazonaws.com/files/2026-02-10/a8f6821b-3982-4b4d-9b25-70c8aff5ac31/ascreenshot_28d474d0e62545a482cff6128527883a_text_export.jpeg) + +LiteLLM automatically fetches an OAuth token behind the scenes and calls the tool. The result confirms the M2M OAuth flow is working end-to-end. + +![](https://colony-recorder.s3.amazonaws.com/files/2026-02-10/c3924549-a949-48d1-ac67-ab4c30475859/ascreenshot_8f6eca9d717f45478d50a881bd244bb3_text_export.jpeg) + +### Config.yaml Setup + +```yaml title="config.yaml" showLineNumbers +mcp_servers: + my_mcp_server: + url: "https://my-mcp-server.com/mcp" + auth_type: oauth2 + client_id: os.environ/MCP_CLIENT_ID + client_secret: os.environ/MCP_CLIENT_SECRET + token_url: "https://auth.example.com/oauth/token" + scopes: ["mcp:read", "mcp:write"] # optional +``` + +### How It Works + +1. On first MCP request, LiteLLM POSTs to `token_url` with `grant_type=client_credentials` +2. The access token is cached in-memory with TTL = `expires_in - 60s` +3. Subsequent requests reuse the cached token +4. When the token expires, LiteLLM fetches a new one automatically + +```mermaid +sequenceDiagram + participant Client as Client + participant LiteLLM as LiteLLM Proxy + participant Auth as Authorization Server + participant MCP as MCP Server + + Client->>LiteLLM: MCP request + LiteLLM API key + LiteLLM->>Auth: POST /oauth/token (client_credentials) + Auth->>LiteLLM: access_token (expires_in: 3600) + LiteLLM->>MCP: MCP request + Bearer token + MCP-->>LiteLLM: MCP response + LiteLLM-->>Client: MCP response + + Note over LiteLLM: Token cached for subsequent requests + Client->>LiteLLM: Next MCP request + LiteLLM->>MCP: MCP request + cached Bearer token + MCP-->>LiteLLM: MCP response + LiteLLM-->>Client: MCP response +``` + +### Test with Mock Server + +Use [BerriAI/mock-oauth2-mcp-server](https://github.com/BerriAI/mock-oauth2-mcp-server) to test locally: + +```bash title="Terminal 1 - Start mock server" showLineNumbers +pip install fastapi uvicorn +python mock_oauth2_mcp_server.py # starts on :8765 +``` + +```yaml title="config.yaml" showLineNumbers +mcp_servers: + test_oauth2: + url: "http://localhost:8765/mcp" + auth_type: oauth2 + client_id: "test-client" + client_secret: "test-secret" + token_url: "http://localhost:8765/oauth/token" +``` + +```bash title="Terminal 2 - Start proxy and test" showLineNumbers +litellm --config config.yaml --port 4000 + +# List tools +curl http://localhost:4000/mcp-rest/tools/list \ + -H "Authorization: Bearer sk-1234" + +# Call a tool +curl http://localhost:4000/mcp-rest/tools/call \ + -H "Content-Type: application/json" \ + -H "Authorization: Bearer sk-1234" \ + -d '{"name": "echo", "arguments": {"message": "hello"}}' +``` + +### Config Reference + +| Field | Required | Description | +|-------|----------|-------------| +| `auth_type` | Yes | Must be `oauth2` | +| `client_id` | Yes | OAuth2 client ID. Supports `os.environ/VAR_NAME` | +| `client_secret` | Yes | OAuth2 client secret. Supports `os.environ/VAR_NAME` | +| `token_url` | Yes | Token endpoint URL | +| `scopes` | No | List of scopes to request | diff --git a/docs/my-website/docs/mcp_public_internet.md b/docs/my-website/docs/mcp_public_internet.md new file mode 100644 index 00000000000..69dd7464657 --- /dev/null +++ b/docs/my-website/docs/mcp_public_internet.md @@ -0,0 +1,251 @@ +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; + +# Exposing MCPs on the Public Internet + +Control which MCP servers are visible to external callers (e.g., ChatGPT, Claude Desktop) vs. internal-only callers. This is useful when you want a subset of your MCP servers available publicly while keeping sensitive servers restricted to your private network. + +## Overview + +| Property | Details | +|-------|-------| +| Description | IP-based access control for MCP servers — external callers only see servers marked as public | +| Setting | `available_on_public_internet` on each MCP server | +| Network Config | `mcp_internal_ip_ranges` in `general_settings` | +| Supported Clients | ChatGPT, Claude Desktop, Cursor, OpenAI API, or any MCP client | + +## How It Works + +When a request arrives at LiteLLM's MCP endpoints, LiteLLM checks the caller's IP address to determine whether they are an **internal** or **external** caller: + +1. **Extract the client IP** from the incoming request (supports `X-Forwarded-For` when configured behind a reverse proxy). +2. **Classify the IP** as internal or external by checking it against the configured private IP ranges (defaults to RFC 1918: `10.0.0.0/8`, `172.16.0.0/12`, `192.168.0.0/16`, `127.0.0.0/8`). +3. **Filter the server list**: + - **Internal callers** see all MCP servers (public and private). + - **External callers** only see servers with `available_on_public_internet: true`. + +This filtering is applied at every MCP access point: the MCP registry, tool listing, tool calling, dynamic server routes, and OAuth discovery endpoints. + +```mermaid +flowchart TD + A[Incoming MCP Request] --> B[Extract Client IP Address] + B --> C{Is IP in private ranges?} + C -->|Yes - Internal caller| D[Return ALL MCP servers] + C -->|No - External caller| E[Return ONLY servers with
available_on_public_internet = true] +``` + +## Walkthrough + +This walkthrough covers two flows: +1. **Adding a public MCP server** (DeepWiki) and connecting to it from ChatGPT +2. **Making an existing server private** (Exa) and verifying ChatGPT no longer sees it + +### Flow 1: Add a Public MCP Server (DeepWiki) + +DeepWiki is a free MCP server — a good candidate to expose publicly so AI gateway users can access it from ChatGPT. + +#### Step 1: Create the MCP Server + +Navigate to the MCP Servers page and click **"+ Add New MCP Server"**. + +![Click Add New MCP Server](https://colony-recorder.s3.amazonaws.com/files/2026-02-07/28cc27c2-d980-4255-b552-ebf542ef95be/ascreenshot_30a7e3c043834f1c87b69e6ffc5bba4f_text_export.jpeg) + +The create dialog opens. Enter **"DeepWiki"** as the server name. + +![Enter server name](https://colony-recorder.s3.amazonaws.com/files/2026-02-07/8c733c38-310a-40ef-8a5b-7af91cc7f74f/ascreenshot_16df83fed5bd4683a22a042e07063cec_text_export.jpeg) + +For the transport type dropdown, select **HTTP** since DeepWiki uses the Streamable HTTP transport. + +![Select transport type](https://colony-recorder.s3.amazonaws.com/files/2026-02-07/e473f603-d692-40c7-a218-866c2e1cb554/ascreenshot_e93997971f2f44beac6152786889addf_text_export.jpeg) + +Now scroll down to the MCP Server URL field. + +![Configure server](https://colony-recorder.s3.amazonaws.com/files/2026-02-07/b08d3c1f-9279-45b6-8efb-f73008901da6/ascreenshot_ce0de66f230a41b0a454e76653429021_text_export.jpeg) + +Enter the DeepWiki MCP URL: `https://mcp.deepwiki.com/mcp`. + +![Enter MCP server URL](https://colony-recorder.s3.amazonaws.com/files/2026-02-07/e59f8285-cfde-4c57-aa79-24244acc9160/ascreenshot_8d575c66dc614a4183212ba282d22b41_text_export.jpeg) + +With the name, transport, and URL filled in, the basic server configuration is complete. + +![Server URL configured](https://colony-recorder.s3.amazonaws.com/files/2026-02-07/0f1af7ed-760d-4445-bdec-3da706d4eef4/ascreenshot_d7d6db69bc254ded871d14a71188a212_text_export.jpeg) + +#### Step 2: Enable "Available on Public Internet" + +Before creating, scroll down and expand the **Permission Management / Access Control** section. This is where you control who can see this server. + +![Expand Permission Management](https://colony-recorder.s3.amazonaws.com/files/2026-02-07/cc10dea2-6028-4a27-a33b-1b1b7212efb5/ascreenshot_0fdd152b862a4bf39973bc805ce64c57_text_export.jpeg) + +Toggle **"Available on Public Internet"** on. This is the key setting — it tells LiteLLM that external callers (like ChatGPT connecting from the public internet) should be able to discover and use this server. + +![Toggle Available on Public Internet](https://colony-recorder.s3.amazonaws.com/files/2026-02-07/39c14543-c5ae-4189-8f85-9efc87135820/ascreenshot_9991f54910c24e21bba5c05ea4fa8e28_text_export.jpeg) + +With the toggle enabled, click **"Create"** to save the server. + +![Click Create](https://colony-recorder.s3.amazonaws.com/files/2026-02-07/843be209-aade-44f4-98da-e55d1644854c/ascreenshot_8cfc90345a5f4d069b397e80d0a6e449_text_export.jpeg) + +#### Step 3: Connect from ChatGPT + +Now let's verify it works. Open ChatGPT and look for the MCP server icon to add a new connection. The endpoint to use is `/mcp`. + +![ChatGPT add MCP server](https://colony-recorder.s3.amazonaws.com/files/2026-02-07/58b5f674-edf4-4156-a5fa-5fdc8ed5d7b9/ascreenshot_36735f7c37394e919793968794614126_text_export.jpeg) + +In the dropdown, select **"Add an MCP server"** to configure a new connection. + +![ChatGPT MCP server option](https://colony-recorder.s3.amazonaws.com/files/2026-02-07/f89da8af-bc61-44a7-a765-f52733f4970d/ascreenshot_6410a917b782437eb558de3bfcd35ffd_text_export.jpeg) + +ChatGPT asks for a server label. Give it a recognizable name like "LiteLLM". + +![Enter server label](https://colony-recorder.s3.amazonaws.com/files/2026-02-07/88505afe-07c1-4674-a89c-8035a5d05eb6/ascreenshot_143aefc38ddd4d3f9f5823ca2cc09bc2_text_export.jpeg) + +Next, enter the Server URL. This should be your LiteLLM proxy's MCP endpoint — `/mcp`. + +![Enter LiteLLM MCP URL](https://colony-recorder.s3.amazonaws.com/files/2026-02-07/9048be4a-7e40-43e7-9789-059fed2741a6/ascreenshot_e81232c17fd148f48f0ae552e9dc2a10_text_export.jpeg) + +Paste your LiteLLM URL and confirm it looks correct. + +![URL pasted](https://colony-recorder.s3.amazonaws.com/files/2026-02-07/7707e796-e146-47c8-bce0-58e6f4076272/ascreenshot_0710dc58b8ed4d6887856b1388d59329_text_export.jpeg) + +ChatGPT also needs authentication. Enter your LiteLLM API key in the authentication field so it can connect to the proxy. + +![Enter API key](https://colony-recorder.s3.amazonaws.com/files/2026-02-07/f6cfcb81-021d-4a41-94d7-d4eaf449d025/ascreenshot_d635865abfb64732a7278922f08dbcaa_text_export.jpeg) + +Click **"Connect"** to establish the connection. + +![Click Connect](https://colony-recorder.s3.amazonaws.com/files/2026-02-07/1146b326-6f0c-4050-9729-af5c88e1bc81/ascreenshot_e19fb857e5394b9a9bf77b075b4fb620_text_export.jpeg) + +ChatGPT connects and shows the available tools. Since both DeepWiki and Exa are currently marked as public, ChatGPT can see tools from both servers. + +![ChatGPT shows available MCP tools](https://colony-recorder.s3.amazonaws.com/files/2026-02-07/43ac56b7-9933-4762-903a-370fc52c79b5/ascreenshot_39073d6dc3bc4bb6a79d93365a26a4f8_text_export.jpeg) + +--- + +### Flow 2: Make an Existing Server Private (Exa) + +Now let's do the reverse — take an existing MCP server (Exa) that's currently public and restrict it to internal access only. After this change, ChatGPT should no longer see Exa's tools. + +#### Step 1: Edit the Server + +Go to the MCP Servers table and click on the Exa server to open its detail view. + +![Exa server overview](https://colony-recorder.s3.amazonaws.com/files/2026-02-07/65844f13-b1ec-4092-b3fd-b1cae3c0c833/ascreenshot_cc8ea435c5e14761a1394ca80fe817c0_text_export.jpeg) + +Switch to the **"Settings"** tab to access the edit form. + +![Click Settings](https://colony-recorder.s3.amazonaws.com/files/2026-02-07/d5b65271-561e-4d2a-b832-96d32611f6e4/ascreenshot_a200942b17264c1eb7a3ffdb2c2141f5_text_export.jpeg) + +The edit form loads with Exa's current configuration. + +![Edit server](https://colony-recorder.s3.amazonaws.com/files/2026-02-07/119184f6-f3cd-45b7-9cfa-0ea08de27020/ascreenshot_c39a793da03a4f0fb84b5ee829af9034_text_export.jpeg) + +#### Step 2: Toggle Off "Available on Public Internet" + +Scroll down and expand the **Permission Management / Access Control** section to find the public internet toggle. + +![Expand permissions](https://colony-recorder.s3.amazonaws.com/files/2026-02-07/bf7114cc-8741-4fa0-a39a-fe625482e88a/ascreenshot_8a987649c03e46558a2ec9a6f2f539a4_text_export.jpeg) + +Toggle **"Available on Public Internet"** off. This will hide Exa from any caller outside your private network. + +![Toggle off public internet](https://colony-recorder.s3.amazonaws.com/files/2026-02-07/f36af5ad-028f-4bb1-aed1-43e38ff9b733/ascreenshot_9128364a049f489bb8483e18e5c88015_text_export.jpeg) + +Click **"Save Changes"** to apply. The change takes effect immediately — no proxy restart needed. + +![Save changes](https://colony-recorder.s3.amazonaws.com/files/2026-02-07/126a71b3-02e1-4d61-a208-942b92e9ef25/ascreenshot_f349ef69e08044dd8e4903f4286b7b97_text_export.jpeg) + +#### Step 3: Verify in ChatGPT + +Go back to ChatGPT to confirm Exa is no longer visible. You'll need to reconnect for ChatGPT to re-fetch the tool list. + +![ChatGPT verify](https://colony-recorder.s3.amazonaws.com/files/2026-02-07/15518882-8b19-44d3-9bba-245aeb62b4b1/ascreenshot_f98f59c51e6543e1be4f3960ba375fc9_text_export.jpeg) + +Open the MCP server settings and select to add or reconnect a server. + +![Reconnect to server](https://colony-recorder.s3.amazonaws.com/files/2026-02-07/784d3174-77c0-42e6-a059-4c906db8f72a/ascreenshot_d77db951b83e4b15a00373222712f6b5_text_export.jpeg) + +Enter the same LiteLLM MCP URL as before. + +![Reconnect URL](https://colony-recorder.s3.amazonaws.com/files/2026-02-07/17ef5fb0-b240-4556-8d20-753d359b7fcf/ascreenshot_583466ce9e8f40d1ba0af8b1e7d04413_text_export.jpeg) + +Set the server label. + +![Reconnect name](https://colony-recorder.s3.amazonaws.com/files/2026-02-07/d7907637-c957-4a3c-ab4f-1600ca9a70a0/ascreenshot_e429eea43f3f4b3ca4d3ac5a77fbde2d_text_export.jpeg) + +Enter your API key for authentication. + +![Reconnect key](https://colony-recorder.s3.amazonaws.com/files/2026-02-07/9cfff77a-37aa-4ca6-8032-0b46c50f37e3/ascreenshot_250664183399496b8f5c9f86f576fc0b_text_export.jpeg) + +Click **"Connect"** to re-establish the connection. + +![Click Connect](https://colony-recorder.s3.amazonaws.com/files/2026-02-07/686f6307-b4ae-448b-ac6c-2c9d7b4f6b57/ascreenshot_3f499d0812af42ab89fed103cc21c249_text_export.jpeg) + +This time, only DeepWiki's tools appear — Exa is gone. LiteLLM detected that ChatGPT is calling from a public IP and filtered out Exa since it's no longer marked as public. Internal users on your private network would still see both servers. + +![Only DeepWiki tools visible](https://colony-recorder.s3.amazonaws.com/files/2026-02-07/667d79b6-75f9-4799-9315-0c176e7a5e34/ascreenshot_efa43050ac0b4445a09e542fa8f270ff_text_export.jpeg) + +## Configuration Reference + +### Per-Server Setting + + + + +Toggle **"Available on Public Internet"** in the Permission Management section when creating or editing an MCP server. + + + + +```yaml title="config.yaml" showLineNumbers +mcp_servers: + deepwiki: + url: https://mcp.deepwiki.com/mcp + available_on_public_internet: true # visible to external callers + + exa: + url: https://exa.ai/mcp + auth_type: api_key + auth_value: os.environ/EXA_API_KEY + available_on_public_internet: false # internal only (default) +``` + + + + +```bash title="Create a public MCP server" showLineNumbers +curl -X POST /v1/mcp/server \ + -H "Authorization: Bearer sk-..." \ + -H "Content-Type: application/json" \ + -d '{ + "server_name": "DeepWiki", + "url": "https://mcp.deepwiki.com/mcp", + "transport": "http", + "available_on_public_internet": true + }' +``` + +```bash title="Update an existing server" showLineNumbers +curl -X PUT /v1/mcp/server \ + -H "Authorization: Bearer sk-..." \ + -H "Content-Type: application/json" \ + -d '{ + "server_id": "", + "available_on_public_internet": false + }' +``` + + + + +### Custom Private IP Ranges + +By default, LiteLLM treats RFC 1918 private ranges as internal. You can customize this in the **Network Settings** tab under MCP Servers, or via config: + +```yaml title="config.yaml" showLineNumbers +general_settings: + mcp_internal_ip_ranges: + - "10.0.0.0/8" + - "172.16.0.0/12" + - "192.168.0.0/16" + - "100.64.0.0/10" # Add your VPN/Tailscale range +``` + +When empty, the standard private ranges are used (`10.0.0.0/8`, `172.16.0.0/12`, `192.168.0.0/16`, `127.0.0.0/8`). diff --git a/docs/my-website/docs/pass_through/bedrock.md b/docs/my-website/docs/pass_through/bedrock.md index b8d20d77da0..65c5d8caadc 100644 --- a/docs/my-website/docs/pass_through/bedrock.md +++ b/docs/my-website/docs/pass_through/bedrock.md @@ -556,3 +556,147 @@ for event in response.get("completion"): print(completion) ``` + +## Using LangChain AWS SDK with LiteLLM + +You can use the [LangChain AWS SDK](https://python.langchain.com/docs/integrations/chat/bedrock/) with LiteLLM Proxy to get cost tracking, load balancing, and other LiteLLM features. + +### Quick Start + +**1. Install LangChain AWS**: + +```bash showLineNumbers +pip install langchain-aws +``` + +**2. Setup LiteLLM Proxy**: + +Create a `config.yaml`: + +```yaml showLineNumbers +model_list: + - model_name: claude-sonnet + litellm_params: + model: bedrock/us.anthropic.claude-3-7-sonnet-20250219-v1:0 + aws_region_name: us-east-1 + custom_llm_provider: bedrock +``` + +Start the proxy: + +```bash showLineNumbers +export AWS_ACCESS_KEY_ID="your-access-key" +export AWS_SECRET_ACCESS_KEY="your-secret-key" + +litellm --config config.yaml + +# RUNNING on http://0.0.0.0:4000 +``` + +**3. Use LangChain with LiteLLM**: + +```python showLineNumbers +from langchain_aws import ChatBedrockConverse +from langchain_core.messages import HumanMessage + +# Your LiteLLM API key +API_KEY = "Bearer sk-1234" + +# Initialize ChatBedrockConverse pointing to LiteLLM proxy +llm = ChatBedrockConverse( + model_id="us.anthropic.claude-3-7-sonnet-20250219-v1:0", + endpoint_url="http://localhost:4000/bedrock", + region_name="us-east-1", + aws_access_key_id=API_KEY, + aws_secret_access_key="bedrock" # Any non-empty value works +) + +# Invoke the model +messages = [HumanMessage(content="Hello, how are you?")] +response = llm.invoke(messages) + +print(response.content) +``` + +### Advanced Example: PDF Document Processing with Citations + +LangChain AWS SDK supports Bedrock's document processing features. Here's how to use it with LiteLLM: + +```python showLineNumbers +import os +import json +from langchain_aws import ChatBedrockConverse +from langchain_core.messages import HumanMessage + +# Your LiteLLM API key +API_KEY = "Bearer sk-1234" + +def get_llm() -> ChatBedrockConverse: + """Initialize LLM pointing to LiteLLM proxy""" + llm = ChatBedrockConverse( + model_id="us.anthropic.claude-3-7-sonnet-20250219-v1:0", + base_model_id="anthropic.claude-3-7-sonnet-20250219-v1:0", + endpoint_url="http://localhost:4000/bedrock", + region_name="us-east-1", + aws_access_key_id=API_KEY, + aws_secret_access_key="bedrock" + ) + return llm + +if __name__ == "__main__": + # Initialize the LLM + llm = get_llm() + + # Read PDF file as bytes (Converse API requires raw bytes) + with open("your-document.pdf", "rb") as file: + file_bytes = file.read() + + # Prepare messages with document attachment + messages = [ + HumanMessage(content=[ + {"text": "What is the policy number in this document?"}, + { + "document": { + "format": "pdf", + "name": "PolicyDocument", + "source": {"bytes": file_bytes}, + "citations": {"enabled": True} + } + } + ]) + ] + + # Invoke the LLM + response = llm.invoke(messages) + + # Print response with citations + print(json.dumps(response.content, indent=4)) +``` + +### Supported LangChain Features + +All LangChain AWS features work with LiteLLM: + +| Feature | Supported | Notes | +|---------|-----------|-------| +| Text Generation | ✅ | Full support | +| Streaming | ✅ | Use `stream()` method | +| Document Processing | ✅ | PDF, images, etc. | +| Citations | ✅ | Enable in document config | +| Tool Use | ✅ | Function calling support | +| Multi-modal | ✅ | Text + images + documents | + +### Troubleshooting + +**Issue**: `UnknownOperationException` error + +**Solution**: Make sure you're using the correct endpoint URL format: +- ✅ Correct: `http://localhost:4000/bedrock` +- ❌ Wrong: `http://localhost:4000/bedrock/v2` + +**Issue**: Authentication errors + +**Solution**: Ensure your API key is in the correct format: +```python +aws_access_key_id="Bearer sk-1234" # Include "Bearer " prefix +``` diff --git a/docs/my-website/docs/providers/litellm_proxy.md b/docs/my-website/docs/providers/litellm_proxy.md index bfefc8a787c..918ac6755a5 100644 --- a/docs/my-website/docs/providers/litellm_proxy.md +++ b/docs/my-website/docs/providers/litellm_proxy.md @@ -227,6 +227,28 @@ response = litellm.completion( ) ``` +## OAuth2/JWT Authentication + +If your LiteLLM Proxy requires OAuth2/JWT authentication (e.g., Azure AD, Keycloak, Okta), the SDK can automatically obtain and refresh tokens for you. + +```python +import litellm +from litellm.proxy_auth import AzureADCredential, ProxyAuthHandler + +litellm.proxy_auth = ProxyAuthHandler( + credential=AzureADCredential(), + scope="api://my-litellm-proxy/.default" +) +litellm.api_base = "https://my-proxy.example.com" + +response = litellm.completion( + model="gpt-4", + messages=[{"role": "user", "content": "Hello!"}] +) +``` + +[Learn more about SDK Proxy Authentication (OAuth2/JWT Auto-Refresh) →](../proxy_auth) + ## Sending `tags` to LiteLLM Proxy Tags allow you to categorize and track your API requests for monitoring, debugging, and analytics purposes. You can send tags as a list of strings to the LiteLLM Proxy using the `extra_body` parameter. diff --git a/docs/my-website/docs/providers/perplexity.md b/docs/my-website/docs/providers/perplexity.md index 2fcb49c60fa..68adf9939c6 100644 --- a/docs/my-website/docs/providers/perplexity.md +++ b/docs/my-website/docs/providers/perplexity.md @@ -120,6 +120,293 @@ All models listed here https://docs.perplexity.ai/docs/model-cards are supported +## Agentic Research API (Responses API) + +Requires v1.72.6+ + + +### Using Presets + +Presets provide optimized defaults for specific use cases. Start with a preset for quick setup: + + + + +```python +from litellm import responses +import os + +os.environ['PERPLEXITY_API_KEY'] = "" + +# Using the pro-search preset +response = responses( + model="perplexity/preset/pro-search", + input="What are the latest developments in AI?", + custom_llm_provider="perplexity", +) + +print(response.output) +``` + + + + +1. Setup config.yaml + +```yaml +model_list: + - model_name: perplexity-pro-search + litellm_params: + model: perplexity/preset/pro-search + api_key: os.environ/PERPLEXITY_API_KEY +``` + +2. Start proxy + +```bash +litellm --config /path/to/config.yaml +``` + +3. Test it! + +```bash +curl http://0.0.0.0:4000/v1/responses \ + -H "Content-Type: application/json" \ + -H "Authorization: Bearer anything" \ + -d '{ + "model": "perplexity-pro-search", + "input": "What are the latest developments in AI?" + }' +``` + + + + +### Using Third-Party Models + +Access models from OpenAI, Anthropic, Google, xAI, and other providers through Perplexity's unified API: + + + + +```python +from litellm import responses +import os + +os.environ['PERPLEXITY_API_KEY'] = "" + +response = responses( + model="perplexity/openai/gpt-4o", + input="Explain quantum computing in simple terms", + custom_llm_provider="perplexity", + max_output_tokens=500, +) + +print(response.output) +``` + + + + +```python +from litellm import responses +import os + +os.environ['PERPLEXITY_API_KEY'] = "" + +response = responses( + model="perplexity/anthropic/claude-3-5-sonnet-20241022", + input="Write a short story about a robot learning to paint", + custom_llm_provider="perplexity", + max_output_tokens=500, +) + +print(response.output) +``` + + + + +```python +from litellm import responses +import os + +os.environ['PERPLEXITY_API_KEY'] = "" + +response = responses( + model="perplexity/google/gemini-2.0-flash-exp", + input="Explain the concept of neural networks", + custom_llm_provider="perplexity", + max_output_tokens=500, +) + +print(response.output) +``` + + + + +```python +from litellm import responses +import os + +os.environ['PERPLEXITY_API_KEY'] = "" + +response = responses( + model="perplexity/xai/grok-2-1212", + input="What makes a good AI assistant?", + custom_llm_provider="perplexity", + max_output_tokens=500, +) + +print(response.output) +``` + + + + +### Web Search Tool + +Enable web search capabilities to access real-time information: + +```python +from litellm import responses +import os + +os.environ['PERPLEXITY_API_KEY'] = "" + +response = responses( + model="perplexity/openai/gpt-4o", + input="What's the weather in San Francisco today?", + custom_llm_provider="perplexity", + tools=[{"type": "web_search"}], + instructions="You have access to a web_search tool. Use it for questions about current events.", +) + +print(response.output) +``` + + +### Reasoning Effort (Responses API) + +Control the reasoning effort level for reasoning-capable models: + +```python +from litellm import responses +import os + +os.environ['PERPLEXITY_API_KEY'] = "" + +response = responses( + model="perplexity/openai/gpt-5.2", + input="Solve this complex problem step by step", + custom_llm_provider="perplexity", + reasoning={"effort": "high"}, # Options: low, medium, high + max_output_tokens=1000, +) + +print(response.output) +``` + +### Multi-Turn Conversations + +Use message arrays for multi-turn conversations with context: + +```python +from litellm import responses +import os + +os.environ['PERPLEXITY_API_KEY'] = "" + +response = responses( + model="perplexity/anthropic/claude-3-5-sonnet-20241022", + input=[ + {"type": "message", "role": "system", "content": "You are a helpful assistant."}, + {"type": "message", "role": "user", "content": "What are the latest AI developments?"}, + ], + custom_llm_provider="perplexity", + instructions="Provide detailed, well-researched answers.", + max_output_tokens=800, +) + +print(response.output) +``` + +### Streaming Responses + +Stream responses for real-time output: + +```python +from litellm import responses +import os + +os.environ['PERPLEXITY_API_KEY'] = "" + +response = responses( + model="perplexity/openai/gpt-4o", + input="Tell me a story about space exploration", + custom_llm_provider="perplexity", + stream=True, + max_output_tokens=500, +) + +for chunk in response: + if hasattr(chunk, 'type'): + if chunk.type == "response.output_text.delta": + print(chunk.delta, end="", flush=True) +``` + +### Supported Third-Party Models + +| Provider | Model Name | Function Call | +|----------|------------|---------------| +| OpenAI | gpt-4o | `responses(model="perplexity/openai/gpt-4o", ...)` | +| OpenAI | gpt-4o-mini | `responses(model="perplexity/openai/gpt-4o-mini", ...)` | +| OpenAI | gpt-5.2 | `responses(model="perplexity/openai/gpt-5.2", ...)` | +| Anthropic | claude-3-5-sonnet-20241022 | `responses(model="perplexity/anthropic/claude-3-5-sonnet-20241022", ...)` | +| Anthropic | claude-3-5-haiku-20241022 | `responses(model="perplexity/anthropic/claude-3-5-haiku-20241022", ...)` | +| Google | gemini-2.0-flash-exp | `responses(model="perplexity/google/gemini-2.0-flash-exp", ...)` | +| Google | gemini-2.0-flash-thinking-exp | `responses(model="perplexity/google/gemini-2.0-flash-thinking-exp", ...)` | +| xAI | grok-2-1212 | `responses(model="perplexity/xai/grok-2-1212", ...)` | +| xAI | grok-2-vision-1212 | `responses(model="perplexity/xai/grok-2-vision-1212", ...)` | + +### Available Presets + +| Preset Name | Function Call | +|----------------|--------------------------------------------------------| +| fast-search | `responses(model="perplexity/preset/fast-search", ...)`| +| pro-search | `responses(model="perplexity/preset/pro-search", ...)` | +| deep-research | `responses(model="perplexity/preset/deep-research", ...)`| + +### Complete Example + +```python +from litellm import responses +import os + +os.environ['PERPLEXITY_API_KEY'] = "" + +# Comprehensive example with multiple features +response = responses( + model="perplexity/openai/gpt-4o", + input="Research the latest developments in quantum computing and provide sources", + custom_llm_provider="perplexity", + tools=[ + {"type": "web_search"}, + {"type": "fetch_url"} + ], + instructions="Use web_search to find relevant information and fetch_url to retrieve detailed content from sources. Provide citations for all claims.", + max_output_tokens=1000, + temperature=0.7, +) + +print(f"Response ID: {response.id}") +print(f"Model: {response.model}") +print(f"Status: {response.status}") +print(f"Output: {response.output}") +print(f"Usage: {response.usage}") +``` + :::info For more information about passing provider-specific parameters, [go here](../completion/provider_specific_params.md) diff --git a/docs/my-website/docs/proxy/admin_ui_sso.md b/docs/my-website/docs/proxy/admin_ui_sso.md index 37e45b50284..f88d3480446 100644 --- a/docs/my-website/docs/proxy/admin_ui_sso.md +++ b/docs/my-website/docs/proxy/admin_ui_sso.md @@ -223,6 +223,7 @@ GENERIC_USER_FIRST_NAME_ATTRIBUTE = "first_name" GENERIC_USER_LAST_NAME_ATTRIBUTE = "last_name" GENERIC_USER_ROLE_ATTRIBUTE = "given_role" GENERIC_USER_PROVIDER_ATTRIBUTE = "provider" +GENERIC_USER_EXTRA_ATTRIBUTES = "department,employee_id,manager" # comma-separated list of additional fields to extract from SSO response GENERIC_CLIENT_STATE = "some-state" # if the provider needs a state parameter GENERIC_INCLUDE_CLIENT_ID = "false" # some providers enforce that the client_id is not in the body GENERIC_SCOPE = "openid profile email" # default scope openid is sometimes not enough to retrieve basic user info like first_name and last_name located in profile scope @@ -239,6 +240,40 @@ Use `GENERIC_USER_ROLE_ATTRIBUTE` to specify which attribute in the SSO token co Nested attribute paths are supported (e.g., `claims.role` or `attributes.litellm_role`). +**Capturing Additional SSO Fields** + +Use `GENERIC_USER_EXTRA_ATTRIBUTES` to extract additional fields from the SSO provider response beyond the standard user attributes (id, email, name, etc.). This is useful when you need to access custom organization-specific data (e.g., department, employee ID, groups) in your [custom SSO handler](./custom_sso.md). + +```shell +# Comma-separated list of field names to extract +GENERIC_USER_EXTRA_ATTRIBUTES="department,employee_id,manager,groups" +``` + +**Accessing Extra Fields in Custom SSO Handler:** + +```python +from litellm.proxy.management_endpoints.types import CustomOpenID + +async def custom_sso_handler(userIDPInfo: CustomOpenID): + # Access the extra fields + extra_fields = getattr(userIDPInfo, 'extra_fields', None) or {} + + user_department = extra_fields.get("department") + employee_id = extra_fields.get("employee_id") + user_groups = extra_fields.get("groups", []) + + # Use these fields for custom logic (e.g., team assignment, access control) + # ... +``` + +**Nested Field Paths:** + +Dot notation is supported for nested fields: + +```shell +GENERIC_USER_EXTRA_ATTRIBUTES="org_info.department,org_info.cost_center,metadata.employee_type" +``` + - Set Redirect URI, if your provider requires it - Set a redirect url = `/sso/callback` ```shell diff --git a/docs/my-website/docs/proxy/config_settings.md b/docs/my-website/docs/proxy/config_settings.md index 5cdae51f448..38ad9bdd0ee 100644 --- a/docs/my-website/docs/proxy/config_settings.md +++ b/docs/my-website/docs/proxy/config_settings.md @@ -395,7 +395,7 @@ router_settings: | ATHINA_API_KEY | API key for Athina service | ATHINA_BASE_URL | Base URL for Athina service (defaults to `https://log.athina.ai`) | AUTH_STRATEGY | Strategy used for authentication (e.g., OAuth, API key) -| AUTO_REDIRECT_UI_LOGIN_TO_SSO | Flag to enable automatic redirect of UI login page to SSO when SSO is configured. Default is **true** +| AUTO_REDIRECT_UI_LOGIN_TO_SSO | Flag to enable automatic redirect of UI login page to SSO when SSO is configured. Default is **false** | AUDIO_SPEECH_CHUNK_SIZE | Chunk size for audio speech processing. Default is 1024 | ANTHROPIC_API_KEY | API key for Anthropic service | ANTHROPIC_API_BASE | Base URL for Anthropic API. Default is https://api.anthropic.com @@ -548,6 +548,10 @@ router_settings: | DEFAULT_MCP_SEMANTIC_FILTER_EMBEDDING_MODEL | Default embedding model for MCP semantic tool filtering. Default is "text-embedding-3-small" | DEFAULT_MCP_SEMANTIC_FILTER_SIMILARITY_THRESHOLD | Default similarity threshold for MCP semantic tool filtering. Default is 0.3 | DEFAULT_MCP_SEMANTIC_FILTER_TOP_K | Default number of top results to return for MCP semantic tool filtering. Default is 10 +| MCP_OAUTH2_TOKEN_CACHE_DEFAULT_TTL | Default TTL in seconds for MCP OAuth2 token cache. Default is 3600 +| MCP_OAUTH2_TOKEN_CACHE_MAX_SIZE | Maximum number of entries in MCP OAuth2 token cache. Default is 200 +| MCP_OAUTH2_TOKEN_CACHE_MIN_TTL | Minimum TTL in seconds for MCP OAuth2 token cache. Default is 10 +| MCP_OAUTH2_TOKEN_EXPIRY_BUFFER_SECONDS | Seconds to subtract from token expiry when computing cache TTL. Default is 60 | DEFAULT_MOCK_RESPONSE_COMPLETION_TOKEN_COUNT | Default token count for mock response completions. Default is 20 | DEFAULT_MOCK_RESPONSE_PROMPT_TOKEN_COUNT | Default token count for mock response prompts. Default is 10 | DEFAULT_MODEL_CREATED_AT_TIME | Default creation timestamp for models. Default is 1677610602 @@ -640,6 +644,7 @@ router_settings: | GENERIC_TOKEN_ENDPOINT | Token endpoint for generic OAuth providers | GENERIC_USER_DISPLAY_NAME_ATTRIBUTE | Attribute for user's display name in generic auth | GENERIC_USER_EMAIL_ATTRIBUTE | Attribute for user's email in generic auth +| GENERIC_USER_EXTRA_ATTRIBUTES | Comma-separated list of additional fields to extract from generic SSO provider response (e.g., "department,employee_id,groups"). Accessible via `CustomOpenID.extra_fields` in custom SSO handlers. Supports dot notation for nested fields | GENERIC_USER_FIRST_NAME_ATTRIBUTE | Attribute for user's first name in generic auth | GENERIC_USER_ID_ATTRIBUTE | Attribute for user ID in generic auth | GENERIC_USER_LAST_NAME_ATTRIBUTE | Attribute for user's last name in generic auth @@ -779,6 +784,7 @@ router_settings: | LITELLM_USER_AGENT | Custom user agent string for LiteLLM API requests. Used for partner telemetry attribution | LITELLM_PRINT_STANDARD_LOGGING_PAYLOAD | If true, prints the standard logging payload to the console - useful for debugging | LITELM_ENVIRONMENT | Environment for LiteLLM Instance. This is currently only logged to DeepEval to determine the environment for DeepEval integration. +| LITELLM_ASYNCIO_QUEUE_MAXSIZE | Maximum size for asyncio queues (e.g. log queues, spend update queues, and cookbook examples such as realtime audio in `nova_sonic_realtime.py`). Bounds in-memory growth to prevent OOM. Default is 1000. | LOGFIRE_TOKEN | Token for Logfire logging service | LOGFIRE_BASE_URL | Base URL for Logfire logging service (useful for self hosted deployments) | LOGGING_WORKER_CONCURRENCY | Maximum number of concurrent coroutine slots for the logging worker on the asyncio event loop. Default is 100. Setting too high will flood the event loop with logging tasks which will lower the overall latency of the requests. @@ -806,6 +812,7 @@ router_settings: | MAX_RETRY_DELAY | Maximum delay in seconds for retrying requests. Default is 8.0 | MAX_LANGFUSE_INITIALIZED_CLIENTS | Maximum number of Langfuse clients to initialize on proxy. Default is 50. This is set since langfuse initializes 1 thread everytime a client is initialized. We've had an incident in the past where we reached 100% cpu utilization because Langfuse was initialized several times. | MAX_MCP_SEMANTIC_FILTER_TOOLS_HEADER_LENGTH | Maximum header length for MCP semantic filter tools. Default is 150 +| MAX_POLICY_ESTIMATE_IMPACT_ROWS | Maximum number of rows returned when estimating the impact of a policy. Default is 1000 | MIN_NON_ZERO_TEMPERATURE | Minimum non-zero temperature value. Default is 0.0001 | MINIMUM_PROMPT_CACHE_TOKEN_COUNT | Minimum token count for caching a prompt. Default is 1024 | MISTRAL_API_BASE | Base URL for Mistral API. Default is https://api.mistral.ai @@ -822,6 +829,8 @@ router_settings: | MICROSOFT_USER_ID_ATTRIBUTE | Field name for user ID in Microsoft SSO response. Default is `id` | MICROSOFT_USER_LAST_NAME_ATTRIBUTE | Field name for user last name in Microsoft SSO response. Default is `surname` | MICROSOFT_USERINFO_ENDPOINT | Custom userinfo endpoint URL for Microsoft SSO (overrides default Microsoft Graph userinfo endpoint) +| MODEL_COST_MAP_MAX_SHRINK_RATIO | Maximum allowed shrinkage ratio when validating a fetched model cost map against the local backup. Rejects the fetched map if it is smaller than this fraction of the backup. Default is 0.5 +| MODEL_COST_MAP_MIN_MODEL_COUNT | Minimum number of models a fetched cost map must contain to be considered valid. Default is 50 | NO_DOCS | Flag to disable Swagger UI documentation | NO_REDOC | Flag to disable Redoc documentation | NO_PROXY | List of addresses to bypass proxy diff --git a/docs/my-website/docs/proxy/custom_sso.md b/docs/my-website/docs/proxy/custom_sso.md index bbd7f41bee1..8b7adeb0c5a 100644 --- a/docs/my-website/docs/proxy/custom_sso.md +++ b/docs/my-website/docs/proxy/custom_sso.md @@ -142,6 +142,18 @@ async def custom_sso_handler(userIDPInfo: OpenID) -> SSOUserDefinedValues: f"No ID found for user. userIDPInfo.id is None {userIDPInfo}" ) + ################################################# + # Access extra fields from SSO provider (requires GENERIC_USER_EXTRA_ATTRIBUTES env var) + # Example: Set GENERIC_USER_EXTRA_ATTRIBUTES="department,employee_id,groups" + extra_fields = getattr(userIDPInfo, 'extra_fields', None) or {} + user_department = extra_fields.get("department") + employee_id = extra_fields.get("employee_id") + user_groups = extra_fields.get("groups", []) + + print(f"User department: {user_department}") # noqa + print(f"Employee ID: {employee_id}") # noqa + print(f"User groups: {user_groups}") # noqa + ################################################# ################################################# # Run your custom code / logic here diff --git a/docs/my-website/docs/proxy/forward_client_headers.md b/docs/my-website/docs/proxy/forward_client_headers.md index 5477ffe87aa..2155a7517be 100644 --- a/docs/my-website/docs/proxy/forward_client_headers.md +++ b/docs/my-website/docs/proxy/forward_client_headers.md @@ -6,6 +6,52 @@ Control which model groups can forward client headers to the underlying LLM prov By default, LiteLLM does not forward client headers to LLM provider APIs for security reasons. However, you can selectively enable header forwarding for specific model groups using the `forward_client_headers_to_llm_api` setting. +## How it Works + +LiteLLM does **not** forward all client headers to the LLM provider. Instead, it uses an **allowlist** approach — only headers matching specific rules are forwarded. This ensures sensitive headers (like your LiteLLM API key) are never accidentally sent to upstream providers. + +```mermaid +sequenceDiagram + participant Client as Client (SDK / curl) + participant Proxy as LiteLLM Proxy + participant Filter as Header Filter (Allowlist) + participant LLM as LLM Provider (OpenAI, Anthropic, etc.) + + Client->>Proxy: Request with all headers
(Authorization, x-trace-id,
x-custom-header, anthropic-beta, etc.) + + Proxy->>Filter: Check forward_client_headers_to_llm_api
setting for this model group + + Note over Filter: Allowlist rules:
1. Headers starting with "x-" ✅
2. "anthropic-beta" ✅
3. "x-stainless-*" ❌ (blocked)
4. All other headers ❌ (blocked) + + Filter-->>Proxy: Return only allowed headers + + Proxy->>LLM: Request with filtered headers
(x-trace-id, x-custom-header,
anthropic-beta) + + LLM-->>Proxy: Response + Proxy-->>Client: Response +``` + +### Header Allowlist Rules + +The following rules determine which headers are forwarded (see [`_get_forwardable_headers`](https://github.com/litellm/litellm/blob/main/litellm/proxy/litellm_pre_call_utils.py) in `litellm/proxy/litellm_pre_call_utils.py`): + +| Rule | Example | Forwarded? | +|---|---|---| +| Headers starting with `x-` | `x-trace-id`, `x-custom-header`, `x-request-source` | ✅ Yes | +| `anthropic-beta` header | `anthropic-beta: prompt-caching-2024-07-31` | ✅ Yes | +| Headers starting with `x-stainless-*` | `x-stainless-lang`, `x-stainless-arch` | ❌ No (causes OpenAI SDK issues) | +| Standard HTTP headers | `Authorization`, `Content-Type`, `Host` | ❌ No | +| Other provider headers | `Accept`, `User-Agent` | ❌ No | + +### Additional Header Mechanisms + +| Mechanism | Description | Reference | +|---|---|---| +| **`x-pass-` prefix** | Headers prefixed with `x-pass-` are always forwarded with the prefix stripped, regardless of settings. E.g., `x-pass-anthropic-beta: value` → `anthropic-beta: value`. Works for all pass-through endpoints. | [Source code](https://github.com/litellm/litellm/blob/main/litellm/passthrough/utils.py) | +| **`openai-organization`** | Forwarded only when `forward_openai_org_id: true` is set in `general_settings`. | [Forward OpenAI Org ID](#enable-globally) | +| **User information headers** | When `add_user_information_to_llm_headers: true`, LiteLLM adds `x-litellm-user-id`, `x-litellm-org-id`, etc. | [User Information Headers](#user-information-headers-optional) | +| **Vertex AI pass-through** | Uses a separate, stricter allowlist: only `anthropic-beta` and `content-type`. | [Source code](https://github.com/litellm/litellm/blob/main/litellm/constants.py) | + ## Configuration ## Enable Globally diff --git a/docs/my-website/docs/proxy/guardrails/custom_code_guardrail.md b/docs/my-website/docs/proxy/guardrails/custom_code_guardrail.md index cb246144497..8cbc247ae5e 100644 --- a/docs/my-website/docs/proxy/guardrails/custom_code_guardrail.md +++ b/docs/my-website/docs/proxy/guardrails/custom_code_guardrail.md @@ -61,15 +61,23 @@ curl -X POST http://localhost:4000/chat/completions \ ### Function Signature -Your code must define an `apply_guardrail` function: +Your code must define an `apply_guardrail` function. It can be either sync or async: ```python +# Sync version def apply_guardrail(inputs, request_data, input_type): # inputs: see table below # request_data: {"model": "...", "user_id": "...", "team_id": "...", "metadata": {...}} # input_type: "request" or "response" return allow() # or block() or modify() + +# Async version (recommended when using HTTP primitives) +async def apply_guardrail(inputs, request_data, input_type): + response = await http_post("https://api.example.com/check", body={"text": inputs["texts"][0]}) + if response["success"] and response["body"].get("flagged"): + return block("Content flagged") + return allow() ``` ### `inputs` Parameter @@ -145,6 +153,29 @@ def apply_guardrail(inputs, request_data, input_type): | `char_count(text)` | Count characters | | `lower(text)` / `upper(text)` / `trim(text)` | String transforms | +### HTTP Requests (Async) + +Make async HTTP requests to external APIs for additional validation or content moderation. + +| Function | Description | +|----------|-------------| +| `await http_request(url, method, headers, body, timeout)` | General async HTTP request | +| `await http_get(url, headers, timeout)` | Async GET request | +| `await http_post(url, body, headers, timeout)` | Async POST request | + +**Response format:** +```python +{ + "status_code": 200, # HTTP status code + "body": {...}, # Response body (parsed JSON or string) + "headers": {...}, # Response headers + "success": True, # True if status code is 2xx + "error": None # Error message if request failed +} +``` + +**Note:** When using HTTP primitives, define your function as `async def apply_guardrail(...)` for non-blocking execution. + ## Examples ### Block PII (SSN) @@ -213,6 +244,29 @@ def apply_guardrail(inputs, request_data, input_type): return allow() ``` +### Call External Moderation API (Async) + +```python +async def apply_guardrail(inputs, request_data, input_type): + # Call an external moderation API + for text in inputs["texts"]: + response = await http_post( + "https://api.example.com/moderate", + body={"text": text, "user_id": request_data["user_id"]}, + headers={"Authorization": "Bearer YOUR_API_KEY"}, + timeout=10 + ) + + if not response["success"]: + # API call failed - decide whether to allow or block + return allow() + + if response["body"].get("flagged"): + return block(response["body"].get("reason", "Content flagged")) + + return allow() +``` + ### Combine Multiple Checks ```python @@ -241,8 +295,8 @@ Custom code runs in a restricted environment: - ❌ No `import` statements - ❌ No file I/O -- ❌ No network access - ❌ No `exec()` or `eval()` +- ✅ HTTP requests via built-in `http_request`, `http_get`, `http_post` primitives - ✅ Only LiteLLM-provided primitives available ## Per-Request Usage diff --git a/docs/my-website/docs/proxy/guardrails/guardrail_policies.md b/docs/my-website/docs/proxy/guardrails/guardrail_policies.md index 56be11c85a7..e2cb839203e 100644 --- a/docs/my-website/docs/proxy/guardrails/guardrail_policies.md +++ b/docs/my-website/docs/proxy/guardrails/guardrail_policies.md @@ -1,3 +1,7 @@ +import Image from '@theme/IdealImage'; +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; + # [Beta] Guardrail Policies Use policies to group guardrails and control which ones run for specific teams, keys, or models. @@ -10,6 +14,9 @@ Use policies to group guardrails and control which ones run for specific teams, ## Quick Start + + + ```yaml showLineNumbers title="config.yaml" model_list: - model_name: gpt-4 @@ -43,6 +50,26 @@ policy_attachments: scope: "*" # apply to all requests ``` + + + +**Step 1: Create a Policy** + +Go to **Policies** tab and click **+ Create New Policy**. Fill in the policy name, description, and select guardrails to add. + +![Enter policy name](https://colony-recorder.s3.amazonaws.com/files/2026-02-11/4ba62cc8-d2c4-4af1-a526-686295466928/ascreenshot_401eab3e2081466e8f4d4ffa3bf7bff4_text_export.jpeg) + +![Add a description for the policy](https://colony-recorder.s3.amazonaws.com/files/2026-02-11/51685e47-1d94-4d9c-acb0-3c88dce9f938/ascreenshot_a5cd40066ff34afbb1e4089a3c93d889_text_export.jpeg) + +![Select a parent policy to inherit from](https://colony-recorder.s3.amazonaws.com/files/2026-02-11/1d96c3d3-187a-4f7c-97d2-6ac1f093d51e/ascreenshot_8a3af3b2210547dca3d4709df920d005_text_export.jpeg) + +![Select guardrails to add to the policy](https://colony-recorder.s3.amazonaws.com/files/2026-02-11/23781274-e600-4d5f-a8a6-4a2a977a166c/ascreenshot_a2a45d2c5d064c77ab7cb47b569ad9e9_text_export.jpeg) + +![Click Create Policy to save](https://colony-recorder.s3.amazonaws.com/files/2026-02-11/1d1ae8a8-daa5-451b-9fa2-c5b607ff6220/ascreenshot_218c2dd259714be4aa3c4e1894c96878_text_export.jpeg) + + + + Response headers show what ran: ``` @@ -58,6 +85,9 @@ x-litellm-applied-guardrails: pii_masking,prompt_injection You have a global baseline, but want to add extra guardrails for a specific team. + + + ```yaml showLineNumbers title="config.yaml" policies: global-baseline: @@ -81,6 +111,30 @@ policy_attachments: - finance # team alias from /team/new ``` + + + +**Option 1: Create a team-scoped attachment** + +Go to **Policies** > **Attachments** tab and click **+ Create New Attachment**. Select the policy and the teams to scope it to. + +![Select teams for the attachment](https://colony-recorder.s3.amazonaws.com/files/2026-02-11/50e58f54-3bc3-477e-a106-e58cb65fde7e/ascreenshot_85d2e3d9d8d24842baced92fea170427_text_export.jpeg) + +![Select the teams to attach the policy to](https://colony-recorder.s3.amazonaws.com/files/2026-02-11/f24066bb-0a73-49fb-87b6-c65ad3ca5b2f/ascreenshot_242476fbdac447309f65de78b0ed9fdd_text_export.jpeg) + +**Option 2: Attach from team settings** + +Go to **Teams** > click on a team > **Settings** tab > under **Policies**, select the policies to attach. + +![Open team settings and click Edit Settings](https://colony-recorder.s3.amazonaws.com/files/2026-02-11/c31c3735-4f9d-4c6a-896b-186e97296940/ascreenshot_4749bb24ce5942cca462acc958fd3822_text_export.jpeg) + +![Select policies to attach to this team](https://colony-recorder.s3.amazonaws.com/files/2026-02-11/da8d5d7a-d975-4bfe-acd2-f41dcea29520/ascreenshot_835a33b6cec545cbb2987f017fbaff90_text_export.jpeg) + + + + + + Now the `finance` team gets `pii_masking` + `strict_compliance_check` + `audit_logger`, while everyone else just gets `pii_masking`. ## Remove guardrails for a specific team @@ -201,6 +255,60 @@ policy_attachments: - "test-*" # key alias pattern ``` +**Tag-based** (matches keys/teams by metadata tags, wildcards supported): + +```yaml showLineNumbers title="config.yaml" +policy_attachments: + - policy: hipaa-compliance + tags: + - "healthcare" + - "health-*" # wildcard - matches health-team, health-dev, etc. +``` + +Tags are read from key and team `metadata.tags`. For example, a key created with `metadata: {"tags": ["healthcare"]}` would match the attachment above. + +## Test Policy Matching + +Debug which policies and guardrails apply for a given context. Use this to verify your policy configuration before deploying. + + + + +Go to **Policies** > **Test** tab. Enter a team alias, key alias, model, or tags and click **Test** to see which policies match and what guardrails would be applied. + + + + + + +```bash +curl -X POST "http://localhost:4000/policies/resolve" \ + -H "Authorization: Bearer " \ + -H "Content-Type: application/json" \ + -d '{ + "tags": ["healthcare"], + "model": "gpt-4" + }' +``` + +Response: + +```json +{ + "effective_guardrails": ["pii_masking"], + "matched_policies": [ + { + "policy_name": "hipaa-compliance", + "matched_via": "tag:healthcare", + "guardrails_added": ["pii_masking"] + } + ] +} +``` + + + + ## Config Reference ### `policies` @@ -233,14 +341,18 @@ policy_attachments: scope: ... teams: [...] keys: [...] + models: [...] + tags: [...] ``` | Field | Type | Description | |-------|------|-------------| | `policy` | `string` | **Required.** Name of the policy to attach. | | `scope` | `string` | Use `"*"` to apply globally. | -| `teams` | `list[string]` | Team aliases (from `/team/new`). | +| `teams` | `list[string]` | Team aliases (from `/team/new`). Supports `*` wildcard. | | `keys` | `list[string]` | Key aliases (from `/key/generate`). Supports `*` wildcard. | +| `models` | `list[string]` | Model names. Supports `*` wildcard. | +| `tags` | `list[string]` | Tag patterns (from key/team `metadata.tags`). Supports `*` wildcard. | ### Response Headers @@ -248,6 +360,7 @@ policy_attachments: |--------|-------------| | `x-litellm-applied-policies` | Policies that matched this request | | `x-litellm-applied-guardrails` | Guardrails that actually ran | +| `x-litellm-policy-sources` | Why each policy matched (e.g., `hipaa=tag:healthcare; baseline=scope:*`) | ## How it works diff --git a/docs/my-website/docs/proxy/guardrails/policy_tags.md b/docs/my-website/docs/proxy/guardrails/policy_tags.md new file mode 100644 index 00000000000..11840116c31 --- /dev/null +++ b/docs/my-website/docs/proxy/guardrails/policy_tags.md @@ -0,0 +1,139 @@ +# Tag-Based Policy Attachments + +Apply guardrail policies automatically to any key or team that has a specific tag. Instead of attaching policies one-by-one, tag your keys and let the policy engine handle the rest. + +**Example:** Your security team requires all healthcare-related keys to run PII masking and PHI detection. Tag those keys with `health`, create a single tag-based attachment, and every matching key gets the guardrails automatically. + +## 1. Create a Policy with Guardrails + +Navigate to **Policies** in the left sidebar. You'll see a list of existing policies along with their guardrails. + +![Policies list page showing existing policies and the + Add New Policy button](https://colony-recorder.s3.amazonaws.com/files/2026-02-11/d7aa1e1f-011e-40bf-a356-6dfe9d5d54f1/ascreenshot_8db95c231a7f4a79a36c2a98ba127542_text_export.jpeg) + +Click **+ Add New Policy**. In the modal, enter a name for your policy (e.g., `high-risk-policy2`). You can also type to search existing policy names if you want to reference them. + +![Create New Policy modal — enter the policy name and optional description](https://colony-recorder.s3.amazonaws.com/files/2026-02-11/18f1ff69-9b83-4a98-9aad-9892a104d3ff/ascreenshot_1c6b85231cad4ec695750b53bbbda52c_text_export.jpeg) + +Scroll down to **Guardrails to Add**. Click the dropdown to see all available guardrails configured on your proxy — select the ones this policy should enforce. + +![Guardrails to Add dropdown showing available guardrails like OAI-moderation, phi-pre-guard, pii-pre-guard](https://colony-recorder.s3.amazonaws.com/files/2026-02-11/55cedad7-9939-44a1-8644-a184cde82ab7/ascreenshot_eab4e55b82b8411893eccb6234d60b82_text_export.jpeg) + +After selecting your guardrails, they appear as chips in the input field. The **Resolved Guardrails** section below shows the final set that will be applied (including any inherited from a parent policy). + +![Selected guardrails shown as chips: testing-pl, phi-pre-guard, pii-pre-guard. Resolved Guardrails preview below.](https://colony-recorder.s3.amazonaws.com/files/2026-02-11/c06d5b08-1c85-4715-b827-3e6864880428/ascreenshot_7a082e55f3ad425f9009346c68afae23_text_export.jpeg) + +Click **Create Policy** to save. + +![Click Create Policy to save the new policy](https://colony-recorder.s3.amazonaws.com/files/2026-02-11/7e6eae64-4bba-4d72-b226-d1308ac576a8/ascreenshot_22d0ed686c594221bbbd2f40df214d75_text_export.jpeg) + +## 2. Add a Tag Attachment for the Policy + +After creating the policy, switch to the **Attachments** tab. This is where you define *where* the policy applies. + +![Switch to the Attachments tab — shows the attachment table and scope documentation](https://colony-recorder.s3.amazonaws.com/files/2026-02-11/871ae6d9-16d1-44e2-baf2-7bb8a9e72087/ascreenshot_76e124619d70462ea0e2fbb46ded1ac9_text_export.jpeg) + +Click **+ Add New Attachment**. The Attachments page explains the available scopes: Global, Teams, Keys, Models, and **Tags**. + +![Attachments page showing scope types including Tags — click + Add New Attachment](https://colony-recorder.s3.amazonaws.com/files/2026-02-11/d45ab8bc-fc1e-425b-8a3f-44d18df810ec/ascreenshot_425824030f3144b7ab3c0ac570349b00_text_export.jpeg) + +In the **Create Policy Attachment** modal, first select the policy you just created from the dropdown. + +![Select the policy to attach from the dropdown (e.g., high-risk-policy2)](https://colony-recorder.s3.amazonaws.com/files/2026-02-11/e0dcac40-e39c-4a6a-9d9c-4bbb9ec0ee91/ascreenshot_445b19894e0b466196a13e20c8e67f2d_text_export.jpeg) + +Choose **Specific (teams, keys, models, or tags)** as the scope type. This expands the form to show fields for Teams, Keys, Models, and Tags. + +![Select "Specific" scope type to reveal the Tags field](https://colony-recorder.s3.amazonaws.com/files/2026-02-11/f685e02a-e22e-4c6c-9742-d5268746214b/ascreenshot_14d63d9d06dd4fc7854cfeb5e8d9ef85_text_export.jpeg) + +Scroll down to the **Tags** field and type the tag to match — here we enter `health`. You can enter any string, or use a wildcard pattern like `health-*` to match all tags starting with `health-` (e.g., `health-team`, `health-dev`). + +![Tags field with "health" entered. Supports wildcards like prod-* matching prod-us, prod-eu.](https://colony-recorder.s3.amazonaws.com/files/2026-02-11/14581df7-732c-4ea5-b36d-58270b00e92c/ascreenshot_e734c81418f046549b61a84b9d352a29_text_export.jpeg) + +## 3. Check the Impact of the Attachment + +Before creating the attachment, click **Estimate Impact** to preview how many keys and teams would be affected. This is your blast-radius check — make sure the scope is what you expect before applying. + +![Click Estimate Impact — the tag "health" is entered and ready to preview](https://colony-recorder.s3.amazonaws.com/files/2026-02-11/6ccb81d7-3d11-48b0-b634-fc4d738aa530/ascreenshot_2eb89e6ff13a4b12b61004660a36c30c_text_export.jpeg) + +The **Impact Preview** appears inline, showing exactly how many keys and teams would be affected. In this example: "This attachment would affect **1 key** and **0 teams**", with the key alias `hi` listed. + +![Impact Preview showing "This attachment would affect 1 key and 0 teams." Keys: hi](https://colony-recorder.s3.amazonaws.com/files/2026-02-11/8834d85a-2c15-48dd-8d6b-810cf11ee5c4/ascreenshot_d814b42ca9f34c23b0c2269bfa3e64fb_text_export.jpeg) + +Once you're satisfied with the impact, click **Create Attachment** to save. + +![Click Create Attachment to finalize](https://colony-recorder.s3.amazonaws.com/files/2026-02-11/4a8918f2-eedb-4f49-a53b-4e46d0387d2a/ascreenshot_b08d490d836d4f46b4e5cbb14f61377a_text_export.jpeg) + +The attachment now appears in the table with the policy name `high-risk-policy2` and tag `health` visible. + +![Attachments table showing the new attachment with policy high-risk-policy2 and tag "health"](https://colony-recorder.s3.amazonaws.com/files/2026-02-11/45867887-0aec-44a4-963b-b6cc6c302e3e/ascreenshot_981caeff98574ec89a8a53cd295e5043_text_export.jpeg) + +## 4. Create a Key with the Tag + +Navigate to **Virtual Keys** in the left sidebar. Click **+ Create New Key**. + +![Virtual Keys page showing existing keys — click + Create New Key](https://colony-recorder.s3.amazonaws.com/files/2026-02-11/4c1f9448-e590-4546-9357-6f68aa395b27/ascreenshot_4a7bc5be9e4347f3a9fe46f78d938d7c_text_export.jpeg) + +Enter a key name and select a model. Then expand **Optional Settings** and scroll down to the **Tags** field. + +![Create New Key modal — enter the key name](https://colony-recorder.s3.amazonaws.com/files/2026-02-11/f84f7a2b-8057-4926-9f80-d68e437c77cf/ascreenshot_a277c8611b6e41059663b0759cd85cab_text_export.jpeg) + +In the **Tags** field, type `health` and press Enter. This is the tag the policy engine will match against. + +![Tags field in key creation — type "health" to add the tag](https://colony-recorder.s3.amazonaws.com/files/2026-02-11/3ad3bf10-76d2-4f15-9a66-ed6c99bb25c4/ascreenshot_8a8773fb65fc49329cb1716da92b2723_text_export.jpeg) + +The tag `health` now appears as a chip in the Tags field. Confirm your settings look correct. + +![Tags field showing "health" selected with a checkmark](https://colony-recorder.s3.amazonaws.com/files/2026-02-11/de3e58a9-6013-4d0c-882e-5517ea286684/ascreenshot_c7eef1736fce4aa894ac3b118b3800a2_text_export.jpeg) + +Click **Create Key** at the bottom of the form. + +![Click Create Key to generate the new virtual key with the health tag](https://colony-recorder.s3.amazonaws.com/files/2026-02-11/51d419ea-ee80-4e24-8e93-b99a844881bc/ascreenshot_097d4564289943a88e30b5d2e3eab262_text_export.jpeg) + +A dialog appears with your new virtual key. Click **Copy Virtual Key** — you'll need this to test in the next step. + +![Save your Key dialog — click Copy Virtual Key to copy it to clipboard](https://colony-recorder.s3.amazonaws.com/files/2026-02-11/e87a0cc1-4d12-4066-bfa2-973159808fd1/ascreenshot_7b616a7291d0497a9c61bdcdb59394d7_text_export.jpeg) + +## 5. Test the Key and Validate the Policy is Applied + +Navigate to **Playground** in the left sidebar to test the key interactively. + +![Navigate to Playground from the sidebar](https://colony-recorder.s3.amazonaws.com/files/2026-02-11/e6f8a3ee-e9e8-4107-93d1-bfca734c5ce9/ascreenshot_539bde38abe646e49148a912fff2d257_text_export.jpeg) + +Under **Virtual Key Source**, select "Virtual Key" and paste the key you just copied into the input field. + +![Paste the virtual key into the Playground configuration](https://colony-recorder.s3.amazonaws.com/files/2026-02-11/a6612c4a-d499-4e54-8019-f54fde674ad9/ascreenshot_e85ebb9051554594bab0da57823fafad_text_export.jpeg) + +Select a model from the **Select Model** dropdown. + +![Select a model (e.g., bedrock-claude-opus-4.5) from the dropdown](https://colony-recorder.s3.amazonaws.com/files/2026-02-11/325e330f-3eff-4c5e-b177-21916138a2f5/ascreenshot_693478f89c034e949e08f3ed0dd05120_text_export.jpeg) + +Type a message and press Enter. If a guardrail blocks the request, you'll see it in the response. In this example, the `testing-pl` guardrail detected an email pattern and returned a 403 error — confirming the policy is working. + +![Guardrail in action — the request was blocked with "Content blocked: email pattern detected"](https://colony-recorder.s3.amazonaws.com/files/2026-02-11/2cf16809-d2e5-4eae-a7dd-6a16dfcca7ce/ascreenshot_727d7d4ed20b4a52b2b41e39fd36eccb_text_export.jpeg) + +**Using curl:** + +You can also verify via the command line. The response headers confirm which policies and guardrails were applied: + +```bash +curl -v http://localhost:4000/chat/completions \ + -H "Authorization: Bearer " \ + -H "Content-Type: application/json" \ + -d '{ + "model": "gpt-4o", + "messages": [{"role": "user", "content": "say hi"}] + }' +``` + +Check the response headers: + +``` +x-litellm-applied-policies: high-risk-policy2 +x-litellm-applied-guardrails: pii-pre-guard,phi-pre-guard,testing-pl +x-litellm-policy-sources: high-risk-policy2=tag:health +``` + +| Header | What it tells you | +|--------|-------------------| +| `x-litellm-applied-policies` | Which policies matched this request | +| `x-litellm-applied-guardrails` | Which guardrails actually ran | +| `x-litellm-policy-sources` | **Why** each policy matched — `tag:health` confirms it was the tag | diff --git a/docs/my-website/docs/proxy/guardrails/zscaler_ai_guard.md b/docs/my-website/docs/proxy/guardrails/zscaler_ai_guard.md index 94f31c3bfdf..2e626004238 100644 --- a/docs/my-website/docs/proxy/guardrails/zscaler_ai_guard.md +++ b/docs/my-website/docs/proxy/guardrails/zscaler_ai_guard.md @@ -100,7 +100,7 @@ In cases where encounter other errors when apply Zscaler AI Guard, return exampl } } ``` -## 6. Sending User Information to Zscaler AI Guard for Analysis (Optional) +## 6. Sending User Information to Zscaler AI Guard (Optional) If you need to send end-user information to Zscaler AI Guard for analysis, you can set the configuration in the environment variables to True and include the relevant information in custom_headers on Zscaler AI Guard. - To send user_api_key_alias: @@ -133,4 +133,30 @@ curl -i http://localhost:8165/v1/chat/completions \ "zguard_policy_id": } }' +``` + +## 8. Set Custom Zscaler AI Guard Policy on Litellm Team OR Key Metadata (Optional) +In addition to setting `zguard_policy_id` in a request or the configuration file, you can also set it in the metadata for LiteLLM Team or Key. The `zguard_policy_id` is determined using the following order of precedence: request, Key, Team, config file. This logic is illustrated below: +``` +user_api_key_metadata = metadata.get("user_api_key_metadata", {}) or {} +team_metadata = metadata.get("team_metadata", {}) or {} +policy_id = ( + metadata.get("zguard_policy_id") + if "zguard_policy_id" in metadata + else ( + user_api_key_metadata.get("zguard_policy_id") + if "zguard_policy_id" in user_api_key_metadata + else ( + team_metadata.get("zguard_policy_id") + if "zguard_policy_id" in team_metadata + else self.policy_id + ) + ) + ) +``` +You can leverage this feature to apply multiple policies configured on the Zscaler AI Guard (ZGuard) to traffic from different applications. (Note: It is recommended to map policies using either Team or Key metadata, but not a mix of both.) + +Example set in Team/Key Metadata, you can set From UI: +``` +{"zguard_policy_id": 100} ``` \ No newline at end of file diff --git a/docs/my-website/docs/proxy/ui_team_soft_budget_alerts.md b/docs/my-website/docs/proxy/ui_team_soft_budget_alerts.md new file mode 100644 index 00000000000..17c42e57c9a --- /dev/null +++ b/docs/my-website/docs/proxy/ui_team_soft_budget_alerts.md @@ -0,0 +1,130 @@ +import Image from '@theme/IdealImage'; + +# Team Soft Budget Alerts + +Set a soft budget on a team and get email alerts when spending crosses the threshold — without blocking any requests. + +## Overview + +A **soft budget** is a spending threshold that triggers email notifications when exceeded, but **does not block requests**. This is different from a hard budget (`max_budget`), which rejects requests once the limit is reached. + + + +Team soft budget alerts let you: + +- **Get notified early** — receive email alerts when a team's spend crosses the soft budget threshold +- **Keep requests flowing** — unlike hard budgets, soft budgets never block API calls +- **Target specific recipients** — send alerts to specific email addresses (e.g. team leads, finance), not just the team members +- **Work without global alerting** — team soft budget alerts are sent via email independently of Slack or other global alerting configuration + +:::warning Email integration required +Team soft budget alerts are sent via email. You must have an active email integration (SendGrid, Resend, or SMTP) configured on your proxy for alerts to be delivered. See [Email Notifications](./email.md) for setup instructions. +::: + +:::info Automatically active +Team soft budget alerts are **automatically active** once you configure a soft budget and at least one alerting email on a team. No additional proxy configuration or restart is needed — alerts are checked on every request. +::: + +## How It Works + +On every API request made with a key belonging to a team, the proxy checks: + +1. Does the team have a `soft_budget` set? +2. Is the team's current `spend` >= the `soft_budget`? +3. Are there any emails configured in `soft_budget_alerting_emails`? + +If all three conditions are met, an email alert is sent to the configured recipients. Alerts are **deduplicated** so the same alert is only sent once within a 24-hour window. + +## How to Set Up Team Soft Budget Alerts + +### 1. Navigate to the Admin UI + +Go to the Admin UI (e.g. `http://localhost:4000/ui` or your `PROXY_BASE_URL/ui`). + +![](https://colony-recorder.s3.amazonaws.com/files/2026-02-07/f06d75ad-25ef-4ee8-90c3-9604f8e46a1c/ascreenshot_1a6defaed1494d6da0001459511ecfd5_text_export.jpeg) + +### 2. Go to Teams + +Click **Teams** in the sidebar. + +![](https://colony-recorder.s3.amazonaws.com/files/2026-02-07/f06d75ad-25ef-4ee8-90c3-9604f8e46a1c/ascreenshot_2d258fa280f6463b966bf7a05bb102d5_text_export.jpeg) + +### 3. Select a team + +Click on the team you want to configure soft budget alerts for. + +![](https://colony-recorder.s3.amazonaws.com/files/2026-02-07/490f09fb-6bf5-45a8-a384-676889f34c88/ascreenshot_15cceb22abe64df0bf7d7c742ecb5b2f_text_export.jpeg) + +### 4. Open team Settings + +Click the **Settings** tab to view the team's configuration. + +![](https://colony-recorder.s3.amazonaws.com/files/2026-02-07/28dd1bc5-7d07-462f-b277-33f885bdc07e/ascreenshot_12f2b762b5d24686801d93ad5b067e06_text_export.jpeg) + +### 5. Edit Settings + +Click **Edit Settings** to modify the team's budget configuration. + +![](https://colony-recorder.s3.amazonaws.com/files/2026-02-07/30a483ea-7e01-4fdc-ac5f-a5572388d138/ascreenshot_0915eadd9e754a798489853b82de3cb5_text_export.jpeg) + +### 6. Set the Soft Budget + +Click the **Soft Budget (USD)** field and enter your desired threshold. For example, enter `0.01` for testing or a higher value like `500` for production. + +![](https://colony-recorder.s3.amazonaws.com/files/2026-02-07/8b306d80-4943-4ad0-a51a-94b5ebdd6680/ascreenshot_5bb6e65c6428473fac2607f6a7f4b98a_text_export.jpeg) + +### 7. Add alerting emails + +Click the **Soft Budget Alerting Emails** field and enter one or more comma-separated email addresses that should receive the alert. + +![](https://colony-recorder.s3.amazonaws.com/files/2026-02-07/a97c6efa-cc93-45d7-979e-d2a533f423b9/ascreenshot_2d8223ce8e934aa1bfadfb2f78aee5fc_text_export.jpeg) + +### 8. Save Changes + +Click **Save Changes**. The soft budget alert is now active — no proxy restart required. + +![](https://colony-recorder.s3.amazonaws.com/files/2026-02-07/865ba6f1-3fc6-4c19-8e08-433561d6c3f7/ascreenshot_b2f0503ada3a479a83dc8b7d01c1f8da_text_export.jpeg) + +### 9. Verify: email alert received + +Once the team's spend crosses the soft budget, an email alert is sent to the configured recipients. Below is an example of the alert email: + + + +## Settings Reference + +| Setting | Description | +| ------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------- | +| **Soft Budget (USD)** | The spending threshold that triggers an email alert. Requests are **not** blocked when this limit is exceeded. | +| **Soft Budget Alerting Emails** | Comma-separated email addresses that receive the alert when the soft budget is crossed. At least one email is required for alerts to be sent. | + +:::tip Soft Budget vs. Max Budget + +- **Soft Budget**: Advisory threshold — sends email alerts but does **not** block requests. +- **Max Budget**: Hard limit — blocks requests once the budget is exceeded. + +You can set both on the same team to get early warnings (soft) and a hard stop (max). +::: + +## API Configuration + +You can also configure team soft budgets via the API when creating or updating a team: + +```bash +curl -X POST 'http://localhost:4000/team/update' \ + --header 'Authorization: Bearer sk-1234' \ + --header 'Content-Type: application/json' \ + --data '{ + "team_id": "your-team-id", + "soft_budget": 500.00, + "metadata": { + "soft_budget_alerting_emails": ["lead@example.com", "finance@example.com"] + } + }' +``` + +## Related Documentation + +- [Email Notifications](./email.md) – Configure email integrations (Resend, SMTP) for LiteLLM Proxy +- [Alerting](./alerting.md) – Set up Slack and other alerting channels +- [Cost Tracking](./cost_tracking.md) – Track and manage spend across teams, keys, and users diff --git a/docs/my-website/docs/proxy_auth.md b/docs/my-website/docs/proxy_auth.md new file mode 100644 index 00000000000..91084b34a37 --- /dev/null +++ b/docs/my-website/docs/proxy_auth.md @@ -0,0 +1,333 @@ +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; + +# SDK Proxy Authentication (OAuth2/JWT Auto-Refresh) + +Automatically obtain and refresh OAuth2/JWT tokens when using the LiteLLM Python SDK with a LiteLLM Proxy that requires JWT authentication. + +## Overview + +When your LiteLLM Proxy is protected by an OAuth2/OIDC provider (Azure AD, Keycloak, Okta, Auth0, etc.), your SDK clients need valid JWT tokens for every request. Instead of manually managing token lifecycle, `litellm.proxy_auth` handles this automatically: + +- Obtains tokens from your identity provider +- Caches tokens to avoid unnecessary requests +- Refreshes tokens before they expire (60-second buffer) +- Injects `Authorization: Bearer ` headers into every request + +## Quick Start + +### Azure AD + + + + +Uses the [DefaultAzureCredential](https://learn.microsoft.com/en-us/python/api/azure-identity/azure.identity.defaultazurecredential) chain (environment variables, managed identity, Azure CLI, etc.): + +```python +import litellm +from litellm.proxy_auth import AzureADCredential, ProxyAuthHandler + +# One-time setup +litellm.proxy_auth = ProxyAuthHandler( + credential=AzureADCredential(), # uses DefaultAzureCredential + scope="api://my-litellm-proxy/.default" +) +litellm.api_base = "https://my-proxy.example.com" + +# All requests now include Authorization headers automatically +response = litellm.completion( + model="gpt-4", + messages=[{"role": "user", "content": "Hello!"}] +) +``` + + + + +Use a specific Azure AD app registration: + +```python +import litellm +from azure.identity import ClientSecretCredential +from litellm.proxy_auth import AzureADCredential, ProxyAuthHandler + +azure_cred = ClientSecretCredential( + tenant_id="your-tenant-id", + client_id="your-client-id", + client_secret="your-client-secret" +) + +litellm.proxy_auth = ProxyAuthHandler( + credential=AzureADCredential(credential=azure_cred), + scope="api://my-litellm-proxy/.default" +) +litellm.api_base = "https://my-proxy.example.com" + +response = litellm.completion( + model="gpt-4", + messages=[{"role": "user", "content": "Hello!"}] +) +``` + + + + +**Required package:** `pip install azure-identity` + +### Generic OAuth2 (Okta, Auth0, Keycloak, etc.) + +Works with any OAuth2 provider that supports the `client_credentials` grant type: + +```python +import litellm +from litellm.proxy_auth import GenericOAuth2Credential, ProxyAuthHandler + +litellm.proxy_auth = ProxyAuthHandler( + credential=GenericOAuth2Credential( + client_id="your-client-id", + client_secret="your-client-secret", + token_url="https://your-idp.example.com/oauth2/token" + ), + scope="litellm_proxy_api" +) +litellm.api_base = "https://my-proxy.example.com" + +response = litellm.completion( + model="gpt-4", + messages=[{"role": "user", "content": "Hello!"}] +) +``` + +### Custom Credential Provider + +Implement the `TokenCredential` protocol to use any authentication mechanism: + +```python +import time +import litellm +from litellm.proxy_auth import AccessToken, ProxyAuthHandler + +class MyCustomCredential: + """Any class with a get_token(scope) -> AccessToken method works.""" + + def get_token(self, scope: str) -> AccessToken: + # Your custom logic to obtain a token + token = my_auth_system.get_jwt(scope=scope) + return AccessToken( + token=token, + expires_on=int(time.time()) + 3600 + ) + +litellm.proxy_auth = ProxyAuthHandler( + credential=MyCustomCredential(), + scope="my-scope" +) +``` + +## Supported Endpoints + +Auth headers are automatically injected for: + +| Endpoint | Function | +|----------|----------| +| Chat Completions | `litellm.completion()` / `litellm.acompletion()` | +| Embeddings | `litellm.embedding()` / `litellm.aembedding()` | + +## How It Works + +``` +┌──────────┐ ┌──────────────────┐ ┌──────────────┐ ┌──────────────┐ +│ Your │ │ ProxyAuthHandler │ │ Identity │ │ LiteLLM │ +│ Code │────▶│ (token cache) │────▶│ Provider │ │ Proxy │ +│ │ │ │◀────│ (Azure AD, │ │ │ +│ │ │ │ │ Okta, etc) │ │ │ +│ │ └────────┬─────────┘ └──────────────┘ │ │ +│ │ │ Authorization: Bearer │ │ +│ │──────────────┼───────────────────────────────────▶│ │ +│ │◀─────────────┼────────────────────────────────────│ │ +└──────────┘ │ └──────────────┘ +``` + +1. You set `litellm.proxy_auth` once at startup +2. On each SDK call (`completion()`, `embedding()`), the handler checks its cached token +3. If the token is missing or expires within 60 seconds, it requests a new one from your identity provider +4. The `Authorization: Bearer ` header is injected into the request +5. If token retrieval fails, a warning is logged and the request proceeds without auth headers + +## API Reference + +### ProxyAuthHandler + +The main handler that manages the token lifecycle. + +```python +from litellm.proxy_auth import ProxyAuthHandler + +handler = ProxyAuthHandler( + credential=, # required - credential provider + scope="" # required - OAuth2 scope to request +) +``` + +| Parameter | Type | Required | Description | +|-----------|------|----------|-------------| +| `credential` | `TokenCredential` | Yes | A credential provider (AzureADCredential, GenericOAuth2Credential, or custom) | +| `scope` | `str` | Yes | The OAuth2 scope to request tokens for | + +**Methods:** + +| Method | Returns | Description | +|--------|---------|-------------| +| `get_token()` | `AccessToken` | Get a valid token, refreshing if needed | +| `get_auth_headers()` | `dict` | Get `{"Authorization": "Bearer "}` headers | + +### AzureADCredential + +Wraps any `azure-identity` credential with lazy initialization. + +```python +from litellm.proxy_auth import AzureADCredential + +# Uses DefaultAzureCredential (recommended) +cred = AzureADCredential() + +# Or wrap a specific azure-identity credential +from azure.identity import ManagedIdentityCredential +cred = AzureADCredential(credential=ManagedIdentityCredential()) +``` + +| Parameter | Type | Required | Description | +|-----------|------|----------|-------------| +| `credential` | Azure `TokenCredential` | No | An azure-identity credential. If `None`, uses `DefaultAzureCredential` | + +### GenericOAuth2Credential + +Standard OAuth2 client credentials flow for any provider. + +```python +from litellm.proxy_auth import GenericOAuth2Credential + +cred = GenericOAuth2Credential( + client_id="your-client-id", + client_secret="your-client-secret", + token_url="https://your-idp.com/oauth2/token" +) +``` + +| Parameter | Type | Required | Description | +|-----------|------|----------|-------------| +| `client_id` | `str` | Yes | OAuth2 client ID | +| `client_secret` | `str` | Yes | OAuth2 client secret | +| `token_url` | `str` | Yes | Token endpoint URL | + +### AccessToken + +Dataclass representing an OAuth2 access token. + +```python +from litellm.proxy_auth import AccessToken + +token = AccessToken( + token="eyJhbG...", # JWT string + expires_on=1234567890 # Unix timestamp +) +``` + +### TokenCredential Protocol + +Any class implementing this protocol can be used as a credential provider: + +```python +from litellm.proxy_auth import AccessToken + +class MyCredential: + def get_token(self, scope: str) -> AccessToken: + ... +``` + +## Provider-Specific Examples + +### Keycloak + +```python +from litellm.proxy_auth import GenericOAuth2Credential, ProxyAuthHandler + +litellm.proxy_auth = ProxyAuthHandler( + credential=GenericOAuth2Credential( + client_id="litellm-client", + client_secret="your-keycloak-client-secret", + token_url="https://keycloak.example.com/realms/your-realm/protocol/openid-connect/token" + ), + scope="openid" +) +``` + +### Okta + +```python +from litellm.proxy_auth import GenericOAuth2Credential, ProxyAuthHandler + +litellm.proxy_auth = ProxyAuthHandler( + credential=GenericOAuth2Credential( + client_id="your-okta-client-id", + client_secret="your-okta-client-secret", + token_url="https://your-org.okta.com/oauth2/default/v1/token" + ), + scope="litellm_api" +) +``` + +### Auth0 + +```python +from litellm.proxy_auth import GenericOAuth2Credential, ProxyAuthHandler + +litellm.proxy_auth = ProxyAuthHandler( + credential=GenericOAuth2Credential( + client_id="your-auth0-client-id", + client_secret="your-auth0-client-secret", + token_url="https://your-tenant.auth0.com/oauth/token" + ), + scope="https://my-proxy.example.com/api" +) +``` + +### Azure AD with Managed Identity + +```python +from azure.identity import ManagedIdentityCredential +from litellm.proxy_auth import AzureADCredential, ProxyAuthHandler + +litellm.proxy_auth = ProxyAuthHandler( + credential=AzureADCredential( + credential=ManagedIdentityCredential() + ), + scope="api://my-litellm-proxy/.default" +) +``` + +## Combining with `use_litellm_proxy` + +You can use `proxy_auth` together with [`use_litellm_proxy`](./providers/litellm_proxy#send-all-sdk-requests-to-litellm-proxy) to route all SDK requests through an authenticated proxy: + +```python +import os +import litellm +from litellm.proxy_auth import AzureADCredential, ProxyAuthHandler + +# Route all requests through the proxy +os.environ["LITELLM_PROXY_API_BASE"] = "https://my-proxy.example.com" +litellm.use_litellm_proxy = True + +# Authenticate with OAuth2/JWT +litellm.proxy_auth = ProxyAuthHandler( + credential=AzureADCredential(), + scope="api://my-litellm-proxy/.default" +) + +# This request goes through the proxy with automatic JWT auth +response = litellm.completion( + model="vertex_ai/gemini-2.0-flash-001", + messages=[{"role": "user", "content": "Hello!"}] +) +``` diff --git a/docs/my-website/docs/troubleshoot.md b/docs/my-website/docs/troubleshoot.md index f9ed47972eb..179f1c7897c 100644 --- a/docs/my-website/docs/troubleshoot.md +++ b/docs/my-website/docs/troubleshoot.md @@ -45,6 +45,58 @@ Full error logs, stack traces, and any images from service metrics (CPU, memory, --- +## UI Issues + +If you're experiencing issues with the LiteLLM Admin UI, please include the following information in addition to the general details above. + +### 1. Steps to Reproduce + +A clear, step-by-step description of how to trigger the issue (e.g., "Navigate to Settings → Team, click 'Create Team', fill in fields, click submit → error appears"). + +### 2. LiteLLM Version + +The current version of LiteLLM you're running. Check via `litellm --version` or the UI's settings page. + +### 3. Architecture & Deployment Setup + +Distributed environments are a known source of UI issues. Please describe: + +- **Number of LiteLLM instances/replicas** and how they are deployed (e.g., Kubernetes, Docker Compose, ECS) +- **Load balancer** type and configuration (e.g., ALB, Nginx, Cloudflare Tunnel) — include whether sticky sessions are enabled +- **How the UI is accessed** — directly via LiteLLM, through a reverse proxy, or behind an ingress controller +- **Any CDN or caching layers** between the user and the LiteLLM server + +### 4. Network Tab Requests + +Open your browser's Developer Tools (F12 → Network tab), reproduce the issue, and share: + +- The **failing request(s)** — URL, method, status code, and response body +- **Screenshots or HAR export** of the relevant network activity +- Any **CORS or mixed-content errors** shown in the Console tab + +### 5. Environment Variables + +Non-sensitive environment variables related to the UI and proxy setup, such as: + +- `LITELLM_MASTER_KEY` +- `PROXY_BASE_URL` / `LITELLM_PROXY_BASE_URL` +- `UI_BASE_PATH` +- Any SSO-related variables (e.g., `GOOGLE_CLIENT_ID`, `MICROSOFT_TENANT`) + +Do **not** include passwords, secrets, or API keys. + +### 6. Browser & Access Details + +- **Browser** and version (e.g., Chrome 120, Firefox 121) +- **Access URL** used to reach the UI (redact sensitive parts) +- Whether the issue occurs for **all users or specific roles** (Admin, Internal User, etc.) + +### 7. Screenshots or Screen Recordings + +A screenshot or short screen recording of the issue is extremely helpful. Include any visible error messages, toasts, or unexpected behavior. + +--- + ## Support Channels [Schedule Demo 👋](https://calendly.com/d/4mp-gd3-k5k/berriai-1-1-onboarding-litellm-hosted-version) diff --git a/docs/my-website/docs/troubleshoot/max_callbacks.md b/docs/my-website/docs/troubleshoot/max_callbacks.md new file mode 100644 index 00000000000..4b0f3e24b73 --- /dev/null +++ b/docs/my-website/docs/troubleshoot/max_callbacks.md @@ -0,0 +1,68 @@ +# MAX_CALLBACKS Limit + +## Error Message + +``` +Cannot add callback - would exceed MAX_CALLBACKS limit of 30. Current callbacks: 30 +``` + +## What This Means + +LiteLLM limits the number of callbacks that can be registered to prevent performance degradation. Each callback runs on every LLM request, so having too many callbacks can cause exponential CPU usage and slow down your proxy. + +The default limit is **30 callbacks**. + +## When You Might Hit This Limit + +- **Large enterprise deployments** with many teams, each having their own guardrails +- **Multiple logging integrations** combined with custom callbacks +- **Per-team callback configurations** that add up across your organization + +## How to Override + +Set the `LITELLM_MAX_CALLBACKS` environment variable to increase the limit: + +```bash +# Docker +docker run -e LITELLM_MAX_CALLBACKS=100 ... + +# Docker Compose +environment: + - LITELLM_MAX_CALLBACKS=100 + +# Kubernetes +env: + - name: LITELLM_MAX_CALLBACKS + value: "100" + +# Direct +export LITELLM_MAX_CALLBACKS=100 +litellm --config config.yaml +``` + +## Recommendations + +1. **Start conservative** - Only increase as much as you need. If you have 60 teams with guardrails, try `LITELLM_MAX_CALLBACKS=75` to leave headroom. + +2. **Monitor performance** - More callbacks means more processing per request. Watch your CPU usage and response latency after increasing the limit. + +3. **Consolidate where possible** - If multiple teams use identical guardrails, consider using shared callback configurations rather than per-team duplicates. + +## Example: Large Enterprise Setup + +For an organization with 60+ teams, each with a guardrail callback: + +```yaml +# config.yaml +litellm_settings: + callbacks: ["prometheus", "langfuse"] # 2 global callbacks + +# Each team adds 1 guardrail callback = 60+ callbacks +# Total: 62+ callbacks needed +``` + +Set the environment variable: + +```bash +export LITELLM_MAX_CALLBACKS=100 +``` diff --git a/docs/my-website/docs/tutorials/claude_code_beta_headers.md b/docs/my-website/docs/tutorials/claude_code_beta_headers.md new file mode 100644 index 00000000000..4cc6f7ff92b --- /dev/null +++ b/docs/my-website/docs/tutorials/claude_code_beta_headers.md @@ -0,0 +1,230 @@ +import Image from '@theme/IdealImage'; + +# Claude Code - Managing Anthropic Beta Headers + +When using Claude Code with LiteLLM and non-Anthropic providers (Bedrock, Azure AI, Vertex AI), you need to ensure that only supported beta headers are sent to each provider. This guide explains how to add support for new beta headers or fix invalid beta header errors. + +## What Are Beta Headers? + +Anthropic uses beta headers to enable experimental features in Claude. When you use Claude Code, it may send beta headers like: + +``` +anthropic-beta: prompt-caching-scope-2026-01-05,advanced-tool-use-2025-11-20 +``` + +However, not all providers support all Anthropic beta features. LiteLLM uses `anthropic_beta_headers_config.json` to manage which beta headers are supported by each provider. + +## Common Error Message + +```bash +Error: The model returned the following errors: invalid beta flag +``` + +## How LiteLLM Handles Beta Headers + +LiteLLM uses a strict validation approach with a configuration file: + +``` +litellm/litellm/anthropic_beta_headers_config.json +``` + +This JSON file contains a **mapping** of beta headers for each provider: +- **Keys**: Input beta header names (from Anthropic) +- **Values**: Provider-specific header names (or `null` if unsupported) +- **Validation**: Only headers present in the mapping with non-null values are forwarded + +This enforces stricter validation than just filtering unsupported headers - headers must be explicitly defined to be allowed. + +## Adding Support for a New Beta Header + +When Anthropic releases a new beta feature, you need to add it to the configuration file for each provider. + +### Step 1: Locate the Config File + +Find the file in your LiteLLM installation: + +```bash +# If installed via pip +cd $(python -c "import litellm; import os; print(os.path.dirname(litellm.__file__))") + +# The config file is at: +# litellm/anthropic_beta_headers_config.json +``` + +### Step 2: Add the New Beta Header + +Open `anthropic_beta_headers_config.json` and add the new header to each provider's mapping: + +```json title="anthropic_beta_headers_config.json" +{ + "description": "Mapping of Anthropic beta headers for each provider. Keys are input header names, values are provider-specific header names (or null if unsupported). Only headers present in mapping keys with non-null values can be forwarded.", + "anthropic": { + "advanced-tool-use-2025-11-20": "advanced-tool-use-2025-11-20", + "new-feature-2026-03-01": "new-feature-2026-03-01", + ... + }, + "azure_ai": { + "advanced-tool-use-2025-11-20": "advanced-tool-use-2025-11-20", + "new-feature-2026-03-01": "new-feature-2026-03-01", + ... + }, + "bedrock_converse": { + "advanced-tool-use-2025-11-20": "tool-search-tool-2025-10-19", + "new-feature-2026-03-01": null, + ... + }, + "bedrock": { + "advanced-tool-use-2025-11-20": "tool-search-tool-2025-10-19", + "new-feature-2026-03-01": null, + ... + }, + "vertex_ai": { + "advanced-tool-use-2025-11-20": "tool-search-tool-2025-10-19", + "new-feature-2026-03-01": null, + ... + } +} +``` + +**Key Points:** +- **Supported headers**: Set the value to the provider-specific header name (often the same as the key) +- **Unsupported headers**: Set the value to `null` +- **Header transformations**: Some providers use different header names (e.g., Bedrock maps `advanced-tool-use-2025-11-20` to `tool-search-tool-2025-10-19`) +- **Alphabetical order**: Keep headers sorted alphabetically for maintainability + +### Step 3: Restart Your Application + +After updating the config file, restart your LiteLLM proxy or application: + +```bash +# If using LiteLLM proxy +litellm --config config.yaml + +# If using Python SDK +# Just restart your Python application +``` + +The updated configuration will be loaded automatically. + +## Fixing Invalid Beta Header Errors + +If you encounter an "invalid beta flag" error, it means a beta header is being sent that the provider doesn't support. + +### Step 1: Identify the Problematic Header + +Check your logs to see which header is causing the issue: + +```bash +Error: The model returned the following errors: invalid beta flag: new-feature-2026-03-01 +``` + +### Step 2: Update the Config + +Set the header value to `null` for that provider: + +```json title="anthropic_beta_headers_config.json" +{ + "bedrock_converse": { + "new-feature-2026-03-01": null + } +} +``` + +### Step 3: Restart and Test + +Restart your application and verify the header is now filtered out. + +## Contributing a Fix to LiteLLM + +Help the community by contributing your fix! + +### What to Include in Your PR + +1. **Update the config file**: Add the new beta header to `litellm/anthropic_beta_headers_config.json` +2. **Test your changes**: Verify the header is correctly filtered/mapped for each provider +3. **Documentation**: Include provider documentation links showing which headers are supported + +### Example PR Description + +```markdown +## Add support for new-feature-2026-03-01 beta header + +### Changes +- Added `new-feature-2026-03-01` to anthropic_beta_headers_config.json +- Set to `null` for bedrock_converse (unsupported) +- Set to header name for anthropic, azure_ai (supported) + +### Testing +Tested with: +- ✅ Anthropic: Header passed through correctly +- ✅ Azure AI: Header passed through correctly +- ✅ Bedrock Converse: Header filtered out (returns error without fix) + +### References +- Anthropic docs: [link] +- AWS Bedrock docs: [link] +``` + + +## How Beta Header Filtering Works + +When you make a request through LiteLLM: + +```mermaid +sequenceDiagram + participant CC as Claude Code + participant LP as LiteLLM + participant Config as Beta Headers Config + participant Provider as Provider (Bedrock/Azure/etc) + + CC->>LP: Request with beta headers + Note over CC,LP: anthropic-beta: header1,header2,header3 + + LP->>Config: Load header mapping for provider + Config-->>LP: Returns mapping (header→value or null) + + Note over LP: Validate & Transform:
1. Check if header exists in mapping
2. Filter out null values
3. Map to provider-specific names + + LP->>Provider: Request with filtered & mapped headers + Note over LP,Provider: anthropic-beta: mapped-header2
(header1, header3 filtered out) + + Provider-->>LP: Success response + LP-->>CC: Response +``` + +### Filtering Rules + +1. **Header must exist in mapping**: Unknown headers are filtered out +2. **Header must have non-null value**: Headers with `null` values are filtered out +3. **Header transformation**: Headers are mapped to provider-specific names (e.g., `advanced-tool-use-2025-11-20` → `tool-search-tool-2025-10-19` for Bedrock) + +### Example + +Request with headers: +``` +anthropic-beta: advanced-tool-use-2025-11-20,computer-use-2025-01-24,unknown-header +``` + +For Bedrock Converse: +- ✅ `computer-use-2025-01-24` → `computer-use-2025-01-24` (supported, passed through) +- ❌ `advanced-tool-use-2025-11-20` → filtered out (null value in config) +- ❌ `unknown-header` → filtered out (not in config) + +Result sent to Bedrock: +``` +anthropic-beta: computer-use-2025-01-24 +``` + +## Provider-Specific Notes + +### Bedrock +- Beta headers appear in both HTTP headers AND request body (`additionalModelRequestFields.anthropic_beta`) +- Some headers are transformed (e.g., `advanced-tool-use` → `tool-search-tool`) + +### Azure AI +- Uses same header names as Anthropic +- Some features not yet supported (check config for null values) + +### Vertex AI +- Some headers are transformed to match Vertex AI's implementation +- Limited beta feature support compared to Anthropic \ No newline at end of file diff --git a/docs/my-website/docs/tutorials/claude_code_prompt_cache_routing.md b/docs/my-website/docs/tutorials/claude_code_prompt_cache_routing.md new file mode 100644 index 00000000000..bbb29489856 --- /dev/null +++ b/docs/my-website/docs/tutorials/claude_code_prompt_cache_routing.md @@ -0,0 +1,43 @@ +# Claude Code - Prompt Cache Routing + +Claude's [Prompt Caching](https://platform.claude.com/docs/en/build-with-claude/prompt-caching) feature helps to optimize API usage through attempting to cache prompts and re-use cached prompts during subsequent API calls. This feature is used by Claude Code. + +When LiteLLM [load balancing](../proxy/load_balancing.md) is enabled, to ensure this prompt caching feature still works with Claude Code, LiteLLM needs to be configured to use the `PromptCachingDeploymentCheck` pre-call check. This pre-call check will ensure that API calls that used prompt caching are remembered and that subsequent API calls that try to use that prompt caching are routed to the same model deployment where a cache write occurred. + +## Set Up + +1. Configure the router so that it uses the `PromptCachingDeploymentCheck` (via setting the `optional_pre_call_checks` property), and configure the models so that they can access multiple deployments of Claude; below, we show an example for multiple AWS accounts (referred to as `account-1` and `account-2`, using the `aws_profile_name` property): +```yaml +router_settings: + optional_pre_call_checks: ["prompt_caching"] + +model_list: +- litellm_params: + model: us.anthropic.claude-sonnet-4-5-20250929-v1:0 + aws_profile_name: account-1 + aws_region_name: us-west-2 + model_info: + litellm_provider: bedrock + model_name: us.anthropic.claude-sonnet-4-5-20250929-v1:0 +- litellm_params: + model: us.anthropic.claude-sonnet-4-5-20250929-v1:0 + aws_profile_name: account-2 + aws_region_name: us-west-2 + model_info: + litellm_provider: bedrock + model_name: us.anthropic.claude-sonnet-4-5-20250929-v1:0 +``` +2. Utilize Claude Code: + 1. Launch Claude Code, which will do a warm-up API call that tries to cache its warm-up prompt and its system prompt. + 2. Wait a few seconds, then quit Claude Code and re-open it. + 3. You'll notice that the warm-up API call successfully gets a cache hit (if using Claude Code in an IDE like VS Code, ensure that you don't do anything between step 2.1 and 2.2 here, otherwise there may not be a cache hit): + 1. Go to the [LiteLLM Request Logs page](../proxy/ui_logs.md) in the Admin UI + 2. Click on the individual requests to see (a) the cache creation and cache read tokens; and (b) the Model ID. In particular, the API call from step 2.1 should show a cache write, and the API call from step 2.2 should show a cache read; in addition, the Model ID should be equal (meaning the API call is getting forwarded to the same AWS account). + +## Related + +- [Claude Code - Quickstart](./claude_responses_api.md) +- [Claude Code - Customer Tracking](./claude_code_customer_tracking.md) +- [Claude Code - Plugin Marketplace](./claude_code_plugin_marketplace.md) +- [Claude Code - WebSearch](./claude_code_websearch.md) +- [Proxy - Load Balancing](../proxy/load_balancing.md) diff --git a/docs/my-website/img/policy_team_attach.png b/docs/my-website/img/policy_team_attach.png new file mode 100644 index 00000000000..4e337931ed8 Binary files /dev/null and b/docs/my-website/img/policy_team_attach.png differ diff --git a/docs/my-website/img/policy_test_matching.png b/docs/my-website/img/policy_test_matching.png new file mode 100644 index 00000000000..5d024ae78b4 Binary files /dev/null and b/docs/my-website/img/policy_test_matching.png differ diff --git a/docs/my-website/img/release_notes/mcp_internet.png b/docs/my-website/img/release_notes/mcp_internet.png new file mode 100644 index 00000000000..d24d2a20870 Binary files /dev/null and b/docs/my-website/img/release_notes/mcp_internet.png differ diff --git a/docs/my-website/img/ui_team_soft_budget_alerts.png b/docs/my-website/img/ui_team_soft_budget_alerts.png new file mode 100644 index 00000000000..9627b5f1daa Binary files /dev/null and b/docs/my-website/img/ui_team_soft_budget_alerts.png differ diff --git a/docs/my-website/img/ui_team_soft_budget_email_example.png b/docs/my-website/img/ui_team_soft_budget_email_example.png new file mode 100644 index 00000000000..0cd83487112 Binary files /dev/null and b/docs/my-website/img/ui_team_soft_budget_email_example.png differ diff --git a/docs/my-website/package.json b/docs/my-website/package.json index 4c3db680565..4af7a168f83 100644 --- a/docs/my-website/package.json +++ b/docs/my-website/package.json @@ -61,6 +61,8 @@ "mermaid": ">=11.10.0", "gray-matter": "4.0.3", "glob": ">=11.1.0", + "tar": ">=7.5.7", + "@isaacs/brace-expansion": ">=5.0.1", "node-forge": ">=1.3.2", "mdast-util-to-hast": ">=13.2.1", "lodash-es": ">=4.17.23" diff --git a/docs/my-website/release_notes/v1.81.3-stable/index.md b/docs/my-website/release_notes/v1.81.3-stable/index.md index 22b6f43deef..c4b9013590c 100644 --- a/docs/my-website/release_notes/v1.81.3-stable/index.md +++ b/docs/my-website/release_notes/v1.81.3-stable/index.md @@ -27,7 +27,7 @@ import TabItem from '@theme/TabItem'; docker run \ -e STORE_MODEL_IN_DB=True \ -p 4000:4000 \ -docker.litellm.ai/berriai/litellm:v1.81.3.rc.2 +docker.litellm.ai/berriai/litellm:v1.81.3-stable ``` diff --git a/docs/my-website/release_notes/v1.81.6.md b/docs/my-website/release_notes/v1.81.6.md index ef19276f2cf..d349afa65f9 100644 --- a/docs/my-website/release_notes/v1.81.6.md +++ b/docs/my-website/release_notes/v1.81.6.md @@ -1,5 +1,5 @@ --- -title: "v1.81.6 - Logs v2 with Tool Call Tracing" +title: "[Preview] v1.81.6 - Logs v2 with Tool Call Tracing" slug: "v1-81-6" date: 2026-01-31T00:00:00 authors: diff --git a/docs/my-website/release_notes/v1.81.9.md b/docs/my-website/release_notes/v1.81.9.md new file mode 100644 index 00000000000..c34d3056cae --- /dev/null +++ b/docs/my-website/release_notes/v1.81.9.md @@ -0,0 +1,372 @@ +--- +title: "[Preview] v1.81.9 - Control which MCP Servers are exposed on the Internet" +slug: "v1-81-9" +date: 2026-02-07T00:00:00 +authors: + - name: Krrish Dholakia + title: CEO, LiteLLM + url: https://www.linkedin.com/in/krish-d/ + image_url: https://pbs.twimg.com/profile_images/1298587542745358340/DZv3Oj-h_400x400.jpg + - name: Ishaan Jaff + title: CTO, LiteLLM + url: https://www.linkedin.com/in/reffajnaahsi/ + image_url: https://pbs.twimg.com/profile_images/1613813310264340481/lz54oEiB_400x400.jpg +hide_table_of_contents: false +--- + +## Deploy this version + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; +import Image from '@theme/IdealImage'; + + + + +``` showLineNumbers title="docker run litellm" +docker run \ +-e STORE_MODEL_IN_DB=True \ +-p 4000:4000 \ +ghcr.io/berriai/litellm:main-v1.81.9.rc.1 +``` + + + + +``` showLineNumbers title="pip install litellm" +pip install litellm==1.81.9 +``` + + + + +## Key Highlights + +- **Claude Opus 4.6** - [Full support across Anthropic, AWS Bedrock, Azure AI, and Vertex AI with adaptive thinking and 1M context window](../../blog/claude_opus_4_6) +- **A2A Agent Gateway** - [Call A2A (Agent-to-Agent) registered agents through the standard `/chat/completions` API](../../docs/a2a_invoking_agents) +- **Expose MCP servers on the public internet** - [Launch MCP servers with public/private visibility and IP-based access control for internet-facing deployments](../../docs/mcp_public_internet) +- **UI Team Soft Budget Alerts** - [Set soft budgets on teams and receive email alerts when spending crosses the threshold — without blocking requests](../../docs/proxy/ui_team_soft_budget_alerts) +- **Performance Optimizations** - Multiple performance improvements including ~40% Prometheus CPU reduction, LRU caching, and optimized logging paths +- **LiteLLM Observatory** - [Automated 24-hour load tests](../../blog/litellm-observatory) +- **30% Faster Request Processing for Callback-Heavy Deployments** - [Performance improvement for callback heavy deployments][PR #20354](https://github.com/BerriAI/litellm/pull/20354) + +--- + +## 30% Faster Request Processing for Callback-Heavy Deployments + + If you use logging callbacks like Langfuse, Datadog, or Prometheus, every request was paying an unnecessary cost: three loops that re-sorted your callbacks on every single request, even though the callback list hadn't changed. The more callbacks you had configured, the more time was wasted. We moved this work to happen once at startup instead of on every request. For deployments with the default callback set, this is a ~30% speedup in request setup. For deployments with many callbacks configured, the improvement is even larger. + +--- + +## LiteLLM Observatory + +LiteLLM Observatory is a long-running release-validation system we built to catch regressions before they reach users. The system is built to be extensible—you can add new tests, configure models and failure thresholds, and queue runs against any deployment. Our goal is to achieve 100% coverage of LiteLLM functionality through these tests. We run 24-hour load tests against our production deployments before all releases, surfacing issues like resource lifecycle bugs, OOMs, and CPU regressions that only appear under sustained load. + +--- + +## MCP Servers on the Public Internet + +This release makes it safe to expose MCP servers on the public internet by adding public/private visibility and IP-based access control. You can now run internet-facing MCP services while restricting access to trusted networks and keeping internal tools private. + +[Get started](../../docs/mcp_public_internet) + + + +## UI Team Soft Budget Alerts + +Set a soft budget on any team to receive email alerts when spending crosses the threshold — without blocking any requests. Configure the threshold and alerting emails directly from the Admin UI, with no proxy restart needed. + +[Get started](../../docs/proxy/ui_team_soft_budget_alerts) + + + +Let's dive in. + +--- + +## New Models / Updated Models + +#### New Model Support (13 new models) + +| Provider | Model | Context Window | Input ($/1M tokens) | Output ($/1M tokens) | +| -------- | ----- | -------------- | ------------------- | -------------------- | +| Anthropic | `claude-opus-4-6` | 1M | $5.00 | $25.00 | +| AWS Bedrock | `anthropic.claude-opus-4-6-v1` | 1M | $5.00 | $25.00 | +| Azure AI | `azure_ai/claude-opus-4-6` | 200K | $5.00 | $25.00 | +| Vertex AI | `vertex_ai/claude-opus-4-6` | 1M | $5.00 | $25.00 | +| Google Gemini | `gemini/deep-research-pro-preview-12-2025` | 65K | $2.00 | $12.00 | +| Vertex AI | `vertex_ai/deep-research-pro-preview-12-2025` | 65K | $2.00 | $12.00 | +| Moonshot | `moonshot/kimi-k2.5` | 262K | $0.60 | $3.00 | +| OpenRouter | `openrouter/qwen/qwen3-235b-a22b-2507` | 262K | $0.07 | $0.10 | +| OpenRouter | `openrouter/qwen/qwen3-235b-a22b-thinking-2507` | 262K | $0.11 | $0.60 | +| Together AI | `together_ai/zai-org/GLM-4.7` | 200K | $0.45 | $2.00 | +| Together AI | `together_ai/moonshotai/Kimi-K2.5` | 256K | $0.50 | $2.80 | +| ElevenLabs | `elevenlabs/eleven_v3` | - | $0.18/1K chars | - | +| ElevenLabs | `elevenlabs/eleven_multilingual_v2` | - | $0.18/1K chars | - | + +#### Features + +- **[Anthropic](../../docs/providers/anthropic)** + - Full Claude Opus 4.6 support with adaptive thinking across all regions (us, eu, apac, au) - [PR #20506](https://github.com/BerriAI/litellm/pull/20506), [PR #20508](https://github.com/BerriAI/litellm/pull/20508), [PR #20514](https://github.com/BerriAI/litellm/pull/20514), [PR #20551](https://github.com/BerriAI/litellm/pull/20551) + - Map reasoning content to anthropic thinking block (streaming + non-streaming) - [PR #20254](https://github.com/BerriAI/litellm/pull/20254) + +- **[AWS Bedrock](../../docs/providers/bedrock)** + - Add 1hr tiered caching costs for long-context models - [PR #20214](https://github.com/BerriAI/litellm/pull/20214) + - Support TTL (1h) field in prompt caching for Bedrock Claude 4.5 models - [PR #20338](https://github.com/BerriAI/litellm/pull/20338) + - Add Nova Sonic speech-to-speech model support - [PR #20244](https://github.com/BerriAI/litellm/pull/20244) + - Fix empty assistant message for Converse API - [PR #20390](https://github.com/BerriAI/litellm/pull/20390) + - Fix content blocked handling - [PR #20606](https://github.com/BerriAI/litellm/pull/20606) + +- **[Google Gemini / Vertex AI](../../docs/providers/gemini)** + - Add Gemini Deep Research model support - [PR #20406](https://github.com/BerriAI/litellm/pull/20406) + - Fix Vertex AI Gemini streaming content_filter handling - [PR #20105](https://github.com/BerriAI/litellm/pull/20105) + - Allow using OpenAI-style tools for `web_search` with Vertex AI/Gemini models - [PR #20280](https://github.com/BerriAI/litellm/pull/20280) + - Fix `supports_native_streaming` for Gemini and Vertex AI models - [PR #20408](https://github.com/BerriAI/litellm/pull/20408) + - Add mapping for responses tools in file IDs - [PR #20402](https://github.com/BerriAI/litellm/pull/20402) + +- **[Cohere](../../docs/providers/cohere)** + - Support `dimensions` param for Cohere embed v4 - [PR #20235](https://github.com/BerriAI/litellm/pull/20235) + +- **[Cerebras](../../docs/providers/cerebras)** + - Add reasoning param support for GPT OSS Cerebras - [PR #20258](https://github.com/BerriAI/litellm/pull/20258) + +- **[Moonshot](../../docs/providers/moonshot)** + - Add Kimi K2.5 model entries - [PR #20273](https://github.com/BerriAI/litellm/pull/20273) + +- **[OpenRouter](../../docs/providers/openrouter)** + - Add Qwen3-235B models - [PR #20455](https://github.com/BerriAI/litellm/pull/20455) + +- **[Together AI](../../docs/providers/togetherai)** + - Add GLM-4.7 and Kimi-K2.5 models - [PR #20319](https://github.com/BerriAI/litellm/pull/20319) + +- **[ElevenLabs](../../docs/providers/elevenlabs)** + - Add `eleven_v3` and `eleven_multilingual_v2` TTS models - [PR #20522](https://github.com/BerriAI/litellm/pull/20522) + +- **[Vercel AI Gateway](../../docs/providers/vercel_ai_gateway)** + - Add missing capability flags to models - [PR #20276](https://github.com/BerriAI/litellm/pull/20276) + +- **[GitHub Copilot](../../docs/providers/github_copilot)** + - Fix system prompts being dropped and auto-add required Copilot headers - [PR #20113](https://github.com/BerriAI/litellm/pull/20113) + +- **[GigaChat](../../docs/providers/gigachat)** + - Fix incorrect merging of consecutive user messages for GigaChat provider - [PR #20341](https://github.com/BerriAI/litellm/pull/20341) + +- **[xAI](../../docs/providers/xai_realtime)** + - Add xAI `/realtime` API support - works with LiveKit SDK - [PR #20381](https://github.com/BerriAI/litellm/pull/20381) + +- **[OpenAI](../../docs/providers/openai)** + - Add `gpt-5-search-api` model and docs clarifications - [PR #20512](https://github.com/BerriAI/litellm/pull/20512) + +### Bug Fixes + +- **[Anthropic](../../docs/providers/anthropic)** + - Fix extra inputs not permitted error for `provider_specific_fields` - [PR #20334](https://github.com/BerriAI/litellm/pull/20334) + +- **[AWS Bedrock](../../docs/providers/bedrock)** + - Fix: Managed Batches inconsistent state management for list and cancel batches - [PR #20331](https://github.com/BerriAI/litellm/pull/20331) + +- **[OpenAI Embeddings](../../docs/providers/openai)** + - Fix `open_ai_embedding_models` to have `custom_llm_provider` None - [PR #20253](https://github.com/BerriAI/litellm/pull/20253) + +--- + +## LLM API Endpoints + +#### Features + +- **[Messages API](../../docs/providers/anthropic)** + - Filter unsupported Claude Code beta headers for non-Anthropic providers - [PR #20578](https://github.com/BerriAI/litellm/pull/20578) + - Fix inconsistent response format in `anthropic.messages.acreate()` when using non-Anthropic providers - [PR #20442](https://github.com/BerriAI/litellm/pull/20442) + - Fix 404 on `/api/event_logging/batch` endpoint that caused Claude Code "route not found" errors - [PR #20504](https://github.com/BerriAI/litellm/pull/20504) + +- **[A2A Agent Gateway](../../docs/a2a)** + - Allow calling A2A agents through LiteLLM `/chat/completions` API - [PR #20358](https://github.com/BerriAI/litellm/pull/20358) + - Use A2A registered agents with `/chat/completions` - [PR #20362](https://github.com/BerriAI/litellm/pull/20362) + - Fix A2A agents deployed with localhost/internal URLs in their agent cards - [PR #20604](https://github.com/BerriAI/litellm/pull/20604) + +- **[Files API](../../docs/providers/gemini)** + - Add support for delete and GET via file_id for Gemini - [PR #20329](https://github.com/BerriAI/litellm/pull/20329) + +- **General** + - Add User-Agent customization support - [PR #19881](https://github.com/BerriAI/litellm/pull/19881) + - Fix search tools not found when using per-request routers - [PR #19818](https://github.com/BerriAI/litellm/pull/19818) + - Forward extra headers in chat - [PR #20386](https://github.com/BerriAI/litellm/pull/20386) + +--- + +## Management Endpoints / UI + +#### Features + +- **SSO Configuration** + - SSO Config Team Mappings - [PR #20111](https://github.com/BerriAI/litellm/pull/20111) + - UI - SSO: Add Team Mappings - [PR #20299](https://github.com/BerriAI/litellm/pull/20299) + - Extract user roles from JWT access token for Keycloak compatibility - [PR #20591](https://github.com/BerriAI/litellm/pull/20591) + +- **Auth / SDK** + - Add `proxy_auth` for auto OAuth2/JWT token management in SDK - [PR #20238](https://github.com/BerriAI/litellm/pull/20238) + +- **Virtual Keys** + - Key `reset_spend` endpoint - [PR #20305](https://github.com/BerriAI/litellm/pull/20305) + - UI - Keys: Allowed Routes to Key Info and Edit Pages - [PR #20369](https://github.com/BerriAI/litellm/pull/20369) + - Add Key info endpoint object permission data - [PR #20407](https://github.com/BerriAI/litellm/pull/20407) + - Keys and Teams Router Setting + Allow Override of Router Settings - [PR #20205](https://github.com/BerriAI/litellm/pull/20205) + +- **Teams & Budgets** + - Add `soft_budget` to Team Table + Create/Update Endpoints - [PR #20530](https://github.com/BerriAI/litellm/pull/20530) + - Team Soft Budget Email Alerts - [PR #20553](https://github.com/BerriAI/litellm/pull/20553) + - UI - Team Settings: Soft Budget + Alerting Emails - [PR #20634](https://github.com/BerriAI/litellm/pull/20634) + - UI - User Budget Page: Unlimited Budget Checkbox - [PR #20380](https://github.com/BerriAI/litellm/pull/20380) + - `/user/update` allow for `max_budget` resets - [PR #20375](https://github.com/BerriAI/litellm/pull/20375) + +- **UI Improvements** + - Default Team Settings: Migrate to use Reusable Model Select - [PR #20310](https://github.com/BerriAI/litellm/pull/20310) + - Navbar: Option to Hide Community Engagement Buttons - [PR #20308](https://github.com/BerriAI/litellm/pull/20308) + - Show team alias on Models health page - [PR #20359](https://github.com/BerriAI/litellm/pull/20359) + - Admin Settings: Add option for Authentication for public AI Hub - [PR #20444](https://github.com/BerriAI/litellm/pull/20444) + - Adjust daily spend date filtering for user timezone - [PR #20472](https://github.com/BerriAI/litellm/pull/20472) + +- **SCIM** + - Add base `/scim/v2` endpoint for SCIM resource discovery - [PR #20301](https://github.com/BerriAI/litellm/pull/20301) + +- **Proxy CLI** + - CLI arguments for RDS IAM auth - [PR #20437](https://github.com/BerriAI/litellm/pull/20437) + +#### Bugs + +- Fix: Remove unnecessary key blocking on UI login that prevented access - [PR #20210](https://github.com/BerriAI/litellm/pull/20210) +- UI - Team Settings: Disable Global Guardrail Persistence - [PR #20307](https://github.com/BerriAI/litellm/pull/20307) +- UI - Model Info Page: Fix Input and Output Labels - [PR #20462](https://github.com/BerriAI/litellm/pull/20462) +- UI - Model Page: Column Resizing on Smaller Screens - [PR #20599](https://github.com/BerriAI/litellm/pull/20599) +- Fix `/key/list` `user_id` Empty String Edge Case - [PR #20623](https://github.com/BerriAI/litellm/pull/20623) +- Add array type checks for model, agent, and MCP hub data to prevent UI crashes - [PR #20469](https://github.com/BerriAI/litellm/pull/20469) +- Fix unique constraint on daily tables + logging when updates fail - [PR #20394](https://github.com/BerriAI/litellm/pull/20394) + +--- + +## Logging / Guardrail / Prompt Management Integrations + +#### Bug Fixes (3 fixes) + +- **[Langfuse](../../docs/proxy/logging#langfuse)** + - Fix Langfuse OTEL trace export failing when spans contain null attributes - [PR #20382](https://github.com/BerriAI/litellm/pull/20382) + +- **[Prometheus](../../docs/proxy/logging#prometheus)** + - Fix incorrect failure metrics labels causing miscounted error rates - [PR #20152](https://github.com/BerriAI/litellm/pull/20152) + +- **[Slack Alerts](../../docs/proxy/alerting)** + - Fix Slack alert delivery failing for certain budget threshold configurations - [PR #20257](https://github.com/BerriAI/litellm/pull/20257) + +#### Guardrails (7 updates) + +- **Custom Code Guardrails** + - Add HTTP support to custom code guardrails + Unified guardrails for MCP + Agent guardrail support - [PR #20619](https://github.com/BerriAI/litellm/pull/20619) + - Custom Code Guardrails UI Playground - [PR #20377](https://github.com/BerriAI/litellm/pull/20377) + +- **Team-Based Guardrails** + - Implement team-based isolation guardrails management - [PR #20318](https://github.com/BerriAI/litellm/pull/20318) + +- **[OpenAI Moderations](../../docs/apply_guardrail)** + - Ensure OpenAI Moderations Guard works with OpenAI Embeddings - [PR #20523](https://github.com/BerriAI/litellm/pull/20523) + +- **[GraySwan / Cygnal](../../docs/apply_guardrail)** + - Fix fail-open for GraySwan and pass metadata to Cygnal API endpoint - [PR #19837](https://github.com/BerriAI/litellm/pull/19837) + +- **General** + - Check for `model_response_choices` before guardrail input - [PR #19784](https://github.com/BerriAI/litellm/pull/19784) + - Preserve streaming content on guardrail-sampled chunks - [PR #20027](https://github.com/BerriAI/litellm/pull/20027) + +--- + +## Spend Tracking, Budgets and Rate Limiting + +- **Support 0 cost models** - Allow zero-cost model entries for internal/free-tier models - [PR #20249](https://github.com/BerriAI/litellm/pull/20249) + +--- + +## MCP Gateway (9 updates) + +- **MCP Semantic Filtering** - Filter MCP tools using semantic similarity to reduce tool sprawl for LLM calls - [PR #20296](https://github.com/BerriAI/litellm/pull/20296), [PR #20316](https://github.com/BerriAI/litellm/pull/20316) +- **UI - MCP Semantic Filtering** - Add support for MCP Semantic Filtering configuration on UI - [PR #20454](https://github.com/BerriAI/litellm/pull/20454) +- **MCP IP-Based Access Control** - Set MCP servers as private/public available on internet with IP-based restrictions - [PR #20607](https://github.com/BerriAI/litellm/pull/20607), [PR #20620](https://github.com/BerriAI/litellm/pull/20620) +- **Fix MCP "Session not found" error** on VSCode reconnect - [PR #20298](https://github.com/BerriAI/litellm/pull/20298) +- **Fix OAuth2 'Capabilities: none' bug** for upstream MCP servers - [PR #20602](https://github.com/BerriAI/litellm/pull/20602) +- **Include Config Defined Search Tools** in `/search_tools/list` - [PR #20371](https://github.com/BerriAI/litellm/pull/20371) +- **UI - Search Tools**: Show Config Defined Search Tools - [PR #20436](https://github.com/BerriAI/litellm/pull/20436) +- **Ensure MCP permissions are enforced** when using JWT Auth - [PR #20383](https://github.com/BerriAI/litellm/pull/20383) +- **Fix `gcs_bucket_name` not being passed** correctly for MCP server storage configuration - [PR #20491](https://github.com/BerriAI/litellm/pull/20491) + +--- + +## Performance / Loadbalancing / Reliability improvements (14 improvements) + +- **Prometheus ~40% CPU reduction** - Parallelize budget metrics, fix caching bug, reduce CPU usage - [PR #20544](https://github.com/BerriAI/litellm/pull/20544) +- **Prevent closed client errors** by reverting httpx client caching - [PR #20025](https://github.com/BerriAI/litellm/pull/20025) +- **Avoid unnecessary Router creation** when no models or search tools are configured - [PR #20661](https://github.com/BerriAI/litellm/pull/20661) +- **Optimize `wrapper_async`** with `CallTypes` caching and reduced lookups - [PR #20204](https://github.com/BerriAI/litellm/pull/20204) +- **Cache `_get_relevant_args_to_use_for_logging()`** at module level - [PR #20077](https://github.com/BerriAI/litellm/pull/20077) +- **LRU cache for `normalize_request_route`** - [PR #19812](https://github.com/BerriAI/litellm/pull/19812) +- **Optimize `get_standard_logging_metadata`** with set intersection - [PR #19685](https://github.com/BerriAI/litellm/pull/19685) +- **Early-exit guards in `completion_cost`** for unused features - [PR #20020](https://github.com/BerriAI/litellm/pull/20020) +- **Optimize `get_litellm_params`** with sparse kwargs extraction - [PR #19884](https://github.com/BerriAI/litellm/pull/19884) +- **Guard debug log f-strings** and remove redundant dict copies - [PR #19961](https://github.com/BerriAI/litellm/pull/19961) +- **Replace enum construction with frozenset lookup** - [PR #20302](https://github.com/BerriAI/litellm/pull/20302) +- **Guard debug f-string in `update_environment_variables`** - [PR #20360](https://github.com/BerriAI/litellm/pull/20360) +- **Warn when budget lookup fails** to surface silent caching misses - [PR #20545](https://github.com/BerriAI/litellm/pull/20545) +- **Add INFO-level session reuse logging** per request for better observability - [PR #20597](https://github.com/BerriAI/litellm/pull/20597) + +--- + +## Database Changes + +### Schema Updates + +| Table | Change Type | Description | PR | Migration | +| ----- | ----------- | ----------- | -- | --------- | +| `LiteLLM_TeamTable` | New Column | Added `allow_team_guardrail_config` boolean field for team-based guardrail isolation | [PR #20318](https://github.com/BerriAI/litellm/pull/20318) | [Migration](https://github.com/BerriAI/litellm/blob/main/litellm-proxy-extras/litellm_proxy_extras/migrations/20260205091235_allow_team_guardrail_config/migration.sql) | +| `LiteLLM_DeletedTeamTable` | New Column | Added `allow_team_guardrail_config` boolean field | [PR #20318](https://github.com/BerriAI/litellm/pull/20318) | [Migration](https://github.com/BerriAI/litellm/blob/main/litellm-proxy-extras/litellm_proxy_extras/migrations/20260205091235_allow_team_guardrail_config/migration.sql) | +| `LiteLLM_TeamTable` | New Column | Added `soft_budget` (double precision) for soft budget alerting | [PR #20530](https://github.com/BerriAI/litellm/pull/20530) | [Migration](https://github.com/BerriAI/litellm/blob/main/litellm-proxy-extras/litellm_proxy_extras/migrations/20260205144610_add_soft_budget_to_team_table/migration.sql) | +| `LiteLLM_DeletedTeamTable` | New Column | Added `soft_budget` (double precision) | [PR #20653](https://github.com/BerriAI/litellm/pull/20653) | [Migration](https://github.com/BerriAI/litellm/blob/main/litellm-proxy-extras/litellm_proxy_extras/migrations/20260207110613_add_soft_budget_to_deleted_teams_table/migration.sql) | +| `LiteLLM_MCPServerTable` | New Column | Added `available_on_public_internet` boolean for MCP IP-based access control | [PR #20607](https://github.com/BerriAI/litellm/pull/20607) | [Migration](https://github.com/BerriAI/litellm/blob/main/litellm-proxy-extras/litellm_proxy_extras/migrations/20260207093506_add_available_on_public_internet_to_mcp_servers/migration.sql) | + +--- + +## Documentation Updates (14 updates) + +- Add FAQ for setting up and verifying LITELLM_LICENSE - [PR #20284](https://github.com/BerriAI/litellm/pull/20284) +- Model request tags documentation - [PR #20290](https://github.com/BerriAI/litellm/pull/20290) +- Add Prisma migration troubleshooting guide - [PR #20300](https://github.com/BerriAI/litellm/pull/20300) +- MCP Semantic Filtering documentation - [PR #20316](https://github.com/BerriAI/litellm/pull/20316) +- Add CopilotKit SDK doc as supported agents SDK - [PR #20396](https://github.com/BerriAI/litellm/pull/20396) +- Add documentation for Nova Sonic - [PR #20320](https://github.com/BerriAI/litellm/pull/20320) +- Update Vertex AI Text to Speech doc to show use of audio - [PR #20255](https://github.com/BerriAI/litellm/pull/20255) +- Improve Okta SSO setup guide with step-by-step instructions - [PR #20353](https://github.com/BerriAI/litellm/pull/20353) +- Langfuse doc update - [PR #20443](https://github.com/BerriAI/litellm/pull/20443) +- Expose MCPs on public internet documentation - [PR #20626](https://github.com/BerriAI/litellm/pull/20626) +- Add blog post: Achieving Sub-Millisecond Proxy Overhead - [PR #20309](https://github.com/BerriAI/litellm/pull/20309) +- Add blog post about litellm-observatory - [PR #20622](https://github.com/BerriAI/litellm/pull/20622) +- Update Opus 4.6 blog with adaptive thinking - [PR #20637](https://github.com/BerriAI/litellm/pull/20637) +- `gpt-5-search-api` docs clarifications - [PR #20512](https://github.com/BerriAI/litellm/pull/20512) + +--- + +## New Contributors +* @Quentin-M made their first contribution in [PR #19818](https://github.com/BerriAI/litellm/pull/19818) +* @amirzaushnizer made their first contribution in [PR #20235](https://github.com/BerriAI/litellm/pull/20235) +* @cscguochang made their first contribution in [PR #20214](https://github.com/BerriAI/litellm/pull/20214) +* @krauckbot made their first contribution in [PR #20273](https://github.com/BerriAI/litellm/pull/20273) +* @agrattan0820 made their first contribution in [PR #19784](https://github.com/BerriAI/litellm/pull/19784) +* @nina-hu made their first contribution in [PR #20472](https://github.com/BerriAI/litellm/pull/20472) +* @swayambhu94 made their first contribution in [PR #20469](https://github.com/BerriAI/litellm/pull/20469) +* @ssadedin made their first contribution in [PR #20566](https://github.com/BerriAI/litellm/pull/20566) + +--- + +## Full Changelog +[v1.81.6-nightly...v1.81.9](https://github.com/BerriAI/litellm/compare/v1.81.6-nightly...v1.81.9) diff --git a/docs/my-website/sidebars.js b/docs/my-website/sidebars.js index fda0e3be4e4..579b5699101 100644 --- a/docs/my-website/sidebars.js +++ b/docs/my-website/sidebars.js @@ -42,49 +42,62 @@ const sidebars = { label: "Guardrails", items: [ "proxy/guardrails/quick_start", - "proxy/guardrails/guardrail_policies", "proxy/guardrails/guardrail_load_balancing", + "proxy/guardrails/test_playground", + "proxy/guardrails/litellm_content_filter", { type: "category", - "label": "Contributing to Guardrails", + label: "Providers", + items: [ + ...[ + "proxy/guardrails/qualifire", + "proxy/guardrails/aim_security", + "proxy/guardrails/onyx_security", + "proxy/guardrails/aporia_api", + "proxy/guardrails/azure_content_guardrail", + "proxy/guardrails/bedrock", + "proxy/guardrails/enkryptai", + "proxy/guardrails/ibm_guardrails", + "proxy/guardrails/grayswan", + "proxy/guardrails/hiddenlayer", + "proxy/guardrails/lasso_security", + "proxy/guardrails/guardrails_ai", + "proxy/guardrails/lakera_ai", + "proxy/guardrails/model_armor", + "proxy/guardrails/noma_security", + "proxy/guardrails/dynamoai", + "proxy/guardrails/openai_moderation", + "proxy/guardrails/pangea", + "proxy/guardrails/pillar_security", + "proxy/guardrails/pii_masking_v2", + "proxy/guardrails/panw_prisma_airs", + "proxy/guardrails/secret_detection", + "proxy/guardrails/custom_guardrail", + "proxy/guardrails/custom_code_guardrail", + "proxy/guardrails/prompt_injection", + "proxy/guardrails/tool_permission", + "proxy/guardrails/zscaler_ai_guard", + "proxy/guardrails/javelin" + ].sort(), + ], + }, + { + type: "category", + label: "Contributing to Guardrails", items: [ "adding_provider/generic_guardrail_api", "adding_provider/simple_guardrail_tutorial", "adding_provider/adding_guardrail_support", ] }, - "proxy/guardrails/test_playground", - "proxy/guardrails/litellm_content_filter", - ...[ - "proxy/guardrails/qualifire", - "proxy/guardrails/aim_security", - "proxy/guardrails/onyx_security", - "proxy/guardrails/aporia_api", - "proxy/guardrails/azure_content_guardrail", - "proxy/guardrails/bedrock", - "proxy/guardrails/enkryptai", - "proxy/guardrails/ibm_guardrails", - "proxy/guardrails/grayswan", - "proxy/guardrails/hiddenlayer", - "proxy/guardrails/lasso_security", - "proxy/guardrails/guardrails_ai", - "proxy/guardrails/lakera_ai", - "proxy/guardrails/model_armor", - "proxy/guardrails/noma_security", - "proxy/guardrails/dynamoai", - "proxy/guardrails/openai_moderation", - "proxy/guardrails/pangea", - "proxy/guardrails/pillar_security", - "proxy/guardrails/pii_masking_v2", - "proxy/guardrails/panw_prisma_airs", - "proxy/guardrails/secret_detection", - "proxy/guardrails/custom_guardrail", - "proxy/guardrails/custom_code_guardrail", - "proxy/guardrails/prompt_injection", - "proxy/guardrails/tool_permission", - "proxy/guardrails/zscaler_ai_guard", - "proxy/guardrails/javelin" - ].sort(), + ], + }, + { + type: "category", + label: "Policies", + items: [ + "proxy/guardrails/guardrail_policies", + "proxy/guardrails/policy_tags", ], }, { @@ -96,6 +109,11 @@ const sidebars = { "proxy/prometheus" ] }, + { + type: "doc", + id: "integrations/websearch_interception", + label: "Web Search Integration" + }, { type: "category", label: "[Beta] Prompt Management", @@ -125,10 +143,12 @@ const sidebars = { "tutorials/claude_responses_api", "tutorials/claude_code_max_subscription", "tutorials/claude_code_customer_tracking", + "tutorials/claude_code_prompt_cache_routing", "tutorials/claude_code_websearch", "tutorials/claude_mcp", "tutorials/claude_non_anthropic_models", "tutorials/claude_code_plugin_marketplace", + "tutorials/claude_code_beta_headers", ] }, "tutorials/opencode_integration", @@ -222,6 +242,7 @@ const sidebars = { label: "Configuration", items: [ "set_keys", + "proxy_auth", "caching/all_caches", ], }, @@ -286,40 +307,52 @@ const sidebars = { label: "Admin UI", items: [ "proxy/ui", - "proxy/admin_ui_sso", - "proxy/custom_root_ui", - "proxy/custom_sso", - "proxy/ai_hub", - "proxy/model_compare_ui", - "proxy/ui_credentials", - "tutorials/scim_litellm", { type: "category", - label: "UI User/Team Management", + label: "Setup & SSO", items: [ - "proxy/access_control", - "proxy/public_teams", + "proxy/admin_ui_sso", + "proxy/custom_sso", + "proxy/custom_root_ui", + "tutorials/scim_litellm", + ] + }, + { + type: "category", + label: "Models", + items: [ + "proxy/ui_credentials", + "proxy/ai_hub", + "proxy/model_compare_ui", + ] + }, + { + type: "category", + label: "Teams & Organizations", + items: [ + "proxy/access_control", "proxy/self_serve", + "proxy/public_teams", "proxy/ui/bulk_edit_users", "proxy/ui/page_visibility", ] }, { type: "category", - label: "UI Usage Tracking", + label: "Observability: Usage", items: [ "proxy/customer_usage", - "proxy/endpoint_activity" + "proxy/endpoint_activity", ] }, { type: "category", - label: "UI Logs", + label: "Logs", items: [ "proxy/ui_logs", "proxy/ui_spend_log_settings", "proxy/ui_logs_sessions", - "proxy/deleted_keys_teams" + "proxy/deleted_keys_teams", ] } ], @@ -367,6 +400,7 @@ const sidebars = { items: [ "proxy/users", "proxy/team_budgets", + "proxy/ui_team_soft_budget_alerts", "proxy/tag_budgets", "proxy/customers", "proxy/dynamic_rate_limit", @@ -375,6 +409,16 @@ const sidebars = { ], }, "proxy/caching", + { + type: "link", + label: "Guardrails", + href: "https://docs.litellm.ai/docs/proxy/guardrails/quick_start", + }, + { + type: "link", + label: "Policies", + href: "https://docs.litellm.ai/docs/proxy/guardrails/guardrail_policies", + }, { type: "category", label: "Create Custom Plugins", @@ -542,6 +586,8 @@ const sidebars = { items: [ "mcp", "mcp_usage", + "mcp_oauth", + "mcp_public_internet", "mcp_semantic_filter", "mcp_control", "mcp_cost", @@ -1059,6 +1105,18 @@ const sidebars = { "troubleshoot/cpu_issues", "troubleshoot/memory_issues", "troubleshoot/spend_queue_warnings", + "troubleshoot/max_callbacks", + ], + }, + { + type: "category", + label: "Blog", + items: [ + { + type: "link", + label: "Incident: Broken Model Cost Map", + href: "/blog/model-cost-map-incident", + }, ], }, ], diff --git a/docs/my-website/src/components/MiddlewareDiagrams/BaseHTTPMiddlewareAnimation.tsx b/docs/my-website/src/components/MiddlewareDiagrams/BaseHTTPMiddlewareAnimation.tsx new file mode 100644 index 00000000000..0821cf353c6 --- /dev/null +++ b/docs/my-website/src/components/MiddlewareDiagrams/BaseHTTPMiddlewareAnimation.tsx @@ -0,0 +1,133 @@ +import React, { useState, useEffect, useCallback, useRef } from 'react'; +import styles from './styles.module.css'; + +interface Stage { + label: string; + subtitle: string; + code: string; +} + +const STAGES: Stage[] = [ + { + label: 'Request Wrapping', + subtitle: '_CachedRequest', + code: 'request = _CachedRequest(scope, receive)', + }, + { + label: 'Sync Event', + subtitle: 'anyio.Event()', + code: 'response_sent = anyio.Event()', + }, + { + label: 'Memory Stream', + subtitle: 'create_memory_object_stream()', + code: 'send_stream, recv_stream = anyio.create_memory_object_stream()', + }, + { + label: 'Task Group', + subtitle: 'create_task_group()', + code: 'async with anyio.create_task_group() as task_group:', + }, + { + label: 'Background Task', + subtitle: 'task_group.start_soon(coro)', + code: 'task_group.start_soon(coro) # app runs in separate task', + }, + { + label: 'Nested Task Group', + subtitle: 'receive_or_disconnect()', + code: 'async with anyio.create_task_group() as task_group: ...', + }, + { + label: 'Response Wrapping', + subtitle: '_StreamingResponse', + code: 'response = _StreamingResponse(status_code=..., content=body_stream())', + }, +]; + +const INTERVAL_MS = 1200; +const PAUSE_MS = 600; + +export default function BaseHTTPMiddlewareAnimation() { + const [activeStage, setActiveStage] = useState(0); + const [paused, setPaused] = useState(false); + const [expandedStage, setExpandedStage] = useState(null); + const timerRef = useRef | null>(null); + + const clearTimer = useCallback(() => { + if (timerRef.current !== null) { + clearTimeout(timerRef.current); + timerRef.current = null; + } + }, []); + + useEffect(() => { + if (paused) return; + + const advance = () => { + setActiveStage((prev) => { + const next = (prev + 1) % STAGES.length; + // If wrapping around, add extra pause + if (next === 0) { + timerRef.current = setTimeout(() => { + timerRef.current = setTimeout(advance, INTERVAL_MS); + }, PAUSE_MS); + return next; + } + timerRef.current = setTimeout(advance, INTERVAL_MS); + return next; + }); + }; + + timerRef.current = setTimeout(advance, INTERVAL_MS); + return clearTimer; + }, [paused, clearTimer]); + + const handleStageClick = (index: number) => { + clearTimer(); + setPaused(true); + setActiveStage(index); + + if (expandedStage === index) { + // Close panel and resume + setExpandedStage(null); + setPaused(false); + } else { + setExpandedStage(index); + } + }; + + return ( +
+
7 steps per request
+
+ {STAGES.map((stage, i) => ( +
+
handleStageClick(i)} + role="button" + tabIndex={0} + onKeyDown={(e) => { + if (e.key === 'Enter' || e.key === ' ') handleStageClick(i); + }} + > +
{i + 1}
+
{stage.label}
+
{stage.subtitle}
+
+
+ ))} +
+
+ {expandedStage !== null && ( +
+            {STAGES[expandedStage].code}
+          
+ )} +
+
+ ); +} diff --git a/docs/my-website/src/components/MiddlewareDiagrams/BenchmarkVisualization.tsx b/docs/my-website/src/components/MiddlewareDiagrams/BenchmarkVisualization.tsx new file mode 100644 index 00000000000..b2b34d9d044 --- /dev/null +++ b/docs/my-website/src/components/MiddlewareDiagrams/BenchmarkVisualization.tsx @@ -0,0 +1,337 @@ +import React, { useState, useEffect, useRef, useCallback } from 'react'; +import styles from './styles.module.css'; + +/* ── Constants ── */ +const TOTAL_REQUESTS = 50_000; +const DURATION_AFTER_MS = 8_000; // "After" column finishes in 8s +const DURATION_BEFORE_MS = 13_920; // 74% slower → 8000 * 1.74 +const TICK_MS = 50; +const RESET_PAUSE_MS = 2_000; +const MAX_DOTS = 14; + +const BEFORE_RPS = 3_785; +const AFTER_RPS = 6_577; +const BEFORE_P50 = 21; +const AFTER_P50 = 13; + +const BEFORE_LAYERS = [ + { label: 'ab client', warning: false }, + { label: 'uvicorn \u00B7 1 worker', warning: false }, + { label: 'ASGI Middleware', warning: false }, + { label: 'BaseHTTPMiddleware', warning: true }, + { label: 'GET /health \u2192 "ok"', warning: false }, +]; + +const AFTER_LAYERS = [ + { label: 'ab client', warning: false }, + { label: 'uvicorn \u00B7 1 worker', warning: false }, + { label: 'ASGI Middleware', warning: false }, + { label: 'ASGI Middleware', warning: false }, + { label: 'GET /health \u2192 "ok"', warning: false }, +]; + +const BENCHMARK_RUNS = [ + { config: 'Before (1 ASGI + 1 BaseHTTP)', run: 1, rps: 3596, p50: 21 }, + { config: 'Before (1 ASGI + 1 BaseHTTP)', run: 2, rps: 3599, p50: 21 }, + { config: 'Before (1 ASGI + 1 BaseHTTP)', run: 3, rps: 4161, p50: 21 }, + { config: 'After (2x Pure ASGI)', run: 1, rps: 6504, p50: 13 }, + { config: 'After (2x Pure ASGI)', run: 2, rps: 6631, p50: 13 }, + { config: 'After (2x Pure ASGI)', run: 3, rps: 6595, p50: 13 }, +]; + +/* ── Dot type ── */ +interface Dot { + id: number; + progress: number; // 0..1 (top to bottom) +} + +/* ── Component ── */ +export default function BenchmarkVisualization() { + const [elapsed, setElapsed] = useState(0); + const [running, setRunning] = useState(false); + const [afterDone, setAfterDone] = useState(false); + const [beforeDone, setBeforeDone] = useState(false); + const [tableOpen, setTableOpen] = useState(false); + const [beforeDots, setBeforeDots] = useState([]); + const [afterDots, setAfterDots] = useState([]); + const dotIdRef = useRef(0); + const observerRef = useRef(null); + const wrapperRef = useRef(null); + const timerRef = useRef | null>(null); + const hasStartedRef = useRef(false); + + const beforeProgress = Math.min(elapsed / DURATION_BEFORE_MS, 1); + const afterProgress = Math.min(elapsed / DURATION_AFTER_MS, 1); + const beforeCompleted = Math.round(beforeProgress * TOTAL_REQUESTS); + const afterCompleted = Math.round(afterProgress * TOTAL_REQUESTS); + const beforeCurrentRPS = running && !beforeDone + ? Math.round(BEFORE_RPS * (0.9 + Math.random() * 0.2)) + : beforeDone ? 0 : 0; + const afterCurrentRPS = running && !afterDone + ? Math.round(AFTER_RPS * (0.9 + Math.random() * 0.2)) + : afterDone ? 0 : 0; + + const reset = useCallback(() => { + setElapsed(0); + setAfterDone(false); + setBeforeDone(false); + setBeforeDots([]); + setAfterDots([]); + dotIdRef.current = 0; + }, []); + + // Start/restart loop + const startSimulation = useCallback(() => { + reset(); + setRunning(true); + }, [reset]); + + // IntersectionObserver to auto-start on scroll + useEffect(() => { + observerRef.current = new IntersectionObserver( + ([entry]) => { + if (entry.isIntersecting && !hasStartedRef.current) { + hasStartedRef.current = true; + startSimulation(); + } + }, + { threshold: 0.3 } + ); + + if (wrapperRef.current) { + observerRef.current.observe(wrapperRef.current); + } + + return () => { + observerRef.current?.disconnect(); + }; + }, [startSimulation]); + + // Main tick + useEffect(() => { + if (!running) return; + + timerRef.current = setInterval(() => { + setElapsed((prev) => { + const next = prev + TICK_MS; + + if (next >= DURATION_AFTER_MS) setAfterDone(true); + if (next >= DURATION_BEFORE_MS) setBeforeDone(true); + + // Both done → schedule reset + if (next >= DURATION_BEFORE_MS) { + setTimeout(() => { + startSimulation(); + }, RESET_PAUSE_MS); + setRunning(false); + return next; + } + return next; + }); + }, TICK_MS); + + return () => { + if (timerRef.current) clearInterval(timerRef.current); + }; + }, [running, startSimulation]); + + // Dot animation + useEffect(() => { + if (!running) return; + + const dotInterval = setInterval(() => { + const spawnBefore = !beforeDone && Math.random() < 0.4; + const spawnAfter = !afterDone && Math.random() < 0.65; + + if (spawnBefore) { + setBeforeDots((prev) => { + const dots = [...prev, { id: dotIdRef.current++, progress: 0 }]; + return dots.slice(-MAX_DOTS); + }); + } + if (spawnAfter) { + setAfterDots((prev) => { + const dots = [...prev, { id: dotIdRef.current++, progress: 0 }]; + return dots.slice(-MAX_DOTS); + }); + } + + // Advance existing dots + setBeforeDots((prev) => + prev + .map((d) => ({ ...d, progress: d.progress + 0.08 })) + .filter((d) => d.progress <= 1) + ); + setAfterDots((prev) => + prev + .map((d) => ({ ...d, progress: d.progress + 0.14 })) + .filter((d) => d.progress <= 1) + ); + }, 100); + + return () => clearInterval(dotInterval); + }, [running, beforeDone, afterDone]); + + const renderFlowStack = ( + layers: { label: string; warning: boolean }[], + dots: Dot[], + isBefore: boolean + ) => ( +
+
+ {dots.map((dot) => ( +
0.85 ? (1 - dot.progress) * 6 : 0.8, + }} + /> + ))} +
+ {layers.map((layer, i) => ( + + {i > 0 &&
} +
+ {layer.label} + {layer.warning && ← overhead} +
+
+ ))} +
+ ); + + const formatNum = (n: number) => n.toLocaleString(); + + return ( +
+
+ 50,000 requests · 1,000 concurrent · 1 worker +
+ +
+ {/* Before column */} +
+
+ Before (1 ASGI + 1 BaseHTTP) + {beforeDone && ( + done + )} +
+ {renderFlowStack(BEFORE_LAYERS, beforeDots, true)} +
+
+
{formatNum(beforeCurrentRPS)}
+
RPS
+
+
+
{formatNum(beforeCompleted)}
+
Completed
+
+
+
{BEFORE_P50}ms
+
P50
+
+
+
+
+
+
+ + {/* After column */} +
+
+ After (2x Pure ASGI) + {afterDone && ( + done + )} +
+ {renderFlowStack(AFTER_LAYERS, afterDots, false)} +
+
+
{formatNum(afterCurrentRPS)}
+
RPS
+
+
+
{formatNum(afterCompleted)}
+
Completed
+
+
+
{AFTER_P50}ms
+
P50
+
+
+
+
+
+
+
+ + {/* Summary stats */} +
+
+
+74%
+
Throughput (RPS)
+
+
+
-38%
+
Median Latency (P50)
+
+
+ + {/* Collapsible per-run data */} +
+ +
+ + + + + + + + + + + {BENCHMARK_RUNS.map((row, i) => ( + + + + + + + ))} + +
ConfigRunRPSP50 (ms)
{row.config}{row.run}{formatNum(row.rps)}{row.p50}
+
+
+ +
+ ); +} diff --git a/docs/my-website/src/components/MiddlewareDiagrams/PureASGIAnimation.tsx b/docs/my-website/src/components/MiddlewareDiagrams/PureASGIAnimation.tsx new file mode 100644 index 00000000000..c936519a651 --- /dev/null +++ b/docs/my-website/src/components/MiddlewareDiagrams/PureASGIAnimation.tsx @@ -0,0 +1,67 @@ +import React, { useState, useEffect, useRef, useCallback } from 'react'; +import styles from './styles.module.css'; + +interface Stage { + label: string; + subtitle: string; +} + +const STAGES: Stage[] = [ + { label: 'Scope Check', subtitle: 'scope["type"] != "http"' }, + { label: 'Direct Call', subtitle: 'await self.app(scope, receive, send)' }, +]; + +const INTERVAL_MS = 1200; +const PAUSE_MS = 600; + +export default function PureASGIAnimation() { + const [activeStage, setActiveStage] = useState(0); + const timerRef = useRef | null>(null); + + const clearTimer = useCallback(() => { + if (timerRef.current !== null) { + clearTimeout(timerRef.current); + timerRef.current = null; + } + }, []); + + useEffect(() => { + const advance = () => { + setActiveStage((prev) => { + const next = (prev + 1) % STAGES.length; + if (next === 0) { + timerRef.current = setTimeout(() => { + timerRef.current = setTimeout(advance, INTERVAL_MS); + }, PAUSE_MS); + return next; + } + timerRef.current = setTimeout(advance, INTERVAL_MS); + return next; + }); + }; + + timerRef.current = setTimeout(advance, INTERVAL_MS); + return clearTimer; + }, [clearTimer]); + + return ( +
+
2 steps per request
+
+ {STAGES.map((stage, i) => ( +
+
+
{i + 1}
+
{stage.label}
+
{stage.subtitle}
+
+
+ ))} +
+
+ ); +} diff --git a/docs/my-website/src/components/MiddlewareDiagrams/index.tsx b/docs/my-website/src/components/MiddlewareDiagrams/index.tsx new file mode 100644 index 00000000000..ad20d62adfd --- /dev/null +++ b/docs/my-website/src/components/MiddlewareDiagrams/index.tsx @@ -0,0 +1,3 @@ +export { default as BaseHTTPMiddlewareAnimation } from './BaseHTTPMiddlewareAnimation'; +export { default as PureASGIAnimation } from './PureASGIAnimation'; +export { default as BenchmarkVisualization } from './BenchmarkVisualization'; diff --git a/docs/my-website/src/components/MiddlewareDiagrams/styles.module.css b/docs/my-website/src/components/MiddlewareDiagrams/styles.module.css new file mode 100644 index 00000000000..a9b9249f97a --- /dev/null +++ b/docs/my-website/src/components/MiddlewareDiagrams/styles.module.css @@ -0,0 +1,494 @@ +/* ── Shared custom properties ── */ +:root { + --mw-stage-bg: #f8f9fa; + --mw-stage-border: #dee2e6; + --mw-stage-active-bg: #e8f4fd; + --mw-stage-active-border: #3b82f6; + --mw-stage-green-active-bg: #ecfdf5; + --mw-stage-green-active-border: #10b981; + --mw-dot-color: #3b82f6; + --mw-warning-accent: #ef4444; + --mw-success-accent: #10b981; + --mw-text-primary: #1a1a2e; + --mw-text-secondary: #6b7280; + --mw-code-bg: #f1f5f9; + --mw-panel-bg: #ffffff; + --mw-panel-border: #e5e7eb; + --mw-bar-bg: #e5e7eb; + --mw-arrow-color: #9ca3af; + --mw-column-bg: #fafafa; + --mw-column-border: #e5e7eb; + --mw-layer-bg: #f3f4f6; + --mw-layer-border: #d1d5db; + --mw-layer-warning-bg: #fef2f2; + --mw-layer-warning-border: #fca5a5; + --mw-progress-bg: #e5e7eb; +} + +[data-theme='dark'] { + --mw-stage-bg: #1e1e2e; + --mw-stage-border: #374151; + --mw-stage-active-bg: #1e3a5f; + --mw-stage-active-border: #60a5fa; + --mw-stage-green-active-bg: #064e3b; + --mw-stage-green-active-border: #34d399; + --mw-dot-color: #60a5fa; + --mw-warning-accent: #f87171; + --mw-success-accent: #34d399; + --mw-text-primary: #e5e7eb; + --mw-text-secondary: #9ca3af; + --mw-code-bg: #1e293b; + --mw-panel-bg: #111827; + --mw-panel-border: #374151; + --mw-bar-bg: #374151; + --mw-arrow-color: #6b7280; + --mw-column-bg: #111827; + --mw-column-border: #374151; + --mw-layer-bg: #1f2937; + --mw-layer-border: #4b5563; + --mw-layer-warning-bg: #451a1a; + --mw-layer-warning-border: #b91c1c; + --mw-progress-bg: #374151; +} + +/* ── Pipeline (shared between BaseHTTP and PureASGI) ── */ +.pipelineWrapper { + margin: 1.5rem 0; +} + +.pipelineLabel { + text-align: center; + font-size: 0.85rem; + font-weight: 600; + color: var(--mw-text-secondary); + margin-bottom: 0.75rem; + text-transform: uppercase; + letter-spacing: 0.05em; +} + +.pipeline { + display: flex; + flex-wrap: wrap; + justify-content: center; + align-items: stretch; + gap: 0.75rem; + padding: 0.5rem 0; +} + +.pipelineTwoCol { + max-width: 480px; + margin: 0 auto; +} + +.stageWrapper { + display: flex; + align-items: center; + width: 160px; + flex-shrink: 0; +} + +.pipelineTwoCol .stageWrapper { + width: 200px; +} + +.arrow { + display: none; +} + +.stage { + flex: 1; + padding: 0.85rem 0.75rem; + min-height: 100px; + display: flex; + flex-direction: column; + justify-content: center; + background: var(--mw-stage-bg); + border: 2px solid var(--mw-stage-border); + border-radius: 8px; + text-align: center; + cursor: pointer; + transition: background 0.4s ease, border-color 0.4s ease, box-shadow 0.4s ease; + user-select: none; +} + +.stage:hover { + border-color: var(--mw-stage-active-border); +} + +.stageActive { + background: var(--mw-stage-active-bg); + border-color: var(--mw-stage-active-border); + box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15); +} + +.stageActiveGreen { + background: var(--mw-stage-green-active-bg); + border-color: var(--mw-stage-green-active-border); + box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.15); +} + +.stageNoClick { + cursor: default; +} + +.stageNumber { + font-size: 0.7rem; + font-weight: 700; + color: var(--mw-text-secondary); + margin-bottom: 0.3rem; +} + +.stageLabel { + font-size: 0.85rem; + font-weight: 600; + color: var(--mw-text-primary); + margin-bottom: 0.25rem; + line-height: 1.3; +} + +.stageSubtitle { + font-size: 0.72rem; + color: var(--mw-text-secondary); + font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace; + word-break: break-word; + line-height: 1.3; +} + +/* ── Code panel (accordion) ── */ +.codePanel { + max-height: 0; + overflow: hidden; + transition: max-height 0.35s ease, padding 0.35s ease; + background: var(--mw-code-bg); + border-radius: 0 0 8px 8px; + margin-top: 0.5rem; +} + +.codePanelOpen { + max-height: 120px; + padding: 0.75rem 1rem; +} + +.codePanelCode { + font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace; + font-size: 0.8rem; + color: var(--mw-text-primary); + white-space: pre; + margin: 0; + line-height: 1.5; +} + +/* ── Benchmark Visualization ── */ +.benchmarkWrapper { + margin: 1.5rem 0; +} + +.benchmarkConfig { + text-align: center; + font-size: 0.85rem; + color: var(--mw-text-secondary); + margin-bottom: 1rem; + font-weight: 500; +} + +.benchmarkColumns { + display: flex; + gap: 1.5rem; +} + +.benchmarkColumn { + flex: 1; + background: var(--mw-column-bg); + border: 1px solid var(--mw-column-border); + border-radius: 12px; + padding: 1.25rem; + position: relative; + overflow: hidden; +} + +.columnTitle { + font-size: 0.9rem; + font-weight: 700; + color: var(--mw-text-primary); + text-align: center; + margin-bottom: 1rem; +} + +.columnTitleBefore { + color: var(--mw-warning-accent); +} + +.columnTitleAfter { + color: var(--mw-success-accent); +} + +/* ── Request flow stack ── */ +.flowStack { + display: flex; + flex-direction: column; + align-items: center; + gap: 0; + position: relative; + min-height: 280px; +} + +.flowLayer { + width: 100%; + max-width: 260px; + padding: 0.6rem 0.75rem; + background: var(--mw-layer-bg); + border: 1px solid var(--mw-layer-border); + border-radius: 6px; + text-align: center; + font-size: 0.78rem; + font-weight: 500; + color: var(--mw-text-primary); + position: relative; + z-index: 1; +} + +.flowLayerWarning { + background: var(--mw-layer-warning-bg); + border-color: var(--mw-layer-warning-border); + font-weight: 700; +} + +.flowArrow { + display: flex; + justify-content: center; + color: var(--mw-arrow-color); + font-size: 0.9rem; + padding: 0.15rem 0; + position: relative; + z-index: 0; + min-height: 20px; +} + +.overheadTag { + font-size: 0.65rem; + color: var(--mw-warning-accent); + margin-left: 0.4rem; +} + +/* ── Dots layer (canvas for flowing dots) ── */ +.dotsCanvas { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + pointer-events: none; + z-index: 2; +} + +.dot { + position: absolute; + width: 6px; + height: 6px; + border-radius: 50%; + background: var(--mw-dot-color); + opacity: 0.8; +} + +.dotSlow { + background: var(--mw-warning-accent); +} + +.dotFast { + background: var(--mw-success-accent); +} + +/* ── Stats & progress ── */ +.statsRow { + display: flex; + justify-content: space-around; + margin-top: 1rem; + padding-top: 0.75rem; + border-top: 1px solid var(--mw-panel-border); +} + +.stat { + text-align: center; +} + +.statValue { + font-size: 1.1rem; + font-weight: 700; + color: var(--mw-text-primary); + font-variant-numeric: tabular-nums; +} + +.statLabel { + font-size: 0.7rem; + color: var(--mw-text-secondary); + text-transform: uppercase; + letter-spacing: 0.04em; +} + +.progressBar { + width: 100%; + height: 6px; + background: var(--mw-progress-bg); + border-radius: 3px; + margin-top: 0.75rem; + overflow: hidden; +} + +.progressFill { + height: 100%; + border-radius: 3px; + transition: width 0.1s linear; +} + +.progressFillBefore { + background: var(--mw-warning-accent); +} + +.progressFillAfter { + background: var(--mw-success-accent); +} + +/* ── Summary stats below simulation ── */ +.summaryStats { + display: flex; + justify-content: center; + gap: 2rem; + margin-top: 1.5rem; + flex-wrap: wrap; +} + +.summaryItem { + text-align: center; + padding: 0.75rem 1.25rem; + background: var(--mw-stage-bg); + border-radius: 8px; + border: 1px solid var(--mw-panel-border); +} + +.summaryValue { + font-size: 1.5rem; + font-weight: 800; + color: var(--mw-success-accent); +} + +.summaryLabel { + font-size: 0.8rem; + color: var(--mw-text-secondary); + margin-top: 0.2rem; +} + +/* ── Collapsible table ── */ +.collapsible { + margin-top: 1.5rem; +} + +.collapsibleToggle { + background: none; + border: 1px solid var(--mw-panel-border); + border-radius: 6px; + padding: 0.5rem 1rem; + cursor: pointer; + font-size: 0.85rem; + color: var(--mw-text-primary); + width: 100%; + text-align: left; + display: flex; + align-items: center; + gap: 0.5rem; + transition: background 0.2s; +} + +.collapsibleToggle:hover { + background: var(--mw-stage-bg); +} + +.collapsibleChevron { + transition: transform 0.3s ease; + font-size: 0.7rem; +} + +.collapsibleChevronOpen { + transform: rotate(90deg); +} + +.collapsibleContent { + max-height: 0; + overflow: hidden; + transition: max-height 0.35s ease; +} + +.collapsibleContentOpen { + max-height: 600px; +} + +.dataTable { + width: 100%; + border-collapse: collapse; + margin-top: 0.75rem; + font-size: 0.85rem; +} + +.dataTable th, +.dataTable td { + padding: 0.5rem 0.75rem; + text-align: left; + border-bottom: 1px solid var(--mw-panel-border); +} + +.dataTable th { + font-weight: 600; + color: var(--mw-text-secondary); + font-size: 0.75rem; + text-transform: uppercase; + letter-spacing: 0.04em; +} + +.dataTable td { + color: var(--mw-text-primary); + font-variant-numeric: tabular-nums; +} + +/* ── Reproduce section ── */ +.reproduceSection { + margin-top: 1rem; +} + +/* ── Done badge ── */ +.doneBadge { + display: inline-block; + font-size: 0.75rem; + font-weight: 600; + padding: 0.2rem 0.6rem; + border-radius: 4px; + margin-left: 0.5rem; +} + +.doneBadgeBefore { + color: var(--mw-warning-accent); + background: var(--mw-layer-warning-bg); +} + +.doneBadgeAfter { + color: var(--mw-success-accent); + background: var(--mw-stage-green-active-bg); +} + +/* ── Responsive ── */ +@media (max-width: 768px) { + .stageWrapper { + width: 140px; + } + + .pipelineTwoCol .stageWrapper { + width: 160px; + } + + .benchmarkColumns { + flex-direction: column; + } + + .summaryStats { + flex-direction: column; + align-items: center; + } +} diff --git a/enterprise/dist/litellm_enterprise-0.1.30-py3-none-any.whl b/enterprise/dist/litellm_enterprise-0.1.30-py3-none-any.whl new file mode 100644 index 00000000000..0165bb096c0 Binary files /dev/null and b/enterprise/dist/litellm_enterprise-0.1.30-py3-none-any.whl differ diff --git a/enterprise/dist/litellm_enterprise-0.1.30.tar.gz b/enterprise/dist/litellm_enterprise-0.1.30.tar.gz new file mode 100644 index 00000000000..2bb7510e5d3 Binary files /dev/null and b/enterprise/dist/litellm_enterprise-0.1.30.tar.gz differ diff --git a/enterprise/dist/litellm_enterprise-0.1.31-py3-none-any.whl b/enterprise/dist/litellm_enterprise-0.1.31-py3-none-any.whl new file mode 100644 index 00000000000..03cadbd9023 Binary files /dev/null and b/enterprise/dist/litellm_enterprise-0.1.31-py3-none-any.whl differ diff --git a/enterprise/dist/litellm_enterprise-0.1.31.tar.gz b/enterprise/dist/litellm_enterprise-0.1.31.tar.gz new file mode 100644 index 00000000000..1ba1a717f62 Binary files /dev/null and b/enterprise/dist/litellm_enterprise-0.1.31.tar.gz differ diff --git a/enterprise/litellm_enterprise/enterprise_callbacks/send_emails/base_email.py b/enterprise/litellm_enterprise/enterprise_callbacks/send_emails/base_email.py index 61e0745bab1..d3e04769300 100644 --- a/enterprise/litellm_enterprise/enterprise_callbacks/send_emails/base_email.py +++ b/enterprise/litellm_enterprise/enterprise_callbacks/send_emails/base_email.py @@ -30,8 +30,15 @@ from litellm.integrations.email_templates.user_invitation_email import ( from litellm.integrations.email_templates.templates import ( MAX_BUDGET_ALERT_EMAIL_TEMPLATE, SOFT_BUDGET_ALERT_EMAIL_TEMPLATE, + TEAM_SOFT_BUDGET_ALERT_EMAIL_TEMPLATE, +) +from litellm.proxy._types import ( + CallInfo, + InvitationNew, + Litellm_EntityType, + UserAPIKeyAuth, + WebhookEvent, ) -from litellm.proxy._types import CallInfo, InvitationNew, UserAPIKeyAuth, WebhookEvent from litellm.secret_managers.main import get_secret_bool from litellm.types.integrations.slack_alerting import LITELLM_LOGO_URL from litellm.constants import ( @@ -217,6 +224,78 @@ class BaseEmailLogger(CustomLogger): ) pass + async def send_team_soft_budget_alert_email(self, event: WebhookEvent): + """ + Send email to team members when team soft budget is crossed + Supports multiple recipients via alert_emails field from team metadata + """ + # Collect all recipient emails + recipient_emails: List[str] = [] + + # Add additional alert emails from team metadata.soft_budget_alert_emails + if hasattr(event, "alert_emails") and event.alert_emails: + for email in event.alert_emails: + if email and email not in recipient_emails: # Avoid duplicates + recipient_emails.append(email) + + # If no recipients found, skip sending + if not recipient_emails: + verbose_proxy_logger.warning( + f"No recipient emails found for team soft budget alert. event={event.model_dump(exclude_none=True)}" + ) + return + + # Validate that we have at least one valid email address + first_recipient_email = recipient_emails[0] + if not first_recipient_email or not first_recipient_email.strip(): + verbose_proxy_logger.warning( + f"Invalid recipient email found for team soft budget alert. event={event.model_dump(exclude_none=True)}" + ) + return + + verbose_proxy_logger.debug( + f"send_team_soft_budget_alert_email_event: {json.dumps(event.model_dump(exclude_none=True), indent=4, default=str)}" + ) + + # Get email params using the first recipient email (for template formatting) + # For team alerts with alert_emails, we don't need user_id lookup since we already have email addresses + # Pass user_id=None to prevent _get_email_params from trying to look up email from a potentially None user_id + email_params = await self._get_email_params( + email_event=EmailEvent.soft_budget_crossed, + user_id=None, # Team alerts don't require user_id when alert_emails are provided + user_email=first_recipient_email, + event_message=event.event_message, + ) + + # Format budget values + soft_budget_str = f"${event.soft_budget}" if event.soft_budget is not None else "N/A" + spend_str = f"${event.spend}" if event.spend is not None else "$0.00" + max_budget_info = "" + if event.max_budget is not None: + max_budget_info = f"Maximum Budget: ${event.max_budget}
" + + # Use team alias or generic greeting + team_alias = event.team_alias or "Team" + + email_html_content = TEAM_SOFT_BUDGET_ALERT_EMAIL_TEMPLATE.format( + email_logo_url=email_params.logo_url, + team_alias=team_alias, + soft_budget=soft_budget_str, + spend=spend_str, + max_budget_info=max_budget_info, + base_url=email_params.base_url, + email_support_contact=email_params.support_contact, + ) + + # Send email to all recipients + await self.send_email( + from_email=self.DEFAULT_LITELLM_EMAIL, + to_email=recipient_emails, + subject=email_params.subject, + html_body=email_html_content, + ) + pass + async def send_max_budget_alert_email(self, event: WebhookEvent): """ Send email to user when max budget alert threshold is reached @@ -285,15 +364,36 @@ class BaseEmailLogger(CustomLogger): # - Don't re-alert, if alert already sent _cache: DualCache = self.internal_usage_cache - # percent of max_budget left to spend - if user_info.max_budget is None and user_info.soft_budget is None: - return - # For soft_budget alerts, check if we've already sent an alert if type == "soft_budget": + # For team soft budget alerts, we only need team soft_budget to be set + # For other entity types, we need either max_budget or soft_budget + if user_info.event_group == Litellm_EntityType.TEAM: + if user_info.soft_budget is None: + return + # For team soft budget alerts, require alert_emails to be configured + # Team soft budget alerts are sent via metadata.soft_budget_alerting_emails + if user_info.alert_emails is None or len(user_info.alert_emails) == 0: + verbose_proxy_logger.debug( + "Skipping team soft budget email alert: no alert_emails configured", + ) + return + else: + # For non-team alerts, require either max_budget or soft_budget + if user_info.max_budget is None and user_info.soft_budget is None: + return if user_info.soft_budget is not None and user_info.spend >= user_info.soft_budget: # Generate cache key based on event type and identifier - _id = user_info.token or user_info.user_id or "default_id" + # Use appropriate ID based on event_group to ensure unique cache keys per entity type + if user_info.event_group == Litellm_EntityType.TEAM: + _id = user_info.team_id or "default_id" + elif user_info.event_group == Litellm_EntityType.ORGANIZATION: + _id = user_info.organization_id or "default_id" + elif user_info.event_group == Litellm_EntityType.USER: + _id = user_info.user_id or "default_id" + else: + # For KEY and other types, use token or user_id + _id = user_info.token or user_info.user_id or "default_id" _cache_key = f"email_budget_alerts:soft_budget_crossed:{_id}" # Check if we've already sent this alert @@ -318,10 +418,15 @@ class BaseEmailLogger(CustomLogger): projected_exceeded_date=user_info.projected_exceeded_date, projected_spend=user_info.projected_spend, event_group=user_info.event_group, + alert_emails=user_info.alert_emails, ) try: - await self.send_soft_budget_alert_email(webhook_event) + # Use team-specific function for team alerts, otherwise use standard function + if user_info.event_group == Litellm_EntityType.TEAM: + await self.send_team_soft_budget_alert_email(webhook_event) + else: + await self.send_soft_budget_alert_email(webhook_event) # Cache the alert to prevent duplicate sends await _cache.async_set_cache( diff --git a/enterprise/litellm_enterprise/proxy/hooks/managed_files.py b/enterprise/litellm_enterprise/proxy/hooks/managed_files.py index 569ea17f6d8..a41b3f3bf6f 100644 --- a/enterprise/litellm_enterprise/proxy/hooks/managed_files.py +++ b/enterprise/litellm_enterprise/proxy/hooks/managed_files.py @@ -899,49 +899,49 @@ class _PROXY_LiteLLMManagedFiles(CustomLogger, BaseFileEndpoints): batch_id=response.id, model_id=model_id ) - if ( - response.output_file_id and model_id - ): # return a file id with the model_id and output_file_id - original_output_file_id = response.output_file_id - response.output_file_id = self.get_unified_output_file_id( - output_file_id=response.output_file_id, - model_id=model_id, - model_name=model_name, - ) - - # Fetch the actual file object for the output file - file_object = None - try: - # Use litellm to retrieve the file object from the provider - from litellm import afile_retrieve - file_object = await afile_retrieve( - custom_llm_provider=model_name.split("/")[0] if model_name and "/" in model_name else "openai", - file_id=original_output_file_id + # Handle both output_file_id and error_file_id + for file_attr in ["output_file_id", "error_file_id"]: + file_id_value = getattr(response, file_attr, None) + if file_id_value and model_id: + original_file_id = file_id_value + unified_file_id = self.get_unified_output_file_id( + output_file_id=original_file_id, + model_id=model_id, + model_name=model_name, ) - verbose_logger.debug( - f"Successfully retrieved file object for output_file_id={original_output_file_id}" + setattr(response, file_attr, unified_file_id) + + # Fetch the actual file object from the provider + file_object = None + try: + # Use litellm to retrieve the file object from the provider + from litellm import afile_retrieve + file_object = await afile_retrieve( + custom_llm_provider=model_name.split("/")[0] if model_name and "/" in model_name else "openai", + file_id=original_file_id + ) + verbose_logger.debug( + f"Successfully retrieved file object for {file_attr}={original_file_id}" + ) + except Exception as e: + verbose_logger.warning( + f"Failed to retrieve file object for {file_attr}={original_file_id}: {str(e)}. Storing with None and will fetch on-demand." + ) + + await self.store_unified_file_id( + file_id=unified_file_id, + file_object=file_object, + litellm_parent_otel_span=user_api_key_dict.parent_otel_span, + model_mappings={model_id: original_file_id}, + user_api_key_dict=user_api_key_dict, ) - except Exception as e: - verbose_logger.warning( - f"Failed to retrieve file object for output_file_id={original_output_file_id}: {str(e)}. Storing with None and will fetch on-demand." - ) - - await self.store_unified_file_id( - file_id=response.output_file_id, - file_object=file_object, - litellm_parent_otel_span=user_api_key_dict.parent_otel_span, - model_mappings={model_id: original_output_file_id}, - user_api_key_dict=user_api_key_dict, - ) - asyncio.create_task( - self.store_unified_object_id( - unified_object_id=response.id, - file_object=response, - litellm_parent_otel_span=user_api_key_dict.parent_otel_span, - model_object_id=original_response_id, - file_purpose="batch", - user_api_key_dict=user_api_key_dict, - ) + await self.store_unified_object_id( + unified_object_id=response.id, + file_object=response, + litellm_parent_otel_span=user_api_key_dict.parent_otel_span, + model_object_id=original_response_id, + file_purpose="batch", + user_api_key_dict=user_api_key_dict, ) elif isinstance(response, LiteLLMFineTuningJob): ## Check if unified_file_id is in the response @@ -958,15 +958,13 @@ class _PROXY_LiteLLMManagedFiles(CustomLogger, BaseFileEndpoints): response.id = self.get_unified_generic_response_id( model_id=model_id, generic_response_id=response.id ) - asyncio.create_task( - self.store_unified_object_id( - unified_object_id=response.id, - file_object=response, - litellm_parent_otel_span=user_api_key_dict.parent_otel_span, - model_object_id=original_response_id, - file_purpose="fine-tune", - user_api_key_dict=user_api_key_dict, - ) + await self.store_unified_object_id( + unified_object_id=response.id, + file_object=response, + litellm_parent_otel_span=user_api_key_dict.parent_otel_span, + model_object_id=original_response_id, + file_purpose="fine-tune", + user_api_key_dict=user_api_key_dict, ) elif isinstance(response, AsyncCursorPage): """ diff --git a/enterprise/pyproject.toml b/enterprise/pyproject.toml index c5aaa0a3407..eca5cdb97df 100644 --- a/enterprise/pyproject.toml +++ b/enterprise/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "litellm-enterprise" -version = "0.1.29" +version = "0.1.31" description = "Package for LiteLLM Enterprise features" authors = ["BerriAI"] readme = "README.md" @@ -22,7 +22,7 @@ requires = ["poetry-core"] build-backend = "poetry.core.masonry.api" [tool.commitizen] -version = "0.1.29" +version = "0.1.31" version_files = [ "pyproject.toml:version", "../requirements.txt:litellm-enterprise==", diff --git a/litellm-js/spend-logs/package.json b/litellm-js/spend-logs/package.json index 9c1c2d4f6dc..67292567145 100644 --- a/litellm-js/spend-logs/package.json +++ b/litellm-js/spend-logs/package.json @@ -11,6 +11,8 @@ "tsx": "^4.7.1" }, "overrides": { - "glob": ">=11.1.0" + "glob": ">=11.1.0", + "tar": ">=7.5.7", + "@isaacs/brace-expansion": ">=5.0.1" } } diff --git a/litellm-proxy-extras/dist/litellm_proxy_extras-0.4.32-py3-none-any.whl b/litellm-proxy-extras/dist/litellm_proxy_extras-0.4.32-py3-none-any.whl new file mode 100644 index 00000000000..deb9653aa78 Binary files /dev/null and b/litellm-proxy-extras/dist/litellm_proxy_extras-0.4.32-py3-none-any.whl differ diff --git a/litellm-proxy-extras/dist/litellm_proxy_extras-0.4.32.tar.gz b/litellm-proxy-extras/dist/litellm_proxy_extras-0.4.32.tar.gz new file mode 100644 index 00000000000..212194e31e2 Binary files /dev/null and b/litellm-proxy-extras/dist/litellm_proxy_extras-0.4.32.tar.gz differ diff --git a/litellm-proxy-extras/dist/litellm_proxy_extras-0.4.33-py3-none-any.whl b/litellm-proxy-extras/dist/litellm_proxy_extras-0.4.33-py3-none-any.whl new file mode 100644 index 00000000000..a4872243ae6 Binary files /dev/null and b/litellm-proxy-extras/dist/litellm_proxy_extras-0.4.33-py3-none-any.whl differ diff --git a/litellm-proxy-extras/dist/litellm_proxy_extras-0.4.33.tar.gz b/litellm-proxy-extras/dist/litellm_proxy_extras-0.4.33.tar.gz new file mode 100644 index 00000000000..643be22aa42 Binary files /dev/null and b/litellm-proxy-extras/dist/litellm_proxy_extras-0.4.33.tar.gz differ diff --git a/litellm-proxy-extras/dist/litellm_proxy_extras-0.4.34-py3-none-any.whl b/litellm-proxy-extras/dist/litellm_proxy_extras-0.4.34-py3-none-any.whl new file mode 100644 index 00000000000..175d84543ec Binary files /dev/null and b/litellm-proxy-extras/dist/litellm_proxy_extras-0.4.34-py3-none-any.whl differ diff --git a/litellm-proxy-extras/dist/litellm_proxy_extras-0.4.34.tar.gz b/litellm-proxy-extras/dist/litellm_proxy_extras-0.4.34.tar.gz new file mode 100644 index 00000000000..e1fcc0c603f Binary files /dev/null and b/litellm-proxy-extras/dist/litellm_proxy_extras-0.4.34.tar.gz differ diff --git a/litellm-proxy-extras/litellm_proxy_extras/migrations/20260207093506_add_available_on_public_internet_to_mcp_servers/migration.sql b/litellm-proxy-extras/litellm_proxy_extras/migrations/20260207093506_add_available_on_public_internet_to_mcp_servers/migration.sql new file mode 100644 index 00000000000..1efde3dbe0f --- /dev/null +++ b/litellm-proxy-extras/litellm_proxy_extras/migrations/20260207093506_add_available_on_public_internet_to_mcp_servers/migration.sql @@ -0,0 +1,3 @@ +-- AlterTable +ALTER TABLE "LiteLLM_MCPServerTable" ADD COLUMN "available_on_public_internet" BOOLEAN NOT NULL DEFAULT false; + diff --git a/litellm-proxy-extras/litellm_proxy_extras/migrations/20260207110613_add_soft_budget_to_deleted_teams_table/migration.sql b/litellm-proxy-extras/litellm_proxy_extras/migrations/20260207110613_add_soft_budget_to_deleted_teams_table/migration.sql new file mode 100644 index 00000000000..abfb153061b --- /dev/null +++ b/litellm-proxy-extras/litellm_proxy_extras/migrations/20260207110613_add_soft_budget_to_deleted_teams_table/migration.sql @@ -0,0 +1,3 @@ +-- AlterTable +ALTER TABLE "LiteLLM_DeletedTeamTable" ADD COLUMN "soft_budget" DOUBLE PRECISION; + diff --git a/litellm-proxy-extras/litellm_proxy_extras/migrations/20260209085821_add_verificationtoken_indexes/migration.sql b/litellm-proxy-extras/litellm_proxy_extras/migrations/20260209085821_add_verificationtoken_indexes/migration.sql new file mode 100644 index 00000000000..572eea9b529 --- /dev/null +++ b/litellm-proxy-extras/litellm_proxy_extras/migrations/20260209085821_add_verificationtoken_indexes/migration.sql @@ -0,0 +1,8 @@ +-- CreateIndex +CREATE INDEX "LiteLLM_VerificationToken_user_id_team_id_idx" ON "LiteLLM_VerificationToken"("user_id", "team_id"); + +-- CreateIndex +CREATE INDEX "LiteLLM_VerificationToken_team_id_idx" ON "LiteLLM_VerificationToken"("team_id"); + +-- CreateIndex +CREATE INDEX "LiteLLM_VerificationToken_budget_reset_at_expires_idx" ON "LiteLLM_VerificationToken"("budget_reset_at", "expires"); diff --git a/litellm-proxy-extras/litellm_proxy_extras/schema.prisma b/litellm-proxy-extras/litellm_proxy_extras/schema.prisma index e713e6ca87a..558dfcc9517 100644 --- a/litellm-proxy-extras/litellm_proxy_extras/schema.prisma +++ b/litellm-proxy-extras/litellm_proxy_extras/schema.prisma @@ -148,6 +148,7 @@ model LiteLLM_DeletedTeamTable { members_with_roles Json @default("{}") metadata Json @default("{}") max_budget Float? + soft_budget Float? spend Float @default(0.0) models String[] max_parallel_requests Int? @@ -263,6 +264,7 @@ model LiteLLM_MCPServerTable { token_url String? registration_url String? allow_all_keys Boolean @default(false) + available_on_public_internet Boolean @default(false) } // Generate Tokens for Proxy @@ -308,6 +310,16 @@ model LiteLLM_VerificationToken { litellm_budget_table LiteLLM_BudgetTable? @relation(fields: [budget_id], references: [budget_id]) litellm_organization_table LiteLLM_OrganizationTable? @relation(fields: [organization_id], references: [organization_id]) object_permission LiteLLM_ObjectPermissionTable? @relation(fields: [object_permission_id], references: [object_permission_id]) + + // SELECT COUNT(*) FROM (SELECT "public"."LiteLLM_VerificationToken"."token" FROM "public"."LiteLLM_VerificationToken" WHERE ("public"."LiteLLM_VerificationToken"."user_id" = $1 AND ("public"."LiteLLM_VerificationToken"."team_id" IS NULL OR "public"."LiteLLM_VerificationToken"."team_id" <> $2)) OFFSET $3 ) AS "sub" + // SELECT ... FROM "public"."LiteLLM_VerificationToken" WHERE "public"."LiteLLM_VerificationToken"."user_id" = $1 OFFSET $2 + @@index([user_id, team_id]) + + // SELECT ... FROM "public"."LiteLLM_VerificationToken" WHERE "public"."LiteLLM_VerificationToken"."team_id" = $1 OFFSET $2 + @@index([team_id]) + + // SELECT ... FROM "public"."LiteLLM_VerificationToken" WHERE (("public"."LiteLLM_VerificationToken"."expires" IS NULL OR "public"."LiteLLM_VerificationToken"."expires" > $1) AND "public"."LiteLLM_VerificationToken"."budget_reset_at" < $2) OFFSET $3 + @@index([budget_reset_at, expires]) } // Audit table for deleted keys - preserves spend and key information for historical tracking @@ -902,6 +914,7 @@ model LiteLLM_PolicyAttachmentTable { teams String[] @default([]) // Team aliases or patterns keys String[] @default([]) // Key aliases or patterns models String[] @default([]) // Model names or patterns + tags String[] @default([]) // Tag patterns (e.g., ["healthcare", "prod-*"]) created_at DateTime @default(now()) created_by String? updated_at DateTime @default(now()) @updatedAt diff --git a/litellm-proxy-extras/pyproject.toml b/litellm-proxy-extras/pyproject.toml index 0e72cd90813..e0a769a5edf 100644 --- a/litellm-proxy-extras/pyproject.toml +++ b/litellm-proxy-extras/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "litellm-proxy-extras" -version = "0.4.31" +version = "0.4.34" description = "Additional files for the LiteLLM Proxy. Reduces the size of the main litellm package." authors = ["BerriAI"] readme = "README.md" @@ -22,7 +22,7 @@ requires = ["poetry-core"] build-backend = "poetry.core.masonry.api" [tool.commitizen] -version = "0.4.31" +version = "0.4.34" version_files = [ "pyproject.toml:version", "../requirements.txt:litellm-proxy-extras==", diff --git a/litellm/__init__.py b/litellm/__init__.py index 8174b9d2655..538ee727612 100644 --- a/litellm/__init__.py +++ b/litellm/__init__.py @@ -1155,6 +1155,7 @@ from .exceptions import ( BadRequestError, ImageFetchError, NotFoundError, + PermissionDeniedError, RateLimitError, ServiceUnavailableError, BadGatewayError, @@ -1393,6 +1394,7 @@ if TYPE_CHECKING: from .llms.litellm_proxy.responses.transformation import LiteLLMProxyResponsesAPIConfig as LiteLLMProxyResponsesAPIConfig from .llms.volcengine.responses.transformation import VolcEngineResponsesAPIConfig as VolcEngineResponsesAPIConfig from .llms.manus.responses.transformation import ManusResponsesAPIConfig as ManusResponsesAPIConfig + from .llms.perplexity.responses.transformation import PerplexityResponsesConfig as PerplexityResponsesConfig from .llms.gemini.interactions.transformation import GoogleAIStudioInteractionsConfig as GoogleAIStudioInteractionsConfig from .llms.openai.chat.o_series_transformation import OpenAIOSeriesConfig as OpenAIOSeriesConfig, OpenAIOSeriesConfig as OpenAIO1Config from .llms.anthropic.skills.transformation import AnthropicSkillsConfig as AnthropicSkillsConfig diff --git a/litellm/_lazy_imports_registry.py b/litellm/_lazy_imports_registry.py index a01fe9c11db..ebe9af9d85c 100644 --- a/litellm/_lazy_imports_registry.py +++ b/litellm/_lazy_imports_registry.py @@ -226,6 +226,7 @@ LLM_CONFIG_NAMES = ( "XAIResponsesAPIConfig", "LiteLLMProxyResponsesAPIConfig", "VolcEngineResponsesAPIConfig", + "PerplexityResponsesConfig", "GoogleAIStudioInteractionsConfig", "OpenAIOSeriesConfig", "AnthropicSkillsConfig", @@ -274,6 +275,7 @@ LLM_CONFIG_NAMES = ( "LmStudioEmbeddingConfig", "NscaleConfig", "PerplexityChatConfig", + "PerplexityResponsesConfig", "AzureOpenAIO1Config", "IBMWatsonXAIConfig", "IBMWatsonXChatConfig", @@ -901,6 +903,10 @@ _LLM_CONFIGS_IMPORT_MAP = { ".llms.manus.responses.transformation", "ManusResponsesAPIConfig", ), + "PerplexityResponsesConfig": ( + ".llms.perplexity.responses.transformation", + "PerplexityResponsesConfig", + ), "GoogleAIStudioInteractionsConfig": ( ".llms.gemini.interactions.transformation", "GoogleAIStudioInteractionsConfig", diff --git a/litellm/_logging.py b/litellm/_logging.py index e222627e76c..fd833f7056a 100644 --- a/litellm/_logging.py +++ b/litellm/_logging.py @@ -1,9 +1,13 @@ -import json +import ast import logging import os import sys from datetime import datetime from logging import Formatter +from typing import Any, Dict, Optional + +from litellm.litellm_core_utils.safe_json_dumps import safe_dumps +from litellm.litellm_core_utils.safe_json_loads import safe_json_loads set_verbose = False @@ -19,6 +23,67 @@ handler = logging.StreamHandler() handler.setLevel(numeric_level) +def _try_parse_json_message(message: str) -> Optional[Dict[str, Any]]: + """ + Try to parse a log message as JSON. Returns parsed dict if valid, else None. + Handles messages that are entirely valid JSON (e.g. json.dumps output). + Uses shared safe_json_loads for consistent error handling. + """ + if not message or not isinstance(message, str): + return None + msg_stripped = message.strip() + if not (msg_stripped.startswith("{") or msg_stripped.startswith("[")): + return None + parsed = safe_json_loads(message, default=None) + if parsed is None or not isinstance(parsed, dict): + return None + return parsed + + +def _try_parse_embedded_python_dict(message: str) -> Optional[Dict[str, Any]]: + """ + Try to find and parse a Python dict repr (e.g. str(d) or repr(d)) embedded in + the message. Handles patterns like: + "get_available_deployment for model: X, Selected deployment: {'model_name': '...', ...} for model: X" + Uses ast.literal_eval for safe parsing. Returns the parsed dict or None. + """ + if not message or not isinstance(message, str) or "{" not in message: + return None + i = 0 + while i < len(message): + start = message.find("{", i) + if start == -1: + break + depth = 0 + for j in range(start, len(message)): + c = message[j] + if c == "{": + depth += 1 + elif c == "}": + depth -= 1 + if depth == 0: + substr = message[start : j + 1] + try: + result = ast.literal_eval(substr) + if isinstance(result, dict) and len(result) > 0: + return result + except (ValueError, SyntaxError, TypeError): + pass + break + i = start + 1 + return None + + +# Standard LogRecord attribute names - used to identify 'extra' fields. +# Derived at runtime so we automatically include version-specific attrs (e.g. taskName). +def _get_standard_record_attrs() -> frozenset: + """Standard LogRecord attribute names - excludes extra keys from logger.debug(..., extra={...}).""" + return frozenset(logging.LogRecord("", 0, "", 0, "", (), None).__dict__.keys()) + + +_STANDARD_RECORD_ATTRS = _get_standard_record_attrs() + + class JsonFormatter(Formatter): def __init__(self): super(JsonFormatter, self).__init__() @@ -29,16 +94,31 @@ class JsonFormatter(Formatter): return dt.isoformat() def format(self, record): - json_record = { - "message": record.getMessage(), + message_str = record.getMessage() + json_record: Dict[str, Any] = { + "message": message_str, "level": record.levelname, "timestamp": self.formatTime(record), } + # Parse embedded JSON or Python dict repr in message so sub-fields become first-class properties + parsed = _try_parse_json_message(message_str) + if parsed is None: + parsed = _try_parse_embedded_python_dict(message_str) + if parsed is not None: + for key, value in parsed.items(): + if key not in json_record: + json_record[key] = value + + # Include extra attributes passed via logger.debug("msg", extra={...}) + for key, value in record.__dict__.items(): + if key not in _STANDARD_RECORD_ATTRS and key not in json_record: + json_record[key] = value + if record.exc_info: json_record["stacktrace"] = self.formatException(record.exc_info) - return json.dumps(json_record) + return safe_dumps(json_record) # Function to set up exception handlers for JSON logging @@ -169,15 +249,15 @@ def _initialize_loggers_with_handler(handler: logging.Handler): def _get_uvicorn_json_log_config(): """ Generate a uvicorn log_config dictionary that applies JSON formatting to all loggers. - + This ensures that uvicorn's access logs, error logs, and all application logs are formatted as JSON when json_logs is enabled. """ json_formatter_class = "litellm._logging.JsonFormatter" - + # Use the module-level log_level variable for consistency uvicorn_log_level = log_level.upper() - + log_config = { "version": 1, "disable_existing_loggers": False, @@ -222,7 +302,7 @@ def _get_uvicorn_json_log_config(): }, }, } - + return log_config diff --git a/litellm/a2a_protocol/__init__.py b/litellm/a2a_protocol/__init__.py index d8d349bb98a..85c03687e25 100644 --- a/litellm/a2a_protocol/__init__.py +++ b/litellm/a2a_protocol/__init__.py @@ -39,6 +39,12 @@ Example usage (class-based): """ from litellm.a2a_protocol.client import A2AClient +from litellm.a2a_protocol.exceptions import ( + A2AAgentCardError, + A2AConnectionError, + A2AError, + A2ALocalhostURLError, +) from litellm.a2a_protocol.main import ( aget_agent_card, asend_message, @@ -49,11 +55,19 @@ from litellm.a2a_protocol.main import ( from litellm.types.agents import LiteLLMSendMessageResponse __all__ = [ + # Client "A2AClient", + # Functions "asend_message", "send_message", "asend_message_streaming", "aget_agent_card", "create_a2a_client", + # Response types "LiteLLMSendMessageResponse", + # Exceptions + "A2AError", + "A2AConnectionError", + "A2AAgentCardError", + "A2ALocalhostURLError", ] diff --git a/litellm/a2a_protocol/card_resolver.py b/litellm/a2a_protocol/card_resolver.py index 7c4c5af149d..4c5dd3e3ba6 100644 --- a/litellm/a2a_protocol/card_resolver.py +++ b/litellm/a2a_protocol/card_resolver.py @@ -7,6 +7,7 @@ Extends the A2A SDK's card resolver to support multiple well-known paths. from typing import TYPE_CHECKING, Any, Dict, Optional from litellm._logging import verbose_logger +from litellm.constants import LOCALHOST_URL_PATTERNS if TYPE_CHECKING: from a2a.types import AgentCard @@ -26,15 +27,61 @@ except ImportError: pass +def is_localhost_or_internal_url(url: Optional[str]) -> bool: + """ + Check if a URL is a localhost or internal URL. + + This detects common development URLs that are accidentally left in + agent cards when deploying to production. + + Args: + url: The URL to check + + Returns: + True if the URL is localhost/internal + """ + if not url: + return False + + url_lower = url.lower() + + return any(pattern in url_lower for pattern in LOCALHOST_URL_PATTERNS) + + +def fix_agent_card_url(agent_card: "AgentCard", base_url: str) -> "AgentCard": + """ + Fix the agent card URL if it contains a localhost/internal address. + + Many A2A agents are deployed with agent cards that contain internal URLs + like "http://0.0.0.0:8001/" or "http://localhost:8000/". This function + replaces such URLs with the provided base_url. + + Args: + agent_card: The agent card to fix + base_url: The base URL to use as replacement + + Returns: + The agent card with the URL fixed if necessary + """ + card_url = getattr(agent_card, "url", None) + + if card_url and is_localhost_or_internal_url(card_url): + # Normalize base_url to ensure it ends with / + fixed_url = base_url.rstrip("/") + "/" + agent_card.url = fixed_url + + return agent_card + + class LiteLLMA2ACardResolver(_A2ACardResolver): # type: ignore[misc] """ Custom A2A card resolver that supports multiple well-known paths. - + Extends the base A2ACardResolver to try both: - /.well-known/agent-card.json (standard) - /.well-known/agent.json (previous/alternative) """ - + async def get_agent_card( self, relative_card_path: Optional[str] = None, @@ -42,17 +89,17 @@ class LiteLLMA2ACardResolver(_A2ACardResolver): # type: ignore[misc] ) -> "AgentCard": """ Fetch the agent card, trying multiple well-known paths. - + First tries the standard path, then falls back to the previous path. - + Args: relative_card_path: Optional path to the agent card endpoint. If None, tries both well-known paths. http_kwargs: Optional dictionary of keyword arguments to pass to httpx.get - + Returns: AgentCard from the A2A agent - + Raises: A2AClientHTTPError or A2AClientJSONError if both paths fail """ @@ -62,13 +109,13 @@ class LiteLLMA2ACardResolver(_A2ACardResolver): # type: ignore[misc] relative_card_path=relative_card_path, http_kwargs=http_kwargs, ) - + # Try both well-known paths paths = [ AGENT_CARD_WELL_KNOWN_PATH, PREV_AGENT_CARD_WELL_KNOWN_PATH, ] - + last_error = None for path in paths: try: @@ -85,11 +132,11 @@ class LiteLLMA2ACardResolver(_A2ACardResolver): # type: ignore[misc] ) last_error = e continue - + # If we get here, all paths failed - re-raise the last error if last_error is not None: raise last_error - + # This shouldn't happen, but just in case raise Exception( f"Failed to fetch agent card from {self.base_url}. " diff --git a/litellm/a2a_protocol/exception_mapping_utils.py b/litellm/a2a_protocol/exception_mapping_utils.py new file mode 100644 index 00000000000..49dbb22b158 --- /dev/null +++ b/litellm/a2a_protocol/exception_mapping_utils.py @@ -0,0 +1,203 @@ +""" +A2A Protocol Exception Mapping Utils. + +Maps A2A SDK exceptions to LiteLLM A2A exception types. +""" + +from typing import TYPE_CHECKING, Any, Optional + +from litellm._logging import verbose_logger +from litellm.a2a_protocol.card_resolver import ( + fix_agent_card_url, + is_localhost_or_internal_url, +) +from litellm.a2a_protocol.exceptions import ( + A2AAgentCardError, + A2AConnectionError, + A2AError, + A2ALocalhostURLError, +) +from litellm.constants import CONNECTION_ERROR_PATTERNS + +if TYPE_CHECKING: + from a2a.client import A2AClient as A2AClientType + + +# Runtime import +A2A_SDK_AVAILABLE = False +try: + from a2a.client import A2AClient as _A2AClient # type: ignore[no-redef] + + A2A_SDK_AVAILABLE = True +except ImportError: + _A2AClient = None # type: ignore[assignment, misc] + + +class A2AExceptionCheckers: + """ + Helper class for checking various A2A error conditions. + """ + + @staticmethod + def is_connection_error(error_str: str) -> bool: + """ + Check if an error string indicates a connection error. + + Args: + error_str: The error string to check + + Returns: + True if the error indicates a connection issue + """ + if not isinstance(error_str, str): + return False + + error_str_lower = error_str.lower() + return any(pattern in error_str_lower for pattern in CONNECTION_ERROR_PATTERNS) + + @staticmethod + def is_localhost_url(url: Optional[str]) -> bool: + """ + Check if a URL is a localhost/internal URL. + + Args: + url: The URL to check + + Returns: + True if the URL is localhost/internal + """ + return is_localhost_or_internal_url(url) + + @staticmethod + def is_agent_card_error(error_str: str) -> bool: + """ + Check if an error string indicates an agent card error. + + Args: + error_str: The error string to check + + Returns: + True if the error is related to agent card fetching/parsing + """ + if not isinstance(error_str, str): + return False + + error_str_lower = error_str.lower() + agent_card_patterns = [ + "agent card", + "agent-card", + ".well-known", + "card not found", + "invalid agent", + ] + return any(pattern in error_str_lower for pattern in agent_card_patterns) + + +def map_a2a_exception( + original_exception: Exception, + card_url: Optional[str] = None, + api_base: Optional[str] = None, + model: Optional[str] = None, +) -> Exception: + """ + Map an A2A SDK exception to a LiteLLM A2A exception type. + + Args: + original_exception: The original exception from the A2A SDK + card_url: The URL from the agent card (if available) + api_base: The original API base URL + model: The model/agent name + + Returns: + A mapped LiteLLM A2A exception + + Raises: + A2ALocalhostURLError: If the error is a connection error to a localhost URL + A2AConnectionError: If the error is a general connection error + A2AAgentCardError: If the error is related to agent card issues + A2AError: For other A2A-related errors + """ + error_str = str(original_exception) + + # Check for localhost URL connection error (special case - retryable) + if ( + card_url + and api_base + and A2AExceptionCheckers.is_localhost_url(card_url) + and A2AExceptionCheckers.is_connection_error(error_str) + ): + raise A2ALocalhostURLError( + localhost_url=card_url, + base_url=api_base, + original_error=original_exception, + model=model, + ) + + # Check for agent card errors + if A2AExceptionCheckers.is_agent_card_error(error_str): + raise A2AAgentCardError( + message=error_str, + url=api_base, + model=model, + ) + + # Check for general connection errors + if A2AExceptionCheckers.is_connection_error(error_str): + raise A2AConnectionError( + message=error_str, + url=card_url or api_base, + model=model, + ) + + # Default: wrap in generic A2AError + raise A2AError( + message=error_str, + model=model, + ) + + +def handle_a2a_localhost_retry( + error: A2ALocalhostURLError, + agent_card: Any, + a2a_client: "A2AClientType", + is_streaming: bool = False, +) -> "A2AClientType": + """ + Handle A2ALocalhostURLError by fixing the URL and creating a new client. + + This is called when we catch an A2ALocalhostURLError and want to retry + with the corrected URL. + + Args: + error: The localhost URL error + agent_card: The agent card object to fix + a2a_client: The current A2A client + is_streaming: Whether this is a streaming request (for logging) + + Returns: + A new A2A client with the fixed URL + + Raises: + ImportError: If the A2A SDK is not installed + """ + if not A2A_SDK_AVAILABLE or _A2AClient is None: + raise ImportError( + "A2A SDK is required for localhost retry handling. " + "Install it with: pip install a2a" + ) + + request_type = "streaming " if is_streaming else "" + verbose_logger.warning( + f"A2A {request_type}request to '{error.localhost_url}' failed: {error.original_error}. " + f"Agent card contains localhost/internal URL. " + f"Retrying with base_url '{error.base_url}'." + ) + + # Fix the agent card URL + fix_agent_card_url(agent_card, error.base_url) + + # Create a new client with the fixed agent card (transport caches URL) + return _A2AClient( + httpx_client=a2a_client._transport.httpx_client, # type: ignore[union-attr] + agent_card=agent_card, + ) diff --git a/litellm/a2a_protocol/exceptions.py b/litellm/a2a_protocol/exceptions.py new file mode 100644 index 00000000000..546b23105be --- /dev/null +++ b/litellm/a2a_protocol/exceptions.py @@ -0,0 +1,150 @@ +""" +A2A Protocol Exceptions. + +Custom exception types for A2A protocol operations, following LiteLLM's exception pattern. +""" + +from typing import Optional + +import httpx + + +class A2AError(Exception): + """ + Base exception for A2A protocol errors. + + Follows the same pattern as LiteLLM's main exceptions. + """ + + def __init__( + self, + message: str, + status_code: int = 500, + llm_provider: str = "a2a_agent", + model: Optional[str] = None, + response: Optional[httpx.Response] = None, + litellm_debug_info: Optional[str] = None, + max_retries: Optional[int] = None, + num_retries: Optional[int] = None, + ): + self.status_code = status_code + self.message = f"litellm.A2AError: {message}" + self.llm_provider = llm_provider + self.model = model + self.litellm_debug_info = litellm_debug_info + self.max_retries = max_retries + self.num_retries = num_retries + self.response = response or httpx.Response( + status_code=self.status_code, + request=httpx.Request(method="POST", url="https://litellm.ai"), + ) + super().__init__(self.message) + + def __str__(self) -> str: + _message = self.message + if self.num_retries: + _message += f" LiteLLM Retried: {self.num_retries} times" + if self.max_retries: + _message += f", LiteLLM Max Retries: {self.max_retries}" + return _message + + def __repr__(self) -> str: + return self.__str__() + + +class A2AConnectionError(A2AError): + """ + Raised when connection to an A2A agent fails. + + This typically occurs when: + - The agent is unreachable + - The agent card contains a localhost/internal URL + - Network issues prevent connection + """ + + def __init__( + self, + message: str, + url: Optional[str] = None, + model: Optional[str] = None, + response: Optional[httpx.Response] = None, + litellm_debug_info: Optional[str] = None, + max_retries: Optional[int] = None, + num_retries: Optional[int] = None, + ): + self.url = url + super().__init__( + message=message, + status_code=503, + llm_provider="a2a_agent", + model=model, + response=response, + litellm_debug_info=litellm_debug_info, + max_retries=max_retries, + num_retries=num_retries, + ) + + +class A2AAgentCardError(A2AError): + """ + Raised when there's an issue with the agent card. + + This includes: + - Failed to fetch agent card + - Invalid agent card format + - Missing required fields + """ + + def __init__( + self, + message: str, + url: Optional[str] = None, + model: Optional[str] = None, + response: Optional[httpx.Response] = None, + litellm_debug_info: Optional[str] = None, + ): + self.url = url + super().__init__( + message=message, + status_code=404, + llm_provider="a2a_agent", + model=model, + response=response, + litellm_debug_info=litellm_debug_info, + ) + + +class A2ALocalhostURLError(A2AConnectionError): + """ + Raised when an agent card contains a localhost/internal URL. + + Many A2A agents are deployed with agent cards that contain internal URLs + like "http://0.0.0.0:8001/" or "http://localhost:8000/". This error + indicates that the URL needs to be corrected and the request should be retried. + + Attributes: + localhost_url: The localhost/internal URL found in the agent card + base_url: The public base URL that should be used instead + original_error: The original connection error that was raised + """ + + def __init__( + self, + localhost_url: str, + base_url: str, + original_error: Optional[Exception] = None, + model: Optional[str] = None, + ): + self.localhost_url = localhost_url + self.base_url = base_url + self.original_error = original_error + + message = ( + f"Agent card contains localhost/internal URL '{localhost_url}'. " + f"Retrying with base URL '{base_url}'." + ) + super().__init__( + message=message, + url=localhost_url, + model=model, + ) diff --git a/litellm/a2a_protocol/main.py b/litellm/a2a_protocol/main.py index b326f9e7ed5..642dfaf023c 100644 --- a/litellm/a2a_protocol/main.py +++ b/litellm/a2a_protocol/main.py @@ -44,6 +44,11 @@ except ImportError: # Import our custom card resolver that supports multiple well-known paths from litellm.a2a_protocol.card_resolver import LiteLLMA2ACardResolver +from litellm.a2a_protocol.exception_mapping_utils import ( + handle_a2a_localhost_retry, + map_a2a_exception, +) +from litellm.a2a_protocol.exceptions import A2ALocalhostURLError # Use our custom resolver instead of the default A2A SDK resolver A2ACardResolver = LiteLLMA2ACardResolver @@ -244,10 +249,50 @@ async def asend_message( verbose_logger.info(f"A2A send_message request_id={request.id}, agent={agent_name}") - a2a_response = await a2a_client.send_message(request) + # Get agent card URL for localhost retry logic + agent_card = getattr(a2a_client, "_litellm_agent_card", None) or getattr( + a2a_client, "agent_card", None + ) + card_url = getattr(agent_card, "url", None) if agent_card else None + + # Retry loop: if connection fails due to localhost URL in agent card, retry with fixed URL + a2a_response = None + for _ in range(2): # max 2 attempts: original + 1 retry + try: + a2a_response = await a2a_client.send_message(request) + break # success, exit retry loop + except A2ALocalhostURLError as e: + # Localhost URL error - fix and retry + a2a_client = handle_a2a_localhost_retry( + error=e, + agent_card=agent_card, + a2a_client=a2a_client, + is_streaming=False, + ) + card_url = agent_card.url if agent_card else None + except Exception as e: + # Map exception - will raise A2ALocalhostURLError if applicable + try: + map_a2a_exception(e, card_url, api_base, model=agent_name) + except A2ALocalhostURLError as localhost_err: + # Localhost URL error - fix and retry + a2a_client = handle_a2a_localhost_retry( + error=localhost_err, + agent_card=agent_card, + a2a_client=a2a_client, + is_streaming=False, + ) + card_url = agent_card.url if agent_card else None + continue + except Exception: + # Re-raise the mapped exception + raise verbose_logger.info(f"A2A send_message completed, request_id={request.id}") + # a2a_response is guaranteed to be set if we reach here (loop breaks on success or raises) + assert a2a_response is not None + # Wrap in LiteLLM response type for _hidden_params support response = LiteLLMSendMessageResponse.from_a2a_response(a2a_response) @@ -307,6 +352,48 @@ def send_message( ) +def _build_streaming_logging_obj( + request: "SendStreamingMessageRequest", + agent_name: str, + agent_id: Optional[str], + litellm_params: Optional[Dict[str, Any]], + metadata: Optional[Dict[str, Any]], + proxy_server_request: Optional[Dict[str, Any]], +) -> Logging: + """Build logging object for streaming A2A requests.""" + start_time = datetime.datetime.now() + model = f"a2a_agent/{agent_name}" + + logging_obj = Logging( + model=model, + messages=[{"role": "user", "content": "streaming-request"}], + stream=False, + call_type="asend_message_streaming", + start_time=start_time, + litellm_call_id=str(request.id), + function_id=str(request.id), + ) + logging_obj.model = model + logging_obj.custom_llm_provider = "a2a_agent" + logging_obj.model_call_details["model"] = model + logging_obj.model_call_details["custom_llm_provider"] = "a2a_agent" + if agent_id: + logging_obj.model_call_details["agent_id"] = agent_id + + _litellm_params = litellm_params.copy() if litellm_params else {} + if metadata: + _litellm_params["metadata"] = metadata + if proxy_server_request: + _litellm_params["proxy_server_request"] = proxy_server_request + + logging_obj.litellm_params = _litellm_params + logging_obj.optional_params = _litellm_params + logging_obj.model_call_details["litellm_params"] = _litellm_params + logging_obj.model_call_details["metadata"] = metadata or {} + + return logging_obj + + async def asend_message_streaming( a2a_client: Optional["A2AClientType"] = None, request: Optional["SendStreamingMessageRequest"] = None, @@ -403,55 +490,72 @@ async def asend_message_streaming( verbose_logger.info(f"A2A send_message_streaming request_id={request.id}") - # Track for logging - start_time = datetime.datetime.now() - stream = a2a_client.send_message_streaming(request) - # Build logging object for streaming completion callbacks agent_card = getattr(a2a_client, "_litellm_agent_card", None) or getattr( a2a_client, "agent_card", None ) + card_url = getattr(agent_card, "url", None) if agent_card else None agent_name = getattr(agent_card, "name", "unknown") if agent_card else "unknown" - model = f"a2a_agent/{agent_name}" - logging_obj = Logging( - model=model, - messages=[{"role": "user", "content": "streaming-request"}], - stream=False, # complete response logging after stream ends - call_type="asend_message_streaming", - start_time=start_time, - litellm_call_id=str(request.id), - function_id=str(request.id), - ) - logging_obj.model = model - logging_obj.custom_llm_provider = "a2a_agent" - logging_obj.model_call_details["model"] = model - logging_obj.model_call_details["custom_llm_provider"] = "a2a_agent" - if agent_id: - logging_obj.model_call_details["agent_id"] = agent_id - - # Propagate litellm_params for spend logging (includes cost_per_query, etc.) - _litellm_params = litellm_params.copy() if litellm_params else {} - # Merge metadata into litellm_params.metadata (required for proxy cost tracking) - if metadata: - _litellm_params["metadata"] = metadata - if proxy_server_request: - _litellm_params["proxy_server_request"] = proxy_server_request - - logging_obj.litellm_params = _litellm_params - logging_obj.optional_params = _litellm_params # used by cost calc - logging_obj.model_call_details["litellm_params"] = _litellm_params - logging_obj.model_call_details["metadata"] = metadata or {} - - iterator = A2AStreamingIterator( - stream=stream, + logging_obj = _build_streaming_logging_obj( request=request, - logging_obj=logging_obj, agent_name=agent_name, + agent_id=agent_id, + litellm_params=litellm_params, + metadata=metadata, + proxy_server_request=proxy_server_request, ) - async for chunk in iterator: - yield chunk + # Retry loop: if connection fails due to localhost URL in agent card, retry with fixed URL + # Connection errors in streaming typically occur on first chunk iteration + first_chunk = True + for attempt in range(2): # max 2 attempts: original + 1 retry + stream = a2a_client.send_message_streaming(request) + iterator = A2AStreamingIterator( + stream=stream, + request=request, + logging_obj=logging_obj, + agent_name=agent_name, + ) + + try: + first_chunk = True + async for chunk in iterator: + if first_chunk: + first_chunk = False # connection succeeded + yield chunk + return # stream completed successfully + except A2ALocalhostURLError as e: + # Only retry on first chunk, not mid-stream + if first_chunk and attempt == 0: + a2a_client = handle_a2a_localhost_retry( + error=e, + agent_card=agent_card, + a2a_client=a2a_client, + is_streaming=True, + ) + card_url = agent_card.url if agent_card else None + else: + raise + except Exception as e: + # Only map exception on first chunk + if first_chunk and attempt == 0: + try: + map_a2a_exception(e, card_url, api_base, model=agent_name) + except A2ALocalhostURLError as localhost_err: + # Localhost URL error - fix and retry + a2a_client = handle_a2a_localhost_retry( + error=localhost_err, + agent_card=agent_card, + a2a_client=a2a_client, + is_streaming=True, + ) + card_url = agent_card.url if agent_card else None + continue + except Exception: + # Re-raise the mapped exception + raise + raise async def create_a2a_client( diff --git a/litellm/anthropic_beta_headers_config.json b/litellm/anthropic_beta_headers_config.json new file mode 100644 index 00000000000..5edb8067a08 --- /dev/null +++ b/litellm/anthropic_beta_headers_config.json @@ -0,0 +1,151 @@ +{ + "description": "Mapping of Anthropic beta headers for each provider. Keys are input header names, values are provider-specific header names (or null if unsupported). Only headers present in mapping keys with non-null values can be forwarded.", + "anthropic": { + "advanced-tool-use-2025-11-20": "advanced-tool-use-2025-11-20", + "bash_20241022": "bash_20241022", + "bash_20250124": "bash_20250124", + "code-execution-2025-08-25": "code-execution-2025-08-25", + "compact-2026-01-12": "compact-2026-01-12", + "computer-use-2025-01-24": "computer-use-2025-01-24", + "computer-use-2025-11-24": "computer-use-2025-11-24", + "context-1m-2025-08-07": "context-1m-2025-08-07", + "context-management-2025-06-27": "context-management-2025-06-27", + "effort-2025-11-24": "effort-2025-11-24", + "fast-mode-2026-02-01": "fast-mode-2026-02-01", + "files-api-2025-04-14": "files-api-2025-04-14", + "structured-output-2024-03-01": "structured-output-2024-03-01", + "fine-grained-tool-streaming-2025-05-14": "fine-grained-tool-streaming-2025-05-14", + "interleaved-thinking-2025-05-14": "interleaved-thinking-2025-05-14", + "mcp-client-2025-11-20": "mcp-client-2025-11-20", + "mcp-client-2025-04-04": "mcp-client-2025-04-04", + "mcp-servers-2025-12-04": "mcp-servers-2025-12-04", + "output-128k-2025-02-19": "output-128k-2025-02-19", + "prompt-caching-scope-2026-01-05": "prompt-caching-scope-2026-01-05", + "skills-2025-10-02": "skills-2025-10-02", + "structured-outputs-2025-11-13": "structured-outputs-2025-11-13", + "text_editor_20241022": "text_editor_20241022", + "text_editor_20250124": "text_editor_20250124", + "token-efficient-tools-2025-02-19": "token-efficient-tools-2025-02-19", + "web-fetch-2025-09-10": "web-fetch-2025-09-10", + "web-search-2025-03-05": "web-search-2025-03-05" + }, + "azure_ai": { + "advanced-tool-use-2025-11-20": "advanced-tool-use-2025-11-20", + "bash_20241022": "bash_20241022", + "bash_20250124": "bash_20250124", + "code-execution-2025-08-25": "code-execution-2025-08-25", + "compact-2026-01-12": null, + "computer-use-2025-01-24": "computer-use-2025-01-24", + "computer-use-2025-11-24": "computer-use-2025-11-24", + "context-1m-2025-08-07": "context-1m-2025-08-07", + "context-management-2025-06-27": "context-management-2025-06-27", + "effort-2025-11-24": "effort-2025-11-24", + "fast-mode-2026-02-01": null, + "files-api-2025-04-14": "files-api-2025-04-14", + "fine-grained-tool-streaming-2025-05-14": null, + "interleaved-thinking-2025-05-14": "interleaved-thinking-2025-05-14", + "mcp-client-2025-11-20": "mcp-client-2025-11-20", + "mcp-client-2025-04-04": "mcp-client-2025-04-04", + "mcp-servers-2025-12-04": "mcp-servers-2025-12-04", + "output-128k-2025-02-19": null, + "structured-output-2024-03-01": null, + "prompt-caching-scope-2026-01-05": "prompt-caching-scope-2026-01-05", + "skills-2025-10-02": "skills-2025-10-02", + "structured-outputs-2025-11-13": "structured-outputs-2025-11-13", + "text_editor_20241022": null, + "text_editor_20250124": null, + "token-efficient-tools-2025-02-19": null, + "web-fetch-2025-09-10": "web-fetch-2025-09-10", + "web-search-2025-03-05": "web-search-2025-03-05" + }, + "bedrock_converse": { + "advanced-tool-use-2025-11-20": "tool-search-tool-2025-10-19", + "bash_20241022": null, + "bash_20250124": null, + "code-execution-2025-08-25": null, + "compact-2026-01-12": null, + "computer-use-2025-01-24": "computer-use-2025-01-24", + "computer-use-2025-11-24": "computer-use-2025-11-24", + "context-1m-2025-08-07": null, + "context-management-2025-06-27": "context-management-2025-06-27", + "effort-2025-11-24": null, + "fast-mode-2026-02-01": null, + "files-api-2025-04-14": null, + "fine-grained-tool-streaming-2025-05-14": null, + "interleaved-thinking-2025-05-14": "interleaved-thinking-2025-05-14", + "mcp-client-2025-11-20": null, + "mcp-client-2025-04-04": null, + "mcp-servers-2025-12-04": null, + "output-128k-2025-02-19": null, + "structured-output-2024-03-01": null, + "prompt-caching-scope-2026-01-05": null, + "skills-2025-10-02": null, + "structured-outputs-2025-11-13": "structured-outputs-2025-11-13", + "text_editor_20241022": null, + "text_editor_20250124": null, + "token-efficient-tools-2025-02-19": null, + "tool-search-tool-2025-10-19": "tool-search-tool-2025-10-19", + "web-fetch-2025-09-10": null, + "web-search-2025-03-05": null + }, + "bedrock": { + "advanced-tool-use-2025-11-20": "tool-search-tool-2025-10-19", + "bash_20241022": null, + "bash_20250124": null, + "code-execution-2025-08-25": null, + "compact-2026-01-12": "compact-2026-01-12", + "computer-use-2025-01-24": "computer-use-2025-01-24", + "computer-use-2025-11-24": "computer-use-2025-11-24", + "context-1m-2025-08-07": "context-1m-2025-08-07", + "context-management-2025-06-27": "context-management-2025-06-27", + "effort-2025-11-24": null, + "fast-mode-2026-02-01": null, + "files-api-2025-04-14": null, + "fine-grained-tool-streaming-2025-05-14": null, + "interleaved-thinking-2025-05-14": "interleaved-thinking-2025-05-14", + "mcp-client-2025-11-20": null, + "mcp-client-2025-04-04": null, + "mcp-servers-2025-12-04": null, + "output-128k-2025-02-19": null, + "structured-output-2024-03-01": null, + "prompt-caching-scope-2026-01-05": null, + "skills-2025-10-02": null, + "structured-outputs-2025-11-13": null, + "text_editor_20241022": null, + "text_editor_20250124": null, + "token-efficient-tools-2025-02-19": null, + "tool-search-tool-2025-10-19": "tool-search-tool-2025-10-19", + "web-fetch-2025-09-10": null, + "web-search-2025-03-05": null + }, + "vertex_ai": { + "advanced-tool-use-2025-11-20": "tool-search-tool-2025-10-19", + "bash_20241022": null, + "bash_20250124": null, + "code-execution-2025-08-25": null, + "compact-2026-01-12": null, + "computer-use-2025-01-24": "computer-use-2025-01-24", + "computer-use-2025-11-24": "computer-use-2025-11-24", + "context-1m-2025-08-07": null, + "context-management-2025-06-27": "context-management-2025-06-27", + "effort-2025-11-24": null, + "fast-mode-2026-02-01": null, + "files-api-2025-04-14": null, + "fine-grained-tool-streaming-2025-05-14": null, + "interleaved-thinking-2025-05-14": "interleaved-thinking-2025-05-14", + "mcp-client-2025-11-20": null, + "mcp-client-2025-04-04": null, + "mcp-servers-2025-12-04": null, + "output-128k-2025-02-19": null, + "structured-output-2024-03-01": null, + "prompt-caching-scope-2026-01-05": null, + "skills-2025-10-02": null, + "structured-outputs-2025-11-13": null, + "text_editor_20241022": null, + "text_editor_20250124": null, + "token-efficient-tools-2025-02-19": null, + "tool-search-tool-2025-10-19": "tool-search-tool-2025-10-19", + "web-fetch-2025-09-10": null, + "web-search-2025-03-05": "web-search-2025-03-05" + } +} \ No newline at end of file diff --git a/litellm/anthropic_beta_headers_manager.py b/litellm/anthropic_beta_headers_manager.py new file mode 100644 index 00000000000..9730ae02698 --- /dev/null +++ b/litellm/anthropic_beta_headers_manager.py @@ -0,0 +1,237 @@ +""" +Centralized manager for Anthropic beta headers across different providers. + +This module provides utilities to: +1. Load beta header configuration from JSON (mapping of supported headers per provider) +2. Filter and map beta headers based on provider support +3. Handle provider-specific header name mappings (e.g., advanced-tool-use -> tool-search-tool) + +Design: +- JSON config contains mapping of beta headers for each provider +- Keys are input header names, values are provider-specific header names (or null if unsupported) +- Only headers present in mapping keys with non-null values can be forwarded +- This enforces stricter validation than the previous unsupported list approach +""" + +import json +import os +from typing import Dict, List, Optional, Set + +from litellm.litellm_core_utils.litellm_logging import verbose_logger + +# Cache for the loaded configuration +_BETA_HEADERS_CONFIG: Optional[Dict] = None + + +def _load_beta_headers_config() -> Dict: + """ + Load the beta headers configuration from JSON file. + Uses caching to avoid repeated file reads. + + Returns: + Dict containing the beta headers configuration + """ + global _BETA_HEADERS_CONFIG + + if _BETA_HEADERS_CONFIG is not None: + return _BETA_HEADERS_CONFIG + + config_path = os.path.join( + os.path.dirname(__file__), + "anthropic_beta_headers_config.json" + ) + + try: + with open(config_path, "r") as f: + _BETA_HEADERS_CONFIG = json.load(f) + verbose_logger.debug(f"Loaded beta headers config from {config_path}") + return _BETA_HEADERS_CONFIG + except Exception as e: + verbose_logger.error(f"Failed to load beta headers config: {e}") + # Return empty config as fallback (empty mappings) + return { + "anthropic": {}, + "azure_ai": {}, + "bedrock": {}, + "bedrock_converse": {}, + "vertex_ai": {} + } + + +def get_provider_name(provider: str) -> str: + """ + Resolve provider aliases to canonical provider names. + + Args: + provider: Provider name (may be an alias) + + Returns: + Canonical provider name + """ + config = _load_beta_headers_config() + aliases = config.get("provider_aliases", {}) + return aliases.get(provider, provider) + + +def filter_and_transform_beta_headers( + beta_headers: List[str], + provider: str, +) -> List[str]: + """ + Filter and transform beta headers based on provider's mapping configuration. + + This function: + 1. Only allows headers that are present in the provider's mapping keys + 2. Filters out headers with null values (unsupported) + 3. Maps headers to provider-specific names (e.g., advanced-tool-use -> tool-search-tool) + + Args: + beta_headers: List of Anthropic beta header values + provider: Provider name (e.g., "anthropic", "bedrock", "vertex_ai") + + Returns: + List of filtered and transformed beta headers for the provider + """ + if not beta_headers: + return [] + + config = _load_beta_headers_config() + provider = get_provider_name(provider) + + # Get the header mapping for this provider + provider_mapping = config.get(provider, {}) + + filtered_headers: Set[str] = set() + + for header in beta_headers: + header = header.strip() + + # Check if header is in the mapping + if header not in provider_mapping: + verbose_logger.debug( + f"Dropping unknown beta header '{header}' for provider '{provider}' (not in mapping)" + ) + continue + + # Get the mapped header value + mapped_header = provider_mapping[header] + + # Skip if header is unsupported (null value) + if mapped_header is None: + verbose_logger.debug( + f"Dropping unsupported beta header '{header}' for provider '{provider}'" + ) + continue + + # Add the mapped header + filtered_headers.add(mapped_header) + + return sorted(list(filtered_headers)) + + +def is_beta_header_supported( + beta_header: str, + provider: str, +) -> bool: + """ + Check if a specific beta header is supported by a provider. + + Args: + beta_header: The Anthropic beta header value + provider: Provider name + + Returns: + True if the header is in the mapping with a non-null value, False otherwise + """ + config = _load_beta_headers_config() + provider = get_provider_name(provider) + provider_mapping = config.get(provider, {}) + + # Header is supported if it's in the mapping and has a non-null value + return beta_header in provider_mapping and provider_mapping[beta_header] is not None + + +def get_provider_beta_header( + anthropic_beta_header: str, + provider: str, +) -> Optional[str]: + """ + Get the provider-specific beta header name for a given Anthropic beta header. + + This function handles header transformations/mappings (e.g., advanced-tool-use -> tool-search-tool). + + Args: + anthropic_beta_header: The Anthropic beta header value + provider: Provider name + + Returns: + The provider-specific header name if supported, or None if unsupported/unknown + """ + config = _load_beta_headers_config() + provider = get_provider_name(provider) + + # Get the header mapping for this provider + provider_mapping = config.get(provider, {}) + + # Check if header is in the mapping + if anthropic_beta_header not in provider_mapping: + return None + + # Return the mapped value (could be None if unsupported) + return provider_mapping[anthropic_beta_header] + + +def update_headers_with_filtered_beta( + headers: dict, + provider: str, +) -> dict: + """ + Update headers dict by filtering and transforming anthropic-beta header values. + Modifies the headers dict in place and returns it. + + Args: + headers: Request headers dict (will be modified in place) + provider: Provider name + + Returns: + Updated headers dict + """ + existing_beta = headers.get("anthropic-beta") + if not existing_beta: + return headers + + # Parse existing beta headers + beta_values = [b.strip() for b in existing_beta.split(",") if b.strip()] + + # Filter and transform based on provider + filtered_beta_values = filter_and_transform_beta_headers( + beta_headers=beta_values, + provider=provider, + ) + + # Update or remove the header + if filtered_beta_values: + headers["anthropic-beta"] = ",".join(filtered_beta_values) + else: + # Remove the header if no values remain + headers.pop("anthropic-beta", None) + + return headers + + +def get_unsupported_headers(provider: str) -> List[str]: + """ + Get all beta headers that are unsupported by a provider (have null values in mapping). + + Args: + provider: Provider name + + Returns: + List of unsupported Anthropic beta header names + """ + config = _load_beta_headers_config() + provider = get_provider_name(provider) + provider_mapping = config.get(provider, {}) + + # Return headers with null values + return [header for header, value in provider_mapping.items() if value is None] diff --git a/litellm/batch_completion/main.py b/litellm/batch_completion/main.py index 7100fb004f8..446e3f2f990 100644 --- a/litellm/batch_completion/main.py +++ b/litellm/batch_completion/main.py @@ -237,17 +237,37 @@ def batch_completion_models_all_responses(*args, **kwargs): if "model" in kwargs: kwargs.pop("model") if "models" in kwargs: - models = kwargs["models"] - kwargs.pop("models") + models = kwargs.pop("models") else: raise Exception("'models' param not in kwargs") + if isinstance(models, str): + models = [models] + elif isinstance(models, (list, tuple)): + models = list(models) + else: + raise TypeError("'models' must be a string or list of strings") + + if len(models) == 0: + return [] + responses = [] with concurrent.futures.ThreadPoolExecutor(max_workers=len(models)) as executor: - for idx, model in enumerate(models): - future = executor.submit(litellm.completion, *args, model=model, **kwargs) - if future.result() is not None: - responses.append(future.result()) + futures = [ + executor.submit(litellm.completion, *args, model=model, **kwargs) + for model in models + ] + + for future in futures: + try: + result = future.result() + if result is not None: + responses.append(result) + except Exception as e: + print_verbose( + f"batch_completion_models_all_responses: model request failed: {str(e)}" + ) + continue return responses diff --git a/litellm/caching/redis_cache.py b/litellm/caching/redis_cache.py index ea7e3f5a979..03d09ecc041 100644 --- a/litellm/caching/redis_cache.py +++ b/litellm/caching/redis_cache.py @@ -1123,7 +1123,7 @@ class RedisCache(BaseCache): redis_client = redis_async.Redis(**self.redis_kwargs) # Test the connection - ping_result = await redis_client.ping() + ping_result = await redis_client.ping() # type: ignore[misc] # Close the connection await redis_client.aclose() # type: ignore[attr-defined] diff --git a/litellm/caching/redis_cluster_cache.py b/litellm/caching/redis_cluster_cache.py index 91fcf1d7288..664578c8700 100644 --- a/litellm/caching/redis_cluster_cache.py +++ b/litellm/caching/redis_cluster_cache.py @@ -83,7 +83,7 @@ class RedisClusterCache(RedisCache): ) # Test the connection - ping_result = await redis_client.ping() # type: ignore[attr-defined] + ping_result = await redis_client.ping() # type: ignore[attr-defined, misc] # Close the connection await redis_client.aclose() # type: ignore[attr-defined] diff --git a/litellm/constants.py b/litellm/constants.py index 25decd363a6..88c57d3ce4c 100644 --- a/litellm/constants.py +++ b/litellm/constants.py @@ -2,6 +2,8 @@ import os import sys from typing import List, Literal +from litellm.litellm_core_utils.env_utils import get_env_int + DEFAULT_HEALTH_CHECK_PROMPT = str( os.getenv("DEFAULT_HEALTH_CHECK_PROMPT", "test from litellm") ) @@ -46,6 +48,14 @@ DEFAULT_REPLICATE_POLLING_DELAY_SECONDS = int( os.getenv("DEFAULT_REPLICATE_POLLING_DELAY_SECONDS", 1) ) DEFAULT_IMAGE_TOKEN_COUNT = int(os.getenv("DEFAULT_IMAGE_TOKEN_COUNT", 250)) + +# Model cost map validation constants +MODEL_COST_MAP_MIN_MODEL_COUNT = int( + os.getenv("MODEL_COST_MAP_MIN_MODEL_COUNT", 50) +) # Minimum number of models a fetched cost map must contain to be considered valid +MODEL_COST_MAP_MAX_SHRINK_RATIO = float( + os.getenv("MODEL_COST_MAP_MAX_SHRINK_RATIO", 0.5) +) # Maximum allowed shrinkage ratio vs local backup (0.5 = reject if fetched map is <50% of backup) DEFAULT_IMAGE_WIDTH = int(os.getenv("DEFAULT_IMAGE_WIDTH", 300)) DEFAULT_IMAGE_HEIGHT = int(os.getenv("DEFAULT_IMAGE_HEIGHT", 300)) # Maximum size for image URL downloads in MB (default 50MB, set to 0 to disable limit) @@ -81,6 +91,20 @@ MAX_MCP_SEMANTIC_FILTER_TOOLS_HEADER_LENGTH = int( os.getenv("MAX_MCP_SEMANTIC_FILTER_TOOLS_HEADER_LENGTH", 150) ) +# MCP OAuth2 Client Credentials Defaults +MCP_OAUTH2_TOKEN_EXPIRY_BUFFER_SECONDS = int( + os.getenv("MCP_OAUTH2_TOKEN_EXPIRY_BUFFER_SECONDS", "60") +) +MCP_OAUTH2_TOKEN_CACHE_MAX_SIZE = int( + os.getenv("MCP_OAUTH2_TOKEN_CACHE_MAX_SIZE", "200") +) +MCP_OAUTH2_TOKEN_CACHE_DEFAULT_TTL = int( + os.getenv("MCP_OAUTH2_TOKEN_CACHE_DEFAULT_TTL", "3600") +) +MCP_OAUTH2_TOKEN_CACHE_MIN_TTL = int( + os.getenv("MCP_OAUTH2_TOKEN_CACHE_MIN_TTL", "10") +) + LITELLM_UI_ALLOW_HEADERS = [ "x-litellm-semantic-filter", "x-litellm-semantic-filter-tools", @@ -99,6 +123,11 @@ DEFAULT_REASONING_EFFORT_MINIMAL_THINKING_BUDGET_GEMINI_2_5_FLASH_LITE = int( ) ) +# Maximum number of callbacks that can be registered +# This prevents callbacks from exponentially growing and consuming CPU resources +# Override with LITELLM_MAX_CALLBACKS env var for large deployments (e.g., many teams with guardrails) +MAX_CALLBACKS = get_env_int("LITELLM_MAX_CALLBACKS", 30) + # Generic fallback for unknown models DEFAULT_REASONING_EFFORT_MINIMAL_THINKING_BUDGET = int( os.getenv("DEFAULT_REASONING_EFFORT_MINIMAL_THINKING_BUDGET", 128) @@ -184,6 +213,10 @@ REDIS_DAILY_AGENT_SPEND_UPDATE_BUFFER_KEY = "litellm_daily_agent_spend_update_bu REDIS_DAILY_TAG_SPEND_UPDATE_BUFFER_KEY = "litellm_daily_tag_spend_update_buffer" MAX_REDIS_BUFFER_DEQUEUE_COUNT = int(os.getenv("MAX_REDIS_BUFFER_DEQUEUE_COUNT", 100)) MAX_SIZE_IN_MEMORY_QUEUE = int(os.getenv("MAX_SIZE_IN_MEMORY_QUEUE", 2000)) +# Bounds asyncio.Queue() instances (log queues, spend update queues, etc.) to prevent unbounded memory growth +LITELLM_ASYNCIO_QUEUE_MAXSIZE = int( + os.getenv("LITELLM_ASYNCIO_QUEUE_MAXSIZE", 1000) +) MAX_IN_MEMORY_QUEUE_FLUSH_COUNT = int( os.getenv("MAX_IN_MEMORY_QUEUE_FLUSH_COUNT", 1000) ) @@ -306,6 +339,22 @@ DEFAULT_MAX_TOKENS_FOR_TRITON = int(os.getenv("DEFAULT_MAX_TOKENS_FOR_TRITON", 2 #### Networking settings #### request_timeout: float = float(os.getenv("REQUEST_TIMEOUT", 6000)) # time in seconds DEFAULT_A2A_AGENT_TIMEOUT: float = float(os.getenv("DEFAULT_A2A_AGENT_TIMEOUT", 6000)) # 10 minutes +# Patterns that indicate a localhost/internal URL in A2A agent cards that should be +# replaced with the original base_url. This is a common misconfiguration where +# developers deploy agents with development URLs in their agent cards. +LOCALHOST_URL_PATTERNS: List[str] = [ + "localhost", + "127.0.0.1", + "0.0.0.0", + "[::1]", # IPv6 localhost +] +# Patterns in error messages that indicate a connection failure +CONNECTION_ERROR_PATTERNS: List[str] = [ + "connect", + "connection", + "network", + "refused", +] STREAM_SSE_DONE_STRING: str = "[DONE]" STREAM_SSE_DATA_PREFIX: str = "data: " ### SPEND TRACKING ### @@ -1261,6 +1310,9 @@ DEFAULT_SLACK_ALERTING_THRESHOLD = int( os.getenv("DEFAULT_SLACK_ALERTING_THRESHOLD", 300) ) MAX_TEAM_LIST_LIMIT = int(os.getenv("MAX_TEAM_LIST_LIMIT", 20)) +MAX_POLICY_ESTIMATE_IMPACT_ROWS = int( + os.getenv("MAX_POLICY_ESTIMATE_IMPACT_ROWS", 1000) +) DEFAULT_PROMPT_INJECTION_SIMILARITY_THRESHOLD = float( os.getenv("DEFAULT_PROMPT_INJECTION_SIMILARITY_THRESHOLD", 0.7) ) diff --git a/litellm/cost_calculator.py b/litellm/cost_calculator.py index bef4d52ce49..4ea22dbd90f 100644 --- a/litellm/cost_calculator.py +++ b/litellm/cost_calculator.py @@ -1,5 +1,6 @@ # What is this? ## File for 'response_cost' calculation in Logging +import logging import time from functools import lru_cache from typing import TYPE_CHECKING, Any, List, Literal, Optional, Tuple, Union, cast @@ -774,10 +775,11 @@ def _apply_cost_discount( discount_amount = original_cost * discount_percent final_cost = original_cost - discount_amount - verbose_logger.debug( - f"Applied {discount_percent*100}% discount to {custom_llm_provider}: " - f"${original_cost:.6f} -> ${final_cost:.6f} (saved ${discount_amount:.6f})" - ) + if verbose_logger.isEnabledFor(logging.DEBUG): + verbose_logger.debug( + f"Applied {discount_percent*100}% discount to {custom_llm_provider}: " + f"${original_cost:.6f} -> ${final_cost:.6f} (saved ${discount_amount:.6f})" + ) return final_cost, discount_percent, discount_amount @@ -807,17 +809,20 @@ def _apply_cost_margin( margin_config = None if custom_llm_provider and custom_llm_provider in litellm.cost_margin_config: margin_config = litellm.cost_margin_config[custom_llm_provider] - verbose_logger.debug( - f"Found provider-specific margin config for {custom_llm_provider}: {margin_config}" - ) + if verbose_logger.isEnabledFor(logging.DEBUG): + verbose_logger.debug( + f"Found provider-specific margin config for {custom_llm_provider}: {margin_config}" + ) elif "global" in litellm.cost_margin_config: margin_config = litellm.cost_margin_config["global"] - verbose_logger.debug(f"Using global margin config: {margin_config}") + if verbose_logger.isEnabledFor(logging.DEBUG): + verbose_logger.debug(f"Using global margin config: {margin_config}") else: - verbose_logger.debug( - f"No margin config found. Provider: {custom_llm_provider}, " - f"Available configs: {list(litellm.cost_margin_config.keys())}" - ) + if verbose_logger.isEnabledFor(logging.DEBUG): + verbose_logger.debug( + f"No margin config found. Provider: {custom_llm_provider}, " + f"Available configs: {list(litellm.cost_margin_config.keys())}" + ) if margin_config is not None: # Handle different margin config formats @@ -836,11 +841,12 @@ def _apply_cost_margin( final_cost = original_cost + margin_total_amount - verbose_logger.debug( - f"Applied margin to {custom_llm_provider or 'global'}: " - f"${original_cost:.6f} -> ${final_cost:.6f} " - f"(margin: {margin_percent*100 if margin_percent > 0 else 0}% + ${margin_fixed_amount:.6f} = ${margin_total_amount:.6f})" - ) + if verbose_logger.isEnabledFor(logging.DEBUG): + verbose_logger.debug( + f"Applied margin to {custom_llm_provider or 'global'}: " + f"${original_cost:.6f} -> ${final_cost:.6f} " + f"(margin: {margin_percent*100 if margin_percent > 0 else 0}% + ${margin_fixed_amount:.6f} = ${margin_total_amount:.6f})" + ) return final_cost, margin_percent, margin_fixed_amount, margin_total_amount @@ -1021,9 +1027,10 @@ def completion_cost( # noqa: PLR0915 for idx, model in enumerate(potential_model_names): try: - verbose_logger.debug( - f"selected model name for cost calculation: {model}" - ) + if verbose_logger.isEnabledFor(logging.DEBUG): + verbose_logger.debug( + f"selected model name for cost calculation: {model}" + ) if completion_response is not None and ( isinstance(completion_response, BaseModel) @@ -1411,37 +1418,47 @@ def completion_cost( # noqa: PLR0915 # Apply discount from module-level config if configured original_cost = _final_cost - _final_cost, discount_percent, discount_amount = _apply_cost_discount( - base_cost=_final_cost, - custom_llm_provider=custom_llm_provider, - ) + if litellm.cost_discount_config: + _final_cost, discount_percent, discount_amount = _apply_cost_discount( + base_cost=_final_cost, + custom_llm_provider=custom_llm_provider, + ) + else: + discount_percent = 0.0 + discount_amount = 0.0 # Apply margin from module-level config if configured - ( - _final_cost, - margin_percent, - margin_fixed_amount, - margin_total_amount, - ) = _apply_cost_margin( - base_cost=_final_cost, - custom_llm_provider=custom_llm_provider, - ) + if litellm.cost_margin_config: + ( + _final_cost, + margin_percent, + margin_fixed_amount, + margin_total_amount, + ) = _apply_cost_margin( + base_cost=_final_cost, + custom_llm_provider=custom_llm_provider, + ) + else: + margin_percent = 0.0 + margin_fixed_amount = 0.0 + margin_total_amount = 0.0 # Store cost breakdown in logging object if available - _store_cost_breakdown_in_logging_obj( - litellm_logging_obj=litellm_logging_obj, - prompt_tokens_cost_usd_dollar=prompt_tokens_cost_usd_dollar, - completion_tokens_cost_usd_dollar=completion_tokens_cost_usd_dollar, - cost_for_built_in_tools_cost_usd_dollar=cost_for_built_in_tools, - total_cost_usd_dollar=_final_cost, - additional_costs=additional_costs, - original_cost=original_cost, - discount_percent=discount_percent, - discount_amount=discount_amount, - margin_percent=margin_percent, - margin_fixed_amount=margin_fixed_amount, - margin_total_amount=margin_total_amount, - ) + if litellm_logging_obj is not None: + _store_cost_breakdown_in_logging_obj( + litellm_logging_obj=litellm_logging_obj, + prompt_tokens_cost_usd_dollar=prompt_tokens_cost_usd_dollar, + completion_tokens_cost_usd_dollar=completion_tokens_cost_usd_dollar, + cost_for_built_in_tools_cost_usd_dollar=cost_for_built_in_tools, + total_cost_usd_dollar=_final_cost, + original_cost=original_cost, + additional_costs=additional_costs, + discount_percent=discount_percent, + discount_amount=discount_amount, + margin_percent=margin_percent, + margin_fixed_amount=margin_fixed_amount, + margin_total_amount=margin_total_amount, + ) return _final_cost except Exception as e: @@ -2116,3 +2133,5 @@ def handle_realtime_stream_cost_calculation( total_cost = input_cost_per_token + output_cost_per_token return total_cost + + diff --git a/litellm/experimental_mcp_client/client.py b/litellm/experimental_mcp_client/client.py index 3e8f9bc337b..5e21ff9754f 100644 --- a/litellm/experimental_mcp_client/client.py +++ b/litellm/experimental_mcp_client/client.py @@ -209,6 +209,8 @@ class MCPClient: headers["X-API-Key"] = self._mcp_auth_value elif self.auth_type == MCPAuth.authorization: headers["Authorization"] = self._mcp_auth_value + elif self.auth_type == MCPAuth.oauth2: + headers["Authorization"] = f"Bearer {self._mcp_auth_value}" elif isinstance(self._mcp_auth_value, dict): headers.update(self._mcp_auth_value) diff --git a/litellm/integrations/arize/arize.py b/litellm/integrations/arize/arize.py index 9c2f0d95d4d..fe2f9f41f1b 100644 --- a/litellm/integrations/arize/arize.py +++ b/litellm/integrations/arize/arize.py @@ -28,6 +28,41 @@ else: class ArizeLogger(OpenTelemetry): + """ + Arize logger that sends traces to an Arize endpoint. + + Creates its own dedicated TracerProvider so it can coexist with the + generic ``otel`` callback (or any other OTEL-based integration) without + fighting over the global ``opentelemetry.trace`` TracerProvider singleton. + """ + + def _init_tracing(self, tracer_provider): + """ + Override to always create a *private* TracerProvider for Arize. + + See ArizePhoenixLogger._init_tracing for full rationale. + """ + from opentelemetry.sdk.trace import TracerProvider + from opentelemetry.trace import SpanKind + + if tracer_provider is not None: + self.tracer = tracer_provider.get_tracer("litellm") + self.span_kind = SpanKind + return + + provider = TracerProvider(resource=self._get_litellm_resource(self.config)) + provider.add_span_processor(self._get_span_processor()) + self.tracer = provider.get_tracer("litellm") + self.span_kind = SpanKind + + def _init_otel_logger_on_litellm_proxy(self): + """ + Override: Arize should NOT overwrite the proxy's + ``open_telemetry_logger``. That attribute is reserved for the + primary ``otel`` callback which handles proxy-level parent spans. + """ + pass + def set_attributes(self, span: Span, kwargs, response_obj: Optional[Any]): ArizeLogger.set_arize_attributes(span, kwargs, response_obj) return diff --git a/litellm/integrations/arize/arize_phoenix.py b/litellm/integrations/arize/arize_phoenix.py index cd345a7f76d..1b038c098f8 100644 --- a/litellm/integrations/arize/arize_phoenix.py +++ b/litellm/integrations/arize/arize_phoenix.py @@ -5,43 +5,211 @@ from litellm._logging import verbose_logger from litellm.integrations.arize import _utils from litellm.integrations.arize._utils import ArizeOTELAttributes from litellm.types.integrations.arize_phoenix import ArizePhoenixConfig -from litellm.integrations.opentelemetry import OpenTelemetry if TYPE_CHECKING: + from opentelemetry.sdk.trace import TracerProvider from opentelemetry.trace import Span as _Span + from opentelemetry.trace import SpanKind + from litellm.integrations.opentelemetry import OpenTelemetry as _OpenTelemetry from litellm.integrations.opentelemetry import OpenTelemetryConfig as _OpenTelemetryConfig from litellm.types.integrations.arize import Protocol as _Protocol Protocol = _Protocol OpenTelemetryConfig = _OpenTelemetryConfig Span = Union[_Span, Any] + OpenTelemetry = _OpenTelemetry else: Protocol = Any OpenTelemetryConfig = Any Span = Any + TracerProvider = Any + SpanKind = Any + # Import OpenTelemetry at runtime + try: + from litellm.integrations.opentelemetry import OpenTelemetry + except ImportError: + OpenTelemetry = None # type: ignore ARIZE_HOSTED_PHOENIX_ENDPOINT = "https://otlp.arize.com/v1/traces" -class ArizePhoenixLogger(OpenTelemetry): +class ArizePhoenixLogger(OpenTelemetry): # type: ignore + """ + Arize Phoenix logger that sends traces to a Phoenix endpoint. + + Creates its own dedicated TracerProvider so it can coexist with the + generic ``otel`` callback (or any other OTEL-based integration) without + fighting over the global ``opentelemetry.trace`` TracerProvider singleton. + """ + + def _init_tracing(self, tracer_provider): + """ + Override to always create a *private* TracerProvider for Arize Phoenix. + + The base ``OpenTelemetry._init_tracing`` falls back to the global + TracerProvider when one already exists. That causes whichever + integration initialises second to silently reuse the first one's + exporter, so spans only reach one destination. + + By creating our own provider we guarantee Arize Phoenix always gets + its own exporter pipeline, regardless of initialisation order. + """ + from opentelemetry.sdk.trace import TracerProvider + from opentelemetry.trace import SpanKind + + if tracer_provider is not None: + # Explicitly supplied (e.g. in tests) — honour it. + self.tracer = tracer_provider.get_tracer("litellm") + self.span_kind = SpanKind + return + + # Always create a dedicated provider — never touch the global one. + provider = TracerProvider(resource=self._get_litellm_resource(self.config)) + provider.add_span_processor(self._get_span_processor()) + self.tracer = provider.get_tracer("litellm") + self.span_kind = SpanKind + verbose_logger.debug( + "ArizePhoenixLogger: Created dedicated TracerProvider " + "(endpoint=%s, exporter=%s)", + self.config.endpoint, + self.config.exporter, + ) + + def _init_otel_logger_on_litellm_proxy(self): + """ + Override: Arize Phoenix should NOT overwrite the proxy's + ``open_telemetry_logger``. That attribute is reserved for the + primary ``otel`` callback which handles proxy-level parent spans. + """ + pass + def set_attributes(self, span: Span, kwargs, response_obj: Optional[Any]): ArizePhoenixLogger.set_arize_phoenix_attributes(span, kwargs, response_obj) return @staticmethod def set_arize_phoenix_attributes(span: Span, kwargs, response_obj): + from litellm.integrations.opentelemetry_utils.base_otel_llm_obs_attributes import safe_set_attribute + _utils.set_attributes(span, kwargs, response_obj, ArizeOTELAttributes) - - # Set project name on the span for all traces to go to custom Phoenix projects - config = ArizePhoenixLogger.get_arize_phoenix_config() - if config.project_name: - from litellm.integrations.opentelemetry_utils.base_otel_llm_obs_attributes import safe_set_attribute - safe_set_attribute(span, "openinference.project.name", config.project_name) - + + # Dynamic project name: check metadata first, then fall back to env var config + dynamic_project_name = ArizePhoenixLogger._get_dynamic_project_name(kwargs) + if dynamic_project_name: + safe_set_attribute(span, "openinference.project.name", dynamic_project_name) + else: + # Fall back to static config from env var + config = ArizePhoenixLogger.get_arize_phoenix_config() + if config.project_name: + safe_set_attribute(span, "openinference.project.name", config.project_name) + return + @staticmethod + def _get_dynamic_project_name(kwargs) -> Optional[str]: + """ + Retrieve dynamic Phoenix project name from request metadata. + + Users can set `metadata.phoenix_project_name` in their request to route + traces to different Phoenix projects dynamically. + """ + standard_logging_payload = kwargs.get("standard_logging_object") + if isinstance(standard_logging_payload, dict): + metadata = standard_logging_payload.get("metadata") + if isinstance(metadata, dict): + project_name = metadata.get("phoenix_project_name") + if project_name: + return str(project_name) + + # Also check litellm_params.metadata for SDK usage + litellm_params = kwargs.get("litellm_params") + if isinstance(litellm_params, dict): + metadata = litellm_params.get("metadata") or {} + else: + metadata = {} + if isinstance(metadata, dict): + project_name = metadata.get("phoenix_project_name") + if project_name: + return str(project_name) + + return None + + def _handle_success(self, kwargs, response_obj, start_time, end_time): + """ + Override to prevent creating duplicate litellm_request spans when a proxy parent span exists. + + ArizePhoenixLogger should reuse the proxy parent span instead of creating a new litellm_request span, + to maintain a shallow span hierarchy as expected by Arize Phoenix. + """ + from opentelemetry.trace import Status, StatusCode + from litellm.secret_managers.main import get_secret_bool + from litellm.integrations.opentelemetry import LITELLM_PROXY_REQUEST_SPAN_NAME + + verbose_logger.debug( + "ArizePhoenixLogger: Logging kwargs: %s, OTEL config settings=%s", + kwargs, + self.config, + ) + ctx, parent_span = self._get_span_context(kwargs) + + # ArizePhoenixLogger NEVER creates a litellm_request span when a proxy parent span exists + # This is different from the base OpenTelemetry behavior which respects USE_OTEL_LITELLM_REQUEST_SPAN + should_create_primary_span = parent_span is None or ( + parent_span.name != LITELLM_PROXY_REQUEST_SPAN_NAME + and get_secret_bool("USE_OTEL_LITELLM_REQUEST_SPAN") + ) + + if should_create_primary_span: + # Create a new litellm_request span + span = self._start_primary_span( + kwargs, response_obj, start_time, end_time, ctx + ) + # Raw-request sub-span (if enabled) - child of litellm_request span + self._maybe_log_raw_request( + kwargs, response_obj, start_time, end_time, span + ) + # Ensure proxy-request parent span is annotated with the actual operation kind + if ( + parent_span is not None + and parent_span.name == LITELLM_PROXY_REQUEST_SPAN_NAME + ): + self.set_attributes(parent_span, kwargs, response_obj) + else: + # Do not create primary span (keep hierarchy shallow when parent exists) + span = None + # Only set attributes if the span is still recording (not closed) + # Note: parent_span is guaranteed to be not None here + if parent_span.is_recording(): + parent_span.set_status(Status(StatusCode.OK)) + self.set_attributes(parent_span, kwargs, response_obj) + # Raw-request as direct child of parent_span + self._maybe_log_raw_request( + kwargs, response_obj, start_time, end_time, parent_span + ) + + # 3. Guardrail span + self._create_guardrail_span(kwargs=kwargs, context=ctx) + + # 4. Metrics & cost recording + self._record_metrics(kwargs, response_obj, start_time, end_time) + + # 5. Semantic logs. + if self.config.enable_events: + log_span = span if span is not None else parent_span + if log_span is not None: + self._emit_semantic_logs(kwargs, response_obj, log_span) + + # 6. Do NOT end parent span - it should be managed by its creator + # External spans (from Langfuse, user code, HTTP headers, global context) must not be closed by LiteLLM + # However, proxy-created spans should be closed here + if ( + parent_span is not None + and parent_span.name == LITELLM_PROXY_REQUEST_SPAN_NAME + ): + parent_span.end(end_time=self._to_ns(end_time)) + @staticmethod def get_arize_phoenix_config() -> ArizePhoenixConfig: """ diff --git a/litellm/integrations/cloudzero/transform.py b/litellm/integrations/cloudzero/transform.py index e06b944a419..c36833a6dbf 100644 --- a/litellm/integrations/cloudzero/transform.py +++ b/litellm/integrations/cloudzero/transform.py @@ -103,10 +103,15 @@ class CBFTransformer: # Use team_alias if available, otherwise team_id, otherwise fallback to 'unknown' entity_id = str(team_alias) if team_alias else (str(team_id) if team_id else 'unknown') + # Get alias fields if they exist + api_key_alias = row.get('api_key_alias') + organization_alias = row.get('organization_alias') + project_alias = row.get('project_alias') + user_alias = row.get('user_alias') + dimensions = { 'entity_type': CZEntityType.TEAM.value, 'entity_id': entity_id, - 'team_id': str(team_id) if team_id else 'unknown', 'team_alias': str(team_alias) if team_alias else 'unknown', 'model': model, 'model_group': str(row.get('model_group', '')), @@ -119,28 +124,37 @@ class CBFTransformer: 'failed_requests': str(row.get('failed_requests', 0)), 'cache_creation_tokens': str(row.get('cache_creation_input_tokens', 0)), 'cache_read_tokens': str(row.get('cache_read_input_tokens', 0)), + 'organization_alias': str(organization_alias) if organization_alias else '', + 'project_alias': str(project_alias) if project_alias else '', + 'user_alias': str(user_alias) if user_alias else '', } # Extract CZRN components to populate corresponding CBF columns czrn_components = self.czrn_generator.extract_components(resource_id) service_type, provider, region, owner_account_id, resource_type, cloud_local_id = czrn_components + # Build resource/account as concat of api_key_alias and api_key_prefix + resource_account = f"{api_key_alias}|{api_key_hash}" if api_key_alias else api_key_hash + # CloudZero CBF format with proper column names cbf_record = { # Required CBF fields 'time/usage_start': usage_date.isoformat() if usage_date else None, # Required: ISO-formatted UTC datetime 'cost/cost': float(row.get('spend', 0.0)), # Required: billed cost - 'resource/id': resource_id, # Required when resource tags are present + 'resource/id': model, # Send model name # Usage metrics for token consumption 'usage/amount': total_tokens, # Numeric value of tokens consumed 'usage/units': 'tokens', # Description of token units - # CBF fields that correspond to CZRN components - 'resource/service': service_type, # Maps to CZRN service-type (litellm) - 'resource/account': owner_account_id, # Maps to CZRN owner-account-id (entity_id) + # CBF fields - updated per LIT-1907 + 'resource/service': str(row.get('model_group', '')), # Send model_group + 'resource/account': resource_account, # Send api_key_alias|api_key_prefix 'resource/region': region, # Maps to CZRN region (cross-region) - 'resource/usage_family': resource_type, # Maps to CZRN resource-type (llm-usage) + 'resource/usage_family': str(row.get('custom_llm_provider', '')), # Send provider + + # Action field + 'action/operation': str(team_id) if team_id else '', # Send team_id # Line item details 'lineitem/type': 'Usage', # Standard usage line item @@ -155,13 +169,11 @@ class CBFTransformer: if value and value != 'N/A' and value != 'unknown': # Only add meaningful tags cbf_record[f'resource/tag:{key}'] = str(value) - # Add token breakdown as resource tags for analysis + # Add token breakdown as resource tags for analysis (excluding total_tokens per LIT-1907) if prompt_tokens > 0: cbf_record['resource/tag:prompt_tokens'] = str(prompt_tokens) if completion_tokens > 0: cbf_record['resource/tag:completion_tokens'] = str(completion_tokens) - if total_tokens > 0: - cbf_record['resource/tag:total_tokens'] = str(total_tokens) return CBFRecord(cbf_record) diff --git a/litellm/integrations/custom_guardrail.py b/litellm/integrations/custom_guardrail.py index 1652ec2aa0c..407bc581f71 100644 --- a/litellm/integrations/custom_guardrail.py +++ b/litellm/integrations/custom_guardrail.py @@ -268,6 +268,7 @@ class CustomGuardrail(CustomLogger): """ Returns the guardrail(s) to be run from the metadata or root """ + if "guardrails" in data: return data["guardrails"] metadata = data.get("litellm_metadata") or data.get("metadata", {}) @@ -615,6 +616,7 @@ class CustomGuardrail(CustomLogger): end_time: Optional[float] = None, duration: Optional[float] = None, event_type: Optional[GuardrailEventHooks] = None, + original_inputs: Optional[Dict] = None, ): """ Add StandardLoggingGuardrailInformation to the request data @@ -624,6 +626,17 @@ class CustomGuardrail(CustomLogger): # Convert None to empty dict to satisfy type requirements guardrail_response = {} if response is None else response + # For apply_guardrail functions in custom_code_guardrail scenario, + # simplify the logged response to "allow", "deny", or "mask" + if original_inputs is not None and isinstance(response, dict): + # Check if inputs were modified by comparing them + if self._inputs_were_modified(original_inputs, response): + guardrail_response = "mask" + else: + guardrail_response = "allow" + + verbose_logger.debug(f"Guardrail response: {response}") + self.add_standard_logging_guardrail_information_to_request_data( guardrail_json_response=guardrail_response, request_data=request_data, @@ -649,8 +662,14 @@ class CustomGuardrail(CustomLogger): This gets logged on downsteam Langfuse, DataDog, etc. """ + # For custom_code_guardrail scenario, log as "deny" instead of full exception + # Check if this is from custom_code_guardrail by checking the class name + guardrail_response: Union[Exception, str] = e + if "CustomCodeGuardrail" in self.__class__.__name__: + guardrail_response = "deny" + self.add_standard_logging_guardrail_information_to_request_data( - guardrail_json_response=e, + guardrail_json_response=guardrail_response, request_data=request_data, guardrail_status="guardrail_failed_to_respond", duration=duration, @@ -660,6 +679,25 @@ class CustomGuardrail(CustomLogger): ) raise e + def _inputs_were_modified(self, original_inputs: Dict, response: Dict) -> bool: + """ + Compare original inputs with response to determine if content was modified. + + Returns True if the inputs were modified (mask scenario), False otherwise (allow scenario). + """ + # Get all keys from both dictionaries + all_keys = set(original_inputs.keys()) | set(response.keys()) + + # Compare each key's value + for key in all_keys: + original_value = original_inputs.get(key) + response_value = response.get(key) + if original_value != response_value: + return True + + # No modifications detected + return False + def mask_content_in_string( self, content_string: str, @@ -767,6 +805,12 @@ def log_guardrail_information(func): self: CustomGuardrail = args[0] request_data: dict = kwargs.get("data") or kwargs.get("request_data") or {} event_type = _infer_event_type_from_function_name(func.__name__) + + # Store original inputs for comparison (for apply_guardrail functions) + original_inputs = None + if func.__name__ == "apply_guardrail" and "inputs" in kwargs: + original_inputs = kwargs.get("inputs") + try: response = await func(*args, **kwargs) return self._process_response( @@ -776,6 +820,7 @@ def log_guardrail_information(func): end_time=datetime.now().timestamp(), duration=(datetime.now() - start_time).total_seconds(), event_type=event_type, + original_inputs=original_inputs, ) except Exception as e: return self._process_error( @@ -793,6 +838,12 @@ def log_guardrail_information(func): self: CustomGuardrail = args[0] request_data: dict = kwargs.get("data") or kwargs.get("request_data") or {} event_type = _infer_event_type_from_function_name(func.__name__) + + # Store original inputs for comparison (for apply_guardrail functions) + original_inputs = None + if func.__name__ == "apply_guardrail" and "inputs" in kwargs: + original_inputs = kwargs.get("inputs") + try: response = func(*args, **kwargs) return self._process_response( @@ -800,6 +851,7 @@ def log_guardrail_information(func): request_data=request_data, duration=(datetime.now() - start_time).total_seconds(), event_type=event_type, + original_inputs=original_inputs, ) except Exception as e: return self._process_error( diff --git a/litellm/integrations/custom_logger.py b/litellm/integrations/custom_logger.py index 07d237c4758..4a341863d4b 100644 --- a/litellm/integrations/custom_logger.py +++ b/litellm/integrations/custom_logger.py @@ -664,6 +664,37 @@ class CustomLogger: # https://docs.litellm.ai/docs/observability/custom_callbac return final_response """ pass + + async def async_should_run_chat_completion_agentic_loop( + self, + response: Any, + model: str, + messages: List[Dict], + tools: Optional[List[Dict]], + stream: bool, + custom_llm_provider: str, + kwargs: Dict, + ) -> Tuple[bool, Dict]: + """ + Hook to determine if chat completion agentic loop should be executed. + """ + return False, {} + + async def async_run_chat_completion_agentic_loop( + self, + tools: Dict, + model: str, + messages: List[Dict], + response: Any, + optional_params: Dict, + logging_obj: "LiteLLMLoggingObj", + stream: bool, + kwargs: Dict, + ) -> Any: + """ + Hook to execute chat completion agentic loop based on context from should_run hook. + """ + pass # Useful helpers for custom logger classes diff --git a/litellm/integrations/datadog/datadog.py b/litellm/integrations/datadog/datadog.py index 127b0e53fa8..64e0b26a8e7 100644 --- a/litellm/integrations/datadog/datadog.py +++ b/litellm/integrations/datadog/datadog.py @@ -45,7 +45,14 @@ from litellm.llms.custom_httpx.http_handler import ( httpxSpecialProvider, ) from litellm.types.integrations.base_health_check import IntegrationHealthCheckStatus -from litellm.types.integrations.datadog import * +from litellm.types.integrations.datadog import ( + DD_ERRORS, + DD_MAX_BATCH_SIZE, + DataDogStatus, + DatadogInitParams, + DatadogPayload, + DatadogProxyFailureHookJsonMessage, +) from litellm.types.services import ServiceLoggerPayload, ServiceTypes from litellm.types.utils import StandardLoggingPayload @@ -85,12 +92,14 @@ class DataDogLogger( """ try: verbose_logger.debug("Datadog: in init datadog logger") - + self.is_mock_mode = should_use_datadog_mock() - + if self.is_mock_mode: create_mock_datadog_client() - verbose_logger.debug("[DATADOG MOCK] Datadog logger initialized in mock mode") + verbose_logger.debug( + "[DATADOG MOCK] Datadog logger initialized in mock mode" + ) ######################################################### # Handle datadog_params set as litellm.datadog_params @@ -209,6 +218,96 @@ class DataDogLogger( ) pass + async def async_post_call_failure_hook( + self, + request_data: dict, + original_exception: Exception, + user_api_key_dict: Any, + traceback_str: Optional[str] = None, + ) -> Optional[Any]: + """ + Log proxy-level failures (e.g. 401 auth, DB connection errors) to Datadog. + + Ensures failures that occur before or outside the LLM completion flow + (e.g. ConnectError during auth when DB is down) are visible in Datadog + alongside Prometheus. + """ + try: + from litellm.litellm_core_utils.litellm_logging import ( + StandardLoggingPayloadSetup, + ) + from litellm.litellm_core_utils.safe_json_dumps import safe_dumps + + error_information = StandardLoggingPayloadSetup.get_error_information( + original_exception=original_exception, + traceback_str=traceback_str, + ) + _code = error_information.get("error_code") or "" + status_code: Optional[int] = None + if _code and str(_code).strip().isdigit(): + status_code = int(_code) + + # Use project-standard sanitized user context when running in proxy + user_context: Dict[str, Any] = {} + try: + from litellm.proxy.litellm_pre_call_utils import ( + LiteLLMProxyRequestSetup, + ) + + _meta = ( + LiteLLMProxyRequestSetup.get_sanitized_user_information_from_key( + user_api_key_dict=user_api_key_dict + ) + ) + user_context = dict(_meta) if isinstance(_meta, dict) else _meta + except Exception: + # Fallback if proxy not available (e.g. SDK-only): minimal safe fields + if hasattr(user_api_key_dict, "request_route"): + user_context["request_route"] = getattr( + user_api_key_dict, "request_route", None + ) + if hasattr(user_api_key_dict, "team_id"): + user_context["team_id"] = getattr( + user_api_key_dict, "team_id", None + ) + if hasattr(user_api_key_dict, "user_id"): + user_context["user_id"] = getattr( + user_api_key_dict, "user_id", None + ) + if hasattr(user_api_key_dict, "end_user_id"): + user_context["end_user_id"] = getattr( + user_api_key_dict, "end_user_id", None + ) + + message_payload: DatadogProxyFailureHookJsonMessage = { + "exception": error_information.get("error_message") + or str(original_exception), + "error_class": error_information.get("error_class") + or original_exception.__class__.__name__, + "status_code": status_code, + "traceback": error_information.get("traceback") or "", + "user_api_key_dict": user_context, + } + + dd_payload = DatadogPayload( + ddsource=get_datadog_source(), + ddtags=get_datadog_tags(), + hostname=get_datadog_hostname(), + message=safe_dumps(message_payload), + service=get_datadog_service(), + status=DataDogStatus.ERROR, + ) + self._add_trace_context_to_payload(dd_payload=dd_payload) + self.log_queue.append(dd_payload) + + if len(self.log_queue) >= self.batch_size: + await self.async_send_batch() + except Exception as e: + verbose_logger.exception( + f"Datadog: async_post_call_failure_hook - {str(e)}\n{traceback.format_exc()}" + ) + return None + async def async_send_batch(self): """ Sends the in memory logs queue to datadog api @@ -230,9 +329,11 @@ class DataDogLogger( len(self.log_queue), self.intake_url, ) - + if self.is_mock_mode: - verbose_logger.debug("[DATADOG MOCK] Mock mode enabled - API calls will be intercepted") + verbose_logger.debug( + "[DATADOG MOCK] Mock mode enabled - API calls will be intercepted" + ) response = await self.async_send_compressed_data(self.log_queue) if response.status_code == 413: diff --git a/litellm/integrations/email_templates/templates.py b/litellm/integrations/email_templates/templates.py index 5de23db0f24..091351df2bb 100644 --- a/litellm/integrations/email_templates/templates.py +++ b/litellm/integrations/email_templates/templates.py @@ -85,6 +85,30 @@ SOFT_BUDGET_ALERT_EMAIL_TEMPLATE = """ The LiteLLM team
""" +TEAM_SOFT_BUDGET_ALERT_EMAIL_TEMPLATE = """ + LiteLLM Logo + +

Hi {team_alias} team member,
+ + Your LiteLLM team has crossed its soft budget limit of {soft_budget}.

+ + Current Spend: {spend}
+ Soft Budget: {soft_budget}
+ {max_budget_info} + +

+ ⚠️ Note: Your API requests will continue to work, but you should monitor your usage closely. + If you reach your maximum budget, requests will be rejected. +

+ + You can view your usage and manage your budget in the LiteLLM Dashboard.

+ + If you have any questions, please send an email to {email_support_contact}

+ + Best,
+ The LiteLLM team
+""" + MAX_BUDGET_ALERT_EMAIL_TEMPLATE = """ LiteLLM Logo diff --git a/litellm/integrations/gcs_bucket/gcs_bucket.py b/litellm/integrations/gcs_bucket/gcs_bucket.py index 3cb62905531..0f1ba4a4093 100644 --- a/litellm/integrations/gcs_bucket/gcs_bucket.py +++ b/litellm/integrations/gcs_bucket/gcs_bucket.py @@ -9,6 +9,7 @@ from typing import TYPE_CHECKING, Any, Dict, List, Optional, Tuple from urllib.parse import quote from litellm._logging import verbose_logger +from litellm.constants import LITELLM_ASYNCIO_QUEUE_MAXSIZE from litellm.integrations.additional_logging_utils import AdditionalLoggingUtils from litellm.integrations.gcs_bucket.gcs_bucket_base import GCSBucketBase from litellm.proxy._types import CommonProxyErrors @@ -41,7 +42,9 @@ class GCSBucketLogger(GCSBucketBase, AdditionalLoggingUtils): batch_size=self.batch_size, flush_interval=self.flush_interval, ) - self.log_queue: asyncio.Queue[GCSLogQueueItem] = asyncio.Queue() # type: ignore[assignment] + self.log_queue: asyncio.Queue[GCSLogQueueItem] = asyncio.Queue( # type: ignore[assignment] + maxsize=LITELLM_ASYNCIO_QUEUE_MAXSIZE + ) asyncio.create_task(self.periodic_flush()) AdditionalLoggingUtils.__init__(self) @@ -69,6 +72,9 @@ class GCSBucketLogger(GCSBucketBase, AdditionalLoggingUtils): ) if logging_payload is None: raise ValueError("standard_logging_object not found in kwargs") + # When queue is at maxsize, flush immediately to make room (no blocking, no data dropped) + if self.log_queue.full(): + await self.flush_queue() await self.log_queue.put( GCSLogQueueItem( payload=logging_payload, kwargs=kwargs, response_obj=response_obj @@ -91,9 +97,9 @@ class GCSBucketLogger(GCSBucketBase, AdditionalLoggingUtils): ) if logging_payload is None: raise ValueError("standard_logging_object not found in kwargs") - # Add to logging queue - this will be flushed periodically - # Use asyncio.Queue.put() for thread-safe concurrent access - # If queue is full, this will block until space is available (backpressure) + # When queue is at maxsize, flush immediately to make room (no blocking, no data dropped) + if self.log_queue.full(): + await self.flush_queue() await self.log_queue.put( GCSLogQueueItem( payload=logging_payload, kwargs=kwargs, response_obj=response_obj diff --git a/litellm/integrations/opentelemetry.py b/litellm/integrations/opentelemetry.py index 296a88f9a0b..b847180174a 100644 --- a/litellm/integrations/opentelemetry.py +++ b/litellm/integrations/opentelemetry.py @@ -5,6 +5,10 @@ from typing import TYPE_CHECKING, Any, Dict, List, Optional, Union, cast import litellm from litellm._logging import verbose_logger +from litellm.integrations._types.open_inference import ( + OpenInferenceSpanKindValues, + SpanAttributes, +) from litellm.integrations.custom_logger import CustomLogger from litellm.litellm_core_utils.safe_json_dumps import safe_dumps from litellm.secret_managers.main import get_secret_bool @@ -17,10 +21,6 @@ from litellm.types.utils import ( StandardCallbackDynamicParams, StandardLoggingPayload, ) -from litellm.integrations._types.open_inference import ( - OpenInferenceSpanKindValues, - SpanAttributes, -) # OpenTelemetry imports moved to individual functions to avoid import errors when not installed @@ -40,7 +40,9 @@ if TYPE_CHECKING: Context = Union[_Context, Any] SpanExporter = Union[_SpanExporter, Any] UserAPIKeyAuth = Union[_UserAPIKeyAuth, Any] - ManagementEndpointLoggingPayload = Union[_ManagementEndpointLoggingPayload, Any] + ManagementEndpointLoggingPayload = Union[ + _ManagementEndpointLoggingPayload, Any + ] else: Span = Any Tracer = Any @@ -70,6 +72,13 @@ class OpenTelemetryConfig: model_id: Optional[str] = None def __post_init__(self) -> None: + # If endpoint is specified but exporter is still the default "console", + # automatically infer "otlp_http" to send traces to the endpoint. + # This fixes an issue where UI-configured OTEL settings would default + # to console output instead of sending traces to the configured endpoint. + if self.endpoint and isinstance(self.exporter, str) and self.exporter == "console": + self.exporter = "otlp_http" + if not self.service_name: self.service_name = os.getenv("OTEL_SERVICE_NAME", "litellm") if not self.deployment_environment: @@ -95,12 +104,16 @@ class OpenTelemetryConfig: exporter = os.getenv( "OTEL_EXPORTER_OTLP_PROTOCOL", os.getenv("OTEL_EXPORTER", "console") ) - endpoint = os.getenv("OTEL_EXPORTER_OTLP_ENDPOINT", os.getenv("OTEL_ENDPOINT")) + endpoint = os.getenv( + "OTEL_EXPORTER_OTLP_ENDPOINT", os.getenv("OTEL_ENDPOINT") + ) headers = os.getenv( "OTEL_EXPORTER_OTLP_HEADERS", os.getenv("OTEL_HEADERS") ) # example: OTEL_HEADERS=x-honeycomb-team=B85YgLm96***" enable_metrics: bool = ( - os.getenv("LITELLM_OTEL_INTEGRATION_ENABLE_METRICS", "false").lower() + os.getenv( + "LITELLM_OTEL_INTEGRATION_ENABLE_METRICS", "false" + ).lower() == "true" ) enable_events: bool = ( @@ -108,7 +121,9 @@ class OpenTelemetryConfig: == "true" ) service_name = os.getenv("OTEL_SERVICE_NAME", "litellm") - deployment_environment = os.getenv("OTEL_ENVIRONMENT_NAME", "production") + deployment_environment = os.getenv( + "OTEL_ENVIRONMENT_NAME", "production" + ) model_id = os.getenv("OTEL_MODEL_ID", service_name) if exporter == "in_memory": @@ -157,7 +172,9 @@ class OpenTelemetry(CustomLogger): logging.getLogger(__name__) # Enable OpenTelemetry logging - otel_exporter_logger = logging.getLogger("opentelemetry.sdk.trace.export") + otel_exporter_logger = logging.getLogger( + "opentelemetry.sdk.trace.export" + ) otel_exporter_logger.setLevel(logging.DEBUG) # init CustomLogger params @@ -253,7 +270,9 @@ class OpenTelemetry(CustomLogger): # Don't call set_provider to preserve existing context else: # Default proxy provider or unknown type, create our own - verbose_logger.debug("OpenTelemetry: Creating new %s", provider_name) + verbose_logger.debug( + "OpenTelemetry: Creating new %s", provider_name + ) provider = create_new_provider_fn() set_provider_fn(provider) except Exception as e: @@ -274,7 +293,9 @@ class OpenTelemetry(CustomLogger): from opentelemetry.trace import SpanKind def create_tracer_provider(): - provider = TracerProvider(resource=self._get_litellm_resource(self.config)) + provider = TracerProvider( + resource=self._get_litellm_resource(self.config) + ) provider.add_span_processor(self._get_span_processor()) return provider @@ -388,10 +409,14 @@ class OpenTelemetry(CustomLogger): def log_failure_event(self, kwargs, response_obj, start_time, end_time): self._handle_failure(kwargs, response_obj, start_time, end_time) - async def async_log_success_event(self, kwargs, response_obj, start_time, end_time): + async def async_log_success_event( + self, kwargs, response_obj, start_time, end_time + ): self._handle_success(kwargs, response_obj, start_time, end_time) - async def async_log_failure_event(self, kwargs, response_obj, start_time, end_time): + async def async_log_failure_event( + self, kwargs, response_obj, start_time, end_time + ): self._handle_failure(kwargs, response_obj, start_time, end_time) async def async_service_success_hook( @@ -588,7 +613,9 @@ class OpenTelemetry(CustomLogger): if dynamic_headers is not None: # Create spans using a temporary tracer with dynamic headers - tracer_to_use = self._get_tracer_with_dynamic_headers(dynamic_headers) + tracer_to_use = self._get_tracer_with_dynamic_headers( + dynamic_headers + ) verbose_logger.debug( "Using dynamic headers for this request: %s", dynamic_headers ) @@ -624,7 +651,9 @@ class OpenTelemetry(CustomLogger): ) # Create a temporary tracer provider with dynamic headers - temp_provider = TracerProvider(resource=self._get_litellm_resource(self.config)) + temp_provider = TracerProvider( + resource=self._get_litellm_resource(self.config) + ) temp_provider.add_span_processor( self._get_span_processor(dynamic_headers=dynamic_headers) ) @@ -755,7 +784,9 @@ class OpenTelemetry(CustomLogger): metadata = litellm_params.get("metadata") or {} generation_name = metadata.get("generation_name") - raw_span_name = generation_name if generation_name else RAW_REQUEST_SPAN_NAME + raw_span_name = ( + generation_name if generation_name else RAW_REQUEST_SPAN_NAME + ) otel_tracer: Tracer = self.get_tracer_to_use_for_request(kwargs) raw_span = otel_tracer.start_span( @@ -780,7 +811,9 @@ class OpenTelemetry(CustomLogger): } std_log = kwargs.get("standard_logging_object") - md = getattr(std_log, "metadata", None) or (std_log or {}).get("metadata", {}) + md = getattr(std_log, "metadata", None) or (std_log or {}).get( + "metadata", {} + ) for key in [ "user_api_key_hash", "user_api_key_alias", @@ -802,9 +835,9 @@ class OpenTelemetry(CustomLogger): common_attrs[f"metadata.{key}"] = str(md[key]) # get hidden params - hidden_params = getattr(std_log, "hidden_params", None) or (std_log or {}).get( - "hidden_params", {} - ) + hidden_params = getattr(std_log, "hidden_params", None) or ( + std_log or {} + ).get("hidden_params", {}) if hidden_params: common_attrs["hidden_params"] = safe_dumps(hidden_params) @@ -838,7 +871,9 @@ class OpenTelemetry(CustomLogger): self._record_response_duration_metric(kwargs, end_time, common_attrs) @staticmethod - def _to_timestamp(val: Optional[Union[datetime, float, str]]) -> Optional[float]: + def _to_timestamp( + val: Optional[Union[datetime, float, str]], + ) -> Optional[float]: """Convert datetime/float/string to timestamp.""" if val is None: return None @@ -855,7 +890,9 @@ class OpenTelemetry(CustomLogger): except ValueError: return None - def _record_time_to_first_token_metric(self, kwargs: dict, common_attrs: dict): + def _record_time_to_first_token_metric( + self, kwargs: dict, common_attrs: dict + ): """Record Time to First Token (TTFT) metric for streaming requests.""" optional_params = kwargs.get("optional_params", {}) is_streaming = optional_params.get("stream", False) @@ -868,7 +905,10 @@ class OpenTelemetry(CustomLogger): api_call_start_time = kwargs.get("api_call_start_time", None) completion_start_time = kwargs.get("completion_start_time", None) - if api_call_start_time is not None and completion_start_time is not None: + if ( + api_call_start_time is not None + and completion_start_time is not None + ): # Convert to timestamps if needed (handles datetime, float, and string) api_call_start_ts = self._to_timestamp(api_call_start_time) completion_start_ts = self._to_timestamp(completion_start_time) @@ -876,7 +916,9 @@ class OpenTelemetry(CustomLogger): if api_call_start_ts is None or completion_start_ts is None: return # Skip recording if conversion failed - time_to_first_token_seconds = completion_start_ts - api_call_start_ts + time_to_first_token_seconds = ( + completion_start_ts - api_call_start_ts + ) self._time_to_first_token_histogram.record( time_to_first_token_seconds, attributes=common_attrs ) @@ -946,7 +988,9 @@ class OpenTelemetry(CustomLogger): generation_time_seconds = duration_s if generation_time_seconds > 0: - time_per_output_token_seconds = generation_time_seconds / completion_tokens + time_per_output_token_seconds = ( + generation_time_seconds / completion_tokens + ) self._time_per_output_token_histogram.record( time_per_output_token_seconds, attributes=common_attrs ) @@ -1007,21 +1051,26 @@ class OpenTelemetry(CustomLogger): # See: https://github.com/open-telemetry/opentelemetry-python/pull/4676 # TODO: Refactor to use the proper OTEL Logs API instead of directly creating SDK LogRecords - from opentelemetry._logs import SeverityNumber, get_logger, get_logger_provider + from opentelemetry._logs import ( + SeverityNumber, + get_logger, + ) - try: - from opentelemetry.sdk._logs import LogRecord as SdkLogRecord # type: ignore[attr-defined] # OTEL < 1.39.0 - except ImportError: - from opentelemetry.sdk._logs._internal import LogRecord as SdkLogRecord # type: ignore[attr-defined, no-redef] # OTEL >= 1.39.0 + # MyPy evaluates both branches of try/except imports and can fail when + # newer OTEL stubs remove/relocate symbols. Gate the typing import so + # only the canonical location is type-checked. + if TYPE_CHECKING: + from opentelemetry.sdk._logs._internal import LogRecord as SdkLogRecord + else: + try: + from opentelemetry.sdk._logs import ( + LogRecord as SdkLogRecord, # type: ignore[attr-defined] + ) + except ImportError: + from opentelemetry.sdk._logs._internal import LogRecord as SdkLogRecord otel_logger = get_logger(LITELLM_LOGGER_NAME) - # Get the resource from the logger provider - logger_provider = get_logger_provider() - resource = getattr( - logger_provider, "_resource", None - ) or self._get_litellm_resource(self.config) - parent_ctx = span.get_span_context() provider = (kwargs.get("litellm_params") or {}).get( "custom_llm_provider", "Unknown" @@ -1030,7 +1079,10 @@ class OpenTelemetry(CustomLogger): # per-message events for msg in kwargs.get("messages", []): role = msg.get("role", "user") - attrs = {"event_name": "gen_ai.content.prompt", "gen_ai.system": provider} + attrs = { + "event_name": "gen_ai.content.prompt", + "gen_ai.system": provider, + } if role == "tool" and msg.get("id"): attrs["id"] = msg["id"] if self.message_logging and msg.get("content"): @@ -1044,7 +1096,6 @@ class OpenTelemetry(CustomLogger): severity_number=SeverityNumber.INFO, severity_text="INFO", body=msg.copy(), - resource=resource, attributes=attrs, ) otel_logger.emit(log_record) @@ -1076,7 +1127,6 @@ class OpenTelemetry(CustomLogger): severity_number=SeverityNumber.INFO, severity_text="INFO", body=body, - resource=resource, attributes=attrs, ) otel_logger.emit(log_record) @@ -1146,7 +1196,9 @@ class OpenTelemetry(CustomLogger): value=guardrail_information.get("guardrail_mode"), ) - masked_entity_count = guardrail_information.get("masked_entity_count") + masked_entity_count = guardrail_information.get( + "masked_entity_count" + ) if masked_entity_count is not None: guardrail_span.set_attribute( "masked_entity_count", safe_dumps(masked_entity_count) @@ -1173,8 +1225,9 @@ class OpenTelemetry(CustomLogger): # Decide whether to create a primary span # Always create if no parent span exists (backward compatibility) # OR if USE_OTEL_LITELLM_REQUEST_SPAN is explicitly enabled - should_create_primary_span = parent_otel_span is None or get_secret_bool( - "USE_OTEL_LITELLM_REQUEST_SPAN" + should_create_primary_span = ( + parent_otel_span is None + or get_secret_bool("USE_OTEL_LITELLM_REQUEST_SPAN") ) if should_create_primary_span: @@ -1200,7 +1253,9 @@ class OpenTelemetry(CustomLogger): if parent_otel_span.is_recording(): parent_otel_span.set_status(Status(StatusCode.ERROR)) self.set_attributes(parent_otel_span, kwargs, response_obj) - self._record_exception_on_span(span=parent_otel_span, kwargs=kwargs) + self._record_exception_on_span( + span=parent_otel_span, kwargs=kwargs + ) # Create span for guardrail information self._create_guardrail_span(kwargs=kwargs, context=_parent_context) @@ -1223,7 +1278,9 @@ class OpenTelemetry(CustomLogger): 2. Sets structured error attributes from StandardLoggingPayloadErrorInformation """ try: - from litellm.integrations._types.open_inference import ErrorAttributes + from litellm.integrations._types.open_inference import ( + ErrorAttributes, + ) # Get the exception object if available exception = kwargs.get("exception") @@ -1233,15 +1290,17 @@ class OpenTelemetry(CustomLogger): span.record_exception(exception) # Get StandardLoggingPayload for structured error information - standard_logging_payload: Optional[StandardLoggingPayload] = kwargs.get( - "standard_logging_object" + standard_logging_payload: Optional[StandardLoggingPayload] = ( + kwargs.get("standard_logging_object") ) if standard_logging_payload is None: return # Extract error_information from StandardLoggingPayload - error_information = standard_logging_payload.get("error_information") + error_information = standard_logging_payload.get( + "error_information" + ) if error_information is None: # Fallback to error_str if error_information is not available @@ -1331,7 +1390,9 @@ class OpenTelemetry(CustomLogger): ) pass - def cast_as_primitive_value_type(self, value) -> Union[str, bool, int, float]: + def cast_as_primitive_value_type( + self, value + ) -> Union[str, bool, int, float]: """ Casts the value to a primitive OTEL type if it is not already a primitive type. @@ -1401,8 +1462,8 @@ class OpenTelemetry(CustomLogger): optional_params = kwargs.get("optional_params", {}) litellm_params = kwargs.get("litellm_params", {}) or {} - standard_logging_payload: Optional[StandardLoggingPayload] = kwargs.get( - "standard_logging_object" + standard_logging_payload: Optional[StandardLoggingPayload] = ( + kwargs.get("standard_logging_object") ) if standard_logging_payload is None: raise ValueError("standard_logging_object not found in kwargs") @@ -1424,11 +1485,13 @@ class OpenTelemetry(CustomLogger): ) or (standard_logging_payload or {}).get("hidden_params", {}) if hidden_params: self.safe_set_attribute( - span=span, key="hidden_params", value=safe_dumps(hidden_params) + span=span, + key="hidden_params", + value=safe_dumps(hidden_params), ) # Cost breakdown tracking - cost_breakdown: Optional[CostBreakdown] = standard_logging_payload.get( - "cost_breakdown" + cost_breakdown: Optional[CostBreakdown] = ( + standard_logging_payload.get("cost_breakdown") ) if cost_breakdown: for key, value in cost_breakdown.items(): @@ -1504,7 +1567,9 @@ class OpenTelemetry(CustomLogger): # The unique identifier for the completion. if response_obj and response_obj.get("id"): self.safe_set_attribute( - span=span, key="gen_ai.response.id", value=response_obj.get("id") + span=span, + key="gen_ai.response.id", + value=response_obj.get("id"), ) # The model used to generate the response. @@ -1639,7 +1704,9 @@ class OpenTelemetry(CustomLogger): "OpenTelemetry logging error in set_attributes %s", str(e) ) - def _cast_as_primitive_value_type(self, value) -> Union[str, bool, int, float]: + def _cast_as_primitive_value_type( + self, value + ) -> Union[str, bool, int, float]: """ Casts the value to a primitive OTEL type if it is not already a primitive type. @@ -1673,7 +1740,10 @@ class OpenTelemetry(CustomLogger): if isinstance(messages, str): # Handle system_instructions passed as a string return [ - {"role": "system", "parts": [{"type": "text", "content": messages}]} + { + "role": "system", + "parts": [{"type": "text", "content": messages}], + } ] transformed = [] @@ -1714,9 +1784,11 @@ class OpenTelemetry(CustomLogger): message = choice.get("message") or {} finish_reason = choice.get("finish_reason") - transformed_msg = self._transform_messages_to_otel_semantic_conventions( - [message] - )[0] + transformed_msg = ( + self._transform_messages_to_otel_semantic_conventions( + [message] + )[0] + ) if finish_reason: transformed_msg["finish_reason"] = finish_reason @@ -1728,7 +1800,9 @@ class OpenTelemetry(CustomLogger): self.set_attributes(span, kwargs, response_obj) kwargs.get("optional_params", {}) litellm_params = kwargs.get("litellm_params", {}) or {} - custom_llm_provider = litellm_params.get("custom_llm_provider", "Unknown") + custom_llm_provider = litellm_params.get( + "custom_llm_provider", "Unknown" + ) _raw_response = kwargs.get("original_response") _additional_args = kwargs.get("additional_args", {}) or {} @@ -1741,7 +1815,9 @@ class OpenTelemetry(CustomLogger): if complete_input_dict and isinstance(complete_input_dict, dict): for param, val in complete_input_dict.items(): self.safe_set_attribute( - span=span, key=f"llm.{custom_llm_provider}.{param}", value=val + span=span, + key=f"llm.{custom_llm_provider}.{param}", + value=val, ) ############################################# @@ -1773,7 +1849,8 @@ class OpenTelemetry(CustomLogger): ) except Exception as e: verbose_logger.exception( - "OpenTelemetry logging error in set_raw_request_attributes %s", str(e) + "OpenTelemetry logging error in set_raw_request_attributes %s", + str(e), ) def _to_ns(self, dt): @@ -1813,7 +1890,9 @@ class OpenTelemetry(CustomLogger): ) litellm_params = kwargs.get("litellm_params", {}) or {} - proxy_server_request = litellm_params.get("proxy_server_request", {}) or {} + proxy_server_request = ( + litellm_params.get("proxy_server_request", {}) or {} + ) headers = proxy_server_request.get("headers", {}) or {} traceparent = headers.get("traceparent", None) _metadata = litellm_params.get("metadata", {}) or {} @@ -1832,7 +1911,10 @@ class OpenTelemetry(CustomLogger): "OpenTelemetry: Using traceparent header for context propagation" ) carrier = {"traceparent": traceparent} - return TraceContextTextMapPropagator().extract(carrier=carrier), None + return ( + TraceContextTextMapPropagator().extract(carrier=carrier), + None, + ) # Priority 3: Active span from global context (auto-detection) try: @@ -1960,10 +2042,14 @@ class OpenTelemetry(CustomLogger): self.OTEL_HEADERS, ) - _split_otel_headers = OpenTelemetry._get_headers_dictionary(self.OTEL_HEADERS) + _split_otel_headers = OpenTelemetry._get_headers_dictionary( + self.OTEL_HEADERS + ) # Normalize endpoint for logs - ensure it points to /v1/logs instead of /v1/traces - normalized_endpoint = self._normalize_otel_endpoint(self.OTEL_ENDPOINT, "logs") + normalized_endpoint = self._normalize_otel_endpoint( + self.OTEL_ENDPOINT, "logs" + ) verbose_logger.debug( "OpenTelemetry: Log endpoint normalized from %s to %s", @@ -2051,14 +2137,18 @@ class OpenTelemetry(CustomLogger): self.OTEL_HEADERS, ) - _split_otel_headers = OpenTelemetry._get_headers_dictionary(self.OTEL_HEADERS) + _split_otel_headers = OpenTelemetry._get_headers_dictionary( + self.OTEL_HEADERS + ) normalized_endpoint = self._normalize_otel_endpoint( self.OTEL_ENDPOINT, "metrics" ) if self.OTEL_EXPORTER == "console": exporter = ConsoleMetricExporter() - return PeriodicExportingMetricReader(exporter, export_interval_millis=5000) + return PeriodicExportingMetricReader( + exporter, export_interval_millis=5000 + ) elif ( self.OTEL_EXPORTER == "otlp_http" @@ -2074,7 +2164,9 @@ class OpenTelemetry(CustomLogger): headers=_split_otel_headers, preferred_temporality={Histogram: AggregationTemporality.DELTA}, ) - return PeriodicExportingMetricReader(exporter, export_interval_millis=5000) + return PeriodicExportingMetricReader( + exporter, export_interval_millis=5000 + ) elif self.OTEL_EXPORTER == "otlp_grpc" or self.OTEL_EXPORTER == "grpc": try: @@ -2092,7 +2184,9 @@ class OpenTelemetry(CustomLogger): headers=_split_otel_headers, preferred_temporality={Histogram: AggregationTemporality.DELTA}, ) - return PeriodicExportingMetricReader(exporter, export_interval_millis=5000) + return PeriodicExportingMetricReader( + exporter, export_interval_millis=5000 + ) else: verbose_logger.warning( @@ -2100,7 +2194,9 @@ class OpenTelemetry(CustomLogger): self.OTEL_EXPORTER, ) exporter = ConsoleMetricExporter() - return PeriodicExportingMetricReader(exporter, export_interval_millis=5000) + return PeriodicExportingMetricReader( + exporter, export_interval_millis=5000 + ) def _normalize_otel_endpoint( self, endpoint: Optional[str], signal_type: str @@ -2171,7 +2267,9 @@ class OpenTelemetry(CustomLogger): return endpoint @staticmethod - def _get_headers_dictionary(headers: Optional[Union[str, dict]]) -> Dict[str, str]: + def _get_headers_dictionary( + headers: Optional[Union[str, dict]], + ) -> Dict[str, str]: """ Convert a string or dictionary of headers into a dictionary of headers. """ diff --git a/litellm/integrations/posthog.py b/litellm/integrations/posthog.py index dd7c3627b87..c4b6e843d60 100644 --- a/litellm/integrations/posthog.py +++ b/litellm/integrations/posthog.py @@ -17,6 +17,7 @@ from typing import Any, Dict, Optional, Tuple from litellm._logging import verbose_logger from litellm._uuid import uuid from litellm.integrations.custom_batch_logger import CustomBatchLogger +from litellm.litellm_core_utils.safe_json_dumps import safe_dumps from litellm.integrations.posthog_mock_client import ( should_use_posthog_mock, create_mock_posthog_client, @@ -100,7 +101,7 @@ class PostHogLogger(CustomBatchLogger): response = self.sync_client.post( url=capture_url, - json=payload, + content=safe_dumps(payload), headers=headers, ) response.raise_for_status() @@ -356,7 +357,7 @@ class PostHogLogger(CustomBatchLogger): response = await self.async_client.post( url=capture_url, - json=payload, + content=safe_dumps(payload), headers=headers, ) response.raise_for_status() @@ -438,7 +439,7 @@ class PostHogLogger(CustomBatchLogger): response = self.sync_client.post( url=capture_url, - json=payload, + content=safe_dumps(payload), headers=headers, ) response.raise_for_status() diff --git a/litellm/integrations/prometheus.py b/litellm/integrations/prometheus.py index 00c38eac188..1675201f1f1 100644 --- a/litellm/integrations/prometheus.py +++ b/litellm/integrations/prometheus.py @@ -1,6 +1,7 @@ # used for /metrics endpoint on LiteLLM Proxy #### What this does #### # On success, log events to Prometheus +import asyncio import os import sys from datetime import datetime, timedelta @@ -28,7 +29,10 @@ from litellm.proxy._types import ( UserAPIKeyAuth, ) from litellm.types.integrations.prometheus import * -from litellm.types.integrations.prometheus import _sanitize_prometheus_label_name +from litellm.types.integrations.prometheus import ( + _sanitize_prometheus_label_name, + _sanitize_prometheus_label_value, +) from litellm.types.utils import StandardLoggingPayload if TYPE_CHECKING: @@ -1188,28 +1192,34 @@ class PrometheusLogger(CustomLogger): _user_spend = _metadata.get("user_api_key_user_spend", None) _user_max_budget = _metadata.get("user_api_key_user_max_budget", None) - await self._set_api_key_budget_metrics_after_api_request( - user_api_key=user_api_key, - user_api_key_alias=user_api_key_alias, - response_cost=response_cost, - key_max_budget=_api_key_max_budget, - key_spend=_api_key_spend, - ) - - await self._set_team_budget_metrics_after_api_request( - user_api_team=user_api_team, - user_api_team_alias=user_api_team_alias, - team_spend=_team_spend, - team_max_budget=_team_max_budget, - response_cost=response_cost, - ) - - await self._set_user_budget_metrics_after_api_request( - user_id=user_id, - user_spend=_user_spend, - user_max_budget=_user_max_budget, - response_cost=response_cost, + results = await asyncio.gather( + self._set_api_key_budget_metrics_after_api_request( + user_api_key=user_api_key, + user_api_key_alias=user_api_key_alias, + response_cost=response_cost, + key_max_budget=_api_key_max_budget, + key_spend=_api_key_spend, + ), + self._set_team_budget_metrics_after_api_request( + user_api_team=user_api_team, + user_api_team_alias=user_api_team_alias, + team_spend=_team_spend, + team_max_budget=_team_max_budget, + response_cost=response_cost, + ), + self._set_user_budget_metrics_after_api_request( + user_id=user_id, + user_spend=_user_spend, + user_max_budget=_user_max_budget, + response_cost=response_cost, + ), + return_exceptions=True, ) + for i, r in enumerate(results): + if isinstance(r, Exception): + verbose_logger.debug( + f"[Non-Blocking] Prometheus: Budget metric lookup {['key', 'team', 'user'][i]} failed: {r}" + ) def _increment_top_level_request_and_spend_metrics( self, @@ -1269,11 +1279,17 @@ class PrometheusLogger(CustomLogger): ) self.litellm_remaining_api_key_requests_for_model.labels( - user_api_key, user_api_key_alias, model_group, model_id + _sanitize_prometheus_label_value(user_api_key), + _sanitize_prometheus_label_value(user_api_key_alias), + _sanitize_prometheus_label_value(model_group), + _sanitize_prometheus_label_value(model_id), ).set(remaining_requests) self.litellm_remaining_api_key_tokens_for_model.labels( - user_api_key, user_api_key_alias, model_group, model_id + _sanitize_prometheus_label_value(user_api_key), + _sanitize_prometheus_label_value(user_api_key_alias), + _sanitize_prometheus_label_value(model_group), + _sanitize_prometheus_label_value(model_id), ).set(remaining_tokens) def _set_latency_metrics( @@ -1394,14 +1410,14 @@ class PrometheusLogger(CustomLogger): try: self.litellm_llm_api_failed_requests_metric.labels( - end_user_id, - user_api_key, - user_api_key_alias, - model, - user_api_team, - user_api_team_alias, - user_id, - standard_logging_payload.get("model_id", ""), + _sanitize_prometheus_label_value(end_user_id), + _sanitize_prometheus_label_value(user_api_key), + _sanitize_prometheus_label_value(user_api_key_alias), + _sanitize_prometheus_label_value(model), + _sanitize_prometheus_label_value(user_api_team), + _sanitize_prometheus_label_value(user_api_team_alias), + _sanitize_prometheus_label_value(user_id), + _sanitize_prometheus_label_value(standard_logging_payload.get("model_id", "")), ).inc() self.set_llm_deployment_failure_metrics(kwargs) except Exception as e: @@ -2347,7 +2363,11 @@ class PrometheusLogger(CustomLogger): increment metric when litellm.Router / load balancing logic places a deployment in cool down """ self.litellm_deployment_cooled_down.labels( - litellm_model_name, model_id, api_base, api_provider, exception_status + _sanitize_prometheus_label_value(litellm_model_name), + _sanitize_prometheus_label_value(model_id), + _sanitize_prometheus_label_value(api_base), + _sanitize_prometheus_label_value(api_provider), + _sanitize_prometheus_label_value(exception_status), ).inc() def increment_callback_logging_failure( @@ -2898,12 +2918,14 @@ class PrometheusLogger(CustomLogger): max_budget=max_budget, ) try: + # Note: Setting check_db_only=True bypasses cache and hits DB on every request, + # causing huge latency increase and CPU spikes. Keep check_db_only=False. user_info = await get_user_object( user_id=user_id, prisma_client=prisma_client, user_api_key_cache=user_api_key_cache, user_id_upsert=False, - check_db_only=True, + check_db_only=False, ) except Exception as e: verbose_logger.debug( @@ -3065,9 +3087,10 @@ def prometheus_label_factory( # Extract dictionary from Pydantic object enum_dict = enum_values.model_dump() - # Filter supported labels + # Filter supported labels and sanitize values to prevent breaking + # the Prometheus text format (e.g. U+2028 Line Separator in label values) filtered_labels = { - label: value + label: _sanitize_prometheus_label_value(value) for label, value in enum_dict.items() if label in supported_enum_labels } @@ -3085,14 +3108,14 @@ def prometheus_label_factory( # check sanitized key sanitized_key = _sanitize_prometheus_label_name(key) if sanitized_key in supported_enum_labels: - filtered_labels[sanitized_key] = value + filtered_labels[sanitized_key] = _sanitize_prometheus_label_value(value) # Add custom tags if configured if enum_values.tags is not None: custom_tag_labels = get_custom_labels_from_tags(enum_values.tags) for key, value in custom_tag_labels.items(): if key in supported_enum_labels: - filtered_labels[key] = value + filtered_labels[key] = _sanitize_prometheus_label_value(value) for label in supported_enum_labels: if label not in filtered_labels: diff --git a/litellm/integrations/websearch_interception/handler.py b/litellm/integrations/websearch_interception/handler.py index 5d36b760afb..1277cac51d7 100644 --- a/litellm/integrations/websearch_interception/handler.py +++ b/litellm/integrations/websearch_interception/handler.py @@ -17,6 +17,7 @@ from litellm.integrations.custom_logger import CustomLogger from litellm.integrations.websearch_interception.tools import ( get_litellm_web_search_tool, is_web_search_tool, + is_web_search_tool_chat_completion, ) from litellm.integrations.websearch_interception.transformation import ( WebSearchTransformation, @@ -48,7 +49,8 @@ class WebSearchInterceptionLogger(CustomLogger): Args: enabled_providers: List of LLM providers to enable interception for. Use LlmProviders enum values (e.g., [LlmProviders.BEDROCK]) - Default: [LlmProviders.BEDROCK] + If None or empty list, enables for ALL providers. + Default: None (all providers enabled) search_tool_name: Name of search tool configured in router's search_tools. If None, will attempt to use first available search tool. """ @@ -183,10 +185,10 @@ class WebSearchInterceptionLogger(CustomLogger): verbose_logger.debug( f"WebSearchInterception: Pre-request hook called" f" - custom_llm_provider={custom_llm_provider}" - f" - enabled_providers={self.enabled_providers}" + f" - enabled_providers={self.enabled_providers or 'ALL'}" ) - if custom_llm_provider not in self.enabled_providers: + if self.enabled_providers is not None and custom_llm_provider not in self.enabled_providers: verbose_logger.debug( f"WebSearchInterception: Skipping - provider {custom_llm_provider} not in {self.enabled_providers}" ) @@ -245,7 +247,12 @@ class WebSearchInterceptionLogger(CustomLogger): custom_llm_provider: str, kwargs: Dict, ) -> Tuple[bool, Dict]: - """Check if WebSearch tool interception is needed""" + """ + Check if WebSearch tool interception is needed for Anthropic Messages API. + + This is the legacy method for Anthropic-style responses. + For chat completions, use async_should_run_chat_completion_agentic_loop instead. + """ verbose_logger.debug(f"WebSearchInterception: Hook called! provider={custom_llm_provider}, stream={stream}") verbose_logger.debug(f"WebSearchInterception: Response type: {type(response)}") @@ -253,7 +260,7 @@ class WebSearchInterceptionLogger(CustomLogger): # Check if provider should be intercepted # Note: custom_llm_provider is already normalized by get_llm_provider() # (e.g., "bedrock/invoke/..." -> "bedrock") - if custom_llm_provider not in self.enabled_providers: + if self.enabled_providers is not None and custom_llm_provider not in self.enabled_providers: verbose_logger.debug( f"WebSearchInterception: Skipping provider {custom_llm_provider} (not in enabled list: {self.enabled_providers})" ) @@ -267,10 +274,11 @@ class WebSearchInterceptionLogger(CustomLogger): ) return False, {} - # Detect WebSearch tool_use in response + # Detect WebSearch tool_use in response (Anthropic format) should_intercept, tool_calls = WebSearchTransformation.transform_request( response=response, stream=stream, + response_format="anthropic", ) if not should_intercept: @@ -288,6 +296,67 @@ class WebSearchInterceptionLogger(CustomLogger): "tool_calls": tool_calls, "tool_type": "websearch", "provider": custom_llm_provider, + "response_format": "anthropic", + } + return True, tools_dict + + async def async_should_run_chat_completion_agentic_loop( + self, + response: Any, + model: str, + messages: List[Dict], + tools: Optional[List[Dict]], + stream: bool, + custom_llm_provider: str, + kwargs: Dict, + ) -> Tuple[bool, Dict]: + """ + Check if WebSearch tool interception is needed for Chat Completions API. + + Similar to async_should_run_agentic_loop but for OpenAI-style chat completions. + """ + + verbose_logger.debug(f"WebSearchInterception: Chat completion hook called! provider={custom_llm_provider}, stream={stream}") + verbose_logger.debug(f"WebSearchInterception: Response type: {type(response)}") + + # Check if provider should be intercepted + if self.enabled_providers is not None and custom_llm_provider not in self.enabled_providers: + verbose_logger.debug( + f"WebSearchInterception: Skipping provider {custom_llm_provider} (not in enabled list: {self.enabled_providers})" + ) + return False, {} + + # Check if tools include any web search tool (strict check for chat completions) + has_websearch_tool = any(is_web_search_tool_chat_completion(t) for t in (tools or [])) + if not has_websearch_tool: + verbose_logger.debug( + "WebSearchInterception: No litellm_web_search tool in request" + ) + return False, {} + + # Detect WebSearch tool_calls in response (OpenAI format) + should_intercept, tool_calls = WebSearchTransformation.transform_request( + response=response, + stream=stream, + response_format="openai", + ) + + if not should_intercept: + verbose_logger.debug( + "WebSearchInterception: No WebSearch tool_calls detected in response" + ) + return False, {} + + verbose_logger.debug( + f"WebSearchInterception: Detected {len(tool_calls)} WebSearch tool call(s), executing agentic loop" + ) + + # Return tools dict with tool calls + tools_dict = { + "tool_calls": tool_calls, + "tool_type": "websearch", + "provider": custom_llm_provider, + "response_format": "openai", } return True, tools_dict @@ -303,7 +372,11 @@ class WebSearchInterceptionLogger(CustomLogger): stream: bool, kwargs: Dict, ) -> Any: - """Execute agentic loop with WebSearch execution""" + """ + Execute agentic loop with WebSearch execution for Anthropic Messages API. + + This is the legacy method for Anthropic-style responses. + """ tool_calls = tools["tool_calls"] @@ -321,6 +394,41 @@ class WebSearchInterceptionLogger(CustomLogger): kwargs=kwargs, ) + async def async_run_chat_completion_agentic_loop( + self, + tools: Dict, + model: str, + messages: List[Dict], + response: Any, + optional_params: Dict, + logging_obj: Any, + stream: bool, + kwargs: Dict, + ) -> Any: + """ + Execute agentic loop with WebSearch execution for Chat Completions API. + + Similar to async_run_agentic_loop but for OpenAI-style chat completions. + """ + + tool_calls = tools["tool_calls"] + response_format = tools.get("response_format", "openai") + + verbose_logger.debug( + f"WebSearchInterception: Executing chat completion agentic loop for {len(tool_calls)} search(es)" + ) + + return await self._execute_chat_completion_agentic_loop( + model=model, + messages=messages, + tool_calls=tool_calls, + optional_params=optional_params, + logging_obj=logging_obj, + stream=stream, + kwargs=kwargs, + response_format=response_format, + ) + async def _execute_agentic_loop( self, model: str, @@ -382,7 +490,8 @@ class WebSearchInterceptionLogger(CustomLogger): ) # Make follow-up request with search results - follow_up_messages = messages + [assistant_message, user_message] + # Type cast: user_message is a Dict for Anthropic format (default response_format) + follow_up_messages = messages + [assistant_message, cast(Dict, user_message)] verbose_logger.debug( "WebSearchInterception: Making follow-up request with search results" @@ -521,6 +630,150 @@ class WebSearchInterceptionLogger(CustomLogger): ) raise + async def _execute_chat_completion_agentic_loop( # noqa: PLR0915 + self, + model: str, + messages: List[Dict], + tool_calls: List[Dict], + optional_params: Dict, + logging_obj: Any, + stream: bool, + kwargs: Dict, + response_format: str = "openai", + ) -> Any: + """Execute litellm.search() and make follow-up chat completion request""" + + # Extract search queries from tool_calls + search_tasks = [] + for tool_call in tool_calls: + # Handle both Anthropic-style input and OpenAI-style function.arguments + query = None + if "input" in tool_call and isinstance(tool_call["input"], dict): + query = tool_call["input"].get("query") + elif "function" in tool_call: + func = tool_call["function"] + if isinstance(func, dict): + args = func.get("arguments", {}) + if isinstance(args, dict): + query = args.get("query") + + if query: + verbose_logger.debug( + f"WebSearchInterception: Queuing search for query='{query}'" + ) + search_tasks.append(self._execute_search(query)) + else: + verbose_logger.warning( + f"WebSearchInterception: Tool call {tool_call.get('id')} has no query" + ) + # Add empty result for tools without query + search_tasks.append(self._create_empty_search_result()) + + # Execute searches in parallel + verbose_logger.debug( + f"WebSearchInterception: Executing {len(search_tasks)} search(es) in parallel" + ) + search_results = await asyncio.gather(*search_tasks, return_exceptions=True) + + # Handle any exceptions in search results + final_search_results: List[str] = [] + for i, result in enumerate(search_results): + if isinstance(result, Exception): + verbose_logger.error( + f"WebSearchInterception: Search {i} failed with error: {str(result)}" + ) + final_search_results.append( + f"Search failed: {str(result)}" + ) + elif isinstance(result, str): + final_search_results.append(cast(str, result)) + else: + verbose_logger.warning( + f"WebSearchInterception: Unexpected result type {type(result)} at index {i}" + ) + final_search_results.append(str(result)) + + # Build assistant and tool messages using transformation + assistant_message, tool_messages_or_user = WebSearchTransformation.transform_response( + tool_calls=tool_calls, + search_results=final_search_results, + response_format=response_format, + ) + + # Make follow-up request with search results + # For OpenAI format, tool_messages_or_user is a list of tool messages + if response_format == "openai": + follow_up_messages = messages + [assistant_message] + cast(List[Dict], tool_messages_or_user) + else: + # For Anthropic format (shouldn't happen in this method, but handle it) + follow_up_messages = messages + [assistant_message, cast(Dict, tool_messages_or_user)] + + verbose_logger.debug( + "WebSearchInterception: Making follow-up chat completion request with search results" + ) + verbose_logger.debug( + f"WebSearchInterception: Follow-up messages count: {len(follow_up_messages)}" + ) + + # Use litellm.acompletion for follow-up request + try: + # Remove internal parameters that shouldn't be passed to follow-up request + internal_params = { + '_websearch_interception', + 'acompletion', + 'litellm_logging_obj', + 'custom_llm_provider', + 'model_alias_map', + 'stream_response', + 'custom_prompt_dict', + } + kwargs_for_followup = { + k: v for k, v in kwargs.items() + if not k.startswith('_websearch_interception') and k not in internal_params + } + + # Get full model name from kwargs + full_model_name = model + if "custom_llm_provider" in kwargs: + custom_llm_provider = kwargs["custom_llm_provider"] + # Reconstruct full model name with provider prefix if needed + if not model.startswith(custom_llm_provider): + # Check if model already has a provider prefix + if "/" not in model: + full_model_name = f"{custom_llm_provider}/{model}" + + verbose_logger.debug( + f"WebSearchInterception: Using model name: {full_model_name}" + ) + + # Prepare tools for follow-up request (same as original) + tools_param = optional_params.get("tools") + + # Remove tools and extra_body from optional_params to avoid issues + # extra_body often contains internal LiteLLM params that shouldn't be forwarded + optional_params_clean = { + k: v for k, v in optional_params.items() + if k not in {"tools", "extra_body", "model_alias_map","stream_response", "custom_prompt_dict" } + } + + final_response = await litellm.acompletion( + model=full_model_name, + messages=follow_up_messages, + tools=tools_param, + **optional_params_clean, + **kwargs_for_followup, + ) + + verbose_logger.debug( + f"WebSearchInterception: Follow-up request completed, response type: {type(final_response)}" + ) + return final_response + except Exception as e: + verbose_logger.exception( + f"WebSearchInterception: Follow-up request failed: {str(e)}" + ) + raise + async def _create_empty_search_result(self) -> str: """Create an empty search result for tool calls without queries""" return "No search query provided" diff --git a/litellm/integrations/websearch_interception/tools.py b/litellm/integrations/websearch_interception/tools.py index 4f8b7372fe3..c39d150fb19 100644 --- a/litellm/integrations/websearch_interception/tools.py +++ b/litellm/integrations/websearch_interception/tools.py @@ -49,12 +49,57 @@ def get_litellm_web_search_tool() -> Dict[str, Any]: } +def is_web_search_tool_chat_completion(tool: Dict[str, Any]) -> bool: + """ + Check if a tool is a web search tool for Chat Completions API (strict check). + + This is a stricter version that ONLY checks for the exact LiteLLM web search tool name. + Use this for Chat Completions API to avoid false positives with user-defined tools. + + Detects ONLY: + - LiteLLM standard: name == "litellm_web_search" (Anthropic format) + - OpenAI format: type == "function" with function.name == "litellm_web_search" + + Args: + tool: Tool dictionary to check + + Returns: + True if tool is exactly the LiteLLM web search tool + + Example: + >>> is_web_search_tool_chat_completion({"name": "litellm_web_search"}) + True + >>> is_web_search_tool_chat_completion({"type": "function", "function": {"name": "litellm_web_search"}}) + True + >>> is_web_search_tool_chat_completion({"name": "web_search"}) + False + >>> is_web_search_tool_chat_completion({"name": "WebSearch"}) + False + """ + tool_name = tool.get("name", "") + tool_type = tool.get("type", "") + + # Check for OpenAI format: {"type": "function", "function": {"name": "litellm_web_search"}} + if tool_type == "function" and "function" in tool: + function_def = tool.get("function", {}) + function_name = function_def.get("name", "") + if function_name == LITELLM_WEB_SEARCH_TOOL_NAME: + return True + + # Check for LiteLLM standard tool (Anthropic format) + if tool_name == LITELLM_WEB_SEARCH_TOOL_NAME: + return True + + return False + + def is_web_search_tool(tool: Dict[str, Any]) -> bool: """ Check if a tool is a web search tool (native or LiteLLM standard). Detects: - LiteLLM standard: name == "litellm_web_search" + - OpenAI format: type == "function" with function.name == "litellm_web_search" - Anthropic native: type starts with "web_search_" (e.g., "web_search_20250305") - Claude Code: name == "web_search" with a type field - Custom: name == "WebSearch" (legacy format) @@ -68,6 +113,8 @@ def is_web_search_tool(tool: Dict[str, Any]) -> bool: Example: >>> is_web_search_tool({"name": "litellm_web_search"}) True + >>> is_web_search_tool({"type": "function", "function": {"name": "litellm_web_search"}}) + True >>> is_web_search_tool({"type": "web_search_20250305", "name": "web_search"}) True >>> is_web_search_tool({"name": "calculator"}) @@ -75,8 +122,15 @@ def is_web_search_tool(tool: Dict[str, Any]) -> bool: """ tool_name = tool.get("name", "") tool_type = tool.get("type", "") + + # Check for OpenAI format: {"type": "function", "function": {"name": "..."}} + if tool_type == "function" and "function" in tool: + function_def = tool.get("function", {}) + function_name = function_def.get("name", "") + if function_name == LITELLM_WEB_SEARCH_TOOL_NAME: + return True - # Check for LiteLLM standard tool + # Check for LiteLLM standard tool (Anthropic format) if tool_name == LITELLM_WEB_SEARCH_TOOL_NAME: return True diff --git a/litellm/integrations/websearch_interception/transformation.py b/litellm/integrations/websearch_interception/transformation.py index 313358822a5..e44ec35c3a2 100644 --- a/litellm/integrations/websearch_interception/transformation.py +++ b/litellm/integrations/websearch_interception/transformation.py @@ -1,10 +1,10 @@ """ WebSearch Tool Transformation -Transforms between Anthropic tool_use format and LiteLLM search format. +Transforms between Anthropic/OpenAI tool_use format and LiteLLM search format. """ - -from typing import Any, Dict, List, Tuple +import json +from typing import Any, Dict, List, Tuple, Union from litellm._logging import verbose_logger from litellm.constants import LITELLM_WEB_SEARCH_TOOL_NAME @@ -17,28 +17,31 @@ class WebSearchTransformation: Handles transformation between: - Anthropic tool_use format → LiteLLM search requests - - LiteLLM SearchResponse → Anthropic tool_result format + - OpenAI tool_calls format → LiteLLM search requests + - LiteLLM SearchResponse → Anthropic/OpenAI tool_result format """ @staticmethod def transform_request( response: Any, stream: bool, + response_format: str = "anthropic", ) -> Tuple[bool, List[Dict]]: """ - Transform Anthropic response to extract WebSearch tool calls. + Transform model response to extract WebSearch tool calls. - Detects if response contains WebSearch tool_use blocks and extracts + Detects if response contains WebSearch tool_use/tool_calls blocks and extracts the search queries for execution. Args: - response: Model response (dict or AnthropicMessagesResponse) + response: Model response (dict, AnthropicMessagesResponse, or ModelResponse) stream: Whether response is streaming + response_format: Response format - "anthropic" or "openai" (default: "anthropic") Returns: (has_websearch, tool_calls): has_websearch: True if WebSearch tool_use found - tool_calls: List of tool_use dicts with id, name, input + tool_calls: List of tool_use/tool_calls dicts with id, name, input/function Note: Streaming requests are handled by converting stream=True to stream=False @@ -54,8 +57,11 @@ class WebSearchTransformation: ) return False, [] - # Parse non-streaming response - return WebSearchTransformation._detect_from_non_streaming_response(response) + # Parse non-streaming response based on format + if response_format == "openai": + return WebSearchTransformation._detect_from_openai_response(response) + else: + return WebSearchTransformation._detect_from_non_streaming_response(response) @staticmethod def _detect_from_non_streaming_response( @@ -114,26 +120,142 @@ class WebSearchTransformation: return len(tool_calls) > 0, tool_calls + @staticmethod + def _detect_from_openai_response( + response: Any, + ) -> Tuple[bool, List[Dict]]: + """Parse OpenAI-style response for WebSearch tool_calls""" + + # Handle both dict and ModelResponse objects + if isinstance(response, dict): + choices = response.get("choices", []) + else: + if not hasattr(response, "choices"): + verbose_logger.debug( + "WebSearchInterception: Response has no choices attribute" + ) + return False, [] + choices = response.choices or [] + + if not choices: + verbose_logger.debug( + "WebSearchInterception: Response has empty choices" + ) + return False, [] + + # Get first choice's message + first_choice = choices[0] + if isinstance(first_choice, dict): + message = first_choice.get("message", {}) + else: + message = getattr(first_choice, "message", None) + + if not message: + verbose_logger.debug( + "WebSearchInterception: First choice has no message" + ) + return False, [] + + # Get tool_calls from message + if isinstance(message, dict): + openai_tool_calls = message.get("tool_calls", []) + else: + openai_tool_calls = getattr(message, "tool_calls", None) or [] + + if not openai_tool_calls: + verbose_logger.debug( + "WebSearchInterception: Message has no tool_calls" + ) + return False, [] + + # Find all WebSearch tool calls + tool_calls = [] + for tool_call in openai_tool_calls: + # Handle both dict and object tool calls + if isinstance(tool_call, dict): + tool_id = tool_call.get("id") + tool_type = tool_call.get("type") + function = tool_call.get("function", {}) + function_name = function.get("name") if isinstance(function, dict) else getattr(function, "name", None) + function_arguments = function.get("arguments") if isinstance(function, dict) else getattr(function, "arguments", None) + else: + tool_id = getattr(tool_call, "id", None) + tool_type = getattr(tool_call, "type", None) + function = getattr(tool_call, "function", None) + function_name = getattr(function, "name", None) if function else None + function_arguments = getattr(function, "arguments", None) if function else None + + # Check for LiteLLM standard or legacy web search tools + if tool_type == "function" and function_name in ( + LITELLM_WEB_SEARCH_TOOL_NAME, "WebSearch", "web_search" + ): + # Parse arguments (might be JSON string) + if isinstance(function_arguments, str): + try: + arguments = json.loads(function_arguments) + except json.JSONDecodeError: + verbose_logger.warning( + f"WebSearchInterception: Failed to parse function arguments: {function_arguments}" + ) + arguments = {} + else: + arguments = function_arguments or {} + + # Convert to internal format (similar to Anthropic) + tool_call_dict = { + "id": tool_id, + "type": "function", + "name": function_name, + "function": { + "name": function_name, + "arguments": arguments, + }, + "input": arguments, # For compatibility with Anthropic format + } + tool_calls.append(tool_call_dict) + verbose_logger.debug( + f"WebSearchInterception: Found {function_name} tool_call with id={tool_id}" + ) + + return len(tool_calls) > 0, tool_calls + @staticmethod def transform_response( tool_calls: List[Dict], search_results: List[str], - ) -> Tuple[Dict, Dict]: + response_format: str = "anthropic", + ) -> Tuple[Dict, Union[Dict, List[Dict]]]: """ - Transform LiteLLM search results to Anthropic tool_result format. + Transform LiteLLM search results to Anthropic/OpenAI tool_result format. - Builds the assistant and user messages needed for the agentic loop + Builds the assistant and user/tool messages needed for the agentic loop follow-up request. Args: - tool_calls: List of tool_use dicts from transform_request + tool_calls: List of tool_use/tool_calls dicts from transform_request search_results: List of search result strings (one per tool_call) + response_format: Response format - "anthropic" or "openai" (default: "anthropic") Returns: - (assistant_message, user_message): - assistant_message: Message with tool_use blocks - user_message: Message with tool_result blocks + (assistant_message, user_or_tool_messages): + For Anthropic: assistant_message with tool_use blocks, user_message with tool_result blocks + For OpenAI: assistant_message with tool_calls, tool_messages list with tool results """ + if response_format == "openai": + return WebSearchTransformation._transform_response_openai( + tool_calls, search_results + ) + else: + return WebSearchTransformation._transform_response_anthropic( + tool_calls, search_results + ) + + @staticmethod + def _transform_response_anthropic( + tool_calls: List[Dict], + search_results: List[str], + ) -> Tuple[Dict, Dict]: + """Transform to Anthropic format (single user message with tool_result blocks)""" # Build assistant message with tool_use blocks assistant_message = { "role": "assistant", @@ -163,6 +285,40 @@ class WebSearchTransformation: return assistant_message, user_message + @staticmethod + def _transform_response_openai( + tool_calls: List[Dict], + search_results: List[str], + ) -> Tuple[Dict, List[Dict]]: + """Transform to OpenAI format (assistant with tool_calls, separate tool messages)""" + # Build assistant message with tool_calls + assistant_message = { + "role": "assistant", + "tool_calls": [ + { + "id": tc["id"], + "type": "function", + "function": { + "name": tc["name"], + "arguments": json.dumps(tc["input"]) if isinstance(tc["input"], dict) else str(tc["input"]), + }, + } + for tc in tool_calls + ], + } + + # Build separate tool messages (one per tool call) + tool_messages = [ + { + "role": "tool", + "tool_call_id": tool_calls[i]["id"], + "content": search_results[i], + } + for i in range(len(tool_calls)) + ] + + return assistant_message, tool_messages + @staticmethod def format_search_response(result: SearchResponse) -> str: """ diff --git a/litellm/litellm_core_utils/core_helpers.py b/litellm/litellm_core_utils/core_helpers.py index 00695cbfb5b..7c8e2ebeaff 100644 --- a/litellm/litellm_core_utils/core_helpers.py +++ b/litellm/litellm_core_utils/core_helpers.py @@ -94,8 +94,8 @@ def map_finish_reason( return "length" elif finish_reason == "tool_use": # anthropic return "tool_calls" - elif finish_reason == "content_filtered": - return "content_filter" + elif finish_reason == "compaction": + return "length" return finish_reason diff --git a/litellm/litellm_core_utils/env_utils.py b/litellm/litellm_core_utils/env_utils.py new file mode 100644 index 00000000000..34c65275331 --- /dev/null +++ b/litellm/litellm_core_utils/env_utils.py @@ -0,0 +1,21 @@ +""" +Utility helpers for reading and parsing environment variables. +""" + +import os + + +def get_env_int(env_var: str, default: int) -> int: + """Parse an environment variable as an integer, falling back to default on invalid values. + + Handles empty strings, whitespace, and non-numeric values gracefully + so that misconfiguration doesn't crash the process at import time. + """ + raw = os.getenv(env_var) + if raw is None: + return default + raw = raw.strip() + try: + return int(raw) + except (ValueError, TypeError): + return default diff --git a/litellm/litellm_core_utils/get_litellm_params.py b/litellm/litellm_core_utils/get_litellm_params.py index 060e98fd49f..36a8dfdb5a6 100644 --- a/litellm/litellm_core_utils/get_litellm_params.py +++ b/litellm/litellm_core_utils/get_litellm_params.py @@ -1,19 +1,48 @@ from typing import Optional +# Pre-define optional kwargs keys as frozenset for O(1) lookups +# These are extracted from kwargs only if present, avoiding unnecessary .get() calls +_OPTIONAL_KWARGS_KEYS = frozenset({ + "azure_ad_token", + "tenant_id", + "client_id", + "client_secret", + "azure_username", + "azure_password", + "azure_scope", + "timeout", + "bucket_name", + "vertex_credentials", + "vertex_project", + "vertex_location", + "vertex_ai_project", + "vertex_ai_location", + "vertex_ai_credentials", + "aws_region_name", + "aws_access_key_id", + "aws_secret_access_key", + "aws_session_token", + "aws_session_name", + "aws_profile_name", + "aws_role_name", + "aws_web_identity_token", + "aws_sts_endpoint", + "aws_external_id", + "aws_bedrock_runtime_endpoint", + "tpm", + "rpm", +}) + + def _get_base_model_from_litellm_call_metadata( metadata: Optional[dict], ) -> Optional[str]: if metadata is None: return None - - if metadata is not None: - model_info = metadata.get("model_info", {}) - - if model_info is not None: - base_model = model_info.get("base_model", None) - if base_model is not None: - return base_model + model_info = metadata.get("model_info") + if model_info: + return model_info.get("base_model") return None @@ -66,6 +95,7 @@ def get_litellm_params( litellm_request_debug: Optional[bool] = None, **kwargs, ) -> dict: + # Build base dict with explicit parameters (always included) litellm_params = { "acompletion": acompletion, "api_key": api_key, @@ -112,37 +142,15 @@ def get_litellm_params( "ssl_verify": ssl_verify, "merge_reasoning_content_in_choices": merge_reasoning_content_in_choices, "api_version": api_version, - "azure_ad_token": kwargs.get("azure_ad_token"), - "tenant_id": kwargs.get("tenant_id"), - "client_id": kwargs.get("client_id"), - "client_secret": kwargs.get("client_secret"), - "azure_username": kwargs.get("azure_username"), - "azure_password": kwargs.get("azure_password"), - "azure_scope": kwargs.get("azure_scope"), "max_retries": max_retries, - "timeout": kwargs.get("timeout"), - "bucket_name": kwargs.get("bucket_name"), - "vertex_credentials": kwargs.get("vertex_credentials"), - "vertex_project": kwargs.get("vertex_project"), - "vertex_location": kwargs.get("vertex_location"), - "vertex_ai_project": kwargs.get("vertex_ai_project"), - "vertex_ai_location": kwargs.get("vertex_ai_location"), - "vertex_ai_credentials": kwargs.get("vertex_ai_credentials"), "use_litellm_proxy": use_litellm_proxy, "litellm_request_debug": litellm_request_debug, - "aws_region_name": kwargs.get("aws_region_name"), - # AWS credentials for Bedrock/Sagemaker - "aws_access_key_id": kwargs.get("aws_access_key_id"), - "aws_secret_access_key": kwargs.get("aws_secret_access_key"), - "aws_session_token": kwargs.get("aws_session_token"), - "aws_session_name": kwargs.get("aws_session_name"), - "aws_profile_name": kwargs.get("aws_profile_name"), - "aws_role_name": kwargs.get("aws_role_name"), - "aws_web_identity_token": kwargs.get("aws_web_identity_token"), - "aws_sts_endpoint": kwargs.get("aws_sts_endpoint"), - "aws_external_id": kwargs.get("aws_external_id"), - "aws_bedrock_runtime_endpoint": kwargs.get("aws_bedrock_runtime_endpoint"), - "tpm": kwargs.get("tpm"), - "rpm": kwargs.get("rpm"), } + + # Sparse extraction: only add kwargs keys that are actually present + if kwargs: + for key in _OPTIONAL_KWARGS_KEYS: + if key in kwargs: + litellm_params[key] = kwargs[key] + return litellm_params diff --git a/litellm/litellm_core_utils/get_model_cost_map.py b/litellm/litellm_core_utils/get_model_cost_map.py index 9b86f4ca2f0..e622a317454 100644 --- a/litellm/litellm_core_utils/get_model_cost_map.py +++ b/litellm/litellm_core_utils/get_model_cost_map.py @@ -8,40 +8,187 @@ export LITELLM_LOCAL_MODEL_COST_MAP=True ``` """ +import json import os +from importlib.resources import files import httpx +from litellm import verbose_logger +from litellm.constants import ( + MODEL_COST_MAP_MAX_SHRINK_RATIO, + MODEL_COST_MAP_MIN_MODEL_COUNT, +) + + +class GetModelCostMap: + """ + Handles fetching, validating, and loading the model cost map. + + Only the backup model *count* is cached (a single int). The full + backup dict is never held in memory — it is only parsed when it + needs to be *returned* as a fallback. + """ + + _backup_model_count: int = -1 # -1 = not yet loaded + + @staticmethod + def load_local_model_cost_map() -> dict: + """Load the local backup model cost map bundled with the package.""" + content = json.loads( + files("litellm") + .joinpath("model_prices_and_context_window_backup.json") + .read_text(encoding="utf-8") + ) + return content + + @classmethod + def _get_backup_model_count(cls) -> int: + """Return the number of models in the local backup (cached int).""" + if cls._backup_model_count < 0: + backup = cls.load_local_model_cost_map() + cls._backup_model_count = len(backup) + return cls._backup_model_count + + @staticmethod + def _check_is_valid_dict(fetched_map: dict) -> bool: + """Check 1: fetched map is a non-empty dict.""" + if not isinstance(fetched_map, dict): + verbose_logger.warning( + "LiteLLM: Fetched model cost map is not a dict (type=%s). " + "Falling back to local backup.", + type(fetched_map).__name__, + ) + return False + + if len(fetched_map) == 0: + verbose_logger.warning( + "LiteLLM: Fetched model cost map is empty. " + "Falling back to local backup.", + ) + return False + + return True + + @classmethod + def _check_model_count_not_reduced( + cls, + fetched_map: dict, + backup_model_count: int, + min_model_count: int = MODEL_COST_MAP_MIN_MODEL_COUNT, + max_shrink_ratio: float = MODEL_COST_MAP_MAX_SHRINK_RATIO, + ) -> bool: + """Check 2: model count has not reduced significantly vs backup.""" + fetched_count = len(fetched_map) + + if fetched_count < min_model_count: + verbose_logger.warning( + "LiteLLM: Fetched model cost map has only %d models (minimum=%d). " + "This may indicate a corrupted upstream file. " + "Falling back to local backup.", + fetched_count, + min_model_count, + ) + return False + + if backup_model_count > 0 and fetched_count < backup_model_count * max_shrink_ratio: + verbose_logger.warning( + "LiteLLM: Fetched model cost map shrank significantly " + "(fetched=%d, backup=%d, threshold=%.0f%%). " + "This may indicate a corrupted upstream file. " + "Falling back to local backup.", + fetched_count, + backup_model_count, + max_shrink_ratio * 100, + ) + return False + + return True + + @classmethod + def validate_model_cost_map( + cls, + fetched_map: dict, + backup_model_count: int, + min_model_count: int = MODEL_COST_MAP_MIN_MODEL_COUNT, + max_shrink_ratio: float = MODEL_COST_MAP_MAX_SHRINK_RATIO, + ) -> bool: + """ + Validate the integrity of a fetched model cost map. + + Runs each check in order and returns False on the first failure. + + Checks: + 1. ``_check_is_valid_dict`` -- fetched map is a non-empty dict. + 2. ``_check_model_count_not_reduced`` -- model count meets minimum + and has not shrunk >``max_shrink_ratio`` vs backup. + + Returns True if all checks pass, False otherwise. + """ + if not cls._check_is_valid_dict(fetched_map): + return False + + if not cls._check_model_count_not_reduced( + fetched_map=fetched_map, + backup_model_count=backup_model_count, + min_model_count=min_model_count, + max_shrink_ratio=max_shrink_ratio, + ): + return False + + return True + + @staticmethod + def fetch_remote_model_cost_map(url: str, timeout: int = 5) -> dict: + """ + Fetch the model cost map from a remote URL. + + Returns the parsed JSON dict. Raises on network/parse errors + (caller is expected to handle). + """ + response = httpx.get(url, timeout=timeout) + response.raise_for_status() + return response.json() + def get_model_cost_map(url: str) -> dict: - if ( - os.getenv("LITELLM_LOCAL_MODEL_COST_MAP", False) - or os.getenv("LITELLM_LOCAL_MODEL_COST_MAP", False) == "True" - ): - from importlib.resources import files - import json + """ + Public entry point — returns the model cost map dict. - content = json.loads( - files("litellm") - .joinpath("model_prices_and_context_window_backup.json") - .read_text(encoding="utf-8") - ) - return content + 1. If ``LITELLM_LOCAL_MODEL_COST_MAP`` is set, uses the local backup only. + 2. Otherwise fetches from ``url``, validates integrity, and falls back + to the local backup on any failure. + + Only the backup model count is cached (a single int) for validation. + The full backup dict is only parsed when it must be *returned* as a + fallback — it is never held in memory long-term. + """ + # Note: can't use get_secret_bool here — this runs during litellm.__init__ + # before litellm._key_management_settings is set. + if os.getenv("LITELLM_LOCAL_MODEL_COST_MAP", "").lower() == "true": + return GetModelCostMap.load_local_model_cost_map() try: - response = httpx.get( - url, timeout=5 - ) # set a 5 second timeout for the get request - response.raise_for_status() # Raise an exception if the request is unsuccessful - content = response.json() - return content - except Exception: - from importlib.resources import files - import json - - content = json.loads( - files("litellm") - .joinpath("model_prices_and_context_window_backup.json") - .read_text(encoding="utf-8") + content = GetModelCostMap.fetch_remote_model_cost_map(url) + except Exception as e: + verbose_logger.warning( + "LiteLLM: Failed to fetch remote model cost map from %s: %s. " + "Falling back to local backup.", + url, + str(e), ) - return content + return GetModelCostMap.load_local_model_cost_map() + + # Validate using cached count (cheap int comparison, no file I/O) + if not GetModelCostMap.validate_model_cost_map( + fetched_map=content, + backup_model_count=GetModelCostMap._get_backup_model_count(), + ): + verbose_logger.warning( + "LiteLLM: Fetched model cost map failed integrity check. " + "Using local backup instead. url=%s", + url, + ) + return GetModelCostMap.load_local_model_cost_map() + + return content diff --git a/litellm/litellm_core_utils/litellm_logging.py b/litellm/litellm_core_utils/litellm_logging.py index 14015225f38..82a7af64f97 100644 --- a/litellm/litellm_core_utils/litellm_logging.py +++ b/litellm/litellm_core_utils/litellm_logging.py @@ -203,6 +203,10 @@ except Exception as e: EnterpriseStandardLoggingPayloadSetupVAR = None _in_memory_loggers: List[Any] = [] +_STANDARD_LOGGING_METADATA_KEYS: frozenset = frozenset( + StandardLoggingMetadata.__annotations__.keys() +) + ### GLOBAL VARIABLES ### # Cache custom pricing keys as frozenset for O(1) lookups instead of looping through 49 keys @@ -522,7 +526,8 @@ class Logging(LiteLLMLoggingBaseClass): } self.litellm_request_debug = litellm_params.get("litellm_request_debug", False) self.logger_fn = litellm_params.get("logger_fn", None) - verbose_logger.debug(f"self.optional_params: {self.optional_params}") + if _is_debugging_on() or self.litellm_request_debug: + verbose_logger.debug(f"self.optional_params: {self.optional_params}") self.model_call_details.update( { @@ -3759,7 +3764,7 @@ def _init_custom_logger_compatible_class( # noqa: PLR0915 from litellm.integrations.opentelemetry import OpenTelemetry for callback in _in_memory_loggers: - if isinstance(callback, OpenTelemetry): + if type(callback) is OpenTelemetry: return callback # type: ignore otel_logger = OpenTelemetry( **_get_custom_logger_settings_from_proxy_server( @@ -4515,17 +4520,12 @@ class StandardLoggingPayloadSetup: user_api_key_auth_metadata=None, ) if isinstance(metadata, dict): - # Filter the metadata dictionary to include only the specified keys - supported_keys = StandardLoggingMetadata.__annotations__.keys() - for key in supported_keys: - if key in metadata: - clean_metadata[key] = metadata[key] # type: ignore + for key in metadata.keys() & _STANDARD_LOGGING_METADATA_KEYS: + clean_metadata[key] = metadata[key] # type: ignore - if metadata.get("user_api_key") is not None: - if is_valid_sha256_hash(str(metadata.get("user_api_key"))): - clean_metadata["user_api_key_hash"] = metadata.get( - "user_api_key" - ) # this is the hash + user_api_key = metadata.get("user_api_key") + if user_api_key and isinstance(user_api_key, str) and is_valid_sha256_hash(user_api_key): + clean_metadata["user_api_key_hash"] = user_api_key _potential_requester_metadata = metadata.get( "metadata", None ) # check if user passed metadata in the sdk request - e.g. metadata for langsmith logging - https://docs.litellm.ai/docs/observability/langsmith_integration#set-langsmith-fields diff --git a/litellm/litellm_core_utils/logging_callback_manager.py b/litellm/litellm_core_utils/logging_callback_manager.py index 435ae078a65..34d25817378 100644 --- a/litellm/litellm_core_utils/logging_callback_manager.py +++ b/litellm/litellm_core_utils/logging_callback_manager.py @@ -2,6 +2,7 @@ from typing import TYPE_CHECKING, Callable, Dict, List, Optional, Set, Type, Uni import litellm from litellm._logging import verbose_logger +from litellm.constants import MAX_CALLBACKS from litellm.integrations.additional_logging_utils import AdditionalLoggingUtils from litellm.integrations.custom_logger import CustomLogger from litellm.integrations.generic_api.generic_api_callback import GenericAPILogger @@ -24,9 +25,6 @@ class LoggingCallbackManager: - Keep a reasonable MAX_CALLBACKS limit (this ensures callbacks don't exponentially grow and consume CPU Resources) """ - # healthy maximum number of callbacks - unlikely someone needs more than 20 - MAX_CALLBACKS = 30 - def add_litellm_input_callback(self, callback: Union[CustomLogger, str]): """ Add a input callback to litellm.input_callback @@ -155,9 +153,9 @@ class LoggingCallbackManager: Check if adding another callback would exceed MAX_CALLBACKS Returns True if safe to add, False if would exceed limit """ - if len(parent_list) >= self.MAX_CALLBACKS: + if len(parent_list) >= MAX_CALLBACKS: verbose_logger.warning( - f"Cannot add callback - would exceed MAX_CALLBACKS limit of {self.MAX_CALLBACKS}. Current callbacks: {len(parent_list)}" + f"Cannot add callback - would exceed MAX_CALLBACKS limit of {MAX_CALLBACKS}. Current callbacks: {len(parent_list)}" ) return False return True diff --git a/litellm/litellm_core_utils/prompt_templates/common_utils.py b/litellm/litellm_core_utils/prompt_templates/common_utils.py index b1c2d0a52f5..cdddee4e54e 100644 --- a/litellm/litellm_core_utils/prompt_templates/common_utils.py +++ b/litellm/litellm_core_utils/prompt_templates/common_utils.py @@ -1272,3 +1272,59 @@ def parse_tool_call_arguments( ) raise ValueError(error_message) from e + + +def split_concatenated_json_objects(raw: str) -> List[Dict[str, Any]]: + """ + Split a string that contains one or more concatenated JSON objects into + a list of parsed dicts. + + LLM providers (notably Bedrock Claude Sonnet 4.5) sometimes return + multiple tool-call argument objects concatenated in a single + ``arguments`` string, e.g.:: + + '{"command":["curl",...]}{"command":["curl",...]}{"command":["curl",...]}' + + ``json.loads()`` fails on this with ``JSONDecodeError: Extra data``. + This helper uses ``json.JSONDecoder.raw_decode()`` to walk the string + and extract each JSON object individually. + + Returns + ------- + list[dict] + A list of parsed dicts – one per JSON object found. If *raw* is + empty or whitespace-only, an empty list is returned. + + Raises + ------ + json.JSONDecodeError + If the string contains text that cannot be parsed as JSON at all. + """ + import json + + raw = raw.strip() + if not raw: + return [] + + decoder = json.JSONDecoder() + results: List[Dict[str, Any]] = [] + idx = 0 + length = len(raw) + + while idx < length: + # Skip whitespace between objects + while idx < length and raw[idx] in " \t\n\r": + idx += 1 + if idx >= length: + break + + obj, end_idx = decoder.raw_decode(raw, idx) + if isinstance(obj, dict): + results.append(obj) + else: + # Non-dict JSON value – wrap in empty dict (Bedrock requires + # toolUse.input to be an object). + results.append({}) + idx = end_idx + + return results diff --git a/litellm/litellm_core_utils/prompt_templates/factory.py b/litellm/litellm_core_utils/prompt_templates/factory.py index 53d2ca2f23f..c907ed32b95 100644 --- a/litellm/litellm_core_utils/prompt_templates/factory.py +++ b/litellm/litellm_core_utils/prompt_templates/factory.py @@ -2190,6 +2190,16 @@ def anthropic_messages_pt( # noqa: PLR0915 while msg_i < len(messages) and messages[msg_i]["role"] == "assistant": assistant_content_block: ChatCompletionAssistantMessage = messages[msg_i] # type: ignore + # Extract compaction_blocks from provider_specific_fields and add them first + _provider_specific_fields_raw = assistant_content_block.get( + "provider_specific_fields" + ) + if isinstance(_provider_specific_fields_raw, dict): + _compaction_blocks = _provider_specific_fields_raw.get("compaction_blocks") + if _compaction_blocks and isinstance(_compaction_blocks, list): + # Add compaction blocks at the beginning of assistant content : https://platform.claude.com/docs/en/build-with-claude/compaction + assistant_content.extend(_compaction_blocks) # type: ignore + thinking_blocks = assistant_content_block.get("thinking_blocks", None) if ( thinking_blocks is not None @@ -3277,25 +3287,68 @@ def _convert_to_bedrock_tool_call_invoke( - extract name - extract id """ + from litellm.litellm_core_utils.prompt_templates.common_utils import ( + split_concatenated_json_objects, + ) try: _parts_list: List[BedrockContentBlock] = [] for tool in tool_calls: if "function" in tool: - id = tool["id"] + tool_id = tool["id"] name = tool["function"].get("name", "") arguments = tool["function"].get("arguments", "") - arguments_dict = json.loads(arguments) if arguments else {} - # Ensure arguments_dict is always a dict (Bedrock requires toolUse.input to be an object) - # When some providers return arguments: '""' (JSON-encoded empty string), json.loads returns "" - if not isinstance(arguments_dict, dict): - arguments_dict = {} + if not arguments or not arguments.strip(): arguments_dict = {} else: - arguments_dict = json.loads(arguments) + try: + arguments_dict = json.loads(arguments) + # Ensure arguments_dict is always a dict + # (Bedrock requires toolUse.input to be an object). + # Some providers return arguments: '""' which + # json.loads decodes to a bare string. + if not isinstance(arguments_dict, dict): + arguments_dict = {} + except json.JSONDecodeError: + # The model may return multiple JSON objects + # concatenated in a single arguments string, e.g. + # '{"cmd":"a"}{"cmd":"b"}{"cmd":"c"}' + # Split them and emit one toolUse block per object. + # Fixes: https://github.com/BerriAI/litellm/issues/20543 + parsed_objects = split_concatenated_json_objects( + arguments + ) + if parsed_objects: + # First object keeps the original tool id. + for obj_idx, obj in enumerate(parsed_objects): + block_id = ( + tool_id + if obj_idx == 0 + else f"{tool_id}_{obj_idx}" + ) + bedrock_tool = BedrockToolUseBlock( + input=obj, name=name, toolUseId=block_id + ) + _parts_list.append( + BedrockContentBlock(toolUse=bedrock_tool) + ) + # cache_control applies to the whole original + # tool call; attach after the last split block. + if tool.get("cache_control", None) is not None: + _parts_list.append( + BedrockContentBlock( + cachePoint=CachePointBlock( + type="default" + ) + ) + ) + continue + # Fallback: no objects extracted — use empty dict. + arguments_dict = {} + bedrock_tool = BedrockToolUseBlock( - input=arguments_dict, name=name, toolUseId=id + input=arguments_dict, name=name, toolUseId=tool_id ) bedrock_content_block = BedrockContentBlock(toolUse=bedrock_tool) _parts_list.append(bedrock_content_block) diff --git a/litellm/litellm_core_utils/redact_messages.py b/litellm/litellm_core_utils/redact_messages.py index aa763dc9899..5d6d1fbc1c5 100644 --- a/litellm/litellm_core_utils/redact_messages.py +++ b/litellm/litellm_core_utils/redact_messages.py @@ -140,9 +140,14 @@ def should_redact_message_logging(model_call_details: dict) -> bool: metadata_field = get_metadata_variable_name_from_kwargs(litellm_params) metadata = litellm_params.get(metadata_field, {}) - + if not isinstance(metadata, dict): + # Fall back: litellm_metadata was None, try metadata + metadata = litellm_params.get("metadata", {}) + if not isinstance(metadata, dict): + metadata = {} + # Get headers from the metadata - request_headers = metadata.get("headers", {}) if isinstance(metadata, dict) else {} + request_headers = metadata.get("headers", {}) # Check for headers that explicitly control redaction if request_headers and bool( diff --git a/litellm/litellm_core_utils/streaming_chunk_builder_utils.py b/litellm/litellm_core_utils/streaming_chunk_builder_utils.py index 53252df0a28..76c7246b87e 100644 --- a/litellm/litellm_core_utils/streaming_chunk_builder_utils.py +++ b/litellm/litellm_core_utils/streaming_chunk_builder_utils.py @@ -1,6 +1,6 @@ import base64 import time -from typing import TYPE_CHECKING, Any, Dict, List, Literal, Optional, Union, cast +from typing import TYPE_CHECKING, Any, Dict, List, Optional, Union, cast from litellm.types.llms.openai import ( ChatCompletionAssistantContentValue, @@ -326,10 +326,22 @@ class ChunkProcessor: thinking_blocks: List[ Union["ChatCompletionThinkingBlock", "ChatCompletionRedactedThinkingBlock"] ] = [] - combined_thinking_text: Optional[str] = None - data: Optional[str] = None - signature: Optional[str] = None - type: Literal["thinking", "redacted_thinking"] = "thinking" + current_thinking_text_parts: List[str] = [] + current_signature: Optional[str] = None + + def _flush_thinking_block() -> None: + nonlocal current_thinking_text_parts, current_signature + if len(current_thinking_text_parts) > 0 and current_signature: + thinking_blocks.append( + ChatCompletionThinkingBlock( + type="thinking", + thinking="".join(current_thinking_text_parts), + signature=current_signature, + ) + ) + current_thinking_text_parts = [] + current_signature = None + for chunk in chunks: choices = chunk["choices"] for choice in choices: @@ -339,33 +351,25 @@ class ChunkProcessor: for thinking_block in thinking: thinking_type = thinking_block.get("type", None) if thinking_type and thinking_type == "redacted_thinking": - type = "redacted_thinking" - data = thinking_block.get("data", None) + _flush_thinking_block() + redacted_data = thinking_block.get("data", None) + if redacted_data: + thinking_blocks.append( + ChatCompletionRedactedThinkingBlock( + type="redacted_thinking", + data=redacted_data, + ) + ) else: - type = "thinking" thinking_text = thinking_block.get("thinking", None) if thinking_text: - if combined_thinking_text is None: - combined_thinking_text = "" - - combined_thinking_text += thinking_text + current_thinking_text_parts.append(thinking_text) signature = thinking_block.get("signature", None) + if signature: + current_signature = signature + _flush_thinking_block() - if combined_thinking_text and type == "thinking" and signature: - thinking_blocks.append( - ChatCompletionThinkingBlock( - type=type, - thinking=combined_thinking_text, - signature=signature, - ) - ) - elif data and type == "redacted_thinking": - thinking_blocks.append( - ChatCompletionRedactedThinkingBlock( - type=type, - data=data, - ) - ) + _flush_thinking_block() if len(thinking_blocks) > 0: return thinking_blocks diff --git a/litellm/litellm_core_utils/token_counter.py b/litellm/litellm_core_utils/token_counter.py index a99bd1cd0f3..6b9e51034c0 100644 --- a/litellm/litellm_core_utils/token_counter.py +++ b/litellm/litellm_core_utils/token_counter.py @@ -706,7 +706,7 @@ def _count_content_list( if isinstance(c, str): num_tokens += count_function(c) elif c["type"] == "text": - num_tokens += count_function(c.get("text", "")) + num_tokens += count_function(str(c.get("text", ""))) elif c["type"] == "image_url": image_url = c.get("image_url") num_tokens += _count_image_tokens( @@ -722,7 +722,7 @@ def _count_content_list( elif c["type"] == "thinking": # Claude extended thinking content block # Count the thinking text and skip signature (opaque signature blob) - thinking_text = c.get("thinking", "") + thinking_text = str(c.get("thinking", "")) if thinking_text: num_tokens += count_function(thinking_text) else: diff --git a/litellm/llms/a2a/chat/guardrail_translation/README.md b/litellm/llms/a2a/chat/guardrail_translation/README.md new file mode 100644 index 00000000000..1e18f5cda3a --- /dev/null +++ b/litellm/llms/a2a/chat/guardrail_translation/README.md @@ -0,0 +1,155 @@ +# A2A Protocol Guardrail Translation Handler + +Handler for processing A2A (Agent-to-Agent) Protocol messages with guardrails. + +## Overview + +This handler processes A2A JSON-RPC 2.0 input/output by: +1. Extracting text from message parts (`kind: "text"`) +2. Applying guardrails to text content +3. Mapping guardrailed text back to original structure + +## A2A Protocol Format + +### Input Format (JSON-RPC 2.0) + +```json +{ + "jsonrpc": "2.0", + "id": "request-id", + "method": "message/send", + "params": { + "message": { + "kind": "message", + "messageId": "...", + "role": "user", + "parts": [ + {"kind": "text", "text": "Hello, my SSN is 123-45-6789"} + ] + }, + "metadata": { + "guardrails": ["block-ssn"] + } + } +} +``` + +### Output Formats + +The handler supports multiple A2A response formats: + +**Direct message:** +```json +{ + "result": { + "kind": "message", + "parts": [{"kind": "text", "text": "Response text"}] + } +} +``` + +**Nested message:** +```json +{ + "result": { + "message": { + "parts": [{"kind": "text", "text": "Response text"}] + } + } +} +``` + +**Task with artifacts:** +```json +{ + "result": { + "kind": "task", + "artifacts": [ + {"parts": [{"kind": "text", "text": "Artifact text"}]} + ] + } +} +``` + +**Task with status message:** +```json +{ + "result": { + "kind": "task", + "status": { + "message": { + "parts": [{"kind": "text", "text": "Status message"}] + } + } + } +} +``` + +**Streaming artifact-update:** +```json +{ + "result": { + "kind": "artifact-update", + "artifact": { + "parts": [{"kind": "text", "text": "Streaming text"}] + } + } +} +``` + +## Usage + +The handler is automatically discovered and applied when guardrails are used with A2A endpoints. + +### Via LiteLLM Proxy + +```bash +curl -X POST 'http://localhost:4000/a2a/my-agent' \ +-H 'Content-Type: application/json' \ +-H 'Authorization: Bearer your-api-key' \ +-d '{ + "jsonrpc": "2.0", + "id": "1", + "method": "message/send", + "params": { + "message": { + "kind": "message", + "messageId": "msg-1", + "role": "user", + "parts": [{"kind": "text", "text": "Hello, my SSN is 123-45-6789"}] + }, + "metadata": { + "guardrails": ["block-ssn"] + } + } +}' +``` + +### Specifying Guardrails + +Guardrails can be specified in the A2A request via the `metadata.guardrails` field: + +```json +{ + "params": { + "message": {...}, + "metadata": { + "guardrails": ["block-ssn", "pii-filter"] + } + } +} +``` + +## Extension + +Override these methods to customize behavior: + +- `_extract_texts_from_result()`: Custom text extraction from A2A responses +- `_extract_texts_from_parts()`: Custom text extraction from message parts +- `_apply_text_to_path()`: Custom application of guardrailed text + +## Call Types + +This handler is registered for: +- `CallTypes.send_message`: Synchronous A2A message sending +- `CallTypes.asend_message`: Asynchronous A2A message sending diff --git a/litellm/llms/a2a/chat/guardrail_translation/__init__.py b/litellm/llms/a2a/chat/guardrail_translation/__init__.py new file mode 100644 index 00000000000..13c20677485 --- /dev/null +++ b/litellm/llms/a2a/chat/guardrail_translation/__init__.py @@ -0,0 +1,11 @@ +"""A2A Protocol handler for Unified Guardrails.""" + +from litellm.llms.a2a.chat.guardrail_translation.handler import A2AGuardrailHandler +from litellm.types.utils import CallTypes + +guardrail_translation_mappings = { + CallTypes.send_message: A2AGuardrailHandler, + CallTypes.asend_message: A2AGuardrailHandler, +} + +__all__ = ["guardrail_translation_mappings"] diff --git a/litellm/llms/a2a/chat/guardrail_translation/handler.py b/litellm/llms/a2a/chat/guardrail_translation/handler.py new file mode 100644 index 00000000000..770453f2def --- /dev/null +++ b/litellm/llms/a2a/chat/guardrail_translation/handler.py @@ -0,0 +1,315 @@ +""" +A2A Protocol Handler for Unified Guardrails + +This module provides guardrail translation support for A2A (Agent-to-Agent) Protocol. +It handles both JSON-RPC 2.0 input requests and output responses, extracting text +from message parts and applying guardrails. + +A2A Protocol Format: +- Input: JSON-RPC 2.0 with params.message.parts containing text parts +- Output: JSON-RPC 2.0 with result containing message/artifact parts +""" + +from typing import TYPE_CHECKING, Any, Dict, List, Optional, Tuple, Union + +from litellm._logging import verbose_proxy_logger +from litellm.llms.base_llm.guardrail_translation.base_translation import BaseTranslation +from litellm.types.utils import GenericGuardrailAPIInputs + +if TYPE_CHECKING: + from litellm.integrations.custom_guardrail import CustomGuardrail + from litellm.litellm_core_utils.litellm_logging import Logging as LiteLLMLoggingObj + from litellm.proxy._types import UserAPIKeyAuth + + +class A2AGuardrailHandler(BaseTranslation): + """ + Handler for processing A2A Protocol messages with guardrails. + + This class provides methods to: + 1. Process input messages (pre-call hook) - extracts text from A2A message parts + 2. Process output responses (post-call hook) - extracts text from A2A response parts + + A2A Message Format: + - Input: params.message.parts[].text (where kind == "text") + - Output: result.message.parts[].text or result.artifacts[].parts[].text + """ + + async def process_input_messages( + self, + data: dict, + guardrail_to_apply: "CustomGuardrail", + litellm_logging_obj: Optional["LiteLLMLoggingObj"] = None, + ) -> Any: + """ + Process A2A input messages by applying guardrails to text content. + + Extracts text from A2A message parts and applies guardrails. + + Args: + data: The A2A JSON-RPC 2.0 request data + guardrail_to_apply: The guardrail instance to apply + litellm_logging_obj: Optional logging object + + Returns: + Modified data with guardrails applied to text content + """ + # A2A request format: { "params": { "message": { "parts": [...] } } } + params = data.get("params", {}) + message = params.get("message", {}) + parts = message.get("parts", []) + + if not parts: + verbose_proxy_logger.debug("A2A: No parts in message, skipping guardrail") + return data + + texts_to_check: List[str] = [] + text_part_indices: List[int] = [] # Track which parts contain text + + # Step 1: Extract text from all text parts + for part_idx, part in enumerate(parts): + if part.get("kind") == "text": + text = part.get("text", "") + if text: + texts_to_check.append(text) + text_part_indices.append(part_idx) + + # Step 2: Apply guardrail to all texts in batch + if texts_to_check: + inputs = GenericGuardrailAPIInputs(texts=texts_to_check) + + # Pass the structured A2A message to guardrails + inputs["structured_messages"] = [message] + + # Include agent model info if available + model = data.get("model") + if model: + inputs["model"] = model + + guardrailed_inputs = await guardrail_to_apply.apply_guardrail( + inputs=inputs, + request_data=data, + input_type="request", + logging_obj=litellm_logging_obj, + ) + + guardrailed_texts = guardrailed_inputs.get("texts", []) + + # Step 3: Apply guardrailed text back to original parts + if guardrailed_texts and len(guardrailed_texts) == len(text_part_indices): + for task_idx, part_idx in enumerate(text_part_indices): + parts[part_idx]["text"] = guardrailed_texts[task_idx] + + verbose_proxy_logger.debug("A2A: Processed input message: %s", message) + + return data + + async def process_output_response( + self, + response: Any, + guardrail_to_apply: "CustomGuardrail", + litellm_logging_obj: Optional["LiteLLMLoggingObj"] = None, + user_api_key_dict: Optional["UserAPIKeyAuth"] = None, + ) -> Any: + """ + Process A2A output response by applying guardrails to text content. + + Handles multiple A2A response formats: + - Direct message: {"result": {"kind": "message", "parts": [...]}} + - Nested message: {"result": {"message": {"parts": [...]}}} + - Task with artifacts: {"result": {"kind": "task", "artifacts": [{"parts": [...]}]}} + - Task with status message: {"result": {"kind": "task", "status": {"message": {"parts": [...]}}}} + + Args: + response: A2A JSON-RPC 2.0 response dict or object + guardrail_to_apply: The guardrail instance to apply + litellm_logging_obj: Optional logging object + user_api_key_dict: User API key metadata + + Returns: + Modified response with guardrails applied to text content + """ + # Handle both dict and Pydantic model responses + if hasattr(response, "model_dump"): + response_dict = response.model_dump() + is_pydantic = True + elif isinstance(response, dict): + response_dict = response + is_pydantic = False + else: + verbose_proxy_logger.warning( + "A2A: Unknown response type %s, skipping guardrail", type(response) + ) + return response + + result = response_dict.get("result", {}) + if not result or not isinstance(result, dict): + verbose_proxy_logger.debug("A2A: No result in response, skipping guardrail") + return response + + # Find all text-containing parts in the response + texts_to_check: List[str] = [] + # Each mapping is (path_to_parts_list, part_index) + # path_to_parts_list is a tuple of keys to navigate to the parts list + task_mappings: List[Tuple[Tuple[str, ...], int]] = [] + + # Extract texts from all possible locations + self._extract_texts_from_result( + result=result, + texts_to_check=texts_to_check, + task_mappings=task_mappings, + ) + + if not texts_to_check: + verbose_proxy_logger.debug("A2A: No text content in response") + return response + + # Step 2: Apply guardrail to all texts in batch + # Create a request_data dict with response info and user API key metadata + request_data: dict = {"response": response_dict} + + # Add user API key metadata with prefixed keys + user_metadata = self.transform_user_api_key_dict_to_metadata(user_api_key_dict) + if user_metadata: + request_data["litellm_metadata"] = user_metadata + + inputs = GenericGuardrailAPIInputs(texts=texts_to_check) + + guardrailed_inputs = await guardrail_to_apply.apply_guardrail( + inputs=inputs, + request_data=request_data, + input_type="response", + logging_obj=litellm_logging_obj, + ) + + guardrailed_texts = guardrailed_inputs.get("texts", []) + + # Step 3: Apply guardrailed text back to original response + if guardrailed_texts and len(guardrailed_texts) == len(task_mappings): + for task_idx, (path, part_idx) in enumerate(task_mappings): + self._apply_text_to_path( + result=result, + path=path, + part_idx=part_idx, + text=guardrailed_texts[task_idx], + ) + + verbose_proxy_logger.debug("A2A: Processed output response") + + # Update the original response + if is_pydantic: + # For Pydantic models, we need to update the underlying dict + # and the model will reflect the changes + response_dict["result"] = result + return response + else: + response["result"] = result + return response + + def _extract_texts_from_result( + self, + result: Dict[str, Any], + texts_to_check: List[str], + task_mappings: List[Tuple[Tuple[str, ...], int]], + ) -> None: + """ + Extract text from all possible locations in an A2A result. + + Handles multiple response formats: + 1. Direct message with parts: {"parts": [...]} + 2. Nested message: {"message": {"parts": [...]}} + 3. Task with artifacts: {"artifacts": [{"parts": [...]}]} + 4. Task with status message: {"status": {"message": {"parts": [...]}}} + 5. Streaming artifact-update: {"artifact": {"parts": [...]}} + """ + # Case 1: Direct parts in result (direct message) + if "parts" in result: + self._extract_texts_from_parts( + parts=result["parts"], + path=("parts",), + texts_to_check=texts_to_check, + task_mappings=task_mappings, + ) + + # Case 2: Nested message + message = result.get("message") + if message and isinstance(message, dict) and "parts" in message: + self._extract_texts_from_parts( + parts=message["parts"], + path=("message", "parts"), + texts_to_check=texts_to_check, + task_mappings=task_mappings, + ) + + # Case 3: Streaming artifact-update (singular artifact) + artifact = result.get("artifact") + if artifact and isinstance(artifact, dict) and "parts" in artifact: + self._extract_texts_from_parts( + parts=artifact["parts"], + path=("artifact", "parts"), + texts_to_check=texts_to_check, + task_mappings=task_mappings, + ) + + # Case 4: Task with status message + status = result.get("status", {}) + if isinstance(status, dict): + status_message = status.get("message") + if ( + status_message + and isinstance(status_message, dict) + and "parts" in status_message + ): + self._extract_texts_from_parts( + parts=status_message["parts"], + path=("status", "message", "parts"), + texts_to_check=texts_to_check, + task_mappings=task_mappings, + ) + + # Case 5: Task with artifacts (plural, array) + artifacts = result.get("artifacts", []) + if artifacts and isinstance(artifacts, list): + for artifact_idx, art in enumerate(artifacts): + if isinstance(art, dict) and "parts" in art: + self._extract_texts_from_parts( + parts=art["parts"], + path=("artifacts", str(artifact_idx), "parts"), + texts_to_check=texts_to_check, + task_mappings=task_mappings, + ) + + def _extract_texts_from_parts( + self, + parts: List[Dict[str, Any]], + path: Tuple[str, ...], + texts_to_check: List[str], + task_mappings: List[Tuple[Tuple[str, ...], int]], + ) -> None: + """Extract text from message parts.""" + for part_idx, part in enumerate(parts): + if part.get("kind") == "text": + text = part.get("text", "") + if text: + texts_to_check.append(text) + task_mappings.append((path, part_idx)) + + def _apply_text_to_path( + self, + result: Dict[Union[str, int], Any], + path: Tuple[str, ...], + part_idx: int, + text: str, + ) -> None: + """Apply guardrailed text back to the specified path in the result.""" + # Navigate to the parts list + current = result + for key in path: + if key.isdigit(): + # Array index + current = current[int(key)] + else: + current = current[key] + + # Update the text in the part + current[part_idx]["text"] = text diff --git a/litellm/llms/anthropic/chat/handler.py b/litellm/llms/anthropic/chat/handler.py index 6a9aafd076b..f51adf96102 100644 --- a/litellm/llms/anthropic/chat/handler.py +++ b/litellm/llms/anthropic/chat/handler.py @@ -58,6 +58,9 @@ from litellm.types.utils import ( from ...base import BaseLLM from ..common_utils import AnthropicError, process_anthropic_headers +from litellm.anthropic_beta_headers_manager import ( + update_headers_with_filtered_beta, +) from .transformation import AnthropicConfig if TYPE_CHECKING: @@ -75,6 +78,7 @@ async def make_call( logging_obj, timeout: Optional[Union[float, httpx.Timeout]], json_mode: bool, + speed: Optional[str] = None, ) -> Tuple[Any, httpx.Headers]: if client is None: client = litellm.module_level_aclient @@ -103,6 +107,7 @@ async def make_call( streaming_response=response.aiter_lines(), sync_stream=False, json_mode=json_mode, + speed=speed, ) # LOGGING @@ -126,6 +131,7 @@ def make_sync_call( logging_obj, timeout: Optional[Union[float, httpx.Timeout]], json_mode: bool, + speed: Optional[str] = None, ) -> Tuple[Any, httpx.Headers]: if client is None: client = litellm.module_level_client # re-use a module level client @@ -159,7 +165,7 @@ def make_sync_call( ) completion_stream = ModelResponseIterator( - streaming_response=response.iter_lines(), sync_stream=True, json_mode=json_mode + streaming_response=response.iter_lines(), sync_stream=True, json_mode=json_mode, speed=speed ) # LOGGING @@ -213,6 +219,7 @@ class AnthropicChatCompletion(BaseLLM): logging_obj=logging_obj, timeout=timeout, json_mode=json_mode, + speed=optional_params.get("speed") if optional_params else None, ) streamwrapper = CustomStreamWrapper( completion_stream=completion_stream, @@ -329,6 +336,10 @@ class AnthropicChatCompletion(BaseLLM): litellm_params=litellm_params, ) + headers = update_headers_with_filtered_beta( + headers=headers, provider=custom_llm_provider + ) + config = ProviderConfigManager.get_provider_chat_config( model=model, provider=LlmProviders(custom_llm_provider), @@ -427,6 +438,7 @@ class AnthropicChatCompletion(BaseLLM): logging_obj=logging_obj, timeout=timeout, json_mode=json_mode, + speed=optional_params.get("speed") if optional_params else None, ) return CustomStreamWrapper( completion_stream=completion_stream, @@ -485,13 +497,14 @@ class AnthropicChatCompletion(BaseLLM): class ModelResponseIterator: def __init__( - self, streaming_response, sync_stream: bool, json_mode: Optional[bool] = False + self, streaming_response, sync_stream: bool, json_mode: Optional[bool] = False, speed: Optional[str] = None ): self.streaming_response = streaming_response self.response_iterator = self.streaming_response self.content_blocks: List[ContentBlockDelta] = [] self.tool_index = -1 self.json_mode = json_mode + self.speed = speed # Generate response ID once per stream to match OpenAI-compatible behavior self.response_id = _generate_id() @@ -512,6 +525,9 @@ class ModelResponseIterator: # Accumulate web_search_tool_result blocks for multi-turn reconstruction # See: https://github.com/BerriAI/litellm/issues/17737 self.web_search_results: List[Dict[str, Any]] = [] + + # Accumulate compaction blocks for multi-turn reconstruction + self.compaction_blocks: List[Dict[str, Any]] = [] def check_empty_tool_call_args(self) -> bool: """ @@ -538,7 +554,7 @@ class ModelResponseIterator: def _handle_usage(self, anthropic_usage_chunk: Union[dict, UsageDelta]) -> Usage: return AnthropicConfig().calculate_usage( - usage_object=cast(dict, anthropic_usage_chunk), reasoning_content=None + usage_object=cast(dict, anthropic_usage_chunk), reasoning_content=None, speed=self.speed ) def _content_block_delta_helper(self, chunk: dict) -> Tuple[ @@ -592,6 +608,12 @@ class ModelResponseIterator: ) ] provider_specific_fields["thinking_blocks"] = thinking_blocks + elif "content" in content_block["delta"] and content_block["delta"].get("type") == "compaction_delta": + # Handle compaction delta + provider_specific_fields["compaction_delta"] = { + "type": "compaction_delta", + "content": content_block["delta"]["content"] + } return text, tool_use, thinking_blocks, provider_specific_fields @@ -721,6 +743,20 @@ class ModelResponseIterator: provider_specific_fields=provider_specific_fields, ) + elif content_block_start["content_block"]["type"] == "compaction": + # Handle compaction blocks + # The full content comes in content_block_start + self.compaction_blocks.append( + content_block_start["content_block"] + ) + provider_specific_fields["compaction_blocks"] = ( + self.compaction_blocks + ) + provider_specific_fields["compaction_start"] = { + "type": "compaction", + "content": content_block_start["content_block"].get("content", "") + } + elif content_block_start["content_block"]["type"].endswith("_tool_result"): # Handle all tool result types (web_search, bash_code_execution, text_editor, etc.) content_type = content_block_start["content_block"]["type"] diff --git a/litellm/llms/anthropic/chat/transformation.py b/litellm/llms/anthropic/chat/transformation.py index 1b61b533275..acd08f0a569 100644 --- a/litellm/llms/anthropic/chat/transformation.py +++ b/litellm/llms/anthropic/chat/transformation.py @@ -170,9 +170,10 @@ class AnthropicConfig(AnthropicModelInfo, BaseConfig): tool_call["caller"] = cast(Dict[str, Any], anthropic_tool_content["caller"]) # type: ignore[typeddict-item] return tool_call - def _is_claude_opus_4_5(self, model: str) -> bool: + @staticmethod + def _is_claude_opus_4_6(model: str) -> bool: """Check if the model is Claude Opus 4.5.""" - return "opus-4-5" in model.lower() or "opus_4_5" in model.lower() + return "opus-4-6" in model.lower() or "opus_4_6" in model.lower() def get_supported_openai_params(self, model: str): params = [ @@ -189,6 +190,7 @@ class AnthropicConfig(AnthropicModelInfo, BaseConfig): "response_format", "user", "web_search_options", + "speed", ] if "claude-3-7-sonnet" in model or supports_reasoning( @@ -659,32 +661,38 @@ class AnthropicConfig(AnthropicModelInfo, BaseConfig): @staticmethod def _map_reasoning_effort( - reasoning_effort: Optional[Union[REASONING_EFFORT, str]], + reasoning_effort: Optional[Union[REASONING_EFFORT, str]], + model: str, ) -> Optional[AnthropicThinkingParam]: - if reasoning_effort is None: - return None - elif reasoning_effort == "low": + if AnthropicConfig._is_claude_opus_4_6(model): return AnthropicThinkingParam( - type="enabled", - budget_tokens=DEFAULT_REASONING_EFFORT_LOW_THINKING_BUDGET, - ) - elif reasoning_effort == "medium": - return AnthropicThinkingParam( - type="enabled", - budget_tokens=DEFAULT_REASONING_EFFORT_MEDIUM_THINKING_BUDGET, - ) - elif reasoning_effort == "high": - return AnthropicThinkingParam( - type="enabled", - budget_tokens=DEFAULT_REASONING_EFFORT_HIGH_THINKING_BUDGET, - ) - elif reasoning_effort == "minimal": - return AnthropicThinkingParam( - type="enabled", - budget_tokens=DEFAULT_REASONING_EFFORT_MINIMAL_THINKING_BUDGET, + type="adaptive", ) else: - raise ValueError(f"Unmapped reasoning effort: {reasoning_effort}") + if reasoning_effort is None: + return None + elif reasoning_effort == "low": + return AnthropicThinkingParam( + type="enabled", + budget_tokens=DEFAULT_REASONING_EFFORT_LOW_THINKING_BUDGET, + ) + elif reasoning_effort == "medium": + return AnthropicThinkingParam( + type="enabled", + budget_tokens=DEFAULT_REASONING_EFFORT_MEDIUM_THINKING_BUDGET, + ) + elif reasoning_effort == "high": + return AnthropicThinkingParam( + type="enabled", + budget_tokens=DEFAULT_REASONING_EFFORT_HIGH_THINKING_BUDGET, + ) + elif reasoning_effort == "minimal": + return AnthropicThinkingParam( + type="enabled", + budget_tokens=DEFAULT_REASONING_EFFORT_MINIMAL_THINKING_BUDGET, + ) + else: + raise ValueError(f"Unmapped reasoning effort: {reasoning_effort}") def _extract_json_schema_from_response_format( self, value: Optional[dict] @@ -826,6 +834,10 @@ class AnthropicConfig(AnthropicModelInfo, BaseConfig): "sonnet-4-5", "opus-4.1", "opus-4-1", + "opus-4.5", + "opus-4-5", + "opus-4.6", + "opus-4-6", } ): _output_format = ( @@ -860,13 +872,8 @@ class AnthropicConfig(AnthropicModelInfo, BaseConfig): if param == "thinking": optional_params["thinking"] = value elif param == "reasoning_effort" and isinstance(value, str): - # For Claude Opus 4.5, map reasoning_effort to output_config - if self._is_claude_opus_4_5(model): - optional_params["output_config"] = {"effort": value} - - # For other models, map to thinking parameter optional_params["thinking"] = AnthropicConfig._map_reasoning_effort( - value + reasoning_effort=value, model=model ) elif param == "web_search_options" and isinstance(value, dict): hosted_web_search_tool = self.map_web_search_tool( @@ -877,6 +884,12 @@ class AnthropicConfig(AnthropicModelInfo, BaseConfig): ) elif param == "extra_headers": optional_params["extra_headers"] = value + elif param == "context_management" and isinstance(value, dict): + # Pass through Anthropic-specific context_management parameter + optional_params["context_management"] = value + elif param == "speed" and isinstance(value, str): + # Pass through Anthropic-specific speed parameter for fast mode + optional_params["speed"] = value ## handle thinking tokens self.update_optional_params_with_thinking_tokens( @@ -922,6 +935,7 @@ class AnthropicConfig(AnthropicModelInfo, BaseConfig): Translate system message to anthropic format. Removes system message from the original list and returns a new list of anthropic system message content. + Filters out system messages containing x-anthropic-billing-header metadata. """ system_prompt_indices = [] anthropic_system_message_list: List[AnthropicSystemMessageContent] = [] @@ -933,6 +947,9 @@ class AnthropicConfig(AnthropicModelInfo, BaseConfig): # Skip empty text blocks - Anthropic API raises errors for empty text if not system_message_block["content"]: continue + # Skip system messages containing x-anthropic-billing-header metadata + if system_message_block["content"].startswith("x-anthropic-billing-header:"): + continue anthropic_system_message_content = AnthropicSystemMessageContent( type="text", text=system_message_block["content"], @@ -951,6 +968,9 @@ class AnthropicConfig(AnthropicModelInfo, BaseConfig): text_value = _content.get("text") if _content.get("type") == "text" and not text_value: continue + # Skip system messages containing x-anthropic-billing-header metadata + if _content.get("type") == "text" and text_value and text_value.startswith("x-anthropic-billing-header:"): + continue anthropic_system_message_content = ( AnthropicSystemMessageContent( type=_content.get("type"), @@ -1026,9 +1046,37 @@ class AnthropicConfig(AnthropicModelInfo, BaseConfig): if beta_value not in existing_values: headers["anthropic-beta"] = f"{existing_beta}, {beta_value}" - def _ensure_context_management_beta_header(self, headers: dict) -> None: - beta_value = ANTHROPIC_BETA_HEADER_VALUES.CONTEXT_MANAGEMENT_2025_06_27.value - self._ensure_beta_header(headers, beta_value) + def _ensure_context_management_beta_header( + self, headers: dict, context_management: dict + ) -> None: + """ + Add appropriate beta headers based on context_management edits. + - If any edit has type "compact_20260112", add compact-2026-01-12 header + - For all other edits, add context-management-2025-06-27 header + """ + edits = context_management.get("edits", []) + + has_compact = False + has_other = False + + for edit in edits: + edit_type = edit.get("type", "") + if edit_type == "compact_20260112": + has_compact = True + else: + has_other = True + + # Add compact header if any compact edits exist + if has_compact: + self._ensure_beta_header( + headers, ANTHROPIC_BETA_HEADER_VALUES.COMPACT_2026_01_12.value + ) + + # Add context management header if any other edits exist + if has_other: + self._ensure_beta_header( + headers, ANTHROPIC_BETA_HEADER_VALUES.CONTEXT_MANAGEMENT_2025_06_27.value + ) def update_headers_with_optional_anthropic_beta( self, headers: dict, optional_params: dict @@ -1056,11 +1104,17 @@ class AnthropicConfig(AnthropicModelInfo, BaseConfig): headers, ANTHROPIC_BETA_HEADER_VALUES.CONTEXT_MANAGEMENT_2025_06_27.value ) if optional_params.get("context_management") is not None: - self._ensure_context_management_beta_header(headers) + self._ensure_context_management_beta_header( + headers, optional_params["context_management"] + ) if optional_params.get("output_format") is not None: self._ensure_beta_header( headers, ANTHROPIC_BETA_HEADER_VALUES.STRUCTURED_OUTPUT_2025_09_25.value ) + if optional_params.get("speed") == "fast": + self._ensure_beta_header( + headers, ANTHROPIC_BETA_HEADER_VALUES.FAST_MODE_2026_02_01.value + ) return headers def transform_request( @@ -1225,6 +1279,7 @@ class AnthropicConfig(AnthropicModelInfo, BaseConfig): List[ChatCompletionToolCallChunk], Optional[List[Any]], Optional[List[Any]], + Optional[List[Any]], ]: text_content = "" citations: Optional[List[Any]] = None @@ -1237,6 +1292,7 @@ class AnthropicConfig(AnthropicModelInfo, BaseConfig): tool_calls: List[ChatCompletionToolCallChunk] = [] web_search_results: Optional[List[Any]] = None tool_results: Optional[List[Any]] = None + compaction_blocks: Optional[List[Any]] = None for idx, content in enumerate(completion_response["content"]): if content["type"] == "text": text_content += content["text"] @@ -1278,6 +1334,12 @@ class AnthropicConfig(AnthropicModelInfo, BaseConfig): thinking_blocks.append( cast(ChatCompletionRedactedThinkingBlock, content) ) + + ## COMPACTION + elif content["type"] == "compaction": + if compaction_blocks is None: + compaction_blocks = [] + compaction_blocks.append(content) ## CITATIONS if content.get("citations") is not None: @@ -1299,13 +1361,14 @@ class AnthropicConfig(AnthropicModelInfo, BaseConfig): if thinking_content is not None: reasoning_content += thinking_content - return text_content, citations, thinking_blocks, reasoning_content, tool_calls, web_search_results, tool_results + return text_content, citations, thinking_blocks, reasoning_content, tool_calls, web_search_results, tool_results, compaction_blocks def calculate_usage( self, usage_object: dict, reasoning_content: Optional[str], completion_response: Optional[dict] = None, + speed: Optional[str] = None, ) -> Usage: # NOTE: Sometimes the usage object has None set explicitly for token counts, meaning .get() & key access returns None, and we need to account for this prompt_tokens = usage_object.get("input_tokens", 0) or 0 @@ -1316,6 +1379,10 @@ class AnthropicConfig(AnthropicModelInfo, BaseConfig): cache_creation_token_details: Optional[CacheCreationTokenDetails] = None web_search_requests: Optional[int] = None tool_search_requests: Optional[int] = None + inference_geo: Optional[str] = None + if "inference_geo" in _usage and _usage["inference_geo"] is not None: + inference_geo = _usage["inference_geo"] + if ( "cache_creation_input_tokens" in _usage and _usage["cache_creation_input_tokens"] is not None @@ -1399,6 +1466,8 @@ class AnthropicConfig(AnthropicModelInfo, BaseConfig): if (web_search_requests is not None or tool_search_requests is not None) else None ), + inference_geo=inference_geo, + speed=speed, ) return usage @@ -1409,6 +1478,7 @@ class AnthropicConfig(AnthropicModelInfo, BaseConfig): model_response: ModelResponse, json_mode: Optional[bool] = None, prefix_prompt: Optional[str] = None, + speed: Optional[str] = None, ): _hidden_params: Dict = {} _hidden_params["additional_headers"] = process_anthropic_headers( @@ -1442,6 +1512,7 @@ class AnthropicConfig(AnthropicModelInfo, BaseConfig): tool_calls, web_search_results, tool_results, + compaction_blocks, ) = self.extract_response_content(completion_response=completion_response) if ( @@ -1469,6 +1540,8 @@ class AnthropicConfig(AnthropicModelInfo, BaseConfig): provider_specific_fields["tool_results"] = tool_results if container is not None: provider_specific_fields["container"] = container + if compaction_blocks is not None: + provider_specific_fields["compaction_blocks"] = compaction_blocks _message = litellm.Message( tool_calls=tool_calls, @@ -1477,6 +1550,7 @@ class AnthropicConfig(AnthropicModelInfo, BaseConfig): thinking_blocks=thinking_blocks, reasoning_content=reasoning_content, ) + _message.provider_specific_fields = provider_specific_fields ## HANDLE JSON MODE - anthropic returns single function call json_mode_message = self._transform_response_for_json_mode( @@ -1501,24 +1575,14 @@ class AnthropicConfig(AnthropicModelInfo, BaseConfig): usage_object=completion_response["usage"], reasoning_content=reasoning_content, completion_response=completion_response, + speed=speed, ) setattr(model_response, "usage", usage) # type: ignore model_response.created = int(time.time()) model_response.model = completion_response["model"] - context_management_response = completion_response.get("context_management") - if context_management_response is not None: - _hidden_params["context_management"] = context_management_response - try: - model_response.__dict__["context_management"] = ( - context_management_response - ) - except Exception: - pass - model_response._hidden_params = _hidden_params - return model_response def get_prefix_prompt(self, messages: List[AllMessageValues]) -> Optional[str]: @@ -1580,6 +1644,7 @@ class AnthropicConfig(AnthropicModelInfo, BaseConfig): ) prefix_prompt = self.get_prefix_prompt(messages=messages) + speed = optional_params.get("speed") model_response = self.transform_parsed_response( completion_response=completion_response, @@ -1587,6 +1652,7 @@ class AnthropicConfig(AnthropicModelInfo, BaseConfig): model_response=model_response, json_mode=json_mode, prefix_prompt=prefix_prompt, + speed=speed, ) return model_response diff --git a/litellm/llms/anthropic/cost_calculation.py b/litellm/llms/anthropic/cost_calculation.py index 8f34eb00ce5..271406f2f7d 100644 --- a/litellm/llms/anthropic/cost_calculation.py +++ b/litellm/llms/anthropic/cost_calculation.py @@ -22,10 +22,22 @@ def cost_per_token(model: str, usage: "Usage") -> Tuple[float, float]: Returns: Tuple[float, float] - prompt_cost_in_usd, completion_cost_in_usd """ - return generic_cost_per_token( - model=model, usage=usage, custom_llm_provider="anthropic" + model_with_prefix = model + + # First, prepend inference_geo if present + if hasattr(usage, "inference_geo") and usage.inference_geo and usage.inference_geo.lower() not in ["global", "not_available"]: + model_with_prefix = f"{usage.inference_geo}/{model_with_prefix}" + + # Then, prepend speed if it's "fast" + if hasattr(usage, "speed") and usage.speed == "fast": + model_with_prefix = f"fast/{model_with_prefix}" + + prompt_cost, completion_cost = generic_cost_per_token( + model=model_with_prefix, usage=usage, custom_llm_provider="anthropic" ) + return prompt_cost, completion_cost + def get_cost_for_anthropic_web_search( model_info: Optional["ModelInfo"] = None, diff --git a/litellm/llms/anthropic/experimental_pass_through/adapters/handler.py b/litellm/llms/anthropic/experimental_pass_through/adapters/handler.py index a17eba75b3b..c6caaddf98b 100644 --- a/litellm/llms/anthropic/experimental_pass_through/adapters/handler.py +++ b/litellm/llms/anthropic/experimental_pass_through/adapters/handler.py @@ -30,6 +30,58 @@ ANTHROPIC_ADAPTER = AnthropicAdapter() class LiteLLMMessagesToCompletionTransformationHandler: + @staticmethod + def _route_openai_thinking_to_responses_api_if_needed( + completion_kwargs: Dict[str, Any], + *, + thinking: Optional[Dict[str, Any]], + ) -> None: + """ + When users call `litellm.anthropic.messages.*` with a non-Anthropic model and + `thinking={"type": "enabled", ...}`, LiteLLM converts this into OpenAI + `reasoning_effort`. + + For OpenAI models, Chat Completions typically does not return reasoning text + (only token accounting). To return a thinking-like content block in the + Anthropic response format, we route the request through OpenAI's Responses API + and request a reasoning summary. + """ + custom_llm_provider = completion_kwargs.get("custom_llm_provider") + if custom_llm_provider is None: + try: + _, inferred_provider, _, _ = litellm.utils.get_llm_provider( + model=cast(str, completion_kwargs.get("model")) + ) + custom_llm_provider = inferred_provider + except Exception: + custom_llm_provider = None + + if custom_llm_provider != "openai": + return + + if not isinstance(thinking, dict) or thinking.get("type") != "enabled": + return + + model = completion_kwargs.get("model") + if isinstance(model, str) and model and not model.startswith("responses/"): + # Prefix model with "responses/" to route to OpenAI Responses API + completion_kwargs["model"] = f"responses/{model}" + + reasoning_effort = completion_kwargs.get("reasoning_effort") + if isinstance(reasoning_effort, str) and reasoning_effort: + completion_kwargs["reasoning_effort"] = { + "effort": reasoning_effort, + "summary": "detailed", + } + elif isinstance(reasoning_effort, dict): + if ( + "summary" not in reasoning_effort + and "generate_summary" not in reasoning_effort + ): + updated_reasoning_effort = dict(reasoning_effort) + updated_reasoning_effort["summary"] = "detailed" + completion_kwargs["reasoning_effort"] = updated_reasoning_effort + @staticmethod def _prepare_completion_kwargs( *, @@ -123,6 +175,11 @@ class LiteLLMMessagesToCompletionTransformationHandler: ): completion_kwargs[key] = value + LiteLLMMessagesToCompletionTransformationHandler._route_openai_thinking_to_responses_api_if_needed( + completion_kwargs, + thinking=thinking, + ) + return completion_kwargs, tool_name_mapping @staticmethod diff --git a/litellm/llms/anthropic/experimental_pass_through/messages/transformation.py b/litellm/llms/anthropic/experimental_pass_through/messages/transformation.py index 308bf367d06..8f2f3bf3545 100644 --- a/litellm/llms/anthropic/experimental_pass_through/messages/transformation.py +++ b/litellm/llms/anthropic/experimental_pass_through/messages/transformation.py @@ -43,9 +43,46 @@ class AnthropicMessagesConfig(BaseAnthropicMessagesConfig): "thinking", "context_management", "output_format", + "inference_geo", + "speed", + "output_config", # TODO: Add Anthropic `metadata` support # "metadata", ] + + @staticmethod + def _filter_billing_headers_from_system(system_param): + """ + Filter out x-anthropic-billing-header metadata from system parameter. + + Args: + system_param: Can be a string or a list of system message content blocks + + Returns: + Filtered system parameter (string or list), or None if all content was filtered + """ + if isinstance(system_param, str): + # If it's a string and starts with billing header, filter it out + if system_param.startswith("x-anthropic-billing-header:"): + return None + return system_param + elif isinstance(system_param, list): + # Filter list of system content blocks + filtered_list = [] + for content_block in system_param: + if isinstance(content_block, dict): + text = content_block.get("text", "") + content_type = content_block.get("type", "") + # Skip text blocks that start with billing header + if content_type == "text" and text.startswith("x-anthropic-billing-header:"): + continue + filtered_list.append(content_block) + else: + # Keep non-dict items as-is + filtered_list.append(content_block) + return filtered_list if len(filtered_list) > 0 else None + else: + return system_param def get_complete_url( self, @@ -112,6 +149,17 @@ class AnthropicMessagesConfig(BaseAnthropicMessagesConfig): message="max_tokens is required for Anthropic /v1/messages API", status_code=400, ) + + # Filter out x-anthropic-billing-header from system messages + system_param = anthropic_messages_optional_request_params.get("system") + if system_param is not None: + filtered_system = self._filter_billing_headers_from_system(system_param) + if filtered_system is not None and len(filtered_system) > 0: + anthropic_messages_optional_request_params["system"] = filtered_system + else: + # Remove system parameter if all content was filtered out + anthropic_messages_optional_request_params.pop("system", None) + ####### get required params for all anthropic messages requests ###### verbose_logger.debug(f"TRANSFORMATION DEBUG - Messages: {messages}") anthropic_messages_request: AnthropicMessagesRequest = AnthropicMessagesRequest( @@ -175,10 +223,11 @@ class AnthropicMessagesConfig(BaseAnthropicMessagesConfig): - context_management: adds 'context-management-2025-06-27' - tool_search: adds provider-specific tool search header - output_format: adds 'structured-outputs-2025-11-13' + - speed: adds 'fast-mode-2026-02-01' Args: headers: Request headers dict - optional_params: Optional parameters including tools, context_management, output_format + optional_params: Optional parameters including tools, context_management, output_format, speed custom_llm_provider: Provider name for looking up correct tool search header """ beta_values: set = set() @@ -189,13 +238,36 @@ class AnthropicMessagesConfig(BaseAnthropicMessagesConfig): beta_values.update(b.strip() for b in existing_beta.split(",")) # Check for context management - if optional_params.get("context_management") is not None: - beta_values.add(ANTHROPIC_BETA_HEADER_VALUES.CONTEXT_MANAGEMENT_2025_06_27.value) + context_management_param = optional_params.get("context_management") + if context_management_param is not None: + # Check edits array for compact_20260112 type + edits = context_management_param.get("edits", []) + has_compact = False + has_other = False + + for edit in edits: + edit_type = edit.get("type", "") + if edit_type == "compact_20260112": + has_compact = True + else: + has_other = True + + # Add compact header if any compact edits exist + if has_compact: + beta_values.add(ANTHROPIC_BETA_HEADER_VALUES.COMPACT_2026_01_12.value) + + # Add context management header if any other edits exist + if has_other: + beta_values.add(ANTHROPIC_BETA_HEADER_VALUES.CONTEXT_MANAGEMENT_2025_06_27.value) # Check for structured outputs if optional_params.get("output_format") is not None: beta_values.add(ANTHROPIC_BETA_HEADER_VALUES.STRUCTURED_OUTPUT_2025_09_25.value) + # Check for fast mode + if optional_params.get("speed") == "fast": + beta_values.add(ANTHROPIC_BETA_HEADER_VALUES.FAST_MODE_2026_02_01.value) + # Check for tool search tools tools = optional_params.get("tools") if tools: diff --git a/litellm/llms/azure/azure.py b/litellm/llms/azure/azure.py index cb9fe0aeb30..76fa713ca8c 100644 --- a/litellm/llms/azure/azure.py +++ b/litellm/llms/azure/azure.py @@ -1060,6 +1060,7 @@ class AzureChatCompletion(BaseAzureLLM, BaseLLM): headers: dict, client=None, timeout=None, + model: Optional[str] = None, ) -> ImageResponse: response: Optional[dict] = None @@ -1071,8 +1072,9 @@ class AzureChatCompletion(BaseAzureLLM, BaseLLM): if api_base.endswith("/"): api_base = api_base.rstrip("/") api_version: str = azure_client_params.get("api_version", "") + # Use the deployment name (model) for URL construction, not the base_model from data img_gen_api_base = self.create_azure_base_url( - azure_client_params=azure_client_params, model=data.get("model", "") + azure_client_params=azure_client_params, model=model or data.get("model", "") ) ## LOGGING @@ -1159,21 +1161,20 @@ class AzureChatCompletion(BaseAzureLLM, BaseLLM): model = model else: model = None - ## BASE MODEL CHECK if ( model_response is not None - and optional_params.get("base_model", None) is not None + and litellm_params is not None + and litellm_params.get("base_model", None) is not None ): - model_response._hidden_params["model"] = optional_params.pop( - "base_model" - ) + model_response._hidden_params["model"] = litellm_params.get("base_model", None) # Azure image generation API doesn't support extra_body parameter extra_body = optional_params.pop("extra_body", {}) flattened_params = {**optional_params, **extra_body} - data = {"model": model, "prompt": prompt, **flattened_params} + base_model = litellm_params.get("base_model", None) if litellm_params else None + data = {"model": base_model or model, "prompt": prompt, **flattened_params} max_retries = data.pop("max_retries", 2) if not isinstance(max_retries, int): raise AzureOpenAIError( @@ -1196,10 +1197,11 @@ class AzureChatCompletion(BaseAzureLLM, BaseLLM): is_async=False, ) if aimg_generation is True: - return self.aimage_generation(data=data, input=input, logging_obj=logging_obj, model_response=model_response, api_key=api_key, client=client, azure_client_params=azure_client_params, timeout=timeout, headers=headers) # type: ignore + return self.aimage_generation(data=data, input=input, logging_obj=logging_obj, model_response=model_response, api_key=api_key, client=client, azure_client_params=azure_client_params, timeout=timeout, headers=headers, model=model) # type: ignore + # Use the deployment name (model) for URL construction, not the base_model from data img_gen_api_base = self.create_azure_base_url( - azure_client_params=azure_client_params, model=data.get("model", "") + azure_client_params=azure_client_params, model=model ) ## LOGGING diff --git a/litellm/llms/azure/chat/gpt_transformation.py b/litellm/llms/azure/chat/gpt_transformation.py index 0ae6fad7300..18dad503a59 100644 --- a/litellm/llms/azure/chat/gpt_transformation.py +++ b/litellm/llms/azure/chat/gpt_transformation.py @@ -105,6 +105,7 @@ class AzureOpenAIConfig(BaseConfig): "modalities", "audio", "web_search_options", + "prompt_cache_key", ] def _is_response_format_supported_model(self, model: str) -> bool: diff --git a/litellm/llms/azure_ai/anthropic/messages_transformation.py b/litellm/llms/azure_ai/anthropic/messages_transformation.py index 0d00c907031..a4dc88f9c68 100644 --- a/litellm/llms/azure_ai/anthropic/messages_transformation.py +++ b/litellm/llms/azure_ai/anthropic/messages_transformation.py @@ -62,7 +62,6 @@ class AzureAnthropicMessagesConfig(AnthropicMessagesConfig): if "content-type" not in headers: headers["content-type"] = "application/json" - # Update headers with anthropic beta features (context management, tool search, etc.) headers = self._update_headers_with_anthropic_beta( headers=headers, optional_params=optional_params, diff --git a/litellm/llms/azure_ai/anthropic/transformation.py b/litellm/llms/azure_ai/anthropic/transformation.py index 2d8d3b987c7..c5510db68b1 100644 --- a/litellm/llms/azure_ai/anthropic/transformation.py +++ b/litellm/llms/azure_ai/anthropic/transformation.py @@ -2,7 +2,6 @@ Azure Anthropic transformation config - extends AnthropicConfig with Azure authentication """ from typing import TYPE_CHECKING, Dict, List, Optional, Union - from litellm.llms.anthropic.chat.transformation import AnthropicConfig from litellm.llms.azure.common_utils import BaseAzureLLM from litellm.types.llms.openai import AllMessageValues @@ -87,6 +86,7 @@ class AzureAnthropicConfig(AnthropicConfig): if "anthropic-version" not in headers: headers["anthropic-version"] = "2023-06-01" + return headers def transform_request( diff --git a/litellm/llms/azure_ai/chat/transformation.py b/litellm/llms/azure_ai/chat/transformation.py index 04d2b3a2769..585efd3307d 100644 --- a/litellm/llms/azure_ai/chat/transformation.py +++ b/litellm/llms/azure_ai/chat/transformation.py @@ -11,12 +11,14 @@ from litellm.litellm_core_utils.prompt_templates.common_utils import ( _audio_or_image_in_message_content, convert_content_list_to_str, ) +from litellm.llms.azure.common_utils import BaseAzureLLM from litellm.llms.base_llm.chat.transformation import LiteLLMLoggingObj from litellm.llms.openai.common_utils import drop_params_from_unprocessable_entity_error from litellm.llms.openai.openai import OpenAIConfig from litellm.llms.xai.chat.transformation import XAIChatConfig from litellm.secret_managers.main import get_secret_str from litellm.types.llms.openai import AllMessageValues +from litellm.types.router import GenericLiteLLMParams from litellm.types.utils import ModelResponse, ProviderField from litellm.utils import _add_path_to_api_base, supports_tool_choice @@ -64,12 +66,21 @@ class AzureAIStudioConfig(OpenAIConfig): api_key: Optional[str] = None, api_base: Optional[str] = None, ) -> dict: - if api_base and self._should_use_api_key_header(api_base): - headers["api-key"] = api_key + if api_key: + if api_base and self._should_use_api_key_header(api_base): + headers["api-key"] = api_key + else: + headers["Authorization"] = f"Bearer {api_key}" else: - headers["Authorization"] = f"Bearer {api_key}" + # No api_key provided — fall back to Azure AD token-based auth + litellm_params_obj = GenericLiteLLMParams( + **(litellm_params if isinstance(litellm_params, dict) else {}) + ) + headers = BaseAzureLLM._base_validate_azure_environment( + headers=headers, litellm_params=litellm_params_obj + ) - headers["Content-Type"] = "application/json" # tell Azure AI Studio to expect JSON + headers["Content-Type"] = "application/json" return headers diff --git a/litellm/llms/bedrock/base_aws_llm.py b/litellm/llms/bedrock/base_aws_llm.py index 1de1c40c438..304c707fa0b 100644 --- a/litellm/llms/bedrock/base_aws_llm.py +++ b/litellm/llms/bedrock/base_aws_llm.py @@ -211,25 +211,13 @@ class BaseAWSLLM: aws_external_id=aws_external_id, ) elif aws_role_name is not None: - # Check if we're in IRSA and trying to assume the same role we already have - current_role_arn = os.getenv("AWS_ROLE_ARN") - web_identity_token_file = os.getenv("AWS_WEB_IDENTITY_TOKEN_FILE") - - # In IRSA environments, we should skip role assumption if we're already running as the target role - # This is true when: - # 1. We have AWS_ROLE_ARN set (current role) - # 2. We have AWS_WEB_IDENTITY_TOKEN_FILE set (IRSA environment) - # 3. The current role matches the requested role - if ( - current_role_arn - and web_identity_token_file - and current_role_arn == aws_role_name - ): + # Check if we're already running as the target role and can skip assumption + # This handles IRSA (EKS), ECS task roles, and EC2 instance profiles + if self._is_already_running_as_role(aws_role_name, ssl_verify=ssl_verify): verbose_logger.debug( - "Using IRSA same-role optimization: calling _auth_with_env_vars" + "Already running as target role %s, using ambient credentials", + aws_role_name, ) - # We're already running as this role via IRSA, no need to assume it again - # Use the default boto3 credentials (which will use the IRSA credentials) credentials, _cache_ttl = self._auth_with_env_vars() else: verbose_logger.debug( @@ -553,6 +541,107 @@ class BaseAWSLLM: aws_region_name = "us-west-2" return aws_region_name + @staticmethod + def _parse_arn_account_and_role_name( + arn: str, + ) -> Optional[Tuple[str, str, str]]: + """ + Parse an ARN and return (partition, account_id, role_name). + + Handles: + - arn:aws:iam::123456789012:role/MyRole + - arn:aws:iam::123456789012:role/path/to/MyRole + - arn:aws:sts::123456789012:assumed-role/MyRole/session-name + + Returns None if the ARN cannot be parsed. + """ + # ARN format: arn:PARTITION:SERVICE:REGION:ACCOUNT:RESOURCE + parts = arn.split(":") + if len(parts) < 6 or parts[0] != "arn": + return None + + partition = parts[1] # e.g. "aws", "aws-cn", "aws-us-gov" + account_id = parts[4] + resource = ":".join(parts[5:]) # rejoin in case resource contains colons + + if resource.startswith("role/"): + # arn:aws:iam::ACCOUNT:role/[path/]ROLE_NAME + role_name = resource.split("/")[-1] + elif resource.startswith("assumed-role/"): + # arn:aws:sts::ACCOUNT:assumed-role/ROLE_NAME/SESSION + role_parts = resource.split("/") + if len(role_parts) >= 2: + role_name = role_parts[1] + else: + return None + else: + return None + + return partition, account_id, role_name + + def _is_already_running_as_role( + self, + aws_role_name: str, + ssl_verify: Optional[Union[bool, str]] = None, + ) -> bool: + """ + Check if the current environment is already running as the target IAM role. + + This handles multiple AWS environments: + - IRSA (EKS): AWS_ROLE_ARN + AWS_WEB_IDENTITY_TOKEN_FILE are set + - ECS task roles: Uses sts:GetCallerIdentity to check current role ARN + - EC2 instance profiles: Uses sts:GetCallerIdentity to check current role ARN + + Compares partition, account ID, and role name to avoid cross-account + false matches. + + Returns True if the current identity matches the target role, meaning + we can skip sts:AssumeRole and use ambient credentials directly. + """ + target_parsed = self._parse_arn_account_and_role_name(aws_role_name) + if target_parsed is None: + return False + + target_partition, target_account, target_role = target_parsed + + # Fast path: IRSA environment check (no API call needed) + current_role_arn = os.getenv("AWS_ROLE_ARN") + web_identity_token_file = os.getenv("AWS_WEB_IDENTITY_TOKEN_FILE") + if current_role_arn and web_identity_token_file: + return current_role_arn == aws_role_name + + # For ECS/EC2: call sts:GetCallerIdentity to check if already running as the role + try: + import boto3 + + with tracer.trace("boto3.client(sts).get_caller_identity"): + sts_client = boto3.client( + "sts", verify=self._get_ssl_verify(ssl_verify) + ) + identity = sts_client.get_caller_identity() + caller_arn = identity.get("Arn", "") + + caller_parsed = self._parse_arn_account_and_role_name(caller_arn) + if caller_parsed is not None: + caller_partition, caller_account, caller_role = caller_parsed + if ( + caller_partition == target_partition + and caller_account == target_account + and caller_role == target_role + ): + verbose_logger.debug( + "Current identity already matches target role: %s", + aws_role_name, + ) + return True + + except Exception as e: + verbose_logger.debug( + "Could not determine current role identity: %s", str(e) + ) + + return False + @tracer.wrap() def _auth_with_web_identity_token( self, @@ -867,7 +956,35 @@ class BaseAWSLLM: if aws_external_id is not None: assume_role_params["ExternalId"] = aws_external_id - sts_response = sts_client.assume_role(**assume_role_params) + try: + sts_response = sts_client.assume_role(**assume_role_params) + except Exception as e: + error_str = str(e) + if "AccessDenied" in error_str: + # Only fall back to ambient credentials if we can positively + # confirm the caller is already the target role (same account, + # partition, and role name). This avoids silently using the + # wrong identity when there is a genuine trust-policy or + # permission misconfiguration. + if self._is_already_running_as_role( + aws_role_name, ssl_verify=ssl_verify + ): + verbose_logger.warning( + "AssumeRole failed for %s (%s). " + "Caller is already running as this role; " + "falling back to ambient credentials.", + aws_role_name, + error_str, + ) + return self._auth_with_env_vars() + # Genuine permission error — re-raise + verbose_logger.error( + "AssumeRole AccessDenied for %s and caller is NOT " + "the same role. Re-raising. Error: %s", + aws_role_name, + error_str, + ) + raise # Extract the credentials from the response and convert to Session Credentials sts_credentials = sts_response["Credentials"] diff --git a/litellm/llms/bedrock/chat/converse_handler.py b/litellm/llms/bedrock/chat/converse_handler.py index d5bd054118d..25af852e09c 100644 --- a/litellm/llms/bedrock/chat/converse_handler.py +++ b/litellm/llms/bedrock/chat/converse_handler.py @@ -13,7 +13,9 @@ from litellm.llms.custom_httpx.http_handler import ( ) from litellm.types.utils import ModelResponse from litellm.utils import CustomStreamWrapper - +from litellm.anthropic_beta_headers_manager import ( + update_headers_with_filtered_beta, + ) from ..base_aws_llm import BaseAWSLLM, Credentials from ..common_utils import BedrockError from .invoke_handler import AWSEventStreamDecoder, MockResponseIterator, make_call @@ -337,7 +339,11 @@ class BedrockConverseLLM(BaseAWSLLM): headers = {"Content-Type": "application/json"} if extra_headers is not None: headers = {"Content-Type": "application/json", **extra_headers} - + + # Filter beta headers in HTTP headers before making the request + headers = update_headers_with_filtered_beta( + headers=headers, provider="bedrock_converse" + ) ### ROUTING (ASYNC, STREAMING, SYNC) if acompletion: if isinstance(client, HTTPHandler): diff --git a/litellm/llms/bedrock/chat/converse_transformation.py b/litellm/llms/bedrock/chat/converse_transformation.py index 6591e152a14..efa755d515e 100644 --- a/litellm/llms/bedrock/chat/converse_transformation.py +++ b/litellm/llms/bedrock/chat/converse_transformation.py @@ -30,8 +30,6 @@ from litellm.litellm_core_utils.prompt_templates.factory import ( from litellm.llms.anthropic.chat.transformation import AnthropicConfig from litellm.llms.base_llm.chat.transformation import BaseConfig, BaseLLMException from litellm.types.llms.bedrock import * - -from ..common_utils import is_claude_4_5_on_bedrock from litellm.types.llms.openai import ( AllMessageValues, ChatCompletionAssistantMessage, @@ -68,6 +66,7 @@ from ..common_utils import ( BedrockModelInfo, get_anthropic_beta_from_headers, get_bedrock_tool_name, + is_claude_4_5_on_bedrock, ) # Computer use tool prefixes supported by Bedrock @@ -83,6 +82,7 @@ BEDROCK_COMPUTER_USE_TOOLS = [ UNSUPPORTED_BEDROCK_CONVERSE_BETA_PATTERNS = [ "advanced-tool-use", # Bedrock Converse doesn't support advanced-tool-use beta headers "prompt-caching", # Prompt caching not supported in Converse API + "compact-2026-01-12", # The compact beta feature is not currently supported on the Converse and ConverseStream APIs ] @@ -431,7 +431,7 @@ class AmazonConverseConfig(BaseConfig): else: # Anthropic and other models: convert to thinking parameter optional_params["thinking"] = AnthropicConfig._map_reasoning_effort( - reasoning_effort + reasoning_effort=reasoning_effort, model=model ) def get_supported_openai_params(self, model: str) -> List[str]: @@ -617,37 +617,6 @@ class AmazonConverseConfig(BaseConfig): return transformed_tools - def _filter_unsupported_beta_headers_for_bedrock( - self, model: str, beta_list: list - ) -> list: - """ - Remove beta headers that are not supported on Bedrock Converse API for the given model. - - Extended thinking beta headers are only supported on specific Claude 4+ models. - Some beta headers are universally unsupported on Bedrock Converse API. - - Args: - model: The model name - beta_list: The list of beta headers to filter - - Returns: - Filtered list of beta headers - """ - filtered_betas = [] - - # 1. Filter out beta headers that are universally unsupported on Bedrock Converse - for beta in beta_list: - should_keep = True - for unsupported_pattern in UNSUPPORTED_BEDROCK_CONVERSE_BETA_PATTERNS: - if unsupported_pattern in beta.lower(): - should_keep = False - break - - if should_keep: - filtered_betas.append(beta) - - return filtered_betas - def _separate_computer_use_tools( self, tools: List[OpenAIChatCompletionToolParam], model: str ) -> Tuple[ @@ -1124,7 +1093,28 @@ class AmazonConverseConfig(BaseConfig): # Add computer use tools and anthropic_beta if needed (only when computer use tools are present) if computer_use_tools: - anthropic_beta_list.append("computer-use-2024-10-22") + # Determine the correct computer-use beta header based on model + # "computer-use-2025-11-24" for Claude Opus 4.6, Claude Opus 4.5 + # "computer-use-2025-01-24" for Claude Sonnet 4.5, Haiku 4.5, Opus 4.1, Sonnet 4, Opus 4, and Sonnet 3.7 + # "computer-use-2024-10-22" for older models + model_lower = model.lower() + if "opus-4.6" in model_lower or "opus_4.6" in model_lower or "opus-4-6" in model_lower or "opus_4_6" in model_lower: + computer_use_header = "computer-use-2025-11-24" + elif "opus-4.5" in model_lower or "opus_4.5" in model_lower or "opus-4-5" in model_lower or "opus_4_5" in model_lower: + computer_use_header = "computer-use-2025-11-24" + elif any(pattern in model_lower for pattern in [ + "sonnet-4.5", "sonnet_4.5", "sonnet-4-5", "sonnet_4_5", + "haiku-4.5", "haiku_4.5", "haiku-4-5", "haiku_4_5", + "opus-4.1", "opus_4.1", "opus-4-1", "opus_4_1", + "sonnet-4", "sonnet_4", + "opus-4", "opus_4", + "sonnet-3.7", "sonnet_3.7", "sonnet-3-7", "sonnet_3_7" + ]): + computer_use_header = "computer-use-2025-01-24" + else: + computer_use_header = "computer-use-2024-10-22" + + anthropic_beta_list.append(computer_use_header) # Transform computer use tools to proper Bedrock format transformed_computer_tools = self._transform_computer_use_tools( computer_use_tools @@ -1139,24 +1129,9 @@ class AmazonConverseConfig(BaseConfig): # Set anthropic_beta in additional_request_params if we have any beta features # ONLY apply to Anthropic/Claude models - other models (e.g., Qwen, Llama) don't support this field - # and will error with "unknown variant anthropic_beta" if included base_model = BedrockModelInfo.get_base_model(model) if anthropic_beta_list and base_model.startswith("anthropic"): - # Remove duplicates while preserving order - unique_betas = [] - seen = set() - for beta in anthropic_beta_list: - if beta not in seen: - unique_betas.append(beta) - seen.add(beta) - - # Filter out unsupported beta headers for Bedrock Converse API - filtered_betas = self._filter_unsupported_beta_headers_for_bedrock( - model=model, - beta_list=unique_betas, - ) - - additional_request_params["anthropic_beta"] = filtered_betas + additional_request_params["anthropic_beta"] = anthropic_beta_list return bedrock_tools, anthropic_beta_list diff --git a/litellm/llms/bedrock/chat/invoke_transformations/anthropic_claude3_transformation.py b/litellm/llms/bedrock/chat/invoke_transformations/anthropic_claude3_transformation.py index c936b2cd23c..dfab81123fd 100644 --- a/litellm/llms/bedrock/chat/invoke_transformations/anthropic_claude3_transformation.py +++ b/litellm/llms/bedrock/chat/invoke_transformations/anthropic_claude3_transformation.py @@ -133,27 +133,9 @@ class AmazonAnthropicClaudeConfig(AmazonInvokeConfig, AnthropicConfig): beta_set.add("tool-search-tool-2025-10-19") # Filter out beta headers that Bedrock Invoke doesn't support - # AWS Bedrock only supports a specific whitelist of beta flags - # Reference: https://docs.aws.amazon.com/bedrock/latest/userguide/model-parameters-anthropic-claude-messages-request-response.html - BEDROCK_SUPPORTED_BETAS = { - "computer-use-2024-10-22", # Legacy computer use - "computer-use-2025-01-24", # Current computer use (Claude 3.7 Sonnet) - "token-efficient-tools-2025-02-19", # Tool use (Claude 3.7+ and Claude 4+) - "interleaved-thinking-2025-05-14", # Interleaved thinking (Claude 4+) - "output-128k-2025-02-19", # 128K output tokens (Claude 3.7 Sonnet) - "dev-full-thinking-2025-05-14", # Developer mode for raw thinking (Claude 4+) - "context-1m-2025-08-07", # 1 million tokens (Claude Sonnet 4) - "context-management-2025-06-27", # Context management (Claude Sonnet/Haiku 4.5) - "effort-2025-11-24", # Effort parameter (Claude Opus 4.5) - "tool-search-tool-2025-10-19", # Tool search (Claude Opus 4.5) - "tool-examples-2025-10-29", # Tool use examples (Claude Opus 4.5) - } - - # Only keep beta headers that Bedrock supports - beta_set = {beta for beta in beta_set if beta in BEDROCK_SUPPORTED_BETAS} - - if beta_set: - _anthropic_request["anthropic_beta"] = list(beta_set) + # Uses centralized configuration from anthropic_beta_headers_config.json + beta_list = list(beta_set) + _anthropic_request["anthropic_beta"] = beta_list return _anthropic_request diff --git a/litellm/llms/bedrock/messages/invoke_transformations/anthropic_claude3_transformation.py b/litellm/llms/bedrock/messages/invoke_transformations/anthropic_claude3_transformation.py index 90de67a822f..2c041adba7a 100644 --- a/litellm/llms/bedrock/messages/invoke_transformations/anthropic_claude3_transformation.py +++ b/litellm/llms/bedrock/messages/invoke_transformations/anthropic_claude3_transformation.py @@ -55,10 +55,6 @@ class AmazonAnthropicClaudeMessagesConfig( # Beta header patterns that are not supported by Bedrock Invoke API # These will be filtered out to prevent 400 "invalid beta flag" errors - UNSUPPORTED_BEDROCK_INVOKE_BETA_PATTERNS = [ - "advanced-tool-use", # Bedrock Invoke doesn't support advanced-tool-use beta headers - "prompt-caching-scope", - ] def __init__(self, **kwargs): BaseAnthropicMessagesConfig.__init__(self, **kwargs) @@ -254,62 +250,6 @@ class AmazonAnthropicClaudeMessagesConfig( return any(pattern in model_lower for pattern in supported_patterns) - def _filter_unsupported_beta_headers_for_bedrock( - self, model: str, beta_set: set - ) -> None: - """ - Remove beta headers that are not supported on Bedrock for the given model. - - Extended thinking beta headers are only supported on specific Claude 4+ models. - Advanced tool use headers are not supported on Bedrock Invoke API, but need to be - translated to Bedrock-specific headers for models that support tool search - (Claude Opus 4.5, Sonnet 4.5). - This prevents 400 "invalid beta flag" errors on Bedrock. - - Note: Bedrock Invoke API fails with a 400 error when unsupported beta headers - are sent, returning: {"message":"invalid beta flag"} - - Translation for models supporting tool search (Opus 4.5, Sonnet 4.5): - - advanced-tool-use-2025-11-20 -> tool-search-tool-2025-10-19 + tool-examples-2025-10-29 - - Args: - model: The model name - beta_set: The set of beta headers to filter in-place - """ - beta_headers_to_remove = set() - has_advanced_tool_use = False - - # 1. Filter out beta headers that are universally unsupported on Bedrock Invoke and track if advanced-tool-use header is present - for beta in beta_set: - for unsupported_pattern in self.UNSUPPORTED_BEDROCK_INVOKE_BETA_PATTERNS: - if unsupported_pattern in beta.lower(): - beta_headers_to_remove.add(beta) - has_advanced_tool_use = True - break - - # 2. Filter out extended thinking headers for models that don't support them - extended_thinking_patterns = [ - "extended-thinking", - "interleaved-thinking", - ] - if not self._supports_extended_thinking_on_bedrock(model): - for beta in beta_set: - for pattern in extended_thinking_patterns: - if pattern in beta.lower(): - beta_headers_to_remove.add(beta) - break - - # Remove all filtered headers - for beta in beta_headers_to_remove: - beta_set.discard(beta) - - # 3. Translate advanced-tool-use to Bedrock-specific headers for models that support tool search - # Ref: https://docs.aws.amazon.com/bedrock/latest/userguide/model-parameters-anthropic-claude-messages-request-response.html - # Ref: https://platform.claude.com/docs/en/agents-and-tools/tool-use/tool-search-tool - if has_advanced_tool_use and self._supports_tool_search_on_bedrock(model): - beta_set.add("tool-search-tool-2025-10-19") - beta_set.add("tool-examples-2025-10-29") - def _get_tool_search_beta_header_for_bedrock( self, model: str, @@ -475,12 +415,11 @@ class AmazonAnthropicClaudeMessagesConfig( beta_set=beta_set, ) - # Filter out unsupported beta headers for Bedrock (e.g., advanced-tool-use, extended-thinking on non-Opus/Sonnet 4 models) - self._filter_unsupported_beta_headers_for_bedrock( - model=model, - beta_set=beta_set, - ) - + # --- Custom logic: if tool-search-tool-2025-10-19 is present, add tool-examples-2025-10-29 --- + if "tool-search-tool-2025-10-19" in beta_set: + beta_set.add("tool-examples-2025-10-29") + # ------------------------------------------------------------------------------ + if beta_set: anthropic_messages_request["anthropic_beta"] = list(beta_set) diff --git a/litellm/llms/custom_httpx/aiohttp_transport.py b/litellm/llms/custom_httpx/aiohttp_transport.py index a7b83d8c802..1b03ec47643 100644 --- a/litellm/llms/custom_httpx/aiohttp_transport.py +++ b/litellm/llms/custom_httpx/aiohttp_transport.py @@ -1,6 +1,7 @@ import asyncio import contextlib import os +import ssl import typing import urllib.request from typing import Callable, Dict, Optional, Union @@ -139,8 +140,13 @@ class LiteLLMAiohttpTransport(AiohttpTransport): Credit to: https://github.com/karpetrosyan/httpx-aiohttp for this implementation """ - def __init__(self, client: Union[ClientSession, Callable[[], ClientSession]]): + def __init__( + self, + client: Union[ClientSession, Callable[[], ClientSession]], + ssl_verify: Optional[Union[bool, ssl.SSLContext]] = None, + ): self.client = client + self._ssl_verify = ssl_verify # Store for per-request SSL override super().__init__(client=client) # Store the client factory for recreating sessions when needed if callable(client): @@ -214,6 +220,7 @@ class LiteLLMAiohttpTransport(AiohttpTransport): timeout: dict, proxy: Optional[str], sni_hostname: Optional[str], + ssl_verify: Optional[Union[bool, ssl.SSLContext]] = None, ) -> ClientResponse: """ Helper function to make an aiohttp request with the given parameters. @@ -224,6 +231,7 @@ class LiteLLMAiohttpTransport(AiohttpTransport): timeout: Timeout settings dict with 'connect', 'read', 'pool' keys proxy: Optional proxy URL sni_hostname: Optional SNI hostname for SSL + ssl_verify: Optional SSL verification setting (False to disable, SSLContext for custom) Returns: ClientResponse from aiohttp @@ -237,6 +245,13 @@ class LiteLLMAiohttpTransport(AiohttpTransport): data = request.stream # type: ignore request.headers.pop("transfer-encoding", None) # handled by aiohttp + # Only pass ssl kwarg when explicitly configured, to avoid + # overriding the session/connector defaults with None (which is + # not a valid value for aiohttp's ssl parameter). + ssl_kwargs: Dict[str, Union[bool, ssl.SSLContext]] = {} + if ssl_verify is not None: + ssl_kwargs["ssl"] = ssl_verify + response = await client_session.request( method=request.method, url=YarlURL(str(request.url), encoded=True), @@ -251,6 +266,7 @@ class LiteLLMAiohttpTransport(AiohttpTransport): ), proxy=proxy, server_hostname=sni_hostname, + **ssl_kwargs, ).__aenter__() return response @@ -268,6 +284,9 @@ class LiteLLMAiohttpTransport(AiohttpTransport): # Resolve proxy settings from environment variables proxy = await self._get_proxy_settings(request) + # Use stored SSL configuration for per-request override + ssl_config = self._ssl_verify + try: with map_aiohttp_exceptions(): response = await self._make_aiohttp_request( @@ -276,6 +295,7 @@ class LiteLLMAiohttpTransport(AiohttpTransport): timeout=timeout, proxy=proxy, sni_hostname=sni_hostname, + ssl_verify=ssl_config, ) except RuntimeError as e: # Handle the case where session was closed between our check and actual use @@ -296,6 +316,7 @@ class LiteLLMAiohttpTransport(AiohttpTransport): timeout=timeout, proxy=proxy, sni_hostname=sni_hostname, + ssl_verify=ssl_config, ) else: # Re-raise if it's a different RuntimeError diff --git a/litellm/llms/custom_httpx/http_handler.py b/litellm/llms/custom_httpx/http_handler.py index ac9dd5998e2..95f411c397c 100644 --- a/litellm/llms/custom_httpx/http_handler.py +++ b/litellm/llms/custom_httpx/http_handler.py @@ -846,6 +846,16 @@ class AsyncHTTPHandler: if str_to_bool(os.getenv("AIOHTTP_TRUST_ENV", "False")) is True: trust_env = True + ######################################################### + # Determine SSL config to pass to transport for per-request override + # This ensures ssl_verify works even with shared sessions + ######################################################### + ssl_for_transport: Optional[Union[bool, ssl.SSLContext]] = None + if ssl_context is not None: + ssl_for_transport = ssl_context + elif ssl_verify is False: + ssl_for_transport = False + verbose_logger.debug("Creating AiohttpTransport...") # Use shared session if provided and valid @@ -853,7 +863,10 @@ class AsyncHTTPHandler: verbose_logger.debug( f"SHARED SESSION: Reusing existing ClientSession (ID: {id(shared_session)})" ) - return LiteLLMAiohttpTransport(client=shared_session) + return LiteLLMAiohttpTransport( + client=shared_session, + ssl_verify=ssl_for_transport, + ) # Create new session only if none provided or existing one is invalid verbose_logger.debug( @@ -877,6 +890,7 @@ class AsyncHTTPHandler: connector=TCPConnector(**transport_connector_kwargs), trust_env=trust_env, ), + ssl_verify=ssl_for_transport, ) @staticmethod diff --git a/litellm/llms/custom_httpx/llm_http_handler.py b/litellm/llms/custom_httpx/llm_http_handler.py index d2ea7e872a2..a97ebd8e74c 100644 --- a/litellm/llms/custom_httpx/llm_http_handler.py +++ b/litellm/llms/custom_httpx/llm_http_handler.py @@ -81,6 +81,9 @@ from litellm.types.llms.anthropic_skills import ( ListSkillsResponse, Skill, ) +from litellm.anthropic_beta_headers_manager import ( + update_headers_with_filtered_beta, + ) from litellm.types.llms.openai import ( CreateBatchRequest, CreateFileRequest, @@ -302,7 +305,7 @@ class BaseLLMHTTPHandler: logging_obj=logging_obj, signed_json_body=signed_json_body, ) - return provider_config.transform_response( + initial_response = provider_config.transform_response( model=model, raw_response=response, model_response=model_response, @@ -316,6 +319,20 @@ class BaseLLMHTTPHandler: json_mode=json_mode, ) + # Call agentic chat completion hooks + final_response = await self._call_agentic_chat_completion_hooks( + response=initial_response, + model=model, + messages=messages, + optional_params=optional_params, + logging_obj=logging_obj, + stream=False, + custom_llm_provider=custom_llm_provider, + kwargs=litellm_params, + ) + + return final_response if final_response is not None else initial_response + def completion( self, model: str, @@ -412,6 +429,11 @@ class BaseLLMHTTPHandler: }, ) + # Check if stream was converted for WebSearch interception + # This is set by the async_pre_request_hook in WebSearchInterceptionLogger + if litellm_params.get("_websearch_interception_converted_stream", False): + logging_obj.model_call_details["websearch_interception_converted_stream"] = True + if acompletion is True: if stream is True: data = self._add_stream_param_to_request_body( @@ -1839,6 +1861,10 @@ class BaseLLMHTTPHandler: api_key=api_key, api_base=api_base, ) + + headers = update_headers_with_filtered_beta( + headers=headers, provider=custom_llm_provider + ) logging_obj.update_environment_variables( model=model, @@ -4361,10 +4387,10 @@ class BaseLLMHTTPHandler: kwargs: Dict, ) -> Optional[Any]: """ - Call agentic completion hooks for all custom loggers. + Call agentic completion hooks for all custom loggers (Anthropic Messages API). - 1. Call async_should_run_agentic_completion to check if agentic loop is needed - 2. If yes, call async_run_agentic_completion to execute the loop + 1. Call async_should_run_agentic_loop to check if agentic loop is needed + 2. If yes, call async_run_agentic_loop to execute the loop Returns the response from agentic loop, or None if no hook runs. """ @@ -4453,6 +4479,105 @@ class BaseLLMHTTPHandler: return None + async def _call_agentic_chat_completion_hooks( + self, + response: Any, + model: str, + messages: List[Dict], + optional_params: Dict, + logging_obj: "LiteLLMLoggingObj", + stream: bool, + custom_llm_provider: str, + kwargs: Dict, + ) -> Optional[Any]: + """ + Call agentic chat completion hooks for all custom loggers (Chat Completions API). + + 1. Call async_should_run_chat_completion_agentic_loop to check if agentic loop is needed + 2. If yes, call async_run_chat_completion_agentic_loop to execute the loop + + Returns the response from agentic loop, or None if no hook runs. + """ + from litellm._logging import verbose_logger + from litellm.integrations.custom_logger import CustomLogger + + callbacks = litellm.callbacks + ( + logging_obj.dynamic_success_callbacks or [] + ) + tools = optional_params.get("tools", []) + + for callback in callbacks: + try: + if isinstance(callback, CustomLogger): + # Check if callback has the chat completion agentic loop method + if not hasattr(callback, "async_should_run_chat_completion_agentic_loop"): + continue + + # First: Check if agentic loop should run + should_run, tool_calls = ( + await callback.async_should_run_chat_completion_agentic_loop( + response=response, + model=model, + messages=messages, + tools=tools, + stream=stream, + custom_llm_provider=custom_llm_provider, + kwargs=kwargs, + ) + ) + + if should_run: + # Second: Execute agentic loop + # Add custom_llm_provider to kwargs so the agentic loop can reconstruct the full model name + kwargs_with_provider = kwargs.copy() if kwargs else {} + kwargs_with_provider["custom_llm_provider"] = custom_llm_provider + agentic_response = await callback.async_run_chat_completion_agentic_loop( + tools=tool_calls, + model=model, + messages=messages, + response=response, + optional_params=optional_params, + logging_obj=logging_obj, + stream=stream, + kwargs=kwargs_with_provider, + ) + # First hook that runs agentic loop wins + return agentic_response + + except Exception as e: + verbose_logger.exception( + f"LiteLLM.AgenticHookError: Exception in chat completion agentic hooks: {str(e)}" + ) + + # Check if we need to convert response to fake stream for chat completions + # This happens when: + # 1. Stream was originally True but converted to False for WebSearch interception + # 2. No agentic loop ran (LLM didn't use the tool) + # 3. We have a non-streaming response that needs to be converted to streaming + websearch_converted_stream = ( + logging_obj.model_call_details.get("websearch_interception_converted_stream", False) + if logging_obj is not None + else False + ) + + if websearch_converted_stream: + from litellm._logging import verbose_logger + from litellm.llms.base_llm.base_model_iterator import ( + convert_model_response_to_streaming, + ) + + verbose_logger.debug( + "WebSearchInterception: No tool call made, converting non-streaming chat completion to fake stream" + ) + + # Convert the non-streaming ModelResponse to a fake stream + if hasattr(response, "choices"): + # Use the existing converter for ModelResponse + fake_stream = convert_model_response_to_streaming(response) + return fake_stream + + return None + def _handle_error( self, e: Exception, diff --git a/litellm/llms/databricks/chat/transformation.py b/litellm/llms/databricks/chat/transformation.py index 2b7f5dd5995..7c2a9569c58 100644 --- a/litellm/llms/databricks/chat/transformation.py +++ b/litellm/llms/databricks/chat/transformation.py @@ -60,6 +60,38 @@ from ...anthropic.chat.transformation import AnthropicConfig from ...openai_like.chat.transformation import OpenAILikeChatConfig from ..common_utils import DatabricksBase, DatabricksException +def _sanitize_empty_content(message_dict: dict[str, Any]) -> None: + """ + Remove or filter content so empty text blocks are not sent. + Databricks Model Serving uses Anthropic Messages API spec and rejects empty text blocks. + """ + content = message_dict.get("content") + if content is None: + message_dict.pop("content", None) + return + if isinstance(content, str): + if not content.strip(): + message_dict.pop("content") + return + if isinstance(content, list): + if not content: + message_dict.pop("content") + return + filtered = [ + block + for block in content + if not ( + isinstance(block, dict) + and block.get("type") == "text" + and not (block.get("text") or "").strip() + ) + ] + if not filtered: + message_dict.pop("content") + else: + message_dict["content"] = filtered + + if TYPE_CHECKING: from litellm.litellm_core_utils.litellm_logging import Logging as _LiteLLMLoggingObj @@ -298,7 +330,8 @@ class DatabricksConfig(DatabricksBase, OpenAILikeChatConfig, AnthropicConfig): if "reasoning_effort" in non_default_params and "claude" in model: optional_params["thinking"] = AnthropicConfig._map_reasoning_effort( - non_default_params.get("reasoning_effort") + reasoning_effort=non_default_params.get("reasoning_effort"), + model=model ) optional_params.pop("reasoning_effort", None) ## handle thinking tokens @@ -349,6 +382,7 @@ class DatabricksConfig(DatabricksBase, OpenAILikeChatConfig, AnthropicConfig): # Move message-level cache_control into a content block when content is a string. if "cache_control" in _message and isinstance(_message.get("content"), str): _message = self._move_cache_control_into_string_content_block(_message) + _sanitize_empty_content(cast(dict[str, Any], _message)) new_messages.append(_message) if is_async: diff --git a/litellm/llms/deprecated_providers/palm.py b/litellm/llms/deprecated_providers/palm.py index 3039222c0e2..657a6fdb229 100644 --- a/litellm/llms/deprecated_providers/palm.py +++ b/litellm/llms/deprecated_providers/palm.py @@ -139,7 +139,7 @@ def completion( ) ## COMPLETION CALL try: - response = palm.generate_text(prompt=prompt, **inference_params) + response = palm.generate_text(prompt=prompt, **inference_params) # type: ignore[attr-defined] except Exception as e: raise PalmError( message=str(e), diff --git a/litellm/llms/oci/chat/transformation.py b/litellm/llms/oci/chat/transformation.py index 84f39ef2525..1c22602b483 100644 --- a/litellm/llms/oci/chat/transformation.py +++ b/litellm/llms/oci/chat/transformation.py @@ -218,6 +218,7 @@ class OCIChatConfig(BaseConfig): "parallel_tool_calls": False, "audio": False, "web_search_options": False, + "response_format": "responseFormat", } # Cohere and Gemini use the same parameter mapping as GENERIC @@ -269,6 +270,9 @@ class OCIChatConfig(BaseConfig): adapted_params[alias] = value + if alias == "responseFormat": + adapted_params["response_format"] = value + return adapted_params def _sign_with_oci_signer( @@ -673,6 +677,36 @@ class OCIChatConfig(BaseConfig): selected_params["tools"] = adapt_tool_definition_to_oci_standard( # type: ignore[assignment] selected_params["tools"], vendor # type: ignore[arg-type] ) + + # Transform response_format type to OCI uppercase format + if "responseFormat" in selected_params: + rf = selected_params["responseFormat"] + if isinstance(rf, dict) and "type" in rf: + rf_payload = dict(rf) + selected_params["responseFormat"] = rf_payload + + response_type = rf_payload["type"] + schema_payload: Optional[Any] = None + + if "json_schema" in rf_payload: + raw_schema_payload = rf_payload.pop("json_schema") + if isinstance(raw_schema_payload, dict): + schema_payload = dict(raw_schema_payload) + else: + schema_payload = raw_schema_payload + + if schema_payload is not None: + rf_payload["jsonSchema"] = schema_payload + + if vendor == OCIVendors.COHERE: + # Cohere expects lower-case type values + rf_payload["type"] = response_type + else: + format_type = response_type.upper() + if format_type == "JSON": + format_type = "JSON_OBJECT" + rf_payload["type"] = format_type + return selected_params def adapt_messages_to_cohere_standard(self, messages: List[AllMessageValues]) -> List[CohereMessage]: @@ -804,13 +838,24 @@ class OCIChatConfig(BaseConfig): if not user_messages: raise Exception("No user message found for Cohere model") + # Extract system messages into preambleOverride + system_messages = [msg for msg in messages if msg.get("role") == "system"] + preamble_override = None + if system_messages: + preamble = "\n".join( + self._extract_text_content(msg["content"]) for msg in system_messages + ) + if preamble: + preamble_override = preamble # Create Cohere-specific chat request + optional_cohere_params = self._get_optional_params(OCIVendors.COHERE, optional_params) chat_request = CohereChatRequest( apiFormat="COHERE", message=self._extract_text_content(user_messages[-1]["content"]), chatHistory=self.adapt_messages_to_cohere_standard(messages), - **self._get_optional_params(OCIVendors.COHERE, optional_params) + preambleOverride=preamble_override, + **optional_cohere_params ) data = OCICompletionPayload( diff --git a/litellm/llms/ollama/chat/transformation.py b/litellm/llms/ollama/chat/transformation.py index 8c98cc54050..bc5aa654aad 100644 --- a/litellm/llms/ollama/chat/transformation.py +++ b/litellm/llms/ollama/chat/transformation.py @@ -502,13 +502,12 @@ class OllamaChatCompletionResponseIterator(BaseModelResponseIterator): reasoning_content: Optional[str] = None content: Optional[str] = None if chunk["message"].get("thinking") is not None: - if self.started_reasoning_content is False: - reasoning_content = chunk["message"].get("thinking") - self.started_reasoning_content = True - elif self.finished_reasoning_content is False: - reasoning_content = chunk["message"].get("thinking") - self.finished_reasoning_content = True + reasoning_content = chunk["message"].get("thinking") + self.started_reasoning_content = True elif chunk["message"].get("content") is not None: + if self.started_reasoning_content and not self.finished_reasoning_content: + self.finished_reasoning_content = True + message_content = chunk["message"].get("content") if "" in message_content: message_content = message_content.replace("", "") diff --git a/litellm/llms/openai/chat/gpt_transformation.py b/litellm/llms/openai/chat/gpt_transformation.py index 6cc09dafc2f..16368907070 100644 --- a/litellm/llms/openai/chat/gpt_transformation.py +++ b/litellm/llms/openai/chat/gpt_transformation.py @@ -20,12 +20,12 @@ from typing import ( import httpx import litellm +from litellm.litellm_core_utils.core_helpers import map_finish_reason from litellm.litellm_core_utils.llm_response_utils.convert_dict_to_response import ( _extract_reasoning_content, _handle_invalid_parallel_tool_calls, _should_convert_tool_call_to_json_mode, ) -from litellm.litellm_core_utils.core_helpers import map_finish_reason from litellm.litellm_core_utils.prompt_templates.common_utils import get_tool_call_names from litellm.litellm_core_utils.prompt_templates.image_handling import ( async_convert_url_to_base64, @@ -161,6 +161,7 @@ class OpenAIGPTConfig(BaseLLMModelInfo, BaseConfig): "web_search_options", "service_tier", "safety_identifier", + "prompt_cache_key", ] # works across all models model_specific_params = [] diff --git a/litellm/llms/openai/openai.py b/litellm/llms/openai/openai.py index 8a8070240da..da87852dff5 100644 --- a/litellm/llms/openai/openai.py +++ b/litellm/llms/openai/openai.py @@ -501,6 +501,88 @@ class OpenAIChatCompletion(BaseLLM, BaseOpenAILLM): else: raise e + async def _call_agentic_completion_hooks_openai( + self, + response: Any, + model: str, + messages: List[Dict], + optional_params: Dict, + logging_obj: LiteLLMLoggingObj, + stream: bool, + litellm_params: Dict, + ) -> Optional[Any]: + """ + Call agentic completion hooks for all custom loggers (OpenAI Chat Completions API). + + 1. Call async_should_run_chat_completion_agentic_loop to check if agentic loop is needed + 2. If yes, call async_run_chat_completion_agentic_loop to execute the loop + + Returns the response from agentic loop, or None if no hook runs. + """ + from litellm._logging import verbose_logger + from litellm.integrations.custom_logger import CustomLogger + + callbacks = litellm.callbacks + ( + logging_obj.dynamic_success_callbacks or [] + ) + # Avoid logging full callback objects to prevent leaking sensitive data + verbose_logger.debug( + "LiteLLM.AgenticHooks: callbacks_count=%s", len(callbacks) + ) + tools = optional_params.get("tools", []) + # Avoid logging full tools payloads; they may contain sensitive parameters + verbose_logger.debug( + "LiteLLM.AgenticHooks: tools_count=%s", len(tools) if isinstance(tools, list) else 1 if tools else 0 + ) + # Get custom_llm_provider from litellm_params + custom_llm_provider = litellm_params.get("custom_llm_provider", "openai") + + for callback in callbacks: + try: + if isinstance(callback, CustomLogger): + # Check if the callback has the chat completion agentic loop methods + if not hasattr(callback, 'async_should_run_chat_completion_agentic_loop'): + continue + + # First: Check if agentic loop should run (using chat completion method) + should_run, tool_calls = ( + await callback.async_should_run_chat_completion_agentic_loop( + response=response, + model=model, + messages=messages, + tools=tools, + stream=stream, + custom_llm_provider=custom_llm_provider, + kwargs=litellm_params, + ) + ) + + if should_run: + # Second: Execute agentic loop + kwargs_with_provider = litellm_params.copy() if litellm_params else {} + kwargs_with_provider["custom_llm_provider"] = custom_llm_provider + + # For OpenAI Chat Completions, use the chat completion agentic loop method + agentic_response = await callback.async_run_chat_completion_agentic_loop( + tools=tool_calls, + model=model, + messages=messages, + response=response, + optional_params=optional_params, + logging_obj=logging_obj, + stream=stream, + kwargs=kwargs_with_provider, + ) + # First hook that runs agentic loop wins + return agentic_response + + except Exception as e: + verbose_logger.exception( + f"LiteLLM.AgenticHookError: Exception in agentic completion hooks for OpenAI: {str(e)}" + ) + + return None + def mock_streaming( self, response: ModelResponse, @@ -844,7 +926,6 @@ class OpenAIChatCompletion(BaseLLM, BaseOpenAILLM): logging_obj=logging_obj, ) stringified_response = response.model_dump() - logging_obj.post_call( input=data["messages"], api_key=api_key, @@ -859,6 +940,20 @@ class OpenAIChatCompletion(BaseLLM, BaseOpenAILLM): _response_headers=headers, ) + # Call agentic completion hooks (e.g., for websearch_interception) + agentic_response = await self._call_agentic_completion_hooks_openai( + response=final_response_obj, + model=model, + messages=messages, + optional_params=optional_params, + logging_obj=logging_obj, + stream=False, + litellm_params=litellm_params, + ) + + if agentic_response is not None: + final_response_obj = agentic_response + if fake_stream is True: return self.mock_streaming( response=cast(ModelResponse, final_response_obj), diff --git a/litellm/llms/openai/videos/transformation.py b/litellm/llms/openai/videos/transformation.py index 3073b22e1ca..0dd7940a92e 100644 --- a/litellm/llms/openai/videos/transformation.py +++ b/litellm/llms/openai/videos/transformation.py @@ -269,26 +269,27 @@ class OpenAIVideoConfig(BaseVideoConfig): ) -> Tuple[str, Dict]: """ Transform the video list request for OpenAI API. - + OpenAI API expects the following request: - GET /v1/videos """ # Use the api_base directly for video list url = api_base - + # Prepare query parameters params = {} if after is not None: - params["after"] = after + # Decode the wrapped video ID back to the original provider ID + params["after"] = extract_original_video_id(after) if limit is not None: params["limit"] = str(limit) if order is not None: params["order"] = order - + # Add any extra query parameters if extra_query: params.update(extra_query) - + return url, params def transform_video_list_response( @@ -296,18 +297,40 @@ class OpenAIVideoConfig(BaseVideoConfig): raw_response: httpx.Response, logging_obj: LiteLLMLoggingObj, custom_llm_provider: Optional[str] = None, - ) -> Dict[str,str]: + ) -> Dict[str, str]: response_data = raw_response.json() - + if custom_llm_provider and "data" in response_data: for video_obj in response_data.get("data", []): if isinstance(video_obj, dict) and "id" in video_obj: video_obj["id"] = encode_video_id_with_provider( - video_obj["id"], - custom_llm_provider, - video_obj.get("model") + video_obj["id"], + custom_llm_provider, + video_obj.get("model"), ) - + + # Encode pagination cursor IDs so they remain consistent + # with the wrapped data[].id format + data_list = response_data.get("data", []) + if response_data.get("first_id"): + first_model = None + if data_list and isinstance(data_list[0], dict): + first_model = data_list[0].get("model") + response_data["first_id"] = encode_video_id_with_provider( + response_data["first_id"], + custom_llm_provider, + first_model, + ) + if response_data.get("last_id"): + last_model = None + if data_list and isinstance(data_list[-1], dict): + last_model = data_list[-1].get("model") + response_data["last_id"] = encode_video_id_with_provider( + response_data["last_id"], + custom_llm_provider, + last_model, + ) + return response_data def transform_video_delete_request( diff --git a/litellm/llms/perplexity/responses/__init__.py b/litellm/llms/perplexity/responses/__init__.py new file mode 100644 index 00000000000..9bdf810e839 --- /dev/null +++ b/litellm/llms/perplexity/responses/__init__.py @@ -0,0 +1,7 @@ +""" +Perplexity Agentic Research API (Responses API) module +""" + +from .transformation import PerplexityResponsesConfig + +__all__ = ["PerplexityResponsesConfig"] diff --git a/litellm/llms/perplexity/responses/transformation.py b/litellm/llms/perplexity/responses/transformation.py new file mode 100644 index 00000000000..178e76ea970 --- /dev/null +++ b/litellm/llms/perplexity/responses/transformation.py @@ -0,0 +1,409 @@ +""" +Transformation logic for Perplexity Agentic Research API (Responses API) + +This module handles the translation between OpenAI's Responses API format +and Perplexity's Responses API format, which supports: +- Third-party model access (OpenAI, Anthropic, Google, xAI, etc.) +- Presets for optimized configurations +- Web search and URL fetching tools +- Reasoning effort control +- Instructions parameter for system-level guidance +""" + +from typing import Any, Dict, List, Optional, Union + +import httpx + +from litellm._logging import verbose_logger +from litellm.litellm_core_utils.litellm_logging import Logging as LiteLLMLoggingObj +from litellm.llms.base_llm.chat.transformation import BaseLLMException +from litellm.llms.openai.responses.transformation import OpenAIResponsesAPIConfig +from litellm.secret_managers.main import get_secret_str +from litellm.types.llms.openai import ( + ResponseAPIUsage, + ResponseInputParam, + ResponsesAPIOptionalRequestParams, + ResponsesAPIResponse, + ResponsesAPIStreamingResponse, +) +from litellm.types.router import GenericLiteLLMParams +from litellm.types.utils import LlmProviders + + +class PerplexityResponsesConfig(OpenAIResponsesAPIConfig): + """ + Configuration for Perplexity Agentic Research API (Responses API) + + + Reference: https://docs.perplexity.ai/agentic-research/quickstart + """ + + @property + def custom_llm_provider(self) -> LlmProviders: + return LlmProviders.PERPLEXITY + + def get_supported_openai_params(self, model: str) -> list: + """ + Perplexity Responses API supports a different set of parameters + + Ref: https://docs.perplexity.ai/api-reference/responses-post + """ + return [ + "max_output_tokens", + "stream", + "temperature", + "top_p", + "tools", + "reasoning", + "preset", + "instructions", + "models", # Model fallback support + ] + + def validate_environment( + self, headers: dict, model: str, litellm_params: Optional[GenericLiteLLMParams] + ) -> dict: + """Validate environment and set up headers""" + # Get API key from environment + api_key = ( + get_secret_str("PERPLEXITYAI_API_KEY") + or get_secret_str("PERPLEXITY_API_KEY") + ) + + if api_key: + headers["Authorization"] = f"Bearer {api_key}" + + headers["Content-Type"] = "application/json" + + return headers + + def get_complete_url( + self, + api_base: Optional[str], + litellm_params: dict, + ) -> str: + """Get the complete URL for the Perplexity Responses API""" + if api_base is None: + api_base = get_secret_str("PERPLEXITY_API_BASE") or "https://api.perplexity.ai" + + # Ensure api_base doesn't end with a slash + api_base = api_base.rstrip("/") + + # Add the responses endpoint + return f"{api_base}/v1/responses" + + def map_openai_params( + self, + response_api_optional_params: ResponsesAPIOptionalRequestParams, + model: str, + drop_params: bool, + ) -> Dict: + """ + Map OpenAI Responses API parameters to Perplexity format + + Key differences: + - Supports 'preset' parameter for predefined configurations + - Supports 'instructions' parameter for system-level guidance + - Tools are specified differently (web_search, fetch_url) + """ + mapped_params: Dict[str, Any] = {} + + # Map standard parameters + if response_api_optional_params.get("max_output_tokens"): + mapped_params["max_output_tokens"] = response_api_optional_params["max_output_tokens"] + + if response_api_optional_params.get("temperature"): + mapped_params["temperature"] = response_api_optional_params["temperature"] + + if response_api_optional_params.get("top_p"): + mapped_params["top_p"] = response_api_optional_params["top_p"] + + if response_api_optional_params.get("stream"): + mapped_params["stream"] = response_api_optional_params["stream"] + + if response_api_optional_params.get("stream_options"): + mapped_params["stream_options"] = response_api_optional_params["stream_options"] + + # Map Perplexity-specific parameters (using .get() with Any dict access) + preset = response_api_optional_params.get("preset") # type: ignore + if preset: + mapped_params["preset"] = preset + + instructions = response_api_optional_params.get("instructions") # type: ignore + if instructions: + mapped_params["instructions"] = instructions + + if response_api_optional_params.get("reasoning"): + mapped_params["reasoning"] = response_api_optional_params["reasoning"] + + tools = response_api_optional_params.get("tools") + if tools: + # Convert tools to list of dicts for transformation + tools_list = [dict(tool) if hasattr(tool, '__dict__') else tool for tool in tools] # type: ignore + mapped_params["tools"] = self._transform_tools(tools_list) # type: ignore + + return mapped_params + + def _transform_tools(self, tools: List[Dict[str, Any]]) -> List[Dict[str, Any]]: + """ + Transform tools to Perplexity format + + Perplexity supports: + - web_search: Performs web searches + - fetch_url: Fetches content from URLs + """ + perplexity_tools = [] + + for tool in tools: + if isinstance(tool, dict): + tool_type = tool.get("type") + + # Direct Perplexity tool format + if tool_type in ["web_search", "fetch_url"]: + perplexity_tools.append(tool) + + # OpenAI function format - try to map to Perplexity tools + elif tool_type == "function": + function = tool.get("function", {}) + function_name = function.get("name", "") + + if function_name == "web_search" or "search" in function_name.lower(): + perplexity_tools.append({"type": "web_search"}) + elif function_name == "fetch_url" or "fetch" in function_name.lower(): + perplexity_tools.append({"type": "fetch_url"}) + + return perplexity_tools + + def transform_responses_api_request( + self, + model: str, + input: Union[str, ResponseInputParam], + response_api_optional_request_params: Dict, + litellm_params: GenericLiteLLMParams, + headers: dict, + ) -> Dict: + """ + Transform request to Perplexity Responses API format + """ + # Check if the model is a preset (format: preset/preset-name) + if model.startswith("preset/"): + preset_name = model.replace("preset/", "") + data = { + "preset": preset_name, + "input": self._format_input(input), + } + # Check if preset is explicitly provided in params + elif response_api_optional_request_params.get("preset"): + data = { + "preset": response_api_optional_request_params.pop("preset"), + "input": self._format_input(input), + } + else: + # Full request format for third-party models + data = { + "model": model, + "input": self._format_input(input), + } + + # Add all optional parameters + for key, value in response_api_optional_request_params.items(): + data[key] = value + + return data + + def _format_input(self, input: Union[str, ResponseInputParam]) -> Union[str, List[Dict[str, Any]]]: + """ + Format input for Perplexity Responses API + + The API accepts either: + - A simple string for single-turn queries + - An array of message objects for multi-turn conversations + """ + if isinstance(input, str): + return input + + # Handle ResponseInputParam format + if isinstance(input, list): + formatted_messages = [] + for item in input: + if isinstance(item, dict): + formatted_message = { + "type": "message", + "role": item.get("role"), + "content": item.get("content", ""), + } + formatted_messages.append(formatted_message) + return formatted_messages + + return str(input) + + def transform_response_api_response( + self, + model: str, + raw_response: httpx.Response, + logging_obj: LiteLLMLoggingObj, + ) -> ResponsesAPIResponse: + """ + Transform Perplexity Responses API response to OpenAI Responses API format + """ + try: + raw_response_json = raw_response.json() + except Exception as e: + raise BaseLLMException( + status_code=raw_response.status_code, + message=f"Failed to parse response: {str(e)}", + ) + + # Check for error status + status = raw_response_json.get("status") + if status == "failed": + error = raw_response_json.get("error", {}) + error_message = error.get("message", "Unknown error") + raise BaseLLMException( + status_code=raw_response.status_code, + message=error_message, + ) + + # Transform usage to handle Perplexity's cost structure + usage_data = raw_response_json.get("usage", {}) + transformed_usage_dict = self._transform_usage(usage_data) + + # Convert usage dict to ResponseAPIUsage object + usage_obj = ResponseAPIUsage(**transformed_usage_dict) if transformed_usage_dict else None + + # Map Perplexity response to OpenAI Responses API format + response = ResponsesAPIResponse( + id=raw_response_json.get("id", ""), + object="response", + created_at=raw_response_json.get("created_at", 0), + status=raw_response_json.get("status", "completed"), + model=raw_response_json.get("model", model), + output=raw_response_json.get("output", []), + usage=usage_obj, + ) + + return response + + def _transform_usage(self, usage_data: Dict[str, Any]) -> Dict[str, Any]: + """ + Transform Perplexity usage data to OpenAI format + + Perplexity returns: + { + "input_tokens": 100, + "output_tokens": 200, + "total_tokens": 300, + "cost": { + "currency": "USD", + "input_cost": 0.0001, + "output_cost": 0.0002, + "total_cost": 0.0003 + } + } + + OpenAI expects: + { + "input_tokens": 100, + "output_tokens": 200, + "total_tokens": 300, + "cost": 0.0003 + } + """ + transformed = { + "input_tokens": usage_data.get("input_tokens", 0), + "output_tokens": usage_data.get("output_tokens", 0), + "total_tokens": usage_data.get("total_tokens", 0), + } + + # Transform cost from Perplexity format (dict) to OpenAI format (float) + cost_obj = usage_data.get("cost") + if isinstance(cost_obj, dict) and "total_cost" in cost_obj: + transformed["cost"] = cost_obj["total_cost"] + verbose_logger.debug( + "Transformed Perplexity cost object to float: %s -> %s", + cost_obj, + cost_obj["total_cost"] + ) + elif cost_obj is not None: + # If cost is already a float/number, use it as-is + transformed["cost"] = cost_obj + + # Add input_tokens_details if present + if "input_tokens_details" in usage_data: + transformed["input_tokens_details"] = usage_data["input_tokens_details"] + + # Add output_tokens_details if present + if "output_tokens_details" in usage_data: + transformed["output_tokens_details"] = usage_data["output_tokens_details"] + + return transformed + + def transform_streaming_response( + self, + model: str, + parsed_chunk: dict, + logging_obj: LiteLLMLoggingObj, + ) -> ResponsesAPIStreamingResponse: + """ + Transform a parsed streaming response chunk into a ResponsesAPIStreamingResponse + """ + # Get the event type from the chunk + verbose_logger.debug("Raw Perplexity Chunk=%s", parsed_chunk) + event_type = str(parsed_chunk.get("type")) + event_pydantic_model = PerplexityResponsesConfig.get_event_model_class( + event_type=event_type + ) + + # Transform Perplexity-specific fields to OpenAI format + parsed_chunk = self._transform_perplexity_chunk(parsed_chunk) + + # Defensive: Handle error.code being null (similar to OpenAI implementation) + try: + error_obj = parsed_chunk.get("error") + if isinstance(error_obj, dict) and error_obj.get("code") is None: + # Preserve other fields, but ensure `code` is a non-null string + parsed_chunk = dict(parsed_chunk) + parsed_chunk["error"] = dict(error_obj) + parsed_chunk["error"]["code"] = "unknown_error" + except Exception: + # If anything unexpected happens here, fall back to attempting + # instantiation and let higher-level handlers manage errors. + verbose_logger.debug("Failed to coalesce error.code in parsed_chunk") + + return event_pydantic_model(**parsed_chunk) + + def _transform_perplexity_chunk(self, chunk: dict) -> dict: + """ + Transform Perplexity-specific fields in a streaming chunk to OpenAI format. + + This handles: + - Converting Perplexity's cost object to a simple float + """ + # Make a copy to avoid modifying the original + chunk = dict(chunk) + + # Transform usage.cost from Perplexity format to OpenAI format + # Perplexity: {"currency": "USD", "input_cost": 0.0001, "output_cost": 0.0002, "total_cost": 0.0003} + # OpenAI: 0.0003 (just the total_cost as a float) + try: + response_obj = chunk.get("response") + if isinstance(response_obj, dict): + usage_obj = response_obj.get("usage") + if isinstance(usage_obj, dict): + cost_obj = usage_obj.get("cost") + if isinstance(cost_obj, dict) and "total_cost" in cost_obj: + # Replace the cost object with just the total_cost value + chunk = dict(chunk) + chunk["response"] = dict(response_obj) + chunk["response"]["usage"] = dict(usage_obj) + chunk["response"]["usage"]["cost"] = cost_obj["total_cost"] + verbose_logger.debug( + "Transformed Perplexity cost object to float: %s -> %s", + cost_obj, + cost_obj["total_cost"] + ) + except Exception as e: + # If transformation fails, log and continue with original chunk + verbose_logger.debug("Failed to transform Perplexity cost object: %s", e) + + return chunk diff --git a/litellm/llms/vertex_ai/common_utils.py b/litellm/llms/vertex_ai/common_utils.py index a0e2ddf5e98..02b69b94d94 100644 --- a/litellm/llms/vertex_ai/common_utils.py +++ b/litellm/llms/vertex_ai/common_utils.py @@ -1,4 +1,5 @@ import re +from copy import deepcopy from enum import Enum from typing import Any, Dict, List, Literal, Optional, Set, Tuple, Union, get_type_hints @@ -684,7 +685,7 @@ def convert_anyof_null_to_nullable(schema, depth=0): if anyof is not None: contains_null = False for atype in anyof: - if atype == {"type": "null"}: + if isinstance(atype, dict) and atype.get("type") == "null": # remove null type anyof.remove(atype) contains_null = True @@ -801,8 +802,38 @@ def _convert_schema_types(schema, depth=0): if "type" in schema: type_val = schema["type"] if isinstance(type_val, list) and len(type_val) > 1: - # Convert ["string", "number"] -> {"anyOf": [{"type": "STRING"}, {"type": "NUMBER"}]} - schema["anyOf"] = [{"type": t} for t in type_val if isinstance(t, str)] + # Convert type arrays to anyOf format + # Fields that are specific to object/array types and should move into anyOf + type_specific_fields = {"properties", "required", "additionalProperties", "items", "minItems", "maxItems", "minProperties", "maxProperties"} + + any_of: List[Dict[str, Any]] = [] + for t in type_val: + if not isinstance(t, str): + continue + if t == "null": + # Keep null entry minimal so we can strip it later. + any_of.append({"type": "null"}) + continue + + # For object/array types, include type-specific fields + if t in ("object", "array"): + item_schema = {"type": t} + # Move type-specific fields into this anyOf item + for field in type_specific_fields: + if field in schema: + item_schema[field] = deepcopy(schema[field]) + any_of.append(item_schema) + else: + # For primitive types, only include the type + any_of.append({"type": t}) + + # Remove type-specific fields from parent if we moved them into anyOf + has_object_or_array = any(t in ("object", "array") for t in type_val if isinstance(t, str)) + if has_object_or_array: + for field in type_specific_fields: + schema.pop(field, None) + + schema["anyOf"] = any_of schema.pop("type") elif isinstance(type_val, list) and len(type_val) == 1: schema["type"] = type_val[0] diff --git a/litellm/llms/vertex_ai/gemini/transformation.py b/litellm/llms/vertex_ai/gemini/transformation.py index 3004f39b973..00b461dcda0 100644 --- a/litellm/llms/vertex_ai/gemini/transformation.py +++ b/litellm/llms/vertex_ai/gemini/transformation.py @@ -437,6 +437,27 @@ def _gemini_convert_messages_with_history( # noqa: PLR0915 else: assistant_content.append(PartType(text=assistant_text)) # type: ignore + ## HANDLE ASSISTANT IMAGES FIELD + # Process images field if present (for generated images from assistant) + assistant_images = assistant_msg.get("images") + if assistant_images is not None and isinstance(assistant_images, list): + for image_item in assistant_images: + if isinstance(image_item, dict): + image_url_obj = image_item.get("image_url") + if isinstance(image_url_obj, dict): + assistant_image_url = image_url_obj.get("url") + format = image_url_obj.get("format") + detail = image_url_obj.get("detail") + media_resolution_enum = _convert_detail_to_media_resolution_enum(detail) + if assistant_image_url: + _part = _process_gemini_media( + image_url=assistant_image_url, + format=format, + media_resolution_enum=media_resolution_enum, + model=model, + ) + assistant_content.append(_part) + ## HANDLE ASSISTANT FUNCTION CALL if ( assistant_msg.get("tool_calls", []) is not None diff --git a/litellm/llms/vertex_ai/vertex_ai_partner_models/anthropic/experimental_pass_through/transformation.py b/litellm/llms/vertex_ai/vertex_ai_partner_models/anthropic/experimental_pass_through/transformation.py index 9b8ff3ecc2d..54c3f9e0474 100644 --- a/litellm/llms/vertex_ai/vertex_ai_partner_models/anthropic/experimental_pass_through/transformation.py +++ b/litellm/llms/vertex_ai/vertex_ai_partner_models/anthropic/experimental_pass_through/transformation.py @@ -7,7 +7,6 @@ from litellm.llms.anthropic.experimental_pass_through.messages.transformation im from litellm.types.llms.anthropic import ( ANTHROPIC_BETA_HEADER_VALUES, ANTHROPIC_HOSTED_TOOLS, - ANTHROPIC_PROMPT_CACHING_SCOPE_BETA_HEADER, ) from litellm.types.llms.anthropic_tool_search import get_tool_search_beta_header from litellm.types.llms.vertex_ai import VertexPartnerProvider @@ -65,10 +64,29 @@ class VertexAIPartnerModelsAnthropicMessagesConfig(AnthropicMessagesConfig, Vert existing_beta = headers.get("anthropic-beta") if existing_beta: beta_values.update(b.strip() for b in existing_beta.split(",")) - - # Use the helper to remove unsupported beta headers - self.remove_unsupported_beta(headers) - beta_values.discard(ANTHROPIC_PROMPT_CACHING_SCOPE_BETA_HEADER) + + # Check for context management + context_management_param = optional_params.get("context_management") + if context_management_param is not None: + # Check edits array for compact_20260112 type + edits = context_management_param.get("edits", []) + has_compact = False + has_other = False + + for edit in edits: + edit_type = edit.get("type", "") + if edit_type == "compact_20260112": + has_compact = True + else: + has_other = True + + # Add compact header if any compact edits exist + if has_compact: + beta_values.add(ANTHROPIC_BETA_HEADER_VALUES.COMPACT_2026_01_12.value) + + # Add context management header if any other edits exist + if has_other: + beta_values.add(ANTHROPIC_BETA_HEADER_VALUES.CONTEXT_MANAGEMENT_2025_06_27.value) # Check for web search tool for tool in tools: @@ -128,23 +146,3 @@ class VertexAIPartnerModelsAnthropicMessagesConfig(AnthropicMessagesConfig, Vert ) # do not pass output_format in request body to vertex ai - vertex ai does not support output_format as yet return anthropic_messages_request - - def remove_unsupported_beta(self, headers: dict) -> None: - """ - Helper method to remove unsupported beta headers from the beta headers. - Modifies headers in place. - """ - unsupported_beta_headers = [ - ANTHROPIC_PROMPT_CACHING_SCOPE_BETA_HEADER - ] - existing_beta = headers.get("anthropic-beta") - if existing_beta: - filtered_beta = [ - b.strip() - for b in existing_beta.split(",") - if b.strip() not in unsupported_beta_headers - ] - if filtered_beta: - headers["anthropic-beta"] = ",".join(filtered_beta) - elif "anthropic-beta" in headers: - del headers["anthropic-beta"] diff --git a/litellm/llms/vertex_ai/vertex_ai_partner_models/anthropic/transformation.py b/litellm/llms/vertex_ai/vertex_ai_partner_models/anthropic/transformation.py index 1df07f405e6..6a5b934661a 100644 --- a/litellm/llms/vertex_ai/vertex_ai_partner_models/anthropic/transformation.py +++ b/litellm/llms/vertex_ai/vertex_ai_partner_models/anthropic/transformation.py @@ -51,6 +51,42 @@ class VertexAIAnthropicConfig(AnthropicConfig): def custom_llm_provider(self) -> Optional[str]: return "vertex_ai" + def _add_context_management_beta_headers( + self, beta_set: set, context_management: dict + ) -> None: + """ + Add context_management beta headers to the beta_set. + + - If any edit has type "compact_20260112", add compact-2026-01-12 header + - For all other edits, add context-management-2025-06-27 header + + Args: + beta_set: Set of beta headers to modify in-place + context_management: The context_management dict from optional_params + """ + from litellm.types.llms.anthropic import ANTHROPIC_BETA_HEADER_VALUES + + edits = context_management.get("edits", []) + has_compact = False + has_other = False + + for edit in edits: + edit_type = edit.get("type", "") + if edit_type == "compact_20260112": + has_compact = True + else: + has_other = True + + # Add compact header if any compact edits exist + if has_compact: + beta_set.add(ANTHROPIC_BETA_HEADER_VALUES.COMPACT_2026_01_12.value) + + # Add context management header if any other edits exist + if has_other: + beta_set.add( + ANTHROPIC_BETA_HEADER_VALUES.CONTEXT_MANAGEMENT_2025_06_27.value + ) + def transform_request( self, model: str, @@ -68,10 +104,10 @@ class VertexAIAnthropicConfig(AnthropicConfig): ) data.pop("model", None) # vertex anthropic doesn't accept 'model' parameter - + # VertexAI doesn't support output_format parameter, remove it if present data.pop("output_format", None) - + tools = optional_params.get("tools") tool_search_used = self.is_tool_search_used(tools) auto_betas = self.get_anthropic_beta_list( @@ -85,11 +121,30 @@ class VertexAIAnthropicConfig(AnthropicConfig): beta_set = set(auto_betas) if tool_search_used: - beta_set.add("tool-search-tool-2025-10-19") # Vertex requires this header for tool search + beta_set.add( + "tool-search-tool-2025-10-19" + ) # Vertex requires this header for tool search + + # Add context_management beta headers (compact and/or context-management) + context_management = optional_params.get("context_management") + if context_management: + self._add_context_management_beta_headers(beta_set, context_management) + + extra_headers = optional_params.get("extra_headers") or {} + anthropic_beta_value = extra_headers.get("anthropic-beta", "") + if isinstance(anthropic_beta_value, str) and anthropic_beta_value: + for beta in anthropic_beta_value.split(","): + beta = beta.strip() + if beta: + beta_set.add(beta) + elif isinstance(anthropic_beta_value, list): + beta_set.update(anthropic_beta_value) + + data.pop("extra_headers", None) if beta_set: data["anthropic_beta"] = list(beta_set) - + return data def map_openai_params( @@ -109,7 +164,7 @@ class VertexAIAnthropicConfig(AnthropicConfig): original_model = model if "response_format" in non_default_params: model = "claude-3-sonnet-20240229" # Use a model that will use tool-based approach - + # Call parent method with potentially modified model name optional_params = super().map_openai_params( non_default_params=non_default_params, @@ -117,10 +172,10 @@ class VertexAIAnthropicConfig(AnthropicConfig): model=model, drop_params=drop_params, ) - + # Restore original model name for any other processing model = original_model - + return optional_params def transform_response( diff --git a/litellm/llms/vertex_ai/vertex_ai_partner_models/count_tokens/handler.py b/litellm/llms/vertex_ai/vertex_ai_partner_models/count_tokens/handler.py index 3842159fd7b..c6914ac3d6b 100644 --- a/litellm/llms/vertex_ai/vertex_ai_partner_models/count_tokens/handler.py +++ b/litellm/llms/vertex_ai/vertex_ai_partner_models/count_tokens/handler.py @@ -107,6 +107,11 @@ class VertexAIPartnerModelsTokenCounter(VertexBase): vertex_project = self.get_vertex_ai_project(litellm_params) vertex_location = self.get_vertex_ai_location(litellm_params) + # Map empty location/cluade models to a supported region for count-tokens endpoint + # https://docs.cloud.google.com/vertex-ai/generative-ai/docs/partner-models/claude/count-tokens + if not vertex_location or "claude" in model.lower(): + vertex_location = "us-central1" + # Get access token and resolved project ID access_token, project_id = await self._ensure_access_token_async( credentials=vertex_credentials, @@ -118,7 +123,7 @@ class VertexAIPartnerModelsTokenCounter(VertexBase): endpoint_url = self._build_count_tokens_endpoint( model=model, project_id=project_id, - vertex_location=vertex_location or "us-central1", + vertex_location=vertex_location, api_base=litellm_params.get("api_base"), ) diff --git a/litellm/model_prices_and_context_window_backup.json b/litellm/model_prices_and_context_window_backup.json index 04ad5ed0c1c..f6edcf7efd0 100644 --- a/litellm/model_prices_and_context_window_backup.json +++ b/litellm/model_prices_and_context_window_backup.json @@ -963,36 +963,6 @@ "supports_vision": true, "tool_use_system_prompt_tokens": 159 }, - "anthropic.claude-opus-4-6-v1:0": { - "cache_creation_input_token_cost": 6.25e-06, - "cache_creation_input_token_cost_above_200k_tokens": 1.25e-05, - "cache_read_input_token_cost": 5e-07, - "cache_read_input_token_cost_above_200k_tokens": 1e-06, - "input_cost_per_token": 5e-06, - "input_cost_per_token_above_200k_tokens": 1e-05, - "litellm_provider": "bedrock_converse", - "max_input_tokens": 1000000, - "max_output_tokens": 128000, - "max_tokens": 128000, - "mode": "chat", - "output_cost_per_token": 2.5e-05, - "output_cost_per_token_above_200k_tokens": 3.75e-05, - "search_context_cost_per_query": { - "search_context_size_high": 0.01, - "search_context_size_low": 0.01, - "search_context_size_medium": 0.01 - }, - "supports_assistant_prefill": false, - "supports_computer_use": true, - "supports_function_calling": true, - "supports_pdf_input": true, - "supports_prompt_caching": true, - "supports_reasoning": true, - "supports_response_schema": true, - "supports_tool_choice": true, - "supports_vision": true, - "tool_use_system_prompt_tokens": 346 - }, "anthropic.claude-opus-4-6-v1": { "cache_creation_input_token_cost": 6.25e-06, "cache_creation_input_token_cost_above_200k_tokens": 1.25e-05, @@ -1023,36 +993,6 @@ "supports_vision": true, "tool_use_system_prompt_tokens": 346 }, - "global.anthropic.claude-opus-4-6-v1:0": { - "cache_creation_input_token_cost": 6.25e-06, - "cache_creation_input_token_cost_above_200k_tokens": 1.25e-05, - "cache_read_input_token_cost": 5e-07, - "cache_read_input_token_cost_above_200k_tokens": 1e-06, - "input_cost_per_token": 5e-06, - "input_cost_per_token_above_200k_tokens": 1e-05, - "litellm_provider": "bedrock_converse", - "max_input_tokens": 1000000, - "max_output_tokens": 128000, - "max_tokens": 128000, - "mode": "chat", - "output_cost_per_token": 2.5e-05, - "output_cost_per_token_above_200k_tokens": 3.75e-05, - "search_context_cost_per_query": { - "search_context_size_high": 0.01, - "search_context_size_low": 0.01, - "search_context_size_medium": 0.01 - }, - "supports_assistant_prefill": false, - "supports_computer_use": true, - "supports_function_calling": true, - "supports_pdf_input": true, - "supports_prompt_caching": true, - "supports_reasoning": true, - "supports_response_schema": true, - "supports_tool_choice": true, - "supports_vision": true, - "tool_use_system_prompt_tokens": 346 - }, "global.anthropic.claude-opus-4-6-v1": { "cache_creation_input_token_cost": 6.25e-06, "cache_creation_input_token_cost_above_200k_tokens": 1.25e-05, @@ -1083,36 +1023,6 @@ "supports_vision": true, "tool_use_system_prompt_tokens": 346 }, - "us.anthropic.claude-opus-4-6-v1:0": { - "cache_creation_input_token_cost": 6.875e-06, - "cache_creation_input_token_cost_above_200k_tokens": 1.375e-05, - "cache_read_input_token_cost": 5.5e-07, - "cache_read_input_token_cost_above_200k_tokens": 1.1e-06, - "input_cost_per_token": 5.5e-06, - "input_cost_per_token_above_200k_tokens": 1.1e-05, - "litellm_provider": "bedrock_converse", - "max_input_tokens": 1000000, - "max_output_tokens": 128000, - "max_tokens": 128000, - "mode": "chat", - "output_cost_per_token": 2.75e-05, - "output_cost_per_token_above_200k_tokens": 4.125e-05, - "search_context_cost_per_query": { - "search_context_size_high": 0.01, - "search_context_size_low": 0.01, - "search_context_size_medium": 0.01 - }, - "supports_assistant_prefill": false, - "supports_computer_use": true, - "supports_function_calling": true, - "supports_pdf_input": true, - "supports_prompt_caching": true, - "supports_reasoning": true, - "supports_response_schema": true, - "supports_tool_choice": true, - "supports_vision": true, - "tool_use_system_prompt_tokens": 346 - }, "us.anthropic.claude-opus-4-6-v1": { "cache_creation_input_token_cost": 6.875e-06, "cache_creation_input_token_cost_above_200k_tokens": 1.375e-05, @@ -1143,36 +1053,6 @@ "supports_vision": true, "tool_use_system_prompt_tokens": 346 }, - "eu.anthropic.claude-opus-4-6-v1:0": { - "cache_creation_input_token_cost": 6.875e-06, - "cache_creation_input_token_cost_above_200k_tokens": 1.375e-05, - "cache_read_input_token_cost": 5.5e-07, - "cache_read_input_token_cost_above_200k_tokens": 1.1e-06, - "input_cost_per_token": 5.5e-06, - "input_cost_per_token_above_200k_tokens": 1.1e-05, - "litellm_provider": "bedrock_converse", - "max_input_tokens": 1000000, - "max_output_tokens": 128000, - "max_tokens": 128000, - "mode": "chat", - "output_cost_per_token": 2.75e-05, - "output_cost_per_token_above_200k_tokens": 4.125e-05, - "search_context_cost_per_query": { - "search_context_size_high": 0.01, - "search_context_size_low": 0.01, - "search_context_size_medium": 0.01 - }, - "supports_assistant_prefill": false, - "supports_computer_use": true, - "supports_function_calling": true, - "supports_pdf_input": true, - "supports_prompt_caching": true, - "supports_reasoning": true, - "supports_response_schema": true, - "supports_tool_choice": true, - "supports_vision": true, - "tool_use_system_prompt_tokens": 346 - }, "eu.anthropic.claude-opus-4-6-v1": { "cache_creation_input_token_cost": 6.875e-06, "cache_creation_input_token_cost_above_200k_tokens": 1.375e-05, @@ -1203,36 +1083,6 @@ "supports_vision": true, "tool_use_system_prompt_tokens": 346 }, - "apac.anthropic.claude-opus-4-6-v1:0": { - "cache_creation_input_token_cost": 6.875e-06, - "cache_creation_input_token_cost_above_200k_tokens": 1.375e-05, - "cache_read_input_token_cost": 5.5e-07, - "cache_read_input_token_cost_above_200k_tokens": 1.1e-06, - "input_cost_per_token": 5.5e-06, - "input_cost_per_token_above_200k_tokens": 1.1e-05, - "litellm_provider": "bedrock_converse", - "max_input_tokens": 1000000, - "max_output_tokens": 128000, - "max_tokens": 128000, - "mode": "chat", - "output_cost_per_token": 2.75e-05, - "output_cost_per_token_above_200k_tokens": 4.125e-05, - "search_context_cost_per_query": { - "search_context_size_high": 0.01, - "search_context_size_low": 0.01, - "search_context_size_medium": 0.01 - }, - "supports_assistant_prefill": false, - "supports_computer_use": true, - "supports_function_calling": true, - "supports_pdf_input": true, - "supports_prompt_caching": true, - "supports_reasoning": true, - "supports_response_schema": true, - "supports_tool_choice": true, - "supports_vision": true, - "tool_use_system_prompt_tokens": 346 - }, "apac.anthropic.claude-opus-4-6-v1": { "cache_creation_input_token_cost": 6.875e-06, "cache_creation_input_token_cost_above_200k_tokens": 1.375e-05, @@ -3494,29 +3344,6 @@ "supports_tool_choice": true, "supports_vision": true }, - "azure/gpt-5-search-api": { - "cache_read_input_token_cost": 1.25e-07, - "input_cost_per_token": 1.25e-06, - "litellm_provider": "azure", - "max_input_tokens": 128000, - "max_output_tokens": 4096, - "max_tokens": 4096, - "mode": "chat", - "output_cost_per_token": 1e-05, - "search_context_cost_per_query": { - "search_context_size_high": 0.05, - "search_context_size_low": 0.03, - "search_context_size_medium": 0.035 - }, - "supports_function_calling": true, - "supports_parallel_function_calling": true, - "supports_prompt_caching": true, - "supports_response_schema": true, - "supports_system_messages": true, - "supports_tool_choice": true, - "supports_vision": true, - "supports_web_search": true - }, "azure/gpt-5-2025-08-07": { "cache_read_input_token_cost": 1.25e-07, "input_cost_per_token": 1.25e-06, @@ -6021,6 +5848,19 @@ "output_cost_per_token": 7e-07, "supports_tool_choice": true }, + "azure_ai/kimi-k2.5": { + "input_cost_per_token": 6e-07, + "litellm_provider": "azure_ai", + "max_input_tokens": 262144, + "max_output_tokens": 262144, + "max_tokens": 262144, + "mode": "chat", + "output_cost_per_token": 3e-06, + "source": "https://techcommunity.microsoft.com/blog/azure-ai-foundry-blog/kimi-k2-5-now-in-microsoft-foundry/4492321", + "supports_function_calling": true, + "supports_tool_choice": true, + "supports_vision": true + }, "azure_ai/ministral-3b": { "input_cost_per_token": 4e-08, "litellm_provider": "azure_ai", @@ -6264,6 +6104,39 @@ "output_cost_per_token": 2.4e-05, "supports_tool_choice": true }, + "bedrock/ap-northeast-1/moonshotai.kimi-k2-thinking": { + "input_cost_per_token": 7.3e-07, + "litellm_provider": "bedrock", + "max_input_tokens": 262144, + "max_output_tokens": 262144, + "max_tokens": 262144, + "mode": "chat", + "output_cost_per_token": 3.03e-06, + "supports_function_calling": true, + "supports_reasoning": true + }, + "bedrock/moonshotai.kimi-k2-thinking": { + "input_cost_per_token": 7.3e-07, + "litellm_provider": "bedrock", + "max_input_tokens": 262144, + "max_output_tokens": 262144, + "max_tokens": 262144, + "mode": "chat", + "output_cost_per_token": 3.03e-06, + "supports_function_calling": true, + "supports_reasoning": true + }, + "bedrock/moonshotai.kimi-k2.5": { + "input_cost_per_token": 7.3e-07, + "litellm_provider": "bedrock", + "max_input_tokens": 262144, + "max_output_tokens": 262144, + "max_tokens": 262144, + "mode": "chat", + "output_cost_per_token": 3.03e-06, + "supports_function_calling": true, + "supports_reasoning": true + }, "bedrock/ap-south-1/meta.llama3-70b-instruct-v1:0": { "input_cost_per_token": 3.18e-06, "litellm_provider": "bedrock", @@ -6282,6 +6155,17 @@ "mode": "chat", "output_cost_per_token": 7.2e-07 }, + "bedrock/ap-south-1/moonshotai.kimi-k2-thinking": { + "input_cost_per_token": 7.1e-07, + "litellm_provider": "bedrock", + "max_input_tokens": 262144, + "max_output_tokens": 262144, + "max_tokens": 262144, + "mode": "chat", + "output_cost_per_token": 2.94e-06, + "supports_function_calling": true, + "supports_reasoning": true + }, "bedrock/ca-central-1/meta.llama3-70b-instruct-v1:0": { "input_cost_per_token": 3.05e-06, "litellm_provider": "bedrock", @@ -6487,6 +6371,17 @@ "mode": "chat", "output_cost_per_token": 1.01e-06 }, + "bedrock/sa-east-1/moonshotai.kimi-k2-thinking": { + "input_cost_per_token": 7.3e-07, + "litellm_provider": "bedrock", + "max_input_tokens": 262144, + "max_output_tokens": 262144, + "max_tokens": 262144, + "mode": "chat", + "output_cost_per_token": 3.03e-06, + "supports_function_calling": true, + "supports_reasoning": true + }, "bedrock/us-east-1/1-month-commitment/anthropic.claude-instant-v1": { "input_cost_per_second": 0.011, "litellm_provider": "bedrock", @@ -6623,6 +6518,28 @@ "output_cost_per_token": 7e-07, "supports_tool_choice": true }, + "bedrock/us-east-1/moonshotai.kimi-k2-thinking": { + "input_cost_per_token": 6e-07, + "litellm_provider": "bedrock", + "max_input_tokens": 262144, + "max_output_tokens": 262144, + "max_tokens": 262144, + "mode": "chat", + "output_cost_per_token": 2.5e-06, + "supports_function_calling": true, + "supports_reasoning": true + }, + "bedrock/us-east-2/moonshotai.kimi-k2-thinking": { + "input_cost_per_token": 6e-07, + "litellm_provider": "bedrock", + "max_input_tokens": 262144, + "max_output_tokens": 262144, + "max_tokens": 262144, + "mode": "chat", + "output_cost_per_token": 2.5e-06, + "supports_function_calling": true, + "supports_reasoning": true + }, "bedrock/us-gov-east-1/amazon.nova-pro-v1:0": { "input_cost_per_token": 9.6e-07, "litellm_provider": "bedrock", @@ -7029,6 +6946,17 @@ "output_cost_per_token": 7e-07, "supports_tool_choice": true }, + "bedrock/us-west-2/moonshotai.kimi-k2-thinking": { + "input_cost_per_token": 6e-07, + "litellm_provider": "bedrock", + "max_input_tokens": 262144, + "max_output_tokens": 262144, + "max_tokens": 262144, + "mode": "chat", + "output_cost_per_token": 2.5e-06, + "supports_function_calling": true, + "supports_reasoning": true + }, "bedrock/us.anthropic.claude-3-5-haiku-20241022-v1:0": { "cache_creation_input_token_cost": 1e-06, "cache_read_input_token_cost": 8e-08, @@ -7836,6 +7764,99 @@ "supports_vision": true, "tool_use_system_prompt_tokens": 346 }, + "fast/claude-opus-4-6": { + "cache_creation_input_token_cost": 6.25e-06, + "cache_creation_input_token_cost_above_200k_tokens": 1.25e-05, + "cache_creation_input_token_cost_above_1hr": 1e-05, + "cache_read_input_token_cost": 5e-07, + "cache_read_input_token_cost_above_200k_tokens": 1e-06, + "input_cost_per_token": 3e-05, + "input_cost_per_token_above_200k_tokens": 1e-05, + "litellm_provider": "anthropic", + "max_input_tokens": 1000000, + "max_output_tokens": 128000, + "max_tokens": 128000, + "mode": "chat", + "output_cost_per_token": 0.00015, + "output_cost_per_token_above_200k_tokens": 3.75e-05, + "search_context_cost_per_query": { + "search_context_size_high": 0.01, + "search_context_size_low": 0.01, + "search_context_size_medium": 0.01 + }, + "supports_assistant_prefill": false, + "supports_computer_use": true, + "supports_function_calling": true, + "supports_pdf_input": true, + "supports_prompt_caching": true, + "supports_reasoning": true, + "supports_response_schema": true, + "supports_tool_choice": true, + "supports_vision": true, + "tool_use_system_prompt_tokens": 346 + }, + "us/claude-opus-4-6": { + "cache_creation_input_token_cost": 6.875e-06, + "cache_creation_input_token_cost_above_200k_tokens": 1.375e-05, + "cache_creation_input_token_cost_above_1hr": 1.1e-05, + "cache_read_input_token_cost": 5.5e-07, + "cache_read_input_token_cost_above_200k_tokens": 1.1e-06, + "input_cost_per_token": 5.5e-06, + "input_cost_per_token_above_200k_tokens": 1.1e-05, + "litellm_provider": "anthropic", + "max_input_tokens": 200000, + "max_output_tokens": 128000, + "max_tokens": 128000, + "mode": "chat", + "output_cost_per_token": 2.75e-05, + "output_cost_per_token_above_200k_tokens": 4.125e-05, + "search_context_cost_per_query": { + "search_context_size_high": 0.01, + "search_context_size_low": 0.01, + "search_context_size_medium": 0.01 + }, + "supports_assistant_prefill": false, + "supports_computer_use": true, + "supports_function_calling": true, + "supports_pdf_input": true, + "supports_prompt_caching": true, + "supports_reasoning": true, + "supports_response_schema": true, + "supports_tool_choice": true, + "supports_vision": true, + "tool_use_system_prompt_tokens": 346 + }, + "fast/us/claude-opus-4-6": { + "cache_creation_input_token_cost": 6.875e-06, + "cache_creation_input_token_cost_above_200k_tokens": 1.375e-05, + "cache_creation_input_token_cost_above_1hr": 1.1e-05, + "cache_read_input_token_cost": 5.5e-07, + "cache_read_input_token_cost_above_200k_tokens": 1.1e-06, + "input_cost_per_token": 3e-05, + "input_cost_per_token_above_200k_tokens": 1.1e-05, + "litellm_provider": "anthropic", + "max_input_tokens": 200000, + "max_output_tokens": 128000, + "max_tokens": 128000, + "mode": "chat", + "output_cost_per_token": 0.00015, + "output_cost_per_token_above_200k_tokens": 4.125e-05, + "search_context_cost_per_query": { + "search_context_size_high": 0.01, + "search_context_size_low": 0.01, + "search_context_size_medium": 0.01 + }, + "supports_assistant_prefill": false, + "supports_computer_use": true, + "supports_function_calling": true, + "supports_pdf_input": true, + "supports_prompt_caching": true, + "supports_reasoning": true, + "supports_response_schema": true, + "supports_tool_choice": true, + "supports_vision": true, + "tool_use_system_prompt_tokens": 346 + }, "claude-opus-4-6-20260205": { "cache_creation_input_token_cost": 6.25e-06, "cache_creation_input_token_cost_above_200k_tokens": 1.25e-05, @@ -7867,6 +7888,68 @@ "supports_vision": true, "tool_use_system_prompt_tokens": 346 }, + "fast/claude-opus-4-6-20260205": { + "cache_creation_input_token_cost": 6.25e-06, + "cache_creation_input_token_cost_above_200k_tokens": 1.25e-05, + "cache_creation_input_token_cost_above_1hr": 1e-05, + "cache_read_input_token_cost": 5e-07, + "cache_read_input_token_cost_above_200k_tokens": 1e-06, + "input_cost_per_token": 3e-05, + "input_cost_per_token_above_200k_tokens": 1e-05, + "litellm_provider": "anthropic", + "max_input_tokens": 1000000, + "max_output_tokens": 128000, + "max_tokens": 128000, + "mode": "chat", + "output_cost_per_token": 0.00015, + "output_cost_per_token_above_200k_tokens": 3.75e-05, + "search_context_cost_per_query": { + "search_context_size_high": 0.01, + "search_context_size_low": 0.01, + "search_context_size_medium": 0.01 + }, + "supports_assistant_prefill": false, + "supports_computer_use": true, + "supports_function_calling": true, + "supports_pdf_input": true, + "supports_prompt_caching": true, + "supports_reasoning": true, + "supports_response_schema": true, + "supports_tool_choice": true, + "supports_vision": true, + "tool_use_system_prompt_tokens": 346 + }, + "us/claude-opus-4-6-20260205": { + "cache_creation_input_token_cost": 6.875e-06, + "cache_creation_input_token_cost_above_200k_tokens": 1.375e-05, + "cache_creation_input_token_cost_above_1hr": 1.1e-05, + "cache_read_input_token_cost": 5.5e-07, + "cache_read_input_token_cost_above_200k_tokens": 1.1e-06, + "input_cost_per_token": 5.5e-06, + "input_cost_per_token_above_200k_tokens": 1.1e-05, + "litellm_provider": "anthropic", + "max_input_tokens": 200000, + "max_output_tokens": 128000, + "max_tokens": 128000, + "mode": "chat", + "output_cost_per_token": 2.75e-05, + "output_cost_per_token_above_200k_tokens": 4.125e-05, + "search_context_cost_per_query": { + "search_context_size_high": 0.01, + "search_context_size_low": 0.01, + "search_context_size_medium": 0.01 + }, + "supports_assistant_prefill": false, + "supports_computer_use": true, + "supports_function_calling": true, + "supports_pdf_input": true, + "supports_prompt_caching": true, + "supports_reasoning": true, + "supports_response_schema": true, + "supports_tool_choice": true, + "supports_vision": true, + "tool_use_system_prompt_tokens": 346 + }, "claude-sonnet-4-20250514": { "deprecation_date": "2026-05-14", "cache_creation_input_token_cost": 3.75e-06, @@ -8963,6 +9046,43 @@ } ] }, + "dashscope/qwen3-max": { + "litellm_provider": "dashscope", + "max_input_tokens": 258048, + "max_output_tokens": 65536, + "max_tokens": 65536, + "mode": "chat", + "source": "https://www.alibabacloud.com/help/en/model-studio/models", + "supports_function_calling": true, + "supports_reasoning": true, + "supports_tool_choice": true, + "tiered_pricing": [ + { + "input_cost_per_token": 1.2e-06, + "output_cost_per_token": 6e-06, + "range": [ + 0, + 32000.0 + ] + }, + { + "input_cost_per_token": 2.4e-06, + "output_cost_per_token": 1.2e-05, + "range": [ + 32000.0, + 128000.0 + ] + }, + { + "input_cost_per_token": 3e-06, + "output_cost_per_token": 1.5e-05, + "range": [ + 128000.0, + 252000.0 + ] + } + ] + }, "dashscope/qwq-plus": { "input_cost_per_token": 8e-07, "litellm_provider": "dashscope", @@ -10636,14 +10756,22 @@ "input_cost_per_token": 2.8e-07, "input_cost_per_token_cache_hit": 2.8e-08, "litellm_provider": "deepseek", - "max_input_tokens": 128000, + "max_input_tokens": 131072, "max_output_tokens": 8192, "max_tokens": 8192, "mode": "chat", "output_cost_per_token": 4.2e-07, + "source": "https://api-docs.deepseek.com/quick_start/pricing", + "supported_endpoints": [ + "/v1/chat/completions" + ], "supports_assistant_prefill": true, "supports_function_calling": true, + "supports_native_streaming": true, + "supports_parallel_function_calling": true, "supports_prompt_caching": true, + "supports_response_schema": true, + "supports_system_messages": true, "supports_tool_choice": true }, "deepseek/deepseek-coder": { @@ -10680,16 +10808,24 @@ "input_cost_per_token": 2.8e-07, "input_cost_per_token_cache_hit": 2.8e-08, "litellm_provider": "deepseek", - "max_input_tokens": 128000, - "max_output_tokens": 8192, - "max_tokens": 8192, + "max_input_tokens": 131072, + "max_output_tokens": 65536, + "max_tokens": 65536, "mode": "chat", "output_cost_per_token": 4.2e-07, + "source": "https://api-docs.deepseek.com/quick_start/pricing", + "supported_endpoints": [ + "/v1/chat/completions" + ], "supports_assistant_prefill": true, - "supports_function_calling": true, + "supports_function_calling": false, + "supports_native_streaming": true, + "supports_parallel_function_calling": false, "supports_prompt_caching": true, "supports_reasoning": true, - "supports_tool_choice": true + "supports_response_schema": true, + "supports_system_messages": true, + "supports_tool_choice": false }, "deepseek/deepseek-v3": { "cache_creation_input_token_cost": 0.0, @@ -18758,29 +18894,6 @@ "supports_service_tier": true, "supports_vision": true }, - "gpt-5-search-api": { - "cache_read_input_token_cost": 1.25e-07, - "input_cost_per_token": 1.25e-06, - "litellm_provider": "openai", - "max_input_tokens": 128000, - "max_output_tokens": 4096, - "max_tokens": 4096, - "mode": "chat", - "output_cost_per_token": 1e-05, - "search_context_cost_per_query": { - "search_context_size_high": 0.05, - "search_context_size_low": 0.03, - "search_context_size_medium": 0.035 - }, - "supports_function_calling": true, - "supports_parallel_function_calling": true, - "supports_prompt_caching": true, - "supports_response_schema": true, - "supports_system_messages": true, - "supports_tool_choice": true, - "supports_vision": true, - "supports_web_search": true - }, "gpt-5.1": { "cache_read_input_token_cost": 1.25e-07, "cache_read_input_token_cost_priority": 2.5e-07, @@ -25655,6 +25768,66 @@ "supports_function_calling": true, "supports_tool_choice": true }, + "perplexity/preset/pro-search": { + "litellm_provider": "perplexity", + "mode": "responses", + "supports_web_search": true, + "supports_preset": true + }, + "perplexity/openai/gpt-4o": { + "litellm_provider": "perplexity", + "mode": "responses", + "supports_web_search": true, + "supports_reasoning": false + }, + "perplexity/openai/gpt-4o-mini": { + "litellm_provider": "perplexity", + "mode": "responses", + "supports_web_search": true, + "supports_reasoning": false + }, + "perplexity/openai/gpt-5.2": { + "litellm_provider": "perplexity", + "mode": "responses", + "supports_web_search": true, + "supports_reasoning": true + }, + "perplexity/anthropic/claude-3-5-sonnet-20241022": { + "litellm_provider": "perplexity", + "mode": "responses", + "supports_web_search": true, + "supports_reasoning": false + }, + "perplexity/anthropic/claude-3-5-haiku-20241022": { + "litellm_provider": "perplexity", + "mode": "responses", + "supports_web_search": true, + "supports_reasoning": false + }, + "perplexity/google/gemini-2.0-flash-exp": { + "litellm_provider": "perplexity", + "mode": "responses", + "supports_web_search": true, + "supports_reasoning": false + }, + "perplexity/google/gemini-2.0-flash-thinking-exp": { + "litellm_provider": "perplexity", + "mode": "responses", + "supports_web_search": true, + "supports_reasoning": true + }, + "perplexity/xai/grok-2-1212": { + "litellm_provider": "perplexity", + "mode": "responses", + "supports_web_search": true, + "supports_reasoning": false + }, + "perplexity/xai/grok-2-vision-1212": { + "litellm_provider": "perplexity", + "mode": "responses", + "supports_web_search": true, + "supports_reasoning": false + }, "publicai/aisingapore/Qwen-SEA-LION-v4-32B-IT": { "input_cost_per_token": 0.0, "litellm_provider": "publicai", @@ -28581,6 +28754,193 @@ "supports_function_calling": true, "supports_tool_choice": true }, + "vercel_ai_gateway/anthropic/claude-3-5-sonnet": { + "cache_creation_input_token_cost": 3.75e-06, + "cache_read_input_token_cost": 3e-07, + "input_cost_per_token": 3e-06, + "litellm_provider": "vercel_ai_gateway", + "max_input_tokens": 200000, + "max_output_tokens": 8192, + "max_tokens": 8192, + "mode": "chat", + "output_cost_per_token": 1.5e-05, + "supports_assistant_prefill": true, + "supports_computer_use": true, + "supports_function_calling": true, + "supports_prompt_caching": true, + "supports_response_schema": true, + "supports_tool_choice": true, + "supports_vision": true + }, + "vercel_ai_gateway/anthropic/claude-3-5-sonnet-20241022": { + "cache_creation_input_token_cost": 3.75e-06, + "cache_read_input_token_cost": 3e-07, + "input_cost_per_token": 3e-06, + "litellm_provider": "vercel_ai_gateway", + "max_input_tokens": 200000, + "max_output_tokens": 8192, + "max_tokens": 8192, + "mode": "chat", + "output_cost_per_token": 1.5e-05, + "supports_assistant_prefill": true, + "supports_computer_use": true, + "supports_function_calling": true, + "supports_prompt_caching": true, + "supports_response_schema": true, + "supports_tool_choice": true, + "supports_vision": true + }, + "vercel_ai_gateway/anthropic/claude-3-7-sonnet": { + "cache_creation_input_token_cost": 3.75e-06, + "cache_read_input_token_cost": 3e-07, + "input_cost_per_token": 3e-06, + "litellm_provider": "vercel_ai_gateway", + "max_input_tokens": 200000, + "max_output_tokens": 64000, + "max_tokens": 64000, + "mode": "chat", + "output_cost_per_token": 1.5e-05, + "supports_assistant_prefill": true, + "supports_computer_use": true, + "supports_function_calling": true, + "supports_prompt_caching": true, + "supports_reasoning": true, + "supports_response_schema": true, + "supports_tool_choice": true, + "supports_vision": true + }, + "vercel_ai_gateway/anthropic/claude-haiku-4.5": { + "cache_creation_input_token_cost": 1.25e-06, + "cache_read_input_token_cost": 1e-07, + "input_cost_per_token": 1e-06, + "litellm_provider": "vercel_ai_gateway", + "max_input_tokens": 200000, + "max_output_tokens": 64000, + "max_tokens": 64000, + "mode": "chat", + "output_cost_per_token": 5e-06, + "supports_assistant_prefill": true, + "supports_computer_use": true, + "supports_function_calling": true, + "supports_prompt_caching": true, + "supports_reasoning": true, + "supports_response_schema": true, + "supports_tool_choice": true, + "supports_vision": true + }, + "vercel_ai_gateway/anthropic/claude-opus-4": { + "cache_creation_input_token_cost": 1.875e-05, + "cache_read_input_token_cost": 1.5e-06, + "input_cost_per_token": 1.5e-05, + "litellm_provider": "vercel_ai_gateway", + "max_input_tokens": 200000, + "max_output_tokens": 32000, + "max_tokens": 32000, + "mode": "chat", + "output_cost_per_token": 7.5e-05, + "supports_assistant_prefill": true, + "supports_computer_use": true, + "supports_function_calling": true, + "supports_prompt_caching": true, + "supports_reasoning": true, + "supports_response_schema": true, + "supports_tool_choice": true, + "supports_vision": true + }, + "vercel_ai_gateway/anthropic/claude-opus-4.1": { + "cache_creation_input_token_cost": 1.875e-05, + "cache_read_input_token_cost": 1.5e-06, + "input_cost_per_token": 1.5e-05, + "litellm_provider": "vercel_ai_gateway", + "max_input_tokens": 200000, + "max_output_tokens": 32000, + "max_tokens": 32000, + "mode": "chat", + "output_cost_per_token": 7.5e-05, + "supports_assistant_prefill": true, + "supports_computer_use": true, + "supports_function_calling": true, + "supports_prompt_caching": true, + "supports_reasoning": true, + "supports_response_schema": true, + "supports_tool_choice": true, + "supports_vision": true + }, + "vercel_ai_gateway/anthropic/claude-opus-4.5": { + "cache_creation_input_token_cost": 6.25e-06, + "cache_read_input_token_cost": 5e-07, + "input_cost_per_token": 5e-06, + "litellm_provider": "vercel_ai_gateway", + "max_input_tokens": 200000, + "max_output_tokens": 64000, + "max_tokens": 64000, + "mode": "chat", + "output_cost_per_token": 2.5e-05, + "supports_assistant_prefill": true, + "supports_computer_use": true, + "supports_function_calling": true, + "supports_prompt_caching": true, + "supports_reasoning": true, + "supports_response_schema": true, + "supports_tool_choice": true, + "supports_vision": true + }, + "vercel_ai_gateway/anthropic/claude-opus-4.6": { + "cache_creation_input_token_cost": 6.25e-06, + "cache_read_input_token_cost": 5e-07, + "input_cost_per_token": 5e-06, + "litellm_provider": "vercel_ai_gateway", + "max_input_tokens": 200000, + "max_output_tokens": 64000, + "max_tokens": 64000, + "mode": "chat", + "output_cost_per_token": 2.5e-05, + "supports_assistant_prefill": true, + "supports_computer_use": true, + "supports_function_calling": true, + "supports_prompt_caching": true, + "supports_reasoning": true, + "supports_response_schema": true, + "supports_tool_choice": true, + "supports_vision": true + }, + "vercel_ai_gateway/anthropic/claude-sonnet-4": { + "cache_creation_input_token_cost": 3.75e-06, + "cache_read_input_token_cost": 3e-07, + "input_cost_per_token": 3e-06, + "litellm_provider": "vercel_ai_gateway", + "max_input_tokens": 200000, + "max_output_tokens": 64000, + "max_tokens": 64000, + "mode": "chat", + "output_cost_per_token": 1.5e-05, + "supports_assistant_prefill": true, + "supports_computer_use": true, + "supports_function_calling": true, + "supports_prompt_caching": true, + "supports_reasoning": true, + "supports_response_schema": true, + "supports_tool_choice": true, + "supports_vision": true + }, + "vercel_ai_gateway/anthropic/claude-sonnet-4.5": { + "cache_creation_input_token_cost": 3.75e-06, + "cache_read_input_token_cost": 3e-07, + "input_cost_per_token": 3e-06, + "litellm_provider": "vercel_ai_gateway", + "max_input_tokens": 1000000, + "max_output_tokens": 64000, + "max_tokens": 64000, + "mode": "chat", + "output_cost_per_token": 1.5e-05, + "supports_assistant_prefill": true, + "supports_computer_use": true, + "supports_function_calling": true, + "supports_prompt_caching": true, + "supports_reasoning": true, + "supports_tool_choice": true, + "supports_vision": true + }, "vercel_ai_gateway/cohere/command-a": { "input_cost_per_token": 2.5e-06, "litellm_provider": "vercel_ai_gateway", @@ -28590,7 +28950,8 @@ "mode": "chat", "output_cost_per_token": 1e-05, "supports_function_calling": true, - "supports_tool_choice": true + "supports_tool_choice": true, + "supports_response_schema": true }, "vercel_ai_gateway/cohere/command-r": { "input_cost_per_token": 1.5e-07, diff --git a/litellm/proxy/_experimental/mcp_server/auth/litellm_auth_handler.py b/litellm/proxy/_experimental/mcp_server/auth/litellm_auth_handler.py index 081d83dd1c8..75b75d3ba44 100644 --- a/litellm/proxy/_experimental/mcp_server/auth/litellm_auth_handler.py +++ b/litellm/proxy/_experimental/mcp_server/auth/litellm_auth_handler.py @@ -27,6 +27,7 @@ class MCPAuthenticatedUser(AuthenticatedUser): oauth2_headers: Optional[Dict[str, str]] = None, mcp_protocol_version: Optional[str] = None, raw_headers: Optional[Dict[str, str]] = None, + client_ip: Optional[str] = None, ): self.user_api_key_auth = user_api_key_auth self.mcp_auth_header = mcp_auth_header @@ -35,3 +36,4 @@ class MCPAuthenticatedUser(AuthenticatedUser): self.mcp_protocol_version = mcp_protocol_version self.oauth2_headers = oauth2_headers self.raw_headers = raw_headers + self.client_ip = client_ip diff --git a/litellm/proxy/_experimental/mcp_server/auth/user_api_key_auth_mcp.py b/litellm/proxy/_experimental/mcp_server/auth/user_api_key_auth_mcp.py index 7e70b5baae4..548e3bc3dbf 100644 --- a/litellm/proxy/_experimental/mcp_server/auth/user_api_key_auth_mcp.py +++ b/litellm/proxy/_experimental/mcp_server/auth/user_api_key_auth_mcp.py @@ -1,11 +1,17 @@ from typing import Dict, List, Optional, Set, Tuple +from fastapi import HTTPException from starlette.datastructures import Headers from starlette.requests import Request from starlette.types import Scope from litellm._logging import verbose_logger -from litellm.proxy._types import LiteLLM_TeamTable, SpecialHeaders, UserAPIKeyAuth +from litellm.proxy._types import ( + LiteLLM_TeamTable, + ProxyException, + SpecialHeaders, + UserAPIKeyAuth, +) from litellm.proxy.auth.user_api_key_auth import user_api_key_auth @@ -63,6 +69,13 @@ class MCPRequestHandler: HTTPException: If headers are invalid or missing required headers """ headers = MCPRequestHandler._safe_get_headers_from_scope(scope) + + # Check if there is an explicit LiteLLM API key (primary header) + has_explicit_litellm_key = ( + headers.get(MCPRequestHandler.LITELLM_API_KEY_HEADER_NAME_PRIMARY) + is not None + ) + litellm_api_key = ( MCPRequestHandler.get_litellm_api_key_from_headers(headers) or "" ) @@ -106,16 +119,38 @@ class MCPRequestHandler: request.body = mock_body # type: ignore if ".well-known" in str(request.url): # public routes validated_user_api_key_auth = UserAPIKeyAuth() - # elif litellm_api_key == "": - # from fastapi import HTTPException - - # raise HTTPException( - # status_code=401, - # detail="LiteLLM API key is missing. Please add it or use OAuth authentication.", - # headers={ - # "WWW-Authenticate": f'Bearer resource_metadata=f"{request.base_url}/.well-known/oauth-protected-resource"', - # }, - # ) + elif has_explicit_litellm_key: + # Explicit x-litellm-api-key provided - always validate normally + validated_user_api_key_auth = await user_api_key_auth( + api_key=litellm_api_key, request=request + ) + elif oauth2_headers: + # No x-litellm-api-key, but Authorization header present. + # Could be a LiteLLM key (backward compat) OR an OAuth2 token + # from an upstream MCP provider (e.g. Atlassian). + # Try LiteLLM auth first; on auth failure, treat as OAuth2 passthrough. + try: + validated_user_api_key_auth = await user_api_key_auth( + api_key=litellm_api_key, request=request + ) + except HTTPException as e: + if e.status_code in (401, 403): + verbose_logger.debug( + "MCP OAuth2: Authorization header is not a valid LiteLLM key, " + "treating as OAuth2 token passthrough" + ) + validated_user_api_key_auth = UserAPIKeyAuth() + else: + raise + except ProxyException as e: + if str(e.code) in ("401", "403"): + verbose_logger.debug( + "MCP OAuth2: Authorization header is not a valid LiteLLM key, " + "treating as OAuth2 token passthrough" + ) + validated_user_api_key_auth = UserAPIKeyAuth() + else: + raise else: validated_user_api_key_auth = await user_api_key_auth( api_key=litellm_api_key, request=request @@ -342,45 +377,31 @@ class MCPRequestHandler: return [] @staticmethod - async def _get_key_object_permission( + def _get_key_object_permission( user_api_key_auth: Optional[UserAPIKeyAuth] = None, ): - """Helper to get key object_permission from cache or DB.""" - from litellm.proxy.auth.auth_checks import get_object_permission - from litellm.proxy.proxy_server import ( - prisma_client, - proxy_logging_obj, - user_api_key_cache, - ) + """ + Get key object_permission - already loaded by get_key_object() in main auth flow. + Note: object_permission is automatically populated when the key is fetched via + get_key_object() in litellm/proxy/auth/auth_checks.py + """ if not user_api_key_auth: return None - # Already loaded - if user_api_key_auth.object_permission: - return user_api_key_auth.object_permission - - # Need to fetch from DB - if user_api_key_auth.object_permission_id and prisma_client: - return await get_object_permission( - object_permission_id=user_api_key_auth.object_permission_id, - prisma_client=prisma_client, - user_api_key_cache=user_api_key_cache, - parent_otel_span=user_api_key_auth.parent_otel_span, - proxy_logging_obj=proxy_logging_obj, - ) - - return None + return user_api_key_auth.object_permission @staticmethod async def _get_team_object_permission( user_api_key_auth: Optional[UserAPIKeyAuth] = None, ): - """Helper to get team object_permission from cache or DB.""" - from litellm.proxy.auth.auth_checks import ( - get_object_permission, - get_team_object, - ) + """ + Get team object_permission - automatically loaded by get_team_object() in main auth flow. + + Note: object_permission is automatically populated when the team is fetched via + get_team_object() in litellm/proxy/auth/auth_checks.py + """ + from litellm.proxy.auth.auth_checks import get_team_object from litellm.proxy.proxy_server import ( prisma_client, proxy_logging_obj, @@ -393,7 +414,7 @@ class MCPRequestHandler: if not user_api_key_auth or not user_api_key_auth.team_id or not prisma_client: return None - # First get the team object (which may have object_permission already loaded) + # Get the team object (which has object_permission already loaded) team_obj: Optional[LiteLLM_TeamTable] = await get_team_object( team_id=user_api_key_auth.team_id, prisma_client=prisma_client, @@ -405,21 +426,7 @@ class MCPRequestHandler: if not team_obj: return None - # Already loaded - if team_obj.object_permission: - return team_obj.object_permission - - # Need to fetch from DB using object_permission_id - if team_obj.object_permission_id: - return await get_object_permission( - object_permission_id=team_obj.object_permission_id, - prisma_client=prisma_client, - user_api_key_cache=user_api_key_cache, - parent_otel_span=user_api_key_auth.parent_otel_span, - proxy_logging_obj=proxy_logging_obj, - ) - - return None + return team_obj.object_permission @staticmethod async def get_allowed_tools_for_server( @@ -441,8 +448,8 @@ class MCPRequestHandler: return None try: - # Get key and team object permissions - key_obj_perm = await MCPRequestHandler._get_key_object_permission( + # Get key and team object permissions (already loaded in main auth flow) + key_obj_perm = MCPRequestHandler._get_key_object_permission( user_api_key_auth ) team_obj_perm = await MCPRequestHandler._get_team_object_permission( @@ -529,7 +536,8 @@ class MCPRequestHandler: user_api_key_auth: Optional[UserAPIKeyAuth] = None, ) -> List[str]: try: - key_object_permission = await MCPRequestHandler._get_key_object_permission( + # Get key object permission (already loaded in main auth flow) + key_object_permission = MCPRequestHandler._get_key_object_permission( user_api_key_auth ) if key_object_permission is None: @@ -561,12 +569,10 @@ class MCPRequestHandler: """ Get allowed MCP servers for a team. - Uses the helper _get_team_object_permission which: - 1. First checks if object_permission is already loaded on the team - 2. If not, fetches from DB using object_permission_id if it exists + Note: object_permission is automatically loaded by get_team_object() in main auth flow. """ try: - # Use the helper method that properly handles fetching from DB if needed + # Get team object permission (already loaded in main auth flow) object_permissions = await MCPRequestHandler._get_team_object_permission( user_api_key_auth ) diff --git a/litellm/proxy/_experimental/mcp_server/discoverable_endpoints.py b/litellm/proxy/_experimental/mcp_server/discoverable_endpoints.py index 56feff548ad..b0ae03c94d3 100644 --- a/litellm/proxy/_experimental/mcp_server/discoverable_endpoints.py +++ b/litellm/proxy/_experimental/mcp_server/discoverable_endpoints.py @@ -1,6 +1,6 @@ import json from typing import Optional -from urllib.parse import urlencode, urlparse, urlunparse +from urllib.parse import parse_qsl, urlencode, urlparse, urlunparse from fastapi import APIRouter, Form, HTTPException, Request from fastapi.responses import HTMLResponse, JSONResponse, RedirectResponse @@ -9,13 +9,15 @@ from litellm.llms.custom_httpx.http_handler import ( get_async_httpx_client, httpxSpecialProvider, ) +from litellm.proxy.auth.ip_address_utils import IPAddressUtils from litellm.proxy.common_utils.encrypt_decrypt_utils import ( decrypt_value_helper, encrypt_value_helper, ) from litellm.proxy.common_utils.http_parsing_utils import _read_request_body -from litellm.types.mcp_server.mcp_server_manager import MCPServer from litellm.proxy.utils import get_server_root_path +from litellm.types.mcp import MCPAuth +from litellm.types.mcp_server.mcp_server_manager import MCPServer router = APIRouter( tags=["mcp"], @@ -124,6 +126,29 @@ def decode_state_hash(encrypted_state: str) -> dict: return state_data +def _resolve_oauth2_server_for_root_endpoints( + client_ip: Optional[str] = None, +) -> Optional[MCPServer]: + """ + Resolve the MCP server for root-level OAuth endpoints (no server name in path). + + When the MCP SDK hits root-level endpoints like /register, /authorize, /token + without a server name prefix, we try to find the right server automatically. + Returns the server if exactly one OAuth2 server is configured, else None. + """ + from litellm.proxy._experimental.mcp_server.mcp_server_manager import ( + global_mcp_server_manager, + ) + + registry = global_mcp_server_manager.get_filtered_registry(client_ip=client_ip) + oauth2_servers = [ + s for s in registry.values() if s.auth_type == MCPAuth.oauth2 + ] + if len(oauth2_servers) == 1: + return oauth2_servers[0] + return None + + async def authorize_with_server( request: Request, mcp_server: MCPServer, @@ -169,7 +194,13 @@ async def authorize_with_server( if code_challenge_method: params["code_challenge_method"] = code_challenge_method - return RedirectResponse(f"{mcp_server.authorization_url}?{urlencode(params)}") + parsed_auth_url = urlparse(mcp_server.authorization_url) + existing_params = dict(parse_qsl(parsed_auth_url.query)) + existing_params.update(params) + final_url = urlunparse( + parsed_auth_url._replace(query=urlencode(existing_params)) + ) + return RedirectResponse(final_url) async def exchange_token_with_server( @@ -300,7 +331,12 @@ async def authorize( ) lookup_name = mcp_server_name or client_id - mcp_server = global_mcp_server_manager.get_mcp_server_by_name(lookup_name) + client_ip = IPAddressUtils.get_mcp_client_ip(request) + mcp_server = global_mcp_server_manager.get_mcp_server_by_name( + lookup_name, client_ip=client_ip + ) + if mcp_server is None and mcp_server_name is None: + mcp_server = _resolve_oauth2_server_for_root_endpoints() if mcp_server is None: raise HTTPException(status_code=404, detail="MCP server not found") return await authorize_with_server( @@ -342,7 +378,12 @@ async def token_endpoint( ) lookup_name = mcp_server_name or client_id - mcp_server = global_mcp_server_manager.get_mcp_server_by_name(lookup_name) + client_ip = IPAddressUtils.get_mcp_client_ip(request) + mcp_server = global_mcp_server_manager.get_mcp_server_by_name( + lookup_name, client_ip=client_ip + ) + if mcp_server is None and mcp_server_name is None: + mcp_server = _resolve_oauth2_server_for_root_endpoints() if mcp_server is None: raise HTTPException(status_code=404, detail="MCP server not found") return await exchange_token_with_server( @@ -423,9 +464,19 @@ def _build_oauth_protected_resource_response( ) request_base_url = get_request_base_url(request) + + # When no server name provided, try to resolve the single OAuth2 server + if mcp_server_name is None: + resolved = _resolve_oauth2_server_for_root_endpoints() + if resolved: + mcp_server_name = resolved.server_name or resolved.name + mcp_server: Optional[MCPServer] = None if mcp_server_name: - mcp_server = global_mcp_server_manager.get_mcp_server_by_name(mcp_server_name) + client_ip = IPAddressUtils.get_mcp_client_ip(request) + mcp_server = global_mcp_server_manager.get_mcp_server_by_name( + mcp_server_name, client_ip=client_ip + ) # Build resource URL based on the pattern if mcp_server_name: @@ -525,6 +576,12 @@ def _build_oauth_authorization_server_response( request_base_url = get_request_base_url(request) + # When no server name provided, try to resolve the single OAuth2 server + if mcp_server_name is None: + resolved = _resolve_oauth2_server_for_root_endpoints() + if resolved: + mcp_server_name = resolved.server_name or resolved.name + authorization_endpoint = ( f"{request_base_url}/{mcp_server_name}/authorize" if mcp_server_name @@ -538,7 +595,10 @@ def _build_oauth_authorization_server_response( mcp_server: Optional[MCPServer] = None if mcp_server_name: - mcp_server = global_mcp_server_manager.get_mcp_server_by_name(mcp_server_name) + client_ip = IPAddressUtils.get_mcp_client_ip(request) + mcp_server = global_mcp_server_manager.get_mcp_server_by_name( + mcp_server_name, client_ip=client_ip + ) return { "issuer": request_base_url, # point to your proxy @@ -627,9 +687,25 @@ async def register_client(request: Request, mcp_server_name: Optional[str] = Non "redirect_uris": [f"{request_base_url}/callback"], } if not mcp_server_name: + resolved = _resolve_oauth2_server_for_root_endpoints() + if resolved: + return await register_client_with_server( + request=request, + mcp_server=resolved, + client_name=data.get("client_name", ""), + grant_types=data.get("grant_types", []), + response_types=data.get("response_types", []), + token_endpoint_auth_method=data.get( + "token_endpoint_auth_method", "" + ), + fallback_client_id=resolved.server_name or resolved.name, + ) return dummy_return - mcp_server = global_mcp_server_manager.get_mcp_server_by_name(mcp_server_name) + client_ip = IPAddressUtils.get_mcp_client_ip(request) + mcp_server = global_mcp_server_manager.get_mcp_server_by_name( + mcp_server_name, client_ip=client_ip + ) if mcp_server is None: return dummy_return return await register_client_with_server( diff --git a/litellm/proxy/_experimental/mcp_server/guardrail_translation/handler.py b/litellm/proxy/_experimental/mcp_server/guardrail_translation/handler.py index 4d53ae7059d..14bbb82808d 100644 --- a/litellm/proxy/_experimental/mcp_server/guardrail_translation/handler.py +++ b/litellm/proxy/_experimental/mcp_server/guardrail_translation/handler.py @@ -1,26 +1,37 @@ """ MCP Guardrail Handler for Unified Guardrails. -This handler works with the synthetic "messages" payload generated by -`ProxyLogging._convert_mcp_to_llm_format`, which always produces a single user -message whose `content` string encodes the MCP tool name and arguments. The -handler simply feeds that text through the configured guardrail and writes the -result back onto the message. +Converts an MCP call_tool (name + arguments) into a single OpenAI-compatible +tool_call and passes it to apply_guardrail. Works with the synthetic payload +from ProxyLogging._convert_mcp_to_llm_format. + +Note: For MCP tool definitions (schema) -> OpenAI tools=[], see +litellm.experimental_mcp_client.tools.transform_mcp_tool_to_openai_tool +when you have a full MCP Tool from list_tools. Here we only have the call +payload (name + arguments) so we just build the tool_call. """ from typing import TYPE_CHECKING, Any, Dict, Optional +from mcp.types import Tool as MCPTool + from litellm._logging import verbose_proxy_logger +from litellm.experimental_mcp_client.tools import transform_mcp_tool_to_openai_tool from litellm.llms.base_llm.guardrail_translation.base_translation import BaseTranslation +from litellm.types.llms.openai import ( + ChatCompletionToolParam, + ChatCompletionToolParamFunctionChunk, +) from litellm.types.utils import GenericGuardrailAPIInputs if TYPE_CHECKING: - from litellm.integrations.custom_guardrail import CustomGuardrail from mcp.types import CallToolResult + from litellm.integrations.custom_guardrail import CustomGuardrail + class MCPGuardrailTranslationHandler(BaseTranslation): - """Guardrail translation handler for MCP tool calls.""" + """Guardrail translation handler for MCP tool calls (passes a single tool_call to guardrail).""" async def process_input_messages( self, @@ -28,56 +39,51 @@ class MCPGuardrailTranslationHandler(BaseTranslation): guardrail_to_apply: "CustomGuardrail", litellm_logging_obj: Optional[Any] = None, ) -> Dict[str, Any]: - messages = data.get("messages") - if not isinstance(messages, list) or not messages: - verbose_proxy_logger.debug("MCP Guardrail: No messages to process") + mcp_tool_name = data.get("mcp_tool_name") or data.get("name") + mcp_arguments = data.get("mcp_arguments") or data.get("arguments") + mcp_tool_description = data.get("mcp_tool_description") or data.get( + "description" + ) + if mcp_arguments is None or not isinstance(mcp_arguments, dict): + mcp_arguments = {} + + if not mcp_tool_name: + verbose_proxy_logger.debug("MCP Guardrail: mcp_tool_name missing") return data - first_message = messages[0] - content: Optional[str] = None - if isinstance(first_message, dict): - content = first_message.get("content") - else: - content = getattr(first_message, "content", None) + # Convert MCP input via transform_mcp_tool_to_openai_tool, then map to litellm + # ChatCompletionToolParam (openai SDK type has incompatible strict/cache_control). + mcp_tool = MCPTool( + name=mcp_tool_name, + description=mcp_tool_description or "", + inputSchema={}, # Call payload has no schema; guardrail gets args from request_data + ) + openai_tool = transform_mcp_tool_to_openai_tool(mcp_tool) + fn = openai_tool["function"] + tool_def: ChatCompletionToolParam = { + "type": "function", + "function": ChatCompletionToolParamFunctionChunk( + name=fn["name"], + description=fn.get("description") or "", + parameters=fn.get("parameters") + or { + "type": "object", + "properties": {}, + "additionalProperties": False, + }, + strict=fn.get("strict", False) or False, # Default to False if None + ), + } + inputs: GenericGuardrailAPIInputs = GenericGuardrailAPIInputs( + tools=[tool_def], + ) - if not isinstance(content, str): - verbose_proxy_logger.debug( - "MCP Guardrail: Message content missing or not a string", - ) - return data - - inputs = GenericGuardrailAPIInputs(texts=[content]) - # Include model information if available - model = data.get("model") - if model: - inputs["model"] = model - guardrailed_inputs = await guardrail_to_apply.apply_guardrail( + await guardrail_to_apply.apply_guardrail( inputs=inputs, request_data=data, input_type="request", logging_obj=litellm_logging_obj, ) - guardrailed_texts = ( - guardrailed_inputs.get("texts", []) if guardrailed_inputs else [] - ) - - if guardrailed_texts: - new_content = guardrailed_texts[0] - if isinstance(first_message, dict): - first_message["content"] = new_content - else: - setattr(first_message, "content", new_content) - - verbose_proxy_logger.debug( - "MCP Guardrail: Updated content for tool %s", - data.get("mcp_tool_name"), - ) - else: - verbose_proxy_logger.debug( - "MCP Guardrail: Guardrail returned no text updates for tool %s", - data.get("mcp_tool_name"), - ) - return data async def process_output_response( @@ -87,7 +93,6 @@ class MCPGuardrailTranslationHandler(BaseTranslation): litellm_logging_obj: Optional[Any] = None, user_api_key_dict: Optional[Any] = None, ) -> Any: - # Not implemented: MCP guardrail translation never calls this path today. verbose_proxy_logger.debug( "MCP Guardrail: Output processing not implemented for MCP tools", ) diff --git a/litellm/proxy/_experimental/mcp_server/mcp_server_manager.py b/litellm/proxy/_experimental/mcp_server/mcp_server_manager.py index 4c17a2ff3e0..fd251488db4 100644 --- a/litellm/proxy/_experimental/mcp_server/mcp_server_manager.py +++ b/litellm/proxy/_experimental/mcp_server/mcp_server_manager.py @@ -36,6 +36,7 @@ from litellm.llms.custom_httpx.http_handler import get_async_httpx_client from litellm.proxy._experimental.mcp_server.auth.user_api_key_auth_mcp import ( MCPRequestHandler, ) +from litellm.proxy._experimental.mcp_server.oauth2_token_cache import resolve_mcp_auth from litellm.proxy._experimental.mcp_server.utils import ( MCP_TOOL_PREFIX_SEPARATOR, add_server_prefix_to_name, @@ -53,6 +54,7 @@ from litellm.proxy._types import ( MCPTransportType, UserAPIKeyAuth, ) +from litellm.proxy.auth.ip_address_utils import IPAddressUtils from litellm.proxy.common_utils.encrypt_decrypt_utils import decrypt_value_helper from litellm.proxy.utils import ProxyLogging from litellm.types.llms.custom_http import httpxSpecialProvider @@ -65,20 +67,21 @@ from litellm.types.mcp_server.mcp_server_manager import ( from litellm.types.utils import CallTypes try: - from mcp.shared.tool_name_validation import ( # type: ignore - SEP_986_URL, - validate_tool_name, + from mcp.shared.tool_name_validation import ( + validate_tool_name, # pyright: ignore[reportAssignmentType] ) + from mcp.shared.tool_name_validation import SEP_986_URL except ImportError: from pydantic import BaseModel + SEP_986_URL = "https://github.com/modelcontextprotocol/protocol/blob/main/proposals/0001-tool-name-validation.md" - class ToolNameValidationResult(BaseModel): + class _ToolNameValidationResult(BaseModel): is_valid: bool = True warnings: list = [] - def validate_tool_name(name: str) -> ToolNameValidationResult: # type: ignore[misc] - return ToolNameValidationResult() + def validate_tool_name(name: str) -> _ToolNameValidationResult: # type: ignore[misc] + return _ToolNameValidationResult() # Probe includes characters on both sides of the separator to mimic real prefixed tool names. @@ -324,6 +327,9 @@ class MCPServerManager: access_groups=server_config.get("access_groups", None), static_headers=server_config.get("static_headers", None), allow_all_keys=bool(server_config.get("allow_all_keys", False)), + available_on_public_internet=bool( + server_config.get("available_on_public_internet", False) + ), ) self.config_mcp_servers[server_id] = new_server @@ -333,7 +339,7 @@ class MCPServerManager: verbose_logger.info( f"Loading OpenAPI spec from {spec_path} for server {server_name}" ) - self._register_openapi_tools( + await self._register_openapi_tools( spec_path=spec_path, server=new_server, base_url=server_config.get("url", ""), @@ -345,7 +351,9 @@ class MCPServerManager: self.initialize_tool_name_to_mcp_server_name_mapping() - def _register_openapi_tools(self, spec_path: str, server: MCPServer, base_url: str): + async def _register_openapi_tools( + self, spec_path: str, server: MCPServer, base_url: str + ): """ Register tools from an OpenAPI specification for a given server. @@ -367,15 +375,15 @@ class MCPServerManager: get_base_url as get_openapi_base_url, ) from litellm.proxy._experimental.mcp_server.openapi_to_mcp_generator import ( - load_openapi_spec, + load_openapi_spec_async, ) from litellm.proxy._experimental.mcp_server.tool_registry import ( global_mcp_tool_registry, ) try: - # Load OpenAPI spec - spec = load_openapi_spec(spec_path) + # Load OpenAPI spec (async to avoid "called from within a running event loop") + spec = await load_openapi_spec_async(spec_path) # Use base_url from config if provided, otherwise extract from spec if not base_url: @@ -469,12 +477,12 @@ class MCPServerManager: ) # Update tool name to server name mapping (for both prefixed and base names) - self.tool_name_to_mcp_server_name_mapping[ - base_tool_name - ] = server_prefix - self.tool_name_to_mcp_server_name_mapping[ - prefixed_tool_name - ] = server_prefix + self.tool_name_to_mcp_server_name_mapping[base_tool_name] = ( + server_prefix + ) + self.tool_name_to_mcp_server_name_mapping[prefixed_tool_name] = ( + server_prefix + ) registered_count += 1 verbose_logger.debug( @@ -622,6 +630,9 @@ class MCPServerManager: allowed_tools=getattr(mcp_server, "allowed_tools", None), disallowed_tools=getattr(mcp_server, "disallowed_tools", None), allow_all_keys=mcp_server.allow_all_keys, + available_on_public_internet=bool( + getattr(mcp_server, "available_on_public_internet", False) + ), updated_at=getattr(mcp_server, "updated_at", None), ) return new_server @@ -660,24 +671,47 @@ class MCPServerManager: return [ server.server_id for server in self.get_registry().values() - if server.allow_all_keys + if server.allow_all_keys is True ] async def get_allowed_mcp_servers( self, user_api_key_auth: Optional[UserAPIKeyAuth] = None ) -> List[str]: """ - Get the allowed MCP Servers for the user + Get the allowed MCP Servers for the user. + + Priority: + 1. If object_permission.mcp_servers is explicitly set, use it (even for admins) + 2. If admin and no object_permission, return all servers + 3. Otherwise, use standard permission checks """ from litellm.proxy.management_endpoints.common_utils import _user_has_admin_view - # If admin, get all servers - if user_api_key_auth and _user_has_admin_view(user_api_key_auth): - return list(self.get_registry().keys()) - allow_all_server_ids = self.get_allow_all_keys_server_ids() try: + # Check if object_permission.mcp_servers is explicitly set + has_explicit_object_permission = False + if user_api_key_auth and user_api_key_auth.object_permission: + # Check if mcp_servers is explicitly set (not None, empty list is valid) + if user_api_key_auth.object_permission.mcp_servers is not None: + has_explicit_object_permission = True + verbose_logger.debug( + f"Object permission mcp_servers explicitly set: {user_api_key_auth.object_permission.mcp_servers}" + ) + + # If admin but NO explicit object permission, get all servers + if ( + user_api_key_auth + and _user_has_admin_view(user_api_key_auth) + and not has_explicit_object_permission + ): + verbose_logger.debug( + "Admin user without explicit object_permission - returning all servers" + ) + return list(self.get_registry().keys()) + + # Get allowed servers from object permissions (respects object_permission even for admins) allowed_mcp_servers = await MCPRequestHandler.get_allowed_mcp_servers( user_api_key_auth ) @@ -696,6 +730,23 @@ class MCPServerManager: verbose_logger.warning(f"Failed to get allowed MCP servers: {str(e)}.") return allow_all_server_ids + def filter_server_ids_by_ip( + self, server_ids: List[str], client_ip: Optional[str] + ) -> List[str]: + """ + Filter server IDs by client IP — external callers only see public servers. + + Returns server_ids unchanged when client_ip is None (no filtering). + """ + if client_ip is None: + return server_ids + return [ + sid + for sid in server_ids + if (s := self.get_mcp_server_by_id(sid)) is not None + and self._is_server_accessible_from_ip(s, client_ip) + ] + async def get_tools_for_server(self, server_id: str) -> List[MCPTool]: """ Get the tools for a given server @@ -806,7 +857,7 @@ class MCPServerManager: return resolved_env - def _create_mcp_client( + async def _create_mcp_client( self, server: MCPServer, mcp_auth_header: Optional[Union[str, Dict[str, str]]] = None, @@ -816,13 +867,22 @@ class MCPServerManager: """ Create an MCPClient instance for the given server. + Auth resolution (single place for all auth logic): + 1. ``mcp_auth_header`` — per-request/per-user override + 2. OAuth2 client_credentials token — auto-fetched and cached + 3. ``server.authentication_token`` — static token from config/DB + Args: - server (MCPServer): The server configuration - mcp_auth_header: MCP auth header to be passed to the MCP server. This is optional and will be used if provided. + server: The server configuration. + mcp_auth_header: Optional per-request auth override. + extra_headers: Additional headers to forward. + stdio_env: Environment variables for stdio transport. Returns: - MCPClient: Configured MCP client instance + Configured MCP client instance. """ + auth_value = await resolve_mcp_auth(server, mcp_auth_header) + transport = server.transport or MCPTransport.sse # Handle stdio transport @@ -841,7 +901,7 @@ class MCPServerManager: server_url="", # Not used for stdio transport_type=transport, auth_type=server.auth_type, - auth_value=mcp_auth_header or server.authentication_token, + auth_value=auth_value, timeout=60.0, stdio_config=stdio_config, extra_headers=extra_headers, @@ -853,7 +913,7 @@ class MCPServerManager: server_url=server_url, transport_type=transport, auth_type=server.auth_type, - auth_value=mcp_auth_header or server.authentication_token, + auth_value=auth_value, timeout=60.0, extra_headers=extra_headers, ) @@ -893,7 +953,7 @@ class MCPServerManager: stdio_env = self._build_stdio_env(server, raw_headers) - client = self._create_mcp_client( + client = await self._create_mcp_client( server=server, mcp_auth_header=mcp_auth_header, extra_headers=extra_headers, @@ -953,7 +1013,7 @@ class MCPServerManager: stdio_env = self._build_stdio_env(server, raw_headers) - client = self._create_mcp_client( + client = await self._create_mcp_client( server=server, mcp_auth_header=mcp_auth_header, extra_headers=extra_headers, @@ -997,7 +1057,7 @@ class MCPServerManager: stdio_env = self._build_stdio_env(server, raw_headers) - client = self._create_mcp_client( + client = await self._create_mcp_client( server=server, mcp_auth_header=mcp_auth_header, extra_headers=extra_headers, @@ -1041,7 +1101,7 @@ class MCPServerManager: stdio_env = self._build_stdio_env(server, raw_headers) - client = self._create_mcp_client( + client = await self._create_mcp_client( server=server, mcp_auth_header=mcp_auth_header, extra_headers=extra_headers, @@ -1082,7 +1142,7 @@ class MCPServerManager: stdio_env = self._build_stdio_env(server, raw_headers) - client = self._create_mcp_client( + client = await self._create_mcp_client( server=server, mcp_auth_header=mcp_auth_header, extra_headers=extra_headers, @@ -1112,7 +1172,7 @@ class MCPServerManager: stdio_env = self._build_stdio_env(server, raw_headers) - client = self._create_mcp_client( + client = await self._create_mcp_client( server=server, mcp_auth_header=mcp_auth_header, extra_headers=extra_headers, @@ -1916,7 +1976,7 @@ class MCPServerManager: stdio_env = self._build_stdio_env(mcp_server, raw_headers) - client = self._create_mcp_client( + client = await self._create_mcp_client( server=mcp_server, mcp_auth_header=server_auth_header, extra_headers=extra_headers, @@ -1929,7 +1989,9 @@ class MCPServerManager: ) async def _call_tool_via_client(client, params): - return await client.call_tool(params, host_progress_callback=host_progress_callback) + return await client.call_tool( + params, host_progress_callback=host_progress_callback + ) tasks.append( asyncio.create_task(_call_tool_via_client(client, call_tool_params)) @@ -1967,7 +2029,6 @@ class MCPServerManager: oauth2_headers: Optional[Dict[str, str]] = None, raw_headers: Optional[Dict[str, str]] = None, host_progress_callback: Optional[Callable] = None, - ) -> CallToolResult: """ Call a tool with the given name and arguments @@ -2091,8 +2152,8 @@ class MCPServerManager: Note: This now handles prefixed tool names """ for server in self.get_registry().values(): - if server.auth_type == MCPAuth.oauth2: - # Skip OAuth2 servers for now as they may require user-specific tokens + if server.needs_user_oauth_token: + # Skip OAuth2 servers that rely on user-provided tokens continue tools = await self._get_tools_from_server(server) for tool in tools: @@ -2200,6 +2261,43 @@ class MCPServerManager: servers.append(server) return servers + def _get_general_settings(self) -> Dict[str, Any]: + """Get general_settings, importing lazily to avoid circular imports.""" + try: + from litellm.proxy.proxy_server import ( + general_settings as proxy_general_settings, + ) + + return proxy_general_settings + except ImportError: + # Fallback if proxy_server not available + return {} + + def _is_server_accessible_from_ip( + self, server: MCPServer, client_ip: Optional[str] + ) -> bool: + """ + Check if a server is accessible from the given client IP. + + - If client_ip is None, no IP filtering is applied (internal callers). + - If the server has available_on_public_internet=True, it's always accessible. + - Otherwise, only internal/private IPs can access it. + """ + if client_ip is None: + return True + if server.available_on_public_internet: + return True + # Check backwards compat: litellm.public_mcp_servers + public_ids = set(litellm.public_mcp_servers or []) + if server.server_id in public_ids: + return True + # Non-public server: only accessible from internal IPs + general_settings = self._get_general_settings() + internal_networks = IPAddressUtils.parse_internal_networks( + general_settings.get("mcp_internal_ip_ranges") + ) + return IPAddressUtils.is_internal_ip(client_ip, internal_networks) + def get_mcp_server_by_id(self, server_id: str) -> Optional[MCPServer]: """ Get the MCP Server from the server id @@ -2212,27 +2310,72 @@ class MCPServerManager: def get_public_mcp_servers(self) -> List[MCPServer]: """ - Get the public MCP servers + Get the public MCP servers (available_on_public_internet=True flag on server). + Also includes servers from litellm.public_mcp_servers for backwards compat. """ servers: List[MCPServer] = [] - if litellm.public_mcp_servers is None: - return servers - for server_id in litellm.public_mcp_servers: - server = self.get_mcp_server_by_id(server_id) - if server: + public_ids = set(litellm.public_mcp_servers or []) + for server in self.get_registry().values(): + if server.available_on_public_internet or server.server_id in public_ids: servers.append(server) return servers - def get_mcp_server_by_name(self, server_name: str) -> Optional[MCPServer]: + def get_mcp_server_by_name( + self, server_name: str, client_ip: Optional[str] = None + ) -> Optional[MCPServer]: """ - Get the MCP Server from the server name + Get the MCP Server from the server name. + + Uses priority-based matching to avoid collisions: + 1. First pass: exact alias match (highest priority) + 2. Second pass: exact server_name match + 3. Third pass: exact name match (lowest priority) + + Args: + server_name: The server name to look up. + client_ip: Optional client IP for access control. When provided, + non-public servers are hidden from external IPs. """ registry = self.get_registry() + # Pass 1: Match by alias (highest priority) + for server in registry.values(): + if server.alias == server_name: + if not self._is_server_accessible_from_ip(server, client_ip): + return None + return server + # Pass 2: Match by server_name for server in registry.values(): if server.server_name == server_name: + if not self._is_server_accessible_from_ip(server, client_ip): + return None + return server + # Pass 3: Match by name (lowest priority) + for server in registry.values(): + if server.name == server_name: + if not self._is_server_accessible_from_ip(server, client_ip): + return None return server return None + def get_filtered_registry( + self, client_ip: Optional[str] = None + ) -> Dict[str, MCPServer]: + """ + Get registry filtered by client IP access control. + + Args: + client_ip: Optional client IP. When provided, non-public servers + are hidden from external IPs. When None, returns all servers. + """ + registry = self.get_registry() + if client_ip is None: + return registry + return { + k: v + for k, v in registry.items() + if self._is_server_accessible_from_ip(v, client_ip) + } + def _generate_stable_server_id( self, server_name: str, @@ -2305,7 +2448,7 @@ class MCPServerManager: should_skip_health_check = False # Skip if auth_type is oauth2 - if server.auth_type == MCPAuth.oauth2: + if server.needs_user_oauth_token: should_skip_health_check = True # Skip if auth_type is not none and authentication_token is missing elif ( @@ -2320,7 +2463,7 @@ class MCPServerManager: if server.static_headers: extra_headers.update(server.static_headers) - client = self._create_mcp_client( + client = await self._create_mcp_client( server=server, mcp_auth_header=None, extra_headers=extra_headers, @@ -2462,6 +2605,7 @@ class MCPServerManager: token_url=server.token_url, registration_url=server.registration_url, allow_all_keys=server.allow_all_keys, + available_on_public_internet=server.available_on_public_internet, ) async def get_all_mcp_servers_unfiltered(self) -> List[LiteLLM_MCPServerTable]: diff --git a/litellm/proxy/_experimental/mcp_server/oauth2_token_cache.py b/litellm/proxy/_experimental/mcp_server/oauth2_token_cache.py new file mode 100644 index 00000000000..0de381ee1df --- /dev/null +++ b/litellm/proxy/_experimental/mcp_server/oauth2_token_cache.py @@ -0,0 +1,163 @@ +""" +OAuth2 client_credentials token cache for MCP servers. + +Automatically fetches and refreshes access tokens for MCP servers configured +with ``client_id``, ``client_secret``, and ``token_url``. +""" + +import asyncio +from typing import TYPE_CHECKING, Dict, Optional, Tuple, Union + +import httpx + +from litellm._logging import verbose_logger +from litellm.caching.in_memory_cache import InMemoryCache +from litellm.constants import ( + MCP_OAUTH2_TOKEN_CACHE_DEFAULT_TTL, + MCP_OAUTH2_TOKEN_CACHE_MAX_SIZE, + MCP_OAUTH2_TOKEN_CACHE_MIN_TTL, + MCP_OAUTH2_TOKEN_EXPIRY_BUFFER_SECONDS, +) +from litellm.llms.custom_httpx.http_handler import get_async_httpx_client +from litellm.types.llms.custom_http import httpxSpecialProvider + +if TYPE_CHECKING: + from litellm.types.mcp_server.mcp_server_manager import MCPServer + + +class MCPOAuth2TokenCache(InMemoryCache): + """ + In-memory cache for OAuth2 client_credentials tokens, keyed by server_id. + + Inherits from ``InMemoryCache`` for TTL-based storage and eviction. + Adds per-server ``asyncio.Lock`` to prevent duplicate concurrent fetches. + """ + + def __init__(self) -> None: + super().__init__( + max_size_in_memory=MCP_OAUTH2_TOKEN_CACHE_MAX_SIZE, + default_ttl=MCP_OAUTH2_TOKEN_CACHE_DEFAULT_TTL, + ) + self._locks: Dict[str, asyncio.Lock] = {} + + def _get_lock(self, server_id: str) -> asyncio.Lock: + return self._locks.setdefault(server_id, asyncio.Lock()) + + async def async_get_token(self, server: "MCPServer") -> Optional[str]: + """Return a valid access token, fetching or refreshing as needed. + + Returns ``None`` when the server lacks client credentials config. + """ + if not server.has_client_credentials: + return None + + server_id = server.server_id + + # Fast path — cached token is still valid + cached = self.get_cache(server_id) + if cached is not None: + return cached + + # Slow path — acquire per-server lock then double-check + async with self._get_lock(server_id): + cached = self.get_cache(server_id) + if cached is not None: + return cached + + token, ttl = await self._fetch_token(server) + self.set_cache(server_id, token, ttl=ttl) + return token + + async def _fetch_token(self, server: "MCPServer") -> Tuple[str, int]: + """POST to ``token_url`` with ``grant_type=client_credentials``. + + Returns ``(access_token, ttl_seconds)`` where ttl accounts for the + expiry buffer so the cache entry expires before the real token does. + """ + client = get_async_httpx_client(llm_provider=httpxSpecialProvider.MCP) + + if not server.client_id or not server.client_secret or not server.token_url: + raise ValueError( + f"MCP server '{server.server_id}' missing required OAuth2 fields: " + f"client_id={bool(server.client_id)}, " + f"client_secret={bool(server.client_secret)}, " + f"token_url={bool(server.token_url)}" + ) + + data: Dict[str, str] = { + "grant_type": "client_credentials", + "client_id": server.client_id, + "client_secret": server.client_secret, + } + if server.scopes: + data["scope"] = " ".join(server.scopes) + + verbose_logger.debug( + "Fetching OAuth2 client_credentials token for MCP server %s", + server.server_id, + ) + + try: + response = await client.post(server.token_url, data=data) + response.raise_for_status() + except httpx.HTTPStatusError as exc: + raise ValueError( + f"OAuth2 token request for MCP server '{server.server_id}' " + f"failed with status {exc.response.status_code}" + ) from exc + + body = response.json() + + if not isinstance(body, dict): + raise ValueError( + f"OAuth2 token response for MCP server '{server.server_id}' " + f"returned non-object JSON (got {type(body).__name__})" + ) + + access_token = body.get("access_token") + if not access_token: + raise ValueError( + f"OAuth2 token response for MCP server '{server.server_id}' " + f"missing 'access_token'" + ) + + # Safely parse expires_in — providers may return null or non-numeric values + raw_expires_in = body.get("expires_in") + try: + expires_in = int(raw_expires_in) if raw_expires_in is not None else MCP_OAUTH2_TOKEN_CACHE_DEFAULT_TTL + except (TypeError, ValueError): + expires_in = MCP_OAUTH2_TOKEN_CACHE_DEFAULT_TTL + + ttl = max(expires_in - MCP_OAUTH2_TOKEN_EXPIRY_BUFFER_SECONDS, MCP_OAUTH2_TOKEN_CACHE_MIN_TTL) + + verbose_logger.info( + "Fetched OAuth2 token for MCP server %s (expires in %ds)", + server.server_id, + expires_in, + ) + return access_token, ttl + + def invalidate(self, server_id: str) -> None: + """Remove a cached token (e.g. after a 401).""" + self.delete_cache(server_id) + + +mcp_oauth2_token_cache = MCPOAuth2TokenCache() + + +async def resolve_mcp_auth( + server: "MCPServer", + mcp_auth_header: Optional[Union[str, Dict[str, str]]] = None, +) -> Optional[Union[str, Dict[str, str]]]: + """Resolve the auth value for an MCP server. + + Priority: + 1. ``mcp_auth_header`` — per-request/per-user override + 2. OAuth2 client_credentials token — auto-fetched and cached + 3. ``server.authentication_token`` — static token from config/DB + """ + if mcp_auth_header: + return mcp_auth_header + if server.has_client_credentials: + return await mcp_oauth2_token_cache.async_get_token(server) + return server.authentication_token diff --git a/litellm/proxy/_experimental/mcp_server/openapi_to_mcp_generator.py b/litellm/proxy/_experimental/mcp_server/openapi_to_mcp_generator.py index b635f15ed09..deb0b4f9549 100644 --- a/litellm/proxy/_experimental/mcp_server/openapi_to_mcp_generator.py +++ b/litellm/proxy/_experimental/mcp_server/openapi_to_mcp_generator.py @@ -3,6 +3,8 @@ This module is used to generate MCP tools from OpenAPI specs. """ import json +import asyncio +import os from pathlib import PurePosixPath from typing import Any, Dict, Optional from urllib.parse import quote @@ -45,8 +47,36 @@ def _sanitize_path_parameter_value(param_value: Any, param_name: str) -> str: def load_openapi_spec(filepath: str) -> Dict[str, Any]: - """Load OpenAPI specification from JSON file.""" - with open(filepath, "r") as f: + """ + Sync wrapper. For URL specs, use the shared/custom MCP httpx client. + """ + try: + # If we're already inside an event loop, prefer the async function. + asyncio.get_running_loop() + raise RuntimeError( + "load_openapi_spec() was called from within a running event loop. " + "Use 'await load_openapi_spec_async(...)' instead." + ) + except RuntimeError as e: + # "no running event loop" is fine; other RuntimeErrors we re-raise + if "no running event loop" not in str(e).lower(): + raise + return asyncio.run(load_openapi_spec_async(filepath)) + +async def load_openapi_spec_async(filepath: str) -> Dict[str, Any]: + if filepath.startswith("http://") or filepath.startswith("https://"): + client = get_async_httpx_client(llm_provider=httpxSpecialProvider.MCP) + # NOTE: do not close shared client if get_async_httpx_client returns a shared singleton. + # If it returns a new client each time, consider wrapping it in an async context manager. + r = await client.get(filepath) + r.raise_for_status() + return r.json() + + # fallback: local file + # Local filesystem path + if not os.path.exists(filepath): + raise FileNotFoundError(f"OpenAPI spec not found at {filepath}") + with open(filepath, "r", encoding="utf-8") as f: return json.load(f) diff --git a/litellm/proxy/_experimental/mcp_server/rest_endpoints.py b/litellm/proxy/_experimental/mcp_server/rest_endpoints.py index d93f852f22d..aed81afd254 100644 --- a/litellm/proxy/_experimental/mcp_server/rest_endpoints.py +++ b/litellm/proxy/_experimental/mcp_server/rest_endpoints.py @@ -1,6 +1,6 @@ import importlib from datetime import datetime -from typing import Dict, List, Optional, Union +from typing import Any, Awaitable, Callable, Dict, List, Optional, Union from fastapi import APIRouter, Depends, HTTPException, Query, Request @@ -10,8 +10,10 @@ from litellm.proxy._experimental.mcp_server.ui_session_utils import ( ) from litellm.proxy._experimental.mcp_server.utils import merge_mcp_headers from litellm.proxy._types import UserAPIKeyAuth +from litellm.proxy.auth.ip_address_utils import IPAddressUtils from litellm.proxy.auth.user_api_key_auth import user_api_key_auth from litellm.types.mcp import MCPAuth +from litellm.types.utils import CallTypes MCP_AVAILABLE: bool = True try: @@ -28,12 +30,14 @@ router = APIRouter( if MCP_AVAILABLE: from mcp.types import Tool as MCPTool + from litellm.proxy._experimental.mcp_server.mcp_server_manager import ( global_mcp_server_manager, ) from litellm.proxy._experimental.mcp_server.server import ( ListMCPToolsRestAPIResponseObject, MCPServer, + _tool_name_matches, execute_mcp_tool, filter_tools_by_allowed_tools, ) @@ -76,10 +80,87 @@ if MCP_AVAILABLE: for tool in tools ] + def _extract_mcp_headers_from_request( + request: Request, + mcp_request_handler_cls, + ) -> tuple: + """ + Extract MCP auth headers from HTTP request. + + Returns: + Tuple of (mcp_auth_header, mcp_server_auth_headers, raw_headers) + """ + headers = request.headers + raw_headers = dict(headers) + mcp_auth_header = mcp_request_handler_cls._get_mcp_auth_header_from_headers( + headers + ) + mcp_server_auth_headers = ( + mcp_request_handler_cls._get_mcp_server_auth_headers_from_headers(headers) + ) + return mcp_auth_header, mcp_server_auth_headers, raw_headers + + async def _resolve_allowed_mcp_servers_with_ip_filter( + request: Request, + user_api_key_dict: UserAPIKeyAuth, + server_id: str, + ) -> List[MCPServer]: + """ + Resolve allowed MCP servers for a tool call with IP filtering. + + Args: + request: The HTTP request object + user_api_key_dict: The user's API key auth object + server_id: The server ID to validate access for + + Returns: + List of allowed MCPServer objects + + Raises: + HTTPException: If the server_id is not allowed + """ + # Get all auth contexts + auth_contexts = await build_effective_auth_contexts(user_api_key_dict) + + # Collect allowed server IDs from all contexts, then apply IP filtering + _rest_client_ip = IPAddressUtils.get_mcp_client_ip(request) + allowed_server_ids_set = set() + for auth_context in auth_contexts: + servers = await global_mcp_server_manager.get_allowed_mcp_servers( + user_api_key_auth=auth_context, + ) + allowed_server_ids_set.update(servers) + + allowed_server_ids_set = set( + global_mcp_server_manager.filter_server_ids_by_ip( + list(allowed_server_ids_set), _rest_client_ip + ) + ) + + # Check if the specified server_id is allowed + if server_id not in allowed_server_ids_set: + raise HTTPException( + status_code=403, + detail={ + "error": "access_denied", + "message": f"The key is not allowed to access server {server_id}", + }, + ) + + # Build allowed_mcp_servers list (only include allowed servers) + allowed_mcp_servers: List[MCPServer] = [] + for allowed_server_id in allowed_server_ids_set: + server = global_mcp_server_manager.get_mcp_server_by_id(allowed_server_id) + if server is not None: + allowed_mcp_servers.append(server) + + return allowed_mcp_servers + async def _get_tools_for_single_server( server, server_auth_header, raw_headers: Optional[Dict[str, str]] = None, + user_api_key_auth: Optional[UserAPIKeyAuth] = None, ): """Helper function to get tools for a single server.""" tools = await global_mcp_server_manager._get_tools_from_server( @@ -94,8 +175,58 @@ if MCP_AVAILABLE: if server.allowed_tools is not None and len(server.allowed_tools) > 0: tools = filter_tools_by_allowed_tools(tools, server) + # Filter tools based on user_api_key_auth.object_permission.mcp_tool_permissions + # This provides per-key/team/org control over which tools can be accessed + if ( + user_api_key_auth + and user_api_key_auth.object_permission + and user_api_key_auth.object_permission.mcp_tool_permissions + ): + allowed_tools_for_server = ( + user_api_key_auth.object_permission.mcp_tool_permissions.get( + server.server_id + ) + ) + if ( + allowed_tools_for_server is not None + and len(allowed_tools_for_server) > 0 + ): + # Filter tools to only include those in the allowed list + tools = [ + tool + for tool in tools + if _tool_name_matches(tool.name, allowed_tools_for_server) + ] + return _create_tool_response_objects(tools, server.mcp_info) + async def _resolve_allowed_mcp_servers_for_tool_call( + user_api_key_dict: UserAPIKeyAuth, + server_id: str, + ) -> List[MCPServer]: + """Resolve allowed MCP servers for the given user and validate server_id access.""" + auth_contexts = await build_effective_auth_contexts(user_api_key_dict) + allowed_server_ids_set = set() + for auth_context in auth_contexts: + servers = await global_mcp_server_manager.get_allowed_mcp_servers( + user_api_key_auth=auth_context + ) + allowed_server_ids_set.update(servers) + if server_id not in allowed_server_ids_set: + raise HTTPException( + status_code=403, + detail={ + "error": "access_denied", + "message": f"The key is not allowed to access server {server_id}", + }, + ) + allowed_mcp_servers: List[MCPServer] = [] + for allowed_server_id in allowed_server_ids_set: + server = global_mcp_server_manager.get_mcp_server_by_id(allowed_server_id) + if server is not None: + allowed_mcp_servers.append(server) + return allowed_mcp_servers + ######################################################## @router.get("/tools/list", dependencies=[Depends(user_api_key_auth)]) async def list_tool_rest_api( @@ -142,21 +273,25 @@ if MCP_AVAILABLE: auth_contexts = await build_effective_auth_contexts(user_api_key_dict) + _rest_client_ip = IPAddressUtils.get_mcp_client_ip(request) + allowed_server_ids_set = set() for auth_context in auth_contexts: servers = await global_mcp_server_manager.get_allowed_mcp_servers( - user_api_key_auth=auth_context + user_api_key_auth=auth_context, ) allowed_server_ids_set.update(servers) - allowed_server_ids = list(allowed_server_ids_set) + allowed_server_ids = global_mcp_server_manager.filter_server_ids_by_ip( + list(allowed_server_ids_set), _rest_client_ip + ) list_tools_result = [] error_message = None # If server_id is specified, only query that specific server if server_id: - if server_id not in allowed_server_ids_set: + if server_id not in allowed_server_ids: raise HTTPException( status_code=403, detail={ @@ -178,7 +313,10 @@ if MCP_AVAILABLE: try: list_tools_result = await _get_tools_for_single_server( - server, server_auth_header, raw_headers_from_request + server, + server_auth_header, + raw_headers_from_request, + user_api_key_dict, ) except Exception as e: verbose_logger.exception( @@ -214,7 +352,10 @@ if MCP_AVAILABLE: try: tools_result = await _get_tools_for_single_server( - server, server_auth_header, raw_headers_from_request + server, + server_auth_header, + raw_headers_from_request, + user_api_key_dict, ) list_tools_result.extend(tools_result) except Exception as e: @@ -261,7 +402,14 @@ if MCP_AVAILABLE: from litellm.proxy._experimental.mcp_server.auth.user_api_key_auth_mcp import ( MCPRequestHandler, ) - from litellm.proxy.proxy_server import add_litellm_data_to_request, proxy_config + from litellm.proxy.common_request_processing import ( + ProxyBaseLLMRequestProcessing, + ) + from litellm.proxy.proxy_server import ( + general_settings, + proxy_config, + proxy_logging_obj, + ) try: data = await request.json() @@ -289,28 +437,22 @@ if MCP_AVAILABLE: tool_arguments = data.get("arguments") - data = await add_litellm_data_to_request( - data=data, - request=request, - user_api_key_dict=user_api_key_dict, - proxy_config=proxy_config, + proxy_base_llm_response_processor = ProxyBaseLLMRequestProcessing(data=data) + data, logging_obj = ( + await proxy_base_llm_response_processor.common_processing_pre_call_logic( + request=request, + user_api_key_dict=user_api_key_dict, + proxy_config=proxy_config, + route_type=CallTypes.call_mcp_tool.value, + proxy_logging_obj=proxy_logging_obj, + general_settings=general_settings, + ) ) - # FIX: Extract MCP auth headers from request - # The UI sends bearer token in x-mcp-auth header and server-specific headers, - # but they weren't being extracted and passed to call_mcp_tool. - # This fix ensures auth headers are properly extracted from the HTTP request - # and passed through to the MCP server for authentication. - headers = request.headers - raw_headers_from_request = dict(headers) - mcp_auth_header = MCPRequestHandler._get_mcp_auth_header_from_headers( - headers + # Extract MCP auth headers from request and add to data dict + mcp_auth_header, mcp_server_auth_headers, raw_headers_from_request = ( + _extract_mcp_headers_from_request(request, MCPRequestHandler) ) - mcp_server_auth_headers = ( - MCPRequestHandler._get_mcp_server_auth_headers_from_headers(headers) - ) - - # Add extracted headers to data dict to pass to call_mcp_tool if mcp_auth_header: data["mcp_auth_header"] = mcp_auth_header if mcp_server_auth_headers: @@ -322,35 +464,10 @@ if MCP_AVAILABLE: if "metadata" in data and "user_api_key_auth" in data["metadata"]: data["user_api_key_auth"] = data["metadata"]["user_api_key_auth"] - # Get all auth contexts - auth_contexts = await build_effective_auth_contexts(user_api_key_dict) - - # Collect allowed server IDs from all contexts - allowed_server_ids_set = set() - for auth_context in auth_contexts: - servers = await global_mcp_server_manager.get_allowed_mcp_servers( - user_api_key_auth=auth_context - ) - allowed_server_ids_set.update(servers) - - # Check if the specified server_id is allowed - if server_id not in allowed_server_ids_set: - raise HTTPException( - status_code=403, - detail={ - "error": "access_denied", - "message": f"The key is not allowed to access server {server_id}", - }, - ) - - # Build allowed_mcp_servers list (only include allowed servers) - allowed_mcp_servers: List[MCPServer] = [] - for allowed_server_id in allowed_server_ids_set: - server = global_mcp_server_manager.get_mcp_server_by_id( - allowed_server_id - ) - if server is not None: - allowed_mcp_servers.append(server) + # Resolve allowed MCP servers with IP filtering + allowed_mcp_servers = await _resolve_allowed_mcp_servers_with_ip_filter( + request, user_api_key_dict, server_id + ) # Call execute_mcp_tool directly (permission checks already done) result = await execute_mcp_tool( @@ -411,24 +528,50 @@ if MCP_AVAILABLE: NewMCPServerRequest, ) + def _extract_credentials( + request: NewMCPServerRequest, + ) -> tuple: + """ + Extract OAuth credentials from the nested ``request.credentials`` dict. + + Returns: + (client_id, client_secret, scopes) — any value may be ``None``. + """ + creds = request.credentials if isinstance(request.credentials, dict) else {} + client_id: Optional[str] = creds.get("client_id") + client_secret: Optional[str] = creds.get("client_secret") + scopes_raw = creds.get("scopes") + scopes: Optional[List[str]] = scopes_raw if isinstance(scopes_raw, list) else None + return client_id, client_secret, scopes + async def _execute_with_mcp_client( request: NewMCPServerRequest, - operation, + operation: Callable[..., Awaitable[Any]], mcp_auth_header: Optional[Union[str, Dict[str, str]]] = None, oauth2_headers: Optional[Dict[str, str]] = None, raw_headers: Optional[Dict[str, str]] = None, - ): + ) -> dict: """ - Common helper to create MCP client, execute operation, and ensure proper cleanup. + Create a temporary MCP client from *request*, run *operation*, and return the result. + + For M2M OAuth servers (those with ``client_id``, ``client_secret``, and + ``token_url``), the incoming ``oauth2_headers`` are dropped so that + ``resolve_mcp_auth`` can auto-fetch a token via ``client_credentials``. Args: - request: MCP server configuration - operation: Async function that takes a client and returns the operation result + request: MCP server configuration submitted by the UI. + operation: Async callable that receives the created client and returns a result dict. + mcp_auth_header: Pre-resolved credential header (API-key / bearer token). + oauth2_headers: Headers extracted from the incoming request (may contain the + litellm API key — must NOT be forwarded for M2M servers). + raw_headers: Raw request headers forwarded for stdio env construction. Returns: - Operation result or error response + The dict returned by *operation*, or an error dict on failure. """ try: + client_id, client_secret, scopes = _extract_credentials(request) + server_model = MCPServer( server_id=request.server_id or "", name=request.alias or request.server_name or "", @@ -440,18 +583,30 @@ if MCP_AVAILABLE: args=request.args, env=request.env, static_headers=request.static_headers, + client_id=client_id, + client_secret=client_secret, + token_url=request.token_url, + scopes=scopes, + authorization_url=request.authorization_url, + registration_url=request.registration_url, ) stdio_env = global_mcp_server_manager._build_stdio_env( server_model, raw_headers ) + # For M2M OAuth servers, drop the incoming Authorization header so that + # resolve_mcp_auth can auto-fetch a token via client_credentials. + effective_oauth2_headers = ( + None if server_model.has_client_credentials else oauth2_headers + ) + merged_headers = merge_mcp_headers( - extra_headers=oauth2_headers, + extra_headers=effective_oauth2_headers, static_headers=request.static_headers, ) - client = global_mcp_server_manager._create_mcp_client( + client = await global_mcp_server_manager._create_mcp_client( server=server_model, mcp_auth_header=mcp_auth_header, extra_headers=merged_headers, @@ -460,11 +615,14 @@ if MCP_AVAILABLE: return await operation(client) - except Exception as e: - verbose_logger.error(f"Error in MCP operation: {e}", exc_info=True) + except (KeyboardInterrupt, SystemExit): + raise + except BaseException as e: + verbose_logger.error("Error in MCP operation: %s", e, exc_info=True) return { "status": "error", - "message": "An internal error has occurred while testing the MCP server.", + "error": True, + "message": "Failed to connect to MCP server. Check proxy logs for details.", } @router.post("/test/connection", dependencies=[Depends(user_api_key_auth)]) diff --git a/litellm/proxy/_experimental/mcp_server/server.py b/litellm/proxy/_experimental/mcp_server/server.py index 79cd88227a9..58cd8c99e7b 100644 --- a/litellm/proxy/_experimental/mcp_server/server.py +++ b/litellm/proxy/_experimental/mcp_server/server.py @@ -5,12 +5,24 @@ LiteLLM MCP Server Routes import asyncio import contextlib -from datetime import datetime import traceback import uuid -from typing import Any, AsyncIterator, Dict, List, Optional, Tuple, Union, cast, Callable +from datetime import datetime +from typing import ( + Any, + AsyncIterator, + Callable, + Dict, + List, + Optional, + Tuple, + Union, + cast, +) + from fastapi import FastAPI, HTTPException from pydantic import AnyUrl, ConfigDict +from starlette.requests import Request as StarletteRequest from starlette.types import Receive, Scope, Send from litellm._logging import verbose_logger @@ -19,12 +31,16 @@ from litellm.litellm_core_utils.litellm_logging import Logging as LiteLLMLogging from litellm.proxy._experimental.mcp_server.auth.user_api_key_auth_mcp import ( MCPRequestHandler, ) +from litellm.proxy._experimental.mcp_server.discoverable_endpoints import ( + get_request_base_url, +) from litellm.proxy._experimental.mcp_server.utils import ( LITELLM_MCP_SERVER_DESCRIPTION, LITELLM_MCP_SERVER_NAME, LITELLM_MCP_SERVER_VERSION, ) from litellm.proxy._types import UserAPIKeyAuth +from litellm.proxy.auth.ip_address_utils import IPAddressUtils from litellm.types.mcp import MCPAuth from litellm.types.mcp_server.mcp_server_manager import MCPInfo, MCPServer from litellm.types.utils import CallTypes, StandardLoggingMCPToolCall @@ -213,6 +229,7 @@ if MCP_AVAILABLE: mcp_server_auth_headers, oauth2_headers, raw_headers, + _client_ip, ) = get_auth_context() verbose_logger.debug( f"MCP list_tools - User API Key Auth from context: {user_api_key_auth}" @@ -276,6 +293,7 @@ if MCP_AVAILABLE: mcp_server_auth_headers, oauth2_headers, raw_headers, + _client_ip, ) = get_auth_context() verbose_logger.debug( @@ -288,7 +306,7 @@ if MCP_AVAILABLE: host_token = getattr(host_ctx.meta, 'progressToken', None) if host_token and hasattr(host_ctx, 'session') and host_ctx.session: host_session = host_ctx.session - + async def forward_progress(progress: float, total: float | None): """Forward progress notifications from external MCP to Host""" try: @@ -300,7 +318,7 @@ if MCP_AVAILABLE: verbose_logger.debug(f"Forwarded progress {progress}/{total} to Host") except Exception as e: verbose_logger.error(f"Failed to forward progress to Host: {e}") - + host_progress_callback = forward_progress verbose_logger.debug(f"Host progressToken captured: {host_token[:8]}...") except Exception as e: @@ -387,6 +405,7 @@ if MCP_AVAILABLE: mcp_server_auth_headers, oauth2_headers, raw_headers, + _client_ip, ) = get_auth_context() verbose_logger.debug( f"MCP list_prompts - User API Key Auth from context: {user_api_key_auth}" @@ -440,6 +459,7 @@ if MCP_AVAILABLE: mcp_server_auth_headers, oauth2_headers, raw_headers, + _client_ip, ) = get_auth_context() verbose_logger.debug( @@ -467,6 +487,7 @@ if MCP_AVAILABLE: mcp_server_auth_headers, oauth2_headers, raw_headers, + _client_ip, ) = get_auth_context() verbose_logger.debug( f"MCP list_resources - User API Key Auth from context: {user_api_key_auth}" @@ -505,6 +526,7 @@ if MCP_AVAILABLE: mcp_server_auth_headers, oauth2_headers, raw_headers, + _client_ip, ) = get_auth_context() verbose_logger.debug( f"MCP list_resource_templates - User API Key Auth from context: {user_api_key_auth}" @@ -544,6 +566,7 @@ if MCP_AVAILABLE: mcp_server_auth_headers, oauth2_headers, raw_headers, + _client_ip, ) = get_auth_context() read_resource_result = await mcp_read_resource( @@ -702,13 +725,57 @@ if MCP_AVAILABLE: return tools_to_return + def _get_client_ip_from_context() -> Optional[str]: + """ + Extract client_ip from auth context. + Returns None if context not set (caller should handle this as "no IP filtering"). + """ + try: + auth_user = auth_context_var.get() + if auth_user and isinstance(auth_user, MCPAuthenticatedUser): + return auth_user.client_ip + except Exception: + pass + return None + async def _get_allowed_mcp_servers( user_api_key_auth: Optional[UserAPIKeyAuth], mcp_servers: Optional[List[str]], + client_ip: Optional[str] = None, ) -> List[MCPServer]: - """Return allowed MCP servers for a request after applying filters.""" + """Return allowed MCP servers for a request after applying filters. + + Args: + user_api_key_auth: The authenticated user's API key info. + mcp_servers: Optional list of server names to filter to. + client_ip: Client IP for IP-based access control. If None, falls back to + auth context. Pass explicitly from request handlers for safety. + Note: If client_ip is None and auth context is not set, IP filtering is skipped. + This is intentional for internal callers but may indicate a bug if called + from a request handler without proper context setup. + """ + # Use explicit client_ip if provided, otherwise try auth context + if client_ip is None: + client_ip = _get_client_ip_from_context() + if client_ip is None: + verbose_logger.debug( + "MCP _get_allowed_mcp_servers called without client_ip and no auth context. " + "IP filtering will be skipped. This is expected for internal calls." + ) + allowed_mcp_server_ids = ( - await global_mcp_server_manager.get_allowed_mcp_servers(user_api_key_auth) + await global_mcp_server_manager.get_allowed_mcp_servers( + user_api_key_auth + ) + ) + allowed_mcp_server_ids = ( + global_mcp_server_manager.filter_server_ids_by_ip( + allowed_mcp_server_ids, client_ip + ) + ) + verbose_logger.debug( + "MCP IP filter: client_ip=%s, allowed_server_ids=%s", + client_ip, allowed_mcp_server_ids, ) allowed_mcp_servers: List[MCPServer] = [] for allowed_mcp_server_id in allowed_mcp_server_ids: @@ -1715,7 +1782,7 @@ if MCP_AVAILABLE: oauth2_headers: Optional[Dict[str, str]] = None, raw_headers: Optional[Dict[str, str]] = None, litellm_logging_obj: Optional[Any] = None, - host_progress_callback: Optional[Callable] = None, + host_progress_callback: Optional[Callable] = None, ) -> CallToolResult: """Handle tool execution for managed server tools""" # Import here to avoid circular import @@ -1891,6 +1958,10 @@ if MCP_AVAILABLE: oauth2_headers, raw_headers, ) = await extract_mcp_auth_context(scope, path) + + # Extract client IP for MCP access control + _client_ip = IPAddressUtils.get_mcp_client_ip(StarletteRequest(scope)) + verbose_logger.debug( f"MCP request mcp_servers (header/path): {mcp_servers}" ) @@ -1899,12 +1970,12 @@ if MCP_AVAILABLE: ) # https://datatracker.ietf.org/doc/html/rfc9728#name-www-authenticate-response for server_name in mcp_servers or []: - server = global_mcp_server_manager.get_mcp_server_by_name(server_name) + server = global_mcp_server_manager.get_mcp_server_by_name( + server_name, client_ip=_client_ip + ) if server and server.auth_type == MCPAuth.oauth2 and not oauth2_headers: - from starlette.requests import Request - - request = Request(scope) - base_url = str(request.base_url).rstrip("/") + request = StarletteRequest(scope) + base_url = get_request_base_url(request) authorization_uri = ( f"Bearer authorization_uri=" @@ -1925,6 +1996,7 @@ if MCP_AVAILABLE: mcp_server_auth_headers=mcp_server_auth_headers, oauth2_headers=oauth2_headers, raw_headers=raw_headers, + client_ip=_client_ip, ) # Ensure session managers are initialized @@ -1936,12 +2008,13 @@ if MCP_AVAILABLE: _strip_stale_mcp_session_header(scope, session_manager) await session_manager.handle_request(scope, receive, send) + except HTTPException: + # Re-raise HTTP exceptions to preserve status codes and details + raise except Exception as e: - raise e verbose_logger.exception(f"Error handling MCP request: {e}") - # Instead of re-raising, try to send a graceful error response + # Try to send a graceful error response for non-HTTP exceptions try: - # Send a proper HTTP error response instead of letting the exception bubble up from starlette.responses import JSONResponse from starlette.status import HTTP_500_INTERNAL_SERVER_ERROR @@ -1969,6 +2042,10 @@ if MCP_AVAILABLE: oauth2_headers, raw_headers, ) = await extract_mcp_auth_context(scope, path) + + # Extract client IP for MCP access control + _sse_client_ip = IPAddressUtils.get_mcp_client_ip(StarletteRequest(scope)) + verbose_logger.debug( f"MCP request mcp_servers (header/path): {mcp_servers}" ) @@ -1982,6 +2059,7 @@ if MCP_AVAILABLE: mcp_server_auth_headers=mcp_server_auth_headers, oauth2_headers=oauth2_headers, raw_headers=raw_headers, + client_ip=_sse_client_ip, ) if not _SESSION_MANAGERS_INITIALIZED: @@ -2045,6 +2123,7 @@ if MCP_AVAILABLE: mcp_server_auth_headers: Optional[Dict[str, Dict[str, str]]] = None, oauth2_headers: Optional[Dict[str, str]] = None, raw_headers: Optional[Dict[str, str]] = None, + client_ip: Optional[str] = None, ) -> None: """ Set the UserAPIKeyAuth in the auth context variable. @@ -2054,6 +2133,7 @@ if MCP_AVAILABLE: mcp_auth_header: MCP auth header to be passed to the MCP server (deprecated) mcp_servers: Optional list of server names and access groups to filter by mcp_server_auth_headers: Optional dict of server-specific auth headers {server_alias: auth_value} + client_ip: Client IP address for MCP access control """ auth_user = MCPAuthenticatedUser( user_api_key_auth=user_api_key_auth, @@ -2062,6 +2142,7 @@ if MCP_AVAILABLE: mcp_server_auth_headers=mcp_server_auth_headers, oauth2_headers=oauth2_headers, raw_headers=raw_headers, + client_ip=client_ip, ) auth_context_var.set(auth_user) @@ -2073,14 +2154,15 @@ if MCP_AVAILABLE: Optional[Dict[str, Dict[str, str]]], Optional[Dict[str, str]], Optional[Dict[str, str]], + Optional[str], ] ): """ Get the UserAPIKeyAuth from the auth context variable. Returns: - Tuple[Optional[UserAPIKeyAuth], Optional[str], Optional[List[str]], Optional[Dict[str, str]]]: - UserAPIKeyAuth object, MCP auth header (deprecated), MCP servers (can include access groups), and server-specific auth headers + Tuple containing: UserAPIKeyAuth, MCP auth header (deprecated), + MCP servers, server-specific auth headers, OAuth2 headers, raw headers, client IP """ auth_user = auth_context_var.get() if auth_user and isinstance(auth_user, MCPAuthenticatedUser): @@ -2091,8 +2173,9 @@ if MCP_AVAILABLE: auth_user.mcp_server_auth_headers, auth_user.oauth2_headers, auth_user.raw_headers, + auth_user.client_ip, ) - return None, None, None, None, None, None + return None, None, None, None, None, None, None ######################################################## ############ End of Auth Context Functions ############# diff --git a/litellm/proxy/_experimental/out/404/index.html b/litellm/proxy/_experimental/out/404/index.html index a8bd30680ab..63f46b9c025 100644 --- a/litellm/proxy/_experimental/out/404/index.html +++ b/litellm/proxy/_experimental/out/404/index.html @@ -1 +1 @@ -404: This page could not be found.LiteLLM Dashboard

404

This page could not be found.

\ No newline at end of file +404: This page could not be found.LiteLLM Dashboard

404

This page could not be found.

\ No newline at end of file diff --git a/litellm/proxy/_experimental/out/__next.__PAGE__.txt b/litellm/proxy/_experimental/out/__next.__PAGE__.txt new file mode 100644 index 00000000000..797e7a44c06 --- /dev/null +++ b/litellm/proxy/_experimental/out/__next.__PAGE__.txt @@ -0,0 +1,30 @@ +1:"$Sreact.fragment" +2:I[347257,["/litellm-asset-prefix/_next/static/chunks/d96012bcfc98706a.js","/litellm-asset-prefix/_next/static/chunks/dbca964212122d58.js"],"ClientPageRoot"] +3:I[952683,["/litellm-asset-prefix/_next/static/chunks/26adfa4e8ffc85c7.js","/litellm-asset-prefix/_next/static/chunks/e8ed72789c2b42ff.js","/litellm-asset-prefix/_next/static/chunks/0a6c418370a8c183.js","/litellm-asset-prefix/_next/static/chunks/4cd6ff0dfce62b8e.js","/litellm-asset-prefix/_next/static/chunks/4a4dedb94a06b61d.js","/litellm-asset-prefix/_next/static/chunks/1b1b0930772e484a.js","/litellm-asset-prefix/_next/static/chunks/fbc296c4562eeddc.js","/litellm-asset-prefix/_next/static/chunks/e99e2eb6c969ac42.js","/litellm-asset-prefix/_next/static/chunks/5f9c3b92a016f382.js","/litellm-asset-prefix/_next/static/chunks/e04f5de552319954.js","/litellm-asset-prefix/_next/static/chunks/f56edde1dfbfa5c2.js","/litellm-asset-prefix/_next/static/chunks/403c4d96324c23a6.js","/litellm-asset-prefix/_next/static/chunks/4a74699f9b25ffd8.js","/litellm-asset-prefix/_next/static/chunks/0a671fedee641c02.js","/litellm-asset-prefix/_next/static/chunks/3b30ab8eaa03bc21.js","/litellm-asset-prefix/_next/static/chunks/fe750aa0bf04912c.js","/litellm-asset-prefix/_next/static/chunks/7b788dd93ad868b3.js","/litellm-asset-prefix/_next/static/chunks/d64d74932cb225a3.js","/litellm-asset-prefix/_next/static/chunks/6930557cf99ba2ed.js","/litellm-asset-prefix/_next/static/chunks/95015f87c824f421.js","/litellm-asset-prefix/_next/static/chunks/64f1a2ef9113d86f.js","/litellm-asset-prefix/_next/static/chunks/87a251aeda49f573.js","/litellm-asset-prefix/_next/static/chunks/33b32c9f63756046.js","/litellm-asset-prefix/_next/static/chunks/88c74f8b4b20d25a.js","/litellm-asset-prefix/_next/static/chunks/c52ccee83fcf13d9.js","/litellm-asset-prefix/_next/static/chunks/acb2890475c0e12c.js","/litellm-asset-prefix/_next/static/chunks/18268b188d85d0d8.js","/litellm-asset-prefix/_next/static/chunks/b720ff808b5789ef.js","/litellm-asset-prefix/_next/static/chunks/008c46047ca6ae0a.js","/litellm-asset-prefix/_next/static/chunks/3754e5316d782fdf.js","/litellm-asset-prefix/_next/static/chunks/c4452a79c69324a6.js","/litellm-asset-prefix/_next/static/chunks/7e417dd24c8becd0.js","/litellm-asset-prefix/_next/static/chunks/c7b74067c01ee971.js","/litellm-asset-prefix/_next/static/chunks/e9a81ef6cd35a613.js","/litellm-asset-prefix/_next/static/chunks/4980372eaa37b78b.js","/litellm-asset-prefix/_next/static/chunks/ba3f0517ce70ce68.js","/litellm-asset-prefix/_next/static/chunks/79738bf720f4be4d.js","/litellm-asset-prefix/_next/static/chunks/a5b66d8611aefbcd.js","/litellm-asset-prefix/_next/static/chunks/00ff280cdb7d7ee5.js","/litellm-asset-prefix/_next/static/chunks/0a65da2cd24e2ab6.js","/litellm-asset-prefix/_next/static/chunks/554b4994eea1cb97.js","/litellm-asset-prefix/_next/static/chunks/b32c07bb80491ab6.js","/litellm-asset-prefix/_next/static/chunks/a382857dbbcea5d1.js","/litellm-asset-prefix/_next/static/chunks/0b27adb95e5b531e.js","/litellm-asset-prefix/_next/static/chunks/df9bbd7990a5fafe.js","/litellm-asset-prefix/_next/static/chunks/496b84010c33cf69.js","/litellm-asset-prefix/_next/static/chunks/2971c4658f1bcd7d.js","/litellm-asset-prefix/_next/static/chunks/6c4c97f1ea6e7d77.js","/litellm-asset-prefix/_next/static/chunks/8e1e9d99970e681d.js","/litellm-asset-prefix/_next/static/chunks/8354d717e34ebd6f.js","/litellm-asset-prefix/_next/static/chunks/8927d9c0b6434f68.js","/litellm-asset-prefix/_next/static/chunks/368fa3a0a47b3cb5.js","/litellm-asset-prefix/_next/static/chunks/8fb6b3333e6465c3.js","/litellm-asset-prefix/_next/static/chunks/450ebd094f4fa24d.js","/litellm-asset-prefix/_next/static/chunks/e8aec000aaa33bd3.js"],"default"] +1a:I[897367,["/litellm-asset-prefix/_next/static/chunks/d96012bcfc98706a.js","/litellm-asset-prefix/_next/static/chunks/dbca964212122d58.js"],"OutletBoundary"] +1b:"$Sreact.suspense" +:HL["/litellm-asset-prefix/_next/static/chunks/3f3fa56b5786d58c.css","style"] +0:{"buildId":"5d4yNl8wNnid2iuIZ_SiS","rsc":["$","$1","c",{"children":[["$","$L2",null,{"Component":"$3","serverProvidedParams":{"searchParams":{},"params":{},"promises":["$@4","$@5"]}}],[["$","link","0",{"rel":"stylesheet","href":"/litellm-asset-prefix/_next/static/chunks/3f3fa56b5786d58c.css","precedence":"next"}],["$","script","script-0",{"src":"/litellm-asset-prefix/_next/static/chunks/0a6c418370a8c183.js","async":true}],["$","script","script-1",{"src":"/litellm-asset-prefix/_next/static/chunks/4cd6ff0dfce62b8e.js","async":true}],["$","script","script-2",{"src":"/litellm-asset-prefix/_next/static/chunks/4a4dedb94a06b61d.js","async":true}],["$","script","script-3",{"src":"/litellm-asset-prefix/_next/static/chunks/1b1b0930772e484a.js","async":true}],["$","script","script-4",{"src":"/litellm-asset-prefix/_next/static/chunks/fbc296c4562eeddc.js","async":true}],["$","script","script-5",{"src":"/litellm-asset-prefix/_next/static/chunks/e99e2eb6c969ac42.js","async":true}],["$","script","script-6",{"src":"/litellm-asset-prefix/_next/static/chunks/5f9c3b92a016f382.js","async":true}],["$","script","script-7",{"src":"/litellm-asset-prefix/_next/static/chunks/e04f5de552319954.js","async":true}],["$","script","script-8",{"src":"/litellm-asset-prefix/_next/static/chunks/f56edde1dfbfa5c2.js","async":true}],["$","script","script-9",{"src":"/litellm-asset-prefix/_next/static/chunks/403c4d96324c23a6.js","async":true}],["$","script","script-10",{"src":"/litellm-asset-prefix/_next/static/chunks/4a74699f9b25ffd8.js","async":true}],["$","script","script-11",{"src":"/litellm-asset-prefix/_next/static/chunks/0a671fedee641c02.js","async":true}],["$","script","script-12",{"src":"/litellm-asset-prefix/_next/static/chunks/3b30ab8eaa03bc21.js","async":true}],["$","script","script-13",{"src":"/litellm-asset-prefix/_next/static/chunks/fe750aa0bf04912c.js","async":true}],["$","script","script-14",{"src":"/litellm-asset-prefix/_next/static/chunks/7b788dd93ad868b3.js","async":true}],["$","script","script-15",{"src":"/litellm-asset-prefix/_next/static/chunks/d64d74932cb225a3.js","async":true}],["$","script","script-16",{"src":"/litellm-asset-prefix/_next/static/chunks/6930557cf99ba2ed.js","async":true}],["$","script","script-17",{"src":"/litellm-asset-prefix/_next/static/chunks/95015f87c824f421.js","async":true}],["$","script","script-18",{"src":"/litellm-asset-prefix/_next/static/chunks/64f1a2ef9113d86f.js","async":true}],["$","script","script-19",{"src":"/litellm-asset-prefix/_next/static/chunks/87a251aeda49f573.js","async":true}],["$","script","script-20",{"src":"/litellm-asset-prefix/_next/static/chunks/33b32c9f63756046.js","async":true}],["$","script","script-21",{"src":"/litellm-asset-prefix/_next/static/chunks/88c74f8b4b20d25a.js","async":true}],["$","script","script-22",{"src":"/litellm-asset-prefix/_next/static/chunks/c52ccee83fcf13d9.js","async":true}],["$","script","script-23",{"src":"/litellm-asset-prefix/_next/static/chunks/acb2890475c0e12c.js","async":true}],["$","script","script-24",{"src":"/litellm-asset-prefix/_next/static/chunks/18268b188d85d0d8.js","async":true}],["$","script","script-25",{"src":"/litellm-asset-prefix/_next/static/chunks/b720ff808b5789ef.js","async":true}],["$","script","script-26",{"src":"/litellm-asset-prefix/_next/static/chunks/008c46047ca6ae0a.js","async":true}],["$","script","script-27",{"src":"/litellm-asset-prefix/_next/static/chunks/3754e5316d782fdf.js","async":true}],["$","script","script-28",{"src":"/litellm-asset-prefix/_next/static/chunks/c4452a79c69324a6.js","async":true}],["$","script","script-29",{"src":"/litellm-asset-prefix/_next/static/chunks/7e417dd24c8becd0.js","async":true}],["$","script","script-30",{"src":"/litellm-asset-prefix/_next/static/chunks/c7b74067c01ee971.js","async":true}],["$","script","script-31",{"src":"/litellm-asset-prefix/_next/static/chunks/e9a81ef6cd35a613.js","async":true}],["$","script","script-32",{"src":"/litellm-asset-prefix/_next/static/chunks/4980372eaa37b78b.js","async":true}],["$","script","script-33",{"src":"/litellm-asset-prefix/_next/static/chunks/ba3f0517ce70ce68.js","async":true}],"$L6","$L7","$L8","$L9","$La","$Lb","$Lc","$Ld","$Le","$Lf","$L10","$L11","$L12","$L13","$L14","$L15","$L16","$L17","$L18"],"$L19"]}],"loading":null,"isPartial":false} +4:{} +5:"$0:rsc:props:children:0:props:serverProvidedParams:params" +6:["$","script","script-34",{"src":"/litellm-asset-prefix/_next/static/chunks/79738bf720f4be4d.js","async":true}] +7:["$","script","script-35",{"src":"/litellm-asset-prefix/_next/static/chunks/a5b66d8611aefbcd.js","async":true}] +8:["$","script","script-36",{"src":"/litellm-asset-prefix/_next/static/chunks/00ff280cdb7d7ee5.js","async":true}] +9:["$","script","script-37",{"src":"/litellm-asset-prefix/_next/static/chunks/0a65da2cd24e2ab6.js","async":true}] +a:["$","script","script-38",{"src":"/litellm-asset-prefix/_next/static/chunks/554b4994eea1cb97.js","async":true}] +b:["$","script","script-39",{"src":"/litellm-asset-prefix/_next/static/chunks/b32c07bb80491ab6.js","async":true}] +c:["$","script","script-40",{"src":"/litellm-asset-prefix/_next/static/chunks/a382857dbbcea5d1.js","async":true}] +d:["$","script","script-41",{"src":"/litellm-asset-prefix/_next/static/chunks/0b27adb95e5b531e.js","async":true}] +e:["$","script","script-42",{"src":"/litellm-asset-prefix/_next/static/chunks/df9bbd7990a5fafe.js","async":true}] +f:["$","script","script-43",{"src":"/litellm-asset-prefix/_next/static/chunks/496b84010c33cf69.js","async":true}] +10:["$","script","script-44",{"src":"/litellm-asset-prefix/_next/static/chunks/2971c4658f1bcd7d.js","async":true}] +11:["$","script","script-45",{"src":"/litellm-asset-prefix/_next/static/chunks/6c4c97f1ea6e7d77.js","async":true}] +12:["$","script","script-46",{"src":"/litellm-asset-prefix/_next/static/chunks/8e1e9d99970e681d.js","async":true}] +13:["$","script","script-47",{"src":"/litellm-asset-prefix/_next/static/chunks/8354d717e34ebd6f.js","async":true}] +14:["$","script","script-48",{"src":"/litellm-asset-prefix/_next/static/chunks/8927d9c0b6434f68.js","async":true}] +15:["$","script","script-49",{"src":"/litellm-asset-prefix/_next/static/chunks/368fa3a0a47b3cb5.js","async":true}] +16:["$","script","script-50",{"src":"/litellm-asset-prefix/_next/static/chunks/8fb6b3333e6465c3.js","async":true}] +17:["$","script","script-51",{"src":"/litellm-asset-prefix/_next/static/chunks/450ebd094f4fa24d.js","async":true}] +18:["$","script","script-52",{"src":"/litellm-asset-prefix/_next/static/chunks/e8aec000aaa33bd3.js","async":true}] +19:["$","$L1a",null,{"children":["$","$1b",null,{"name":"Next.MetadataOutlet","children":"$@1c"}]}] +1c:null diff --git a/litellm/proxy/_experimental/out/__next._full.txt b/litellm/proxy/_experimental/out/__next._full.txt new file mode 100644 index 00000000000..1616c04ef15 --- /dev/null +++ b/litellm/proxy/_experimental/out/__next._full.txt @@ -0,0 +1,61 @@ +1:"$Sreact.fragment" +2:I[71195,["/litellm-asset-prefix/_next/static/chunks/26adfa4e8ffc85c7.js","/litellm-asset-prefix/_next/static/chunks/e8ed72789c2b42ff.js"],"default"] +3:I[339756,["/litellm-asset-prefix/_next/static/chunks/d96012bcfc98706a.js","/litellm-asset-prefix/_next/static/chunks/dbca964212122d58.js"],"default"] +4:I[837457,["/litellm-asset-prefix/_next/static/chunks/d96012bcfc98706a.js","/litellm-asset-prefix/_next/static/chunks/dbca964212122d58.js"],"default"] +5:I[347257,["/litellm-asset-prefix/_next/static/chunks/d96012bcfc98706a.js","/litellm-asset-prefix/_next/static/chunks/dbca964212122d58.js"],"ClientPageRoot"] +6:I[952683,["/litellm-asset-prefix/_next/static/chunks/26adfa4e8ffc85c7.js","/litellm-asset-prefix/_next/static/chunks/e8ed72789c2b42ff.js","/litellm-asset-prefix/_next/static/chunks/0a6c418370a8c183.js","/litellm-asset-prefix/_next/static/chunks/4cd6ff0dfce62b8e.js","/litellm-asset-prefix/_next/static/chunks/4a4dedb94a06b61d.js","/litellm-asset-prefix/_next/static/chunks/1b1b0930772e484a.js","/litellm-asset-prefix/_next/static/chunks/fbc296c4562eeddc.js","/litellm-asset-prefix/_next/static/chunks/e99e2eb6c969ac42.js","/litellm-asset-prefix/_next/static/chunks/5f9c3b92a016f382.js","/litellm-asset-prefix/_next/static/chunks/e04f5de552319954.js","/litellm-asset-prefix/_next/static/chunks/f56edde1dfbfa5c2.js","/litellm-asset-prefix/_next/static/chunks/403c4d96324c23a6.js","/litellm-asset-prefix/_next/static/chunks/4a74699f9b25ffd8.js","/litellm-asset-prefix/_next/static/chunks/0a671fedee641c02.js","/litellm-asset-prefix/_next/static/chunks/3b30ab8eaa03bc21.js","/litellm-asset-prefix/_next/static/chunks/fe750aa0bf04912c.js","/litellm-asset-prefix/_next/static/chunks/7b788dd93ad868b3.js","/litellm-asset-prefix/_next/static/chunks/d64d74932cb225a3.js","/litellm-asset-prefix/_next/static/chunks/6930557cf99ba2ed.js","/litellm-asset-prefix/_next/static/chunks/95015f87c824f421.js","/litellm-asset-prefix/_next/static/chunks/64f1a2ef9113d86f.js","/litellm-asset-prefix/_next/static/chunks/87a251aeda49f573.js","/litellm-asset-prefix/_next/static/chunks/33b32c9f63756046.js","/litellm-asset-prefix/_next/static/chunks/88c74f8b4b20d25a.js","/litellm-asset-prefix/_next/static/chunks/c52ccee83fcf13d9.js","/litellm-asset-prefix/_next/static/chunks/acb2890475c0e12c.js","/litellm-asset-prefix/_next/static/chunks/18268b188d85d0d8.js","/litellm-asset-prefix/_next/static/chunks/b720ff808b5789ef.js","/litellm-asset-prefix/_next/static/chunks/008c46047ca6ae0a.js","/litellm-asset-prefix/_next/static/chunks/3754e5316d782fdf.js","/litellm-asset-prefix/_next/static/chunks/c4452a79c69324a6.js","/litellm-asset-prefix/_next/static/chunks/7e417dd24c8becd0.js","/litellm-asset-prefix/_next/static/chunks/c7b74067c01ee971.js","/litellm-asset-prefix/_next/static/chunks/e9a81ef6cd35a613.js","/litellm-asset-prefix/_next/static/chunks/4980372eaa37b78b.js","/litellm-asset-prefix/_next/static/chunks/ba3f0517ce70ce68.js","/litellm-asset-prefix/_next/static/chunks/79738bf720f4be4d.js","/litellm-asset-prefix/_next/static/chunks/a5b66d8611aefbcd.js","/litellm-asset-prefix/_next/static/chunks/00ff280cdb7d7ee5.js","/litellm-asset-prefix/_next/static/chunks/0a65da2cd24e2ab6.js","/litellm-asset-prefix/_next/static/chunks/554b4994eea1cb97.js","/litellm-asset-prefix/_next/static/chunks/b32c07bb80491ab6.js","/litellm-asset-prefix/_next/static/chunks/a382857dbbcea5d1.js","/litellm-asset-prefix/_next/static/chunks/0b27adb95e5b531e.js","/litellm-asset-prefix/_next/static/chunks/df9bbd7990a5fafe.js","/litellm-asset-prefix/_next/static/chunks/496b84010c33cf69.js","/litellm-asset-prefix/_next/static/chunks/2971c4658f1bcd7d.js","/litellm-asset-prefix/_next/static/chunks/6c4c97f1ea6e7d77.js","/litellm-asset-prefix/_next/static/chunks/8e1e9d99970e681d.js","/litellm-asset-prefix/_next/static/chunks/8354d717e34ebd6f.js","/litellm-asset-prefix/_next/static/chunks/8927d9c0b6434f68.js","/litellm-asset-prefix/_next/static/chunks/368fa3a0a47b3cb5.js","/litellm-asset-prefix/_next/static/chunks/8fb6b3333e6465c3.js","/litellm-asset-prefix/_next/static/chunks/450ebd094f4fa24d.js","/litellm-asset-prefix/_next/static/chunks/e8aec000aaa33bd3.js"],"default"] +30:I[168027,[],"default"] +:HL["/litellm-asset-prefix/_next/static/chunks/4e20891f2fd03463.css","style"] +:HL["/litellm-asset-prefix/_next/static/chunks/da873dd93f7630eb.css","style"] +:HL["/litellm-asset-prefix/_next/static/media/83afe278b6a6bb3c-s.p.3a6ba036.woff2","font",{"crossOrigin":"","type":"font/woff2"}] +:HL["/litellm-asset-prefix/_next/static/chunks/3f3fa56b5786d58c.css","style"] +0:{"P":null,"b":"5d4yNl8wNnid2iuIZ_SiS","c":["",""],"q":"","i":false,"f":[[["",{"children":["__PAGE__",{}]},"$undefined","$undefined",true],[["$","$1","c",{"children":[[["$","link","0",{"rel":"stylesheet","href":"/litellm-asset-prefix/_next/static/chunks/4e20891f2fd03463.css","precedence":"next","crossOrigin":"$undefined","nonce":"$undefined"}],["$","link","1",{"rel":"stylesheet","href":"/litellm-asset-prefix/_next/static/chunks/da873dd93f7630eb.css","precedence":"next","crossOrigin":"$undefined","nonce":"$undefined"}],["$","script","script-0",{"src":"/litellm-asset-prefix/_next/static/chunks/26adfa4e8ffc85c7.js","async":true,"nonce":"$undefined"}],["$","script","script-1",{"src":"/litellm-asset-prefix/_next/static/chunks/e8ed72789c2b42ff.js","async":true,"nonce":"$undefined"}]],["$","html",null,{"lang":"en","children":["$","body",null,{"className":"inter_5972bc34-module__OU16Qa__className","children":["$","$L2",null,{"children":["$","$L3",null,{"parallelRouterKey":"children","error":"$undefined","errorStyles":"$undefined","errorScripts":"$undefined","template":["$","$L4",null,{}],"templateStyles":"$undefined","templateScripts":"$undefined","notFound":[[["$","title",null,{"children":"404: This page could not be found."}],["$","div",null,{"style":{"fontFamily":"system-ui,\"Segoe UI\",Roboto,Helvetica,Arial,sans-serif,\"Apple Color Emoji\",\"Segoe UI Emoji\"","height":"100vh","textAlign":"center","display":"flex","flexDirection":"column","alignItems":"center","justifyContent":"center"},"children":["$","div",null,{"children":[["$","style",null,{"dangerouslySetInnerHTML":{"__html":"body{color:#000;background:#fff;margin:0}.next-error-h1{border-right:1px solid rgba(0,0,0,.3)}@media (prefers-color-scheme:dark){body{color:#fff;background:#000}.next-error-h1{border-right:1px solid rgba(255,255,255,.3)}}"}}],["$","h1",null,{"className":"next-error-h1","style":{"display":"inline-block","margin":"0 20px 0 0","padding":"0 23px 0 0","fontSize":24,"fontWeight":500,"verticalAlign":"top","lineHeight":"49px"},"children":404}],["$","div",null,{"style":{"display":"inline-block"},"children":["$","h2",null,{"style":{"fontSize":14,"fontWeight":400,"lineHeight":"49px","margin":0},"children":"This page could not be found."}]}]]}]}]],[]],"forbidden":"$undefined","unauthorized":"$undefined"}]}]}]}]]}],{"children":[["$","$1","c",{"children":[["$","$L5",null,{"Component":"$6","serverProvidedParams":{"searchParams":{},"params":{},"promises":["$@7","$@8"]}}],[["$","link","0",{"rel":"stylesheet","href":"/litellm-asset-prefix/_next/static/chunks/3f3fa56b5786d58c.css","precedence":"next","crossOrigin":"$undefined","nonce":"$undefined"}],["$","script","script-0",{"src":"/litellm-asset-prefix/_next/static/chunks/0a6c418370a8c183.js","async":true,"nonce":"$undefined"}],["$","script","script-1",{"src":"/litellm-asset-prefix/_next/static/chunks/4cd6ff0dfce62b8e.js","async":true,"nonce":"$undefined"}],["$","script","script-2",{"src":"/litellm-asset-prefix/_next/static/chunks/4a4dedb94a06b61d.js","async":true,"nonce":"$undefined"}],["$","script","script-3",{"src":"/litellm-asset-prefix/_next/static/chunks/1b1b0930772e484a.js","async":true,"nonce":"$undefined"}],["$","script","script-4",{"src":"/litellm-asset-prefix/_next/static/chunks/fbc296c4562eeddc.js","async":true,"nonce":"$undefined"}],["$","script","script-5",{"src":"/litellm-asset-prefix/_next/static/chunks/e99e2eb6c969ac42.js","async":true,"nonce":"$undefined"}],["$","script","script-6",{"src":"/litellm-asset-prefix/_next/static/chunks/5f9c3b92a016f382.js","async":true,"nonce":"$undefined"}],["$","script","script-7",{"src":"/litellm-asset-prefix/_next/static/chunks/e04f5de552319954.js","async":true,"nonce":"$undefined"}],["$","script","script-8",{"src":"/litellm-asset-prefix/_next/static/chunks/f56edde1dfbfa5c2.js","async":true,"nonce":"$undefined"}],["$","script","script-9",{"src":"/litellm-asset-prefix/_next/static/chunks/403c4d96324c23a6.js","async":true,"nonce":"$undefined"}],["$","script","script-10",{"src":"/litellm-asset-prefix/_next/static/chunks/4a74699f9b25ffd8.js","async":true,"nonce":"$undefined"}],["$","script","script-11",{"src":"/litellm-asset-prefix/_next/static/chunks/0a671fedee641c02.js","async":true,"nonce":"$undefined"}],["$","script","script-12",{"src":"/litellm-asset-prefix/_next/static/chunks/3b30ab8eaa03bc21.js","async":true,"nonce":"$undefined"}],["$","script","script-13",{"src":"/litellm-asset-prefix/_next/static/chunks/fe750aa0bf04912c.js","async":true,"nonce":"$undefined"}],["$","script","script-14",{"src":"/litellm-asset-prefix/_next/static/chunks/7b788dd93ad868b3.js","async":true,"nonce":"$undefined"}],["$","script","script-15",{"src":"/litellm-asset-prefix/_next/static/chunks/d64d74932cb225a3.js","async":true,"nonce":"$undefined"}],"$L9","$La","$Lb","$Lc","$Ld","$Le","$Lf","$L10","$L11","$L12","$L13","$L14","$L15","$L16","$L17","$L18","$L19","$L1a","$L1b","$L1c","$L1d","$L1e","$L1f","$L20","$L21","$L22","$L23","$L24","$L25","$L26","$L27","$L28","$L29","$L2a","$L2b","$L2c","$L2d"],"$L2e"]}],{},null,false,false]},null,false,false],"$L2f",false]],"m":"$undefined","G":["$30",[]],"S":true} +31:I[897367,["/litellm-asset-prefix/_next/static/chunks/d96012bcfc98706a.js","/litellm-asset-prefix/_next/static/chunks/dbca964212122d58.js"],"OutletBoundary"] +32:"$Sreact.suspense" +34:I[897367,["/litellm-asset-prefix/_next/static/chunks/d96012bcfc98706a.js","/litellm-asset-prefix/_next/static/chunks/dbca964212122d58.js"],"ViewportBoundary"] +36:I[897367,["/litellm-asset-prefix/_next/static/chunks/d96012bcfc98706a.js","/litellm-asset-prefix/_next/static/chunks/dbca964212122d58.js"],"MetadataBoundary"] +9:["$","script","script-16",{"src":"/litellm-asset-prefix/_next/static/chunks/6930557cf99ba2ed.js","async":true,"nonce":"$undefined"}] +a:["$","script","script-17",{"src":"/litellm-asset-prefix/_next/static/chunks/95015f87c824f421.js","async":true,"nonce":"$undefined"}] +b:["$","script","script-18",{"src":"/litellm-asset-prefix/_next/static/chunks/64f1a2ef9113d86f.js","async":true,"nonce":"$undefined"}] +c:["$","script","script-19",{"src":"/litellm-asset-prefix/_next/static/chunks/87a251aeda49f573.js","async":true,"nonce":"$undefined"}] +d:["$","script","script-20",{"src":"/litellm-asset-prefix/_next/static/chunks/33b32c9f63756046.js","async":true,"nonce":"$undefined"}] +e:["$","script","script-21",{"src":"/litellm-asset-prefix/_next/static/chunks/88c74f8b4b20d25a.js","async":true,"nonce":"$undefined"}] +f:["$","script","script-22",{"src":"/litellm-asset-prefix/_next/static/chunks/c52ccee83fcf13d9.js","async":true,"nonce":"$undefined"}] +10:["$","script","script-23",{"src":"/litellm-asset-prefix/_next/static/chunks/acb2890475c0e12c.js","async":true,"nonce":"$undefined"}] +11:["$","script","script-24",{"src":"/litellm-asset-prefix/_next/static/chunks/18268b188d85d0d8.js","async":true,"nonce":"$undefined"}] +12:["$","script","script-25",{"src":"/litellm-asset-prefix/_next/static/chunks/b720ff808b5789ef.js","async":true,"nonce":"$undefined"}] +13:["$","script","script-26",{"src":"/litellm-asset-prefix/_next/static/chunks/008c46047ca6ae0a.js","async":true,"nonce":"$undefined"}] +14:["$","script","script-27",{"src":"/litellm-asset-prefix/_next/static/chunks/3754e5316d782fdf.js","async":true,"nonce":"$undefined"}] +15:["$","script","script-28",{"src":"/litellm-asset-prefix/_next/static/chunks/c4452a79c69324a6.js","async":true,"nonce":"$undefined"}] +16:["$","script","script-29",{"src":"/litellm-asset-prefix/_next/static/chunks/7e417dd24c8becd0.js","async":true,"nonce":"$undefined"}] +17:["$","script","script-30",{"src":"/litellm-asset-prefix/_next/static/chunks/c7b74067c01ee971.js","async":true,"nonce":"$undefined"}] +18:["$","script","script-31",{"src":"/litellm-asset-prefix/_next/static/chunks/e9a81ef6cd35a613.js","async":true,"nonce":"$undefined"}] +19:["$","script","script-32",{"src":"/litellm-asset-prefix/_next/static/chunks/4980372eaa37b78b.js","async":true,"nonce":"$undefined"}] +1a:["$","script","script-33",{"src":"/litellm-asset-prefix/_next/static/chunks/ba3f0517ce70ce68.js","async":true,"nonce":"$undefined"}] +1b:["$","script","script-34",{"src":"/litellm-asset-prefix/_next/static/chunks/79738bf720f4be4d.js","async":true,"nonce":"$undefined"}] +1c:["$","script","script-35",{"src":"/litellm-asset-prefix/_next/static/chunks/a5b66d8611aefbcd.js","async":true,"nonce":"$undefined"}] +1d:["$","script","script-36",{"src":"/litellm-asset-prefix/_next/static/chunks/00ff280cdb7d7ee5.js","async":true,"nonce":"$undefined"}] +1e:["$","script","script-37",{"src":"/litellm-asset-prefix/_next/static/chunks/0a65da2cd24e2ab6.js","async":true,"nonce":"$undefined"}] +1f:["$","script","script-38",{"src":"/litellm-asset-prefix/_next/static/chunks/554b4994eea1cb97.js","async":true,"nonce":"$undefined"}] +20:["$","script","script-39",{"src":"/litellm-asset-prefix/_next/static/chunks/b32c07bb80491ab6.js","async":true,"nonce":"$undefined"}] +21:["$","script","script-40",{"src":"/litellm-asset-prefix/_next/static/chunks/a382857dbbcea5d1.js","async":true,"nonce":"$undefined"}] +22:["$","script","script-41",{"src":"/litellm-asset-prefix/_next/static/chunks/0b27adb95e5b531e.js","async":true,"nonce":"$undefined"}] +23:["$","script","script-42",{"src":"/litellm-asset-prefix/_next/static/chunks/df9bbd7990a5fafe.js","async":true,"nonce":"$undefined"}] +24:["$","script","script-43",{"src":"/litellm-asset-prefix/_next/static/chunks/496b84010c33cf69.js","async":true,"nonce":"$undefined"}] +25:["$","script","script-44",{"src":"/litellm-asset-prefix/_next/static/chunks/2971c4658f1bcd7d.js","async":true,"nonce":"$undefined"}] +26:["$","script","script-45",{"src":"/litellm-asset-prefix/_next/static/chunks/6c4c97f1ea6e7d77.js","async":true,"nonce":"$undefined"}] +27:["$","script","script-46",{"src":"/litellm-asset-prefix/_next/static/chunks/8e1e9d99970e681d.js","async":true,"nonce":"$undefined"}] +28:["$","script","script-47",{"src":"/litellm-asset-prefix/_next/static/chunks/8354d717e34ebd6f.js","async":true,"nonce":"$undefined"}] +29:["$","script","script-48",{"src":"/litellm-asset-prefix/_next/static/chunks/8927d9c0b6434f68.js","async":true,"nonce":"$undefined"}] +2a:["$","script","script-49",{"src":"/litellm-asset-prefix/_next/static/chunks/368fa3a0a47b3cb5.js","async":true,"nonce":"$undefined"}] +2b:["$","script","script-50",{"src":"/litellm-asset-prefix/_next/static/chunks/8fb6b3333e6465c3.js","async":true,"nonce":"$undefined"}] +2c:["$","script","script-51",{"src":"/litellm-asset-prefix/_next/static/chunks/450ebd094f4fa24d.js","async":true,"nonce":"$undefined"}] +2d:["$","script","script-52",{"src":"/litellm-asset-prefix/_next/static/chunks/e8aec000aaa33bd3.js","async":true,"nonce":"$undefined"}] +2e:["$","$L31",null,{"children":["$","$32",null,{"name":"Next.MetadataOutlet","children":"$@33"}]}] +2f:["$","$1","h",{"children":[null,["$","$L34",null,{"children":"$L35"}],["$","div",null,{"hidden":true,"children":["$","$L36",null,{"children":["$","$32",null,{"name":"Next.Metadata","children":"$L37"}]}]}],["$","meta",null,{"name":"next-size-adjust","content":""}]]}] +7:{} +8:"$0:f:0:1:1:children:0:props:children:0:props:serverProvidedParams:params" +35:[["$","meta","0",{"charSet":"utf-8"}],["$","meta","1",{"name":"viewport","content":"width=device-width, initial-scale=1"}]] +38:I[27201,["/litellm-asset-prefix/_next/static/chunks/d96012bcfc98706a.js","/litellm-asset-prefix/_next/static/chunks/dbca964212122d58.js"],"IconMark"] +33:null +37:[["$","title","0",{"children":"LiteLLM Dashboard"}],["$","meta","1",{"name":"description","content":"LiteLLM Proxy Admin UI"}],["$","link","2",{"rel":"icon","href":"/favicon.ico?favicon.1d32c690.ico","sizes":"48x48","type":"image/x-icon"}],["$","link","3",{"rel":"icon","href":"./favicon.ico"}],["$","$L38","4",{}]] diff --git a/litellm/proxy/_experimental/out/__next._head.txt b/litellm/proxy/_experimental/out/__next._head.txt new file mode 100644 index 00000000000..1584b554081 --- /dev/null +++ b/litellm/proxy/_experimental/out/__next._head.txt @@ -0,0 +1,6 @@ +1:"$Sreact.fragment" +2:I[897367,["/litellm-asset-prefix/_next/static/chunks/d96012bcfc98706a.js","/litellm-asset-prefix/_next/static/chunks/dbca964212122d58.js"],"ViewportBoundary"] +3:I[897367,["/litellm-asset-prefix/_next/static/chunks/d96012bcfc98706a.js","/litellm-asset-prefix/_next/static/chunks/dbca964212122d58.js"],"MetadataBoundary"] +4:"$Sreact.suspense" +5:I[27201,["/litellm-asset-prefix/_next/static/chunks/d96012bcfc98706a.js","/litellm-asset-prefix/_next/static/chunks/dbca964212122d58.js"],"IconMark"] +0:{"buildId":"5d4yNl8wNnid2iuIZ_SiS","rsc":["$","$1","h",{"children":[null,["$","$L2",null,{"children":[["$","meta","0",{"charSet":"utf-8"}],["$","meta","1",{"name":"viewport","content":"width=device-width, initial-scale=1"}]]}],["$","div",null,{"hidden":true,"children":["$","$L3",null,{"children":["$","$4",null,{"name":"Next.Metadata","children":[["$","title","0",{"children":"LiteLLM Dashboard"}],["$","meta","1",{"name":"description","content":"LiteLLM Proxy Admin UI"}],["$","link","2",{"rel":"icon","href":"/favicon.ico?favicon.1d32c690.ico","sizes":"48x48","type":"image/x-icon"}],["$","link","3",{"rel":"icon","href":"./favicon.ico"}],["$","$L5","4",{}]]}]}]}],["$","meta",null,{"name":"next-size-adjust","content":""}]]}],"loading":null,"isPartial":false} diff --git a/litellm/proxy/_experimental/out/__next._index.txt b/litellm/proxy/_experimental/out/__next._index.txt new file mode 100644 index 00000000000..3962191aa52 --- /dev/null +++ b/litellm/proxy/_experimental/out/__next._index.txt @@ -0,0 +1,7 @@ +1:"$Sreact.fragment" +2:I[71195,["/litellm-asset-prefix/_next/static/chunks/26adfa4e8ffc85c7.js","/litellm-asset-prefix/_next/static/chunks/e8ed72789c2b42ff.js"],"default"] +3:I[339756,["/litellm-asset-prefix/_next/static/chunks/d96012bcfc98706a.js","/litellm-asset-prefix/_next/static/chunks/dbca964212122d58.js"],"default"] +4:I[837457,["/litellm-asset-prefix/_next/static/chunks/d96012bcfc98706a.js","/litellm-asset-prefix/_next/static/chunks/dbca964212122d58.js"],"default"] +:HL["/litellm-asset-prefix/_next/static/chunks/4e20891f2fd03463.css","style"] +:HL["/litellm-asset-prefix/_next/static/chunks/da873dd93f7630eb.css","style"] +0:{"buildId":"5d4yNl8wNnid2iuIZ_SiS","rsc":["$","$1","c",{"children":[[["$","link","0",{"rel":"stylesheet","href":"/litellm-asset-prefix/_next/static/chunks/4e20891f2fd03463.css","precedence":"next"}],["$","link","1",{"rel":"stylesheet","href":"/litellm-asset-prefix/_next/static/chunks/da873dd93f7630eb.css","precedence":"next"}],["$","script","script-0",{"src":"/litellm-asset-prefix/_next/static/chunks/26adfa4e8ffc85c7.js","async":true}],["$","script","script-1",{"src":"/litellm-asset-prefix/_next/static/chunks/e8ed72789c2b42ff.js","async":true}]],["$","html",null,{"lang":"en","children":["$","body",null,{"className":"inter_5972bc34-module__OU16Qa__className","children":["$","$L2",null,{"children":["$","$L3",null,{"parallelRouterKey":"children","template":["$","$L4",null,{}],"notFound":[[["$","title",null,{"children":"404: This page could not be found."}],["$","div",null,{"style":{"fontFamily":"system-ui,\"Segoe UI\",Roboto,Helvetica,Arial,sans-serif,\"Apple Color Emoji\",\"Segoe UI Emoji\"","height":"100vh","textAlign":"center","display":"flex","flexDirection":"column","alignItems":"center","justifyContent":"center"},"children":["$","div",null,{"children":[["$","style",null,{"dangerouslySetInnerHTML":{"__html":"body{color:#000;background:#fff;margin:0}.next-error-h1{border-right:1px solid rgba(0,0,0,.3)}@media (prefers-color-scheme:dark){body{color:#fff;background:#000}.next-error-h1{border-right:1px solid rgba(255,255,255,.3)}}"}}],["$","h1",null,{"className":"next-error-h1","style":{"display":"inline-block","margin":"0 20px 0 0","padding":"0 23px 0 0","fontSize":24,"fontWeight":500,"verticalAlign":"top","lineHeight":"49px"},"children":404}],["$","div",null,{"style":{"display":"inline-block"},"children":["$","h2",null,{"style":{"fontSize":14,"fontWeight":400,"lineHeight":"49px","margin":0},"children":"This page could not be found."}]}]]}]}]],[]]}]}]}]}]]}],"loading":null,"isPartial":false} diff --git a/litellm/proxy/_experimental/out/__next._tree.txt b/litellm/proxy/_experimental/out/__next._tree.txt new file mode 100644 index 00000000000..c7254dbd6b0 --- /dev/null +++ b/litellm/proxy/_experimental/out/__next._tree.txt @@ -0,0 +1,5 @@ +:HL["/litellm-asset-prefix/_next/static/chunks/4e20891f2fd03463.css","style"] +:HL["/litellm-asset-prefix/_next/static/chunks/da873dd93f7630eb.css","style"] +:HL["/litellm-asset-prefix/_next/static/media/83afe278b6a6bb3c-s.p.3a6ba036.woff2","font",{"crossOrigin":"","type":"font/woff2"}] +:HL["/litellm-asset-prefix/_next/static/chunks/3f3fa56b5786d58c.css","style"] +0:{"buildId":"5d4yNl8wNnid2iuIZ_SiS","tree":{"name":"","paramType":null,"paramKey":"","hasRuntimePrefetch":false,"slots":{"children":{"name":"__PAGE__","paramType":null,"paramKey":"__PAGE__","hasRuntimePrefetch":false,"slots":null,"isRootLayout":false}},"isRootLayout":true},"staleTime":300} diff --git a/litellm/proxy/_experimental/out/_next/static/5d4yNl8wNnid2iuIZ_SiS/_buildManifest.js b/litellm/proxy/_experimental/out/_next/static/5d4yNl8wNnid2iuIZ_SiS/_buildManifest.js new file mode 100644 index 00000000000..d74e1661bbe --- /dev/null +++ b/litellm/proxy/_experimental/out/_next/static/5d4yNl8wNnid2iuIZ_SiS/_buildManifest.js @@ -0,0 +1,16 @@ +self.__BUILD_MANIFEST = { + "__rewrites": { + "afterFiles": [], + "beforeFiles": [ + { + "source": "/litellm-asset-prefix/_next/:path+", + "destination": "/_next/:path+" + } + ], + "fallback": [] + }, + "sortedPages": [ + "/_app", + "/_error" + ] +};self.__BUILD_MANIFEST_CB && self.__BUILD_MANIFEST_CB() \ No newline at end of file diff --git a/litellm/proxy/_experimental/out/_next/static/5d4yNl8wNnid2iuIZ_SiS/_clientMiddlewareManifest.json b/litellm/proxy/_experimental/out/_next/static/5d4yNl8wNnid2iuIZ_SiS/_clientMiddlewareManifest.json new file mode 100644 index 00000000000..0637a088a01 --- /dev/null +++ b/litellm/proxy/_experimental/out/_next/static/5d4yNl8wNnid2iuIZ_SiS/_clientMiddlewareManifest.json @@ -0,0 +1 @@ +[] \ No newline at end of file diff --git a/litellm/proxy/_experimental/out/_next/static/MkHZcSjEBwlJY7dIHtt6n/_ssgManifest.js b/litellm/proxy/_experimental/out/_next/static/5d4yNl8wNnid2iuIZ_SiS/_ssgManifest.js similarity index 100% rename from litellm/proxy/_experimental/out/_next/static/MkHZcSjEBwlJY7dIHtt6n/_ssgManifest.js rename to litellm/proxy/_experimental/out/_next/static/5d4yNl8wNnid2iuIZ_SiS/_ssgManifest.js diff --git a/litellm/proxy/_experimental/out/_next/static/MkHZcSjEBwlJY7dIHtt6n/_buildManifest.js b/litellm/proxy/_experimental/out/_next/static/MkHZcSjEBwlJY7dIHtt6n/_buildManifest.js deleted file mode 100644 index 1b732be87b0..00000000000 --- a/litellm/proxy/_experimental/out/_next/static/MkHZcSjEBwlJY7dIHtt6n/_buildManifest.js +++ /dev/null @@ -1 +0,0 @@ -self.__BUILD_MANIFEST={__rewrites:{afterFiles:[],beforeFiles:[],fallback:[]},"/_error":["static/chunks/pages/_error-cf5ca766ac8f493f.js"],sortedPages:["/_app","/_error"]},self.__BUILD_MANIFEST_CB&&self.__BUILD_MANIFEST_CB(); \ No newline at end of file diff --git a/litellm/proxy/_experimental/out/_next/static/chunks/008c46047ca6ae0a.js b/litellm/proxy/_experimental/out/_next/static/chunks/008c46047ca6ae0a.js new file mode 100644 index 00000000000..79342f7a52d --- /dev/null +++ b/litellm/proxy/_experimental/out/_next/static/chunks/008c46047ca6ae0a.js @@ -0,0 +1,55 @@ +(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,38243,908286,e=>{"use strict";e.i(247167);var t=e.i(271645),o=e.i(343794),n=e.i(876556);function i(e){return["small","middle","large"].includes(e)}function r(e){return!!e&&"number"==typeof e&&!Number.isNaN(e)}e.s(["isPresetSize",()=>i,"isValidGapNumber",()=>r],908286);var l=e.i(242064),a=e.i(249616),d=e.i(372409),s=e.i(246422);let c=(0,s.genStyleHooks)(["Space","Addon"],e=>[(e=>{let{componentCls:t,borderRadius:o,paddingSM:n,colorBorder:i,paddingXS:r,fontSizeLG:l,fontSizeSM:a,borderRadiusLG:s,borderRadiusSM:c,colorBgContainerDisabled:u,lineWidth:m}=e;return{[t]:[{display:"inline-flex",alignItems:"center",gap:0,paddingInline:n,margin:0,background:u,borderWidth:m,borderStyle:"solid",borderColor:i,borderRadius:o,"&-large":{fontSize:l,borderRadius:s},"&-small":{paddingInline:r,borderRadius:c,fontSize:a},"&-compact-last-item":{borderEndStartRadius:0,borderStartStartRadius:0},"&-compact-first-item":{borderEndEndRadius:0,borderStartEndRadius:0},"&-compact-item:not(:first-child):not(:last-child)":{borderRadius:0},"&-compact-item:not(:last-child)":{borderInlineEndWidth:0}},(0,d.genCompactItemStyle)(e,{focus:!1})]}})(e)]);var u=function(e,t){var o={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&0>t.indexOf(n)&&(o[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols)for(var i=0,n=Object.getOwnPropertySymbols(e);it.indexOf(n[i])&&Object.prototype.propertyIsEnumerable.call(e,n[i])&&(o[n[i]]=e[n[i]]);return o};let m=t.default.forwardRef((e,n)=>{let{className:i,children:r,style:d,prefixCls:s}=e,m=u(e,["className","children","style","prefixCls"]),{getPrefixCls:p,direction:g}=t.default.useContext(l.ConfigContext),b=p("space-addon",s),[$,f,v]=c(b),{compactItemClassnames:h,compactSize:y}=(0,a.useCompactItemContext)(b,g),x=(0,o.default)(b,f,h,v,{[`${b}-${y}`]:y},i);return $(t.default.createElement("div",Object.assign({ref:n,className:x,style:d},m),r))}),p=t.default.createContext({latestIndex:0}),g=p.Provider,b=({className:e,index:o,children:n,split:i,style:r})=>{let{latestIndex:l}=t.useContext(p);return null==n?null:t.createElement(t.Fragment,null,t.createElement("div",{className:e,style:r},n),o{let t=(0,$.mergeToken)(e,{spaceGapSmallSize:e.paddingXS,spaceGapMiddleSize:e.padding,spaceGapLargeSize:e.paddingLG});return[(e=>{let{componentCls:t,antCls:o}=e;return{[t]:{display:"inline-flex","&-rtl":{direction:"rtl"},"&-vertical":{flexDirection:"column"},"&-align":{flexDirection:"column","&-center":{alignItems:"center"},"&-start":{alignItems:"flex-start"},"&-end":{alignItems:"flex-end"},"&-baseline":{alignItems:"baseline"}},[`${t}-item:empty`]:{display:"none"},[`${t}-item > ${o}-badge-not-a-wrapper:only-child`]:{display:"block"}}}})(t),(e=>{let{componentCls:t}=e;return{[t]:{"&-gap-row-small":{rowGap:e.spaceGapSmallSize},"&-gap-row-middle":{rowGap:e.spaceGapMiddleSize},"&-gap-row-large":{rowGap:e.spaceGapLargeSize},"&-gap-col-small":{columnGap:e.spaceGapSmallSize},"&-gap-col-middle":{columnGap:e.spaceGapMiddleSize},"&-gap-col-large":{columnGap:e.spaceGapLargeSize}}}})(t)]},()=>({}),{resetStyle:!1});var v=function(e,t){var o={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&0>t.indexOf(n)&&(o[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols)for(var i=0,n=Object.getOwnPropertySymbols(e);it.indexOf(n[i])&&Object.prototype.propertyIsEnumerable.call(e,n[i])&&(o[n[i]]=e[n[i]]);return o};let h=t.forwardRef((e,a)=>{var d;let{getPrefixCls:s,direction:c,size:u,className:m,style:p,classNames:$,styles:h}=(0,l.useComponentConfig)("space"),{size:y=null!=u?u:"small",align:x,className:C,rootClassName:I,children:S,direction:w="horizontal",prefixCls:O,split:B,style:k,wrap:E=!1,classNames:z,styles:j}=e,H=v(e,["size","align","className","rootClassName","children","direction","prefixCls","split","style","wrap","classNames","styles"]),[N,T]=Array.isArray(y)?y:[y,y],R=i(T),P=i(N),M=r(T),A=r(N),D=(0,n.default)(S,{keepEmpty:!0}),L=void 0===x&&"horizontal"===w?"center":x,W=s("space",O),[G,q,X]=f(W),F=(0,o.default)(W,m,q,`${W}-${w}`,{[`${W}-rtl`]:"rtl"===c,[`${W}-align-${L}`]:L,[`${W}-gap-row-${T}`]:R,[`${W}-gap-col-${N}`]:P},C,I,X),Y=(0,o.default)(`${W}-item`,null!=(d=null==z?void 0:z.item)?d:$.item),_=Object.assign(Object.assign({},h.item),null==j?void 0:j.item),V=D.map((e,o)=>{let n=(null==e?void 0:e.key)||`${Y}-${o}`;return t.createElement(b,{className:Y,key:n,index:o,split:B,style:_},e)}),U=t.useMemo(()=>({latestIndex:D.reduce((e,t,o)=>null!=t?o:e,0)}),[D]);if(0===D.length)return null;let Z={};return E&&(Z.flexWrap="wrap"),!P&&A&&(Z.columnGap=N),!R&&M&&(Z.rowGap=T),G(t.createElement("div",Object.assign({ref:a,className:F,style:Object.assign(Object.assign(Object.assign({},Z),p),k)},H),t.createElement(g,{value:U},V)))});h.Compact=a.default,h.Addon=m,e.s(["default",0,h],38243)},801312,e=>{"use strict";e.i(247167);var t=e.i(931067),o=e.i(271645);let n={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M724 218.3V141c0-6.7-7.7-10.4-12.9-6.3L260.3 486.8a31.86 31.86 0 000 50.3l450.8 352.1c5.3 4.1 12.9.4 12.9-6.3v-77.3c0-4.9-2.3-9.6-6.1-12.6l-360-281 360-281.1c3.8-3 6.1-7.7 6.1-12.6z"}}]},name:"left",theme:"outlined"};var i=e.i(9583),r=o.forwardRef(function(e,r){return o.createElement(i.default,(0,t.default)({},e,{ref:r,icon:n}))});e.s(["default",0,r],801312)},704914,e=>{"use strict";let t=e.i(271645).createContext({siderHook:{addSider:()=>null,removeSider:()=>null}});e.s(["LayoutContext",0,t])},741273,e=>{"use strict";e.i(247167);var t=e.i(931067),o=e.i(271645);let n={icon:{tag:"svg",attrs:{viewBox:"0 0 1024 1024",focusable:"false"},children:[{tag:"path",attrs:{d:"M912 192H328c-4.4 0-8 3.6-8 8v56c0 4.4 3.6 8 8 8h584c4.4 0 8-3.6 8-8v-56c0-4.4-3.6-8-8-8zm0 284H328c-4.4 0-8 3.6-8 8v56c0 4.4 3.6 8 8 8h584c4.4 0 8-3.6 8-8v-56c0-4.4-3.6-8-8-8zm0 284H328c-4.4 0-8 3.6-8 8v56c0 4.4 3.6 8 8 8h584c4.4 0 8-3.6 8-8v-56c0-4.4-3.6-8-8-8zM104 228a56 56 0 10112 0 56 56 0 10-112 0zm0 284a56 56 0 10112 0 56 56 0 10-112 0zm0 284a56 56 0 10112 0 56 56 0 10-112 0z"}}]},name:"bars",theme:"outlined"};var i=e.i(9583),r=o.forwardRef(function(e,r){return o.createElement(i.default,(0,t.default)({},e,{ref:r,icon:n}))});e.s(["default",0,r],741273)},290224,251224,e=>{"use strict";let t;e.i(247167);var o=e.i(271645),n=e.i(741273),i=e.i(801312),r=e.i(286612),l=e.i(343794),a=e.i(529681),d=e.i(958503),s=e.i(242064),c=e.i(704914);e.i(296059);var u=e.i(915654),m=e.i(246422);let p=e=>{let{colorBgLayout:t,controlHeight:o,controlHeightLG:n,colorText:i,controlHeightSM:r,marginXXS:l,colorTextLightSolid:a,colorBgContainer:d}=e,s=1.25*n;return{colorBgHeader:"#001529",colorBgBody:t,colorBgTrigger:"#002140",bodyBg:t,headerBg:"#001529",headerHeight:2*o,headerPadding:`0 ${s}px`,headerColor:i,footerPadding:`${r}px ${s}px`,footerBg:t,siderBg:"#001529",triggerHeight:n+2*l,triggerBg:"#002140",triggerColor:a,zeroTriggerWidth:n,zeroTriggerHeight:n,lightSiderBg:d,lightTriggerBg:d,lightTriggerColor:i}},g=[["colorBgBody","bodyBg"],["colorBgHeader","headerBg"],["colorBgTrigger","triggerBg"]],b=(0,m.genStyleHooks)("Layout",e=>{let{antCls:t,componentCls:o,colorText:n,footerBg:i,headerHeight:r,headerPadding:l,headerColor:a,footerPadding:d,fontSize:s,bodyBg:c,headerBg:m}=e;return{[o]:{display:"flex",flex:"auto",flexDirection:"column",minHeight:0,background:c,"&, *":{boxSizing:"border-box"},[`&${o}-has-sider`]:{flexDirection:"row",[`> ${o}, > ${o}-content`]:{width:0}},[`${o}-header, &${o}-footer`]:{flex:"0 0 auto"},"&-rtl":{direction:"rtl"}},[`${o}-header`]:{height:r,padding:l,color:a,lineHeight:(0,u.unit)(r),background:m,[`${t}-menu`]:{lineHeight:"inherit"}},[`${o}-footer`]:{padding:d,color:n,fontSize:s,background:i},[`${o}-content`]:{flex:"auto",color:n,minHeight:0}}},p,{deprecatedTokens:g});e.s(["DEPRECATED_TOKENS",0,g,"default",0,b,"prepareComponentToken",0,p],251224);let $=(0,m.genStyleHooks)(["Layout","Sider"],e=>{let{componentCls:t,siderBg:o,motionDurationMid:n,motionDurationSlow:i,antCls:r,triggerHeight:l,triggerColor:a,triggerBg:d,headerHeight:s,zeroTriggerWidth:c,zeroTriggerHeight:m,borderRadiusLG:p,lightSiderBg:g,lightTriggerColor:b,lightTriggerBg:$,bodyBg:f}=e;return{[t]:{position:"relative",minWidth:0,background:o,transition:`all ${n}, background 0s`,"&-has-trigger":{paddingBottom:l},"&-right":{order:1},[`${t}-children`]:{height:"100%",marginTop:-.1,paddingTop:.1,[`${r}-menu${r}-menu-inline-collapsed`]:{width:"auto"}},[`&-zero-width ${t}-children`]:{overflow:"hidden"},[`${t}-trigger`]:{position:"fixed",bottom:0,zIndex:1,height:l,color:a,lineHeight:(0,u.unit)(l),textAlign:"center",background:d,cursor:"pointer",transition:`all ${n}`},[`${t}-zero-width-trigger`]:{position:"absolute",top:s,insetInlineEnd:e.calc(c).mul(-1).equal(),zIndex:1,width:c,height:m,color:a,fontSize:e.fontSizeXL,display:"flex",alignItems:"center",justifyContent:"center",background:o,borderRadius:`0 ${(0,u.unit)(p)} ${(0,u.unit)(p)} 0`,cursor:"pointer",transition:`background ${i} ease`,"&::after":{position:"absolute",inset:0,background:"transparent",transition:`all ${i}`,content:'""'},"&:hover::after":{background:"rgba(255, 255, 255, 0.2)"},"&-right":{insetInlineStart:e.calc(c).mul(-1).equal(),borderRadius:`${(0,u.unit)(p)} 0 0 ${(0,u.unit)(p)}`}},"&-light":{background:g,[`${t}-trigger`]:{color:b,background:$},[`${t}-zero-width-trigger`]:{color:b,background:$,border:`1px solid ${f}`,borderInlineStart:0}}}}},p,{deprecatedTokens:g});var f=function(e,t){var o={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&0>t.indexOf(n)&&(o[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols)for(var i=0,n=Object.getOwnPropertySymbols(e);it.indexOf(n[i])&&Object.prototype.propertyIsEnumerable.call(e,n[i])&&(o[n[i]]=e[n[i]]);return o};let v={xs:"479.98px",sm:"575.98px",md:"767.98px",lg:"991.98px",xl:"1199.98px",xxl:"1599.98px"},h=o.createContext({}),y=(t=0,(e="")=>(t+=1,`${e}${t}`)),x=o.forwardRef((e,t)=>{let{prefixCls:u,className:m,trigger:p,children:g,defaultCollapsed:b=!1,theme:x="dark",style:C={},collapsible:I=!1,reverseArrow:S=!1,width:w=200,collapsedWidth:O=80,zeroWidthTriggerStyle:B,breakpoint:k,onCollapse:E,onBreakpoint:z}=e,j=f(e,["prefixCls","className","trigger","children","defaultCollapsed","theme","style","collapsible","reverseArrow","width","collapsedWidth","zeroWidthTriggerStyle","breakpoint","onCollapse","onBreakpoint"]),{siderHook:H}=(0,o.useContext)(c.LayoutContext),[N,T]=(0,o.useState)("collapsed"in e?e.collapsed:b),[R,P]=(0,o.useState)(!1);(0,o.useEffect)(()=>{"collapsed"in e&&T(e.collapsed)},[e.collapsed]);let M=(t,o)=>{"collapsed"in e||T(t),null==E||E(t,o)},{getPrefixCls:A,direction:D}=(0,o.useContext)(s.ConfigContext),L=A("layout-sider",u),[W,G,q]=$(L),X=(0,o.useRef)(null);X.current=e=>{P(e.matches),null==z||z(e.matches),N!==e.matches&&M(e.matches,"responsive")},(0,o.useEffect)(()=>{let e;function t(e){var t;return null==(t=X.current)?void 0:t.call(X,e)}return void 0!==(null==window?void 0:window.matchMedia)&&k&&k in v&&(e=window.matchMedia(`screen and (max-width: ${v[k]})`),(0,d.addMediaQueryListener)(e,t),t(e)),()=>{(0,d.removeMediaQueryListener)(e,t)}},[k]),(0,o.useEffect)(()=>{let e=y("ant-sider-");return H.addSider(e),()=>H.removeSider(e)},[]);let F=()=>{M(!N,"clickTrigger")},Y=(0,a.default)(j,["collapsed"]),_=N?O:w,V=!Number.isNaN(Number.parseFloat(_))&&Number.isFinite(Number(_))?`${_}px`:String(_),U=0===Number.parseFloat(String(O||0))?o.createElement("span",{onClick:F,className:(0,l.default)(`${L}-zero-width-trigger`,`${L}-zero-width-trigger-${S?"right":"left"}`),style:B},p||o.createElement(n.default,null)):null,Z="rtl"===D==!S,K={expanded:Z?o.createElement(r.default,null):o.createElement(i.default,null),collapsed:Z?o.createElement(i.default,null):o.createElement(r.default,null)}[N?"collapsed":"expanded"],Q=null!==p?U||o.createElement("div",{className:`${L}-trigger`,onClick:F,style:{width:V}},p||K):null,J=Object.assign(Object.assign({},C),{flex:`0 0 ${V}`,maxWidth:V,minWidth:V,width:V}),ee=(0,l.default)(L,`${L}-${x}`,{[`${L}-collapsed`]:!!N,[`${L}-has-trigger`]:I&&null!==p&&!U,[`${L}-below`]:!!R,[`${L}-zero-width`]:0===Number.parseFloat(V)},m,G,q),et=o.useMemo(()=>({siderCollapsed:N}),[N]);return W(o.createElement(h.Provider,{value:et},o.createElement("aside",Object.assign({className:ee},Y,{style:J,ref:t}),o.createElement("div",{className:`${L}-children`},g),I||R&&U?Q:null)))});e.s(["SiderContext",0,h,"default",0,x],290224)},356061,e=>{"use strict";var t=e.i(983409);e.s(["ItemGroup",()=>t.default])},60699,652199,e=>{"use strict";e.i(247167);var t=e.i(271645),o=e.i(375565),n=e.i(356061),i=e.i(290224),r=e.i(867384),l=e.i(343794),a=e.i(175066),d=e.i(529681),s=e.i(613541),c=e.i(763731),u=e.i(242064),m=e.i(321883);let p=(0,t.createContext)({prefixCls:"",firstLevel:!0,inlineCollapsed:!1});var g=e.i(259792),g=g,b=function(e,t){var o={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&0>t.indexOf(n)&&(o[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols)for(var i=0,n=Object.getOwnPropertySymbols(e);it.indexOf(n[i])&&Object.prototype.propertyIsEnumerable.call(e,n[i])&&(o[n[i]]=e[n[i]]);return o};let $=e=>{let{prefixCls:o,className:n,dashed:i}=e,r=b(e,["prefixCls","className","dashed"]),{getPrefixCls:a}=t.useContext(u.ConfigContext),d=a("menu",o),s=(0,l.default)({[`${d}-item-divider-dashed`]:!!i},n);return t.createElement(g.default,Object.assign({className:s},r))};var f=e.i(452741),f=f,v=e.i(876556),h=e.i(491816);let y=e=>{var o;let n,r,{className:a,children:s,icon:u,title:m,danger:g,extra:b}=e,{prefixCls:$,firstLevel:y,direction:x,disableMenuItemTitleTooltip:C,inlineCollapsed:I}=t.useContext(p),{siderCollapsed:S}=t.useContext(i.SiderContext),w=m;void 0===m?w=y?s:"":!1===m&&(w="");let O={title:w};S||I||(O.title=null,O.open=!1);let B=(0,v.default)(s).length,k=t.createElement(f.default,Object.assign({},(0,d.default)(e,["title","icon","danger"]),{className:(0,l.default)({[`${$}-item-danger`]:g,[`${$}-item-only-child`]:(u?B+1:B)===1},a),title:"string"==typeof m?m:void 0}),(0,c.cloneElement)(u,{className:(0,l.default)(t.isValidElement(u)?null==(o=u.props)?void 0:o.className:void 0,`${$}-item-icon`)}),(n=null==s?void 0:s[0],r=t.createElement("span",{className:(0,l.default)(`${$}-title-content`,{[`${$}-title-content-with-extra`]:!!b||0===b})},s),(!u||t.isValidElement(s)&&"span"===s.type)&&s&&I&&y&&"string"==typeof n?t.createElement("div",{className:`${$}-inline-collapsed-noicon`},n.charAt(0)):r));return C||(k=t.createElement(h.default,Object.assign({},O,{placement:"rtl"===x?"left":"right",classNames:{root:`${$}-inline-collapsed-tooltip`}}),k)),k};var x=e.i(611935),C=e.i(617206),I=function(e,t){var o={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&0>t.indexOf(n)&&(o[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols)for(var i=0,n=Object.getOwnPropertySymbols(e);it.indexOf(n[i])&&Object.prototype.propertyIsEnumerable.call(e,n[i])&&(o[n[i]]=e[n[i]]);return o};let S=t.createContext(null),w=t.forwardRef((e,o)=>{let{children:n}=e,i=I(e,["children"]),r=t.useContext(S),l=t.useMemo(()=>Object.assign(Object.assign({},r),i),[r,i.prefixCls,i.mode,i.selectable,i.rootClassName]),a=(0,x.supportNodeRef)(n),d=(0,x.useComposeRef)(o,a?(0,x.getNodeRef)(n):null);return t.createElement(S.Provider,{value:l},t.createElement(C.default,{space:!0},a?t.cloneElement(n,{ref:d}):n))});e.s(["OverrideProvider",0,w,"default",0,S],652199),e.i(296059);var O=e.i(915654);e.i(262370);var B=e.i(135551),k=e.i(183293),E=e.i(447580),z=e.i(664142),j=e.i(717356),H=e.i(246422),N=e.i(838378);let T=e=>(0,k.genFocusOutline)(e),R=(e,t)=>{let{componentCls:o,itemColor:n,itemSelectedColor:i,subMenuItemSelectedColor:r,groupTitleColor:l,itemBg:a,subMenuItemBg:d,itemSelectedBg:s,activeBarHeight:c,activeBarWidth:u,activeBarBorderWidth:m,motionDurationSlow:p,motionEaseInOut:g,motionEaseOut:b,itemPaddingInline:$,motionDurationMid:f,itemHoverColor:v,lineType:h,colorSplit:y,itemDisabledColor:x,dangerItemColor:C,dangerItemHoverColor:I,dangerItemSelectedColor:S,dangerItemActiveBg:w,dangerItemSelectedBg:B,popupBg:k,itemHoverBg:E,itemActiveBg:z,menuSubMenuBg:j,horizontalItemSelectedColor:H,horizontalItemSelectedBg:N,horizontalItemBorderRadius:R,horizontalItemHoverBg:P}=e;return{[`${o}-${t}, ${o}-${t} > ${o}`]:{color:n,background:a,[`&${o}-root:focus-visible`]:Object.assign({},T(e)),[`${o}-item`]:{"&-group-title, &-extra":{color:l}},[`${o}-submenu-selected > ${o}-submenu-title`]:{color:r},[`${o}-item, ${o}-submenu-title`]:{color:n,[`&:not(${o}-item-disabled):focus-visible`]:Object.assign({},T(e))},[`${o}-item-disabled, ${o}-submenu-disabled`]:{color:`${x} !important`},[`${o}-item:not(${o}-item-selected):not(${o}-submenu-selected)`]:{[`&:hover, > ${o}-submenu-title:hover`]:{color:v}},[`&:not(${o}-horizontal)`]:{[`${o}-item:not(${o}-item-selected)`]:{"&:hover":{backgroundColor:E},"&:active":{backgroundColor:z}},[`${o}-submenu-title`]:{"&:hover":{backgroundColor:E},"&:active":{backgroundColor:z}}},[`${o}-item-danger`]:{color:C,[`&${o}-item:hover`]:{[`&:not(${o}-item-selected):not(${o}-submenu-selected)`]:{color:I}},[`&${o}-item:active`]:{background:w}},[`${o}-item a`]:{"&, &:hover":{color:"inherit"}},[`${o}-item-selected`]:{color:i,[`&${o}-item-danger`]:{color:S},"a, a:hover":{color:"inherit"}},[`& ${o}-item-selected`]:{backgroundColor:s,[`&${o}-item-danger`]:{backgroundColor:B}},[`&${o}-submenu > ${o}`]:{backgroundColor:j},[`&${o}-popup > ${o}`]:{backgroundColor:k},[`&${o}-submenu-popup > ${o}`]:{backgroundColor:k},[`&${o}-horizontal`]:Object.assign(Object.assign({},"dark"===t?{borderBottom:0}:{}),{[`> ${o}-item, > ${o}-submenu`]:{top:m,marginTop:e.calc(m).mul(-1).equal(),marginBottom:0,borderRadius:R,"&::after":{position:"absolute",insetInline:$,bottom:0,borderBottom:`${(0,O.unit)(c)} solid transparent`,transition:`border-color ${p} ${g}`,content:'""'},"&:hover, &-active, &-open":{background:P,"&::after":{borderBottomWidth:c,borderBottomColor:H}},"&-selected":{color:H,backgroundColor:N,"&:hover":{backgroundColor:N},"&::after":{borderBottomWidth:c,borderBottomColor:H}}}}),[`&${o}-root`]:{[`&${o}-inline, &${o}-vertical`]:{borderInlineEnd:`${(0,O.unit)(m)} ${h} ${y}`}},[`&${o}-inline`]:{[`${o}-sub${o}-inline`]:{background:d},[`${o}-item`]:{position:"relative","&::after":{position:"absolute",insetBlock:0,insetInlineEnd:0,borderInlineEnd:`${(0,O.unit)(u)} solid ${i}`,transform:"scaleY(0.0001)",opacity:0,transition:`transform ${f} ${b},opacity ${f} ${b}`,content:'""'},[`&${o}-item-danger`]:{"&::after":{borderInlineEndColor:S}}},[`${o}-selected, ${o}-item-selected`]:{"&::after":{transform:"scaleY(1)",opacity:1,transition:`transform ${f} ${g},opacity ${f} ${g}`}}}}}},P=e=>{let{componentCls:t,itemHeight:o,itemMarginInline:n,padding:i,menuArrowSize:r,marginXS:l,itemMarginBlock:a,itemWidth:d,itemPaddingInline:s}=e,c=e.calc(r).add(i).add(l).equal();return{[`${t}-item`]:{position:"relative",overflow:"hidden"},[`${t}-item, ${t}-submenu-title`]:{height:o,lineHeight:(0,O.unit)(o),paddingInline:s,overflow:"hidden",textOverflow:"ellipsis",marginInline:n,marginBlock:a,width:d},[`> ${t}-item, + > ${t}-submenu > ${t}-submenu-title`]:{height:o,lineHeight:(0,O.unit)(o)},[`${t}-item-group-list ${t}-submenu-title, + ${t}-submenu-title`]:{paddingInlineEnd:c}}},M=e=>{let{componentCls:t,motionDurationSlow:o,motionDurationMid:n,motionEaseInOut:i,motionEaseOut:r,iconCls:l,iconSize:a,iconMarginInlineEnd:d}=e;return{[`${t}-item, ${t}-submenu-title`]:{position:"relative",display:"block",margin:0,whiteSpace:"nowrap",cursor:"pointer",transition:`border-color ${o},background ${o},padding calc(${o} + 0.1s) ${i}`,[`${t}-item-icon, ${l}`]:{minWidth:a,fontSize:a,transition:`font-size ${n} ${r},margin ${o} ${i},color ${o}`,"+ span":{marginInlineStart:d,opacity:1,transition:`opacity ${o} ${i},margin ${o},color ${o}`}},[`${t}-item-icon`]:Object.assign({},(0,k.resetIcon)()),[`&${t}-item-only-child`]:{[`> ${l}, > ${t}-item-icon`]:{marginInlineEnd:0}}},[`${t}-item-disabled, ${t}-submenu-disabled`]:{background:"none !important",cursor:"not-allowed","&::after":{borderColor:"transparent !important"},a:{color:"inherit !important",cursor:"not-allowed",pointerEvents:"none"},[`> ${t}-submenu-title`]:{color:"inherit !important",cursor:"not-allowed"}}}},A=e=>{let{componentCls:t,motionDurationSlow:o,motionEaseInOut:n,borderRadius:i,menuArrowSize:r,menuArrowOffset:l}=e;return{[`${t}-submenu`]:{"&-expand-icon, &-arrow":{position:"absolute",top:"50%",insetInlineEnd:e.margin,width:r,color:"currentcolor",transform:"translateY(-50%)",transition:`transform ${o} ${n}, opacity ${o}`},"&-arrow":{"&::before, &::after":{position:"absolute",width:e.calc(r).mul(.6).equal(),height:e.calc(r).mul(.15).equal(),backgroundColor:"currentcolor",borderRadius:i,transition:`background ${o} ${n},transform ${o} ${n},top ${o} ${n},color ${o} ${n}`,content:'""'},"&::before":{transform:`rotate(45deg) translateY(${(0,O.unit)(e.calc(l).mul(-1).equal())})`},"&::after":{transform:`rotate(-45deg) translateY(${(0,O.unit)(l)})`}}}}},D=e=>{var t,o,n;let{colorPrimary:i,colorError:r,colorTextDisabled:l,colorErrorBg:a,colorText:d,colorTextDescription:s,colorBgContainer:c,colorFillAlter:u,colorFillContent:m,lineWidth:p,lineWidthBold:g,controlItemBgActive:b,colorBgTextHover:$,controlHeightLG:f,lineHeight:v,colorBgElevated:h,marginXXS:y,padding:x,fontSize:C,controlHeightSM:I,fontSizeLG:S,colorTextLightSolid:w,colorErrorHover:O}=e,k=null!=(t=e.activeBarWidth)?t:0,E=null!=(o=e.activeBarBorderWidth)?o:p,z=null!=(n=e.itemMarginInline)?n:e.marginXXS,j=new B.FastColor(w).setA(.65).toRgbString();return{dropdownWidth:160,zIndexPopup:e.zIndexPopupBase+50,radiusItem:e.borderRadiusLG,itemBorderRadius:e.borderRadiusLG,radiusSubMenuItem:e.borderRadiusSM,subMenuItemBorderRadius:e.borderRadiusSM,colorItemText:d,itemColor:d,colorItemTextHover:d,itemHoverColor:d,colorItemTextHoverHorizontal:i,horizontalItemHoverColor:i,colorGroupTitle:s,groupTitleColor:s,colorItemTextSelected:i,itemSelectedColor:i,subMenuItemSelectedColor:i,colorItemTextSelectedHorizontal:i,horizontalItemSelectedColor:i,colorItemBg:c,itemBg:c,colorItemBgHover:$,itemHoverBg:$,colorItemBgActive:m,itemActiveBg:b,colorSubItemBg:u,subMenuItemBg:u,colorItemBgSelected:b,itemSelectedBg:b,colorItemBgSelectedHorizontal:"transparent",horizontalItemSelectedBg:"transparent",colorActiveBarWidth:0,activeBarWidth:k,colorActiveBarHeight:g,activeBarHeight:g,colorActiveBarBorderSize:p,activeBarBorderWidth:E,colorItemTextDisabled:l,itemDisabledColor:l,colorDangerItemText:r,dangerItemColor:r,colorDangerItemTextHover:r,dangerItemHoverColor:r,colorDangerItemTextSelected:r,dangerItemSelectedColor:r,colorDangerItemBgActive:a,dangerItemActiveBg:a,colorDangerItemBgSelected:a,dangerItemSelectedBg:a,itemMarginInline:z,horizontalItemBorderRadius:0,horizontalItemHoverBg:"transparent",itemHeight:f,groupTitleLineHeight:v,collapsedWidth:2*f,popupBg:h,itemMarginBlock:y,itemPaddingInline:x,horizontalLineHeight:`${1.15*f}px`,iconSize:C,iconMarginInlineEnd:I-C,collapsedIconSize:S,groupTitleFontSize:C,darkItemDisabledColor:new B.FastColor(w).setA(.25).toRgbString(),darkItemColor:j,darkDangerItemColor:r,darkItemBg:"#001529",darkPopupBg:"#001529",darkSubMenuItemBg:"#000c17",darkItemSelectedColor:w,darkItemSelectedBg:i,darkDangerItemSelectedBg:r,darkItemHoverBg:"transparent",darkGroupTitleColor:j,darkItemHoverColor:w,darkDangerItemHoverColor:O,darkDangerItemSelectedColor:w,darkDangerItemActiveBg:r,itemWidth:k?`calc(100% + ${E}px)`:`calc(100% - ${2*z}px)`}};var L=e.i(905054),L=L,W=e.i(465394),G=e.i(122767);let q=e=>{var o;let n,{popupClassName:i,icon:r,title:a,theme:s}=e,u=t.useContext(p),{prefixCls:m,inlineCollapsed:g,theme:b}=u,$=(0,W.useFullPath)();if(r){let e=t.isValidElement(a)&&"span"===a.type;n=t.createElement(t.Fragment,null,(0,c.cloneElement)(r,{className:(0,l.default)(t.isValidElement(r)?null==(o=r.props)?void 0:o.className:void 0,`${m}-item-icon`)}),e?a:t.createElement("span",{className:`${m}-title-content`},a))}else n=g&&!$.length&&a&&"string"==typeof a?t.createElement("div",{className:`${m}-inline-collapsed-noicon`},a.charAt(0)):t.createElement("span",{className:`${m}-title-content`},a);let f=t.useMemo(()=>Object.assign(Object.assign({},u),{firstLevel:!1}),[u]),[v]=(0,G.useZIndex)("Menu");return t.createElement(p.Provider,{value:f},t.createElement(L.default,Object.assign({},(0,d.default)(e,["icon"]),{title:n,popupClassName:(0,l.default)(m,i,`${m}-${s||b}`),popupStyle:Object.assign({zIndex:v},e.popupStyle)})))};var X=function(e,t){var o={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&0>t.indexOf(n)&&(o[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols)for(var i=0,n=Object.getOwnPropertySymbols(e);it.indexOf(n[i])&&Object.prototype.propertyIsEnumerable.call(e,n[i])&&(o[n[i]]=e[n[i]]);return o};function F(e){return null===e||!1===e}let Y={item:y,submenu:q,divider:$},_=(0,t.forwardRef)((e,n)=>{var i;let g=t.useContext(S),b=g||{},{getPrefixCls:$,getPopupContainer:f,direction:v,menu:h}=t.useContext(u.ConfigContext),y=$(),{prefixCls:x,className:C,style:I,theme:w="light",expandIcon:B,_internalDisableMenuItemTitleTooltip:T,inlineCollapsed:L,siderCollapsed:W,rootClassName:G,mode:q,selectable:_,onClick:V,overflowedIndicatorPopupClassName:U}=e,Z=X(e,["prefixCls","className","style","theme","expandIcon","_internalDisableMenuItemTitleTooltip","inlineCollapsed","siderCollapsed","rootClassName","mode","selectable","onClick","overflowedIndicatorPopupClassName"]),K=(0,d.default)(Z,["collapsedWidth"]);null==(i=b.validator)||i.call(b,{mode:q});let Q=(0,a.default)((...e)=>{var t;null==V||V.apply(void 0,e),null==(t=b.onClick)||t.call(b)}),J=b.mode||q,ee=null!=_?_:b.selectable,et=null!=L?L:W,eo={horizontal:{motionName:`${y}-slide-up`},inline:(0,s.default)(y),other:{motionName:`${y}-zoom-big`}},en=$("menu",x||b.prefixCls),ei=(0,m.default)(en),[er,el,ea]=((e,t=e,o=!0)=>(0,H.genStyleHooks)("Menu",e=>{let{colorBgElevated:t,controlHeightLG:o,fontSize:n,darkItemColor:i,darkDangerItemColor:r,darkItemBg:l,darkSubMenuItemBg:a,darkItemSelectedColor:d,darkItemSelectedBg:s,darkDangerItemSelectedBg:c,darkItemHoverBg:u,darkGroupTitleColor:m,darkItemHoverColor:p,darkItemDisabledColor:g,darkDangerItemHoverColor:b,darkDangerItemSelectedColor:$,darkDangerItemActiveBg:f,popupBg:v,darkPopupBg:h}=e,y=e.calc(n).div(7).mul(5).equal(),x=(0,N.mergeToken)(e,{menuArrowSize:y,menuHorizontalHeight:e.calc(o).mul(1.15).equal(),menuArrowOffset:e.calc(y).mul(.25).equal(),menuSubMenuBg:t,calc:e.calc,popupBg:v}),C=(0,N.mergeToken)(x,{itemColor:i,itemHoverColor:p,groupTitleColor:m,itemSelectedColor:d,subMenuItemSelectedColor:d,itemBg:l,popupBg:h,subMenuItemBg:a,itemActiveBg:"transparent",itemSelectedBg:s,activeBarHeight:0,activeBarBorderWidth:0,itemHoverBg:u,itemDisabledColor:g,dangerItemColor:r,dangerItemHoverColor:b,dangerItemSelectedColor:$,dangerItemActiveBg:f,dangerItemSelectedBg:c,menuSubMenuBg:a,horizontalItemSelectedColor:d,horizontalItemSelectedBg:s});return[(e=>{let{antCls:t,componentCls:o,fontSize:n,motionDurationSlow:i,motionDurationMid:r,motionEaseInOut:l,paddingXS:a,padding:d,colorSplit:s,lineWidth:c,zIndexPopup:u,borderRadiusLG:m,subMenuItemBorderRadius:p,menuArrowSize:g,menuArrowOffset:b,lineType:$,groupTitleLineHeight:f,groupTitleFontSize:v}=e;return[{"":{[o]:Object.assign(Object.assign({},(0,k.clearFix)()),{"&-hidden":{display:"none"}})},[`${o}-submenu-hidden`]:{display:"none"}},{[o]:Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},(0,k.resetComponent)(e)),(0,k.clearFix)()),{marginBottom:0,paddingInlineStart:0,fontSize:n,lineHeight:0,listStyle:"none",outline:"none",transition:`width ${i} cubic-bezier(0.2, 0, 0, 1) 0s`,"ul, ol":{margin:0,padding:0,listStyle:"none"},"&-overflow":{display:"flex",[`${o}-item`]:{flex:"none"}},[`${o}-item, ${o}-submenu, ${o}-submenu-title`]:{borderRadius:e.itemBorderRadius},[`${o}-item-group-title`]:{padding:`${(0,O.unit)(a)} ${(0,O.unit)(d)}`,fontSize:v,lineHeight:f,transition:`all ${i}`},[`&-horizontal ${o}-submenu`]:{transition:`border-color ${i} ${l},background ${i} ${l}`},[`${o}-submenu, ${o}-submenu-inline`]:{transition:`border-color ${i} ${l},background ${i} ${l},padding ${r} ${l}`},[`${o}-submenu ${o}-sub`]:{cursor:"initial",transition:`background ${i} ${l},padding ${i} ${l}`},[`${o}-title-content`]:{transition:`color ${i}`,"&-with-extra":{display:"inline-flex",alignItems:"center",width:"100%"},[`> ${t}-typography-ellipsis-single-line`]:{display:"inline",verticalAlign:"unset"},[`${o}-item-extra`]:{marginInlineStart:"auto",paddingInlineStart:e.padding}},[`${o}-item a`]:{"&::before":{position:"absolute",inset:0,backgroundColor:"transparent",content:'""'}},[`${o}-item-divider`]:{overflow:"hidden",lineHeight:0,borderColor:s,borderStyle:$,borderWidth:0,borderTopWidth:c,marginBlock:c,padding:0,"&-dashed":{borderStyle:"dashed"}}}),M(e)),{[`${o}-item-group`]:{[`${o}-item-group-list`]:{margin:0,padding:0,[`${o}-item, ${o}-submenu-title`]:{paddingInline:`${(0,O.unit)(e.calc(n).mul(2).equal())} ${(0,O.unit)(d)}`}}},"&-submenu":{"&-popup":{position:"absolute",zIndex:u,borderRadius:m,boxShadow:"none",transformOrigin:"0 0",[`&${o}-submenu`]:{background:"transparent"},"&::before":{position:"absolute",inset:0,zIndex:-1,width:"100%",height:"100%",opacity:0,content:'""'},[`> ${o}`]:Object.assign(Object.assign(Object.assign({borderRadius:m},M(e)),A(e)),{[`${o}-item, ${o}-submenu > ${o}-submenu-title`]:{borderRadius:p},[`${o}-submenu-title::after`]:{transition:`transform ${i} ${l}`}})},[` + &-placement-leftTop, + &-placement-bottomRight, + `]:{transformOrigin:"100% 0"},[` + &-placement-leftBottom, + &-placement-topRight, + `]:{transformOrigin:"100% 100%"},[` + &-placement-rightBottom, + &-placement-topLeft, + `]:{transformOrigin:"0 100%"},[` + &-placement-bottomLeft, + &-placement-rightTop, + `]:{transformOrigin:"0 0"},[` + &-placement-leftTop, + &-placement-leftBottom + `]:{paddingInlineEnd:e.paddingXS},[` + &-placement-rightTop, + &-placement-rightBottom + `]:{paddingInlineStart:e.paddingXS},[` + &-placement-topRight, + &-placement-topLeft + `]:{paddingBottom:e.paddingXS},[` + &-placement-bottomRight, + &-placement-bottomLeft + `]:{paddingTop:e.paddingXS}}}),A(e)),{[`&-inline-collapsed ${o}-submenu-arrow, + &-inline ${o}-submenu-arrow`]:{"&::before":{transform:`rotate(-45deg) translateX(${(0,O.unit)(b)})`},"&::after":{transform:`rotate(45deg) translateX(${(0,O.unit)(e.calc(b).mul(-1).equal())})`}},[`${o}-submenu-open${o}-submenu-inline > ${o}-submenu-title > ${o}-submenu-arrow`]:{transform:`translateY(${(0,O.unit)(e.calc(g).mul(.2).mul(-1).equal())})`,"&::after":{transform:`rotate(-45deg) translateX(${(0,O.unit)(e.calc(b).mul(-1).equal())})`},"&::before":{transform:`rotate(45deg) translateX(${(0,O.unit)(b)})`}}})},{[`${t}-layout-header`]:{[o]:{lineHeight:"inherit"}}}]})(x),(e=>{let{componentCls:t,motionDurationSlow:o,horizontalLineHeight:n,colorSplit:i,lineWidth:r,lineType:l,itemPaddingInline:a}=e;return{[`${t}-horizontal`]:{lineHeight:n,border:0,borderBottom:`${(0,O.unit)(r)} ${l} ${i}`,boxShadow:"none","&::after":{display:"block",clear:"both",height:0,content:'"\\20"'},[`${t}-item, ${t}-submenu`]:{position:"relative",display:"inline-block",verticalAlign:"bottom",paddingInline:a},[`> ${t}-item:hover, + > ${t}-item-active, + > ${t}-submenu ${t}-submenu-title:hover`]:{backgroundColor:"transparent"},[`${t}-item, ${t}-submenu-title`]:{transition:`border-color ${o},background ${o}`},[`${t}-submenu-arrow`]:{display:"none"}}}})(x),(e=>{let{componentCls:t,iconCls:o,itemHeight:n,colorTextLightSolid:i,dropdownWidth:r,controlHeightLG:l,motionEaseOut:a,paddingXL:d,itemMarginInline:s,fontSizeLG:c,motionDurationFast:u,motionDurationSlow:m,paddingXS:p,boxShadowSecondary:g,collapsedWidth:b,collapsedIconSize:$}=e,f={height:n,lineHeight:(0,O.unit)(n),listStylePosition:"inside",listStyleType:"disc"};return[{[t]:{"&-inline, &-vertical":Object.assign({[`&${t}-root`]:{boxShadow:"none"}},P(e))},[`${t}-submenu-popup`]:{[`${t}-vertical`]:Object.assign(Object.assign({},P(e)),{boxShadow:g})}},{[`${t}-submenu-popup ${t}-vertical${t}-sub`]:{minWidth:r,maxHeight:`calc(100vh - ${(0,O.unit)(e.calc(l).mul(2.5).equal())})`,padding:"0",overflow:"hidden",borderInlineEnd:0,"&:not([class*='-active'])":{overflowX:"hidden",overflowY:"auto"}}},{[`${t}-inline`]:{width:"100%",[`&${t}-root`]:{[`${t}-item, ${t}-submenu-title`]:{display:"flex",alignItems:"center",transition:`border-color ${m},background ${m},padding ${u} ${a}`,[`> ${t}-title-content`]:{flex:"auto",minWidth:0,overflow:"hidden",textOverflow:"ellipsis"},"> *":{flex:"none"}}},[`${t}-sub${t}-inline`]:{padding:0,border:0,borderRadius:0,boxShadow:"none",[`& > ${t}-submenu > ${t}-submenu-title`]:f,[`& ${t}-item-group-title`]:{paddingInlineStart:d}},[`${t}-item`]:f}},{[`${t}-inline-collapsed`]:{width:b,[`&${t}-root`]:{[`${t}-item, ${t}-submenu ${t}-submenu-title`]:{[`> ${t}-inline-collapsed-noicon`]:{fontSize:c,textAlign:"center"}}},[`> ${t}-item, + > ${t}-item-group > ${t}-item-group-list > ${t}-item, + > ${t}-item-group > ${t}-item-group-list > ${t}-submenu > ${t}-submenu-title, + > ${t}-submenu > ${t}-submenu-title`]:{insetInlineStart:0,paddingInline:`calc(50% - ${(0,O.unit)(e.calc($).div(2).equal())} - ${(0,O.unit)(s)})`,textOverflow:"clip",[` + ${t}-submenu-arrow, + ${t}-submenu-expand-icon + `]:{opacity:0},[`${t}-item-icon, ${o}`]:{margin:0,fontSize:$,lineHeight:(0,O.unit)(n),"+ span":{display:"inline-block",opacity:0}}},[`${t}-item-icon, ${o}`]:{display:"inline-block"},"&-tooltip":{pointerEvents:"none",[`${t}-item-icon, ${o}`]:{display:"none"},"a, a:hover":{color:i}},[`${t}-item-group-title`]:Object.assign(Object.assign({},k.textEllipsis),{paddingInline:p})}}]})(x),R(x,"light"),R(C,"dark"),(({componentCls:e,menuArrowOffset:t,calc:o})=>({[`${e}-rtl`]:{direction:"rtl"},[`${e}-submenu-rtl`]:{transformOrigin:"100% 0"},[`${e}-rtl${e}-vertical, + ${e}-submenu-rtl ${e}-vertical`]:{[`${e}-submenu-arrow`]:{"&::before":{transform:`rotate(-45deg) translateY(${(0,O.unit)(o(t).mul(-1).equal())})`},"&::after":{transform:`rotate(45deg) translateY(${(0,O.unit)(t)})`}}}}))(x),(0,E.genCollapseMotion)(x),(0,z.initSlideMotion)(x,"slide-up"),(0,z.initSlideMotion)(x,"slide-down"),(0,j.initZoomMotion)(x,"zoom-big")]},D,{deprecatedTokens:[["colorGroupTitle","groupTitleColor"],["radiusItem","itemBorderRadius"],["radiusSubMenuItem","subMenuItemBorderRadius"],["colorItemText","itemColor"],["colorItemTextHover","itemHoverColor"],["colorItemTextHoverHorizontal","horizontalItemHoverColor"],["colorItemTextSelected","itemSelectedColor"],["colorItemTextSelectedHorizontal","horizontalItemSelectedColor"],["colorItemTextDisabled","itemDisabledColor"],["colorDangerItemText","dangerItemColor"],["colorDangerItemTextHover","dangerItemHoverColor"],["colorDangerItemTextSelected","dangerItemSelectedColor"],["colorDangerItemBgActive","dangerItemActiveBg"],["colorDangerItemBgSelected","dangerItemSelectedBg"],["colorItemBg","itemBg"],["colorItemBgHover","itemHoverBg"],["colorSubItemBg","subMenuItemBg"],["colorItemBgActive","itemActiveBg"],["colorItemBgSelectedHorizontal","horizontalItemSelectedBg"],["colorActiveBarWidth","activeBarWidth"],["colorActiveBarHeight","activeBarHeight"],["colorActiveBarBorderSize","activeBarBorderWidth"],["colorItemBgSelected","itemSelectedBg"]],injectStyle:o,unitless:{groupTitleLineHeight:!0}})(e,t))(en,ei,!g),ed=(0,l.default)(`${en}-${w}`,null==h?void 0:h.className,C),es=t.useMemo(()=>{var e,o;if("function"==typeof B||F(B))return B||null;if("function"==typeof b.expandIcon||F(b.expandIcon))return b.expandIcon||null;if("function"==typeof(null==h?void 0:h.expandIcon)||F(null==h?void 0:h.expandIcon))return(null==h?void 0:h.expandIcon)||null;let n=null!=(e=null!=B?B:null==b?void 0:b.expandIcon)?e:null==h?void 0:h.expandIcon;return(0,c.cloneElement)(n,{className:(0,l.default)(`${en}-submenu-expand-icon`,t.isValidElement(n)?null==(o=n.props)?void 0:o.className:void 0)})},[B,null==b?void 0:b.expandIcon,null==h?void 0:h.expandIcon,en]),ec=t.useMemo(()=>({prefixCls:en,inlineCollapsed:et||!1,direction:v,firstLevel:!0,theme:w,mode:J,disableMenuItemTitleTooltip:T}),[en,et,v,T,w]);return er(t.createElement(S.Provider,{value:null},t.createElement(p.Provider,{value:ec},t.createElement(o.default,Object.assign({getPopupContainer:f,overflowedIndicator:t.createElement(r.default,null),overflowedIndicatorPopupClassName:(0,l.default)(en,`${en}-${w}`,U),mode:J,selectable:ee,onClick:Q},K,{inlineCollapsed:et,style:Object.assign(Object.assign({},null==h?void 0:h.style),I),className:ed,prefixCls:en,direction:v,defaultMotions:eo,expandIcon:es,ref:n,rootClassName:(0,l.default)(G,el,b.rootClassName,ea,ei),_internalComponents:Y})))))}),V=(0,t.forwardRef)((e,o)=>{let n=(0,t.useRef)(null),r=t.useContext(i.SiderContext);return(0,t.useImperativeHandle)(o,()=>({menu:n.current,focus:e=>{var t;null==(t=n.current)||t.focus(e)}})),t.createElement(_,Object.assign({ref:n},e,r))});V.Item=y,V.SubMenu=q,V.Divider=$,V.ItemGroup=n.ItemGroup,e.s(["default",0,V],60699)},138540,e=>{"use strict";e.s(["default",0,e=>"object"!=typeof e&&"function"!=typeof e||null===e])},21539,e=>{"use strict";e.i(247167);var t=e.i(271645),o=e.i(801312),n=e.i(286612),i=e.i(343794),r=e.i(878081),l=e.i(175066),a=e.i(914949),d=e.i(529681),s=e.i(122767),c=e.i(138540),u=e.i(805984),m=e.i(805484),p=e.i(763731),g=e.i(747656),b=e.i(340010),$=e.i(242064),f=e.i(321883),v=e.i(60699),h=e.i(652199),y=e.i(104458);e.i(296059);var x=e.i(915654),C=e.i(183293),I=e.i(777489),S=e.i(664142),w=e.i(717356),O=e.i(320560),B=e.i(307358),k=e.i(246422),E=e.i(838378);let z=(0,k.genStyleHooks)("Dropdown",e=>{let{marginXXS:t,sizePopupArrow:o,paddingXXS:n,componentCls:i}=e,r=(0,E.mergeToken)(e,{menuCls:`${i}-menu`,dropdownArrowDistance:e.calc(o).div(2).add(t).equal(),dropdownEdgeChildPadding:n});return[(e=>{let{componentCls:t,menuCls:o,zIndexPopup:n,dropdownArrowDistance:i,sizePopupArrow:r,antCls:l,iconCls:a,motionDurationMid:d,paddingBlock:s,fontSize:c,dropdownEdgeChildPadding:u,colorTextDisabled:m,fontSizeIcon:p,controlPaddingHorizontal:g,colorBgElevated:b}=e;return[{[t]:{position:"absolute",top:-9999,left:{_skip_check_:!0,value:-9999},zIndex:n,display:"block","&::before":{position:"absolute",insetBlock:e.calc(r).div(2).sub(i).equal(),zIndex:-9999,opacity:1e-4,content:'""'},"&-menu-vertical":{maxHeight:"100vh",overflowY:"auto"},[`&-trigger${l}-btn`]:{[`& > ${a}-down, & > ${l}-btn-icon > ${a}-down`]:{fontSize:p}},[`${t}-wrap`]:{position:"relative",[`${l}-btn > ${a}-down`]:{fontSize:p},[`${a}-down::before`]:{transition:`transform ${d}`}},[`${t}-wrap-open`]:{[`${a}-down::before`]:{transform:"rotate(180deg)"}},[` + &-hidden, + &-menu-hidden, + &-menu-submenu-hidden + `]:{display:"none"},[`&${l}-slide-down-enter${l}-slide-down-enter-active${t}-placement-bottomLeft, + &${l}-slide-down-appear${l}-slide-down-appear-active${t}-placement-bottomLeft, + &${l}-slide-down-enter${l}-slide-down-enter-active${t}-placement-bottom, + &${l}-slide-down-appear${l}-slide-down-appear-active${t}-placement-bottom, + &${l}-slide-down-enter${l}-slide-down-enter-active${t}-placement-bottomRight, + &${l}-slide-down-appear${l}-slide-down-appear-active${t}-placement-bottomRight`]:{animationName:S.slideUpIn},[`&${l}-slide-up-enter${l}-slide-up-enter-active${t}-placement-topLeft, + &${l}-slide-up-appear${l}-slide-up-appear-active${t}-placement-topLeft, + &${l}-slide-up-enter${l}-slide-up-enter-active${t}-placement-top, + &${l}-slide-up-appear${l}-slide-up-appear-active${t}-placement-top, + &${l}-slide-up-enter${l}-slide-up-enter-active${t}-placement-topRight, + &${l}-slide-up-appear${l}-slide-up-appear-active${t}-placement-topRight`]:{animationName:S.slideDownIn},[`&${l}-slide-down-leave${l}-slide-down-leave-active${t}-placement-bottomLeft, + &${l}-slide-down-leave${l}-slide-down-leave-active${t}-placement-bottom, + &${l}-slide-down-leave${l}-slide-down-leave-active${t}-placement-bottomRight`]:{animationName:S.slideUpOut},[`&${l}-slide-up-leave${l}-slide-up-leave-active${t}-placement-topLeft, + &${l}-slide-up-leave${l}-slide-up-leave-active${t}-placement-top, + &${l}-slide-up-leave${l}-slide-up-leave-active${t}-placement-topRight`]:{animationName:S.slideDownOut}}},(0,O.default)(e,b,{arrowPlacement:{top:!0,bottom:!0}}),{[`${t} ${o}`]:{position:"relative",margin:0},[`${o}-submenu-popup`]:{position:"absolute",zIndex:n,background:"transparent",boxShadow:"none",transformOrigin:"0 0","ul, li":{listStyle:"none",margin:0}},[`${t}, ${t}-menu-submenu`]:Object.assign(Object.assign({},(0,C.resetComponent)(e)),{[o]:Object.assign(Object.assign({padding:u,listStyleType:"none",backgroundColor:b,backgroundClip:"padding-box",borderRadius:e.borderRadiusLG,outline:"none",boxShadow:e.boxShadowSecondary},(0,C.genFocusStyle)(e)),{"&:empty":{padding:0,boxShadow:"none"},[`${o}-item-group-title`]:{padding:`${(0,x.unit)(s)} ${(0,x.unit)(g)}`,color:e.colorTextDescription,transition:`all ${d}`},[`${o}-item`]:{position:"relative",display:"flex",alignItems:"center"},[`${o}-item-icon`]:{minWidth:c,marginInlineEnd:e.marginXS,fontSize:e.fontSizeSM},[`${o}-title-content`]:{flex:"auto","&-with-extra":{display:"inline-flex",alignItems:"center",width:"100%"},"> a":{color:"inherit",transition:`all ${d}`,"&:hover":{color:"inherit"},"&::after":{position:"absolute",inset:0,content:'""'}},[`${o}-item-extra`]:{paddingInlineStart:e.padding,marginInlineStart:"auto",fontSize:e.fontSizeSM,color:e.colorTextDescription}},[`${o}-item, ${o}-submenu-title`]:Object.assign(Object.assign({display:"flex",margin:0,padding:`${(0,x.unit)(s)} ${(0,x.unit)(g)}`,color:e.colorText,fontWeight:"normal",fontSize:c,lineHeight:e.lineHeight,cursor:"pointer",transition:`all ${d}`,borderRadius:e.borderRadiusSM,"&:hover, &-active":{backgroundColor:e.controlItemBgHover}},(0,C.genFocusStyle)(e)),{"&-selected":{color:e.colorPrimary,backgroundColor:e.controlItemBgActive,"&:hover, &-active":{backgroundColor:e.controlItemBgActiveHover}},"&-disabled":{color:m,cursor:"not-allowed","&:hover":{color:m,backgroundColor:b,cursor:"not-allowed"},a:{pointerEvents:"none"}},"&-divider":{height:1,margin:`${(0,x.unit)(e.marginXXS)} 0`,overflow:"hidden",lineHeight:0,backgroundColor:e.colorSplit},[`${t}-menu-submenu-expand-icon`]:{position:"absolute",insetInlineEnd:e.paddingXS,[`${t}-menu-submenu-arrow-icon`]:{marginInlineEnd:"0 !important",color:e.colorIcon,fontSize:p,fontStyle:"normal"}}}),[`${o}-item-group-list`]:{margin:`0 ${(0,x.unit)(e.marginXS)}`,padding:0,listStyle:"none"},[`${o}-submenu-title`]:{paddingInlineEnd:e.calc(g).add(e.fontSizeSM).equal()},[`${o}-submenu-vertical`]:{position:"relative"},[`${o}-submenu${o}-submenu-disabled ${t}-menu-submenu-title`]:{[`&, ${t}-menu-submenu-arrow-icon`]:{color:m,backgroundColor:b,cursor:"not-allowed"}},[`${o}-submenu-selected ${t}-menu-submenu-title`]:{color:e.colorPrimary}})})},[(0,S.initSlideMotion)(e,"slide-up"),(0,S.initSlideMotion)(e,"slide-down"),(0,I.initMoveMotion)(e,"move-up"),(0,I.initMoveMotion)(e,"move-down"),(0,w.initZoomMotion)(e,"zoom-big")]]})(r),(e=>{let{componentCls:t,menuCls:o,colorError:n,colorTextLightSolid:i}=e,r=`${o}-item`;return{[`${t}, ${t}-menu-submenu`]:{[`${o} ${r}`]:{[`&${r}-danger:not(${r}-disabled)`]:{color:n,"&:hover":{color:i,backgroundColor:n}}}}}})(r)]},e=>Object.assign(Object.assign({zIndexPopup:e.zIndexPopupBase+50,paddingBlock:(e.controlHeight-e.fontSize*e.lineHeight)/2},(0,O.getArrowOffsetToken)({contentRadius:e.borderRadiusLG,limitVerticalRadius:!0})),(0,B.getArrowToken)(e)),{resetStyle:!1}),j=e=>{var m;let{menu:x,arrow:C,prefixCls:I,children:S,trigger:w,disabled:O,dropdownRender:B,popupRender:k,getPopupContainer:E,overlayClassName:j,rootClassName:H,overlayStyle:N,open:T,onOpenChange:R,visible:P,onVisibleChange:M,mouseEnterDelay:A=.15,mouseLeaveDelay:D=.1,autoAdjustOverflow:L=!0,placement:W="",overlay:G,transitionName:q,destroyOnHidden:X,destroyPopupOnHide:F}=e,{getPopupContainer:Y,getPrefixCls:_,direction:V,dropdown:U}=t.useContext($.ConfigContext),Z=k||B;(0,g.devUseWarning)("Dropdown");let K=t.useMemo(()=>{let e=_();return void 0!==q?q:W.includes("top")?`${e}-slide-down`:`${e}-slide-up`},[_,W,q]),Q=t.useMemo(()=>W?W.includes("Center")?W.slice(0,W.indexOf("Center")):W:"rtl"===V?"bottomRight":"bottomLeft",[W,V]),J=_("dropdown",I),ee=(0,f.default)(J),[et,eo,en]=z(J,ee),[,ei]=(0,y.useToken)(),er=t.Children.only((0,c.default)(S)?t.createElement("span",null,S):S),el=(0,p.cloneElement)(er,{className:(0,i.default)(`${J}-trigger`,{[`${J}-rtl`]:"rtl"===V},er.props.className),disabled:null!=(m=er.props.disabled)?m:O}),ea=O?[]:w,ed=!!(null==ea?void 0:ea.includes("contextMenu")),[es,ec]=(0,a.default)(!1,{value:null!=T?T:P}),eu=(0,l.default)(e=>{null==R||R(e,{source:"trigger"}),null==M||M(e),ec(e)}),em=(0,i.default)(j,H,eo,en,ee,null==U?void 0:U.className,{[`${J}-rtl`]:"rtl"===V}),ep=(0,u.default)({arrowPointAtCenter:"object"==typeof C&&C.pointAtCenter,autoAdjustOverflow:L,offset:ei.marginXXS,arrowWidth:C?ei.sizePopupArrow:0,borderRadius:ei.borderRadius}),eg=(0,l.default)(()=>{null!=x&&x.selectable&&null!=x&&x.multiple||(null==R||R(!1,{source:"menu"}),ec(!1))}),[eb,e$]=(0,s.useZIndex)("Dropdown",null==N?void 0:N.zIndex),ef=t.createElement(r.default,Object.assign({alignPoint:ed},(0,d.default)(e,["rootClassName"]),{mouseEnterDelay:A,mouseLeaveDelay:D,visible:es,builtinPlacements:ep,arrow:!!C,overlayClassName:em,prefixCls:J,getPopupContainer:E||Y,transitionName:K,trigger:ea,overlay:()=>{let e;return e=(null==x?void 0:x.items)?t.createElement(v.default,Object.assign({},x)):"function"==typeof G?G():G,Z&&(e=Z(e)),e=t.Children.only("string"==typeof e?t.createElement("span",null,e):e),t.createElement(h.OverrideProvider,{prefixCls:`${J}-menu`,rootClassName:(0,i.default)(en,ee),expandIcon:t.createElement("span",{className:`${J}-menu-submenu-arrow`},"rtl"===V?t.createElement(o.default,{className:`${J}-menu-submenu-arrow-icon`}):t.createElement(n.default,{className:`${J}-menu-submenu-arrow-icon`})),mode:"vertical",selectable:!1,onClick:eg,validator:({mode:e})=>{}},e)},placement:Q,onVisibleChange:eu,overlayStyle:Object.assign(Object.assign(Object.assign({},null==U?void 0:U.style),N),{zIndex:eb}),autoDestroy:null!=X?X:F}),el);return eb&&(ef=t.createElement(b.default.Provider,{value:e$},ef)),et(ef)},H=(0,m.default)(j,"align",void 0,"dropdown",e=>e);j._InternalPanelDoNotUseOrYouWillBeFired=e=>t.createElement(H,Object.assign({},e),t.createElement("span",null));var N=e.i(867384),T=e.i(920228),R=e.i(38243),P=e.i(249616),M=function(e,t){var o={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&0>t.indexOf(n)&&(o[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols)for(var i=0,n=Object.getOwnPropertySymbols(e);it.indexOf(n[i])&&Object.prototype.propertyIsEnumerable.call(e,n[i])&&(o[n[i]]=e[n[i]]);return o};let A=e=>{let{getPopupContainer:o,getPrefixCls:n,direction:r}=t.useContext($.ConfigContext),{prefixCls:l,type:a="default",danger:d,disabled:s,loading:c,onClick:u,htmlType:m,children:p,className:g,menu:b,arrow:f,autoFocus:v,overlay:h,trigger:y,align:x,open:C,onOpenChange:I,placement:S,getPopupContainer:w,href:O,icon:B=t.createElement(N.default,null),title:k,buttonsRender:E=e=>e,mouseEnterDelay:z,mouseLeaveDelay:H,overlayClassName:A,overlayStyle:D,destroyOnHidden:L,destroyPopupOnHide:W,dropdownRender:G,popupRender:q}=e,X=M(e,["prefixCls","type","danger","disabled","loading","onClick","htmlType","children","className","menu","arrow","autoFocus","overlay","trigger","align","open","onOpenChange","placement","getPopupContainer","href","icon","title","buttonsRender","mouseEnterDelay","mouseLeaveDelay","overlayClassName","overlayStyle","destroyOnHidden","destroyPopupOnHide","dropdownRender","popupRender"]),F=n("dropdown",l),Y=`${F}-button`,_={menu:b,arrow:f,autoFocus:v,align:x,disabled:s,trigger:s?[]:y,onOpenChange:I,getPopupContainer:w||o,mouseEnterDelay:z,mouseLeaveDelay:H,overlayClassName:A,overlayStyle:D,destroyOnHidden:L,popupRender:q||G},{compactSize:V,compactItemClassnames:U}=(0,P.useCompactItemContext)(F,r),Z=(0,i.default)(Y,U,g);"destroyPopupOnHide"in e&&(_.destroyPopupOnHide=W),"overlay"in e&&(_.overlay=h),"open"in e&&(_.open=C),"placement"in e?_.placement=S:_.placement="rtl"===r?"bottomLeft":"bottomRight";let[K,Q]=E([t.createElement(T.default,{type:a,danger:d,disabled:s,loading:c,onClick:u,htmlType:m,href:O,title:k},p),t.createElement(T.default,{type:a,danger:d,icon:B})]);return t.createElement(R.default.Compact,Object.assign({className:Z,size:V,block:!0},X),K,t.createElement(j,Object.assign({},_),Q))};A.__ANT_BUTTON=!0,j.Button=A,e.s(["default",0,j],21539)}]); \ No newline at end of file diff --git a/litellm/proxy/_experimental/out/_next/static/chunks/00ff280cdb7d7ee5.js b/litellm/proxy/_experimental/out/_next/static/chunks/00ff280cdb7d7ee5.js new file mode 100644 index 00000000000..ef84e7aadbe --- /dev/null +++ b/litellm/proxy/_experimental/out/_next/static/chunks/00ff280cdb7d7ee5.js @@ -0,0 +1 @@ +(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,829087,397126,229315,343084,953760,e=>{"use strict";e.i(247167);var t=e.i(271645);new WeakMap,new WeakMap;var n='input:not([inert]):not([inert] *),select:not([inert]):not([inert] *),textarea:not([inert]):not([inert] *),a[href]:not([inert]):not([inert] *),button:not([inert]):not([inert] *),[tabindex]:not(slot):not([inert]):not([inert] *),audio[controls]:not([inert]):not([inert] *),video[controls]:not([inert]):not([inert] *),[contenteditable]:not([contenteditable="false"]):not([inert]):not([inert] *),details>summary:first-of-type:not([inert]):not([inert] *),details:not([inert]):not([inert] *)',r="u"typeof window&&void 0!==window.CSS&&"function"==typeof window.CSS.escape)t=r(window.CSS.escape(e.name));else try{t=r(e.name)}catch(e){return console.error("Looks like you have a radio button with a name attribute containing invalid CSS selector characters and need the CSS.escape polyfill: %s",e.message),!1}var o=h(t,e.form);return!o||o===e},v=function(e){return m(e)&&"radio"===e.type&&!g(e)},y=function(e){var t,n,r,o,l,u,a,c=e&&i(e),s=null==(t=c)?void 0:t.host,f=!1;if(c&&c!==e)for(f=!!(null!=(n=s)&&null!=(r=n.ownerDocument)&&r.contains(s)||null!=e&&null!=(o=e.ownerDocument)&&o.contains(e));!f&&s;)f=!!(null!=(u=s=null==(l=c=i(s))?void 0:l.host)&&null!=(a=u.ownerDocument)&&a.contains(s));return f},w=function(e){var t=e.getBoundingClientRect(),n=t.width,r=t.height;return 0===n&&0===r},b=function(e,t){var n=t.displayCheck,r=t.getShadowRoot;if("full-native"===n&&"checkVisibility"in e)return!e.checkVisibility({checkOpacity:!1,opacityProperty:!1,contentVisibilityAuto:!0,visibilityProperty:!0,checkVisibilityCSS:!0});if("hidden"===getComputedStyle(e).visibility)return!0;var l=o.call(e,"details>summary:first-of-type")?e.parentElement:e;if(o.call(l,"details:not([open]) *"))return!0;if(n&&"full"!==n&&"full-native"!==n&&"legacy-full"!==n){if("non-zero-area"===n)return w(e)}else{if("function"==typeof r){for(var u=e;e;){var a=e.parentElement,c=i(e);if(a&&!a.shadowRoot&&!0===r(a))return w(e);e=e.assignedSlot?e.assignedSlot:a||c===e.ownerDocument?a:c.host}e=u}if(y(e))return!e.getClientRects().length;if("legacy-full"!==n)return!0}return!1},x=function(e){if(/^(INPUT|BUTTON|SELECT|TEXTAREA)$/.test(e.tagName))for(var t=e.parentElement;t;){if("FIELDSET"===t.tagName&&t.disabled){for(var n=0;nf(t))&&!!E(e,t)},S=function(e){var t=parseInt(e.getAttribute("tabindex"),10);return!!isNaN(t)||!!(t>=0)},T=function(e){var t=[],n=[];return e.forEach(function(e,r){var o=!!e.scopeParent,i=o?e.scopeParent:e,l=d(i,o),u=o?T(e.candidates):i;0===l?o?t.push.apply(t,u):t.push(i):n.push({documentOrder:r,tabIndex:l,item:e,isScope:o,content:u})}),n.sort(p).reduce(function(e,t){return t.isScope?e.push.apply(e,t.content):e.push(t.content),e},[]).concat(t)},L=function(e,t){return T((t=t||{}).getShadowRoot?c([e],t.includeContainer,{filter:R.bind(null,t),flatten:!1,getShadowRoot:t.getShadowRoot,shadowRootFilter:S}):a(e,t.includeContainer,R.bind(null,t)))},A=function(e,t){if(t=t||{},!e)throw Error("No node provided");return!1!==o.call(e,n)&&R(t,e)};e.s(["isTabbable",()=>A,"tabbable",()=>L],397126);var C=e.i(174080);function P(){return"u">typeof window}function O(e){return M(e)?(e.nodeName||"").toLowerCase():"#document"}function k(e){var t;return(null==e||null==(t=e.ownerDocument)?void 0:t.defaultView)||window}function D(e){var t;return null==(t=(M(e)?e.ownerDocument:e.document)||window.document)?void 0:t.documentElement}function M(e){return!!P()&&(e instanceof Node||e instanceof k(e).Node)}function N(e){return!!P()&&(e instanceof Element||e instanceof k(e).Element)}function F(e){return!!P()&&(e instanceof HTMLElement||e instanceof k(e).HTMLElement)}function I(e){return!(!P()||"u"{try{return e.matches(t)}catch(e){return!1}})}let z=["transform","translate","scale","rotate","perspective"],K=["transform","translate","scale","rotate","perspective","filter"],U=["paint","layout","strict","content"];function X(e){let t=$(),n=N(e)?J(e):e;return z.some(e=>!!n[e]&&"none"!==n[e])||!!n.containerType&&"normal"!==n.containerType||!t&&!!n.backdropFilter&&"none"!==n.backdropFilter||!t&&!!n.filter&&"none"!==n.filter||K.some(e=>(n.willChange||"").includes(e))||U.some(e=>(n.contain||"").includes(e))}function Y(e){let t=Z(e);for(;F(t)&&!G(t);){if(X(t))return t;if(j(t))break;t=Z(t)}return null}function $(){return!("u"J,"getContainingBlock",()=>Y,"getDocumentElement",()=>D,"getFrameElement",()=>et,"getNodeName",()=>O,"getNodeScroll",()=>Q,"getOverflowAncestors",()=>ee,"getParentNode",()=>Z,"getWindow",()=>k,"isContainingBlock",()=>X,"isElement",()=>N,"isHTMLElement",()=>F,"isLastTraversableNode",()=>G,"isOverflowElement",()=>W,"isShadowRoot",()=>I,"isTableElement",()=>V,"isTopLayer",()=>j,"isWebKit",()=>$],229315);let en=["top","right","bottom","left"],er=en.reduce((e,t)=>e.concat(t,t+"-start",t+"-end"),[]),eo=Math.min,ei=Math.max,el=Math.round,eu=Math.floor,ea=e=>({x:e,y:e}),ec={left:"right",right:"left",bottom:"top",top:"bottom"},es={start:"end",end:"start"};function ef(e,t,n){return ei(e,eo(t,n))}function ed(e,t){return"function"==typeof e?e(t):e}function ep(e){return e.split("-")[0]}function em(e){return e.split("-")[1]}function eh(e){return"x"===e?"y":"x"}function eg(e){return"y"===e?"height":"width"}let ev=new Set(["top","bottom"]);function ey(e){return ev.has(ep(e))?"y":"x"}function ew(e){return eh(ey(e))}function eb(e,t,n){void 0===n&&(n=!1);let r=em(e),o=ew(e),i=eg(o),l="x"===o?r===(n?"end":"start")?"right":"left":"start"===r?"bottom":"top";return t.reference[i]>t.floating[i]&&(l=eC(l)),[l,eC(l)]}function ex(e){let t=eC(e);return[eE(e),t,eE(t)]}function eE(e){return e.replace(/start|end/g,e=>es[e])}let eR=["left","right"],eS=["right","left"],eT=["top","bottom"],eL=["bottom","top"];function eA(e,t,n,r){let o=em(e),i=function(e,t,n){switch(e){case"top":case"bottom":if(n)return t?eS:eR;return t?eR:eS;case"left":case"right":return t?eT:eL;default:return[]}}(ep(e),"start"===n,r);return o&&(i=i.map(e=>e+"-"+o),t&&(i=i.concat(i.map(eE)))),i}function eC(e){return e.replace(/left|right|bottom|top/g,e=>ec[e])}function eP(e){return"number"!=typeof e?{top:0,right:0,bottom:0,left:0,...e}:{top:e,right:e,bottom:e,left:e}}function eO(e){let{x:t,y:n,width:r,height:o}=e;return{width:r,height:o,top:n,left:t,right:t+r,bottom:n+o,x:t,y:n}}function ek(e,t,n){let r,{reference:o,floating:i}=e,l=ey(t),u=ew(t),a=eg(u),c=ep(t),s="y"===l,f=o.x+o.width/2-i.width/2,d=o.y+o.height/2-i.height/2,p=o[a]/2-i[a]/2;switch(c){case"top":r={x:f,y:o.y-i.height};break;case"bottom":r={x:f,y:o.y+o.height};break;case"right":r={x:o.x+o.width,y:d};break;case"left":r={x:o.x-i.width,y:d};break;default:r={x:o.x,y:o.y}}switch(em(t)){case"start":r[u]-=p*(n&&s?-1:1);break;case"end":r[u]+=p*(n&&s?-1:1)}return r}async function eD(e,t){var n;void 0===t&&(t={});let{x:r,y:o,platform:i,rects:l,elements:u,strategy:a}=e,{boundary:c="clippingAncestors",rootBoundary:s="viewport",elementContext:f="floating",altBoundary:d=!1,padding:p=0}=ed(t,e),m=eP(p),h=u[d?"floating"===f?"reference":"floating":f],g=eO(await i.getClippingRect({element:null==(n=await (null==i.isElement?void 0:i.isElement(h)))||n?h:h.contextElement||await (null==i.getDocumentElement?void 0:i.getDocumentElement(u.floating)),boundary:c,rootBoundary:s,strategy:a})),v="floating"===f?{x:r,y:o,width:l.floating.width,height:l.floating.height}:l.reference,y=await (null==i.getOffsetParent?void 0:i.getOffsetParent(u.floating)),w=await (null==i.isElement?void 0:i.isElement(y))&&await (null==i.getScale?void 0:i.getScale(y))||{x:1,y:1},b=eO(i.convertOffsetParentRelativeRectToViewportRelativeRect?await i.convertOffsetParentRelativeRectToViewportRelativeRect({elements:u,rect:v,offsetParent:y,strategy:a}):v);return{top:(g.top-b.top+m.top)/w.y,bottom:(b.bottom-g.bottom+m.bottom)/w.y,left:(g.left-b.left+m.left)/w.x,right:(b.right-g.right+m.right)/w.x}}e.s(["clamp",()=>ef,"createCoords",()=>ea,"evaluate",()=>ed,"floor",()=>eu,"getAlignment",()=>em,"getAlignmentAxis",()=>ew,"getAlignmentSides",()=>eb,"getAxisLength",()=>eg,"getExpandedPlacements",()=>ex,"getOppositeAlignmentPlacement",()=>eE,"getOppositeAxis",()=>eh,"getOppositeAxisPlacements",()=>eA,"getOppositePlacement",()=>eC,"getPaddingObject",()=>eP,"getSide",()=>ep,"getSideAxis",()=>ey,"max",()=>ei,"min",()=>eo,"placements",()=>er,"rectToClientRect",()=>eO,"round",()=>el,"sides",()=>en],343084);let eM=async(e,t,n)=>{let{placement:r="bottom",strategy:o="absolute",middleware:i=[],platform:l}=n,u=i.filter(Boolean),a=await (null==l.isRTL?void 0:l.isRTL(t)),c=await l.getElementRects({reference:e,floating:t,strategy:o}),{x:s,y:f}=ek(c,r,a),d=r,p={},m=0;for(let n=0;ne[t]>=0)}function eI(e){let t=eo(...e.map(e=>e.left)),n=eo(...e.map(e=>e.top));return{x:t,y:n,width:ei(...e.map(e=>e.right))-t,height:ei(...e.map(e=>e.bottom))-n}}let eB=new Set(["left","top"]);async function eW(e,t){let{placement:n,platform:r,elements:o}=e,i=await (null==r.isRTL?void 0:r.isRTL(o.floating)),l=ep(n),u=em(n),a="y"===ey(n),c=eB.has(l)?-1:1,s=i&&a?-1:1,f=ed(t,e),{mainAxis:d,crossAxis:p,alignmentAxis:m}="number"==typeof f?{mainAxis:f,crossAxis:0,alignmentAxis:null}:{mainAxis:f.mainAxis||0,crossAxis:f.crossAxis||0,alignmentAxis:f.alignmentAxis};return u&&"number"==typeof m&&(p="end"===u?-1*m:m),a?{x:p*s,y:d*c}:{x:d*c,y:p*s}}function eH(e){let t=J(e),n=parseFloat(t.width)||0,r=parseFloat(t.height)||0,o=F(e),i=o?e.offsetWidth:n,l=o?e.offsetHeight:r,u=el(n)!==i||el(r)!==l;return u&&(n=i,r=l),{width:n,height:r,$:u}}function eV(e){return N(e)?e:e.contextElement}function e_(e){let t=eV(e);if(!F(t))return ea(1);let n=t.getBoundingClientRect(),{width:r,height:o,$:i}=eH(t),l=(i?el(n.width):n.width)/r,u=(i?el(n.height):n.height)/o;return l&&Number.isFinite(l)||(l=1),u&&Number.isFinite(u)||(u=1),{x:l,y:u}}let ej=ea(0);function ez(e){let t=k(e);return $()&&t.visualViewport?{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}:ej}function eK(e,t,n,r){var o;void 0===t&&(t=!1),void 0===n&&(n=!1);let i=e.getBoundingClientRect(),l=eV(e),u=ea(1);t&&(r?N(r)&&(u=e_(r)):u=e_(e));let a=(void 0===(o=n)&&(o=!1),r&&(!o||r===k(l))&&o)?ez(l):ea(0),c=(i.left+a.x)/u.x,s=(i.top+a.y)/u.y,f=i.width/u.x,d=i.height/u.y;if(l){let e=k(l),t=r&&N(r)?k(r):r,n=e,o=et(n);for(;o&&r&&t!==n;){let e=e_(o),t=o.getBoundingClientRect(),r=J(o),i=t.left+(o.clientLeft+parseFloat(r.paddingLeft))*e.x,l=t.top+(o.clientTop+parseFloat(r.paddingTop))*e.y;c*=e.x,s*=e.y,f*=e.x,d*=e.y,c+=i,s+=l,o=et(n=k(o))}}return eO({width:f,height:d,x:c,y:s})}function eU(e,t){let n=Q(e).scrollLeft;return t?t.left+n:eK(D(e)).left+n}function eX(e,t){let n=e.getBoundingClientRect();return{x:n.left+t.scrollLeft-eU(e,n),y:n.top+t.scrollTop}}let eY=new Set(["absolute","fixed"]);function e$(e,t,n){var r;let o;if("viewport"===t)o=function(e,t){let n=k(e),r=D(e),o=n.visualViewport,i=r.clientWidth,l=r.clientHeight,u=0,a=0;if(o){i=o.width,l=o.height;let e=$();(!e||e&&"fixed"===t)&&(u=o.offsetLeft,a=o.offsetTop)}let c=eU(r);if(c<=0){let e=r.ownerDocument,t=e.body,n=getComputedStyle(t),o="CSS1Compat"===e.compatMode&&parseFloat(n.marginLeft)+parseFloat(n.marginRight)||0,l=Math.abs(r.clientWidth-t.clientWidth-o);l<=25&&(i-=l)}else c<=25&&(i+=c);return{width:i,height:l,x:u,y:a}}(e,n);else if("document"===t){let t,n,i,l,u,a,c;r=D(e),t=D(r),n=Q(r),i=r.ownerDocument.body,l=ei(t.scrollWidth,t.clientWidth,i.scrollWidth,i.clientWidth),u=ei(t.scrollHeight,t.clientHeight,i.scrollHeight,i.clientHeight),a=-n.scrollLeft+eU(r),c=-n.scrollTop,"rtl"===J(i).direction&&(a+=ei(t.clientWidth,i.clientWidth)-l),o={width:l,height:u,x:a,y:c}}else if(N(t)){let e,r,i,l,u,a;r=(e=eK(t,!0,"fixed"===n)).top+t.clientTop,i=e.left+t.clientLeft,l=F(t)?e_(t):ea(1),u=t.clientWidth*l.x,a=t.clientHeight*l.y,o={width:u,height:a,x:i*l.x,y:r*l.y}}else{let n=ez(e);o={x:t.x-n.x,y:t.y-n.y,width:t.width,height:t.height}}return eO(o)}function eq(e){return"static"===J(e).position}function eG(e,t){if(!F(e)||"fixed"===J(e).position)return null;if(t)return t(e);let n=e.offsetParent;return D(e)===n&&(n=n.ownerDocument.body),n}function eJ(e,t){let n=k(e);if(j(e))return n;if(!F(e)){let t=Z(e);for(;t&&!G(t);){if(N(t)&&!eq(t))return t;t=Z(t)}return n}let r=eG(e,t);for(;r&&V(r)&&eq(r);)r=eG(r,t);return r&&G(r)&&eq(r)&&!X(r)?n:r||Y(e)||n}let eQ=async function(e){let t=this.getOffsetParent||eJ,n=this.getDimensions,r=await n(e.floating);return{reference:function(e,t,n){let r=F(t),o=D(t),i="fixed"===n,l=eK(e,!0,i,t),u={scrollLeft:0,scrollTop:0},a=ea(0);if(r||!r&&!i)if(("body"!==O(t)||W(o))&&(u=Q(t)),r){let e=eK(t,!0,i,t);a.x=e.x+t.clientLeft,a.y=e.y+t.clientTop}else o&&(a.x=eU(o));i&&!r&&o&&(a.x=eU(o));let c=!o||r||i?ea(0):eX(o,u);return{x:l.left+u.scrollLeft-a.x-c.x,y:l.top+u.scrollTop-a.y-c.y,width:l.width,height:l.height}}(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}},eZ={convertOffsetParentRelativeRectToViewportRelativeRect:function(e){let{elements:t,rect:n,offsetParent:r,strategy:o}=e,i="fixed"===o,l=D(r),u=!!t&&j(t.floating);if(r===l||u&&i)return n;let a={scrollLeft:0,scrollTop:0},c=ea(1),s=ea(0),f=F(r);if((f||!f&&!i)&&(("body"!==O(r)||W(l))&&(a=Q(r)),F(r))){let e=eK(r);c=e_(r),s.x=e.x+r.clientLeft,s.y=e.y+r.clientTop}let d=!l||f||i?ea(0):eX(l,a);return{width:n.width*c.x,height:n.height*c.y,x:n.x*c.x-a.scrollLeft*c.x+s.x+d.x,y:n.y*c.y-a.scrollTop*c.y+s.y+d.y}},getDocumentElement:D,getClippingRect:function(e){let{element:t,boundary:n,rootBoundary:r,strategy:o}=e,i=[..."clippingAncestors"===n?j(t)?[]:function(e,t){let n=t.get(e);if(n)return n;let r=ee(e,[],!1).filter(e=>N(e)&&"body"!==O(e)),o=null,i="fixed"===J(e).position,l=i?Z(e):e;for(;N(l)&&!G(l);){let t=J(l),n=X(l);n||"fixed"!==t.position||(o=null),(i?!n&&!o:!n&&"static"===t.position&&!!o&&eY.has(o.position)||W(l)&&!n&&function e(t,n){let r=Z(t);return!(r===n||!N(r)||G(r))&&("fixed"===J(r).position||e(r,n))}(e,l))?r=r.filter(e=>e!==l):o=t,l=Z(l)}return t.set(e,r),r}(t,this._c):[].concat(n),r],l=i[0],u=i.reduce((e,n)=>{let r=e$(t,n,o);return e.top=ei(r.top,e.top),e.right=eo(r.right,e.right),e.bottom=eo(r.bottom,e.bottom),e.left=ei(r.left,e.left),e},e$(t,l,o));return{width:u.right-u.left,height:u.bottom-u.top,x:u.left,y:u.top}},getOffsetParent:eJ,getElementRects:eQ,getClientRects:function(e){return Array.from(e.getClientRects())},getDimensions:function(e){let{width:t,height:n}=eH(e);return{width:t,height:n}},getScale:e_,isElement:N,isRTL:function(e){return"rtl"===J(e).direction}};function e0(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function e1(e,t,n,r){let o;void 0===r&&(r={});let{ancestorScroll:i=!0,ancestorResize:l=!0,elementResize:u="function"==typeof ResizeObserver,layoutShift:a="function"==typeof IntersectionObserver,animationFrame:c=!1}=r,s=eV(e),f=i||l?[...s?ee(s):[],...ee(t)]:[];f.forEach(e=>{i&&e.addEventListener("scroll",n,{passive:!0}),l&&e.addEventListener("resize",n)});let d=s&&a?function(e,t){let n,r=null,o=D(e);function i(){var e;clearTimeout(n),null==(e=r)||e.disconnect(),r=null}return!function l(u,a){void 0===u&&(u=!1),void 0===a&&(a=1),i();let c=e.getBoundingClientRect(),{left:s,top:f,width:d,height:p}=c;if(u||t(),!d||!p)return;let m={rootMargin:-eu(f)+"px "+-eu(o.clientWidth-(s+d))+"px "+-eu(o.clientHeight-(f+p))+"px "+-eu(s)+"px",threshold:ei(0,eo(1,a))||1},h=!0;function g(t){let r=t[0].intersectionRatio;if(r!==a){if(!h)return l();r?l(!1,r):n=setTimeout(()=>{l(!1,1e-7)},1e3)}1!==r||e0(c,e.getBoundingClientRect())||l(),h=!1}try{r=new IntersectionObserver(g,{...m,root:o.ownerDocument})}catch(e){r=new IntersectionObserver(g,m)}r.observe(e)}(!0),i}(s,n):null,p=-1,m=null;u&&(m=new ResizeObserver(e=>{let[r]=e;r&&r.target===s&&m&&(m.unobserve(t),cancelAnimationFrame(p),p=requestAnimationFrame(()=>{var e;null==(e=m)||e.observe(t)})),n()}),s&&!c&&m.observe(s),m.observe(t));let h=c?eK(e):null;return c&&function t(){let r=eK(e);h&&!e0(h,r)&&n(),h=r,o=requestAnimationFrame(t)}(),n(),()=>{var e;f.forEach(e=>{i&&e.removeEventListener("scroll",n),l&&e.removeEventListener("resize",n)}),null==d||d(),null==(e=m)||e.disconnect(),m=null,c&&cancelAnimationFrame(o)}}let e2=function(e){return void 0===e&&(e=0),{name:"offset",options:e,async fn(t){var n,r;let{x:o,y:i,placement:l,middlewareData:u}=t,a=await eW(t,e);return l===(null==(n=u.offset)?void 0:n.placement)&&null!=(r=u.arrow)&&r.alignmentOffset?{}:{x:o+a.x,y:i+a.y,data:{...a,placement:l}}}}},e3=function(e){return void 0===e&&(e={}),{name:"autoPlacement",options:e,async fn(t){var n,r,o,i;let{rects:l,middlewareData:u,placement:a,platform:c,elements:s}=t,{crossAxis:f=!1,alignment:d,allowedPlacements:p=er,autoAlignment:m=!0,...h}=ed(e,t),g=void 0!==d||p===er?((i=d||null)?[...p.filter(e=>em(e)===i),...p.filter(e=>em(e)!==i)]:p.filter(e=>ep(e)===e)).filter(e=>!i||em(e)===i||!!m&&eE(e)!==e):p,v=await c.detectOverflow(t,h),y=(null==(n=u.autoPlacement)?void 0:n.index)||0,w=g[y];if(null==w)return{};let b=eb(w,l,await (null==c.isRTL?void 0:c.isRTL(s.floating)));if(a!==w)return{reset:{placement:g[0]}};let x=[v[ep(w)],v[b[0]],v[b[1]]],E=[...(null==(r=u.autoPlacement)?void 0:r.overflows)||[],{placement:w,overflows:x}],R=g[y+1];if(R)return{data:{index:y+1,overflows:E},reset:{placement:R}};let S=E.map(e=>{let t=em(e.placement);return[e.placement,t&&f?e.overflows.slice(0,2).reduce((e,t)=>e+t,0):e.overflows[0],e.overflows]}).sort((e,t)=>e[1]-t[1]),T=(null==(o=S.filter(e=>e[2].slice(0,em(e[0])?2:3).every(e=>e<=0))[0])?void 0:o[0])||S[0][0];return T!==a?{data:{index:y+1,overflows:E},reset:{placement:T}}:{}}}},e5=function(e){return void 0===e&&(e={}),{name:"shift",options:e,async fn(t){let{x:n,y:r,placement:o,platform:i}=t,{mainAxis:l=!0,crossAxis:u=!1,limiter:a={fn:e=>{let{x:t,y:n}=e;return{x:t,y:n}}},...c}=ed(e,t),s={x:n,y:r},f=await i.detectOverflow(t,c),d=ey(ep(o)),p=eh(d),m=s[p],h=s[d];if(l){let e="y"===p?"top":"left",t="y"===p?"bottom":"right",n=m+f[e],r=m-f[t];m=ef(n,m,r)}if(u){let e="y"===d?"top":"left",t="y"===d?"bottom":"right",n=h+f[e],r=h-f[t];h=ef(n,h,r)}let g=a.fn({...t,[p]:m,[d]:h});return{...g,data:{x:g.x-n,y:g.y-r,enabled:{[p]:l,[d]:u}}}}}},e7=function(e){return void 0===e&&(e={}),{name:"flip",options:e,async fn(t){var n,r,o,i,l;let{placement:u,middlewareData:a,rects:c,initialPlacement:s,platform:f,elements:d}=t,{mainAxis:p=!0,crossAxis:m=!0,fallbackPlacements:h,fallbackStrategy:g="bestFit",fallbackAxisSideDirection:v="none",flipAlignment:y=!0,...w}=ed(e,t);if(null!=(n=a.arrow)&&n.alignmentOffset)return{};let b=ep(u),x=ey(s),E=ep(s)===s,R=await (null==f.isRTL?void 0:f.isRTL(d.floating)),S=h||(E||!y?[eC(s)]:ex(s)),T="none"!==v;!h&&T&&S.push(...eA(s,y,v,R));let L=[s,...S],A=await f.detectOverflow(t,w),C=[],P=(null==(r=a.flip)?void 0:r.overflows)||[];if(p&&C.push(A[b]),m){let e=eb(u,c,R);C.push(A[e[0]],A[e[1]])}if(P=[...P,{placement:u,overflows:C}],!C.every(e=>e<=0)){let e=((null==(o=a.flip)?void 0:o.index)||0)+1,t=L[e];if(t&&("alignment"!==m||x===ey(t)||P.every(e=>ey(e.placement)!==x||e.overflows[0]>0)))return{data:{index:e,overflows:P},reset:{placement:t}};let n=null==(i=P.filter(e=>e.overflows[0]<=0).sort((e,t)=>e.overflows[1]-t.overflows[1])[0])?void 0:i.placement;if(!n)switch(g){case"bestFit":{let e=null==(l=P.filter(e=>{if(T){let t=ey(e.placement);return t===x||"y"===t}return!0}).map(e=>[e.placement,e.overflows.filter(e=>e>0).reduce((e,t)=>e+t,0)]).sort((e,t)=>e[1]-t[1])[0])?void 0:l[0];e&&(n=e);break}case"initialPlacement":n=s}if(u!==n)return{reset:{placement:n}}}return{}}}},e4=function(e){return void 0===e&&(e={}),{name:"size",options:e,async fn(t){var n,r;let o,i,{placement:l,rects:u,platform:a,elements:c}=t,{apply:s=()=>{},...f}=ed(e,t),d=await a.detectOverflow(t,f),p=ep(l),m=em(l),h="y"===ey(l),{width:g,height:v}=u.floating;"top"===p||"bottom"===p?(o=p,i=m===(await (null==a.isRTL?void 0:a.isRTL(c.floating))?"start":"end")?"left":"right"):(i=p,o="end"===m?"top":"bottom");let y=v-d.top-d.bottom,w=g-d.left-d.right,b=eo(v-d[o],y),x=eo(g-d[i],w),E=!t.middlewareData.shift,R=b,S=x;if(null!=(n=t.middlewareData.shift)&&n.enabled.x&&(S=w),null!=(r=t.middlewareData.shift)&&r.enabled.y&&(R=y),E&&!m){let e=ei(d.left,0),t=ei(d.right,0),n=ei(d.top,0),r=ei(d.bottom,0);h?S=g-2*(0!==e||0!==t?e+t:ei(d.left,d.right)):R=v-2*(0!==n||0!==r?n+r:ei(d.top,d.bottom))}await s({...t,availableWidth:S,availableHeight:R});let T=await a.getDimensions(c.floating);return g!==T.width||v!==T.height?{reset:{rects:!0}}:{}}}},e9=function(e){return void 0===e&&(e={}),{name:"hide",options:e,async fn(t){let{rects:n,platform:r}=t,{strategy:o="referenceHidden",...i}=ed(e,t);switch(o){case"referenceHidden":{let e=eN(await r.detectOverflow(t,{...i,elementContext:"reference"}),n.reference);return{data:{referenceHiddenOffsets:e,referenceHidden:eF(e)}}}case"escaped":{let e=eN(await r.detectOverflow(t,{...i,altBoundary:!0}),n.floating);return{data:{escapedOffsets:e,escaped:eF(e)}}}default:return{}}}}},e8=e=>({name:"arrow",options:e,async fn(t){let{x:n,y:r,placement:o,rects:i,platform:l,elements:u,middlewareData:a}=t,{element:c,padding:s=0}=ed(e,t)||{};if(null==c)return{};let f=eP(s),d={x:n,y:r},p=ew(o),m=eg(p),h=await l.getDimensions(c),g="y"===p,v=g?"clientHeight":"clientWidth",y=i.reference[m]+i.reference[p]-d[p]-i.floating[m],w=d[p]-i.reference[p],b=await (null==l.getOffsetParent?void 0:l.getOffsetParent(c)),x=b?b[v]:0;x&&await (null==l.isElement?void 0:l.isElement(b))||(x=u.floating[v]||i.floating[m]);let E=x/2-h[m]/2-1,R=eo(f[g?"top":"left"],E),S=eo(f[g?"bottom":"right"],E),T=x-h[m]-S,L=x/2-h[m]/2+(y/2-w/2),A=ef(R,L,T),C=!a.arrow&&null!=em(o)&&L!==A&&i.reference[m]/2-(Le.y-t.y),n=[],r=null;for(let e=0;er.height/2?n.push([o]):n[n.length-1].push(o),r=o}return n.map(e=>eO(eI(e)))}(s),d=eO(eI(s)),p=eP(u),m=await i.getElementRects({reference:{getBoundingClientRect:function(){if(2===f.length&&f[0].left>f[1].right&&null!=a&&null!=c)return f.find(e=>a>e.left-p.left&&ae.top-p.top&&c=2){if("y"===ey(n)){let e=f[0],t=f[f.length-1],r="top"===ep(n),o=e.top,i=t.bottom,l=r?e.left:t.left,u=r?e.right:t.right;return{top:o,bottom:i,left:l,right:u,width:u-l,height:i-o,x:l,y:o}}let e="left"===ep(n),t=ei(...f.map(e=>e.right)),r=eo(...f.map(e=>e.left)),o=f.filter(n=>e?n.left===r:n.right===t),i=o[0].top,l=o[o.length-1].bottom;return{top:i,bottom:l,left:r,right:t,width:t-r,height:l-i,x:r,y:i}}return d}},floating:r.floating,strategy:l});return o.reference.x!==m.reference.x||o.reference.y!==m.reference.y||o.reference.width!==m.reference.width||o.reference.height!==m.reference.height?{reset:{rects:m}}:{}}}},te=function(e){return void 0===e&&(e={}),{options:e,fn(t){let{x:n,y:r,placement:o,rects:i,middlewareData:l}=t,{offset:u=0,mainAxis:a=!0,crossAxis:c=!0}=ed(e,t),s={x:n,y:r},f=ey(o),d=eh(f),p=s[d],m=s[f],h=ed(u,t),g="number"==typeof h?{mainAxis:h,crossAxis:0}:{mainAxis:0,crossAxis:0,...h};if(a){let e="y"===d?"height":"width",t=i.reference[d]-i.floating[e]+g.mainAxis,n=i.reference[d]+i.reference[e]-g.mainAxis;pn&&(p=n)}if(c){var v,y;let e="y"===d?"width":"height",t=eB.has(ep(o)),n=i.reference[f]-i.floating[e]+(t&&(null==(v=l.offset)?void 0:v[f])||0)+(t?0:g.crossAxis),r=i.reference[f]+i.reference[e]+(t?0:(null==(y=l.offset)?void 0:y[f])||0)-(t?g.crossAxis:0);mr&&(m=r)}return{[d]:p,[f]:m}}}},tt=(e,t,n)=>{let r=new Map,o={platform:eZ,...n},i={...o.platform,_c:r};return eM(e,t,{...o,platform:i})};e.s(["arrow",()=>e8,"autoPlacement",()=>e3,"autoUpdate",()=>e1,"computePosition",()=>tt,"detectOverflow",()=>eD,"flip",()=>e7,"hide",()=>e9,"inline",()=>e6,"limitShift",()=>te,"offset",()=>e2,"shift",()=>e5,"size",()=>e4],953760);var tn="u">typeof document?t.useLayoutEffect:t.useEffect;function tr(e,t){let n,r,o;if(e===t)return!0;if(typeof e!=typeof t)return!1;if("function"==typeof e&&e.toString()===t.toString())return!0;if(e&&t&&"object"==typeof e){if(Array.isArray(e)){if((n=e.length)!=t.length)return!1;for(r=n;0!=r--;)if(!tr(e[r],t[r]))return!1;return!0}if((n=(o=Object.keys(e)).length)!==Object.keys(t).length)return!1;for(r=n;0!=r--;)if(!Object.prototype.hasOwnProperty.call(t,o[r]))return!1;for(r=n;0!=r--;){let n=o[r];if(("_owner"!==n||!e.$$typeof)&&!tr(e[n],t[n]))return!1}return!0}return e!=e&&t!=t}function to(e){let n=t.useRef(e);return tn(()=>{n.current=e}),n}var ti="u">typeof document?t.useLayoutEffect:t.useEffect;let tl=!1,tu=0,ta=()=>"floating-ui-"+tu++,tc=t["useId".toString()]||function(){let[e,n]=t.useState(()=>tl?ta():void 0);return ti(()=>{null==e&&n(ta())},[]),t.useEffect(()=>{tl||(tl=!0)},[]),e},ts=t.createContext(null),tf=t.createContext(null),td=()=>{var e;return(null==(e=t.useContext(ts))?void 0:e.id)||null};function tp(e){return(null==e?void 0:e.ownerDocument)||document}function tm(e){return tp(e).defaultView||window}function th(e){return!!e&&e instanceof tm(e).Element}function tg(e){return!!e&&e instanceof tm(e).HTMLElement}function tv(e,t){let n=["mouse","pen"];return t||n.push("",void 0),n.includes(e)}function ty(e){let n=(0,t.useRef)(e);return ti(()=>{n.current=e}),n}let tw="data-floating-ui-safe-polygon";function tb(e,t,n){return n&&!tv(n)?0:"number"==typeof e?e:null==e?void 0:e[t]}let tx=function(e,n){let{enabled:r=!0,delay:o=0,handleClose:i=null,mouseOnly:l=!1,restMs:u=0,move:a=!0}=void 0===n?{}:n,{open:c,onOpenChange:s,dataRef:f,events:d,elements:{domReference:p,floating:m},refs:h}=e,g=t.useContext(tf),v=td(),y=ty(i),w=ty(o),b=t.useRef(),x=t.useRef(),E=t.useRef(),R=t.useRef(),S=t.useRef(!0),T=t.useRef(!1),L=t.useRef(()=>{}),A=t.useCallback(()=>{var e;let t=null==(e=f.current.openEvent)?void 0:e.type;return(null==t?void 0:t.includes("mouse"))&&"mousedown"!==t},[f]);t.useEffect(()=>{if(r)return d.on("dismiss",e),()=>{d.off("dismiss",e)};function e(){clearTimeout(x.current),clearTimeout(R.current),S.current=!0}},[r,d]),t.useEffect(()=>{if(!r||!y.current||!c)return;function e(){A()&&s(!1)}let t=tp(m).documentElement;return t.addEventListener("mouseleave",e),()=>{t.removeEventListener("mouseleave",e)}},[m,c,s,r,y,f,A]);let C=t.useCallback(function(e){void 0===e&&(e=!0);let t=tb(w.current,"close",b.current);t&&!E.current?(clearTimeout(x.current),x.current=setTimeout(()=>s(!1),t)):e&&(clearTimeout(x.current),s(!1))},[w,s]),P=t.useCallback(()=>{L.current(),E.current=void 0},[]),O=t.useCallback(()=>{if(T.current){let e=tp(h.floating.current).body;e.style.pointerEvents="",e.removeAttribute(tw),T.current=!1}},[h]);return t.useEffect(()=>{if(r&&th(p))return c&&p.addEventListener("mouseleave",i),null==m||m.addEventListener("mouseleave",i),a&&p.addEventListener("mousemove",n,{once:!0}),p.addEventListener("mouseenter",n),p.addEventListener("mouseleave",o),()=>{c&&p.removeEventListener("mouseleave",i),null==m||m.removeEventListener("mouseleave",i),a&&p.removeEventListener("mousemove",n),p.removeEventListener("mouseenter",n),p.removeEventListener("mouseleave",o)};function t(){return!!f.current.openEvent&&["click","mousedown"].includes(f.current.openEvent.type)}function n(e){if(clearTimeout(x.current),S.current=!1,l&&!tv(b.current)||u>0&&0===tb(w.current,"open"))return;f.current.openEvent=e;let t=tb(w.current,"open",b.current);t?x.current=setTimeout(()=>{s(!0)},t):s(!0)}function o(n){if(t())return;L.current();let r=tp(m);if(clearTimeout(R.current),y.current){c||clearTimeout(x.current),E.current=y.current({...e,tree:g,x:n.clientX,y:n.clientY,onClose(){O(),P(),C()}});let t=E.current;r.addEventListener("mousemove",t),L.current=()=>{r.removeEventListener("mousemove",t)};return}C()}function i(n){t()||null==y.current||y.current({...e,tree:g,x:n.clientX,y:n.clientY,onClose(){O(),P(),C()}})(n)}},[p,m,r,e,l,u,a,C,P,O,s,c,g,w,y,f]),ti(()=>{var e,t,n;if(r&&c&&null!=(e=y.current)&&e.__options.blockPointerEvents&&A()){let e=tp(m).body;if(e.setAttribute(tw,""),e.style.pointerEvents="none",T.current=!0,th(p)&&m){let e=null==g||null==(t=g.nodesRef.current.find(e=>e.id===v))||null==(n=t.context)?void 0:n.elements.floating;return e&&(e.style.pointerEvents=""),p.style.pointerEvents="auto",m.style.pointerEvents="auto",()=>{p.style.pointerEvents="",m.style.pointerEvents=""}}}},[r,c,v,m,p,g,y,f,A]),ti(()=>{c||(b.current=void 0,P(),O())},[c,P,O]),t.useEffect(()=>()=>{P(),clearTimeout(x.current),clearTimeout(R.current),O()},[r,P,O]),t.useMemo(()=>{if(!r)return{};function e(e){b.current=e.pointerType}return{reference:{onPointerDown:e,onPointerEnter:e,onMouseMove(){c||0===u||(clearTimeout(R.current),R.current=setTimeout(()=>{S.current||s(!0)},u))}},floating:{onMouseEnter(){clearTimeout(x.current)},onMouseLeave(){d.emit("dismiss",{type:"mouseLeave",data:{returnFocus:!1}}),C(!1)}}}},[d,r,u,c,s,C])};function tE(e,t){if(!e||!t)return!1;let n=t.getRootNode&&t.getRootNode();if(e.contains(t))return!0;if(n&&function(e){if("u"{var n;return e.parentId===t&&(null==(n=e.context)?void 0:n.open)})||[],r=n;for(;r.length;)r=e.filter(e=>{var t;return null==(t=r)?void 0:t.some(t=>{var n;return e.parentId===t.id&&(null==(n=e.context)?void 0:n.open)})})||[],n=n.concat(r);return n}let tS=t["useInsertionEffect".toString()]||(e=>e());function tT(e){let n=t.useRef(()=>{});return tS(()=>{n.current=e}),t.useCallback(function(){for(var e=arguments.length,t=Array(e),r=0;r!1),E="function"==typeof p?x:p,R=t.useRef(!1),{escapeKeyBubbles:S,outsidePressBubbles:T}=tP(y);return t.useEffect(()=>{if(!r||!f)return;function e(e){if("Escape"===e.key){let e=w?tR(w.nodesRef.current,l):[];if(e.length>0){let t=!0;if(e.forEach(e=>{var n;if(null!=(n=e.context)&&n.open&&!e.context.dataRef.current.__escapeKeyBubbles){t=!1;return}}),!t)return}i.emit("dismiss",{type:"escapeKey",data:{returnFocus:{preventScroll:!1}}}),o(!1)}}function t(e){var t;let n=R.current;if(R.current=!1,n||"function"==typeof E&&!E(e))return;let r="composedPath"in e?e.composedPath()[0]:e.target;if(tg(r)&&c){let t=c.ownerDocument.defaultView||window,n=r.scrollWidth>r.clientWidth,o=r.scrollHeight>r.clientHeight,i=o&&e.offsetX>r.clientWidth;if(o&&"rtl"===t.getComputedStyle(r).direction&&(i=e.offsetX<=r.offsetWidth-r.clientWidth),i||n&&e.offsetY>r.clientHeight)return}let u=w&&tR(w.nodesRef.current,l).some(t=>{var n;return tL(e,null==(n=t.context)?void 0:n.elements.floating)});if(tL(e,c)||tL(e,a)||u)return;let s=w?tR(w.nodesRef.current,l):[];if(s.length>0){let e=!0;if(s.forEach(t=>{var n;if(null!=(n=t.context)&&n.open&&!t.context.dataRef.current.__outsidePressBubbles){e=!1;return}}),!e)return}i.emit("dismiss",{type:"outsidePress",data:{returnFocus:b?{preventScroll:!0}:function(e){let t,n;if(0===e.mozInputSource&&e.isTrusted)return!0;let r=/Android/i;return(r.test(null!=(n=navigator.userAgentData)&&n.platform?n.platform:navigator.platform)||r.test((t=navigator.userAgentData)&&Array.isArray(t.brands)?t.brands.map(e=>{let{brand:t,version:n}=e;return t+"/"+n}).join(" "):navigator.userAgent))&&e.pointerType?"click"===e.type&&1===e.buttons:0===e.detail&&!e.pointerType}(e)||0===(t=e).width&&0===t.height||1===t.width&&1===t.height&&0===t.pressure&&0===t.detail&&"mouse"!==t.pointerType||t.width<1&&t.height<1&&0===t.pressure&&0===t.detail}}),o(!1)}function n(){o(!1)}s.current.__escapeKeyBubbles=S,s.current.__outsidePressBubbles=T;let p=tp(c);d&&p.addEventListener("keydown",e),E&&p.addEventListener(m,t);let h=[];return v&&(th(a)&&(h=ee(a)),th(c)&&(h=h.concat(ee(c))),!th(u)&&u&&u.contextElement&&(h=h.concat(ee(u.contextElement)))),(h=h.filter(e=>{var t;return e!==(null==(t=p.defaultView)?void 0:t.visualViewport)})).forEach(e=>{e.addEventListener("scroll",n,{passive:!0})}),()=>{d&&p.removeEventListener("keydown",e),E&&p.removeEventListener(m,t),h.forEach(e=>{e.removeEventListener("scroll",n)})}},[s,c,a,u,d,E,m,i,w,l,r,o,v,f,S,T,b]),t.useEffect(()=>{R.current=!1},[E,m]),t.useMemo(()=>f?{reference:{[tA[g]]:()=>{h&&(i.emit("dismiss",{type:"referencePress",data:{returnFocus:!1}}),o(!1))}},floating:{[tC[m]]:()=>{R.current=!0}}}:{},[f,i,h,m,g,o])},tk=function(e,n){let{open:r,onOpenChange:o,dataRef:i,events:l,refs:u,elements:{floating:a,domReference:c}}=e,{enabled:s=!0,keyboardOnly:f=!0}=void 0===n?{}:n,d=t.useRef(""),p=t.useRef(!1),m=t.useRef();return t.useEffect(()=>{if(!s)return;let e=tp(a).defaultView||window;function t(){!r&&tg(c)&&c===function(e){let t=e.activeElement;for(;(null==(n=t)||null==(r=n.shadowRoot)?void 0:r.activeElement)!=null;){var n,r;t=t.shadowRoot.activeElement}return t}(tp(c))&&(p.current=!0)}return e.addEventListener("blur",t),()=>{e.removeEventListener("blur",t)}},[a,c,r,s]),t.useEffect(()=>{if(s)return l.on("dismiss",e),()=>{l.off("dismiss",e)};function e(e){("referencePress"===e.type||"escapeKey"===e.type)&&(p.current=!0)}},[l,s]),t.useEffect(()=>()=>{clearTimeout(m.current)},[]),t.useMemo(()=>s?{reference:{onPointerDown(e){let{pointerType:t}=e;d.current=t,p.current=!!(t&&f)},onMouseLeave(){p.current=!1},onFocus(e){var t;p.current||"focus"===e.type&&(null==(t=i.current.openEvent)?void 0:t.type)==="mousedown"&&i.current.openEvent&&tL(i.current.openEvent,c)||(i.current.openEvent=e.nativeEvent,o(!0))},onBlur(e){p.current=!1;let t=e.relatedTarget,n=th(t)&&t.hasAttribute("data-floating-ui-focus-guard")&&"outside"===t.getAttribute("data-type");m.current=setTimeout(()=>{tE(u.floating.current,t)||tE(c,t)||n||o(!1)})}}}:{},[s,f,c,u,i,o])},tD=function(e,n){let{open:r}=e,{enabled:o=!0,role:i="dialog"}=void 0===n?{}:n,l=tc(),u=tc();return t.useMemo(()=>{let e={id:l,role:i};return o?"tooltip"===i?{reference:{"aria-describedby":r?l:void 0},floating:e}:{reference:{"aria-expanded":r?"true":"false","aria-haspopup":"alertdialog"===i?"dialog":i,"aria-controls":r?l:void 0,..."listbox"===i&&{role:"combobox"},..."menu"===i&&{id:u}},floating:{...e,..."menu"===i&&{"aria-labelledby":u}}}:{}},[o,i,r,l,u])};function tM(e,t,n){let r=new Map;return{..."floating"===n&&{tabIndex:-1},...e,...t.map(e=>e?e[n]:null).concat(e).reduce((e,t)=>(t&&Object.entries(t).forEach(t=>{let[n,o]=t;if(0===n.indexOf("on")){if(r.has(n)||r.set(n,[]),"function"==typeof o){var i;null==(i=r.get(n))||i.push(o),e[n]=function(){for(var e,t=arguments.length,o=Array(t),i=0;ie(...o))}}}else e[n]=o}),e),{})}}let tN=function(e){void 0===e&&(e=[]);let n=e,r=t.useCallback(t=>tM(t,e,"reference"),n),o=t.useCallback(t=>tM(t,e,"floating"),n),i=t.useCallback(t=>tM(t,e,"item"),e.map(e=>null==e?void 0:e.item));return t.useMemo(()=>({getReferenceProps:r,getFloatingProps:o,getItemProps:i}),[r,o,i])};var tF=e.i(444755);let tI=e=>{let[n,r]=(0,t.useState)(!1),[o,i]=(0,t.useState)(),{x:l,y:u,refs:a,strategy:c,context:s}=function(e){void 0===e&&(e={});let{open:n=!1,onOpenChange:r,nodeId:o}=e,i=function(e){void 0===e&&(e={});let{placement:n="bottom",strategy:r="absolute",middleware:o=[],platform:i,whileElementsMounted:l,open:u}=e,[a,c]=t.useState({x:null,y:null,strategy:r,placement:n,middlewareData:{},isPositioned:!1}),[s,f]=t.useState(o);tr(s,o)||f(o);let d=t.useRef(null),p=t.useRef(null),m=t.useRef(a),h=to(l),g=to(i),[v,y]=t.useState(null),[w,b]=t.useState(null),x=t.useCallback(e=>{d.current!==e&&(d.current=e,y(e))},[]),E=t.useCallback(e=>{p.current!==e&&(p.current=e,b(e))},[]),R=t.useCallback(()=>{if(!d.current||!p.current)return;let e={placement:n,strategy:r,middleware:s};g.current&&(e.platform=g.current),tt(d.current,p.current,e).then(e=>{let t={...e,isPositioned:!0};S.current&&!tr(m.current,t)&&(m.current=t,C.flushSync(()=>{c(t)}))})},[s,n,r,g]);tn(()=>{!1===u&&m.current.isPositioned&&(m.current.isPositioned=!1,c(e=>({...e,isPositioned:!1})))},[u]);let S=t.useRef(!1);tn(()=>(S.current=!0,()=>{S.current=!1}),[]),tn(()=>{if(v&&w)if(h.current)return h.current(v,w,R);else R()},[v,w,R,h]);let T=t.useMemo(()=>({reference:d,floating:p,setReference:x,setFloating:E}),[x,E]),L=t.useMemo(()=>({reference:v,floating:w}),[v,w]);return t.useMemo(()=>({...a,update:R,refs:T,elements:L,reference:x,floating:E}),[a,R,T,L,x,E])}(e),l=t.useContext(tf),u=t.useRef(null),a=t.useRef({}),c=t.useState(()=>{let e;return e=new Map,{emit(t,n){var r;null==(r=e.get(t))||r.forEach(e=>e(n))},on(t,n){e.set(t,[...e.get(t)||[],n])},off(t,n){e.set(t,(e.get(t)||[]).filter(e=>e!==n))}}})[0],[s,f]=t.useState(null),d=t.useCallback(e=>{let t=th(e)?{getBoundingClientRect:()=>e.getBoundingClientRect(),contextElement:e}:e;i.refs.setReference(t)},[i.refs]),p=t.useCallback(e=>{(th(e)||null===e)&&(u.current=e,f(e)),(th(i.refs.reference.current)||null===i.refs.reference.current||null!==e&&!th(e))&&i.refs.setReference(e)},[i.refs]),m=t.useMemo(()=>({...i.refs,setReference:p,setPositionReference:d,domReference:u}),[i.refs,p,d]),h=t.useMemo(()=>({...i.elements,domReference:s}),[i.elements,s]),g=tT(r),v=t.useMemo(()=>({...i,refs:m,elements:h,dataRef:a,nodeId:o,events:c,open:n,onOpenChange:g}),[i,o,c,n,g,m,h]);return ti(()=>{let e=null==l?void 0:l.nodesRef.current.find(e=>e.id===o);e&&(e.context=v)}),t.useMemo(()=>({...i,context:v,refs:m,reference:p,positionReference:d}),[i,m,v,p,d])}({open:n,onOpenChange:t=>{t&&e?i(setTimeout(()=>{r(t)},e)):(clearTimeout(o),r(t))},placement:"top",whileElementsMounted:e1,middleware:[e2(5),e7({fallbackAxisSideDirection:"start"}),e5()]}),{getReferenceProps:f,getFloatingProps:d}=tN([tx(s,{move:!1}),tk(s),tO(s),tD(s,{role:"tooltip"})]);return{tooltipProps:{open:n,x:l,y:u,refs:a,strategy:c,getFloatingProps:d},getReferenceProps:f}},tB=({text:e,open:n,x:r,y:o,refs:i,strategy:l,getFloatingProps:u})=>n&&e?t.default.createElement("div",Object.assign({className:(0,tF.tremorTwMerge)("max-w-xs text-sm z-20 rounded-tremor-default opacity-100 px-2.5 py-1","text-white bg-tremor-background-emphasis","dark:text-tremor-content-emphasis dark:bg-white"),ref:i.setFloating,style:{position:l,top:null!=o?o:0,left:null!=r?r:0}},u()),e):null;tB.displayName="Tooltip",e.s(["default",()=>tB,"useTooltip",()=>tI],829087)}]); \ No newline at end of file diff --git a/litellm/proxy/_experimental/out/_next/static/chunks/01d07594f3f5250a.js b/litellm/proxy/_experimental/out/_next/static/chunks/01d07594f3f5250a.js new file mode 100644 index 00000000000..86b6f94a57a --- /dev/null +++ b/litellm/proxy/_experimental/out/_next/static/chunks/01d07594f3f5250a.js @@ -0,0 +1 @@ +(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,582458,e=>{"use strict";let t=(0,e.i(475254).default)("triangle-alert",[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]]);e.s(["default",()=>t])},788191,e=>{"use strict";e.i(247167);var t=e.i(931067),a=e.i(271645);let s={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M512 64C264.6 64 64 264.6 64 512s200.6 448 448 448 448-200.6 448-448S759.4 64 512 64zm0 820c-205.4 0-372-166.6-372-372s166.6-372 372-372 372 166.6 372 372-166.6 372-372 372z"}},{tag:"path",attrs:{d:"M719.4 499.1l-296.1-215A15.9 15.9 0 00398 297v430c0 13.1 14.8 20.5 25.3 12.9l296.1-215a15.9 15.9 0 000-25.8zm-257.6 134V390.9L628.5 512 461.8 633.1z"}}]},name:"play-circle",theme:"outlined"};var r=e.i(9583),i=a.forwardRef(function(e,i){return a.createElement(r.default,(0,t.default)({},e,{ref:i,icon:s}))});e.s(["PlayCircleOutlined",0,i],788191)},19732,e=>{"use strict";e.i(247167);var t=e.i(931067),a=e.i(271645);let s={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M512 472a40 40 0 1080 0 40 40 0 10-80 0zm367 352.9L696.3 352V178H768v-68H256v68h71.7v174L145 824.9c-2.8 7.4-4.3 15.2-4.3 23.1 0 35.3 28.7 64 64 64h614.6c7.9 0 15.7-1.5 23.1-4.3 33-12.7 49.4-49.8 36.6-82.8zM395.7 364.7V180h232.6v184.7L719.2 600c-20.7-5.3-42.1-8-63.9-8-61.2 0-119.2 21.5-165.3 60a188.78 188.78 0 01-121.3 43.9c-32.7 0-64.1-8.3-91.8-23.7l118.8-307.5zM210.5 844l41.7-107.8c35.7 18.1 75.4 27.8 116.6 27.8 61.2 0 119.2-21.5 165.3-60 33.9-28.2 76.3-43.9 121.3-43.9 35 0 68.4 9.5 97.6 27.1L813.5 844h-603z"}}]},name:"experiment",theme:"outlined"};var r=e.i(9583),i=a.forwardRef(function(e,i){return a.createElement(r.default,(0,t.default)({},e,{ref:i,icon:s}))});e.s(["ExperimentOutlined",0,i],19732)},153702,e=>{"use strict";e.i(247167);var t=e.i(931067),a=e.i(271645);let s={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M888 792H200V168c0-4.4-3.6-8-8-8h-56c-4.4 0-8 3.6-8 8v688c0 4.4 3.6 8 8 8h752c4.4 0 8-3.6 8-8v-56c0-4.4-3.6-8-8-8zm-600-80h56c4.4 0 8-3.6 8-8V560c0-4.4-3.6-8-8-8h-56c-4.4 0-8 3.6-8 8v144c0 4.4 3.6 8 8 8zm152 0h56c4.4 0 8-3.6 8-8V384c0-4.4-3.6-8-8-8h-56c-4.4 0-8 3.6-8 8v320c0 4.4 3.6 8 8 8zm152 0h56c4.4 0 8-3.6 8-8V462c0-4.4-3.6-8-8-8h-56c-4.4 0-8 3.6-8 8v242c0 4.4 3.6 8 8 8zm152 0h56c4.4 0 8-3.6 8-8V304c0-4.4-3.6-8-8-8h-56c-4.4 0-8 3.6-8 8v400c0 4.4 3.6 8 8 8z"}}]},name:"bar-chart",theme:"outlined"};var r=e.i(9583),i=a.forwardRef(function(e,i){return a.createElement(r.default,(0,t.default)({},e,{ref:i,icon:s}))});e.s(["BarChartOutlined",0,i],153702)},645526,e=>{"use strict";e.i(247167);var t=e.i(931067),a=e.i(271645);let s={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M824.2 699.9a301.55 301.55 0 00-86.4-60.4C783.1 602.8 812 546.8 812 484c0-110.8-92.4-201.7-203.2-200-109.1 1.7-197 90.6-197 200 0 62.8 29 118.8 74.2 155.5a300.95 300.95 0 00-86.4 60.4C345 754.6 314 826.8 312 903.8a8 8 0 008 8.2h56c4.3 0 7.9-3.4 8-7.7 1.9-58 25.4-112.3 66.7-153.5A226.62 226.62 0 01612 684c60.9 0 118.2 23.7 161.3 66.8C814.5 792 838 846.3 840 904.3c.1 4.3 3.7 7.7 8 7.7h56a8 8 0 008-8.2c-2-77-33-149.2-87.8-203.9zM612 612c-34.2 0-66.4-13.3-90.5-37.5a126.86 126.86 0 01-37.5-91.8c.3-32.8 13.4-64.5 36.3-88 24-24.6 56.1-38.3 90.4-38.7 33.9-.3 66.8 12.9 91 36.6 24.8 24.3 38.4 56.8 38.4 91.4 0 34.2-13.3 66.3-37.5 90.5A127.3 127.3 0 01612 612zM361.5 510.4c-.9-8.7-1.4-17.5-1.4-26.4 0-15.9 1.5-31.4 4.3-46.5.7-3.6-1.2-7.3-4.5-8.8-13.6-6.1-26.1-14.5-36.9-25.1a127.54 127.54 0 01-38.7-95.4c.9-32.1 13.8-62.6 36.3-85.6 24.7-25.3 57.9-39.1 93.2-38.7 31.9.3 62.7 12.6 86 34.4 7.9 7.4 14.7 15.6 20.4 24.4 2 3.1 5.9 4.4 9.3 3.2 17.6-6.1 36.2-10.4 55.3-12.4 5.6-.6 8.8-6.6 6.3-11.6-32.5-64.3-98.9-108.7-175.7-109.9-110.9-1.7-203.3 89.2-203.3 199.9 0 62.8 28.9 118.8 74.2 155.5-31.8 14.7-61.1 35-86.5 60.4-54.8 54.7-85.8 126.9-87.8 204a8 8 0 008 8.2h56.1c4.3 0 7.9-3.4 8-7.7 1.9-58 25.4-112.3 66.7-153.5 29.4-29.4 65.4-49.8 104.7-59.7 3.9-1 6.5-4.7 6-8.7z"}}]},name:"team",theme:"outlined"};var r=e.i(9583),i=a.forwardRef(function(e,i){return a.createElement(r.default,(0,t.default)({},e,{ref:i,icon:s}))});e.s(["TeamOutlined",0,i],645526)},299251,e=>{"use strict";e.i(247167);var t=e.i(931067),a=e.i(271645);let s={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M894 462c30.9 0 43.8-39.7 18.7-58L530.8 126.2a31.81 31.81 0 00-37.6 0L111.3 404c-25.1 18.2-12.2 58 18.8 58H192v374h-72c-4.4 0-8 3.6-8 8v52c0 4.4 3.6 8 8 8h784c4.4 0 8-3.6 8-8v-52c0-4.4-3.6-8-8-8h-72V462h62zM512 196.7l271.1 197.2H240.9L512 196.7zM264 462h117v374H264V462zm189 0h117v374H453V462zm307 374H642V462h118v374z"}}]},name:"bank",theme:"outlined"};var r=e.i(9583),i=a.forwardRef(function(e,i){return a.createElement(r.default,(0,t.default)({},e,{ref:i,icon:s}))});e.s(["BankOutlined",0,i],299251)},777579,e=>{"use strict";e.i(247167);var t=e.i(931067),a=e.i(271645);let s={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M888 792H200V168c0-4.4-3.6-8-8-8h-56c-4.4 0-8 3.6-8 8v688c0 4.4 3.6 8 8 8h752c4.4 0 8-3.6 8-8v-56c0-4.4-3.6-8-8-8zM305.8 637.7c3.1 3.1 8.1 3.1 11.3 0l138.3-137.6L583 628.5c3.1 3.1 8.2 3.1 11.3 0l275.4-275.3c3.1-3.1 3.1-8.2 0-11.3l-39.6-39.6a8.03 8.03 0 00-11.3 0l-230 229.9L461.4 404a8.03 8.03 0 00-11.3 0L266.3 586.7a8.03 8.03 0 000 11.3l39.5 39.7z"}}]},name:"line-chart",theme:"outlined"};var r=e.i(9583),i=a.forwardRef(function(e,i){return a.createElement(r.default,(0,t.default)({},e,{ref:i,icon:s}))});e.s(["LineChartOutlined",0,i],777579)},438957,e=>{"use strict";e.i(247167);var t=e.i(931067),a=e.i(271645);let s={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M608 112c-167.9 0-304 136.1-304 304 0 70.3 23.9 135 63.9 186.5l-41.1 41.1-62.3-62.3a8.15 8.15 0 00-11.4 0l-39.8 39.8a8.15 8.15 0 000 11.4l62.3 62.3-44.9 44.9-62.3-62.3a8.15 8.15 0 00-11.4 0l-39.8 39.8a8.15 8.15 0 000 11.4l62.3 62.3-65.3 65.3a8.03 8.03 0 000 11.3l42.3 42.3c3.1 3.1 8.2 3.1 11.3 0l253.6-253.6A304.06 304.06 0 00608 720c167.9 0 304-136.1 304-304S775.9 112 608 112zm161.2 465.2C726.2 620.3 668.9 644 608 644c-60.9 0-118.2-23.7-161.2-66.8-43.1-43-66.8-100.3-66.8-161.2 0-60.9 23.7-118.2 66.8-161.2 43-43.1 100.3-66.8 161.2-66.8 60.9 0 118.2 23.7 161.2 66.8 43.1 43 66.8 100.3 66.8 161.2 0 60.9-23.7 118.2-66.8 161.2z"}}]},name:"key",theme:"outlined"};var r=e.i(9583),i=a.forwardRef(function(e,i){return a.createElement(r.default,(0,t.default)({},e,{ref:i,icon:s}))});e.s(["KeyOutlined",0,i],438957)},232164,e=>{"use strict";e.i(247167);var t=e.i(931067),a=e.i(271645);let s={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M483.2 790.3L861.4 412c1.7-1.7 2.5-4 2.3-6.3l-25.5-301.4c-.7-7.8-6.8-13.9-14.6-14.6L522.2 64.3c-2.3-.2-4.7.6-6.3 2.3L137.7 444.8a8.03 8.03 0 000 11.3l334.2 334.2c3.1 3.2 8.2 3.2 11.3 0zm62.6-651.7l224.6 19 19 224.6L477.5 694 233.9 450.5l311.9-311.9zm60.16 186.23a48 48 0 1067.88-67.89 48 48 0 10-67.88 67.89zM889.7 539.8l-39.6-39.5a8.03 8.03 0 00-11.3 0l-362 361.3-237.6-237a8.03 8.03 0 00-11.3 0l-39.6 39.5a8.03 8.03 0 000 11.3l243.2 242.8 39.6 39.5c3.1 3.1 8.2 3.1 11.3 0l407.3-406.6c3.1-3.1 3.1-8.2 0-11.3z"}}]},name:"tags",theme:"outlined"};var r=e.i(9583),i=a.forwardRef(function(e,i){return a.createElement(r.default,(0,t.default)({},e,{ref:i,icon:s}))});e.s(["TagsOutlined",0,i],232164)},210612,e=>{"use strict";e.i(247167);var t=e.i(931067),a=e.i(271645);let s={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M832 64H192c-17.7 0-32 14.3-32 32v832c0 17.7 14.3 32 32 32h640c17.7 0 32-14.3 32-32V96c0-17.7-14.3-32-32-32zm-600 72h560v208H232V136zm560 480H232V408h560v208zm0 272H232V680h560v208zM304 240a40 40 0 1080 0 40 40 0 10-80 0zm0 272a40 40 0 1080 0 40 40 0 10-80 0zm0 272a40 40 0 1080 0 40 40 0 10-80 0z"}}]},name:"database",theme:"outlined"};var r=e.i(9583),i=a.forwardRef(function(e,i){return a.createElement(r.default,(0,t.default)({},e,{ref:i,icon:s}))});e.s(["DatabaseOutlined",0,i],210612)},218129,e=>{"use strict";e.i(247167);var t=e.i(931067),a=e.i(271645);let s={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M917.7 148.8l-42.4-42.4c-1.6-1.6-3.6-2.3-5.7-2.3s-4.1.8-5.7 2.3l-76.1 76.1a199.27 199.27 0 00-112.1-34.3c-51.2 0-102.4 19.5-141.5 58.6L432.3 308.7a8.03 8.03 0 000 11.3L704 591.7c1.6 1.6 3.6 2.3 5.7 2.3 2 0 4.1-.8 5.7-2.3l101.9-101.9c68.9-69 77-175.7 24.3-253.5l76.1-76.1c3.1-3.2 3.1-8.3 0-11.4zM769.1 441.7l-59.4 59.4-186.8-186.8 59.4-59.4c24.9-24.9 58.1-38.7 93.4-38.7 35.3 0 68.4 13.7 93.4 38.7 24.9 24.9 38.7 58.1 38.7 93.4 0 35.3-13.8 68.4-38.7 93.4zm-190.2 105a8.03 8.03 0 00-11.3 0L501 613.3 410.7 523l66.7-66.7c3.1-3.1 3.1-8.2 0-11.3L441 408.6a8.03 8.03 0 00-11.3 0L363 475.3l-43-43a7.85 7.85 0 00-5.7-2.3c-2 0-4.1.8-5.7 2.3L206.8 534.2c-68.9 69-77 175.7-24.3 253.5l-76.1 76.1a8.03 8.03 0 000 11.3l42.4 42.4c1.6 1.6 3.6 2.3 5.7 2.3s4.1-.8 5.7-2.3l76.1-76.1c33.7 22.9 72.9 34.3 112.1 34.3 51.2 0 102.4-19.5 141.5-58.6l101.9-101.9c3.1-3.1 3.1-8.2 0-11.3l-43-43 66.7-66.7c3.1-3.1 3.1-8.2 0-11.3l-36.6-36.2zM441.7 769.1a131.32 131.32 0 01-93.4 38.7c-35.3 0-68.4-13.7-93.4-38.7a131.32 131.32 0 01-38.7-93.4c0-35.3 13.7-68.4 38.7-93.4l59.4-59.4 186.8 186.8-59.4 59.4z"}}]},name:"api",theme:"outlined"};var r=e.i(9583),i=a.forwardRef(function(e,i){return a.createElement(r.default,(0,t.default)({},e,{ref:i,icon:s}))});e.s(["ApiOutlined",0,i],218129)},366308,e=>{"use strict";e.i(247167);var t=e.i(931067),a=e.i(271645);let s={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M876.6 239.5c-.5-.9-1.2-1.8-2-2.5-5-5-13.1-5-18.1 0L684.2 409.3l-67.9-67.9L788.7 169c.8-.8 1.4-1.6 2-2.5 3.6-6.1 1.6-13.9-4.5-17.5-98.2-58-226.8-44.7-311.3 39.7-67 67-89.2 162-66.5 247.4l-293 293c-3 3-2.8 7.9.3 11l169.7 169.7c3.1 3.1 8.1 3.3 11 .3l292.9-292.9c85.5 22.8 180.5.7 247.6-66.4 84.4-84.5 97.7-213.1 39.7-311.3zM786 499.8c-58.1 58.1-145.3 69.3-214.6 33.6l-8.8 8.8-.1-.1-274 274.1-79.2-79.2 230.1-230.1s0 .1.1.1l52.8-52.8c-35.7-69.3-24.5-156.5 33.6-214.6a184.2 184.2 0 01144-53.5L537 318.9a32.05 32.05 0 000 45.3l124.5 124.5a32.05 32.05 0 0045.3 0l132.8-132.8c3.7 51.8-14.4 104.8-53.6 143.9z"}}]},name:"tool",theme:"outlined"};var r=e.i(9583),i=a.forwardRef(function(e,i){return a.createElement(r.default,(0,t.default)({},e,{ref:i,icon:s}))});e.s(["ToolOutlined",0,i],366308)},313603,e=>{"use strict";e.i(247167);var t=e.i(931067),a=e.i(271645);let s={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M924.8 625.7l-65.5-56c3.1-19 4.7-38.4 4.7-57.8s-1.6-38.8-4.7-57.8l65.5-56a32.03 32.03 0 009.3-35.2l-.9-2.6a443.74 443.74 0 00-79.7-137.9l-1.8-2.1a32.12 32.12 0 00-35.1-9.5l-81.3 28.9c-30-24.6-63.5-44-99.7-57.6l-15.7-85a32.05 32.05 0 00-25.8-25.7l-2.7-.5c-52.1-9.4-106.9-9.4-159 0l-2.7.5a32.05 32.05 0 00-25.8 25.7l-15.8 85.4a351.86 351.86 0 00-99 57.4l-81.9-29.1a32 32 0 00-35.1 9.5l-1.8 2.1a446.02 446.02 0 00-79.7 137.9l-.9 2.6c-4.5 12.5-.8 26.5 9.3 35.2l66.3 56.6c-3.1 18.8-4.6 38-4.6 57.1 0 19.2 1.5 38.4 4.6 57.1L99 625.5a32.03 32.03 0 00-9.3 35.2l.9 2.6c18.1 50.4 44.9 96.9 79.7 137.9l1.8 2.1a32.12 32.12 0 0035.1 9.5l81.9-29.1c29.8 24.5 63.1 43.9 99 57.4l15.8 85.4a32.05 32.05 0 0025.8 25.7l2.7.5a449.4 449.4 0 00159 0l2.7-.5a32.05 32.05 0 0025.8-25.7l15.7-85a350 350 0 0099.7-57.6l81.3 28.9a32 32 0 0035.1-9.5l1.8-2.1c34.8-41.1 61.6-87.5 79.7-137.9l.9-2.6c4.5-12.3.8-26.3-9.3-35zM788.3 465.9c2.5 15.1 3.8 30.6 3.8 46.1s-1.3 31-3.8 46.1l-6.6 40.1 74.7 63.9a370.03 370.03 0 01-42.6 73.6L721 702.8l-31.4 25.8c-23.9 19.6-50.5 35-79.3 45.8l-38.1 14.3-17.9 97a377.5 377.5 0 01-85 0l-17.9-97.2-37.8-14.5c-28.5-10.8-55-26.2-78.7-45.7l-31.4-25.9-93.4 33.2c-17-22.9-31.2-47.6-42.6-73.6l75.5-64.5-6.5-40c-2.4-14.9-3.7-30.3-3.7-45.5 0-15.3 1.2-30.6 3.7-45.5l6.5-40-75.5-64.5c11.3-26.1 25.6-50.7 42.6-73.6l93.4 33.2 31.4-25.9c23.7-19.5 50.2-34.9 78.7-45.7l37.9-14.3 17.9-97.2c28.1-3.2 56.8-3.2 85 0l17.9 97 38.1 14.3c28.7 10.8 55.4 26.2 79.3 45.8l31.4 25.8 92.8-32.9c17 22.9 31.2 47.6 42.6 73.6L781.8 426l6.5 39.9zM512 326c-97.2 0-176 78.8-176 176s78.8 176 176 176 176-78.8 176-176-78.8-176-176-176zm79.2 255.2A111.6 111.6 0 01512 614c-29.9 0-58-11.7-79.2-32.8A111.6 111.6 0 01400 502c0-29.9 11.7-58 32.8-79.2C454 401.6 482.1 390 512 390c29.9 0 58 11.6 79.2 32.8A111.6 111.6 0 01624 502c0 29.9-11.7 58-32.8 79.2z"}}]},name:"setting",theme:"outlined"};var r=e.i(9583),i=a.forwardRef(function(e,i){return a.createElement(r.default,(0,t.default)({},e,{ref:i,icon:s}))});e.s(["SettingOutlined",0,i],313603)},531278,e=>{"use strict";let t=(0,e.i(475254).default)("loader-circle",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]]);e.s(["Loader2",()=>t],531278)},372943,899268,e=>{"use strict";e.i(247167);var t=e.i(8211),a=e.i(271645),s=e.i(343794),r=e.i(529681),i=e.i(242064),l=e.i(704914),c=e.i(876556),n=e.i(290224),d=e.i(251224),o=function(e,t){var a={};for(var s in e)Object.prototype.hasOwnProperty.call(e,s)&&0>t.indexOf(s)&&(a[s]=e[s]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols)for(var r=0,s=Object.getOwnPropertySymbols(e);rt.indexOf(s[r])&&Object.prototype.propertyIsEnumerable.call(e,s[r])&&(a[s[r]]=e[s[r]]);return a};function m({suffixCls:e,tagName:t,displayName:s}){return s=>a.forwardRef((r,i)=>a.createElement(s,Object.assign({ref:i,suffixCls:e,tagName:t},r)))}let u=a.forwardRef((e,t)=>{let{prefixCls:r,suffixCls:l,className:c,tagName:n}=e,m=o(e,["prefixCls","suffixCls","className","tagName"]),{getPrefixCls:u}=a.useContext(i.ConfigContext),f=u("layout",r),[h,g,v]=(0,d.default)(f),x=l?`${f}-${l}`:f;return h(a.createElement(n,Object.assign({className:(0,s.default)(r||x,c,g,v),ref:t},m)))}),f=a.forwardRef((e,m)=>{let{direction:u}=a.useContext(i.ConfigContext),[f,h]=a.useState([]),{prefixCls:g,className:v,rootClassName:x,children:p,hasSider:y,tagName:b,style:N}=e,w=o(e,["prefixCls","className","rootClassName","children","hasSider","tagName","style"]),j=(0,r.default)(w,["suffixCls"]),{getPrefixCls:L,className:z,style:M}=(0,i.useComponentConfig)("layout"),O=L("layout",g),C="boolean"==typeof y?y:!!f.length||(0,c.default)(p).some(e=>e.type===n.default),[k,H,V]=(0,d.default)(O),_=(0,s.default)(O,{[`${O}-has-sider`]:C,[`${O}-rtl`]:"rtl"===u},z,v,x,H,V),R=a.useMemo(()=>({siderHook:{addSider:e=>{h(a=>[].concat((0,t.default)(a),[e]))},removeSider:e=>{h(t=>t.filter(t=>t!==e))}}}),[]);return k(a.createElement(l.LayoutContext.Provider,{value:R},a.createElement(b,Object.assign({ref:m,className:_,style:Object.assign(Object.assign({},M),N)},j),p)))}),h=m({tagName:"div",displayName:"Layout"})(f),g=m({suffixCls:"header",tagName:"header",displayName:"Header"})(u),v=m({suffixCls:"footer",tagName:"footer",displayName:"Footer"})(u),x=m({suffixCls:"content",tagName:"main",displayName:"Content"})(u);h.Header=g,h.Footer=v,h.Content=x,h.Sider=n.default,h._InternalSiderContext=n.SiderContext,e.s(["Layout",0,h],372943);var p=e.i(60699);e.s(["Menu",()=>p.default],899268)},592143,e=>{"use strict";var t=e.i(609587);e.s(["ConfigProvider",()=>t.default])},182399,e=>{"use strict";e.i(247167);var t=e.i(931067),a=e.i(271645);let s={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M856 376H648V168c0-8.8-7.2-16-16-16H168c-8.8 0-16 7.2-16 16v464c0 8.8 7.2 16 16 16h208v208c0 8.8 7.2 16 16 16h464c8.8 0 16-7.2 16-16V392c0-8.8-7.2-16-16-16zm-480 16v188H220V220h360v156H392c-8.8 0-16 7.2-16 16zm204 52v136H444V444h136zm224 360H444V648h188c8.8 0 16-7.2 16-16V444h156v360z"}}]},name:"block",theme:"outlined"};var r=e.i(9583),i=a.forwardRef(function(e,i){return a.createElement(r.default,(0,t.default)({},e,{ref:i,icon:s}))});e.s(["BlockOutlined",0,i],182399)},477189,457202,e=>{"use strict";e.i(247167);var t=e.i(931067),a=e.i(271645);let s={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M464 144H160c-8.8 0-16 7.2-16 16v304c0 8.8 7.2 16 16 16h304c8.8 0 16-7.2 16-16V160c0-8.8-7.2-16-16-16zm-52 268H212V212h200v200zm452-268H560c-8.8 0-16 7.2-16 16v304c0 8.8 7.2 16 16 16h304c8.8 0 16-7.2 16-16V160c0-8.8-7.2-16-16-16zm-52 268H612V212h200v200zM464 544H160c-8.8 0-16 7.2-16 16v304c0 8.8 7.2 16 16 16h304c8.8 0 16-7.2 16-16V560c0-8.8-7.2-16-16-16zm-52 268H212V612h200v200zm452-268H560c-8.8 0-16 7.2-16 16v304c0 8.8 7.2 16 16 16h304c8.8 0 16-7.2 16-16V560c0-8.8-7.2-16-16-16zm-52 268H612V612h200v200z"}}]},name:"appstore",theme:"outlined"};var r=e.i(9583),i=a.forwardRef(function(e,i){return a.createElement(r.default,(0,t.default)({},e,{ref:i,icon:s}))});e.s(["AppstoreOutlined",0,i],477189);let l={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M296 250c-4.4 0-8 3.6-8 8v48c0 4.4 3.6 8 8 8h384c4.4 0 8-3.6 8-8v-48c0-4.4-3.6-8-8-8H296zm184 144H296c-4.4 0-8 3.6-8 8v48c0 4.4 3.6 8 8 8h184c4.4 0 8-3.6 8-8v-48c0-4.4-3.6-8-8-8zm-48 458H208V148h560v320c0 4.4 3.6 8 8 8h56c4.4 0 8-3.6 8-8V108c0-17.7-14.3-32-32-32H168c-17.7 0-32 14.3-32 32v784c0 17.7 14.3 32 32 32h264c4.4 0 8-3.6 8-8v-56c0-4.4-3.6-8-8-8zm440-88H728v-36.6c46.3-13.8 80-56.6 80-107.4 0-61.9-50.1-112-112-112s-112 50.1-112 112c0 50.7 33.7 93.6 80 107.4V764H520c-8.8 0-16 7.2-16 16v152c0 8.8 7.2 16 16 16h352c8.8 0 16-7.2 16-16V780c0-8.8-7.2-16-16-16zM646 620c0-27.6 22.4-50 50-50s50 22.4 50 50-22.4 50-50 50-50-22.4-50-50zm180 266H566v-60h260v60z"}}]},name:"audit",theme:"outlined"};var c=a.forwardRef(function(e,s){return a.createElement(r.default,(0,t.default)({},e,{ref:s,icon:l}))});e.s(["AuditOutlined",0,c],457202)},878894,664659,655900,299023,25652,882293,e=>{"use strict";var t=e.i(582458);e.s(["AlertTriangle",()=>t.default],878894);var a=e.i(475254);let s=(0,a.default)("chevron-down",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]);e.s(["ChevronDown",()=>s],664659);let r=(0,a.default)("chevron-up",[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]]);e.s(["ChevronUp",()=>r],655900);let i=(0,a.default)("minus",[["path",{d:"M5 12h14",key:"1ays0h"}]]);e.s(["Minus",()=>i],299023);let l=(0,a.default)("trending-up",[["path",{d:"M16 7h6v6",key:"box55l"}],["path",{d:"m22 7-8.5 8.5-5-5L2 17",key:"1t1m79"}]]);e.s(["TrendingUp",()=>l],25652);let c=(0,a.default)("user-check",[["path",{d:"m16 11 2 2 4-4",key:"9rsbq5"}],["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}]]);e.s(["UserCheck",()=>c],882293)},761911,e=>{"use strict";let t=(0,e.i(475254).default)("users",[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["path",{d:"M16 3.128a4 4 0 0 1 0 7.744",key:"16gr8j"}],["path",{d:"M22 21v-2a4 4 0 0 0-3-3.87",key:"kshegd"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}]]);e.s(["Users",()=>t],761911)},297178,e=>{"use strict";var t=e.i(843476);e.i(389083);var a=e.i(878894);e.i(664659),e.i(655900);var s=e.i(531278),r=e.i(299023),i=e.i(25652),l=e.i(882293),c=e.i(761911),n=e.i(271645),d=e.i(764205);let o=(...e)=>e.filter(Boolean).join(" ");function m({accessToken:e,width:m=220}){let[u,f]=(0,n.useState)(!1),[h,g]=(0,n.useState)(!1),[v,x]=(0,n.useState)(null),[p,y]=(0,n.useState)(!1),[b,N]=(0,n.useState)(null);(0,n.useEffect)(()=>{(async()=>{if(e){y(!0),N(null);try{let t=await (0,d.getRemainingUsers)(e);x(t)}catch(e){console.error("Failed to fetch usage data:",e),N("Failed to load usage data")}finally{y(!1)}}})()},[e]);let{isOverLimit:w,isNearLimit:j,usagePercentage:L,userMetrics:z,teamMetrics:M}=(e=>{if(!e)return{isOverLimit:!1,isNearLimit:!1,usagePercentage:0,userMetrics:{isOverLimit:!1,isNearLimit:!1,usagePercentage:0},teamMetrics:{isOverLimit:!1,isNearLimit:!1,usagePercentage:0}};let t=e.total_users?e.total_users_used/e.total_users*100:0,a=t>100,s=t>=80&&t<=100,r=e.total_teams?e.total_teams_used/e.total_teams*100:0,i=r>100,l=r>=80&&r<=100,c=a||i;return{isOverLimit:c,isNearLimit:(s||l)&&!c,usagePercentage:Math.max(t,r),userMetrics:{isOverLimit:a,isNearLimit:s,usagePercentage:t},teamMetrics:{isOverLimit:i,isNearLimit:l,usagePercentage:r}}})(v);return e&&(v?.total_users!==null||v?.total_teams!==null)?(0,t.jsx)("div",{className:"fixed bottom-4 left-4 z-50",style:{width:`${Math.min(m,220)}px`},children:(0,t.jsx)(()=>h?(0,t.jsx)("button",{onClick:()=>g(!1),className:o("bg-white border border-gray-200 rounded-lg shadow-sm p-3 hover:shadow-md transition-all w-full"),title:"Show usage details",children:(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)(c.Users,{className:"h-4 w-4 flex-shrink-0"}),(w||j)&&(0,t.jsx)("span",{className:"flex-shrink-0",children:w?(0,t.jsx)(a.AlertTriangle,{className:"h-3 w-3"}):j?(0,t.jsx)(i.TrendingUp,{className:"h-3 w-3"}):null}),(0,t.jsxs)("div",{className:"flex items-center gap-2 text-sm font-medium truncate",children:[v&&null!==v.total_users&&(0,t.jsxs)("span",{className:o("flex-shrink-0 px-1.5 py-0.5 rounded text-xs border",z.isOverLimit&&"bg-red-50 text-red-700 border-red-200",z.isNearLimit&&"bg-yellow-50 text-yellow-700 border-yellow-200",!z.isOverLimit&&!z.isNearLimit&&"bg-gray-50 text-gray-700 border-gray-200"),children:["U: ",v.total_users_used,"/",v.total_users]}),v&&null!==v.total_teams&&(0,t.jsxs)("span",{className:o("flex-shrink-0 px-1.5 py-0.5 rounded text-xs border",M.isOverLimit&&"bg-red-50 text-red-700 border-red-200",M.isNearLimit&&"bg-yellow-50 text-yellow-700 border-yellow-200",!M.isOverLimit&&!M.isNearLimit&&"bg-gray-50 text-gray-700 border-gray-200"),children:["T: ",v.total_teams_used,"/",v.total_teams]}),!v||null===v.total_users&&null===v.total_teams&&(0,t.jsx)("span",{className:"truncate",children:"Usage"})]})]})}):p?(0,t.jsx)("div",{className:"bg-white border border-gray-200 rounded-lg shadow-sm p-4 w-full",children:(0,t.jsxs)("div",{className:"flex items-center justify-center gap-2 py-2",children:[(0,t.jsx)(s.Loader2,{className:"h-4 w-4 animate-spin"}),(0,t.jsx)("span",{className:"text-sm text-gray-500 truncate",children:"Loading..."})]})}):b||!v?(0,t.jsx)("div",{className:"bg-white border border-gray-200 rounded-lg shadow-sm p-4 group w-full",children:(0,t.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,t.jsx)("div",{className:"flex-1 min-w-0",children:(0,t.jsx)("span",{className:"text-sm text-gray-500 truncate block",children:b||"No data"})}),(0,t.jsx)("button",{onClick:()=>g(!0),className:"opacity-0 group-hover:opacity-100 p-1 hover:bg-gray-100 rounded transition-all flex-shrink-0",title:"Minimize",children:(0,t.jsx)(r.Minus,{className:"h-3 w-3 text-gray-400"})})]})}):(0,t.jsxs)("div",{className:o("bg-white border rounded-lg shadow-sm p-3 transition-all duration-200 group w-full"),children:[(0,t.jsxs)("div",{className:"flex items-center justify-between gap-2 mb-3",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[(0,t.jsx)(c.Users,{className:"h-4 w-4 flex-shrink-0"}),(0,t.jsx)("span",{className:"font-medium text-sm truncate",children:"Usage"})]}),(0,t.jsx)("button",{onClick:()=>g(!0),className:"opacity-0 group-hover:opacity-100 p-1 hover:bg-gray-100 rounded transition-all flex-shrink-0",title:"Minimize",children:(0,t.jsx)(r.Minus,{className:"h-3 w-3 text-gray-400"})})]}),(0,t.jsxs)("div",{className:"space-y-3 text-sm",children:[null!==v.total_users&&(0,t.jsxs)("div",{className:o("space-y-1 border rounded-md p-2",z.isOverLimit&&"border-red-200 bg-red-50",z.isNearLimit&&"border-yellow-200 bg-yellow-50"),children:[(0,t.jsxs)("div",{className:"flex items-center gap-2 text-xs text-gray-600 mb-1",children:[(0,t.jsx)(c.Users,{className:"h-3 w-3"}),(0,t.jsx)("span",{className:"font-medium",children:"Users"}),(0,t.jsx)("span",{className:o("ml-1 px-1.5 py-0.5 rounded border",z.isOverLimit&&"bg-red-50 text-red-700 border-red-200",z.isNearLimit&&"bg-yellow-50 text-yellow-700 border-yellow-200",!z.isOverLimit&&!z.isNearLimit&&"bg-gray-50 text-gray-600 border-gray-200"),children:z.isOverLimit?"Over limit":z.isNearLimit?"Near limit":"OK"})]}),(0,t.jsxs)("div",{className:"flex justify-between items-center",children:[(0,t.jsx)("span",{className:"text-gray-600 text-xs",children:"Used:"}),(0,t.jsxs)("span",{className:"font-medium text-right",children:[v.total_users_used,"/",v.total_users]})]}),(0,t.jsxs)("div",{className:"flex justify-between items-center",children:[(0,t.jsx)("span",{className:"text-gray-600 text-xs",children:"Remaining:"}),(0,t.jsx)("span",{className:o("font-medium text-right",z.isOverLimit&&"text-red-600",z.isNearLimit&&"text-yellow-600"),children:v.total_users_remaining})]}),(0,t.jsxs)("div",{className:"flex justify-between items-center",children:[(0,t.jsx)("span",{className:"text-gray-600 text-xs",children:"Usage:"}),(0,t.jsxs)("span",{className:"font-medium text-right",children:[Math.round(z.usagePercentage),"%"]})]}),(0,t.jsx)("div",{className:"w-full bg-gray-200 rounded-full h-2",children:(0,t.jsx)("div",{className:o("h-2 rounded-full transition-all duration-300",z.isOverLimit&&"bg-red-500",z.isNearLimit&&"bg-yellow-500",!z.isOverLimit&&!z.isNearLimit&&"bg-green-500"),style:{width:`${Math.min(z.usagePercentage,100)}%`}})})]}),null!==v.total_teams&&(0,t.jsxs)("div",{className:o("space-y-1 border rounded-md p-2",M.isOverLimit&&"border-red-200 bg-red-50",M.isNearLimit&&"border-yellow-200 bg-yellow-50"),children:[(0,t.jsxs)("div",{className:"flex items-center gap-2 text-xs text-gray-600 mb-1",children:[(0,t.jsx)(l.UserCheck,{className:"h-3 w-3"}),(0,t.jsx)("span",{className:"font-medium",children:"Teams"}),(0,t.jsx)("span",{className:o("ml-1 px-1.5 py-0.5 rounded border",M.isOverLimit&&"bg-red-50 text-red-700 border-red-200",M.isNearLimit&&"bg-yellow-50 text-yellow-700 border-yellow-200",!M.isOverLimit&&!M.isNearLimit&&"bg-gray-50 text-gray-600 border-gray-200"),children:M.isOverLimit?"Over limit":M.isNearLimit?"Near limit":"OK"})]}),(0,t.jsxs)("div",{className:"flex justify-between items-center",children:[(0,t.jsx)("span",{className:"text-gray-600 text-xs",children:"Used:"}),(0,t.jsxs)("span",{className:"font-medium text-right",children:[v.total_teams_used,"/",v.total_teams]})]}),(0,t.jsxs)("div",{className:"flex justify-between items-center",children:[(0,t.jsx)("span",{className:"text-gray-600 text-xs",children:"Remaining:"}),(0,t.jsx)("span",{className:o("font-medium text-right",M.isOverLimit&&"text-red-600",M.isNearLimit&&"text-yellow-600"),children:v.total_teams_remaining})]}),(0,t.jsxs)("div",{className:"flex justify-between items-center",children:[(0,t.jsx)("span",{className:"text-gray-600 text-xs",children:"Usage:"}),(0,t.jsxs)("span",{className:"font-medium text-right",children:[Math.round(M.usagePercentage),"%"]})]}),(0,t.jsx)("div",{className:"w-full bg-gray-200 rounded-full h-2",children:(0,t.jsx)("div",{className:o("h-2 rounded-full transition-all duration-300",M.isOverLimit&&"bg-red-500",M.isNearLimit&&"bg-yellow-500",!M.isOverLimit&&!M.isNearLimit&&"bg-green-500"),style:{width:`${Math.min(M.usagePercentage,100)}%`}})})]})]})]}),{})}):null}e.s(["default",()=>m])}]); \ No newline at end of file diff --git a/litellm/proxy/_experimental/out/_next/static/chunks/023ea71d56024e51.js b/litellm/proxy/_experimental/out/_next/static/chunks/023ea71d56024e51.js new file mode 100644 index 00000000000..6545cebed4c --- /dev/null +++ b/litellm/proxy/_experimental/out/_next/static/chunks/023ea71d56024e51.js @@ -0,0 +1 @@ +(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,596115,e=>{"use strict";var s=e.i(843476),l=e.i(271645),a=e.i(764205),t=e.i(584578),r=e.i(808613),i=e.i(774197),o=e.i(468133),n=e.i(708347),d=e.i(304967),c=e.i(994388),m=e.i(309426),h=e.i(599724),u=e.i(350967),x=e.i(404206),p=e.i(747871),g=e.i(500330),_=e.i(752978),j=e.i(197647),f=e.i(653824),b=e.i(881073),y=e.i(723731),v=e.i(278587);let w=({lastRefreshed:e,onRefresh:l,userRole:a,children:t})=>(0,s.jsxs)(f.TabGroup,{className:"gap-2 h-[75vh] w-full",children:[(0,s.jsxs)(b.TabList,{className:"flex justify-between mt-2 w-full items-center",children:[(0,s.jsxs)("div",{className:"flex",children:[(0,s.jsx)(j.Tab,{children:"Your Teams"}),(0,s.jsx)(j.Tab,{children:"Available Teams"}),(0,n.isAdminRole)(a||"")&&(0,s.jsx)(j.Tab,{children:"Default Team Settings"})]}),(0,s.jsxs)("div",{className:"flex items-center space-x-2",children:[e&&(0,s.jsxs)(h.Text,{children:["Last Refreshed: ",e]}),(0,s.jsx)(_.Icon,{icon:v.RefreshIcon,variant:"shadow",size:"xs",className:"self-center",onClick:l})]})]}),(0,s.jsx)(y.TabPanels,{children:t})]});var T=e.i(206929),C=e.i(35983);let N=({filters:e,organizations:l,showFilters:a,onToggleFilters:t,onChange:r,onReset:i})=>(0,s.jsxs)("div",{className:"flex flex-col space-y-4",children:[(0,s.jsxs)("div",{className:"flex flex-wrap items-center gap-3",children:[(0,s.jsxs)("div",{className:"relative w-64",children:[(0,s.jsx)("input",{type:"text",placeholder:"Search by Team Name...",className:"w-full px-3 py-2 pl-8 border rounded-md text-sm focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500",value:e.team_alias,onChange:e=>r("team_alias",e.target.value)}),(0,s.jsx)("svg",{className:"absolute left-2.5 top-2.5 h-4 w-4 text-gray-500",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,s.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"})})]}),(0,s.jsxs)("button",{className:`px-3 py-2 text-sm border rounded-md hover:bg-gray-50 flex items-center gap-2 ${a?"bg-gray-100":""}`,onClick:()=>t(!a),children:[(0,s.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,s.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M3 4a1 1 0 011-1h16a1 1 0 011 1v2.586a1 1 0 01-.293.707l-6.414 6.414a1 1 0 00-.293.707V17l-4 4v-6.586a1 1 0 00-.293-.707L3.293 7.293A1 1 0 013 6.586V4z"})}),"Filters",(e.team_id||e.team_alias||e.organization_id)&&(0,s.jsx)("span",{className:"w-2 h-2 rounded-full bg-blue-500"})]}),(0,s.jsxs)("button",{className:"px-3 py-2 text-sm border rounded-md hover:bg-gray-50 flex items-center gap-2",onClick:i,children:[(0,s.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,s.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"})}),"Reset Filters"]})]}),a&&(0,s.jsxs)("div",{className:"flex flex-wrap items-center gap-3 mt-3",children:[(0,s.jsxs)("div",{className:"relative w-64",children:[(0,s.jsx)("input",{type:"text",placeholder:"Enter Team ID",className:"w-full px-3 py-2 pl-8 border rounded-md text-sm focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500",value:e.team_id,onChange:e=>r("team_id",e.target.value)}),(0,s.jsx)("svg",{className:"absolute left-2.5 top-2.5 h-4 w-4 text-gray-500",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,s.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5.121 17.804A13.937 13.937 0 0112 16c2.5 0 4.847.655 6.879 1.804M15 10a3 3 0 11-6 0 3 3 0 016 0zm6 2a9 9 0 11-18 0 9 9 0 0118 0z"})})]}),(0,s.jsx)("div",{className:"w-64",children:(0,s.jsx)(T.Select,{value:e.organization_id||"",onValueChange:e=>r("organization_id",e),placeholder:"Select Organization",children:l?.map(e=>(0,s.jsx)(C.SelectItem,{value:e.organization_id||"",children:e.organization_alias||e.organization_id},e.organization_id))})})]})]});var S=e.i(135214),k=e.i(269200),I=e.i(942232),F=e.i(977572),A=e.i(427612),z=e.i(64848),M=e.i(496020),O=e.i(592968),P=e.i(591935),L=e.i(68155),D=e.i(389083),B=e.i(871943),E=e.i(502547),R=e.i(355619);let V=({team:e})=>{let[a,t]=(0,l.useState)(!1);return(0,s.jsx)(F.TableCell,{style:{maxWidth:"8-x",whiteSpace:"pre-wrap",overflow:"hidden"},className:e.models.length>3?"px-0":"",children:(0,s.jsx)("div",{className:"flex flex-col",children:Array.isArray(e.models)?(0,s.jsx)("div",{className:"flex flex-col",children:0===e.models.length?(0,s.jsx)(D.Badge,{size:"xs",className:"mb-1",color:"red",children:(0,s.jsx)(h.Text,{children:"All Proxy Models"})}):(0,s.jsx)(s.Fragment,{children:(0,s.jsxs)("div",{className:"flex items-start",children:[e.models.length>3&&(0,s.jsx)("div",{children:(0,s.jsx)(_.Icon,{icon:a?B.ChevronDownIcon:E.ChevronRightIcon,className:"cursor-pointer",size:"xs",onClick:()=>{t(e=>!e)}})}),(0,s.jsxs)("div",{className:"flex flex-wrap gap-1",children:[e.models.slice(0,3).map((e,l)=>"all-proxy-models"===e?(0,s.jsx)(D.Badge,{size:"xs",color:"red",children:(0,s.jsx)(h.Text,{children:"All Proxy Models"})},l):(0,s.jsx)(D.Badge,{size:"xs",color:"blue",children:(0,s.jsx)(h.Text,{children:e.length>30?`${(0,R.getModelDisplayName)(e).slice(0,30)}...`:(0,R.getModelDisplayName)(e)})},l)),e.models.length>3&&!a&&(0,s.jsx)(D.Badge,{size:"xs",color:"gray",className:"cursor-pointer",children:(0,s.jsxs)(h.Text,{children:["+",e.models.length-3," ",e.models.length-3==1?"more model":"more models"]})}),a&&(0,s.jsx)("div",{className:"flex flex-wrap gap-1",children:e.models.slice(3).map((e,l)=>"all-proxy-models"===e?(0,s.jsx)(D.Badge,{size:"xs",color:"red",children:(0,s.jsx)(h.Text,{children:"All Proxy Models"})},l+3):(0,s.jsx)(D.Badge,{size:"xs",color:"blue",children:(0,s.jsx)(h.Text,{children:e.length>30?`${(0,R.getModelDisplayName)(e).slice(0,30)}...`:(0,R.getModelDisplayName)(e)})},l+3))})]})]})})}):null})})};var H=e.i(918549),H=H,W=e.i(846753),W=W;let U=({team:e,userId:l})=>{var a;let t,r=(a=((e,s)=>{if(!s)return null;let l=e.members_with_roles?.find(e=>e.user_id===s);return l?.role??null})(e,l),t="inline-flex items-center px-2.5 py-0.5 rounded-md text-xs font-medium border","admin"===a?(0,s.jsxs)("span",{className:t,style:{backgroundColor:"#EEF2FF",color:"#3730A3",borderColor:"#C7D2FE"},children:[(0,s.jsx)(H.default,{className:"h-3 w-3 mr-1"}),"Admin"]}):(0,s.jsxs)("span",{className:t,style:{backgroundColor:"#F3F4F6",color:"#4B5563",borderColor:"#E5E7EB"},children:[(0,s.jsx)(W.default,{className:"h-3 w-3 mr-1"}),"Member"]}));return(0,s.jsx)(F.TableCell,{children:r})},$=({teams:e,currentOrg:l,setSelectedTeamId:a,perTeamInfo:t,userRole:r,userId:i,setEditTeam:o,onDeleteTeam:n})=>(0,s.jsxs)(k.Table,{children:[(0,s.jsx)(A.TableHead,{children:(0,s.jsxs)(M.TableRow,{children:[(0,s.jsx)(z.TableHeaderCell,{children:"Team Name"}),(0,s.jsx)(z.TableHeaderCell,{children:"Team ID"}),(0,s.jsx)(z.TableHeaderCell,{children:"Created"}),(0,s.jsx)(z.TableHeaderCell,{children:"Spend (USD)"}),(0,s.jsx)(z.TableHeaderCell,{children:"Budget (USD)"}),(0,s.jsx)(z.TableHeaderCell,{children:"Models"}),(0,s.jsx)(z.TableHeaderCell,{children:"Organization"}),(0,s.jsx)(z.TableHeaderCell,{children:"Your Role"}),(0,s.jsx)(z.TableHeaderCell,{children:"Info"})]})}),(0,s.jsx)(I.TableBody,{children:e&&e.length>0?e.filter(e=>!l||e.organization_id===l.organization_id).sort((e,s)=>new Date(s.created_at).getTime()-new Date(e.created_at).getTime()).map(e=>(0,s.jsxs)(M.TableRow,{children:[(0,s.jsx)(F.TableCell,{style:{maxWidth:"4px",whiteSpace:"pre-wrap",overflow:"hidden"},children:e.team_alias}),(0,s.jsx)(F.TableCell,{children:(0,s.jsx)("div",{className:"overflow-hidden",children:(0,s.jsx)(O.Tooltip,{title:e.team_id,children:(0,s.jsxs)(c.Button,{size:"xs",variant:"light",className:"font-mono text-blue-500 bg-blue-50 hover:bg-blue-100 text-xs font-normal px-2 py-0.5 text-left overflow-hidden truncate max-w-[200px]",onClick:()=>{a(e.team_id)},children:[e.team_id.slice(0,7),"..."]})})})}),(0,s.jsx)(F.TableCell,{style:{maxWidth:"4px",whiteSpace:"pre-wrap",overflow:"hidden"},children:e.created_at?new Date(e.created_at).toLocaleDateString():"N/A"}),(0,s.jsx)(F.TableCell,{style:{maxWidth:"4px",whiteSpace:"pre-wrap",overflow:"hidden"},children:(0,g.formatNumberWithCommas)(e.spend,4)}),(0,s.jsx)(F.TableCell,{style:{maxWidth:"4px",whiteSpace:"pre-wrap",overflow:"hidden"},children:null!==e.max_budget&&void 0!==e.max_budget?e.max_budget:"No limit"}),(0,s.jsx)(V,{team:e}),(0,s.jsx)(F.TableCell,{children:e.organization_id}),(0,s.jsx)(U,{team:e,userId:i}),(0,s.jsxs)(F.TableCell,{children:[(0,s.jsxs)(h.Text,{children:[t&&e.team_id&&t[e.team_id]&&t[e.team_id].keys&&t[e.team_id].keys.length," ","Keys"]}),(0,s.jsxs)(h.Text,{children:[t&&e.team_id&&t[e.team_id]&&t[e.team_id].team_info&&t[e.team_id].team_info.members_with_roles&&t[e.team_id].team_info.members_with_roles.length," ","Members"]})]}),(0,s.jsx)(F.TableCell,{children:"Admin"==r?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(_.Icon,{icon:P.PencilAltIcon,size:"sm",onClick:()=>{a(e.team_id),o(!0)}}),(0,s.jsx)(_.Icon,{onClick:()=>n(e.team_id),icon:L.TrashIcon,size:"sm"})]}):null})]},e.team_id)):null})]});var G=e.i(582458),G=G,J=e.i(995926);let K=({teams:e,teamToDelete:a,onCancel:t,onConfirm:r})=>{let[i,o]=(0,l.useState)(""),n=e?.find(e=>e.team_id===a),d=n?.team_alias||"",c=n?.keys?.length||0,m=i===d;return(0,s.jsx)("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50",children:(0,s.jsxs)("div",{className:"bg-white rounded-lg shadow-xl w-full max-w-2xl min-h-[380px] py-6 overflow-hidden transform transition-all flex flex-col justify-between",children:[(0,s.jsxs)("div",{children:[(0,s.jsxs)("div",{className:"flex items-center justify-between px-6 py-4 border-b border-gray-200",children:[(0,s.jsx)("h3",{className:"text-lg font-semibold text-gray-900",children:"Delete Team"}),(0,s.jsx)("button",{onClick:()=>{t(),o("")},className:"text-gray-400 hover:text-gray-500 focus:outline-none",children:(0,s.jsx)(J.XIcon,{size:20})})]}),(0,s.jsxs)("div",{className:"px-6 py-4",children:[c>0&&(0,s.jsxs)("div",{className:"flex items-start gap-3 p-4 bg-red-50 border border-red-100 rounded-md mb-5",children:[(0,s.jsx)("div",{className:"text-red-500 mt-0.5",children:(0,s.jsx)(G.default,{size:20})}),(0,s.jsxs)("div",{children:[(0,s.jsxs)("p",{className:"text-base font-medium text-red-600",children:["Warning: This team has ",c," associated key",c>1?"s":"","."]}),(0,s.jsx)("p",{className:"text-base text-red-600 mt-2",children:"Deleting the team will also delete all associated keys. This action is irreversible."})]})]}),(0,s.jsx)("p",{className:"text-base text-gray-600 mb-5",children:"Are you sure you want to force delete this team and all its keys?"}),(0,s.jsxs)("div",{className:"mb-5",children:[(0,s.jsxs)("label",{className:"block text-base font-medium text-gray-700 mb-2",children:["Type ",(0,s.jsx)("span",{className:"underline",children:d})," to confirm deletion:"]}),(0,s.jsx)("input",{type:"text",value:i,onChange:e=>o(e.target.value),placeholder:"Enter team name exactly",className:"w-full px-4 py-3 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500 text-base",autoFocus:!0})]})]})]}),(0,s.jsxs)("div",{className:"px-6 py-4 bg-gray-50 flex justify-end gap-4",children:[(0,s.jsx)("button",{onClick:()=>{t(),o("")},className:"px-5 py-3 bg-white border border-gray-300 rounded-md text-base font-medium text-gray-700 hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500",children:"Cancel"}),(0,s.jsx)("button",{onClick:r,disabled:!m,className:`px-5 py-3 rounded-md text-base font-medium text-white focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-red-500 ${m?"bg-red-600 hover:bg-red-700":"bg-red-300 cursor-not-allowed"}`,children:"Force Delete"})]})]})})};var q=e.i(464571),Y=e.i(311451),X=e.i(212931),Q=e.i(199133),Z=e.i(790848),ee=e.i(677667),es=e.i(130643),el=e.i(898667),ea=e.i(779241),et=e.i(827252),er=e.i(435451),ei=e.i(916940),eo=e.i(75921),en=e.i(552130),ed=e.i(651904),ec=e.i(533882),em=e.i(727749),eh=e.i(390605);let eu=({isTeamModalVisible:e,handleOk:t,handleCancel:i,currentOrg:o,organizations:n,teams:d,setTeams:c,modelAliases:m,setModelAliases:u,loggingSettings:x,setLoggingSettings:p,setIsTeamModalVisible:g})=>{let{userId:_,userRole:j,accessToken:f,premiumUser:b}=(0,S.default)(),[y]=r.Form.useForm(),[v,w]=(0,l.useState)([]),[T,C]=(0,l.useState)(null),[N,k]=(0,l.useState)([]),[I,F]=(0,l.useState)([]),[A,z]=(0,l.useState)([]),[M,P]=(0,l.useState)([]),[L,D]=(0,l.useState)(!1);(0,l.useEffect)(()=>{(async()=>{try{if(null===_||null===j||null===f)return;let e=await (0,R.fetchAvailableModelsForTeamOrKey)(_,j,f);e&&w(e)}catch(e){console.error("Error fetching user models:",e)}})()},[f,_,j,d]),(0,l.useEffect)(()=>{let e;console.log(`currentOrgForCreateTeam: ${T}`);let s=(e=[],T&&T.models.length>0?(console.log(`organization.models: ${T.models}`),e=T.models):e=v,(0,R.unfurlWildcardModelsInList)(e,v));console.log(`models: ${s}`),k(s),y.setFieldValue("models",[])},[T,v,y]);let B=async()=>{try{if(null==f)return;let e=await (0,a.fetchMCPAccessGroups)(f);P(e)}catch(e){console.error("Failed to fetch MCP access groups:",e)}};(0,l.useEffect)(()=>{B()},[f,B]),(0,l.useEffect)(()=>{let e=async()=>{try{if(null==f)return;let e=(await (0,a.getPoliciesList)(f)).policies.map(e=>e.policy_name);z(e)}catch(e){console.error("Failed to fetch policies:",e)}};(async()=>{try{if(null==f)return;let e=(await (0,a.getGuardrailsList)(f)).guardrails.map(e=>e.guardrail_name);F(e)}catch(e){console.error("Failed to fetch guardrails:",e)}})(),e()},[f]);let E=async e=>{try{if(console.log(`formValues: ${JSON.stringify(e)}`),null!=f){let s=e?.team_alias,l=d?.map(e=>e.team_alias)??[],t=e?.organization_id||o?.organization_id;if(""===t||"string"!=typeof t?e.organization_id=null:e.organization_id=t.trim(),l.includes(s))throw Error(`Team alias ${s} already exists, please pick another alias`);if(em.default.info("Creating Team"),x.length>0){let s={};if(e.metadata)try{s=JSON.parse(e.metadata)}catch(e){console.warn("Invalid JSON in metadata field, starting with empty object")}s={...s,logging:x.filter(e=>e.callback_name)},e.metadata=JSON.stringify(s)}if(e.secret_manager_settings&&"string"==typeof e.secret_manager_settings)if(""===e.secret_manager_settings.trim())delete e.secret_manager_settings;else try{e.secret_manager_settings=JSON.parse(e.secret_manager_settings)}catch(e){throw Error("Failed to parse secret manager settings: "+e)}if(e.allowed_vector_store_ids&&e.allowed_vector_store_ids.length>0||e.allowed_mcp_servers_and_groups&&(e.allowed_mcp_servers_and_groups.servers?.length>0||e.allowed_mcp_servers_and_groups.accessGroups?.length>0||e.allowed_mcp_servers_and_groups.toolPermissions)){if(e.object_permission={},e.allowed_vector_store_ids&&e.allowed_vector_store_ids.length>0&&(e.object_permission.vector_stores=e.allowed_vector_store_ids,delete e.allowed_vector_store_ids),e.allowed_mcp_servers_and_groups){let{servers:s,accessGroups:l}=e.allowed_mcp_servers_and_groups;s&&s.length>0&&(e.object_permission.mcp_servers=s),l&&l.length>0&&(e.object_permission.mcp_access_groups=l),delete e.allowed_mcp_servers_and_groups}if(e.mcp_tool_permissions&&Object.keys(e.mcp_tool_permissions).length>0&&(e.object_permission||(e.object_permission={}),e.object_permission.mcp_tool_permissions=e.mcp_tool_permissions,delete e.mcp_tool_permissions),e.allowed_agents_and_groups){let{agents:s,accessGroups:l}=e.allowed_agents_and_groups;e.object_permission||(e.object_permission={}),s&&s.length>0&&(e.object_permission.agents=s),l&&l.length>0&&(e.object_permission.agent_access_groups=l),delete e.allowed_agents_and_groups}}e.allowed_mcp_access_groups&&e.allowed_mcp_access_groups.length>0&&(e.object_permission||(e.object_permission={}),e.object_permission.mcp_access_groups=e.allowed_mcp_access_groups,delete e.allowed_mcp_access_groups),Object.keys(m).length>0&&(e.model_aliases=m);let r=await (0,a.teamCreateCall)(f,e);null!==d?c([...d,r]):c([r]),console.log(`response for team create call: ${r}`),em.default.success("Team created"),y.resetFields(),p([]),u({}),g(!1)}}catch(e){console.error("Error creating the team:",e),em.default.fromBackend("Error creating the team: "+e)}};return(0,s.jsx)(X.Modal,{title:"Create Team",open:e,width:1e3,footer:null,onOk:t,onCancel:i,children:(0,s.jsxs)(r.Form,{form:y,onFinish:E,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(r.Form.Item,{label:"Team Name",name:"team_alias",rules:[{required:!0,message:"Please input a team name"}],children:(0,s.jsx)(ea.TextInput,{placeholder:""})}),(0,s.jsx)(r.Form.Item,{label:(0,s.jsxs)("span",{children:["Organization"," ",(0,s.jsx)(O.Tooltip,{title:(0,s.jsxs)("span",{children:["Organizations can have multiple teams. Learn more about"," ",(0,s.jsx)("a",{href:"https://docs.litellm.ai/docs/proxy/user_management_heirarchy",target:"_blank",rel:"noopener noreferrer",style:{color:"#1890ff",textDecoration:"underline"},onClick:e=>e.stopPropagation(),children:"user management hierarchy"})]}),children:(0,s.jsx)(et.InfoCircleOutlined,{style:{marginLeft:"4px"}})})]}),name:"organization_id",initialValue:o?o.organization_id:null,className:"mt-8",children:(0,s.jsx)(Q.Select,{showSearch:!0,allowClear:!0,placeholder:"Search or select an Organization",onChange:e=>{y.setFieldValue("organization_id",e),C(n?.find(s=>s.organization_id===e)||null)},filterOption:(e,s)=>!!s&&(s.children?.toString()||"").toLowerCase().includes(e.toLowerCase()),optionFilterProp:"children",children:n?.map(e=>(0,s.jsxs)(Q.Select.Option,{value:e.organization_id,children:[(0,s.jsx)("span",{className:"font-medium",children:e.organization_alias})," ",(0,s.jsxs)("span",{className:"text-gray-500",children:["(",e.organization_id,")"]})]},e.organization_id))})}),(0,s.jsx)(r.Form.Item,{label:(0,s.jsxs)("span",{children:["Models"," ",(0,s.jsx)(O.Tooltip,{title:"These are the models that your selected team has access to",children:(0,s.jsx)(et.InfoCircleOutlined,{style:{marginLeft:"4px"}})})]}),name:"models",children:(0,s.jsxs)(Q.Select,{mode:"multiple",placeholder:"Select models",style:{width:"100%"},children:[(0,s.jsx)(Q.Select.Option,{value:"all-proxy-models",children:"All Proxy Models"},"all-proxy-models"),N.map(e=>(0,s.jsx)(Q.Select.Option,{value:e,children:(0,R.getModelDisplayName)(e)},e))]})}),(0,s.jsx)(r.Form.Item,{label:"Max Budget (USD)",name:"max_budget",children:(0,s.jsx)(er.default,{step:.01,precision:2,width:200})}),(0,s.jsx)(r.Form.Item,{className:"mt-8",label:"Reset Budget",name:"budget_duration",children:(0,s.jsxs)(Q.Select,{defaultValue:null,placeholder:"n/a",children:[(0,s.jsx)(Q.Select.Option,{value:"24h",children:"daily"}),(0,s.jsx)(Q.Select.Option,{value:"7d",children:"weekly"}),(0,s.jsx)(Q.Select.Option,{value:"30d",children:"monthly"})]})}),(0,s.jsx)(r.Form.Item,{label:"Tokens per minute Limit (TPM)",name:"tpm_limit",children:(0,s.jsx)(er.default,{step:1,width:400})}),(0,s.jsx)(r.Form.Item,{label:"Requests per minute Limit (RPM)",name:"rpm_limit",children:(0,s.jsx)(er.default,{step:1,width:400})}),(0,s.jsxs)(ee.Accordion,{className:"mt-20 mb-8",onClick:()=>{L||(B(),D(!0))},children:[(0,s.jsx)(el.AccordionHeader,{children:(0,s.jsx)("b",{children:"Additional Settings"})}),(0,s.jsxs)(es.AccordionBody,{children:[(0,s.jsx)(r.Form.Item,{label:"Team ID",name:"team_id",help:"ID of the team you want to create. If not provided, it will be generated automatically.",children:(0,s.jsx)(ea.TextInput,{onChange:e=>{e.target.value=e.target.value.trim()}})}),(0,s.jsx)(r.Form.Item,{label:"Team Member Budget (USD)",name:"team_member_budget",normalize:e=>e?Number(e):void 0,tooltip:"This is the individual budget for a user in the team.",children:(0,s.jsx)(er.default,{step:.01,precision:2,width:200})}),(0,s.jsx)(r.Form.Item,{label:"Team Member Key Duration (eg: 1d, 1mo)",name:"team_member_key_duration",tooltip:"Set a limit to the duration of a team member's key. Format: 30s (seconds), 30m (minutes), 30h (hours), 30d (days), 1mo (month)",children:(0,s.jsx)(ea.TextInput,{placeholder:"e.g., 30d"})}),(0,s.jsx)(r.Form.Item,{label:"Team Member RPM Limit",name:"team_member_rpm_limit",tooltip:"The RPM (Requests Per Minute) limit for individual team members",children:(0,s.jsx)(er.default,{step:1,width:400})}),(0,s.jsx)(r.Form.Item,{label:"Team Member TPM Limit",name:"team_member_tpm_limit",tooltip:"The TPM (Tokens Per Minute) limit for individual team members",children:(0,s.jsx)(er.default,{step:1,width:400})}),(0,s.jsx)(r.Form.Item,{label:"Metadata",name:"metadata",help:"Additional team metadata. Enter metadata as JSON object.",children:(0,s.jsx)(Y.Input.TextArea,{rows:4})}),(0,s.jsx)(r.Form.Item,{label:"Secret Manager Settings",name:"secret_manager_settings",help:b?"Enter secret manager configuration as a JSON object.":"Premium feature - Upgrade to manage secret manager settings.",rules:[{validator:async(e,s)=>{if(!s)return Promise.resolve();try{return JSON.parse(s),Promise.resolve()}catch(e){return Promise.reject(Error("Please enter valid JSON"))}}}],children:(0,s.jsx)(Y.Input.TextArea,{rows:4,placeholder:'{"namespace": "admin", "mount": "secret", "path_prefix": "litellm"}',disabled:!b})}),(0,s.jsx)(r.Form.Item,{label:(0,s.jsxs)("span",{children:["Guardrails"," ",(0,s.jsx)(O.Tooltip,{title:"Setup your first guardrail",children:(0,s.jsx)("a",{href:"https://docs.litellm.ai/docs/proxy/guardrails/quick_start",target:"_blank",rel:"noopener noreferrer",onClick:e=>e.stopPropagation(),children:(0,s.jsx)(et.InfoCircleOutlined,{style:{marginLeft:"4px"}})})})]}),name:"guardrails",className:"mt-8",help:"Select existing guardrails or enter new ones",children:(0,s.jsx)(Q.Select,{mode:"tags",style:{width:"100%"},placeholder:"Select or enter guardrails",options:I.map(e=>({value:e,label:e}))})}),(0,s.jsx)(r.Form.Item,{label:(0,s.jsxs)("span",{children:["Disable Global Guardrails"," ",(0,s.jsx)(O.Tooltip,{title:"When enabled, this team will bypass any guardrails configured to run on every request (global guardrails)",children:(0,s.jsx)(et.InfoCircleOutlined,{style:{marginLeft:"4px"}})})]}),name:"disable_global_guardrails",className:"mt-4",valuePropName:"checked",help:"Bypass global guardrails for this team",children:(0,s.jsx)(Z.Switch,{checkedChildren:"Yes",unCheckedChildren:"No"})}),(0,s.jsx)(r.Form.Item,{label:(0,s.jsxs)("span",{children:["Policies"," ",(0,s.jsx)(O.Tooltip,{title:"Apply policies to this team to control guardrails and other settings",children:(0,s.jsx)("a",{href:"https://docs.litellm.ai/docs/proxy/guardrails/guardrail_policies",target:"_blank",rel:"noopener noreferrer",onClick:e=>e.stopPropagation(),children:(0,s.jsx)(et.InfoCircleOutlined,{style:{marginLeft:"4px"}})})})]}),name:"policies",className:"mt-8",help:"Select existing policies or enter new ones",children:(0,s.jsx)(Q.Select,{mode:"tags",style:{width:"100%"},placeholder:"Select or enter policies",options:A.map(e=>({value:e,label:e}))})}),(0,s.jsx)(r.Form.Item,{label:(0,s.jsxs)("span",{children:["Allowed Vector Stores"," ",(0,s.jsx)(O.Tooltip,{title:"Select which vector stores this team can access by default. Leave empty for access to all vector stores",children:(0,s.jsx)(et.InfoCircleOutlined,{style:{marginLeft:"4px"}})})]}),name:"allowed_vector_store_ids",className:"mt-8",help:"Select vector stores this team can access. Leave empty for access to all vector stores",children:(0,s.jsx)(ei.default,{onChange:e=>y.setFieldValue("allowed_vector_store_ids",e),value:y.getFieldValue("allowed_vector_store_ids"),accessToken:f||"",placeholder:"Select vector stores (optional)"})})]})]}),(0,s.jsxs)(ee.Accordion,{className:"mt-8 mb-8",children:[(0,s.jsx)(el.AccordionHeader,{children:(0,s.jsx)("b",{children:"MCP Settings"})}),(0,s.jsxs)(es.AccordionBody,{children:[(0,s.jsx)(r.Form.Item,{label:(0,s.jsxs)("span",{children:["Allowed MCP Servers"," ",(0,s.jsx)(O.Tooltip,{title:"Select which MCP servers or access groups this team can access",children:(0,s.jsx)(et.InfoCircleOutlined,{style:{marginLeft:"4px"}})})]}),name:"allowed_mcp_servers_and_groups",className:"mt-4",help:"Select MCP servers or access groups this team can access",children:(0,s.jsx)(eo.default,{onChange:e=>y.setFieldValue("allowed_mcp_servers_and_groups",e),value:y.getFieldValue("allowed_mcp_servers_and_groups"),accessToken:f||"",placeholder:"Select MCP servers or access groups (optional)"})}),(0,s.jsx)(r.Form.Item,{name:"mcp_tool_permissions",initialValue:{},hidden:!0,children:(0,s.jsx)(Y.Input,{type:"hidden"})}),(0,s.jsx)(r.Form.Item,{noStyle:!0,shouldUpdate:(e,s)=>e.allowed_mcp_servers_and_groups!==s.allowed_mcp_servers_and_groups||e.mcp_tool_permissions!==s.mcp_tool_permissions,children:()=>(0,s.jsx)("div",{className:"mt-6",children:(0,s.jsx)(eh.default,{accessToken:f||"",selectedServers:y.getFieldValue("allowed_mcp_servers_and_groups")?.servers||[],toolPermissions:y.getFieldValue("mcp_tool_permissions")||{},onChange:e=>y.setFieldsValue({mcp_tool_permissions:e})})})})]})]}),(0,s.jsxs)(ee.Accordion,{className:"mt-8 mb-8",children:[(0,s.jsx)(el.AccordionHeader,{children:(0,s.jsx)("b",{children:"Agent Settings"})}),(0,s.jsx)(es.AccordionBody,{children:(0,s.jsx)(r.Form.Item,{label:(0,s.jsxs)("span",{children:["Allowed Agents"," ",(0,s.jsx)(O.Tooltip,{title:"Select which agents or access groups this team can access",children:(0,s.jsx)(et.InfoCircleOutlined,{style:{marginLeft:"4px"}})})]}),name:"allowed_agents_and_groups",className:"mt-4",help:"Select agents or access groups this team can access",children:(0,s.jsx)(en.default,{onChange:e=>y.setFieldValue("allowed_agents_and_groups",e),value:y.getFieldValue("allowed_agents_and_groups"),accessToken:f||"",placeholder:"Select agents or access groups (optional)"})})})]}),(0,s.jsxs)(ee.Accordion,{className:"mt-8 mb-8",children:[(0,s.jsx)(el.AccordionHeader,{children:(0,s.jsx)("b",{children:"Logging Settings"})}),(0,s.jsx)(es.AccordionBody,{children:(0,s.jsx)("div",{className:"mt-4",children:(0,s.jsx)(ed.default,{value:x,onChange:p,premiumUser:b})})})]}),(0,s.jsxs)(ee.Accordion,{className:"mt-8 mb-8",children:[(0,s.jsx)(el.AccordionHeader,{children:(0,s.jsx)("b",{children:"Model Aliases"})}),(0,s.jsx)(es.AccordionBody,{children:(0,s.jsxs)("div",{className:"mt-4",children:[(0,s.jsx)(h.Text,{className:"text-sm text-gray-600 mb-4",children:"Create custom aliases for models that can be used by team members in API calls. This allows you to create shortcuts for specific models."}),(0,s.jsx)(ec.default,{accessToken:f||"",initialModelAliases:m,onAliasUpdate:u,showExampleConfig:!1})]})})]})]}),(0,s.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,s.jsx)(q.Button,{htmlType:"submit",children:"Create Team"})})]})})},ex=({teams:e,accessToken:_,setTeams:j,userID:f,userRole:b,organizations:y,premiumUser:v=!1})=>{let[T,C]=(0,l.useState)(null),[k,I]=(0,l.useState)(!1),[F,A]=(0,l.useState)({team_id:"",team_alias:"",organization_id:"",sort_by:"created_at",sort_order:"desc"}),[z]=r.Form.useForm(),[M]=r.Form.useForm(),[O,P]=(0,l.useState)(null),[L,D]=(0,l.useState)(!1),[B,E]=(0,l.useState)(!1),[R,V]=(0,l.useState)(!1),[H,W]=(0,l.useState)(!1),[U,G]=(0,l.useState)([]),[J,q]=(0,l.useState)(!1),[Y,X]=(0,l.useState)(null),[Q,Z]=(0,l.useState)({}),[ee,es]=(0,l.useState)([]),[el,ea]=(0,l.useState)({}),{lastRefreshed:et,onRefreshClick:er}=(({currentOrg:e,setTeams:s})=>{let[a,r]=(0,l.useState)(""),{accessToken:i,userId:o,userRole:n}=(0,S.default)(),d=(0,l.useCallback)(()=>{r(new Date().toLocaleString())},[]);return(0,l.useEffect)(()=>{i&&(0,t.fetchTeams)(i,o,n,e,s).then(),d()},[i,e,a,d,s,o,n]),{lastRefreshed:a,setLastRefreshed:r,onRefreshClick:d}})({currentOrg:T,setTeams:j});(0,l.useEffect)(()=>{e&&Z(e.reduce((e,s)=>(e[s.team_id]={keys:s.keys||[],team_info:{members_with_roles:s.members_with_roles||[]}},e),{}))},[e]);let ei=async e=>{X(e),q(!0)},eo=async()=>{if(null!=Y&&null!=e&&null!=_){try{await (0,a.teamDeleteCall)(_,Y),(0,t.fetchTeams)(_,f,b,T,j)}catch(e){console.error("Error deleting the team:",e)}q(!1),X(null)}};return(0,s.jsx)("div",{className:"w-full mx-4 h-[75vh]",children:(0,s.jsx)(u.Grid,{numItems:1,className:"gap-2 p-8 w-full mt-2",children:(0,s.jsxs)(m.Col,{numColSpan:1,className:"flex flex-col gap-2",children:[("Admin"==b||"Org Admin"==b)&&(0,s.jsx)(c.Button,{className:"w-fit",onClick:()=>E(!0),children:"+ Create New Team"}),O?(0,s.jsx)(i.default,{teamId:O,onUpdate:e=>{j(s=>{if(null==s)return s;let l=s.map(s=>e.team_id===s.team_id?(0,g.updateExistingKeys)(s,e):s);return _&&(0,t.fetchTeams)(_,f,b,T,j),l})},onClose:()=>{P(null),D(!1)},accessToken:_,is_team_admin:(e=>{if(null==e||null==e.members_with_roles)return!1;for(let s=0;se.team_id===O)),is_proxy_admin:"Admin"==b,userModels:U,editTeam:L,premiumUser:v}):(0,s.jsxs)(w,{lastRefreshed:et,onRefresh:er,userRole:b,children:[(0,s.jsxs)(x.TabPanel,{children:[(0,s.jsxs)(h.Text,{children:["Click on “Team ID” to view team details ",(0,s.jsx)("b",{children:"and"})," manage team members."]}),(0,s.jsx)(u.Grid,{numItems:1,className:"gap-2 pt-2 pb-2 h-[75vh] w-full mt-2",children:(0,s.jsx)(m.Col,{numColSpan:1,children:(0,s.jsxs)(d.Card,{className:"w-full mx-auto flex-auto overflow-hidden overflow-y-auto max-h-[50vh]",children:[(0,s.jsx)("div",{className:"border-b px-6 py-4",children:(0,s.jsx)("div",{className:"flex flex-col space-y-4",children:(0,s.jsx)(N,{filters:F,organizations:y,showFilters:k,onToggleFilters:I,onChange:(e,s)=>{let l={...F,[e]:s};A(l),_&&(0,a.v2TeamListCall)(_,l.organization_id||null,null,l.team_id||null,l.team_alias||null).then(e=>{e&&e.teams&&j(e.teams)}).catch(e=>{console.error("Error fetching teams:",e)})},onReset:()=>{A({team_id:"",team_alias:"",organization_id:"",sort_by:"created_at",sort_order:"desc"}),_&&(0,a.v2TeamListCall)(_,null,f||null,null,null).then(e=>{e&&e.teams&&j(e.teams)}).catch(e=>{console.error("Error fetching teams:",e)})}})})}),(0,s.jsx)($,{teams:e,currentOrg:T,perTeamInfo:Q,userRole:b,userId:f,setSelectedTeamId:P,setEditTeam:D,onDeleteTeam:ei}),J&&(0,s.jsx)(K,{teams:e,teamToDelete:Y,onCancel:()=>{q(!1),X(null)},onConfirm:eo})]})})})]}),(0,s.jsx)(x.TabPanel,{children:(0,s.jsx)(p.default,{accessToken:_,userID:f})}),(0,n.isAdminRole)(b||"")&&(0,s.jsx)(x.TabPanel,{children:(0,s.jsx)(o.default,{accessToken:_,userID:f||"",userRole:b||""})})]}),("Admin"==b||"Org Admin"==b)&&(0,s.jsx)(eu,{isTeamModalVisible:B,handleOk:()=>{E(!1),z.resetFields(),es([]),ea({})},handleCancel:()=>{E(!1),z.resetFields(),es([]),ea({})},currentOrg:T,organizations:y,teams:e,setTeams:j,modelAliases:el,setModelAliases:ea,loggingSettings:ee,setLoggingSettings:es,setIsTeamModalVisible:E})]})})})};var ep=e.i(214541),eg=e.i(846835);e.s(["default",0,()=>{let{accessToken:e,userId:a,userRole:t}=(0,S.default)(),{teams:r,setTeams:i}=(0,ep.default)(),[o,n]=(0,l.useState)([]);return(0,l.useEffect)(()=>{(0,eg.fetchOrganizations)(e,n).then(()=>{})},[e]),(0,s.jsx)(ex,{teams:r,accessToken:e,setTeams:i,userID:a,userRole:t,organizations:o})}],596115)}]); \ No newline at end of file diff --git a/litellm/proxy/_experimental/out/_next/static/chunks/02ae0dc9a2dbf6b9.js b/litellm/proxy/_experimental/out/_next/static/chunks/02ae0dc9a2dbf6b9.js new file mode 100644 index 00000000000..fc8dffd1511 --- /dev/null +++ b/litellm/proxy/_experimental/out/_next/static/chunks/02ae0dc9a2dbf6b9.js @@ -0,0 +1,8 @@ +(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,94629,e=>{"use strict";var t=e.i(271645);let r=t.forwardRef(function(e,r){return t.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:2,stroke:"currentColor","aria-hidden":"true",ref:r},e),t.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M7 16V4m0 0L3 8m4-4l4 4m6 0v12m0 0l4-4m-4 4l-4-4"}))});e.s(["SwitchVerticalIcon",0,r],94629)},591935,e=>{"use strict";var t=e.i(271645);let r=t.forwardRef(function(e,r){return t.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:2,stroke:"currentColor","aria-hidden":"true",ref:r},e),t.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z"}))});e.s(["PencilAltIcon",0,r],591935)},728889,e=>{"use strict";var t=e.i(290571),r=e.i(271645),a=e.i(829087),l=e.i(480731),s=e.i(444755),o=e.i(673706),i=e.i(95779);let n={xs:{paddingX:"px-1.5",paddingY:"py-1.5"},sm:{paddingX:"px-1.5",paddingY:"py-1.5"},md:{paddingX:"px-2",paddingY:"py-2"},lg:{paddingX:"px-2",paddingY:"py-2"},xl:{paddingX:"px-2.5",paddingY:"py-2.5"}},d={xs:{height:"h-3",width:"w-3"},sm:{height:"h-5",width:"w-5"},md:{height:"h-5",width:"w-5"},lg:{height:"h-7",width:"w-7"},xl:{height:"h-9",width:"w-9"}},c={simple:{rounded:"",border:"",ring:"",shadow:""},light:{rounded:"rounded-tremor-default",border:"",ring:"",shadow:""},shadow:{rounded:"rounded-tremor-default",border:"border",ring:"",shadow:"shadow-tremor-card dark:shadow-dark-tremor-card"},solid:{rounded:"rounded-tremor-default",border:"border-2",ring:"ring-1",shadow:""},outlined:{rounded:"rounded-tremor-default",border:"border",ring:"ring-2",shadow:""}},m=(0,o.makeClassName)("Icon"),g=r.default.forwardRef((e,g)=>{let{icon:u,variant:h="simple",tooltip:x,size:b=l.Sizes.SM,color:p,className:f}=e,j=(0,t.__rest)(e,["icon","variant","tooltip","size","color","className"]),C=((e,t)=>{switch(e){case"simple":return{textColor:t?(0,o.getColorClassNames)(t,i.colorPalette.text).textColor:"text-tremor-brand dark:text-dark-tremor-brand",bgColor:"",borderColor:"",ringColor:""};case"light":return{textColor:t?(0,o.getColorClassNames)(t,i.colorPalette.text).textColor:"text-tremor-brand dark:text-dark-tremor-brand",bgColor:t?(0,s.tremorTwMerge)((0,o.getColorClassNames)(t,i.colorPalette.background).bgColor,"bg-opacity-20"):"bg-tremor-brand-muted dark:bg-dark-tremor-brand-muted",borderColor:"",ringColor:""};case"shadow":return{textColor:t?(0,o.getColorClassNames)(t,i.colorPalette.text).textColor:"text-tremor-brand dark:text-dark-tremor-brand",bgColor:t?(0,s.tremorTwMerge)((0,o.getColorClassNames)(t,i.colorPalette.background).bgColor,"bg-opacity-20"):"bg-tremor-background dark:bg-dark-tremor-background",borderColor:"border-tremor-border dark:border-dark-tremor-border",ringColor:""};case"solid":return{textColor:t?(0,o.getColorClassNames)(t,i.colorPalette.text).textColor:"text-tremor-brand-inverted dark:text-dark-tremor-brand-inverted",bgColor:t?(0,s.tremorTwMerge)((0,o.getColorClassNames)(t,i.colorPalette.background).bgColor,"bg-opacity-20"):"bg-tremor-brand dark:bg-dark-tremor-brand",borderColor:"border-tremor-brand-inverted dark:border-dark-tremor-brand-inverted",ringColor:"ring-tremor-ring dark:ring-dark-tremor-ring"};case"outlined":return{textColor:t?(0,o.getColorClassNames)(t,i.colorPalette.text).textColor:"text-tremor-brand dark:text-dark-tremor-brand",bgColor:t?(0,s.tremorTwMerge)((0,o.getColorClassNames)(t,i.colorPalette.background).bgColor,"bg-opacity-20"):"bg-tremor-background dark:bg-dark-tremor-background",borderColor:t?(0,o.getColorClassNames)(t,i.colorPalette.ring).borderColor:"border-tremor-brand-subtle dark:border-dark-tremor-brand-subtle",ringColor:t?(0,s.tremorTwMerge)((0,o.getColorClassNames)(t,i.colorPalette.ring).ringColor,"ring-opacity-40"):"ring-tremor-brand-muted dark:ring-dark-tremor-brand-muted"}}})(h,p),{tooltipProps:w,getReferenceProps:v}=(0,a.useTooltip)();return r.default.createElement("span",Object.assign({ref:(0,o.mergeRefs)([g,w.refs.setReference]),className:(0,s.tremorTwMerge)(m("root"),"inline-flex shrink-0 items-center justify-center",C.bgColor,C.textColor,C.borderColor,C.ringColor,c[h].rounded,c[h].border,c[h].shadow,c[h].ring,n[b].paddingX,n[b].paddingY,f)},v,j),r.default.createElement(a.default,Object.assign({text:x},w)),r.default.createElement(u,{className:(0,s.tremorTwMerge)(m("icon"),"shrink-0",d[b].height,d[b].width)}))});g.displayName="Icon",e.s(["default",()=>g],728889)},752978,e=>{"use strict";var t=e.i(728889);e.s(["Icon",()=>t.default])},599724,936325,e=>{"use strict";var t=e.i(95779),r=e.i(444755),a=e.i(673706),l=e.i(271645);let s=l.default.forwardRef((e,s)=>{let{color:o,className:i,children:n}=e;return l.default.createElement("p",{ref:s,className:(0,r.tremorTwMerge)("text-tremor-default",o?(0,a.getColorClassNames)(o,t.colorPalette.text).textColor:(0,r.tremorTwMerge)("text-tremor-content","dark:text-dark-tremor-content"),i)},n)});s.displayName="Text",e.s(["default",()=>s],936325),e.s(["Text",()=>s],599724)},994388,e=>{"use strict";var t=e.i(290571),r=e.i(829087),a=e.i(271645);let l=["preEnter","entering","entered","preExit","exiting","exited","unmounted"],s=e=>({_s:e,status:l[e],isEnter:e<3,isMounted:6!==e,isResolved:2===e||e>4}),o=e=>e?6:5,i=(e,t,r,a,l)=>{clearTimeout(a.current);let o=s(e);t(o),r.current=o,l&&l({current:o})};var n=e.i(480731),d=e.i(444755),c=e.i(673706);let m=e=>{var r=(0,t.__rest)(e,[]);return a.default.createElement("svg",Object.assign({},r,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor"}),a.default.createElement("path",{fill:"none",d:"M0 0h24v24H0z"}),a.default.createElement("path",{d:"M18.364 5.636L16.95 7.05A7 7 0 1 0 19 12h2a9 9 0 1 1-2.636-6.364z"}))};var g=e.i(95779);let u={xs:{height:"h-4",width:"w-4"},sm:{height:"h-5",width:"w-5"},md:{height:"h-5",width:"w-5"},lg:{height:"h-6",width:"w-6"},xl:{height:"h-6",width:"w-6"}},h=(e,t)=>{switch(e){case"primary":return{textColor:t?(0,c.getColorClassNames)("white").textColor:"text-tremor-brand-inverted dark:text-dark-tremor-brand-inverted",hoverTextColor:t?(0,c.getColorClassNames)("white").textColor:"text-tremor-brand-inverted dark:text-dark-tremor-brand-inverted",bgColor:t?(0,c.getColorClassNames)(t,g.colorPalette.background).bgColor:"bg-tremor-brand dark:bg-dark-tremor-brand",hoverBgColor:t?(0,c.getColorClassNames)(t,g.colorPalette.darkBackground).hoverBgColor:"hover:bg-tremor-brand-emphasis dark:hover:bg-dark-tremor-brand-emphasis",borderColor:t?(0,c.getColorClassNames)(t,g.colorPalette.border).borderColor:"border-tremor-brand dark:border-dark-tremor-brand",hoverBorderColor:t?(0,c.getColorClassNames)(t,g.colorPalette.darkBorder).hoverBorderColor:"hover:border-tremor-brand-emphasis dark:hover:border-dark-tremor-brand-emphasis"};case"secondary":return{textColor:t?(0,c.getColorClassNames)(t,g.colorPalette.text).textColor:"text-tremor-brand dark:text-dark-tremor-brand",hoverTextColor:t?(0,c.getColorClassNames)(t,g.colorPalette.text).textColor:"hover:text-tremor-brand-emphasis dark:hover:text-dark-tremor-brand-emphasis",bgColor:(0,c.getColorClassNames)("transparent").bgColor,hoverBgColor:t?(0,d.tremorTwMerge)((0,c.getColorClassNames)(t,g.colorPalette.background).hoverBgColor,"hover:bg-opacity-20 dark:hover:bg-opacity-20"):"hover:bg-tremor-brand-faint dark:hover:bg-dark-tremor-brand-faint",borderColor:t?(0,c.getColorClassNames)(t,g.colorPalette.border).borderColor:"border-tremor-brand dark:border-dark-tremor-brand"};case"light":return{textColor:t?(0,c.getColorClassNames)(t,g.colorPalette.text).textColor:"text-tremor-brand dark:text-dark-tremor-brand",hoverTextColor:t?(0,c.getColorClassNames)(t,g.colorPalette.darkText).hoverTextColor:"hover:text-tremor-brand-emphasis dark:hover:text-dark-tremor-brand-emphasis",bgColor:(0,c.getColorClassNames)("transparent").bgColor,borderColor:"",hoverBorderColor:""}}},x=(0,c.makeClassName)("Button"),b=({loading:e,iconSize:t,iconPosition:r,Icon:l,needMargin:s,transitionStatus:o})=>{let i=s?r===n.HorizontalPositions.Left?(0,d.tremorTwMerge)("-ml-1","mr-1.5"):(0,d.tremorTwMerge)("-mr-1","ml-1.5"):"",c=(0,d.tremorTwMerge)("w-0 h-0"),g={default:c,entering:c,entered:t,exiting:t,exited:c};return e?a.default.createElement(m,{className:(0,d.tremorTwMerge)(x("icon"),"animate-spin shrink-0",i,g.default,g[o]),style:{transition:"width 150ms"}}):a.default.createElement(l,{className:(0,d.tremorTwMerge)(x("icon"),"shrink-0",t,i)})},p=a.default.forwardRef((e,l)=>{let{icon:m,iconPosition:g=n.HorizontalPositions.Left,size:p=n.Sizes.SM,color:f,variant:j="primary",disabled:C,loading:w=!1,loadingText:v,children:k,tooltip:N,className:y}=e,T=(0,t.__rest)(e,["icon","iconPosition","size","color","variant","disabled","loading","loadingText","children","tooltip","className"]),_=w||C,$=void 0!==m||w,E=w&&v,M=!(!k&&!E),S=(0,d.tremorTwMerge)(u[p].height,u[p].width),O="light"!==j?(0,d.tremorTwMerge)("rounded-tremor-default border","shadow-tremor-input","dark:shadow-dark-tremor-input"):"",B=h(j,f),R=("light"!==j?{xs:{paddingX:"px-2.5",paddingY:"py-1.5",fontSize:"text-xs"},sm:{paddingX:"px-4",paddingY:"py-2",fontSize:"text-sm"},md:{paddingX:"px-4",paddingY:"py-2",fontSize:"text-md"},lg:{paddingX:"px-4",paddingY:"py-2.5",fontSize:"text-lg"},xl:{paddingX:"px-4",paddingY:"py-3",fontSize:"text-xl"}}:{xs:{paddingX:"",paddingY:"",fontSize:"text-xs"},sm:{paddingX:"",paddingY:"",fontSize:"text-sm"},md:{paddingX:"",paddingY:"",fontSize:"text-md"},lg:{paddingX:"",paddingY:"",fontSize:"text-lg"},xl:{paddingX:"",paddingY:"",fontSize:"text-xl"}})[p],{tooltipProps:I,getReferenceProps:P}=(0,r.useTooltip)(300),[z,L]=(({enter:e=!0,exit:t=!0,preEnter:r,preExit:l,timeout:n,initialEntered:d,mountOnEnter:c,unmountOnExit:m,onStateChange:g}={})=>{let[u,h]=(0,a.useState)(()=>s(d?2:o(c))),x=(0,a.useRef)(u),b=(0,a.useRef)(0),[p,f]="object"==typeof n?[n.enter,n.exit]:[n,n],j=(0,a.useCallback)(()=>{let e=((e,t)=>{switch(e){case 1:case 0:return 2;case 4:case 3:return o(t)}})(x.current._s,m);e&&i(e,h,x,b,g)},[g,m]);return[u,(0,a.useCallback)(a=>{let s=e=>{switch(i(e,h,x,b,g),e){case 1:p>=0&&(b.current=((...e)=>setTimeout(...e))(j,p));break;case 4:f>=0&&(b.current=((...e)=>setTimeout(...e))(j,f));break;case 0:case 3:b.current=((...e)=>setTimeout(...e))(()=>{isNaN(document.body.offsetTop)||s(e+1)},0)}},n=x.current.isEnter;"boolean"!=typeof a&&(a=!n),a?n||s(e?+!r:2):n&&s(t?l?3:4:o(m))},[j,g,e,t,r,l,p,f,m]),j]})({timeout:50});return(0,a.useEffect)(()=>{L(w)},[w]),a.default.createElement("button",Object.assign({ref:(0,c.mergeRefs)([l,I.refs.setReference]),className:(0,d.tremorTwMerge)(x("root"),"shrink-0 inline-flex justify-center items-center group font-medium outline-none",O,R.paddingX,R.paddingY,R.fontSize,B.textColor,B.bgColor,B.borderColor,B.hoverBorderColor,_?"opacity-50 cursor-not-allowed":(0,d.tremorTwMerge)(h(j,f).hoverTextColor,h(j,f).hoverBgColor,h(j,f).hoverBorderColor),y),disabled:_},P,T),a.default.createElement(r.default,Object.assign({text:N},I)),$&&g!==n.HorizontalPositions.Right?a.default.createElement(b,{loading:w,iconSize:S,iconPosition:g,Icon:m,transitionStatus:z.status,needMargin:M}):null,E||k?a.default.createElement("span",{className:(0,d.tremorTwMerge)(x("text"),"text-tremor-default whitespace-nowrap")},E?v:k):null,$&&g===n.HorizontalPositions.Right?a.default.createElement(b,{loading:w,iconSize:S,iconPosition:g,Icon:m,transitionStatus:z.status,needMargin:M}):null)});p.displayName="Button",e.s(["Button",()=>p],994388)},304967,e=>{"use strict";var t=e.i(290571),r=e.i(271645),a=e.i(480731),l=e.i(95779),s=e.i(444755),o=e.i(673706);let i=(0,o.makeClassName)("Card"),n=r.default.forwardRef((e,n)=>{let{decoration:d="",decorationColor:c,children:m,className:g}=e,u=(0,t.__rest)(e,["decoration","decorationColor","children","className"]);return r.default.createElement("div",Object.assign({ref:n,className:(0,s.tremorTwMerge)(i("root"),"relative w-full text-left ring-1 rounded-tremor-default p-6","bg-tremor-background ring-tremor-ring shadow-tremor-card","dark:bg-dark-tremor-background dark:ring-dark-tremor-ring dark:shadow-dark-tremor-card",c?(0,o.getColorClassNames)(c,l.colorPalette.border).borderColor:"border-tremor-brand dark:border-dark-tremor-brand",(e=>{if(!e)return"";switch(e){case a.HorizontalPositions.Left:return"border-l-4";case a.VerticalPositions.Top:return"border-t-4";case a.HorizontalPositions.Right:return"border-r-4";case a.VerticalPositions.Bottom:return"border-b-4";default:return""}})(d),g)},u),m)});n.displayName="Card",e.s(["Card",()=>n],304967)},185793,e=>{"use strict";e.i(247167);var t=e.i(271645),r=e.i(343794),a=e.i(242064),l=e.i(529681);let s=e=>{let{prefixCls:a,className:l,style:s,size:o,shape:i}=e,n=(0,r.default)({[`${a}-lg`]:"large"===o,[`${a}-sm`]:"small"===o}),d=(0,r.default)({[`${a}-circle`]:"circle"===i,[`${a}-square`]:"square"===i,[`${a}-round`]:"round"===i}),c=t.useMemo(()=>"number"==typeof o?{width:o,height:o,lineHeight:`${o}px`}:{},[o]);return t.createElement("span",{className:(0,r.default)(a,n,d,l),style:Object.assign(Object.assign({},c),s)})};e.i(296059);var o=e.i(694758),i=e.i(915654),n=e.i(246422),d=e.i(838378);let c=new o.Keyframes("ant-skeleton-loading",{"0%":{backgroundPosition:"100% 50%"},"100%":{backgroundPosition:"0 50%"}}),m=e=>({height:e,lineHeight:(0,i.unit)(e)}),g=e=>Object.assign({width:e},m(e)),u=(e,t)=>Object.assign({width:t(e).mul(5).equal(),minWidth:t(e).mul(5).equal()},m(e)),h=e=>Object.assign({width:e},m(e)),x=(e,t,r)=>{let{skeletonButtonCls:a}=e;return{[`${r}${a}-circle`]:{width:t,minWidth:t,borderRadius:"50%"},[`${r}${a}-round`]:{borderRadius:t}}},b=(e,t)=>Object.assign({width:t(e).mul(2).equal(),minWidth:t(e).mul(2).equal()},m(e)),p=(0,n.genStyleHooks)("Skeleton",e=>{let{componentCls:t,calc:r}=e;return(e=>{let{componentCls:t,skeletonAvatarCls:r,skeletonTitleCls:a,skeletonParagraphCls:l,skeletonButtonCls:s,skeletonInputCls:o,skeletonImageCls:i,controlHeight:n,controlHeightLG:d,controlHeightSM:m,gradientFromColor:p,padding:f,marginSM:j,borderRadius:C,titleHeight:w,blockRadius:v,paragraphLiHeight:k,controlHeightXS:N,paragraphMarginTop:y}=e;return{[t]:{display:"table",width:"100%",[`${t}-header`]:{display:"table-cell",paddingInlineEnd:f,verticalAlign:"top",[r]:Object.assign({display:"inline-block",verticalAlign:"top",background:p},g(n)),[`${r}-circle`]:{borderRadius:"50%"},[`${r}-lg`]:Object.assign({},g(d)),[`${r}-sm`]:Object.assign({},g(m))},[`${t}-content`]:{display:"table-cell",width:"100%",verticalAlign:"top",[a]:{width:"100%",height:w,background:p,borderRadius:v,[`+ ${l}`]:{marginBlockStart:m}},[l]:{padding:0,"> li":{width:"100%",height:k,listStyle:"none",background:p,borderRadius:v,"+ li":{marginBlockStart:N}}},[`${l}> li:last-child:not(:first-child):not(:nth-child(2))`]:{width:"61%"}},[`&-round ${t}-content`]:{[`${a}, ${l} > li`]:{borderRadius:C}}},[`${t}-with-avatar ${t}-content`]:{[a]:{marginBlockStart:j,[`+ ${l}`]:{marginBlockStart:y}}},[`${t}${t}-element`]:Object.assign(Object.assign(Object.assign(Object.assign({display:"inline-block",width:"auto"},(e=>{let{borderRadiusSM:t,skeletonButtonCls:r,controlHeight:a,controlHeightLG:l,controlHeightSM:s,gradientFromColor:o,calc:i}=e;return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({[r]:Object.assign({display:"inline-block",verticalAlign:"top",background:o,borderRadius:t,width:i(a).mul(2).equal(),minWidth:i(a).mul(2).equal()},b(a,i))},x(e,a,r)),{[`${r}-lg`]:Object.assign({},b(l,i))}),x(e,l,`${r}-lg`)),{[`${r}-sm`]:Object.assign({},b(s,i))}),x(e,s,`${r}-sm`))})(e)),(e=>{let{skeletonAvatarCls:t,gradientFromColor:r,controlHeight:a,controlHeightLG:l,controlHeightSM:s}=e;return{[t]:Object.assign({display:"inline-block",verticalAlign:"top",background:r},g(a)),[`${t}${t}-circle`]:{borderRadius:"50%"},[`${t}${t}-lg`]:Object.assign({},g(l)),[`${t}${t}-sm`]:Object.assign({},g(s))}})(e)),(e=>{let{controlHeight:t,borderRadiusSM:r,skeletonInputCls:a,controlHeightLG:l,controlHeightSM:s,gradientFromColor:o,calc:i}=e;return{[a]:Object.assign({display:"inline-block",verticalAlign:"top",background:o,borderRadius:r},u(t,i)),[`${a}-lg`]:Object.assign({},u(l,i)),[`${a}-sm`]:Object.assign({},u(s,i))}})(e)),(e=>{let{skeletonImageCls:t,imageSizeBase:r,gradientFromColor:a,borderRadiusSM:l,calc:s}=e;return{[t]:Object.assign(Object.assign({display:"inline-flex",alignItems:"center",justifyContent:"center",verticalAlign:"middle",background:a,borderRadius:l},h(s(r).mul(2).equal())),{[`${t}-path`]:{fill:"#bfbfbf"},[`${t}-svg`]:Object.assign(Object.assign({},h(r)),{maxWidth:s(r).mul(4).equal(),maxHeight:s(r).mul(4).equal()}),[`${t}-svg${t}-svg-circle`]:{borderRadius:"50%"}}),[`${t}${t}-circle`]:{borderRadius:"50%"}}})(e)),[`${t}${t}-block`]:{width:"100%",[s]:{width:"100%"},[o]:{width:"100%"}},[`${t}${t}-active`]:{[` + ${a}, + ${l} > li, + ${r}, + ${s}, + ${o}, + ${i} + `]:Object.assign({},{background:e.skeletonLoadingBackground,backgroundSize:"400% 100%",animationName:c,animationDuration:e.skeletonLoadingMotionDuration,animationTimingFunction:"ease",animationIterationCount:"infinite"})}}})((0,d.mergeToken)(e,{skeletonAvatarCls:`${t}-avatar`,skeletonTitleCls:`${t}-title`,skeletonParagraphCls:`${t}-paragraph`,skeletonButtonCls:`${t}-button`,skeletonInputCls:`${t}-input`,skeletonImageCls:`${t}-image`,imageSizeBase:r(e.controlHeight).mul(1.5).equal(),borderRadius:100,skeletonLoadingBackground:`linear-gradient(90deg, ${e.gradientFromColor} 25%, ${e.gradientToColor} 37%, ${e.gradientFromColor} 63%)`,skeletonLoadingMotionDuration:"1.4s"}))},e=>{let{colorFillContent:t,colorFill:r}=e;return{color:t,colorGradientEnd:r,gradientFromColor:t,gradientToColor:r,titleHeight:e.controlHeight/2,blockRadius:e.borderRadiusSM,paragraphMarginTop:e.marginLG+e.marginXXS,paragraphLiHeight:e.controlHeight/2}},{deprecatedTokens:[["color","gradientFromColor"],["colorGradientEnd","gradientToColor"]]}),f=e=>{let{prefixCls:a,className:l,style:s,rows:o=0}=e,i=Array.from({length:o}).map((r,a)=>t.createElement("li",{key:a,style:{width:((e,t)=>{let{width:r,rows:a=2}=t;return Array.isArray(r)?r[e]:a-1===e?r:void 0})(a,e)}}));return t.createElement("ul",{className:(0,r.default)(a,l),style:s},i)},j=({prefixCls:e,className:a,width:l,style:s})=>t.createElement("h3",{className:(0,r.default)(e,a),style:Object.assign({width:l},s)});function C(e){return e&&"object"==typeof e?e:{}}let w=e=>{let{prefixCls:l,loading:o,className:i,rootClassName:n,style:d,children:c,avatar:m=!1,title:g=!0,paragraph:u=!0,active:h,round:x}=e,{getPrefixCls:b,direction:w,className:v,style:k}=(0,a.useComponentConfig)("skeleton"),N=b("skeleton",l),[y,T,_]=p(N);if(o||!("loading"in e)){let e,a,l=!!m,o=!!g,c=!!u;if(l){let r=Object.assign(Object.assign({prefixCls:`${N}-avatar`},o&&!c?{size:"large",shape:"square"}:{size:"large",shape:"circle"}),C(m));e=t.createElement("div",{className:`${N}-header`},t.createElement(s,Object.assign({},r)))}if(o||c){let e,r;if(o){let r=Object.assign(Object.assign({prefixCls:`${N}-title`},!l&&c?{width:"38%"}:l&&c?{width:"50%"}:{}),C(g));e=t.createElement(j,Object.assign({},r))}if(c){let e,a=Object.assign(Object.assign({prefixCls:`${N}-paragraph`},(e={},l&&o||(e.width="61%"),!l&&o?e.rows=3:e.rows=2,e)),C(u));r=t.createElement(f,Object.assign({},a))}a=t.createElement("div",{className:`${N}-content`},e,r)}let b=(0,r.default)(N,{[`${N}-with-avatar`]:l,[`${N}-active`]:h,[`${N}-rtl`]:"rtl"===w,[`${N}-round`]:x},v,i,n,T,_);return y(t.createElement("div",{className:b,style:Object.assign(Object.assign({},k),d)},e,a))}return null!=c?c:null};w.Button=e=>{let{prefixCls:o,className:i,rootClassName:n,active:d,block:c=!1,size:m="default"}=e,{getPrefixCls:g}=t.useContext(a.ConfigContext),u=g("skeleton",o),[h,x,b]=p(u),f=(0,l.default)(e,["prefixCls"]),j=(0,r.default)(u,`${u}-element`,{[`${u}-active`]:d,[`${u}-block`]:c},i,n,x,b);return h(t.createElement("div",{className:j},t.createElement(s,Object.assign({prefixCls:`${u}-button`,size:m},f))))},w.Avatar=e=>{let{prefixCls:o,className:i,rootClassName:n,active:d,shape:c="circle",size:m="default"}=e,{getPrefixCls:g}=t.useContext(a.ConfigContext),u=g("skeleton",o),[h,x,b]=p(u),f=(0,l.default)(e,["prefixCls","className"]),j=(0,r.default)(u,`${u}-element`,{[`${u}-active`]:d},i,n,x,b);return h(t.createElement("div",{className:j},t.createElement(s,Object.assign({prefixCls:`${u}-avatar`,shape:c,size:m},f))))},w.Input=e=>{let{prefixCls:o,className:i,rootClassName:n,active:d,block:c,size:m="default"}=e,{getPrefixCls:g}=t.useContext(a.ConfigContext),u=g("skeleton",o),[h,x,b]=p(u),f=(0,l.default)(e,["prefixCls"]),j=(0,r.default)(u,`${u}-element`,{[`${u}-active`]:d,[`${u}-block`]:c},i,n,x,b);return h(t.createElement("div",{className:j},t.createElement(s,Object.assign({prefixCls:`${u}-input`,size:m},f))))},w.Image=e=>{let{prefixCls:l,className:s,rootClassName:o,style:i,active:n}=e,{getPrefixCls:d}=t.useContext(a.ConfigContext),c=d("skeleton",l),[m,g,u]=p(c),h=(0,r.default)(c,`${c}-element`,{[`${c}-active`]:n},s,o,g,u);return m(t.createElement("div",{className:h},t.createElement("div",{className:(0,r.default)(`${c}-image`,s),style:i},t.createElement("svg",{viewBox:"0 0 1098 1024",xmlns:"http://www.w3.org/2000/svg",className:`${c}-image-svg`},t.createElement("title",null,"Image placeholder"),t.createElement("path",{d:"M365.714286 329.142857q0 45.714286-32.036571 77.677714t-77.677714 32.036571-77.677714-32.036571-32.036571-77.677714 32.036571-77.677714 77.677714-32.036571 77.677714 32.036571 32.036571 77.677714zM950.857143 548.571429l0 256-804.571429 0 0-109.714286 182.857143-182.857143 91.428571 91.428571 292.571429-292.571429zM1005.714286 146.285714l-914.285714 0q-7.460571 0-12.873143 5.412571t-5.412571 12.873143l0 694.857143q0 7.460571 5.412571 12.873143t12.873143 5.412571l914.285714 0q7.460571 0 12.873143-5.412571t5.412571-12.873143l0-694.857143q0-7.460571-5.412571-12.873143t-12.873143-5.412571zM1097.142857 164.571429l0 694.857143q0 37.741714-26.843429 64.585143t-64.585143 26.843429l-914.285714 0q-37.741714 0-64.585143-26.843429t-26.843429-64.585143l0-694.857143q0-37.741714 26.843429-64.585143t64.585143-26.843429l914.285714 0q37.741714 0 64.585143 26.843429t26.843429 64.585143z",className:`${c}-image-path`})))))},w.Node=e=>{let{prefixCls:l,className:s,rootClassName:o,style:i,active:n,children:d}=e,{getPrefixCls:c}=t.useContext(a.ConfigContext),m=c("skeleton",l),[g,u,h]=p(m),x=(0,r.default)(m,`${m}-element`,{[`${m}-active`]:n},u,s,o,h);return g(t.createElement("div",{className:x},t.createElement("div",{className:(0,r.default)(`${m}-image`,s),style:i},d)))},e.s(["default",0,w],185793)},959013,e=>{"use strict";e.i(247167);var t=e.i(931067),r=e.i(271645);let a={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M482 152h60q8 0 8 8v704q0 8-8 8h-60q-8 0-8-8V160q0-8 8-8z"}},{tag:"path",attrs:{d:"M192 474h672q8 0 8 8v60q0 8-8 8H160q-8 0-8-8v-60q0-8 8-8z"}}]},name:"plus",theme:"outlined"};var l=e.i(9583),s=r.forwardRef(function(e,s){return r.createElement(l.default,(0,t.default)({},e,{ref:s,icon:a}))});e.s(["default",0,s],959013)},269200,e=>{"use strict";var t=e.i(290571),r=e.i(271645),a=e.i(444755);let l=(0,e.i(673706).makeClassName)("Table"),s=r.default.forwardRef((e,s)=>{let{children:o,className:i}=e,n=(0,t.__rest)(e,["children","className"]);return r.default.createElement("div",{className:(0,a.tremorTwMerge)(l("root"),"overflow-auto",i)},r.default.createElement("table",Object.assign({ref:s,className:(0,a.tremorTwMerge)(l("table"),"w-full text-tremor-default","text-tremor-content","dark:text-dark-tremor-content")},n),o))});s.displayName="Table",e.s(["Table",()=>s],269200)},427612,e=>{"use strict";var t=e.i(290571),r=e.i(271645),a=e.i(444755);let l=(0,e.i(673706).makeClassName)("TableHead"),s=r.default.forwardRef((e,s)=>{let{children:o,className:i}=e,n=(0,t.__rest)(e,["children","className"]);return r.default.createElement(r.default.Fragment,null,r.default.createElement("thead",Object.assign({ref:s,className:(0,a.tremorTwMerge)(l("root"),"text-left","text-tremor-content","dark:text-dark-tremor-content",i)},n),o))});s.displayName="TableHead",e.s(["TableHead",()=>s],427612)},64848,e=>{"use strict";var t=e.i(290571),r=e.i(271645),a=e.i(444755);let l=(0,e.i(673706).makeClassName)("TableHeaderCell"),s=r.default.forwardRef((e,s)=>{let{children:o,className:i}=e,n=(0,t.__rest)(e,["children","className"]);return r.default.createElement(r.default.Fragment,null,r.default.createElement("th",Object.assign({ref:s,className:(0,a.tremorTwMerge)(l("root"),"whitespace-nowrap text-left font-semibold top-0 px-4 py-3.5","text-tremor-content-strong","dark:text-dark-tremor-content-strong",i)},n),o))});s.displayName="TableHeaderCell",e.s(["TableHeaderCell",()=>s],64848)},942232,e=>{"use strict";var t=e.i(290571),r=e.i(271645),a=e.i(444755);let l=(0,e.i(673706).makeClassName)("TableBody"),s=r.default.forwardRef((e,s)=>{let{children:o,className:i}=e,n=(0,t.__rest)(e,["children","className"]);return r.default.createElement(r.default.Fragment,null,r.default.createElement("tbody",Object.assign({ref:s,className:(0,a.tremorTwMerge)(l("root"),"align-top divide-y","divide-tremor-border","dark:divide-dark-tremor-border",i)},n),o))});s.displayName="TableBody",e.s(["TableBody",()=>s],942232)},496020,e=>{"use strict";var t=e.i(290571),r=e.i(271645),a=e.i(444755);let l=(0,e.i(673706).makeClassName)("TableRow"),s=r.default.forwardRef((e,s)=>{let{children:o,className:i}=e,n=(0,t.__rest)(e,["children","className"]);return r.default.createElement(r.default.Fragment,null,r.default.createElement("tr",Object.assign({ref:s,className:(0,a.tremorTwMerge)(l("row"),i)},n),o))});s.displayName="TableRow",e.s(["TableRow",()=>s],496020)},977572,e=>{"use strict";var t=e.i(290571),r=e.i(271645),a=e.i(444755);let l=(0,e.i(673706).makeClassName)("TableCell"),s=r.default.forwardRef((e,s)=>{let{children:o,className:i}=e,n=(0,t.__rest)(e,["children","className"]);return r.default.createElement(r.default.Fragment,null,r.default.createElement("td",Object.assign({ref:s,className:(0,a.tremorTwMerge)(l("root"),"align-middle whitespace-nowrap text-left p-4",i)},n),o))});s.displayName="TableCell",e.s(["TableCell",()=>s],977572)},68155,e=>{"use strict";var t=e.i(271645);let r=t.forwardRef(function(e,r){return t.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:2,stroke:"currentColor","aria-hidden":"true",ref:r},e),t.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16"}))});e.s(["TrashIcon",0,r],68155)},871943,e=>{"use strict";var t=e.i(271645);let r=t.forwardRef(function(e,r){return t.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:2,stroke:"currentColor","aria-hidden":"true",ref:r},e),t.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19 9l-7 7-7-7"}))});e.s(["ChevronDownIcon",0,r],871943)},360820,e=>{"use strict";var t=e.i(271645);let r=t.forwardRef(function(e,r){return t.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:2,stroke:"currentColor","aria-hidden":"true",ref:r},e),t.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 15l7-7 7 7"}))});e.s(["ChevronUpIcon",0,r],360820)},278587,e=>{"use strict";var t=e.i(271645);let r=t.forwardRef(function(e,r){return t.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:2,stroke:"currentColor","aria-hidden":"true",ref:r},e),t.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"}))});e.s(["RefreshIcon",0,r],278587)},345244,e=>{"use strict";var t=e.i(843476),r=e.i(271645),a=e.i(752978),l=e.i(994388),s=e.i(309426),o=e.i(599724),i=e.i(350967),n=e.i(278587),d=e.i(304967),c=e.i(629569),m=e.i(389083),g=e.i(677667),u=e.i(898667),h=e.i(130643),x=e.i(808613),b=e.i(311451),p=e.i(199133),f=e.i(592968),j=e.i(827252),C=e.i(702597),w=e.i(355619),v=e.i(764205),k=e.i(727749),N=e.i(435451),y=e.i(860585),T=e.i(500330),_=e.i(678784),$=e.i(118366),E=e.i(464571);let M=({tagId:e,onClose:a,accessToken:s,is_admin:i,editTag:n})=>{let[M]=x.Form.useForm(),[S,O]=(0,r.useState)(null),[B,R]=(0,r.useState)(n),[I,P]=(0,r.useState)([]),[z,L]=(0,r.useState)({}),A=async(e,t)=>{await (0,T.copyToClipboard)(e)&&(L(e=>({...e,[t]:!0})),setTimeout(()=>{L(e=>({...e,[t]:!1}))},2e3))},H=async()=>{if(s)try{let t=(await (0,v.tagInfoCall)(s,[e]))[e];t&&(O(t),n&&M.setFieldsValue({name:t.name,description:t.description,models:t.models,max_budget:t.litellm_budget_table?.max_budget,budget_duration:t.litellm_budget_table?.budget_duration}))}catch(e){console.error("Error fetching tag details:",e),k.default.fromBackend("Error fetching tag details: "+e)}};(0,r.useEffect)(()=>{H()},[e,s]),(0,r.useEffect)(()=>{s&&(0,C.fetchUserModels)("dummy-user","Admin",s,P)},[s]);let q=async e=>{if(s)try{await (0,v.tagUpdateCall)(s,{name:e.name,description:e.description,models:e.models,max_budget:e.max_budget,tpm_limit:e.tpm_limit,rpm_limit:e.rpm_limit,budget_duration:e.budget_duration}),k.default.success("Tag updated successfully"),R(!1),H()}catch(e){console.error("Error updating tag:",e),k.default.fromBackend("Error updating tag: "+e)}};return S?(0,t.jsxs)("div",{className:"p-4",children:[(0,t.jsxs)("div",{className:"flex justify-between items-center mb-6",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)(l.Button,{onClick:a,className:"mb-4",children:"← Back to Tags"}),(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)(o.Text,{className:"font-medium",children:"Tag Name:"}),(0,t.jsx)("span",{className:"font-mono px-2 py-1 bg-gray-100 rounded text-sm border border-gray-200",children:S.name}),(0,t.jsx)(E.Button,{type:"text",size:"small",icon:z["tag-name"]?(0,t.jsx)(_.CheckIcon,{size:12}):(0,t.jsx)($.CopyIcon,{size:12}),onClick:()=>A(S.name,"tag-name"),className:`transition-all duration-200 ${z["tag-name"]?"text-green-600 bg-green-50 border-green-200":"text-gray-500 hover:text-gray-700 hover:bg-gray-100"}`})]}),(0,t.jsx)(o.Text,{className:"text-gray-500",children:S.description||"No description"})]}),i&&!B&&(0,t.jsx)(l.Button,{onClick:()=>R(!0),children:"Edit Tag"})]}),B?(0,t.jsx)(d.Card,{children:(0,t.jsxs)(x.Form,{form:M,onFinish:q,layout:"vertical",initialValues:S,children:[(0,t.jsx)(x.Form.Item,{label:"Tag Name",name:"name",rules:[{required:!0,message:"Please input a tag name"}],children:(0,t.jsx)(b.Input,{className:"rounded-md border-gray-300"})}),(0,t.jsx)(x.Form.Item,{label:"Description",name:"description",children:(0,t.jsx)(b.Input.TextArea,{rows:4})}),(0,t.jsx)(x.Form.Item,{label:(0,t.jsxs)("span",{children:["Allowed Models",(0,t.jsx)(f.Tooltip,{title:"Select which models are allowed to process this type of data",children:(0,t.jsx)(j.InfoCircleOutlined,{style:{marginLeft:"4px"}})})]}),name:"models",children:(0,t.jsx)(p.Select,{mode:"multiple",placeholder:"Select Models",children:I.map(e=>(0,t.jsx)(p.Select.Option,{value:e,children:(0,w.getModelDisplayName)(e)},e))})}),(0,t.jsxs)(g.Accordion,{className:"mt-4 mb-4",children:[(0,t.jsx)(u.AccordionHeader,{children:(0,t.jsx)(c.Title,{className:"m-0",children:"Budget & Rate Limits"})}),(0,t.jsxs)(h.AccordionBody,{children:[(0,t.jsx)(x.Form.Item,{label:(0,t.jsxs)("span",{children:["Max Budget (USD)"," ",(0,t.jsx)(f.Tooltip,{title:"Maximum amount in USD this tag can spend",children:(0,t.jsx)(j.InfoCircleOutlined,{style:{marginLeft:"4px"}})})]}),name:"max_budget",children:(0,t.jsx)(N.default,{step:.01,precision:2,width:200})}),(0,t.jsx)(x.Form.Item,{label:(0,t.jsxs)("span",{children:["Reset Budget"," ",(0,t.jsx)(f.Tooltip,{title:"How often the budget should reset",children:(0,t.jsx)(j.InfoCircleOutlined,{style:{marginLeft:"4px"}})})]}),name:"budget_duration",children:(0,t.jsx)(y.default,{onChange:e=>M.setFieldValue("budget_duration",e)})}),(0,t.jsx)("div",{className:"mt-4 p-3 bg-gray-50 rounded-md border border-gray-200",children:(0,t.jsxs)("p",{className:"text-sm text-gray-600",children:["TPM/RPM limits for tags are not currently supported. If you need this feature, please"," ",(0,t.jsx)("a",{href:"https://github.com/BerriAI/litellm/issues/new",target:"_blank",rel:"noopener noreferrer",className:"text-blue-600 hover:text-blue-800 underline",children:"create a GitHub issue"}),"."]})})]})]}),(0,t.jsxs)("div",{className:"flex justify-end space-x-2",children:[(0,t.jsx)(l.Button,{onClick:()=>R(!1),children:"Cancel"}),(0,t.jsx)(l.Button,{type:"submit",children:"Save Changes"})]})]})}):(0,t.jsxs)("div",{className:"space-y-6",children:[(0,t.jsxs)(d.Card,{children:[(0,t.jsx)(c.Title,{children:"Tag Details"}),(0,t.jsxs)("div",{className:"space-y-4 mt-4",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)(o.Text,{className:"font-medium",children:"Name"}),(0,t.jsx)(o.Text,{children:S.name})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)(o.Text,{className:"font-medium",children:"Description"}),(0,t.jsx)(o.Text,{children:S.description||"-"})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)(o.Text,{className:"font-medium",children:"Allowed Models"}),(0,t.jsx)("div",{className:"flex flex-wrap gap-2 mt-2",children:S.models&&0!==S.models.length?S.models.map(e=>(0,t.jsx)(m.Badge,{color:"blue",children:(0,t.jsx)(f.Tooltip,{title:`ID: ${e}`,children:S.model_info?.[e]||e})},e)):(0,t.jsx)(m.Badge,{color:"red",children:"All Models"})})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)(o.Text,{className:"font-medium",children:"Created"}),(0,t.jsx)(o.Text,{children:S.created_at?new Date(S.created_at).toLocaleString():"-"})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)(o.Text,{className:"font-medium",children:"Last Updated"}),(0,t.jsx)(o.Text,{children:S.updated_at?new Date(S.updated_at).toLocaleString():"-"})]})]})]}),S.litellm_budget_table&&(0,t.jsxs)(d.Card,{children:[(0,t.jsx)(c.Title,{children:"Budget & Rate Limits"}),(0,t.jsxs)("div",{className:"space-y-4 mt-4",children:[void 0!==S.litellm_budget_table.max_budget&&null!==S.litellm_budget_table.max_budget&&(0,t.jsxs)("div",{children:[(0,t.jsx)(o.Text,{className:"font-medium",children:"Max Budget"}),(0,t.jsxs)(o.Text,{children:["$",S.litellm_budget_table.max_budget]})]}),S.litellm_budget_table.budget_duration&&(0,t.jsxs)("div",{children:[(0,t.jsx)(o.Text,{className:"font-medium",children:"Budget Duration"}),(0,t.jsx)(o.Text,{children:S.litellm_budget_table.budget_duration})]}),void 0!==S.litellm_budget_table.tpm_limit&&null!==S.litellm_budget_table.tpm_limit&&(0,t.jsxs)("div",{children:[(0,t.jsx)(o.Text,{className:"font-medium",children:"TPM Limit"}),(0,t.jsx)(o.Text,{children:S.litellm_budget_table.tpm_limit.toLocaleString()})]}),void 0!==S.litellm_budget_table.rpm_limit&&null!==S.litellm_budget_table.rpm_limit&&(0,t.jsxs)("div",{children:[(0,t.jsx)(o.Text,{className:"font-medium",children:"RPM Limit"}),(0,t.jsx)(o.Text,{children:S.litellm_budget_table.rpm_limit.toLocaleString()})]})]})]})]})]}):(0,t.jsx)("div",{children:"Loading..."})};var S=e.i(871943),O=e.i(360820),B=e.i(591935),R=e.i(94629),I=e.i(68155),P=e.i(152990),z=e.i(682830),L=e.i(269200),A=e.i(942232),H=e.i(977572),q=e.i(427612),D=e.i(64848),F=e.i(496020);let X="This is just a spend tag that was passed dynamically in a request. It does not control any LLM models.",Y=({data:e,onEdit:s,onDelete:i,onSelectTag:n})=>{let[d,c]=r.default.useState([{id:"created_at",desc:!0}]),g=[{header:"Tag Name",accessorKey:"name",cell:({row:e})=>{let r=e.original,a=r.description===X;return(0,t.jsx)("div",{className:"overflow-hidden",children:(0,t.jsx)(f.Tooltip,{title:a?"You cannot view the information of a dynamically generated spend tag":r.name,children:(0,t.jsx)(l.Button,{size:"xs",variant:"light",className:"font-mono text-blue-500 bg-blue-50 hover:bg-blue-100 text-xs font-normal px-2 py-0.5",onClick:()=>n(r.name),disabled:a,children:r.name})})})}},{header:"Description",accessorKey:"description",cell:({row:e})=>{let r=e.original;return(0,t.jsx)(f.Tooltip,{title:r.description,children:(0,t.jsx)("span",{className:"text-xs",children:r.description||"-"})})}},{header:"Allowed Models",accessorKey:"models",cell:({row:e})=>{let r=e.original;return(0,t.jsx)("div",{style:{display:"flex",flexDirection:"column"},children:r?.models?.length===0?(0,t.jsx)(m.Badge,{size:"xs",className:"mb-1",color:"red",children:"All Models"}):r?.models?.map(e=>(0,t.jsx)(m.Badge,{size:"xs",className:"mb-1",color:"blue",children:(0,t.jsx)(f.Tooltip,{title:`ID: ${e}`,children:(0,t.jsx)(o.Text,{children:r.model_info?.[e]||e})})},e))})}},{header:"Created",accessorKey:"created_at",sortingFn:"datetime",cell:({row:e})=>{let r=e.original;return(0,t.jsx)("span",{className:"text-xs",children:new Date(r.created_at).toLocaleDateString()})}},{id:"actions",header:"Actions",cell:({row:e})=>{let r=e.original,l=r.description===X;return(0,t.jsxs)("div",{className:"flex space-x-2",children:[l?(0,t.jsx)(f.Tooltip,{title:"Dynamically generated spend tags cannot be edited",children:(0,t.jsx)(a.Icon,{icon:B.PencilAltIcon,size:"sm",className:"opacity-50 cursor-not-allowed","aria-label":"Edit tag (disabled)"})}):(0,t.jsx)(f.Tooltip,{title:"Edit tag",children:(0,t.jsx)(a.Icon,{icon:B.PencilAltIcon,size:"sm",onClick:()=>s(r),className:"cursor-pointer hover:text-blue-500"})}),l?(0,t.jsx)(f.Tooltip,{title:"Dynamically generated spend tags cannot be deleted",children:(0,t.jsx)(a.Icon,{icon:I.TrashIcon,size:"sm",className:"opacity-50 cursor-not-allowed","aria-label":"Delete tag (disabled)"})}):(0,t.jsx)(f.Tooltip,{title:"Delete tag",children:(0,t.jsx)(a.Icon,{icon:I.TrashIcon,size:"sm",onClick:()=>i(r.name),className:"cursor-pointer hover:text-red-500"})})]})}}],u=(0,P.useReactTable)({data:e,columns:g,state:{sorting:d},onSortingChange:c,getCoreRowModel:(0,z.getCoreRowModel)(),getSortedRowModel:(0,z.getSortedRowModel)(),enableSorting:!0});return(0,t.jsx)("div",{className:"rounded-lg custom-border relative",children:(0,t.jsx)("div",{className:"overflow-x-auto",children:(0,t.jsxs)(L.Table,{className:"[&_td]:py-0.5 [&_th]:py-1",children:[(0,t.jsx)(q.TableHead,{children:u.getHeaderGroups().map(e=>(0,t.jsx)(F.TableRow,{children:e.headers.map(e=>(0,t.jsx)(D.TableHeaderCell,{className:`py-1 h-8 ${"actions"===e.id?"sticky right-0 bg-white shadow-[-4px_0_8px_-6px_rgba(0,0,0,0.1)]":""}`,onClick:e.column.getToggleSortingHandler(),children:(0,t.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,t.jsx)("div",{className:"flex items-center",children:e.isPlaceholder?null:(0,P.flexRender)(e.column.columnDef.header,e.getContext())}),"actions"!==e.id&&(0,t.jsx)("div",{className:"w-4",children:e.column.getIsSorted()?({asc:(0,t.jsx)(O.ChevronUpIcon,{className:"h-4 w-4 text-blue-500"}),desc:(0,t.jsx)(S.ChevronDownIcon,{className:"h-4 w-4 text-blue-500"})})[e.column.getIsSorted()]:(0,t.jsx)(R.SwitchVerticalIcon,{className:"h-4 w-4 text-gray-400"})})]})},e.id))},e.id))}),(0,t.jsx)(A.TableBody,{children:u.getRowModel().rows.length>0?u.getRowModel().rows.map(e=>(0,t.jsx)(F.TableRow,{className:"h-8",children:e.getVisibleCells().map(e=>(0,t.jsx)(H.TableCell,{className:`py-0.5 max-h-8 overflow-hidden text-ellipsis whitespace-nowrap ${"actions"===e.column.id?"sticky right-0 bg-white shadow-[-4px_0_8px_-6px_rgba(0,0,0,0.1)]":""}`,children:(0,P.flexRender)(e.column.columnDef.cell,e.getContext())},e.id))},e.id)):(0,t.jsx)(F.TableRow,{children:(0,t.jsx)(H.TableCell,{colSpan:g.length,className:"h-8 text-center",children:(0,t.jsx)("div",{className:"text-center text-gray-500",children:(0,t.jsx)("p",{children:"No tags found"})})})})})]})})})};var V=e.i(779241),W=e.i(212931);let U=({visible:e,onCancel:r,onSubmit:a,availableModels:s})=>{let[o]=x.Form.useForm();return(0,t.jsx)(W.Modal,{title:"Create New Tag",open:e,width:800,footer:null,onCancel:()=>{o.resetFields(),r()},children:(0,t.jsxs)(x.Form,{form:o,onFinish:e=>{a(e),o.resetFields()},labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,t.jsx)(x.Form.Item,{label:"Tag Name",name:"tag_name",rules:[{required:!0,message:"Please input a tag name"}],children:(0,t.jsx)(V.TextInput,{})}),(0,t.jsx)(x.Form.Item,{label:"Description",name:"description",children:(0,t.jsx)(b.Input.TextArea,{rows:4})}),(0,t.jsx)(x.Form.Item,{label:(0,t.jsxs)("span",{children:["Allowed Models",(0,t.jsx)(f.Tooltip,{title:"Select which models are allowed to process requests from this tag",children:(0,t.jsx)(j.InfoCircleOutlined,{style:{marginLeft:"4px"}})})]}),name:"allowed_llms",children:(0,t.jsx)(p.Select,{mode:"multiple",placeholder:"Select Models",children:s.map(e=>(0,t.jsx)(p.Select.Option,{value:e.model_info.id,children:(0,t.jsxs)("div",{children:[(0,t.jsx)("span",{children:e.model_name}),(0,t.jsxs)("span",{className:"text-gray-400 ml-2",children:["(",e.model_info.id,")"]})]})},e.model_info.id))})}),(0,t.jsxs)(g.Accordion,{className:"mt-4 mb-4",children:[(0,t.jsx)(u.AccordionHeader,{children:(0,t.jsx)(c.Title,{className:"m-0",children:"Budget & Rate Limits (Optional)"})}),(0,t.jsxs)(h.AccordionBody,{children:[(0,t.jsx)(x.Form.Item,{className:"mt-4",label:(0,t.jsxs)("span",{children:["Max Budget (USD)"," ",(0,t.jsx)(f.Tooltip,{title:"Maximum amount in USD this tag can spend. When reached, requests with this tag will be blocked",children:(0,t.jsx)(j.InfoCircleOutlined,{style:{marginLeft:"4px"}})})]}),name:"max_budget",children:(0,t.jsx)(N.default,{step:.01,precision:2,width:200})}),(0,t.jsx)(x.Form.Item,{className:"mt-4",label:(0,t.jsxs)("span",{children:["Reset Budget"," ",(0,t.jsx)(f.Tooltip,{title:"How often the budget should reset. For example, setting 'daily' will reset the budget every 24 hours",children:(0,t.jsx)(j.InfoCircleOutlined,{style:{marginLeft:"4px"}})})]}),name:"budget_duration",children:(0,t.jsx)(y.default,{onChange:e=>o.setFieldValue("budget_duration",e)})}),(0,t.jsx)("div",{className:"mt-4 p-3 bg-gray-50 rounded-md border border-gray-200",children:(0,t.jsxs)("p",{className:"text-sm text-gray-600",children:["TPM/RPM limits for tags are not currently supported. If you need this feature, please"," ",(0,t.jsx)("a",{href:"https://github.com/BerriAI/litellm/issues/new",target:"_blank",rel:"noopener noreferrer",className:"text-blue-600 hover:text-blue-800 underline",children:"create a GitHub issue"}),"."]})})]})]}),(0,t.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,t.jsx)(l.Button,{type:"submit",children:"Create Tag"})})]})})};e.s(["default",0,({accessToken:e,userID:d,userRole:c})=>{let[m,g]=(0,r.useState)([]),[u,h]=(0,r.useState)(!1),[x,b]=(0,r.useState)(null),[p,f]=(0,r.useState)(!1),[j,C]=(0,r.useState)(!1),[w,N]=(0,r.useState)(null),[y,T]=(0,r.useState)(""),[_,$]=(0,r.useState)([]),E=async()=>{if(e)try{let t=await (0,v.tagListCall)(e);console.log("List tags response:",t),g(Object.values(t))}catch(e){console.error("Error fetching tags:",e),k.default.fromBackend("Error fetching tags: "+e)}},S=async t=>{if(e)try{await (0,v.tagCreateCall)(e,{name:t.tag_name,description:t.description,models:t.allowed_llms,max_budget:t.max_budget,soft_budget:t.soft_budget,tpm_limit:t.tpm_limit,rpm_limit:t.rpm_limit,budget_duration:t.budget_duration}),k.default.success("Tag created successfully"),h(!1),E()}catch(e){console.error("Error creating tag:",e),k.default.fromBackend("Error creating tag: "+e)}},O=async e=>{N(e),C(!0)},B=async()=>{if(e&&w){try{await (0,v.tagDeleteCall)(e,w),k.default.success("Tag deleted successfully"),E()}catch(e){console.error("Error deleting tag:",e),k.default.fromBackend("Error deleting tag: "+e)}C(!1),N(null)}};return(0,r.useEffect)(()=>{d&&c&&e&&(async()=>{try{let t=await (0,v.modelInfoCall)(e,d,c);t&&t.data&&$(t.data)}catch(e){console.error("Error fetching models:",e),k.default.fromBackend("Error fetching models: "+e)}})()},[e,d,c]),(0,r.useEffect)(()=>{E()},[e]),(0,t.jsx)("div",{className:"w-full mx-4 h-[75vh]",children:x?(0,t.jsx)(M,{tagId:x,onClose:()=>{b(null),f(!1)},accessToken:e,is_admin:"Admin"===c,editTag:p}):(0,t.jsxs)("div",{className:"gap-2 p-8 h-[75vh] w-full mt-2",children:[(0,t.jsxs)("div",{className:"flex justify-between mt-2 w-full items-center mb-4",children:[(0,t.jsx)("h1",{children:"Tag Management"}),(0,t.jsxs)("div",{className:"flex items-center space-x-2",children:[y&&(0,t.jsxs)(o.Text,{children:["Last Refreshed: ",y]}),(0,t.jsx)(a.Icon,{icon:n.RefreshIcon,variant:"shadow",size:"xs",className:"self-center cursor-pointer",onClick:()=>{E(),T(new Date().toLocaleString())}})]})]}),(0,t.jsxs)(o.Text,{className:"mb-4",children:["Click on a tag name to view and edit its details.",(0,t.jsxs)("p",{children:["You can use tags to restrict the usage of certain LLMs based on tags passed in the request. Read more about tag routing"," ",(0,t.jsx)("a",{href:"https://docs.litellm.ai/docs/proxy/tag_routing",target:"_blank",rel:"noopener noreferrer",children:"here"}),"."]})]}),(0,t.jsx)(l.Button,{className:"mb-4",onClick:()=>h(!0),children:"+ Create New Tag"}),(0,t.jsx)(i.Grid,{numItems:1,className:"gap-2 pt-2 pb-2 h-[75vh] w-full mt-2",children:(0,t.jsx)(s.Col,{numColSpan:1,children:(0,t.jsx)(Y,{data:m,onEdit:e=>{b(e.name),f(!0)},onDelete:O,onSelectTag:b})})}),(0,t.jsx)(U,{visible:u,onCancel:()=>h(!1),onSubmit:S,availableModels:_}),j&&(0,t.jsx)("div",{className:"fixed z-10 inset-0 overflow-y-auto",children:(0,t.jsxs)("div",{className:"flex items-end justify-center min-h-screen pt-4 px-4 pb-20 text-center sm:block sm:p-0",children:[(0,t.jsx)("div",{className:"fixed inset-0 transition-opacity","aria-hidden":"true",children:(0,t.jsx)("div",{className:"absolute inset-0 bg-gray-500 opacity-75"})}),(0,t.jsxs)("div",{className:"inline-block align-bottom bg-white rounded-lg text-left overflow-hidden shadow-xl transform transition-all sm:my-8 sm:align-middle sm:max-w-lg sm:w-full",children:[(0,t.jsx)("div",{className:"bg-white px-4 pt-5 pb-4 sm:p-6 sm:pb-4",children:(0,t.jsx)("div",{className:"sm:flex sm:items-start",children:(0,t.jsxs)("div",{className:"mt-3 text-center sm:mt-0 sm:ml-4 sm:text-left",children:[(0,t.jsx)("h3",{className:"text-lg leading-6 font-medium text-gray-900",children:"Delete Tag"}),(0,t.jsx)("div",{className:"mt-2",children:(0,t.jsx)("p",{className:"text-sm text-gray-500",children:"Are you sure you want to delete this tag?"})})]})})}),(0,t.jsxs)("div",{className:"bg-gray-50 px-4 py-3 sm:px-6 sm:flex sm:flex-row-reverse",children:[(0,t.jsx)(l.Button,{onClick:B,color:"red",className:"ml-2",children:"Delete"}),(0,t.jsx)(l.Button,{onClick:()=>{C(!1),N(null)},children:"Cancel"})]})]})]})})]})})}],345244)},954210,e=>{"use strict";var t=e.i(843476),r=e.i(345244),a=e.i(135214);e.s(["default",0,()=>{let{accessToken:e,userId:l,userRole:s}=(0,a.default)();return(0,t.jsx)(r.default,{accessToken:e,userID:l,userRole:s})}])}]); \ No newline at end of file diff --git a/litellm/proxy/_experimental/out/_next/static/chunks/033a61668f263790.js b/litellm/proxy/_experimental/out/_next/static/chunks/033a61668f263790.js new file mode 100644 index 00000000000..0fbdb89dfca --- /dev/null +++ b/litellm/proxy/_experimental/out/_next/static/chunks/033a61668f263790.js @@ -0,0 +1,8 @@ +(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,618566,(e,t,r)=>{t.exports=e.r(976562)},947293,e=>{"use strict";class t extends Error{}function r(e,r){let i;if("string"!=typeof e)throw new t("Invalid token specified: must be a string");r||(r={});let s=+(!0!==r.header),n=e.split(".")[s];if("string"!=typeof n)throw new t(`Invalid token specified: missing part #${s+1}`);try{i=function(e){let t=e.replace(/-/g,"+").replace(/_/g,"/");switch(t.length%4){case 0:break;case 2:t+="==";break;case 3:t+="=";break;default:throw Error("base64 string is not of the correct length")}try{var r;return r=t,decodeURIComponent(atob(r).replace(/(.)/g,(e,t)=>{let r=t.charCodeAt(0).toString(16).toUpperCase();return r.length<2&&(r="0"+r),"%"+r}))}catch(e){return atob(t)}}(n)}catch(e){throw new t(`Invalid token specified: invalid base64 for part #${s+1} (${e.message})`)}try{return JSON.parse(i)}catch(e){throw new t(`Invalid token specified: invalid json for part #${s+1} (${e.message})`)}}t.prototype.name="InvalidTokenError",e.s(["jwtDecode",()=>r])},180166,e=>{"use strict";var t={setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e),setInterval:(e,t)=>setInterval(e,t),clearInterval:e=>clearInterval(e)},r=new class{#e=t;#t=!1;setTimeoutProvider(e){this.#e=e}setTimeout(e,t){return this.#e.setTimeout(e,t)}clearTimeout(e){this.#e.clearTimeout(e)}setInterval(e,t){return this.#e.setInterval(e,t)}clearInterval(e){this.#e.clearInterval(e)}};function i(e){setTimeout(e,0)}e.s(["systemSetTimeoutZero",()=>i,"timeoutManager",()=>r])},540143,e=>{"use strict";let t,r,i,s,n,a;var o=e.i(180166).systemSetTimeoutZero,l=(t=[],r=0,i=e=>{e()},s=e=>{e()},n=o,{batch:e=>{let a;r++;try{a=e()}finally{let e;--r||(e=t,t=[],e.length&&n(()=>{s(()=>{e.forEach(e=>{i(e)})})}))}return a},batchCalls:e=>(...t)=>{a(()=>{e(...t)})},schedule:a=e=>{r?t.push(e):n(()=>{i(e)})},setNotifyFunction:e=>{i=e},setBatchNotifyFunction:e=>{s=e},setScheduler:e=>{n=e}});e.s(["notifyManager",()=>l])},619273,e=>{"use strict";var t=e.i(180166),r="u"=0&&e!==1/0}function a(e,t){return Math.max(e+(t||0)-Date.now(),0)}function o(e,t){return"function"==typeof e?e(t):e}function l(e,t){return"function"==typeof e?e(t):e}function u(e,t){let{type:r="all",exact:i,fetchStatus:s,predicate:n,queryKey:a,stale:o}=e;if(a){if(i){if(t.queryHash!==h(a,t.options))return!1}else if(!p(t.queryKey,a))return!1}if("all"!==r){let e=t.isActive();if("active"===r&&!e||"inactive"===r&&e)return!1}return("boolean"!=typeof o||t.isStale()===o)&&(!s||s===t.state.fetchStatus)&&(!n||!!n(t))}function c(e,t){let{exact:r,status:i,predicate:s,mutationKey:n}=e;if(n){if(!t.options.mutationKey)return!1;if(r){if(d(t.options.mutationKey)!==d(n))return!1}else if(!p(t.options.mutationKey,n))return!1}return(!i||t.state.status===i)&&(!s||!!s(t))}function h(e,t){return(t?.queryKeyHashFn||d)(e)}function d(e){return JSON.stringify(e,(e,t)=>g(t)?Object.keys(t).sort().reduce((e,r)=>(e[r]=t[r],e),{}):t)}function p(e,t){return e===t||typeof e==typeof t&&!!e&&!!t&&"object"==typeof e&&"object"==typeof t&&Object.keys(t).every(r=>p(e[r],t[r]))}var f=Object.prototype.hasOwnProperty;function y(e,t){if(!t||Object.keys(e).length!==Object.keys(t).length)return!1;for(let r in e)if(e[r]!==t[r])return!1;return!0}function m(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function g(e){if(!b(e))return!1;let t=e.constructor;if(void 0===t)return!0;let r=t.prototype;return!!b(r)&&!!r.hasOwnProperty("isPrototypeOf")&&Object.getPrototypeOf(e)===Object.prototype}function b(e){return"[object Object]"===Object.prototype.toString.call(e)}function v(e){return new Promise(r=>{t.timeoutManager.setTimeout(r,e)})}function O(e,t,r){return"function"==typeof r.structuralSharing?r.structuralSharing(e,t):!1!==r.structuralSharing?function e(t,r,i=0){if(t===r)return t;if(i>500)return r;let s=m(t)&&m(r);if(!s&&!(g(t)&&g(r)))return r;let n=(s?t:Object.keys(t)).length,a=s?r:Object.keys(r),o=a.length,l=s?Array(o):{},u=0;for(let c=0;cr?i.slice(1):i}function S(e,t,r=0){let i=[t,...e];return r&&i.length>r?i.slice(0,-1):i}var w=Symbol();function E(e,t){return!e.queryFn&&t?.initialPromise?()=>t.initialPromise:e.queryFn&&e.queryFn!==w?e.queryFn:()=>Promise.reject(Error(`Missing queryFn: '${e.queryHash}'`))}function T(e,t){return"function"==typeof e?e(...t):!!e}function $(e,t,r){let i,s=!1;return Object.defineProperty(e,"signal",{enumerable:!0,get:()=>(i??=t(),s||(s=!0,i.aborted?r():i.addEventListener("abort",r,{once:!0})),i)}),e}e.s(["addConsumeAwareSignal",()=>$,"addToEnd",()=>R,"addToStart",()=>S,"ensureQueryFn",()=>E,"functionalUpdate",()=>s,"hashKey",()=>d,"hashQueryKeyByOptions",()=>h,"isServer",()=>r,"isValidTimeout",()=>n,"keepPreviousData",()=>C,"matchMutation",()=>c,"matchQuery",()=>u,"noop",()=>i,"partialMatchKey",()=>p,"replaceData",()=>O,"resolveEnabled",()=>l,"resolveStaleTime",()=>o,"shallowEqualObjects",()=>y,"shouldThrowError",()=>T,"skipToken",()=>w,"sleep",()=>v,"timeUntilStale",()=>a])},88587,e=>{"use strict";var t=e.i(180166),r=e.i(619273),i=class{#r;destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),(0,r.isValidTimeout)(this.gcTime)&&(this.#r=t.timeoutManager.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(r.isServer?1/0:3e5))}clearGcTimeout(){this.#r&&(t.timeoutManager.clearTimeout(this.#r),this.#r=void 0)}};e.s(["Removable",()=>i])},915823,e=>{"use strict";var t=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(e){return this.listeners.add(e),this.onSubscribe(),()=>{this.listeners.delete(e),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}};e.s(["Subscribable",()=>t])},175555,e=>{"use strict";var t=e.i(915823),r=e.i(619273),i=new class extends t.Subscribable{#i;#s;#n;constructor(){super(),this.#n=e=>{if(!r.isServer&&window.addEventListener){let t=()=>e();return window.addEventListener("visibilitychange",t,!1),()=>{window.removeEventListener("visibilitychange",t)}}}}onSubscribe(){this.#s||this.setEventListener(this.#n)}onUnsubscribe(){this.hasListeners()||(this.#s?.(),this.#s=void 0)}setEventListener(e){this.#n=e,this.#s?.(),this.#s=e(e=>{"boolean"==typeof e?this.setFocused(e):this.onFocus()})}setFocused(e){this.#i!==e&&(this.#i=e,this.onFocus())}onFocus(){let e=this.isFocused();this.listeners.forEach(t=>{t(e)})}isFocused(){return"boolean"==typeof this.#i?this.#i:globalThis.document?.visibilityState!=="hidden"}};e.s(["focusManager",()=>i])},936553,814448,793803,e=>{"use strict";var t=e.i(175555),r=e.i(915823),i=e.i(619273),s=new class extends r.Subscribable{#a=!0;#s;#n;constructor(){super(),this.#n=e=>{if(!i.isServer&&window.addEventListener){let t=()=>e(!0),r=()=>e(!1);return window.addEventListener("online",t,!1),window.addEventListener("offline",r,!1),()=>{window.removeEventListener("online",t),window.removeEventListener("offline",r)}}}}onSubscribe(){this.#s||this.setEventListener(this.#n)}onUnsubscribe(){this.hasListeners()||(this.#s?.(),this.#s=void 0)}setEventListener(e){this.#n=e,this.#s?.(),this.#s=e(this.setOnline.bind(this))}setOnline(e){this.#a!==e&&(this.#a=e,this.listeners.forEach(t=>{t(e)}))}isOnline(){return this.#a}};function n(){let e,t,r=new Promise((r,i)=>{e=r,t=i});function i(e){Object.assign(r,e),delete r.resolve,delete r.reject}return r.status="pending",r.catch(()=>{}),r.resolve=t=>{i({status:"fulfilled",value:t}),e(t)},r.reject=e=>{i({status:"rejected",reason:e}),t(e)},r}function a(e){return Math.min(1e3*2**e,3e4)}function o(e){return(e??"online")!=="online"||s.isOnline()}e.s(["onlineManager",()=>s],814448),e.s(["pendingThenable",()=>n],793803);var l=class extends Error{constructor(e){super("CancelledError"),this.revert=e?.revert,this.silent=e?.silent}};function u(e){let r,u=!1,c=0,h=n(),d=()=>t.focusManager.isFocused()&&("always"===e.networkMode||s.isOnline())&&e.canRun(),p=()=>o(e.networkMode)&&e.canRun(),f=e=>{"pending"===h.status&&(r?.(),h.resolve(e))},y=e=>{"pending"===h.status&&(r?.(),h.reject(e))},m=()=>new Promise(t=>{r=e=>{("pending"!==h.status||d())&&t(e)},e.onPause?.()}).then(()=>{r=void 0,"pending"===h.status&&e.onContinue?.()}),g=()=>{let t;if("pending"!==h.status)return;let r=0===c?e.initialPromise:void 0;try{t=r??e.fn()}catch(e){t=Promise.reject(e)}Promise.resolve(t).then(f).catch(t=>{if("pending"!==h.status)return;let r=e.retry??3*!i.isServer,s=e.retryDelay??a,n="function"==typeof s?s(c,t):s,o=!0===r||"number"==typeof r&&cd()?void 0:m()).then(()=>{u?y(t):g()}))})};return{promise:h,status:()=>h.status,cancel:t=>{if("pending"===h.status){let r=new l(t);y(r),e.onCancel?.(r)}},continue:()=>(r?.(),h),cancelRetry:()=>{u=!0},continueRetry:()=>{u=!1},canStart:p,start:()=>(p()?g():m().then(g),h)}}e.s(["CancelledError",()=>l,"canFetch",()=>o,"createRetryer",()=>u],936553)},912598,e=>{"use strict";var t=e.i(271645),r=e.i(843476),i=t.createContext(void 0),s=e=>{let r=t.useContext(i);if(e)return e;if(!r)throw Error("No QueryClient set, use QueryClientProvider to set one");return r},n=({client:e,children:s})=>(t.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),(0,r.jsx)(i.Provider,{value:e,children:s}));e.s(["QueryClientProvider",()=>n,"useQueryClient",()=>s])},286491,e=>{"use strict";var t=e.i(619273),r=e.i(540143),i=e.i(936553),s=e.i(88587),n=class extends s.Removable{#o;#l;#u;#c;#h;#d;#p;constructor(e){super(),this.#p=!1,this.#d=e.defaultOptions,this.setOptions(e.options),this.observers=[],this.#c=e.client,this.#u=this.#c.getQueryCache(),this.queryKey=e.queryKey,this.queryHash=e.queryHash,this.#o=l(this.options),this.state=e.state??this.#o,this.scheduleGc()}get meta(){return this.options.meta}get promise(){return this.#h?.promise}setOptions(e){if(this.options={...this.#d,...e},this.updateGcTime(this.options.gcTime),this.state&&void 0===this.state.data){let e=l(this.options);void 0!==e.data&&(this.setState(o(e.data,e.dataUpdatedAt)),this.#o=e)}}optionalRemove(){this.observers.length||"idle"!==this.state.fetchStatus||this.#u.remove(this)}setData(e,r){let i=(0,t.replaceData)(this.state.data,e,this.options);return this.#f({data:i,type:"success",dataUpdatedAt:r?.updatedAt,manual:r?.manual}),i}setState(e,t){this.#f({type:"setState",state:e,setStateOptions:t})}cancel(e){let r=this.#h?.promise;return this.#h?.cancel(e),r?r.then(t.noop).catch(t.noop):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}reset(){this.destroy(),this.setState(this.#o)}isActive(){return this.observers.some(e=>!1!==(0,t.resolveEnabled)(e.options.enabled,this))}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===t.skipToken||this.state.dataUpdateCount+this.state.errorUpdateCount===0}isStatic(){return this.getObserversCount()>0&&this.observers.some(e=>"static"===(0,t.resolveStaleTime)(e.options.staleTime,this))}isStale(){return this.getObserversCount()>0?this.observers.some(e=>e.getCurrentResult().isStale):void 0===this.state.data||this.state.isInvalidated}isStaleByTime(e=0){return void 0===this.state.data||"static"!==e&&(!!this.state.isInvalidated||!(0,t.timeUntilStale)(this.state.dataUpdatedAt,e))}onFocus(){let e=this.observers.find(e=>e.shouldFetchOnWindowFocus());e?.refetch({cancelRefetch:!1}),this.#h?.continue()}onOnline(){let e=this.observers.find(e=>e.shouldFetchOnReconnect());e?.refetch({cancelRefetch:!1}),this.#h?.continue()}addObserver(e){this.observers.includes(e)||(this.observers.push(e),this.clearGcTimeout(),this.#u.notify({type:"observerAdded",query:this,observer:e}))}removeObserver(e){this.observers.includes(e)&&(this.observers=this.observers.filter(t=>t!==e),this.observers.length||(this.#h&&(this.#p?this.#h.cancel({revert:!0}):this.#h.cancelRetry()),this.scheduleGc()),this.#u.notify({type:"observerRemoved",query:this,observer:e}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||this.#f({type:"invalidate"})}async fetch(e,r){let s;if("idle"!==this.state.fetchStatus&&this.#h?.status()!=="rejected"){if(void 0!==this.state.data&&r?.cancelRefetch)this.cancel({silent:!0});else if(this.#h)return this.#h.continueRetry(),this.#h.promise}if(e&&this.setOptions(e),!this.options.queryFn){let e=this.observers.find(e=>e.options.queryFn);e&&this.setOptions(e.options)}let n=new AbortController,a=e=>{Object.defineProperty(e,"signal",{enumerable:!0,get:()=>(this.#p=!0,n.signal)})},o=()=>{let e,i=(0,t.ensureQueryFn)(this.options,r),s=(a(e={client:this.#c,queryKey:this.queryKey,meta:this.meta}),e);return(this.#p=!1,this.options.persister)?this.options.persister(i,s,this):i(s)},l=(a(s={fetchOptions:r,options:this.options,queryKey:this.queryKey,client:this.#c,state:this.state,fetchFn:o}),s);this.options.behavior?.onFetch(l,this),this.#l=this.state,("idle"===this.state.fetchStatus||this.state.fetchMeta!==l.fetchOptions?.meta)&&this.#f({type:"fetch",meta:l.fetchOptions?.meta}),this.#h=(0,i.createRetryer)({initialPromise:r?.initialPromise,fn:l.fetchFn,onCancel:e=>{e instanceof i.CancelledError&&e.revert&&this.setState({...this.#l,fetchStatus:"idle"}),n.abort()},onFail:(e,t)=>{this.#f({type:"failed",failureCount:e,error:t})},onPause:()=>{this.#f({type:"pause"})},onContinue:()=>{this.#f({type:"continue"})},retry:l.options.retry,retryDelay:l.options.retryDelay,networkMode:l.options.networkMode,canRun:()=>!0});try{let e=await this.#h.start();if(void 0===e)throw Error(`${this.queryHash} data is undefined`);return this.setData(e),this.#u.config.onSuccess?.(e,this),this.#u.config.onSettled?.(e,this.state.error,this),e}catch(e){if(e instanceof i.CancelledError){if(e.silent)return this.#h.promise;else if(e.revert){if(void 0===this.state.data)throw e;return this.state.data}}throw this.#f({type:"error",error:e}),this.#u.config.onError?.(e,this),this.#u.config.onSettled?.(this.state.data,e,this),e}finally{this.scheduleGc()}}#f(e){let t=t=>{switch(e.type){case"failed":return{...t,fetchFailureCount:e.failureCount,fetchFailureReason:e.error};case"pause":return{...t,fetchStatus:"paused"};case"continue":return{...t,fetchStatus:"fetching"};case"fetch":return{...t,...a(t.data,this.options),fetchMeta:e.meta??null};case"success":let r={...t,...o(e.data,e.dataUpdatedAt),dataUpdateCount:t.dataUpdateCount+1,...!e.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};return this.#l=e.manual?r:void 0,r;case"error":let i=e.error;return{...t,error:i,errorUpdateCount:t.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:t.fetchFailureCount+1,fetchFailureReason:i,fetchStatus:"idle",status:"error",isInvalidated:!0};case"invalidate":return{...t,isInvalidated:!0};case"setState":return{...t,...e.state}}};this.state=t(this.state),r.notifyManager.batch(()=>{this.observers.forEach(e=>{e.onQueryUpdate()}),this.#u.notify({query:this,type:"updated",action:e})})}};function a(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:(0,i.canFetch)(t.networkMode)?"fetching":"paused",...void 0===e&&{error:null,status:"pending"}}}function o(e,t){return{data:e,dataUpdatedAt:t??Date.now(),error:null,isInvalidated:!1,status:"success"}}function l(e){let t="function"==typeof e.initialData?e.initialData():e.initialData,r=void 0!==t,i=r?"function"==typeof e.initialDataUpdatedAt?e.initialDataUpdatedAt():e.initialDataUpdatedAt:0;return{data:t,dataUpdateCount:0,dataUpdatedAt:r?i??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:r?"success":"pending",fetchStatus:"idle"}}e.s(["Query",()=>n,"fetchState",()=>a])},869230,e=>{"use strict";var t=e.i(175555),r=e.i(540143),i=e.i(286491),s=e.i(915823),n=e.i(793803),a=e.i(619273),o=e.i(180166),l=class extends s.Subscribable{constructor(e,t){super(),this.options=t,this.#c=e,this.#y=null,this.#m=(0,n.pendingThenable)(),this.bindMethods(),this.setOptions(t)}#c;#g=void 0;#b=void 0;#v=void 0;#O;#C;#m;#y;#R;#S;#w;#E;#T;#$;#k=new Set;bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){1===this.listeners.size&&(this.#g.addObserver(this),u(this.#g,this.options)?this.#j():this.updateResult(),this.#I())}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return c(this.#g,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return c(this.#g,this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,this.#Q(),this.#x(),this.#g.removeObserver(this)}setOptions(e){let t=this.options,r=this.#g;if(this.options=this.#c.defaultQueryOptions(e),void 0!==this.options.enabled&&"boolean"!=typeof this.options.enabled&&"function"!=typeof this.options.enabled&&"boolean"!=typeof(0,a.resolveEnabled)(this.options.enabled,this.#g))throw Error("Expected enabled to be a boolean or a callback that returns a boolean");this.#F(),this.#g.setOptions(this.options),t._defaulted&&!(0,a.shallowEqualObjects)(this.options,t)&&this.#c.getQueryCache().notify({type:"observerOptionsUpdated",query:this.#g,observer:this});let i=this.hasListeners();i&&h(this.#g,r,this.options,t)&&this.#j(),this.updateResult(),i&&(this.#g!==r||(0,a.resolveEnabled)(this.options.enabled,this.#g)!==(0,a.resolveEnabled)(t.enabled,this.#g)||(0,a.resolveStaleTime)(this.options.staleTime,this.#g)!==(0,a.resolveStaleTime)(t.staleTime,this.#g))&&this.#q();let s=this.#M();i&&(this.#g!==r||(0,a.resolveEnabled)(this.options.enabled,this.#g)!==(0,a.resolveEnabled)(t.enabled,this.#g)||s!==this.#$)&&this.#U(s)}getOptimisticResult(e){var t,r;let i=this.#c.getQueryCache().build(this.#c,e),s=this.createResult(i,e);return t=this,r=s,(0,a.shallowEqualObjects)(t.getCurrentResult(),r)||(this.#v=s,this.#C=this.options,this.#O=this.#g.state),s}getCurrentResult(){return this.#v}trackResult(e,t){return new Proxy(e,{get:(e,r)=>(this.trackProp(r),t?.(r),"promise"===r&&(this.trackProp("data"),this.options.experimental_prefetchInRender||"pending"!==this.#m.status||this.#m.reject(Error("experimental_prefetchInRender feature flag is not enabled"))),Reflect.get(e,r))})}trackProp(e){this.#k.add(e)}getCurrentQuery(){return this.#g}refetch({...e}={}){return this.fetch({...e})}fetchOptimistic(e){let t=this.#c.defaultQueryOptions(e),r=this.#c.getQueryCache().build(this.#c,t);return r.fetch().then(()=>this.createResult(r,t))}fetch(e){return this.#j({...e,cancelRefetch:e.cancelRefetch??!0}).then(()=>(this.updateResult(),this.#v))}#j(e){this.#F();let t=this.#g.fetch(this.options,e);return e?.throwOnError||(t=t.catch(a.noop)),t}#q(){this.#Q();let e=(0,a.resolveStaleTime)(this.options.staleTime,this.#g);if(a.isServer||this.#v.isStale||!(0,a.isValidTimeout)(e))return;let t=(0,a.timeUntilStale)(this.#v.dataUpdatedAt,e);this.#E=o.timeoutManager.setTimeout(()=>{this.#v.isStale||this.updateResult()},t+1)}#M(){return("function"==typeof this.options.refetchInterval?this.options.refetchInterval(this.#g):this.options.refetchInterval)??!1}#U(e){this.#x(),this.#$=e,!a.isServer&&!1!==(0,a.resolveEnabled)(this.options.enabled,this.#g)&&(0,a.isValidTimeout)(this.#$)&&0!==this.#$&&(this.#T=o.timeoutManager.setInterval(()=>{(this.options.refetchIntervalInBackground||t.focusManager.isFocused())&&this.#j()},this.#$))}#I(){this.#q(),this.#U(this.#M())}#Q(){this.#E&&(o.timeoutManager.clearTimeout(this.#E),this.#E=void 0)}#x(){this.#T&&(o.timeoutManager.clearInterval(this.#T),this.#T=void 0)}createResult(e,t){let r,s=this.#g,o=this.options,l=this.#v,c=this.#O,p=this.#C,f=e!==s?e.state:this.#b,{state:y}=e,m={...y},g=!1;if(t._optimisticResults){let r=this.hasListeners(),n=!r&&u(e,t),a=r&&h(e,s,t,o);(n||a)&&(m={...m,...(0,i.fetchState)(y.data,e.options)}),"isRestoring"===t._optimisticResults&&(m.fetchStatus="idle")}let{error:b,errorUpdatedAt:v,status:O}=m;r=m.data;let C=!1;if(void 0!==t.placeholderData&&void 0===r&&"pending"===O){let e;l?.isPlaceholderData&&t.placeholderData===p?.placeholderData?(e=l.data,C=!0):e="function"==typeof t.placeholderData?t.placeholderData(this.#w?.state.data,this.#w):t.placeholderData,void 0!==e&&(O="success",r=(0,a.replaceData)(l?.data,e,t),g=!0)}if(t.select&&void 0!==r&&!C)if(l&&r===c?.data&&t.select===this.#R)r=this.#S;else try{this.#R=t.select,r=t.select(r),r=(0,a.replaceData)(l?.data,r,t),this.#S=r,this.#y=null}catch(e){this.#y=e}this.#y&&(b=this.#y,r=this.#S,v=Date.now(),O="error");let R="fetching"===m.fetchStatus,S="pending"===O,w="error"===O,E=S&&R,T=void 0!==r,$={status:O,fetchStatus:m.fetchStatus,isPending:S,isSuccess:"success"===O,isError:w,isInitialLoading:E,isLoading:E,data:r,dataUpdatedAt:m.dataUpdatedAt,error:b,errorUpdatedAt:v,failureCount:m.fetchFailureCount,failureReason:m.fetchFailureReason,errorUpdateCount:m.errorUpdateCount,isFetched:m.dataUpdateCount>0||m.errorUpdateCount>0,isFetchedAfterMount:m.dataUpdateCount>f.dataUpdateCount||m.errorUpdateCount>f.errorUpdateCount,isFetching:R,isRefetching:R&&!S,isLoadingError:w&&!T,isPaused:"paused"===m.fetchStatus,isPlaceholderData:g,isRefetchError:w&&T,isStale:d(e,t),refetch:this.refetch,promise:this.#m,isEnabled:!1!==(0,a.resolveEnabled)(t.enabled,e)};if(this.options.experimental_prefetchInRender){let t=void 0!==$.data,r="error"===$.status&&!t,i=e=>{r?e.reject($.error):t&&e.resolve($.data)},a=()=>{i(this.#m=$.promise=(0,n.pendingThenable)())},o=this.#m;switch(o.status){case"pending":e.queryHash===s.queryHash&&i(o);break;case"fulfilled":(r||$.data!==o.value)&&a();break;case"rejected":r&&$.error===o.reason||a()}}return $}updateResult(){let e=this.#v,t=this.createResult(this.#g,this.options);if(this.#O=this.#g.state,this.#C=this.options,void 0!==this.#O.data&&(this.#w=this.#g),(0,a.shallowEqualObjects)(t,e))return;this.#v=t;let r=()=>{if(!e)return!0;let{notifyOnChangeProps:t}=this.options,r="function"==typeof t?t():t;if("all"===r||!r&&!this.#k.size)return!0;let i=new Set(r??this.#k);return this.options.throwOnError&&i.add("error"),Object.keys(this.#v).some(t=>this.#v[t]!==e[t]&&i.has(t))};this.#D({listeners:r()})}#F(){let e=this.#c.getQueryCache().build(this.#c,this.options);if(e===this.#g)return;let t=this.#g;this.#g=e,this.#b=e.state,this.hasListeners()&&(t?.removeObserver(this),e.addObserver(this))}onQueryUpdate(){this.updateResult(),this.hasListeners()&&this.#I()}#D(e){r.notifyManager.batch(()=>{e.listeners&&this.listeners.forEach(e=>{e(this.#v)}),this.#c.getQueryCache().notify({query:this.#g,type:"observerResultsUpdated"})})}};function u(e,t){return!1!==(0,a.resolveEnabled)(t.enabled,e)&&void 0===e.state.data&&("error"!==e.state.status||!1!==t.retryOnMount)||void 0!==e.state.data&&c(e,t,t.refetchOnMount)}function c(e,t,r){if(!1!==(0,a.resolveEnabled)(t.enabled,e)&&"static"!==(0,a.resolveStaleTime)(t.staleTime,e)){let i="function"==typeof r?r(e):r;return"always"===i||!1!==i&&d(e,t)}return!1}function h(e,t,r,i){return(e!==t||!1===(0,a.resolveEnabled)(i.enabled,e))&&(!r.suspense||"error"!==e.state.status)&&d(e,r)}function d(e,t){return!1!==(0,a.resolveEnabled)(t.enabled,e)&&e.isStaleByTime((0,a.resolveStaleTime)(t.staleTime,e))}e.s(["QueryObserver",()=>l])},266027,e=>{"use strict";let t;var r=e.i(869230);e.i(247167);var i=e.i(271645),s=e.i(619273),n=e.i(540143),a=e.i(912598);e.i(843476);var o=i.createContext((t=!1,{clearReset:()=>{t=!1},reset:()=>{t=!0},isReset:()=>t})),l=i.createContext(!1);l.Provider;var u=(e,t,r)=>t.fetchOptimistic(e).catch(()=>{r.clearReset()});function c(e,t){return function(e,t,r){let c,h=i.useContext(l),d=i.useContext(o),p=(0,a.useQueryClient)(r),f=p.defaultQueryOptions(e);p.getDefaultOptions().queries?._experimental_beforeQuery?.(f);let y=p.getQueryCache().get(f.queryHash);if(f._optimisticResults=h?"isRestoring":"optimistic",f.suspense){let e=e=>"static"===e?e:Math.max(e??1e3,1e3),t=f.staleTime;f.staleTime="function"==typeof t?(...r)=>e(t(...r)):e(t),"number"==typeof f.gcTime&&(f.gcTime=Math.max(f.gcTime,1e3))}c=y?.state.error&&"function"==typeof f.throwOnError?(0,s.shouldThrowError)(f.throwOnError,[y.state.error,y]):f.throwOnError,(f.suspense||f.experimental_prefetchInRender||c)&&!d.isReset()&&(f.retryOnMount=!1),i.useEffect(()=>{d.clearReset()},[d]);let m=!p.getQueryCache().get(f.queryHash),[g]=i.useState(()=>new t(p,f)),b=g.getOptimisticResult(f),v=!h&&!1!==e.subscribed;if(i.useSyncExternalStore(i.useCallback(e=>{let t=v?g.subscribe(n.notifyManager.batchCalls(e)):s.noop;return g.updateResult(),t},[g,v]),()=>g.getCurrentResult(),()=>g.getCurrentResult()),i.useEffect(()=>{g.setOptions(f)},[f,g]),f?.suspense&&b.isPending)throw u(f,g,d);if((({result:e,errorResetBoundary:t,throwOnError:r,query:i,suspense:n})=>e.isError&&!t.isReset()&&!e.isFetching&&i&&(n&&void 0===e.data||(0,s.shouldThrowError)(r,[e.error,i])))({result:b,errorResetBoundary:d,throwOnError:f.throwOnError,query:y,suspense:f.suspense}))throw b.error;if(p.getDefaultOptions().queries?._experimental_afterQuery?.(f,b),f.experimental_prefetchInRender&&!s.isServer&&b.isLoading&&b.isFetching&&!h){let e=m?u(f,g,d):y?.promise;e?.catch(s.noop).finally(()=>{g.updateResult()})}return f.notifyOnChangeProps?b:g.trackResult(b)}(e,r.QueryObserver,t)}e.s(["useQuery",()=>c],266027)},243652,e=>{"use strict";function t(e){let t=[e];return{all:t,lists:()=>[...t,"list"],list:e=>[...t,"list",{params:e}],details:()=>[...t,"detail"],detail:e=>[...t,"detail",e]}}e.s(["createQueryKeys",()=>t])},612256,e=>{"use strict";var t=e.i(764205),r=e.i(266027);let i=(0,e.i(243652).createQueryKeys)("uiConfig");e.s(["useUIConfig",0,()=>(0,r.useQuery)({queryKey:i.list({}),queryFn:async()=>await (0,t.getUiConfig)(),staleTime:864e5,gcTime:864e5})])},161281,e=>{"use strict";var t=e.i(947293);function r(e){try{let r=(0,t.jwtDecode)(e);if(r&&"number"==typeof r.exp)return 1e3*r.exp<=Date.now();return!1}catch{return!0}}function i(e){if(!e)return null;try{return(0,t.jwtDecode)(e)}catch{return null}}function s(e){return!!e&&null!==i(e)&&!r(e)}e.s(["checkTokenValidity",()=>s,"decodeToken",()=>i,"isJwtExpired",()=>r])},190144,e=>{"use strict";e.i(247167);var t=e.i(931067),r=e.i(271645);let i={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M832 64H296c-4.4 0-8 3.6-8 8v56c0 4.4 3.6 8 8 8h496v688c0 4.4 3.6 8 8 8h56c4.4 0 8-3.6 8-8V96c0-17.7-14.3-32-32-32zM704 192H192c-17.7 0-32 14.3-32 32v530.7c0 8.5 3.4 16.6 9.4 22.6l173.3 173.3c2.2 2.2 4.7 4 7.4 5.5v1.9h4.2c3.5 1.3 7.2 2 11 2H704c17.7 0 32-14.3 32-32V224c0-17.7-14.3-32-32-32zM350 856.2L263.9 770H350v86.2zM664 888H414V746c0-22.1-17.9-40-40-40H232V264h432v624z"}}]},name:"copy",theme:"outlined"};var s=e.i(9583),n=r.forwardRef(function(e,n){return r.createElement(s.default,(0,t.default)({},e,{ref:n,icon:i}))});e.s(["default",0,n],190144)},735049,e=>{"use strict";var t=e.i(654310),r=function(e){if((0,t.default)()&&window.document.documentElement){var r=Array.isArray(e)?e:[e],i=window.document.documentElement;return r.some(function(e){return e in i.style})}return!1},i=function(e,t){if(!r(e))return!1;var i=document.createElement("div"),s=i.style[e];return i.style[e]=t,i.style[e]!==s};function s(e,t){return Array.isArray(e)||void 0===t?r(e):i(e,t)}e.s(["isStyleSupport",()=>s])},185793,e=>{"use strict";e.i(247167);var t=e.i(271645),r=e.i(343794),i=e.i(242064),s=e.i(529681);let n=e=>{let{prefixCls:i,className:s,style:n,size:a,shape:o}=e,l=(0,r.default)({[`${i}-lg`]:"large"===a,[`${i}-sm`]:"small"===a}),u=(0,r.default)({[`${i}-circle`]:"circle"===o,[`${i}-square`]:"square"===o,[`${i}-round`]:"round"===o}),c=t.useMemo(()=>"number"==typeof a?{width:a,height:a,lineHeight:`${a}px`}:{},[a]);return t.createElement("span",{className:(0,r.default)(i,l,u,s),style:Object.assign(Object.assign({},c),n)})};e.i(296059);var a=e.i(694758),o=e.i(915654),l=e.i(246422),u=e.i(838378);let c=new a.Keyframes("ant-skeleton-loading",{"0%":{backgroundPosition:"100% 50%"},"100%":{backgroundPosition:"0 50%"}}),h=e=>({height:e,lineHeight:(0,o.unit)(e)}),d=e=>Object.assign({width:e},h(e)),p=(e,t)=>Object.assign({width:t(e).mul(5).equal(),minWidth:t(e).mul(5).equal()},h(e)),f=e=>Object.assign({width:e},h(e)),y=(e,t,r)=>{let{skeletonButtonCls:i}=e;return{[`${r}${i}-circle`]:{width:t,minWidth:t,borderRadius:"50%"},[`${r}${i}-round`]:{borderRadius:t}}},m=(e,t)=>Object.assign({width:t(e).mul(2).equal(),minWidth:t(e).mul(2).equal()},h(e)),g=(0,l.genStyleHooks)("Skeleton",e=>{let{componentCls:t,calc:r}=e;return(e=>{let{componentCls:t,skeletonAvatarCls:r,skeletonTitleCls:i,skeletonParagraphCls:s,skeletonButtonCls:n,skeletonInputCls:a,skeletonImageCls:o,controlHeight:l,controlHeightLG:u,controlHeightSM:h,gradientFromColor:g,padding:b,marginSM:v,borderRadius:O,titleHeight:C,blockRadius:R,paragraphLiHeight:S,controlHeightXS:w,paragraphMarginTop:E}=e;return{[t]:{display:"table",width:"100%",[`${t}-header`]:{display:"table-cell",paddingInlineEnd:b,verticalAlign:"top",[r]:Object.assign({display:"inline-block",verticalAlign:"top",background:g},d(l)),[`${r}-circle`]:{borderRadius:"50%"},[`${r}-lg`]:Object.assign({},d(u)),[`${r}-sm`]:Object.assign({},d(h))},[`${t}-content`]:{display:"table-cell",width:"100%",verticalAlign:"top",[i]:{width:"100%",height:C,background:g,borderRadius:R,[`+ ${s}`]:{marginBlockStart:h}},[s]:{padding:0,"> li":{width:"100%",height:S,listStyle:"none",background:g,borderRadius:R,"+ li":{marginBlockStart:w}}},[`${s}> li:last-child:not(:first-child):not(:nth-child(2))`]:{width:"61%"}},[`&-round ${t}-content`]:{[`${i}, ${s} > li`]:{borderRadius:O}}},[`${t}-with-avatar ${t}-content`]:{[i]:{marginBlockStart:v,[`+ ${s}`]:{marginBlockStart:E}}},[`${t}${t}-element`]:Object.assign(Object.assign(Object.assign(Object.assign({display:"inline-block",width:"auto"},(e=>{let{borderRadiusSM:t,skeletonButtonCls:r,controlHeight:i,controlHeightLG:s,controlHeightSM:n,gradientFromColor:a,calc:o}=e;return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({[r]:Object.assign({display:"inline-block",verticalAlign:"top",background:a,borderRadius:t,width:o(i).mul(2).equal(),minWidth:o(i).mul(2).equal()},m(i,o))},y(e,i,r)),{[`${r}-lg`]:Object.assign({},m(s,o))}),y(e,s,`${r}-lg`)),{[`${r}-sm`]:Object.assign({},m(n,o))}),y(e,n,`${r}-sm`))})(e)),(e=>{let{skeletonAvatarCls:t,gradientFromColor:r,controlHeight:i,controlHeightLG:s,controlHeightSM:n}=e;return{[t]:Object.assign({display:"inline-block",verticalAlign:"top",background:r},d(i)),[`${t}${t}-circle`]:{borderRadius:"50%"},[`${t}${t}-lg`]:Object.assign({},d(s)),[`${t}${t}-sm`]:Object.assign({},d(n))}})(e)),(e=>{let{controlHeight:t,borderRadiusSM:r,skeletonInputCls:i,controlHeightLG:s,controlHeightSM:n,gradientFromColor:a,calc:o}=e;return{[i]:Object.assign({display:"inline-block",verticalAlign:"top",background:a,borderRadius:r},p(t,o)),[`${i}-lg`]:Object.assign({},p(s,o)),[`${i}-sm`]:Object.assign({},p(n,o))}})(e)),(e=>{let{skeletonImageCls:t,imageSizeBase:r,gradientFromColor:i,borderRadiusSM:s,calc:n}=e;return{[t]:Object.assign(Object.assign({display:"inline-flex",alignItems:"center",justifyContent:"center",verticalAlign:"middle",background:i,borderRadius:s},f(n(r).mul(2).equal())),{[`${t}-path`]:{fill:"#bfbfbf"},[`${t}-svg`]:Object.assign(Object.assign({},f(r)),{maxWidth:n(r).mul(4).equal(),maxHeight:n(r).mul(4).equal()}),[`${t}-svg${t}-svg-circle`]:{borderRadius:"50%"}}),[`${t}${t}-circle`]:{borderRadius:"50%"}}})(e)),[`${t}${t}-block`]:{width:"100%",[n]:{width:"100%"},[a]:{width:"100%"}},[`${t}${t}-active`]:{[` + ${i}, + ${s} > li, + ${r}, + ${n}, + ${a}, + ${o} + `]:Object.assign({},{background:e.skeletonLoadingBackground,backgroundSize:"400% 100%",animationName:c,animationDuration:e.skeletonLoadingMotionDuration,animationTimingFunction:"ease",animationIterationCount:"infinite"})}}})((0,u.mergeToken)(e,{skeletonAvatarCls:`${t}-avatar`,skeletonTitleCls:`${t}-title`,skeletonParagraphCls:`${t}-paragraph`,skeletonButtonCls:`${t}-button`,skeletonInputCls:`${t}-input`,skeletonImageCls:`${t}-image`,imageSizeBase:r(e.controlHeight).mul(1.5).equal(),borderRadius:100,skeletonLoadingBackground:`linear-gradient(90deg, ${e.gradientFromColor} 25%, ${e.gradientToColor} 37%, ${e.gradientFromColor} 63%)`,skeletonLoadingMotionDuration:"1.4s"}))},e=>{let{colorFillContent:t,colorFill:r}=e;return{color:t,colorGradientEnd:r,gradientFromColor:t,gradientToColor:r,titleHeight:e.controlHeight/2,blockRadius:e.borderRadiusSM,paragraphMarginTop:e.marginLG+e.marginXXS,paragraphLiHeight:e.controlHeight/2}},{deprecatedTokens:[["color","gradientFromColor"],["colorGradientEnd","gradientToColor"]]}),b=e=>{let{prefixCls:i,className:s,style:n,rows:a=0}=e,o=Array.from({length:a}).map((r,i)=>t.createElement("li",{key:i,style:{width:((e,t)=>{let{width:r,rows:i=2}=t;return Array.isArray(r)?r[e]:i-1===e?r:void 0})(i,e)}}));return t.createElement("ul",{className:(0,r.default)(i,s),style:n},o)},v=({prefixCls:e,className:i,width:s,style:n})=>t.createElement("h3",{className:(0,r.default)(e,i),style:Object.assign({width:s},n)});function O(e){return e&&"object"==typeof e?e:{}}let C=e=>{let{prefixCls:s,loading:a,className:o,rootClassName:l,style:u,children:c,avatar:h=!1,title:d=!0,paragraph:p=!0,active:f,round:y}=e,{getPrefixCls:m,direction:C,className:R,style:S}=(0,i.useComponentConfig)("skeleton"),w=m("skeleton",s),[E,T,$]=g(w);if(a||!("loading"in e)){let e,i,s=!!h,a=!!d,c=!!p;if(s){let r=Object.assign(Object.assign({prefixCls:`${w}-avatar`},a&&!c?{size:"large",shape:"square"}:{size:"large",shape:"circle"}),O(h));e=t.createElement("div",{className:`${w}-header`},t.createElement(n,Object.assign({},r)))}if(a||c){let e,r;if(a){let r=Object.assign(Object.assign({prefixCls:`${w}-title`},!s&&c?{width:"38%"}:s&&c?{width:"50%"}:{}),O(d));e=t.createElement(v,Object.assign({},r))}if(c){let e,i=Object.assign(Object.assign({prefixCls:`${w}-paragraph`},(e={},s&&a||(e.width="61%"),!s&&a?e.rows=3:e.rows=2,e)),O(p));r=t.createElement(b,Object.assign({},i))}i=t.createElement("div",{className:`${w}-content`},e,r)}let m=(0,r.default)(w,{[`${w}-with-avatar`]:s,[`${w}-active`]:f,[`${w}-rtl`]:"rtl"===C,[`${w}-round`]:y},R,o,l,T,$);return E(t.createElement("div",{className:m,style:Object.assign(Object.assign({},S),u)},e,i))}return null!=c?c:null};C.Button=e=>{let{prefixCls:a,className:o,rootClassName:l,active:u,block:c=!1,size:h="default"}=e,{getPrefixCls:d}=t.useContext(i.ConfigContext),p=d("skeleton",a),[f,y,m]=g(p),b=(0,s.default)(e,["prefixCls"]),v=(0,r.default)(p,`${p}-element`,{[`${p}-active`]:u,[`${p}-block`]:c},o,l,y,m);return f(t.createElement("div",{className:v},t.createElement(n,Object.assign({prefixCls:`${p}-button`,size:h},b))))},C.Avatar=e=>{let{prefixCls:a,className:o,rootClassName:l,active:u,shape:c="circle",size:h="default"}=e,{getPrefixCls:d}=t.useContext(i.ConfigContext),p=d("skeleton",a),[f,y,m]=g(p),b=(0,s.default)(e,["prefixCls","className"]),v=(0,r.default)(p,`${p}-element`,{[`${p}-active`]:u},o,l,y,m);return f(t.createElement("div",{className:v},t.createElement(n,Object.assign({prefixCls:`${p}-avatar`,shape:c,size:h},b))))},C.Input=e=>{let{prefixCls:a,className:o,rootClassName:l,active:u,block:c,size:h="default"}=e,{getPrefixCls:d}=t.useContext(i.ConfigContext),p=d("skeleton",a),[f,y,m]=g(p),b=(0,s.default)(e,["prefixCls"]),v=(0,r.default)(p,`${p}-element`,{[`${p}-active`]:u,[`${p}-block`]:c},o,l,y,m);return f(t.createElement("div",{className:v},t.createElement(n,Object.assign({prefixCls:`${p}-input`,size:h},b))))},C.Image=e=>{let{prefixCls:s,className:n,rootClassName:a,style:o,active:l}=e,{getPrefixCls:u}=t.useContext(i.ConfigContext),c=u("skeleton",s),[h,d,p]=g(c),f=(0,r.default)(c,`${c}-element`,{[`${c}-active`]:l},n,a,d,p);return h(t.createElement("div",{className:f},t.createElement("div",{className:(0,r.default)(`${c}-image`,n),style:o},t.createElement("svg",{viewBox:"0 0 1098 1024",xmlns:"http://www.w3.org/2000/svg",className:`${c}-image-svg`},t.createElement("title",null,"Image placeholder"),t.createElement("path",{d:"M365.714286 329.142857q0 45.714286-32.036571 77.677714t-77.677714 32.036571-77.677714-32.036571-32.036571-77.677714 32.036571-77.677714 77.677714-32.036571 77.677714 32.036571 32.036571 77.677714zM950.857143 548.571429l0 256-804.571429 0 0-109.714286 182.857143-182.857143 91.428571 91.428571 292.571429-292.571429zM1005.714286 146.285714l-914.285714 0q-7.460571 0-12.873143 5.412571t-5.412571 12.873143l0 694.857143q0 7.460571 5.412571 12.873143t12.873143 5.412571l914.285714 0q7.460571 0 12.873143-5.412571t5.412571-12.873143l0-694.857143q0-7.460571-5.412571-12.873143t-12.873143-5.412571zM1097.142857 164.571429l0 694.857143q0 37.741714-26.843429 64.585143t-64.585143 26.843429l-914.285714 0q-37.741714 0-64.585143-26.843429t-26.843429-64.585143l0-694.857143q0-37.741714 26.843429-64.585143t64.585143-26.843429l914.285714 0q37.741714 0 64.585143 26.843429t26.843429 64.585143z",className:`${c}-image-path`})))))},C.Node=e=>{let{prefixCls:s,className:n,rootClassName:a,style:o,active:l,children:u}=e,{getPrefixCls:c}=t.useContext(i.ConfigContext),h=c("skeleton",s),[d,p,f]=g(h),y=(0,r.default)(h,`${h}-element`,{[`${h}-active`]:l},p,n,a,f);return d(t.createElement("div",{className:y},t.createElement("div",{className:(0,r.default)(`${h}-image`,n),style:o},u)))},e.s(["default",0,C],185793)}]); \ No newline at end of file diff --git a/litellm/proxy/_experimental/out/_next/static/chunks/06aaedbe7d27898c.js b/litellm/proxy/_experimental/out/_next/static/chunks/06aaedbe7d27898c.js new file mode 100644 index 00000000000..5b79d13c9bc --- /dev/null +++ b/litellm/proxy/_experimental/out/_next/static/chunks/06aaedbe7d27898c.js @@ -0,0 +1 @@ +(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,270377,e=>{"use strict";e.i(247167);var t=e.i(931067),r=e.i(271645);let i={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M512 64C264.6 64 64 264.6 64 512s200.6 448 448 448 448-200.6 448-448S759.4 64 512 64zm0 820c-205.4 0-372-166.6-372-372s166.6-372 372-372 372 166.6 372 372-166.6 372-372 372z"}},{tag:"path",attrs:{d:"M464 688a48 48 0 1096 0 48 48 0 10-96 0zm24-112h48c4.4 0 8-3.6 8-8V296c0-4.4-3.6-8-8-8h-48c-4.4 0-8 3.6-8 8v272c0 4.4 3.6 8 8 8z"}}]},name:"exclamation-circle",theme:"outlined"};var n=e.i(9583),o=r.forwardRef(function(e,o){return r.createElement(n.default,(0,t.default)({},e,{ref:o,icon:i}))});e.s(["ExclamationCircleOutlined",0,o],270377)},244451,e=>{"use strict";let t;e.i(247167);var r=e.i(271645),i=e.i(343794),n=e.i(242064),o=e.i(763731),a=e.i(174428);let l=80*Math.PI,s=e=>{let{dotClassName:t,style:n,hasCircleCls:o}=e;return r.createElement("circle",{className:(0,i.default)(`${t}-circle`,{[`${t}-circle-bg`]:o}),r:40,cx:50,cy:50,strokeWidth:20,style:n})},c=({percent:e,prefixCls:t})=>{let n=`${t}-dot`,o=`${n}-holder`,c=`${o}-hidden`,[u,d]=r.useState(!1);(0,a.default)(()=>{0!==e&&d(!0)},[0!==e]);let m=Math.max(Math.min(e,100),0);if(!u)return null;let p={strokeDashoffset:`${l/4}`,strokeDasharray:`${l*m/100} ${l*(100-m)/100}`};return r.createElement("span",{className:(0,i.default)(o,`${n}-progress`,m<=0&&c)},r.createElement("svg",{viewBox:"0 0 100 100",role:"progressbar","aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":m},r.createElement(s,{dotClassName:n,hasCircleCls:!0}),r.createElement(s,{dotClassName:n,style:p})))};function u(e){let{prefixCls:t,percent:n=0}=e,o=`${t}-dot`,a=`${o}-holder`,l=`${a}-hidden`;return r.createElement(r.Fragment,null,r.createElement("span",{className:(0,i.default)(a,n>0&&l)},r.createElement("span",{className:(0,i.default)(o,`${t}-dot-spin`)},[1,2,3,4].map(e=>r.createElement("i",{className:`${t}-dot-item`,key:e})))),r.createElement(c,{prefixCls:t,percent:n}))}function d(e){var t;let{prefixCls:n,indicator:a,percent:l}=e,s=`${n}-dot`;return a&&r.isValidElement(a)?(0,o.cloneElement)(a,{className:(0,i.default)(null==(t=a.props)?void 0:t.className,s),percent:l}):r.createElement(u,{prefixCls:n,percent:l})}e.i(296059);var m=e.i(694758),p=e.i(183293),f=e.i(246422),g=e.i(838378);let h=new m.Keyframes("antSpinMove",{to:{opacity:1}}),y=new m.Keyframes("antRotate",{to:{transform:"rotate(405deg)"}}),v=(0,f.genStyleHooks)("Spin",e=>(e=>{let{componentCls:t,calc:r}=e;return{[t]:Object.assign(Object.assign({},(0,p.resetComponent)(e)),{position:"absolute",display:"none",color:e.colorPrimary,fontSize:0,textAlign:"center",verticalAlign:"middle",opacity:0,transition:`transform ${e.motionDurationSlow} ${e.motionEaseInOutCirc}`,"&-spinning":{position:"relative",display:"inline-block",opacity:1},[`${t}-text`]:{fontSize:e.fontSize,paddingTop:r(r(e.dotSize).sub(e.fontSize)).div(2).add(2).equal()},"&-fullscreen":{position:"fixed",width:"100vw",height:"100vh",backgroundColor:e.colorBgMask,zIndex:e.zIndexPopupBase,inset:0,display:"flex",alignItems:"center",flexDirection:"column",justifyContent:"center",opacity:0,visibility:"hidden",transition:`all ${e.motionDurationMid}`,"&-show":{opacity:1,visibility:"visible"},[t]:{[`${t}-dot-holder`]:{color:e.colorWhite},[`${t}-text`]:{color:e.colorTextLightSolid}}},"&-nested-loading":{position:"relative",[`> div > ${t}`]:{position:"absolute",top:0,insetInlineStart:0,zIndex:4,display:"block",width:"100%",height:"100%",maxHeight:e.contentHeight,[`${t}-dot`]:{position:"absolute",top:"50%",insetInlineStart:"50%",margin:r(e.dotSize).mul(-1).div(2).equal()},[`${t}-text`]:{position:"absolute",top:"50%",width:"100%",textShadow:`0 1px 2px ${e.colorBgContainer}`},[`&${t}-show-text ${t}-dot`]:{marginTop:r(e.dotSize).div(2).mul(-1).sub(10).equal()},"&-sm":{[`${t}-dot`]:{margin:r(e.dotSizeSM).mul(-1).div(2).equal()},[`${t}-text`]:{paddingTop:r(r(e.dotSizeSM).sub(e.fontSize)).div(2).add(2).equal()},[`&${t}-show-text ${t}-dot`]:{marginTop:r(e.dotSizeSM).div(2).mul(-1).sub(10).equal()}},"&-lg":{[`${t}-dot`]:{margin:r(e.dotSizeLG).mul(-1).div(2).equal()},[`${t}-text`]:{paddingTop:r(r(e.dotSizeLG).sub(e.fontSize)).div(2).add(2).equal()},[`&${t}-show-text ${t}-dot`]:{marginTop:r(e.dotSizeLG).div(2).mul(-1).sub(10).equal()}}},[`${t}-container`]:{position:"relative",transition:`opacity ${e.motionDurationSlow}`,"&::after":{position:"absolute",top:0,insetInlineEnd:0,bottom:0,insetInlineStart:0,zIndex:10,width:"100%",height:"100%",background:e.colorBgContainer,opacity:0,transition:`all ${e.motionDurationSlow}`,content:'""',pointerEvents:"none"}},[`${t}-blur`]:{clear:"both",opacity:.5,userSelect:"none",pointerEvents:"none","&::after":{opacity:.4,pointerEvents:"auto"}}},"&-tip":{color:e.spinDotDefault},[`${t}-dot-holder`]:{width:"1em",height:"1em",fontSize:e.dotSize,display:"inline-block",transition:`transform ${e.motionDurationSlow} ease, opacity ${e.motionDurationSlow} ease`,transformOrigin:"50% 50%",lineHeight:1,color:e.colorPrimary,"&-hidden":{transform:"scale(0.3)",opacity:0}},[`${t}-dot-progress`]:{position:"absolute",inset:0},[`${t}-dot`]:{position:"relative",display:"inline-block",fontSize:e.dotSize,width:"1em",height:"1em","&-item":{position:"absolute",display:"block",width:r(e.dotSize).sub(r(e.marginXXS).div(2)).div(2).equal(),height:r(e.dotSize).sub(r(e.marginXXS).div(2)).div(2).equal(),background:"currentColor",borderRadius:"100%",transform:"scale(0.75)",transformOrigin:"50% 50%",opacity:.3,animationName:h,animationDuration:"1s",animationIterationCount:"infinite",animationTimingFunction:"linear",animationDirection:"alternate","&:nth-child(1)":{top:0,insetInlineStart:0,animationDelay:"0s"},"&:nth-child(2)":{top:0,insetInlineEnd:0,animationDelay:"0.4s"},"&:nth-child(3)":{insetInlineEnd:0,bottom:0,animationDelay:"0.8s"},"&:nth-child(4)":{bottom:0,insetInlineStart:0,animationDelay:"1.2s"}},"&-spin":{transform:"rotate(45deg)",animationName:y,animationDuration:"1.2s",animationIterationCount:"infinite",animationTimingFunction:"linear"},"&-circle":{strokeLinecap:"round",transition:["stroke-dashoffset","stroke-dasharray","stroke","stroke-width","opacity"].map(t=>`${t} ${e.motionDurationSlow} ease`).join(","),fillOpacity:0,stroke:"currentcolor"},"&-circle-bg":{stroke:e.colorFillSecondary}},[`&-sm ${t}-dot`]:{"&, &-holder":{fontSize:e.dotSizeSM}},[`&-sm ${t}-dot-holder`]:{i:{width:r(r(e.dotSizeSM).sub(r(e.marginXXS).div(2))).div(2).equal(),height:r(r(e.dotSizeSM).sub(r(e.marginXXS).div(2))).div(2).equal()}},[`&-lg ${t}-dot`]:{"&, &-holder":{fontSize:e.dotSizeLG}},[`&-lg ${t}-dot-holder`]:{i:{width:r(r(e.dotSizeLG).sub(e.marginXXS)).div(2).equal(),height:r(r(e.dotSizeLG).sub(e.marginXXS)).div(2).equal()}},[`&${t}-show-text ${t}-text`]:{display:"block"}})}})((0,g.mergeToken)(e,{spinDotDefault:e.colorTextDescription})),e=>{let{controlHeightLG:t,controlHeight:r}=e;return{contentHeight:400,dotSize:t/2,dotSizeSM:.35*t,dotSizeLG:r}}),b=[[30,.05],[70,.03],[96,.01]];var $=function(e,t){var r={};for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&0>t.indexOf(i)&&(r[i]=e[i]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols)for(var n=0,i=Object.getOwnPropertySymbols(e);nt.indexOf(i[n])&&Object.prototype.propertyIsEnumerable.call(e,i[n])&&(r[i[n]]=e[i[n]]);return r};let S=e=>{var o;let{prefixCls:a,spinning:l=!0,delay:s=0,className:c,rootClassName:u,size:m="default",tip:p,wrapperClassName:f,style:g,children:h,fullscreen:y=!1,indicator:S,percent:x}=e,k=$(e,["prefixCls","spinning","delay","className","rootClassName","size","tip","wrapperClassName","style","children","fullscreen","indicator","percent"]),{getPrefixCls:C,direction:w,className:E,style:O,indicator:z}=(0,n.useComponentConfig)("spin"),j=C("spin",a),[D,N,I]=v(j),[M,T]=r.useState(()=>l&&(!l||!s||!!Number.isNaN(Number(s)))),P=function(e,t){let[i,n]=r.useState(0),o=r.useRef(null),a="auto"===t;return r.useEffect(()=>(a&&e&&(n(0),o.current=setInterval(()=>{n(e=>{let t=100-e;for(let r=0;r{o.current&&(clearInterval(o.current),o.current=null)}),[a,e]),a?i:t}(M,x);r.useEffect(()=>{if(l){let e=function(e,t,r){var i,n=r||{},o=n.noTrailing,a=void 0!==o&&o,l=n.noLeading,s=void 0!==l&&l,c=n.debounceMode,u=void 0===c?void 0:c,d=!1,m=0;function p(){i&&clearTimeout(i)}function f(){for(var r=arguments.length,n=Array(r),o=0;oe?s?(m=Date.now(),a||(i=setTimeout(u?g:f,e))):f():!0!==a&&(i=setTimeout(u?g:f,void 0===u?e-c:e)))}return f.cancel=function(e){var t=(e||{}).upcomingOnly;p(),d=!(void 0!==t&&t)},f}(s,()=>{T(!0)},{debounceMode:false});return e(),()=>{var t;null==(t=null==e?void 0:e.cancel)||t.call(e)}}T(!1)},[s,l]);let A=r.useMemo(()=>void 0!==h&&!y,[h,y]),X=(0,i.default)(j,E,{[`${j}-sm`]:"small"===m,[`${j}-lg`]:"large"===m,[`${j}-spinning`]:M,[`${j}-show-text`]:!!p,[`${j}-rtl`]:"rtl"===w},c,!y&&u,N,I),W=(0,i.default)(`${j}-container`,{[`${j}-blur`]:M}),L=null!=(o=null!=S?S:z)?o:t,R=Object.assign(Object.assign({},O),g),q=r.createElement("div",Object.assign({},k,{style:R,className:X,"aria-live":"polite","aria-busy":M}),r.createElement(d,{prefixCls:j,indicator:L,percent:P}),p&&(A||y)?r.createElement("div",{className:`${j}-text`},p):null);return D(A?r.createElement("div",Object.assign({},k,{className:(0,i.default)(`${j}-nested-loading`,f,N,I)}),M&&r.createElement("div",{key:"loading"},q),r.createElement("div",{className:W,key:"container"},h)):y?r.createElement("div",{className:(0,i.default)(`${j}-fullscreen`,{[`${j}-fullscreen-show`]:M},u,N,I)},q):q)};S.setDefaultIndicator=e=>{t=e},e.s(["default",0,S],244451)},482725,e=>{"use strict";var t=e.i(244451);e.s(["Spin",()=>t.default])},309821,e=>{"use strict";e.i(247167);var t=e.i(271645);e.i(262370);var r=e.i(135551),i=e.i(201072),n=e.i(121229),o=e.i(726289),a=e.i(864517),l=e.i(343794),s=e.i(529681),c=e.i(242064),u=e.i(931067),d=e.i(209428),m=e.i(703923),p={percent:0,prefixCls:"rc-progress",strokeColor:"#2db7f5",strokeLinecap:"round",strokeWidth:1,trailColor:"#D9D9D9",trailWidth:1,gapPosition:"bottom"},f=function(){var e=(0,t.useRef)([]),r=(0,t.useRef)(null);return(0,t.useEffect)(function(){var t=Date.now(),i=!1;e.current.forEach(function(e){if(e){i=!0;var n=e.style;n.transitionDuration=".3s, .3s, .3s, .06s",r.current&&t-r.current<100&&(n.transitionDuration="0s, 0s")}}),i&&(r.current=Date.now())}),e.current},g=e.i(410160),h=e.i(392221),y=e.i(654310),v=0,b=(0,y.default)();let $=function(e){var r=t.useState(),i=(0,h.default)(r,2),n=i[0],o=i[1];return t.useEffect(function(){var e;o("rc_progress_".concat((b?(e=v,v+=1):e="TEST_OR_SSR",e)))},[]),e||n};var S=function(e){var r=e.bg,i=e.children;return t.createElement("div",{style:{width:"100%",height:"100%",background:r}},i)};function x(e,t){return Object.keys(e).map(function(r){var i=parseFloat(r),n="".concat(Math.floor(i*t),"%");return"".concat(e[r]," ").concat(n)})}var k=t.forwardRef(function(e,r){var i=e.prefixCls,n=e.color,o=e.gradientId,a=e.radius,l=e.style,s=e.ptg,c=e.strokeLinecap,u=e.strokeWidth,d=e.size,m=e.gapDegree,p=n&&"object"===(0,g.default)(n),f=d/2,h=t.createElement("circle",{className:"".concat(i,"-circle-path"),r:a,cx:f,cy:f,stroke:p?"#FFF":void 0,strokeLinecap:c,strokeWidth:u,opacity:+(0!==s),style:l,ref:r});if(!p)return h;var y="".concat(o,"-conic"),v=x(n,(360-m)/360),b=x(n,1),$="conic-gradient(from ".concat(m?"".concat(180+m/2,"deg"):"0deg",", ").concat(v.join(", "),")"),k="linear-gradient(to ".concat(m?"bottom":"top",", ").concat(b.join(", "),")");return t.createElement(t.Fragment,null,t.createElement("mask",{id:y},h),t.createElement("foreignObject",{x:0,y:0,width:d,height:d,mask:"url(#".concat(y,")")},t.createElement(S,{bg:k},t.createElement(S,{bg:$}))))}),C=function(e,t,r,i,n,o,a,l,s,c){var u=arguments.length>10&&void 0!==arguments[10]?arguments[10]:0,d=(100-i)/100*t;return"round"===s&&100!==i&&(d+=c/2)>=t&&(d=t-.01),{stroke:"string"==typeof l?l:void 0,strokeDasharray:"".concat(t,"px ").concat(e),strokeDashoffset:d+u,transform:"rotate(".concat(n+r/100*360*((360-o)/360)+(0===o?0:({bottom:0,top:180,left:90,right:-90})[a]),"deg)"),transformOrigin:"".concat(50,"px ").concat(50,"px"),transition:"stroke-dashoffset .3s ease 0s, stroke-dasharray .3s ease 0s, stroke .3s, stroke-width .06s ease .3s, opacity .3s ease 0s",fillOpacity:0}},w=["id","prefixCls","steps","strokeWidth","trailWidth","gapDegree","gapPosition","trailColor","strokeLinecap","style","className","strokeColor","percent"];function E(e){var t=null!=e?e:[];return Array.isArray(t)?t:[t]}let O=function(e){var r,i,n,o,a=(0,d.default)((0,d.default)({},p),e),s=a.id,c=a.prefixCls,h=a.steps,y=a.strokeWidth,v=a.trailWidth,b=a.gapDegree,S=void 0===b?0:b,x=a.gapPosition,O=a.trailColor,z=a.strokeLinecap,j=a.style,D=a.className,N=a.strokeColor,I=a.percent,M=(0,m.default)(a,w),T=$(s),P="".concat(T,"-gradient"),A=50-y/2,X=2*Math.PI*A,W=S>0?90+S/2:-90,L=(360-S)/360*X,R="object"===(0,g.default)(h)?h:{count:h,gap:2},q=R.count,B=R.gap,F=E(I),H=E(N),G=H.find(function(e){return e&&"object"===(0,g.default)(e)}),_=G&&"object"===(0,g.default)(G)?"butt":z,K=C(X,L,0,100,W,S,x,O,_,y),U=f();return t.createElement("svg",(0,u.default)({className:(0,l.default)("".concat(c,"-circle"),D),viewBox:"0 0 ".concat(100," ").concat(100),style:j,id:s,role:"presentation"},M),!q&&t.createElement("circle",{className:"".concat(c,"-circle-trail"),r:A,cx:50,cy:50,stroke:O,strokeLinecap:_,strokeWidth:v||y,style:K}),q?(r=Math.round(q*(F[0]/100)),i=100/q,n=0,Array(q).fill(null).map(function(e,o){var a=o<=r-1?H[0]:O,l=a&&"object"===(0,g.default)(a)?"url(#".concat(P,")"):void 0,s=C(X,L,n,i,W,S,x,a,"butt",y,B);return n+=(L-s.strokeDashoffset+B)*100/L,t.createElement("circle",{key:o,className:"".concat(c,"-circle-path"),r:A,cx:50,cy:50,stroke:l,strokeWidth:y,opacity:1,style:s,ref:function(e){U[o]=e}})})):(o=0,F.map(function(e,r){var i=H[r]||H[H.length-1],n=C(X,L,o,e,W,S,x,i,_,y);return o+=e,t.createElement(k,{key:r,color:i,ptg:e,radius:A,prefixCls:c,gradientId:P,style:n,strokeLinecap:_,strokeWidth:y,gapDegree:S,ref:function(e){U[r]=e},size:100})}).reverse()))};var z=e.i(491816);e.i(765846);var j=e.i(896091);function D(e){return!e||e<0?0:e>100?100:e}function N({success:e,successPercent:t}){let r=t;return e&&"progress"in e&&(r=e.progress),e&&"percent"in e&&(r=e.percent),r}let I=(e,t,r)=>{var i,n,o,a;let l=-1,s=-1;if("step"===t){let t=r.steps,i=r.strokeWidth;"string"==typeof e||void 0===e?(l="small"===e?2:14,s=null!=i?i:8):"number"==typeof e?[l,s]=[e,e]:[l=14,s=8]=Array.isArray(e)?e:[e.width,e.height],l*=t}else if("line"===t){let t=null==r?void 0:r.strokeWidth;"string"==typeof e||void 0===e?s=t||("small"===e?6:8):"number"==typeof e?[l,s]=[e,e]:[l=-1,s=8]=Array.isArray(e)?e:[e.width,e.height]}else("circle"===t||"dashboard"===t)&&("string"==typeof e||void 0===e?[l,s]="small"===e?[60,60]:[120,120]:"number"==typeof e?[l,s]=[e,e]:Array.isArray(e)&&(l=null!=(n=null!=(i=e[0])?i:e[1])?n:120,s=null!=(a=null!=(o=e[0])?o:e[1])?a:120));return[l,s]},M=e=>{let{prefixCls:r,trailColor:i=null,strokeLinecap:n="round",gapPosition:o,gapDegree:a,width:s=120,type:c,children:u,success:d,size:m=s,steps:p}=e,[f,g]=I(m,"circle"),{strokeWidth:h}=e;void 0===h&&(h=Math.max(3/f*100,6));let y=t.useMemo(()=>a||0===a?a:"dashboard"===c?75:void 0,[a,c]),v=(({percent:e,success:t,successPercent:r})=>{let i=D(N({success:t,successPercent:r}));return[i,D(D(e)-i)]})(e),b="[object Object]"===Object.prototype.toString.call(e.strokeColor),$=(({success:e={},strokeColor:t})=>{let{strokeColor:r}=e;return[r||j.presetPrimaryColors.green,t||null]})({success:d,strokeColor:e.strokeColor}),S=(0,l.default)(`${r}-inner`,{[`${r}-circle-gradient`]:b}),x=t.createElement(O,{steps:p,percent:p?v[1]:v,strokeWidth:h,trailWidth:h,strokeColor:p?$[1]:$,strokeLinecap:n,trailColor:i,prefixCls:r,gapDegree:y,gapPosition:o||"dashboard"===c&&"bottom"||void 0}),k=f<=20,C=t.createElement("div",{className:S,style:{width:f,height:g,fontSize:.15*f+6}},x,!k&&u);return k?t.createElement(z.default,{title:u},C):C};e.i(296059);var T=e.i(694758),P=e.i(915654),A=e.i(183293),X=e.i(246422),W=e.i(838378);let L="--progress-line-stroke-color",R="--progress-percent",q=e=>{let t=e?"100%":"-100%";return new T.Keyframes(`antProgress${e?"RTL":"LTR"}Active`,{"0%":{transform:`translateX(${t}) scaleX(0)`,opacity:.1},"20%":{transform:`translateX(${t}) scaleX(0)`,opacity:.5},to:{transform:"translateX(0) scaleX(1)",opacity:0}})},B=(0,X.genStyleHooks)("Progress",e=>{let t=e.calc(e.marginXXS).div(2).equal(),r=(0,W.mergeToken)(e,{progressStepMarginInlineEnd:t,progressStepMinWidth:t,progressActiveMotionDuration:"2.4s"});return[(e=>{let{componentCls:t,iconCls:r}=e;return{[t]:Object.assign(Object.assign({},(0,A.resetComponent)(e)),{display:"inline-block","&-rtl":{direction:"rtl"},"&-line":{position:"relative",width:"100%",fontSize:e.fontSize},[`${t}-outer`]:{display:"inline-flex",alignItems:"center",width:"100%"},[`${t}-inner`]:{position:"relative",display:"inline-block",width:"100%",flex:1,overflow:"hidden",verticalAlign:"middle",backgroundColor:e.remainingColor,borderRadius:e.lineBorderRadius},[`${t}-inner:not(${t}-circle-gradient)`]:{[`${t}-circle-path`]:{stroke:e.defaultColor}},[`${t}-success-bg, ${t}-bg`]:{position:"relative",background:e.defaultColor,borderRadius:e.lineBorderRadius,transition:`all ${e.motionDurationSlow} ${e.motionEaseInOutCirc}`},[`${t}-layout-bottom`]:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",[`${t}-text`]:{width:"max-content",marginInlineStart:0,marginTop:e.marginXXS}},[`${t}-bg`]:{overflow:"hidden","&::after":{content:'""',background:{_multi_value_:!0,value:["inherit",`var(${L})`]},height:"100%",width:`calc(1 / var(${R}) * 100%)`,display:"block"},[`&${t}-bg-inner`]:{minWidth:"max-content","&::after":{content:"none"},[`${t}-text-inner`]:{color:e.colorWhite,[`&${t}-text-bright`]:{color:"rgba(0, 0, 0, 0.45)"}}}},[`${t}-success-bg`]:{position:"absolute",insetBlockStart:0,insetInlineStart:0,backgroundColor:e.colorSuccess},[`${t}-text`]:{display:"inline-block",marginInlineStart:e.marginXS,color:e.colorText,lineHeight:1,width:"2em",whiteSpace:"nowrap",textAlign:"start",verticalAlign:"middle",wordBreak:"normal",[r]:{fontSize:e.fontSize},[`&${t}-text-outer`]:{width:"max-content"},[`&${t}-text-outer${t}-text-start`]:{width:"max-content",marginInlineStart:0,marginInlineEnd:e.marginXS}},[`${t}-text-inner`]:{display:"flex",justifyContent:"center",alignItems:"center",width:"100%",height:"100%",marginInlineStart:0,padding:`0 ${(0,P.unit)(e.paddingXXS)}`,[`&${t}-text-start`]:{justifyContent:"start"},[`&${t}-text-end`]:{justifyContent:"end"}},[`&${t}-status-active`]:{[`${t}-bg::before`]:{position:"absolute",inset:0,backgroundColor:e.colorBgContainer,borderRadius:e.lineBorderRadius,opacity:0,animationName:q(),animationDuration:e.progressActiveMotionDuration,animationTimingFunction:e.motionEaseOutQuint,animationIterationCount:"infinite",content:'""'}},[`&${t}-rtl${t}-status-active`]:{[`${t}-bg::before`]:{animationName:q(!0)}},[`&${t}-status-exception`]:{[`${t}-bg`]:{backgroundColor:e.colorError},[`${t}-text`]:{color:e.colorError}},[`&${t}-status-exception ${t}-inner:not(${t}-circle-gradient)`]:{[`${t}-circle-path`]:{stroke:e.colorError}},[`&${t}-status-success`]:{[`${t}-bg`]:{backgroundColor:e.colorSuccess},[`${t}-text`]:{color:e.colorSuccess}},[`&${t}-status-success ${t}-inner:not(${t}-circle-gradient)`]:{[`${t}-circle-path`]:{stroke:e.colorSuccess}}})}})(r),(e=>{let{componentCls:t,iconCls:r}=e;return{[t]:{[`${t}-circle-trail`]:{stroke:e.remainingColor},[`&${t}-circle ${t}-inner`]:{position:"relative",lineHeight:1,backgroundColor:"transparent"},[`&${t}-circle ${t}-text`]:{position:"absolute",insetBlockStart:"50%",insetInlineStart:0,width:"100%",margin:0,padding:0,color:e.circleTextColor,fontSize:e.circleTextFontSize,lineHeight:1,whiteSpace:"normal",textAlign:"center",transform:"translateY(-50%)",[r]:{fontSize:e.circleIconFontSize}},[`${t}-circle&-status-exception`]:{[`${t}-text`]:{color:e.colorError}},[`${t}-circle&-status-success`]:{[`${t}-text`]:{color:e.colorSuccess}}},[`${t}-inline-circle`]:{lineHeight:1,[`${t}-inner`]:{verticalAlign:"bottom"}}}})(r),(e=>{let{componentCls:t}=e;return{[t]:{[`${t}-steps`]:{display:"inline-block","&-outer":{display:"flex",flexDirection:"row",alignItems:"center"},"&-item":{flexShrink:0,minWidth:e.progressStepMinWidth,marginInlineEnd:e.progressStepMarginInlineEnd,backgroundColor:e.remainingColor,transition:`all ${e.motionDurationSlow}`,"&-active":{backgroundColor:e.defaultColor}}}}}})(r),(e=>{let{componentCls:t,iconCls:r}=e;return{[t]:{[`${t}-small&-line, ${t}-small&-line ${t}-text ${r}`]:{fontSize:e.fontSizeSM}}}})(r)]},e=>({circleTextColor:e.colorText,defaultColor:e.colorInfo,remainingColor:e.colorFillSecondary,lineBorderRadius:100,circleTextFontSize:"1em",circleIconFontSize:`${e.fontSize/e.fontSizeSM}em`}));var F=function(e,t){var r={};for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&0>t.indexOf(i)&&(r[i]=e[i]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols)for(var n=0,i=Object.getOwnPropertySymbols(e);nt.indexOf(i[n])&&Object.prototype.propertyIsEnumerable.call(e,i[n])&&(r[i[n]]=e[i[n]]);return r};let H=e=>{let{prefixCls:r,direction:i,percent:n,size:o,strokeWidth:a,strokeColor:s,strokeLinecap:c="round",children:u,trailColor:d=null,percentPosition:m,success:p}=e,{align:f,type:g}=m,h=s&&"string"!=typeof s?((e,t)=>{let{from:r=j.presetPrimaryColors.blue,to:i=j.presetPrimaryColors.blue,direction:n="rtl"===t?"to left":"to right"}=e,o=F(e,["from","to","direction"]);if(0!==Object.keys(o).length){let e,t=(e=[],Object.keys(o).forEach(t=>{let r=Number.parseFloat(t.replace(/%/g,""));Number.isNaN(r)||e.push({key:r,value:o[t]})}),(e=e.sort((e,t)=>e.key-t.key)).map(({key:e,value:t})=>`${t} ${e}%`).join(", ")),r=`linear-gradient(${n}, ${t})`;return{background:r,[L]:r}}let a=`linear-gradient(${n}, ${r}, ${i})`;return{background:a,[L]:a}})(s,i):{[L]:s,background:s},y="square"===c||"butt"===c?0:void 0,[v,b]=I(null!=o?o:[-1,a||("small"===o?6:8)],"line",{strokeWidth:a}),$=Object.assign(Object.assign({width:`${D(n)}%`,height:b,borderRadius:y},h),{[R]:D(n)/100}),S=N(e),x={width:`${D(S)}%`,height:b,borderRadius:y,backgroundColor:null==p?void 0:p.strokeColor},k=t.createElement("div",{className:`${r}-inner`,style:{backgroundColor:d||void 0,borderRadius:y}},t.createElement("div",{className:(0,l.default)(`${r}-bg`,`${r}-bg-${g}`),style:$},"inner"===g&&u),void 0!==S&&t.createElement("div",{className:`${r}-success-bg`,style:x})),C="outer"===g&&"start"===f,w="outer"===g&&"end"===f;return"outer"===g&&"center"===f?t.createElement("div",{className:`${r}-layout-bottom`},k,u):t.createElement("div",{className:`${r}-outer`,style:{width:v<0?"100%":v}},C&&u,k,w&&u)},G=e=>{let{size:r,steps:i,rounding:n=Math.round,percent:o=0,strokeWidth:a=8,strokeColor:s,trailColor:c=null,prefixCls:u,children:d}=e,m=n(o/100*i),[p,f]=I(null!=r?r:["small"===r?2:14,a],"step",{steps:i,strokeWidth:a}),g=p/i,h=Array.from({length:i});for(let e=0;et.indexOf(i)&&(r[i]=e[i]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols)for(var n=0,i=Object.getOwnPropertySymbols(e);nt.indexOf(i[n])&&Object.prototype.propertyIsEnumerable.call(e,i[n])&&(r[i[n]]=e[i[n]]);return r};let K=["normal","exception","active","success"],U=t.forwardRef((e,u)=>{let d,{prefixCls:m,className:p,rootClassName:f,steps:g,strokeColor:h,percent:y=0,size:v="default",showInfo:b=!0,type:$="line",status:S,format:x,style:k,percentPosition:C={}}=e,w=_(e,["prefixCls","className","rootClassName","steps","strokeColor","percent","size","showInfo","type","status","format","style","percentPosition"]),{align:E="end",type:O="outer"}=C,z=Array.isArray(h)?h[0]:h,j="string"==typeof h||Array.isArray(h)?h:void 0,T=t.useMemo(()=>{if(z){let e="string"==typeof z?z:Object.values(z)[0];return new r.FastColor(e).isLight()}return!1},[h]),P=t.useMemo(()=>{var t,r;let i=N(e);return Number.parseInt(void 0!==i?null==(t=null!=i?i:0)?void 0:t.toString():null==(r=null!=y?y:0)?void 0:r.toString(),10)},[y,e.success,e.successPercent]),A=t.useMemo(()=>!K.includes(S)&&P>=100?"success":S||"normal",[S,P]),{getPrefixCls:X,direction:W,progress:L}=t.useContext(c.ConfigContext),R=X("progress",m),[q,F,U]=B(R),V="line"===$,Q=V&&!g,Y=t.useMemo(()=>{let r;if(!b)return null;let s=N(e),c=x||(e=>`${e}%`),u=V&&T&&"inner"===O;return"inner"===O||x||"exception"!==A&&"success"!==A?r=c(D(y),D(s)):"exception"===A?r=V?t.createElement(o.default,null):t.createElement(a.default,null):"success"===A&&(r=V?t.createElement(i.default,null):t.createElement(n.default,null)),t.createElement("span",{className:(0,l.default)(`${R}-text`,{[`${R}-text-bright`]:u,[`${R}-text-${E}`]:Q,[`${R}-text-${O}`]:Q}),title:"string"==typeof r?r:void 0},r)},[b,y,P,A,$,R,x]);"line"===$?d=g?t.createElement(G,Object.assign({},e,{strokeColor:j,prefixCls:R,steps:"object"==typeof g?g.count:g}),Y):t.createElement(H,Object.assign({},e,{strokeColor:z,prefixCls:R,direction:W,percentPosition:{align:E,type:O}}),Y):("circle"===$||"dashboard"===$)&&(d=t.createElement(M,Object.assign({},e,{strokeColor:z,prefixCls:R,progressStatus:A}),Y));let J=(0,l.default)(R,`${R}-status-${A}`,{[`${R}-${"dashboard"===$&&"circle"||$}`]:"line"!==$,[`${R}-inline-circle`]:"circle"===$&&I(v,"circle")[0]<=20,[`${R}-line`]:Q,[`${R}-line-align-${E}`]:Q,[`${R}-line-position-${O}`]:Q,[`${R}-steps`]:g,[`${R}-show-info`]:b,[`${R}-${v}`]:"string"==typeof v,[`${R}-rtl`]:"rtl"===W},null==L?void 0:L.className,p,f,F,U);return q(t.createElement("div",Object.assign({ref:u,style:Object.assign(Object.assign({},null==L?void 0:L.style),k),className:J,role:"progressbar","aria-valuenow":P,"aria-valuemin":0,"aria-valuemax":100},(0,s.default)(w,["trailColor","strokeWidth","width","gapDegree","gapPosition","strokeLinecap","success","successPercent"])),d))});e.s(["default",0,U],309821)},955135,e=>{"use strict";var t=e.i(597440);e.s(["DeleteOutlined",()=>t.default])}]); \ No newline at end of file diff --git a/litellm/proxy/_experimental/out/_next/static/chunks/0930068a29eb5657.js b/litellm/proxy/_experimental/out/_next/static/chunks/0930068a29eb5657.js new file mode 100644 index 00000000000..b09a8f5fc18 --- /dev/null +++ b/litellm/proxy/_experimental/out/_next/static/chunks/0930068a29eb5657.js @@ -0,0 +1 @@ +(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,533882,e=>{"use strict";var t=e.i(843476),r=e.i(271645),a=e.i(250980),s=e.i(797672),l=e.i(68155),n=e.i(304967),i=e.i(629569),o=e.i(599724),c=e.i(269200),d=e.i(427612),u=e.i(64848),m=e.i(942232),x=e.i(496020),g=e.i(977572),h=e.i(992619),p=e.i(727749);e.s(["default",0,({accessToken:e,initialModelAliases:f={},onAliasUpdate:b,showExampleConfig:y=!0})=>{let[v,j]=(0,r.useState)([]),[N,w]=(0,r.useState)({aliasName:"",targetModel:""}),[k,C]=(0,r.useState)(null);(0,r.useEffect)(()=>{j(Object.entries(f).map(([e,t],r)=>({id:`${r}-${e}`,aliasName:e,targetModel:t})))},[f]);let M=()=>{if(!k)return;if(!k.aliasName||!k.targetModel)return void p.default.fromBackend("Please provide both alias name and target model");if(v.some(e=>e.id!==k.id&&e.aliasName===k.aliasName))return void p.default.fromBackend("An alias with this name already exists");let e=v.map(e=>e.id===k.id?k:e);j(e),C(null);let t={};e.forEach(e=>{t[e.aliasName]=e.targetModel}),b&&b(t),p.default.success("Alias updated successfully")},S=()=>{C(null)},T=v.reduce((e,t)=>(e[t.aliasName]=t.targetModel,e),{});return(0,t.jsxs)("div",{className:"mt-4",children:[(0,t.jsxs)("div",{className:"mb-6",children:[(0,t.jsx)(o.Text,{className:"text-sm font-medium text-gray-700 mb-2",children:"Add New Alias"}),(0,t.jsxs)("div",{className:"grid grid-cols-3 gap-4",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{className:"block text-xs text-gray-500 mb-1",children:"Alias Name"}),(0,t.jsx)("input",{type:"text",value:N.aliasName,onChange:e=>w({...N,aliasName:e.target.value}),placeholder:"e.g., gpt-4o",className:"w-full px-3 py-2 border border-gray-300 rounded-md text-sm"})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{className:"block text-xs text-gray-500 mb-1",children:"Target Model"}),(0,t.jsx)(h.default,{accessToken:e,value:N.targetModel,placeholder:"Select target model",onChange:e=>w({...N,targetModel:e}),showLabel:!1})]}),(0,t.jsx)("div",{className:"flex items-end",children:(0,t.jsxs)("button",{onClick:()=>{if(!N.aliasName||!N.targetModel)return void p.default.fromBackend("Please provide both alias name and target model");if(v.some(e=>e.aliasName===N.aliasName))return void p.default.fromBackend("An alias with this name already exists");let e=[...v,{id:`${Date.now()}-${N.aliasName}`,aliasName:N.aliasName,targetModel:N.targetModel}];j(e),w({aliasName:"",targetModel:""});let t={};e.forEach(e=>{t[e.aliasName]=e.targetModel}),b&&b(t),p.default.success("Alias added successfully")},disabled:!N.aliasName||!N.targetModel,className:`flex items-center px-4 py-2 rounded-md text-sm ${!N.aliasName||!N.targetModel?"bg-gray-300 text-gray-500 cursor-not-allowed":"bg-green-600 text-white hover:bg-green-700"}`,children:[(0,t.jsx)(a.PlusCircleIcon,{className:"w-4 h-4 mr-1"}),"Add Alias"]})})]})]}),(0,t.jsx)(o.Text,{className:"text-sm font-medium text-gray-700 mb-2",children:"Manage Existing Aliases"}),(0,t.jsx)("div",{className:"rounded-lg custom-border relative mb-6",children:(0,t.jsx)("div",{className:"overflow-x-auto",children:(0,t.jsxs)(c.Table,{className:"[&_td]:py-0.5 [&_th]:py-1",children:[(0,t.jsx)(d.TableHead,{children:(0,t.jsxs)(x.TableRow,{children:[(0,t.jsx)(u.TableHeaderCell,{className:"py-1 h-8",children:"Alias Name"}),(0,t.jsx)(u.TableHeaderCell,{className:"py-1 h-8",children:"Target Model"}),(0,t.jsx)(u.TableHeaderCell,{className:"py-1 h-8",children:"Actions"})]})}),(0,t.jsxs)(m.TableBody,{children:[v.map(r=>(0,t.jsx)(x.TableRow,{className:"h-8",children:k&&k.id===r.id?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(g.TableCell,{className:"py-0.5",children:(0,t.jsx)("input",{type:"text",value:k.aliasName,onChange:e=>C({...k,aliasName:e.target.value}),className:"w-full px-2 py-1 border border-gray-300 rounded-md text-sm"})}),(0,t.jsx)(g.TableCell,{className:"py-0.5",children:(0,t.jsx)(h.default,{accessToken:e,value:k.targetModel,onChange:e=>C({...k,targetModel:e}),showLabel:!1,style:{height:"32px"}})}),(0,t.jsx)(g.TableCell,{className:"py-0.5 whitespace-nowrap",children:(0,t.jsxs)("div",{className:"flex space-x-2",children:[(0,t.jsx)("button",{onClick:M,className:"text-xs bg-blue-50 text-blue-600 px-2 py-1 rounded hover:bg-blue-100",children:"Save"}),(0,t.jsx)("button",{onClick:S,className:"text-xs bg-gray-50 text-gray-600 px-2 py-1 rounded hover:bg-gray-100",children:"Cancel"})]})})]}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(g.TableCell,{className:"py-0.5 text-sm text-gray-900",children:r.aliasName}),(0,t.jsx)(g.TableCell,{className:"py-0.5 text-sm text-gray-500",children:r.targetModel}),(0,t.jsx)(g.TableCell,{className:"py-0.5 whitespace-nowrap",children:(0,t.jsxs)("div",{className:"flex space-x-2",children:[(0,t.jsx)("button",{onClick:()=>{C({...r})},className:"text-xs bg-blue-50 text-blue-600 px-2 py-1 rounded hover:bg-blue-100",children:(0,t.jsx)(s.PencilIcon,{className:"w-3 h-3"})}),(0,t.jsx)("button",{onClick:()=>{var e;let t,a;return e=r.id,j(t=v.filter(t=>t.id!==e)),a={},void(t.forEach(e=>{a[e.aliasName]=e.targetModel}),b&&b(a),p.default.success("Alias deleted successfully"))},className:"text-xs bg-red-50 text-red-600 px-2 py-1 rounded hover:bg-red-100",children:(0,t.jsx)(l.TrashIcon,{className:"w-3 h-3"})})]})})]})},r.id)),0===v.length&&(0,t.jsx)(x.TableRow,{children:(0,t.jsx)(g.TableCell,{colSpan:3,className:"py-0.5 text-sm text-gray-500 text-center",children:"No aliases added yet. Add a new alias above."})})]})]})})}),y&&(0,t.jsxs)(n.Card,{children:[(0,t.jsx)(i.Title,{className:"mb-4",children:"Configuration Example"}),(0,t.jsx)(o.Text,{className:"text-gray-600 mb-4",children:"Here's how your current aliases would look in the config:"}),(0,t.jsx)("div",{className:"bg-gray-100 rounded-lg p-4 font-mono text-sm",children:(0,t.jsxs)("div",{className:"text-gray-700",children:["model_aliases:",0===Object.keys(T).length?(0,t.jsxs)("span",{className:"text-gray-500",children:[(0,t.jsx)("br",{}),"  # No aliases configured yet"]}):Object.entries(T).map(([e,r])=>(0,t.jsxs)("span",{children:[(0,t.jsx)("br",{}),'  "',e,'": "',r,'"']},e))]})})]})]})}])},651904,e=>{"use strict";var t=e.i(843476),r=e.i(599724),a=e.i(266484);e.s(["default",0,function({value:e,onChange:s,premiumUser:l=!1,disabledCallbacks:n=[],onDisabledCallbacksChange:i}){return l?(0,t.jsx)(a.default,{value:e,onChange:s,disabledCallbacks:n,onDisabledCallbacksChange:i}):(0,t.jsxs)("div",{children:[(0,t.jsxs)("div",{className:"flex flex-wrap gap-2 mb-3",children:[(0,t.jsx)("div",{className:"inline-flex items-center px-3 py-1.5 rounded-lg bg-green-50 border border-green-200 text-green-800 text-sm font-medium opacity-50",children:"✨ langfuse-logging"}),(0,t.jsx)("div",{className:"inline-flex items-center px-3 py-1.5 rounded-lg bg-green-50 border border-green-200 text-green-800 text-sm font-medium opacity-50",children:"✨ datadog-logging"})]}),(0,t.jsx)("div",{className:"p-3 bg-yellow-50 border border-yellow-200 rounded-lg",children:(0,t.jsxs)(r.Text,{className:"text-sm text-yellow-800",children:["Setting Key/Team logging settings is a LiteLLM Enterprise feature. Global Logging Settings are available for all free users. Get a trial key"," ",(0,t.jsx)("a",{href:"https://www.litellm.ai/#pricing",target:"_blank",rel:"noopener noreferrer",className:"underline",children:"here"}),"."]})})]})}])},250980,e=>{"use strict";var t=e.i(271645);let r=t.forwardRef(function(e,r){return t.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:2,stroke:"currentColor","aria-hidden":"true",ref:r},e),t.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 9v3m0 0v3m0-3h3m-3 0H9m12 0a9 9 0 11-18 0 9 9 0 0118 0z"}))});e.s(["PlusCircleIcon",0,r],250980)},502547,e=>{"use strict";var t=e.i(271645);let r=t.forwardRef(function(e,r){return t.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:2,stroke:"currentColor","aria-hidden":"true",ref:r},e),t.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9 5l7 7-7 7"}))});e.s(["ChevronRightIcon",0,r],502547)},384767,e=>{"use strict";var t=e.i(843476),r=e.i(599724),a=e.i(271645),s=e.i(389083);let l=a.forwardRef(function(e,t){return a.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:2,stroke:"currentColor","aria-hidden":"true",ref:t},e),a.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M4 7v10c0 2.21 3.582 4 8 4s8-1.79 8-4V7M4 7c0 2.21 3.582 4 8 4s8-1.79 8-4M4 7c0-2.21 3.582-4 8-4s8 1.79 8 4m0 5c0 2.21-3.582 4-8 4s-8-1.79-8-4"}))});var n=e.i(764205);let i=function({vectorStores:e,accessToken:i}){let[o,c]=(0,a.useState)([]);return(0,a.useEffect)(()=>{(async()=>{if(i&&0!==e.length)try{let e=await (0,n.vectorStoreListCall)(i);e.data&&c(e.data.map(e=>({vector_store_id:e.vector_store_id,vector_store_name:e.vector_store_name})))}catch(e){console.error("Error fetching vector stores:",e)}})()},[i,e.length]),(0,t.jsxs)("div",{className:"space-y-3",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)(l,{className:"h-4 w-4 text-blue-600"}),(0,t.jsx)(r.Text,{className:"font-semibold text-gray-900",children:"Vector Stores"}),(0,t.jsx)(s.Badge,{color:"blue",size:"xs",children:e.length})]}),e.length>0?(0,t.jsx)("div",{className:"flex flex-wrap gap-2",children:e.map((e,r)=>{let a;return(0,t.jsx)("div",{className:"inline-flex items-center px-3 py-1.5 rounded-lg bg-blue-50 border border-blue-200 text-blue-800 text-sm font-medium",children:(a=o.find(t=>t.vector_store_id===e))?`${a.vector_store_name||a.vector_store_id} (${a.vector_store_id})`:e},r)})}):(0,t.jsxs)("div",{className:"flex items-center gap-2 px-3 py-2 rounded-lg bg-gray-50 border border-gray-200",children:[(0,t.jsx)(l,{className:"h-4 w-4 text-gray-400"}),(0,t.jsx)(r.Text,{className:"text-gray-500 text-sm",children:"No vector stores configured"})]})]})},o=a.forwardRef(function(e,t){return a.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:2,stroke:"currentColor","aria-hidden":"true",ref:t},e),a.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 12h14M5 12a2 2 0 01-2-2V6a2 2 0 012-2h14a2 2 0 012 2v4a2 2 0 01-2 2M5 12a2 2 0 00-2 2v4a2 2 0 002 2h14a2 2 0 002-2v-4a2 2 0 00-2-2m-2-4h.01M17 16h.01"}))});var c=e.i(871943),d=e.i(502547),u=e.i(592968);let m=function({mcpServers:l,mcpAccessGroups:i=[],mcpToolPermissions:m={},accessToken:x}){let[g,h]=(0,a.useState)([]),[p,f]=(0,a.useState)([]),[b,y]=(0,a.useState)(new Set);(0,a.useEffect)(()=>{(async()=>{if(x&&l.length>0)try{let e=await (0,n.fetchMCPServers)(x);e&&Array.isArray(e)?h(e):e.data&&Array.isArray(e.data)&&h(e.data)}catch(e){console.error("Error fetching MCP servers:",e)}})()},[x,l.length]),(0,a.useEffect)(()=>{(async()=>{if(x&&i.length>0)try{let t=await e.A(601236).then(e=>e.fetchMCPAccessGroups(x));f(Array.isArray(t)?t:t.data||[])}catch(e){console.error("Error fetching MCP access groups:",e)}})()},[x,i.length]);let v=[...l.map(e=>({type:"server",value:e})),...i.map(e=>({type:"accessGroup",value:e}))],j=v.length;return(0,t.jsxs)("div",{className:"space-y-3",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)(o,{className:"h-4 w-4 text-blue-600"}),(0,t.jsx)(r.Text,{className:"font-semibold text-gray-900",children:"MCP Servers"}),(0,t.jsx)(s.Badge,{color:"blue",size:"xs",children:j})]}),j>0?(0,t.jsx)("div",{className:"max-h-[400px] overflow-y-auto space-y-2 pr-1",children:v.map((e,r)=>{let a="server"===e.type?m[e.value]:void 0,s=a&&a.length>0,l=b.has(e.value);return(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsxs)("div",{onClick:()=>{var t;return s&&(t=e.value,void y(e=>{let r=new Set(e);return r.has(t)?r.delete(t):r.add(t),r}))},className:`flex items-center gap-3 py-2 px-3 rounded-lg border border-gray-200 transition-all ${s?"cursor-pointer hover:bg-gray-50 hover:border-gray-300":"bg-white"}`,children:[(0,t.jsx)("div",{className:"flex items-center gap-2 flex-1 min-w-0",children:"server"===e.type?(0,t.jsx)(u.Tooltip,{title:`Full ID: ${e.value}`,placement:"top",children:(0,t.jsxs)("div",{className:"inline-flex items-center gap-2 min-w-0",children:[(0,t.jsx)("span",{className:"inline-block w-1.5 h-1.5 bg-blue-500 rounded-full flex-shrink-0"}),(0,t.jsx)("span",{className:"text-sm font-medium text-gray-900 truncate",children:(e=>{let t=g.find(t=>t.server_id===e);if(t){let r=e.length>7?`${e.slice(0,3)}...${e.slice(-4)}`:e;return`${t.alias} (${r})`}return e})(e.value)})]})}):(0,t.jsxs)("div",{className:"inline-flex items-center gap-2 min-w-0",children:[(0,t.jsx)("span",{className:"inline-block w-1.5 h-1.5 bg-green-500 rounded-full flex-shrink-0"}),(0,t.jsx)("span",{className:"text-sm font-medium text-gray-900 truncate",children:e.value}),(0,t.jsx)("span",{className:"ml-1 px-1.5 py-0.5 text-[9px] font-semibold text-green-600 bg-green-50 border border-green-200 rounded uppercase tracking-wide flex-shrink-0",children:"Group"})]})}),s&&(0,t.jsxs)("div",{className:"flex items-center gap-1 flex-shrink-0 whitespace-nowrap",children:[(0,t.jsx)("span",{className:"text-xs font-medium text-gray-600",children:a.length}),(0,t.jsx)("span",{className:"text-xs text-gray-500",children:1===a.length?"tool":"tools"}),l?(0,t.jsx)(c.ChevronDownIcon,{className:"h-3.5 w-3.5 text-gray-400 ml-0.5"}):(0,t.jsx)(d.ChevronRightIcon,{className:"h-3.5 w-3.5 text-gray-400 ml-0.5"})]})]}),s&&l&&(0,t.jsx)("div",{className:"ml-4 pl-4 border-l-2 border-blue-200 pb-1",children:(0,t.jsx)("div",{className:"flex flex-wrap gap-1.5",children:a.map((e,r)=>(0,t.jsx)("span",{className:"inline-flex items-center px-2.5 py-1 rounded-lg bg-blue-50 border border-blue-200 text-blue-800 text-xs font-medium",children:e},r))})})]},r)})}):(0,t.jsxs)("div",{className:"flex items-center gap-2 px-3 py-2 rounded-lg bg-gray-50 border border-gray-200",children:[(0,t.jsx)(o,{className:"h-4 w-4 text-gray-400"}),(0,t.jsx)(r.Text,{className:"text-gray-500 text-sm",children:"No MCP servers or access groups configured"})]})]})},x=a.forwardRef(function(e,t){return a.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:2,stroke:"currentColor","aria-hidden":"true",ref:t},e),a.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M17 20h5v-2a3 3 0 00-5.356-1.857M17 20H7m10 0v-2c0-.656-.126-1.283-.356-1.857M7 20H2v-2a3 3 0 015.356-1.857M7 20v-2c0-.656.126-1.283.356-1.857m0 0a5.002 5.002 0 019.288 0M15 7a3 3 0 11-6 0 3 3 0 016 0zm6 3a2 2 0 11-4 0 2 2 0 014 0zM7 10a2 2 0 11-4 0 2 2 0 014 0z"}))}),g=function({agents:e,agentAccessGroups:l=[],accessToken:i}){let[o,c]=(0,a.useState)([]);(0,a.useEffect)(()=>{(async()=>{if(i&&e.length>0)try{let e=await (0,n.getAgentsList)(i);e&&e.agents&&Array.isArray(e.agents)&&c(e.agents)}catch(e){console.error("Error fetching agents:",e)}})()},[i,e.length]);let d=[...e.map(e=>({type:"agent",value:e})),...l.map(e=>({type:"accessGroup",value:e}))],m=d.length;return(0,t.jsxs)("div",{className:"space-y-3",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)(x,{className:"h-4 w-4 text-purple-600"}),(0,t.jsx)(r.Text,{className:"font-semibold text-gray-900",children:"Agents"}),(0,t.jsx)(s.Badge,{color:"purple",size:"xs",children:m})]}),m>0?(0,t.jsx)("div",{className:"max-h-[400px] overflow-y-auto space-y-2 pr-1",children:d.map((e,r)=>(0,t.jsx)("div",{className:"space-y-2",children:(0,t.jsx)("div",{className:"flex items-center gap-3 py-2 px-3 rounded-lg border border-gray-200 bg-white",children:(0,t.jsx)("div",{className:"flex items-center gap-2 flex-1 min-w-0",children:"agent"===e.type?(0,t.jsx)(u.Tooltip,{title:`Full ID: ${e.value}`,placement:"top",children:(0,t.jsxs)("div",{className:"inline-flex items-center gap-2 min-w-0",children:[(0,t.jsx)("span",{className:"inline-block w-1.5 h-1.5 bg-purple-500 rounded-full flex-shrink-0"}),(0,t.jsx)("span",{className:"text-sm font-medium text-gray-900 truncate",children:(e=>{let t=o.find(t=>t.agent_id===e);if(t){let r=e.length>7?`${e.slice(0,3)}...${e.slice(-4)}`:e;return`${t.agent_name} (${r})`}return e})(e.value)})]})}):(0,t.jsxs)("div",{className:"inline-flex items-center gap-2 min-w-0",children:[(0,t.jsx)("span",{className:"inline-block w-1.5 h-1.5 bg-green-500 rounded-full flex-shrink-0"}),(0,t.jsx)("span",{className:"text-sm font-medium text-gray-900 truncate",children:e.value}),(0,t.jsx)("span",{className:"ml-1 px-1.5 py-0.5 text-[9px] font-semibold text-green-600 bg-green-50 border border-green-200 rounded uppercase tracking-wide flex-shrink-0",children:"Group"})]})})})},r))}):(0,t.jsxs)("div",{className:"flex items-center gap-2 px-3 py-2 rounded-lg bg-gray-50 border border-gray-200",children:[(0,t.jsx)(x,{className:"h-4 w-4 text-gray-400"}),(0,t.jsx)(r.Text,{className:"text-gray-500 text-sm",children:"No agents or access groups configured"})]})]})};e.s(["default",0,function({objectPermission:e,variant:a="card",className:s="",accessToken:l}){let n=e?.vector_stores||[],o=e?.mcp_servers||[],c=e?.mcp_access_groups||[],d=e?.mcp_tool_permissions||{},u=e?.agents||[],x=e?.agent_access_groups||[],h=(0,t.jsxs)("div",{className:"card"===a?"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6":"space-y-4",children:[(0,t.jsx)(i,{vectorStores:n,accessToken:l}),(0,t.jsx)(m,{mcpServers:o,mcpAccessGroups:c,mcpToolPermissions:d,accessToken:l}),(0,t.jsx)(g,{agents:u,agentAccessGroups:x,accessToken:l})]});return"card"===a?(0,t.jsxs)("div",{className:`bg-white border border-gray-200 rounded-lg p-6 ${s}`,children:[(0,t.jsx)("div",{className:"flex items-center gap-2 mb-6",children:(0,t.jsxs)("div",{children:[(0,t.jsx)(r.Text,{className:"font-semibold text-gray-900",children:"Object Permissions"}),(0,t.jsx)(r.Text,{className:"text-xs text-gray-500",children:"Access control for Vector Stores and MCP Servers"})]})}),h]}):(0,t.jsxs)("div",{className:`${s}`,children:[(0,t.jsx)(r.Text,{className:"font-medium text-gray-900 mb-3",children:"Object Permissions"}),h]})}],384767)},91739,e=>{"use strict";var t=e.i(544195);e.s(["Radio",()=>t.default])},737434,e=>{"use strict";var t=e.i(184163);e.s(["DownloadOutlined",()=>t.default])},964306,e=>{"use strict";var t=e.i(271645);let r=t.forwardRef(function(e,r){return t.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:2,stroke:"currentColor","aria-hidden":"true",ref:r},e),t.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M10 14l2-2m0 0l2-2m-2 2l-2-2m2 2l2 2m7-2a9 9 0 11-18 0 9 9 0 0118 0z"}))});e.s(["XCircleIcon",0,r],964306)},743151,(e,t,r)=>{"use strict";function a(e){return(a="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}Object.defineProperty(r,"__esModule",{value:!0}),r.CopyToClipboard=void 0;var s=i(e.r(271645)),l=i(e.r(844343)),n=["text","onCopy","options","children"];function i(e){return e&&e.__esModule?e:{default:e}}function o(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,a)}return r}function c(e){for(var t=1;t=0||(s[r]=e[r]);return s}(e,t);if(Object.getOwnPropertySymbols){var l=Object.getOwnPropertySymbols(e);for(a=0;a=0)&&Object.prototype.propertyIsEnumerable.call(e,r)&&(s[r]=e[r])}return s}(e,n),a=s.default.Children.only(t);return s.default.cloneElement(a,c(c({},r),{},{onClick:this.onClick}))}}],function(e,t){for(var r=0;r{"use strict";var a=e.r(743151).CopyToClipboard;a.CopyToClipboard=a,t.exports=a},653496,e=>{"use strict";var t=e.i(721369);e.s(["Tabs",()=>t.default])},689020,e=>{"use strict";var t=e.i(764205);let r=async e=>{try{let r=await (0,t.modelHubCall)(e);if(console.log("model_info:",r),r?.data.length>0){let e=r.data.map(e=>({model_group:e.model_group,mode:e?.mode}));return e.sort((e,t)=>e.model_group.localeCompare(t.model_group)),e}return[]}catch(e){throw console.error("Error fetching model info:",e),e}};e.s(["fetchAvailableModels",0,r])},983561,e=>{"use strict";e.i(247167);var t=e.i(931067),r=e.i(271645);let a={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M300 328a60 60 0 10120 0 60 60 0 10-120 0zM852 64H172c-17.7 0-32 14.3-32 32v660c0 17.7 14.3 32 32 32h680c17.7 0 32-14.3 32-32V96c0-17.7-14.3-32-32-32zm-32 660H204V128h616v596zM604 328a60 60 0 10120 0 60 60 0 10-120 0zm250.2 556H169.8c-16.5 0-29.8 14.3-29.8 32v36c0 4.4 3.3 8 7.4 8h729.1c4.1 0 7.4-3.6 7.4-8v-36c.1-17.7-13.2-32-29.7-32zM664 508H360c-4.4 0-8 3.6-8 8v60c0 4.4 3.6 8 8 8h304c4.4 0 8-3.6 8-8v-60c0-4.4-3.6-8-8-8z"}}]},name:"robot",theme:"outlined"};var s=e.i(9583),l=r.forwardRef(function(e,l){return r.createElement(s.default,(0,t.default)({},e,{ref:l,icon:a}))});e.s(["RobotOutlined",0,l],983561)},992619,e=>{"use strict";var t=e.i(843476),r=e.i(271645),a=e.i(779241),s=e.i(599724),l=e.i(199133),n=e.i(983561),i=e.i(689020);e.s(["default",0,({accessToken:e,value:o,placeholder:c="Select a Model",onChange:d,disabled:u=!1,style:m,className:x,showLabel:g=!0,labelText:h="Select Model"})=>{let[p,f]=(0,r.useState)(o),[b,y]=(0,r.useState)(!1),[v,j]=(0,r.useState)([]),N=(0,r.useRef)(null);return(0,r.useEffect)(()=>{f(o)},[o]),(0,r.useEffect)(()=>{e&&(async()=>{try{let t=await (0,i.fetchAvailableModels)(e);console.log("Fetched models for selector:",t),t.length>0&&j(t)}catch(e){console.error("Error fetching model info:",e)}})()},[e]),(0,t.jsxs)("div",{children:[g&&(0,t.jsxs)(s.Text,{className:"font-medium block mb-2 text-gray-700 flex items-center",children:[(0,t.jsx)(n.RobotOutlined,{className:"mr-2"})," ",h]}),(0,t.jsx)(l.Select,{value:p,placeholder:c,onChange:e=>{"custom"===e?(y(!0),f(void 0)):(y(!1),f(e),d&&d(e))},options:[...Array.from(new Set(v.map(e=>e.model_group))).map((e,t)=>({value:e,label:e,key:t})),{value:"custom",label:"Enter custom model",key:"custom"}],style:{width:"100%",...m},showSearch:!0,className:`rounded-md ${x||""}`,disabled:u}),b&&(0,t.jsx)(a.TextInput,{className:"mt-2",placeholder:"Enter custom model name",onValueChange:e=>{N.current&&clearTimeout(N.current),N.current=setTimeout(()=>{f(e),d&&d(e)},500)},disabled:u})]})}])},220508,e=>{"use strict";var t=e.i(271645);let r=t.forwardRef(function(e,r){return t.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:2,stroke:"currentColor","aria-hidden":"true",ref:r},e),t.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z"}))});e.s(["CheckCircleIcon",0,r],220508)},793130,e=>{"use strict";var t=e.i(290571),r=e.i(429427),a=e.i(371330),s=e.i(271645),l=e.i(394487),n=e.i(503269),i=e.i(214520),o=e.i(746725),c=e.i(914189),d=e.i(144279),u=e.i(294316),m=e.i(601893),x=e.i(140721),g=e.i(942803),h=e.i(233538),p=e.i(694421),f=e.i(700020),b=e.i(35889),y=e.i(998348),v=e.i(722678);let j=(0,s.createContext)(null);j.displayName="GroupContext";let N=s.Fragment,w=Object.assign((0,f.forwardRefWithAs)(function(e,t){var N;let w=(0,s.useId)(),k=(0,g.useProvidedId)(),C=(0,m.useDisabled)(),{id:M=k||`headlessui-switch-${w}`,disabled:S=C||!1,checked:T,defaultChecked:_,onChange:E,name:O,value:P,form:R,autoFocus:A=!1,...L}=e,F=(0,s.useContext)(j),[D,$]=(0,s.useState)(null),B=(0,s.useRef)(null),I=(0,u.useSyncRefs)(B,t,null===F?null:F.setSwitch,$),z=(0,i.useDefaultValue)(_),[H,G]=(0,n.useControllable)(T,E,null!=z&&z),V=(0,o.useDisposables)(),[K,W]=(0,s.useState)(!1),q=(0,c.useEvent)(()=>{W(!0),null==G||G(!H),V.nextFrame(()=>{W(!1)})}),U=(0,c.useEvent)(e=>{if((0,h.isDisabledReactIssue7711)(e.currentTarget))return e.preventDefault();e.preventDefault(),q()}),X=(0,c.useEvent)(e=>{e.key===y.Keys.Space?(e.preventDefault(),q()):e.key===y.Keys.Enter&&(0,p.attemptSubmit)(e.currentTarget)}),J=(0,c.useEvent)(e=>e.preventDefault()),Y=(0,v.useLabelledBy)(),Q=(0,b.useDescribedBy)(),{isFocusVisible:Z,focusProps:ee}=(0,r.useFocusRing)({autoFocus:A}),{isHovered:et,hoverProps:er}=(0,a.useHover)({isDisabled:S}),{pressed:ea,pressProps:es}=(0,l.useActivePress)({disabled:S}),el=(0,s.useMemo)(()=>({checked:H,disabled:S,hover:et,focus:Z,active:ea,autofocus:A,changing:K}),[H,et,Z,ea,S,K,A]),en=(0,f.mergeProps)({id:M,ref:I,role:"switch",type:(0,d.useResolveButtonType)(e,D),tabIndex:-1===e.tabIndex?0:null!=(N=e.tabIndex)?N:0,"aria-checked":H,"aria-labelledby":Y,"aria-describedby":Q,disabled:S||void 0,autoFocus:A,onClick:U,onKeyUp:X,onKeyPress:J},ee,er,es),ei=(0,s.useCallback)(()=>{if(void 0!==z)return null==G?void 0:G(z)},[G,z]),eo=(0,f.useRender)();return s.default.createElement(s.default.Fragment,null,null!=O&&s.default.createElement(x.FormFields,{disabled:S,data:{[O]:P||"on"},overrides:{type:"checkbox",checked:H},form:R,onReset:ei}),eo({ourProps:en,theirProps:L,slot:el,defaultTag:"button",name:"Switch"}))}),{Group:function(e){var t;let[r,a]=(0,s.useState)(null),[l,n]=(0,v.useLabels)(),[i,o]=(0,b.useDescriptions)(),c=(0,s.useMemo)(()=>({switch:r,setSwitch:a}),[r,a]),d=(0,f.useRender)();return s.default.createElement(o,{name:"Switch.Description",value:i},s.default.createElement(n,{name:"Switch.Label",value:l,props:{htmlFor:null==(t=c.switch)?void 0:t.id,onClick(e){r&&(e.currentTarget instanceof HTMLLabelElement&&e.preventDefault(),r.click(),r.focus({preventScroll:!0}))}}},s.default.createElement(j.Provider,{value:c},d({ourProps:{},theirProps:e,slot:{},defaultTag:N,name:"Switch.Group"}))))},Label:v.Label,Description:b.Description});var k=e.i(888288),C=e.i(95779),M=e.i(444755),S=e.i(673706),T=e.i(829087);let _=(0,S.makeClassName)("Switch"),E=s.default.forwardRef((e,r)=>{let{checked:a,defaultChecked:l=!1,onChange:n,color:i,name:o,error:c,errorMessage:d,disabled:u,required:m,tooltip:x,id:g}=e,h=(0,t.__rest)(e,["checked","defaultChecked","onChange","color","name","error","errorMessage","disabled","required","tooltip","id"]),p={bgColor:i?(0,S.getColorClassNames)(i,C.colorPalette.background).bgColor:"bg-tremor-brand dark:bg-dark-tremor-brand",ringColor:i?(0,S.getColorClassNames)(i,C.colorPalette.ring).ringColor:"ring-tremor-brand-muted dark:ring-dark-tremor-brand-muted"},[f,b]=(0,k.default)(l,a),[y,v]=(0,s.useState)(!1),{tooltipProps:j,getReferenceProps:N}=(0,T.useTooltip)(300);return s.default.createElement("div",{className:"flex flex-row items-center justify-start"},s.default.createElement(T.default,Object.assign({text:x},j)),s.default.createElement("div",Object.assign({ref:(0,S.mergeRefs)([r,j.refs.setReference]),className:(0,M.tremorTwMerge)(_("root"),"flex flex-row relative h-5")},h,N),s.default.createElement("input",{type:"checkbox",className:(0,M.tremorTwMerge)(_("input"),"absolute w-5 h-5 cursor-pointer left-0 top-0 opacity-0"),name:o,required:m,checked:f,onChange:e=>{e.preventDefault()}}),s.default.createElement(w,{checked:f,onChange:e=>{b(e),null==n||n(e)},disabled:u,className:(0,M.tremorTwMerge)(_("switch"),"w-10 h-5 group relative inline-flex shrink-0 cursor-pointer items-center justify-center rounded-tremor-full","focus:outline-none",u?"cursor-not-allowed":""),onFocus:()=>v(!0),onBlur:()=>v(!1),id:g},s.default.createElement("span",{className:(0,M.tremorTwMerge)(_("sr-only"),"sr-only")},"Switch ",f?"on":"off"),s.default.createElement("span",{"aria-hidden":"true",className:(0,M.tremorTwMerge)(_("background"),f?p.bgColor:"bg-tremor-border dark:bg-dark-tremor-border","pointer-events-none absolute mx-auto h-3 w-9 rounded-tremor-full transition-colors duration-100 ease-in-out")}),s.default.createElement("span",{"aria-hidden":"true",className:(0,M.tremorTwMerge)(_("round"),f?(0,M.tremorTwMerge)(p.bgColor,"translate-x-5 border-tremor-background dark:border-dark-tremor-background"):"translate-x-0 bg-tremor-border dark:bg-dark-tremor-border border-tremor-background dark:border-dark-tremor-background","pointer-events-none absolute left-0 inline-block h-5 w-5 transform rounded-tremor-full border-2 shadow-tremor-input duration-100 ease-in-out transition",y?(0,M.tremorTwMerge)("ring-2",p.ringColor):"")}))),c&&d?s.default.createElement("p",{className:(0,M.tremorTwMerge)(_("errorMessage"),"text-sm text-red-500 mt-1 ")},d):null)});E.displayName="Switch",e.s(["Switch",()=>E],793130)},37727,e=>{"use strict";var t=e.i(841947);e.s(["X",()=>t.default])},603908,e=>{"use strict";let t=(0,e.i(475254).default)("plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]);e.s(["default",()=>t])},158392,419470,e=>{"use strict";var t=e.i(843476),r=e.i(779241);let a={ttl:3600,lowest_latency_buffer:0},s=({routingStrategyArgs:e})=>{let s={ttl:"Sliding window to look back over when calculating the average latency of a deployment. Default - 1 hour (in seconds).",lowest_latency_buffer:"Shuffle between deployments within this % of the lowest latency. Default - 0 (i.e. always pick lowest latency)."};return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("div",{className:"space-y-6",children:[(0,t.jsxs)("div",{className:"max-w-3xl",children:[(0,t.jsx)("h3",{className:"text-sm font-medium text-gray-900",children:"Latency-Based Configuration"}),(0,t.jsx)("p",{className:"text-xs text-gray-500 mt-1",children:"Fine-tune latency-based routing behavior"})]}),(0,t.jsx)("div",{className:"grid grid-cols-1 gap-6 lg:grid-cols-2 xl:grid-cols-3",children:Object.entries(e||a).map(([e,a])=>(0,t.jsx)("div",{className:"space-y-2",children:(0,t.jsxs)("label",{className:"block",children:[(0,t.jsx)("span",{className:"text-xs font-medium text-gray-700 uppercase tracking-wide",children:e.replace(/_/g," ")}),(0,t.jsx)("p",{className:"text-xs text-gray-500 mt-0.5 mb-2",children:s[e]||""}),(0,t.jsx)(r.TextInput,{name:e,defaultValue:"object"==typeof a?JSON.stringify(a,null,2):a?.toString(),className:"font-mono text-sm w-full"})]})},e))})]}),(0,t.jsx)("div",{className:"border-t border-gray-200"})]})},l=({routerSettings:e,routerFieldsMetadata:a})=>(0,t.jsxs)("div",{className:"space-y-6",children:[(0,t.jsxs)("div",{className:"max-w-3xl",children:[(0,t.jsx)("h3",{className:"text-sm font-medium text-gray-900",children:"Reliability & Retries"}),(0,t.jsx)("p",{className:"text-xs text-gray-500 mt-1",children:"Configure retry logic and failure handling"})]}),(0,t.jsx)("div",{className:"grid grid-cols-1 gap-6 lg:grid-cols-2 xl:grid-cols-3",children:Object.entries(e).filter(([e,t])=>"fallbacks"!=e&&"context_window_fallbacks"!=e&&"routing_strategy_args"!=e&&"routing_strategy"!=e&&"enable_tag_filtering"!=e).map(([e,s])=>(0,t.jsx)("div",{className:"space-y-2",children:(0,t.jsxs)("label",{className:"block",children:[(0,t.jsx)("span",{className:"text-xs font-medium text-gray-700 uppercase tracking-wide",children:a[e]?.ui_field_name||e}),(0,t.jsx)("p",{className:"text-xs text-gray-500 mt-0.5 mb-2",children:a[e]?.field_description||""}),(0,t.jsx)(r.TextInput,{name:e,defaultValue:null==s||"null"===s?"":"object"==typeof s?JSON.stringify(s,null,2):s?.toString()||"",placeholder:"—",className:"font-mono text-sm w-full"})]})},e))})]});var n=e.i(199133);let i=({selectedStrategy:e,availableStrategies:r,routingStrategyDescriptions:a,routerFieldsMetadata:s,onStrategyChange:l})=>(0,t.jsxs)("div",{className:"space-y-2 max-w-3xl",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{className:"text-xs font-medium text-gray-700 uppercase tracking-wide",children:s.routing_strategy?.ui_field_name||"Routing Strategy"}),(0,t.jsx)("p",{className:"text-xs text-gray-500 mt-0.5 mb-2",children:s.routing_strategy?.field_description||""})]}),(0,t.jsx)("div",{className:"routing-strategy-select max-w-3xl",children:(0,t.jsx)(n.Select,{value:e,onChange:l,style:{width:"100%"},size:"large",children:r.map(e=>(0,t.jsx)(n.Select.Option,{value:e,label:e,children:(0,t.jsxs)("div",{className:"flex flex-col gap-0.5 py-1",children:[(0,t.jsx)("span",{className:"font-mono text-sm font-medium",children:e}),a[e]&&(0,t.jsx)("span",{className:"text-xs text-gray-500 font-normal",children:a[e]})]})},e))})})]});var o=e.i(793130);let c=({enabled:e,routerFieldsMetadata:r,onToggle:a})=>(0,t.jsx)("div",{className:"space-y-3 max-w-3xl",children:(0,t.jsxs)("div",{className:"flex items-start justify-between",children:[(0,t.jsxs)("div",{className:"flex-1",children:[(0,t.jsx)("label",{className:"text-xs font-medium text-gray-700 uppercase tracking-wide",children:r.enable_tag_filtering?.ui_field_name||"Enable Tag Filtering"}),(0,t.jsxs)("p",{className:"text-xs text-gray-500 mt-0.5",children:[r.enable_tag_filtering?.field_description||"",r.enable_tag_filtering?.link&&(0,t.jsxs)(t.Fragment,{children:[" ",(0,t.jsx)("a",{href:r.enable_tag_filtering.link,target:"_blank",rel:"noopener noreferrer",className:"text-blue-600 hover:text-blue-800 underline",children:"Learn more"})]})]})]}),(0,t.jsx)(o.Switch,{checked:e,onChange:a,className:"ml-4"})]})});e.s(["default",0,({value:e,onChange:r,routerFieldsMetadata:a,availableRoutingStrategies:n,routingStrategyDescriptions:o})=>(0,t.jsxs)("div",{className:"w-full space-y-8 py-2",children:[(0,t.jsxs)("div",{className:"space-y-6",children:[(0,t.jsxs)("div",{className:"max-w-3xl",children:[(0,t.jsx)("h3",{className:"text-sm font-medium text-gray-900",children:"Routing Settings"}),(0,t.jsx)("p",{className:"text-xs text-gray-500 mt-1",children:"Configure how requests are routed to deployments"})]}),n.length>0&&(0,t.jsx)(i,{selectedStrategy:e.selectedStrategy||e.routerSettings.routing_strategy||null,availableStrategies:n,routingStrategyDescriptions:o,routerFieldsMetadata:a,onStrategyChange:t=>{r({...e,selectedStrategy:t})}}),(0,t.jsx)(c,{enabled:e.enableTagFiltering,routerFieldsMetadata:a,onToggle:t=>{r({...e,enableTagFiltering:t})}})]}),(0,t.jsx)("div",{className:"border-t border-gray-200"}),"latency-based-routing"===e.selectedStrategy&&(0,t.jsx)(s,{routingStrategyArgs:e.routerSettings.routing_strategy_args}),(0,t.jsx)(l,{routerSettings:e.routerSettings,routerFieldsMetadata:a})]})],158392);var d=e.i(994388),u=e.i(998573),m=e.i(653496),x=e.i(603908),x=x,g=e.i(271645),h=e.i(592968),p=e.i(475254);let f=(0,p.default)("circle-alert",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]]),b=(0,p.default)("arrow-down",[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]]);var y=e.i(37727);function v({group:e,onChange:r,availableModels:a,maxFallbacks:s}){let l=a.filter(t=>t!==e.primaryModel),i=e.fallbackModels.length{let a=[...e.fallbackModels];a.includes(t)&&(a=a.filter(e=>e!==t)),r({...e,primaryModel:t,fallbackModels:a})},showSearch:!0,filterOption:(e,t)=>(t?.label??"").toLowerCase().includes(e.toLowerCase()),options:a.map(e=>({label:e,value:e}))}),!e.primaryModel&&(0,t.jsxs)("div",{className:"mt-2 flex items-center gap-2 text-amber-600 text-xs bg-amber-50 p-2 rounded",children:[(0,t.jsx)(f,{className:"w-4 h-4"}),(0,t.jsx)("span",{children:"Select a model to begin configuring fallbacks"})]})]}),(0,t.jsx)("div",{className:"flex items-center justify-center -my-4 z-10",children:(0,t.jsxs)("div",{className:"bg-indigo-50 text-indigo-500 px-4 py-1 rounded-full text-xs font-bold border border-indigo-100 flex items-center gap-2 shadow-sm",children:[(0,t.jsx)(b,{className:"w-4 h-4"}),"IF FAILS, TRY..."]})}),(0,t.jsxs)("div",{className:`transition-opacity duration-300 ${!e.primaryModel?"opacity-50 pointer-events-none":"opacity-100"}`,children:[(0,t.jsxs)("label",{className:"block text-sm font-semibold text-gray-700 mb-2",children:["Fallback Chain ",(0,t.jsx)("span",{className:"text-red-500",children:"*"}),(0,t.jsxs)("span",{className:"text-xs text-gray-500 font-normal ml-2",children:["(Max ",s," fallbacks at a time)"]})]}),(0,t.jsxs)("div",{className:"bg-gray-50 rounded-xl p-4 border border-gray-200",children:[(0,t.jsxs)("div",{className:"mb-4",children:[(0,t.jsx)(n.Select,{mode:"multiple",className:"w-full",size:"large",placeholder:i?"Select fallback models to add...":`Maximum ${s} fallbacks reached`,value:e.fallbackModels,onChange:t=>{let a=t.slice(0,s);r({...e,fallbackModels:a})},disabled:!e.primaryModel,options:l.map(e=>({label:e,value:e})),optionRender:(r,a)=>{let s=e.fallbackModels.includes(r.value),l=s?e.fallbackModels.indexOf(r.value)+1:null;return(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[s&&null!==l&&(0,t.jsx)("span",{className:"flex items-center justify-center w-5 h-5 rounded bg-indigo-100 text-indigo-600 text-xs font-bold",children:l}),(0,t.jsx)("span",{children:r.label})]})},maxTagCount:"responsive",maxTagPlaceholder:e=>(0,t.jsx)(h.Tooltip,{styles:{root:{pointerEvents:"none"}},title:e.map(({value:e})=>e).join(", "),children:(0,t.jsxs)("span",{children:["+",e.length," more"]})}),showSearch:!0,filterOption:(e,t)=>(t?.label??"").toLowerCase().includes(e.toLowerCase())}),(0,t.jsx)("p",{className:"text-xs text-gray-500 mt-1 ml-1",children:i?`Search and select multiple models. Selected models will appear below in order. (${e.fallbackModels.length}/${s} used)`:`Maximum ${s} fallbacks reached. Remove some to add more.`})]}),(0,t.jsx)("div",{className:"space-y-2 min-h-[100px]",children:0===e.fallbackModels.length?(0,t.jsxs)("div",{className:"h-32 border-2 border-dashed border-gray-300 rounded-lg flex flex-col items-center justify-center text-gray-400",children:[(0,t.jsx)("span",{className:"text-sm",children:"No fallback models selected"}),(0,t.jsx)("span",{className:"text-xs mt-1",children:"Add models from the dropdown above"})]}):e.fallbackModels.map((a,s)=>(0,t.jsxs)("div",{className:"group flex items-center justify-between p-3 bg-white rounded-lg border border-gray-200 hover:border-indigo-300 hover:shadow-sm transition-all",children:[(0,t.jsxs)("div",{className:"flex items-center gap-3",children:[(0,t.jsx)("div",{className:"flex items-center justify-center w-6 h-6 rounded bg-gray-100 text-gray-400 group-hover:text-indigo-500 group-hover:bg-indigo-50",children:(0,t.jsx)("span",{className:"text-xs font-bold",children:s+1})}),(0,t.jsx)("div",{children:(0,t.jsx)("span",{className:"font-medium text-gray-800",children:a})})]}),(0,t.jsx)("button",{type:"button",onClick:()=>{let t;return t=e.fallbackModels.filter((e,t)=>t!==s),void r({...e,fallbackModels:t})},className:"opacity-0 group-hover:opacity-100 transition-opacity text-gray-400 hover:text-red-500 p-1",children:(0,t.jsx)(y.X,{className:"w-4 h-4"})})]},`${a}-${s}`))})]})]})]})}function j({groups:e,onGroupsChange:r,availableModels:a,maxFallbacks:s=5,maxGroups:l=5}){let[n,i]=(0,g.useState)(e.length>0?e[0].id:"1");(0,g.useEffect)(()=>{e.length>0?e.some(e=>e.id===n)||i(e[0].id):i("1")},[e]);let o=()=>{if(e.length>=l)return;let t=Date.now().toString();r([...e,{id:t,primaryModel:null,fallbackModels:[]}]),i(t)},c=t=>{r(e.map(e=>e.id===t.id?t:e))},h=e.map((r,l)=>{let n=r.primaryModel?r.primaryModel:`Group ${l+1}`;return{key:r.id,label:n,closable:e.length>1,children:(0,t.jsx)(v,{group:r,onChange:c,availableModels:a,maxFallbacks:s})}});return 0===e.length?(0,t.jsxs)("div",{className:"text-center py-12 bg-gray-50 rounded-lg border border-dashed border-gray-300",children:[(0,t.jsx)("p",{className:"text-gray-500 mb-4",children:"No fallback groups configured"}),(0,t.jsx)(d.Button,{variant:"primary",onClick:o,icon:()=>(0,t.jsx)(x.default,{className:"w-4 h-4"}),children:"Create First Group"})]}):(0,t.jsx)(m.Tabs,{type:"editable-card",activeKey:n,onChange:i,onEdit:(t,a)=>{"add"===a?o():"remove"===a&&e.length>1&&(t=>{if(1===e.length)return u.message.warning("At least one group is required");let a=e.filter(e=>e.id!==t);r(a),n===t&&a.length>0&&i(a[a.length-1].id)})(t)},items:h,className:"fallback-tabs",tabBarStyle:{marginBottom:0},hideAdd:e.length>=l})}e.s(["FallbackSelectionForm",()=>j],419470)}]); \ No newline at end of file diff --git a/litellm/proxy/_experimental/out/_next/static/chunks/0a65da2cd24e2ab6.js b/litellm/proxy/_experimental/out/_next/static/chunks/0a65da2cd24e2ab6.js new file mode 100644 index 00000000000..0bb6bef6dc3 --- /dev/null +++ b/litellm/proxy/_experimental/out/_next/static/chunks/0a65da2cd24e2ab6.js @@ -0,0 +1,3 @@ +(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,621642,25080,e=>{"use strict";var t=e.i(290571),r=e.i(271645),n=e.i(144582),a=e.i(888288),o=e.i(757440);let l=e=>{var n=(0,t.__rest)(e,[]);return r.default.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor"},n),r.default.createElement("path",{d:"M18.031 16.6168L22.3137 20.8995L20.8995 22.3137L16.6168 18.031C15.0769 19.263 13.124 20 11 20C6.032 20 2 15.968 2 11C2 6.032 6.032 2 11 2C15.968 2 20 6.032 20 11C20 13.124 19.263 15.0769 18.031 16.6168ZM16.0247 15.8748C17.2475 14.6146 18 12.8956 18 11C18 7.1325 14.8675 4 11 4C7.1325 4 4 7.1325 4 11C4 14.8675 7.1325 18 11 18C12.8956 18 14.6146 17.2475 15.8748 16.0247L16.0247 15.8748Z"}))};var s=e.i(446428);let i=e=>{var n=(0,t.__rest)(e,[]);return r.default.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",width:"100%",height:"100%",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},n),r.default.createElement("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),r.default.createElement("line",{x1:"6",y1:"6",x2:"18",y2:"18"}))};var u=e.i(444755),d=e.i(673706),c=e.i(103471),m=e.i(495470),f=e.i(854056);let h=(0,d.makeClassName)("MultiSelect"),p=r.default.forwardRef((e,d)=>{let{defaultValue:p=[],value:b,onValueChange:v,placeholder:g="Select...",placeholderSearch:w="Search",disabled:y=!1,icon:x,children:k,className:M,required:D,name:N,error:E=!1,errorMessage:S,id:P}=e,T=(0,t.__rest)(e,["defaultValue","value","onValueChange","placeholder","placeholderSearch","disabled","icon","children","className","required","name","error","errorMessage","id"]),C=(0,r.useRef)(null),[_,j]=(0,a.default)(p,b),{reactElementChildren:L,optionsAvailable:F}=(0,r.useMemo)(()=>{let e=r.default.Children.toArray(k).filter(r.isValidElement);return{reactElementChildren:e,optionsAvailable:(0,c.getFilteredOptions)("",e)}},[k]),[O,I]=(0,r.useState)(""),Y=(null!=_?_:[]).length>0,W=(0,r.useMemo)(()=>O?(0,c.getFilteredOptions)(O,L):F,[O,L,F]),H=()=>{I("")};return r.default.createElement("div",{className:(0,u.tremorTwMerge)("w-full min-w-[10rem] text-tremor-default",M)},r.default.createElement("div",{className:"relative"},r.default.createElement("select",{title:"multi-select-hidden",required:D,className:(0,u.tremorTwMerge)("h-full w-full absolute left-0 top-0 -z-10 opacity-0"),value:_,onChange:e=>{e.preventDefault()},name:N,disabled:y,multiple:!0,id:P,onFocus:()=>{let e=C.current;e&&e.focus()}},r.default.createElement("option",{className:"hidden",value:"",disabled:!0,hidden:!0},g),W.map(e=>{let t=e.props.value,n=e.props.children;return r.default.createElement("option",{className:"hidden",key:t,value:t},n)})),r.default.createElement(m.Listbox,Object.assign({as:"div",ref:d,defaultValue:_,value:_,onChange:e=>{null==v||v(e),j(e)},disabled:y,id:P,multiple:!0},T),({value:e})=>r.default.createElement(r.default.Fragment,null,r.default.createElement(m.ListboxButton,{className:(0,u.tremorTwMerge)("w-full outline-none text-left whitespace-nowrap truncate rounded-tremor-default focus:ring-2 transition duration-100 border pr-8 py-1.5","border-tremor-border shadow-tremor-input focus:border-tremor-brand-subtle focus:ring-tremor-brand-muted","dark:border-dark-tremor-border dark:shadow-dark-tremor-input dark:focus:border-dark-tremor-brand-subtle dark:focus:ring-dark-tremor-brand-muted",x?"pl-11 -ml-0.5":"pl-3",(0,c.getSelectButtonColors)(e.length>0,y,E)),ref:C},x&&r.default.createElement("span",{className:(0,u.tremorTwMerge)("absolute inset-y-0 left-0 flex items-center ml-px pl-2.5")},r.default.createElement(x,{className:(0,u.tremorTwMerge)(h("Icon"),"flex-none h-5 w-5","text-tremor-content-subtle","dark:text-dark-tremor-content-subtle")})),r.default.createElement("div",{className:"h-6 flex items-center"},e.length>0?r.default.createElement("div",{className:"flex flex-nowrap overflow-x-scroll [&::-webkit-scrollbar]:hidden [scrollbar-width:none] gap-x-1 mr-5 -ml-1.5 relative"},F.filter(t=>e.includes(t.props.value)).map((t,n)=>{var a;return r.default.createElement("div",{key:n,className:(0,u.tremorTwMerge)("max-w-[100px] lg:max-w-[200px] flex justify-center items-center pl-2 pr-1.5 py-1 font-medium","rounded-tremor-small","bg-tremor-background-muted dark:bg-dark-tremor-background-muted","bg-tremor-background-subtle dark:bg-dark-tremor-background-subtle","text-tremor-content-default dark:text-dark-tremor-content-default","text-tremor-content-emphasis dark:text-dark-tremor-content-emphasis")},r.default.createElement("div",{className:"text-xs truncate "},null!=(a=t.props.children)?a:t.props.value),r.default.createElement("div",{onClick:r=>{r.preventDefault();let n=e.filter(e=>e!==t.props.value);null==v||v(n),j(n)}},r.default.createElement(i,{className:(0,u.tremorTwMerge)(h("clearIconItem"),"cursor-pointer rounded-tremor-full w-3.5 h-3.5 ml-2","text-tremor-content-subtle hover:text-tremor-content","dark:text-dark-tremor-content-subtle dark:hover:text-tremor-content")})))})):r.default.createElement("span",null,g)),r.default.createElement("span",{className:(0,u.tremorTwMerge)("absolute inset-y-0 right-0 flex items-center mr-2.5")},r.default.createElement(o.default,{className:(0,u.tremorTwMerge)(h("arrowDownIcon"),"flex-none h-5 w-5","text-tremor-content-subtle","dark:text-dark-tremor-content-subtle")}))),Y&&!y?r.default.createElement("button",{type:"button",className:(0,u.tremorTwMerge)("absolute inset-y-0 right-0 flex items-center mr-8"),onClick:e=>{e.preventDefault(),j([]),null==v||v([])}},r.default.createElement(s.default,{className:(0,u.tremorTwMerge)(h("clearIconAllItems"),"flex-none h-4 w-4","text-tremor-content-subtle","dark:text-dark-tremor-content-subtle")})):null,r.default.createElement(f.Transition,{enter:"transition ease duration-100 transform",enterFrom:"opacity-0 -translate-y-4",enterTo:"opacity-100 translate-y-0",leave:"transition ease duration-100 transform",leaveFrom:"opacity-100 translate-y-0",leaveTo:"opacity-0 -translate-y-4"},r.default.createElement(m.ListboxOptions,{anchor:"bottom start",className:(0,u.tremorTwMerge)("z-10 divide-y w-[var(--button-width)] overflow-y-auto outline-none rounded-tremor-default max-h-[228px] border [--anchor-gap:4px]","bg-tremor-background border-tremor-border divide-tremor-border shadow-tremor-dropdown","dark:bg-dark-tremor-background dark:border-dark-tremor-border dark:divide-dark-tremor-border dark:shadow-dark-tremor-dropdown")},r.default.createElement("div",{className:(0,u.tremorTwMerge)("flex items-center w-full px-2.5","bg-tremor-background-muted","dark:bg-dark-tremor-background-muted")},r.default.createElement("span",null,r.default.createElement(l,{className:(0,u.tremorTwMerge)("flex-none w-4 h-4 mr-2","text-tremor-content-subtle","dark:text-dark-tremor-content-subtle")})),r.default.createElement("input",{name:"search",type:"input",autoComplete:"off",placeholder:w,className:(0,u.tremorTwMerge)("w-full focus:outline-none focus:ring-none bg-transparent text-tremor-default py-2","text-tremor-content-emphasis","dark:text-dark-tremor-content-subtle"),onKeyDown:e=>{"Space"===e.code&&""!==e.target.value&&e.stopPropagation()},onChange:e=>I(e.target.value),value:O})),r.default.createElement(n.default.Provider,Object.assign({},{onBlur:{handleResetSearch:H}},{value:{selectedValue:e}}),W)))))),E&&S?r.default.createElement("p",{className:(0,u.tremorTwMerge)("errorMessage","text-sm text-rose-500 mt-1")},S):null)});p.displayName="MultiSelect",e.s(["MultiSelect",()=>p],621642);let b=(0,d.makeClassName)("MultiSelectItem"),v=r.default.forwardRef((e,a)=>{let{value:o,className:l,children:s}=e,i=(0,t.__rest)(e,["value","className","children"]),{selectedValue:c}=(0,r.useContext)(n.default),f=(0,d.isValueInArray)(o,c);return r.default.createElement(m.ListboxOption,Object.assign({className:(0,u.tremorTwMerge)(b("root"),"flex justify-start items-center cursor-default text-tremor-default p-2.5","data-[focus]:bg-tremor-background-muted data-[focus]:text-tremor-content-strong data-[select]ed:text-tremor-content-strong text-tremor-content-emphasis","dark:data-[focus]:bg-dark-tremor-background-muted dark:data-[focus]:text-dark-tremor-content-strong dark:data-[select]ed:text-dark-tremor-content-strong dark:data-[select]ed:bg-dark-tremor-background-muted dark:text-dark-tremor-content-emphasis",l),ref:a,key:o,value:o},i),r.default.createElement("input",{type:"checkbox",className:(0,u.tremorTwMerge)(b("checkbox"),"flex-none focus:ring-none focus:outline-none cursor-pointer mr-2.5","accent-tremor-brand","dark:accent-dark-tremor-brand"),checked:f,readOnly:!0}),r.default.createElement("span",{className:"whitespace-nowrap truncate"},null!=s?s:o))});v.displayName="MultiSelectItem",e.s(["MultiSelectItem",()=>v],25080)},144267,e=>{"use strict";let t,r,n;var a,o,l,s=e.i(843476),i=e.i(271645),u=e.i(290571);let d=e=>{var t=(0,u.__rest)(e,[]);return i.default.createElement("svg",Object.assign({},t,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor"}),i.default.createElement("path",{fillRule:"evenodd",d:"M6 2a1 1 0 00-1 1v1H4a2 2 0 00-2 2v10a2 2 0 002 2h12a2 2 0 002-2V6a2 2 0 00-2-2h-1V3a1 1 0 10-2 0v1H7V3a1 1 0 00-1-1zm0 5a1 1 0 000 2h8a1 1 0 100-2H6z",clipRule:"evenodd"}))};var c=e.i(446428),m=e.i(435684);function f(e){let t=(0,m.toDate)(e);return t.setHours(0,0,0,0),t}function h(){return f(Date.now())}function p(e){let t=(0,m.toDate)(e);return t.setDate(1),t.setHours(0,0,0,0),t}var b=e.i(444755),v=e.i(103471),g=e.i(439189);function w(e,t){return(0,g.addDays)(e,-t)}var y=e.i(497245),x=e.i(96226);function k(e,t){var r;let{years:n=0,months:a=0,weeks:o=0,days:l=0,hours:s=0,minutes:i=0,seconds:u=0}=t,d=w((r=a+12*n,(0,y.addMonths)(e,-r)),l+7*o);return(0,x.constructFrom)(e,d.getTime()-1e3*(u+60*(i+60*s)))}function M(e){let t=(0,m.toDate)(e),r=(0,x.constructFrom)(e,0);return r.setFullYear(t.getFullYear(),0,1),r.setHours(0,0,0,0),r}function D(e){let t;return e.forEach(function(e){let r=(0,m.toDate)(e);(void 0===t||t{let r=(0,m.toDate)(e);(!t||t>r||isNaN(+r))&&(t=r)}),t||new Date(NaN)}let E={lessThanXSeconds:{one:"less than a second",other:"less than {{count}} seconds"},xSeconds:{one:"1 second",other:"{{count}} seconds"},halfAMinute:"half a minute",lessThanXMinutes:{one:"less than a minute",other:"less than {{count}} minutes"},xMinutes:{one:"1 minute",other:"{{count}} minutes"},aboutXHours:{one:"about 1 hour",other:"about {{count}} hours"},xHours:{one:"1 hour",other:"{{count}} hours"},xDays:{one:"1 day",other:"{{count}} days"},aboutXWeeks:{one:"about 1 week",other:"about {{count}} weeks"},xWeeks:{one:"1 week",other:"{{count}} weeks"},aboutXMonths:{one:"about 1 month",other:"about {{count}} months"},xMonths:{one:"1 month",other:"{{count}} months"},aboutXYears:{one:"about 1 year",other:"about {{count}} years"},xYears:{one:"1 year",other:"{{count}} years"},overXYears:{one:"over 1 year",other:"over {{count}} years"},almostXYears:{one:"almost 1 year",other:"almost {{count}} years"}};function S(e){return (t={})=>{let r=t.width?String(t.width):e.defaultWidth;return e.formats[r]||e.formats[e.defaultWidth]}}let P={date:S({formats:{full:"EEEE, MMMM do, y",long:"MMMM do, y",medium:"MMM d, y",short:"MM/dd/yyyy"},defaultWidth:"full"}),time:S({formats:{full:"h:mm:ss a zzzz",long:"h:mm:ss a z",medium:"h:mm:ss a",short:"h:mm a"},defaultWidth:"full"}),dateTime:S({formats:{full:"{{date}} 'at' {{time}}",long:"{{date}} 'at' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},defaultWidth:"full"})},T={lastWeek:"'last' eeee 'at' p",yesterday:"'yesterday at' p",today:"'today at' p",tomorrow:"'tomorrow at' p",nextWeek:"eeee 'at' p",other:"P"};function C(e){return(t,r)=>{let n;if("formatting"===(r?.context?String(r.context):"standalone")&&e.formattingValues){let t=e.defaultFormattingWidth||e.defaultWidth,a=r?.width?String(r.width):t;n=e.formattingValues[a]||e.formattingValues[t]}else{let t=e.defaultWidth,a=r?.width?String(r.width):e.defaultWidth;n=e.values[a]||e.values[t]}return n[e.argumentCallback?e.argumentCallback(t):t]}}function _(e){return(t,r={})=>{let n,a=r.width,o=a&&e.matchPatterns[a]||e.matchPatterns[e.defaultMatchWidth],l=t.match(o);if(!l)return null;let s=l[0],i=a&&e.parsePatterns[a]||e.parsePatterns[e.defaultParseWidth],u=Array.isArray(i)?function(e,t){for(let r=0;re.test(s)):function(e,t){for(let r in e)if(Object.prototype.hasOwnProperty.call(e,r)&&t(e[r]))return r}(i,e=>e.test(s));return n=e.valueCallback?e.valueCallback(u):u,{value:n=r.valueCallback?r.valueCallback(n):n,rest:t.slice(s.length)}}}let j={code:"en-US",formatDistance:(e,t,r)=>{let n,a=E[e];if(n="string"==typeof a?a:1===t?a.one:a.other.replace("{{count}}",t.toString()),r?.addSuffix)if(r.comparison&&r.comparison>0)return"in "+n;else return n+" ago";return n},formatLong:P,formatRelative:(e,t,r,n)=>T[e],localize:{ordinalNumber:(e,t)=>{let r=Number(e),n=r%100;if(n>20||n<10)switch(n%10){case 1:return r+"st";case 2:return r+"nd";case 3:return r+"rd"}return r+"th"},era:C({values:{narrow:["B","A"],abbreviated:["BC","AD"],wide:["Before Christ","Anno Domini"]},defaultWidth:"wide"}),quarter:C({values:{narrow:["1","2","3","4"],abbreviated:["Q1","Q2","Q3","Q4"],wide:["1st quarter","2nd quarter","3rd quarter","4th quarter"]},defaultWidth:"wide",argumentCallback:e=>e-1}),month:C({values:{narrow:["J","F","M","A","M","J","J","A","S","O","N","D"],abbreviated:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],wide:["January","February","March","April","May","June","July","August","September","October","November","December"]},defaultWidth:"wide"}),day:C({values:{narrow:["S","M","T","W","T","F","S"],short:["Su","Mo","Tu","We","Th","Fr","Sa"],abbreviated:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],wide:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]},defaultWidth:"wide"}),dayPeriod:C({values:{narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"}},defaultWidth:"wide",formattingValues:{narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"}},defaultFormattingWidth:"wide"})},match:{ordinalNumber:(a={matchPattern:/^(\d+)(th|st|nd|rd)?/i,parsePattern:/\d+/i,valueCallback:e=>parseInt(e,10)},(e,t={})=>{let r=e.match(a.matchPattern);if(!r)return null;let n=r[0],o=e.match(a.parsePattern);if(!o)return null;let l=a.valueCallback?a.valueCallback(o[0]):o[0];return{value:l=t.valueCallback?t.valueCallback(l):l,rest:e.slice(n.length)}}),era:_({matchPatterns:{narrow:/^(b|a)/i,abbreviated:/^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,wide:/^(before christ|before common era|anno domini|common era)/i},defaultMatchWidth:"wide",parsePatterns:{any:[/^b/i,/^(a|c)/i]},defaultParseWidth:"any"}),quarter:_({matchPatterns:{narrow:/^[1234]/i,abbreviated:/^q[1234]/i,wide:/^[1234](th|st|nd|rd)? quarter/i},defaultMatchWidth:"wide",parsePatterns:{any:[/1/i,/2/i,/3/i,/4/i]},defaultParseWidth:"any",valueCallback:e=>e+1}),month:_({matchPatterns:{narrow:/^[jfmasond]/i,abbreviated:/^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,wide:/^(january|february|march|april|may|june|july|august|september|october|november|december)/i},defaultMatchWidth:"wide",parsePatterns:{narrow:[/^j/i,/^f/i,/^m/i,/^a/i,/^m/i,/^j/i,/^j/i,/^a/i,/^s/i,/^o/i,/^n/i,/^d/i],any:[/^ja/i,/^f/i,/^mar/i,/^ap/i,/^may/i,/^jun/i,/^jul/i,/^au/i,/^s/i,/^o/i,/^n/i,/^d/i]},defaultParseWidth:"any"}),day:_({matchPatterns:{narrow:/^[smtwf]/i,short:/^(su|mo|tu|we|th|fr|sa)/i,abbreviated:/^(sun|mon|tue|wed|thu|fri|sat)/i,wide:/^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i},defaultMatchWidth:"wide",parsePatterns:{narrow:[/^s/i,/^m/i,/^t/i,/^w/i,/^t/i,/^f/i,/^s/i],any:[/^su/i,/^m/i,/^tu/i,/^w/i,/^th/i,/^f/i,/^sa/i]},defaultParseWidth:"any"}),dayPeriod:_({matchPatterns:{narrow:/^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,any:/^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i},defaultMatchWidth:"any",parsePatterns:{any:{am:/^a/i,pm:/^p/i,midnight:/^mi/i,noon:/^no/i,morning:/morning/i,afternoon:/afternoon/i,evening:/evening/i,night:/night/i}},defaultParseWidth:"any"})},options:{weekStartsOn:0,firstWeekContainsDate:1}},L={};function F(e){let t=(0,m.toDate)(e),r=new Date(Date.UTC(t.getFullYear(),t.getMonth(),t.getDate(),t.getHours(),t.getMinutes(),t.getSeconds(),t.getMilliseconds()));return r.setUTCFullYear(t.getFullYear()),e-r}function O(e,t){let r=f(e),n=f(t);return Math.round((r-F(r)-(n-F(n)))/864e5)}function I(e,t){let r=t?.weekStartsOn??t?.locale?.options?.weekStartsOn??L.weekStartsOn??L.locale?.options?.weekStartsOn??0,n=(0,m.toDate)(e),a=n.getDay();return n.setDate(n.getDate()-(7*(a=a.getTime()?r+1:t.getTime()>=l.getTime()?r:r-1}function H(e){let t,r,n=(0,m.toDate)(e);return Math.round((Y(n)-(t=W(n),(r=(0,x.constructFrom)(n,0)).setFullYear(t,0,4),r.setHours(0,0,0,0),Y(r)))/6048e5)+1}function R(e,t){let r=(0,m.toDate)(e),n=r.getFullYear(),a=t?.firstWeekContainsDate??t?.locale?.options?.firstWeekContainsDate??L.firstWeekContainsDate??L.locale?.options?.firstWeekContainsDate??1,o=(0,x.constructFrom)(e,0);o.setFullYear(n+1,0,a),o.setHours(0,0,0,0);let l=I(o,t),s=(0,x.constructFrom)(e,0);s.setFullYear(n,0,a),s.setHours(0,0,0,0);let i=I(s,t);return r.getTime()>=l.getTime()?n+1:r.getTime()>=i.getTime()?n:n-1}function B(e,t){let r,n,a,o=(0,m.toDate)(e);return Math.round((I(o,t)-(r=t?.firstWeekContainsDate??t?.locale?.options?.firstWeekContainsDate??L.firstWeekContainsDate??L.locale?.options?.firstWeekContainsDate??1,n=R(o,t),(a=(0,x.constructFrom)(o,0)).setFullYear(n,0,r),a.setHours(0,0,0,0),I(a,t)))/6048e5)+1}function q(e,t){let r=Math.abs(e).toString().padStart(t,"0");return(e<0?"-":"")+r}let A={y(e,t){let r=e.getFullYear(),n=r>0?r:1-r;return q("yy"===t?n%100:n,t.length)},M(e,t){let r=e.getMonth();return"M"===t?String(r+1):q(r+1,2)},d:(e,t)=>q(e.getDate(),t.length),a(e,t){let r=e.getHours()/12>=1?"pm":"am";switch(t){case"a":case"aa":return r.toUpperCase();case"aaa":return r;case"aaaaa":return r[0];default:return"am"===r?"a.m.":"p.m."}},h:(e,t)=>q(e.getHours()%12||12,t.length),H:(e,t)=>q(e.getHours(),t.length),m:(e,t)=>q(e.getMinutes(),t.length),s:(e,t)=>q(e.getSeconds(),t.length),S(e,t){let r=t.length;return q(Math.trunc(e.getMilliseconds()*Math.pow(10,r-3)),t.length)}},Q={G:function(e,t,r){let n=+(e.getFullYear()>0);switch(t){case"G":case"GG":case"GGG":return r.era(n,{width:"abbreviated"});case"GGGGG":return r.era(n,{width:"narrow"});default:return r.era(n,{width:"wide"})}},y:function(e,t,r){if("yo"===t){let t=e.getFullYear();return r.ordinalNumber(t>0?t:1-t,{unit:"year"})}return A.y(e,t)},Y:function(e,t,r,n){let a=R(e,n),o=a>0?a:1-a;return"YY"===t?q(o%100,2):"Yo"===t?r.ordinalNumber(o,{unit:"year"}):q(o,t.length)},R:function(e,t){return q(W(e),t.length)},u:function(e,t){return q(e.getFullYear(),t.length)},Q:function(e,t,r){let n=Math.ceil((e.getMonth()+1)/3);switch(t){case"Q":return String(n);case"QQ":return q(n,2);case"Qo":return r.ordinalNumber(n,{unit:"quarter"});case"QQQ":return r.quarter(n,{width:"abbreviated",context:"formatting"});case"QQQQQ":return r.quarter(n,{width:"narrow",context:"formatting"});default:return r.quarter(n,{width:"wide",context:"formatting"})}},q:function(e,t,r){let n=Math.ceil((e.getMonth()+1)/3);switch(t){case"q":return String(n);case"qq":return q(n,2);case"qo":return r.ordinalNumber(n,{unit:"quarter"});case"qqq":return r.quarter(n,{width:"abbreviated",context:"standalone"});case"qqqqq":return r.quarter(n,{width:"narrow",context:"standalone"});default:return r.quarter(n,{width:"wide",context:"standalone"})}},M:function(e,t,r){let n=e.getMonth();switch(t){case"M":case"MM":return A.M(e,t);case"Mo":return r.ordinalNumber(n+1,{unit:"month"});case"MMM":return r.month(n,{width:"abbreviated",context:"formatting"});case"MMMMM":return r.month(n,{width:"narrow",context:"formatting"});default:return r.month(n,{width:"wide",context:"formatting"})}},L:function(e,t,r){let n=e.getMonth();switch(t){case"L":return String(n+1);case"LL":return q(n+1,2);case"Lo":return r.ordinalNumber(n+1,{unit:"month"});case"LLL":return r.month(n,{width:"abbreviated",context:"standalone"});case"LLLLL":return r.month(n,{width:"narrow",context:"standalone"});default:return r.month(n,{width:"wide",context:"standalone"})}},w:function(e,t,r,n){let a=B(e,n);return"wo"===t?r.ordinalNumber(a,{unit:"week"}):q(a,t.length)},I:function(e,t,r){let n=H(e);return"Io"===t?r.ordinalNumber(n,{unit:"week"}):q(n,t.length)},d:function(e,t,r){return"do"===t?r.ordinalNumber(e.getDate(),{unit:"date"}):A.d(e,t)},D:function(e,t,r){let n,a=O(n=(0,m.toDate)(e),M(n))+1;return"Do"===t?r.ordinalNumber(a,{unit:"dayOfYear"}):q(a,t.length)},E:function(e,t,r){let n=e.getDay();switch(t){case"E":case"EE":case"EEE":return r.day(n,{width:"abbreviated",context:"formatting"});case"EEEEE":return r.day(n,{width:"narrow",context:"formatting"});case"EEEEEE":return r.day(n,{width:"short",context:"formatting"});default:return r.day(n,{width:"wide",context:"formatting"})}},e:function(e,t,r,n){let a=e.getDay(),o=(a-n.weekStartsOn+8)%7||7;switch(t){case"e":return String(o);case"ee":return q(o,2);case"eo":return r.ordinalNumber(o,{unit:"day"});case"eee":return r.day(a,{width:"abbreviated",context:"formatting"});case"eeeee":return r.day(a,{width:"narrow",context:"formatting"});case"eeeeee":return r.day(a,{width:"short",context:"formatting"});default:return r.day(a,{width:"wide",context:"formatting"})}},c:function(e,t,r,n){let a=e.getDay(),o=(a-n.weekStartsOn+8)%7||7;switch(t){case"c":return String(o);case"cc":return q(o,t.length);case"co":return r.ordinalNumber(o,{unit:"day"});case"ccc":return r.day(a,{width:"abbreviated",context:"standalone"});case"ccccc":return r.day(a,{width:"narrow",context:"standalone"});case"cccccc":return r.day(a,{width:"short",context:"standalone"});default:return r.day(a,{width:"wide",context:"standalone"})}},i:function(e,t,r){let n=e.getDay(),a=0===n?7:n;switch(t){case"i":return String(a);case"ii":return q(a,t.length);case"io":return r.ordinalNumber(a,{unit:"day"});case"iii":return r.day(n,{width:"abbreviated",context:"formatting"});case"iiiii":return r.day(n,{width:"narrow",context:"formatting"});case"iiiiii":return r.day(n,{width:"short",context:"formatting"});default:return r.day(n,{width:"wide",context:"formatting"})}},a:function(e,t,r){let n=e.getHours()/12>=1?"pm":"am";switch(t){case"a":case"aa":return r.dayPeriod(n,{width:"abbreviated",context:"formatting"});case"aaa":return r.dayPeriod(n,{width:"abbreviated",context:"formatting"}).toLowerCase();case"aaaaa":return r.dayPeriod(n,{width:"narrow",context:"formatting"});default:return r.dayPeriod(n,{width:"wide",context:"formatting"})}},b:function(e,t,r){let n,a=e.getHours();switch(n=12===a?"noon":0===a?"midnight":a/12>=1?"pm":"am",t){case"b":case"bb":return r.dayPeriod(n,{width:"abbreviated",context:"formatting"});case"bbb":return r.dayPeriod(n,{width:"abbreviated",context:"formatting"}).toLowerCase();case"bbbbb":return r.dayPeriod(n,{width:"narrow",context:"formatting"});default:return r.dayPeriod(n,{width:"wide",context:"formatting"})}},B:function(e,t,r){let n,a=e.getHours();switch(n=a>=17?"evening":a>=12?"afternoon":a>=4?"morning":"night",t){case"B":case"BB":case"BBB":return r.dayPeriod(n,{width:"abbreviated",context:"formatting"});case"BBBBB":return r.dayPeriod(n,{width:"narrow",context:"formatting"});default:return r.dayPeriod(n,{width:"wide",context:"formatting"})}},h:function(e,t,r){if("ho"===t){let t=e.getHours()%12;return 0===t&&(t=12),r.ordinalNumber(t,{unit:"hour"})}return A.h(e,t)},H:function(e,t,r){return"Ho"===t?r.ordinalNumber(e.getHours(),{unit:"hour"}):A.H(e,t)},K:function(e,t,r){let n=e.getHours()%12;return"Ko"===t?r.ordinalNumber(n,{unit:"hour"}):q(n,t.length)},k:function(e,t,r){let n=e.getHours();return(0===n&&(n=24),"ko"===t)?r.ordinalNumber(n,{unit:"hour"}):q(n,t.length)},m:function(e,t,r){return"mo"===t?r.ordinalNumber(e.getMinutes(),{unit:"minute"}):A.m(e,t)},s:function(e,t,r){return"so"===t?r.ordinalNumber(e.getSeconds(),{unit:"second"}):A.s(e,t)},S:function(e,t){return A.S(e,t)},X:function(e,t,r){let n=e.getTimezoneOffset();if(0===n)return"Z";switch(t){case"X":return z(n);case"XXXX":case"XX":return V(n);default:return V(n,":")}},x:function(e,t,r){let n=e.getTimezoneOffset();switch(t){case"x":return z(n);case"xxxx":case"xx":return V(n);default:return V(n,":")}},O:function(e,t,r){let n=e.getTimezoneOffset();switch(t){case"O":case"OO":case"OOO":return"GMT"+G(n,":");default:return"GMT"+V(n,":")}},z:function(e,t,r){let n=e.getTimezoneOffset();switch(t){case"z":case"zz":case"zzz":return"GMT"+G(n,":");default:return"GMT"+V(n,":")}},t:function(e,t,r){return q(Math.trunc(e.getTime()/1e3),t.length)},T:function(e,t,r){return q(e.getTime(),t.length)}};function G(e,t=""){let r=e>0?"-":"+",n=Math.abs(e),a=Math.trunc(n/60),o=n%60;return 0===o?r+String(a):r+String(a)+t+q(o,2)}function z(e,t){return e%60==0?(e>0?"-":"+")+q(Math.abs(e)/60,2):V(e,t)}function V(e,t=""){let r=Math.abs(e);return(e>0?"-":"+")+q(Math.trunc(r/60),2)+t+q(r%60,2)}let $=(e,t)=>{switch(e){case"P":return t.date({width:"short"});case"PP":return t.date({width:"medium"});case"PPP":return t.date({width:"long"});default:return t.date({width:"full"})}},K=(e,t)=>{switch(e){case"p":return t.time({width:"short"});case"pp":return t.time({width:"medium"});case"ppp":return t.time({width:"long"});default:return t.time({width:"full"})}},X={p:K,P:(e,t)=>{let r,n=e.match(/(P+)(p+)?/)||[],a=n[1],o=n[2];if(!o)return $(e,t);switch(a){case"P":r=t.dateTime({width:"short"});break;case"PP":r=t.dateTime({width:"medium"});break;case"PPP":r=t.dateTime({width:"long"});break;default:r=t.dateTime({width:"full"})}return r.replace("{{date}}",$(a,t)).replace("{{time}}",K(o,t))}},Z=/^D+$/,U=/^Y+$/,J=["D","DD","YY","YYYY"];function ee(e){return e instanceof Date||"object"==typeof e&&"[object Date]"===Object.prototype.toString.call(e)}let et=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,er=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,en=/^'([^]*?)'?$/,ea=/''/g,eo=/[a-zA-Z]/;function el(e,t,r){let n=r?.locale??L.locale??j,a=r?.firstWeekContainsDate??r?.locale?.options?.firstWeekContainsDate??L.firstWeekContainsDate??L.locale?.options?.firstWeekContainsDate??1,o=r?.weekStartsOn??r?.locale?.options?.weekStartsOn??L.weekStartsOn??L.locale?.options?.weekStartsOn??0,l=(0,m.toDate)(e);if(!((ee(l)||"number"==typeof l)&&!isNaN(Number((0,m.toDate)(l)))))throw RangeError("Invalid time value");let s=t.match(er).map(e=>{let t=e[0];return"p"===t||"P"===t?(0,X[t])(e,n.formatLong):e}).join("").match(et).map(e=>{if("''"===e)return{isToken:!1,value:"'"};let t=e[0];if("'"===t){var r;let t;return{isToken:!1,value:(t=(r=e).match(en))?t[1].replace(ea,"'"):r}}if(Q[t])return{isToken:!0,value:e};if(t.match(eo))throw RangeError("Format string contains an unescaped latin alphabet character `"+t+"`");return{isToken:!1,value:e}});n.localize.preprocessor&&(s=n.localize.preprocessor(l,s));let i={firstWeekContainsDate:a,weekStartsOn:o,locale:n};return s.map(a=>{if(!a.isToken)return a.value;let o=a.value;return(!r?.useAdditionalWeekYearTokens&&U.test(o)||!r?.useAdditionalDayOfYearTokens&&Z.test(o))&&function(e,t,r){var n,a,o;let l,s=(n=e,a=t,o=r,l="Y"===n[0]?"years":"days of the month",`Use \`${n.toLowerCase()}\` instead of \`${n}\` (in \`${a}\`) for formatting ${l} to the input \`${o}\`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md`);if(console.warn(s),J.includes(e))throw RangeError(s)}(o,t,String(e)),(0,Q[o[0]])(l,o,n.localize,i)}).join("")}let es=(0,e.i(673706).makeClassName)("DateRangePicker"),ei=[{value:"tdy",text:"Today",from:h()},{value:"w",text:"Last 7 days",from:k(h(),{days:7})},{value:"t",text:"Last 30 days",from:k(h(),{days:30})},{value:"m",text:"Month to Date",from:p(h())},{value:"y",text:"Year to Date",from:M(h())}];function eu(e){let t=(0,m.toDate)(e),r=t.getMonth();return t.setFullYear(t.getFullYear(),r+1,0),t.setHours(23,59,59,999),t}function ed(e,t){let r,n,a,o,l=(0,m.toDate)(e),s=l.getFullYear(),i=l.getDate(),u=(0,x.constructFrom)(e,0);u.setFullYear(s,t,15),u.setHours(0,0,0,0);let d=(n=(r=(0,m.toDate)(u)).getFullYear(),a=r.getMonth(),(o=(0,x.constructFrom)(u,0)).setFullYear(n,a+1,0),o.setHours(0,0,0,0),o.getDate());return l.setMonth(t,Math.min(i,d)),l}function ec(e,t){let r=(0,m.toDate)(e);return isNaN(+r)?(0,x.constructFrom)(e,NaN):(r.setFullYear(t),r)}function em(e,t){let r=(0,m.toDate)(e),n=(0,m.toDate)(t);return 12*(r.getFullYear()-n.getFullYear())+(r.getMonth()-n.getMonth())}function ef(e,t){let r=(0,m.toDate)(e),n=(0,m.toDate)(t);return r.getFullYear()===n.getFullYear()&&r.getMonth()===n.getMonth()}function eh(e,t){return+(0,m.toDate)(e)<+(0,m.toDate)(t)}function ep(e,t){return+f(e)==+f(t)}function eb(e,t){let r=(0,m.toDate)(e),n=(0,m.toDate)(t);return r.getTime()>n.getTime()}function ev(e,t){return(0,g.addDays)(e,7*t)}function eg(e,t){return(0,y.addMonths)(e,12*t)}function ew(e,t){let r=t?.weekStartsOn??t?.locale?.options?.weekStartsOn??L.weekStartsOn??L.locale?.options?.weekStartsOn??0,n=(0,m.toDate)(e),a=n.getDay();return n.setDate(n.getDate()+((a0,a=n?t:1-t;if(a<=50)r=e||100;else{let t=a+50;r=e+100*Math.trunc(t/100)-100*(e>=t%100)}return n?r:1-r}function e1(e){return e%400==0||e%4==0&&e%100!=0}let e2=[31,28,31,30,31,30,31,31,30,31,30,31],e4=[31,29,31,30,31,30,31,31,30,31,30,31];function e3(e,t,r){let n=r?.weekStartsOn??r?.locale?.options?.weekStartsOn??L.weekStartsOn??L.locale?.options?.weekStartsOn??0,a=(0,m.toDate)(e),o=a.getDay(),l=7-n,s=t<0||t>6?t-(o+l)%7:((t%7+7)%7+l)%7-(o+l)%7;return(0,g.addDays)(a,s)}new class extends eM{priority=140;parse(e,t,r){switch(t){case"G":case"GG":case"GGG":return r.era(e,{width:"abbreviated"})||r.era(e,{width:"narrow"});case"GGGGG":return r.era(e,{width:"narrow"});default:return r.era(e,{width:"wide"})||r.era(e,{width:"abbreviated"})||r.era(e,{width:"narrow"})}}set(e,t,r){return t.era=r,e.setFullYear(r,0,1),e.setHours(0,0,0,0),e}incompatibleTokens=["R","u","t","T"]},new class extends eM{priority=130;incompatibleTokens=["Y","R","u","w","I","i","e","c","t","T"];parse(e,t,r){let n=e=>({year:e,isTwoDigitYear:"yy"===t});switch(t){case"y":return e$(eZ(4,e),n);case"yo":return e$(r.ordinalNumber(e,{unit:"year"}),n);default:return e$(eZ(t.length,e),n)}}validate(e,t){return t.isTwoDigitYear||t.year>0}set(e,t,r){let n=e.getFullYear();if(r.isTwoDigitYear){let t=e0(r.year,n);return e.setFullYear(t,0,1),e.setHours(0,0,0,0),e}let a="era"in t&&1!==t.era?1-r.year:r.year;return e.setFullYear(a,0,1),e.setHours(0,0,0,0),e}},new class extends eM{priority=130;parse(e,t,r){let n=e=>({year:e,isTwoDigitYear:"YY"===t});switch(t){case"Y":return e$(eZ(4,e),n);case"Yo":return e$(r.ordinalNumber(e,{unit:"year"}),n);default:return e$(eZ(t.length,e),n)}}validate(e,t){return t.isTwoDigitYear||t.year>0}set(e,t,r,n){let a=R(e,n);if(r.isTwoDigitYear){let t=e0(r.year,a);return e.setFullYear(t,0,n.firstWeekContainsDate),e.setHours(0,0,0,0),I(e,n)}let o="era"in t&&1!==t.era?1-r.year:r.year;return e.setFullYear(o,0,n.firstWeekContainsDate),e.setHours(0,0,0,0),I(e,n)}incompatibleTokens=["y","R","u","Q","q","M","L","I","d","D","i","t","T"]},new class extends eM{priority=130;parse(e,t){return"R"===t?eU(4,e):eU(t.length,e)}set(e,t,r){let n=(0,x.constructFrom)(e,0);return n.setFullYear(r,0,4),n.setHours(0,0,0,0),Y(n)}incompatibleTokens=["G","y","Y","u","Q","q","M","L","w","d","D","e","c","t","T"]},new class extends eM{priority=130;parse(e,t){return"u"===t?eU(4,e):eU(t.length,e)}set(e,t,r){return e.setFullYear(r,0,1),e.setHours(0,0,0,0),e}incompatibleTokens=["G","y","Y","R","w","I","i","e","c","t","T"]},new class extends eM{priority=120;parse(e,t,r){switch(t){case"Q":case"QQ":return eZ(t.length,e);case"Qo":return r.ordinalNumber(e,{unit:"quarter"});case"QQQ":return r.quarter(e,{width:"abbreviated",context:"formatting"})||r.quarter(e,{width:"narrow",context:"formatting"});case"QQQQQ":return r.quarter(e,{width:"narrow",context:"formatting"});default:return r.quarter(e,{width:"wide",context:"formatting"})||r.quarter(e,{width:"abbreviated",context:"formatting"})||r.quarter(e,{width:"narrow",context:"formatting"})}}validate(e,t){return t>=1&&t<=4}set(e,t,r){return e.setMonth((r-1)*3,1),e.setHours(0,0,0,0),e}incompatibleTokens=["Y","R","q","M","L","w","I","d","D","i","e","c","t","T"]},new class extends eM{priority=120;parse(e,t,r){switch(t){case"q":case"qq":return eZ(t.length,e);case"qo":return r.ordinalNumber(e,{unit:"quarter"});case"qqq":return r.quarter(e,{width:"abbreviated",context:"standalone"})||r.quarter(e,{width:"narrow",context:"standalone"});case"qqqqq":return r.quarter(e,{width:"narrow",context:"standalone"});default:return r.quarter(e,{width:"wide",context:"standalone"})||r.quarter(e,{width:"abbreviated",context:"standalone"})||r.quarter(e,{width:"narrow",context:"standalone"})}}validate(e,t){return t>=1&&t<=4}set(e,t,r){return e.setMonth((r-1)*3,1),e.setHours(0,0,0,0),e}incompatibleTokens=["Y","R","Q","M","L","w","I","d","D","i","e","c","t","T"]},new class extends eM{incompatibleTokens=["Y","R","q","Q","L","w","I","D","i","e","c","t","T"];priority=110;parse(e,t,r){let n=e=>e-1;switch(t){case"M":return e$(eK(eD,e),n);case"MM":return e$(eZ(2,e),n);case"Mo":return e$(r.ordinalNumber(e,{unit:"month"}),n);case"MMM":return r.month(e,{width:"abbreviated",context:"formatting"})||r.month(e,{width:"narrow",context:"formatting"});case"MMMMM":return r.month(e,{width:"narrow",context:"formatting"});default:return r.month(e,{width:"wide",context:"formatting"})||r.month(e,{width:"abbreviated",context:"formatting"})||r.month(e,{width:"narrow",context:"formatting"})}}validate(e,t){return t>=0&&t<=11}set(e,t,r){return e.setMonth(r,1),e.setHours(0,0,0,0),e}},new class extends eM{priority=110;parse(e,t,r){let n=e=>e-1;switch(t){case"L":return e$(eK(eD,e),n);case"LL":return e$(eZ(2,e),n);case"Lo":return e$(r.ordinalNumber(e,{unit:"month"}),n);case"LLL":return r.month(e,{width:"abbreviated",context:"standalone"})||r.month(e,{width:"narrow",context:"standalone"});case"LLLLL":return r.month(e,{width:"narrow",context:"standalone"});default:return r.month(e,{width:"wide",context:"standalone"})||r.month(e,{width:"abbreviated",context:"standalone"})||r.month(e,{width:"narrow",context:"standalone"})}}validate(e,t){return t>=0&&t<=11}set(e,t,r){return e.setMonth(r,1),e.setHours(0,0,0,0),e}incompatibleTokens=["Y","R","q","Q","M","w","I","D","i","e","c","t","T"]},new class extends eM{priority=100;parse(e,t,r){switch(t){case"w":return eK(eS,e);case"wo":return r.ordinalNumber(e,{unit:"week"});default:return eZ(t.length,e)}}validate(e,t){return t>=1&&t<=53}set(e,t,r,n){let a,o;return I((o=B(a=(0,m.toDate)(e),n)-r,a.setDate(a.getDate()-7*o),a),n)}incompatibleTokens=["y","R","u","q","Q","M","L","I","d","D","i","t","T"]},new class extends eM{priority=100;parse(e,t,r){switch(t){case"I":return eK(eS,e);case"Io":return r.ordinalNumber(e,{unit:"week"});default:return eZ(t.length,e)}}validate(e,t){return t>=1&&t<=53}set(e,t,r){let n,a;return Y((a=H(n=(0,m.toDate)(e))-r,n.setDate(n.getDate()-7*a),n))}incompatibleTokens=["y","Y","u","q","Q","M","L","w","d","D","e","c","t","T"]},new class extends eM{priority=90;subPriority=1;parse(e,t,r){switch(t){case"d":return eK(eN,e);case"do":return r.ordinalNumber(e,{unit:"date"});default:return eZ(t.length,e)}}validate(e,t){let r=e1(e.getFullYear()),n=e.getMonth();return r?t>=1&&t<=e4[n]:t>=1&&t<=e2[n]}set(e,t,r){return e.setDate(r),e.setHours(0,0,0,0),e}incompatibleTokens=["Y","R","q","Q","w","I","D","i","e","c","t","T"]},new class extends eM{priority=90;subpriority=1;parse(e,t,r){switch(t){case"D":case"DD":return eK(eE,e);case"Do":return r.ordinalNumber(e,{unit:"date"});default:return eZ(t.length,e)}}validate(e,t){return e1(e.getFullYear())?t>=1&&t<=366:t>=1&&t<=365}set(e,t,r){return e.setMonth(0,r),e.setHours(0,0,0,0),e}incompatibleTokens=["Y","R","q","Q","M","L","w","I","d","E","i","e","c","t","T"]},new class extends eM{priority=90;parse(e,t,r){switch(t){case"E":case"EE":case"EEE":return r.day(e,{width:"abbreviated",context:"formatting"})||r.day(e,{width:"short",context:"formatting"})||r.day(e,{width:"narrow",context:"formatting"});case"EEEEE":return r.day(e,{width:"narrow",context:"formatting"});case"EEEEEE":return r.day(e,{width:"short",context:"formatting"})||r.day(e,{width:"narrow",context:"formatting"});default:return r.day(e,{width:"wide",context:"formatting"})||r.day(e,{width:"abbreviated",context:"formatting"})||r.day(e,{width:"short",context:"formatting"})||r.day(e,{width:"narrow",context:"formatting"})}}validate(e,t){return t>=0&&t<=6}set(e,t,r,n){return(e=e3(e,r,n)).setHours(0,0,0,0),e}incompatibleTokens=["D","i","e","c","t","T"]},new class extends eM{priority=90;parse(e,t,r,n){let a=e=>{let t=7*Math.floor((e-1)/7);return(e+n.weekStartsOn+6)%7+t};switch(t){case"e":case"ee":return e$(eZ(t.length,e),a);case"eo":return e$(r.ordinalNumber(e,{unit:"day"}),a);case"eee":return r.day(e,{width:"abbreviated",context:"formatting"})||r.day(e,{width:"short",context:"formatting"})||r.day(e,{width:"narrow",context:"formatting"});case"eeeee":return r.day(e,{width:"narrow",context:"formatting"});case"eeeeee":return r.day(e,{width:"short",context:"formatting"})||r.day(e,{width:"narrow",context:"formatting"});default:return r.day(e,{width:"wide",context:"formatting"})||r.day(e,{width:"abbreviated",context:"formatting"})||r.day(e,{width:"short",context:"formatting"})||r.day(e,{width:"narrow",context:"formatting"})}}validate(e,t){return t>=0&&t<=6}set(e,t,r,n){return(e=e3(e,r,n)).setHours(0,0,0,0),e}incompatibleTokens=["y","R","u","q","Q","M","L","I","d","D","E","i","c","t","T"]},new class extends eM{priority=90;parse(e,t,r,n){let a=e=>{let t=7*Math.floor((e-1)/7);return(e+n.weekStartsOn+6)%7+t};switch(t){case"c":case"cc":return e$(eZ(t.length,e),a);case"co":return e$(r.ordinalNumber(e,{unit:"day"}),a);case"ccc":return r.day(e,{width:"abbreviated",context:"standalone"})||r.day(e,{width:"short",context:"standalone"})||r.day(e,{width:"narrow",context:"standalone"});case"ccccc":return r.day(e,{width:"narrow",context:"standalone"});case"cccccc":return r.day(e,{width:"short",context:"standalone"})||r.day(e,{width:"narrow",context:"standalone"});default:return r.day(e,{width:"wide",context:"standalone"})||r.day(e,{width:"abbreviated",context:"standalone"})||r.day(e,{width:"short",context:"standalone"})||r.day(e,{width:"narrow",context:"standalone"})}}validate(e,t){return t>=0&&t<=6}set(e,t,r,n){return(e=e3(e,r,n)).setHours(0,0,0,0),e}incompatibleTokens=["y","R","u","q","Q","M","L","I","d","D","E","i","e","t","T"]},new class extends eM{priority=90;parse(e,t,r){let n=e=>0===e?7:e;switch(t){case"i":case"ii":return eZ(t.length,e);case"io":return r.ordinalNumber(e,{unit:"day"});case"iii":return e$(r.day(e,{width:"abbreviated",context:"formatting"})||r.day(e,{width:"short",context:"formatting"})||r.day(e,{width:"narrow",context:"formatting"}),n);case"iiiii":return e$(r.day(e,{width:"narrow",context:"formatting"}),n);case"iiiiii":return e$(r.day(e,{width:"short",context:"formatting"})||r.day(e,{width:"narrow",context:"formatting"}),n);default:return e$(r.day(e,{width:"wide",context:"formatting"})||r.day(e,{width:"abbreviated",context:"formatting"})||r.day(e,{width:"short",context:"formatting"})||r.day(e,{width:"narrow",context:"formatting"}),n)}}validate(e,t){return t>=1&&t<=7}set(e,t,r){var n;let a,o,l;return n=e,a=(0,m.toDate)(n),0===(o=(0,m.toDate)(a).getDay())&&(o=7),l=o,(e=(0,g.addDays)(a,r-l)).setHours(0,0,0,0),e}incompatibleTokens=["y","Y","u","q","Q","M","L","w","d","D","E","e","c","t","T"]},new class extends eM{priority=80;parse(e,t,r){switch(t){case"a":case"aa":case"aaa":return r.dayPeriod(e,{width:"abbreviated",context:"formatting"})||r.dayPeriod(e,{width:"narrow",context:"formatting"});case"aaaaa":return r.dayPeriod(e,{width:"narrow",context:"formatting"});default:return r.dayPeriod(e,{width:"wide",context:"formatting"})||r.dayPeriod(e,{width:"abbreviated",context:"formatting"})||r.dayPeriod(e,{width:"narrow",context:"formatting"})}}set(e,t,r){return e.setHours(eJ(r),0,0,0),e}incompatibleTokens=["b","B","H","k","t","T"]},new class extends eM{priority=80;parse(e,t,r){switch(t){case"b":case"bb":case"bbb":return r.dayPeriod(e,{width:"abbreviated",context:"formatting"})||r.dayPeriod(e,{width:"narrow",context:"formatting"});case"bbbbb":return r.dayPeriod(e,{width:"narrow",context:"formatting"});default:return r.dayPeriod(e,{width:"wide",context:"formatting"})||r.dayPeriod(e,{width:"abbreviated",context:"formatting"})||r.dayPeriod(e,{width:"narrow",context:"formatting"})}}set(e,t,r){return e.setHours(eJ(r),0,0,0),e}incompatibleTokens=["a","B","H","k","t","T"]},new class extends eM{priority=80;parse(e,t,r){switch(t){case"B":case"BB":case"BBB":return r.dayPeriod(e,{width:"abbreviated",context:"formatting"})||r.dayPeriod(e,{width:"narrow",context:"formatting"});case"BBBBB":return r.dayPeriod(e,{width:"narrow",context:"formatting"});default:return r.dayPeriod(e,{width:"wide",context:"formatting"})||r.dayPeriod(e,{width:"abbreviated",context:"formatting"})||r.dayPeriod(e,{width:"narrow",context:"formatting"})}}set(e,t,r){return e.setHours(eJ(r),0,0,0),e}incompatibleTokens=["a","b","t","T"]},new class extends eM{priority=70;parse(e,t,r){switch(t){case"h":return eK(e_,e);case"ho":return r.ordinalNumber(e,{unit:"hour"});default:return eZ(t.length,e)}}validate(e,t){return t>=1&&t<=12}set(e,t,r){let n=e.getHours()>=12;return n&&r<12?e.setHours(r+12,0,0,0):n||12!==r?e.setHours(r,0,0,0):e.setHours(0,0,0,0),e}incompatibleTokens=["H","K","k","t","T"]},new class extends eM{priority=70;parse(e,t,r){switch(t){case"H":return eK(eP,e);case"Ho":return r.ordinalNumber(e,{unit:"hour"});default:return eZ(t.length,e)}}validate(e,t){return t>=0&&t<=23}set(e,t,r){return e.setHours(r,0,0,0),e}incompatibleTokens=["a","b","h","K","k","t","T"]},new class extends eM{priority=70;parse(e,t,r){switch(t){case"K":return eK(eC,e);case"Ko":return r.ordinalNumber(e,{unit:"hour"});default:return eZ(t.length,e)}}validate(e,t){return t>=0&&t<=11}set(e,t,r){return e.getHours()>=12&&r<12?e.setHours(r+12,0,0,0):e.setHours(r,0,0,0),e}incompatibleTokens=["h","H","k","t","T"]},new class extends eM{priority=70;parse(e,t,r){switch(t){case"k":return eK(eT,e);case"ko":return r.ordinalNumber(e,{unit:"hour"});default:return eZ(t.length,e)}}validate(e,t){return t>=1&&t<=24}set(e,t,r){return e.setHours(r<=24?r%24:r,0,0,0),e}incompatibleTokens=["a","b","h","H","K","t","T"]},new class extends eM{priority=60;parse(e,t,r){switch(t){case"m":return eK(ej,e);case"mo":return r.ordinalNumber(e,{unit:"minute"});default:return eZ(t.length,e)}}validate(e,t){return t>=0&&t<=59}set(e,t,r){return e.setMinutes(r,0,0),e}incompatibleTokens=["t","T"]},new class extends eM{priority=50;parse(e,t,r){switch(t){case"s":return eK(eL,e);case"so":return r.ordinalNumber(e,{unit:"second"});default:return eZ(t.length,e)}}validate(e,t){return t>=0&&t<=59}set(e,t,r){return e.setSeconds(r,0),e}incompatibleTokens=["t","T"]},new class extends eM{priority=30;parse(e,t){return e$(eZ(t.length,e),e=>Math.trunc(e*Math.pow(10,-t.length+3)))}set(e,t,r){return e.setMilliseconds(r),e}incompatibleTokens=["t","T"]},new class extends eM{priority=10;parse(e,t){switch(t){case"X":return eX(eA,e);case"XX":return eX(eQ,e);case"XXXX":return eX(eG,e);case"XXXXX":return eX(eV,e);default:return eX(ez,e)}}set(e,t,r){return t.timestampIsSet?e:(0,x.constructFrom)(e,e.getTime()-F(e)-r)}incompatibleTokens=["t","T","x"]},new class extends eM{priority=10;parse(e,t){switch(t){case"x":return eX(eA,e);case"xx":return eX(eQ,e);case"xxxx":return eX(eG,e);case"xxxxx":return eX(eV,e);default:return eX(ez,e)}}set(e,t,r){return t.timestampIsSet?e:(0,x.constructFrom)(e,e.getTime()-F(e)-r)}incompatibleTokens=["t","T","X"]},new class extends eM{priority=40;parse(e){return eK(eW,e)}set(e,t,r){return[(0,x.constructFrom)(e,1e3*r),{timestampIsSet:!0}]}incompatibleTokens="*"},new class extends eM{priority=20;parse(e){return eK(eW,e)}set(e,t,r){return[(0,x.constructFrom)(e,r),{timestampIsSet:!0}]}incompatibleTokens="*"};var e5=function(){return(e5=Object.assign||function(e){for(var t,r=1,n=arguments.length;rem(u,l)&&(l=(0,y.addMonths)(u,-1*((void 0===c?1:c)-1))),d&&0>em(l,d)&&(l=d),m=p(l),f=t.month,b=(h=(0,i.useState)(m))[0],v=[void 0===f?b:f,h[1]])[0],w=v[1],[g,function(e){if(!t.disableNavigation){var r,n=p(e);w(n),null==(r=t.onMonthChange)||r.call(t,n)}}]),M=k[0],D=k[1],N=function(e,t){for(var r=t.reverseMonths,n=t.numberOfMonths,a=p(e),o=em(p((0,y.addMonths)(a,n)),a),l=[],s=0;s=em(o,r)))return(0,y.addMonths)(o,-(n?void 0===a?1:a:1))}}(M,x),P=function(e){return N.some(function(t){return ef(e,t)})};return(0,s.jsx)(tc.Provider,{value:{currentMonth:M,displayMonths:N,goToMonth:D,goToDate:function(e,t){P(e)||(t&&eh(e,t)?D((0,y.addMonths)(e,1+-1*x.numberOfMonths)):D(e))},previousMonth:S,nextMonth:E,isDateDisplayed:P},children:e.children})}function tf(){var e=(0,i.useContext)(tc);if(!e)throw Error("useNavigation must be used within a NavigationProvider");return e}function th(e){var t,r=to(),n=r.classNames,a=r.styles,o=r.components,l=tf().goToMonth,i=function(t){l((0,y.addMonths)(t,e.displayIndex?-e.displayIndex:0))},u=null!=(t=null==o?void 0:o.CaptionLabel)?t:tl,d=(0,s.jsx)(u,{id:e.id,displayMonth:e.displayMonth});return(0,s.jsxs)("div",{className:n.caption_dropdowns,style:a.caption_dropdowns,children:[(0,s.jsx)("div",{className:n.vhidden,children:d}),(0,s.jsx)(tu,{onChange:i,displayMonth:e.displayMonth}),(0,s.jsx)(td,{onChange:i,displayMonth:e.displayMonth})]})}function tp(e){return(0,s.jsx)("svg",e5({width:"16px",height:"16px",viewBox:"0 0 120 120"},e,{children:(0,s.jsx)("path",{d:"M69.490332,3.34314575 C72.6145263,0.218951416 77.6798462,0.218951416 80.8040405,3.34314575 C83.8617626,6.40086786 83.9268205,11.3179931 80.9992143,14.4548388 L80.8040405,14.6568542 L35.461,60 L80.8040405,105.343146 C83.8617626,108.400868 83.9268205,113.317993 80.9992143,116.454839 L80.8040405,116.656854 C77.7463184,119.714576 72.8291931,119.779634 69.6923475,116.852028 L69.490332,116.656854 L18.490332,65.6568542 C15.4326099,62.5991321 15.367552,57.6820069 18.2951583,54.5451612 L18.490332,54.3431458 L69.490332,3.34314575 Z",fill:"currentColor",fillRule:"nonzero"})}))}function tb(e){return(0,s.jsx)("svg",e5({width:"16px",height:"16px",viewBox:"0 0 120 120"},e,{children:(0,s.jsx)("path",{d:"M49.8040405,3.34314575 C46.6798462,0.218951416 41.6145263,0.218951416 38.490332,3.34314575 C35.4326099,6.40086786 35.367552,11.3179931 38.2951583,14.4548388 L38.490332,14.6568542 L83.8333725,60 L38.490332,105.343146 C35.4326099,108.400868 35.367552,113.317993 38.2951583,116.454839 L38.490332,116.656854 C41.5480541,119.714576 46.4651794,119.779634 49.602025,116.852028 L49.8040405,116.656854 L100.804041,65.6568542 C103.861763,62.5991321 103.926821,57.6820069 100.999214,54.5451612 L100.804041,54.3431458 L49.8040405,3.34314575 Z",fill:"currentColor"})}))}var tv=(0,i.forwardRef)(function(e,t){var r=to(),n=r.classNames,a=r.styles,o=[n.button_reset,n.button];e.className&&o.push(e.className);var l=o.join(" "),i=e5(e5({},a.button_reset),a.button);return e.style&&Object.assign(i,e.style),(0,s.jsx)("button",e5({},e,{ref:t,type:"button",className:l,style:i}))});function tg(e){var t,r,n=to(),a=n.dir,o=n.locale,l=n.classNames,i=n.styles,u=n.labels,d=u.labelPrevious,c=u.labelNext,m=n.components;if(!e.nextMonth&&!e.previousMonth)return(0,s.jsx)(s.Fragment,{});var f=d(e.previousMonth,{locale:o}),h=[l.nav_button,l.nav_button_previous].join(" "),p=c(e.nextMonth,{locale:o}),b=[l.nav_button,l.nav_button_next].join(" "),v=null!=(t=null==m?void 0:m.IconRight)?t:tb,g=null!=(r=null==m?void 0:m.IconLeft)?r:tp;return(0,s.jsxs)("div",{className:l.nav,style:i.nav,children:[!e.hidePrevious&&(0,s.jsx)(tv,{name:"previous-month","aria-label":f,className:h,style:i.nav_button_previous,disabled:!e.previousMonth,onClick:e.onPreviousClick,children:"rtl"===a?(0,s.jsx)(v,{className:l.nav_icon,style:i.nav_icon}):(0,s.jsx)(g,{className:l.nav_icon,style:i.nav_icon})}),!e.hideNext&&(0,s.jsx)(tv,{name:"next-month","aria-label":p,className:b,style:i.nav_button_next,disabled:!e.nextMonth,onClick:e.onNextClick,children:"rtl"===a?(0,s.jsx)(g,{className:l.nav_icon,style:i.nav_icon}):(0,s.jsx)(v,{className:l.nav_icon,style:i.nav_icon})})]})}function tw(e){var t=to().numberOfMonths,r=tf(),n=r.previousMonth,a=r.nextMonth,o=r.goToMonth,l=r.displayMonths,i=l.findIndex(function(t){return ef(e.displayMonth,t)}),u=0===i,d=i===l.length-1;return(0,s.jsx)(tg,{displayMonth:e.displayMonth,hideNext:t>1&&(u||!d),hidePrevious:t>1&&(d||!u),nextMonth:a,previousMonth:n,onPreviousClick:function(){n&&o(n)},onNextClick:function(){a&&o(a)}})}function ty(e){var t,r,n=to(),a=n.classNames,o=n.disableNavigation,l=n.styles,i=n.captionLayout,u=n.components,d=null!=(t=null==u?void 0:u.CaptionLabel)?t:tl;return r=o?(0,s.jsx)(d,{id:e.id,displayMonth:e.displayMonth}):"dropdown"===i?(0,s.jsx)(th,{displayMonth:e.displayMonth,id:e.id}):"dropdown-buttons"===i?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(th,{displayMonth:e.displayMonth,displayIndex:e.displayIndex,id:e.id}),(0,s.jsx)(tw,{displayMonth:e.displayMonth,displayIndex:e.displayIndex,id:e.id})]}):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(d,{id:e.id,displayMonth:e.displayMonth,displayIndex:e.displayIndex}),(0,s.jsx)(tw,{displayMonth:e.displayMonth,id:e.id})]}),(0,s.jsx)("div",{className:a.caption,style:l.caption,children:r})}function tx(e){var t=to(),r=t.footer,n=t.styles,a=t.classNames.tfoot;return r?(0,s.jsx)("tfoot",{className:a,style:n.tfoot,children:(0,s.jsx)("tr",{children:(0,s.jsx)("td",{colSpan:8,children:r})})}):(0,s.jsx)(s.Fragment,{})}function tk(){var e=to(),t=e.classNames,r=e.styles,n=e.showWeekNumber,a=e.locale,o=e.weekStartsOn,l=e.ISOWeek,i=e.formatters.formatWeekdayName,u=e.labels.labelWeekday,d=function(e,t,r){for(var n=r?Y(new Date):I(new Date,{locale:e,weekStartsOn:t}),a=[],o=0;o<7;o++){var l=(0,g.addDays)(n,o);a.push(l)}return a}(a,o,l);return(0,s.jsxs)("tr",{style:r.head_row,className:t.head_row,children:[n&&(0,s.jsx)("td",{style:r.head_cell,className:t.head_cell}),d.map(function(e,n){return(0,s.jsx)("th",{scope:"col",className:t.head_cell,style:r.head_cell,"aria-label":u(e,{locale:a}),children:i(e,{locale:a})},n)})]})}function tM(){var e,t=to(),r=t.classNames,n=t.styles,a=t.components,o=null!=(e=null==a?void 0:a.HeadRow)?e:tk;return(0,s.jsx)("thead",{style:n.head,className:r.head,children:(0,s.jsx)(o,{})})}function tD(e){var t=to(),r=t.locale,n=t.formatters.formatDay;return(0,s.jsx)(s.Fragment,{children:n(e.date,{locale:r})})}var tN=(0,i.createContext)(void 0);function tE(e){return e7(e.initialProps)?(0,s.jsx)(tS,{initialProps:e.initialProps,children:e.children}):(0,s.jsx)(tN.Provider,{value:{selected:void 0,modifiers:{disabled:[]}},children:e.children})}function tS(e){var t=e.initialProps,r=e.children,n=t.selected,a=t.min,o=t.max,l={disabled:[]};return n&&l.disabled.push(function(e){var t=o&&n.length>o-1,r=n.some(function(t){return ep(t,e)});return!!(t&&!r)}),(0,s.jsx)(tN.Provider,{value:{selected:n,onDayClick:function(e,r,l){var s,i;if((null==(s=t.onDayClick)||s.call(t,e,r,l),!r.selected||!a||(null==n?void 0:n.length)!==a)&&!(!r.selected&&o&&(null==n?void 0:n.length)===o)){var u=n?e6([],n,!0):[];if(r.selected){var d=u.findIndex(function(t){return ep(e,t)});u.splice(d,1)}else u.push(e);null==(i=t.onSelect)||i.call(t,u,e,r,l)}},modifiers:l},children:r})}function tP(){var e=(0,i.useContext)(tN);if(!e)throw Error("useSelectMultiple must be used within a SelectMultipleProvider");return e}var tT=(0,i.createContext)(void 0);function tC(e){return e8(e.initialProps)?(0,s.jsx)(t_,{initialProps:e.initialProps,children:e.children}):(0,s.jsx)(tT.Provider,{value:{selected:void 0,modifiers:{range_start:[],range_end:[],range_middle:[],disabled:[]}},children:e.children})}function t_(e){var t=e.initialProps,r=e.children,n=t.selected,a=n||{},o=a.from,l=a.to,i=t.min,u=t.max,d={range_start:[],range_end:[],range_middle:[],disabled:[]};if(o?(d.range_start=[o],l?(d.range_end=[l],ep(o,l)||(d.range_middle=[{after:o,before:l}])):d.range_end=[o]):l&&(d.range_start=[l],d.range_end=[l]),i&&(o&&!l&&d.disabled.push({after:w(o,i-1),before:(0,g.addDays)(o,i-1)}),o&&l&&d.disabled.push({after:o,before:(0,g.addDays)(o,i-1)}),!o&&l&&d.disabled.push({after:w(l,i-1),before:(0,g.addDays)(l,i-1)})),u){if(o&&!l&&(d.disabled.push({before:(0,g.addDays)(o,-u+1)}),d.disabled.push({after:(0,g.addDays)(o,u-1)})),o&&l){var c=u-(O(l,o)+1);d.disabled.push({before:w(o,c)}),d.disabled.push({after:(0,g.addDays)(l,c)})}!o&&l&&(d.disabled.push({before:(0,g.addDays)(l,-u+1)}),d.disabled.push({after:(0,g.addDays)(l,u-1)}))}return(0,s.jsx)(tT.Provider,{value:{selected:n,onDayClick:function(e,r,a){null==(u=t.onDayClick)||u.call(t,e,r,a);var o,l,s,i,u,d,c=(o=e,s=(l=n||{}).from,i=l.to,s&&i?ep(i,o)&&ep(s,o)?void 0:ep(i,o)?{from:i,to:void 0}:ep(s,o)?void 0:eb(s,o)?{from:o,to:i}:{from:s,to:o}:i?eb(o,i)?{from:i,to:o}:{from:o,to:i}:s?eh(o,s)?{from:o,to:s}:{from:s,to:o}:{from:o,to:void 0});null==(d=t.onSelect)||d.call(t,c,e,r,a)},modifiers:d},children:r})}function tj(){var e=(0,i.useContext)(tT);if(!e)throw Error("useSelectRange must be used within a SelectRangeProvider");return e}function tL(e){return Array.isArray(e)?e6([],e,!0):void 0!==e?[e]:[]}(o=l||(l={})).Outside="outside",o.Disabled="disabled",o.Selected="selected",o.Hidden="hidden",o.Today="today",o.RangeStart="range_start",o.RangeEnd="range_end",o.RangeMiddle="range_middle";var tF=l.Selected,tO=l.Disabled,tI=l.Hidden,tY=l.Today,tW=l.RangeEnd,tH=l.RangeMiddle,tR=l.RangeStart,tB=l.Outside,tq=(0,i.createContext)(void 0);function tA(e){var t,r,n,a,o=to(),l=tP(),i=tj(),u=((t={})[tF]=tL(o.selected),t[tO]=tL(o.disabled),t[tI]=tL(o.hidden),t[tY]=[o.today],t[tW]=[],t[tH]=[],t[tR]=[],t[tB]=[],r=t,o.fromDate&&r[tO].push({before:o.fromDate}),o.toDate&&r[tO].push({after:o.toDate}),e7(o)?r[tO]=r[tO].concat(l.modifiers[tO]):e8(o)&&(r[tO]=r[tO].concat(i.modifiers[tO]),r[tR]=i.modifiers[tR],r[tH]=i.modifiers[tH],r[tW]=i.modifiers[tW]),r),d=(n=o.modifiers,a={},Object.entries(n).forEach(function(e){var t=e[0],r=e[1];a[t]=tL(r)}),a),c=e5(e5({},u),d);return(0,s.jsx)(tq.Provider,{value:c,children:e.children})}function tQ(){var e=(0,i.useContext)(tq);if(!e)throw Error("useModifiers must be used within a ModifiersProvider");return e}function tG(e,t,r){var n=Object.keys(t).reduce(function(r,n){return t[n].some(function(t){if("boolean"==typeof t)return t;if(ee(t))return ep(e,t);if(Array.isArray(t)&&t.every(ee))return t.includes(e);if(t&&"object"==typeof t&&"from"in t)return n=t.from,a=t.to,n&&a?(0>O(a,n)&&(n=(r=[a,n])[0],a=r[1]),O(e,n)>=0&&O(a,e)>=0):a?ep(a,e):!!n&&ep(n,e);if(t&&"object"==typeof t&&"dayOfWeek"in t)return t.dayOfWeek.includes(e.getDay());if(t&&"object"==typeof t&&"before"in t&&"after"in t){var r,n,a,o=O(t.before,e),l=O(t.after,e),s=o>0,i=l<0;return eb(t.before,t.after)?i&&s:s||i}return t&&"object"==typeof t&&"after"in t?O(e,t.after)>0:t&&"object"==typeof t&&"before"in t?O(t.before,e)>0:"function"==typeof t&&t(e)})&&r.push(n),r},[]),a={};return n.forEach(function(e){return a[e]=!0}),r&&!ef(e,r)&&(a.outside=!0),a}var tz=(0,i.createContext)(void 0);function tV(e){var t=tf(),r=tQ(),n=(0,i.useState)(),a=n[0],o=n[1],l=(0,i.useState)(),u=l[0],d=l[1],c=function(e,t){for(var r,n,a=p(e[0]),o=eu(e[e.length-1]),l=a;l<=o;){var s=tG(l,t);if(!(!s.disabled&&!s.hidden)){l=(0,g.addDays)(l,1);continue}if(s.selected)return l;s.today&&!n&&(n=l),r||(r=l),l=(0,g.addDays)(l,1)}return n||r}(t.displayMonths,r),m=(null!=a?a:u&&t.isDateDisplayed(u))?u:c,f=function(e){o(e)},h=to(),b=function(e,n){if(a){var o=function e(t,r){var n=r.moveBy,a=r.direction,o=r.context,l=r.modifiers,s=r.retry,i=void 0===s?{count:0,lastFocused:t}:s,u=o.weekStartsOn,d=o.fromDate,c=o.toDate,m=o.locale,f=({day:g.addDays,week:ev,month:y.addMonths,year:eg,startOfWeek:function(e){return o.ISOWeek?Y(e):I(e,{locale:m,weekStartsOn:u})},endOfWeek:function(e){return o.ISOWeek?ey(e):ew(e,{locale:m,weekStartsOn:u})}})[n](t,"after"===a?1:-1);"before"===a&&d?f=D([d,f]):"after"===a&&c&&(f=N([c,f]));var h=!0;if(l){var p=tG(f,l);h=!p.disabled&&!p.hidden}return h?f:i.count>365?i.lastFocused:e(f,{moveBy:n,direction:a,context:o,modifiers:l,retry:e5(e5({},i),{count:i.count+1})})}(a,{moveBy:e,direction:n,context:h,modifiers:r});ep(a,o)||(t.goToDate(o,a),f(o))}};return(0,s.jsx)(tz.Provider,{value:{focusedDay:a,focusTarget:m,blur:function(){d(a),o(void 0)},focus:f,focusDayAfter:function(){return b("day","after")},focusDayBefore:function(){return b("day","before")},focusWeekAfter:function(){return b("week","after")},focusWeekBefore:function(){return b("week","before")},focusMonthBefore:function(){return b("month","before")},focusMonthAfter:function(){return b("month","after")},focusYearBefore:function(){return b("year","before")},focusYearAfter:function(){return b("year","after")},focusStartOfWeek:function(){return b("startOfWeek","before")},focusEndOfWeek:function(){return b("endOfWeek","after")}},children:e.children})}function t$(){var e=(0,i.useContext)(tz);if(!e)throw Error("useFocusContext must be used within a FocusProvider");return e}var tK=(0,i.createContext)(void 0);function tX(e){return e9(e.initialProps)?(0,s.jsx)(tZ,{initialProps:e.initialProps,children:e.children}):(0,s.jsx)(tK.Provider,{value:{selected:void 0},children:e.children})}function tZ(e){var t=e.initialProps,r=e.children,n={selected:t.selected,onDayClick:function(e,r,n){var a,o,l;if(null==(a=t.onDayClick)||a.call(t,e,r,n),r.selected&&!t.required){null==(o=t.onSelect)||o.call(t,void 0,e,r,n);return}null==(l=t.onSelect)||l.call(t,e,e,r,n)}};return(0,s.jsx)(tK.Provider,{value:n,children:r})}function tU(){var e=(0,i.useContext)(tK);if(!e)throw Error("useSelectSingle must be used within a SelectSingleProvider");return e}function tJ(e){var t,r,n,a,o,u,d,c,m,f,h,p,b,v,g,w,y,x,k,M,D,N,E,S,P,T,C,_,j,L,F,O,I,Y,W,H,R,B,q,A,Q,G,z=(0,i.useRef)(null),V=(t=e.date,r=e.displayMonth,u=to(),d=t$(),c=tG(t,tQ(),r),m=to(),f=tU(),h=tP(),p=tj(),v=(b=t$()).focusDayAfter,g=b.focusDayBefore,w=b.focusWeekAfter,y=b.focusWeekBefore,x=b.blur,k=b.focus,M=b.focusMonthBefore,D=b.focusMonthAfter,N=b.focusYearBefore,E=b.focusYearAfter,S=b.focusStartOfWeek,P=b.focusEndOfWeek,T={onClick:function(e){var r,n,a,o;e9(m)?null==(r=f.onDayClick)||r.call(f,t,c,e):e7(m)?null==(n=h.onDayClick)||n.call(h,t,c,e):e8(m)?null==(a=p.onDayClick)||a.call(p,t,c,e):null==(o=m.onDayClick)||o.call(m,t,c,e)},onFocus:function(e){var r;k(t),null==(r=m.onDayFocus)||r.call(m,t,c,e)},onBlur:function(e){var r;x(),null==(r=m.onDayBlur)||r.call(m,t,c,e)},onKeyDown:function(e){var r;switch(e.key){case"ArrowLeft":e.preventDefault(),e.stopPropagation(),"rtl"===m.dir?v():g();break;case"ArrowRight":e.preventDefault(),e.stopPropagation(),"rtl"===m.dir?g():v();break;case"ArrowDown":e.preventDefault(),e.stopPropagation(),w();break;case"ArrowUp":e.preventDefault(),e.stopPropagation(),y();break;case"PageUp":e.preventDefault(),e.stopPropagation(),e.shiftKey?N():M();break;case"PageDown":e.preventDefault(),e.stopPropagation(),e.shiftKey?E():D();break;case"Home":e.preventDefault(),e.stopPropagation(),S();break;case"End":e.preventDefault(),e.stopPropagation(),P()}null==(r=m.onDayKeyDown)||r.call(m,t,c,e)},onKeyUp:function(e){var r;null==(r=m.onDayKeyUp)||r.call(m,t,c,e)},onMouseEnter:function(e){var r;null==(r=m.onDayMouseEnter)||r.call(m,t,c,e)},onMouseLeave:function(e){var r;null==(r=m.onDayMouseLeave)||r.call(m,t,c,e)},onPointerEnter:function(e){var r;null==(r=m.onDayPointerEnter)||r.call(m,t,c,e)},onPointerLeave:function(e){var r;null==(r=m.onDayPointerLeave)||r.call(m,t,c,e)},onTouchCancel:function(e){var r;null==(r=m.onDayTouchCancel)||r.call(m,t,c,e)},onTouchEnd:function(e){var r;null==(r=m.onDayTouchEnd)||r.call(m,t,c,e)},onTouchMove:function(e){var r;null==(r=m.onDayTouchMove)||r.call(m,t,c,e)},onTouchStart:function(e){var r;null==(r=m.onDayTouchStart)||r.call(m,t,c,e)}},C=to(),_=tU(),j=tP(),L=tj(),F=e9(C)?_.selected:e7(C)?j.selected:e8(C)?L.selected:void 0,O=!!(u.onDayClick||"default"!==u.mode),(0,i.useEffect)(function(){var e;c.outside||!d.focusedDay||O&&ep(d.focusedDay,t)&&(null==(e=z.current)||e.focus())},[d.focusedDay,t,z,O,c.outside]),Y=(I=[u.classNames.day],Object.keys(c).forEach(function(e){var t=u.modifiersClassNames[e];if(t)I.push(t);else if(Object.values(l).includes(e)){var r=u.classNames["day_".concat(e)];r&&I.push(r)}}),I).join(" "),W=e5({},u.styles.day),Object.keys(c).forEach(function(e){var t;W=e5(e5({},W),null==(t=u.modifiersStyles)?void 0:t[e])}),H=W,R=!!(c.outside&&!u.showOutsideDays||c.hidden),B=null!=(o=null==(a=u.components)?void 0:a.DayContent)?o:tD,q={style:H,className:Y,children:(0,s.jsx)(B,{date:t,displayMonth:r,activeModifiers:c}),role:"gridcell"},A=d.focusTarget&&ep(d.focusTarget,t)&&!c.outside,Q=d.focusedDay&&ep(d.focusedDay,t),G=e5(e5(e5({},q),((n={disabled:c.disabled,role:"gridcell"})["aria-selected"]=c.selected,n.tabIndex=Q||A?0:-1,n)),T),{isButton:O,isHidden:R,activeModifiers:c,selectedDays:F,buttonProps:G,divProps:q});return V.isHidden?(0,s.jsx)("div",{role:"gridcell"}):V.isButton?(0,s.jsx)(tv,e5({name:"day",ref:z},V.buttonProps)):(0,s.jsx)("div",e5({},V.divProps))}function t0(e){var t=e.number,r=e.dates,n=to(),a=n.onWeekNumberClick,o=n.styles,l=n.classNames,i=n.locale,u=n.labels.labelWeekNumber,d=(0,n.formatters.formatWeekNumber)(Number(t),{locale:i});if(!a)return(0,s.jsx)("span",{className:l.weeknumber,style:o.weeknumber,children:d});var c=u(Number(t),{locale:i});return(0,s.jsx)(tv,{name:"week-number","aria-label":c,className:l.weeknumber,style:o.weeknumber,onClick:function(e){a(t,r,e)},children:d})}function t1(e){var t,r,n,a=to(),o=a.styles,l=a.classNames,i=a.showWeekNumber,u=a.components,d=null!=(t=null==u?void 0:u.Day)?t:tJ,c=null!=(r=null==u?void 0:u.WeekNumber)?r:t0;return i&&(n=(0,s.jsx)("td",{className:l.cell,style:o.cell,children:(0,s.jsx)(c,{number:e.weekNumber,dates:e.dates})})),(0,s.jsxs)("tr",{className:l.row,style:o.row,children:[n,e.dates.map(function(t){return(0,s.jsx)("td",{className:l.cell,style:o.cell,role:"presentation",children:(0,s.jsx)(d,{displayMonth:e.displayMonth,date:t})},Math.trunc((0,m.toDate)(t)/1e3))})]})}function t2(e,t,r){for(var n=(null==r?void 0:r.ISOWeek)?ey(t):ew(t,r),a=(null==r?void 0:r.ISOWeek)?Y(e):I(e,r),o=O(n,a),l=[],s=0;s<=o;s++)l.push((0,g.addDays)(a,s));return l.reduce(function(e,t){var n=(null==r?void 0:r.ISOWeek)?H(t):B(t,r),a=e.find(function(e){return e.weekNumber===n});return a?a.dates.push(t):e.push({weekNumber:n,dates:[t]}),e},[])}function t4(e){var t,r,n,a=to(),o=a.locale,l=a.classNames,i=a.styles,u=a.hideHead,d=a.fixedWeeks,c=a.components,f=a.weekStartsOn,h=a.firstWeekContainsDate,b=a.ISOWeek,v=function(e,t){var r=t2(p(e),eu(e),t);if(null==t?void 0:t.useFixedWeeks){let d,c,f,h;var n,a,o=(c=(d=(0,m.toDate)(e)).getMonth(),d.setFullYear(d.getFullYear(),c+1,0),d.setHours(0,0,0,0),n=d,a=p(e),f=I(n,t),h=I(a,t),Math.round((f-F(f)-(h-F(h)))/6048e5)+1);if(o<6){var l=r[r.length-1],s=l.dates[l.dates.length-1],i=ev(s,6-o),u=t2(ev(s,1),i,t);r.push.apply(r,u)}}return r}(e.displayMonth,{useFixedWeeks:!!d,ISOWeek:b,locale:o,weekStartsOn:f,firstWeekContainsDate:h}),g=null!=(t=null==c?void 0:c.Head)?t:tM,w=null!=(r=null==c?void 0:c.Row)?r:t1,y=null!=(n=null==c?void 0:c.Footer)?n:tx;return(0,s.jsxs)("table",{id:e.id,className:l.table,style:i.table,role:"grid","aria-labelledby":e["aria-labelledby"],children:[!u&&(0,s.jsx)(g,{}),(0,s.jsx)("tbody",{className:l.tbody,style:i.tbody,children:v.map(function(t){return(0,s.jsx)(w,{displayMonth:e.displayMonth,dates:t.dates,weekNumber:t.weekNumber},t.weekNumber)})}),(0,s.jsx)(y,{displayMonth:e.displayMonth})]})}var t3="u">typeof window&&window.document&&window.document.createElement?i.useLayoutEffect:i.useEffect,t5=!1,t6=0;function t7(){return"react-day-picker-".concat(++t6)}function t8(e){var t,r,n,a,o,l,u,d,c=to(),m=c.dir,f=c.classNames,h=c.styles,p=c.components,b=tf().displayMonths,v=(n=null!=(t=c.id?"".concat(c.id,"-").concat(e.displayIndex):void 0)?t:t5?t7():null,o=(a=(0,i.useState)(n))[0],l=a[1],t3(function(){null===o&&l(t7())},[]),(0,i.useEffect)(function(){!1===t5&&(t5=!0)},[]),null!=(r=null!=t?t:o)?r:void 0),g=c.id?"".concat(c.id,"-grid-").concat(e.displayIndex):void 0,w=[f.month],y=h.month,x=0===e.displayIndex,k=e.displayIndex===b.length-1,M=!x&&!k;"rtl"===m&&(k=(u=[x,k])[0],x=u[1]),x&&(w.push(f.caption_start),y=e5(e5({},y),h.caption_start)),k&&(w.push(f.caption_end),y=e5(e5({},y),h.caption_end)),M&&(w.push(f.caption_between),y=e5(e5({},y),h.caption_between));var D=null!=(d=null==p?void 0:p.Caption)?d:ty;return(0,s.jsxs)("div",{className:w.join(" "),style:y,children:[(0,s.jsx)(D,{id:v,displayMonth:e.displayMonth,displayIndex:e.displayIndex}),(0,s.jsx)(t4,{id:g,"aria-labelledby":v,displayMonth:e.displayMonth})]},e.displayIndex)}function t9(e){var t=to(),r=t.classNames,n=t.styles;return(0,s.jsx)("div",{className:r.months,style:n.months,children:e.children})}function re(e){var t,r,n=e.initialProps,a=to(),o=t$(),l=tf(),u=(0,i.useState)(!1),d=u[0],c=u[1];(0,i.useEffect)(function(){a.initialFocus&&o.focusTarget&&(d||(o.focus(o.focusTarget),c(!0)))},[a.initialFocus,d,o.focus,o.focusTarget,o]);var m=[a.classNames.root,a.className];a.numberOfMonths>1&&m.push(a.classNames.multiple_months),a.showWeekNumber&&m.push(a.classNames.with_weeknumber);var f=e5(e5({},a.styles.root),a.style),h=Object.keys(n).filter(function(e){return e.startsWith("data-")}).reduce(function(e,t){var r;return e5(e5({},e),((r={})[t]=n[t],r))},{}),p=null!=(r=null==(t=n.components)?void 0:t.Months)?r:t9;return(0,s.jsx)("div",e5({className:m.join(" "),style:f,dir:a.dir,id:a.id,nonce:n.nonce,title:n.title,lang:n.lang},h,{children:(0,s.jsx)(p,{children:l.displayMonths.map(function(e,t){return(0,s.jsx)(t8,{displayIndex:t,displayMonth:e},t)})})}))}function rt(e){var t=e.children,r=function(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&0>t.indexOf(n)&&(r[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols)for(var a=0,n=Object.getOwnPropertySymbols(e);at.indexOf(n[a])&&Object.prototype.propertyIsEnumerable.call(e,n[a])&&(r[n[a]]=e[n[a]]);return r}(e,["children"]);return(0,s.jsx)(ta,{initialProps:r,children:(0,s.jsx)(tm,{children:(0,s.jsx)(tX,{initialProps:r,children:(0,s.jsx)(tE,{initialProps:r,children:(0,s.jsx)(tC,{initialProps:r,children:(0,s.jsx)(tA,{children:(0,s.jsx)(tV,{children:t})})})})})})})}function rr(e){return(0,s.jsx)(rt,e5({},e,{children:(0,s.jsx)(re,{initialProps:e})}))}let rn=e=>{var t=(0,u.__rest)(e,[]);return i.default.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor"},t),i.default.createElement("path",{d:"M10.8284 12.0007L15.7782 16.9504L14.364 18.3646L8 12.0007L14.364 5.63672L15.7782 7.05093L10.8284 12.0007Z"}))},ra=e=>{var t=(0,u.__rest)(e,[]);return i.default.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor"},t),i.default.createElement("path",{d:"M13.1717 12.0007L8.22192 7.05093L9.63614 5.63672L16.0001 12.0007L9.63614 18.3646L8.22192 16.9504L13.1717 12.0007Z"}))},ro=e=>{var t=(0,u.__rest)(e,[]);return i.default.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor"},t),i.default.createElement("path",{d:"M4.83582 12L11.0429 18.2071L12.4571 16.7929L7.66424 12L12.4571 7.20712L11.0429 5.79291L4.83582 12ZM10.4857 12L16.6928 18.2071L18.107 16.7929L13.3141 12L18.107 7.20712L16.6928 5.79291L10.4857 12Z"}))},rl=e=>{var t=(0,u.__rest)(e,[]);return i.default.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor"},t),i.default.createElement("path",{d:"M19.1642 12L12.9571 5.79291L11.5429 7.20712L16.3358 12L11.5429 16.7929L12.9571 18.2071L19.1642 12ZM13.5143 12L7.30722 5.79291L5.89301 7.20712L10.6859 12L5.89301 16.7929L7.30722 18.2071L13.5143 12Z"}))};var rs=e.i(936325),ri=e.i(728889);let ru=e=>{var{onClick:t,icon:r}=e,n=(0,u.__rest)(e,["onClick","icon"]);return i.default.createElement("button",Object.assign({type:"button",className:(0,b.tremorTwMerge)("flex items-center justify-center p-1 h-7 w-7 outline-none focus:ring-2 transition duration-100 border border-tremor-border dark:border-dark-tremor-border hover:bg-tremor-background-muted dark:hover:bg-dark-tremor-background-muted rounded-tremor-small focus:border-tremor-brand-subtle select-none dark:focus:border-dark-tremor-brand-subtle focus:ring-tremor-brand-muted dark:focus:ring-dark-tremor-brand-muted text-tremor-content-subtle dark:text-dark-tremor-content-subtle hover:text-tremor-content dark:hover:text-dark-tremor-content")},n),i.default.createElement(ri.default,{onClick:t,icon:r,variant:"simple",color:"slate",size:"sm"}))};function rd(e){var{mode:t,defaultMonth:r,selected:n,onSelect:a,locale:o,disabled:l,enableYearNavigation:s,classNames:d,weekStartsOn:c=0}=e,m=(0,u.__rest)(e,["mode","defaultMonth","selected","onSelect","locale","disabled","enableYearNavigation","classNames","weekStartsOn"]);return i.default.createElement(rr,Object.assign({showOutsideDays:!0,mode:t,defaultMonth:r,selected:n,onSelect:a,locale:o,disabled:l,weekStartsOn:c,classNames:Object.assign({months:"flex flex-col sm:flex-row space-y-4 sm:space-x-4 sm:space-y-0",month:"space-y-4",caption:"flex justify-center pt-2 relative items-center",caption_label:"text-tremor-default text-tremor-content-emphasis dark:text-dark-tremor-content-emphasis font-medium",nav:"space-x-1 flex items-center",nav_button:"flex items-center justify-center p-1 h-7 w-7 outline-none focus:ring-2 transition duration-100 border border-tremor-border dark:border-dark-tremor-border hover:bg-tremor-background-muted dark:hover:bg-dark-tremor-background-muted rounded-tremor-small focus:border-tremor-brand-subtle dark:focus:border-dark-tremor-brand-subtle focus:ring-tremor-brand-muted dark:focus:ring-dark-tremor-brand-muted text-tremor-content-subtle dark:text-dark-tremor-content-subtle hover:text-tremor-content dark:hover:text-dark-tremor-content",nav_button_previous:"absolute left-1",nav_button_next:"absolute right-1",table:"w-full border-collapse space-y-1",head_row:"flex",head_cell:"w-9 font-normal text-center text-tremor-content-subtle dark:text-dark-tremor-content-subtle",row:"flex w-full mt-0.5",cell:"text-center p-0 relative focus-within:relative text-tremor-default text-tremor-content-emphasis dark:text-dark-tremor-content-emphasis",day:"h-9 w-9 p-0 hover:bg-tremor-background-subtle dark:hover:bg-dark-tremor-background-subtle outline-tremor-brand dark:outline-dark-tremor-brand rounded-tremor-default",day_today:"font-bold",day_selected:"aria-selected:bg-tremor-background-emphasis aria-selected:text-tremor-content-inverted dark:aria-selected:bg-dark-tremor-background-emphasis dark:aria-selected:text-dark-tremor-content-inverted ",day_disabled:"text-tremor-content-subtle dark:text-dark-tremor-content-subtle disabled:hover:bg-transparent",day_outside:"text-tremor-content-subtle dark:text-dark-tremor-content-subtle"},d),components:{IconLeft:e=>{var t=(0,u.__rest)(e,[]);return i.default.createElement(rn,Object.assign({className:"h-4 w-4"},t))},IconRight:e=>{var t=(0,u.__rest)(e,[]);return i.default.createElement(ra,Object.assign({className:"h-4 w-4"},t))},Caption:e=>{var t=(0,u.__rest)(e,[]);let{goToMonth:r,nextMonth:n,previousMonth:a,currentMonth:l}=tf();return i.default.createElement("div",{className:"flex justify-between items-center"},i.default.createElement("div",{className:"flex items-center space-x-1"},s&&i.default.createElement(ru,{onClick:()=>l&&r(eg(l,-1)),icon:ro}),i.default.createElement(ru,{onClick:()=>a&&r(a),icon:rn})),i.default.createElement(rs.default,{className:"text-tremor-default tabular-nums capitalize text-tremor-content-emphasis dark:text-dark-tremor-content-emphasis font-medium"},el(t.displayMonth,"LLLL yyy",{locale:o})),i.default.createElement("div",{className:"flex items-center space-x-1"},i.default.createElement(ru,{onClick:()=>n&&r(n),icon:ra}),s&&i.default.createElement(ru,{onClick:()=>l&&r(eg(l,1)),icon:rl})))}}},m))}rd.displayName="DateRangePicker";var rc=e.i(333771),rm=e.i(888288),rf=e.i(429427),rh=e.i(371330),rp=e.i(394487),rb=e.i(992704),rv=e.i(914189),rg=e.i(941444),rw=e.i(835696),ry=e.i(877891),rx=e.i(952744),rk=e.i(605083),rM=e.i(144279),rD=e.i(2788),rN=e.i(402155);let rE=(0,i.createContext)(null);function rS({children:e,node:t}){let[r,n]=(0,i.useState)(null),a=rP(null!=t?t:r);return i.default.createElement(rE.Provider,{value:a},e,null===a&&i.default.createElement(rD.Hidden,{features:rD.HiddenFeatures.Hidden,ref:e=>{var t,r;if(e){for(let a of null!=(r=null==(t=(0,rN.getOwnerDocument)(e))?void 0:t.querySelectorAll("html > *, body > *"))?r:[])if(a!==document.body&&a!==document.head&&a instanceof HTMLElement&&null!=a&&a.contains(e)){n(a);break}}}}))}function rP(e=null){var t;return null!=(t=(0,i.useContext)(rE))?t:e}var rT=e.i(101852),rC=e.i(294316),r_=e.i(401141),rj=((t=rj||{})[t.Forwards=0]="Forwards",t[t.Backwards=1]="Backwards",t);function rL(){let e=(0,i.useRef)(0);return(0,r_.useWindowEvent)(!0,"keydown",t=>{"Tab"===t.key&&(e.current=+!!t.shiftKey)},!0),e}var rF=e.i(83733),rO=e.i(674175),rI=e.i(919751),rY=e.i(233137),rW=e.i(233538),rH=e.i(652265),rR=e.i(397701),rB=e.i(700020),rq=e.i(998348),rA=e.i(635307),rQ=((r=rQ||{})[r.Open=0]="Open",r[r.Closed=1]="Closed",r),rG=((n=rG||{})[n.TogglePopover=0]="TogglePopover",n[n.ClosePopover=1]="ClosePopover",n[n.SetButton=2]="SetButton",n[n.SetButtonId=3]="SetButtonId",n[n.SetPanel=4]="SetPanel",n[n.SetPanelId=5]="SetPanelId",n);let rz={0:e=>({...e,popoverState:(0,rR.match)(e.popoverState,{0:1,1:0}),__demoMode:!1}),1:e=>1===e.popoverState?e:{...e,popoverState:1,__demoMode:!1},2:(e,t)=>e.button===t.button?e:{...e,button:t.button},3:(e,t)=>e.buttonId===t.buttonId?e:{...e,buttonId:t.buttonId},4:(e,t)=>e.panel===t.panel?e:{...e,panel:t.panel},5:(e,t)=>e.panelId===t.panelId?e:{...e,panelId:t.panelId}},rV=(0,i.createContext)(null);function r$(e){let t=(0,i.useContext)(rV);if(null===t){let t=Error(`<${e} /> is missing a parent component.`);throw Error.captureStackTrace&&Error.captureStackTrace(t,r$),t}return t}rV.displayName="PopoverContext";let rK=(0,i.createContext)(null);function rX(e){let t=(0,i.useContext)(rK);if(null===t){let t=Error(`<${e} /> is missing a parent component.`);throw Error.captureStackTrace&&Error.captureStackTrace(t,rX),t}return t}rK.displayName="PopoverAPIContext";let rZ=(0,i.createContext)(null);function rU(){return(0,i.useContext)(rZ)}rZ.displayName="PopoverGroupContext";let rJ=(0,i.createContext)(null);function r0(e,t){return(0,rR.match)(t.type,rz,e,t)}rJ.displayName="PopoverPanelContext";let r1=rB.RenderFeatures.RenderStrategy|rB.RenderFeatures.Static;function r2(e,t){let r=(0,i.useId)(),{id:n=`headlessui-popover-backdrop-${r}`,transition:a=!1,...o}=e,[{popoverState:l},s]=r$("Popover.Backdrop"),[u,d]=(0,i.useState)(null),c=(0,rC.useSyncRefs)(t,d),m=(0,rY.useOpenClosed)(),[f,h]=(0,rF.useTransition)(a,u,null!==m?(m&rY.State.Open)===rY.State.Open:0===l),p=(0,rv.useEvent)(e=>{if((0,rW.isDisabledReactIssue7711)(e.currentTarget))return e.preventDefault();s({type:1})}),b=(0,i.useMemo)(()=>({open:0===l}),[l]),v={ref:c,id:n,"aria-hidden":!0,onClick:p,...(0,rF.transitionDataAttributes)(h)};return(0,rB.useRender)()({ourProps:v,theirProps:o,slot:b,defaultTag:"div",features:r1,visible:f,name:"Popover.Backdrop"})}let r4=rB.RenderFeatures.RenderStrategy|rB.RenderFeatures.Static,r3=(0,rB.forwardRefWithAs)(function(e,t){var r,n,a;let o,{__demoMode:l=!1,...s}=e,u=(0,i.useRef)(null),d=(0,rC.useSyncRefs)(t,(0,rC.optionalRef)(e=>{u.current=e})),c=(0,i.useRef)([]),m=(0,i.useReducer)(r0,{__demoMode:l,popoverState:+!l,buttons:c,button:null,buttonId:null,panel:null,panelId:null,beforePanelSentinel:(0,i.createRef)(),afterPanelSentinel:(0,i.createRef)(),afterButtonSentinel:(0,i.createRef)()}),[{popoverState:f,button:h,buttonId:p,panel:b,panelId:v,beforePanelSentinel:g,afterPanelSentinel:w,afterButtonSentinel:y},x]=m,k=(0,rk.useOwnerDocument)(null!=(r=u.current)?r:h),M=(0,i.useMemo)(()=>{if(!h||!b)return!1;for(let e of document.querySelectorAll("body > *"))if(Number(null==e?void 0:e.contains(h))^Number(null==e?void 0:e.contains(b)))return!0;let e=(0,rH.getFocusableElements)(),t=e.indexOf(h),r=(t+e.length-1)%e.length,n=(t+1)%e.length,a=e[r],o=e[n];return!b.contains(a)&&!b.contains(o)},[h,b]),D=(0,rg.useLatestValue)(p),N=(0,rg.useLatestValue)(v),E=(0,i.useMemo)(()=>({buttonId:D,panelId:N,close:()=>x({type:1})}),[D,N,x]),S=rU(),P=null==S?void 0:S.registerPopover,T=(0,rv.useEvent)(()=>{var e;return null!=(e=null==S?void 0:S.isFocusWithinPopoverGroup())?e:(null==k?void 0:k.activeElement)&&((null==h?void 0:h.contains(k.activeElement))||(null==b?void 0:b.contains(k.activeElement)))});(0,i.useEffect)(()=>null==P?void 0:P(E),[P,E]);let[C,_]=(0,rA.useNestedPortals)(),j=rP(h),L=function({defaultContainers:e=[],portals:t,mainTreeNode:r}={}){let n=(0,rk.useOwnerDocument)(r),a=(0,rv.useEvent)(()=>{var a,o;let l=[];for(let t of e)null!==t&&(t instanceof HTMLElement?l.push(t):"current"in t&&t.current instanceof HTMLElement&&l.push(t.current));if(null!=t&&t.current)for(let e of t.current)l.push(e);for(let e of null!=(a=null==n?void 0:n.querySelectorAll("html > *, body > *"))?a:[])e!==document.body&&e!==document.head&&e instanceof HTMLElement&&"headlessui-portal-root"!==e.id&&(r&&(e.contains(r)||e.contains(null==(o=null==r?void 0:r.getRootNode())?void 0:o.host))||l.some(t=>e.contains(t))||l.push(e));return l});return{resolveContainers:a,contains:(0,rv.useEvent)(e=>a().some(t=>t.contains(e)))}}({mainTreeNode:j,portals:C,defaultContainers:[h,b]});n=null==k?void 0:k.defaultView,a="focus",o=(0,rg.useLatestValue)(e=>{var t,r,n,a,o,l;e.target!==window&&e.target instanceof HTMLElement&&0===f&&(T()||h&&b&&(L.contains(e.target)||null!=(r=null==(t=g.current)?void 0:t.contains)&&r.call(t,e.target)||null!=(a=null==(n=w.current)?void 0:n.contains)&&a.call(n,e.target)||null!=(l=null==(o=y.current)?void 0:o.contains)&&l.call(o,e.target)||x({type:1})))}),(0,i.useEffect)(()=>{function e(e){o.current(e)}return(n=null!=n?n:window).addEventListener(a,e,!0),()=>n.removeEventListener(a,e,!0)},[n,a,!0]),(0,rx.useOutsideClick)(0===f,L.resolveContainers,(e,t)=>{x({type:1}),(0,rH.isFocusableElement)(t,rH.FocusableMode.Loose)||(e.preventDefault(),null==h||h.focus())});let F=(0,rv.useEvent)(e=>{x({type:1});let t=e?e instanceof HTMLElement?e:"current"in e&&e.current instanceof HTMLElement?e.current:h:h;null==t||t.focus()}),O=(0,i.useMemo)(()=>({close:F,isPortalled:M}),[F,M]),I=(0,i.useMemo)(()=>({open:0===f,close:F}),[f,F]),Y=(0,rB.useRender)();return i.default.createElement(rS,{node:j},i.default.createElement(rI.FloatingProvider,null,i.default.createElement(rJ.Provider,{value:null},i.default.createElement(rV.Provider,{value:m},i.default.createElement(rK.Provider,{value:O},i.default.createElement(rO.CloseProvider,{value:F},i.default.createElement(rY.OpenClosedProvider,{value:(0,rR.match)(f,{0:rY.State.Open,1:rY.State.Closed})},i.default.createElement(_,null,Y({ourProps:{ref:d},theirProps:s,slot:I,defaultTag:"div",name:"Popover"})))))))))}),r5=(0,rB.forwardRefWithAs)(function(e,t){let r=(0,i.useId)(),{id:n=`headlessui-popover-button-${r}`,disabled:a=!1,autoFocus:o=!1,...l}=e,[s,u]=r$("Popover.Button"),{isPortalled:d}=rX("Popover.Button"),c=(0,i.useRef)(null),m=`headlessui-focus-sentinel-${(0,i.useId)()}`,f=rU(),h=null==f?void 0:f.closeOthers,p=null!==(0,i.useContext)(rJ);(0,i.useEffect)(()=>{if(!p)return u({type:3,buttonId:n}),()=>{u({type:3,buttonId:null})}},[p,n,u]);let[b]=(0,i.useState)(()=>Symbol()),v=(0,rC.useSyncRefs)(c,t,(0,rI.useFloatingReference)(),(0,rv.useEvent)(e=>{if(!p){if(e)s.buttons.current.push(b);else{let e=s.buttons.current.indexOf(b);-1!==e&&s.buttons.current.splice(e,1)}s.buttons.current.length>1&&console.warn("You are already using a but only 1 is supported."),e&&u({type:2,button:e})}})),g=(0,rC.useSyncRefs)(c,t),w=(0,rk.useOwnerDocument)(c),y=(0,rv.useEvent)(e=>{var t,r,n;if(p){if(1===s.popoverState)return;switch(e.key){case rq.Keys.Space:case rq.Keys.Enter:e.preventDefault(),null==(r=(t=e.target).click)||r.call(t),u({type:1}),null==(n=s.button)||n.focus()}}else switch(e.key){case rq.Keys.Space:case rq.Keys.Enter:e.preventDefault(),e.stopPropagation(),1===s.popoverState&&(null==h||h(s.buttonId)),u({type:0});break;case rq.Keys.Escape:if(0!==s.popoverState)return null==h?void 0:h(s.buttonId);if(!c.current||null!=w&&w.activeElement&&!c.current.contains(w.activeElement))return;e.preventDefault(),e.stopPropagation(),u({type:1})}}),x=(0,rv.useEvent)(e=>{p||e.key===rq.Keys.Space&&e.preventDefault()}),k=(0,rv.useEvent)(e=>{var t,r;(0,rW.isDisabledReactIssue7711)(e.currentTarget)||a||(p?(u({type:1}),null==(t=s.button)||t.focus()):(e.preventDefault(),e.stopPropagation(),1===s.popoverState&&(null==h||h(s.buttonId)),u({type:0}),null==(r=s.button)||r.focus()))}),M=(0,rv.useEvent)(e=>{e.preventDefault(),e.stopPropagation()}),{isFocusVisible:D,focusProps:N}=(0,rf.useFocusRing)({autoFocus:o}),{isHovered:E,hoverProps:S}=(0,rh.useHover)({isDisabled:a}),{pressed:P,pressProps:T}=(0,rp.useActivePress)({disabled:a}),C=0===s.popoverState,_=(0,i.useMemo)(()=>({open:C,active:P||C,disabled:a,hover:E,focus:D,autofocus:o}),[C,E,D,P,a,o]),j=(0,rM.useResolveButtonType)(e,s.button),L=p?(0,rB.mergeProps)({ref:g,type:j,onKeyDown:y,onClick:k,disabled:a||void 0,autoFocus:o},N,S,T):(0,rB.mergeProps)({ref:v,id:s.buttonId,type:j,"aria-expanded":0===s.popoverState,"aria-controls":s.panel?s.panelId:void 0,disabled:a||void 0,autoFocus:o,onKeyDown:y,onKeyUp:x,onClick:k,onMouseDown:M},N,S,T),F=rL(),O=(0,rv.useEvent)(()=>{let e=s.panel;e&&(0,rR.match)(F.current,{[rj.Forwards]:()=>(0,rH.focusIn)(e,rH.Focus.First),[rj.Backwards]:()=>(0,rH.focusIn)(e,rH.Focus.Last)})===rH.FocusResult.Error&&(0,rH.focusIn)((0,rH.getFocusableElements)().filter(e=>"true"!==e.dataset.headlessuiFocusGuard),(0,rR.match)(F.current,{[rj.Forwards]:rH.Focus.Next,[rj.Backwards]:rH.Focus.Previous}),{relativeTo:s.button})}),I=(0,rB.useRender)();return i.default.createElement(i.default.Fragment,null,I({ourProps:L,theirProps:l,slot:_,defaultTag:"button",name:"Popover.Button"}),C&&!p&&d&&i.default.createElement(rD.Hidden,{id:m,ref:s.afterButtonSentinel,features:rD.HiddenFeatures.Focusable,"data-headlessui-focus-guard":!0,as:"button",type:"button",onFocus:O}))}),r6=(0,rB.forwardRefWithAs)(r2),r7=(0,rB.forwardRefWithAs)(r2),r8=(0,rB.forwardRefWithAs)(function(e,t){let r=(0,i.useId)(),{id:n=`headlessui-popover-panel-${r}`,focus:a=!1,anchor:o,portal:l=!1,modal:s=!1,transition:u=!1,...d}=e,[c,m]=r$("Popover.Panel"),{close:f,isPortalled:h}=rX("Popover.Panel"),p=`headlessui-focus-sentinel-before-${r}`,b=`headlessui-focus-sentinel-after-${r}`,v=(0,i.useRef)(null),g=(0,rI.useResolvedAnchor)(o),[w,y]=(0,rI.useFloatingPanel)(g),x=(0,rI.useFloatingPanelProps)();g&&(l=!0);let[k,M]=(0,i.useState)(null),D=(0,rC.useSyncRefs)(v,t,g?w:null,(0,rv.useEvent)(e=>m({type:4,panel:e})),M),N=(0,rk.useOwnerDocument)(v);(0,rw.useIsoMorphicEffect)(()=>(m({type:5,panelId:n}),()=>{m({type:5,panelId:null})}),[n,m]);let E=(0,rY.useOpenClosed)(),[S,P]=(0,rF.useTransition)(u,k,null!==E?(E&rY.State.Open)===rY.State.Open:0===c.popoverState);(0,ry.useOnDisappear)(S,c.button,()=>{m({type:1})});let T=!c.__demoMode&&s&&S;(0,rT.useScrollLock)(T,N);let C=(0,rv.useEvent)(e=>{var t;if(e.key===rq.Keys.Escape){if(0!==c.popoverState||!v.current||null!=N&&N.activeElement&&!v.current.contains(N.activeElement))return;e.preventDefault(),e.stopPropagation(),m({type:1}),null==(t=c.button)||t.focus()}});(0,i.useEffect)(()=>{var t;e.static||1===c.popoverState&&(null==(t=e.unmount)||t)&&m({type:4,panel:null})},[c.popoverState,e.unmount,e.static,m]),(0,i.useEffect)(()=>{if(c.__demoMode||!a||0!==c.popoverState||!v.current)return;let e=null==N?void 0:N.activeElement;v.current.contains(e)||(0,rH.focusIn)(v.current,rH.Focus.First)},[c.__demoMode,a,v.current,c.popoverState]);let _=(0,i.useMemo)(()=>({open:0===c.popoverState,close:f}),[c.popoverState,f]),j=(0,rB.mergeProps)(g?x():{},{ref:D,id:n,onKeyDown:C,onBlur:a&&0===c.popoverState?e=>{var t,r,n,a,o;let l=e.relatedTarget;l&&v.current&&(null!=(t=v.current)&&t.contains(l)||(m({type:1}),(null!=(n=null==(r=c.beforePanelSentinel.current)?void 0:r.contains)&&n.call(r,l)||null!=(o=null==(a=c.afterPanelSentinel.current)?void 0:a.contains)&&o.call(a,l))&&l.focus({preventScroll:!0})))}:void 0,tabIndex:-1,style:{...d.style,...y,"--button-width":(0,rb.useElementSize)(c.button,!0).width},...(0,rF.transitionDataAttributes)(P)}),L=rL(),F=(0,rv.useEvent)(()=>{let e=v.current;e&&(0,rR.match)(L.current,{[rj.Forwards]:()=>{var t;(0,rH.focusIn)(e,rH.Focus.First)===rH.FocusResult.Error&&(null==(t=c.afterPanelSentinel.current)||t.focus())},[rj.Backwards]:()=>{var e;null==(e=c.button)||e.focus({preventScroll:!0})}})}),O=(0,rv.useEvent)(()=>{let e=v.current;e&&(0,rR.match)(L.current,{[rj.Forwards]:()=>{if(!c.button)return;let e=(0,rH.getFocusableElements)(),t=e.indexOf(c.button),r=e.slice(0,t+1),n=[...e.slice(t+1),...r];for(let e of n.slice())if("true"===e.dataset.headlessuiFocusGuard||null!=k&&k.contains(e)){let t=n.indexOf(e);-1!==t&&n.splice(t,1)}(0,rH.focusIn)(n,rH.Focus.First,{sorted:!1})},[rj.Backwards]:()=>{var t;(0,rH.focusIn)(e,rH.Focus.Previous)===rH.FocusResult.Error&&(null==(t=c.button)||t.focus())}})}),I=(0,rB.useRender)();return i.default.createElement(rY.ResetOpenClosedProvider,null,i.default.createElement(rJ.Provider,{value:n},i.default.createElement(rK.Provider,{value:{close:f,isPortalled:h}},i.default.createElement(rA.Portal,{enabled:!!l&&(e.static||S)},S&&h&&i.default.createElement(rD.Hidden,{id:p,ref:c.beforePanelSentinel,features:rD.HiddenFeatures.Focusable,"data-headlessui-focus-guard":!0,as:"button",type:"button",onFocus:F}),I({ourProps:j,theirProps:d,slot:_,defaultTag:"div",features:r4,visible:S,name:"Popover.Panel"}),S&&h&&i.default.createElement(rD.Hidden,{id:b,ref:c.afterPanelSentinel,features:rD.HiddenFeatures.Focusable,"data-headlessui-focus-guard":!0,as:"button",type:"button",onFocus:O})))))}),r9=Object.assign(r3,{Button:r5,Backdrop:r7,Overlay:r6,Panel:r8,Group:(0,rB.forwardRefWithAs)(function(e,t){let r=(0,i.useRef)(null),n=(0,rC.useSyncRefs)(r,t),[a,o]=(0,i.useState)([]),l=(0,rv.useEvent)(e=>{o(t=>{let r=t.indexOf(e);if(-1!==r){let e=t.slice();return e.splice(r,1),e}return t})}),s=(0,rv.useEvent)(e=>(o(t=>[...t,e]),()=>l(e))),u=(0,rv.useEvent)(()=>{var e;let t=(0,rN.getOwnerDocument)(r);if(!t)return!1;let n=t.activeElement;return!!(null!=(e=r.current)&&e.contains(n))||a.some(e=>{var r,a;return(null==(r=t.getElementById(e.buttonId.current))?void 0:r.contains(n))||(null==(a=t.getElementById(e.panelId.current))?void 0:a.contains(n))})}),d=(0,rv.useEvent)(e=>{for(let t of a)t.buttonId.current!==e&&t.close()}),c=(0,i.useMemo)(()=>({registerPopover:s,unregisterPopover:l,isFocusWithinPopoverGroup:u,closeOthers:d}),[s,l,u,d]),m=(0,i.useMemo)(()=>({}),[]),f=(0,rB.useRender)();return i.default.createElement(rS,null,i.default.createElement(rZ.Provider,{value:c},f({ourProps:{ref:n},theirProps:e,slot:m,defaultTag:"div",name:"Popover.Group"})))})});var ne=e.i(854056),nt=e.i(495470);let nr=h(),nn=i.default.forwardRef((e,t)=>{var r,n;let{value:a,defaultValue:o,onValueChange:l,enableSelect:s=!0,minDate:g,maxDate:w,placeholder:y="Select range",selectPlaceholder:x="Select range",disabled:k=!1,locale:M=j,enableClear:E=!0,displayFormat:S,children:P,className:T,enableYearNavigation:C=!1,weekStartsOn:_=0,disabledDates:L}=e,F=(0,u.__rest)(e,["value","defaultValue","onValueChange","enableSelect","minDate","maxDate","placeholder","selectPlaceholder","disabled","locale","enableClear","displayFormat","children","className","enableYearNavigation","weekStartsOn","disabledDates"]),[O,I]=(0,rm.default)(o,a),[Y,W]=(0,i.useState)(!1),[H,R]=(0,i.useState)(!1),B=(0,i.useMemo)(()=>{let e=[];return g&&e.push({before:g}),w&&e.push({after:w}),[...e,...null!=L?L:[]]},[g,w,L]),q=(0,i.useMemo)(()=>{let e=new Map;return P?i.default.Children.forEach(P,t=>{var r;e.set(t.props.value,{text:null!=(r=(0,v.getNodeText)(t))?r:t.props.value,from:t.props.from,to:t.props.to})}):ei.forEach(t=>{e.set(t.value,{text:t.text,from:t.from,to:nr})}),e},[P]),A=(0,i.useMemo)(()=>{if(P)return(0,v.constructValueToNameMapping)(P);let e=new Map;return ei.forEach(t=>e.set(t.value,t.text)),e},[P]),Q=(null==O?void 0:O.selectValue)||"",G=((e,t,r,n)=>{var a;if(r&&(e=null==(a=n.get(r))?void 0:a.from),e)return f(e&&!t?e:D([e,t]))})(null==O?void 0:O.from,g,Q,q),z=((e,t,r,n)=>{var a,o;if(r&&(e=f(null!=(o=null==(a=n.get(r))?void 0:a.to)?o:h())),e)return f(e&&!t?e:N([e,t]))})(null==O?void 0:O.to,w,Q,q),V=G||z?((e,t,r,n)=>{let a=(null==r?void 0:r.code)||"en-US";if(!e&&!t)return"";if(e&&!t)return n?el(e,n):e.toLocaleDateString(a,{year:"numeric",month:"short",day:"numeric"});if(e&&t){if(+(0,m.toDate)(e)==+(0,m.toDate)(t))return n?el(e,n):e.toLocaleDateString(a,{year:"numeric",month:"short",day:"numeric"});if(e.getMonth()===t.getMonth()&&e.getFullYear()===t.getFullYear())return n?`${el(e,n)} - ${el(t,n)}`:`${e.toLocaleDateString(a,{month:"short",day:"numeric"})} - + ${t.getDate()}, ${t.getFullYear()}`;{if(n)return`${el(e,n)} - ${el(t,n)}`;let r={year:"numeric",month:"short",day:"numeric"};return`${e.toLocaleDateString(a,r)} - + ${t.toLocaleDateString(a,r)}`}}return""})(G,z,M,S):y,$=p(null!=(n=null!=(r=null!=z?z:G)?r:w)?n:nr),K=E&&!k;return i.default.createElement("div",Object.assign({ref:t,className:(0,b.tremorTwMerge)("w-full min-w-[10rem] relative flex justify-between text-tremor-default max-w-sm shadow-tremor-input dark:shadow-dark-tremor-input rounded-tremor-default",T)},F),i.default.createElement(r9,{as:"div",className:(0,b.tremorTwMerge)("w-full",s?"rounded-l-tremor-default":"rounded-tremor-default",Y&&"ring-2 ring-tremor-brand-muted dark:ring-dark-tremor-brand-muted z-10")},i.default.createElement("div",{className:"relative w-full"},i.default.createElement(r5,{onFocus:()=>W(!0),onBlur:()=>W(!1),disabled:k,className:(0,b.tremorTwMerge)("w-full outline-none text-left whitespace-nowrap truncate focus:ring-2 transition duration-100 rounded-l-tremor-default flex flex-nowrap border pl-3 py-2","rounded-l-tremor-default border-tremor-border text-tremor-content-emphasis focus:border-tremor-brand-subtle focus:ring-tremor-brand-muted","dark:border-dark-tremor-border dark:text-dark-tremor-content-emphasis dark:focus:border-dark-tremor-brand-subtle dark:focus:ring-dark-tremor-brand-muted",s?"rounded-l-tremor-default":"rounded-tremor-default",K?"pr-8":"pr-4",(0,v.getSelectButtonColors)((0,v.hasValue)(G||z),k))},i.default.createElement(d,{className:(0,b.tremorTwMerge)(es("calendarIcon"),"flex-none shrink-0 h-5 w-5 -ml-0.5 mr-2","text-tremor-content-subtle","dark:text-dark-tremor-content-subtle"),"aria-hidden":"true"}),i.default.createElement("p",{className:"truncate"},V)),K&&G?i.default.createElement("button",{type:"button",className:(0,b.tremorTwMerge)("absolute outline-none inset-y-0 right-0 flex items-center transition duration-100 mr-4"),onClick:e=>{e.preventDefault(),null==l||l({}),I({})}},i.default.createElement(c.default,{className:(0,b.tremorTwMerge)(es("clearIcon"),"flex-none h-4 w-4","text-tremor-content-subtle","dark:text-dark-tremor-content-subtle")})):null),i.default.createElement(ne.Transition,{enter:"transition ease duration-100 transform",enterFrom:"opacity-0 -translate-y-4",enterTo:"opacity-100 translate-y-0",leave:"transition ease duration-100 transform",leaveFrom:"opacity-100 translate-y-0",leaveTo:"opacity-0 -translate-y-4"},i.default.createElement(r8,{anchor:"bottom start",focus:!0,className:(0,b.tremorTwMerge)("min-w-min divide-y overflow-y-auto outline-none rounded-tremor-default p-3 border [--anchor-gap:4px]","bg-tremor-background border-tremor-border divide-tremor-border shadow-tremor-dropdown","dark:bg-dark-tremor-background dark:border-dark-tremor-border dark:divide-dark-tremor-border dark:shadow-dark-tremor-dropdown")},i.default.createElement(rd,Object.assign({mode:"range",showOutsideDays:!0,defaultMonth:$,selected:{from:G,to:z},onSelect:e=>{null==l||l({from:null==e?void 0:e.from,to:null==e?void 0:e.to}),I({from:null==e?void 0:e.from,to:null==e?void 0:e.to})},locale:M,disabled:B,enableYearNavigation:C,classNames:{day_range_middle:(0,b.tremorTwMerge)("!rounded-none aria-selected:!bg-tremor-background-subtle aria-selected:dark:!bg-dark-tremor-background-subtle aria-selected:!text-tremor-content aria-selected:dark:!bg-dark-tremor-background-subtle"),day_range_start:"rounded-r-none rounded-l-tremor-small aria-selected:text-tremor-brand-inverted dark:aria-selected:text-dark-tremor-brand-inverted",day_range_end:"rounded-l-none rounded-r-tremor-small aria-selected:text-tremor-brand-inverted dark:aria-selected:text-dark-tremor-brand-inverted"},weekStartsOn:_},e))))),s&&i.default.createElement(nt.Listbox,{as:"div",className:(0,b.tremorTwMerge)("w-48 -ml-px rounded-r-tremor-default",H&&"ring-2 ring-tremor-brand-muted dark:ring-dark-tremor-brand-muted z-10"),value:Q,onChange:e=>{let{from:t,to:r}=q.get(e),n=null!=r?r:nr;null==l||l({from:t,to:n,selectValue:e}),I({from:t,to:n,selectValue:e})},disabled:k},({value:e})=>{var t;return i.default.createElement(i.default.Fragment,null,i.default.createElement(nt.ListboxButton,{onFocus:()=>R(!0),onBlur:()=>R(!1),className:(0,b.tremorTwMerge)("w-full outline-none text-left whitespace-nowrap truncate rounded-r-tremor-default transition duration-100 border px-4 py-2","border-tremor-border text-tremor-content-emphasis focus:border-tremor-brand-subtle","dark:border-dark-tremor-border dark:text-dark-tremor-content-emphasis dark:focus:border-dark-tremor-brand-subtle",(0,v.getSelectButtonColors)((0,v.hasValue)(e),k))},e&&null!=(t=A.get(e))?t:x),i.default.createElement(ne.Transition,{enter:"transition ease duration-100 transform",enterFrom:"opacity-0 -translate-y-4",enterTo:"opacity-100 translate-y-0",leave:"transition ease duration-100 transform",leaveFrom:"opacity-100 translate-y-0",leaveTo:"opacity-0 -translate-y-4"},i.default.createElement(nt.ListboxOptions,{anchor:"bottom end",className:(0,b.tremorTwMerge)("[--anchor-gap:4px] divide-y overflow-y-auto outline-none border min-w-44","shadow-tremor-dropdown bg-tremor-background border-tremor-border divide-tremor-border rounded-tremor-default","dark:shadow-dark-tremor-dropdown dark:bg-dark-tremor-background dark:border-dark-tremor-border dark:divide-dark-tremor-border")},null!=P?P:ei.map(e=>i.default.createElement(rc.default,{key:e.value,value:e.value},e.text)))))}))});nn.displayName="DateRangePicker";var na=e.i(599724);e.s(["default",0,({value:e,onValueChange:t,label:r="Select Time Range",className:n="",showTimeRange:a=!0})=>{let[o,l]=(0,i.useState)(!1),u=(0,i.useRef)(null),d=(0,i.useCallback)(e=>{l(!0),setTimeout(()=>l(!1),1500),t(e),requestIdleCallback(()=>{if(e.from){let r,n={...e},a=new Date(e.from);r=new Date(e.to?e.to:e.from),a.toDateString(),r.toDateString(),a.setHours(0,0,0,0),r.setHours(23,59,59,999),n.from=a,n.to=r,t(n)}},{timeout:100})},[t]),c=(0,i.useCallback)((e,t)=>{if(!e||!t)return"";let r=e=>e.toLocaleString("en-US",{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit",hour12:!0,timeZoneName:"short"});if(e.toDateString()!==t.toDateString())return`${r(e)} - ${r(t)}`;{let r=e.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"}),n=e.toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit",hour12:!0}),a=t.toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit",hour12:!0,timeZoneName:"short"});return`${r}: ${n} - ${a}`}},[]);return(0,s.jsxs)("div",{className:n,children:[r&&(0,s.jsx)(na.Text,{className:"mb-2",children:r}),(0,s.jsxs)("div",{className:"relative w-fit",children:[(0,s.jsx)("div",{ref:u,children:(0,s.jsx)(nn,{enableSelect:!0,value:e,onValueChange:d,placeholder:"Select date range",enableClear:!1,style:{zIndex:100}})}),o&&(0,s.jsx)("div",{className:"absolute top-1/2 animate-pulse",style:{left:"calc(100% + 8px)",transform:"translateY(-50%)",zIndex:110},children:(0,s.jsxs)("div",{className:"flex items-center gap-1 text-green-600 text-sm font-medium bg-white px-2 py-1 rounded-full border border-green-200 shadow-sm whitespace-nowrap",children:[(0,s.jsx)("div",{className:"w-3 h-3 bg-green-500 text-white rounded-full flex items-center justify-center text-xs",children:"✓"}),(0,s.jsx)("span",{className:"text-xs",children:"Selected"})]})})]}),a&&e.from&&e.to&&(0,s.jsx)(na.Text,{className:"mt-2 text-xs text-gray-500",children:c(e.from,e.to)})]})}],144267)}]); \ No newline at end of file diff --git a/litellm/proxy/_experimental/out/_next/static/chunks/0a671fedee641c02.js b/litellm/proxy/_experimental/out/_next/static/chunks/0a671fedee641c02.js new file mode 100644 index 00000000000..6fca76c9838 --- /dev/null +++ b/litellm/proxy/_experimental/out/_next/static/chunks/0a671fedee641c02.js @@ -0,0 +1 @@ +(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,241902,e=>{"use strict";var t,r=e.i(843476),s=e.i(271645),l=e.i(752978),a=e.i(994388),o=e.i(309426),i=e.i(599724),n=e.i(350967),c=e.i(653824),d=e.i(881073),m=e.i(197647),x=e.i(723731),u=e.i(404206),h=e.i(278587),p=e.i(764205),v=e.i(871943),g=e.i(360820),j=e.i(94629),f=e.i(152990),b=e.i(682830),y=e.i(269200),_=e.i(942232),w=e.i(977572),N=e.i(427612),S=e.i(64848),C=e.i(496020),I=e.i(592968),T=e.i(902555),k=e.i(916925);let A=({data:e,onView:t,onEdit:l,onDelete:a})=>{let[o,i]=s.default.useState([{id:"created_at",desc:!0}]),n=[{header:"Vector Store ID",accessorKey:"vector_store_id",cell:({row:e})=>{let s=e.original;return(0,r.jsx)("button",{onClick:()=>t(s.vector_store_id),className:"font-mono text-blue-500 bg-blue-50 hover:bg-blue-100 text-xs font-normal px-2 py-0.5 text-left w-full truncate whitespace-nowrap cursor-pointer max-w-[15ch]",children:s.vector_store_id.length>15?`${s.vector_store_id.slice(0,15)}...`:s.vector_store_id})}},{header:"Name",accessorKey:"vector_store_name",cell:({row:e})=>{let t=e.original;return(0,r.jsx)(I.Tooltip,{title:t.vector_store_name,children:(0,r.jsx)("span",{className:"text-xs",children:t.vector_store_name||"-"})})}},{header:"Description",accessorKey:"vector_store_description",cell:({row:e})=>{let t=e.original;return(0,r.jsx)(I.Tooltip,{title:t.vector_store_description,children:(0,r.jsx)("span",{className:"text-xs",children:t.vector_store_description||"-"})})}},{header:"Files",accessorKey:"vector_store_metadata",cell:({row:e})=>{let t=e.original,s=t.vector_store_metadata?.ingested_files||[];if(0===s.length)return(0,r.jsx)("span",{className:"text-xs text-gray-400",children:"-"});let l=s.map(e=>e.filename||e.file_url||"Unknown").join(", "),a=1===s.length?s[0].filename||s[0].file_url||"1 file":`${s.length} files`;return(0,r.jsx)(I.Tooltip,{title:l,children:(0,r.jsx)("span",{className:"text-xs text-blue-600",children:a})})}},{header:"Provider",accessorKey:"custom_llm_provider",cell:({row:e})=>{let t=e.original,{displayName:s,logo:l}=(0,k.getProviderLogoAndName)(t.custom_llm_provider);return(0,r.jsxs)("div",{className:"flex items-center space-x-2",children:[l&&(0,r.jsx)("img",{src:l,alt:s,className:"h-4 w-4"}),(0,r.jsx)("span",{className:"text-xs",children:s})]})}},{header:"Created At",accessorKey:"created_at",sortingFn:"datetime",cell:({row:e})=>{let t=e.original;return(0,r.jsx)("span",{className:"text-xs",children:new Date(t.created_at).toLocaleDateString()})}},{header:"Updated At",accessorKey:"updated_at",sortingFn:"datetime",cell:({row:e})=>{let t=e.original;return(0,r.jsx)("span",{className:"text-xs",children:new Date(t.updated_at).toLocaleDateString()})}},{id:"actions",header:"",cell:({row:e})=>{let t=e.original;return(0,r.jsxs)("div",{className:"flex space-x-2",children:[(0,r.jsx)(T.default,{variant:"Edit",tooltipText:"Edit vector store",onClick:()=>l(t.vector_store_id)}),(0,r.jsx)(T.default,{variant:"Delete",tooltipText:"Delete vector store",onClick:()=>a(t.vector_store_id)})]})}}],c=(0,f.useReactTable)({data:e,columns:n,state:{sorting:o},onSortingChange:i,getCoreRowModel:(0,b.getCoreRowModel)(),getSortedRowModel:(0,b.getSortedRowModel)(),enableSorting:!0});return(0,r.jsx)("div",{className:"rounded-lg custom-border relative",children:(0,r.jsx)("div",{className:"overflow-x-auto",children:(0,r.jsxs)(y.Table,{className:"[&_td]:py-0.5 [&_th]:py-1",children:[(0,r.jsx)(N.TableHead,{children:c.getHeaderGroups().map(e=>(0,r.jsx)(C.TableRow,{children:e.headers.map(e=>(0,r.jsx)(S.TableHeaderCell,{className:`py-1 h-8 ${"actions"===e.id?"sticky right-0 bg-white shadow-[-4px_0_8px_-6px_rgba(0,0,0,0.1)]":""}`,onClick:e.column.getToggleSortingHandler(),children:(0,r.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,r.jsx)("div",{className:"flex items-center",children:e.isPlaceholder?null:(0,f.flexRender)(e.column.columnDef.header,e.getContext())}),"actions"!==e.id&&(0,r.jsx)("div",{className:"w-4",children:e.column.getIsSorted()?({asc:(0,r.jsx)(g.ChevronUpIcon,{className:"h-4 w-4 text-blue-500"}),desc:(0,r.jsx)(v.ChevronDownIcon,{className:"h-4 w-4 text-blue-500"})})[e.column.getIsSorted()]:(0,r.jsx)(j.SwitchVerticalIcon,{className:"h-4 w-4 text-gray-400"})})]})},e.id))},e.id))}),(0,r.jsx)(_.TableBody,{children:c.getRowModel().rows.length>0?c.getRowModel().rows.map(e=>(0,r.jsx)(C.TableRow,{className:"h-8",children:e.getVisibleCells().map(e=>(0,r.jsx)(w.TableCell,{className:`py-0.5 max-h-8 overflow-hidden text-ellipsis whitespace-nowrap ${"actions"===e.column.id?"sticky right-0 bg-white shadow-[-4px_0_8px_-6px_rgba(0,0,0,0.1)]":""}`,children:(0,f.flexRender)(e.column.columnDef.cell,e.getContext())},e.id))},e.id)):(0,r.jsx)(C.TableRow,{children:(0,r.jsx)(w.TableCell,{colSpan:n.length,className:"h-8 text-center",children:(0,r.jsx)("div",{className:"text-center text-gray-500",children:(0,r.jsx)("p",{children:"No vector stores found"})})})})})]})})})};var L=e.i(779241),V=e.i(212931),O=e.i(808613),E=e.i(199133),D=e.i(311451),P=e.i(560445),F=e.i(827252),B=((t={}).Bedrock="Amazon Bedrock",t.S3Vectors="Amazon S3 Vectors",t.PgVector="PostgreSQL pgvector (LiteLLM Connector)",t.VertexRagEngine="Vertex AI RAG Engine",t.OpenAI="OpenAI",t.Azure="Azure OpenAI",t.Milvus="Milvus",t);let z={Bedrock:"bedrock",PgVector:"pg_vector",VertexRagEngine:"vertex_ai",OpenAI:"openai",Azure:"azure",Milvus:"milvus",S3Vectors:"s3_vectors"},R="../ui/assets/logos/",M={"Amazon Bedrock":`${R}bedrock.svg`,"PostgreSQL pgvector (LiteLLM Connector)":`${R}postgresql.svg`,"Vertex AI RAG Engine":`${R}google.svg`,OpenAI:`${R}openai_small.svg`,"Azure OpenAI":`${R}microsoft_azure.svg`,Milvus:`${R}milvus.svg`,"Amazon S3 Vectors":`${R}s3_vector.png`},q={bedrock:[],pg_vector:[{name:"api_base",label:"API Base",tooltip:"Enter the base URL of your deployed litellm-pgvector server (e.g., http://your-server:8000)",placeholder:"http://your-deployed-server:8000",required:!0,type:"text"},{name:"api_key",label:"API Key",tooltip:"Enter the API key from your deployed litellm-pgvector server",placeholder:"your-deployed-api-key",required:!0,type:"password"}],vertex_rag_engine:[],openai:[{name:"api_key",label:"API Key",tooltip:"Enter your OpenAI API key",placeholder:"sk-...",required:!0,type:"password"}],azure:[{name:"api_key",label:"API Key",tooltip:"Enter your Azure OpenAI API key",placeholder:"your-azure-api-key",required:!0,type:"password"},{name:"api_base",label:"API Base",tooltip:"Enter your Azure OpenAI endpoint (e.g., https://your-resource.openai.azure.com/)",placeholder:"https://your-resource.openai.azure.com/",required:!0,type:"text"}],milvus:[{name:"api_key",label:"API Key",tooltip:"To obtain a token, you should use a colon (:) to concatenate the username and password that you use to access your Milvus instance (e.g., username:password)",placeholder:"username:password or api key",required:!0,type:"password"},{name:"api_base",label:"API Base",tooltip:"Enter your Milvus endpoint (e.g., https://your-milvus-endpoint.com/)",placeholder:"https://your-milvus-endpoint.com/",required:!0,type:"text"},{name:"embedding_model",label:"Embedding Model",tooltip:"Select the embedding model to use",placeholder:"text-embedding-3-small",required:!0,type:"select"}],s3_vectors:[{name:"vector_bucket_name",label:"Vector Bucket Name",tooltip:"S3 bucket name for vector storage (will be auto-created if it doesn't exist)",placeholder:"my-vector-bucket",required:!0,type:"text"},{name:"index_name",label:"Index Name",tooltip:"Name for the vector index (optional, will be auto-generated if not provided)",placeholder:"my-vector-index",required:!1,type:"text"},{name:"aws_region_name",label:"AWS Region",tooltip:"AWS region where the S3 bucket is located (e.g., us-west-2)",placeholder:"us-west-2",required:!0,type:"text"},{name:"embedding_model",label:"Embedding Model",tooltip:"Select the embedding model to use for vector generation",placeholder:"text-embedding-3-small",required:!0,type:"select"}]},$=e=>q[e]||[];var U=e.i(689020),K=e.i(727749);let G=({isVisible:e,onCancel:t,onSuccess:l,accessToken:o,credentials:i})=>{let[n]=O.Form.useForm(),[c,d]=(0,s.useState)("{}"),[m,x]=(0,s.useState)("bedrock"),[u,h]=(0,s.useState)([]);(0,s.useEffect)(()=>{o&&(async()=>{try{let e=await (0,U.fetchAvailableModels)(o);e.length>0&&h(e)}catch(e){console.error("Error fetching model info:",e)}})()},[o]);let v=async e=>{if(o)try{let t={};try{t=c.trim()?JSON.parse(c):{}}catch(e){K.default.fromBackend("Invalid JSON in metadata field");return}let r={vector_store_id:e.vector_store_id,custom_llm_provider:e.custom_llm_provider,vector_store_name:e.vector_store_name,vector_store_description:e.vector_store_description,vector_store_metadata:t,litellm_credential_name:e.litellm_credential_name};r.litellm_params=$(e.custom_llm_provider).reduce((t,r)=>("milvus"===e.custom_llm_provider&&"embedding_model"===r.name?t.litellm_embedding_model=e[r.name]:t[r.name]=e[r.name],t),{}),await (0,p.vectorStoreCreateCall)(o,r),K.default.success("Vector store created successfully"),n.resetFields(),d("{}"),l()}catch(e){console.error("Error creating vector store:",e),K.default.fromBackend("Error creating vector store: "+e)}},g=()=>{n.resetFields(),d("{}"),x("bedrock"),t()};return(0,r.jsx)(V.Modal,{title:"Add New Vector Store",open:e,width:1e3,footer:null,onCancel:g,children:(0,r.jsxs)(O.Form,{form:n,onFinish:v,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,r.jsx)(O.Form.Item,{label:(0,r.jsxs)("span",{children:["Provider"," ",(0,r.jsx)(I.Tooltip,{title:"Select the provider for this vector store",children:(0,r.jsx)(F.InfoCircleOutlined,{style:{marginLeft:"4px"}})})]}),name:"custom_llm_provider",rules:[{required:!0,message:"Please select a provider"}],initialValue:"bedrock",children:(0,r.jsx)(E.Select,{onChange:e=>x(e),children:Object.entries(B).map(([e,t])=>(0,r.jsx)(E.Select.Option,{value:z[e],children:(0,r.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,r.jsx)("img",{src:M[t],alt:`${e} logo`,className:"w-5 h-5",onError:e=>{let r=e.target,s=r.parentElement;if(s){let e=document.createElement("div");e.className="w-5 h-5 rounded-full bg-gray-200 flex items-center justify-center text-xs",e.textContent=t.charAt(0),s.replaceChild(e,r)}}}),(0,r.jsx)("span",{children:t})]})},e))})}),"pg_vector"===m&&(0,r.jsx)(P.Alert,{message:"PG Vector Setup Required",description:(0,r.jsxs)("div",{children:[(0,r.jsx)("p",{children:"LiteLLM provides a server to connect to PG Vector. To use this provider:"}),(0,r.jsxs)("ol",{style:{marginLeft:"16px",marginTop:"8px"},children:[(0,r.jsxs)("li",{children:["Deploy the litellm-pgvector server from:"," ",(0,r.jsx)("a",{href:"https://github.com/BerriAI/litellm-pgvector",target:"_blank",rel:"noopener noreferrer",children:"https://github.com/BerriAI/litellm-pgvector"})]}),(0,r.jsx)("li",{children:"Configure your PostgreSQL database with pgvector extension"}),(0,r.jsx)("li",{children:"Start the server and note the API base URL and API key"}),(0,r.jsx)("li",{children:"Enter those details in the fields below"})]})]}),type:"info",showIcon:!0,style:{marginBottom:"16px"}}),"vertex_rag_engine"===m&&(0,r.jsx)(P.Alert,{message:"Vertex AI RAG Engine Setup",description:(0,r.jsxs)("div",{children:[(0,r.jsx)("p",{children:"To use Vertex AI RAG Engine:"}),(0,r.jsxs)("ol",{style:{marginLeft:"16px",marginTop:"8px"},children:[(0,r.jsxs)("li",{children:["Set up your Vertex AI RAG Engine corpus following the guide:"," ",(0,r.jsx)("a",{href:"https://cloud.google.com/vertex-ai/generative-ai/docs/rag-engine/rag-overview",target:"_blank",rel:"noopener noreferrer",children:"Vertex AI RAG Engine Overview"})]}),(0,r.jsx)("li",{children:"Create a corpus in your Google Cloud project"}),(0,r.jsx)("li",{children:"Note the corpus ID from the Vertex AI console"}),(0,r.jsx)("li",{children:"Enter the corpus ID in the Vector Store ID field below"})]})]}),type:"info",showIcon:!0,style:{marginBottom:"16px"}}),(0,r.jsx)(O.Form.Item,{label:(0,r.jsxs)("span",{children:["Vector Store ID"," ",(0,r.jsx)(I.Tooltip,{title:"Enter the vector store ID from your api provider",children:(0,r.jsx)(F.InfoCircleOutlined,{style:{marginLeft:"4px"}})})]}),name:"vector_store_id",rules:[{required:!0,message:"Please input the vector store ID from your api provider"}],children:(0,r.jsx)(L.TextInput,{placeholder:"vertex_rag_engine"===m?"6917529027641081856 (Get corpus ID from Vertex AI console)":"Enter vector store ID from your provider"})}),$(m).map(e=>{if("select"===e.type){let t=u.filter(e=>"embedding"===e.mode||null===e.mode).map(e=>({value:e.model_group,label:e.model_group}));return(0,r.jsx)(O.Form.Item,{label:(0,r.jsxs)("span",{children:[e.label," ",(0,r.jsx)(I.Tooltip,{title:e.tooltip,children:(0,r.jsx)(F.InfoCircleOutlined,{style:{marginLeft:"4px"}})})]}),name:e.name,rules:e.required?[{required:!0,message:`Please select the ${e.label.toLowerCase()}`}]:[],children:(0,r.jsx)(E.Select,{placeholder:e.placeholder,showSearch:!0,filterOption:(e,t)=>(t?.label??"").toLowerCase().includes(e.toLowerCase()),options:t,style:{width:"100%"}})},e.name)}return(0,r.jsx)(O.Form.Item,{label:(0,r.jsxs)("span",{children:[e.label," ",(0,r.jsx)(I.Tooltip,{title:e.tooltip,children:(0,r.jsx)(F.InfoCircleOutlined,{style:{marginLeft:"4px"}})})]}),name:e.name,rules:e.required?[{required:!0,message:`Please input the ${e.label.toLowerCase()}`}]:[],children:(0,r.jsx)(L.TextInput,{type:e.type||"text",placeholder:e.placeholder})},e.name)}),(0,r.jsx)(O.Form.Item,{label:(0,r.jsxs)("span",{children:["Vector Store Name"," ",(0,r.jsx)(I.Tooltip,{title:"Custom name you want to give to the vector store, this name will be rendered on the LiteLLM UI",children:(0,r.jsx)(F.InfoCircleOutlined,{style:{marginLeft:"4px"}})})]}),name:"vector_store_name",children:(0,r.jsx)(L.TextInput,{})}),(0,r.jsx)(O.Form.Item,{label:"Description",name:"vector_store_description",children:(0,r.jsx)(D.Input.TextArea,{rows:4})}),(0,r.jsx)(O.Form.Item,{label:(0,r.jsxs)("span",{children:["Existing Credentials"," ",(0,r.jsx)(I.Tooltip,{title:"Optionally select API provider credentials for this vector store eg. Bedrock API KEY",children:(0,r.jsx)(F.InfoCircleOutlined,{style:{marginLeft:"4px"}})})]}),name:"litellm_credential_name",children:(0,r.jsx)(E.Select,{showSearch:!0,placeholder:"Select or search for existing credentials",optionFilterProp:"children",filterOption:(e,t)=>(t?.label??"").toLowerCase().includes(e.toLowerCase()),options:[{value:null,label:"None"},...i.map(e=>({value:e.credential_name,label:e.credential_name}))],allowClear:!0})}),(0,r.jsx)(O.Form.Item,{label:(0,r.jsxs)("span",{children:["Metadata"," ",(0,r.jsx)(I.Tooltip,{title:"JSON metadata for the vector store (optional)",children:(0,r.jsx)(F.InfoCircleOutlined,{style:{marginLeft:"4px"}})})]}),children:(0,r.jsx)(D.Input.TextArea,{rows:4,value:c,onChange:e=>d(e.target.value),placeholder:'{"key": "value"}'})}),(0,r.jsxs)("div",{className:"flex justify-end space-x-3",children:[(0,r.jsx)(a.Button,{onClick:g,variant:"secondary",children:"Cancel"}),(0,r.jsx)(a.Button,{variant:"primary",type:"submit",children:"Create"})]})]})})};var H=e.i(127952),J=e.i(304967),W=e.i(629569),X=e.i(389083),Q=e.i(464571),Y=e.i(530212),Z=e.i(175712),ee=e.i(898586),et=e.i(482725),er=e.i(998573),es=e.i(312361);e.i(247167);var el=e.i(931067),ea={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"defs",attrs:{},children:[{tag:"style",attrs:{}}]},{tag:"path",attrs:{d:"M931.4 498.9L94.9 79.5c-3.4-1.7-7.3-2.1-11-1.2a15.99 15.99 0 00-11.7 19.3l86.2 352.2c1.3 5.3 5.2 9.6 10.4 11.3l147.7 50.7-147.6 50.7c-5.2 1.8-9.1 6-10.3 11.3L72.2 926.5c-.9 3.7-.5 7.6 1.2 10.9 3.9 7.9 13.5 11.1 21.5 7.2l836.5-417c3.1-1.5 5.6-4.1 7.2-7.1 3.9-8 .7-17.6-7.2-21.6zM170.8 826.3l50.3-205.6 295.2-101.3c2.3-.8 4.2-2.6 5-5 1.4-4.2-.8-8.7-5-10.2L221.1 403 171 198.2l628 314.9-628.2 313.2z"}}]},name:"send",theme:"outlined"},eo=e.i(9583),ei=s.forwardRef(function(e,t){return s.createElement(eo.default,(0,el.default)({},e,{ref:t,icon:ea}))}),en=e.i(210612),ec=e.i(56456),ed=e.i(755151),em=e.i(240647);let{TextArea:ex}=D.Input,{Text:eu,Title:eh}=ee.Typography,ep=({vectorStoreId:e,accessToken:t,className:l=""})=>{let[a,o]=(0,s.useState)(""),[i,n]=(0,s.useState)(!1),[c,d]=(0,s.useState)([]),[m,x]=(0,s.useState)({}),u=async()=>{if(!a.trim())return void er.message.warning("Please enter a search query");n(!0);try{let r=await (0,p.vectorStoreSearchCall)(t,e,a),s={query:a,response:r,timestamp:Date.now()};d(e=>[s,...e]),o("")}catch(e){console.error("Error searching vector store:",e),K.default.fromBackend("Failed to search vector store")}finally{n(!1)}};return(0,r.jsx)(Z.Card,{className:"w-full rounded-xl shadow-md",children:(0,r.jsxs)("div",{className:"flex flex-col h-[600px]",children:[(0,r.jsxs)("div",{className:"p-4 border-b border-gray-200 flex justify-between items-center",children:[(0,r.jsxs)("div",{className:"flex items-center",children:[(0,r.jsx)(en.DatabaseOutlined,{className:"mr-2 text-blue-500"}),(0,r.jsx)(eh,{level:4,className:"mb-0",children:"Test Vector Store"})]}),c.length>0&&(0,r.jsx)(Q.Button,{onClick:()=>{d([]),x({}),K.default.success("Search history cleared")},size:"small",children:"Clear History"})]}),(0,r.jsxs)("div",{className:"flex-1 overflow-auto p-4 pb-0",children:[0===c.length?(0,r.jsxs)("div",{className:"h-full flex flex-col items-center justify-center text-gray-400",children:[(0,r.jsx)(en.DatabaseOutlined,{style:{fontSize:"48px",marginBottom:"16px"}}),(0,r.jsx)(eu,{children:"Test your vector store by entering a search query below"})]}):(0,r.jsx)("div",{className:"space-y-4",children:c.map((e,t)=>(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsx)("div",{className:"text-right",children:(0,r.jsxs)("div",{className:"inline-block max-w-[80%] rounded-lg shadow-sm p-3 bg-blue-50 border border-blue-200",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2 mb-1",children:[(0,r.jsx)("strong",{className:"text-sm",children:"Query"}),(0,r.jsx)("span",{className:"text-xs text-gray-500",children:new Date(e.timestamp).toLocaleString()})]}),(0,r.jsx)("div",{className:"text-left",children:e.query})]})}),(0,r.jsx)("div",{className:"text-left",children:(0,r.jsxs)("div",{className:"inline-block max-w-[80%] rounded-lg shadow-sm p-3 bg-white border border-gray-200",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2 mb-2",children:[(0,r.jsx)(en.DatabaseOutlined,{className:"text-green-500"}),(0,r.jsx)("strong",{className:"text-sm",children:"Vector Store Results"}),e.response&&(0,r.jsxs)("span",{className:"text-xs px-2 py-0.5 rounded bg-gray-100 text-gray-600",children:[e.response.data?.length||0," results"]})]}),e.response&&e.response.data&&e.response.data.length>0?(0,r.jsx)("div",{className:"space-y-3",children:e.response.data.map((e,s)=>{let l=m[`${t}-${s}`]||!1;return(0,r.jsxs)("div",{className:"border rounded-lg overflow-hidden bg-gray-50",children:[(0,r.jsxs)("div",{className:"flex justify-between items-center p-3 cursor-pointer hover:bg-gray-100 transition-colors",onClick:()=>{let e;return e=`${t}-${s}`,void x(t=>({...t,[e]:!t[e]}))},children:[(0,r.jsxs)("div",{className:"flex items-center",children:[l?(0,r.jsx)(ed.DownOutlined,{className:"text-gray-500 mr-2"}):(0,r.jsx)(em.RightOutlined,{className:"text-gray-500 mr-2"}),(0,r.jsxs)("span",{className:"font-medium text-sm",children:["Result ",s+1]}),!l&&e.content&&e.content[0]&&(0,r.jsxs)("span",{className:"ml-2 text-xs text-gray-500 truncate max-w-md",children:["- ",e.content[0].text.substring(0,100),"..."]})]}),(0,r.jsxs)("span",{className:"text-xs bg-blue-100 text-blue-800 px-2 py-1 rounded",children:["Score: ",e.score.toFixed(4)]})]}),l&&(0,r.jsxs)("div",{className:"border-t bg-white p-3",children:[e.content&&e.content.map((e,t)=>(0,r.jsxs)("div",{className:"mb-3",children:[(0,r.jsxs)("div",{className:"text-xs text-gray-500 mb-1",children:["Content (",e.type,")"]}),(0,r.jsx)("div",{className:"text-sm bg-gray-50 p-3 rounded border text-gray-800 max-h-40 overflow-y-auto",children:e.text})]},t)),(e.file_id||e.filename||e.attributes)&&(0,r.jsxs)("div",{className:"mt-3 pt-3 border-t border-gray-200",children:[(0,r.jsx)("div",{className:"text-xs text-gray-500 mb-2 font-medium",children:"Metadata"}),(0,r.jsxs)("div",{className:"space-y-2 text-xs",children:[e.file_id&&(0,r.jsxs)("div",{className:"bg-gray-50 p-2 rounded",children:[(0,r.jsx)("span",{className:"font-medium",children:"File ID:"})," ",e.file_id]}),e.filename&&(0,r.jsxs)("div",{className:"bg-gray-50 p-2 rounded",children:[(0,r.jsx)("span",{className:"font-medium",children:"Filename:"})," ",e.filename]}),e.attributes&&Object.keys(e.attributes).length>0&&(0,r.jsxs)("div",{className:"bg-gray-50 p-2 rounded",children:[(0,r.jsx)("span",{className:"font-medium block mb-1",children:"Attributes:"}),(0,r.jsx)("pre",{className:"text-xs bg-white p-2 rounded border overflow-x-auto",children:JSON.stringify(e.attributes,null,2)})]})]})]})]})]},s)})}):(0,r.jsx)("div",{className:"text-gray-500 text-sm",children:"No results found"})]})}),to(e.target.value),onKeyDown:e=>{"Enter"!==e.key||e.shiftKey||(e.preventDefault(),u())},placeholder:"Enter your search query... (Shift+Enter for new line)",disabled:i,autoSize:{minRows:1,maxRows:4},style:{resize:"none"}})}),(0,r.jsx)(Q.Button,{type:"primary",onClick:u,disabled:i||!a.trim(),icon:(0,r.jsx)(ei,{}),loading:i,children:"Search"})]})})]})})},ev=({vectorStoreId:e,onClose:t,accessToken:l,is_admin:o,editVectorStore:n})=>{let[h]=O.Form.useForm(),[v,g]=(0,s.useState)(null),[j,f]=(0,s.useState)(n),[b,y]=(0,s.useState)("{}"),[_,w]=(0,s.useState)([]),[N,S]=(0,s.useState)("details"),C=async()=>{if(l)try{let t=await (0,p.vectorStoreInfoCall)(l,e);if(t&&t.vector_store){if(g(t.vector_store),t.vector_store.vector_store_metadata){let e="string"==typeof t.vector_store.vector_store_metadata?JSON.parse(t.vector_store.vector_store_metadata):t.vector_store.vector_store_metadata;y(JSON.stringify(e,null,2))}n&&h.setFieldsValue({vector_store_id:t.vector_store.vector_store_id,custom_llm_provider:t.vector_store.custom_llm_provider,vector_store_name:t.vector_store.vector_store_name,vector_store_description:t.vector_store.vector_store_description})}}catch(e){console.error("Error fetching vector store details:",e),K.default.fromBackend("Error fetching vector store details: "+e)}},T=async()=>{if(l)try{let e=await (0,p.credentialListCall)(l);console.log("List credentials response:",e),w(e.credentials||[])}catch(e){console.error("Error fetching credentials:",e)}};(0,s.useEffect)(()=>{C(),T()},[e,l]);let A=async e=>{if(l)try{let t={};try{t=b?JSON.parse(b):{}}catch(e){K.default.fromBackend("Invalid JSON in metadata field");return}let r={vector_store_id:e.vector_store_id,custom_llm_provider:e.custom_llm_provider,vector_store_name:e.vector_store_name,vector_store_description:e.vector_store_description,vector_store_metadata:t};await (0,p.vectorStoreUpdateCall)(l,r),K.default.success("Vector store updated successfully"),f(!1),C()}catch(e){console.error("Error updating vector store:",e),K.default.fromBackend("Error updating vector store: "+e)}};return v?(0,r.jsxs)("div",{className:"p-4 max-w-full",children:[(0,r.jsxs)("div",{className:"flex justify-between items-center mb-6",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)(a.Button,{icon:Y.ArrowLeftIcon,variant:"light",className:"mb-4",onClick:t,children:"Back to Vector Stores"}),(0,r.jsxs)(W.Title,{children:["Vector Store ID: ",v.vector_store_id]}),(0,r.jsx)(i.Text,{className:"text-gray-500",children:v.vector_store_description||"No description"})]}),o&&!j&&(0,r.jsx)(a.Button,{onClick:()=>f(!0),children:"Edit Vector Store"})]}),(0,r.jsxs)(c.TabGroup,{children:[(0,r.jsxs)(d.TabList,{className:"mb-6",children:[(0,r.jsx)(m.Tab,{children:"Details"}),(0,r.jsx)(m.Tab,{children:"Test Vector Store"})]}),(0,r.jsxs)(x.TabPanels,{children:[(0,r.jsx)(u.TabPanel,{children:j?(0,r.jsxs)("div",{children:[(0,r.jsx)("div",{className:"flex justify-between items-center mb-4",children:(0,r.jsx)(W.Title,{children:"Edit Vector Store"})}),(0,r.jsx)(J.Card,{children:(0,r.jsxs)(O.Form,{form:h,onFinish:A,layout:"vertical",initialValues:v,children:[(0,r.jsx)(O.Form.Item,{label:"Vector Store ID",name:"vector_store_id",rules:[{required:!0,message:"Please input a vector store ID"}],children:(0,r.jsx)(D.Input,{disabled:!0})}),(0,r.jsx)(O.Form.Item,{label:"Vector Store Name",name:"vector_store_name",children:(0,r.jsx)(D.Input,{})}),(0,r.jsx)(O.Form.Item,{label:"Description",name:"vector_store_description",children:(0,r.jsx)(D.Input.TextArea,{rows:4})}),(0,r.jsx)(O.Form.Item,{label:(0,r.jsxs)("span",{children:["Provider"," ",(0,r.jsx)(I.Tooltip,{title:"Select the provider for this vector store",children:(0,r.jsx)(F.InfoCircleOutlined,{style:{marginLeft:"4px"}})})]}),name:"custom_llm_provider",rules:[{required:!0,message:"Please select a provider"}],children:(0,r.jsx)(E.Select,{children:Object.entries(k.Providers).map(([e,t])=>"Bedrock"===e?(0,r.jsx)(E.Select.Option,{value:k.provider_map[e],children:(0,r.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,r.jsx)("img",{src:k.providerLogoMap[t],alt:`${e} logo`,className:"w-5 h-5",onError:e=>{let r=e.target,s=r.parentElement;if(s){let e=document.createElement("div");e.className="w-5 h-5 rounded-full bg-gray-200 flex items-center justify-center text-xs",e.textContent=t.charAt(0),s.replaceChild(e,r)}}}),(0,r.jsx)("span",{children:t})]})},e):null)})}),(0,r.jsx)("div",{className:"mb-4",children:(0,r.jsx)(i.Text,{className:"text-sm text-gray-500 mb-2",children:"Either select existing credentials OR enter provider credentials below"})}),(0,r.jsx)(O.Form.Item,{label:"Existing Credentials",name:"litellm_credential_name",children:(0,r.jsx)(E.Select,{showSearch:!0,placeholder:"Select or search for existing credentials",optionFilterProp:"children",filterOption:(e,t)=>(t?.label??"").toLowerCase().includes(e.toLowerCase()),options:[{value:null,label:"None"},..._.map(e=>({value:e.credential_name,label:e.credential_name}))],allowClear:!0})}),(0,r.jsxs)("div",{className:"flex items-center my-4",children:[(0,r.jsx)("div",{className:"flex-grow border-t border-gray-200"}),(0,r.jsx)("span",{className:"px-4 text-gray-500 text-sm",children:"OR"}),(0,r.jsx)("div",{className:"flex-grow border-t border-gray-200"})]}),(0,r.jsx)(O.Form.Item,{label:(0,r.jsxs)("span",{children:["Metadata"," ",(0,r.jsx)(I.Tooltip,{title:"JSON metadata for the vector store",children:(0,r.jsx)(F.InfoCircleOutlined,{style:{marginLeft:"4px"}})})]}),children:(0,r.jsx)(D.Input.TextArea,{rows:4,value:b,onChange:e=>y(e.target.value),placeholder:'{"key": "value"}'})}),(0,r.jsxs)("div",{className:"flex justify-end space-x-2",children:[(0,r.jsx)(Q.Button,{onClick:()=>f(!1),children:"Cancel"}),(0,r.jsx)(Q.Button,{type:"primary",htmlType:"submit",children:"Save Changes"})]})]})})]}):(0,r.jsxs)("div",{children:[(0,r.jsxs)("div",{className:"flex justify-between items-center mb-4",children:[(0,r.jsx)(W.Title,{children:"Vector Store Details"}),o&&(0,r.jsx)(a.Button,{onClick:()=>f(!0),children:"Edit Vector Store"})]}),(0,r.jsx)(J.Card,{children:(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)(i.Text,{className:"font-medium",children:"ID"}),(0,r.jsx)(i.Text,{children:v.vector_store_id})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)(i.Text,{className:"font-medium",children:"Name"}),(0,r.jsx)(i.Text,{children:v.vector_store_name||"-"})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)(i.Text,{className:"font-medium",children:"Description"}),(0,r.jsx)(i.Text,{children:v.vector_store_description||"-"})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)(i.Text,{className:"font-medium",children:"Provider"}),(0,r.jsx)("div",{className:"flex items-center space-x-2 mt-1",children:(()=>{let e=v.custom_llm_provider||"bedrock",{displayName:t,logo:s}=(()=>{let t=Object.keys(k.provider_map).find(t=>k.provider_map[t].toLowerCase()===e.toLowerCase());if(!t)return{displayName:e,logo:""};let r=k.Providers[t],s=k.providerLogoMap[r];return{displayName:r,logo:s}})();return(0,r.jsxs)(r.Fragment,{children:[s&&(0,r.jsx)("img",{src:s,alt:`${t} logo`,className:"w-5 h-5",onError:e=>{let r=e.target,s=r.parentElement;if(s){let e=document.createElement("div");e.className="w-5 h-5 rounded-full bg-gray-200 flex items-center justify-center text-xs",e.textContent=t.charAt(0),s.replaceChild(e,r)}}}),(0,r.jsx)(X.Badge,{color:"blue",children:t})]})})()})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)(i.Text,{className:"font-medium",children:"Metadata"}),(0,r.jsx)("div",{className:"bg-gray-50 p-3 rounded mt-2 font-mono text-xs overflow-auto max-h-48",children:(0,r.jsx)("pre",{children:b})})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)(i.Text,{className:"font-medium",children:"Created"}),(0,r.jsx)(i.Text,{children:v.created_at?new Date(v.created_at).toLocaleString():"-"})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)(i.Text,{className:"font-medium",children:"Last Updated"}),(0,r.jsx)(i.Text,{children:v.updated_at?new Date(v.updated_at).toLocaleString():"-"})]})]})})]})}),(0,r.jsx)(u.TabPanel,{children:(0,r.jsx)(ep,{vectorStoreId:v.vector_store_id,accessToken:l||""})})]})]})]}):(0,r.jsx)("div",{children:"Loading..."})};var eg=e.i(515831);let ej={icon:{tag:"svg",attrs:{viewBox:"0 0 1024 1024",focusable:"false"},children:[{tag:"path",attrs:{d:"M885.2 446.3l-.2-.8-112.2-285.1c-5-16.1-19.9-27.2-36.8-27.2H281.2c-17 0-32.1 11.3-36.9 27.6L139.4 443l-.3.7-.2.8c-1.3 4.9-1.7 9.9-1 14.8-.1 1.6-.2 3.2-.2 4.8V830a60.9 60.9 0 0060.8 60.8h627.2c33.5 0 60.8-27.3 60.9-60.8V464.1c0-1.3 0-2.6-.1-3.7.4-4.9 0-9.6-1.3-14.1zm-295.8-43l-.3 15.7c-.8 44.9-31.8 75.1-77.1 75.1-22.1 0-41.1-7.1-54.8-20.6S436 441.2 435.6 419l-.3-15.7H229.5L309 210h399.2l81.7 193.3H589.4zm-375 76.8h157.3c24.3 57.1 76 90.8 140.4 90.8 33.7 0 65-9.4 90.3-27.2 22.2-15.6 39.5-37.4 50.7-63.6h156.5V814H214.4V480.1z"}}]},name:"inbox",theme:"outlined"};var ef=s.forwardRef(function(e,t){return s.createElement(eo.default,(0,el.default)({},e,{ref:t,icon:ej}))}),eb=e.i(291542),ey=e.i(906579),e_=e.i(984125),e_=e_,ew=e.i(166406),eN=e.i(955135);let eS=({documents:e,onRemove:t})=>{let s=[{title:"Name",dataIndex:"name",key:"name",render:(e,t)=>(0,r.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,r.jsx)("span",{className:"text-sm",children:e}),t.size&&(0,r.jsxs)("span",{className:"text-xs text-gray-400",children:["(",(e=>{if(!e)return"-";let t=e/1024;return t<1024?`${t.toFixed(2)} KB`:`${(t/1024).toFixed(2)} MB`})(t.size),")"]})]})},{title:"Status",dataIndex:"status",key:"status",width:150,render:e=>{let t;return t=({uploading:{color:"blue",text:"Uploading"},done:{color:"green",text:"Ready"},error:{color:"red",text:"Error"},removed:{color:"default",text:"Removed"}})[e],(0,r.jsx)(ey.Badge,{color:t.color,text:t.text})}},{title:"Actions",key:"actions",width:120,render:(e,s)=>(0,r.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,r.jsx)(I.Tooltip,{title:"View details",children:(0,r.jsx)(e_.default,{className:"cursor-pointer text-gray-600 hover:text-blue-500",onClick:()=>console.log("View",s)})}),(0,r.jsx)(I.Tooltip,{title:"Copy ID",children:(0,r.jsx)(ew.CopyOutlined,{className:"cursor-pointer text-gray-600 hover:text-blue-500",onClick:()=>{var e;return e=s.uid,void(navigator.clipboard.writeText(e),er.message.success("Document ID copied to clipboard"))}})}),(0,r.jsx)(I.Tooltip,{title:"Remove",children:(0,r.jsx)(eN.DeleteOutlined,{className:"cursor-pointer text-gray-600 hover:text-red-500",onClick:()=>t(s.uid)})})]})}];return(0,r.jsx)(eb.Table,{dataSource:e,columns:s,rowKey:"uid",pagination:!1,locale:{emptyText:"No documents uploaded yet. Upload documents above to get started."},size:"small"})},eC=({accessToken:e,providerParams:t,onParamsChange:l})=>{let[a,o]=(0,s.useState)([]),[i,n]=(0,s.useState)(!1);(0,s.useEffect)(()=>{e&&(async()=>{n(!0);try{let t=(await (0,U.fetchAvailableModels)(e)).filter(e=>"embedding"===e.mode);o(t)}catch(e){console.error("Error fetching embedding models:",e)}finally{n(!1)}})()},[e]);let c=(e,r)=>{l({...t,[e]:r})};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(P.Alert,{message:"AWS S3 Vectors Setup",description:(0,r.jsxs)("div",{children:[(0,r.jsx)("p",{children:"AWS S3 Vectors allows you to store and query vector embeddings directly in S3:"}),(0,r.jsxs)("ul",{style:{marginLeft:"16px",marginTop:"8px"},children:[(0,r.jsx)("li",{children:"Vector buckets and indexes will be automatically created if they don't exist"}),(0,r.jsx)("li",{children:"Vector dimensions are auto-detected from your selected embedding model"}),(0,r.jsx)("li",{children:"Ensure your AWS credentials have permissions for S3 Vectors operations"}),(0,r.jsxs)("li",{children:["Learn more:"," ",(0,r.jsx)("a",{href:"https://docs.aws.amazon.com/AmazonS3/latest/userguide/s3-vector-buckets.html",target:"_blank",rel:"noopener noreferrer",children:"AWS S3 Vectors Documentation"})]})]})]}),type:"info",showIcon:!0,style:{marginBottom:"16px"}}),(0,r.jsx)(O.Form.Item,{label:(0,r.jsxs)("span",{children:["Vector Bucket Name"," ",(0,r.jsx)(I.Tooltip,{title:"S3 bucket name for vector storage (must be at least 3 characters, lowercase letters, numbers, hyphens, and periods only)",children:(0,r.jsx)(F.InfoCircleOutlined,{style:{marginLeft:"4px"}})})]}),required:!0,validateStatus:t.vector_bucket_name&&t.vector_bucket_name.length<3?"error":void 0,help:t.vector_bucket_name&&t.vector_bucket_name.length<3?"Bucket name must be at least 3 characters":void 0,children:(0,r.jsx)(D.Input,{value:t.vector_bucket_name||"",onChange:e=>c("vector_bucket_name",e.target.value),placeholder:"my-vector-bucket (min 3 chars)",size:"large",className:"rounded-md"})}),(0,r.jsx)(O.Form.Item,{label:(0,r.jsxs)("span",{children:["Index Name"," ",(0,r.jsx)(I.Tooltip,{title:"Name for the vector index (optional, will be auto-generated if not provided). If provided, must be at least 3 characters.",children:(0,r.jsx)(F.InfoCircleOutlined,{style:{marginLeft:"4px"}})})]}),validateStatus:t.index_name&&t.index_name.length>0&&t.index_name.length<3?"error":void 0,help:t.index_name&&t.index_name.length>0&&t.index_name.length<3?"Index name must be at least 3 characters if provided":void 0,children:(0,r.jsx)(D.Input,{value:t.index_name||"",onChange:e=>c("index_name",e.target.value),placeholder:"my-vector-index (optional, min 3 chars)",size:"large",className:"rounded-md"})}),(0,r.jsx)(O.Form.Item,{label:(0,r.jsxs)("span",{children:["AWS Region"," ",(0,r.jsx)(I.Tooltip,{title:"AWS region where the S3 bucket is located (e.g., us-west-2)",children:(0,r.jsx)(F.InfoCircleOutlined,{style:{marginLeft:"4px"}})})]}),required:!0,children:(0,r.jsx)(D.Input,{value:t.aws_region_name||"",onChange:e=>c("aws_region_name",e.target.value),placeholder:"us-west-2",size:"large",className:"rounded-md"})}),(0,r.jsx)(O.Form.Item,{label:(0,r.jsxs)("span",{children:["Embedding Model"," ",(0,r.jsx)(I.Tooltip,{title:"Select the embedding model to use for vector generation",children:(0,r.jsx)(F.InfoCircleOutlined,{style:{marginLeft:"4px"}})})]}),required:!0,children:(0,r.jsx)(E.Select,{value:t.embedding_model||void 0,onChange:e=>c("embedding_model",e),placeholder:"Select an embedding model",size:"large",showSearch:!0,loading:i,filterOption:(e,t)=>(t?.label??"").toLowerCase().includes(e.toLowerCase()),options:a.map(e=>({value:e.model_group,label:e.model_group})),style:{width:"100%"}})})]})},{Dragger:eI}=eg.Upload,eT=({accessToken:e,onSuccess:t})=>{let[l]=O.Form.useForm(),[a,o]=(0,s.useState)([]),[n,c]=(0,s.useState)(!1),[d,m]=(0,s.useState)("bedrock"),[x,u]=(0,s.useState)(""),[h,v]=(0,s.useState)(""),[g,j]=(0,s.useState)([]),[f,b]=(0,s.useState)({}),y={name:"file",multiple:!0,accept:".pdf,.txt,.docx,.md,.doc",beforeUpload:e=>{if(!["application/pdf","text/plain","application/vnd.openxmlformats-officedocument.wordprocessingml.document","application/msword","text/markdown"].includes(e.type))return er.message.error(`${e.name} is not a supported file type. Please upload PDF, TXT, DOCX, or MD files.`),eg.Upload.LIST_IGNORE;if(!(e.size/1024/1024<50))return er.message.error(`${e.name} must be smaller than 50MB!`),eg.Upload.LIST_IGNORE;let t={uid:e.uid,name:e.name,status:"done",size:e.size,type:e.type,originFileObj:e};return o(e=>[...e,t]),!1},onRemove:e=>{o(t=>t.filter(t=>t.uid!==e.uid))},fileList:a.map(e=>({uid:e.uid,name:e.name,status:e.status,size:e.size})),showUploadList:!1},_=async()=>{let r;if(0===a.length)return void er.message.warning("Please upload at least one document");if(!d)return void er.message.warning("Please select a provider");for(let e of $(d).filter(e=>e.required))if(!f[e.name])return void er.message.warning(`Please provide ${e.label}`);if("s3_vectors"===d){if(f.vector_bucket_name&&f.vector_bucket_name.length<3)return void er.message.warning("Vector bucket name must be at least 3 characters");if(f.index_name&&f.index_name.length>0&&f.index_name.length<3)return void er.message.warning("Index name must be at least 3 characters if provided")}if(!e)return void er.message.error("No access token available");c(!0);let s=[];try{for(let t of a)if(t.originFileObj){o(e=>e.map(e=>e.uid===t.uid?{...e,status:"uploading"}:e));try{let l=await (0,p.ragIngestCall)(e,t.originFileObj,d,r,x||void 0,h||void 0,f);!r&&l.vector_store_id&&(r=l.vector_store_id),s.push(l),o(e=>e.map(e=>e.uid===t.uid?{...e,status:"done"}:e))}catch(e){throw console.error(`Error ingesting ${t.name}:`,e),o(e=>e.map(e=>e.uid===t.uid?{...e,status:"error"}:e)),e}}j(s),K.default.success(`Successfully created vector store with ${s.length} document(s). Vector Store ID: ${r}`),t&&r&&t(r),setTimeout(()=>{o([]),j([])},3e3)}catch(e){console.error("Error creating vector store:",e),K.default.fromBackend(`Failed to create vector store: ${e}`)}finally{c(!1)}};return(0,r.jsxs)("div",{className:"space-y-6",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)(W.Title,{children:"Create Vector Store"}),(0,r.jsx)(i.Text,{className:"text-gray-500",children:"Upload documents and select a provider to create a new vector store with embedded content."})]}),(0,r.jsxs)(J.Card,{children:[(0,r.jsxs)("div",{className:"mb-4",children:[(0,r.jsx)(i.Text,{className:"font-medium",children:"Step 1: Upload Documents"}),(0,r.jsx)(i.Text,{className:"text-sm text-gray-500 block mt-1",children:"Upload one or more documents (PDF, TXT, DOCX, MD). Maximum file size: 50MB per file."})]}),(0,r.jsxs)(eI,{...y,children:[(0,r.jsx)("p",{className:"ant-upload-drag-icon",children:(0,r.jsx)(ef,{style:{fontSize:"48px",color:"#1890ff"}})}),(0,r.jsx)("p",{className:"ant-upload-text",children:"Click or drag files to this area to upload"}),(0,r.jsx)("p",{className:"ant-upload-hint",children:"Support for single or bulk upload. Supported formats: PDF, TXT, DOCX, MD"})]})]}),a.length>0&&(0,r.jsxs)(J.Card,{children:[(0,r.jsx)("div",{className:"mb-4",children:(0,r.jsxs)(i.Text,{className:"font-medium",children:["Uploaded Documents (",a.length,")"]})}),(0,r.jsx)(eS,{documents:a,onRemove:e=>{o(t=>t.filter(t=>t.uid!==e))}})]}),(0,r.jsx)(J.Card,{children:(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)(i.Text,{className:"font-medium",children:"Step 2: Configure Vector Store"}),(0,r.jsx)(i.Text,{className:"text-sm text-gray-500 block mt-1",children:"Choose the provider and optionally provide a name and description for your vector store."})]}),(0,r.jsxs)(O.Form,{form:l,layout:"vertical",children:[(0,r.jsx)(O.Form.Item,{label:(0,r.jsxs)("span",{children:["Vector Store Name"," ",(0,r.jsx)(I.Tooltip,{title:"Optional: Give your vector store a meaningful name",children:(0,r.jsx)(F.InfoCircleOutlined,{style:{marginLeft:"4px"}})})]}),children:(0,r.jsx)(D.Input,{value:x,onChange:e=>u(e.target.value),placeholder:"e.g., Product Documentation, Customer Support KB",size:"large",className:"rounded-md"})}),(0,r.jsx)(O.Form.Item,{label:(0,r.jsxs)("span",{children:["Description"," ",(0,r.jsx)(I.Tooltip,{title:"Optional: Describe what this vector store contains",children:(0,r.jsx)(F.InfoCircleOutlined,{style:{marginLeft:"4px"}})})]}),children:(0,r.jsx)(D.Input.TextArea,{value:h,onChange:e=>v(e.target.value),placeholder:"e.g., Contains all product documentation and user guides",rows:2,size:"large",className:"rounded-md"})}),(0,r.jsx)(O.Form.Item,{label:(0,r.jsxs)("span",{children:["Provider"," ",(0,r.jsx)(I.Tooltip,{title:"Select the provider for embedding and vector store operations",children:(0,r.jsx)(F.InfoCircleOutlined,{style:{marginLeft:"4px"}})})]}),required:!0,children:(0,r.jsx)(E.Select,{value:d,onChange:m,placeholder:"Select a provider",size:"large",style:{width:"100%"},children:Object.entries(B).map(([e,t])=>(0,r.jsx)(E.Select.Option,{value:z[e],children:(0,r.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,r.jsx)("img",{src:M[t],alt:`${e} logo`,className:"w-5 h-5",onError:e=>{let r=e.target,s=r.parentElement;if(s){let e=document.createElement("div");e.className="w-5 h-5 rounded-full bg-gray-200 flex items-center justify-center text-xs",e.textContent=t.charAt(0),s.replaceChild(e,r)}}}),(0,r.jsx)("span",{children:t})]})},e))})}),"s3_vectors"===d&&(0,r.jsx)(eC,{accessToken:e,providerParams:f,onParamsChange:b}),"s3_vectors"!==d&&$(d).map(e=>"select"===e.type?(0,r.jsx)(O.Form.Item,{label:(0,r.jsxs)("span",{children:[e.label," ",(0,r.jsx)(I.Tooltip,{title:e.tooltip,children:(0,r.jsx)(F.InfoCircleOutlined,{style:{marginLeft:"4px"}})})]}),required:e.required,children:(0,r.jsx)(D.Input,{value:f[e.name]||"",onChange:t=>b(r=>({...r,[e.name]:t.target.value})),placeholder:e.placeholder,size:"large",className:"rounded-md"})},e.name):(0,r.jsx)(O.Form.Item,{label:(0,r.jsxs)("span",{children:[e.label," ",(0,r.jsx)(I.Tooltip,{title:e.tooltip,children:(0,r.jsx)(F.InfoCircleOutlined,{style:{marginLeft:"4px"}})})]}),required:e.required,children:(0,r.jsx)(D.Input,{type:"password"===e.type?"password":"text",value:f[e.name]||"",onChange:t=>b(r=>({...r,[e.name]:t.target.value})),placeholder:e.placeholder,size:"large",className:"rounded-md"})},e.name))]}),(0,r.jsx)("div",{className:"flex justify-end",children:(0,r.jsx)(Q.Button,{type:"primary",size:"large",onClick:_,loading:n,disabled:0===a.length||!d,children:n?"Creating Vector Store...":"Create Vector Store"})})]})}),g.length>0&&(0,r.jsx)(P.Alert,{message:"Vector Store Created Successfully",description:(0,r.jsxs)("div",{children:[(0,r.jsxs)("p",{children:[(0,r.jsx)("strong",{children:"Vector Store ID:"})," ",g[0]?.vector_store_id]}),(0,r.jsxs)("p",{children:[(0,r.jsx)("strong",{children:"Documents Ingested:"})," ",g.length]})]}),type:"success",showIcon:!0,closable:!0})]})},{Text:ek,Title:eA}=ee.Typography,eL=({accessToken:e,vectorStores:t})=>{let[l,a]=(0,s.useState)(t.length>0?t[0].vector_store_id:void 0);return e?0===t.length?(0,r.jsx)(Z.Card,{children:(0,r.jsx)("div",{className:"text-center py-8",children:(0,r.jsx)(ek,{type:"secondary",children:"No vector stores available. Create one first to test it."})})}):(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsx)(Z.Card,{children:(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)(eA,{level:5,children:"Select Vector Store"}),(0,r.jsx)(ek,{type:"secondary",children:"Choose a vector store to test search queries against"})]}),(0,r.jsx)(E.Select,{value:l,onChange:a,placeholder:"Select a vector store",size:"large",style:{width:"100%"},showSearch:!0,optionFilterProp:"children",children:t.map(e=>(0,r.jsx)(E.Select.Option,{value:e.vector_store_id,children:(0,r.jsxs)("div",{className:"flex flex-col",children:[(0,r.jsx)("span",{className:"font-medium",children:e.vector_store_name||e.vector_store_id}),e.vector_store_name&&(0,r.jsx)("span",{className:"text-xs text-gray-500 font-mono",children:e.vector_store_id})]})},e.vector_store_id))})]})}),l&&(0,r.jsx)(ep,{vectorStoreId:l,accessToken:e})]}):(0,r.jsx)(Z.Card,{children:(0,r.jsx)(ek,{type:"secondary",children:"Access token is required to test vector stores."})})};var eV=e.i(708347);e.s(["default",0,({accessToken:e,userID:t,userRole:v})=>{let[g,j]=(0,s.useState)([]),[f,b]=(0,s.useState)(!1),[y,_]=(0,s.useState)(!1),[w,N]=(0,s.useState)(null),[S,C]=(0,s.useState)(""),[I,T]=(0,s.useState)([]),[k,L]=(0,s.useState)(null),[V,O]=(0,s.useState)(!1),[E,D]=(0,s.useState)(!1),P=async()=>{if(e)try{let t=await (0,p.vectorStoreListCall)(e);console.log("List vector stores response:",t),j(t.data||[])}catch(e){console.error("Error fetching vector stores:",e),K.default.fromBackend("Error fetching vector stores: "+e)}},F=async()=>{if(e)try{let t=await (0,p.credentialListCall)(e);console.log("List credentials response:",t),T(t.credentials||[])}catch(e){console.error("Error fetching credentials:",e),K.default.fromBackend("Error fetching credentials: "+e)}},B=async e=>{N(e),_(!0)},z=async()=>{if(e&&w){D(!0);try{await (0,p.vectorStoreDeleteCall)(e,w),K.default.success("Vector store deleted successfully"),P()}catch(e){console.error("Error deleting vector store:",e),K.default.fromBackend("Error deleting vector store: "+e)}finally{D(!1),_(!1),N(null)}}};return(0,s.useEffect)(()=>{P(),F()},[e]),k?(0,r.jsx)("div",{className:"w-full h-full",children:(0,r.jsx)(ev,{vectorStoreId:k,onClose:()=>{L(null),O(!1),P()},accessToken:e,is_admin:(0,eV.isAdminRole)(v||""),editVectorStore:V})}):(0,r.jsx)("div",{className:"w-full mx-4 h-[75vh]",children:(0,r.jsxs)("div",{className:"gap-2 p-8 h-[75vh] w-full mt-2",children:[(0,r.jsxs)("div",{className:"flex justify-between mt-2 w-full items-center mb-4",children:[(0,r.jsx)("h1",{children:"Vector Store Management"}),(0,r.jsxs)("div",{className:"flex items-center space-x-2",children:[S&&(0,r.jsxs)(i.Text,{children:["Last Refreshed: ",S]}),(0,r.jsx)(l.Icon,{icon:h.RefreshIcon,variant:"shadow",size:"xs",className:"self-center cursor-pointer",onClick:()=>{P(),F(),C(new Date().toLocaleString())}})]})]}),(0,r.jsx)(i.Text,{className:"mb-4",children:(0,r.jsx)("p",{children:"You can use vector stores to store and retrieve LLM embeddings."})}),(0,r.jsxs)(c.TabGroup,{children:[(0,r.jsxs)(d.TabList,{className:"mb-6",children:[(0,r.jsx)(m.Tab,{children:"Create Vector Store"}),(0,r.jsx)(m.Tab,{children:"Manage Vector Stores"}),(0,r.jsx)(m.Tab,{children:"Test Vector Store"})]}),(0,r.jsxs)(x.TabPanels,{children:[(0,r.jsx)(u.TabPanel,{children:(0,r.jsx)(eT,{accessToken:e,onSuccess:e=>{console.log("Vector store created:",e),P()}})}),(0,r.jsxs)(u.TabPanel,{children:[(0,r.jsx)(a.Button,{className:"mb-4",onClick:()=>b(!0),children:"+ Add Vector Store"}),(0,r.jsx)(n.Grid,{numItems:1,className:"gap-2 pt-2 pb-2 w-full mt-2",children:(0,r.jsx)(o.Col,{numColSpan:1,children:(0,r.jsx)(A,{data:g,onView:e=>{L(e),O(!1)},onEdit:e=>{L(e),O(!0)},onDelete:B})})})]}),(0,r.jsx)(u.TabPanel,{children:(0,r.jsx)(eL,{accessToken:e,vectorStores:g})})]})]}),(0,r.jsx)(G,{isVisible:f,onCancel:()=>b(!1),onSuccess:()=>{b(!1),P()},accessToken:e,credentials:I}),(0,r.jsx)(H.default,{isOpen:y,title:"Delete Vector Store",message:"Are you sure you want to delete this vector store? This action cannot be undone.",resourceInformationTitle:"Vector Store Information",resourceInformation:[{label:"Vector Store ID",value:w,code:!0}],onCancel:()=>_(!1),onOk:z,confirmLoading:E})]})})}],241902)}]); \ No newline at end of file diff --git a/litellm/proxy/_experimental/out/_next/static/chunks/0a6c418370a8c183.js b/litellm/proxy/_experimental/out/_next/static/chunks/0a6c418370a8c183.js new file mode 100644 index 00000000000..b3e15e69622 --- /dev/null +++ b/litellm/proxy/_experimental/out/_next/static/chunks/0a6c418370a8c183.js @@ -0,0 +1,41 @@ +(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,486794,(e,t,n)=>{t.exports=function(){var e=document.getSelection();if(!e.rangeCount)return function(){};for(var t=document.activeElement,n=[],l=0;l{"use strict";var l=e.r(486794),r={"text/plain":"Text","text/html":"Url",default:"Text"};t.exports=function(e,t){var n,o,a,i,c,s,u,d,p=!1;t||(t={}),a=t.debug||!1;try{if(c=l(),s=document.createRange(),u=document.getSelection(),(d=document.createElement("span")).textContent=e,d.ariaHidden="true",d.style.all="unset",d.style.position="fixed",d.style.top=0,d.style.clip="rect(0, 0, 0, 0)",d.style.whiteSpace="pre",d.style.webkitUserSelect="text",d.style.MozUserSelect="text",d.style.msUserSelect="text",d.style.userSelect="text",d.addEventListener("copy",function(n){if(n.stopPropagation(),t.format)if(n.preventDefault(),void 0===n.clipboardData){a&&console.warn("unable to use e.clipboardData"),a&&console.warn("trying IE specific stuff"),window.clipboardData.clearData();var l=r[t.format]||r.default;window.clipboardData.setData(l,e)}else n.clipboardData.clearData(),n.clipboardData.setData(t.format,e);t.onCopy&&(n.preventDefault(),t.onCopy(n.clipboardData))}),document.body.appendChild(d),s.selectNodeContents(d),u.addRange(s),!document.execCommand("copy"))throw Error("copy command was unsuccessful");p=!0}catch(l){a&&console.error("unable to copy using execCommand: ",l),a&&console.warn("trying IE specific stuff");try{window.clipboardData.setData(t.format||"text",e),t.onCopy&&t.onCopy(window.clipboardData),p=!0}catch(l){a&&console.error("unable to copy using clipboardData: ",l),a&&console.error("falling back to prompt"),n="message"in t?t.message:"Copy to clipboard: #{key}, Enter",o=(/mac os x/i.test(navigator.userAgent)?"⌘":"Ctrl")+"+C",i=n.replace(/#{\s*key\s*}/g,o),window.prompt(i,e)}}finally{u&&("function"==typeof u.removeRange?u.removeRange(s):u.removeAllRanges()),d&&document.body.removeChild(d),c()}return p}},898586,401361,335771,e=>{"use strict";e.i(247167);var t=e.i(271645),n=e.i(8211),l=e.i(931067);let r={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M257.7 752c2 0 4-.2 6-.5L431.9 722c2-.4 3.9-1.3 5.3-2.8l423.9-423.9a9.96 9.96 0 000-14.1L694.9 114.9c-1.9-1.9-4.4-2.9-7.1-2.9s-5.2 1-7.1 2.9L256.8 538.8c-1.5 1.5-2.4 3.3-2.8 5.3l-29.5 168.2a33.5 33.5 0 009.4 29.8c6.6 6.4 14.9 9.9 23.8 9.9zm67.4-174.4L687.8 215l73.3 73.3-362.7 362.6-88.9 15.7 15.6-89zM880 836H144c-17.7 0-32 14.3-32 32v36c0 4.4 3.6 8 8 8h784c4.4 0 8-3.6 8-8v-36c0-17.7-14.3-32-32-32z"}}]},name:"edit",theme:"outlined"};var o=e.i(9583),a=t.forwardRef(function(e,n){return t.createElement(o.default,(0,l.default)({},e,{ref:n,icon:r}))});e.s(["default",0,a],401361);var i=e.i(343794),c=e.i(430073),s=e.i(876556),u=e.i(174428),d=e.i(914949),p=e.i(529681),f=e.i(611935),m=e.i(735049),g=e.i(242064),b=e.i(929447),y=e.i(491816);let v={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M864 170h-60c-4.4 0-8 3.6-8 8v518H310v-73c0-6.7-7.8-10.5-13-6.3l-141.9 112a8 8 0 000 12.6l141.9 112c5.3 4.2 13 .4 13-6.3v-75h498c35.3 0 64-28.7 64-64V178c0-4.4-3.6-8-8-8z"}}]},name:"enter",theme:"outlined"};var h=t.forwardRef(function(e,n){return t.createElement(o.default,(0,l.default)({},e,{ref:n,icon:v}))}),x=e.i(404948),O=e.i(763731),E=e.i(635432),S=e.i(183293),w=e.i(246422);e.i(765846);var j=e.i(896091);let C=(0,w.genStyleHooks)("Typography",e=>{let t,{componentCls:n,titleMarginTop:l}=e;return{[n]:Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({color:e.colorText,wordBreak:"break-word",lineHeight:e.lineHeight,[`&${n}-secondary`]:{color:e.colorTextDescription},[`&${n}-success`]:{color:e.colorSuccessText},[`&${n}-warning`]:{color:e.colorWarningText},[`&${n}-danger`]:{color:e.colorErrorText,"a&:active, a&:focus":{color:e.colorErrorTextActive},"a&:hover":{color:e.colorErrorTextHover}},[`&${n}-disabled`]:{color:e.colorTextDisabled,cursor:"not-allowed",userSelect:"none"},[` + div&, + p + `]:{marginBottom:"1em"}},(t={},[1,2,3,4,5].forEach(n=>{t[` + h${n}&, + div&-h${n}, + div&-h${n} > textarea, + h${n} + `]=((e,t,n,l)=>{let{titleMarginBottom:r,fontWeightStrong:o}=l;return{marginBottom:r,color:n,fontWeight:o,fontSize:e,lineHeight:t}})(e[`fontSizeHeading${n}`],e[`lineHeightHeading${n}`],e.colorTextHeading,e)}),t)),{[` + & + h1${n}, + & + h2${n}, + & + h3${n}, + & + h4${n}, + & + h5${n} + `]:{marginTop:l},[` + div, + ul, + li, + p, + h1, + h2, + h3, + h4, + h5`]:{[` + + h1, + + h2, + + h3, + + h4, + + h5 + `]:{marginTop:l}}}),{code:{margin:"0 0.2em",paddingInline:"0.4em",paddingBlock:"0.2em 0.1em",fontSize:"85%",fontFamily:e.fontFamilyCode,background:"rgba(150, 150, 150, 0.1)",border:"1px solid rgba(100, 100, 100, 0.2)",borderRadius:3},kbd:{margin:"0 0.2em",paddingInline:"0.4em",paddingBlock:"0.15em 0.1em",fontSize:"90%",fontFamily:e.fontFamilyCode,background:"rgba(150, 150, 150, 0.06)",border:"1px solid rgba(100, 100, 100, 0.2)",borderBottomWidth:2,borderRadius:3},mark:{padding:0,backgroundColor:j.gold[2]},"u, ins":{textDecoration:"underline",textDecorationSkipInk:"auto"},"s, del":{textDecoration:"line-through"},strong:{fontWeight:e.fontWeightStrong},"ul, ol":{marginInline:0,marginBlock:"0 1em",padding:0,li:{marginInline:"20px 0",marginBlock:0,paddingInline:"4px 0",paddingBlock:0}},ul:{listStyleType:"circle",ul:{listStyleType:"disc"}},ol:{listStyleType:"decimal"},"pre, blockquote":{margin:"1em 0"},pre:{padding:"0.4em 0.6em",whiteSpace:"pre-wrap",wordWrap:"break-word",background:"rgba(150, 150, 150, 0.1)",border:"1px solid rgba(100, 100, 100, 0.2)",borderRadius:3,fontFamily:e.fontFamilyCode,code:{display:"inline",margin:0,padding:0,fontSize:"inherit",fontFamily:"inherit",background:"transparent",border:0}},blockquote:{paddingInline:"0.6em 0",paddingBlock:0,borderInlineStart:"4px solid rgba(100, 100, 100, 0.2)",opacity:.85}}),(e=>{let{componentCls:t}=e;return{"a&, a":Object.assign(Object.assign({},(0,S.operationUnit)(e)),{userSelect:"text",[`&[disabled], &${t}-disabled`]:{color:e.colorTextDisabled,cursor:"not-allowed","&:active, &:hover":{color:e.colorTextDisabled},"&:active":{pointerEvents:"none"}}})}})(e)),{[` + ${n}-expand, + ${n}-collapse, + ${n}-edit, + ${n}-copy + `]:Object.assign(Object.assign({},(0,S.operationUnit)(e)),{marginInlineStart:e.marginXXS})}),(e=>{let{componentCls:t,paddingSM:n}=e;return{"&-edit-content":{position:"relative","div&":{insetInlineStart:e.calc(e.paddingSM).mul(-1).equal(),insetBlockStart:e.calc(n).div(-2).add(1).equal(),marginBottom:e.calc(n).div(2).sub(2).equal()},[`${t}-edit-content-confirm`]:{position:"absolute",insetInlineEnd:e.calc(e.marginXS).add(2).equal(),insetBlockEnd:e.marginXS,color:e.colorIcon,fontWeight:"normal",fontSize:e.fontSize,fontStyle:"normal",pointerEvents:"none"},textarea:{margin:"0!important",MozTransition:"none",height:"1em"}}}})(e)),{[`${e.componentCls}-copy-success`]:{[` + &, + &:hover, + &:focus`]:{color:e.colorSuccess}},[`${e.componentCls}-copy-icon-only`]:{marginInlineStart:0}}),{[` + a&-ellipsis, + span&-ellipsis + `]:{display:"inline-block",maxWidth:"100%"},"&-ellipsis-single-line":{whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis","a&, span&":{verticalAlign:"bottom"},"> code":{paddingBlock:0,maxWidth:"calc(100% - 1.2em)",display:"inline-block",overflow:"hidden",textOverflow:"ellipsis",verticalAlign:"bottom",boxSizing:"content-box"}},"&-ellipsis-multiple-line":{display:"-webkit-box",overflow:"hidden",WebkitLineClamp:3,WebkitBoxOrient:"vertical"}}),{"&-rtl":{direction:"rtl"}})}},()=>({titleMarginTop:"1.2em",titleMarginBottom:"0.5em"})),k=e=>{let{prefixCls:n,"aria-label":l,className:r,style:o,direction:a,maxLength:c,autoSize:s=!0,value:u,onSave:d,onCancel:p,onEnd:f,component:m,enterIcon:g=t.createElement(h,null)}=e,b=t.useRef(null),y=t.useRef(!1),v=t.useRef(null),[S,w]=t.useState(u);t.useEffect(()=>{w(u)},[u]),t.useEffect(()=>{var e;if(null==(e=b.current)?void 0:e.resizableTextArea){let{textArea:e}=b.current.resizableTextArea;e.focus();let{length:t}=e.value;e.setSelectionRange(t,t)}},[]);let j=()=>{d(S.trim())},[k,R,$]=C(n),T=(0,i.default)(n,`${n}-edit-content`,{[`${n}-rtl`]:"rtl"===a,[`${n}-${m}`]:!!m},r,R,$);return k(t.createElement("div",{className:T,style:o},t.createElement(E.default,{ref:b,maxLength:c,value:S,onChange:({target:e})=>{w(e.value.replace(/[\n\r]/g,""))},onKeyDown:({keyCode:e})=>{y.current||(v.current=e)},onKeyUp:({keyCode:e,ctrlKey:t,altKey:n,metaKey:l,shiftKey:r})=>{v.current!==e||y.current||t||n||l||r||(e===x.default.ENTER?(j(),null==f||f()):e===x.default.ESC&&p())},onCompositionStart:()=>{y.current=!0},onCompositionEnd:()=>{y.current=!1},onBlur:()=>{j()},"aria-label":l,rows:1,autoSize:s}),null!==g?(0,O.cloneElement)(g,{className:`${n}-edit-content-confirm`}):null))};var R=e.i(844343),$=e.i(175066);function T(e,n){return t.useMemo(()=>{let t=!!e;return[t,Object.assign(Object.assign({},n),t&&"object"==typeof e?e:null)]},[e])}var I=function(e,t){var n={};for(var l in e)Object.prototype.hasOwnProperty.call(e,l)&&0>t.indexOf(l)&&(n[l]=e[l]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols)for(var r=0,l=Object.getOwnPropertySymbols(e);rt.indexOf(l[r])&&Object.prototype.propertyIsEnumerable.call(e,l[r])&&(n[l[r]]=e[l[r]]);return n};let D=t.forwardRef((e,n)=>{let{prefixCls:l,component:r="article",className:o,rootClassName:a,setContentRef:c,children:s,direction:u,style:d}=e,p=I(e,["prefixCls","component","className","rootClassName","setContentRef","children","direction","style"]),{getPrefixCls:m,direction:b,className:y,style:v}=(0,g.useComponentConfig)("typography"),h=c?(0,f.composeRef)(n,c):n,x=m("typography",l),[O,E,S]=C(x),w=(0,i.default)(x,y,{[`${x}-rtl`]:"rtl"===(null!=u?u:b)},o,a,E,S),j=Object.assign(Object.assign({},v),d);return O(t.createElement(r,Object.assign({className:w,style:j,ref:h},p),s))});var P=e.i(121229),B=e.i(190144),M=e.i(739295);function H(e){return!1===e?[!1,!1]:Array.isArray(e)?e:[e]}function z(e,t,n){return!0===e||void 0===e?t:e||n&&t}let A=e=>["string","number"].includes(typeof e),W=({prefixCls:e,copied:n,locale:l,iconOnly:r,tooltips:o,icon:a,tabIndex:c,onCopy:s,loading:u})=>{let d=H(o),p=H(a),{copied:f,copy:m}=null!=l?l:{},g=n?f:m,b=z(d[+!!n],g),v="string"==typeof b?b:g;return t.createElement(y.default,{title:b},t.createElement("button",{type:"button",className:(0,i.default)(`${e}-copy`,{[`${e}-copy-success`]:n,[`${e}-copy-icon-only`]:r}),onClick:s,"aria-label":v,tabIndex:c},n?z(p[1],t.createElement(P.default,null),!0):z(p[0],u?t.createElement(M.default,null):t.createElement(B.default,null),!0)))},L=t.forwardRef(({style:e,children:n},l)=>{let r=t.useRef(null);return t.useImperativeHandle(l,()=>({isExceed:()=>{let e=r.current;return e.scrollHeight>e.clientHeight},getHeight:()=>r.current.clientHeight})),t.createElement("span",{"aria-hidden":!0,ref:r,style:Object.assign({position:"fixed",display:"block",left:0,top:0,pointerEvents:"none",backgroundColor:"rgba(255, 0, 0, 0.65)"},e)},n)});function N(e,t){let n=0,l=[];for(let r=0;rt){let e=t-n;return l.push(String(o).slice(0,e)),l}l.push(o),n=a}return e}let U={display:"-webkit-box",overflow:"hidden",WebkitBoxOrient:"vertical"};function F(e){let{enableMeasure:l,width:r,text:o,children:a,rows:i,expanded:c,miscDeps:d,onEllipsis:p}=e,f=t.useMemo(()=>(0,s.default)(o),[o]),m=t.useMemo(()=>f.reduce((e,t)=>e+(A(t)?String(t).length:1),0),[o]),g=t.useMemo(()=>a(f,!1),[o]),[b,y]=t.useState(null),v=t.useRef(null),h=t.useRef(null),x=t.useRef(null),O=t.useRef(null),E=t.useRef(null),[S,w]=t.useState(!1),[j,C]=t.useState(0),[k,R]=t.useState(0),[$,T]=t.useState(null);(0,u.default)(()=>{l&&r&&m?C(1):C(0)},[r,o,i,l,f]),(0,u.default)(()=>{var e,t,n,l;if(1===j)C(2),T(h.current&&getComputedStyle(h.current).whiteSpace);else if(2===j){let r=!!(null==(e=x.current)?void 0:e.isExceed());C(r?3:4),y(r?[0,m]:null),w(r),R(Math.max((null==(t=x.current)?void 0:t.getHeight())||0,(1===i?0:(null==(n=O.current)?void 0:n.getHeight())||0)+((null==(l=E.current)?void 0:l.getHeight())||0))+1),p(r)}},[j]);let I=b?Math.ceil((b[0]+b[1])/2):0;(0,u.default)(()=>{var e;let[t,n]=b||[0,0];if(t!==n){let l=((null==(e=v.current)?void 0:e.getHeight())||0)>k,r=I;n-t==1&&(r=l?t:n),y(l?[t,r]:[r,n])}},[b,I]);let D=t.useMemo(()=>{if(!l)return a(f,!1);if(3!==j||!b||b[0]!==b[1]){let e=a(f,!1);return[4,0].includes(j)?e:t.createElement("span",{style:Object.assign(Object.assign({},U),{WebkitLineClamp:i})},e)}return a(c?f:N(f,b[0]),S)},[c,j,b,f].concat((0,n.default)(d))),P={width:r,margin:0,padding:0,whiteSpace:"nowrap"===$?"normal":"inherit"};return t.createElement(t.Fragment,null,D,2===j&&t.createElement(t.Fragment,null,t.createElement(L,{style:Object.assign(Object.assign(Object.assign({},P),U),{WebkitLineClamp:i}),ref:x},g),t.createElement(L,{style:Object.assign(Object.assign(Object.assign({},P),U),{WebkitLineClamp:i-1}),ref:O},g),t.createElement(L,{style:Object.assign(Object.assign(Object.assign({},P),U),{WebkitLineClamp:1}),ref:E},a([],!0))),3===j&&b&&b[0]!==b[1]&&t.createElement(L,{style:Object.assign(Object.assign({},P),{top:400}),ref:v},a(N(f,I),!0)),1===j&&t.createElement("span",{style:{whiteSpace:"inherit"},ref:h}))}let q=({enableEllipsis:e,isEllipsis:n,children:l,tooltipProps:r})=>(null==r?void 0:r.title)&&e?t.createElement(y.default,Object.assign({open:!!n&&void 0},r),l):l;var X=function(e,t){var n={};for(var l in e)Object.prototype.hasOwnProperty.call(e,l)&&0>t.indexOf(l)&&(n[l]=e[l]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols)for(var r=0,l=Object.getOwnPropertySymbols(e);rt.indexOf(l[r])&&Object.prototype.propertyIsEnumerable.call(e,l[r])&&(n[l[r]]=e[l[r]]);return n};let K=["delete","mark","code","underline","strong","keyboard","italic"],V=t.forwardRef((e,l)=>{var r;let o,v,h,{prefixCls:x,className:O,style:E,type:S,disabled:w,children:j,ellipsis:C,editable:I,copyable:P,component:B,title:M}=e,H=X(e,["prefixCls","className","style","type","disabled","children","ellipsis","editable","copyable","component","title"]),{getPrefixCls:z,direction:L}=t.useContext(g.ConfigContext),[N]=(0,b.default)("Text"),U=t.useRef(null),V=t.useRef(null),_=z("typography",x),G=(0,p.default)(H,K),[J,Q]=T(I),[Y,Z]=(0,d.default)(!1,{value:Q.editing}),{triggerType:ee=["icon"]}=Q,et=e=>{var t;e&&(null==(t=Q.onStart)||t.call(Q)),Z(e)},en=(o=(0,t.useRef)(void 0),(0,t.useEffect)(()=>{o.current=Y}),o.current);(0,u.default)(()=>{var e;!Y&&en&&(null==(e=V.current)||e.focus())},[Y]);let el=e=>{null==e||e.preventDefault(),et(!0)},[er,eo]=T(P),{copied:ea,copyLoading:ei,onClick:ec}=(({copyConfig:e,children:n})=>{let[l,r]=t.useState(!1),[o,a]=t.useState(!1),i=t.useRef(null),c=()=>{i.current&&clearTimeout(i.current)},s={};e.format&&(s.format=e.format),t.useEffect(()=>c,[]);let u=(0,$.default)(t=>{var l,o,u,d;return l=void 0,o=void 0,u=void 0,d=function*(){var l;null==t||t.preventDefault(),null==t||t.stopPropagation(),a(!0);try{let o="function"==typeof e.text?yield e.text():e.text;(0,R.default)(o||((e,t=!1)=>t&&null==e?[]:Array.isArray(e)?e:[e])(n,!0).join("")||"",s),a(!1),r(!0),c(),i.current=setTimeout(()=>{r(!1)},3e3),null==(l=e.onCopy)||l.call(e,t)}catch(e){throw a(!1),e}},new(u||(u=Promise))(function(e,t){function n(e){try{a(d.next(e))}catch(e){t(e)}}function r(e){try{a(d.throw(e))}catch(e){t(e)}}function a(t){var l;t.done?e(t.value):((l=t.value)instanceof u?l:new u(function(e){e(l)})).then(n,r)}a((d=d.apply(l,o||[])).next())})});return{copied:l,copyLoading:o,onClick:u}})({copyConfig:eo,children:j}),[es,eu]=t.useState(!1),[ed,ep]=t.useState(!1),[ef,em]=t.useState(!1),[eg,eb]=t.useState(!1),[ey,ev]=t.useState(!0),[eh,ex]=T(C,{expandable:!1,symbol:e=>e?null==N?void 0:N.collapse:null==N?void 0:N.expand}),[eO,eE]=(0,d.default)(ex.defaultExpanded||!1,{value:ex.expanded}),eS=eh&&(!eO||"collapsible"===ex.expandable),{rows:ew=1}=ex,ej=t.useMemo(()=>eS&&(void 0!==ex.suffix||ex.onEllipsis||ex.expandable||J||er),[eS,ex,J,er]);(0,u.default)(()=>{eh&&!ej&&(eu((0,m.isStyleSupport)("webkitLineClamp")),ep((0,m.isStyleSupport)("textOverflow")))},[ej,eh]);let[eC,ek]=t.useState(eS),eR=t.useMemo(()=>!ej&&(1===ew?ed:es),[ej,ed,es]);(0,u.default)(()=>{ek(eR&&eS)},[eR,eS]);let e$=eS&&(eC?eg:ef),eT=eS&&1===ew&&eC,eI=eS&&ew>1&&eC,[eD,eP]=t.useState(0),eB=e=>{var t;em(e),ef!==e&&(null==(t=ex.onEllipsis)||t.call(ex,e))};t.useEffect(()=>{let e=U.current;if(eh&&eC&&e){let t,n,l,r=(t=document.createElement("em"),e.appendChild(t),n=e.getBoundingClientRect(),l=t.getBoundingClientRect(),e.removeChild(t),n.left>l.left||l.right>n.right||n.top>l.top||l.bottom>n.bottom);eg!==r&&eb(r)}},[eh,eC,j,eI,ey,eD]),t.useEffect(()=>{let e=U.current;if("u"{ev(!!e.offsetParent)});return t.observe(e),()=>{t.disconnect()}},[eC,eS]);let eM=(v=ex.tooltip,h=Q.text,(0,t.useMemo)(()=>!0===v?{title:null!=h?h:j}:(0,t.isValidElement)(v)?{title:v}:"object"==typeof v?Object.assign({title:null!=h?h:j},v):{title:v},[v,h,j])),eH=t.useMemo(()=>{if(eh&&!eC)return[Q.text,j,M,eM.title].find(A)},[eh,eC,M,eM.title,e$]);return Y?t.createElement(k,{value:null!=(r=Q.text)?r:"string"==typeof j?j:"",onSave:e=>{var t;null==(t=Q.onChange)||t.call(Q,e),et(!1)},onCancel:()=>{var e;null==(e=Q.onCancel)||e.call(Q),et(!1)},onEnd:Q.onEnd,prefixCls:_,className:O,style:E,direction:L,component:B,maxLength:Q.maxLength,autoSize:Q.autoSize,enterIcon:Q.enterIcon}):t.createElement(c.default,{onResize:({offsetWidth:e})=>{eP(e)},disabled:!eS},r=>t.createElement(q,{tooltipProps:eM,enableEllipsis:eS,isEllipsis:e$},t.createElement(D,Object.assign({className:(0,i.default)({[`${_}-${S}`]:S,[`${_}-disabled`]:w,[`${_}-ellipsis`]:eh,[`${_}-ellipsis-single-line`]:eT,[`${_}-ellipsis-multiple-line`]:eI},O),prefixCls:x,style:Object.assign(Object.assign({},E),{WebkitLineClamp:eI?ew:void 0}),component:B,ref:(0,f.composeRef)(r,U,l),direction:L,onClick:ee.includes("text")?el:void 0,"aria-label":null==eH?void 0:eH.toString(),title:M},G),t.createElement(F,{enableMeasure:eS&&!eC,text:j,rows:ew,width:eD,onEllipsis:eB,expanded:eO,miscDeps:[ea,eO,ei,J,er,N].concat((0,n.default)(K.map(t=>e[t])))},(n,l)=>{let r;return function({mark:e,code:n,underline:l,delete:r,strong:o,keyboard:a,italic:i},c){let s=c;function u(e,n){n&&(s=t.createElement(e,{},s))}return u("strong",o),u("u",l),u("del",r),u("code",n),u("mark",e),u("kbd",a),u("i",i),s}(e,t.createElement(t.Fragment,null,n.length>0&&l&&!eO&&eH?t.createElement("span",{key:"show-content","aria-hidden":!0},n):n,[(r=l)&&!eO&&t.createElement("span",{"aria-hidden":!0,key:"ellipsis"},"..."),ex.suffix,[r&&(()=>{let{expandable:e,symbol:n}=ex;return e?t.createElement("button",{type:"button",key:"expand",className:`${_}-${eO?"collapse":"expand"}`,onClick:e=>{var t,n;eE((t={expanded:!eO}).expanded),null==(n=ex.onExpand)||n.call(ex,e,t)},"aria-label":eO?N.collapse:null==N?void 0:N.expand},"function"==typeof n?n(eO):n):null})(),(()=>{if(!J)return;let{icon:e,tooltip:n,tabIndex:l}=Q,r=(0,s.default)(n)[0]||(null==N?void 0:N.edit),o="string"==typeof r?r:"";return ee.includes("icon")?t.createElement(y.default,{key:"edit",title:!1===n?"":r},t.createElement("button",{type:"button",ref:V,className:`${_}-edit`,onClick:el,"aria-label":o,tabIndex:l},e||t.createElement(a,{role:"button"}))):null})(),er?t.createElement(W,Object.assign({key:"copy"},eo,{prefixCls:_,copied:ea,locale:N,onCopy:ec,loading:ei,iconOnly:null==j})):null]]))}))))});var _=function(e,t){var n={};for(var l in e)Object.prototype.hasOwnProperty.call(e,l)&&0>t.indexOf(l)&&(n[l]=e[l]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols)for(var r=0,l=Object.getOwnPropertySymbols(e);rt.indexOf(l[r])&&Object.prototype.propertyIsEnumerable.call(e,l[r])&&(n[l[r]]=e[l[r]]);return n};let G=t.forwardRef((e,n)=>{let{ellipsis:l,rel:r,children:o,navigate:a}=e,i=_(e,["ellipsis","rel","children","navigate"]),c=Object.assign(Object.assign({},i),{rel:void 0===r&&"_blank"===i.target?"noopener noreferrer":r});return t.createElement(V,Object.assign({},c,{ref:n,ellipsis:!!l,component:"a"}),o)});var J=function(e,t){var n={};for(var l in e)Object.prototype.hasOwnProperty.call(e,l)&&0>t.indexOf(l)&&(n[l]=e[l]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols)for(var r=0,l=Object.getOwnPropertySymbols(e);rt.indexOf(l[r])&&Object.prototype.propertyIsEnumerable.call(e,l[r])&&(n[l[r]]=e[l[r]]);return n};let Q=t.forwardRef((e,n)=>{let{children:l}=e,r=J(e,["children"]);return t.createElement(V,Object.assign({ref:n},r,{component:"div"}),l)});var Y=function(e,t){var n={};for(var l in e)Object.prototype.hasOwnProperty.call(e,l)&&0>t.indexOf(l)&&(n[l]=e[l]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols)for(var r=0,l=Object.getOwnPropertySymbols(e);rt.indexOf(l[r])&&Object.prototype.propertyIsEnumerable.call(e,l[r])&&(n[l[r]]=e[l[r]]);return n};let Z=t.forwardRef((e,n)=>{let{ellipsis:l,children:r}=e,o=Y(e,["ellipsis","children"]),a=t.useMemo(()=>l&&"object"==typeof l?(0,p.default)(l,["expandable","rows"]):l,[l]);return t.createElement(V,Object.assign({ref:n},o,{ellipsis:a,component:"span"}),r)});var ee=function(e,t){var n={};for(var l in e)Object.prototype.hasOwnProperty.call(e,l)&&0>t.indexOf(l)&&(n[l]=e[l]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols)for(var r=0,l=Object.getOwnPropertySymbols(e);rt.indexOf(l[r])&&Object.prototype.propertyIsEnumerable.call(e,l[r])&&(n[l[r]]=e[l[r]]);return n};let et=[1,2,3,4,5],en=t.forwardRef((e,n)=>{let{level:l=1,children:r}=e,o=ee(e,["level","children"]),a=et.includes(l)?`h${l}`:"h1";return t.createElement(V,Object.assign({ref:n},o,{component:a}),r)});e.s(["default",0,en],335771),D.Text=Z,D.Link=G,D.Title=en,D.Paragraph=Q,e.s(["Typography",0,D],898586)}]); \ No newline at end of file diff --git a/litellm/proxy/_experimental/out/_next/static/chunks/0b27adb95e5b531e.js b/litellm/proxy/_experimental/out/_next/static/chunks/0b27adb95e5b531e.js new file mode 100644 index 00000000000..f6841cc4c19 --- /dev/null +++ b/litellm/proxy/_experimental/out/_next/static/chunks/0b27adb95e5b531e.js @@ -0,0 +1,84 @@ +(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,487304,e=>{"use strict";var t,l,a=e.i(843476),r=e.i(271645),s=e.i(994388),i=e.i(653824),n=e.i(881073),o=e.i(197647),d=e.i(723731),c=e.i(404206),u=e.i(326373),m=e.i(755151),p=e.i(646563),x=e.i(245094),g=e.i(764205),h=e.i(808613),f=e.i(898586),y=e.i(199133),j=e.i(212931),_=e.i(262218),v=e.i(280898),b=e.i(779241),N=((t={}).PresidioPII="Presidio PII",t.Bedrock="Bedrock Guardrail",t.Lakera="Lakera",t);let w={},C=e=>{let t={};return t.PresidioPII="Presidio PII",t.Bedrock="Bedrock Guardrail",t.Lakera="Lakera",Object.entries(e).forEach(([e,l])=>{l&&"object"==typeof l&&"ui_friendly_name"in l&&(t[e.split("_").map((e,t)=>e.charAt(0).toUpperCase()+e.slice(1)).join("")]=l.ui_friendly_name)}),w=t,t},S=()=>Object.keys(w).length>0?w:N,k={PresidioPII:"presidio",Bedrock:"bedrock",Lakera:"lakera_v2",LitellmContentFilter:"litellm_content_filter",ToolPermission:"tool_permission"},T=e=>{Object.entries(e).forEach(([e,t])=>{t&&"object"==typeof t&&"ui_friendly_name"in t&&(k[e.split("_").map((e,t)=>e.charAt(0).toUpperCase()+e.slice(1)).join("")]=e)})},O=e=>!!e&&"Presidio PII"===S()[e],I=e=>!!e&&"LiteLLM Content Filter"===S()[e],P="../ui/assets/logos/",A={"Presidio PII":`${P}presidio.png`,"Bedrock Guardrail":`${P}bedrock.svg`,Lakera:`${P}lakeraai.jpeg`,"Azure Content Safety Prompt Shield":`${P}presidio.png`,"Azure Content Safety Text Moderation":`${P}presidio.png`,"Aporia AI":`${P}aporia.png`,"PANW Prisma AIRS":`${P}palo_alto_networks.jpeg`,"Noma Security":`${P}noma_security.png`,"Javelin Guardrails":`${P}javelin.png`,"Pillar Guardrail":`${P}pillar.jpeg`,"Google Cloud Model Armor":`${P}google.svg`,"Guardrails AI":`${P}guardrails_ai.jpeg`,"Lasso Guardrail":`${P}lasso.png`,"Pangea Guardrail":`${P}pangea.png`,"AIM Guardrail":`${P}aim_security.jpeg`,"OpenAI Moderation":`${P}openai_small.svg`,EnkryptAI:`${P}enkrypt_ai.avif`,"Prompt Security":`${P}prompt_security.png`,"LiteLLM Content Filter":`${P}litellm_logo.jpg`},B=e=>{if(!e)return{logo:"",displayName:"-"};let t=Object.keys(k).find(t=>k[t].toLowerCase()===e.toLowerCase());if(!t)return{logo:"",displayName:e};let l=S()[t];return{logo:A[l]||"",displayName:l||e}};var L=e.i(464571),F=e.i(536916),E=e.i(592968),M=e.i(149192),R=e.i(741585),R=R,z=e.i(724154);e.i(247167);var G=e.i(931067);let $={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M880.1 154H143.9c-24.5 0-39.8 26.7-27.5 48L349 597.4V838c0 17.7 14.2 32 31.8 32h262.4c17.6 0 31.8-14.3 31.8-32V597.4L907.7 202c12.2-21.3-3.1-48-27.6-48zM603.4 798H420.6V642h182.9v156zm9.6-236.6l-9.5 16.6h-183l-9.5-16.6L212.7 226h598.6L613 561.4z"}}]},name:"filter",theme:"outlined"};var D=e.i(9583),K=r.forwardRef(function(e,t){return r.createElement(D.default,(0,G.default)({},e,{ref:t,icon:$}))});let{Text:J}=f.Typography,{Option:q}=y.Select,U=({categories:e,selectedCategories:t,onChange:l})=>(0,a.jsxs)("div",{children:[(0,a.jsxs)("div",{className:"flex items-center mb-2",children:[(0,a.jsx)(K,{className:"text-gray-500 mr-1"}),(0,a.jsx)(J,{className:"text-gray-500 font-medium",children:"Filter by category"})]}),(0,a.jsx)(y.Select,{mode:"multiple",placeholder:"Select categories to filter by",style:{width:"100%"},onChange:l,value:t,allowClear:!0,showSearch:!0,optionFilterProp:"children",className:"mb-4",tagRender:e=>(0,a.jsx)(_.Tag,{color:"blue",closable:e.closable,onClose:e.onClose,className:"mr-2 mb-2",children:e.label}),children:e.map(e=>(0,a.jsx)(q,{value:e.category,children:e.category},e.category))})]}),V=({onSelectAll:e,onUnselectAll:t,hasSelectedEntities:l})=>(0,a.jsxs)("div",{className:"bg-gray-50 p-5 rounded-lg mb-6 border border-gray-200 shadow-sm",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between mb-4",children:[(0,a.jsxs)("div",{className:"flex items-center",children:[(0,a.jsx)(J,{strong:!0,className:"text-gray-700 text-base",children:"Quick Actions"}),(0,a.jsx)(E.Tooltip,{title:"Apply action to all PII types at once",children:(0,a.jsx)("div",{className:"ml-2 text-gray-400 cursor-help text-xs",children:"ⓘ"})})]}),(0,a.jsx)(L.Button,{color:"danger",variant:"outlined",onClick:t,disabled:!l,icon:(0,a.jsx)(M.CloseOutlined,{}),children:"Unselect All"})]}),(0,a.jsxs)("div",{className:"grid grid-cols-2 gap-4",children:[(0,a.jsx)(L.Button,{color:"primary",variant:"outlined",onClick:()=>e("MASK"),className:"h-10",block:!0,icon:(0,a.jsx)(R.default,{}),children:"Select All & Mask"}),(0,a.jsx)(L.Button,{color:"danger",variant:"outlined",onClick:()=>e("BLOCK"),className:"h-10 hover:bg-red-100",block:!0,icon:(0,a.jsx)(z.StopOutlined,{}),children:"Select All & Block"})]})]}),H=({entities:e,selectedEntities:t,selectedActions:l,actions:r,onEntitySelect:s,onActionSelect:i,entityToCategoryMap:n})=>(0,a.jsxs)("div",{className:"border rounded-lg overflow-hidden shadow-sm",children:[(0,a.jsxs)("div",{className:"bg-gray-50 px-5 py-3 border-b flex",children:[(0,a.jsx)(J,{strong:!0,className:"flex-1 text-gray-700",children:"PII Type"}),(0,a.jsx)(J,{strong:!0,className:"w-32 text-right text-gray-700",children:"Action"})]}),(0,a.jsx)("div",{className:"max-h-[400px] overflow-y-auto",children:0===e.length?(0,a.jsx)("div",{className:"py-10 text-center text-gray-500",children:"No PII types match your filter criteria"}):e.map(e=>(0,a.jsxs)("div",{className:`px-5 py-3 flex items-center justify-between hover:bg-gray-50 border-b ${t.includes(e)?"bg-blue-50":""}`,children:[(0,a.jsxs)("div",{className:"flex items-center flex-1",children:[(0,a.jsx)(F.Checkbox,{checked:t.includes(e),onChange:()=>s(e),className:"mr-3"}),(0,a.jsx)(J,{className:t.includes(e)?"font-medium text-gray-900":"text-gray-700",children:e.replace(/_/g," ")}),n.get(e)&&(0,a.jsx)(_.Tag,{className:"ml-2 text-xs",color:"blue",children:n.get(e)})]}),(0,a.jsx)("div",{className:"w-32",children:(0,a.jsx)(y.Select,{value:t.includes(e)&&l[e]||"MASK",onChange:t=>i(e,t),style:{width:120},disabled:!t.includes(e),className:`${!t.includes(e)?"opacity-50":""}`,dropdownMatchSelectWidth:!1,children:r.map(e=>(0,a.jsx)(q,{value:e,children:(0,a.jsxs)("div",{className:"flex items-center",children:[(e=>{switch(e){case"MASK":return(0,a.jsx)(R.default,{style:{marginRight:4}});case"BLOCK":return(0,a.jsx)(z.StopOutlined,{style:{marginRight:4}});default:return null}})(e),e]})},e))})})]},e))})]}),{Title:Y,Text:W}=f.Typography,Q=({entities:e,actions:t,selectedEntities:l,selectedActions:s,onEntitySelect:i,onActionSelect:n,entityCategories:o=[]})=>{let[d,c]=(0,r.useState)([]),u=new Map;o.forEach(e=>{e.entities.forEach(t=>{u.set(t,e.category)})});let m=e.filter(e=>0===d.length||d.includes(u.get(e)||""));return(0,a.jsxs)("div",{className:"pii-configuration",children:[(0,a.jsxs)("div",{className:"flex justify-between items-center mb-5",children:[(0,a.jsx)("div",{className:"flex items-center",children:(0,a.jsx)(Y,{level:4,className:"!m-0 font-semibold text-gray-800",children:"Configure PII Protection"})}),(0,a.jsxs)(W,{className:"text-gray-500",children:[l.length," items selected"]})]}),(0,a.jsxs)("div",{className:"mb-6",children:[(0,a.jsx)(U,{categories:o,selectedCategories:d,onChange:c}),(0,a.jsx)(V,{onSelectAll:t=>{e.forEach(e=>{l.includes(e)||i(e),n(e,t)})},onUnselectAll:()=>{l.forEach(e=>{i(e)})},hasSelectedEntities:l.length>0})]}),(0,a.jsx)(H,{entities:m,selectedEntities:l,selectedActions:s,actions:t,onEntitySelect:i,onActionSelect:n,entityToCategoryMap:u})]})};var Z=e.i(482725),X=e.i(435451);let ee=({selectedProvider:e,accessToken:t,providerParams:l=null,value:s=null})=>{let[i,n]=(0,r.useState)(!1),[o,d]=(0,r.useState)(l),[c,u]=(0,r.useState)(null);if((0,r.useEffect)(()=>{if(l)return void d(l);let e=async()=>{if(t){n(!0),u(null);try{let e=await (0,g.getGuardrailProviderSpecificParams)(t);console.log("Provider params API response:",e),d(e),C(e),T(e)}catch(e){console.error("Error fetching provider params:",e),u("Failed to load provider parameters")}finally{n(!1)}}};l||e()},[t,l]),!e)return null;if(i)return(0,a.jsx)(Z.Spin,{tip:"Loading provider parameters..."});if(c)return(0,a.jsx)("div",{className:"text-red-500",children:c});let m=k[e]?.toLowerCase(),p=o&&o[m];if(console.log("Provider key:",m),console.log("Provider fields:",p),!p||0===Object.keys(p).length)return(0,a.jsx)("div",{children:"No configuration fields available for this provider."});console.log("Value:",s);let x=new Set(["patterns","blocked_words","blocked_words_file","categories","severity_threshold","pattern_redaction_format","keyword_redaction_tag"]),f=I(e),j=(e,t="",l)=>Object.entries(e).map(([e,r])=>{let i=t?`${t}.${e}`:e,n=l?l[e]:s?.[e];return(console.log("Field value:",n),"ui_friendly_name"===e||"optional_params"===e&&"nested"===r.type&&r.fields||f&&x.has(e))?null:"nested"===r.type&&r.fields?(0,a.jsxs)("div",{children:[(0,a.jsx)("div",{className:"mb-2 font-medium",children:e}),(0,a.jsx)("div",{className:"ml-4 border-l-2 border-gray-200 pl-4",children:j(r.fields,i,n)})]},i):(0,a.jsx)(h.Form.Item,{name:i,label:e,tooltip:r.description,rules:r.required?[{required:!0,message:`${e} is required`}]:void 0,children:"select"===r.type&&r.options?(0,a.jsx)(y.Select,{placeholder:r.description,defaultValue:n||r.default_value,children:r.options.map(e=>(0,a.jsx)(y.Select.Option,{value:e,children:e},e))}):"multiselect"===r.type&&r.options?(0,a.jsx)(y.Select,{mode:"multiple",placeholder:r.description,defaultValue:n||r.default_value,children:r.options.map(e=>(0,a.jsx)(y.Select.Option,{value:e,children:e},e))}):"bool"===r.type||"boolean"===r.type?(0,a.jsxs)(y.Select,{placeholder:r.description,defaultValue:void 0!==n?String(n):r.default_value,children:[(0,a.jsx)(y.Select.Option,{value:"true",children:"True"}),(0,a.jsx)(y.Select.Option,{value:"false",children:"False"})]}):"number"===r.type?(0,a.jsx)(X.default,{step:1,width:400,placeholder:r.description,defaultValue:void 0!==n?Number(n):void 0}):e.includes("password")||e.includes("secret")||e.includes("key")?(0,a.jsx)(b.TextInput,{placeholder:r.description,type:"password",defaultValue:n||""}):(0,a.jsx)(b.TextInput,{placeholder:r.description,type:"text",defaultValue:n||""})},i)});return(0,a.jsx)(a.Fragment,{children:j(p)})},{Title:et}=f.Typography,el=({field:e,fieldKey:t,fullFieldKey:l,value:s})=>{let[i,n]=r.default.useState([]),[o,d]=r.default.useState(e.dict_key_options||[]);return r.default.useEffect(()=>{if(s&&"object"==typeof s){let t=Object.keys(s);n(t.map(e=>({key:e,id:`${e}_${Date.now()}_${Math.random()}`}))),d((e.dict_key_options||[]).filter(e=>!t.includes(e)))}},[s,e.dict_key_options]),(0,a.jsxs)("div",{className:"space-y-3",children:[i.map(t=>(0,a.jsxs)("div",{className:"flex items-center space-x-3 p-3 border rounded-lg",children:[(0,a.jsx)("div",{className:"w-24 font-medium text-sm",children:t.key}),(0,a.jsx)("div",{className:"flex-1",children:(0,a.jsx)(h.Form.Item,{name:Array.isArray(l)?[...l,t.key]:[l,t.key],style:{marginBottom:0},initialValue:s&&"object"==typeof s?s[t.key]:void 0,normalize:"number"===e.dict_value_type?e=>{if(null==e||""===e)return;let t=Number(e);return isNaN(t)?e:t}:void 0,children:"number"===e.dict_value_type?(0,a.jsx)(X.default,{step:1,width:200,placeholder:`Enter ${t.key} value`}):"boolean"===e.dict_value_type?(0,a.jsxs)(y.Select,{placeholder:`Select ${t.key} value`,children:[(0,a.jsx)(y.Select.Option,{value:!0,children:"True"}),(0,a.jsx)(y.Select.Option,{value:!1,children:"False"})]}):(0,a.jsx)(b.TextInput,{placeholder:`Enter ${t.key} value`,type:"text"})})}),(0,a.jsx)("button",{type:"button",className:"text-red-500 hover:text-red-700 text-sm",onClick:()=>{var e,l;return e=t.id,l=t.key,void(n(i.filter(t=>t.id!==e)),d([...o,l].sort()))},children:"Remove"})]},t.id)),o.length>0&&(0,a.jsxs)("div",{className:"flex items-center space-x-3 mt-2",children:[(0,a.jsx)(y.Select,{placeholder:"Select category to configure",style:{width:200},onSelect:e=>e&&void(!e||(n([...i,{key:e,id:`${e}_${Date.now()}`}]),d(o.filter(t=>t!==e)))),value:void 0,children:o.map(e=>(0,a.jsx)(y.Select.Option,{value:e,children:e},e))}),(0,a.jsx)("span",{className:"text-sm text-gray-500",children:"Select a category to add threshold configuration"})]})]})},ea=({optionalParams:e,parentFieldKey:t,values:l})=>e.fields&&0!==Object.keys(e.fields).length?(0,a.jsxs)("div",{className:"guardrail-optional-params",children:[(0,a.jsxs)("div",{className:"mb-8 pb-4 border-b border-gray-100",children:[(0,a.jsx)(et,{level:3,className:"mb-2 font-semibold text-gray-900",children:"Optional Parameters"}),(0,a.jsx)("p",{className:"text-gray-600 text-sm",children:e.description||"Configure additional settings for this guardrail provider"})]}),(0,a.jsx)("div",{className:"space-y-8",children:Object.entries(e.fields).map(([e,r])=>{let s,i;return s=`${t}.${e}`,(console.log("value",i=l?.[e]),"dict"===r.type&&r.dict_key_options)?(0,a.jsxs)("div",{className:"mb-8 p-6 bg-gray-50 rounded-lg border border-gray-200",children:[(0,a.jsx)("div",{className:"mb-4 font-medium text-gray-900 text-base",children:e}),(0,a.jsx)("p",{className:"text-sm text-gray-600 mb-4",children:r.description}),(0,a.jsx)(el,{field:r,fieldKey:e,fullFieldKey:[t,e],value:i})]},s):(0,a.jsx)("div",{className:"mb-8 p-6 bg-white rounded-lg border border-gray-200 shadow-sm",children:(0,a.jsx)(h.Form.Item,{name:[t,e],label:(0,a.jsxs)("div",{className:"mb-2",children:[(0,a.jsx)("div",{className:"font-medium text-gray-900 text-base",children:e}),(0,a.jsx)("p",{className:"text-sm text-gray-600 mt-1",children:r.description})]}),rules:r.required?[{required:!0,message:`${e} is required`}]:void 0,className:"mb-0",initialValue:void 0!==i?i:r.default_value,normalize:"number"===r.type?e=>{if(null==e||""===e)return;let t=Number(e);return isNaN(t)?e:t}:void 0,children:"select"===r.type&&r.options?(0,a.jsx)(y.Select,{placeholder:r.description,children:r.options.map(e=>(0,a.jsx)(y.Select.Option,{value:e,children:e},e))}):"multiselect"===r.type&&r.options?(0,a.jsx)(y.Select,{mode:"multiple",placeholder:r.description,children:r.options.map(e=>(0,a.jsx)(y.Select.Option,{value:e,children:e},e))}):"bool"===r.type||"boolean"===r.type?(0,a.jsxs)(y.Select,{placeholder:r.description,children:[(0,a.jsx)(y.Select.Option,{value:"true",children:"True"}),(0,a.jsx)(y.Select.Option,{value:"false",children:"False"})]}):"number"===r.type?(0,a.jsx)(X.default,{step:1,width:400,placeholder:r.description}):e.includes("password")||e.includes("secret")||e.includes("key")?(0,a.jsx)(b.TextInput,{placeholder:r.description,type:"password"}):(0,a.jsx)(b.TextInput,{placeholder:r.description,type:"text"})})},s)})})]}):null;var er=e.i(727749),es=e.i(770914),ei=e.i(515831),en=e.i(175712),eo=e.i(519756);let{Text:ed}=f.Typography,{Option:ec}=y.Select,eu=({visible:e,prebuiltPatterns:t,categories:l,selectedPatternName:r,patternAction:i,onPatternNameChange:n,onActionChange:o,onAdd:d,onCancel:c})=>(0,a.jsxs)(j.Modal,{title:"Add prebuilt pattern",open:e,onCancel:c,footer:null,width:800,children:[(0,a.jsxs)(es.Space,{direction:"vertical",style:{width:"100%"},size:"large",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)(ed,{strong:!0,children:"Pattern type"}),(0,a.jsx)(y.Select,{placeholder:"Choose pattern type",value:r,onChange:n,style:{width:"100%",marginTop:8},showSearch:!0,filterOption:(e,l)=>{let a=t.find(e=>e.name===l?.value);return!!a&&(a.display_name.toLowerCase().includes(e.toLowerCase())||a.name.toLowerCase().includes(e.toLowerCase()))},children:l.map(e=>{let l=t.filter(t=>t.category===e);return 0===l.length?null:(0,a.jsx)(y.Select.OptGroup,{label:e,children:l.map(e=>(0,a.jsx)(ec,{value:e.name,children:e.display_name},e.name))},e)})})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)(ed,{strong:!0,children:"Action"}),(0,a.jsx)(ed,{type:"secondary",style:{display:"block",marginTop:4,marginBottom:8},children:"Choose what action the guardrail should take when this pattern is detected"}),(0,a.jsxs)(y.Select,{value:i,onChange:o,style:{width:"100%"},children:[(0,a.jsx)(ec,{value:"BLOCK",children:"Block"}),(0,a.jsx)(ec,{value:"MASK",children:"Mask"})]})]})]}),(0,a.jsxs)("div",{style:{display:"flex",justifyContent:"flex-end",gap:"8px",marginTop:"24px"},children:[(0,a.jsx)(s.Button,{variant:"secondary",onClick:c,children:"Cancel"}),(0,a.jsx)(s.Button,{onClick:d,children:"Add"})]})]}),{Text:em}=f.Typography,{Option:ep}=y.Select,ex=({visible:e,patternName:t,patternRegex:l,patternAction:r,onNameChange:i,onRegexChange:n,onActionChange:o,onAdd:d,onCancel:c})=>(0,a.jsxs)(j.Modal,{title:"Add custom regex pattern",open:e,onCancel:c,footer:null,width:800,children:[(0,a.jsxs)(es.Space,{direction:"vertical",style:{width:"100%"},size:"large",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)(em,{strong:!0,children:"Pattern name"}),(0,a.jsx)(b.TextInput,{placeholder:"e.g., internal_id, employee_code",value:t,onValueChange:i,style:{marginTop:8}})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)(em,{strong:!0,children:"Regex pattern"}),(0,a.jsx)(b.TextInput,{placeholder:"e.g., ID-[0-9]{6}",value:l,onValueChange:n,style:{marginTop:8}}),(0,a.jsx)(em,{type:"secondary",style:{fontSize:12},children:"Enter a valid regular expression to match sensitive data"})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)(em,{strong:!0,children:"Action"}),(0,a.jsx)(em,{type:"secondary",style:{display:"block",marginTop:4,marginBottom:8},children:"Choose what action the guardrail should take when this pattern is detected"}),(0,a.jsxs)(y.Select,{value:r,onChange:o,style:{width:"100%"},children:[(0,a.jsx)(ep,{value:"BLOCK",children:"Block"}),(0,a.jsx)(ep,{value:"MASK",children:"Mask"})]})]})]}),(0,a.jsxs)("div",{style:{display:"flex",justifyContent:"flex-end",gap:"8px",marginTop:"24px"},children:[(0,a.jsx)(s.Button,{variant:"secondary",onClick:c,children:"Cancel"}),(0,a.jsx)(s.Button,{onClick:d,children:"Add"})]})]});var eg=e.i(78085);let{Text:eh}=f.Typography,{Option:ef}=y.Select,ey=({visible:e,keyword:t,action:l,description:r,onKeywordChange:i,onActionChange:n,onDescriptionChange:o,onAdd:d,onCancel:c})=>(0,a.jsxs)(j.Modal,{title:"Add blocked keyword",open:e,onCancel:c,footer:null,width:800,children:[(0,a.jsxs)(es.Space,{direction:"vertical",style:{width:"100%"},size:"large",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)(eh,{strong:!0,children:"Keyword"}),(0,a.jsx)(b.TextInput,{placeholder:"Enter sensitive keyword or phrase",value:t,onValueChange:i,style:{marginTop:8}})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)(eh,{strong:!0,children:"Action"}),(0,a.jsx)(eh,{type:"secondary",style:{display:"block",marginTop:4,marginBottom:8},children:"Choose what action the guardrail should take when this keyword is detected"}),(0,a.jsxs)(y.Select,{value:l,onChange:n,style:{width:"100%"},children:[(0,a.jsx)(ef,{value:"BLOCK",children:"Block"}),(0,a.jsx)(ef,{value:"MASK",children:"Mask"})]})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)(eh,{strong:!0,children:"Description (optional)"}),(0,a.jsx)(eg.Textarea,{placeholder:"Explain why this keyword is sensitive",value:r,onValueChange:o,rows:3,style:{marginTop:8}})]})]}),(0,a.jsxs)("div",{style:{display:"flex",justifyContent:"flex-end",gap:"8px",marginTop:"24px"},children:[(0,a.jsx)(s.Button,{variant:"secondary",onClick:c,children:"Cancel"}),(0,a.jsx)(s.Button,{onClick:d,children:"Add"})]})]});var ej=e.i(291542),e_=e.i(955135);let{Text:ev}=f.Typography,{Option:eb}=y.Select,eN=({patterns:e,onActionChange:t,onRemove:l})=>{let r=[{title:"Type",dataIndex:"type",key:"type",width:100,render:e=>(0,a.jsx)(_.Tag,{color:"prebuilt"===e?"blue":"green",children:"prebuilt"===e?"Prebuilt":"Custom"})},{title:"Pattern name",dataIndex:"name",key:"name",render:(e,t)=>t.display_name||t.name},{title:"Regex pattern",dataIndex:"pattern",key:"pattern",render:e=>e?(0,a.jsxs)(ev,{code:!0,style:{fontSize:12},children:[e.substring(0,40),"..."]}):"-"},{title:"Action",dataIndex:"action",key:"action",width:150,render:(e,l)=>(0,a.jsxs)(y.Select,{value:e,onChange:e=>t(l.id,e),style:{width:120},size:"small",children:[(0,a.jsx)(eb,{value:"BLOCK",children:"Block"}),(0,a.jsx)(eb,{value:"MASK",children:"Mask"})]})},{title:"",key:"actions",width:100,render:(e,t)=>(0,a.jsx)(s.Button,{type:"button",variant:"light",color:"red",size:"xs",icon:e_.DeleteOutlined,onClick:()=>l(t.id),children:"Delete"})}];return 0===e.length?(0,a.jsx)("div",{style:{textAlign:"center",padding:"40px 0",color:"#999"},children:"No patterns added."}):(0,a.jsx)(ej.Table,{dataSource:e,columns:r,rowKey:"id",pagination:!1,size:"small"})},{Text:ew}=f.Typography,{Option:eC}=y.Select,eS=({keywords:e,onActionChange:t,onRemove:l})=>{let r=[{title:"Keyword",dataIndex:"keyword",key:"keyword"},{title:"Action",dataIndex:"action",key:"action",width:150,render:(e,l)=>(0,a.jsxs)(y.Select,{value:e,onChange:e=>t(l.id,"action",e),style:{width:120},size:"small",children:[(0,a.jsx)(eC,{value:"BLOCK",children:"Block"}),(0,a.jsx)(eC,{value:"MASK",children:"Mask"})]})},{title:"Description",dataIndex:"description",key:"description",render:e=>e||"-"},{title:"",key:"actions",width:100,render:(e,t)=>(0,a.jsx)(s.Button,{type:"button",variant:"light",color:"red",size:"xs",icon:e_.DeleteOutlined,onClick:()=>l(t.id),children:"Delete"})}];return 0===e.length?(0,a.jsx)("div",{style:{textAlign:"center",padding:"40px 0",color:"#999"},children:"No keywords added."}):(0,a.jsx)(ej.Table,{dataSource:e,columns:r,rowKey:"id",pagination:!1,size:"small"})};var ek=e.i(362024),eT=e.i(993914);let{Title:eO,Text:eI}=f.Typography,{Option:eP}=y.Select,{Panel:eA}=ek.Collapse,eB=({availableCategories:e,selectedCategories:t,onCategoryAdd:l,onCategoryRemove:i,onCategoryUpdate:n,accessToken:o})=>{let[d,c]=r.default.useState(""),[u,m]=r.default.useState({}),[x,h]=r.default.useState({}),[f,j]=r.default.useState([]),[v,b]=r.default.useState(""),[N,w]=r.default.useState(!1),C=async e=>{if(o&&!u[e]){h(t=>({...t,[e]:!0}));try{let t=await (0,g.getCategoryYaml)(o,e);m(l=>({...l,[e]:t.yaml_content}))}catch(t){console.error(`Failed to fetch YAML for category ${e}:`,t)}finally{h(t=>({...t,[e]:!1}))}}};r.default.useEffect(()=>{if(d&&o){let e=u[d];if(e)return void b(e);w(!0),console.log(`Fetching YAML for category: ${d}`,{accessToken:o?"present":"missing"}),(0,g.getCategoryYaml)(o,d).then(e=>{console.log(`Successfully fetched YAML for ${d}:`,e),b(e.yaml_content),m(t=>({...t,[d]:e.yaml_content}))}).catch(e=>{console.error(`Failed to fetch preview YAML for category ${d}:`,e),b("")}).finally(()=>{w(!1)})}else b(""),w(!1)},[d,o]);let S=[{title:"Category",dataIndex:"display_name",key:"display_name",render:(t,l)=>{let r=e.find(e=>e.name===l.category);return(0,a.jsxs)("div",{children:[(0,a.jsx)("div",{style:{fontWeight:500},children:t}),r?.description&&(0,a.jsx)("div",{style:{fontSize:"12px",color:"#888",marginTop:"4px"},children:r.description})]})}},{title:"Action",dataIndex:"action",key:"action",width:150,render:(e,t)=>(0,a.jsxs)(y.Select,{value:e,onChange:e=>n(t.id,"action",e),style:{width:"100%"},children:[(0,a.jsx)(eP,{value:"BLOCK",children:(0,a.jsx)(_.Tag,{color:"red",children:"BLOCK"})}),(0,a.jsx)(eP,{value:"MASK",children:(0,a.jsx)(_.Tag,{color:"orange",children:"MASK"})})]})},{title:"Severity Threshold",dataIndex:"severity_threshold",key:"severity_threshold",width:180,render:(e,t)=>(0,a.jsxs)(y.Select,{value:e,onChange:e=>n(t.id,"severity_threshold",e),style:{width:"100%"},children:[(0,a.jsx)(eP,{value:"low",children:"Low"}),(0,a.jsx)(eP,{value:"medium",children:"Medium"}),(0,a.jsx)(eP,{value:"high",children:"High"})]})},{title:"",key:"actions",width:80,render:(e,t)=>(0,a.jsx)(s.Button,{icon:e_.DeleteOutlined,onClick:()=>i(t.id),variant:"secondary",size:"xs",children:"Remove"})}],k=e.filter(e=>!t.some(t=>t.category===e.name));return(0,a.jsxs)(en.Card,{title:(0,a.jsxs)("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[(0,a.jsx)(eO,{level:5,style:{margin:0},children:"Content Categories"}),(0,a.jsx)(eI,{type:"secondary",style:{fontSize:14,fontWeight:400},children:"Detect harmful content, bias, and inappropriate advice using semantic analysis"})]}),size:"small",children:[(0,a.jsxs)("div",{style:{marginBottom:16,display:"flex",gap:8},children:[(0,a.jsx)(y.Select,{placeholder:"Select a content category",value:d||void 0,onChange:c,style:{flex:1},showSearch:!0,optionLabelProp:"label",filterOption:(e,t)=>(t?.label?.toString().toLowerCase()??"").includes(e.toLowerCase()),children:k.map(e=>(0,a.jsx)(eP,{value:e.name,label:e.display_name,children:(0,a.jsxs)("div",{children:[(0,a.jsx)("div",{style:{fontWeight:500},children:e.display_name}),(0,a.jsx)("div",{style:{fontSize:"12px",color:"#666",marginTop:"2px"},children:e.description})]})},e.name))}),(0,a.jsx)(s.Button,{onClick:()=>{if(!d)return;let a=e.find(e=>e.name===d);!a||t.some(e=>e.category===d)||(l({id:`category-${Date.now()}`,category:a.name,display_name:a.display_name,action:a.default_action,severity_threshold:"medium"}),c(""),b(""))},disabled:!d,icon:p.PlusOutlined,children:"Add"})]}),d&&(0,a.jsxs)("div",{style:{marginBottom:16,padding:"12px",background:"#f9f9f9",border:"1px solid #e0e0e0",borderRadius:"4px"},children:[(0,a.jsxs)("div",{style:{marginBottom:8,fontWeight:500,fontSize:"14px"},children:["Preview: ",e.find(e=>e.name===d)?.display_name]}),N?(0,a.jsx)("div",{style:{padding:"16px",textAlign:"center",color:"#888"},children:"Loading YAML..."}):v?(0,a.jsx)("pre",{style:{background:"#fff",padding:"12px",borderRadius:"4px",overflow:"auto",maxHeight:"300px",fontSize:"12px",lineHeight:"1.5",margin:0,border:"1px solid #e0e0e0"},children:(0,a.jsx)("code",{children:v})}):(0,a.jsx)("div",{style:{padding:"8px",textAlign:"center",color:"#888",fontSize:"12px"},children:"Unable to load YAML content"})]}),t.length>0?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(ej.Table,{dataSource:t,columns:S,pagination:!1,size:"small",rowKey:"id"}),(0,a.jsx)("div",{style:{marginTop:16},children:(0,a.jsx)(ek.Collapse,{activeKey:f,onChange:e=>{let t=Array.isArray(e)?e:e?[e]:[],l=new Set(f);t.forEach(e=>{l.has(e)||u[e]||C(e)}),j(t)},ghost:!0,children:t.map(e=>(0,a.jsx)(eA,{header:(0,a.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8},children:[(0,a.jsx)(eT.FileTextOutlined,{}),(0,a.jsxs)("span",{children:["View YAML for ",e.display_name]})]}),children:x[e.category]?(0,a.jsx)("div",{style:{padding:"16px",textAlign:"center",color:"#888"},children:"Loading YAML..."}):u[e.category]?(0,a.jsx)("pre",{style:{background:"#f5f5f5",padding:"16px",borderRadius:"4px",overflow:"auto",maxHeight:"400px",fontSize:"12px",lineHeight:"1.5",margin:0},children:(0,a.jsx)("code",{children:u[e.category]})}):(0,a.jsx)("div",{style:{padding:"16px",textAlign:"center",color:"#888"},children:"YAML will load when expanded"})},e.category))})})]}):(0,a.jsx)("div",{style:{textAlign:"center",padding:"24px",color:"#888",border:"1px dashed #d9d9d9",borderRadius:"4px"},children:"No content categories selected. Add categories to detect harmful content, bias, or inappropriate advice."})]})},{Title:eL,Text:eF}=f.Typography,eE=({prebuiltPatterns:e,categories:t,selectedPatterns:l,blockedWords:i,onPatternAdd:n,onPatternRemove:o,onPatternActionChange:d,onBlockedWordAdd:c,onBlockedWordRemove:u,onBlockedWordUpdate:m,onFileUpload:x,accessToken:h,showStep:f,contentCategories:y=[],selectedContentCategories:j=[],onContentCategoryAdd:_,onContentCategoryRemove:v,onContentCategoryUpdate:b})=>{let[N,w]=(0,r.useState)(!1),[C,S]=(0,r.useState)(!1),[k,T]=(0,r.useState)(!1),[O,I]=(0,r.useState)(""),[P,A]=(0,r.useState)("BLOCK"),[B,L]=(0,r.useState)(""),[F,E]=(0,r.useState)(""),[M,R]=(0,r.useState)("BLOCK"),[z,G]=(0,r.useState)(""),[$,D]=(0,r.useState)("BLOCK"),[K,J]=(0,r.useState)(""),[q,U]=(0,r.useState)(!1),V=async e=>{U(!0);try{let t=await e.text();if(h){let e=await (0,g.validateBlockedWordsFile)(h,t);if(e.valid)x&&x(t),er.default.success(e.message||"File uploaded successfully");else{let t=e.error||e.errors&&e.errors.join(", ")||"Invalid file";er.default.error(`Validation failed: ${t}`)}}}catch(e){er.default.error(`Failed to upload file: ${e}`)}finally{U(!1)}return!1};return(0,a.jsxs)("div",{className:"space-y-6",children:[!f&&(0,a.jsx)("div",{children:(0,a.jsx)(eF,{type:"secondary",children:"Configure patterns, keywords, and content categories to detect and filter sensitive information in requests and responses."})}),(!f||"patterns"===f)&&(0,a.jsxs)(en.Card,{title:(0,a.jsxs)("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[(0,a.jsx)(eL,{level:5,style:{margin:0},children:"Pattern Detection"}),(0,a.jsx)(eF,{type:"secondary",style:{fontSize:14,fontWeight:400},children:"Detect sensitive information using regex patterns (SSN, credit cards, API keys, etc.)"})]}),size:"small",children:[(0,a.jsx)("div",{style:{marginBottom:16},children:(0,a.jsxs)(es.Space,{children:[(0,a.jsx)(s.Button,{type:"button",onClick:()=>w(!0),icon:p.PlusOutlined,children:"Add prebuilt pattern"}),(0,a.jsx)(s.Button,{type:"button",onClick:()=>T(!0),variant:"secondary",icon:p.PlusOutlined,children:"Add custom regex"})]})}),(0,a.jsx)(eN,{patterns:l,onActionChange:d,onRemove:o})]}),(!f||"keywords"===f)&&(0,a.jsxs)(en.Card,{title:(0,a.jsxs)("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[(0,a.jsx)(eL,{level:5,style:{margin:0},children:"Blocked Keywords"}),(0,a.jsx)(eF,{type:"secondary",style:{fontSize:14,fontWeight:400},children:"Block or mask specific sensitive terms and phrases"})]}),size:"small",children:[(0,a.jsx)("div",{style:{marginBottom:16},children:(0,a.jsxs)(es.Space,{children:[(0,a.jsx)(s.Button,{type:"button",onClick:()=>S(!0),icon:p.PlusOutlined,children:"Add keyword"}),(0,a.jsx)(ei.Upload,{beforeUpload:V,accept:".yaml,.yml",showUploadList:!1,children:(0,a.jsx)(s.Button,{type:"button",variant:"secondary",icon:eo.UploadOutlined,loading:q,children:"Upload YAML file"})})]})}),(0,a.jsx)(eS,{keywords:i,onActionChange:m,onRemove:u})]}),(!f||"categories"===f)&&y.length>0&&_&&v&&b&&(0,a.jsx)(eB,{availableCategories:y,selectedCategories:j,onCategoryAdd:_,onCategoryRemove:v,onCategoryUpdate:b,accessToken:h}),(0,a.jsx)(eu,{visible:N,prebuiltPatterns:e,categories:t,selectedPatternName:O,patternAction:P,onPatternNameChange:I,onActionChange:e=>A(e),onAdd:()=>{if(!O)return void er.default.error("Please select a pattern");let t=e.find(e=>e.name===O);n({id:`pattern-${Date.now()}`,type:"prebuilt",name:O,display_name:t?.display_name,action:P}),w(!1),I(""),A("BLOCK")},onCancel:()=>{w(!1),I(""),A("BLOCK")}}),(0,a.jsx)(ex,{visible:k,patternName:B,patternRegex:F,patternAction:M,onNameChange:L,onRegexChange:E,onActionChange:e=>R(e),onAdd:()=>{B&&F?(n({id:`custom-${Date.now()}`,type:"custom",name:B,pattern:F,action:M}),T(!1),L(""),E(""),R("BLOCK")):er.default.error("Please provide pattern name and regex")},onCancel:()=>{T(!1),L(""),E(""),R("BLOCK")}}),(0,a.jsx)(ey,{visible:C,keyword:z,action:$,description:K,onKeywordChange:G,onActionChange:e=>D(e),onDescriptionChange:J,onAdd:()=>{z?(c({id:`word-${Date.now()}`,keyword:z,action:$,description:K||void 0}),S(!1),G(""),J(""),D("BLOCK")):er.default.error("Please enter a keyword")},onCancel:()=>{S(!1),G(""),J(""),D("BLOCK")}})]})};var eM=e.i(304967),eR=e.i(599724),ez=e.i(312361),eG=e.i(21548),e$=e.i(311451),eD=e.i(827252);let eK={rules:[],default_action:"deny",on_disallowed_action:"block",violation_message_template:""},eJ=({value:e,onChange:t,disabled:l=!1})=>{let r={...eK,...e||{},rules:e?.rules?[...e.rules]:[]},s=e=>{let l={...r,...e};t?.(l)},i=(e,t)=>{s({rules:r.rules.map((l,a)=>a===e?{...l,...t}:l)})},n=(e,t)=>{let l=r.rules[e];if(!l)return;let a=Object.entries(l.allowed_param_patterns||{});t(a);let s={};a.forEach(([e,t])=>{s[e]=t}),i(e,{allowed_param_patterns:Object.keys(s).length>0?s:void 0})};return(0,a.jsxs)(eM.Card,{children:[(0,a.jsxs)("div",{className:"flex items-center justify-between",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)(eR.Text,{className:"text-lg font-semibold",children:"LiteLLM Tool Permission Guardrail"}),(0,a.jsx)(eR.Text,{className:"text-sm text-gray-500",children:"Provide regex patterns (e.g., ^mcp__github_.*$) for tool names or types and optionally constrain payload fields."})]}),!l&&(0,a.jsx)(L.Button,{icon:(0,a.jsx)(p.PlusOutlined,{}),type:"primary",onClick:()=>{s({rules:[...r.rules,{id:`rule_${Math.random().toString(36).slice(2,8)}`,decision:"allow",allowed_param_patterns:void 0}]})},className:"!bg-blue-600 !text-white hover:!bg-blue-500",children:"Add Rule"})]}),(0,a.jsx)(ez.Divider,{}),0===r.rules.length?(0,a.jsx)(eG.Empty,{description:"No tool rules added yet"}):(0,a.jsx)("div",{className:"space-y-4",children:r.rules.map((e,t)=>{let o;return(0,a.jsxs)(eM.Card,{className:"bg-gray-50",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between mb-3",children:[(0,a.jsxs)(eR.Text,{className:"font-semibold",children:["Rule ",t+1]}),(0,a.jsx)(L.Button,{icon:(0,a.jsx)(e_.DeleteOutlined,{}),danger:!0,type:"text",disabled:l,onClick:()=>{s({rules:r.rules.filter((e,l)=>l!==t)})},children:"Remove"})]}),(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-4 md:grid-cols-2",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)(eR.Text,{className:"text-sm font-medium",children:"Rule ID"}),(0,a.jsx)(e$.Input,{disabled:l,placeholder:"unique_rule_id",value:e.id,onChange:e=>i(t,{id:e.target.value})})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)(eR.Text,{className:"text-sm font-medium",children:"Tool Name (optional)"}),(0,a.jsx)(e$.Input,{disabled:l,placeholder:"^mcp__github_.*$",value:e.tool_name??"",onChange:e=>i(t,{tool_name:""===e.target.value.trim()?void 0:e.target.value})})]})]}),(0,a.jsx)("div",{className:"grid grid-cols-1 gap-4 md:grid-cols-2 mt-4",children:(0,a.jsxs)("div",{children:[(0,a.jsx)(eR.Text,{className:"text-sm font-medium",children:"Tool Type (optional)"}),(0,a.jsx)(e$.Input,{disabled:l,placeholder:"^function$",value:e.tool_type??"",onChange:e=>i(t,{tool_type:""===e.target.value.trim()?void 0:e.target.value})})]})}),(0,a.jsxs)("div",{className:"mt-4 flex flex-col gap-2",children:[(0,a.jsx)(eR.Text,{className:"text-sm font-medium",children:"Decision"}),(0,a.jsxs)(y.Select,{disabled:l,value:e.decision,style:{width:200},onChange:e=>i(t,{decision:e}),children:[(0,a.jsx)(y.Select.Option,{value:"allow",children:"Allow"}),(0,a.jsx)(y.Select.Option,{value:"deny",children:"Deny"})]})]}),(0,a.jsx)("div",{className:"mt-4",children:0===(o=Object.entries(e.allowed_param_patterns||{})).length?(0,a.jsx)(L.Button,{disabled:l,size:"small",onClick:()=>i(t,{allowed_param_patterns:{"":""}}),children:"+ Restrict tool arguments (optional)"}):(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsx)(eR.Text,{className:"text-sm text-gray-600",children:"Argument constraints (dot or array paths)"}),o.map(([r,s],i)=>(0,a.jsxs)(es.Space,{align:"start",children:[(0,a.jsx)(e$.Input,{disabled:l,placeholder:"messages[0].content",value:r,onChange:e=>{var l;return l=e.target.value,void n(t,e=>{if(!e[i])return;let[,t]=e[i];e[i]=[l,t]})}}),(0,a.jsx)(e$.Input,{disabled:l,placeholder:"^email@.*$",value:s,onChange:e=>{var l;return l=e.target.value,void n(t,e=>{if(!e[i])return;let[t]=e[i];e[i]=[t,l]})}}),(0,a.jsx)(L.Button,{disabled:l,icon:(0,a.jsx)(e_.DeleteOutlined,{}),danger:!0,onClick:()=>n(t,e=>{e.splice(i,1)})})]},`${e.id||t}-${i}`)),(0,a.jsx)(L.Button,{disabled:l,size:"small",onClick:()=>i(t,{allowed_param_patterns:{...e.allowed_param_patterns||{},"":""}}),children:"+ Add another constraint"})]})})]},e.id||t)})}),(0,a.jsx)(ez.Divider,{}),(0,a.jsxs)("div",{className:"grid gap-4 md:grid-cols-2",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)(eR.Text,{className:"text-sm font-medium",children:"Default action"}),(0,a.jsxs)(y.Select,{disabled:l,value:r.default_action,onChange:e=>s({default_action:e}),children:[(0,a.jsx)(y.Select.Option,{value:"allow",children:"Allow"}),(0,a.jsx)(y.Select.Option,{value:"deny",children:"Deny"})]})]}),(0,a.jsxs)("div",{children:[(0,a.jsxs)(eR.Text,{className:"text-sm font-medium flex items-center gap-1",children:["On disallowed action",(0,a.jsx)(E.Tooltip,{title:"Block returns an error when a forbidden tool is invoked. Rewrite strips the tool call but lets the rest of the response continue.",children:(0,a.jsx)(eD.InfoCircleOutlined,{})})]}),(0,a.jsxs)(y.Select,{disabled:l,value:r.on_disallowed_action,onChange:e=>s({on_disallowed_action:e}),children:[(0,a.jsx)(y.Select.Option,{value:"block",children:"Block"}),(0,a.jsx)(y.Select.Option,{value:"rewrite",children:"Rewrite"})]})]})]}),(0,a.jsxs)("div",{className:"mt-4",children:[(0,a.jsx)(eR.Text,{className:"text-sm font-medium",children:"Violation message (optional)"}),(0,a.jsx)(e$.Input.TextArea,{disabled:l,rows:3,placeholder:"This violates our org policy...",value:r.violation_message_template,onChange:e=>s({violation_message_template:e.target.value})})]})]})},{Title:eq,Text:eU,Link:eV}=f.Typography,{Option:eH}=y.Select,{Step:eY}=v.Steps,eW={pre_call:"Before LLM Call - Runs before the LLM call and checks the input (Recommended)",during_call:"During LLM Call - Runs in parallel with the LLM call, with response held until check completes",post_call:"After LLM Call - Runs after the LLM call and checks only the output",logging_only:"Logging Only - Only runs on logging callbacks without affecting the LLM call",pre_mcp_call:"Before MCP Tool Call - Runs before MCP tool execution and validates tool calls",during_mcp_call:"During MCP Tool Call - Runs in parallel with MCP tool execution for monitoring"},eQ=({visible:e,onClose:t,accessToken:l,onSuccess:i})=>{let n,[o]=h.Form.useForm(),[d,c]=(0,r.useState)(!1),[u,m]=(0,r.useState)(null),[p,x]=(0,r.useState)(null),[f,N]=(0,r.useState)([]),[w,P]=(0,r.useState)({}),[B,L]=(0,r.useState)(0),[F,E]=(0,r.useState)(null),[M,R]=(0,r.useState)([]),[z,G]=(0,r.useState)(2),[$,D]=(0,r.useState)({}),[K,J]=(0,r.useState)([]),[q,U]=(0,r.useState)([]),[V,H]=(0,r.useState)([]),[Y,W]=(0,r.useState)({rules:[],default_action:"deny",on_disallowed_action:"block",violation_message_template:""}),Z=(0,r.useMemo)(()=>!!u&&"tool_permission"===(k[u]||"").toLowerCase(),[u]);(0,r.useEffect)(()=>{l&&(async()=>{try{let[e,t]=await Promise.all([(0,g.getGuardrailUISettings)(l),(0,g.getGuardrailProviderSpecificParams)(l)]);x(e),E(t),C(t),T(t)}catch(e){console.error("Error fetching guardrail data:",e),er.default.fromBackend("Failed to load guardrail configuration")}})()},[l]);let X=e=>{m(e),o.setFieldsValue({config:void 0,presidio_analyzer_api_base:void 0,presidio_anonymizer_api_base:void 0}),N([]),P({}),R([]),G(2),D({}),W({rules:[],default_action:"deny",on_disallowed_action:"block",violation_message_template:""})},et=e=>{N(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e])},el=(e,t)=>{P(l=>({...l,[e]:t}))},es=async()=>{try{if(0===B&&(await o.validateFields(["guardrail_name","provider","mode","default_on"]),u)){let e=["guardrail_name","provider","mode","default_on"];"PresidioPII"===u&&e.push("presidio_analyzer_api_base","presidio_anonymizer_api_base"),await o.validateFields(e)}if(1===B&&O(u)&&0===f.length)return void er.default.fromBackend("Please select at least one PII entity to continue");L(B+1)}catch(e){console.error("Form validation failed:",e)}},ei=()=>{o.resetFields(),m(null),N([]),P({}),R([]),G(2),D({}),J([]),U([]),H([]),W({rules:[],default_action:"deny",on_disallowed_action:"block",violation_message_template:""}),L(0)},en=()=>{ei(),t()},eo=async()=>{try{c(!0),await o.validateFields();let e=o.getFieldsValue(!0),a=k[e.provider],r={guardrail_name:e.guardrail_name,litellm_params:{guardrail:a,mode:e.mode,default_on:e.default_on},guardrail_info:{}};if("PresidioPII"===e.provider&&f.length>0){let t={};f.forEach(e=>{t[e]=w[e]||"MASK"}),r.litellm_params.pii_entities_config=t,e.presidio_analyzer_api_base&&(r.litellm_params.presidio_analyzer_api_base=e.presidio_analyzer_api_base),e.presidio_anonymizer_api_base&&(r.litellm_params.presidio_anonymizer_api_base=e.presidio_anonymizer_api_base)}if(I(e.provider))K.length>0&&(r.litellm_params.patterns=K.map(e=>({pattern_type:"prebuilt"===e.type?"prebuilt":"regex",pattern_name:"prebuilt"===e.type?e.name:void 0,pattern:"custom"===e.type?e.pattern:void 0,name:e.name,action:e.action}))),q.length>0&&(r.litellm_params.blocked_words=q.map(e=>({keyword:e.keyword,action:e.action,description:e.description}))),V.length>0&&(r.litellm_params.categories=V.map(e=>({category:e.category,enabled:!0,action:e.action,severity_threshold:e.severity_threshold||"medium"})));else if(e.config)try{r.guardrail_info=JSON.parse(e.config)}catch(e){er.default.fromBackend("Invalid JSON in configuration"),c(!1);return}if("tool_permission"===a){if(0===Y.rules.length){er.default.fromBackend("Add at least one tool permission rule"),c(!1);return}r.litellm_params.rules=Y.rules,r.litellm_params.default_action=Y.default_action,r.litellm_params.on_disallowed_action=Y.on_disallowed_action,Y.violation_message_template&&(r.litellm_params.violation_message_template=Y.violation_message_template)}if(console.log("values: ",JSON.stringify(e)),F&&u){let t=k[u]?.toLowerCase();console.log("providerKey: ",t);let l=F[t]||{},a=new Set;console.log("providerSpecificParams: ",JSON.stringify(l)),Object.keys(l).forEach(e=>{"optional_params"!==e&&a.add(e)}),l.optional_params&&l.optional_params.fields&&Object.keys(l.optional_params.fields).forEach(e=>{a.add(e)}),console.log("allowedParams: ",a),a.forEach(t=>{let l=e[t];(null==l||""===l)&&(l=e.optional_params?.[t]),null!=l&&""!==l&&(r.litellm_params[t]=l)})}if(!l)throw Error("No access token available");console.log("Sending guardrail data:",JSON.stringify(r)),await (0,g.createGuardrailCall)(l,r),er.default.success("Guardrail created successfully"),ei(),i(),t()}catch(e){console.error("Failed to create guardrail:",e),er.default.fromBackend("Failed to create guardrail: "+(e instanceof Error?e.message:String(e)))}finally{c(!1)}},ed=e=>{if(!p||!I(u))return null;let t=p.content_filter_settings;return t?(0,a.jsx)(eE,{prebuiltPatterns:t.prebuilt_patterns||[],categories:t.pattern_categories||[],selectedPatterns:K,blockedWords:q,onPatternAdd:e=>J([...K,e]),onPatternRemove:e=>J(K.filter(t=>t.id!==e)),onPatternActionChange:(e,t)=>{J(K.map(l=>l.id===e?{...l,action:t}:l))},onBlockedWordAdd:e=>U([...q,e]),onBlockedWordRemove:e=>U(q.filter(t=>t.id!==e)),onBlockedWordUpdate:(e,t,l)=>{U(q.map(a=>a.id===e?{...a,[t]:l}:a))},contentCategories:t.content_categories||[],selectedContentCategories:V,onContentCategoryAdd:e=>H([...V,e]),onContentCategoryRemove:e=>H(V.filter(t=>t.id!==e)),onContentCategoryUpdate:(e,t,l)=>{H(V.map(a=>a.id===e?{...a,[t]:l}:a))},accessToken:l,showStep:e}):null};return(0,a.jsx)(j.Modal,{title:"Add Guardrail",open:e,onCancel:en,footer:null,width:800,children:(0,a.jsxs)(h.Form,{form:o,layout:"vertical",initialValues:{mode:"pre_call",default_on:!1},children:[(0,a.jsxs)(v.Steps,{current:B,className:"mb-6",style:{overflow:"visible"},children:[(0,a.jsx)(eY,{title:"Basic Info"}),(0,a.jsx)(eY,{title:O(u)?"PII Configuration":I(u)?"Default Categories":"Provider Configuration"}),I(u)&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(eY,{title:"Patterns"}),(0,a.jsx)(eY,{title:"Keywords"})]})]}),(()=>{switch(B){case 0:return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(h.Form.Item,{name:"guardrail_name",label:"Guardrail Name",rules:[{required:!0,message:"Please enter a guardrail name"}],children:(0,a.jsx)(b.TextInput,{placeholder:"Enter a name for this guardrail"})}),(0,a.jsx)(h.Form.Item,{name:"provider",label:"Guardrail Provider",rules:[{required:!0,message:"Please select a provider"}],children:(0,a.jsx)(y.Select,{placeholder:"Select a guardrail provider",onChange:X,labelInValue:!1,optionLabelProp:"label",dropdownRender:e=>e,showSearch:!0,children:Object.entries(S()).map(([e,t])=>(0,a.jsx)(eH,{value:e,label:(0,a.jsxs)("div",{style:{display:"flex",alignItems:"center"},children:[A[t]&&(0,a.jsx)("img",{src:A[t],alt:"",style:{height:"20px",width:"20px",marginRight:"8px",objectFit:"contain"},onError:e=>{e.currentTarget.style.display="none"}}),(0,a.jsx)("span",{children:t})]}),children:(0,a.jsxs)("div",{style:{display:"flex",alignItems:"center"},children:[A[t]&&(0,a.jsx)("img",{src:A[t],alt:"",style:{height:"20px",width:"20px",marginRight:"8px",objectFit:"contain"},onError:e=>{e.currentTarget.style.display="none"}}),(0,a.jsx)("span",{children:t})]})},e))})}),(0,a.jsx)(h.Form.Item,{name:"mode",label:"Mode",tooltip:"How the guardrail should be applied",rules:[{required:!0,message:"Please select a mode"}],children:(0,a.jsx)(y.Select,{optionLabelProp:"label",mode:"multiple",children:p?.supported_modes?.map(e=>(0,a.jsx)(eH,{value:e,label:e,children:(0,a.jsxs)("div",{children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("strong",{children:e}),"pre_call"===e&&(0,a.jsx)(_.Tag,{color:"green",style:{marginLeft:"8px"},children:"Recommended"})]}),(0,a.jsx)("div",{style:{fontSize:"12px",color:"#888"},children:eW[e]})]})},e))||(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(eH,{value:"pre_call",label:"pre_call",children:(0,a.jsxs)("div",{children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("strong",{children:"pre_call"})," ",(0,a.jsx)(_.Tag,{color:"green",children:"Recommended"})]}),(0,a.jsx)("div",{style:{fontSize:"12px",color:"#888"},children:eW.pre_call})]})}),(0,a.jsx)(eH,{value:"during_call",label:"during_call",children:(0,a.jsxs)("div",{children:[(0,a.jsx)("div",{children:(0,a.jsx)("strong",{children:"during_call"})}),(0,a.jsx)("div",{style:{fontSize:"12px",color:"#888"},children:eW.during_call})]})}),(0,a.jsx)(eH,{value:"post_call",label:"post_call",children:(0,a.jsxs)("div",{children:[(0,a.jsx)("div",{children:(0,a.jsx)("strong",{children:"post_call"})}),(0,a.jsx)("div",{style:{fontSize:"12px",color:"#888"},children:eW.post_call})]})}),(0,a.jsx)(eH,{value:"logging_only",label:"logging_only",children:(0,a.jsxs)("div",{children:[(0,a.jsx)("div",{children:(0,a.jsx)("strong",{children:"logging_only"})}),(0,a.jsx)("div",{style:{fontSize:"12px",color:"#888"},children:eW.logging_only})]})})]})})}),(0,a.jsx)(h.Form.Item,{name:"default_on",label:"Always On",tooltip:"If enabled, this guardrail will be applied to all requests by default.",children:(0,a.jsxs)(y.Select,{children:[(0,a.jsx)(y.Select.Option,{value:!0,children:"Yes"}),(0,a.jsx)(y.Select.Option,{value:!1,children:"No"})]})}),!Z&&!I(u)&&(0,a.jsx)(ee,{selectedProvider:u,accessToken:l,providerParams:F})]});case 1:if(O(u))return p&&"PresidioPII"===u?(0,a.jsx)(Q,{entities:p.supported_entities,actions:p.supported_actions,selectedEntities:f,selectedActions:w,onEntitySelect:et,onActionSelect:el,entityCategories:p.pii_entity_categories}):null;if(I(u))return ed("categories");if(!u)return null;if(Z)return(0,a.jsx)(eJ,{value:Y,onChange:W});if(!F)return null;console.log("guardrail_provider_map: ",k),console.log("selectedProvider: ",u);let e=k[u]?.toLowerCase(),t=F&&F[e];return t&&t.optional_params?(0,a.jsx)(ea,{optionalParams:t.optional_params,parentFieldKey:"optional_params"}):null;case 2:if(I(u))return ed("patterns");return null;case 3:if(I(u))return ed("keywords");return null;default:return null}})(),(n=B===(I(u)?4:2)-1,(0,a.jsxs)("div",{className:"flex justify-end space-x-2 mt-4",children:[B>0&&(0,a.jsx)(s.Button,{variant:"secondary",onClick:()=>{L(B-1)},children:"Previous"}),!n&&(0,a.jsx)(s.Button,{onClick:es,children:"Next"}),n&&(0,a.jsx)(s.Button,{onClick:eo,loading:d,children:"Create Guardrail"}),(0,a.jsx)(s.Button,{variant:"secondary",onClick:en,children:"Cancel"})]}))]})})};var eZ=e.i(269200),eX=e.i(942232),e0=e.i(977572),e1=e.i(427612),e2=e.i(64848),e4=e.i(496020),e5=e.i(752978),e8=e.i(68155),e6=e.i(94629),e3=e.i(360820),e7=e.i(871943),e9=e.i(389083),te=e.i(152990),tt=e.i(682830),tl=e.i(790848);let{Title:ta,Text:tr}=f.Typography,{Option:ts}=y.Select,ti=({visible:e,onClose:t,accessToken:l,onSuccess:i,guardrailId:n,initialValues:o})=>{let[d]=h.Form.useForm(),[c,u]=(0,r.useState)(!1),[m,p]=(0,r.useState)(o?.provider||null),[x,f]=(0,r.useState)(null),[_,v]=(0,r.useState)([]),[N,w]=(0,r.useState)({});(0,r.useEffect)(()=>{(async()=>{try{if(!l)return;let e=await (0,g.getGuardrailUISettings)(l);f(e)}catch(e){console.error("Error fetching guardrail settings:",e),er.default.fromBackend("Failed to load guardrail settings")}})()},[l]),(0,r.useEffect)(()=>{o?.pii_entities_config&&Object.keys(o.pii_entities_config).length>0&&(v(Object.keys(o.pii_entities_config)),w(o.pii_entities_config))},[o]);let C=e=>{v(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e])},T=(e,t)=>{w(l=>({...l,[e]:t}))},O=async()=>{try{u(!0);let e=await d.validateFields(),a=k[e.provider],r={guardrail_id:n,guardrail:{guardrail_name:e.guardrail_name,litellm_params:{guardrail:a,mode:e.mode,default_on:e.default_on},guardrail_info:{}}};if("PresidioPII"===e.provider&&_.length>0){let e={};_.forEach(t=>{e[t]=N[t]||"MASK"}),r.guardrail.litellm_params.pii_entities_config=e}else if(e.config)try{let t=JSON.parse(e.config);"Bedrock"===e.provider&&t?(t.guardrail_id&&(r.guardrail.litellm_params.guardrailIdentifier=t.guardrail_id),t.guardrail_version&&(r.guardrail.litellm_params.guardrailVersion=t.guardrail_version)):r.guardrail.guardrail_info=t}catch(e){er.default.fromBackend("Invalid JSON in configuration"),u(!1);return}if(!l)throw Error("No access token available");console.log("Sending guardrail update data:",JSON.stringify(r));let s=`/guardrails/${n}`,o=await fetch(s,{method:"PUT",headers:{[(0,g.getGlobalLitellmHeaderName)()]:`Bearer ${l}`,"Content-Type":"application/json"},body:JSON.stringify(r)});if(!o.ok){let e=await o.text();throw Error(e||"Failed to update guardrail")}er.default.success("Guardrail updated successfully"),i(),t()}catch(e){console.error("Failed to update guardrail:",e),er.default.fromBackend("Failed to update guardrail: "+(e instanceof Error?e.message:String(e)))}finally{u(!1)}};return(0,a.jsx)(j.Modal,{title:"Edit Guardrail",open:e,onCancel:t,footer:null,width:700,children:(0,a.jsxs)(h.Form,{form:d,layout:"vertical",initialValues:o,children:[(0,a.jsx)(h.Form.Item,{name:"guardrail_name",label:"Guardrail Name",rules:[{required:!0,message:"Please enter a guardrail name"}],children:(0,a.jsx)(b.TextInput,{placeholder:"Enter a name for this guardrail"})}),(0,a.jsx)(h.Form.Item,{name:"provider",label:"Guardrail Provider",rules:[{required:!0,message:"Please select a provider"}],children:(0,a.jsx)(y.Select,{placeholder:"Select a guardrail provider",onChange:e=>{p(e),d.setFieldsValue({config:void 0}),v([]),w({})},disabled:!0,optionLabelProp:"label",children:Object.entries(S()).map(([e,t])=>(0,a.jsx)(ts,{value:e,label:t,children:(0,a.jsxs)("div",{style:{display:"flex",alignItems:"center"},children:[A[t]&&(0,a.jsx)("img",{src:A[t],alt:"",style:{height:"20px",width:"20px",marginRight:"8px",objectFit:"contain"},onError:e=>{e.currentTarget.style.display="none"}}),(0,a.jsx)("span",{children:t})]})},e))})}),(0,a.jsx)(h.Form.Item,{name:"mode",label:"Mode",tooltip:"How the guardrail should be applied",rules:[{required:!0,message:"Please select a mode"}],children:(0,a.jsx)(y.Select,{children:x?.supported_modes?.map(e=>(0,a.jsx)(ts,{value:e,children:e},e))||(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(ts,{value:"pre_call",children:"pre_call"}),(0,a.jsx)(ts,{value:"post_call",children:"post_call"})]})})}),(0,a.jsx)(h.Form.Item,{name:"default_on",label:"Always On",tooltip:"If enabled, this guardrail will be applied to all requests by default",valuePropName:"checked",children:(0,a.jsx)(tl.Switch,{})}),(()=>{if(!m)return null;if("PresidioPII"===m)return x&&m&&"PresidioPII"===m?(0,a.jsx)(Q,{entities:x.supported_entities,actions:x.supported_actions,selectedEntities:_,selectedActions:N,onEntitySelect:C,onActionSelect:T,entityCategories:x.pii_entity_categories}):null;switch(m){case"Aporia":return(0,a.jsx)(h.Form.Item,{label:"Aporia Configuration",name:"config",tooltip:"JSON configuration for Aporia",children:(0,a.jsx)(e$.Input.TextArea,{rows:4,placeholder:`{ + "api_key": "your_aporia_api_key", + "project_name": "your_project_name" +}`})});case"AimSecurity":return(0,a.jsx)(h.Form.Item,{label:"Aim Security Configuration",name:"config",tooltip:"JSON configuration for Aim Security",children:(0,a.jsx)(e$.Input.TextArea,{rows:4,placeholder:`{ + "api_key": "your_aim_api_key" +}`})});case"Bedrock":return(0,a.jsx)(h.Form.Item,{label:"Amazon Bedrock Configuration",name:"config",tooltip:"JSON configuration for Amazon Bedrock guardrails",children:(0,a.jsx)(e$.Input.TextArea,{rows:4,placeholder:`{ + "guardrail_id": "your_guardrail_id", + "guardrail_version": "your_guardrail_version" +}`})});case"GuardrailsAI":return(0,a.jsx)(h.Form.Item,{label:"Guardrails.ai Configuration",name:"config",tooltip:"JSON configuration for Guardrails.ai",children:(0,a.jsx)(e$.Input.TextArea,{rows:4,placeholder:`{ + "api_key": "your_guardrails_api_key", + "guardrail_id": "your_guardrail_id" +}`})});case"LakeraAI":return(0,a.jsx)(h.Form.Item,{label:"Lakera AI Configuration",name:"config",tooltip:"JSON configuration for Lakera AI",children:(0,a.jsx)(e$.Input.TextArea,{rows:4,placeholder:`{ + "api_key": "your_lakera_api_key" +}`})});case"PromptInjection":return(0,a.jsx)(h.Form.Item,{label:"Prompt Injection Configuration",name:"config",tooltip:"JSON configuration for prompt injection detection",children:(0,a.jsx)(e$.Input.TextArea,{rows:4,placeholder:`{ + "threshold": 0.8 +}`})});default:return(0,a.jsx)(h.Form.Item,{label:"Custom Configuration",name:"config",tooltip:"JSON configuration for your custom guardrail",children:(0,a.jsx)(e$.Input.TextArea,{rows:4,placeholder:`{ + "key1": "value1", + "key2": "value2" +}`})})}})(),(0,a.jsxs)("div",{className:"flex justify-end space-x-2 mt-4",children:[(0,a.jsx)(s.Button,{variant:"secondary",onClick:t,children:"Cancel"}),(0,a.jsx)(s.Button,{onClick:O,loading:c,children:"Update Guardrail"})]})]})})};var tn=((l={}).DB="db",l.CONFIG="config",l);let to=({guardrailsList:e,isLoading:t,onDeleteClick:l,accessToken:i,onGuardrailUpdated:n,isAdmin:o=!1,onGuardrailClick:d})=>{let[c,u]=(0,r.useState)([{id:"created_at",desc:!0}]),[m,p]=(0,r.useState)(!1),[x,g]=(0,r.useState)(null),h=e=>e?new Date(e).toLocaleString():"-",f=[{header:"Guardrail ID",accessorKey:"guardrail_id",cell:e=>(0,a.jsx)(E.Tooltip,{title:String(e.getValue()||""),children:(0,a.jsx)(s.Button,{size:"xs",variant:"light",className:"font-mono text-blue-500 bg-blue-50 hover:bg-blue-100 text-xs font-normal px-2 py-0.5 text-left overflow-hidden truncate max-w-[200px]",onClick:()=>e.getValue()&&d(e.getValue()),children:e.getValue()?`${String(e.getValue()).slice(0,7)}...`:""})})},{header:"Name",accessorKey:"guardrail_name",cell:({row:e})=>{let t=e.original;return(0,a.jsx)(E.Tooltip,{title:t.guardrail_name,children:(0,a.jsx)("span",{className:"text-xs font-medium",children:t.guardrail_name||"-"})})}},{header:"Provider",accessorKey:"litellm_params.guardrail",cell:({row:e})=>{let{logo:t,displayName:l}=B(e.original.litellm_params.guardrail);return(0,a.jsxs)("div",{className:"flex items-center space-x-2",children:[t&&(0,a.jsx)("img",{src:t,alt:`${l} logo`,className:"w-4 h-4",onError:e=>{e.target.style.display="none"}}),(0,a.jsx)("span",{className:"text-xs",children:l})]})}},{header:"Mode",accessorKey:"litellm_params.mode",cell:({row:e})=>{let t=e.original;return(0,a.jsx)("span",{className:"text-xs",children:t.litellm_params.mode})}},{header:"Default On",accessorKey:"litellm_params.default_on",cell:({row:e})=>{let t=e.original;return(0,a.jsx)(e9.Badge,{color:t.litellm_params?.default_on?"green":"gray",className:"text-xs font-normal",size:"xs",children:t.litellm_params?.default_on?"Default On":"Default Off"})}},{header:"Created At",accessorKey:"created_at",cell:({row:e})=>{let t=e.original;return(0,a.jsx)(E.Tooltip,{title:t.created_at,children:(0,a.jsx)("span",{className:"text-xs",children:h(t.created_at)})})}},{header:"Updated At",accessorKey:"updated_at",cell:({row:e})=>{let t=e.original;return(0,a.jsx)(E.Tooltip,{title:t.updated_at,children:(0,a.jsx)("span",{className:"text-xs",children:h(t.updated_at)})})}},{id:"actions",header:"Actions",cell:({row:e})=>{let t=e.original,r=t.guardrail_definition_location===tn.CONFIG;return(0,a.jsx)("div",{className:"flex space-x-2",children:r?(0,a.jsx)(E.Tooltip,{title:"Config guardrail cannot be deleted on the dashboard. Please delete it from the config file.",children:(0,a.jsx)(e5.Icon,{"data-testid":"config-delete-icon",icon:e8.TrashIcon,size:"sm",className:"cursor-not-allowed text-gray-400",title:"Config guardrail cannot be deleted on the dashboard. Please delete it from the config file.","aria-label":"Delete guardrail (config)"})}):(0,a.jsx)(E.Tooltip,{title:"Delete guardrail",children:(0,a.jsx)(e5.Icon,{icon:e8.TrashIcon,size:"sm",onClick:()=>t.guardrail_id&&l(t.guardrail_id,t.guardrail_name||"Unnamed Guardrail"),className:"cursor-pointer hover:text-red-500"})})})}}],y=(0,te.useReactTable)({data:e,columns:f,state:{sorting:c},onSortingChange:u,getCoreRowModel:(0,tt.getCoreRowModel)(),getSortedRowModel:(0,tt.getSortedRowModel)(),enableSorting:!0});return(0,a.jsxs)("div",{className:"rounded-lg custom-border relative",children:[(0,a.jsx)("div",{className:"overflow-x-auto",children:(0,a.jsxs)(eZ.Table,{className:"[&_td]:py-0.5 [&_th]:py-1",children:[(0,a.jsx)(e1.TableHead,{children:y.getHeaderGroups().map(e=>(0,a.jsx)(e4.TableRow,{children:e.headers.map(e=>(0,a.jsx)(e2.TableHeaderCell,{className:`py-1 h-8 ${"actions"===e.id?"sticky right-0 bg-white shadow-[-4px_0_8px_-6px_rgba(0,0,0,0.1)]":""}`,onClick:e.column.getToggleSortingHandler(),children:(0,a.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,a.jsx)("div",{className:"flex items-center",children:e.isPlaceholder?null:(0,te.flexRender)(e.column.columnDef.header,e.getContext())}),"actions"!==e.id&&(0,a.jsx)("div",{className:"w-4",children:e.column.getIsSorted()?({asc:(0,a.jsx)(e3.ChevronUpIcon,{className:"h-4 w-4 text-blue-500"}),desc:(0,a.jsx)(e7.ChevronDownIcon,{className:"h-4 w-4 text-blue-500"})})[e.column.getIsSorted()]:(0,a.jsx)(e6.SwitchVerticalIcon,{className:"h-4 w-4 text-gray-400"})})]})},e.id))},e.id))}),(0,a.jsx)(eX.TableBody,{children:t?(0,a.jsx)(e4.TableRow,{children:(0,a.jsx)(e0.TableCell,{colSpan:f.length,className:"h-8 text-center",children:(0,a.jsx)("div",{className:"text-center text-gray-500",children:(0,a.jsx)("p",{children:"Loading..."})})})}):e.length>0?y.getRowModel().rows.map(e=>(0,a.jsx)(e4.TableRow,{className:"h-8",children:e.getVisibleCells().map(e=>(0,a.jsx)(e0.TableCell,{className:`py-0.5 max-h-8 overflow-hidden text-ellipsis whitespace-nowrap ${"actions"===e.column.id?"sticky right-0 bg-white shadow-[-4px_0_8px_-6px_rgba(0,0,0,0.1)]":""}`,children:(0,te.flexRender)(e.column.columnDef.cell,e.getContext())},e.id))},e.id)):(0,a.jsx)(e4.TableRow,{children:(0,a.jsx)(e0.TableCell,{colSpan:f.length,className:"h-8 text-center",children:(0,a.jsx)("div",{className:"text-center text-gray-500",children:(0,a.jsx)("p",{children:"No guardrails found"})})})})})]})}),x&&(0,a.jsx)(ti,{visible:m,onClose:()=>p(!1),accessToken:i,onSuccess:()=>{p(!1),g(null),n()},guardrailId:x.guardrail_id||"",initialValues:{guardrail_name:x.guardrail_name||"",provider:Object.keys(k).find(e=>k[e]===x?.litellm_params.guardrail)||"",mode:x.litellm_params.mode,default_on:x.litellm_params.default_on,pii_entities_config:x.litellm_params.pii_entities_config,...x.guardrail_info}})]})};var td=e.i(708347),tc=e.i(629569),tu=e.i(350967),R=R;let tm=({patterns:e,blockedWords:t,readOnly:l=!0,onPatternActionChange:r,onPatternRemove:s,onBlockedWordUpdate:i,onBlockedWordRemove:n})=>{if(0===e.length&&0===t.length)return null;let o=()=>{};return(0,a.jsxs)(a.Fragment,{children:[e.length>0&&(0,a.jsxs)(eM.Card,{className:"mt-6",children:[(0,a.jsxs)("div",{className:"flex justify-between items-center mb-4",children:[(0,a.jsx)(eR.Text,{className:"text-lg font-semibold",children:"Pattern Detection"}),(0,a.jsxs)(e9.Badge,{color:"blue",children:[e.length," patterns configured"]})]}),(0,a.jsx)(eN,{patterns:e,onActionChange:l?o:r||o,onRemove:l?o:s||o})]}),t.length>0&&(0,a.jsxs)(eM.Card,{className:"mt-6",children:[(0,a.jsxs)("div",{className:"flex justify-between items-center mb-4",children:[(0,a.jsx)(eR.Text,{className:"text-lg font-semibold",children:"Blocked Keywords"}),(0,a.jsxs)(e9.Badge,{color:"blue",children:[t.length," keywords configured"]})]}),(0,a.jsx)(eS,{keywords:t,onActionChange:l?o:i||o,onRemove:l?o:n||o})]})]})},tp=({guardrailData:e,guardrailSettings:t,isEditing:l,accessToken:s,onDataChange:i,onUnsavedChanges:n})=>{let[o,d]=(0,r.useState)([]),[c,u]=(0,r.useState)([]),[m,p]=(0,r.useState)([]),[x,g]=(0,r.useState)([]);(0,r.useEffect)(()=>{if(e?.litellm_params?.patterns){let t=e.litellm_params.patterns.map((e,t)=>({id:`pattern-${t}`,type:"prebuilt"===e.pattern_type?"prebuilt":"custom",name:e.pattern_name||e.name,display_name:e.display_name,pattern:e.pattern,action:e.action||"BLOCK"}));d(t),p(t)}else d([]),p([]);if(e?.litellm_params?.blocked_words){let t=e.litellm_params.blocked_words.map((e,t)=>({id:`word-${t}`,keyword:e.keyword,action:e.action||"BLOCK",description:e.description}));u(t),g(t)}else u([]),g([])},[e]),(0,r.useEffect)(()=>{i&&i(o,c)},[o,c,i]);let h=r.default.useMemo(()=>{let e=JSON.stringify(o)!==JSON.stringify(m),t=JSON.stringify(c)!==JSON.stringify(x);return e||t},[o,c,m,x]);return((0,r.useEffect)(()=>{l&&n&&n(h)},[h,l,n]),e?.litellm_params?.guardrail!=="litellm_content_filter")?null:l?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(ez.Divider,{orientation:"left",children:"Content Filter Configuration"}),h&&(0,a.jsx)("div",{className:"mb-4 px-4 py-3 bg-yellow-50 border border-yellow-200 rounded-md",children:(0,a.jsx)("p",{className:"text-sm text-yellow-800 font-medium",children:'⚠️ You have unsaved changes to patterns or keywords. Remember to click "Save Changes" at the bottom.'})}),(0,a.jsx)("div",{className:"mb-6",children:t&&t.content_filter_settings&&(0,a.jsx)(eE,{prebuiltPatterns:t.content_filter_settings.prebuilt_patterns||[],categories:t.content_filter_settings.pattern_categories||[],selectedPatterns:o,blockedWords:c,onPatternAdd:e=>d([...o,e]),onPatternRemove:e=>d(o.filter(t=>t.id!==e)),onPatternActionChange:(e,t)=>d(o.map(l=>l.id===e?{...l,action:t}:l)),onBlockedWordAdd:e=>u([...c,e]),onBlockedWordRemove:e=>u(c.filter(t=>t.id!==e)),onBlockedWordUpdate:(e,t,l)=>u(c.map(a=>a.id===e?{...a,[t]:l}:a)),onFileUpload:e=>{console.log("File uploaded:",e)},accessToken:s})})]}):(0,a.jsx)(tm,{patterns:o,blockedWords:c,readOnly:!0})};var tx=e.i(788191),tg=e.i(245704);let th={icon:{tag:"svg",attrs:{"fill-rule":"evenodd",viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M512 64c247.4 0 448 200.6 448 448S759.4 960 512 960 64 759.4 64 512 264.6 64 512 64zm0 76c-205.4 0-372 166.6-372 372s166.6 372 372 372 372-166.6 372-372-166.6-372-372-372zm128.01 198.83c.03 0 .05.01.09.06l45.02 45.01a.2.2 0 01.05.09.12.12 0 010 .07c0 .02-.01.04-.05.08L557.25 512l127.87 127.86a.27.27 0 01.05.06v.02a.12.12 0 010 .07c0 .03-.01.05-.05.09l-45.02 45.02a.2.2 0 01-.09.05.12.12 0 01-.07 0c-.02 0-.04-.01-.08-.05L512 557.25 384.14 685.12c-.04.04-.06.05-.08.05a.12.12 0 01-.07 0c-.03 0-.05-.01-.09-.05l-45.02-45.02a.2.2 0 01-.05-.09.12.12 0 010-.07c0-.02.01-.04.06-.08L466.75 512 338.88 384.14a.27.27 0 01-.05-.06l-.01-.02a.12.12 0 010-.07c0-.03.01-.05.05-.09l45.02-45.02a.2.2 0 01.09-.05.12.12 0 01.07 0c.02 0 .04.01.08.06L512 466.75l127.86-127.86c.04-.05.06-.06.08-.06a.12.12 0 01.07 0z"}}]},name:"close-circle",theme:"outlined"};var tf=r.forwardRef(function(e,t){return r.createElement(D.default,(0,G.default)({},e,{ref:t,icon:th}))});let ty={icon:{tag:"svg",attrs:{viewBox:"0 0 1024 1024",focusable:"false"},children:[{tag:"path",attrs:{d:"M715.8 493.5L335 165.1c-14.2-12.2-35-1.2-35 18.5v656.8c0 19.7 20.8 30.7 35 18.5l380.8-328.4c10.9-9.4 10.9-27.6 0-37z"}}]},name:"caret-right",theme:"outlined"};var tj=r.forwardRef(function(e,t){return r.createElement(D.default,(0,G.default)({},e,{ref:t,icon:ty}))}),t_=e.i(987432);let{Panel:tv}=ek.Collapse,{TextArea:tb}=e$.Input,tN={empty:{name:"Empty Template",code:`async def apply_guardrail(inputs, request_data, input_type): + # inputs: {texts, images, tools, tool_calls, structured_messages, model} + # request_data: {model, user_id, team_id, end_user_id, metadata} + # input_type: "request" or "response" + return allow()`},blockSSN:{name:"Block SSN",code:`def apply_guardrail(inputs, request_data, input_type): + for text in inputs["texts"]: + if regex_match(text, r"\\d{3}-\\d{2}-\\d{4}"): + return block("SSN detected") + return allow()`},redactEmail:{name:"Redact Emails",code:`def apply_guardrail(inputs, request_data, input_type): + pattern = r"[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}" + modified = [] + for text in inputs["texts"]: + modified.append(regex_replace(text, pattern, "[EMAIL REDACTED]")) + return modify(texts=modified)`},blockSQL:{name:"Block SQL Injection",code:`def apply_guardrail(inputs, request_data, input_type): + if input_type != "request": + return allow() + for text in inputs["texts"]: + if contains_code_language(text, ["sql"]): + return block("SQL code not allowed") + return allow()`},validateJSON:{name:"Validate JSON",code:`def apply_guardrail(inputs, request_data, input_type): + if input_type != "response": + return allow() + + schema = {"type": "object", "required": ["name", "value"]} + + for text in inputs["texts"]: + obj = json_parse(text) + if obj is None: + return block("Invalid JSON response") + if not json_schema_valid(obj, schema): + return block("Response missing required fields") + return allow()`},externalAPI:{name:"External API Check (async)",code:`async def apply_guardrail(inputs, request_data, input_type): + # Call an external moderation API (async for non-blocking) + for text in inputs["texts"]: + response = await http_post( + "https://api.example.com/moderate", + body={"text": text, "user_id": request_data["user_id"]}, + headers={"Authorization": "Bearer YOUR_API_KEY"}, + timeout=10 + ) + + if not response["success"]: + # API call failed, allow by default or block + return allow() + + if response["body"].get("flagged"): + return block(response["body"].get("reason", "Content flagged")) + + return allow()`}},tw={"Return Values":[{name:"allow()",desc:"Let request/response through"},{name:"block(reason)",desc:"Reject with message"},{name:"modify(texts=[], images=[], tool_calls=[])",desc:"Transform content"}],"HTTP Requests (async)":[{name:"await http_request(url, method, headers, body)",desc:"Make async HTTP request"},{name:"await http_get(url, headers)",desc:"Async GET request"},{name:"await http_post(url, body, headers)",desc:"Async POST request"}],"Regex Functions":[{name:"regex_match(text, pattern)",desc:"Returns True if pattern found"},{name:"regex_replace(text, pattern, replacement)",desc:"Replace all matches"},{name:"regex_find_all(text, pattern)",desc:"Return list of matches"}],"JSON Functions":[{name:"json_parse(text)",desc:"Parse JSON string, returns None on error"},{name:"json_stringify(obj)",desc:"Convert to JSON string"},{name:"json_schema_valid(obj, schema)",desc:"Validate against JSON schema"}],"URL Functions":[{name:"extract_urls(text)",desc:"Extract all URLs from text"},{name:"is_valid_url(url)",desc:"Check if URL is valid"},{name:"all_urls_valid(text)",desc:"Check all URLs in text are valid"}],"Code Detection":[{name:"detect_code(text)",desc:"Returns True if code detected"},{name:"detect_code_languages(text)",desc:"Returns list of detected languages"},{name:'contains_code_language(text, ["sql"])',desc:"Check for specific languages"}],"Text Utilities":[{name:"contains(text, substring)",desc:"Check if substring exists"},{name:"contains_any(text, [substr1, substr2])",desc:"Check if any substring exists"},{name:"word_count(text)",desc:"Count words"},{name:"char_count(text)",desc:"Count characters"},{name:"lower(text) / upper(text) / trim(text)",desc:"String transforms"}]},tC=[{value:"pre_call",label:"pre_call (Request)"},{value:"post_call",label:"post_call (Response)"},{value:"during_call",label:"during_call (Parallel)"},{value:"logging_only",label:"logging_only"},{value:"pre_mcp_call",label:"pre_mcp_call (Before MCP Tool Call)"},{value:"post_mcp_call",label:"post_mcp_call (After MCP Tool Call)"},{value:"during_mcp_call",label:"during_mcp_call (During MCP Tool Call)"}],tS=({visible:e,onClose:t,onSuccess:l,accessToken:i,editData:n})=>{let o=!!n,[d,c]=(0,r.useState)(""),[u,m]=(0,r.useState)(["pre_call"]),[p,h]=(0,r.useState)(!1),[f,_]=(0,r.useState)("empty"),[v,N]=(0,r.useState)(tN.empty.code),[w,C]=(0,r.useState)(!1),[S,k]=(0,r.useState)(!1),[T,O]=(0,r.useState)(!1),I={texts:["Hello, my SSN is 123-45-6789"],images:[],tools:[{type:"function",function:{name:"get_weather",description:"Get the current weather in a location",parameters:{type:"object",properties:{location:{type:"string",description:"City name"}},required:["location"]}}}],tool_calls:[],structured_messages:[{role:"system",content:"You are a helpful assistant."},{role:"user",content:"Hello, my SSN is 123-45-6789"}],model:"gpt-4"},P={texts:["The weather in San Francisco is 72°F and sunny."],images:[],tools:[],tool_calls:[{id:"call_abc123",type:"function",function:{name:"get_weather",arguments:'{"location": "San Francisco"}'}}],structured_messages:[],model:"gpt-4"},[A,B]=(0,r.useState)(JSON.stringify(I,null,2)),[L,F]=(0,r.useState)(null),[E,M]=(0,r.useState)(null),R=(0,r.useRef)(null),z=e=>null==e?["pre_call"]:Array.isArray(e)?e.length?e:["pre_call"]:[e];(0,r.useEffect)(()=>{e&&(n?(c(n.guardrail_name||""),m(z(n.litellm_params?.mode)),h(n.litellm_params?.default_on||!1),N(n.litellm_params?.custom_code||tN.empty.code),_("")):(c(""),m(["pre_call"]),h(!1),_("empty"),N(tN.empty.code)),F(null),O(!1))},[e,n]);let G=async e=>{try{await navigator.clipboard.writeText(e),M(e),setTimeout(()=>M(null),2e3)}catch(e){console.error("Failed to copy:",e)}},$=async()=>{if(!d.trim())return void er.default.fromBackend("Please enter a guardrail name");if(!v.trim())return void er.default.fromBackend("Please enter custom code");if(!i)return void er.default.fromBackend("No access token available");C(!0);try{if(o&&n){let e={litellm_params:{custom_code:v}};d!==n.guardrail_name&&(e.guardrail_name=d);let t=z(n.litellm_params?.mode);(u.length!==t.length||u.some((e,l)=>e!==t[l]))&&(e.litellm_params.mode=u),p!==n.litellm_params?.default_on&&(e.litellm_params.default_on=p),await (0,g.updateGuardrailCall)(i,n.guardrail_id,e),er.default.success("Custom code guardrail updated successfully")}else await (0,g.createGuardrailCall)(i,{guardrail_name:d,litellm_params:{guardrail:"custom_code",mode:u,default_on:p,custom_code:v},guardrail_info:{}}),er.default.success("Custom code guardrail created successfully");l(),t()}catch(e){console.error("Failed to save guardrail:",e),er.default.fromBackend(`Failed to ${o?"update":"create"} guardrail: `+(e instanceof Error?e.message:String(e)))}finally{C(!1)}},D=async()=>{if(!i)return void F({error:"No access token available"});k(!0),F(null);try{let e;try{e=JSON.parse(A)}catch(e){F({error:"Invalid test input JSON"}),k(!1);return}e.texts||(e.texts=[]);let t=["pre_call","pre_mcp_call"],l=["post_call","post_mcp_call"],a=u.some(e=>t.includes(e))?"request":u.some(e=>l.includes(e))?"response":"request",r=await (0,g.testCustomCodeGuardrail)(i,{custom_code:v,test_input:e,input_type:a,request_data:{model:"test-model",metadata:{}}});r.success&&r.result?F(r.result):r.error?F({error:r.error,error_type:r.error_type}):F({error:"Unknown error occurred"})}catch(e){console.error("Failed to test custom code:",e),F({error:e instanceof Error?e.message:"Failed to test custom code"})}finally{k(!1)}},K=v.split("\n").length;return(0,a.jsxs)(j.Modal,{open:e,onCancel:t,footer:null,width:1400,className:"custom-code-modal",closable:!0,destroyOnClose:!0,children:[(0,a.jsxs)("div",{className:"flex flex-col h-[80vh]",children:[(0,a.jsxs)("div",{className:"pb-4 border-b border-gray-200",children:[(0,a.jsx)("h2",{className:"text-xl font-semibold text-gray-900",children:o?"Edit Custom Guardrail":"Create Custom Guardrail"}),(0,a.jsx)("p",{className:"text-sm text-gray-500 mt-1",children:"Define custom logic using Python-like syntax"})]}),(0,a.jsxs)("div",{className:"flex items-center gap-4 py-4 border-b border-gray-100",children:[(0,a.jsxs)("div",{className:"flex-1 max-w-[200px]",children:[(0,a.jsx)("label",{className:"block text-xs font-medium text-gray-600 mb-1",children:"Guardrail Name"}),(0,a.jsx)(b.TextInput,{value:d,onValueChange:c,placeholder:"e.g., block-pii-custom"})]}),(0,a.jsxs)("div",{className:"w-[280px]",children:[(0,a.jsx)("label",{className:"block text-xs font-medium text-gray-600 mb-1",children:"Mode (can select multiple)"}),(0,a.jsx)(y.Select,{mode:"multiple",value:u,onChange:m,options:tC,className:"w-full",size:"middle",placeholder:"Select modes"})]}),(0,a.jsxs)("div",{className:"w-[180px]",children:[(0,a.jsx)("label",{className:"block text-xs font-medium text-gray-600 mb-1",children:"Template"}),(0,a.jsx)(y.Select,{value:f,onChange:e=>{_(e),N(tN[e].code)},className:"w-full",size:"middle",children:Object.entries(tN).map(([e,t])=>(0,a.jsx)(y.Select.Option,{value:e,children:t.name},e))})]}),(0,a.jsxs)("div",{className:"flex items-center gap-2 pt-5",children:[(0,a.jsx)("span",{className:"text-sm text-gray-600",children:"Default On"}),(0,a.jsx)(tl.Switch,{checked:p,onChange:h})]})]}),(0,a.jsxs)("div",{className:"flex flex-1 overflow-hidden mt-4 gap-6",children:[(0,a.jsxs)("div",{className:"flex-[2] flex flex-col min-w-0 overflow-y-auto",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between mb-2 flex-shrink-0",children:[(0,a.jsx)("span",{className:"text-xs font-semibold text-gray-500 uppercase tracking-wide",children:"Python Logic"}),(0,a.jsx)("span",{className:"text-xs text-gray-400",children:"Restricted environment (no imports)"})]}),(0,a.jsxs)("div",{className:"relative rounded-lg overflow-hidden border border-gray-700 bg-[#1e1e1e] flex-shrink-0",style:{minHeight:"300px",maxHeight:"400px"},children:[(0,a.jsx)("div",{className:"absolute left-0 top-0 bottom-0 w-12 bg-[#1e1e1e] border-r border-gray-700 text-right pr-3 pt-3 select-none overflow-hidden",style:{fontFamily:"'Fira Code', 'Monaco', 'Consolas', monospace",fontSize:"14px",lineHeight:"1.6"},children:Array.from({length:Math.max(K,20)},(e,t)=>(0,a.jsx)("div",{className:"text-gray-500 h-[22.4px]",children:t+1},t+1))}),(0,a.jsx)("textarea",{ref:R,value:v,onChange:e=>N(e.target.value),onKeyDown:e=>{if("Tab"===e.key){e.preventDefault();let t=e.currentTarget,l=t.selectionStart,a=t.selectionEnd;N(v.substring(0,l)+" "+v.substring(a)),setTimeout(()=>{t.selectionStart=t.selectionEnd=l+4},0)}},spellCheck:!1,className:"w-full h-full pl-14 pr-4 pt-3 pb-3 resize-none focus:outline-none bg-transparent text-gray-200",style:{fontFamily:"'Fira Code', 'Monaco', 'Consolas', monospace",fontSize:"14px",lineHeight:"1.6",tabSize:4}})]}),(0,a.jsx)(ek.Collapse,{activeKey:T?["test"]:[],onChange:e=>O(e.includes("test")),className:"mt-3 bg-white border border-gray-200 rounded-lg flex-shrink-0",expandIcon:({isActive:e})=>(0,a.jsx)(tj,{rotate:90*!!e}),children:(0,a.jsx)(tv,{header:(0,a.jsxs)("span",{className:"flex items-center gap-2 text-sm font-medium",children:[(0,a.jsx)(tx.PlayCircleOutlined,{className:"text-blue-500"}),"Test Your Guardrail"]}),children:(0,a.jsxs)("div",{className:"space-y-3",children:[(0,a.jsxs)("div",{children:[(0,a.jsxs)("div",{className:"flex items-center justify-between mb-2",children:[(0,a.jsx)("label",{className:"block text-xs font-medium text-gray-600",children:"Test Input (JSON)"}),(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("span",{className:"text-xs text-gray-500",children:"Load example:"}),(0,a.jsx)("button",{type:"button",onClick:()=>B(JSON.stringify(I,null,2)),className:"px-2 py-1 text-xs rounded border border-orange-200 bg-orange-50 text-orange-700 hover:bg-orange-100 transition-colors",children:"Pre-call"}),(0,a.jsx)("button",{type:"button",onClick:()=>B(JSON.stringify(P,null,2)),className:"px-2 py-1 text-xs rounded border border-green-200 bg-green-50 text-green-700 hover:bg-green-100 transition-colors",children:"Post-call"})]})]}),(0,a.jsx)("div",{className:"mb-2 p-2 bg-gray-50 rounded text-xs text-gray-600 border border-gray-200",children:(0,a.jsxs)("div",{className:"grid grid-cols-2 gap-x-4 gap-y-1",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("strong",{children:"texts"}),": Message content (always)"]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("strong",{children:"images"}),": Base64 images (vision)"]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("strong",{children:"tools"}),": Tool definitions ",(0,a.jsx)("span",{className:"text-orange-600",children:"(pre_call)"})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("strong",{children:"tool_calls"}),": LLM tool calls ",(0,a.jsx)("span",{className:"text-green-600",children:"(post_call)"})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("strong",{children:"structured_messages"}),": Full messages ",(0,a.jsx)("span",{className:"text-orange-600",children:"(pre_call)"})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("strong",{children:"model"}),": Model name (always)"]})]})}),(0,a.jsx)(tb,{value:A,onChange:e=>B(e.target.value),rows:8,className:"font-mono text-xs",placeholder:'{"texts": ["test message"], ...}'})]}),(0,a.jsxs)("div",{className:"flex items-center gap-3",children:[(0,a.jsx)(s.Button,{size:"xs",onClick:D,disabled:S,icon:tx.PlayCircleOutlined,children:S?"Running...":"Run Test"}),L&&(0,a.jsx)("div",{className:`flex items-center gap-2 text-sm ${L.error?"text-red-600":"allow"===L.action?"text-green-600":"block"===L.action?"text-orange-600":"text-blue-600"}`,children:L.error?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(tf,{}),(0,a.jsxs)("span",{children:[L.error_type&&(0,a.jsxs)("span",{className:"font-medium",children:["[",L.error_type,"] "]}),L.error]})]}):"allow"===L.action?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(tg.CheckCircleOutlined,{})," Allowed"]}):"block"===L.action?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(tf,{})," Blocked: ",L.reason]}):"modify"===L.action?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(tg.CheckCircleOutlined,{})," Modified",L.texts&&L.texts.length>0&&(0,a.jsxs)("span",{className:"text-xs text-gray-500 ml-1",children:["→ ",L.texts[0].substring(0,50),L.texts[0].length>50?"...":""]})]}):(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(tg.CheckCircleOutlined,{})," ",L.action||"Unknown"]})})]})]})},"test")})]}),(0,a.jsxs)("div",{className:"w-[300px] flex-shrink-0 overflow-auto border-l border-gray-200 pl-6",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2 mb-3",children:[(0,a.jsx)(x.CodeOutlined,{className:"text-blue-500"}),(0,a.jsx)("span",{className:"font-semibold text-gray-700",children:"Available Primitives"})]}),(0,a.jsx)("p",{className:"text-xs text-gray-500 mb-3",children:"Click to copy functions to clipboard"}),(0,a.jsx)(ek.Collapse,{defaultActiveKey:["Return Values"],className:"primitives-collapse bg-transparent border-0",expandIconPosition:"end",children:Object.entries(tw).map(([e,t])=>(0,a.jsx)(tv,{header:(0,a.jsx)("span",{className:"text-sm font-medium text-gray-700",children:e}),className:"bg-white mb-2 rounded-lg border border-gray-200",children:(0,a.jsx)("div",{className:"space-y-2",children:t.map(e=>(0,a.jsx)("button",{onClick:()=>G(e.name),className:`w-full text-left px-2 py-2 rounded transition-colors ${E===e.name?"bg-green-100":"bg-gray-50 hover:bg-blue-50"}`,children:E===e.name?(0,a.jsxs)("span",{className:"flex items-center gap-1 text-xs font-mono text-green-700",children:[(0,a.jsx)(tg.CheckCircleOutlined,{})," Copied!"]}):(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("div",{className:"text-xs font-mono text-gray-800",children:e.name}),(0,a.jsx)("div",{className:"text-[10px] text-gray-500 mt-0.5",children:e.desc})]})},e.name))})},e))})]})]}),(0,a.jsxs)("div",{className:"flex items-center justify-between pt-4 mt-4 border-t border-gray-200",children:[(0,a.jsx)("span",{className:"text-xs text-gray-400",children:"Changes are auto-saved to local draft"}),(0,a.jsxs)("div",{className:"flex items-center gap-3",children:[(0,a.jsx)(s.Button,{variant:"secondary",onClick:t,children:"Cancel"}),(0,a.jsx)(s.Button,{onClick:$,loading:w,disabled:w||!d.trim(),icon:t_.SaveOutlined,children:o?"Update Guardrail":"Save Guardrail"})]})]})]}),(0,a.jsx)("style",{children:` + .custom-code-modal .ant-modal-content { + padding: 24px; + } + .custom-code-modal .ant-modal-close { + top: 20px; + right: 20px; + } + .primitives-collapse .ant-collapse-item { + border: none !important; + } + .primitives-collapse .ant-collapse-header { + padding: 8px 12px !important; + } + .primitives-collapse .ant-collapse-content-box { + padding: 8px 12px !important; + } + `})]})};var tk=e.i(530212),tT=e.i(500330),tO=e.i(678784),tI=e.i(118366);let tP=({guardrailId:e,onClose:t,accessToken:l,isAdmin:u})=>{let[m,p]=(0,r.useState)(null),[f,j]=(0,r.useState)(null),[_,v]=(0,r.useState)(!0),[N,w]=(0,r.useState)(!1),[C]=h.Form.useForm(),[S,T]=(0,r.useState)([]),[O,I]=(0,r.useState)({}),[P,A]=(0,r.useState)(null),[F,M]=(0,r.useState)({}),[G,$]=(0,r.useState)(!1),D={rules:[],default_action:"deny",on_disallowed_action:"block",violation_message_template:""},[K,J]=(0,r.useState)(D),[q,U]=(0,r.useState)(!1),[V,H]=(0,r.useState)(!1),Y=r.default.useRef({patterns:[],blockedWords:[]}),W=(0,r.useCallback)((e,t)=>{Y.current={patterns:e,blockedWords:t}},[]),Z=async()=>{try{if(v(!0),!l)return;let t=await (0,g.getGuardrailInfo)(l,e);if(p(t),t.litellm_params?.pii_entities_config){let e=t.litellm_params.pii_entities_config;if(T([]),I({}),Object.keys(e).length>0){let t=[],l={};Object.entries(e).forEach(([e,a])=>{t.push(e),l[e]="string"==typeof a?a:"MASK"}),T(t),I(l)}}else T([]),I({})}catch(e){er.default.fromBackend("Failed to load guardrail information"),console.error("Error fetching guardrail info:",e)}finally{v(!1)}},X=async()=>{try{if(!l)return;let e=await (0,g.getGuardrailProviderSpecificParams)(l);j(e)}catch(e){console.error("Error fetching guardrail provider specific params:",e)}},et=async()=>{try{if(!l)return;let e=await (0,g.getGuardrailUISettings)(l);A(e)}catch(e){console.error("Error fetching guardrail UI settings:",e)}};(0,r.useEffect)(()=>{X()},[l]),(0,r.useEffect)(()=>{Z(),et()},[e,l]),(0,r.useEffect)(()=>{m&&C&&C.setFieldsValue({guardrail_name:m.guardrail_name,...m.litellm_params,guardrail_info:m.guardrail_info?JSON.stringify(m.guardrail_info,null,2):"",...m.litellm_params?.optional_params&&{optional_params:m.litellm_params.optional_params}})},[m,f,C]);let el=(0,r.useCallback)(()=>{m?.litellm_params?.guardrail==="tool_permission"?J({rules:m.litellm_params?.rules||[],default_action:(m.litellm_params?.default_action||"deny").toLowerCase(),on_disallowed_action:(m.litellm_params?.on_disallowed_action||"block").toLowerCase(),violation_message_template:m.litellm_params?.violation_message_template||""}):J(D),U(!1)},[m]);(0,r.useEffect)(()=>{el()},[el]);let es=async t=>{try{if(!l)return;let a={litellm_params:{}};t.guardrail_name!==m.guardrail_name&&(a.guardrail_name=t.guardrail_name),t.default_on!==m.litellm_params?.default_on&&(a.litellm_params.default_on=t.default_on);let r=m.guardrail_info,s=t.guardrail_info?JSON.parse(t.guardrail_info):void 0;JSON.stringify(r)!==JSON.stringify(s)&&(a.guardrail_info=s);let i=m.litellm_params?.pii_entities_config||{},n={};if(S.forEach(e=>{n[e]=O[e]||"MASK"}),JSON.stringify(i)!==JSON.stringify(n)&&(a.litellm_params.pii_entities_config=n),m.litellm_params?.guardrail==="litellm_content_filter"&&G){let e,t;m.litellm_params?.patterns,m.litellm_params?.blocked_words;let l=(e=Y.current.patterns||[],t=Y.current.blockedWords||[],{patterns:e.map(e=>({pattern_type:"prebuilt"===e.type?"prebuilt":"regex",pattern_name:"prebuilt"===e.type?e.name:void 0,pattern:"custom"===e.type?e.pattern:void 0,name:e.name,action:e.action})),blocked_words:t.map(e=>({keyword:e.keyword,action:e.action,description:e.description}))});a.litellm_params.patterns=l.patterns,a.litellm_params.blocked_words=l.blocked_words}if(m.litellm_params?.guardrail==="tool_permission"){let e=m.litellm_params?.rules||[],t=K.rules||[],l=JSON.stringify(e)!==JSON.stringify(t),r=(m.litellm_params?.default_action||"deny").toLowerCase(),s=(K.default_action||"deny").toLowerCase(),i=r!==s,n=(m.litellm_params?.on_disallowed_action||"block").toLowerCase(),o=(K.on_disallowed_action||"block").toLowerCase(),d=n!==o,c=m.litellm_params?.violation_message_template||"",u=K.violation_message_template||"",p=c!==u;(q||l||i||d||p)&&(a.litellm_params.rules=t,a.litellm_params.default_action=s,a.litellm_params.on_disallowed_action=o,a.litellm_params.violation_message_template=u||null)}let o=Object.keys(k).find(e=>k[e]===m.litellm_params?.guardrail);console.log("values: ",JSON.stringify(t)),console.log("currentProvider: ",o);let d=m.litellm_params?.guardrail==="tool_permission";if(f&&o&&!d){let e=f[k[o]?.toLowerCase()]||{},l=new Set;console.log("providerSpecificParams: ",JSON.stringify(e)),Object.keys(e).forEach(e=>{"optional_params"!==e&&l.add(e)}),e.optional_params&&e.optional_params.fields&&Object.keys(e.optional_params.fields).forEach(e=>{l.add(e)}),console.log("allowedParams: ",l),l.forEach(e=>{if("patterns"===e||"blocked_words"===e)return;let l=t[e];(null==l||""===l)&&(l=t.optional_params?.[e]);let r=m.litellm_params?.[e];JSON.stringify(l)!==JSON.stringify(r)&&(null!=l&&""!==l?a.litellm_params[e]=l:null!=r&&""!==r&&(a.litellm_params[e]=null))})}if(0===Object.keys(a.litellm_params).length&&delete a.litellm_params,0===Object.keys(a).length){er.default.info("No changes detected"),w(!1);return}await (0,g.updateGuardrailCall)(l,e,a),er.default.success("Guardrail updated successfully"),$(!1),Z(),w(!1)}catch(e){console.error("Error updating guardrail:",e),er.default.fromBackend("Failed to update guardrail")}};if(_)return(0,a.jsx)("div",{className:"p-4",children:"Loading..."});if(!m)return(0,a.jsx)("div",{className:"p-4",children:"Guardrail not found"});let ei=e=>e?new Date(e).toLocaleString():"-",{logo:en,displayName:eo}=B(m.litellm_params?.guardrail||""),ed=async(e,t)=>{await (0,tT.copyToClipboard)(e)&&(M(e=>({...e,[t]:!0})),setTimeout(()=>{M(e=>({...e,[t]:!1}))},2e3))},ec="config"===m.guardrail_definition_location;return(0,a.jsxs)("div",{className:"p-4",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)(s.Button,{icon:tk.ArrowLeftIcon,variant:"light",onClick:t,className:"mb-4",children:"Back to Guardrails"}),(0,a.jsx)(tc.Title,{children:m.guardrail_name||"Unnamed Guardrail"}),(0,a.jsxs)("div",{className:"flex items-center cursor-pointer",children:[(0,a.jsx)(eR.Text,{className:"text-gray-500 font-mono",children:m.guardrail_id}),(0,a.jsx)(L.Button,{type:"text",size:"small",icon:F["guardrail-id"]?(0,a.jsx)(tO.CheckIcon,{size:12}):(0,a.jsx)(tI.CopyIcon,{size:12}),onClick:()=>ed(m.guardrail_id,"guardrail-id"),className:`left-2 z-10 transition-all duration-200 ${F["guardrail-id"]?"text-green-600 bg-green-50 border-green-200":"text-gray-500 hover:text-gray-700 hover:bg-gray-100"}`})]})]}),(0,a.jsxs)(i.TabGroup,{children:[(0,a.jsxs)(n.TabList,{className:"mb-4",children:[(0,a.jsx)(o.Tab,{children:"Overview"},"overview"),u?(0,a.jsx)(o.Tab,{children:"Settings"},"settings"):(0,a.jsx)(a.Fragment,{})]}),(0,a.jsxs)(d.TabPanels,{children:[(0,a.jsxs)(c.TabPanel,{children:[(0,a.jsxs)(tu.Grid,{numItems:1,numItemsSm:2,numItemsLg:3,className:"gap-6",children:[(0,a.jsxs)(eM.Card,{children:[(0,a.jsx)(eR.Text,{children:"Provider"}),(0,a.jsxs)("div",{className:"mt-2 flex items-center space-x-2",children:[en&&(0,a.jsx)("img",{src:en,alt:`${eo} logo`,className:"w-6 h-6",onError:e=>{e.target.style.display="none"}}),(0,a.jsx)(tc.Title,{children:eo})]})]}),(0,a.jsxs)(eM.Card,{children:[(0,a.jsx)(eR.Text,{children:"Mode"}),(0,a.jsxs)("div",{className:"mt-2",children:[(0,a.jsx)(tc.Title,{children:m.litellm_params?.mode||"-"}),(0,a.jsx)(e9.Badge,{color:m.litellm_params?.default_on?"green":"gray",children:m.litellm_params?.default_on?"Default On":"Default Off"})]})]}),(0,a.jsxs)(eM.Card,{children:[(0,a.jsx)(eR.Text,{children:"Created At"}),(0,a.jsxs)("div",{className:"mt-2",children:[(0,a.jsx)(tc.Title,{children:ei(m.created_at)}),(0,a.jsxs)(eR.Text,{children:["Last Updated: ",ei(m.updated_at)]})]})]})]}),m.litellm_params?.pii_entities_config&&Object.keys(m.litellm_params.pii_entities_config).length>0&&(0,a.jsx)(eM.Card,{className:"mt-6",children:(0,a.jsxs)("div",{className:"flex justify-between items-center",children:[(0,a.jsx)(eR.Text,{className:"font-medium",children:"PII Protection"}),(0,a.jsxs)(e9.Badge,{color:"blue",children:[Object.keys(m.litellm_params.pii_entities_config).length," PII entities configured"]})]})}),m.litellm_params?.pii_entities_config&&Object.keys(m.litellm_params.pii_entities_config).length>0&&(0,a.jsxs)(eM.Card,{className:"mt-6",children:[(0,a.jsx)(eR.Text,{className:"mb-4 text-lg font-semibold",children:"PII Entity Configuration"}),(0,a.jsxs)("div",{className:"border rounded-lg overflow-hidden shadow-sm",children:[(0,a.jsxs)("div",{className:"bg-gray-50 px-5 py-3 border-b flex",children:[(0,a.jsx)(eR.Text,{className:"flex-1 font-semibold text-gray-700",children:"Entity Type"}),(0,a.jsx)(eR.Text,{className:"flex-1 font-semibold text-gray-700",children:"Configuration"})]}),(0,a.jsx)("div",{className:"max-h-[400px] overflow-y-auto",children:Object.entries(m.litellm_params?.pii_entities_config).map(([e,t])=>(0,a.jsxs)("div",{className:"px-5 py-3 flex border-b hover:bg-gray-50 transition-colors",children:[(0,a.jsx)(eR.Text,{className:"flex-1 font-medium text-gray-900",children:e}),(0,a.jsx)(eR.Text,{className:"flex-1",children:(0,a.jsxs)("span",{className:`inline-flex items-center gap-1.5 ${"MASK"===t?"text-blue-600":"text-red-600"}`,children:["MASK"===t?(0,a.jsx)(R.default,{}):(0,a.jsx)(z.StopOutlined,{}),String(t)]})})]},e))})]})]}),m.litellm_params?.guardrail==="tool_permission"&&(0,a.jsx)(eM.Card,{className:"mt-6",children:(0,a.jsx)(eJ,{value:K,disabled:!0})}),m.litellm_params?.guardrail==="custom_code"&&m.litellm_params?.custom_code&&(0,a.jsxs)(eM.Card,{className:"mt-6",children:[(0,a.jsxs)("div",{className:"flex justify-between items-center mb-4",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)(x.CodeOutlined,{className:"text-blue-500"}),(0,a.jsx)(eR.Text,{className:"font-medium text-lg",children:"Custom Code"})]}),u&&!ec&&(0,a.jsx)(s.Button,{size:"xs",variant:"secondary",icon:x.CodeOutlined,onClick:()=>H(!0),children:"Edit Code"})]}),(0,a.jsx)("div",{className:"relative rounded-lg overflow-hidden border border-gray-700 bg-[#1e1e1e]",children:(0,a.jsx)("pre",{className:"p-4 text-sm text-gray-200 overflow-x-auto",style:{fontFamily:"'Fira Code', 'Monaco', 'Consolas', monospace"},children:(0,a.jsx)("code",{children:m.litellm_params.custom_code})})})]}),(0,a.jsx)(tp,{guardrailData:m,guardrailSettings:P,isEditing:!1,accessToken:l})]}),u&&(0,a.jsx)(c.TabPanel,{children:(0,a.jsxs)(eM.Card,{children:[(0,a.jsxs)("div",{className:"flex justify-between items-center mb-4",children:[(0,a.jsx)(tc.Title,{children:"Guardrail Settings"}),ec&&(0,a.jsx)(E.Tooltip,{title:"Guardrail is defined in the config file and cannot be edited.",children:(0,a.jsx)(eD.InfoCircleOutlined,{})}),!N&&!ec&&(m.litellm_params?.guardrail==="custom_code"?(0,a.jsx)(s.Button,{icon:x.CodeOutlined,onClick:()=>H(!0),children:"Edit Code"}):(0,a.jsx)(s.Button,{onClick:()=>w(!0),children:"Edit Settings"}))]}),N?(0,a.jsxs)(h.Form,{form:C,onFinish:es,initialValues:{guardrail_name:m.guardrail_name,...m.litellm_params,guardrail_info:m.guardrail_info?JSON.stringify(m.guardrail_info,null,2):"",...m.litellm_params?.optional_params&&{optional_params:m.litellm_params.optional_params}},layout:"vertical",children:[(0,a.jsx)(h.Form.Item,{label:"Guardrail Name",name:"guardrail_name",rules:[{required:!0,message:"Please input a guardrail name"}],children:(0,a.jsx)(b.TextInput,{})}),(0,a.jsx)(h.Form.Item,{label:"Default On",name:"default_on",children:(0,a.jsxs)(y.Select,{children:[(0,a.jsx)(y.Select.Option,{value:!0,children:"Yes"}),(0,a.jsx)(y.Select.Option,{value:!1,children:"No"})]})}),m.litellm_params?.guardrail==="presidio"&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(ez.Divider,{orientation:"left",children:"PII Protection"}),(0,a.jsx)("div",{className:"mb-6",children:P&&(0,a.jsx)(Q,{entities:P.supported_entities,actions:P.supported_actions,selectedEntities:S,selectedActions:O,onEntitySelect:e=>{T(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e])},onActionSelect:(e,t)=>{I(l=>({...l,[e]:t}))},entityCategories:P.pii_entity_categories})})]}),(0,a.jsx)(tp,{guardrailData:m,guardrailSettings:P,isEditing:!0,accessToken:l,onDataChange:W,onUnsavedChanges:$}),(0,a.jsx)(ez.Divider,{orientation:"left",children:"Provider Settings"}),m.litellm_params?.guardrail==="tool_permission"?(0,a.jsx)(eJ,{value:K,onChange:J}):(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(ee,{selectedProvider:Object.keys(k).find(e=>k[e]===m.litellm_params?.guardrail)||null,accessToken:l,providerParams:f,value:m.litellm_params}),f&&(()=>{let e=Object.keys(k).find(e=>k[e]===m.litellm_params?.guardrail);if(!e)return null;let t=f[k[e]?.toLowerCase()];return t&&t.optional_params?(0,a.jsx)(ea,{optionalParams:t.optional_params,parentFieldKey:"optional_params",values:m.litellm_params}):null})()]}),(0,a.jsx)(ez.Divider,{orientation:"left",children:"Advanced Settings"}),(0,a.jsx)(h.Form.Item,{label:"Guardrail Information",name:"guardrail_info",children:(0,a.jsx)(e$.Input.TextArea,{rows:5})}),(0,a.jsxs)("div",{className:"flex justify-end gap-2 mt-6",children:[(0,a.jsx)(L.Button,{onClick:()=>{w(!1),$(!1),el()},children:"Cancel"}),(0,a.jsx)(s.Button,{children:"Save Changes"})]})]}):(0,a.jsxs)("div",{className:"space-y-4",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)(eR.Text,{className:"font-medium",children:"Guardrail ID"}),(0,a.jsx)("div",{className:"font-mono",children:m.guardrail_id})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)(eR.Text,{className:"font-medium",children:"Guardrail Name"}),(0,a.jsx)("div",{children:m.guardrail_name||"Unnamed Guardrail"})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)(eR.Text,{className:"font-medium",children:"Provider"}),(0,a.jsx)("div",{children:eo})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)(eR.Text,{className:"font-medium",children:"Mode"}),(0,a.jsx)("div",{children:m.litellm_params?.mode||"-"})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)(eR.Text,{className:"font-medium",children:"Default On"}),(0,a.jsx)(e9.Badge,{color:m.litellm_params?.default_on?"green":"gray",children:m.litellm_params?.default_on?"Yes":"No"})]}),m.litellm_params?.pii_entities_config&&Object.keys(m.litellm_params.pii_entities_config).length>0&&(0,a.jsxs)("div",{children:[(0,a.jsx)(eR.Text,{className:"font-medium",children:"PII Protection"}),(0,a.jsx)("div",{className:"mt-2",children:(0,a.jsxs)(e9.Badge,{color:"blue",children:[Object.keys(m.litellm_params.pii_entities_config).length," PII entities configured"]})})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)(eR.Text,{className:"font-medium",children:"Created At"}),(0,a.jsx)("div",{children:ei(m.created_at)})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)(eR.Text,{className:"font-medium",children:"Last Updated"}),(0,a.jsx)("div",{children:ei(m.updated_at)})]}),m.litellm_params?.guardrail==="tool_permission"&&(0,a.jsx)(eJ,{value:K,disabled:!0})]})]})})]})]}),(0,a.jsx)(tS,{visible:V,onClose:()=>H(!1),onSuccess:()=>{H(!1),Z()},accessToken:l,editData:m?{guardrail_id:m.guardrail_id,guardrail_name:m.guardrail_name,litellm_params:m.litellm_params}:null})]})};var tA=e.i(573421),tB=e.i(19732),tL=e.i(928685),tF=e.i(166406),tE=e.i(637235),tM=e.i(240647);let{Text:tR}=f.Typography,tz=function({results:e,errors:t}){let[l,i]=(0,r.useState)(new Set),n=e=>{let t=new Set(l);t.has(e)?t.delete(e):t.add(e),i(t)},o=async e=>{try{if(navigator.clipboard&&window.isSecureContext)return await navigator.clipboard.writeText(e),!0;{let t=document.createElement("textarea");t.value=e,t.style.position="fixed",t.style.opacity="0",document.body.appendChild(t),t.focus(),t.select();let l=document.execCommand("copy");if(document.body.removeChild(t),!l)throw Error("execCommand failed");return!0}}catch(e){return console.error("Copy failed:",e),!1}};return e||t?(0,a.jsxs)("div",{className:"space-y-3 pt-4 border-t border-gray-200",children:[(0,a.jsx)("h3",{className:"text-sm font-semibold text-gray-900",children:"Results"}),e&&e.map(e=>{let t=l.has(e.guardrailName);return(0,a.jsx)(eM.Card,{className:"bg-green-50 border-green-200",children:(0,a.jsxs)("div",{className:"space-y-3",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between",children:[(0,a.jsxs)("div",{className:"flex items-center space-x-2 cursor-pointer flex-1",onClick:()=>n(e.guardrailName),children:[t?(0,a.jsx)(tM.RightOutlined,{className:"text-gray-500 text-xs"}):(0,a.jsx)(m.DownOutlined,{className:"text-gray-500 text-xs"}),(0,a.jsx)(tg.CheckCircleOutlined,{className:"text-green-600 text-lg"}),(0,a.jsx)("span",{className:"text-sm font-medium text-green-800",children:e.guardrailName})]}),(0,a.jsxs)("div",{className:"flex items-center gap-3",children:[(0,a.jsxs)("div",{className:"flex items-center space-x-1 text-xs text-gray-600",children:[(0,a.jsx)(tE.ClockCircleOutlined,{}),(0,a.jsxs)("span",{className:"font-medium",children:[e.latency,"ms"]})]}),!t&&(0,a.jsx)(s.Button,{size:"xs",variant:"secondary",icon:tF.CopyOutlined,onClick:async()=>{await o(e.response_text)?er.default.success("Result copied to clipboard"):er.default.fromBackend("Failed to copy result")},children:"Copy"})]})]}),!t&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{className:"bg-white border border-green-200 rounded p-3",children:[(0,a.jsx)("label",{className:"text-xs font-medium text-gray-600 mb-2 block",children:"Output Text"}),(0,a.jsx)("div",{className:"font-mono text-sm text-gray-900 whitespace-pre-wrap break-words",children:e.response_text})]}),(0,a.jsxs)("div",{className:"text-xs text-gray-600",children:[(0,a.jsx)("span",{className:"font-medium",children:"Characters:"})," ",e.response_text.length]})]})]})},e.guardrailName)}),t&&t.map(e=>{let t=l.has(e.guardrailName);return(0,a.jsx)(eM.Card,{className:"bg-red-50 border-red-200",children:(0,a.jsxs)("div",{className:"flex items-start space-x-2",children:[(0,a.jsx)("div",{className:"cursor-pointer mt-0.5",onClick:()=>n(e.guardrailName),children:t?(0,a.jsx)(tM.RightOutlined,{className:"text-gray-500 text-xs"}):(0,a.jsx)(m.DownOutlined,{className:"text-gray-500 text-xs"})}),(0,a.jsx)("div",{className:"text-red-600 mt-0.5",children:(0,a.jsx)("svg",{className:"w-5 h-5",fill:"currentColor",viewBox:"0 0 20 20",children:(0,a.jsx)("path",{fillRule:"evenodd",d:"M10 18a8 8 0 100-16 8 8 0 000 16zM8.707 7.293a1 1 0 00-1.414 1.414L8.586 10l-1.293 1.293a1 1 0 101.414 1.414L10 11.414l1.293 1.293a1 1 0 001.414-1.414L11.414 10l1.293-1.293a1 1 0 00-1.414-1.414L10 8.586 8.707 7.293z",clipRule:"evenodd"})})}),(0,a.jsxs)("div",{className:"flex-1",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between mb-1",children:[(0,a.jsxs)("p",{className:"text-sm font-medium text-red-800 cursor-pointer",onClick:()=>n(e.guardrailName),children:[e.guardrailName," - Error"]}),(0,a.jsxs)("div",{className:"flex items-center space-x-1 text-xs text-gray-600",children:[(0,a.jsx)(tE.ClockCircleOutlined,{}),(0,a.jsxs)("span",{className:"font-medium",children:[e.latency,"ms"]})]})]}),!t&&(0,a.jsx)("p",{className:"text-sm text-red-700 mt-1",children:e.error.message})]})]})},e.guardrailName)})]}):null},{TextArea:tG}=e$.Input,{Text:t$}=f.Typography,tD=function({guardrailNames:e,onSubmit:t,isLoading:l,results:i,errors:n,onClose:o}){let[d,c]=(0,r.useState)(""),u=()=>{d.trim()?t(d):er.default.fromBackend("Please enter text to test")},m=async e=>{try{if(navigator.clipboard&&window.isSecureContext)return await navigator.clipboard.writeText(e),!0;{let t=document.createElement("textarea");t.value=e,t.style.position="fixed",t.style.opacity="0",document.body.appendChild(t),t.focus(),t.select();let l=document.execCommand("copy");if(document.body.removeChild(t),!l)throw Error("execCommand failed");return!0}}catch(e){return console.error("Copy failed:",e),!1}},p=async()=>{await m(d)?er.default.success("Input copied to clipboard"):er.default.fromBackend("Failed to copy input")};return(0,a.jsxs)("div",{className:"space-y-4 h-full flex flex-col",children:[(0,a.jsx)("div",{className:"flex items-center justify-between pb-3 border-b border-gray-200",children:(0,a.jsx)("div",{className:"flex items-center space-x-3",children:(0,a.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,a.jsxs)("div",{className:"flex items-center space-x-2 mb-1",children:[(0,a.jsx)("h2",{className:"text-lg font-semibold text-gray-900",children:"Test Guardrails:"}),(0,a.jsx)("div",{className:"flex flex-wrap gap-2",children:e.map(e=>(0,a.jsx)("div",{className:"inline-flex items-center space-x-1 bg-blue-50 px-3 py-1 rounded-md border border-blue-200",children:(0,a.jsx)("span",{className:"font-mono text-blue-700 font-medium text-sm",children:e})},e))})]}),(0,a.jsxs)("p",{className:"text-sm text-gray-500",children:["Test ",e.length>1?"guardrails":"guardrail"," and compare results"]})]})})}),(0,a.jsxs)("div",{className:"flex-1 overflow-auto space-y-4",children:[(0,a.jsxs)("div",{className:"space-y-3",children:[(0,a.jsxs)("div",{children:[(0,a.jsxs)("div",{className:"flex justify-between items-center mb-2",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("label",{className:"text-sm font-medium text-gray-700",children:"Input Text"}),(0,a.jsx)(E.Tooltip,{title:"Press Enter to submit. Use Shift+Enter for new line.",children:(0,a.jsx)(eD.InfoCircleOutlined,{className:"text-gray-400 cursor-help"})})]}),d&&(0,a.jsx)(s.Button,{size:"xs",variant:"secondary",icon:tF.CopyOutlined,onClick:p,children:"Copy Input"})]}),(0,a.jsx)(tG,{value:d,onChange:e=>c(e.target.value),onKeyDown:e=>{"Enter"!==e.key||e.shiftKey||e.ctrlKey||e.metaKey||(e.preventDefault(),u())},placeholder:"Enter text to test with guardrails...",rows:8,className:"font-mono text-sm"}),(0,a.jsxs)("div",{className:"flex justify-between items-center mt-1",children:[(0,a.jsxs)(t$,{className:"text-xs text-gray-500",children:["Press ",(0,a.jsx)("kbd",{className:"px-1 py-0.5 bg-gray-100 border border-gray-300 rounded text-xs",children:"Enter"})," to submit • ",(0,a.jsx)("kbd",{className:"px-1 py-0.5 bg-gray-100 border border-gray-300 rounded text-xs",children:"Shift+Enter"})," for new line"]}),(0,a.jsxs)(t$,{className:"text-xs text-gray-500",children:["Characters: ",d.length]})]})]}),(0,a.jsx)("div",{className:"pt-2",children:(0,a.jsx)(s.Button,{onClick:u,loading:l,disabled:!d.trim(),className:"w-full",children:l?`Testing ${e.length} guardrail${e.length>1?"s":""}...`:`Test ${e.length} guardrail${e.length>1?"s":""}`})})]}),(0,a.jsx)(tz,{results:i,errors:n})]})]})},tK=({guardrailsList:e,isLoading:t,accessToken:l,onClose:s})=>{let[i,n]=(0,r.useState)(new Set),[o,d]=(0,r.useState)(""),[c,u]=(0,r.useState)([]),[m,p]=(0,r.useState)([]),[x,h]=(0,r.useState)(!1),f=e.filter(e=>e.guardrail_name?.toLowerCase().includes(o.toLowerCase())),y=e=>{let t=new Set(i);t.has(e)?t.delete(e):t.add(e),n(t)},j=async e=>{if(0===i.size||!l)return;h(!0),u([]),p([]);let t=[],a=[];await Promise.all(Array.from(i).map(async r=>{let s=Date.now();try{let a=await (0,g.applyGuardrail)(l,r,e,null,null),i=Date.now()-s;t.push({guardrailName:r,response_text:a.response_text,latency:i})}catch(t){let e=Date.now()-s;console.error(`Error testing guardrail ${r}:`,t),a.push({guardrailName:r,error:t,latency:e})}})),u(t),p(a),h(!1),t.length>0&&er.default.success(`${t.length} guardrail${t.length>1?"s":""} applied successfully`),a.length>0&&er.default.fromBackend(`${a.length} guardrail${a.length>1?"s":""} failed`)};return(0,a.jsx)("div",{className:"w-full h-[calc(100vh-200px)]",children:(0,a.jsx)(eM.Card,{className:"h-full",children:(0,a.jsxs)("div",{className:"flex h-full",children:[(0,a.jsxs)("div",{className:"w-1/4 border-r border-gray-200 flex flex-col overflow-hidden",children:[(0,a.jsx)("div",{className:"p-4 border-b border-gray-200",children:(0,a.jsxs)("div",{className:"mb-3",children:[(0,a.jsx)(tc.Title,{className:"text-lg font-semibold mb-3",children:"Guardrails"}),(0,a.jsx)(b.TextInput,{icon:tL.SearchOutlined,placeholder:"Search guardrails...",value:o,onValueChange:d})]})}),(0,a.jsx)("div",{className:"flex-1 overflow-auto",children:t?(0,a.jsx)("div",{className:"flex items-center justify-center h-32",children:(0,a.jsx)(Z.Spin,{})}):0===f.length?(0,a.jsx)("div",{className:"p-4",children:(0,a.jsx)(eG.Empty,{description:o?"No guardrails match your search":"No guardrails available"})}):(0,a.jsx)(tA.List,{dataSource:f,renderItem:e=>(0,a.jsx)(tA.List.Item,{onClick:()=>{e.guardrail_name&&y(e.guardrail_name)},className:`cursor-pointer hover:bg-gray-50 transition-colors px-4 ${i.has(e.guardrail_name||"")?"bg-blue-50 border-l-4 border-l-blue-500":"border-l-4 border-l-transparent"}`,children:(0,a.jsx)(tA.List.Item.Meta,{avatar:(0,a.jsx)(F.Checkbox,{checked:i.has(e.guardrail_name||""),onClick:t=>{t.stopPropagation(),e.guardrail_name&&y(e.guardrail_name)}}),title:(0,a.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,a.jsx)(tB.ExperimentOutlined,{className:"text-gray-400"}),(0,a.jsx)("span",{className:"font-medium text-gray-900",children:e.guardrail_name})]}),description:(0,a.jsxs)("div",{className:"text-xs space-y-1 mt-1",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("span",{className:"font-medium",children:"Type: "}),(0,a.jsx)("span",{className:"text-gray-600",children:e.litellm_params.guardrail})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("span",{className:"font-medium",children:"Mode: "}),(0,a.jsx)("span",{className:"text-gray-600",children:e.litellm_params.mode})]})]})})})})}),(0,a.jsx)("div",{className:"p-3 border-t border-gray-200 bg-gray-50",children:(0,a.jsxs)(eR.Text,{className:"text-xs text-gray-600",children:[i.size," of ",f.length," selected"]})})]}),(0,a.jsxs)("div",{className:"w-3/4 flex flex-col bg-white",children:[(0,a.jsx)("div",{className:"p-4 border-b border-gray-200 flex justify-between items-center",children:(0,a.jsx)(tc.Title,{className:"text-xl font-semibold mb-0",children:"Guardrail Testing Playground"})}),(0,a.jsx)("div",{className:"flex-1 overflow-auto p-4",children:0===i.size?(0,a.jsxs)("div",{className:"h-full flex flex-col items-center justify-center text-gray-400",children:[(0,a.jsx)(tB.ExperimentOutlined,{style:{fontSize:"48px",marginBottom:"16px"}}),(0,a.jsx)(eR.Text,{className:"text-lg font-medium text-gray-600 mb-2",children:"Select Guardrails to Test"}),(0,a.jsx)(eR.Text,{className:"text-center text-gray-500 max-w-md",children:"Choose one or more guardrails from the left sidebar to start testing and comparing results."})]}):(0,a.jsx)("div",{className:"h-full",children:(0,a.jsx)(tD,{guardrailNames:Array.from(i),onSubmit:j,results:c.length>0?c:null,errors:m.length>0?m:null,isLoading:x,onClose:()=>n(new Set)})})})]})]})})})};var tJ=e.i(127952);e.s(["default",0,({accessToken:e,userRole:t})=>{let[l,h]=(0,r.useState)([]),[f,y]=(0,r.useState)(!1),[j,_]=(0,r.useState)(!1),[v,b]=(0,r.useState)(!1),[N,w]=(0,r.useState)(!1),[C,S]=(0,r.useState)(null),[k,T]=(0,r.useState)(!1),[O,I]=(0,r.useState)(null),[P,A]=(0,r.useState)(0),L=!!t&&(0,td.isAdminRole)(t),F=async()=>{if(e){b(!0);try{let t=await (0,g.getGuardrailsList)(e);console.log(`guardrails: ${JSON.stringify(t)}`),h(t.guardrails)}catch(e){console.error("Error fetching guardrails:",e)}finally{b(!1)}}};(0,r.useEffect)(()=>{F()},[e]);let E=()=>{F()},M=async()=>{if(C&&e){w(!0);try{await (0,g.deleteGuardrailCall)(e,C.guardrail_id),er.default.success(`Guardrail "${C.guardrail_name}" deleted successfully`),await F()}catch(e){console.error("Error deleting guardrail:",e),er.default.fromBackend("Failed to delete guardrail")}finally{w(!1),T(!1),S(null)}}},R=C&&C.litellm_params?B(C.litellm_params.guardrail).displayName:void 0;return(0,a.jsx)("div",{className:"w-full mx-auto flex-auto overflow-y-auto m-8 p-2",children:(0,a.jsxs)(i.TabGroup,{index:P,onIndexChange:A,children:[(0,a.jsxs)(n.TabList,{className:"mb-4",children:[(0,a.jsx)(o.Tab,{children:"Guardrails"}),(0,a.jsx)(o.Tab,{disabled:!e||0===l.length,children:"Test Playground"})]}),(0,a.jsxs)(d.TabPanels,{children:[(0,a.jsxs)(c.TabPanel,{children:[(0,a.jsx)("div",{className:"flex justify-between items-center mb-4",children:(0,a.jsx)(u.Dropdown,{menu:{items:[{key:"provider",icon:(0,a.jsx)(p.PlusOutlined,{}),label:"Add Provider Guardrail",onClick:()=>{O&&I(null),y(!0)}},{key:"custom_code",icon:(0,a.jsx)(x.CodeOutlined,{}),label:"Create Custom Code Guardrail",onClick:()=>{O&&I(null),_(!0)}}]},trigger:["click"],disabled:!e,children:(0,a.jsxs)(s.Button,{disabled:!e,children:["+ Add New Guardrail ",(0,a.jsx)(m.DownOutlined,{className:"ml-2"})]})})}),O?(0,a.jsx)(tP,{guardrailId:O,onClose:()=>I(null),accessToken:e,isAdmin:L}):(0,a.jsx)(to,{guardrailsList:l,isLoading:v,onDeleteClick:(e,t)=>{S(l.find(t=>t.guardrail_id===e)||null),T(!0)},accessToken:e,onGuardrailUpdated:F,isAdmin:L,onGuardrailClick:e=>I(e)}),(0,a.jsx)(eQ,{visible:f,onClose:()=>{y(!1)},accessToken:e,onSuccess:E}),(0,a.jsx)(tS,{visible:j,onClose:()=>{_(!1)},accessToken:e,onSuccess:E}),(0,a.jsx)(tJ.default,{isOpen:k,title:"Delete Guardrail",message:`Are you sure you want to delete guardrail: ${C?.guardrail_name}? This action cannot be undone.`,resourceInformationTitle:"Guardrail Information",resourceInformation:[{label:"Name",value:C?.guardrail_name},{label:"ID",value:C?.guardrail_id,code:!0},{label:"Provider",value:R},{label:"Mode",value:C?.litellm_params.mode},{label:"Default On",value:C?.litellm_params.default_on?"Yes":"No"}],onCancel:()=>{T(!1),S(null)},onOk:M,confirmLoading:N})]}),(0,a.jsx)(c.TabPanel,{children:(0,a.jsx)(tK,{guardrailsList:l,isLoading:v,accessToken:e,onClose:()=>A(0)})})]})]})})}],487304)}]); \ No newline at end of file diff --git a/litellm/proxy/_experimental/out/_next/static/chunks/0d1694151d7fdaec.js b/litellm/proxy/_experimental/out/_next/static/chunks/0d1694151d7fdaec.js new file mode 100644 index 00000000000..6c9e93d7db9 --- /dev/null +++ b/litellm/proxy/_experimental/out/_next/static/chunks/0d1694151d7fdaec.js @@ -0,0 +1,38 @@ +(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,349356,e=>{e.v({AElig:"Æ",AMP:"&",Aacute:"Á",Acirc:"Â",Agrave:"À",Aring:"Å",Atilde:"Ã",Auml:"Ä",COPY:"©",Ccedil:"Ç",ETH:"Ð",Eacute:"É",Ecirc:"Ê",Egrave:"È",Euml:"Ë",GT:">",Iacute:"Í",Icirc:"Î",Igrave:"Ì",Iuml:"Ï",LT:"<",Ntilde:"Ñ",Oacute:"Ó",Ocirc:"Ô",Ograve:"Ò",Oslash:"Ø",Otilde:"Õ",Ouml:"Ö",QUOT:'"',REG:"®",THORN:"Þ",Uacute:"Ú",Ucirc:"Û",Ugrave:"Ù",Uuml:"Ü",Yacute:"Ý",aacute:"á",acirc:"â",acute:"´",aelig:"æ",agrave:"à",amp:"&",aring:"å",atilde:"ã",auml:"ä",brvbar:"¦",ccedil:"ç",cedil:"¸",cent:"¢",copy:"©",curren:"¤",deg:"°",divide:"÷",eacute:"é",ecirc:"ê",egrave:"è",eth:"ð",euml:"ë",frac12:"½",frac14:"¼",frac34:"¾",gt:">",iacute:"í",icirc:"î",iexcl:"¡",igrave:"ì",iquest:"¿",iuml:"ï",laquo:"«",lt:"<",macr:"¯",micro:"µ",middot:"·",nbsp:" ",not:"¬",ntilde:"ñ",oacute:"ó",ocirc:"ô",ograve:"ò",ordf:"ª",ordm:"º",oslash:"ø",otilde:"õ",ouml:"ö",para:"¶",plusmn:"±",pound:"£",quot:'"',raquo:"»",reg:"®",sect:"§",shy:"­",sup1:"¹",sup2:"²",sup3:"³",szlig:"ß",thorn:"þ",times:"×",uacute:"ú",ucirc:"û",ugrave:"ù",uml:"¨",uuml:"ü",yacute:"ý",yen:"¥",yuml:"ÿ"})},137429,e=>{e.v({0:"�",128:"€",130:"‚",131:"ƒ",132:"„",133:"…",134:"†",135:"‡",136:"ˆ",137:"‰",138:"Š",139:"‹",140:"Œ",142:"Ž",145:"‘",146:"’",147:"“",148:"”",149:"•",150:"–",151:"—",152:"˜",153:"™",154:"š",155:"›",156:"œ",158:"ž",159:"Ÿ"})},434626,e=>{"use strict";var r=e.i(271645);let t=r.forwardRef(function(e,t){return r.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:2,stroke:"currentColor","aria-hidden":"true",ref:t},e),r.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M10 6H6a2 2 0 00-2 2v10a2 2 0 002 2h10a2 2 0 002-2v-4M14 4h6m0 0v6m0-6L10 14"}))});e.s(["ExternalLinkIcon",0,t],434626)},902555,e=>{"use strict";var r=e.i(843476),t=e.i(591935),l=e.i(122577),a=e.i(278587),o=e.i(68155),i=e.i(360820),n=e.i(871943),s=e.i(434626),d=e.i(592968),c=e.i(115504),u=e.i(752978);function m({icon:e,onClick:t,className:l,disabled:a,dataTestId:o}){return a?(0,r.jsx)(u.Icon,{icon:e,size:"sm",className:"opacity-50 cursor-not-allowed","data-testid":o}):(0,r.jsx)(u.Icon,{icon:e,size:"sm",onClick:t,className:(0,c.cx)("cursor-pointer",l),"data-testid":o})}let g={Edit:{icon:t.PencilAltIcon,className:"hover:text-blue-600"},Delete:{icon:o.TrashIcon,className:"hover:text-red-600"},Test:{icon:l.PlayIcon,className:"hover:text-blue-600"},Regenerate:{icon:a.RefreshIcon,className:"hover:text-green-600"},Up:{icon:i.ChevronUpIcon,className:"hover:text-blue-600"},Down:{icon:n.ChevronDownIcon,className:"hover:text-blue-600"},Open:{icon:s.ExternalLinkIcon,className:"hover:text-green-600"}};function h({onClick:e,tooltipText:t,disabled:l=!1,disabledTooltipText:a,dataTestId:o,variant:i}){let{icon:n,className:s}=g[i];return(0,r.jsx)(d.Tooltip,{title:l?a:t,children:(0,r.jsx)("span",{children:(0,r.jsx)(m,{icon:n,onClick:e,className:s,disabled:l,dataTestId:o})})})}e.s(["default",()=>h],902555)},122577,e=>{"use strict";var r=e.i(271645);let t=r.forwardRef(function(e,t){return r.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:2,stroke:"currentColor","aria-hidden":"true",ref:t},e),r.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M14.752 11.168l-3.197-2.132A1 1 0 0010 9.87v4.263a1 1 0 001.555.832l3.197-2.132a1 1 0 000-1.664z"}),r.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M21 12a9 9 0 11-18 0 9 9 0 0118 0z"}))});e.s(["PlayIcon",0,t],122577)},207670,e=>{"use strict";function r(){for(var e,r,t=0,l="",a=arguments.length;tr,"default",0,r])},728889,e=>{"use strict";var r=e.i(290571),t=e.i(271645),l=e.i(829087),a=e.i(480731),o=e.i(444755),i=e.i(673706),n=e.i(95779);let s={xs:{paddingX:"px-1.5",paddingY:"py-1.5"},sm:{paddingX:"px-1.5",paddingY:"py-1.5"},md:{paddingX:"px-2",paddingY:"py-2"},lg:{paddingX:"px-2",paddingY:"py-2"},xl:{paddingX:"px-2.5",paddingY:"py-2.5"}},d={xs:{height:"h-3",width:"w-3"},sm:{height:"h-5",width:"w-5"},md:{height:"h-5",width:"w-5"},lg:{height:"h-7",width:"w-7"},xl:{height:"h-9",width:"w-9"}},c={simple:{rounded:"",border:"",ring:"",shadow:""},light:{rounded:"rounded-tremor-default",border:"",ring:"",shadow:""},shadow:{rounded:"rounded-tremor-default",border:"border",ring:"",shadow:"shadow-tremor-card dark:shadow-dark-tremor-card"},solid:{rounded:"rounded-tremor-default",border:"border-2",ring:"ring-1",shadow:""},outlined:{rounded:"rounded-tremor-default",border:"border",ring:"ring-2",shadow:""}},u=(0,i.makeClassName)("Icon"),m=t.default.forwardRef((e,m)=>{let{icon:g,variant:h="simple",tooltip:b,size:p=a.Sizes.SM,color:x,className:f}=e,j=(0,r.__rest)(e,["icon","variant","tooltip","size","color","className"]),C=((e,r)=>{switch(e){case"simple":return{textColor:r?(0,i.getColorClassNames)(r,n.colorPalette.text).textColor:"text-tremor-brand dark:text-dark-tremor-brand",bgColor:"",borderColor:"",ringColor:""};case"light":return{textColor:r?(0,i.getColorClassNames)(r,n.colorPalette.text).textColor:"text-tremor-brand dark:text-dark-tremor-brand",bgColor:r?(0,o.tremorTwMerge)((0,i.getColorClassNames)(r,n.colorPalette.background).bgColor,"bg-opacity-20"):"bg-tremor-brand-muted dark:bg-dark-tremor-brand-muted",borderColor:"",ringColor:""};case"shadow":return{textColor:r?(0,i.getColorClassNames)(r,n.colorPalette.text).textColor:"text-tremor-brand dark:text-dark-tremor-brand",bgColor:r?(0,o.tremorTwMerge)((0,i.getColorClassNames)(r,n.colorPalette.background).bgColor,"bg-opacity-20"):"bg-tremor-background dark:bg-dark-tremor-background",borderColor:"border-tremor-border dark:border-dark-tremor-border",ringColor:""};case"solid":return{textColor:r?(0,i.getColorClassNames)(r,n.colorPalette.text).textColor:"text-tremor-brand-inverted dark:text-dark-tremor-brand-inverted",bgColor:r?(0,o.tremorTwMerge)((0,i.getColorClassNames)(r,n.colorPalette.background).bgColor,"bg-opacity-20"):"bg-tremor-brand dark:bg-dark-tremor-brand",borderColor:"border-tremor-brand-inverted dark:border-dark-tremor-brand-inverted",ringColor:"ring-tremor-ring dark:ring-dark-tremor-ring"};case"outlined":return{textColor:r?(0,i.getColorClassNames)(r,n.colorPalette.text).textColor:"text-tremor-brand dark:text-dark-tremor-brand",bgColor:r?(0,o.tremorTwMerge)((0,i.getColorClassNames)(r,n.colorPalette.background).bgColor,"bg-opacity-20"):"bg-tremor-background dark:bg-dark-tremor-background",borderColor:r?(0,i.getColorClassNames)(r,n.colorPalette.ring).borderColor:"border-tremor-brand-subtle dark:border-dark-tremor-brand-subtle",ringColor:r?(0,o.tremorTwMerge)((0,i.getColorClassNames)(r,n.colorPalette.ring).ringColor,"ring-opacity-40"):"ring-tremor-brand-muted dark:ring-dark-tremor-brand-muted"}}})(h,x),{tooltipProps:k,getReferenceProps:y}=(0,l.useTooltip)();return t.default.createElement("span",Object.assign({ref:(0,i.mergeRefs)([m,k.refs.setReference]),className:(0,o.tremorTwMerge)(u("root"),"inline-flex shrink-0 items-center justify-center",C.bgColor,C.textColor,C.borderColor,C.ringColor,c[h].rounded,c[h].border,c[h].shadow,c[h].ring,s[p].paddingX,s[p].paddingY,f)},y,j),t.default.createElement(l.default,Object.assign({text:b},k)),t.default.createElement(g,{className:(0,o.tremorTwMerge)(u("icon"),"shrink-0",d[p].height,d[p].width)}))});m.displayName="Icon",e.s(["default",()=>m],728889)},752978,e=>{"use strict";var r=e.i(728889);e.s(["Icon",()=>r.default])},591935,e=>{"use strict";var r=e.i(271645);let t=r.forwardRef(function(e,t){return r.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:2,stroke:"currentColor","aria-hidden":"true",ref:t},e),r.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z"}))});e.s(["PencilAltIcon",0,t],591935)},646050,e=>{"use strict";var r=e.i(843476),t=e.i(994388),l=e.i(304967),a=e.i(197647),o=e.i(653824),i=e.i(269200),n=e.i(942232),s=e.i(977572),d=e.i(427612),c=e.i(64848),u=e.i(496020),m=e.i(881073),g=e.i(404206),h=e.i(723731),b=e.i(599724),p=e.i(271645),x=e.i(650056),f=e.i(127952),j=e.i(902555),C=e.i(727749),k=e.i(764205),y=e.i(779241),T=e.i(677667),v=e.i(898667),w=e.i(130643),I=e.i(464571),N=e.i(212931),B=e.i(808613),_=e.i(28651),P=e.i(199133);let A=({isModalVisible:e,accessToken:t,setIsModalVisible:l,setBudgetList:a})=>{let[o]=B.Form.useForm(),i=async e=>{if(null!=t&&void 0!=t)try{C.default.info("Making API Call");let r=await (0,k.budgetCreateCall)(t,e);console.log("key create Response:",r),a(e=>e?[...e,r]:[r]),C.default.success("Budget Created"),o.resetFields()}catch(e){console.error("Error creating the key:",e),C.default.fromBackend(`Error creating the key: ${e}`)}};return(0,r.jsx)(N.Modal,{title:"Create Budget",open:e,width:800,footer:null,onOk:()=>{l(!1),o.resetFields()},onCancel:()=>{l(!1),o.resetFields()},children:(0,r.jsxs)(B.Form,{form:o,onFinish:i,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(B.Form.Item,{label:"Budget ID",name:"budget_id",rules:[{required:!0,message:"Please input a human-friendly name for the budget"}],help:"A human-friendly name for the budget",children:(0,r.jsx)(y.TextInput,{placeholder:""})}),(0,r.jsx)(B.Form.Item,{label:"Max Tokens per minute",name:"tpm_limit",help:"Default is model limit.",children:(0,r.jsx)(_.InputNumber,{step:1,precision:2,width:200})}),(0,r.jsx)(B.Form.Item,{label:"Max Requests per minute",name:"rpm_limit",help:"Default is model limit.",children:(0,r.jsx)(_.InputNumber,{step:1,precision:2,width:200})}),(0,r.jsxs)(T.Accordion,{className:"mt-20 mb-8",children:[(0,r.jsx)(v.AccordionHeader,{children:(0,r.jsx)("b",{children:"Optional Settings"})}),(0,r.jsxs)(w.AccordionBody,{children:[(0,r.jsx)(B.Form.Item,{label:"Max Budget (USD)",name:"max_budget",children:(0,r.jsx)(_.InputNumber,{step:.01,precision:2,width:200})}),(0,r.jsx)(B.Form.Item,{className:"mt-8",label:"Reset Budget",name:"budget_duration",children:(0,r.jsxs)(P.Select,{defaultValue:null,placeholder:"n/a",children:[(0,r.jsx)(P.Select.Option,{value:"24h",children:"daily"}),(0,r.jsx)(P.Select.Option,{value:"7d",children:"weekly"}),(0,r.jsx)(P.Select.Option,{value:"30d",children:"monthly"})]})})]})]})]}),(0,r.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,r.jsx)(I.Button,{htmlType:"submit",children:"Create Budget"})})]})})},E=({isModalVisible:e,accessToken:t,setIsModalVisible:l,setBudgetList:a,existingBudget:o,handleUpdateCall:i})=>{console.log("existingBudget",o);let[n]=B.Form.useForm();(0,p.useEffect)(()=>{n.setFieldsValue(o)},[o,n]);let s=async e=>{if(null!=t&&void 0!=t)try{C.default.info("Making API Call"),l(!0);let r=await (0,k.budgetUpdateCall)(t,e);a(e=>e?[...e,r]:[r]),C.default.success("Budget Updated"),n.resetFields(),i()}catch(e){console.error("Error creating the key:",e),C.default.fromBackend(`Error creating the key: ${e}`)}};return(0,r.jsx)(N.Modal,{title:"Edit Budget",open:e,width:800,footer:null,onOk:()=>{l(!1),n.resetFields()},onCancel:()=>{l(!1),n.resetFields()},children:(0,r.jsxs)(B.Form,{form:n,onFinish:s,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",initialValues:o,children:[(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(B.Form.Item,{label:"Budget ID",name:"budget_id",rules:[{required:!0,message:"Please input a human-friendly name for the budget"}],help:"A human-friendly name for the budget",children:(0,r.jsx)(y.TextInput,{placeholder:""})}),(0,r.jsx)(B.Form.Item,{label:"Max Tokens per minute",name:"tpm_limit",help:"Default is model limit.",children:(0,r.jsx)(_.InputNumber,{step:1,precision:2,width:200})}),(0,r.jsx)(B.Form.Item,{label:"Max Requests per minute",name:"rpm_limit",help:"Default is model limit.",children:(0,r.jsx)(_.InputNumber,{step:1,precision:2,width:200})}),(0,r.jsxs)(T.Accordion,{className:"mt-20 mb-8",children:[(0,r.jsx)(v.AccordionHeader,{children:(0,r.jsx)("b",{children:"Optional Settings"})}),(0,r.jsxs)(w.AccordionBody,{children:[(0,r.jsx)(B.Form.Item,{label:"Max Budget (USD)",name:"max_budget",children:(0,r.jsx)(_.InputNumber,{step:.01,precision:2,width:200})}),(0,r.jsx)(B.Form.Item,{className:"mt-8",label:"Reset Budget",name:"budget_duration",children:(0,r.jsxs)(P.Select,{defaultValue:null,placeholder:"n/a",children:[(0,r.jsx)(P.Select.Option,{value:"24h",children:"daily"}),(0,r.jsx)(P.Select.Option,{value:"7d",children:"weekly"}),(0,r.jsx)(P.Select.Option,{value:"30d",children:"monthly"})]})})]})]})]}),(0,r.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,r.jsx)(I.Button,{htmlType:"submit",children:"Save"})})]})})},M=` +curl -X POST --location '/end_user/new' \\ + +-H 'Authorization: Bearer ' \\ + +-H 'Content-Type: application/json' \\ + +-d '{"user_id": "my-customer-id', "budget_id": ""}' # 👈 KEY CHANGE + +`,O=` +curl -X POST --location '/chat/completions' \\ + +-H 'Authorization: Bearer ' \\ + +-H 'Content-Type: application/json' \\ + +-d '{ + "model": "gpt-3.5-turbo', + "messages":[{"role": "user", "content": "Hey, how's it going?"}], + "user": "my-customer-id" +}' # 👈 KEY CHANGE + +`,F=`from openai import OpenAI +client = OpenAI( + base_url="", + api_key="" +) + +completion = client.chat.completions.create( + model="gpt-3.5-turbo", + messages=[ + {"role": "system", "content": "You are a helpful assistant."}, + {"role": "user", "content": "Hello!"} + ], + user="my-customer-id" +) + +print(completion.choices[0].message)`;e.s(["default",0,({accessToken:e})=>{let[y,T]=(0,p.useState)(!1),[v,w]=(0,p.useState)(!1),[I,N]=(0,p.useState)(null),[B,_]=(0,p.useState)([]),[P,S]=(0,p.useState)(!1),[D,R]=(0,p.useState)(!1);(0,p.useEffect)(()=>{e&&(0,k.getBudgetList)(e).then(e=>{_(e)})},[e]);let H=async r=>{null!=e&&(N(r),w(!0))},L=async()=>{if(I&&null!=e){S(!0);try{await (0,k.budgetDeleteCall)(e,I.budget_id),C.default.success("Budget deleted."),await U()}catch(e){console.error("Error deleting budget:",e),"function"==typeof C.default.fromBackend?C.default.fromBackend("Failed to delete budget"):C.default.info("Failed to delete budget")}finally{S(!1),R(!1),N(null)}}},U=async()=>{null!=e&&(0,k.getBudgetList)(e).then(e=>{_(e)})};return(0,r.jsxs)("div",{className:"w-full mx-auto flex-auto overflow-y-auto m-8 p-2",children:[(0,r.jsx)(t.Button,{size:"sm",variant:"primary",className:"mb-2",onClick:()=>T(!0),children:"+ Create Budget"}),(0,r.jsxs)(o.TabGroup,{children:[(0,r.jsxs)(m.TabList,{children:[(0,r.jsx)(a.Tab,{children:"Budgets"}),(0,r.jsx)(a.Tab,{children:"Examples"})]}),(0,r.jsxs)(h.TabPanels,{children:[(0,r.jsx)(g.TabPanel,{children:(0,r.jsxs)("div",{className:"mt-6",children:[(0,r.jsx)(A,{accessToken:e,isModalVisible:y,setIsModalVisible:T,setBudgetList:_}),I&&(0,r.jsx)(E,{accessToken:e,isModalVisible:v,setIsModalVisible:w,setBudgetList:_,existingBudget:I,handleUpdateCall:U}),(0,r.jsxs)(l.Card,{children:[(0,r.jsx)(b.Text,{children:"Create a budget to assign to customers."}),(0,r.jsxs)(i.Table,{children:[(0,r.jsx)(d.TableHead,{children:(0,r.jsxs)(u.TableRow,{children:[(0,r.jsx)(c.TableHeaderCell,{children:"Budget ID"}),(0,r.jsx)(c.TableHeaderCell,{children:"Max Budget"}),(0,r.jsx)(c.TableHeaderCell,{children:"TPM"}),(0,r.jsx)(c.TableHeaderCell,{children:"RPM"})]})}),(0,r.jsx)(n.TableBody,{children:B.slice().sort((e,r)=>new Date(r.updated_at).getTime()-new Date(e.updated_at).getTime()).map((e,t)=>(0,r.jsxs)(u.TableRow,{children:[(0,r.jsx)(s.TableCell,{children:e.budget_id}),(0,r.jsx)(s.TableCell,{children:e.max_budget?e.max_budget:"n/a"}),(0,r.jsx)(s.TableCell,{children:e.tpm_limit?e.tpm_limit:"n/a"}),(0,r.jsx)(s.TableCell,{children:e.rpm_limit?e.rpm_limit:"n/a"}),(0,r.jsx)(j.default,{variant:"Edit",tooltipText:"Edit budget",onClick:()=>H(e),dataTestId:"edit-budget-button"}),(0,r.jsx)(j.default,{variant:"Delete",tooltipText:"Delete budget",onClick:()=>{N(e),R(!0)},dataTestId:"delete-budget-button"})]},t))})]})]}),(0,r.jsx)(f.default,{isOpen:D,title:"Delete Budget?",message:"Are you sure you want to delete this budget? This action cannot be undone.",resourceInformationTitle:"Budget Information",resourceInformation:[{label:"Budget ID",value:I?.budget_id,code:!0},{label:"Max Budget",value:I?.max_budget},{label:"TPM",value:I?.tpm_limit},{label:"RPM",value:I?.rpm_limit}],onCancel:()=>{R(!1)},onOk:L,confirmLoading:P})]})}),(0,r.jsx)(g.TabPanel,{children:(0,r.jsxs)("div",{className:"mt-6",children:[(0,r.jsx)(b.Text,{className:"text-base",children:"How to use budget id"}),(0,r.jsxs)(o.TabGroup,{children:[(0,r.jsxs)(m.TabList,{children:[(0,r.jsx)(a.Tab,{children:"Assign Budget to Customer"}),(0,r.jsx)(a.Tab,{children:"Test it (Curl)"}),(0,r.jsx)(a.Tab,{children:"Test it (OpenAI SDK)"})]}),(0,r.jsxs)(h.TabPanels,{children:[(0,r.jsx)(g.TabPanel,{children:(0,r.jsx)(x.Prism,{language:"bash",children:M})}),(0,r.jsx)(g.TabPanel,{children:(0,r.jsx)(x.Prism,{language:"bash",children:O})}),(0,r.jsx)(g.TabPanel,{children:(0,r.jsx)(x.Prism,{language:"python",children:F})})]})]})]})})]})]})]})}],646050)},267167,e=>{"use strict";var r=e.i(843476),t=e.i(646050),l=e.i(135214);e.s(["default",0,()=>{let{accessToken:e}=(0,l.default)();return(0,r.jsx)(t.default,{accessToken:e})}])}]); \ No newline at end of file diff --git a/litellm/proxy/_experimental/out/_next/static/chunks/0d2b7ad3109bd883.js b/litellm/proxy/_experimental/out/_next/static/chunks/0d2b7ad3109bd883.js new file mode 100644 index 00000000000..acb1d237ecc --- /dev/null +++ b/litellm/proxy/_experimental/out/_next/static/chunks/0d2b7ad3109bd883.js @@ -0,0 +1,14 @@ +(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,91874,681216,e=>{"use strict";var t=e.i(931067),r=e.i(209428),a=e.i(211577),l=e.i(392221),o=e.i(703923),n=e.i(343794),i=e.i(914949),s=e.i(271645),d=["prefixCls","className","style","checked","disabled","defaultChecked","type","title","onChange"],c=(0,s.forwardRef)(function(e,c){var u=e.prefixCls,m=void 0===u?"rc-checkbox":u,g=e.className,f=e.style,b=e.checked,p=e.disabled,h=e.defaultChecked,C=e.type,v=void 0===C?"checkbox":C,k=e.title,x=e.onChange,w=(0,o.default)(e,d),$=(0,s.useRef)(null),y=(0,s.useRef)(null),N=(0,i.default)(void 0!==h&&h,{value:b}),O=(0,l.default)(N,2),E=O[0],j=O[1];(0,s.useImperativeHandle)(c,function(){return{focus:function(e){var t;null==(t=$.current)||t.focus(e)},blur:function(){var e;null==(e=$.current)||e.blur()},input:$.current,nativeElement:y.current}});var T=(0,n.default)(m,g,(0,a.default)((0,a.default)({},"".concat(m,"-checked"),E),"".concat(m,"-disabled"),p));return s.createElement("span",{className:T,title:k,style:f,ref:y},s.createElement("input",(0,t.default)({},w,{className:"".concat(m,"-input"),ref:$,onChange:function(t){p||("checked"in e||j(t.target.checked),null==x||x({target:(0,r.default)((0,r.default)({},e),{},{type:v,checked:t.target.checked}),stopPropagation:function(){t.stopPropagation()},preventDefault:function(){t.preventDefault()},nativeEvent:t.nativeEvent}))},disabled:p,checked:!!E,type:v})),s.createElement("span",{className:"".concat(m,"-inner")}))});e.s(["default",0,c],91874);var u=e.i(963188);function m(e){let t=s.default.useRef(null),r=()=>{u.default.cancel(t.current),t.current=null};return[()=>{r(),t.current=(0,u.default)(()=>{t.current=null})},a=>{t.current&&(a.stopPropagation(),r()),null==e||e(a)}]}e.s(["default",()=>m],681216)},374276,236836,e=>{"use strict";e.i(247167);var t=e.i(271645),r=e.i(343794),a=e.i(91874),l=e.i(611935),o=e.i(121872),n=e.i(26905),i=e.i(242064),s=e.i(937328),d=e.i(321883),c=e.i(62139);let u=t.default.createContext(null);e.i(296059);var m=e.i(915654),g=e.i(183293),f=e.i(246422),b=e.i(838378);function p(e,t){return(e=>{let{checkboxCls:t}=e,r=`${t}-wrapper`;return[{[`${t}-group`]:Object.assign(Object.assign({},(0,g.resetComponent)(e)),{display:"inline-flex",flexWrap:"wrap",columnGap:e.marginXS,[`> ${e.antCls}-row`]:{flex:1}}),[r]:Object.assign(Object.assign({},(0,g.resetComponent)(e)),{display:"inline-flex",alignItems:"baseline",cursor:"pointer","&:after":{display:"inline-block",width:0,overflow:"hidden",content:"'\\a0'"},[`& + ${r}`]:{marginInlineStart:0},[`&${r}-in-form-item`]:{'input[type="checkbox"]':{width:14,height:14}}}),[t]:Object.assign(Object.assign({},(0,g.resetComponent)(e)),{position:"relative",whiteSpace:"nowrap",lineHeight:1,cursor:"pointer",borderRadius:e.borderRadiusSM,alignSelf:"center",[`${t}-input`]:{position:"absolute",inset:0,zIndex:1,cursor:"pointer",opacity:0,margin:0,[`&:focus-visible + ${t}-inner`]:(0,g.genFocusOutline)(e)},[`${t}-inner`]:{boxSizing:"border-box",display:"block",width:e.checkboxSize,height:e.checkboxSize,direction:"ltr",backgroundColor:e.colorBgContainer,border:`${(0,m.unit)(e.lineWidth)} ${e.lineType} ${e.colorBorder}`,borderRadius:e.borderRadiusSM,borderCollapse:"separate",transition:`all ${e.motionDurationSlow}`,"&:after":{boxSizing:"border-box",position:"absolute",top:"50%",insetInlineStart:"25%",display:"table",width:e.calc(e.checkboxSize).div(14).mul(5).equal(),height:e.calc(e.checkboxSize).div(14).mul(8).equal(),border:`${(0,m.unit)(e.lineWidthBold)} solid ${e.colorWhite}`,borderTop:0,borderInlineStart:0,transform:"rotate(45deg) scale(0) translate(-50%,-50%)",opacity:0,content:'""',transition:`all ${e.motionDurationFast} ${e.motionEaseInBack}, opacity ${e.motionDurationFast}`}},"& + span":{paddingInlineStart:e.paddingXS,paddingInlineEnd:e.paddingXS}})},{[` + ${r}:not(${r}-disabled), + ${t}:not(${t}-disabled) + `]:{[`&:hover ${t}-inner`]:{borderColor:e.colorPrimary}},[`${r}:not(${r}-disabled)`]:{[`&:hover ${t}-checked:not(${t}-disabled) ${t}-inner`]:{backgroundColor:e.colorPrimaryHover,borderColor:"transparent"},[`&:hover ${t}-checked:not(${t}-disabled):after`]:{borderColor:e.colorPrimaryHover}}},{[`${t}-checked`]:{[`${t}-inner`]:{backgroundColor:e.colorPrimary,borderColor:e.colorPrimary,"&:after":{opacity:1,transform:"rotate(45deg) scale(1) translate(-50%,-50%)",transition:`all ${e.motionDurationMid} ${e.motionEaseOutBack} ${e.motionDurationFast}`}}},[` + ${r}-checked:not(${r}-disabled), + ${t}-checked:not(${t}-disabled) + `]:{[`&:hover ${t}-inner`]:{backgroundColor:e.colorPrimaryHover,borderColor:"transparent"}}},{[t]:{"&-indeterminate":{"&":{[`${t}-inner`]:{backgroundColor:`${e.colorBgContainer}`,borderColor:`${e.colorBorder}`,"&:after":{top:"50%",insetInlineStart:"50%",width:e.calc(e.fontSizeLG).div(2).equal(),height:e.calc(e.fontSizeLG).div(2).equal(),backgroundColor:e.colorPrimary,border:0,transform:"translate(-50%, -50%) scale(1)",opacity:1,content:'""'}},[`&:hover ${t}-inner`]:{backgroundColor:`${e.colorBgContainer}`,borderColor:`${e.colorPrimary}`}}}}},{[`${r}-disabled`]:{cursor:"not-allowed"},[`${t}-disabled`]:{[`&, ${t}-input`]:{cursor:"not-allowed",pointerEvents:"none"},[`${t}-inner`]:{background:e.colorBgContainerDisabled,borderColor:e.colorBorder,"&:after":{borderColor:e.colorTextDisabled}},"&:after":{display:"none"},"& + span":{color:e.colorTextDisabled},[`&${t}-indeterminate ${t}-inner::after`]:{background:e.colorTextDisabled}}}]})((0,b.mergeToken)(t,{checkboxCls:`.${e}`,checkboxSize:t.controlInteractiveSize}))}let h=(0,f.genStyleHooks)("Checkbox",(e,{prefixCls:t})=>[p(t,e)]);e.s(["default",0,h,"getStyle",()=>p],236836);var C=e.i(681216),v=function(e,t){var r={};for(var a in e)Object.prototype.hasOwnProperty.call(e,a)&&0>t.indexOf(a)&&(r[a]=e[a]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols)for(var l=0,a=Object.getOwnPropertySymbols(e);lt.indexOf(a[l])&&Object.prototype.propertyIsEnumerable.call(e,a[l])&&(r[a[l]]=e[a[l]]);return r};let k=t.forwardRef((e,m)=>{var g;let{prefixCls:f,className:b,rootClassName:p,children:k,indeterminate:x=!1,style:w,onMouseEnter:$,onMouseLeave:y,skipGroup:N=!1,disabled:O}=e,E=v(e,["prefixCls","className","rootClassName","children","indeterminate","style","onMouseEnter","onMouseLeave","skipGroup","disabled"]),{getPrefixCls:j,direction:T,checkbox:S}=t.useContext(i.ConfigContext),R=t.useContext(u),{isFormItemInput:M}=t.useContext(c.FormItemInputContext),P=t.useContext(s.default),z=null!=(g=(null==R?void 0:R.disabled)||O)?g:P,B=t.useRef(E.value),q=t.useRef(null),H=(0,l.composeRef)(m,q);t.useEffect(()=>{null==R||R.registerValue(E.value)},[]),t.useEffect(()=>{if(!N)return E.value!==B.current&&(null==R||R.cancelValue(B.current),null==R||R.registerValue(E.value),B.current=E.value),()=>null==R?void 0:R.cancelValue(E.value)},[E.value]),t.useEffect(()=>{var e;(null==(e=q.current)?void 0:e.input)&&(q.current.input.indeterminate=x)},[x]);let I=j("checkbox",f),L=(0,d.default)(I),[_,A,X]=h(I,L),D=Object.assign({},E);R&&!N&&(D.onChange=(...e)=>{E.onChange&&E.onChange.apply(E,e),R.toggleOption&&R.toggleOption({label:k,value:E.value})},D.name=R.name,D.checked=R.value.includes(E.value));let F=(0,r.default)(`${I}-wrapper`,{[`${I}-rtl`]:"rtl"===T,[`${I}-wrapper-checked`]:D.checked,[`${I}-wrapper-disabled`]:z,[`${I}-wrapper-in-form-item`]:M},null==S?void 0:S.className,b,p,X,L,A),W=(0,r.default)({[`${I}-indeterminate`]:x},n.TARGET_CLS,A),[Y,G]=(0,C.default)(D.onClick);return _(t.createElement(o.default,{component:"Checkbox",disabled:z},t.createElement("label",{className:F,style:Object.assign(Object.assign({},null==S?void 0:S.style),w),onMouseEnter:$,onMouseLeave:y,onClick:Y},t.createElement(a.default,Object.assign({},D,{onClick:G,prefixCls:I,className:W,disabled:z,ref:H})),null!=k&&t.createElement("span",{className:`${I}-label`},k))))});var x=e.i(8211),w=e.i(529681),$=function(e,t){var r={};for(var a in e)Object.prototype.hasOwnProperty.call(e,a)&&0>t.indexOf(a)&&(r[a]=e[a]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols)for(var l=0,a=Object.getOwnPropertySymbols(e);lt.indexOf(a[l])&&Object.prototype.propertyIsEnumerable.call(e,a[l])&&(r[a[l]]=e[a[l]]);return r};let y=t.forwardRef((e,a)=>{let{defaultValue:l,children:o,options:n=[],prefixCls:s,className:c,rootClassName:m,style:g,onChange:f}=e,b=$(e,["defaultValue","children","options","prefixCls","className","rootClassName","style","onChange"]),{getPrefixCls:p,direction:C}=t.useContext(i.ConfigContext),[v,y]=t.useState(b.value||l||[]),[N,O]=t.useState([]);t.useEffect(()=>{"value"in b&&y(b.value||[])},[b.value]);let E=t.useMemo(()=>n.map(e=>"string"==typeof e||"number"==typeof e?{label:e,value:e}:e),[n]),j=e=>{O(t=>t.filter(t=>t!==e))},T=e=>{O(t=>[].concat((0,x.default)(t),[e]))},S=e=>{let t=v.indexOf(e.value),r=(0,x.default)(v);-1===t?r.push(e.value):r.splice(t,1),"value"in b||y(r),null==f||f(r.filter(e=>N.includes(e)).sort((e,t)=>E.findIndex(t=>t.value===e)-E.findIndex(e=>e.value===t)))},R=p("checkbox",s),M=`${R}-group`,P=(0,d.default)(R),[z,B,q]=h(R,P),H=(0,w.default)(b,["value","disabled"]),I=n.length?E.map(e=>t.createElement(k,{prefixCls:R,key:e.value.toString(),disabled:"disabled"in e?e.disabled:b.disabled,value:e.value,checked:v.includes(e.value),onChange:e.onChange,className:(0,r.default)(`${M}-item`,e.className),style:e.style,title:e.title,id:e.id,required:e.required},e.label)):o,L=t.useMemo(()=>({toggleOption:S,value:v,disabled:b.disabled,name:b.name,registerValue:T,cancelValue:j}),[S,v,b.disabled,b.name,T,j]),_=(0,r.default)(M,{[`${M}-rtl`]:"rtl"===C},c,m,q,P,B);return z(t.createElement("div",Object.assign({className:_,style:g},H,{ref:a}),t.createElement(u.Provider,{value:L},I)))});k.Group=y,k.__ANT_CHECKBOX=!0,e.s(["default",0,k],374276)},536916,e=>{"use strict";var t=e.i(374276);e.s(["Checkbox",()=>t.default])},599724,936325,e=>{"use strict";var t=e.i(95779),r=e.i(444755),a=e.i(673706),l=e.i(271645);let o=l.default.forwardRef((e,o)=>{let{color:n,className:i,children:s}=e;return l.default.createElement("p",{ref:o,className:(0,r.tremorTwMerge)("text-tremor-default",n?(0,a.getColorClassNames)(n,t.colorPalette.text).textColor:(0,r.tremorTwMerge)("text-tremor-content","dark:text-dark-tremor-content"),i)},s)});o.displayName="Text",e.s(["default",()=>o],936325),e.s(["Text",()=>o],599724)},994388,e=>{"use strict";var t=e.i(290571),r=e.i(829087),a=e.i(271645);let l=["preEnter","entering","entered","preExit","exiting","exited","unmounted"],o=e=>({_s:e,status:l[e],isEnter:e<3,isMounted:6!==e,isResolved:2===e||e>4}),n=e=>e?6:5,i=(e,t,r,a,l)=>{clearTimeout(a.current);let n=o(e);t(n),r.current=n,l&&l({current:n})};var s=e.i(480731),d=e.i(444755),c=e.i(673706);let u=e=>{var r=(0,t.__rest)(e,[]);return a.default.createElement("svg",Object.assign({},r,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor"}),a.default.createElement("path",{fill:"none",d:"M0 0h24v24H0z"}),a.default.createElement("path",{d:"M18.364 5.636L16.95 7.05A7 7 0 1 0 19 12h2a9 9 0 1 1-2.636-6.364z"}))};var m=e.i(95779);let g={xs:{height:"h-4",width:"w-4"},sm:{height:"h-5",width:"w-5"},md:{height:"h-5",width:"w-5"},lg:{height:"h-6",width:"w-6"},xl:{height:"h-6",width:"w-6"}},f=(e,t)=>{switch(e){case"primary":return{textColor:t?(0,c.getColorClassNames)("white").textColor:"text-tremor-brand-inverted dark:text-dark-tremor-brand-inverted",hoverTextColor:t?(0,c.getColorClassNames)("white").textColor:"text-tremor-brand-inverted dark:text-dark-tremor-brand-inverted",bgColor:t?(0,c.getColorClassNames)(t,m.colorPalette.background).bgColor:"bg-tremor-brand dark:bg-dark-tremor-brand",hoverBgColor:t?(0,c.getColorClassNames)(t,m.colorPalette.darkBackground).hoverBgColor:"hover:bg-tremor-brand-emphasis dark:hover:bg-dark-tremor-brand-emphasis",borderColor:t?(0,c.getColorClassNames)(t,m.colorPalette.border).borderColor:"border-tremor-brand dark:border-dark-tremor-brand",hoverBorderColor:t?(0,c.getColorClassNames)(t,m.colorPalette.darkBorder).hoverBorderColor:"hover:border-tremor-brand-emphasis dark:hover:border-dark-tremor-brand-emphasis"};case"secondary":return{textColor:t?(0,c.getColorClassNames)(t,m.colorPalette.text).textColor:"text-tremor-brand dark:text-dark-tremor-brand",hoverTextColor:t?(0,c.getColorClassNames)(t,m.colorPalette.text).textColor:"hover:text-tremor-brand-emphasis dark:hover:text-dark-tremor-brand-emphasis",bgColor:(0,c.getColorClassNames)("transparent").bgColor,hoverBgColor:t?(0,d.tremorTwMerge)((0,c.getColorClassNames)(t,m.colorPalette.background).hoverBgColor,"hover:bg-opacity-20 dark:hover:bg-opacity-20"):"hover:bg-tremor-brand-faint dark:hover:bg-dark-tremor-brand-faint",borderColor:t?(0,c.getColorClassNames)(t,m.colorPalette.border).borderColor:"border-tremor-brand dark:border-dark-tremor-brand"};case"light":return{textColor:t?(0,c.getColorClassNames)(t,m.colorPalette.text).textColor:"text-tremor-brand dark:text-dark-tremor-brand",hoverTextColor:t?(0,c.getColorClassNames)(t,m.colorPalette.darkText).hoverTextColor:"hover:text-tremor-brand-emphasis dark:hover:text-dark-tremor-brand-emphasis",bgColor:(0,c.getColorClassNames)("transparent").bgColor,borderColor:"",hoverBorderColor:""}}},b=(0,c.makeClassName)("Button"),p=({loading:e,iconSize:t,iconPosition:r,Icon:l,needMargin:o,transitionStatus:n})=>{let i=o?r===s.HorizontalPositions.Left?(0,d.tremorTwMerge)("-ml-1","mr-1.5"):(0,d.tremorTwMerge)("-mr-1","ml-1.5"):"",c=(0,d.tremorTwMerge)("w-0 h-0"),m={default:c,entering:c,entered:t,exiting:t,exited:c};return e?a.default.createElement(u,{className:(0,d.tremorTwMerge)(b("icon"),"animate-spin shrink-0",i,m.default,m[n]),style:{transition:"width 150ms"}}):a.default.createElement(l,{className:(0,d.tremorTwMerge)(b("icon"),"shrink-0",t,i)})},h=a.default.forwardRef((e,l)=>{let{icon:u,iconPosition:m=s.HorizontalPositions.Left,size:h=s.Sizes.SM,color:C,variant:v="primary",disabled:k,loading:x=!1,loadingText:w,children:$,tooltip:y,className:N}=e,O=(0,t.__rest)(e,["icon","iconPosition","size","color","variant","disabled","loading","loadingText","children","tooltip","className"]),E=x||k,j=void 0!==u||x,T=x&&w,S=!(!$&&!T),R=(0,d.tremorTwMerge)(g[h].height,g[h].width),M="light"!==v?(0,d.tremorTwMerge)("rounded-tremor-default border","shadow-tremor-input","dark:shadow-dark-tremor-input"):"",P=f(v,C),z=("light"!==v?{xs:{paddingX:"px-2.5",paddingY:"py-1.5",fontSize:"text-xs"},sm:{paddingX:"px-4",paddingY:"py-2",fontSize:"text-sm"},md:{paddingX:"px-4",paddingY:"py-2",fontSize:"text-md"},lg:{paddingX:"px-4",paddingY:"py-2.5",fontSize:"text-lg"},xl:{paddingX:"px-4",paddingY:"py-3",fontSize:"text-xl"}}:{xs:{paddingX:"",paddingY:"",fontSize:"text-xs"},sm:{paddingX:"",paddingY:"",fontSize:"text-sm"},md:{paddingX:"",paddingY:"",fontSize:"text-md"},lg:{paddingX:"",paddingY:"",fontSize:"text-lg"},xl:{paddingX:"",paddingY:"",fontSize:"text-xl"}})[h],{tooltipProps:B,getReferenceProps:q}=(0,r.useTooltip)(300),[H,I]=(({enter:e=!0,exit:t=!0,preEnter:r,preExit:l,timeout:s,initialEntered:d,mountOnEnter:c,unmountOnExit:u,onStateChange:m}={})=>{let[g,f]=(0,a.useState)(()=>o(d?2:n(c))),b=(0,a.useRef)(g),p=(0,a.useRef)(0),[h,C]="object"==typeof s?[s.enter,s.exit]:[s,s],v=(0,a.useCallback)(()=>{let e=((e,t)=>{switch(e){case 1:case 0:return 2;case 4:case 3:return n(t)}})(b.current._s,u);e&&i(e,f,b,p,m)},[m,u]);return[g,(0,a.useCallback)(a=>{let o=e=>{switch(i(e,f,b,p,m),e){case 1:h>=0&&(p.current=((...e)=>setTimeout(...e))(v,h));break;case 4:C>=0&&(p.current=((...e)=>setTimeout(...e))(v,C));break;case 0:case 3:p.current=((...e)=>setTimeout(...e))(()=>{isNaN(document.body.offsetTop)||o(e+1)},0)}},s=b.current.isEnter;"boolean"!=typeof a&&(a=!s),a?s||o(e?+!r:2):s&&o(t?l?3:4:n(u))},[v,m,e,t,r,l,h,C,u]),v]})({timeout:50});return(0,a.useEffect)(()=>{I(x)},[x]),a.default.createElement("button",Object.assign({ref:(0,c.mergeRefs)([l,B.refs.setReference]),className:(0,d.tremorTwMerge)(b("root"),"shrink-0 inline-flex justify-center items-center group font-medium outline-none",M,z.paddingX,z.paddingY,z.fontSize,P.textColor,P.bgColor,P.borderColor,P.hoverBorderColor,E?"opacity-50 cursor-not-allowed":(0,d.tremorTwMerge)(f(v,C).hoverTextColor,f(v,C).hoverBgColor,f(v,C).hoverBorderColor),N),disabled:E},q,O),a.default.createElement(r.default,Object.assign({text:y},B)),j&&m!==s.HorizontalPositions.Right?a.default.createElement(p,{loading:x,iconSize:R,iconPosition:m,Icon:u,transitionStatus:H.status,needMargin:S}):null,T||$?a.default.createElement("span",{className:(0,d.tremorTwMerge)(b("text"),"text-tremor-default whitespace-nowrap")},T?w:$):null,j&&m===s.HorizontalPositions.Right?a.default.createElement(p,{loading:x,iconSize:R,iconPosition:m,Icon:u,transitionStatus:H.status,needMargin:S}):null)});h.displayName="Button",e.s(["Button",()=>h],994388)},304967,e=>{"use strict";var t=e.i(290571),r=e.i(271645),a=e.i(480731),l=e.i(95779),o=e.i(444755),n=e.i(673706);let i=(0,n.makeClassName)("Card"),s=r.default.forwardRef((e,s)=>{let{decoration:d="",decorationColor:c,children:u,className:m}=e,g=(0,t.__rest)(e,["decoration","decorationColor","children","className"]);return r.default.createElement("div",Object.assign({ref:s,className:(0,o.tremorTwMerge)(i("root"),"relative w-full text-left ring-1 rounded-tremor-default p-6","bg-tremor-background ring-tremor-ring shadow-tremor-card","dark:bg-dark-tremor-background dark:ring-dark-tremor-ring dark:shadow-dark-tremor-card",c?(0,n.getColorClassNames)(c,l.colorPalette.border).borderColor:"border-tremor-brand dark:border-dark-tremor-brand",(e=>{if(!e)return"";switch(e){case a.HorizontalPositions.Left:return"border-l-4";case a.VerticalPositions.Top:return"border-t-4";case a.HorizontalPositions.Right:return"border-r-4";case a.VerticalPositions.Bottom:return"border-b-4";default:return""}})(d),m)},g),u)});s.displayName="Card",e.s(["Card",()=>s],304967)},185793,e=>{"use strict";e.i(247167);var t=e.i(271645),r=e.i(343794),a=e.i(242064),l=e.i(529681);let o=e=>{let{prefixCls:a,className:l,style:o,size:n,shape:i}=e,s=(0,r.default)({[`${a}-lg`]:"large"===n,[`${a}-sm`]:"small"===n}),d=(0,r.default)({[`${a}-circle`]:"circle"===i,[`${a}-square`]:"square"===i,[`${a}-round`]:"round"===i}),c=t.useMemo(()=>"number"==typeof n?{width:n,height:n,lineHeight:`${n}px`}:{},[n]);return t.createElement("span",{className:(0,r.default)(a,s,d,l),style:Object.assign(Object.assign({},c),o)})};e.i(296059);var n=e.i(694758),i=e.i(915654),s=e.i(246422),d=e.i(838378);let c=new n.Keyframes("ant-skeleton-loading",{"0%":{backgroundPosition:"100% 50%"},"100%":{backgroundPosition:"0 50%"}}),u=e=>({height:e,lineHeight:(0,i.unit)(e)}),m=e=>Object.assign({width:e},u(e)),g=(e,t)=>Object.assign({width:t(e).mul(5).equal(),minWidth:t(e).mul(5).equal()},u(e)),f=e=>Object.assign({width:e},u(e)),b=(e,t,r)=>{let{skeletonButtonCls:a}=e;return{[`${r}${a}-circle`]:{width:t,minWidth:t,borderRadius:"50%"},[`${r}${a}-round`]:{borderRadius:t}}},p=(e,t)=>Object.assign({width:t(e).mul(2).equal(),minWidth:t(e).mul(2).equal()},u(e)),h=(0,s.genStyleHooks)("Skeleton",e=>{let{componentCls:t,calc:r}=e;return(e=>{let{componentCls:t,skeletonAvatarCls:r,skeletonTitleCls:a,skeletonParagraphCls:l,skeletonButtonCls:o,skeletonInputCls:n,skeletonImageCls:i,controlHeight:s,controlHeightLG:d,controlHeightSM:u,gradientFromColor:h,padding:C,marginSM:v,borderRadius:k,titleHeight:x,blockRadius:w,paragraphLiHeight:$,controlHeightXS:y,paragraphMarginTop:N}=e;return{[t]:{display:"table",width:"100%",[`${t}-header`]:{display:"table-cell",paddingInlineEnd:C,verticalAlign:"top",[r]:Object.assign({display:"inline-block",verticalAlign:"top",background:h},m(s)),[`${r}-circle`]:{borderRadius:"50%"},[`${r}-lg`]:Object.assign({},m(d)),[`${r}-sm`]:Object.assign({},m(u))},[`${t}-content`]:{display:"table-cell",width:"100%",verticalAlign:"top",[a]:{width:"100%",height:x,background:h,borderRadius:w,[`+ ${l}`]:{marginBlockStart:u}},[l]:{padding:0,"> li":{width:"100%",height:$,listStyle:"none",background:h,borderRadius:w,"+ li":{marginBlockStart:y}}},[`${l}> li:last-child:not(:first-child):not(:nth-child(2))`]:{width:"61%"}},[`&-round ${t}-content`]:{[`${a}, ${l} > li`]:{borderRadius:k}}},[`${t}-with-avatar ${t}-content`]:{[a]:{marginBlockStart:v,[`+ ${l}`]:{marginBlockStart:N}}},[`${t}${t}-element`]:Object.assign(Object.assign(Object.assign(Object.assign({display:"inline-block",width:"auto"},(e=>{let{borderRadiusSM:t,skeletonButtonCls:r,controlHeight:a,controlHeightLG:l,controlHeightSM:o,gradientFromColor:n,calc:i}=e;return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({[r]:Object.assign({display:"inline-block",verticalAlign:"top",background:n,borderRadius:t,width:i(a).mul(2).equal(),minWidth:i(a).mul(2).equal()},p(a,i))},b(e,a,r)),{[`${r}-lg`]:Object.assign({},p(l,i))}),b(e,l,`${r}-lg`)),{[`${r}-sm`]:Object.assign({},p(o,i))}),b(e,o,`${r}-sm`))})(e)),(e=>{let{skeletonAvatarCls:t,gradientFromColor:r,controlHeight:a,controlHeightLG:l,controlHeightSM:o}=e;return{[t]:Object.assign({display:"inline-block",verticalAlign:"top",background:r},m(a)),[`${t}${t}-circle`]:{borderRadius:"50%"},[`${t}${t}-lg`]:Object.assign({},m(l)),[`${t}${t}-sm`]:Object.assign({},m(o))}})(e)),(e=>{let{controlHeight:t,borderRadiusSM:r,skeletonInputCls:a,controlHeightLG:l,controlHeightSM:o,gradientFromColor:n,calc:i}=e;return{[a]:Object.assign({display:"inline-block",verticalAlign:"top",background:n,borderRadius:r},g(t,i)),[`${a}-lg`]:Object.assign({},g(l,i)),[`${a}-sm`]:Object.assign({},g(o,i))}})(e)),(e=>{let{skeletonImageCls:t,imageSizeBase:r,gradientFromColor:a,borderRadiusSM:l,calc:o}=e;return{[t]:Object.assign(Object.assign({display:"inline-flex",alignItems:"center",justifyContent:"center",verticalAlign:"middle",background:a,borderRadius:l},f(o(r).mul(2).equal())),{[`${t}-path`]:{fill:"#bfbfbf"},[`${t}-svg`]:Object.assign(Object.assign({},f(r)),{maxWidth:o(r).mul(4).equal(),maxHeight:o(r).mul(4).equal()}),[`${t}-svg${t}-svg-circle`]:{borderRadius:"50%"}}),[`${t}${t}-circle`]:{borderRadius:"50%"}}})(e)),[`${t}${t}-block`]:{width:"100%",[o]:{width:"100%"},[n]:{width:"100%"}},[`${t}${t}-active`]:{[` + ${a}, + ${l} > li, + ${r}, + ${o}, + ${n}, + ${i} + `]:Object.assign({},{background:e.skeletonLoadingBackground,backgroundSize:"400% 100%",animationName:c,animationDuration:e.skeletonLoadingMotionDuration,animationTimingFunction:"ease",animationIterationCount:"infinite"})}}})((0,d.mergeToken)(e,{skeletonAvatarCls:`${t}-avatar`,skeletonTitleCls:`${t}-title`,skeletonParagraphCls:`${t}-paragraph`,skeletonButtonCls:`${t}-button`,skeletonInputCls:`${t}-input`,skeletonImageCls:`${t}-image`,imageSizeBase:r(e.controlHeight).mul(1.5).equal(),borderRadius:100,skeletonLoadingBackground:`linear-gradient(90deg, ${e.gradientFromColor} 25%, ${e.gradientToColor} 37%, ${e.gradientFromColor} 63%)`,skeletonLoadingMotionDuration:"1.4s"}))},e=>{let{colorFillContent:t,colorFill:r}=e;return{color:t,colorGradientEnd:r,gradientFromColor:t,gradientToColor:r,titleHeight:e.controlHeight/2,blockRadius:e.borderRadiusSM,paragraphMarginTop:e.marginLG+e.marginXXS,paragraphLiHeight:e.controlHeight/2}},{deprecatedTokens:[["color","gradientFromColor"],["colorGradientEnd","gradientToColor"]]}),C=e=>{let{prefixCls:a,className:l,style:o,rows:n=0}=e,i=Array.from({length:n}).map((r,a)=>t.createElement("li",{key:a,style:{width:((e,t)=>{let{width:r,rows:a=2}=t;return Array.isArray(r)?r[e]:a-1===e?r:void 0})(a,e)}}));return t.createElement("ul",{className:(0,r.default)(a,l),style:o},i)},v=({prefixCls:e,className:a,width:l,style:o})=>t.createElement("h3",{className:(0,r.default)(e,a),style:Object.assign({width:l},o)});function k(e){return e&&"object"==typeof e?e:{}}let x=e=>{let{prefixCls:l,loading:n,className:i,rootClassName:s,style:d,children:c,avatar:u=!1,title:m=!0,paragraph:g=!0,active:f,round:b}=e,{getPrefixCls:p,direction:x,className:w,style:$}=(0,a.useComponentConfig)("skeleton"),y=p("skeleton",l),[N,O,E]=h(y);if(n||!("loading"in e)){let e,a,l=!!u,n=!!m,c=!!g;if(l){let r=Object.assign(Object.assign({prefixCls:`${y}-avatar`},n&&!c?{size:"large",shape:"square"}:{size:"large",shape:"circle"}),k(u));e=t.createElement("div",{className:`${y}-header`},t.createElement(o,Object.assign({},r)))}if(n||c){let e,r;if(n){let r=Object.assign(Object.assign({prefixCls:`${y}-title`},!l&&c?{width:"38%"}:l&&c?{width:"50%"}:{}),k(m));e=t.createElement(v,Object.assign({},r))}if(c){let e,a=Object.assign(Object.assign({prefixCls:`${y}-paragraph`},(e={},l&&n||(e.width="61%"),!l&&n?e.rows=3:e.rows=2,e)),k(g));r=t.createElement(C,Object.assign({},a))}a=t.createElement("div",{className:`${y}-content`},e,r)}let p=(0,r.default)(y,{[`${y}-with-avatar`]:l,[`${y}-active`]:f,[`${y}-rtl`]:"rtl"===x,[`${y}-round`]:b},w,i,s,O,E);return N(t.createElement("div",{className:p,style:Object.assign(Object.assign({},$),d)},e,a))}return null!=c?c:null};x.Button=e=>{let{prefixCls:n,className:i,rootClassName:s,active:d,block:c=!1,size:u="default"}=e,{getPrefixCls:m}=t.useContext(a.ConfigContext),g=m("skeleton",n),[f,b,p]=h(g),C=(0,l.default)(e,["prefixCls"]),v=(0,r.default)(g,`${g}-element`,{[`${g}-active`]:d,[`${g}-block`]:c},i,s,b,p);return f(t.createElement("div",{className:v},t.createElement(o,Object.assign({prefixCls:`${g}-button`,size:u},C))))},x.Avatar=e=>{let{prefixCls:n,className:i,rootClassName:s,active:d,shape:c="circle",size:u="default"}=e,{getPrefixCls:m}=t.useContext(a.ConfigContext),g=m("skeleton",n),[f,b,p]=h(g),C=(0,l.default)(e,["prefixCls","className"]),v=(0,r.default)(g,`${g}-element`,{[`${g}-active`]:d},i,s,b,p);return f(t.createElement("div",{className:v},t.createElement(o,Object.assign({prefixCls:`${g}-avatar`,shape:c,size:u},C))))},x.Input=e=>{let{prefixCls:n,className:i,rootClassName:s,active:d,block:c,size:u="default"}=e,{getPrefixCls:m}=t.useContext(a.ConfigContext),g=m("skeleton",n),[f,b,p]=h(g),C=(0,l.default)(e,["prefixCls"]),v=(0,r.default)(g,`${g}-element`,{[`${g}-active`]:d,[`${g}-block`]:c},i,s,b,p);return f(t.createElement("div",{className:v},t.createElement(o,Object.assign({prefixCls:`${g}-input`,size:u},C))))},x.Image=e=>{let{prefixCls:l,className:o,rootClassName:n,style:i,active:s}=e,{getPrefixCls:d}=t.useContext(a.ConfigContext),c=d("skeleton",l),[u,m,g]=h(c),f=(0,r.default)(c,`${c}-element`,{[`${c}-active`]:s},o,n,m,g);return u(t.createElement("div",{className:f},t.createElement("div",{className:(0,r.default)(`${c}-image`,o),style:i},t.createElement("svg",{viewBox:"0 0 1098 1024",xmlns:"http://www.w3.org/2000/svg",className:`${c}-image-svg`},t.createElement("title",null,"Image placeholder"),t.createElement("path",{d:"M365.714286 329.142857q0 45.714286-32.036571 77.677714t-77.677714 32.036571-77.677714-32.036571-32.036571-77.677714 32.036571-77.677714 77.677714-32.036571 77.677714 32.036571 32.036571 77.677714zM950.857143 548.571429l0 256-804.571429 0 0-109.714286 182.857143-182.857143 91.428571 91.428571 292.571429-292.571429zM1005.714286 146.285714l-914.285714 0q-7.460571 0-12.873143 5.412571t-5.412571 12.873143l0 694.857143q0 7.460571 5.412571 12.873143t12.873143 5.412571l914.285714 0q7.460571 0 12.873143-5.412571t5.412571-12.873143l0-694.857143q0-7.460571-5.412571-12.873143t-12.873143-5.412571zM1097.142857 164.571429l0 694.857143q0 37.741714-26.843429 64.585143t-64.585143 26.843429l-914.285714 0q-37.741714 0-64.585143-26.843429t-26.843429-64.585143l0-694.857143q0-37.741714 26.843429-64.585143t64.585143-26.843429l914.285714 0q37.741714 0 64.585143 26.843429t26.843429 64.585143z",className:`${c}-image-path`})))))},x.Node=e=>{let{prefixCls:l,className:o,rootClassName:n,style:i,active:s,children:d}=e,{getPrefixCls:c}=t.useContext(a.ConfigContext),u=c("skeleton",l),[m,g,f]=h(u),b=(0,r.default)(u,`${u}-element`,{[`${u}-active`]:s},g,o,n,f);return m(t.createElement("div",{className:b},t.createElement("div",{className:(0,r.default)(`${u}-image`,o),style:i},d)))},e.s(["default",0,x],185793)},959013,e=>{"use strict";e.i(247167);var t=e.i(931067),r=e.i(271645);let a={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M482 152h60q8 0 8 8v704q0 8-8 8h-60q-8 0-8-8V160q0-8 8-8z"}},{tag:"path",attrs:{d:"M192 474h672q8 0 8 8v60q0 8-8 8H160q-8 0-8-8v-60q0-8 8-8z"}}]},name:"plus",theme:"outlined"};var l=e.i(9583),o=r.forwardRef(function(e,o){return r.createElement(l.default,(0,t.default)({},e,{ref:o,icon:a}))});e.s(["default",0,o],959013)},269200,e=>{"use strict";var t=e.i(290571),r=e.i(271645),a=e.i(444755);let l=(0,e.i(673706).makeClassName)("Table"),o=r.default.forwardRef((e,o)=>{let{children:n,className:i}=e,s=(0,t.__rest)(e,["children","className"]);return r.default.createElement("div",{className:(0,a.tremorTwMerge)(l("root"),"overflow-auto",i)},r.default.createElement("table",Object.assign({ref:o,className:(0,a.tremorTwMerge)(l("table"),"w-full text-tremor-default","text-tremor-content","dark:text-dark-tremor-content")},s),n))});o.displayName="Table",e.s(["Table",()=>o],269200)},942232,e=>{"use strict";var t=e.i(290571),r=e.i(271645),a=e.i(444755);let l=(0,e.i(673706).makeClassName)("TableBody"),o=r.default.forwardRef((e,o)=>{let{children:n,className:i}=e,s=(0,t.__rest)(e,["children","className"]);return r.default.createElement(r.default.Fragment,null,r.default.createElement("tbody",Object.assign({ref:o,className:(0,a.tremorTwMerge)(l("root"),"align-top divide-y","divide-tremor-border","dark:divide-dark-tremor-border",i)},s),n))});o.displayName="TableBody",e.s(["TableBody",()=>o],942232)},977572,e=>{"use strict";var t=e.i(290571),r=e.i(271645),a=e.i(444755);let l=(0,e.i(673706).makeClassName)("TableCell"),o=r.default.forwardRef((e,o)=>{let{children:n,className:i}=e,s=(0,t.__rest)(e,["children","className"]);return r.default.createElement(r.default.Fragment,null,r.default.createElement("td",Object.assign({ref:o,className:(0,a.tremorTwMerge)(l("root"),"align-middle whitespace-nowrap text-left p-4",i)},s),n))});o.displayName="TableCell",e.s(["TableCell",()=>o],977572)},427612,e=>{"use strict";var t=e.i(290571),r=e.i(271645),a=e.i(444755);let l=(0,e.i(673706).makeClassName)("TableHead"),o=r.default.forwardRef((e,o)=>{let{children:n,className:i}=e,s=(0,t.__rest)(e,["children","className"]);return r.default.createElement(r.default.Fragment,null,r.default.createElement("thead",Object.assign({ref:o,className:(0,a.tremorTwMerge)(l("root"),"text-left","text-tremor-content","dark:text-dark-tremor-content",i)},s),n))});o.displayName="TableHead",e.s(["TableHead",()=>o],427612)},64848,e=>{"use strict";var t=e.i(290571),r=e.i(271645),a=e.i(444755);let l=(0,e.i(673706).makeClassName)("TableHeaderCell"),o=r.default.forwardRef((e,o)=>{let{children:n,className:i}=e,s=(0,t.__rest)(e,["children","className"]);return r.default.createElement(r.default.Fragment,null,r.default.createElement("th",Object.assign({ref:o,className:(0,a.tremorTwMerge)(l("root"),"whitespace-nowrap text-left font-semibold top-0 px-4 py-3.5","text-tremor-content-strong","dark:text-dark-tremor-content-strong",i)},s),n))});o.displayName="TableHeaderCell",e.s(["TableHeaderCell",()=>o],64848)},496020,e=>{"use strict";var t=e.i(290571),r=e.i(271645),a=e.i(444755);let l=(0,e.i(673706).makeClassName)("TableRow"),o=r.default.forwardRef((e,o)=>{let{children:n,className:i}=e,s=(0,t.__rest)(e,["children","className"]);return r.default.createElement(r.default.Fragment,null,r.default.createElement("tr",Object.assign({ref:o,className:(0,a.tremorTwMerge)(l("row"),i)},s),n))});o.displayName="TableRow",e.s(["TableRow",()=>o],496020)},68155,e=>{"use strict";var t=e.i(271645);let r=t.forwardRef(function(e,r){return t.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:2,stroke:"currentColor","aria-hidden":"true",ref:r},e),t.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16"}))});e.s(["TrashIcon",0,r],68155)},360820,e=>{"use strict";var t=e.i(271645);let r=t.forwardRef(function(e,r){return t.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:2,stroke:"currentColor","aria-hidden":"true",ref:r},e),t.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 15l7-7 7 7"}))});e.s(["ChevronUpIcon",0,r],360820)},871943,e=>{"use strict";var t=e.i(271645);let r=t.forwardRef(function(e,r){return t.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:2,stroke:"currentColor","aria-hidden":"true",ref:r},e),t.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19 9l-7 7-7-7"}))});e.s(["ChevronDownIcon",0,r],871943)},278587,e=>{"use strict";var t=e.i(271645);let r=t.forwardRef(function(e,r){return t.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:2,stroke:"currentColor","aria-hidden":"true",ref:r},e),t.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"}))});e.s(["RefreshIcon",0,r],278587)}]); \ No newline at end of file diff --git a/litellm/proxy/_experimental/out/_next/static/chunks/0f3785dff6cc02a9.js b/litellm/proxy/_experimental/out/_next/static/chunks/0f3785dff6cc02a9.js new file mode 100644 index 00000000000..bde1e6603b9 --- /dev/null +++ b/litellm/proxy/_experimental/out/_next/static/chunks/0f3785dff6cc02a9.js @@ -0,0 +1 @@ +(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,757440,e=>{"use strict";var t=e.i(290571),r=e.i(271645);let a=e=>{var a=(0,t.__rest)(e,[]);return r.default.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor"},a),r.default.createElement("path",{d:"M11.9999 13.1714L16.9497 8.22168L18.3639 9.63589L11.9999 15.9999L5.63599 9.63589L7.0502 8.22168L11.9999 13.1714Z"}))};e.s(["default",()=>a])},446428,854056,e=>{"use strict";let t;var r=e.i(290571),a=e.i(271645);let n=e=>{var t=(0,r.__rest)(e,[]);return a.default.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor"},t),a.default.createElement("path",{d:"M12 22C6.47715 22 2 17.5228 2 12C2 6.47715 6.47715 2 12 2C17.5228 2 22 6.47715 22 12C22 17.5228 17.5228 22 12 22ZM12 10.5858L9.17157 7.75736L7.75736 9.17157L10.5858 12L7.75736 14.8284L9.17157 16.2426L12 13.4142L14.8284 16.2426L16.2426 14.8284L13.4142 12L16.2426 9.17157L14.8284 7.75736L12 10.5858Z"}))};e.s(["default",()=>n],446428);var l=e.i(746725),o=e.i(914189),s=e.i(553521),i=e.i(835696),c=e.i(941444),u=e.i(178677),d=e.i(294316),m=e.i(83733),f=e.i(233137),b=e.i(732607),g=e.i(397701),p=e.i(700020);function h(e){var t;return!!(e.enter||e.enterFrom||e.enterTo||e.leave||e.leaveFrom||e.leaveTo)||(null!=(t=e.as)?t:C)!==a.Fragment||1===a.default.Children.count(e.children)}let v=(0,a.createContext)(null);v.displayName="TransitionContext";var x=((t=x||{}).Visible="visible",t.Hidden="hidden",t);let y=(0,a.createContext)(null);function w(e){return"children"in e?w(e.children):e.current.filter(({el:e})=>null!==e.current).filter(({state:e})=>"visible"===e).length>0}function N(e,t){let r=(0,c.useLatestValue)(e),n=(0,a.useRef)([]),i=(0,s.useIsMounted)(),u=(0,l.useDisposables)(),d=(0,o.useEvent)((e,t=p.RenderStrategy.Hidden)=>{let a=n.current.findIndex(({el:t})=>t===e);-1!==a&&((0,g.match)(t,{[p.RenderStrategy.Unmount](){n.current.splice(a,1)},[p.RenderStrategy.Hidden](){n.current[a].state="hidden"}}),u.microTask(()=>{var e;!w(n)&&i.current&&(null==(e=r.current)||e.call(r))}))}),m=(0,o.useEvent)(e=>{let t=n.current.find(({el:t})=>t===e);return t?"visible"!==t.state&&(t.state="visible"):n.current.push({el:e,state:"visible"}),()=>d(e,p.RenderStrategy.Unmount)}),f=(0,a.useRef)([]),b=(0,a.useRef)(Promise.resolve()),h=(0,a.useRef)({enter:[],leave:[]}),v=(0,o.useEvent)((e,r,a)=>{f.current.splice(0),t&&(t.chains.current[r]=t.chains.current[r].filter(([t])=>t!==e)),null==t||t.chains.current[r].push([e,new Promise(e=>{f.current.push(e)})]),null==t||t.chains.current[r].push([e,new Promise(e=>{Promise.all(h.current[r].map(([e,t])=>t)).then(()=>e())})]),"enter"===r?b.current=b.current.then(()=>null==t?void 0:t.wait.current).then(()=>a(r)):a(r)}),x=(0,o.useEvent)((e,t,r)=>{Promise.all(h.current[t].splice(0).map(([e,t])=>t)).then(()=>{var e;null==(e=f.current.shift())||e()}).then(()=>r(t))});return(0,a.useMemo)(()=>({children:n,register:m,unregister:d,onStart:v,onStop:x,wait:b,chains:h}),[m,d,n,v,x,h,b])}y.displayName="NestingContext";let C=a.Fragment,j=p.RenderFeatures.RenderStrategy,E=(0,p.forwardRefWithAs)(function(e,t){let{show:r,appear:n=!1,unmount:l=!0,...s}=e,c=(0,a.useRef)(null),m=h(e),b=(0,d.useSyncRefs)(...m?[c,t]:null===t?[]:[t]);(0,u.useServerHandoffComplete)();let g=(0,f.useOpenClosed)();if(void 0===r&&null!==g&&(r=(g&f.State.Open)===f.State.Open),void 0===r)throw Error("A is used but it is missing a `show={true | false}` prop.");let[x,C]=(0,a.useState)(r?"visible":"hidden"),E=N(()=>{r||C("hidden")}),[O,S]=(0,a.useState)(!0),k=(0,a.useRef)([r]);(0,i.useIsoMorphicEffect)(()=>{!1!==O&&k.current[k.current.length-1]!==r&&(k.current.push(r),S(!1))},[k,r]);let T=(0,a.useMemo)(()=>({show:r,appear:n,initial:O}),[r,n,O]);(0,i.useIsoMorphicEffect)(()=>{r?C("visible"):w(E)||null===c.current||C("hidden")},[r,E]);let R={unmount:l},I=(0,o.useEvent)(()=>{var t;O&&S(!1),null==(t=e.beforeEnter)||t.call(e)}),M=(0,o.useEvent)(()=>{var t;O&&S(!1),null==(t=e.beforeLeave)||t.call(e)}),B=(0,p.useRender)();return a.default.createElement(y.Provider,{value:E},a.default.createElement(v.Provider,{value:T},B({ourProps:{...R,as:a.Fragment,children:a.default.createElement($,{ref:b,...R,...s,beforeEnter:I,beforeLeave:M})},theirProps:{},defaultTag:a.Fragment,features:j,visible:"visible"===x,name:"Transition"})))}),$=(0,p.forwardRefWithAs)(function(e,t){var r,n;let{transition:l=!0,beforeEnter:s,afterEnter:c,beforeLeave:x,afterLeave:E,enter:$,enterFrom:O,enterTo:S,entered:k,leave:T,leaveFrom:R,leaveTo:I,...M}=e,[B,P]=(0,a.useState)(null),D=(0,a.useRef)(null),z=h(e),F=(0,d.useSyncRefs)(...z?[D,t,P]:null===t?[]:[t]),L=null==(r=M.unmount)||r?p.RenderStrategy.Unmount:p.RenderStrategy.Hidden,{show:_,appear:H,initial:A}=function(){let e=(0,a.useContext)(v);if(null===e)throw Error("A is used but it is missing a parent or .");return e}(),[V,W]=(0,a.useState)(_?"visible":"hidden"),q=function(){let e=(0,a.useContext)(y);if(null===e)throw Error("A is used but it is missing a parent or .");return e}(),{register:K,unregister:Z}=q;(0,i.useIsoMorphicEffect)(()=>K(D),[K,D]),(0,i.useIsoMorphicEffect)(()=>{if(L===p.RenderStrategy.Hidden&&D.current)return _&&"visible"!==V?void W("visible"):(0,g.match)(V,{hidden:()=>Z(D),visible:()=>K(D)})},[V,D,K,Z,_,L]);let Q=(0,u.useServerHandoffComplete)();(0,i.useIsoMorphicEffect)(()=>{if(z&&Q&&"visible"===V&&null===D.current)throw Error("Did you forget to passthrough the `ref` to the actual DOM node?")},[D,V,Q,z]);let U=A&&!H,G=H&&_&&A,X=(0,a.useRef)(!1),Y=N(()=>{X.current||(W("hidden"),Z(D))},q),J=(0,o.useEvent)(e=>{X.current=!0,Y.onStart(D,e?"enter":"leave",e=>{"enter"===e?null==s||s():"leave"===e&&(null==x||x())})}),ee=(0,o.useEvent)(e=>{let t=e?"enter":"leave";X.current=!1,Y.onStop(D,t,e=>{"enter"===e?null==c||c():"leave"===e&&(null==E||E())}),"leave"!==t||w(Y)||(W("hidden"),Z(D))});(0,a.useEffect)(()=>{z&&l||(J(_),ee(_))},[_,z,l]);let et=!(!l||!z||!Q||U),[,er]=(0,m.useTransition)(et,B,_,{start:J,end:ee}),ea=(0,p.compact)({ref:F,className:(null==(n=(0,b.classNames)(M.className,G&&$,G&&O,er.enter&&$,er.enter&&er.closed&&O,er.enter&&!er.closed&&S,er.leave&&T,er.leave&&!er.closed&&R,er.leave&&er.closed&&I,!er.transition&&_&&k))?void 0:n.trim())||void 0,...(0,m.transitionDataAttributes)(er)}),en=0;"visible"===V&&(en|=f.State.Open),"hidden"===V&&(en|=f.State.Closed),er.enter&&(en|=f.State.Opening),er.leave&&(en|=f.State.Closing);let el=(0,p.useRender)();return a.default.createElement(y.Provider,{value:Y},a.default.createElement(f.OpenClosedProvider,{value:en},el({ourProps:ea,theirProps:M,defaultTag:C,features:j,visible:"visible"===V,name:"Transition.Child"})))}),O=(0,p.forwardRefWithAs)(function(e,t){let r=null!==(0,a.useContext)(v),n=null!==(0,f.useOpenClosed)();return a.default.createElement(a.default.Fragment,null,!r&&n?a.default.createElement(E,{ref:t,...e}):a.default.createElement($,{ref:t,...e}))}),S=Object.assign(E,{Child:O,Root:E});e.s(["Transition",()=>S],854056)},206929,e=>{"use strict";var t=e.i(290571),r=e.i(757440),a=e.i(271645),n=e.i(446428),l=e.i(444755),o=e.i(673706),s=e.i(103471),i=e.i(495470),c=e.i(854056),u=e.i(888288);let d=(0,o.makeClassName)("Select"),m=a.default.forwardRef((e,o)=>{let{defaultValue:m="",value:f,onValueChange:b,placeholder:g="Select...",disabled:p=!1,icon:h,enableClear:v=!1,required:x,children:y,name:w,error:N=!1,errorMessage:C,className:j,id:E}=e,$=(0,t.__rest)(e,["defaultValue","value","onValueChange","placeholder","disabled","icon","enableClear","required","children","name","error","errorMessage","className","id"]),O=(0,a.useRef)(null),S=a.Children.toArray(y),[k,T]=(0,u.default)(m,f),R=(0,a.useMemo)(()=>{let e=a.default.Children.toArray(y).filter(a.isValidElement);return(0,s.constructValueToNameMapping)(e)},[y]);return a.default.createElement("div",{className:(0,l.tremorTwMerge)("w-full min-w-[10rem] text-tremor-default",j)},a.default.createElement("div",{className:"relative"},a.default.createElement("select",{title:"select-hidden",required:x,className:(0,l.tremorTwMerge)("h-full w-full absolute left-0 top-0 -z-10 opacity-0"),value:k,onChange:e=>{e.preventDefault()},name:w,disabled:p,id:E,onFocus:()=>{let e=O.current;e&&e.focus()}},a.default.createElement("option",{className:"hidden",value:"",disabled:!0,hidden:!0},g),S.map(e=>{let t=e.props.value,r=e.props.children;return a.default.createElement("option",{className:"hidden",key:t,value:t},r)})),a.default.createElement(i.Listbox,Object.assign({as:"div",ref:o,defaultValue:k,value:k,onChange:e=>{null==b||b(e),T(e)},disabled:p,id:E},$),({value:e})=>{var t;return a.default.createElement(a.default.Fragment,null,a.default.createElement(i.ListboxButton,{ref:O,className:(0,l.tremorTwMerge)("w-full outline-none text-left whitespace-nowrap truncate rounded-tremor-default focus:ring-2 transition duration-100 border pr-8 py-2","border-tremor-border shadow-tremor-input focus:border-tremor-brand-subtle focus:ring-tremor-brand-muted","dark:border-dark-tremor-border dark:shadow-dark-tremor-input dark:focus:border-dark-tremor-brand-subtle dark:focus:ring-dark-tremor-brand-muted",h?"pl-10":"pl-3",(0,s.getSelectButtonColors)((0,s.hasValue)(e),p,N))},h&&a.default.createElement("span",{className:(0,l.tremorTwMerge)("absolute inset-y-0 left-0 flex items-center ml-px pl-2.5")},a.default.createElement(h,{className:(0,l.tremorTwMerge)(d("Icon"),"flex-none h-5 w-5","text-tremor-content-subtle","dark:text-dark-tremor-content-subtle")})),a.default.createElement("span",{className:"w-[90%] block truncate"},e&&null!=(t=R.get(e))?t:g),a.default.createElement("span",{className:(0,l.tremorTwMerge)("absolute inset-y-0 right-0 flex items-center mr-3")},a.default.createElement(r.default,{className:(0,l.tremorTwMerge)(d("arrowDownIcon"),"flex-none h-5 w-5","text-tremor-content-subtle","dark:text-dark-tremor-content-subtle")}))),v&&k?a.default.createElement("button",{type:"button",className:(0,l.tremorTwMerge)("absolute inset-y-0 right-0 flex items-center mr-8"),onClick:e=>{e.preventDefault(),T(""),null==b||b("")}},a.default.createElement(n.default,{className:(0,l.tremorTwMerge)(d("clearIcon"),"flex-none h-4 w-4","text-tremor-content-subtle","dark:text-dark-tremor-content-subtle")})):null,a.default.createElement(c.Transition,{enter:"transition ease duration-100 transform",enterFrom:"opacity-0 -translate-y-4",enterTo:"opacity-100 translate-y-0",leave:"transition ease duration-100 transform",leaveFrom:"opacity-100 translate-y-0",leaveTo:"opacity-0 -translate-y-4"},a.default.createElement(i.ListboxOptions,{anchor:"bottom start",className:(0,l.tremorTwMerge)("z-10 w-[var(--button-width)] divide-y overflow-y-auto outline-none rounded-tremor-default max-h-[228px] border [--anchor-gap:4px]","bg-tremor-background border-tremor-border divide-tremor-border shadow-tremor-dropdown","dark:bg-dark-tremor-background dark:border-dark-tremor-border dark:divide-dark-tremor-border dark:shadow-dark-tremor-dropdown")},y)))})),N&&C?a.default.createElement("p",{className:(0,l.tremorTwMerge)("errorMessage","text-sm text-rose-500 mt-1")},C):null)});m.displayName="Select",e.s(["Select",()=>m],206929)},214541,e=>{"use strict";var t=e.i(271645),r=e.i(135214),a=e.i(270345);e.s(["default",0,()=>{let[e,n]=(0,t.useState)([]),{accessToken:l,userId:o,userRole:s}=(0,r.default)();return(0,t.useEffect)(()=>{(async()=>{n(await (0,a.fetchTeams)(l,o,s,null))})()},[l,o,s]),{teams:e,setTeams:n}}])},11751,643449,183588,e=>{"use strict";function t(e){return""===e?null:e}e.s(["mapEmptyStringToNull",()=>t],11751);var r=e.i(843476),a=e.i(599724),n=e.i(389083),l=e.i(810757),o=e.i(477386),s=e.i(557662);e.s(["default",0,function({loggingConfigs:e=[],disabledCallbacks:t=[],variant:i="card",className:c=""}){let u=(0,r.jsxs)("div",{className:"space-y-6",children:[(0,r.jsxs)("div",{className:"space-y-3",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)(l.CogIcon,{className:"h-4 w-4 text-blue-600"}),(0,r.jsx)(a.Text,{className:"font-semibold text-gray-900",children:"Logging Integrations"}),(0,r.jsx)(n.Badge,{color:"blue",size:"xs",children:e.length})]}),e.length>0?(0,r.jsx)("div",{className:"space-y-3",children:e.map((e,t)=>{var o;let i=(o=e.callback_name,Object.entries(s.callback_map).find(([e,t])=>t===o)?.[0]||o),c=s.callbackInfo[i]?.logo;return(0,r.jsxs)("div",{className:"flex items-center justify-between p-3 rounded-lg bg-blue-50 border border-blue-200",children:[(0,r.jsxs)("div",{className:"flex items-center gap-3",children:[c?(0,r.jsx)("img",{src:c,alt:i,className:"w-5 h-5 object-contain"}):(0,r.jsx)(l.CogIcon,{className:"h-5 w-5 text-gray-400"}),(0,r.jsxs)("div",{children:[(0,r.jsx)(a.Text,{className:"font-medium text-blue-800",children:i}),(0,r.jsxs)(a.Text,{className:"text-xs text-blue-600",children:[Object.keys(e.callback_vars).length," parameters configured"]})]})]}),(0,r.jsx)(n.Badge,{color:(e=>{switch(e){case"success":return"green";case"failure":return"red";case"success_and_failure":return"blue";default:return"gray"}})(e.callback_type),size:"sm",children:(e=>{switch(e){case"success":return"Success Only";case"failure":return"Failure Only";case"success_and_failure":return"Success & Failure";default:return e}})(e.callback_type)})]},t)})}):(0,r.jsxs)("div",{className:"flex items-center gap-2 px-3 py-2 rounded-lg bg-gray-50 border border-gray-200",children:[(0,r.jsx)(l.CogIcon,{className:"h-4 w-4 text-gray-400"}),(0,r.jsx)(a.Text,{className:"text-gray-500 text-sm",children:"No logging integrations configured"})]})]}),(0,r.jsxs)("div",{className:"space-y-3",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)(o.BanIcon,{className:"h-4 w-4 text-red-600"}),(0,r.jsx)(a.Text,{className:"font-semibold text-gray-900",children:"Disabled Callbacks"}),(0,r.jsx)(n.Badge,{color:"red",size:"xs",children:t.length})]}),t.length>0?(0,r.jsx)("div",{className:"space-y-3",children:t.map((e,t)=>{let l=s.reverse_callback_map[e]||e,i=s.callbackInfo[l]?.logo;return(0,r.jsxs)("div",{className:"flex items-center justify-between p-3 rounded-lg bg-red-50 border border-red-200",children:[(0,r.jsxs)("div",{className:"flex items-center gap-3",children:[i?(0,r.jsx)("img",{src:i,alt:l,className:"w-5 h-5 object-contain"}):(0,r.jsx)(o.BanIcon,{className:"h-5 w-5 text-gray-400"}),(0,r.jsxs)("div",{children:[(0,r.jsx)(a.Text,{className:"font-medium text-red-800",children:l}),(0,r.jsx)(a.Text,{className:"text-xs text-red-600",children:"Disabled for this key"})]})]}),(0,r.jsx)(n.Badge,{color:"red",size:"sm",children:"Disabled"})]},t)})}):(0,r.jsxs)("div",{className:"flex items-center gap-2 px-3 py-2 rounded-lg bg-gray-50 border border-gray-200",children:[(0,r.jsx)(o.BanIcon,{className:"h-4 w-4 text-gray-400"}),(0,r.jsx)(a.Text,{className:"text-gray-500 text-sm",children:"No callbacks disabled"})]})]})]});return"card"===i?(0,r.jsxs)("div",{className:`bg-white border border-gray-200 rounded-lg p-6 ${c}`,children:[(0,r.jsx)("div",{className:"flex items-center gap-2 mb-6",children:(0,r.jsxs)("div",{children:[(0,r.jsx)(a.Text,{className:"font-semibold text-gray-900",children:"Logging Settings"}),(0,r.jsx)(a.Text,{className:"text-xs text-gray-500",children:"Active logging integrations and disabled callbacks for this key"})]})}),u]}):(0,r.jsxs)("div",{className:`${c}`,children:[(0,r.jsx)(a.Text,{className:"font-medium text-gray-900 mb-3",children:"Logging Settings"}),u]})}],643449);var i=e.i(266484);e.s(["default",0,({value:e,onChange:t,disabledCallbacks:a=[],onDisabledCallbacksChange:n})=>(0,r.jsx)(i.default,{value:e,onChange:t,disabledCallbacks:a,onDisabledCallbacksChange:n})],183588)},981339,e=>{"use strict";var t=e.i(185793);e.s(["Skeleton",()=>t.default])},906579,e=>{"use strict";e.i(247167);var t=e.i(271645),r=e.i(343794),a=e.i(361275),n=e.i(702779),l=e.i(763731),o=e.i(242064);e.i(296059);var s=e.i(915654),i=e.i(694758),c=e.i(183293),u=e.i(403541),d=e.i(246422),m=e.i(838378);let f=new i.Keyframes("antStatusProcessing",{"0%":{transform:"scale(0.8)",opacity:.5},"100%":{transform:"scale(2.4)",opacity:0}}),b=new i.Keyframes("antZoomBadgeIn",{"0%":{transform:"scale(0) translate(50%, -50%)",opacity:0},"100%":{transform:"scale(1) translate(50%, -50%)"}}),g=new i.Keyframes("antZoomBadgeOut",{"0%":{transform:"scale(1) translate(50%, -50%)"},"100%":{transform:"scale(0) translate(50%, -50%)",opacity:0}}),p=new i.Keyframes("antNoWrapperZoomBadgeIn",{"0%":{transform:"scale(0)",opacity:0},"100%":{transform:"scale(1)"}}),h=new i.Keyframes("antNoWrapperZoomBadgeOut",{"0%":{transform:"scale(1)"},"100%":{transform:"scale(0)",opacity:0}}),v=new i.Keyframes("antBadgeLoadingCircle",{"0%":{transformOrigin:"50%"},"100%":{transform:"translate(50%, -50%) rotate(360deg)",transformOrigin:"50%"}}),x=e=>{let{fontHeight:t,lineWidth:r,marginXS:a,colorBorderBg:n}=e,l=e.colorTextLightSolid,o=e.colorError,s=e.colorErrorHover;return(0,m.mergeToken)(e,{badgeFontHeight:t,badgeShadowSize:r,badgeTextColor:l,badgeColor:o,badgeColorHover:s,badgeShadowColor:n,badgeProcessingDuration:"1.2s",badgeRibbonOffset:a,badgeRibbonCornerTransform:"scaleY(0.75)",badgeRibbonCornerFilter:"brightness(75%)"})},y=e=>{let{fontSize:t,lineHeight:r,fontSizeSM:a,lineWidth:n}=e;return{indicatorZIndex:"auto",indicatorHeight:Math.round(t*r)-2*n,indicatorHeightSM:t,dotSize:a/2,textFontSize:a,textFontSizeSM:a,textFontWeight:"normal",statusSize:a/2}},w=(0,d.genStyleHooks)("Badge",e=>(e=>{let{componentCls:t,iconCls:r,antCls:a,badgeShadowSize:n,textFontSize:l,textFontSizeSM:o,statusSize:i,dotSize:d,textFontWeight:m,indicatorHeight:x,indicatorHeightSM:y,marginXS:w,calc:N}=e,C=`${a}-scroll-number`,j=(0,u.genPresetColor)(e,(e,{darkColor:r})=>({[`&${t} ${t}-color-${e}`]:{background:r,[`&:not(${t}-count)`]:{color:r},"a:hover &":{background:r}}}));return{[t]:Object.assign(Object.assign(Object.assign(Object.assign({},(0,c.resetComponent)(e)),{position:"relative",display:"inline-block",width:"fit-content",lineHeight:1,[`${t}-count`]:{display:"inline-flex",justifyContent:"center",zIndex:e.indicatorZIndex,minWidth:x,height:x,color:e.badgeTextColor,fontWeight:m,fontSize:l,lineHeight:(0,s.unit)(x),whiteSpace:"nowrap",textAlign:"center",background:e.badgeColor,borderRadius:N(x).div(2).equal(),boxShadow:`0 0 0 ${(0,s.unit)(n)} ${e.badgeShadowColor}`,transition:`background ${e.motionDurationMid}`,a:{color:e.badgeTextColor},"a:hover":{color:e.badgeTextColor},"a:hover &":{background:e.badgeColorHover}},[`${t}-count-sm`]:{minWidth:y,height:y,fontSize:o,lineHeight:(0,s.unit)(y),borderRadius:N(y).div(2).equal()},[`${t}-multiple-words`]:{padding:`0 ${(0,s.unit)(e.paddingXS)}`,bdi:{unicodeBidi:"plaintext"}},[`${t}-dot`]:{zIndex:e.indicatorZIndex,width:d,minWidth:d,height:d,background:e.badgeColor,borderRadius:"100%",boxShadow:`0 0 0 ${(0,s.unit)(n)} ${e.badgeShadowColor}`},[`${t}-count, ${t}-dot, ${C}-custom-component`]:{position:"absolute",top:0,insetInlineEnd:0,transform:"translate(50%, -50%)",transformOrigin:"100% 0%",[`&${r}-spin`]:{animationName:v,animationDuration:"1s",animationIterationCount:"infinite",animationTimingFunction:"linear"}},[`&${t}-status`]:{lineHeight:"inherit",verticalAlign:"baseline",[`${t}-status-dot`]:{position:"relative",top:-1,display:"inline-block",width:i,height:i,verticalAlign:"middle",borderRadius:"50%"},[`${t}-status-success`]:{backgroundColor:e.colorSuccess},[`${t}-status-processing`]:{overflow:"visible",color:e.colorInfo,backgroundColor:e.colorInfo,borderColor:"currentcolor","&::after":{position:"absolute",top:0,insetInlineStart:0,width:"100%",height:"100%",borderWidth:n,borderStyle:"solid",borderColor:"inherit",borderRadius:"50%",animationName:f,animationDuration:e.badgeProcessingDuration,animationIterationCount:"infinite",animationTimingFunction:"ease-in-out",content:'""'}},[`${t}-status-default`]:{backgroundColor:e.colorTextPlaceholder},[`${t}-status-error`]:{backgroundColor:e.colorError},[`${t}-status-warning`]:{backgroundColor:e.colorWarning},[`${t}-status-text`]:{marginInlineStart:w,color:e.colorText,fontSize:e.fontSize}}}),j),{[`${t}-zoom-appear, ${t}-zoom-enter`]:{animationName:b,animationDuration:e.motionDurationSlow,animationTimingFunction:e.motionEaseOutBack,animationFillMode:"both"},[`${t}-zoom-leave`]:{animationName:g,animationDuration:e.motionDurationSlow,animationTimingFunction:e.motionEaseOutBack,animationFillMode:"both"},[`&${t}-not-a-wrapper`]:{[`${t}-zoom-appear, ${t}-zoom-enter`]:{animationName:p,animationDuration:e.motionDurationSlow,animationTimingFunction:e.motionEaseOutBack},[`${t}-zoom-leave`]:{animationName:h,animationDuration:e.motionDurationSlow,animationTimingFunction:e.motionEaseOutBack},[`&:not(${t}-status)`]:{verticalAlign:"middle"},[`${C}-custom-component, ${t}-count`]:{transform:"none"},[`${C}-custom-component, ${C}`]:{position:"relative",top:"auto",display:"block",transformOrigin:"50% 50%"}},[C]:{overflow:"hidden",transition:`all ${e.motionDurationMid} ${e.motionEaseOutBack}`,[`${C}-only`]:{position:"relative",display:"inline-block",height:x,transition:`all ${e.motionDurationSlow} ${e.motionEaseOutBack}`,WebkitTransformStyle:"preserve-3d",WebkitBackfaceVisibility:"hidden",[`> p${C}-only-unit`]:{height:x,margin:0,WebkitTransformStyle:"preserve-3d",WebkitBackfaceVisibility:"hidden"}},[`${C}-symbol`]:{verticalAlign:"top"}},"&-rtl":{direction:"rtl",[`${t}-count, ${t}-dot, ${C}-custom-component`]:{transform:"translate(-50%, -50%)"}}})}})(x(e)),y),N=(0,d.genStyleHooks)(["Badge","Ribbon"],e=>(e=>{let{antCls:t,badgeFontHeight:r,marginXS:a,badgeRibbonOffset:n,calc:l}=e,o=`${t}-ribbon`,i=`${t}-ribbon-wrapper`,d=(0,u.genPresetColor)(e,(e,{darkColor:t})=>({[`&${o}-color-${e}`]:{background:t,color:t}}));return{[i]:{position:"relative"},[o]:Object.assign(Object.assign(Object.assign(Object.assign({},(0,c.resetComponent)(e)),{position:"absolute",top:a,padding:`0 ${(0,s.unit)(e.paddingXS)}`,color:e.colorPrimary,lineHeight:(0,s.unit)(r),whiteSpace:"nowrap",backgroundColor:e.colorPrimary,borderRadius:e.borderRadiusSM,[`${o}-text`]:{color:e.badgeTextColor},[`${o}-corner`]:{position:"absolute",top:"100%",width:n,height:n,color:"currentcolor",border:`${(0,s.unit)(l(n).div(2).equal())} solid`,transform:e.badgeRibbonCornerTransform,transformOrigin:"top",filter:e.badgeRibbonCornerFilter}}),d),{[`&${o}-placement-end`]:{insetInlineEnd:l(n).mul(-1).equal(),borderEndEndRadius:0,[`${o}-corner`]:{insetInlineEnd:0,borderInlineEndColor:"transparent",borderBlockEndColor:"transparent"}},[`&${o}-placement-start`]:{insetInlineStart:l(n).mul(-1).equal(),borderEndStartRadius:0,[`${o}-corner`]:{insetInlineStart:0,borderBlockEndColor:"transparent",borderInlineStartColor:"transparent"}},"&-rtl":{direction:"rtl"}})}})(x(e)),y),C=e=>{let a,{prefixCls:n,value:l,current:o,offset:s=0}=e;return s&&(a={position:"absolute",top:`${s}00%`,left:0}),t.createElement("span",{style:a,className:(0,r.default)(`${n}-only-unit`,{current:o})},l)},j=e=>{let r,a,{prefixCls:n,count:l,value:o}=e,s=Number(o),i=Math.abs(l),[c,u]=t.useState(s),[d,m]=t.useState(i),f=()=>{u(s),m(i)};if(t.useEffect(()=>{let e=setTimeout(f,1e3);return()=>clearTimeout(e)},[s]),c===s||Number.isNaN(s)||Number.isNaN(c))r=[t.createElement(C,Object.assign({},e,{key:s,current:!0}))],a={transition:"none"};else{r=[];let n=s+10,l=[];for(let e=s;e<=n;e+=1)l.push(e);let o=de%10===c);r=(o<0?l.slice(0,u+1):l.slice(u)).map((r,a)=>t.createElement(C,Object.assign({},e,{key:r,value:r%10,offset:o<0?a-u:a,current:a===u}))),a={transform:`translateY(${-function(e,t,r){let a=e,n=0;for(;(a+10)%10!==t;)a+=r,n+=r;return n}(c,s,o)}00%)`}}return t.createElement("span",{className:`${n}-only`,style:a,onTransitionEnd:f},r)};var E=function(e,t){var r={};for(var a in e)Object.prototype.hasOwnProperty.call(e,a)&&0>t.indexOf(a)&&(r[a]=e[a]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols)for(var n=0,a=Object.getOwnPropertySymbols(e);nt.indexOf(a[n])&&Object.prototype.propertyIsEnumerable.call(e,a[n])&&(r[a[n]]=e[a[n]]);return r};let $=t.forwardRef((e,a)=>{let{prefixCls:n,count:s,className:i,motionClassName:c,style:u,title:d,show:m,component:f="sup",children:b}=e,g=E(e,["prefixCls","count","className","motionClassName","style","title","show","component","children"]),{getPrefixCls:p}=t.useContext(o.ConfigContext),h=p("scroll-number",n),v=Object.assign(Object.assign({},g),{"data-show":m,style:u,className:(0,r.default)(h,i,c),title:d}),x=s;if(s&&Number(s)%1==0){let e=String(s).split("");x=t.createElement("bdi",null,e.map((r,a)=>t.createElement(j,{prefixCls:h,count:Number(s),value:r,key:e.length-a})))}return((null==u?void 0:u.borderColor)&&(v.style=Object.assign(Object.assign({},u),{boxShadow:`0 0 0 1px ${u.borderColor} inset`})),b)?(0,l.cloneElement)(b,e=>({className:(0,r.default)(`${h}-custom-component`,null==e?void 0:e.className,c)})):t.createElement(f,Object.assign({},v,{ref:a}),x)});var O=function(e,t){var r={};for(var a in e)Object.prototype.hasOwnProperty.call(e,a)&&0>t.indexOf(a)&&(r[a]=e[a]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols)for(var n=0,a=Object.getOwnPropertySymbols(e);nt.indexOf(a[n])&&Object.prototype.propertyIsEnumerable.call(e,a[n])&&(r[a[n]]=e[a[n]]);return r};let S=t.forwardRef((e,s)=>{var i,c,u,d,m;let{prefixCls:f,scrollNumberPrefixCls:b,children:g,status:p,text:h,color:v,count:x=null,overflowCount:y=99,dot:N=!1,size:C="default",title:j,offset:E,style:S,className:k,rootClassName:T,classNames:R,styles:I,showZero:M=!1}=e,B=O(e,["prefixCls","scrollNumberPrefixCls","children","status","text","color","count","overflowCount","dot","size","title","offset","style","className","rootClassName","classNames","styles","showZero"]),{getPrefixCls:P,direction:D,badge:z}=t.useContext(o.ConfigContext),F=P("badge",f),[L,_,H]=w(F),A=x>y?`${y}+`:x,V="0"===A||0===A||"0"===h||0===h,W=null===x||V&&!M,q=(null!=p||null!=v)&&W,K=null!=p||!V,Z=N&&!V,Q=Z?"":A,U=(0,t.useMemo)(()=>((null==Q||""===Q)&&(null==h||""===h)||V&&!M)&&!Z,[Q,V,M,Z,h]),G=(0,t.useRef)(x);U||(G.current=x);let X=G.current,Y=(0,t.useRef)(Q);U||(Y.current=Q);let J=Y.current,ee=(0,t.useRef)(Z);U||(ee.current=Z);let et=(0,t.useMemo)(()=>{if(!E)return Object.assign(Object.assign({},null==z?void 0:z.style),S);let e={marginTop:E[1]};return"rtl"===D?e.left=Number.parseInt(E[0],10):e.right=-Number.parseInt(E[0],10),Object.assign(Object.assign(Object.assign({},e),null==z?void 0:z.style),S)},[D,E,S,null==z?void 0:z.style]),er=null!=j?j:"string"==typeof X||"number"==typeof X?X:void 0,ea=!U&&(0===h?M:!!h&&!0!==h),en=ea?t.createElement("span",{className:`${F}-status-text`},h):null,el=X&&"object"==typeof X?(0,l.cloneElement)(X,e=>({style:Object.assign(Object.assign({},et),e.style)})):void 0,eo=(0,n.isPresetColor)(v,!1),es=(0,r.default)(null==R?void 0:R.indicator,null==(i=null==z?void 0:z.classNames)?void 0:i.indicator,{[`${F}-status-dot`]:q,[`${F}-status-${p}`]:!!p,[`${F}-color-${v}`]:eo}),ei={};v&&!eo&&(ei.color=v,ei.background=v);let ec=(0,r.default)(F,{[`${F}-status`]:q,[`${F}-not-a-wrapper`]:!g,[`${F}-rtl`]:"rtl"===D},k,T,null==z?void 0:z.className,null==(c=null==z?void 0:z.classNames)?void 0:c.root,null==R?void 0:R.root,_,H);if(!g&&q&&(h||K||!W)){let e=et.color;return L(t.createElement("span",Object.assign({},B,{className:ec,style:Object.assign(Object.assign(Object.assign({},null==I?void 0:I.root),null==(u=null==z?void 0:z.styles)?void 0:u.root),et)}),t.createElement("span",{className:es,style:Object.assign(Object.assign(Object.assign({},null==I?void 0:I.indicator),null==(d=null==z?void 0:z.styles)?void 0:d.indicator),ei)}),ea&&t.createElement("span",{style:{color:e},className:`${F}-status-text`},h)))}return L(t.createElement("span",Object.assign({ref:s},B,{className:ec,style:Object.assign(Object.assign({},null==(m=null==z?void 0:z.styles)?void 0:m.root),null==I?void 0:I.root)}),g,t.createElement(a.default,{visible:!U,motionName:`${F}-zoom`,motionAppear:!1,motionDeadline:1e3},({className:e})=>{var a,n;let l=P("scroll-number",b),o=ee.current,s=(0,r.default)(null==R?void 0:R.indicator,null==(a=null==z?void 0:z.classNames)?void 0:a.indicator,{[`${F}-dot`]:o,[`${F}-count`]:!o,[`${F}-count-sm`]:"small"===C,[`${F}-multiple-words`]:!o&&J&&J.toString().length>1,[`${F}-status-${p}`]:!!p,[`${F}-color-${v}`]:eo}),i=Object.assign(Object.assign(Object.assign({},null==I?void 0:I.indicator),null==(n=null==z?void 0:z.styles)?void 0:n.indicator),et);return v&&!eo&&((i=i||{}).background=v),t.createElement($,{prefixCls:l,show:!U,motionClassName:e,className:s,count:J,title:er,style:i,key:"scrollNumber"},el)}),en))});S.Ribbon=e=>{let{className:a,prefixCls:l,style:s,color:i,children:c,text:u,placement:d="end",rootClassName:m}=e,{getPrefixCls:f,direction:b}=t.useContext(o.ConfigContext),g=f("ribbon",l),p=`${g}-wrapper`,[h,v,x]=N(g,p),y=(0,n.isPresetColor)(i,!1),w=(0,r.default)(g,`${g}-placement-${d}`,{[`${g}-rtl`]:"rtl"===b,[`${g}-color-${i}`]:y},a),C={},j={};return i&&!y&&(C.background=i,j.color=i),h(t.createElement("div",{className:(0,r.default)(p,m,v,x)},c,t.createElement("div",{className:(0,r.default)(w,v),style:Object.assign(Object.assign({},C),s)},t.createElement("span",{className:`${g}-text`},u),t.createElement("div",{className:`${g}-corner`,style:j}))))},e.s(["Badge",0,S],906579)},785242,e=>{"use strict";var t=e.i(619273),r=e.i(266027),a=e.i(912598),n=e.i(135214),l=e.i(270345),o=e.i(243652),s=e.i(764205);let i=(0,o.createQueryKeys)("teams"),c=async(e,t,r,a={})=>{try{let n=(0,s.getProxyBaseUrl)(),l=new URLSearchParams(Object.entries({team_id:a.teamID,organization_id:a.organizationID,team_alias:a.team_alias,user_id:a.userID,page:t,page_size:r,sort_by:a.sortBy,sort_order:a.sortOrder,status:"deleted"}).filter(([,e])=>null!=e).map(([e,t])=>[e,String(t)])),o=`${n?`${n}/v2/team/list`:"/v2/team/list"}?${l}`,i=await fetch(o,{method:"GET",headers:{[(0,s.getGlobalLitellmHeaderName)()]:`Bearer ${e}`,"Content-Type":"application/json"}});if(!i.ok){let e=await i.json(),t=(0,s.deriveErrorMessage)(e);throw(0,s.handleError)(t),Error(t)}let c=await i.json();if(console.log("/team/list?status=deleted API Response:",c),c&&"object"==typeof c&&"teams"in c)return c.teams;return c}catch(e){throw console.error("Failed to list deleted teams:",e),e}},u=(0,o.createQueryKeys)("deletedTeams");e.s(["useDeletedTeams",0,(e,a,l={})=>{let{accessToken:o}=(0,n.default)();return(0,r.useQuery)({queryKey:u.list({page:e,limit:a,...l}),queryFn:async()=>await c(o,e,a,l),enabled:!!o,staleTime:3e4,placeholderData:t.keepPreviousData})},"useTeam",0,e=>{let{accessToken:t}=(0,n.default)(),l=(0,a.useQueryClient)();return(0,r.useQuery)({queryKey:i.detail(e),enabled:!!(t&&e),queryFn:async()=>{if(!t||!e)throw Error("Missing auth or teamId");return(0,s.teamInfoCall)(t,e)},initialData:()=>{if(!e)return;let t=l.getQueryData(i.list({}));return t?.find(t=>t.team_id===e)}})},"useTeams",0,()=>{let{accessToken:e,userId:t,userRole:a}=(0,n.default)();return(0,r.useQuery)({queryKey:i.list({}),queryFn:async()=>await (0,l.fetchTeams)(e,t,a,null),enabled:!!e})}])},21548,e=>{"use strict";var t=e.i(616303);e.s(["Empty",()=>t.default])},987432,e=>{"use strict";e.i(247167);var t=e.i(931067),r=e.i(271645);let a={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M893.3 293.3L730.7 130.7c-7.5-7.5-16.7-13-26.7-16V112H144c-17.7 0-32 14.3-32 32v736c0 17.7 14.3 32 32 32h736c17.7 0 32-14.3 32-32V338.5c0-17-6.7-33.2-18.7-45.2zM384 184h256v104H384V184zm456 656H184V184h136v136c0 17.7 14.3 32 32 32h320c17.7 0 32-14.3 32-32V205.8l136 136V840zM512 442c-79.5 0-144 64.5-144 144s64.5 144 144 144 144-64.5 144-144-64.5-144-144-144zm0 224c-44.2 0-80-35.8-80-80s35.8-80 80-80 80 35.8 80 80-35.8 80-80 80z"}}]},name:"save",theme:"outlined"};var n=e.i(9583),l=r.forwardRef(function(e,l){return r.createElement(n.default,(0,t.default)({},e,{ref:l,icon:a}))});e.s(["SaveOutlined",0,l],987432)},91979,e=>{"use strict";e.i(247167);var t=e.i(931067),r=e.i(271645);let a={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M909.1 209.3l-56.4 44.1C775.8 155.1 656.2 92 521.9 92 290 92 102.3 279.5 102 511.5 101.7 743.7 289.8 932 521.9 932c181.3 0 335.8-115 394.6-276.1 1.5-4.2-.7-8.9-4.9-10.3l-56.7-19.5a8 8 0 00-10.1 4.8c-1.8 5-3.8 10-5.9 14.9-17.3 41-42.1 77.8-73.7 109.4A344.77 344.77 0 01655.9 829c-42.3 17.9-87.4 27-133.8 27-46.5 0-91.5-9.1-133.8-27A341.5 341.5 0 01279 755.2a342.16 342.16 0 01-73.7-109.4c-17.9-42.4-27-87.4-27-133.9s9.1-91.5 27-133.9c17.3-41 42.1-77.8 73.7-109.4 31.6-31.6 68.4-56.4 109.3-73.8 42.3-17.9 87.4-27 133.8-27 46.5 0 91.5 9.1 133.8 27a341.5 341.5 0 01109.3 73.8c9.9 9.9 19.2 20.4 27.8 31.4l-60.2 47a8 8 0 003 14.1l175.6 43c5 1.2 9.9-2.6 9.9-7.7l.8-180.9c-.1-6.6-7.8-10.3-13-6.2z"}}]},name:"reload",theme:"outlined"};var n=e.i(9583),l=r.forwardRef(function(e,l){return r.createElement(n.default,(0,t.default)({},e,{ref:l,icon:a}))});e.s(["ReloadOutlined",0,l],91979)}]); \ No newline at end of file diff --git a/litellm/proxy/_experimental/out/_next/static/chunks/1059-26bdac09bbb12a4b.js b/litellm/proxy/_experimental/out/_next/static/chunks/1059-26bdac09bbb12a4b.js deleted file mode 100644 index cd4f5e4e326..00000000000 --- a/litellm/proxy/_experimental/out/_next/static/chunks/1059-26bdac09bbb12a4b.js +++ /dev/null @@ -1 +0,0 @@ -"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[1059],{83669:function(t,e,r){r.d(e,{Z:function(){return c}});var n=r(1119),o=r(2265),a={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M699 353h-46.9c-10.2 0-19.9 4.9-25.9 13.3L469 584.3l-71.2-98.8c-6-8.3-15.6-13.3-25.9-13.3H325c-6.5 0-10.3 7.4-6.5 12.7l124.6 172.8a31.8 31.8 0 0051.7 0l210.6-292c3.9-5.3.1-12.7-6.4-12.7z"}},{tag:"path",attrs:{d:"M512 64C264.6 64 64 264.6 64 512s200.6 448 448 448 448-200.6 448-448S759.4 64 512 64zm0 820c-205.4 0-372-166.6-372-372s166.6-372 372-372 372 166.6 372 372-166.6 372-372 372z"}}]},name:"check-circle",theme:"outlined"},i=r(55015),c=o.forwardRef(function(t,e){return o.createElement(i.Z,(0,n.Z)({},t,{ref:e,icon:a}))})},62670:function(t,e,r){r.d(e,{Z:function(){return c}});var n=r(1119),o=r(2265),a={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M512 64C264.6 64 64 264.6 64 512s200.6 448 448 448 448-200.6 448-448S759.4 64 512 64zm0 820c-205.4 0-372-166.6-372-372s166.6-372 372-372 372 166.6 372 372-166.6 372-372 372zm47.7-395.2l-25.4-5.9V348.6c38 5.2 61.5 29 65.5 58.2.5 4 3.9 6.9 7.9 6.9h44.9c4.7 0 8.4-4.1 8-8.8-6.1-62.3-57.4-102.3-125.9-109.2V263c0-4.4-3.6-8-8-8h-28.1c-4.4 0-8 3.6-8 8v33c-70.8 6.9-126.2 46-126.2 119 0 67.6 49.8 100.2 102.1 112.7l24.7 6.3v142.7c-44.2-5.9-69-29.5-74.1-61.3-.6-3.8-4-6.6-7.9-6.6H363c-4.7 0-8.4 4-8 8.7 4.5 55 46.2 105.6 135.2 112.1V761c0 4.4 3.6 8 8 8h28.4c4.4 0 8-3.6 8-8.1l-.2-31.7c78.3-6.9 134.3-48.8 134.3-124-.1-69.4-44.2-100.4-109-116.4zm-68.6-16.2c-5.6-1.6-10.3-3.1-15-5-33.8-12.2-49.5-31.9-49.5-57.3 0-36.3 27.5-57 64.5-61.7v124zM534.3 677V543.3c3.1.9 5.9 1.6 8.8 2.2 47.3 14.4 63.2 34.4 63.2 65.1 0 39.1-29.4 62.6-72 66.4z"}}]},name:"dollar",theme:"outlined"},i=r(55015),c=o.forwardRef(function(t,e){return o.createElement(i.Z,(0,n.Z)({},t,{ref:e,icon:a}))})},45246:function(t,e,r){r.d(e,{Z:function(){return c}});var n=r(1119),o=r(2265),a={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M696 480H328c-4.4 0-8 3.6-8 8v48c0 4.4 3.6 8 8 8h368c4.4 0 8-3.6 8-8v-48c0-4.4-3.6-8-8-8z"}},{tag:"path",attrs:{d:"M512 64C264.6 64 64 264.6 64 512s200.6 448 448 448 448-200.6 448-448S759.4 64 512 64zm0 820c-205.4 0-372-166.6-372-372s166.6-372 372-372 372 166.6 372 372-166.6 372-372 372z"}}]},name:"minus-circle",theme:"outlined"},i=r(55015),c=o.forwardRef(function(t,e){return o.createElement(i.Z,(0,n.Z)({},t,{ref:e,icon:a}))})},89245:function(t,e,r){r.d(e,{Z:function(){return c}});var n=r(1119),o=r(2265),a={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M909.1 209.3l-56.4 44.1C775.8 155.1 656.2 92 521.9 92 290 92 102.3 279.5 102 511.5 101.7 743.7 289.8 932 521.9 932c181.3 0 335.8-115 394.6-276.1 1.5-4.2-.7-8.9-4.9-10.3l-56.7-19.5a8 8 0 00-10.1 4.8c-1.8 5-3.8 10-5.9 14.9-17.3 41-42.1 77.8-73.7 109.4A344.77 344.77 0 01655.9 829c-42.3 17.9-87.4 27-133.8 27-46.5 0-91.5-9.1-133.8-27A341.5 341.5 0 01279 755.2a342.16 342.16 0 01-73.7-109.4c-17.9-42.4-27-87.4-27-133.9s9.1-91.5 27-133.9c17.3-41 42.1-77.8 73.7-109.4 31.6-31.6 68.4-56.4 109.3-73.8 42.3-17.9 87.4-27 133.8-27 46.5 0 91.5 9.1 133.8 27a341.5 341.5 0 01109.3 73.8c9.9 9.9 19.2 20.4 27.8 31.4l-60.2 47a8 8 0 003 14.1l175.6 43c5 1.2 9.9-2.6 9.9-7.7l.8-180.9c-.1-6.6-7.8-10.3-13-6.2z"}}]},name:"reload",theme:"outlined"},i=r(55015),c=o.forwardRef(function(t,e){return o.createElement(i.Z,(0,n.Z)({},t,{ref:e,icon:a}))})},77565:function(t,e,r){r.d(e,{Z:function(){return c}});var n=r(1119),o=r(2265),a={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M765.7 486.8L314.9 134.7A7.97 7.97 0 00302 141v77.3c0 4.9 2.3 9.6 6.1 12.6l360 281.1-360 281.1c-3.9 3-6.1 7.7-6.1 12.6V883c0 6.7 7.7 10.4 12.9 6.3l450.8-352.1a31.96 31.96 0 000-50.4z"}}]},name:"right",theme:"outlined"},i=r(55015),c=o.forwardRef(function(t,e){return o.createElement(i.Z,(0,n.Z)({},t,{ref:e,icon:a}))})},69993:function(t,e,r){r.d(e,{Z:function(){return c}});var n=r(1119),o=r(2265),a={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M300 328a60 60 0 10120 0 60 60 0 10-120 0zM852 64H172c-17.7 0-32 14.3-32 32v660c0 17.7 14.3 32 32 32h680c17.7 0 32-14.3 32-32V96c0-17.7-14.3-32-32-32zm-32 660H204V128h616v596zM604 328a60 60 0 10120 0 60 60 0 10-120 0zm250.2 556H169.8c-16.5 0-29.8 14.3-29.8 32v36c0 4.4 3.3 8 7.4 8h729.1c4.1 0 7.4-3.6 7.4-8v-36c.1-17.7-13.2-32-29.7-32zM664 508H360c-4.4 0-8 3.6-8 8v60c0 4.4 3.6 8 8 8h304c4.4 0 8-3.6 8-8v-60c0-4.4-3.6-8-8-8z"}}]},name:"robot",theme:"outlined"},i=r(55015),c=o.forwardRef(function(t,e){return o.createElement(i.Z,(0,n.Z)({},t,{ref:e,icon:a}))})},58630:function(t,e,r){r.d(e,{Z:function(){return c}});var n=r(1119),o=r(2265),a={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M876.6 239.5c-.5-.9-1.2-1.8-2-2.5-5-5-13.1-5-18.1 0L684.2 409.3l-67.9-67.9L788.7 169c.8-.8 1.4-1.6 2-2.5 3.6-6.1 1.6-13.9-4.5-17.5-98.2-58-226.8-44.7-311.3 39.7-67 67-89.2 162-66.5 247.4l-293 293c-3 3-2.8 7.9.3 11l169.7 169.7c3.1 3.1 8.1 3.3 11 .3l292.9-292.9c85.5 22.8 180.5.7 247.6-66.4 84.4-84.5 97.7-213.1 39.7-311.3zM786 499.8c-58.1 58.1-145.3 69.3-214.6 33.6l-8.8 8.8-.1-.1-274 274.1-79.2-79.2 230.1-230.1s0 .1.1.1l52.8-52.8c-35.7-69.3-24.5-156.5 33.6-214.6a184.2 184.2 0 01144-53.5L537 318.9a32.05 32.05 0 000 45.3l124.5 124.5a32.05 32.05 0 0045.3 0l132.8-132.8c3.7 51.8-14.4 104.8-53.6 143.9z"}}]},name:"tool",theme:"outlined"},i=r(55015),c=o.forwardRef(function(t,e){return o.createElement(i.Z,(0,n.Z)({},t,{ref:e,icon:a}))})},47323:function(t,e,r){r.d(e,{Z:function(){return b}});var n=r(5853),o=r(2265),a=r(47187),i=r(7084),c=r(13241),l=r(1153),s=r(26898);let d={xs:{paddingX:"px-1.5",paddingY:"py-1.5"},sm:{paddingX:"px-1.5",paddingY:"py-1.5"},md:{paddingX:"px-2",paddingY:"py-2"},lg:{paddingX:"px-2",paddingY:"py-2"},xl:{paddingX:"px-2.5",paddingY:"py-2.5"}},u={xs:{height:"h-3",width:"w-3"},sm:{height:"h-5",width:"w-5"},md:{height:"h-5",width:"w-5"},lg:{height:"h-7",width:"w-7"},xl:{height:"h-9",width:"w-9"}},m={simple:{rounded:"",border:"",ring:"",shadow:""},light:{rounded:"rounded-tremor-default",border:"",ring:"",shadow:""},shadow:{rounded:"rounded-tremor-default",border:"border",ring:"",shadow:"shadow-tremor-card dark:shadow-dark-tremor-card"},solid:{rounded:"rounded-tremor-default",border:"border-2",ring:"ring-1",shadow:""},outlined:{rounded:"rounded-tremor-default",border:"border",ring:"ring-2",shadow:""}},g=(t,e)=>{switch(t){case"simple":return{textColor:e?(0,l.bM)(e,s.K.text).textColor:"text-tremor-brand dark:text-dark-tremor-brand",bgColor:"",borderColor:"",ringColor:""};case"light":return{textColor:e?(0,l.bM)(e,s.K.text).textColor:"text-tremor-brand dark:text-dark-tremor-brand",bgColor:e?(0,c.q)((0,l.bM)(e,s.K.background).bgColor,"bg-opacity-20"):"bg-tremor-brand-muted dark:bg-dark-tremor-brand-muted",borderColor:"",ringColor:""};case"shadow":return{textColor:e?(0,l.bM)(e,s.K.text).textColor:"text-tremor-brand dark:text-dark-tremor-brand",bgColor:e?(0,c.q)((0,l.bM)(e,s.K.background).bgColor,"bg-opacity-20"):"bg-tremor-background dark:bg-dark-tremor-background",borderColor:"border-tremor-border dark:border-dark-tremor-border",ringColor:""};case"solid":return{textColor:e?(0,l.bM)(e,s.K.text).textColor:"text-tremor-brand-inverted dark:text-dark-tremor-brand-inverted",bgColor:e?(0,c.q)((0,l.bM)(e,s.K.background).bgColor,"bg-opacity-20"):"bg-tremor-brand dark:bg-dark-tremor-brand",borderColor:"border-tremor-brand-inverted dark:border-dark-tremor-brand-inverted",ringColor:"ring-tremor-ring dark:ring-dark-tremor-ring"};case"outlined":return{textColor:e?(0,l.bM)(e,s.K.text).textColor:"text-tremor-brand dark:text-dark-tremor-brand",bgColor:e?(0,c.q)((0,l.bM)(e,s.K.background).bgColor,"bg-opacity-20"):"bg-tremor-background dark:bg-dark-tremor-background",borderColor:e?(0,l.bM)(e,s.K.ring).borderColor:"border-tremor-brand-subtle dark:border-dark-tremor-brand-subtle",ringColor:e?(0,c.q)((0,l.bM)(e,s.K.ring).ringColor,"ring-opacity-40"):"ring-tremor-brand-muted dark:ring-dark-tremor-brand-muted"}}},p=(0,l.fn)("Icon"),b=o.forwardRef((t,e)=>{let{icon:r,variant:s="simple",tooltip:b,size:f=i.u8.SM,color:h,className:v}=t,y=(0,n._T)(t,["icon","variant","tooltip","size","color","className"]),w=g(s,h),{tooltipProps:x,getReferenceProps:k}=(0,a.l)();return o.createElement("span",Object.assign({ref:(0,l.lq)([e,x.refs.setReference]),className:(0,c.q)(p("root"),"inline-flex shrink-0 items-center justify-center",w.bgColor,w.textColor,w.borderColor,w.ringColor,m[s].rounded,m[s].border,m[s].shadow,m[s].ring,d[f].paddingX,d[f].paddingY,v)},k,y),o.createElement(a.Z,Object.assign({text:b},x)),o.createElement(r,{className:(0,c.q)(p("icon"),"shrink-0",u[f].height,u[f].width)}))});b.displayName="Icon"},67101:function(t,e,r){r.d(e,{Z:function(){return d}});var n=r(5853),o=r(13241),a=r(1153),i=r(2265),c=r(9496);let l=(0,a.fn)("Grid"),s=(t,e)=>t&&Object.keys(e).includes(String(t))?e[t]:"",d=i.forwardRef((t,e)=>{let{numItems:r=1,numItemsSm:a,numItemsMd:d,numItemsLg:u,children:m,className:g}=t,p=(0,n._T)(t,["numItems","numItemsSm","numItemsMd","numItemsLg","children","className"]),b=s(r,c._m),f=s(a,c.LH),h=s(d,c.l5),v=s(u,c.N4),y=(0,o.q)(b,f,h,v);return i.createElement("div",Object.assign({ref:e,className:(0,o.q)(l("root"),"grid",y,g)},p),m)});d.displayName="Grid"},9496:function(t,e,r){r.d(e,{LH:function(){return o},N4:function(){return i},PT:function(){return c},SP:function(){return l},VS:function(){return s},_m:function(){return n},_w:function(){return d},l5:function(){return a}});let n={0:"grid-cols-none",1:"grid-cols-1",2:"grid-cols-2",3:"grid-cols-3",4:"grid-cols-4",5:"grid-cols-5",6:"grid-cols-6",7:"grid-cols-7",8:"grid-cols-8",9:"grid-cols-9",10:"grid-cols-10",11:"grid-cols-11",12:"grid-cols-12"},o={0:"sm:grid-cols-none",1:"sm:grid-cols-1",2:"sm:grid-cols-2",3:"sm:grid-cols-3",4:"sm:grid-cols-4",5:"sm:grid-cols-5",6:"sm:grid-cols-6",7:"sm:grid-cols-7",8:"sm:grid-cols-8",9:"sm:grid-cols-9",10:"sm:grid-cols-10",11:"sm:grid-cols-11",12:"sm:grid-cols-12"},a={0:"md:grid-cols-none",1:"md:grid-cols-1",2:"md:grid-cols-2",3:"md:grid-cols-3",4:"md:grid-cols-4",5:"md:grid-cols-5",6:"md:grid-cols-6",7:"md:grid-cols-7",8:"md:grid-cols-8",9:"md:grid-cols-9",10:"md:grid-cols-10",11:"md:grid-cols-11",12:"md:grid-cols-12"},i={0:"lg:grid-cols-none",1:"lg:grid-cols-1",2:"lg:grid-cols-2",3:"lg:grid-cols-3",4:"lg:grid-cols-4",5:"lg:grid-cols-5",6:"lg:grid-cols-6",7:"lg:grid-cols-7",8:"lg:grid-cols-8",9:"lg:grid-cols-9",10:"lg:grid-cols-10",11:"lg:grid-cols-11",12:"lg:grid-cols-12"},c={1:"col-span-1",2:"col-span-2",3:"col-span-3",4:"col-span-4",5:"col-span-5",6:"col-span-6",7:"col-span-7",8:"col-span-8",9:"col-span-9",10:"col-span-10",11:"col-span-11",12:"col-span-12",13:"col-span-13"},l={1:"sm:col-span-1",2:"sm:col-span-2",3:"sm:col-span-3",4:"sm:col-span-4",5:"sm:col-span-5",6:"sm:col-span-6",7:"sm:col-span-7",8:"sm:col-span-8",9:"sm:col-span-9",10:"sm:col-span-10",11:"sm:col-span-11",12:"sm:col-span-12",13:"sm:col-span-13"},s={1:"md:col-span-1",2:"md:col-span-2",3:"md:col-span-3",4:"md:col-span-4",5:"md:col-span-5",6:"md:col-span-6",7:"md:col-span-7",8:"md:col-span-8",9:"md:col-span-9",10:"md:col-span-10",11:"md:col-span-11",12:"md:col-span-12",13:"md:col-span-13"},d={1:"lg:col-span-1",2:"lg:col-span-2",3:"lg:col-span-3",4:"lg:col-span-4",5:"lg:col-span-5",6:"lg:col-span-6",7:"lg:col-span-7",8:"lg:col-span-8",9:"lg:col-span-9",10:"lg:col-span-10",11:"lg:col-span-11",12:"lg:col-span-12",13:"lg:col-span-13"}},96761:function(t,e,r){r.d(e,{Z:function(){return l}});var n=r(5853),o=r(26898),a=r(13241),i=r(1153),c=r(2265);let l=c.forwardRef((t,e)=>{let{color:r,children:l,className:s}=t,d=(0,n._T)(t,["color","children","className"]);return c.createElement("p",Object.assign({ref:e,className:(0,a.q)("font-medium text-tremor-title",r?(0,i.bM)(r,o.K.darkText).textColor:"text-tremor-content-strong dark:text-dark-tremor-content-strong",s)},d),l)});l.displayName="Title"},33866:function(t,e,r){r.d(e,{Z:function(){return I}});var n=r(2265),o=r(36760),a=r.n(o),i=r(66632),c=r(93350),l=r(19722),s=r(71744),d=r(93463),u=r(12918),m=r(18536),g=r(71140),p=r(99320);let b=new d.E4("antStatusProcessing",{"0%":{transform:"scale(0.8)",opacity:.5},"100%":{transform:"scale(2.4)",opacity:0}}),f=new d.E4("antZoomBadgeIn",{"0%":{transform:"scale(0) translate(50%, -50%)",opacity:0},"100%":{transform:"scale(1) translate(50%, -50%)"}}),h=new d.E4("antZoomBadgeOut",{"0%":{transform:"scale(1) translate(50%, -50%)"},"100%":{transform:"scale(0) translate(50%, -50%)",opacity:0}}),v=new d.E4("antNoWrapperZoomBadgeIn",{"0%":{transform:"scale(0)",opacity:0},"100%":{transform:"scale(1)"}}),y=new d.E4("antNoWrapperZoomBadgeOut",{"0%":{transform:"scale(1)"},"100%":{transform:"scale(0)",opacity:0}}),w=new d.E4("antBadgeLoadingCircle",{"0%":{transformOrigin:"50%"},"100%":{transform:"translate(50%, -50%) rotate(360deg)",transformOrigin:"50%"}}),x=t=>{let{componentCls:e,iconCls:r,antCls:n,badgeShadowSize:o,textFontSize:a,textFontSizeSM:i,statusSize:c,dotSize:l,textFontWeight:s,indicatorHeight:g,indicatorHeightSM:p,marginXS:x,calc:k}=t,O="".concat(n,"-scroll-number"),C=(0,m.Z)(t,(t,r)=>{let{darkColor:n}=r;return{["&".concat(e," ").concat(e,"-color-").concat(t)]:{background:n,["&:not(".concat(e,"-count)")]:{color:n},"a:hover &":{background:n}}}});return{[e]:Object.assign(Object.assign(Object.assign(Object.assign({},(0,u.Wf)(t)),{position:"relative",display:"inline-block",width:"fit-content",lineHeight:1,["".concat(e,"-count")]:{display:"inline-flex",justifyContent:"center",zIndex:t.indicatorZIndex,minWidth:g,height:g,color:t.badgeTextColor,fontWeight:s,fontSize:a,lineHeight:(0,d.bf)(g),whiteSpace:"nowrap",textAlign:"center",background:t.badgeColor,borderRadius:k(g).div(2).equal(),boxShadow:"0 0 0 ".concat((0,d.bf)(o)," ").concat(t.badgeShadowColor),transition:"background ".concat(t.motionDurationMid),a:{color:t.badgeTextColor},"a:hover":{color:t.badgeTextColor},"a:hover &":{background:t.badgeColorHover}},["".concat(e,"-count-sm")]:{minWidth:p,height:p,fontSize:i,lineHeight:(0,d.bf)(p),borderRadius:k(p).div(2).equal()},["".concat(e,"-multiple-words")]:{padding:"0 ".concat((0,d.bf)(t.paddingXS)),bdi:{unicodeBidi:"plaintext"}},["".concat(e,"-dot")]:{zIndex:t.indicatorZIndex,width:l,minWidth:l,height:l,background:t.badgeColor,borderRadius:"100%",boxShadow:"0 0 0 ".concat((0,d.bf)(o)," ").concat(t.badgeShadowColor)},["".concat(e,"-count, ").concat(e,"-dot, ").concat(O,"-custom-component")]:{position:"absolute",top:0,insetInlineEnd:0,transform:"translate(50%, -50%)",transformOrigin:"100% 0%",["&".concat(r,"-spin")]:{animationName:w,animationDuration:"1s",animationIterationCount:"infinite",animationTimingFunction:"linear"}},["&".concat(e,"-status")]:{lineHeight:"inherit",verticalAlign:"baseline",["".concat(e,"-status-dot")]:{position:"relative",top:-1,display:"inline-block",width:c,height:c,verticalAlign:"middle",borderRadius:"50%"},["".concat(e,"-status-success")]:{backgroundColor:t.colorSuccess},["".concat(e,"-status-processing")]:{overflow:"visible",color:t.colorInfo,backgroundColor:t.colorInfo,borderColor:"currentcolor","&::after":{position:"absolute",top:0,insetInlineStart:0,width:"100%",height:"100%",borderWidth:o,borderStyle:"solid",borderColor:"inherit",borderRadius:"50%",animationName:b,animationDuration:t.badgeProcessingDuration,animationIterationCount:"infinite",animationTimingFunction:"ease-in-out",content:'""'}},["".concat(e,"-status-default")]:{backgroundColor:t.colorTextPlaceholder},["".concat(e,"-status-error")]:{backgroundColor:t.colorError},["".concat(e,"-status-warning")]:{backgroundColor:t.colorWarning},["".concat(e,"-status-text")]:{marginInlineStart:x,color:t.colorText,fontSize:t.fontSize}}}),C),{["".concat(e,"-zoom-appear, ").concat(e,"-zoom-enter")]:{animationName:f,animationDuration:t.motionDurationSlow,animationTimingFunction:t.motionEaseOutBack,animationFillMode:"both"},["".concat(e,"-zoom-leave")]:{animationName:h,animationDuration:t.motionDurationSlow,animationTimingFunction:t.motionEaseOutBack,animationFillMode:"both"},["&".concat(e,"-not-a-wrapper")]:{["".concat(e,"-zoom-appear, ").concat(e,"-zoom-enter")]:{animationName:v,animationDuration:t.motionDurationSlow,animationTimingFunction:t.motionEaseOutBack},["".concat(e,"-zoom-leave")]:{animationName:y,animationDuration:t.motionDurationSlow,animationTimingFunction:t.motionEaseOutBack},["&:not(".concat(e,"-status)")]:{verticalAlign:"middle"},["".concat(O,"-custom-component, ").concat(e,"-count")]:{transform:"none"},["".concat(O,"-custom-component, ").concat(O)]:{position:"relative",top:"auto",display:"block",transformOrigin:"50% 50%"}},[O]:{overflow:"hidden",transition:"all ".concat(t.motionDurationMid," ").concat(t.motionEaseOutBack),["".concat(O,"-only")]:{position:"relative",display:"inline-block",height:g,transition:"all ".concat(t.motionDurationSlow," ").concat(t.motionEaseOutBack),WebkitTransformStyle:"preserve-3d",WebkitBackfaceVisibility:"hidden",["> p".concat(O,"-only-unit")]:{height:g,margin:0,WebkitTransformStyle:"preserve-3d",WebkitBackfaceVisibility:"hidden"}},["".concat(O,"-symbol")]:{verticalAlign:"top"}},"&-rtl":{direction:"rtl",["".concat(e,"-count, ").concat(e,"-dot, ").concat(O,"-custom-component")]:{transform:"translate(-50%, -50%)"}}})}},k=t=>{let{fontHeight:e,lineWidth:r,marginXS:n,colorBorderBg:o}=t,a=t.colorTextLightSolid,i=t.colorError,c=t.colorErrorHover;return(0,g.IX)(t,{badgeFontHeight:e,badgeShadowSize:r,badgeTextColor:a,badgeColor:i,badgeColorHover:c,badgeShadowColor:o,badgeProcessingDuration:"1.2s",badgeRibbonOffset:n,badgeRibbonCornerTransform:"scaleY(0.75)",badgeRibbonCornerFilter:"brightness(75%)"})},O=t=>{let{fontSize:e,lineHeight:r,fontSizeSM:n,lineWidth:o}=t;return{indicatorZIndex:"auto",indicatorHeight:Math.round(e*r)-2*o,indicatorHeightSM:e,dotSize:n/2,textFontSize:n,textFontSizeSM:n,textFontWeight:"normal",statusSize:n/2}};var C=(0,p.I$)("Badge",t=>x(k(t)),O);let E=t=>{let{antCls:e,badgeFontHeight:r,marginXS:n,badgeRibbonOffset:o,calc:a}=t,i="".concat(e,"-ribbon"),c=(0,m.Z)(t,(t,e)=>{let{darkColor:r}=e;return{["&".concat(i,"-color-").concat(t)]:{background:r,color:r}}});return{["".concat(e,"-ribbon-wrapper")]:{position:"relative"},[i]:Object.assign(Object.assign(Object.assign(Object.assign({},(0,u.Wf)(t)),{position:"absolute",top:n,padding:"0 ".concat((0,d.bf)(t.paddingXS)),color:t.colorPrimary,lineHeight:(0,d.bf)(r),whiteSpace:"nowrap",backgroundColor:t.colorPrimary,borderRadius:t.borderRadiusSM,["".concat(i,"-text")]:{color:t.badgeTextColor},["".concat(i,"-corner")]:{position:"absolute",top:"100%",width:o,height:o,color:"currentcolor",border:"".concat((0,d.bf)(a(o).div(2).equal())," solid"),transform:t.badgeRibbonCornerTransform,transformOrigin:"top",filter:t.badgeRibbonCornerFilter}}),c),{["&".concat(i,"-placement-end")]:{insetInlineEnd:a(o).mul(-1).equal(),borderEndEndRadius:0,["".concat(i,"-corner")]:{insetInlineEnd:0,borderInlineEndColor:"transparent",borderBlockEndColor:"transparent"}},["&".concat(i,"-placement-start")]:{insetInlineStart:a(o).mul(-1).equal(),borderEndStartRadius:0,["".concat(i,"-corner")]:{insetInlineStart:0,borderBlockEndColor:"transparent",borderInlineStartColor:"transparent"}},"&-rtl":{direction:"rtl"}})}};var S=(0,p.I$)(["Badge","Ribbon"],t=>E(k(t)),O);let N=t=>{let e;let{prefixCls:r,value:o,current:i,offset:c=0}=t;return c&&(e={position:"absolute",top:"".concat(c,"00%"),left:0}),n.createElement("span",{style:e,className:a()("".concat(r,"-only-unit"),{current:i})},o)};var j=t=>{let e,r;let{prefixCls:o,count:a,value:i}=t,c=Number(i),l=Math.abs(a),[s,d]=n.useState(c),[u,m]=n.useState(l),g=()=>{d(c),m(l)};if(n.useEffect(()=>{let t=setTimeout(g,1e3);return()=>clearTimeout(t)},[c]),s===c||Number.isNaN(c)||Number.isNaN(s))e=[n.createElement(N,Object.assign({},t,{key:c,current:!0}))],r={transition:"none"};else{e=[];let o=c+10,a=[];for(let t=c;t<=o;t+=1)a.push(t);let i=ut%10===s);e=(i<0?a.slice(0,d+1):a.slice(d)).map((e,r)=>n.createElement(N,Object.assign({},t,{key:e,value:e%10,offset:i<0?r-d:r,current:r===d}))),r={transform:"translateY(".concat(-function(t,e,r){let n=t,o=0;for(;(n+10)%10!==e;)n+=r,o+=r;return o}(s,c,i),"00%)")}}return n.createElement("span",{className:"".concat(o,"-only"),style:r,onTransitionEnd:g},e)},M=function(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&0>e.indexOf(n)&&(r[n]=t[n]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols)for(var o=0,n=Object.getOwnPropertySymbols(t);oe.indexOf(n[o])&&Object.prototype.propertyIsEnumerable.call(t,n[o])&&(r[n[o]]=t[n[o]]);return r};let z=n.forwardRef((t,e)=>{let{prefixCls:r,count:o,className:i,motionClassName:c,style:d,title:u,show:m,component:g="sup",children:p}=t,b=M(t,["prefixCls","count","className","motionClassName","style","title","show","component","children"]),{getPrefixCls:f}=n.useContext(s.E_),h=f("scroll-number",r),v=Object.assign(Object.assign({},b),{"data-show":m,style:d,className:a()(h,i,c),title:u}),y=o;if(o&&Number(o)%1==0){let t=String(o).split("");y=n.createElement("bdi",null,t.map((e,r)=>n.createElement(j,{prefixCls:h,count:Number(o),value:e,key:t.length-r})))}return((null==d?void 0:d.borderColor)&&(v.style=Object.assign(Object.assign({},d),{boxShadow:"0 0 0 1px ".concat(d.borderColor," inset")})),p)?(0,l.Tm)(p,t=>({className:a()("".concat(h,"-custom-component"),null==t?void 0:t.className,c)})):n.createElement(g,Object.assign({},v,{ref:e}),y)});var Z=function(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&0>e.indexOf(n)&&(r[n]=t[n]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols)for(var o=0,n=Object.getOwnPropertySymbols(t);oe.indexOf(n[o])&&Object.prototype.propertyIsEnumerable.call(t,n[o])&&(r[n[o]]=t[n[o]]);return r};let R=n.forwardRef((t,e)=>{var r,o,d,u,m;let{prefixCls:g,scrollNumberPrefixCls:p,children:b,status:f,text:h,color:v,count:y=null,overflowCount:w=99,dot:x=!1,size:k="default",title:O,offset:E,style:S,className:N,rootClassName:j,classNames:M,styles:R,showZero:I=!1}=t,L=Z(t,["prefixCls","scrollNumberPrefixCls","children","status","text","color","count","overflowCount","dot","size","title","offset","style","className","rootClassName","classNames","styles","showZero"]),{getPrefixCls:B,direction:T,badge:P}=n.useContext(s.E_),W=B("badge",g),[A,q,H]=C(W),G=y>w?"".concat(w,"+"):y,D="0"===G||0===G||"0"===h||0===h,K=null===y||D&&!I,V=(null!=f||null!=v)&&K,F=null!=f||!D,_=x&&!D,X=_?"":G,Y=(0,n.useMemo)(()=>((null==X||""===X)&&(null==h||""===h)||D&&!I)&&!_,[X,D,I,_,h]),$=(0,n.useRef)(y);Y||($.current=y);let U=$.current,J=(0,n.useRef)(X);Y||(J.current=X);let Q=J.current,tt=(0,n.useRef)(_);Y||(tt.current=_);let te=(0,n.useMemo)(()=>{if(!E)return Object.assign(Object.assign({},null==P?void 0:P.style),S);let t={marginTop:E[1]};return"rtl"===T?t.left=Number.parseInt(E[0],10):t.right=-Number.parseInt(E[0],10),Object.assign(Object.assign(Object.assign({},t),null==P?void 0:P.style),S)},[T,E,S,null==P?void 0:P.style]),tr=null!=O?O:"string"==typeof U||"number"==typeof U?U:void 0,tn=!Y&&(0===h?I:!!h&&!0!==h),to=tn?n.createElement("span",{className:"".concat(W,"-status-text")},h):null,ta=U&&"object"==typeof U?(0,l.Tm)(U,t=>({style:Object.assign(Object.assign({},te),t.style)})):void 0,ti=(0,c.o2)(v,!1),tc=a()(null==M?void 0:M.indicator,null===(r=null==P?void 0:P.classNames)||void 0===r?void 0:r.indicator,{["".concat(W,"-status-dot")]:V,["".concat(W,"-status-").concat(f)]:!!f,["".concat(W,"-color-").concat(v)]:ti}),tl={};v&&!ti&&(tl.color=v,tl.background=v);let ts=a()(W,{["".concat(W,"-status")]:V,["".concat(W,"-not-a-wrapper")]:!b,["".concat(W,"-rtl")]:"rtl"===T},N,j,null==P?void 0:P.className,null===(o=null==P?void 0:P.classNames)||void 0===o?void 0:o.root,null==M?void 0:M.root,q,H);if(!b&&V&&(h||F||!K)){let t=te.color;return A(n.createElement("span",Object.assign({},L,{className:ts,style:Object.assign(Object.assign(Object.assign({},null==R?void 0:R.root),null===(d=null==P?void 0:P.styles)||void 0===d?void 0:d.root),te)}),n.createElement("span",{className:tc,style:Object.assign(Object.assign(Object.assign({},null==R?void 0:R.indicator),null===(u=null==P?void 0:P.styles)||void 0===u?void 0:u.indicator),tl)}),tn&&n.createElement("span",{style:{color:t},className:"".concat(W,"-status-text")},h)))}return A(n.createElement("span",Object.assign({ref:e},L,{className:ts,style:Object.assign(Object.assign({},null===(m=null==P?void 0:P.styles)||void 0===m?void 0:m.root),null==R?void 0:R.root)}),b,n.createElement(i.ZP,{visible:!Y,motionName:"".concat(W,"-zoom"),motionAppear:!1,motionDeadline:1e3},t=>{var e,r;let{className:o}=t,i=B("scroll-number",p),c=tt.current,l=a()(null==M?void 0:M.indicator,null===(e=null==P?void 0:P.classNames)||void 0===e?void 0:e.indicator,{["".concat(W,"-dot")]:c,["".concat(W,"-count")]:!c,["".concat(W,"-count-sm")]:"small"===k,["".concat(W,"-multiple-words")]:!c&&Q&&Q.toString().length>1,["".concat(W,"-status-").concat(f)]:!!f,["".concat(W,"-color-").concat(v)]:ti}),s=Object.assign(Object.assign(Object.assign({},null==R?void 0:R.indicator),null===(r=null==P?void 0:P.styles)||void 0===r?void 0:r.indicator),te);return v&&!ti&&((s=s||{}).background=v),n.createElement(z,{prefixCls:i,show:!Y,motionClassName:o,className:l,count:Q,title:tr,style:s,key:"scrollNumber"},ta)}),to))});R.Ribbon=t=>{let{className:e,prefixCls:r,style:o,color:i,children:l,text:d,placement:u="end",rootClassName:m}=t,{getPrefixCls:g,direction:p}=n.useContext(s.E_),b=g("ribbon",r),f="".concat(b,"-wrapper"),[h,v,y]=S(b,f),w=(0,c.o2)(i,!1),x=a()(b,"".concat(b,"-placement-").concat(u),{["".concat(b,"-rtl")]:"rtl"===p,["".concat(b,"-color-").concat(i)]:w},e),k={},O={};return i&&!w&&(k.background=i,O.color=i),h(n.createElement("div",{className:a()(f,m,v,y)},l,n.createElement("div",{className:a()(x,v),style:Object.assign(Object.assign({},k),o)},n.createElement("span",{className:"".concat(b,"-text")},d),n.createElement("div",{className:"".concat(b,"-corner"),style:O}))))};var I=R},58760:function(t,e,r){r.d(e,{Z:function(){return S}});var n=r(2265),o=r(36760),a=r.n(o),i=r(45287);function c(t){return["small","middle","large"].includes(t)}function l(t){return!!t&&"number"==typeof t&&!Number.isNaN(t)}var s=r(71744),d=r(77685),u=r(17691),m=r(99320);let g=t=>{let{componentCls:e,borderRadius:r,paddingSM:n,colorBorder:o,paddingXS:a,fontSizeLG:i,fontSizeSM:c,borderRadiusLG:l,borderRadiusSM:s,colorBgContainerDisabled:d,lineWidth:m}=t;return{[e]:[{display:"inline-flex",alignItems:"center",gap:0,paddingInline:n,margin:0,background:d,borderWidth:m,borderStyle:"solid",borderColor:o,borderRadius:r,"&-large":{fontSize:i,borderRadius:l},"&-small":{paddingInline:a,borderRadius:s,fontSize:c},"&-compact-last-item":{borderEndStartRadius:0,borderStartStartRadius:0},"&-compact-first-item":{borderEndEndRadius:0,borderStartEndRadius:0},"&-compact-item:not(:first-child):not(:last-child)":{borderRadius:0},"&-compact-item:not(:last-child)":{borderInlineEndWidth:0}},(0,u.c)(t,{focus:!1})]}};var p=(0,m.I$)(["Space","Addon"],t=>[g(t)]),b=function(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&0>e.indexOf(n)&&(r[n]=t[n]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols)for(var o=0,n=Object.getOwnPropertySymbols(t);oe.indexOf(n[o])&&Object.prototype.propertyIsEnumerable.call(t,n[o])&&(r[n[o]]=t[n[o]]);return r};let f=n.forwardRef((t,e)=>{let{className:r,children:o,style:i,prefixCls:c}=t,l=b(t,["className","children","style","prefixCls"]),{getPrefixCls:u,direction:m}=n.useContext(s.E_),g=u("space-addon",c),[f,h,v]=p(g),{compactItemClassnames:y,compactSize:w}=(0,d.ri)(g,m),x=a()(g,h,y,v,{["".concat(g,"-").concat(w)]:w},r);return f(n.createElement("div",Object.assign({ref:e,className:x,style:i},l),o))}),h=n.createContext({latestIndex:0}),v=h.Provider;var y=t=>{let{className:e,index:r,children:o,split:a,style:i}=t,{latestIndex:c}=n.useContext(h);return null==o?null:n.createElement(n.Fragment,null,n.createElement("div",{className:e,style:i},o),r{let{componentCls:e,antCls:r}=t;return{[e]:{display:"inline-flex","&-rtl":{direction:"rtl"},"&-vertical":{flexDirection:"column"},"&-align":{flexDirection:"column","&-center":{alignItems:"center"},"&-start":{alignItems:"flex-start"},"&-end":{alignItems:"flex-end"},"&-baseline":{alignItems:"baseline"}},["".concat(e,"-item:empty")]:{display:"none"},["".concat(e,"-item > ").concat(r,"-badge-not-a-wrapper:only-child")]:{display:"block"}}}},k=t=>{let{componentCls:e}=t;return{[e]:{"&-gap-row-small":{rowGap:t.spaceGapSmallSize},"&-gap-row-middle":{rowGap:t.spaceGapMiddleSize},"&-gap-row-large":{rowGap:t.spaceGapLargeSize},"&-gap-col-small":{columnGap:t.spaceGapSmallSize},"&-gap-col-middle":{columnGap:t.spaceGapMiddleSize},"&-gap-col-large":{columnGap:t.spaceGapLargeSize}}}};var O=(0,m.I$)("Space",t=>{let e=(0,w.IX)(t,{spaceGapSmallSize:t.paddingXS,spaceGapMiddleSize:t.padding,spaceGapLargeSize:t.paddingLG});return[x(e),k(e)]},()=>({}),{resetStyle:!1}),C=function(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&0>e.indexOf(n)&&(r[n]=t[n]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols)for(var o=0,n=Object.getOwnPropertySymbols(t);oe.indexOf(n[o])&&Object.prototype.propertyIsEnumerable.call(t,n[o])&&(r[n[o]]=t[n[o]]);return r};let E=n.forwardRef((t,e)=>{var r;let{getPrefixCls:o,direction:d,size:u,className:m,style:g,classNames:p,styles:b}=(0,s.dj)("space"),{size:f=null!=u?u:"small",align:h,className:w,rootClassName:x,children:k,direction:E="horizontal",prefixCls:S,split:N,style:j,wrap:M=!1,classNames:z,styles:Z}=t,R=C(t,["size","align","className","rootClassName","children","direction","prefixCls","split","style","wrap","classNames","styles"]),[I,L]=Array.isArray(f)?f:[f,f],B=c(L),T=c(I),P=l(L),W=l(I),A=(0,i.Z)(k,{keepEmpty:!0}),q=void 0===h&&"horizontal"===E?"center":h,H=o("space",S),[G,D,K]=O(H),V=a()(H,m,D,"".concat(H,"-").concat(E),{["".concat(H,"-rtl")]:"rtl"===d,["".concat(H,"-align-").concat(q)]:q,["".concat(H,"-gap-row-").concat(L)]:B,["".concat(H,"-gap-col-").concat(I)]:T},w,x,K),F=a()("".concat(H,"-item"),null!==(r=null==z?void 0:z.item)&&void 0!==r?r:p.item),_=Object.assign(Object.assign({},b.item),null==Z?void 0:Z.item),X=A.map((t,e)=>{let r=(null==t?void 0:t.key)||"".concat(F,"-").concat(e);return n.createElement(y,{className:F,key:r,index:e,split:N,style:_},t)}),Y=n.useMemo(()=>({latestIndex:A.reduce((t,e,r)=>null!=e?r:t,0)}),[A]);if(0===A.length)return null;let $={};return M&&($.flexWrap="wrap"),!T&&W&&($.columnGap=I),!B&&P&&($.rowGap=L),G(n.createElement("div",Object.assign({ref:e,className:V,style:Object.assign(Object.assign(Object.assign({},$),g),j)},R),n.createElement(v,{value:Y},X)))});E.Compact=d.ZP,E.Addon=f;var S=E},79205:function(t,e,r){r.d(e,{Z:function(){return u}});var n=r(2265);let o=t=>t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),a=t=>t.replace(/^([A-Z])|[\s-_]+(\w)/g,(t,e,r)=>r?r.toUpperCase():e.toLowerCase()),i=t=>{let e=a(t);return e.charAt(0).toUpperCase()+e.slice(1)},c=function(){for(var t=arguments.length,e=Array(t),r=0;r!!t&&""!==t.trim()&&r.indexOf(t)===e).join(" ").trim()},l=t=>{for(let e in t)if(e.startsWith("aria-")||"role"===e||"title"===e)return!0};var s={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};let d=(0,n.forwardRef)((t,e)=>{let{color:r="currentColor",size:o=24,strokeWidth:a=2,absoluteStrokeWidth:i,className:d="",children:u,iconNode:m,...g}=t;return(0,n.createElement)("svg",{ref:e,...s,width:o,height:o,stroke:r,strokeWidth:i?24*Number(a)/Number(o):a,className:c("lucide",d),...!u&&!l(g)&&{"aria-hidden":"true"},...g},[...m.map(t=>{let[e,r]=t;return(0,n.createElement)(e,r)}),...Array.isArray(u)?u:[u]])}),u=(t,e)=>{let r=(0,n.forwardRef)((r,a)=>{let{className:l,...s}=r;return(0,n.createElement)(d,{ref:a,iconNode:e,className:c("lucide-".concat(o(i(t))),"lucide-".concat(t),l),...s})});return r.displayName=i(t),r}},30401:function(t,e,r){r.d(e,{Z:function(){return n}});let n=(0,r(79205).Z)("check",[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]])},64935:function(t,e,r){r.d(e,{Z:function(){return n}});let n=(0,r(79205).Z)("code",[["path",{d:"m16 18 6-6-6-6",key:"eg8j8"}],["path",{d:"m8 6-6 6 6 6",key:"ppft3o"}]])},78867:function(t,e,r){r.d(e,{Z:function(){return n}});let n=(0,r(79205).Z)("copy",[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]])},96362:function(t,e,r){r.d(e,{Z:function(){return n}});let n=(0,r(79205).Z)("external-link",[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]])},29202:function(t,e,r){r.d(e,{Z:function(){return n}});let n=(0,r(79205).Z)("globe",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20",key:"13o1zl"}],["path",{d:"M2 12h20",key:"9i4pu4"}]])},54001:function(t,e,r){r.d(e,{Z:function(){return n}});let n=(0,r(79205).Z)("key",[["path",{d:"m15.5 7.5 2.3 2.3a1 1 0 0 0 1.4 0l2.1-2.1a1 1 0 0 0 0-1.4L19 4",key:"g0fldk"}],["path",{d:"m21 2-9.6 9.6",key:"1j0ho8"}],["circle",{cx:"7.5",cy:"15.5",r:"5.5",key:"yqb3hr"}]])},96137:function(t,e,r){r.d(e,{Z:function(){return n}});let n=(0,r(79205).Z)("server",[["rect",{width:"20",height:"8",x:"2",y:"2",rx:"2",ry:"2",key:"ngkwjq"}],["rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",ry:"2",key:"iecqi9"}],["line",{x1:"6",x2:"6.01",y1:"6",y2:"6",key:"16zg32"}],["line",{x1:"6",x2:"6.01",y1:"18",y2:"18",key:"nzw8ys"}]])},80221:function(t,e,r){r.d(e,{Z:function(){return n}});let n=(0,r(79205).Z)("terminal",[["path",{d:"M12 19h8",key:"baeox8"}],["path",{d:"m4 17 6-6-6-6",key:"1yngyt"}]])},11239:function(t,e,r){r.d(e,{Z:function(){return n}});let n=(0,r(79205).Z)("zap",[["path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z",key:"1xq2db"}]])},10900:function(t,e,r){var n=r(2265);let o=n.forwardRef(function(t,e){return n.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:2,stroke:"currentColor","aria-hidden":"true",ref:e},t),n.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M10 19l-7-7m0 0l7-7m-7 7h18"}))});e.Z=o},71437:function(t,e,r){var n=r(2265);let o=n.forwardRef(function(t,e){return n.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:2,stroke:"currentColor","aria-hidden":"true",ref:e},t),n.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M15 12a3 3 0 11-6 0 3 3 0 016 0z"}),n.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M2.458 12C3.732 7.943 7.523 5 12 5c4.478 0 8.268 2.943 9.542 7-1.274 4.057-5.064 7-9.542 7-4.477 0-8.268-2.943-9.542-7z"}))});e.Z=o},82376:function(t,e,r){var n=r(2265);let o=n.forwardRef(function(t,e){return n.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:2,stroke:"currentColor","aria-hidden":"true",ref:e},t),n.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M13.875 18.825A10.05 10.05 0 0112 19c-4.478 0-8.268-2.943-9.543-7a9.97 9.97 0 011.563-3.029m5.858.908a3 3 0 114.243 4.243M9.878 9.878l4.242 4.242M9.88 9.88l-3.29-3.29m7.532 7.532l3.29 3.29M3 3l3.59 3.59m0 0A9.953 9.953 0 0112 5c4.478 0 8.268 2.943 9.543 7a10.025 10.025 0 01-4.132 5.411m0 0L21 21"}))});e.Z=o},53410:function(t,e,r){var n=r(2265);let o=n.forwardRef(function(t,e){return n.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:2,stroke:"currentColor","aria-hidden":"true",ref:e},t),n.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z"}))});e.Z=o},74998:function(t,e,r){var n=r(2265);let o=n.forwardRef(function(t,e){return n.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:2,stroke:"currentColor","aria-hidden":"true",ref:e},t),n.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16"}))});e.Z=o},21770:function(t,e,r){r.d(e,{D:function(){return d}});var n=r(2265),o=r(2894),a=r(18238),i=r(24112),c=r(45345),l=class extends i.l{#t;#e=void 0;#r;#n;constructor(t,e){super(),this.#t=t,this.setOptions(e),this.bindMethods(),this.#o()}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(t){let e=this.options;this.options=this.#t.defaultMutationOptions(t),(0,c.VS)(this.options,e)||this.#t.getMutationCache().notify({type:"observerOptionsUpdated",mutation:this.#r,observer:this}),e?.mutationKey&&this.options.mutationKey&&(0,c.Ym)(e.mutationKey)!==(0,c.Ym)(this.options.mutationKey)?this.reset():this.#r?.state.status==="pending"&&this.#r.setOptions(this.options)}onUnsubscribe(){this.hasListeners()||this.#r?.removeObserver(this)}onMutationUpdate(t){this.#o(),this.#a(t)}getCurrentResult(){return this.#e}reset(){this.#r?.removeObserver(this),this.#r=void 0,this.#o(),this.#a()}mutate(t,e){return this.#n=e,this.#r?.removeObserver(this),this.#r=this.#t.getMutationCache().build(this.#t,this.options),this.#r.addObserver(this),this.#r.execute(t)}#o(){let t=this.#r?.state??(0,o.R)();this.#e={...t,isPending:"pending"===t.status,isSuccess:"success"===t.status,isError:"error"===t.status,isIdle:"idle"===t.status,mutate:this.mutate,reset:this.reset}}#a(t){a.Vr.batch(()=>{if(this.#n&&this.hasListeners()){let e=this.#e.variables,r=this.#e.context,n={client:this.#t,meta:this.options.meta,mutationKey:this.options.mutationKey};t?.type==="success"?(this.#n.onSuccess?.(t.data,e,r,n),this.#n.onSettled?.(t.data,null,e,r,n)):t?.type==="error"&&(this.#n.onError?.(t.error,e,r,n),this.#n.onSettled?.(void 0,t.error,e,r,n))}this.listeners.forEach(t=>{t(this.#e)})})}},s=r(29827);function d(t,e){let r=(0,s.NL)(e),[o]=n.useState(()=>new l(r,t));n.useEffect(()=>{o.setOptions(t)},[o,t]);let i=n.useSyncExternalStore(n.useCallback(t=>o.subscribe(a.Vr.batchCalls(t)),[o]),()=>o.getCurrentResult(),()=>o.getCurrentResult()),d=n.useCallback((t,e)=>{o.mutate(t,e).catch(c.ZT)},[o]);if(i.error&&(0,c.L3)(o.options.throwOnError,[i.error]))throw i.error;return{...i,mutate:d,mutateAsync:i.mutate}}}}]); \ No newline at end of file diff --git a/litellm/proxy/_experimental/out/_next/static/chunks/1067d2c077cd73d6.js b/litellm/proxy/_experimental/out/_next/static/chunks/1067d2c077cd73d6.js new file mode 100644 index 00000000000..0379598998b --- /dev/null +++ b/litellm/proxy/_experimental/out/_next/static/chunks/1067d2c077cd73d6.js @@ -0,0 +1,4 @@ +(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,751734,e=>{"use strict";let t=(0,e.i(271645).createContext)(0);e.s(["default",()=>t])},144582,e=>{"use strict";let t=(0,e.i(271645).createContext)({selectedValue:void 0,handleValueChange:void 0});e.s(["default",()=>t])},404206,e=>{"use strict";var t=e.i(290571),r=e.i(751734),n=e.i(144582),o=e.i(444755),a=e.i(673706),s=e.i(271645);let l=(0,a.makeClassName)("TabPanel"),i=s.default.forwardRef((e,a)=>{let{children:i,className:u}=e,c=(0,t.__rest)(e,["children","className"]),{selectedValue:d}=(0,s.useContext)(n.default),f=d===(0,s.useContext)(r.default);return s.default.createElement("div",Object.assign({ref:a,className:(0,o.tremorTwMerge)(l("root"),"w-full mt-2",f?"":"hidden",u),"aria-selected":f?"true":"false"},c),i)});i.displayName="TabPanel",e.s(["TabPanel",()=>i],404206)},429427,371330,80758,402155,368578,544508,746725,835696,941444,914189,394487,e=>{"use strict";let t;e.i(247167);var r=e.i(271645);let n="u">typeof document?r.default.useLayoutEffect:()=>{},o=e=>{var t;return null!=(t=null==e?void 0:e.ownerDocument)?t:document},a=e=>e&&"window"in e&&e.window===e?e:o(e).defaultView||window;"u">typeof Element&&Element.prototype;let s=["input:not([disabled]):not([type=hidden])","select:not([disabled])","textarea:not([disabled])","button:not([disabled])","a[href]","area[href]","summary","iframe","object","embed","audio[controls]","video[controls]",'[contenteditable]:not([contenteditable^="false"])',"permission"];s.join(":not([hidden]),"),s.push('[tabindex]:not([tabindex="-1"]):not([disabled])'),s.join(':not([hidden]):not([tabindex="-1"]),');let l=null;function i(e){return e.nativeEvent=e,e.isDefaultPrevented=()=>e.defaultPrevented,e.isPropagationStopped=()=>e.cancelBubble,e.persist=()=>{},e}function u(e){let t=(0,r.useRef)({isFocused:!1,observer:null});return n(()=>{let e=t.current;return()=>{e.observer&&(e.observer.disconnect(),e.observer=null)}},[]),(0,r.useCallback)(r=>{if(r.target instanceof HTMLButtonElement||r.target instanceof HTMLInputElement||r.target instanceof HTMLTextAreaElement||r.target instanceof HTMLSelectElement){t.current.isFocused=!0;let n=r.target;n.addEventListener("focusout",r=>{if(t.current.isFocused=!1,n.disabled){let t=i(r);null==e||e(t)}t.current.observer&&(t.current.observer.disconnect(),t.current.observer=null)},{once:!0}),t.current.observer=new MutationObserver(()=>{if(t.current.isFocused&&n.disabled){var e;null==(e=t.current.observer)||e.disconnect();let r=n===document.activeElement?null:document.activeElement;n.dispatchEvent(new FocusEvent("blur",{relatedTarget:r})),n.dispatchEvent(new FocusEvent("focusout",{bubbles:!0,relatedTarget:r}))}}),t.current.observer.observe(n,{attributes:!0,attributeFilter:["disabled"]})}},[e])}function c(e){var t;if("u"e.test(t.brand))||e.test(window.navigator.userAgent)}function d(e){var t;return"u">typeof window&&null!=window.navigator&&e.test((null==(t=window.navigator.userAgentData)?void 0:t.platform)||window.navigator.platform)}function f(e){let t=null;return()=>(null==t&&(t=e()),t)}let p=f(function(){return d(/^Mac/i)}),m=f(function(){return d(/^iPhone/i)}),v=f(function(){return d(/^iPad/i)||p()&&navigator.maxTouchPoints>1}),b=f(function(){return m()||v()});f(function(){return p()||b()});let g=f(function(){return c(/AppleWebKit/i)&&!h()}),h=f(function(){return c(/Chrome/i)}),y=f(function(){return c(/Android/i)}),E=f(function(){return c(/Firefox/i)});function w(e,t,r=!0){var n,o;let{metaKey:a,ctrlKey:s,altKey:i,shiftKey:u}=t;E()&&(null==(o=window.event)||null==(n=o.type)?void 0:n.startsWith("key"))&&"_blank"===e.target&&(p()?a=!0:s=!0);let c=g()&&p()&&!v()&&1?new KeyboardEvent("keydown",{keyIdentifier:"Enter",metaKey:a,ctrlKey:s,altKey:i,shiftKey:u}):new MouseEvent("click",{metaKey:a,ctrlKey:s,altKey:i,shiftKey:u,detail:1,bubbles:!0,cancelable:!0});if(w.isOpening=r,function(){if(null==l){l=!1;try{document.createElement("div").focus({get preventScroll(){return l=!0,!0}})}catch{}}return l}())e.focus({preventScroll:!0});else{let t=function(e){let t=e.parentNode,r=[],n=document.scrollingElement||document.documentElement;for(;t instanceof HTMLElement&&t!==n;)(t.offsetHeighttypeof window&&window.document&&window.document.createElement,new WeakMap;r.default.useId;let x=null,F=new Set,P=new Map,k=!1,L=!1,N={Tab:!0,Escape:!0};function C(e,t){for(let r of F)r(e,t)}function I(e){k=!0,w.isOpening||e.metaKey||!p()&&e.altKey||e.ctrlKey||"Control"===e.key||"Shift"===e.key||"Meta"===e.key||(x="keyboard",C("keyboard",e))}function S(e){x="pointer","pointerType"in e&&e.pointerType,("mousedown"===e.type||"pointerdown"===e.type)&&(k=!0,C("pointer",e))}function A(e){w.isOpening||(""!==e.pointerType||!e.isTrusted)&&(y()&&e.pointerType?"click"!==e.type||1!==e.buttons:0!==e.detail||e.pointerType)||(k=!0,x="virtual")}function M(e){e.target!==window&&e.target!==document&&e.isTrusted&&(k||L||(x="virtual",C("virtual",e)),k=!1,L=!1)}function R(){k=!1,L=!0}function O(e){if("u"typeof PointerEvent&&(r.addEventListener("pointerdown",S,!0),r.addEventListener("pointermove",S,!0),r.addEventListener("pointerup",S,!0)),t.addEventListener("beforeunload",()=>{D(e)},{once:!0}),P.set(t,{focus:n})}let D=(e,t)=>{let r=a(e),n=o(e);t&&n.removeEventListener("DOMContentLoaded",t),P.has(r)&&(r.HTMLElement.prototype.focus=P.get(r).focus,n.removeEventListener("keydown",I,!0),n.removeEventListener("keyup",I,!0),n.removeEventListener("click",A,!0),r.removeEventListener("focus",M,!0),r.removeEventListener("blur",R,!1),"u">typeof PointerEvent&&(n.removeEventListener("pointerdown",S,!0),n.removeEventListener("pointermove",S,!0),n.removeEventListener("pointerup",S,!0)),P.delete(r))};function H(){return"pointer"!==x}"u">typeof document&&("loading"!==(t=o(void 0)).readyState?O(void 0):t.addEventListener("DOMContentLoaded",()=>{O(void 0)}));let j=new Set(["checkbox","radio","range","color","file","image","button","submit","reset"]);function K(e,t){return!!t&&!!e&&e.contains(t)}function W(){let e=(0,r.useRef)(new Map),t=(0,r.useCallback)((t,r,n,o)=>{let a=(null==o?void 0:o.once)?(...t)=>{e.current.delete(n),n(...t)}:n;e.current.set(n,{type:r,eventTarget:t,fn:a,options:o}),t.addEventListener(r,a,o)},[]),n=(0,r.useCallback)((t,r,n,o)=>{var a;let s=(null==(a=e.current.get(n))?void 0:a.fn)||n;t.removeEventListener(r,s,o),e.current.delete(n)},[]),o=(0,r.useCallback)(()=>{e.current.forEach((e,t)=>{n(e.eventTarget,e.type,t,e.options)})},[n]);return(0,r.useEffect)(()=>o,[o]),{addGlobalListener:t,removeGlobalListener:n,removeAllGlobalListeners:o}}function B(e={}){var t;let{autoFocus:n=!1,isTextInput:s,within:l}=e,c=(0,r.useRef)({isFocused:!1,isFocusVisible:n||H()}),[d,f]=(0,r.useState)(!1),[p,m]=(0,r.useState)(()=>c.current.isFocused&&c.current.isFocusVisible),v=(0,r.useCallback)(()=>m(c.current.isFocused&&c.current.isFocusVisible),[]),b=(0,r.useCallback)(e=>{c.current.isFocused=e,f(e),v()},[v]);t={isTextInput:s},O(),(0,r.useEffect)(()=>{let e=(e,r)=>{var n;let s,l,i,u,d;n=!!(null==t?void 0:t.isTextInput),s=o(null==r?void 0:r.target),l="u">typeof window?a(null==r?void 0:r.target).HTMLInputElement:HTMLInputElement,i="u">typeof window?a(null==r?void 0:r.target).HTMLTextAreaElement:HTMLTextAreaElement,u="u">typeof window?a(null==r?void 0:r.target).HTMLElement:HTMLElement,d="u">typeof window?a(null==r?void 0:r.target).KeyboardEvent:KeyboardEvent,(n=n||s.activeElement instanceof l&&!j.has(s.activeElement.type)||s.activeElement instanceof i||s.activeElement instanceof u&&s.activeElement.isContentEditable)&&"keyboard"===e&&r instanceof d&&!N[r.key]||(e=>{c.current.isFocusVisible=e,v()})(H())};return F.add(e),()=>{F.delete(e)}},[]);let{focusProps:g}=function(e){let{isDisabled:t,onFocus:n,onBlur:a,onFocusChange:s}=e,l=(0,r.useCallback)(e=>{if(e.target===e.currentTarget)return a&&a(e),s&&s(!1),!0},[a,s]),i=u(l),c=(0,r.useCallback)(e=>{var t;let r=o(e.target),a=r?((e=document)=>e.activeElement)(r):((e=document)=>e.activeElement)();e.target===e.currentTarget&&a===(t=e.nativeEvent,t.target)&&(n&&n(e),s&&s(!0),i(e))},[s,n,i]);return{focusProps:{onFocus:!t&&(n||s||a)?c:void 0,onBlur:!t&&(a||s)?l:void 0}}}({isDisabled:l,onFocusChange:b}),{focusWithinProps:h}=function(e){let{isDisabled:t,onBlurWithin:n,onFocusWithin:a,onFocusWithinChange:s}=e,l=(0,r.useRef)({isFocusWithin:!1}),{addGlobalListener:c,removeAllGlobalListeners:d}=W(),f=(0,r.useCallback)(e=>{e.currentTarget.contains(e.target)&&l.current.isFocusWithin&&!e.currentTarget.contains(e.relatedTarget)&&(l.current.isFocusWithin=!1,d(),n&&n(e),s&&s(!1))},[n,s,l,d]),p=u(f),m=(0,r.useCallback)(e=>{var t;if(!e.currentTarget.contains(e.target))return;let r=o(e.target),n=((e=document)=>e.activeElement)(r);if(!l.current.isFocusWithin&&n===(t=e.nativeEvent,t.target)){a&&a(e),s&&s(!0),l.current.isFocusWithin=!0,p(e);let t=e.currentTarget;c(r,"focus",e=>{if(l.current.isFocusWithin&&!K(t,e.target)){let n=new r.defaultView.FocusEvent("blur",{relatedTarget:e.target});Object.defineProperty(n,"target",{value:t}),Object.defineProperty(n,"currentTarget",{value:t}),f(i(n))}},{capture:!0})}},[a,s,p,c,f]);return t?{focusWithinProps:{onFocus:void 0,onBlur:void 0}}:{focusWithinProps:{onFocus:m,onBlur:f}}}({isDisabled:!l,onFocusWithinChange:b});return{isFocused:d,isFocusVisible:p,focusProps:l?h:g}}e.s(["useFocusRing",()=>B],429427);let V=!1,_=0;function G(e){"touch"===e.pointerType&&(V=!0,setTimeout(()=>{V=!1},50))}function U(){if("u">typeof document)return 0===_&&"u">typeof PointerEvent&&document.addEventListener("pointerup",G),_++,()=>{!(--_>0)&&"u">typeof PointerEvent&&document.removeEventListener("pointerup",G)}}function $(e){let{onHoverStart:t,onHoverChange:n,onHoverEnd:a,isDisabled:s}=e,[l,i]=(0,r.useState)(!1),u=(0,r.useRef)({isHovered:!1,ignoreEmulatedMouseEvents:!1,pointerType:"",target:null}).current;(0,r.useEffect)(U,[]);let{addGlobalListener:c,removeAllGlobalListeners:d}=W(),{hoverProps:f,triggerHoverEnd:p}=(0,r.useMemo)(()=>{let e=(e,t)=>{let r=u.target;u.pointerType="",u.target=null,"touch"!==t&&u.isHovered&&r&&(u.isHovered=!1,d(),a&&a({type:"hoverend",target:r,pointerType:t}),n&&n(!1),i(!1))},r={};return"u">typeof PointerEvent&&(r.onPointerEnter=r=>{V&&"mouse"===r.pointerType||((r,a)=>{if(u.pointerType=a,s||"touch"===a||u.isHovered||!r.currentTarget.contains(r.target))return;u.isHovered=!0;let l=r.currentTarget;u.target=l,c(o(r.target),"pointerover",t=>{u.isHovered&&u.target&&!K(u.target,t.target)&&e(t,t.pointerType)},{capture:!0}),t&&t({type:"hoverstart",target:l,pointerType:a}),n&&n(!0),i(!0)})(r,r.pointerType)},r.onPointerLeave=t=>{!s&&t.currentTarget.contains(t.target)&&e(t,t.pointerType)}),{hoverProps:r,triggerHoverEnd:e}},[t,n,a,s,u,c,d]);return(0,r.useEffect)(()=>{s&&p({currentTarget:u.target},u.pointerType)},[s]),{hoverProps:f,isHovered:l}}e.s(["useHover",()=>$],371330);var q=Object.defineProperty,X=(e,t,r)=>{let n;return(n="symbol"!=typeof t?t+"":t)in e?q(e,n,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[n]=r,r};let Y=new class{constructor(){X(this,"current",this.detect()),X(this,"handoffState","pending"),X(this,"currentId",0)}set(e){this.current!==e&&(this.handoffState="pending",this.currentId=0,this.current=e)}reset(){this.set(this.detect())}nextId(){return++this.currentId}get isServer(){return"server"===this.current}get isClient(){return"client"===this.current}detect(){return"u"setTimeout(()=>{throw e}))}function J(){let e=[],t={addEventListener:(e,r,n,o)=>(e.addEventListener(r,n,o),t.add(()=>e.removeEventListener(r,n,o))),requestAnimationFrame(...e){let r=requestAnimationFrame(...e);return t.add(()=>cancelAnimationFrame(r))},nextFrame:(...e)=>t.requestAnimationFrame(()=>t.requestAnimationFrame(...e)),setTimeout(...e){let r=setTimeout(...e);return t.add(()=>clearTimeout(r))},microTask(...e){let r={current:!0};return Z(()=>{r.current&&e[0]()}),t.add(()=>{r.current=!1})},style(e,t,r){let n=e.style.getPropertyValue(t);return Object.assign(e.style,{[t]:r}),this.add(()=>{Object.assign(e.style,{[t]:n})})},group(e){let t=J();return e(t),this.add(()=>t.dispose())},add:t=>(e.includes(t)||e.push(t),()=>{let r=e.indexOf(t);if(r>=0)for(let t of e.splice(r,1))t()}),dispose(){for(let t of e.splice(0))t()}};return t}function Q(){let[e]=(0,r.useState)(J);return(0,r.useEffect)(()=>()=>e.dispose(),[e]),e}e.s(["env",()=>Y],80758),e.s(["getOwnerDocument",()=>z],402155),e.s(["microTask",()=>Z],368578),e.s(["disposables",()=>J],544508),e.s(["useDisposables",()=>Q],746725);let ee=(e,t)=>{Y.isServer?(0,r.useEffect)(e,t):(0,r.useLayoutEffect)(e,t)};function et(e){let t=(0,r.useRef)(e);return ee(()=>{t.current=e},[e]),t}e.s(["useIsoMorphicEffect",()=>ee],835696),e.s(["useLatestValue",()=>et],941444);let er=function(e){let t=et(e);return r.default.useCallback((...e)=>t.current(...e),[t])};function en({disabled:e=!1}={}){let t=(0,r.useRef)(null),[n,o]=(0,r.useState)(!1),a=Q(),s=er(()=>{t.current=null,o(!1),a.dispose()}),l=er(e=>{if(a.dispose(),null===t.current){t.current=e.currentTarget,o(!0);{let r=z(e.currentTarget);a.addEventListener(r,"pointerup",s,!1),a.addEventListener(r,"pointermove",e=>{if(t.current){var r,n;let a,s;o((a=e.width/2,s=e.height/2,r={top:e.clientY-s,right:e.clientX+a,bottom:e.clientY+s,left:e.clientX-a},n=t.current.getBoundingClientRect(),!(!r||!n||r.rightn.right||r.bottomn.bottom)))}},!1),a.addEventListener(r,"pointercancel",s,!1)}}});return{pressed:n,pressProps:e?{}:{onPointerDown:l,onPointerUp:s,onClick:s}}}e.s(["useEvent",()=>er],914189),e.s(["useActivePress",()=>en],394487)},144279,294316,e=>{"use strict";var t=e.i(271645);function r(e,r){return(0,t.useMemo)(()=>{var t;if(e.type)return e.type;let n=null!=(t=e.as)?t:"button";if("string"==typeof n&&"button"===n.toLowerCase()||(null==r?void 0:r.tagName)==="BUTTON"&&!r.hasAttribute("type"))return"button"},[e.type,e.as,r])}e.s(["useResolveButtonType",()=>r],144279);var n=e.i(914189);let o=Symbol();function a(e,t=!0){return Object.assign(e,{[o]:t})}function s(...e){let r=(0,t.useRef)(e);(0,t.useEffect)(()=>{r.current=e},[e]);let a=(0,n.useEvent)(e=>{for(let t of r.current)null!=t&&("function"==typeof t?t(e):t.current=e)});return e.every(e=>null==e||(null==e?void 0:e[o]))?void 0:a}e.s(["optionalRef",()=>a,"useSyncRefs",()=>s],294316)},553521,e=>{"use strict";var t=e.i(271645),r=e.i(835696);function n(){let e=(0,t.useRef)(!1);return(0,r.useIsoMorphicEffect)(()=>(e.current=!0,()=>{e.current=!1}),[]),e}e.s(["useIsMounted",()=>n])},732607,e=>{"use strict";function t(...e){return Array.from(new Set(e.flatMap(e=>"string"==typeof e?e.split(" "):[]))).filter(Boolean).join(" ")}e.s(["classNames",()=>t])},397701,e=>{"use strict";function t(e,r,...n){if(e in r){let t=r[e];return"function"==typeof t?t(...n):t}let o=Error(`Tried to handle "${e}" but there is no handler defined. Only defined handlers are: ${Object.keys(r).map(e=>`"${e}"`).join(", ")}.`);throw Error.captureStackTrace&&Error.captureStackTrace(o,t),o}e.s(["match",()=>t])},700020,e=>{"use strict";let t,r;var n=e.i(271645),o=e.i(732607),a=e.i(397701),s=((t=s||{})[t.None=0]="None",t[t.RenderStrategy=1]="RenderStrategy",t[t.Static=2]="Static",t),l=((r=l||{})[r.Unmount=0]="Unmount",r[r.Hidden=1]="Hidden",r);function i(){let e,t,r=(e=(0,n.useRef)([]),t=(0,n.useCallback)(t=>{for(let r of e.current)null!=r&&("function"==typeof r?r(t):r.current=t)},[]),(...r)=>{if(!r.every(e=>null==e))return e.current=r,t});return(0,n.useCallback)(e=>(function({ourProps:e,theirProps:t,slot:r,defaultTag:n,features:o,visible:s=!0,name:l,mergeRefs:i}){i=null!=i?i:c;let f=d(t,e);if(s)return u(f,r,n,l,i);let p=null!=o?o:0;if(2&p){let{static:e=!1,...t}=f;if(e)return u(t,r,n,l,i)}if(1&p){let{unmount:e=!0,...t}=f;return(0,a.match)(+!e,{0:()=>null,1:()=>u({...t,hidden:!0,style:{display:"none"}},r,n,l,i)})}return u(f,r,n,l,i)})({mergeRefs:r,...e}),[r])}function u(e,t={},r,a,s){let{as:l=r,children:i,refName:c="ref",...f}=v(e,["unmount","static"]),p=void 0!==e.ref?{[c]:e.ref}:{},b="function"==typeof i?i(t):i;"className"in f&&f.className&&"function"==typeof f.className&&(f.className=f.className(t)),f["aria-labelledby"]&&f["aria-labelledby"]===f.id&&(f["aria-labelledby"]=void 0);let g={};if(t){let e=!1,r=[];for(let[n,o]of Object.entries(t))"boolean"==typeof o&&(e=!0),!0===o&&r.push(n.replace(/([A-Z])/g,e=>`-${e.toLowerCase()}`));if(e)for(let e of(g["data-headlessui-state"]=r.join(" "),r))g[`data-${e}`]=""}if(l===n.Fragment&&(Object.keys(m(f)).length>0||Object.keys(m(g)).length>0))if(!(0,n.isValidElement)(b)||Array.isArray(b)&&b.length>1){if(Object.keys(m(f)).length>0)throw Error(['Passing props on "Fragment"!',"",`The current component <${a} /> is rendering a "Fragment".`,"However we need to passthrough the following props:",Object.keys(m(f)).concat(Object.keys(m(g))).map(e=>` - ${e}`).join(` +`),"","You can apply a few solutions:",['Add an `as="..."` prop, to ensure that we render an actual element instead of a "Fragment".',"Render a single element as the child so that we can forward the props onto that element."].map(e=>` - ${e}`).join(` +`)].join(` +`))}else{var h;let e=b.props,t=null==e?void 0:e.className,r="function"==typeof t?(...e)=>(0,o.classNames)(t(...e),f.className):(0,o.classNames)(t,f.className),a=d(b.props,m(v(f,["ref"])));for(let e in g)e in a&&delete g[e];return(0,n.cloneElement)(b,Object.assign({},a,g,p,{ref:s((h=b,n.default.version.split(".")[0]>="19"?h.props.ref:h.ref),p.ref)},r?{className:r}:{}))}return(0,n.createElement)(l,Object.assign({},v(f,["ref"]),l!==n.Fragment&&p,l!==n.Fragment&&g),b)}function c(...e){return e.every(e=>null==e)?void 0:t=>{for(let r of e)null!=r&&("function"==typeof r?r(t):r.current=t)}}function d(...e){if(0===e.length)return{};if(1===e.length)return e[0];let t={},r={};for(let n of e)for(let e in n)e.startsWith("on")&&"function"==typeof n[e]?(null!=r[e]||(r[e]=[]),r[e].push(n[e])):t[e]=n[e];if(t.disabled||t["aria-disabled"])for(let e in r)/^(on(?:Click|Pointer|Mouse|Key)(?:Down|Up|Press)?)$/.test(e)&&(r[e]=[e=>{var t;return null==(t=null==e?void 0:e.preventDefault)?void 0:t.call(e)}]);for(let e in r)Object.assign(t,{[e](t,...n){for(let o of r[e]){if((t instanceof Event||(null==t?void 0:t.nativeEvent)instanceof Event)&&t.defaultPrevented)return;o(t,...n)}}});return t}function f(...e){if(0===e.length)return{};if(1===e.length)return e[0];let t={},r={};for(let n of e)for(let e in n)e.startsWith("on")&&"function"==typeof n[e]?(null!=r[e]||(r[e]=[]),r[e].push(n[e])):t[e]=n[e];for(let e in r)Object.assign(t,{[e](...t){for(let n of r[e])null==n||n(...t)}});return t}function p(e){var t;return Object.assign((0,n.forwardRef)(e),{displayName:null!=(t=e.displayName)?t:e.name})}function m(e){let t=Object.assign({},e);for(let e in t)void 0===t[e]&&delete t[e];return t}function v(e,t=[]){let r=Object.assign({},e);for(let e of t)e in r&&delete r[e];return r}e.s(["RenderFeatures",()=>s,"RenderStrategy",()=>l,"compact",()=>m,"forwardRefWithAs",()=>p,"mergeProps",()=>f,"useRender",()=>i])},2788,e=>{"use strict";let t;var r=e.i(700020),n=((t=n||{})[t.None=1]="None",t[t.Focusable=2]="Focusable",t[t.Hidden=4]="Hidden",t);let o=(0,r.forwardRefWithAs)(function(e,t){var n;let{features:o=1,...a}=e,s={ref:t,"aria-hidden":(2&o)==2||(null!=(n=a["aria-hidden"])?n:void 0),hidden:(4&o)==4||void 0,style:{position:"fixed",top:1,left:1,width:1,height:0,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",borderWidth:"0",...(4&o)==4&&(2&o)!=2&&{display:"none"}}};return(0,r.useRender)()({ourProps:s,theirProps:a,slot:{},defaultTag:"span",name:"Hidden"})});e.s(["Hidden",()=>o,"HiddenFeatures",()=>n])},640497,e=>{"use strict";var t=e.i(271645),r=e.i(553521),n=e.i(2788);function o({onFocus:e}){let[o,a]=(0,t.useState)(!0),s=(0,r.useIsMounted)();return o?t.default.createElement(n.Hidden,{as:"button",type:"button",features:n.HiddenFeatures.Focusable,onFocus:t=>{t.preventDefault();let r,n=50;r=requestAnimationFrame(function t(){if(n--<=0){r&&cancelAnimationFrame(r);return}if(e()){if(cancelAnimationFrame(r),!s.current)return;a(!1);return}r=requestAnimationFrame(t)})}}):null}e.s(["FocusSentinel",()=>o])},652265,e=>{"use strict";let t,r,n,o,a;e.i(544508);var s=e.i(397701),l=e.i(402155);let i=["[contentEditable=true]","[tabindex]","a[href]","area[href]","button:not([disabled])","iframe","input:not([disabled])","select:not([disabled])","textarea:not([disabled])"].map(e=>`${e}:not([tabindex='-1'])`).join(","),u=["[data-autofocus]"].map(e=>`${e}:not([tabindex='-1'])`).join(",");var c=((t=c||{})[t.First=1]="First",t[t.Previous=2]="Previous",t[t.Next=4]="Next",t[t.Last=8]="Last",t[t.WrapAround=16]="WrapAround",t[t.NoScroll=32]="NoScroll",t[t.AutoFocus=64]="AutoFocus",t),d=((r=d||{})[r.Error=0]="Error",r[r.Overflow=1]="Overflow",r[r.Success=2]="Success",r[r.Underflow=3]="Underflow",r),f=((n=f||{})[n.Previous=-1]="Previous",n[n.Next=1]="Next",n);function p(e=document.body){return null==e?[]:Array.from(e.querySelectorAll(i)).sort((e,t)=>Math.sign((e.tabIndex||Number.MAX_SAFE_INTEGER)-(t.tabIndex||Number.MAX_SAFE_INTEGER)))}var m=((o=m||{})[o.Strict=0]="Strict",o[o.Loose=1]="Loose",o);function v(e,t=0){var r;return e!==(null==(r=(0,l.getOwnerDocument)(e))?void 0:r.body)&&(0,s.match)(t,{0:()=>e.matches(i),1(){let t=e;for(;null!==t;){if(t.matches(i))return!0;t=t.parentElement}return!1}})}var b=((a=b||{})[a.Keyboard=0]="Keyboard",a[a.Mouse=1]="Mouse",a);function g(e,t=e=>e){return e.slice().sort((e,r)=>{let n=t(e),o=t(r);if(null===n||null===o)return 0;let a=n.compareDocumentPosition(o);return a&Node.DOCUMENT_POSITION_FOLLOWING?-1:a&Node.DOCUMENT_POSITION_PRECEDING?1:0})}function h(e,t){return y(p(),t,{relativeTo:e})}function y(e,t,{sorted:r=!0,relativeTo:n=null,skipElements:o=[]}={}){var a,s,l;let i=Array.isArray(e)?e.length>0?e[0].ownerDocument:document:e.ownerDocument,c=Array.isArray(e)?r?g(e):e:64&t?function(e=document.body){return null==e?[]:Array.from(e.querySelectorAll(u)).sort((e,t)=>Math.sign((e.tabIndex||Number.MAX_SAFE_INTEGER)-(t.tabIndex||Number.MAX_SAFE_INTEGER)))}(e):p(e);o.length>0&&c.length>1&&(c=c.filter(e=>!o.some(t=>null!=t&&"current"in t?(null==t?void 0:t.current)===e:t===e))),n=null!=n?n:i.activeElement;let d=(()=>{if(5&t)return 1;if(10&t)return -1;throw Error("Missing Focus.First, Focus.Previous, Focus.Next or Focus.Last")})(),f=(()=>{if(1&t)return 0;if(2&t)return Math.max(0,c.indexOf(n))-1;if(4&t)return Math.max(0,c.indexOf(n))+1;if(8&t)return c.length-1;throw Error("Missing Focus.First, Focus.Previous, Focus.Next or Focus.Last")})(),m=32&t?{preventScroll:!0}:{},v=0,b=c.length,h;do{if(v>=b||v+b<=0)return 0;let e=f+v;if(16&t)e=(e+b)%b;else{if(e<0)return 3;if(e>=b)return 1}null==(h=c[e])||h.focus(m),v+=d}while(h!==i.activeElement)return 6&t&&null!=(l=null==(s=null==(a=h)?void 0:a.matches)?void 0:s.call(a,"textarea,input"))&&l&&h.select(),2}"u">typeof window&&"u">typeof document&&(document.addEventListener("keydown",e=>{e.metaKey||e.altKey||e.ctrlKey||(document.documentElement.dataset.headlessuiFocusVisible="")},!0),document.addEventListener("click",e=>{1===e.detail?delete document.documentElement.dataset.headlessuiFocusVisible:0===e.detail&&(document.documentElement.dataset.headlessuiFocusVisible="")},!0)),e.s(["Focus",()=>c,"FocusResult",()=>d,"FocusableMode",()=>m,"focusFrom",()=>h,"focusIn",()=>y,"getFocusableElements",()=>p,"isFocusableElement",()=>v,"sortByDomNode",()=>g])},963703,e=>{"use strict";var t=e.i(271645);let r=t.createContext(null);function n({children:e}){let n=t.useRef({groups:new Map,get(e,t){var r;let n=this.groups.get(e);n||(n=new Map,this.groups.set(e,n));let o=null!=(r=n.get(t))?r:0;return n.set(t,o+1),[Array.from(n.keys()).indexOf(t),function(){let e=n.get(t);e>1?n.set(t,e-1):n.delete(t)}]}});return t.createElement(r.Provider,{value:n},e)}function o(e){let n=t.useContext(r);if(!n)throw Error("You must wrap your component in a ");let o=t.useId(),[a,s]=n.current.get(e,o);return t.useEffect(()=>s,[]),a}e.s(["StableCollection",()=>n,"useStableCollectionIndex",()=>o])},998348,e=>{"use strict";let t;var r=((t=r||{}).Space=" ",t.Enter="Enter",t.Escape="Escape",t.Backspace="Backspace",t.Delete="Delete",t.ArrowLeft="ArrowLeft",t.ArrowUp="ArrowUp",t.ArrowRight="ArrowRight",t.ArrowDown="ArrowDown",t.Home="Home",t.End="End",t.PageUp="PageUp",t.PageDown="PageDown",t.Tab="Tab",t);e.s(["Keys",()=>r])},970554,e=>{"use strict";let t,r,n;var o=e.i(429427),a=e.i(371330),s=e.i(271645),l=e.i(394487),i=e.i(914189),u=e.i(835696),c=e.i(941444),d=e.i(144279),f=e.i(294316),p=e.i(640497),m=e.i(2788),v=e.i(652265),b=e.i(397701),g=e.i(368578),h=e.i(402155),y=e.i(700020),E=e.i(963703),w=e.i(998348),T=((t=T||{})[t.Forwards=0]="Forwards",t[t.Backwards=1]="Backwards",t),x=((r=x||{})[r.Less=-1]="Less",r[r.Equal=0]="Equal",r[r.Greater=1]="Greater",r),F=((n=F||{})[n.SetSelectedIndex=0]="SetSelectedIndex",n[n.RegisterTab=1]="RegisterTab",n[n.UnregisterTab=2]="UnregisterTab",n[n.RegisterPanel=3]="RegisterPanel",n[n.UnregisterPanel=4]="UnregisterPanel",n);let P={0(e,t){var r;let n=(0,v.sortByDomNode)(e.tabs,e=>e.current),o=(0,v.sortByDomNode)(e.panels,e=>e.current),a=n.filter(e=>{var t;return!(null!=(t=e.current)&&t.hasAttribute("disabled"))}),s={...e,tabs:n,panels:o};if(t.index<0||t.index>n.length-1){let r=(0,b.match)(Math.sign(t.index-e.selectedIndex),{[-1]:()=>1,0:()=>(0,b.match)(Math.sign(t.index),{[-1]:()=>0,0:()=>0,1:()=>1}),1:()=>0});if(0===a.length)return s;let o=(0,b.match)(r,{0:()=>n.indexOf(a[0]),1:()=>n.indexOf(a[a.length-1])});return{...s,selectedIndex:-1===o?e.selectedIndex:o}}let l=n.slice(0,t.index),i=[...n.slice(t.index),...l].find(e=>a.includes(e));if(!i)return s;let u=null!=(r=n.indexOf(i))?r:e.selectedIndex;return -1===u&&(u=e.selectedIndex),{...s,selectedIndex:u}},1(e,t){if(e.tabs.includes(t.tab))return e;let r=e.tabs[e.selectedIndex],n=(0,v.sortByDomNode)([...e.tabs,t.tab],e=>e.current),o=e.selectedIndex;return e.info.current.isControlled||-1===(o=n.indexOf(r))&&(o=e.selectedIndex),{...e,tabs:n,selectedIndex:o}},2:(e,t)=>({...e,tabs:e.tabs.filter(e=>e!==t.tab)}),3:(e,t)=>e.panels.includes(t.panel)?e:{...e,panels:(0,v.sortByDomNode)([...e.panels,t.panel],e=>e.current)},4:(e,t)=>({...e,panels:e.panels.filter(e=>e!==t.panel)})},k=(0,s.createContext)(null);function L(e){let t=(0,s.useContext)(k);if(null===t){let t=Error(`<${e} /> is missing a parent component.`);throw Error.captureStackTrace&&Error.captureStackTrace(t,L),t}return t}k.displayName="TabsDataContext";let N=(0,s.createContext)(null);function C(e){let t=(0,s.useContext)(N);if(null===t){let t=Error(`<${e} /> is missing a parent component.`);throw Error.captureStackTrace&&Error.captureStackTrace(t,C),t}return t}function I(e,t){return(0,b.match)(t.type,P,e,t)}N.displayName="TabsActionsContext";let S=y.RenderFeatures.RenderStrategy|y.RenderFeatures.Static,A=Object.assign((0,y.forwardRefWithAs)(function(e,t){var r,n;let c=(0,s.useId)(),{id:p=`headlessui-tabs-tab-${c}`,disabled:m=!1,autoFocus:T=!1,...x}=e,{orientation:F,activation:P,selectedIndex:k,tabs:N,panels:I}=L("Tab"),S=C("Tab"),A=L("Tab"),[M,R]=(0,s.useState)(null),O=(0,s.useRef)(null),D=(0,f.useSyncRefs)(O,t,R);(0,u.useIsoMorphicEffect)(()=>S.registerTab(O),[S,O]);let H=(0,E.useStableCollectionIndex)("tabs"),j=N.indexOf(O);-1===j&&(j=H);let K=j===k,W=(0,i.useEvent)(e=>{var t;let r=e();if(r===v.FocusResult.Success&&"auto"===P){let e=null==(t=(0,h.getOwnerDocument)(O))?void 0:t.activeElement,r=A.tabs.findIndex(t=>t.current===e);-1!==r&&S.change(r)}return r}),B=(0,i.useEvent)(e=>{let t=N.map(e=>e.current).filter(Boolean);if(e.key===w.Keys.Space||e.key===w.Keys.Enter){e.preventDefault(),e.stopPropagation(),S.change(j);return}switch(e.key){case w.Keys.Home:case w.Keys.PageUp:return e.preventDefault(),e.stopPropagation(),W(()=>(0,v.focusIn)(t,v.Focus.First));case w.Keys.End:case w.Keys.PageDown:return e.preventDefault(),e.stopPropagation(),W(()=>(0,v.focusIn)(t,v.Focus.Last))}if(W(()=>(0,b.match)(F,{vertical:()=>e.key===w.Keys.ArrowUp?(0,v.focusIn)(t,v.Focus.Previous|v.Focus.WrapAround):e.key===w.Keys.ArrowDown?(0,v.focusIn)(t,v.Focus.Next|v.Focus.WrapAround):v.FocusResult.Error,horizontal:()=>e.key===w.Keys.ArrowLeft?(0,v.focusIn)(t,v.Focus.Previous|v.Focus.WrapAround):e.key===w.Keys.ArrowRight?(0,v.focusIn)(t,v.Focus.Next|v.Focus.WrapAround):v.FocusResult.Error}))===v.FocusResult.Success)return e.preventDefault()}),V=(0,s.useRef)(!1),_=(0,i.useEvent)(()=>{var e;V.current||(V.current=!0,null==(e=O.current)||e.focus({preventScroll:!0}),S.change(j),(0,g.microTask)(()=>{V.current=!1}))}),G=(0,i.useEvent)(e=>{e.preventDefault()}),{isFocusVisible:U,focusProps:$}=(0,o.useFocusRing)({autoFocus:T}),{isHovered:q,hoverProps:X}=(0,a.useHover)({isDisabled:m}),{pressed:Y,pressProps:z}=(0,l.useActivePress)({disabled:m}),Z=(0,s.useMemo)(()=>({selected:K,hover:q,active:Y,focus:U,autofocus:T,disabled:m}),[K,q,U,Y,T,m]),J=(0,y.mergeProps)({ref:D,onKeyDown:B,onMouseDown:G,onClick:_,id:p,role:"tab",type:(0,d.useResolveButtonType)(e,M),"aria-controls":null==(n=null==(r=I[j])?void 0:r.current)?void 0:n.id,"aria-selected":K,tabIndex:K?0:-1,disabled:m||void 0,autoFocus:T},$,X,z);return(0,y.useRender)()({ourProps:J,theirProps:x,slot:Z,defaultTag:"button",name:"Tabs.Tab"})}),{Group:(0,y.forwardRefWithAs)(function(e,t){let{defaultIndex:r=0,vertical:n=!1,manual:o=!1,onChange:a,selectedIndex:l=null,...d}=e,m=n?"vertical":"horizontal",b=o?"manual":"auto",g=null!==l,h=(0,c.useLatestValue)({isControlled:g}),w=(0,f.useSyncRefs)(t),[T,x]=(0,s.useReducer)(I,{info:h,selectedIndex:null!=l?l:r,tabs:[],panels:[]}),F=(0,s.useMemo)(()=>({selectedIndex:T.selectedIndex}),[T.selectedIndex]),P=(0,c.useLatestValue)(a||(()=>{})),L=(0,c.useLatestValue)(T.tabs),C=(0,s.useMemo)(()=>({orientation:m,activation:b,...T}),[m,b,T]),S=(0,i.useEvent)(e=>(x({type:1,tab:e}),()=>x({type:2,tab:e}))),A=(0,i.useEvent)(e=>(x({type:3,panel:e}),()=>x({type:4,panel:e}))),M=(0,i.useEvent)(e=>{R.current!==e&&P.current(e),g||x({type:0,index:e})}),R=(0,c.useLatestValue)(g?e.selectedIndex:T.selectedIndex),O=(0,s.useMemo)(()=>({registerTab:S,registerPanel:A,change:M}),[]);(0,u.useIsoMorphicEffect)(()=>{x({type:0,index:null!=l?l:r})},[l]),(0,u.useIsoMorphicEffect)(()=>{if(void 0===R.current||T.tabs.length<=0)return;let e=(0,v.sortByDomNode)(T.tabs,e=>e.current);e.some((e,t)=>T.tabs[t]!==e)&&M(e.indexOf(T.tabs[R.current]))});let D=(0,y.useRender)();return s.default.createElement(E.StableCollection,null,s.default.createElement(N.Provider,{value:O},s.default.createElement(k.Provider,{value:C},C.tabs.length<=0&&s.default.createElement(p.FocusSentinel,{onFocus:()=>{var e,t;for(let r of L.current)if((null==(e=r.current)?void 0:e.tabIndex)===0)return null==(t=r.current)||t.focus(),!0;return!1}}),D({ourProps:{ref:w},theirProps:d,slot:F,defaultTag:"div",name:"Tabs"}))))}),List:(0,y.forwardRefWithAs)(function(e,t){let{orientation:r,selectedIndex:n}=L("Tab.List"),o=(0,f.useSyncRefs)(t),a=(0,s.useMemo)(()=>({selectedIndex:n}),[n]);return(0,y.useRender)()({ourProps:{ref:o,role:"tablist","aria-orientation":r},theirProps:e,slot:a,defaultTag:"div",name:"Tabs.List"})}),Panels:(0,y.forwardRefWithAs)(function(e,t){let{selectedIndex:r}=L("Tab.Panels"),n=(0,f.useSyncRefs)(t),o=(0,s.useMemo)(()=>({selectedIndex:r}),[r]);return(0,y.useRender)()({ourProps:{ref:n},theirProps:e,slot:o,defaultTag:"div",name:"Tabs.Panels"})}),Panel:(0,y.forwardRefWithAs)(function(e,t){var r,n,a,l;let i=(0,s.useId)(),{id:c=`headlessui-tabs-panel-${i}`,tabIndex:d=0,...p}=e,{selectedIndex:v,tabs:b,panels:g}=L("Tab.Panel"),h=C("Tab.Panel"),w=(0,s.useRef)(null),T=(0,f.useSyncRefs)(w,t);(0,u.useIsoMorphicEffect)(()=>h.registerPanel(w),[h,w]);let x=(0,E.useStableCollectionIndex)("panels"),F=g.indexOf(w);-1===F&&(F=x);let P=F===v,{isFocusVisible:k,focusProps:N}=(0,o.useFocusRing)(),I=(0,s.useMemo)(()=>({selected:P,focus:k}),[P,k]),A=(0,y.mergeProps)({ref:T,id:c,role:"tabpanel","aria-labelledby":null==(n=null==(r=b[F])?void 0:r.current)?void 0:n.id,tabIndex:P?d:-1},N),M=(0,y.useRender)();return P||null!=(a=p.unmount)&&!a||null!=(l=p.static)&&l?M({ourProps:A,theirProps:p,slot:I,defaultTag:"div",features:S,visible:P,name:"Tabs.Panel"}):s.default.createElement(m.Hidden,{"aria-hidden":"true",...A})})});e.s(["Tab",()=>A])},723731,e=>{"use strict";var t=e.i(290571),r=e.i(970554),n=e.i(751734),o=e.i(144582),a=e.i(444755),s=e.i(673706),l=e.i(271645);let i=(0,s.makeClassName)("TabPanels"),u=l.default.forwardRef((e,s)=>{let{children:u,className:c}=e,d=(0,t.__rest)(e,["children","className"]);return l.default.createElement(r.Tab.Panels,Object.assign({as:"div",ref:s,className:(0,a.tremorTwMerge)(i("root"),"w-full",c)},d),({selectedIndex:e})=>l.default.createElement(o.default.Provider,{value:{selectedValue:e}},l.default.Children.map(u,(e,t)=>l.default.createElement(n.default.Provider,{value:t},e))))});u.displayName="TabPanels",e.s(["TabPanels",()=>u],723731)},653824,e=>{"use strict";var t=e.i(290571),r=e.i(970554),n=e.i(444755),o=e.i(673706),a=e.i(271645);let s=(0,o.makeClassName)("TabGroup"),l=a.default.forwardRef((e,o)=>{let{defaultIndex:l,index:i,onIndexChange:u,children:c,className:d}=e,f=(0,t.__rest)(e,["defaultIndex","index","onIndexChange","children","className"]);return a.default.createElement(r.Tab.Group,Object.assign({as:"div",ref:o,defaultIndex:l,selectedIndex:i,onChange:u,className:(0,n.tremorTwMerge)(s("root"),"w-full",d)},f),c)});l.displayName="TabGroup",e.s(["TabGroup",()=>l],653824)},405371,910342,e=>{"use strict";var t=e.i(290571),r=e.i(271645),n=e.i(480731);let o=(0,r.createContext)(n.BaseColors.Blue);e.s(["default",()=>o],910342);var a=e.i(970554),s=e.i(444755);let l=(0,e.i(673706).makeClassName)("TabList"),i=(0,r.createContext)("line"),u={line:(0,s.tremorTwMerge)("flex border-b space-x-4","border-tremor-border","dark:border-dark-tremor-border"),solid:(0,s.tremorTwMerge)("inline-flex p-0.5 rounded-tremor-default space-x-1.5","bg-tremor-background-subtle","dark:bg-dark-tremor-background-subtle")},c=r.default.forwardRef((e,n)=>{let{color:c,variant:d="line",children:f,className:p}=e,m=(0,t.__rest)(e,["color","variant","children","className"]);return r.default.createElement(a.Tab.List,Object.assign({ref:n,className:(0,s.tremorTwMerge)(l("root"),"justify-start overflow-x-clip",u[d],p)},m),r.default.createElement(i.Provider,{value:d},r.default.createElement(o.Provider,{value:c},f)))});c.displayName="TabList",e.s(["TabVariantContext",()=>i,"default",()=>c],405371)},881073,e=>{"use strict";var t=e.i(405371);e.s(["TabList",()=>t.default])},197647,e=>{"use strict";var t=e.i(290571),r=e.i(970554),n=e.i(95779),o=e.i(444755),a=e.i(673706),s=e.i(271645),l=e.i(405371),i=e.i(910342);let u=(0,a.makeClassName)("Tab"),c=s.default.forwardRef((e,c)=>{let{icon:d,className:f,children:p}=e,m=(0,t.__rest)(e,["icon","className","children"]),v=(0,s.useContext)(l.TabVariantContext),b=(0,s.useContext)(i.default);return s.default.createElement(r.Tab,Object.assign({ref:c,className:(0,o.tremorTwMerge)(u("root"),"flex whitespace-nowrap truncate max-w-xs outline-none data-focus-visible:ring text-tremor-default transition duration-100",function(e,t){switch(e){case"line":return(0,o.tremorTwMerge)("data-[selected]:border-b-2 hover:border-b-2 border-transparent transition duration-100 -mb-px px-2 py-2","hover:border-tremor-content hover:text-tremor-content-emphasis text-tremor-content","[&:not([data-selected])]:dark:hover:border-dark-tremor-content-emphasis [&:not([data-selected])]:dark:hover:text-dark-tremor-content-emphasis [&:not([data-selected])]:dark:text-dark-tremor-content",t?(0,a.getColorClassNames)(t,n.colorPalette.border).selectBorderColor:["data-[selected]:border-tremor-brand data-[selected]:text-tremor-brand","data-[selected]:dark:border-dark-tremor-brand data-[selected]:dark:text-dark-tremor-brand"]);case"solid":return(0,o.tremorTwMerge)("border-transparent border rounded-tremor-small px-2.5 py-1","data-[selected]:border-tremor-border data-[selected]:bg-tremor-background data-[selected]:shadow-tremor-input [&:not([data-selected])]:hover:text-tremor-content-emphasis data-[selected]:text-tremor-brand [&:not([data-selected])]:text-tremor-content","dark:data-[selected]:border-dark-tremor-border dark:data-[selected]:bg-dark-tremor-background dark:data-[selected]:shadow-dark-tremor-input dark:[&:not([data-selected])]:hover:text-dark-tremor-content-emphasis dark:data-[selected]:text-dark-tremor-brand dark:[&:not([data-selected])]:text-dark-tremor-content",t?(0,a.getColorClassNames)(t,n.colorPalette.text).selectTextColor:"text-tremor-content dark:text-dark-tremor-content")}}(v,b),f,b&&(0,a.getColorClassNames)(b,n.colorPalette.text).selectTextColor)},m),d?s.default.createElement(d,{className:(0,o.tremorTwMerge)(u("icon"),"flex-none h-5 w-5",p?"mr-2":"")}):null,p?s.default.createElement("span",null,p):null)});c.displayName="Tab",e.s(["Tab",()=>c],197647)}]); \ No newline at end of file diff --git a/litellm/proxy/_experimental/out/_next/static/chunks/1070-ab9dafb0fc6e0b85.js b/litellm/proxy/_experimental/out/_next/static/chunks/1070-ab9dafb0fc6e0b85.js deleted file mode 100644 index a35f71fe0e6..00000000000 --- a/litellm/proxy/_experimental/out/_next/static/chunks/1070-ab9dafb0fc6e0b85.js +++ /dev/null @@ -1 +0,0 @@ -"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[1070],{88009:function(e,t,c){c.d(t,{Z:function(){return i}});var n=c(1119),a=c(2265),r={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M464 144H160c-8.8 0-16 7.2-16 16v304c0 8.8 7.2 16 16 16h304c8.8 0 16-7.2 16-16V160c0-8.8-7.2-16-16-16zm-52 268H212V212h200v200zm452-268H560c-8.8 0-16 7.2-16 16v304c0 8.8 7.2 16 16 16h304c8.8 0 16-7.2 16-16V160c0-8.8-7.2-16-16-16zm-52 268H612V212h200v200zM464 544H160c-8.8 0-16 7.2-16 16v304c0 8.8 7.2 16 16 16h304c8.8 0 16-7.2 16-16V560c0-8.8-7.2-16-16-16zm-52 268H212V612h200v200zm452-268H560c-8.8 0-16 7.2-16 16v304c0 8.8 7.2 16 16 16h304c8.8 0 16-7.2 16-16V560c0-8.8-7.2-16-16-16zm-52 268H612V612h200v200z"}}]},name:"appstore",theme:"outlined"},o=c(55015),i=a.forwardRef(function(e,t){return a.createElement(o.Z,(0,n.Z)({},e,{ref:t,icon:r}))})},93750:function(e,t,c){c.d(t,{Z:function(){return i}});var n=c(1119),a=c(2265),r={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M296 250c-4.4 0-8 3.6-8 8v48c0 4.4 3.6 8 8 8h384c4.4 0 8-3.6 8-8v-48c0-4.4-3.6-8-8-8H296zm184 144H296c-4.4 0-8 3.6-8 8v48c0 4.4 3.6 8 8 8h184c4.4 0 8-3.6 8-8v-48c0-4.4-3.6-8-8-8zm-48 458H208V148h560v320c0 4.4 3.6 8 8 8h56c4.4 0 8-3.6 8-8V108c0-17.7-14.3-32-32-32H168c-17.7 0-32 14.3-32 32v784c0 17.7 14.3 32 32 32h264c4.4 0 8-3.6 8-8v-56c0-4.4-3.6-8-8-8zm440-88H728v-36.6c46.3-13.8 80-56.6 80-107.4 0-61.9-50.1-112-112-112s-112 50.1-112 112c0 50.7 33.7 93.6 80 107.4V764H520c-8.8 0-16 7.2-16 16v152c0 8.8 7.2 16 16 16h352c8.8 0 16-7.2 16-16V780c0-8.8-7.2-16-16-16zM646 620c0-27.6 22.4-50 50-50s50 22.4 50 50-22.4 50-50 50-50-22.4-50-50zm180 266H566v-60h260v60z"}}]},name:"audit",theme:"outlined"},o=c(55015),i=a.forwardRef(function(e,t){return a.createElement(o.Z,(0,n.Z)({},e,{ref:t,icon:r}))})},37527:function(e,t,c){c.d(t,{Z:function(){return i}});var n=c(1119),a=c(2265),r={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M894 462c30.9 0 43.8-39.7 18.7-58L530.8 126.2a31.81 31.81 0 00-37.6 0L111.3 404c-25.1 18.2-12.2 58 18.8 58H192v374h-72c-4.4 0-8 3.6-8 8v52c0 4.4 3.6 8 8 8h784c4.4 0 8-3.6 8-8v-52c0-4.4-3.6-8-8-8h-72V462h62zM512 196.7l271.1 197.2H240.9L512 196.7zM264 462h117v374H264V462zm189 0h117v374H453V462zm307 374H642V462h118v374z"}}]},name:"bank",theme:"outlined"},o=c(55015),i=a.forwardRef(function(e,t){return a.createElement(o.Z,(0,n.Z)({},e,{ref:t,icon:r}))})},9775:function(e,t,c){c.d(t,{Z:function(){return i}});var n=c(1119),a=c(2265),r={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M888 792H200V168c0-4.4-3.6-8-8-8h-56c-4.4 0-8 3.6-8 8v688c0 4.4 3.6 8 8 8h752c4.4 0 8-3.6 8-8v-56c0-4.4-3.6-8-8-8zm-600-80h56c4.4 0 8-3.6 8-8V560c0-4.4-3.6-8-8-8h-56c-4.4 0-8 3.6-8 8v144c0 4.4 3.6 8 8 8zm152 0h56c4.4 0 8-3.6 8-8V384c0-4.4-3.6-8-8-8h-56c-4.4 0-8 3.6-8 8v320c0 4.4 3.6 8 8 8zm152 0h56c4.4 0 8-3.6 8-8V462c0-4.4-3.6-8-8-8h-56c-4.4 0-8 3.6-8 8v242c0 4.4 3.6 8 8 8zm152 0h56c4.4 0 8-3.6 8-8V304c0-4.4-3.6-8-8-8h-56c-4.4 0-8 3.6-8 8v400c0 4.4 3.6 8 8 8z"}}]},name:"bar-chart",theme:"outlined"},o=c(55015),i=a.forwardRef(function(e,t){return a.createElement(o.Z,(0,n.Z)({},e,{ref:t,icon:r}))})},68208:function(e,t,c){c.d(t,{Z:function(){return i}});var n=c(1119),a=c(2265),r={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M856 376H648V168c0-8.8-7.2-16-16-16H168c-8.8 0-16 7.2-16 16v464c0 8.8 7.2 16 16 16h208v208c0 8.8 7.2 16 16 16h464c8.8 0 16-7.2 16-16V392c0-8.8-7.2-16-16-16zm-480 16v188H220V220h360v156H392c-8.8 0-16 7.2-16 16zm204 52v136H444V444h136zm224 360H444V648h188c8.8 0 16-7.2 16-16V444h156v360z"}}]},name:"block",theme:"outlined"},o=c(55015),i=a.forwardRef(function(e,t){return a.createElement(o.Z,(0,n.Z)({},e,{ref:t,icon:r}))})},41169:function(e,t,c){c.d(t,{Z:function(){return i}});var n=c(1119),a=c(2265),r={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M512 472a40 40 0 1080 0 40 40 0 10-80 0zm367 352.9L696.3 352V178H768v-68H256v68h71.7v174L145 824.9c-2.8 7.4-4.3 15.2-4.3 23.1 0 35.3 28.7 64 64 64h614.6c7.9 0 15.7-1.5 23.1-4.3 33-12.7 49.4-49.8 36.6-82.8zM395.7 364.7V180h232.6v184.7L719.2 600c-20.7-5.3-42.1-8-63.9-8-61.2 0-119.2 21.5-165.3 60a188.78 188.78 0 01-121.3 43.9c-32.7 0-64.1-8.3-91.8-23.7l118.8-307.5zM210.5 844l41.7-107.8c35.7 18.1 75.4 27.8 116.6 27.8 61.2 0 119.2-21.5 165.3-60 33.9-28.2 76.3-43.9 121.3-43.9 35 0 68.4 9.5 97.6 27.1L813.5 844h-603z"}}]},name:"experiment",theme:"outlined"},o=c(55015),i=a.forwardRef(function(e,t){return a.createElement(o.Z,(0,n.Z)({},e,{ref:t,icon:r}))})},48231:function(e,t,c){c.d(t,{Z:function(){return i}});var n=c(1119),a=c(2265),r={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M888 792H200V168c0-4.4-3.6-8-8-8h-56c-4.4 0-8 3.6-8 8v688c0 4.4 3.6 8 8 8h752c4.4 0 8-3.6 8-8v-56c0-4.4-3.6-8-8-8zM305.8 637.7c3.1 3.1 8.1 3.1 11.3 0l138.3-137.6L583 628.5c3.1 3.1 8.2 3.1 11.3 0l275.4-275.3c3.1-3.1 3.1-8.2 0-11.3l-39.6-39.6a8.03 8.03 0 00-11.3 0l-230 229.9L461.4 404a8.03 8.03 0 00-11.3 0L266.3 586.7a8.03 8.03 0 000 11.3l39.5 39.7z"}}]},name:"line-chart",theme:"outlined"},o=c(55015),i=a.forwardRef(function(e,t){return a.createElement(o.Z,(0,n.Z)({},e,{ref:t,icon:r}))})},28595:function(e,t,c){c.d(t,{Z:function(){return i}});var n=c(1119),a=c(2265),r={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M512 64C264.6 64 64 264.6 64 512s200.6 448 448 448 448-200.6 448-448S759.4 64 512 64zm0 820c-205.4 0-372-166.6-372-372s166.6-372 372-372 372 166.6 372 372-166.6 372-372 372z"}},{tag:"path",attrs:{d:"M719.4 499.1l-296.1-215A15.9 15.9 0 00398 297v430c0 13.1 14.8 20.5 25.3 12.9l296.1-215a15.9 15.9 0 000-25.8zm-257.6 134V390.9L628.5 512 461.8 633.1z"}}]},name:"play-circle",theme:"outlined"},o=c(55015),i=a.forwardRef(function(e,t){return a.createElement(o.Z,(0,n.Z)({},e,{ref:t,icon:r}))})},41361:function(e,t,c){c.d(t,{Z:function(){return i}});var n=c(1119),a=c(2265),r={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M824.2 699.9a301.55 301.55 0 00-86.4-60.4C783.1 602.8 812 546.8 812 484c0-110.8-92.4-201.7-203.2-200-109.1 1.7-197 90.6-197 200 0 62.8 29 118.8 74.2 155.5a300.95 300.95 0 00-86.4 60.4C345 754.6 314 826.8 312 903.8a8 8 0 008 8.2h56c4.3 0 7.9-3.4 8-7.7 1.9-58 25.4-112.3 66.7-153.5A226.62 226.62 0 01612 684c60.9 0 118.2 23.7 161.3 66.8C814.5 792 838 846.3 840 904.3c.1 4.3 3.7 7.7 8 7.7h56a8 8 0 008-8.2c-2-77-33-149.2-87.8-203.9zM612 612c-34.2 0-66.4-13.3-90.5-37.5a126.86 126.86 0 01-37.5-91.8c.3-32.8 13.4-64.5 36.3-88 24-24.6 56.1-38.3 90.4-38.7 33.9-.3 66.8 12.9 91 36.6 24.8 24.3 38.4 56.8 38.4 91.4 0 34.2-13.3 66.3-37.5 90.5A127.3 127.3 0 01612 612zM361.5 510.4c-.9-8.7-1.4-17.5-1.4-26.4 0-15.9 1.5-31.4 4.3-46.5.7-3.6-1.2-7.3-4.5-8.8-13.6-6.1-26.1-14.5-36.9-25.1a127.54 127.54 0 01-38.7-95.4c.9-32.1 13.8-62.6 36.3-85.6 24.7-25.3 57.9-39.1 93.2-38.7 31.9.3 62.7 12.6 86 34.4 7.9 7.4 14.7 15.6 20.4 24.4 2 3.1 5.9 4.4 9.3 3.2 17.6-6.1 36.2-10.4 55.3-12.4 5.6-.6 8.8-6.6 6.3-11.6-32.5-64.3-98.9-108.7-175.7-109.9-110.9-1.7-203.3 89.2-203.3 199.9 0 62.8 28.9 118.8 74.2 155.5-31.8 14.7-61.1 35-86.5 60.4-54.8 54.7-85.8 126.9-87.8 204a8 8 0 008 8.2h56.1c4.3 0 7.9-3.4 8-7.7 1.9-58 25.4-112.3 66.7-153.5 29.4-29.4 65.4-49.8 104.7-59.7 3.9-1 6.5-4.7 6-8.7z"}}]},name:"team",theme:"outlined"},o=c(55015),i=a.forwardRef(function(e,t){return a.createElement(o.Z,(0,n.Z)({},e,{ref:t,icon:r}))})},13817:function(e,t,c){c.d(t,{default:function(){return H}});var n=c(83145),a=c(2265),r=c(36760),o=c.n(r),i=c(18694),f=c(71744),l=c(80856),u=c(45287),s=c(32186),h=c(25437),d=function(e,t){var c={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&0>t.indexOf(n)&&(c[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols)for(var a=0,n=Object.getOwnPropertySymbols(e);at.indexOf(n[a])&&Object.prototype.propertyIsEnumerable.call(e,n[a])&&(c[n[a]]=e[n[a]]);return c};function m(e){let{suffixCls:t,tagName:c,displayName:n}=e;return e=>a.forwardRef((n,r)=>a.createElement(e,Object.assign({ref:r,suffixCls:t,tagName:c},n)))}let v=a.forwardRef((e,t)=>{let{prefixCls:c,suffixCls:n,className:r,tagName:i}=e,l=d(e,["prefixCls","suffixCls","className","tagName"]),{getPrefixCls:u}=a.useContext(f.E_),s=u("layout",c),[m,v,p]=(0,h.ZP)(s),g=n?"".concat(s,"-").concat(n):s;return m(a.createElement(i,Object.assign({className:o()(c||g,r,v,p),ref:t},l)))}),p=a.forwardRef((e,t)=>{let{direction:c}=a.useContext(f.E_),[r,m]=a.useState([]),{prefixCls:v,className:p,rootClassName:g,children:Z,hasSider:y,tagName:z,style:H}=e,V=d(e,["prefixCls","className","rootClassName","children","hasSider","tagName","style"]),b=(0,i.Z)(V,["suffixCls"]),{getPrefixCls:M,className:w,style:x}=(0,f.dj)("layout"),k=M("layout",v),C="boolean"==typeof y?y:!!r.length||(0,u.Z)(Z).some(e=>e.type===s.Z),[N,E,O]=(0,h.ZP)(k),L=o()(k,{["".concat(k,"-has-sider")]:C,["".concat(k,"-rtl")]:"rtl"===c},w,p,g,E,O),j=a.useMemo(()=>({siderHook:{addSider:e=>{m(t=>[].concat((0,n.Z)(t),[e]))},removeSider:e=>{m(t=>t.filter(t=>t!==e))}}}),[]);return N(a.createElement(l.V.Provider,{value:j},a.createElement(z,Object.assign({ref:t,className:L,style:Object.assign(Object.assign({},x),H)},b),Z)))}),g=m({tagName:"div",displayName:"Layout"})(p),Z=m({suffixCls:"header",tagName:"header",displayName:"Header"})(v),y=m({suffixCls:"footer",tagName:"footer",displayName:"Footer"})(v),z=m({suffixCls:"content",tagName:"main",displayName:"Content"})(v);g.Header=Z,g.Footer=y,g.Content=z,g.Sider=s.Z,g._InternalSiderContext=s.D;var H=g},40875:function(e,t,c){c.d(t,{Z:function(){return n}});let n=(0,c(79205).Z)("chevron-down",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]])},22135:function(e,t,c){c.d(t,{Z:function(){return n}});let n=(0,c(79205).Z)("chevron-up",[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]])},51817:function(e,t,c){c.d(t,{Z:function(){return n}});let n=(0,c(79205).Z)("loader-circle",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]])},21047:function(e,t,c){c.d(t,{Z:function(){return n}});let n=(0,c(79205).Z)("minus",[["path",{d:"M5 12h14",key:"1ays0h"}]])},70525:function(e,t,c){c.d(t,{Z:function(){return n}});let n=(0,c(79205).Z)("trending-up",[["path",{d:"M16 7h6v6",key:"box55l"}],["path",{d:"m22 7-8.5 8.5-5-5L2 17",key:"1t1m79"}]])},76865:function(e,t,c){c.d(t,{Z:function(){return n}});let n=(0,c(79205).Z)("triangle-alert",[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]])},49663:function(e,t,c){c.d(t,{Z:function(){return n}});let n=(0,c(79205).Z)("user-check",[["path",{d:"m16 11 2 2 4-4",key:"9rsbq5"}],["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}]])},95805:function(e,t,c){c.d(t,{Z:function(){return n}});let n=(0,c(79205).Z)("users",[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["path",{d:"M16 3.128a4 4 0 0 1 0 7.744",key:"16gr8j"}],["path",{d:"M22 21v-2a4 4 0 0 0-3-3.87",key:"kshegd"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}]])}}]); \ No newline at end of file diff --git a/litellm/proxy/_experimental/out/_next/static/chunks/1098-a1702da59647cf14.js b/litellm/proxy/_experimental/out/_next/static/chunks/1098-a1702da59647cf14.js deleted file mode 100644 index 8bdb738f169..00000000000 --- a/litellm/proxy/_experimental/out/_next/static/chunks/1098-a1702da59647cf14.js +++ /dev/null @@ -1 +0,0 @@ -"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[1098],{30280:function(e,t,l){l.d(t,{EX:function(){return c},Km:function(){return o},Tv:function(){return u}});var s=l(11713),a=l(45345),r=l(90246),i=l(19250),n=l(39760);let o=(0,r.n)("keys"),d=async function(e,t,l){let s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};try{let a=(0,i.getProxyBaseUrl)(),r=new URLSearchParams(Object.entries({team_id:s.teamID,organization_id:s.organizationID,key_alias:s.selectedKeyAlias,key_hash:s.keyHash,user_id:s.userID,page:t,size:l,sort_by:s.sortBy,sort_order:s.sortOrder,expand:s.expand,status:s.status,return_full_object:"true",include_team_keys:"true",include_created_by_keys:"true"}).filter(e=>{let[,t]=e;return null!=t}).map(e=>{let[t,l]=e;return[t,String(l)]})),n="".concat(a?"".concat(a,"/key/list"):"/key/list","?").concat(r),o=await fetch(n,{method:"GET",headers:{[(0,i.getGlobalLitellmHeaderName)()]:"Bearer ".concat(e),"Content-Type":"application/json"}});if(!o.ok){let e=await o.json(),t=(0,i.deriveErrorMessage)(e);throw(0,i.handleError)(t),Error(t)}let d=await o.json();return console.log("/key/list API Response:",d),d}catch(e){throw console.error("Failed to list keys:",e),e}},c=function(e,t){let l=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},{accessToken:r}=(0,n.Z)();return(0,s.a)({queryKey:o.list({page:e,limit:t,...l}),queryFn:async()=>await d(r,e,t,l),enabled:!!r,staleTime:3e4,placeholderData:a.Wk})},m=(0,r.n)("deletedKeys"),u=function(e,t){let l=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},{accessToken:r}=(0,n.Z)();return(0,s.a)({queryKey:m.list({page:e,limit:t,...l}),queryFn:async()=>await d(r,e,t,{...l,status:"deleted"}),enabled:!!r,staleTime:3e4,placeholderData:a.Wk})}},89348:function(e,t,l){l.d(t,{$:function(){return x}});var s=l(57437),a=l(16312),r=l(42264),i=l(65869),n=l(99397),o=l(2265),d=l(37592),c=l(99981),m=l(49322),u=l(15051),h=l(32489);function g(e){let{group:t,onChange:l,availableModels:a,maxFallbacks:r}=e,i=a.filter(e=>e!==t.primaryModel),n=e=>{let s=t.fallbackModels.filter((t,l)=>l!==e);l({...t,fallbackModels:s})},o=t.fallbackModels.length{let s=[...t.fallbackModels];s.includes(e)&&(s=s.filter(t=>t!==e)),l({...t,primaryModel:e,fallbackModels:s})},showSearch:!0,filterOption:(e,t)=>{var l;return(null!==(l=null==t?void 0:t.label)&&void 0!==l?l:"").toLowerCase().includes(e.toLowerCase())},options:a.map(e=>({label:e,value:e}))}),!t.primaryModel&&(0,s.jsxs)("div",{className:"mt-2 flex items-center gap-2 text-amber-600 text-xs bg-amber-50 p-2 rounded",children:[(0,s.jsx)(m.Z,{className:"w-4 h-4"}),(0,s.jsx)("span",{children:"Select a model to begin configuring fallbacks"})]})]}),(0,s.jsx)("div",{className:"flex items-center justify-center -my-4 z-10",children:(0,s.jsxs)("div",{className:"bg-indigo-50 text-indigo-500 px-4 py-1 rounded-full text-xs font-bold border border-indigo-100 flex items-center gap-2 shadow-sm",children:[(0,s.jsx)(u.Z,{className:"w-4 h-4"}),"IF FAILS, TRY..."]})}),(0,s.jsxs)("div",{className:"transition-opacity duration-300 ".concat(t.primaryModel?"opacity-100":"opacity-50 pointer-events-none"),children:[(0,s.jsxs)("label",{className:"block text-sm font-semibold text-gray-700 mb-2",children:["Fallback Chain ",(0,s.jsx)("span",{className:"text-red-500",children:"*"}),(0,s.jsxs)("span",{className:"text-xs text-gray-500 font-normal ml-2",children:["(Max ",r," fallbacks at a time)"]})]}),(0,s.jsxs)("div",{className:"bg-gray-50 rounded-xl p-4 border border-gray-200",children:[(0,s.jsxs)("div",{className:"mb-4",children:[(0,s.jsx)(d.default,{mode:"multiple",className:"w-full",size:"large",placeholder:o?"Select fallback models to add...":"Maximum ".concat(r," fallbacks reached"),value:t.fallbackModels,onChange:e=>{let s=e.slice(0,r);l({...t,fallbackModels:s})},disabled:!t.primaryModel,options:i.map(e=>({label:e,value:e})),optionRender:(e,l)=>{let a=t.fallbackModels.includes(e.value),r=a?t.fallbackModels.indexOf(e.value)+1:null;return(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[a&&null!==r&&(0,s.jsx)("span",{className:"flex items-center justify-center w-5 h-5 rounded bg-indigo-100 text-indigo-600 text-xs font-bold",children:r}),(0,s.jsx)("span",{children:e.label})]})},maxTagCount:"responsive",maxTagPlaceholder:e=>(0,s.jsx)(c.Z,{styles:{root:{pointerEvents:"none"}},title:e.map(e=>{let{value:t}=e;return t}).join(", "),children:(0,s.jsxs)("span",{children:["+",e.length," more"]})}),showSearch:!0,filterOption:(e,t)=>{var l;return(null!==(l=null==t?void 0:t.label)&&void 0!==l?l:"").toLowerCase().includes(e.toLowerCase())}}),(0,s.jsx)("p",{className:"text-xs text-gray-500 mt-1 ml-1",children:o?"Search and select multiple models. Selected models will appear below in order. (".concat(t.fallbackModels.length,"/").concat(r," used)"):"Maximum ".concat(r," fallbacks reached. Remove some to add more.")})]}),(0,s.jsx)("div",{className:"space-y-2 min-h-[100px]",children:0===t.fallbackModels.length?(0,s.jsxs)("div",{className:"h-32 border-2 border-dashed border-gray-300 rounded-lg flex flex-col items-center justify-center text-gray-400",children:[(0,s.jsx)("span",{className:"text-sm",children:"No fallback models selected"}),(0,s.jsx)("span",{className:"text-xs mt-1",children:"Add models from the dropdown above"})]}):t.fallbackModels.map((e,t)=>(0,s.jsxs)("div",{className:"group flex items-center justify-between p-3 bg-white rounded-lg border border-gray-200 hover:border-indigo-300 hover:shadow-sm transition-all",children:[(0,s.jsxs)("div",{className:"flex items-center gap-3",children:[(0,s.jsx)("div",{className:"flex items-center justify-center w-6 h-6 rounded bg-gray-100 text-gray-400 group-hover:text-indigo-500 group-hover:bg-indigo-50",children:(0,s.jsx)("span",{className:"text-xs font-bold",children:t+1})}),(0,s.jsx)("div",{children:(0,s.jsx)("span",{className:"font-medium text-gray-800",children:e})})]}),(0,s.jsx)("button",{type:"button",onClick:()=>n(t),className:"opacity-0 group-hover:opacity-100 transition-opacity text-gray-400 hover:text-red-500 p-1",children:(0,s.jsx)(h.Z,{className:"w-4 h-4"})})]},"".concat(e,"-").concat(t)))})]})]})]})}function x(e){let{groups:t,onGroupsChange:l,availableModels:d,maxFallbacks:c=5,maxGroups:m=5}=e,[u,h]=(0,o.useState)(t.length>0?t[0].id:"1");(0,o.useEffect)(()=>{t.length>0?t.some(e=>e.id===u)||h(t[0].id):h("1")},[t]);let x=()=>{if(t.length>=m)return;let e=Date.now().toString();l([...t,{id:e,primaryModel:null,fallbackModels:[]}]),h(e)},p=e=>{if(1===t.length){r.ZP.warning("At least one group is required");return}let s=t.filter(t=>t.id!==e);l(s),u===e&&s.length>0&&h(s[s.length-1].id)},y=e=>{l(t.map(t=>t.id===e.id?e:t))},f=t.map((e,l)=>{let a=e.primaryModel?e.primaryModel:"Group ".concat(l+1);return{key:e.id,label:a,closable:t.length>1,children:(0,s.jsx)(g,{group:e,onChange:y,availableModels:d,maxFallbacks:c})}});return 0===t.length?(0,s.jsxs)("div",{className:"text-center py-12 bg-gray-50 rounded-lg border border-dashed border-gray-300",children:[(0,s.jsx)("p",{className:"text-gray-500 mb-4",children:"No fallback groups configured"}),(0,s.jsx)(a.z,{variant:"primary",onClick:x,icon:()=>(0,s.jsx)(n.Z,{className:"w-4 h-4"}),children:"Create First Group"})]}):(0,s.jsx)(i.default,{type:"editable-card",activeKey:u,onChange:h,onEdit:(e,l)=>{"add"===l?x():"remove"===l&&t.length>1&&p(e)},items:f,className:"fallback-tabs",tabBarStyle:{marginBottom:0},hideAdd:t.length>=m})}},62099:function(e,t,l){var s=l(57437),a=l(2265),r=l(37592),i=l(99981),n=l(23496),o=l(63709),d=l(15424),c=l(31283);let{Option:m}=r.default;t.Z=e=>{var t;let{form:l,autoRotationEnabled:u,onAutoRotationChange:h,rotationInterval:g,onRotationIntervalChange:x,isCreateMode:p=!1}=e,y=g&&!["7d","30d","90d","180d","365d"].includes(g),[f,j]=(0,a.useState)(y),[b,v]=(0,a.useState)(y?g:""),[_,N]=(0,a.useState)((null==l?void 0:null===(t=l.getFieldValue)||void 0===t?void 0:t.call(l,"duration"))||"");return(0,s.jsxs)("div",{className:"space-y-6",children:[(0,s.jsxs)("div",{className:"space-y-4",children:[(0,s.jsx)("span",{className:"text-sm font-medium text-gray-700",children:"Key Expiry Settings"}),(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsxs)("label",{className:"text-sm font-medium text-gray-700 flex items-center space-x-1",children:[(0,s.jsx)("span",{children:"Expire Key"}),(0,s.jsx)(i.Z,{title:p?"Set when this key should expire. Format: 30s (seconds), 30m (minutes), 30h (hours), 30d (days). Leave empty to never expire.":"Set when this key should expire. Format: 30s (seconds), 30m (minutes), 30h (hours), 30d (days). Use -1 to never expire.",children:(0,s.jsx)(d.Z,{className:"text-gray-400 cursor-help text-xs"})})]}),(0,s.jsx)(c.o,{name:"duration",placeholder:p?"e.g., 30d or leave empty to never expire":"e.g., 30d or -1 to never expire",className:"w-full",value:_,onValueChange:e=>{N(e),l&&"function"==typeof l.setFieldValue?l.setFieldValue("duration",e):l&&"function"==typeof l.setFieldsValue&&l.setFieldsValue({duration:e})}})]})]}),(0,s.jsx)(n.Z,{}),(0,s.jsxs)("div",{className:"space-y-4",children:[(0,s.jsx)("span",{className:"text-sm font-medium text-gray-700",children:"Auto-Rotation Settings"}),(0,s.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsxs)("label",{className:"text-sm font-medium text-gray-700 flex items-center space-x-1",children:[(0,s.jsx)("span",{children:"Enable Auto-Rotation"}),(0,s.jsx)(i.Z,{title:"Key will automatically regenerate at the specified interval for enhanced security.",children:(0,s.jsx)(d.Z,{className:"text-gray-400 cursor-help text-xs"})})]}),(0,s.jsx)(o.Z,{checked:u,onChange:h,size:"default",className:u?"":"bg-gray-400"})]}),u&&(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsxs)("label",{className:"text-sm font-medium text-gray-700 flex items-center space-x-1",children:[(0,s.jsx)("span",{children:"Rotation Interval"}),(0,s.jsx)(i.Z,{title:"How often the key should be automatically rotated. Choose the interval that best fits your security requirements.",children:(0,s.jsx)(d.Z,{className:"text-gray-400 cursor-help text-xs"})})]}),(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsxs)(r.default,{value:f?"custom":g,onChange:e=>{"custom"===e?j(!0):(j(!1),v(""),x(e))},className:"w-full",placeholder:"Select interval",children:[(0,s.jsx)(m,{value:"7d",children:"7 days"}),(0,s.jsx)(m,{value:"30d",children:"30 days"}),(0,s.jsx)(m,{value:"90d",children:"90 days"}),(0,s.jsx)(m,{value:"180d",children:"180 days"}),(0,s.jsx)(m,{value:"365d",children:"365 days"}),(0,s.jsx)(m,{value:"custom",children:"Custom interval"})]}),f&&(0,s.jsxs)("div",{className:"space-y-1",children:[(0,s.jsx)(c.o,{value:b,onChange:e=>{let t=e.target.value;v(t),x(t)},placeholder:"e.g., 1s, 5m, 2h, 14d"}),(0,s.jsx)("div",{className:"text-xs text-gray-500",children:"Supported formats: seconds (s), minutes (m), hours (h), days (d)"})]})]})]})]}),u&&(0,s.jsx)("div",{className:"bg-blue-50 p-3 rounded-md text-sm text-blue-700",children:"When rotation occurs, you'll receive a notification with the new key. The old key will be deactivated after a brief grace period."})]})]})}},72885:function(e,t,l){var s=l(57437),a=l(2265),r=l(77355),i=l(93416),n=l(74998),o=l(95704),d=l(76593),c=l(9114);t.Z=e=>{let{accessToken:t,initialModelAliases:l={},onAliasUpdate:m,showExampleConfig:u=!0}=e,[h,g]=(0,a.useState)([]),[x,p]=(0,a.useState)({aliasName:"",targetModel:""}),[y,f]=(0,a.useState)(null);(0,a.useEffect)(()=>{g(Object.entries(l).map((e,t)=>{let[l,s]=e;return{id:"".concat(t,"-").concat(l),aliasName:l,targetModel:s}}))},[l]);let j=e=>{f({...e})},b=()=>{if(!y)return;if(!y.aliasName||!y.targetModel){c.Z.fromBackend("Please provide both alias name and target model");return}if(h.some(e=>e.id!==y.id&&e.aliasName===y.aliasName)){c.Z.fromBackend("An alias with this name already exists");return}let e=h.map(e=>e.id===y.id?y:e);g(e),f(null);let t={};e.forEach(e=>{t[e.aliasName]=e.targetModel}),m&&m(t),c.Z.success("Alias updated successfully")},v=()=>{f(null)},_=e=>{let t=h.filter(t=>t.id!==e);g(t);let l={};t.forEach(e=>{l[e.aliasName]=e.targetModel}),m&&m(l),c.Z.success("Alias deleted successfully")},N=h.reduce((e,t)=>(e[t.aliasName]=t.targetModel,e),{});return(0,s.jsxs)("div",{className:"mt-4",children:[(0,s.jsxs)("div",{className:"mb-6",children:[(0,s.jsx)(o.xv,{className:"text-sm font-medium text-gray-700 mb-2",children:"Add New Alias"}),(0,s.jsxs)("div",{className:"grid grid-cols-3 gap-4",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{className:"block text-xs text-gray-500 mb-1",children:"Alias Name"}),(0,s.jsx)("input",{type:"text",value:x.aliasName,onChange:e=>p({...x,aliasName:e.target.value}),placeholder:"e.g., gpt-4o",className:"w-full px-3 py-2 border border-gray-300 rounded-md text-sm"})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{className:"block text-xs text-gray-500 mb-1",children:"Target Model"}),(0,s.jsx)(d.Z,{accessToken:t,value:x.targetModel,placeholder:"Select target model",onChange:e=>p({...x,targetModel:e}),showLabel:!1})]}),(0,s.jsx)("div",{className:"flex items-end",children:(0,s.jsxs)("button",{onClick:()=>{if(!x.aliasName||!x.targetModel){c.Z.fromBackend("Please provide both alias name and target model");return}if(h.some(e=>e.aliasName===x.aliasName)){c.Z.fromBackend("An alias with this name already exists");return}let e=[...h,{id:"".concat(Date.now(),"-").concat(x.aliasName),aliasName:x.aliasName,targetModel:x.targetModel}];g(e),p({aliasName:"",targetModel:""});let t={};e.forEach(e=>{t[e.aliasName]=e.targetModel}),m&&m(t),c.Z.success("Alias added successfully")},disabled:!x.aliasName||!x.targetModel,className:"flex items-center px-4 py-2 rounded-md text-sm ".concat(x.aliasName&&x.targetModel?"bg-green-600 text-white hover:bg-green-700":"bg-gray-300 text-gray-500 cursor-not-allowed"),children:[(0,s.jsx)(r.Z,{className:"w-4 h-4 mr-1"}),"Add Alias"]})})]})]}),(0,s.jsx)(o.xv,{className:"text-sm font-medium text-gray-700 mb-2",children:"Manage Existing Aliases"}),(0,s.jsx)("div",{className:"rounded-lg custom-border relative mb-6",children:(0,s.jsx)("div",{className:"overflow-x-auto",children:(0,s.jsxs)(o.iA,{className:"[&_td]:py-0.5 [&_th]:py-1",children:[(0,s.jsx)(o.ss,{children:(0,s.jsxs)(o.SC,{children:[(0,s.jsx)(o.xs,{className:"py-1 h-8",children:"Alias Name"}),(0,s.jsx)(o.xs,{className:"py-1 h-8",children:"Target Model"}),(0,s.jsx)(o.xs,{className:"py-1 h-8",children:"Actions"})]})}),(0,s.jsxs)(o.RM,{children:[h.map(e=>(0,s.jsx)(o.SC,{className:"h-8",children:y&&y.id===e.id?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(o.pj,{className:"py-0.5",children:(0,s.jsx)("input",{type:"text",value:y.aliasName,onChange:e=>f({...y,aliasName:e.target.value}),className:"w-full px-2 py-1 border border-gray-300 rounded-md text-sm"})}),(0,s.jsx)(o.pj,{className:"py-0.5",children:(0,s.jsx)(d.Z,{accessToken:t,value:y.targetModel,onChange:e=>f({...y,targetModel:e}),showLabel:!1,style:{height:"32px"}})}),(0,s.jsx)(o.pj,{className:"py-0.5 whitespace-nowrap",children:(0,s.jsxs)("div",{className:"flex space-x-2",children:[(0,s.jsx)("button",{onClick:b,className:"text-xs bg-blue-50 text-blue-600 px-2 py-1 rounded hover:bg-blue-100",children:"Save"}),(0,s.jsx)("button",{onClick:v,className:"text-xs bg-gray-50 text-gray-600 px-2 py-1 rounded hover:bg-gray-100",children:"Cancel"})]})})]}):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(o.pj,{className:"py-0.5 text-sm text-gray-900",children:e.aliasName}),(0,s.jsx)(o.pj,{className:"py-0.5 text-sm text-gray-500",children:e.targetModel}),(0,s.jsx)(o.pj,{className:"py-0.5 whitespace-nowrap",children:(0,s.jsxs)("div",{className:"flex space-x-2",children:[(0,s.jsx)("button",{onClick:()=>j(e),className:"text-xs bg-blue-50 text-blue-600 px-2 py-1 rounded hover:bg-blue-100",children:(0,s.jsx)(i.Z,{className:"w-3 h-3"})}),(0,s.jsx)("button",{onClick:()=>_(e.id),className:"text-xs bg-red-50 text-red-600 px-2 py-1 rounded hover:bg-red-100",children:(0,s.jsx)(n.Z,{className:"w-3 h-3"})})]})})]})},e.id)),0===h.length&&(0,s.jsx)(o.SC,{children:(0,s.jsx)(o.pj,{colSpan:3,className:"py-0.5 text-sm text-gray-500 text-center",children:"No aliases added yet. Add a new alias above."})})]})]})})}),u&&(0,s.jsxs)(o.Zb,{children:[(0,s.jsx)(o.Dx,{className:"mb-4",children:"Configuration Example"}),(0,s.jsx)(o.xv,{className:"text-gray-600 mb-4",children:"Here's how your current aliases would look in the config:"}),(0,s.jsx)("div",{className:"bg-gray-100 rounded-lg p-4 font-mono text-sm",children:(0,s.jsxs)("div",{className:"text-gray-700",children:["model_aliases:",0===Object.keys(N).length?(0,s.jsxs)("span",{className:"text-gray-500",children:[(0,s.jsx)("br",{}),"\xa0\xa0# No aliases configured yet"]}):Object.entries(N).map(e=>{let[t,l]=e;return(0,s.jsxs)("span",{children:[(0,s.jsx)("br",{}),'\xa0\xa0"',t,'": "',l,'"']},t)})]})})]})]})}},76593:function(e,t,l){var s=l(57437),a=l(2265),r=l(56522),i=l(37592),n=l(69993),o=l(10703);t.Z=e=>{let{accessToken:t,value:l,placeholder:d="Select a Model",onChange:c,disabled:m=!1,style:u,className:h,showLabel:g=!0,labelText:x="Select Model"}=e,[p,y]=(0,a.useState)(l),[f,j]=(0,a.useState)(!1),[b,v]=(0,a.useState)([]),_=(0,a.useRef)(null);return(0,a.useEffect)(()=>{y(l)},[l]),(0,a.useEffect)(()=>{t&&(async()=>{try{let e=await (0,o.p)(t);console.log("Fetched models for selector:",e),e.length>0&&v(e)}catch(e){console.error("Error fetching model info:",e)}})()},[t]),(0,s.jsxs)("div",{children:[g&&(0,s.jsxs)(r.x,{className:"font-medium block mb-2 text-gray-700 flex items-center",children:[(0,s.jsx)(n.Z,{className:"mr-2"})," ",x]}),(0,s.jsx)(i.default,{value:p,placeholder:d,onChange:e=>{"custom"===e?(j(!0),y(void 0)):(j(!1),y(e),c&&c(e))},options:[...Array.from(new Set(b.map(e=>e.model_group))).map((e,t)=>({value:e,label:e,key:t})),{value:"custom",label:"Enter custom model",key:"custom"}],style:{width:"100%",...u},showSearch:!0,className:"rounded-md ".concat(h||""),disabled:m}),f&&(0,s.jsx)(r.o,{className:"mt-2",placeholder:"Enter custom model name",onValueChange:e=>{_.current&&clearTimeout(_.current),_.current=setTimeout(()=>{y(e),c&&c(e)},500)},disabled:m})]})}},2597:function(e,t,l){var s=l(57437);l(2265);var a=l(92280),r=l(54507);t.Z=function(e){let{value:t,onChange:l,premiumUser:i=!1,disabledCallbacks:n=[],onDisabledCallbacksChange:o}=e;return i?(0,s.jsx)(r.Z,{value:t,onChange:l,disabledCallbacks:n,onDisabledCallbacksChange:o}):(0,s.jsxs)("div",{children:[(0,s.jsxs)("div",{className:"flex flex-wrap gap-2 mb-3",children:[(0,s.jsx)("div",{className:"inline-flex items-center px-3 py-1.5 rounded-lg bg-green-50 border border-green-200 text-green-800 text-sm font-medium opacity-50",children:"✨ langfuse-logging"}),(0,s.jsx)("div",{className:"inline-flex items-center px-3 py-1.5 rounded-lg bg-green-50 border border-green-200 text-green-800 text-sm font-medium opacity-50",children:"✨ datadog-logging"})]}),(0,s.jsx)("div",{className:"p-3 bg-yellow-50 border border-yellow-200 rounded-lg",children:(0,s.jsxs)(a.x,{className:"text-sm text-yellow-800",children:["Setting Key/Team logging settings is a LiteLLM Enterprise feature. Global Logging Settings are available for all free users. Get a trial key"," ",(0,s.jsx)("a",{href:"https://www.litellm.ai/#pricing",target:"_blank",rel:"noopener noreferrer",className:"underline",children:"here"}),"."]})})]})}},65895:function(e,t,l){var s=l(57437);l(2265);var a=l(37592),r=l(10032),i=l(99981),n=l(15424);let{Option:o}=a.default;t.Z=e=>{let{type:t,name:l,showDetailedDescriptions:d=!0,className:c="",initialValue:m=null,form:u,onChange:h}=e,g=t.toUpperCase(),x=t.toLowerCase(),p="Select 'guaranteed_throughput' to prevent overallocating ".concat(g," limit when the key belongs to a Team with specific ").concat(g," limits.");return(0,s.jsx)(r.Z.Item,{label:(0,s.jsxs)("span",{children:[g," Rate Limit Type"," ",(0,s.jsx)(i.Z,{title:p,children:(0,s.jsx)(n.Z,{style:{marginLeft:"4px"}})})]}),name:l,initialValue:m,className:c,children:(0,s.jsx)(a.default,{defaultValue:d?"default":void 0,placeholder:"Select rate limit type",style:{width:"100%"},optionLabelProp:d?"label":void 0,onChange:e=>{u&&u.setFieldValue(l,e),h&&h(e)},children:d?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(o,{value:"best_effort_throughput",label:"Default",children:(0,s.jsxs)("div",{style:{padding:"4px 0"},children:[(0,s.jsx)("div",{style:{fontWeight:500},children:"Default"}),(0,s.jsxs)("div",{style:{fontSize:"11px",color:"#6b7280",marginTop:"2px"},children:["Best effort throughput - no error if we're overallocating ",x," (Team/Key Limits checked at runtime)."]})]})}),(0,s.jsx)(o,{value:"guaranteed_throughput",label:"Guaranteed throughput",children:(0,s.jsxs)("div",{style:{padding:"4px 0"},children:[(0,s.jsx)("div",{style:{fontWeight:500},children:"Guaranteed throughput"}),(0,s.jsxs)("div",{style:{fontSize:"11px",color:"#6b7280",marginTop:"2px"},children:["Guaranteed throughput - raise an error if we're overallocating ",x," (also checks model-specific limits)"]})]})}),(0,s.jsx)(o,{value:"dynamic",label:"Dynamic",children:(0,s.jsxs)("div",{style:{padding:"4px 0"},children:[(0,s.jsx)("div",{style:{fontWeight:500},children:"Dynamic"}),(0,s.jsxs)("div",{style:{fontSize:"11px",color:"#6b7280",marginTop:"2px"},children:["If the key has a set ",g," (e.g. 2 ",g,") and there are no 429 errors, it can dynamically exceed the limit when the model being called is not erroring."]})]})})]}):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(o,{value:"best_effort_throughput",children:"Best effort throughput"}),(0,s.jsx)(o,{value:"guaranteed_throughput",children:"Guaranteed throughput"}),(0,s.jsx)(o,{value:"dynamic",children:"Dynamic"})]})})})}},76364:function(e,t,l){var s=l(57437),a=l(2265),r=l(58643),i=l(19250),n=l(56334),o=l(89348),d=l(10703);let c=(0,a.forwardRef)((e,t)=>{let{accessToken:l,value:c,onChange:m,modelData:u}=e,[h,g]=(0,a.useState)({routerSettings:{},selectedStrategy:null,enableTagFiltering:!1}),[x,p]=(0,a.useState)([]),[y,f]=(0,a.useState)([]),[j,b]=(0,a.useState)([]),[v,_]=(0,a.useState)([]),[N,w]=(0,a.useState)({}),[k,S]=(0,a.useState)({}),Z=(0,a.useRef)(!1),C=(0,a.useRef)(null),M=e=>e&&0!==e.length?e.map((e,t)=>{let[l,s]=Object.entries(e)[0];return{id:(t+1).toString(),primaryModel:l||null,fallbackModels:s||[]}}):[{id:"1",primaryModel:null,fallbackModels:[]}],T=e=>e.filter(e=>e.primaryModel&&e.fallbackModels.length>0).map(e=>({[e.primaryModel]:e.fallbackModels}));(0,a.useEffect)(()=>{let e=(null==c?void 0:c.router_settings)?JSON.stringify({routing_strategy:c.router_settings.routing_strategy,fallbacks:c.router_settings.fallbacks,enable_tag_filtering:c.router_settings.enable_tag_filtering}):null;if(Z.current&&e===C.current){Z.current=!1;return}if(Z.current&&e!==C.current&&(Z.current=!1),e!==C.current){if(C.current=e,null==c?void 0:c.router_settings){var t;let e=c.router_settings,{fallbacks:l,...s}=e;g({routerSettings:s,selectedStrategy:e.routing_strategy||null,enableTagFiltering:null!==(t=e.enable_tag_filtering)&&void 0!==t&&t});let a=e.fallbacks||[];p(a),f(M(a))}else g({routerSettings:{},selectedStrategy:null,enableTagFiltering:!1}),p([]),f([{id:"1",primaryModel:null,fallbackModels:[]}])}},[c]),(0,a.useEffect)(()=>{l&&(0,i.getRouterSettingsCall)(l).then(e=>{if(e.fields){let t={};e.fields.forEach(e=>{t[e.field_name]={ui_field_name:e.ui_field_name,field_description:e.field_description,options:e.options,link:e.link}}),w(t);let l=e.fields.find(e=>"routing_strategy"===e.field_name);(null==l?void 0:l.options)&&_(l.options),e.routing_strategy_descriptions&&S(e.routing_strategy_descriptions)}})},[l]),(0,a.useEffect)(()=>{l&&(async()=>{try{let e=await (0,d.p)(l);b(e)}catch(e){console.error("Error fetching model info for fallbacks:",e)}})()},[l]);let L=()=>{let e=new Set(["allowed_fails","cooldown_time","num_retries","timeout","retry_after"]),t=new Set(["model_group_alias","retry_policy"]),l=(l,s,a)=>{if(null==s)return a;let r=String(s).trim();if(""===r||"null"===r.toLowerCase())return null;if(e.has(l)){let e=Number(r);return Number.isNaN(e)?a:e}if(t.has(l)){if(""===r)return null;try{return JSON.parse(r)}catch(e){return a}}return"true"===r.toLowerCase()||"false"!==r.toLowerCase()&&r},s=Object.fromEntries(Object.entries({...h.routerSettings,enable_tag_filtering:h.enableTagFiltering,routing_strategy:h.selectedStrategy,fallbacks:x.length>0?x:null}).map(e=>{let[t,s]=e;if("routing_strategy_args"!==t&&"routing_strategy"!==t&&"enable_tag_filtering"!==t&&"fallbacks"!==t){let e=document.querySelector('input[name="'.concat(t,'"]'));if(e&&void 0!==e.value&&""!==e.value){let a=l(t,e.value,s);return[t,a]}}else if("routing_strategy"===t)return[t,h.selectedStrategy];else if("enable_tag_filtering"===t)return[t,h.enableTagFiltering];else if("fallbacks"===t)return[t,x.length>0?x:null];else if("routing_strategy_args"===t&&"latency-based-routing"===h.selectedStrategy){let e=document.querySelector('input[name="lowest_latency_buffer"]'),t=document.querySelector('input[name="ttl"]'),l={};return(null==e?void 0:e.value)&&(l.lowest_latency_buffer=Number(e.value)),(null==t?void 0:t.value)&&(l.ttl=Number(t.value)),["routing_strategy_args",Object.keys(l).length>0?l:null]}return[t,s]}).filter(e=>null!=e)),a=function(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return null==e||"object"==typeof e&&!Array.isArray(e)&&0===Object.keys(e).length||t&&("number"!=typeof e||Number.isNaN(e))?null:e};return{routing_strategy:a(s.routing_strategy),allowed_fails:a(s.allowed_fails,!0),cooldown_time:a(s.cooldown_time,!0),num_retries:a(s.num_retries,!0),timeout:a(s.timeout,!0),retry_after:a(s.retry_after,!0),fallbacks:x.length>0?x:null,context_window_fallbacks:a(s.context_window_fallbacks),retry_policy:a(s.retry_policy),model_group_alias:a(s.model_group_alias),enable_tag_filtering:h.enableTagFiltering,routing_strategy_args:a(s.routing_strategy_args)}};(0,a.useEffect)(()=>{if(!m)return;let e=setTimeout(()=>{Z.current=!0,m({router_settings:L()})},100);return()=>clearTimeout(e)},[h,x]);let F=Array.from(new Set(j.map(e=>e.model_group))).sort();return((0,a.useImperativeHandle)(t,()=>({getValue:()=>({router_settings:L()})})),l)?(0,s.jsx)("div",{className:"w-full",children:(0,s.jsxs)(r.v0,{className:"w-full",children:[(0,s.jsxs)(r.td,{variant:"line",defaultValue:"1",className:"px-8 pt-4",children:[(0,s.jsx)(r.OK,{value:"1",children:"Loadbalancing"}),(0,s.jsx)(r.OK,{value:"2",children:"Fallbacks"})]}),(0,s.jsxs)(r.nP,{className:"px-8 py-6",children:[(0,s.jsx)(r.x4,{children:(0,s.jsx)(n.Z,{value:h,onChange:g,routerFieldsMetadata:N,availableRoutingStrategies:v,routingStrategyDescriptions:k})}),(0,s.jsx)(r.x4,{children:(0,s.jsx)(o.$,{groups:y,onGroupsChange:e=>{f(e),p(T(e))},availableModels:F,maxFallbacks:5,maxGroups:5})})]})]})}):null});c.displayName="RouterSettingsAccordion",t.Z=c},71098:function(e,t,l){l.d(t,{ZP:function(){return et},wk:function(){return X},Nr:function(){return ee}});var s=l(57437),a=l(30280),r=l(39760),i=l(59872),n=l(15424),o=l(29827),d=l(87452),c=l(88829),m=l(72208),u=l(78489),h=l(49804),g=l(67101),x=l(84264),p=l(49566),y=l(96761),f=l(37592),j=l(10032),b=l(22116),v=l(99981),_=l(29967),N=l(5545),w=l(63709),k=l(4260),S=l(7310),Z=l.n(S),C=l(2265),M=l(29233),T=l(20347),L=l(82586),F=l(97434),P=l(65925),A=l(63610),E=l(62099),I=l(72885),V=l(95096),R=l(2597),O=l(65895),D=l(76364),K=l(84376),U=l(7765),q=l(46468),B=l(97492),G=l(68473),z=l(9114),J=l(19250),W=l(24199),H=l(97415);let Y=e=>{let t;if(!(t=!e||"object"!=typeof e||e instanceof Error?String(e):JSON.stringify(e)).includes("/key/generate")&&!t.includes("KeyManagementRoutes.KEY_GENERATE"))return"Error creating the key: ".concat(e);let l=t;try{if(!e||"object"!=typeof e||e instanceof Error){let e=t.match(/\{[\s\S]*\}/);if(e){let t=JSON.parse(e[0]),s=(null==t?void 0:t.error)||t;(null==s?void 0:s.message)&&(l=s.message)}}else{let t=(null==e?void 0:e.error)||e;(null==t?void 0:t.message)&&(l=t.message)}}catch(e){}return t.includes("team_member_permission_error")||l.includes("Team member does not have permissions")?"Team member does not have permission to generate key for this team. Ask your proxy admin to configure the team member permission settings.":"Error creating the key: ".concat(e)},{Option:$}=f.default,Q=e=>{let t=[];if(console.log("data:",JSON.stringify(e)),e)for(let l of e)l.metadata&&l.metadata.tags&&t.push(...l.metadata.tags);let l=Array.from(new Set(t)).map(e=>({value:e,label:e}));return console.log("uniqueTags:",l),l},X=async(e,t,l,s)=>{try{if(null===e||null===t)return[];if(null!==l){let a=(await (0,J.modelAvailableCall)(l,e,t,!0,s,!0)).data.map(e=>e.id);return console.log("available_model_names:",a),a}return[]}catch(e){return console.error("Error fetching user models:",e),[]}},ee=async(e,t,l,s)=>{try{if(null===e||null===t)return;if(null!==l){let a=(await (0,J.modelAvailableCall)(l,e,t)).data.map(e=>e.id);console.log("available_model_names:",a),s(a)}}catch(e){console.error("Error fetching user models:",e)}};var et=e=>{let{team:t,teams:l,data:S,addKey:et}=e,{accessToken:el,userId:es,userRole:ea,premiumUser:er}=(0,r.Z)(),ei=(0,o.NL)(),[en]=j.Z.useForm(),[eo,ed]=(0,C.useState)(!1),[ec,em]=(0,C.useState)(null),[eu,eh]=(0,C.useState)(null),[eg,ex]=(0,C.useState)([]),[ep,ey]=(0,C.useState)([]),[ef,ej]=(0,C.useState)("you"),[eb,ev]=(0,C.useState)(Q(S)),[e_,eN]=(0,C.useState)([]),[ew,ek]=(0,C.useState)([]),[eS,eZ]=(0,C.useState)([]),[eC,eM]=(0,C.useState)([]),[eT,eL]=(0,C.useState)(t),[eF,eP]=(0,C.useState)(!1),[eA,eE]=(0,C.useState)(null),[eI,eV]=(0,C.useState)({}),[eR,eO]=(0,C.useState)([]),[eD,eK]=(0,C.useState)(!1),[eU,eq]=(0,C.useState)([]),[eB,eG]=(0,C.useState)([]),[ez,eJ]=(0,C.useState)("llm_api"),[eW,eH]=(0,C.useState)({}),[eY,e$]=(0,C.useState)(!1),[eQ,eX]=(0,C.useState)("30d"),[e0,e4]=(0,C.useState)(null),[e1,e2]=(0,C.useState)(0),e5=()=>{ed(!1),en.resetFields(),eM([]),eG([]),eJ("llm_api"),eH({}),e$(!1),eX("30d"),e4(null),e2(e=>e+1)},e3=()=>{ed(!1),em(null),eL(null),en.resetFields(),eM([]),eG([]),eJ("llm_api"),eH({}),e$(!1),eX("30d"),e4(null),e2(e=>e+1)};(0,C.useEffect)(()=>{es&&ea&&el&&ee(es,ea,el,ex)},[el,es,ea]),(0,C.useEffect)(()=>{let e=async()=>{try{let e=(await (0,J.getPoliciesList)(el)).policies.map(e=>e.policy_name);ek(e)}catch(e){console.error("Failed to fetch policies:",e)}},t=async()=>{try{let e=await (0,J.getPromptsList)(el);eZ(e.prompts.map(e=>e.prompt_id))}catch(e){console.error("Failed to fetch prompts:",e)}};(async()=>{try{let e=(await (0,J.getGuardrailsList)(el)).guardrails.map(e=>e.guardrail_name);eN(e)}catch(e){console.error("Failed to fetch guardrails:",e)}})(),e(),t()},[el]),(0,C.useEffect)(()=>{(async()=>{try{if(el){let e=sessionStorage.getItem("possibleUserRoles");if(e)eV(JSON.parse(e));else{let e=await (0,J.getPossibleUserRoles)(el);sessionStorage.setItem("possibleUserRoles",JSON.stringify(e)),eV(e)}}}catch(e){console.error("Error fetching possible user roles:",e)}})()},[el]);let e7=ep.includes("no-default-models")&&!eT,e6=async e=>{try{var t,l,s,r,i,n,o;let d;let c=null!==(i=null==e?void 0:e.key_alias)&&void 0!==i?i:"",m=null!==(n=null==e?void 0:e.team_id)&&void 0!==n?n:null;if((null!==(o=null==S?void 0:S.filter(e=>e.team_id===m).map(e=>e.key_alias))&&void 0!==o?o:[]).includes(c))throw Error("Key alias ".concat(c," already exists for team with ID ").concat(m,", please provide another key alias"));z.Z.info("Making API Call"),ed(!0),"you"===ef&&(e.user_id=es);let u={};try{u=JSON.parse(e.metadata||"{}")}catch(e){console.error("Error parsing metadata:",e)}if("service_account"===ef&&(u.service_account_id=e.key_alias),eC.length>0&&(u={...u,logging:eC.filter(e=>e.callback_name)}),eB.length>0){let e=(0,F.Z3)(eB);u={...u,litellm_disabled_callbacks:e}}if(eY&&(e.auto_rotate=!0,e.rotation_interval=eQ),e.duration&&""!==e.duration.trim()||(e.duration=null),e.metadata=JSON.stringify(u),e.allowed_vector_store_ids&&e.allowed_vector_store_ids.length>0&&(e.object_permission={vector_stores:e.allowed_vector_store_ids},delete e.allowed_vector_store_ids),e.allowed_mcp_servers_and_groups&&((null===(t=e.allowed_mcp_servers_and_groups.servers)||void 0===t?void 0:t.length)>0||(null===(l=e.allowed_mcp_servers_and_groups.accessGroups)||void 0===l?void 0:l.length)>0)){e.object_permission||(e.object_permission={});let{servers:t,accessGroups:l}=e.allowed_mcp_servers_and_groups;t&&t.length>0&&(e.object_permission.mcp_servers=t),l&&l.length>0&&(e.object_permission.mcp_access_groups=l),delete e.allowed_mcp_servers_and_groups}let h=e.mcp_tool_permissions||{};if(Object.keys(h).length>0&&(e.object_permission||(e.object_permission={}),e.object_permission.mcp_tool_permissions=h),delete e.mcp_tool_permissions,e.allowed_mcp_access_groups&&e.allowed_mcp_access_groups.length>0&&(e.object_permission||(e.object_permission={}),e.object_permission.mcp_access_groups=e.allowed_mcp_access_groups,delete e.allowed_mcp_access_groups),e.allowed_agents_and_groups&&((null===(s=e.allowed_agents_and_groups.agents)||void 0===s?void 0:s.length)>0||(null===(r=e.allowed_agents_and_groups.accessGroups)||void 0===r?void 0:r.length)>0)){e.object_permission||(e.object_permission={});let{agents:t,accessGroups:l}=e.allowed_agents_and_groups;t&&t.length>0&&(e.object_permission.agents=t),l&&l.length>0&&(e.object_permission.agent_access_groups=l),delete e.allowed_agents_and_groups}Object.keys(eW).length>0&&(e.aliases=JSON.stringify(eW)),(null==e0?void 0:e0.router_settings)&&Object.values(e0.router_settings).some(e=>null!=e&&""!==e)&&(e.router_settings=e0.router_settings),d="service_account"===ef?await (0,J.keyCreateServiceAccountCall)(el,e):await (0,J.keyCreateCall)(el,es,e),console.log("key create Response:",d),et(d),ei.invalidateQueries({queryKey:a.Km.lists()}),em(d.key),eh(d.soft_budget),z.Z.success("Virtual Key Created"),en.resetFields(),localStorage.removeItem("userData"+es)}catch(t){console.log("error in create key:",t);let e=Y(t);z.Z.fromBackend(e)}};(0,C.useEffect)(()=>{if(es&&ea&&el){var e;X(es,ea,el,null!==(e=null==eT?void 0:eT.team_id)&&void 0!==e?e:null).then(e=>{var t;ey(Array.from(new Set([...null!==(t=null==eT?void 0:eT.models)&&void 0!==t?t:[],...e])))})}en.setFieldValue("models",[])},[eT,el,es,ea]);let e9=async e=>{if(!e){eO([]);return}eK(!0);try{let t=new URLSearchParams;if(t.append("user_email",e),null==el)return;let l=(await (0,J.userFilterUICall)(el,t)).map(e=>({label:"".concat(e.user_email," (").concat(e.user_id,")"),value:e.user_id,user:e}));eO(l)}catch(e){console.error("Error fetching users:",e),z.Z.fromBackend("Failed to search for users")}finally{eK(!1)}},e8=(0,C.useCallback)(Z()(e=>e9(e),300),[el]),te=(e,t)=>{let l=t.user;en.setFieldsValue({user_id:l.user_id})};return(0,s.jsxs)("div",{children:[ea&&T.LQ.includes(ea)&&(0,s.jsx)(u.Z,{className:"mx-auto",onClick:()=>ed(!0),children:"+ Create New Key"}),(0,s.jsx)(b.Z,{open:eo,width:1e3,footer:null,onOk:e5,onCancel:e3,children:(0,s.jsxs)(j.Z,{form:en,onFinish:e6,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",children:[(0,s.jsxs)("div",{className:"mb-8",children:[(0,s.jsx)(y.Z,{className:"mb-4",children:"Key Ownership"}),(0,s.jsx)(j.Z.Item,{label:(0,s.jsxs)("span",{children:["Owned By"," ",(0,s.jsx)(v.Z,{title:"Select who will own this Virtual Key",children:(0,s.jsx)(n.Z,{style:{marginLeft:"4px"}})})]}),className:"mb-4",children:(0,s.jsxs)(_.ZP.Group,{onChange:e=>ej(e.target.value),value:ef,children:[(0,s.jsx)(_.ZP,{value:"you",children:"You"}),(0,s.jsx)(_.ZP,{value:"service_account",children:"Service Account"}),"Admin"===ea&&(0,s.jsx)(_.ZP,{value:"another_user",children:"Another User"})]})}),"another_user"===ef&&(0,s.jsx)(j.Z.Item,{label:(0,s.jsxs)("span",{children:["User ID"," ",(0,s.jsx)(v.Z,{title:"The user who will own this key and be responsible for its usage",children:(0,s.jsx)(n.Z,{style:{marginLeft:"4px"}})})]}),name:"user_id",className:"mt-4",rules:[{required:"another_user"===ef,message:"Please input the user ID of the user you are assigning the key to"}],children:(0,s.jsxs)("div",{children:[(0,s.jsxs)("div",{style:{display:"flex",marginBottom:"8px"},children:[(0,s.jsx)(f.default,{showSearch:!0,placeholder:"Type email to search for users",filterOption:!1,onSearch:e=>{e8(e)},onSelect:(e,t)=>te(e,t),options:eR,loading:eD,allowClear:!0,style:{width:"100%"},notFoundContent:eD?"Searching...":"No users found"}),(0,s.jsx)(N.ZP,{onClick:()=>eP(!0),style:{marginLeft:"8px"},children:"Create User"})]}),(0,s.jsx)("div",{className:"text-xs text-gray-500",children:"Search by email to find users"})]})}),(0,s.jsx)(j.Z.Item,{label:(0,s.jsxs)("span",{children:["Team"," ",(0,s.jsx)(v.Z,{title:"The team this key belongs to, which determines available models and budget limits",children:(0,s.jsx)(n.Z,{style:{marginLeft:"4px"}})})]}),name:"team_id",initialValue:t?t.team_id:null,className:"mt-4",rules:[{required:"service_account"===ef,message:"Please select a team for the service account"}],help:"service_account"===ef?"required":"",children:(0,s.jsx)(K.Z,{teams:l,onChange:e=>{eL((null==l?void 0:l.find(t=>t.team_id===e))||null)}})})]}),e7&&(0,s.jsx)("div",{className:"mb-8 p-4 bg-blue-50 border border-blue-200 rounded-md",children:(0,s.jsx)(x.Z,{className:"text-blue-800 text-sm",children:"Please select a team to continue configuring your Virtual Key. If you do not see any teams, please contact your Proxy Admin to either provide you with access to models or to add you to a team."})}),!e7&&(0,s.jsxs)("div",{className:"mb-8",children:[(0,s.jsx)(y.Z,{className:"mb-4",children:"Key Details"}),(0,s.jsx)(j.Z.Item,{label:(0,s.jsxs)("span",{children:["you"===ef||"another_user"===ef?"Key Name":"Service Account ID"," ",(0,s.jsx)(v.Z,{title:"you"===ef||"another_user"===ef?"A descriptive name to identify this key":"Unique identifier for this service account",children:(0,s.jsx)(n.Z,{style:{marginLeft:"4px"}})})]}),name:"key_alias",rules:[{required:!0,message:"Please input a ".concat("you"===ef?"key name":"service account ID")}],help:"required",children:(0,s.jsx)(p.Z,{placeholder:""})}),(0,s.jsx)(j.Z.Item,{label:(0,s.jsxs)("span",{children:["Models"," ",(0,s.jsx)(v.Z,{title:"Select which models this key can access. Choose 'All Team Models' to grant access to all models available to the team",children:(0,s.jsx)(n.Z,{style:{marginLeft:"4px"}})})]}),name:"models",rules:"management"===ez||"read_only"===ez?[]:[{required:!0,message:"Please select a model"}],help:"management"===ez||"read_only"===ez?"Models field is disabled for this key type":"required",className:"mt-4",children:(0,s.jsxs)(f.default,{mode:"multiple",placeholder:"Select models",style:{width:"100%"},disabled:"management"===ez||"read_only"===ez,onChange:e=>{e.includes("all-team-models")&&en.setFieldsValue({models:["all-team-models"]})},children:[(0,s.jsx)($,{value:"all-team-models",children:"All Team Models"},"all-team-models"),ep.map(e=>(0,s.jsx)($,{value:e,children:(0,q.W0)(e)},e))]})}),(0,s.jsx)(j.Z.Item,{label:(0,s.jsxs)("span",{children:["Key Type"," ",(0,s.jsx)(v.Z,{title:"Select the type of key to determine what routes and operations this key can access",children:(0,s.jsx)(n.Z,{style:{marginLeft:"4px"}})})]}),name:"key_type",initialValue:"llm_api",className:"mt-4",children:(0,s.jsxs)(f.default,{defaultValue:"llm_api",placeholder:"Select key type",style:{width:"100%"},optionLabelProp:"label",onChange:e=>{eJ(e),("management"===e||"read_only"===e)&&en.setFieldsValue({models:[]})},children:[(0,s.jsx)($,{value:"default",label:"Default",children:(0,s.jsxs)("div",{style:{padding:"4px 0"},children:[(0,s.jsx)("div",{style:{fontWeight:500},children:"Default"}),(0,s.jsx)("div",{style:{fontSize:"11px",color:"#6b7280",marginTop:"2px"},children:"Can call LLM API + Management routes"})]})}),(0,s.jsx)($,{value:"llm_api",label:"LLM API",children:(0,s.jsxs)("div",{style:{padding:"4px 0"},children:[(0,s.jsx)("div",{style:{fontWeight:500},children:"LLM API"}),(0,s.jsx)("div",{style:{fontSize:"11px",color:"#6b7280",marginTop:"2px"},children:"Can call only LLM API routes (chat/completions, embeddings, etc.)"})]})}),(0,s.jsx)($,{value:"management",label:"Management",children:(0,s.jsxs)("div",{style:{padding:"4px 0"},children:[(0,s.jsx)("div",{style:{fontWeight:500},children:"Management"}),(0,s.jsx)("div",{style:{fontSize:"11px",color:"#6b7280",marginTop:"2px"},children:"Can call only management routes (user/team/key management)"})]})})]})})]}),!e7&&(0,s.jsx)("div",{className:"mb-8",children:(0,s.jsxs)(d.Z,{className:"mt-4 mb-4",children:[(0,s.jsx)(m.Z,{children:(0,s.jsx)(y.Z,{className:"m-0",children:"Optional Settings"})}),(0,s.jsxs)(c.Z,{children:[(0,s.jsx)(j.Z.Item,{className:"mt-4",label:(0,s.jsxs)("span",{children:["Max Budget (USD)"," ",(0,s.jsx)(v.Z,{title:"Maximum amount in USD this key can spend. When reached, the key will be blocked from making further requests",children:(0,s.jsx)(n.Z,{style:{marginLeft:"4px"}})})]}),name:"max_budget",help:"Budget cannot exceed team max budget: $".concat((null==t?void 0:t.max_budget)!==null&&(null==t?void 0:t.max_budget)!==void 0?null==t?void 0:t.max_budget:"unlimited"),rules:[{validator:async(e,l)=>{if(l&&t&&null!==t.max_budget&&l>t.max_budget)throw Error("Budget cannot exceed team max budget: $".concat((0,i.pw)(t.max_budget,4)))}}],children:(0,s.jsx)(W.Z,{step:.01,precision:2,width:200})}),(0,s.jsx)(j.Z.Item,{className:"mt-4",label:(0,s.jsxs)("span",{children:["Reset Budget"," ",(0,s.jsx)(v.Z,{title:"How often the budget should reset. For example, setting 'daily' will reset the budget every 24 hours",children:(0,s.jsx)(n.Z,{style:{marginLeft:"4px"}})})]}),name:"budget_duration",help:"Team Reset Budget: ".concat((null==t?void 0:t.budget_duration)!==null&&(null==t?void 0:t.budget_duration)!==void 0?null==t?void 0:t.budget_duration:"None"),children:(0,s.jsx)(P.Z,{onChange:e=>en.setFieldValue("budget_duration",e)})}),(0,s.jsx)(j.Z.Item,{className:"mt-4",label:(0,s.jsxs)("span",{children:["Tokens per minute Limit (TPM)"," ",(0,s.jsx)(v.Z,{title:"Maximum number of tokens this key can process per minute. Helps control usage and costs",children:(0,s.jsx)(n.Z,{style:{marginLeft:"4px"}})})]}),name:"tpm_limit",help:"TPM cannot exceed team TPM limit: ".concat((null==t?void 0:t.tpm_limit)!==null&&(null==t?void 0:t.tpm_limit)!==void 0?null==t?void 0:t.tpm_limit:"unlimited"),rules:[{validator:async(e,l)=>{if(l&&t&&null!==t.tpm_limit&&l>t.tpm_limit)throw Error("TPM limit cannot exceed team TPM limit: ".concat(t.tpm_limit))}}],children:(0,s.jsx)(W.Z,{step:1,width:400})}),(0,s.jsx)(O.Z,{type:"tpm",name:"tpm_limit_type",className:"mt-4",initialValue:null,form:en,showDetailedDescriptions:!0}),(0,s.jsx)(j.Z.Item,{className:"mt-4",label:(0,s.jsxs)("span",{children:["Requests per minute Limit (RPM)"," ",(0,s.jsx)(v.Z,{title:"Maximum number of API requests this key can make per minute. Helps prevent abuse and manage load",children:(0,s.jsx)(n.Z,{style:{marginLeft:"4px"}})})]}),name:"rpm_limit",help:"RPM cannot exceed team RPM limit: ".concat((null==t?void 0:t.rpm_limit)!==null&&(null==t?void 0:t.rpm_limit)!==void 0?null==t?void 0:t.rpm_limit:"unlimited"),rules:[{validator:async(e,l)=>{if(l&&t&&null!==t.rpm_limit&&l>t.rpm_limit)throw Error("RPM limit cannot exceed team RPM limit: ".concat(t.rpm_limit))}}],children:(0,s.jsx)(W.Z,{step:1,width:400})}),(0,s.jsx)(O.Z,{type:"rpm",name:"rpm_limit_type",className:"mt-4",initialValue:null,form:en,showDetailedDescriptions:!0}),(0,s.jsx)(j.Z.Item,{label:(0,s.jsxs)("span",{children:["Guardrails"," ",(0,s.jsx)(v.Z,{title:"Apply safety guardrails to this key to filter content or enforce policies",children:(0,s.jsx)("a",{href:"https://docs.litellm.ai/docs/proxy/guardrails/quick_start",target:"_blank",rel:"noopener noreferrer",onClick:e=>e.stopPropagation(),children:(0,s.jsx)(n.Z,{style:{marginLeft:"4px"}})})})]}),name:"guardrails",className:"mt-4",help:er?"Select existing guardrails or enter new ones":"Premium feature - Upgrade to set guardrails by key",children:(0,s.jsx)(f.default,{mode:"tags",style:{width:"100%"},disabled:!er,placeholder:er?"Select or enter guardrails":"Premium feature - Upgrade to set guardrails by key",options:e_.map(e=>({value:e,label:e}))})}),(0,s.jsx)(j.Z.Item,{label:(0,s.jsxs)("span",{children:["Disable Global Guardrails"," ",(0,s.jsx)(v.Z,{title:"When enabled, this key will bypass any guardrails configured to run on every request (global guardrails)",children:(0,s.jsx)("a",{href:"https://docs.litellm.ai/docs/proxy/guardrails/quick_start",target:"_blank",rel:"noopener noreferrer",onClick:e=>e.stopPropagation(),children:(0,s.jsx)(n.Z,{style:{marginLeft:"4px"}})})})]}),name:"disable_global_guardrails",className:"mt-4",valuePropName:"checked",help:er?"Bypass global guardrails for this key":"Premium feature - Upgrade to disable global guardrails by key",children:(0,s.jsx)(w.Z,{disabled:!er,checkedChildren:"Yes",unCheckedChildren:"No"})}),(0,s.jsx)(j.Z.Item,{label:(0,s.jsxs)("span",{children:["Policies"," ",(0,s.jsx)(v.Z,{title:"Apply policies to this key to control guardrails and other settings",children:(0,s.jsx)("a",{href:"https://docs.litellm.ai/docs/proxy/guardrails/guardrail_policies",target:"_blank",rel:"noopener noreferrer",onClick:e=>e.stopPropagation(),children:(0,s.jsx)(n.Z,{style:{marginLeft:"4px"}})})})]}),name:"policies",className:"mt-4",help:er?"Select existing policies or enter new ones":"Premium feature - Upgrade to set policies by key",children:(0,s.jsx)(f.default,{mode:"tags",style:{width:"100%"},disabled:!er,placeholder:er?"Select or enter policies":"Premium feature - Upgrade to set policies by key",options:ew.map(e=>({value:e,label:e}))})}),(0,s.jsx)(j.Z.Item,{label:(0,s.jsxs)("span",{children:["Prompts"," ",(0,s.jsx)(v.Z,{title:"Allow this key to use specific prompt templates",children:(0,s.jsx)("a",{href:"https://docs.litellm.ai/docs/proxy/prompt_management",target:"_blank",rel:"noopener noreferrer",onClick:e=>e.stopPropagation(),children:(0,s.jsx)(n.Z,{style:{marginLeft:"4px"}})})})]}),name:"prompts",className:"mt-4",help:er?"Select existing prompts or enter new ones":"Premium feature - Upgrade to set prompts by key",children:(0,s.jsx)(f.default,{mode:"tags",style:{width:"100%"},disabled:!er,placeholder:er?"Select or enter prompts":"Premium feature - Upgrade to set prompts by key",options:eS.map(e=>({value:e,label:e}))})}),(0,s.jsx)(j.Z.Item,{label:(0,s.jsxs)("span",{children:["Allowed Pass Through Routes"," ",(0,s.jsx)(v.Z,{title:"Allow this key to use specific pass through routes",children:(0,s.jsx)("a",{href:"https://docs.litellm.ai/docs/proxy/pass_through",target:"_blank",rel:"noopener noreferrer",onClick:e=>e.stopPropagation(),children:(0,s.jsx)(n.Z,{style:{marginLeft:"4px"}})})})]}),name:"allowed_passthrough_routes",className:"mt-4",help:er?"Select existing pass through routes or enter new ones":"Premium feature - Upgrade to set pass through routes by key",children:(0,s.jsx)(V.Z,{onChange:e=>en.setFieldValue("allowed_passthrough_routes",e),value:en.getFieldValue("allowed_passthrough_routes"),accessToken:el,placeholder:er?"Select or enter pass through routes":"Premium feature - Upgrade to set pass through routes by key",disabled:!er,teamId:eT?eT.team_id:null})}),(0,s.jsx)(j.Z.Item,{label:(0,s.jsxs)("span",{children:["Allowed Vector Stores"," ",(0,s.jsx)(v.Z,{title:"Select which vector stores this key can access. If none selected, the key will have access to all available vector stores",children:(0,s.jsx)(n.Z,{style:{marginLeft:"4px"}})})]}),name:"allowed_vector_store_ids",className:"mt-4",help:"Select vector stores this key can access. Leave empty for access to all vector stores",children:(0,s.jsx)(H.Z,{onChange:e=>en.setFieldValue("allowed_vector_store_ids",e),value:en.getFieldValue("allowed_vector_store_ids"),accessToken:el,placeholder:"Select vector stores (optional)"})}),(0,s.jsx)(j.Z.Item,{label:(0,s.jsxs)("span",{children:["Metadata"," ",(0,s.jsx)(v.Z,{title:"JSON object with additional information about this key. Used for tracking or custom logic",children:(0,s.jsx)(n.Z,{style:{marginLeft:"4px"}})})]}),name:"metadata",className:"mt-4",children:(0,s.jsx)(k.default.TextArea,{rows:4,placeholder:"Enter metadata as JSON"})}),(0,s.jsx)(j.Z.Item,{label:(0,s.jsxs)("span",{children:["Tags"," ",(0,s.jsx)(v.Z,{title:"Tags for tracking spend and/or doing tag-based routing. Used for analytics and filtering",children:(0,s.jsx)(n.Z,{style:{marginLeft:"4px"}})})]}),name:"tags",className:"mt-4",help:"Tags for tracking spend and/or doing tag-based routing.",children:(0,s.jsx)(f.default,{mode:"tags",style:{width:"100%"},placeholder:"Enter tags",tokenSeparators:[","],options:eb})}),(0,s.jsxs)(d.Z,{className:"mt-4 mb-4",children:[(0,s.jsx)(m.Z,{children:(0,s.jsx)("b",{children:"MCP Settings"})}),(0,s.jsxs)(c.Z,{children:[(0,s.jsx)(j.Z.Item,{label:(0,s.jsxs)("span",{children:["Allowed MCP Servers"," ",(0,s.jsx)(v.Z,{title:"Select which MCP servers or access groups this key can access",children:(0,s.jsx)(n.Z,{style:{marginLeft:"4px"}})})]}),name:"allowed_mcp_servers_and_groups",help:"Select MCP servers or access groups this key can access",children:(0,s.jsx)(B.Z,{onChange:e=>en.setFieldValue("allowed_mcp_servers_and_groups",e),value:en.getFieldValue("allowed_mcp_servers_and_groups"),accessToken:el,placeholder:"Select MCP servers or access groups (optional)"})}),(0,s.jsx)(j.Z.Item,{name:"mcp_tool_permissions",initialValue:{},hidden:!0,children:(0,s.jsx)(k.default,{type:"hidden"})}),(0,s.jsx)(j.Z.Item,{noStyle:!0,shouldUpdate:(e,t)=>e.allowed_mcp_servers_and_groups!==t.allowed_mcp_servers_and_groups||e.mcp_tool_permissions!==t.mcp_tool_permissions,children:()=>{var e;return(0,s.jsx)("div",{className:"mt-6",children:(0,s.jsx)(G.Z,{accessToken:el,selectedServers:(null===(e=en.getFieldValue("allowed_mcp_servers_and_groups"))||void 0===e?void 0:e.servers)||[],toolPermissions:en.getFieldValue("mcp_tool_permissions")||{},onChange:e=>en.setFieldsValue({mcp_tool_permissions:e})})})}})]})]}),(0,s.jsxs)(d.Z,{className:"mt-4 mb-4",children:[(0,s.jsx)(m.Z,{children:(0,s.jsx)("b",{children:"Agent Settings"})}),(0,s.jsx)(c.Z,{children:(0,s.jsx)(j.Z.Item,{label:(0,s.jsxs)("span",{children:["Allowed Agents"," ",(0,s.jsx)(v.Z,{title:"Select which agents or access groups this key can access",children:(0,s.jsx)(n.Z,{style:{marginLeft:"4px"}})})]}),name:"allowed_agents_and_groups",help:"Select agents or access groups this key can access",children:(0,s.jsx)(L.Z,{onChange:e=>en.setFieldValue("allowed_agents_and_groups",e),value:en.getFieldValue("allowed_agents_and_groups"),accessToken:el,placeholder:"Select agents or access groups (optional)"})})})]}),er?(0,s.jsxs)(d.Z,{className:"mt-4 mb-4",children:[(0,s.jsx)(m.Z,{children:(0,s.jsx)("b",{children:"Logging Settings"})}),(0,s.jsx)(c.Z,{children:(0,s.jsx)("div",{className:"mt-4",children:(0,s.jsx)(R.Z,{value:eC,onChange:eM,premiumUser:!0,disabledCallbacks:eB,onDisabledCallbacksChange:eG})})})]}):(0,s.jsx)(v.Z,{title:(0,s.jsxs)("span",{children:["Key-level logging settings is an enterprise feature, get in touch -",(0,s.jsx)("a",{href:"https://www.litellm.ai/enterprise",target:"_blank",children:"https://www.litellm.ai/enterprise"})]}),placement:"top",children:(0,s.jsxs)("div",{style:{position:"relative"},children:[(0,s.jsx)("div",{style:{opacity:.5},children:(0,s.jsxs)(d.Z,{className:"mt-4 mb-4",children:[(0,s.jsx)(m.Z,{children:(0,s.jsx)("b",{children:"Logging Settings"})}),(0,s.jsx)(c.Z,{children:(0,s.jsx)("div",{className:"mt-4",children:(0,s.jsx)(R.Z,{value:eC,onChange:eM,premiumUser:!1,disabledCallbacks:eB,onDisabledCallbacksChange:eG})})})]})}),(0,s.jsx)("div",{style:{position:"absolute",inset:0,cursor:"not-allowed"}})]})}),(0,s.jsxs)(d.Z,{className:"mt-4 mb-4",children:[(0,s.jsx)(m.Z,{children:(0,s.jsx)("b",{children:"Router Settings"})}),(0,s.jsx)(c.Z,{children:(0,s.jsx)("div",{className:"mt-4 w-full",children:(0,s.jsx)(D.Z,{accessToken:el||"",value:e0||void 0,onChange:e4,modelData:eg.length>0?{data:eg.map(e=>({model_name:e}))}:void 0},e1)})})]},"router-settings-accordion-".concat(e1)),(0,s.jsxs)(d.Z,{className:"mt-4 mb-4",children:[(0,s.jsx)(m.Z,{children:(0,s.jsx)("b",{children:"Model Aliases"})}),(0,s.jsx)(c.Z,{children:(0,s.jsxs)("div",{className:"mt-4",children:[(0,s.jsx)(x.Z,{className:"text-sm text-gray-600 mb-4",children:"Create custom aliases for models that can be used in API calls. This allows you to create shortcuts for specific models."}),(0,s.jsx)(I.Z,{accessToken:el,initialModelAliases:eW,onAliasUpdate:eH,showExampleConfig:!1})]})})]}),(0,s.jsxs)(d.Z,{className:"mt-4 mb-4",children:[(0,s.jsx)(m.Z,{children:(0,s.jsx)("b",{children:"Key Lifecycle"})}),(0,s.jsx)(c.Z,{children:(0,s.jsx)("div",{className:"mt-4",children:(0,s.jsx)(E.Z,{form:en,autoRotationEnabled:eY,onAutoRotationChange:e$,rotationInterval:eQ,onRotationIntervalChange:eX,isCreateMode:!0})})}),(0,s.jsx)(j.Z.Item,{name:"duration",hidden:!0,initialValue:null,children:(0,s.jsx)(k.default,{})})]}),(0,s.jsxs)(d.Z,{className:"mt-4 mb-4",children:[(0,s.jsx)(m.Z,{children:(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)("b",{children:"Advanced Settings"}),(0,s.jsx)(v.Z,{title:(0,s.jsxs)("span",{children:["Learn more about advanced settings in our"," ",(0,s.jsx)("a",{href:J.proxyBaseUrl?"".concat(J.proxyBaseUrl,"/#/key%20management/generate_key_fn_key_generate_post"):"/#/key%20management/generate_key_fn_key_generate_post",target:"_blank",rel:"noopener noreferrer",className:"text-blue-400 hover:text-blue-300",children:"documentation"})]}),children:(0,s.jsx)(n.Z,{className:"text-gray-400 hover:text-gray-300 cursor-help"})})]})}),(0,s.jsx)(c.Z,{children:(0,s.jsx)(A.Z,{schemaComponent:"GenerateKeyRequest",form:en,excludedFields:["key_alias","team_id","models","duration","metadata","tags","guardrails","max_budget","budget_duration","tpm_limit","rpm_limit"]})})]})]})]})}),(0,s.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,s.jsx)(N.ZP,{htmlType:"submit",disabled:e7,style:{opacity:e7?.5:1},children:"Create Key"})})]})}),eF&&(0,s.jsx)(b.Z,{title:"Create New User",visible:eF,onCancel:()=>eP(!1),footer:null,width:800,children:(0,s.jsx)(U.Z,{userID:es,accessToken:el,teams:l,possibleUIRoles:eI,onUserCreated:e=>{eE(e),en.setFieldsValue({user_id:e}),eP(!1)},isEmbedded:!0})}),ec&&(0,s.jsx)(b.Z,{visible:eo,onOk:e5,onCancel:e3,footer:null,children:(0,s.jsxs)(g.Z,{numItems:1,className:"gap-2 w-full",children:[(0,s.jsx)(y.Z,{children:"Save your Key"}),(0,s.jsx)(h.Z,{numColSpan:1,children:(0,s.jsxs)("p",{children:["Please save this secret key somewhere safe and accessible. For security reasons,"," ",(0,s.jsx)("b",{children:"you will not be able to view it again"})," through your LiteLLM account. If you lose this secret key, you will need to generate a new one."]})}),(0,s.jsx)(h.Z,{numColSpan:1,children:null!=ec?(0,s.jsxs)("div",{children:[(0,s.jsx)(x.Z,{className:"mt-3",children:"Virtual Key:"}),(0,s.jsx)("div",{style:{background:"#f8f8f8",padding:"10px",borderRadius:"5px",marginBottom:"10px"},children:(0,s.jsx)("pre",{style:{wordWrap:"break-word",whiteSpace:"normal"},children:ec})}),(0,s.jsx)(M.CopyToClipboard,{text:ec,onCopy:()=>{z.Z.success("Virtual Key copied to clipboard")},children:(0,s.jsx)(u.Z,{className:"mt-3",children:"Copy Virtual Key"})})]}):(0,s.jsx)(x.Z,{children:"Key being created, this might take 30s"})})]})})]})}},56334:function(e,t,l){l.d(t,{Z:function(){return u}});var s=l(57437);l(2265);var a=l(31283);let r={ttl:3600,lowest_latency_buffer:0};var i=e=>{let{routingStrategyArgs:t}=e,l={ttl:"Sliding window to look back over when calculating the average latency of a deployment. Default - 1 hour (in seconds).",lowest_latency_buffer:"Shuffle between deployments within this % of the lowest latency. Default - 0 (i.e. always pick lowest latency)."};return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("div",{className:"space-y-6",children:[(0,s.jsxs)("div",{className:"max-w-3xl",children:[(0,s.jsx)("h3",{className:"text-sm font-medium text-gray-900",children:"Latency-Based Configuration"}),(0,s.jsx)("p",{className:"text-xs text-gray-500 mt-1",children:"Fine-tune latency-based routing behavior"})]}),(0,s.jsx)("div",{className:"grid grid-cols-1 gap-6 lg:grid-cols-2 xl:grid-cols-3",children:Object.entries(t||r).map(e=>{let[t,r]=e;return(0,s.jsx)("div",{className:"space-y-2",children:(0,s.jsxs)("label",{className:"block",children:[(0,s.jsx)("span",{className:"text-xs font-medium text-gray-700 uppercase tracking-wide",children:t.replace(/_/g," ")}),(0,s.jsx)("p",{className:"text-xs text-gray-500 mt-0.5 mb-2",children:l[t]||""}),(0,s.jsx)(a.o,{name:t,defaultValue:"object"==typeof r?JSON.stringify(r,null,2):null==r?void 0:r.toString(),className:"font-mono text-sm w-full"})]})},t)})})]}),(0,s.jsx)("div",{className:"border-t border-gray-200"})]})},n=e=>{let{routerSettings:t,routerFieldsMetadata:l}=e;return(0,s.jsxs)("div",{className:"space-y-6",children:[(0,s.jsxs)("div",{className:"max-w-3xl",children:[(0,s.jsx)("h3",{className:"text-sm font-medium text-gray-900",children:"Reliability & Retries"}),(0,s.jsx)("p",{className:"text-xs text-gray-500 mt-1",children:"Configure retry logic and failure handling"})]}),(0,s.jsx)("div",{className:"grid grid-cols-1 gap-6 lg:grid-cols-2 xl:grid-cols-3",children:Object.entries(t).filter(e=>{let[t,l]=e;return"fallbacks"!=t&&"context_window_fallbacks"!=t&&"routing_strategy_args"!=t&&"routing_strategy"!=t&&"enable_tag_filtering"!=t}).map(e=>{var t,r;let[i,n]=e;return(0,s.jsx)("div",{className:"space-y-2",children:(0,s.jsxs)("label",{className:"block",children:[(0,s.jsx)("span",{className:"text-xs font-medium text-gray-700 uppercase tracking-wide",children:(null===(t=l[i])||void 0===t?void 0:t.ui_field_name)||i}),(0,s.jsx)("p",{className:"text-xs text-gray-500 mt-0.5 mb-2",children:(null===(r=l[i])||void 0===r?void 0:r.field_description)||""}),(0,s.jsx)(a.o,{name:i,defaultValue:null==n||"null"===n?"":"object"==typeof n?JSON.stringify(n,null,2):(null==n?void 0:n.toString())||"",placeholder:"—",className:"font-mono text-sm w-full"})]})},i)})})]})},o=l(37592),d=e=>{var t,l;let{selectedStrategy:a,availableStrategies:r,routingStrategyDescriptions:i,routerFieldsMetadata:n,onStrategyChange:d}=e;return(0,s.jsxs)("div",{className:"space-y-2 max-w-3xl",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{className:"text-xs font-medium text-gray-700 uppercase tracking-wide",children:(null===(t=n.routing_strategy)||void 0===t?void 0:t.ui_field_name)||"Routing Strategy"}),(0,s.jsx)("p",{className:"text-xs text-gray-500 mt-0.5 mb-2",children:(null===(l=n.routing_strategy)||void 0===l?void 0:l.field_description)||""})]}),(0,s.jsx)("div",{className:"routing-strategy-select max-w-3xl",children:(0,s.jsx)(o.default,{value:a,onChange:d,style:{width:"100%"},size:"large",children:r.map(e=>(0,s.jsx)(o.default.Option,{value:e,label:e,children:(0,s.jsxs)("div",{className:"flex flex-col gap-0.5 py-1",children:[(0,s.jsx)("span",{className:"font-mono text-sm font-medium",children:e}),i[e]&&(0,s.jsx)("span",{className:"text-xs text-gray-500 font-normal",children:i[e]})]})},e))})})]})},c=l(59341),m=e=>{var t,l,a;let{enabled:r,routerFieldsMetadata:i,onToggle:n}=e;return(0,s.jsx)("div",{className:"space-y-3 max-w-3xl",children:(0,s.jsxs)("div",{className:"flex items-start justify-between",children:[(0,s.jsxs)("div",{className:"flex-1",children:[(0,s.jsx)("label",{className:"text-xs font-medium text-gray-700 uppercase tracking-wide",children:(null===(t=i.enable_tag_filtering)||void 0===t?void 0:t.ui_field_name)||"Enable Tag Filtering"}),(0,s.jsxs)("p",{className:"text-xs text-gray-500 mt-0.5",children:[(null===(l=i.enable_tag_filtering)||void 0===l?void 0:l.field_description)||"",(null===(a=i.enable_tag_filtering)||void 0===a?void 0:a.link)&&(0,s.jsxs)(s.Fragment,{children:[" ",(0,s.jsx)("a",{href:i.enable_tag_filtering.link,target:"_blank",rel:"noopener noreferrer",className:"text-blue-600 hover:text-blue-800 underline",children:"Learn more"})]})]})]}),(0,s.jsx)(c.Z,{checked:r,onChange:n,className:"ml-4"})]})})},u=e=>{let{value:t,onChange:l,routerFieldsMetadata:a,availableRoutingStrategies:r,routingStrategyDescriptions:o}=e;return(0,s.jsxs)("div",{className:"w-full space-y-8 py-2",children:[(0,s.jsxs)("div",{className:"space-y-6",children:[(0,s.jsxs)("div",{className:"max-w-3xl",children:[(0,s.jsx)("h3",{className:"text-sm font-medium text-gray-900",children:"Routing Settings"}),(0,s.jsx)("p",{className:"text-xs text-gray-500 mt-1",children:"Configure how requests are routed to deployments"})]}),r.length>0&&(0,s.jsx)(d,{selectedStrategy:t.selectedStrategy||t.routerSettings.routing_strategy||null,availableStrategies:r,routingStrategyDescriptions:o,routerFieldsMetadata:a,onStrategyChange:e=>{l({...t,selectedStrategy:e})}}),(0,s.jsx)(m,{enabled:t.enableTagFiltering,routerFieldsMetadata:a,onToggle:e=>{l({...t,enableTagFiltering:e})}})]}),(0,s.jsx)("div",{className:"border-t border-gray-200"}),"latency-based-routing"===t.selectedStrategy&&(0,s.jsx)(i,{routingStrategyArgs:t.routerSettings.routing_strategy_args}),(0,s.jsx)(n,{routerSettings:t.routerSettings,routerFieldsMetadata:a})]})}}}]); \ No newline at end of file diff --git a/litellm/proxy/_experimental/out/_next/static/chunks/1108-8b678b0704cb239b.js b/litellm/proxy/_experimental/out/_next/static/chunks/1108-8b678b0704cb239b.js deleted file mode 100644 index 89c5291477d..00000000000 --- a/litellm/proxy/_experimental/out/_next/static/chunks/1108-8b678b0704cb239b.js +++ /dev/null @@ -1 +0,0 @@ -(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[1108],{40278:function(t,e,r){"use strict";r.d(e,{Z:function(){return S}});var n=r(5853),o=r(7084),i=r(26898),a=r(13241),u=r(1153),c=r(2265),l=r(47625),s=r(93765),f=r(31699),p=r(97059),h=r(62994),d=r(25311),y=(0,s.z)({chartName:"BarChart",GraphicalChild:f.$,defaultTooltipEventType:"axis",validateTooltipEventTypes:["axis","item"],axisComponents:[{axisType:"xAxis",AxisComp:p.K},{axisType:"yAxis",AxisComp:h.B}],formatAxisMap:d.t9}),v=r(56940),m=r(26680),b=r(8147),g=r(22190),x=r(65278),w=r(98593),O=r(92666),j=r(32644);let S=c.forwardRef((t,e)=>{let{data:r=[],categories:s=[],index:d,colors:S=i.s,valueFormatter:P=u.Cj,layout:E="horizontal",stack:k=!1,relative:A=!1,startEndOnly:M=!1,animationDuration:_=900,showAnimation:T=!1,showXAxis:C=!0,showYAxis:N=!0,yAxisWidth:D=56,intervalType:I="equidistantPreserveStart",showTooltip:L=!0,showLegend:B=!0,showGridLines:R=!0,autoMinValue:z=!1,minValue:U,maxValue:F,allowDecimals:$=!0,noDataText:q,onValueChange:Z,enableLegendSlider:W=!1,customTooltip:Y,rotateLabelX:H,barCategoryGap:X,tickGap:G=5,xAxisLabel:V,yAxisLabel:K,className:Q,padding:J=C||N?{left:20,right:20}:{left:0,right:0}}=t,tt=(0,n._T)(t,["data","categories","index","colors","valueFormatter","layout","stack","relative","startEndOnly","animationDuration","showAnimation","showXAxis","showYAxis","yAxisWidth","intervalType","showTooltip","showLegend","showGridLines","autoMinValue","minValue","maxValue","allowDecimals","noDataText","onValueChange","enableLegendSlider","customTooltip","rotateLabelX","barCategoryGap","tickGap","xAxisLabel","yAxisLabel","className","padding"]),[te,tr]=(0,c.useState)(60),tn=(0,j.me)(s,S),[to,ti]=c.useState(void 0),[ta,tu]=(0,c.useState)(void 0),tc=!!Z;function tl(t,e,r){var n,o,i,a;r.stopPropagation(),Z&&((0,j.vZ)(to,Object.assign(Object.assign({},t.payload),{value:t.value}))?(tu(void 0),ti(void 0),null==Z||Z(null)):(tu(null===(o=null===(n=t.tooltipPayload)||void 0===n?void 0:n[0])||void 0===o?void 0:o.dataKey),ti(Object.assign(Object.assign({},t.payload),{value:t.value})),null==Z||Z(Object.assign({eventType:"bar",categoryClicked:null===(a=null===(i=t.tooltipPayload)||void 0===i?void 0:i[0])||void 0===a?void 0:a.dataKey},t.payload))))}let ts=(0,j.i4)(z,U,F);return c.createElement("div",Object.assign({ref:e,className:(0,a.q)("w-full h-80",Q)},tt),c.createElement(l.h,{className:"h-full w-full"},(null==r?void 0:r.length)?c.createElement(y,{barCategoryGap:X,data:r,stackOffset:k?"sign":A?"expand":"none",layout:"vertical"===E?"vertical":"horizontal",onClick:tc&&(ta||to)?()=>{ti(void 0),tu(void 0),null==Z||Z(null)}:void 0,margin:{bottom:V?30:void 0,left:K?20:void 0,right:K?5:void 0,top:5}},R?c.createElement(v.q,{className:(0,a.q)("stroke-1","stroke-tremor-border","dark:stroke-dark-tremor-border"),horizontal:"vertical"!==E,vertical:"vertical"===E}):null,"vertical"!==E?c.createElement(p.K,{padding:J,hide:!C,dataKey:d,interval:M?"preserveStartEnd":I,tick:{transform:"translate(0, 6)"},ticks:M?[r[0][d],r[r.length-1][d]]:void 0,fill:"",stroke:"",className:(0,a.q)("mt-4 text-tremor-label","fill-tremor-content","dark:fill-dark-tremor-content"),tickLine:!1,axisLine:!1,angle:null==H?void 0:H.angle,dy:null==H?void 0:H.verticalShift,height:null==H?void 0:H.xAxisHeight,minTickGap:G},V&&c.createElement(m._,{position:"insideBottom",offset:-20,className:"fill-tremor-content-emphasis text-tremor-default font-medium dark:fill-dark-tremor-content-emphasis"},V)):c.createElement(p.K,{hide:!C,type:"number",tick:{transform:"translate(-3, 0)"},domain:ts,fill:"",stroke:"",className:(0,a.q)("text-tremor-label","fill-tremor-content","dark:fill-dark-tremor-content"),tickLine:!1,axisLine:!1,tickFormatter:P,minTickGap:G,allowDecimals:$,angle:null==H?void 0:H.angle,dy:null==H?void 0:H.verticalShift,height:null==H?void 0:H.xAxisHeight},V&&c.createElement(m._,{position:"insideBottom",offset:-20,className:"fill-tremor-content-emphasis text-tremor-default font-medium dark:fill-dark-tremor-content-emphasis"},V)),"vertical"!==E?c.createElement(h.B,{width:D,hide:!N,axisLine:!1,tickLine:!1,type:"number",domain:ts,tick:{transform:"translate(-3, 0)"},fill:"",stroke:"",className:(0,a.q)("text-tremor-label","fill-tremor-content","dark:fill-dark-tremor-content"),tickFormatter:A?t=>"".concat((100*t).toString()," %"):P,allowDecimals:$},K&&c.createElement(m._,{position:"insideLeft",style:{textAnchor:"middle"},angle:-90,offset:-15,className:"fill-tremor-content-emphasis text-tremor-default font-medium dark:fill-dark-tremor-content-emphasis"},K)):c.createElement(h.B,{width:D,hide:!N,dataKey:d,axisLine:!1,tickLine:!1,ticks:M?[r[0][d],r[r.length-1][d]]:void 0,type:"category",interval:"preserveStartEnd",tick:{transform:"translate(0, 6)"},fill:"",stroke:"",className:(0,a.q)("text-tremor-label","fill-tremor-content","dark:fill-dark-tremor-content")},K&&c.createElement(m._,{position:"insideLeft",style:{textAnchor:"middle"},angle:-90,offset:-15,className:"fill-tremor-content-emphasis text-tremor-default font-medium dark:fill-dark-tremor-content-emphasis"},K)),c.createElement(b.u,{wrapperStyle:{outline:"none"},isAnimationActive:!1,cursor:{fill:"#d1d5db",opacity:"0.15"},content:L?t=>{let{active:e,payload:r,label:n}=t;return Y?c.createElement(Y,{payload:null==r?void 0:r.map(t=>{var e;return Object.assign(Object.assign({},t),{color:null!==(e=tn.get(t.dataKey))&&void 0!==e?e:o.fr.Gray})}),active:e,label:n}):c.createElement(w.ZP,{active:e,payload:r,label:n,valueFormatter:P,categoryColors:tn})}:c.createElement(c.Fragment,null),position:{y:0}}),B?c.createElement(g.D,{verticalAlign:"top",height:te,content:t=>{let{payload:e}=t;return(0,x.Z)({payload:e},tn,tr,ta,tc?t=>{tc&&(t!==ta||to?(tu(t),null==Z||Z({eventType:"category",categoryClicked:t})):(tu(void 0),null==Z||Z(null)),ti(void 0))}:void 0,W)}}):null,s.map(t=>{var e;return c.createElement(f.$,{className:(0,a.q)((0,u.bM)(null!==(e=tn.get(t))&&void 0!==e?e:o.fr.Gray,i.K.background).fillColor,Z?"cursor-pointer":""),key:t,name:t,type:"linear",stackId:k||A?"a":void 0,dataKey:t,fill:"",isAnimationActive:T,animationDuration:_,shape:t=>((t,e,r,n)=>{let{fillOpacity:o,name:i,payload:a,value:u}=t,{x:l,width:s,y:f,height:p}=t;return"horizontal"===n&&p<0?(f+=p,p=Math.abs(p)):"vertical"===n&&s<0&&(l+=s,s=Math.abs(s)),c.createElement("rect",{x:l,y:f,width:s,height:p,opacity:e||r&&r!==i?(0,j.vZ)(e,Object.assign(Object.assign({},a),{value:u}))?o:.3:o})})(t,to,ta,E),onClick:tl})})):c.createElement(O.Z,{noDataText:q})))});S.displayName="BarChart"},65278:function(t,e,r){"use strict";r.d(e,{Z:function(){return y}});var n=r(2265);let o=t=>{n.useEffect(()=>{let e=()=>{t()};return e(),window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[t])};var i=r(5853),a=r(26898),u=r(13241),c=r(1153);let l=t=>{var e=(0,i._T)(t,[]);return n.createElement("svg",Object.assign({},e,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor"}),n.createElement("path",{d:"M8 12L14 6V18L8 12Z"}))},s=t=>{var e=(0,i._T)(t,[]);return n.createElement("svg",Object.assign({},e,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor"}),n.createElement("path",{d:"M16 12L10 18V6L16 12Z"}))},f=(0,c.fn)("Legend"),p=t=>{let{name:e,color:r,onClick:o,activeLegend:i}=t,l=!!o;return n.createElement("li",{className:(0,u.q)(f("legendItem"),"group inline-flex items-center px-2 py-0.5 rounded-tremor-small transition whitespace-nowrap",l?"cursor-pointer":"cursor-default","text-tremor-content",l?"hover:bg-tremor-background-subtle":"","dark:text-dark-tremor-content",l?"dark:hover:bg-dark-tremor-background-subtle":""),onClick:t=>{t.stopPropagation(),null==o||o(e,r)}},n.createElement("svg",{className:(0,u.q)("flex-none h-2 w-2 mr-1.5",(0,c.bM)(r,a.K.text).textColor,i&&i!==e?"opacity-40":"opacity-100"),fill:"currentColor",viewBox:"0 0 8 8"},n.createElement("circle",{cx:4,cy:4,r:4})),n.createElement("p",{className:(0,u.q)("whitespace-nowrap truncate text-tremor-default","text-tremor-content",l?"group-hover:text-tremor-content-emphasis":"","dark:text-dark-tremor-content",i&&i!==e?"opacity-40":"opacity-100",l?"dark:group-hover:text-dark-tremor-content-emphasis":"")},e))},h=t=>{let{icon:e,onClick:r,disabled:o}=t,[i,a]=n.useState(!1),c=n.useRef(null);return n.useEffect(()=>(i?c.current=setInterval(()=>{null==r||r()},300):clearInterval(c.current),()=>clearInterval(c.current)),[i,r]),(0,n.useEffect)(()=>{o&&(clearInterval(c.current),a(!1))},[o]),n.createElement("button",{type:"button",className:(0,u.q)(f("legendSliderButton"),"w-5 group inline-flex items-center truncate rounded-tremor-small transition",o?"cursor-not-allowed":"cursor-pointer",o?"text-tremor-content-subtle":"text-tremor-content hover:text-tremor-content-emphasis hover:bg-tremor-background-subtle",o?"dark:text-dark-tremor-subtle":"dark:text-dark-tremor dark:hover:text-tremor-content-emphasis dark:hover:bg-dark-tremor-background-subtle"),disabled:o,onClick:t=>{t.stopPropagation(),null==r||r()},onMouseDown:t=>{t.stopPropagation(),a(!0)},onMouseUp:t=>{t.stopPropagation(),a(!1)}},n.createElement(e,{className:"w-full"}))},d=n.forwardRef((t,e)=>{let{categories:r,colors:o=a.s,className:c,onClickLegendItem:d,activeLegend:y,enableLegendSlider:v=!1}=t,m=(0,i._T)(t,["categories","colors","className","onClickLegendItem","activeLegend","enableLegendSlider"]),b=n.useRef(null),g=n.useRef(null),[x,w]=n.useState(null),[O,j]=n.useState(null),S=n.useRef(null),P=(0,n.useCallback)(()=>{let t=null==b?void 0:b.current;t&&w({left:t.scrollLeft>0,right:t.scrollWidth-t.clientWidth>t.scrollLeft})},[w]),E=(0,n.useCallback)(t=>{var e,r;let n=null==b?void 0:b.current,o=null==g?void 0:g.current,i=null!==(e=null==n?void 0:n.clientWidth)&&void 0!==e?e:0,a=null!==(r=null==o?void 0:o.clientWidth)&&void 0!==r?r:0;n&&v&&(n.scrollTo({left:"left"===t?n.scrollLeft-i+a:n.scrollLeft+i-a,behavior:"smooth"}),setTimeout(()=>{P()},400))},[v,P]);n.useEffect(()=>{let t=t=>{"ArrowLeft"===t?E("left"):"ArrowRight"===t&&E("right")};return O?(t(O),S.current=setInterval(()=>{t(O)},300)):clearInterval(S.current),()=>clearInterval(S.current)},[O,E]);let k=t=>{t.stopPropagation(),"ArrowLeft"!==t.key&&"ArrowRight"!==t.key||(t.preventDefault(),j(t.key))},A=t=>{t.stopPropagation(),j(null)};return n.useEffect(()=>{let t=null==b?void 0:b.current;return v&&(P(),null==t||t.addEventListener("keydown",k),null==t||t.addEventListener("keyup",A)),()=>{null==t||t.removeEventListener("keydown",k),null==t||t.removeEventListener("keyup",A)}},[P,v]),n.createElement("ol",Object.assign({ref:e,className:(0,u.q)(f("root"),"relative overflow-hidden",c)},m),n.createElement("div",{ref:b,tabIndex:0,className:(0,u.q)("h-full flex",v?(null==x?void 0:x.right)||(null==x?void 0:x.left)?"pl-4 pr-12 items-center overflow-auto snap-mandatory [&::-webkit-scrollbar]:hidden [scrollbar-width:none]":"":"flex-wrap")},r.map((t,e)=>n.createElement(p,{key:"item-".concat(e),name:t,color:o[e%o.length],onClick:d,activeLegend:y}))),v&&((null==x?void 0:x.right)||(null==x?void 0:x.left))?n.createElement(n.Fragment,null,n.createElement("div",{className:(0,u.q)("bg-tremor-background","dark:bg-dark-tremor-background","absolute flex top-0 pr-1 bottom-0 right-0 items-center justify-center h-full"),ref:g},n.createElement(h,{icon:l,onClick:()=>{j(null),E("left")},disabled:!(null==x?void 0:x.left)}),n.createElement(h,{icon:s,onClick:()=>{j(null),E("right")},disabled:!(null==x?void 0:x.right)}))):null)});d.displayName="Legend";let y=(t,e,r,i,a,u)=>{let{payload:c}=t,l=(0,n.useRef)(null);o(()=>{var t,e;r((e=null===(t=l.current)||void 0===t?void 0:t.clientHeight)?Number(e)+20:60)});let s=c.filter(t=>"none"!==t.type);return n.createElement("div",{ref:l,className:"flex items-center justify-end"},n.createElement(d,{categories:s.map(t=>t.value),colors:s.map(t=>e.get(t.value)),onClickLegendItem:a,activeLegend:i,enableLegendSlider:u}))}},98593:function(t,e,r){"use strict";r.d(e,{$B:function(){return c},ZP:function(){return s},zX:function(){return l}});var n=r(2265),o=r(7084),i=r(26898),a=r(13241),u=r(1153);let c=t=>{let{children:e}=t;return n.createElement("div",{className:(0,a.q)("rounded-tremor-default text-tremor-default border","bg-tremor-background shadow-tremor-dropdown border-tremor-border","dark:bg-dark-tremor-background dark:shadow-dark-tremor-dropdown dark:border-dark-tremor-border")},e)},l=t=>{let{value:e,name:r,color:o}=t;return n.createElement("div",{className:"flex items-center justify-between space-x-8"},n.createElement("div",{className:"flex items-center space-x-2"},n.createElement("span",{className:(0,a.q)("shrink-0 rounded-tremor-full border-2 h-3 w-3","border-tremor-background shadow-tremor-card","dark:border-dark-tremor-background dark:shadow-dark-tremor-card",(0,u.bM)(o,i.K.background).bgColor)}),n.createElement("p",{className:(0,a.q)("text-right whitespace-nowrap","text-tremor-content","dark:text-dark-tremor-content")},r)),n.createElement("p",{className:(0,a.q)("font-medium tabular-nums text-right whitespace-nowrap","text-tremor-content-emphasis","dark:text-dark-tremor-content-emphasis")},e))},s=t=>{let{active:e,payload:r,label:i,categoryColors:u,valueFormatter:s}=t;if(e&&r){let t=r.filter(t=>"none"!==t.type);return n.createElement(c,null,n.createElement("div",{className:(0,a.q)("border-tremor-border border-b px-4 py-2","dark:border-dark-tremor-border")},n.createElement("p",{className:(0,a.q)("font-medium","text-tremor-content-emphasis","dark:text-dark-tremor-content-emphasis")},i)),n.createElement("div",{className:(0,a.q)("px-4 py-2 space-y-1")},t.map((t,e)=>{var r;let{value:i,name:a}=t;return n.createElement(l,{key:"id-".concat(e),value:s(i),name:a,color:null!==(r=u.get(a))&&void 0!==r?r:o.fr.Blue})})))}return null}},92666:function(t,e,r){"use strict";r.d(e,{Z:function(){return i}});var n=r(13241),o=r(2265);let i=t=>{let{className:e,noDataText:r="No data"}=t;return o.createElement("div",{className:(0,n.q)("flex items-center justify-center w-full h-full border border-dashed rounded-tremor-default","border-tremor-border","dark:border-dark-tremor-border",e)},o.createElement("p",{className:(0,n.q)("text-tremor-content text-tremor-default","dark:text-dark-tremor-content")},r))}},32644:function(t,e,r){"use strict";r.d(e,{FB:function(){return i},i4:function(){return o},me:function(){return n},vZ:function(){return function t(e,r){if(e===r)return!0;if("object"!=typeof e||"object"!=typeof r||null===e||null===r)return!1;let n=Object.keys(e),o=Object.keys(r);if(n.length!==o.length)return!1;for(let i of n)if(!o.includes(i)||!t(e[i],r[i]))return!1;return!0}}});let n=(t,e)=>{let r=new Map;return t.forEach((t,n)=>{r.set(t,e[n%e.length])}),r},o=(t,e,r)=>[t?"auto":null!=e?e:0,null!=r?r:"auto"];function i(t,e){let r=[];for(let n of t)if(Object.prototype.hasOwnProperty.call(n,e)&&(r.push(n[e]),r.length>1))return!1;return!0}},49804:function(t,e,r){"use strict";r.d(e,{Z:function(){return l}});var n=r(5853),o=r(13241),i=r(1153),a=r(2265),u=r(9496);let c=(0,i.fn)("Col"),l=a.forwardRef((t,e)=>{let{numColSpan:r=1,numColSpanSm:i,numColSpanMd:l,numColSpanLg:s,children:f,className:p}=t,h=(0,n._T)(t,["numColSpan","numColSpanSm","numColSpanMd","numColSpanLg","children","className"]),d=(t,e)=>t&&Object.keys(e).includes(String(t))?e[t]:"";return a.createElement("div",Object.assign({ref:e,className:(0,o.q)(c("root"),(()=>{let t=d(r,u.PT),e=d(i,u.SP),n=d(l,u.VS),a=d(s,u._w);return(0,o.q)(t,e,n,a)})(),p)},h),f)});l.displayName="Col"},97765:function(t,e,r){"use strict";r.d(e,{Z:function(){return c}});var n=r(5853),o=r(26898),i=r(13241),a=r(1153),u=r(2265);let c=u.forwardRef((t,e)=>{let{color:r,children:c,className:l}=t,s=(0,n._T)(t,["color","children","className"]);return u.createElement("p",Object.assign({ref:e,className:(0,i.q)(r?(0,a.bM)(r,o.K.lightText).textColor:"text-tremor-content-emphasis dark:text-dark-tremor-content-emphasis",l)},s),c)});c.displayName="Subtitle"},61134:function(t,e,r){var n;!function(o){"use strict";var i,a={precision:20,rounding:4,toExpNeg:-7,toExpPos:21,LN10:"2.302585092994045684017991454684364207601101488628772976033327900967572609677352480235997205089598298341967784042286"},u=!0,c="[DecimalError] ",l=c+"Invalid argument: ",s=c+"Exponent out of range: ",f=Math.floor,p=Math.pow,h=/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,d=f(1286742750677284.5),y={};function v(t,e){var r,n,o,i,a,c,l,s,f=t.constructor,p=f.precision;if(!t.s||!e.s)return e.s||(e=new f(t)),u?E(e,p):e;if(l=t.d,s=e.d,a=t.e,o=e.e,l=l.slice(),i=a-o){for(i<0?(n=l,i=-i,c=s.length):(n=s,o=a,c=l.length),i>(c=(a=Math.ceil(p/7))>c?a+1:c+1)&&(i=c,n.length=1),n.reverse();i--;)n.push(0);n.reverse()}for((c=l.length)-(i=s.length)<0&&(i=c,n=s,s=l,l=n),r=0;i;)r=(l[--i]=l[i]+s[i]+r)/1e7|0,l[i]%=1e7;for(r&&(l.unshift(r),++o),c=l.length;0==l[--c];)l.pop();return e.d=l,e.e=o,u?E(e,p):e}function m(t,e,r){if(t!==~~t||tr)throw Error(l+t)}function b(t){var e,r,n,o=t.length-1,i="",a=t[0];if(o>0){for(i+=a,e=1;et.e^this.s<0?1:-1;for(e=0,r=(n=this.d.length)<(o=t.d.length)?n:o;et.d[e]^this.s<0?1:-1;return n===o?0:n>o^this.s<0?1:-1},y.decimalPlaces=y.dp=function(){var t=this.d.length-1,e=(t-this.e)*7;if(t=this.d[t])for(;t%10==0;t/=10)e--;return e<0?0:e},y.dividedBy=y.div=function(t){return g(this,new this.constructor(t))},y.dividedToIntegerBy=y.idiv=function(t){var e=this.constructor;return E(g(this,new e(t),0,1),e.precision)},y.equals=y.eq=function(t){return!this.cmp(t)},y.exponent=function(){return w(this)},y.greaterThan=y.gt=function(t){return this.cmp(t)>0},y.greaterThanOrEqualTo=y.gte=function(t){return this.cmp(t)>=0},y.isInteger=y.isint=function(){return this.e>this.d.length-2},y.isNegative=y.isneg=function(){return this.s<0},y.isPositive=y.ispos=function(){return this.s>0},y.isZero=function(){return 0===this.s},y.lessThan=y.lt=function(t){return 0>this.cmp(t)},y.lessThanOrEqualTo=y.lte=function(t){return 1>this.cmp(t)},y.logarithm=y.log=function(t){var e,r=this.constructor,n=r.precision,o=n+5;if(void 0===t)t=new r(10);else if((t=new r(t)).s<1||t.eq(i))throw Error(c+"NaN");if(this.s<1)throw Error(c+(this.s?"NaN":"-Infinity"));return this.eq(i)?new r(0):(u=!1,e=g(S(this,o),S(t,o),o),u=!0,E(e,n))},y.minus=y.sub=function(t){return t=new this.constructor(t),this.s==t.s?k(this,t):v(this,(t.s=-t.s,t))},y.modulo=y.mod=function(t){var e,r=this.constructor,n=r.precision;if(!(t=new r(t)).s)throw Error(c+"NaN");return this.s?(u=!1,e=g(this,t,0,1).times(t),u=!0,this.minus(e)):E(new r(this),n)},y.naturalExponential=y.exp=function(){return x(this)},y.naturalLogarithm=y.ln=function(){return S(this)},y.negated=y.neg=function(){var t=new this.constructor(this);return t.s=-t.s||0,t},y.plus=y.add=function(t){return t=new this.constructor(t),this.s==t.s?v(this,t):k(this,(t.s=-t.s,t))},y.precision=y.sd=function(t){var e,r,n;if(void 0!==t&&!!t!==t&&1!==t&&0!==t)throw Error(l+t);if(e=w(this)+1,r=7*(n=this.d.length-1)+1,n=this.d[n]){for(;n%10==0;n/=10)r--;for(n=this.d[0];n>=10;n/=10)r++}return t&&e>r?e:r},y.squareRoot=y.sqrt=function(){var t,e,r,n,o,i,a,l=this.constructor;if(this.s<1){if(!this.s)return new l(0);throw Error(c+"NaN")}for(t=w(this),u=!1,0==(o=Math.sqrt(+this))||o==1/0?(((e=b(this.d)).length+t)%2==0&&(e+="0"),o=Math.sqrt(e),t=f((t+1)/2)-(t<0||t%2),n=new l(e=o==1/0?"5e"+t:(e=o.toExponential()).slice(0,e.indexOf("e")+1)+t)):n=new l(o.toString()),o=a=(r=l.precision)+3;;)if(n=(i=n).plus(g(this,i,a+2)).times(.5),b(i.d).slice(0,a)===(e=b(n.d)).slice(0,a)){if(e=e.slice(a-3,a+1),o==a&&"4999"==e){if(E(i,r+1,0),i.times(i).eq(this)){n=i;break}}else if("9999"!=e)break;a+=4}return u=!0,E(n,r)},y.times=y.mul=function(t){var e,r,n,o,i,a,c,l,s,f=this.constructor,p=this.d,h=(t=new f(t)).d;if(!this.s||!t.s)return new f(0);for(t.s*=this.s,r=this.e+t.e,(l=p.length)<(s=h.length)&&(i=p,p=h,h=i,a=l,l=s,s=a),i=[],n=a=l+s;n--;)i.push(0);for(n=s;--n>=0;){for(e=0,o=l+n;o>n;)c=i[o]+h[n]*p[o-n-1]+e,i[o--]=c%1e7|0,e=c/1e7|0;i[o]=(i[o]+e)%1e7|0}for(;!i[--a];)i.pop();return e?++r:i.shift(),t.d=i,t.e=r,u?E(t,f.precision):t},y.toDecimalPlaces=y.todp=function(t,e){var r=this,n=r.constructor;return(r=new n(r),void 0===t)?r:(m(t,0,1e9),void 0===e?e=n.rounding:m(e,0,8),E(r,t+w(r)+1,e))},y.toExponential=function(t,e){var r,n=this,o=n.constructor;return void 0===t?r=A(n,!0):(m(t,0,1e9),void 0===e?e=o.rounding:m(e,0,8),r=A(n=E(new o(n),t+1,e),!0,t+1)),r},y.toFixed=function(t,e){var r,n,o=this.constructor;return void 0===t?A(this):(m(t,0,1e9),void 0===e?e=o.rounding:m(e,0,8),r=A((n=E(new o(this),t+w(this)+1,e)).abs(),!1,t+w(n)+1),this.isneg()&&!this.isZero()?"-"+r:r)},y.toInteger=y.toint=function(){var t=this.constructor;return E(new t(this),w(this)+1,t.rounding)},y.toNumber=function(){return+this},y.toPower=y.pow=function(t){var e,r,n,o,a,l,s=this,p=s.constructor,h=+(t=new p(t));if(!t.s)return new p(i);if(!(s=new p(s)).s){if(t.s<1)throw Error(c+"Infinity");return s}if(s.eq(i))return s;if(n=p.precision,t.eq(i))return E(s,n);if(l=(e=t.e)>=(r=t.d.length-1),a=s.s,l){if((r=h<0?-h:h)<=9007199254740991){for(o=new p(i),e=Math.ceil(n/7+4),u=!1;r%2&&M((o=o.times(s)).d,e),0!==(r=f(r/2));)M((s=s.times(s)).d,e);return u=!0,t.s<0?new p(i).div(o):E(o,n)}}else if(a<0)throw Error(c+"NaN");return a=a<0&&1&t.d[Math.max(e,r)]?-1:1,s.s=1,u=!1,o=t.times(S(s,n+12)),u=!0,(o=x(o)).s=a,o},y.toPrecision=function(t,e){var r,n,o=this,i=o.constructor;return void 0===t?(r=w(o),n=A(o,r<=i.toExpNeg||r>=i.toExpPos)):(m(t,1,1e9),void 0===e?e=i.rounding:m(e,0,8),r=w(o=E(new i(o),t,e)),n=A(o,t<=r||r<=i.toExpNeg,t)),n},y.toSignificantDigits=y.tosd=function(t,e){var r=this.constructor;return void 0===t?(t=r.precision,e=r.rounding):(m(t,1,1e9),void 0===e?e=r.rounding:m(e,0,8)),E(new r(this),t,e)},y.toString=y.valueOf=y.val=y.toJSON=function(){var t=w(this),e=this.constructor;return A(this,t<=e.toExpNeg||t>=e.toExpPos)};var g=function(){function t(t,e){var r,n=0,o=t.length;for(t=t.slice();o--;)r=t[o]*e+n,t[o]=r%1e7|0,n=r/1e7|0;return n&&t.unshift(n),t}function e(t,e,r,n){var o,i;if(r!=n)i=r>n?1:-1;else for(o=i=0;oe[o]?1:-1;break}return i}function r(t,e,r){for(var n=0;r--;)t[r]-=n,n=t[r]1;)t.shift()}return function(n,o,i,a){var u,l,s,f,p,h,d,y,v,m,b,g,x,O,j,S,P,k,A=n.constructor,M=n.s==o.s?1:-1,_=n.d,T=o.d;if(!n.s)return new A(n);if(!o.s)throw Error(c+"Division by zero");for(s=0,l=n.e-o.e,P=T.length,j=_.length,y=(d=new A(M)).d=[];T[s]==(_[s]||0);)++s;if(T[s]>(_[s]||0)&&--l,(g=null==i?i=A.precision:a?i+(w(n)-w(o))+1:i)<0)return new A(0);if(g=g/7+2|0,s=0,1==P)for(f=0,T=T[0],g++;(s1&&(T=t(T,f),_=t(_,f),P=T.length,j=_.length),O=P,m=(v=_.slice(0,P)).length;m=1e7/2&&++S;do f=0,(u=e(T,v,P,m))<0?(b=v[0],P!=m&&(b=1e7*b+(v[1]||0)),(f=b/S|0)>1?(f>=1e7&&(f=1e7-1),h=(p=t(T,f)).length,m=v.length,1==(u=e(p,v,h,m))&&(f--,r(p,P16)throw Error(s+w(t));if(!t.s)return new h(i);for(null==e?(u=!1,c=d):c=e,a=new h(.03125);t.abs().gte(.1);)t=t.times(a),f+=5;for(c+=Math.log(p(2,f))/Math.LN10*2+5|0,r=n=o=new h(i),h.precision=c;;){if(n=E(n.times(t),c),r=r.times(++l),b((a=o.plus(g(n,r,c))).d).slice(0,c)===b(o.d).slice(0,c)){for(;f--;)o=E(o.times(o),c);return h.precision=d,null==e?(u=!0,E(o,d)):o}o=a}}function w(t){for(var e=7*t.e,r=t.d[0];r>=10;r/=10)e++;return e}function O(t,e,r){if(e>t.LN10.sd())throw u=!0,r&&(t.precision=r),Error(c+"LN10 precision limit exceeded");return E(new t(t.LN10),e)}function j(t){for(var e="";t--;)e+="0";return e}function S(t,e){var r,n,o,a,l,s,f,p,h,d=1,y=t,v=y.d,m=y.constructor,x=m.precision;if(y.s<1)throw Error(c+(y.s?"NaN":"-Infinity"));if(y.eq(i))return new m(0);if(null==e?(u=!1,p=x):p=e,y.eq(10))return null==e&&(u=!0),O(m,p);if(p+=10,m.precision=p,n=(r=b(v)).charAt(0),!(15e14>Math.abs(a=w(y))))return f=O(m,p+2,x).times(a+""),y=S(new m(n+"."+r.slice(1)),p-10).plus(f),m.precision=x,null==e?(u=!0,E(y,x)):y;for(;n<7&&1!=n||1==n&&r.charAt(1)>3;)n=(r=b((y=y.times(t)).d)).charAt(0),d++;for(a=w(y),n>1?(y=new m("0."+r),a++):y=new m(n+"."+r.slice(1)),s=l=y=g(y.minus(i),y.plus(i),p),h=E(y.times(y),p),o=3;;){if(l=E(l.times(h),p),b((f=s.plus(g(l,new m(o),p))).d).slice(0,p)===b(s.d).slice(0,p))return s=s.times(2),0!==a&&(s=s.plus(O(m,p+2,x).times(a+""))),s=g(s,new m(d),p),m.precision=x,null==e?(u=!0,E(s,x)):s;s=f,o+=2}}function P(t,e){var r,n,o;for((r=e.indexOf("."))>-1&&(e=e.replace(".","")),(n=e.search(/e/i))>0?(r<0&&(r=n),r+=+e.slice(n+1),e=e.substring(0,n)):r<0&&(r=e.length),n=0;48===e.charCodeAt(n);)++n;for(o=e.length;48===e.charCodeAt(o-1);)--o;if(e=e.slice(n,o)){if(o-=n,r=r-n-1,t.e=f(r/7),t.d=[],n=(r+1)%7,r<0&&(n+=7),nd||t.e<-d))throw Error(s+r)}else t.s=0,t.e=0,t.d=[0];return t}function E(t,e,r){var n,o,i,a,c,l,h,y,v=t.d;for(a=1,i=v[0];i>=10;i/=10)a++;if((n=e-a)<0)n+=7,o=e,h=v[y=0];else{if((y=Math.ceil((n+1)/7))>=(i=v.length))return t;for(a=1,h=i=v[y];i>=10;i/=10)a++;n%=7,o=n-7+a}if(void 0!==r&&(c=h/(i=p(10,a-o-1))%10|0,l=e<0||void 0!==v[y+1]||h%i,l=r<4?(c||l)&&(0==r||r==(t.s<0?3:2)):c>5||5==c&&(4==r||l||6==r&&(n>0?o>0?h/p(10,a-o):0:v[y-1])%10&1||r==(t.s<0?8:7))),e<1||!v[0])return l?(i=w(t),v.length=1,e=e-i-1,v[0]=p(10,(7-e%7)%7),t.e=f(-e/7)||0):(v.length=1,v[0]=t.e=t.s=0),t;if(0==n?(v.length=y,i=1,y--):(v.length=y+1,i=p(10,7-n),v[y]=o>0?(h/p(10,a-o)%p(10,o)|0)*i:0),l)for(;;){if(0==y){1e7==(v[0]+=i)&&(v[0]=1,++t.e);break}if(v[y]+=i,1e7!=v[y])break;v[y--]=0,i=1}for(n=v.length;0===v[--n];)v.pop();if(u&&(t.e>d||t.e<-d))throw Error(s+w(t));return t}function k(t,e){var r,n,o,i,a,c,l,s,f,p,h=t.constructor,d=h.precision;if(!t.s||!e.s)return e.s?e.s=-e.s:e=new h(t),u?E(e,d):e;if(l=t.d,p=e.d,n=e.e,s=t.e,l=l.slice(),a=s-n){for((f=a<0)?(r=l,a=-a,c=p.length):(r=p,n=s,c=l.length),a>(o=Math.max(Math.ceil(d/7),c)+2)&&(a=o,r.length=1),r.reverse(),o=a;o--;)r.push(0);r.reverse()}else{for((f=(o=l.length)<(c=p.length))&&(c=o),o=0;o0;--o)l[c++]=0;for(o=p.length;o>a;){if(l[--o]0?i=i.charAt(0)+"."+i.slice(1)+j(n):a>1&&(i=i.charAt(0)+"."+i.slice(1)),i=i+(o<0?"e":"e+")+o):o<0?(i="0."+j(-o-1)+i,r&&(n=r-a)>0&&(i+=j(n))):o>=a?(i+=j(o+1-a),r&&(n=r-o-1)>0&&(i=i+"."+j(n))):((n=o+1)0&&(o+1===a&&(i+="."),i+=j(n))),t.s<0?"-"+i:i}function M(t,e){if(t.length>e)return t.length=e,!0}function _(t){if(!t||"object"!=typeof t)throw Error(c+"Object expected");var e,r,n,o=["precision",1,1e9,"rounding",0,8,"toExpNeg",-1/0,0,"toExpPos",0,1/0];for(e=0;e=o[e+1]&&n<=o[e+2])this[r]=n;else throw Error(l+r+": "+n)}if(void 0!==(n=t[r="LN10"])){if(n==Math.LN10)this[r]=new this(n);else throw Error(l+r+": "+n)}return this}(a=function t(e){var r,n,o;function i(t){if(!(this instanceof i))return new i(t);if(this.constructor=i,t instanceof i){this.s=t.s,this.e=t.e,this.d=(t=t.d)?t.slice():t;return}if("number"==typeof t){if(0*t!=0)throw Error(l+t);if(t>0)this.s=1;else if(t<0)t=-t,this.s=-1;else{this.s=0,this.e=0,this.d=[0];return}if(t===~~t&&t<1e7){this.e=0,this.d=[t];return}return P(this,t.toString())}if("string"!=typeof t)throw Error(l+t);if(45===t.charCodeAt(0)?(t=t.slice(1),this.s=-1):this.s=1,h.test(t))P(this,t);else throw Error(l+t)}if(i.prototype=y,i.ROUND_UP=0,i.ROUND_DOWN=1,i.ROUND_CEIL=2,i.ROUND_FLOOR=3,i.ROUND_HALF_UP=4,i.ROUND_HALF_DOWN=5,i.ROUND_HALF_EVEN=6,i.ROUND_HALF_CEIL=7,i.ROUND_HALF_FLOOR=8,i.clone=t,i.config=i.set=_,void 0===e&&(e={}),e)for(r=0,o=["precision","rounding","toExpNeg","toExpPos","LN10"];r-1}},56883:function(t){t.exports=function(t,e,r){for(var n=-1,o=null==t?0:t.length;++n0&&i(s)?r>1?t(s,r-1,i,a,u):n(u,s):a||(u[u.length]=s)}return u}},63321:function(t,e,r){var n=r(33023)();t.exports=n},98060:function(t,e,r){var n=r(63321),o=r(43228);t.exports=function(t,e){return t&&n(t,e,o)}},92167:function(t,e,r){var n=r(67906),o=r(70235);t.exports=function(t,e){e=n(e,t);for(var r=0,i=e.length;null!=t&&re}},93012:function(t){t.exports=function(t,e){return null!=t&&e in Object(t)}},47909:function(t,e,r){var n=r(8235),o=r(31953),i=r(35281);t.exports=function(t,e,r){return e==e?i(t,e,r):n(t,o,r)}},90370:function(t,e,r){var n=r(54506),o=r(10303);t.exports=function(t){return o(t)&&"[object Arguments]"==n(t)}},56318:function(t,e,r){var n=r(6791),o=r(10303);t.exports=function t(e,r,i,a,u){return e===r||(null!=e&&null!=r&&(o(e)||o(r))?n(e,r,i,a,t,u):e!=e&&r!=r)}},6791:function(t,e,r){var n=r(85885),o=r(97638),i=r(88030),a=r(64974),u=r(81690),c=r(25614),l=r(98051),s=r(9792),f="[object Arguments]",p="[object Array]",h="[object Object]",d=Object.prototype.hasOwnProperty;t.exports=function(t,e,r,y,v,m){var b=c(t),g=c(e),x=b?p:u(t),w=g?p:u(e);x=x==f?h:x,w=w==f?h:w;var O=x==h,j=w==h,S=x==w;if(S&&l(t)){if(!l(e))return!1;b=!0,O=!1}if(S&&!O)return m||(m=new n),b||s(t)?o(t,e,r,y,v,m):i(t,e,x,r,y,v,m);if(!(1&r)){var P=O&&d.call(t,"__wrapped__"),E=j&&d.call(e,"__wrapped__");if(P||E){var k=P?t.value():t,A=E?e.value():e;return m||(m=new n),v(k,A,r,y,m)}}return!!S&&(m||(m=new n),a(t,e,r,y,v,m))}},62538:function(t,e,r){var n=r(85885),o=r(56318);t.exports=function(t,e,r,i){var a=r.length,u=a,c=!i;if(null==t)return!u;for(t=Object(t);a--;){var l=r[a];if(c&&l[2]?l[1]!==t[l[0]]:!(l[0]in t))return!1}for(;++ao?0:o+e),(r=r>o?o:r)<0&&(r+=o),o=e>r?0:r-e>>>0,e>>>=0;for(var i=Array(o);++n=200){var y=e?null:u(t);if(y)return c(y);p=!1,s=a,d=new n}else d=e?[]:h;t:for(;++l=o?t:n(t,e,r)}},1536:function(t,e,r){var n=r(78371);t.exports=function(t,e){if(t!==e){var r=void 0!==t,o=null===t,i=t==t,a=n(t),u=void 0!==e,c=null===e,l=e==e,s=n(e);if(!c&&!s&&!a&&t>e||a&&u&&l&&!c&&!s||o&&u&&l||!r&&l||!i)return 1;if(!o&&!a&&!s&&t=c)return l;return l*("desc"==r[o]?-1:1)}}return t.index-e.index}},92077:function(t,e,r){var n=r(74288)["__core-js_shared__"];t.exports=n},97930:function(t,e,r){var n=r(5629);t.exports=function(t,e){return function(r,o){if(null==r)return r;if(!n(r))return t(r,o);for(var i=r.length,a=e?i:-1,u=Object(r);(e?a--:++a-1?u[c?e[l]:l]:void 0}}},35464:function(t,e,r){var n=r(19608),o=r(49639),i=r(175);t.exports=function(t){return function(e,r,a){return a&&"number"!=typeof a&&o(e,r,a)&&(r=a=void 0),e=i(e),void 0===r?(r=e,e=0):r=i(r),a=void 0===a?es))return!1;var p=c.get(t),h=c.get(e);if(p&&h)return p==e&&h==t;var d=-1,y=!0,v=2&r?new n:void 0;for(c.set(t,e),c.set(e,t);++d-1&&t%1==0&&t-1}},13368:function(t,e,r){var n=r(24457);t.exports=function(t,e){var r=this.__data__,o=n(r,t);return o<0?(++this.size,r.push([t,e])):r[o][1]=e,this}},38764:function(t,e,r){var n=r(9855),o=r(99078),i=r(88675);t.exports=function(){this.size=0,this.__data__={hash:new n,map:new(i||o),string:new n}}},78615:function(t,e,r){var n=r(1507);t.exports=function(t){var e=n(this,t).delete(t);return this.size-=e?1:0,e}},83391:function(t,e,r){var n=r(1507);t.exports=function(t){return n(this,t).get(t)}},53483:function(t,e,r){var n=r(1507);t.exports=function(t){return n(this,t).has(t)}},74724:function(t,e,r){var n=r(1507);t.exports=function(t,e){var r=n(this,t),o=r.size;return r.set(t,e),this.size+=r.size==o?0:1,this}},22523:function(t){t.exports=function(t){var e=-1,r=Array(t.size);return t.forEach(function(t,n){r[++e]=[n,t]}),r}},47073:function(t){t.exports=function(t,e){return function(r){return null!=r&&r[t]===e&&(void 0!==e||t in Object(r))}}},23787:function(t,e,r){var n=r(50967);t.exports=function(t){var e=n(t,function(t){return 500===r.size&&r.clear(),t}),r=e.cache;return e}},20453:function(t,e,r){var n=r(39866)(Object,"create");t.exports=n},77184:function(t,e,r){var n=r(45070)(Object.keys,Object);t.exports=n},39931:function(t,e,r){t=r.nmd(t);var n=r(17071),o=e&&!e.nodeType&&e,i=o&&t&&!t.nodeType&&t,a=i&&i.exports===o&&n.process,u=function(){try{var t=i&&i.require&&i.require("util").types;if(t)return t;return a&&a.binding&&a.binding("util")}catch(t){}}();t.exports=u},45070:function(t){t.exports=function(t,e){return function(r){return t(e(r))}}},49478:function(t,e,r){var n=r(60493),o=Math.max;t.exports=function(t,e,r){return e=o(void 0===e?t.length-1:e,0),function(){for(var i=arguments,a=-1,u=o(i.length-e,0),c=Array(u);++a0){if(++r>=800)return arguments[0]}else r=0;return t.apply(void 0,arguments)}}},84092:function(t,e,r){var n=r(99078);t.exports=function(){this.__data__=new n,this.size=0}},31663:function(t){t.exports=function(t){var e=this.__data__,r=e.delete(t);return this.size=e.size,r}},69135:function(t){t.exports=function(t){return this.__data__.get(t)}},39552:function(t){t.exports=function(t){return this.__data__.has(t)}},63960:function(t,e,r){var n=r(99078),o=r(88675),i=r(76219);t.exports=function(t,e){var r=this.__data__;if(r instanceof n){var a=r.__data__;if(!o||a.length<199)return a.push([t,e]),this.size=++r.size,this;r=this.__data__=new i(a)}return r.set(t,e),this.size=r.size,this}},35281:function(t){t.exports=function(t,e,r){for(var n=r-1,o=t.length;++n-1&&t%1==0&&t<=9007199254740991}},82559:function(t,e,r){var n=r(22345);t.exports=function(t){return n(t)&&t!=+t}},77571:function(t){t.exports=function(t){return null==t}},22345:function(t,e,r){var n=r(54506),o=r(10303);t.exports=function(t){return"number"==typeof t||o(t)&&"[object Number]"==n(t)}},90231:function(t,e,r){var n=r(54506),o=r(62602),i=r(10303),a=Object.prototype,u=Function.prototype.toString,c=a.hasOwnProperty,l=u.call(Object);t.exports=function(t){if(!i(t)||"[object Object]"!=n(t))return!1;var e=o(t);if(null===e)return!0;var r=c.call(e,"constructor")&&e.constructor;return"function"==typeof r&&r instanceof r&&u.call(r)==l}},42715:function(t,e,r){var n=r(54506),o=r(25614),i=r(10303);t.exports=function(t){return"string"==typeof t||!o(t)&&i(t)&&"[object String]"==n(t)}},9792:function(t,e,r){var n=r(59332),o=r(23305),i=r(39931),a=i&&i.isTypedArray,u=a?o(a):n;t.exports=u},43228:function(t,e,r){var n=r(28579),o=r(4578),i=r(5629);t.exports=function(t){return i(t)?n(t):o(t)}},86185:function(t){t.exports=function(t){var e=null==t?0:t.length;return e?t[e-1]:void 0}},89238:function(t,e,r){var n=r(73819),o=r(88157),i=r(24240),a=r(25614);t.exports=function(t,e){return(a(t)?n:i)(t,o(e,3))}},41443:function(t,e,r){var n=r(83023),o=r(98060),i=r(88157);t.exports=function(t,e){var r={};return e=i(e,3),o(t,function(t,o,i){n(r,o,e(t,o,i))}),r}},95645:function(t,e,r){var n=r(67646),o=r(58905),i=r(79586);t.exports=function(t){return t&&t.length?n(t,i,o):void 0}},50967:function(t,e,r){var n=r(76219);function o(t,e){if("function"!=typeof t||null!=e&&"function"!=typeof e)throw TypeError("Expected a function");var r=function(){var n=arguments,o=e?e.apply(this,n):n[0],i=r.cache;if(i.has(o))return i.get(o);var a=t.apply(this,n);return r.cache=i.set(o,a)||i,a};return r.cache=new(o.Cache||n),r}o.Cache=n,t.exports=o},99008:function(t,e,r){var n=r(67646),o=r(20121),i=r(79586);t.exports=function(t){return t&&t.length?n(t,i,o):void 0}},93810:function(t){t.exports=function(){}},22350:function(t,e,r){var n=r(18155),o=r(73584),i=r(67352),a=r(70235);t.exports=function(t){return i(t)?n(a(t)):o(t)}},99676:function(t,e,r){var n=r(35464)();t.exports=n},33645:function(t,e,r){var n=r(25253),o=r(88157),i=r(12327),a=r(25614),u=r(49639);t.exports=function(t,e,r){var c=a(t)?n:i;return r&&u(t,e,r)&&(e=void 0),c(t,o(e,3))}},34935:function(t,e,r){var n=r(72569),o=r(84046),i=r(44843),a=r(49639),u=i(function(t,e){if(null==t)return[];var r=e.length;return r>1&&a(t,e[0],e[1])?e=[]:r>2&&a(e[0],e[1],e[2])&&(e=[e[0]]),o(t,n(e,1),[])});t.exports=u},55716:function(t){t.exports=function(){return[]}},7406:function(t){t.exports=function(){return!1}},37065:function(t,e,r){var n=r(7310),o=r(28302);t.exports=function(t,e,r){var i=!0,a=!0;if("function"!=typeof t)throw TypeError("Expected a function");return o(r)&&(i="leading"in r?!!r.leading:i,a="trailing"in r?!!r.trailing:a),n(t,e,{leading:i,maxWait:e,trailing:a})}},175:function(t,e,r){var n=r(6660),o=1/0;t.exports=function(t){return t?(t=n(t))===o||t===-o?(t<0?-1:1)*17976931348623157e292:t==t?t:0:0===t?t:0}},85759:function(t,e,r){var n=r(175);t.exports=function(t){var e=n(t),r=e%1;return e==e?r?e-r:e:0}},3641:function(t,e,r){var n=r(65020);t.exports=function(t){return null==t?"":n(t)}},47230:function(t,e,r){var n=r(88157),o=r(13826);t.exports=function(t,e){return t&&t.length?o(t,n(e,2)):[]}},75551:function(t,e,r){var n=r(80675)("toUpperCase");t.exports=n},48049:function(t,e,r){"use strict";var n=r(14397);function o(){}function i(){}i.resetWarningCache=o,t.exports=function(){function t(t,e,r,o,i,a){if(a!==n){var u=Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw u.name="Invariant Violation",u}}function e(){return t}t.isRequired=t;var r={array:t,bigint:t,bool:t,func:t,number:t,object:t,string:t,symbol:t,any:t,arrayOf:e,element:t,elementType:t,instanceOf:e,node:t,objectOf:e,oneOf:e,oneOfType:e,shape:e,exact:e,checkPropTypes:i,resetWarningCache:o};return r.PropTypes=r,r}},40718:function(t,e,r){t.exports=r(48049)()},14397:function(t){"use strict";t.exports="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED"},84735:function(t,e,r){"use strict";r.d(e,{ZP:function(){return tS}});var n=r(2265),o=r(40718),i=r.n(o),a=Object.getOwnPropertyNames,u=Object.getOwnPropertySymbols,c=Object.prototype.hasOwnProperty;function l(t,e){return function(r,n,o){return t(r,n,o)&&e(r,n,o)}}function s(t){return function(e,r,n){if(!e||!r||"object"!=typeof e||"object"!=typeof r)return t(e,r,n);var o=n.cache,i=o.get(e),a=o.get(r);if(i&&a)return i===r&&a===e;o.set(e,r),o.set(r,e);var u=t(e,r,n);return o.delete(e),o.delete(r),u}}function f(t){return a(t).concat(u(t))}var p=Object.hasOwn||function(t,e){return c.call(t,e)};function h(t,e){return t===e||!t&&!e&&t!=t&&e!=e}var d=Object.getOwnPropertyDescriptor,y=Object.keys;function v(t,e,r){var n=t.length;if(e.length!==n)return!1;for(;n-- >0;)if(!r.equals(t[n],e[n],n,n,t,e,r))return!1;return!0}function m(t,e){return h(t.getTime(),e.getTime())}function b(t,e){return t.name===e.name&&t.message===e.message&&t.cause===e.cause&&t.stack===e.stack}function g(t,e){return t===e}function x(t,e,r){var n,o,i=t.size;if(i!==e.size)return!1;if(!i)return!0;for(var a=Array(i),u=t.entries(),c=0;(n=u.next())&&!n.done;){for(var l=e.entries(),s=!1,f=0;(o=l.next())&&!o.done;){if(a[f]){f++;continue}var p=n.value,h=o.value;if(r.equals(p[0],h[0],c,f,t,e,r)&&r.equals(p[1],h[1],p[0],h[0],t,e,r)){s=a[f]=!0;break}f++}if(!s)return!1;c++}return!0}function w(t,e,r){var n=y(t),o=n.length;if(y(e).length!==o)return!1;for(;o-- >0;)if(!A(t,e,r,n[o]))return!1;return!0}function O(t,e,r){var n,o,i,a=f(t),u=a.length;if(f(e).length!==u)return!1;for(;u-- >0;)if(!A(t,e,r,n=a[u])||(o=d(t,n),i=d(e,n),(o||i)&&(!o||!i||o.configurable!==i.configurable||o.enumerable!==i.enumerable||o.writable!==i.writable)))return!1;return!0}function j(t,e){return h(t.valueOf(),e.valueOf())}function S(t,e){return t.source===e.source&&t.flags===e.flags}function P(t,e,r){var n,o,i=t.size;if(i!==e.size)return!1;if(!i)return!0;for(var a=Array(i),u=t.values();(n=u.next())&&!n.done;){for(var c=e.values(),l=!1,s=0;(o=c.next())&&!o.done;){if(!a[s]&&r.equals(n.value,o.value,n.value,o.value,t,e,r)){l=a[s]=!0;break}s++}if(!l)return!1}return!0}function E(t,e){var r=t.length;if(e.length!==r)return!1;for(;r-- >0;)if(t[r]!==e[r])return!1;return!0}function k(t,e){return t.hostname===e.hostname&&t.pathname===e.pathname&&t.protocol===e.protocol&&t.port===e.port&&t.hash===e.hash&&t.username===e.username&&t.password===e.password}function A(t,e,r,n){return("_owner"===n||"__o"===n||"__v"===n)&&(!!t.$$typeof||!!e.$$typeof)||p(e,n)&&r.equals(t[n],e[n],n,n,t,e,r)}var M=Array.isArray,_="undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView?ArrayBuffer.isView:null,T=Object.assign,C=Object.prototype.toString.call.bind(Object.prototype.toString),N=D();function D(t){void 0===t&&(t={});var e,r,n,o,i,a,u,c,f,p,d,y,A,N,D=t.circular,I=t.createInternalComparator,L=t.createState,B=t.strict,R=(r=(e=function(t){var e=t.circular,r=t.createCustomConfig,n=t.strict,o={areArraysEqual:n?O:v,areDatesEqual:m,areErrorsEqual:b,areFunctionsEqual:g,areMapsEqual:n?l(x,O):x,areNumbersEqual:h,areObjectsEqual:n?O:w,arePrimitiveWrappersEqual:j,areRegExpsEqual:S,areSetsEqual:n?l(P,O):P,areTypedArraysEqual:n?O:E,areUrlsEqual:k,unknownTagComparators:void 0};if(r&&(o=T({},o,r(o))),e){var i=s(o.areArraysEqual),a=s(o.areMapsEqual),u=s(o.areObjectsEqual),c=s(o.areSetsEqual);o=T({},o,{areArraysEqual:i,areMapsEqual:a,areObjectsEqual:u,areSetsEqual:c})}return o}(t)).areArraysEqual,n=e.areDatesEqual,o=e.areErrorsEqual,i=e.areFunctionsEqual,a=e.areMapsEqual,u=e.areNumbersEqual,c=e.areObjectsEqual,f=e.arePrimitiveWrappersEqual,p=e.areRegExpsEqual,d=e.areSetsEqual,y=e.areTypedArraysEqual,A=e.areUrlsEqual,N=e.unknownTagComparators,function(t,e,l){if(t===e)return!0;if(null==t||null==e)return!1;var s=typeof t;if(s!==typeof e)return!1;if("object"!==s)return"number"===s?u(t,e,l):"function"===s&&i(t,e,l);var h=t.constructor;if(h!==e.constructor)return!1;if(h===Object)return c(t,e,l);if(M(t))return r(t,e,l);if(null!=_&&_(t))return y(t,e,l);if(h===Date)return n(t,e,l);if(h===RegExp)return p(t,e,l);if(h===Map)return a(t,e,l);if(h===Set)return d(t,e,l);var v=C(t);if("[object Date]"===v)return n(t,e,l);if("[object RegExp]"===v)return p(t,e,l);if("[object Map]"===v)return a(t,e,l);if("[object Set]"===v)return d(t,e,l);if("[object Object]"===v)return"function"!=typeof t.then&&"function"!=typeof e.then&&c(t,e,l);if("[object URL]"===v)return A(t,e,l);if("[object Error]"===v)return o(t,e,l);if("[object Arguments]"===v)return c(t,e,l);if("[object Boolean]"===v||"[object Number]"===v||"[object String]"===v)return f(t,e,l);if(N){var m=N[v];if(!m){var b=null!=t?t[Symbol.toStringTag]:void 0;b&&(m=N[b])}if(m)return m(t,e,l)}return!1}),z=I?I(R):function(t,e,r,n,o,i,a){return R(t,e,a)};return function(t){var e=t.circular,r=t.comparator,n=t.createState,o=t.equals,i=t.strict;if(n)return function(t,a){var u=n(),c=u.cache;return r(t,a,{cache:void 0===c?e?new WeakMap:void 0:c,equals:o,meta:u.meta,strict:i})};if(e)return function(t,e){return r(t,e,{cache:new WeakMap,equals:o,meta:void 0,strict:i})};var a={cache:void 0,equals:o,meta:void 0,strict:i};return function(t,e){return r(t,e,a)}}({circular:void 0!==D&&D,comparator:R,createState:L,equals:z,strict:void 0!==B&&B})}function I(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=-1;requestAnimationFrame(function n(o){if(r<0&&(r=o),o-r>e)t(o),r=-1;else{var i;i=n,"undefined"!=typeof requestAnimationFrame&&requestAnimationFrame(i)}})}function L(t){return(L="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function B(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);rt.length)&&(e=t.length);for(var r=0,n=Array(e);r=0&&t<=1}),"[configBezier]: arguments should be x1, y1, x2, y2 of [0, 1] instead received %s",n);var p=V(i,u),h=V(a,c),d=(t=i,e=u,function(r){var n;return G([].concat(function(t){if(Array.isArray(t))return H(t)}(n=X(t,e).map(function(t,e){return t*e}).slice(1))||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(n)||Y(n)||function(){throw TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(),[0]),r)}),y=function(t){for(var e=t>1?1:t,r=e,n=0;n<8;++n){var o,i=p(r)-e,a=d(r);if(1e-4>Math.abs(i-e)||a<1e-4)break;r=(o=r-i/a)>1?1:o<0?0:o}return h(r)};return y.isStepper=!1,y},Q=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e=t.stiff,r=void 0===e?100:e,n=t.damping,o=void 0===n?8:n,i=t.dt,a=void 0===i?17:i,u=function(t,e,n){var i=n+(-(t-e)*r-n*o)*a/1e3,u=n*a/1e3+t;return 1e-4>Math.abs(u-e)&&1e-4>Math.abs(i)?[e,0]:[u,i]};return u.isStepper=!0,u.dt=a,u},J=function(){for(var t=arguments.length,e=Array(t),r=0;rt.length)&&(e=t.length);for(var r=0,n=Array(e);rt.length)&&(e=t.length);for(var r=0,n=Array(e);r0?r[o-1]:n,p=l||Object.keys(c);if("function"==typeof u||"spring"===u)return[].concat(th(t),[e.runJSAnimation.bind(e,{from:f.style,to:c,duration:i,easing:u}),i]);var h=Z(p,i,u),d=tv(tv(tv({},f.style),c),{},{transition:h});return[].concat(th(t),[d,i,s]).filter($)},[a,Math.max(void 0===u?0:u,n)])),[t.onAnimationEnd]))}},{key:"runAnimation",value:function(t){if(!this.manager){var e,r,n;this.manager=(e=function(){return null},r=!1,n=function t(n){if(!r){if(Array.isArray(n)){if(!n.length)return;var o=function(t){if(Array.isArray(t))return t}(n)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(n)||function(t,e){if(t){if("string"==typeof t)return B(t,void 0);var r=Object.prototype.toString.call(t).slice(8,-1);if("Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r)return Array.from(t);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return B(t,void 0)}}(n)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(),i=o[0],a=o.slice(1);if("number"==typeof i){I(t.bind(null,a),i);return}t(i),I(t.bind(null,a));return}"object"===L(n)&&e(n),"function"==typeof n&&n()}},{stop:function(){r=!0},start:function(t){r=!1,n(t)},subscribe:function(t){return e=t,function(){e=function(){return null}}}})}var o=t.begin,i=t.duration,a=t.attributeName,u=t.to,c=t.easing,l=t.onAnimationStart,s=t.onAnimationEnd,f=t.steps,p=t.children,h=this.manager;if(this.unSubscribe=h.subscribe(this.handleStyleChange),"function"==typeof c||"function"==typeof p||"spring"===c){this.runJSAnimation(t);return}if(f.length>1){this.runStepAnimation(t);return}var d=a?tm({},a,u):u,y=Z(Object.keys(d),i,c);h.start([l,o,tv(tv({},d),{},{transition:y}),i,s])}},{key:"render",value:function(){var t=this.props,e=t.children,r=(t.begin,t.duration),o=(t.attributeName,t.easing,t.isActive),i=(t.steps,t.from,t.to,t.canBegin,t.onAnimationEnd,t.shouldReAnimate,t.onAnimationReStart,function(t,e){if(null==t)return{};var r,n,o=function(t,e){if(null==t)return{};var r,n,o={},i=Object.keys(t);for(n=0;n=0||(o[r]=t[r]);return o}(t,e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(n=0;n=0)&&Object.prototype.propertyIsEnumerable.call(t,r)&&(o[r]=t[r])}return o}(t,tp)),a=n.Children.count(e),u=this.state.style;if("function"==typeof e)return e(u);if(!o||0===a||r<=0)return e;var c=function(t){var e=t.props,r=e.style,o=e.className;return(0,n.cloneElement)(t,tv(tv({},i),{},{style:tv(tv({},void 0===r?{}:r),u),className:o}))};return 1===a?c(n.Children.only(e)):n.createElement("div",null,n.Children.map(e,function(t){return c(t)}))}}],function(t,e){for(var r=0;r=0)continue;r[n]=t[n]}return r}(t,e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(n=0;n=0)&&Object.prototype.propertyIsEnumerable.call(t,r)&&(o[r]=t[r])}return o}(t,w),i=parseInt("".concat(r),10),a=parseInt("".concat(n),10),u=parseInt("".concat(e.height||o.height),10),c=parseInt("".concat(e.width||o.width),10);return P(P(P(P(P({},e),o),i?{x:i}:{}),a?{y:a}:{}),{},{height:u,width:c,name:e.name,radius:e.radius})}function k(t){return n.createElement(x.bn,j({shapeType:"rectangle",propTransformer:E,activeClassName:"recharts-active-bar"},t))}var A=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return function(r,n){if("number"==typeof t)return t;var o=(0,d.hj)(r)||(0,d.Rw)(r);return o?t(r,n):(o||(0,g.Z)(!1),e)}},M=["value","background"];function _(t){return(_="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function T(){return(T=Object.assign?Object.assign.bind():function(t){for(var e=1;e=0)continue;r[n]=t[n]}return r}(t,e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(n=0;n=0)&&Object.prototype.propertyIsEnumerable.call(t,r)&&(o[r]=t[r])}return o}(e,M);if(!u)return null;var l=N(N(N(N(N({},c),{},{fill:"#eee"},u),a),(0,b.bw)(t.props,e,r)),{},{onAnimationStart:t.handleAnimationStart,onAnimationEnd:t.handleAnimationEnd,dataKey:o,index:r,className:"recharts-bar-background-rectangle"});return n.createElement(k,T({key:"background-bar-".concat(r),option:t.props.background,isActive:r===i},l))})}},{key:"renderErrorBar",value:function(t,e){if(this.props.isAnimationActive&&!this.state.isAnimationFinished)return null;var r=this.props,o=r.data,i=r.xAxis,a=r.yAxis,u=r.layout,c=r.children,l=(0,y.NN)(c,f.W);if(!l)return null;var p="vertical"===u?o[0].height/2:o[0].width/2,h=function(t,e){var r=Array.isArray(t.value)?t.value[1]:t.value;return{x:t.x,y:t.y,value:r,errorVal:(0,m.F$)(t,e)}};return n.createElement(s.m,{clipPath:t?"url(#clipPath-".concat(e,")"):null},l.map(function(t){return n.cloneElement(t,{key:"error-bar-".concat(e,"-").concat(t.props.dataKey),data:o,xAxis:i,yAxis:a,layout:u,offset:p,dataPointFormatter:h})}))}},{key:"render",value:function(){var t=this.props,e=t.hide,r=t.data,i=t.className,a=t.xAxis,u=t.yAxis,c=t.left,f=t.top,p=t.width,d=t.height,y=t.isAnimationActive,v=t.background,m=t.id;if(e||!r||!r.length)return null;var b=this.state.isAnimationFinished,g=(0,o.Z)("recharts-bar",i),x=a&&a.allowDataOverflow,w=u&&u.allowDataOverflow,O=x||w,j=l()(m)?this.id:m;return n.createElement(s.m,{className:g},x||w?n.createElement("defs",null,n.createElement("clipPath",{id:"clipPath-".concat(j)},n.createElement("rect",{x:x?c:c-p/2,y:w?f:f-d/2,width:x?p:2*p,height:w?d:2*d}))):null,n.createElement(s.m,{className:"recharts-bar-rectangles",clipPath:O?"url(#clipPath-".concat(j,")"):null},v?this.renderBackground():null,this.renderRectangles()),this.renderErrorBar(O,j),(!y||b)&&h.e.renderCallByParent(this.props,r))}}],r=[{key:"getDerivedStateFromProps",value:function(t,e){return t.animationId!==e.prevAnimationId?{prevAnimationId:t.animationId,curData:t.data,prevData:e.curData}:t.data!==e.curData?{curData:t.data}:null}}],e&&D(a.prototype,e),r&&D(a,r),Object.defineProperty(a,"prototype",{writable:!1}),a}(n.PureComponent);R(U,"displayName","Bar"),R(U,"defaultProps",{xAxisId:0,yAxisId:0,legendType:"rect",minPointSize:0,hide:!1,data:[],layout:"vertical",activeBar:!1,isAnimationActive:!v.x.isSsr,animationBegin:0,animationDuration:400,animationEasing:"ease"}),R(U,"getComposedData",function(t){var e=t.props,r=t.item,n=t.barPosition,o=t.bandSize,i=t.xAxis,a=t.yAxis,u=t.xAxisTicks,c=t.yAxisTicks,l=t.stackedData,s=t.dataStartIndex,f=t.displayedData,h=t.offset,v=(0,m.Bu)(n,r);if(!v)return null;var b=e.layout,g=r.type.defaultProps,x=void 0!==g?N(N({},g),r.props):r.props,w=x.dataKey,O=x.children,j=x.minPointSize,S="horizontal"===b?a:i,P=l?S.scale.domain():null,E=(0,m.Yj)({numericAxis:S}),k=(0,y.NN)(O,p.b),M=f.map(function(t,e){l?f=(0,m.Vv)(l[s+e],P):Array.isArray(f=(0,m.F$)(t,w))||(f=[E,f]);var n=A(j,U.defaultProps.minPointSize)(f[1],e);if("horizontal"===b){var f,p,h,y,g,x,O,S=[a.scale(f[0]),a.scale(f[1])],M=S[0],_=S[1];p=(0,m.Fy)({axis:i,ticks:u,bandSize:o,offset:v.offset,entry:t,index:e}),h=null!==(O=null!=_?_:M)&&void 0!==O?O:void 0,y=v.size;var T=M-_;if(g=Number.isNaN(T)?0:T,x={x:p,y:a.y,width:y,height:a.height},Math.abs(n)>0&&Math.abs(g)0&&Math.abs(y)=0)continue;r[n]=t[n]}return r}(t,e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(n=0;n=0)&&Object.prototype.propertyIsEnumerable.call(t,r)&&(o[r]=t[r])}return o}function P(t,e){for(var r=0;r0?this.props:d)),o<=0||a<=0||!y||!y.length)?null:n.createElement(s.m,{className:(0,c.Z)("recharts-cartesian-axis",l),ref:function(e){t.layerReference=e}},r&&this.renderAxisLine(),this.renderTicks(y,this.state.fontSize,this.state.letterSpacing),p._.renderCallByParent(this.props))}}],r=[{key:"renderTickItem",value:function(t,e,r){var o=(0,c.Z)(e.className,"recharts-cartesian-axis-tick-value");return n.isValidElement(t)?n.cloneElement(t,j(j({},e),{},{className:o})):i()(t)?t(j(j({},e),{},{className:o})):n.createElement(f.x,w({},e,{className:"recharts-cartesian-axis-tick-value"}),r)}}],e&&P(o.prototype,e),r&&P(o,r),Object.defineProperty(o,"prototype",{writable:!1}),o}(n.Component);M(T,"displayName","CartesianAxis"),M(T,"defaultProps",{x:0,y:0,width:0,height:0,viewBox:{x:0,y:0,width:0,height:0},orientation:"bottom",ticks:[],stroke:"#666",tickLine:!0,axisLine:!0,tick:!0,mirror:!1,minTickGap:5,tickSize:6,tickMargin:2,interval:"preserveEnd"})},56940:function(t,e,r){"use strict";r.d(e,{q:function(){return M}});var n=r(2265),o=r(86757),i=r.n(o),a=r(1175),u=r(16630),c=r(82944),l=r(85355),s=r(78242),f=r(80285),p=r(25739),h=["x1","y1","x2","y2","key"],d=["offset"];function y(t){return(y="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function v(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),r.push.apply(r,n)}return r}function m(t){for(var e=1;e=0)continue;r[n]=t[n]}return r}(t,e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(n=0;n=0)&&Object.prototype.propertyIsEnumerable.call(t,r)&&(o[r]=t[r])}return o}var x=function(t){var e=t.fill;if(!e||"none"===e)return null;var r=t.fillOpacity,o=t.x,i=t.y,a=t.width,u=t.height,c=t.ry;return n.createElement("rect",{x:o,y:i,ry:c,width:a,height:u,stroke:"none",fill:e,fillOpacity:r,className:"recharts-cartesian-grid-bg"})};function w(t,e){var r;if(n.isValidElement(t))r=n.cloneElement(t,e);else if(i()(t))r=t(e);else{var o=e.x1,a=e.y1,u=e.x2,l=e.y2,s=e.key,f=g(e,h),p=(0,c.L6)(f,!1),y=(p.offset,g(p,d));r=n.createElement("line",b({},y,{x1:o,y1:a,x2:u,y2:l,fill:"none",key:s}))}return r}function O(t){var e=t.x,r=t.width,o=t.horizontal,i=void 0===o||o,a=t.horizontalPoints;if(!i||!a||!a.length)return null;var u=a.map(function(n,o){return w(i,m(m({},t),{},{x1:e,y1:n,x2:e+r,y2:n,key:"line-".concat(o),index:o}))});return n.createElement("g",{className:"recharts-cartesian-grid-horizontal"},u)}function j(t){var e=t.y,r=t.height,o=t.vertical,i=void 0===o||o,a=t.verticalPoints;if(!i||!a||!a.length)return null;var u=a.map(function(n,o){return w(i,m(m({},t),{},{x1:n,y1:e,x2:n,y2:e+r,key:"line-".concat(o),index:o}))});return n.createElement("g",{className:"recharts-cartesian-grid-vertical"},u)}function S(t){var e=t.horizontalFill,r=t.fillOpacity,o=t.x,i=t.y,a=t.width,u=t.height,c=t.horizontalPoints,l=t.horizontal;if(!(void 0===l||l)||!e||!e.length)return null;var s=c.map(function(t){return Math.round(t+i-i)}).sort(function(t,e){return t-e});i!==s[0]&&s.unshift(0);var f=s.map(function(t,c){var l=s[c+1]?s[c+1]-t:i+u-t;if(l<=0)return null;var f=c%e.length;return n.createElement("rect",{key:"react-".concat(c),y:t,x:o,height:l,width:a,stroke:"none",fill:e[f],fillOpacity:r,className:"recharts-cartesian-grid-bg"})});return n.createElement("g",{className:"recharts-cartesian-gridstripes-horizontal"},f)}function P(t){var e=t.vertical,r=t.verticalFill,o=t.fillOpacity,i=t.x,a=t.y,u=t.width,c=t.height,l=t.verticalPoints;if(!(void 0===e||e)||!r||!r.length)return null;var s=l.map(function(t){return Math.round(t+i-i)}).sort(function(t,e){return t-e});i!==s[0]&&s.unshift(0);var f=s.map(function(t,e){var l=s[e+1]?s[e+1]-t:i+u-t;if(l<=0)return null;var f=e%r.length;return n.createElement("rect",{key:"react-".concat(e),x:t,y:a,width:l,height:c,stroke:"none",fill:r[f],fillOpacity:o,className:"recharts-cartesian-grid-bg"})});return n.createElement("g",{className:"recharts-cartesian-gridstripes-vertical"},f)}var E=function(t,e){var r=t.xAxis,n=t.width,o=t.height,i=t.offset;return(0,l.Rf)((0,s.f)(m(m(m({},f.O.defaultProps),r),{},{ticks:(0,l.uY)(r,!0),viewBox:{x:0,y:0,width:n,height:o}})),i.left,i.left+i.width,e)},k=function(t,e){var r=t.yAxis,n=t.width,o=t.height,i=t.offset;return(0,l.Rf)((0,s.f)(m(m(m({},f.O.defaultProps),r),{},{ticks:(0,l.uY)(r,!0),viewBox:{x:0,y:0,width:n,height:o}})),i.top,i.top+i.height,e)},A={horizontal:!0,vertical:!0,stroke:"#ccc",fill:"none",verticalFill:[],horizontalFill:[]};function M(t){var e,r,o,c,l,s,f=(0,p.zn)(),h=(0,p.Mw)(),d=(0,p.qD)(),v=m(m({},t),{},{stroke:null!==(e=t.stroke)&&void 0!==e?e:A.stroke,fill:null!==(r=t.fill)&&void 0!==r?r:A.fill,horizontal:null!==(o=t.horizontal)&&void 0!==o?o:A.horizontal,horizontalFill:null!==(c=t.horizontalFill)&&void 0!==c?c:A.horizontalFill,vertical:null!==(l=t.vertical)&&void 0!==l?l:A.vertical,verticalFill:null!==(s=t.verticalFill)&&void 0!==s?s:A.verticalFill,x:(0,u.hj)(t.x)?t.x:d.left,y:(0,u.hj)(t.y)?t.y:d.top,width:(0,u.hj)(t.width)?t.width:d.width,height:(0,u.hj)(t.height)?t.height:d.height}),g=v.x,w=v.y,M=v.width,_=v.height,T=v.syncWithTicks,C=v.horizontalValues,N=v.verticalValues,D=(0,p.CW)(),I=(0,p.Nf)();if(!(0,u.hj)(M)||M<=0||!(0,u.hj)(_)||_<=0||!(0,u.hj)(g)||g!==+g||!(0,u.hj)(w)||w!==+w)return null;var L=v.verticalCoordinatesGenerator||E,B=v.horizontalCoordinatesGenerator||k,R=v.horizontalPoints,z=v.verticalPoints;if((!R||!R.length)&&i()(B)){var U=C&&C.length,F=B({yAxis:I?m(m({},I),{},{ticks:U?C:I.ticks}):void 0,width:f,height:h,offset:d},!!U||T);(0,a.Z)(Array.isArray(F),"horizontalCoordinatesGenerator should return Array but instead it returned [".concat(y(F),"]")),Array.isArray(F)&&(R=F)}if((!z||!z.length)&&i()(L)){var $=N&&N.length,q=L({xAxis:D?m(m({},D),{},{ticks:$?N:D.ticks}):void 0,width:f,height:h,offset:d},!!$||T);(0,a.Z)(Array.isArray(q),"verticalCoordinatesGenerator should return Array but instead it returned [".concat(y(q),"]")),Array.isArray(q)&&(z=q)}return n.createElement("g",{className:"recharts-cartesian-grid"},n.createElement(x,{fill:v.fill,fillOpacity:v.fillOpacity,x:v.x,y:v.y,width:v.width,height:v.height,ry:v.ry}),n.createElement(O,b({},v,{offset:d,horizontalPoints:R,xAxis:D,yAxis:I})),n.createElement(j,b({},v,{offset:d,verticalPoints:z,xAxis:D,yAxis:I})),n.createElement(S,b({},v,{horizontalPoints:R})),n.createElement(P,b({},v,{verticalPoints:z})))}M.displayName="CartesianGrid"},13137:function(t,e,r){"use strict";r.d(e,{W:function(){return v}});var n=r(2265),o=r(69398),i=r(9841),a=r(82944),u=["offset","layout","width","dataKey","data","dataPointFormatter","xAxis","yAxis"];function c(t){return(c="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function l(){return(l=Object.assign?Object.assign.bind():function(t){for(var e=1;et.length)&&(e=t.length);for(var r=0,n=Array(e);r=0)continue;r[n]=t[n]}return r}(t,e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(n=0;n=0)&&Object.prototype.propertyIsEnumerable.call(t,r)&&(o[r]=t[r])}return o}(t,u),m=(0,a.L6)(v,!1);"x"===this.props.direction&&"number"!==d.type&&(0,o.Z)(!1);var b=p.map(function(t){var o,a,u=h(t,f),p=u.x,v=u.y,b=u.value,g=u.errorVal;if(!g)return null;var x=[];if(Array.isArray(g)){var w=function(t){if(Array.isArray(t))return t}(g)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,u=[],c=!0,l=!1;try{for(i=(r=r.call(t)).next;!(c=(n=i.call(r)).done)&&(u.push(n.value),2!==u.length);c=!0);}catch(t){l=!0,o=t}finally{try{if(!c&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(l)throw o}}return u}}(g,2)||function(t,e){if(t){if("string"==typeof t)return s(t,2);var r=Object.prototype.toString.call(t).slice(8,-1);if("Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r)return Array.from(t);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return s(t,2)}}(g,2)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}();o=w[0],a=w[1]}else o=a=g;if("vertical"===r){var O=d.scale,j=v+e,S=j+c,P=j-c,E=O(b-o),k=O(b+a);x.push({x1:k,y1:S,x2:k,y2:P}),x.push({x1:E,y1:j,x2:k,y2:j}),x.push({x1:E,y1:S,x2:E,y2:P})}else if("horizontal"===r){var A=y.scale,M=p+e,_=M-c,T=M+c,C=A(b-o),N=A(b+a);x.push({x1:_,y1:N,x2:T,y2:N}),x.push({x1:M,y1:C,x2:M,y2:N}),x.push({x1:_,y1:C,x2:T,y2:C})}return n.createElement(i.m,l({className:"recharts-errorBar",key:"bar-".concat(x.map(function(t){return"".concat(t.x1,"-").concat(t.x2,"-").concat(t.y1,"-").concat(t.y2)}))},m),x.map(function(t){return n.createElement("line",l({},t,{key:"line-".concat(t.x1,"-").concat(t.x2,"-").concat(t.y1,"-").concat(t.y2)}))}))});return n.createElement(i.m,{className:"recharts-errorBars"},b)}}],function(t,e){for(var r=0;rt*o)return!1;var i=r();return t*(e-t*i/2-n)>=0&&t*(e+t*i/2-o)<=0}function f(t){return(f="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function p(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),r.push.apply(r,n)}return r}function h(t){for(var e=1;e=2?(0,i.uY)(m[1].coordinate-m[0].coordinate):1,M=(n="width"===P,f=b.x,p=b.y,d=b.width,y=b.height,1===A?{start:n?f:p,end:n?f+d:p+y}:{start:n?f+d:p+y,end:n?f:p});return"equidistantPreserveStart"===w?function(t,e,r,n,o){for(var i,a=(n||[]).slice(),u=e.start,c=e.end,f=0,p=1,h=u;p<=a.length;)if(i=function(){var e,i=null==n?void 0:n[f];if(void 0===i)return{v:l(n,p)};var a=f,d=function(){return void 0===e&&(e=r(i,a)),e},y=i.coordinate,v=0===f||s(t,y,d,h,c);v||(f=0,h=u,p+=1),v&&(h=y+t*(d()/2+o),f+=p)}())return i.v;return[]}(A,M,k,m,g):("preserveStart"===w||"preserveStartEnd"===w?function(t,e,r,n,o,i){var a=(n||[]).slice(),u=a.length,c=e.start,l=e.end;if(i){var f=n[u-1],p=r(f,u-1),d=t*(f.coordinate+t*p/2-l);a[u-1]=f=h(h({},f),{},{tickCoord:d>0?f.coordinate-d*t:f.coordinate}),s(t,f.tickCoord,function(){return p},c,l)&&(l=f.tickCoord-t*(p/2+o),a[u-1]=h(h({},f),{},{isShow:!0}))}for(var y=i?u-1:u,v=function(e){var n,i=a[e],u=function(){return void 0===n&&(n=r(i,e)),n};if(0===e){var f=t*(i.coordinate-t*u()/2-c);a[e]=i=h(h({},i),{},{tickCoord:f<0?i.coordinate-f*t:i.coordinate})}else a[e]=i=h(h({},i),{},{tickCoord:i.coordinate});s(t,i.tickCoord,u,c,l)&&(c=i.tickCoord+t*(u()/2+o),a[e]=h(h({},i),{},{isShow:!0}))},m=0;m0?l.coordinate-p*t:l.coordinate})}else i[e]=l=h(h({},l),{},{tickCoord:l.coordinate});s(t,l.tickCoord,f,u,c)&&(c=l.tickCoord-t*(f()/2+o),i[e]=h(h({},l),{},{isShow:!0}))},f=a-1;f>=0;f--)l(f);return i}(A,M,k,m,g)).filter(function(t){return t.isShow})}},93765:function(t,e,r){"use strict";r.d(e,{z:function(){return eD}});var n,o,i=r(2265),a=r(77571),u=r.n(a),c=r(86757),l=r.n(c),s=r(99676),f=r.n(s),p=r(13735),h=r.n(p),d=r(34935),y=r.n(d),v=r(37065),m=r.n(v),b=r(61994),g=r(69398),x=r(48777),w=r(9841),O=r(8147),j=r(22190),S=r(81889),P=r(73649),E=r(82944),k=r(55284),A=r(58811),M=r(85355),_=r(16630);function T(t){return(T="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function C(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),r.push.apply(r,n)}return r}function N(t){for(var e=1;e0&&e.handleDrag(t.changedTouches[0])}),W(e,"handleDragEnd",function(){e.setState({isTravellerMoving:!1,isSlideMoving:!1},function(){var t=e.props,r=t.endIndex,n=t.onDragEnd,o=t.startIndex;null==n||n({endIndex:r,startIndex:o})}),e.detachDragEndListener()}),W(e,"handleLeaveWrapper",function(){(e.state.isTravellerMoving||e.state.isSlideMoving)&&(e.leaveTimer=window.setTimeout(e.handleDragEnd,e.props.leaveTimeOut))}),W(e,"handleEnterSlideOrTraveller",function(){e.setState({isTextActive:!0})}),W(e,"handleLeaveSlideOrTraveller",function(){e.setState({isTextActive:!1})}),W(e,"handleSlideDragStart",function(t){var r=X(t)?t.changedTouches[0]:t;e.setState({isTravellerMoving:!1,isSlideMoving:!0,slideMoveStartX:r.pageX}),e.attachDragEndListener()}),e.travellerDragStartHandlers={startX:e.handleTravellerDragStart.bind(e,"startX"),endX:e.handleTravellerDragStart.bind(e,"endX")},e.state={},e}return!function(t,e){if("function"!=typeof e&&null!==e)throw TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&Z(t,e)}(n,t),e=[{key:"componentWillUnmount",value:function(){this.leaveTimer&&(clearTimeout(this.leaveTimer),this.leaveTimer=null),this.detachDragEndListener()}},{key:"getIndex",value:function(t){var e=t.startX,r=t.endX,o=this.state.scaleValues,i=this.props,a=i.gap,u=i.data.length-1,c=n.getIndexInRange(o,Math.min(e,r)),l=n.getIndexInRange(o,Math.max(e,r));return{startIndex:c-c%a,endIndex:l===u?u:l-l%a}}},{key:"getTextOfTick",value:function(t){var e=this.props,r=e.data,n=e.tickFormatter,o=e.dataKey,i=(0,M.F$)(r[t],o,t);return l()(n)?n(i,t):i}},{key:"attachDragEndListener",value:function(){window.addEventListener("mouseup",this.handleDragEnd,!0),window.addEventListener("touchend",this.handleDragEnd,!0),window.addEventListener("mousemove",this.handleDrag,!0)}},{key:"detachDragEndListener",value:function(){window.removeEventListener("mouseup",this.handleDragEnd,!0),window.removeEventListener("touchend",this.handleDragEnd,!0),window.removeEventListener("mousemove",this.handleDrag,!0)}},{key:"handleSlideDrag",value:function(t){var e=this.state,r=e.slideMoveStartX,n=e.startX,o=e.endX,i=this.props,a=i.x,u=i.width,c=i.travellerWidth,l=i.startIndex,s=i.endIndex,f=i.onChange,p=t.pageX-r;p>0?p=Math.min(p,a+u-c-o,a+u-c-n):p<0&&(p=Math.max(p,a-n,a-o));var h=this.getIndex({startX:n+p,endX:o+p});(h.startIndex!==l||h.endIndex!==s)&&f&&f(h),this.setState({startX:n+p,endX:o+p,slideMoveStartX:t.pageX})}},{key:"handleTravellerDragStart",value:function(t,e){var r=X(e)?e.changedTouches[0]:e;this.setState({isSlideMoving:!1,isTravellerMoving:!0,movingTravellerId:t,brushMoveStartX:r.pageX}),this.attachDragEndListener()}},{key:"handleTravellerMove",value:function(t){var e=this.state,r=e.brushMoveStartX,n=e.movingTravellerId,o=e.endX,i=e.startX,a=this.state[n],u=this.props,c=u.x,l=u.width,s=u.travellerWidth,f=u.onChange,p=u.gap,h=u.data,d={startX:this.state.startX,endX:this.state.endX},y=t.pageX-r;y>0?y=Math.min(y,c+l-s-a):y<0&&(y=Math.max(y,c-a)),d[n]=a+y;var v=this.getIndex(d),m=v.startIndex,b=v.endIndex,g=function(){var t=h.length-1;return"startX"===n&&(o>i?m%p==0:b%p==0)||oi?b%p==0:m%p==0)||o>i&&b===t};this.setState(W(W({},n,a+y),"brushMoveStartX",t.pageX),function(){f&&g()&&f(v)})}},{key:"handleTravellerMoveKeyboard",value:function(t,e){var r=this,n=this.state,o=n.scaleValues,i=n.startX,a=n.endX,u=this.state[e],c=o.indexOf(u);if(-1!==c){var l=c+t;if(-1!==l&&!(l>=o.length)){var s=o[l];"startX"===e&&s>=a||"endX"===e&&s<=i||this.setState(W({},e,s),function(){r.props.onChange(r.getIndex({startX:r.state.startX,endX:r.state.endX}))})}}}},{key:"renderBackground",value:function(){var t=this.props,e=t.x,r=t.y,n=t.width,o=t.height,a=t.fill,u=t.stroke;return i.createElement("rect",{stroke:u,fill:a,x:e,y:r,width:n,height:o})}},{key:"renderPanorama",value:function(){var t=this.props,e=t.x,r=t.y,n=t.width,o=t.height,a=t.data,u=t.children,c=t.padding,l=i.Children.only(u);return l?i.cloneElement(l,{x:e,y:r,width:n,height:o,margin:c,compact:!0,data:a}):null}},{key:"renderTravellerLayer",value:function(t,e){var r,o,a=this,u=this.props,c=u.y,l=u.travellerWidth,s=u.height,f=u.traveller,p=u.ariaLabel,h=u.data,d=u.startIndex,y=u.endIndex,v=Math.max(t,this.props.x),m=U(U({},(0,E.L6)(this.props,!1)),{},{x:v,y:c,width:l,height:s}),b=p||"Min value: ".concat(null===(r=h[d])||void 0===r?void 0:r.name,", Max value: ").concat(null===(o=h[y])||void 0===o?void 0:o.name);return i.createElement(w.m,{tabIndex:0,role:"slider","aria-label":b,"aria-valuenow":t,className:"recharts-brush-traveller",onMouseEnter:this.handleEnterSlideOrTraveller,onMouseLeave:this.handleLeaveSlideOrTraveller,onMouseDown:this.travellerDragStartHandlers[e],onTouchStart:this.travellerDragStartHandlers[e],onKeyDown:function(t){["ArrowLeft","ArrowRight"].includes(t.key)&&(t.preventDefault(),t.stopPropagation(),a.handleTravellerMoveKeyboard("ArrowRight"===t.key?1:-1,e))},onFocus:function(){a.setState({isTravellerFocused:!0})},onBlur:function(){a.setState({isTravellerFocused:!1})},style:{cursor:"col-resize"}},n.renderTraveller(f,m))}},{key:"renderSlide",value:function(t,e){var r=this.props,n=r.y,o=r.height,a=r.stroke,u=r.travellerWidth;return i.createElement("rect",{className:"recharts-brush-slide",onMouseEnter:this.handleEnterSlideOrTraveller,onMouseLeave:this.handleLeaveSlideOrTraveller,onMouseDown:this.handleSlideDragStart,onTouchStart:this.handleSlideDragStart,style:{cursor:"move"},stroke:"none",fill:a,fillOpacity:.2,x:Math.min(t,e)+u,y:n,width:Math.max(Math.abs(e-t)-u,0),height:o})}},{key:"renderText",value:function(){var t=this.props,e=t.startIndex,r=t.endIndex,n=t.y,o=t.height,a=t.travellerWidth,u=t.stroke,c=this.state,l=c.startX,s=c.endX,f={pointerEvents:"none",fill:u};return i.createElement(w.m,{className:"recharts-brush-texts"},i.createElement(A.x,R({textAnchor:"end",verticalAnchor:"middle",x:Math.min(l,s)-5,y:n+o/2},f),this.getTextOfTick(e)),i.createElement(A.x,R({textAnchor:"start",verticalAnchor:"middle",x:Math.max(l,s)+a+5,y:n+o/2},f),this.getTextOfTick(r)))}},{key:"render",value:function(){var t=this.props,e=t.data,r=t.className,n=t.children,o=t.x,a=t.y,u=t.width,c=t.height,l=t.alwaysShowText,s=this.state,f=s.startX,p=s.endX,h=s.isTextActive,d=s.isSlideMoving,y=s.isTravellerMoving,v=s.isTravellerFocused;if(!e||!e.length||!(0,_.hj)(o)||!(0,_.hj)(a)||!(0,_.hj)(u)||!(0,_.hj)(c)||u<=0||c<=0)return null;var m=(0,b.Z)("recharts-brush",r),g=1===i.Children.count(n),x=L("userSelect","none");return i.createElement(w.m,{className:m,onMouseLeave:this.handleLeaveWrapper,onTouchMove:this.handleTouchMove,style:x},this.renderBackground(),g&&this.renderPanorama(),this.renderSlide(f,p),this.renderTravellerLayer(f,"startX"),this.renderTravellerLayer(p,"endX"),(h||d||y||v||l)&&this.renderText())}}],r=[{key:"renderDefaultTraveller",value:function(t){var e=t.x,r=t.y,n=t.width,o=t.height,a=t.stroke,u=Math.floor(r+o/2)-1;return i.createElement(i.Fragment,null,i.createElement("rect",{x:e,y:r,width:n,height:o,fill:a,stroke:"none"}),i.createElement("line",{x1:e+1,y1:u,x2:e+n-1,y2:u,fill:"none",stroke:"#fff"}),i.createElement("line",{x1:e+1,y1:u+2,x2:e+n-1,y2:u+2,fill:"none",stroke:"#fff"}))}},{key:"renderTraveller",value:function(t,e){return i.isValidElement(t)?i.cloneElement(t,e):l()(t)?t(e):n.renderDefaultTraveller(e)}},{key:"getDerivedStateFromProps",value:function(t,e){var r=t.data,n=t.width,o=t.x,i=t.travellerWidth,a=t.updateId,u=t.startIndex,c=t.endIndex;if(r!==e.prevData||a!==e.prevUpdateId)return U({prevData:r,prevTravellerWidth:i,prevUpdateId:a,prevX:o,prevWidth:n},r&&r.length?H({data:r,width:n,x:o,travellerWidth:i,startIndex:u,endIndex:c}):{scale:null,scaleValues:null});if(e.scale&&(n!==e.prevWidth||o!==e.prevX||i!==e.prevTravellerWidth)){e.scale.range([o,o+n-i]);var l=e.scale.domain().map(function(t){return e.scale(t)});return{prevData:r,prevTravellerWidth:i,prevUpdateId:a,prevX:o,prevWidth:n,startX:e.scale(t.startIndex),endX:e.scale(t.endIndex),scaleValues:l}}return null}},{key:"getIndexInRange",value:function(t,e){for(var r=t.length,n=0,o=r-1;o-n>1;){var i=Math.floor((n+o)/2);t[i]>e?o=i:n=i}return e>=t[o]?o:n}}],e&&F(n.prototype,e),r&&F(n,r),Object.defineProperty(n,"prototype",{writable:!1}),n}(i.PureComponent);W(G,"displayName","Brush"),W(G,"defaultProps",{height:40,travellerWidth:5,gap:1,fill:"#fff",stroke:"#666",padding:{top:1,right:1,bottom:1,left:1},leaveTimeOut:1e3,alwaysShowText:!1});var V=r(4094),K=r(38569),Q=r(26680),J=function(t,e){var r=t.alwaysShow,n=t.ifOverflow;return r&&(n="extendDomain"),n===e},tt=r(25311),te=r(1175);function tr(){return(tr=Object.assign?Object.assign.bind():function(t){for(var e=1;et.length)&&(e=t.length);for(var r=0,n=Array(e);rt.length)&&(e=t.length);for(var r=0,n=Array(e);r=0)continue;r[n]=t[n]}return r}(t,e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(n=0;n=0)&&Object.prototype.propertyIsEnumerable.call(t,r)&&(o[r]=t[r])}return o}(t,t2));return(0,_.hj)(r)&&(0,_.hj)(o)&&(0,_.hj)(f)&&(0,_.hj)(h)&&(0,_.hj)(u)&&(0,_.hj)(l)?i.createElement("path",t5({},(0,E.L6)(y,!0),{className:(0,b.Z)("recharts-cross",d),d:"M".concat(r,",").concat(u,"v").concat(h,"M").concat(l,",").concat(o,"h").concat(f)})):null};function t7(t){var e=t.cx,r=t.cy,n=t.radius,o=t.startAngle,i=t.endAngle;return{points:[(0,tq.op)(e,r,n,o),(0,tq.op)(e,r,n,i)],cx:e,cy:r,radius:n,startAngle:o,endAngle:i}}var t4=r(60474);function t8(t){return(t8="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function t9(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),r.push.apply(r,n)}return r}function et(t){for(var e=1;e=0)continue;r[n]=t[n]}return r}(t,e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(n=0;n=0)&&Object.prototype.propertyIsEnumerable.call(t,r)&&(o[r]=t[r])}return o}function ec(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(t){}return(ec=function(){return!!t})()}function el(t){return(el=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function es(t,e){return(es=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t})(t,e)}function ef(t){return function(t){if(Array.isArray(t))return eh(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||ep(t)||function(){throw TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function ep(t,e){if(t){if("string"==typeof t)return eh(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);if("Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r)return Array.from(t);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return eh(t,e)}}function eh(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r0?i:t&&t.length&&(0,_.hj)(n)&&(0,_.hj)(o)?t.slice(n,o+1):[]};function eS(t){return"number"===t?[0,"auto"]:void 0}var eP=function(t,e,r,n){var o=t.graphicalItems,i=t.tooltipAxis,a=ej(e,t);return r<0||!o||!o.length||r>=a.length?null:o.reduce(function(o,u){var c,l,s=null!==(c=u.props.data)&&void 0!==c?c:e;if(s&&t.dataStartIndex+t.dataEndIndex!==0&&t.dataEndIndex-t.dataStartIndex>=r&&(s=s.slice(t.dataStartIndex,t.dataEndIndex+1)),i.dataKey&&!i.allowDuplicatedCategory){var f=void 0===s?a:s;l=(0,_.Ap)(f,i.dataKey,n)}else l=s&&s[r]||a[r];return l?[].concat(ef(o),[(0,M.Qo)(u,l)]):o},[])},eE=function(t,e,r,n){var o=n||{x:t.chartX,y:t.chartY},i="horizontal"===r?o.x:"vertical"===r?o.y:"centric"===r?o.angle:o.radius,a=t.orderedTooltipTicks,u=t.tooltipAxis,c=t.tooltipTicks,l=(0,M.VO)(i,a,c,u);if(l>=0&&c){var s=c[l]&&c[l].value,f=eP(t,e,l,s),p=eO(r,a,l,o);return{activeTooltipIndex:l,activeLabel:s,activePayload:f,activeCoordinate:p}}return null},ek=function(t,e){var r=e.axes,n=e.graphicalItems,o=e.axisType,i=e.axisIdKey,a=e.stackGroups,c=e.dataStartIndex,l=e.dataEndIndex,s=t.layout,p=t.children,h=t.stackOffset,d=(0,M.NA)(s,o);return r.reduce(function(e,r){var y=void 0!==r.type.defaultProps?ey(ey({},r.type.defaultProps),r.props):r.props,v=y.type,m=y.dataKey,b=y.allowDataOverflow,g=y.allowDuplicatedCategory,x=y.scale,w=y.ticks,O=y.includeHidden,j=y[i];if(e[j])return e;var S=ej(t.data,{graphicalItems:n.filter(function(t){var e;return(i in t.props?t.props[i]:null===(e=t.type.defaultProps)||void 0===e?void 0:e[i])===j}),dataStartIndex:c,dataEndIndex:l}),P=S.length;(function(t,e,r){if("number"===r&&!0===e&&Array.isArray(t)){var n=null==t?void 0:t[0],o=null==t?void 0:t[1];if(n&&o&&(0,_.hj)(n)&&(0,_.hj)(o))return!0}return!1})(y.domain,b,v)&&(A=(0,M.LG)(y.domain,null,b),d&&("number"===v||"auto"!==x)&&(C=(0,M.gF)(S,m,"category")));var E=eS(v);if(!A||0===A.length){var k,A,T,C,N,D=null!==(N=y.domain)&&void 0!==N?N:E;if(m){if(A=(0,M.gF)(S,m,v),"category"===v&&d){var I=(0,_.bv)(A);g&&I?(T=A,A=f()(0,P)):g||(A=(0,M.ko)(D,A,r).reduce(function(t,e){return t.indexOf(e)>=0?t:[].concat(ef(t),[e])},[]))}else if("category"===v)A=g?A.filter(function(t){return""!==t&&!u()(t)}):(0,M.ko)(D,A,r).reduce(function(t,e){return t.indexOf(e)>=0||""===e||u()(e)?t:[].concat(ef(t),[e])},[]);else if("number"===v){var L=(0,M.ZI)(S,n.filter(function(t){var e,r,n=i in t.props?t.props[i]:null===(e=t.type.defaultProps)||void 0===e?void 0:e[i],o="hide"in t.props?t.props.hide:null===(r=t.type.defaultProps)||void 0===r?void 0:r.hide;return n===j&&(O||!o)}),m,o,s);L&&(A=L)}d&&("number"===v||"auto"!==x)&&(C=(0,M.gF)(S,m,"category"))}else A=d?f()(0,P):a&&a[j]&&a[j].hasStack&&"number"===v?"expand"===h?[0,1]:(0,M.EB)(a[j].stackGroups,c,l):(0,M.s6)(S,n.filter(function(t){var e=i in t.props?t.props[i]:t.type.defaultProps[i],r="hide"in t.props?t.props.hide:t.type.defaultProps.hide;return e===j&&(O||!r)}),v,s,!0);"number"===v?(A=t$(p,A,j,o,w),D&&(A=(0,M.LG)(D,A,b))):"category"===v&&D&&A.every(function(t){return D.indexOf(t)>=0})&&(A=D)}return ey(ey({},e),{},ev({},j,ey(ey({},y),{},{axisType:o,domain:A,categoricalDomain:C,duplicateDomain:T,originalDomain:null!==(k=y.domain)&&void 0!==k?k:E,isCategorical:d,layout:s})))},{})},eA=function(t,e){var r=e.graphicalItems,n=e.Axis,o=e.axisType,i=e.axisIdKey,a=e.stackGroups,u=e.dataStartIndex,c=e.dataEndIndex,l=t.layout,s=t.children,p=ej(t.data,{graphicalItems:r,dataStartIndex:u,dataEndIndex:c}),d=p.length,y=(0,M.NA)(l,o),v=-1;return r.reduce(function(t,e){var m,b=(void 0!==e.type.defaultProps?ey(ey({},e.type.defaultProps),e.props):e.props)[i],g=eS("number");return t[b]?t:(v++,m=y?f()(0,d):a&&a[b]&&a[b].hasStack?t$(s,m=(0,M.EB)(a[b].stackGroups,u,c),b,o):t$(s,m=(0,M.LG)(g,(0,M.s6)(p,r.filter(function(t){var e,r,n=i in t.props?t.props[i]:null===(e=t.type.defaultProps)||void 0===e?void 0:e[i],o="hide"in t.props?t.props.hide:null===(r=t.type.defaultProps)||void 0===r?void 0:r.hide;return n===b&&!o}),"number",l),n.defaultProps.allowDataOverflow),b,o),ey(ey({},t),{},ev({},b,ey(ey({axisType:o},n.defaultProps),{},{hide:!0,orientation:h()(eb,"".concat(o,".").concat(v%2),null),domain:m,originalDomain:g,isCategorical:y,layout:l}))))},{})},eM=function(t,e){var r=e.axisType,n=void 0===r?"xAxis":r,o=e.AxisComp,i=e.graphicalItems,a=e.stackGroups,u=e.dataStartIndex,c=e.dataEndIndex,l=t.children,s="".concat(n,"Id"),f=(0,E.NN)(l,o),p={};return f&&f.length?p=ek(t,{axes:f,graphicalItems:i,axisType:n,axisIdKey:s,stackGroups:a,dataStartIndex:u,dataEndIndex:c}):i&&i.length&&(p=eA(t,{Axis:o,graphicalItems:i,axisType:n,axisIdKey:s,stackGroups:a,dataStartIndex:u,dataEndIndex:c})),p},e_=function(t){var e=(0,_.Kt)(t),r=(0,M.uY)(e,!1,!0);return{tooltipTicks:r,orderedTooltipTicks:y()(r,function(t){return t.coordinate}),tooltipAxis:e,tooltipAxisBandSize:(0,M.zT)(e,r)}},eT=function(t){var e=t.children,r=t.defaultShowTooltip,n=(0,E.sP)(e,G),o=0,i=0;return t.data&&0!==t.data.length&&(i=t.data.length-1),n&&n.props&&(n.props.startIndex>=0&&(o=n.props.startIndex),n.props.endIndex>=0&&(i=n.props.endIndex)),{chartX:0,chartY:0,dataStartIndex:o,dataEndIndex:i,activeTooltipIndex:-1,isTooltipActive:!!r}},eC=function(t){return"horizontal"===t?{numericAxisName:"yAxis",cateAxisName:"xAxis"}:"vertical"===t?{numericAxisName:"xAxis",cateAxisName:"yAxis"}:"centric"===t?{numericAxisName:"radiusAxis",cateAxisName:"angleAxis"}:{numericAxisName:"angleAxis",cateAxisName:"radiusAxis"}},eN=function(t,e){var r=t.props,n=t.graphicalItems,o=t.xAxisMap,i=void 0===o?{}:o,a=t.yAxisMap,u=void 0===a?{}:a,c=r.width,l=r.height,s=r.children,f=r.margin||{},p=(0,E.sP)(s,G),d=(0,E.sP)(s,j.D),y=Object.keys(u).reduce(function(t,e){var r=u[e],n=r.orientation;return r.mirror||r.hide?t:ey(ey({},t),{},ev({},n,t[n]+r.width))},{left:f.left||0,right:f.right||0}),v=Object.keys(i).reduce(function(t,e){var r=i[e],n=r.orientation;return r.mirror||r.hide?t:ey(ey({},t),{},ev({},n,h()(t,"".concat(n))+r.height))},{top:f.top||0,bottom:f.bottom||0}),m=ey(ey({},v),y),b=m.bottom;p&&(m.bottom+=p.props.height||G.defaultProps.height),d&&e&&(m=(0,M.By)(m,n,r,e));var g=c-m.left-m.right,x=l-m.top-m.bottom;return ey(ey({brushBottom:b},m),{},{width:Math.max(g,0),height:Math.max(x,0)})},eD=function(t){var e=t.chartName,r=t.GraphicalChild,n=t.defaultTooltipEventType,o=void 0===n?"axis":n,a=t.validateTooltipEventTypes,c=void 0===a?["axis"]:a,s=t.axisComponents,f=t.legendContent,p=t.formatAxisMap,d=t.defaultProps,y=function(t,e){var r=e.graphicalItems,n=e.stackGroups,o=e.offset,i=e.updateId,a=e.dataStartIndex,c=e.dataEndIndex,l=t.barSize,f=t.layout,p=t.barGap,h=t.barCategoryGap,d=t.maxBarSize,y=eC(f),v=y.numericAxisName,m=y.cateAxisName,b=!!r&&!!r.length&&r.some(function(t){var e=(0,E.Gf)(t&&t.type);return e&&e.indexOf("Bar")>=0}),x=[];return r.forEach(function(r,y){var w=ej(t.data,{graphicalItems:[r],dataStartIndex:a,dataEndIndex:c}),O=void 0!==r.type.defaultProps?ey(ey({},r.type.defaultProps),r.props):r.props,j=O.dataKey,S=O.maxBarSize,P=O["".concat(v,"Id")],k=O["".concat(m,"Id")],A=s.reduce(function(t,r){var n=e["".concat(r.axisType,"Map")],o=O["".concat(r.axisType,"Id")];n&&n[o]||"zAxis"===r.axisType||(0,g.Z)(!1);var i=n[o];return ey(ey({},t),{},ev(ev({},r.axisType,i),"".concat(r.axisType,"Ticks"),(0,M.uY)(i)))},{}),_=A[m],T=A["".concat(m,"Ticks")],C=n&&n[P]&&n[P].hasStack&&(0,M.O3)(r,n[P].stackGroups),N=(0,E.Gf)(r.type).indexOf("Bar")>=0,D=(0,M.zT)(_,T),I=[],L=b&&(0,M.pt)({barSize:l,stackGroups:n,totalSize:"xAxis"===m?A[m].width:"yAxis"===m?A[m].height:void 0});if(N){var B,R,z=u()(S)?d:S,U=null!==(B=null!==(R=(0,M.zT)(_,T,!0))&&void 0!==R?R:z)&&void 0!==B?B:0;I=(0,M.qz)({barGap:p,barCategoryGap:h,bandSize:U!==D?U:D,sizeList:L[k],maxBarSize:z}),U!==D&&(I=I.map(function(t){return ey(ey({},t),{},{position:ey(ey({},t.position),{},{offset:t.position.offset-U/2})})}))}var F=r&&r.type&&r.type.getComposedData;F&&x.push({props:ey(ey({},F(ey(ey({},A),{},{displayedData:w,props:t,dataKey:j,item:r,bandSize:D,barPosition:I,offset:o,stackedData:C,layout:f,dataStartIndex:a,dataEndIndex:c}))),{},ev(ev(ev({key:r.key||"item-".concat(y)},v,A[v]),m,A[m]),"animationId",i)),childIndex:(0,E.$R)(r,t.children),item:r})}),x},v=function(t,n){var o=t.props,i=t.dataStartIndex,a=t.dataEndIndex,u=t.updateId;if(!(0,E.TT)({props:o}))return null;var c=o.children,l=o.layout,f=o.stackOffset,h=o.data,d=o.reverseStackOrder,v=eC(l),m=v.numericAxisName,b=v.cateAxisName,g=(0,E.NN)(c,r),x=(0,M.wh)(h,g,"".concat(m,"Id"),"".concat(b,"Id"),f,d),w=s.reduce(function(t,e){var r="".concat(e.axisType,"Map");return ey(ey({},t),{},ev({},r,eM(o,ey(ey({},e),{},{graphicalItems:g,stackGroups:e.axisType===m&&x,dataStartIndex:i,dataEndIndex:a}))))},{}),O=eN(ey(ey({},w),{},{props:o,graphicalItems:g}),null==n?void 0:n.legendBBox);Object.keys(w).forEach(function(t){w[t]=p(o,w[t],O,t.replace("Map",""),e)});var j=e_(w["".concat(b,"Map")]),S=y(o,ey(ey({},w),{},{dataStartIndex:i,dataEndIndex:a,updateId:u,graphicalItems:g,stackGroups:x,offset:O}));return ey(ey({formattedGraphicalItems:S,graphicalItems:g,offset:O,stackGroups:x},j),w)},j=function(t){var r;function n(t){var r,o,a,c,s;return!function(t,e){if(!(t instanceof e))throw TypeError("Cannot call a class as a function")}(this,n),c=n,s=[t],c=el(c),ev(a=function(t,e){if(e&&("object"===eo(e)||"function"==typeof e))return e;if(void 0!==e)throw TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(this,ec()?Reflect.construct(c,s||[],el(this).constructor):c.apply(this,s)),"eventEmitterSymbol",Symbol("rechartsEventEmitter")),ev(a,"accessibilityManager",new tQ),ev(a,"handleLegendBBoxUpdate",function(t){if(t){var e=a.state,r=e.dataStartIndex,n=e.dataEndIndex,o=e.updateId;a.setState(ey({legendBBox:t},v({props:a.props,dataStartIndex:r,dataEndIndex:n,updateId:o},ey(ey({},a.state),{},{legendBBox:t}))))}}),ev(a,"handleReceiveSyncEvent",function(t,e,r){a.props.syncId===t&&(r!==a.eventEmitterSymbol||"function"==typeof a.props.syncMethod)&&a.applySyncEvent(e)}),ev(a,"handleBrushChange",function(t){var e=t.startIndex,r=t.endIndex;if(e!==a.state.dataStartIndex||r!==a.state.dataEndIndex){var n=a.state.updateId;a.setState(function(){return ey({dataStartIndex:e,dataEndIndex:r},v({props:a.props,dataStartIndex:e,dataEndIndex:r,updateId:n},a.state))}),a.triggerSyncEvent({dataStartIndex:e,dataEndIndex:r})}}),ev(a,"handleMouseEnter",function(t){var e=a.getMouseInfo(t);if(e){var r=ey(ey({},e),{},{isTooltipActive:!0});a.setState(r),a.triggerSyncEvent(r);var n=a.props.onMouseEnter;l()(n)&&n(r,t)}}),ev(a,"triggeredAfterMouseMove",function(t){var e=a.getMouseInfo(t),r=e?ey(ey({},e),{},{isTooltipActive:!0}):{isTooltipActive:!1};a.setState(r),a.triggerSyncEvent(r);var n=a.props.onMouseMove;l()(n)&&n(r,t)}),ev(a,"handleItemMouseEnter",function(t){a.setState(function(){return{isTooltipActive:!0,activeItem:t,activePayload:t.tooltipPayload,activeCoordinate:t.tooltipPosition||{x:t.cx,y:t.cy}}})}),ev(a,"handleItemMouseLeave",function(){a.setState(function(){return{isTooltipActive:!1}})}),ev(a,"handleMouseMove",function(t){t.persist(),a.throttleTriggeredAfterMouseMove(t)}),ev(a,"handleMouseLeave",function(t){a.throttleTriggeredAfterMouseMove.cancel();var e={isTooltipActive:!1};a.setState(e),a.triggerSyncEvent(e);var r=a.props.onMouseLeave;l()(r)&&r(e,t)}),ev(a,"handleOuterEvent",function(t){var e,r=(0,E.Bh)(t),n=h()(a.props,"".concat(r));r&&l()(n)&&n(null!==(e=/.*touch.*/i.test(r)?a.getMouseInfo(t.changedTouches[0]):a.getMouseInfo(t))&&void 0!==e?e:{},t)}),ev(a,"handleClick",function(t){var e=a.getMouseInfo(t);if(e){var r=ey(ey({},e),{},{isTooltipActive:!0});a.setState(r),a.triggerSyncEvent(r);var n=a.props.onClick;l()(n)&&n(r,t)}}),ev(a,"handleMouseDown",function(t){var e=a.props.onMouseDown;l()(e)&&e(a.getMouseInfo(t),t)}),ev(a,"handleMouseUp",function(t){var e=a.props.onMouseUp;l()(e)&&e(a.getMouseInfo(t),t)}),ev(a,"handleTouchMove",function(t){null!=t.changedTouches&&t.changedTouches.length>0&&a.throttleTriggeredAfterMouseMove(t.changedTouches[0])}),ev(a,"handleTouchStart",function(t){null!=t.changedTouches&&t.changedTouches.length>0&&a.handleMouseDown(t.changedTouches[0])}),ev(a,"handleTouchEnd",function(t){null!=t.changedTouches&&t.changedTouches.length>0&&a.handleMouseUp(t.changedTouches[0])}),ev(a,"handleDoubleClick",function(t){var e=a.props.onDoubleClick;l()(e)&&e(a.getMouseInfo(t),t)}),ev(a,"handleContextMenu",function(t){var e=a.props.onContextMenu;l()(e)&&e(a.getMouseInfo(t),t)}),ev(a,"triggerSyncEvent",function(t){void 0!==a.props.syncId&&tY.emit(tH,a.props.syncId,t,a.eventEmitterSymbol)}),ev(a,"applySyncEvent",function(t){var e=a.props,r=e.layout,n=e.syncMethod,o=a.state.updateId,i=t.dataStartIndex,u=t.dataEndIndex;if(void 0!==t.dataStartIndex||void 0!==t.dataEndIndex)a.setState(ey({dataStartIndex:i,dataEndIndex:u},v({props:a.props,dataStartIndex:i,dataEndIndex:u,updateId:o},a.state)));else if(void 0!==t.activeTooltipIndex){var c=t.chartX,l=t.chartY,s=t.activeTooltipIndex,f=a.state,p=f.offset,h=f.tooltipTicks;if(!p)return;if("function"==typeof n)s=n(h,t);else if("value"===n){s=-1;for(var d=0;d=0){if(s.dataKey&&!s.allowDuplicatedCategory){var A="function"==typeof s.dataKey?function(t){return"function"==typeof s.dataKey?s.dataKey(t.payload):null}:"payload.".concat(s.dataKey.toString());C=(0,_.Ap)(v,A,p),N=m&&b&&(0,_.Ap)(b,A,p)}else C=null==v?void 0:v[f],N=m&&b&&b[f];if(S||j){var T=void 0!==t.props.activeIndex?t.props.activeIndex:f;return[(0,i.cloneElement)(t,ey(ey(ey({},n.props),P),{},{activeIndex:T})),null,null]}if(!u()(C))return[k].concat(ef(a.renderActivePoints({item:n,activePoint:C,basePoint:N,childIndex:f,isRange:m})))}else{var C,N,D,I=(null!==(D=a.getItemByXY(a.state.activeCoordinate))&&void 0!==D?D:{graphicalItem:k}).graphicalItem,L=I.item,B=void 0===L?t:L,R=I.childIndex,z=ey(ey(ey({},n.props),P),{},{activeIndex:R});return[(0,i.cloneElement)(B,z),null,null]}}return m?[k,null,null]:[k,null]}),ev(a,"renderCustomized",function(t,e,r){return(0,i.cloneElement)(t,ey(ey({key:"recharts-customized-".concat(r)},a.props),a.state))}),ev(a,"renderMap",{CartesianGrid:{handler:ew,once:!0},ReferenceArea:{handler:a.renderReferenceElement},ReferenceLine:{handler:ew},ReferenceDot:{handler:a.renderReferenceElement},XAxis:{handler:ew},YAxis:{handler:ew},Brush:{handler:a.renderBrush,once:!0},Bar:{handler:a.renderGraphicChild},Line:{handler:a.renderGraphicChild},Area:{handler:a.renderGraphicChild},Radar:{handler:a.renderGraphicChild},RadialBar:{handler:a.renderGraphicChild},Scatter:{handler:a.renderGraphicChild},Pie:{handler:a.renderGraphicChild},Funnel:{handler:a.renderGraphicChild},Tooltip:{handler:a.renderCursor,once:!0},PolarGrid:{handler:a.renderPolarGrid,once:!0},PolarAngleAxis:{handler:a.renderPolarAxis},PolarRadiusAxis:{handler:a.renderPolarAxis},Customized:{handler:a.renderCustomized}}),a.clipPathId="".concat(null!==(r=t.id)&&void 0!==r?r:(0,_.EL)("recharts"),"-clip"),a.throttleTriggeredAfterMouseMove=m()(a.triggeredAfterMouseMove,null!==(o=t.throttleDelay)&&void 0!==o?o:1e3/60),a.state={},a}return!function(t,e){if("function"!=typeof e&&null!==e)throw TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&es(t,e)}(n,t),r=[{key:"componentDidMount",value:function(){var t,e;this.addListener(),this.accessibilityManager.setDetails({container:this.container,offset:{left:null!==(t=this.props.margin.left)&&void 0!==t?t:0,top:null!==(e=this.props.margin.top)&&void 0!==e?e:0},coordinateList:this.state.tooltipTicks,mouseHandlerCallback:this.triggeredAfterMouseMove,layout:this.props.layout}),this.displayDefaultTooltip()}},{key:"displayDefaultTooltip",value:function(){var t=this.props,e=t.children,r=t.data,n=t.height,o=t.layout,i=(0,E.sP)(e,O.u);if(i){var a=i.props.defaultIndex;if("number"==typeof a&&!(a<0)&&!(a>this.state.tooltipTicks.length-1)){var u=this.state.tooltipTicks[a]&&this.state.tooltipTicks[a].value,c=eP(this.state,r,a,u),l=this.state.tooltipTicks[a].coordinate,s=(this.state.offset.top+n)/2,f="horizontal"===o?{x:l,y:s}:{y:l,x:s},p=this.state.formattedGraphicalItems.find(function(t){return"Scatter"===t.item.type.name});p&&(f=ey(ey({},f),p.props.points[a].tooltipPosition),c=p.props.points[a].tooltipPayload);var h={activeTooltipIndex:a,isTooltipActive:!0,activeLabel:u,activePayload:c,activeCoordinate:f};this.setState(h),this.renderCursor(i),this.accessibilityManager.setIndex(a)}}}},{key:"getSnapshotBeforeUpdate",value:function(t,e){if(!this.props.accessibilityLayer)return null;if(this.state.tooltipTicks!==e.tooltipTicks&&this.accessibilityManager.setDetails({coordinateList:this.state.tooltipTicks}),this.props.layout!==t.layout&&this.accessibilityManager.setDetails({layout:this.props.layout}),this.props.margin!==t.margin){var r,n;this.accessibilityManager.setDetails({offset:{left:null!==(r=this.props.margin.left)&&void 0!==r?r:0,top:null!==(n=this.props.margin.top)&&void 0!==n?n:0}})}return null}},{key:"componentDidUpdate",value:function(t){(0,E.rL)([(0,E.sP)(t.children,O.u)],[(0,E.sP)(this.props.children,O.u)])||this.displayDefaultTooltip()}},{key:"componentWillUnmount",value:function(){this.removeListener(),this.throttleTriggeredAfterMouseMove.cancel()}},{key:"getTooltipEventType",value:function(){var t=(0,E.sP)(this.props.children,O.u);if(t&&"boolean"==typeof t.props.shared){var e=t.props.shared?"axis":"item";return c.indexOf(e)>=0?e:o}return o}},{key:"getMouseInfo",value:function(t){if(!this.container)return null;var e=this.container,r=e.getBoundingClientRect(),n=(0,V.os)(r),o={chartX:Math.round(t.pageX-n.left),chartY:Math.round(t.pageY-n.top)},i=r.width/e.offsetWidth||1,a=this.inRange(o.chartX,o.chartY,i);if(!a)return null;var u=this.state,c=u.xAxisMap,l=u.yAxisMap,s=this.getTooltipEventType(),f=eE(this.state,this.props.data,this.props.layout,a);if("axis"!==s&&c&&l){var p=(0,_.Kt)(c).scale,h=(0,_.Kt)(l).scale,d=p&&p.invert?p.invert(o.chartX):null,y=h&&h.invert?h.invert(o.chartY):null;return ey(ey({},o),{},{xValue:d,yValue:y},f)}return f?ey(ey({},o),f):null}},{key:"inRange",value:function(t,e){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,n=this.props.layout,o=t/r,i=e/r;if("horizontal"===n||"vertical"===n){var a=this.state.offset;return o>=a.left&&o<=a.left+a.width&&i>=a.top&&i<=a.top+a.height?{x:o,y:i}:null}var u=this.state,c=u.angleAxisMap,l=u.radiusAxisMap;if(c&&l){var s=(0,_.Kt)(c);return(0,tq.z3)({x:o,y:i},s)}return null}},{key:"parseEventsOfWrapper",value:function(){var t=this.props.children,e=this.getTooltipEventType(),r=(0,E.sP)(t,O.u),n={};return r&&"axis"===e&&(n="click"===r.props.trigger?{onClick:this.handleClick}:{onMouseEnter:this.handleMouseEnter,onDoubleClick:this.handleDoubleClick,onMouseMove:this.handleMouseMove,onMouseLeave:this.handleMouseLeave,onTouchMove:this.handleTouchMove,onTouchStart:this.handleTouchStart,onTouchEnd:this.handleTouchEnd,onContextMenu:this.handleContextMenu}),ey(ey({},(0,tX.Ym)(this.props,this.handleOuterEvent)),n)}},{key:"addListener",value:function(){tY.on(tH,this.handleReceiveSyncEvent)}},{key:"removeListener",value:function(){tY.removeListener(tH,this.handleReceiveSyncEvent)}},{key:"filterFormatItem",value:function(t,e,r){for(var n=this.state.formattedGraphicalItems,o=0,i=n.length;ot.length)&&(e=t.length);for(var r=0,n=Array(e);r=0?1:-1;"insideStart"===u?(o=b+S*l,a=w):"insideEnd"===u?(o=g-S*l,a=!w):"end"===u&&(o=g+S*l,a=w),a=j<=0?a:!a;var P=(0,d.op)(p,y,O,o),E=(0,d.op)(p,y,O,o+(a?1:-1)*359),k="M".concat(P.x,",").concat(P.y,"\n A").concat(O,",").concat(O,",0,1,").concat(a?0:1,",\n ").concat(E.x,",").concat(E.y),A=i()(t.id)?(0,h.EL)("recharts-radial-line-"):t.id;return n.createElement("text",x({},r,{dominantBaseline:"central",className:(0,s.Z)("recharts-radial-bar-label",f)}),n.createElement("defs",null,n.createElement("path",{id:A,d:k})),n.createElement("textPath",{xlinkHref:"#".concat(A)},e))},j=function(t){var e=t.viewBox,r=t.offset,n=t.position,o=e.cx,i=e.cy,a=e.innerRadius,u=e.outerRadius,c=(e.startAngle+e.endAngle)/2;if("outside"===n){var l=(0,d.op)(o,i,u+r,c),s=l.x;return{x:s,y:l.y,textAnchor:s>=o?"start":"end",verticalAnchor:"middle"}}if("center"===n)return{x:o,y:i,textAnchor:"middle",verticalAnchor:"middle"};if("centerTop"===n)return{x:o,y:i,textAnchor:"middle",verticalAnchor:"start"};if("centerBottom"===n)return{x:o,y:i,textAnchor:"middle",verticalAnchor:"end"};var f=(0,d.op)(o,i,(a+u)/2,c);return{x:f.x,y:f.y,textAnchor:"middle",verticalAnchor:"middle"}},S=function(t){var e=t.viewBox,r=t.parentViewBox,n=t.offset,o=t.position,i=e.x,a=e.y,u=e.width,c=e.height,s=c>=0?1:-1,f=s*n,p=s>0?"end":"start",d=s>0?"start":"end",y=u>=0?1:-1,v=y*n,m=y>0?"end":"start",b=y>0?"start":"end";if("top"===o)return g(g({},{x:i+u/2,y:a-s*n,textAnchor:"middle",verticalAnchor:p}),r?{height:Math.max(a-r.y,0),width:u}:{});if("bottom"===o)return g(g({},{x:i+u/2,y:a+c+f,textAnchor:"middle",verticalAnchor:d}),r?{height:Math.max(r.y+r.height-(a+c),0),width:u}:{});if("left"===o){var x={x:i-v,y:a+c/2,textAnchor:m,verticalAnchor:"middle"};return g(g({},x),r?{width:Math.max(x.x-r.x,0),height:c}:{})}if("right"===o){var w={x:i+u+v,y:a+c/2,textAnchor:b,verticalAnchor:"middle"};return g(g({},w),r?{width:Math.max(r.x+r.width-w.x,0),height:c}:{})}var O=r?{width:u,height:c}:{};return"insideLeft"===o?g({x:i+v,y:a+c/2,textAnchor:b,verticalAnchor:"middle"},O):"insideRight"===o?g({x:i+u-v,y:a+c/2,textAnchor:m,verticalAnchor:"middle"},O):"insideTop"===o?g({x:i+u/2,y:a+f,textAnchor:"middle",verticalAnchor:d},O):"insideBottom"===o?g({x:i+u/2,y:a+c-f,textAnchor:"middle",verticalAnchor:p},O):"insideTopLeft"===o?g({x:i+v,y:a+f,textAnchor:b,verticalAnchor:d},O):"insideTopRight"===o?g({x:i+u-v,y:a+f,textAnchor:m,verticalAnchor:d},O):"insideBottomLeft"===o?g({x:i+v,y:a+c-f,textAnchor:b,verticalAnchor:p},O):"insideBottomRight"===o?g({x:i+u-v,y:a+c-f,textAnchor:m,verticalAnchor:p},O):l()(o)&&((0,h.hj)(o.x)||(0,h.hU)(o.x))&&((0,h.hj)(o.y)||(0,h.hU)(o.y))?g({x:i+(0,h.h1)(o.x,u),y:a+(0,h.h1)(o.y,c),textAnchor:"end",verticalAnchor:"end"},O):g({x:i+u/2,y:a+c/2,textAnchor:"middle",verticalAnchor:"middle"},O)};function P(t){var e,r=t.offset,o=g({offset:void 0===r?5:r},function(t,e){if(null==t)return{};var r,n,o=function(t,e){if(null==t)return{};var r={};for(var n in t)if(Object.prototype.hasOwnProperty.call(t,n)){if(e.indexOf(n)>=0)continue;r[n]=t[n]}return r}(t,e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(n=0;n=0)&&Object.prototype.propertyIsEnumerable.call(t,r)&&(o[r]=t[r])}return o}(t,v)),a=o.viewBox,c=o.position,l=o.value,d=o.children,y=o.content,m=o.className,b=o.textBreakAll;if(!a||i()(l)&&i()(d)&&!(0,n.isValidElement)(y)&&!u()(y))return null;if((0,n.isValidElement)(y))return(0,n.cloneElement)(y,o);if(u()(y)){if(e=(0,n.createElement)(y,o),(0,n.isValidElement)(e))return e}else e=w(o);var P="cx"in a&&(0,h.hj)(a.cx),E=(0,p.L6)(o,!0);if(P&&("insideStart"===c||"insideEnd"===c||"end"===c))return O(o,e,E);var k=P?j(o):S(o);return n.createElement(f.x,x({className:(0,s.Z)("recharts-label",void 0===m?"":m)},E,k,{breakAll:b}),e)}P.displayName="Label";var E=function(t){var e=t.cx,r=t.cy,n=t.angle,o=t.startAngle,i=t.endAngle,a=t.r,u=t.radius,c=t.innerRadius,l=t.outerRadius,s=t.x,f=t.y,p=t.top,d=t.left,y=t.width,v=t.height,m=t.clockWise,b=t.labelViewBox;if(b)return b;if((0,h.hj)(y)&&(0,h.hj)(v)){if((0,h.hj)(s)&&(0,h.hj)(f))return{x:s,y:f,width:y,height:v};if((0,h.hj)(p)&&(0,h.hj)(d))return{x:p,y:d,width:y,height:v}}return(0,h.hj)(s)&&(0,h.hj)(f)?{x:s,y:f,width:0,height:0}:(0,h.hj)(e)&&(0,h.hj)(r)?{cx:e,cy:r,startAngle:o||n||0,endAngle:i||n||0,innerRadius:c||0,outerRadius:l||u||a||0,clockWise:m}:t.viewBox?t.viewBox:{}};P.parseViewBox=E,P.renderCallByParent=function(t,e){var r,o,i=!(arguments.length>2)||void 0===arguments[2]||arguments[2];if(!t||!t.children&&i&&!t.label)return null;var a=t.children,c=E(t),s=(0,p.NN)(a,P).map(function(t,r){return(0,n.cloneElement)(t,{viewBox:e||c,key:"label-".concat(r)})});return i?[(r=t.label,o=e||c,r?!0===r?n.createElement(P,{key:"label-implicit",viewBox:o}):(0,h.P2)(r)?n.createElement(P,{key:"label-implicit",viewBox:o,value:r}):(0,n.isValidElement)(r)?r.type===P?(0,n.cloneElement)(r,{key:"label-implicit",viewBox:o}):n.createElement(P,{key:"label-implicit",content:r,viewBox:o}):u()(r)?n.createElement(P,{key:"label-implicit",content:r,viewBox:o}):l()(r)?n.createElement(P,x({viewBox:o},r,{key:"label-implicit"})):null:null)].concat(function(t){if(Array.isArray(t))return m(t)}(s)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(s)||function(t,e){if(t){if("string"==typeof t)return m(t,void 0);var r=Object.prototype.toString.call(t).slice(8,-1);if("Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r)return Array.from(t);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return m(t,void 0)}}(s)||function(){throw TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()):s}},58772:function(t,e,r){"use strict";r.d(e,{e:function(){return P}});var n=r(2265),o=r(77571),i=r.n(o),a=r(28302),u=r.n(a),c=r(86757),l=r.n(c),s=r(86185),f=r.n(s),p=r(26680),h=r(9841),d=r(82944),y=r(85355);function v(t){return(v="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}var m=["valueAccessor"],b=["data","dataKey","clockWise","id","textBreakAll"];function g(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r=0)continue;r[n]=t[n]}return r}(t,e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(n=0;n=0)&&Object.prototype.propertyIsEnumerable.call(t,r)&&(o[r]=t[r])}return o}var S=function(t){return Array.isArray(t.value)?f()(t.value):t.value};function P(t){var e=t.valueAccessor,r=void 0===e?S:e,o=j(t,m),a=o.data,u=o.dataKey,c=o.clockWise,l=o.id,s=o.textBreakAll,f=j(o,b);return a&&a.length?n.createElement(h.m,{className:"recharts-label-list"},a.map(function(t,e){var o=i()(u)?r(t,e):(0,y.F$)(t&&t.payload,u),a=i()(l)?{}:{id:"".concat(l,"-").concat(e)};return n.createElement(p._,x({},(0,d.L6)(t,!0),f,a,{parentViewBox:t.parentViewBox,value:o,textBreakAll:s,viewBox:p._.parseViewBox(i()(c)?t:O(O({},t),{},{clockWise:c})),key:"label-".concat(e),index:e}))})):null}P.displayName="LabelList",P.renderCallByParent=function(t,e){var r,o=!(arguments.length>2)||void 0===arguments[2]||arguments[2];if(!t||!t.children&&o&&!t.label)return null;var i=t.children,a=(0,d.NN)(i,P).map(function(t,r){return(0,n.cloneElement)(t,{data:e,key:"labelList-".concat(r)})});return o?[(r=t.label)?!0===r?n.createElement(P,{key:"labelList-implicit",data:e}):n.isValidElement(r)||l()(r)?n.createElement(P,{key:"labelList-implicit",data:e,content:r}):u()(r)?n.createElement(P,x({data:e},r,{key:"labelList-implicit"})):null:null].concat(function(t){if(Array.isArray(t))return g(t)}(a)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(a)||function(t,e){if(t){if("string"==typeof t)return g(t,void 0);var r=Object.prototype.toString.call(t).slice(8,-1);if("Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r)return Array.from(t);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return g(t,void 0)}}(a)||function(){throw TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()):a}},22190:function(t,e,r){"use strict";r.d(e,{D:function(){return N}});var n=r(2265),o=r(86757),i=r.n(o),a=r(61994),u=r(1175),c=r(48777),l=r(14870),s=r(41637);function f(t){return(f="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function p(){return(p=Object.assign?Object.assign.bind():function(t){for(var e=1;e');var x=e.inactive?h:e.color;return n.createElement("li",p({className:b,style:y,key:"legend-item-".concat(r)},(0,s.bw)(t.props,e,r)),n.createElement(c.T,{width:o,height:o,viewBox:d,style:v},t.renderIcon(e)),n.createElement("span",{className:"recharts-legend-item-text",style:{color:x}},l?l(g,e,r):g))})}},{key:"render",value:function(){var t=this.props,e=t.payload,r=t.layout,o=t.align;return e&&e.length?n.createElement("ul",{className:"recharts-default-legend",style:{padding:0,margin:0,textAlign:"horizontal"===r?o:"left"}},this.renderItems()):null}}],function(t,e){for(var r=0;r1||Math.abs(e.height-this.lastBoundingBox.height)>1)&&(this.lastBoundingBox.width=e.width,this.lastBoundingBox.height=e.height,t&&t(e)):(-1!==this.lastBoundingBox.width||-1!==this.lastBoundingBox.height)&&(this.lastBoundingBox.width=-1,this.lastBoundingBox.height=-1,t&&t(null))}},{key:"getBBoxSnapshot",value:function(){return this.lastBoundingBox.width>=0&&this.lastBoundingBox.height>=0?P({},this.lastBoundingBox):{width:0,height:0}}},{key:"getDefaultPosition",value:function(t){var e,r,n=this.props,o=n.layout,i=n.align,a=n.verticalAlign,u=n.margin,c=n.chartWidth,l=n.chartHeight;return t&&(void 0!==t.left&&null!==t.left||void 0!==t.right&&null!==t.right)||(e="center"===i&&"vertical"===o?{left:((c||0)-this.getBBoxSnapshot().width)/2}:"right"===i?{right:u&&u.right||0}:{left:u&&u.left||0}),t&&(void 0!==t.top&&null!==t.top||void 0!==t.bottom&&null!==t.bottom)||(r="middle"===a?{top:((l||0)-this.getBBoxSnapshot().height)/2}:"bottom"===a?{bottom:u&&u.bottom||0}:{top:u&&u.top||0}),P(P({},e),r)}},{key:"render",value:function(){var t=this,e=this.props,r=e.content,o=e.width,i=e.height,a=e.wrapperStyle,u=e.payloadUniqBy,c=e.payload,l=P(P({position:"absolute",width:o||"auto",height:i||"auto"},this.getDefaultPosition(a)),a);return n.createElement("div",{className:"recharts-legend-wrapper",style:l,ref:function(e){t.wrapperNode=e}},function(t,e){if(n.isValidElement(t))return n.cloneElement(t,e);if("function"==typeof t)return n.createElement(t,e);e.ref;var r=function(t,e){if(null==t)return{};var r,n,o=function(t,e){if(null==t)return{};var r={};for(var n in t)if(Object.prototype.hasOwnProperty.call(t,n)){if(e.indexOf(n)>=0)continue;r[n]=t[n]}return r}(t,e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(n=0;n=0)&&Object.prototype.propertyIsEnumerable.call(t,r)&&(o[r]=t[r])}return o}(e,j);return n.createElement(g,r)}(r,P(P({},this.props),{},{payload:(0,w.z)(c,u,C)})))}}],r=[{key:"getWithHeight",value:function(t,e){var r=P(P({},this.defaultProps),t.props).layout;return"vertical"===r&&(0,x.hj)(t.props.height)?{height:t.props.height}:"horizontal"===r?{width:t.props.width||e}:null}}],e&&E(o.prototype,e),r&&E(o,r),Object.defineProperty(o,"prototype",{writable:!1}),o}(n.PureComponent);_(N,"displayName","Legend"),_(N,"defaultProps",{iconSize:14,layout:"horizontal",align:"center",verticalAlign:"bottom"})},47625:function(t,e,r){"use strict";r.d(e,{h:function(){return d}});var n=r(61994),o=r(2265),i=r(37065),a=r.n(i),u=r(16630),c=r(1175),l=r(82944);function s(t){return(s="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function f(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),r.push.apply(r,n)}return r}function p(t){for(var e=1;et.length)&&(e=t.length);for(var r=0,n=Array(e);r0&&(t=a()(t,S,{trailing:!0,leading:!1}));var e=new ResizeObserver(t),r=M.current.getBoundingClientRect();return D(r.width,r.height),e.observe(M.current),function(){e.disconnect()}},[D,S]);var I=(0,o.useMemo)(function(){var t=C.containerWidth,e=C.containerHeight;if(t<0||e<0)return null;(0,c.Z)((0,u.hU)(y)||(0,u.hU)(m),"The width(%s) and height(%s) are both fixed numbers,\n maybe you don't need to use a ResponsiveContainer.",y,m),(0,c.Z)(!i||i>0,"The aspect(%s) must be greater than zero.",i);var r=(0,u.hU)(y)?t:y,n=(0,u.hU)(m)?e:m;i&&i>0&&(r?n=r/i:n&&(r=n*i),w&&n>w&&(n=w)),(0,c.Z)(r>0||n>0,"The width(%s) and height(%s) of chart should be greater than 0,\n please check the style of container, or the props width(%s) and height(%s),\n or add a minWidth(%s) or minHeight(%s) or use aspect(%s) to control the\n height and width.",r,n,y,m,g,x,i);var a=!Array.isArray(O)&&(0,l.Gf)(O.type).endsWith("Chart");return o.Children.map(O,function(t){return o.isValidElement(t)?(0,o.cloneElement)(t,p({width:r,height:n},a?{style:p({height:"100%",width:"100%",maxHeight:n,maxWidth:r},t.props.style)}:{})):t})},[i,O,m,w,x,g,C,y]);return o.createElement("div",{id:P?"".concat(P):void 0,className:(0,n.Z)("recharts-responsive-container",E),style:p(p({},void 0===A?{}:A),{},{width:y,height:m,minWidth:g,minHeight:x,maxHeight:w}),ref:M},I)})},58811:function(t,e,r){"use strict";r.d(e,{x:function(){return B}});var n=r(2265),o=r(77571),i=r.n(o),a=r(61994),u=r(16630),c=r(34067),l=r(82944),s=r(4094);function f(t){return(f="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function p(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,u=[],c=!0,l=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;c=!1}else for(;!(c=(n=i.call(r)).done)&&(u.push(n.value),u.length!==e);c=!0);}catch(t){l=!0,o=t}finally{try{if(!c&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(l)throw o}}return u}}(t,e)||function(t,e){if(t){if("string"==typeof t)return h(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);if("Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r)return Array.from(t);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return h(t,e)}}(t,e)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function h(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r=0)continue;r[n]=t[n]}return r}(t,e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(n=0;n=0)&&Object.prototype.propertyIsEnumerable.call(t,r)&&(o[r]=t[r])}return o}function M(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,u=[],c=!0,l=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;c=!1}else for(;!(c=(n=i.call(r)).done)&&(u.push(n.value),u.length!==e);c=!0);}catch(t){l=!0,o=t}finally{try{if(!c&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(l)throw o}}return u}}(t,e)||function(t,e){if(t){if("string"==typeof t)return _(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);if("Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r)return Array.from(t);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return _(t,e)}}(t,e)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function _(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r0&&void 0!==arguments[0]?arguments[0]:[];return t.reduce(function(t,e){var i=e.word,a=e.width,u=t[t.length-1];return u&&(null==n||o||u.width+a+ra||e.reduce(function(t,e){return t.width>e.width?t:e}).width>Number(n),e]},y=0,v=c.length-1,m=0;y<=v&&m<=c.length-1;){var b=Math.floor((y+v)/2),g=M(d(b-1),2),x=g[0],w=g[1],O=M(d(b),1)[0];if(x||O||(y=b+1),x&&O&&(v=b-1),!x&&O){i=w;break}m++}return i||h},D=function(t){return[{words:i()(t)?[]:t.toString().split(T)}]},I=function(t){var e=t.width,r=t.scaleToFit,n=t.children,o=t.style,i=t.breakAll,a=t.maxLines;if((e||r)&&!c.x.isSsr){var u=C({breakAll:i,children:n,style:o});return u?N({breakAll:i,children:n,maxLines:a,style:o},u.wordsWithComputedWidth,u.spaceWidth,e,r):D(n)}return D(n)},L="#808080",B=function(t){var e,r=t.x,o=void 0===r?0:r,i=t.y,c=void 0===i?0:i,s=t.lineHeight,f=void 0===s?"1em":s,p=t.capHeight,h=void 0===p?"0.71em":p,d=t.scaleToFit,y=void 0!==d&&d,v=t.textAnchor,m=t.verticalAnchor,b=t.fill,g=void 0===b?L:b,x=A(t,P),w=(0,n.useMemo)(function(){return I({breakAll:x.breakAll,children:x.children,maxLines:x.maxLines,scaleToFit:y,style:x.style,width:x.width})},[x.breakAll,x.children,x.maxLines,y,x.style,x.width]),O=x.dx,j=x.dy,M=x.angle,_=x.className,T=x.breakAll,C=A(x,E);if(!(0,u.P2)(o)||!(0,u.P2)(c))return null;var N=o+((0,u.hj)(O)?O:0),D=c+((0,u.hj)(j)?j:0);switch(void 0===m?"end":m){case"start":e=S("calc(".concat(h,")"));break;case"middle":e=S("calc(".concat((w.length-1)/2," * -").concat(f," + (").concat(h," / 2))"));break;default:e=S("calc(".concat(w.length-1," * -").concat(f,")"))}var B=[];if(y){var R=w[0].width,z=x.width;B.push("scale(".concat(((0,u.hj)(z)?z/R:1)/R,")"))}return M&&B.push("rotate(".concat(M,", ").concat(N,", ").concat(D,")")),B.length&&(C.transform=B.join(" ")),n.createElement("text",k({},(0,l.L6)(C,!0),{x:N,y:D,className:(0,a.Z)("recharts-text",_),textAnchor:void 0===v?"start":v,fill:g.includes("url")?L:g}),w.map(function(t,r){var o=t.words.join(T?"":" ");return n.createElement("tspan",{x:N,dy:0===r?e:f,key:"".concat(o,"-").concat(r)},o)}))}},8147:function(t,e,r){"use strict";r.d(e,{u:function(){return $}});var n=r(2265),o=r(34935),i=r.n(o),a=r(77571),u=r.n(a),c=r(61994),l=r(16630);function s(t){return(s="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function f(){return(f=Object.assign?Object.assign.bind():function(t){for(var e=1;et.length)&&(e=t.length);for(var r=0,n=Array(e);rc[n]+s?Math.max(f,c[n]):Math.max(p,c[n])}function O(t){return(O="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function j(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),r.push.apply(r,n)}return r}function S(t){for(var e=1;e1||Math.abs(t.height-this.state.lastBoundingBox.height)>1)&&this.setState({lastBoundingBox:{width:t.width,height:t.height}})}else(-1!==this.state.lastBoundingBox.width||-1!==this.state.lastBoundingBox.height)&&this.setState({lastBoundingBox:{width:-1,height:-1}})}},{key:"componentDidMount",value:function(){document.addEventListener("keydown",this.handleKeyDown),this.updateBBox()}},{key:"componentWillUnmount",value:function(){document.removeEventListener("keydown",this.handleKeyDown)}},{key:"componentDidUpdate",value:function(){var t,e;this.props.active&&this.updateBBox(),this.state.dismissed&&((null===(t=this.props.coordinate)||void 0===t?void 0:t.x)!==this.state.dismissedAtCoordinate.x||(null===(e=this.props.coordinate)||void 0===e?void 0:e.y)!==this.state.dismissedAtCoordinate.y)&&(this.state.dismissed=!1)}},{key:"render",value:function(){var t,e,r,o,i,a,u,s,f,p,h,d,y,v,m,O,j,P,E,k=this,A=this.props,M=A.active,_=A.allowEscapeViewBox,T=A.animationDuration,C=A.animationEasing,N=A.children,D=A.coordinate,I=A.hasPayload,L=A.isAnimationActive,B=A.offset,R=A.position,z=A.reverseDirection,U=A.useTranslate3d,F=A.viewBox,$=A.wrapperStyle,q=(d=(t={allowEscapeViewBox:_,coordinate:D,offsetTopLeft:B,position:R,reverseDirection:z,tooltipBox:this.state.lastBoundingBox,useTranslate3d:U,viewBox:F}).allowEscapeViewBox,y=t.coordinate,v=t.offsetTopLeft,m=t.position,O=t.reverseDirection,j=t.tooltipBox,P=t.useTranslate3d,E=t.viewBox,j.height>0&&j.width>0&&y?(r=(e={translateX:p=w({allowEscapeViewBox:d,coordinate:y,key:"x",offsetTopLeft:v,position:m,reverseDirection:O,tooltipDimension:j.width,viewBox:E,viewBoxDimension:E.width}),translateY:h=w({allowEscapeViewBox:d,coordinate:y,key:"y",offsetTopLeft:v,position:m,reverseDirection:O,tooltipDimension:j.height,viewBox:E,viewBoxDimension:E.height}),useTranslate3d:P}).translateX,o=e.translateY,f={transform:e.useTranslate3d?"translate3d(".concat(r,"px, ").concat(o,"px, 0)"):"translate(".concat(r,"px, ").concat(o,"px)")}):f=x,{cssProperties:f,cssClasses:(a=(i={translateX:p,translateY:h,coordinate:y}).coordinate,u=i.translateX,s=i.translateY,(0,c.Z)(g,b(b(b(b({},"".concat(g,"-right"),(0,l.hj)(u)&&a&&(0,l.hj)(a.x)&&u>=a.x),"".concat(g,"-left"),(0,l.hj)(u)&&a&&(0,l.hj)(a.x)&&u=a.y),"".concat(g,"-top"),(0,l.hj)(s)&&a&&(0,l.hj)(a.y)&&s0;return n.createElement(_,{allowEscapeViewBox:i,animationDuration:a,animationEasing:u,isAnimationActive:f,active:o,coordinate:l,hasPayload:O,offset:p,position:y,reverseDirection:m,useTranslate3d:b,viewBox:g,wrapperStyle:x},(t=I(I({},this.props),{},{payload:w}),n.isValidElement(c)?n.cloneElement(c,t):"function"==typeof c?n.createElement(c,t):n.createElement(v,t)))}}],function(t,e){for(var r=0;r=0)continue;r[n]=t[n]}return r}(t,e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(n=0;n=0)&&Object.prototype.propertyIsEnumerable.call(t,r)&&(o[r]=t[r])}return o}(t,a),s=(0,o.Z)("recharts-layer",c);return n.createElement("g",u({className:s},(0,i.L6)(l,!0),{ref:e}),r)})},48777:function(t,e,r){"use strict";r.d(e,{T:function(){return c}});var n=r(2265),o=r(61994),i=r(82944),a=["children","width","height","viewBox","className","style","title","desc"];function u(){return(u=Object.assign?Object.assign.bind():function(t){for(var e=1;e=0)continue;r[n]=t[n]}return r}(t,e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(n=0;n=0)&&Object.prototype.propertyIsEnumerable.call(t,r)&&(o[r]=t[r])}return o}(t,a),y=l||{width:r,height:c,x:0,y:0},v=(0,o.Z)("recharts-surface",s);return n.createElement("svg",u({},(0,i.L6)(d,!0,"svg"),{className:v,width:r,height:c,style:f,viewBox:"".concat(y.x," ").concat(y.y," ").concat(y.width," ").concat(y.height)}),n.createElement("title",null,p),n.createElement("desc",null,h),e)}},25739:function(t,e,r){"use strict";r.d(e,{br:function(){return g},CW:function(){return O},Mw:function(){return A},zn:function(){return k},sp:function(){return x},qD:function(){return E},d2:function(){return P},bH:function(){return w},Ud:function(){return S},Nf:function(){return j}});var n=r(2265),o=r(69398),i=r(84173),a=r.n(i),u=r(32242),c=r.n(u),l=r(50967),s=r.n(l)()(function(t){return{x:t.left,y:t.top,width:t.width,height:t.height}},function(t){return["l",t.left,"t",t.top,"w",t.width,"h",t.height].join("")}),f=r(16630),p=(0,n.createContext)(void 0),h=(0,n.createContext)(void 0),d=(0,n.createContext)(void 0),y=(0,n.createContext)({}),v=(0,n.createContext)(void 0),m=(0,n.createContext)(0),b=(0,n.createContext)(0),g=function(t){var e=t.state,r=e.xAxisMap,o=e.yAxisMap,i=e.offset,a=t.clipPathId,u=t.children,c=t.width,l=t.height,f=s(i);return n.createElement(p.Provider,{value:r},n.createElement(h.Provider,{value:o},n.createElement(y.Provider,{value:i},n.createElement(d.Provider,{value:f},n.createElement(v.Provider,{value:a},n.createElement(m.Provider,{value:l},n.createElement(b.Provider,{value:c},u)))))))},x=function(){return(0,n.useContext)(v)},w=function(t){var e=(0,n.useContext)(p);null!=e||(0,o.Z)(!1);var r=e[t];return null!=r||(0,o.Z)(!1),r},O=function(){var t=(0,n.useContext)(p);return(0,f.Kt)(t)},j=function(){var t=(0,n.useContext)(h);return a()(t,function(t){return c()(t.domain,Number.isFinite)})||(0,f.Kt)(t)},S=function(t){var e=(0,n.useContext)(h);null!=e||(0,o.Z)(!1);var r=e[t];return null!=r||(0,o.Z)(!1),r},P=function(){return(0,n.useContext)(d)},E=function(){return(0,n.useContext)(y)},k=function(){return(0,n.useContext)(b)},A=function(){return(0,n.useContext)(m)}},57165:function(t,e,r){"use strict";r.d(e,{H:function(){return H}});var n=r(2265);function o(){}function i(t,e,r){t._context.bezierCurveTo((2*t._x0+t._x1)/3,(2*t._y0+t._y1)/3,(t._x0+2*t._x1)/3,(t._y0+2*t._y1)/3,(t._x0+4*t._x1+e)/6,(t._y0+4*t._y1+r)/6)}function a(t){this._context=t}function u(t){this._context=t}function c(t){this._context=t}a.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._y0=this._y1=NaN,this._point=0},lineEnd:function(){switch(this._point){case 3:i(this,this._x1,this._y1);case 2:this._context.lineTo(this._x1,this._y1)}(this._line||0!==this._line&&1===this._point)&&this._context.closePath(),this._line=1-this._line},point:function(t,e){switch(t=+t,e=+e,this._point){case 0:this._point=1,this._line?this._context.lineTo(t,e):this._context.moveTo(t,e);break;case 1:this._point=2;break;case 2:this._point=3,this._context.lineTo((5*this._x0+this._x1)/6,(5*this._y0+this._y1)/6);default:i(this,t,e)}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=e}},u.prototype={areaStart:o,areaEnd:o,lineStart:function(){this._x0=this._x1=this._x2=this._x3=this._x4=this._y0=this._y1=this._y2=this._y3=this._y4=NaN,this._point=0},lineEnd:function(){switch(this._point){case 1:this._context.moveTo(this._x2,this._y2),this._context.closePath();break;case 2:this._context.moveTo((this._x2+2*this._x3)/3,(this._y2+2*this._y3)/3),this._context.lineTo((this._x3+2*this._x2)/3,(this._y3+2*this._y2)/3),this._context.closePath();break;case 3:this.point(this._x2,this._y2),this.point(this._x3,this._y3),this.point(this._x4,this._y4)}},point:function(t,e){switch(t=+t,e=+e,this._point){case 0:this._point=1,this._x2=t,this._y2=e;break;case 1:this._point=2,this._x3=t,this._y3=e;break;case 2:this._point=3,this._x4=t,this._y4=e,this._context.moveTo((this._x0+4*this._x1+t)/6,(this._y0+4*this._y1+e)/6);break;default:i(this,t,e)}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=e}},c.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._y0=this._y1=NaN,this._point=0},lineEnd:function(){(this._line||0!==this._line&&3===this._point)&&this._context.closePath(),this._line=1-this._line},point:function(t,e){switch(t=+t,e=+e,this._point){case 0:this._point=1;break;case 1:this._point=2;break;case 2:this._point=3;var r=(this._x0+4*this._x1+t)/6,n=(this._y0+4*this._y1+e)/6;this._line?this._context.lineTo(r,n):this._context.moveTo(r,n);break;case 3:this._point=4;default:i(this,t,e)}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=e}};class l{constructor(t,e){this._context=t,this._x=e}areaStart(){this._line=0}areaEnd(){this._line=NaN}lineStart(){this._point=0}lineEnd(){(this._line||0!==this._line&&1===this._point)&&this._context.closePath(),this._line=1-this._line}point(t,e){switch(t=+t,e=+e,this._point){case 0:this._point=1,this._line?this._context.lineTo(t,e):this._context.moveTo(t,e);break;case 1:this._point=2;default:this._x?this._context.bezierCurveTo(this._x0=(this._x0+t)/2,this._y0,this._x0,e,t,e):this._context.bezierCurveTo(this._x0,this._y0=(this._y0+e)/2,t,this._y0,t,e)}this._x0=t,this._y0=e}}function s(t){this._context=t}function f(t){this._context=t}function p(t){return new f(t)}function h(t,e,r){var n=t._x1-t._x0,o=e-t._x1,i=(t._y1-t._y0)/(n||o<0&&-0),a=(r-t._y1)/(o||n<0&&-0);return((i<0?-1:1)+(a<0?-1:1))*Math.min(Math.abs(i),Math.abs(a),.5*Math.abs((i*o+a*n)/(n+o)))||0}function d(t,e){var r=t._x1-t._x0;return r?(3*(t._y1-t._y0)/r-e)/2:e}function y(t,e,r){var n=t._x0,o=t._y0,i=t._x1,a=t._y1,u=(i-n)/3;t._context.bezierCurveTo(n+u,o+u*e,i-u,a-u*r,i,a)}function v(t){this._context=t}function m(t){this._context=new b(t)}function b(t){this._context=t}function g(t){this._context=t}function x(t){var e,r,n=t.length-1,o=Array(n),i=Array(n),a=Array(n);for(o[0]=0,i[0]=2,a[0]=t[0]+2*t[1],e=1;e=0;--e)o[e]=(a[e]-o[e+1])/i[e];for(e=0,i[n-1]=(t[n]+o[n-1])/2;e=0&&(this._t=1-this._t,this._line=1-this._line)},point:function(t,e){switch(t=+t,e=+e,this._point){case 0:this._point=1,this._line?this._context.lineTo(t,e):this._context.moveTo(t,e);break;case 1:this._point=2;default:if(this._t<=0)this._context.lineTo(this._x,e),this._context.lineTo(t,e);else{var r=this._x*(1-this._t)+t*this._t;this._context.lineTo(r,this._y),this._context.lineTo(r,e)}}this._x=t,this._y=e}};var O=r(22516),j=r(76115),S=r(67790);function P(t){return t[0]}function E(t){return t[1]}function k(t,e){var r=(0,j.Z)(!0),n=null,o=p,i=null,a=(0,S.d)(u);function u(u){var c,l,s,f=(u=(0,O.Z)(u)).length,p=!1;for(null==n&&(i=o(s=a())),c=0;c<=f;++c)!(c=f;--p)u.point(m[p],b[p]);u.lineEnd(),u.areaEnd()}}v&&(m[s]=+t(h,s,l),b[s]=+e(h,s,l),u.point(n?+n(h,s,l):m[s],r?+r(h,s,l):b[s]))}if(d)return u=null,d+""||null}function s(){return k().defined(o).curve(a).context(i)}return t="function"==typeof t?t:void 0===t?P:(0,j.Z)(+t),e="function"==typeof e?e:void 0===e?(0,j.Z)(0):(0,j.Z)(+e),r="function"==typeof r?r:void 0===r?E:(0,j.Z)(+r),l.x=function(e){return arguments.length?(t="function"==typeof e?e:(0,j.Z)(+e),n=null,l):t},l.x0=function(e){return arguments.length?(t="function"==typeof e?e:(0,j.Z)(+e),l):t},l.x1=function(t){return arguments.length?(n=null==t?null:"function"==typeof t?t:(0,j.Z)(+t),l):n},l.y=function(t){return arguments.length?(e="function"==typeof t?t:(0,j.Z)(+t),r=null,l):e},l.y0=function(t){return arguments.length?(e="function"==typeof t?t:(0,j.Z)(+t),l):e},l.y1=function(t){return arguments.length?(r=null==t?null:"function"==typeof t?t:(0,j.Z)(+t),l):r},l.lineX0=l.lineY0=function(){return s().x(t).y(e)},l.lineY1=function(){return s().x(t).y(r)},l.lineX1=function(){return s().x(n).y(e)},l.defined=function(t){return arguments.length?(o="function"==typeof t?t:(0,j.Z)(!!t),l):o},l.curve=function(t){return arguments.length?(a=t,null!=i&&(u=a(i)),l):a},l.context=function(t){return arguments.length?(null==t?i=u=null:u=a(i=t),l):i},l}var M=r(75551),_=r.n(M),T=r(86757),C=r.n(T),N=r(61994),D=r(41637),I=r(82944),L=r(16630);function B(t){return(B="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function R(){return(R=Object.assign?Object.assign.bind():function(t){for(var e=1;et.length)&&(e=t.length);for(var r=0,n=Array(e);r=0?1:-1,c=r>=0?1:-1,l=n>=0&&r>=0||n<0&&r<0?1:0;if(a>0&&o instanceof Array){for(var s=[0,0,0,0],f=0;f<4;f++)s[f]=o[f]>a?a:o[f];i="M".concat(t,",").concat(e+u*s[0]),s[0]>0&&(i+="A ".concat(s[0],",").concat(s[0],",0,0,").concat(l,",").concat(t+c*s[0],",").concat(e)),i+="L ".concat(t+r-c*s[1],",").concat(e),s[1]>0&&(i+="A ".concat(s[1],",").concat(s[1],",0,0,").concat(l,",\n ").concat(t+r,",").concat(e+u*s[1])),i+="L ".concat(t+r,",").concat(e+n-u*s[2]),s[2]>0&&(i+="A ".concat(s[2],",").concat(s[2],",0,0,").concat(l,",\n ").concat(t+r-c*s[2],",").concat(e+n)),i+="L ".concat(t+c*s[3],",").concat(e+n),s[3]>0&&(i+="A ".concat(s[3],",").concat(s[3],",0,0,").concat(l,",\n ").concat(t,",").concat(e+n-u*s[3])),i+="Z"}else if(a>0&&o===+o&&o>0){var p=Math.min(a,o);i="M ".concat(t,",").concat(e+u*p,"\n A ").concat(p,",").concat(p,",0,0,").concat(l,",").concat(t+c*p,",").concat(e,"\n L ").concat(t+r-c*p,",").concat(e,"\n A ").concat(p,",").concat(p,",0,0,").concat(l,",").concat(t+r,",").concat(e+u*p,"\n L ").concat(t+r,",").concat(e+n-u*p,"\n A ").concat(p,",").concat(p,",0,0,").concat(l,",").concat(t+r-c*p,",").concat(e+n,"\n L ").concat(t+c*p,",").concat(e+n,"\n A ").concat(p,",").concat(p,",0,0,").concat(l,",").concat(t,",").concat(e+n-u*p," Z")}else i="M ".concat(t,",").concat(e," h ").concat(r," v ").concat(n," h ").concat(-r," Z");return i},h=function(t,e){if(!t||!e)return!1;var r=t.x,n=t.y,o=e.x,i=e.y,a=e.width,u=e.height;return!!(Math.abs(a)>0&&Math.abs(u)>0)&&r>=Math.min(o,o+a)&&r<=Math.max(o,o+a)&&n>=Math.min(i,i+u)&&n<=Math.max(i,i+u)},d={x:0,y:0,width:0,height:0,radius:0,isAnimationActive:!1,isUpdateAnimationActive:!1,animationBegin:0,animationDuration:1500,animationEasing:"ease"},y=function(t){var e,r=f(f({},d),t),u=(0,n.useRef)(),s=function(t){if(Array.isArray(t))return t}(e=(0,n.useState)(-1))||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,u=[],c=!0,l=!1;try{for(i=(r=r.call(t)).next;!(c=(n=i.call(r)).done)&&(u.push(n.value),2!==u.length);c=!0);}catch(t){l=!0,o=t}finally{try{if(!c&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(l)throw o}}return u}}(e,2)||function(t,e){if(t){if("string"==typeof t)return l(t,2);var r=Object.prototype.toString.call(t).slice(8,-1);if("Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r)return Array.from(t);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return l(t,2)}}(e,2)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(),h=s[0],y=s[1];(0,n.useEffect)(function(){if(u.current&&u.current.getTotalLength)try{var t=u.current.getTotalLength();t&&y(t)}catch(t){}},[]);var v=r.x,m=r.y,b=r.width,g=r.height,x=r.radius,w=r.className,O=r.animationEasing,j=r.animationDuration,S=r.animationBegin,P=r.isAnimationActive,E=r.isUpdateAnimationActive;if(v!==+v||m!==+m||b!==+b||g!==+g||0===b||0===g)return null;var k=(0,o.Z)("recharts-rectangle",w);return E?n.createElement(i.ZP,{canBegin:h>0,from:{width:b,height:g,x:v,y:m},to:{width:b,height:g,x:v,y:m},duration:j,animationEasing:O,isActive:E},function(t){var e=t.width,o=t.height,l=t.x,s=t.y;return n.createElement(i.ZP,{canBegin:h>0,from:"0px ".concat(-1===h?1:h,"px"),to:"".concat(h,"px 0px"),attributeName:"strokeDasharray",begin:S,duration:j,isActive:P,easing:O},n.createElement("path",c({},(0,a.L6)(r,!0),{className:k,d:p(l,s,e,o,x),ref:u})))}):n.createElement("path",c({},(0,a.L6)(r,!0),{className:k,d:p(v,m,b,g,x)}))}},60474:function(t,e,r){"use strict";r.d(e,{L:function(){return v}});var n=r(2265),o=r(61994),i=r(82944),a=r(39206),u=r(16630);function c(t){return(c="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function l(){return(l=Object.assign?Object.assign.bind():function(t){for(var e=1;e180),",").concat(+(c>s),",\n ").concat(p.x,",").concat(p.y,"\n ");if(o>0){var d=(0,a.op)(r,n,o,c),y=(0,a.op)(r,n,o,s);h+="L ".concat(y.x,",").concat(y.y,"\n A ").concat(o,",").concat(o,",0,\n ").concat(+(Math.abs(l)>180),",").concat(+(c<=s),",\n ").concat(d.x,",").concat(d.y," Z")}else h+="L ".concat(r,",").concat(n," Z");return h},d=function(t){var e=t.cx,r=t.cy,n=t.innerRadius,o=t.outerRadius,i=t.cornerRadius,a=t.forceCornerRadius,c=t.cornerIsExternal,l=t.startAngle,s=t.endAngle,f=(0,u.uY)(s-l),d=p({cx:e,cy:r,radius:o,angle:l,sign:f,cornerRadius:i,cornerIsExternal:c}),y=d.circleTangency,v=d.lineTangency,m=d.theta,b=p({cx:e,cy:r,radius:o,angle:s,sign:-f,cornerRadius:i,cornerIsExternal:c}),g=b.circleTangency,x=b.lineTangency,w=b.theta,O=c?Math.abs(l-s):Math.abs(l-s)-m-w;if(O<0)return a?"M ".concat(v.x,",").concat(v.y,"\n a").concat(i,",").concat(i,",0,0,1,").concat(2*i,",0\n a").concat(i,",").concat(i,",0,0,1,").concat(-(2*i),",0\n "):h({cx:e,cy:r,innerRadius:n,outerRadius:o,startAngle:l,endAngle:s});var j="M ".concat(v.x,",").concat(v.y,"\n A").concat(i,",").concat(i,",0,0,").concat(+(f<0),",").concat(y.x,",").concat(y.y,"\n A").concat(o,",").concat(o,",0,").concat(+(O>180),",").concat(+(f<0),",").concat(g.x,",").concat(g.y,"\n A").concat(i,",").concat(i,",0,0,").concat(+(f<0),",").concat(x.x,",").concat(x.y,"\n ");if(n>0){var S=p({cx:e,cy:r,radius:n,angle:l,sign:f,isExternal:!0,cornerRadius:i,cornerIsExternal:c}),P=S.circleTangency,E=S.lineTangency,k=S.theta,A=p({cx:e,cy:r,radius:n,angle:s,sign:-f,isExternal:!0,cornerRadius:i,cornerIsExternal:c}),M=A.circleTangency,_=A.lineTangency,T=A.theta,C=c?Math.abs(l-s):Math.abs(l-s)-k-T;if(C<0&&0===i)return"".concat(j,"L").concat(e,",").concat(r,"Z");j+="L".concat(_.x,",").concat(_.y,"\n A").concat(i,",").concat(i,",0,0,").concat(+(f<0),",").concat(M.x,",").concat(M.y,"\n A").concat(n,",").concat(n,",0,").concat(+(C>180),",").concat(+(f>0),",").concat(P.x,",").concat(P.y,"\n A").concat(i,",").concat(i,",0,0,").concat(+(f<0),",").concat(E.x,",").concat(E.y,"Z")}else j+="L".concat(e,",").concat(r,"Z");return j},y={cx:0,cy:0,innerRadius:0,outerRadius:0,startAngle:0,endAngle:0,cornerRadius:0,forceCornerRadius:!1,cornerIsExternal:!1},v=function(t){var e,r=f(f({},y),t),a=r.cx,c=r.cy,s=r.innerRadius,p=r.outerRadius,v=r.cornerRadius,m=r.forceCornerRadius,b=r.cornerIsExternal,g=r.startAngle,x=r.endAngle,w=r.className;if(p0&&360>Math.abs(g-x)?d({cx:a,cy:c,innerRadius:s,outerRadius:p,cornerRadius:Math.min(S,j/2),forceCornerRadius:m,cornerIsExternal:b,startAngle:g,endAngle:x}):h({cx:a,cy:c,innerRadius:s,outerRadius:p,startAngle:g,endAngle:x}),n.createElement("path",l({},(0,i.L6)(r,!0),{className:O,d:e,role:"img"}))}},14870:function(t,e,r){"use strict";r.d(e,{v:function(){return N}});var n=r(2265),o=r(75551),i=r.n(o);let a=Math.cos,u=Math.sin,c=Math.sqrt,l=Math.PI,s=2*l;var f={draw(t,e){let r=c(e/l);t.moveTo(r,0),t.arc(0,0,r,0,s)}};let p=c(1/3),h=2*p,d=u(l/10)/u(7*l/10),y=u(s/10)*d,v=-a(s/10)*d,m=c(3),b=c(3)/2,g=1/c(12),x=(g/2+1)*3;var w=r(76115),O=r(67790);c(3),c(3);var j=r(61994),S=r(82944);function P(t){return(P="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}var E=["type","size","sizeType"];function k(){return(k=Object.assign?Object.assign.bind():function(t){for(var e=1;e=0)continue;r[n]=t[n]}return r}(t,e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(n=0;n=0)&&Object.prototype.propertyIsEnumerable.call(t,r)&&(o[r]=t[r])}return o}(t,E)),{},{type:o,size:u,sizeType:l}),p=s.className,h=s.cx,d=s.cy,y=(0,S.L6)(s,!0);return h===+h&&d===+d&&u===+u?n.createElement("path",k({},y,{className:(0,j.Z)("recharts-symbols",p),transform:"translate(".concat(h,", ").concat(d,")"),d:(e=_["symbol".concat(i()(o))]||f,(function(t,e){let r=null,n=(0,O.d)(o);function o(){let o;if(r||(r=o=n()),t.apply(this,arguments).draw(r,+e.apply(this,arguments)),o)return r=null,o+""||null}return t="function"==typeof t?t:(0,w.Z)(t||f),e="function"==typeof e?e:(0,w.Z)(void 0===e?64:+e),o.type=function(e){return arguments.length?(t="function"==typeof e?e:(0,w.Z)(e),o):t},o.size=function(t){return arguments.length?(e="function"==typeof t?t:(0,w.Z)(+t),o):e},o.context=function(t){return arguments.length?(r=null==t?null:t,o):r},o})().type(e).size(C(u,l,o))())})):null};N.registerSymbol=function(t,e){_["symbol".concat(i()(t))]=e}},11638:function(t,e,r){"use strict";r.d(e,{bn:function(){return C},a3:function(){return z},lT:function(){return N},V$:function(){return D},w7:function(){return I}});var n=r(2265),o=r(86757),i=r.n(o),a=r(90231),u=r.n(a),c=r(24342),l=r.n(c),s=r(21652),f=r.n(s),p=r(73649),h=r(61994),d=r(84735),y=r(82944);function v(t){return(v="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function m(){return(m=Object.assign?Object.assign.bind():function(t){for(var e=1;et.length)&&(e=t.length);for(var r=0,n=Array(e);r0,from:{upperWidth:0,lowerWidth:0,height:p,x:c,y:l},to:{upperWidth:s,lowerWidth:f,height:p,x:c,y:l},duration:j,animationEasing:g,isActive:P},function(t){var e=t.upperWidth,i=t.lowerWidth,u=t.height,c=t.x,l=t.y;return n.createElement(d.ZP,{canBegin:a>0,from:"0px ".concat(-1===a?1:a,"px"),to:"".concat(a,"px 0px"),attributeName:"strokeDasharray",begin:S,duration:j,easing:g},n.createElement("path",m({},(0,y.L6)(r,!0),{className:E,d:w(c,l,e,i,u),ref:o})))}):n.createElement("g",null,n.createElement("path",m({},(0,y.L6)(r,!0),{className:E,d:w(c,l,s,f,p)})))},S=r(60474),P=r(9841),E=r(14870),k=["option","shapeType","propTransformer","activeClassName","isActive"];function A(t){return(A="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function M(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),r.push.apply(r,n)}return r}function _(t){for(var e=1;e=0)continue;r[n]=t[n]}return r}(t,e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(n=0;n=0)&&Object.prototype.propertyIsEnumerable.call(t,r)&&(o[r]=t[r])}return o}(t,k);if((0,n.isValidElement)(r))e=(0,n.cloneElement)(r,_(_({},f),(0,n.isValidElement)(r)?r.props:r));else if(i()(r))e=r(f);else if(u()(r)&&!l()(r)){var p=(void 0===a?function(t,e){return _(_({},e),t)}:a)(r,f);e=n.createElement(T,{shapeType:o,elementProps:p})}else e=n.createElement(T,{shapeType:o,elementProps:f});return s?n.createElement(P.m,{className:void 0===c?"recharts-active-shape":c},e):e}function N(t,e){return null!=e&&"trapezoids"in t.props}function D(t,e){return null!=e&&"sectors"in t.props}function I(t,e){return null!=e&&"points"in t.props}function L(t,e){var r,n,o=t.x===(null==e||null===(r=e.labelViewBox)||void 0===r?void 0:r.x)||t.x===e.x,i=t.y===(null==e||null===(n=e.labelViewBox)||void 0===n?void 0:n.y)||t.y===e.y;return o&&i}function B(t,e){var r=t.endAngle===e.endAngle,n=t.startAngle===e.startAngle;return r&&n}function R(t,e){var r=t.x===e.x,n=t.y===e.y,o=t.z===e.z;return r&&n&&o}function z(t){var e,r,n,o=t.activeTooltipItem,i=t.graphicalItem,a=t.itemData,u=(N(i,o)?e="trapezoids":D(i,o)?e="sectors":I(i,o)&&(e="points"),e),c=N(i,o)?null===(r=o.tooltipPayload)||void 0===r||null===(r=r[0])||void 0===r||null===(r=r.payload)||void 0===r?void 0:r.payload:D(i,o)?null===(n=o.tooltipPayload)||void 0===n||null===(n=n[0])||void 0===n||null===(n=n.payload)||void 0===n?void 0:n.payload:I(i,o)?o.payload:{},l=a.filter(function(t,e){var r=f()(c,t),n=i.props[u].filter(function(t){var e;return(N(i,o)?e=L:D(i,o)?e=B:I(i,o)&&(e=R),e)(t,o)}),a=i.props[u].indexOf(n[n.length-1]);return r&&e===a});return a.indexOf(l[l.length-1])}},25311:function(t,e,r){"use strict";r.d(e,{Ky:function(){return w},O1:function(){return b},_b:function(){return g},t9:function(){return m},xE:function(){return O}});var n=r(41443),o=r.n(n),i=r(32242),a=r.n(i),u=r(85355),c=r(82944),l=r(16630),s=r(31699);function f(t){return(f="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function p(t,e){for(var r=0;r0&&(A=Math.min((t||0)-(M[e-1]||0),A))}),Number.isFinite(A)){var _=A/k,T="vertical"===g.layout?r.height:r.width;if("gap"===g.padding&&(c=_*T/2),"no-gap"===g.padding){var C=(0,l.h1)(t.barCategoryGap,_*T),N=_*T/2;c=N-C-(N-C)/T*C}}}s="xAxis"===n?[r.left+(j.left||0)+(c||0),r.left+r.width-(j.right||0)-(c||0)]:"yAxis"===n?"horizontal"===f?[r.top+r.height-(j.bottom||0),r.top+(j.top||0)]:[r.top+(j.top||0)+(c||0),r.top+r.height-(j.bottom||0)-(c||0)]:g.range,P&&(s=[s[1],s[0]]);var D=(0,u.Hq)(g,o,m),I=D.scale,L=D.realScaleType;I.domain(w).range(s),(0,u.zF)(I);var B=(0,u.g$)(I,d(d({},g),{},{realScaleType:L}));"xAxis"===n?(b="top"===x&&!S||"bottom"===x&&S,p=r.left,h=v[E]-b*g.height):"yAxis"===n&&(b="left"===x&&!S||"right"===x&&S,p=v[E]-b*g.width,h=r.top);var R=d(d(d({},g),B),{},{realScaleType:L,x:p,y:h,scale:I,width:"xAxis"===n?r.width:g.width,height:"yAxis"===n?r.height:g.height});return R.bandSize=(0,u.zT)(R,B),g.hide||"xAxis"!==n?g.hide||(v[E]+=(b?-1:1)*R.width):v[E]+=(b?-1:1)*R.height,d(d({},i),{},y({},a,R))},{})},b=function(t,e){var r=t.x,n=t.y,o=e.x,i=e.y;return{x:Math.min(r,o),y:Math.min(n,i),width:Math.abs(o-r),height:Math.abs(i-n)}},g=function(t){return b({x:t.x1,y:t.y1},{x:t.x2,y:t.y2})},x=function(){var t,e;function r(t){!function(t,e){if(!(t instanceof e))throw TypeError("Cannot call a class as a function")}(this,r),this.scale=t}return t=[{key:"domain",get:function(){return this.scale.domain}},{key:"range",get:function(){return this.scale.range}},{key:"rangeMin",get:function(){return this.range()[0]}},{key:"rangeMax",get:function(){return this.range()[1]}},{key:"bandwidth",get:function(){return this.scale.bandwidth}},{key:"apply",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=e.bandAware,n=e.position;if(void 0!==t){if(n)switch(n){case"start":default:return this.scale(t);case"middle":var o=this.bandwidth?this.bandwidth()/2:0;return this.scale(t)+o;case"end":var i=this.bandwidth?this.bandwidth():0;return this.scale(t)+i}if(r){var a=this.bandwidth?this.bandwidth()/2:0;return this.scale(t)+a}return this.scale(t)}}},{key:"isInRange",value:function(t){var e=this.range(),r=e[0],n=e[e.length-1];return r<=n?t>=r&&t<=n:t>=n&&t<=r}}],e=[{key:"create",value:function(t){return new r(t)}}],t&&p(r.prototype,t),e&&p(r,e),Object.defineProperty(r,"prototype",{writable:!1}),r}();y(x,"EPS",1e-4);var w=function(t){var e=Object.keys(t).reduce(function(e,r){return d(d({},e),{},y({},r,x.create(t[r])))},{});return d(d({},e),{},{apply:function(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=r.bandAware,i=r.position;return o()(t,function(t,r){return e[r].apply(t,{bandAware:n,position:i})})},isInRange:function(t){return a()(t,function(t,r){return e[r].isInRange(t)})}})},O=function(t){var e=t.width,r=t.height,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,o=(n%180+180)%180*Math.PI/180,i=Math.atan(r/e);return Math.abs(o>i&&otx(e,t()).base(e.base()),tj.o.apply(e,arguments),e}},scaleOrdinal:function(){return tX.Z},scalePoint:function(){return f.x},scalePow:function(){return tJ},scaleQuantile:function(){return function t(){var e,r=[],n=[],o=[];function i(){var t=0,e=Math.max(1,n.length);for(o=Array(e-1);++t=1)return+r(t[n-1],n-1,t);var n,o=(n-1)*e,i=Math.floor(o),a=+r(t[i],i,t);return a+(+r(t[i+1],i+1,t)-a)*(o-i)}}(r,t/e);return a}function a(t){return null==t||isNaN(t=+t)?e:n[P(o,t)]}return a.invertExtent=function(t){var e=n.indexOf(t);return e<0?[NaN,NaN]:[e>0?o[e-1]:r[0],e=o?[i[o-1],n]:[i[e-1],i[e]]},u.unknown=function(t){return arguments.length&&(e=t),u},u.thresholds=function(){return i.slice()},u.copy=function(){return t().domain([r,n]).range(a).unknown(e)},tj.o.apply(tI(u),arguments)}},scaleRadial:function(){return function t(){var e,r=tO(),n=[0,1],o=!1;function i(t){var n,i=Math.sign(n=r(t))*Math.sqrt(Math.abs(n));return isNaN(i)?e:o?Math.round(i):i}return i.invert=function(t){return r.invert(t1(t))},i.domain=function(t){return arguments.length?(r.domain(t),i):r.domain()},i.range=function(t){return arguments.length?(r.range((n=Array.from(t,td)).map(t1)),i):n.slice()},i.rangeRound=function(t){return i.range(t).round(!0)},i.round=function(t){return arguments.length?(o=!!t,i):o},i.clamp=function(t){return arguments.length?(r.clamp(t),i):r.clamp()},i.unknown=function(t){return arguments.length?(e=t,i):e},i.copy=function(){return t(r.domain(),n).round(o).clamp(r.clamp()).unknown(e)},tj.o.apply(i,arguments),tI(i)}},scaleSequential:function(){return function t(){var e=tI(rX()(tv));return e.copy=function(){return rG(e,t())},tj.O.apply(e,arguments)}},scaleSequentialLog:function(){return function t(){var e=tZ(rX()).domain([1,10]);return e.copy=function(){return rG(e,t()).base(e.base())},tj.O.apply(e,arguments)}},scaleSequentialPow:function(){return rV},scaleSequentialQuantile:function(){return function t(){var e=[],r=tv;function n(t){if(null!=t&&!isNaN(t=+t))return r((P(e,t,1)-1)/(e.length-1))}return n.domain=function(t){if(!arguments.length)return e.slice();for(let r of(e=[],t))null==r||isNaN(r=+r)||e.push(r);return e.sort(g),n},n.interpolator=function(t){return arguments.length?(r=t,n):r},n.range=function(){return e.map((t,n)=>r(n/(e.length-1)))},n.quantiles=function(t){return Array.from({length:t+1},(r,n)=>(function(t,e,r){if(!(!(n=(t=Float64Array.from(function*(t,e){if(void 0===e)for(let e of t)null!=e&&(e=+e)>=e&&(yield e);else{let r=-1;for(let n of t)null!=(n=e(n,++r,t))&&(n=+n)>=n&&(yield n)}}(t,void 0))).length)||isNaN(e=+e))){if(e<=0||n<2)return t5(t);if(e>=1)return t2(t);var n,o=(n-1)*e,i=Math.floor(o),a=t2((function t(e,r,n=0,o=1/0,i){if(r=Math.floor(r),n=Math.floor(Math.max(0,n)),o=Math.floor(Math.min(e.length-1,o)),!(n<=r&&r<=o))return e;for(i=void 0===i?t6:function(t=g){if(t===g)return t6;if("function"!=typeof t)throw TypeError("compare is not a function");return(e,r)=>{let n=t(e,r);return n||0===n?n:(0===t(r,r))-(0===t(e,e))}}(i);o>n;){if(o-n>600){let a=o-n+1,u=r-n+1,c=Math.log(a),l=.5*Math.exp(2*c/3),s=.5*Math.sqrt(c*l*(a-l)/a)*(u-a/2<0?-1:1),f=Math.max(n,Math.floor(r-u*l/a+s)),p=Math.min(o,Math.floor(r+(a-u)*l/a+s));t(e,r,f,p,i)}let a=e[r],u=n,c=o;for(t3(e,n,r),i(e[o],a)>0&&t3(e,n,o);ui(e[u],a);)++u;for(;i(e[c],a)>0;)--c}0===i(e[n],a)?t3(e,n,c):t3(e,++c,o),c<=r&&(n=c+1),r<=c&&(o=c-1)}return e})(t,i).subarray(0,i+1));return a+(t5(t.subarray(i+1))-a)*(o-i)}})(e,n/t))},n.copy=function(){return t(r).domain(e)},tj.O.apply(n,arguments)}},scaleSequentialSqrt:function(){return rK},scaleSequentialSymlog:function(){return function t(){var e=tH(rX());return e.copy=function(){return rG(e,t()).constant(e.constant())},tj.O.apply(e,arguments)}},scaleSqrt:function(){return t0},scaleSymlog:function(){return function t(){var e=tH(tw());return e.copy=function(){return tx(e,t()).constant(e.constant())},tj.o.apply(e,arguments)}},scaleThreshold:function(){return function t(){var e,r=[.5],n=[0,1],o=1;function i(t){return null!=t&&t<=t?n[P(r,t,0,o)]:e}return i.domain=function(t){return arguments.length?(o=Math.min((r=Array.from(t)).length,n.length-1),i):r.slice()},i.range=function(t){return arguments.length?(n=Array.from(t),o=Math.min(r.length,n.length-1),i):n.slice()},i.invertExtent=function(t){var e=n.indexOf(t);return[r[e-1],r[e]]},i.unknown=function(t){return arguments.length?(e=t,i):e},i.copy=function(){return t().domain(r).range(n).unknown(e)},tj.o.apply(i,arguments)}},scaleTime:function(){return rY},scaleUtc:function(){return rH},tickFormat:function(){return tD}});var f=r(55284);let p=Math.sqrt(50),h=Math.sqrt(10),d=Math.sqrt(2);function y(t,e,r){let n,o,i;let a=(e-t)/Math.max(0,r),u=Math.floor(Math.log10(a)),c=a/Math.pow(10,u),l=c>=p?10:c>=h?5:c>=d?2:1;return(u<0?(n=Math.round(t*(i=Math.pow(10,-u)/l)),o=Math.round(e*i),n/ie&&--o,i=-i):(n=Math.round(t/(i=Math.pow(10,u)*l)),o=Math.round(e/i),n*ie&&--o),o0))return[];if(t===e)return[t];let n=e=o))return[];let u=i-o+1,c=Array(u);if(n){if(a<0)for(let t=0;te?1:t>=e?0:NaN}function x(t,e){return null==t||null==e?NaN:et?1:e>=t?0:NaN}function w(t){let e,r,n;function o(t,n,o=0,i=t.length){if(o>>1;0>r(t[e],n)?o=e+1:i=e}while(og(t(e),r),n=(e,r)=>t(e)-r):(e=t===g||t===x?t:O,r=t,n=t),{left:o,center:function(t,e,r=0,i=t.length){let a=o(t,e,r,i-1);return a>r&&n(t[a-1],e)>-n(t[a],e)?a-1:a},right:function(t,n,o=0,i=t.length){if(o>>1;0>=r(t[e],n)?o=e+1:i=e}while(o>8&15|e>>4&240,e>>4&15|240&e,(15&e)<<4|15&e,1):8===r?Z(e>>24&255,e>>16&255,e>>8&255,(255&e)/255):4===r?Z(e>>12&15|e>>8&240,e>>8&15|e>>4&240,e>>4&15|240&e,((15&e)<<4|15&e)/255):null):(e=N.exec(t))?new Y(e[1],e[2],e[3],1):(e=D.exec(t))?new Y(255*e[1]/100,255*e[2]/100,255*e[3]/100,1):(e=I.exec(t))?Z(e[1],e[2],e[3],e[4]):(e=L.exec(t))?Z(255*e[1]/100,255*e[2]/100,255*e[3]/100,e[4]):(e=B.exec(t))?Q(e[1],e[2]/100,e[3]/100,1):(e=R.exec(t))?Q(e[1],e[2]/100,e[3]/100,e[4]):z.hasOwnProperty(t)?q(z[t]):"transparent"===t?new Y(NaN,NaN,NaN,0):null}function q(t){return new Y(t>>16&255,t>>8&255,255&t,1)}function Z(t,e,r,n){return n<=0&&(t=e=r=NaN),new Y(t,e,r,n)}function W(t,e,r,n){var o;return 1==arguments.length?((o=t)instanceof A||(o=$(o)),o)?new Y((o=o.rgb()).r,o.g,o.b,o.opacity):new Y:new Y(t,e,r,null==n?1:n)}function Y(t,e,r,n){this.r=+t,this.g=+e,this.b=+r,this.opacity=+n}function H(){return`#${K(this.r)}${K(this.g)}${K(this.b)}`}function X(){let t=G(this.opacity);return`${1===t?"rgb(":"rgba("}${V(this.r)}, ${V(this.g)}, ${V(this.b)}${1===t?")":`, ${t})`}`}function G(t){return isNaN(t)?1:Math.max(0,Math.min(1,t))}function V(t){return Math.max(0,Math.min(255,Math.round(t)||0))}function K(t){return((t=V(t))<16?"0":"")+t.toString(16)}function Q(t,e,r,n){return n<=0?t=e=r=NaN:r<=0||r>=1?t=e=NaN:e<=0&&(t=NaN),new tt(t,e,r,n)}function J(t){if(t instanceof tt)return new tt(t.h,t.s,t.l,t.opacity);if(t instanceof A||(t=$(t)),!t)return new tt;if(t instanceof tt)return t;var e=(t=t.rgb()).r/255,r=t.g/255,n=t.b/255,o=Math.min(e,r,n),i=Math.max(e,r,n),a=NaN,u=i-o,c=(i+o)/2;return u?(a=e===i?(r-n)/u+(r0&&c<1?0:a,new tt(a,u,c,t.opacity)}function tt(t,e,r,n){this.h=+t,this.s=+e,this.l=+r,this.opacity=+n}function te(t){return(t=(t||0)%360)<0?t+360:t}function tr(t){return Math.max(0,Math.min(1,t||0))}function tn(t,e,r){return(t<60?e+(r-e)*t/60:t<180?r:t<240?e+(r-e)*(240-t)/60:e)*255}function to(t,e,r,n,o){var i=t*t,a=i*t;return((1-3*t+3*i-a)*e+(4-6*i+3*a)*r+(1+3*t+3*i-3*a)*n+a*o)/6}E(A,$,{copy(t){return Object.assign(new this.constructor,this,t)},displayable(){return this.rgb().displayable()},hex:U,formatHex:U,formatHex8:function(){return this.rgb().formatHex8()},formatHsl:function(){return J(this).formatHsl()},formatRgb:F,toString:F}),E(Y,W,k(A,{brighter(t){return t=null==t?1.4285714285714286:Math.pow(1.4285714285714286,t),new Y(this.r*t,this.g*t,this.b*t,this.opacity)},darker(t){return t=null==t?.7:Math.pow(.7,t),new Y(this.r*t,this.g*t,this.b*t,this.opacity)},rgb(){return this},clamp(){return new Y(V(this.r),V(this.g),V(this.b),G(this.opacity))},displayable(){return -.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:H,formatHex:H,formatHex8:function(){return`#${K(this.r)}${K(this.g)}${K(this.b)}${K((isNaN(this.opacity)?1:this.opacity)*255)}`},formatRgb:X,toString:X})),E(tt,function(t,e,r,n){return 1==arguments.length?J(t):new tt(t,e,r,null==n?1:n)},k(A,{brighter(t){return t=null==t?1.4285714285714286:Math.pow(1.4285714285714286,t),new tt(this.h,this.s,this.l*t,this.opacity)},darker(t){return t=null==t?.7:Math.pow(.7,t),new tt(this.h,this.s,this.l*t,this.opacity)},rgb(){var t=this.h%360+(this.h<0)*360,e=isNaN(t)||isNaN(this.s)?0:this.s,r=this.l,n=r+(r<.5?r:1-r)*e,o=2*r-n;return new Y(tn(t>=240?t-240:t+120,o,n),tn(t,o,n),tn(t<120?t+240:t-120,o,n),this.opacity)},clamp(){return new tt(te(this.h),tr(this.s),tr(this.l),G(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){let t=G(this.opacity);return`${1===t?"hsl(":"hsla("}${te(this.h)}, ${100*tr(this.s)}%, ${100*tr(this.l)}%${1===t?")":`, ${t})`}`}}));var ti=t=>()=>t;function ta(t,e){var r=e-t;return r?function(e){return t+e*r}:ti(isNaN(t)?e:t)}var tu=function t(e){var r,n=1==(r=+(r=e))?ta:function(t,e){var n,o,i;return e-t?(n=t,o=e,n=Math.pow(n,i=r),o=Math.pow(o,i)-n,i=1/i,function(t){return Math.pow(n+t*o,i)}):ti(isNaN(t)?e:t)};function o(t,e){var r=n((t=W(t)).r,(e=W(e)).r),o=n(t.g,e.g),i=n(t.b,e.b),a=ta(t.opacity,e.opacity);return function(e){return t.r=r(e),t.g=o(e),t.b=i(e),t.opacity=a(e),t+""}}return o.gamma=t,o}(1);function tc(t){return function(e){var r,n,o=e.length,i=Array(o),a=Array(o),u=Array(o);for(r=0;r=1?(r=1,e-1):Math.floor(r*e),o=t[n],i=t[n+1],a=n>0?t[n-1]:2*o-i,u=nu&&(a=e.slice(u,a),l[c]?l[c]+=a:l[++c]=a),(o=o[0])===(i=i[0])?l[c]?l[c]+=i:l[++c]=i:(l[++c]=null,s.push({i:c,x:tl(o,i)})),u=tf.lastIndex;return ue&&(r=t,t=e,e=r),l=function(r){return Math.max(t,Math.min(e,r))}),n=c>2?tg:tb,o=i=null,f}function f(e){return null==e||isNaN(e=+e)?r:(o||(o=n(a.map(t),u,c)))(t(l(e)))}return f.invert=function(r){return l(e((i||(i=n(u,a.map(t),tl)))(r)))},f.domain=function(t){return arguments.length?(a=Array.from(t,td),s()):a.slice()},f.range=function(t){return arguments.length?(u=Array.from(t),s()):u.slice()},f.rangeRound=function(t){return u=Array.from(t),c=th,s()},f.clamp=function(t){return arguments.length?(l=!!t||tv,s()):l!==tv},f.interpolate=function(t){return arguments.length?(c=t,s()):c},f.unknown=function(t){return arguments.length?(r=t,f):r},function(r,n){return t=r,e=n,s()}}function tO(){return tw()(tv,tv)}var tj=r(89999),tS=/^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;function tP(t){var e;if(!(e=tS.exec(t)))throw Error("invalid format: "+t);return new tE({fill:e[1],align:e[2],sign:e[3],symbol:e[4],zero:e[5],width:e[6],comma:e[7],precision:e[8]&&e[8].slice(1),trim:e[9],type:e[10]})}function tE(t){this.fill=void 0===t.fill?" ":t.fill+"",this.align=void 0===t.align?">":t.align+"",this.sign=void 0===t.sign?"-":t.sign+"",this.symbol=void 0===t.symbol?"":t.symbol+"",this.zero=!!t.zero,this.width=void 0===t.width?void 0:+t.width,this.comma=!!t.comma,this.precision=void 0===t.precision?void 0:+t.precision,this.trim=!!t.trim,this.type=void 0===t.type?"":t.type+""}function tk(t,e){if((r=(t=e?t.toExponential(e-1):t.toExponential()).indexOf("e"))<0)return null;var r,n=t.slice(0,r);return[n.length>1?n[0]+n.slice(2):n,+t.slice(r+1)]}function tA(t){return(t=tk(Math.abs(t)))?t[1]:NaN}function tM(t,e){var r=tk(t,e);if(!r)return t+"";var n=r[0],o=r[1];return o<0?"0."+Array(-o).join("0")+n:n.length>o+1?n.slice(0,o+1)+"."+n.slice(o+1):n+Array(o-n.length+2).join("0")}tP.prototype=tE.prototype,tE.prototype.toString=function(){return this.fill+this.align+this.sign+this.symbol+(this.zero?"0":"")+(void 0===this.width?"":Math.max(1,0|this.width))+(this.comma?",":"")+(void 0===this.precision?"":"."+Math.max(0,0|this.precision))+(this.trim?"~":"")+this.type};var t_={"%":(t,e)=>(100*t).toFixed(e),b:t=>Math.round(t).toString(2),c:t=>t+"",d:function(t){return Math.abs(t=Math.round(t))>=1e21?t.toLocaleString("en").replace(/,/g,""):t.toString(10)},e:(t,e)=>t.toExponential(e),f:(t,e)=>t.toFixed(e),g:(t,e)=>t.toPrecision(e),o:t=>Math.round(t).toString(8),p:(t,e)=>tM(100*t,e),r:tM,s:function(t,e){var r=tk(t,e);if(!r)return t+"";var o=r[0],i=r[1],a=i-(n=3*Math.max(-8,Math.min(8,Math.floor(i/3))))+1,u=o.length;return a===u?o:a>u?o+Array(a-u+1).join("0"):a>0?o.slice(0,a)+"."+o.slice(a):"0."+Array(1-a).join("0")+tk(t,Math.max(0,e+a-1))[0]},X:t=>Math.round(t).toString(16).toUpperCase(),x:t=>Math.round(t).toString(16)};function tT(t){return t}var tC=Array.prototype.map,tN=["y","z","a","f","p","n","\xb5","m","","k","M","G","T","P","E","Z","Y"];function tD(t,e,r,n){var o,u,c=b(t,e,r);switch((n=tP(null==n?",f":n)).type){case"s":var l=Math.max(Math.abs(t),Math.abs(e));return null!=n.precision||isNaN(u=Math.max(0,3*Math.max(-8,Math.min(8,Math.floor(tA(l)/3)))-tA(Math.abs(c))))||(n.precision=u),a(n,l);case"":case"e":case"g":case"p":case"r":null!=n.precision||isNaN(u=Math.max(0,tA(Math.abs(Math.max(Math.abs(t),Math.abs(e)))-(o=Math.abs(o=c)))-tA(o))+1)||(n.precision=u-("e"===n.type));break;case"f":case"%":null!=n.precision||isNaN(u=Math.max(0,-tA(Math.abs(c))))||(n.precision=u-("%"===n.type)*2)}return i(n)}function tI(t){var e=t.domain;return t.ticks=function(t){var r=e();return v(r[0],r[r.length-1],null==t?10:t)},t.tickFormat=function(t,r){var n=e();return tD(n[0],n[n.length-1],null==t?10:t,r)},t.nice=function(r){null==r&&(r=10);var n,o,i=e(),a=0,u=i.length-1,c=i[a],l=i[u],s=10;for(l0;){if((o=m(c,l,r))===n)return i[a]=c,i[u]=l,e(i);if(o>0)c=Math.floor(c/o)*o,l=Math.ceil(l/o)*o;else if(o<0)c=Math.ceil(c*o)/o,l=Math.floor(l*o)/o;else break;n=o}return t},t}function tL(){var t=tO();return t.copy=function(){return tx(t,tL())},tj.o.apply(t,arguments),tI(t)}function tB(t,e){t=t.slice();var r,n=0,o=t.length-1,i=t[n],a=t[o];return a-t(-e,r)}function tZ(t){let e,r;let n=t(tR,tz),o=n.domain,a=10;function u(){var i,u;return e=(i=a)===Math.E?Math.log:10===i&&Math.log10||2===i&&Math.log2||(i=Math.log(i),t=>Math.log(t)/i),r=10===(u=a)?t$:u===Math.E?Math.exp:t=>Math.pow(u,t),o()[0]<0?(e=tq(e),r=tq(r),t(tU,tF)):t(tR,tz),n}return n.base=function(t){return arguments.length?(a=+t,u()):a},n.domain=function(t){return arguments.length?(o(t),u()):o()},n.ticks=t=>{let n,i;let u=o(),c=u[0],l=u[u.length-1],s=l0){for(;f<=p;++f)for(n=1;nl)break;d.push(i)}}else for(;f<=p;++f)for(n=a-1;n>=1;--n)if(!((i=f>0?n/r(-f):n*r(f))l)break;d.push(i)}2*d.length{if(null==t&&(t=10),null==o&&(o=10===a?"s":","),"function"!=typeof o&&(a%1||null!=(o=tP(o)).precision||(o.trim=!0),o=i(o)),t===1/0)return o;let u=Math.max(1,a*t/n.ticks().length);return t=>{let n=t/r(Math.round(e(t)));return n*ao(tB(o(),{floor:t=>r(Math.floor(e(t))),ceil:t=>r(Math.ceil(e(t)))})),n}function tW(t){return function(e){return Math.sign(e)*Math.log1p(Math.abs(e/t))}}function tY(t){return function(e){return Math.sign(e)*Math.expm1(Math.abs(e))*t}}function tH(t){var e=1,r=t(tW(1),tY(e));return r.constant=function(r){return arguments.length?t(tW(e=+r),tY(e)):e},tI(r)}i=(o=function(t){var e,r,o,i=void 0===t.grouping||void 0===t.thousands?tT:(e=tC.call(t.grouping,Number),r=t.thousands+"",function(t,n){for(var o=t.length,i=[],a=0,u=e[0],c=0;o>0&&u>0&&(c+u+1>n&&(u=Math.max(1,n-c)),i.push(t.substring(o-=u,o+u)),!((c+=u+1)>n));)u=e[a=(a+1)%e.length];return i.reverse().join(r)}),a=void 0===t.currency?"":t.currency[0]+"",u=void 0===t.currency?"":t.currency[1]+"",c=void 0===t.decimal?".":t.decimal+"",l=void 0===t.numerals?tT:(o=tC.call(t.numerals,String),function(t){return t.replace(/[0-9]/g,function(t){return o[+t]})}),s=void 0===t.percent?"%":t.percent+"",f=void 0===t.minus?"−":t.minus+"",p=void 0===t.nan?"NaN":t.nan+"";function h(t){var e=(t=tP(t)).fill,r=t.align,o=t.sign,h=t.symbol,d=t.zero,y=t.width,v=t.comma,m=t.precision,b=t.trim,g=t.type;"n"===g?(v=!0,g="g"):t_[g]||(void 0===m&&(m=12),b=!0,g="g"),(d||"0"===e&&"="===r)&&(d=!0,e="0",r="=");var x="$"===h?a:"#"===h&&/[boxX]/.test(g)?"0"+g.toLowerCase():"",w="$"===h?u:/[%p]/.test(g)?s:"",O=t_[g],j=/[defgprs%]/.test(g);function S(t){var a,u,s,h=x,S=w;if("c"===g)S=O(t)+S,t="";else{var P=(t=+t)<0||1/t<0;if(t=isNaN(t)?p:O(Math.abs(t),m),b&&(t=function(t){e:for(var e,r=t.length,n=1,o=-1;n0&&(o=0)}return o>0?t.slice(0,o)+t.slice(e+1):t}(t)),P&&0==+t&&"+"!==o&&(P=!1),h=(P?"("===o?o:f:"-"===o||"("===o?"":o)+h,S=("s"===g?tN[8+n/3]:"")+S+(P&&"("===o?")":""),j){for(a=-1,u=t.length;++a(s=t.charCodeAt(a))||s>57){S=(46===s?c+t.slice(a+1):t.slice(a))+S,t=t.slice(0,a);break}}}v&&!d&&(t=i(t,1/0));var E=h.length+t.length+S.length,k=E>1)+h+t+S+k.slice(E);break;default:t=k+h+t+S}return l(t)}return m=void 0===m?6:/[gprs]/.test(g)?Math.max(1,Math.min(21,m)):Math.max(0,Math.min(20,m)),S.toString=function(){return t+""},S}return{format:h,formatPrefix:function(t,e){var r=h(((t=tP(t)).type="f",t)),n=3*Math.max(-8,Math.min(8,Math.floor(tA(e)/3))),o=Math.pow(10,-n),i=tN[8+n/3];return function(t){return r(o*t)+i}}}}({thousands:",",grouping:[3],currency:["$",""]})).format,a=o.formatPrefix;var tX=r(36967);function tG(t){return function(e){return e<0?-Math.pow(-e,t):Math.pow(e,t)}}function tV(t){return t<0?-Math.sqrt(-t):Math.sqrt(t)}function tK(t){return t<0?-t*t:t*t}function tQ(t){var e=t(tv,tv),r=1;return e.exponent=function(e){return arguments.length?1==(r=+e)?t(tv,tv):.5===r?t(tV,tK):t(tG(r),tG(1/r)):r},tI(e)}function tJ(){var t=tQ(tw());return t.copy=function(){return tx(t,tJ()).exponent(t.exponent())},tj.o.apply(t,arguments),t}function t0(){return tJ.apply(null,arguments).exponent(.5)}function t1(t){return Math.sign(t)*t*t}function t2(t,e){let r;if(void 0===e)for(let e of t)null!=e&&(r=e)&&(r=e);else{let n=-1;for(let o of t)null!=(o=e(o,++n,t))&&(r=o)&&(r=o)}return r}function t5(t,e){let r;if(void 0===e)for(let e of t)null!=e&&(r>e||void 0===r&&e>=e)&&(r=e);else{let n=-1;for(let o of t)null!=(o=e(o,++n,t))&&(r>o||void 0===r&&o>=o)&&(r=o)}return r}function t6(t,e){return(null==t||!(t>=t))-(null==e||!(e>=e))||(te?1:0)}function t3(t,e,r){let n=t[e];t[e]=t[r],t[r]=n}let t7=new Date,t4=new Date;function t8(t,e,r,n){function o(e){return t(e=0==arguments.length?new Date:new Date(+e)),e}return o.floor=e=>(t(e=new Date(+e)),e),o.ceil=r=>(t(r=new Date(r-1)),e(r,1),t(r),r),o.round=t=>{let e=o(t),r=o.ceil(t);return t-e(e(t=new Date(+t),null==r?1:Math.floor(r)),t),o.range=(r,n,i)=>{let a;let u=[];if(r=o.ceil(r),i=null==i?1:Math.floor(i),!(r0))return u;do u.push(a=new Date(+r)),e(r,i),t(r);while(at8(e=>{if(e>=e)for(;t(e),!r(e);)e.setTime(e-1)},(t,n)=>{if(t>=t){if(n<0)for(;++n<=0;)for(;e(t,-1),!r(t););else for(;--n>=0;)for(;e(t,1),!r(t););}}),r&&(o.count=(e,n)=>(t7.setTime(+e),t4.setTime(+n),t(t7),t(t4),Math.floor(r(t7,t4))),o.every=t=>isFinite(t=Math.floor(t))&&t>0?t>1?o.filter(n?e=>n(e)%t==0:e=>o.count(0,e)%t==0):o:null),o}let t9=t8(()=>{},(t,e)=>{t.setTime(+t+e)},(t,e)=>e-t);t9.every=t=>isFinite(t=Math.floor(t))&&t>0?t>1?t8(e=>{e.setTime(Math.floor(e/t)*t)},(e,r)=>{e.setTime(+e+r*t)},(e,r)=>(r-e)/t):t9:null,t9.range;let et=t8(t=>{t.setTime(t-t.getMilliseconds())},(t,e)=>{t.setTime(+t+1e3*e)},(t,e)=>(e-t)/1e3,t=>t.getUTCSeconds());et.range;let ee=t8(t=>{t.setTime(t-t.getMilliseconds()-1e3*t.getSeconds())},(t,e)=>{t.setTime(+t+6e4*e)},(t,e)=>(e-t)/6e4,t=>t.getMinutes());ee.range;let er=t8(t=>{t.setUTCSeconds(0,0)},(t,e)=>{t.setTime(+t+6e4*e)},(t,e)=>(e-t)/6e4,t=>t.getUTCMinutes());er.range;let en=t8(t=>{t.setTime(t-t.getMilliseconds()-1e3*t.getSeconds()-6e4*t.getMinutes())},(t,e)=>{t.setTime(+t+36e5*e)},(t,e)=>(e-t)/36e5,t=>t.getHours());en.range;let eo=t8(t=>{t.setUTCMinutes(0,0,0)},(t,e)=>{t.setTime(+t+36e5*e)},(t,e)=>(e-t)/36e5,t=>t.getUTCHours());eo.range;let ei=t8(t=>t.setHours(0,0,0,0),(t,e)=>t.setDate(t.getDate()+e),(t,e)=>(e-t-(e.getTimezoneOffset()-t.getTimezoneOffset())*6e4)/864e5,t=>t.getDate()-1);ei.range;let ea=t8(t=>{t.setUTCHours(0,0,0,0)},(t,e)=>{t.setUTCDate(t.getUTCDate()+e)},(t,e)=>(e-t)/864e5,t=>t.getUTCDate()-1);ea.range;let eu=t8(t=>{t.setUTCHours(0,0,0,0)},(t,e)=>{t.setUTCDate(t.getUTCDate()+e)},(t,e)=>(e-t)/864e5,t=>Math.floor(t/864e5));function ec(t){return t8(e=>{e.setDate(e.getDate()-(e.getDay()+7-t)%7),e.setHours(0,0,0,0)},(t,e)=>{t.setDate(t.getDate()+7*e)},(t,e)=>(e-t-(e.getTimezoneOffset()-t.getTimezoneOffset())*6e4)/6048e5)}eu.range;let el=ec(0),es=ec(1),ef=ec(2),ep=ec(3),eh=ec(4),ed=ec(5),ey=ec(6);function ev(t){return t8(e=>{e.setUTCDate(e.getUTCDate()-(e.getUTCDay()+7-t)%7),e.setUTCHours(0,0,0,0)},(t,e)=>{t.setUTCDate(t.getUTCDate()+7*e)},(t,e)=>(e-t)/6048e5)}el.range,es.range,ef.range,ep.range,eh.range,ed.range,ey.range;let em=ev(0),eb=ev(1),eg=ev(2),ex=ev(3),ew=ev(4),eO=ev(5),ej=ev(6);em.range,eb.range,eg.range,ex.range,ew.range,eO.range,ej.range;let eS=t8(t=>{t.setDate(1),t.setHours(0,0,0,0)},(t,e)=>{t.setMonth(t.getMonth()+e)},(t,e)=>e.getMonth()-t.getMonth()+(e.getFullYear()-t.getFullYear())*12,t=>t.getMonth());eS.range;let eP=t8(t=>{t.setUTCDate(1),t.setUTCHours(0,0,0,0)},(t,e)=>{t.setUTCMonth(t.getUTCMonth()+e)},(t,e)=>e.getUTCMonth()-t.getUTCMonth()+(e.getUTCFullYear()-t.getUTCFullYear())*12,t=>t.getUTCMonth());eP.range;let eE=t8(t=>{t.setMonth(0,1),t.setHours(0,0,0,0)},(t,e)=>{t.setFullYear(t.getFullYear()+e)},(t,e)=>e.getFullYear()-t.getFullYear(),t=>t.getFullYear());eE.every=t=>isFinite(t=Math.floor(t))&&t>0?t8(e=>{e.setFullYear(Math.floor(e.getFullYear()/t)*t),e.setMonth(0,1),e.setHours(0,0,0,0)},(e,r)=>{e.setFullYear(e.getFullYear()+r*t)}):null,eE.range;let ek=t8(t=>{t.setUTCMonth(0,1),t.setUTCHours(0,0,0,0)},(t,e)=>{t.setUTCFullYear(t.getUTCFullYear()+e)},(t,e)=>e.getUTCFullYear()-t.getUTCFullYear(),t=>t.getUTCFullYear());function eA(t,e,r,n,o,i){let a=[[et,1,1e3],[et,5,5e3],[et,15,15e3],[et,30,3e4],[i,1,6e4],[i,5,3e5],[i,15,9e5],[i,30,18e5],[o,1,36e5],[o,3,108e5],[o,6,216e5],[o,12,432e5],[n,1,864e5],[n,2,1728e5],[r,1,6048e5],[e,1,2592e6],[e,3,7776e6],[t,1,31536e6]];function u(e,r,n){let o=Math.abs(r-e)/n,i=w(([,,t])=>t).right(a,o);if(i===a.length)return t.every(b(e/31536e6,r/31536e6,n));if(0===i)return t9.every(Math.max(b(e,r,n),1));let[u,c]=a[o/a[i-1][2]isFinite(t=Math.floor(t))&&t>0?t8(e=>{e.setUTCFullYear(Math.floor(e.getUTCFullYear()/t)*t),e.setUTCMonth(0,1),e.setUTCHours(0,0,0,0)},(e,r)=>{e.setUTCFullYear(e.getUTCFullYear()+r*t)}):null,ek.range;let[eM,e_]=eA(ek,eP,em,eu,eo,er),[eT,eC]=eA(eE,eS,el,ei,en,ee);function eN(t){if(0<=t.y&&t.y<100){var e=new Date(-1,t.m,t.d,t.H,t.M,t.S,t.L);return e.setFullYear(t.y),e}return new Date(t.y,t.m,t.d,t.H,t.M,t.S,t.L)}function eD(t){if(0<=t.y&&t.y<100){var e=new Date(Date.UTC(-1,t.m,t.d,t.H,t.M,t.S,t.L));return e.setUTCFullYear(t.y),e}return new Date(Date.UTC(t.y,t.m,t.d,t.H,t.M,t.S,t.L))}function eI(t,e,r){return{y:t,m:e,d:r,H:0,M:0,S:0,L:0}}var eL={"-":"",_:" ",0:"0"},eB=/^\s*\d+/,eR=/^%/,ez=/[\\^$*+?|[\]().{}]/g;function eU(t,e,r){var n=t<0?"-":"",o=(n?-t:t)+"",i=o.length;return n+(i[t.toLowerCase(),e]))}function eZ(t,e,r){var n=eB.exec(e.slice(r,r+1));return n?(t.w=+n[0],r+n[0].length):-1}function eW(t,e,r){var n=eB.exec(e.slice(r,r+1));return n?(t.u=+n[0],r+n[0].length):-1}function eY(t,e,r){var n=eB.exec(e.slice(r,r+2));return n?(t.U=+n[0],r+n[0].length):-1}function eH(t,e,r){var n=eB.exec(e.slice(r,r+2));return n?(t.V=+n[0],r+n[0].length):-1}function eX(t,e,r){var n=eB.exec(e.slice(r,r+2));return n?(t.W=+n[0],r+n[0].length):-1}function eG(t,e,r){var n=eB.exec(e.slice(r,r+4));return n?(t.y=+n[0],r+n[0].length):-1}function eV(t,e,r){var n=eB.exec(e.slice(r,r+2));return n?(t.y=+n[0]+(+n[0]>68?1900:2e3),r+n[0].length):-1}function eK(t,e,r){var n=/^(Z)|([+-]\d\d)(?::?(\d\d))?/.exec(e.slice(r,r+6));return n?(t.Z=n[1]?0:-(n[2]+(n[3]||"00")),r+n[0].length):-1}function eQ(t,e,r){var n=eB.exec(e.slice(r,r+1));return n?(t.q=3*n[0]-3,r+n[0].length):-1}function eJ(t,e,r){var n=eB.exec(e.slice(r,r+2));return n?(t.m=n[0]-1,r+n[0].length):-1}function e0(t,e,r){var n=eB.exec(e.slice(r,r+2));return n?(t.d=+n[0],r+n[0].length):-1}function e1(t,e,r){var n=eB.exec(e.slice(r,r+3));return n?(t.m=0,t.d=+n[0],r+n[0].length):-1}function e2(t,e,r){var n=eB.exec(e.slice(r,r+2));return n?(t.H=+n[0],r+n[0].length):-1}function e5(t,e,r){var n=eB.exec(e.slice(r,r+2));return n?(t.M=+n[0],r+n[0].length):-1}function e6(t,e,r){var n=eB.exec(e.slice(r,r+2));return n?(t.S=+n[0],r+n[0].length):-1}function e3(t,e,r){var n=eB.exec(e.slice(r,r+3));return n?(t.L=+n[0],r+n[0].length):-1}function e7(t,e,r){var n=eB.exec(e.slice(r,r+6));return n?(t.L=Math.floor(n[0]/1e3),r+n[0].length):-1}function e4(t,e,r){var n=eR.exec(e.slice(r,r+1));return n?r+n[0].length:-1}function e8(t,e,r){var n=eB.exec(e.slice(r));return n?(t.Q=+n[0],r+n[0].length):-1}function e9(t,e,r){var n=eB.exec(e.slice(r));return n?(t.s=+n[0],r+n[0].length):-1}function rt(t,e){return eU(t.getDate(),e,2)}function re(t,e){return eU(t.getHours(),e,2)}function rr(t,e){return eU(t.getHours()%12||12,e,2)}function rn(t,e){return eU(1+ei.count(eE(t),t),e,3)}function ro(t,e){return eU(t.getMilliseconds(),e,3)}function ri(t,e){return ro(t,e)+"000"}function ra(t,e){return eU(t.getMonth()+1,e,2)}function ru(t,e){return eU(t.getMinutes(),e,2)}function rc(t,e){return eU(t.getSeconds(),e,2)}function rl(t){var e=t.getDay();return 0===e?7:e}function rs(t,e){return eU(el.count(eE(t)-1,t),e,2)}function rf(t){var e=t.getDay();return e>=4||0===e?eh(t):eh.ceil(t)}function rp(t,e){return t=rf(t),eU(eh.count(eE(t),t)+(4===eE(t).getDay()),e,2)}function rh(t){return t.getDay()}function rd(t,e){return eU(es.count(eE(t)-1,t),e,2)}function ry(t,e){return eU(t.getFullYear()%100,e,2)}function rv(t,e){return eU((t=rf(t)).getFullYear()%100,e,2)}function rm(t,e){return eU(t.getFullYear()%1e4,e,4)}function rb(t,e){var r=t.getDay();return eU((t=r>=4||0===r?eh(t):eh.ceil(t)).getFullYear()%1e4,e,4)}function rg(t){var e=t.getTimezoneOffset();return(e>0?"-":(e*=-1,"+"))+eU(e/60|0,"0",2)+eU(e%60,"0",2)}function rx(t,e){return eU(t.getUTCDate(),e,2)}function rw(t,e){return eU(t.getUTCHours(),e,2)}function rO(t,e){return eU(t.getUTCHours()%12||12,e,2)}function rj(t,e){return eU(1+ea.count(ek(t),t),e,3)}function rS(t,e){return eU(t.getUTCMilliseconds(),e,3)}function rP(t,e){return rS(t,e)+"000"}function rE(t,e){return eU(t.getUTCMonth()+1,e,2)}function rk(t,e){return eU(t.getUTCMinutes(),e,2)}function rA(t,e){return eU(t.getUTCSeconds(),e,2)}function rM(t){var e=t.getUTCDay();return 0===e?7:e}function r_(t,e){return eU(em.count(ek(t)-1,t),e,2)}function rT(t){var e=t.getUTCDay();return e>=4||0===e?ew(t):ew.ceil(t)}function rC(t,e){return t=rT(t),eU(ew.count(ek(t),t)+(4===ek(t).getUTCDay()),e,2)}function rN(t){return t.getUTCDay()}function rD(t,e){return eU(eb.count(ek(t)-1,t),e,2)}function rI(t,e){return eU(t.getUTCFullYear()%100,e,2)}function rL(t,e){return eU((t=rT(t)).getUTCFullYear()%100,e,2)}function rB(t,e){return eU(t.getUTCFullYear()%1e4,e,4)}function rR(t,e){var r=t.getUTCDay();return eU((t=r>=4||0===r?ew(t):ew.ceil(t)).getUTCFullYear()%1e4,e,4)}function rz(){return"+0000"}function rU(){return"%"}function rF(t){return+t}function r$(t){return Math.floor(+t/1e3)}function rq(t){return new Date(t)}function rZ(t){return t instanceof Date?+t:+new Date(+t)}function rW(t,e,r,n,o,i,a,u,c,l){var s=tO(),f=s.invert,p=s.domain,h=l(".%L"),d=l(":%S"),y=l("%I:%M"),v=l("%I %p"),m=l("%a %d"),b=l("%b %d"),g=l("%B"),x=l("%Y");function w(t){return(c(t)1)for(var r,n,o,i=1,a=t[e[0]],u=a.length;i=12)]},q:function(t){return 1+~~(t.getMonth()/3)},Q:rF,s:r$,S:rc,u:rl,U:rs,V:rp,w:rh,W:rd,x:null,X:null,y:ry,Y:rm,Z:rg,"%":rU},x={a:function(t){return a[t.getUTCDay()]},A:function(t){return i[t.getUTCDay()]},b:function(t){return c[t.getUTCMonth()]},B:function(t){return u[t.getUTCMonth()]},c:null,d:rx,e:rx,f:rP,g:rL,G:rR,H:rw,I:rO,j:rj,L:rS,m:rE,M:rk,p:function(t){return o[+(t.getUTCHours()>=12)]},q:function(t){return 1+~~(t.getUTCMonth()/3)},Q:rF,s:r$,S:rA,u:rM,U:r_,V:rC,w:rN,W:rD,x:null,X:null,y:rI,Y:rB,Z:rz,"%":rU},w={a:function(t,e,r){var n=h.exec(e.slice(r));return n?(t.w=d.get(n[0].toLowerCase()),r+n[0].length):-1},A:function(t,e,r){var n=f.exec(e.slice(r));return n?(t.w=p.get(n[0].toLowerCase()),r+n[0].length):-1},b:function(t,e,r){var n=m.exec(e.slice(r));return n?(t.m=b.get(n[0].toLowerCase()),r+n[0].length):-1},B:function(t,e,r){var n=y.exec(e.slice(r));return n?(t.m=v.get(n[0].toLowerCase()),r+n[0].length):-1},c:function(t,r,n){return S(t,e,r,n)},d:e0,e:e0,f:e7,g:eV,G:eG,H:e2,I:e2,j:e1,L:e3,m:eJ,M:e5,p:function(t,e,r){var n=l.exec(e.slice(r));return n?(t.p=s.get(n[0].toLowerCase()),r+n[0].length):-1},q:eQ,Q:e8,s:e9,S:e6,u:eW,U:eY,V:eH,w:eZ,W:eX,x:function(t,e,n){return S(t,r,e,n)},X:function(t,e,r){return S(t,n,e,r)},y:eV,Y:eG,Z:eK,"%":e4};function O(t,e){return function(r){var n,o,i,a=[],u=-1,c=0,l=t.length;for(r instanceof Date||(r=new Date(+r));++u53)return null;"w"in i||(i.w=1),"Z"in i?(n=(o=(n=eD(eI(i.y,0,1))).getUTCDay())>4||0===o?eb.ceil(n):eb(n),n=ea.offset(n,(i.V-1)*7),i.y=n.getUTCFullYear(),i.m=n.getUTCMonth(),i.d=n.getUTCDate()+(i.w+6)%7):(n=(o=(n=eN(eI(i.y,0,1))).getDay())>4||0===o?es.ceil(n):es(n),n=ei.offset(n,(i.V-1)*7),i.y=n.getFullYear(),i.m=n.getMonth(),i.d=n.getDate()+(i.w+6)%7)}else("W"in i||"U"in i)&&("w"in i||(i.w="u"in i?i.u%7:"W"in i?1:0),o="Z"in i?eD(eI(i.y,0,1)).getUTCDay():eN(eI(i.y,0,1)).getDay(),i.m=0,i.d="W"in i?(i.w+6)%7+7*i.W-(o+5)%7:i.w+7*i.U-(o+6)%7);return"Z"in i?(i.H+=i.Z/100|0,i.M+=i.Z%100,eD(i)):eN(i)}}function S(t,e,r,n){for(var o,i,a=0,u=e.length,c=r.length;a=c)return -1;if(37===(o=e.charCodeAt(a++))){if(!(i=w[(o=e.charAt(a++))in eL?e.charAt(a++):o])||(n=i(t,r,n))<0)return -1}else if(o!=r.charCodeAt(n++))return -1}return n}return g.x=O(r,g),g.X=O(n,g),g.c=O(e,g),x.x=O(r,x),x.X=O(n,x),x.c=O(e,x),{format:function(t){var e=O(t+="",g);return e.toString=function(){return t},e},parse:function(t){var e=j(t+="",!1);return e.toString=function(){return t},e},utcFormat:function(t){var e=O(t+="",x);return e.toString=function(){return t},e},utcParse:function(t){var e=j(t+="",!0);return e.toString=function(){return t},e}}}({dateTime:"%x, %X",date:"%-m/%-d/%Y",time:"%-I:%M:%S %p",periods:["AM","PM"],days:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],shortDays:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],months:["January","February","March","April","May","June","July","August","September","October","November","December"],shortMonths:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"]})).format,u.parse,l=u.utcFormat,u.utcParse;var r2=r(22516),r5=r(76115);function r6(t){for(var e=t.length,r=Array(e);--e>=0;)r[e]=e;return r}function r3(t,e){return t[e]}function r7(t){let e=[];return e.key=t,e}var r4=r(95645),r8=r.n(r4),r9=r(99008),nt=r.n(r9),ne=r(77571),nr=r.n(ne),nn=r(86757),no=r.n(nn),ni=r(42715),na=r.n(ni),nu=r(13735),nc=r.n(nu),nl=r(11314),ns=r.n(nl),nf=r(82559),np=r.n(nf),nh=r(75551),nd=r.n(nh),ny=r(21652),nv=r.n(ny),nm=r(34935),nb=r.n(nm),ng=r(61134),nx=r.n(ng);function nw(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r=e?r.apply(void 0,o):t(e-a,nP(function(){for(var t=arguments.length,e=Array(t),n=0;nt.length)&&(e=t.length);for(var r=0,n=Array(e);rn&&(o=n,i=r),[o,i]}function nR(t,e,r){if(t.lte(0))return new(nx())(0);var n=nC.getDigitCount(t.toNumber()),o=new(nx())(10).pow(n),i=t.div(o),a=1!==n?.05:.1,u=new(nx())(Math.ceil(i.div(a).toNumber())).add(r).mul(a).mul(o);return e?u:new(nx())(Math.ceil(u))}function nz(t,e,r){var n=1,o=new(nx())(t);if(!o.isint()&&r){var i=Math.abs(t);i<1?(n=new(nx())(10).pow(nC.getDigitCount(t)-1),o=new(nx())(Math.floor(o.div(n).toNumber())).mul(n)):i>1&&(o=new(nx())(Math.floor(t)))}else 0===t?o=new(nx())(Math.floor((e-1)/2)):r||(o=new(nx())(Math.floor(t)));var a=Math.floor((e-1)/2);return nM(nA(function(t){return o.add(new(nx())(t-a).mul(n)).toNumber()}),nk)(0,e)}var nU=nT(function(t){var e=nD(t,2),r=e[0],n=e[1],o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:6,i=!(arguments.length>2)||void 0===arguments[2]||arguments[2],a=Math.max(o,2),u=nD(nB([r,n]),2),c=u[0],l=u[1];if(c===-1/0||l===1/0){var s=l===1/0?[c].concat(nN(nk(0,o-1).map(function(){return 1/0}))):[].concat(nN(nk(0,o-1).map(function(){return-1/0})),[l]);return r>n?n_(s):s}if(c===l)return nz(c,o,i);var f=function t(e,r,n,o){var i,a=arguments.length>4&&void 0!==arguments[4]?arguments[4]:0;if(!Number.isFinite((r-e)/(n-1)))return{step:new(nx())(0),tickMin:new(nx())(0),tickMax:new(nx())(0)};var u=nR(new(nx())(r).sub(e).div(n-1),o,a),c=Math.ceil((i=e<=0&&r>=0?new(nx())(0):(i=new(nx())(e).add(r).div(2)).sub(new(nx())(i).mod(u))).sub(e).div(u).toNumber()),l=Math.ceil(new(nx())(r).sub(i).div(u).toNumber()),s=c+l+1;return s>n?t(e,r,n,o,a+1):(s0?l+(n-s):l,c=r>0?c:c+(n-s)),{step:u,tickMin:i.sub(new(nx())(c).mul(u)),tickMax:i.add(new(nx())(l).mul(u))})}(c,l,a,i),p=f.step,h=f.tickMin,d=f.tickMax,y=nC.rangeStep(h,d.add(new(nx())(.1).mul(p)),p);return r>n?n_(y):y});nT(function(t){var e=nD(t,2),r=e[0],n=e[1],o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:6,i=!(arguments.length>2)||void 0===arguments[2]||arguments[2],a=Math.max(o,2),u=nD(nB([r,n]),2),c=u[0],l=u[1];if(c===-1/0||l===1/0)return[r,n];if(c===l)return nz(c,o,i);var s=nR(new(nx())(l).sub(c).div(a-1),i,0),f=nM(nA(function(t){return new(nx())(c).add(new(nx())(t).mul(s)).toNumber()}),nk)(0,a).filter(function(t){return t>=c&&t<=l});return r>n?n_(f):f});var nF=nT(function(t,e){var r=nD(t,2),n=r[0],o=r[1],i=!(arguments.length>2)||void 0===arguments[2]||arguments[2],a=nD(nB([n,o]),2),u=a[0],c=a[1];if(u===-1/0||c===1/0)return[n,o];if(u===c)return[u];var l=nR(new(nx())(c).sub(u).div(Math.max(e,2)-1),i,0),s=[].concat(nN(nC.rangeStep(new(nx())(u),new(nx())(c).sub(new(nx())(.99).mul(l)),l)),[c]);return n>o?n_(s):s}),n$=r(13137),nq=r(16630),nZ=r(82944),nW=r(38569);function nY(t){return(nY="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function nH(t){return function(t){if(Array.isArray(t))return nX(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,e){if(t){if("string"==typeof t)return nX(t,void 0);var r=Object.prototype.toString.call(t).slice(8,-1);if("Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r)return Array.from(t);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return nX(t,void 0)}}(t)||function(){throw TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function nX(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r1&&void 0!==arguments[1]?arguments[1]:[],n=arguments.length>2?arguments[2]:void 0,o=arguments.length>3?arguments[3]:void 0,i=-1,a=null!==(e=null==r?void 0:r.length)&&void 0!==e?e:0;if(a<=1)return 0;if(o&&"angleAxis"===o.axisType&&1e-6>=Math.abs(Math.abs(o.range[1]-o.range[0])-360))for(var u=o.range,c=0;c0?n[c-1].coordinate:n[a-1].coordinate,s=n[c].coordinate,f=c>=a-1?n[0].coordinate:n[c+1].coordinate,p=void 0;if((0,nq.uY)(s-l)!==(0,nq.uY)(f-s)){var h=[];if((0,nq.uY)(f-s)===(0,nq.uY)(u[1]-u[0])){p=f;var d=s+u[1]-u[0];h[0]=Math.min(d,(d+l)/2),h[1]=Math.max(d,(d+l)/2)}else{p=l;var y=f+u[1]-u[0];h[0]=Math.min(s,(y+s)/2),h[1]=Math.max(s,(y+s)/2)}var v=[Math.min(s,(p+s)/2),Math.max(s,(p+s)/2)];if(t>v[0]&&t<=v[1]||t>=h[0]&&t<=h[1]){i=n[c].index;break}}else{var m=Math.min(l,f),b=Math.max(l,f);if(t>(m+s)/2&&t<=(b+s)/2){i=n[c].index;break}}}else for(var g=0;g0&&g(r[g].coordinate+r[g-1].coordinate)/2&&t<=(r[g].coordinate+r[g+1].coordinate)/2||g===a-1&&t>(r[g].coordinate+r[g-1].coordinate)/2){i=r[g].index;break}return i},n1=function(t){var e,r,n=t.type.displayName,o=null!==(e=t.type)&&void 0!==e&&e.defaultProps?nV(nV({},t.type.defaultProps),t.props):t.props,i=o.stroke,a=o.fill;switch(n){case"Line":r=i;break;case"Area":case"Radar":r=i&&"none"!==i?i:a;break;default:r=a}return r},n2=function(t){var e=t.barSize,r=t.totalSize,n=t.stackGroups,o=void 0===n?{}:n;if(!o)return{};for(var i={},a=Object.keys(o),u=0,c=a.length;u=0});if(v&&v.length){var m=v[0].type.defaultProps,b=void 0!==m?nV(nV({},m),v[0].props):v[0].props,g=b.barSize,x=b[y];i[x]||(i[x]=[]);var w=nr()(g)?e:g;i[x].push({item:v[0],stackList:v.slice(1),barSize:nr()(w)?void 0:(0,nq.h1)(w,r,0)})}}return i},n5=function(t){var e,r=t.barGap,n=t.barCategoryGap,o=t.bandSize,i=t.sizeList,a=void 0===i?[]:i,u=t.maxBarSize,c=a.length;if(c<1)return null;var l=(0,nq.h1)(r,o,0,!0),s=[];if(a[0].barSize===+a[0].barSize){var f=!1,p=o/c,h=a.reduce(function(t,e){return t+e.barSize||0},0);(h+=(c-1)*l)>=o&&(h-=(c-1)*l,l=0),h>=o&&p>0&&(f=!0,p*=.9,h=c*p);var d={offset:((o-h)/2>>0)-l,size:0};e=a.reduce(function(t,e){var r={item:e.item,position:{offset:d.offset+d.size+l,size:f?p:e.barSize}},n=[].concat(nH(t),[r]);return d=n[n.length-1].position,e.stackList&&e.stackList.length&&e.stackList.forEach(function(t){n.push({item:t,position:d})}),n},s)}else{var y=(0,nq.h1)(n,o,0,!0);o-2*y-(c-1)*l<=0&&(l=0);var v=(o-2*y-(c-1)*l)/c;v>1&&(v>>=0);var m=u===+u?Math.min(v,u):v;e=a.reduce(function(t,e,r){var n=[].concat(nH(t),[{item:e.item,position:{offset:y+(v+l)*r+(v-m)/2,size:m}}]);return e.stackList&&e.stackList.length&&e.stackList.forEach(function(t){n.push({item:t,position:n[n.length-1].position})}),n},s)}return e},n6=function(t,e,r,n){var o=r.children,i=r.width,a=r.margin,u=i-(a.left||0)-(a.right||0),c=(0,nW.z)({children:o,legendWidth:u});if(c){var l=n||{},s=l.width,f=l.height,p=c.align,h=c.verticalAlign,d=c.layout;if(("vertical"===d||"horizontal"===d&&"middle"===h)&&"center"!==p&&(0,nq.hj)(t[p]))return nV(nV({},t),{},nK({},p,t[p]+(s||0)));if(("horizontal"===d||"vertical"===d&&"center"===p)&&"middle"!==h&&(0,nq.hj)(t[h]))return nV(nV({},t),{},nK({},h,t[h]+(f||0)))}return t},n3=function(t,e,r,n,o){var i=e.props.children,a=(0,nZ.NN)(i,n$.W).filter(function(t){var e;return e=t.props.direction,!!nr()(o)||("horizontal"===n?"yAxis"===o:"vertical"===n||"x"===e?"xAxis"===o:"y"!==e||"yAxis"===o)});if(a&&a.length){var u=a.map(function(t){return t.props.dataKey});return t.reduce(function(t,e){var n=nQ(e,r);if(nr()(n))return t;var o=Array.isArray(n)?[nt()(n),r8()(n)]:[n,n],i=u.reduce(function(t,r){var n=nQ(e,r,0),i=o[0]-Math.abs(Array.isArray(n)?n[0]:n),a=o[1]+Math.abs(Array.isArray(n)?n[1]:n);return[Math.min(i,t[0]),Math.max(a,t[1])]},[1/0,-1/0]);return[Math.min(i[0],t[0]),Math.max(i[1],t[1])]},[1/0,-1/0])}return null},n7=function(t,e,r,n,o){var i=e.map(function(e){return n3(t,e,r,o,n)}).filter(function(t){return!nr()(t)});return i&&i.length?i.reduce(function(t,e){return[Math.min(t[0],e[0]),Math.max(t[1],e[1])]},[1/0,-1/0]):null},n4=function(t,e,r,n,o){var i=e.map(function(e){var i=e.props.dataKey;return"number"===r&&i&&n3(t,e,i,n)||nJ(t,i,r,o)});if("number"===r)return i.reduce(function(t,e){return[Math.min(t[0],e[0]),Math.max(t[1],e[1])]},[1/0,-1/0]);var a={};return i.reduce(function(t,e){for(var r=0,n=e.length;r=2?2*(0,nq.uY)(a[0]-a[1])*c:c,e&&(t.ticks||t.niceTicks))?(t.ticks||t.niceTicks).map(function(t){return{coordinate:n(o?o.indexOf(t):t)+c,value:t,offset:c}}).filter(function(t){return!np()(t.coordinate)}):t.isCategorical&&t.categoricalDomain?t.categoricalDomain.map(function(t,e){return{coordinate:n(t)+c,value:t,index:e,offset:c}}):n.ticks&&!r?n.ticks(t.tickCount).map(function(t){return{coordinate:n(t)+c,value:t,offset:c}}):n.domain().map(function(t,e){return{coordinate:n(t)+c,value:o?o[t]:t,index:e,offset:c}})},oe=new WeakMap,or=function(t,e){if("function"!=typeof e)return t;oe.has(t)||oe.set(t,new WeakMap);var r=oe.get(t);if(r.has(e))return r.get(e);var n=function(){t.apply(void 0,arguments),e.apply(void 0,arguments)};return r.set(e,n),n},on=function(t,e,r){var n=t.scale,o=t.type,i=t.layout,a=t.axisType;if("auto"===n)return"radial"===i&&"radiusAxis"===a?{scale:f.Z(),realScaleType:"band"}:"radial"===i&&"angleAxis"===a?{scale:tL(),realScaleType:"linear"}:"category"===o&&e&&(e.indexOf("LineChart")>=0||e.indexOf("AreaChart")>=0||e.indexOf("ComposedChart")>=0&&!r)?{scale:f.x(),realScaleType:"point"}:"category"===o?{scale:f.Z(),realScaleType:"band"}:{scale:tL(),realScaleType:"linear"};if(na()(n)){var u="scale".concat(nd()(n));return{scale:(s[u]||f.x)(),realScaleType:s[u]?u:"point"}}return no()(n)?{scale:n}:{scale:f.x(),realScaleType:"point"}},oo=function(t){var e=t.domain();if(e&&!(e.length<=2)){var r=e.length,n=t.range(),o=Math.min(n[0],n[1])-1e-4,i=Math.max(n[0],n[1])+1e-4,a=t(e[0]),u=t(e[r-1]);(ai||ui)&&t.domain([e[0],e[r-1]])}},oi=function(t,e){if(!t)return null;for(var r=0,n=t.length;rn)&&(o[1]=n),o[0]>n&&(o[0]=n),o[1]=0?(t[a][r][0]=o,t[a][r][1]=o+u,o=t[a][r][1]):(t[a][r][0]=i,t[a][r][1]=i+u,i=t[a][r][1])}},expand:function(t,e){if((n=t.length)>0){for(var r,n,o,i=0,a=t[0].length;i0){for(var r,n=0,o=t[e[0]],i=o.length;n0&&(n=(r=t[e[0]]).length)>0){for(var r,n,o,i=0,a=1;a=0?(t[i][r][0]=o,t[i][r][1]=o+a,o=t[i][r][1]):(t[i][r][0]=0,t[i][r][1]=0)}}},oc=function(t,e,r){var n=e.map(function(t){return t.props.dataKey}),o=ou[r];return(function(){var t=(0,r5.Z)([]),e=r6,r=r1,n=r3;function o(o){var i,a,u=Array.from(t.apply(this,arguments),r7),c=u.length,l=-1;for(let t of o)for(i=0,++l;i=0?0:o<0?o:n}return r[0]},od=function(t,e){var r,n=(null!==(r=t.type)&&void 0!==r&&r.defaultProps?nV(nV({},t.type.defaultProps),t.props):t.props).stackId;if((0,nq.P2)(n)){var o=e[n];if(o){var i=o.items.indexOf(t);return i>=0?o.stackedData[i]:null}}return null},oy=function(t,e,r){return Object.keys(t).reduce(function(n,o){var i=t[o].stackedData.reduce(function(t,n){var o=n.slice(e,r+1).reduce(function(t,e){return[nt()(e.concat([t[0]]).filter(nq.hj)),r8()(e.concat([t[1]]).filter(nq.hj))]},[1/0,-1/0]);return[Math.min(t[0],o[0]),Math.max(t[1],o[1])]},[1/0,-1/0]);return[Math.min(i[0],n[0]),Math.max(i[1],n[1])]},[1/0,-1/0]).map(function(t){return t===1/0||t===-1/0?0:t})},ov=/^dataMin[\s]*-[\s]*([0-9]+([.]{1}[0-9]+){0,1})$/,om=/^dataMax[\s]*\+[\s]*([0-9]+([.]{1}[0-9]+){0,1})$/,ob=function(t,e,r){if(no()(t))return t(e,r);if(!Array.isArray(t))return e;var n=[];if((0,nq.hj)(t[0]))n[0]=r?t[0]:Math.min(t[0],e[0]);else if(ov.test(t[0])){var o=+ov.exec(t[0])[1];n[0]=e[0]-o}else no()(t[0])?n[0]=t[0](e[0]):n[0]=e[0];if((0,nq.hj)(t[1]))n[1]=r?t[1]:Math.max(t[1],e[1]);else if(om.test(t[1])){var i=+om.exec(t[1])[1];n[1]=e[1]+i}else no()(t[1])?n[1]=t[1](e[1]):n[1]=e[1];return n},og=function(t,e,r){if(t&&t.scale&&t.scale.bandwidth){var n=t.scale.bandwidth();if(!r||n>0)return n}if(t&&e&&e.length>=2){for(var o=nb()(e,function(t){return t.coordinate}),i=1/0,a=1,u=o.length;a1&&void 0!==arguments[1]?arguments[1]:{};if(null==t||n.x.isSsr)return{width:0,height:0};var o=(Object.keys(e=a({},r)).forEach(function(t){e[t]||delete e[t]}),e),i=JSON.stringify({text:t,copyStyle:o});if(u.widthCache[i])return u.widthCache[i];try{var s=document.getElementById(l);s||((s=document.createElement("span")).setAttribute("id",l),s.setAttribute("aria-hidden","true"),document.body.appendChild(s));var f=a(a({},c),o);Object.assign(s.style,f),s.textContent="".concat(t);var p=s.getBoundingClientRect(),h={width:p.width,height:p.height};return u.widthCache[i]=h,++u.cacheCount>2e3&&(u.cacheCount=0,u.widthCache={}),h}catch(t){return{width:0,height:0}}},f=function(t){return{top:t.top+window.scrollY-document.documentElement.clientTop,left:t.left+window.scrollX-document.documentElement.clientLeft}}},16630:function(t,e,r){"use strict";r.d(e,{Ap:function(){return S},EL:function(){return g},Kt:function(){return w},P2:function(){return m},Rw:function(){return v},bv:function(){return O},fC:function(){return P},h1:function(){return x},hU:function(){return d},hj:function(){return y},k4:function(){return j},uY:function(){return h}});var n=r(42715),o=r.n(n),i=r(82559),a=r.n(i),u=r(13735),c=r.n(u),l=r(22345),s=r.n(l),f=r(77571),p=r.n(f),h=function(t){return 0===t?0:t>0?1:-1},d=function(t){return o()(t)&&t.indexOf("%")===t.length-1},y=function(t){return s()(t)&&!a()(t)},v=function(t){return p()(t)},m=function(t){return y(t)||o()(t)},b=0,g=function(t){var e=++b;return"".concat(t||"").concat(e)},x=function(t,e){var r,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,i=arguments.length>3&&void 0!==arguments[3]&&arguments[3];if(!y(t)&&!o()(t))return n;if(d(t)){var u=t.indexOf("%");r=e*parseFloat(t.slice(0,u))/100}else r=+t;return a()(r)&&(r=n),i&&r>e&&(r=e),r},w=function(t){if(!t)return null;var e=Object.keys(t);return e&&e.length?t[e[0]]:null},O=function(t){if(!Array.isArray(t))return!1;for(var e=t.length,r={},n=0;n2?r-2:0),o=2;ot.length)&&(e=t.length);for(var r=0,n=Array(e);r2&&void 0!==arguments[2]?arguments[2]:{top:0,right:0,bottom:0,left:0};return Math.min(Math.abs(t-(r.left||0)-(r.right||0)),Math.abs(e-(r.top||0)-(r.bottom||0)))/2},b=function(t,e,r,n,i){var a=t.width,u=t.height,s=t.startAngle,f=t.endAngle,y=(0,c.h1)(t.cx,a,a/2),v=(0,c.h1)(t.cy,u,u/2),b=m(a,u,r),g=(0,c.h1)(t.innerRadius,b,0),x=(0,c.h1)(t.outerRadius,b,.8*b);return Object.keys(e).reduce(function(t,r){var a,u=e[r],c=u.domain,m=u.reversed;if(o()(u.range))"angleAxis"===n?a=[s,f]:"radiusAxis"===n&&(a=[g,x]),m&&(a=[a[1],a[0]]);else{var b,w=function(t){if(Array.isArray(t))return t}(b=a=u.range)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,u=[],c=!0,l=!1;try{for(i=(r=r.call(t)).next;!(c=(n=i.call(r)).done)&&(u.push(n.value),2!==u.length);c=!0);}catch(t){l=!0,o=t}finally{try{if(!c&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(l)throw o}}return u}}(b,2)||function(t,e){if(t){if("string"==typeof t)return d(t,2);var r=Object.prototype.toString.call(t).slice(8,-1);if("Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r)return Array.from(t);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return d(t,2)}}(b,2)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}();s=w[0],f=w[1]}var O=(0,l.Hq)(u,i),j=O.realScaleType,S=O.scale;S.domain(c).range(a),(0,l.zF)(S);var P=(0,l.g$)(S,p(p({},u),{},{realScaleType:j})),E=p(p(p({},u),P),{},{range:a,radius:x,realScaleType:j,scale:S,cx:y,cy:v,innerRadius:g,outerRadius:x,startAngle:s,endAngle:f});return p(p({},t),{},h({},r,E))},{})},g=function(t,e){var r=t.x,n=t.y;return Math.sqrt(Math.pow(r-e.x,2)+Math.pow(n-e.y,2))},x=function(t,e){var r=t.x,n=t.y,o=e.cx,i=e.cy,a=g({x:r,y:n},{x:o,y:i});if(a<=0)return{radius:a};var u=Math.acos((r-o)/a);return n>i&&(u=2*Math.PI-u),{radius:a,angle:180*u/Math.PI,angleInRadian:u}},w=function(t){var e=t.startAngle,r=t.endAngle,n=Math.min(Math.floor(e/360),Math.floor(r/360));return{startAngle:e-360*n,endAngle:r-360*n}},O=function(t,e){var r,n=x({x:t.x,y:t.y},e),o=n.radius,i=n.angle,a=e.innerRadius,u=e.outerRadius;if(ou)return!1;if(0===o)return!0;var c=w(e),l=c.startAngle,s=c.endAngle,f=i;if(l<=s){for(;f>s;)f-=360;for(;f=l&&f<=s}else{for(;f>l;)f-=360;for(;f=s&&f<=l}return r?p(p({},e),{},{radius:o,angle:f+360*Math.min(Math.floor(e.startAngle/360),Math.floor(e.endAngle/360))}):null},j=function(t){return(0,i.isValidElement)(t)||u()(t)||"boolean"==typeof t?"":t.className}},82944:function(t,e,r){"use strict";r.d(e,{$R:function(){return R},Bh:function(){return B},Gf:function(){return j},L6:function(){return N},NN:function(){return k},TT:function(){return M},eu:function(){return L},jf:function(){return T},rL:function(){return D},sP:function(){return A}});var n=r(13735),o=r.n(n),i=r(77571),a=r.n(i),u=r(42715),c=r.n(u),l=r(86757),s=r.n(l),f=r(28302),p=r.n(f),h=r(2265),d=r(14326),y=r(16630),v=r(46485),m=r(41637),b=["children"],g=["children"];function x(t,e){if(null==t)return{};var r,n,o=function(t,e){if(null==t)return{};var r={};for(var n in t)if(Object.prototype.hasOwnProperty.call(t,n)){if(e.indexOf(n)>=0)continue;r[n]=t[n]}return r}(t,e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(n=0;n=0)&&Object.prototype.propertyIsEnumerable.call(t,r)&&(o[r]=t[r])}return o}function w(t){return(w="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}var O={click:"onClick",mousedown:"onMouseDown",mouseup:"onMouseUp",mouseover:"onMouseOver",mousemove:"onMouseMove",mouseout:"onMouseOut",mouseenter:"onMouseEnter",mouseleave:"onMouseLeave",touchcancel:"onTouchCancel",touchend:"onTouchEnd",touchmove:"onTouchMove",touchstart:"onTouchStart",contextmenu:"onContextMenu",dblclick:"onDoubleClick"},j=function(t){return"string"==typeof t?t:t?t.displayName||t.name||"Component":""},S=null,P=null,E=function t(e){if(e===S&&Array.isArray(P))return P;var r=[];return h.Children.forEach(e,function(e){a()(e)||((0,d.isFragment)(e)?r=r.concat(t(e.props.children)):r.push(e))}),P=r,S=e,r};function k(t,e){var r=[],n=[];return n=Array.isArray(e)?e.map(function(t){return j(t)}):[j(e)],E(t).forEach(function(t){var e=o()(t,"type.displayName")||o()(t,"type.name");-1!==n.indexOf(e)&&r.push(t)}),r}function A(t,e){var r=k(t,e);return r&&r[0]}var M=function(t){if(!t||!t.props)return!1;var e=t.props,r=e.width,n=e.height;return!!(0,y.hj)(r)&&!(r<=0)&&!!(0,y.hj)(n)&&!(n<=0)},_=["a","altGlyph","altGlyphDef","altGlyphItem","animate","animateColor","animateMotion","animateTransform","circle","clipPath","color-profile","cursor","defs","desc","ellipse","feBlend","feColormatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence","filter","font","font-face","font-face-format","font-face-name","font-face-url","foreignObject","g","glyph","glyphRef","hkern","image","line","lineGradient","marker","mask","metadata","missing-glyph","mpath","path","pattern","polygon","polyline","radialGradient","rect","script","set","stop","style","svg","switch","symbol","text","textPath","title","tref","tspan","use","view","vkern"],T=function(t){return t&&"object"===w(t)&&"clipDot"in t},C=function(t,e,r,n){var o,i=null!==(o=null===m.ry||void 0===m.ry?void 0:m.ry[n])&&void 0!==o?o:[];return e.startsWith("data-")||!s()(t)&&(n&&i.includes(e)||m.Yh.includes(e))||r&&m.nv.includes(e)},N=function(t,e,r){if(!t||"function"==typeof t||"boolean"==typeof t)return null;var n=t;if((0,h.isValidElement)(t)&&(n=t.props),!p()(n))return null;var o={};return Object.keys(n).forEach(function(t){var i;C(null===(i=n)||void 0===i?void 0:i[t],t,e,r)&&(o[t]=n[t])}),o},D=function t(e,r){if(e===r)return!0;var n=h.Children.count(e);if(n!==h.Children.count(r))return!1;if(0===n)return!0;if(1===n)return I(Array.isArray(e)?e[0]:e,Array.isArray(r)?r[0]:r);for(var o=0;o=0)r.push(t);else if(t){var i=j(t.type),a=e[i]||{},u=a.handler,l=a.once;if(u&&(!l||!n[i])){var s=u(t,i,o);r.push(s),n[i]=!0}}}),r},B=function(t){var e=t&&t.type;return e&&O[e]?O[e]:null},R=function(t,e){return E(e).indexOf(t)}},46485:function(t,e,r){"use strict";function n(t,e){for(var r in t)if(({}).hasOwnProperty.call(t,r)&&(!({}).hasOwnProperty.call(e,r)||t[r]!==e[r]))return!1;for(var n in e)if(({}).hasOwnProperty.call(e,n)&&!({}).hasOwnProperty.call(t,n))return!1;return!0}r.d(e,{w:function(){return n}})},38569:function(t,e,r){"use strict";r.d(e,{z:function(){return l}});var n=r(22190),o=r(85355),i=r(82944);function a(t){return(a="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function u(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),r.push.apply(r,n)}return r}function c(t){for(var e=1;e=0))throw Error(`invalid digits: ${t}`);if(e>15)return a;let r=10**e;return function(t){this._+=t[0];for(let e=1,n=t.length;e1e-6){if(Math.abs(f*c-l*s)>1e-6&&i){let h=r-a,d=o-u,y=c*c+l*l,v=Math.sqrt(y),m=Math.sqrt(p),b=i*Math.tan((n-Math.acos((y+p-(h*h+d*d))/(2*v*m)))/2),g=b/m,x=b/v;Math.abs(g-1)>1e-6&&this._append`L${t+g*s},${e+g*f}`,this._append`A${i},${i},0,0,${+(f*h>s*d)},${this._x1=t+x*c},${this._y1=e+x*l}`}else this._append`L${this._x1=t},${this._y1=e}`}}arc(t,e,r,a,u,c){if(t=+t,e=+e,c=!!c,(r=+r)<0)throw Error(`negative radius: ${r}`);let l=r*Math.cos(a),s=r*Math.sin(a),f=t+l,p=e+s,h=1^c,d=c?a-u:u-a;null===this._x1?this._append`M${f},${p}`:(Math.abs(this._x1-f)>1e-6||Math.abs(this._y1-p)>1e-6)&&this._append`L${f},${p}`,r&&(d<0&&(d=d%o+o),d>i?this._append`A${r},${r},0,1,${h},${t-l},${e-s}A${r},${r},0,1,${h},${this._x1=f},${this._y1=p}`:d>1e-6&&this._append`A${r},${r},0,${+(d>=n)},${h},${this._x1=t+r*Math.cos(u)},${this._y1=e+r*Math.sin(u)}`)}rect(t,e,r,n){this._append`M${this._x0=this._x1=+t},${this._y0=this._y1=+e}h${r=+r}v${+n}h${-r}Z`}toString(){return this._}}function c(t){let e=3;return t.digits=function(r){if(!arguments.length)return e;if(null==r)e=null;else{let t=Math.floor(r);if(!(t>=0))throw RangeError(`invalid digits: ${r}`);e=t}return t},()=>new u(e)}u.prototype},59121:function(t,e,r){"use strict";r.d(e,{E:function(){return i}});var n=r(99649),o=r(63497);function i(t,e){let r=(0,n.Q)(t);return isNaN(e)?(0,o.L)(t,NaN):(e&&r.setDate(r.getDate()+e),r)}},31091:function(t,e,r){"use strict";r.d(e,{z:function(){return i}});var n=r(99649),o=r(63497);function i(t,e){let r=(0,n.Q)(t);if(isNaN(e))return(0,o.L)(t,NaN);if(!e)return r;let i=r.getDate(),a=(0,o.L)(t,r.getTime());return(a.setMonth(r.getMonth()+e+1,0),i>=a.getDate())?a:(r.setFullYear(a.getFullYear(),a.getMonth(),i),r)}},63497:function(t,e,r){"use strict";function n(t,e){return t instanceof Date?new t.constructor(e):new Date(e)}r.d(e,{L:function(){return n}})},99649:function(t,e,r){"use strict";function n(t){let e=Object.prototype.toString.call(t);return t instanceof Date||"object"==typeof t&&"[object Date]"===e?new t.constructor(+t):new Date("number"==typeof t||"[object Number]"===e||"string"==typeof t||"[object String]"===e?t:NaN)}r.d(e,{Q:function(){return n}})},69398:function(t,e,r){"use strict";function n(t,e){if(!t)throw Error("Invariant failed")}r.d(e,{Z:function(){return n}})}}]); \ No newline at end of file diff --git a/litellm/proxy/_experimental/out/_next/static/chunks/1112-0b9bd4ebde18e77b.js b/litellm/proxy/_experimental/out/_next/static/chunks/1112-0b9bd4ebde18e77b.js deleted file mode 100644 index ea4e968a055..00000000000 --- a/litellm/proxy/_experimental/out/_next/static/chunks/1112-0b9bd4ebde18e77b.js +++ /dev/null @@ -1 +0,0 @@ -"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[1112],{41112:function(e,l,s){s.d(l,{Z:function(){return B}});var a=s(57437),t=s(2265),r=s(16312),i=s(22116),n=s(19250),o=s(4260),c=s(37592),d=s(10032),m=s(42264),x=s(43769);let{TextArea:u}=o.default,{Option:h}=c.default,g=["Development","Productivity","Learning","Security","Data & Analytics","Integration","Testing","Documentation"];var p=e=>{let{visible:l,onClose:s,accessToken:p,onSuccess:j}=e,[y]=d.Z.useForm(),[b,N]=(0,t.useState)(!1),[Z,f]=(0,t.useState)("github"),v=async e=>{if(!p){m.ZP.error("No access token available");return}if(!(0,x.$L)(e.name)){m.ZP.error("Plugin name must be kebab-case (lowercase letters, numbers, and hyphens only)");return}if(e.version&&!(0,x.Nq)(e.version)){m.ZP.error("Version must be in semantic versioning format (e.g., 1.0.0)");return}if(e.authorEmail&&!(0,x.vV)(e.authorEmail)){m.ZP.error("Invalid email format");return}if(e.homepage&&!(0,x.jv)(e.homepage)){m.ZP.error("Invalid homepage URL format");return}N(!0);try{let l={name:e.name.trim(),source:"github"===Z?{source:"github",repo:e.repo.trim()}:{source:"url",url:e.url.trim()}};e.version&&(l.version=e.version.trim()),e.description&&(l.description=e.description.trim()),(e.authorName||e.authorEmail)&&(l.author={},e.authorName&&(l.author.name=e.authorName.trim()),e.authorEmail&&(l.author.email=e.authorEmail.trim())),e.homepage&&(l.homepage=e.homepage.trim()),e.category&&(l.category=e.category),e.keywords&&(l.keywords=(0,x.jE)(e.keywords)),await (0,n.registerClaudeCodePlugin)(p,l),m.ZP.success("Plugin registered successfully"),y.resetFields(),f("github"),j(),s()}catch(e){console.error("Error registering plugin:",e),m.ZP.error("Failed to register plugin")}finally{N(!1)}},C=()=>{y.resetFields(),f("github"),s()};return(0,a.jsx)(i.Z,{title:"Add New Claude Code Plugin",open:l,onCancel:C,footer:null,width:700,className:"top-8",children:(0,a.jsxs)(d.Z,{form:y,layout:"vertical",onFinish:v,className:"mt-4",children:[(0,a.jsx)(d.Z.Item,{label:"Plugin Name",name:"name",rules:[{required:!0,message:"Please enter plugin name"},{pattern:/^[a-z0-9-]+$/,message:"Name must be kebab-case (lowercase, numbers, hyphens only)"}],tooltip:"Unique identifier in kebab-case format (e.g., my-awesome-plugin)",children:(0,a.jsx)(o.default,{placeholder:"my-awesome-plugin",className:"rounded-lg"})}),(0,a.jsx)(d.Z.Item,{label:"Source Type",name:"sourceType",initialValue:"github",rules:[{required:!0,message:"Please select source type"}],children:(0,a.jsxs)(c.default,{onChange:e=>{f(e),y.setFieldsValue({repo:void 0,url:void 0})},className:"rounded-lg",children:[(0,a.jsx)(h,{value:"github",children:"GitHub"}),(0,a.jsx)(h,{value:"url",children:"URL"})]})}),"github"===Z&&(0,a.jsx)(d.Z.Item,{label:"GitHub Repository",name:"repo",rules:[{required:!0,message:"Please enter repository"},{pattern:/^[a-zA-Z0-9_-]+\/[a-zA-Z0-9_-]+$/,message:"Repository must be in format: org/repo"}],tooltip:"Format: organization/repository (e.g., anthropics/claude-code)",children:(0,a.jsx)(o.default,{placeholder:"anthropics/claude-code",className:"rounded-lg"})}),"url"===Z&&(0,a.jsx)(d.Z.Item,{label:"Git URL",name:"url",rules:[{required:!0,message:"Please enter git URL"}],tooltip:"Full git URL to the repository",children:(0,a.jsx)(o.default,{type:"url",placeholder:"https://github.com/org/repo.git",className:"rounded-lg"})}),(0,a.jsx)(d.Z.Item,{label:"Version (Optional)",name:"version",tooltip:"Semantic version (e.g., 1.0.0)",children:(0,a.jsx)(o.default,{placeholder:"1.0.0",className:"rounded-lg"})}),(0,a.jsx)(d.Z.Item,{label:"Description (Optional)",name:"description",tooltip:"Brief description of what the plugin does",children:(0,a.jsx)(u,{rows:3,placeholder:"A plugin that helps with...",maxLength:500,className:"rounded-lg"})}),(0,a.jsx)(d.Z.Item,{label:"Category (Optional)",name:"category",tooltip:"Select a category or enter a custom one",children:(0,a.jsx)(c.default,{placeholder:"Select or type a category",allowClear:!0,showSearch:!0,optionFilterProp:"children",className:"rounded-lg",children:g.map(e=>(0,a.jsx)(h,{value:e,children:e},e))})}),(0,a.jsx)(d.Z.Item,{label:"Keywords (Optional)",name:"keywords",tooltip:"Comma-separated list of keywords for search",children:(0,a.jsx)(o.default,{placeholder:"search, web, api",className:"rounded-lg"})}),(0,a.jsx)(d.Z.Item,{label:"Author Name (Optional)",name:"authorName",tooltip:"Name of the plugin author or organization",children:(0,a.jsx)(o.default,{placeholder:"Your Name or Organization",className:"rounded-lg"})}),(0,a.jsx)(d.Z.Item,{label:"Author Email (Optional)",name:"authorEmail",rules:[{type:"email",message:"Please enter a valid email"}],tooltip:"Contact email for the plugin author",children:(0,a.jsx)(o.default,{type:"email",placeholder:"author@example.com",className:"rounded-lg"})}),(0,a.jsx)(d.Z.Item,{label:"Homepage (Optional)",name:"homepage",rules:[{type:"url",message:"Please enter a valid URL"}],tooltip:"URL to the plugin's homepage or documentation",children:(0,a.jsx)(o.default,{type:"url",placeholder:"https://example.com",className:"rounded-lg"})}),(0,a.jsx)(d.Z.Item,{className:"mb-0 mt-6",children:(0,a.jsxs)("div",{className:"flex justify-end gap-2",children:[(0,a.jsx)(r.z,{variant:"secondary",onClick:C,disabled:b,children:"Cancel"}),(0,a.jsx)(r.z,{type:"submit",loading:b,children:b?"Registering...":"Register Plugin"})]})})]})})},j=s(23639),y=s(74998),b=s(44633),N=s(86462),Z=s(49084),f=s(71594),v=s(24525),C=s(41649),w=s(78489),P=s(21626),k=s(97214),S=s(28241),_=s(58834),z=s(69552),I=s(71876),E=s(99981),A=s(63709),D=s(9114),L=e=>{let{pluginsList:l,isLoading:s,onDeleteClick:r,accessToken:i,onPluginUpdated:o,isAdmin:c,onPluginClick:d}=e,[m,u]=(0,t.useState)([{id:"created_at",desc:!0}]),[h,g]=(0,t.useState)(null),p=e=>e?new Date(e).toLocaleString():"-",L=e=>{navigator.clipboard.writeText(e),D.Z.success("Copied to clipboard!")},R=async e=>{if(i){g(e.id);try{e.enabled?(await (0,n.disableClaudeCodePlugin)(i,e.name),D.Z.success('Plugin "'.concat(e.name,'" disabled'))):(await (0,n.enableClaudeCodePlugin)(i,e.name),D.Z.success('Plugin "'.concat(e.name,'" enabled'))),o()}catch(e){D.Z.error("Failed to toggle plugin status")}finally{g(null)}}},F=[{header:"Plugin Name",accessorKey:"name",cell:e=>{let{row:l}=e,s=l.original,t=s.name||"";return(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)(E.Z,{title:t,children:(0,a.jsx)(w.Z,{size:"xs",variant:"light",className:"font-mono text-blue-500 bg-blue-50 hover:bg-blue-100 text-xs font-normal px-2 py-0.5 text-left overflow-hidden truncate min-w-[150px] justify-start",onClick:()=>d(s.id),children:t})}),(0,a.jsx)(E.Z,{title:"Copy Plugin ID",children:(0,a.jsx)(j.Z,{onClick:e=>{e.stopPropagation(),L(s.id)},className:"cursor-pointer text-gray-500 hover:text-blue-500 text-xs"})})]})}},{header:"Version",accessorKey:"version",cell:e=>{let{row:l}=e,s=l.original.version||"N/A";return(0,a.jsx)("span",{className:"text-xs text-gray-600",children:s})}},{header:"Description",accessorKey:"description",cell:e=>{let{row:l}=e,s=l.original.description||"No description";return(0,a.jsx)(E.Z,{title:s,children:(0,a.jsx)("span",{className:"text-xs text-gray-600 block max-w-[300px] truncate",children:s})})}},{header:"Category",accessorKey:"category",cell:e=>{let{row:l}=e,s=l.original.category;if(!s)return(0,a.jsx)(C.Z,{color:"gray",className:"text-xs font-normal",size:"xs",children:"Uncategorized"});let t=(0,x.LH)(s);return(0,a.jsx)(C.Z,{color:t,className:"text-xs font-normal",size:"xs",children:s})}},{header:"Enabled",accessorKey:"enabled",cell:e=>{let{row:l}=e,s=l.original;return(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)(C.Z,{color:s.enabled?"green":"gray",className:"text-xs font-normal",size:"xs",children:s.enabled?"Yes":"No"}),c&&(0,a.jsx)(E.Z,{title:s.enabled?"Disable plugin":"Enable plugin",children:(0,a.jsx)(A.Z,{size:"small",checked:s.enabled,loading:h===s.id,onChange:()=>R(s)})})]})}},{header:"Created At",accessorKey:"created_at",cell:e=>{let{row:l}=e,s=l.original;return(0,a.jsx)(E.Z,{title:s.created_at,children:(0,a.jsx)("span",{className:"text-xs",children:p(s.created_at)})})}},...c?[{header:"Actions",id:"actions",enableSorting:!1,cell:e=>{let{row:l}=e,s=l.original;return(0,a.jsx)("div",{className:"flex items-center gap-1",children:(0,a.jsx)(E.Z,{title:"Delete plugin",children:(0,a.jsx)(w.Z,{size:"xs",variant:"light",color:"red",onClick:e=>{e.stopPropagation(),r(s.name,s.name)},icon:y.Z,className:"text-red-500 hover:text-red-700 hover:bg-red-50"})})})}}]:[]],U=(0,f.b7)({data:l,columns:F,state:{sorting:m},onSortingChange:u,getCoreRowModel:(0,v.sC)(),getSortedRowModel:(0,v.tj)(),enableSorting:!0});return(0,a.jsx)("div",{className:"rounded-lg custom-border relative",children:(0,a.jsx)("div",{className:"overflow-x-auto",children:(0,a.jsxs)(P.Z,{className:"[&_td]:py-0.5 [&_th]:py-1",children:[(0,a.jsx)(_.Z,{children:U.getHeaderGroups().map(e=>(0,a.jsx)(I.Z,{children:e.headers.map(e=>(0,a.jsx)(z.Z,{className:"py-1 h-8 ".concat("actions"===e.id?"sticky right-0 bg-white shadow-[-4px_0_8px_-6px_rgba(0,0,0,0.1)]":""),onClick:e.column.getCanSort()?e.column.getToggleSortingHandler():void 0,children:(0,a.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,a.jsx)("div",{className:"flex items-center",children:e.isPlaceholder?null:(0,f.ie)(e.column.columnDef.header,e.getContext())}),e.column.getCanSort()&&(0,a.jsx)("div",{className:"w-4",children:e.column.getIsSorted()?({asc:(0,a.jsx)(b.Z,{className:"h-4 w-4 text-blue-500"}),desc:(0,a.jsx)(N.Z,{className:"h-4 w-4 text-blue-500"})})[e.column.getIsSorted()]:(0,a.jsx)(Z.Z,{className:"h-4 w-4 text-gray-400"})})]})},e.id))},e.id))}),(0,a.jsx)(k.Z,{children:s?(0,a.jsx)(I.Z,{children:(0,a.jsx)(S.Z,{colSpan:F.length,className:"h-8 text-center",children:(0,a.jsx)("div",{className:"text-center text-gray-500",children:(0,a.jsx)("p",{children:"Loading..."})})})}):l&&l.length>0?U.getRowModel().rows.map(e=>(0,a.jsx)(I.Z,{className:"h-8",children:e.getVisibleCells().map(e=>(0,a.jsx)(S.Z,{className:"py-0.5 max-h-8 overflow-hidden text-ellipsis whitespace-nowrap ".concat("actions"===e.column.id?"sticky right-0 bg-white shadow-[-4px_0_8px_-6px_rgba(0,0,0,0.1)]":""),children:(0,f.ie)(e.column.columnDef.cell,e.getContext())},e.id))},e.id)):(0,a.jsx)(I.Z,{children:(0,a.jsx)(S.Z,{colSpan:F.length,className:"h-8 text-center",children:(0,a.jsx)("div",{className:"text-center text-gray-500",children:(0,a.jsx)("p",{children:"No plugins found. Add one to get started."})})})})})]})})})},R=s(20347),F=s(10900),U=s(3477),O=s(12514),T=s(67101),H=s(84264),K=s(96761),V=s(10353),q=e=>{let{pluginId:l,onClose:s,accessToken:r,isAdmin:i,onPluginUpdated:o}=e,[c,d]=(0,t.useState)(null),[m,u]=(0,t.useState)(!0),[h,g]=(0,t.useState)(!1);(0,t.useEffect)(()=>{p()},[l,r]);let p=async()=>{if(r){u(!0);try{let e=await (0,n.getClaudeCodePluginDetails)(r,l);d(e.plugin)}catch(e){console.error("Error fetching plugin info:",e),D.Z.error("Failed to load plugin information")}finally{u(!1)}}},y=async()=>{if(r&&c){g(!0);try{c.enabled?(await (0,n.disableClaudeCodePlugin)(r,c.name),D.Z.success('Plugin "'.concat(c.name,'" disabled'))):(await (0,n.enableClaudeCodePlugin)(r,c.name),D.Z.success('Plugin "'.concat(c.name,'" enabled'))),o(),p()}catch(e){D.Z.error("Failed to toggle plugin status")}finally{g(!1)}}},b=e=>{navigator.clipboard.writeText(e),D.Z.success("Copied to clipboard!")};if(m)return(0,a.jsx)("div",{className:"flex items-center justify-center p-8",children:(0,a.jsx)(V.Z,{size:"large"})});if(!c)return(0,a.jsxs)("div",{className:"p-8 text-center text-gray-500",children:[(0,a.jsx)("p",{children:"Plugin not found"}),(0,a.jsx)(w.Z,{className:"mt-4",onClick:s,children:"Go Back"})]});let N=(0,x.aB)(c),Z=(0,x.OB)(c.source),f=(0,x.LH)(c.category);return(0,a.jsxs)("div",{className:"space-y-4",children:[(0,a.jsxs)("div",{className:"flex items-center gap-3 mb-6",children:[(0,a.jsx)(F.Z,{className:"h-5 w-5 cursor-pointer text-gray-500 hover:text-gray-700",onClick:s}),(0,a.jsx)("h2",{className:"text-2xl font-bold",children:c.name}),c.version&&(0,a.jsxs)(C.Z,{color:"blue",size:"xs",children:["v",c.version]}),c.category&&(0,a.jsx)(C.Z,{color:f,size:"xs",children:c.category}),(0,a.jsx)(C.Z,{color:c.enabled?"green":"gray",size:"xs",children:c.enabled?"Enabled":"Disabled"})]}),(0,a.jsx)(O.Z,{children:(0,a.jsxs)("div",{className:"flex items-center justify-between",children:[(0,a.jsxs)("div",{className:"flex-1",children:[(0,a.jsx)(H.Z,{className:"text-gray-600 text-xs mb-2",children:"Install Command"}),(0,a.jsx)("div",{className:"font-mono bg-gray-100 px-3 py-2 rounded text-sm",children:N})]}),(0,a.jsx)(E.Z,{title:"Copy install command",children:(0,a.jsx)(w.Z,{size:"xs",variant:"secondary",icon:j.Z,onClick:()=>b(N),className:"ml-4",children:"Copy"})})]})}),(0,a.jsxs)(O.Z,{children:[(0,a.jsx)(K.Z,{children:"Plugin Details"}),(0,a.jsxs)(T.Z,{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-6 mt-4",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)(H.Z,{className:"text-gray-600 text-xs",children:"Plugin ID"}),(0,a.jsxs)("div",{className:"flex items-center gap-2 mt-1",children:[(0,a.jsx)(H.Z,{className:"font-mono text-xs",children:c.id}),(0,a.jsx)(j.Z,{className:"cursor-pointer text-gray-500 hover:text-blue-500 text-xs",onClick:()=>b(c.id)})]})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)(H.Z,{className:"text-gray-600 text-xs",children:"Name"}),(0,a.jsx)(H.Z,{className:"font-semibold mt-1",children:c.name})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)(H.Z,{className:"text-gray-600 text-xs",children:"Version"}),(0,a.jsx)(H.Z,{className:"font-semibold mt-1",children:c.version||"N/A"})]}),(0,a.jsxs)("div",{className:"col-span-2",children:[(0,a.jsx)(H.Z,{className:"text-gray-600 text-xs",children:"Source"}),(0,a.jsxs)("div",{className:"flex items-center gap-2 mt-1",children:[(0,a.jsx)(H.Z,{className:"font-semibold",children:(0,x.i5)(c.source)}),Z&&(0,a.jsx)("a",{href:Z,target:"_blank",rel:"noopener noreferrer",className:"text-blue-500 hover:text-blue-700",children:(0,a.jsx)(U.Z,{className:"h-4 w-4"})})]})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)(H.Z,{className:"text-gray-600 text-xs",children:"Category"}),(0,a.jsx)("div",{className:"mt-1",children:c.category?(0,a.jsx)(C.Z,{color:f,size:"xs",children:c.category}):(0,a.jsx)(H.Z,{className:"text-gray-400",children:"Uncategorized"})})]}),i&&(0,a.jsxs)("div",{className:"col-span-3",children:[(0,a.jsx)(H.Z,{className:"text-gray-600 text-xs",children:"Status"}),(0,a.jsxs)("div",{className:"flex items-center gap-3 mt-2",children:[(0,a.jsx)(A.Z,{checked:c.enabled,loading:h,onChange:y}),(0,a.jsx)(H.Z,{className:"text-sm",children:c.enabled?"Plugin is enabled and visible in marketplace":"Plugin is disabled and hidden from marketplace"})]})]})]})]}),c.description&&(0,a.jsxs)(O.Z,{children:[(0,a.jsx)(K.Z,{children:"Description"}),(0,a.jsx)(H.Z,{className:"mt-2",children:c.description})]}),c.keywords&&c.keywords.length>0&&(0,a.jsxs)(O.Z,{children:[(0,a.jsx)(K.Z,{children:"Keywords"}),(0,a.jsx)("div",{className:"flex flex-wrap gap-2 mt-2",children:c.keywords.map((e,l)=>(0,a.jsx)(C.Z,{color:"gray",size:"xs",children:e},l))})]}),c.author&&(0,a.jsxs)(O.Z,{children:[(0,a.jsx)(K.Z,{children:"Author Information"}),(0,a.jsxs)(T.Z,{className:"grid grid-cols-1 sm:grid-cols-2 gap-4 mt-4",children:[c.author.name&&(0,a.jsxs)("div",{children:[(0,a.jsx)(H.Z,{className:"text-gray-600 text-xs",children:"Name"}),(0,a.jsx)(H.Z,{className:"font-semibold mt-1",children:c.author.name})]}),c.author.email&&(0,a.jsxs)("div",{children:[(0,a.jsx)(H.Z,{className:"text-gray-600 text-xs",children:"Email"}),(0,a.jsx)(H.Z,{className:"font-semibold mt-1",children:(0,a.jsx)("a",{href:"mailto:".concat(c.author.email),className:"text-blue-500 hover:text-blue-700",children:c.author.email})})]})]})]}),c.homepage&&(0,a.jsxs)(O.Z,{children:[(0,a.jsx)(K.Z,{children:"Homepage"}),(0,a.jsxs)("a",{href:c.homepage,target:"_blank",rel:"noopener noreferrer",className:"text-blue-500 hover:text-blue-700 flex items-center gap-2 mt-2",children:[c.homepage,(0,a.jsx)(U.Z,{className:"h-4 w-4"})]})]}),(0,a.jsxs)(O.Z,{children:[(0,a.jsx)(K.Z,{children:"Metadata"}),(0,a.jsxs)(T.Z,{className:"grid grid-cols-1 sm:grid-cols-2 gap-4 mt-4",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)(H.Z,{className:"text-gray-600 text-xs",children:"Created At"}),(0,a.jsx)(H.Z,{className:"font-semibold mt-1",children:(0,x.ie)(c.created_at)})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)(H.Z,{className:"text-gray-600 text-xs",children:"Updated At"}),(0,a.jsx)(H.Z,{className:"font-semibold mt-1",children:(0,x.ie)(c.updated_at)})]}),c.created_by&&(0,a.jsxs)("div",{className:"col-span-2",children:[(0,a.jsx)(H.Z,{className:"text-gray-600 text-xs",children:"Created By"}),(0,a.jsx)(H.Z,{className:"font-semibold mt-1",children:c.created_by})]})]})]})]})},B=e=>{let{accessToken:l,userRole:s}=e,[o,c]=(0,t.useState)([]),[d,m]=(0,t.useState)(!1),[x,u]=(0,t.useState)(!1),[h,g]=(0,t.useState)(!1),[j,y]=(0,t.useState)(null),[b,N]=(0,t.useState)(null),Z=!!s&&(0,R.tY)(s),f=async()=>{if(l){u(!0);try{let e=await (0,n.getClaudeCodePluginsList)(l,!1);console.log("Claude Code plugins: ".concat(JSON.stringify(e))),c(e.plugins)}catch(e){console.error("Error fetching Claude Code plugins:",e)}finally{u(!1)}}};(0,t.useEffect)(()=>{f()},[l]);let v=async()=>{if(j&&l){g(!0);try{await (0,n.deleteClaudeCodePlugin)(l,j.name),D.Z.success('Plugin "'.concat(j.displayName,'" deleted successfully')),f()}catch(e){console.error("Error deleting plugin:",e),D.Z.error("Failed to delete plugin")}finally{g(!1),y(null)}}};return(0,a.jsxs)("div",{className:"w-full mx-auto flex-auto overflow-y-auto m-8 p-2",children:[(0,a.jsxs)("div",{className:"flex flex-col gap-2 mb-4",children:[(0,a.jsx)("h1",{className:"text-2xl font-bold",children:"Claude Code Plugins"}),(0,a.jsxs)("p",{className:"text-sm text-gray-600",children:["Manage Claude Code marketplace plugins. Add, enable, disable, or delete plugins that will be available in your marketplace catalog. Enabled plugins will appear in the public marketplace at"," ",(0,a.jsx)("code",{className:"bg-gray-100 px-1 rounded",children:"/claude-code/marketplace.json"}),"."]}),(0,a.jsx)("div",{className:"mt-2",children:(0,a.jsx)(r.z,{onClick:()=>{b&&N(null),m(!0)},disabled:!l||!Z,children:"+ Add New Plugin"})})]}),b?(0,a.jsx)(q,{pluginId:b,onClose:()=>N(null),accessToken:l,isAdmin:Z,onPluginUpdated:f}):(0,a.jsx)(L,{pluginsList:o,isLoading:x,onDeleteClick:(e,l)=>{y({name:e,displayName:l})},accessToken:l,onPluginUpdated:f,isAdmin:Z,onPluginClick:e=>N(e)}),(0,a.jsx)(p,{visible:d,onClose:()=>{m(!1)},accessToken:l,onSuccess:()=>{f()}}),j&&(0,a.jsxs)(i.Z,{title:"Delete Plugin",open:null!==j,onOk:v,onCancel:()=>{y(null)},confirmLoading:h,okText:"Delete",okButtonProps:{danger:!0},children:[(0,a.jsxs)("p",{children:["Are you sure you want to delete plugin:"," ",(0,a.jsx)("strong",{children:j.displayName}),"?"]}),(0,a.jsx)("p",{children:"This action cannot be undone."})]})]})}}}]); \ No newline at end of file diff --git a/litellm/proxy/_experimental/out/_next/static/chunks/1208-5caf6d9856cc3f13.js b/litellm/proxy/_experimental/out/_next/static/chunks/1208-5caf6d9856cc3f13.js deleted file mode 100644 index de5590f1965..00000000000 --- a/litellm/proxy/_experimental/out/_next/static/chunks/1208-5caf6d9856cc3f13.js +++ /dev/null @@ -1 +0,0 @@ -"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[1208],{44625:function(t,e,o){o.d(e,{Z:function(){return l}});var r=o(1119),n=o(2265),a={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M832 64H192c-17.7 0-32 14.3-32 32v832c0 17.7 14.3 32 32 32h640c17.7 0 32-14.3 32-32V96c0-17.7-14.3-32-32-32zm-600 72h560v208H232V136zm560 480H232V408h560v208zm0 272H232V680h560v208zM304 240a40 40 0 1080 0 40 40 0 10-80 0zm0 272a40 40 0 1080 0 40 40 0 10-80 0zm0 272a40 40 0 1080 0 40 40 0 10-80 0z"}}]},name:"database",theme:"outlined"},i=o(55015),l=n.forwardRef(function(t,e){return n.createElement(i.Z,(0,r.Z)({},t,{ref:e,icon:a}))})},46783:function(t,e,o){o.d(e,{Z:function(){return l}});var r=o(1119),n=o(2265),a={icon:{tag:"svg",attrs:{viewBox:"0 0 1024 1024",focusable:"false"},children:[{tag:"path",attrs:{d:"M885.2 446.3l-.2-.8-112.2-285.1c-5-16.1-19.9-27.2-36.8-27.2H281.2c-17 0-32.1 11.3-36.9 27.6L139.4 443l-.3.7-.2.8c-1.3 4.9-1.7 9.9-1 14.8-.1 1.6-.2 3.2-.2 4.8V830a60.9 60.9 0 0060.8 60.8h627.2c33.5 0 60.8-27.3 60.9-60.8V464.1c0-1.3 0-2.6-.1-3.7.4-4.9 0-9.6-1.3-14.1zm-295.8-43l-.3 15.7c-.8 44.9-31.8 75.1-77.1 75.1-22.1 0-41.1-7.1-54.8-20.6S436 441.2 435.6 419l-.3-15.7H229.5L309 210h399.2l81.7 193.3H589.4zm-375 76.8h157.3c24.3 57.1 76 90.8 140.4 90.8 33.7 0 65-9.4 90.3-27.2 22.2-15.6 39.5-37.4 50.7-63.6h156.5V814H214.4V480.1z"}}]},name:"inbox",theme:"outlined"},i=o(55015),l=n.forwardRef(function(t,e){return n.createElement(i.Z,(0,r.Z)({},t,{ref:e,icon:a}))})},23907:function(t,e,o){o.d(e,{Z:function(){return l}});var r=o(1119),n=o(2265),a={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"defs",attrs:{},children:[{tag:"style",attrs:{}}]},{tag:"path",attrs:{d:"M931.4 498.9L94.9 79.5c-3.4-1.7-7.3-2.1-11-1.2a15.99 15.99 0 00-11.7 19.3l86.2 352.2c1.3 5.3 5.2 9.6 10.4 11.3l147.7 50.7-147.6 50.7c-5.2 1.8-9.1 6-10.3 11.3L72.2 926.5c-.9 3.7-.5 7.6 1.2 10.9 3.9 7.9 13.5 11.1 21.5 7.2l836.5-417c3.1-1.5 5.6-4.1 7.2-7.1 3.9-8 .7-17.6-7.2-21.6zM170.8 826.3l50.3-205.6 295.2-101.3c2.3-.8 4.2-2.6 5-5 1.4-4.2-.8-8.7-5-10.2L221.1 403 171 198.2l628 314.9-628.2 313.2z"}}]},name:"send",theme:"outlined"},i=o(55015),l=n.forwardRef(function(t,e){return n.createElement(i.Z,(0,r.Z)({},t,{ref:e,icon:a}))})},47323:function(t,e,o){o.d(e,{Z:function(){return f}});var r=o(5853),n=o(2265),a=o(47187),i=o(7084),l=o(13241),c=o(1153),s=o(26898);let d={xs:{paddingX:"px-1.5",paddingY:"py-1.5"},sm:{paddingX:"px-1.5",paddingY:"py-1.5"},md:{paddingX:"px-2",paddingY:"py-2"},lg:{paddingX:"px-2",paddingY:"py-2"},xl:{paddingX:"px-2.5",paddingY:"py-2.5"}},u={xs:{height:"h-3",width:"w-3"},sm:{height:"h-5",width:"w-5"},md:{height:"h-5",width:"w-5"},lg:{height:"h-7",width:"w-7"},xl:{height:"h-9",width:"w-9"}},m={simple:{rounded:"",border:"",ring:"",shadow:""},light:{rounded:"rounded-tremor-default",border:"",ring:"",shadow:""},shadow:{rounded:"rounded-tremor-default",border:"border",ring:"",shadow:"shadow-tremor-card dark:shadow-dark-tremor-card"},solid:{rounded:"rounded-tremor-default",border:"border-2",ring:"ring-1",shadow:""},outlined:{rounded:"rounded-tremor-default",border:"border",ring:"ring-2",shadow:""}},g=(t,e)=>{switch(t){case"simple":return{textColor:e?(0,c.bM)(e,s.K.text).textColor:"text-tremor-brand dark:text-dark-tremor-brand",bgColor:"",borderColor:"",ringColor:""};case"light":return{textColor:e?(0,c.bM)(e,s.K.text).textColor:"text-tremor-brand dark:text-dark-tremor-brand",bgColor:e?(0,l.q)((0,c.bM)(e,s.K.background).bgColor,"bg-opacity-20"):"bg-tremor-brand-muted dark:bg-dark-tremor-brand-muted",borderColor:"",ringColor:""};case"shadow":return{textColor:e?(0,c.bM)(e,s.K.text).textColor:"text-tremor-brand dark:text-dark-tremor-brand",bgColor:e?(0,l.q)((0,c.bM)(e,s.K.background).bgColor,"bg-opacity-20"):"bg-tremor-background dark:bg-dark-tremor-background",borderColor:"border-tremor-border dark:border-dark-tremor-border",ringColor:""};case"solid":return{textColor:e?(0,c.bM)(e,s.K.text).textColor:"text-tremor-brand-inverted dark:text-dark-tremor-brand-inverted",bgColor:e?(0,l.q)((0,c.bM)(e,s.K.background).bgColor,"bg-opacity-20"):"bg-tremor-brand dark:bg-dark-tremor-brand",borderColor:"border-tremor-brand-inverted dark:border-dark-tremor-brand-inverted",ringColor:"ring-tremor-ring dark:ring-dark-tremor-ring"};case"outlined":return{textColor:e?(0,c.bM)(e,s.K.text).textColor:"text-tremor-brand dark:text-dark-tremor-brand",bgColor:e?(0,l.q)((0,c.bM)(e,s.K.background).bgColor,"bg-opacity-20"):"bg-tremor-background dark:bg-dark-tremor-background",borderColor:e?(0,c.bM)(e,s.K.ring).borderColor:"border-tremor-brand-subtle dark:border-dark-tremor-brand-subtle",ringColor:e?(0,l.q)((0,c.bM)(e,s.K.ring).ringColor,"ring-opacity-40"):"ring-tremor-brand-muted dark:ring-dark-tremor-brand-muted"}}},b=(0,c.fn)("Icon"),f=n.forwardRef((t,e)=>{let{icon:o,variant:s="simple",tooltip:f,size:p=i.u8.SM,color:h,className:v}=t,w=(0,r._T)(t,["icon","variant","tooltip","size","color","className"]),k=g(s,h),{tooltipProps:x,getReferenceProps:C}=(0,a.l)();return n.createElement("span",Object.assign({ref:(0,c.lq)([e,x.refs.setReference]),className:(0,l.q)(b("root"),"inline-flex shrink-0 items-center justify-center",k.bgColor,k.textColor,k.borderColor,k.ringColor,m[s].rounded,m[s].border,m[s].shadow,m[s].ring,d[p].paddingX,d[p].paddingY,v)},C,w),n.createElement(a.Z,Object.assign({text:f},x)),n.createElement(o,{className:(0,l.q)(b("icon"),"shrink-0",u[p].height,u[p].width)}))});f.displayName="Icon"},49804:function(t,e,o){o.d(e,{Z:function(){return s}});var r=o(5853),n=o(13241),a=o(1153),i=o(2265),l=o(9496);let c=(0,a.fn)("Col"),s=i.forwardRef((t,e)=>{let{numColSpan:o=1,numColSpanSm:a,numColSpanMd:s,numColSpanLg:d,children:u,className:m}=t,g=(0,r._T)(t,["numColSpan","numColSpanSm","numColSpanMd","numColSpanLg","children","className"]),b=(t,e)=>t&&Object.keys(e).includes(String(t))?e[t]:"";return i.createElement("div",Object.assign({ref:e,className:(0,n.q)(c("root"),(()=>{let t=b(o,l.PT),e=b(a,l.SP),r=b(s,l.VS),i=b(d,l._w);return(0,n.q)(t,e,r,i)})(),m)},g),u)});s.displayName="Col"},33866:function(t,e,o){o.d(e,{Z:function(){return R}});var r=o(2265),n=o(36760),a=o.n(n),i=o(66632),l=o(93350),c=o(19722),s=o(71744),d=o(93463),u=o(12918),m=o(18536),g=o(71140),b=o(99320);let f=new d.E4("antStatusProcessing",{"0%":{transform:"scale(0.8)",opacity:.5},"100%":{transform:"scale(2.4)",opacity:0}}),p=new d.E4("antZoomBadgeIn",{"0%":{transform:"scale(0) translate(50%, -50%)",opacity:0},"100%":{transform:"scale(1) translate(50%, -50%)"}}),h=new d.E4("antZoomBadgeOut",{"0%":{transform:"scale(1) translate(50%, -50%)"},"100%":{transform:"scale(0) translate(50%, -50%)",opacity:0}}),v=new d.E4("antNoWrapperZoomBadgeIn",{"0%":{transform:"scale(0)",opacity:0},"100%":{transform:"scale(1)"}}),w=new d.E4("antNoWrapperZoomBadgeOut",{"0%":{transform:"scale(1)"},"100%":{transform:"scale(0)",opacity:0}}),k=new d.E4("antBadgeLoadingCircle",{"0%":{transformOrigin:"50%"},"100%":{transform:"translate(50%, -50%) rotate(360deg)",transformOrigin:"50%"}}),x=t=>{let{componentCls:e,iconCls:o,antCls:r,badgeShadowSize:n,textFontSize:a,textFontSizeSM:i,statusSize:l,dotSize:c,textFontWeight:s,indicatorHeight:g,indicatorHeightSM:b,marginXS:x,calc:C}=t,y="".concat(r,"-scroll-number"),O=(0,m.Z)(t,(t,o)=>{let{darkColor:r}=o;return{["&".concat(e," ").concat(e,"-color-").concat(t)]:{background:r,["&:not(".concat(e,"-count)")]:{color:r},"a:hover &":{background:r}}}});return{[e]:Object.assign(Object.assign(Object.assign(Object.assign({},(0,u.Wf)(t)),{position:"relative",display:"inline-block",width:"fit-content",lineHeight:1,["".concat(e,"-count")]:{display:"inline-flex",justifyContent:"center",zIndex:t.indicatorZIndex,minWidth:g,height:g,color:t.badgeTextColor,fontWeight:s,fontSize:a,lineHeight:(0,d.bf)(g),whiteSpace:"nowrap",textAlign:"center",background:t.badgeColor,borderRadius:C(g).div(2).equal(),boxShadow:"0 0 0 ".concat((0,d.bf)(n)," ").concat(t.badgeShadowColor),transition:"background ".concat(t.motionDurationMid),a:{color:t.badgeTextColor},"a:hover":{color:t.badgeTextColor},"a:hover &":{background:t.badgeColorHover}},["".concat(e,"-count-sm")]:{minWidth:b,height:b,fontSize:i,lineHeight:(0,d.bf)(b),borderRadius:C(b).div(2).equal()},["".concat(e,"-multiple-words")]:{padding:"0 ".concat((0,d.bf)(t.paddingXS)),bdi:{unicodeBidi:"plaintext"}},["".concat(e,"-dot")]:{zIndex:t.indicatorZIndex,width:c,minWidth:c,height:c,background:t.badgeColor,borderRadius:"100%",boxShadow:"0 0 0 ".concat((0,d.bf)(n)," ").concat(t.badgeShadowColor)},["".concat(e,"-count, ").concat(e,"-dot, ").concat(y,"-custom-component")]:{position:"absolute",top:0,insetInlineEnd:0,transform:"translate(50%, -50%)",transformOrigin:"100% 0%",["&".concat(o,"-spin")]:{animationName:k,animationDuration:"1s",animationIterationCount:"infinite",animationTimingFunction:"linear"}},["&".concat(e,"-status")]:{lineHeight:"inherit",verticalAlign:"baseline",["".concat(e,"-status-dot")]:{position:"relative",top:-1,display:"inline-block",width:l,height:l,verticalAlign:"middle",borderRadius:"50%"},["".concat(e,"-status-success")]:{backgroundColor:t.colorSuccess},["".concat(e,"-status-processing")]:{overflow:"visible",color:t.colorInfo,backgroundColor:t.colorInfo,borderColor:"currentcolor","&::after":{position:"absolute",top:0,insetInlineStart:0,width:"100%",height:"100%",borderWidth:n,borderStyle:"solid",borderColor:"inherit",borderRadius:"50%",animationName:f,animationDuration:t.badgeProcessingDuration,animationIterationCount:"infinite",animationTimingFunction:"ease-in-out",content:'""'}},["".concat(e,"-status-default")]:{backgroundColor:t.colorTextPlaceholder},["".concat(e,"-status-error")]:{backgroundColor:t.colorError},["".concat(e,"-status-warning")]:{backgroundColor:t.colorWarning},["".concat(e,"-status-text")]:{marginInlineStart:x,color:t.colorText,fontSize:t.fontSize}}}),O),{["".concat(e,"-zoom-appear, ").concat(e,"-zoom-enter")]:{animationName:p,animationDuration:t.motionDurationSlow,animationTimingFunction:t.motionEaseOutBack,animationFillMode:"both"},["".concat(e,"-zoom-leave")]:{animationName:h,animationDuration:t.motionDurationSlow,animationTimingFunction:t.motionEaseOutBack,animationFillMode:"both"},["&".concat(e,"-not-a-wrapper")]:{["".concat(e,"-zoom-appear, ").concat(e,"-zoom-enter")]:{animationName:v,animationDuration:t.motionDurationSlow,animationTimingFunction:t.motionEaseOutBack},["".concat(e,"-zoom-leave")]:{animationName:w,animationDuration:t.motionDurationSlow,animationTimingFunction:t.motionEaseOutBack},["&:not(".concat(e,"-status)")]:{verticalAlign:"middle"},["".concat(y,"-custom-component, ").concat(e,"-count")]:{transform:"none"},["".concat(y,"-custom-component, ").concat(y)]:{position:"relative",top:"auto",display:"block",transformOrigin:"50% 50%"}},[y]:{overflow:"hidden",transition:"all ".concat(t.motionDurationMid," ").concat(t.motionEaseOutBack),["".concat(y,"-only")]:{position:"relative",display:"inline-block",height:g,transition:"all ".concat(t.motionDurationSlow," ").concat(t.motionEaseOutBack),WebkitTransformStyle:"preserve-3d",WebkitBackfaceVisibility:"hidden",["> p".concat(y,"-only-unit")]:{height:g,margin:0,WebkitTransformStyle:"preserve-3d",WebkitBackfaceVisibility:"hidden"}},["".concat(y,"-symbol")]:{verticalAlign:"top"}},"&-rtl":{direction:"rtl",["".concat(e,"-count, ").concat(e,"-dot, ").concat(y,"-custom-component")]:{transform:"translate(-50%, -50%)"}}})}},C=t=>{let{fontHeight:e,lineWidth:o,marginXS:r,colorBorderBg:n}=t,a=t.colorTextLightSolid,i=t.colorError,l=t.colorErrorHover;return(0,g.IX)(t,{badgeFontHeight:e,badgeShadowSize:o,badgeTextColor:a,badgeColor:i,badgeColorHover:l,badgeShadowColor:n,badgeProcessingDuration:"1.2s",badgeRibbonOffset:r,badgeRibbonCornerTransform:"scaleY(0.75)",badgeRibbonCornerFilter:"brightness(75%)"})},y=t=>{let{fontSize:e,lineHeight:o,fontSizeSM:r,lineWidth:n}=t;return{indicatorZIndex:"auto",indicatorHeight:Math.round(e*o)-2*n,indicatorHeightSM:e,dotSize:r/2,textFontSize:r,textFontSizeSM:r,textFontWeight:"normal",statusSize:r/2}};var O=(0,b.I$)("Badge",t=>x(C(t)),y);let j=t=>{let{antCls:e,badgeFontHeight:o,marginXS:r,badgeRibbonOffset:n,calc:a}=t,i="".concat(e,"-ribbon"),l=(0,m.Z)(t,(t,e)=>{let{darkColor:o}=e;return{["&".concat(i,"-color-").concat(t)]:{background:o,color:o}}});return{["".concat(e,"-ribbon-wrapper")]:{position:"relative"},[i]:Object.assign(Object.assign(Object.assign(Object.assign({},(0,u.Wf)(t)),{position:"absolute",top:r,padding:"0 ".concat((0,d.bf)(t.paddingXS)),color:t.colorPrimary,lineHeight:(0,d.bf)(o),whiteSpace:"nowrap",backgroundColor:t.colorPrimary,borderRadius:t.borderRadiusSM,["".concat(i,"-text")]:{color:t.badgeTextColor},["".concat(i,"-corner")]:{position:"absolute",top:"100%",width:n,height:n,color:"currentcolor",border:"".concat((0,d.bf)(a(n).div(2).equal())," solid"),transform:t.badgeRibbonCornerTransform,transformOrigin:"top",filter:t.badgeRibbonCornerFilter}}),l),{["&".concat(i,"-placement-end")]:{insetInlineEnd:a(n).mul(-1).equal(),borderEndEndRadius:0,["".concat(i,"-corner")]:{insetInlineEnd:0,borderInlineEndColor:"transparent",borderBlockEndColor:"transparent"}},["&".concat(i,"-placement-start")]:{insetInlineStart:a(n).mul(-1).equal(),borderEndStartRadius:0,["".concat(i,"-corner")]:{insetInlineStart:0,borderBlockEndColor:"transparent",borderInlineStartColor:"transparent"}},"&-rtl":{direction:"rtl"}})}};var S=(0,b.I$)(["Badge","Ribbon"],t=>j(C(t)),y);let E=t=>{let e;let{prefixCls:o,value:n,current:i,offset:l=0}=t;return l&&(e={position:"absolute",top:"".concat(l,"00%"),left:0}),r.createElement("span",{style:e,className:a()("".concat(o,"-only-unit"),{current:i})},n)};var N=t=>{let e,o;let{prefixCls:n,count:a,value:i}=t,l=Number(i),c=Math.abs(a),[s,d]=r.useState(l),[u,m]=r.useState(c),g=()=>{d(l),m(c)};if(r.useEffect(()=>{let t=setTimeout(g,1e3);return()=>clearTimeout(t)},[l]),s===l||Number.isNaN(l)||Number.isNaN(s))e=[r.createElement(E,Object.assign({},t,{key:l,current:!0}))],o={transition:"none"};else{e=[];let n=l+10,a=[];for(let t=l;t<=n;t+=1)a.push(t);let i=ut%10===s);e=(i<0?a.slice(0,d+1):a.slice(d)).map((e,o)=>r.createElement(E,Object.assign({},t,{key:e,value:e%10,offset:i<0?o-d:o,current:o===d}))),o={transform:"translateY(".concat(-function(t,e,o){let r=t,n=0;for(;(r+10)%10!==e;)r+=o,n+=o;return n}(s,l,i),"00%)")}}return r.createElement("span",{className:"".concat(n,"-only"),style:o,onTransitionEnd:g},e)},M=function(t,e){var o={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&0>e.indexOf(r)&&(o[r]=t[r]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols)for(var n=0,r=Object.getOwnPropertySymbols(t);ne.indexOf(r[n])&&Object.prototype.propertyIsEnumerable.call(t,r[n])&&(o[r[n]]=t[r[n]]);return o};let z=r.forwardRef((t,e)=>{let{prefixCls:o,count:n,className:i,motionClassName:l,style:d,title:u,show:m,component:g="sup",children:b}=t,f=M(t,["prefixCls","count","className","motionClassName","style","title","show","component","children"]),{getPrefixCls:p}=r.useContext(s.E_),h=p("scroll-number",o),v=Object.assign(Object.assign({},f),{"data-show":m,style:d,className:a()(h,i,l),title:u}),w=n;if(n&&Number(n)%1==0){let t=String(n).split("");w=r.createElement("bdi",null,t.map((e,o)=>r.createElement(N,{prefixCls:h,count:Number(n),value:e,key:t.length-o})))}return((null==d?void 0:d.borderColor)&&(v.style=Object.assign(Object.assign({},d),{boxShadow:"0 0 0 1px ".concat(d.borderColor," inset")})),b)?(0,c.Tm)(b,t=>({className:a()("".concat(h,"-custom-component"),null==t?void 0:t.className,l)})):r.createElement(g,Object.assign({},v,{ref:e}),w)});var B=function(t,e){var o={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&0>e.indexOf(r)&&(o[r]=t[r]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols)for(var n=0,r=Object.getOwnPropertySymbols(t);ne.indexOf(r[n])&&Object.prototype.propertyIsEnumerable.call(t,r[n])&&(o[r[n]]=t[r[n]]);return o};let Z=r.forwardRef((t,e)=>{var o,n,d,u,m;let{prefixCls:g,scrollNumberPrefixCls:b,children:f,status:p,text:h,color:v,count:w=null,overflowCount:k=99,dot:x=!1,size:C="default",title:y,offset:j,style:S,className:E,rootClassName:N,classNames:M,styles:Z,showZero:R=!1}=t,L=B(t,["prefixCls","scrollNumberPrefixCls","children","status","text","color","count","overflowCount","dot","size","title","offset","style","className","rootClassName","classNames","styles","showZero"]),{getPrefixCls:T,direction:I,badge:H}=r.useContext(s.E_),P=T("badge",g),[W,D,F]=O(P),q=w>k?"".concat(k,"+"):w,A="0"===q||0===q||"0"===h||0===h,X=null===w||A&&!R,_=(null!=p||null!=v)&&X,V=null!=p||!A,K=x&&!A,Y=K?"":q,G=(0,r.useMemo)(()=>((null==Y||""===Y)&&(null==h||""===h)||A&&!R)&&!K,[Y,A,R,K,h]),Q=(0,r.useRef)(w);G||(Q.current=w);let $=Q.current,J=(0,r.useRef)(Y);G||(J.current=Y);let U=J.current,tt=(0,r.useRef)(K);G||(tt.current=K);let te=(0,r.useMemo)(()=>{if(!j)return Object.assign(Object.assign({},null==H?void 0:H.style),S);let t={marginTop:j[1]};return"rtl"===I?t.left=Number.parseInt(j[0],10):t.right=-Number.parseInt(j[0],10),Object.assign(Object.assign(Object.assign({},t),null==H?void 0:H.style),S)},[I,j,S,null==H?void 0:H.style]),to=null!=y?y:"string"==typeof $||"number"==typeof $?$:void 0,tr=!G&&(0===h?R:!!h&&!0!==h),tn=tr?r.createElement("span",{className:"".concat(P,"-status-text")},h):null,ta=$&&"object"==typeof $?(0,c.Tm)($,t=>({style:Object.assign(Object.assign({},te),t.style)})):void 0,ti=(0,l.o2)(v,!1),tl=a()(null==M?void 0:M.indicator,null===(o=null==H?void 0:H.classNames)||void 0===o?void 0:o.indicator,{["".concat(P,"-status-dot")]:_,["".concat(P,"-status-").concat(p)]:!!p,["".concat(P,"-color-").concat(v)]:ti}),tc={};v&&!ti&&(tc.color=v,tc.background=v);let ts=a()(P,{["".concat(P,"-status")]:_,["".concat(P,"-not-a-wrapper")]:!f,["".concat(P,"-rtl")]:"rtl"===I},E,N,null==H?void 0:H.className,null===(n=null==H?void 0:H.classNames)||void 0===n?void 0:n.root,null==M?void 0:M.root,D,F);if(!f&&_&&(h||V||!X)){let t=te.color;return W(r.createElement("span",Object.assign({},L,{className:ts,style:Object.assign(Object.assign(Object.assign({},null==Z?void 0:Z.root),null===(d=null==H?void 0:H.styles)||void 0===d?void 0:d.root),te)}),r.createElement("span",{className:tl,style:Object.assign(Object.assign(Object.assign({},null==Z?void 0:Z.indicator),null===(u=null==H?void 0:H.styles)||void 0===u?void 0:u.indicator),tc)}),tr&&r.createElement("span",{style:{color:t},className:"".concat(P,"-status-text")},h)))}return W(r.createElement("span",Object.assign({ref:e},L,{className:ts,style:Object.assign(Object.assign({},null===(m=null==H?void 0:H.styles)||void 0===m?void 0:m.root),null==Z?void 0:Z.root)}),f,r.createElement(i.ZP,{visible:!G,motionName:"".concat(P,"-zoom"),motionAppear:!1,motionDeadline:1e3},t=>{var e,o;let{className:n}=t,i=T("scroll-number",b),l=tt.current,c=a()(null==M?void 0:M.indicator,null===(e=null==H?void 0:H.classNames)||void 0===e?void 0:e.indicator,{["".concat(P,"-dot")]:l,["".concat(P,"-count")]:!l,["".concat(P,"-count-sm")]:"small"===C,["".concat(P,"-multiple-words")]:!l&&U&&U.toString().length>1,["".concat(P,"-status-").concat(p)]:!!p,["".concat(P,"-color-").concat(v)]:ti}),s=Object.assign(Object.assign(Object.assign({},null==Z?void 0:Z.indicator),null===(o=null==H?void 0:H.styles)||void 0===o?void 0:o.indicator),te);return v&&!ti&&((s=s||{}).background=v),r.createElement(z,{prefixCls:i,show:!G,motionClassName:n,className:c,count:U,title:to,style:s,key:"scrollNumber"},ta)}),tn))});Z.Ribbon=t=>{let{className:e,prefixCls:o,style:n,color:i,children:c,text:d,placement:u="end",rootClassName:m}=t,{getPrefixCls:g,direction:b}=r.useContext(s.E_),f=g("ribbon",o),p="".concat(f,"-wrapper"),[h,v,w]=S(f,p),k=(0,l.o2)(i,!1),x=a()(f,"".concat(f,"-placement-").concat(u),{["".concat(f,"-rtl")]:"rtl"===b,["".concat(f,"-color-").concat(i)]:k},e),C={},y={};return i&&!k&&(C.background=i,y.color=i),h(r.createElement("div",{className:a()(p,m,v,w)},c,r.createElement("div",{className:a()(x,v),style:Object.assign(Object.assign({},C),n)},r.createElement("span",{className:"".concat(f,"-text")},d),r.createElement("div",{className:"".concat(f,"-corner"),style:y}))))};var R=Z},2651:function(t,e,o){o.d(e,{Z:function(){return w}});var r=o(93463),n=o(11938),a=o(70774),i=o(73602),l=o(91691),c=o(25119),s=o(37628),d=o(32417),u=o(4877),m=o(57943),g=o(12789),b=o(54558);let f=(t,e)=>new b.t(t).setA(e).toRgbString(),p=(t,e)=>new b.t(t).lighten(e).toHexString(),h=t=>{let e=(0,m.R_)(t,{theme:"dark"});return{1:e[0],2:e[1],3:e[2],4:e[3],5:e[6],6:e[5],7:e[4],8:e[6],9:e[5],10:e[4]}},v=(t,e)=>{let o=t||"#000",r=e||"#fff";return{colorBgBase:o,colorTextBase:r,colorText:f(r,.85),colorTextSecondary:f(r,.65),colorTextTertiary:f(r,.45),colorTextQuaternary:f(r,.25),colorFill:f(r,.18),colorFillSecondary:f(r,.12),colorFillTertiary:f(r,.08),colorFillQuaternary:f(r,.04),colorBgSolid:f(r,.95),colorBgSolidHover:f(r,1),colorBgSolidActive:f(r,.9),colorBgElevated:p(o,12),colorBgContainer:p(o,8),colorBgLayout:p(o,0),colorBgSpotlight:p(o,26),colorBgBlur:f(r,.04),colorBorder:p(o,26),colorBorderSecondary:p(o,19)}};var w={defaultSeed:c.u_.token,useToken:function(){let[t,e,o]=(0,l.ZP)();return{theme:t,token:e,hashId:o}},defaultAlgorithm:s.Z,darkAlgorithm:(t,e)=>{let o=Object.keys(a.M).map(e=>{let o=(0,m.R_)(t[e],{theme:"dark"});return Array.from({length:10},()=>1).reduce((t,r,n)=>(t["".concat(e,"-").concat(n+1)]=o[n],t["".concat(e).concat(n+1)]=o[n],t),{})}).reduce((t,e)=>t=Object.assign(Object.assign({},t),e),{}),r=null!=e?e:(0,s.Z)(t),n=(0,g.Z)(t,{generateColorPalettes:h,generateNeutralColorPalettes:v});return Object.assign(Object.assign(Object.assign(Object.assign({},r),o),n),{colorPrimaryBg:n.colorPrimaryBorder,colorPrimaryBgHover:n.colorPrimaryBorderHover})},compactAlgorithm:(t,e)=>{let o=null!=e?e:(0,s.Z)(t),r=o.fontSizeSM,n=o.controlHeight-4;return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},o),function(t){let{sizeUnit:e,sizeStep:o}=t,r=o-2;return{sizeXXL:e*(r+10),sizeXL:e*(r+6),sizeLG:e*(r+2),sizeMD:e*(r+2),sizeMS:e*(r+1),size:e*r,sizeSM:e*r,sizeXS:e*(r-1),sizeXXS:e*(r-1)}}(null!=e?e:t)),(0,u.Z)(r)),{controlHeight:n}),(0,d.Z)(Object.assign(Object.assign({},o),{controlHeight:n})))},getDesignToken:t=>{let e=(null==t?void 0:t.algorithm)?(0,r.jG)(t.algorithm):n.Z,o=Object.assign(Object.assign({},a.Z),null==t?void 0:t.token);return(0,r.t2)(o,{override:null==t?void 0:t.token},e,i.Z)},defaultConfig:c.u_,_internalContext:c.Mj}},10900:function(t,e,o){var r=o(2265);let n=r.forwardRef(function(t,e){return r.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:2,stroke:"currentColor","aria-hidden":"true",ref:e},t),r.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M10 19l-7-7m0 0l7-7m-7 7h18"}))});e.Z=n},86462:function(t,e,o){var r=o(2265);let n=r.forwardRef(function(t,e){return r.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:2,stroke:"currentColor","aria-hidden":"true",ref:e},t),r.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19 9l-7 7-7-7"}))});e.Z=n},44633:function(t,e,o){var r=o(2265);let n=r.forwardRef(function(t,e){return r.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:2,stroke:"currentColor","aria-hidden":"true",ref:e},t),r.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 15l7-7 7 7"}))});e.Z=n},3477:function(t,e,o){var r=o(2265);let n=r.forwardRef(function(t,e){return r.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:2,stroke:"currentColor","aria-hidden":"true",ref:e},t),r.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M10 6H6a2 2 0 00-2 2v10a2 2 0 002 2h10a2 2 0 002-2v-4M14 4h6m0 0v6m0-6L10 14"}))});e.Z=n},53410:function(t,e,o){var r=o(2265);let n=r.forwardRef(function(t,e){return r.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:2,stroke:"currentColor","aria-hidden":"true",ref:e},t),r.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z"}))});e.Z=n},91126:function(t,e,o){var r=o(2265);let n=r.forwardRef(function(t,e){return r.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:2,stroke:"currentColor","aria-hidden":"true",ref:e},t),r.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M14.752 11.168l-3.197-2.132A1 1 0 0010 9.87v4.263a1 1 0 001.555.832l3.197-2.132a1 1 0 000-1.664z"}),r.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M21 12a9 9 0 11-18 0 9 9 0 0118 0z"}))});e.Z=n},23628:function(t,e,o){var r=o(2265);let n=r.forwardRef(function(t,e){return r.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:2,stroke:"currentColor","aria-hidden":"true",ref:e},t),r.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"}))});e.Z=n},49084:function(t,e,o){var r=o(2265);let n=r.forwardRef(function(t,e){return r.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:2,stroke:"currentColor","aria-hidden":"true",ref:e},t),r.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M7 16V4m0 0L3 8m4-4l4 4m6 0v12m0 0l4-4m-4 4l-4-4"}))});e.Z=n},74998:function(t,e,o){var r=o(2265);let n=r.forwardRef(function(t,e){return r.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:2,stroke:"currentColor","aria-hidden":"true",ref:e},t),r.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16"}))});e.Z=n}}]); \ No newline at end of file diff --git a/litellm/proxy/_experimental/out/_next/static/chunks/1300460219810c10.js b/litellm/proxy/_experimental/out/_next/static/chunks/1300460219810c10.js new file mode 100644 index 00000000000..4056b191841 --- /dev/null +++ b/litellm/proxy/_experimental/out/_next/static/chunks/1300460219810c10.js @@ -0,0 +1,4 @@ +(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,312718,(e,t,r)=>{"use strict";Object.defineProperty(r,"__esModule",{value:!0}),Object.defineProperty(r,"InvariantError",{enumerable:!0,get:function(){return n}});class n extends Error{constructor(e,t){super(`Invariant: ${e.endsWith(".")?e:e+"."} This is a bug in Next.js.`,t),this.name="InvariantError"}}},563141,(e,t,r)=>{"use strict";r._=function(e){return e&&e.__esModule?e:{default:e}}},132061,(e,t,r)=>{"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n={BailoutToCSRError:function(){return u},isBailoutToCSRError:function(){return i}};for(var o in n)Object.defineProperty(r,o,{enumerable:!0,get:n[o]});let a="BAILOUT_TO_CLIENT_SIDE_RENDERING";class u extends Error{constructor(e){super(`Bail out to client-side rendering: ${e}`),this.reason=e,this.digest=a}}function i(e){return"object"==typeof e&&null!==e&&"digest"in e&&e.digest===a}},754394,(e,t,r)=>{"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n={HTTPAccessErrorStatus:function(){return a},HTTP_ERROR_FALLBACK_ERROR_CODE:function(){return i},getAccessFallbackErrorTypeByStatus:function(){return l},getAccessFallbackHTTPStatus:function(){return s},isHTTPAccessFallbackError:function(){return c}};for(var o in n)Object.defineProperty(r,o,{enumerable:!0,get:n[o]});let a={NOT_FOUND:404,FORBIDDEN:403,UNAUTHORIZED:401},u=new Set(Object.values(a)),i="NEXT_HTTP_ERROR_FALLBACK";function c(e){if("object"!=typeof e||null===e||!("digest"in e)||"string"!=typeof e.digest)return!1;let[t,r]=e.digest.split(";");return t===i&&u.has(Number(r))}function s(e){return Number(e.digest.split(";")[1])}function l(e){switch(e){case 401:return"unauthorized";case 403:return"forbidden";case 404:return"not-found";default:return}}("function"==typeof r.default||"object"==typeof r.default&&null!==r.default)&&void 0===r.default.__esModule&&(Object.defineProperty(r.default,"__esModule",{value:!0}),Object.assign(r.default,r),t.exports=r.default)},476963,(e,t,r)=>{"use strict";Object.defineProperty(r,"__esModule",{value:!0}),Object.defineProperty(r,"RedirectStatusCode",{enumerable:!0,get:function(){return o}});var n,o=((n={})[n.SeeOther=303]="SeeOther",n[n.TemporaryRedirect=307]="TemporaryRedirect",n[n.PermanentRedirect=308]="PermanentRedirect",n);("function"==typeof r.default||"object"==typeof r.default&&null!==r.default)&&void 0===r.default.__esModule&&(Object.defineProperty(r.default,"__esModule",{value:!0}),Object.assign(r.default,r),t.exports=r.default)},968391,(e,t,r)=>{"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n,o={REDIRECT_ERROR_CODE:function(){return i},RedirectType:function(){return c},isRedirectError:function(){return s}};for(var a in o)Object.defineProperty(r,a,{enumerable:!0,get:o[a]});let u=e.r(476963),i="NEXT_REDIRECT";var c=((n={}).push="push",n.replace="replace",n);function s(e){if("object"!=typeof e||null===e||!("digest"in e)||"string"!=typeof e.digest)return!1;let t=e.digest.split(";"),[r,n]=t,o=t.slice(2,-2).join(";"),a=Number(t.at(-2));return r===i&&("replace"===n||"push"===n)&&"string"==typeof o&&!isNaN(a)&&a in u.RedirectStatusCode}("function"==typeof r.default||"object"==typeof r.default&&null!==r.default)&&void 0===r.default.__esModule&&(Object.defineProperty(r.default,"__esModule",{value:!0}),Object.assign(r.default,r),t.exports=r.default)},265713,(e,t,r)=>{"use strict";Object.defineProperty(r,"__esModule",{value:!0}),Object.defineProperty(r,"isNextRouterError",{enumerable:!0,get:function(){return a}});let n=e.r(754394),o=e.r(968391);function a(e){return(0,o.isRedirectError)(e)||(0,n.isHTTPAccessFallbackError)(e)}("function"==typeof r.default||"object"==typeof r.default&&null!==r.default)&&void 0===r.default.__esModule&&(Object.defineProperty(r.default,"__esModule",{value:!0}),Object.assign(r.default,r),t.exports=r.default)},903680,(e,t,r)=>{"use strict";Object.defineProperty(r,"__esModule",{value:!0}),Object.defineProperty(r,"ReadonlyURLSearchParams",{enumerable:!0,get:function(){return o}});class n extends Error{constructor(){super("Method unavailable on `ReadonlyURLSearchParams`. Read more: https://nextjs.org/docs/app/api-reference/functions/use-search-params#updating-searchparams")}}class o extends URLSearchParams{append(){throw new n}delete(){throw new n}set(){throw new n}sort(){throw new n}}("function"==typeof r.default||"object"==typeof r.default&&null!==r.default)&&void 0===r.default.__esModule&&(Object.defineProperty(r.default,"__esModule",{value:!0}),Object.assign(r.default,r),t.exports=r.default)},261994,(e,t,r)=>{"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n={NavigationPromisesContext:function(){return l},PathParamsContext:function(){return s},PathnameContext:function(){return c},ReadonlyURLSearchParams:function(){return u.ReadonlyURLSearchParams},SearchParamsContext:function(){return i},createDevToolsInstrumentedPromise:function(){return d}};for(var o in n)Object.defineProperty(r,o,{enumerable:!0,get:n[o]});let a=e.r(271645),u=e.r(903680),i=(0,a.createContext)(null),c=(0,a.createContext)(null),s=(0,a.createContext)(null),l=(0,a.createContext)(null);function d(e,t){let r=Promise.resolve(t);return r.status="fulfilled",r.value=t,r.displayName=`${e} (SSR)`,r}},245955,(e,t,r)=>{"use strict";Object.defineProperty(r,"__esModule",{value:!0}),Object.defineProperty(r,"workUnitAsyncStorageInstance",{enumerable:!0,get:function(){return n}});let n=(0,e.r(90317).createAsyncLocalStorage)()},621768,(e,t,r)=>{"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n={ACTION_HEADER:function(){return u},FLIGHT_HEADERS:function(){return y},NEXT_ACTION_NOT_FOUND_HEADER:function(){return R},NEXT_ACTION_REVALIDATED_HEADER:function(){return P},NEXT_DID_POSTPONE_HEADER:function(){return h},NEXT_HMR_REFRESH_HASH_COOKIE:function(){return d},NEXT_HMR_REFRESH_HEADER:function(){return l},NEXT_HTML_REQUEST_ID_HEADER:function(){return v},NEXT_IS_PRERENDER_HEADER:function(){return g},NEXT_REQUEST_ID_HEADER:function(){return O},NEXT_REWRITTEN_PATH_HEADER:function(){return b},NEXT_REWRITTEN_QUERY_HEADER:function(){return E},NEXT_ROUTER_PREFETCH_HEADER:function(){return c},NEXT_ROUTER_SEGMENT_PREFETCH_HEADER:function(){return s},NEXT_ROUTER_STALE_TIME_HEADER:function(){return m},NEXT_ROUTER_STATE_TREE_HEADER:function(){return i},NEXT_RSC_UNION_QUERY:function(){return _},NEXT_URL:function(){return f},RSC_CONTENT_TYPE_HEADER:function(){return p},RSC_HEADER:function(){return a}};for(var o in n)Object.defineProperty(r,o,{enumerable:!0,get:n[o]});let a="rsc",u="next-action",i="next-router-state-tree",c="next-router-prefetch",s="next-router-segment-prefetch",l="next-hmr-refresh",d="__next_hmr_refresh_hash__",f="next-url",p="text/x-component",y=[a,i,c,l,s],_="_rsc",m="x-nextjs-stale-time",h="x-nextjs-postponed",b="x-nextjs-rewritten-path",E="x-nextjs-rewritten-query",g="x-nextjs-prerender",R="x-nextjs-action-not-found",O="x-nextjs-request-id",v="x-nextjs-html-request-id",P="x-action-revalidated";("function"==typeof r.default||"object"==typeof r.default&&null!==r.default)&&void 0===r.default.__esModule&&(Object.defineProperty(r.default,"__esModule",{value:!0}),Object.assign(r.default,r),t.exports=r.default)},662141,(e,t,r)=>{"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n={getCacheSignal:function(){return m},getDraftModeProviderForCacheScope:function(){return _},getHmrRefreshHash:function(){return f},getPrerenderResumeDataCache:function(){return l},getRenderResumeDataCache:function(){return d},getRuntimeStagePromise:function(){return h},getServerComponentsHmrCache:function(){return y},isHmrRefresh:function(){return p},throwForMissingRequestStore:function(){return c},throwInvariantForMissingStore:function(){return s},workUnitAsyncStorage:function(){return a.workUnitAsyncStorageInstance}};for(var o in n)Object.defineProperty(r,o,{enumerable:!0,get:n[o]});let a=e.r(245955),u=e.r(621768),i=e.r(312718);function c(e){throw Object.defineProperty(Error(`\`${e}\` was called outside a request scope. Read more: https://nextjs.org/docs/messages/next-dynamic-api-wrong-context`),"__NEXT_ERROR_CODE",{value:"E251",enumerable:!1,configurable:!0})}function s(){throw Object.defineProperty(new i.InvariantError("Expected workUnitAsyncStorage to have a store."),"__NEXT_ERROR_CODE",{value:"E696",enumerable:!1,configurable:!0})}function l(e){switch(e.type){case"prerender":case"prerender-runtime":case"prerender-ppr":case"prerender-client":return e.prerenderResumeDataCache;case"request":if(e.prerenderResumeDataCache)return e.prerenderResumeDataCache;case"prerender-legacy":case"cache":case"private-cache":case"unstable-cache":return null;default:return e}}function d(e){switch(e.type){case"request":case"prerender":case"prerender-runtime":case"prerender-client":if(e.renderResumeDataCache)return e.renderResumeDataCache;case"prerender-ppr":return e.prerenderResumeDataCache??null;case"cache":case"private-cache":case"unstable-cache":case"prerender-legacy":return null;default:return e}}function f(e,t){if(e.dev)switch(t.type){case"cache":case"private-cache":case"prerender":case"prerender-runtime":return t.hmrRefreshHash;case"request":var r;return null==(r=t.cookies.get(u.NEXT_HMR_REFRESH_HASH_COOKIE))?void 0:r.value}}function p(e,t){if(e.dev)switch(t.type){case"cache":case"private-cache":case"request":return t.isHmrRefresh??!1}return!1}function y(e,t){if(e.dev)switch(t.type){case"cache":case"private-cache":case"request":return t.serverComponentsHmrCache}}function _(e,t){if(e.isDraftMode)switch(t.type){case"cache":case"private-cache":case"unstable-cache":case"prerender-runtime":case"request":return t.draftMode}}function m(e){switch(e.type){case"prerender":case"prerender-client":case"prerender-runtime":return e.cacheSignal;case"request":if(e.cacheSignal)return e.cacheSignal;case"prerender-ppr":case"prerender-legacy":case"cache":case"private-cache":case"unstable-cache":return null;default:return e}}function h(e){switch(e.type){case"prerender-runtime":case"private-cache":return e.runtimeStagePromise;case"prerender":case"prerender-client":case"prerender-ppr":case"prerender-legacy":case"request":case"cache":case"unstable-cache":return null;default:return e}}},151836,(e,t,r)=>{"use strict";function n(e){if("function"!=typeof WeakMap)return null;var t=new WeakMap,r=new WeakMap;return(n=function(e){return e?r:t})(e)}r._=function(e,t){if(!t&&e&&e.__esModule)return e;if(null===e||"object"!=typeof e&&"function"!=typeof e)return{default:e};var r=n(t);if(r&&r.has(e))return r.get(e);var o={__proto__:null},a=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var u in e)if("default"!==u&&Object.prototype.hasOwnProperty.call(e,u)){var i=a?Object.getOwnPropertyDescriptor(e,u):null;i&&(i.get||i.set)?Object.defineProperty(o,u,i):o[u]=e[u]}return o.default=e,r&&r.set(e,o),o}},813258,(e,t,r)=>{"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n={DEFAULT_SEGMENT_KEY:function(){return d},NOT_FOUND_SEGMENT_KEY:function(){return f},PAGE_SEGMENT_KEY:function(){return l},addSearchParamsIfPageSegment:function(){return c},computeSelectedLayoutSegment:function(){return s},getSegmentValue:function(){return a},getSelectedLayoutSegmentPath:function(){return function e(t,r,n=!0,o=[]){let u;if(n)u=t[1][r];else{let e=t[1];u=e.children??Object.values(e)[0]}if(!u)return o;let i=a(u[0]);return!i||i.startsWith(l)?o:(o.push(i),e(u,r,!1,o))}},isGroupSegment:function(){return u},isParallelRouteSegment:function(){return i}};for(var o in n)Object.defineProperty(r,o,{enumerable:!0,get:n[o]});function a(e){return Array.isArray(e)?e[1]:e}function u(e){return"("===e[0]&&e.endsWith(")")}function i(e){return e.startsWith("@")&&"@children"!==e}function c(e,t){if(e.includes(l)){let e=JSON.stringify(t);return"{}"!==e?l+"?"+e:l}return e}function s(e,t){if(!e||0===e.length)return null;let r="children"===t?e[0]:e[e.length-1];return r===d?null:r}let l="__PAGE__",d="__DEFAULT__",f="/_not-found"},292838,(e,t,r)=>{"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n={UnrecognizedActionError:function(){return a},unstable_isUnrecognizedActionError:function(){return u}};for(var o in n)Object.defineProperty(r,o,{enumerable:!0,get:n[o]});class a extends Error{constructor(...e){super(...e),this.name="UnrecognizedActionError"}}function u(e){return!!(e&&"object"==typeof e&&e instanceof a)}("function"==typeof r.default||"object"==typeof r.default&&null!==r.default)&&void 0===r.default.__esModule&&(Object.defineProperty(r.default,"__esModule",{value:!0}),Object.assign(r.default,r),t.exports=r.default)},134457,(e,t,r)=>{"use strict";Object.defineProperty(r,"__esModule",{value:!0}),Object.defineProperty(r,"actionAsyncStorageInstance",{enumerable:!0,get:function(){return n}});let n=(0,e.r(90317).createAsyncLocalStorage)()},362266,(e,t,r)=>{"use strict";Object.defineProperty(r,"__esModule",{value:!0}),Object.defineProperty(r,"actionAsyncStorage",{enumerable:!0,get:function(){return n.actionAsyncStorageInstance}});let n=e.r(134457)},124063,(e,t,r)=>{"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n={getRedirectError:function(){return c},getRedirectStatusCodeFromError:function(){return p},getRedirectTypeFromError:function(){return f},getURLFromRedirectError:function(){return d},permanentRedirect:function(){return l},redirect:function(){return s}};for(var o in n)Object.defineProperty(r,o,{enumerable:!0,get:n[o]});let a=e.r(476963),u=e.r(968391),i="u"{"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n={AppRouterContext:function(){return u},GlobalLayoutRouterContext:function(){return c},LayoutRouterContext:function(){return i},MissingSlotContext:function(){return l},TemplateContext:function(){return s}};for(var o in n)Object.defineProperty(r,o,{enumerable:!0,get:n[o]});let a=e.r(563141)._(e.r(271645)),u=a.default.createContext(null),i=a.default.createContext(null),c=a.default.createContext(null),s=a.default.createContext(null),l=a.default.createContext(new Set)},13957,(e,t,r)=>{"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n={ServerInsertedHTMLContext:function(){return u},useServerInsertedHTML:function(){return i}};for(var o in n)Object.defineProperty(r,o,{enumerable:!0,get:n[o]});let a=e.r(151836)._(e.r(271645)),u=a.default.createContext(null);function i(e){let t=(0,a.useContext)(u);t&&t(e)}},222783,(e,t,r)=>{"use strict";Object.defineProperty(r,"__esModule",{value:!0}),Object.defineProperty(r,"notFound",{enumerable:!0,get:function(){return a}});let n=e.r(754394),o=`${n.HTTP_ERROR_FALLBACK_ERROR_CODE};404`;function a(){let e=Object.defineProperty(Error(o),"__NEXT_ERROR_CODE",{value:"E394",enumerable:!1,configurable:!0});throw e.digest=o,e}("function"==typeof r.default||"object"==typeof r.default&&null!==r.default)&&void 0===r.default.__esModule&&(Object.defineProperty(r.default,"__esModule",{value:!0}),Object.assign(r.default,r),t.exports=r.default)},879854,(e,t,r)=>{"use strict";function n(){throw Object.defineProperty(Error("`forbidden()` is experimental and only allowed to be enabled when `experimental.authInterrupts` is enabled."),"__NEXT_ERROR_CODE",{value:"E488",enumerable:!1,configurable:!0})}Object.defineProperty(r,"__esModule",{value:!0}),Object.defineProperty(r,"forbidden",{enumerable:!0,get:function(){return n}}),e.r(754394).HTTP_ERROR_FALLBACK_ERROR_CODE,("function"==typeof r.default||"object"==typeof r.default&&null!==r.default)&&void 0===r.default.__esModule&&(Object.defineProperty(r.default,"__esModule",{value:!0}),Object.assign(r.default,r),t.exports=r.default)},122683,(e,t,r)=>{"use strict";function n(){throw Object.defineProperty(Error("`unauthorized()` is experimental and only allowed to be used when `experimental.authInterrupts` is enabled."),"__NEXT_ERROR_CODE",{value:"E411",enumerable:!1,configurable:!0})}Object.defineProperty(r,"__esModule",{value:!0}),Object.defineProperty(r,"unauthorized",{enumerable:!0,get:function(){return n}}),e.r(754394).HTTP_ERROR_FALLBACK_ERROR_CODE,("function"==typeof r.default||"object"==typeof r.default&&null!==r.default)&&void 0===r.default.__esModule&&(Object.defineProperty(r.default,"__esModule",{value:!0}),Object.assign(r.default,r),t.exports=r.default)},115507,(e,t,r)=>{"use strict";Object.defineProperty(r,"__esModule",{value:!0}),Object.defineProperty(r,"unstable_rethrow",{enumerable:!0,get:function(){return function e(t){if((0,o.isNextRouterError)(t)||(0,n.isBailoutToCSRError)(t))throw t;t instanceof Error&&"cause"in t&&e(t.cause)}}});let n=e.r(132061),o=e.r(265713);("function"==typeof r.default||"object"==typeof r.default&&null!==r.default)&&void 0===r.default.__esModule&&(Object.defineProperty(r.default,"__esModule",{value:!0}),Object.assign(r.default,r),t.exports=r.default)},963138,(e,t,r)=>{"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n={isHangingPromiseRejectionError:function(){return a},makeDevtoolsIOAwarePromise:function(){return d},makeHangingPromise:function(){return s}};for(var o in n)Object.defineProperty(r,o,{enumerable:!0,get:n[o]});function a(e){return"object"==typeof e&&null!==e&&"digest"in e&&e.digest===u}let u="HANGING_PROMISE_REJECTION";class i extends Error{constructor(e,t){super(`During prerendering, ${t} rejects when the prerender is complete. Typically these errors are handled by React but if you move ${t} to a different context by using \`setTimeout\`, \`after\`, or similar functions you may observe this error and you should handle it in that context. This occurred at route "${e}".`),this.route=e,this.expression=t,this.digest=u}}let c=new WeakMap;function s(e,t,r){if(e.aborted)return Promise.reject(new i(t,r));{let n=new Promise((n,o)=>{let a=o.bind(null,new i(t,r)),u=c.get(e);if(u)u.push(a);else{let t=[a];c.set(e,t),e.addEventListener("abort",()=>{for(let e=0;e{setTimeout(()=>{t(e)},0)})}},367287,(e,t,r)=>{"use strict";Object.defineProperty(r,"__esModule",{value:!0}),Object.defineProperty(r,"isPostpone",{enumerable:!0,get:function(){return o}});let n=Symbol.for("react.postpone");function o(e){return"object"==typeof e&&null!==e&&e.$$typeof===n}},476353,(e,t,r)=>{"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n={DynamicServerError:function(){return u},isDynamicServerError:function(){return i}};for(var o in n)Object.defineProperty(r,o,{enumerable:!0,get:n[o]});let a="DYNAMIC_SERVER_USAGE";class u extends Error{constructor(e){super(`Dynamic server usage: ${e}`),this.description=e,this.digest=a}}function i(e){return"object"==typeof e&&null!==e&&"digest"in e&&"string"==typeof e.digest&&e.digest===a}("function"==typeof r.default||"object"==typeof r.default&&null!==r.default)&&void 0===r.default.__esModule&&(Object.defineProperty(r.default,"__esModule",{value:!0}),Object.assign(r.default,r),t.exports=r.default)},643248,(e,t,r)=>{"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n={StaticGenBailoutError:function(){return u},isStaticGenBailoutError:function(){return i}};for(var o in n)Object.defineProperty(r,o,{enumerable:!0,get:n[o]});let a="NEXT_STATIC_GEN_BAILOUT";class u extends Error{constructor(...e){super(...e),this.code=a}}function i(e){return"object"==typeof e&&null!==e&&"code"in e&&e.code===a}("function"==typeof r.default||"object"==typeof r.default&&null!==r.default)&&void 0===r.default.__esModule&&(Object.defineProperty(r.default,"__esModule",{value:!0}),Object.assign(r.default,r),t.exports=r.default)},954839,(e,t,r)=>{"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n={METADATA_BOUNDARY_NAME:function(){return a},OUTLET_BOUNDARY_NAME:function(){return i},ROOT_LAYOUT_BOUNDARY_NAME:function(){return c},VIEWPORT_BOUNDARY_NAME:function(){return u}};for(var o in n)Object.defineProperty(r,o,{enumerable:!0,get:n[o]});let a="__next_metadata_boundary__",u="__next_viewport_boundary__",i="__next_outlet_boundary__",c="__next_root_layout_boundary__"},729419,(e,t,r)=>{"use strict";var n=e.i(247167);Object.defineProperty(r,"__esModule",{value:!0});var o={atLeastOneTask:function(){return c},scheduleImmediate:function(){return i},scheduleOnNextTick:function(){return u},waitAtLeastOneReactRenderTask:function(){return s}};for(var a in o)Object.defineProperty(r,a,{enumerable:!0,get:o[a]});let u=e=>{Promise.resolve().then(()=>{n.default.nextTick(e)})},i=e=>{setImmediate(e)};function c(){return new Promise(e=>i(e))}function s(){return new Promise(e=>setImmediate(e))}},67673,(e,t,r)=>{"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n,o,a={Postpone:function(){return T},PreludeState:function(){return J},abortAndThrowOnSynchronousRequestDataAccess:function(){return S},abortOnSynchronousPlatformIOAccess:function(){return j},accessedDynamicData:function(){return k},annotateDynamicAccess:function(){return $},consumeDynamicAccess:function(){return I},createDynamicTrackingState:function(){return b},createDynamicValidationState:function(){return E},createHangingInputAbortSignal:function(){return L},createRenderInBrowserAbortSignal:function(){return H},delayUntilRuntimeStage:function(){return er},formatDynamicAPIAccesses:function(){return U},getFirstDynamicReason:function(){return g},getStaticShellDisallowedDynamicReasons:function(){return et},isDynamicPostpone:function(){return x},isPrerenderInterruptedError:function(){return N},logDisallowedDynamicError:function(){return Z},markCurrentScopeAsDynamic:function(){return R},postponeWithTracking:function(){return w},throwIfDisallowedDynamic:function(){return ee},throwToInterruptStaticGeneration:function(){return O},trackAllowedDynamicAccess:function(){return z},trackDynamicDataInDynamicRender:function(){return v},trackDynamicHoleInRuntimeShell:function(){return K},trackDynamicHoleInStaticShell:function(){return V},useDynamicRouteParams:function(){return X},useDynamicSearchParams:function(){return B}};for(var u in a)Object.defineProperty(r,u,{enumerable:!0,get:a[u]});let i=(n=e.r(271645))&&n.__esModule?n:{default:n},c=e.r(476353),s=e.r(643248),l=e.r(662141),d=e.r(563599),f=e.r(963138),p=e.r(954839),y=e.r(729419),_=e.r(132061),m=e.r(312718),h="function"==typeof i.default.unstable_postpone;function b(e){return{isDebugDynamicAccesses:e,dynamicAccesses:[],syncDynamicErrorWithStack:null}}function E(){return{hasSuspenseAboveBody:!1,hasDynamicMetadata:!1,dynamicMetadata:null,hasDynamicViewport:!1,hasAllowedDynamic:!1,dynamicErrors:[]}}function g(e){var t;return null==(t=e.dynamicAccesses[0])?void 0:t.expression}function R(e,t,r){if(t)switch(t.type){case"cache":case"unstable-cache":case"private-cache":return}if(!e.forceDynamic&&!e.forceStatic){if(e.dynamicShouldError)throw Object.defineProperty(new s.StaticGenBailoutError(`Route ${e.route} with \`dynamic = "error"\` couldn't be rendered statically because it used \`${r}\`. See more info here: https://nextjs.org/docs/app/building-your-application/rendering/static-and-dynamic#dynamic-rendering`),"__NEXT_ERROR_CODE",{value:"E553",enumerable:!1,configurable:!0});if(t)switch(t.type){case"prerender-ppr":return w(e.route,r,t.dynamicTracking);case"prerender-legacy":t.revalidate=0;let n=Object.defineProperty(new c.DynamicServerError(`Route ${e.route} couldn't be rendered statically because it used ${r}. See more info here: https://nextjs.org/docs/messages/dynamic-server-error`),"__NEXT_ERROR_CODE",{value:"E550",enumerable:!1,configurable:!0});throw e.dynamicUsageDescription=r,e.dynamicUsageStack=n.stack,n}}}function O(e,t,r){let n=Object.defineProperty(new c.DynamicServerError(`Route ${t.route} couldn't be rendered statically because it used \`${e}\`. See more info here: https://nextjs.org/docs/messages/dynamic-server-error`),"__NEXT_ERROR_CODE",{value:"E558",enumerable:!1,configurable:!0});throw r.revalidate=0,t.dynamicUsageDescription=e,t.dynamicUsageStack=n.stack,n}function v(e){switch(e.type){case"cache":case"unstable-cache":case"private-cache":return}}function P(e,t,r){let n=C(`Route ${e} needs to bail out of prerendering at this point because it used ${t}.`);r.controller.abort(n);let o=r.dynamicTracking;o&&o.dynamicAccesses.push({stack:o.isDebugDynamicAccesses?Error().stack:void 0,expression:t})}function j(e,t,r,n){let o=n.dynamicTracking;P(e,t,n),o&&null===o.syncDynamicErrorWithStack&&(o.syncDynamicErrorWithStack=r)}function S(e,t,r,n){if(!1===n.controller.signal.aborted){P(e,t,n);let o=n.dynamicTracking;o&&null===o.syncDynamicErrorWithStack&&(o.syncDynamicErrorWithStack=r)}throw C(`Route ${e} needs to bail out of prerendering at this point because it used ${t}.`)}function T({reason:e,route:t}){let r=l.workUnitAsyncStorage.getStore();w(t,e,r&&"prerender-ppr"===r.type?r.dynamicTracking:null)}function w(e,t,r){(function(){if(!h)throw Object.defineProperty(Error("Invariant: React.unstable_postpone is not defined. This suggests the wrong version of React was loaded. This is a bug in Next.js"),"__NEXT_ERROR_CODE",{value:"E224",enumerable:!1,configurable:!0})})(),r&&r.dynamicAccesses.push({stack:r.isDebugDynamicAccesses?Error().stack:void 0,expression:t}),i.default.unstable_postpone(D(e,t))}function D(e,t){return`Route ${e} needs to bail out of prerendering at this point because it used ${t}. React throws this special object to indicate where. It should not be caught by your own try/catch. Learn more: https://nextjs.org/docs/messages/ppr-caught-error`}function x(e){return"object"==typeof e&&null!==e&&"string"==typeof e.message&&A(e.message)}function A(e){return e.includes("needs to bail out of prerendering at this point because it used")&&e.includes("Learn more: https://nextjs.org/docs/messages/ppr-caught-error")}if(!1===A(D("%%%","^^^")))throw Object.defineProperty(Error("Invariant: isDynamicPostpone misidentified a postpone reason. This is a bug in Next.js"),"__NEXT_ERROR_CODE",{value:"E296",enumerable:!1,configurable:!0});let M="NEXT_PRERENDER_INTERRUPTED";function C(e){let t=Object.defineProperty(Error(e),"__NEXT_ERROR_CODE",{value:"E394",enumerable:!1,configurable:!0});return t.digest=M,t}function N(e){return"object"==typeof e&&null!==e&&e.digest===M&&"name"in e&&"message"in e&&e instanceof Error}function k(e){return e.length>0}function I(e,t){return e.dynamicAccesses.push(...t.dynamicAccesses),e.dynamicAccesses}function U(e){return e.filter(e=>"string"==typeof e.stack&&e.stack.length>0).map(({expression:e,stack:t})=>(t=t.split("\n").slice(4).filter(e=>!(e.includes("node_modules/next/")||e.includes(" ()")||e.includes(" (node:"))).join("\n"),`Dynamic API Usage Debug - ${e}: +${t}`))}function H(){let e=new AbortController;return e.abort(Object.defineProperty(new _.BailoutToCSRError("Render in Browser"),"__NEXT_ERROR_CODE",{value:"E721",enumerable:!1,configurable:!0})),e.signal}function L(e){switch(e.type){case"prerender":case"prerender-runtime":let t=new AbortController;if(e.cacheSignal)e.cacheSignal.inputReady().then(()=>{t.abort()});else{let r=(0,l.getRuntimeStagePromise)(e);r?r.then(()=>(0,y.scheduleOnNextTick)(()=>t.abort())):(0,y.scheduleOnNextTick)(()=>t.abort())}return t.signal;case"prerender-client":case"prerender-ppr":case"prerender-legacy":case"request":case"cache":case"private-cache":case"unstable-cache":return}}function $(e,t){let r=t.dynamicTracking;r&&r.dynamicAccesses.push({stack:r.isDebugDynamicAccesses?Error().stack:void 0,expression:e})}function X(e){let t=d.workAsyncStorage.getStore(),r=l.workUnitAsyncStorage.getStore();if(t&&r)switch(r.type){case"prerender-client":case"prerender":{let n=r.fallbackRouteParams;n&&n.size>0&&i.default.use((0,f.makeHangingPromise)(r.renderSignal,t.route,e));break}case"prerender-ppr":{let n=r.fallbackRouteParams;if(n&&n.size>0)return w(t.route,e,r.dynamicTracking);break}case"prerender-runtime":throw Object.defineProperty(new m.InvariantError(`\`${e}\` was called during a runtime prerender. Next.js should be preventing ${e} from being included in server components statically, but did not in this case.`),"__NEXT_ERROR_CODE",{value:"E771",enumerable:!1,configurable:!0});case"cache":case"private-cache":throw Object.defineProperty(new m.InvariantError(`\`${e}\` was called inside a cache scope. Next.js should be preventing ${e} from being included in server components statically, but did not in this case.`),"__NEXT_ERROR_CODE",{value:"E745",enumerable:!1,configurable:!0})}}function B(e){let t=d.workAsyncStorage.getStore(),r=l.workUnitAsyncStorage.getStore();if(t)switch(!r&&(0,l.throwForMissingRequestStore)(e),r.type){case"prerender-client":i.default.use((0,f.makeHangingPromise)(r.renderSignal,t.route,e));break;case"prerender-legacy":case"prerender-ppr":if(t.forceStatic)return;throw Object.defineProperty(new _.BailoutToCSRError(e),"__NEXT_ERROR_CODE",{value:"E394",enumerable:!1,configurable:!0});case"prerender":case"prerender-runtime":throw Object.defineProperty(new m.InvariantError(`\`${e}\` was called from a Server Component. Next.js should be preventing ${e} from being included in server components statically, but did not in this case.`),"__NEXT_ERROR_CODE",{value:"E795",enumerable:!1,configurable:!0});case"cache":case"unstable-cache":case"private-cache":throw Object.defineProperty(new m.InvariantError(`\`${e}\` was called inside a cache scope. Next.js should be preventing ${e} from being included in server components statically, but did not in this case.`),"__NEXT_ERROR_CODE",{value:"E745",enumerable:!1,configurable:!0});case"request":return}}let F=/\n\s+at Suspense \(\)/,W=RegExp(`\\n\\s+at Suspense \\(\\)(?:(?!\\n\\s+at (?:body|div|main|section|article|aside|header|footer|nav|form|p|span|h1|h2|h3|h4|h5|h6) \\(\\))[\\s\\S])*?\\n\\s+at ${p.ROOT_LAYOUT_BOUNDARY_NAME} \\([^\\n]*\\)`),G=RegExp(`\\n\\s+at ${p.METADATA_BOUNDARY_NAME}[\\n\\s]`),q=RegExp(`\\n\\s+at ${p.VIEWPORT_BOUNDARY_NAME}[\\n\\s]`),Y=RegExp(`\\n\\s+at ${p.OUTLET_BOUNDARY_NAME}[\\n\\s]`);function z(e,t,r,n){if(!Y.test(t)){if(G.test(t)){r.hasDynamicMetadata=!0;return}if(q.test(t)){r.hasDynamicViewport=!0;return}if(W.test(t)){r.hasAllowedDynamic=!0,r.hasSuspenseAboveBody=!0;return}else if(F.test(t)){r.hasAllowedDynamic=!0;return}else{if(n.syncDynamicErrorWithStack)return void r.dynamicErrors.push(n.syncDynamicErrorWithStack);let o=Q(`Route "${e.route}": Uncached data was accessed outside of . This delays the entire page from rendering, resulting in a slow user experience. Learn more: https://nextjs.org/docs/messages/blocking-route`,t);return void r.dynamicErrors.push(o)}}}function K(e,t,r,n){if(!Y.test(t)){if(G.test(t)){r.dynamicMetadata=Q(`Route "${e.route}": Uncached data or \`connection()\` was accessed inside \`generateMetadata\`. Except for this instance, the page would have been entirely prerenderable which may have been the intended behavior. See more info here: https://nextjs.org/docs/messages/next-prerender-dynamic-metadata`,t);return}if(q.test(t)){let n=Q(`Route "${e.route}": Uncached data or \`connection()\` was accessed inside \`generateViewport\`. This delays the entire page from rendering, resulting in a slow user experience. Learn more: https://nextjs.org/docs/messages/next-prerender-dynamic-viewport`,t);r.dynamicErrors.push(n);return}if(W.test(t)){r.hasAllowedDynamic=!0,r.hasSuspenseAboveBody=!0;return}else if(F.test(t)){r.hasAllowedDynamic=!0;return}else{if(n.syncDynamicErrorWithStack)return void r.dynamicErrors.push(n.syncDynamicErrorWithStack);let o=Q(`Route "${e.route}": Uncached data or \`connection()\` was accessed outside of \`\`. This delays the entire page from rendering, resulting in a slow user experience. Learn more: https://nextjs.org/docs/messages/blocking-route`,t);return void r.dynamicErrors.push(o)}}}function V(e,t,r,n){if(!Y.test(t)){if(G.test(t)){r.dynamicMetadata=Q(`Route "${e.route}": Runtime data such as \`cookies()\`, \`headers()\`, \`params\`, or \`searchParams\` was accessed inside \`generateMetadata\` or you have file-based metadata such as icons that depend on dynamic params segments. Except for this instance, the page would have been entirely prerenderable which may have been the intended behavior. See more info here: https://nextjs.org/docs/messages/next-prerender-dynamic-metadata`,t);return}if(q.test(t)){let n=Q(`Route "${e.route}": Runtime data such as \`cookies()\`, \`headers()\`, \`params\`, or \`searchParams\` was accessed inside \`generateViewport\`. This delays the entire page from rendering, resulting in a slow user experience. Learn more: https://nextjs.org/docs/messages/next-prerender-dynamic-viewport`,t);r.dynamicErrors.push(n);return}if(W.test(t)){r.hasAllowedDynamic=!0,r.hasSuspenseAboveBody=!0;return}else if(F.test(t)){r.hasAllowedDynamic=!0;return}else{if(n.syncDynamicErrorWithStack)return void r.dynamicErrors.push(n.syncDynamicErrorWithStack);let o=Q(`Route "${e.route}": Runtime data such as \`cookies()\`, \`headers()\`, \`params\`, or \`searchParams\` was accessed outside of \`\`. This delays the entire page from rendering, resulting in a slow user experience. Learn more: https://nextjs.org/docs/messages/blocking-route`,t);return void r.dynamicErrors.push(o)}}}function Q(e,t){let r=Object.defineProperty(Error(e),"__NEXT_ERROR_CODE",{value:"E394",enumerable:!1,configurable:!0});return r.stack=r.name+": "+e+t,r}var J=((o={})[o.Full=0]="Full",o[o.Empty=1]="Empty",o[o.Errored=2]="Errored",o);function Z(e,t){console.error(t),e.dev||(e.hasReadableErrorStacks?console.error(`To get a more detailed stack trace and pinpoint the issue, start the app in development mode by running \`next dev\`, then open "${e.route}" in your browser to investigate the error.`):console.error(`To get a more detailed stack trace and pinpoint the issue, try one of the following: + - Start the app in development mode by running \`next dev\`, then open "${e.route}" in your browser to investigate the error. + - Rerun the production build with \`next build --debug-prerender\` to generate better stack traces.`))}function ee(e,t,r,n){if(n.syncDynamicErrorWithStack)throw Z(e,n.syncDynamicErrorWithStack),new s.StaticGenBailoutError;if(0!==t){if(r.hasSuspenseAboveBody)return;let n=r.dynamicErrors;if(n.length>0){for(let t=0;t0)return n;if(1===t)return[Object.defineProperty(new m.InvariantError(`Route "${e.route}" did not produce a static shell and Next.js was unable to determine a reason.`),"__NEXT_ERROR_CODE",{value:"E936",enumerable:!1,configurable:!0})]}else if(!1===r.hasAllowedDynamic&&0===r.dynamicErrors.length&&r.dynamicMetadata)return[r.dynamicMetadata];return[]}function er(e,t){return e.runtimeStagePromise?e.runtimeStagePromise.then(()=>t):t}},891414,(e,t,r)=>{"use strict";Object.defineProperty(r,"__esModule",{value:!0}),Object.defineProperty(r,"unstable_rethrow",{enumerable:!0,get:function(){return function e(t){if((0,u.isNextRouterError)(t)||(0,a.isBailoutToCSRError)(t)||(0,c.isDynamicServerError)(t)||(0,i.isDynamicPostpone)(t)||(0,o.isPostpone)(t)||(0,n.isHangingPromiseRejectionError)(t)||(0,i.isPrerenderInterruptedError)(t))throw t;t instanceof Error&&"cause"in t&&e(t.cause)}}});let n=e.r(963138),o=e.r(367287),a=e.r(132061),u=e.r(265713),i=e.r(67673),c=e.r(476353);("function"==typeof r.default||"object"==typeof r.default&&null!==r.default)&&void 0===r.default.__esModule&&(Object.defineProperty(r.default,"__esModule",{value:!0}),Object.assign(r.default,r),t.exports=r.default)},490508,(e,t,r)=>{"use strict";Object.defineProperty(r,"__esModule",{value:!0}),Object.defineProperty(r,"unstable_rethrow",{enumerable:!0,get:function(){return n}});let n="u"{"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n={ReadonlyURLSearchParams:function(){return a.ReadonlyURLSearchParams},RedirectType:function(){return i.RedirectType},forbidden:function(){return s.forbidden},notFound:function(){return c.notFound},permanentRedirect:function(){return u.permanentRedirect},redirect:function(){return u.redirect},unauthorized:function(){return l.unauthorized},unstable_isUnrecognizedActionError:function(){return f},unstable_rethrow:function(){return d.unstable_rethrow}};for(var o in n)Object.defineProperty(r,o,{enumerable:!0,get:n[o]});let a=e.r(903680),u=e.r(124063),i=e.r(968391),c=e.r(222783),s=e.r(879854),l=e.r(122683),d=e.r(490508);function f(){throw Object.defineProperty(Error("`unstable_isUnrecognizedActionError` can only be used on the client."),"__NEXT_ERROR_CODE",{value:"E776",enumerable:!1,configurable:!0})}("function"==typeof r.default||"object"==typeof r.default&&null!==r.default)&&void 0===r.default.__esModule&&(Object.defineProperty(r.default,"__esModule",{value:!0}),Object.assign(r.default,r),t.exports=r.default)},976562,(e,t,r)=>{"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n={ReadonlyURLSearchParams:function(){return i.ReadonlyURLSearchParams},RedirectType:function(){return d.RedirectType},ServerInsertedHTMLContext:function(){return s.ServerInsertedHTMLContext},forbidden:function(){return d.forbidden},notFound:function(){return d.notFound},permanentRedirect:function(){return d.permanentRedirect},redirect:function(){return d.redirect},unauthorized:function(){return d.unauthorized},unstable_isUnrecognizedActionError:function(){return l.unstable_isUnrecognizedActionError},unstable_rethrow:function(){return d.unstable_rethrow},useParams:function(){return h},usePathname:function(){return _},useRouter:function(){return m},useSearchParams:function(){return y},useSelectedLayoutSegment:function(){return E},useSelectedLayoutSegments:function(){return b},useServerInsertedHTML:function(){return s.useServerInsertedHTML}};for(var o in n)Object.defineProperty(r,o,{enumerable:!0,get:n[o]});let a=e.r(151836)._(e.r(271645)),u=e.r(8372),i=e.r(261994),c=e.r(813258),s=e.r(13957),l=e.r(292838),d=e.r(592805),f="u"e?new i.ReadonlyURLSearchParams(e):null,[e])}function _(){return f?.("usePathname()"),(0,a.useContext)(i.PathnameContext)}function m(){let e=(0,a.useContext)(u.AppRouterContext);if(null===e)throw Object.defineProperty(Error("invariant expected app router to be mounted"),"__NEXT_ERROR_CODE",{value:"E238",enumerable:!1,configurable:!0});return e}function h(){return f?.("useParams()"),(0,a.useContext)(i.PathParamsContext)}function b(e="children"){f?.("useSelectedLayoutSegments()");let t=(0,a.useContext)(u.LayoutRouterContext);return t?(0,c.getSelectedLayoutSegmentPath)(t.parentTree,e):null}function E(e="children"){f?.("useSelectedLayoutSegment()"),(0,a.useContext)(i.NavigationPromisesContext);let t=b(e);return(0,c.computeSelectedLayoutSegment)(t,e)}("function"==typeof r.default||"object"==typeof r.default&&null!==r.default)&&void 0===r.default.__esModule&&(Object.defineProperty(r.default,"__esModule",{value:!0}),Object.assign(r.default,r),t.exports=r.default)}]); \ No newline at end of file diff --git a/litellm/proxy/_experimental/out/_next/static/chunks/13941d92d83ccc8d.js b/litellm/proxy/_experimental/out/_next/static/chunks/13941d92d83ccc8d.js new file mode 100644 index 00000000000..7883eaa15a4 --- /dev/null +++ b/litellm/proxy/_experimental/out/_next/static/chunks/13941d92d83ccc8d.js @@ -0,0 +1 @@ +(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,737434,e=>{"use strict";var t=e.i(184163);e.s(["DownloadOutlined",()=>t.default])},964306,e=>{"use strict";var t=e.i(271645);let r=t.forwardRef(function(e,r){return t.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:2,stroke:"currentColor","aria-hidden":"true",ref:r},e),t.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M10 14l2-2m0 0l2-2m-2 2l-2-2m2 2l2 2m7-2a9 9 0 11-18 0 9 9 0 0118 0z"}))});e.s(["XCircleIcon",0,r],964306)},860585,e=>{"use strict";var t=e.i(843476),r=e.i(199133);let{Option:l}=r.Select;e.s(["default",0,({value:e,onChange:a,className:n="",style:o={}})=>(0,t.jsxs)(r.Select,{style:{width:"100%",...o},value:e||void 0,onChange:a,className:n,placeholder:"n/a",allowClear:!0,children:[(0,t.jsx)(l,{value:"24h",children:"daily"}),(0,t.jsx)(l,{value:"7d",children:"weekly"}),(0,t.jsx)(l,{value:"30d",children:"monthly"})]}),"getBudgetDurationLabel",0,e=>e?({"24h":"daily","7d":"weekly","30d":"monthly"})[e]||e:"Not set"])},743151,(e,t,r)=>{"use strict";function l(e){return(l="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}Object.defineProperty(r,"__esModule",{value:!0}),r.CopyToClipboard=void 0;var a=i(e.r(271645)),n=i(e.r(844343)),o=["text","onCopy","options","children"];function i(e){return e&&e.__esModule?e:{default:e}}function s(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var l=Object.getOwnPropertySymbols(e);t&&(l=l.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,l)}return r}function c(e){for(var t=1;t=0||(a[r]=e[r]);return a}(e,t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);for(l=0;l=0)&&Object.prototype.propertyIsEnumerable.call(e,r)&&(a[r]=e[r])}return a}(e,o),l=a.default.Children.only(t);return a.default.cloneElement(l,c(c({},r),{},{onClick:this.onClick}))}}],function(e,t){for(var r=0;r{"use strict";var l=e.r(743151).CopyToClipboard;l.CopyToClipboard=l,t.exports=l},663435,e=>{"use strict";var t=e.i(843476),r=e.i(199133);e.s(["default",0,({teams:e,value:l,onChange:a,disabled:n})=>(console.log("disabled",n),(0,t.jsx)(r.Select,{showSearch:!0,placeholder:"Search or select a team",value:l,onChange:a,disabled:n,allowClear:!0,filterOption:(t,r)=>{if(!r)return!1;let l=e?.find(e=>e.team_id===r.key);if(!l)return!1;let a=t.toLowerCase().trim(),n=(l.team_alias||"").toLowerCase(),o=(l.team_id||"").toLowerCase();return n.includes(a)||o.includes(a)},optionFilterProp:"children",children:e?.map(e=>(0,t.jsxs)(r.Select.Option,{value:e.team_id,children:[(0,t.jsx)("span",{className:"font-medium",children:e.team_alias})," ",(0,t.jsxs)("span",{className:"text-gray-500",children:["(",e.team_id,")"]})]},e.team_id))}))])},285027,e=>{"use strict";e.i(247167);var t=e.i(931067),r=e.i(271645);let l={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M464 720a48 48 0 1096 0 48 48 0 10-96 0zm16-304v184c0 4.4 3.6 8 8 8h48c4.4 0 8-3.6 8-8V416c0-4.4-3.6-8-8-8h-48c-4.4 0-8 3.6-8 8zm475.7 440l-416-720c-6.2-10.7-16.9-16-27.7-16s-21.6 5.3-27.7 16l-416 720C56 877.4 71.4 904 96 904h832c24.6 0 40-26.6 27.7-48zm-783.5-27.9L512 239.9l339.8 588.2H172.2z"}}]},name:"warning",theme:"outlined"};var a=e.i(9583),n=r.forwardRef(function(e,n){return r.createElement(a.default,(0,t.default)({},e,{ref:n,icon:l}))});e.s(["WarningOutlined",0,n],285027)},355619,e=>{"use strict";var t=e.i(764205);let r=async(e,r,l)=>{try{if(null===e||null===r)return;if(null!==l){let a=(await (0,t.modelAvailableCall)(l,e,r,!0,null,!0)).data.map(e=>e.id),n=[],o=[];return a.forEach(e=>{e.endsWith("/*")?n.push(e):o.push(e)}),[...n,...o]}}catch(e){console.error("Error fetching user models:",e)}};e.s(["fetchAvailableModelsForTeamOrKey",0,r,"getModelDisplayName",0,e=>{if("all-proxy-models"===e)return"All Proxy Models";if(e.endsWith("/*")){let t=e.replace("/*","");return`All ${t} models`}return e},"unfurlWildcardModelsInList",0,(e,t)=>{let r=[],l=[];return console.log("teamModels",e),console.log("allModels",t),e.forEach(e=>{if(e.endsWith("/*")){let a=e.replace("/*",""),n=t.filter(e=>e.startsWith(a+"/"));l.push(...n),r.push(e)}else l.push(e)}),[...r,...l].filter((e,t,r)=>r.indexOf(e)===t)}])},309821,e=>{"use strict";e.i(247167);var t=e.i(271645);e.i(262370);var r=e.i(135551),l=e.i(201072),a=e.i(121229),n=e.i(726289),o=e.i(864517),i=e.i(343794),s=e.i(529681),c=e.i(242064),d=e.i(931067),u=e.i(209428),m=e.i(703923),f={percent:0,prefixCls:"rc-progress",strokeColor:"#2db7f5",strokeLinecap:"round",strokeWidth:1,trailColor:"#D9D9D9",trailWidth:1,gapPosition:"bottom"},p=function(){var e=(0,t.useRef)([]),r=(0,t.useRef)(null);return(0,t.useEffect)(function(){var t=Date.now(),l=!1;e.current.forEach(function(e){if(e){l=!0;var a=e.style;a.transitionDuration=".3s, .3s, .3s, .06s",r.current&&t-r.current<100&&(a.transitionDuration="0s, 0s")}}),l&&(r.current=Date.now())}),e.current},g=e.i(410160),h=e.i(392221),b=e.i(654310),y=0,x=(0,b.default)();let v=function(e){var r=t.useState(),l=(0,h.default)(r,2),a=l[0],n=l[1];return t.useEffect(function(){var e;n("rc_progress_".concat((x?(e=y,y+=1):e="TEST_OR_SSR",e)))},[]),e||a};var k=function(e){var r=e.bg,l=e.children;return t.createElement("div",{style:{width:"100%",height:"100%",background:r}},l)};function j(e,t){return Object.keys(e).map(function(r){var l=parseFloat(r),a="".concat(Math.floor(l*t),"%");return"".concat(e[r]," ").concat(a)})}var w=t.forwardRef(function(e,r){var l=e.prefixCls,a=e.color,n=e.gradientId,o=e.radius,i=e.style,s=e.ptg,c=e.strokeLinecap,d=e.strokeWidth,u=e.size,m=e.gapDegree,f=a&&"object"===(0,g.default)(a),p=u/2,h=t.createElement("circle",{className:"".concat(l,"-circle-path"),r:o,cx:p,cy:p,stroke:f?"#FFF":void 0,strokeLinecap:c,strokeWidth:d,opacity:+(0!==s),style:i,ref:r});if(!f)return h;var b="".concat(n,"-conic"),y=j(a,(360-m)/360),x=j(a,1),v="conic-gradient(from ".concat(m?"".concat(180+m/2,"deg"):"0deg",", ").concat(y.join(", "),")"),w="linear-gradient(to ".concat(m?"bottom":"top",", ").concat(x.join(", "),")");return t.createElement(t.Fragment,null,t.createElement("mask",{id:b},h),t.createElement("foreignObject",{x:0,y:0,width:u,height:u,mask:"url(#".concat(b,")")},t.createElement(k,{bg:w},t.createElement(k,{bg:v}))))}),C=function(e,t,r,l,a,n,o,i,s,c){var d=arguments.length>10&&void 0!==arguments[10]?arguments[10]:0,u=(100-l)/100*t;return"round"===s&&100!==l&&(u+=c/2)>=t&&(u=t-.01),{stroke:"string"==typeof i?i:void 0,strokeDasharray:"".concat(t,"px ").concat(e),strokeDashoffset:u+d,transform:"rotate(".concat(a+r/100*360*((360-n)/360)+(0===n?0:({bottom:0,top:180,left:90,right:-90})[o]),"deg)"),transformOrigin:"".concat(50,"px ").concat(50,"px"),transition:"stroke-dashoffset .3s ease 0s, stroke-dasharray .3s ease 0s, stroke .3s, stroke-width .06s ease .3s, opacity .3s ease 0s",fillOpacity:0}},S=["id","prefixCls","steps","strokeWidth","trailWidth","gapDegree","gapPosition","trailColor","strokeLinecap","style","className","strokeColor","percent"];function N(e){var t=null!=e?e:[];return Array.isArray(t)?t:[t]}let $=function(e){var r,l,a,n,o=(0,u.default)((0,u.default)({},f),e),s=o.id,c=o.prefixCls,h=o.steps,b=o.strokeWidth,y=o.trailWidth,x=o.gapDegree,k=void 0===x?0:x,j=o.gapPosition,$=o.trailColor,O=o.strokeLinecap,E=o.style,M=o.className,P=o.strokeColor,_=o.percent,T=(0,m.default)(o,S),D=v(s),R="".concat(D,"-gradient"),F=50-b/2,I=2*Math.PI*F,A=k>0?90+k/2:-90,L=(360-k)/360*I,z="object"===(0,g.default)(h)?h:{count:h,gap:2},W=z.count,B=z.gap,X=N(_),H=N(P),q=H.find(function(e){return e&&"object"===(0,g.default)(e)}),K=q&&"object"===(0,g.default)(q)?"butt":O,V=C(I,L,0,100,A,k,j,$,K,b),G=p();return t.createElement("svg",(0,d.default)({className:(0,i.default)("".concat(c,"-circle"),M),viewBox:"0 0 ".concat(100," ").concat(100),style:E,id:s,role:"presentation"},T),!W&&t.createElement("circle",{className:"".concat(c,"-circle-trail"),r:F,cx:50,cy:50,stroke:$,strokeLinecap:K,strokeWidth:y||b,style:V}),W?(r=Math.round(W*(X[0]/100)),l=100/W,a=0,Array(W).fill(null).map(function(e,n){var o=n<=r-1?H[0]:$,i=o&&"object"===(0,g.default)(o)?"url(#".concat(R,")"):void 0,s=C(I,L,a,l,A,k,j,o,"butt",b,B);return a+=(L-s.strokeDashoffset+B)*100/L,t.createElement("circle",{key:n,className:"".concat(c,"-circle-path"),r:F,cx:50,cy:50,stroke:i,strokeWidth:b,opacity:1,style:s,ref:function(e){G[n]=e}})})):(n=0,X.map(function(e,r){var l=H[r]||H[H.length-1],a=C(I,L,n,e,A,k,j,l,K,b);return n+=e,t.createElement(w,{key:r,color:l,ptg:e,radius:F,prefixCls:c,gradientId:R,style:a,strokeLinecap:K,strokeWidth:b,gapDegree:k,ref:function(e){G[r]=e},size:100})}).reverse()))};var O=e.i(491816);e.i(765846);var E=e.i(896091);function M(e){return!e||e<0?0:e>100?100:e}function P({success:e,successPercent:t}){let r=t;return e&&"progress"in e&&(r=e.progress),e&&"percent"in e&&(r=e.percent),r}let _=(e,t,r)=>{var l,a,n,o;let i=-1,s=-1;if("step"===t){let t=r.steps,l=r.strokeWidth;"string"==typeof e||void 0===e?(i="small"===e?2:14,s=null!=l?l:8):"number"==typeof e?[i,s]=[e,e]:[i=14,s=8]=Array.isArray(e)?e:[e.width,e.height],i*=t}else if("line"===t){let t=null==r?void 0:r.strokeWidth;"string"==typeof e||void 0===e?s=t||("small"===e?6:8):"number"==typeof e?[i,s]=[e,e]:[i=-1,s=8]=Array.isArray(e)?e:[e.width,e.height]}else("circle"===t||"dashboard"===t)&&("string"==typeof e||void 0===e?[i,s]="small"===e?[60,60]:[120,120]:"number"==typeof e?[i,s]=[e,e]:Array.isArray(e)&&(i=null!=(a=null!=(l=e[0])?l:e[1])?a:120,s=null!=(o=null!=(n=e[0])?n:e[1])?o:120));return[i,s]},T=e=>{let{prefixCls:r,trailColor:l=null,strokeLinecap:a="round",gapPosition:n,gapDegree:o,width:s=120,type:c,children:d,success:u,size:m=s,steps:f}=e,[p,g]=_(m,"circle"),{strokeWidth:h}=e;void 0===h&&(h=Math.max(3/p*100,6));let b=t.useMemo(()=>o||0===o?o:"dashboard"===c?75:void 0,[o,c]),y=(({percent:e,success:t,successPercent:r})=>{let l=M(P({success:t,successPercent:r}));return[l,M(M(e)-l)]})(e),x="[object Object]"===Object.prototype.toString.call(e.strokeColor),v=(({success:e={},strokeColor:t})=>{let{strokeColor:r}=e;return[r||E.presetPrimaryColors.green,t||null]})({success:u,strokeColor:e.strokeColor}),k=(0,i.default)(`${r}-inner`,{[`${r}-circle-gradient`]:x}),j=t.createElement($,{steps:f,percent:f?y[1]:y,strokeWidth:h,trailWidth:h,strokeColor:f?v[1]:v,strokeLinecap:a,trailColor:l,prefixCls:r,gapDegree:b,gapPosition:n||"dashboard"===c&&"bottom"||void 0}),w=p<=20,C=t.createElement("div",{className:k,style:{width:p,height:g,fontSize:.15*p+6}},j,!w&&d);return w?t.createElement(O.default,{title:d},C):C};e.i(296059);var D=e.i(694758),R=e.i(915654),F=e.i(183293),I=e.i(246422),A=e.i(838378);let L="--progress-line-stroke-color",z="--progress-percent",W=e=>{let t=e?"100%":"-100%";return new D.Keyframes(`antProgress${e?"RTL":"LTR"}Active`,{"0%":{transform:`translateX(${t}) scaleX(0)`,opacity:.1},"20%":{transform:`translateX(${t}) scaleX(0)`,opacity:.5},to:{transform:"translateX(0) scaleX(1)",opacity:0}})},B=(0,I.genStyleHooks)("Progress",e=>{let t=e.calc(e.marginXXS).div(2).equal(),r=(0,A.mergeToken)(e,{progressStepMarginInlineEnd:t,progressStepMinWidth:t,progressActiveMotionDuration:"2.4s"});return[(e=>{let{componentCls:t,iconCls:r}=e;return{[t]:Object.assign(Object.assign({},(0,F.resetComponent)(e)),{display:"inline-block","&-rtl":{direction:"rtl"},"&-line":{position:"relative",width:"100%",fontSize:e.fontSize},[`${t}-outer`]:{display:"inline-flex",alignItems:"center",width:"100%"},[`${t}-inner`]:{position:"relative",display:"inline-block",width:"100%",flex:1,overflow:"hidden",verticalAlign:"middle",backgroundColor:e.remainingColor,borderRadius:e.lineBorderRadius},[`${t}-inner:not(${t}-circle-gradient)`]:{[`${t}-circle-path`]:{stroke:e.defaultColor}},[`${t}-success-bg, ${t}-bg`]:{position:"relative",background:e.defaultColor,borderRadius:e.lineBorderRadius,transition:`all ${e.motionDurationSlow} ${e.motionEaseInOutCirc}`},[`${t}-layout-bottom`]:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",[`${t}-text`]:{width:"max-content",marginInlineStart:0,marginTop:e.marginXXS}},[`${t}-bg`]:{overflow:"hidden","&::after":{content:'""',background:{_multi_value_:!0,value:["inherit",`var(${L})`]},height:"100%",width:`calc(1 / var(${z}) * 100%)`,display:"block"},[`&${t}-bg-inner`]:{minWidth:"max-content","&::after":{content:"none"},[`${t}-text-inner`]:{color:e.colorWhite,[`&${t}-text-bright`]:{color:"rgba(0, 0, 0, 0.45)"}}}},[`${t}-success-bg`]:{position:"absolute",insetBlockStart:0,insetInlineStart:0,backgroundColor:e.colorSuccess},[`${t}-text`]:{display:"inline-block",marginInlineStart:e.marginXS,color:e.colorText,lineHeight:1,width:"2em",whiteSpace:"nowrap",textAlign:"start",verticalAlign:"middle",wordBreak:"normal",[r]:{fontSize:e.fontSize},[`&${t}-text-outer`]:{width:"max-content"},[`&${t}-text-outer${t}-text-start`]:{width:"max-content",marginInlineStart:0,marginInlineEnd:e.marginXS}},[`${t}-text-inner`]:{display:"flex",justifyContent:"center",alignItems:"center",width:"100%",height:"100%",marginInlineStart:0,padding:`0 ${(0,R.unit)(e.paddingXXS)}`,[`&${t}-text-start`]:{justifyContent:"start"},[`&${t}-text-end`]:{justifyContent:"end"}},[`&${t}-status-active`]:{[`${t}-bg::before`]:{position:"absolute",inset:0,backgroundColor:e.colorBgContainer,borderRadius:e.lineBorderRadius,opacity:0,animationName:W(),animationDuration:e.progressActiveMotionDuration,animationTimingFunction:e.motionEaseOutQuint,animationIterationCount:"infinite",content:'""'}},[`&${t}-rtl${t}-status-active`]:{[`${t}-bg::before`]:{animationName:W(!0)}},[`&${t}-status-exception`]:{[`${t}-bg`]:{backgroundColor:e.colorError},[`${t}-text`]:{color:e.colorError}},[`&${t}-status-exception ${t}-inner:not(${t}-circle-gradient)`]:{[`${t}-circle-path`]:{stroke:e.colorError}},[`&${t}-status-success`]:{[`${t}-bg`]:{backgroundColor:e.colorSuccess},[`${t}-text`]:{color:e.colorSuccess}},[`&${t}-status-success ${t}-inner:not(${t}-circle-gradient)`]:{[`${t}-circle-path`]:{stroke:e.colorSuccess}}})}})(r),(e=>{let{componentCls:t,iconCls:r}=e;return{[t]:{[`${t}-circle-trail`]:{stroke:e.remainingColor},[`&${t}-circle ${t}-inner`]:{position:"relative",lineHeight:1,backgroundColor:"transparent"},[`&${t}-circle ${t}-text`]:{position:"absolute",insetBlockStart:"50%",insetInlineStart:0,width:"100%",margin:0,padding:0,color:e.circleTextColor,fontSize:e.circleTextFontSize,lineHeight:1,whiteSpace:"normal",textAlign:"center",transform:"translateY(-50%)",[r]:{fontSize:e.circleIconFontSize}},[`${t}-circle&-status-exception`]:{[`${t}-text`]:{color:e.colorError}},[`${t}-circle&-status-success`]:{[`${t}-text`]:{color:e.colorSuccess}}},[`${t}-inline-circle`]:{lineHeight:1,[`${t}-inner`]:{verticalAlign:"bottom"}}}})(r),(e=>{let{componentCls:t}=e;return{[t]:{[`${t}-steps`]:{display:"inline-block","&-outer":{display:"flex",flexDirection:"row",alignItems:"center"},"&-item":{flexShrink:0,minWidth:e.progressStepMinWidth,marginInlineEnd:e.progressStepMarginInlineEnd,backgroundColor:e.remainingColor,transition:`all ${e.motionDurationSlow}`,"&-active":{backgroundColor:e.defaultColor}}}}}})(r),(e=>{let{componentCls:t,iconCls:r}=e;return{[t]:{[`${t}-small&-line, ${t}-small&-line ${t}-text ${r}`]:{fontSize:e.fontSizeSM}}}})(r)]},e=>({circleTextColor:e.colorText,defaultColor:e.colorInfo,remainingColor:e.colorFillSecondary,lineBorderRadius:100,circleTextFontSize:"1em",circleIconFontSize:`${e.fontSize/e.fontSizeSM}em`}));var X=function(e,t){var r={};for(var l in e)Object.prototype.hasOwnProperty.call(e,l)&&0>t.indexOf(l)&&(r[l]=e[l]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols)for(var a=0,l=Object.getOwnPropertySymbols(e);at.indexOf(l[a])&&Object.prototype.propertyIsEnumerable.call(e,l[a])&&(r[l[a]]=e[l[a]]);return r};let H=e=>{let{prefixCls:r,direction:l,percent:a,size:n,strokeWidth:o,strokeColor:s,strokeLinecap:c="round",children:d,trailColor:u=null,percentPosition:m,success:f}=e,{align:p,type:g}=m,h=s&&"string"!=typeof s?((e,t)=>{let{from:r=E.presetPrimaryColors.blue,to:l=E.presetPrimaryColors.blue,direction:a="rtl"===t?"to left":"to right"}=e,n=X(e,["from","to","direction"]);if(0!==Object.keys(n).length){let e,t=(e=[],Object.keys(n).forEach(t=>{let r=Number.parseFloat(t.replace(/%/g,""));Number.isNaN(r)||e.push({key:r,value:n[t]})}),(e=e.sort((e,t)=>e.key-t.key)).map(({key:e,value:t})=>`${t} ${e}%`).join(", ")),r=`linear-gradient(${a}, ${t})`;return{background:r,[L]:r}}let o=`linear-gradient(${a}, ${r}, ${l})`;return{background:o,[L]:o}})(s,l):{[L]:s,background:s},b="square"===c||"butt"===c?0:void 0,[y,x]=_(null!=n?n:[-1,o||("small"===n?6:8)],"line",{strokeWidth:o}),v=Object.assign(Object.assign({width:`${M(a)}%`,height:x,borderRadius:b},h),{[z]:M(a)/100}),k=P(e),j={width:`${M(k)}%`,height:x,borderRadius:b,backgroundColor:null==f?void 0:f.strokeColor},w=t.createElement("div",{className:`${r}-inner`,style:{backgroundColor:u||void 0,borderRadius:b}},t.createElement("div",{className:(0,i.default)(`${r}-bg`,`${r}-bg-${g}`),style:v},"inner"===g&&d),void 0!==k&&t.createElement("div",{className:`${r}-success-bg`,style:j})),C="outer"===g&&"start"===p,S="outer"===g&&"end"===p;return"outer"===g&&"center"===p?t.createElement("div",{className:`${r}-layout-bottom`},w,d):t.createElement("div",{className:`${r}-outer`,style:{width:y<0?"100%":y}},C&&d,w,S&&d)},q=e=>{let{size:r,steps:l,rounding:a=Math.round,percent:n=0,strokeWidth:o=8,strokeColor:s,trailColor:c=null,prefixCls:d,children:u}=e,m=a(n/100*l),[f,p]=_(null!=r?r:["small"===r?2:14,o],"step",{steps:l,strokeWidth:o}),g=f/l,h=Array.from({length:l});for(let e=0;et.indexOf(l)&&(r[l]=e[l]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols)for(var a=0,l=Object.getOwnPropertySymbols(e);at.indexOf(l[a])&&Object.prototype.propertyIsEnumerable.call(e,l[a])&&(r[l[a]]=e[l[a]]);return r};let V=["normal","exception","active","success"],G=t.forwardRef((e,d)=>{let u,{prefixCls:m,className:f,rootClassName:p,steps:g,strokeColor:h,percent:b=0,size:y="default",showInfo:x=!0,type:v="line",status:k,format:j,style:w,percentPosition:C={}}=e,S=K(e,["prefixCls","className","rootClassName","steps","strokeColor","percent","size","showInfo","type","status","format","style","percentPosition"]),{align:N="end",type:$="outer"}=C,O=Array.isArray(h)?h[0]:h,E="string"==typeof h||Array.isArray(h)?h:void 0,D=t.useMemo(()=>{if(O){let e="string"==typeof O?O:Object.values(O)[0];return new r.FastColor(e).isLight()}return!1},[h]),R=t.useMemo(()=>{var t,r;let l=P(e);return Number.parseInt(void 0!==l?null==(t=null!=l?l:0)?void 0:t.toString():null==(r=null!=b?b:0)?void 0:r.toString(),10)},[b,e.success,e.successPercent]),F=t.useMemo(()=>!V.includes(k)&&R>=100?"success":k||"normal",[k,R]),{getPrefixCls:I,direction:A,progress:L}=t.useContext(c.ConfigContext),z=I("progress",m),[W,X,G]=B(z),U="line"===v,J=U&&!g,Y=t.useMemo(()=>{let r;if(!x)return null;let s=P(e),c=j||(e=>`${e}%`),d=U&&D&&"inner"===$;return"inner"===$||j||"exception"!==F&&"success"!==F?r=c(M(b),M(s)):"exception"===F?r=U?t.createElement(n.default,null):t.createElement(o.default,null):"success"===F&&(r=U?t.createElement(l.default,null):t.createElement(a.default,null)),t.createElement("span",{className:(0,i.default)(`${z}-text`,{[`${z}-text-bright`]:d,[`${z}-text-${N}`]:J,[`${z}-text-${$}`]:J}),title:"string"==typeof r?r:void 0},r)},[x,b,R,F,v,z,j]);"line"===v?u=g?t.createElement(q,Object.assign({},e,{strokeColor:E,prefixCls:z,steps:"object"==typeof g?g.count:g}),Y):t.createElement(H,Object.assign({},e,{strokeColor:O,prefixCls:z,direction:A,percentPosition:{align:N,type:$}}),Y):("circle"===v||"dashboard"===v)&&(u=t.createElement(T,Object.assign({},e,{strokeColor:O,prefixCls:z,progressStatus:F}),Y));let Q=(0,i.default)(z,`${z}-status-${F}`,{[`${z}-${"dashboard"===v&&"circle"||v}`]:"line"!==v,[`${z}-inline-circle`]:"circle"===v&&_(y,"circle")[0]<=20,[`${z}-line`]:J,[`${z}-line-align-${N}`]:J,[`${z}-line-position-${$}`]:J,[`${z}-steps`]:g,[`${z}-show-info`]:x,[`${z}-${y}`]:"string"==typeof y,[`${z}-rtl`]:"rtl"===A},null==L?void 0:L.className,f,p,X,G);return W(t.createElement("div",Object.assign({ref:d,style:Object.assign(Object.assign({},null==L?void 0:L.style),w),className:Q,role:"progressbar","aria-valuenow":R,"aria-valuemin":0,"aria-valuemax":100},(0,s.default)(S,["trailColor","strokeWidth","width","gapDegree","gapPosition","strokeLinecap","success","successPercent"])),u))});e.s(["default",0,G],309821)},955135,e=>{"use strict";var t=e.i(597440);e.s(["DeleteOutlined",()=>t.default])},519756,e=>{"use strict";e.i(247167);var t=e.i(931067),r=e.i(271645);let l={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M400 317.7h73.9V656c0 4.4 3.6 8 8 8h60c4.4 0 8-3.6 8-8V317.7H624c6.7 0 10.4-7.7 6.3-12.9L518.3 163a8 8 0 00-12.6 0l-112 141.7c-4.1 5.3-.4 13 6.3 13zM878 626h-60c-4.4 0-8 3.6-8 8v154H214V634c0-4.4-3.6-8-8-8h-60c-4.4 0-8 3.6-8 8v198c0 17.7 14.3 32 32 32h684c17.7 0 32-14.3 32-32V634c0-4.4-3.6-8-8-8z"}}]},name:"upload",theme:"outlined"};var a=e.i(9583),n=r.forwardRef(function(e,n){return r.createElement(a.default,(0,t.default)({},e,{ref:n,icon:l}))});e.s(["UploadOutlined",0,n],519756)},91739,e=>{"use strict";var t=e.i(544195);e.s(["Radio",()=>t.default])},220508,e=>{"use strict";var t=e.i(271645);let r=t.forwardRef(function(e,r){return t.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:2,stroke:"currentColor","aria-hidden":"true",ref:r},e),t.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z"}))});e.s(["CheckCircleIcon",0,r],220508)},793130,e=>{"use strict";var t=e.i(290571),r=e.i(429427),l=e.i(371330),a=e.i(271645),n=e.i(394487),o=e.i(503269),i=e.i(214520),s=e.i(746725),c=e.i(914189),d=e.i(144279),u=e.i(294316),m=e.i(601893),f=e.i(140721),p=e.i(942803),g=e.i(233538),h=e.i(694421),b=e.i(700020),y=e.i(35889),x=e.i(998348),v=e.i(722678);let k=(0,a.createContext)(null);k.displayName="GroupContext";let j=a.Fragment,w=Object.assign((0,b.forwardRefWithAs)(function(e,t){var j;let w=(0,a.useId)(),C=(0,p.useProvidedId)(),S=(0,m.useDisabled)(),{id:N=C||`headlessui-switch-${w}`,disabled:$=S||!1,checked:O,defaultChecked:E,onChange:M,name:P,value:_,form:T,autoFocus:D=!1,...R}=e,F=(0,a.useContext)(k),[I,A]=(0,a.useState)(null),L=(0,a.useRef)(null),z=(0,u.useSyncRefs)(L,t,null===F?null:F.setSwitch,A),W=(0,i.useDefaultValue)(E),[B,X]=(0,o.useControllable)(O,M,null!=W&&W),H=(0,s.useDisposables)(),[q,K]=(0,a.useState)(!1),V=(0,c.useEvent)(()=>{K(!0),null==X||X(!B),H.nextFrame(()=>{K(!1)})}),G=(0,c.useEvent)(e=>{if((0,g.isDisabledReactIssue7711)(e.currentTarget))return e.preventDefault();e.preventDefault(),V()}),U=(0,c.useEvent)(e=>{e.key===x.Keys.Space?(e.preventDefault(),V()):e.key===x.Keys.Enter&&(0,h.attemptSubmit)(e.currentTarget)}),J=(0,c.useEvent)(e=>e.preventDefault()),Y=(0,v.useLabelledBy)(),Q=(0,y.useDescribedBy)(),{isFocusVisible:Z,focusProps:ee}=(0,r.useFocusRing)({autoFocus:D}),{isHovered:et,hoverProps:er}=(0,l.useHover)({isDisabled:$}),{pressed:el,pressProps:ea}=(0,n.useActivePress)({disabled:$}),en=(0,a.useMemo)(()=>({checked:B,disabled:$,hover:et,focus:Z,active:el,autofocus:D,changing:q}),[B,et,Z,el,$,q,D]),eo=(0,b.mergeProps)({id:N,ref:z,role:"switch",type:(0,d.useResolveButtonType)(e,I),tabIndex:-1===e.tabIndex?0:null!=(j=e.tabIndex)?j:0,"aria-checked":B,"aria-labelledby":Y,"aria-describedby":Q,disabled:$||void 0,autoFocus:D,onClick:G,onKeyUp:U,onKeyPress:J},ee,er,ea),ei=(0,a.useCallback)(()=>{if(void 0!==W)return null==X?void 0:X(W)},[X,W]),es=(0,b.useRender)();return a.default.createElement(a.default.Fragment,null,null!=P&&a.default.createElement(f.FormFields,{disabled:$,data:{[P]:_||"on"},overrides:{type:"checkbox",checked:B},form:T,onReset:ei}),es({ourProps:eo,theirProps:R,slot:en,defaultTag:"button",name:"Switch"}))}),{Group:function(e){var t;let[r,l]=(0,a.useState)(null),[n,o]=(0,v.useLabels)(),[i,s]=(0,y.useDescriptions)(),c=(0,a.useMemo)(()=>({switch:r,setSwitch:l}),[r,l]),d=(0,b.useRender)();return a.default.createElement(s,{name:"Switch.Description",value:i},a.default.createElement(o,{name:"Switch.Label",value:n,props:{htmlFor:null==(t=c.switch)?void 0:t.id,onClick(e){r&&(e.currentTarget instanceof HTMLLabelElement&&e.preventDefault(),r.click(),r.focus({preventScroll:!0}))}}},a.default.createElement(k.Provider,{value:c},d({ourProps:{},theirProps:e,slot:{},defaultTag:j,name:"Switch.Group"}))))},Label:v.Label,Description:y.Description});var C=e.i(888288),S=e.i(95779),N=e.i(444755),$=e.i(673706),O=e.i(829087);let E=(0,$.makeClassName)("Switch"),M=a.default.forwardRef((e,r)=>{let{checked:l,defaultChecked:n=!1,onChange:o,color:i,name:s,error:c,errorMessage:d,disabled:u,required:m,tooltip:f,id:p}=e,g=(0,t.__rest)(e,["checked","defaultChecked","onChange","color","name","error","errorMessage","disabled","required","tooltip","id"]),h={bgColor:i?(0,$.getColorClassNames)(i,S.colorPalette.background).bgColor:"bg-tremor-brand dark:bg-dark-tremor-brand",ringColor:i?(0,$.getColorClassNames)(i,S.colorPalette.ring).ringColor:"ring-tremor-brand-muted dark:ring-dark-tremor-brand-muted"},[b,y]=(0,C.default)(n,l),[x,v]=(0,a.useState)(!1),{tooltipProps:k,getReferenceProps:j}=(0,O.useTooltip)(300);return a.default.createElement("div",{className:"flex flex-row items-center justify-start"},a.default.createElement(O.default,Object.assign({text:f},k)),a.default.createElement("div",Object.assign({ref:(0,$.mergeRefs)([r,k.refs.setReference]),className:(0,N.tremorTwMerge)(E("root"),"flex flex-row relative h-5")},g,j),a.default.createElement("input",{type:"checkbox",className:(0,N.tremorTwMerge)(E("input"),"absolute w-5 h-5 cursor-pointer left-0 top-0 opacity-0"),name:s,required:m,checked:b,onChange:e=>{e.preventDefault()}}),a.default.createElement(w,{checked:b,onChange:e=>{y(e),null==o||o(e)},disabled:u,className:(0,N.tremorTwMerge)(E("switch"),"w-10 h-5 group relative inline-flex shrink-0 cursor-pointer items-center justify-center rounded-tremor-full","focus:outline-none",u?"cursor-not-allowed":""),onFocus:()=>v(!0),onBlur:()=>v(!1),id:p},a.default.createElement("span",{className:(0,N.tremorTwMerge)(E("sr-only"),"sr-only")},"Switch ",b?"on":"off"),a.default.createElement("span",{"aria-hidden":"true",className:(0,N.tremorTwMerge)(E("background"),b?h.bgColor:"bg-tremor-border dark:bg-dark-tremor-border","pointer-events-none absolute mx-auto h-3 w-9 rounded-tremor-full transition-colors duration-100 ease-in-out")}),a.default.createElement("span",{"aria-hidden":"true",className:(0,N.tremorTwMerge)(E("round"),b?(0,N.tremorTwMerge)(h.bgColor,"translate-x-5 border-tremor-background dark:border-dark-tremor-background"):"translate-x-0 bg-tremor-border dark:bg-dark-tremor-border border-tremor-background dark:border-dark-tremor-background","pointer-events-none absolute left-0 inline-block h-5 w-5 transform rounded-tremor-full border-2 shadow-tremor-input duration-100 ease-in-out transition",x?(0,N.tremorTwMerge)("ring-2",h.ringColor):"")}))),c&&d?a.default.createElement("p",{className:(0,N.tremorTwMerge)(E("errorMessage"),"text-sm text-red-500 mt-1 ")},d):null)});M.displayName="Switch",e.s(["Switch",()=>M],793130)},37727,e=>{"use strict";var t=e.i(841947);e.s(["X",()=>t.default])},653496,e=>{"use strict";var t=e.i(721369);e.s(["Tabs",()=>t.default])},603908,e=>{"use strict";let t=(0,e.i(475254).default)("plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]);e.s(["default",()=>t])},158392,419470,e=>{"use strict";var t=e.i(843476),r=e.i(779241);let l={ttl:3600,lowest_latency_buffer:0},a=({routingStrategyArgs:e})=>{let a={ttl:"Sliding window to look back over when calculating the average latency of a deployment. Default - 1 hour (in seconds).",lowest_latency_buffer:"Shuffle between deployments within this % of the lowest latency. Default - 0 (i.e. always pick lowest latency)."};return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("div",{className:"space-y-6",children:[(0,t.jsxs)("div",{className:"max-w-3xl",children:[(0,t.jsx)("h3",{className:"text-sm font-medium text-gray-900",children:"Latency-Based Configuration"}),(0,t.jsx)("p",{className:"text-xs text-gray-500 mt-1",children:"Fine-tune latency-based routing behavior"})]}),(0,t.jsx)("div",{className:"grid grid-cols-1 gap-6 lg:grid-cols-2 xl:grid-cols-3",children:Object.entries(e||l).map(([e,l])=>(0,t.jsx)("div",{className:"space-y-2",children:(0,t.jsxs)("label",{className:"block",children:[(0,t.jsx)("span",{className:"text-xs font-medium text-gray-700 uppercase tracking-wide",children:e.replace(/_/g," ")}),(0,t.jsx)("p",{className:"text-xs text-gray-500 mt-0.5 mb-2",children:a[e]||""}),(0,t.jsx)(r.TextInput,{name:e,defaultValue:"object"==typeof l?JSON.stringify(l,null,2):l?.toString(),className:"font-mono text-sm w-full"})]})},e))})]}),(0,t.jsx)("div",{className:"border-t border-gray-200"})]})},n=({routerSettings:e,routerFieldsMetadata:l})=>(0,t.jsxs)("div",{className:"space-y-6",children:[(0,t.jsxs)("div",{className:"max-w-3xl",children:[(0,t.jsx)("h3",{className:"text-sm font-medium text-gray-900",children:"Reliability & Retries"}),(0,t.jsx)("p",{className:"text-xs text-gray-500 mt-1",children:"Configure retry logic and failure handling"})]}),(0,t.jsx)("div",{className:"grid grid-cols-1 gap-6 lg:grid-cols-2 xl:grid-cols-3",children:Object.entries(e).filter(([e,t])=>"fallbacks"!=e&&"context_window_fallbacks"!=e&&"routing_strategy_args"!=e&&"routing_strategy"!=e&&"enable_tag_filtering"!=e).map(([e,a])=>(0,t.jsx)("div",{className:"space-y-2",children:(0,t.jsxs)("label",{className:"block",children:[(0,t.jsx)("span",{className:"text-xs font-medium text-gray-700 uppercase tracking-wide",children:l[e]?.ui_field_name||e}),(0,t.jsx)("p",{className:"text-xs text-gray-500 mt-0.5 mb-2",children:l[e]?.field_description||""}),(0,t.jsx)(r.TextInput,{name:e,defaultValue:null==a||"null"===a?"":"object"==typeof a?JSON.stringify(a,null,2):a?.toString()||"",placeholder:"—",className:"font-mono text-sm w-full"})]})},e))})]});var o=e.i(199133);let i=({selectedStrategy:e,availableStrategies:r,routingStrategyDescriptions:l,routerFieldsMetadata:a,onStrategyChange:n})=>(0,t.jsxs)("div",{className:"space-y-2 max-w-3xl",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{className:"text-xs font-medium text-gray-700 uppercase tracking-wide",children:a.routing_strategy?.ui_field_name||"Routing Strategy"}),(0,t.jsx)("p",{className:"text-xs text-gray-500 mt-0.5 mb-2",children:a.routing_strategy?.field_description||""})]}),(0,t.jsx)("div",{className:"routing-strategy-select max-w-3xl",children:(0,t.jsx)(o.Select,{value:e,onChange:n,style:{width:"100%"},size:"large",children:r.map(e=>(0,t.jsx)(o.Select.Option,{value:e,label:e,children:(0,t.jsxs)("div",{className:"flex flex-col gap-0.5 py-1",children:[(0,t.jsx)("span",{className:"font-mono text-sm font-medium",children:e}),l[e]&&(0,t.jsx)("span",{className:"text-xs text-gray-500 font-normal",children:l[e]})]})},e))})})]});var s=e.i(793130);let c=({enabled:e,routerFieldsMetadata:r,onToggle:l})=>(0,t.jsx)("div",{className:"space-y-3 max-w-3xl",children:(0,t.jsxs)("div",{className:"flex items-start justify-between",children:[(0,t.jsxs)("div",{className:"flex-1",children:[(0,t.jsx)("label",{className:"text-xs font-medium text-gray-700 uppercase tracking-wide",children:r.enable_tag_filtering?.ui_field_name||"Enable Tag Filtering"}),(0,t.jsxs)("p",{className:"text-xs text-gray-500 mt-0.5",children:[r.enable_tag_filtering?.field_description||"",r.enable_tag_filtering?.link&&(0,t.jsxs)(t.Fragment,{children:[" ",(0,t.jsx)("a",{href:r.enable_tag_filtering.link,target:"_blank",rel:"noopener noreferrer",className:"text-blue-600 hover:text-blue-800 underline",children:"Learn more"})]})]})]}),(0,t.jsx)(s.Switch,{checked:e,onChange:l,className:"ml-4"})]})});e.s(["default",0,({value:e,onChange:r,routerFieldsMetadata:l,availableRoutingStrategies:o,routingStrategyDescriptions:s})=>(0,t.jsxs)("div",{className:"w-full space-y-8 py-2",children:[(0,t.jsxs)("div",{className:"space-y-6",children:[(0,t.jsxs)("div",{className:"max-w-3xl",children:[(0,t.jsx)("h3",{className:"text-sm font-medium text-gray-900",children:"Routing Settings"}),(0,t.jsx)("p",{className:"text-xs text-gray-500 mt-1",children:"Configure how requests are routed to deployments"})]}),o.length>0&&(0,t.jsx)(i,{selectedStrategy:e.selectedStrategy||e.routerSettings.routing_strategy||null,availableStrategies:o,routingStrategyDescriptions:s,routerFieldsMetadata:l,onStrategyChange:t=>{r({...e,selectedStrategy:t})}}),(0,t.jsx)(c,{enabled:e.enableTagFiltering,routerFieldsMetadata:l,onToggle:t=>{r({...e,enableTagFiltering:t})}})]}),(0,t.jsx)("div",{className:"border-t border-gray-200"}),"latency-based-routing"===e.selectedStrategy&&(0,t.jsx)(a,{routingStrategyArgs:e.routerSettings.routing_strategy_args}),(0,t.jsx)(n,{routerSettings:e.routerSettings,routerFieldsMetadata:l})]})],158392);var d=e.i(994388),u=e.i(998573),m=e.i(653496),f=e.i(603908),f=f,p=e.i(271645),g=e.i(592968),h=e.i(475254);let b=(0,h.default)("circle-alert",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]]),y=(0,h.default)("arrow-down",[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]]);var x=e.i(37727);function v({group:e,onChange:r,availableModels:l,maxFallbacks:a}){let n=l.filter(t=>t!==e.primaryModel),i=e.fallbackModels.length{let l=[...e.fallbackModels];l.includes(t)&&(l=l.filter(e=>e!==t)),r({...e,primaryModel:t,fallbackModels:l})},showSearch:!0,filterOption:(e,t)=>(t?.label??"").toLowerCase().includes(e.toLowerCase()),options:l.map(e=>({label:e,value:e}))}),!e.primaryModel&&(0,t.jsxs)("div",{className:"mt-2 flex items-center gap-2 text-amber-600 text-xs bg-amber-50 p-2 rounded",children:[(0,t.jsx)(b,{className:"w-4 h-4"}),(0,t.jsx)("span",{children:"Select a model to begin configuring fallbacks"})]})]}),(0,t.jsx)("div",{className:"flex items-center justify-center -my-4 z-10",children:(0,t.jsxs)("div",{className:"bg-indigo-50 text-indigo-500 px-4 py-1 rounded-full text-xs font-bold border border-indigo-100 flex items-center gap-2 shadow-sm",children:[(0,t.jsx)(y,{className:"w-4 h-4"}),"IF FAILS, TRY..."]})}),(0,t.jsxs)("div",{className:`transition-opacity duration-300 ${!e.primaryModel?"opacity-50 pointer-events-none":"opacity-100"}`,children:[(0,t.jsxs)("label",{className:"block text-sm font-semibold text-gray-700 mb-2",children:["Fallback Chain ",(0,t.jsx)("span",{className:"text-red-500",children:"*"}),(0,t.jsxs)("span",{className:"text-xs text-gray-500 font-normal ml-2",children:["(Max ",a," fallbacks at a time)"]})]}),(0,t.jsxs)("div",{className:"bg-gray-50 rounded-xl p-4 border border-gray-200",children:[(0,t.jsxs)("div",{className:"mb-4",children:[(0,t.jsx)(o.Select,{mode:"multiple",className:"w-full",size:"large",placeholder:i?"Select fallback models to add...":`Maximum ${a} fallbacks reached`,value:e.fallbackModels,onChange:t=>{let l=t.slice(0,a);r({...e,fallbackModels:l})},disabled:!e.primaryModel,options:n.map(e=>({label:e,value:e})),optionRender:(r,l)=>{let a=e.fallbackModels.includes(r.value),n=a?e.fallbackModels.indexOf(r.value)+1:null;return(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[a&&null!==n&&(0,t.jsx)("span",{className:"flex items-center justify-center w-5 h-5 rounded bg-indigo-100 text-indigo-600 text-xs font-bold",children:n}),(0,t.jsx)("span",{children:r.label})]})},maxTagCount:"responsive",maxTagPlaceholder:e=>(0,t.jsx)(g.Tooltip,{styles:{root:{pointerEvents:"none"}},title:e.map(({value:e})=>e).join(", "),children:(0,t.jsxs)("span",{children:["+",e.length," more"]})}),showSearch:!0,filterOption:(e,t)=>(t?.label??"").toLowerCase().includes(e.toLowerCase())}),(0,t.jsx)("p",{className:"text-xs text-gray-500 mt-1 ml-1",children:i?`Search and select multiple models. Selected models will appear below in order. (${e.fallbackModels.length}/${a} used)`:`Maximum ${a} fallbacks reached. Remove some to add more.`})]}),(0,t.jsx)("div",{className:"space-y-2 min-h-[100px]",children:0===e.fallbackModels.length?(0,t.jsxs)("div",{className:"h-32 border-2 border-dashed border-gray-300 rounded-lg flex flex-col items-center justify-center text-gray-400",children:[(0,t.jsx)("span",{className:"text-sm",children:"No fallback models selected"}),(0,t.jsx)("span",{className:"text-xs mt-1",children:"Add models from the dropdown above"})]}):e.fallbackModels.map((l,a)=>(0,t.jsxs)("div",{className:"group flex items-center justify-between p-3 bg-white rounded-lg border border-gray-200 hover:border-indigo-300 hover:shadow-sm transition-all",children:[(0,t.jsxs)("div",{className:"flex items-center gap-3",children:[(0,t.jsx)("div",{className:"flex items-center justify-center w-6 h-6 rounded bg-gray-100 text-gray-400 group-hover:text-indigo-500 group-hover:bg-indigo-50",children:(0,t.jsx)("span",{className:"text-xs font-bold",children:a+1})}),(0,t.jsx)("div",{children:(0,t.jsx)("span",{className:"font-medium text-gray-800",children:l})})]}),(0,t.jsx)("button",{type:"button",onClick:()=>{let t;return t=e.fallbackModels.filter((e,t)=>t!==a),void r({...e,fallbackModels:t})},className:"opacity-0 group-hover:opacity-100 transition-opacity text-gray-400 hover:text-red-500 p-1",children:(0,t.jsx)(x.X,{className:"w-4 h-4"})})]},`${l}-${a}`))})]})]})]})}function k({groups:e,onGroupsChange:r,availableModels:l,maxFallbacks:a=5,maxGroups:n=5}){let[o,i]=(0,p.useState)(e.length>0?e[0].id:"1");(0,p.useEffect)(()=>{e.length>0?e.some(e=>e.id===o)||i(e[0].id):i("1")},[e]);let s=()=>{if(e.length>=n)return;let t=Date.now().toString();r([...e,{id:t,primaryModel:null,fallbackModels:[]}]),i(t)},c=t=>{r(e.map(e=>e.id===t.id?t:e))},g=e.map((r,n)=>{let o=r.primaryModel?r.primaryModel:`Group ${n+1}`;return{key:r.id,label:o,closable:e.length>1,children:(0,t.jsx)(v,{group:r,onChange:c,availableModels:l,maxFallbacks:a})}});return 0===e.length?(0,t.jsxs)("div",{className:"text-center py-12 bg-gray-50 rounded-lg border border-dashed border-gray-300",children:[(0,t.jsx)("p",{className:"text-gray-500 mb-4",children:"No fallback groups configured"}),(0,t.jsx)(d.Button,{variant:"primary",onClick:s,icon:()=>(0,t.jsx)(f.default,{className:"w-4 h-4"}),children:"Create First Group"})]}):(0,t.jsx)(m.Tabs,{type:"editable-card",activeKey:o,onChange:i,onEdit:(t,l)=>{"add"===l?s():"remove"===l&&e.length>1&&(t=>{if(1===e.length)return u.message.warning("At least one group is required");let l=e.filter(e=>e.id!==t);r(l),o===t&&l.length>0&&i(l[l.length-1].id)})(t)},items:g,className:"fallback-tabs",tabBarStyle:{marginBottom:0},hideAdd:e.length>=n})}e.s(["FallbackSelectionForm",()=>k],419470)}]); \ No newline at end of file diff --git a/litellm/proxy/_experimental/out/_next/static/chunks/16123b35dd50b2e0.js b/litellm/proxy/_experimental/out/_next/static/chunks/16123b35dd50b2e0.js new file mode 100644 index 00000000000..60db1679914 --- /dev/null +++ b/litellm/proxy/_experimental/out/_next/static/chunks/16123b35dd50b2e0.js @@ -0,0 +1 @@ +(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,533882,e=>{"use strict";var a=e.i(843476),s=e.i(271645),t=e.i(250980),l=e.i(797672),r=e.i(68155),i=e.i(304967),n=e.i(629569),c=e.i(599724),o=e.i(269200),d=e.i(427612),m=e.i(64848),u=e.i(942232),g=e.i(496020),x=e.i(977572),p=e.i(992619),h=e.i(727749);e.s(["default",0,({accessToken:e,initialModelAliases:b={},onAliasUpdate:f,showExampleConfig:v=!0})=>{let[y,j]=(0,s.useState)([]),[_,N]=(0,s.useState)({aliasName:"",targetModel:""}),[w,k]=(0,s.useState)(null);(0,s.useEffect)(()=>{j(Object.entries(b).map(([e,a],s)=>({id:`${s}-${e}`,aliasName:e,targetModel:a})))},[b]);let C=()=>{if(!w)return;if(!w.aliasName||!w.targetModel)return void h.default.fromBackend("Please provide both alias name and target model");if(y.some(e=>e.id!==w.id&&e.aliasName===w.aliasName))return void h.default.fromBackend("An alias with this name already exists");let e=y.map(e=>e.id===w.id?w:e);j(e),k(null);let a={};e.forEach(e=>{a[e.aliasName]=e.targetModel}),f&&f(a),h.default.success("Alias updated successfully")},S=()=>{k(null)},T=y.reduce((e,a)=>(e[a.aliasName]=a.targetModel,e),{});return(0,a.jsxs)("div",{className:"mt-4",children:[(0,a.jsxs)("div",{className:"mb-6",children:[(0,a.jsx)(c.Text,{className:"text-sm font-medium text-gray-700 mb-2",children:"Add New Alias"}),(0,a.jsxs)("div",{className:"grid grid-cols-3 gap-4",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("label",{className:"block text-xs text-gray-500 mb-1",children:"Alias Name"}),(0,a.jsx)("input",{type:"text",value:_.aliasName,onChange:e=>N({..._,aliasName:e.target.value}),placeholder:"e.g., gpt-4o",className:"w-full px-3 py-2 border border-gray-300 rounded-md text-sm"})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("label",{className:"block text-xs text-gray-500 mb-1",children:"Target Model"}),(0,a.jsx)(p.default,{accessToken:e,value:_.targetModel,placeholder:"Select target model",onChange:e=>N({..._,targetModel:e}),showLabel:!1})]}),(0,a.jsx)("div",{className:"flex items-end",children:(0,a.jsxs)("button",{onClick:()=>{if(!_.aliasName||!_.targetModel)return void h.default.fromBackend("Please provide both alias name and target model");if(y.some(e=>e.aliasName===_.aliasName))return void h.default.fromBackend("An alias with this name already exists");let e=[...y,{id:`${Date.now()}-${_.aliasName}`,aliasName:_.aliasName,targetModel:_.targetModel}];j(e),N({aliasName:"",targetModel:""});let a={};e.forEach(e=>{a[e.aliasName]=e.targetModel}),f&&f(a),h.default.success("Alias added successfully")},disabled:!_.aliasName||!_.targetModel,className:`flex items-center px-4 py-2 rounded-md text-sm ${!_.aliasName||!_.targetModel?"bg-gray-300 text-gray-500 cursor-not-allowed":"bg-green-600 text-white hover:bg-green-700"}`,children:[(0,a.jsx)(t.PlusCircleIcon,{className:"w-4 h-4 mr-1"}),"Add Alias"]})})]})]}),(0,a.jsx)(c.Text,{className:"text-sm font-medium text-gray-700 mb-2",children:"Manage Existing Aliases"}),(0,a.jsx)("div",{className:"rounded-lg custom-border relative mb-6",children:(0,a.jsx)("div",{className:"overflow-x-auto",children:(0,a.jsxs)(o.Table,{className:"[&_td]:py-0.5 [&_th]:py-1",children:[(0,a.jsx)(d.TableHead,{children:(0,a.jsxs)(g.TableRow,{children:[(0,a.jsx)(m.TableHeaderCell,{className:"py-1 h-8",children:"Alias Name"}),(0,a.jsx)(m.TableHeaderCell,{className:"py-1 h-8",children:"Target Model"}),(0,a.jsx)(m.TableHeaderCell,{className:"py-1 h-8",children:"Actions"})]})}),(0,a.jsxs)(u.TableBody,{children:[y.map(s=>(0,a.jsx)(g.TableRow,{className:"h-8",children:w&&w.id===s.id?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(x.TableCell,{className:"py-0.5",children:(0,a.jsx)("input",{type:"text",value:w.aliasName,onChange:e=>k({...w,aliasName:e.target.value}),className:"w-full px-2 py-1 border border-gray-300 rounded-md text-sm"})}),(0,a.jsx)(x.TableCell,{className:"py-0.5",children:(0,a.jsx)(p.default,{accessToken:e,value:w.targetModel,onChange:e=>k({...w,targetModel:e}),showLabel:!1,style:{height:"32px"}})}),(0,a.jsx)(x.TableCell,{className:"py-0.5 whitespace-nowrap",children:(0,a.jsxs)("div",{className:"flex space-x-2",children:[(0,a.jsx)("button",{onClick:C,className:"text-xs bg-blue-50 text-blue-600 px-2 py-1 rounded hover:bg-blue-100",children:"Save"}),(0,a.jsx)("button",{onClick:S,className:"text-xs bg-gray-50 text-gray-600 px-2 py-1 rounded hover:bg-gray-100",children:"Cancel"})]})})]}):(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(x.TableCell,{className:"py-0.5 text-sm text-gray-900",children:s.aliasName}),(0,a.jsx)(x.TableCell,{className:"py-0.5 text-sm text-gray-500",children:s.targetModel}),(0,a.jsx)(x.TableCell,{className:"py-0.5 whitespace-nowrap",children:(0,a.jsxs)("div",{className:"flex space-x-2",children:[(0,a.jsx)("button",{onClick:()=>{k({...s})},className:"text-xs bg-blue-50 text-blue-600 px-2 py-1 rounded hover:bg-blue-100",children:(0,a.jsx)(l.PencilIcon,{className:"w-3 h-3"})}),(0,a.jsx)("button",{onClick:()=>{var e;let a,t;return e=s.id,j(a=y.filter(a=>a.id!==e)),t={},void(a.forEach(e=>{t[e.aliasName]=e.targetModel}),f&&f(t),h.default.success("Alias deleted successfully"))},className:"text-xs bg-red-50 text-red-600 px-2 py-1 rounded hover:bg-red-100",children:(0,a.jsx)(r.TrashIcon,{className:"w-3 h-3"})})]})})]})},s.id)),0===y.length&&(0,a.jsx)(g.TableRow,{children:(0,a.jsx)(x.TableCell,{colSpan:3,className:"py-0.5 text-sm text-gray-500 text-center",children:"No aliases added yet. Add a new alias above."})})]})]})})}),v&&(0,a.jsxs)(i.Card,{children:[(0,a.jsx)(n.Title,{className:"mb-4",children:"Configuration Example"}),(0,a.jsx)(c.Text,{className:"text-gray-600 mb-4",children:"Here's how your current aliases would look in the config:"}),(0,a.jsx)("div",{className:"bg-gray-100 rounded-lg p-4 font-mono text-sm",children:(0,a.jsxs)("div",{className:"text-gray-700",children:["model_aliases:",0===Object.keys(T).length?(0,a.jsxs)("span",{className:"text-gray-500",children:[(0,a.jsx)("br",{}),"  # No aliases configured yet"]}):Object.entries(T).map(([e,s])=>(0,a.jsxs)("span",{children:[(0,a.jsx)("br",{}),'  "',e,'": "',s,'"']},e))]})})]})]})}])},651904,e=>{"use strict";var a=e.i(843476),s=e.i(599724),t=e.i(266484);e.s(["default",0,function({value:e,onChange:l,premiumUser:r=!1,disabledCallbacks:i=[],onDisabledCallbacksChange:n}){return r?(0,a.jsx)(t.default,{value:e,onChange:l,disabledCallbacks:i,onDisabledCallbacksChange:n}):(0,a.jsxs)("div",{children:[(0,a.jsxs)("div",{className:"flex flex-wrap gap-2 mb-3",children:[(0,a.jsx)("div",{className:"inline-flex items-center px-3 py-1.5 rounded-lg bg-green-50 border border-green-200 text-green-800 text-sm font-medium opacity-50",children:"✨ langfuse-logging"}),(0,a.jsx)("div",{className:"inline-flex items-center px-3 py-1.5 rounded-lg bg-green-50 border border-green-200 text-green-800 text-sm font-medium opacity-50",children:"✨ datadog-logging"})]}),(0,a.jsx)("div",{className:"p-3 bg-yellow-50 border border-yellow-200 rounded-lg",children:(0,a.jsxs)(s.Text,{className:"text-sm text-yellow-800",children:["Setting Key/Team logging settings is a LiteLLM Enterprise feature. Global Logging Settings are available for all free users. Get a trial key"," ",(0,a.jsx)("a",{href:"https://www.litellm.ai/#pricing",target:"_blank",rel:"noopener noreferrer",className:"underline",children:"here"}),"."]})})]})}])},797672,e=>{"use strict";var a=e.i(271645);let s=a.forwardRef(function(e,s){return a.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:2,stroke:"currentColor","aria-hidden":"true",ref:s},e),a.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M15.232 5.232l3.536 3.536m-2.036-5.036a2.5 2.5 0 113.536 3.536L6.5 21.036H3v-3.572L16.732 3.732z"}))});e.s(["PencilIcon",0,s],797672)},689020,e=>{"use strict";var a=e.i(764205);let s=async e=>{try{let s=await (0,a.modelHubCall)(e);if(console.log("model_info:",s),s?.data.length>0){let e=s.data.map(e=>({model_group:e.model_group,mode:e?.mode}));return e.sort((e,a)=>e.model_group.localeCompare(a.model_group)),e}return[]}catch(e){throw console.error("Error fetching model info:",e),e}};e.s(["fetchAvailableModels",0,s])},983561,e=>{"use strict";e.i(247167);var a=e.i(931067),s=e.i(271645);let t={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M300 328a60 60 0 10120 0 60 60 0 10-120 0zM852 64H172c-17.7 0-32 14.3-32 32v660c0 17.7 14.3 32 32 32h680c17.7 0 32-14.3 32-32V96c0-17.7-14.3-32-32-32zm-32 660H204V128h616v596zM604 328a60 60 0 10120 0 60 60 0 10-120 0zm250.2 556H169.8c-16.5 0-29.8 14.3-29.8 32v36c0 4.4 3.3 8 7.4 8h729.1c4.1 0 7.4-3.6 7.4-8v-36c.1-17.7-13.2-32-29.7-32zM664 508H360c-4.4 0-8 3.6-8 8v60c0 4.4 3.6 8 8 8h304c4.4 0 8-3.6 8-8v-60c0-4.4-3.6-8-8-8z"}}]},name:"robot",theme:"outlined"};var l=e.i(9583),r=s.forwardRef(function(e,r){return s.createElement(l.default,(0,a.default)({},e,{ref:r,icon:t}))});e.s(["RobotOutlined",0,r],983561)},992619,e=>{"use strict";var a=e.i(843476),s=e.i(271645),t=e.i(779241),l=e.i(599724),r=e.i(199133),i=e.i(983561),n=e.i(689020);e.s(["default",0,({accessToken:e,value:c,placeholder:o="Select a Model",onChange:d,disabled:m=!1,style:u,className:g,showLabel:x=!0,labelText:p="Select Model"})=>{let[h,b]=(0,s.useState)(c),[f,v]=(0,s.useState)(!1),[y,j]=(0,s.useState)([]),_=(0,s.useRef)(null);return(0,s.useEffect)(()=>{b(c)},[c]),(0,s.useEffect)(()=>{e&&(async()=>{try{let a=await (0,n.fetchAvailableModels)(e);console.log("Fetched models for selector:",a),a.length>0&&j(a)}catch(e){console.error("Error fetching model info:",e)}})()},[e]),(0,a.jsxs)("div",{children:[x&&(0,a.jsxs)(l.Text,{className:"font-medium block mb-2 text-gray-700 flex items-center",children:[(0,a.jsx)(i.RobotOutlined,{className:"mr-2"})," ",p]}),(0,a.jsx)(r.Select,{value:h,placeholder:o,onChange:e=>{"custom"===e?(v(!0),b(void 0)):(v(!1),b(e),d&&d(e))},options:[...Array.from(new Set(y.map(e=>e.model_group))).map((e,a)=>({value:e,label:e,key:a})),{value:"custom",label:"Enter custom model",key:"custom"}],style:{width:"100%",...u},showSearch:!0,className:`rounded-md ${g||""}`,disabled:m}),f&&(0,a.jsx)(t.TextInput,{className:"mt-2",placeholder:"Enter custom model name",onValueChange:e=>{_.current&&clearTimeout(_.current),_.current=setTimeout(()=>{b(e),d&&d(e)},500)},disabled:m})]})}])},500727,e=>{"use strict";var a=e.i(266027),s=e.i(243652),t=e.i(764205),l=e.i(135214);let r=(0,s.createQueryKeys)("mcpServers");e.s(["useMCPServers",0,()=>{let{accessToken:e}=(0,l.default)();return(0,a.useQuery)({queryKey:r.list({}),queryFn:async()=>await (0,t.fetchMCPServers)(e),enabled:!!e})}])},841947,e=>{"use strict";let a=(0,e.i(475254).default)("x",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]);e.s(["default",()=>a])},916940,e=>{"use strict";var a=e.i(843476),s=e.i(271645),t=e.i(199133),l=e.i(764205);e.s(["default",0,({onChange:e,value:r,className:i,accessToken:n,placeholder:c="Select vector stores",disabled:o=!1})=>{let[d,m]=(0,s.useState)([]),[u,g]=(0,s.useState)(!1);return(0,s.useEffect)(()=>{(async()=>{if(n){g(!0);try{let e=await (0,l.vectorStoreListCall)(n);e.data&&m(e.data)}catch(e){console.error("Error fetching vector stores:",e)}finally{g(!1)}}})()},[n]),(0,a.jsx)("div",{children:(0,a.jsx)(t.Select,{mode:"multiple",placeholder:c,onChange:e,value:r,loading:u,className:i,allowClear:!0,options:d.map(e=>({label:`${e.vector_store_name||e.vector_store_id} (${e.vector_store_id})`,value:e.vector_store_id,title:e.vector_store_description||e.vector_store_id})),optionFilterProp:"label",showSearch:!0,style:{width:"100%"},disabled:o})})}])},552130,e=>{"use strict";var a=e.i(843476),s=e.i(271645),t=e.i(199133),l=e.i(764205);e.s(["default",0,({onChange:e,value:r,className:i,accessToken:n,placeholder:c="Select agents",disabled:o=!1})=>{let[d,m]=(0,s.useState)([]),[u,g]=(0,s.useState)([]),[x,p]=(0,s.useState)(!1);(0,s.useEffect)(()=>{(async()=>{if(n){p(!0);try{let e=await (0,l.getAgentsList)(n),a=e?.agents||[];m(a);let s=new Set;a.forEach(e=>{let a=e.agent_access_groups;a&&Array.isArray(a)&&a.forEach(e=>s.add(e))}),g(Array.from(s))}catch(e){console.error("Error fetching agents:",e)}finally{p(!1)}}})()},[n]);let h=[...u.map(e=>({label:e,value:`group:${e}`,isAccessGroup:!0,searchText:`${e} Access Group`})),...d.map(e=>({label:`${e.agent_name||e.agent_id}`,value:e.agent_id,isAccessGroup:!1,searchText:`${e.agent_name||e.agent_id} ${e.agent_id} Agent`}))],b=[...r?.agents||[],...(r?.accessGroups||[]).map(e=>`group:${e}`)];return(0,a.jsx)("div",{children:(0,a.jsx)(t.Select,{mode:"multiple",placeholder:c,onChange:a=>{e({agents:a.filter(e=>!e.startsWith("group:")),accessGroups:a.filter(e=>e.startsWith("group:")).map(e=>e.replace("group:",""))})},value:b,loading:x,className:i,allowClear:!0,showSearch:!0,style:{width:"100%"},disabled:o,filterOption:(e,a)=>(h.find(e=>e.value===a?.value)?.searchText||"").toLowerCase().includes(e.toLowerCase()),children:h.map(e=>(0,a.jsx)(t.Select.Option,{value:e.value,label:e.label,children:(0,a.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[(0,a.jsx)("span",{style:{display:"inline-block",width:8,height:8,borderRadius:"50%",background:e.isAccessGroup?"#52c41a":"#722ed1",flexShrink:0}}),(0,a.jsx)("span",{style:{flex:1},children:e.label}),(0,a.jsx)("span",{style:{color:e.isAccessGroup?"#52c41a":"#722ed1",fontSize:"12px",fontWeight:500,opacity:.8},children:e.isAccessGroup?"Access Group":"Agent"})]})},e.value))})})}])},557662,e=>{"use strict";let a="../ui/assets/logos/",s=[{id:"arize",displayName:"Arize",logo:`${a}arize.png`,supports_key_team_logging:!0,dynamic_params:{arize_api_key:"password",arize_space_id:"password"},description:"Arize Logging Integration"},{id:"braintrust",displayName:"Braintrust",logo:`${a}braintrust.png`,supports_key_team_logging:!1,dynamic_params:{braintrust_api_key:"password",braintrust_project_name:"text"},description:"Braintrust Logging Integration"},{id:"custom_callback_api",displayName:"Custom Callback API",logo:`${a}custom.svg`,supports_key_team_logging:!0,dynamic_params:{custom_callback_api_url:"text",custom_callback_api_headers:"text"},description:"Custom Callback API Logging Integration"},{id:"datadog",displayName:"Datadog",logo:`${a}datadog.png`,supports_key_team_logging:!1,dynamic_params:{dd_api_key:"password",dd_site:"text"},description:"Datadog Logging Integration"},{id:"lago",displayName:"Lago",logo:`${a}lago.svg`,supports_key_team_logging:!1,dynamic_params:{lago_api_url:"text",lago_api_key:"password"},description:"Lago Billing Logging Integration"},{id:"langfuse",displayName:"Langfuse",logo:`${a}langfuse.png`,supports_key_team_logging:!0,dynamic_params:{langfuse_public_key:"text",langfuse_secret_key:"password",langfuse_host:"text"},description:"Langfuse v2 Logging Integration"},{id:"langfuse_otel",displayName:"Langfuse OTEL",logo:`${a}langfuse.png`,supports_key_team_logging:!0,dynamic_params:{langfuse_public_key:"text",langfuse_secret_key:"password",langfuse_host:"text"},description:"Langfuse v3 OTEL Logging Integration"},{id:"langsmith",displayName:"LangSmith",logo:`${a}langsmith.png`,supports_key_team_logging:!0,dynamic_params:{langsmith_api_key:"password",langsmith_project:"text",langsmith_base_url:"text",langsmith_sampling_rate:"number"},description:"Langsmith Logging Integration"},{id:"openmeter",displayName:"OpenMeter",logo:`${a}openmeter.png`,supports_key_team_logging:!1,dynamic_params:{openmeter_api_key:"password",openmeter_base_url:"text"},description:"OpenMeter Logging Integration"},{id:"otel",displayName:"Open Telemetry",logo:`${a}otel.png`,supports_key_team_logging:!1,dynamic_params:{otel_endpoint:"text",otel_headers:"text"},description:"OpenTelemetry Logging Integration"},{id:"s3",displayName:"S3",logo:`${a}aws.svg`,supports_key_team_logging:!1,dynamic_params:{s3_bucket_name:"text",aws_access_key_id:"password",aws_secret_access_key:"password",aws_region:"text"},description:"S3 Bucket (AWS) Logging Integration"},{id:"SQS",displayName:"SQS",logo:`${a}aws.svg`,supports_key_team_logging:!1,dynamic_params:{sqs_queue_url:"text",aws_access_key_id:"password",aws_secret_access_key:"password",aws_region:"text"},description:"SQS Queue (AWS) Logging Integration"}],t=s.reduce((e,a)=>(e[a.displayName]=a,e),{}),l=s.reduce((e,a)=>(e[a.displayName]=a.id,e),{}),r=s.reduce((e,a)=>(e[a.id]=a.displayName,e),{});e.s(["callbackInfo",0,t,"callback_map",0,l,"mapDisplayToInternalNames",0,e=>e.map(e=>l[e]||e),"mapInternalToDisplayNames",0,e=>e.map(e=>r[e]||e),"reverse_callback_map",0,r])},844565,e=>{"use strict";var a=e.i(843476),s=e.i(271645),t=e.i(199133),l=e.i(764205);e.s(["default",0,({onChange:e,value:r,className:i,accessToken:n,placeholder:c="Select pass through routes",disabled:o=!1,teamId:d})=>{let[m,u]=(0,s.useState)([]),[g,x]=(0,s.useState)(!1);return(0,s.useEffect)(()=>{(async()=>{if(n){x(!0);try{let e=await (0,l.getPassThroughEndpointsCall)(n,d);if(e.endpoints){let a=e.endpoints.map(e=>e.path);u(a)}}catch(e){console.error("Error fetching pass through routes:",e)}finally{x(!1)}}})()},[n,d]),(0,a.jsx)(t.Select,{mode:"tags",placeholder:c,onChange:e,value:r,loading:g,className:i,allowClear:!0,options:m.map(e=>({label:e,value:e})),optionFilterProp:"label",showSearch:!0,style:{width:"100%"},disabled:o})}])},988297,e=>{"use strict";var a=e.i(271645);let s=a.forwardRef(function(e,s){return a.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:2,stroke:"currentColor","aria-hidden":"true",ref:s},e),a.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 4v16m8-8H4"}))});e.s(["PlusIcon",0,s],988297)},810757,477386,e=>{"use strict";var a=e.i(271645);let s=a.forwardRef(function(e,s){return a.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:2,stroke:"currentColor","aria-hidden":"true",ref:s},e),a.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 002.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 001.065 2.572c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 00-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 00-2.572 1.065c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 00-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 00-1.065-2.572c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 001.066-2.573c-.94-1.543.826-3.31 2.37-2.37.996.608 2.296.07 2.572-1.065z"}),a.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M15 12a3 3 0 11-6 0 3 3 0 016 0z"}))});e.s(["CogIcon",0,s],810757);let t=a.forwardRef(function(e,s){return a.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:2,stroke:"currentColor","aria-hidden":"true",ref:s},e),a.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M18.364 18.364A9 9 0 005.636 5.636m12.728 12.728A9 9 0 015.636 5.636m12.728 12.728L5.636 5.636"}))});e.s(["BanIcon",0,t],477386)},266484,e=>{"use strict";var a=e.i(843476),s=e.i(199133),t=e.i(592968),l=e.i(312361),r=e.i(827252),i=e.i(994388),n=e.i(304967),c=e.i(779241),o=e.i(988297),d=e.i(68155),m=e.i(810757),u=e.i(477386),g=e.i(557662),x=e.i(435451);let{Option:p}=s.Select;e.s(["default",0,({value:e=[],onChange:h,disabledCallbacks:b=[],onDisabledCallbacksChange:f})=>{let v=Object.entries(g.callbackInfo).filter(([e,a])=>a.supports_key_team_logging).map(([e,a])=>e),y=Object.keys(g.callbackInfo),j=e=>{h?.(e)},_=(a,s,t)=>{let l=[...e];if("callback_name"===s){let e=g.callback_map[t]||t;l[a]={...l[a],[s]:e,callback_vars:{}}}else l[a]={...l[a],[s]:t};j(l)},N=(a,s,t)=>{let l=[...e];l[a]={...l[a],callback_vars:{...l[a].callback_vars,[s]:t}},j(l)};return(0,a.jsxs)("div",{className:"space-y-6",children:[(0,a.jsxs)("div",{className:"space-y-4",children:[(0,a.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,a.jsx)(u.BanIcon,{className:"w-5 h-5 text-red-500"}),(0,a.jsx)("span",{className:"text-base font-semibold text-gray-800",children:"Disabled Callbacks"}),(0,a.jsx)(t.Tooltip,{title:"Select callbacks to disable for this key. Disabled callbacks will not receive any logging data.",children:(0,a.jsx)(r.InfoCircleOutlined,{className:"text-gray-400 cursor-help"})})]}),(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsx)("label",{className:"text-sm font-medium text-gray-700",children:"Disabled Callbacks"}),(0,a.jsx)(s.Select,{mode:"multiple",placeholder:"Select callbacks to disable",value:b,onChange:e=>{let a=(0,g.mapDisplayToInternalNames)(e);f?.(a)},style:{width:"100%"},optionLabelProp:"label",children:y.map(e=>{let s=g.callbackInfo[e]?.logo,l=g.callbackInfo[e]?.description;return(0,a.jsx)(p,{value:e,label:e,children:(0,a.jsx)(t.Tooltip,{title:l,placement:"right",children:(0,a.jsxs)("div",{className:"flex items-center space-x-2",children:[s&&(0,a.jsx)("img",{src:s,alt:e,className:"w-4 h-4 object-contain",onError:a=>{let s=a.target,t=s.parentElement;if(t){let a=document.createElement("div");a.className="w-4 h-4 rounded-full bg-gray-200 flex items-center justify-center text-xs",a.textContent=e.charAt(0),t.replaceChild(a,s)}}}),(0,a.jsx)("span",{children:e})]})})},e)})}),(0,a.jsx)("div",{className:"text-xs text-gray-500",children:"Select callbacks that should be disabled for this key. These callbacks will not receive any logging data."})]})]}),(0,a.jsx)(l.Divider,{}),(0,a.jsxs)("div",{className:"flex justify-between items-center",children:[(0,a.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,a.jsx)(m.CogIcon,{className:"w-5 h-5 text-blue-500"}),(0,a.jsx)("span",{className:"text-base font-semibold text-gray-800",children:"Logging Integrations"}),(0,a.jsx)(t.Tooltip,{title:"Configure callback logging integrations for this team.",children:(0,a.jsx)(r.InfoCircleOutlined,{className:"text-gray-400 cursor-help"})})]}),(0,a.jsx)(i.Button,{variant:"secondary",onClick:()=>{j([...e,{callback_name:"",callback_type:"success",callback_vars:{}}])},icon:o.PlusIcon,size:"sm",className:"hover:border-blue-400 hover:text-blue-500",type:"button",children:"Add Integration"})]}),(0,a.jsx)("div",{className:"space-y-4",children:e.map((l,o)=>{let m=l.callback_name?Object.entries(g.callback_map).find(([e,a])=>a===l.callback_name)?.[0]:void 0,u=m?g.callbackInfo[m]?.logo:null;return(0,a.jsxs)(n.Card,{className:"border border-gray-200 shadow-sm hover:shadow-md transition-shadow duration-200",decoration:"top",decorationColor:"blue",children:[(0,a.jsxs)("div",{className:"flex justify-between items-start mb-4",children:[(0,a.jsxs)("div",{className:"flex items-center space-x-2",children:[u&&(0,a.jsx)("img",{src:u,alt:m,className:"w-5 h-5 object-contain"}),(0,a.jsxs)("span",{className:"text-sm font-medium",children:[m||"New Integration"," Configuration"]})]}),(0,a.jsx)(i.Button,{variant:"light",onClick:()=>{j(e.filter((e,a)=>a!==o))},icon:d.TrashIcon,size:"xs",color:"red",className:"hover:bg-red-50",type:"button",children:"Remove"})]}),(0,a.jsxs)("div",{className:"space-y-4",children:[(0,a.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsx)("label",{className:"text-sm font-medium text-gray-700",children:"Integration Type"}),(0,a.jsx)(s.Select,{value:m,placeholder:"Select integration",onChange:e=>_(o,"callback_name",e),className:"w-full",optionLabelProp:"label",children:v.map(e=>{let s=g.callbackInfo[e]?.logo,l=g.callbackInfo[e]?.description;return(0,a.jsx)(p,{value:e,label:e,children:(0,a.jsx)(t.Tooltip,{title:l,placement:"right",children:(0,a.jsxs)("div",{className:"flex items-center space-x-2",children:[s&&(0,a.jsx)("img",{src:s,alt:e,className:"w-4 h-4 object-contain",onError:a=>{let s=a.target,t=s.parentElement;if(t){let a=document.createElement("div");a.className="w-4 h-4 rounded-full bg-gray-200 flex items-center justify-center text-xs",a.textContent=e.charAt(0),t.replaceChild(a,s)}}}),(0,a.jsx)("span",{children:e})]})})},e)})})]}),(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsx)("label",{className:"text-sm font-medium text-gray-700",children:"Event Type"}),(0,a.jsxs)(s.Select,{value:l.callback_type,onChange:e=>_(o,"callback_type",e),className:"w-full",children:[(0,a.jsx)(p,{value:"success",children:(0,a.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,a.jsx)("div",{className:"w-2 h-2 bg-green-500 rounded-full"}),(0,a.jsx)("span",{children:"Success Only"})]})}),(0,a.jsx)(p,{value:"failure",children:(0,a.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,a.jsx)("div",{className:"w-2 h-2 bg-red-500 rounded-full"}),(0,a.jsx)("span",{children:"Failure Only"})]})}),(0,a.jsx)(p,{value:"success_and_failure",children:(0,a.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,a.jsx)("div",{className:"w-2 h-2 bg-blue-500 rounded-full"}),(0,a.jsx)("span",{children:"Success & Failure"})]})})]})]})]}),((e,s)=>{if(!e.callback_name)return null;let l=Object.entries(g.callback_map).find(([a,s])=>s===e.callback_name)?.[0];if(!l)return null;let i=g.callbackInfo[l]?.dynamic_params||{};return 0===Object.keys(i).length?null:(0,a.jsxs)("div",{className:"mt-6 pt-4 border-t border-gray-100",children:[(0,a.jsxs)("div",{className:"flex items-center space-x-2 mb-4",children:[(0,a.jsx)("div",{className:"w-3 h-3 bg-blue-100 rounded-full flex items-center justify-center",children:(0,a.jsx)("div",{className:"w-1.5 h-1.5 bg-blue-500 rounded-full"})}),(0,a.jsx)("span",{className:"text-sm font-medium text-gray-700",children:"Integration Parameters"})]}),(0,a.jsx)("div",{className:"grid grid-cols-1 gap-4",children:Object.entries(i).map(([l,i])=>(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsxs)("label",{className:"text-sm font-medium text-gray-700 capitalize flex items-center space-x-1",children:[(0,a.jsx)("span",{children:l.replace(/_/g," ")}),(0,a.jsx)(t.Tooltip,{title:`Environment variable reference recommended: os.environ/${l.toUpperCase()}`,children:(0,a.jsx)(r.InfoCircleOutlined,{className:"text-gray-400 cursor-help text-xs"})}),"password"===i&&(0,a.jsx)("span",{className:"inline-flex items-center px-2 py-0.5 rounded text-xs font-medium bg-yellow-100 text-yellow-800",children:"Sensitive"}),"number"===i&&(0,a.jsx)("span",{className:"inline-flex items-center px-2 py-0.5 rounded text-xs font-medium bg-yellow-100 text-yellow-800",children:"Number"})]}),"number"===i&&(0,a.jsx)("span",{className:"text-xs text-gray-500",children:"Value must be between 0 and 1"}),"number"===i?(0,a.jsx)(x.default,{step:.01,width:400,placeholder:`os.environ/${l.toUpperCase()}`,value:e.callback_vars[l]||"",onChange:e=>N(s,l,e.target.value)}):(0,a.jsx)(c.TextInput,{type:"password"===i?"password":"text",placeholder:`os.environ/${l.toUpperCase()}`,value:e.callback_vars[l]||"",onChange:e=>N(s,l,e.target.value)})]},l))})]})})(l,o)]})]},o)})}),0===e.length&&(0,a.jsxs)("div",{className:"text-center py-12 text-gray-500 border-2 border-dashed border-gray-200 rounded-lg bg-gray-50/50",children:[(0,a.jsx)(m.CogIcon,{className:"w-12 h-12 text-gray-300 mb-3 mx-auto"}),(0,a.jsx)("div",{className:"text-base font-medium mb-1",children:"No logging integrations configured"}),(0,a.jsx)("div",{className:"text-sm text-gray-400",children:'Click "Add Integration" to configure logging for this team'})]})]})}])},75921,e=>{"use strict";var a=e.i(843476),s=e.i(266027),t=e.i(243652),l=e.i(764205),r=e.i(135214);let i=(0,t.createQueryKeys)("mcpAccessGroups");var n=e.i(500727),c=e.i(199133);e.s(["default",0,({onChange:e,value:t,className:o,accessToken:d,placeholder:m="Select MCP servers",disabled:u=!1})=>{let{data:g=[],isLoading:x}=(0,n.useMCPServers)(),{data:p=[],isLoading:h}=(()=>{let{accessToken:e}=(0,r.default)();return(0,s.useQuery)({queryKey:i.list({}),queryFn:async()=>await (0,l.fetchMCPAccessGroups)(e),enabled:!!e})})(),b=[...p.map(e=>({label:e,value:e,isAccessGroup:!0,searchText:`${e} Access Group`})),...g.map(e=>({label:`${e.server_name||e.server_id} (${e.server_id})`,value:e.server_id,isAccessGroup:!1,searchText:`${e.server_name||e.server_id} ${e.server_id} MCP Server`}))],f=[...t?.servers||[],...t?.accessGroups||[]];return(0,a.jsx)("div",{children:(0,a.jsx)(c.Select,{mode:"multiple",placeholder:m,onChange:a=>{e({servers:a.filter(e=>!p.includes(e)),accessGroups:a.filter(e=>p.includes(e))})},value:f,loading:x||h,className:o,allowClear:!0,showSearch:!0,style:{width:"100%"},disabled:u,filterOption:(e,a)=>(b.find(e=>e.value===a?.value)?.searchText||"").toLowerCase().includes(e.toLowerCase()),children:b.map(e=>(0,a.jsx)(c.Select.Option,{value:e.value,label:e.label,children:(0,a.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[(0,a.jsx)("span",{style:{display:"inline-block",width:8,height:8,borderRadius:"50%",background:e.isAccessGroup?"#52c41a":"#1890ff",flexShrink:0}}),(0,a.jsx)("span",{style:{flex:1},children:e.label}),(0,a.jsx)("span",{style:{color:e.isAccessGroup?"#52c41a":"#1890ff",fontSize:"12px",fontWeight:500,opacity:.8},children:e.isAccessGroup?"Access Group":"MCP Server"})]})},e.value))})})}],75921)},390605,995926,e=>{"use strict";var a=e.i(843476),s=e.i(271645),t=e.i(764205),l=e.i(599724),r=e.i(482725),i=e.i(536916),n=e.i(841947);e.s(["XIcon",()=>n.default],995926);var n=n,c=e.i(500727);e.s(["default",0,({accessToken:e,selectedServers:o,toolPermissions:d,onChange:m,disabled:u=!1})=>{let{data:g=[]}=(0,c.useMCPServers)(),[x,p]=(0,s.useState)({}),[h,b]=(0,s.useState)({}),[f,v]=(0,s.useState)({}),y=(0,s.useMemo)(()=>0===o.length?[]:g.filter(e=>o.includes(e.server_id)),[g,o]),j=async a=>{b(e=>({...e,[a]:!0})),v(e=>({...e,[a]:""}));try{let s=await (0,t.listMCPTools)(e,a);s.error?(v(e=>({...e,[a]:s.message||"Failed to fetch tools"})),p(e=>({...e,[a]:[]}))):p(e=>({...e,[a]:s.tools||[]}))}catch(e){console.error(`Error fetching tools for server ${a}:`,e),v(e=>({...e,[a]:"Failed to fetch tools"})),p(e=>({...e,[a]:[]}))}finally{b(e=>({...e,[a]:!1}))}};return((0,s.useEffect)(()=>{y.forEach(e=>{x[e.server_id]||h[e.server_id]||j(e.server_id)})},[y]),0===o.length)?null:(0,a.jsx)("div",{className:"space-y-4",children:y.map(e=>{let s=e.server_name||e.alias||e.server_id,t=x[e.server_id]||[],c=d[e.server_id]||[],o=h[e.server_id],g=f[e.server_id];return(0,a.jsxs)("div",{className:"border rounded-lg bg-gray-50",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between p-4 border-b bg-white rounded-t-lg",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)(l.Text,{className:"font-semibold text-gray-900",children:s}),e.description&&(0,a.jsx)(l.Text,{className:"text-sm text-gray-500",children:e.description})]}),(0,a.jsxs)("div",{className:"flex items-center gap-3",children:[(0,a.jsx)("button",{type:"button",className:"text-sm text-blue-600 hover:text-blue-700 font-medium",onClick:()=>{var a;let s;return s=x[a=e.server_id]||[],void m({...d,[a]:s.map(e=>e.name)})},disabled:u||o,children:"Select All"}),(0,a.jsx)("button",{type:"button",className:"text-sm text-blue-600 hover:text-blue-700 font-medium",onClick:()=>{var a;return a=e.server_id,void m({...d,[a]:[]})},disabled:u||o,children:"Deselect All"}),(0,a.jsx)("button",{type:"button",className:"text-gray-400 hover:text-gray-600",onClick:()=>{},children:(0,a.jsx)(n.default,{className:"w-4 h-4"})})]})]}),(0,a.jsxs)("div",{className:"p-4",children:[(0,a.jsx)(l.Text,{className:"text-sm font-medium text-gray-700 mb-3",children:"Available Tools"}),o&&(0,a.jsxs)("div",{className:"flex items-center justify-center py-8",children:[(0,a.jsx)(r.Spin,{size:"large"}),(0,a.jsx)(l.Text,{className:"ml-3 text-gray-500",children:"Loading tools..."})]}),g&&!o&&(0,a.jsxs)("div",{className:"p-4 bg-red-50 border border-red-200 rounded-lg text-center",children:[(0,a.jsx)(l.Text,{className:"text-red-600 font-medium",children:"Unable to load tools"}),(0,a.jsx)(l.Text,{className:"text-sm text-red-500 mt-1",children:g})]}),!o&&!g&&t.length>0&&(0,a.jsx)("div",{className:"space-y-2",children:t.map(s=>{let t=c.includes(s.name);return(0,a.jsxs)("div",{className:"flex items-start gap-2",children:[(0,a.jsx)(i.Checkbox,{checked:t,onChange:()=>{var a,t;let l,r;return a=e.server_id,t=s.name,r=(l=d[a]||[]).includes(t)?l.filter(e=>e!==t):[...l,t],void m({...d,[a]:r})},disabled:u}),(0,a.jsx)("div",{className:"flex-1 min-w-0",children:(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)(l.Text,{className:"font-medium text-gray-900",children:s.name}),(0,a.jsxs)(l.Text,{className:"text-sm text-gray-500",children:["- ",s.description||"No description"]})]})})]},s.name)})}),!o&&!g&&0===t.length&&(0,a.jsx)("div",{className:"text-center py-6",children:(0,a.jsx)(l.Text,{className:"text-gray-500",children:"No tools available"})})]})]},e.server_id)})})}],390605)}]); \ No newline at end of file diff --git a/litellm/proxy/_experimental/out/_next/static/chunks/1658-c301cddaf7772753.js b/litellm/proxy/_experimental/out/_next/static/chunks/1658-c301cddaf7772753.js deleted file mode 100644 index 730804d53de..00000000000 --- a/litellm/proxy/_experimental/out/_next/static/chunks/1658-c301cddaf7772753.js +++ /dev/null @@ -1 +0,0 @@ -"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[1658],{71658:function(e,l,t){t.d(l,{Z:function(){return l1}});var s=t(57437),a=t(19250),r=t(11713),i=t(90246),n=t(39760);let o=(0,i.n)("credentials"),d=()=>{let{accessToken:e}=(0,n.Z)();return(0,r.a)({queryKey:o.list({}),queryFn:async()=>await (0,a.credentialListCall)(e),enabled:!!e})},c=(0,i.n)("modelCostMap"),m=()=>(0,r.a)({queryKey:c.list({}),queryFn:async()=>await (0,a.modelCostMap)(),staleTime:6e4,gcTime:6e4});var u=t(52178),h=t(55584),x=t(47359),p=t(71594),g=t(24525),f=t(2265),j=t(19130),v=t(73705),_=t(5545),b=t(44633),y=t(86462),N=t(3837),w=t(49084);let Z=e=>{let{sortState:l,onSortChange:t}=e,a=[{key:"asc",label:"Ascending",icon:(0,s.jsx)(b.Z,{className:"h-4 w-4"})},{key:"desc",label:"Descending",icon:(0,s.jsx)(y.Z,{className:"h-4 w-4"})},{key:"reset",label:"Reset",icon:(0,s.jsx)(N.Z,{className:"h-4 w-4"})}];return(0,s.jsx)(v.Z,{menu:{items:a,onClick:e=>{let{key:l}=e;"asc"===l?t("asc"):"desc"===l?t("desc"):"reset"===l&&t(!1)},selectable:!0,selectedKeys:l?[l]:[]},trigger:["click"],autoAdjustOverflow:!0,children:(0,s.jsx)(_.ZP,{type:"text",onClick:e=>e.stopPropagation(),icon:"asc"===l?(0,s.jsx)(b.Z,{className:"h-4 w-4"}):"desc"===l?(0,s.jsx)(y.Z,{className:"h-4 w-4"}):(0,s.jsx)(w.Z,{className:"h-4 w-4"}),className:l?"text-blue-500 hover:text-blue-600":"text-gray-400 hover:text-blue-500"})})};function C(e){let{data:l=[],columns:t,isLoading:a=!1,sorting:r=[],onSortingChange:i,pagination:n,onPaginationChange:o,enablePagination:d=!1}=e,[c]=f.useState("onChange"),[m,u]=f.useState({}),[h,x]=f.useState({}),v=(0,p.b7)({data:l,columns:t,state:{sorting:r,columnSizing:m,columnVisibility:h,...d&&n?{pagination:n}:{}},columnResizeMode:c,onSortingChange:i,onColumnSizingChange:u,onColumnVisibilityChange:x,...d&&o?{onPaginationChange:o}:{},getCoreRowModel:(0,g.sC)(),...d?{getPaginationRowModel:(0,g.G_)()}:{},enableSorting:!0,enableColumnResizing:!0,manualSorting:!0,defaultColumn:{minSize:40,maxSize:500}});return(0,s.jsx)("div",{className:"rounded-lg custom-border relative",children:(0,s.jsx)("div",{className:"overflow-x-auto",children:(0,s.jsx)("div",{className:"relative min-w-full",children:(0,s.jsxs)(j.iA,{className:"[&_td]:py-2 [&_th]:py-2 w-full",children:[(0,s.jsx)(j.ss,{children:v.getHeaderGroups().map(e=>(0,s.jsx)(j.SC,{children:e.headers.map(e=>{var l;return(0,s.jsxs)(j.xs,{className:"py-1 h-8 relative ".concat("actions"===e.id?"sticky right-0 bg-white shadow-[-4px_0_8px_-6px_rgba(0,0,0,0.1)] w-[120px] ml-8":""," ").concat((null===(l=e.column.columnDef.meta)||void 0===l?void 0:l.className)||""),style:{width:"actions"===e.id?120:e.getSize(),position:"actions"===e.id?"sticky":"relative",right:"actions"===e.id?0:"auto"},children:[(0,s.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,s.jsx)("div",{className:"flex items-center",children:e.isPlaceholder?null:(0,p.ie)(e.column.columnDef.header,e.getContext())}),"actions"!==e.id&&e.column.getCanSort()&&i&&(0,s.jsx)(Z,{sortState:!1!==e.column.getIsSorted()&&e.column.getIsSorted(),onSortChange:l=>{!1===l?i([]):i([{id:e.column.id,desc:"desc"===l}])},columnId:e.column.id})]}),e.column.getCanResize()&&(0,s.jsx)("div",{onMouseDown:e.getResizeHandler(),onTouchStart:e.getResizeHandler(),className:"absolute right-0 top-0 h-full w-2 cursor-col-resize select-none touch-none ".concat(e.column.getIsResizing()?"bg-blue-500":"hover:bg-blue-200")})]},e.id)})},e.id))}),(0,s.jsx)(j.RM,{children:a?(0,s.jsx)(j.SC,{children:(0,s.jsx)(j.pj,{colSpan:t.length,className:"h-8 text-center",children:(0,s.jsx)("div",{className:"text-center text-gray-500",children:(0,s.jsx)("p",{children:"\uD83D\uDE85 Loading models..."})})})}):v.getRowModel().rows.length>0?v.getRowModel().rows.map(e=>(0,s.jsx)(j.SC,{children:e.getVisibleCells().map(e=>{var l;return(0,s.jsx)(j.pj,{className:"py-0.5 ".concat("actions"===e.column.id?"sticky right-0 bg-white shadow-[-4px_0_8px_-6px_rgba(0,0,0,0.1)] w-[120px] ml-8":""," ").concat((null===(l=e.column.columnDef.meta)||void 0===l?void 0:l.className)||""),style:{width:"actions"===e.column.id?120:e.column.getSize(),position:"actions"===e.column.id?"sticky":"relative",right:"actions"===e.column.id?0:"auto"},children:(0,p.ie)(e.column.columnDef.cell,e.getContext())},e.id)})},e.id)):(0,s.jsx)(j.SC,{children:(0,s.jsx)(j.pj,{colSpan:t.length,className:"h-8 text-center",children:(0,s.jsx)("div",{className:"text-center text-gray-500",children:(0,s.jsx)("p",{children:"No models found"})})})})})]})})})})}var k=t(45589),S=t(74998),A=t(41649),E=t(78489),P=t(47323),M=t(99981),L=t(42673);let F=e=>{let{provider:l,className:t="w-4 h-4"}=e,[a,r]=(0,f.useState)(!1),{logo:i}=(0,L.dr)(l);return a||!i?(0,s.jsx)("div",{className:"".concat(t," rounded-full bg-gray-200 flex items-center justify-center text-xs"),children:(null==l?void 0:l.charAt(0))||"-"}):(0,s.jsx)("img",{src:i,alt:"".concat(l," logo"),className:t,onError:()=>r(!0)})},I=(e,l,t,a,r,i,n,o,d,c)=>[{header:()=>(0,s.jsx)("span",{className:"text-sm font-semibold",children:"Model ID"}),accessorKey:"model_info.id",enableSorting:!1,cell:e=>{let{row:l}=e,t=l.original;return(0,s.jsx)(M.Z,{title:t.model_info.id,children:(0,s.jsx)("div",{className:"font-mono text-blue-500 bg-blue-50 hover:bg-blue-100 text-xs font-normal px-2 py-0.5 text-left w-full truncate whitespace-nowrap cursor-pointer max-w-[15ch]",onClick:()=>a(t.model_info.id),children:t.model_info.id})})}},{header:()=>(0,s.jsx)("span",{className:"text-sm font-semibold",children:"Model Information"}),accessorKey:"model_name",size:250,cell:e=>{let{row:l}=e,t=l.original,a=i(l.original)||"-",r=(0,s.jsxs)("div",{children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("strong",{children:"Provider:"})," ",t.provider||"-"]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("strong",{children:"Public Model Name:"})," ",a]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("strong",{children:"LiteLLM Model Name:"})," ",t.litellm_model_name||"-"]})]});return(0,s.jsx)(M.Z,{title:r,children:(0,s.jsxs)("div",{className:"flex items-start space-x-2 min-w-0 w-full max-w-[250px]",children:[(0,s.jsx)("div",{className:"flex-shrink-0 mt-0.5",children:t.provider?(0,s.jsx)(F,{provider:t.provider}):(0,s.jsx)("div",{className:"w-4 h-4 rounded-full bg-gray-200 flex items-center justify-center text-xs",children:"-"})}),(0,s.jsxs)("div",{className:"flex flex-col min-w-0 flex-1",children:[(0,s.jsx)("div",{className:"text-xs font-medium text-gray-900 truncate max-w-[210px]",children:a}),(0,s.jsx)("div",{className:"text-xs text-gray-500 truncate mt-0.5 max-w-[210px]",children:t.litellm_model_name||"-"})]})]})})}},{header:()=>(0,s.jsx)("span",{className:"text-sm font-semibold",children:"Credentials"}),accessorKey:"litellm_credential_name",enableSorting:!1,size:180,cell:e=>{var l;let{row:t}=e,a=null===(l=t.original.litellm_params)||void 0===l?void 0:l.litellm_credential_name;return a?(0,s.jsx)(M.Z,{title:"Credential: ".concat(a),children:(0,s.jsxs)("div",{className:"flex items-center space-x-2 max-w-[180px]",children:[(0,s.jsx)(k.Z,{className:"w-4 h-4 text-blue-500 flex-shrink-0"}),(0,s.jsx)("span",{className:"text-xs truncate",title:a,children:a})]})}):(0,s.jsxs)("div",{className:"flex items-center space-x-2 max-w-[180px]",children:[(0,s.jsx)(k.Z,{className:"w-4 h-4 text-gray-300 flex-shrink-0"}),(0,s.jsx)("span",{className:"text-xs text-gray-400",children:"No credentials"})]})}},{header:()=>(0,s.jsx)("span",{className:"text-sm font-semibold",children:"Created By"}),accessorKey:"model_info.created_by",sortingFn:"datetime",size:160,cell:e=>{var l;let{row:t}=e,a=t.original,r=!(null===(l=a.model_info)||void 0===l?void 0:l.db_model),i=a.model_info.created_by,n=a.model_info.created_at?new Date(a.model_info.created_at).toLocaleDateString():null;return(0,s.jsxs)("div",{className:"flex flex-col min-w-0 max-w-[160px]",children:[(0,s.jsx)("div",{className:"text-xs font-medium text-gray-900 truncate",title:r?"Defined in config":i||"Unknown",children:r?"Defined in config":i||"Unknown"}),(0,s.jsx)("div",{className:"text-xs text-gray-500 truncate mt-0.5",title:r?"Config file":n||"Unknown date",children:r?"-":n||"Unknown date"})]})}},{header:()=>(0,s.jsx)("span",{className:"text-sm font-semibold",children:"Updated At"}),accessorKey:"model_info.updated_at",sortingFn:"datetime",cell:e=>{let{row:l}=e,t=l.original;return(0,s.jsx)("span",{className:"text-xs",children:t.model_info.updated_at?new Date(t.model_info.updated_at).toLocaleDateString():"-"})}},{header:()=>(0,s.jsx)("span",{className:"text-sm font-semibold",children:"Costs"}),accessorKey:"input_cost",size:120,cell:e=>{let{row:l}=e,t=l.original,a=t.input_cost,r=t.output_cost;return a||r?(0,s.jsx)(M.Z,{title:"Cost per 1M tokens",children:(0,s.jsxs)("div",{className:"flex flex-col min-w-0 max-w-[120px]",children:[a&&(0,s.jsxs)("div",{className:"text-xs font-medium text-gray-900 truncate",children:["In: $",a]}),r&&(0,s.jsxs)("div",{className:"text-xs text-gray-500 truncate mt-0.5",children:["Out: $",r]})]})}):(0,s.jsx)("div",{className:"max-w-[120px]",children:(0,s.jsx)("span",{className:"text-xs text-gray-400",children:"-"})})}},{header:()=>(0,s.jsx)("span",{className:"text-sm font-semibold",children:"Team ID"}),accessorKey:"model_info.team_id",enableSorting:!1,cell:e=>{let{row:l}=e,t=l.original;return t.model_info.team_id?(0,s.jsx)("div",{className:"overflow-hidden",children:(0,s.jsx)(M.Z,{title:t.model_info.team_id,children:(0,s.jsxs)(E.Z,{size:"xs",variant:"light",className:"font-mono text-blue-500 bg-blue-50 hover:bg-blue-100 text-xs font-normal px-2 py-0.5 text-left overflow-hidden truncate max-w-[200px]",onClick:()=>r(t.model_info.team_id),children:[t.model_info.team_id.slice(0,7),"..."]})})}):"-"}},{header:()=>(0,s.jsx)("span",{className:"text-sm font-semibold",children:"Model Access Group"}),accessorKey:"model_info.model_access_group",enableSorting:!1,cell:e=>{let{row:l}=e,t=l.original,a=t.model_info.access_groups;if(!a||0===a.length)return"-";let r=t.model_info.id,i=d.has(r),n=a.length>1,o=()=>{let e=new Set(d);i?e.delete(r):e.add(r),c(e)};return(0,s.jsxs)("div",{className:"flex items-center gap-1 overflow-hidden",children:[(0,s.jsx)(A.Z,{size:"xs",color:"blue",className:"text-xs px-1.5 py-0.5 h-5 leading-tight flex-shrink-0",children:a[0]}),(i||!n&&2===a.length)&&a.slice(1).map((e,l)=>(0,s.jsx)(A.Z,{size:"xs",color:"blue",className:"text-xs px-1.5 py-0.5 h-5 leading-tight flex-shrink-0",children:e},l+1)),n&&(0,s.jsx)("button",{onClick:e=>{e.stopPropagation(),o()},className:"text-xs text-blue-600 hover:text-blue-800 px-1 py-0.5 rounded hover:bg-blue-50 h-5 leading-tight flex-shrink-0 whitespace-nowrap",children:i?"−":"+".concat(a.length-1)})]})}},{header:()=>(0,s.jsx)("span",{className:"text-sm font-semibold",children:"Status"}),accessorKey:"model_info.db_model",cell:e=>{let{row:l}=e,t=l.original;return(0,s.jsx)("div",{className:"\n inline-flex items-center px-2 py-0.5 rounded-full text-xs font-medium\n ".concat(t.model_info.db_model?"bg-blue-50 text-blue-600":"bg-gray-100 text-gray-600","\n "),children:t.model_info.db_model?"DB Model":"Config Model"})}},{id:"actions",header:()=>(0,s.jsx)("span",{className:"text-sm font-semibold",children:"Actions"}),cell:t=>{var r,i;let{row:n}=t,o=n.original,d="Admin"===e||(null===(r=o.model_info)||void 0===r?void 0:r.created_by)===l,c=!(null===(i=o.model_info)||void 0===i?void 0:i.db_model);return(0,s.jsx)("div",{className:"flex items-center justify-end gap-2 pr-4",children:c?(0,s.jsx)(M.Z,{title:"Config model cannot be deleted on the dashboard. Please delete it from the config file.",children:(0,s.jsx)(P.Z,{icon:S.Z,size:"sm",className:"opacity-50 cursor-not-allowed"})}):(0,s.jsx)(M.Z,{title:"Delete model",children:(0,s.jsx)(P.Z,{icon:S.Z,size:"sm",onClick:()=>{d&&a(o.model_info.id)},className:d?"cursor-pointer hover:text-red-600":"opacity-50 cursor-not-allowed"})})})}}],T=e=>{var l;return(null==e?void 0:null===(l=e.model_info)||void 0===l?void 0:l.team_public_model_name)?e.model_info.team_public_model_name:(null==e?void 0:e.model_name)||"-"};var R=t(15424),O=t(67101),V=t(27281),q=t(57365),z=t(29706),D=t(84264),B=t(50337),G=t(10353),U=t(7310),H=t.n(U);let K=(e,l)=>{if(!(null==e?void 0:e.data))return{data:[]};let t=JSON.parse(JSON.stringify(e.data));for(let e=0;e{let[l]=e;return"model"!==l&&"api_base"!==l}))),t[e].provider=c,t[e].input_cost=m,t[e].output_cost=u,t[e].litellm_model_name=n,t[e].input_cost&&(t[e].input_cost=(1e6*Number(t[e].input_cost)).toFixed(2)),t[e].output_cost&&(t[e].output_cost=(1e6*Number(t[e].output_cost)).toFixed(2)),t[e].max_tokens=h,t[e].max_input_tokens=x,t[e].api_base=null==i?void 0:null===(r=i.litellm_params)||void 0===r?void 0:r.api_base,t[e].cleanedLitellmParams=p}return{data:t}};var J=e=>{let{selectedModelGroup:l,setSelectedModelGroup:t,availableModelGroups:a,availableModelAccessGroups:r,setSelectedModelId:i,setSelectedTeamId:o}=e,{data:d,isLoading:c}=m(),{userId:h,userRole:p,premiumUser:g}=(0,n.Z)(),{data:j,isLoading:v}=(0,x.y2)(),[_,b]=(0,f.useState)(""),[y,N]=(0,f.useState)(""),[w,Z]=(0,f.useState)("current_team"),[k,S]=(0,f.useState)("personal"),[A,E]=(0,f.useState)(!1),[P,M]=(0,f.useState)(null),[L,F]=(0,f.useState)(new Set),[U,J]=(0,f.useState)(1),[W]=(0,f.useState)(50),[Y,$]=(0,f.useState)({pageIndex:0,pageSize:50}),[X,Q]=(0,f.useState)([]),ee=(0,f.useMemo)(()=>H()(e=>{N(e),J(1),$(e=>({...e,pageIndex:0}))},200),[]);(0,f.useEffect)(()=>(ee(_),()=>{ee.cancel()}),[_,ee]);let el="personal"===k?void 0:k.team_id,et=(0,f.useMemo)(()=>{if(0===X.length)return;let e=X[0];return({input_cost:"costs",model_info_db_model:"status",model_info_created_by:"created_at",model_info_updated_at:"updated_at"})[e.id]||e.id},[X]),es=(0,f.useMemo)(()=>{if(0!==X.length)return X[0].desc?"desc":"asc"},[X]),{data:ea,isLoading:er}=(0,u.XP)(U,W,y||void 0,void 0,el,et,es),ei=er||c,en=e=>null!=d&&"object"==typeof d&&e in d?d[e].litellm_provider:"openai",eo=(0,f.useMemo)(()=>ea?K(ea,en):{data:[]},[ea,d]),ed=(0,f.useMemo)(()=>{var e,l,t,s;return ea?{total_count:null!==(e=ea.total_count)&&void 0!==e?e:0,current_page:null!==(l=ea.current_page)&&void 0!==l?l:1,total_pages:null!==(t=ea.total_pages)&&void 0!==t?t:1,size:null!==(s=ea.size)&&void 0!==s?s:W}:{total_count:0,current_page:1,total_pages:1,size:W}},[ea,W]),ec=(0,f.useMemo)(()=>eo&&eo.data&&0!==eo.data.length?eo.data.filter(e=>{var t,s;let a="all"===l||e.model_name===l||!l||"wildcard"===l&&(null===(t=e.model_name)||void 0===t?void 0:t.includes("*")),r="all"===P||(null===(s=e.model_info.access_groups)||void 0===s?void 0:s.includes(P))||!P;return a&&r}):[],[eo,l,P]);return(0,f.useEffect)(()=>{$(e=>({...e,pageIndex:0})),J(1)},[l,P]),(0,f.useEffect)(()=>{J(1),$(e=>({...e,pageIndex:0}))},[el]),(0,f.useEffect)(()=>{J(1),$(e=>({...e,pageIndex:0}))},[X]),(0,s.jsx)(z.Z,{children:(0,s.jsx)(O.Z,{children:(0,s.jsx)("div",{className:"flex flex-col space-y-4",children:(0,s.jsxs)("div",{className:"bg-white rounded-lg shadow",children:[(0,s.jsxs)("div",{className:"border-b px-6 py-4 bg-gray-50",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between",children:[(0,s.jsxs)("div",{className:"flex items-center gap-4",children:[(0,s.jsx)(D.Z,{className:"text-lg font-semibold text-gray-900",children:"Current Team:"}),ei?(0,s.jsx)(B.Z.Input,{active:!0,style:{width:320,height:36}}):(0,s.jsxs)(V.Z,{className:"w-80",defaultValue:"personal",value:"personal"===k?"personal":k.team_id,onValueChange:e=>{if("personal"===e)S("personal"),J(1),$(e=>({...e,pageIndex:0}));else{let l=null==j?void 0:j.find(l=>l.team_id===e);l&&(S(l),J(1),$(e=>({...e,pageIndex:0})))}},children:[(0,s.jsx)(q.Z,{value:"personal",children:(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)("div",{className:"w-2 h-2 bg-blue-500 rounded-full"}),(0,s.jsx)("span",{className:"font-medium",children:"Personal"})]})}),v?(0,s.jsx)(q.Z,{value:"loading",children:(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)(G.Z,{size:"small"}),(0,s.jsx)("span",{className:"font-medium text-gray-500",children:"Loading teams..."})]})}):null==j?void 0:j.filter(e=>e.team_id).map(e=>(0,s.jsx)(q.Z,{value:e.team_id,children:(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)("div",{className:"w-2 h-2 bg-green-500 rounded-full"}),(0,s.jsx)("span",{className:"font-medium",children:e.team_alias?"".concat(e.team_alias.slice(0,30),"..."):"Team ".concat(e.team_id.slice(0,30),"...")})]})},e.team_id))]})]}),(0,s.jsxs)("div",{className:"flex items-center gap-4",children:[(0,s.jsx)(D.Z,{className:"text-lg font-semibold text-gray-900",children:"View:"}),ei?(0,s.jsx)(B.Z.Input,{active:!0,style:{width:256,height:36}}):(0,s.jsxs)(V.Z,{className:"w-64",defaultValue:"current_team",value:w,onValueChange:e=>Z(e),children:[(0,s.jsx)(q.Z,{value:"current_team",children:(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)("div",{className:"w-2 h-2 bg-purple-500 rounded-full"}),(0,s.jsx)("span",{className:"font-medium",children:"Current Team Models"})]})}),(0,s.jsx)(q.Z,{value:"all",children:(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)("div",{className:"w-2 h-2 bg-gray-500 rounded-full"}),(0,s.jsx)("span",{className:"font-medium",children:"All Available Models"})]})})]})]})]}),"current_team"===w&&(0,s.jsxs)("div",{className:"flex items-start gap-2 mt-3",children:[(0,s.jsx)(R.Z,{className:"text-gray-400 mt-0.5 flex-shrink-0 text-xs"}),(0,s.jsx)("div",{className:"text-xs text-gray-500",children:"personal"===k?(0,s.jsxs)("span",{children:["To access these models: Create a Virtual Key without selecting a team on the"," ",(0,s.jsx)("a",{href:"/public?login=success&page=api-keys",className:"text-gray-600 hover:text-gray-800 underline",children:"Virtual Keys page"})]}):(0,s.jsxs)("span",{children:['To access these models: Create a Virtual Key and select Team as "',"string"!=typeof k?k.team_alias||k.team_id:"",'" on the'," ",(0,s.jsx)("a",{href:"/public?login=success&page=api-keys",className:"text-gray-600 hover:text-gray-800 underline",children:"Virtual Keys page"})]})})]})]}),(0,s.jsx)("div",{className:"border-b px-6 py-4",children:(0,s.jsxs)("div",{className:"flex flex-col space-y-4",children:[(0,s.jsxs)("div",{className:"flex flex-wrap items-center gap-3",children:[(0,s.jsxs)("div",{className:"relative w-64",children:[(0,s.jsx)("input",{type:"text",placeholder:"Search model names...",className:"w-full px-3 py-2 pl-8 border rounded-md text-sm focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500",value:_,onChange:e=>b(e.target.value)}),(0,s.jsx)("svg",{className:"absolute left-2.5 top-2.5 h-4 w-4 text-gray-500",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,s.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"})})]}),(0,s.jsxs)("button",{className:"px-3 py-2 text-sm border rounded-md hover:bg-gray-50 flex items-center gap-2 ".concat(A?"bg-gray-100":""),onClick:()=>E(!A),children:[(0,s.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,s.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M3 4a1 1 0 011-1h16a1 1 0 011 1v2.586a1 1 0 01-.293.707l-6.414 6.414a1 1 0 00-.293.707V17l-4 4v-6.586a1 1 0 00-.293-.707L3.293 7.293A1 1 0 013 6.586V4z"})}),"Filters"]}),(0,s.jsxs)("button",{className:"px-3 py-2 text-sm border rounded-md hover:bg-gray-50 flex items-center gap-2",onClick:()=>{b(""),t("all"),M(null),S("personal"),Z("current_team"),J(1),$({pageIndex:0,pageSize:50}),Q([])},children:[(0,s.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,s.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"})}),"Reset Filters"]})]}),A&&(0,s.jsxs)("div",{className:"flex flex-wrap items-center gap-3 mt-3",children:[(0,s.jsx)("div",{className:"w-64",children:(0,s.jsxs)(V.Z,{value:null!=l?l:"all",onValueChange:e=>t("all"===e?"all":e),placeholder:"Filter by Public Model Name",children:[(0,s.jsx)(q.Z,{value:"all",children:"All Models"}),(0,s.jsx)(q.Z,{value:"wildcard",children:"Wildcard Models (*)"}),a.map((e,l)=>(0,s.jsx)(q.Z,{value:e,children:e},l))]})}),(0,s.jsx)("div",{className:"w-64",children:(0,s.jsxs)(V.Z,{value:null!=P?P:"all",onValueChange:e=>M("all"===e?null:e),placeholder:"Filter by Model Access Group",children:[(0,s.jsx)(q.Z,{value:"all",children:"All Model Access Groups"}),r.map((e,l)=>(0,s.jsx)(q.Z,{value:e,children:e},l))]})})]}),(0,s.jsxs)("div",{className:"flex justify-between items-center",children:[ei?(0,s.jsx)(B.Z.Input,{active:!0,style:{width:184,height:20}}):(0,s.jsx)("span",{className:"text-sm text-gray-700",children:ed.total_count>0?"Showing ".concat((U-1)*W+1," - ").concat(Math.min(U*W,ed.total_count)," of ").concat(ed.total_count," results"):"Showing 0 results"}),(0,s.jsxs)("div",{className:"flex items-center space-x-2",children:[ei?(0,s.jsx)(B.Z.Button,{active:!0,style:{width:84,height:30}}):(0,s.jsx)("button",{onClick:()=>{J(U-1),$(e=>({...e,pageIndex:0}))},disabled:1===U,className:"px-3 py-1 text-sm border rounded-md ".concat(1===U?"bg-gray-100 text-gray-400 cursor-not-allowed":"hover:bg-gray-50"),children:"Previous"}),ei?(0,s.jsx)(B.Z.Button,{active:!0,style:{width:56,height:30}}):(0,s.jsx)("button",{onClick:()=>{J(U+1),$(e=>({...e,pageIndex:0}))},disabled:U>=ed.total_pages,className:"px-3 py-1 text-sm border rounded-md ".concat(U>=ed.total_pages?"bg-gray-100 text-gray-400 cursor-not-allowed":"hover:bg-gray-50"),children:"Next"})]})]})]})}),(0,s.jsx)(C,{columns:I(p,h,g,i,o,T,()=>{},()=>{},L,F),data:ec,isLoading:er,sorting:X,onSortingChange:Q,pagination:Y,onPaginationChange:$,enablePagination:!0})]})})})})},W=t(96761),Y=t(12221);let $={"BadRequestError (400)":"BadRequestErrorRetries","AuthenticationError (401)":"AuthenticationErrorRetries","TimeoutError (408)":"TimeoutErrorRetries","RateLimitError (429)":"RateLimitErrorRetries","ContentPolicyViolationError (400)":"ContentPolicyViolationErrorRetries","InternalServerError (500)":"InternalServerErrorRetries"};var X=e=>{let{selectedModelGroup:l,setSelectedModelGroup:t,availableModelGroups:a,globalRetryPolicy:r,setGlobalRetryPolicy:i,defaultRetry:n,modelGroupRetryPolicy:o,setModelGroupRetryPolicy:d,handleSaveRetrySettings:c}=e;return(0,s.jsxs)(z.Z,{children:[(0,s.jsx)("div",{className:"flex items-center gap-4 mb-6",children:(0,s.jsxs)("div",{className:"flex items-center",children:[(0,s.jsx)(D.Z,{children:"Retry Policy Scope:"}),(0,s.jsxs)(V.Z,{className:"ml-2 w-48",defaultValue:"global",value:"global"===l?"global":l||a[0],onValueChange:e=>t(e),children:[(0,s.jsx)(q.Z,{value:"global",children:"Global Default"}),a.map((e,l)=>(0,s.jsx)(q.Z,{value:e,onClick:()=>t(e),children:e},l))]})]})}),"global"===l?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(W.Z,{children:"Global Retry Policy"}),(0,s.jsx)(D.Z,{className:"mb-6",children:"Default retry settings applied to all model groups unless overridden"})]}):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)(W.Z,{children:["Retry Policy for ",l]}),(0,s.jsx)(D.Z,{className:"mb-6",children:"Model-specific retry settings. Falls back to global defaults if not set."})]}),$&&(0,s.jsx)("table",{children:(0,s.jsx)("tbody",{children:Object.entries($).map((e,t)=>{var a,c,m,u;let h,[x,p]=e;if("global"===l)h=null!==(a=null==r?void 0:r[p])&&void 0!==a?a:n;else{let e=null==o?void 0:null===(c=o[l])||void 0===c?void 0:c[p];h=null!=e?e:null!==(m=null==r?void 0:r[p])&&void 0!==m?m:n}return(0,s.jsxs)("tr",{className:"flex justify-between items-center mt-2",children:[(0,s.jsxs)("td",{children:[(0,s.jsx)(D.Z,{children:x}),"global"!==l&&(0,s.jsxs)(D.Z,{className:"text-xs text-gray-500 ml-2",children:["(Global: ",null!==(u=null==r?void 0:r[p])&&void 0!==u?u:n,")"]})]}),(0,s.jsx)("td",{children:(0,s.jsx)(Y.Z,{className:"ml-5",value:h,min:0,step:1,onChange:e=>{"global"===l?i(l=>null==e?l:{...null!=l?l:{},[p]:e}):d(t=>{var s;let a=null!==(s=null==t?void 0:t[l])&&void 0!==s?s:{};return{...null!=t?t:{},[l]:{...a,[p]:e}}})}})})]},t)})})}),(0,s.jsx)(E.Z,{className:"mt-6 mr-8",onClick:c,children:"Save"})]})},Q=t(57840),ee=t(58760),el=t(867),et=t(5945),es=t(3810),ea=t(22116),er=t(89245),ei=t(5540),en=t(8881),eo=t(9114);let{Text:ed}=Q.default;var ec=e=>{let{accessToken:l,onReloadSuccess:t,buttonText:r="Reload Price Data",showIcon:i=!0,size:n="middle",type:o="primary",className:d=""}=e,[c,m]=(0,f.useState)(!1),[u,h]=(0,f.useState)(!1),[x,p]=(0,f.useState)(!1),[g,j]=(0,f.useState)(!1),[v,b]=(0,f.useState)(6),[y,N]=(0,f.useState)(null),[w,Z]=(0,f.useState)(!1);(0,f.useEffect)(()=>{C();let e=setInterval(()=>{C()},3e4);return()=>clearInterval(e)},[l]);let C=async()=>{if(l){Z(!0);try{console.log("Fetching reload status...");let e=await (0,a.getModelCostMapReloadStatus)(l);console.log("Received status:",e),N(e)}catch(e){console.error("Failed to fetch reload status:",e),N({scheduled:!1,interval_hours:null,last_run:null,next_run:null})}finally{Z(!1)}}},k=async()=>{if(!l){eo.Z.fromBackend("No access token available");return}m(!0);try{let e=await (0,a.reloadModelCostMap)(l);"success"===e.status?(eo.Z.success("Price data reloaded successfully! ".concat(e.models_count||0," models updated.")),null==t||t(),await C()):eo.Z.fromBackend("Failed to reload price data")}catch(e){console.error("Error reloading price data:",e),eo.Z.fromBackend("Failed to reload price data. Please try again.")}finally{m(!1)}},S=async()=>{if(!l){eo.Z.fromBackend("No access token available");return}if(v<=0){eo.Z.fromBackend("Hours must be greater than 0");return}h(!0);try{let e=await (0,a.scheduleModelCostMapReload)(l,v);"success"===e.status?(eo.Z.success("Periodic reload scheduled for every ".concat(v," hours")),j(!1),await C()):eo.Z.fromBackend("Failed to schedule periodic reload")}catch(e){console.error("Error scheduling reload:",e),eo.Z.fromBackend("Failed to schedule periodic reload. Please try again.")}finally{h(!1)}},A=async()=>{if(!l){eo.Z.fromBackend("No access token available");return}p(!0);try{let e=await (0,a.cancelModelCostMapReload)(l);"success"===e.status?(eo.Z.success("Periodic reload cancelled successfully"),await C()):eo.Z.fromBackend("Failed to cancel periodic reload")}catch(e){console.error("Error cancelling reload:",e),eo.Z.fromBackend("Failed to cancel periodic reload. Please try again.")}finally{p(!1)}},E=e=>{if(!e)return"Never";try{return new Date(e).toLocaleString()}catch(l){return e}};return(0,s.jsxs)("div",{className:d,children:[(0,s.jsxs)(ee.Z,{direction:"horizontal",size:"middle",style:{marginBottom:16},children:[(0,s.jsx)(el.Z,{title:"Hard Refresh Price Data",description:"This will immediately fetch the latest pricing information from the remote source. Continue?",onConfirm:k,okText:"Yes",cancelText:"No",okButtonProps:{style:{backgroundColor:"#6366f1",borderColor:"#6366f1",color:"white",fontWeight:"500",borderRadius:"0.375rem",padding:"0.375rem 0.75rem",height:"auto",fontSize:"0.875rem",lineHeight:"1.25rem",transition:"all 0.2s ease-in-out"},onMouseEnter:e=>{e.currentTarget.style.backgroundColor="#4f46e5"},onMouseLeave:e=>{e.currentTarget.style.backgroundColor="#6366f1"}},children:(0,s.jsx)(_.ZP,{type:o,size:n,loading:c,icon:i?(0,s.jsx)(er.Z,{}):void 0,style:{backgroundColor:"#6366f1",borderColor:"#6366f1",color:"white",fontWeight:"500",borderRadius:"0.375rem",padding:"0.375rem 0.75rem",height:"auto",fontSize:"0.875rem",lineHeight:"1.25rem",transition:"all 0.2s ease-in-out"},onMouseEnter:e=>{e.currentTarget.style.backgroundColor="#4f46e5"},onMouseLeave:e=>{e.currentTarget.style.backgroundColor="#6366f1"},children:r})}),(null==y?void 0:y.scheduled)?(0,s.jsx)(_.ZP,{type:"default",size:n,danger:!0,icon:(0,s.jsx)(en.Z,{}),loading:x,onClick:A,style:{borderColor:"#ff4d4f",color:"#ff4d4f",fontWeight:"500",borderRadius:"0.375rem",padding:"0.375rem 0.75rem",height:"auto",fontSize:"0.875rem",lineHeight:"1.25rem"},children:"Cancel Periodic Reload"}):(0,s.jsx)(_.ZP,{type:"default",size:n,icon:(0,s.jsx)(ei.Z,{}),onClick:()=>j(!0),style:{borderColor:"#d9d9d9",color:"#6366f1",fontWeight:"500",borderRadius:"0.375rem",padding:"0.375rem 0.75rem",height:"auto",fontSize:"0.875rem",lineHeight:"1.25rem"},children:"Set Up Periodic Reload"})]}),y&&(0,s.jsx)(et.Z,{size:"small",style:{backgroundColor:"#f8f9fa",border:"1px solid #e9ecef",borderRadius:8},children:(0,s.jsxs)(ee.Z,{direction:"vertical",size:"small",style:{width:"100%"},children:[y.scheduled?(0,s.jsx)("div",{children:(0,s.jsxs)(es.Z,{color:"green",icon:(0,s.jsx)(ei.Z,{}),children:["Scheduled every ",y.interval_hours," hours"]})}):(0,s.jsx)(ed,{type:"secondary",children:"No periodic reload scheduled"}),(0,s.jsxs)("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[(0,s.jsx)(ed,{type:"secondary",style:{fontSize:"12px"},children:"Last run:"}),(0,s.jsx)(ed,{style:{fontSize:"12px"},children:E(y.last_run)})]}),y.scheduled&&(0,s.jsxs)(s.Fragment,{children:[y.next_run&&(0,s.jsxs)("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[(0,s.jsx)(ed,{type:"secondary",style:{fontSize:"12px"},children:"Next run:"}),(0,s.jsx)(ed,{style:{fontSize:"12px"},children:E(y.next_run)})]}),(0,s.jsxs)("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[(0,s.jsx)(ed,{type:"secondary",style:{fontSize:"12px"},children:"Status:"}),(0,s.jsx)(es.Z,{color:(null==y?void 0:y.scheduled)?y.last_run?"success":"processing":"default",children:(null==y?void 0:y.scheduled)?y.last_run?"Active":"Ready":"Not scheduled"})]})]})]})}),(0,s.jsxs)(ea.Z,{title:"Set Up Periodic Reload",open:g,onOk:S,onCancel:()=>j(!1),confirmLoading:u,okText:"Schedule",cancelText:"Cancel",okButtonProps:{style:{backgroundColor:"#6366f1",borderColor:"#6366f1",color:"white"}},children:[(0,s.jsx)("div",{style:{marginBottom:16},children:(0,s.jsx)(ed,{children:"Set up automatic reload of price data every:"})}),(0,s.jsx)("div",{style:{marginBottom:16},children:(0,s.jsx)(Y.Z,{min:1,max:168,value:v,onChange:e=>b(e||6),addonAfter:"hours",style:{width:"100%"}})}),(0,s.jsx)("div",{children:(0,s.jsxs)(ed,{type:"secondary",children:["This will automatically fetch the latest pricing data from the remote source every ",v," hours."]})})]})]})},em=()=>{let{accessToken:e}=(0,n.Z)(),{refetch:l}=m();return(0,s.jsx)(z.Z,{children:(0,s.jsxs)("div",{className:"p-6",children:[(0,s.jsxs)("div",{className:"mb-6",children:[(0,s.jsx)(W.Z,{children:"Price Data Management"}),(0,s.jsx)(D.Z,{className:"text-tremor-content",children:"Manage model pricing data and configure automatic reload schedules"})]}),(0,s.jsx)(ec,{accessToken:e,onReloadSuccess:()=>{l()},buttonText:"Reload Price Data",size:"middle",type:"primary",className:"w-full"})]})})};let eu=async(e,l,t)=>{try{var s,a;console.log("handling submit for formValues:",e);let l=e.model_mappings||[];if("model_mappings"in e&&delete e.model_mappings,e.model&&e.model.includes("all-wildcard")){let t=e.custom_llm_provider,a=(null!==(s=L.fK[t])&&void 0!==s?s:t.toLowerCase())+"/*";e.model_name=a,l.push({public_name:a,litellm_model:a}),e.model=a}let t=[];for(let s of l){let l={},r={},i=s.public_name;for(let[t,i]of(l.model=s.litellm_model,e.input_cost_per_token&&(e.input_cost_per_token=Number(e.input_cost_per_token)/1e6),e.output_cost_per_token&&(e.output_cost_per_token=Number(e.output_cost_per_token)/1e6),l.model=s.litellm_model,console.log("formValues add deployment:",e),Object.entries(e)))if(""!==i&&"custom_pricing"!==t&&"pricing_model"!==t&&"cache_control"!==t){if("model_name"==t)l.model=i;else if("custom_llm_provider"==t){console.log("custom_llm_provider:",i);let e=null!==(a=L.fK[i])&&void 0!==a?a:i.toLowerCase();l.custom_llm_provider=e,console.log("custom_llm_provider mappingResult:",e)}else if("model"==t)continue;else if("base_model"===t)r[t]=i;else if("team_id"===t)r.team_id=i;else if("model_access_group"===t)r.access_groups=i;else if("mode"==t)console.log("placing mode in modelInfo"),r.mode=i,delete l.mode;else if("custom_model_name"===t)l.model=i;else if("litellm_extra_params"==t){console.log("litellm_extra_params:",i);let e={};if(i&&void 0!=i){try{e=JSON.parse(i)}catch(e){throw eo.Z.fromBackend("Failed to parse LiteLLM Extra Params: "+e),Error("Failed to parse litellm_extra_params: "+e)}for(let[t,s]of Object.entries(e))l[t]=s}}else if("model_info_params"==t){console.log("model_info_params:",i);let e={};if(i&&void 0!=i){try{e=JSON.parse(i)}catch(e){throw eo.Z.fromBackend("Failed to parse LiteLLM Extra Params: "+e),Error("Failed to parse litellm_extra_params: "+e)}for(let[l,t]of Object.entries(e))r[l]=t}}else if("input_cost_per_token"===t||"output_cost_per_token"===t||"input_cost_per_second"===t){i&&(l[t]=Number(i));continue}else l[t]=i}t.push({litellmParamsObj:l,modelInfoObj:r,modelName:i})}return t}catch(e){eo.Z.fromBackend("Failed to create model: "+e)}},eh=async(e,l,t,s)=>{try{let r=await eu(e,l,t);if(!r||0===r.length)return;for(let e of r){let{litellmParamsObj:t,modelInfoObj:s,modelName:r}=e,i={model_name:r,litellm_params:t,model_info:s},n=await (0,a.modelCreateCall)(l,i);console.log("response for model create call: ".concat(n.data))}s&&s(),t.resetFields()}catch(e){eo.Z.fromBackend("Failed to add model: "+e)}};var ex=t(53410),ep=t(62490),eg=t(10032),ef=t(21609),ej=t(31283),ev=t(37592);let e_=(0,i.n)("providerFields"),eb=()=>(0,r.a)({queryKey:e_.list({}),queryFn:async()=>await (0,a.getProviderCreateMetadata)(),staleTime:864e5,gcTime:864e5});var ey=t(3632),eN=t(56522),ew=t(47451),eZ=t(69410),eC=t(65319),ek=t(4260);let{Link:eS}=Q.default,eA=e=>{var l,t,s,a,r;let i="password"===e.field_type?"password":"select"===e.field_type?"select":"upload"===e.field_type?"upload":"textarea"===e.field_type?"textarea":"text";return{key:e.key,label:e.label,placeholder:null!==(l=e.placeholder)&&void 0!==l?l:void 0,tooltip:null!==(t=e.tooltip)&&void 0!==t?t:void 0,required:null!==(s=e.required)&&void 0!==s&&s,type:i,options:null!==(a=e.options)&&void 0!==a?a:void 0,defaultValue:null!==(r=e.default_value)&&void 0!==r?r:void 0}},eE={};var eP=e=>{let{selectedProvider:l,uploadProps:t}=e,a=L.Cl[l],r=eg.Z.useFormInstance(),{data:i,isLoading:n,error:o}=eb(),d=f.useMemo(()=>{if(!i)return null;let e={};return i.forEach(l=>{let t=l.provider_display_name,s=l.credential_fields.map(eA);e[t]=s,l.provider&&(e[l.provider]=s),l.litellm_provider&&(e[l.litellm_provider]=s)}),e},[i]);f.useEffect(()=>{d&&Object.assign(eE,d)},[d]);let c=f.useMemo(()=>{var e;let t=null!==(e=eE[a])&&void 0!==e?e:eE[l];if(t)return t;if(!i)return[];let s=i.find(e=>e.provider_display_name===a||e.provider===l||e.litellm_provider===l);if(!s)return[];let r=s.credential_fields.map(eA);return eE[s.provider_display_name]=r,s.provider&&(eE[s.provider]=r),s.litellm_provider&&(eE[s.litellm_provider]=r),r},[a,l,i]),m={name:"file",accept:".json",beforeUpload:e=>{if("application/json"===e.type){let l=new FileReader;l.onload=e=>{if(e.target){let l=e.target.result;console.log("Setting field value from JSON, length: ".concat(l.length)),r.setFieldsValue({vertex_credentials:l}),console.log("Form values after setting:",r.getFieldsValue())}},l.readAsText(e)}return!1},onChange(e){console.log("Upload onChange triggered in ProviderSpecificFields"),console.log("Current form values:",r.getFieldsValue()),"uploading"!==e.file.status&&console.log(e.file,e.fileList)}};return(0,s.jsxs)(s.Fragment,{children:[n&&0===c.length&&(0,s.jsx)(ew.Z,{children:(0,s.jsx)(eZ.Z,{span:24,children:(0,s.jsx)(eN.x,{className:"mb-2",children:"Loading provider fields..."})})}),o&&0===c.length&&(0,s.jsx)(ew.Z,{children:(0,s.jsx)(eZ.Z,{span:24,children:(0,s.jsx)(eN.x,{className:"mb-2 text-red-500",children:o instanceof Error?o.message:"Failed to load provider credential fields"})})}),c.map(e=>{var l;return(0,s.jsxs)(f.Fragment,{children:[(0,s.jsx)(eg.Z.Item,{label:e.label,name:e.key,rules:e.required?[{required:!0,message:"Required"}]:void 0,tooltip:e.tooltip,className:"vertex_credentials"===e.key?"mb-0":void 0,children:"select"===e.type?(0,s.jsx)(ev.default,{placeholder:e.placeholder,defaultValue:e.defaultValue,children:null===(l=e.options)||void 0===l?void 0:l.map(e=>(0,s.jsx)(ev.default.Option,{value:e,children:e},e))}):"upload"===e.type?(0,s.jsx)(eC.default,{...m,onChange:l=>{(null==t?void 0:t.onChange)&&t.onChange(l),setTimeout(()=>{let l=r.getFieldValue(e.key);console.log("".concat(e.key," value after upload:"),JSON.stringify(l))},500)},children:(0,s.jsx)(_.ZP,{icon:(0,s.jsx)(ey.Z,{}),children:"Click to Upload"})}):"textarea"===e.type?(0,s.jsx)(ek.default.TextArea,{placeholder:e.placeholder,defaultValue:e.defaultValue,rows:6,style:{fontFamily:"monospace",fontSize:"12px"}}):(0,s.jsx)(eN.o,{placeholder:e.placeholder,type:"password"===e.type?"password":"text",defaultValue:e.defaultValue})}),"vertex_credentials"===e.key&&(0,s.jsx)(ew.Z,{children:(0,s.jsx)(eZ.Z,{children:(0,s.jsx)(eN.x,{className:"mb-3 mt-1",children:"Give a gcp service account(.json file)"})})}),"base_model"===e.key&&(0,s.jsxs)(ew.Z,{children:[(0,s.jsx)(eZ.Z,{span:10}),(0,s.jsx)(eZ.Z,{span:10,children:(0,s.jsxs)(eN.x,{className:"mb-2",children:["The actual model your azure deployment uses. Used for accurate cost tracking. Select name from"," ",(0,s.jsx)(eS,{href:"https://github.com/BerriAI/litellm/blob/main/model_prices_and_context_window.json",target:"_blank",children:"here"})]})})]})]},e.key)})]})};let{Link:eM}=Q.default;var eL=e=>{let{open:l,onCancel:t,onAddCredential:a,uploadProps:r}=e,[i]=eg.Z.useForm(),[n,o]=(0,f.useState)(L.Cl.OpenAI);return(0,s.jsx)(ea.Z,{title:"Add New Credential",open:l,onCancel:()=>{t(),i.resetFields()},footer:null,width:600,children:(0,s.jsxs)(eg.Z,{form:i,onFinish:e=>{a(Object.entries(e).reduce((e,l)=>{let[t,s]=l;return""!==s&&null!=s&&(e[t]=s),e},{})),i.resetFields()},layout:"vertical",children:[(0,s.jsx)(eg.Z.Item,{label:"Credential Name:",name:"credential_name",rules:[{required:!0,message:"Credential name is required"}],children:(0,s.jsx)(ej.o,{placeholder:"Enter a friendly name for these credentials"})}),(0,s.jsx)(eg.Z.Item,{rules:[{required:!0,message:"Required"}],label:"Provider:",name:"custom_llm_provider",tooltip:"Helper to auto-populate provider specific fields",children:(0,s.jsx)(ev.default,{showSearch:!0,onChange:e=>{o(e),i.setFieldValue("custom_llm_provider",e)},children:Object.entries(L.Cl).map(e=>{let[l,t]=e;return(0,s.jsx)(ev.default.Option,{value:l,children:(0,s.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,s.jsx)("img",{src:L.cd[t],alt:"".concat(l," logo"),className:"w-5 h-5",onError:e=>{let l=e.target,s=l.parentElement;if(s){let e=document.createElement("div");e.className="w-5 h-5 rounded-full bg-gray-200 flex items-center justify-center text-xs",e.textContent=t.charAt(0),s.replaceChild(e,l)}}}),(0,s.jsx)("span",{children:t})]})},l)})})}),(0,s.jsx)(eP,{selectedProvider:n,uploadProps:r}),(0,s.jsxs)("div",{className:"flex justify-between items-center",children:[(0,s.jsx)(M.Z,{title:"Get help on our github",children:(0,s.jsx)(eM,{href:"https://github.com/BerriAI/litellm/issues",children:"Need Help?"})}),(0,s.jsxs)("div",{children:[(0,s.jsx)(_.ZP,{onClick:()=>{t(),i.resetFields()},style:{marginRight:10},children:"Cancel"}),(0,s.jsx)(_.ZP,{htmlType:"submit",children:"Add Credential"})]})]})]})})};let{Link:eF}=Q.default;function eI(e){let{open:l,onCancel:t,onUpdateCredential:a,uploadProps:r,existingCredential:i}=e,[n]=eg.Z.useForm(),[o,d]=(0,f.useState)(L.Cl.Anthropic);return(0,f.useEffect)(()=>{if(i){let e=Object.entries(i.credential_values||{}).reduce((e,l)=>{let[t,s]=l;return e[t]=null!=s?s:null,e},{});n.setFieldsValue({credential_name:i.credential_name,custom_llm_provider:i.credential_info.custom_llm_provider,...e}),d(i.credential_info.custom_llm_provider)}},[i]),(0,s.jsx)(ea.Z,{title:"Edit Credential",open:l,onCancel:()=>{t(),n.resetFields()},footer:null,width:600,destroyOnHidden:!0,children:(0,s.jsxs)(eg.Z,{form:n,onFinish:e=>{a(Object.entries(e).reduce((e,l)=>{let[t,s]=l;return""!==s&&null!=s&&(e[t]=s),e},{})),n.resetFields()},layout:"vertical",children:[(0,s.jsx)(eg.Z.Item,{label:"Credential Name:",name:"credential_name",rules:[{required:!0,message:"Credential name is required"}],initialValue:null==i?void 0:i.credential_name,children:(0,s.jsx)(ej.o,{placeholder:"Enter a friendly name for these credentials",disabled:null!=i&&!!i.credential_name})}),(0,s.jsx)(eg.Z.Item,{rules:[{required:!0,message:"Required"}],label:"Provider:",name:"custom_llm_provider",tooltip:"Helper to auto-populate provider specific fields",children:(0,s.jsx)(ev.default,{showSearch:!0,onChange:e=>{d(e),n.setFieldValue("custom_llm_provider",e)},children:Object.entries(L.Cl).map(e=>{let[l,t]=e;return(0,s.jsx)(ev.default.Option,{value:l,children:(0,s.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,s.jsx)("img",{src:L.cd[t],alt:"".concat(l," logo"),className:"w-5 h-5",onError:e=>{let l=e.target,s=l.parentElement;if(s){let e=document.createElement("div");e.className="w-5 h-5 rounded-full bg-gray-200 flex items-center justify-center text-xs",e.textContent=t.charAt(0),s.replaceChild(e,l)}}}),(0,s.jsx)("span",{children:t})]})},l)})})}),(0,s.jsx)(eP,{selectedProvider:o,uploadProps:r}),(0,s.jsxs)("div",{className:"flex justify-between items-center",children:[(0,s.jsx)(M.Z,{title:"Get help on our github",children:(0,s.jsx)(eF,{href:"https://github.com/BerriAI/litellm/issues",children:"Need Help?"})}),(0,s.jsxs)("div",{children:[(0,s.jsx)(_.ZP,{onClick:()=>{t(),n.resetFields()},style:{marginRight:10},children:"Cancel"}),(0,s.jsx)(_.ZP,{htmlType:"submit",children:"Update Credential"})]})]})]})})}var eT=e=>{var l;let{uploadProps:t}=e,{accessToken:r}=(0,n.Z)(),{data:i,refetch:o}=d(),c=(null==i?void 0:i.credentials)||[],[m,u]=(0,f.useState)(!1),[h,x]=(0,f.useState)(!1),[p,g]=(0,f.useState)(null),[j,v]=(0,f.useState)(null),[_,b]=(0,f.useState)(!1),[y,N]=(0,f.useState)(!1),[w]=eg.Z.useForm(),Z=["credential_name","custom_llm_provider"],C=async e=>{if(!r)return;let l=Object.entries(e).filter(e=>{let[l]=e;return!Z.includes(l)}).reduce((e,l)=>{let[t,s]=l;return{...e,[t]:s}},{}),t={credential_name:e.credential_name,credential_values:l,credential_info:{custom_llm_provider:e.custom_llm_provider}};await (0,a.credentialUpdateCall)(r,e.credential_name,t),eo.Z.success("Credential updated successfully"),x(!1),await o()},k=async e=>{if(!r)return;let l=Object.entries(e).filter(e=>{let[l]=e;return!Z.includes(l)}).reduce((e,l)=>{let[t,s]=l;return{...e,[t]:s}},{}),t={credential_name:e.credential_name,credential_values:l,credential_info:{custom_llm_provider:e.custom_llm_provider}};await (0,a.credentialCreateCall)(r,t),eo.Z.success("Credential added successfully"),u(!1),await o()},A=e=>{let l={openai:"blue",azure:"indigo",anthropic:"purple",default:"gray"},t=l[e.toLowerCase()]||l.default;return(0,s.jsx)(ep.Ct,{color:t,size:"xs",children:e})},E=async()=>{if(r&&j){N(!0);try{await (0,a.credentialDeleteCall)(r,j.credential_name),eo.Z.success("Credential deleted successfully"),await o()}catch(e){eo.Z.error("Failed to delete credential")}finally{v(null),b(!1),N(!1)}}},P=e=>{v(e),b(!0)};return(0,s.jsxs)("div",{className:"w-full mx-auto flex-auto overflow-y-auto p-2",children:[(0,s.jsx)(ep.zx,{onClick:()=>u(!0),children:"Add Credential"}),(0,s.jsx)("div",{className:"flex justify-between items-center mt-4 mb-4",children:(0,s.jsx)(ep.xv,{children:"Configured credentials for different AI providers. Add and manage your API credentials."})}),(0,s.jsx)(ep.Zb,{children:(0,s.jsxs)(ep.iA,{children:[(0,s.jsx)(ep.ss,{children:(0,s.jsxs)(ep.SC,{children:[(0,s.jsx)(ep.xs,{children:"Credential Name"}),(0,s.jsx)(ep.xs,{children:"Provider"}),(0,s.jsx)(ep.xs,{children:"Actions"})]})}),(0,s.jsx)(ep.RM,{children:c&&0!==c.length?c.map((e,l)=>{var t;return(0,s.jsxs)(ep.SC,{children:[(0,s.jsx)(ep.pj,{children:e.credential_name}),(0,s.jsx)(ep.pj,{children:A((null===(t=e.credential_info)||void 0===t?void 0:t.custom_llm_provider)||"-")}),(0,s.jsxs)(ep.pj,{children:[(0,s.jsx)(ep.zx,{icon:ex.Z,variant:"light",size:"sm",onClick:()=>{g(e),x(!0)}}),(0,s.jsx)(ep.zx,{icon:S.Z,variant:"light",size:"sm",onClick:()=>P(e),className:"ml-2"})]})]},l)}):(0,s.jsx)(ep.SC,{children:(0,s.jsx)(ep.pj,{colSpan:4,className:"text-center py-4 text-gray-500",children:"No credentials configured"})})})]})}),m&&(0,s.jsx)(eL,{onAddCredential:k,open:m,onCancel:()=>u(!1),uploadProps:t}),h&&(0,s.jsx)(eI,{open:h,existingCredential:p,onUpdateCredential:C,uploadProps:t,onCancel:()=>x(!1)}),(0,s.jsx)(ef.Z,{isOpen:_,onCancel:()=>{v(null),b(!1)},onOk:E,title:"Delete Credential?",message:"Are you sure you want to delete this credential? This action cannot be undone and may break existing integrations.",resourceInformationTitle:"Credential Information",resourceInformation:[{label:"Credential Name",value:null==j?void 0:j.credential_name},{label:"Provider",value:(null==j?void 0:null===(l=j.credential_info)||void 0===l?void 0:l.custom_llm_provider)||"-"}],confirmLoading:y,requiredConfirmation:null==j?void 0:j.credential_name})]})},eR=t(20347),eO=t(23628),eV=t(29827),eq=t(49804),ez=t(12485),eD=t(18135),eB=t(35242),eG=t(77991),eU=t(34419),eH=t(58643),eK=t(29),eJ=t.n(eK),eW=t(23496),eY=t(35291),e$=t(23639);let{Text:eX}=Q.default;var eQ=e=>{let{formValues:l,accessToken:t,testMode:r,modelName:i="this model",onClose:n,onTestComplete:o}=e,[d,c]=f.useState(null),[m,u]=f.useState(null),[h,x]=f.useState(null),[p,g]=f.useState(!0),[j,v]=f.useState(!1),[b,y]=f.useState(!1),N=async()=>{g(!0),y(!1),c(null),u(null),x(null),v(!1),await new Promise(e=>setTimeout(e,100));try{console.log("Testing connection with form values:",l);let r=await eu(l,t,null);if(!r){console.log("No result from prepareModelAddRequest"),c("Failed to prepare model data. Please check your form inputs."),v(!1),g(!1);return}console.log("Result from prepareModelAddRequest:",r);let{litellmParamsObj:i,modelInfoObj:n,modelName:o}=r[0],d=await (0,a.testConnectionRequest)(t,i,n,null==n?void 0:n.mode);if("success"===d.status)eo.Z.success("Connection test successful!"),c(null),v(!0);else{var e,s;let l=(null===(e=d.result)||void 0===e?void 0:e.error)||d.message||"Unknown error";c(l),u(i),x(null===(s=d.result)||void 0===s?void 0:s.raw_request_typed_dict),v(!1)}}catch(e){console.error("Test connection error:",e),c(e instanceof Error?e.message:String(e)),v(!1)}finally{g(!1),o&&o()}};f.useEffect(()=>{let e=setTimeout(()=>{N()},200);return()=>clearTimeout(e)},[]);let w=e=>e?e.split("stack trace:")[0].trim().replace(/^litellm\.(.*?)Error: /,""):"Unknown error",Z="string"==typeof d?w(d):(null==d?void 0:d.message)?w(d.message):"Unknown error",C=h?((e,l,t)=>{let s=JSON.stringify(l,null,2).split("\n").map(e=>" ".concat(e)).join("\n"),a=Object.entries(t).map(e=>{let[l,t]=e;return"-H '".concat(l,": ").concat(t,"'")}).join(" \\\n ");return"curl -X POST \\\n ".concat(e," \\\n ").concat(a?"".concat(a," \\\n "):"","-H 'Content-Type: application/json' \\\n -d '{\n").concat(s,"\n }'")})(h.raw_request_api_base,h.raw_request_body,h.raw_request_headers||{}):"";return(0,s.jsxs)("div",{style:{padding:"24px",borderRadius:"8px",backgroundColor:"#fff"},children:[p?(0,s.jsxs)("div",{style:{textAlign:"center",padding:"32px 20px"},className:"jsx-dc9a0e2d897fe63b",children:[(0,s.jsx)("div",{style:{marginBottom:"16px"},className:"jsx-dc9a0e2d897fe63b loading-spinner",children:(0,s.jsx)("div",{style:{border:"3px solid #f3f3f3",borderTop:"3px solid #1890ff",borderRadius:"50%",width:"30px",height:"30px",animation:"spin 1s linear infinite",margin:"0 auto"},className:"jsx-dc9a0e2d897fe63b"})}),(0,s.jsxs)(eX,{style:{fontSize:"16px"},children:["Testing connection to ",i,"..."]}),(0,s.jsx)(eJ(),{id:"dc9a0e2d897fe63b",children:"@-webkit-keyframes spin{0%{-webkit-transform:rotate(0deg);transform:rotate(0deg)}100%{-webkit-transform:rotate(360deg);transform:rotate(360deg)}}@-moz-keyframes spin{0%{-moz-transform:rotate(0deg);transform:rotate(0deg)}100%{-moz-transform:rotate(360deg);transform:rotate(360deg)}}@-o-keyframes spin{0%{-o-transform:rotate(0deg);transform:rotate(0deg)}100%{-o-transform:rotate(360deg);transform:rotate(360deg)}}@keyframes spin{0%{-webkit-transform:rotate(0deg);-moz-transform:rotate(0deg);-o-transform:rotate(0deg);transform:rotate(0deg)}100%{-webkit-transform:rotate(360deg);-moz-transform:rotate(360deg);-o-transform:rotate(360deg);transform:rotate(360deg)}}"})]}):j?(0,s.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",padding:"32px 20px"},children:[(0,s.jsx)("div",{style:{color:"#52c41a",fontSize:"24px",display:"flex",alignItems:"center"},children:(0,s.jsx)("svg",{viewBox:"64 64 896 896",focusable:"false","data-icon":"check-circle",width:"1em",height:"1em",fill:"currentColor","aria-hidden":"true",children:(0,s.jsx)("path",{d:"M512 64C264.6 64 64 264.6 64 512s200.6 448 448 448 448-200.6 448-448S759.4 64 512 64zm193.5 301.7l-210.6 292a31.8 31.8 0 01-51.7 0L318.5 484.9c-3.8-5.3 0-12.7 6.5-12.7h46.9c10.2 0 19.9 4.9 25.9 13.3l71.2 98.8 157.2-218c6-8.3 15.6-13.3 25.9-13.3H699c6.5 0 10.3 7.4 6.5 12.7z"})})}),(0,s.jsxs)(eX,{type:"success",style:{fontSize:"18px",fontWeight:500,marginLeft:"10px"},children:["Connection to ",i," successful!"]})]}):(0,s.jsx)(s.Fragment,{children:(0,s.jsxs)("div",{children:[(0,s.jsxs)("div",{style:{display:"flex",alignItems:"center",marginBottom:"20px"},children:[(0,s.jsx)(eY.Z,{style:{color:"#ff4d4f",fontSize:"24px",marginRight:"12px"}}),(0,s.jsxs)(eX,{type:"danger",style:{fontSize:"18px",fontWeight:500},children:["Connection to ",i," failed"]})]}),(0,s.jsxs)("div",{style:{backgroundColor:"#fff2f0",border:"1px solid #ffccc7",borderRadius:"8px",padding:"16px",marginBottom:"20px",boxShadow:"0 1px 2px rgba(0, 0, 0, 0.03)"},children:[(0,s.jsxs)(eX,{strong:!0,style:{display:"block",marginBottom:"8px"},children:["Error:"," "]}),(0,s.jsx)(eX,{type:"danger",style:{fontSize:"14px",lineHeight:"1.5"},children:Z}),d&&(0,s.jsx)("div",{style:{marginTop:"12px"},children:(0,s.jsx)(_.ZP,{type:"link",onClick:()=>y(!b),style:{paddingLeft:0,height:"auto"},children:b?"Hide Details":"Show Details"})})]}),b&&(0,s.jsxs)("div",{style:{marginBottom:"20px"},children:[(0,s.jsx)(eX,{strong:!0,style:{display:"block",marginBottom:"8px",fontSize:"15px"},children:"Troubleshooting Details"}),(0,s.jsx)("pre",{style:{backgroundColor:"#f5f5f5",padding:"16px",borderRadius:"8px",fontSize:"13px",maxHeight:"200px",overflow:"auto",border:"1px solid #e8e8e8",lineHeight:"1.5"},children:"string"==typeof d?d:JSON.stringify(d,null,2)})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)(eX,{strong:!0,style:{display:"block",marginBottom:"8px",fontSize:"15px"},children:"API Request"}),(0,s.jsx)("pre",{style:{backgroundColor:"#f5f5f5",padding:"16px",borderRadius:"8px",fontSize:"13px",maxHeight:"250px",overflow:"auto",border:"1px solid #e8e8e8",lineHeight:"1.5"},children:C||"No request data available"}),(0,s.jsx)(_.ZP,{style:{marginTop:"8px"},icon:(0,s.jsx)(e$.Z,{}),onClick:()=>{navigator.clipboard.writeText(C||""),eo.Z.success("Copied to clipboard")},children:"Copy to Clipboard"})]})]})}),(0,s.jsx)(eW.Z,{style:{margin:"24px 0 16px"}}),(0,s.jsx)("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:(0,s.jsx)(_.ZP,{type:"link",href:"https://docs.litellm.ai/docs/providers",target:"_blank",icon:(0,s.jsx)(R.Z,{}),children:"View Documentation"})})]})};let e0=async(e,l,t,s)=>{try{console.log("=== AUTO ROUTER SUBMIT HANDLER CALLED ==="),console.log("handling auto router submit for formValues:",e),console.log("Access token:",l?"Present":"Missing"),console.log("Form:",t?"Present":"Missing"),console.log("Callback:",s?"Present":"Missing");let r={model_name:e.auto_router_name,litellm_params:{model:"auto_router/".concat(e.auto_router_name),auto_router_config:JSON.stringify(e.auto_router_config),auto_router_default_model:e.auto_router_default_model},model_info:{}};e.auto_router_embedding_model&&"custom"!==e.auto_router_embedding_model?r.litellm_params.auto_router_embedding_model=e.auto_router_embedding_model:e.custom_embedding_model&&(r.litellm_params.auto_router_embedding_model=e.custom_embedding_model),e.team_id&&(r.model_info.team_id=e.team_id),e.model_access_group&&e.model_access_group.length>0&&(r.model_info.access_groups=e.model_access_group),console.log("Auto router configuration to be created:",r),console.log("Auto router config (stringified):",r.litellm_params.auto_router_config),console.log("Calling modelCreateCall with:",{accessToken:l?"Present":"Missing",config:r});let i=await (0,a.modelCreateCall)(l,r);console.log("response for auto router create call:",i),t.resetFields()}catch(e){console.error("Failed to add auto router:",e),eo.Z.fromBackend("Failed to add auto router: "+e)}};var e1=t(10703),e2=t(44851),e4=t(96473),e5=t(70464),e6=t(26349),e3=t(92280);let{TextArea:e8}=ek.default,{Panel:e7}=e2.default;var e9=e=>{let{modelInfo:l,value:t,onChange:a}=e,[r,i]=(0,f.useState)([]),[n,o]=(0,f.useState)(!1),[d,c]=(0,f.useState)([]);(0,f.useEffect)(()=>{if(null==t?void 0:t.routes){let e=t.routes.map((e,l)=>({id:e.id||"route-".concat(l,"-").concat(Date.now()),model:e.name||e.model||"",utterances:e.utterances||[],description:e.description||"",score_threshold:e.score_threshold||.5}));i(e),c(e.map(e=>e.id))}else i([]),c([])},[t]);let m=e=>{let l=r.filter(l=>l.id!==e);i(l),h(l),c(l=>l.filter(l=>l!==e))},u=(e,l,t)=>{let s=r.map(s=>s.id===e?{...s,[l]:t}:s);i(s),h(s)},h=e=>{let l={routes:e.map(e=>({name:e.model,utterances:e.utterances,description:e.description,score_threshold:e.score_threshold}))};null==a||a(l)},x=l.map(e=>({value:e.model_group,label:e.model_group}));return(0,s.jsxs)("div",{className:"w-full max-w-none",children:[(0,s.jsxs)("div",{className:"flex justify-between items-center mb-6 w-full",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)(e3.x,{className:"text-lg font-semibold",children:"Routes Configuration"}),(0,s.jsx)(M.Z,{title:"Configure routing logic to automatically select the best model based on user input patterns",children:(0,s.jsx)(R.Z,{className:"text-gray-400"})})]}),(0,s.jsx)(_.ZP,{type:"primary",icon:(0,s.jsx)(e4.Z,{}),onClick:()=>{let e="route-".concat(Date.now()),l=[...r,{id:e,model:"",utterances:[],description:"",score_threshold:.5}];i(l),h(l),c(l=>[...l,e])},className:"bg-blue-600 hover:bg-blue-700",children:"Add Route"})]}),0===r.length?(0,s.jsx)("div",{className:"text-center py-12 text-gray-500 bg-gray-50 rounded-lg border-2 border-dashed border-gray-200 mb-6",children:(0,s.jsx)(e3.x,{children:"No routes configured. Click “Add Route” to get started."})}):(0,s.jsx)("div",{className:"space-y-3 mb-6 w-full",children:r.map((e,l)=>(0,s.jsx)(et.Z,{className:"border border-gray-200 shadow-sm w-full",bodyStyle:{padding:0},children:(0,s.jsx)(e2.default,{ghost:!0,expandIcon:e=>{let{isActive:l}=e;return(0,s.jsx)(e5.Z,{rotate:l?180:0})},activeKey:d,onChange:e=>c(Array.isArray(e)?e:[e].filter(Boolean)),items:[{key:e.id,label:(0,s.jsxs)("div",{className:"flex justify-between items-center py-2",children:[(0,s.jsxs)(e3.x,{className:"font-medium text-base",children:["Route ",l+1,": ",e.model||"Unnamed"]}),(0,s.jsx)(_.ZP,{type:"text",danger:!0,icon:(0,s.jsx)(e6.Z,{}),onClick:l=>{l.stopPropagation(),m(e.id)},className:"mr-2"})]}),children:(0,s.jsxs)("div",{className:"px-6 pb-6 w-full",children:[(0,s.jsxs)("div",{className:"mb-4 w-full",children:[(0,s.jsx)(e3.x,{className:"text-sm font-medium mb-2 block",children:"Model"}),(0,s.jsx)(ev.default,{value:e.model,onChange:l=>u(e.id,"model",l),placeholder:"Select model",showSearch:!0,style:{width:"100%"},options:x})]}),(0,s.jsxs)("div",{className:"mb-4 w-full",children:[(0,s.jsx)(e3.x,{className:"text-sm font-medium mb-2 block",children:"Description"}),(0,s.jsx)(e8,{value:e.description,onChange:l=>u(e.id,"description",l.target.value),placeholder:"Describe when this route should be used...",rows:2,style:{width:"100%"}})]}),(0,s.jsxs)("div",{className:"mb-4 w-full",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2 mb-2",children:[(0,s.jsx)(e3.x,{className:"text-sm font-medium",children:"Score Threshold"}),(0,s.jsx)(M.Z,{title:"Minimum similarity score to route to this model (0-1)",children:(0,s.jsx)(R.Z,{className:"text-gray-400"})})]}),(0,s.jsx)(Y.Z,{value:e.score_threshold,onChange:l=>u(e.id,"score_threshold",l||0),min:0,max:1,step:.1,style:{width:"100%"},placeholder:"0.5"})]}),(0,s.jsxs)("div",{className:"w-full",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2 mb-2",children:[(0,s.jsx)(e3.x,{className:"text-sm font-medium",children:"Example Utterances"}),(0,s.jsx)(M.Z,{title:"Training examples for this route. Type an utterance and press Enter to add it.",children:(0,s.jsx)(R.Z,{className:"text-gray-400"})})]}),(0,s.jsx)(e3.x,{className:"text-xs text-gray-500 mb-2",children:"Type an utterance and press Enter to add it. You can also paste multiple lines."}),(0,s.jsx)(ev.default,{mode:"tags",value:e.utterances,onChange:l=>u(e.id,"utterances",l),placeholder:"Type an utterance and press Enter...",style:{width:"100%"},tokenSeparators:["\n"],maxTagCount:"responsive",allowClear:!0})]})]})}]})},e.id))}),(0,s.jsxs)("div",{className:"border-t pt-6 w-full",children:[(0,s.jsxs)("div",{className:"flex justify-between items-center mb-4 w-full",children:[(0,s.jsx)(e3.x,{className:"text-lg font-semibold",children:"JSON Preview"}),(0,s.jsx)(_.ZP,{type:"link",onClick:()=>o(!n),className:"text-blue-600 p-0",children:n?"Hide":"Show"})]}),n&&(0,s.jsx)(et.Z,{className:"bg-gray-50 w-full",children:(0,s.jsx)("pre",{className:"text-sm overflow-auto max-h-64 w-full",children:JSON.stringify({routes:r.map(e=>({name:e.model,utterances:e.utterances,description:e.description,score_threshold:e.score_threshold}))},null,2)})})]})]})};let{Title:le,Link:ll}=Q.default;var lt=e=>{let{form:l,handleOk:t,accessToken:r,userRole:i}=e,[n,o]=(0,f.useState)(!1),[d,c]=(0,f.useState)(!1),[m,u]=(0,f.useState)(""),[h,x]=(0,f.useState)([]),[p,g]=(0,f.useState)([]),[j,v]=(0,f.useState)(!1),[b,y]=(0,f.useState)(!1),[N,w]=(0,f.useState)(null);(0,f.useEffect)(()=>{(async()=>{x((await (0,a.modelAvailableCall)(r,"","",!1,null,!0,!0)).data.map(e=>e.id))})()},[r]),(0,f.useEffect)(()=>{(async()=>{try{let e=await (0,e1.p)(r);console.log("Fetched models for auto router:",e),g(e)}catch(e){console.error("Error fetching model info for auto router:",e)}})()},[r]);let Z=eR.ZL.includes(i),C=async()=>{c(!0),u("test-".concat(Date.now())),o(!0)},k=()=>{console.log("Auto router submit triggered!"),console.log("Router config:",N);let e=l.getFieldsValue();if(console.log("Form values:",e),!e.auto_router_name){eo.Z.fromBackend("Please enter an Auto Router Name");return}if(!e.auto_router_default_model){eo.Z.fromBackend("Please select a Default Model");return}if(l.setFieldsValue({custom_llm_provider:"auto_router",model:e.auto_router_name,api_key:"not_required_for_auto_router"}),!N||!N.routes||0===N.routes.length){eo.Z.fromBackend("Please configure at least one route for the auto router");return}if(N.routes.filter(e=>!e.name||!e.description||0===e.utterances.length).length>0){eo.Z.fromBackend("Please ensure all routes have a target model, description, and at least one utterance");return}l.validateFields().then(e=>{console.log("Form validation passed, submitting with values:",e);let s={...e,auto_router_config:N};console.log("Final submit values:",s),e0(s,r,l,t)}).catch(e=>{console.error("Validation failed:",e);let l=e.errorFields||[];if(l.length>0){let e=l.map(e=>{let l=e.name[0];return({auto_router_name:"Auto Router Name",auto_router_default_model:"Default Model",auto_router_embedding_model:"Embedding Model"})[l]||l});eo.Z.fromBackend("Please fill in the following required fields: ".concat(e.join(", ")))}else eo.Z.fromBackend("Please fill in all required fields")})};return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(le,{level:2,children:"Add Auto Router"}),(0,s.jsx)(eN.x,{className:"text-gray-600 mb-6",children:"Create an auto router with intelligent routing logic that automatically selects the best model based on user input patterns and semantic matching."}),(0,s.jsx)(et.Z,{children:(0,s.jsxs)(eg.Z,{form:l,onFinish:k,labelCol:{span:10},wrapperCol:{span:16},labelAlign:"left",children:[(0,s.jsx)(eg.Z.Item,{rules:[{required:!0,message:"Auto router name is required"}],label:"Auto Router Name",name:"auto_router_name",tooltip:"Unique name for this auto router configuration",labelCol:{span:10},labelAlign:"left",children:(0,s.jsx)(eN.o,{placeholder:"e.g., auto_router_1, smart_routing"})}),(0,s.jsx)("div",{className:"w-full mb-4",children:(0,s.jsx)(e9,{modelInfo:p,value:N,onChange:e=>{w(e),l.setFieldValue("auto_router_config",e)}})}),(0,s.jsx)(eg.Z.Item,{rules:[{required:!0,message:"Default model is required"}],label:"Default Model",name:"auto_router_default_model",tooltip:"Fallback model to use when auto routing logic cannot determine the best model",labelCol:{span:10},labelAlign:"left",children:(0,s.jsx)(ev.default,{placeholder:"Select a default model",onChange:e=>{v("custom"===e)},options:[...Array.from(new Set(p.map(e=>e.model_group))).map(e=>({value:e,label:e})),{value:"custom",label:"Enter custom model name"}],style:{width:"100%"},showSearch:!0})}),(0,s.jsx)(eg.Z.Item,{label:"Embedding Model",name:"auto_router_embedding_model",tooltip:"Optional: Embedding model to use for semantic routing decisions",labelCol:{span:10},labelAlign:"left",children:(0,s.jsx)(ev.default,{value:l.getFieldValue("auto_router_embedding_model"),placeholder:"Select an embedding model (optional)",onChange:e=>{y("custom"===e),l.setFieldValue("auto_router_embedding_model",e)},options:[...Array.from(new Set(p.map(e=>e.model_group))).map(e=>({value:e,label:e})),{value:"custom",label:"Enter custom model name"}],style:{width:"100%"},showSearch:!0,allowClear:!0})}),(0,s.jsxs)("div",{className:"flex items-center my-4",children:[(0,s.jsx)("div",{className:"flex-grow border-t border-gray-200"}),(0,s.jsx)("span",{className:"px-4 text-gray-500 text-sm",children:"Additional Settings"}),(0,s.jsx)("div",{className:"flex-grow border-t border-gray-200"})]}),Z&&(0,s.jsx)(eg.Z.Item,{label:"Model Access Group",name:"model_access_group",className:"mb-4",tooltip:"Use model access groups to control who can access this auto router",children:(0,s.jsx)(ev.default,{mode:"tags",showSearch:!0,placeholder:"Select existing groups or type to create new ones",optionFilterProp:"children",tokenSeparators:[","],options:h.map(e=>({value:e,label:e})),maxTagCount:"responsive",allowClear:!0})}),(0,s.jsxs)("div",{className:"flex justify-between items-center mb-4",children:[(0,s.jsx)(M.Z,{title:"Get help on our github",children:(0,s.jsx)(Q.default.Link,{href:"https://github.com/BerriAI/litellm/issues",children:"Need Help?"})}),(0,s.jsxs)("div",{className:"space-x-2",children:[(0,s.jsx)(_.ZP,{onClick:C,loading:d,children:"Test Connect"}),(0,s.jsx)(_.ZP,{onClick:()=>{console.log("Add Auto Router button clicked!"),console.log("Current router config:",N),console.log("Current form values:",l.getFieldsValue()),k()},children:"Add Auto Router"})]})]})]})}),(0,s.jsx)(ea.Z,{title:"Connection Test Results",open:n,onCancel:()=>{o(!1),c(!1)},footer:[(0,s.jsx)(_.ZP,{onClick:()=>{o(!1),c(!1)},children:"Close"},"close")],width:700,children:n&&(0,s.jsx)(eQ,{formValues:l.getFieldsValue(),accessToken:r,testMode:"chat",modelName:l.getFieldValue("auto_router_name"),onClose:()=>{o(!1),c(!1)},onTestComplete:()=>c(!1)},m)})]})};let ls=(0,i.n)("guardrails"),la=()=>{let{accessToken:e,userId:l,userRole:t}=(0,n.Z)();return(0,r.a)({queryKey:ls.list({}),queryFn:async()=>(await (0,a.getGuardrailsList)(e)).guardrails.map(e=>e.guardrail_name),enabled:!!(e&&l&&t)})},lr=(0,i.n)("tags"),li=()=>{let{accessToken:e,userId:l,userRole:t}=(0,n.Z)();return(0,r.a)({queryKey:lr.list({}),queryFn:async()=>await (0,a.tagListCall)(e),enabled:!!(e&&l&&t)})};var ln=t(59341),lo=t(51653),ld=t(84376),lc=t(63709),lm=t(26210),lu=t(34766),lh=t(45246),lx=t(24199);let{Text:lp}=Q.default;var lg=e=>{let{form:l,showCacheControl:t,onCacheControlChange:a}=e,r=e=>{let t=l.getFieldValue("litellm_extra_params");try{let s=t?JSON.parse(t):{};e.length>0?s.cache_control_injection_points=e:delete s.cache_control_injection_points,Object.keys(s).length>0?l.setFieldValue("litellm_extra_params",JSON.stringify(s,null,2)):l.setFieldValue("litellm_extra_params","")}catch(e){console.error("Error updating cache control points:",e)}};return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(eg.Z.Item,{label:"Cache Control Injection Points",name:"cache_control",valuePropName:"checked",className:"mb-4",tooltip:"Tell litellm where to inject cache control checkpoints. You can specify either by role (to apply to all messages of that role) or by specific message index.",children:(0,s.jsx)(lc.Z,{onChange:a,className:"bg-gray-600"})}),t&&(0,s.jsxs)("div",{className:"ml-6 pl-4 border-l-2 border-gray-200",children:[(0,s.jsx)(lp,{className:"text-sm text-gray-500 block mb-4",children:"Providers like Anthropic, Bedrock API require users to specify where to inject cache control checkpoints, litellm can automatically add them for you as a cost saving feature."}),(0,s.jsx)(eg.Z.List,{name:"cache_control_injection_points",initialValue:[{location:"message"}],children:(e,t)=>{let{add:a,remove:i}=t;return(0,s.jsxs)(s.Fragment,{children:[e.map((t,a)=>(0,s.jsxs)("div",{className:"flex items-center mb-4 gap-4",children:[(0,s.jsx)(eg.Z.Item,{...t,label:"Type",name:[t.name,"location"],initialValue:"message",className:"mb-0",style:{width:"180px"},children:(0,s.jsx)(ev.default,{disabled:!0,options:[{value:"message",label:"Message"}]})}),(0,s.jsx)(eg.Z.Item,{...t,label:"Role",name:[t.name,"role"],className:"mb-0",style:{width:"180px"},tooltip:"LiteLLM will mark all messages of this role as cacheable",children:(0,s.jsx)(ev.default,{placeholder:"Select a role",allowClear:!0,options:[{value:"user",label:"User"},{value:"system",label:"System"},{value:"assistant",label:"Assistant"}],onChange:()=>{r(l.getFieldValue("cache_control_points"))}})}),(0,s.jsx)(eg.Z.Item,{...t,label:"Index",name:[t.name,"index"],className:"mb-0",style:{width:"180px"},tooltip:"(Optional) If set litellm will mark the message at this index as cacheable",children:(0,s.jsx)(lx.Z,{type:"number",placeholder:"Optional",step:1,onChange:()=>{r(l.getFieldValue("cache_control_points"))}})}),e.length>1&&(0,s.jsx)(lh.Z,{className:"text-red-500 cursor-pointer text-lg ml-12",onClick:()=>{i(t.name),setTimeout(()=>{r(l.getFieldValue("cache_control_points"))},0)}})]},t.key)),(0,s.jsx)(eg.Z.Item,{children:(0,s.jsxs)("button",{type:"button",className:"flex items-center justify-center w-full border border-dashed border-gray-300 py-2 px-4 text-gray-600 hover:text-blue-600 hover:border-blue-300 transition-all rounded",onClick:()=>a(),children:[(0,s.jsx)(e4.Z,{className:"mr-2"}),"Add Injection Point"]})})]})}})]})]})},lf=t(9309);let{Link:lj}=Q.default;var lv=e=>{let{showAdvancedSettings:l,setShowAdvancedSettings:t,teams:a,guardrailsList:r,tagsList:i}=e,[n]=eg.Z.useForm(),[o,d]=f.useState(!1),[c,m]=f.useState("per_token"),[u,h]=f.useState(!1),x=(e,l)=>l&&(isNaN(Number(l))||0>Number(l))?Promise.reject("Please enter a valid positive number"):Promise.resolve();return(0,s.jsx)(s.Fragment,{children:(0,s.jsxs)(lm.UQ,{className:"mt-2 mb-4",children:[(0,s.jsx)(lm._m,{children:(0,s.jsx)("b",{children:"Advanced Settings"})}),(0,s.jsx)(lm.X1,{children:(0,s.jsxs)("div",{className:"bg-white rounded-lg",children:[(0,s.jsx)(eg.Z.Item,{label:"Custom Pricing",name:"custom_pricing",valuePropName:"checked",className:"mb-4",children:(0,s.jsx)(lc.Z,{onChange:e=>{d(e),e||n.setFieldsValue({input_cost_per_token:void 0,output_cost_per_token:void 0,input_cost_per_second:void 0})},className:"bg-gray-600"})}),(0,s.jsx)(eg.Z.Item,{label:(0,s.jsxs)("span",{children:["Guardrails"," ",(0,s.jsx)(M.Z,{title:"Apply safety guardrails to this key to filter content or enforce policies",children:(0,s.jsx)("a",{href:"https://docs.litellm.ai/docs/proxy/guardrails/quick_start",target:"_blank",rel:"noopener noreferrer",onClick:e=>e.stopPropagation(),children:(0,s.jsx)(R.Z,{style:{marginLeft:"4px"}})})})]}),name:"guardrails",className:"mt-4",help:"Select existing guardrails. Go to 'Guardrails' tab to create new guardrails.",children:(0,s.jsx)(ev.default,{mode:"tags",style:{width:"100%"},placeholder:"Select or enter guardrails",options:r.map(e=>({value:e,label:e}))})}),(0,s.jsx)(eg.Z.Item,{label:"Tags",name:"tags",className:"mb-4",children:(0,s.jsx)(ev.default,{mode:"tags",style:{width:"100%"},placeholder:"Select or enter tags",options:Object.values(i).map(e=>({value:e.name,label:e.name,title:e.description||e.name}))})}),o&&(0,s.jsxs)("div",{className:"ml-6 pl-4 border-l-2 border-gray-200",children:[(0,s.jsx)(eg.Z.Item,{label:"Pricing Model",name:"pricing_model",className:"mb-4",children:(0,s.jsx)(ev.default,{defaultValue:"per_token",onChange:e=>m(e),options:[{value:"per_token",label:"Per Million Tokens"},{value:"per_second",label:"Per Second"}]})}),"per_token"===c?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(eg.Z.Item,{label:"Input Cost (per 1M tokens)",name:"input_cost_per_token",rules:[{validator:x}],className:"mb-4",children:(0,s.jsx)(lm.oi,{})}),(0,s.jsx)(eg.Z.Item,{label:"Output Cost (per 1M tokens)",name:"output_cost_per_token",rules:[{validator:x}],className:"mb-4",children:(0,s.jsx)(lm.oi,{})})]}):(0,s.jsx)(eg.Z.Item,{label:"Cost Per Second",name:"input_cost_per_second",rules:[{validator:x}],className:"mb-4",children:(0,s.jsx)(lm.oi,{})})]}),(0,s.jsx)(eg.Z.Item,{label:"Use in pass through routes",name:"use_in_pass_through",valuePropName:"checked",className:"mb-4 mt-4",tooltip:(0,s.jsxs)("span",{children:["Allow using these credentials in pass through routes."," ",(0,s.jsx)(lj,{href:"https://docs.litellm.ai/docs/pass_through/vertex_ai",target:"_blank",children:"Learn more"})]}),children:(0,s.jsx)(lc.Z,{onChange:e=>{let l=n.getFieldValue("litellm_extra_params");try{let t=l?JSON.parse(l):{};e?t.use_in_pass_through=!0:delete t.use_in_pass_through,Object.keys(t).length>0?n.setFieldValue("litellm_extra_params",JSON.stringify(t,null,2)):n.setFieldValue("litellm_extra_params","")}catch(l){e?n.setFieldValue("litellm_extra_params",JSON.stringify({use_in_pass_through:!0},null,2)):n.setFieldValue("litellm_extra_params","")}},className:"bg-gray-600"})}),(0,s.jsx)(lg,{form:n,showCacheControl:u,onCacheControlChange:e=>{if(h(e),!e){let e=n.getFieldValue("litellm_extra_params");try{let l=e?JSON.parse(e):{};delete l.cache_control_injection_points,Object.keys(l).length>0?n.setFieldValue("litellm_extra_params",JSON.stringify(l,null,2)):n.setFieldValue("litellm_extra_params","")}catch(e){n.setFieldValue("litellm_extra_params","")}}}}),(0,s.jsx)(eg.Z.Item,{label:"LiteLLM Params",name:"litellm_extra_params",tooltip:"Optional litellm params used for making a litellm.completion() call.",className:"mb-4 mt-4",rules:[{validator:lf.Ac}],children:(0,s.jsx)(lu.Z,{rows:4,placeholder:'{ "rpm": 100, "timeout": 0, "stream_timeout": 0 }'})}),(0,s.jsxs)(ew.Z,{className:"mb-4",children:[(0,s.jsx)(eZ.Z,{span:10}),(0,s.jsx)(eZ.Z,{span:10,children:(0,s.jsxs)(lm.xv,{className:"text-gray-600 text-sm",children:["Pass JSON of litellm supported params"," ",(0,s.jsx)(lj,{href:"https://docs.litellm.ai/docs/completion/input",target:"_blank",children:"litellm.completion() call"})]})})]}),(0,s.jsx)(eg.Z.Item,{label:"Model Info",name:"model_info_params",tooltip:"Optional model info params. Returned when calling `/model/info` endpoint.",className:"mb-0",rules:[{validator:lf.Ac}],children:(0,s.jsx)(lu.Z,{rows:4,placeholder:'{ "mode": "chat" }'})})]})})]})})},l_=t(56609),lb=t(67187);let ly=e=>{let{content:l,children:t,width:a="auto",className:r=""}=e,[i,n]=(0,f.useState)(!1),[o,d]=(0,f.useState)("top"),c=(0,f.useRef)(null),m=()=>{if(c.current){let e=c.current.getBoundingClientRect(),l=e.top,t=window.innerHeight-e.bottom;l<300&&t>300?d("bottom"):d("top")}};return(0,s.jsxs)("div",{className:"relative inline-block",ref:c,children:[t||(0,s.jsx)(lb.Z,{className:"ml-1 text-gray-500 cursor-help",onMouseEnter:()=>{m(),n(!0)},onMouseLeave:()=>n(!1)}),i&&(0,s.jsxs)("div",{className:"absolute left-1/2 -translate-x-1/2 z-50 bg-black/90 text-white p-2 rounded-md text-sm font-normal shadow-lg ".concat(r),style:{["top"===o?"bottom":"top"]:"100%",width:a,marginBottom:"top"===o?"8px":"0",marginTop:"bottom"===o?"8px":"0"},children:[l,(0,s.jsx)("div",{className:"absolute left-1/2 -translate-x-1/2 w-0 h-0",style:{top:"top"===o?"100%":"auto",bottom:"bottom"===o?"100%":"auto",borderTop:"top"===o?"6px solid rgba(0, 0, 0, 0.9)":"6px solid transparent",borderBottom:"bottom"===o?"6px solid rgba(0, 0, 0, 0.9)":"6px solid transparent",borderLeft:"6px solid transparent",borderRight:"6px solid transparent"}})]})]})};var lN=()=>{let e=eg.Z.useFormInstance(),[l,t]=(0,f.useState)(0),a=eg.Z.useWatch("model",e)||[],r=Array.isArray(a)?a:[a],i=eg.Z.useWatch("custom_model_name",e),n=!r.includes("all-wildcard"),o=eg.Z.useWatch("custom_llm_provider",e);if((0,f.useEffect)(()=>{if(i&&r.includes("custom")){let l=(e.getFieldValue("model_mappings")||[]).map(e=>"custom"===e.public_name||"custom"===e.litellm_model?o===L.Cl.Azure?{public_name:i,litellm_model:"azure/".concat(i)}:{public_name:i,litellm_model:i}:e);e.setFieldValue("model_mappings",l),t(e=>e+1)}},[i,r,o,e]),(0,f.useEffect)(()=>{if(r.length>0&&!r.includes("all-wildcard")){let l=e.getFieldValue("model_mappings")||[];if(l.length!==r.length||!r.every(e=>l.some(l=>"custom"===e?"custom"===l.litellm_model||l.litellm_model===i:o===L.Cl.Azure?l.litellm_model==="azure/".concat(e):l.litellm_model===e))){let l=r.map(e=>"custom"===e&&i?o===L.Cl.Azure?{public_name:i,litellm_model:"azure/".concat(i)}:{public_name:i,litellm_model:i}:o===L.Cl.Azure?{public_name:e,litellm_model:"azure/".concat(e)}:{public_name:e,litellm_model:e});e.setFieldValue("model_mappings",l),t(e=>e+1)}}},[r,i,o,e]),!n)return null;let d=(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("div",{className:"mb-2 font-normal",children:"The name you specify in your API calls to LiteLLM Proxy"}),(0,s.jsxs)("div",{className:"mb-2 font-normal",children:[(0,s.jsx)("strong",{children:"Example:"})," If you name your public model"," ",(0,s.jsx)("code",{className:"bg-gray-700 px-1 py-0.5 rounded text-xs",children:"example-name"}),", and choose"," ",(0,s.jsx)("code",{className:"bg-gray-700 px-1 py-0.5 rounded text-xs",children:"openai/qwen-plus-latest"})," as the LiteLLM model"]}),(0,s.jsxs)("div",{className:"mb-2 font-normal",children:[(0,s.jsx)("strong",{children:"Usage:"})," You make an API call to the LiteLLM proxy with"," ",(0,s.jsx)("code",{className:"bg-gray-700 px-1 py-0.5 rounded text-xs",children:'model = "example-name"'})]}),(0,s.jsxs)("div",{className:"font-normal",children:[(0,s.jsx)("strong",{children:"Result:"})," LiteLLM sends"," ",(0,s.jsx)("code",{className:"bg-gray-700 px-1 py-0.5 rounded text-xs",children:"qwen-plus-latest"})," to the provider"]})]}),c=(0,s.jsx)("div",{children:"The model name LiteLLM will send to the LLM API"}),m=[{title:(0,s.jsxs)("span",{className:"flex items-center",children:["Public Model Name",(0,s.jsx)(ly,{content:d,width:"500px"})]}),dataIndex:"public_name",key:"public_name",render:(l,t,a)=>(0,s.jsx)(ej.o,{value:l,onChange:l=>{let t=l.target.value,s=[...e.getFieldValue("model_mappings")],r=o===L.Cl.Anthropic,i=t.endsWith("-1m"),n=e.getFieldValue("litellm_extra_params"),d=!n||""===n.trim(),c=t;if(r&&i&&d){let l=JSON.stringify({extra_headers:{"anthropic-beta":"context-1m-2025-08-07"}},null,2);e.setFieldValue("litellm_extra_params",l),c=t.slice(0,-3)}s[a].public_name=c,e.setFieldValue("model_mappings",s)}})},{title:(0,s.jsxs)("span",{className:"flex items-center",children:["LiteLLM Model Name",(0,s.jsx)(ly,{content:c,width:"360px"})]}),dataIndex:"litellm_model",key:"litellm_model"}];return(0,s.jsx)(s.Fragment,{children:(0,s.jsx)(eg.Z.Item,{label:"Model Mappings",name:"model_mappings",tooltip:"Map public model names to LiteLLM model names for load balancing",labelCol:{span:10},wrapperCol:{span:16},labelAlign:"left",rules:[{required:!0,validator:async(e,l)=>{if(!l||0===l.length)throw Error("At least one model mapping is required");if(l.filter(e=>!e.public_name||""===e.public_name.trim()).length>0)throw Error("All model mappings must have valid public names")}}],children:(0,s.jsx)(l_.Z,{dataSource:e.getFieldValue("model_mappings"),columns:m,pagination:!1,size:"small"},l)})})},lw=e=>{let{selectedProvider:l,providerModels:t,getPlaceholder:a}=e,r=eg.Z.useFormInstance(),i=e=>{let t=e.target.value,s=(r.getFieldValue("model_mappings")||[]).map(e=>"custom"===e.public_name||"custom"===e.litellm_model?l===L.Cl.Azure?{public_name:t,litellm_model:"azure/".concat(t)}:{public_name:t,litellm_model:t}:e);r.setFieldsValue({model_mappings:s})};return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)(eg.Z.Item,{label:"LiteLLM Model Name(s)",tooltip:"The model name LiteLLM will send to the LLM API",className:"mb-0",children:[(0,s.jsx)(eg.Z.Item,{name:"model",rules:[{required:!0,message:"Please enter ".concat(l===L.Cl.Azure?"a deployment name":"at least one model",".")}],noStyle:!0,children:l===L.Cl.Azure||l===L.Cl.OpenAI_Compatible||l===L.Cl.Ollama?(0,s.jsx)(s.Fragment,{children:(0,s.jsx)(eN.o,{placeholder:a(l),onChange:l===L.Cl.Azure?e=>{let l=e.target.value,t=l?[{public_name:l,litellm_model:"azure/".concat(l)}]:[];r.setFieldsValue({model:l,model_mappings:t})}:void 0})}):t.length>0?(0,s.jsx)(ev.default,{mode:"multiple",allowClear:!0,showSearch:!0,placeholder:"Select models",onChange:e=>{let t=Array.isArray(e)?e:[e];if(t.includes("all-wildcard"))r.setFieldsValue({model_name:void 0,model_mappings:[]});else if(JSON.stringify(r.getFieldValue("model"))!==JSON.stringify(t)){let e=t.map(e=>l===L.Cl.Azure?{public_name:e,litellm_model:"azure/".concat(e)}:{public_name:e,litellm_model:e});r.setFieldsValue({model:t,model_mappings:e})}},optionFilterProp:"children",filterOption:(e,l)=>{var t;return(null!==(t=null==l?void 0:l.label)&&void 0!==t?t:"").toLowerCase().includes(e.toLowerCase())},options:[{label:"Custom Model Name (Enter below)",value:"custom"},{label:"All ".concat(l," Models (Wildcard)"),value:"all-wildcard"},...t.map(e=>({label:e,value:e}))],style:{width:"100%"}}):(0,s.jsx)(eN.o,{placeholder:a(l)})}),(0,s.jsx)(eg.Z.Item,{noStyle:!0,shouldUpdate:(e,l)=>e.model!==l.model,children:e=>{let{getFieldValue:t}=e,a=t("model")||[];return(Array.isArray(a)?a:[a]).includes("custom")&&(0,s.jsx)(eg.Z.Item,{name:"custom_model_name",rules:[{required:!0,message:"Please enter a custom model name."}],className:"mt-2",children:(0,s.jsx)(eN.o,{placeholder:l===L.Cl.Azure?"Enter Azure deployment name":"Enter custom model name",onChange:i})})}})]}),(0,s.jsxs)(ew.Z,{children:[(0,s.jsx)(eZ.Z,{span:10}),(0,s.jsx)(eZ.Z,{span:14,children:(0,s.jsx)(eN.x,{className:"mb-3 mt-1",children:l===L.Cl.Azure?"Your deployment name will be saved as the public model name, and LiteLLM will use 'azure/deployment-name' internally":"The model name LiteLLM will send to the LLM API"})})]})]})};let lZ=[{value:"chat",label:"Chat - /chat/completions"},{value:"completion",label:"Completion - /completions"},{value:"embedding",label:"Embedding - /embeddings"},{value:"audio_speech",label:"Audio Speech - /audio/speech"},{value:"audio_transcription",label:"Audio Transcription - /audio/transcriptions"},{value:"image_generation",label:"Image Generation - /images/generations"},{value:"video_generation",label:"Video Generation - /videos"},{value:"rerank",label:"Rerank - /rerank"},{value:"realtime",label:"Realtime - /realtime"},{value:"batch",label:"Batch - /batch"},{value:"ocr",label:"OCR - /ocr"}],{Title:lC,Link:lk}=Q.default;var lS=e=>{let{form:l,handleOk:t,selectedProvider:r,setSelectedProvider:i,providerModels:o,setProviderModelsFn:d,getPlaceholder:c,uploadProps:m,showAdvancedSettings:u,setShowAdvancedSettings:h,teams:x,credentials:p}=e,[g,j]=(0,f.useState)("chat"),[v,b]=(0,f.useState)(!1),[y,N]=(0,f.useState)(!1),[w,Z]=(0,f.useState)(""),{accessToken:C,userRole:k,premiumUser:S,userId:A}=(0,n.Z)(),{data:E,isLoading:P,error:I}=eb(),{data:T,isLoading:R,error:O}=la(),{data:V,isLoading:q,error:z}=li(),B=async()=>{N(!0),Z("test-".concat(Date.now())),b(!0)},[G,U]=(0,f.useState)(!1),[H,K]=(0,f.useState)([]),[J,W]=(0,f.useState)(null);(0,f.useEffect)(()=>{(async()=>{K((await (0,a.modelAvailableCall)(C,"","",!1,null,!0,!0)).data.map(e=>e.id))})()},[C]);let Y=(0,f.useMemo)(()=>E?[...E].sort((e,l)=>e.provider_display_name.localeCompare(l.provider_display_name)):[],[E]),$=I?I instanceof Error?I.message:"Failed to load providers":null,X=eR.ZL.includes(k),ee=(0,eR.yV)(x,A);return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(lC,{level:2,children:"Add Model"}),(0,s.jsx)(et.Z,{children:(0,s.jsx)(eg.Z,{form:l,onFinish:async e=>{console.log("\uD83D\uDD25 Form onFinish triggered with values:",e),await t().then(()=>{W(null)})},onFinishFailed:e=>{console.log("\uD83D\uDCA5 Form onFinishFailed triggered:",e)},labelCol:{span:10},wrapperCol:{span:16},labelAlign:"left",children:(0,s.jsxs)(s.Fragment,{children:[ee&&!X&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(eg.Z.Item,{label:"Select Team",name:"team_id",rules:[{required:!0,message:"Please select a team to continue"}],tooltip:"Select the team for which you want to add this model",children:(0,s.jsx)(ld.Z,{teams:x,onChange:e=>{W(e)}})}),!J&&(0,s.jsx)(lo.Z,{message:"Team Selection Required",description:"As a team admin, you need to select your team first before adding models.",type:"info",showIcon:!0,className:"mb-4"})]}),(X||ee&&J)&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(eg.Z.Item,{rules:[{required:!0,message:"Required"}],label:"Provider:",name:"custom_llm_provider",tooltip:"E.g. OpenAI, Azure OpenAI, Anthropic, Bedrock, etc.",labelCol:{span:10},labelAlign:"left",children:(0,s.jsxs)(ev.default,{virtual:!1,showSearch:!0,loading:P,placeholder:P?"Loading providers...":"Select a provider",optionFilterProp:"data-label",onChange:e=>{i(e),d(e),l.setFieldsValue({custom_llm_provider:e}),l.setFieldsValue({model:[],model_name:void 0})},children:[$&&0===Y.length&&(0,s.jsx)(ev.default.Option,{value:"",children:$},"__error"),Y.map(e=>{let l=e.provider_display_name,t=e.provider;return L.cd[l],(0,s.jsx)(ev.default.Option,{value:t,"data-label":l,children:(0,s.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,s.jsx)(F,{provider:t,className:"w-5 h-5"}),(0,s.jsx)("span",{children:l})]})},t)})]})}),(0,s.jsx)(lw,{selectedProvider:r,providerModels:o,getPlaceholder:c}),(0,s.jsx)(lN,{}),(0,s.jsx)(eg.Z.Item,{label:"Mode",name:"mode",className:"mb-1",children:(0,s.jsx)(ev.default,{style:{width:"100%"},value:g,onChange:e=>j(e),options:lZ})}),(0,s.jsxs)(ew.Z,{children:[(0,s.jsx)(eZ.Z,{span:10}),(0,s.jsx)(eZ.Z,{span:10,children:(0,s.jsxs)(D.Z,{className:"mb-5 mt-1",children:[(0,s.jsx)("strong",{children:"Optional"})," - LiteLLM endpoint to use when health checking this model"," ",(0,s.jsx)(lk,{href:"https://docs.litellm.ai/docs/proxy/health#health",target:"_blank",children:"Learn more"})]})})]}),(0,s.jsx)("div",{className:"mb-4",children:(0,s.jsx)(Q.default.Text,{className:"text-sm text-gray-500 mb-2",children:"Either select existing credentials OR enter new provider credentials below"})}),(0,s.jsx)(eg.Z.Item,{label:"Existing Credentials",name:"litellm_credential_name",initialValue:null,children:(0,s.jsx)(ev.default,{showSearch:!0,placeholder:"Select or search for existing credentials",optionFilterProp:"children",filterOption:(e,l)=>{var t;return(null!==(t=null==l?void 0:l.label)&&void 0!==t?t:"").toLowerCase().includes(e.toLowerCase())},options:[{value:null,label:"None"},...p.map(e=>({value:e.credential_name,label:e.credential_name}))],allowClear:!0})}),(0,s.jsx)(eg.Z.Item,{noStyle:!0,shouldUpdate:(e,l)=>e.litellm_credential_name!==l.litellm_credential_name||e.provider!==l.provider,children:e=>{let{getFieldValue:l}=e,t=l("litellm_credential_name");return(console.log("\uD83D\uDD11 Credential Name Changed:",t),t)?null:(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("div",{className:"flex items-center my-4",children:[(0,s.jsx)("div",{className:"flex-grow border-t border-gray-200"}),(0,s.jsx)("span",{className:"px-4 text-gray-500 text-sm",children:"OR"}),(0,s.jsx)("div",{className:"flex-grow border-t border-gray-200"})]}),(0,s.jsx)(eP,{selectedProvider:r,uploadProps:m})]})}}),(0,s.jsxs)("div",{className:"flex items-center my-4",children:[(0,s.jsx)("div",{className:"flex-grow border-t border-gray-200"}),(0,s.jsx)("span",{className:"px-4 text-gray-500 text-sm",children:"Additional Model Info Settings"}),(0,s.jsx)("div",{className:"flex-grow border-t border-gray-200"})]}),(X||!ee)&&(0,s.jsx)(eg.Z.Item,{label:"Team-BYOK Model",tooltip:"Only use this model + credential combination for this team. Useful when teams want to onboard their own OpenAI keys.",className:"mb-4",children:(0,s.jsx)(M.Z,{title:S?"":"This is an enterprise-only feature. Upgrade to premium to restrict model+credential combinations to a specific team.",placement:"top",children:(0,s.jsx)(ln.Z,{checked:G,onChange:e=>{U(e),e||l.setFieldValue("team_id",void 0)},disabled:!S})})}),G&&(X||!ee)&&(0,s.jsx)(eg.Z.Item,{label:"Select Team",name:"team_id",className:"mb-4",tooltip:"Only keys for this team will be able to call this model.",rules:[{required:G&&!X,message:"Please select a team."}],children:(0,s.jsx)(ld.Z,{teams:x,disabled:!S})}),X&&(0,s.jsx)(s.Fragment,{children:(0,s.jsx)(eg.Z.Item,{label:"Model Access Group",name:"model_access_group",className:"mb-4",tooltip:"Use model access groups to give users access to select models, and add new ones to the group over time.",children:(0,s.jsx)(ev.default,{mode:"tags",showSearch:!0,placeholder:"Select existing groups or type to create new ones",optionFilterProp:"children",tokenSeparators:[","],options:H.map(e=>({value:e,label:e})),maxTagCount:"responsive",allowClear:!0})})}),(0,s.jsx)(lv,{showAdvancedSettings:u,setShowAdvancedSettings:h,teams:x,guardrailsList:T||[],tagsList:V||{}})]}),(0,s.jsxs)("div",{className:"flex justify-between items-center mb-4",children:[(0,s.jsx)(M.Z,{title:"Get help on our github",children:(0,s.jsx)(Q.default.Link,{href:"https://github.com/BerriAI/litellm/issues",children:"Need Help?"})}),(0,s.jsxs)("div",{className:"space-x-2",children:[(0,s.jsx)(_.ZP,{onClick:B,loading:y,children:"Test Connect"}),(0,s.jsx)(_.ZP,{htmlType:"submit",children:"Add Model"})]})]})]})})}),(0,s.jsx)(ea.Z,{title:"Connection Test Results",open:v,onCancel:()=>{b(!1),N(!1)},footer:[(0,s.jsx)(_.ZP,{onClick:()=>{b(!1),N(!1)},children:"Close"},"close")],width:700,children:v&&(0,s.jsx)(eQ,{formValues:l.getFieldsValue(),accessToken:C,testMode:g,modelName:l.getFieldValue("model_name")||l.getFieldValue("model"),onClose:()=>{b(!1),N(!1)},onTestComplete:()=>N(!1)},w)})]})},lA=e=>{let{form:l,handleOk:t,selectedProvider:a,setSelectedProvider:r,providerModels:i,setProviderModelsFn:n,getPlaceholder:o,uploadProps:d,showAdvancedSettings:c,setShowAdvancedSettings:m,teams:u,credentials:h,accessToken:x,userRole:p}=e,[g]=eg.Z.useForm();return(0,s.jsx)(s.Fragment,{children:(0,s.jsxs)(eH.v0,{className:"w-full",children:[(0,s.jsxs)(eH.td,{className:"mb-4",children:[(0,s.jsx)(eH.OK,{children:"Add Model"}),(0,s.jsx)(eH.OK,{children:"Add Auto Router"})]}),(0,s.jsxs)(eH.nP,{children:[(0,s.jsx)(eH.x4,{children:(0,s.jsx)(lS,{form:l,handleOk:t,selectedProvider:a,setSelectedProvider:r,providerModels:i,setProviderModelsFn:n,getPlaceholder:o,uploadProps:d,showAdvancedSettings:c,setShowAdvancedSettings:m,teams:u,credentials:h})}),(0,s.jsx)(eH.x4,{children:(0,s.jsx)(lt,{form:g,handleOk:()=>{g.validateFields().then(e=>{e0(e,x,g,t)}).catch(e=>{console.error("Validation failed:",e)})},accessToken:x,userRole:p})})]})]})})},lE=t(8048),lP=t(4156),lM=t(15731),lL=t(91126);let lF=(e,l,t,a,r,i,n,o,d,c,m)=>[{header:()=>(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)(lP.Z,{checked:t,indeterminate:l.length>0&&!t,onChange:e=>r(e.target.checked),onClick:e=>e.stopPropagation()}),(0,s.jsx)("span",{children:"Model ID"})]}),accessorKey:"model_info.id",enableSorting:!0,sortingFn:"alphanumeric",cell:e=>{let{row:t}=e,r=t.original,i=r.model_name,n=l.includes(i);return(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)(lP.Z,{checked:n,onChange:e=>a(i,e.target.checked),onClick:e=>e.stopPropagation()}),(0,s.jsx)(M.Z,{title:r.model_info.id,children:(0,s.jsx)("div",{className:"font-mono text-blue-500 bg-blue-50 hover:bg-blue-100 text-xs font-normal px-2 py-0.5 text-left w-full truncate whitespace-nowrap cursor-pointer max-w-[15ch]",onClick:()=>m&&m(r.model_info.id),children:r.model_info.id})})]})}},{header:"Model Name",accessorKey:"model_name",enableSorting:!0,sortingFn:"alphanumeric",cell:e=>{let{row:l}=e,t=l.original,a=o(t)||t.model_name;return(0,s.jsx)("div",{className:"font-medium text-sm",children:(0,s.jsx)(M.Z,{title:a,children:(0,s.jsx)("div",{className:"truncate max-w-[200px]",children:a})})})}},{header:"Health Status",accessorKey:"health_status",enableSorting:!0,sortingFn:(e,l,t)=>{var s,a;let r=e.getValue("health_status")||"unknown",i=l.getValue("health_status")||"unknown",n={healthy:0,checking:1,unknown:2,unhealthy:3};return(null!==(s=n[r])&&void 0!==s?s:4)-(null!==(a=n[i])&&void 0!==a?a:4)},cell:l=>{var t;let{row:a}=l,r=a.original,i={status:r.health_status,loading:r.health_loading,error:r.health_error};if(i.loading)return(0,s.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,s.jsxs)("div",{className:"flex space-x-1",children:[(0,s.jsx)("div",{className:"w-2 h-2 bg-indigo-500 rounded-full animate-pulse"}),(0,s.jsx)("div",{className:"w-2 h-2 bg-indigo-500 rounded-full animate-pulse",style:{animationDelay:"0.2s"}}),(0,s.jsx)("div",{className:"w-2 h-2 bg-indigo-500 rounded-full animate-pulse",style:{animationDelay:"0.4s"}})]}),(0,s.jsx)(e3.x,{className:"text-gray-600 text-sm",children:"Checking..."})]});let o=r.model_name,d="healthy"===i.status&&(null===(t=e[o])||void 0===t?void 0:t.successResponse);return(0,s.jsxs)("div",{className:"flex items-center space-x-2",children:[n(i.status),d&&c&&(0,s.jsx)(M.Z,{title:"View response details",placement:"top",children:(0,s.jsx)("button",{onClick:()=>{var l;return c(o,null===(l=e[o])||void 0===l?void 0:l.successResponse)},className:"p-1 text-green-600 hover:text-green-800 hover:bg-green-50 rounded cursor-pointer transition-colors",children:(0,s.jsx)(lM.Z,{className:"h-4 w-4"})})})]})}},{header:"Error Details",accessorKey:"health_error",enableSorting:!1,cell:l=>{let{row:t}=l,a=t.original.model_name,r=e[a];if(!(null==r?void 0:r.error))return(0,s.jsx)(e3.x,{className:"text-gray-400 text-sm",children:"No errors"});let i=r.error,n=r.fullError||r.error;return(0,s.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,s.jsx)("div",{className:"max-w-[200px]",children:(0,s.jsx)(M.Z,{title:i,placement:"top",children:(0,s.jsx)(e3.x,{className:"text-red-600 text-sm truncate",children:i})})}),d&&n!==i&&(0,s.jsx)(M.Z,{title:"View full error details",placement:"top",children:(0,s.jsx)("button",{onClick:()=>d(a,i,n),className:"p-1 text-red-600 hover:text-red-800 hover:bg-red-50 rounded cursor-pointer transition-colors",children:(0,s.jsx)(lM.Z,{className:"h-4 w-4"})})})]})}},{header:"Last Check",accessorKey:"last_check",enableSorting:!0,sortingFn:(e,l,t)=>{let s=e.getValue("last_check")||"Never checked",a=l.getValue("last_check")||"Never checked";if("Never checked"===s&&"Never checked"===a)return 0;if("Never checked"===s)return 1;if("Never checked"===a)return -1;if("Check in progress..."===s&&"Check in progress..."===a)return 0;if("Check in progress..."===s)return -1;if("Check in progress..."===a)return 1;let r=new Date(s),i=new Date(a);return isNaN(r.getTime())&&isNaN(i.getTime())?0:isNaN(r.getTime())?1:isNaN(i.getTime())?-1:i.getTime()-r.getTime()},cell:e=>{let{row:l}=e,t=l.original;return(0,s.jsx)(e3.x,{className:"text-gray-600 text-sm",children:t.health_loading?"Check in progress...":t.last_check})}},{header:"Last Success",accessorKey:"last_success",enableSorting:!0,sortingFn:(e,l,t)=>{let s=e.getValue("last_success")||"Never succeeded",a=l.getValue("last_success")||"Never succeeded";if("Never succeeded"===s&&"Never succeeded"===a)return 0;if("Never succeeded"===s)return 1;if("Never succeeded"===a)return -1;if("None"===s&&"None"===a)return 0;if("None"===s)return 1;if("None"===a)return -1;let r=new Date(s),i=new Date(a);return isNaN(r.getTime())&&isNaN(i.getTime())?0:isNaN(r.getTime())?1:isNaN(i.getTime())?-1:i.getTime()-r.getTime()},cell:l=>{let{row:t}=l,a=e[t.original.model_name],r=(null==a?void 0:a.lastSuccess)||"None";return(0,s.jsx)(e3.x,{className:"text-gray-600 text-sm",children:r})}},{header:"Actions",id:"actions",cell:e=>{let{row:l}=e,t=l.original,a=t.model_name,r=t.health_status&&"none"!==t.health_status,n=t.health_loading?"Checking...":r?"Re-run Health Check":"Run Health Check";return(0,s.jsx)(M.Z,{title:n,placement:"top",children:(0,s.jsx)("button",{className:"p-2 rounded-md transition-colors ".concat(t.health_loading?"text-gray-400 cursor-not-allowed bg-gray-100":"text-indigo-600 hover:text-indigo-700 hover:bg-indigo-50"),onClick:()=>{t.health_loading||i(a)},disabled:t.health_loading,children:t.health_loading?(0,s.jsxs)("div",{className:"flex space-x-1",children:[(0,s.jsx)("div",{className:"w-1 h-1 bg-gray-400 rounded-full animate-pulse"}),(0,s.jsx)("div",{className:"w-1 h-1 bg-gray-400 rounded-full animate-pulse",style:{animationDelay:"0.2s"}}),(0,s.jsx)("div",{className:"w-1 h-1 bg-gray-400 rounded-full animate-pulse",style:{animationDelay:"0.4s"}})]}):r?(0,s.jsx)(eO.Z,{className:"h-4 w-4"}):(0,s.jsx)(lL.Z,{className:"h-4 w-4"})})})},enableSorting:!1}],lI=[{pattern:/Missing .* API Key/i,replacement:"Missing API Key"},{pattern:/Connection timeout/i,replacement:"Connection timeout"},{pattern:/Network.*not.*ok/i,replacement:"Network connection failed"},{pattern:/403.*Forbidden/i,replacement:"Access forbidden - check API key permissions"},{pattern:/401.*Unauthorized/i,replacement:"Unauthorized - invalid API key"},{pattern:/429.*rate limit/i,replacement:"Rate limit exceeded"},{pattern:/500.*Internal Server Error/i,replacement:"Provider internal server error"},{pattern:/litellm\.AuthenticationError/i,replacement:"Authentication failed"},{pattern:/litellm\.RateLimitError/i,replacement:"Rate limit exceeded"},{pattern:/litellm\.APIError/i,replacement:"API error"}];var lT=e=>{let{accessToken:l,modelData:t,all_models_on_proxy:r,getDisplayModelName:i,setSelectedModelId:n}=e,[o,d]=(0,f.useState)({}),[c,m]=(0,f.useState)([]),[u,h]=(0,f.useState)(!1),[x,p]=(0,f.useState)(!1),[g,j]=(0,f.useState)(null),[v,b]=(0,f.useState)(!1),[y,N]=(0,f.useState)(null);(0,f.useRef)(null),(0,f.useEffect)(()=>{l&&(null==t?void 0:t.data)&&(async()=>{let e={};t.data.forEach(l=>{e[l.model_name]={status:"none",lastCheck:"None",lastSuccess:"None",loading:!1,error:void 0,fullError:void 0,successResponse:void 0}});try{let s=await (0,a.latestHealthChecksCall)(l);s&&s.latest_health_checks&&"object"==typeof s.latest_health_checks&&Object.entries(s.latest_health_checks).forEach(l=>{let[s,a]=l;if(!a)return;let r=null,i=t.data.find(e=>e.model_name===s);if(i)r=i.model_name;else{let e=t.data.find(e=>e.model_info&&e.model_info.id===s);if(e)r=e.model_name;else if(a.model_name){let e=t.data.find(e=>e.model_name===a.model_name);e&&(r=e.model_name)}}if(r){let l=a.error_message||void 0;e[r]={status:a.status||"unknown",lastCheck:a.checked_at?new Date(a.checked_at).toLocaleString():"None",lastSuccess:"healthy"===a.status&&a.checked_at?new Date(a.checked_at).toLocaleString():"None",loading:!1,error:l?w(l):void 0,fullError:l,successResponse:"healthy"===a.status?a:void 0}}})}catch(e){console.warn("Failed to load health check history (using default states):",e)}d(e)})()},[l,t]);let w=e=>{var l;if(!e)return"Health check failed";let t="string"==typeof e?e:JSON.stringify(e),s=t.match(/(\w+Error):\s*(\d{3})/i);if(s)return"".concat(s[1],": ").concat(s[2]);let a=t.match(/(AuthenticationError|RateLimitError|BadRequestError|InternalServerError|TimeoutError|NotFoundError|ForbiddenError|ServiceUnavailableError|BadGatewayError|ContentPolicyViolationError|\w+Error)/i),r=t.match(/\b(400|401|403|404|408|429|500|502|503|504)\b/);if(a&&r)return"".concat(a[1],": ").concat(r[1]);if(r){let e=r[1];return"".concat({400:"BadRequestError",401:"AuthenticationError",403:"ForbiddenError",404:"NotFoundError",408:"TimeoutError",429:"RateLimitError",500:"InternalServerError",502:"BadGatewayError",503:"ServiceUnavailableError",504:"GatewayTimeoutError"}[e],": ").concat(e)}if(a){let e=a[1],l={AuthenticationError:"401",RateLimitError:"429",BadRequestError:"400",InternalServerError:"500",TimeoutError:"408",NotFoundError:"404",ForbiddenError:"403",ServiceUnavailableError:"503",BadGatewayError:"502",GatewayTimeoutError:"504",ContentPolicyViolationError:"400"}[e];return l?"".concat(e,": ").concat(l):e}for(let{pattern:e,replacement:l}of lI)if(e.test(t))return l;if(/missing.*api.*key|invalid.*key|unauthorized/i.test(t))return"AuthenticationError: 401";if(/rate.*limit|too.*many.*requests/i.test(t))return"RateLimitError: 429";if(/timeout|timed.*out/i.test(t))return"TimeoutError: 408";if(/not.*found/i.test(t))return"NotFoundError: 404";if(/forbidden|access.*denied/i.test(t))return"ForbiddenError: 403";if(/internal.*server.*error/i.test(t))return"InternalServerError: 500";let i=t.replace(/[\n\r]+/g," ").replace(/\s+/g," ").trim(),n=null===(l=i.split(/[.!?]/)[0])||void 0===l?void 0:l.trim();return n&&n.length>0?n.length>100?n.substring(0,97)+"...":n:i.length>100?i.substring(0,97)+"...":i},Z=async e=>{if(l){d(l=>({...l,[e]:{...l[e],loading:!0,status:"checking"}}));try{var s,r;let i=await (0,a.individualModelHealthCheckCall)(l,e),n=new Date().toLocaleString();if(i.unhealthy_count>0&&i.unhealthy_endpoints&&i.unhealthy_endpoints.length>0){let l=(null===(s=i.unhealthy_endpoints[0])||void 0===s?void 0:s.error)||"Health check failed",t=w(l);d(s=>{var a;return{...s,[e]:{status:"unhealthy",lastCheck:n,lastSuccess:(null===(a=s[e])||void 0===a?void 0:a.lastSuccess)||"None",loading:!1,error:t,fullError:l}}})}else d(l=>({...l,[e]:{status:"healthy",lastCheck:n,lastSuccess:n,loading:!1,successResponse:i}}));try{let s=await (0,a.latestHealthChecksCall)(l),i=t.data.find(l=>l.model_name===e);if(i){let l=i.model_info.id,t=null===(r=s.latest_health_checks)||void 0===r?void 0:r[l];if(t){let l=t.error_message||void 0;d(s=>{var a,r,i,n,o,d,c;return{...s,[e]:{status:t.status||(null===(a=s[e])||void 0===a?void 0:a.status)||"unknown",lastCheck:t.checked_at?new Date(t.checked_at).toLocaleString():(null===(r=s[e])||void 0===r?void 0:r.lastCheck)||"None",lastSuccess:"healthy"===t.status?t.checked_at?new Date(t.checked_at).toLocaleString():(null===(i=s[e])||void 0===i?void 0:i.lastSuccess)||"None":(null===(n=s[e])||void 0===n?void 0:n.lastSuccess)||"None",loading:!1,error:l?w(l):null===(o=s[e])||void 0===o?void 0:o.error,fullError:l||(null===(d=s[e])||void 0===d?void 0:d.fullError),successResponse:"healthy"===t.status?t:null===(c=s[e])||void 0===c?void 0:c.successResponse}}})}}}catch(e){console.debug("Could not fetch updated status from database (non-critical):",e)}}catch(a){let l=new Date().toLocaleString(),t=a instanceof Error?a.message:String(a),s=w(t);d(a=>{var r;return{...a,[e]:{status:"unhealthy",lastCheck:l,lastSuccess:(null===(r=a[e])||void 0===r?void 0:r.lastSuccess)||"None",loading:!1,error:s,fullError:t}}})}}},C=async()=>{let e=c.length>0?c:r,s=e.reduce((e,l)=>(e[l]={...o[l],loading:!0,status:"checking"},e),{});d(e=>({...e,...s}));let i={},n=e.map(async e=>{if(l)try{let s=await (0,a.individualModelHealthCheckCall)(l,e);i[e]=s;let r=new Date().toLocaleString();if(s.unhealthy_count>0&&s.unhealthy_endpoints&&s.unhealthy_endpoints.length>0){var t;let l=(null===(t=s.unhealthy_endpoints[0])||void 0===t?void 0:t.error)||"Health check failed",a=w(l);d(t=>{var s;return{...t,[e]:{status:"unhealthy",lastCheck:r,lastSuccess:(null===(s=t[e])||void 0===s?void 0:s.lastSuccess)||"None",loading:!1,error:a,fullError:l}}})}else d(l=>({...l,[e]:{status:"healthy",lastCheck:r,lastSuccess:r,loading:!1,successResponse:s}}))}catch(a){console.error("Health check failed for ".concat(e,":"),a);let l=new Date().toLocaleString(),t=a instanceof Error?a.message:String(a),s=w(t);d(a=>{var r;return{...a,[e]:{status:"unhealthy",lastCheck:l,lastSuccess:(null===(r=a[e])||void 0===r?void 0:r.lastSuccess)||"None",loading:!1,error:s,fullError:t}}})}});await Promise.allSettled(n);try{if(!l)return;let s=await (0,a.latestHealthChecksCall)(l);s.latest_health_checks&&Object.entries(s.latest_health_checks).forEach(l=>{let[s,a]=l,r=t.data.find(e=>e.model_info.id===s);if(r&&e.includes(r.model_name)&&a){let e=r.model_name,l=a.error_message||void 0;d(t=>{let s=t[e];return{...t,[e]:{status:a.status||(null==s?void 0:s.status)||"unknown",lastCheck:a.checked_at?new Date(a.checked_at).toLocaleString():(null==s?void 0:s.lastCheck)||"None",lastSuccess:"healthy"===a.status&&a.checked_at?new Date(a.checked_at).toLocaleString():(null==s?void 0:s.lastSuccess)||"None",loading:!1,error:l?w(l):null==s?void 0:s.error,fullError:l||(null==s?void 0:s.fullError),successResponse:"healthy"===a.status?a:null==s?void 0:s.successResponse}}})}})}catch(e){console.warn("Failed to fetch updated health statuses from database (non-critical):",e)}},k=e=>{h(e),e?m(r):m([])},S=()=>{p(!1),j(null)},P=()=>{b(!1),N(null)};return(0,s.jsxs)("div",{children:[(0,s.jsx)("div",{className:"mb-6",children:(0,s.jsxs)("div",{className:"flex justify-between items-center",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)(W.Z,{children:"Model Health Status"}),(0,s.jsx)(D.Z,{className:"text-gray-600 mt-1",children:"Run health checks on individual models to verify they are working correctly"})]}),(0,s.jsxs)("div",{className:"flex items-center gap-3",children:[c.length>0&&(0,s.jsx)(E.Z,{size:"sm",variant:"light",onClick:()=>k(!1),className:"px-3 py-1 text-sm",children:"Clear Selection"}),(0,s.jsx)(E.Z,{size:"sm",variant:"secondary",onClick:C,disabled:Object.values(o).some(e=>e.loading),className:"px-3 py-1 text-sm",children:c.length>0&&c.length{l?m(l=>[...l,e]):(m(l=>l.filter(l=>l!==e)),h(!1))},k,Z,e=>{switch(e){case"healthy":return(0,s.jsx)(A.Z,{color:"emerald",children:"healthy"});case"unhealthy":return(0,s.jsx)(A.Z,{color:"red",children:"unhealthy"});case"checking":return(0,s.jsx)(A.Z,{color:"blue",children:"checking"});case"none":return(0,s.jsx)(A.Z,{color:"gray",children:"none"});default:return(0,s.jsx)(A.Z,{color:"gray",children:"unknown"})}},i,(e,l,t)=>{j({modelName:e,cleanedError:l,fullError:t}),p(!0)},(e,l)=>{N({modelName:e,response:l}),b(!0)},n),data:t.data.map(e=>{let l=o[e.model_name]||{status:"none",lastCheck:"None",loading:!1};return{model_name:e.model_name,model_info:e.model_info,provider:e.provider,litellm_model_name:e.litellm_model_name,health_status:l.status,last_check:l.lastCheck,last_success:l.lastSuccess||"None",health_loading:l.loading,health_error:l.error,health_full_error:l.fullError}}),isLoading:!1})}),(0,s.jsx)(ea.Z,{title:g?"Health Check Error - ".concat(g.modelName):"Error Details",open:x,onCancel:S,footer:[(0,s.jsx)(_.ZP,{onClick:S,children:"Close"},"close")],width:800,children:g&&(0,s.jsxs)("div",{className:"space-y-4",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)(D.Z,{className:"font-medium",children:"Error:"}),(0,s.jsx)("div",{className:"mt-2 p-3 bg-red-50 border border-red-200 rounded-md",children:(0,s.jsx)(D.Z,{className:"text-red-800",children:g.cleanedError})})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)(D.Z,{className:"font-medium",children:"Full Error Details:"}),(0,s.jsx)("div",{className:"mt-2 p-3 bg-gray-50 border border-gray-200 rounded-md max-h-96 overflow-y-auto",children:(0,s.jsx)("pre",{className:"text-sm text-gray-800 whitespace-pre-wrap",children:g.fullError})})]})]})}),(0,s.jsx)(ea.Z,{title:y?"Health Check Response - ".concat(y.modelName):"Response Details",open:v,onCancel:P,footer:[(0,s.jsx)(_.ZP,{onClick:P,children:"Close"},"close")],width:800,children:y&&(0,s.jsxs)("div",{className:"space-y-4",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)(D.Z,{className:"font-medium",children:"Status:"}),(0,s.jsx)("div",{className:"mt-2 p-3 bg-green-50 border border-green-200 rounded-md",children:(0,s.jsx)(D.Z,{className:"text-green-800",children:"Health check passed successfully"})})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)(D.Z,{className:"font-medium",children:"Response Details:"}),(0,s.jsx)("div",{className:"mt-2 p-3 bg-gray-50 border border-gray-200 rounded-md max-h-96 overflow-y-auto",children:(0,s.jsx)("pre",{className:"text-sm text-gray-800 whitespace-pre-wrap",children:JSON.stringify(y.response,null,2)})})]})]})})]})},lR=t(47686),lO=t(77355),lV=t(93416),lq=t(95704),lz=e=>{let{accessToken:l,initialModelGroupAlias:t={},onAliasUpdate:r}=e,[i,n]=(0,f.useState)([]),[o,d]=(0,f.useState)({aliasName:"",targetModelGroup:""}),[c,m]=(0,f.useState)(null),[u,h]=(0,f.useState)(!0);(0,f.useEffect)(()=>{n(Object.entries(t).map((e,l)=>{var t;let[s,a]=e;return{id:"".concat(l,"-").concat(s),aliasName:s,targetModelGroup:"string"==typeof a?a:null!==(t=null==a?void 0:a.model)&&void 0!==t?t:""}}))},[t]);let x=async e=>{if(!l)return console.error("Access token is missing"),!1;try{let t={};return e.forEach(e=>{t[e.aliasName]=e.targetModelGroup}),console.log("Saving model group alias:",t),await (0,a.setCallbacksCall)(l,{router_settings:{model_group_alias:t}}),r&&r(t),!0}catch(e){return console.error("Failed to save model group alias settings:",e),eo.Z.fromBackend("Failed to save model group alias settings"),!1}},p=async()=>{if(!o.aliasName||!o.targetModelGroup){eo.Z.fromBackend("Please provide both alias name and target model group");return}if(i.some(e=>e.aliasName===o.aliasName)){eo.Z.fromBackend("An alias with this name already exists");return}let e=[...i,{id:"".concat(Date.now(),"-").concat(o.aliasName),aliasName:o.aliasName,targetModelGroup:o.targetModelGroup}];await x(e)&&(n(e),d({aliasName:"",targetModelGroup:""}),eo.Z.success("Alias added successfully"))},g=e=>{m({...e})},j=async()=>{if(!c)return;if(!c.aliasName||!c.targetModelGroup){eo.Z.fromBackend("Please provide both alias name and target model group");return}if(i.some(e=>e.id!==c.id&&e.aliasName===c.aliasName)){eo.Z.fromBackend("An alias with this name already exists");return}let e=i.map(e=>e.id===c.id?c:e);await x(e)&&(n(e),m(null),eo.Z.success("Alias updated successfully"))},v=()=>{m(null)},_=async e=>{let l=i.filter(l=>l.id!==e);await x(l)&&(n(l),eo.Z.success("Alias deleted successfully"))},b=i.reduce((e,l)=>(e[l.aliasName]=l.targetModelGroup,e),{});return(0,s.jsxs)(lq.Zb,{className:"mb-6",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between cursor-pointer",onClick:()=>h(!u),children:[(0,s.jsxs)("div",{className:"flex flex-col",children:[(0,s.jsx)(lq.Dx,{className:"mb-0",children:"Model Group Alias Settings"}),(0,s.jsx)("p",{className:"text-sm text-gray-500",children:"Create aliases for your model groups to simplify API calls. For example, you can create an alias 'gpt-4o' that points to 'gpt-4o-mini-openai' model group."})]}),(0,s.jsx)("div",{className:"flex items-center",children:u?(0,s.jsx)(y.Z,{className:"w-5 h-5 text-gray-500"}):(0,s.jsx)(lR.Z,{className:"w-5 h-5 text-gray-500"})})]}),u&&(0,s.jsxs)("div",{className:"mt-4",children:[(0,s.jsxs)("div",{className:"mb-6",children:[(0,s.jsx)(lq.xv,{className:"text-sm font-medium text-gray-700 mb-2",children:"Add New Alias"}),(0,s.jsxs)("div",{className:"grid grid-cols-3 gap-4",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{className:"block text-xs text-gray-500 mb-1",children:"Alias Name"}),(0,s.jsx)("input",{type:"text",value:o.aliasName,onChange:e=>d({...o,aliasName:e.target.value}),placeholder:"e.g., gpt-4o",className:"w-full px-3 py-2 border border-gray-300 rounded-md text-sm"})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{className:"block text-xs text-gray-500 mb-1",children:"Target Model Group"}),(0,s.jsx)("input",{type:"text",value:o.targetModelGroup,onChange:e=>d({...o,targetModelGroup:e.target.value}),placeholder:"e.g., gpt-4o-mini-openai",className:"w-full px-3 py-2 border border-gray-300 rounded-md text-sm"})]}),(0,s.jsx)("div",{className:"flex items-end",children:(0,s.jsxs)("button",{onClick:p,disabled:!o.aliasName||!o.targetModelGroup,className:"flex items-center px-4 py-2 rounded-md text-sm ".concat(o.aliasName&&o.targetModelGroup?"bg-green-600 text-white hover:bg-green-700":"bg-gray-300 text-gray-500 cursor-not-allowed"),children:[(0,s.jsx)(lO.Z,{className:"w-4 h-4 mr-1"}),"Add Alias"]})})]})]}),(0,s.jsx)(lq.xv,{className:"text-sm font-medium text-gray-700 mb-2",children:"Manage Existing Aliases"}),(0,s.jsx)("div",{className:"rounded-lg custom-border relative mb-6",children:(0,s.jsx)("div",{className:"overflow-x-auto",children:(0,s.jsxs)(lq.iA,{className:"[&_td]:py-0.5 [&_th]:py-1",children:[(0,s.jsx)(lq.ss,{children:(0,s.jsxs)(lq.SC,{children:[(0,s.jsx)(lq.xs,{className:"py-1 h-8",children:"Alias Name"}),(0,s.jsx)(lq.xs,{className:"py-1 h-8",children:"Target Model Group"}),(0,s.jsx)(lq.xs,{className:"py-1 h-8",children:"Actions"})]})}),(0,s.jsxs)(lq.RM,{children:[i.map(e=>(0,s.jsx)(lq.SC,{className:"h-8",children:c&&c.id===e.id?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(lq.pj,{className:"py-0.5",children:(0,s.jsx)("input",{type:"text",value:c.aliasName,onChange:e=>m({...c,aliasName:e.target.value}),className:"w-full px-2 py-1 border border-gray-300 rounded-md text-sm"})}),(0,s.jsx)(lq.pj,{className:"py-0.5",children:(0,s.jsx)("input",{type:"text",value:c.targetModelGroup,onChange:e=>m({...c,targetModelGroup:e.target.value}),className:"w-full px-2 py-1 border border-gray-300 rounded-md text-sm"})}),(0,s.jsx)(lq.pj,{className:"py-0.5 whitespace-nowrap",children:(0,s.jsxs)("div",{className:"flex space-x-2",children:[(0,s.jsx)("button",{onClick:j,className:"text-xs bg-blue-50 text-blue-600 px-2 py-1 rounded hover:bg-blue-100",children:"Save"}),(0,s.jsx)("button",{onClick:v,className:"text-xs bg-gray-50 text-gray-600 px-2 py-1 rounded hover:bg-gray-100",children:"Cancel"})]})})]}):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(lq.pj,{className:"py-0.5 text-sm text-gray-900",children:e.aliasName}),(0,s.jsx)(lq.pj,{className:"py-0.5 text-sm text-gray-500",children:e.targetModelGroup}),(0,s.jsx)(lq.pj,{className:"py-0.5 whitespace-nowrap",children:(0,s.jsxs)("div",{className:"flex space-x-2",children:[(0,s.jsx)("button",{onClick:()=>g(e),className:"text-xs bg-blue-50 text-blue-600 px-2 py-1 rounded hover:bg-blue-100",children:(0,s.jsx)(lV.Z,{className:"w-3 h-3"})}),(0,s.jsx)("button",{onClick:()=>_(e.id),className:"text-xs bg-red-50 text-red-600 px-2 py-1 rounded hover:bg-red-100",children:(0,s.jsx)(S.Z,{className:"w-3 h-3"})})]})})]})},e.id)),0===i.length&&(0,s.jsx)(lq.SC,{children:(0,s.jsx)(lq.pj,{colSpan:3,className:"py-0.5 text-sm text-gray-500 text-center",children:"No aliases added yet. Add a new alias above."})})]})]})})}),(0,s.jsxs)(lq.Zb,{children:[(0,s.jsx)(lq.Dx,{className:"mb-4",children:"Configuration Example"}),(0,s.jsx)(lq.xv,{className:"text-gray-600 mb-4",children:"Here's how your current aliases would look in the config.yaml:"}),(0,s.jsx)("div",{className:"bg-gray-100 rounded-lg p-4 font-mono text-sm",children:(0,s.jsxs)("div",{className:"text-gray-700",children:["router_settings:",(0,s.jsx)("br",{}),"\xa0\xa0model_group_alias:",0===Object.keys(b).length?(0,s.jsxs)("span",{className:"text-gray-500",children:[(0,s.jsx)("br",{}),"\xa0\xa0\xa0\xa0# No aliases configured yet"]}):Object.entries(b).map(e=>{let[l,t]=e;return(0,s.jsxs)("span",{children:[(0,s.jsx)("br",{}),'\xa0\xa0\xa0\xa0"',l,'": "',t,'"']},l)})]})})]})]})]})},lD=t(10900),lB=t(12514),lG=t(49566),lU=t(30401),lH=t(78867),lK=t(59872),lJ=e=>{let{isVisible:l,onCancel:t,onSuccess:r,modelData:i,accessToken:n,userRole:o}=e,[d]=eg.Z.useForm(),[c,m]=(0,f.useState)(!1),[u,h]=(0,f.useState)([]),[x,p]=(0,f.useState)([]),[g,j]=(0,f.useState)(!1),[v,b]=(0,f.useState)(!1),[y,N]=(0,f.useState)(null);(0,f.useEffect)(()=>{l&&i&&w()},[l,i]),(0,f.useEffect)(()=>{let e=async()=>{if(n)try{let e=await (0,a.modelAvailableCall)(n,"","",!1,null,!0,!0);h(e.data.map(e=>e.id))}catch(e){console.error("Error fetching model access groups:",e)}},t=async()=>{if(n)try{let e=await (0,e1.p)(n);p(e)}catch(e){console.error("Error fetching model info:",e)}};l&&(e(),t())},[l,n]);let w=()=>{try{var e,l,t,s,a,r;let n=null;(null===(e=i.litellm_params)||void 0===e?void 0:e.auto_router_config)&&(n="string"==typeof i.litellm_params.auto_router_config?JSON.parse(i.litellm_params.auto_router_config):i.litellm_params.auto_router_config),N(n),d.setFieldsValue({auto_router_name:i.model_name,auto_router_default_model:(null===(l=i.litellm_params)||void 0===l?void 0:l.auto_router_default_model)||"",auto_router_embedding_model:(null===(t=i.litellm_params)||void 0===t?void 0:t.auto_router_embedding_model)||"",model_access_group:(null===(s=i.model_info)||void 0===s?void 0:s.access_groups)||[]});let o=new Set(x.map(e=>e.model_group));j(!o.has(null===(a=i.litellm_params)||void 0===a?void 0:a.auto_router_default_model)),b(!o.has(null===(r=i.litellm_params)||void 0===r?void 0:r.auto_router_embedding_model))}catch(e){console.error("Error parsing auto router config:",e),eo.Z.fromBackend("Error loading auto router configuration")}},Z=async()=>{try{m(!0);let e=await d.validateFields(),l={...i.litellm_params,auto_router_config:JSON.stringify(y),auto_router_default_model:e.auto_router_default_model,auto_router_embedding_model:e.auto_router_embedding_model||void 0},s={...i.model_info,access_groups:e.model_access_group||[]},o={model_name:e.auto_router_name,litellm_params:l,model_info:s};await (0,a.modelPatchUpdateCall)(n,o,i.model_info.id);let c={...i,model_name:e.auto_router_name,litellm_params:l,model_info:s};eo.Z.success("Auto router configuration updated successfully"),r(c),t()}catch(e){console.error("Error updating auto router:",e),eo.Z.fromBackend("Failed to update auto router configuration")}finally{m(!1)}},C=x.map(e=>({value:e.model_group,label:e.model_group}));return(0,s.jsx)(ea.Z,{title:"Edit Auto Router Configuration",open:l,onCancel:t,footer:[(0,s.jsx)(_.ZP,{onClick:t,children:"Cancel"},"cancel"),(0,s.jsx)(_.ZP,{loading:c,onClick:Z,children:"Save Changes"},"submit")],width:1e3,destroyOnClose:!0,children:(0,s.jsxs)("div",{className:"space-y-6",children:[(0,s.jsx)(eN.x,{className:"text-gray-600",children:"Edit the auto router configuration including routing logic, default models, and access settings."}),(0,s.jsxs)(eg.Z,{form:d,layout:"vertical",className:"space-y-4",children:[(0,s.jsx)(eg.Z.Item,{label:"Auto Router Name",name:"auto_router_name",rules:[{required:!0,message:"Auto router name is required"}],children:(0,s.jsx)(eN.o,{placeholder:"e.g., auto_router_1, smart_routing"})}),(0,s.jsx)("div",{className:"w-full",children:(0,s.jsx)(e9,{modelInfo:x,value:y,onChange:e=>{N(e)}})}),(0,s.jsx)(eg.Z.Item,{label:"Default Model",name:"auto_router_default_model",rules:[{required:!0,message:"Default model is required"}],children:(0,s.jsx)(ev.default,{placeholder:"Select a default model",onChange:e=>{j("custom"===e)},options:[...C,{value:"custom",label:"Enter custom model name"}],showSearch:!0})}),(0,s.jsx)(eg.Z.Item,{label:"Embedding Model",name:"auto_router_embedding_model",children:(0,s.jsx)(ev.default,{placeholder:"Select an embedding model (optional)",onChange:e=>{b("custom"===e)},options:[...C,{value:"custom",label:"Enter custom model name"}],showSearch:!0,allowClear:!0})}),"Admin"===o&&(0,s.jsx)(eg.Z.Item,{label:"Model Access Groups",name:"model_access_group",tooltip:"Control who can access this auto router",children:(0,s.jsx)(ev.default,{mode:"tags",showSearch:!0,placeholder:"Select existing groups or type to create new ones",optionFilterProp:"children",tokenSeparators:[","],options:u.map(e=>({value:e,label:e})),maxTagCount:"responsive",allowClear:!0})})]})]})})};let{Title:lW,Link:lY}=Q.default;var l$=e=>{let{isVisible:l,onCancel:t,onAddCredential:a,existingCredential:r,setIsCredentialModalOpen:i}=e,[n]=eg.Z.useForm();return console.log("existingCredential in add credentials tab: ".concat(JSON.stringify(r))),(0,s.jsx)(ea.Z,{title:"Reuse Credentials",visible:l,onCancel:()=>{t(),n.resetFields()},footer:null,width:600,children:(0,s.jsxs)(eg.Z,{form:n,onFinish:e=>{a(e),n.resetFields(),i(!1)},layout:"vertical",children:[(0,s.jsx)(eg.Z.Item,{label:"Credential Name:",name:"credential_name",rules:[{required:!0,message:"Credential name is required"}],initialValue:null==r?void 0:r.credential_name,children:(0,s.jsx)(ej.o,{placeholder:"Enter a friendly name for these credentials"})}),Object.entries((null==r?void 0:r.credential_values)||{}).map(e=>{let[l,t]=e;return(0,s.jsx)(eg.Z.Item,{label:l,name:l,initialValue:t,children:(0,s.jsx)(ej.o,{placeholder:"Enter ".concat(l),disabled:!0})},l)}),(0,s.jsxs)("div",{className:"flex justify-between items-center",children:[(0,s.jsx)(M.Z,{title:"Get help on our github",children:(0,s.jsx)(lY,{href:"https://github.com/BerriAI/litellm/issues",children:"Need Help?"})}),(0,s.jsxs)("div",{children:[(0,s.jsx)(_.ZP,{onClick:()=>{t(),n.resetFields()},style:{marginRight:10},children:"Cancel"}),(0,s.jsx)(_.ZP,{htmlType:"submit",children:"Reuse Credentials"})]})]})]})})};function lX(e){var l,t,r,i,n,o,d,c,h,x,p,g,j,v,b,y,N,w,Z,C,A,P,F,I,V,q,B,G,U,H,J,Y,$;let{modelId:X,onClose:Q,accessToken:ee,userID:el,userRole:et,onModelUpdate:es,modelAccessGroups:er}=e,[ei]=eg.Z.useForm(),[en,ed]=(0,f.useState)(null),[ec,em]=(0,f.useState)(!1),[eu,eh]=(0,f.useState)(!1),[ex,ep]=(0,f.useState)(!1),[ej,e_]=(0,f.useState)(!1),[eb,ey]=(0,f.useState)(!1),[eN,ew]=(0,f.useState)(!1),[eZ,eC]=(0,f.useState)(null),[eS,eA]=(0,f.useState)(!1),[eE,eP]=(0,f.useState)({}),[eM,eL]=(0,f.useState)(!1),[eF,eI]=(0,f.useState)([]),[eT,eR]=(0,f.useState)({}),{data:eV,isLoading:eq}=(0,u.XP)(1,50,void 0,X),{data:eU}=m(),{data:eH}=(0,u.VI)(),eK=e=>null!=eU&&"object"==typeof eU&&e in eU?eU[e].litellm_provider:"openai",eJ=(0,f.useMemo)(()=>(null==eV?void 0:eV.data)&&0!==eV.data.length&&K(eV,eK).data[0]||null,[eV,eU]),eW=("Admin"===et||(null==eJ?void 0:null===(l=eJ.model_info)||void 0===l?void 0:l.created_by)===el)&&(null==eJ?void 0:null===(t=eJ.model_info)||void 0===t?void 0:t.db_model),eY="Admin"===et,e$=(null==eJ?void 0:null===(r=eJ.litellm_params)||void 0===r?void 0:r.auto_router_config)!=null,eX=(null==eJ?void 0:null===(i=eJ.litellm_params)||void 0===i?void 0:i.litellm_credential_name)!=null&&(null==eJ?void 0:null===(n=eJ.litellm_params)||void 0===n?void 0:n.litellm_credential_name)!=void 0;(0,f.useEffect)(()=>{if(eJ&&!en){var e,l,t,s,a,r,i;let n=eJ;n.litellm_model_name||(n={...n,litellm_model_name:null!==(i=null!==(r=null!==(a=null==n?void 0:null===(l=n.litellm_params)||void 0===l?void 0:l.litellm_model_name)&&void 0!==a?a:null==n?void 0:null===(t=n.litellm_params)||void 0===t?void 0:t.model)&&void 0!==r?r:null==n?void 0:null===(s=n.model_info)||void 0===s?void 0:s.key)&&void 0!==i?i:null}),ed(n),(null==n?void 0:null===(e=n.litellm_params)||void 0===e?void 0:e.cache_control_injection_points)&&eA(!0)}},[eJ,en]),(0,f.useEffect)(()=>{let e=async()=>{var e,l,t,s,r,i,n;if(!ee||eJ)return;let o=await (0,a.modelInfoV1Call)(ee,X);console.log("modelInfoResponse, ",o);let d=o.data[0];d&&!d.litellm_model_name&&(d={...d,litellm_model_name:null!==(n=null!==(i=null!==(r=null==d?void 0:null===(l=d.litellm_params)||void 0===l?void 0:l.litellm_model_name)&&void 0!==r?r:null==d?void 0:null===(t=d.litellm_params)||void 0===t?void 0:t.model)&&void 0!==i?i:null==d?void 0:null===(s=d.model_info)||void 0===s?void 0:s.key)&&void 0!==n?n:null}),ed(d),(null==d?void 0:null===(e=d.litellm_params)||void 0===e?void 0:e.cache_control_injection_points)&&eA(!0)},l=async()=>{if(ee)try{let e=(await (0,a.getGuardrailsList)(ee)).guardrails.map(e=>e.guardrail_name);eI(e)}catch(e){console.error("Failed to fetch guardrails:",e)}},t=async()=>{if(ee)try{let e=await (0,a.tagListCall)(ee);eR(e)}catch(e){console.error("Failed to fetch tags:",e)}};(async()=>{if(console.log("accessToken, ",ee),!ee||eX)return;let e=await (0,a.credentialGetCall)(ee,null,X);console.log("existingCredentialResponse, ",e),eC({credential_name:e.credential_name,credential_values:e.credential_values,credential_info:e.credential_info})})(),e(),l(),t()},[ee,X]);let eQ=async e=>{var l;if(console.log("values, ",e),!ee)return;let t={credential_name:e.credential_name,model_id:X,credential_info:{custom_llm_provider:null===(l=en.litellm_params)||void 0===l?void 0:l.custom_llm_provider}};eo.Z.info("Storing credential.."),console.log("credentialResponse, ",await (0,a.credentialCreateCall)(ee,t)),eo.Z.success("Credential stored successfully")},e0=async e=>{try{var l;let t;if(!ee)return;ey(!0),console.log("values.model_name, ",e.model_name);let s={};try{s=e.litellm_extra_params?JSON.parse(e.litellm_extra_params):{}}catch(e){eo.Z.fromBackend("Invalid JSON in LiteLLM Params"),ey(!1);return}let r={...e.litellm_params,...s,model:e.litellm_model_name,api_base:e.api_base,custom_llm_provider:e.custom_llm_provider,organization:e.organization,tpm:e.tpm,rpm:e.rpm,max_retries:e.max_retries,timeout:e.timeout,stream_timeout:e.stream_timeout,input_cost_per_token:e.input_cost/1e6,output_cost_per_token:e.output_cost/1e6,tags:e.tags};e.guardrails&&(r.guardrails=e.guardrails),e.cache_control&&(null===(l=e.cache_control_injection_points)||void 0===l?void 0:l.length)>0?r.cache_control_injection_points=e.cache_control_injection_points:delete r.cache_control_injection_points;try{t=e.model_info?JSON.parse(e.model_info):eJ.model_info,e.model_access_group&&(t={...t,access_groups:e.model_access_group}),void 0!==e.health_check_model&&(t={...t,health_check_model:e.health_check_model})}catch(e){eo.Z.fromBackend("Invalid JSON in Model Info");return}let i={model_name:e.model_name,litellm_params:r,model_info:t};await (0,a.modelPatchUpdateCall)(ee,i,X);let n={...en,model_name:e.model_name,litellm_model_name:e.litellm_model_name,litellm_params:r,model_info:t};ed(n),es&&es(n),eo.Z.success("Model settings updated successfully"),e_(!1),ew(!1)}catch(e){console.error("Error updating model:",e),eo.Z.fromBackend("Failed to update model settings")}finally{ey(!1)}};if(eq)return(0,s.jsxs)("div",{className:"p-4",children:[(0,s.jsx)(E.Z,{icon:lD.Z,variant:"light",onClick:Q,className:"mb-4",children:"Back to Models"}),(0,s.jsx)(D.Z,{children:"Loading..."})]});if(!eJ)return(0,s.jsxs)("div",{className:"p-4",children:[(0,s.jsx)(E.Z,{icon:lD.Z,variant:"light",onClick:Q,className:"mb-4",children:"Back to Models"}),(0,s.jsx)(D.Z,{children:"Model not found"})]});let e1=async()=>{if(ee)try{var e,l,t;eo.Z.info("Testing connection...");let s=await (0,a.testConnectionRequest)(ee,{custom_llm_provider:en.litellm_params.custom_llm_provider,litellm_credential_name:en.litellm_params.litellm_credential_name,model:en.litellm_model_name},{mode:null===(e=en.model_info)||void 0===e?void 0:e.mode},null===(l=en.model_info)||void 0===l?void 0:l.mode);if("success"===s.status)eo.Z.success("Connection test successful!");else throw Error((null==s?void 0:null===(t=s.result)||void 0===t?void 0:t.error)||(null==s?void 0:s.message)||"Unknown error")}catch(e){e instanceof Error?eo.Z.error("Error testing connection: "+(0,lf.aS)(e.message,100)):eo.Z.error("Error testing connection: "+String(e))}},e2=async()=>{try{if(eh(!0),!ee)return;await (0,a.modelDeleteCall)(ee,X),eo.Z.success("Model deleted successfully"),es&&es({deleted:!0,model_info:{id:X}}),Q()}catch(e){console.error("Error deleting the model:",e),eo.Z.fromBackend("Failed to delete model")}finally{eh(!1),em(!1)}},e4=async(e,l)=>{await (0,lK.vQ)(e)&&(eP(e=>({...e,[l]:!0})),setTimeout(()=>{eP(e=>({...e,[l]:!1}))},2e3))},e5=eJ.litellm_model_name.includes("*");return console.log("isWildcardModel, ",e5),(0,s.jsxs)("div",{className:"p-4",children:[(0,s.jsxs)("div",{className:"flex justify-between items-center mb-6",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)(E.Z,{icon:lD.Z,variant:"light",onClick:Q,className:"mb-4",children:"Back to Models"}),(0,s.jsxs)(W.Z,{children:["Public Model Name: ",T(eJ)]}),(0,s.jsxs)("div",{className:"flex items-center cursor-pointer",children:[(0,s.jsx)(D.Z,{className:"text-gray-500 font-mono",children:eJ.model_info.id}),(0,s.jsx)(_.ZP,{type:"text",size:"small",icon:eE["model-id"]?(0,s.jsx)(lU.Z,{size:12}):(0,s.jsx)(lH.Z,{size:12}),onClick:()=>e4(eJ.model_info.id,"model-id"),className:"left-2 z-10 transition-all duration-200 ".concat(eE["model-id"]?"text-green-600 bg-green-50 border-green-200":"text-gray-500 hover:text-gray-700 hover:bg-gray-100")})]})]}),(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsx)(E.Z,{variant:"secondary",icon:eO.Z,onClick:e1,className:"flex items-center gap-2","data-testid":"test-connection-button",children:"Test Connection"}),(0,s.jsx)(E.Z,{icon:k.Z,variant:"secondary",onClick:()=>ep(!0),className:"flex items-center",disabled:!eY,"data-testid":"reuse-credentials-button",children:"Re-use Credentials"}),(0,s.jsx)(E.Z,{icon:S.Z,variant:"secondary",onClick:()=>em(!0),className:"flex items-center text-red-500 border-red-500 hover:text-red-700",disabled:!eW,"data-testid":"delete-model-button",children:"Delete Model"})]})]}),(0,s.jsxs)(eD.Z,{children:[(0,s.jsxs)(eB.Z,{className:"mb-6",children:[(0,s.jsx)(ez.Z,{children:"Overview"}),(0,s.jsx)(ez.Z,{children:"Raw JSON"})]}),(0,s.jsxs)(eG.Z,{children:[(0,s.jsxs)(z.Z,{children:[(0,s.jsxs)(O.Z,{numItems:1,numItemsSm:2,numItemsLg:3,className:"gap-6 mb-6",children:[(0,s.jsxs)(lB.Z,{children:[(0,s.jsx)(D.Z,{children:"Provider"}),(0,s.jsxs)("div",{className:"mt-2 flex items-center space-x-2",children:[eJ.provider&&(0,s.jsx)("img",{src:(0,L.dr)(eJ.provider).logo,alt:"".concat(eJ.provider," logo"),className:"w-4 h-4",onError:e=>{let l=e.currentTarget,t=l.parentElement;if(t&&t.contains(l))try{var s;let e=document.createElement("div");e.className="w-4 h-4 rounded-full bg-gray-200 flex items-center justify-center text-xs",e.textContent=(null===(s=eJ.provider)||void 0===s?void 0:s.charAt(0))||"-",t.replaceChild(e,l)}catch(e){console.error("Failed to replace provider logo fallback:",e)}}}),(0,s.jsx)(W.Z,{children:eJ.provider||"Not Set"})]})]}),(0,s.jsxs)(lB.Z,{children:[(0,s.jsx)(D.Z,{children:"LiteLLM Model"}),(0,s.jsx)("div",{className:"mt-2 overflow-hidden",children:(0,s.jsx)(M.Z,{title:eJ.litellm_model_name||"Not Set",children:(0,s.jsx)("div",{className:"break-all text-sm font-medium leading-relaxed cursor-pointer",children:eJ.litellm_model_name||"Not Set"})})})]}),(0,s.jsxs)(lB.Z,{children:[(0,s.jsx)(D.Z,{children:"Pricing"}),(0,s.jsxs)("div",{className:"mt-2",children:[(0,s.jsxs)(D.Z,{children:["Input: $",eJ.input_cost,"/1M tokens"]}),(0,s.jsxs)(D.Z,{children:["Output: $",eJ.output_cost,"/1M tokens"]})]})]})]}),(0,s.jsxs)("div",{className:"mb-6 text-sm text-gray-500 flex items-center gap-x-6",children:[(0,s.jsxs)("div",{className:"flex items-center gap-x-2",children:[(0,s.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,s.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z"})}),"Created At"," ",eJ.model_info.created_at?new Date(eJ.model_info.created_at).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"}):"Not Set"]}),(0,s.jsxs)("div",{className:"flex items-center gap-x-2",children:[(0,s.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,s.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M16 7a4 4 0 11-8 0 4 4 0 018 0zM12 14a7 7 0 00-7 7h14a7 7 0 00-7-7z"})}),"Created By ",eJ.model_info.created_by||"Not Set"]})]}),(0,s.jsxs)(lB.Z,{children:[(0,s.jsxs)("div",{className:"flex justify-between items-center mb-4",children:[(0,s.jsx)(W.Z,{children:"Model Settings"}),(0,s.jsxs)("div",{className:"flex gap-2",children:[e$&&eW&&!eN&&(0,s.jsx)(E.Z,{onClick:()=>eL(!0),className:"flex items-center",children:"Edit Auto Router"}),eW?!eN&&(0,s.jsx)(E.Z,{onClick:()=>ew(!0),className:"flex items-center",children:"Edit Settings"}):(0,s.jsx)(M.Z,{title:"Only DB models can be edited. You must be an admin or the creator of the model to edit it.",children:(0,s.jsx)(R.Z,{})})]})]}),en?(0,s.jsx)(eg.Z,{form:ei,onFinish:e0,initialValues:{model_name:en.model_name,litellm_model_name:en.litellm_model_name,api_base:en.litellm_params.api_base,custom_llm_provider:en.litellm_params.custom_llm_provider,organization:en.litellm_params.organization,tpm:en.litellm_params.tpm,rpm:en.litellm_params.rpm,max_retries:en.litellm_params.max_retries,timeout:en.litellm_params.timeout,stream_timeout:en.litellm_params.stream_timeout,input_cost:en.litellm_params.input_cost_per_token?1e6*en.litellm_params.input_cost_per_token:(null===(o=en.model_info)||void 0===o?void 0:o.input_cost_per_token)*1e6||null,output_cost:(null===(d=en.litellm_params)||void 0===d?void 0:d.output_cost_per_token)?1e6*en.litellm_params.output_cost_per_token:(null===(c=en.model_info)||void 0===c?void 0:c.output_cost_per_token)*1e6||null,cache_control:null!==(h=en.litellm_params)&&void 0!==h&&!!h.cache_control_injection_points,cache_control_injection_points:(null===(x=en.litellm_params)||void 0===x?void 0:x.cache_control_injection_points)||[],model_access_group:Array.isArray(null===(p=en.model_info)||void 0===p?void 0:p.access_groups)?en.model_info.access_groups:[],guardrails:Array.isArray(null===(g=en.litellm_params)||void 0===g?void 0:g.guardrails)?en.litellm_params.guardrails:[],tags:Array.isArray(null===(j=en.litellm_params)||void 0===j?void 0:j.tags)?en.litellm_params.tags:[],health_check_model:e5?null===(v=en.model_info)||void 0===v?void 0:v.health_check_model:null,litellm_extra_params:JSON.stringify(en.litellm_params||{},null,2)},layout:"vertical",onValuesChange:()=>e_(!0),children:(0,s.jsxs)("div",{className:"space-y-4",children:[(0,s.jsxs)("div",{className:"space-y-4",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)(D.Z,{className:"font-medium",children:"Model Name"}),eN?(0,s.jsx)(eg.Z.Item,{name:"model_name",className:"mb-0",children:(0,s.jsx)(lG.Z,{placeholder:"Enter model name"})}):(0,s.jsx)("div",{className:"mt-1 p-2 bg-gray-50 rounded",children:en.model_name})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)(D.Z,{className:"font-medium",children:"LiteLLM Model Name"}),eN?(0,s.jsx)(eg.Z.Item,{name:"litellm_model_name",className:"mb-0",children:(0,s.jsx)(lG.Z,{placeholder:"Enter LiteLLM model name"})}):(0,s.jsx)("div",{className:"mt-1 p-2 bg-gray-50 rounded",children:en.litellm_model_name})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)(D.Z,{className:"font-medium",children:"Input Cost (per 1M tokens)"}),eN?(0,s.jsx)(eg.Z.Item,{name:"input_cost",className:"mb-0",children:(0,s.jsx)(lx.Z,{placeholder:"Enter input cost"})}):(0,s.jsx)("div",{className:"mt-1 p-2 bg-gray-50 rounded",children:(null==en?void 0:null===(b=en.litellm_params)||void 0===b?void 0:b.input_cost_per_token)?((null===(y=en.litellm_params)||void 0===y?void 0:y.input_cost_per_token)*1e6).toFixed(4):(null==en?void 0:null===(N=en.model_info)||void 0===N?void 0:N.input_cost_per_token)?(1e6*en.model_info.input_cost_per_token).toFixed(4):null})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)(D.Z,{className:"font-medium",children:"Output Cost (per 1M tokens)"}),eN?(0,s.jsx)(eg.Z.Item,{name:"output_cost",className:"mb-0",children:(0,s.jsx)(lx.Z,{placeholder:"Enter output cost"})}):(0,s.jsx)("div",{className:"mt-1 p-2 bg-gray-50 rounded",children:(null==en?void 0:null===(w=en.litellm_params)||void 0===w?void 0:w.output_cost_per_token)?(1e6*en.litellm_params.output_cost_per_token).toFixed(4):(null==en?void 0:null===(Z=en.model_info)||void 0===Z?void 0:Z.output_cost_per_token)?(1e6*en.model_info.output_cost_per_token).toFixed(4):null})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)(D.Z,{className:"font-medium",children:"API Base"}),eN?(0,s.jsx)(eg.Z.Item,{name:"api_base",className:"mb-0",children:(0,s.jsx)(lG.Z,{placeholder:"Enter API base"})}):(0,s.jsx)("div",{className:"mt-1 p-2 bg-gray-50 rounded",children:(null===(C=en.litellm_params)||void 0===C?void 0:C.api_base)||"Not Set"})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)(D.Z,{className:"font-medium",children:"Custom LLM Provider"}),eN?(0,s.jsx)(eg.Z.Item,{name:"custom_llm_provider",className:"mb-0",children:(0,s.jsx)(lG.Z,{placeholder:"Enter custom LLM provider"})}):(0,s.jsx)("div",{className:"mt-1 p-2 bg-gray-50 rounded",children:(null===(A=en.litellm_params)||void 0===A?void 0:A.custom_llm_provider)||"Not Set"})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)(D.Z,{className:"font-medium",children:"Organization"}),eN?(0,s.jsx)(eg.Z.Item,{name:"organization",className:"mb-0",children:(0,s.jsx)(lG.Z,{placeholder:"Enter organization"})}):(0,s.jsx)("div",{className:"mt-1 p-2 bg-gray-50 rounded",children:(null===(P=en.litellm_params)||void 0===P?void 0:P.organization)||"Not Set"})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)(D.Z,{className:"font-medium",children:"TPM (Tokens per Minute)"}),eN?(0,s.jsx)(eg.Z.Item,{name:"tpm",className:"mb-0",children:(0,s.jsx)(lx.Z,{placeholder:"Enter TPM"})}):(0,s.jsx)("div",{className:"mt-1 p-2 bg-gray-50 rounded",children:(null===(F=en.litellm_params)||void 0===F?void 0:F.tpm)||"Not Set"})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)(D.Z,{className:"font-medium",children:"RPM (Requests per Minute)"}),eN?(0,s.jsx)(eg.Z.Item,{name:"rpm",className:"mb-0",children:(0,s.jsx)(lx.Z,{placeholder:"Enter RPM"})}):(0,s.jsx)("div",{className:"mt-1 p-2 bg-gray-50 rounded",children:(null===(I=en.litellm_params)||void 0===I?void 0:I.rpm)||"Not Set"})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)(D.Z,{className:"font-medium",children:"Max Retries"}),eN?(0,s.jsx)(eg.Z.Item,{name:"max_retries",className:"mb-0",children:(0,s.jsx)(lx.Z,{placeholder:"Enter max retries"})}):(0,s.jsx)("div",{className:"mt-1 p-2 bg-gray-50 rounded",children:(null===(V=en.litellm_params)||void 0===V?void 0:V.max_retries)||"Not Set"})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)(D.Z,{className:"font-medium",children:"Timeout (seconds)"}),eN?(0,s.jsx)(eg.Z.Item,{name:"timeout",className:"mb-0",children:(0,s.jsx)(lx.Z,{placeholder:"Enter timeout"})}):(0,s.jsx)("div",{className:"mt-1 p-2 bg-gray-50 rounded",children:(null===(q=en.litellm_params)||void 0===q?void 0:q.timeout)||"Not Set"})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)(D.Z,{className:"font-medium",children:"Stream Timeout (seconds)"}),eN?(0,s.jsx)(eg.Z.Item,{name:"stream_timeout",className:"mb-0",children:(0,s.jsx)(lx.Z,{placeholder:"Enter stream timeout"})}):(0,s.jsx)("div",{className:"mt-1 p-2 bg-gray-50 rounded",children:(null===(B=en.litellm_params)||void 0===B?void 0:B.stream_timeout)||"Not Set"})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)(D.Z,{className:"font-medium",children:"Model Access Groups"}),eN?(0,s.jsx)(eg.Z.Item,{name:"model_access_group",className:"mb-0",children:(0,s.jsx)(ev.default,{mode:"tags",showSearch:!0,placeholder:"Select existing groups or type to create new ones",optionFilterProp:"children",tokenSeparators:[","],maxTagCount:"responsive",allowClear:!0,style:{width:"100%"},options:null==er?void 0:er.map(e=>({value:e,label:e}))})}):(0,s.jsx)("div",{className:"mt-1 p-2 bg-gray-50 rounded",children:(null===(G=en.model_info)||void 0===G?void 0:G.access_groups)?Array.isArray(en.model_info.access_groups)?en.model_info.access_groups.length>0?(0,s.jsx)("div",{className:"flex flex-wrap gap-1",children:en.model_info.access_groups.map((e,l)=>(0,s.jsx)("span",{className:"inline-flex items-center px-2 py-1 rounded-full text-xs font-medium bg-blue-100 text-blue-800",children:e},l))}):"No groups assigned":en.model_info.access_groups:"Not Set"})]}),(0,s.jsxs)("div",{children:[(0,s.jsxs)(D.Z,{className:"font-medium",children:["Guardrails",(0,s.jsx)(M.Z,{title:"Apply safety guardrails to this model to filter content or enforce policies",children:(0,s.jsx)("a",{href:"https://docs.litellm.ai/docs/proxy/guardrails/quick_start",target:"_blank",rel:"noopener noreferrer",onClick:e=>e.stopPropagation(),children:(0,s.jsx)(R.Z,{style:{marginLeft:"4px"}})})})]}),eN?(0,s.jsx)(eg.Z.Item,{name:"guardrails",className:"mb-0",children:(0,s.jsx)(ev.default,{mode:"tags",showSearch:!0,placeholder:"Select existing guardrails or type to create new ones",optionFilterProp:"children",tokenSeparators:[","],maxTagCount:"responsive",allowClear:!0,style:{width:"100%"},options:eF.map(e=>({value:e,label:e}))})}):(0,s.jsx)("div",{className:"mt-1 p-2 bg-gray-50 rounded",children:(null===(U=en.litellm_params)||void 0===U?void 0:U.guardrails)?Array.isArray(en.litellm_params.guardrails)?en.litellm_params.guardrails.length>0?(0,s.jsx)("div",{className:"flex flex-wrap gap-1",children:en.litellm_params.guardrails.map((e,l)=>(0,s.jsx)("span",{className:"inline-flex items-center px-2 py-1 rounded-full text-xs font-medium bg-green-100 text-green-800",children:e},l))}):"No guardrails assigned":en.litellm_params.guardrails:"Not Set"})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)(D.Z,{className:"font-medium",children:"Tags"}),eN?(0,s.jsx)(eg.Z.Item,{name:"tags",className:"mb-0",children:(0,s.jsx)(ev.default,{mode:"tags",showSearch:!0,placeholder:"Select existing tags or type to create new ones",optionFilterProp:"children",tokenSeparators:[","],maxTagCount:"responsive",allowClear:!0,style:{width:"100%"},options:Object.values(eT).map(e=>({value:e.name,label:e.name,title:e.description||e.name}))})}):(0,s.jsx)("div",{className:"mt-1 p-2 bg-gray-50 rounded",children:(null===(H=en.litellm_params)||void 0===H?void 0:H.tags)?Array.isArray(en.litellm_params.tags)?en.litellm_params.tags.length>0?(0,s.jsx)("div",{className:"flex flex-wrap gap-1",children:en.litellm_params.tags.map((e,l)=>(0,s.jsx)("span",{className:"inline-flex items-center px-2 py-1 rounded-full text-xs font-medium bg-purple-100 text-purple-800",children:e},l))}):"No tags assigned":en.litellm_params.tags:"Not Set"})]}),e5&&(0,s.jsxs)("div",{children:[(0,s.jsx)(D.Z,{className:"font-medium",children:"Health Check Model"}),eN?(0,s.jsx)(eg.Z.Item,{name:"health_check_model",className:"mb-0",children:(0,s.jsx)(ev.default,{showSearch:!0,placeholder:"Select existing health check model",optionFilterProp:"children",allowClear:!0,options:(()=>{var e;let l=eJ.litellm_model_name.split("/")[0];return(null==eH?void 0:null===(e=eH.data)||void 0===e?void 0:e.filter(e=>{var t;return(null===(t=e.providers)||void 0===t?void 0:t.includes(l))&&e.model_group!==eJ.litellm_model_name}).map(e=>({value:e.model_group,label:e.model_group})))||[]})()})}):(0,s.jsx)("div",{className:"mt-1 p-2 bg-gray-50 rounded",children:(null===(J=en.model_info)||void 0===J?void 0:J.health_check_model)||"Not Set"})]}),eN?(0,s.jsx)(lg,{form:ei,showCacheControl:eS,onCacheControlChange:e=>eA(e)}):(0,s.jsxs)("div",{children:[(0,s.jsx)(D.Z,{className:"font-medium",children:"Cache Control"}),(0,s.jsx)("div",{className:"mt-1 p-2 bg-gray-50 rounded",children:(null===(Y=en.litellm_params)||void 0===Y?void 0:Y.cache_control_injection_points)?(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{children:"Enabled"}),(0,s.jsx)("div",{className:"mt-2",children:en.litellm_params.cache_control_injection_points.map((e,l)=>(0,s.jsxs)("div",{className:"text-sm text-gray-600 mb-1",children:["Location: ",e.location,",",e.role&&(0,s.jsxs)("span",{children:[" Role: ",e.role]}),void 0!==e.index&&(0,s.jsxs)("span",{children:[" Index: ",e.index]})]},l))})]}):"Disabled"})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)(D.Z,{className:"font-medium",children:"Model Info"}),eN?(0,s.jsx)(eg.Z.Item,{name:"model_info",className:"mb-0",children:(0,s.jsx)(ek.default.TextArea,{rows:4,placeholder:'{"gpt-4": 100, "claude-v1": 200}',defaultValue:JSON.stringify(eJ.model_info,null,2)})}):(0,s.jsx)("div",{className:"mt-1 p-2 bg-gray-50 rounded",children:(0,s.jsx)("pre",{className:"bg-gray-100 p-2 rounded text-xs overflow-auto mt-1",children:JSON.stringify(en.model_info,null,2)})})]}),(0,s.jsxs)("div",{children:[(0,s.jsxs)(D.Z,{className:"font-medium",children:["LiteLLM Params",(0,s.jsx)(M.Z,{title:"Optional litellm params used for making a litellm.completion() call. Some params are automatically added by LiteLLM.",children:(0,s.jsx)("a",{href:"https://docs.litellm.ai/docs/completion/input",target:"_blank",rel:"noopener noreferrer",onClick:e=>e.stopPropagation(),children:(0,s.jsx)(R.Z,{style:{marginLeft:"4px"}})})})]}),eN?(0,s.jsx)(eg.Z.Item,{name:"litellm_extra_params",rules:[{validator:lf.Ac}],children:(0,s.jsx)(ek.default.TextArea,{rows:4,placeholder:'{ "rpm": 100, "timeout": 0, "stream_timeout": 0 }'})}):(0,s.jsx)("div",{className:"mt-1 p-2 bg-gray-50 rounded",children:(0,s.jsx)("pre",{className:"bg-gray-100 p-2 rounded text-xs overflow-auto mt-1",children:JSON.stringify(en.litellm_params,null,2)})})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)(D.Z,{className:"font-medium",children:"Team ID"}),(0,s.jsx)("div",{className:"mt-1 p-2 bg-gray-50 rounded",children:eJ.model_info.team_id||"Not Set"})]})]}),eN&&(0,s.jsxs)("div",{className:"mt-6 flex justify-end gap-2",children:[(0,s.jsx)(E.Z,{variant:"secondary",onClick:()=>{ei.resetFields(),e_(!1),ew(!1)},disabled:eb,children:"Cancel"}),(0,s.jsx)(E.Z,{variant:"primary",onClick:()=>ei.submit(),loading:eb,children:"Save Changes"})]})]})}):(0,s.jsx)(D.Z,{children:"Loading..."})]})]}),(0,s.jsx)(z.Z,{children:(0,s.jsx)(lB.Z,{children:(0,s.jsx)("pre",{className:"bg-gray-100 p-4 rounded text-xs overflow-auto",children:JSON.stringify(eJ,null,2)})})})]})]}),(0,s.jsx)(ef.Z,{isOpen:ec,title:"Delete Model",alertMessage:"This action cannot be undone.",message:"Are you sure you want to delete this model?",resourceInformationTitle:"Model Information",resourceInformation:[{label:"Model Name",value:(null==eJ?void 0:eJ.model_name)||"Not Set"},{label:"LiteLLM Model Name",value:(null==eJ?void 0:eJ.litellm_model_name)||"Not Set"},{label:"Provider",value:(null==eJ?void 0:eJ.provider)||"Not Set"},{label:"Created By",value:(null==eJ?void 0:null===($=eJ.model_info)||void 0===$?void 0:$.created_by)||"Not Set"}],onCancel:()=>em(!1),onOk:e2,confirmLoading:eu}),ex&&!eX?(0,s.jsx)(l$,{isVisible:ex,onCancel:()=>ep(!1),onAddCredential:eQ,existingCredential:eZ,setIsCredentialModalOpen:ep}):(0,s.jsx)(ea.Z,{open:ex,onCancel:()=>ep(!1),title:"Using Existing Credential",children:(0,s.jsx)(D.Z,{children:eJ.litellm_params.litellm_credential_name})}),(0,s.jsx)(lJ,{isVisible:eM,onCancel:()=>eL(!1),onSuccess:e=>{ed(e),es&&es(e)},modelData:en||eJ,accessToken:ee||"",userRole:et||""})]})}var lQ=t(27593),l0=t(56147),l1=e=>{var l;let{premiumUser:t,teams:r}=e,{accessToken:i,token:o,userRole:c,userId:x}=(0,n.Z)(),[p]=eg.Z.useForm(),[g,j]=(0,f.useState)(""),[v,_]=(0,f.useState)([]),[b,y]=(0,f.useState)(L.Cl.Anthropic),[N,w]=(0,f.useState)(null),[Z,C]=(0,f.useState)(null),[k,S]=(0,f.useState)(null),[A,E]=(0,f.useState)(0),[M,F]=(0,f.useState)({}),[I,R]=(0,f.useState)(!1),[V,q]=(0,f.useState)(null),[B,G]=(0,f.useState)(null),[U,H]=(0,f.useState)(0),W=(0,eV.NL)(),{data:Y,isLoading:$,refetch:ee}=(0,u.XP)(),{data:el,isLoading:et}=m(),{data:es,isLoading:ea}=d(),er=(null==es?void 0:es.credentials)||[],{data:ei,isLoading:en}=(0,h.L)(),ed=(0,f.useMemo)(()=>{if(!(null==Y?void 0:Y.data))return[];let e=new Set;for(let l of Y.data)e.add(l.model_name);return Array.from(e).sort()},[null==Y?void 0:Y.data]),ec=(0,f.useMemo)(()=>{if(!(null==Y?void 0:Y.data))return[];let e=new Set;for(let l of Y.data){let t=l.model_info;if(null==t?void 0:t.access_groups)for(let l of t.access_groups)e.add(l)}return Array.from(e)},[null==Y?void 0:Y.data]),eu=(0,f.useMemo)(()=>(null==Y?void 0:Y.data)?Y.data.map(e=>e.model_name):[],[null==Y?void 0:Y.data]),ex=e=>null!=el&&"object"==typeof el&&e in el?el[e].litellm_provider:"openai",ep=(0,f.useMemo)(()=>(null==Y?void 0:Y.data)?K(Y,ex):{data:[]},[null==Y?void 0:Y.data,ex]),ef=c&&(0,eR.P4)(c),ej=c&&eR.lo.includes(c),ev=x&&(0,eR.yV)(r,x),e_=ej&&(null==ei?void 0:null===(l=ei.values)||void 0===l?void 0:l.disable_model_add_for_internal_users)===!0,eb=!ef&&(e_||!ev),ey={name:"file",accept:".json",pastable:!1,beforeUpload:e=>{if("application/json"===e.type){let l=new FileReader;l.onload=e=>{if(e.target){let l=e.target.result;p.setFieldsValue({vertex_credentials:l})}},l.readAsText(e)}return!1},onChange(e){"done"===e.file.status?eo.Z.success("".concat(e.file.name," file uploaded successfully")):"error"===e.file.status&&eo.Z.fromBackend("".concat(e.file.name," file upload failed."))}},eN=()=>{j(new Date().toLocaleString()),W.invalidateQueries({queryKey:["models","list"]}),ee()},ew=async()=>{if(i)try{let e={router_settings:{}};"global"===N?(k&&(e.router_settings.retry_policy=k),eo.Z.success("Global retry settings saved successfully")):(Z&&(e.router_settings.model_group_retry_policy=Z),eo.Z.success("Retry settings saved successfully for ".concat(N))),await (0,a.setCallbacksCall)(i,e)}catch(e){eo.Z.fromBackend("Failed to save retry settings")}};if((0,f.useEffect)(()=>{if(!i||!o||!c||!x||!Y)return;let e=async()=>{try{let e=(await (0,a.getCallbacksCall)(i,x,c)).router_settings,l=e.model_group_retry_policy,t=e.num_retries;C(l),S(e.retry_policy),E(t);let s=e.model_group_alias||{};F(s)}catch(e){console.error("Error fetching model data:",e)}};i&&o&&c&&x&&Y&&e()},[i,o,c,x,Y]),c&&"Admin Viewer"==c){let{Title:e,Paragraph:l}=Q.default;return(0,s.jsxs)("div",{children:[(0,s.jsx)(e,{level:1,children:"Access Denied"}),(0,s.jsx)(l,{children:"Ask your proxy admin for access to view all models"})]})}let eZ=async()=>{try{let e=await p.validateFields();await eh(e,i,p,eN)}catch(t){var e;let l=(null===(e=t.errorFields)||void 0===e?void 0:e.map(e=>"".concat(e.name.join("."),": ").concat(e.errors.join(", "))).join(" | "))||"Unknown validation error";eo.Z.fromBackend("Please fill in the following required fields: ".concat(l))}};return(Object.keys(L.Cl).find(e=>L.Cl[e]===b),B)?(0,s.jsx)("div",{className:"w-full h-full",children:(0,s.jsx)(l0.Z,{teamId:B,onClose:()=>G(null),accessToken:i,is_team_admin:"Admin"===c,is_proxy_admin:"Proxy Admin"===c,userModels:eu,editTeam:!1,onUpdate:eN,premiumUser:t})}):(0,s.jsx)("div",{className:"w-full mx-4 h-[75vh]",children:(0,s.jsx)(O.Z,{numItems:1,className:"gap-2 p-8 w-full mt-2",children:(0,s.jsxs)(eq.Z,{numColSpan:1,className:"flex flex-col gap-2",children:[(0,s.jsx)("div",{className:"flex justify-between items-center mb-4",children:(0,s.jsxs)("div",{children:[(0,s.jsx)("h2",{className:"text-lg font-semibold",children:"Model Management"}),eR.ZL.includes(c)?(0,s.jsx)("p",{className:"text-sm text-gray-600",children:"Add and manage models for the proxy"}):(0,s.jsx)("p",{className:"text-sm text-gray-600",children:"Add models for teams you are an admin for."})]})}),(0,s.jsxs)("div",{className:"mb-4 px-4 py-3 bg-blue-50 rounded-lg border border-blue-100 flex items-center gap-4",children:[(0,s.jsx)("div",{className:"flex-shrink-0 w-10 h-10 bg-white rounded-full flex items-center justify-center border border-blue-200",children:(0,s.jsx)(eU.Z,{style:{fontSize:"18px",color:"#6366f1"}})}),(0,s.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,s.jsx)("h4",{className:"text-gray-900 font-semibold text-sm m-0",children:"Missing a provider?"}),(0,s.jsx)("p",{className:"text-gray-500 text-xs m-0 mt-0.5",children:"The LiteLLM engineering team is constantly adding support for new LLM models, providers, endpoints. If you don't see the one you need, let us know and we'll prioritize it."})]}),(0,s.jsxs)("a",{href:"https://models.litellm.ai/?request=true",target:"_blank",rel:"noopener noreferrer",className:"flex-shrink-0 inline-flex items-center gap-2 px-4 py-2 bg-[#6366f1] hover:bg-[#5558e3] text-white text-sm font-medium rounded-lg transition-colors",children:["Request Provider",(0,s.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:(0,s.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M10 6H6a2 2 0 00-2 2v10a2 2 0 002 2h10a2 2 0 002-2v-4M14 4h6m0 0v6m0-6L10 14"})})]})]}),V&&!($||et||ea||en)?(0,s.jsx)(lX,{modelId:V,onClose:()=>{q(null)},accessToken:i,userID:x,userRole:c,onModelUpdate:e=>{W.invalidateQueries({queryKey:["models","list"]}),eN()},modelAccessGroups:ec}):(0,s.jsxs)(eD.Z,{index:U,onIndexChange:H,className:"gap-2 h-[75vh] w-full ",children:[(0,s.jsxs)(eB.Z,{className:"flex justify-between mt-2 w-full items-center",children:[(0,s.jsxs)("div",{className:"flex",children:[eR.ZL.includes(c)?(0,s.jsx)(ez.Z,{children:"All Models"}):(0,s.jsx)(ez.Z,{children:"Your Models"}),!eb&&(0,s.jsx)(ez.Z,{children:"Add Model"}),eR.ZL.includes(c)&&(0,s.jsx)(ez.Z,{children:"LLM Credentials"}),eR.ZL.includes(c)&&(0,s.jsx)(ez.Z,{children:"Pass-Through Endpoints"}),eR.ZL.includes(c)&&(0,s.jsx)(ez.Z,{children:"Health Status"}),eR.ZL.includes(c)&&(0,s.jsx)(ez.Z,{children:"Model Retry Settings"}),eR.ZL.includes(c)&&(0,s.jsx)(ez.Z,{children:"Model Group Alias"}),eR.ZL.includes(c)&&(0,s.jsx)(ez.Z,{children:"Price Data Reload"})]}),(0,s.jsxs)("div",{className:"flex items-center space-x-2",children:[g&&(0,s.jsxs)(D.Z,{children:["Last Refreshed: ",g]}),(0,s.jsx)(P.Z,{icon:eO.Z,variant:"shadow",size:"xs",className:"self-center",onClick:eN})]})]}),(0,s.jsxs)(eG.Z,{children:[(0,s.jsx)(J,{selectedModelGroup:N,setSelectedModelGroup:w,availableModelGroups:ed,availableModelAccessGroups:ec,setSelectedModelId:q,setSelectedTeamId:G}),!eb&&(0,s.jsx)(z.Z,{className:"h-full",children:(0,s.jsx)(lA,{form:p,handleOk:eZ,selectedProvider:b,setSelectedProvider:y,providerModels:v,setProviderModelsFn:e=>{_((0,L.bK)(e,el))},getPlaceholder:L.ph,uploadProps:ey,showAdvancedSettings:I,setShowAdvancedSettings:R,teams:r,credentials:er,accessToken:i,userRole:c})}),(0,s.jsx)(z.Z,{children:(0,s.jsx)(eT,{uploadProps:ey})}),(0,s.jsx)(z.Z,{children:(0,s.jsx)(lQ.Z,{accessToken:i,userRole:c,userID:x,modelData:ep,premiumUser:t})}),(0,s.jsx)(z.Z,{children:(0,s.jsx)(lT,{accessToken:i,modelData:ep,all_models_on_proxy:eu,getDisplayModelName:T,setSelectedModelId:q})}),(0,s.jsx)(X,{selectedModelGroup:N,setSelectedModelGroup:w,availableModelGroups:ed,globalRetryPolicy:k,setGlobalRetryPolicy:S,defaultRetry:A,modelGroupRetryPolicy:Z,setModelGroupRetryPolicy:C,handleSaveRetrySettings:ew}),(0,s.jsx)(z.Z,{children:(0,s.jsx)(lz,{accessToken:i,initialModelGroupAlias:M,onAliasUpdate:F})}),(0,s.jsx)(em,{})]})]})]})})})}},27593:function(e,l,t){t.d(l,{Z:function(){return Y}});var s=t(57437),a=t(2265),r=t(78489),i=t(47323),n=t(84264),o=t(96761),d=t(19250),c=t(99981),m=t(33866),u=t(15731),h=t(53410),x=t(74998),p=t(59341),g=t(49566),f=t(12514),j=t(97765),v=t(37592),_=t(10032),b=t(22116),y=t(51653),N=t(24199),w=t(12660),Z=t(15424),C=t(58760),k=t(5545),S=t(45246),A=t(96473),E=t(31283),P=e=>{let{value:l={},onChange:t}=e,[r,i]=(0,a.useState)(Object.entries(l)),n=e=>{let l=r.filter((l,t)=>t!==e);i(l),null==t||t(Object.fromEntries(l))},o=(e,l,s)=>{let a=[...r];a[e]=[l,s],i(a),null==t||t(Object.fromEntries(a))};return(0,s.jsxs)("div",{children:[r.map((e,l)=>{let[t,a]=e;return(0,s.jsxs)(C.Z,{style:{display:"flex",marginBottom:8},align:"center",children:[(0,s.jsx)(E.o,{placeholder:"Header Name",value:t,onChange:e=>o(l,e.target.value,a)}),(0,s.jsx)(E.o,{placeholder:"Header Value",value:a,onChange:e=>o(l,t,e.target.value)}),(0,s.jsx)("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",height:"100%"},children:(0,s.jsx)(S.Z,{onClick:()=>n(l),style:{cursor:"pointer"}})})]},l)}),(0,s.jsx)(k.ZP,{type:"dashed",onClick:()=>{i([...r,["",""]])},icon:(0,s.jsx)(A.Z,{}),children:"Add Header"})]})},M=t(77565),L=e=>{let{pathValue:l,targetValue:t,includeSubpath:a}=e,r=(0,d.getProxyBaseUrl)();return l&&t?(0,s.jsxs)(f.Z,{className:"p-5",children:[(0,s.jsx)(o.Z,{className:"text-lg font-semibold text-gray-900 mb-2",children:"Route Preview"}),(0,s.jsx)(j.Z,{className:"text-gray-600 mb-5",children:"How your requests will be routed"}),(0,s.jsxs)("div",{className:"space-y-5",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("div",{className:"text-base font-semibold text-gray-900 mb-3",children:"Basic routing:"}),(0,s.jsxs)("div",{className:"flex items-center gap-4",children:[(0,s.jsxs)("div",{className:"flex-1 bg-gray-50 border border-gray-200 rounded-lg p-3",children:[(0,s.jsx)("div",{className:"text-sm text-gray-600 mb-2",children:"Your endpoint"}),(0,s.jsx)("code",{className:"font-mono text-sm text-gray-900",children:l?"".concat(r).concat(l):""})]}),(0,s.jsx)("div",{className:"text-gray-400",children:(0,s.jsx)(M.Z,{className:"text-lg"})}),(0,s.jsxs)("div",{className:"flex-1 bg-gray-50 border border-gray-200 rounded-lg p-3",children:[(0,s.jsx)("div",{className:"text-sm text-gray-600 mb-2",children:"Forwards to"}),(0,s.jsx)("code",{className:"font-mono text-sm text-gray-900",children:t})]})]})]}),a&&(0,s.jsx)(s.Fragment,{children:(0,s.jsxs)("div",{children:[(0,s.jsx)("div",{className:"text-base font-semibold text-gray-900 mb-3",children:"With subpaths:"}),(0,s.jsxs)("div",{className:"flex items-center gap-4",children:[(0,s.jsxs)("div",{className:"flex-1 bg-gray-50 border border-gray-200 rounded-lg p-3",children:[(0,s.jsx)("div",{className:"text-sm text-gray-600 mb-2",children:"Your endpoint + subpath"}),(0,s.jsxs)("code",{className:"font-mono text-sm text-gray-900",children:[l&&"".concat(r).concat(l),(0,s.jsx)("span",{className:"text-blue-600",children:"/v1/text-to-image/base/model"})]})]}),(0,s.jsx)("div",{className:"text-gray-400",children:(0,s.jsx)(M.Z,{className:"text-lg"})}),(0,s.jsxs)("div",{className:"flex-1 bg-gray-50 border border-gray-200 rounded-lg p-3",children:[(0,s.jsx)("div",{className:"text-sm text-gray-600 mb-2",children:"Forwards to"}),(0,s.jsxs)("code",{className:"font-mono text-sm text-gray-900",children:[t,(0,s.jsx)("span",{className:"text-blue-600",children:"/v1/text-to-image/base/model"})]})]})]}),(0,s.jsxs)("div",{className:"mt-3 text-sm text-gray-600",children:["Any path after ",l," will be appended to the target URL"]})]})}),!a&&(0,s.jsx)("div",{className:"mt-4 p-3 bg-blue-50 rounded-md border border-blue-200",children:(0,s.jsxs)("div",{className:"flex items-start",children:[(0,s.jsx)(Z.Z,{className:"text-blue-500 mt-0.5 mr-2 flex-shrink-0"}),(0,s.jsxs)("div",{className:"text-sm text-blue-700",children:[(0,s.jsx)("span",{className:"font-medium",children:"Not seeing the routing you wanted?"})," Try enabling - Include Subpaths - above - this allows subroutes like"," ",(0,s.jsx)("code",{className:"bg-blue-100 px-1 py-0.5 rounded font-mono text-xs",children:"/api/v1/models"})," to be forwarded automatically."]})]})})]})]}):null},F=t(9114),I=t(63709),T=e=>{let{premiumUser:l,authEnabled:t,onAuthChange:a}=e;return(0,s.jsxs)(f.Z,{className:"p-6",children:[(0,s.jsx)(o.Z,{className:"text-lg font-semibold text-gray-900 mb-2",children:"Security"}),(0,s.jsx)(j.Z,{className:"text-gray-600 mb-4",children:"When enabled, requests to this endpoint will require a valid LiteLLM Virtual Key"}),l?(0,s.jsx)(_.Z.Item,{name:"auth",valuePropName:"checked",className:"mb-0",children:(0,s.jsx)(I.Z,{checked:t,onChange:e=>{a(e)}})}):(0,s.jsxs)("div",{children:[(0,s.jsxs)("div",{className:"flex items-center mb-3",children:[(0,s.jsx)(I.Z,{disabled:!0,checked:!1,style:{outline:"2px solid #d1d5db",outlineOffset:"2px"}}),(0,s.jsx)("span",{className:"ml-2 text-sm text-gray-400",children:"Authentication (Premium)"})]}),(0,s.jsx)("div",{className:"p-3 bg-yellow-50 border border-yellow-200 rounded-lg",children:(0,s.jsxs)(n.Z,{className:"text-sm text-yellow-800",children:["Setting authentication for pass-through endpoints is a LiteLLM Enterprise feature. Get a trial key"," ",(0,s.jsx)("a",{href:"https://www.litellm.ai/#pricing",target:"_blank",rel:"noopener noreferrer",className:"underline",children:"here"}),"."]})})]})]})},R=t(67479),O=e=>{let{accessToken:l,value:t={},onChange:r,disabled:i=!1}=e,[n,d]=(0,a.useState)(Object.keys(t)),[m,u]=(0,a.useState)(t);(0,a.useEffect)(()=>{u(t),d(Object.keys(t))},[t]);let h=(e,l,t)=>{var s,a;let i=m[e]||{},n={...m,[e]:{...i,[l]:t.length>0?t:void 0}};(null===(s=n[e])||void 0===s?void 0:s.request_fields)||(null===(a=n[e])||void 0===a?void 0:a.response_fields)||(n[e]=null),u(n),r&&r(n)};return(0,s.jsxs)(f.Z,{className:"p-6",children:[(0,s.jsx)(o.Z,{className:"text-lg font-semibold text-gray-900 mb-2",children:"Guardrails"}),(0,s.jsx)(j.Z,{className:"text-gray-600 mb-6",children:"Configure guardrails to enforce policies on requests and responses. Guardrails are opt-in for passthrough endpoints."}),(0,s.jsx)(y.Z,{message:(0,s.jsxs)("span",{children:["Field-Level Targeting"," ",(0,s.jsx)("a",{href:"https://docs.litellm.ai/docs/proxy/pass_through_guardrails#field-level-targeting",target:"_blank",rel:"noopener noreferrer",className:"text-blue-600 hover:text-blue-800 underline",children:"(Learn More)"})]}),description:(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsx)("div",{children:"Optionally specify which fields to check. If left empty, the entire request/response is sent to the guardrail."}),(0,s.jsxs)("div",{className:"text-xs space-y-1 mt-2",children:[(0,s.jsx)("div",{className:"font-medium",children:"Common Examples:"}),(0,s.jsxs)("div",{children:["• ",(0,s.jsx)("code",{className:"bg-gray-100 px-1 rounded",children:"query"})," - Single field"]}),(0,s.jsxs)("div",{children:["• ",(0,s.jsx)("code",{className:"bg-gray-100 px-1 rounded",children:"documents[*].text"})," - All text in documents array"]}),(0,s.jsxs)("div",{children:["• ",(0,s.jsx)("code",{className:"bg-gray-100 px-1 rounded",children:"messages[*].content"})," - All message contents"]})]})]}),type:"info",showIcon:!0,className:"mb-4"}),(0,s.jsx)(_.Z.Item,{label:(0,s.jsxs)("span",{className:"text-sm font-medium text-gray-700 flex items-center",children:["Select Guardrails",(0,s.jsx)(c.Z,{title:"Choose which guardrails should run on this endpoint. Org/team/key level guardrails will also be included.",children:(0,s.jsx)(Z.Z,{className:"ml-2 text-blue-400 hover:text-blue-600 cursor-help"})})]}),children:(0,s.jsx)(R.Z,{accessToken:l,value:n,onChange:e=>{d(e);let l={};e.forEach(e=>{l[e]=m[e]||null}),u(l),r&&r(l)},disabled:i})}),n.length>0&&(0,s.jsxs)("div",{className:"mt-6 space-y-4",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between mb-3",children:[(0,s.jsx)("div",{className:"text-sm font-medium text-gray-700",children:"Field Targeting (Optional)"}),(0,s.jsx)("div",{className:"text-xs text-gray-500",children:"\uD83D\uDCA1 Tip: Leave empty to check entire payload"})]}),n.map(e=>{var l,t;return(0,s.jsxs)(f.Z,{className:"p-4 bg-gray-50",children:[(0,s.jsx)("div",{className:"text-sm font-medium text-gray-900 mb-3",children:e}),(0,s.jsxs)("div",{className:"space-y-3",children:[(0,s.jsxs)("div",{children:[(0,s.jsxs)("div",{className:"flex items-center justify-between mb-1",children:[(0,s.jsxs)("label",{className:"text-xs text-gray-600 flex items-center",children:["Request Fields (pre_call)",(0,s.jsx)(c.Z,{title:(0,s.jsxs)("div",{children:[(0,s.jsx)("div",{className:"font-medium mb-1",children:"Specify which request fields to check"}),(0,s.jsxs)("div",{className:"text-xs space-y-1",children:[(0,s.jsx)("div",{children:"Examples:"}),(0,s.jsx)("div",{children:"• query"}),(0,s.jsx)("div",{children:"• documents[*].text"}),(0,s.jsx)("div",{children:"• messages[*].content"})]})]}),children:(0,s.jsx)(Z.Z,{className:"ml-1 text-gray-400"})})]}),(0,s.jsxs)("div",{className:"flex gap-1",children:[(0,s.jsx)("button",{type:"button",onClick:()=>{var l;let t=(null===(l=m[e])||void 0===l?void 0:l.request_fields)||[];h(e,"request_fields",[...t,"query"])},className:"text-xs px-2 py-1 bg-white border border-gray-300 rounded hover:bg-gray-50",disabled:i,children:"+ query"}),(0,s.jsx)("button",{type:"button",onClick:()=>{var l;let t=(null===(l=m[e])||void 0===l?void 0:l.request_fields)||[];h(e,"request_fields",[...t,"documents[*]"])},className:"text-xs px-2 py-1 bg-white border border-gray-300 rounded hover:bg-gray-50",disabled:i,children:"+ documents[*]"})]})]}),(0,s.jsx)(v.default,{mode:"tags",style:{width:"100%"},placeholder:"Type field name or use + buttons above (e.g., query, documents[*].text)",value:(null===(l=m[e])||void 0===l?void 0:l.request_fields)||[],onChange:l=>h(e,"request_fields",l),disabled:i,tokenSeparators:[","]})]}),(0,s.jsxs)("div",{children:[(0,s.jsxs)("div",{className:"flex items-center justify-between mb-1",children:[(0,s.jsxs)("label",{className:"text-xs text-gray-600 flex items-center",children:["Response Fields (post_call)",(0,s.jsx)(c.Z,{title:(0,s.jsxs)("div",{children:[(0,s.jsx)("div",{className:"font-medium mb-1",children:"Specify which response fields to check"}),(0,s.jsxs)("div",{className:"text-xs space-y-1",children:[(0,s.jsx)("div",{children:"Examples:"}),(0,s.jsx)("div",{children:"• results[*].text"}),(0,s.jsx)("div",{children:"• choices[*].message.content"})]})]}),children:(0,s.jsx)(Z.Z,{className:"ml-1 text-gray-400"})})]}),(0,s.jsx)("div",{className:"flex gap-1",children:(0,s.jsx)("button",{type:"button",onClick:()=>{var l;let t=(null===(l=m[e])||void 0===l?void 0:l.response_fields)||[];h(e,"response_fields",[...t,"results[*]"])},className:"text-xs px-2 py-1 bg-white border border-gray-300 rounded hover:bg-gray-50",disabled:i,children:"+ results[*]"})})]}),(0,s.jsx)(v.default,{mode:"tags",style:{width:"100%"},placeholder:"Type field name or use + buttons above (e.g., results[*].text)",value:(null===(t=m[e])||void 0===t?void 0:t.response_fields)||[],onChange:l=>h(e,"response_fields",l),disabled:i,tokenSeparators:[","]})]})]})]},e)})]})]})};let{Option:V}=v.default;var q=e=>{let{accessToken:l,setPassThroughItems:t,passThroughItems:i,premiumUser:n=!1}=e,[m]=_.Z.useForm(),[u,h]=(0,a.useState)(!1),[x,v]=(0,a.useState)(!1),[C,k]=(0,a.useState)(""),[S,A]=(0,a.useState)(""),[E,M]=(0,a.useState)(""),[I,R]=(0,a.useState)(!0),[V,q]=(0,a.useState)(!1),[z,D]=(0,a.useState)({}),B=()=>{m.resetFields(),A(""),M(""),R(!0),D({}),h(!1)},G=e=>{let l=e;e&&!e.startsWith("/")&&(l="/"+e),A(l),m.setFieldsValue({path:l})},U=async e=>{console.log("addPassThrough called with:",e),v(!0);try{!n&&"auth"in e&&delete e.auth,z&&Object.keys(z).length>0&&(e.guardrails=z),console.log("formValues: ".concat(JSON.stringify(e)));let s=(await (0,d.createPassThroughEndpoint)(l,e)).endpoints[0],a=[...i,s];t(a),F.Z.success("Pass-through endpoint created successfully"),m.resetFields(),A(""),M(""),R(!0),D({}),h(!1)}catch(e){F.Z.fromBackend("Error creating pass-through endpoint: "+e)}finally{v(!1)}};return(0,s.jsxs)("div",{children:[(0,s.jsx)(r.Z,{className:"mx-auto mb-4 mt-4",onClick:()=>h(!0),children:"+ Add Pass-Through Endpoint"}),(0,s.jsx)(b.Z,{title:(0,s.jsxs)("div",{className:"flex items-center space-x-3 pb-4 border-b border-gray-100",children:[(0,s.jsx)(w.Z,{className:"text-xl text-blue-500"}),(0,s.jsx)("h2",{className:"text-xl font-semibold text-gray-900",children:"Add Pass-Through Endpoint"})]}),open:u,width:1e3,onCancel:B,footer:null,className:"top-8",styles:{body:{padding:"24px"},header:{padding:"24px 24px 0 24px",border:"none"}},children:(0,s.jsxs)("div",{className:"mt-6",children:[(0,s.jsx)(y.Z,{message:"What is a Pass-Through Endpoint?",description:"Route requests from your LiteLLM proxy to any external API. Perfect for custom models, image generation APIs, or any service you want to proxy through LiteLLM.",type:"info",showIcon:!0,className:"mb-6"}),(0,s.jsxs)(_.Z,{form:m,onFinish:U,layout:"vertical",className:"space-y-6",initialValues:{include_subpath:!0,path:S,target:E},children:[(0,s.jsxs)(f.Z,{className:"p-5",children:[(0,s.jsx)(o.Z,{className:"text-lg font-semibold text-gray-900 mb-2",children:"Route Configuration"}),(0,s.jsx)(j.Z,{className:"text-gray-600 mb-5",children:"Configure how requests to your domain will be forwarded to the target API"}),(0,s.jsxs)("div",{className:"space-y-5",children:[(0,s.jsx)(_.Z.Item,{label:(0,s.jsx)("span",{className:"text-sm font-medium text-gray-700",children:"Path Prefix"}),name:"path",rules:[{required:!0,message:"Path is required",pattern:/^\//}],extra:(0,s.jsx)("div",{className:"text-xs text-gray-500 mt-1",children:"Example: /bria, /adobe-photoshop, /elasticsearch"}),className:"mb-4",children:(0,s.jsx)("div",{className:"flex items-center",children:(0,s.jsx)(g.Z,{placeholder:"bria",value:S,onChange:e=>G(e.target.value),className:"flex-1"})})}),(0,s.jsx)(_.Z.Item,{label:(0,s.jsx)("span",{className:"text-sm font-medium text-gray-700",children:"Target URL"}),name:"target",rules:[{required:!0,message:"Target URL is required"},{type:"url",message:"Please enter a valid URL"}],extra:(0,s.jsx)("div",{className:"text-xs text-gray-500 mt-1",children:"Example:https://engine.prod.bria-api.com"}),className:"mb-4",children:(0,s.jsx)(g.Z,{placeholder:"https://engine.prod.bria-api.com",value:E,onChange:e=>{M(e.target.value),m.setFieldsValue({target:e.target.value})}})}),(0,s.jsxs)("div",{className:"flex items-center justify-between py-3",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("div",{className:"text-sm font-medium text-gray-700",children:"Include Subpaths"}),(0,s.jsx)("div",{className:"text-xs text-gray-500 mt-0.5",children:"Forward all subpaths to the target API (recommended for REST APIs)"})]}),(0,s.jsx)(_.Z.Item,{name:"include_subpath",valuePropName:"checked",className:"mb-0",children:(0,s.jsx)(p.Z,{checked:I,onChange:R})})]})]})]}),(0,s.jsx)(L,{pathValue:S,targetValue:E,includeSubpath:I}),(0,s.jsxs)(f.Z,{className:"p-6",children:[(0,s.jsx)(o.Z,{className:"text-lg font-semibold text-gray-900 mb-2",children:"Headers"}),(0,s.jsx)(j.Z,{className:"text-gray-600 mb-6",children:"Add headers that will be sent with every request to the target API"}),(0,s.jsx)(_.Z.Item,{label:(0,s.jsxs)("span",{className:"text-sm font-medium text-gray-700 flex items-center",children:["Authentication Headers",(0,s.jsx)(c.Z,{title:"Authentication and other headers to forward with requests",children:(0,s.jsx)(Z.Z,{className:"ml-2 text-blue-400 hover:text-blue-600 cursor-help"})})]}),name:"headers",rules:[{required:!0,message:"Please configure the headers"}],extra:(0,s.jsxs)("div",{className:"text-xs text-gray-500 mt-2",children:[(0,s.jsx)("div",{className:"font-medium mb-1",children:"Add authentication tokens and other required headers"}),(0,s.jsx)("div",{children:"Common examples: auth_token, Authorization, x-api-key"})]}),children:(0,s.jsx)(P,{})})]}),(0,s.jsx)(T,{premiumUser:n,authEnabled:V,onAuthChange:e=>{q(e),m.setFieldsValue({auth:e})}}),(0,s.jsx)(O,{accessToken:l,value:z,onChange:D}),(0,s.jsxs)(f.Z,{className:"p-6",children:[(0,s.jsx)(o.Z,{className:"text-lg font-semibold text-gray-900 mb-2",children:"Billing"}),(0,s.jsx)(j.Z,{className:"text-gray-600 mb-6",children:"Optional cost tracking for this endpoint"}),(0,s.jsx)(_.Z.Item,{label:(0,s.jsxs)("span",{className:"text-sm font-medium text-gray-700 flex items-center",children:["Cost Per Request (USD)",(0,s.jsx)(c.Z,{title:"Optional: Track costs for requests to this endpoint",children:(0,s.jsx)(Z.Z,{className:"ml-2 text-gray-400 hover:text-gray-600"})})]}),name:"cost_per_request",extra:(0,s.jsx)("div",{className:"text-xs text-gray-500 mt-2",children:"The cost charged for each request through this endpoint"}),children:(0,s.jsx)(N.Z,{min:0,step:.001,precision:4,placeholder:"2.0000",size:"large"})})]}),(0,s.jsxs)("div",{className:"flex items-center justify-end space-x-3 pt-6 border-t border-gray-100",children:[(0,s.jsx)(r.Z,{variant:"secondary",onClick:B,children:"Cancel"}),(0,s.jsx)(r.Z,{variant:"primary",loading:x,onClick:()=>{console.log("Submit button clicked"),m.submit()},children:x?"Creating...":"Add Pass-Through Endpoint"})]})]})]})})]})},z=t(30078),D=t(4260),B=t(12221),G=t(87769),U=t(42208);let H=e=>{let{value:l}=e,[t,r]=(0,a.useState)(!1),i=JSON.stringify(l,null,2);return(0,s.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,s.jsx)("pre",{className:"font-mono text-xs bg-gray-50 p-2 rounded max-w-md overflow-auto",children:t?i:"••••••••"}),(0,s.jsx)("button",{onClick:()=>r(!t),className:"p-1 hover:bg-gray-100 rounded",type:"button",children:t?(0,s.jsx)(G.Z,{className:"w-4 h-4 text-gray-500"}):(0,s.jsx)(U.Z,{className:"w-4 h-4 text-gray-500"})})]})};var K=e=>{let{endpointData:l,onClose:t,accessToken:r,isAdmin:i,premiumUser:n=!1,onEndpointUpdated:o}=e,[c,m]=(0,a.useState)(l),[u,h]=(0,a.useState)(!1),[x,p]=(0,a.useState)(!1),[g,f]=(0,a.useState)((null==l?void 0:l.auth)||!1),[j,v]=(0,a.useState)((null==l?void 0:l.guardrails)||{}),[b]=_.Z.useForm(),y=async e=>{try{if(!r||!(null==c?void 0:c.id))return;let l={};if(e.headers)try{l="string"==typeof e.headers?JSON.parse(e.headers):e.headers}catch(e){F.Z.fromBackend("Invalid JSON format for headers");return}let t={path:c.path,target:e.target,headers:l,include_subpath:e.include_subpath,cost_per_request:e.cost_per_request,auth:n?e.auth:void 0,guardrails:j&&Object.keys(j).length>0?j:void 0};await (0,d.updatePassThroughEndpoint)(r,c.id,t),m({...c,...t}),p(!1),o&&o()}catch(e){console.error("Error updating endpoint:",e),F.Z.fromBackend("Failed to update pass through endpoint")}},N=async()=>{try{if(!r||!(null==c?void 0:c.id))return;await (0,d.deletePassThroughEndpointsCall)(r,c.id),F.Z.success("Pass through endpoint deleted successfully"),t(),o&&o()}catch(e){console.error("Error deleting endpoint:",e),F.Z.fromBackend("Failed to delete pass through endpoint")}};return u?(0,s.jsx)("div",{className:"p-4",children:"Loading..."}):c?(0,s.jsxs)("div",{className:"p-4",children:[(0,s.jsx)("div",{className:"flex justify-between items-center mb-6",children:(0,s.jsxs)("div",{children:[(0,s.jsx)(k.ZP,{onClick:t,className:"mb-4",children:"← Back"}),(0,s.jsxs)(z.Dx,{children:["Pass Through Endpoint: ",c.path]}),(0,s.jsx)(z.xv,{className:"text-gray-500 font-mono",children:c.id})]})}),(0,s.jsxs)(z.v0,{children:[(0,s.jsxs)(z.td,{className:"mb-4",children:[(0,s.jsx)(z.OK,{children:"Overview"},"overview"),i?(0,s.jsx)(z.OK,{children:"Settings"},"settings"):(0,s.jsx)(s.Fragment,{})]}),(0,s.jsxs)(z.nP,{children:[(0,s.jsxs)(z.x4,{children:[(0,s.jsxs)(z.rj,{numItems:1,numItemsSm:2,numItemsLg:3,className:"gap-6",children:[(0,s.jsxs)(z.Zb,{children:[(0,s.jsx)(z.xv,{children:"Path"}),(0,s.jsx)("div",{className:"mt-2",children:(0,s.jsx)(z.Dx,{className:"font-mono",children:c.path})})]}),(0,s.jsxs)(z.Zb,{children:[(0,s.jsx)(z.xv,{children:"Target"}),(0,s.jsx)("div",{className:"mt-2",children:(0,s.jsx)(z.Dx,{children:c.target})})]}),(0,s.jsxs)(z.Zb,{children:[(0,s.jsx)(z.xv,{children:"Configuration"}),(0,s.jsxs)("div",{className:"mt-2 space-y-2",children:[(0,s.jsx)("div",{children:(0,s.jsx)(z.Ct,{color:c.include_subpath?"green":"gray",children:c.include_subpath?"Include Subpath":"Exact Path"})}),(0,s.jsx)("div",{children:(0,s.jsx)(z.Ct,{color:c.auth?"blue":"gray",children:c.auth?"Auth Required":"No Auth"})}),void 0!==c.cost_per_request&&(0,s.jsx)("div",{children:(0,s.jsxs)(z.xv,{children:["Cost per request: $",c.cost_per_request]})})]})]})]}),(0,s.jsx)("div",{className:"mt-6",children:(0,s.jsx)(L,{pathValue:c.path,targetValue:c.target,includeSubpath:c.include_subpath||!1})}),c.headers&&Object.keys(c.headers).length>0&&(0,s.jsxs)(z.Zb,{className:"mt-6",children:[(0,s.jsxs)("div",{className:"flex justify-between items-center",children:[(0,s.jsx)(z.xv,{className:"font-medium",children:"Headers"}),(0,s.jsxs)(z.Ct,{color:"blue",children:[Object.keys(c.headers).length," headers configured"]})]}),(0,s.jsx)("div",{className:"mt-4",children:(0,s.jsx)(H,{value:c.headers})})]}),c.guardrails&&Object.keys(c.guardrails).length>0&&(0,s.jsxs)(z.Zb,{className:"mt-6",children:[(0,s.jsxs)("div",{className:"flex justify-between items-center",children:[(0,s.jsx)(z.xv,{className:"font-medium",children:"Guardrails"}),(0,s.jsxs)(z.Ct,{color:"purple",children:[Object.keys(c.guardrails).length," guardrails configured"]})]}),(0,s.jsx)("div",{className:"mt-4 space-y-2",children:Object.entries(c.guardrails).map(e=>{let[l,t]=e;return(0,s.jsxs)("div",{className:"p-3 bg-gray-50 rounded",children:[(0,s.jsx)("div",{className:"font-medium text-sm",children:l}),t&&(t.request_fields||t.response_fields)&&(0,s.jsxs)("div",{className:"mt-2 text-xs text-gray-600 space-y-1",children:[t.request_fields&&(0,s.jsxs)("div",{children:["Request fields: ",t.request_fields.join(", ")]}),t.response_fields&&(0,s.jsxs)("div",{children:["Response fields: ",t.response_fields.join(", ")]})]}),!t&&(0,s.jsx)("div",{className:"text-xs text-gray-600 mt-1",children:"Uses entire payload"})]},l)})})]})]}),i&&(0,s.jsx)(z.x4,{children:(0,s.jsxs)(z.Zb,{children:[(0,s.jsxs)("div",{className:"flex justify-between items-center mb-4",children:[(0,s.jsx)(z.Dx,{children:"Pass Through Endpoint Settings"}),(0,s.jsx)("div",{className:"space-x-2",children:!x&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(z.zx,{onClick:()=>p(!0),children:"Edit Settings"}),(0,s.jsx)(z.zx,{onClick:N,variant:"secondary",color:"red",children:"Delete Endpoint"})]})})]}),x?(0,s.jsxs)(_.Z,{form:b,onFinish:y,initialValues:{target:c.target,headers:c.headers?JSON.stringify(c.headers,null,2):"",include_subpath:c.include_subpath||!1,cost_per_request:c.cost_per_request,auth:c.auth||!1},layout:"vertical",children:[(0,s.jsx)(_.Z.Item,{label:"Target URL",name:"target",rules:[{required:!0,message:"Please input a target URL"}],children:(0,s.jsx)(z.oi,{placeholder:"https://api.example.com"})}),(0,s.jsx)(_.Z.Item,{label:"Headers (JSON)",name:"headers",children:(0,s.jsx)(D.default.TextArea,{rows:5,placeholder:'{"Authorization": "Bearer your-token", "Content-Type": "application/json"}'})}),(0,s.jsx)(_.Z.Item,{label:"Include Subpath",name:"include_subpath",valuePropName:"checked",children:(0,s.jsx)(I.Z,{})}),(0,s.jsx)(_.Z.Item,{label:"Cost per Request",name:"cost_per_request",children:(0,s.jsx)(B.Z,{min:0,step:.01,precision:2,placeholder:"0.00",addonBefore:"$"})}),(0,s.jsx)(T,{premiumUser:n,authEnabled:g,onAuthChange:e=>{f(e),b.setFieldsValue({auth:e})}}),(0,s.jsx)("div",{className:"mt-4",children:(0,s.jsx)(O,{accessToken:r||"",value:j,onChange:v})}),(0,s.jsxs)("div",{className:"flex justify-end gap-2 mt-6",children:[(0,s.jsx)(k.ZP,{onClick:()=>p(!1),children:"Cancel"}),(0,s.jsx)(z.zx,{children:"Save Changes"})]})]}):(0,s.jsxs)("div",{className:"space-y-4",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)(z.xv,{className:"font-medium",children:"Path"}),(0,s.jsx)("div",{className:"font-mono",children:c.path})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)(z.xv,{className:"font-medium",children:"Target URL"}),(0,s.jsx)("div",{children:c.target})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)(z.xv,{className:"font-medium",children:"Include Subpath"}),(0,s.jsx)(z.Ct,{color:c.include_subpath?"green":"gray",children:c.include_subpath?"Yes":"No"})]}),void 0!==c.cost_per_request&&(0,s.jsxs)("div",{children:[(0,s.jsx)(z.xv,{className:"font-medium",children:"Cost per Request"}),(0,s.jsxs)("div",{children:["$",c.cost_per_request]})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)(z.xv,{className:"font-medium",children:"Authentication Required"}),(0,s.jsx)(z.Ct,{color:c.auth?"green":"gray",children:c.auth?"Yes":"No"})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)(z.xv,{className:"font-medium",children:"Headers"}),c.headers&&Object.keys(c.headers).length>0?(0,s.jsx)("div",{className:"mt-2",children:(0,s.jsx)(H,{value:c.headers})}):(0,s.jsx)("div",{className:"text-gray-500",children:"No headers configured"})]})]})]})})]})]})]}):(0,s.jsx)("div",{className:"p-4",children:"Pass through endpoint not found"})},J=t(12322);let W=e=>{let{value:l}=e,[t,r]=(0,a.useState)(!1),i=JSON.stringify(l);return(0,s.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,s.jsx)("span",{className:"font-mono text-xs",children:t?i:"••••••••"}),(0,s.jsx)("button",{onClick:()=>r(!t),className:"p-1 hover:bg-gray-100 rounded",type:"button",children:t?(0,s.jsx)(G.Z,{className:"w-4 h-4 text-gray-500"}):(0,s.jsx)(U.Z,{className:"w-4 h-4 text-gray-500"})})]})};var Y=e=>{let{accessToken:l,userRole:t,userID:p,modelData:g,premiumUser:f}=e,[j,v]=(0,a.useState)([]),[_,b]=(0,a.useState)(null),[y,N]=(0,a.useState)(!1),[w,Z]=(0,a.useState)(null);(0,a.useEffect)(()=>{l&&t&&p&&(0,d.getPassThroughEndpointsCall)(l).then(e=>{v(e.endpoints)})},[l,t,p]);let C=async e=>{Z(e),N(!0)},k=async()=>{if(null!=w&&l){try{await (0,d.deletePassThroughEndpointsCall)(l,w);let e=j.filter(e=>e.id!==w);v(e),F.Z.success("Endpoint deleted successfully.")}catch(e){console.error("Error deleting the endpoint:",e),F.Z.fromBackend("Error deleting the endpoint: "+e)}N(!1),Z(null)}},S=(e,l)=>{C(e)},A=[{header:"ID",accessorKey:"id",cell:e=>(0,s.jsx)(c.Z,{title:e.row.original.id,children:(0,s.jsx)("div",{className:"font-mono text-blue-500 bg-blue-50 hover:bg-blue-100 text-xs font-normal px-2 py-0.5 text-left w-full truncate whitespace-nowrap cursor-pointer max-w-[15ch]",onClick:()=>e.row.original.id&&b(e.row.original.id),children:e.row.original.id})})},{header:"Path",accessorKey:"path"},{header:"Target",accessorKey:"target",cell:e=>(0,s.jsx)(n.Z,{children:e.getValue()})},{header:()=>(0,s.jsxs)("div",{className:"flex items-center gap-1",children:[(0,s.jsx)("span",{children:"Authentication"}),(0,s.jsx)(c.Z,{title:"LiteLLM Virtual Key required to call endpoint",children:(0,s.jsx)(u.Z,{className:"w-4 h-4 text-gray-400 cursor-help"})})]}),accessorKey:"auth",cell:e=>(0,s.jsx)(m.Z,{color:e.getValue()?"green":"gray",children:e.getValue()?"Yes":"No"})},{header:"Headers",accessorKey:"headers",cell:e=>(0,s.jsx)(W,{value:e.getValue()||{}})},{header:"Actions",id:"actions",cell:e=>{let{row:l}=e;return(0,s.jsxs)("div",{className:"flex space-x-1",children:[(0,s.jsx)(i.Z,{icon:h.Z,size:"sm",onClick:()=>l.original.id&&b(l.original.id),title:"Edit"}),(0,s.jsx)(i.Z,{icon:x.Z,size:"sm",onClick:()=>S(l.original.id,l.index),title:"Delete"})]})}}];if(!l)return null;if(_){console.log("selectedEndpointId",_),console.log("generalSettings",j);let e=j.find(e=>e.id===_);return e?(0,s.jsx)(K,{endpointData:e,onClose:()=>b(null),accessToken:l,isAdmin:"Admin"===t||"admin"===t,premiumUser:f,onEndpointUpdated:()=>{l&&(0,d.getPassThroughEndpointsCall)(l).then(e=>{v(e.endpoints)})}}):(0,s.jsx)("div",{children:"Endpoint not found"})}return(0,s.jsxs)("div",{children:[(0,s.jsxs)("div",{children:[(0,s.jsx)(o.Z,{children:"Pass Through Endpoints"}),(0,s.jsx)(n.Z,{className:"text-tremor-content",children:"Configure and manage your pass-through endpoints"})]}),(0,s.jsx)(q,{accessToken:l,setPassThroughItems:v,passThroughItems:j,premiumUser:f}),(0,s.jsx)(J.w,{data:j,columns:A,renderSubComponent:()=>(0,s.jsx)("div",{}),getRowCanExpand:()=>!1,isLoading:!1,noDataMessage:"No pass-through endpoints configured"}),y&&(0,s.jsx)("div",{className:"fixed z-10 inset-0 overflow-y-auto",children:(0,s.jsxs)("div",{className:"flex items-end justify-center min-h-screen pt-4 px-4 pb-20 text-center sm:block sm:p-0",children:[(0,s.jsx)("div",{className:"fixed inset-0 transition-opacity","aria-hidden":"true",children:(0,s.jsx)("div",{className:"absolute inset-0 bg-gray-500 opacity-75"})}),(0,s.jsx)("span",{className:"hidden sm:inline-block sm:align-middle sm:h-screen","aria-hidden":"true",children:"​"}),(0,s.jsxs)("div",{className:"inline-block align-bottom bg-white rounded-lg text-left overflow-hidden shadow-xl transform transition-all sm:my-8 sm:align-middle sm:max-w-lg sm:w-full",children:[(0,s.jsx)("div",{className:"bg-white px-4 pt-5 pb-4 sm:p-6 sm:pb-4",children:(0,s.jsx)("div",{className:"sm:flex sm:items-start",children:(0,s.jsxs)("div",{className:"mt-3 text-center sm:mt-0 sm:ml-4 sm:text-left",children:[(0,s.jsx)("h3",{className:"text-lg leading-6 font-medium text-gray-900",children:"Delete Pass-Through Endpoint"}),(0,s.jsx)("div",{className:"mt-2",children:(0,s.jsx)("p",{className:"text-sm text-gray-500",children:"Are you sure you want to delete this pass-through endpoint? This action cannot be undone."})})]})})}),(0,s.jsxs)("div",{className:"bg-gray-50 px-4 py-3 sm:px-6 sm:flex sm:flex-row-reverse",children:[(0,s.jsx)(r.Z,{onClick:k,color:"red",className:"ml-2",children:"Delete"}),(0,s.jsx)(r.Z,{onClick:()=>{N(!1),Z(null)},children:"Cancel"})]})]})]})})]})}},12322:function(e,l,t){t.d(l,{w:function(){return o}});var s=t(57437),a=t(2265),r=t(71594),i=t(24525),n=t(19130);function o(e){let{data:l=[],columns:t,onRowClick:o,renderSubComponent:d,getRowCanExpand:c,isLoading:m=!1,loadingMessage:u="\uD83D\uDE85 Loading logs...",noDataMessage:h="No logs found"}=e,x=!!d&&!!c,p=(0,r.b7)({data:l,columns:t,...x&&{getRowCanExpand:c},getRowId:(e,l)=>{var t;return null!==(t=null==e?void 0:e.request_id)&&void 0!==t?t:String(l)},getCoreRowModel:(0,i.sC)(),...x&&{getExpandedRowModel:(0,i.rV)()}});return(0,s.jsx)("div",{className:"rounded-lg custom-border overflow-x-auto w-full max-w-full box-border",children:(0,s.jsxs)(n.iA,{className:"[&_td]:py-0.5 [&_th]:py-1 table-fixed w-full box-border",style:{minWidth:"400px"},children:[(0,s.jsx)(n.ss,{children:p.getHeaderGroups().map(e=>(0,s.jsx)(n.SC,{children:e.headers.map(e=>(0,s.jsx)(n.xs,{className:"py-1 h-8",children:e.isPlaceholder?null:(0,r.ie)(e.column.columnDef.header,e.getContext())},e.id))},e.id))}),(0,s.jsx)(n.RM,{children:m?(0,s.jsx)(n.SC,{children:(0,s.jsx)(n.pj,{colSpan:t.length,className:"h-8 text-center",children:(0,s.jsx)("div",{className:"text-center text-gray-500",children:(0,s.jsx)("p",{children:u})})})}):p.getRowModel().rows.length>0?p.getRowModel().rows.map(e=>(0,s.jsxs)(a.Fragment,{children:[(0,s.jsx)(n.SC,{className:"h-8 ".concat(x?"":"cursor-pointer hover:bg-gray-50"),onClick:()=>!x&&(null==o?void 0:o(e.original)),children:e.getVisibleCells().map(e=>(0,s.jsx)(n.pj,{className:"py-0.5 max-h-8 overflow-hidden text-ellipsis whitespace-nowrap",children:(0,r.ie)(e.column.columnDef.cell,e.getContext())},e.id))}),x&&e.getIsExpanded()&&d&&(0,s.jsx)(n.SC,{children:(0,s.jsx)(n.pj,{colSpan:e.getVisibleCells().length,className:"p-0",children:(0,s.jsx)("div",{className:"w-full max-w-full overflow-hidden box-border",children:d({row:e})})})})]},e.id)):(0,s.jsx)(n.SC,{children:(0,s.jsx)(n.pj,{colSpan:t.length,className:"h-8 text-center",children:(0,s.jsx)("div",{className:"text-center text-gray-500",children:(0,s.jsx)("p",{children:h})})})})})]})})}}}]); \ No newline at end of file diff --git a/litellm/proxy/_experimental/out/_next/static/chunks/16adfc735b73e561.js b/litellm/proxy/_experimental/out/_next/static/chunks/16adfc735b73e561.js new file mode 100644 index 00000000000..34a84ca958a --- /dev/null +++ b/litellm/proxy/_experimental/out/_next/static/chunks/16adfc735b73e561.js @@ -0,0 +1,2 @@ +(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,434626,e=>{"use strict";var t=e.i(271645);let r=t.forwardRef(function(e,r){return t.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:2,stroke:"currentColor","aria-hidden":"true",ref:r},e),t.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M10 6H6a2 2 0 00-2 2v10a2 2 0 002 2h10a2 2 0 002-2v-4M14 4h6m0 0v6m0-6L10 14"}))});e.s(["ExternalLinkIcon",0,r],434626)},902555,e=>{"use strict";var t=e.i(843476),r=e.i(591935),o=e.i(122577),n=e.i(278587),i=e.i(68155),a=e.i(360820),s=e.i(871943),l=e.i(434626),c=e.i(592968),u=e.i(115504),d=e.i(752978);function m({icon:e,onClick:r,className:o,disabled:n,dataTestId:i}){return n?(0,t.jsx)(d.Icon,{icon:e,size:"sm",className:"opacity-50 cursor-not-allowed","data-testid":i}):(0,t.jsx)(d.Icon,{icon:e,size:"sm",onClick:r,className:(0,u.cx)("cursor-pointer",o),"data-testid":i})}let p={Edit:{icon:r.PencilAltIcon,className:"hover:text-blue-600"},Delete:{icon:i.TrashIcon,className:"hover:text-red-600"},Test:{icon:o.PlayIcon,className:"hover:text-blue-600"},Regenerate:{icon:n.RefreshIcon,className:"hover:text-green-600"},Up:{icon:a.ChevronUpIcon,className:"hover:text-blue-600"},Down:{icon:s.ChevronDownIcon,className:"hover:text-blue-600"},Open:{icon:l.ExternalLinkIcon,className:"hover:text-green-600"}};function g({onClick:e,tooltipText:r,disabled:o=!1,disabledTooltipText:n,dataTestId:i,variant:a}){let{icon:s,className:l}=p[a];return(0,t.jsx)(c.Tooltip,{title:o?n:r,children:(0,t.jsx)("span",{children:(0,t.jsx)(m,{icon:s,onClick:e,className:l,disabled:o,dataTestId:i})})})}e.s(["default",()=>g],902555)},122577,e=>{"use strict";var t=e.i(271645);let r=t.forwardRef(function(e,r){return t.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:2,stroke:"currentColor","aria-hidden":"true",ref:r},e),t.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M14.752 11.168l-3.197-2.132A1 1 0 0010 9.87v4.263a1 1 0 001.555.832l3.197-2.132a1 1 0 000-1.664z"}),t.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M21 12a9 9 0 11-18 0 9 9 0 0118 0z"}))});e.s(["PlayIcon",0,r],122577)},207670,e=>{"use strict";function t(){for(var e,t,r=0,o="",n=arguments.length;rt,"default",0,t])},728889,e=>{"use strict";var t=e.i(290571),r=e.i(271645),o=e.i(829087),n=e.i(480731),i=e.i(444755),a=e.i(673706),s=e.i(95779);let l={xs:{paddingX:"px-1.5",paddingY:"py-1.5"},sm:{paddingX:"px-1.5",paddingY:"py-1.5"},md:{paddingX:"px-2",paddingY:"py-2"},lg:{paddingX:"px-2",paddingY:"py-2"},xl:{paddingX:"px-2.5",paddingY:"py-2.5"}},c={xs:{height:"h-3",width:"w-3"},sm:{height:"h-5",width:"w-5"},md:{height:"h-5",width:"w-5"},lg:{height:"h-7",width:"w-7"},xl:{height:"h-9",width:"w-9"}},u={simple:{rounded:"",border:"",ring:"",shadow:""},light:{rounded:"rounded-tremor-default",border:"",ring:"",shadow:""},shadow:{rounded:"rounded-tremor-default",border:"border",ring:"",shadow:"shadow-tremor-card dark:shadow-dark-tremor-card"},solid:{rounded:"rounded-tremor-default",border:"border-2",ring:"ring-1",shadow:""},outlined:{rounded:"rounded-tremor-default",border:"border",ring:"ring-2",shadow:""}},d=(0,a.makeClassName)("Icon"),m=r.default.forwardRef((e,m)=>{let{icon:p,variant:g="simple",tooltip:f,size:h=n.Sizes.SM,color:b,className:v}=e,y=(0,t.__rest)(e,["icon","variant","tooltip","size","color","className"]),C=((e,t)=>{switch(e){case"simple":return{textColor:t?(0,a.getColorClassNames)(t,s.colorPalette.text).textColor:"text-tremor-brand dark:text-dark-tremor-brand",bgColor:"",borderColor:"",ringColor:""};case"light":return{textColor:t?(0,a.getColorClassNames)(t,s.colorPalette.text).textColor:"text-tremor-brand dark:text-dark-tremor-brand",bgColor:t?(0,i.tremorTwMerge)((0,a.getColorClassNames)(t,s.colorPalette.background).bgColor,"bg-opacity-20"):"bg-tremor-brand-muted dark:bg-dark-tremor-brand-muted",borderColor:"",ringColor:""};case"shadow":return{textColor:t?(0,a.getColorClassNames)(t,s.colorPalette.text).textColor:"text-tremor-brand dark:text-dark-tremor-brand",bgColor:t?(0,i.tremorTwMerge)((0,a.getColorClassNames)(t,s.colorPalette.background).bgColor,"bg-opacity-20"):"bg-tremor-background dark:bg-dark-tremor-background",borderColor:"border-tremor-border dark:border-dark-tremor-border",ringColor:""};case"solid":return{textColor:t?(0,a.getColorClassNames)(t,s.colorPalette.text).textColor:"text-tremor-brand-inverted dark:text-dark-tremor-brand-inverted",bgColor:t?(0,i.tremorTwMerge)((0,a.getColorClassNames)(t,s.colorPalette.background).bgColor,"bg-opacity-20"):"bg-tremor-brand dark:bg-dark-tremor-brand",borderColor:"border-tremor-brand-inverted dark:border-dark-tremor-brand-inverted",ringColor:"ring-tremor-ring dark:ring-dark-tremor-ring"};case"outlined":return{textColor:t?(0,a.getColorClassNames)(t,s.colorPalette.text).textColor:"text-tremor-brand dark:text-dark-tremor-brand",bgColor:t?(0,i.tremorTwMerge)((0,a.getColorClassNames)(t,s.colorPalette.background).bgColor,"bg-opacity-20"):"bg-tremor-background dark:bg-dark-tremor-background",borderColor:t?(0,a.getColorClassNames)(t,s.colorPalette.ring).borderColor:"border-tremor-brand-subtle dark:border-dark-tremor-brand-subtle",ringColor:t?(0,i.tremorTwMerge)((0,a.getColorClassNames)(t,s.colorPalette.ring).ringColor,"ring-opacity-40"):"ring-tremor-brand-muted dark:ring-dark-tremor-brand-muted"}}})(g,b),{tooltipProps:x,getReferenceProps:w}=(0,o.useTooltip)();return r.default.createElement("span",Object.assign({ref:(0,a.mergeRefs)([m,x.refs.setReference]),className:(0,i.tremorTwMerge)(d("root"),"inline-flex shrink-0 items-center justify-center",C.bgColor,C.textColor,C.borderColor,C.ringColor,u[g].rounded,u[g].border,u[g].shadow,u[g].ring,l[h].paddingX,l[h].paddingY,v)},w,y),r.default.createElement(o.default,Object.assign({text:f},x)),r.default.createElement(p,{className:(0,i.tremorTwMerge)(d("icon"),"shrink-0",c[h].height,c[h].width)}))});m.displayName="Icon",e.s(["default",()=>m],728889)},752978,e=>{"use strict";var t=e.i(728889);e.s(["Icon",()=>t.default])},591935,e=>{"use strict";var t=e.i(271645);let r=t.forwardRef(function(e,r){return t.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:2,stroke:"currentColor","aria-hidden":"true",ref:r},e),t.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z"}))});e.s(["PencilAltIcon",0,r],591935)},350967,46757,e=>{"use strict";var t=e.i(290571),r=e.i(444755),o=e.i(673706),n=e.i(271645);let i={0:"grid-cols-none",1:"grid-cols-1",2:"grid-cols-2",3:"grid-cols-3",4:"grid-cols-4",5:"grid-cols-5",6:"grid-cols-6",7:"grid-cols-7",8:"grid-cols-8",9:"grid-cols-9",10:"grid-cols-10",11:"grid-cols-11",12:"grid-cols-12"},a={0:"sm:grid-cols-none",1:"sm:grid-cols-1",2:"sm:grid-cols-2",3:"sm:grid-cols-3",4:"sm:grid-cols-4",5:"sm:grid-cols-5",6:"sm:grid-cols-6",7:"sm:grid-cols-7",8:"sm:grid-cols-8",9:"sm:grid-cols-9",10:"sm:grid-cols-10",11:"sm:grid-cols-11",12:"sm:grid-cols-12"},s={0:"md:grid-cols-none",1:"md:grid-cols-1",2:"md:grid-cols-2",3:"md:grid-cols-3",4:"md:grid-cols-4",5:"md:grid-cols-5",6:"md:grid-cols-6",7:"md:grid-cols-7",8:"md:grid-cols-8",9:"md:grid-cols-9",10:"md:grid-cols-10",11:"md:grid-cols-11",12:"md:grid-cols-12"},l={0:"lg:grid-cols-none",1:"lg:grid-cols-1",2:"lg:grid-cols-2",3:"lg:grid-cols-3",4:"lg:grid-cols-4",5:"lg:grid-cols-5",6:"lg:grid-cols-6",7:"lg:grid-cols-7",8:"lg:grid-cols-8",9:"lg:grid-cols-9",10:"lg:grid-cols-10",11:"lg:grid-cols-11",12:"lg:grid-cols-12"},c={1:"col-span-1",2:"col-span-2",3:"col-span-3",4:"col-span-4",5:"col-span-5",6:"col-span-6",7:"col-span-7",8:"col-span-8",9:"col-span-9",10:"col-span-10",11:"col-span-11",12:"col-span-12",13:"col-span-13"},u={1:"sm:col-span-1",2:"sm:col-span-2",3:"sm:col-span-3",4:"sm:col-span-4",5:"sm:col-span-5",6:"sm:col-span-6",7:"sm:col-span-7",8:"sm:col-span-8",9:"sm:col-span-9",10:"sm:col-span-10",11:"sm:col-span-11",12:"sm:col-span-12",13:"sm:col-span-13"},d={1:"md:col-span-1",2:"md:col-span-2",3:"md:col-span-3",4:"md:col-span-4",5:"md:col-span-5",6:"md:col-span-6",7:"md:col-span-7",8:"md:col-span-8",9:"md:col-span-9",10:"md:col-span-10",11:"md:col-span-11",12:"md:col-span-12",13:"md:col-span-13"},m={1:"lg:col-span-1",2:"lg:col-span-2",3:"lg:col-span-3",4:"lg:col-span-4",5:"lg:col-span-5",6:"lg:col-span-6",7:"lg:col-span-7",8:"lg:col-span-8",9:"lg:col-span-9",10:"lg:col-span-10",11:"lg:col-span-11",12:"lg:col-span-12",13:"lg:col-span-13"};e.s(["colSpan",()=>c,"colSpanLg",()=>m,"colSpanMd",()=>d,"colSpanSm",()=>u,"gridCols",()=>i,"gridColsLg",()=>l,"gridColsMd",()=>s,"gridColsSm",()=>a],46757);let p=(0,o.makeClassName)("Grid"),g=(e,t)=>e&&Object.keys(t).includes(String(e))?t[e]:"",f=n.default.forwardRef((e,o)=>{let{numItems:c=1,numItemsSm:u,numItemsMd:d,numItemsLg:m,children:f,className:h}=e,b=(0,t.__rest)(e,["numItems","numItemsSm","numItemsMd","numItemsLg","children","className"]),v=g(c,i),y=g(u,a),C=g(d,s),x=g(m,l),w=(0,r.tremorTwMerge)(v,y,C,x);return n.default.createElement("div",Object.assign({ref:o,className:(0,r.tremorTwMerge)(p("root"),"grid",w,h)},b),f)});f.displayName="Grid",e.s(["Grid",()=>f],350967)},244451,e=>{"use strict";let t;e.i(247167);var r=e.i(271645),o=e.i(343794),n=e.i(242064),i=e.i(763731),a=e.i(174428);let s=80*Math.PI,l=e=>{let{dotClassName:t,style:n,hasCircleCls:i}=e;return r.createElement("circle",{className:(0,o.default)(`${t}-circle`,{[`${t}-circle-bg`]:i}),r:40,cx:50,cy:50,strokeWidth:20,style:n})},c=({percent:e,prefixCls:t})=>{let n=`${t}-dot`,i=`${n}-holder`,c=`${i}-hidden`,[u,d]=r.useState(!1);(0,a.default)(()=>{0!==e&&d(!0)},[0!==e]);let m=Math.max(Math.min(e,100),0);if(!u)return null;let p={strokeDashoffset:`${s/4}`,strokeDasharray:`${s*m/100} ${s*(100-m)/100}`};return r.createElement("span",{className:(0,o.default)(i,`${n}-progress`,m<=0&&c)},r.createElement("svg",{viewBox:"0 0 100 100",role:"progressbar","aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":m},r.createElement(l,{dotClassName:n,hasCircleCls:!0}),r.createElement(l,{dotClassName:n,style:p})))};function u(e){let{prefixCls:t,percent:n=0}=e,i=`${t}-dot`,a=`${i}-holder`,s=`${a}-hidden`;return r.createElement(r.Fragment,null,r.createElement("span",{className:(0,o.default)(a,n>0&&s)},r.createElement("span",{className:(0,o.default)(i,`${t}-dot-spin`)},[1,2,3,4].map(e=>r.createElement("i",{className:`${t}-dot-item`,key:e})))),r.createElement(c,{prefixCls:t,percent:n}))}function d(e){var t;let{prefixCls:n,indicator:a,percent:s}=e,l=`${n}-dot`;return a&&r.isValidElement(a)?(0,i.cloneElement)(a,{className:(0,o.default)(null==(t=a.props)?void 0:t.className,l),percent:s}):r.createElement(u,{prefixCls:n,percent:s})}e.i(296059);var m=e.i(694758),p=e.i(183293),g=e.i(246422),f=e.i(838378);let h=new m.Keyframes("antSpinMove",{to:{opacity:1}}),b=new m.Keyframes("antRotate",{to:{transform:"rotate(405deg)"}}),v=(0,g.genStyleHooks)("Spin",e=>(e=>{let{componentCls:t,calc:r}=e;return{[t]:Object.assign(Object.assign({},(0,p.resetComponent)(e)),{position:"absolute",display:"none",color:e.colorPrimary,fontSize:0,textAlign:"center",verticalAlign:"middle",opacity:0,transition:`transform ${e.motionDurationSlow} ${e.motionEaseInOutCirc}`,"&-spinning":{position:"relative",display:"inline-block",opacity:1},[`${t}-text`]:{fontSize:e.fontSize,paddingTop:r(r(e.dotSize).sub(e.fontSize)).div(2).add(2).equal()},"&-fullscreen":{position:"fixed",width:"100vw",height:"100vh",backgroundColor:e.colorBgMask,zIndex:e.zIndexPopupBase,inset:0,display:"flex",alignItems:"center",flexDirection:"column",justifyContent:"center",opacity:0,visibility:"hidden",transition:`all ${e.motionDurationMid}`,"&-show":{opacity:1,visibility:"visible"},[t]:{[`${t}-dot-holder`]:{color:e.colorWhite},[`${t}-text`]:{color:e.colorTextLightSolid}}},"&-nested-loading":{position:"relative",[`> div > ${t}`]:{position:"absolute",top:0,insetInlineStart:0,zIndex:4,display:"block",width:"100%",height:"100%",maxHeight:e.contentHeight,[`${t}-dot`]:{position:"absolute",top:"50%",insetInlineStart:"50%",margin:r(e.dotSize).mul(-1).div(2).equal()},[`${t}-text`]:{position:"absolute",top:"50%",width:"100%",textShadow:`0 1px 2px ${e.colorBgContainer}`},[`&${t}-show-text ${t}-dot`]:{marginTop:r(e.dotSize).div(2).mul(-1).sub(10).equal()},"&-sm":{[`${t}-dot`]:{margin:r(e.dotSizeSM).mul(-1).div(2).equal()},[`${t}-text`]:{paddingTop:r(r(e.dotSizeSM).sub(e.fontSize)).div(2).add(2).equal()},[`&${t}-show-text ${t}-dot`]:{marginTop:r(e.dotSizeSM).div(2).mul(-1).sub(10).equal()}},"&-lg":{[`${t}-dot`]:{margin:r(e.dotSizeLG).mul(-1).div(2).equal()},[`${t}-text`]:{paddingTop:r(r(e.dotSizeLG).sub(e.fontSize)).div(2).add(2).equal()},[`&${t}-show-text ${t}-dot`]:{marginTop:r(e.dotSizeLG).div(2).mul(-1).sub(10).equal()}}},[`${t}-container`]:{position:"relative",transition:`opacity ${e.motionDurationSlow}`,"&::after":{position:"absolute",top:0,insetInlineEnd:0,bottom:0,insetInlineStart:0,zIndex:10,width:"100%",height:"100%",background:e.colorBgContainer,opacity:0,transition:`all ${e.motionDurationSlow}`,content:'""',pointerEvents:"none"}},[`${t}-blur`]:{clear:"both",opacity:.5,userSelect:"none",pointerEvents:"none","&::after":{opacity:.4,pointerEvents:"auto"}}},"&-tip":{color:e.spinDotDefault},[`${t}-dot-holder`]:{width:"1em",height:"1em",fontSize:e.dotSize,display:"inline-block",transition:`transform ${e.motionDurationSlow} ease, opacity ${e.motionDurationSlow} ease`,transformOrigin:"50% 50%",lineHeight:1,color:e.colorPrimary,"&-hidden":{transform:"scale(0.3)",opacity:0}},[`${t}-dot-progress`]:{position:"absolute",inset:0},[`${t}-dot`]:{position:"relative",display:"inline-block",fontSize:e.dotSize,width:"1em",height:"1em","&-item":{position:"absolute",display:"block",width:r(e.dotSize).sub(r(e.marginXXS).div(2)).div(2).equal(),height:r(e.dotSize).sub(r(e.marginXXS).div(2)).div(2).equal(),background:"currentColor",borderRadius:"100%",transform:"scale(0.75)",transformOrigin:"50% 50%",opacity:.3,animationName:h,animationDuration:"1s",animationIterationCount:"infinite",animationTimingFunction:"linear",animationDirection:"alternate","&:nth-child(1)":{top:0,insetInlineStart:0,animationDelay:"0s"},"&:nth-child(2)":{top:0,insetInlineEnd:0,animationDelay:"0.4s"},"&:nth-child(3)":{insetInlineEnd:0,bottom:0,animationDelay:"0.8s"},"&:nth-child(4)":{bottom:0,insetInlineStart:0,animationDelay:"1.2s"}},"&-spin":{transform:"rotate(45deg)",animationName:b,animationDuration:"1.2s",animationIterationCount:"infinite",animationTimingFunction:"linear"},"&-circle":{strokeLinecap:"round",transition:["stroke-dashoffset","stroke-dasharray","stroke","stroke-width","opacity"].map(t=>`${t} ${e.motionDurationSlow} ease`).join(","),fillOpacity:0,stroke:"currentcolor"},"&-circle-bg":{stroke:e.colorFillSecondary}},[`&-sm ${t}-dot`]:{"&, &-holder":{fontSize:e.dotSizeSM}},[`&-sm ${t}-dot-holder`]:{i:{width:r(r(e.dotSizeSM).sub(r(e.marginXXS).div(2))).div(2).equal(),height:r(r(e.dotSizeSM).sub(r(e.marginXXS).div(2))).div(2).equal()}},[`&-lg ${t}-dot`]:{"&, &-holder":{fontSize:e.dotSizeLG}},[`&-lg ${t}-dot-holder`]:{i:{width:r(r(e.dotSizeLG).sub(e.marginXXS)).div(2).equal(),height:r(r(e.dotSizeLG).sub(e.marginXXS)).div(2).equal()}},[`&${t}-show-text ${t}-text`]:{display:"block"}})}})((0,f.mergeToken)(e,{spinDotDefault:e.colorTextDescription})),e=>{let{controlHeightLG:t,controlHeight:r}=e;return{contentHeight:400,dotSize:t/2,dotSizeSM:.35*t,dotSizeLG:r}}),y=[[30,.05],[70,.03],[96,.01]];var C=function(e,t){var r={};for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&0>t.indexOf(o)&&(r[o]=e[o]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols)for(var n=0,o=Object.getOwnPropertySymbols(e);nt.indexOf(o[n])&&Object.prototype.propertyIsEnumerable.call(e,o[n])&&(r[o[n]]=e[o[n]]);return r};let x=e=>{var i;let{prefixCls:a,spinning:s=!0,delay:l=0,className:c,rootClassName:u,size:m="default",tip:p,wrapperClassName:g,style:f,children:h,fullscreen:b=!1,indicator:x,percent:w}=e,k=C(e,["prefixCls","spinning","delay","className","rootClassName","size","tip","wrapperClassName","style","children","fullscreen","indicator","percent"]),{getPrefixCls:E,direction:S,className:O,style:N,indicator:P}=(0,n.useComponentConfig)("spin"),$=E("spin",a),[j,M,T]=v($),[I,R]=r.useState(()=>s&&(!s||!l||!!Number.isNaN(Number(l)))),D=function(e,t){let[o,n]=r.useState(0),i=r.useRef(null),a="auto"===t;return r.useEffect(()=>(a&&e&&(n(0),i.current=setInterval(()=>{n(e=>{let t=100-e;for(let r=0;r{i.current&&(clearInterval(i.current),i.current=null)}),[a,e]),a?o:t}(I,w);r.useEffect(()=>{if(s){let e=function(e,t,r){var o,n=r||{},i=n.noTrailing,a=void 0!==i&&i,s=n.noLeading,l=void 0!==s&&s,c=n.debounceMode,u=void 0===c?void 0:c,d=!1,m=0;function p(){o&&clearTimeout(o)}function g(){for(var r=arguments.length,n=Array(r),i=0;ie?l?(m=Date.now(),a||(o=setTimeout(u?f:g,e))):g():!0!==a&&(o=setTimeout(u?f:g,void 0===u?e-c:e)))}return g.cancel=function(e){var t=(e||{}).upcomingOnly;p(),d=!(void 0!==t&&t)},g}(l,()=>{R(!0)},{debounceMode:false});return e(),()=>{var t;null==(t=null==e?void 0:e.cancel)||t.call(e)}}R(!1)},[l,s]);let L=r.useMemo(()=>void 0!==h&&!b,[h,b]),z=(0,o.default)($,O,{[`${$}-sm`]:"small"===m,[`${$}-lg`]:"large"===m,[`${$}-spinning`]:I,[`${$}-show-text`]:!!p,[`${$}-rtl`]:"rtl"===S},c,!b&&u,M,T),F=(0,o.default)(`${$}-container`,{[`${$}-blur`]:I}),A=null!=(i=null!=x?x:P)?i:t,B=Object.assign(Object.assign({},N),f),H=r.createElement("div",Object.assign({},k,{style:B,className:z,"aria-live":"polite","aria-busy":I}),r.createElement(d,{prefixCls:$,indicator:A,percent:D}),p&&(L||b)?r.createElement("div",{className:`${$}-text`},p):null);return j(L?r.createElement("div",Object.assign({},k,{className:(0,o.default)(`${$}-nested-loading`,g,M,T)}),I&&r.createElement("div",{key:"loading"},H),r.createElement("div",{className:F,key:"container"},h)):b?r.createElement("div",{className:(0,o.default)(`${$}-fullscreen`,{[`${$}-fullscreen-show`]:I},u,M,T)},H):H)};x.setDefaultIndicator=e=>{t=e},e.s(["default",0,x],244451)},482725,e=>{"use strict";var t=e.i(244451);e.s(["Spin",()=>t.default])},83733,233137,e=>{"use strict";let t,r;var o,n,i=e.i(247167),a=e.i(271645),s=e.i(544508),l=e.i(746725),c=e.i(835696);void 0!==i.default&&"u">typeof globalThis&&"u">typeof Element&&(null==(o=null==i.default?void 0:i.default.env)?void 0:o.NODE_ENV)==="test"&&void 0===(null==(n=null==Element?void 0:Element.prototype)?void 0:n.getAnimations)&&(Element.prototype.getAnimations=function(){return console.warn(["Headless UI has polyfilled `Element.prototype.getAnimations` for your tests.","Please install a proper polyfill e.g. `jsdom-testing-mocks`, to silence these warnings.","","Example usage:","```js","import { mockAnimationsApi } from 'jsdom-testing-mocks'","mockAnimationsApi()","```"].join(` +`)),[]});var u=((t=u||{})[t.None=0]="None",t[t.Closed=1]="Closed",t[t.Enter=2]="Enter",t[t.Leave=4]="Leave",t);function d(e){let t={};for(let r in e)!0===e[r]&&(t[`data-${r}`]="");return t}function m(e,t,r,o){let[n,i]=(0,a.useState)(r),{hasFlag:u,addFlag:d,removeFlag:m}=function(e=0){let[t,r]=(0,a.useState)(e),o=(0,a.useCallback)(e=>r(e),[t]),n=(0,a.useCallback)(e=>r(t=>t|e),[t]),i=(0,a.useCallback)(e=>(t&e)===e,[t]);return{flags:t,setFlag:o,addFlag:n,hasFlag:i,removeFlag:(0,a.useCallback)(e=>r(t=>t&~e),[r]),toggleFlag:(0,a.useCallback)(e=>r(t=>t^e),[r])}}(e&&n?3:0),p=(0,a.useRef)(!1),g=(0,a.useRef)(!1),f=(0,l.useDisposables)();return(0,c.useIsoMorphicEffect)(()=>{var n;if(e){if(r&&i(!0),!t){r&&d(3);return}return null==(n=null==o?void 0:o.start)||n.call(o,r),function(e,{prepare:t,run:r,done:o,inFlight:n}){let i=(0,s.disposables)();return function(e,{inFlight:t,prepare:r}){if(null!=t&&t.current)return r();let o=e.style.transition;e.style.transition="none",r(),e.offsetHeight,e.style.transition=o}(e,{prepare:t,inFlight:n}),i.nextFrame(()=>{r(),i.requestAnimationFrame(()=>{i.add(function(e,t){var r,o;let n=(0,s.disposables)();if(!e)return n.dispose;let i=!1;n.add(()=>{i=!0});let a=null!=(o=null==(r=e.getAnimations)?void 0:r.call(e).filter(e=>e instanceof CSSTransition))?o:[];return 0===a.length?t():Promise.allSettled(a.map(e=>e.finished)).then(()=>{i||t()}),n.dispose}(e,o))})}),i.dispose}(t,{inFlight:p,prepare(){g.current?g.current=!1:g.current=p.current,p.current=!0,g.current||(r?(d(3),m(4)):(d(4),m(2)))},run(){g.current?r?(m(3),d(4)):(m(4),d(3)):r?m(1):d(1)},done(){var e;g.current&&"function"==typeof t.getAnimations&&t.getAnimations().length>0||(p.current=!1,m(7),r||i(!1),null==(e=null==o?void 0:o.end)||e.call(o,r))}})}},[e,r,t,f]),e?[n,{closed:u(1),enter:u(2),leave:u(4),transition:u(2)||u(4)}]:[r,{closed:void 0,enter:void 0,leave:void 0,transition:void 0}]}e.s(["transitionDataAttributes",()=>d,"useTransition",()=>m],83733);let p=(0,a.createContext)(null);p.displayName="OpenClosedContext";var g=((r=g||{})[r.Open=1]="Open",r[r.Closed=2]="Closed",r[r.Closing=4]="Closing",r[r.Opening=8]="Opening",r);function f(){return(0,a.useContext)(p)}function h({value:e,children:t}){return a.default.createElement(p.Provider,{value:e},t)}function b({children:e}){return a.default.createElement(p.Provider,{value:null},e)}e.s(["OpenClosedProvider",()=>h,"ResetOpenClosedProvider",()=>b,"State",()=>g,"useOpenClosed",()=>f],233137)},888288,e=>{"use strict";var t=e.i(271645);let r=(e,r)=>{let o=void 0!==r,[n,i]=(0,t.useState)(e);return[o?r:n,e=>{o||i(e)}]};e.s(["default",()=>r])},233538,e=>{"use strict";function t(e){let t=e.parentElement,r=null;for(;t&&!(t instanceof HTMLFieldSetElement);)t instanceof HTMLLegendElement&&(r=t),t=t.parentElement;let o=(null==t?void 0:t.getAttribute("disabled"))==="";return!(o&&function(e){if(!e)return!1;let t=e.previousElementSibling;for(;null!==t;){if(t instanceof HTMLLegendElement)return!1;t=t.previousElementSibling}return!0}(r))&&o}e.s(["isDisabledReactIssue7711",()=>t])},503269,214520,601893,694421,140721,942803,35889,722678,e=>{"use strict";var t=e.i(271645),r=e.i(914189);function o(e,o,n){let[i,a]=(0,t.useState)(n),s=void 0!==e,l=(0,t.useRef)(s),c=(0,t.useRef)(!1),u=(0,t.useRef)(!1);return!s||l.current||c.current?s||!l.current||u.current||(u.current=!0,l.current=s,console.error("A component is changing from controlled to uncontrolled. This may be caused by the value changing from a defined value to undefined, which should not happen.")):(c.current=!0,l.current=s,console.error("A component is changing from uncontrolled to controlled. This may be caused by the value changing from undefined to a defined value, which should not happen.")),[s?e:i,(0,r.useEvent)(e=>(s||a(e),null==o?void 0:o(e)))]}function n(e){let[r]=(0,t.useState)(e);return r}e.s(["useControllable",()=>o],503269),e.s(["useDefaultValue",()=>n],214520);let i=(0,t.createContext)(void 0);function a(){return(0,t.useContext)(i)}e.s(["useDisabled",()=>a],601893);var s=e.i(174080),l=e.i(746725);function c(e={},t=null,r=[]){for(let[o,n]of Object.entries(e))!function e(t,r,o){if(Array.isArray(o))for(let[n,i]of o.entries())e(t,u(r,n.toString()),i);else o instanceof Date?t.push([r,o.toISOString()]):"boolean"==typeof o?t.push([r,o?"1":"0"]):"string"==typeof o?t.push([r,o]):"number"==typeof o?t.push([r,`${o}`]):null==o?t.push([r,""]):c(o,r,t)}(r,u(t,o),n);return r}function u(e,t){return e?e+"["+t+"]":t}function d(e){var t,r;let o=null!=(t=null==e?void 0:e.form)?t:e.closest("form");if(o){for(let t of o.elements)if(t!==e&&("INPUT"===t.tagName&&"submit"===t.type||"BUTTON"===t.tagName&&"submit"===t.type||"INPUT"===t.nodeName&&"image"===t.type))return void t.click();null==(r=o.requestSubmit)||r.call(o)}}e.s(["attemptSubmit",()=>d,"objectToFormEntries",()=>c],694421);var m=e.i(700020),p=e.i(2788);let g=(0,t.createContext)(null);function f({children:e}){let r=(0,t.useContext)(g);if(!r)return t.default.createElement(t.default.Fragment,null,e);let{target:o}=r;return o?(0,s.createPortal)(t.default.createElement(t.default.Fragment,null,e),o):null}function h({data:e,form:r,disabled:o,onReset:n,overrides:i}){let[a,s]=(0,t.useState)(null),u=(0,l.useDisposables)();return(0,t.useEffect)(()=>{if(n&&a)return u.addEventListener(a,"reset",n)},[a,r,n]),t.default.createElement(f,null,t.default.createElement(b,{setForm:s,formId:r}),c(e).map(([e,n])=>t.default.createElement(p.Hidden,{features:p.HiddenFeatures.Hidden,...(0,m.compact)({key:e,as:"input",type:"hidden",hidden:!0,readOnly:!0,form:r,disabled:o,name:e,value:n,...i})})))}function b({setForm:e,formId:r}){return(0,t.useEffect)(()=>{if(r){let t=document.getElementById(r);t&&e(t)}},[e,r]),r?null:t.default.createElement(p.Hidden,{features:p.HiddenFeatures.Hidden,as:"input",type:"hidden",hidden:!0,readOnly:!0,ref:t=>{if(!t)return;let r=t.closest("form");r&&e(r)}})}e.s(["FormFields",()=>h],140721);let v=(0,t.createContext)(void 0);function y(){return(0,t.useContext)(v)}e.s(["useProvidedId",()=>y],942803);var C=e.i(835696),x=e.i(294316);let w=(0,t.createContext)(null);function k(){var e,r;return null!=(r=null==(e=(0,t.useContext)(w))?void 0:e.value)?r:void 0}function E(){let[e,o]=(0,t.useState)([]);return[e.length>0?e.join(" "):void 0,(0,t.useMemo)(()=>function(e){let n=(0,r.useEvent)(e=>(o(t=>[...t,e]),()=>o(t=>{let r=t.slice(),o=r.indexOf(e);return -1!==o&&r.splice(o,1),r}))),i=(0,t.useMemo)(()=>({register:n,slot:e.slot,name:e.name,props:e.props,value:e.value}),[n,e.slot,e.name,e.props,e.value]);return t.default.createElement(w.Provider,{value:i},e.children)},[o])]}w.displayName="DescriptionContext";let S=Object.assign((0,m.forwardRefWithAs)(function(e,r){let o=(0,t.useId)(),n=a(),{id:i=`headlessui-description-${o}`,...s}=e,l=function e(){let r=(0,t.useContext)(w);if(null===r){let t=Error("You used a component, but it is not inside a relevant parent.");throw Error.captureStackTrace&&Error.captureStackTrace(t,e),t}return r}(),c=(0,x.useSyncRefs)(r);(0,C.useIsoMorphicEffect)(()=>l.register(i),[i,l.register]);let u=n||!1,d=(0,t.useMemo)(()=>({...l.slot,disabled:u}),[l.slot,u]),p={ref:c,...l.props,id:i};return(0,m.useRender)()({ourProps:p,theirProps:s,slot:d,defaultTag:"p",name:l.name||"Description"})}),{});e.s(["Description",()=>S,"useDescribedBy",()=>k,"useDescriptions",()=>E],35889);let O=(0,t.createContext)(null);function N(e){var r,o,n;let i=null!=(o=null==(r=(0,t.useContext)(O))?void 0:r.value)?o:void 0;return(null!=(n=null==e?void 0:e.length)?n:0)>0?[i,...e].filter(Boolean).join(" "):i}function P({inherit:e=!1}={}){let o=N(),[n,i]=(0,t.useState)([]),a=e?[o,...n].filter(Boolean):n;return[a.length>0?a.join(" "):void 0,(0,t.useMemo)(()=>function(e){let o=(0,r.useEvent)(e=>(i(t=>[...t,e]),()=>i(t=>{let r=t.slice(),o=r.indexOf(e);return -1!==o&&r.splice(o,1),r}))),n=(0,t.useMemo)(()=>({register:o,slot:e.slot,name:e.name,props:e.props,value:e.value}),[o,e.slot,e.name,e.props,e.value]);return t.default.createElement(O.Provider,{value:n},e.children)},[i])]}O.displayName="LabelContext";let $=Object.assign((0,m.forwardRefWithAs)(function(e,o){var n;let i=(0,t.useId)(),s=function e(){let r=(0,t.useContext)(O);if(null===r){let t=Error("You used a
); diff --git a/ui/litellm-dashboard/src/app/page.tsx b/ui/litellm-dashboard/src/app/page.tsx index 2a3448d390c..28b8d81cc56 100644 --- a/ui/litellm-dashboard/src/app/page.tsx +++ b/ui/litellm-dashboard/src/app/page.tsx @@ -43,7 +43,7 @@ import { isJwtExpired } from "@/utils/jwtUtils"; import { isAdminRole } from "@/utils/roles"; import { QueryClient, QueryClientProvider } from "@tanstack/react-query"; import { jwtDecode } from "jwt-decode"; -import { useSearchParams, ReadonlyURLSearchParams } from "next/navigation"; +import { useSearchParams } from "next/navigation"; import { Suspense, useEffect, useState } from "react"; import { ConfigProvider, theme } from "antd"; diff --git a/ui/litellm-dashboard/src/components/AIHub/ModelHubTable.test.tsx b/ui/litellm-dashboard/src/components/AIHub/ModelHubTable.test.tsx index a88ce0d7938..ee59ac84ece 100644 --- a/ui/litellm-dashboard/src/components/AIHub/ModelHubTable.test.tsx +++ b/ui/litellm-dashboard/src/components/AIHub/ModelHubTable.test.tsx @@ -1,8 +1,13 @@ import * as networking from "@/components/networking"; -import { render, screen, waitFor } from "@testing-library/react"; import { afterEach, describe, expect, it, vi } from "vitest"; +import { renderWithProviders, screen, waitFor } from "../../../tests/test-utils"; import ModelHubTable from "./ModelHubTable"; +const mockUseUISettings = vi.hoisted(() => vi.fn()); +const mockGetCookie = vi.hoisted(() => vi.fn()); +const mockCheckTokenValidity = vi.hoisted(() => vi.fn()); +const mockRouterReplace = vi.hoisted(() => vi.fn()); + vi.mock("@/components/networking", () => ({ getUiConfig: vi.fn(), modelHubPublicModelsCall: vi.fn(), @@ -11,11 +16,13 @@ vi.mock("@/components/networking", () => ({ getProxyBaseUrl: vi.fn(() => "http://localhost:4000"), getAgentsList: vi.fn(), fetchMCPServers: vi.fn(), + getUiSettings: vi.fn(), + getClaudeCodeMarketplace: vi.fn(), })); vi.mock("next/navigation", () => ({ useRouter: () => ({ - replace: vi.fn(), + replace: mockRouterReplace, }), })); @@ -23,11 +30,82 @@ vi.mock("@/components/public_model_hub", () => ({ default: () =>
Public Model Hub
, })); +vi.mock("@/app/(dashboard)/hooks/uiSettings/useUISettings", () => ({ + useUISettings: mockUseUISettings, +})); + +vi.mock("@/utils/cookieUtils", () => ({ + getCookie: mockGetCookie, +})); + +vi.mock("@/utils/jwtUtils", () => ({ + checkTokenValidity: mockCheckTokenValidity, +})); + describe("ModelHubTable", () => { afterEach(() => { vi.clearAllMocks(); }); + // Reusable helper function to setup mocks for auth redirect tests + const setupAuthRedirectTest = ( + requireAuth: boolean, + tokenValue: string | null, + isTokenValid: boolean + ) => { + mockUseUISettings.mockReturnValue({ + data: { + values: { + require_auth_for_public_ai_hub: requireAuth, + }, + }, + isLoading: false, + }); + mockGetCookie.mockReturnValue(tokenValue); + mockCheckTokenValidity.mockReturnValue(isTokenValid); + mockRouterReplace.mockClear(); + + // Setup other required mocks + vi.mocked(networking.getUiConfig).mockResolvedValue({ + server_root_path: "/", + proxy_base_url: "http://localhost:4000", + auto_redirect_to_sso: false, + admin_ui_disabled: false, + sso_configured: false, + }); + vi.mocked(networking.modelHubPublicModelsCall).mockResolvedValue([]); + vi.mocked(networking.getUiSettings).mockResolvedValue({ + values: { + require_auth_for_public_ai_hub: requireAuth, + }, + }); + }; + + // Reusable test function for auth redirect scenarios + const testAuthRedirect = ( + requireAuth: boolean, + tokenValue: string | null, + isTokenValid: boolean, + shouldRedirect: boolean, + description: string + ) => { + it(description, async () => { + setupAuthRedirectTest(requireAuth, tokenValue, isTokenValid); + + renderWithProviders( + + ); + + await waitFor(() => { + if (shouldRedirect) { + expect(mockRouterReplace).toHaveBeenCalledWith("http://localhost:4000/ui/login"); + } else { + expect(mockRouterReplace).not.toHaveBeenCalled(); + } + }); + }); + }; + it("should render", async () => { vi.mocked(networking.modelHubCall).mockResolvedValue({ data: [], @@ -39,8 +117,15 @@ describe("ModelHubTable", () => { agents: [], }); vi.mocked(networking.fetchMCPServers).mockResolvedValue([]); + vi.mocked(networking.getUiSettings).mockResolvedValue({ + values: {}, + }); + mockUseUISettings.mockReturnValue({ + data: { values: {} }, + isLoading: false, + }); - render(); + renderWithProviders(); await waitFor(() => { expect(screen.getByText("AI Hub")).toBeInTheDocument(); @@ -56,10 +141,18 @@ describe("ModelHubTable", () => { proxy_base_url: "http://localhost:4000", auto_redirect_to_sso: false, admin_ui_disabled: false, + sso_configured: false, }); modelHubPublicModelsCallMock.mockResolvedValue([]); + vi.mocked(networking.getUiSettings).mockResolvedValue({ + values: {}, + }); + mockUseUISettings.mockReturnValue({ + data: { values: {} }, + isLoading: false, + }); - render(); + renderWithProviders(); await waitFor(() => { expect(getUiConfigMock).toHaveBeenCalled(); @@ -71,4 +164,56 @@ describe("ModelHubTable", () => { expect(getUiConfigCallOrder).toBeLessThan(modelHubPublicModelsCallOrder); }); + + describe("authentication redirect behavior", () => { + // Test cases where requireAuth is true - should redirect on invalid tokens + testAuthRedirect( + true, + null, + false, + true, + "should redirect to login when requireAuth is true and there is no token" + ); + + testAuthRedirect( + true, + "expired-token", + false, + true, + "should redirect to login when requireAuth is true and token is expired" + ); + + testAuthRedirect( + true, + "malformed-token", + false, + true, + "should redirect to login when requireAuth is true and token is malformed" + ); + + // Test cases where requireAuth is false - should NOT redirect regardless of token state + testAuthRedirect( + false, + null, + false, + false, + "should not redirect when requireAuth is false and there is no token" + ); + + testAuthRedirect( + false, + "expired-token", + false, + false, + "should not redirect when requireAuth is false and token is expired" + ); + + testAuthRedirect( + false, + "malformed-token", + false, + false, + "should not redirect when requireAuth is false and token is malformed" + ); + }); }); diff --git a/ui/litellm-dashboard/src/components/AIHub/ModelHubTable.tsx b/ui/litellm-dashboard/src/components/AIHub/ModelHubTable.tsx index 4843713e5a6..71b84e281df 100644 --- a/ui/litellm-dashboard/src/components/AIHub/ModelHubTable.tsx +++ b/ui/litellm-dashboard/src/components/AIHub/ModelHubTable.tsx @@ -27,6 +27,9 @@ import { Copy } from "lucide-react"; import { useRouter } from "next/navigation"; import React, { useCallback, useEffect, useState } from "react"; import { Prism as SyntaxHighlighter } from "react-syntax-highlighter"; +import { useUISettings } from "@/app/(dashboard)/hooks/uiSettings/useUISettings"; +import { checkTokenValidity } from "@/utils/jwtUtils"; +import { getCookie } from "@/utils/cookieUtils"; interface ModelHubTableProps { accessToken: string | null; @@ -76,6 +79,30 @@ const ModelHubTable: React.FC = ({ accessToken, publicPage, const [isMcpModalVisible, setIsMcpModalVisible] = useState(false); const [isMakeMcpPublicModalVisible, setIsMakeMcpPublicModalVisible] = useState(false); const router = useRouter(); + const { data: uiSettings, isLoading: isUISettingsLoading } = useUISettings(); + + // Check authentication requirement for public AI Hub + useEffect(() => { + // Only check when UI settings are loaded and this is a public page + if (isUISettingsLoading || !publicPage) { + return; + } + + const requireAuth = uiSettings?.values?.require_auth_for_public_ai_hub; + + // If require_auth_for_public_ai_hub is true, verify token + if (requireAuth === true) { + const token = getCookie("token"); + const isTokenValid = checkTokenValidity(token); + + // If token is invalid, redirect to login + if (!isTokenValid) { + router.replace(`${getProxyBaseUrl()}/ui/login`); + return; + } + } + // If require_auth_for_public_ai_hub is false, allow public access (no change) + }, [isUISettingsLoading, publicPage, uiSettings, router]); useEffect(() => { const fetchData = async (accessToken: string) => { diff --git a/ui/litellm-dashboard/src/components/CreateUserButton.test.tsx b/ui/litellm-dashboard/src/components/CreateUserButton.test.tsx new file mode 100644 index 00000000000..829b73734dc --- /dev/null +++ b/ui/litellm-dashboard/src/components/CreateUserButton.test.tsx @@ -0,0 +1,264 @@ +import { render, screen, waitFor, within } from "@testing-library/react"; +import userEvent from "@testing-library/user-event"; +import { QueryClient, QueryClientProvider } from "@tanstack/react-query"; +import { describe, it, expect, vi, beforeEach } from "vitest"; +import { CreateUserButton } from "./CreateUserButton"; +import * as networking from "./networking"; +import NotificationsManager from "./molecules/notifications_manager"; + +vi.mock("./networking", () => ({ + userCreateCall: vi.fn(), + modelAvailableCall: vi.fn().mockResolvedValue({ data: [] }), + invitationCreateCall: vi.fn(), + getProxyUISettings: vi.fn().mockResolvedValue({ + PROXY_BASE_URL: null, + PROXY_LOGOUT_URL: null, + DEFAULT_TEAM_DISABLED: false, + SSO_ENABLED: false, + }), + getProxyBaseUrl: vi.fn().mockReturnValue("http://localhost"), +})); + +vi.mock("./bulk_create_users_button", () => ({ + default: () =>
Bulk Create Users
, +})); + +const mockUserCreateCall = vi.mocked(networking.userCreateCall); +const mockInvitationCreateCall = vi.mocked(networking.invitationCreateCall); +const mockGetProxyUISettings = vi.mocked(networking.getProxyUISettings); +const mockNotificationsManager = vi.mocked(NotificationsManager); + +const createQueryClient = () => + new QueryClient({ + defaultOptions: { queries: { retry: false, gcTime: 0 } }, + }); + +const defaultProps = { + userID: "123", + accessToken: "token", + teams: [], + possibleUIRoles: null as Record> | null, +}; + +function renderWithProviders(ui: React.ReactElement) { + const qc = createQueryClient(); + return render({ui}); +} + +describe("CreateUserButton", { timeout: 20000 }, () => { + beforeEach(() => { + vi.clearAllMocks(); + mockGetProxyUISettings.mockResolvedValue({ + PROXY_BASE_URL: null, + PROXY_LOGOUT_URL: null, + DEFAULT_TEAM_DISABLED: false, + SSO_ENABLED: false, + }); + }); + + it("should render the create user form when embedded", () => { + renderWithProviders( + , + ); + expect(screen.getByRole("button", { name: /create user/i })).toBeInTheDocument(); + }); + + it("should render the invite user button when not embedded", async () => { + renderWithProviders(); + await waitFor(() => { + expect(screen.getByRole("button", { name: /\+ invite user/i })).toBeInTheDocument(); + }); + }); + + it("should open the invite modal when invite user button is clicked", async () => { + const user = userEvent.setup(); + renderWithProviders(); + await waitFor(() => { + expect(screen.getByRole("button", { name: /\+ invite user/i })).toBeInTheDocument(); + }); + await user.click(screen.getByRole("button", { name: /\+ invite user/i })); + const dialog = screen.getByRole("dialog", { name: /invite user/i }); + expect(dialog).toBeInTheDocument(); + expect(within(dialog).getByRole("button", { name: /invite user/i })).toBeInTheDocument(); + }); + + it("should display email invitations info message in embedded mode", () => { + renderWithProviders(); + expect(screen.getByText("Email invitations")).toBeInTheDocument(); + }); + + it("should display user role options when possibleUIRoles is provided", async () => { + const possibleUIRoles = { + proxy_admin: { ui_label: "Admin", description: "Full access" }, + proxy_user: { ui_label: "User", description: "Limited access" }, + }; + renderWithProviders( + , + ); + await userEvent.click(screen.getByRole("combobox", { name: /user role/i })); + expect(screen.getByText("Admin")).toBeInTheDocument(); + expect(screen.getByText("User")).toBeInTheDocument(); + }); + + it("should call userCreateCall when form is submitted in embedded mode", async () => { + const user = userEvent.setup(); + mockUserCreateCall.mockResolvedValue({ data: { user_id: "new-user-123" } }); + mockInvitationCreateCall.mockResolvedValue({ + id: "inv-1", + user_id: "new-user-123", + has_user_setup_sso: false, + } as any); + + renderWithProviders( + , + ); + + await user.type(screen.getByLabelText(/user email/i), "test@example.com"); + await user.click(screen.getByRole("combobox", { name: /user role/i })); + await user.click(screen.getByText("User")); + await user.click(screen.getByRole("button", { name: /create user/i })); + + await waitFor(() => { + expect(mockUserCreateCall).toHaveBeenCalledWith("token", null, expect.objectContaining({ + user_email: "test@example.com", + user_role: "proxy_user", + })); + }); + }); + + it("should call onUserCreated callback when user is created in embedded mode", async () => { + const user = userEvent.setup(); + const onUserCreated = vi.fn(); + mockUserCreateCall.mockResolvedValue({ data: { user_id: "new-user-456" } }); + + renderWithProviders( + , + ); + + await user.type(screen.getByLabelText(/user email/i), "embedded@example.com"); + await user.click(screen.getByRole("combobox", { name: /user role/i })); + await user.click(screen.getByText("User")); + await user.click(screen.getByRole("button", { name: /create user/i })); + + await waitFor(() => { + expect(onUserCreated).toHaveBeenCalledWith("new-user-456"); + }); + }); + + it("should show success notification when user is created successfully in standalone mode", async () => { + const user = userEvent.setup(); + mockUserCreateCall.mockResolvedValue({ data: { user_id: "new-user-789" } }); + mockInvitationCreateCall.mockResolvedValue({ + id: "inv-2", + user_id: "new-user-789", + has_user_setup_sso: false, + } as any); + + renderWithProviders( + , + ); + + await waitFor(() => { + expect(screen.getByRole("button", { name: /\+ invite user/i })).toBeInTheDocument(); + }); + await user.click(screen.getByRole("button", { name: /\+ invite user/i })); + + const dialog = screen.getByRole("dialog", { name: /invite user/i }); + await user.type(within(dialog).getByLabelText(/user email/i), "standalone@example.com"); + await user.click(within(dialog).getByRole("combobox", { name: /global proxy role/i })); + await user.click(screen.getByText("User")); + await user.click(within(dialog).getByRole("button", { name: /invite user/i })); + + await waitFor(() => { + expect(mockNotificationsManager.success).toHaveBeenCalledWith("API user Created"); + }); + }); + + it("should show error notification when user creation fails", async () => { + const user = userEvent.setup(); + mockUserCreateCall.mockRejectedValue({ response: { data: { detail: "Email already exists" } } }); + + renderWithProviders( + , + ); + + await user.type(screen.getByLabelText(/user email/i), "duplicate@example.com"); + await user.click(screen.getByRole("combobox", { name: /user role/i })); + await user.click(screen.getByText("User")); + await user.click(screen.getByRole("button", { name: /create user/i })); + + await waitFor(() => { + expect(mockNotificationsManager.fromBackend).toHaveBeenCalledWith("Email already exists"); + }); + }); + + it("should show info notification when making API call", async () => { + const user = userEvent.setup(); + mockUserCreateCall.mockResolvedValue({ data: { user_id: "new-user" } }); + mockInvitationCreateCall.mockResolvedValue({ + id: "inv-3", + user_id: "new-user", + has_user_setup_sso: false, + } as any); + + renderWithProviders( + , + ); + + await user.type(screen.getByLabelText(/user email/i), "info@example.com"); + await user.click(screen.getByRole("combobox", { name: /user role/i })); + await user.click(screen.getByText("User")); + await user.click(screen.getByRole("button", { name: /create user/i })); + + await waitFor(() => { + expect(mockNotificationsManager.info).toHaveBeenCalledWith("Making API Call"); + }); + }); + + it("should close modal when cancel is clicked in standalone mode", async () => { + const user = userEvent.setup(); + renderWithProviders(); + + await waitFor(() => { + expect(screen.getByRole("button", { name: /\+ invite user/i })).toBeInTheDocument(); + }); + await user.click(screen.getByRole("button", { name: /\+ invite user/i })); + expect(screen.getByRole("dialog", { name: /invite user/i })).toBeInTheDocument(); + + const dialog = screen.getByRole("dialog", { name: /invite user/i }); + await user.click(within(dialog).getByRole("button", { name: /close/i })); + expect(screen.queryByRole("dialog")).not.toBeInTheDocument(); + }); + + it("should show onboarding modal when user is created and SSO is disabled", async () => { + const user = userEvent.setup(); + mockUserCreateCall.mockResolvedValue({ data: { user_id: "sso-user" } }); + mockInvitationCreateCall.mockResolvedValue({ + id: "inv-sso", + user_id: "sso-user", + has_user_setup_sso: false, + } as any); + + renderWithProviders( + , + ); + + await waitFor(() => { + expect(screen.getByRole("button", { name: /\+ invite user/i })).toBeInTheDocument(); + }); + await user.click(screen.getByRole("button", { name: /\+ invite user/i })); + + const dialog = screen.getByRole("dialog", { name: /invite user/i }); + await user.type(within(dialog).getByLabelText(/user email/i), "sso@example.com"); + await user.click(within(dialog).getByRole("combobox", { name: /global proxy role/i })); + await user.click(screen.getByText("User")); + await user.click(within(dialog).getByRole("button", { name: /invite user/i })); + + await waitFor(() => { + expect(mockInvitationCreateCall).toHaveBeenCalledWith("token", "sso-user"); + }); + await waitFor(() => { + expect(mockNotificationsManager.success).toHaveBeenCalledWith("API user Created"); + }); + }); +}); diff --git a/ui/litellm-dashboard/src/components/create_user_button.tsx b/ui/litellm-dashboard/src/components/CreateUserButton.tsx similarity index 80% rename from ui/litellm-dashboard/src/components/create_user_button.tsx rename to ui/litellm-dashboard/src/components/CreateUserButton.tsx index da155b042a3..d463ced08f6 100644 --- a/ui/litellm-dashboard/src/components/create_user_button.tsx +++ b/ui/litellm-dashboard/src/components/CreateUserButton.tsx @@ -1,33 +1,29 @@ -import React, { useState, useEffect } from "react"; -import { Button, Modal, Form, Input, Select, Select as Select2 } from "antd"; -import { - Button as Button2, - Text, - TextInput, - SelectItem, - Accordion, - AccordionHeader, - AccordionBody, - Title, -} from "@tremor/react"; -import OnboardingModal from "./onboarding_link"; -import { InvitationLink } from "./onboarding_link"; -import { - userCreateCall, - modelAvailableCall, - invitationCreateCall, - getProxyUISettings, - getProxyBaseUrl, -} from "./networking"; -import BulkCreateUsers from "./bulk_create_users_button"; -const { Option } = Select; -import { Tooltip } from "antd"; -import { InfoCircleOutlined } from "@ant-design/icons"; -import { getModelDisplayName } from "./key_team_helpers/fetch_available_models_team_key"; +import { InfoCircleOutlined, UserAddOutlined } from "@ant-design/icons"; import { useQueryClient } from "@tanstack/react-query"; -import NotificationsManager from "./molecules/notifications_manager"; +import { + Accordion, + AccordionBody, + AccordionHeader, + Button as Button2, + SelectItem, + TextInput, +} from "@tremor/react"; +import { Alert, Button, Form, Input, Modal, Select, Select as Select2, Space, Tooltip, Typography } from "antd"; +import React, { useEffect, useState } from "react"; +import BulkCreateUsers from "./bulk_create_users_button"; import TeamDropdown from "./common_components/team_dropdown"; - +import { getModelDisplayName } from "./key_team_helpers/fetch_available_models_team_key"; +import NotificationsManager from "./molecules/notifications_manager"; +import { + getProxyBaseUrl, + getProxyUISettings, + invitationCreateCall, + modelAvailableCall, + userCreateCall, +} from "./networking"; +import OnboardingModal, { InvitationLink } from "./onboarding_link"; +const { Option } = Select; +const { Text, Link, Title } = Typography; // Helper function to generate UUID compatible across all environments const generateUUID = (): string => { if (typeof crypto !== "undefined" && crypto.randomUUID) { @@ -58,14 +54,8 @@ interface UISettings { SSO_ENABLED: boolean; } -const Createuser: React.FC = ({ - userID, - accessToken, - teams, - possibleUIRoles, - onUserCreated, - isEmbedded = false, -}) => { +export const CreateUserButton: React.FC = ({ + userID, accessToken, teams, possibleUIRoles, onUserCreated, isEmbedded = false }) => { const queryClient = useQueryClient(); const [uiSettings, setUISettings] = useState(null); const [form] = Form.useForm(); @@ -75,28 +65,18 @@ const Createuser: React.FC = ({ const [isInvitationLinkModalVisible, setIsInvitationLinkModalVisible] = useState(false); const [invitationLinkData, setInvitationLinkData] = useState(null); const [baseUrl, setBaseUrl] = useState(null); - // get all models useEffect(() => { const fetchData = async () => { try { - const userRole = "any"; // You may need to get the user role dynamically + const userRole = "any"; const modelDataResponse = await modelAvailableCall(accessToken, userID, userRole); - // Assuming modelDataResponse.data contains an array of model objects with a 'model_name' property const availableModels = []; for (let i = 0; i < modelDataResponse.data.length; i++) { const model = modelDataResponse.data[i]; availableModels.push(model.id); } - console.log("Model data response:", modelDataResponse.data); - console.log("Available models:", availableModels); - - // Assuming modelDataResponse.data contains an array of model names setUserModels(availableModels); - - // get ui settings const uiSettingsResponse = await getProxyUISettings(accessToken); - console.log("uiSettingsResponse:", uiSettingsResponse); - setUISettings(uiSettingsResponse); } catch (error) { console.error("Error fetching model data:", error); @@ -104,9 +84,8 @@ const Createuser: React.FC = ({ }; setBaseUrl(getProxyBaseUrl()); - - fetchData(); // Call the function to fetch model data when the component mounts - }, []); // Empty dependency array to run only once + fetchData(); + }, []); const handleOk = () => { setIsModalVisible(false); @@ -126,25 +105,19 @@ const Createuser: React.FC = ({ setIsModalVisible(true); } if ((!formValues.models || formValues.models.length === 0) && formValues.user_role !== "proxy_admin") { - console.log("formValues.user_role", formValues.user_role); - // If models is empty or undefined, set it to "no-default-models" formValues.models = ["no-default-models"]; } - console.log("formValues in create user:", formValues); const response = await userCreateCall(accessToken, null, formValues); await queryClient.invalidateQueries({ queryKey: ["userList"] }); - console.log("user create Response:", response); setApiuser(true); const user_id = response.data?.user_id || response.user_id; - // Call the callback if provided (for embedded mode) if (onUserCreated && isEmbedded) { onUserCreated(user_id); form.resetFields(); - return; // Skip the invitation flow when embedded + return; } - // only do invite link flow if sso is not enabled if (!uiSettings?.SSO_ENABLED) { invitationCreateCall(accessToken, user_id).then((data) => { data.has_user_setup_sso = false; @@ -184,6 +157,21 @@ const Createuser: React.FC = ({ if (isEmbedded) { return (
+ + New users receive an email invite only when an email integration (SMTP, Resend, or SendGrid) is configured. + {" "} + + Learn how to set up email notifications + + + } + type="info" + showIcon + className="mb-4" + /> @@ -194,9 +182,9 @@ const Createuser: React.FC = ({
{ui_label}{" "} -

+ {description} -

+
))} @@ -234,16 +222,33 @@ const Createuser: React.FC = ({ onOk={handleOk} onCancel={handleCancel} > - Create a User who can own keys + + Create a User who can own keys + + New users receive an email invite only when an email integration (SMTP, Resend, or SendGrid) is configured. + {" "} + + Learn how to set up email notifications + + + } + type="info" + showIcon + className="mb-4" + /> + - + Global Proxy Role{" "} - + @@ -254,12 +259,12 @@ const Createuser: React.FC = ({ {possibleUIRoles && Object.entries(possibleUIRoles).map(([role, { ui_label, description }]) => ( -
- {ui_label}{" "} -

- {description} -

-
+ + {ui_label} + + + {" - "}{description} +
))} @@ -279,7 +284,7 @@ const Createuser: React.FC = ({
- Personal Key Creation + Personal Key Creation = ({
- +
@@ -326,6 +331,4 @@ const Createuser: React.FC = ({ )}
); -}; - -export default Createuser; +}; \ No newline at end of file diff --git a/ui/litellm-dashboard/src/components/ModelSelect/ModelSelect.tsx b/ui/litellm-dashboard/src/components/ModelSelect/ModelSelect.tsx index 2b7399c4565..74b2619f7f3 100644 --- a/ui/litellm-dashboard/src/components/ModelSelect/ModelSelect.tsx +++ b/ui/litellm-dashboard/src/components/ModelSelect/ModelSelect.tsx @@ -200,6 +200,7 @@ export const ModelSelect = (props: ModelSelectProps) => { }, ]} mode="multiple" + placeholder="Select Models" allowClear maxTagCount="responsive" maxTagPlaceholder={(omittedValues) => ( diff --git a/ui/litellm-dashboard/src/components/ModelSelect/PaginatedModelSelect/PaginatedModelSelect.test.tsx b/ui/litellm-dashboard/src/components/ModelSelect/PaginatedModelSelect/PaginatedModelSelect.test.tsx new file mode 100644 index 00000000000..b91f97885e6 --- /dev/null +++ b/ui/litellm-dashboard/src/components/ModelSelect/PaginatedModelSelect/PaginatedModelSelect.test.tsx @@ -0,0 +1,301 @@ +import { screen, waitFor } from "@testing-library/react"; +import userEvent from "@testing-library/user-event"; +import { beforeEach, describe, expect, it, vi } from "vitest"; +import { renderWithProviders } from "../../../../tests/test-utils"; +import { PaginatedModelSelect } from "./PaginatedModelSelect"; + +const mockFetchNextPage = vi.fn(); + +vi.mock("@/app/(dashboard)/hooks/models/useModels", () => ({ + useInfiniteModelInfo: vi.fn(), +})); + +vi.mock("@tanstack/react-pacer/debouncer", () => { + const React = require("react"); + return { + useDebouncedState: (initial: string) => { + const [value, setValue] = React.useState(initial); + return [value, setValue]; + }, + }; +}); + +import { useInfiniteModelInfo } from "@/app/(dashboard)/hooks/models/useModels"; + +const mockUseInfiniteModelInfo = vi.mocked(useInfiniteModelInfo); + +const mockPagesWithModels = { + pages: [ + { + data: [ + { model_name: "GPT-4", model_info: { id: "model-1" } }, + { model_name: "Claude-3", model_info: { id: "model-2" } }, + ], + total_count: 2, + current_page: 1, + total_pages: 1, + size: 50, + }, + ], +}; + +const mockEmptyPages = { + pages: [{ data: [], total_count: 0, current_page: 1, total_pages: 1, size: 50 }], +}; + +describe("PaginatedModelSelect", () => { + const mockOnChange = vi.fn(); + + const defaultHookReturn = { + data: mockPagesWithModels, + fetchNextPage: mockFetchNextPage, + hasNextPage: false, + isFetchingNextPage: false, + isLoading: false, + }; + + beforeEach(() => { + vi.clearAllMocks(); + mockUseInfiniteModelInfo.mockReturnValue(defaultHookReturn as any); + }); + + it("should render", () => { + renderWithProviders(); + + expect(screen.getByRole("combobox")).toBeInTheDocument(); + expect(screen.getByText("Select a model")).toBeInTheDocument(); + }); + + it("should display custom placeholder when provided", () => { + renderWithProviders( + , + ); + + expect(screen.getByText("Choose model")).toBeInTheDocument(); + }); + + it("should display model options when data is loaded", async () => { + renderWithProviders(); + + const combobox = screen.getByRole("combobox"); + await userEvent.click(combobox); + + await waitFor(() => { + expect(screen.getByRole("option", { name: "GPT-4 (model-1)" })).toBeInTheDocument(); + expect(screen.getByRole("option", { name: "Claude-3 (model-2)" })).toBeInTheDocument(); + }); + }); + + it("should call onChange when user selects a model", async () => { + const user = userEvent.setup({ delay: null }); + renderWithProviders(); + + const combobox = screen.getByRole("combobox"); + await user.click(combobox); + + const visibleOption = await screen.findByTitle("GPT-4 (model-1)"); + await user.click(visibleOption); + + await waitFor(() => { + expect(mockOnChange).toHaveBeenCalledWith("model-1"); + }); + }); + + it("should display selected value when value prop is provided", async () => { + renderWithProviders( + , + ); + + const combobox = screen.getByRole("combobox"); + await userEvent.click(combobox); + + await waitFor(() => { + expect(screen.getByRole("option", { name: "GPT-4 (model-1)" })).toBeInTheDocument(); + }); + }); + + it("should show loading state when isLoading is true", () => { + mockUseInfiniteModelInfo.mockReturnValue({ + ...defaultHookReturn, + isLoading: true, + } as any); + + renderWithProviders(); + + expect(screen.getByRole("combobox")).toHaveAttribute("aria-expanded", "false"); + }); + + it("should pass pageSize to useInfiniteModelInfo", () => { + renderWithProviders(); + + expect(mockUseInfiniteModelInfo).toHaveBeenCalledWith(25, undefined); + }); + + it("should pass search to useInfiniteModelInfo when user types", async () => { + const user = userEvent.setup(); + renderWithProviders(); + + const combobox = screen.getByRole("combobox"); + await user.click(combobox); + await user.keyboard("gpt"); + + await waitFor(() => { + expect(mockUseInfiniteModelInfo).toHaveBeenCalledWith(50, "gpt"); + }); + }); + + it("should have scroll container for infinite loading when hasNextPage is true", async () => { + mockUseInfiniteModelInfo.mockReturnValue({ + ...defaultHookReturn, + hasNextPage: true, + isFetchingNextPage: false, + } as any); + + renderWithProviders(); + + const combobox = screen.getByRole("combobox"); + await userEvent.click(combobox); + + await waitFor(() => { + expect(screen.getByRole("option", { name: "GPT-4 (model-1)" })).toBeInTheDocument(); + }); + + const scrollableContainer = document.querySelector( + ".ant-select-dropdown .rc-virtual-list-holder", + ); + expect(scrollableContainer).toBeInTheDocument(); + expect(scrollableContainer).toHaveAttribute("style"); + }); + + it("should deduplicate models with same id across pages", async () => { + mockUseInfiniteModelInfo.mockReturnValue({ + ...defaultHookReturn, + data: { + pages: [ + { + data: [ + { model_name: "GPT-4", model_info: { id: "model-1" } }, + { model_name: "GPT-4 Dupe", model_info: { id: "model-1" } }, + ], + total_count: 2, + current_page: 1, + total_pages: 1, + size: 50, + }, + ], + }, + fetchNextPage: mockFetchNextPage, + hasNextPage: false, + isFetchingNextPage: false, + isLoading: false, + } as any); + + renderWithProviders(); + + const combobox = screen.getByRole("combobox"); + await userEvent.click(combobox); + + await waitFor(() => { + const model1Options = screen.queryAllByRole("option", { name: /model-1/ }); + expect(model1Options.length).toBe(1); + }); + }); + + it("should skip models without model_info id", async () => { + mockUseInfiniteModelInfo.mockReturnValue({ + ...defaultHookReturn, + data: { + pages: [ + { + data: [ + { model_name: "Valid Model", model_info: { id: "valid-id" } }, + { model_name: "No ID", model_info: null }, + { model_name: "Empty ID", model_info: { id: "" } }, + ], + total_count: 3, + current_page: 1, + total_pages: 1, + size: 50, + }, + ], + }, + fetchNextPage: mockFetchNextPage, + hasNextPage: false, + isFetchingNextPage: false, + isLoading: false, + } as any); + + renderWithProviders(); + + const combobox = screen.getByRole("combobox"); + await userEvent.click(combobox); + + await waitFor(() => { + expect(screen.getByRole("option", { name: "Valid Model (valid-id)" })).toBeInTheDocument(); + expect(screen.queryByRole("option", { name: "No ID" })).not.toBeInTheDocument(); + expect(screen.queryByRole("option", { name: "Empty ID" })).not.toBeInTheDocument(); + }); + }); + + it("should show model ID only when model_name is empty", async () => { + mockUseInfiniteModelInfo.mockReturnValue({ + ...defaultHookReturn, + data: { + pages: [ + { + data: [{ model_name: "", model_info: { id: "id-only" } }], + total_count: 1, + current_page: 1, + total_pages: 1, + size: 50, + }, + ], + }, + fetchNextPage: mockFetchNextPage, + hasNextPage: false, + isFetchingNextPage: false, + isLoading: false, + } as any); + + renderWithProviders(); + + const combobox = screen.getByRole("combobox"); + await userEvent.click(combobox); + + await waitFor(() => { + expect(screen.getByRole("option", { name: "id-only" })).toBeInTheDocument(); + }); + }); + + it("should respect allowClear prop", () => { + renderWithProviders( + , + ); + + expect(screen.getByRole("combobox")).toBeInTheDocument(); + }); + + it("should respect disabled prop", () => { + renderWithProviders(); + + const combobox = screen.getByRole("combobox"); + expect(combobox.closest(".ant-select")).toHaveClass("ant-select-disabled"); + }); + + it("should not call fetchNextPage when hasNextPage is false", async () => { + mockUseInfiniteModelInfo.mockReturnValue({ + ...defaultHookReturn, + hasNextPage: false, + } as any); + + renderWithProviders(); + + await userEvent.click(screen.getByRole("combobox")); + + await waitFor(() => { + expect(screen.getByRole("option", { name: "GPT-4 (model-1)" })).toBeInTheDocument(); + }); + + expect(mockFetchNextPage).not.toHaveBeenCalled(); + }); +}); diff --git a/ui/litellm-dashboard/src/components/ModelSelect/PaginatedModelSelect/PaginatedModelSelect.tsx b/ui/litellm-dashboard/src/components/ModelSelect/PaginatedModelSelect/PaginatedModelSelect.tsx new file mode 100644 index 00000000000..9b22fd1bd87 --- /dev/null +++ b/ui/litellm-dashboard/src/components/ModelSelect/PaginatedModelSelect/PaginatedModelSelect.tsx @@ -0,0 +1,143 @@ +import { useInfiniteModelInfo } from "@/app/(dashboard)/hooks/models/useModels"; +import { LoadingOutlined } from "@ant-design/icons"; +import { useDebouncedState } from "@tanstack/react-pacer/debouncer"; +import { Select, Space, Typography } from "antd"; +import { useMemo, useState, type UIEvent } from "react"; + +const { Text } = Typography; + +export interface PaginatedModelSelectProps { + value?: string; + onChange?: (value: string) => void; + placeholder?: string; + style?: React.CSSProperties; + pageSize?: number; + allowClear?: boolean; + disabled?: boolean; +} + +const SCROLL_THRESHOLD = 0.8; +const DEBOUNCE_MS = 300; + +export const PaginatedModelSelect = ({ + value, + onChange, + placeholder = "Select a model", + style, + pageSize = 50, + allowClear = true, + disabled = false, +}: PaginatedModelSelectProps) => { + const [searchInput, setSearchInput] = useState(""); + const [debouncedSearch, setDebouncedSearch] = useDebouncedState("", { + wait: DEBOUNCE_MS, + }); + + const { + data, + fetchNextPage, + hasNextPage, + isFetchingNextPage, + isLoading, + } = useInfiniteModelInfo(pageSize, debouncedSearch || undefined); + + const options = useMemo(() => { + if (!data?.pages) return []; + + const seen = new Set(); + const result: { label: string; value: string; modelName: string; modelId: string }[] = []; + + for (const page of data.pages) { + for (const model of page.data) { + const modelId = model.model_info?.id ?? ""; + const modelName = model.model_name ?? ""; + + // Dedupe by id - skip models without id (can't uniquely identify) + if (!modelId || seen.has(modelId)) continue; + seen.add(modelId); + + result.push({ + label: modelName ? `${modelName} (${modelId})` : modelId, + value: modelId, + modelName, + modelId, + }); + } + } + + return result; + }, [data]); + + const optionRender = (option: { data: { modelName: string; modelId: string; label: string } }) => { + const { modelName, modelId } = option.data; + + return ( + <> + {modelName ? ( + + + Model name: + {modelName} + + + Model ID: {modelId} + + + ) : ( + Model ID: {modelId} + )} + + ); + }; + + const handlePopupScroll = (e: UIEvent) => { + const target = e.currentTarget; + const scrollRatio = + (target.scrollTop + target.clientHeight) / target.scrollHeight; + + if (scrollRatio >= SCROLL_THRESHOLD && hasNextPage && !isFetchingNextPage) { + fetchNextPage(); + } + }; + + const handleSearch = (value: string) => { + setSearchInput(value); + setDebouncedSearch(value); + }; + + const handleChange = (v: string | string[] | null) => { + const normalized = + typeof v === "string" ? v : Array.isArray(v) ? v[0] ?? "" : ""; + onChange?.(normalized); + }; + + return ( + ({ - ), - getBudgetDurationLabel: vi.fn((value: string) => `Budget: ${value}`), -})); + ); + BudgetDurationDropdown.displayName = "BudgetDurationDropdown"; + return { + default: BudgetDurationDropdown, + getBudgetDurationLabel: vi.fn((value: string) => `Budget: ${value}`), + }; +}); vi.mock("./key_team_helpers/fetch_available_models_team_key", () => ({ getModelDisplayName: vi.fn((model: string) => model), })); -vi.mock("./ModelSelect/ModelSelect", () => ({ - ModelSelect: ({ value, onChange }: { value: string[]; onChange: (value: string[]) => void }) => ( +vi.mock("./ModelSelect/ModelSelect", () => { + const ModelSelect = ({ value, onChange }: { value: string[]; onChange: (value: string[]) => void }) => ( - ), -})); + ); + ModelSelect.displayName = "ModelSelect"; + return { ModelSelect }; +}); vi.mock("antd", async (importOriginal) => { const actual = await importOriginal(); @@ -101,22 +117,31 @@ vi.mock("antd", async (importOriginal) => { children, ); }; - SelectComponent.Option = ({ value: optionValue, children: optionChildren }: { value: string; children: React.ReactNode }) => + SelectComponent.displayName = "Select"; + const SelectOption = ({ value: optionValue, children: optionChildren }: { value: string; children: React.ReactNode }) => React.createElement("option", { value: optionValue }, optionChildren); + SelectOption.displayName = "SelectOption"; + SelectComponent.Option = SelectOption; + const Spin = ({ size }: { size?: string }) => React.createElement("div", { "data-testid": "spinner", "data-size": size }); + Spin.displayName = "Spin"; + const Switch = ({ checked, onChange }: { checked: boolean; onChange: (checked: boolean) => void }) => + React.createElement("input", { + type: "checkbox", + role: "switch", + checked: checked, + onChange: (e) => onChange(e.target.checked), + "aria-label": "Toggle switch", + }); + Switch.displayName = "Switch"; + const Paragraph = ({ children }: { children: React.ReactNode }) => React.createElement("p", {}, children); + Paragraph.displayName = "Paragraph"; return { ...actual, - Spin: ({ size }: { size?: string }) => React.createElement("div", { "data-testid": "spinner", "data-size": size }), - Switch: ({ checked, onChange }: { checked: boolean; onChange: (checked: boolean) => void }) => - React.createElement("input", { - type: "checkbox", - role: "switch", - checked: checked, - onChange: (e) => onChange(e.target.checked), - "aria-label": "Toggle switch", - }), + Spin, + Switch, Select: SelectComponent, Typography: { - Paragraph: ({ children }: { children: React.ReactNode }) => React.createElement("p", {}, children), + Paragraph, }, }; }); diff --git a/ui/litellm-dashboard/src/components/UsageIndicator.test.tsx b/ui/litellm-dashboard/src/components/UsageIndicator.test.tsx new file mode 100644 index 00000000000..8c7c15bc5a5 --- /dev/null +++ b/ui/litellm-dashboard/src/components/UsageIndicator.test.tsx @@ -0,0 +1,187 @@ +import React from "react"; +import { describe, it, expect, vi, beforeEach } from "vitest"; +import { render, screen, waitFor } from "@testing-library/react"; +import userEvent from "@testing-library/user-event"; +import UsageIndicator from "./UsageIndicator"; + +vi.mock("./networking", () => ({ + getRemainingUsers: vi.fn(), + getLicenseInfo: vi.fn().mockResolvedValue(null), +})); + +vi.mock("@/app/(dashboard)/hooks/useDisableUsageIndicator", () => ({ + useDisableUsageIndicator: vi.fn(() => false), +})); + +import { getRemainingUsers } from "./networking"; + +const mockGetRemainingUsers = vi.mocked(getRemainingUsers); + +const DEFAULT_USAGE_DATA = { + total_users: 100, + total_users_used: 1, + total_users_remaining: 99, + total_teams: null, + total_teams_used: 0, + total_teams_remaining: null, +}; + +describe("UsageIndicator", () => { + beforeEach(() => { + vi.clearAllMocks(); + mockGetRemainingUsers.mockResolvedValue(DEFAULT_USAGE_DATA); + }); + + it("should render when given access token and usage data loads", async () => { + render(); + + await screen.findByText("Usage"); + + expect(screen.getByText("Usage")).toBeInTheDocument(); + }); + + it("should not show Near limit when users usage is below 80% (1/100 -> 1%)", async () => { + render(); + + await screen.findByText("Usage"); + + expect(screen.queryByText("Near limit")).not.toBeInTheDocument(); + }); + + it("should render nothing when both total_users and total_teams are null", async () => { + mockGetRemainingUsers.mockResolvedValue({ + total_users: null, + total_teams: null, + total_users_used: 520, + total_teams_used: 4, + total_teams_remaining: null, + total_users_remaining: null, + }); + + render(); + + await waitFor(() => { + expect(screen.queryByText("Usage")).not.toBeInTheDocument(); + expect(screen.queryByText("Loading...")).not.toBeInTheDocument(); + }); + }); + + it("should show Near limit for Teams when at 80% usage (4/5)", async () => { + mockGetRemainingUsers.mockResolvedValue({ + total_users: null, + total_users_used: 0, + total_users_remaining: null, + total_teams: 5, + total_teams_used: 4, + total_teams_remaining: 1, + }); + + render(); + + await screen.findByText("Usage"); + + expect(screen.getByText("Teams")).toBeInTheDocument(); + expect(screen.getByText("Near limit")).toBeInTheDocument(); + }); + + it("should show Over limit for Users when usage exceeds 100% (105/100)", async () => { + mockGetRemainingUsers.mockResolvedValue({ + total_users: 100, + total_users_used: 105, + total_users_remaining: -5, + total_teams: null, + total_teams_used: 0, + total_teams_remaining: null, + }); + + render(); + + await screen.findByText("Usage"); + + expect(screen.getByText("Users")).toBeInTheDocument(); + expect(screen.getByText("Over limit")).toBeInTheDocument(); + }); + + it("should show Over limit for Teams when usage exceeds 100%", async () => { + mockGetRemainingUsers.mockResolvedValue({ + total_users: null, + total_users_used: 0, + total_users_remaining: null, + total_teams: 10, + total_teams_used: 12, + total_teams_remaining: -2, + }); + + render(); + + await screen.findByText("Usage"); + + expect(screen.getByText("Teams")).toBeInTheDocument(); + expect(screen.getByText("Over limit")).toBeInTheDocument(); + }); + + it("should render nothing when accessToken is null", () => { + render(); + + expect(mockGetRemainingUsers).not.toHaveBeenCalled(); + expect(screen.queryByText("Usage")).not.toBeInTheDocument(); + }); + + it("should render nothing when disableUsageIndicator is true", async () => { + const { useDisableUsageIndicator } = await import("@/app/(dashboard)/hooks/useDisableUsageIndicator"); + (useDisableUsageIndicator as ReturnType).mockReturnValue(true); + + render(); + + await waitFor(() => { + expect(screen.queryByText("Usage")).not.toBeInTheDocument(); + }); + + (useDisableUsageIndicator as ReturnType).mockReturnValue(false); + }); + + it("should show Loading while fetching", () => { + mockGetRemainingUsers.mockImplementation(() => new Promise(() => {})); + + render(); + + expect(screen.getByText("Loading...")).toBeInTheDocument(); + }); + + it("should show error message when fetch fails", async () => { + const consoleSpy = vi.spyOn(console, "error").mockImplementation(() => {}); + mockGetRemainingUsers.mockRejectedValue(new Error("Network error")); + + render(); + + expect(await screen.findByText("Failed to load usage data")).toBeInTheDocument(); + + consoleSpy.mockRestore(); + }); + + it("should minimize when user clicks minimize button", async () => { + const user = userEvent.setup(); + render(); + + await screen.findByText("Usage"); + + const minimizeButton = screen.getByTitle("Minimize"); + await user.click(minimizeButton); + + expect(screen.queryByText("Users")).not.toBeInTheDocument(); + expect(screen.getByTitle("Show usage details")).toBeInTheDocument(); + }); + + it("should restore from minimized when user clicks restore button", async () => { + const user = userEvent.setup(); + render(); + + await screen.findByText("Usage"); + + await user.click(screen.getByTitle("Minimize")); + await user.click(screen.getByTitle("Show usage details")); + + expect(screen.getByText("Usage")).toBeInTheDocument(); + expect(screen.getByText("Users")).toBeInTheDocument(); + }); +}); diff --git a/ui/litellm-dashboard/src/components/usage_indicator.tsx b/ui/litellm-dashboard/src/components/UsageIndicator.tsx similarity index 73% rename from ui/litellm-dashboard/src/components/usage_indicator.tsx rename to ui/litellm-dashboard/src/components/UsageIndicator.tsx index ed5e8e07555..47da9f78bdc 100644 --- a/ui/litellm-dashboard/src/components/usage_indicator.tsx +++ b/ui/litellm-dashboard/src/components/UsageIndicator.tsx @@ -1,7 +1,8 @@ +import { useDisableUsageIndicator } from "@/app/(dashboard)/hooks/useDisableUsageIndicator"; import { Badge } from "@tremor/react"; -import { AlertTriangle, ChevronDown, ChevronUp, Loader2, Minus, TrendingUp, UserCheck, Users } from "lucide-react"; +import { AlertTriangle, Calendar, ChevronDown, ChevronUp, Loader2, Minus, TrendingUp, UserCheck, Users } from "lucide-react"; import { useEffect, useState } from "react"; -import { getRemainingUsers } from "./networking"; +import { getRemainingUsers, getLicenseInfo, LicenseInfo } from "./networking"; // Simple utility function to combine class names const cn = (...classes: (string | boolean | undefined)[]) => { @@ -22,11 +23,35 @@ interface UsageData { total_teams_remaining: number | null; } +// Calculate days until expiration +const getDaysUntilExpiration = (expirationDate: string | null): number | null => { + if (!expirationDate) return null; + const expDate = new Date(expirationDate + 'T00:00:00Z'); // Force UTC midnight + const now = new Date(); + now.setHours(0, 0, 0, 0); // Normalize to local midnight + const diffTime = expDate.getTime() - now.getTime(); + const diffDays = Math.ceil(diffTime / (1000 * 60 * 60 * 24)); + return diffDays; +}; + +// Format expiration for display +const formatExpirationDisplay = (daysRemaining: number | null): string => { + if (daysRemaining === null) return "No expiration"; + if (daysRemaining < 0) return "Expired"; + if (daysRemaining === 0) return "Expires today"; + if (daysRemaining === 1) return "1 day remaining"; + if (daysRemaining < 30) return `${daysRemaining} days remaining`; + if (daysRemaining < 60) return "1 month remaining"; + const months = Math.floor(daysRemaining / 30); + return `${months} months remaining`; +}; + export default function UsageIndicator({ accessToken, width = 220 }: UsageIndicatorProps) { - const position = "bottom-left"; + const disableUsageIndicator = useDisableUsageIndicator(); const [isExpanded, setIsExpanded] = useState(false); const [isMinimized, setIsMinimized] = useState(false); const [data, setData] = useState(null); + const [licenseInfo, setLicenseInfo] = useState(null); const [isLoading, setIsLoading] = useState(false); const [error, setError] = useState(null); @@ -38,8 +63,12 @@ export default function UsageIndicator({ accessToken, width = 220 }: UsageIndica setError(null); try { - const result = await getRemainingUsers(accessToken); - setData(result); + const [usageResult, licenseResult] = await Promise.all([ + getRemainingUsers(accessToken), + getLicenseInfo(accessToken).catch(() => null), // Don't fail if license endpoint unavailable + ]); + setData(usageResult); + setLicenseInfo(licenseResult); } catch (err) { console.error("Failed to fetch usage data:", err); setError("Failed to load usage data"); @@ -51,6 +80,13 @@ export default function UsageIndicator({ accessToken, width = 220 }: UsageIndica fetchData(); }, [accessToken]); + // Calculate license expiration metrics + const daysUntilExpiration = licenseInfo?.expiration_date + ? getDaysUntilExpiration(licenseInfo.expiration_date) + : null; + const isLicenseExpired = daysUntilExpiration !== null && daysUntilExpiration < 0; + const isLicenseExpiringSoon = daysUntilExpiration !== null && daysUntilExpiration >= 0 && daysUntilExpiration < 30; + // Calculate derived values from data const getUsageMetrics = (data: UsageData | null) => { if (!data) { @@ -105,35 +141,38 @@ export default function UsageIndicator({ accessToken, width = 220 }: UsageIndica const { isOverLimit, isNearLimit, usagePercentage, userMetrics, teamMetrics } = getUsageMetrics(data); + // Include license status in overall status + const hasAnyIssue = isOverLimit || isNearLimit || isLicenseExpired || isLicenseExpiringSoon; + const hasError = isOverLimit || isLicenseExpired; + const hasWarning = (isNearLimit || isLicenseExpiringSoon) && !hasError; + const getStatusColor = () => { - if (isOverLimit) return "red"; - if (isNearLimit) return "yellow"; + if (hasError) return "red"; + if (hasWarning) return "yellow"; return "green"; }; const getStatusIcon = () => { - if (isOverLimit) return ; - if (isNearLimit) return ; + if (hasError) return ; + if (hasWarning) return ; return null; }; // Minimized view - just a small restore button const MinimizedView = () => { - const hasIssues = isOverLimit || isNearLimit; - return (
@@ -197,13 +245,13 @@ export default function UsageIndicator({ accessToken, width = 220 }: UsageIndica onClick={() => setIsExpanded(!isExpanded)} className={cn( "flex items-center gap-3 text-left hover:bg-gray-50 rounded-md px-0 py-1 transition-colors flex-1 min-w-0", - isOverLimit && "text-red-600", - isNearLimit && "text-yellow-600", + hasError && "text-red-600", + hasWarning && "text-yellow-600", )} > Usage Status - {(isOverLimit || isNearLimit) && ( + {hasAnyIssue && ( {getStatusIcon()} @@ -228,6 +276,28 @@ export default function UsageIndicator({ accessToken, width = 220 }: UsageIndica {/* Expanded details - simple and compact */} {isExpanded && (
+ {/* License expiration section */} + {licenseInfo?.has_license && licenseInfo.expiration_date && ( +
+
+ + License +
+
+ {isLicenseExpired ? ( + + ) : isLicenseExpiringSoon ? ( + + ) : null} + {formatExpirationDisplay(daysUntilExpiration)} +
+
+ )} + {/* Users section */} {data.total_users !== null && (
@@ -322,7 +392,6 @@ export default function UsageIndicator({ accessToken, width = 220 }: UsageIndica // Optimized CardStyleView for 220px width const CardStyleView = () => { if (isMinimized) { - const hasIssues = isOverLimit || isNearLimit; return ( @@ -415,6 +496,50 @@ export default function UsageIndicator({ accessToken, width = 220 }: UsageIndica {/* Compact stats optimized for 220px */}
+ {/* License expiration section */} + {licenseInfo?.has_license && licenseInfo.expiration_date && ( +
+
+ + License + + {isLicenseExpired ? "Expired" : isLicenseExpiringSoon ? "Expiring soon" : "OK"} + +
+
+ Status: + + {formatExpirationDisplay(daysUntilExpiration)} + +
+ {licenseInfo.license_type && ( +
+ Type: + {licenseInfo.license_type} +
+ )} +
+ )} + {/* Users section */} {data.total_users !== null && (
({ default: () =>
Endpoint Usage
, })); -vi.mock("./UsageViewSelect/UsageViewSelect", () => ({ - UsageViewSelect: ({ value, onChange }: any) => { - const React = require("react"); +vi.mock("./UsageViewSelect/UsageViewSelect", async () => { + const React = await import("react"); + const UsageViewSelect = ({ value, onChange }: any) => { return React.createElement( "select", { @@ -73,15 +73,19 @@ vi.mock("./UsageViewSelect/UsageViewSelect", () => ({ React.createElement("option", { value: "agent" }, "Agent Usage"), React.createElement("option", { value: "user-agent-activity" }, "User Agent Activity"), ); - }, -})); + }; + UsageViewSelect.displayName = "UsageViewSelect"; + return { UsageViewSelect }; +}); -vi.mock("../../shared/advanced_date_picker", () => ({ - default: ({ value, onValueChange }: any) => { - const React = require("react"); +vi.mock("../../shared/advanced_date_picker", async () => { + const React = await import("react"); + const AdvancedDatePicker = () => { return React.createElement("div", { "data-testid": "advanced-date-picker" }, "Date Picker"); - }, -})); + }; + AdvancedDatePicker.displayName = "AdvancedDatePicker"; + return { default: AdvancedDatePicker }; +}); vi.mock("../../user_agent_activity", () => ({ default: () =>
User Agent Activity
, diff --git a/ui/litellm-dashboard/src/components/VirtualKeysPage/VirtualKeysTable.test.tsx b/ui/litellm-dashboard/src/components/VirtualKeysPage/VirtualKeysTable.test.tsx index ef5bb2a0371..749396c82f3 100644 --- a/ui/litellm-dashboard/src/components/VirtualKeysPage/VirtualKeysTable.test.tsx +++ b/ui/litellm-dashboard/src/components/VirtualKeysPage/VirtualKeysTable.test.tsx @@ -542,3 +542,86 @@ it("should display 'Default Proxy Admin' for created_by when value is 'default_u expect(defaultProxyAdminElements.length).toBeGreaterThan(0); }); }); + + +it("should render table without crashing when models is null", async () => { + const keyWithNullModels = { + ...mockKey, + models: null as unknown as string[], + }; + + mockUseFilterLogic.mockReturnValue({ + filters: { + "Team ID": "", + "Organization ID": "", + "Key Alias": "", + "User ID": "", + "Sort By": "created_at", + "Sort Order": "desc", + }, + filteredKeys: [keyWithNullModels], + allKeyAliases: ["test-key-alias"], + allTeams: [mockTeam], + allOrganizations: [mockOrganization], + handleFilterChange: vi.fn(), + handleFilterReset: vi.fn(), + }); + + const mockProps = { + teams: [mockTeam], + organizations: [mockOrganization], + onSortChange: vi.fn(), + currentSort: { + sortBy: "created_at", + sortOrder: "desc" as const, + }, + }; + + // This should not throw an error + renderWithProviders(); + + await waitFor(() => { + expect(screen.getByText("Test Key Alias")).toBeInTheDocument(); + }); +}); + +it("should render table without crashing when models is undefined", async () => { + const keyWithUndefinedModels = { + ...mockKey, + models: undefined as unknown as string[], + }; + + mockUseFilterLogic.mockReturnValue({ + filters: { + "Team ID": "", + "Organization ID": "", + "Key Alias": "", + "User ID": "", + "Sort By": "created_at", + "Sort Order": "desc", + }, + filteredKeys: [keyWithUndefinedModels], + allKeyAliases: ["test-key-alias"], + allTeams: [mockTeam], + allOrganizations: [mockOrganization], + handleFilterChange: vi.fn(), + handleFilterReset: vi.fn(), + }); + + const mockProps = { + teams: [mockTeam], + organizations: [mockOrganization], + onSortChange: vi.fn(), + currentSort: { + sortBy: "created_at", + sortOrder: "desc" as const, + }, + }; + + // This should not throw an error + renderWithProviders(); + + await waitFor(() => { + expect(screen.getByText("Test Key Alias")).toBeInTheDocument(); + }); +}); diff --git a/ui/litellm-dashboard/src/components/VirtualKeysPage/VirtualKeysTable.tsx b/ui/litellm-dashboard/src/components/VirtualKeysPage/VirtualKeysTable.tsx index 465b9b8fbe0..f7c47943e7e 100644 --- a/ui/litellm-dashboard/src/components/VirtualKeysPage/VirtualKeysTable.tsx +++ b/ui/litellm-dashboard/src/components/VirtualKeysPage/VirtualKeysTable.tsx @@ -727,7 +727,7 @@ export function VirtualKeysTable({ teams, organizations, onSortChange, currentSo whiteSpace: "pre-wrap", overflow: "hidden", }} - className={`py-0.5 max-h-8 overflow-hidden text-ellipsis whitespace-nowrap ${cell.column.id === "models" && (cell.getValue() as string[]).length > 3 ? "px-0" : ""}`} + className={`py-0.5 max-h-8 overflow-hidden text-ellipsis whitespace-nowrap ${cell.column.id === "models" && Array.isArray(cell.getValue()) && (cell.getValue() as string[]).length > 3 ? "px-0" : ""}`} > {flexRender(cell.column.columnDef.cell, cell.getContext())} diff --git a/ui/litellm-dashboard/src/components/activity_metrics.test.tsx b/ui/litellm-dashboard/src/components/activity_metrics.test.tsx index 02738a46666..308b4b395f7 100644 --- a/ui/litellm-dashboard/src/components/activity_metrics.test.tsx +++ b/ui/litellm-dashboard/src/components/activity_metrics.test.tsx @@ -34,8 +34,25 @@ vi.mock("antd", () => { ); PanelComponent.displayName = "Collapse.Panel"; CollapseComponent.Panel = PanelComponent; + const TableComponent = ({ dataSource, columns }: { dataSource?: unknown[]; columns?: { title: string }[] }) => ( + + + + {columns?.map((col, i) => ( + + ))} + + + + {dataSource?.map((_, i) => ( + + ))} + +
{col.title}
+ ); return { Collapse: CollapseComponent, + Table: TableComponent, }; }); @@ -95,6 +112,7 @@ const MOCK_TEAMS: Team[] = [ created_at: "2025-01-01", keys: [], members_with_roles: [], + spend: 0, }, { team_id: "team2", @@ -108,6 +126,7 @@ const MOCK_TEAMS: Team[] = [ created_at: "2025-01-01", keys: [], members_with_roles: [], + spend: 0, }, ]; @@ -141,6 +160,7 @@ const createMockModelActivityData = (label: string, overrides: Partial { expect(tokenElements.length).toBeGreaterThan(0); }); + it("should not display Top Virtual Keys section when model has no top_api_keys", () => { + render(); + expect(screen.queryByText("Top Virtual Keys by Spend")).not.toBeInTheDocument(); + }); + it("should display top API keys section when present", () => { const modelWithTopKeys: Record = { "gpt-4": { @@ -329,6 +355,58 @@ describe("ActivityMetrics", () => { expect(screen.getByText(/Team: team1/)).toBeInTheDocument(); }); + it("should display Model Usage when model has top_models", () => { + const modelWithTopModels: Record = { + "gpt-4": { + ...mockModelMetrics["gpt-4"], + top_models: [ + { + model: "gpt-4", + spend: 100.5, + requests: 100, + successful_requests: 95, + failed_requests: 5, + tokens: 50000, + }, + ], + }, + }; + + render(); + expect(screen.getByRole("heading", { name: "Model Usage" })).toBeInTheDocument(); + }); + + it("should display Spend per day in model section", () => { + render(); + expect(screen.getByText("Spend per day")).toBeInTheDocument(); + }); + + it("should display Requests per day in model section", () => { + render(); + expect(screen.getByText("Requests per day")).toBeInTheDocument(); + }); + + it("should display Success vs Failed Requests in model section", () => { + render(); + expect(screen.getByText("Success vs Failed Requests")).toBeInTheDocument(); + }); + + it("should sort empty string model key last in collapse order", () => { + const modelsWithEmptyKey: Record = { + "gpt-4": { ...mockModelMetrics["gpt-4"] }, + "": { + ...createMockModelActivityData(""), + label: "Unknown", + }, + }; + + render(); + const headings = screen.getAllByRole("heading", { level: 2 }); + const gpt4Index = headings.findIndex((h) => h.textContent?.includes("GPT-4")); + const unknownIndex = headings.findIndex((h) => h.textContent?.includes("Unknown")); + expect(gpt4Index).toBeLessThan(unknownIndex); + }); + it("should display average tokens per successful request", () => { render(); const avgTokensElements = screen.getAllByText(/avg per successful request/); @@ -962,6 +1040,73 @@ describe("processActivityData", () => { expect(result["gpt-4"].top_api_keys[4].spend).toBe(16.0); }); + it("should return empty object when results array is empty", () => { + const result = processActivityData({ results: [] }, "models"); + expect(result).toEqual({}); + }); + + it("should populate top_models for api_keys when models breakdown contains api_key_breakdown for that key", () => { + const dailyActivityWithModelsForKey: { results: DailyData[] } = { + results: [ + { + date: "2025-01-01", + metrics: EMPTY_SPEND_METRICS, + breakdown: { + models: { + "gpt-4": { + metrics: EMPTY_SPEND_METRICS, + metadata: {}, + api_key_breakdown: { + "api-key-hash-1": { + metrics: { + spend: 60.0, + prompt_tokens: 18000, + completion_tokens: 12000, + total_tokens: 30000, + api_requests: 60, + successful_requests: 57, + failed_requests: 3, + cache_read_input_tokens: 0, + cache_creation_input_tokens: 0, + }, + metadata: { key_alias: "key-alias-1", team_id: "team1" }, + }, + }, + }, + }, + model_groups: {}, + mcp_servers: {}, + providers: {}, + api_keys: { + "api-key-hash-1": { + metrics: { + spend: 60.0, + prompt_tokens: 18000, + completion_tokens: 12000, + total_tokens: 30000, + api_requests: 60, + successful_requests: 57, + failed_requests: 3, + cache_read_input_tokens: 0, + cache_creation_input_tokens: 0, + }, + metadata: { key_alias: "key-alias-1", team_id: "team1" }, + }, + }, + entities: {}, + }, + }, + ], + }; + + const result = processActivityData(dailyActivityWithModelsForKey, "api_keys", MOCK_TEAMS); + + expect(result["api-key-hash-1"].top_models).toHaveLength(1); + expect(result["api-key-hash-1"].top_models[0].model).toBe("gpt-4"); + expect(result["api-key-hash-1"].top_models[0].spend).toBe(60.0); + expect(result["api-key-hash-1"].top_models[0].requests).toBe(60); + }); + it("should not process api_key_breakdown when key is api_keys", () => { const dailyActivityWithBreakdown: { results: DailyData[] } = { results: [ @@ -1130,4 +1275,14 @@ describe("formatKeyLabel", () => { const result = formatKeyLabel(modelData, "actual-key", MOCK_TEAMS); expect(result).toBe("key-hash-actual-key (team: Test Team 1)"); }); + + it("should return key_alias with team_id when teams array is empty", () => { + const modelData = createMockKeyMetricWithMetadata({ + key_alias: "my-key", + team_id: "team1", + }); + + const result = formatKeyLabel(modelData, "my-key", []); + expect(result).toBe("my-key (team_id: team1)"); + }); }); diff --git a/ui/litellm-dashboard/src/components/activity_metrics.tsx b/ui/litellm-dashboard/src/components/activity_metrics.tsx index 61006fa6147..2337d41d8df 100644 --- a/ui/litellm-dashboard/src/components/activity_metrics.tsx +++ b/ui/litellm-dashboard/src/components/activity_metrics.tsx @@ -148,7 +148,6 @@ const ModelSection = ({ categories={["metrics.successful_requests", "metrics.failed_requests"]} colors={["green", "red"]} valueFormatter={valueFormatter} - stack customTooltip={CustomTooltip} showLegend={false} /> diff --git a/ui/litellm-dashboard/src/components/common_components/all_view.tsx b/ui/litellm-dashboard/src/components/common_components/all_view.tsx deleted file mode 100644 index 3da292c35c4..00000000000 --- a/ui/litellm-dashboard/src/components/common_components/all_view.tsx +++ /dev/null @@ -1,153 +0,0 @@ -import React from "react"; -import { - Table, - TableBody, - TableCell, - TableHead, - TableHeaderCell, - TableRow, - Text, - Badge, - Icon, - Card, -} from "@tremor/react"; -import { Tooltip } from "antd"; - -interface Column { - header: string; - accessor: string; - cellRenderer?: (value: any, row: any) => React.ReactNode; - width?: string; - style?: React.CSSProperties; -} - -interface Action { - icon?: React.ComponentType; - onClick: (item: T) => void; - condition?: () => boolean; - tooltip?: string; -} - -interface DeleteModalProps { - isOpen: boolean; - onConfirm: () => void; - onCancel: () => void; - title: string; - message: string; -} - -interface DataTableProps { - data: any[]; - columns: Column[]; - actions?: Action[]; - emptyMessage?: string; - deleteModal?: DeleteModalProps; - onItemClick?: (item: any) => void; -} - -const DataTable: React.FC = ({ - data, - columns, - actions, - emptyMessage = "No data available", - deleteModal, - onItemClick, -}) => { - const renderCell = (column: Column, row: any) => { - const value = row[column.accessor]; - - if (column.cellRenderer) { - return column.cellRenderer(value, row); - } - - // Default cell rendering based on value type - if (Array.isArray(value)) { - return ( -
- {value.length === 0 ? ( - - None - - ) : ( - value.map((item: any, index: number) => ( - - {String(item).length > 30 ? `${String(item).slice(0, 30)}...` : item} - - )) - )} -
- ); - } - - return value?.toString() || ""; - }; - - return ( - - - - - {columns.map((column, index) => ( - {column.header} - ))} - {actions && actions.length > 0 && Actions} - - - - - {data && data.length > 0 ? ( - data.map((row, rowIndex) => ( - - {columns.map((column, colIndex) => ( - - {column.accessor === "id" ? ( - {renderCell(column, row)} - ) : ( - renderCell(column, row) - )} - - ))} - {actions && actions.length > 0 && ( - - {actions.map( - (action, actionIndex) => - // @ts-ignore - action.condition?.(row) !== false && ( - - action.onClick(row)} - className="cursor-pointer mx-1" - /> - - ), - )} - - )} - - )) - ) : ( - - - {emptyMessage} - - - )} - -
-
- ); -}; - -export default DataTable; -export type { Action, Column, DataTableProps, DeleteModalProps }; diff --git a/ui/litellm-dashboard/src/components/common_components/chartUtils.test.tsx b/ui/litellm-dashboard/src/components/common_components/chartUtils.test.tsx new file mode 100644 index 00000000000..b924021863a --- /dev/null +++ b/ui/litellm-dashboard/src/components/common_components/chartUtils.test.tsx @@ -0,0 +1,382 @@ +import { render, screen } from "@testing-library/react"; +import { describe, expect, it } from "vitest"; +import { CustomLegend, CustomTooltip } from "./chartUtils"; +import type { CustomTooltipProps } from "@tremor/react"; +import { SpendMetrics } from "../UsagePage/types"; + +describe("CustomTooltip", () => { + const mockPayload = [ + { + dataKey: "metrics.total_tokens", + value: 1000, + color: "blue", + payload: { + date: "2024-01-15", + metrics: { + total_tokens: 1000, + prompt_tokens: 600, + completion_tokens: 400, + spend: 0.05, + api_requests: 10, + successful_requests: 9, + failed_requests: 1, + cache_read_input_tokens: 0, + cache_creation_input_tokens: 0, + } as SpendMetrics, + }, + }, + ]; + + it("should render", () => { + const props: CustomTooltipProps = { + active: true, + payload: mockPayload, + label: "2024-01-15", + }; + render(); + expect(screen.getByText("2024-01-15")).toBeInTheDocument(); + }); + + it("should return null when not active", () => { + const props: CustomTooltipProps = { + active: false, + payload: mockPayload, + label: "2024-01-15", + }; + const { container } = render(); + expect(container.firstChild).toBeNull(); + }); + + it("should return null when payload is empty", () => { + const props: CustomTooltipProps = { + active: true, + payload: [], + label: "2024-01-15", + }; + const { container } = render(); + expect(container.firstChild).toBeNull(); + }); + + it("should display formatted category names", () => { + const props: CustomTooltipProps = { + active: true, + payload: mockPayload, + label: "2024-01-15", + }; + render(); + expect(screen.getByText("Total Tokens")).toBeInTheDocument(); + }); + + it("should format category names by removing metrics prefix and replacing underscores", () => { + const payloadWithUnderscores = [ + { + dataKey: "metrics.prompt_tokens", + value: 600, + color: "green", + payload: { + date: "2024-01-15", + metrics: { + prompt_tokens: 600, + total_tokens: 1000, + completion_tokens: 400, + spend: 0.05, + api_requests: 10, + successful_requests: 9, + failed_requests: 1, + cache_read_input_tokens: 0, + cache_creation_input_tokens: 0, + } as SpendMetrics, + }, + }, + ]; + const props: CustomTooltipProps = { + active: true, + payload: payloadWithUnderscores, + label: "2024-01-15", + }; + render(); + expect(screen.getByText("Prompt Tokens")).toBeInTheDocument(); + }); + + it("should format spend values with dollar sign and two decimal places", () => { + const spendPayload = [ + { + dataKey: "metrics.spend", + value: 1234.567, + color: "red", + payload: { + date: "2024-01-15", + metrics: { + spend: 1234.567, + total_tokens: 1000, + prompt_tokens: 600, + completion_tokens: 400, + api_requests: 10, + successful_requests: 9, + failed_requests: 1, + cache_read_input_tokens: 0, + cache_creation_input_tokens: 0, + } as SpendMetrics, + }, + }, + ]; + const props: CustomTooltipProps = { + active: true, + payload: spendPayload, + label: "2024-01-15", + }; + render(); + expect(screen.getByText("$1,234.57")).toBeInTheDocument(); + }); + + it("should format non-spend numeric values with locale string", () => { + const props: CustomTooltipProps = { + active: true, + payload: mockPayload, + label: "2024-01-15", + }; + render(); + expect(screen.getByText("1,000")).toBeInTheDocument(); + }); + + it("should display N/A when value is undefined", () => { + const payloadWithUndefined = [ + { + dataKey: "metrics.nonexistent", + value: undefined, + color: "blue", + payload: { + date: "2024-01-15", + metrics: { + total_tokens: 1000, + prompt_tokens: 600, + completion_tokens: 400, + spend: 0.05, + api_requests: 10, + successful_requests: 9, + failed_requests: 1, + cache_read_input_tokens: 0, + cache_creation_input_tokens: 0, + } as SpendMetrics, + }, + }, + ]; + const props: CustomTooltipProps = { + active: true, + payload: payloadWithUndefined, + label: "2024-01-15", + }; + render(); + expect(screen.getByText("N/A")).toBeInTheDocument(); + }); + + it("should handle multiple payload items", () => { + const multiplePayload = [ + { + dataKey: "metrics.total_tokens", + value: 1000, + color: "blue", + payload: { + date: "2024-01-15", + metrics: { + total_tokens: 1000, + prompt_tokens: 600, + completion_tokens: 400, + spend: 0.05, + api_requests: 10, + successful_requests: 9, + failed_requests: 1, + cache_read_input_tokens: 0, + cache_creation_input_tokens: 0, + } as SpendMetrics, + }, + }, + { + dataKey: "metrics.spend", + value: 0.05, + color: "green", + payload: { + date: "2024-01-15", + metrics: { + total_tokens: 1000, + prompt_tokens: 600, + completion_tokens: 400, + spend: 0.05, + api_requests: 10, + successful_requests: 9, + failed_requests: 1, + cache_read_input_tokens: 0, + cache_creation_input_tokens: 0, + } as SpendMetrics, + }, + }, + ]; + const props: CustomTooltipProps = { + active: true, + payload: multiplePayload, + label: "2024-01-15", + }; + render(); + expect(screen.getByText("Total Tokens")).toBeInTheDocument(); + expect(screen.getByText("Spend")).toBeInTheDocument(); + }); + + it("should convert color names to hex values", () => { + const props: CustomTooltipProps = { + active: true, + payload: mockPayload, + label: "2024-01-15", + }; + const { container } = render(); + const colorIndicator = container.querySelector('span[style*="background-color"]'); + expect(colorIndicator).toHaveStyle({ backgroundColor: "#3b82f6" }); + }); + + it("should use hex color directly when color is not a known color name", () => { + const payloadWithHexColor = [ + { + dataKey: "metrics.total_tokens", + value: 1000, + color: "#ff0000", + payload: { + date: "2024-01-15", + metrics: { + total_tokens: 1000, + prompt_tokens: 600, + completion_tokens: 400, + spend: 0.05, + api_requests: 10, + successful_requests: 9, + failed_requests: 1, + cache_read_input_tokens: 0, + cache_creation_input_tokens: 0, + } as SpendMetrics, + }, + }, + ]; + const props: CustomTooltipProps = { + active: true, + payload: payloadWithHexColor, + label: "2024-01-15", + }; + const { container } = render(); + const colorIndicator = container.querySelector('span[style*="background-color"]'); + expect(colorIndicator).toHaveStyle({ backgroundColor: "#ff0000" }); + }); + + it("should skip items without dataKey", () => { + const payloadWithoutDataKey = [ + { + dataKey: undefined, + value: 1000, + color: "blue", + payload: { + date: "2024-01-15", + metrics: { + total_tokens: 1000, + prompt_tokens: 600, + completion_tokens: 400, + spend: 0.05, + api_requests: 10, + successful_requests: 9, + failed_requests: 1, + cache_read_input_tokens: 0, + cache_creation_input_tokens: 0, + } as SpendMetrics, + }, + }, + ]; + const props: CustomTooltipProps = { + active: true, + payload: payloadWithoutDataKey as any, + label: "2024-01-15", + }; + render(); + expect(screen.queryByText("Total Tokens")).not.toBeInTheDocument(); + }); + + it("should skip items without payload", () => { + const payloadWithoutPayload = [ + { + dataKey: "metrics.total_tokens", + value: 1000, + color: "blue", + payload: undefined, + }, + ]; + const props: CustomTooltipProps = { + active: true, + payload: payloadWithoutPayload as any, + label: "2024-01-15", + }; + render(); + expect(screen.queryByText("Total Tokens")).not.toBeInTheDocument(); + }); +}); + +describe("CustomLegend", () => { + it("should render", () => { + render(); + expect(screen.getByText("Total Tokens")).toBeInTheDocument(); + }); + + it("should display multiple categories", () => { + render( + , + ); + expect(screen.getByText("Total Tokens")).toBeInTheDocument(); + expect(screen.getByText("Spend")).toBeInTheDocument(); + expect(screen.getByText("Prompt Tokens")).toBeInTheDocument(); + }); + + it("should format category names by removing metrics prefix and replacing underscores", () => { + render(); + expect(screen.getByText("Api Requests")).toBeInTheDocument(); + }); + + it("should capitalize first letter of each word", () => { + render(); + expect(screen.getByText("Successful Requests")).toBeInTheDocument(); + }); + + it("should convert color names to hex values", () => { + const { container } = render(); + const colorIndicator = container.querySelector('span[style*="background-color"]'); + expect(colorIndicator).toHaveStyle({ backgroundColor: "#06b6d4" }); + }); + + it("should use hex color directly when color is not a known color name", () => { + const { container } = render(); + const colorIndicator = container.querySelector('span[style*="background-color"]'); + expect(colorIndicator).toHaveStyle({ backgroundColor: "#ff00ff" }); + }); + + it("should handle all supported color names", () => { + const colors = ["blue", "cyan", "indigo", "green", "red", "purple", "emerald"]; + const categories = colors.map((_, idx) => `metrics.category_${idx}`); + render(); + expect(screen.getByText("Category 0")).toBeInTheDocument(); + }); + + it("should match categories and colors by index", () => { + render( + , + ); + const { container } = render( + , + ); + const colorIndicators = container.querySelectorAll('span[style*="background-color"]'); + expect(colorIndicators[0]).toHaveStyle({ backgroundColor: "#3b82f6" }); + expect(colorIndicators[1]).toHaveStyle({ backgroundColor: "#22c55e" }); + expect(colorIndicators[2]).toHaveStyle({ backgroundColor: "#ef4444" }); + }); +}); diff --git a/ui/litellm-dashboard/src/components/common_components/default_org.tsx b/ui/litellm-dashboard/src/components/common_components/default_org.tsx deleted file mode 100644 index f50c59a556d..00000000000 --- a/ui/litellm-dashboard/src/components/common_components/default_org.tsx +++ /dev/null @@ -1,6 +0,0 @@ -import { Organization } from "../networking"; - -export const defaultOrg = { - organization_id: "default_organization", - organization_alias: "Default Organization", -} as Organization; diff --git a/ui/litellm-dashboard/src/components/common_components/user_form.tsx b/ui/litellm-dashboard/src/components/common_components/user_form.tsx deleted file mode 100644 index 3f7590ac590..00000000000 --- a/ui/litellm-dashboard/src/components/common_components/user_form.tsx +++ /dev/null @@ -1,59 +0,0 @@ -import React from "react"; -import { Select, TextInput } from "@tremor/react"; -import { Form, Select as AntSelect } from "antd"; -import TeamDropdown from "./team_dropdown"; -import { getPossibleUserRoles } from "../networking"; -import TextArea from "antd/es/input/TextArea"; - -interface UserFormProps { - form: any; - teams: any[] | null; - possibleUIRoles: null | Record>; - setPossibleUIRoles?: (roles: any) => void; - accessToken?: string; -} - -const UserForm: React.FC = ({ form, teams, possibleUIRoles, setPossibleUIRoles, accessToken }) => { - React.useEffect(() => { - // Fetch roles if they're not available and we have a setter - if (!possibleUIRoles && setPossibleUIRoles && accessToken) { - getPossibleUserRoles(accessToken).then((roles) => { - setPossibleUIRoles(roles); - }); - } - }, [possibleUIRoles, setPossibleUIRoles, accessToken]); - - return ( - <> - - - - - - - - - - - - - -